Skip to content

Instantly share code, notes, and snippets.

@cdata
Created February 25, 2019 22:13
Show Gist options
  • Save cdata/513d90b41b8fbc7eeb5339a49a841739 to your computer and use it in GitHub Desktop.
Save cdata/513d90b41b8fbc7eeb5339a49a841739 to your computer and use it in GitHub Desktop.
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