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.
@@ -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;
@@ -3869,11 +3869,14 @@ var init_UVMapper = __esm({
3869
3869
  });
3870
3870
  }
3871
3871
  static fillMissingTextureKeys(textures, target) {
3872
- for (let faceName of CUBE_FACES) {
3873
- let v = textures[faceName];
3874
- if (v && v.startsWith("#")) {
3875
- target[faceName] = target[v.substr(1)];
3872
+ for (const key in textures) {
3873
+ let name = key;
3874
+ const seen = /* @__PURE__ */ new Set();
3875
+ while (textures[name]?.startsWith("#") && !seen.has(name)) {
3876
+ seen.add(name);
3877
+ name = textures[name].substr(1);
3876
3878
  }
3879
+ if (name !== key) target[key] = target[name];
3877
3880
  }
3878
3881
  return target;
3879
3882
  }
@@ -5254,13 +5257,14 @@ var init_EntityObject = __esm({
5254
5257
  }
5255
5258
  /**
5256
5259
  * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
5257
- * 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.
5258
5262
  * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
5259
5263
  */
5260
5264
  playAnimation(animation, options) {
5261
5265
  this.playAnimations([animation], options);
5262
5266
  }
5263
- /** 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`. */
5264
5268
  playAnimations(animations, options) {
5265
5269
  const targets = /* @__PURE__ */ new Set();
5266
5270
  const selections = animations.map((animation) => {
@@ -5271,6 +5275,8 @@ var init_EntityObject = __esm({
5271
5275
  if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
5272
5276
  return { animation, names };
5273
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])));
5274
5280
  this.createMeshes();
5275
5281
  this.stopAnimation();
5276
5282
  for (const { animation, names } of selections) {
@@ -5330,24 +5336,26 @@ var init_EntityObject = __esm({
5330
5336
  createMeshes(force = false) {
5331
5337
  if (this.meshesCreated && !force) return;
5332
5338
  const modelRoot = new import_three14.Object3D();
5339
+ let transformNode = modelRoot;
5333
5340
  const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
5334
5341
  if (transform) {
5335
- for (const op of transform) {
5336
- const matrix = new import_three14.Matrix4();
5337
- if ("scale" in op) matrix.makeScale(...op.scale);
5338
- else if ("translate" in op) matrix.makeTranslation(...op.translate);
5339
- else matrix.makeRotationFromEuler(new import_three14.Euler(...op.rotate, "ZYX"));
5340
- 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");
5341
5351
  }
5342
- modelRoot.matrixWorldNeedsUpdate = true;
5343
- modelRoot.matrixAutoUpdate = false;
5344
5352
  } else if (this.options.flip ?? true) {
5345
5353
  modelRoot.scale.set(-1, -1, 1);
5346
5354
  }
5347
5355
  this.add(modelRoot);
5348
5356
  Object.entries(this.entityLayers).forEach(([name, layer], index) => {
5349
5357
  const group = this.createGroup(`layer:${name}`);
5350
- modelRoot.add(group);
5358
+ transformNode.add(group);
5351
5359
  const inward = !Materials.entityModeCulls(layer.render ?? layer.layer.render);
5352
5360
  this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward, this.options.faces?.[name]);
5353
5361
  });