Selaa lähdekoodia

Small optimization in CSS3D molecules example.

Don't need to update scene graph matrices (molecules don't change).

This has very little impact on performance though, bottleneck is not on JS side, profiler shows ~65% of time spent in "(program)".
alteredq 12 vuotta sitten
vanhempi
commit
6947c96776
1 muutettua tiedostoa jossa 13 lisäystä ja 0 poistoa
  1. 13 0
      examples/css3d_molecules.html

+ 13 - 0
examples/css3d_molecules.html

@@ -392,6 +392,10 @@
 						object.position.copy( position );
 						object.position.multiplyScalar( 75 );
 						object.billboard = true;
+
+						object.matrixAutoUpdate = false;
+						object.updateMatrix();
+
 						root.add( object );
 
 						objects.push( object );
@@ -432,6 +436,9 @@
 						object.matrix = objMatrix;
 						object.rotation.setEulerFromRotationMatrix( object.matrix, object.eulerOrder );
 
+						object.matrixAutoUpdate = false;
+						object.updateMatrix();
+
 						root.add( object );
 
 						objects.push( object );
@@ -449,9 +456,15 @@
 						joint.matrix.copy( objMatrix );
 						joint.rotation.setEulerFromRotationMatrix( joint.matrix, joint.eulerOrder );
 
+						joint.matrixAutoUpdate = false;
+						joint.updateMatrix();
+
 						var object = new THREE.CSS3DObject( bond );
 						object.rotation.y = Math.PI/2;
 
+						object.matrixAutoUpdate = false;
+						object.updateMatrix();
+
 						object.properties.bondLengthShort = bondLength + "px";
 						object.properties.bondLengthFull = ( bondLength + 55 ) + "px";