Browse Source

Examples: Fix missing target vectors for .getWorldPosition() in webxr_vr_handinput_cubes.html

Takahiro 4 years ago
parent
commit
ab7b8e0438
1 changed files with 4 additions and 1 deletions
  1. 4 1
      examples/webxr_vr_handinput_cubes.html

+ 4 - 1
examples/webxr_vr_handinput_cubes.html

@@ -27,6 +27,9 @@
 			let controller1, controller2;
 			let controller1, controller2;
 			let controllerGrip1, controllerGrip2;
 			let controllerGrip1, controllerGrip2;
 
 
+			const tmpVector1 = new THREE.Vector3();
+			const tmpVector2 = new THREE.Vector3();
+
 			let controls;
 			let controls;
 
 
 			let grabbing = false;
 			let grabbing = false;
@@ -205,7 +208,7 @@
 				for ( let i = 0; i < spheres.length; i ++ ) {
 				for ( let i = 0; i < spheres.length; i ++ ) {
 
 
 					const sphere = spheres[ i ];
 					const sphere = spheres[ i ];
-					const distance = indexTip.getWorldPosition().distanceTo( sphere.getWorldPosition() );
+					const distance = indexTip.getWorldPosition( tmpVector1 ).distanceTo( sphere.getWorldPosition( tmpVector2 ) );
 
 
 					if ( distance < sphere.geometry.boundingSphere.radius * sphere.scale.x ) {
 					if ( distance < sphere.geometry.boundingSphere.radius * sphere.scale.x ) {