This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscene.ts
267 lines (232 loc) · 8.7 KB
/
scene.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
import { Blit } from './heck/components/Blit';
import { BufferTextureRenderTarget } from './heck/BufferTextureRenderTarget';
import { CapsuleScene } from './nodes/CapsuleScene/CapsuleScene';
import { Capture } from './nodes/Capture/Capture';
import { Dog } from './heck/Dog';
import { FluidScene } from './nodes/FluidScene/FluidScene';
import { IcosahedronScene } from './nodes/IcosahedronScene/IcosahedronScene';
import { InkScene } from './nodes/InkScene/InkScene';
import { KansokushaScene } from './nodes/KansokushaScene/KansokushaScene';
import { KeyboardScene } from './nodes/KeyboardScene/KeyboardScene';
import { Lambda } from './heck/components/Lambda';
import { LineRhombusesScene } from './nodes/LineRhombusesScene/LineRhombusesScene';
import { LineRings3DScene } from './nodes/LineRings3DScene/LineRings3DScene';
import { LineRingsScene } from './nodes/LineRingsScene/LineRingsScene';
import { LineTriTunnelScene } from './nodes/LineTriTunnelScene/LineTriTunnelScene';
import { LineWaveScene } from './nodes/LineWaveScene/LineWaveScene';
import { LoadingScreen } from './nodes/LoadingScreen/LoadingScreen';
import { MUSIC_BPM } from './music/constants';
import { MetaballScene } from './nodes/MetaballScene/MetaballScene';
import { MetalCubeScene } from './nodes/MetalCubeScene/MetalCubeScene';
import { Mixer } from './nodes/Mixer/Mixer';
import { MoonScene } from './nodes/MoonScene/MoonScene';
import { NoisePlaneScene } from './nodes/NoisePlaneScene/NoisePlaneScene';
import { OBSVRLogoBScene } from './nodes/OBSVRLogoBScene/OBSVRLogoBScene';
import { OBSVRLogoScene } from './nodes/OBSVRLogoScene/OBSVRLogoScene';
import { OctreeTunnelScene } from './nodes/OctreeTunnelScene/OctreeTunnelScene';
import { ParticlesRingScene } from './nodes/ParticlesRingScene/ParticlesRingScene';
import { PillarGridScene } from './nodes/PillarGridScene/PillarGridScene';
import { PinArrayScene } from './nodes/PinArrayScene/PinArrayScene';
import { PlexusScene } from './nodes/PlexusScene/PlexusScene';
import { PostStack } from './nodes/PostStack/PostStack';
import { RieScene } from './nodes/RieScene/RieScene';
import { Section2Scene } from './nodes/Section2Scene/Section2Scene';
import { Section3Scene } from './nodes/Section3Scene/Section3Scene';
import { SevenSegScene } from './nodes/SevenSegScene/SevenSegScene';
import { SpongeScene } from './nodes/SpongeScene/SpongeScene';
import { TrailsScene } from './nodes/TrailsScene/TrailsScene';
import { TruchetScene } from './nodes/TruchetScene/TruchetScene';
import { WebGLMemory } from './nodes/WebGLMemory/WebGLMemory';
import { WireCubeScene } from './nodes/WireCubeScene/WireCubeScene';
import { WormTunnelScene } from './nodes/WormTunnelScene/WormTunnelScene';
import { auto, automaton } from './globals/automaton';
import { cameraStackATarget, cameraStackBTarget } from './globals/cameraStackTargets';
import { canvas } from './globals/canvas';
import { canvasRenderTarget } from './globals/canvasRenderTarget';
import { ibllutCalc } from './globals/ibllutCalc';
import { mixerTarget } from './globals/mixerTarget';
import { moonTexGen } from './globals/moonTexGen';
import { music } from './globals/music';
import { postTarget } from './globals/postTarget';
import { promiseGui } from './globals/gui';
import { randomTexture } from './globals/randomTexture';
import { resizeObservers } from './globals/globalObservers';
import { updateAudioAnalyzer } from './globals/audioAnalyzer';
// == dog ==========================================================================================
export const dog = new Dog();
// loading screen
const loadingScene = new LoadingScreen();
// Mr. Update Everything
if ( import.meta.env.DEV ) {
dog.root.children.push( new Lambda( {
onUpdate: () => {
randomTexture.update();
},
name: 'randomTexture',
} ) );
dog.root.children.push( new Lambda( {
onUpdate: () => {
music.update();
},
name: 'music',
} ) );
dog.root.children.push( new Lambda( {
onUpdate: () => {
updateAudioAnalyzer();
},
name: 'audioAnalyzer',
} ) );
dog.root.children.push( new Lambda( {
onUpdate: () => {
automaton.update( MUSIC_BPM / 60.0 * music.time );
},
name: 'automaton',
} ) );
dog.root.children.push( new WebGLMemory() );
} else {
dog.root.children.push( new Lambda( {
onUpdate: () => {
randomTexture.update();
music.update();
updateAudioAnalyzer();
automaton.update( MUSIC_BPM / 60.0 * music.time );
},
} ) );
}
if ( import.meta.env.DEV ) {
promiseGui.then( ( gui ) => {
gui.input( 'active', true )?.on( 'change', ( { value } ) => {
dog.active = value;
} );
// Esc = panic button
window.addEventListener( 'keydown', ( event ) => {
if ( event.code === 'Escape' ) {
const input = (
gui.input( 'active', true )?.controller_.valueController.view as any
).inputElement;
if ( input.checked ) {
input.click();
}
}
} );
gui.button( 'Fullscreen' ).on( 'click', () => {
canvas.requestFullscreen();
} );
} );
}
// == nodes =====================================================================================
// const plane = new Plane();
// dog.root.children.push( plane );
// const plane = new Plane();
// plane.transform.position = [ 0.0, 3.0, 5.0 ];
// plane.transform.scale = [ 1.0, 1.0, 1.0 ];
const scenesA = [
new SpongeScene(),
new WormTunnelScene(),
new PillarGridScene(),
new MetaballScene(),
new TrailsScene(),
new OctreeTunnelScene(),
new ParticlesRingScene(),
new IcosahedronScene(),
new FluidScene(),
new OBSVRLogoScene(),
new TruchetScene(),
new MoonScene(),
new SevenSegScene(),
new KeyboardScene(),
new RieScene(),
new InkScene(),
new CapsuleScene(),
new MetalCubeScene(),
new PinArrayScene(),
new Section2Scene(),
new Section3Scene(),
];
const scenesB = [
new LineWaveScene(),
new LineRingsScene(),
new LineTriTunnelScene(),
new PlexusScene(),
new NoisePlaneScene(),
new KansokushaScene(),
new LineRings3DScene(),
new OBSVRLogoBScene(),
new LineRhombusesScene(),
new WireCubeScene(),
];
dog.root.children.push(
ibllutCalc,
moonTexGen,
...scenesA,
...scenesB,
// plane,
);
auto( 'A', ( { value } ) => {
scenesA.map( ( scene, i ) => scene.active = value === i + 1 );
} );
auto( 'B', ( { value } ) => {
scenesB.map( ( scene, i ) => scene.active = value === i + 1 );
} );
// == post =========================================================================================
const mixer = new Mixer( {
inputA: cameraStackATarget,
inputB: cameraStackBTarget,
target: mixerTarget,
} );
const postStack = new PostStack( {
input: mixerTarget,
target: postTarget,
} );
dog.root.children.push( mixer, postStack );
// == loading scene, again =========================================================================
dog.root.children.push( loadingScene );
// == dev specific =================================================================================
if ( import.meta.env.DEV ) {
const { HistogramScatter } = await import( './nodes/HistogramScatter/HistogramScatter' );
const { RTInspector } = await import( './nodes/RTInspector/RTInspector' );
const { ComponentLogger } = await import( './nodes/ComponentLogger/ComponentLogger' );
const blit = new Blit( {
src: postTarget as BufferTextureRenderTarget,
dst: canvasRenderTarget,
} );
dog.root.children.push( blit );
const histogramScatter = new HistogramScatter( {
input: postTarget as BufferTextureRenderTarget,
target: canvasRenderTarget,
active: false,
} );
dog.root.children.push( histogramScatter );
promiseGui.then( ( gui ) => (
gui.input( 'HistogramScatter/active', false )?.on( 'change', ( { value } ) => {
histogramScatter.active = value;
} )
) );
const rtInspector = new RTInspector( {
target: canvasRenderTarget,
} );
dog.root.children.push( rtInspector );
const capture = new Capture();
dog.root.children.push( capture );
// component logger must be last
const componentLogger = new ComponentLogger();
dog.root.children.push( componentLogger );
}
// == update =======================================================================================
const update = function(): void {
dog.update();
requestAnimationFrame( update );
};
update();
// == resize handler ===============================================================================
resizeObservers.push( ( [ width, height ] ) => {
canvas.width = width;
canvas.height = height;
canvasRenderTarget.viewport = [ 0, 0, width, height ];
cameraStackATarget.resize( width, height );
cameraStackBTarget.resize( width, height );
mixerTarget.resize( width, height );
if ( import.meta.env.DEV ) {
( postTarget as BufferTextureRenderTarget ).resize( width, height );
}
} );