@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.
Files changed (157) hide show
  1. package/capabilities.json +1096 -26
  2. package/dist/camera-shake-CZKOfGn4.d.ts +46 -0
  3. package/dist/{canvas-layer-vCtanIeB.d.ts → canvas-layer-CWuFRT7G.d.ts} +1 -1
  4. package/dist/chunk-2Z44XSI2.js +35 -0
  5. package/dist/chunk-5O73CDMR.js +1849 -0
  6. package/dist/chunk-6KLNISRJ.js +153 -0
  7. package/dist/chunk-7UUT3TY5.js +133 -0
  8. package/dist/chunk-CFGTPFUH.js +231 -0
  9. package/dist/chunk-DBELTTTM.js +615 -0
  10. package/dist/chunk-GMHATRPW.js +7701 -0
  11. package/dist/chunk-GXY7B3JG.js +46 -0
  12. package/dist/chunk-KIRUKTBQ.js +187 -0
  13. package/dist/chunk-N5LRP4BR.js +220 -0
  14. package/dist/chunk-OKXUCASC.js +2238 -0
  15. package/dist/chunk-QWJEMUUT.js +94 -0
  16. package/dist/chunk-VAZM36TV.js +497 -0
  17. package/dist/{game-DzMcitDO.d.ts → game-D7pAzZUY.d.ts} +15 -3
  18. package/dist/hot.d.ts +3 -3
  19. package/dist/hot.js +2 -46
  20. package/dist/index.d.ts +329 -302
  21. package/dist/index.js +10566 -22552
  22. package/dist/{model-lod-CTpZ6imz.d.ts → model-lod-B6BMqS1r.d.ts} +33 -3
  23. package/dist/playtest.d.ts +3 -3
  24. package/dist/playtest.js +24 -75
  25. package/dist/react-css.js +1 -215
  26. package/dist/react.d.ts +2 -2
  27. package/dist/{renderer-rZm0hVqq.d.ts → renderer-DvFVoAgj.d.ts} +13 -4
  28. package/dist/spells/index.d.ts +643 -0
  29. package/dist/spells/index.js +1558 -0
  30. package/dist/spells/ultra/index.d.ts +1600 -0
  31. package/dist/spells/ultra/index.js +6804 -0
  32. package/dist/terrain-jobs-worker.js +1 -123
  33. package/dist/two-sided-foliage-W523J3UM.js +1 -0
  34. package/dist/ui-layer.js +5 -384
  35. package/dist/worker.js +4 -41
  36. package/dist/world.d.ts +725 -259
  37. package/dist/world.js +16714 -18284
  38. package/mcp/animation-server.mjs +1 -1
  39. package/mcp/animation.mjs +2 -3
  40. package/mcp/engine-server.mjs +142 -47
  41. package/mcp/servers.mjs +9 -2
  42. package/mcp/terrain.mjs +8 -0
  43. package/package.json +14 -6
  44. package/patches/three@0.187.0-prd269-upgrade.patch +2102 -0
  45. package/patches/three@0.187.0.patch +2004 -407
  46. package/src/assets.ts +9 -2
  47. package/src/card-lod.ts +152 -0
  48. package/src/compressed-texture-preparation.ts +1008 -0
  49. package/src/frame-budget.ts +31 -20
  50. package/src/game-dev-tools.ts +93 -0
  51. package/src/game-frame-loop.ts +995 -0
  52. package/src/game-renderer-metrics.ts +77 -0
  53. package/src/game-startup.ts +1001 -0
  54. package/src/game-validate.ts +70 -0
  55. package/src/game.ts +253 -1935
  56. package/src/index.ts +27 -2
  57. package/src/launch-diagnostics.ts +22 -12
  58. package/src/look/ao-admission.ts +24 -0
  59. package/src/look/filmic-tone-mapping.ts +15 -13
  60. package/src/look/look-diagnostics.ts +3 -3
  61. package/src/look/quality.ts +10 -5
  62. package/src/look/world-environment.ts +76 -9
  63. package/src/loop.ts +29 -0
  64. package/src/model-lod.ts +42 -3
  65. package/src/particle-kinds.ts +515 -0
  66. package/src/picking.ts +17 -3
  67. package/src/playtest.ts +27 -1
  68. package/src/projection-apply.ts +4 -1
  69. package/src/projection-plan.ts +9 -6
  70. package/src/render/mesh-pool.ts +1 -1
  71. package/src/render/resolution-subrect.ts +2 -0
  72. package/src/render/rough-diffuse.ts +46 -12
  73. package/src/render/soft-shadow.ts +27 -12
  74. package/src/render/virtual-shadow-adaptive.ts +55 -0
  75. package/src/render/virtual-shadow-casters.ts +175 -0
  76. package/src/render/virtual-shadow-layers.ts +76 -0
  77. package/src/render/virtual-shadow-level.ts +224 -0
  78. package/src/render/virtual-shadow-markers.ts +193 -0
  79. package/src/render/virtual-shadow-options.ts +370 -0
  80. package/src/render/virtual-shadow-pages.ts +5 -0
  81. package/src/render/virtual-shadow.ts +213 -992
  82. package/src/render/world-impostor-surface.ts +293 -34
  83. package/src/render-pass-budget.ts +34 -7
  84. package/src/renderProjection.ts +22 -0
  85. package/src/renderer.ts +92 -37
  86. package/src/snow-field.ts +1 -1
  87. package/src/spells/cast-pool.ts +361 -0
  88. package/src/spells/index.ts +177 -0
  89. package/src/spells/mechanisms.ts +295 -0
  90. package/src/spells/reaction-field.ts +415 -0
  91. package/src/spells/spell-lights.ts +139 -0
  92. package/src/spells/spell-world.ts +187 -0
  93. package/src/spells/spell.ts +397 -0
  94. package/src/spells/spells.ts +283 -0
  95. package/src/spells/ultra/engine/camera.ts +184 -0
  96. package/src/spells/ultra/engine/quality.ts +96 -0
  97. package/src/spells/ultra/index.ts +52 -0
  98. package/src/spells/ultra/main.ts +305 -0
  99. package/src/spells/ultra/scene/arenaMaterial.ts +325 -0
  100. package/src/spells/ultra/spells/cast.ts +233 -0
  101. package/src/spells/ultra/spells/fire.ts +1267 -0
  102. package/src/spells/ultra/vfx/FluidVolume.ts +816 -0
  103. package/src/spells/ultra/vfx/FluidVolume.tsl.ts +855 -0
  104. package/src/spells/ultra/vfx/FxTarget.ts +61 -0
  105. package/src/spells/ultra/vfx/GroundField.ts +1399 -0
  106. package/src/spells/ultra/vfx/Particles.ts +1475 -0
  107. package/src/spells/ultra/vfx/Ribbons.ts +645 -0
  108. package/src/spells/ultra/vfx/Shockwaves.ts +286 -0
  109. package/src/spells/ultra/vfx/Volumes.ts +489 -0
  110. package/src/spells/ultra/vfx/common.ts +1195 -0
  111. package/src/spells/ultra/vfx/noise.ts +441 -0
  112. package/src/startup-readiness.ts +128 -34
  113. package/src/version.ts +1 -1
  114. package/src/warmup.ts +56 -8
  115. package/src/water-surface.ts +9 -3
  116. package/src/world-bundle-safety.ts +401 -0
  117. package/src/world-cell-batches.ts +1216 -0
  118. package/src/world-cell-chunks.ts +1132 -0
  119. package/src/world-cell-data.ts +995 -0
  120. package/src/world-cell-impostors.ts +1449 -0
  121. package/src/world-cell-lod-bias.ts +151 -0
  122. package/src/world-cell-models.ts +1074 -0
  123. package/src/world-cell-options.ts +189 -0
  124. package/src/world-cell-placements.ts +694 -0
  125. package/src/world-cell-prewarm.ts +557 -0
  126. package/src/world-cell-readiness.ts +357 -0
  127. package/src/world-cell-render-bundles.ts +459 -0
  128. package/src/world-cell-render-gpu-dress.ts +714 -0
  129. package/src/world-cell-render-main-cull.ts +484 -0
  130. package/src/world-cell-render-shadow-claims.ts +198 -0
  131. package/src/world-cell-render-util.ts +246 -0
  132. package/src/world-cell-render.ts +1493 -0
  133. package/src/world-cell-residency.ts +745 -0
  134. package/src/world-cells.ts +1318 -10418
  135. package/src/world-chunk-shadow.ts +308 -0
  136. package/src/world-collar.ts +315 -0
  137. package/src/world-gpu-flags.ts +163 -0
  138. package/src/world-gpu-readback.ts +881 -0
  139. package/src/world-gpu-reference.ts +510 -0
  140. package/src/world-gpu-scene.ts +214 -2264
  141. package/src/world-gpu-shadow.ts +190 -0
  142. package/src/world-gpu-types.ts +381 -0
  143. package/src/world-gpu-validation.ts +518 -0
  144. package/src/world-heightfield.ts +802 -0
  145. package/src/world-load-limiter.ts +106 -0
  146. package/src/world-noise.ts +241 -0
  147. package/src/world-package.ts +42 -0
  148. package/src/world-region.ts +1 -1
  149. package/src/world-terrain-splat.ts +365 -149
  150. package/src/world-tile-budget.ts +256 -0
  151. package/src/world-tile-geometry.ts +469 -0
  152. package/src/world-tile-lod.ts +408 -0
  153. package/src/world-tile-observation.ts +566 -0
  154. package/src/world-tile-stitch.ts +166 -0
  155. package/src/world-tiles.ts +170 -1745
  156. package/src/world-water-bodies.ts +359 -0
  157. package/src/world.ts +35 -741
