Feature: waving projection screen
This commit is contained in:
parent
3dcfdaff5a
commit
94ae337e96
@ -95,6 +95,7 @@ export class ProjectionScreen extends SceneFeature {
|
||||
super();
|
||||
projectionScreenInstance = this;
|
||||
this.isVisualizerActive = false;
|
||||
this.originalPositions = null;
|
||||
sceneFeatureManager.register(this);
|
||||
}
|
||||
|
||||
@ -125,9 +126,11 @@ export class ProjectionScreen extends SceneFeature {
|
||||
// 16:9 Aspect Ratio, large size
|
||||
const width = 10;
|
||||
const height = width * (9 / 16);
|
||||
const geometry = new THREE.PlaneGeometry(width, height);
|
||||
const geometry = new THREE.PlaneGeometry(width, height, 32, 32);
|
||||
|
||||
// Initial black material
|
||||
this.originalPositions = geometry.attributes.position.clone();
|
||||
|
||||
const material = new THREE.MeshBasicMaterial({ color: 0x000000 });
|
||||
|
||||
this.mesh = new THREE.Mesh(geometry, material);
|
||||
@ -151,6 +154,28 @@ export class ProjectionScreen extends SceneFeature {
|
||||
update(deltaTime) {
|
||||
updateScreenEffect();
|
||||
|
||||
// Wobble Logic
|
||||
if (this.mesh && this.originalPositions) {
|
||||
const time = state.clock.getElapsedTime();
|
||||
const waveSpeed = 0.5;
|
||||
const waveFrequency = 1.2;
|
||||
const waveAmplitude = 0.3;
|
||||
// same as stage-curtain ^^^
|
||||
|
||||
const positions = this.mesh.geometry.attributes.position;
|
||||
|
||||
for (let i = 0; i < positions.count; i++) {
|
||||
const originalX = this.originalPositions.getX(i);
|
||||
const originalZ = this.originalPositions.getZ(i);
|
||||
|
||||
const zOffset = Math.sin(originalX * waveFrequency + time * waveSpeed) * waveAmplitude;
|
||||
|
||||
positions.setZ(i, originalZ + zOffset);
|
||||
}
|
||||
positions.needsUpdate = true;
|
||||
this.mesh.geometry.computeVertexNormals();
|
||||
}
|
||||
|
||||
if (this.isVisualizerActive && state.tvScreen.material.uniforms) {
|
||||
state.tvScreen.material.uniforms.u_time.value = state.clock.getElapsedTime();
|
||||
const beat = (state.music && state.music.beatIntensity) ? state.music.beatIntensity : 0.0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user