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/bundle.js
CHANGED
|
@@ -43098,6 +43098,11 @@ void main() {
|
|
|
43098
43098
|
}
|
|
43099
43099
|
/** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
43100
43100
|
static getMatrix(display, position) {
|
|
43101
|
+
const transform = this.getTransform(display, position);
|
|
43102
|
+
return new Matrix4().compose(transform.position, transform.quaternion, transform.scale);
|
|
43103
|
+
}
|
|
43104
|
+
/** Position, rotation, and scale of a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
43105
|
+
static getTransform(display, position) {
|
|
43101
43106
|
const transform = this.withHandFallbacks(display)?.[position] ?? {};
|
|
43102
43107
|
const left = position === "firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */ || position === "thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */;
|
|
43103
43108
|
const sign = left ? -1 : 1;
|
|
@@ -43106,7 +43111,7 @@ void main() {
|
|
|
43106
43111
|
const translation = new Vector3(...transform.translation ?? [0, 0, 0]).clampScalar(-80, 80);
|
|
43107
43112
|
translation.x *= sign;
|
|
43108
43113
|
const scale = new Vector3(...transform.scale ?? [1, 1, 1]).clampScalar(-4, 4);
|
|
43109
|
-
return
|
|
43114
|
+
return { position: translation, quaternion: rotation, scale };
|
|
43110
43115
|
}
|
|
43111
43116
|
/** Transforms geometry in place and reverses triangle winding when the matrix reflects it. */
|
|
43112
43117
|
static apply(geometry, matrix) {
|
|
@@ -90271,13 +90276,14 @@ ${key}` : key;
|
|
|
90271
90276
|
}
|
|
90272
90277
|
/**
|
|
90273
90278
|
* Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
|
|
90274
|
-
* Offsets apply to the baked pose in the clip's layer (`main` by default)
|
|
90279
|
+
* Offsets apply to the baked pose in the clip's layer (`main` by default) and its repeated draws.
|
|
90280
|
+
* A `main` clip also poses every selected layer without a clip of its own.
|
|
90275
90281
|
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
90276
90282
|
*/
|
|
90277
90283
|
playAnimation(animation, options) {
|
|
90278
90284
|
this.playAnimations([animation], options);
|
|
90279
90285
|
}
|
|
90280
|
-
/** Plays
|
|
90286
|
+
/** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
|
|
90281
90287
|
playAnimations(animations, options) {
|
|
90282
90288
|
const targets = /* @__PURE__ */ new Set();
|
|
90283
90289
|
const selections = animations.map((animation) => {
|
|
@@ -90288,6 +90294,8 @@ ${key}` : key;
|
|
|
90288
90294
|
if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
|
|
90289
90295
|
return { animation, names };
|
|
90290
90296
|
});
|
|
90297
|
+
const main = selections.find(({ animation }) => (animation.layer ?? "main") === "main");
|
|
90298
|
+
if (main) main.names.push(...Object.keys(this.entityLayers).filter((name2) => !targets.has(name2.split("#")[0])));
|
|
90291
90299
|
this.createMeshes();
|
|
90292
90300
|
this.stopAnimation();
|
|
90293
90301
|
for (const { animation, names } of selections) {
|
|
@@ -90347,24 +90355,26 @@ ${key}` : key;
|
|
|
90347
90355
|
createMeshes(force = false) {
|
|
90348
90356
|
if (this.meshesCreated && !force) return;
|
|
90349
90357
|
const modelRoot = new Object3D();
|
|
90358
|
+
let transformNode = modelRoot;
|
|
90350
90359
|
const transform = this.options.flip === void 0 ? this.entity.transform : void 0;
|
|
90351
90360
|
if (transform) {
|
|
90352
|
-
for (const op of transform) {
|
|
90353
|
-
|
|
90354
|
-
|
|
90355
|
-
|
|
90356
|
-
|
|
90357
|
-
|
|
90358
|
-
|
|
90359
|
-
|
|
90360
|
-
|
|
90361
|
+
for (const [index, op] of transform.entries()) {
|
|
90362
|
+
if (index > 0) {
|
|
90363
|
+
const child = new Object3D();
|
|
90364
|
+
transformNode.add(child);
|
|
90365
|
+
transformNode = child;
|
|
90366
|
+
}
|
|
90367
|
+
if ("scale" in op) transformNode.scale.set(...op.scale);
|
|
90368
|
+
else if ("translate" in op) transformNode.position.set(...op.translate);
|
|
90369
|
+
else transformNode.rotation.set(...op.rotate, "ZYX");
|
|
90370
|
+
}
|
|
90361
90371
|
} else if (this.options.flip ?? true) {
|
|
90362
90372
|
modelRoot.scale.set(-1, -1, 1);
|
|
90363
90373
|
}
|
|
90364
90374
|
this.add(modelRoot);
|
|
90365
90375
|
Object.entries(this.entityLayers).forEach(([name2, layer], index) => {
|
|
90366
90376
|
const group = this.createGroup(`layer:${name2}`);
|
|
90367
|
-
|
|
90377
|
+
transformNode.add(group);
|
|
90368
90378
|
const inward = !Materials.entityModeCulls(layer.render ?? layer.layer.render);
|
|
90369
90379
|
this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward, this.options.faces?.[name2]);
|
|
90370
90380
|
});
|
|
@@ -94779,16 +94789,21 @@ ${shader.fragmentShader}`.replace(
|
|
|
94779
94789
|
const special = this.originalModel.special;
|
|
94780
94790
|
if (special) {
|
|
94781
94791
|
const parts2 = await SpecialItems.getParts(special, this.originalModel.key?.root, this.originalModel.components);
|
|
94782
|
-
const
|
|
94783
|
-
|
|
94792
|
+
const display = new SceneObject();
|
|
94793
|
+
if (this.options.displayPosition) {
|
|
94794
|
+
const transform = DisplayTransforms.getTransform(this.originalModel.display, this.options.displayPosition);
|
|
94795
|
+
display.position.copy(transform.position);
|
|
94796
|
+
display.quaternion.copy(transform.quaternion);
|
|
94797
|
+
display.scale.copy(transform.scale);
|
|
94798
|
+
}
|
|
94799
|
+
this.add(display);
|
|
94800
|
+
const offset = new Matrix4().makeTranslation(-8, -8, -8);
|
|
94784
94801
|
try {
|
|
94785
94802
|
const targets = [];
|
|
94786
94803
|
for (const part of parts2) {
|
|
94787
94804
|
const object4 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe, tints: part.tints, faces: part.faces });
|
|
94788
|
-
object4.matrix.
|
|
94789
|
-
object4
|
|
94790
|
-
object4.matrixAutoUpdate = false;
|
|
94791
|
-
this.add(object4);
|
|
94805
|
+
object4.matrix.multiplyMatrices(offset, part.transform).decompose(object4.position, object4.quaternion, object4.scale);
|
|
94806
|
+
display.add(object4);
|
|
94792
94807
|
await object4.init(part.material);
|
|
94793
94808
|
object4.iterateAllMeshes((mesh) => {
|
|
94794
94809
|
const source = mesh.material;
|