minerender 2.1.0-alpha.124 → 2.1.0-alpha.125

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/bundle.js CHANGED
@@ -90271,13 +90271,14 @@ ${key}` : key;
90271
90271
  }
90272
90272
  /**
90273
90273
  * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
90274
- * Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
90274
+ * Offsets apply to the baked pose in the clip's layer (`main` by default) and its repeated draws.
90275
+ * A `main` clip also poses every selected layer without a clip of its own.
90275
90276
  * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
90276
90277
  */
90277
90278
  playAnimation(animation, options) {
90278
90279
  this.playAnimations([animation], options);
90279
90280
  }
90280
- /** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
90281
+ /** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
90281
90282
  playAnimations(animations, options) {
90282
90283
  const targets = /* @__PURE__ */ new Set();
90283
90284
  const selections = animations.map((animation) => {
@@ -90288,6 +90289,8 @@ ${key}` : key;
90288
90289
  if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
90289
90290
  return { animation, names };
90290
90291
  });
90292
+ const main = selections.find(({ animation }) => (animation.layer ?? "main") === "main");
90293
+ if (main) main.names.push(...Object.keys(this.entityLayers).filter((name2) => !targets.has(name2.split("#")[0])));
90291
90294
  this.createMeshes();
90292
90295
  this.stopAnimation();
90293
90296
  for (const { animation, names } of selections) {
@@ -90347,24 +90350,26 @@ ${key}` : key;
90347
90350
  createMeshes(force = false) {
90348
90351
  if (this.meshesCreated && !force) return;
90349
90352
  const modelRoot = new Object3D();
90353
+ let transformNode = modelRoot;
90350
90354
  const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
90351
90355
  if (transform) {
90352
- for (const op of transform) {
90353
- const matrix = new Matrix4();
90354
- if ("scale" in op) matrix.makeScale(...op.scale);
90355
- else if ("translate" in op) matrix.makeTranslation(...op.translate);
90356
- else matrix.makeRotationFromEuler(new Euler(...op.rotate, "ZYX"));
90357
- modelRoot.matrix.multiply(matrix);
90358
- }
90359
- modelRoot.matrixWorldNeedsUpdate = true;
90360
- modelRoot.matrixAutoUpdate = false;
90356
+ for (const [index, op] of transform.entries()) {
90357
+ if (index > 0) {
90358
+ const child = new Object3D();
90359
+ transformNode.add(child);
90360
+ transformNode = child;
90361
+ }
90362
+ if ("scale" in op) transformNode.scale.set(...op.scale);
90363
+ else if ("translate" in op) transformNode.position.set(...op.translate);
90364
+ else transformNode.rotation.set(...op.rotate, "ZYX");
90365
+ }
90361
90366
  } else if (this.options.flip ?? true) {
90362
90367
  modelRoot.scale.set(-1, -1, 1);
90363
90368
  }
90364
90369
  this.add(modelRoot);
90365
90370
  Object.entries(this.entityLayers).forEach(([name2, layer], index) => {
90366
90371
  const group = this.createGroup(`layer:${name2}`);
90367
- modelRoot.add(group);
90372
+ transformNode.add(group);
90368
90373
  const inward = !Materials.entityModeCulls(layer.render ?? layer.layer.render);
90369
90374
  this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward, this.options.faces?.[name2]);
90370
90375
  });