minerender 2.1.0-alpha.139 → 2.1.0-alpha.140
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/esm/index.browser.d.mts +10 -1
- package/dist/browser/esm/scene/SceneDocument.mjs +18 -3
- package/dist/browser/esm/scene/SceneDocument.mjs.map +1 -1
- package/dist/browser/esm/scene/SceneDocumentLoader.mjs +13 -3
- package/dist/browser/esm/scene/SceneDocumentLoader.mjs.map +1 -1
- package/dist/browser/index.d.ts +10 -1
- package/dist/browser/index.js +31 -6
- package/dist/browser/index.js.map +1 -1
- package/dist/bundle.js +31 -6
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +10 -1
- package/dist/node/index.d.ts +10 -1
- package/dist/node/index.js +31 -6
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +31 -6
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -16598,6 +16598,23 @@ var itemContext = (withDisplayContext) => (value, path) => {
|
|
|
16598
16598
|
}
|
|
16599
16599
|
});
|
|
16600
16600
|
};
|
|
16601
|
+
function entityAnimation(value, path) {
|
|
16602
|
+
const animation = object3(value, path);
|
|
16603
|
+
if (["name", "clips"].filter((key) => animation[key] !== void 0).length !== 1) {
|
|
16604
|
+
fail(path, "expected exactly one of name or clips");
|
|
16605
|
+
}
|
|
16606
|
+
fields(value, path, { name: text, clips: (value2, path2) => {
|
|
16607
|
+
list((value3, path3) => {
|
|
16608
|
+
fields(value3, path3, { name: text, weight: nonnegative }, ["name"]);
|
|
16609
|
+
})(value2, path2);
|
|
16610
|
+
if (!value2.length) fail(path2, "expected at least one clip");
|
|
16611
|
+
const names = /* @__PURE__ */ new Set();
|
|
16612
|
+
for (const [index, clip] of value2.entries()) {
|
|
16613
|
+
if (names.has(clip.name)) fail(`${path2}[${index}].name`, `duplicate clip "${clip.name}"`);
|
|
16614
|
+
names.add(clip.name);
|
|
16615
|
+
}
|
|
16616
|
+
}, loop: boolean, speed: nonnegative, time: nonnegative, paused: boolean });
|
|
16617
|
+
}
|
|
16601
16618
|
function guiLayer(value, path) {
|
|
16602
16619
|
const layer = object3(value, path);
|
|
16603
16620
|
if (["texture", "item", "text"].filter((key) => layer[key] !== void 0).length !== 1) {
|
|
@@ -16700,9 +16717,7 @@ function validateObject(value, path) {
|
|
|
16700
16717
|
})
|
|
16701
16718
|
});
|
|
16702
16719
|
},
|
|
16703
|
-
animation:
|
|
16704
|
-
fields(value2, path2, { name: text, loop: boolean, speed: nonnegative, time: nonnegative, paused: boolean }, ["name"]);
|
|
16705
|
-
}
|
|
16720
|
+
animation: entityAnimation
|
|
16706
16721
|
}, [...required, "asset"]);
|
|
16707
16722
|
if (Array.isArray(input.layers) && !input.layers.length) fail(`${path}.layers`, "expected at least one layer");
|
|
16708
16723
|
break;
|
|
@@ -16969,10 +16984,20 @@ var SceneDocumentLoader = class {
|
|
|
16969
16984
|
const entity = await content.addEntity(model, { ...definition.options, instanceMeshes: false });
|
|
16970
16985
|
object4 = entity;
|
|
16971
16986
|
if (definition.animation) {
|
|
16987
|
+
const animation = definition.animation;
|
|
16972
16988
|
const animations = await Entities.getAnimations(key);
|
|
16973
|
-
|
|
16974
|
-
|
|
16975
|
-
|
|
16989
|
+
if (animation.name !== void 0) {
|
|
16990
|
+
const clip = animations && Object.prototype.hasOwnProperty.call(animations, animation.name) ? animations[animation.name] : void 0;
|
|
16991
|
+
if (!clip) throw new Error(`Entity ${definition.asset} has no animation "${animation.name}"`);
|
|
16992
|
+
entity.playAnimation(clip, animation);
|
|
16993
|
+
} else {
|
|
16994
|
+
const clips = animation.clips.map(({ name }) => {
|
|
16995
|
+
const clip = animations && Object.prototype.hasOwnProperty.call(animations, name) ? animations[name] : void 0;
|
|
16996
|
+
if (!clip) throw new Error(`Entity ${definition.asset} has no animation "${name}"`);
|
|
16997
|
+
return clip;
|
|
16998
|
+
});
|
|
16999
|
+
entity.playAnimations(clips, { ...animation, weights: animation.clips.map((clip) => clip.weight ?? 1) });
|
|
17000
|
+
}
|
|
16976
17001
|
}
|
|
16977
17002
|
break;
|
|
16978
17003
|
}
|