MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/MaterialX / animate

Function animate

javascript/MaterialXView/source/index.js:190–222  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

188}
189
190function animate()
191{
192 requestAnimationFrame(animate);
193 const scene = viewer.getScene();
194
195 // Compute FPS and update overlay every 1/2 second.
196 const now = performance.now();
197 frameCount++;
198 if (now - lastFrameTime >= 500) {
199 fps = Math.round((frameCount * 1000) / (now - lastFrameTime));
200 if (fpsOverlay && showFPS) {
201 fpsOverlay.innerText = `FPS: ${fps}`;
202 }
203 lastFrameTime = now;
204 frameCount = 0;
205 }
206
207 if (turntableEnabled)
208 {
209 turntableStep = (turntableStep + 1) % 360;
210 var turntableAngle = turntableStep * (360.0 / turntableSteps) / 180.0 * Math.PI;
211 scene._scene.rotation.y = turntableAngle;
212 }
213
214 scene.updateTimeUniforms();
215 renderer.render(scene.getScene(), scene.getCamera());
216
217 if (captureRequested)
218 {
219 captureFrame();
220 captureRequested = false;
221 }
222}
223
224function handleKeyEvents(event)
225{

Callers 1

initFunction · 0.85

Calls 5

captureFrameFunction · 0.85
updateTimeUniformsMethod · 0.80
getCameraMethod · 0.80
getSceneMethod · 0.45
renderMethod · 0.45

Tested by

no test coverage detected