Skip to content

Commit

Permalink
Merge pull request #21115 from takahirox/MissingTargetVectors
Browse files Browse the repository at this point in the history
Examples: Fix missing target vectors for .getWorldPosition()
  • Loading branch information
mrdoob committed Jan 20, 2021
2 parents e4fe6b8 + ab7b8e0 commit af3920a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/webxr_vr_handinput_cubes.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 ) {

Expand Down

0 comments on commit af3920a

Please sign in to comment.