|
119 | 119 | // Cornell Box inspired scene |
120 | 120 |
|
121 | 121 | // Walls |
122 | | - const wallGeometry = new THREE.PlaneGeometry(1, 1); |
123 | | - |
| 122 | + const wallGeometry = new THREE.PlaneGeometry( 1, 1 ); |
| 123 | + |
124 | 124 | // Left wall - red |
125 | | - const redWallMaterial = new THREE.MeshPhysicalMaterial({ color: "#ff0000" }); |
126 | | - const leftWall = new THREE.Mesh(wallGeometry, redWallMaterial); |
| 125 | + const redWallMaterial = new THREE.MeshPhysicalMaterial( { color: '#ff0000' } ); |
| 126 | + const leftWall = new THREE.Mesh( wallGeometry, redWallMaterial ); |
127 | 127 | leftWall.scale.set( 20, 15, 1 ); |
128 | 128 | leftWall.rotation.y = Math.PI * 0.5; |
129 | | - leftWall.position.set(-10, 7.5, 0); |
| 129 | + leftWall.position.set( - 10, 7.5, 0 ); |
130 | 130 | leftWall.receiveShadow = true; |
131 | | - scene.add(leftWall); |
| 131 | + scene.add( leftWall ); |
132 | 132 |
|
133 | 133 | // Right wall - green |
134 | | - const greenWallMaterial = new THREE.MeshPhysicalMaterial({ color: "#00ff00" }); |
135 | | - const rightWall = new THREE.Mesh(wallGeometry, greenWallMaterial); |
| 134 | + const greenWallMaterial = new THREE.MeshPhysicalMaterial( { color: '#00ff00' } ); |
| 135 | + const rightWall = new THREE.Mesh( wallGeometry, greenWallMaterial ); |
136 | 136 | rightWall.scale.set( 20, 15, 1 ); |
137 | | - rightWall.rotation.y = Math.PI * -0.5; |
138 | | - rightWall.position.set(10, 7.5, 0); |
| 137 | + rightWall.rotation.y = Math.PI * - 0.5; |
| 138 | + rightWall.position.set( 10, 7.5, 0 ); |
139 | 139 | rightWall.receiveShadow = true; |
140 | | - scene.add(rightWall); |
| 140 | + scene.add( rightWall ); |
141 | 141 |
|
142 | 142 | // White walls and boxes |
143 | | - const whiteMaterial = new THREE.MeshPhysicalMaterial({ color: "#fff" }); |
144 | | - |
| 143 | + const whiteMaterial = new THREE.MeshPhysicalMaterial( { color: '#fff' } ); |
| 144 | + |
145 | 145 | // Floor |
146 | | - const floor = new THREE.Mesh(wallGeometry, whiteMaterial); |
| 146 | + const floor = new THREE.Mesh( wallGeometry, whiteMaterial ); |
147 | 147 | floor.scale.set( 20, 20, 1 ); |
148 | | - floor.rotation.x = Math.PI * -.5; |
| 148 | + floor.rotation.x = Math.PI * - .5; |
149 | 149 | floor.receiveShadow = true; |
150 | | - scene.add(floor); |
| 150 | + scene.add( floor ); |
151 | 151 |
|
152 | 152 | // Back wall |
153 | | - const backWall = new THREE.Mesh(wallGeometry, whiteMaterial); |
| 153 | + const backWall = new THREE.Mesh( wallGeometry, whiteMaterial ); |
154 | 154 | backWall.scale.set( 15, 20, 1 ); |
155 | | - backWall.rotation.z = Math.PI * -0.5; |
156 | | - backWall.position.set(0, 7.5, -10); |
| 155 | + backWall.rotation.z = Math.PI * - 0.5; |
| 156 | + backWall.position.set( 0, 7.5, - 10 ); |
157 | 157 | backWall.receiveShadow = true; |
158 | | - scene.add(backWall); |
| 158 | + scene.add( backWall ); |
159 | 159 |
|
160 | 160 | // Ceiling |
161 | | - const ceiling = new THREE.Mesh(wallGeometry, whiteMaterial); |
| 161 | + const ceiling = new THREE.Mesh( wallGeometry, whiteMaterial ); |
162 | 162 | ceiling.scale.set( 20, 20, 1 ); |
163 | 163 | ceiling.rotation.x = Math.PI * 0.5; |
164 | | - ceiling.position.set(0, 15, 0); |
| 164 | + ceiling.position.set( 0, 15, 0 ); |
165 | 165 | ceiling.receiveShadow = true; |
166 | | - scene.add(ceiling); |
| 166 | + scene.add( ceiling ); |
167 | 167 |
|
168 | 168 | // Boxes |
169 | | - const tallBoxGeometry = new THREE.BoxGeometry(5, 7, 5); |
170 | | - const tallBox = new THREE.Mesh(tallBoxGeometry, whiteMaterial); |
| 169 | + const tallBoxGeometry = new THREE.BoxGeometry( 5, 7, 5 ); |
| 170 | + const tallBox = new THREE.Mesh( tallBoxGeometry, whiteMaterial ); |
171 | 171 | tallBox.rotation.y = Math.PI * 0.25; |
172 | | - tallBox.position.set(-3, 3.5, -2); |
| 172 | + tallBox.position.set( - 3, 3.5, - 2 ); |
173 | 173 | tallBox.castShadow = true; |
174 | 174 | tallBox.receiveShadow = true; |
175 | | - scene.add(tallBox); |
| 175 | + scene.add( tallBox ); |
176 | 176 |
|
177 | | - const shortBoxGeometry = new THREE.BoxGeometry(4, 4, 4); |
178 | | - const shortBox = new THREE.Mesh(shortBoxGeometry, whiteMaterial); |
179 | | - shortBox.rotation.y = Math.PI * -0.1; |
180 | | - shortBox.position.set(4, 2, 4); |
| 177 | + const shortBoxGeometry = new THREE.BoxGeometry( 4, 4, 4 ); |
| 178 | + const shortBox = new THREE.Mesh( shortBoxGeometry, whiteMaterial ); |
| 179 | + shortBox.rotation.y = Math.PI * - 0.1; |
| 180 | + shortBox.position.set( 4, 2, 4 ); |
181 | 181 | shortBox.castShadow = true; |
182 | 182 | shortBox.receiveShadow = true; |
183 | | - scene.add(shortBox); |
| 183 | + scene.add( shortBox ); |
184 | 184 |
|
185 | 185 | // Light source geometry |
186 | | - const lightSourceGeometry = new THREE.CylinderGeometry(2.5, 2.5, 1, 64); |
| 186 | + const lightSourceGeometry = new THREE.CylinderGeometry( 2.5, 2.5, 1, 64 ); |
187 | 187 | const lightSourceMaterial = new THREE.MeshBasicMaterial(); |
188 | | - const lightSource = new THREE.Mesh(lightSourceGeometry, lightSourceMaterial); |
| 188 | + const lightSource = new THREE.Mesh( lightSourceGeometry, lightSourceMaterial ); |
189 | 189 | lightSource.position.y = 15; |
190 | | - scene.add(lightSource); |
| 190 | + scene.add( lightSource ); |
191 | 191 |
|
192 | 192 | // Point light |
193 | | - const pointLight = new THREE.PointLight("#ffffff", 100); |
194 | | - pointLight.position.set(0, 13, 0); |
| 193 | + const pointLight = new THREE.PointLight( '#ffffff', 100 ); |
| 194 | + pointLight.position.set( 0, 13, 0 ); |
195 | 195 | pointLight.distance = 100; |
196 | 196 | pointLight.castShadow = true; |
197 | 197 | pointLight.shadow.mapSize.width = 1024; |
198 | 198 | pointLight.shadow.mapSize.height = 1024; |
199 | | - pointLight.shadow.bias = -0.0025; |
200 | | - scene.add(pointLight); |
| 199 | + pointLight.shadow.bias = - 0.0025; |
| 200 | + scene.add( pointLight ); |
201 | 201 |
|
202 | 202 | // Ambient light |
203 | | - const ambientLight = new THREE.AmbientLight("#0c0c0c"); |
204 | | - scene.add(ambientLight); |
| 203 | + const ambientLight = new THREE.AmbientLight( '#0c0c0c' ); |
| 204 | + scene.add( ambientLight ); |
205 | 205 |
|
206 | 206 | window.addEventListener( 'resize', onWindowResize ); |
207 | 207 |
|
|
0 commit comments