minerender 2.1.0-alpha.123 → 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
@@ -88859,11 +88859,14 @@ ${key}` : key;
88859
88859
  });
88860
88860
  }
88861
88861
  static fillMissingTextureKeys(textures, target) {
88862
- for (let faceName of CUBE_FACES) {
88863
- let v5 = textures[faceName];
88864
- if (v5 && v5.startsWith("#")) {
88865
- target[faceName] = target[v5.substr(1)];
88862
+ for (const key in textures) {
88863
+ let name2 = key;
88864
+ const seen = /* @__PURE__ */ new Set();
88865
+ while (textures[name2]?.startsWith("#") && !seen.has(name2)) {
88866
+ seen.add(name2);
88867
+ name2 = textures[name2].substr(1);
88866
88868
  }
88869
+ if (name2 !== key) target[key] = target[name2];
88867
88870
  }
88868
88871
  return target;
88869
88872
  }
@@ -90268,13 +90271,14 @@ ${key}` : key;
90268
90271
  }
90269
90272
  /**
90270
90273
  * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
90271
- * 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.
90272
90276
  * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
90273
90277
  */
90274
90278
  playAnimation(animation, options) {
90275
90279
  this.playAnimations([animation], options);
90276
90280
  }
90277
- /** 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`. */
90278
90282
  playAnimations(animations, options) {
90279
90283
  const targets = /* @__PURE__ */ new Set();
90280
90284
  const selections = animations.map((animation) => {
@@ -90285,6 +90289,8 @@ ${key}` : key;
90285
90289
  if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
90286
90290
  return { animation, names };
90287
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])));
90288
90294
  this.createMeshes();
90289
90295
  this.stopAnimation();
90290
90296
  for (const { animation, names } of selections) {
@@ -90344,24 +90350,26 @@ ${key}` : key;
90344
90350
  createMeshes(force = false) {
90345
90351
  if (this.meshesCreated && !force) return;
90346
90352
  const modelRoot = new Object3D();
90353
+ let transformNode = modelRoot;
90347
90354
  const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
90348
90355
  if (transform) {
90349
- for (const op of transform) {
90350
- const matrix = new Matrix4();
90351
- if ("scale" in op) matrix.makeScale(...op.scale);
90352
- else if ("translate" in op) matrix.makeTranslation(...op.translate);
90353
- else matrix.makeRotationFromEuler(new Euler(...op.rotate, "ZYX"));
90354
- modelRoot.matrix.multiply(matrix);
90355
- }
90356
- modelRoot.matrixWorldNeedsUpdate = true;
90357
- 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
+ }
90358
90366
  } else if (this.options.flip ?? true) {
90359
90367
  modelRoot.scale.set(-1, -1, 1);
90360
90368
  }
90361
90369
  this.add(modelRoot);
90362
90370
  Object.entries(this.entityLayers).forEach(([name2, layer], index) => {
90363
90371
  const group = this.createGroup(`layer:${name2}`);
90364
- modelRoot.add(group);
90372
+ transformNode.add(group);
90365
90373
  const inward = !Materials.entityModeCulls(layer.render ?? layer.layer.render);
90366
90374
  this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward, this.options.faces?.[name2]);
90367
90375
  });