Refactor: SceneFeature+Manager
This commit is contained in:
parent
1d4e428bf9
commit
bc961119b6
@ -1,6 +1,7 @@
|
|||||||
import * as THREE from 'three';
|
import * as THREE from 'three';
|
||||||
import { state } from '../state.js';
|
import { state } from '../state.js';
|
||||||
import { updateScreenEffect } from '../scene/magic-mirror.js'
|
import { updateScreenEffect } from '../scene/magic-mirror.js'
|
||||||
|
import sceneFeatureManager from '../scene/SceneFeatureManager.js';
|
||||||
|
|
||||||
function updateCamera() {
|
function updateCamera() {
|
||||||
const globalTime = Date.now() * 0.0001;
|
const globalTime = Date.now() * 0.0001;
|
||||||
@ -69,6 +70,8 @@ function updateVideo() {
|
|||||||
export function animate() {
|
export function animate() {
|
||||||
requestAnimationFrame(animate);
|
requestAnimationFrame(animate);
|
||||||
|
|
||||||
|
const deltaTime = 1;
|
||||||
|
sceneFeatureManager.update(deltaTime);
|
||||||
state.effectsManager.update();
|
state.effectsManager.update();
|
||||||
updateCamera();
|
updateCamera();
|
||||||
updateScreenLight();
|
updateScreenLight();
|
||||||
|
|||||||
6
party-cathedral/src/scene/SceneFeature.js
Normal file
6
party-cathedral/src/scene/SceneFeature.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// SceneFeature.js
|
||||||
|
|
||||||
|
export class SceneFeature {
|
||||||
|
init() {}
|
||||||
|
update(deltaTime) {}
|
||||||
|
}
|
||||||
31
party-cathedral/src/scene/SceneFeatureManager.js
Normal file
31
party-cathedral/src/scene/SceneFeatureManager.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// SceneFeatureManager.js
|
||||||
|
|
||||||
|
class SceneFeatureManager {
|
||||||
|
constructor() {
|
||||||
|
if (SceneFeatureManager.instance) {
|
||||||
|
return SceneFeatureManager.instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.features = [];
|
||||||
|
SceneFeatureManager.instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
register(feature) {
|
||||||
|
this.features.push(feature);
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
for (const feature of this.features) {
|
||||||
|
feature.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update(deltaTime) {
|
||||||
|
for (const feature of this.features) {
|
||||||
|
feature.update(deltaTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const sceneFeatureManager = new SceneFeatureManager();
|
||||||
|
export default sceneFeatureManager;
|
||||||
@ -1,10 +1,16 @@
|
|||||||
import * as THREE from 'three';
|
import * as THREE from 'three';
|
||||||
import { state } from '../state.js';
|
import { state } from '../state.js';
|
||||||
import wallTextureUrl from '/textures/stone_wall.png';
|
import wallTextureUrl from '/textures/stone_wall.png';
|
||||||
|
import sceneFeatureManager from './SceneFeatureManager.js';
|
||||||
|
import { SceneFeature } from './SceneFeature.js';
|
||||||
|
const length = 40;
|
||||||
|
|
||||||
export function createRoomWalls() {
|
export class RoomWalls extends SceneFeature {
|
||||||
// --- Cathedral Dimensions ---
|
constructor() {
|
||||||
const length = 40;
|
super();
|
||||||
|
sceneFeatureManager.register(this);
|
||||||
|
}
|
||||||
|
init() {
|
||||||
const naveWidth = 12;
|
const naveWidth = 12;
|
||||||
const aisleWidth = 6;
|
const aisleWidth = 6;
|
||||||
const totalWidth = naveWidth + 2 * aisleWidth;
|
const totalWidth = naveWidth + 2 * aisleWidth;
|
||||||
@ -80,7 +86,7 @@ export function createRoomWalls() {
|
|||||||
for (let i = 0; i <= numPillars; i++) {
|
for (let i = 0; i <= numPillars; i++) {
|
||||||
const z = -length / 2 + pillarSpacing * (i + 0.5);
|
const z = -length / 2 + pillarSpacing * (i + 0.5);
|
||||||
// Add wall sections between pillars
|
// Add wall sections between pillars
|
||||||
if (i < numPillars) {
|
if (i <= numPillars) {
|
||||||
createMesh(arcadeWallGeo, arcadeWallMat, new THREE.Vector3(-naveWidth / 2, pillarHeight + arcadeWallHeight / 2, z));
|
createMesh(arcadeWallGeo, arcadeWallMat, new THREE.Vector3(-naveWidth / 2, pillarHeight + arcadeWallHeight / 2, z));
|
||||||
createMesh(arcadeWallGeo, arcadeWallMat, new THREE.Vector3(naveWidth / 2, pillarHeight + arcadeWallHeight / 2, z));
|
createMesh(arcadeWallGeo, arcadeWallMat, new THREE.Vector3(naveWidth / 2, pillarHeight + arcadeWallHeight / 2, z));
|
||||||
}
|
}
|
||||||
@ -99,7 +105,7 @@ export function createRoomWalls() {
|
|||||||
clerestoryMat.map = wallTexture.clone();
|
clerestoryMat.map = wallTexture.clone();
|
||||||
clerestoryMat.map.repeat.set(length / 4, clerestoryHeight / 4);
|
clerestoryMat.map.repeat.set(length / 4, clerestoryHeight / 4);
|
||||||
// Left and Right Clerestory walls
|
// Left and Right Clerestory walls
|
||||||
createMesh(clerestoryGeo, clerestoryMat, new THREE.Vector3(-naveWidth / 2, aisleHeight + clerestoryHeight / 2, 0), new THREE.Euler(0, -Math.PI/2, 0));
|
createMesh(clerestoryGeo, clerestoryMat, new THREE.Vector3(-naveWidth / 2, aisleHeight + clerestoryHeight / 2, 0), new THREE.Euler(0, - Math.PI / 2, 0));
|
||||||
createMesh(clerestoryGeo, clerestoryMat, new THREE.Vector3(naveWidth / 2, aisleHeight + clerestoryHeight / 2, 0), new THREE.Euler(0, Math.PI/2, 0));
|
createMesh(clerestoryGeo, clerestoryMat, new THREE.Vector3(naveWidth / 2, aisleHeight + clerestoryHeight / 2, 0), new THREE.Euler(0, Math.PI/2, 0));
|
||||||
|
|
||||||
// Upper part of the back wall (for the nave)
|
// Upper part of the back wall (for the nave)
|
||||||
@ -139,4 +145,10 @@ export function createRoomWalls() {
|
|||||||
createMesh(gableGeo, gableMat, new THREE.Vector3(0, 0, -length / 2));
|
createMesh(gableGeo, gableMat, new THREE.Vector3(0, 0, -length / 2));
|
||||||
|
|
||||||
// Note: crawlSurfaces and landingSurfaces might need to be updated if spiders/rats are used.
|
// Note: crawlSurfaces and landingSurfaces might need to be updated if spiders/rats are used.
|
||||||
|
}
|
||||||
|
|
||||||
|
update(deltaTime) {
|
||||||
|
// Add any per-frame update logic here, if needed
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
new RoomWalls();
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
import * as THREE from 'three';
|
import * as THREE from 'three';
|
||||||
import { state } from '../state.js';
|
import { state } from '../state.js';
|
||||||
import { createRoomWalls } from './room-walls.js';
|
|
||||||
import floorTextureUrl from '/textures/stone_floor.png';
|
import floorTextureUrl from '/textures/stone_floor.png';
|
||||||
|
import sceneFeatureManager from './SceneFeatureManager.js';
|
||||||
|
import { RoomWalls } from './room-walls.js';
|
||||||
|
|
||||||
// --- Scene Modeling Function ---
|
// --- Scene Modeling Function ---
|
||||||
export function createSceneObjects() {
|
export function createSceneObjects() {
|
||||||
|
sceneFeatureManager.init();
|
||||||
|
|
||||||
// --- Materials (MeshPhongMaterial) ---
|
// --- Materials (MeshPhongMaterial) ---
|
||||||
|
|
||||||
// --- 1. Floor --- (Resized to match the new cathedral dimensions)
|
// --- 1. Floor --- (Resized to match the new cathedral dimensions)
|
||||||
@ -22,13 +25,12 @@ export function createSceneObjects() {
|
|||||||
floor.receiveShadow = true;
|
floor.receiveShadow = true;
|
||||||
state.scene.add(floor);
|
state.scene.add(floor);
|
||||||
|
|
||||||
createRoomWalls(); // This will need to be updated to create cathedral walls.
|
|
||||||
|
|
||||||
// 3. Lighting (Minimal and focused)
|
// 3. Lighting (Minimal and focused)
|
||||||
const ambientLight = new THREE.AmbientLight(0x606060, 1.5); // Increased ambient light for a larger space
|
const ambientLight = new THREE.AmbientLight(0x606060, 1.5); // Increased ambient light for a larger space
|
||||||
state.scene.add(ambientLight);
|
state.scene.add(ambientLight);
|
||||||
|
|
||||||
// Add a HemisphereLight for more natural, general illumination in a large space.
|
// Add a HemisphereLight for more natural, general illumination in a large space.
|
||||||
const hemisphereLight = new THREE.HemisphereLight(0xffffff, 0x444444, 0.7);
|
const hemisphereLight = new THREE.HemisphereLight(0xffffff, 0x444444, 0.7);
|
||||||
|
|
||||||
state.scene.add(hemisphereLight);
|
state.scene.add(hemisphereLight);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user