yskang

threejs-minecraft-26

Apr 21st, 2020
810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. renderer.domElement.addEventListener( 'dblclick', function( event ) {
  2.     // ... other code snippet
  3.  
  4.     // VVV Add below lines
  5.  
  6.     if( !result ) return;
  7.  
  8.     const hitPoint = result.point;
  9.     const backVec = hitPoint.clone().add( raycaster.ray.direction.clone().setLength( 10000 ) );
  10.     const backVecH = backVec.projectOnPlane( new THREE.Vector3( 0, 1, 0 ) );
  11.     backVecH.normalize();
  12.  
  13.     const backwardVec = backVecH.multiplyScalar( 5 );
  14.     const newPos = creeper.position.clone().add( backwardVec );
  15.     creeper.position.set( newPos.x, newPos.y, newPos.z );
  16.  
  17. });
Advertisement
Add Comment
Please, Sign In to add comment