Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- renderer.domElement.addEventListener( 'dblclick', function( event ) {
- // ... other code snippet
- // VVV Add below lines
- if( !result ) return;
- const hitPoint = result.point;
- const backVec = hitPoint.clone().add( raycaster.ray.direction.clone().setLength( 10000 ) );
- const backVecH = backVec.projectOnPlane( new THREE.Vector3( 0, 1, 0 ) );
- backVecH.normalize();
- const backwardVec = backVecH.multiplyScalar( 5 );
- const newPos = creeper.position.clone().add( backwardVec );
- creeper.position.set( newPos.x, newPos.y, newPos.z );
- });
Advertisement
Add Comment
Please, Sign In to add comment