reze-engine 0.69.8 → 0.70.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/dist/_dbg-loader.mjs +1100 -0
- package/dist/camera-mount.d.ts +57 -0
- package/dist/camera-mount.d.ts.map +1 -0
- package/dist/camera-mount.js +249 -0
- package/dist/camera.d.ts +11 -0
- package/dist/camera.d.ts.map +1 -1
- package/dist/camera.js +31 -7
- package/dist/engine.d.ts +130 -2
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +476 -12
- package/dist/graph/compile.js +1 -1
- package/dist/graph/registry.d.ts.map +1 -1
- package/dist/graph/registry.js +19 -2
- package/dist/graph/slots.js +117 -117
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/model.d.ts +35 -0
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +170 -0
- package/dist/shaders/materials/common.d.ts +11 -1
- package/dist/shaders/materials/common.d.ts.map +1 -1
- package/dist/shaders/materials/common.js +571 -548
- package/dist/shaders/passes/cull.d.ts +1 -1
- package/dist/shaders/passes/cull.d.ts.map +1 -1
- package/dist/shaders/passes/cull.js +4 -1
- package/dist/shaders/passes/motion-blur.d.ts +35 -0
- package/dist/shaders/passes/motion-blur.d.ts.map +1 -0
- package/dist/shaders/passes/motion-blur.js +166 -0
- package/dist/shaders/passes/particles.d.ts.map +1 -1
- package/dist/shaders/passes/particles.js +13 -2
- package/dist/shaders/passes/shadow.d.ts +1 -1
- package/dist/shaders/passes/shadow.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/camera-mount.ts +281 -0
- package/src/camera.ts +27 -4
- package/src/engine.ts +21741 -21249
- package/src/graph/compile.ts +1 -1
- package/src/graph/registry.ts +20 -3
- package/src/graph/slots.ts +304 -304
- package/src/index.ts +4 -1
- package/src/model.ts +193 -0
- package/src/shaders/materials/common.ts +706 -682
- package/src/shaders/passes/cull.ts +4 -1
- package/src/shaders/passes/motion-blur.ts +171 -0
- package/src/shaders/passes/particles.ts +14 -2
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Vec3 } from "./math";
|
|
2
|
+
import type { Model } from "./model";
|
|
3
|
+
export type CameraMountMode = "pov" | "selfie";
|
|
4
|
+
/** What setCameraMount asks for. */
|
|
5
|
+
export interface CameraMountOptions {
|
|
6
|
+
/** "pov": through her eyes, turning with her head. "selfie": held in her
|
|
7
|
+
* hand, aimed back at her face. */
|
|
8
|
+
mode: CameraMountMode;
|
|
9
|
+
/** The bone the camera rides. POV 頭 (the head), selfie 右手首 (a wrist). */
|
|
10
|
+
bone?: string;
|
|
11
|
+
/** Seconds the camera's turn trails the bone, eased (POV 0.12, selfie 0.25):
|
|
12
|
+
* a dance's head snaps read as a jolt without it. 0 is rigid. */
|
|
13
|
+
smoothing?: number;
|
|
14
|
+
/** POV: keep the horizon level, dropping the head's tilt. Default true. */
|
|
15
|
+
level?: boolean;
|
|
16
|
+
/** Selfie: how far from her face the phone is held at full stretch, model
|
|
17
|
+
* units (an arm's length is about 7). Closer when her hand is. Default 7. */
|
|
18
|
+
distance?: number;
|
|
19
|
+
}
|
|
20
|
+
/** Where the mounted camera is this frame, world space. */
|
|
21
|
+
export interface MountPose {
|
|
22
|
+
eye: Vec3;
|
|
23
|
+
forward: Vec3;
|
|
24
|
+
up: Vec3;
|
|
25
|
+
}
|
|
26
|
+
export declare function resolveMountOptions(o: CameraMountOptions): Required<CameraMountOptions>;
|
|
27
|
+
/**
|
|
28
|
+
* Between her eyes, world space: the eye bones' midpoint, or up the head bone
|
|
29
|
+
* on a rig without them. Null without a head.
|
|
30
|
+
*/
|
|
31
|
+
export declare function facePoint(m: Model): Vec3 | null;
|
|
32
|
+
export declare class CameraMount {
|
|
33
|
+
readonly model: Model;
|
|
34
|
+
options: Required<CameraMountOptions>;
|
|
35
|
+
private seeded;
|
|
36
|
+
private readonly forward;
|
|
37
|
+
private readonly up;
|
|
38
|
+
/** Selfie: from her face toward the phone, eased. */
|
|
39
|
+
private readonly arm;
|
|
40
|
+
private reach;
|
|
41
|
+
constructor(model: Model, options: CameraMountOptions);
|
|
42
|
+
setOptions(options: CameraMountOptions): void;
|
|
43
|
+
/** Snap to the rig on the next step: a seek or a cut is no camera move. */
|
|
44
|
+
reseed(): void;
|
|
45
|
+
/** This frame's pose, after her pose. Null when the rig lacks the bones. */
|
|
46
|
+
step(dt: number): MountPose | null;
|
|
47
|
+
private pov;
|
|
48
|
+
private selfie;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The materials that ARE her head — hair, face, eyes, brows — for a POV shot
|
|
52
|
+
* to leave out of the camera (and only the camera: her shadow and her mirror
|
|
53
|
+
* image keep them). A material is hers when most of its skinning weight rides
|
|
54
|
+
* 頭 or a bone under it. Computed once per mount.
|
|
55
|
+
*/
|
|
56
|
+
export declare function headMaterials(m: Model): string[];
|
|
57
|
+
//# sourceMappingURL=camera-mount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera-mount.d.ts","sourceRoot":"","sources":["../src/camera-mount.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,CAAA;AAE9C,oCAAoC;AACpC,MAAM,WAAW,kBAAkB;IACjC;wCACoC;IACpC,IAAI,EAAE,eAAe,CAAA;IACrB,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;sEACkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;kFAC8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,2DAA2D;AAC3D,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,IAAI,CAAA;IACT,OAAO,EAAE,IAAI,CAAA;IACb,EAAE,EAAE,IAAI,CAAA;CACT;AAcD,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,kBAAkB,GAAG,QAAQ,CAAC,kBAAkB,CAAC,CASvF;AAqED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI,CAS/C;AAED,qBAAa,WAAW;IAUpB,QAAQ,CAAC,KAAK,EAAE,KAAK;IATvB,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAA;IACrC,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAoB;IACvC,qDAAqD;IACrD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAqB;IACzC,OAAO,CAAC,KAAK,CAAI;gBAGN,KAAK,EAAE,KAAK,EACrB,OAAO,EAAE,kBAAkB;IAK7B,UAAU,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAO7C,2EAA2E;IAC3E,MAAM,IAAI,IAAI;IAId,4EAA4E;IAC5E,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAQlC,OAAO,CAAC,GAAG;IAqBX,OAAO,CAAC,MAAM;CAgCf;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,CAmChD"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
// The camera on a bone: her own eyes (POV), or a phone in her hand (selfie).
|
|
2
|
+
//
|
|
3
|
+
// A third way to hold the camera, beside the orbit and the follow. The follow
|
|
4
|
+
// moves the point the orbit turns about and leaves the orbit's own angle and
|
|
5
|
+
// distance to the person at the mouse; a mount places the EYE and the LOOK from
|
|
6
|
+
// the rig itself, every frame, so the shot is hers.
|
|
7
|
+
//
|
|
8
|
+
// Stepped by the engine after the pose and physics, before the camera uniforms
|
|
9
|
+
// (as the follow is), so it never trails her by a frame and an export renders
|
|
10
|
+
// what the editor showed. A camera VMD or setCameraPose still wins: they are
|
|
11
|
+
// scene data and an explicit host statement about where the camera IS.
|
|
12
|
+
import { Vec3 } from "./math";
|
|
13
|
+
import { Quat } from "./math";
|
|
14
|
+
/** The bones a face is read from, and the head. */
|
|
15
|
+
const HEAD = "頭";
|
|
16
|
+
const EYES = ["左目", "右目"];
|
|
17
|
+
/** POV: how far in front of the eyeballs the lens sits, model units — past the
|
|
18
|
+
* eye's own surface, so nothing of her that is still drawn sits on the lens. */
|
|
19
|
+
const POV_FORWARD = 0.25;
|
|
20
|
+
/** Where a rig without eye bones keeps its eyes: up the head bone, model units. */
|
|
21
|
+
const EYES_UP_FALLBACK = 1.1;
|
|
22
|
+
/** Selfie: the nearest the phone comes to her face, as a share of `distance`. */
|
|
23
|
+
const SELFIE_MIN = 0.55;
|
|
24
|
+
const UP = new Vec3(0, 1, 0);
|
|
25
|
+
export function resolveMountOptions(o) {
|
|
26
|
+
const pov = o.mode !== "selfie";
|
|
27
|
+
return {
|
|
28
|
+
mode: pov ? "pov" : "selfie",
|
|
29
|
+
bone: o.bone || (pov ? HEAD : "右手首"),
|
|
30
|
+
smoothing: Math.min(2, Math.max(0, o.smoothing ?? (pov ? 0.12 : 0.25))),
|
|
31
|
+
level: o.level ?? true,
|
|
32
|
+
distance: Math.min(40, Math.max(2, o.distance ?? 7)),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** A model-space point placed as the scene has the model (setModelTransform). */
|
|
36
|
+
function toWorld(m, p) {
|
|
37
|
+
const s = m.scale;
|
|
38
|
+
const out = new Vec3(p.x * s, p.y * s, p.z * s);
|
|
39
|
+
Quat.rotateVecInto(m.rotation, out, out);
|
|
40
|
+
out.setXYZ(out.x + m.position.x, out.y + m.position.y, out.z + m.position.z);
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
/** A model-space direction turned as the model is; unit length. */
|
|
44
|
+
function dirToWorld(m, x, y, z) {
|
|
45
|
+
const out = new Vec3(x, y, z);
|
|
46
|
+
Quat.rotateVecInto(m.rotation, out, out);
|
|
47
|
+
const l = Math.hypot(out.x, out.y, out.z) || 1;
|
|
48
|
+
out.setXYZ(out.x / l, out.y / l, out.z / l);
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Turn a unit vector toward another by k of the angle between them (a slerp).
|
|
53
|
+
* Not a straight blend: two opposite vectors blend to nothing, so a half turn
|
|
54
|
+
* — her spinning round — would never start to swing.
|
|
55
|
+
*/
|
|
56
|
+
function ease(v, to, k) {
|
|
57
|
+
if (k >= 1) {
|
|
58
|
+
v.set(to);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const d = Math.max(-1, Math.min(1, v.x * to.x + v.y * to.y + v.z * to.z));
|
|
62
|
+
const angle = Math.acos(d);
|
|
63
|
+
if (angle < 1e-5)
|
|
64
|
+
return;
|
|
65
|
+
// The axis to turn about: v × to, or for a half turn any axis square to v.
|
|
66
|
+
let ax = v.y * to.z - v.z * to.y;
|
|
67
|
+
let ay = v.z * to.x - v.x * to.z;
|
|
68
|
+
let az = v.x * to.y - v.y * to.x;
|
|
69
|
+
let al = Math.hypot(ax, ay, az);
|
|
70
|
+
if (al < 1e-6) {
|
|
71
|
+
// Up, unless v is itself vertical.
|
|
72
|
+
if (Math.abs(v.y) < 0.9) {
|
|
73
|
+
ax = -v.z;
|
|
74
|
+
ay = 0;
|
|
75
|
+
az = v.x;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
ax = 0;
|
|
79
|
+
ay = v.z;
|
|
80
|
+
az = -v.y;
|
|
81
|
+
}
|
|
82
|
+
al = Math.hypot(ax, ay, az);
|
|
83
|
+
}
|
|
84
|
+
ax /= al;
|
|
85
|
+
ay /= al;
|
|
86
|
+
az /= al;
|
|
87
|
+
// Rodrigues: v cos θ + (a × v) sin θ + a (a·v)(1 − cos θ).
|
|
88
|
+
const t = angle * k;
|
|
89
|
+
const c = Math.cos(t);
|
|
90
|
+
const s = Math.sin(t);
|
|
91
|
+
const dot = ax * v.x + ay * v.y + az * v.z;
|
|
92
|
+
const cx = ay * v.z - az * v.y;
|
|
93
|
+
const cy = az * v.x - ax * v.z;
|
|
94
|
+
const cz = ax * v.y - ay * v.x;
|
|
95
|
+
const x = v.x * c + cx * s + ax * dot * (1 - c);
|
|
96
|
+
const y = v.y * c + cy * s + ay * dot * (1 - c);
|
|
97
|
+
const z = v.z * c + cz * s + az * dot * (1 - c);
|
|
98
|
+
const l = Math.hypot(x, y, z) || 1;
|
|
99
|
+
v.setXYZ(x / l, y / l, z / l);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Between her eyes, world space: the eye bones' midpoint, or up the head bone
|
|
103
|
+
* on a rig without them. Null without a head.
|
|
104
|
+
*/
|
|
105
|
+
export function facePoint(m) {
|
|
106
|
+
const l = m.getBoneWorldPosition(EYES[0]);
|
|
107
|
+
const r = m.getBoneWorldPosition(EYES[1]);
|
|
108
|
+
if (l && r)
|
|
109
|
+
return toWorld(m, new Vec3((l.x + r.x) / 2, (l.y + r.y) / 2, (l.z + r.z) / 2));
|
|
110
|
+
const h = m.getBoneWorldMatrix(HEAD);
|
|
111
|
+
if (!h)
|
|
112
|
+
return null;
|
|
113
|
+
const up = new Vec3(h[4], h[5], h[6]);
|
|
114
|
+
const ul = Math.hypot(up.x, up.y, up.z) || 1;
|
|
115
|
+
return toWorld(m, new Vec3(h[12] + (up.x / ul) * EYES_UP_FALLBACK, h[13] + (up.y / ul) * EYES_UP_FALLBACK, h[14] + (up.z / ul) * EYES_UP_FALLBACK));
|
|
116
|
+
}
|
|
117
|
+
export class CameraMount {
|
|
118
|
+
constructor(model, options) {
|
|
119
|
+
this.model = model;
|
|
120
|
+
this.seeded = false;
|
|
121
|
+
this.forward = new Vec3(0, 0, -1);
|
|
122
|
+
this.up = new Vec3(0, 1, 0);
|
|
123
|
+
/** Selfie: from her face toward the phone, eased. */
|
|
124
|
+
this.arm = new Vec3(0, 0, -1);
|
|
125
|
+
this.reach = 0;
|
|
126
|
+
this.options = resolveMountOptions(options);
|
|
127
|
+
}
|
|
128
|
+
setOptions(options) {
|
|
129
|
+
const next = resolveMountOptions(options);
|
|
130
|
+
// A new mode or bone starts from where the rig is, not from the old shot.
|
|
131
|
+
if (next.mode !== this.options.mode || next.bone !== this.options.bone)
|
|
132
|
+
this.seeded = false;
|
|
133
|
+
this.options = next;
|
|
134
|
+
}
|
|
135
|
+
/** Snap to the rig on the next step: a seek or a cut is no camera move. */
|
|
136
|
+
reseed() {
|
|
137
|
+
this.seeded = false;
|
|
138
|
+
}
|
|
139
|
+
/** This frame's pose, after her pose. Null when the rig lacks the bones. */
|
|
140
|
+
step(dt) {
|
|
141
|
+
const o = this.options;
|
|
142
|
+
const k = !this.seeded || o.smoothing <= 0 || dt <= 0 ? 1 : 1 - Math.exp(-dt / o.smoothing);
|
|
143
|
+
// A big jump (a seek, a tab come back) is no move to glide through.
|
|
144
|
+
const snap = !this.seeded || dt > 0.25;
|
|
145
|
+
return o.mode === "pov" ? this.pov(snap ? 1 : k) : this.selfie(snap ? 1 : k);
|
|
146
|
+
}
|
|
147
|
+
pov(k) {
|
|
148
|
+
const m = this.model;
|
|
149
|
+
const h = m.getBoneWorldMatrix(this.options.bone) ?? m.getBoneWorldMatrix(HEAD);
|
|
150
|
+
if (!h)
|
|
151
|
+
return null;
|
|
152
|
+
const face = this.options.bone === HEAD ? facePoint(m) : toWorld(m, new Vec3(h[12], h[13], h[14]));
|
|
153
|
+
if (!face)
|
|
154
|
+
return null;
|
|
155
|
+
// MMD rests facing −Z: forward is the head's negated third column, up its second.
|
|
156
|
+
const fwd = dirToWorld(m, -h[8], -h[9], -h[10]);
|
|
157
|
+
const up = this.options.level && Math.abs(fwd.y) < 0.97 ? UP : dirToWorld(m, h[4], h[5], h[6]);
|
|
158
|
+
ease(this.forward, fwd, k);
|
|
159
|
+
ease(this.up, up, k);
|
|
160
|
+
this.seeded = true;
|
|
161
|
+
const f = this.forward;
|
|
162
|
+
const s = POV_FORWARD * m.scale;
|
|
163
|
+
return {
|
|
164
|
+
eye: new Vec3(face.x + f.x * s, face.y + f.y * s, face.z + f.z * s),
|
|
165
|
+
forward: new Vec3(f.x, f.y, f.z),
|
|
166
|
+
up: new Vec3(this.up.x, this.up.y, this.up.z),
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
selfie(k) {
|
|
170
|
+
const m = this.model;
|
|
171
|
+
const face = facePoint(m);
|
|
172
|
+
const hand = m.getBoneWorldPosition(this.options.bone);
|
|
173
|
+
if (!face || !hand)
|
|
174
|
+
return null;
|
|
175
|
+
const hw = toWorld(m, hand);
|
|
176
|
+
let ax = hw.x - face.x;
|
|
177
|
+
let ay = hw.y - face.y;
|
|
178
|
+
let az = hw.z - face.z;
|
|
179
|
+
const d = Math.hypot(ax, ay, az);
|
|
180
|
+
if (d < 1e-4) {
|
|
181
|
+
// Hand on the face: hold the direction it last had.
|
|
182
|
+
ax = this.arm.x;
|
|
183
|
+
ay = this.arm.y;
|
|
184
|
+
az = this.arm.z;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
ax /= d;
|
|
188
|
+
ay /= d;
|
|
189
|
+
az /= d;
|
|
190
|
+
}
|
|
191
|
+
const full = this.options.distance * m.scale;
|
|
192
|
+
const reach = Math.min(full, Math.max(full * SELFIE_MIN, d));
|
|
193
|
+
ease(this.arm, new Vec3(ax, ay, az), k);
|
|
194
|
+
this.reach = this.seeded ? this.reach + (reach - this.reach) * k : reach;
|
|
195
|
+
this.seeded = true;
|
|
196
|
+
const a = this.arm;
|
|
197
|
+
const eye = new Vec3(face.x + a.x * this.reach, face.y + a.y * this.reach, face.z + a.z * this.reach);
|
|
198
|
+
// Aimed back at her face, level: a phone is held upright, not at the wrist's twist.
|
|
199
|
+
const forward = new Vec3(-a.x, -a.y, -a.z);
|
|
200
|
+
const up = Math.abs(forward.y) < 0.97 ? new Vec3(0, 1, 0) : dirToWorld(m, 0, 0, -1);
|
|
201
|
+
return { eye, forward, up };
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* The materials that ARE her head — hair, face, eyes, brows — for a POV shot
|
|
206
|
+
* to leave out of the camera (and only the camera: her shadow and her mirror
|
|
207
|
+
* image keep them). A material is hers when most of its skinning weight rides
|
|
208
|
+
* 頭 or a bone under it. Computed once per mount.
|
|
209
|
+
*/
|
|
210
|
+
export function headMaterials(m) {
|
|
211
|
+
const bones = m.getSkeleton().bones;
|
|
212
|
+
const head = bones.findIndex((b) => b.name === HEAD);
|
|
213
|
+
if (head < 0)
|
|
214
|
+
return [];
|
|
215
|
+
const under = new Uint8Array(bones.length);
|
|
216
|
+
for (let i = 0; i < bones.length; i++) {
|
|
217
|
+
// Walk up to the root; a rig's chain is short.
|
|
218
|
+
for (let b = i, n = 0; b >= 0 && n < 256; b = bones[b].parentIndex, n++) {
|
|
219
|
+
if (b === head) {
|
|
220
|
+
under[i] = 1;
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const { joints, weights } = m.getSkinning();
|
|
226
|
+
const indices = m.getIndices();
|
|
227
|
+
const out = [];
|
|
228
|
+
let start = 0;
|
|
229
|
+
for (const mat of m.getMaterials()) {
|
|
230
|
+
const count = mat.vertexCount;
|
|
231
|
+
let onHead = 0;
|
|
232
|
+
let total = 0;
|
|
233
|
+
for (let i = start; i < start + count; i++) {
|
|
234
|
+
const v = indices[i];
|
|
235
|
+
for (let j = 0; j < 4; j++) {
|
|
236
|
+
const w = weights[v * 4 + j];
|
|
237
|
+
if (w === 0)
|
|
238
|
+
continue;
|
|
239
|
+
total += w;
|
|
240
|
+
if (under[joints[v * 4 + j]])
|
|
241
|
+
onHead += w;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
start += count;
|
|
245
|
+
if (total > 0 && onHead / total > 0.5)
|
|
246
|
+
out.push(mat.name);
|
|
247
|
+
}
|
|
248
|
+
return out;
|
|
249
|
+
}
|
package/dist/camera.d.ts
CHANGED
|
@@ -101,6 +101,17 @@ export declare class Camera {
|
|
|
101
101
|
* to be left.
|
|
102
102
|
*/
|
|
103
103
|
getEyePosition(): Vec3;
|
|
104
|
+
/**
|
|
105
|
+
* The shot as a bone holds it (Engine.setCameraMount): an eye, a look and an
|
|
106
|
+
* up, set by the engine each frame. Outranks the orbit, not a VMD — the
|
|
107
|
+
* orbit's own alpha/beta/radius stay untouched underneath, so taking the
|
|
108
|
+
* mount off puts back the shot that was there. Null while unmounted.
|
|
109
|
+
*/
|
|
110
|
+
mountPose: {
|
|
111
|
+
eye: Vec3;
|
|
112
|
+
forward: Vec3;
|
|
113
|
+
up: Vec3;
|
|
114
|
+
} | null;
|
|
104
115
|
getViewMatrix(): Mat4;
|
|
105
116
|
private getCameraVectors;
|
|
106
117
|
private panCamera;
|
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;AAgCpD,qBAAa,MAAM;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,IAAI,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAI;IAClB;;;oFAGgF;IAChF,IAAI,EAAE,MAAM,CAAiB;IAC7B,GAAG,EAAE,MAAM,CAAU;IACrB;+EAC2E;IAC3E,SAAS,UAAQ;IAGjB,OAAO,CAAC,MAAM,CAAiC;IAC/C,OAAO,CAAC,WAAW,CAAiB;IACpC;;;;;;;;;OASG;IACH,OAAO,EAAE,IA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AW3B,aAAa,CAAC,MAAM,EAAE,iBAAiB;IAiBvC,aAAa;IAkBb,cAAc,CAAC,MAAM,EAAE,OAAO;IAS9B,OAAO,CAAC,WAAW;IAWnB;;;;;;;;;OASG;IACH,OAAO,CAAC,WAAW,CAA4B;IAE/C,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI;IAI/C,OAAO,CAAC,WAAW;IAoBnB,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
|
@@ -97,6 +97,13 @@ export class Camera {
|
|
|
97
97
|
this._vmdDistance = -45;
|
|
98
98
|
this._savedFov = Math.PI / 4;
|
|
99
99
|
this._quatScratch = new Float32Array(16);
|
|
100
|
+
/**
|
|
101
|
+
* The shot as a bone holds it (Engine.setCameraMount): an eye, a look and an
|
|
102
|
+
* up, set by the engine each frame. Outranks the orbit, not a VMD — the
|
|
103
|
+
* orbit's own alpha/beta/radius stay untouched underneath, so taking the
|
|
104
|
+
* mount off puts back the shot that was there. Null while unmounted.
|
|
105
|
+
*/
|
|
106
|
+
this.mountPose = null;
|
|
100
107
|
/**
|
|
101
108
|
* How far the scene REACHES, in world units from the origin.
|
|
102
109
|
*
|
|
@@ -222,9 +229,19 @@ export class Camera {
|
|
|
222
229
|
* to be left.
|
|
223
230
|
*/
|
|
224
231
|
getEyePosition() {
|
|
225
|
-
|
|
232
|
+
if (this.vmdDriven)
|
|
233
|
+
return this.vmdEye();
|
|
234
|
+
const m = this.mountPose;
|
|
235
|
+
if (m)
|
|
236
|
+
return new Vec3(m.eye.x, m.eye.y, m.eye.z);
|
|
237
|
+
return this.getPosition();
|
|
226
238
|
}
|
|
227
239
|
getViewMatrix() {
|
|
240
|
+
if (!this.vmdDriven && this.mountPose) {
|
|
241
|
+
const { eye, forward: f, up: u } = this.mountPose;
|
|
242
|
+
Mat4.lookAtInto(this._viewMat.values, eye.x, eye.y, eye.z, eye.x + f.x, eye.y + f.y, eye.z + f.z, u.x, u.y, u.z);
|
|
243
|
+
return this._viewMat;
|
|
244
|
+
}
|
|
228
245
|
if (this.vmdDriven) {
|
|
229
246
|
const eye = this.vmdEye();
|
|
230
247
|
const s = this._quatScratch;
|
|
@@ -390,6 +407,12 @@ export class Camera {
|
|
|
390
407
|
updateNearFromRadius() {
|
|
391
408
|
const lo = this.reversedZ ? NEAR_MIN_REVERSED : NEAR_MIN_UNORM;
|
|
392
409
|
const hi = this.reversedZ ? NEAR_MAX_REVERSED : NEAR_MAX_UNORM;
|
|
410
|
+
// A mounted lens sits at her face or a hand's length from it: the orbit
|
|
411
|
+
// radius says nothing about that, and her own hands come right up to it.
|
|
412
|
+
if (this.mountPose && !this.vmdDriven) {
|
|
413
|
+
this.near = lo;
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
393
416
|
this.near = Math.min(hi, Math.max(lo, this.radius / 50));
|
|
394
417
|
}
|
|
395
418
|
getProjectionMatrix() {
|
|
@@ -457,8 +480,9 @@ export class Camera {
|
|
|
457
480
|
this.orbitButton = button;
|
|
458
481
|
}
|
|
459
482
|
onMouseMove(e) {
|
|
460
|
-
|
|
461
|
-
|
|
483
|
+
// A VMD or a mount owns the camera; orbit/pan is inert.
|
|
484
|
+
if (this.inputLocked || this.vmdDriven || this.mountPose)
|
|
485
|
+
return;
|
|
462
486
|
if (!this.isDragging)
|
|
463
487
|
return;
|
|
464
488
|
const deltaX = e.clientX - this.lastMousePos.x;
|
|
@@ -480,8 +504,8 @@ export class Camera {
|
|
|
480
504
|
}
|
|
481
505
|
onWheel(e) {
|
|
482
506
|
e.preventDefault();
|
|
483
|
-
if (this.vmdDriven)
|
|
484
|
-
return; // VMD owns the camera; zoom is inert
|
|
507
|
+
if (this.vmdDriven || this.mountPose)
|
|
508
|
+
return; // VMD or mount owns the camera; zoom is inert
|
|
485
509
|
// Update camera radius (zoom)
|
|
486
510
|
this.radius += e.deltaY * this.wheelPrecision;
|
|
487
511
|
// Clamp radius to reasonable bounds
|
|
@@ -530,8 +554,8 @@ export class Camera {
|
|
|
530
554
|
if (!this.isDragging && !this.isPinching)
|
|
531
555
|
return;
|
|
532
556
|
e.preventDefault();
|
|
533
|
-
if (this.vmdDriven)
|
|
534
|
-
return; // VMD owns the camera; pinch/pan/rotate is inert
|
|
557
|
+
if (this.vmdDriven || this.mountPose)
|
|
558
|
+
return; // VMD or mount owns the camera; pinch/pan/rotate is inert
|
|
535
559
|
if (this.isPinching && e.touches.length === 2) {
|
|
536
560
|
// Two-finger gesture: can be pinch zoom or pan
|
|
537
561
|
const touch1 = e.touches[0];
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type CameraMountOptions } from "./camera-mount";
|
|
1
2
|
import { Quat, Vec3 } from "./math";
|
|
2
|
-
import { Model, type EyeTrackingOptions } from "./model";
|
|
3
|
+
import { Model, type AutoBlinkOptions, type EyeTrackingOptions } from "./model";
|
|
3
4
|
import { type CameraKeyframe } from "./vmd-loader";
|
|
4
5
|
import { type CameraPose } from "./camera-animation";
|
|
5
6
|
import { RezePhysics } from "./physics";
|
|
@@ -19,6 +20,12 @@ import { type CompileOptions, type StyleSlot } from "./graph/compile";
|
|
|
19
20
|
import type { AlphaMode, RenderClass, StyleBlend } from "./graph/render-class";
|
|
20
21
|
import type { ApplyStyleGroupResult, ApplyStyleGroupsResult, StyleGroup } from "./graph/style-group";
|
|
21
22
|
import { type EffectParamDecl } from "./shaders/directives";
|
|
23
|
+
/** What setMotionBlur asks for. */
|
|
24
|
+
export interface MotionBlurOptions {
|
|
25
|
+
/** The fraction of a 1/30 s frame the shutter is open: 0.5 is film's 180°.
|
|
26
|
+
* 0.05–1, default 0.5. */
|
|
27
|
+
shutter?: number;
|
|
28
|
+
}
|
|
22
29
|
export type MaterialPreset = "default" | "face" | "hair" | "body" | "eye" | "stockings" | "metal" | "cloth_smooth" | "cloth_rough";
|
|
23
30
|
export type MaterialPresetMap = Partial<Record<MaterialPreset, string[]>>;
|
|
24
31
|
type GroupInstall = {
|
|
@@ -733,6 +740,9 @@ interface ModelInstance {
|
|
|
733
740
|
xrayKey: string;
|
|
734
741
|
/** Materials the reflection probe leaves out (setMaterialInProbe). */
|
|
735
742
|
probeHiddenMaterials: Set<string>;
|
|
743
|
+
/** Materials the main camera leaves out, shadow and mirror keeping them —
|
|
744
|
+
* her own head while the camera is mounted at her eyes (setCameraMount). */
|
|
745
|
+
cameraHiddenMaterials: Set<string>;
|
|
736
746
|
/** Material-morph targets, or null when the model has no type-8 morphs. */
|
|
737
747
|
materialMorphTargets: MaterialMorphTarget[] | null;
|
|
738
748
|
/** The same targets by PMX material index, so a named offset is one lookup. */
|
|
@@ -866,6 +876,22 @@ export type SceneLight = {
|
|
|
866
876
|
*/
|
|
867
877
|
tube?: XYZ;
|
|
868
878
|
};
|
|
879
|
+
/**
|
|
880
|
+
* A KEY LIGHT FOR THE CAST that turns with the camera, as Aether Gazer lights
|
|
881
|
+
* its characters: CharacterEffect's _localLight* puts the key in the frame of
|
|
882
|
+
* the camera's view flattened to the ground (sim_TowardMatrix), so whatever
|
|
883
|
+
* the shot she is lit from the viewer's side — `inclination` degrees above
|
|
884
|
+
* the ground, `azimuth` degrees round from straight behind the camera. Drawn
|
|
885
|
+
* as a directional light on `layers` (RENDERING_LAYER_CHARACTER when
|
|
886
|
+
* omitted), standing in for the sun there.
|
|
887
|
+
*/
|
|
888
|
+
export type CastKey = {
|
|
889
|
+
color: XYZ;
|
|
890
|
+
strength: number;
|
|
891
|
+
inclination: number;
|
|
892
|
+
azimuth: number;
|
|
893
|
+
layers?: number;
|
|
894
|
+
};
|
|
869
895
|
/**
|
|
870
896
|
* Rendering layers, as the game's pipeline (URP's rendering layers) uses them:
|
|
871
897
|
* every drawing carries layer bits and a light reaches it only where its mask
|
|
@@ -1755,6 +1781,8 @@ export declare class Engine {
|
|
|
1755
1781
|
private cameraFollowYaw;
|
|
1756
1782
|
private cameraFollowPitch;
|
|
1757
1783
|
private cameraTargetOffset;
|
|
1784
|
+
/** The camera on a bone (setCameraMount), and whose rig it rides. */
|
|
1785
|
+
private cameraMount;
|
|
1758
1786
|
private lastFrameTime;
|
|
1759
1787
|
private static readonly STATS_WINDOW;
|
|
1760
1788
|
private static readonly STATS_REFRESH_MS;
|
|
@@ -2614,6 +2642,16 @@ export declare class Engine {
|
|
|
2614
2642
|
* drawn behind the window as anywhere else. Null or empty: none.
|
|
2615
2643
|
*/
|
|
2616
2644
|
setXrayMaterials(modelName: string, names: readonly string[] | null): boolean;
|
|
2645
|
+
/**
|
|
2646
|
+
* Each named material's own rendering layers, the bits a light's are tested
|
|
2647
|
+
* against (RENDERING_LAYER_*), in place of the model's. A game lights each
|
|
2648
|
+
* renderer by its own few lamps — URP's per-object lights, four on Aether
|
|
2649
|
+
* Gazer's stages — and a stage converted to one model carries that as a
|
|
2650
|
+
* layer per group of renderers that share lamps, and each lamp on the
|
|
2651
|
+
* groups it lights. Materials left out, or the whole map null, take the
|
|
2652
|
+
* model's layers again.
|
|
2653
|
+
*/
|
|
2654
|
+
setMaterialLayers(modelName: string, layers: Readonly<Record<string, number>> | null): boolean;
|
|
2617
2655
|
/** Bones and followed points into the block, where they stand this frame. */
|
|
2618
2656
|
private resolveParamBindings;
|
|
2619
2657
|
/**
|
|
@@ -2881,6 +2919,27 @@ export declare class Engine {
|
|
|
2881
2919
|
* (re)bound — cameraFollowSeeded, cleared there, is set right after this.
|
|
2882
2920
|
*/
|
|
2883
2921
|
private turnWithFollowBone;
|
|
2922
|
+
/**
|
|
2923
|
+
* The camera on a bone: through her eyes ("pov", on 頭) or held in her hand
|
|
2924
|
+
* and aimed back at her face ("selfie", on a wrist). See camera-mount.ts.
|
|
2925
|
+
*
|
|
2926
|
+
* Placed every frame after her pose and physics, before the camera is
|
|
2927
|
+
* written, so it never trails her and an export renders what the editor
|
|
2928
|
+
* showed. Outranks the orbit and the follow — which stay as they were
|
|
2929
|
+
* underneath, and come back when the mount goes — but not a camera VMD or
|
|
2930
|
+
* setCameraPose. In POV her head (hair, face, eyes: the materials skinned
|
|
2931
|
+
* mostly to 頭 and below) leaves the camera, and only the camera: her shadow
|
|
2932
|
+
* and her mirror image keep it.
|
|
2933
|
+
*
|
|
2934
|
+
* Null takes the camera off. False when the model is not loaded.
|
|
2935
|
+
*/
|
|
2936
|
+
setCameraMount(model: string | Model | null, options: CameraMountOptions | null): boolean;
|
|
2937
|
+
getCameraMount(): (Required<CameraMountOptions> & {
|
|
2938
|
+
model: string;
|
|
2939
|
+
}) | null;
|
|
2940
|
+
/** The materials a POV mount keeps out of the camera, for a host to show. */
|
|
2941
|
+
getCameraHiddenMaterials(modelName: string): string[];
|
|
2942
|
+
private dropCameraMount;
|
|
2884
2943
|
/** True while the orbit target is riding a model bone (setCameraFollow). */
|
|
2885
2944
|
isCameraFollowing(): boolean;
|
|
2886
2945
|
/** True while the loaded camera VMD is actively driving the shot. */
|
|
@@ -3227,6 +3286,16 @@ export declare class Engine {
|
|
|
3227
3286
|
* scenes that want the sharp edge and pay nothing. */
|
|
3228
3287
|
shadowSoftness?: number;
|
|
3229
3288
|
}): void;
|
|
3289
|
+
private castKey;
|
|
3290
|
+
private castKeyAim;
|
|
3291
|
+
/**
|
|
3292
|
+
* The cast's own key light, turning with the camera (CastKey). It takes the
|
|
3293
|
+
* last directional slot; null gives the slot back to the scene's lights.
|
|
3294
|
+
*/
|
|
3295
|
+
setCastKey(key: CastKey | null): void;
|
|
3296
|
+
/** The cast key's direction for this frame's camera: the toward frame is the
|
|
3297
|
+
* view's back (towards the eye) flattened to the ground, up, and their cross. */
|
|
3298
|
+
private updateCastKey;
|
|
3230
3299
|
/**
|
|
3231
3300
|
* The scene's positional lights — an ADDITIVE layer over the sun, which stays
|
|
3232
3301
|
* the key light and keeps the toon ramp to itself.
|
|
@@ -4398,10 +4467,25 @@ export declare class Engine {
|
|
|
4398
4467
|
private handleGizmoMouseUp;
|
|
4399
4468
|
private renderPickPass;
|
|
4400
4469
|
private resolvePickResult;
|
|
4470
|
+
/** See setTimeScale. */
|
|
4471
|
+
private timeScale;
|
|
4472
|
+
/**
|
|
4473
|
+
* Global playback speed: every clock the frame advances — clips and their
|
|
4474
|
+
* morphs, the camera VMD, physics, tweens, jelly eyes, auto blink, effect
|
|
4475
|
+
* time (rzTime), particles, trails, dissolves, param tracks, scheduled
|
|
4476
|
+
* effects and the camera follow's lag — runs on `delta × scale`, live
|
|
4477
|
+
* (render) and offline (renderFrame) alike. So 0.5 is true slow motion: hair
|
|
4478
|
+
* falls slowly, a sparkle drifts at half pace, and an export stepped at
|
|
4479
|
+
* 1/fps covers half as much of the clip per frame. 0.25–2; frame stats stay
|
|
4480
|
+
* on wall time. The host keeps the music in step (it plays the audio).
|
|
4481
|
+
*/
|
|
4482
|
+
setTimeScale(scale: number): void;
|
|
4483
|
+
getTimeScale(): number;
|
|
4401
4484
|
render(): void;
|
|
4402
4485
|
/**
|
|
4403
4486
|
* Render one frame advancing every clock — animation, physics, tweens, and the
|
|
4404
|
-
* camera VMD — by exactly `deltaSeconds
|
|
4487
|
+
* camera VMD — by exactly `deltaSeconds` (times the time scale, see
|
|
4488
|
+
* setTimeScale), independent of wall time. This is the
|
|
4405
4489
|
* offline-rendering primitive (video export): call it N times with 1/fps and the
|
|
4406
4490
|
* result is deterministic whether the machine renders faster or slower than
|
|
4407
4491
|
* realtime. Also resets the realtime clock so a later render() (returning to the
|
|
@@ -4521,6 +4605,50 @@ export declare class Engine {
|
|
|
4521
4605
|
* gives the eyes back to the motion.
|
|
4522
4606
|
*/
|
|
4523
4607
|
setEyeTracking(modelName: string, options: EyeTrackingOptions | null): boolean;
|
|
4608
|
+
/**
|
|
4609
|
+
* Auto blink, per model — see Model.setAutoBlink. She blinks on her own
|
|
4610
|
+
* every few seconds, over a morph motion's own blinks. Null hands the morph
|
|
4611
|
+
* back. False for a model that is not loaded or has no closing morph.
|
|
4612
|
+
*/
|
|
4613
|
+
setAutoBlink(modelName: string, options: AutoBlinkOptions | null): boolean;
|
|
4614
|
+
getAutoBlink(modelName: string): Required<AutoBlinkOptions> | null;
|
|
4615
|
+
private motionBlur;
|
|
4616
|
+
private mbVelocityPipeline;
|
|
4617
|
+
private mbVelocityPending;
|
|
4618
|
+
private mbGatherPipeline;
|
|
4619
|
+
private mbFrameLayout;
|
|
4620
|
+
private mbInstanceLayout;
|
|
4621
|
+
private mbFrameBindGroup;
|
|
4622
|
+
private mbPrevCameraBuffer;
|
|
4623
|
+
private mbUniformBuffer;
|
|
4624
|
+
private readonly mbUniformData;
|
|
4625
|
+
private mbVelocityMs;
|
|
4626
|
+
private mbVelocity;
|
|
4627
|
+
private mbScratch;
|
|
4628
|
+
private mbGatherBindGroup;
|
|
4629
|
+
private mbGatherDepthView;
|
|
4630
|
+
private mbSampler;
|
|
4631
|
+
/** Last frame's camera view-projection, or null after a cut or on the first frame. */
|
|
4632
|
+
private mbPrevViewProj;
|
|
4633
|
+
/** Per model: last frame's skin matrices on the GPU, and the CPU copy they came from. */
|
|
4634
|
+
private readonly mbInstances;
|
|
4635
|
+
/**
|
|
4636
|
+
* Motion blur on everything that moves: her limbs, hair and cloth from the
|
|
4637
|
+
* pose, everything else from the camera. Per pixel, live and in an export
|
|
4638
|
+
* (the shutter follows the frame's own delta, so a 30 fps export and a
|
|
4639
|
+
* 120 Hz screen streak alike). `shutter` is the fraction of a 1/30 s frame
|
|
4640
|
+
* the shutter is open: 0.5 is film's 180°. Null switches it off, and then it
|
|
4641
|
+
* costs nothing. See shaders/passes/motion-blur.ts.
|
|
4642
|
+
*/
|
|
4643
|
+
setMotionBlur(options: MotionBlurOptions | null): void;
|
|
4644
|
+
getMotionBlur(): Required<MotionBlurOptions> | null;
|
|
4645
|
+
private mbEnsurePipelines;
|
|
4646
|
+
/** The motion pass and the gather, on the resolved HDR before bloom. */
|
|
4647
|
+
private renderMotionBlur;
|
|
4648
|
+
private mbStorePrev;
|
|
4649
|
+
/** A model's last-frame skin buffer and its velocity bind group, rebuilt if
|
|
4650
|
+
* the model's own buffers were replaced. */
|
|
4651
|
+
private mbInstance;
|
|
4524
4652
|
/**
|
|
4525
4653
|
* A repeating dissolve on one model, on the scene clock.
|
|
4526
4654
|
*
|