Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Crepper
- // ... other code snippet
- creeper.position.set( 0, 0, -15 );
- // ... other code snippet
- // Add Camera
- // ... other code snippet
- // Comment out these two lines
- //camera.position.set( 30, 30, 30 );
- //camera.lookAt( scene.position );
- // Add PhysicsEngine
- const physicsEngine = new PhysicsEngine();
- physicsEngine.initialize();
- physicsEngine.mock( scene, 30 );
- let groundShape = new CANNON.Plane();
- let groundCM = new CANNON.Material();
- const groundBody = new CANNON.Body({
- mass: 0,
- shape: groundShape,
- material: groundCM
- });
- // setFromAxisAngle ζθ½ x θ»Έ -90 εΊ¦
- groundBody.quaternion.setFromAxisAngle( new CANNON.Vec3( 1, 0, 0 ), -Math.PI / 2 );
- groundBody.position.set( 0, -7, 0 );
- physicsEngine.world.add( groundBody );
- // Add navigation tool
- // Common out the original one and add this line like following
- //const navTool = new NavigationTool(camera);
- const navTool = new NavigationTool( camera, physicsEngine.sphereBody );
- // ... other code snippet
- // Find this function and then ...
- function render() {
- // ... other code snippet
- // Common out the original one and add this line like following
- //navTool.update(scene);
- navTool.update( scene, () => {
- physicsEngine.update( navTool );
- });
- }
- // Common out this event handler
- // renderer.domElement.addEventListener('dblclick', function (event) {
- // const raycaster = new THREE.Raycaster();
- // const mouse = new THREE.Vector2();
- //
- // mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
- // mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
- //
- // raycaster.setFromCamera(mouse.clone(), camera);
- //
- // const intersects = raycaster.intersectObjects(creeper.children);
- //
- // console.log(intersects);
- //
- // const result = intersects[0];
- //
- // if (!result) return;
- //
- // console.log(result);
- //
- // 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);
- //
- // creeper.trigger();
- // });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement