@threenative/core 0.3.11 → 0.3.12
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/capabilities.json +1096 -26
- package/dist/camera-shake-CZKOfGn4.d.ts +46 -0
- package/dist/{canvas-layer-vCtanIeB.d.ts → canvas-layer-CWuFRT7G.d.ts} +1 -1
- package/dist/chunk-2Z44XSI2.js +35 -0
- package/dist/chunk-5O73CDMR.js +1849 -0
- package/dist/chunk-6KLNISRJ.js +153 -0
- package/dist/chunk-7UUT3TY5.js +133 -0
- package/dist/chunk-CFGTPFUH.js +231 -0
- package/dist/chunk-DBELTTTM.js +615 -0
- package/dist/chunk-GMHATRPW.js +7701 -0
- package/dist/chunk-GXY7B3JG.js +46 -0
- package/dist/chunk-KIRUKTBQ.js +187 -0
- package/dist/chunk-N5LRP4BR.js +220 -0
- package/dist/chunk-OKXUCASC.js +2238 -0
- package/dist/chunk-QWJEMUUT.js +94 -0
- package/dist/chunk-VAZM36TV.js +497 -0
- package/dist/{game-DzMcitDO.d.ts → game-D7pAzZUY.d.ts} +15 -3
- package/dist/hot.d.ts +3 -3
- package/dist/hot.js +2 -46
- package/dist/index.d.ts +329 -302
- package/dist/index.js +10566 -22552
- package/dist/{model-lod-CTpZ6imz.d.ts → model-lod-B6BMqS1r.d.ts} +33 -3
- package/dist/playtest.d.ts +3 -3
- package/dist/playtest.js +24 -75
- package/dist/react-css.js +1 -215
- package/dist/react.d.ts +2 -2
- package/dist/{renderer-rZm0hVqq.d.ts → renderer-DvFVoAgj.d.ts} +13 -4
- package/dist/spells/index.d.ts +643 -0
- package/dist/spells/index.js +1558 -0
- package/dist/spells/ultra/index.d.ts +1600 -0
- package/dist/spells/ultra/index.js +6804 -0
- package/dist/terrain-jobs-worker.js +1 -123
- package/dist/two-sided-foliage-W523J3UM.js +1 -0
- package/dist/ui-layer.js +5 -384
- package/dist/worker.js +4 -41
- package/dist/world.d.ts +725 -259
- package/dist/world.js +16714 -18284
- package/mcp/animation-server.mjs +1 -1
- package/mcp/animation.mjs +2 -3
- package/mcp/engine-server.mjs +142 -47
- package/mcp/servers.mjs +9 -2
- package/mcp/terrain.mjs +8 -0
- package/package.json +14 -6
- package/patches/three@0.187.0-prd269-upgrade.patch +2102 -0
- package/patches/three@0.187.0.patch +2004 -407
- package/src/assets.ts +9 -2
- package/src/card-lod.ts +152 -0
- package/src/compressed-texture-preparation.ts +1008 -0
- package/src/frame-budget.ts +31 -20
- package/src/game-dev-tools.ts +93 -0
- package/src/game-frame-loop.ts +995 -0
- package/src/game-renderer-metrics.ts +77 -0
- package/src/game-startup.ts +1001 -0
- package/src/game-validate.ts +70 -0
- package/src/game.ts +253 -1935
- package/src/index.ts +27 -2
- package/src/launch-diagnostics.ts +22 -12
- package/src/look/ao-admission.ts +24 -0
- package/src/look/filmic-tone-mapping.ts +15 -13
- package/src/look/look-diagnostics.ts +3 -3
- package/src/look/quality.ts +10 -5
- package/src/look/world-environment.ts +76 -9
- package/src/loop.ts +29 -0
- package/src/model-lod.ts +42 -3
- package/src/particle-kinds.ts +515 -0
- package/src/picking.ts +17 -3
- package/src/playtest.ts +27 -1
- package/src/projection-apply.ts +4 -1
- package/src/projection-plan.ts +9 -6
- package/src/render/mesh-pool.ts +1 -1
- package/src/render/resolution-subrect.ts +2 -0
- package/src/render/rough-diffuse.ts +46 -12
- package/src/render/soft-shadow.ts +27 -12
- package/src/render/virtual-shadow-adaptive.ts +55 -0
- package/src/render/virtual-shadow-casters.ts +175 -0
- package/src/render/virtual-shadow-layers.ts +76 -0
- package/src/render/virtual-shadow-level.ts +224 -0
- package/src/render/virtual-shadow-markers.ts +193 -0
- package/src/render/virtual-shadow-options.ts +370 -0
- package/src/render/virtual-shadow-pages.ts +5 -0
- package/src/render/virtual-shadow.ts +213 -992
- package/src/render/world-impostor-surface.ts +293 -34
- package/src/render-pass-budget.ts +34 -7
- package/src/renderProjection.ts +22 -0
- package/src/renderer.ts +92 -37
- package/src/snow-field.ts +1 -1
- package/src/spells/cast-pool.ts +361 -0
- package/src/spells/index.ts +177 -0
- package/src/spells/mechanisms.ts +295 -0
- package/src/spells/reaction-field.ts +415 -0
- package/src/spells/spell-lights.ts +139 -0
- package/src/spells/spell-world.ts +187 -0
- package/src/spells/spell.ts +397 -0
- package/src/spells/spells.ts +283 -0
- package/src/spells/ultra/engine/camera.ts +184 -0
- package/src/spells/ultra/engine/quality.ts +96 -0
- package/src/spells/ultra/index.ts +52 -0
- package/src/spells/ultra/main.ts +305 -0
- package/src/spells/ultra/scene/arenaMaterial.ts +325 -0
- package/src/spells/ultra/spells/cast.ts +233 -0
- package/src/spells/ultra/spells/fire.ts +1267 -0
- package/src/spells/ultra/vfx/FluidVolume.ts +816 -0
- package/src/spells/ultra/vfx/FluidVolume.tsl.ts +855 -0
- package/src/spells/ultra/vfx/FxTarget.ts +61 -0
- package/src/spells/ultra/vfx/GroundField.ts +1399 -0
- package/src/spells/ultra/vfx/Particles.ts +1475 -0
- package/src/spells/ultra/vfx/Ribbons.ts +645 -0
- package/src/spells/ultra/vfx/Shockwaves.ts +286 -0
- package/src/spells/ultra/vfx/Volumes.ts +489 -0
- package/src/spells/ultra/vfx/common.ts +1195 -0
- package/src/spells/ultra/vfx/noise.ts +441 -0
- package/src/startup-readiness.ts +128 -34
- package/src/version.ts +1 -1
- package/src/warmup.ts +56 -8
- package/src/water-surface.ts +9 -3
- package/src/world-bundle-safety.ts +401 -0
- package/src/world-cell-batches.ts +1216 -0
- package/src/world-cell-chunks.ts +1132 -0
- package/src/world-cell-data.ts +995 -0
- package/src/world-cell-impostors.ts +1449 -0
- package/src/world-cell-lod-bias.ts +151 -0
- package/src/world-cell-models.ts +1074 -0
- package/src/world-cell-options.ts +189 -0
- package/src/world-cell-placements.ts +694 -0
- package/src/world-cell-prewarm.ts +557 -0
- package/src/world-cell-readiness.ts +357 -0
- package/src/world-cell-render-bundles.ts +459 -0
- package/src/world-cell-render-gpu-dress.ts +714 -0
- package/src/world-cell-render-main-cull.ts +484 -0
- package/src/world-cell-render-shadow-claims.ts +198 -0
- package/src/world-cell-render-util.ts +246 -0
- package/src/world-cell-render.ts +1493 -0
- package/src/world-cell-residency.ts +745 -0
- package/src/world-cells.ts +1318 -10418
- package/src/world-chunk-shadow.ts +308 -0
- package/src/world-collar.ts +315 -0
- package/src/world-gpu-flags.ts +163 -0
- package/src/world-gpu-readback.ts +881 -0
- package/src/world-gpu-reference.ts +510 -0
- package/src/world-gpu-scene.ts +214 -2264
- package/src/world-gpu-shadow.ts +190 -0
- package/src/world-gpu-types.ts +381 -0
- package/src/world-gpu-validation.ts +518 -0
- package/src/world-heightfield.ts +802 -0
- package/src/world-load-limiter.ts +106 -0
- package/src/world-noise.ts +241 -0
- package/src/world-package.ts +42 -0
- package/src/world-region.ts +1 -1
- package/src/world-terrain-splat.ts +365 -149
- package/src/world-tile-budget.ts +256 -0
- package/src/world-tile-geometry.ts +469 -0
- package/src/world-tile-lod.ts +408 -0
- package/src/world-tile-observation.ts +566 -0
- package/src/world-tile-stitch.ts +166 -0
- package/src/world-tiles.ts +170 -1745
- package/src/world-water-bodies.ts +359 -0
- package/src/world.ts +35 -741
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
// Ported from Ultra Elements src/spells/cast.js @698b720 (MIT, Copyright (c) 2026 Humpalumps). JavaScript copied verbatim; GLSL transliterated to TSL.
|
|
2
|
+
import { Vector3 } from "three";
|
|
3
|
+
import { ARENA, arenaSDFJS as arenaSDF } from "../vfx/common.js";
|
|
4
|
+
|
|
5
|
+
// Cast pool + phase clock (PLAN 2.4). One record per live cast; spells keep per-cast state in
|
|
6
|
+
// c.data (reused, so they reset it in phase 'charge'). Phases:
|
|
7
|
+
// charge -> release (instant) -> travel (projectile flight / beam sustain) -> impact -> linger -> done
|
|
8
|
+
// shape decides travel: projectile integrates until it hits the arena or reaches the target,
|
|
9
|
+
// beam sustains while held (or timing.sustain), strike/area/self skip it. A spell may override
|
|
10
|
+
// shape per form with formShapes: { 'Form name': 'strike' }.
|
|
11
|
+
const MAX_CASTS = 16;
|
|
12
|
+
const _d = new Vector3();
|
|
13
|
+
|
|
14
|
+
export type Phase = "charge" | "release" | "travel" | "impact" | "linger" | "done";
|
|
15
|
+
|
|
16
|
+
// what a spell's create(fx) returns (upstream: `s.inst`)
|
|
17
|
+
export interface ISpellInstance {
|
|
18
|
+
phase?(c: ICast, name: Phase): void;
|
|
19
|
+
update?(c: ICast, dt: number): void;
|
|
20
|
+
travel?(c: ICast, dt: number): boolean;
|
|
21
|
+
onParam?(k: string): void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// a spell module (upstream: one default export per src/spells/<element>.js)
|
|
25
|
+
export interface ISpell {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
shape?: string;
|
|
29
|
+
forms?: string[];
|
|
30
|
+
formShapes?: Record<string, string>;
|
|
31
|
+
radius?: number;
|
|
32
|
+
speed?: number;
|
|
33
|
+
lob?: number;
|
|
34
|
+
params?: Record<string, number | string>;
|
|
35
|
+
timing?: { charge?: number; impact?: number; linger?: number; sustain?: number };
|
|
36
|
+
inst?: ISpellInstance;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ICast {
|
|
40
|
+
index: number;
|
|
41
|
+
alive: boolean;
|
|
42
|
+
spell: ISpell | null;
|
|
43
|
+
inst: ISpellInstance | null;
|
|
44
|
+
form: string;
|
|
45
|
+
shape: string;
|
|
46
|
+
phase: Phase;
|
|
47
|
+
t: number;
|
|
48
|
+
age: number;
|
|
49
|
+
seed: number;
|
|
50
|
+
from: Vector3;
|
|
51
|
+
to: Vector3;
|
|
52
|
+
pos: Vector3;
|
|
53
|
+
vel: Vector3;
|
|
54
|
+
dir: Vector3;
|
|
55
|
+
held: boolean;
|
|
56
|
+
travelled: number;
|
|
57
|
+
target: number;
|
|
58
|
+
data: Record<string, unknown>;
|
|
59
|
+
durations: { charge: number; travel: number; impact: number; linger: number };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function record(i: number): ICast {
|
|
63
|
+
return {
|
|
64
|
+
index: i,
|
|
65
|
+
alive: false,
|
|
66
|
+
spell: null,
|
|
67
|
+
inst: null,
|
|
68
|
+
form: "",
|
|
69
|
+
shape: "projectile",
|
|
70
|
+
phase: "done",
|
|
71
|
+
t: 0,
|
|
72
|
+
age: 0,
|
|
73
|
+
seed: 0,
|
|
74
|
+
from: new Vector3(),
|
|
75
|
+
to: new Vector3(),
|
|
76
|
+
pos: new Vector3(),
|
|
77
|
+
vel: new Vector3(),
|
|
78
|
+
dir: new Vector3(),
|
|
79
|
+
held: false,
|
|
80
|
+
travelled: 0,
|
|
81
|
+
target: -1,
|
|
82
|
+
data: {},
|
|
83
|
+
durations: { charge: 0, travel: 0, impact: 0, linger: 0 },
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export class Casts {
|
|
88
|
+
fx: { rand(): number };
|
|
89
|
+
list: ICast[];
|
|
90
|
+
last: ICast | null;
|
|
91
|
+
|
|
92
|
+
constructor(fx: { rand(): number }) {
|
|
93
|
+
this.fx = fx;
|
|
94
|
+
this.list = Array.from({ length: MAX_CASTS }, (_, i) => record(i));
|
|
95
|
+
this.last = null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// spell: module from SPELLS (with .inst set at load). to: world point. target: dummy index or -1.
|
|
99
|
+
cast(
|
|
100
|
+
spell: ISpell,
|
|
101
|
+
to: Vector3,
|
|
102
|
+
{
|
|
103
|
+
form = spell.forms?.[0] ?? "",
|
|
104
|
+
from = ARENA.focus,
|
|
105
|
+
target = -1,
|
|
106
|
+
held = false,
|
|
107
|
+
seed,
|
|
108
|
+
}: { form?: string; from?: Vector3; target?: number; held?: boolean; seed?: number } = {},
|
|
109
|
+
): ICast {
|
|
110
|
+
let c = this.list.find((x) => !x.alive);
|
|
111
|
+
if (!c) {
|
|
112
|
+
// pool full: recycle the oldest
|
|
113
|
+
c = this.list.reduce((a, b) => (b.age > a.age ? b : a));
|
|
114
|
+
this.enter(c, "done");
|
|
115
|
+
}
|
|
116
|
+
Object.assign(c, {
|
|
117
|
+
alive: true,
|
|
118
|
+
spell,
|
|
119
|
+
inst: spell.inst,
|
|
120
|
+
form,
|
|
121
|
+
shape: spell.formShapes?.[form] ?? spell.shape ?? "projectile",
|
|
122
|
+
t: 0,
|
|
123
|
+
age: 0,
|
|
124
|
+
held,
|
|
125
|
+
travelled: 0,
|
|
126
|
+
target,
|
|
127
|
+
});
|
|
128
|
+
c.seed = seed ?? Math.floor(this.fx.rand() * 1e6);
|
|
129
|
+
c.from.copy(from);
|
|
130
|
+
c.to.copy(to);
|
|
131
|
+
c.pos.copy(from);
|
|
132
|
+
c.dir.subVectors(to, from).normalize();
|
|
133
|
+
c.vel.set(0, 0, 0);
|
|
134
|
+
const T = spell.timing ?? {};
|
|
135
|
+
c.durations.charge = T.charge ?? 0.5;
|
|
136
|
+
c.durations.travel = T.sustain ?? 4;
|
|
137
|
+
c.durations.impact = T.impact ?? 0.2;
|
|
138
|
+
c.durations.linger = T.linger ?? 2;
|
|
139
|
+
this.enter(c, "charge");
|
|
140
|
+
this.last = c;
|
|
141
|
+
return c;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
enter(c: ICast, phase: Phase): void {
|
|
145
|
+
c.phase = phase;
|
|
146
|
+
c.t = 0;
|
|
147
|
+
c.inst?.phase?.(c, phase);
|
|
148
|
+
if (phase === "done") c.alive = false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
releaseHeld(): void {
|
|
152
|
+
for (const c of this.list) c.held = false;
|
|
153
|
+
}
|
|
154
|
+
clear(): void {
|
|
155
|
+
for (const c of this.list) if (c.alive) this.enter(c, "done");
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: upstream Ultra Elements code, copied verbatim
|
|
159
|
+
update(dt: number): void {
|
|
160
|
+
for (const c of this.list) {
|
|
161
|
+
if (!c.alive) continue;
|
|
162
|
+
c.t += dt;
|
|
163
|
+
c.age += dt;
|
|
164
|
+
const s = c.spell as ISpell;
|
|
165
|
+
const d = c.durations;
|
|
166
|
+
const inst = c.inst as ISpellInstance;
|
|
167
|
+
if (c.phase === "charge") {
|
|
168
|
+
c.pos.copy(c.from);
|
|
169
|
+
if (c.t >= d.charge) {
|
|
170
|
+
this.enter(c, "release");
|
|
171
|
+
const shape = c.shape;
|
|
172
|
+
if (shape === "projectile") {
|
|
173
|
+
c.vel
|
|
174
|
+
.copy(c.dir)
|
|
175
|
+
.multiplyScalar((s.params?.speed as number | undefined) ?? s.speed ?? 15);
|
|
176
|
+
if (s.lob) c.vel.y += s.lob; // lobbed: initial upward speed, gravity below
|
|
177
|
+
this.enter(c, "travel");
|
|
178
|
+
} else if (shape === "beam") this.enter(c, "travel");
|
|
179
|
+
else {
|
|
180
|
+
if (shape !== "self") c.pos.copy(c.to);
|
|
181
|
+
this.enter(c, "impact");
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
} else if (c.phase === "travel") {
|
|
185
|
+
if (c.shape === "projectile") {
|
|
186
|
+
// the spell may steer (homing) by editing c.vel in its update; integrate here
|
|
187
|
+
if (inst.travel) {
|
|
188
|
+
if (inst.travel(c, dt)) {
|
|
189
|
+
this.enter(c, "impact");
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
if (s.lob) c.vel.y -= 9.81 * dt;
|
|
194
|
+
c.pos.addScaledVector(c.vel, dt);
|
|
195
|
+
c.travelled += c.vel.length() * dt;
|
|
196
|
+
const r = s.radius ?? 0.3;
|
|
197
|
+
const hit =
|
|
198
|
+
(c.travelled > 1 && arenaSDF(c.pos) < r) ||
|
|
199
|
+
(!s.lob && _d.subVectors(c.to, c.pos).dot(c.dir) <= 0) ||
|
|
200
|
+
c.t > d.travel;
|
|
201
|
+
if (hit) {
|
|
202
|
+
if (!s.lob && c.t <= d.travel && _d.subVectors(c.to, c.pos).dot(c.dir) <= 0)
|
|
203
|
+
c.pos.copy(c.to);
|
|
204
|
+
this.enter(c, "impact");
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
} else if (!c.held && c.t >= (s.timing?.sustain ?? 0)) {
|
|
209
|
+
this.enter(c, "impact");
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
} else if (c.phase === "impact") {
|
|
213
|
+
if (c.t >= d.impact) this.enter(c, "linger");
|
|
214
|
+
} else if (c.phase === "linger") {
|
|
215
|
+
if (c.t >= d.linger) {
|
|
216
|
+
this.enter(c, "done");
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (c.alive) inst.update?.(c, dt);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// for the HUD phase strip: the newest live cast
|
|
225
|
+
active(): ICast | null {
|
|
226
|
+
return this.last?.alive ? this.last : null;
|
|
227
|
+
}
|
|
228
|
+
count(): number {
|
|
229
|
+
let n = 0;
|
|
230
|
+
for (const c of this.list) n += c.alive ? 1 : 0;
|
|
231
|
+
return n;
|
|
232
|
+
}
|
|
233
|
+
}
|