reze-engine 0.43.0 → 0.50.1
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 +53 -429
- package/dist/animation.d.ts +26 -0
- package/dist/animation.d.ts.map +1 -1
- package/dist/animation.js +42 -0
- package/dist/camera.d.ts +3 -0
- package/dist/camera.d.ts.map +1 -1
- package/dist/camera.js +33 -8
- package/dist/engine.d.ts +841 -53
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +3498 -451
- package/dist/graph/registry.d.ts +2 -2
- package/dist/graph/registry.d.ts.map +1 -1
- package/dist/graph/registry.js +1 -1
- package/dist/graph/slots.d.ts +0 -1
- package/dist/graph/slots.d.ts.map +1 -1
- package/dist/graph/slots.js +37 -9
- package/dist/hdr.d.ts +18 -0
- package/dist/hdr.d.ts.map +1 -0
- package/dist/hdr.js +162 -0
- package/dist/ibl.d.ts +19 -0
- package/dist/ibl.d.ts.map +1 -0
- package/dist/ibl.js +113 -0
- package/dist/ik-solver.d.ts +2 -1
- package/dist/ik-solver.d.ts.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/math.d.ts +20 -1
- package/dist/math.d.ts.map +1 -1
- package/dist/math.js +23 -16
- package/dist/midi-loader.d.ts +10 -0
- package/dist/midi-loader.d.ts.map +1 -0
- package/dist/midi-loader.js +247 -0
- package/dist/model.d.ts +19 -14
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +31 -2
- package/dist/param-track.d.ts +48 -0
- package/dist/param-track.d.ts.map +1 -0
- package/dist/param-track.js +80 -0
- package/dist/physics/types.d.ts.map +1 -1
- package/dist/physics/types.js +3 -0
- package/dist/reflection.d.ts +27 -0
- package/dist/reflection.d.ts.map +1 -0
- package/dist/reflection.js +93 -0
- package/dist/shaders/anchor-table.d.ts +56 -0
- package/dist/shaders/anchor-table.d.ts.map +1 -0
- package/dist/shaders/anchor-table.js +128 -0
- package/dist/shaders/cast-api.d.ts +2 -0
- package/dist/shaders/cast-api.d.ts.map +1 -0
- package/dist/shaders/cast-api.js +121 -0
- package/dist/shaders/cast-layout.d.ts +21 -0
- package/dist/shaders/cast-layout.d.ts.map +1 -0
- package/dist/shaders/cast-layout.js +20 -0
- package/dist/shaders/lights.d.ts +79 -0
- package/dist/shaders/lights.d.ts.map +1 -0
- package/dist/shaders/lights.js +269 -0
- package/dist/shaders/lyrics-api.d.ts +39 -0
- package/dist/shaders/lyrics-api.d.ts.map +1 -0
- package/dist/shaders/lyrics-api.js +187 -0
- package/dist/shaders/materials/common.d.ts +2 -4
- package/dist/shaders/materials/common.d.ts.map +1 -1
- package/dist/shaders/materials/common.js +87 -35
- package/dist/shaders/midi-api.d.ts +10 -0
- package/dist/shaders/midi-api.d.ts.map +1 -0
- package/dist/shaders/midi-api.js +114 -0
- package/dist/shaders/passes/composite.d.ts +28 -22
- package/dist/shaders/passes/composite.d.ts.map +1 -1
- package/dist/shaders/passes/composite.js +165 -138
- package/dist/shaders/passes/cull.d.ts +2 -0
- package/dist/shaders/passes/cull.d.ts.map +1 -0
- package/dist/shaders/passes/cull.js +138 -0
- package/dist/shaders/passes/field-blit.d.ts +26 -0
- package/dist/shaders/passes/field-blit.d.ts.map +1 -0
- package/dist/shaders/passes/field-blit.js +65 -0
- package/dist/shaders/passes/grid.d.ts +31 -0
- package/dist/shaders/passes/grid.d.ts.map +1 -0
- package/dist/shaders/passes/grid.js +169 -0
- package/dist/shaders/passes/ground.d.ts +13 -1
- package/dist/shaders/passes/ground.d.ts.map +1 -1
- package/dist/shaders/passes/ground.js +170 -25
- package/dist/shaders/passes/hosted-api.d.ts +57 -0
- package/dist/shaders/passes/hosted-api.d.ts.map +1 -0
- package/dist/shaders/passes/hosted-api.js +166 -0
- package/dist/shaders/passes/id-debug.d.ts +28 -0
- package/dist/shaders/passes/id-debug.d.ts.map +1 -0
- package/dist/shaders/passes/id-debug.js +74 -0
- package/dist/shaders/passes/particles.d.ts +10 -2
- package/dist/shaders/passes/particles.d.ts.map +1 -1
- package/dist/shaders/passes/particles.js +37 -109
- package/dist/shaders/passes/scene-contract.d.ts +128 -0
- package/dist/shaders/passes/scene-contract.d.ts.map +1 -0
- package/dist/shaders/passes/scene-contract.js +207 -0
- package/dist/shaders/passes/sim.d.ts +34 -0
- package/dist/shaders/passes/sim.d.ts.map +1 -0
- package/dist/shaders/passes/sim.js +169 -0
- package/dist/shaders/passes/trails.d.ts +14 -2
- package/dist/shaders/passes/trails.d.ts.map +1 -1
- package/dist/shaders/passes/trails.js +55 -90
- package/dist/shaders/score-api.d.ts +10 -0
- package/dist/shaders/score-api.d.ts.map +1 -0
- package/dist/shaders/score-api.js +114 -0
- package/dist/shadow-cascades.d.ts +45 -0
- package/dist/shadow-cascades.d.ts.map +1 -0
- package/dist/shadow-cascades.js +70 -0
- package/dist/vmd-loader.d.ts +3 -2
- package/dist/vmd-loader.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/animation.ts +41 -0
- package/src/camera.ts +31 -8
- package/src/engine.ts +4015 -556
- package/src/graph/registry.ts +2 -2
- package/src/graph/slots.ts +37 -9
- package/src/hdr.ts +156 -0
- package/src/ibl.ts +115 -0
- package/src/ik-solver.ts +1 -1
- package/src/index.ts +12 -0
- package/src/math.ts +23 -17
- package/src/midi-loader.ts +246 -0
- package/src/model.ts +34 -4
- package/src/param-track.ts +83 -0
- package/src/physics/types.ts +4 -1
- package/src/reflection.ts +94 -0
- package/src/shaders/anchor-table.ts +147 -0
- package/src/shaders/cast-api.ts +123 -0
- package/src/shaders/cast-layout.ts +20 -0
- package/src/shaders/lights.ts +280 -0
- package/src/shaders/lyrics-api.ts +202 -0
- package/src/shaders/materials/common.ts +89 -35
- package/src/shaders/midi-api.ts +116 -0
- package/src/shaders/passes/composite.ts +182 -139
- package/src/shaders/passes/cull.ts +139 -0
- package/src/shaders/passes/grid.ts +178 -0
- package/src/shaders/passes/ground.ts +172 -25
- package/src/shaders/passes/hosted-api.ts +171 -0
- package/src/shaders/passes/id-debug.ts +75 -0
- package/src/shaders/passes/particles.ts +54 -112
- package/src/shaders/passes/scene-contract.ts +266 -0
- package/src/shaders/passes/trails.ts +77 -93
- package/src/shadow-cascades.ts +97 -0
- package/src/vmd-loader.ts +2 -2
package/dist/animation.js
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
export const FPS = 30;
|
|
2
2
|
// Priority-aware playback: higher priority preempts, otherwise latest request is queued.
|
|
3
|
+
/**
|
|
4
|
+
* Morphs the OLD tracks drove that the new ones do not name.
|
|
5
|
+
*
|
|
6
|
+
* Nothing in the pose pass resets a morph weight — it writes only the morphs
|
|
7
|
+
* its clip names — so a morph left behind by a replaced track keeps its last
|
|
8
|
+
* value for the rest of the session. These are the ones a caller has to zero,
|
|
9
|
+
* or the old face stays frozen underneath the new one, which reads exactly
|
|
10
|
+
* like the new file having had no effect at all.
|
|
11
|
+
*/
|
|
12
|
+
export function retiredMorphs(prev, next) {
|
|
13
|
+
if (!prev)
|
|
14
|
+
return [];
|
|
15
|
+
const out = [];
|
|
16
|
+
for (const name of prev.morphTracks.keys())
|
|
17
|
+
if (!next.has(name))
|
|
18
|
+
out.push(name);
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
3
21
|
export class AnimationState {
|
|
4
22
|
constructor() {
|
|
5
23
|
this.animations = new Map();
|
|
@@ -23,6 +41,30 @@ export class AnimationState {
|
|
|
23
41
|
frameCount: clip.frameCount,
|
|
24
42
|
});
|
|
25
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Replace a clip's morph tracks wholesale, leaving its bones alone.
|
|
46
|
+
*
|
|
47
|
+
* MMD authors ship expressions as their own file (表情モーション) beside the
|
|
48
|
+
* body motion, and when they do it is AUTHORITATIVE: whatever morphs the body
|
|
49
|
+
* motion carried are the ones the morph pass was made to replace. So
|
|
50
|
+
* this overwrites rather than merges per-morph — a half-overridden face is
|
|
51
|
+
* nobody's intent. With no expression file loaded, the motion's own morphs
|
|
52
|
+
* play untouched, because nothing calls this.
|
|
53
|
+
*
|
|
54
|
+
* The clip is created if it does not exist yet, so the two files may arrive
|
|
55
|
+
* in either order, and frameCount grows to cover the longer of the two — an
|
|
56
|
+
* morph track running past the body motion is common and must not be
|
|
57
|
+
* truncated to it.
|
|
58
|
+
*/
|
|
59
|
+
setMorphTracks(name, morphTracks, frameCount) {
|
|
60
|
+
const clip = this.animations.get(name);
|
|
61
|
+
this.animations.set(name, {
|
|
62
|
+
boneTracks: clip?.boneTracks ?? new Map(),
|
|
63
|
+
morphTracks,
|
|
64
|
+
ikTracks: clip?.ikTracks,
|
|
65
|
+
frameCount: Math.max(clip?.frameCount ?? 0, frameCount),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
26
68
|
removeAnimation(name) {
|
|
27
69
|
this.animations.delete(name);
|
|
28
70
|
if (this.currentAnimationName === name) {
|
package/dist/camera.d.ts
CHANGED
|
@@ -13,6 +13,9 @@ export declare class Camera {
|
|
|
13
13
|
* closer than any real framing — and buys 10× precision at character range. */
|
|
14
14
|
near: number;
|
|
15
15
|
far: number;
|
|
16
|
+
/** Set once by the engine, from whether it got a float depth format. Decides
|
|
17
|
+
* both the near-plane floor and which way round the projection maps z. */
|
|
18
|
+
reversedZ: boolean;
|
|
16
19
|
private canvas;
|
|
17
20
|
private inputLocked;
|
|
18
21
|
private isDragging;
|
package/dist/camera.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../src/camera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAQ,IAAI,EAAE,MAAM,QAAQ,CAAA;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../src/camera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAQ,IAAI,EAAE,MAAM,QAAQ,CAAA;AACzC,OAAO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AK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAE,MAAoB;IAmBhG,WAAW,IAAI,IAAI;IAQnB;wFACoF;IACpF,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAOpC,0FAA0F;IAC1F,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAelC,OAAO,CAAC,MAAM;IAUd;;;;;;;;;;;OAWG;IACH,cAAc,IAAI,IAAI;IAItB,aAAa,IAAI,IAAI;IA2BrB,OAAO,CAAC,gBAAgB;IA0CxB,OAAO,CAAC,SAAS;IAiBjB,kFAAkF;IAClF,OAAO,CAAC,mBAAmB;IAK3B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,oBAAoB;IAM5B,mBAAmB,IAAI,IAAI;IAW3B,aAAa,CAAC,MAAM,EAAE,iBAAiB;IAiBvC,aAAa;IAkBb,cAAc,CAAC,MAAM,EAAE,OAAO;IAS9B,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,WAAW;IAsBnB,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,OAAO;IAYf,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;IA8BpB,OAAO,CAAC,WAAW;IAuFnB,OAAO,CAAC,UAAU;CA+BnB"}
|
package/dist/camera.js
CHANGED
|
@@ -2,11 +2,25 @@ import { Mat4, Quat, Vec3 } from "./math";
|
|
|
2
2
|
/** Far cap / zoom limit; large enough for wide shots without clipping distant ground */
|
|
3
3
|
const FAR_CAP = 8000;
|
|
4
4
|
const FAR_MIN = 200;
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Near-plane floor and cap, in two sets, because what a near plane costs depends
|
|
7
|
+
* entirely on the depth buffer underneath it.
|
|
8
|
+
*
|
|
9
|
+
* The single set that used to live here was written against a projection that
|
|
10
|
+
* silently doubled it (see Mat4.perspectiveInto), so the real clip was at 1.0 and
|
|
11
|
+
* 10 rather than the 0.5 and 5 stated. UNORM keeps exactly that behaviour, now
|
|
12
|
+
* said out loud: identical precision, identical z-fighting margin on coplanar
|
|
13
|
+
* cloth, no change to any scene that renders correctly today.
|
|
14
|
+
*
|
|
15
|
+
* REVERSED gets the floor the content actually wants. Float depth read backwards
|
|
16
|
+
* holds roughly constant RELATIVE precision across the range, so pulling the near
|
|
17
|
+
* plane in by twenty times costs almost nothing — and a 4 mm near plane is closer
|
|
18
|
+
* than any camera VMD will ever push.
|
|
19
|
+
*/
|
|
20
|
+
const NEAR_MIN_UNORM = 1.0;
|
|
21
|
+
const NEAR_MAX_UNORM = 10;
|
|
22
|
+
const NEAR_MIN_REVERSED = 0.05;
|
|
23
|
+
const NEAR_MAX_REVERSED = 5;
|
|
10
24
|
export class Camera {
|
|
11
25
|
constructor(alpha, beta, radius, target, fov = Math.PI / 4) {
|
|
12
26
|
this.aspect = 1;
|
|
@@ -14,8 +28,11 @@ export class Camera {
|
|
|
14
28
|
* nearly all of it within a hand's reach and coplanar cloth/body layers z-fought
|
|
15
29
|
* (white crack flashes, worse the further the camera). 0.5 MMD units ≈ 4 cm —
|
|
16
30
|
* closer than any real framing — and buys 10× precision at character range. */
|
|
17
|
-
this.near =
|
|
31
|
+
this.near = NEAR_MIN_UNORM;
|
|
18
32
|
this.far = FAR_CAP;
|
|
33
|
+
/** Set once by the engine, from whether it got a float depth format. Decides
|
|
34
|
+
* both the near-plane floor and which way round the projection maps z. */
|
|
35
|
+
this.reversedZ = false;
|
|
19
36
|
// Input state
|
|
20
37
|
this.canvas = null;
|
|
21
38
|
this.inputLocked = false;
|
|
@@ -228,12 +245,20 @@ export class Camera {
|
|
|
228
245
|
* user is deliberately close to.
|
|
229
246
|
*/
|
|
230
247
|
updateNearFromRadius() {
|
|
231
|
-
|
|
248
|
+
const lo = this.reversedZ ? NEAR_MIN_REVERSED : NEAR_MIN_UNORM;
|
|
249
|
+
const hi = this.reversedZ ? NEAR_MAX_REVERSED : NEAR_MAX_UNORM;
|
|
250
|
+
this.near = Math.min(hi, Math.max(lo, this.radius / 50));
|
|
232
251
|
}
|
|
233
252
|
getProjectionMatrix() {
|
|
234
253
|
this.updateFarFromRadius();
|
|
235
254
|
this.updateNearFromRadius();
|
|
236
|
-
|
|
255
|
+
// Reversed-Z is the same matrix with near and far handed over the other way
|
|
256
|
+
// round — near → 1, far → 0. One projection function, and the reversal is a
|
|
257
|
+
// property of the depth buffer rather than a second matrix to keep in step.
|
|
258
|
+
if (this.reversedZ)
|
|
259
|
+
Mat4.perspectiveInto(this._projMat.values, this.fov, this.aspect, this.far, this.near);
|
|
260
|
+
else
|
|
261
|
+
Mat4.perspectiveInto(this._projMat.values, this.fov, this.aspect, this.near, this.far);
|
|
237
262
|
return this._projMat;
|
|
238
263
|
}
|
|
239
264
|
attachControl(canvas) {
|