Feature: door outside is glowing red
This commit is contained in:
parent
6d54f4b15a
commit
6e2a59ce77
@ -2,6 +2,9 @@ import * as THREE from 'three';
|
|||||||
import { state } from '../state.js';
|
import { state } from '../state.js';
|
||||||
|
|
||||||
let doorGroupPanel;
|
let doorGroupPanel;
|
||||||
|
let outsideMaterial; // Declare outsideMaterial globally
|
||||||
|
let glowIntensity = 0.0;
|
||||||
|
let glowDirection = 1; // 1 for increasing, -1 for decreasing
|
||||||
|
|
||||||
const DOOR_STATES = {
|
const DOOR_STATES = {
|
||||||
RESTING: 'resting',
|
RESTING: 'resting',
|
||||||
@ -36,7 +39,7 @@ export function createDoor(x, z, rotY) {
|
|||||||
doorGroup.add(frameRight);
|
doorGroup.add(frameRight);
|
||||||
|
|
||||||
// Outside darkness
|
// Outside darkness
|
||||||
const outsideMaterial = new THREE.MeshBasicMaterial({ color: 0x150505, shininess: 50 });
|
outsideMaterial = new THREE.MeshPhongMaterial({ color: 0x150505, emissive: 0x000000, shininess: 50 });
|
||||||
const outside = new THREE.Mesh(new THREE.BoxGeometry(doorWidth, 2.2, 0.04), outsideMaterial);
|
const outside = new THREE.Mesh(new THREE.BoxGeometry(doorWidth, 2.2, 0.04), outsideMaterial);
|
||||||
outside.position.set(0, 0, 0);
|
outside.position.set(0, 0, 0);
|
||||||
doorGroup.add(outside);
|
doorGroup.add(outside);
|
||||||
@ -76,13 +79,13 @@ export function updateDoor() {
|
|||||||
const nextState = Math.random();
|
const nextState = Math.random();
|
||||||
if (nextState < 0.4) {
|
if (nextState < 0.4) {
|
||||||
doorState = DOOR_STATES.RESTING;
|
doorState = DOOR_STATES.RESTING;
|
||||||
stateTimer = 5 + Math.random() * 5;
|
stateTimer = 2 + Math.random() * 5;
|
||||||
} else if (nextState < 0.7) {
|
} else if (nextState < 0.7) {
|
||||||
doorState = DOOR_STATES.OPENING;
|
doorState = DOOR_STATES.OPENING;
|
||||||
stateTimer = 2 + Math.random() * 3; // Open for 2-5 seconds
|
stateTimer = 2 + Math.random() * 4;
|
||||||
} else {
|
} else {
|
||||||
doorState = DOOR_STATES.CLOSING;
|
doorState = DOOR_STATES.CLOSING;
|
||||||
stateTimer = 2 + Math.random() * 3; // Close for 2-5 seconds
|
stateTimer = 3 + Math.random() * 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,4 +101,20 @@ export function updateDoor() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Outside material pulsating glow
|
||||||
|
if (outsideMaterial) {
|
||||||
|
const glowMin = 0.001;
|
||||||
|
const glowMax = 0.01;
|
||||||
|
const glowSpeed = 0.0001; // Speed of the pulsation
|
||||||
|
glowIntensity += glowDirection * glowSpeed;
|
||||||
|
if (glowIntensity >= glowMax) {
|
||||||
|
glowIntensity = glowMax;
|
||||||
|
glowDirection = -1;
|
||||||
|
} else if (glowIntensity <= glowMin) {
|
||||||
|
glowIntensity = glowMin;
|
||||||
|
glowDirection = 1;
|
||||||
|
}
|
||||||
|
outsideMaterial.emissive.setRGB(glowIntensity, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user