@guinetik/gcanvas 1.0.4 → 1.0.5
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/dist/CNAME +1 -0
- package/dist/animations.html +31 -0
- package/dist/basic.html +38 -0
- package/dist/baskara.html +31 -0
- package/dist/bezier.html +35 -0
- package/dist/beziersignature.html +29 -0
- package/dist/blackhole.html +28 -0
- package/dist/blob.html +35 -0
- package/dist/coordinates.html +698 -0
- package/dist/cube3d.html +23 -0
- package/dist/demos.css +303 -0
- package/dist/dino.html +42 -0
- package/dist/easing.html +28 -0
- package/dist/events.html +195 -0
- package/dist/fluent.html +647 -0
- package/dist/fluid-simple.html +22 -0
- package/dist/fluid.html +37 -0
- package/dist/fractals.html +36 -0
- package/dist/gameobjects.html +626 -0
- package/dist/gcanvas.es.js +517 -0
- package/dist/gcanvas.es.min.js +1 -1
- package/dist/gcanvas.umd.js +1 -1
- package/dist/gcanvas.umd.min.js +1 -1
- package/dist/genart.html +26 -0
- package/dist/gendream.html +26 -0
- package/dist/group.html +36 -0
- package/dist/home.html +587 -0
- package/dist/hyperbolic001.html +23 -0
- package/dist/hyperbolic002.html +23 -0
- package/dist/hyperbolic003.html +23 -0
- package/dist/hyperbolic004.html +23 -0
- package/dist/hyperbolic005.html +22 -0
- package/dist/index.html +398 -0
- package/dist/isometric.html +34 -0
- package/dist/js/animations.js +452 -0
- package/dist/js/basic.js +204 -0
- package/dist/js/baskara.js +751 -0
- package/dist/js/bezier.js +692 -0
- package/dist/js/beziersignature.js +241 -0
- package/dist/js/blackhole/accretiondisk.obj.js +379 -0
- package/dist/js/blackhole/blackhole.obj.js +318 -0
- package/dist/js/blackhole/index.js +409 -0
- package/dist/js/blackhole/particle.js +56 -0
- package/dist/js/blackhole/starfield.obj.js +218 -0
- package/dist/js/blob.js +2276 -0
- package/dist/js/coordinates.js +840 -0
- package/dist/js/cube3d.js +789 -0
- package/dist/js/dino.js +1420 -0
- package/dist/js/easing.js +477 -0
- package/dist/js/fluent.js +183 -0
- package/dist/js/fluid-simple.js +253 -0
- package/dist/js/fluid.js +527 -0
- package/dist/js/fractals.js +932 -0
- package/dist/js/fractalworker.js +93 -0
- package/dist/js/gameobjects.js +176 -0
- package/dist/js/genart.js +268 -0
- package/dist/js/gendream.js +209 -0
- package/dist/js/group.js +140 -0
- package/dist/js/hyperbolic001.js +310 -0
- package/dist/js/hyperbolic002.js +388 -0
- package/dist/js/hyperbolic003.js +319 -0
- package/dist/js/hyperbolic004.js +345 -0
- package/dist/js/hyperbolic005.js +340 -0
- package/dist/js/info-toggle.js +25 -0
- package/dist/js/isometric.js +863 -0
- package/dist/js/kerr.js +1547 -0
- package/dist/js/lavalamp.js +590 -0
- package/dist/js/layout.js +354 -0
- package/dist/js/mondrian.js +285 -0
- package/dist/js/opacity.js +275 -0
- package/dist/js/painter.js +484 -0
- package/dist/js/particles-showcase.js +514 -0
- package/dist/js/particles.js +299 -0
- package/dist/js/patterns.js +397 -0
- package/dist/js/penrose/artifact.js +69 -0
- package/dist/js/penrose/blackhole.js +121 -0
- package/dist/js/penrose/constants.js +73 -0
- package/dist/js/penrose/game.js +943 -0
- package/dist/js/penrose/lore.js +278 -0
- package/dist/js/penrose/penrosescene.js +892 -0
- package/dist/js/penrose/ship.js +216 -0
- package/dist/js/penrose/sounds.js +211 -0
- package/dist/js/penrose/voidparticle.js +55 -0
- package/dist/js/penrose/voidscene.js +258 -0
- package/dist/js/penrose/voidship.js +144 -0
- package/dist/js/penrose/wormhole.js +46 -0
- package/dist/js/pipeline.js +555 -0
- package/dist/js/plane3d.js +256 -0
- package/dist/js/platformer.js +1579 -0
- package/dist/js/scene.js +304 -0
- package/dist/js/scenes.js +320 -0
- package/dist/js/schrodinger.js +410 -0
- package/dist/js/schwarzschild.js +1015 -0
- package/dist/js/shapes.js +628 -0
- package/dist/js/space/alien.js +171 -0
- package/dist/js/space/boom.js +98 -0
- package/dist/js/space/boss.js +353 -0
- package/dist/js/space/buff.js +73 -0
- package/dist/js/space/bullet.js +102 -0
- package/dist/js/space/constants.js +85 -0
- package/dist/js/space/game.js +1884 -0
- package/dist/js/space/hud.js +112 -0
- package/dist/js/space/laserbeam.js +179 -0
- package/dist/js/space/lightning.js +277 -0
- package/dist/js/space/minion.js +192 -0
- package/dist/js/space/missile.js +212 -0
- package/dist/js/space/player.js +430 -0
- package/dist/js/space/powerup.js +90 -0
- package/dist/js/space/starfield.js +58 -0
- package/dist/js/space/starpower.js +90 -0
- package/dist/js/spacetime.js +559 -0
- package/dist/js/sphere3d.js +229 -0
- package/dist/js/sprite.js +473 -0
- package/dist/js/starfaux/config.js +118 -0
- package/dist/js/starfaux/enemy.js +353 -0
- package/dist/js/starfaux/hud.js +78 -0
- package/dist/js/starfaux/index.js +482 -0
- package/dist/js/starfaux/laser.js +182 -0
- package/dist/js/starfaux/player.js +468 -0
- package/dist/js/starfaux/terrain.js +560 -0
- package/dist/js/study001.js +275 -0
- package/dist/js/study002.js +366 -0
- package/dist/js/study003.js +331 -0
- package/dist/js/study004.js +389 -0
- package/dist/js/study005.js +209 -0
- package/dist/js/study006.js +194 -0
- package/dist/js/study007.js +192 -0
- package/dist/js/study008.js +413 -0
- package/dist/js/svgtween.js +204 -0
- package/dist/js/tde/accretiondisk.js +471 -0
- package/dist/js/tde/blackhole.js +219 -0
- package/dist/js/tde/blackholescene.js +209 -0
- package/dist/js/tde/config.js +59 -0
- package/dist/js/tde/index.js +820 -0
- package/dist/js/tde/jets.js +290 -0
- package/dist/js/tde/lensedstarfield.js +154 -0
- package/dist/js/tde/tdestar.js +297 -0
- package/dist/js/tde/tidalstream.js +372 -0
- package/dist/js/tde_old/blackhole.obj.js +354 -0
- package/dist/js/tde_old/debris.obj.js +791 -0
- package/dist/js/tde_old/flare.obj.js +239 -0
- package/dist/js/tde_old/index.js +448 -0
- package/dist/js/tde_old/star.obj.js +812 -0
- package/dist/js/tetris/config.js +157 -0
- package/dist/js/tetris/grid.js +286 -0
- package/dist/js/tetris/index.js +1195 -0
- package/dist/js/tetris/renderer.js +634 -0
- package/dist/js/tetris/tetrominos.js +280 -0
- package/dist/js/tiles.js +312 -0
- package/dist/js/tweendemo.js +79 -0
- package/dist/js/visibility.js +102 -0
- package/dist/kerr.html +28 -0
- package/dist/lavalamp.html +27 -0
- package/dist/layouts.html +37 -0
- package/dist/logo.svg +4 -0
- package/dist/loop.html +84 -0
- package/dist/mondrian.html +32 -0
- package/dist/og_image.png +0 -0
- package/dist/opacity.html +36 -0
- package/dist/painter.html +39 -0
- package/dist/particles-showcase.html +28 -0
- package/dist/particles.html +24 -0
- package/dist/patterns.html +33 -0
- package/dist/penrose-game.html +31 -0
- package/dist/pipeline.html +737 -0
- package/dist/plane3d.html +24 -0
- package/dist/platformer.html +43 -0
- package/dist/scene.html +33 -0
- package/dist/scenes.html +96 -0
- package/dist/schrodinger.html +27 -0
- package/dist/schwarzschild.html +27 -0
- package/dist/shapes.html +16 -0
- package/dist/space.html +85 -0
- package/dist/spacetime.html +27 -0
- package/dist/sphere3d.html +24 -0
- package/dist/sprite.html +18 -0
- package/dist/starfaux.html +22 -0
- package/dist/study001.html +23 -0
- package/dist/study002.html +23 -0
- package/dist/study003.html +23 -0
- package/dist/study004.html +23 -0
- package/dist/study005.html +22 -0
- package/dist/study006.html +24 -0
- package/dist/study007.html +24 -0
- package/dist/study008.html +22 -0
- package/dist/svgtween.html +29 -0
- package/dist/tde.html +28 -0
- package/dist/tetris3d.html +25 -0
- package/dist/tiles.html +28 -0
- package/dist/transforms.html +400 -0
- package/dist/tween.html +45 -0
- package/dist/visibility.html +33 -0
- package/package.json +1 -1
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { Scene3D } from "/gcanvas.es.min.js";
|
|
2
|
+
import { BlackHole } from "./blackhole.js";
|
|
3
|
+
import { Star } from "./tdestar.js";
|
|
4
|
+
import { TidalStream } from "./tidalstream.js";
|
|
5
|
+
import { AccretionDisk } from "./accretiondisk.js";
|
|
6
|
+
import { RelativisticJets } from "./jets.js";
|
|
7
|
+
import { CONFIG } from "./config.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* BlackHoleScene - Main 3D scene containing the TDE visualization
|
|
11
|
+
*
|
|
12
|
+
* Z-Order Rendering Rules:
|
|
13
|
+
* 1. BlackHole renders at the back (dark shadow)
|
|
14
|
+
* 2. AccretionDisk renders over the black hole (particles curve around)
|
|
15
|
+
* 3. TidalStream always on top of star and black hole
|
|
16
|
+
* 4. Star position relative to BlackHole changes based on camera depth
|
|
17
|
+
*
|
|
18
|
+
* Z-Index Buckets (lower = renders first = behind):
|
|
19
|
+
* - starBack: 10 (star when behind BH)
|
|
20
|
+
* - blackHole: 15 (dark shadow at back)
|
|
21
|
+
* - disk: 20 (accretion disk over BH)
|
|
22
|
+
* - starFront: 25 (star when in front of BH)
|
|
23
|
+
* - stream: 30 (particles - always on top)
|
|
24
|
+
* - jets: 40 (always on top)
|
|
25
|
+
*
|
|
26
|
+
* @extends Scene3D
|
|
27
|
+
*/
|
|
28
|
+
export class BlackHoleScene extends Scene3D {
|
|
29
|
+
constructor(game, options = {}) {
|
|
30
|
+
super(game, options);
|
|
31
|
+
// Camera is passed via options and handled by Scene3D
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Z-index buckets for render ordering
|
|
35
|
+
* Scene3D sorts by zIndex first (lower renders first/behind),
|
|
36
|
+
* then uses camera depth as tie-breaker
|
|
37
|
+
*
|
|
38
|
+
* Layering (simple):
|
|
39
|
+
* - BlackHole at back (dark shadow)
|
|
40
|
+
* - Disk renders over BH (particles curve around it)
|
|
41
|
+
* - Stream always on top of star and BH
|
|
42
|
+
* - Star moves in front of/behind BH based on camera view
|
|
43
|
+
*/
|
|
44
|
+
this.Z = {
|
|
45
|
+
starBack: 10, // Star when behind BH
|
|
46
|
+
blackHole: 15, // BlackHole: dark shadow at back
|
|
47
|
+
disk: 1, // AccretionDisk: over the black hole
|
|
48
|
+
starFront: 25, // Star when in front of BH
|
|
49
|
+
stream: 30, // TidalStream: always on top of star and BH
|
|
50
|
+
jets: 1, // Jets: always on top
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
init() {
|
|
55
|
+
// Z-order buckets: lower draws first, equal uses depth
|
|
56
|
+
// IMPORTANT: Set zIndex AFTER add() because ZOrderedCollection.add()
|
|
57
|
+
// overwrites zIndex with array index
|
|
58
|
+
|
|
59
|
+
// Add BlackHole at (0,0,0)
|
|
60
|
+
this.bh = new BlackHole(this.game);
|
|
61
|
+
this.add(this.bh);
|
|
62
|
+
this.bh.zIndex = this.Z.blackHole; // Set AFTER add()
|
|
63
|
+
|
|
64
|
+
// Add a Star orbiting the black hole
|
|
65
|
+
this.star = new Star(this.game);
|
|
66
|
+
this.add(this.star);
|
|
67
|
+
this.star.zIndex = this.Z.starFront; // Set AFTER add(), will be updated per-frame
|
|
68
|
+
|
|
69
|
+
// Add accretion disk (starts inactive)
|
|
70
|
+
this.disk = new AccretionDisk(this.game, {
|
|
71
|
+
camera: this.game.camera,
|
|
72
|
+
bhRadius: this.game.baseScale * CONFIG.bhRadiusRatio,
|
|
73
|
+
bhMass: CONFIG.blackHole.initialMass,
|
|
74
|
+
onParticleConsumed: () => {
|
|
75
|
+
this.bh.addConsumedMass(0.1); // Disk particles worth more
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
this.add(this.disk);
|
|
79
|
+
this.disk.zIndex = this.Z.disk; // Set AFTER add()
|
|
80
|
+
|
|
81
|
+
// Add tidal stream for particles
|
|
82
|
+
// When particles are consumed, feed the black hole
|
|
83
|
+
// When particles circularize, transfer to accretion disk
|
|
84
|
+
this.stream = new TidalStream(this.game, {
|
|
85
|
+
camera: this.game.camera,
|
|
86
|
+
scene: this, // Pass scene reference for screen center
|
|
87
|
+
bhRadius: this.game.baseScale * CONFIG.bhRadiusRatio,
|
|
88
|
+
diskInnerRadius: this.disk.innerRadius,
|
|
89
|
+
diskOuterRadius: this.disk.outerRadius,
|
|
90
|
+
onParticleConsumed: () => {
|
|
91
|
+
this.bh.addConsumedMass(0.05); // Each particle adds small amount
|
|
92
|
+
},
|
|
93
|
+
onParticleCaptured: (p) => {
|
|
94
|
+
this.disk.captureParticle(p);
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
this.add(this.stream);
|
|
98
|
+
this.stream.zIndex = this.Z.stream; // Set AFTER add()
|
|
99
|
+
|
|
100
|
+
// Add relativistic jets (activated during flare phase)
|
|
101
|
+
this.jets = new RelativisticJets(this.game, {
|
|
102
|
+
camera: this.game.camera,
|
|
103
|
+
bhRadius: this.game.baseScale * CONFIG.bhRadiusRatio,
|
|
104
|
+
});
|
|
105
|
+
this.add(this.jets);
|
|
106
|
+
this.jets.zIndex = this.Z.jets; // Set AFTER add()
|
|
107
|
+
|
|
108
|
+
// Mark z-order as dirty to ensure initial sort
|
|
109
|
+
if (this._collection) {
|
|
110
|
+
this._collection._zOrderDirty = true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
update(dt) {
|
|
115
|
+
super.update(dt);
|
|
116
|
+
|
|
117
|
+
// Sync all particle systems with current BH radius (grows as it feeds)
|
|
118
|
+
if (this.bh) {
|
|
119
|
+
if (this.stream) {
|
|
120
|
+
this.stream.updateBHRadius(this.bh.currentRadius);
|
|
121
|
+
}
|
|
122
|
+
if (this.disk) {
|
|
123
|
+
this.disk.updateBHRadius(this.bh.currentRadius);
|
|
124
|
+
// Also sync stream's disk bounds for capture detection
|
|
125
|
+
if (this.stream) {
|
|
126
|
+
this.stream.updateDiskBounds(this.disk.innerRadius, this.disk.outerRadius);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (this.jets) {
|
|
130
|
+
this.jets.updateBHRadius(this.bh.currentRadius);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Note: Z-order update is called from TDEDemo.update() AFTER star position
|
|
135
|
+
// is updated, to ensure we use the current frame's position, not the previous frame's.
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Update star's z-index based on its depth relative to the black hole
|
|
140
|
+
*
|
|
141
|
+
* Dynamic z-ordering:
|
|
142
|
+
* - When star in front of BH: star renders on top of BH
|
|
143
|
+
* - When star behind BH: BH renders on top of star
|
|
144
|
+
* - Stream (particles) always stays on top of both
|
|
145
|
+
*
|
|
146
|
+
* Camera3D.project() returns z as depth after rotation:
|
|
147
|
+
* - Lower z = closer to camera
|
|
148
|
+
* - Higher z = farther from camera
|
|
149
|
+
*
|
|
150
|
+
* IMPORTANT: Must be called AFTER star position is updated each frame.
|
|
151
|
+
*/
|
|
152
|
+
updateStarZOrder() {
|
|
153
|
+
if (!this.star || !this.bh || !this.game?.camera) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const camera = this.game.camera;
|
|
158
|
+
|
|
159
|
+
// Project star position to get its depth after camera rotation
|
|
160
|
+
const projStar = camera.project(
|
|
161
|
+
this.star.x || 0,
|
|
162
|
+
this.star.y || 0,
|
|
163
|
+
this.star.z || 0
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
// Black hole is always at origin (0, 0, 0)
|
|
167
|
+
const projBH = camera.project(0, 0, 0);
|
|
168
|
+
|
|
169
|
+
// Star is "in front" if its depth is LESS than BH's depth
|
|
170
|
+
const starInFront = projStar.z < projBH.z;
|
|
171
|
+
|
|
172
|
+
// Update star's z-index
|
|
173
|
+
const newZIndex = starInFront ? this.Z.starFront : this.Z.starBack;
|
|
174
|
+
|
|
175
|
+
if (this.star.zIndex !== newZIndex) {
|
|
176
|
+
this.star.zIndex = newZIndex;
|
|
177
|
+
// Mark ordering dirty so Scene3D resort happens this frame
|
|
178
|
+
if (this._collection) {
|
|
179
|
+
this._collection._zOrderDirty = true;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
onResize() {
|
|
185
|
+
const game = this.game;
|
|
186
|
+
if (this.bh) {
|
|
187
|
+
this.bh.onResize(game.baseScale * CONFIG.bhRadiusRatio);
|
|
188
|
+
}
|
|
189
|
+
if (this.star) {
|
|
190
|
+
this.star.onResize(
|
|
191
|
+
game.baseScale * CONFIG.starRadiusRatio,
|
|
192
|
+
game.baseScale * CONFIG.star.initialOrbitRadius
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
if (this.disk && this.bh) {
|
|
196
|
+
this.disk.updateBHRadius(this.bh.currentRadius);
|
|
197
|
+
}
|
|
198
|
+
if (this.stream && this.bh) {
|
|
199
|
+
this.stream.updateBHRadius(this.bh.currentRadius);
|
|
200
|
+
// Update disk bounds for capture detection
|
|
201
|
+
if (this.disk) {
|
|
202
|
+
this.stream.updateDiskBounds(this.disk.innerRadius, this.disk.outerRadius);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (this.jets && this.bh) {
|
|
206
|
+
this.jets.updateBHRadius(this.bh.currentRadius);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export const CONFIG = {
|
|
2
|
+
// Sizing (as fraction of screen baseScale)
|
|
3
|
+
bhRadiusRatio: 0.01, // Initial dormant black hole size (larger for visible lensing)
|
|
4
|
+
bhFinalRadiusRatio: 0.12, // Final size after consuming star
|
|
5
|
+
starRadiusRatio: 0.08,
|
|
6
|
+
|
|
7
|
+
// Phase durations (seconds)
|
|
8
|
+
durations: {
|
|
9
|
+
approach: 12.0, // Stable wide orbit
|
|
10
|
+
stretch: 10.0, // Orbit begins to decay
|
|
11
|
+
disrupt: 20.0, // Mass transfer (event-based exit)
|
|
12
|
+
accrete: 1.0, // Debris accretion
|
|
13
|
+
flare: 5.0, // Jets firing - spectacular cosmic event!
|
|
14
|
+
stable: Infinity, // Final stable state
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
// Flash effect (now handled by Tweenetik in FSM)
|
|
18
|
+
|
|
19
|
+
// Physics params
|
|
20
|
+
blackHole: {
|
|
21
|
+
initialMass: 2,
|
|
22
|
+
color: "#000",
|
|
23
|
+
},
|
|
24
|
+
star: {
|
|
25
|
+
initialMass: 25,
|
|
26
|
+
color: "#FF6030", // Deep red-orange (cooler K/M type star)
|
|
27
|
+
// Orbit sizing (fraction of half the smaller screen dimension)
|
|
28
|
+
// apoapsis = initialOrbitRadius * (1 + eccentricity)
|
|
29
|
+
// periapsis = initialOrbitRadius * (1 - eccentricity)
|
|
30
|
+
initialOrbitRadius: 1.2, // Semi-major axis
|
|
31
|
+
eccentricity: 0.25, // Lower = more circular, periapsis closer to edge
|
|
32
|
+
// With these values:
|
|
33
|
+
// periapsis (right) = 1.2 * 0.75 = 0.9 (90% to edge - visible on RIGHT side!)
|
|
34
|
+
// apoapsis (left) = 1.2 * 1.25 = 1.5 (goes off screen left)
|
|
35
|
+
orbitSpeed: 0.4,
|
|
36
|
+
decayRate: 0.4,
|
|
37
|
+
massTransferStart: 0.1,
|
|
38
|
+
rotationSpeed: 0.71,
|
|
39
|
+
temperature: 3800,
|
|
40
|
+
orbitCenterX: 0,
|
|
41
|
+
orbitCenterY: 0,
|
|
42
|
+
bypassConstraints: true,
|
|
43
|
+
// Start angle: star should be VISIBLE at start, then swing through orbit
|
|
44
|
+
// 0 = right (periapsis), π/2 = top, π = left (apoapsis), 3π/2 = bottom
|
|
45
|
+
startAngle: Math.PI * 1.85, // Start lower-right, comes FROM right, swings up and around
|
|
46
|
+
},
|
|
47
|
+
sceneOptions: {
|
|
48
|
+
starCount: 5000,
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
// Accretion disk settings
|
|
52
|
+
disk: {
|
|
53
|
+
innerRadiusRatio: 0.03, // ISCO (innermost stable orbit)
|
|
54
|
+
outerRadiusRatio: 0.15, // Outer halo edge
|
|
55
|
+
maxParticles: 2000,
|
|
56
|
+
orbitalSpeed: 0.8,
|
|
57
|
+
activationProgress: 0.8, // Start at 80% of disrupt phase
|
|
58
|
+
},
|
|
59
|
+
};
|