2323 lightBlue : 0x9CBFE3
2424} ;
2525var camera_x ;
26+ var camera_y ;
27+ var camera_z_position ;
28+ var camera_z_look ;
2629var deg2Rad = Math . PI / 180 ;
2730
2831// Make a new world when the page is loaded.
@@ -73,6 +76,9 @@ function World() {
7376 function init ( ) {
7477 // Locate where the world is to be located on the screen.
7578 camera_x = 0 ;
79+ camera_y = 700 ;
80+ camera_z_position = - 1600 ;
81+ camera_z_look = - 100000 ;
7682 element = document . getElementById ( "world" ) ;
7783
7884 // Initialize the renderer.
@@ -97,11 +103,10 @@ function World() {
97103 1 ,
98104 120000
99105 ) ;
100- // camera.position.set(0, 1500, -2000);
101- // camera.lookAt(new THREE.Vector3(0, 600, -5000));
102106
103- camera . position . set ( 0 , 700 , - 1600 ) ;
104- camera . lookAt ( new THREE . Vector3 ( 0 , 650 , - 10000 ) ) ;
107+ //init camera for first time
108+ camera . position . set ( 0 , camera_y , camera_z_position ) ;
109+ camera . lookAt ( new THREE . Vector3 ( 0 , 650 , camera_z_look ) ) ;
105110 window . camera = camera ;
106111
107112 // Set up resizing capabilities.
@@ -127,17 +132,6 @@ function World() {
127132 scene . add ( cube ) ;
128133 } ) ;
129134
130- // var geometryLeft = new THREE.BoxGeometry(3000, 1000, 120000);
131- // const loaderLeft = new THREE.TextureLoader();
132- // loaderLeft.load("js/lava_text.jpg", (texture) => {
133- // const materialLeft = new THREE.MeshBasicMaterial({ map: texture });
134- // const cubeLeft = new THREE.Mesh(geometryLeft, materialLeft);
135- // cubeLeft.position.set(-1800, -400, -60000);
136- // scene.add(cubeLeft);
137-
138- // cubeLeft.rotation.z =-1.5;
139- // });
140-
141135 var geometryLeft = new THREE . BoxGeometry ( 3000 , 1000 , 120000 ) ;
142136 const loaderLeft = new THREE . TextureLoader ( ) . load ( "images/images (1).jpg" , ( texture ) => {
143137 const materialLeft = new THREE . MeshBasicMaterial ( { map : texture } ) ;
@@ -162,18 +156,6 @@ function World() {
162156 cubeRight . rotation . z = 1.5 ;
163157 } ) ;
164158
165- // var geometryRight = new THREE.BoxGeometry(3000, 1000, 120000);
166- // // const cubes = []; // just an array we can use to rotate the cubes
167- // const loaderRight = new THREE.TextureLoader();
168- // loaderRight.load("js/lava_text.jpg", (texture) => {
169- // const materialRight = new THREE.MeshBasicMaterial({ map: texture });
170- // const cubeRight = new THREE.Mesh(geometryRight, materialRight);
171- // cubeRight.position.set(1800, -400, -60000);
172- // scene.add(cubeRight);
173-
174- // cubeRight.rotation.z =1.5;
175- // });
176-
177159 objects = [ ] ;
178160 objectsCoins = [ ] ;
179161 spikePresenceProb = 0.2 ;
@@ -648,8 +630,20 @@ function Character() {
648630 break ;
649631 }
650632 }
651- camera . position . set ( camera_x , 700 , - 1600 ) ;
652- camera . lookAt ( new THREE . Vector3 ( camera_x , 650 , - 10000 ) ) ;
633+ // camera.position.set(camera_x, 700, -1600);
634+ // camera.lookAt(new THREE.Vector3(camera_x, 650, -10000));
635+
636+ // if(camera_y >= 650){
637+ // camera_y -=1;
638+ // }
639+
640+ //follow character
641+ camera_z_position -= 100 ;
642+ camera_z_look -= 100 ;
643+
644+ camera . position . set ( camera_x , camera_y , camera_z_position ) ;
645+ camera . lookAt ( new THREE . Vector3 ( camera_x , 650 , camera_z_look ) ) ;
646+
653647 window . camera = camera ;
654648
655649 // If the character is jumping, update the height of the character.
@@ -720,6 +714,8 @@ function Character() {
720714 }
721715 }
722716 }
717+ //move person forward
718+ self . element . position . z -= 100 ;
723719 } ;
724720
725721 /**
0 commit comments