nova64 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -8
- package/bin/nova64.js +165 -0
- package/dist/assets/console-CY_kygm3.js +14 -0
- package/dist/assets/console-CY_kygm3.js.map +1 -0
- package/dist/assets/main-l0sNRNKZ.js.map +1 -0
- package/dist/assets/sky/studio/nx.png +0 -0
- package/dist/assets/sky/studio/ny.png +0 -0
- package/dist/assets/sky/studio/nz.png +0 -0
- package/dist/assets/sky/studio/px.png +0 -0
- package/dist/assets/sky/studio/py.png +0 -0
- package/dist/assets/sky/studio/pz.png +0 -0
- package/dist/assets/vanilla-Dcuy32gi.js +2 -0
- package/dist/assets/vanilla-Dcuy32gi.js.map +1 -0
- package/dist/console.html +899 -0
- package/dist/docs/BENCHMARK.md +77 -0
- package/dist/docs/CHEATSHEET.md +255 -0
- package/dist/docs/EFFECTS_API_GUIDE.md +577 -0
- package/dist/docs/EFFECTS_QUICK_REFERENCE.md +331 -0
- package/dist/docs/FONT_CHARACTER_REFERENCE.md +219 -0
- package/dist/docs/FREE_GLB_ASSETS.md +330 -0
- package/dist/docs/FULLSCREEN_BUTTON_FEATURE.md +296 -0
- package/dist/docs/GAMEPAD_SUPPORT.md +348 -0
- package/dist/docs/GAME_IMPROVEMENTS.md +278 -0
- package/dist/docs/GAME_QUALITY_STATUS.md +300 -0
- package/dist/docs/MIGRATION_GUIDE.md +553 -0
- package/dist/docs/NOVA64_3D_API.md +356 -0
- package/dist/docs/NOVA64_API_REFERENCE.md +1406 -0
- package/dist/docs/NOVA64_UI_API.md +503 -0
- package/dist/docs/UI_SYSTEM_SUMMARY.md +445 -0
- package/dist/docs/VOXEL_ENGINE_GUIDE.md +662 -0
- package/dist/docs/VOXEL_QUICK_REFERENCE.md +386 -0
- package/dist/docs/api-3d.html +750 -0
- package/dist/docs/api-effects.html +385 -0
- package/dist/docs/api-improvements.md +121 -0
- package/dist/docs/api-skybox.html +407 -0
- package/dist/docs/api-sprites.html +321 -0
- package/dist/docs/api-voxel.html +337 -0
- package/dist/docs/api.html +543 -0
- package/dist/docs/assets.html +306 -0
- package/dist/docs/audio.html +340 -0
- package/dist/docs/blogs.html +286 -0
- package/dist/docs/collision.html +316 -0
- package/dist/docs/console.html +247 -0
- package/dist/docs/editor.html +297 -0
- package/dist/docs/font.html +247 -0
- package/dist/docs/framebuffer.html +247 -0
- package/dist/docs/fullscreen-button.html +297 -0
- package/dist/docs/gpu-systems.html +247 -0
- package/dist/docs/index.html +580 -0
- package/dist/docs/input.html +491 -0
- package/dist/docs/physics.html +311 -0
- package/dist/docs/screens.html +311 -0
- package/dist/docs/storage.html +311 -0
- package/dist/docs/textinput.html +332 -0
- package/dist/docs/ui.html +488 -0
- package/dist/examples/3d-advanced/code.js +695 -0
- package/dist/examples/adventure-comic-3d/code.js +342 -0
- package/dist/examples/audio-lab/code.js +150 -0
- package/dist/examples/boids-flocking/code.js +270 -0
- package/dist/examples/crystal-cathedral-3d/code.js +706 -0
- package/dist/examples/cyberpunk-city-3d/code.js +1383 -0
- package/dist/examples/demoscene/README.md +192 -0
- package/dist/examples/demoscene/code.js +1081 -0
- package/dist/examples/demoscene/meta.json +21 -0
- package/dist/examples/dungeon-crawler-3d/code.js +1117 -0
- package/dist/examples/f-zero-nova-3d/code.js +865 -0
- package/dist/examples/f-zero-nova-3d/code_old.js +1555 -0
- package/dist/examples/fps-demo-3d/code.js +744 -0
- package/dist/examples/game-of-life-3d/code.js +338 -0
- package/dist/examples/generative-art/code.js +632 -0
- package/dist/examples/hello-3d/code.js +325 -0
- package/dist/examples/hello-skybox/code.js +183 -0
- package/dist/examples/hello-world/code.js +19 -0
- package/dist/examples/input-showcase/code.js +109 -0
- package/dist/examples/instancing-demo/code.js +315 -0
- package/dist/examples/minecraft-demo/code.js +387 -0
- package/dist/examples/model-viewer-3d/code.js +114 -0
- package/dist/examples/mystical-realm-3d/code.js +1203 -0
- package/dist/examples/nature-explorer-3d/code.js +1318 -0
- package/dist/examples/particles-demo/code.js +522 -0
- package/dist/examples/pbr-showcase/code.js +140 -0
- package/dist/examples/physics-demo-3d/code.js +948 -0
- package/dist/examples/screen-demo/code.js +267 -0
- package/dist/examples/shooter-demo-3d/code.js +1286 -0
- package/dist/examples/space-combat-3d/IMPLEMENTATION_SUMMARY.md +109 -0
- package/dist/examples/space-combat-3d/README.md +135 -0
- package/dist/examples/space-combat-3d/code.js +1332 -0
- package/dist/examples/space-harrier-3d/code.js +923 -0
- package/dist/examples/star-fox-nova-3d/code.js +1116 -0
- package/dist/examples/star-fox-nova-3d/code_backup.js +410 -0
- package/dist/examples/star-fox-nova-3d/code_broken.js +1821 -0
- package/dist/examples/storage-quest/code.js +209 -0
- package/dist/examples/strider-demo-3d/IMPROVEMENT_OPTIONS.md +285 -0
- package/dist/examples/strider-demo-3d/cache-test.html +132 -0
- package/dist/examples/strider-demo-3d/code-fixed.js +582 -0
- package/dist/examples/strider-demo-3d/code-old.js +1537 -0
- package/dist/examples/strider-demo-3d/code.js +1462 -0
- package/dist/examples/strider-demo-3d/code.js.bak2 +1169 -0
- package/dist/examples/strider-demo-3d/fix-game.sh +53 -0
- package/dist/examples/super-plumber-64/README.md +128 -0
- package/dist/examples/super-plumber-64/code.js +1185 -0
- package/dist/examples/super-plumber-64/index.html +88 -0
- package/dist/examples/test-2d-overlay/code.js +32 -0
- package/dist/examples/test-font/code.js +51 -0
- package/dist/examples/test-minimal/code.js +21 -0
- package/dist/examples/ui-demo/code.js +306 -0
- package/dist/examples/wing-commander-space/README.md +180 -0
- package/dist/examples/wing-commander-space/code.js +1285 -0
- package/dist/examples/wizardry-3d/CHANGELOG.md +366 -0
- package/dist/examples/wizardry-3d/code.js +3928 -0
- package/dist/index.html +666 -0
- package/dist/os9-shell/assets/index-DIHfrTaW.css +1 -0
- package/dist/os9-shell/assets/index-KchE_ngx.js +483 -0
- package/dist/os9-shell/assets/index-KchE_ngx.js.map +1 -0
- package/dist/os9-shell/index.html +23 -0
- package/dist/os9-shell/nova-icon.svg +12 -0
- package/index.html +6 -1
- package/package.json +37 -32
- package/public/assets/sky/studio/nx.png +0 -0
- package/public/assets/sky/studio/ny.png +0 -0
- package/public/assets/sky/studio/nz.png +0 -0
- package/public/assets/sky/studio/px.png +0 -0
- package/public/assets/sky/studio/py.png +0 -0
- package/public/assets/sky/studio/pz.png +0 -0
- package/public/os9-shell/assets/index-KchE_ngx.js +483 -0
- package/public/os9-shell/assets/index-KchE_ngx.js.map +1 -0
- package/public/os9-shell/index.html +10 -1
- package/runtime/api-2d.js +301 -21
- package/runtime/api-3d/pbr.js +45 -1
- package/runtime/api-3d.js +1 -0
- package/runtime/api-effects.js +90 -3
- package/runtime/api-gameutils.js +476 -0
- package/runtime/api-generative.js +610 -0
- package/runtime/api-skybox.js +54 -0
- package/runtime/api-voxel.js +139 -28
- package/runtime/gpu-threejs.js +13 -9
- package/runtime/ui.js +2 -2
- package/src/main.js +24 -1
- package/public/os9-shell/assets/index-B1Uvacma.js +0 -32825
- package/public/os9-shell/assets/index-B1Uvacma.js.map +0 -1
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
# Nova64 Effects, Shaders & Post-Processing API
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Nova64 now includes a comprehensive effects system with custom shaders, post-processing, and particle effects for creating stunning visual experiences.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
✅ **Post-Processing Effects**: Bloom, FXAA anti-aliasing
|
|
10
|
+
✅ **Custom Shaders**: Holographic, energy shield, water, fire/plasma
|
|
11
|
+
✅ **Particle Systems**: GPU-accelerated particle effects
|
|
12
|
+
✅ **Real-time Updates**: Animated shaders with time-based effects
|
|
13
|
+
✅ **Easy Integration**: Simple API for adding effects to any game
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Post-Processing Effects
|
|
18
|
+
|
|
19
|
+
### Bloom Effect
|
|
20
|
+
|
|
21
|
+
Creates a glow around bright objects for a cinematic look.
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
// Enable bloom with default settings
|
|
25
|
+
enableBloom();
|
|
26
|
+
|
|
27
|
+
// Enable with custom settings
|
|
28
|
+
enableBloom(
|
|
29
|
+
1.5, // strength (0-3, default: 1.0)
|
|
30
|
+
0.5, // radius (0-1, default: 0.5)
|
|
31
|
+
0.85 // threshold (0-1, default: 0.85)
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
// Adjust bloom at runtime
|
|
35
|
+
setBloomStrength(2.0); // Increase intensity
|
|
36
|
+
setBloomRadius(0.8); // Wider glow
|
|
37
|
+
setBloomThreshold(0.5); // Glow on darker objects
|
|
38
|
+
|
|
39
|
+
// Disable bloom
|
|
40
|
+
disableBloom();
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Best For**: Sci-fi environments, neon cities, energy effects, explosions
|
|
44
|
+
|
|
45
|
+
### FXAA Anti-Aliasing
|
|
46
|
+
|
|
47
|
+
Smooths jagged edges for cleaner visuals.
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
// Enable FXAA
|
|
51
|
+
enableFXAA();
|
|
52
|
+
|
|
53
|
+
// Disable FXAA
|
|
54
|
+
disableFXAA();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Best For**: All games - improves visual quality with minimal performance cost
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Custom Shaders
|
|
62
|
+
|
|
63
|
+
### Holographic Shader
|
|
64
|
+
|
|
65
|
+
Creates a futuristic holographic effect with scanlines and glitches.
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
export async function init() {
|
|
69
|
+
// Create holographic material
|
|
70
|
+
const holo = createShaderMaterial('holographic', {
|
|
71
|
+
color: new THREE.Color(0x00ffff), // Cyan hologram
|
|
72
|
+
scanlineSpeed: 3.0, // Fast scanlines
|
|
73
|
+
glitchAmount: 0.15, // Subtle glitch
|
|
74
|
+
opacity: 0.7, // Semi-transparent
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Create a holographic cube
|
|
78
|
+
const cube = createCube(2, 0xffffff, [0, 0, -5]);
|
|
79
|
+
const mesh = getMesh(cube);
|
|
80
|
+
mesh.material = holo.material;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Update at runtime
|
|
84
|
+
export function update(dt) {
|
|
85
|
+
updateShaderUniform(holo.id, 'color', new THREE.Color(0xff00ff)); // Change color
|
|
86
|
+
updateShaderUniform(holo.id, 'scanlineSpeed', 5.0); // Faster effect
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Parameters**:
|
|
91
|
+
|
|
92
|
+
- `color`: Hologram color (THREE.Color)
|
|
93
|
+
- `scanlineSpeed`: Speed of scanline animation (0-10)
|
|
94
|
+
- `glitchAmount`: Intensity of glitch effect (0-1)
|
|
95
|
+
- `opacity`: Transparency (0-1)
|
|
96
|
+
|
|
97
|
+
**Best For**: Holograms, UI elements, data displays, sci-fi terminals
|
|
98
|
+
|
|
99
|
+
### Energy Shield Shader
|
|
100
|
+
|
|
101
|
+
Creates a force field effect with hexagon pattern and hit ripples.
|
|
102
|
+
|
|
103
|
+
```javascript
|
|
104
|
+
export async function init() {
|
|
105
|
+
// Create shield material
|
|
106
|
+
const shield = createShaderMaterial('shield', {
|
|
107
|
+
color: new THREE.Color(0x0088ff), // Blue shield
|
|
108
|
+
opacity: 0.5, // Transparent
|
|
109
|
+
hitPosition: new THREE.Vector3(0, 0, 0),
|
|
110
|
+
hitStrength: 0, // No hit initially
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// Create spherical shield around player
|
|
114
|
+
const shieldMesh = createSphere(3, 0xffffff, [0, 0, 0], 32);
|
|
115
|
+
const mesh = getMesh(shieldMesh);
|
|
116
|
+
mesh.material = shield.material;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Trigger hit effect
|
|
120
|
+
function onShieldHit(position) {
|
|
121
|
+
updateShaderUniform(shield.id, 'hitPosition', position);
|
|
122
|
+
updateShaderUniform(shield.id, 'hitStrength', 1.0);
|
|
123
|
+
|
|
124
|
+
// Fade out hit effect
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
updateShaderUniform(shield.id, 'hitStrength', 0.0);
|
|
127
|
+
}, 500);
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Parameters**:
|
|
132
|
+
|
|
133
|
+
- `color`: Shield color (THREE.Color)
|
|
134
|
+
- `opacity`: Base transparency (0-1)
|
|
135
|
+
- `hitPosition`: World position of impact (THREE.Vector3)
|
|
136
|
+
- `hitStrength`: Impact intensity (0-1)
|
|
137
|
+
|
|
138
|
+
**Best For**: Force fields, protective barriers, energy shields, bubble effects
|
|
139
|
+
|
|
140
|
+
### Water Shader
|
|
141
|
+
|
|
142
|
+
Animated water surface with waves and caustics.
|
|
143
|
+
|
|
144
|
+
```javascript
|
|
145
|
+
export async function init() {
|
|
146
|
+
// Create water material
|
|
147
|
+
const water = createShaderMaterial('water', {
|
|
148
|
+
color: new THREE.Color(0x0088ff), // Ocean blue
|
|
149
|
+
waveSpeed: 1.0, // Wave animation speed
|
|
150
|
+
waveHeight: 0.3, // Wave amplitude
|
|
151
|
+
transparency: 0.8, // See-through water
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// Create water plane
|
|
155
|
+
const waterPlane = createPlane(50, 50, [0, -1, 0]);
|
|
156
|
+
const mesh = getMesh(waterPlane);
|
|
157
|
+
mesh.material = water.material;
|
|
158
|
+
mesh.rotation.x = -Math.PI / 2; // Horizontal
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Parameters**:
|
|
163
|
+
|
|
164
|
+
- `color`: Water color (THREE.Color)
|
|
165
|
+
- `waveSpeed`: Animation speed (0-5)
|
|
166
|
+
- `waveHeight`: Wave amplitude (0-2)
|
|
167
|
+
- `transparency`: Opacity (0-1)
|
|
168
|
+
|
|
169
|
+
**Best For**: Oceans, lakes, rivers, liquid surfaces, underwater scenes
|
|
170
|
+
|
|
171
|
+
### Fire/Plasma Shader
|
|
172
|
+
|
|
173
|
+
Animated fire effect with noise-based flames.
|
|
174
|
+
|
|
175
|
+
```javascript
|
|
176
|
+
export async function init() {
|
|
177
|
+
// Create fire material
|
|
178
|
+
const fire = createShaderMaterial('fire', {
|
|
179
|
+
color1: new THREE.Color(0xff4400), // Orange base
|
|
180
|
+
color2: new THREE.Color(0xffff00), // Yellow tips
|
|
181
|
+
intensity: 1.5, // Brightness
|
|
182
|
+
speed: 2.0, // Animation speed
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// Create fire plane
|
|
186
|
+
const firePlane = createPlane(2, 3, [0, 1.5, 0]);
|
|
187
|
+
const mesh = getMesh(firePlane);
|
|
188
|
+
mesh.material = fire.material;
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Parameters**:
|
|
193
|
+
|
|
194
|
+
- `color1`: Base fire color (THREE.Color)
|
|
195
|
+
- `color2`: Flame tip color (THREE.Color)
|
|
196
|
+
- `intensity`: Brightness (0-3)
|
|
197
|
+
- `speed`: Animation speed (0-5)
|
|
198
|
+
|
|
199
|
+
**Best For**: Fire, explosions, energy beams, plasma effects, lava
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Particle Systems
|
|
204
|
+
|
|
205
|
+
Create GPU-accelerated particle effects for explosions, smoke, sparks, etc.
|
|
206
|
+
|
|
207
|
+
### Basic Particle System
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
let explosionParticles;
|
|
211
|
+
|
|
212
|
+
export async function init() {
|
|
213
|
+
// Create explosion particle system
|
|
214
|
+
explosionParticles = createParticleSystem(1000, {
|
|
215
|
+
color: 0xff8800, // Orange
|
|
216
|
+
size: 0.2, // Particle size
|
|
217
|
+
speed: 5.0, // Initial velocity
|
|
218
|
+
lifetime: 2.0, // Seconds before respawn
|
|
219
|
+
spread: 1.0, // Spawn area radius
|
|
220
|
+
gravity: -2.0, // Downward acceleration
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
explosionParticles.position.set(0, 0, -5);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export function update(dt) {
|
|
227
|
+
// Update particle physics
|
|
228
|
+
updateParticles(explosionParticles, dt);
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Advanced Examples
|
|
233
|
+
|
|
234
|
+
**Smoke Effect**:
|
|
235
|
+
|
|
236
|
+
```javascript
|
|
237
|
+
const smoke = createParticleSystem(500, {
|
|
238
|
+
color: 0x888888, // Gray smoke
|
|
239
|
+
size: 0.5,
|
|
240
|
+
speed: 1.0,
|
|
241
|
+
lifetime: 3.0,
|
|
242
|
+
spread: 0.5,
|
|
243
|
+
gravity: 1.0, // Rises up
|
|
244
|
+
});
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**Sparks**:
|
|
248
|
+
|
|
249
|
+
```javascript
|
|
250
|
+
const sparks = createParticleSystem(200, {
|
|
251
|
+
color: 0xffff00, // Yellow sparks
|
|
252
|
+
size: 0.1,
|
|
253
|
+
speed: 8.0,
|
|
254
|
+
lifetime: 0.5, // Short-lived
|
|
255
|
+
spread: 0.2,
|
|
256
|
+
gravity: -5.0, // Falls quickly
|
|
257
|
+
});
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**Magic Spell**:
|
|
261
|
+
|
|
262
|
+
```javascript
|
|
263
|
+
const magic = createParticleSystem(300, {
|
|
264
|
+
color: 0xff00ff, // Purple magic
|
|
265
|
+
size: 0.15,
|
|
266
|
+
speed: 2.0,
|
|
267
|
+
lifetime: 2.5,
|
|
268
|
+
spread: 1.0,
|
|
269
|
+
gravity: 0.5, // Slow rise
|
|
270
|
+
});
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Complete Game Examples
|
|
276
|
+
|
|
277
|
+
### Sci-Fi Space Shooter
|
|
278
|
+
|
|
279
|
+
```javascript
|
|
280
|
+
let shieldEffect, engineParticles, explosionEffect;
|
|
281
|
+
let bloomEnabled = false;
|
|
282
|
+
|
|
283
|
+
export async function init() {
|
|
284
|
+
// Enable bloom for glowing effects
|
|
285
|
+
enableBloom(1.5, 0.5, 0.8);
|
|
286
|
+
bloomEnabled = true;
|
|
287
|
+
|
|
288
|
+
// Enable anti-aliasing
|
|
289
|
+
enableFXAA();
|
|
290
|
+
|
|
291
|
+
// Create player shield
|
|
292
|
+
const shield = createShaderMaterial('shield', {
|
|
293
|
+
color: new THREE.Color(0x00ffff),
|
|
294
|
+
opacity: 0.3,
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
const playerShield = createSphere(2, 0xffffff, [0, 0, 0], 32);
|
|
298
|
+
const shieldMesh = getMesh(playerShield);
|
|
299
|
+
shieldMesh.material = shield.material;
|
|
300
|
+
shieldEffect = shield.id;
|
|
301
|
+
|
|
302
|
+
// Engine trail particles
|
|
303
|
+
engineParticles = createParticleSystem(500, {
|
|
304
|
+
color: 0x0088ff,
|
|
305
|
+
size: 0.1,
|
|
306
|
+
speed: 3.0,
|
|
307
|
+
lifetime: 1.0,
|
|
308
|
+
spread: 0.3,
|
|
309
|
+
gravity: 0,
|
|
310
|
+
});
|
|
311
|
+
engineParticles.position.set(0, 0, 2); // Behind player
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export function update(dt) {
|
|
315
|
+
// Update particle effects
|
|
316
|
+
updateParticles(engineParticles, dt);
|
|
317
|
+
|
|
318
|
+
// Follow player position
|
|
319
|
+
engineParticles.position.copy(player.position);
|
|
320
|
+
engineParticles.position.z += 2;
|
|
321
|
+
|
|
322
|
+
// Pulse bloom intensity based on speed
|
|
323
|
+
const bloomIntensity = 1.0 + player.speed * 0.5;
|
|
324
|
+
setBloomStrength(bloomIntensity);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function onPlayerHit(hitPosition) {
|
|
328
|
+
// Flash shield on hit
|
|
329
|
+
updateShaderUniform(shieldEffect, 'hitPosition', hitPosition);
|
|
330
|
+
updateShaderUniform(shieldEffect, 'hitStrength', 1.0);
|
|
331
|
+
|
|
332
|
+
setTimeout(() => {
|
|
333
|
+
updateShaderUniform(shieldEffect, 'hitStrength', 0.0);
|
|
334
|
+
}, 300);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function createExplosion(position) {
|
|
338
|
+
const explosion = createParticleSystem(300, {
|
|
339
|
+
color: 0xff4400,
|
|
340
|
+
size: 0.3,
|
|
341
|
+
speed: 10.0,
|
|
342
|
+
lifetime: 1.5,
|
|
343
|
+
spread: 0.1,
|
|
344
|
+
gravity: 0,
|
|
345
|
+
});
|
|
346
|
+
explosion.position.copy(position);
|
|
347
|
+
|
|
348
|
+
// Remove after lifetime
|
|
349
|
+
setTimeout(() => {
|
|
350
|
+
scene.remove(explosion);
|
|
351
|
+
}, 1500);
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Cyberpunk City
|
|
356
|
+
|
|
357
|
+
```javascript
|
|
358
|
+
let hologramBillboards = [];
|
|
359
|
+
let neonGlow;
|
|
360
|
+
|
|
361
|
+
export async function init() {
|
|
362
|
+
// Enable bloom for neon glow
|
|
363
|
+
enableBloom(2.0, 0.8, 0.6);
|
|
364
|
+
enableFXAA();
|
|
365
|
+
|
|
366
|
+
// Create holographic billboards
|
|
367
|
+
for (let i = 0; i < 10; i++) {
|
|
368
|
+
const holo = createShaderMaterial('holographic', {
|
|
369
|
+
color: new THREE.Color(Math.random() * 0xffffff),
|
|
370
|
+
scanlineSpeed: 2.0 + Math.random() * 3.0,
|
|
371
|
+
glitchAmount: 0.1,
|
|
372
|
+
opacity: 0.8,
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
const billboard = createPlane(4, 3, [
|
|
376
|
+
(Math.random() - 0.5) * 50,
|
|
377
|
+
10 + Math.random() * 20,
|
|
378
|
+
(Math.random() - 0.5) * 50,
|
|
379
|
+
]);
|
|
380
|
+
|
|
381
|
+
const mesh = getMesh(billboard);
|
|
382
|
+
mesh.material = holo.material;
|
|
383
|
+
|
|
384
|
+
hologramBillboards.push(holo.id);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// Add atmospheric particles (rain/dust)
|
|
388
|
+
const atmosphere = createParticleSystem(2000, {
|
|
389
|
+
color: 0x4488ff,
|
|
390
|
+
size: 0.05,
|
|
391
|
+
speed: 5.0,
|
|
392
|
+
lifetime: 3.0,
|
|
393
|
+
spread: 30.0,
|
|
394
|
+
gravity: -8.0, // Falling rain
|
|
395
|
+
});
|
|
396
|
+
atmosphere.position.set(0, 50, 0);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export function update(dt) {
|
|
400
|
+
// Random glitch effects on holograms
|
|
401
|
+
hologramBillboards.forEach(holoId => {
|
|
402
|
+
if (Math.random() < 0.01) {
|
|
403
|
+
// 1% chance per frame
|
|
404
|
+
updateShaderUniform(holoId, 'glitchAmount', 0.5);
|
|
405
|
+
setTimeout(() => {
|
|
406
|
+
updateShaderUniform(holoId, 'glitchAmount', 0.1);
|
|
407
|
+
}, 100);
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Fantasy Water World
|
|
414
|
+
|
|
415
|
+
```javascript
|
|
416
|
+
let oceanSurface, bubbleParticles;
|
|
417
|
+
|
|
418
|
+
export async function init() {
|
|
419
|
+
enableFXAA();
|
|
420
|
+
|
|
421
|
+
// Create animated ocean
|
|
422
|
+
const ocean = createShaderMaterial('water', {
|
|
423
|
+
color: new THREE.Color(0x0066cc),
|
|
424
|
+
waveSpeed: 0.5,
|
|
425
|
+
waveHeight: 0.5,
|
|
426
|
+
transparency: 0.7,
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
const waterPlane = createPlane(100, 100, [0, 0, 0]);
|
|
430
|
+
const mesh = getMesh(waterPlane);
|
|
431
|
+
mesh.material = ocean.material;
|
|
432
|
+
mesh.rotation.x = -Math.PI / 2;
|
|
433
|
+
oceanSurface = ocean.id;
|
|
434
|
+
|
|
435
|
+
// Underwater bubbles
|
|
436
|
+
bubbleParticles = createParticleSystem(500, {
|
|
437
|
+
color: 0xaaddff,
|
|
438
|
+
size: 0.2,
|
|
439
|
+
speed: 2.0,
|
|
440
|
+
lifetime: 4.0,
|
|
441
|
+
spread: 20.0,
|
|
442
|
+
gravity: 2.0, // Bubbles rise
|
|
443
|
+
});
|
|
444
|
+
bubbleParticles.position.set(0, -5, 0);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
export function update(dt) {
|
|
448
|
+
updateParticles(bubbleParticles, dt);
|
|
449
|
+
|
|
450
|
+
// Vary wave intensity based on game events
|
|
451
|
+
const waveIntensity = 0.3 + Math.sin(Date.now() * 0.001) * 0.2;
|
|
452
|
+
updateShaderUniform(oceanSurface, 'waveHeight', waveIntensity);
|
|
453
|
+
}
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
## Performance Tips
|
|
459
|
+
|
|
460
|
+
### 1. **Use Bloom Wisely**
|
|
461
|
+
|
|
462
|
+
```javascript
|
|
463
|
+
// Good - bloom on bright emissive objects
|
|
464
|
+
setBloomThreshold(0.85); // Only very bright objects glow
|
|
465
|
+
|
|
466
|
+
// Bad - everything glows (performance hit)
|
|
467
|
+
setBloomThreshold(0.0);
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
### 2. **Limit Particle Count**
|
|
471
|
+
|
|
472
|
+
```javascript
|
|
473
|
+
// Mobile/Low-end: 500 particles max
|
|
474
|
+
const particles = createParticleSystem(500, {...});
|
|
475
|
+
|
|
476
|
+
// Desktop/High-end: 2000 particles
|
|
477
|
+
const particles = createParticleSystem(2000, {...});
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
### 3. **Reuse Particle Systems**
|
|
481
|
+
|
|
482
|
+
```javascript
|
|
483
|
+
// Good - one system for all explosions
|
|
484
|
+
const explosionPool = createParticleSystem(1000, {...});
|
|
485
|
+
|
|
486
|
+
// Bad - new system for each explosion (memory leak!)
|
|
487
|
+
function explode() {
|
|
488
|
+
createParticleSystem(500, {...}); // Don't do this repeatedly!
|
|
489
|
+
}
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
### 4. **Shader Complexity**
|
|
493
|
+
|
|
494
|
+
- Holographic: Low cost
|
|
495
|
+
- Shield/Water: Medium cost
|
|
496
|
+
- Fire: Higher cost (noise calculations)
|
|
497
|
+
|
|
498
|
+
---
|
|
499
|
+
|
|
500
|
+
## Troubleshooting
|
|
501
|
+
|
|
502
|
+
### Effects Not Visible
|
|
503
|
+
|
|
504
|
+
**Problem**: Called `enableBloom()` but no effect visible
|
|
505
|
+
|
|
506
|
+
**Solution**: Check bloom threshold and material emissive
|
|
507
|
+
|
|
508
|
+
```javascript
|
|
509
|
+
enableBloom(1.5, 0.5, 0.5); // Lower threshold
|
|
510
|
+
|
|
511
|
+
// Make materials emissive for bloom
|
|
512
|
+
const material = createN64Material({
|
|
513
|
+
color: 0xff0000,
|
|
514
|
+
emissive: 0xff0000,
|
|
515
|
+
emissiveIntensity: 1.0,
|
|
516
|
+
});
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
### Particles Not Moving
|
|
520
|
+
|
|
521
|
+
**Problem**: Particles created but stationary
|
|
522
|
+
|
|
523
|
+
**Solution**: Call `updateParticles()` every frame
|
|
524
|
+
|
|
525
|
+
```javascript
|
|
526
|
+
export function update(dt) {
|
|
527
|
+
updateParticles(myParticles, dt); // Must call this!
|
|
528
|
+
}
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
### Shader Appears Black
|
|
532
|
+
|
|
533
|
+
**Problem**: Custom shader shows as black
|
|
534
|
+
|
|
535
|
+
**Solution**: Check lighting and transparency
|
|
536
|
+
|
|
537
|
+
```javascript
|
|
538
|
+
const shader = createShaderMaterial('holographic', {
|
|
539
|
+
color: new THREE.Color(0xff0000), // Ensure color is set
|
|
540
|
+
opacity: 1.0, // Not fully transparent
|
|
541
|
+
});
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
---
|
|
545
|
+
|
|
546
|
+
## API Reference
|
|
547
|
+
|
|
548
|
+
### Post-Processing
|
|
549
|
+
|
|
550
|
+
- `enableBloom(strength, radius, threshold)` - Enable bloom glow
|
|
551
|
+
- `disableBloom()` - Disable bloom
|
|
552
|
+
- `setBloomStrength(value)` - Adjust bloom intensity (0-3)
|
|
553
|
+
- `setBloomRadius(value)` - Adjust bloom spread (0-1)
|
|
554
|
+
- `setBloomThreshold(value)` - Minimum brightness for bloom (0-1)
|
|
555
|
+
- `enableFXAA()` - Enable anti-aliasing
|
|
556
|
+
- `disableFXAA()` - Disable anti-aliasing
|
|
557
|
+
|
|
558
|
+
### Custom Shaders
|
|
559
|
+
|
|
560
|
+
- `createShaderMaterial(name, uniforms)` - Create shader material
|
|
561
|
+
- Shaders: `'holographic'`, `'shield'`, `'water'`, `'fire'`
|
|
562
|
+
- `updateShaderUniform(shaderId, name, value)` - Update shader parameter
|
|
563
|
+
|
|
564
|
+
### Particles
|
|
565
|
+
|
|
566
|
+
- `createParticleSystem(count, options)` - Create particle effect
|
|
567
|
+
- `updateParticles(system, deltaTime)` - Update particle physics
|
|
568
|
+
|
|
569
|
+
---
|
|
570
|
+
|
|
571
|
+
## Conclusion
|
|
572
|
+
|
|
573
|
+
The Nova64 effects system brings professional-quality visuals to your games with minimal code. Combine bloom, custom shaders, and particles to create stunning sci-fi, fantasy, or modern environments.
|
|
574
|
+
|
|
575
|
+
For more examples, check out the updated game demos in `/examples/`.
|
|
576
|
+
|
|
577
|
+
Happy creating! ✨
|