Created
February 25, 2019 22:13
-
-
Save cdata/513d90b41b8fbc7eeb5339a49a841739 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getScene = (modelViewerElement) => { | |
return modelViewerElement[Object.getOwnPropertySymbols(modelViewerElement)[3]]; | |
}; | |
const getCameraControls = (modelViewerElement) => { | |
return modelViewerElement[Object.getOwnPropertySymbols(modelViewerElement)[21]]; | |
}; | |
const modelViewer = document.querySelector('model-viewer'); | |
const scene = getScene(modelViewer); | |
const cameraControls = getCameraControls(modelViewer); | |
const animate = () => { | |
// Camera object | |
const camera = scene.camera; | |
// Turntable object | |
const pivot = scene.pivot; | |
// Animation example: | |
pivot.rotation.y += Math.PI / 32.0; | |
// Always mark the scene as "dirty" so that it renders again: | |
scene.isDirty = true; | |
requestAnimationFrame(animate); | |
}; | |
animate(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment