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/node/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';
|
|
@@ -1191,7 +1191,7 @@ interface EntityAnimation {
|
|
|
1191
1191
|
/** Seconds. */
|
|
1192
1192
|
length: number;
|
|
1193
1193
|
loop: boolean;
|
|
1194
|
-
/** Geometry layer targeted by this clip; defaults to `main`. */
|
|
1194
|
+
/** Geometry layer targeted by this clip; defaults to `main`. A `main` clip also poses selected layers without their own clip. */
|
|
1195
1195
|
layer?: string;
|
|
1196
1196
|
/** Part name anywhere in a layer; `root` is the layer's root part. */
|
|
1197
1197
|
bones: Record<string, EntityAnimationBone>;
|
|
@@ -1424,6 +1424,12 @@ declare class DisplayTransforms {
|
|
|
1424
1424
|
static withHandFallbacks(display: Model["display"]): Model["display"];
|
|
1425
1425
|
/** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1426
1426
|
static getMatrix(display: Model["display"], position: DisplayPosition): Matrix4;
|
|
1427
|
+
/** Position, rotation, and scale of a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1428
|
+
static getTransform(display: Model["display"], position: DisplayPosition): {
|
|
1429
|
+
position: Vector3;
|
|
1430
|
+
quaternion: Quaternion;
|
|
1431
|
+
scale: Vector3;
|
|
1432
|
+
};
|
|
1427
1433
|
/** Transforms geometry in place and reverses triangle winding when the matrix reflects it. */
|
|
1428
1434
|
static apply(geometry: BufferGeometry, matrix: Matrix4): void;
|
|
1429
1435
|
}
|
|
@@ -1599,11 +1605,12 @@ declare class EntityObject extends SceneObject {
|
|
|
1599
1605
|
get animationTime(): number;
|
|
1600
1606
|
/**
|
|
1601
1607
|
* Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
|
|
1602
|
-
* Offsets apply to the baked pose in the clip's layer (`main` by default)
|
|
1608
|
+
* Offsets apply to the baked pose in the clip's layer (`main` by default) and its repeated draws.
|
|
1609
|
+
* A `main` clip also poses every selected layer without a clip of its own.
|
|
1603
1610
|
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
1604
1611
|
*/
|
|
1605
1612
|
playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
|
|
1606
|
-
/** Plays
|
|
1613
|
+
/** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
|
|
1607
1614
|
playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void;
|
|
1608
1615
|
/** Stops all clips and restores the poses from before playback. */
|
|
1609
1616
|
stopAnimation(): void;
|
package/dist/node/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';
|
|
@@ -1191,7 +1191,7 @@ interface EntityAnimation {
|
|
|
1191
1191
|
/** Seconds. */
|
|
1192
1192
|
length: number;
|
|
1193
1193
|
loop: boolean;
|
|
1194
|
-
/** Geometry layer targeted by this clip; defaults to `main`. */
|
|
1194
|
+
/** Geometry layer targeted by this clip; defaults to `main`. A `main` clip also poses selected layers without their own clip. */
|
|
1195
1195
|
layer?: string;
|
|
1196
1196
|
/** Part name anywhere in a layer; `root` is the layer's root part. */
|
|
1197
1197
|
bones: Record<string, EntityAnimationBone>;
|
|
@@ -1424,6 +1424,12 @@ declare class DisplayTransforms {
|
|
|
1424
1424
|
static withHandFallbacks(display: Model["display"]): Model["display"];
|
|
1425
1425
|
/** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1426
1426
|
static getMatrix(display: Model["display"], position: DisplayPosition): Matrix4;
|
|
1427
|
+
/** Position, rotation, and scale of a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1428
|
+
static getTransform(display: Model["display"], position: DisplayPosition): {
|
|
1429
|
+
position: Vector3;
|
|
1430
|
+
quaternion: Quaternion;
|
|
1431
|
+
scale: Vector3;
|
|
1432
|
+
};
|
|
1427
1433
|
/** Transforms geometry in place and reverses triangle winding when the matrix reflects it. */
|
|
1428
1434
|
static apply(geometry: BufferGeometry, matrix: Matrix4): void;
|
|
1429
1435
|
}
|
|
@@ -1599,11 +1605,12 @@ declare class EntityObject extends SceneObject {
|
|
|
1599
1605
|
get animationTime(): number;
|
|
1600
1606
|
/**
|
|
1601
1607
|
* Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
|
|
1602
|
-
* Offsets apply to the baked pose in the clip's layer (`main` by default)
|
|
1608
|
+
* Offsets apply to the baked pose in the clip's layer (`main` by default) and its repeated draws.
|
|
1609
|
+
* A `main` clip also poses every selected layer without a clip of its own.
|
|
1603
1610
|
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
1604
1611
|
*/
|
|
1605
1612
|
playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
|
|
1606
|
-
/** Plays
|
|
1613
|
+
/** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
|
|
1607
1614
|
playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void;
|
|
1608
1615
|
/** Stops all clips and restores the poses from before playback. */
|
|
1609
1616
|
stopAnimation(): void;
|
package/dist/node/index.js
CHANGED
|
@@ -1535,6 +1535,11 @@ var init_DisplayTransforms = __esm({
|
|
|
1535
1535
|
}
|
|
1536
1536
|
/** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1537
1537
|
static getMatrix(display, position) {
|
|
1538
|
+
const transform = this.getTransform(display, position);
|
|
1539
|
+
return new import_three7.Matrix4().compose(transform.position, transform.quaternion, transform.scale);
|
|
1540
|
+
}
|
|
1541
|
+
/** Position, rotation, and scale of a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1542
|
+
static getTransform(display, position) {
|
|
1538
1543
|
const transform = this.withHandFallbacks(display)?.[position] ?? {};
|
|
1539
1544
|
const left = position === "firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */ || position === "thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */;
|
|
1540
1545
|
const sign = left ? -1 : 1;
|
|
@@ -1543,7 +1548,7 @@ var init_DisplayTransforms = __esm({
|
|
|
1543
1548
|
const translation = new import_three7.Vector3(...transform.translation ?? [0, 0, 0]).clampScalar(-80, 80);
|
|
1544
1549
|
translation.x *= sign;
|
|
1545
1550
|
const scale = new import_three7.Vector3(...transform.scale ?? [1, 1, 1]).clampScalar(-4, 4);
|
|
1546
|
-
return
|
|
1551
|
+
return { position: translation, quaternion: rotation, scale };
|
|
1547
1552
|
}
|
|
1548
1553
|
/** Transforms geometry in place and reverses triangle winding when the matrix reflects it. */
|
|
1549
1554
|
static apply(geometry, matrix) {
|
|
@@ -5358,13 +5363,14 @@ var init_EntityObject = __esm({
|
|
|
5358
5363
|
}
|
|
5359
5364
|
/**
|
|
5360
5365
|
* Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
|
|
5361
|
-
* Offsets apply to the baked pose in the clip's layer (`main` by default)
|
|
5366
|
+
* Offsets apply to the baked pose in the clip's layer (`main` by default) and its repeated draws.
|
|
5367
|
+
* A `main` clip also poses every selected layer without a clip of its own.
|
|
5362
5368
|
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
5363
5369
|
*/
|
|
5364
5370
|
playAnimation(animation, options) {
|
|
5365
5371
|
this.playAnimations([animation], options);
|
|
5366
5372
|
}
|
|
5367
|
-
/** Plays
|
|
5373
|
+
/** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
|
|
5368
5374
|
playAnimations(animations, options) {
|
|
5369
5375
|
const targets = /* @__PURE__ */ new Set();
|
|
5370
5376
|
const selections = animations.map((animation) => {
|
|
@@ -5375,6 +5381,8 @@ var init_EntityObject = __esm({
|
|
|
5375
5381
|
if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
|
|
5376
5382
|
return { animation, names };
|
|
5377
5383
|
});
|
|
5384
|
+
const main = selections.find(({ animation }) => (animation.layer ?? "main") === "main");
|
|
5385
|
+
if (main) main.names.push(...Object.keys(this.entityLayers).filter((name) => !targets.has(name.split("#")[0])));
|
|
5378
5386
|
this.createMeshes();
|
|
5379
5387
|
this.stopAnimation();
|
|
5380
5388
|
for (const { animation, names } of selections) {
|
|
@@ -5434,24 +5442,26 @@ var init_EntityObject = __esm({
|
|
|
5434
5442
|
createMeshes(force = false) {
|
|
5435
5443
|
if (this.meshesCreated && !force) return;
|
|
5436
5444
|
const modelRoot = new import_three14.Object3D();
|
|
5445
|
+
let transformNode = modelRoot;
|
|
5437
5446
|
const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
|
|
5438
5447
|
if (transform) {
|
|
5439
|
-
for (const op of transform) {
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5448
|
+
for (const [index, op] of transform.entries()) {
|
|
5449
|
+
if (index > 0) {
|
|
5450
|
+
const child = new import_three14.Object3D();
|
|
5451
|
+
transformNode.add(child);
|
|
5452
|
+
transformNode = child;
|
|
5453
|
+
}
|
|
5454
|
+
if ("scale" in op) transformNode.scale.set(...op.scale);
|
|
5455
|
+
else if ("translate" in op) transformNode.position.set(...op.translate);
|
|
5456
|
+
else transformNode.rotation.set(...op.rotate, "ZYX");
|
|
5445
5457
|
}
|
|
5446
|
-
modelRoot.matrixWorldNeedsUpdate = true;
|
|
5447
|
-
modelRoot.matrixAutoUpdate = false;
|
|
5448
5458
|
} else if (this.options.flip ?? true) {
|
|
5449
5459
|
modelRoot.scale.set(-1, -1, 1);
|
|
5450
5460
|
}
|
|
5451
5461
|
this.add(modelRoot);
|
|
5452
5462
|
Object.entries(this.entityLayers).forEach(([name, layer], index) => {
|
|
5453
5463
|
const group = this.createGroup(`layer:${name}`);
|
|
5454
|
-
|
|
5464
|
+
transformNode.add(group);
|
|
5455
5465
|
const inward = !Materials.entityModeCulls(layer.render ?? layer.layer.render);
|
|
5456
5466
|
this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward, this.options.faces?.[name]);
|
|
5457
5467
|
});
|
|
@@ -7104,16 +7114,21 @@ var init_ModelObject = __esm({
|
|
|
7104
7114
|
const special = this.originalModel.special;
|
|
7105
7115
|
if (special) {
|
|
7106
7116
|
const parts2 = await SpecialItems.getParts(special, this.originalModel.key?.root, this.originalModel.components);
|
|
7107
|
-
const
|
|
7108
|
-
|
|
7117
|
+
const display = new SceneObject();
|
|
7118
|
+
if (this.options.displayPosition) {
|
|
7119
|
+
const transform = DisplayTransforms.getTransform(this.originalModel.display, this.options.displayPosition);
|
|
7120
|
+
display.position.copy(transform.position);
|
|
7121
|
+
display.quaternion.copy(transform.quaternion);
|
|
7122
|
+
display.scale.copy(transform.scale);
|
|
7123
|
+
}
|
|
7124
|
+
this.add(display);
|
|
7125
|
+
const offset = new import_three27.Matrix4().makeTranslation(-8, -8, -8);
|
|
7109
7126
|
try {
|
|
7110
7127
|
const targets = [];
|
|
7111
7128
|
for (const part of parts2) {
|
|
7112
7129
|
const object4 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe, tints: part.tints, faces: part.faces });
|
|
7113
|
-
object4.matrix.
|
|
7114
|
-
object4
|
|
7115
|
-
object4.matrixAutoUpdate = false;
|
|
7116
|
-
this.add(object4);
|
|
7130
|
+
object4.matrix.multiplyMatrices(offset, part.transform).decompose(object4.position, object4.quaternion, object4.scale);
|
|
7131
|
+
display.add(object4);
|
|
7117
7132
|
await object4.init(part.material);
|
|
7118
7133
|
object4.iterateAllMeshes((mesh) => {
|
|
7119
7134
|
const source = mesh.material;
|