Explorar el Código

Example: ammo / instancing, improve high refresh rate experience (#24425)

* improve high refresh rate experience

Elements are "respawned" too quickly on 120/240hz monitors, this locks that process to a 60hz interval.

* Update physics_ammo_instancing.html

Co-authored-by: Michael Herzog <[email protected]>
Caleb hace 3 años
padre
commit
9391eeb3f0
Se han modificado 1 ficheros con 13 adiciones y 11 borrados
  1. 13 11
      examples/physics_ammo_instancing.html

+ 13 - 11
examples/physics_ammo_instancing.html

@@ -137,26 +137,28 @@
 				controls.update();
 
 				animate();
+				
+				setInterval( () => {
 
-			}
+					let index = Math.floor( Math.random() * boxes.count );
 
-			function animate() {
+					position.set( 0, Math.random() + 1, 0 );
+					physics.setMeshPosition( boxes, position, index );
 
-				requestAnimationFrame( animate );
+					//
 
-				//
+					index = Math.floor( Math.random() * spheres.count );
 
-				let index = Math.floor( Math.random() * boxes.count );
+					position.set( 0, Math.random() + 1, 0 );
+					physics.setMeshPosition( spheres, position, index );
 
-				position.set( 0, Math.random() + 1, 0 );
-				physics.setMeshPosition( boxes, position, index );
+				}, 17 );
 
-				//
+			}
 
-				index = Math.floor( Math.random() * spheres.count );
+			function animate() {
 
-				position.set( 0, Math.random() + 1, 0 );
-				physics.setMeshPosition( spheres, position, index );
+				requestAnimationFrame( animate );
 
 				renderer.render( scene, camera );