浏览代码

Merge pull request #21115 from takahirox/MissingTargetVectors

Examples: Fix missing target vectors for .getWorldPosition()
Mr.doob 4 年之前
父节点
当前提交
af3920a168
共有 1 个文件被更改,包括 4 次插入1 次删除
  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 controllerGrip1, controllerGrip2;
 
+			const tmpVector1 = new THREE.Vector3();
+			const tmpVector2 = new THREE.Vector3();
+
 			let controls;
 
 			let grabbing = false;
@@ -205,7 +208,7 @@
 				for ( let i = 0; i < spheres.length; 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 ) {