minerender 2.1.0-alpha.124 → 2.1.0-alpha.126
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.
- package/dist/browser/index.d.mts +11 -4
- package/dist/browser/index.d.ts +11 -4
- package/dist/browser/index.js +33 -18
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +74 -59
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +34 -19
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +11 -4
- package/dist/node/index.d.ts +11 -4
- package/dist/node/index.js +33 -18
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +74 -59
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as three from 'three';
|
|
2
|
-
import { Vector3, PixelFormat, BoxGeometry, Material, ColorRepresentation, MeshBasicMaterial, Mesh, Euler, Vector2, BufferAttribute, Float32BufferAttribute, BufferGeometry, Object3D, Box3, InstancedMesh, PerspectiveCamera, OrthographicCamera, Matrix4, Box2, Scene, Object3DEventMap, ShaderMaterial, Texture, Camera, MOUSE, TOUCH, Controls, WebGLRenderer, EventDispatcher, Raycaster, Intersection, Group, DataTexture, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points } from 'three';
|
|
2
|
+
import { Vector3, PixelFormat, BoxGeometry, Material, ColorRepresentation, MeshBasicMaterial, Mesh, Euler, Vector2, BufferAttribute, Float32BufferAttribute, BufferGeometry, Object3D, Box3, InstancedMesh, PerspectiveCamera, OrthographicCamera, Matrix4, Quaternion, Box2, Scene, Object3DEventMap, ShaderMaterial, Texture, Camera, MOUSE, TOUCH, Controls, WebGLRenderer, EventDispatcher, Raycaster, Intersection, Group, DataTexture, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points } from 'three';
|
|
3
3
|
import * as nodeCanvas from 'canvas';
|
|
4
4
|
import { ImageData as ImageData$1, CanvasRenderingContext2D } from 'canvas';
|
|
5
5
|
import { Buffer } from 'buffer';
|
|
@@ -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>;
|
|
@@ -1422,6 +1422,12 @@ declare class DisplayTransforms {
|
|
|
1422
1422
|
static withHandFallbacks(display: Model["display"]): Model["display"];
|
|
1423
1423
|
/** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1424
1424
|
static getMatrix(display: Model["display"], position: DisplayPosition): Matrix4;
|
|
1425
|
+
/** Position, rotation, and scale of a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1426
|
+
static getTransform(display: Model["display"], position: DisplayPosition): {
|
|
1427
|
+
position: Vector3;
|
|
1428
|
+
quaternion: Quaternion;
|
|
1429
|
+
scale: Vector3;
|
|
1430
|
+
};
|
|
1425
1431
|
/** Transforms geometry in place and reverses triangle winding when the matrix reflects it. */
|
|
1426
1432
|
static apply(geometry: BufferGeometry, matrix: Matrix4): void;
|
|
1427
1433
|
}
|
|
@@ -1597,11 +1603,12 @@ declare class EntityObject extends SceneObject {
|
|
|
1597
1603
|
get animationTime(): number;
|
|
1598
1604
|
/**
|
|
1599
1605
|
* 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)
|
|
1606
|
+
* Offsets apply to the baked pose in the clip's layer (`main` by default) and its repeated draws.
|
|
1607
|
+
* A `main` clip also poses every selected layer without a clip of its own.
|
|
1601
1608
|
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
1602
1609
|
*/
|
|
1603
1610
|
playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
|
|
1604
|
-
/** Plays
|
|
1611
|
+
/** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
|
|
1605
1612
|
playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void;
|
|
1606
1613
|
/** Stops all clips and restores the poses from before playback. */
|
|
1607
1614
|
stopAnimation(): void;
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as three from 'three';
|
|
2
|
-
import { Vector3, PixelFormat, BoxGeometry, Material, ColorRepresentation, MeshBasicMaterial, Mesh, Euler, Vector2, BufferAttribute, Float32BufferAttribute, BufferGeometry, Object3D, Box3, InstancedMesh, PerspectiveCamera, OrthographicCamera, Matrix4, Box2, Scene, Object3DEventMap, ShaderMaterial, Texture, Camera, MOUSE, TOUCH, Controls, WebGLRenderer, EventDispatcher, Raycaster, Intersection, Group, DataTexture, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points } from 'three';
|
|
2
|
+
import { Vector3, PixelFormat, BoxGeometry, Material, ColorRepresentation, MeshBasicMaterial, Mesh, Euler, Vector2, BufferAttribute, Float32BufferAttribute, BufferGeometry, Object3D, Box3, InstancedMesh, PerspectiveCamera, OrthographicCamera, Matrix4, Quaternion, Box2, Scene, Object3DEventMap, ShaderMaterial, Texture, Camera, MOUSE, TOUCH, Controls, WebGLRenderer, EventDispatcher, Raycaster, Intersection, Group, DataTexture, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points } from 'three';
|
|
3
3
|
import * as nodeCanvas from 'canvas';
|
|
4
4
|
import { ImageData as ImageData$1, CanvasRenderingContext2D } from 'canvas';
|
|
5
5
|
import { Buffer } from 'buffer';
|
|
@@ -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>;
|
|
@@ -1422,6 +1422,12 @@ declare class DisplayTransforms {
|
|
|
1422
1422
|
static withHandFallbacks(display: Model["display"]): Model["display"];
|
|
1423
1423
|
/** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1424
1424
|
static getMatrix(display: Model["display"], position: DisplayPosition): Matrix4;
|
|
1425
|
+
/** Position, rotation, and scale of a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1426
|
+
static getTransform(display: Model["display"], position: DisplayPosition): {
|
|
1427
|
+
position: Vector3;
|
|
1428
|
+
quaternion: Quaternion;
|
|
1429
|
+
scale: Vector3;
|
|
1430
|
+
};
|
|
1425
1431
|
/** Transforms geometry in place and reverses triangle winding when the matrix reflects it. */
|
|
1426
1432
|
static apply(geometry: BufferGeometry, matrix: Matrix4): void;
|
|
1427
1433
|
}
|
|
@@ -1597,11 +1603,12 @@ declare class EntityObject extends SceneObject {
|
|
|
1597
1603
|
get animationTime(): number;
|
|
1598
1604
|
/**
|
|
1599
1605
|
* 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)
|
|
1606
|
+
* Offsets apply to the baked pose in the clip's layer (`main` by default) and its repeated draws.
|
|
1607
|
+
* A `main` clip also poses every selected layer without a clip of its own.
|
|
1601
1608
|
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
1602
1609
|
*/
|
|
1603
1610
|
playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
|
|
1604
|
-
/** Plays
|
|
1611
|
+
/** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
|
|
1605
1612
|
playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void;
|
|
1606
1613
|
/** Stops all clips and restores the poses from before playback. */
|
|
1607
1614
|
stopAnimation(): void;
|
package/dist/browser/index.js
CHANGED
|
@@ -1479,6 +1479,11 @@ var init_DisplayTransforms = __esm({
|
|
|
1479
1479
|
}
|
|
1480
1480
|
/** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1481
1481
|
static getMatrix(display, position) {
|
|
1482
|
+
const transform = this.getTransform(display, position);
|
|
1483
|
+
return new import_three7.Matrix4().compose(transform.position, transform.quaternion, transform.scale);
|
|
1484
|
+
}
|
|
1485
|
+
/** Position, rotation, and scale of a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1486
|
+
static getTransform(display, position) {
|
|
1482
1487
|
const transform = this.withHandFallbacks(display)?.[position] ?? {};
|
|
1483
1488
|
const left = position === "firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */ || position === "thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */;
|
|
1484
1489
|
const sign = left ? -1 : 1;
|
|
@@ -1487,7 +1492,7 @@ var init_DisplayTransforms = __esm({
|
|
|
1487
1492
|
const translation = new import_three7.Vector3(...transform.translation ?? [0, 0, 0]).clampScalar(-80, 80);
|
|
1488
1493
|
translation.x *= sign;
|
|
1489
1494
|
const scale = new import_three7.Vector3(...transform.scale ?? [1, 1, 1]).clampScalar(-4, 4);
|
|
1490
|
-
return
|
|
1495
|
+
return { position: translation, quaternion: rotation, scale };
|
|
1491
1496
|
}
|
|
1492
1497
|
/** Transforms geometry in place and reverses triangle winding when the matrix reflects it. */
|
|
1493
1498
|
static apply(geometry, matrix) {
|
|
@@ -5257,13 +5262,14 @@ var init_EntityObject = __esm({
|
|
|
5257
5262
|
}
|
|
5258
5263
|
/**
|
|
5259
5264
|
* 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)
|
|
5265
|
+
* Offsets apply to the baked pose in the clip's layer (`main` by default) and its repeated draws.
|
|
5266
|
+
* A `main` clip also poses every selected layer without a clip of its own.
|
|
5261
5267
|
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
5262
5268
|
*/
|
|
5263
5269
|
playAnimation(animation, options) {
|
|
5264
5270
|
this.playAnimations([animation], options);
|
|
5265
5271
|
}
|
|
5266
|
-
/** Plays
|
|
5272
|
+
/** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
|
|
5267
5273
|
playAnimations(animations, options) {
|
|
5268
5274
|
const targets = /* @__PURE__ */ new Set();
|
|
5269
5275
|
const selections = animations.map((animation) => {
|
|
@@ -5274,6 +5280,8 @@ var init_EntityObject = __esm({
|
|
|
5274
5280
|
if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
|
|
5275
5281
|
return { animation, names };
|
|
5276
5282
|
});
|
|
5283
|
+
const main = selections.find(({ animation }) => (animation.layer ?? "main") === "main");
|
|
5284
|
+
if (main) main.names.push(...Object.keys(this.entityLayers).filter((name) => !targets.has(name.split("#")[0])));
|
|
5277
5285
|
this.createMeshes();
|
|
5278
5286
|
this.stopAnimation();
|
|
5279
5287
|
for (const { animation, names } of selections) {
|
|
@@ -5333,24 +5341,26 @@ var init_EntityObject = __esm({
|
|
|
5333
5341
|
createMeshes(force = false) {
|
|
5334
5342
|
if (this.meshesCreated && !force) return;
|
|
5335
5343
|
const modelRoot = new import_three14.Object3D();
|
|
5344
|
+
let transformNode = modelRoot;
|
|
5336
5345
|
const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
|
|
5337
5346
|
if (transform) {
|
|
5338
|
-
for (const op of transform) {
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5347
|
+
for (const [index, op] of transform.entries()) {
|
|
5348
|
+
if (index > 0) {
|
|
5349
|
+
const child = new import_three14.Object3D();
|
|
5350
|
+
transformNode.add(child);
|
|
5351
|
+
transformNode = child;
|
|
5352
|
+
}
|
|
5353
|
+
if ("scale" in op) transformNode.scale.set(...op.scale);
|
|
5354
|
+
else if ("translate" in op) transformNode.position.set(...op.translate);
|
|
5355
|
+
else transformNode.rotation.set(...op.rotate, "ZYX");
|
|
5344
5356
|
}
|
|
5345
|
-
modelRoot.matrixWorldNeedsUpdate = true;
|
|
5346
|
-
modelRoot.matrixAutoUpdate = false;
|
|
5347
5357
|
} else if (this.options.flip ?? true) {
|
|
5348
5358
|
modelRoot.scale.set(-1, -1, 1);
|
|
5349
5359
|
}
|
|
5350
5360
|
this.add(modelRoot);
|
|
5351
5361
|
Object.entries(this.entityLayers).forEach(([name, layer], index) => {
|
|
5352
5362
|
const group = this.createGroup(`layer:${name}`);
|
|
5353
|
-
|
|
5363
|
+
transformNode.add(group);
|
|
5354
5364
|
const inward = !Materials.entityModeCulls(layer.render ?? layer.layer.render);
|
|
5355
5365
|
this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward, this.options.faces?.[name]);
|
|
5356
5366
|
});
|
|
@@ -7002,16 +7012,21 @@ var init_ModelObject = __esm({
|
|
|
7002
7012
|
const special = this.originalModel.special;
|
|
7003
7013
|
if (special) {
|
|
7004
7014
|
const parts2 = await SpecialItems.getParts(special, this.originalModel.key?.root, this.originalModel.components);
|
|
7005
|
-
const
|
|
7006
|
-
|
|
7015
|
+
const display = new SceneObject();
|
|
7016
|
+
if (this.options.displayPosition) {
|
|
7017
|
+
const transform = DisplayTransforms.getTransform(this.originalModel.display, this.options.displayPosition);
|
|
7018
|
+
display.position.copy(transform.position);
|
|
7019
|
+
display.quaternion.copy(transform.quaternion);
|
|
7020
|
+
display.scale.copy(transform.scale);
|
|
7021
|
+
}
|
|
7022
|
+
this.add(display);
|
|
7023
|
+
const offset = new import_three27.Matrix4().makeTranslation(-8, -8, -8);
|
|
7007
7024
|
try {
|
|
7008
7025
|
const targets = [];
|
|
7009
7026
|
for (const part of parts2) {
|
|
7010
7027
|
const object4 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe, tints: part.tints, faces: part.faces });
|
|
7011
|
-
object4.matrix.
|
|
7012
|
-
object4
|
|
7013
|
-
object4.matrixAutoUpdate = false;
|
|
7014
|
-
this.add(object4);
|
|
7028
|
+
object4.matrix.multiplyMatrices(offset, part.transform).decompose(object4.position, object4.quaternion, object4.scale);
|
|
7029
|
+
display.add(object4);
|
|
7015
7030
|
await object4.init(part.material);
|
|
7016
7031
|
object4.iterateAllMeshes((mesh) => {
|
|
7017
7032
|
const source = mesh.material;
|