@descix/frqtl-web 0.6.0-p1.1 → 0.6.0
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/CLAUDE.md +23 -14
- package/README.md +51 -13
- package/dist/artifact/double-slit.html +2 -2
- package/dist/dist-manifest.json +74 -71
- package/dist/experiments/empty/index.html +26 -11
- package/dist/frqtl/compat/providers/wasm-engine.js +3 -4
- package/dist/frqtl/compat/renderer/providers/p5-provider.js +1 -1
- package/dist/frqtl/experiments/_shared/doors.js +17 -12
- package/dist/frqtl/objects/FrqtlApp.js +33 -6
- package/dist/frqtl/objects/RecipeContext.js +284 -13
- package/dist/frqtl/objects/constants/WallBehaviors.js +1 -1
- package/dist/frqtl/objects/instruments/capture.js +1 -24
- package/dist/frqtl/objects/instruments/hosted-eyes.js +216 -29
- package/dist/frqtl/objects/objects/makeControlsForObject.js +5 -5
- package/dist/frqtl/objects/record/Record.js +346 -0
- package/dist/frqtl/objects/record/open-record.js +22 -0
- package/dist/frqtl/objects/schema/engine-scopes.js +2 -2
- package/dist/frqtl/objects/schema/scopes.js +2 -2
- package/dist/frqtl/objects/setup/_worldInit.js +1 -2
- package/dist/frqtl/objects/setup/setupBlackbodySubstrate.js +1 -2
- package/dist/frqtl/parts/CameraControls.js +8 -0
- package/dist/frqtl/parts/DetectorWall.js +1 -1
- package/dist/frqtl/parts/FrqtlVision.js +21 -6
- package/dist/frqtl/parts/GraphingDetectorWall.js +7 -7
- package/dist/frqtl/parts/LargeObject.js +2 -2
- package/dist/frqtl/parts/LiveChart.js +2 -2
- package/dist/frqtl/parts/LogicGate.js +3 -3
- package/dist/frqtl/parts/OvenBox.js +1 -1
- package/dist/frqtl/parts/PointSource.js +1 -1
- package/dist/frqtl/parts/SlitLightSource.js +1 -1
- package/dist/frqtl/parts/SlitScreen.js +1 -1
- package/dist/frqtl/parts/SphereEmitter.js +12 -12
- package/dist/frqtl/parts/Trace.js +1 -1
- package/dist/frqtl/parts/Tunnel.js +11 -11
- package/dist/frqtl/parts/Wall.js +20 -10
- package/dist/frqtl/scenes/circuit-sat.js +1 -0
- package/dist/frqtl/scenes/dse-one-emitter.js +32 -34
- package/dist/frqtl/scenes/dse-two-emitters.js +33 -34
- package/dist/frqtl/scenes/mirror-route.js +96 -79
- package/dist/frqtl-web.min.js +54 -50
- package/dist/sdk.html +2 -2
- package/dist/shim/bundle/index.js +118 -96
- package/dist/shim/bundle/indexHtml.js +66 -39
- package/dist/shim/controls/index.js +1 -1
- package/dist/shim/engine/artifact-shell.js +1 -1
- package/dist/shim/engine/router.js +3 -3
- package/dist/shim/host/host-view.js +228 -0
- package/dist/shim/host/index.js +18 -0
- package/dist/shim/index.js +3 -5
- package/dist/shim/notebook/format.js +1 -1
- package/dist/shim/notebook/kernel.js +1 -1
- package/dist/shim/notebook/setup-builder.js +2 -2
- package/dist/shim/notebook/store.js +2 -3
- package/dist/shim/package.json +1 -0
- package/dist/shim/page-params/index.js +2 -30
- package/dist/shim/project/fork.js +293 -0
- package/dist/shim/project/identity.js +3 -1
- package/dist/shim/project/index.js +16 -3
- package/dist/shim/project/link.js +224 -46
- package/dist/shim/project/manifest.js +151 -0
- package/dist/shim/project/parts-writer.js +68 -7
- package/dist/shim/project/read-text.js +43 -0
- package/dist/shim/project/record-format.js +345 -0
- package/dist/shim/project/specifiers.js +104 -15
- package/dist/shim/registry/exhibits.js +15 -34
- package/dist/shim/registry/index.js +3 -3
- package/dist/shim/registry/scene-roster.js +35 -0
- package/dist/shim/registry/scene-source.js +48 -64
- package/dist/shim/registry/walkthrough.js +6 -6
- package/dist/shim/render-state/apply.js +66 -31
- package/dist/shim/render-state/index.js +6 -2
- package/dist/shim/runtime/index.js +4 -4
- package/dist/shim/storage/codec-chains.js +88 -0
- package/dist/shim/storage/folders.js +205 -0
- package/dist/shim/storage/index.js +64 -8
- package/dist/shim/storage/make-namespace-store.js +5 -5
- package/llms.txt +13 -10
- package/package.json +20 -2
- package/dist/frqtl/experiments/_shared/fx-experiment.js +0 -449
- package/dist/js/models/flamingo-draco.glb +0 -0
- package/dist/js/models/flamingo.glb +0 -0
- package/dist/shim/bundle/frqnb.js +0 -112
- package/dist/shim/bundle/manifest.js +0 -95
- package/dist/shim/registry/experiments.js +0 -215
- package/dist/shim/storage/modules.js +0 -249
- package/dist/shim/storage/projects.js +0 -150
|
@@ -19,102 +19,119 @@
|
|
|
19
19
|
// captured descriptor DATA) keeps the population bounded so FPS stays healthy, Restart-safe.
|
|
20
20
|
//
|
|
21
21
|
// ONE MODE-AWARE SOURCE. The mode strip selects the RENDERER the host boots
|
|
22
|
-
// (renderState.renderer), and this scene reads it ONCE,
|
|
22
|
+
// (renderState.renderer), and this scene reads it ONCE, inside buildExperiment: `three` ⇒
|
|
23
23
|
// exp.createScene (a 600x400x600 world), else exp.createCanvas (600x400). The ring geometry,
|
|
24
|
-
// tilts, colours, laser and gate are the SAME in both modes (2D≡3D)
|
|
25
|
-
//
|
|
24
|
+
// tilts, colours, laser and gate are the SAME in both modes (2D≡3D). `parts` is written in the
|
|
25
|
+
// 3D default mode, and flat2D (below) derives the 2D block from it — the scene's own statement of
|
|
26
|
+
// two of its deltas:
|
|
26
27
|
// (a) every mirror is a 3D SLAB — a z-slab centred on the beam plane z=0, rendered as a plate;
|
|
27
28
|
// (b) the laser is VOLUMETRIC (is2D:false — it braids in y AND z; the slab depth catches the
|
|
28
|
-
// z-braid; its tilted xy faces reflect by the 2θ law, its near/far z-faces bounce vz)
|
|
29
|
+
// z-braid; its tilted xy faces reflect by the 2θ law, its near/far z-faces bounce vz).
|
|
30
|
+
// `IS3D` guards the rest, in code after exp.declare:
|
|
29
31
|
// (c) two invisible destroy z-collimators flush with the slab z-band;
|
|
30
|
-
// (d) the population counter carries a z-slab covering the WHOLE universe z-band
|
|
32
|
+
// (d) the population counter carries a z-slab covering the WHOLE universe z-band (the emitter's
|
|
33
|
+
// gateCounter names it, so it stays a code declaration);
|
|
31
34
|
// (e) MOVE/LOOK camera joysticks (the OMNI_3D pattern).
|
|
32
35
|
// The 3D mode's render intent — god-rays at the sun's settings, computed from the light
|
|
33
36
|
// particles only (godraySource 'leaf'), and the 'table-top' camera — rides the registry mode's
|
|
34
37
|
// renderState (lib/shim/registry/walkthrough.js), whose god-ray VALUES are the sun's, owned by
|
|
35
38
|
// lib/shim/render/sun-look.js.
|
|
36
39
|
|
|
37
|
-
import { CameraControls, SphereEmitter } from '@descix/frqtl-web/parts';
|
|
40
|
+
import { CameraControls, SphereEmitter, Wall } from '@descix/frqtl-web/parts';
|
|
38
41
|
import * as FrqtlDisplay from '@descix/frqtl-web/compat/renderer/display-slot.js';
|
|
39
42
|
|
|
40
|
-
|
|
43
|
+
const W = 600, H = 400, WORLD_D = 600; // THE WORLD this scene states (its co-init call below)
|
|
44
|
+
const f = Math.min(W, H) / 600;
|
|
45
|
+
// R 225·f: adjacent decagon vertices sit 2R·sin18° ≈ 0.618R apart vs slab
|
|
46
|
+
// height ~110·f, so the mirrors separate with clear gaps. Fit: R + rotated-slab half-diagonal
|
|
47
|
+
// (≈55·f) stays inside min(W,H)/2 with margin.
|
|
48
|
+
const CX = Math.round(W / 2), CY = Math.round(H / 2), R = Math.round(225 * f), HOP = 3, ROT = 12;
|
|
49
|
+
// CAP 6400 / burst 8 (brightness retune): a VERY BRIGHT braid. The cap is
|
|
50
|
+
// LIVE-controllable off the population counter (select 'population' in Layers → Inspector
|
|
51
|
+
// 'Population Gate').
|
|
52
|
+
const SW = Math.max(10, Math.round(14 * f)), SH = Math.max(70, Math.round(110 * f)), CAP = 6400;
|
|
53
|
+
// SD — the 3D slab z-depth: a 2:1 tile (twice the slab height, z-centred on the beam plane).
|
|
54
|
+
// The scene z-collimator clamps ALL quanta to this band, so every mirror provably faces every
|
|
55
|
+
// alive quantum.
|
|
56
|
+
const SD = 2 * SH;
|
|
57
|
+
// Each mirror a DIFFERENT colour = its identity (a red→magenta rainbow); the recolor hook
|
|
58
|
+
// stamps that colour onto every particle it reflects (string_map['render.color']).
|
|
59
|
+
const PAL = [[255,60,60],[255,140,0],[255,220,0],[150,230,40],[40,210,90],[0,210,190],[0,170,255],[70,90,255],[150,70,235],[235,50,190]];
|
|
60
|
+
// Hit-order vertices of the {10/3} star (m1..m10 named IN the order the beam visits them).
|
|
61
|
+
const order = []; for (var k = 0; k < 10; k++) { order.push((k * HOP) % 10); }
|
|
62
|
+
const D2R = Math.PI / 180;
|
|
63
|
+
const vpos = function (v) { var a = (v * 36 + ROT) * D2R; return [CX + R * Math.cos(a), CY + R * Math.sin(a)]; };
|
|
64
|
+
const pos = order.map(vpos);
|
|
65
|
+
const deg = function (a) { return ((a * 180 / Math.PI) % 360 + 360) % 360; };
|
|
66
|
+
const angOf = function (p, q) { return deg(Math.atan2(q[1] - p[1], q[0] - p[0])); };
|
|
67
|
+
// Per-mirror IN-PLANE orientation from the in/out chords: ori = (in+out−180)/2, branch chosen
|
|
68
|
+
// so the engine reflect law out = 180 + 2·ori − in reproduces the outgoing chord exactly.
|
|
69
|
+
// Orientation is z-axis rotation, so the 3D slab depth adds NO new angle.
|
|
70
|
+
const ORI = [];
|
|
71
|
+
for (var j = 0; j < 10; j++) {
|
|
72
|
+
var pr = pos[(j + 9) % 10], cu = pos[j], nx = pos[(j + 1) % 10];
|
|
73
|
+
var inA = angOf(pr, cu), outA = angOf(cu, nx);
|
|
74
|
+
var o = (((inA + outA - 180) / 2) % 360 + 360) % 360;
|
|
75
|
+
var op = ((180 + 2 * o - inA) % 360 + 360) % 360;
|
|
76
|
+
if (Math.abs(((op - outA + 540) % 360) - 180) > 0.5) { o = (o + 90) % 360; }
|
|
77
|
+
ORI.push(o);
|
|
78
|
+
}
|
|
79
|
+
// The NARROW STRAIGHT-WALK laser (the exemplar): the SAME emitter as Rung 1
|
|
80
|
+
// (Straight Walk) — preset 'particle-walk', every walk-character field INHERITED from the same
|
|
81
|
+
// factory defaults (chargeMode 'positive', dim 0 = 'light' P=1, fundamentalWaveLength 64 → the
|
|
82
|
+
// λ16 braided transverse ripple) — with ONLY the deliberate loop deltas: (a) a 2px source line
|
|
83
|
+
// (emissionBoxSide 2 vs r1's default 10), (b) seated on the m10→m1 leg JUST CLEAR of m10 (70·f
|
|
84
|
+
// past its vertex > the rotated-slab half-diagonal ≈55·f) and aimed along the leg (the longest
|
|
85
|
+
// clear throw: leg 1.618R ≈ 364·f), (c) a burst of 8/tick, and (d) the DECLARED emission gate.
|
|
86
|
+
const pS = pos[9], p0 = pos[0];
|
|
87
|
+
const dx = p0[0] - pS[0], dy = p0[1] - pS[1], L = Math.hypot(dx, dy), ux = dx / L, uy = dy / L;
|
|
88
|
+
const emit = [Math.round(pS[0] + 70 * f * ux), Math.round(pS[1] + 70 * f * uy)];
|
|
89
|
+
// EMISSION-CAP GATE as DECLARED DATA (the blackbody-thermostat pattern):
|
|
90
|
+
// emissionCap + gateCounter compile at CONSTRUCTION into a host tick-fn reading
|
|
91
|
+
// Wall.getLiveCount on the background counter named 'population' (placed below — the by-name
|
|
92
|
+
// reference resolves lazily on the first tick). The closed loop has NO sink, so the gate pauses
|
|
93
|
+
// emission at the cap and resumes below it: the population plateaus. Restart-safe: the parts
|
|
94
|
+
// writer keeps the two fields in the entry and the rebuilt emitter recompiles the gate (no free recipe tick-fn).
|
|
95
|
+
// is2D: false (the 3D default) opens activeAxes.z — the volumetric laser; flat2D writes it true.
|
|
96
|
+
// The parts, written in the 3D default mode (the mode strip's default): the laser, then the ten mirrors at the
|
|
97
|
+
// star vertices — each its own colour + the recolor tag, each a 3D SLAB (z-slab -SD/2..SD/2). 2D is derived from
|
|
98
|
+
// this block by flat2D below.
|
|
99
|
+
export const parts = {
|
|
100
|
+
source: [SphereEmitter, { preset: 'particle-walk', is2D: false, center: emit, orientationDeg: angOf(pS, p0), emissionBoxSide: 2, burstSize: 8, emissionCap: CAP, gateCounter: 'population' }],
|
|
101
|
+
m1: [Wall, { rect: [Math.round(pos[0][0] - SW / 2), Math.round(pos[0][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[0], color: PAL[0], hooks: ['recolor'] }],
|
|
102
|
+
m2: [Wall, { rect: [Math.round(pos[1][0] - SW / 2), Math.round(pos[1][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[1], color: PAL[1], hooks: ['recolor'] }],
|
|
103
|
+
m3: [Wall, { rect: [Math.round(pos[2][0] - SW / 2), Math.round(pos[2][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[2], color: PAL[2], hooks: ['recolor'] }],
|
|
104
|
+
m4: [Wall, { rect: [Math.round(pos[3][0] - SW / 2), Math.round(pos[3][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[3], color: PAL[3], hooks: ['recolor'] }],
|
|
105
|
+
m5: [Wall, { rect: [Math.round(pos[4][0] - SW / 2), Math.round(pos[4][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[4], color: PAL[4], hooks: ['recolor'] }],
|
|
106
|
+
m6: [Wall, { rect: [Math.round(pos[5][0] - SW / 2), Math.round(pos[5][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[5], color: PAL[5], hooks: ['recolor'] }],
|
|
107
|
+
m7: [Wall, { rect: [Math.round(pos[6][0] - SW / 2), Math.round(pos[6][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[6], color: PAL[6], hooks: ['recolor'] }],
|
|
108
|
+
m8: [Wall, { rect: [Math.round(pos[7][0] - SW / 2), Math.round(pos[7][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[7], color: PAL[7], hooks: ['recolor'] }],
|
|
109
|
+
m9: [Wall, { rect: [Math.round(pos[8][0] - SW / 2), Math.round(pos[8][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[8], color: PAL[8], hooks: ['recolor'] }],
|
|
110
|
+
m10: [Wall, { rect: [Math.round(pos[9][0] - SW / 2), Math.round(pos[9][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[9], color: PAL[9], hooks: ['recolor'] }],
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/** This scene's 2D delta, stated once: the same keys in the same order, each props copied with its z-slab
|
|
114
|
+
* (z, depth) dropped and is2D written true where it is spelled. Pure; adds no key. */
|
|
115
|
+
function flat2D(parts) {
|
|
116
|
+
const out = {};
|
|
117
|
+
for (const key of Object.keys(parts)) {
|
|
118
|
+
const props = Object.assign({}, parts[key][1]);
|
|
119
|
+
delete props.z;
|
|
120
|
+
delete props.depth;
|
|
121
|
+
if ('is2D' in props) { props.is2D = true; }
|
|
122
|
+
out[key] = [parts[key][0], props];
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
41
126
|
|
|
42
127
|
export default function buildExperiment(exp) {
|
|
43
128
|
// The booted display (the host's renderState.renderer) decides which world this mode makes.
|
|
44
129
|
var IS3D = FrqtlDisplay.name() === 'three';
|
|
45
|
-
var
|
|
46
|
-
var f = Math.min(W, H) / 600;
|
|
47
|
-
// R 225·f: adjacent decagon vertices sit 2R·sin18° ≈ 0.618R apart vs slab
|
|
48
|
-
// height ~110·f, so the mirrors separate with clear gaps. Fit: R + rotated-slab half-diagonal
|
|
49
|
-
// (≈55·f) stays inside min(W,H)/2 with margin.
|
|
50
|
-
var CX = Math.round(W / 2), CY = Math.round(H / 2), R = Math.round(225 * f), HOP = 3, ROT = 12;
|
|
51
|
-
// CAP 6400 / burst 8 (brightness retune): a VERY BRIGHT braid. The cap is
|
|
52
|
-
// LIVE-controllable off the population counter (select 'population' in Layers → Inspector
|
|
53
|
-
// 'Population Gate').
|
|
54
|
-
var SW = Math.max(10, Math.round(14 * f)), SH = Math.max(70, Math.round(110 * f)), CAP = 6400;
|
|
55
|
-
// SD — the 3D slab z-depth: a 2:1 tile (twice the slab height, z-centred on the beam plane).
|
|
56
|
-
// The scene z-collimator clamps ALL quanta to this band, so every mirror provably faces every
|
|
57
|
-
// alive quantum.
|
|
58
|
-
var SD = 2 * SH;
|
|
59
|
-
// Each mirror a DIFFERENT colour = its identity (a red→magenta rainbow); the recolor hook
|
|
60
|
-
// stamps that colour onto every particle it reflects (string_map['render.color']).
|
|
61
|
-
var PAL = [[255,60,60],[255,140,0],[255,220,0],[150,230,40],[40,210,90],[0,210,190],[0,170,255],[70,90,255],[150,70,235],[235,50,190]];
|
|
62
|
-
// Hit-order vertices of the {10/3} star (m1..m10 named IN the order the beam visits them).
|
|
63
|
-
var order = []; for (var k = 0; k < 10; k++) { order.push((k * HOP) % 10); }
|
|
64
|
-
var D2R = Math.PI / 180;
|
|
65
|
-
var vpos = function (v) { var a = (v * 36 + ROT) * D2R; return [CX + R * Math.cos(a), CY + R * Math.sin(a)]; };
|
|
66
|
-
var pos = order.map(vpos);
|
|
67
|
-
var deg = function (a) { return ((a * 180 / Math.PI) % 360 + 360) % 360; };
|
|
68
|
-
var angOf = function (p, q) { return deg(Math.atan2(q[1] - p[1], q[0] - p[0])); };
|
|
69
|
-
// Per-mirror IN-PLANE orientation from the in/out chords: ori = (in+out−180)/2, branch chosen
|
|
70
|
-
// so the engine reflect law out = 180 + 2·ori − in reproduces the outgoing chord exactly.
|
|
71
|
-
// Orientation is z-axis rotation, so the 3D slab depth adds NO new angle.
|
|
72
|
-
var ORI = [];
|
|
73
|
-
for (var j = 0; j < 10; j++) {
|
|
74
|
-
var pr = pos[(j + 9) % 10], cu = pos[j], nx = pos[(j + 1) % 10];
|
|
75
|
-
var inA = angOf(pr, cu), outA = angOf(cu, nx);
|
|
76
|
-
var o = (((inA + outA - 180) / 2) % 360 + 360) % 360;
|
|
77
|
-
var op = ((180 + 2 * o - inA) % 360 + 360) % 360;
|
|
78
|
-
if (Math.abs(((op - outA + 540) % 360) - 180) > 0.5) { o = (o + 90) % 360; }
|
|
79
|
-
ORI.push(o);
|
|
80
|
-
}
|
|
81
|
-
// The NARROW STRAIGHT-WALK laser (the exemplar): the SAME emitter as Rung 1
|
|
82
|
-
// (Straight Walk) — preset 'particle-walk', every walk-character field INHERITED from the same
|
|
83
|
-
// factory defaults (chargeMode 'positive', dim 0 = 'light' P=1, fundamentalWaveLength 64 → the
|
|
84
|
-
// λ16 braided transverse ripple) — with ONLY the deliberate loop deltas: (a) a 2px source line
|
|
85
|
-
// (emissionBoxSide 2 vs r1's default 10), (b) seated on the m10→m1 leg JUST CLEAR of m10 (70·f
|
|
86
|
-
// past its vertex > the rotated-slab half-diagonal ≈55·f) and aimed along the leg (the longest
|
|
87
|
-
// clear throw: leg 1.618R ≈ 364·f), (c) a burst of 8/tick, and (d) the DECLARED emission gate.
|
|
88
|
-
var pS = pos[9], p0 = pos[0];
|
|
89
|
-
var dx = p0[0] - pS[0], dy = p0[1] - pS[1], L = Math.hypot(dx, dy), ux = dx / L, uy = dy / L;
|
|
90
|
-
var emit = [Math.round(pS[0] + 70 * f * ux), Math.round(pS[1] + 70 * f * uy)];
|
|
91
|
-
// EMISSION-CAP GATE as DECLARED DATA (the blackbody-thermostat pattern):
|
|
92
|
-
// emissionCap + gateCounter compile at CONSTRUCTION into a host tick-fn reading
|
|
93
|
-
// Wall.getLiveCount on the background counter named 'population' (placed below — the by-name
|
|
94
|
-
// reference resolves lazily on the first tick). The closed loop has NO sink, so the gate pauses
|
|
95
|
-
// emission at the cap and resumes below it: the population plateaus. Restart-safe: codegen
|
|
96
|
-
// captures the two fields and the rebuilt emitter recompiles the gate (no free recipe tick-fn).
|
|
97
|
-
// is2D:!IS3D opens activeAxes.z in 3D — the volumetric laser.
|
|
98
|
-
var SRC = {
|
|
99
|
-
preset: 'particle-walk', is2D: !IS3D, center: emit, orientationDeg: angOf(pS, p0),
|
|
100
|
-
emissionBoxSide: 2, burstSize: 8,
|
|
101
|
-
emissionCap: CAP, gateCounter: 'population'
|
|
102
|
-
};
|
|
130
|
+
var P = IS3D ? parts : flat2D(parts);
|
|
103
131
|
// THE WORLD — first, then parts: a 3D scene + universe (600x400x600) or a 2D canvas + universe.
|
|
104
|
-
if (IS3D) { exp.createScene(W, H, WORLD_D, SphereEmitter.worldCfg(
|
|
105
|
-
else { exp.createCanvas(W, H, SphereEmitter.worldCfg(
|
|
106
|
-
exp.declare(
|
|
107
|
-
exp.addObject('SphereEmitter', SRC);
|
|
108
|
-
// The ten mirrors at the star vertices — each its own colour + the recolor tag. In 3D each is a
|
|
109
|
-
// SLAB (z-slab −SD/2..SD/2); in 2D the bag is EMPTY, so the wall is the flat mirror.
|
|
110
|
-
var ZSLAB = IS3D ? { z: -Math.round(SD / 2), depth: SD } : {};
|
|
111
|
-
for (var i = 0; i < 10; i++) {
|
|
112
|
-
var p = pos[i];
|
|
113
|
-
exp.addObject('Wall', Object.assign(
|
|
114
|
-
{ rect: [Math.round(p[0] - SW / 2), Math.round(p[1] - SH / 2), SW, SH] }, ZSLAB,
|
|
115
|
-
{ collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[i],
|
|
116
|
-
name: 'm' + (i + 1), color: PAL[i], hooks: ['recolor'] }));
|
|
117
|
-
}
|
|
132
|
+
if (IS3D) { exp.createScene(W, H, WORLD_D, SphereEmitter.worldCfg(P.source[1])); }
|
|
133
|
+
else { exp.createCanvas(W, H, SphereEmitter.worldCfg(P.source[1])); }
|
|
134
|
+
exp.declare(P);
|
|
118
135
|
if (IS3D) {
|
|
119
136
|
// SCENE Z-COLLIMATOR (without it the z lets things pass through instead of
|
|
120
137
|
// reflecting): the legs' z-braid diffuses lap over lap; any quantum beyond the mirrors'
|