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.
@@ -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;
@@ -5358,13 +5358,14 @@ var init_EntityObject = __esm({
5358
5358
  }
5359
5359
  /**
5360
5360
  * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
5361
- * 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.
5362
5363
  * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
5363
5364
  */
5364
5365
  playAnimation(animation, options) {
5365
5366
  this.playAnimations([animation], options);
5366
5367
  }
5367
- /** 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`. */
5368
5369
  playAnimations(animations, options) {
5369
5370
  const targets = /* @__PURE__ */ new Set();
5370
5371
  const selections = animations.map((animation) => {
@@ -5375,6 +5376,8 @@ var init_EntityObject = __esm({
5375
5376
  if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
5376
5377
  return { animation, names };
5377
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])));
5378
5381
  this.createMeshes();
5379
5382
  this.stopAnimation();
5380
5383
  for (const { animation, names } of selections) {
@@ -5434,24 +5437,26 @@ var init_EntityObject = __esm({
5434
5437
  createMeshes(force = false) {
5435
5438
  if (this.meshesCreated && !force) return;
5436
5439
  const modelRoot = new import_three14.Object3D();
5440
+ let transformNode = modelRoot;
5437
5441
  const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
5438
5442
  if (transform) {
5439
- for (const op of transform) {
5440
- const matrix = new import_three14.Matrix4();
5441
- if ("scale" in op) matrix.makeScale(...op.scale);
5442
- else if ("translate" in op) matrix.makeTranslation(...op.translate);
5443
- else matrix.makeRotationFromEuler(new import_three14.Euler(...op.rotate, "ZYX"));
5444
- 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");
5445
5452
  }
5446
- modelRoot.matrixWorldNeedsUpdate = true;
5447
- modelRoot.matrixAutoUpdate = false;
5448
5453
  } else if (this.options.flip ?? true) {
5449
5454
  modelRoot.scale.set(-1, -1, 1);
5450
5455
  }
5451
5456
  this.add(modelRoot);
5452
5457
  Object.entries(this.entityLayers).forEach(([name, layer], index) => {
5453
5458
  const group = this.createGroup(`layer:${name}`);
5454
- modelRoot.add(group);
5459
+ transformNode.add(group);
5455
5460
  const inward = !Materials.entityModeCulls(layer.render ?? layer.layer.render);
5456
5461
  this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward, this.options.faces?.[name]);
5457
5462
  });