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.
@@ -1189,7 +1189,7 @@ interface EntityAnimation {
1189
1189
  /** Seconds. */
1190
1190
  length: number;
1191
1191
  loop: boolean;
1192
- /** Geometry layer targeted by this clip; defaults to `main`. */
1192
+ /** Geometry layer targeted by this clip; defaults to `main`. A `main` clip also poses selected layers without their own clip. */
1193
1193
  layer?: string;
1194
1194
  /** Part name anywhere in a layer; `root` is the layer's root part. */
1195
1195
  bones: Record<string, EntityAnimationBone>;
@@ -1597,11 +1597,12 @@ declare class EntityObject extends SceneObject {
1597
1597
  get animationTime(): number;
1598
1598
  /**
1599
1599
  * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
1600
- * Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
1600
+ * Offsets apply to the baked pose in the clip's layer (`main` by default) and its repeated draws.
1601
+ * A `main` clip also poses every selected layer without a clip of its own.
1601
1602
  * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
1602
1603
  */
1603
1604
  playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
1604
- /** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
1605
+ /** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
1605
1606
  playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void;
1606
1607
  /** Stops all clips and restores the poses from before playback. */
1607
1608
  stopAnimation(): void;
@@ -1189,7 +1189,7 @@ interface EntityAnimation {
1189
1189
  /** Seconds. */
1190
1190
  length: number;
1191
1191
  loop: boolean;
1192
- /** Geometry layer targeted by this clip; defaults to `main`. */
1192
+ /** Geometry layer targeted by this clip; defaults to `main`. A `main` clip also poses selected layers without their own clip. */
1193
1193
  layer?: string;
1194
1194
  /** Part name anywhere in a layer; `root` is the layer's root part. */
1195
1195
  bones: Record<string, EntityAnimationBone>;
@@ -1597,11 +1597,12 @@ declare class EntityObject extends SceneObject {
1597
1597
  get animationTime(): number;
1598
1598
  /**
1599
1599
  * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
1600
- * Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
1600
+ * Offsets apply to the baked pose in the clip's layer (`main` by default) and its repeated draws.
1601
+ * A `main` clip also poses every selected layer without a clip of its own.
1601
1602
  * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
1602
1603
  */
1603
1604
  playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
1604
- /** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
1605
+ /** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
1605
1606
  playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void;
1606
1607
  /** Stops all clips and restores the poses from before playback. */
1607
1608
  stopAnimation(): void;
@@ -5257,13 +5257,14 @@ var init_EntityObject = __esm({
5257
5257
  }
5258
5258
  /**
5259
5259
  * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
5260
- * Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
5260
+ * Offsets apply to the baked pose in the clip's layer (`main` by default) and its repeated draws.
5261
+ * A `main` clip also poses every selected layer without a clip of its own.
5261
5262
  * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
5262
5263
  */
5263
5264
  playAnimation(animation, options) {
5264
5265
  this.playAnimations([animation], options);
5265
5266
  }
5266
- /** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
5267
+ /** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
5267
5268
  playAnimations(animations, options) {
5268
5269
  const targets = /* @__PURE__ */ new Set();
5269
5270
  const selections = animations.map((animation) => {
@@ -5274,6 +5275,8 @@ var init_EntityObject = __esm({
5274
5275
  if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
5275
5276
  return { animation, names };
5276
5277
  });
5278
+ const main = selections.find(({ animation }) => (animation.layer ?? "main") === "main");
5279
+ if (main) main.names.push(...Object.keys(this.entityLayers).filter((name) => !targets.has(name.split("#")[0])));
5277
5280
  this.createMeshes();
5278
5281
  this.stopAnimation();
5279
5282
  for (const { animation, names } of selections) {
@@ -5333,24 +5336,26 @@ var init_EntityObject = __esm({
5333
5336
  createMeshes(force = false) {
5334
5337
  if (this.meshesCreated && !force) return;
5335
5338
  const modelRoot = new import_three14.Object3D();
5339
+ let transformNode = modelRoot;
5336
5340
  const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
5337
5341
  if (transform) {
5338
- for (const op of transform) {
5339
- const matrix = new import_three14.Matrix4();
5340
- if ("scale" in op) matrix.makeScale(...op.scale);
5341
- else if ("translate" in op) matrix.makeTranslation(...op.translate);
5342
- else matrix.makeRotationFromEuler(new import_three14.Euler(...op.rotate, "ZYX"));
5343
- modelRoot.matrix.multiply(matrix);
5342
+ for (const [index, op] of transform.entries()) {
5343
+ if (index > 0) {
5344
+ const child = new import_three14.Object3D();
5345
+ transformNode.add(child);
5346
+ transformNode = child;
5347
+ }
5348
+ if ("scale" in op) transformNode.scale.set(...op.scale);
5349
+ else if ("translate" in op) transformNode.position.set(...op.translate);
5350
+ else transformNode.rotation.set(...op.rotate, "ZYX");
5344
5351
  }
5345
- modelRoot.matrixWorldNeedsUpdate = true;
5346
- modelRoot.matrixAutoUpdate = false;
5347
5352
  } else if (this.options.flip ?? true) {
5348
5353
  modelRoot.scale.set(-1, -1, 1);
5349
5354
  }
5350
5355
  this.add(modelRoot);
5351
5356
  Object.entries(this.entityLayers).forEach(([name, layer], index) => {
5352
5357
  const group = this.createGroup(`layer:${name}`);
5353
- modelRoot.add(group);
5358
+ transformNode.add(group);
5354
5359
  const inward = !Materials.entityModeCulls(layer.render ?? layer.layer.render);
5355
5360
  this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward, this.options.faces?.[name]);
5356
5361
  });