minerender 2.1.0-alpha.131 → 2.1.0-alpha.132

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.
@@ -1,16 +1,24 @@
1
1
  // src/entity/scene/EntityAnimationPlayer.ts
2
2
  import { Euler, Vector3 } from "three";
3
- import { sampleEntityAnimation } from "../EntityAnimation.mjs";
3
+ import { ENTITY_ANIMATION_CHANNELS, sampleEntityAnimation } from "../EntityAnimation.mjs";
4
4
  var ZERO = [0, 0, 0];
5
5
  var EntityAnimationPlayer = class {
6
6
  constructor() {
7
7
  this.parts = [];
8
+ this._animations = [];
9
+ this._weights = [];
10
+ this.loops = [];
8
11
  this._time = 0;
9
- this.loop = false;
10
12
  this.speed = 1;
11
13
  }
12
14
  get animation() {
13
- return this._animation;
15
+ return this._animations[0];
16
+ }
17
+ get animations() {
18
+ return this._animations.slice();
19
+ }
20
+ get weights() {
21
+ return this._weights.slice();
14
22
  }
15
23
  get time() {
16
24
  return this._time;
@@ -20,10 +28,20 @@ var EntityAnimationPlayer = class {
20
28
  * without them, the current pose is used. Stopping restores the pose from before playback.
21
29
  */
22
30
  play(layers, animation, options = {}, poses) {
31
+ this.playAnimations(layers, [animation], options, poses);
32
+ }
33
+ /**
34
+ * Starts clips on matching parts with a shared clock. Weighted offsets add to the supplied baked poses
35
+ * or, without poses, to each animated part's pose when playback starts.
36
+ */
37
+ playAnimations(layers, animations, options = {}, poses) {
38
+ const weights = validateAnimationWeights(options.weights ?? animations.map(() => 1), animations.length);
23
39
  this.stop();
24
- this._animation = animation;
40
+ this._animations = animations.slice();
41
+ this._weights = weights;
42
+ if (!animations.length) return;
25
43
  this._time = options.time ?? 0;
26
- this.loop = options.loop ?? animation.loop;
44
+ this.loops = animations.map((animation) => options.loop ?? animation.loop);
27
45
  this.speed = options.speed ?? 1;
28
46
  for (const layer of layers) {
29
47
  const objects = [];
@@ -32,7 +50,8 @@ var EntityAnimationPlayer = class {
32
50
  if (poses.has(object)) objects.push(object);
33
51
  });
34
52
  } else {
35
- for (const bone of Object.keys(animation.bones)) {
53
+ const bones = new Set(animations.flatMap((animation) => Object.keys(animation.bones)));
54
+ for (const bone of bones) {
36
55
  const object = layer.getObjectByName(`group:${bone}`);
37
56
  if (object) objects.push(object);
38
57
  }
@@ -56,7 +75,7 @@ var EntityAnimationPlayer = class {
56
75
  }
57
76
  /** Restores the poses from before playback. Returns whether an animation was active. */
58
77
  stop() {
59
- if (!this._animation) return false;
78
+ if (!this._animations.length) return false;
60
79
  for (const part of this.parts) {
61
80
  part.object.position.copy(part.position);
62
81
  part.object.rotation.copy(part.rotation);
@@ -68,12 +87,14 @@ var EntityAnimationPlayer = class {
68
87
  /** Forgets the animation without touching the parts, for parts that no longer exist. */
69
88
  clear() {
70
89
  this.parts = [];
71
- this._animation = void 0;
90
+ this._animations = [];
91
+ this._weights = [];
92
+ this.loops = [];
72
93
  this._time = 0;
73
94
  }
74
95
  /** Applies the pose at an absolute playback time. Returns `false` when no clip is active. */
75
96
  setTime(seconds) {
76
- if (!this._animation) return false;
97
+ if (!this._animations.length) return false;
77
98
  this._time = seconds;
78
99
  this.apply();
79
100
  return true;
@@ -82,8 +103,30 @@ var EntityAnimationPlayer = class {
82
103
  advance(deltaSeconds) {
83
104
  return this.setTime(this._time + deltaSeconds * this.speed);
84
105
  }
106
+ /** Changes weights in clip order and reapplies the current time without restarting playback. */
107
+ setWeights(weights) {
108
+ if (!this._animations.length) return false;
109
+ const validated = validateAnimationWeights(weights, this._animations.length);
110
+ this._weights = validated;
111
+ this.apply();
112
+ return true;
113
+ }
85
114
  apply() {
86
- const pose = sampleEntityAnimation(this._animation, this._time, this.loop);
115
+ const pose = /* @__PURE__ */ Object.create(null);
116
+ for (let i = 0; i < this._animations.length; i++) {
117
+ const weight = this._weights[i];
118
+ if (weight === 0) continue;
119
+ const sampled = sampleEntityAnimation(this._animations[i], this._time, this.loops[i]);
120
+ for (const [bone, channels] of Object.entries(sampled)) {
121
+ const blended = pose[bone] ?? (pose[bone] = {});
122
+ for (const channel of ENTITY_ANIMATION_CHANNELS) {
123
+ const value = channels[channel];
124
+ if (!value) continue;
125
+ const target = blended[channel] ?? (blended[channel] = [0, 0, 0]);
126
+ for (let axis = 0; axis < 3; axis++) target[axis] += value[axis] * weight;
127
+ }
128
+ }
129
+ }
87
130
  for (const part of this.parts) {
88
131
  const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone] ?? {};
89
132
  part.object.position.set(part.basePosition.x + position[0], part.basePosition.y + position[1], part.basePosition.z + position[2]);
@@ -92,7 +135,15 @@ var EntityAnimationPlayer = class {
92
135
  }
93
136
  }
94
137
  };
138
+ function validateAnimationWeights(weights, count) {
139
+ const values = Array.from(weights);
140
+ if (values.length !== count || values.some((weight) => !Number.isFinite(weight) || weight < 0)) {
141
+ throw new Error("Animation weights must match the clip count and contain only finite nonnegative numbers");
142
+ }
143
+ return values;
144
+ }
95
145
  export {
96
- EntityAnimationPlayer
146
+ EntityAnimationPlayer,
147
+ validateAnimationWeights
97
148
  };
98
149
  //# sourceMappingURL=EntityAnimationPlayer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/entity/scene/EntityAnimationPlayer.ts"],"sourcesContent":["import { Euler, Vector3 } from \"three\";\nimport type { Object3D } from \"three\";\nimport { EntityAnimation, sampleEntityAnimation } from \"../EntityAnimation\";\nimport type { EntityModelPart } from \"../EntityModel\";\n\n/** Playback settings passed to {@link EntityObject.playAnimation}, {@link EntityObject.playAnimations}, or {@link EntityAnimationPlayer.play}. */\nexport interface EntityAnimationOptions {\n /** Overrides the animation's own `loop` flag. */\n loop?: boolean;\n /** Playback rate applied to advanced time; defaults to 1. */\n speed?: number;\n /** Start time in seconds; defaults to 0. */\n time?: number;\n}\n\nconst ZERO: readonly number[] = [0, 0, 0];\n\ninterface AnimatedPart {\n bone: string;\n object: Object3D;\n position: Vector3;\n rotation: Euler;\n scale: Vector3;\n basePosition: Vector3;\n baseRotation: Euler;\n baseScale: Vector3;\n}\n\n/**\n * Poses part groups from a keyframe animation the way vanilla does: every update restores the\n * default pose of each animated part, then adds the sampled offsets to its position, Euler angles and scale.\n * It owns no timer; the owner advances it.\n */\nexport class EntityAnimationPlayer {\n\n private parts: AnimatedPart[] = [];\n private _animation?: EntityAnimation;\n private _time = 0;\n private loop = false;\n private speed = 1;\n\n get animation(): EntityAnimation | undefined {\n return this._animation;\n }\n\n get time(): number {\n return this._time;\n }\n\n /**\n * Starts an animation on matching named parts. Supplied baked poses are the baseline for offsets;\n * without them, the current pose is used. Stopping restores the pose from before playback.\n */\n play(layers: Object3D[], animation: EntityAnimation, options: EntityAnimationOptions = {},\n poses?: ReadonlyMap<Object3D, EntityModelPart[\"pose\"]>): void {\n this.stop();\n this._animation = animation;\n this._time = options.time ?? 0;\n this.loop = options.loop ?? animation.loop;\n this.speed = options.speed ?? 1;\n for (const layer of layers) {\n const objects: Object3D[] = [];\n if (poses) {\n layer.traverse(object => { if (poses.has(object)) objects.push(object); });\n } else {\n for (const bone of Object.keys(animation.bones)) {\n const object = layer.getObjectByName(`group:${bone}`);\n if (object) objects.push(object);\n }\n }\n for (const object of objects) {\n const bone = object.name.slice(\"group:\".length);\n const pose = poses?.get(object);\n this.parts.push({\n bone, object, position: object.position.clone(), rotation: object.rotation.clone(), scale: object.scale.clone(),\n basePosition: pose ? new Vector3(...pose.offset) : object.position.clone(),\n baseRotation: pose ? new Euler(...pose.rotation, \"ZYX\") : object.rotation.clone(),\n baseScale: pose ? new Vector3(...(pose.scale ?? [1, 1, 1])) : object.scale.clone()\n });\n }\n }\n this.apply();\n }\n\n /** Restores the poses from before playback. Returns whether an animation was active. */\n stop(): boolean {\n if (!this._animation) return false;\n for (const part of this.parts) {\n part.object.position.copy(part.position);\n part.object.rotation.copy(part.rotation);\n part.object.scale.copy(part.scale);\n }\n this.clear();\n return true;\n }\n\n /** Forgets the animation without touching the parts, for parts that no longer exist. */\n clear(): void {\n this.parts = [];\n this._animation = undefined;\n this._time = 0;\n }\n\n /** Applies the pose at an absolute playback time. Returns `false` when no clip is active. */\n setTime(seconds: number): boolean {\n if (!this._animation) return false;\n this._time = seconds;\n this.apply();\n return true;\n }\n\n /** Advances playback by elapsed seconds multiplied by the speed passed to {@link play}. */\n advance(deltaSeconds: number): boolean {\n return this.setTime(this._time + deltaSeconds * this.speed);\n }\n\n private apply(): void {\n const pose = sampleEntityAnimation(this._animation!, this._time, this.loop);\n for (const part of this.parts) {\n const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone] ?? {};\n part.object.position.set(part.basePosition.x + position[0], part.basePosition.y + position[1], part.basePosition.z + position[2]);\n // Vanilla adds to the Euler angles themselves, so the part keeps its rotation order.\n part.object.rotation.set(part.baseRotation.x + rotation[0], part.baseRotation.y + rotation[1], part.baseRotation.z + rotation[2], part.baseRotation.order);\n part.object.scale.set(part.baseScale.x + scale[0], part.baseScale.y + scale[1], part.baseScale.z + scale[2]);\n }\n }\n\n}\n"],"mappings":";AAAA,SAAS,OAAO,eAAe;AAE/B,SAA0B,6BAA6B;AAavD,IAAM,OAA0B,CAAC,GAAG,GAAG,CAAC;AAkBjC,IAAM,wBAAN,MAA4B;AAAA,EAA5B;AAEH,SAAQ,QAAwB,CAAC;AAEjC,SAAQ,QAAQ;AAChB,SAAQ,OAAO;AACf,SAAQ,QAAQ;AAAA;AAAA,EAEhB,IAAI,YAAyC;AACzC,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,OAAe;AACf,WAAO,KAAK;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,KAAK,QAAoB,WAA4B,UAAkC,CAAC,GACnF,OAA8D;AAC/D,SAAK,KAAK;AACV,SAAK,aAAa;AAClB,SAAK,QAAQ,QAAQ,QAAQ;AAC7B,SAAK,OAAO,QAAQ,QAAQ,UAAU;AACtC,SAAK,QAAQ,QAAQ,SAAS;AAC9B,eAAW,SAAS,QAAQ;AACxB,YAAM,UAAsB,CAAC;AAC7B,U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AAK,aAAa;AAClB,SAAK,QAAQ;AAAA,EACjB;AAAA;AAAA,EAGA,QAAQ,SAA0B;AAC9B,QAAI,CAAC,KAAK,WAAY,QAAO;AAC7B,SAAK,QAAQ;AACb,SAAK,MAAM;AACX,WAAO;AAAA,EACX;AAAA;AAAA,EAGA,QAAQ,cAA+B;AACnC,WAAO,KAAK,QAAQ,KAAK,QAAQ,eAAe,KAAK,KAAK;AAAA,EAC9D;AAAA,EAEQ,QAAc;AAClB,UAAM,OAAO,sBAAsB,KAAK,YAAa,KAAK,OAAO,KAAK,IAAI;AAC1E,eAAW,QAAQ,KAAK,OAAO;AAC3B,YAAM,EAAE,WAAW,MAAM,WAAW,MAAM,QAAQ,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC;AAC/E,WAAK,OAAO,SAAS,IAAI,KAAK,aAAa,IAAI,SAAS,CAAC,GAAG,KAAK,aAAa,IAAI,SAAS,CAAC,GAAG,KAAK,aAAa,IAAI,SAAS,CAAC,CAAC;AAEhI,WAAK,OAAO,SAAS,IAAI,KAAK,aAAa,IAAI,SAAS,CAAC,GAAG,KAAK,aAAa,IAAI,SAAS,CAAC,GAAG,KAAK,aAAa,IAAI,SAAS,CAAC,GAAG,KAAK,aAAa,KAAK;AACzJ,WAAK,OAAO,MAAM,IAAI,KAAK,UAAU,IAAI,MAAM,CAAC,GAAG,KAAK,UAAU,IAAI,MAAM,CAAC,GAAG,KAAK,UAAU,IAAI,MAAM,CAAC,CAAC;AAAA,IAC/G;AAAA,EACJ;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/entity/scene/EntityAnimationPlayer.ts"],"sourcesContent":["import { Euler, Vector3 } from \"three\";\nimport type { Object3D } from \"three\";\nimport { ENTITY_ANIMATION_CHANNELS, EntityAnimation, sampleEntityAnimation } from \"../EntityAnimation\";\nimport type { EntityAnimationPose } from \"../EntityAnimation\";\nimport type { EntityModelPart } from \"../EntityModel\";\n\n/** Playback settings passed to {@link EntityObject.playAnimation}, {@link EntityObject.playAnimations}, or {@link EntityAnimationPlayer.play}. */\nexport interface EntityAnimationOptions {\n /** Overrides the animation's own `loop` flag. */\n loop?: boolean;\n /** Playback rate applied to advanced time; defaults to 1. */\n speed?: number;\n /** Start time in seconds; defaults to 0. */\n time?: number;\n /** Nonnegative finite weights in clip order; defaults to 1 per clip. Offsets add without normalizing weights. */\n weights?: readonly number[];\n}\n\nconst ZERO: readonly number[] = [0, 0, 0];\n\ninterface AnimatedPart {\n bone: string;\n object: Object3D;\n position: Vector3;\n rotation: Euler;\n scale: Vector3;\n basePosition: Vector3;\n baseRotation: Euler;\n baseScale: Vector3;\n}\n\n/**\n * Poses part groups from keyframe animations: every update restores the default pose of each\n * animated part, then adds weighted sampled offsets to its position, Euler angles and scale.\n * It owns no timer; the owner advances it.\n */\nexport class EntityAnimationPlayer {\n\n private parts: AnimatedPart[] = [];\n private _animations: EntityAnimation[] = [];\n private _weights: number[] = [];\n private loops: boolean[] = [];\n private _time = 0;\n private speed = 1;\n\n get animation(): EntityAnimation | undefined {\n return this._animations[0];\n }\n\n get animations(): readonly EntityAnimation[] {\n return this._animations.slice();\n }\n\n get weights(): readonly number[] {\n return this._weights.slice();\n }\n\n get time(): number {\n return this._time;\n }\n\n /**\n * Starts an animation on matching named parts. Supplied baked poses are the baseline for offsets;\n * without them, the current pose is used. Stopping restores the pose from before playback.\n */\n play(layers: Object3D[], animation: EntityAnimation, options: EntityAnimationOptions = {},\n poses?: ReadonlyMap<Object3D, EntityModelPart[\"pose\"]>): void {\n this.playAnimations(layers, [animation], options, poses);\n }\n\n /**\n * Starts clips on matching parts with a shared clock. Weighted offsets add to the supplied baked poses\n * or, without poses, to each animated part's pose when playback starts.\n */\n playAnimations(layers: Object3D[], animations: readonly EntityAnimation[], options: EntityAnimationOptions = {},\n poses?: ReadonlyMap<Object3D, EntityModelPart[\"pose\"]>): void {\n const weights = validateAnimationWeights(options.weights ?? animations.map(() => 1), animations.length);\n this.stop();\n this._animations = animations.slice();\n this._weights = weights;\n if (!animations.length) return;\n this._time = options.time ?? 0;\n this.loops = animations.map(animation => options.loop ?? animation.loop);\n this.speed = options.speed ?? 1;\n for (const layer of layers) {\n const objects: Object3D[] = [];\n if (poses) {\n layer.traverse(object => { if (poses.has(object)) objects.push(object); });\n } else {\n const bones = new Set(animations.flatMap(animation => Object.keys(animation.bones)));\n for (const bone of bones) {\n const object = layer.getObjectByName(`group:${bone}`);\n if (object) objects.push(object);\n }\n }\n for (const object of objects) {\n const bone = object.name.slice(\"group:\".length);\n const pose = poses?.get(object);\n this.parts.push({\n bone, object, position: object.position.clone(), rotation: object.rotation.clone(), scale: object.scale.clone(),\n basePosition: pose ? new Vector3(...pose.offset) : object.position.clone(),\n baseRotation: pose ? new Euler(...pose.rotation, \"ZYX\") : object.rotation.clone(),\n baseScale: pose ? new Vector3(...(pose.scale ?? [1, 1, 1])) : object.scale.clone()\n });\n }\n }\n this.apply();\n }\n\n /** Restores the poses from before playback. Returns whether an animation was active. */\n stop(): boolean {\n if (!this._animations.length) return false;\n for (const part of this.parts) {\n part.object.position.copy(part.position);\n part.object.rotation.copy(part.rotation);\n part.object.scale.copy(part.scale);\n }\n this.clear();\n return true;\n }\n\n /** Forgets the animation without touching the parts, for parts that no longer exist. */\n clear(): void {\n this.parts = [];\n this._animations = [];\n this._weights = [];\n this.loops = [];\n this._time = 0;\n }\n\n /** Applies the pose at an absolute playback time. Returns `false` when no clip is active. */\n setTime(seconds: number): boolean {\n if (!this._animations.length) return false;\n this._time = seconds;\n this.apply();\n return true;\n }\n\n /** Advances playback by elapsed seconds multiplied by the speed passed to {@link play}. */\n advance(deltaSeconds: number): boolean {\n return this.setTime(this._time + deltaSeconds * this.speed);\n }\n\n /** Changes weights in clip order and reapplies the current time without restarting playback. */\n setWeights(weights: readonly number[]): boolean {\n if (!this._animations.length) return false;\n const validated = validateAnimationWeights(weights, this._animations.length);\n this._weights = validated;\n this.apply();\n return true;\n }\n\n private apply(): void {\n const pose: EntityAnimationPose = Object.create(null);\n for (let i = 0; i < this._animations.length; i++) {\n const weight = this._weights[i];\n if (weight === 0) continue;\n const sampled = sampleEntityAnimation(this._animations[i], this._time, this.loops[i]);\n for (const [bone, channels] of Object.entries(sampled)) {\n const blended = pose[bone] ??= {};\n for (const channel of ENTITY_ANIMATION_CHANNELS) {\n const value = channels[channel];\n if (!value) continue;\n const target = blended[channel] ??= [0, 0, 0];\n for (let axis = 0; axis < 3; axis++) target[axis] += value[axis] * weight;\n }\n }\n }\n for (const part of this.parts) {\n const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone] ?? {};\n part.object.position.set(part.basePosition.x + position[0], part.basePosition.y + position[1], part.basePosition.z + position[2]);\n // Vanilla adds to the Euler angles themselves, so the part keeps its rotation order.\n part.object.rotation.set(part.baseRotation.x + rotation[0], part.baseRotation.y + rotation[1], part.baseRotation.z + rotation[2], part.baseRotation.order);\n part.object.scale.set(part.baseScale.x + scale[0], part.baseScale.y + scale[1], part.baseScale.z + scale[2]);\n }\n }\n\n}\n\n/** @internal */\nexport function validateAnimationWeights(weights: readonly number[], count: number): number[] {\n const values = Array.from(weights);\n if (values.length !== count || values.some(weight => !Number.isFinite(weight) || weight < 0)) {\n throw new Error(\"Animation weights must match the clip count and contain only finite nonnegative numbers\");\n }\n return values;\n}\n"],"mappings":";AAAA,SAAS,OAAO,eAAe;AAE/B,SAAS,2BAA4C,6BAA6B;AAgBlF,IAAM,OAA0B,CAAC,GAAG,GAAG,CAAC;AAkBjC,IAAM,wBAAN,MAA4B;AAAA,EAA5B;AAEH,SAAQ,QAAwB,CAAC;AACjC,SAAQ,cAAiC,CAAC;AAC1C,SAAQ,WAAqB,CAAC;AAC9B,SAAQ,QAAmB,CAAC;AAC5B,SAAQ,QAAQ;AAChB,SAAQ,QAAQ;AAAA;AAAA,EAEhB,IAAI,YAAyC;AACzC,WAAO,KAAK,YAAY,CAAC;AAAA,EAC7B;AAAA,EAEA,IAAI,aAAyC;AACzC,WAAO,KAAK,YAAY,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GAAG,KAAK,UAAU,IAAI,MAAM,CAAC,CAAC;AAAA,IAC/G;AAAA,EACJ;AAEJ;AAGO,SAAS,yBAAyB,SAA4B,OAAyB;AAC1F,QAAM,SAAS,MAAM,KAAK,OAAO;AACjC,MAAI,OAAO,WAAW,SAAS,OAAO,KAAK,YAAU,CAAC,OAAO,SAAS,MAAM,KAAK,SAAS,CAAC,GAAG;AAC1F,UAAM,IAAI,MAAM,yFAAyF;AAAA,EAC7G;AACA,SAAO;AACX;","names":[]}
@@ -11,7 +11,7 @@ import { Materials } from "../../Materials.mjs";
11
11
  import { MinecraftCubeTexture } from "../../MinecraftCubeTexture.mjs";
12
12
  import { CUBE_FACES } from "../../CubeFace.mjs";
13
13
  import { isMesh } from "../../util/three.mjs";
14
- import { EntityAnimationPlayer } from "./EntityAnimationPlayer.mjs";
14
+ import { EntityAnimationPlayer, validateAnimationWeights } from "./EntityAnimationPlayer.mjs";
15
15
  var _EntityObject = class _EntityObject extends SceneObject {
16
16
  constructor(entity, options) {
17
17
  super();
@@ -49,7 +49,7 @@ var _EntityObject = class _EntityObject extends SceneObject {
49
49
  for (const geometry of this.geometries) geometry.dispose();
50
50
  this.geometries.clear();
51
51
  for (const dispose of this.disposeWireframes.splice(0)) dispose();
52
- for (const player of this.animationPlayers.splice(0)) player.clear();
52
+ for (const { player } of this.animationPlayers.splice(0)) player.clear();
53
53
  this.partPoses.clear();
54
54
  super.disposeAndRemoveAllChildren();
55
55
  }
@@ -84,15 +84,31 @@ var _EntityObject = class _EntityObject extends SceneObject {
84
84
  //<editor-fold desc="ANIMATION">
85
85
  /** The first active clip, until playback is stopped or the object is disposed. */
86
86
  get animation() {
87
- return this.animationPlayers[0]?.animation;
87
+ return this.animationPlayers[0]?.player.animation;
88
88
  }
89
- /** Clips playing together, each targeting a separate geometry layer. */
89
+ /** Clips playing together, in the order passed to {@link playAnimations}. */
90
90
  get activeAnimations() {
91
- return this.animationPlayers.map((player) => player.animation);
91
+ const animations = [];
92
+ for (const { player, indices } of this.animationPlayers) {
93
+ player.animations.forEach((animation, i) => {
94
+ animations[indices[i]] = animation;
95
+ });
96
+ }
97
+ return animations;
98
+ }
99
+ /** Weights of the active clips, in the same order as {@link activeAnimations}. */
100
+ get animationWeights() {
101
+ const weights = [];
102
+ for (const { player, indices } of this.animationPlayers) {
103
+ player.weights.forEach((weight, i) => {
104
+ weights[indices[i]] = weight;
105
+ });
106
+ }
107
+ return weights;
92
108
  }
93
109
  /** Seconds since the animation started, before looping. */
94
110
  get animationTime() {
95
- return this.animationPlayers[0]?.time ?? 0;
111
+ return this.animationPlayers[0]?.player.time ?? 0;
96
112
  }
97
113
  /**
98
114
  * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
@@ -103,42 +119,59 @@ var _EntityObject = class _EntityObject extends SceneObject {
103
119
  playAnimation(animation, options) {
104
120
  this.playAnimations([animation], options);
105
121
  }
106
- /** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
122
+ /**
123
+ * Plays clips with a shared clock, adding their weighted offsets within each geometry layer.
124
+ * Weights default to 1 and are not normalized. Selected layers without their own clip follow `main`.
125
+ */
107
126
  playAnimations(animations, options) {
108
- const targets = /* @__PURE__ */ new Set();
109
- const selections = animations.map((animation) => {
127
+ const weights = validateAnimationWeights(options?.weights ?? animations.map(() => 1), animations.length);
128
+ const selections = /* @__PURE__ */ new Map();
129
+ animations.forEach((animation, index) => {
110
130
  const layer = animation.layer ?? "main";
111
- if (targets.has(layer)) throw new Error(`Multiple animations target layer "${layer}"`);
112
- targets.add(layer);
113
131
  const names = Object.keys(this.entityLayers).filter((name) => name.split("#")[0] === layer);
114
132
  if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
115
- return { animation, names };
133
+ let selection = selections.get(layer);
134
+ if (!selection) selections.set(layer, selection = { animations: [], names, indices: [] });
135
+ selection.animations.push(animation);
136
+ selection.indices.push(index);
116
137
  });
117
- const main = selections.find(({ animation }) => (animation.layer ?? "main") === "main");
118
- if (main) main.names.push(...Object.keys(this.entityLayers).filter((name) => !targets.has(name.split("#")[0])));
138
+ const main = selections.get("main");
139
+ if (main) main.names.push(...Object.keys(this.entityLayers).filter((name) => !selections.has(name.split("#")[0])));
119
140
  this.createMeshes();
120
141
  this.stopAnimation();
121
- for (const { animation, names } of selections) {
142
+ for (const { animations: clips, names, indices } of selections.values()) {
122
143
  const player = new EntityAnimationPlayer();
123
- player.play(names.map((name) => this.getLayerGroup(name)), animation, options, this.partPoses);
124
- this.animationPlayers.push(player);
144
+ player.playAnimations(
145
+ names.map((name) => this.getLayerGroup(name)),
146
+ clips,
147
+ { ...options, weights: indices.map((index) => weights[index]) },
148
+ this.partPoses
149
+ );
150
+ this.animationPlayers.push({ player, indices });
125
151
  }
126
152
  this.notifyDirty();
127
153
  }
154
+ /** Changes weights in active clip order, notifying the scene without restarting the shared clock. Has no effect without an animation. */
155
+ setAnimationWeights(weights) {
156
+ if (!this.animationPlayers.length) return;
157
+ const values = validateAnimationWeights(weights, this.activeAnimations.length);
158
+ for (const { player, indices } of this.animationPlayers) player.setWeights(indices.map((index) => values[index]));
159
+ this.notifyDirty();
160
+ }
128
161
  /** Stops all clips and restores the poses from before playback. */
129
162
  stopAnimation() {
130
163
  const players = this.animationPlayers.splice(0);
131
- for (const player of players) player.stop();
164
+ for (const { player } of players) player.stop();
132
165
  if (players.length) this.notifyDirty();
133
166
  }
134
167
  /** Poses the object at an explicit time in seconds. Has no effect without an animation. */
135
168
  setAnimationTime(seconds) {
136
- for (const player of this.animationPlayers) player.setTime(seconds);
169
+ for (const { player } of this.animationPlayers) player.setTime(seconds);
137
170
  if (this.animationPlayers.length) this.notifyDirty();
138
171
  }
139
172
  /** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
140
173
  advanceAnimation(deltaSeconds) {
141
- for (const player of this.animationPlayers) player.advance(deltaSeconds);
174
+ for (const { player } of this.animationPlayers) player.advance(deltaSeconds);
142
175
  if (this.animationPlayers.length) this.notifyDirty();
143
176
  }
144
177
  //</editor-fold>
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/entity/scene/EntityObject.ts"],"sourcesContent":["import { SceneObject } from \"../../renderer/SceneObject\";\nimport { SceneObjectOptions } from \"../../renderer/SceneObjectOptions\";\nimport { Caching } from \"../../cache/Caching\";\nimport { merge } from \"../../util/_internal/merge\";\nimport { Color, Object3D } from \"three\";\nimport type { BufferGeometry, ColorRepresentation, Material, Mesh, MeshBasicMaterial } from \"three\";\nimport { Ticker } from \"../../Ticker\";\nimport { addWireframeToMesh } from \"../../util/model\";\nimport { ModelTextures } from \"../../assets/ModelTextures\";\nimport { AssetKey, isAssetKey } from \"../../assets/AssetKey\";\nimport { ExtractableImageData } from \"../../ExtractableImageData\";\nimport { Materials } from \"../../Materials\";\nimport { MinecraftCubeTexture } from \"../../MinecraftCubeTexture\";\nimport { CUBE_FACES, CubeFace } from \"../../CubeFace\";\nimport { EntityLayer, EntityModel, EntityModelPart } from \"../EntityModel\";\nimport type { DoubleArray } from \"../../model/Model\";\nimport type { Maybe } from \"../../util/util\";\nimport { isMesh } from \"../../util/three\";\nimport type { EntityAnimation } from \"../EntityAnimation\";\nimport { EntityAnimationOptions, EntityAnimationPlayer } from \"./EntityAnimationPlayer\";\n\n/** Renders selected entity layers as named part groups. Create it through {@link MineRenderScene.addEntity}. */\nexport class EntityObject extends SceneObject {\n\n public readonly isEntityObject: true = true;\n\n public static readonly DEFAULT_OPTIONS: EntityObjectOptions = merge({}, SceneObject.DEFAULT_OPTIONS);\n public readonly options: EntityObjectOptions;\n\n private meshesCreated: boolean = false;\n private readonly geometries = new Set<BufferGeometry>();\n private readonly disposeWireframes: (() => void)[] = [];\n /** Scrolling materials are owned: their texture offset follows this entity's age. */\n private readonly scrollMaterials: { material: Material, offset: { set(x: number, y: number): unknown }, speed: [number, number] }[] = [];\n private scrollTicker: Maybe<number>;\n /** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */\n public age: number = 0;\n private readonly animationPlayers: EntityAnimationPlayer[] = [];\n private readonly partPoses = new Map<Object3D, EntityModelPart[\"pose\"]>();\n\n constructor(readonly entity: EntityModel, options?: Partial<EntityObjectOptions>) {\n super();\n this.options = merge({}, EntityObject.DEFAULT_OPTIONS, options ?? {});\n this.addEventListener(\"added\", () => this.updateScrollSubscription());\n this.addEventListener(\"removed\", () => this.updateScrollSubscription());\n }\n\n /** An optional shared material replaces texture loading for every selected draw; its owner retains disposal. */\n async init(material?: Material): Promise<void> {\n this.createMeshes();\n if (material) {\n this.clearScrollMaterials();\n this.iterateAllMeshes(mesh => { mesh.material = material; });\n this.notifyDirty();\n } else await this.applyTextures();\n }\n\n dispose() {\n super.dispose();\n }\n\n public disposeAndRemoveAllChildren() {\n this.clearScrollMaterials();\n for (const geometry of this.geometries) geometry.dispose();\n this.geometries.clear();\n for (const dispose of this.disposeWireframes.splice(0)) dispose();\n // The animated part groups are removed with the children.\n for (const player of this.animationPlayers.splice(0)) player.clear();\n this.partPoses.clear();\n super.disposeAndRemoveAllChildren();\n }\n\n private clearScrollMaterials() {\n Ticker.remove(this.scrollTicker);\n this.scrollTicker = undefined;\n for (const { material } of this.scrollMaterials.splice(0)) {\n (material as { map?: { dispose(): void } }).map?.dispose();\n material.dispose();\n }\n }\n\n private updateScrollSubscription() {\n if (this.parent && this.scrollMaterials.length) {\n if (this.scrollTicker === undefined) {\n this.scrollTicker = Ticker.add(() => {\n this.age++;\n this.updateScroll();\n });\n }\n } else {\n Ticker.remove(this.scrollTicker);\n this.scrollTicker = undefined;\n }\n }\n\n /** Applies the entity age to the scrolling materials; the ticker calls this 20 times per second. */\n private updateScroll() {\n for (const { offset, speed } of this.scrollMaterials) {\n // Texture V points up here and down in vanilla.\n offset.set((this.age * speed[0]) % 1, 0 - (this.age * speed[1]) % 1);\n }\n this.notifyDirty();\n }\n\n //<editor-fold desc=\"ANIMATION\">\n\n /** The first active clip, until playback is stopped or the object is disposed. */\n public get animation(): Maybe<EntityAnimation> {\n return this.animationPlayers[0]?.animation;\n }\n\n /** Clips playing together, each targeting a separate geometry layer. */\n public get activeAnimations(): readonly EntityAnimation[] {\n return this.animationPlayers.map(player => player.animation!);\n }\n\n /** Seconds since the animation started, before looping. */\n public get animationTime(): number {\n return this.animationPlayers[0]?.time ?? 0;\n }\n\n /**\n * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.\n * Offsets apply to the baked pose in the clip's layer (`main` by default) and its repeated draws.\n * A `main` clip also poses every selected layer without a clip of its own.\n * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.\n */\n public playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void {\n this.playAnimations([animation], options);\n }\n\n /** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */\n public playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void {\n const targets = new Set<string>();\n const selections = animations.map(animation => {\n const layer = animation.layer ?? \"main\";\n if (targets.has(layer)) throw new Error(`Multiple animations target layer \"${layer}\"`);\n targets.add(layer);\n const names = Object.keys(this.entityLayers).filter(name => name.split(\"#\")[0] === layer);\n if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer \"${layer}\"`);\n return { animation, names };\n });\n const main = selections.find(({ animation }) => (animation.layer ?? \"main\") === \"main\");\n if (main) main.names.push(...Object.keys(this.entityLayers).filter(name => !targets.has(name.split(\"#\")[0])));\n this.createMeshes();\n this.stopAnimation();\n for (const { animation, names } of selections) {\n const player = new EntityAnimationPlayer();\n player.play(names.map(name => this.getLayerGroup(name)!), animation, options, this.partPoses);\n this.animationPlayers.push(player);\n }\n this.notifyDirty();\n }\n\n /** Stops all clips and restores the poses from before playback. */\n public stopAnimation(): void {\n const players = this.animationPlayers.splice(0);\n for (const player of players) player.stop();\n if (players.length) this.notifyDirty();\n }\n\n /** Poses the object at an explicit time in seconds. Has no effect without an animation. */\n public setAnimationTime(seconds: number): void {\n for (const player of this.animationPlayers) player.setTime(seconds);\n if (this.animationPlayers.length) this.notifyDirty();\n }\n\n /** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */\n public advanceAnimation(deltaSeconds: number): void {\n for (const player of this.animationPlayers) player.advance(deltaSeconds);\n if (this.animationPlayers.length) this.notifyDirty();\n }\n\n //</editor-fold>\n\n /** Finds a selected draw by its layer key, such as `main` or `main#2`, or returns `undefined`. */\n public getLayerGroup(name: string): Maybe<Object3D> {\n return super.getGroupByName(`layer:${name}`);\n }\n\n /** Finds a part name without `group:`. Supply `layerName` to restrict the search to one draw. */\n public getGroupByName(name: string, layerName?: string): Maybe<Object3D> {\n return layerName === undefined ? super.getGroupByName(name)\n : this.getLayerGroup(layerName)?.getObjectByName(`group:${name}`);\n }\n\n /** Finds a mesh name without `mesh:`. Supply `layerName` to restrict the search to one draw. */\n public getMeshByName(name: string, layerName?: string): Maybe<Mesh> {\n return layerName === undefined ? super.getMeshByName(name)\n : this.getLayerGroup(layerName)?.getObjectByName(`mesh:${name}`) as Maybe<Mesh>;\n }\n\n private get entityLayers(): Record<string, EntityLayer> {\n return this.entity.layers ?? { main: this.entity };\n }\n\n private getTextureKey(layer: EntityLayer): AssetKey {\n if (layer.texture) return layer.texture;\n const key = layer.key;\n return new AssetKey(\n key.namespace,\n isAssetKey(key) ? key.getFullPath() : key.path,\n \"textures\",\n \"entity\",\n \"assets\",\n \".png\"\n );\n }\n\n protected async loadTextures(layer: EntityLayer = this.entity): Promise<Maybe<ExtractableImageData>> {\n return ModelTextures.get(this.getTextureKey(layer));\n }\n\n protected createMeshes(force: boolean = false) {\n if (this.meshesCreated && !force) return;\n\n const modelRoot = new Object3D();\n let transformNode = modelRoot;\n // Keep Minecraft's model coordinates separate from caller placement and scale.\n const transform = this.options.flip === undefined ? this.entity.transform : undefined;\n if (transform) {\n // One position, rotation and scale cannot express nonuniform scale followed by rotation.\n // Nested nodes preserve each operation and avoid manual matrices, which leave bounds stale.\n for (const [index, op] of transform.entries()) {\n if (index > 0) {\n const child = new Object3D();\n transformNode.add(child);\n transformNode = child;\n }\n if (\"scale\" in op) transformNode.scale.set(...op.scale);\n else if (\"translate\" in op) transformNode.position.set(...op.translate);\n else transformNode.rotation.set(...op.rotate, \"ZYX\");\n }\n } else if (this.options.flip ?? true) {\n modelRoot.scale.set(-1, -1, 1);\n }\n this.add(modelRoot);\n Object.entries(this.entityLayers).forEach(([name, layer], index) => {\n const group = this.createGroup(`layer:${name}`);\n transformNode.add(group);\n const inward = !Materials.entityModeCulls(layer.render ?? layer.layer.render);\n this.createPart(\"root\", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward, this.options.faces?.[name]);\n });\n this.meshesCreated = true;\n }\n\n private createPart(name: string, part: EntityModelPart, parent: Object3D, textureSize: DoubleArray, material: Material, renderOrder: number, inward: boolean = true, faces?: CubeFace[]) {\n const anchor = this.createGroup(name);\n anchor.position.fromArray(part.pose.offset);\n anchor.rotation.set(...part.pose.rotation, \"ZYX\");\n anchor.scale.fromArray(part.pose.scale ?? [1, 1, 1]);\n this.partPoses.set(anchor, part.pose);\n parent.add(anchor);\n const size = part.texture ?? textureSize;\n\n for (const cube of part.cubes) {\n const [width, height, depth] = cube.size;\n const [growX, growY, growZ] = cube.grow ?? [0, 0, 0];\n const texture = new MinecraftCubeTexture(...cube.uv, ...size);\n const uv = size[0] === 0 || size[1] === 0 ? new Array<number>(48).fill(0) : texture.toUvArray(width, height, depth, cube.mirror);\n const geometry = this._getBoxGeometryForDimensionsAndUv(\n width + growX * 2, height + growY * 2, depth + growZ * 2, uv\n ).clone();\n this.geometries.add(geometry);\n geometry.translate(cube.origin[0] + width / 2, cube.origin[1] + height / 2, cube.origin[2] + depth / 2);\n if (faces) {\n geometry.setIndex(Array.from(geometry.getIndex()!.array).filter((_, index) => faces.includes(CUBE_FACES[Math.floor(index / 6)])));\n geometry.clearGroups();\n }\n // Vanilla draws most entity render types without backface culling, e.g. chicken legs are only painted on faces seen from inside.\n // Zero-thickness cubes keep one face per side, as their coplanar faces would z-fight.\n if (inward && Math.min(width + growX * 2, height + growY * 2, depth + growZ * 2) > 0) {\n const index = Array.from(geometry.getIndex()!.array);\n geometry.setIndex(index.concat(index.slice().reverse()));\n }\n const mesh = this.createMesh(name, geometry, material);\n mesh.renderOrder = renderOrder;\n anchor.add(mesh);\n if (this.options.wireframe) this.disposeWireframes.push(addWireframeToMesh(geometry, mesh));\n }\n for (const [childName, child] of Object.entries(part.children)) {\n this.createPart(childName, child, anchor, size, material, renderOrder, inward, faces);\n }\n }\n\n protected async applyTextures() {\n this.clearScrollMaterials();\n const results = await Promise.allSettled(Object.entries(this.entityLayers).map(async ([name, layer]) => {\n const mode = layer.render ?? layer.layer.render ?? \"cutout\";\n const tint = layer.tint === undefined ? undefined : this.options.tints?.[layer.tint];\n const scroll = Materials.entityModeScroll(mode);\n const assetKeyStr = this.getTextureKey(layer).serialize();\n const keyStr = `entity:${ mode }:${ tint === undefined ? \"\" : new Color(tint).getHexString() }:${ assetKeyStr }`;\n let mat = scroll ? undefined : Caching.materialCache.getIfPresent(keyStr);\n if (!mat) {\n const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);\n const imageData = await this.loadTextures(layer);\n if (!imageData) return;\n const canvas = (imageData.data as CanvasRenderingContext2D).canvas;\n const createMaterial = () => Materials.createEntityCanvasMaterial(canvas, mode, tint);\n // A cache clear during decoding must not restore an older source's material.\n // Scrolling materials stay out of the cache, as their texture offset belongs to this entity.\n mat = !scroll && cachedAsset && Caching.textureAssetCache.getIfPresent(assetKeyStr) === cachedAsset\n ? Caching.materialCache.get(keyStr, createMaterial)\n : createMaterial();\n if (scroll) {\n this.scrollMaterials.push({ material: mat!, offset: (mat as MeshBasicMaterial).map!.offset, speed: scroll });\n }\n }\n this.getLayerGroup(name)?.traverse(object => {\n if (isMesh(object)) object.material = mat!;\n });\n }));\n if (!this.children.length) {\n // Disposed while the textures were loading: nothing is left to scroll.\n this.clearScrollMaterials();\n } else if (this.scrollMaterials.length) {\n this.updateScroll();\n }\n this.updateScrollSubscription();\n this.notifyDirty();\n const failure = results.find(result => result.status === \"rejected\");\n if (failure?.status === \"rejected\") throw failure.reason;\n }\n\n\n}\n\n/** Render settings passed to `scene.addEntity(entity, options)` or the EntityObject constructor. */\nexport interface EntityObjectOptions extends SceneObjectOptions {\n /**\n * `true` applies only vanilla's entity flip, scale (-1, -1, 1); `false` keeps raw model space.\n * By default the model's dataset transform is used, or the flip for models without one.\n */\n flip?: boolean;\n /** Colours for the dataset's tint labels, e.g. `{ wool_color: 0xf9801d }`; a pass whose label is absent stays untinted. */\n tints?: Record<string, ColorRepresentation>;\n /** Cube faces by layer key; omitted layers draw all six faces. */\n faces?: Record<string, CubeFace[]>;\n}\n\nexport function isEntityObject(obj: any): obj is EntityObject {\n return (<EntityObject>obj).isEntityObject;\n}\n"],"mappings":";AAAA,SAAS,mBAAmB;AAE5B,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,OAAO,gBAAgB;AAEhC,SAAS,cAAc;AACvB,SAAS,0BAA0B;AACnC,SAAS,qBAAqB;AAC9B,SAAS,UAAU,kBAAkB;AAErC,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,kBAA4B;AAIrC,SAAS,cAAc;AAEvB,SAAiC,6BAA6B;AAGvD,IAAM,gBAAN,MAAM,sBAAqB,YAAY;AAAA,EAkB1C,YAAqB,QAAqB,SAAwC;AAC9E,UAAM;AADW;AAhBrB,SAAgB,iBAAuB;AAKvC,SAAQ,gBAAyB;AACjC,SAAiB,aAAa,oBAAI,IAAoB;AACtD,SAAiB,oBAAoC,CAAC;AAEtD;AAAA,SAAiB,kBAAqH,CAAC;AAGvI;AAAA,SAAO,MAAc;AACrB,SAAiB,mBAA4C,CAAC;AAC9D,SAAiB,YAAY,oBAAI,IAAuC;AAIpE,SAAK,UAAU,MAAM,CAAC,GAAG,cAAa,iBAAiB,WAAW,CAAC,CAAC;AACpE,SAAK,iBAAiB,SAAS,MAAM,KAAK,yBAAyB,CAAC;AACpE,SA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CAAE,IAAK,WAAY;AAC9G,UAAI,MAAM,SAAS,SAAY,QAAQ,cAAc,aAAa,MAAM;AACxE,UAAI,CAAC,KAAK;AACN,cAAM,cAAc,QAAQ,kBAAkB,aAAa,WAAW;AACtE,cAAM,YAAY,MAAM,KAAK,aAAa,KAAK;AAC/C,YAAI,CAAC,UAAW;AAChB,cAAM,SAAU,UAAU,KAAkC;AAC5D,cAAM,iBAAiB,MAAM,UAAU,2BAA2B,QAAQ,MAAM,IAAI;AAGpF,cAAM,CAAC,UAAU,eAAe,QAAQ,kBAAkB,aAAa,WAAW,MAAM,cAClF,QAAQ,cAAc,IAAI,QAAQ,cAAc,IAChD,eAAe;AACrB,YAAI,QAAQ;AACR,eAAK,gBAAgB,KAAK,EAAE,UAAU,KAAM,QAAS,IAA0B,IAAK,QAAQ,OAAO,OAAO,CAAC;AAAA,QAC/G;AAAA,MACJ;AACA,WAAK,cAAc,IAAI,GAAG,SAAS,YAAU;AACzC,YAAI,OAAO,MAAM,EAAG,QAAO,WAAW;AAAA,MAC1C,CAAC;AAAA,IACL,CAAC,CAAC;AACF,QAAI,CAAC,KAAK,SAAS,QAAQ;AAEvB,WAAK,qBAAqB;AAAA,IAC9B,WAAW,KAAK,gBAAgB,QAAQ;AACpC,WAAK,aAAa;AAAA,IACtB;AACA,SAAK,yBAAyB;AAC9B,SAAK,YAAY;AACjB,UAAM,UAAU,QAAQ,KAAK,YAAU,OAAO,WAAW,UAAU;AACnE,QAAI,SAAS,WAAW,WAAY,OAAM,QAAQ;AAAA,EACtD;AAGJ;AAhTa,cAIc,kBAAuC,MAAM,CAAC,GAAG,YAAY,eAAe;AAJhG,IAAM,eAAN;AA+TA,SAAS,eAAe,KAA+B;AAC1D,SAAsB,IAAK;AAC/B;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/entity/scene/EntityObject.ts"],"sourcesContent":["import { SceneObject } from \"../../renderer/SceneObject\";\nimport { SceneObjectOptions } from \"../../renderer/SceneObjectOptions\";\nimport { Caching } from \"../../cache/Caching\";\nimport { merge } from \"../../util/_internal/merge\";\nimport { Color, Object3D } from \"three\";\nimport type { BufferGeometry, ColorRepresentation, Material, Mesh, MeshBasicMaterial } from \"three\";\nimport { Ticker } from \"../../Ticker\";\nimport { addWireframeToMesh } from \"../../util/model\";\nimport { ModelTextures } from \"../../assets/ModelTextures\";\nimport { AssetKey, isAssetKey } from \"../../assets/AssetKey\";\nimport { ExtractableImageData } from \"../../ExtractableImageData\";\nimport { Materials } from \"../../Materials\";\nimport { MinecraftCubeTexture } from \"../../MinecraftCubeTexture\";\nimport { CUBE_FACES, CubeFace } from \"../../CubeFace\";\nimport { EntityLayer, EntityModel, EntityModelPart } from \"../EntityModel\";\nimport type { DoubleArray } from \"../../model/Model\";\nimport type { Maybe } from \"../../util/util\";\nimport { isMesh } from \"../../util/three\";\nimport type { EntityAnimation } from \"../EntityAnimation\";\nimport { EntityAnimationOptions, EntityAnimationPlayer, validateAnimationWeights } from \"./EntityAnimationPlayer\";\n\n/** Renders selected entity layers as named part groups. Create it through {@link MineRenderScene.addEntity}. */\nexport class EntityObject extends SceneObject {\n\n public readonly isEntityObject: true = true;\n\n public static readonly DEFAULT_OPTIONS: EntityObjectOptions = merge({}, SceneObject.DEFAULT_OPTIONS);\n public readonly options: EntityObjectOptions;\n\n private meshesCreated: boolean = false;\n private readonly geometries = new Set<BufferGeometry>();\n private readonly disposeWireframes: (() => void)[] = [];\n /** Scrolling materials are owned: their texture offset follows this entity's age. */\n private readonly scrollMaterials: { material: Material, offset: { set(x: number, y: number): unknown }, speed: [number, number] }[] = [];\n private scrollTicker: Maybe<number>;\n /** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */\n public age: number = 0;\n private readonly animationPlayers: { player: EntityAnimationPlayer, indices: number[] }[] = [];\n private readonly partPoses = new Map<Object3D, EntityModelPart[\"pose\"]>();\n\n constructor(readonly entity: EntityModel, options?: Partial<EntityObjectOptions>) {\n super();\n this.options = merge({}, EntityObject.DEFAULT_OPTIONS, options ?? {});\n this.addEventListener(\"added\", () => this.updateScrollSubscription());\n this.addEventListener(\"removed\", () => this.updateScrollSubscription());\n }\n\n /** An optional shared material replaces texture loading for every selected draw; its owner retains disposal. */\n async init(material?: Material): Promise<void> {\n this.createMeshes();\n if (material) {\n this.clearScrollMaterials();\n this.iterateAllMeshes(mesh => { mesh.material = material; });\n this.notifyDirty();\n } else await this.applyTextures();\n }\n\n dispose() {\n super.dispose();\n }\n\n public disposeAndRemoveAllChildren() {\n this.clearScrollMaterials();\n for (const geometry of this.geometries) geometry.dispose();\n this.geometries.clear();\n for (const dispose of this.disposeWireframes.splice(0)) dispose();\n // The animated part groups are removed with the children.\n for (const { player } of this.animationPlayers.splice(0)) player.clear();\n this.partPoses.clear();\n super.disposeAndRemoveAllChildren();\n }\n\n private clearScrollMaterials() {\n Ticker.remove(this.scrollTicker);\n this.scrollTicker = undefined;\n for (const { material } of this.scrollMaterials.splice(0)) {\n (material as { map?: { dispose(): void } }).map?.dispose();\n material.dispose();\n }\n }\n\n private updateScrollSubscription() {\n if (this.parent && this.scrollMaterials.length) {\n if (this.scrollTicker === undefined) {\n this.scrollTicker = Ticker.add(() => {\n this.age++;\n this.updateScroll();\n });\n }\n } else {\n Ticker.remove(this.scrollTicker);\n this.scrollTicker = undefined;\n }\n }\n\n /** Applies the entity age to the scrolling materials; the ticker calls this 20 times per second. */\n private updateScroll() {\n for (const { offset, speed } of this.scrollMaterials) {\n // Texture V points up here and down in vanilla.\n offset.set((this.age * speed[0]) % 1, 0 - (this.age * speed[1]) % 1);\n }\n this.notifyDirty();\n }\n\n //<editor-fold desc=\"ANIMATION\">\n\n /** The first active clip, until playback is stopped or the object is disposed. */\n public get animation(): Maybe<EntityAnimation> {\n return this.animationPlayers[0]?.player.animation;\n }\n\n /** Clips playing together, in the order passed to {@link playAnimations}. */\n public get activeAnimations(): readonly EntityAnimation[] {\n const animations: EntityAnimation[] = [];\n for (const { player, indices } of this.animationPlayers) {\n player.animations.forEach((animation, i) => { animations[indices[i]] = animation; });\n }\n return animations;\n }\n\n /** Weights of the active clips, in the same order as {@link activeAnimations}. */\n public get animationWeights(): readonly number[] {\n const weights: number[] = [];\n for (const { player, indices } of this.animationPlayers) {\n player.weights.forEach((weight, i) => { weights[indices[i]] = weight; });\n }\n return weights;\n }\n\n /** Seconds since the animation started, before looping. */\n public get animationTime(): number {\n return this.animationPlayers[0]?.player.time ?? 0;\n }\n\n /**\n * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.\n * Offsets apply to the baked pose in the clip's layer (`main` by default) and its repeated draws.\n * A `main` clip also poses every selected layer without a clip of its own.\n * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.\n */\n public playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void {\n this.playAnimations([animation], options);\n }\n\n /**\n * Plays clips with a shared clock, adding their weighted offsets within each geometry layer.\n * Weights default to 1 and are not normalized. Selected layers without their own clip follow `main`.\n */\n public playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void {\n const weights = validateAnimationWeights(options?.weights ?? animations.map(() => 1), animations.length);\n const selections = new Map<string, { animations: EntityAnimation[], names: string[], indices: number[] }>();\n animations.forEach((animation, index) => {\n const layer = animation.layer ?? \"main\";\n const names = Object.keys(this.entityLayers).filter(name => name.split(\"#\")[0] === layer);\n if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer \"${layer}\"`);\n let selection = selections.get(layer);\n if (!selection) selections.set(layer, selection = { animations: [], names, indices: [] });\n selection.animations.push(animation);\n selection.indices.push(index);\n });\n const main = selections.get(\"main\");\n if (main) main.names.push(...Object.keys(this.entityLayers).filter(name => !selections.has(name.split(\"#\")[0])));\n this.createMeshes();\n this.stopAnimation();\n for (const { animations: clips, names, indices } of selections.values()) {\n const player = new EntityAnimationPlayer();\n player.playAnimations(names.map(name => this.getLayerGroup(name)!), clips,\n { ...options, weights: indices.map(index => weights[index]) }, this.partPoses);\n this.animationPlayers.push({ player, indices });\n }\n this.notifyDirty();\n }\n\n /** Changes weights in active clip order, notifying the scene without restarting the shared clock. Has no effect without an animation. */\n public setAnimationWeights(weights: readonly number[]): void {\n if (!this.animationPlayers.length) return;\n const values = validateAnimationWeights(weights, this.activeAnimations.length);\n for (const { player, indices } of this.animationPlayers) player.setWeights(indices.map(index => values[index]));\n this.notifyDirty();\n }\n\n /** Stops all clips and restores the poses from before playback. */\n public stopAnimation(): void {\n const players = this.animationPlayers.splice(0);\n for (const { player } of players) player.stop();\n if (players.length) this.notifyDirty();\n }\n\n /** Poses the object at an explicit time in seconds. Has no effect without an animation. */\n public setAnimationTime(seconds: number): void {\n for (const { player } of this.animationPlayers) player.setTime(seconds);\n if (this.animationPlayers.length) this.notifyDirty();\n }\n\n /** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */\n public advanceAnimation(deltaSeconds: number): void {\n for (const { player } of this.animationPlayers) player.advance(deltaSeconds);\n if (this.animationPlayers.length) this.notifyDirty();\n }\n\n //</editor-fold>\n\n /** Finds a selected draw by its layer key, such as `main` or `main#2`, or returns `undefined`. */\n public getLayerGroup(name: string): Maybe<Object3D> {\n return super.getGroupByName(`layer:${name}`);\n }\n\n /** Finds a part name without `group:`. Supply `layerName` to restrict the search to one draw. */\n public getGroupByName(name: string, layerName?: string): Maybe<Object3D> {\n return layerName === undefined ? super.getGroupByName(name)\n : this.getLayerGroup(layerName)?.getObjectByName(`group:${name}`);\n }\n\n /** Finds a mesh name without `mesh:`. Supply `layerName` to restrict the search to one draw. */\n public getMeshByName(name: string, layerName?: string): Maybe<Mesh> {\n return layerName === undefined ? super.getMeshByName(name)\n : this.getLayerGroup(layerName)?.getObjectByName(`mesh:${name}`) as Maybe<Mesh>;\n }\n\n private get entityLayers(): Record<string, EntityLayer> {\n return this.entity.layers ?? { main: this.entity };\n }\n\n private getTextureKey(layer: EntityLayer): AssetKey {\n if (layer.texture) return layer.texture;\n const key = layer.key;\n return new AssetKey(\n key.namespace,\n isAssetKey(key) ? key.getFullPath() : key.path,\n \"textures\",\n \"entity\",\n \"assets\",\n \".png\"\n );\n }\n\n protected async loadTextures(layer: EntityLayer = this.entity): Promise<Maybe<ExtractableImageData>> {\n return ModelTextures.get(this.getTextureKey(layer));\n }\n\n protected createMeshes(force: boolean = false) {\n if (this.meshesCreated && !force) return;\n\n const modelRoot = new Object3D();\n let transformNode = modelRoot;\n // Keep Minecraft's model coordinates separate from caller placement and scale.\n const transform = this.options.flip === undefined ? this.entity.transform : undefined;\n if (transform) {\n // One position, rotation and scale cannot express nonuniform scale followed by rotation.\n // Nested nodes preserve each operation and avoid manual matrices, which leave bounds stale.\n for (const [index, op] of transform.entries()) {\n if (index > 0) {\n const child = new Object3D();\n transformNode.add(child);\n transformNode = child;\n }\n if (\"scale\" in op) transformNode.scale.set(...op.scale);\n else if (\"translate\" in op) transformNode.position.set(...op.translate);\n else transformNode.rotation.set(...op.rotate, \"ZYX\");\n }\n } else if (this.options.flip ?? true) {\n modelRoot.scale.set(-1, -1, 1);\n }\n this.add(modelRoot);\n Object.entries(this.entityLayers).forEach(([name, layer], index) => {\n const group = this.createGroup(`layer:${name}`);\n transformNode.add(group);\n const inward = !Materials.entityModeCulls(layer.render ?? layer.layer.render);\n this.createPart(\"root\", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward, this.options.faces?.[name]);\n });\n this.meshesCreated = true;\n }\n\n private createPart(name: string, part: EntityModelPart, parent: Object3D, textureSize: DoubleArray, material: Material, renderOrder: number, inward: boolean = true, faces?: CubeFace[]) {\n const anchor = this.createGroup(name);\n anchor.position.fromArray(part.pose.offset);\n anchor.rotation.set(...part.pose.rotation, \"ZYX\");\n anchor.scale.fromArray(part.pose.scale ?? [1, 1, 1]);\n this.partPoses.set(anchor, part.pose);\n parent.add(anchor);\n const size = part.texture ?? textureSize;\n\n for (const cube of part.cubes) {\n const [width, height, depth] = cube.size;\n const [growX, growY, growZ] = cube.grow ?? [0, 0, 0];\n const texture = new MinecraftCubeTexture(...cube.uv, ...size);\n const uv = size[0] === 0 || size[1] === 0 ? new Array<number>(48).fill(0) : texture.toUvArray(width, height, depth, cube.mirror);\n const geometry = this._getBoxGeometryForDimensionsAndUv(\n width + growX * 2, height + growY * 2, depth + growZ * 2, uv\n ).clone();\n this.geometries.add(geometry);\n geometry.translate(cube.origin[0] + width / 2, cube.origin[1] + height / 2, cube.origin[2] + depth / 2);\n if (faces) {\n geometry.setIndex(Array.from(geometry.getIndex()!.array).filter((_, index) => faces.includes(CUBE_FACES[Math.floor(index / 6)])));\n geometry.clearGroups();\n }\n // Vanilla draws most entity render types without backface culling, e.g. chicken legs are only painted on faces seen from inside.\n // Zero-thickness cubes keep one face per side, as their coplanar faces would z-fight.\n if (inward && Math.min(width + growX * 2, height + growY * 2, depth + growZ * 2) > 0) {\n const index = Array.from(geometry.getIndex()!.array);\n geometry.setIndex(index.concat(index.slice().reverse()));\n }\n const mesh = this.createMesh(name, geometry, material);\n mesh.renderOrder = renderOrder;\n anchor.add(mesh);\n if (this.options.wireframe) this.disposeWireframes.push(addWireframeToMesh(geometry, mesh));\n }\n for (const [childName, child] of Object.entries(part.children)) {\n this.createPart(childName, child, anchor, size, material, renderOrder, inward, faces);\n }\n }\n\n protected async applyTextures() {\n this.clearScrollMaterials();\n const results = await Promise.allSettled(Object.entries(this.entityLayers).map(async ([name, layer]) => {\n const mode = layer.render ?? layer.layer.render ?? \"cutout\";\n const tint = layer.tint === undefined ? undefined : this.options.tints?.[layer.tint];\n const scroll = Materials.entityModeScroll(mode);\n const assetKeyStr = this.getTextureKey(layer).serialize();\n const keyStr = `entity:${ mode }:${ tint === undefined ? \"\" : new Color(tint).getHexString() }:${ assetKeyStr }`;\n let mat = scroll ? undefined : Caching.materialCache.getIfPresent(keyStr);\n if (!mat) {\n const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);\n const imageData = await this.loadTextures(layer);\n if (!imageData) return;\n const canvas = (imageData.data as CanvasRenderingContext2D).canvas;\n const createMaterial = () => Materials.createEntityCanvasMaterial(canvas, mode, tint);\n // A cache clear during decoding must not restore an older source's material.\n // Scrolling materials stay out of the cache, as their texture offset belongs to this entity.\n mat = !scroll && cachedAsset && Caching.textureAssetCache.getIfPresent(assetKeyStr) === cachedAsset\n ? Caching.materialCache.get(keyStr, createMaterial)\n : createMaterial();\n if (scroll) {\n this.scrollMaterials.push({ material: mat!, offset: (mat as MeshBasicMaterial).map!.offset, speed: scroll });\n }\n }\n this.getLayerGroup(name)?.traverse(object => {\n if (isMesh(object)) object.material = mat!;\n });\n }));\n if (!this.children.length) {\n // Disposed while the textures were loading: nothing is left to scroll.\n this.clearScrollMaterials();\n } else if (this.scrollMaterials.length) {\n this.updateScroll();\n }\n this.updateScrollSubscription();\n this.notifyDirty();\n const failure = results.find(result => result.status === \"rejected\");\n if (failure?.status === \"rejected\") throw failure.reason;\n }\n\n\n}\n\n/** Render settings passed to `scene.addEntity(entity, options)` or the EntityObject constructor. */\nexport interface EntityObjectOptions extends SceneObjectOptions {\n /**\n * `true` applies only vanilla's entity flip, scale (-1, -1, 1); `false` keeps raw model space.\n * By default the model's dataset transform is used, or the flip for models without one.\n */\n flip?: boolean;\n /** Colours for the dataset's tint labels, e.g. `{ wool_color: 0xf9801d }`; a pass whose label is absent stays untinted. */\n tints?: Record<string, ColorRepresentation>;\n /** Cube faces by layer key; omitted layers draw all six faces. */\n faces?: Record<string, CubeFace[]>;\n}\n\nexport function isEntityObject(obj: any): obj is EntityObject {\n return (<EntityObject>obj).isEntityObject;\n}\n"],"mappings":";AAAA,SAAS,mBAAmB;AAE5B,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,OAAO,gBAAgB;AAEhC,SAAS,cAAc;AACvB,SAAS,0BAA0B;AACnC,SAAS,qBAAqB;AAC9B,SAAS,UAAU,kBAAkB;AAErC,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,kBAA4B;AAIrC,SAAS,cAAc;AAEvB,SAAiC,uBAAuB,gCA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YAAY,eAAe;AAJhG,IAAM,eAAN;AA0VA,SAAS,eAAe,KAA+B;AAC1D,SAAsB,IAAK;AAC/B;","names":[]}
@@ -1576,25 +1576,35 @@ interface EntityAnimationOptions {
1576
1576
  speed?: number;
1577
1577
  /** Start time in seconds; defaults to 0. */
1578
1578
  time?: number;
1579
+ /** Nonnegative finite weights in clip order; defaults to 1 per clip. Offsets add without normalizing weights. */
1580
+ weights?: readonly number[];
1579
1581
  }
1580
1582
  /**
1581
- * Poses part groups from a keyframe animation the way vanilla does: every update restores the
1582
- * default pose of each animated part, then adds the sampled offsets to its position, Euler angles and scale.
1583
+ * Poses part groups from keyframe animations: every update restores the default pose of each
1584
+ * animated part, then adds weighted sampled offsets to its position, Euler angles and scale.
1583
1585
  * It owns no timer; the owner advances it.
1584
1586
  */
1585
1587
  declare class EntityAnimationPlayer {
1586
1588
  private parts;
1587
- private _animation?;
1589
+ private _animations;
1590
+ private _weights;
1591
+ private loops;
1588
1592
  private _time;
1589
- private loop;
1590
1593
  private speed;
1591
1594
  get animation(): EntityAnimation | undefined;
1595
+ get animations(): readonly EntityAnimation[];
1596
+ get weights(): readonly number[];
1592
1597
  get time(): number;
1593
1598
  /**
1594
1599
  * Starts an animation on matching named parts. Supplied baked poses are the baseline for offsets;
1595
1600
  * without them, the current pose is used. Stopping restores the pose from before playback.
1596
1601
  */
1597
1602
  play(layers: Object3D[], animation: EntityAnimation, options?: EntityAnimationOptions, poses?: ReadonlyMap<Object3D, EntityModelPart["pose"]>): void;
1603
+ /**
1604
+ * Starts clips on matching parts with a shared clock. Weighted offsets add to the supplied baked poses
1605
+ * or, without poses, to each animated part's pose when playback starts.
1606
+ */
1607
+ playAnimations(layers: Object3D[], animations: readonly EntityAnimation[], options?: EntityAnimationOptions, poses?: ReadonlyMap<Object3D, EntityModelPart["pose"]>): void;
1598
1608
  /** Restores the poses from before playback. Returns whether an animation was active. */
1599
1609
  stop(): boolean;
1600
1610
  /** Forgets the animation without touching the parts, for parts that no longer exist. */
@@ -1603,8 +1613,12 @@ declare class EntityAnimationPlayer {
1603
1613
  setTime(seconds: number): boolean;
1604
1614
  /** Advances playback by elapsed seconds multiplied by the speed passed to {@link play}. */
1605
1615
  advance(deltaSeconds: number): boolean;
1616
+ /** Changes weights in clip order and reapplies the current time without restarting playback. */
1617
+ setWeights(weights: readonly number[]): boolean;
1606
1618
  private apply;
1607
1619
  }
1620
+ /** @internal */
1621
+ declare function validateAnimationWeights(weights: readonly number[], count: number): number[];
1608
1622
 
1609
1623
  /** Renders selected entity layers as named part groups. Create it through {@link MineRenderScene.addEntity}. */
1610
1624
  declare class EntityObject extends SceneObject {
@@ -1633,8 +1647,10 @@ declare class EntityObject extends SceneObject {
1633
1647
  private updateScroll;
1634
1648
  /** The first active clip, until playback is stopped or the object is disposed. */
1635
1649
  get animation(): Maybe<EntityAnimation>;
1636
- /** Clips playing together, each targeting a separate geometry layer. */
1650
+ /** Clips playing together, in the order passed to {@link playAnimations}. */
1637
1651
  get activeAnimations(): readonly EntityAnimation[];
1652
+ /** Weights of the active clips, in the same order as {@link activeAnimations}. */
1653
+ get animationWeights(): readonly number[];
1638
1654
  /** Seconds since the animation started, before looping. */
1639
1655
  get animationTime(): number;
1640
1656
  /**
@@ -1644,8 +1660,13 @@ declare class EntityObject extends SceneObject {
1644
1660
  * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
1645
1661
  */
1646
1662
  playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
1647
- /** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
1663
+ /**
1664
+ * Plays clips with a shared clock, adding their weighted offsets within each geometry layer.
1665
+ * Weights default to 1 and are not normalized. Selected layers without their own clip follow `main`.
1666
+ */
1648
1667
  playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void;
1668
+ /** Changes weights in active clip order, notifying the scene without restarting the shared clock. Has no effect without an animation. */
1669
+ setAnimationWeights(weights: readonly number[]): void;
1649
1670
  /** Stops all clips and restores the poses from before playback. */
1650
1671
  stopAnimation(): void;
1651
1672
  /** Poses the object at an explicit time in seconds. Has no effect without an animation. */
@@ -4344,4 +4365,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
4344
4365
  */
4345
4366
  declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
4346
4367
 
4347
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilEntityChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Biome, type BiomeColorKind, Biomes, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsMode, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DecoratedPotSide, DecoratedPots, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidQuads, type FluidRules, type FluidSample, type FluidSampler, type FlyAction, FlyControls, type FlyControlsEventMap, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, ItemDefaults, ItemGlint, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderData, type MineRenderDataManifest, type MineRenderDatasets, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, PlayerHeadTextures, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenameKind, Renames, type RenderOptions, Renderer, type RendererControls, type RendererFrame, type RendererOptions, type RendererSurface, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResolvedMineRenderData, type ResponseParser, SCENE_DOCUMENT_MAX_BYTES, SKIN_PARTS, type SavedLightSample, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneItemContext, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionFluidInput, type SectionFluidKind, type SectionFluids, type SectionGeometryInput, type SectionGeometryPage, type SectionLightData, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldBlockIntersection, type WorldChunkSource, type WorldEntityIntersection, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildFluidQuads, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, copySectionLight, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, decodeSceneDocument, encodeSceneDocument, entityAnimationTime, estimateBytesUsed, fluidKindOf, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isFlyControls, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isResourceLocation, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, probeImageSize, registerBrowserEnv, resolveBlockFluidState, resolveLegacyBlock, resolveLegacyBlockState, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sampleSectionLight, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
4368
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilEntityChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Biome, type BiomeColorKind, Biomes, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsMode, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DecoratedPotSide, DecoratedPots, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidQuads, type FluidRules, type FluidSample, type FluidSampler, type FlyAction, FlyControls, type FlyControlsEventMap, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, ItemDefaults, ItemGlint, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderData, type MineRenderDataManifest, type MineRenderDatasets, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, PlayerHeadTextures, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenameKind, Renames, type RenderOptions, Renderer, type RendererControls, type RendererFrame, type RendererOptions, type RendererSurface, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResolvedMineRenderData, type ResponseParser, SCENE_DOCUMENT_MAX_BYTES, SKIN_PARTS, type SavedLightSample, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneItemContext, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionFluidInput, type SectionFluidKind, type SectionFluids, type SectionGeometryInput, type SectionGeometryPage, type SectionLightData, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldBlockIntersection, type WorldChunkSource, type WorldEntityIntersection, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildFluidQuads, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, copySectionLight, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, decodeSceneDocument, encodeSceneDocument, entityAnimationTime, estimateBytesUsed, fluidKindOf, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isFlyControls, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isResourceLocation, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, probeImageSize, registerBrowserEnv, resolveBlockFluidState, resolveLegacyBlock, resolveLegacyBlockState, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sampleSectionLight, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, validateAnimationWeights, yieldToEventLoop };