Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // in index.js
- (function() {
- // ... other code snippet
- // Find this codes for creeper and comment them out
- //// Creeper
- // const creeper = new Creeper();
- // creeper.position.set( 0, 0, -15 );
- // // scene.add( creeper );
- // creeper.toggleAnimate();
- // Find this line and comment it out
- //plane.position.set( 0, -7, 0 );
- // Find this codes for camera, comment them out and add the following line
- //// Add camera
- //const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
- //camera.position.set( 30, 30, 30 );
- //camera.lookAt( scene.position );
- const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
- // Find this codes for PhysicsEngine, comment them out and add the following
- // const physicsEngine = new PhysicsEngine();
- // physicsEngine.initialize();
- // physicsEngine.mock(scene, 30);
- const physicsEngine = new PhysicsEngine( scene, camera );
- physicsEngine.initialize();
- physicsEngine.mock( 10 );
- // Find this line and comment it out
- //let groundCM = new CANNON.Material()
- // Find groundBody and change its material to physicsEngine.physicsMaterial like the below one
- groundBody = new CANNON.Body({
- mass: 0,
- shape: groundShape,
- material: physicsEngine.physicsMaterial
- });
- // 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 );
- // Here we start adding creeper back
- // Creeper
- const world = physicsEngine.world;
- let creeper = new Creeper( 0.19, 10, scene, world );
- // Find the render function
- function render() {
- // ... other code snippet
- // then find `navTool.update` and replace it with the below one
- navTool.update( scene, () => {
- physicsEngine.update(navTool);
- creeper.update();
- });
- // ... other code snippet
- // Find this line and comment it out
- //creeper.animate();
- }
- // ... other code snippet
- // Find this event callback and replace it with the following
- resetBtn.addEventListener( 'click', function() {
- creeper.dispose();
- creeper = new Creeper( 0.19, 10, scene, world );
- });
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement