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.
@@ -1191,7 +1191,7 @@ interface EntityAnimation {
1191
1191
  /** Seconds. */
1192
1192
  length: number;
1193
1193
  loop: boolean;
1194
- /** Geometry layer targeted by this clip; defaults to `main`. */
1194
+ /** Geometry layer targeted by this clip; defaults to `main`. A `main` clip also poses selected layers without their own clip. */
1195
1195
  layer?: string;
1196
1196
  /** Part name anywhere in a layer; `root` is the layer's root part. */
1197
1197
  bones: Record<string, EntityAnimationBone>;
@@ -1599,11 +1599,12 @@ declare class EntityObject extends SceneObject {
1599
1599
  get animationTime(): number;
1600
1600
  /**
1601
1601
  * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
1602
- * Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
1602
+ * Offsets apply to the baked pose in the clip's layer (`main` by default) and its repeated draws.
1603
+ * A `main` clip also poses every selected layer without a clip of its own.
1603
1604
  * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
1604
1605
  */
1605
1606
  playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
1606
- /** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
1607
+ /** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
1607
1608
  playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void;
1608
1609
  /** Stops all clips and restores the poses from before playback. */
1609
1610
  stopAnimation(): void;
@@ -1191,7 +1191,7 @@ interface EntityAnimation {
1191
1191
  /** Seconds. */
1192
1192
  length: number;
1193
1193
  loop: boolean;
1194
- /** Geometry layer targeted by this clip; defaults to `main`. */
1194
+ /** Geometry layer targeted by this clip; defaults to `main`. A `main` clip also poses selected layers without their own clip. */
1195
1195
  layer?: string;
1196
1196
  /** Part name anywhere in a layer; `root` is the layer's root part. */
1197
1197
  bones: Record<string, EntityAnimationBone>;
@@ -1599,11 +1599,12 @@ declare class EntityObject extends SceneObject {
1599
1599
  get animationTime(): number;
1600
1600
  /**
1601
1601
  * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
1602
- * Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
1602
+ * Offsets apply to the baked pose in the clip's layer (`main` by default) and its repeated draws.
1603
+ * A `main` clip also poses every selected layer without a clip of its own.
1603
1604
  * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
1604
1605
  */
1605
1606
  playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
1606
- /** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
1607
+ /** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
1607
1608
  playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void;
1608
1609
  /** Stops all clips and restores the poses from before playback. */
1609
1610
  stopAnimation(): void;
@@ -3966,11 +3966,14 @@ var init_UVMapper = __esm({
3966
3966
  });
3967
3967
  }
3968
3968
  static fillMissingTextureKeys(textures, target) {
3969
- for (let faceName of CUBE_FACES) {
3970
- let v = textures[faceName];
3971
- if (v && v.startsWith("#")) {
3972
- target[faceName] = target[v.substr(1)];
3969
+ for (const key in textures) {
3970
+ let name = key;
3971
+ const seen = /* @__PURE__ */ new Set();
3972
+ while (textures[name]?.startsWith("#") && !seen.has(name)) {
3973
+ seen.add(name);
3974
+ name = textures[name].substr(1);
3973
3975
  }
3976
+ if (name !== key) target[key] = target[name];
3974
3977
  }
3975
3978
  return target;
3976
3979
  }
@@ -5355,13 +5358,14 @@ var init_EntityObject = __esm({
5355
5358
  }
5356
5359
  /**
5357
5360
  * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
5358
- * Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
5361
+ * Offsets apply to the baked pose in the clip's layer (`main` by default) and its repeated draws.
5362
+ * A `main` clip also poses every selected layer without a clip of its own.
5359
5363
  * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
5360
5364
  */
5361
5365
  playAnimation(animation, options) {
5362
5366
  this.playAnimations([animation], options);
5363
5367
  }
5364
- /** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
5368
+ /** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
5365
5369
  playAnimations(animations, options) {
5366
5370
  const targets = /* @__PURE__ */ new Set();
5367
5371
  const selections = animations.map((animation) => {
@@ -5372,6 +5376,8 @@ var init_EntityObject = __esm({
5372
5376
  if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
5373
5377
  return { animation, names };
5374
5378
  });
5379
+ const main = selections.find(({ animation }) => (animation.layer ?? "main") === "main");
5380
+ if (main) main.names.push(...Object.keys(this.entityLayers).filter((name) => !targets.has(name.split("#")[0])));
5375
5381
  this.createMeshes();
5376
5382
  this.stopAnimation();
5377
5383
  for (const { animation, names } of selections) {
@@ -5431,24 +5437,26 @@ var init_EntityObject = __esm({
5431
5437
  createMeshes(force = false) {
5432
5438
  if (this.meshesCreated && !force) return;
5433
5439
  const modelRoot = new import_three14.Object3D();
5440
+ let transformNode = modelRoot;
5434
5441
  const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
5435
5442
  if (transform) {
5436
- for (const op of transform) {
5437
- const matrix = new import_three14.Matrix4();
5438
- if ("scale" in op) matrix.makeScale(...op.scale);
5439
- else if ("translate" in op) matrix.makeTranslation(...op.translate);
5440
- else matrix.makeRotationFromEuler(new import_three14.Euler(...op.rotate, "ZYX"));
5441
- modelRoot.matrix.multiply(matrix);
5443
+ for (const [index, op] of transform.entries()) {
5444
+ if (index > 0) {
5445
+ const child = new import_three14.Object3D();
5446
+ transformNode.add(child);
5447
+ transformNode = child;
5448
+ }
5449
+ if ("scale" in op) transformNode.scale.set(...op.scale);
5450
+ else if ("translate" in op) transformNode.position.set(...op.translate);
5451
+ else transformNode.rotation.set(...op.rotate, "ZYX");
5442
5452
  }
5443
- modelRoot.matrixWorldNeedsUpdate = true;
5444
- modelRoot.matrixAutoUpdate = false;
5445
5453
  } else if (this.options.flip ?? true) {
5446
5454
  modelRoot.scale.set(-1, -1, 1);
5447
5455
  }
5448
5456
  this.add(modelRoot);
5449
5457
  Object.entries(this.entityLayers).forEach(([name, layer], index) => {
5450
5458
  const group = this.createGroup(`layer:${name}`);
5451
- modelRoot.add(group);
5459
+ transformNode.add(group);
5452
5460
  const inward = !Materials.entityModeCulls(layer.render ?? layer.layer.render);
5453
5461
  this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward, this.options.faces?.[name]);
5454
5462
  });