Spaces:
Running
Running
cutechicken
commited on
Update game.js
Browse files
game.js
CHANGED
@@ -326,66 +326,59 @@ class Game {
|
|
326 |
|
327 |
async initialize() {
|
328 |
try {
|
329 |
-
// ์๊ฐ
|
330 |
-
this.scene.fog =
|
331 |
this.scene.background = new THREE.Color(0x87CEEB);
|
332 |
|
333 |
-
// ์ฃผ๋ณ๊ด
|
334 |
-
const ambientLight = new THREE.AmbientLight(0xffffff, 1.
|
335 |
this.scene.add(ambientLight);
|
336 |
|
337 |
-
// ํ์๊ด ์ค์
|
338 |
-
const directionalLight = new THREE.DirectionalLight(0xffffff, 1.
|
339 |
directionalLight.position.set(100, 100, 50);
|
340 |
directionalLight.castShadow = true;
|
341 |
-
directionalLight.shadow.mapSize.width =
|
342 |
-
directionalLight.shadow.mapSize.height =
|
343 |
directionalLight.shadow.camera.near = 0.5;
|
344 |
directionalLight.shadow.camera.far = 500;
|
345 |
-
directionalLight.shadow.bias = -0.
|
346 |
this.scene.add(directionalLight);
|
347 |
|
348 |
-
// ๋ณด์กฐ ์กฐ๋ช
์ถ๊ฐ
|
349 |
-
const hemisphereLight = new THREE.HemisphereLight(0xffffff, 0xD2B48C, 1.0);
|
350 |
-
this.scene.add(hemisphereLight);
|
351 |
-
|
352 |
// ์ฌ๋ง ์งํ ์์ฑ
|
353 |
-
const groundGeometry = new THREE.PlaneGeometry(MAP_SIZE, MAP_SIZE,
|
354 |
const groundTexture = new THREE.TextureLoader().load('/textures/sand.jpg');
|
355 |
groundTexture.wrapS = groundTexture.wrapT = THREE.RepeatWrapping;
|
356 |
-
groundTexture.repeat.set(
|
357 |
|
358 |
-
// ์ฌ๋ง ์ฌ์ง
|
359 |
const groundMaterial = new THREE.MeshStandardMaterial({
|
360 |
map: groundTexture,
|
361 |
-
color: 0xDEB887,
|
362 |
roughness: 0.8,
|
363 |
metalness: 0.1,
|
364 |
-
bumpScale: 0.3
|
365 |
-
emissive: 0x222222, // ์ฝ๊ฐ์ ๋ฐ๊ด ํจ๊ณผ ์ถ๊ฐ
|
366 |
});
|
367 |
|
368 |
const ground = new THREE.Mesh(groundGeometry, groundMaterial);
|
369 |
ground.rotation.x = -Math.PI / 2;
|
370 |
ground.receiveShadow = true;
|
371 |
|
372 |
-
// ์งํ์ ๊ธฐ๋ณต ์ถ๊ฐ (
|
373 |
const vertices = ground.geometry.attributes.position.array;
|
374 |
let seed = Math.random() * 100;
|
375 |
for (let i = 0; i < vertices.length; i += 3) {
|
376 |
const x = vertices[i] / 100;
|
377 |
const y = vertices[i + 1] / 100;
|
378 |
vertices[i + 2] =
|
379 |
-
(Math.sin(x + seed) * Math.cos(y + seed) * 1.0)
|
380 |
-
(Math.sin(x * 2 + seed) * Math.cos(y * 2 + seed) * 0.5) +
|
381 |
-
(Math.sin(x * 4 + seed) * Math.cos(y * 4 + seed) * 0.25);
|
382 |
}
|
383 |
ground.geometry.attributes.position.needsUpdate = true;
|
384 |
ground.geometry.computeVertexNormals();
|
385 |
|
386 |
this.scene.add(ground);
|
387 |
|
388 |
-
// ๋๋จธ์ง ์ด๊ธฐํ
|
389 |
await this.addDesertDecorations();
|
390 |
await this.tank.initialize(this.scene, this.loader);
|
391 |
|
|
|
326 |
|
327 |
async initialize() {
|
328 |
try {
|
329 |
+
// ์๊ฐ ํจ๊ณผ ์ ๊ฑฐ
|
330 |
+
this.scene.fog = null;
|
331 |
this.scene.background = new THREE.Color(0x87CEEB);
|
332 |
|
333 |
+
// ์ฃผ๋ณ๊ด ์ค์
|
334 |
+
const ambientLight = new THREE.AmbientLight(0xffffff, 1.2);
|
335 |
this.scene.add(ambientLight);
|
336 |
|
337 |
+
// ํ์๊ด ์ค์ - ๊ทธ๋ฆผ์ ํ์ง ๋ฎ์ถค
|
338 |
+
const directionalLight = new THREE.DirectionalLight(0xffffff, 1.2);
|
339 |
directionalLight.position.set(100, 100, 50);
|
340 |
directionalLight.castShadow = true;
|
341 |
+
directionalLight.shadow.mapSize.width = 1024; // ๊ทธ๋ฆผ์ ํด์๋ ๋ฎ์ถค
|
342 |
+
directionalLight.shadow.mapSize.height = 1024;
|
343 |
directionalLight.shadow.camera.near = 0.5;
|
344 |
directionalLight.shadow.camera.far = 500;
|
345 |
+
directionalLight.shadow.bias = -0.001;
|
346 |
this.scene.add(directionalLight);
|
347 |
|
|
|
|
|
|
|
|
|
348 |
// ์ฌ๋ง ์งํ ์์ฑ
|
349 |
+
const groundGeometry = new THREE.PlaneGeometry(MAP_SIZE, MAP_SIZE, 100, 100); // ์งํ ํด์๋ ๋ฎ์ถค
|
350 |
const groundTexture = new THREE.TextureLoader().load('/textures/sand.jpg');
|
351 |
groundTexture.wrapS = groundTexture.wrapT = THREE.RepeatWrapping;
|
352 |
+
groundTexture.repeat.set(25, 25); // ํ
์ค์ฒ ๋ฐ๋ณต ํ์ ๊ฐ์
|
353 |
|
354 |
+
// ์ฌ๋ง ์ฌ์ง ์ต์ ํ
|
355 |
const groundMaterial = new THREE.MeshStandardMaterial({
|
356 |
map: groundTexture,
|
357 |
+
color: 0xDEB887,
|
358 |
roughness: 0.8,
|
359 |
metalness: 0.1,
|
360 |
+
bumpScale: 0.3
|
|
|
361 |
});
|
362 |
|
363 |
const ground = new THREE.Mesh(groundGeometry, groundMaterial);
|
364 |
ground.rotation.x = -Math.PI / 2;
|
365 |
ground.receiveShadow = true;
|
366 |
|
367 |
+
// ์งํ์ ๊ธฐ๋ณต ์ถ๊ฐ (๋จ์ํ)
|
368 |
const vertices = ground.geometry.attributes.position.array;
|
369 |
let seed = Math.random() * 100;
|
370 |
for (let i = 0; i < vertices.length; i += 3) {
|
371 |
const x = vertices[i] / 100;
|
372 |
const y = vertices[i + 1] / 100;
|
373 |
vertices[i + 2] =
|
374 |
+
(Math.sin(x + seed) * Math.cos(y + seed) * 1.0);
|
|
|
|
|
375 |
}
|
376 |
ground.geometry.attributes.position.needsUpdate = true;
|
377 |
ground.geometry.computeVertexNormals();
|
378 |
|
379 |
this.scene.add(ground);
|
380 |
|
381 |
+
// ๋๋จธ์ง ์ด๊ธฐํ ์ฝ๋
|
382 |
await this.addDesertDecorations();
|
383 |
await this.tank.initialize(this.scene, this.loader);
|
384 |
|