reze-engine 0.55.2 → 0.55.3

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/engine.js CHANGED
@@ -1089,6 +1089,12 @@ export class Engine {
1089
1089
  * Set by the cascade loop, which skips a cascade that is unwanted and already
1090
1090
  * cleared rather than re-clearing it every frame. */
1091
1091
  this.shadowCascadeCleared = [];
1092
+ this.attachScratch = new Float32Array(16);
1093
+ /** Instances in pose order: a parent before every model hanging from it, so
1094
+ * a child reads the bone as posed and simulated THIS frame. Insertion order
1095
+ * otherwise. Rebuilt when a model is added, removed or re-parented. */
1096
+ this.updateOrder = [];
1097
+ this.updateOrderDirty = true;
1092
1098
  /** Skinned positions for picking, grown on demand. One click's worth of work
1093
1099
  * reused across clicks — a model's vertex count does not change. */
1094
1100
  this.materialPickScratch = null;
@@ -3889,7 +3895,7 @@ export class Engine {
3889
3895
  for (const inst of this.modelInstances.values()) {
3890
3896
  // Neither a stage nor a plane is a performer, so neither is a subject an
3891
3897
  // effect can follow.
3892
- if (!inst.model.visible || inst.isStage || inst.isPlane)
3898
+ if (!inst.model.visible || inst.isStage || inst.isPlane || inst.isProp)
3893
3899
  continue;
3894
3900
  const model = inst.model;
3895
3901
  const matrices = model.getWorldMatrices();
@@ -6741,7 +6747,7 @@ export class Engine {
6741
6747
  // is first in insertion order and was seeding this clock with its own
6742
6748
  // permanent zero. In a scene with a stage, a camera VMD therefore sampled
6743
6749
  // frame 0 forever and the shot never moved.
6744
- if (inst.isStage || inst.isPlane)
6750
+ if (inst.isStage || inst.isPlane || inst.isProp)
6745
6751
  continue;
6746
6752
  const p = inst.model.getAnimationProgress();
6747
6753
  if (p.playing || p.paused)
@@ -7135,6 +7141,12 @@ export class Engine {
7135
7141
  await this.addStage(model, pmxKey, { name, transform: options.transform, assetReader: reader });
7136
7142
  return model;
7137
7143
  }
7144
+ /** loadModel's folder/zip path for a prop. See addProp. */
7145
+ async loadProp(name, options) {
7146
+ const { model, pmxKey, reader } = await this.openPmxFromFiles(name, options);
7147
+ await this.addProp(model, pmxKey, { name, transform: options.transform, assetReader: reader });
7148
+ return model;
7149
+ }
7138
7150
  /** Read a PMX out of a picked folder / expanded zip. Shared by loadModel and
7139
7151
  * loadStage so the file-map and path handling exist in exactly one place. */
7140
7152
  async openPmxFromFiles(name, options) {
@@ -7160,7 +7172,7 @@ export class Engine {
7160
7172
  const reader = assetReader ?? createFetchAssetReader();
7161
7173
  const basePath = deriveBasePathFromPmxPath(pmxPath);
7162
7174
  model.setAssetContext(reader, basePath);
7163
- await this.setupModelInstance(key, model, basePath, reader, options?.stage ?? false, options?.plane ?? false, options?.dynamic ?? false);
7175
+ await this.setupModelInstance(key, model, basePath, reader, options?.stage ?? false, options?.plane ?? false, options?.dynamic ?? false, options?.prop ?? false);
7164
7176
  return key;
7165
7177
  }
7166
7178
  /**
@@ -7188,6 +7200,24 @@ export class Engine {
7188
7200
  this.setModelTransform(key, options.transform);
7189
7201
  return key;
7190
7202
  }
7203
+ /**
7204
+ * Add a PMX as a PROP: an object a character holds or wears rather than a
7205
+ * performer or the environment. A microphone, a fan, a sword, an umbrella.
7206
+ *
7207
+ * It keeps what makes a held thing look right — physics (the charm on a phone
7208
+ * strap swings), toon outlines, its own clip if it has one — and drops what
7209
+ * makes a model a cast member: no effect subject id, so a silhouette effect
7210
+ * still outlines HER and not the mic; no seeding of the scene clock; no bone
7211
+ * picking in the pose editor. Like a card it leaves the built-in ground
7212
+ * alone, which is the one thing a stage does that a prop must not. Usually
7213
+ * hung from a bone with setModelParent, though it can stand on its own.
7214
+ */
7215
+ async addProp(model, pmxPath, options) {
7216
+ const key = await this.addModel(model, pmxPath, options?.name, options?.assetReader, { prop: true });
7217
+ if (options?.transform)
7218
+ this.setModelTransform(key, options.transform);
7219
+ return key;
7220
+ }
7191
7221
  /**
7192
7222
  * Put a picture in the scene as a flat card.
7193
7223
  *
@@ -7412,8 +7442,15 @@ export class Engine {
7412
7442
  for (const install of inst.styleGroups.values())
7413
7443
  this.destroyInstall(install);
7414
7444
  this.modelInstances.delete(name);
7445
+ // Whatever hung from it stands on its own now, at identity — the same
7446
+ // place a detach leaves a model.
7447
+ for (const other of this.modelInstances.values()) {
7448
+ if (other.parent?.model === name)
7449
+ this.setModelParent(other.name, null);
7450
+ }
7415
7451
  this.cullListDirty = true;
7416
7452
  this.bundlesDirty = true;
7453
+ this.updateOrderDirty = true;
7417
7454
  }
7418
7455
  getModelNames() {
7419
7456
  return Array.from(this.modelInstances.keys());
@@ -7421,6 +7458,127 @@ export class Engine {
7421
7458
  getModel(name) {
7422
7459
  return this.modelInstances.get(name)?.model ?? null;
7423
7460
  }
7461
+ /**
7462
+ * Hang a model from a bone of another — MMD's 外部親 (outside parent).
7463
+ *
7464
+ * Every frame, after the parent has been posed and simulated, the child's
7465
+ * root bones are placed at that bone with `offset` composed on top, and only
7466
+ * then is the child posed itself. The placement enters through the child's
7467
+ * BONES rather than its model transform (Model.setRootParent): physics runs
7468
+ * in model space, so a root moved by the transform would have a charm on a
7469
+ * phone strap feel gravity swing with the hand, while a root moved by the
7470
+ * skeleton keeps down down. It also puts the child's own clip on top of the
7471
+ * ride, as MMD does — an umbrella that spins keeps spinning in the hand.
7472
+ *
7473
+ * While attached the child's position and rotation are held at identity and
7474
+ * setModelTransform ignores them; scale still applies, and is folded into
7475
+ * the placement so the offset stays in the parent's units. Detaching leaves
7476
+ * the model at identity until the host places it again.
7477
+ *
7478
+ * A bone the parent lacks rides the parent's root, which is what camera
7479
+ * follow does with an unknown name. Returns false for an unknown model, a
7480
+ * missing parent, or a model asked to ride itself.
7481
+ */
7482
+ setModelParent(name, parent, bone = "全ての親", offset) {
7483
+ const inst = this.modelInstances.get(name);
7484
+ if (!inst)
7485
+ return false;
7486
+ if (parent === null) {
7487
+ if (inst.parent) {
7488
+ inst.parent = null;
7489
+ inst.model.setRootParent(null);
7490
+ inst.skinMatricesDirty = true;
7491
+ this.updateOrderDirty = true;
7492
+ }
7493
+ return true;
7494
+ }
7495
+ if (parent === name || !this.modelInstances.has(parent))
7496
+ return false;
7497
+ const p = offset?.position ?? new Vec3(0, 0, 0);
7498
+ const r = offset?.rotation ?? Quat.identity();
7499
+ const offsetMatrix = inst.parent?.offsetMatrix ?? new Float32Array(16);
7500
+ Mat4.fromPositionRotationScaleInto(p.x, p.y, p.z, r.x, r.y, r.z, r.w, 1, offsetMatrix);
7501
+ // Identity until the first frame fills it: a physics reset between now and
7502
+ // then re-poses the model, and a zero matrix would fold it to a point.
7503
+ const rootMatrix = inst.parent?.rootMatrix ?? new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
7504
+ inst.parent = { model: parent, bone, offsetMatrix, rootMatrix };
7505
+ inst.model.setPosition(new Vec3(0, 0, 0));
7506
+ inst.model.setRotation(Quat.identity());
7507
+ inst.model.setRootParent(rootMatrix);
7508
+ inst.skinMatricesDirty = true;
7509
+ this.updateOrderDirty = true;
7510
+ return true;
7511
+ }
7512
+ /** What a model hangs from, or null. */
7513
+ getModelParent(name) {
7514
+ const att = this.modelInstances.get(name)?.parent;
7515
+ return att ? { model: att.model, bone: att.bone } : null;
7516
+ }
7517
+ /**
7518
+ * The root an attached model is posed under this frame: the parent's
7519
+ * placement, its bone as posed and simulated, then the offset.
7520
+ *
7521
+ * The translation is divided by the child's own scale. The skin bake
7522
+ * multiplies the child's scale back on outside the skeleton, and a uniform
7523
+ * scale commutes with the rotation, so this is exactly what lands the child
7524
+ * at the bone in world units while its mesh still comes out scaled.
7525
+ */
7526
+ placeAttached(inst) {
7527
+ const att = inst.parent;
7528
+ const parent = this.modelInstances.get(att.model);
7529
+ if (!parent) {
7530
+ this.setModelParent(inst.name, null);
7531
+ return;
7532
+ }
7533
+ const out = att.rootMatrix;
7534
+ const tmp = this.attachScratch;
7535
+ const root = parent.model.getRootMatrix();
7536
+ const bone = parent.model.getBoneWorldMatrix(att.bone);
7537
+ if (bone) {
7538
+ Mat4.multiplyArrays(root, 0, bone, 0, tmp, 0);
7539
+ Mat4.multiplyArrays(tmp, 0, att.offsetMatrix, 0, out, 0);
7540
+ }
7541
+ else {
7542
+ Mat4.multiplyArrays(root, 0, att.offsetMatrix, 0, out, 0);
7543
+ }
7544
+ const s = inst.model.scale;
7545
+ if (s > 0 && s !== 1) {
7546
+ const k = 1 / s;
7547
+ out[12] *= k;
7548
+ out[13] *= k;
7549
+ out[14] *= k;
7550
+ }
7551
+ }
7552
+ instancesInUpdateOrder() {
7553
+ if (!this.updateOrderDirty)
7554
+ return this.updateOrder;
7555
+ const placed = new Set();
7556
+ const order = [];
7557
+ let pending = Array.from(this.modelInstances.values());
7558
+ while (pending.length > 0) {
7559
+ const rest = [];
7560
+ for (const inst of pending) {
7561
+ const p = inst.parent?.model;
7562
+ if (p === undefined || placed.has(p) || !this.modelInstances.has(p)) {
7563
+ order.push(inst);
7564
+ placed.add(inst.name);
7565
+ }
7566
+ else
7567
+ rest.push(inst);
7568
+ }
7569
+ if (rest.length === pending.length) {
7570
+ // A cycle: nothing left can go first. They pose in insertion order and
7571
+ // each reads the other's previous frame, which is the best a cycle gets.
7572
+ console.warn(`[reze] attachment cycle: ${rest.map((r) => r.name).join(" → ")}`);
7573
+ order.push(...rest);
7574
+ break;
7575
+ }
7576
+ pending = rest;
7577
+ }
7578
+ this.updateOrder = order;
7579
+ this.updateOrderDirty = false;
7580
+ return order;
7581
+ }
7424
7582
  /**
7425
7583
  * Place a model in the scene — position, rotation, uniform scale, visibility. The
7426
7584
  * transform is a root offset baked into skinning (moves the whole rig), so it composes
@@ -7433,9 +7591,12 @@ export class Engine {
7433
7591
  const model = inst?.model;
7434
7592
  if (!inst || !model)
7435
7593
  return;
7436
- if (transform.position)
7594
+ // An attached model is placed by its parent's bone; its own position and
7595
+ // rotation are held at identity so the ride is the whole placement (see
7596
+ // setModelParent). Scale and visibility are still its own.
7597
+ if (transform.position && !inst.parent)
7437
7598
  model.setPosition(transform.position);
7438
- if (transform.rotation)
7599
+ if (transform.rotation && !inst.parent)
7439
7600
  model.setRotation(transform.rotation);
7440
7601
  if (transform.scale !== undefined)
7441
7602
  model.setScale(transform.scale);
@@ -7553,7 +7714,7 @@ export class Engine {
7553
7714
  for (const inst of this.modelInstances.values()) {
7554
7715
  if (options.modelName !== undefined && inst.name !== options.modelName)
7555
7716
  continue;
7556
- if (inst.isStage || inst.isPlane)
7717
+ if (inst.isStage || inst.isPlane || inst.isProp)
7557
7718
  continue;
7558
7719
  const bones = inst.model.getSkeleton().bones;
7559
7720
  this.bonePickScratch = boneMarkerPositions(inst.model, this.bonePickScratch);
@@ -7615,7 +7776,7 @@ export class Engine {
7615
7776
  for (const inst of this.modelInstances.values()) {
7616
7777
  if (options.modelName !== undefined && inst.name !== options.modelName)
7617
7778
  continue;
7618
- if (inst.isStage || inst.isPlane)
7779
+ if (inst.isStage || inst.isPlane || inst.isProp)
7619
7780
  continue;
7620
7781
  const model = inst.model;
7621
7782
  const { positions } = model.getGeometry();
@@ -7797,6 +7958,52 @@ export class Engine {
7797
7958
  else
7798
7959
  inst.hiddenMaterials.add(materialName);
7799
7960
  }
7961
+ /**
7962
+ * Push a colour/shading edit straight into a material's own uniform buffer —
7963
+ * the same block createMaterialUniformBuffer wrote at load, offset for
7964
+ * offset. A single write per call, on the fields that actually moved, so
7965
+ * dragging one slider does not touch the other eleven.
7966
+ *
7967
+ * UNGROUPED materials only. A grouped material renders through its style
7968
+ * group's own compiled graph (setupPipelines' neutral/DEFAULT_GRAPH path is
7969
+ * what reads this buffer, and a grouped material never runs it) — the call
7970
+ * still writes the bytes, they are simply never sampled, which would look
7971
+ * like the edit silently failing. Callers check groupsByModel first and this
7972
+ * quietly no-ops rather than assume that check was made, since a document
7973
+ * edit landing to the WRONG channel (the group's own colour input) would be
7974
+ * a worse failure than one that does nothing.
7975
+ *
7976
+ * Structural fields — anything that changes which draw bucket a material is
7977
+ * in, or which texture it binds — are NOT here: alpha crossing the 1.0
7978
+ * opaque/transparent line, edge on/off, a texture swap, all need the draw
7979
+ * list or the bind group rebuilt, not a uniform write. Those get their own
7980
+ * call when something needs them.
7981
+ */
7982
+ setMaterialUniforms(modelName, materialName, patch) {
7983
+ const inst = this.modelInstances.get(modelName);
7984
+ if (!inst)
7985
+ return false;
7986
+ const materials = inst.model.getMaterials();
7987
+ const index = materials.findIndex((m) => m.name === materialName);
7988
+ if (index < 0)
7989
+ return false;
7990
+ const buffer = inst.materialUniformBuffers[index];
7991
+ if (!buffer)
7992
+ return false;
7993
+ if (patch.diffuse) {
7994
+ this.device.queue.writeBuffer(buffer, 0, new Float32Array(patch.diffuse));
7995
+ }
7996
+ if (patch.ambient) {
7997
+ this.device.queue.writeBuffer(buffer, 16, new Float32Array(patch.ambient));
7998
+ }
7999
+ if (patch.specularPower !== undefined) {
8000
+ this.device.queue.writeBuffer(buffer, 28, new Float32Array([patch.specularPower]));
8001
+ }
8002
+ if (patch.specular) {
8003
+ this.device.queue.writeBuffer(buffer, 32, new Float32Array(patch.specular));
8004
+ }
8005
+ return true;
8006
+ }
7800
8007
  isMaterialVisible(modelName, materialName) {
7801
8008
  const inst = this.modelInstances.get(modelName);
7802
8009
  return inst ? !inst.hiddenMaterials.has(materialName) : false;
@@ -7905,12 +8112,19 @@ export class Engine {
7905
8112
  updateInstances(deltaTime) {
7906
8113
  let animMs = 0;
7907
8114
  let physicsMs = 0;
7908
- this.forEachInstance((inst) => {
8115
+ for (const inst of this.instancesInUpdateOrder()) {
7909
8116
  const tAnim = performance.now();
8117
+ // An attached model is placed from its parent's bone as posed and
8118
+ // simulated THIS frame — the order guarantees the parent came first —
8119
+ // and only then posed itself, so its clip and physics ride the placement.
8120
+ const attached = inst.parent !== null;
8121
+ if (attached)
8122
+ this.placeAttached(inst);
7910
8123
  // A stage never solves IK — nothing drives its chains — and skips the pose
7911
8124
  // pass entirely while it is idle. Morph changes still come through, since
7912
- // that is the one thing a stage's controls do move.
7913
- const stageIdle = (inst.isStage || inst.isPlane) && inst.model.isIdle();
8125
+ // that is the one thing a stage's controls do move. A prop idles the same
8126
+ // way while it stands on its own; hung from a hand it moves every frame.
8127
+ const stageIdle = (inst.isStage || inst.isPlane || inst.isProp) && !attached && inst.model.isIdle();
7914
8128
  let verticesChanged = false;
7915
8129
  if (!stageIdle) {
7916
8130
  verticesChanged = inst.model.update(deltaTime, inst.isStage || inst.isPlane ? false : this.ikEnabled);
@@ -7956,7 +8170,7 @@ export class Engine {
7956
8170
  }
7957
8171
  if (inst.vertexBufferNeedsUpdate)
7958
8172
  this.updateVertexBuffer(inst);
7959
- });
8173
+ }
7960
8174
  this.frameAnimMsRaw = animMs;
7961
8175
  this.framePhysicsMsRaw = physicsMs;
7962
8176
  const EMA = 0.1;
@@ -8863,7 +9077,7 @@ export class Engine {
8863
9077
  });
8864
9078
  }
8865
9079
  }
8866
- async setupModelInstance(name, model, basePath, assetReader, isStage = false, isPlane = false, dynamicTexture = false) {
9080
+ async setupModelInstance(name, model, basePath, assetReader, isStage = false, isPlane = false, dynamicTexture = false, isProp = false) {
8867
9081
  const vertices = model.getVertices();
8868
9082
  const skinning = model.getSkinning();
8869
9083
  const skeleton = model.getSkeleton();
@@ -8983,6 +9197,8 @@ export class Engine {
8983
9197
  pickDrawCalls: [],
8984
9198
  isStage,
8985
9199
  isPlane,
9200
+ isProp,
9201
+ parent: null,
8986
9202
  dynamicTexture,
8987
9203
  // Seeded true: the bind pose has to reach the GPU once before any frame.
8988
9204
  skinMatricesDirty: true,
@@ -9011,6 +9227,7 @@ export class Engine {
9011
9227
  this.modelInstances.set(name, inst);
9012
9228
  this.cullListDirty = true;
9013
9229
  this.bundlesDirty = true;
9230
+ this.updateOrderDirty = true;
9014
9231
  }
9015
9232
  // Build the per-model GPU vertex-morph state. Returns null (and leaves the model on the
9016
9233
  // CPU morph path) when the model has no vertex morphs. Created buffers are pushed into
@@ -11950,7 +12167,7 @@ export class Engine {
11950
12167
  // serves.
11951
12168
  let n = 0;
11952
12169
  this.forEachInstance((inst) => {
11953
- if (n >= MAX_EFFECT_SUBJECTS || inst.isStage || inst.isPlane)
12170
+ if (n >= MAX_EFFECT_SUBJECTS || inst.isStage || inst.isPlane || inst.isProp)
11954
12171
  return;
11955
12172
  const m = inst.model;
11956
12173
  // The model transform is only where the model was PLACED. A motion moves
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { Engine, DEFAULT_BLOOM_OPTIONS, DEFAULT_DEPTH_OF_FIELD_OPTIONS, DEFAULT_VIEW_TRANSFORM, DEFAULT_COLOR_GRADING, type ColorGradingOptions, type EngineStats, type EngineOptions, type BloomOptions, type DepthOfFieldOptions, type ViewTransformOptions, type LoadModelFromFilesOptions, type MaterialPreset, type MaterialPresetMap, type ModelTransform, type GizmoDragEvent, type GizmoDragCallback, type GizmoDragKind, type DissolveCycle, type EffectParamValue, type EffectResult, type CullDiagnostics, type MidiNote, } from "./engine";
1
+ export { Engine, DEFAULT_BLOOM_OPTIONS, DEFAULT_DEPTH_OF_FIELD_OPTIONS, DEFAULT_VIEW_TRANSFORM, DEFAULT_COLOR_GRADING, type ColorGradingOptions, type EngineStats, type EngineOptions, type BloomOptions, type DepthOfFieldOptions, type ViewTransformOptions, type LoadModelFromFilesOptions, type MaterialPreset, type MaterialPresetMap, type ModelTransform, type ModelAttachment, type GizmoDragEvent, type GizmoDragCallback, type GizmoDragKind, type DissolveCycle, type EffectParamValue, type EffectResult, type CullDiagnostics, type MidiNote, } from "./engine";
2
2
  export { parsePmxFolderInput, pmxFileAtRelativePath, type PmxFolderInputResult } from "./folder-upload";
3
3
  export { parseMidi } from "./midi-loader";
4
4
  export { parseHDR, type HdrImage } from "./hdr";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,qBAAqB,EACrB,8BAA8B,EAC9B,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,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AAa,EAClB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,QAAQ,GACd,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAI3F,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,IAAI,EACT,KAAK,SAAS,GACf,MAAM,WAAW,CAAA"}
package/dist/model.d.ts CHANGED
@@ -159,6 +159,15 @@ export declare class Model {
159
159
  setRotation(rotation: Quat): void;
160
160
  setScale(scale: number): void;
161
161
  setVisible(visible: boolean): void;
162
+ /** Hang the rig's root bones from `matrix` (model space, column-major 16
163
+ * floats), or from nothing. The engine drives this every frame for an
164
+ * attached model; the matrix is read at the next world pass, not copied. */
165
+ setRootParent(matrix: Float32Array | null): void;
166
+ getRootParent(): Float32Array | null;
167
+ /** The placement matrix (position · rotation · scale) the skin bake composes
168
+ * onto every bone. Rebuilt lazily, the way getSkinMatrices does it. */
169
+ getRootMatrix(): Float32Array;
170
+ private refreshRootMatrix;
162
171
  private vertexData;
163
172
  private baseVertexData;
164
173
  private vertexCount;
@@ -197,6 +206,21 @@ export declare class Model {
197
206
  private rootMatrixValues;
198
207
  private rootMatrixDirty;
199
208
  private rootIsIdentity;
209
+ /** What every parentless bone hangs from — MMD's 外部親 (outside parent).
210
+ * Model space, so the pose pipeline, IK and physics all see it: a prop bound
211
+ * to a hand is moved by its BONES, and gravity keeps pointing down while the
212
+ * hand tilts. Null is the ordinary rig, rooted at the model's own origin.
213
+ * Written per frame by the engine from the parent's posed bone; see
214
+ * Engine.setModelParent. */
215
+ private rootParent;
216
+ /** The bind position of the PRIMARY root — the first parentless bone, 全ての親
217
+ * by convention. Under a root parent that bone sits exactly ON the parent
218
+ * bone, as MMD's 外部親 does, so its bind position is taken off every root's
219
+ * local matrix: the primary lands at the parent, the other roots keep their
220
+ * layout relative to it. Without this the MODEL ORIGIN went to the parent
221
+ * bone, and a prop rigged with its one bone at the mesh's centre hung that
222
+ * far away from the hand. */
223
+ private primaryRootBind;
200
224
  private skinMatricesArray?;
201
225
  private deformOrder;
202
226
  /** 1 where the simulation overwrites the bone's world matrix. See setPhysicsDrivenBones. */
@@ -317,6 +341,9 @@ export declare class Model {
317
341
  private clipApplySuspended;
318
342
  setClipApplySuspended(suspended: boolean): void;
319
343
  isClipApplySuspended(): boolean;
344
+ /** A bone's posed matrix — model space, column-major, the live array rather
345
+ * than a copy. Null for a name this rig does not have. */
346
+ getBoneWorldMatrix(boneName: string): Float32Array | null;
320
347
  getBoneWorldPosition(boneName: string): Vec3 | null;
321
348
  /**
322
349
  * A bone's forward axis, normalised — which way a foot points, where a head
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAA6C,MAAM,QAAQ,CAAA;AAEpF,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,gBA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;IAOZ;;uEAEmE;IACnE,cAAc,IAAI,IAAI;IAQtB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAM3B,oBAAoB,IAAI,iBAAiB;IAazC,OAAO,CAAC,MAAM,CAAC,UAAU;IAWzB,OAAO,CAAC,iBAAiB;IAczB;;;;;;OAMG;IACH,OAAO,CAAC,UAAU,CAAoB;IAEtC;8EAC0E;IAC1E,OAAO,CAAC,eAAe;IAevB;;;;8BAI0B;IAC1B,OAAO,CAAC,mBAAmB;IA2C3B,8FAA8F;IAC9F,OAAO,CAAC,gBAAgB;IAkBxB;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,iBAAiB;IAiCzB;;;;yEAIqE;IACrE,OAAO,CAAC,gBAAgB;IAuIxB;sFACkF;IAClF,OAAO,CAAC,YAAY;IAmDpB;;2EAEuE;IACvE,OAAO,CAAC,cAAc;IA0CtB;;;;;;;;;OASG;IACH,MAAM,IAAI,OAAO;IAiBjB,qDAAqD;IACrD,OAAO,CAAC,eAAe;IAQvB,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,OAAO;IAqGpD,OAAO,CAAC,aAAa;IAyCrB,OAAO,CAAC,aAAa,CAAyB;IAI9C,OAAO,CAAC,4BAA4B;IA4HpC;;;;;;;;;;;;;;;;;OAiBG;IACH,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI;IAkDlD;kFAC8E;IAC9E,oBAAoB,IAAI,MAAM,EAAE;IAIhC;;;;;;;;;;;;;;;OAeG;IACH,kBAAkB,IAAI,IAAI;IA4C1B,oBAAoB,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI;CA0GhD"}
package/dist/model.js CHANGED
@@ -70,6 +70,35 @@ export class Model {
70
70
  setVisible(visible) {
71
71
  this._visible = visible;
72
72
  }
73
+ /** Hang the rig's root bones from `matrix` (model space, column-major 16
74
+ * floats), or from nothing. The engine drives this every frame for an
75
+ * attached model; the matrix is read at the next world pass, not copied. */
76
+ setRootParent(matrix) {
77
+ this.rootParent = matrix;
78
+ if (matrix) {
79
+ const root = this.skeleton.bones.find((b) => b.parentIndex < 0);
80
+ this.primaryRootBind = root ? [root.bindTranslation[0], root.bindTranslation[1], root.bindTranslation[2]] : [0, 0, 0];
81
+ }
82
+ }
83
+ getRootParent() {
84
+ return this.rootParent;
85
+ }
86
+ /** The placement matrix (position · rotation · scale) the skin bake composes
87
+ * onto every bone. Rebuilt lazily, the way getSkinMatrices does it. */
88
+ getRootMatrix() {
89
+ this.refreshRootMatrix();
90
+ return this.rootMatrixValues;
91
+ }
92
+ refreshRootMatrix() {
93
+ if (!this.rootMatrixDirty)
94
+ return;
95
+ const p = this._position, r = this._rotation, s = this._scale;
96
+ Mat4.fromPositionRotationScaleInto(p.x, p.y, p.z, r.x, r.y, r.z, r.w, s, this.rootMatrixValues);
97
+ this.rootIsIdentity =
98
+ p.x === 0 && p.y === 0 && p.z === 0 &&
99
+ r.x === 0 && r.y === 0 && r.z === 0 && r.w === 1 && s === 1;
100
+ this.rootMatrixDirty = false;
101
+ }
73
102
  /** Called by Engine when registering the model; enables loadVmd to resolve relative paths for folder uploads. */
74
103
  setAssetContext(reader, basePath) {
75
104
  this.assetReader = reader;
@@ -122,6 +151,21 @@ export class Model {
122
151
  this.rootMatrixValues = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
123
152
  this.rootMatrixDirty = false;
124
153
  this.rootIsIdentity = true;
154
+ /** What every parentless bone hangs from — MMD's 外部親 (outside parent).
155
+ * Model space, so the pose pipeline, IK and physics all see it: a prop bound
156
+ * to a hand is moved by its BONES, and gravity keeps pointing down while the
157
+ * hand tilts. Null is the ordinary rig, rooted at the model's own origin.
158
+ * Written per frame by the engine from the parent's posed bone; see
159
+ * Engine.setModelParent. */
160
+ this.rootParent = null;
161
+ /** The bind position of the PRIMARY root — the first parentless bone, 全ての親
162
+ * by convention. Under a root parent that bone sits exactly ON the parent
163
+ * bone, as MMD's 外部親 does, so its bind position is taken off every root's
164
+ * local matrix: the primary lands at the parent, the other roots keep their
165
+ * layout relative to it. Without this the MODEL ORIGIN went to the parent
166
+ * bone, and a prop rigged with its one bone at the mesh's centre hung that
167
+ * far away from the hand. */
168
+ this.primaryRootBind = [0, 0, 0];
125
169
  /** 1 where the simulation overwrites the bone's world matrix. See setPhysicsDrivenBones. */
126
170
  this.physicsDriven = null;
127
171
  /** Bones to recompute after a step, in deform order — null when no rig needs it. */
@@ -652,6 +696,14 @@ export class Model {
652
696
  isClipApplySuspended() {
653
697
  return this.clipApplySuspended;
654
698
  }
699
+ /** A bone's posed matrix — model space, column-major, the live array rather
700
+ * than a copy. Null for a name this rig does not have. */
701
+ getBoneWorldMatrix(boneName) {
702
+ const idx = this.runtimeSkeleton.nameIndex[boneName];
703
+ if (idx === undefined || idx < 0)
704
+ return null;
705
+ return this.runtimeSkeleton.worldMatrices[idx].values;
706
+ }
655
707
  // World bone origin (world matrix col3); unknown name → null
656
708
  getBoneWorldPosition(boneName) {
657
709
  const idx = this.runtimeSkeleton.nameIndex[boneName];
@@ -879,14 +931,7 @@ export class Model {
879
931
  }
880
932
  const skinMatrices = this.skinMatricesArray;
881
933
  // Rebuild root matrix + cache identity-shortcut flag only when pos/rot changed.
882
- if (this.rootMatrixDirty) {
883
- const p = this._position, r = this._rotation, s = this._scale;
884
- Mat4.fromPositionRotationScaleInto(p.x, p.y, p.z, r.x, r.y, r.z, r.w, s, this.rootMatrixValues);
885
- this.rootIsIdentity =
886
- p.x === 0 && p.y === 0 && p.z === 0 &&
887
- r.x === 0 && r.y === 0 && r.z === 0 && r.w === 1 && s === 1;
888
- this.rootMatrixDirty = false;
889
- }
934
+ this.refreshRootMatrix();
890
935
  if (this.rootIsIdentity) {
891
936
  // skinMatrix = worldMatrix × inverseBindMatrix
892
937
  for (let i = 0; i < boneCount; i++) {
@@ -2209,6 +2254,13 @@ export class Model {
2209
2254
  const parentMat = worldMats[b.parentIndex];
2210
2255
  Mat4.multiplyArrays(parentMat.values, 0, localMVals, 0, worldMat.values, 0);
2211
2256
  }
2257
+ else if (this.rootParent) {
2258
+ const pr = this.primaryRootBind;
2259
+ localMVals[12] -= pr[0];
2260
+ localMVals[13] -= pr[1];
2261
+ localMVals[14] -= pr[2];
2262
+ Mat4.multiplyArrays(this.rootParent, 0, localMVals, 0, worldMat.values, 0);
2263
+ }
2212
2264
  else {
2213
2265
  worldMat.values.set(localMVals);
2214
2266
  }
@@ -2362,6 +2414,8 @@ export class Model {
2362
2414
  // leaving every other bone — the simulated ones above all — untouched.
2363
2415
  const order = subset ?? this.deformOrder;
2364
2416
  const count = subset ? subset.length : boneCount;
2417
+ const rootParent = this.rootParent;
2418
+ const primaryRootBind = this.primaryRootBind;
2365
2419
  const override = this.appendRotOverride;
2366
2420
  const overrideSet = this.appendRotOverrideSet;
2367
2421
  for (let k = 0; k < count; k++) {
@@ -2427,6 +2481,14 @@ export class Model {
2427
2481
  const parentMat = worldMats[b.parentIndex];
2428
2482
  Mat4.multiplyArrays(parentMat.values, 0, localMVals, 0, worldMat.values, 0);
2429
2483
  }
2484
+ else if (rootParent) {
2485
+ // The primary root's bind position comes off every root, so the primary
2486
+ // sits ON the parent bone. See primaryRootBind.
2487
+ localMVals[12] -= primaryRootBind[0];
2488
+ localMVals[13] -= primaryRootBind[1];
2489
+ localMVals[14] -= primaryRootBind[2];
2490
+ Mat4.multiplyArrays(rootParent, 0, localMVals, 0, worldMat.values, 0);
2491
+ }
2430
2492
  else {
2431
2493
  worldMat.values.set(localMVals);
2432
2494
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reze-engine",
3
- "version": "0.55.2",
3
+ "version": "0.55.3",
4
4
  "description": "A lightweight WebGPU engine for real-time 3D MMD/PMX model rendering",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",