Bläddra i källkod

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 år sedan
förälder
incheckning
6947c96776
1 ändrade filer med 13 tillägg och 0 borttagningar
  1. 13 0
      examples/css3d_molecules.html

+ 13 - 0
examples/css3d_molecules.html

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