Commit
·
8ea1a0b
1
Parent(s):
220eacd
Updated default scene
Browse files- backend/storage.py +5 -5
- frontend/game_viewer.html +19 -38
backend/storage.py
CHANGED
|
@@ -78,10 +78,10 @@ def initialize_default_scene():
|
|
| 78 |
# Ground plane and walls are created by physics system in viewer
|
| 79 |
scene = create_scene(
|
| 80 |
name="Welcome Scene",
|
| 81 |
-
description="Clean
|
| 82 |
-
world_width=
|
| 83 |
world_height=10,
|
| 84 |
-
world_depth=
|
| 85 |
lights=lights,
|
| 86 |
environment=env,
|
| 87 |
)
|
|
@@ -92,8 +92,8 @@ def initialize_default_scene():
|
|
| 92 |
# Save to storage
|
| 93 |
storage.save(scene)
|
| 94 |
print(f"✓ Initialized default Welcome Scene (ID: welcome)")
|
| 95 |
-
print(f" -
|
| 96 |
-
print(f" - Ground plane + boundary walls
|
| 97 |
print(f" - Player spawn at (0, 1, 0)")
|
| 98 |
|
| 99 |
|
|
|
|
| 78 |
# Ground plane and walls are created by physics system in viewer
|
| 79 |
scene = create_scene(
|
| 80 |
name="Welcome Scene",
|
| 81 |
+
description="Clean 25x25 FPS world with physics - Ready to explore!",
|
| 82 |
+
world_width=25,
|
| 83 |
world_height=10,
|
| 84 |
+
world_depth=25,
|
| 85 |
lights=lights,
|
| 86 |
environment=env,
|
| 87 |
)
|
|
|
|
| 92 |
# Save to storage
|
| 93 |
storage.save(scene)
|
| 94 |
print(f"✓ Initialized default Welcome Scene (ID: welcome)")
|
| 95 |
+
print(f" - 25x25 world with FPS physics controller")
|
| 96 |
+
print(f" - Ground plane + invisible boundary walls")
|
| 97 |
print(f" - Player spawn at (0, 1, 0)")
|
| 98 |
|
| 99 |
|
frontend/game_viewer.html
CHANGED
|
@@ -127,8 +127,9 @@
|
|
| 127 |
let GRAVITY = -9.82;
|
| 128 |
let PLAYER_MASS = 80.0;
|
| 129 |
let LINEAR_DAMPING = 0.9;
|
| 130 |
-
|
| 131 |
-
|
|
|
|
| 132 |
let isGrounded = false;
|
| 133 |
let canJump = true;
|
| 134 |
|
|
@@ -258,6 +259,13 @@
|
|
| 258 |
}
|
| 259 |
console.log('Scene data loaded:', sceneData);
|
| 260 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
// Apply player configuration from scene data
|
| 262 |
applyPlayerConfig();
|
| 263 |
|
|
@@ -505,64 +513,37 @@
|
|
| 505 |
groundBody.quaternion.setFromEuler(-Math.PI / 2, 0, 0);
|
| 506 |
physicsWorld.addBody(groundBody);
|
| 507 |
|
| 508 |
-
// Create 4 boundary walls (
|
| 509 |
const wallHeight = 5;
|
| 510 |
const wallThickness = 0.5;
|
| 511 |
-
const wallMaterial = new THREE.MeshStandardMaterial({
|
| 512 |
-
color: 0xffffff,
|
| 513 |
-
roughness: 0.7,
|
| 514 |
-
metalness: 0.1
|
| 515 |
-
});
|
| 516 |
-
|
| 517 |
-
// North wall (z = 5)
|
| 518 |
-
const northWallGeometry = new THREE.BoxGeometry(WORLD_SIZE + wallThickness * 2, wallHeight, wallThickness);
|
| 519 |
-
const northWallMesh = new THREE.Mesh(northWallGeometry, wallMaterial);
|
| 520 |
-
northWallMesh.position.set(0, wallHeight / 2, WORLD_HALF);
|
| 521 |
-
northWallMesh.userData = { isWall: true };
|
| 522 |
-
scene.add(northWallMesh);
|
| 523 |
|
|
|
|
| 524 |
const northWallShape = new CANNON.Box(new CANNON.Vec3((WORLD_SIZE + wallThickness * 2) / 2, wallHeight / 2, wallThickness / 2));
|
| 525 |
const northWallBody = new CANNON.Body({ mass: 0, material: defaultMaterial });
|
| 526 |
northWallBody.addShape(northWallShape);
|
| 527 |
-
northWallBody.position.
|
| 528 |
physicsWorld.addBody(northWallBody);
|
| 529 |
wallBodies.push(northWallBody);
|
| 530 |
|
| 531 |
-
// South wall (z = -
|
| 532 |
-
const southWallMesh = new THREE.Mesh(northWallGeometry, wallMaterial);
|
| 533 |
-
southWallMesh.position.set(0, wallHeight / 2, -WORLD_HALF);
|
| 534 |
-
southWallMesh.userData = { isWall: true };
|
| 535 |
-
scene.add(southWallMesh);
|
| 536 |
-
|
| 537 |
const southWallBody = new CANNON.Body({ mass: 0, material: defaultMaterial });
|
| 538 |
southWallBody.addShape(northWallShape);
|
| 539 |
-
southWallBody.position.
|
| 540 |
physicsWorld.addBody(southWallBody);
|
| 541 |
wallBodies.push(southWallBody);
|
| 542 |
|
| 543 |
-
// East wall (x =
|
| 544 |
-
const eastWallGeometry = new THREE.BoxGeometry(wallThickness, wallHeight, WORLD_SIZE);
|
| 545 |
-
const eastWallMesh = new THREE.Mesh(eastWallGeometry, wallMaterial);
|
| 546 |
-
eastWallMesh.position.set(WORLD_HALF, wallHeight / 2, 0);
|
| 547 |
-
eastWallMesh.userData = { isWall: true };
|
| 548 |
-
scene.add(eastWallMesh);
|
| 549 |
-
|
| 550 |
const eastWallShape = new CANNON.Box(new CANNON.Vec3(wallThickness / 2, wallHeight / 2, WORLD_SIZE / 2));
|
| 551 |
const eastWallBody = new CANNON.Body({ mass: 0, material: defaultMaterial });
|
| 552 |
eastWallBody.addShape(eastWallShape);
|
| 553 |
-
eastWallBody.position.
|
| 554 |
physicsWorld.addBody(eastWallBody);
|
| 555 |
wallBodies.push(eastWallBody);
|
| 556 |
|
| 557 |
-
// West wall (x = -
|
| 558 |
-
const westWallMesh = new THREE.Mesh(eastWallGeometry, wallMaterial);
|
| 559 |
-
westWallMesh.position.set(-WORLD_HALF, wallHeight / 2, 0);
|
| 560 |
-
westWallMesh.userData = { isWall: true };
|
| 561 |
-
scene.add(westWallMesh);
|
| 562 |
-
|
| 563 |
const westWallBody = new CANNON.Body({ mass: 0, material: defaultMaterial });
|
| 564 |
westWallBody.addShape(eastWallShape);
|
| 565 |
-
westWallBody.position.
|
| 566 |
physicsWorld.addBody(westWallBody);
|
| 567 |
wallBodies.push(westWallBody);
|
| 568 |
|
|
|
|
| 127 |
let GRAVITY = -9.82;
|
| 128 |
let PLAYER_MASS = 80.0;
|
| 129 |
let LINEAR_DAMPING = 0.9;
|
| 130 |
+
// World size from scene data (default 25x25)
|
| 131 |
+
let WORLD_SIZE = 25;
|
| 132 |
+
let WORLD_HALF = WORLD_SIZE / 2;
|
| 133 |
let isGrounded = false;
|
| 134 |
let canJump = true;
|
| 135 |
|
|
|
|
| 259 |
}
|
| 260 |
console.log('Scene data loaded:', sceneData);
|
| 261 |
|
| 262 |
+
// Apply world size from scene data
|
| 263 |
+
if (sceneData.world_width) {
|
| 264 |
+
WORLD_SIZE = sceneData.world_width;
|
| 265 |
+
WORLD_HALF = WORLD_SIZE / 2;
|
| 266 |
+
console.log('World size set to:', WORLD_SIZE);
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
// Apply player configuration from scene data
|
| 270 |
applyPlayerConfig();
|
| 271 |
|
|
|
|
| 513 |
groundBody.quaternion.setFromEuler(-Math.PI / 2, 0, 0);
|
| 514 |
physicsWorld.addBody(groundBody);
|
| 515 |
|
| 516 |
+
// Create 4 invisible boundary walls (physics only, no visible mesh)
|
| 517 |
const wallHeight = 5;
|
| 518 |
const wallThickness = 0.5;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 519 |
|
| 520 |
+
// North wall (z = +WORLD_HALF)
|
| 521 |
const northWallShape = new CANNON.Box(new CANNON.Vec3((WORLD_SIZE + wallThickness * 2) / 2, wallHeight / 2, wallThickness / 2));
|
| 522 |
const northWallBody = new CANNON.Body({ mass: 0, material: defaultMaterial });
|
| 523 |
northWallBody.addShape(northWallShape);
|
| 524 |
+
northWallBody.position.set(0, wallHeight / 2, WORLD_HALF);
|
| 525 |
physicsWorld.addBody(northWallBody);
|
| 526 |
wallBodies.push(northWallBody);
|
| 527 |
|
| 528 |
+
// South wall (z = -WORLD_HALF)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 529 |
const southWallBody = new CANNON.Body({ mass: 0, material: defaultMaterial });
|
| 530 |
southWallBody.addShape(northWallShape);
|
| 531 |
+
southWallBody.position.set(0, wallHeight / 2, -WORLD_HALF);
|
| 532 |
physicsWorld.addBody(southWallBody);
|
| 533 |
wallBodies.push(southWallBody);
|
| 534 |
|
| 535 |
+
// East wall (x = +WORLD_HALF)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 536 |
const eastWallShape = new CANNON.Box(new CANNON.Vec3(wallThickness / 2, wallHeight / 2, WORLD_SIZE / 2));
|
| 537 |
const eastWallBody = new CANNON.Body({ mass: 0, material: defaultMaterial });
|
| 538 |
eastWallBody.addShape(eastWallShape);
|
| 539 |
+
eastWallBody.position.set(WORLD_HALF, wallHeight / 2, 0);
|
| 540 |
physicsWorld.addBody(eastWallBody);
|
| 541 |
wallBodies.push(eastWallBody);
|
| 542 |
|
| 543 |
+
// West wall (x = -WORLD_HALF)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 544 |
const westWallBody = new CANNON.Body({ mass: 0, material: defaultMaterial });
|
| 545 |
westWallBody.addShape(eastWallShape);
|
| 546 |
+
westWallBody.position.set(-WORLD_HALF, wallHeight / 2, 0);
|
| 547 |
physicsWorld.addBody(westWallBody);
|
| 548 |
wallBodies.push(westWallBody);
|
| 549 |
|