@@ -0,0 +1,286 @@
1
+ // Ported from Ultra Elements src/vfx/Shockwaves.js @698b720 (MIT, Copyright (c) 2026 Humpalumps). JavaScript copied verbatim; GLSL transliterated to TSL.
2
+ import {
3
+ Color,
4
+ DoubleSide,
5
+ Float32BufferAttribute,
6
+ type InstancedBufferAttribute,
7
+ InstancedBufferGeometry,
8
+ Mesh,
9
+ Vector3,
10
+ } from "three";
11
+ import {
12
+ Discard,
13
+ Fn,
14
+ abs,
15
+ attribute,
16
+ cameraPosition,
17
+ cameraProjectionMatrix,
18
+ cameraViewMatrix,
19
+ cross,
20
+ dot,
21
+ exp,
22
+ float,
23
+ length,
24
+ max,
25
+ normalize,
26
+ positionGeometry,
27
+ screenUV,
28
+ select,
29
+ sqrt,
30
+ varying,
31
+ vec2,
32
+ vec3,
33
+ vec4,
34
+ } from "three/tsl";
35
+ import { MeshBasicNodeMaterial, type Node } from "three/webgpu";
36
+ import { instanced } from "./Ribbons.js";
37
+ import { FX_DISTORT_BLENDING, U, fxOutDistort, softFade } from "./common.js";
38
+
39
+ type F = Node<"float">;
40
+ type V2 = Node<"vec2">;
41
+ type V3 = Node<"vec3">;
42
+ type V4 = Node<"vec4">;
43
+
44
+ // Expanding shock shells and ground rings in the fx pass: a radial screen-space distortion
45
+ // proportional to how much shell the view ray crosses (so the rim reads as a lens), plus optional
46
+ // emission. Fire and forget: spawn() and the pool (16, one instanced draw) ages them out.
47
+ // sphere: camera-facing quad perpendicular to the view axis, sized to the shell's silhouette cone;
48
+ // the profile is the exact chord through the shell, normalised to 1 at its peak (rho = inner radius)
49
+ // ground: a flat quad hugging pos.y; ring profile with a sharp leading edge and a soft wake
50
+ // Radius follows a blast-wave curve r0 + (r1 - r0) x^0.4 (Sedov-Taylor r ~ t^0.4); emission decays
51
+ // as (1 - x)^3 (a flash), distortion as (1 - x)^1.5 after a 5% attack. distortion is metres of
52
+ // apparent displacement at the shell's depth.
53
+ // Engine: the distortion and the emission composite through fxOutDistort (common.ts), FX_DISTORT_BLENDING.
54
+
55
+ // projectionMatrix[1][1]
56
+ const proj11 = (): F =>
57
+ (cameraProjectionMatrix as unknown as { element(i: number): V4 }).element(1).y;
58
+
59
+ function shockNodes() {
60
+ const aS0 = attribute("aS0", "vec4") as unknown as V4; // centre, ground
61
+ const aS1 = attribute("aS1", "vec4") as unknown as V4; // radius, thickness, progress (< 0: dead), -
62
+ const aS2 = attribute("aS2", "vec4") as unknown as V4; // emission rgb, distortion (m), envelopes applied
63
+ const position = positionGeometry as unknown as V3;
64
+
65
+ // VERT
66
+ const c = aS0.xyz;
67
+ const R = aS1.x.add(aS1.y.mul(0.75));
68
+ const toC = c.sub(cameraPosition);
69
+ const D = length(toC);
70
+ // ponytail: a camera inside a sphere shell just loses it (ground rings still draw)
71
+ const dead = aS1.z.lessThan(0.0).or(aS0.w.lessThan(0.5).and(D.lessThan(R.mul(1.05))));
72
+ const f = toC.div(D);
73
+ const r = normalize(
74
+ cross(f, select(abs(f.y).lessThan(0.99), vec3(0.0, 1.0, 0.0), vec3(1.0, 0.0, 0.0))),
75
+ );
76
+ const u = cross(r, f);
77
+ const pSphere = c.add(
78
+ r
79
+ .mul(position.x)
80
+ .add(u.mul(position.y))
81
+ .mul(R.div(sqrt(float(1.0).sub(R.div(D).mul(R.div(D)))))),
82
+ );
83
+ const pGround = c.add(vec3(position.x.mul(R), 0.03, position.y.mul(R)));
84
+ const p = select(aS0.w.greaterThan(0.5), pGround, pSphere);
85
+ const cc = cameraProjectionMatrix.mul(cameraViewMatrix).mul(vec4(c, 1.0)) as unknown as V4;
86
+ const view = cameraViewMatrix.mul(vec4(p, 1.0)) as unknown as V4;
87
+ const vertexNode = select(
88
+ dead,
89
+ vec4(2.0, 2.0, 2.0, 1.0),
90
+ cameraProjectionMatrix.mul(view) as unknown as V4,
91
+ );
92
+ const vWorld = varying(p) as unknown as V3;
93
+ const vViewZ = varying(view.z.negate()) as unknown as F;
94
+ const vS0 = varying(aS0) as unknown as V4;
95
+ const vS1 = varying(aS1) as unknown as V4;
96
+ const vS2 = varying(aS2) as unknown as V4;
97
+ const vCentre = varying(cc.xy.div(cc.w).mul(0.5).add(0.5).mul(U.uFxResolution)) as unknown as V2; // projected centre, fx pixels
98
+
99
+ // FRAG
100
+ const fragmentNode = Fn(() => {
101
+ const cF = vS0.xyz;
102
+ const rF = vS1.x;
103
+ const th = vS1.y;
104
+ // sharp leading edge, soft wake behind it
105
+ const x = length(vWorld.xz.sub(cF.xz)).sub(rF).div(th.mul(0.5));
106
+ const profGround = exp(
107
+ x
108
+ .mul(x)
109
+ .negate()
110
+ .mul(select(x.greaterThan(0.0), float(6.0), float(0.8))),
111
+ );
112
+ const rd = normalize(vWorld.sub(cameraPosition));
113
+ const oc = cF.sub(cameraPosition);
114
+ const tc = dot(oc, rd);
115
+ const rho2 = max(dot(oc, oc).sub(tc.mul(tc)), 0.0);
116
+ const ro = rF.add(th.mul(0.5));
117
+ const ri = max(rF.sub(th.mul(0.5)), 0.0);
118
+ const chord = sqrt(max(ro.mul(ro).sub(rho2), 0.0)).sub(sqrt(max(ri.mul(ri).sub(rho2), 0.0)));
119
+ const profSphere = chord.div(sqrt(max(ro.mul(ro).sub(ri.mul(ri)), 1e-6)));
120
+ const prof = select(vS0.w.greaterThan(0.5), profGround, profSphere).toVar();
121
+ Discard(prof.lessThan(1e-3));
122
+ // gl_FragCoord in fx pixels, GL orientation (y up)
123
+ const frag = vec2(screenUV.x, screenUV.y.oneMinus()).mul(U.uFxResolution);
124
+ const dir0 = frag.sub(vCentre);
125
+ const dir = select(dot(dir0, dir0).greaterThan(1e-6), normalize(dir0), vec2(0.0));
126
+ const h = proj11().mul(0.5).div(max(vViewZ, 1e-3));
127
+ const s = softFade(vViewZ, 0.3).mul(prof);
128
+ // sample nearer the centre: the background bulges outward under the rim
129
+ const dist = dir
130
+ .negate()
131
+ .mul(vec2(h.mul(U.uFxResolution.y).div(U.uFxResolution.x), h))
132
+ .mul(vS2.w)
133
+ .mul(s);
134
+ // emission hugs the rim (seen through, the shell's two walls would otherwise glow as a dome)
135
+ const p2 = prof.mul(prof);
136
+ return fxOutDistort(
137
+ vS2.rgb.mul(p2).mul(p2).mul(softFade(vViewZ, 0.3)),
138
+ dist,
139
+ vec3(0.0),
140
+ float(0.0),
141
+ );
142
+ })();
143
+ return { vertexNode, fragmentNode };
144
+ }
145
+
146
+ export interface IShock {
147
+ index: number;
148
+ active: boolean;
149
+ age: number;
150
+ pos: Vector3;
151
+ radius0: number;
152
+ radius1: number;
153
+ duration: number;
154
+ thickness: number;
155
+ distortion: number;
156
+ color: Color;
157
+ intensity: number;
158
+ ground: boolean;
159
+ }
160
+
161
+ export class Shockwaves {
162
+ readonly attrs: InstancedBufferAttribute[];
163
+ readonly geometry: InstancedBufferGeometry;
164
+ readonly uniforms = { ...U };
165
+ readonly mesh: Mesh;
166
+ readonly slots: IShock[];
167
+
168
+ constructor({ max = 16 } = {}) {
169
+ const geo = new InstancedBufferGeometry();
170
+ geo.setAttribute(
171
+ "position",
172
+ new Float32BufferAttribute([-1, -1, 0, 1, -1, 0, 1, 1, 0, -1, 1, 0], 3),
173
+ );
174
+ geo.setIndex([0, 1, 2, 0, 2, 3]);
175
+ this.attrs = ["aS0", "aS1", "aS2"].map((n) => instanced(geo, n, max));
176
+ geo.instanceCount = 0;
177
+ this.geometry = geo;
178
+ const material = new MeshBasicNodeMaterial({ ...FX_DISTORT_BLENDING, side: DoubleSide });
179
+ material.fog = false;
180
+ const nodes = shockNodes();
181
+ material.vertexNode = nodes.vertexNode;
182
+ material.fragmentNode = nodes.fragmentNode;
183
+ this.mesh = new Mesh(geo, material);
184
+ this.mesh.frustumCulled = false;
185
+ this.mesh.visible = false;
186
+ this.mesh.renderOrder = 10;
187
+ this.slots = Array.from({ length: max }, (_, index) => ({
188
+ index,
189
+ active: false,
190
+ age: 0,
191
+ pos: new Vector3(),
192
+ radius0: 0.2,
193
+ radius1: 6,
194
+ duration: 0.6,
195
+ thickness: 0.6,
196
+ distortion: 0.12,
197
+ color: new Color(1, 1, 1),
198
+ intensity: 0,
199
+ ground: false,
200
+ }));
201
+ }
202
+
203
+ // pos: Vector3, color: THREE.Color (both copied). Full pool: the most advanced wave is replaced.
204
+ spawn({
205
+ pos,
206
+ radius0 = 0.2,
207
+ radius1 = 6,
208
+ duration = 0.6,
209
+ thickness = 0.6,
210
+ distortion = 0.12,
211
+ color,
212
+ intensity = 0,
213
+ ground = false,
214
+ }: {
215
+ pos: Vector3;
216
+ radius0?: number;
217
+ radius1?: number;
218
+ duration?: number;
219
+ thickness?: number;
220
+ distortion?: number;
221
+ color?: Color;
222
+ intensity?: number;
223
+ ground?: boolean;
224
+ }): IShock {
225
+ let s = this.slots[0] as IShock;
226
+ for (const x of this.slots) {
227
+ if (!x.active) {
228
+ s = x;
229
+ break;
230
+ }
231
+ if (x.age / x.duration > s.age / s.duration) s = x;
232
+ }
233
+ s.pos.copy(pos);
234
+ Object.assign(s, {
235
+ active: true,
236
+ age: 0,
237
+ radius0,
238
+ radius1,
239
+ duration,
240
+ thickness,
241
+ distortion,
242
+ intensity,
243
+ ground,
244
+ });
245
+ if (color) s.color.copy(color);
246
+ else s.color.setRGB(1, 1, 1);
247
+ return s;
248
+ }
249
+
250
+ update(dt: number): void {
251
+ const a0 = this.attrs[0]?.array as Float32Array;
252
+ const a1 = this.attrs[1]?.array as Float32Array;
253
+ const a2 = this.attrs[2]?.array as Float32Array;
254
+ let top = 0;
255
+ for (const s of this.slots) {
256
+ const o = s.index * 4;
257
+ if (s.active) {
258
+ s.age += dt;
259
+ if (s.age >= s.duration) s.active = false;
260
+ }
261
+ if (!s.active) {
262
+ a1[o + 2] = -1;
263
+ continue;
264
+ }
265
+ top = s.index + 1;
266
+ const x = s.age / s.duration;
267
+ const k = 1 - x;
268
+ const e = s.intensity * k * k * k;
269
+ const d = s.distortion * k ** 1.5 * Math.min(1, x / 0.05);
270
+ a0[o] = s.pos.x;
271
+ a0[o + 1] = s.pos.y;
272
+ a0[o + 2] = s.pos.z;
273
+ a0[o + 3] = s.ground ? 1 : 0;
274
+ a1[o] = s.radius0 + (s.radius1 - s.radius0) * x ** 0.4;
275
+ a1[o + 1] = s.thickness * (0.5 + 0.5 * x);
276
+ a1[o + 2] = x;
277
+ a2[o] = s.color.r * e;
278
+ a2[o + 1] = s.color.g * e;
279
+ a2[o + 2] = s.color.b * e;
280
+ a2[o + 3] = d;
281
+ }
282
+ for (const a of this.attrs) a.needsUpdate = true;
283
+ this.geometry.instanceCount = top;
284
+ this.mesh.visible = top > 0;
285
+ }
286
+ }