minerender 2.1.0-alpha.76 → 2.1.0-alpha.77
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/README.md +57 -0
- package/dist/browser/index.d.mts +121 -2
- package/dist/browser/index.d.ts +121 -2
- package/dist/browser/index.js +720 -303
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +688 -271
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +1463 -1035
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +121 -2
- package/dist/node/index.d.ts +121 -2
- package/dist/node/index.js +721 -302
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +687 -270
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -813,8 +813,8 @@ var init_Textures = __esm({
|
|
|
813
813
|
for (let y = 0; y < size; y++) {
|
|
814
814
|
for (let x = 0; x < size; x++) {
|
|
815
815
|
const offset = (y * size + x) * 4;
|
|
816
|
-
const
|
|
817
|
-
data[offset] = data[offset + 2] =
|
|
816
|
+
const color2 = (x + y) % 2 === 0 ? 255 : 0;
|
|
817
|
+
data[offset] = data[offset + 2] = color2;
|
|
818
818
|
data[offset + 3] = 255;
|
|
819
819
|
}
|
|
820
820
|
}
|
|
@@ -1399,17 +1399,17 @@ var init_AssetKey = __esm({
|
|
|
1399
1399
|
var DisplayPosition, DISPLAY_POSITIONS;
|
|
1400
1400
|
var init_DisplayPosition = __esm({
|
|
1401
1401
|
"src/model/DisplayPosition.ts"() {
|
|
1402
|
-
DisplayPosition = /* @__PURE__ */ ((
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
return
|
|
1402
|
+
DisplayPosition = /* @__PURE__ */ ((DisplayPosition3) => {
|
|
1403
|
+
DisplayPosition3["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
|
|
1404
|
+
DisplayPosition3["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
|
|
1405
|
+
DisplayPosition3["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
|
|
1406
|
+
DisplayPosition3["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
|
|
1407
|
+
DisplayPosition3["GUI"] = "gui";
|
|
1408
|
+
DisplayPosition3["HEAD"] = "head";
|
|
1409
|
+
DisplayPosition3["GROUND"] = "ground";
|
|
1410
|
+
DisplayPosition3["FIXED"] = "fixed";
|
|
1411
|
+
DisplayPosition3["ON_SHELF"] = "on_shelf";
|
|
1412
|
+
return DisplayPosition3;
|
|
1413
1413
|
})(DisplayPosition || {});
|
|
1414
1414
|
DISPLAY_POSITIONS = Object.values(DisplayPosition);
|
|
1415
1415
|
}
|
|
@@ -1627,11 +1627,11 @@ var init_Models = __esm({
|
|
|
1627
1627
|
return this.PERSISTENT_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), (k1) => {
|
|
1628
1628
|
return AssetLoader.get(key, "model" /* MODEL */);
|
|
1629
1629
|
});
|
|
1630
|
-
}).then((
|
|
1631
|
-
if (
|
|
1632
|
-
|
|
1630
|
+
}).then((asset2) => {
|
|
1631
|
+
if (asset2) {
|
|
1632
|
+
asset2.key = key;
|
|
1633
1633
|
}
|
|
1634
|
-
return
|
|
1634
|
+
return asset2;
|
|
1635
1635
|
});
|
|
1636
1636
|
}
|
|
1637
1637
|
/**
|
|
@@ -1721,11 +1721,11 @@ var init_BlockStates = __esm({
|
|
|
1721
1721
|
return this.PERSISTENT_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), (k1) => {
|
|
1722
1722
|
return AssetLoader.get(key, "blockstate" /* BLOCKSTATE */);
|
|
1723
1723
|
});
|
|
1724
|
-
}).then((
|
|
1725
|
-
if (
|
|
1726
|
-
|
|
1724
|
+
}).then((asset2) => {
|
|
1725
|
+
if (asset2) {
|
|
1726
|
+
asset2.key = key;
|
|
1727
1727
|
}
|
|
1728
|
-
return
|
|
1728
|
+
return asset2;
|
|
1729
1729
|
});
|
|
1730
1730
|
}
|
|
1731
1731
|
static getAll(keys) {
|
|
@@ -1875,29 +1875,29 @@ function applyGenericRotation(axis, rotation, obj) {
|
|
|
1875
1875
|
break;
|
|
1876
1876
|
}
|
|
1877
1877
|
}
|
|
1878
|
-
function addBox3WireframeToObject(box, obj,
|
|
1878
|
+
function addBox3WireframeToObject(box, obj, color2 = 16777215, w = 2) {
|
|
1879
1879
|
let size = new Vector33();
|
|
1880
1880
|
box.getSize(size);
|
|
1881
1881
|
let boxGeo = new BoxGeometry2(size.x, size.y, size.z, 1, 1, 1);
|
|
1882
1882
|
let wireGeo = new EdgesGeometry(boxGeo);
|
|
1883
|
-
let wireMat = new LineBasicMaterial({ color, linewidth: w });
|
|
1883
|
+
let wireMat = new LineBasicMaterial({ color: color2, linewidth: w });
|
|
1884
1884
|
let wireframe = new LineSegments(wireGeo, wireMat);
|
|
1885
1885
|
obj.add(wireframe);
|
|
1886
1886
|
let axes = new AxesHelper(1);
|
|
1887
1887
|
obj.add(axes);
|
|
1888
1888
|
}
|
|
1889
|
-
function addWireframeToObject(obj,
|
|
1889
|
+
function addWireframeToObject(obj, color2 = 16777215, w = 2) {
|
|
1890
1890
|
let boxGeo = new BoxGeometry2(16, 16, 16, 1, 1, 1);
|
|
1891
1891
|
let wireGeo = new EdgesGeometry(boxGeo);
|
|
1892
|
-
let wireMat = new LineBasicMaterial({ color, linewidth: w });
|
|
1892
|
+
let wireMat = new LineBasicMaterial({ color: color2, linewidth: w });
|
|
1893
1893
|
let wireframe = new LineSegments(wireGeo, wireMat);
|
|
1894
1894
|
obj.add(wireframe);
|
|
1895
1895
|
let axes = new AxesHelper(1);
|
|
1896
1896
|
obj.add(axes);
|
|
1897
1897
|
}
|
|
1898
|
-
function addWireframeToMesh(geo, mesh,
|
|
1898
|
+
function addWireframeToMesh(geo, mesh, color2 = 16777215, w = 2) {
|
|
1899
1899
|
let wireGeo = new EdgesGeometry(geo);
|
|
1900
|
-
let wireMat = new LineBasicMaterial({ color, linewidth: w });
|
|
1900
|
+
let wireMat = new LineBasicMaterial({ color: color2, linewidth: w });
|
|
1901
1901
|
let wireframe = new LineSegments(wireGeo, wireMat);
|
|
1902
1902
|
mesh.add(wireframe);
|
|
1903
1903
|
let axes = new AxesHelper(1);
|
|
@@ -2326,27 +2326,27 @@ var init_PackFormats = __esm({
|
|
|
2326
2326
|
init_Requests();
|
|
2327
2327
|
PackFormats = class {
|
|
2328
2328
|
/** Resolves pack formats from Mojang's client metadata hosted on assets.mcasset.cloud. */
|
|
2329
|
-
static async get(
|
|
2330
|
-
let pending = this.versions.get(
|
|
2329
|
+
static async get(version2, type) {
|
|
2330
|
+
let pending = this.versions.get(version2);
|
|
2331
2331
|
if (!pending || pending.expires <= Date.now()) {
|
|
2332
2332
|
pending = {
|
|
2333
|
-
formats: this.load(
|
|
2334
|
-
expires: ["latest", "release", "snapshot"].includes(
|
|
2333
|
+
formats: this.load(version2),
|
|
2334
|
+
expires: ["latest", "release", "snapshot"].includes(version2) ? Date.now() + 3e5 : Infinity
|
|
2335
2335
|
};
|
|
2336
|
-
this.versions.set(
|
|
2336
|
+
this.versions.set(version2, pending);
|
|
2337
2337
|
}
|
|
2338
2338
|
try {
|
|
2339
2339
|
return (await pending.formats)[type];
|
|
2340
2340
|
} catch (cause) {
|
|
2341
|
-
if (this.versions.get(
|
|
2341
|
+
if (this.versions.get(version2) === pending) this.versions.delete(version2);
|
|
2342
2342
|
const option = type === "assets" ? "resourcePackFormat" : "dataPackFormat";
|
|
2343
2343
|
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
2344
|
-
throw new Error(`Could not resolve the pack format for Minecraft ${
|
|
2344
|
+
throw new Error(`Could not resolve the pack format for Minecraft ${version2}. Set ArchiveAssetSource ${option} explicitly. ${reason}`);
|
|
2345
2345
|
}
|
|
2346
2346
|
}
|
|
2347
|
-
static async load(
|
|
2347
|
+
static async load(version2) {
|
|
2348
2348
|
const response = await Requests.genericRequest({
|
|
2349
|
-
url: `https://assets.mcasset.cloud/${encodeURIComponent(
|
|
2349
|
+
url: `https://assets.mcasset.cloud/${encodeURIComponent(version2)}/game-version.json`,
|
|
2350
2350
|
responseType: "json"
|
|
2351
2351
|
});
|
|
2352
2352
|
const data = response.data;
|
|
@@ -2435,7 +2435,7 @@ var init_ArchiveAssetSource = __esm({
|
|
|
2435
2435
|
}
|
|
2436
2436
|
async load(key, parser) {
|
|
2437
2437
|
const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
|
|
2438
|
-
const
|
|
2438
|
+
const version2 = AssetLoader.version;
|
|
2439
2439
|
let selectedPath = path;
|
|
2440
2440
|
let url;
|
|
2441
2441
|
try {
|
|
@@ -2443,7 +2443,7 @@ var init_ArchiveAssetSource = __esm({
|
|
|
2443
2443
|
if (key.rootType === "assets" || key.rootType === "data") {
|
|
2444
2444
|
const metadata = await this.getMetadata(key);
|
|
2445
2445
|
if (metadata.hasOverlays) {
|
|
2446
|
-
const format2 = (key.rootType === "assets" ? this.options.resourcePackFormat : this.options.dataPackFormat) ?? await PackFormats.get(
|
|
2446
|
+
const format2 = (key.rootType === "assets" ? this.options.resourcePackFormat : this.options.dataPackFormat) ?? await PackFormats.get(version2, key.rootType);
|
|
2447
2447
|
directories = metadata.overlayDirectories(format2);
|
|
2448
2448
|
}
|
|
2449
2449
|
}
|
|
@@ -2530,8 +2530,8 @@ var init_AssetLoader = __esm({
|
|
|
2530
2530
|
return this.ROOT.substring(this.ROOT.lastIndexOf("/") + 1);
|
|
2531
2531
|
}
|
|
2532
2532
|
/** Selects an mcasset.cloud version, updates the vanilla source, and clears in-memory caches. */
|
|
2533
|
-
static setVersion(
|
|
2534
|
-
this.ROOT = `https://assets.mcasset.cloud/${
|
|
2533
|
+
static setVersion(version2) {
|
|
2534
|
+
this.ROOT = `https://assets.mcasset.cloud/${version2}`;
|
|
2535
2535
|
const source = new HostedAssetSource(this.ROOT, { retryDefaults: false });
|
|
2536
2536
|
const index = this._SOURCES.findIndex((s) => s.key === "mcassets");
|
|
2537
2537
|
if (index !== -1) {
|
|
@@ -2596,8 +2596,8 @@ ${key}` : key;
|
|
|
2596
2596
|
const sources = [...this._SOURCES];
|
|
2597
2597
|
const results = [];
|
|
2598
2598
|
for (const { source } of sources) {
|
|
2599
|
-
const
|
|
2600
|
-
if (
|
|
2599
|
+
const asset2 = await source.get(key, parser);
|
|
2600
|
+
if (asset2 != void 0) results.push(asset2);
|
|
2601
2601
|
if (await source.blocks(key)) break;
|
|
2602
2602
|
}
|
|
2603
2603
|
return results;
|
|
@@ -2667,9 +2667,9 @@ var init_ModelTextures = __esm({
|
|
|
2667
2667
|
const pending = this.preload(key);
|
|
2668
2668
|
const cached2 = Caching.textureAssetCache.getIfPresent(keyStr);
|
|
2669
2669
|
try {
|
|
2670
|
-
const
|
|
2671
|
-
if (
|
|
2672
|
-
return await ImageLoader.infoToCanvasData(
|
|
2670
|
+
const asset2 = await pending;
|
|
2671
|
+
if (asset2) {
|
|
2672
|
+
return await ImageLoader.infoToCanvasData(asset2);
|
|
2673
2673
|
}
|
|
2674
2674
|
return void 0;
|
|
2675
2675
|
} catch (err) {
|
|
@@ -2683,10 +2683,10 @@ var init_ModelTextures = __esm({
|
|
|
2683
2683
|
static async preload(key) {
|
|
2684
2684
|
const keyStr = key.serialize();
|
|
2685
2685
|
return Caching.textureAssetCache.get(keyStr, (k) => {
|
|
2686
|
-
return AssetLoader.get(key, "image" /* IMAGE */).then((
|
|
2687
|
-
if (
|
|
2688
|
-
|
|
2689
|
-
return
|
|
2686
|
+
return AssetLoader.get(key, "image" /* IMAGE */).then((asset2) => {
|
|
2687
|
+
if (asset2)
|
|
2688
|
+
asset2.key = key;
|
|
2689
|
+
return asset2;
|
|
2690
2690
|
});
|
|
2691
2691
|
});
|
|
2692
2692
|
}
|
|
@@ -2699,10 +2699,10 @@ var init_ModelTextures = __esm({
|
|
|
2699
2699
|
const keyStr = key.serialize();
|
|
2700
2700
|
return Caching.textureMetaCache.get(keyStr, (k) => {
|
|
2701
2701
|
return this.PERSISTENT_META_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), (k1) => {
|
|
2702
|
-
return AssetLoader.get(key, "meta" /* META */).then((
|
|
2703
|
-
if (
|
|
2704
|
-
|
|
2705
|
-
return
|
|
2702
|
+
return AssetLoader.get(key, "meta" /* META */).then((asset2) => {
|
|
2703
|
+
if (asset2)
|
|
2704
|
+
asset2.key = key;
|
|
2705
|
+
return asset2;
|
|
2706
2706
|
});
|
|
2707
2707
|
});
|
|
2708
2708
|
});
|
|
@@ -3256,12 +3256,12 @@ var init_UVMapper = __esm({
|
|
|
3256
3256
|
} else {
|
|
3257
3257
|
uniqueTextureNames.push(textureKey);
|
|
3258
3258
|
const assetKey = AssetKey.parse("textures", textureValue, model.key);
|
|
3259
|
-
promises.push(ModelTextures.get(assetKey).then((
|
|
3260
|
-
if (!
|
|
3259
|
+
promises.push(ModelTextures.get(assetKey).then((asset2) => {
|
|
3260
|
+
if (!asset2) {
|
|
3261
3261
|
console.warn(p5, "Missing texture", assetKey);
|
|
3262
3262
|
return;
|
|
3263
3263
|
}
|
|
3264
|
-
textureMap[textureKey] = new WrappedImage(
|
|
3264
|
+
textureMap[textureKey] = new WrappedImage(asset2);
|
|
3265
3265
|
}));
|
|
3266
3266
|
promises.push(ModelTextures.getMeta(assetKey).then((meta) => {
|
|
3267
3267
|
metaMap[textureKey] = meta;
|
|
@@ -3605,10 +3605,10 @@ var init_Entities = __esm({
|
|
|
3605
3605
|
const collect = async (path) => {
|
|
3606
3606
|
const prefix2 = path ? `${path}/` : "";
|
|
3607
3607
|
const key = new AssetKey(DEFAULT_NAMESPACE, `${prefix2}_list`, void 0, void 0, "entity-models", ".json");
|
|
3608
|
-
const
|
|
3609
|
-
if (!
|
|
3610
|
-
const files =
|
|
3611
|
-
const children = await Promise.all(
|
|
3608
|
+
const list2 = await Caching.listAssetCache.get(key.serialize(), () => AssetLoader.get(key, "list" /* LIST */));
|
|
3609
|
+
if (!list2) return [];
|
|
3610
|
+
const files = list2.files.filter((file) => file.endsWith(".json") && file !== "_list.json").map((file) => `${prefix2}${file.slice(0, -5)}`);
|
|
3611
|
+
const children = await Promise.all(list2.directories.map((directory) => collect(`${prefix2}${directory}`)));
|
|
3612
3612
|
return [...files, ...children.flat()];
|
|
3613
3613
|
};
|
|
3614
3614
|
return collect("");
|
|
@@ -3692,8 +3692,8 @@ var init_Entities = __esm({
|
|
|
3692
3692
|
if (await ModelTextures.get(texture2)) return texture2;
|
|
3693
3693
|
}
|
|
3694
3694
|
const listKey = new AssetKey(modelKey.namespace, "_list", `${name}_variant`, void 0, "data", ".json", root);
|
|
3695
|
-
const
|
|
3696
|
-
const files =
|
|
3695
|
+
const list2 = await AssetLoader.get(listKey, "list" /* LIST */);
|
|
3696
|
+
const files = list2?.files.filter((file2) => file2.endsWith(".json") && file2 !== "_list.json");
|
|
3697
3697
|
const file = files?.find((file2) => file2 === "temperate.json") ?? files?.[0];
|
|
3698
3698
|
if (!file) return void 0;
|
|
3699
3699
|
const variantKey = new AssetKey(modelKey.namespace, file.slice(0, -5), `${name}_variant`, void 0, "data", ".json", root);
|
|
@@ -3798,27 +3798,27 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
3798
3798
|
for (const layer of layers) {
|
|
3799
3799
|
const objects = [];
|
|
3800
3800
|
if (poses) {
|
|
3801
|
-
layer.traverse((
|
|
3802
|
-
if (poses.has(
|
|
3801
|
+
layer.traverse((object3) => {
|
|
3802
|
+
if (poses.has(object3)) objects.push(object3);
|
|
3803
3803
|
});
|
|
3804
3804
|
} else {
|
|
3805
3805
|
for (const bone of Object.keys(animation.bones)) {
|
|
3806
|
-
const
|
|
3807
|
-
if (
|
|
3806
|
+
const object3 = layer.getObjectByName(`group:${bone}`);
|
|
3807
|
+
if (object3) objects.push(object3);
|
|
3808
3808
|
}
|
|
3809
3809
|
}
|
|
3810
|
-
for (const
|
|
3811
|
-
const bone =
|
|
3812
|
-
const pose = poses?.get(
|
|
3810
|
+
for (const object3 of objects) {
|
|
3811
|
+
const bone = object3.name.slice("group:".length);
|
|
3812
|
+
const pose = poses?.get(object3);
|
|
3813
3813
|
this.parts.push({
|
|
3814
3814
|
bone,
|
|
3815
|
-
object:
|
|
3816
|
-
position:
|
|
3817
|
-
rotation:
|
|
3818
|
-
scale:
|
|
3819
|
-
basePosition: pose ? new Vector35(...pose.offset) :
|
|
3820
|
-
baseRotation: pose ? new Euler3(...pose.rotation, "ZYX") :
|
|
3821
|
-
baseScale: pose ? new Vector35(...pose.scale ?? [1, 1, 1]) :
|
|
3815
|
+
object: object3,
|
|
3816
|
+
position: object3.position.clone(),
|
|
3817
|
+
rotation: object3.rotation.clone(),
|
|
3818
|
+
scale: object3.scale.clone(),
|
|
3819
|
+
basePosition: pose ? new Vector35(...pose.offset) : object3.position.clone(),
|
|
3820
|
+
baseRotation: pose ? new Euler3(...pose.rotation, "ZYX") : object3.rotation.clone(),
|
|
3821
|
+
baseScale: pose ? new Vector35(...pose.scale ?? [1, 1, 1]) : object3.scale.clone()
|
|
3822
3822
|
});
|
|
3823
3823
|
}
|
|
3824
3824
|
}
|
|
@@ -4176,10 +4176,10 @@ var init_SceneObject = __esm({
|
|
|
4176
4176
|
return new InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
|
|
4177
4177
|
};
|
|
4178
4178
|
const matrix = grow(mesh.instanceMatrix, 0);
|
|
4179
|
-
const
|
|
4179
|
+
const color2 = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
|
|
4180
4180
|
mesh.dispose();
|
|
4181
4181
|
mesh.instanceMatrix = matrix;
|
|
4182
|
-
mesh.instanceColor =
|
|
4182
|
+
mesh.instanceColor = color2;
|
|
4183
4183
|
}
|
|
4184
4184
|
*activeInstanceIndices() {
|
|
4185
4185
|
if (this.instanceMesh) {
|
|
@@ -4352,15 +4352,15 @@ var init_SceneObject = __esm({
|
|
|
4352
4352
|
}
|
|
4353
4353
|
}
|
|
4354
4354
|
//</editor-fold>
|
|
4355
|
-
toggleObjectVisibility(
|
|
4356
|
-
if (
|
|
4355
|
+
toggleObjectVisibility(object3, visible) {
|
|
4356
|
+
if (object3) {
|
|
4357
4357
|
if (typeof visible !== "undefined") {
|
|
4358
|
-
|
|
4358
|
+
object3.visible = visible;
|
|
4359
4359
|
} else {
|
|
4360
|
-
|
|
4360
|
+
object3.visible = !object3.visible;
|
|
4361
4361
|
}
|
|
4362
4362
|
this.notifyDirty();
|
|
4363
|
-
return
|
|
4363
|
+
return object3.visible;
|
|
4364
4364
|
}
|
|
4365
4365
|
this.notifyDirty();
|
|
4366
4366
|
return false;
|
|
@@ -4660,8 +4660,8 @@ var init_EntityObject = __esm({
|
|
|
4660
4660
|
this.scrollMaterials.push({ material: mat, offset: mat.map.offset, speed: scroll });
|
|
4661
4661
|
}
|
|
4662
4662
|
}
|
|
4663
|
-
this.getLayerGroup(name)?.traverse((
|
|
4664
|
-
if (isMesh(
|
|
4663
|
+
this.getLayerGroup(name)?.traverse((object3) => {
|
|
4664
|
+
if (isMesh(object3)) object3.material = mat;
|
|
4665
4665
|
});
|
|
4666
4666
|
}));
|
|
4667
4667
|
if (!this.children.length) {
|
|
@@ -5002,8 +5002,8 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
5002
5002
|
return geometry;
|
|
5003
5003
|
}
|
|
5004
5004
|
}
|
|
5005
|
-
function computeMorphedAttributes(
|
|
5006
|
-
if (
|
|
5005
|
+
function computeMorphedAttributes(object3) {
|
|
5006
|
+
if (object3.geometry.isBufferGeometry !== true) {
|
|
5007
5007
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
5008
5008
|
return null;
|
|
5009
5009
|
}
|
|
@@ -5016,11 +5016,11 @@ function computeMorphedAttributes(object2) {
|
|
|
5016
5016
|
const _morphA = new Vector310();
|
|
5017
5017
|
const _morphB = new Vector310();
|
|
5018
5018
|
const _morphC = new Vector310();
|
|
5019
|
-
function _calculateMorphedAttributeData(
|
|
5019
|
+
function _calculateMorphedAttributeData(object4, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
5020
5020
|
_vA.fromBufferAttribute(attribute, a2);
|
|
5021
5021
|
_vB.fromBufferAttribute(attribute, b2);
|
|
5022
5022
|
_vC.fromBufferAttribute(attribute, c2);
|
|
5023
|
-
const morphInfluences =
|
|
5023
|
+
const morphInfluences = object4.morphTargetInfluences;
|
|
5024
5024
|
if (material2.morphTargets && morphAttribute && morphInfluences) {
|
|
5025
5025
|
_morphA.set(0, 0, 0);
|
|
5026
5026
|
_morphB.set(0, 0, 0);
|
|
@@ -5046,10 +5046,10 @@ function computeMorphedAttributes(object2) {
|
|
|
5046
5046
|
_vB.add(_morphB);
|
|
5047
5047
|
_vC.add(_morphC);
|
|
5048
5048
|
}
|
|
5049
|
-
if (
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5049
|
+
if (object4.isSkinnedMesh) {
|
|
5050
|
+
object4.boneTransform(a2, _vA);
|
|
5051
|
+
object4.boneTransform(b2, _vB);
|
|
5052
|
+
object4.boneTransform(c2, _vC);
|
|
5053
5053
|
}
|
|
5054
5054
|
modifiedAttributeArray[a2 * 3 + 0] = _vA.x;
|
|
5055
5055
|
modifiedAttributeArray[a2 * 3 + 1] = _vA.y;
|
|
@@ -5061,8 +5061,8 @@ function computeMorphedAttributes(object2) {
|
|
|
5061
5061
|
modifiedAttributeArray[c2 * 3 + 1] = _vC.y;
|
|
5062
5062
|
modifiedAttributeArray[c2 * 3 + 2] = _vC.z;
|
|
5063
5063
|
}
|
|
5064
|
-
const geometry =
|
|
5065
|
-
const material =
|
|
5064
|
+
const geometry = object3.geometry;
|
|
5065
|
+
const material = object3.material;
|
|
5066
5066
|
let a, b, c;
|
|
5067
5067
|
const index = geometry.index;
|
|
5068
5068
|
const positionAttribute = geometry.attributes.position;
|
|
@@ -5089,7 +5089,7 @@ function computeMorphedAttributes(object2) {
|
|
|
5089
5089
|
b = index.getX(j + 1);
|
|
5090
5090
|
c = index.getX(j + 2);
|
|
5091
5091
|
_calculateMorphedAttributeData(
|
|
5092
|
-
|
|
5092
|
+
object3,
|
|
5093
5093
|
groupMaterial,
|
|
5094
5094
|
positionAttribute,
|
|
5095
5095
|
morphPosition,
|
|
@@ -5100,7 +5100,7 @@ function computeMorphedAttributes(object2) {
|
|
|
5100
5100
|
modifiedPosition
|
|
5101
5101
|
);
|
|
5102
5102
|
_calculateMorphedAttributeData(
|
|
5103
|
-
|
|
5103
|
+
object3,
|
|
5104
5104
|
groupMaterial,
|
|
5105
5105
|
normalAttribute,
|
|
5106
5106
|
morphNormal,
|
|
@@ -5120,7 +5120,7 @@ function computeMorphedAttributes(object2) {
|
|
|
5120
5120
|
b = index.getX(i + 1);
|
|
5121
5121
|
c = index.getX(i + 2);
|
|
5122
5122
|
_calculateMorphedAttributeData(
|
|
5123
|
-
|
|
5123
|
+
object3,
|
|
5124
5124
|
material,
|
|
5125
5125
|
positionAttribute,
|
|
5126
5126
|
morphPosition,
|
|
@@ -5131,7 +5131,7 @@ function computeMorphedAttributes(object2) {
|
|
|
5131
5131
|
modifiedPosition
|
|
5132
5132
|
);
|
|
5133
5133
|
_calculateMorphedAttributeData(
|
|
5134
|
-
|
|
5134
|
+
object3,
|
|
5135
5135
|
material,
|
|
5136
5136
|
normalAttribute,
|
|
5137
5137
|
morphNormal,
|
|
@@ -5155,7 +5155,7 @@ function computeMorphedAttributes(object2) {
|
|
|
5155
5155
|
b = j + 1;
|
|
5156
5156
|
c = j + 2;
|
|
5157
5157
|
_calculateMorphedAttributeData(
|
|
5158
|
-
|
|
5158
|
+
object3,
|
|
5159
5159
|
groupMaterial,
|
|
5160
5160
|
positionAttribute,
|
|
5161
5161
|
morphPosition,
|
|
@@ -5166,7 +5166,7 @@ function computeMorphedAttributes(object2) {
|
|
|
5166
5166
|
modifiedPosition
|
|
5167
5167
|
);
|
|
5168
5168
|
_calculateMorphedAttributeData(
|
|
5169
|
-
|
|
5169
|
+
object3,
|
|
5170
5170
|
groupMaterial,
|
|
5171
5171
|
normalAttribute,
|
|
5172
5172
|
morphNormal,
|
|
@@ -5186,7 +5186,7 @@ function computeMorphedAttributes(object2) {
|
|
|
5186
5186
|
b = i + 1;
|
|
5187
5187
|
c = i + 2;
|
|
5188
5188
|
_calculateMorphedAttributeData(
|
|
5189
|
-
|
|
5189
|
+
object3,
|
|
5190
5190
|
material,
|
|
5191
5191
|
positionAttribute,
|
|
5192
5192
|
morphPosition,
|
|
@@ -5197,7 +5197,7 @@ function computeMorphedAttributes(object2) {
|
|
|
5197
5197
|
modifiedPosition
|
|
5198
5198
|
);
|
|
5199
5199
|
_calculateMorphedAttributeData(
|
|
5200
|
-
|
|
5200
|
+
object3,
|
|
5201
5201
|
material,
|
|
5202
5202
|
normalAttribute,
|
|
5203
5203
|
morphNormal,
|
|
@@ -5453,9 +5453,9 @@ var init_ItemTints = __esm({
|
|
|
5453
5453
|
}));
|
|
5454
5454
|
return colors;
|
|
5455
5455
|
}
|
|
5456
|
-
static rgb(
|
|
5457
|
-
if (!Array.isArray(
|
|
5458
|
-
const [red, green, blue] =
|
|
5456
|
+
static rgb(color2) {
|
|
5457
|
+
if (!Array.isArray(color2)) return color2 & 16777215;
|
|
5458
|
+
const [red, green, blue] = color2.map((channel) => Math.floor(Math.fround(Math.fround(channel) * 255)));
|
|
5459
5459
|
return red << 16 | green << 8 | blue;
|
|
5460
5460
|
}
|
|
5461
5461
|
};
|
|
@@ -5508,13 +5508,13 @@ var init_ModelObject = __esm({
|
|
|
5508
5508
|
transform.multiply(new Matrix49().makeTranslation(-8, -8, -8));
|
|
5509
5509
|
try {
|
|
5510
5510
|
for (const part of parts) {
|
|
5511
|
-
const
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
this.add(
|
|
5516
|
-
await
|
|
5517
|
-
|
|
5511
|
+
const object3 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
|
|
5512
|
+
object3.matrix.copy(transform).multiply(part.transform);
|
|
5513
|
+
object3.matrixWorldNeedsUpdate = true;
|
|
5514
|
+
object3.matrixAutoUpdate = false;
|
|
5515
|
+
this.add(object3);
|
|
5516
|
+
await object3.init();
|
|
5517
|
+
object3.iterateAllMeshes((mesh) => {
|
|
5518
5518
|
const source = mesh.material;
|
|
5519
5519
|
let material = this.specialMaterials.get(source);
|
|
5520
5520
|
if (!material) {
|
|
@@ -5525,7 +5525,7 @@ var init_ModelObject = __esm({
|
|
|
5525
5525
|
mesh.material = material;
|
|
5526
5526
|
});
|
|
5527
5527
|
for (const [name, rotation] of Object.entries(part.rotations)) {
|
|
5528
|
-
|
|
5528
|
+
object3.getGroupByName(name)?.rotation.set(...rotation, "ZYX");
|
|
5529
5529
|
}
|
|
5530
5530
|
}
|
|
5531
5531
|
} catch (error) {
|
|
@@ -5578,9 +5578,9 @@ var init_ModelObject = __esm({
|
|
|
5578
5578
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
5579
5579
|
const tint = this.options.tints[tintIndex];
|
|
5580
5580
|
if (tint === void 0) continue;
|
|
5581
|
-
const
|
|
5581
|
+
const color2 = new Color9(tint);
|
|
5582
5582
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
5583
|
-
|
|
5583
|
+
color2.toArray(colors, (faceIndex * 4 + vertex) * 3);
|
|
5584
5584
|
}
|
|
5585
5585
|
}
|
|
5586
5586
|
elGeo.setAttribute("color", new BufferAttribute5(colors, 3));
|
|
@@ -5897,9 +5897,9 @@ var init_FluidModelObject = __esm({
|
|
|
5897
5897
|
}
|
|
5898
5898
|
}
|
|
5899
5899
|
geometry.clearGroups();
|
|
5900
|
-
const
|
|
5900
|
+
const color2 = new Color10(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
|
|
5901
5901
|
const colors = new Float32Array(geometry.getAttribute("position").count * 3);
|
|
5902
|
-
for (let i = 0; i < colors.length; i += 3)
|
|
5902
|
+
for (let i = 0; i < colors.length; i += 3) color2.toArray(colors, i);
|
|
5903
5903
|
geometry.setAttribute("color", new BufferAttribute6(colors, 3));
|
|
5904
5904
|
geometry.computeBoundingBox();
|
|
5905
5905
|
geometry.computeBoundingSphere();
|
|
@@ -6029,11 +6029,11 @@ var BrowserEnv = class {
|
|
|
6029
6029
|
imageSize(data) {
|
|
6030
6030
|
return probeImageSize(data);
|
|
6031
6031
|
}
|
|
6032
|
-
openCache(name,
|
|
6032
|
+
openCache(name, version2) {
|
|
6033
6033
|
return new BrowserCache(localforage.createInstance({
|
|
6034
6034
|
// IndexedDB schema upgrades retain records; each cache generation needs its own database.
|
|
6035
|
-
name: name +
|
|
6036
|
-
version
|
|
6035
|
+
name: name + version2,
|
|
6036
|
+
version: version2
|
|
6037
6037
|
}));
|
|
6038
6038
|
}
|
|
6039
6039
|
};
|
|
@@ -6193,8 +6193,8 @@ var Fonts = class {
|
|
|
6193
6193
|
const stack = await AssetLoader.getAll(key, "json" /* JSON */);
|
|
6194
6194
|
if (stack.length === 0) throw new Error(`Could not load font ${key.toNamespacedString()}`);
|
|
6195
6195
|
const glyphs = /* @__PURE__ */ new Map();
|
|
6196
|
-
for (const
|
|
6197
|
-
for (const provider of
|
|
6196
|
+
for (const asset2 of stack) {
|
|
6197
|
+
for (const provider of asset2.providers) {
|
|
6198
6198
|
if (provider.filter?.uniform || provider.filter?.jp) continue;
|
|
6199
6199
|
let provided;
|
|
6200
6200
|
switch (provider.type) {
|
|
@@ -6340,13 +6340,13 @@ var OBJExporter = class {
|
|
|
6340
6340
|
* @param {Object3D} object - The 3D object to export.
|
|
6341
6341
|
* @return {string} The exported OBJ.
|
|
6342
6342
|
*/
|
|
6343
|
-
parse(
|
|
6343
|
+
parse(object3) {
|
|
6344
6344
|
let output = "";
|
|
6345
6345
|
let indexVertex = 0;
|
|
6346
6346
|
let indexVertexUvs = 0;
|
|
6347
6347
|
let indexNormals = 0;
|
|
6348
6348
|
const vertex = new Vector37();
|
|
6349
|
-
const
|
|
6349
|
+
const color2 = new Color4();
|
|
6350
6350
|
const normal = new Vector37();
|
|
6351
6351
|
const uv = new Vector22();
|
|
6352
6352
|
const face = [];
|
|
@@ -6445,9 +6445,9 @@ var OBJExporter = class {
|
|
|
6445
6445
|
vertex.applyMatrix4(points.matrixWorld);
|
|
6446
6446
|
output += "v " + vertex.x + " " + vertex.y + " " + vertex.z;
|
|
6447
6447
|
if (colors !== void 0) {
|
|
6448
|
-
|
|
6449
|
-
ColorManagement.workingToColorSpace(
|
|
6450
|
-
output += " " +
|
|
6448
|
+
color2.fromBufferAttribute(colors, i);
|
|
6449
|
+
ColorManagement.workingToColorSpace(color2, SRGBColorSpace3);
|
|
6450
|
+
output += " " + color2.r + " " + color2.g + " " + color2.b;
|
|
6451
6451
|
}
|
|
6452
6452
|
output += "\n";
|
|
6453
6453
|
}
|
|
@@ -6459,7 +6459,7 @@ var OBJExporter = class {
|
|
|
6459
6459
|
}
|
|
6460
6460
|
indexVertex += nbVertex;
|
|
6461
6461
|
}
|
|
6462
|
-
|
|
6462
|
+
object3.traverse(function(child) {
|
|
6463
6463
|
if (child.isMesh === true) {
|
|
6464
6464
|
parseMesh(child);
|
|
6465
6465
|
}
|
|
@@ -6493,9 +6493,9 @@ var PLYExporter = class {
|
|
|
6493
6493
|
* @param {PLYExporter~Options} options - The export options.
|
|
6494
6494
|
* @return {?(string|ArrayBuffer)} The exported PLY.
|
|
6495
6495
|
*/
|
|
6496
|
-
parse(
|
|
6496
|
+
parse(object3, onDone, options = {}) {
|
|
6497
6497
|
function traverseMeshes(cb) {
|
|
6498
|
-
|
|
6498
|
+
object3.traverse(function(child) {
|
|
6499
6499
|
if (child.isMesh === true || child.isPoints) {
|
|
6500
6500
|
const mesh = child;
|
|
6501
6501
|
const geometry = mesh.geometry;
|
|
@@ -6528,7 +6528,7 @@ var PLYExporter = class {
|
|
|
6528
6528
|
for (const name of customAttributeNames) customTypes[name] = "float";
|
|
6529
6529
|
let vertexCount = 0;
|
|
6530
6530
|
let faceCount = 0;
|
|
6531
|
-
|
|
6531
|
+
object3.traverse(function(child) {
|
|
6532
6532
|
if (child.isMesh === true) {
|
|
6533
6533
|
const mesh = child;
|
|
6534
6534
|
const geometry = mesh.geometry;
|
|
@@ -7150,8 +7150,8 @@ function equalArray(array1, array2) {
|
|
|
7150
7150
|
return element === array2[index];
|
|
7151
7151
|
});
|
|
7152
7152
|
}
|
|
7153
|
-
function stringToArrayBuffer(
|
|
7154
|
-
return new TextEncoder().encode(
|
|
7153
|
+
function stringToArrayBuffer(text2) {
|
|
7154
|
+
return new TextEncoder().encode(text2).buffer;
|
|
7155
7155
|
}
|
|
7156
7156
|
function isIdentityMatrix(matrix) {
|
|
7157
7157
|
return equalArray(matrix.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
@@ -7344,12 +7344,12 @@ var GLTFWriter = class {
|
|
|
7344
7344
|
* @param {THREE.Object3D|THREE.Material|THREE.BufferGeometry|THREE.AnimationClip} object
|
|
7345
7345
|
* @param {Object} objectDef
|
|
7346
7346
|
*/
|
|
7347
|
-
serializeUserData(
|
|
7348
|
-
if (Object.keys(
|
|
7347
|
+
serializeUserData(object3, objectDef) {
|
|
7348
|
+
if (Object.keys(object3.userData).length === 0) return;
|
|
7349
7349
|
const options = this.options;
|
|
7350
7350
|
const extensionsUsed = this.extensionsUsed;
|
|
7351
7351
|
try {
|
|
7352
|
-
const json = JSON.parse(JSON.stringify(
|
|
7352
|
+
const json = JSON.parse(JSON.stringify(object3.userData));
|
|
7353
7353
|
if (options.includeCustomExtensions && json.gltfExtensions) {
|
|
7354
7354
|
if (objectDef.extensions === void 0) objectDef.extensions = {};
|
|
7355
7355
|
for (const extensionName in json.gltfExtensions) {
|
|
@@ -7360,7 +7360,7 @@ var GLTFWriter = class {
|
|
|
7360
7360
|
}
|
|
7361
7361
|
if (Object.keys(json).length > 0) objectDef.extras = json;
|
|
7362
7362
|
} catch (error) {
|
|
7363
|
-
console.warn("THREE.GLTFExporter: userData of '" +
|
|
7363
|
+
console.warn("THREE.GLTFExporter: userData of '" + object3.name + "' won't be serialized because of JSON.stringify error - " + error.message);
|
|
7364
7364
|
}
|
|
7365
7365
|
}
|
|
7366
7366
|
/**
|
|
@@ -7869,9 +7869,9 @@ var GLTFWriter = class {
|
|
|
7869
7869
|
if (material.isMeshStandardMaterial !== true && material.isMeshBasicMaterial !== true) {
|
|
7870
7870
|
console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");
|
|
7871
7871
|
}
|
|
7872
|
-
const
|
|
7873
|
-
if (!equalArray(
|
|
7874
|
-
materialDef.pbrMetallicRoughness.baseColorFactor =
|
|
7872
|
+
const color2 = material.color.toArray().concat([material.opacity]);
|
|
7873
|
+
if (!equalArray(color2, [1, 1, 1, 1])) {
|
|
7874
|
+
materialDef.pbrMetallicRoughness.baseColorFactor = color2;
|
|
7875
7875
|
}
|
|
7876
7876
|
if (material.isMeshStandardMaterial) {
|
|
7877
7877
|
materialDef.pbrMetallicRoughness.metallicFactor = material.metalness;
|
|
@@ -8286,13 +8286,13 @@ var GLTFWriter = class {
|
|
|
8286
8286
|
* @param {THREE.Object3D} object
|
|
8287
8287
|
* @return {?number}
|
|
8288
8288
|
*/
|
|
8289
|
-
processSkin(
|
|
8289
|
+
processSkin(object3) {
|
|
8290
8290
|
const json = this.json;
|
|
8291
8291
|
const nodeMap = this.nodeMap;
|
|
8292
|
-
const node = json.nodes[nodeMap.get(
|
|
8293
|
-
const skeleton =
|
|
8292
|
+
const node = json.nodes[nodeMap.get(object3)];
|
|
8293
|
+
const skeleton = object3.skeleton;
|
|
8294
8294
|
if (skeleton === void 0) return null;
|
|
8295
|
-
const rootJoint =
|
|
8295
|
+
const rootJoint = object3.skeleton.bones[0];
|
|
8296
8296
|
if (rootJoint === void 0) return null;
|
|
8297
8297
|
const joints = [];
|
|
8298
8298
|
const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
|
|
@@ -8300,7 +8300,7 @@ var GLTFWriter = class {
|
|
|
8300
8300
|
for (let i = 0; i < skeleton.bones.length; ++i) {
|
|
8301
8301
|
joints.push(nodeMap.get(skeleton.bones[i]));
|
|
8302
8302
|
temporaryBoneInverse.copy(skeleton.boneInverses[i]);
|
|
8303
|
-
temporaryBoneInverse.multiply(
|
|
8303
|
+
temporaryBoneInverse.multiply(object3.bindMatrix).toArray(inverseBindMatrices, i * 16);
|
|
8304
8304
|
}
|
|
8305
8305
|
if (json.skins === void 0) json.skins = [];
|
|
8306
8306
|
json.skins.push({
|
|
@@ -8316,19 +8316,19 @@ var GLTFWriter = class {
|
|
|
8316
8316
|
* @param {THREE.Object3D} object Object3D to processNodeAsync
|
|
8317
8317
|
* @return {Promise<number>} Index of the node in the nodes list
|
|
8318
8318
|
*/
|
|
8319
|
-
async processNodeAsync(
|
|
8319
|
+
async processNodeAsync(object3) {
|
|
8320
8320
|
const json = this.json;
|
|
8321
8321
|
const options = this.options;
|
|
8322
8322
|
const nodeMap = this.nodeMap;
|
|
8323
8323
|
if (!json.nodes) json.nodes = [];
|
|
8324
|
-
if (
|
|
8325
|
-
return await this._processNodeWithPivotAsync(
|
|
8324
|
+
if (object3.pivot !== null) {
|
|
8325
|
+
return await this._processNodeWithPivotAsync(object3);
|
|
8326
8326
|
}
|
|
8327
8327
|
const nodeDef = {};
|
|
8328
8328
|
if (options.trs) {
|
|
8329
|
-
const rotation =
|
|
8330
|
-
const position =
|
|
8331
|
-
const scale =
|
|
8329
|
+
const rotation = object3.quaternion.toArray();
|
|
8330
|
+
const position = object3.position.toArray();
|
|
8331
|
+
const scale = object3.scale.toArray();
|
|
8332
8332
|
if (!equalArray(rotation, [0, 0, 0, 1])) {
|
|
8333
8333
|
nodeDef.rotation = rotation;
|
|
8334
8334
|
}
|
|
@@ -8339,28 +8339,28 @@ var GLTFWriter = class {
|
|
|
8339
8339
|
nodeDef.scale = scale;
|
|
8340
8340
|
}
|
|
8341
8341
|
} else {
|
|
8342
|
-
if (
|
|
8343
|
-
|
|
8342
|
+
if (object3.matrixAutoUpdate) {
|
|
8343
|
+
object3.updateMatrix();
|
|
8344
8344
|
}
|
|
8345
|
-
if (isIdentityMatrix(
|
|
8346
|
-
nodeDef.matrix =
|
|
8345
|
+
if (isIdentityMatrix(object3.matrix) === false) {
|
|
8346
|
+
nodeDef.matrix = object3.matrix.elements;
|
|
8347
8347
|
}
|
|
8348
8348
|
}
|
|
8349
|
-
if (
|
|
8350
|
-
this.serializeUserData(
|
|
8351
|
-
if (
|
|
8352
|
-
const meshIndex = await this.processMeshAsync(
|
|
8349
|
+
if (object3.name !== "") nodeDef.name = String(object3.name);
|
|
8350
|
+
this.serializeUserData(object3, nodeDef);
|
|
8351
|
+
if (object3.isMesh || object3.isLine || object3.isPoints) {
|
|
8352
|
+
const meshIndex = await this.processMeshAsync(object3);
|
|
8353
8353
|
if (meshIndex !== null) nodeDef.mesh = meshIndex;
|
|
8354
|
-
} else if (
|
|
8355
|
-
nodeDef.camera = this.processCamera(
|
|
8354
|
+
} else if (object3.isCamera) {
|
|
8355
|
+
nodeDef.camera = this.processCamera(object3);
|
|
8356
8356
|
}
|
|
8357
|
-
if (
|
|
8357
|
+
if (object3.isSkinnedMesh) this.skins.push(object3);
|
|
8358
8358
|
const nodeIndex = json.nodes.push(nodeDef) - 1;
|
|
8359
|
-
nodeMap.set(
|
|
8360
|
-
if (
|
|
8359
|
+
nodeMap.set(object3, nodeIndex);
|
|
8360
|
+
if (object3.children.length > 0) {
|
|
8361
8361
|
const children = [];
|
|
8362
|
-
for (let i = 0, l =
|
|
8363
|
-
const child =
|
|
8362
|
+
for (let i = 0, l = object3.children.length; i < l; i++) {
|
|
8363
|
+
const child = object3.children[i];
|
|
8364
8364
|
if (child.visible || options.onlyVisible === false) {
|
|
8365
8365
|
const childNodeIndex = await this.processNodeAsync(child);
|
|
8366
8366
|
if (childNodeIndex !== null) children.push(childNodeIndex);
|
|
@@ -8369,7 +8369,7 @@ var GLTFWriter = class {
|
|
|
8369
8369
|
if (children.length > 0) nodeDef.children = children;
|
|
8370
8370
|
}
|
|
8371
8371
|
await this._invokeAllAsync(function(ext) {
|
|
8372
|
-
ext.writeNode && ext.writeNode(
|
|
8372
|
+
ext.writeNode && ext.writeNode(object3, nodeDef);
|
|
8373
8373
|
});
|
|
8374
8374
|
return nodeIndex;
|
|
8375
8375
|
}
|
|
@@ -8378,19 +8378,19 @@ var GLTFWriter = class {
|
|
|
8378
8378
|
* @param {THREE.Object3D} object Object3D with pivot
|
|
8379
8379
|
* @return {Promise<number>} Index of the container node
|
|
8380
8380
|
*/
|
|
8381
|
-
async _processNodeWithPivotAsync(
|
|
8381
|
+
async _processNodeWithPivotAsync(object3) {
|
|
8382
8382
|
const json = this.json;
|
|
8383
8383
|
const options = this.options;
|
|
8384
8384
|
const nodeMap = this.nodeMap;
|
|
8385
|
-
const pivot =
|
|
8385
|
+
const pivot = object3.pivot;
|
|
8386
8386
|
const containerDef = {};
|
|
8387
|
-
const rotation =
|
|
8387
|
+
const rotation = object3.quaternion.toArray();
|
|
8388
8388
|
const position = [
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8389
|
+
object3.position.x + pivot.x,
|
|
8390
|
+
object3.position.y + pivot.y,
|
|
8391
|
+
object3.position.z + pivot.z
|
|
8392
8392
|
];
|
|
8393
|
-
const scale =
|
|
8393
|
+
const scale = object3.scale.toArray();
|
|
8394
8394
|
if (!equalArray(rotation, [0, 0, 0, 1])) {
|
|
8395
8395
|
containerDef.rotation = rotation;
|
|
8396
8396
|
}
|
|
@@ -8401,28 +8401,28 @@ var GLTFWriter = class {
|
|
|
8401
8401
|
containerDef.scale = scale;
|
|
8402
8402
|
}
|
|
8403
8403
|
containerDef.extras = { pivot: pivot.toArray() };
|
|
8404
|
-
if (
|
|
8405
|
-
this.serializeUserData(
|
|
8404
|
+
if (object3.name !== "") containerDef.name = String(object3.name);
|
|
8405
|
+
this.serializeUserData(object3, containerDef);
|
|
8406
8406
|
const containerIndex = json.nodes.push(containerDef) - 1;
|
|
8407
|
-
nodeMap.set(
|
|
8407
|
+
nodeMap.set(object3, containerIndex);
|
|
8408
8408
|
const childDef = {};
|
|
8409
8409
|
const childPosition = [-pivot.x, -pivot.y, -pivot.z];
|
|
8410
8410
|
if (!equalArray(childPosition, [0, 0, 0])) {
|
|
8411
8411
|
childDef.translation = childPosition;
|
|
8412
8412
|
}
|
|
8413
|
-
if (
|
|
8414
|
-
const meshIndex = await this.processMeshAsync(
|
|
8413
|
+
if (object3.isMesh || object3.isLine || object3.isPoints) {
|
|
8414
|
+
const meshIndex = await this.processMeshAsync(object3);
|
|
8415
8415
|
if (meshIndex !== null) childDef.mesh = meshIndex;
|
|
8416
|
-
} else if (
|
|
8417
|
-
childDef.camera = this.processCamera(
|
|
8416
|
+
} else if (object3.isCamera) {
|
|
8417
|
+
childDef.camera = this.processCamera(object3);
|
|
8418
8418
|
}
|
|
8419
|
-
if (
|
|
8419
|
+
if (object3.isSkinnedMesh) this.skins.push(object3);
|
|
8420
8420
|
const childIndex = json.nodes.push(childDef) - 1;
|
|
8421
8421
|
const containerChildren = [childIndex];
|
|
8422
|
-
if (
|
|
8422
|
+
if (object3.children.length > 0) {
|
|
8423
8423
|
const grandchildren = [];
|
|
8424
|
-
for (let i = 0, l =
|
|
8425
|
-
const child =
|
|
8424
|
+
for (let i = 0, l = object3.children.length; i < l; i++) {
|
|
8425
|
+
const child = object3.children[i];
|
|
8426
8426
|
if (child.visible || options.onlyVisible === false) {
|
|
8427
8427
|
const childNodeIndex = await this.processNodeAsync(child);
|
|
8428
8428
|
if (childNodeIndex !== null) grandchildren.push(childNodeIndex);
|
|
@@ -8432,7 +8432,7 @@ var GLTFWriter = class {
|
|
|
8432
8432
|
}
|
|
8433
8433
|
containerDef.children = containerChildren;
|
|
8434
8434
|
await this._invokeAllAsync(function(ext) {
|
|
8435
|
-
ext.writeNode && ext.writeNode(
|
|
8435
|
+
ext.writeNode && ext.writeNode(object3, containerDef);
|
|
8436
8436
|
});
|
|
8437
8437
|
return containerIndex;
|
|
8438
8438
|
}
|
|
@@ -8875,10 +8875,10 @@ var GLTFMeshGpuInstancing = class {
|
|
|
8875
8875
|
this.writer = writer;
|
|
8876
8876
|
this.name = "EXT_mesh_gpu_instancing";
|
|
8877
8877
|
}
|
|
8878
|
-
writeNode(
|
|
8879
|
-
if (!
|
|
8878
|
+
writeNode(object3, nodeDef) {
|
|
8879
|
+
if (!object3.isInstancedMesh) return;
|
|
8880
8880
|
const writer = this.writer;
|
|
8881
|
-
const mesh =
|
|
8881
|
+
const mesh = object3;
|
|
8882
8882
|
const translationAttr = new Float32Array(mesh.count * 3);
|
|
8883
8883
|
const rotationAttr = new Float32Array(mesh.count * 4);
|
|
8884
8884
|
const scaleAttr = new Float32Array(mesh.count * 3);
|
|
@@ -9068,8 +9068,8 @@ var SceneExporter = class {
|
|
|
9068
9068
|
}
|
|
9069
9069
|
}
|
|
9070
9070
|
};
|
|
9071
|
-
function localMatrix(
|
|
9072
|
-
return
|
|
9071
|
+
function localMatrix(object3) {
|
|
9072
|
+
return object3.matrixAutoUpdate ? new Matrix47().compose(object3.position, object3.quaternion, object3.scale) : object3.matrix.clone();
|
|
9073
9073
|
}
|
|
9074
9074
|
function createSnapshot(root, gltf, bakeColors = false) {
|
|
9075
9075
|
const scene = new Scene3();
|
|
@@ -9173,24 +9173,24 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
9173
9173
|
scene.add(copy);
|
|
9174
9174
|
}
|
|
9175
9175
|
};
|
|
9176
|
-
const visit = (
|
|
9177
|
-
if (!
|
|
9178
|
-
const world = parentWorld.clone().multiply(localMatrix(
|
|
9179
|
-
const mesh =
|
|
9176
|
+
const visit = (object3, parentWorld) => {
|
|
9177
|
+
if (!object3.visible) return;
|
|
9178
|
+
const world = parentWorld.clone().multiply(localMatrix(object3));
|
|
9179
|
+
const mesh = object3;
|
|
9180
9180
|
if (mesh.isMesh) {
|
|
9181
9181
|
const instanced = mesh;
|
|
9182
9182
|
if (instanced.isInstancedMesh) {
|
|
9183
9183
|
for (let i = 0; i < instanced.count; i++) {
|
|
9184
9184
|
const matrix = new Matrix47();
|
|
9185
9185
|
instanced.getMatrixAt(i, matrix);
|
|
9186
|
-
const
|
|
9187
|
-
addMesh(mesh, world.clone().multiply(matrix),
|
|
9186
|
+
const color2 = instanced.instanceColor ? new Color7().fromBufferAttribute(instanced.instanceColor, i) : void 0;
|
|
9187
|
+
addMesh(mesh, world.clone().multiply(matrix), color2);
|
|
9188
9188
|
}
|
|
9189
9189
|
} else {
|
|
9190
9190
|
addMesh(mesh, world);
|
|
9191
9191
|
}
|
|
9192
9192
|
}
|
|
9193
|
-
for (const child of
|
|
9193
|
+
for (const child of object3.children) visit(child, world);
|
|
9194
9194
|
};
|
|
9195
9195
|
try {
|
|
9196
9196
|
const ancestors = [];
|
|
@@ -9266,13 +9266,13 @@ init_AssetKey();
|
|
|
9266
9266
|
|
|
9267
9267
|
// src/gui/GuiText.ts
|
|
9268
9268
|
import { BufferGeometry as BufferGeometry2, Color as Color8, Float32BufferAttribute as Float32BufferAttribute4 } from "three";
|
|
9269
|
-
async function layoutGuiText(
|
|
9269
|
+
async function layoutGuiText(text2, options = {}) {
|
|
9270
9270
|
const maxWidth = options.maxWidth ?? Infinity, lineHeight = options.lineHeight ?? 9;
|
|
9271
9271
|
if (!(maxWidth > 0) || !Number.isFinite(lineHeight) || lineHeight <= 0) {
|
|
9272
9272
|
throw new Error("Text wrap width and line height must be positive");
|
|
9273
9273
|
}
|
|
9274
9274
|
const font = await Fonts.get(options.font);
|
|
9275
|
-
const runs = typeof
|
|
9275
|
+
const runs = typeof text2 === "string" ? [{ text: text2 }] : text2;
|
|
9276
9276
|
const glyphs = [], lineWidths = [];
|
|
9277
9277
|
let line = [], width = 0;
|
|
9278
9278
|
let trailingNewline = false;
|
|
@@ -9326,7 +9326,7 @@ function createGuiTextGeometry(layout, shadow = true) {
|
|
|
9326
9326
|
batch = { image: glyph?.image, positions: [], uvs: [], colors: [], indices: [] };
|
|
9327
9327
|
batches.push(batch);
|
|
9328
9328
|
}
|
|
9329
|
-
const
|
|
9329
|
+
const color2 = new Color8(isShadow ? (style.color & 16579836) >> 2 : style.color);
|
|
9330
9330
|
const offset = isShadow ? 1 : 0;
|
|
9331
9331
|
const top = glyph ? 7 - glyph.ascent : 0;
|
|
9332
9332
|
const height = glyph ? glyph.height * glyph.scale : 8;
|
|
@@ -9354,7 +9354,7 @@ function createGuiTextGeometry(layout, shadow = true) {
|
|
|
9354
9354
|
const v0 = glyph ? 1 - glyph.y / glyph.image.height : 1;
|
|
9355
9355
|
const v1 = glyph ? 1 - (glyph.y + glyph.height) / glyph.image.height : 0;
|
|
9356
9356
|
batch.uvs.push(u0, v0, u1, v0, u0, v1, u1, v1);
|
|
9357
|
-
for (let i = 0; i < 4; i++) batch.colors.push(
|
|
9357
|
+
for (let i = 0; i < 4; i++) batch.colors.push(color2.r, color2.g, color2.b);
|
|
9358
9358
|
batch.indices.push(base, base + 2, base + 1, base + 2, base + 3, base + 1);
|
|
9359
9359
|
};
|
|
9360
9360
|
for (const boldOffset of style.bold ? [0, 1] : [0]) {
|
|
@@ -9388,8 +9388,8 @@ var GuiHelper = class {
|
|
|
9388
9388
|
size: [width + 24, height + 24]
|
|
9389
9389
|
}));
|
|
9390
9390
|
let y = position[1];
|
|
9391
|
-
lines.forEach((
|
|
9392
|
-
layers.push({ ...textOptions, name: `tooltip-line-${index}`, text, position: [position[0], y] });
|
|
9391
|
+
lines.forEach((text2, index) => {
|
|
9392
|
+
layers.push({ ...textOptions, name: `tooltip-line-${index}`, text: text2, position: [position[0], y] });
|
|
9393
9393
|
y += layouts[index].height + (index === 0 ? titleGap : 0);
|
|
9394
9394
|
});
|
|
9395
9395
|
return layers;
|
|
@@ -9845,29 +9845,29 @@ var SceneInspector = class {
|
|
|
9845
9845
|
this.objectControlsContainer.innerHTML = "";
|
|
9846
9846
|
this.addControls(targetObject, targetIntersection, instance);
|
|
9847
9847
|
}
|
|
9848
|
-
addControls(
|
|
9848
|
+
addControls(object3, intersection, instance) {
|
|
9849
9849
|
const container = document.createElement("div");
|
|
9850
9850
|
container.append(this.separator("Select Parent/Child"));
|
|
9851
|
-
if (
|
|
9852
|
-
container.append(this.buttonControl("Select Parent " +
|
|
9853
|
-
this.selectObject(
|
|
9851
|
+
if (object3.parent) {
|
|
9852
|
+
container.append(this.buttonControl("Select Parent " + object3.parent.constructor.name + " " + object3.parent.name, "P", () => {
|
|
9853
|
+
this.selectObject(object3.parent, intersection, instance);
|
|
9854
9854
|
}));
|
|
9855
9855
|
}
|
|
9856
|
-
if (
|
|
9856
|
+
if (object3.children.length > 0) {
|
|
9857
9857
|
let i = 1;
|
|
9858
|
-
for (let child of
|
|
9858
|
+
for (let child of object3.children) {
|
|
9859
9859
|
container.append(this.buttonControl("Select Child " + child.constructor.name + " " + child.name, "C" + i++, () => {
|
|
9860
9860
|
this.selectObject(child, intersection, instance);
|
|
9861
9861
|
}));
|
|
9862
9862
|
}
|
|
9863
9863
|
}
|
|
9864
9864
|
container.append(this.separator());
|
|
9865
|
-
const selectedInstance = instance && (
|
|
9865
|
+
const selectedInstance = instance && (object3 === instance.instanceable || object3 === intersection?.object) ? instance : void 0;
|
|
9866
9866
|
if (!selectedInstance) {
|
|
9867
|
-
container.append(this.toggleControl("Visibility", "V",
|
|
9867
|
+
container.append(this.toggleControl("Visibility", "V", object3.visible, (v) => object3.visible = v));
|
|
9868
9868
|
}
|
|
9869
9869
|
container.append(this.separator("Mesh"));
|
|
9870
|
-
this.addObjectControls(
|
|
9870
|
+
this.addObjectControls(object3, intersection, container, selectedInstance);
|
|
9871
9871
|
container.append(this.separator());
|
|
9872
9872
|
this.objectControlsContainer.append(container);
|
|
9873
9873
|
}
|
|
@@ -10283,29 +10283,29 @@ var BlockTints = class {
|
|
|
10283
10283
|
}
|
|
10284
10284
|
}
|
|
10285
10285
|
if (!indices.size) return tints;
|
|
10286
|
-
let
|
|
10286
|
+
let color2;
|
|
10287
10287
|
switch (rule.source) {
|
|
10288
10288
|
case "constant":
|
|
10289
|
-
|
|
10289
|
+
color2 = rule.color;
|
|
10290
10290
|
break;
|
|
10291
10291
|
case "grass":
|
|
10292
|
-
|
|
10292
|
+
color2 = await Colormaps.grassColor(key);
|
|
10293
10293
|
break;
|
|
10294
10294
|
case "redstone": {
|
|
10295
10295
|
const power = Number(state.power ?? 0) / 15;
|
|
10296
10296
|
const red = power * 0.6 + (power > 0 ? 0.4 : 0.3);
|
|
10297
10297
|
const green = Math.max(0, power * power * 0.7 - 0.5);
|
|
10298
10298
|
const blue = Math.max(0, power * power * 0.6 - 0.7);
|
|
10299
|
-
|
|
10299
|
+
color2 = Math.floor(red * 255) << 16 | Math.floor(green * 255) << 8 | Math.floor(blue * 255);
|
|
10300
10300
|
break;
|
|
10301
10301
|
}
|
|
10302
10302
|
case "stem": {
|
|
10303
10303
|
const age = Number(state.age ?? 0);
|
|
10304
|
-
|
|
10304
|
+
color2 = age * 32 << 16 | 255 - age * 8 << 8 | age * 4;
|
|
10305
10305
|
break;
|
|
10306
10306
|
}
|
|
10307
10307
|
}
|
|
10308
|
-
return { ...Object.fromEntries([...indices].map((index) => [index,
|
|
10308
|
+
return { ...Object.fromEntries([...indices].map((index) => [index, color2])), ...tints };
|
|
10309
10309
|
}
|
|
10310
10310
|
};
|
|
10311
10311
|
|
|
@@ -10442,8 +10442,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
10442
10442
|
return false;
|
|
10443
10443
|
}
|
|
10444
10444
|
return this._models.some((model) => {
|
|
10445
|
-
const
|
|
10446
|
-
return
|
|
10445
|
+
const object3 = isInstanceReference(model) ? model.instanceable : model;
|
|
10446
|
+
return object3.isOpaqueFullCube && this.getModelCullMask(model, 63) === 63;
|
|
10447
10447
|
});
|
|
10448
10448
|
}
|
|
10449
10449
|
getModelMatrix(model) {
|
|
@@ -10452,8 +10452,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
10452
10452
|
return model.matrix.clone();
|
|
10453
10453
|
}
|
|
10454
10454
|
getModelCullMask(model, worldMask) {
|
|
10455
|
-
const
|
|
10456
|
-
if (
|
|
10455
|
+
const object3 = isInstanceReference(model) ? model.instanceable : model;
|
|
10456
|
+
if (object3.options.displayPosition) return 0;
|
|
10457
10457
|
const position = new Vector312();
|
|
10458
10458
|
const rotation = new Quaternion5();
|
|
10459
10459
|
const scale = new Vector312();
|
|
@@ -10470,14 +10470,14 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
10470
10470
|
replacements.push(model);
|
|
10471
10471
|
continue;
|
|
10472
10472
|
}
|
|
10473
|
-
const
|
|
10473
|
+
const object3 = isInstanceReference(model) ? model.instanceable : model;
|
|
10474
10474
|
const cullMask = this.getModelCullMask(model, worldMask);
|
|
10475
|
-
if (cullMask === (
|
|
10475
|
+
if (cullMask === (object3.options.cullMask ?? 0)) {
|
|
10476
10476
|
replacements.push(model);
|
|
10477
10477
|
continue;
|
|
10478
10478
|
}
|
|
10479
10479
|
const matrix = this.getModelMatrix(model);
|
|
10480
|
-
const replacement = await this.scene.addModel(
|
|
10480
|
+
const replacement = await this.scene.addModel(object3.originalModel, { ...object3.options, cullMask });
|
|
10481
10481
|
replacements.push(replacement);
|
|
10482
10482
|
if (isInstanceReference(replacement)) {
|
|
10483
10483
|
replacement.setMatrix(matrix);
|
|
@@ -10485,8 +10485,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
10485
10485
|
replacement.matrix.copy(matrix);
|
|
10486
10486
|
replacement.matrixWorldNeedsUpdate = true;
|
|
10487
10487
|
matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
10488
|
-
replacement.matrixAutoUpdate =
|
|
10489
|
-
replacement.visible =
|
|
10488
|
+
replacement.matrixAutoUpdate = object3.matrixAutoUpdate;
|
|
10489
|
+
replacement.visible = object3.visible;
|
|
10490
10490
|
}
|
|
10491
10491
|
}
|
|
10492
10492
|
} catch (error) {
|
|
@@ -13634,60 +13634,60 @@ var _MineRenderScene = class _MineRenderScene extends Scene4 {
|
|
|
13634
13634
|
this.options = (0, import_ts_deepmerge8.default)({}, _MineRenderScene.DEFAULT_OPTIONS, options ?? {});
|
|
13635
13635
|
}
|
|
13636
13636
|
add(...objects) {
|
|
13637
|
-
for (const
|
|
13637
|
+
for (const object3 of objects) {
|
|
13638
13638
|
this.dirty = true;
|
|
13639
13639
|
try {
|
|
13640
|
-
super.add(
|
|
13640
|
+
super.add(object3);
|
|
13641
13641
|
} finally {
|
|
13642
|
-
if (
|
|
13643
|
-
this.updateObjectRegistration(
|
|
13642
|
+
if (object3?.isObject3D && object3 !== this) {
|
|
13643
|
+
this.updateObjectRegistration(object3, object3.parent === this);
|
|
13644
13644
|
}
|
|
13645
13645
|
}
|
|
13646
13646
|
}
|
|
13647
13647
|
return this;
|
|
13648
13648
|
}
|
|
13649
13649
|
remove(...objects) {
|
|
13650
|
-
for (const
|
|
13651
|
-
if (!this.children.includes(
|
|
13650
|
+
for (const object3 of objects) {
|
|
13651
|
+
if (!this.children.includes(object3)) continue;
|
|
13652
13652
|
this.dirty = true;
|
|
13653
|
-
this.updateObjectRegistration(
|
|
13653
|
+
this.updateObjectRegistration(object3, false);
|
|
13654
13654
|
try {
|
|
13655
|
-
super.remove(
|
|
13655
|
+
super.remove(object3);
|
|
13656
13656
|
} finally {
|
|
13657
|
-
this.updateObjectRegistration(
|
|
13657
|
+
this.updateObjectRegistration(object3, object3.parent === this);
|
|
13658
13658
|
}
|
|
13659
13659
|
}
|
|
13660
13660
|
return this;
|
|
13661
13661
|
}
|
|
13662
|
-
updateObjectRegistration(
|
|
13663
|
-
if (this.observedObjects.has(
|
|
13664
|
-
const observable =
|
|
13662
|
+
updateObjectRegistration(object3, attached) {
|
|
13663
|
+
if (this.observedObjects.has(object3) === attached) return;
|
|
13664
|
+
const observable = object3;
|
|
13665
13665
|
if (attached) {
|
|
13666
|
-
this.observedObjects.add(
|
|
13666
|
+
this.observedObjects.add(object3);
|
|
13667
13667
|
observable.addEventListener("change", this.onObjectChange);
|
|
13668
13668
|
} else {
|
|
13669
|
-
this.observedObjects.delete(
|
|
13669
|
+
this.observedObjects.delete(object3);
|
|
13670
13670
|
observable.removeEventListener("change", this.onObjectChange);
|
|
13671
13671
|
}
|
|
13672
13672
|
const change = attached ? 1 : -1;
|
|
13673
13673
|
this.stats.objectCount += change;
|
|
13674
|
-
if (isSceneObject(
|
|
13674
|
+
if (isSceneObject(object3)) {
|
|
13675
13675
|
this.stats.sceneObjectCount += change;
|
|
13676
13676
|
}
|
|
13677
13677
|
}
|
|
13678
13678
|
/** Initializes each object before attaching it to the scene. */
|
|
13679
|
-
async initAndAdd(...
|
|
13679
|
+
async initAndAdd(...object3) {
|
|
13680
13680
|
this.dirty = true;
|
|
13681
|
-
for (let obj of
|
|
13681
|
+
for (let obj of object3) {
|
|
13682
13682
|
await obj.init();
|
|
13683
13683
|
}
|
|
13684
|
-
return this.add(...
|
|
13684
|
+
return this.add(...object3);
|
|
13685
13685
|
}
|
|
13686
|
-
async addSceneObject(
|
|
13686
|
+
async addSceneObject(asset2, objectSupplier, _options, parent = this) {
|
|
13687
13687
|
this.dirty = true;
|
|
13688
13688
|
const obj = await objectSupplier();
|
|
13689
|
-
if (obj?.options?.instanceMeshes &&
|
|
13690
|
-
let key =
|
|
13689
|
+
if (obj?.options?.instanceMeshes && asset2.key && asset2.key?.assetType === "models") {
|
|
13690
|
+
let key = asset2.key.serialize();
|
|
13691
13691
|
if (isModelObject(obj)) {
|
|
13692
13692
|
const { displayPosition, uvLockRotation, tints, cullMask } = obj.options;
|
|
13693
13693
|
if (displayPosition) key += `|display:${displayPosition}`;
|
|
@@ -13795,11 +13795,11 @@ var _changeEvent = { type: "change" };
|
|
|
13795
13795
|
var _startEvent = { type: "start" };
|
|
13796
13796
|
var _endEvent = { type: "end" };
|
|
13797
13797
|
var OrbitControls = class extends EventDispatcher {
|
|
13798
|
-
constructor(
|
|
13798
|
+
constructor(object3, domElement) {
|
|
13799
13799
|
super();
|
|
13800
13800
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
13801
13801
|
if (domElement === document) console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
|
|
13802
|
-
this.object =
|
|
13802
|
+
this.object = object3;
|
|
13803
13803
|
this.domElement = domElement;
|
|
13804
13804
|
this.domElement.style.touchAction = "none";
|
|
13805
13805
|
this.enabled = true;
|
|
@@ -13856,7 +13856,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
13856
13856
|
};
|
|
13857
13857
|
this.update = function() {
|
|
13858
13858
|
const offset = new Vector313();
|
|
13859
|
-
const quat = new Quaternion6().setFromUnitVectors(
|
|
13859
|
+
const quat = new Quaternion6().setFromUnitVectors(object3.up, new Vector313(0, 1, 0));
|
|
13860
13860
|
const quatInverse = quat.clone().invert();
|
|
13861
13861
|
const lastPosition = new Vector313();
|
|
13862
13862
|
const lastQuaternion = new Quaternion6();
|
|
@@ -14421,8 +14421,8 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
14421
14421
|
}
|
|
14422
14422
|
};
|
|
14423
14423
|
var MapControls = class extends OrbitControls {
|
|
14424
|
-
constructor(
|
|
14425
|
-
super(
|
|
14424
|
+
constructor(object3, domElement) {
|
|
14425
|
+
super(object3, domElement);
|
|
14426
14426
|
this.screenSpacePanning = false;
|
|
14427
14427
|
this.mouseButtons.LEFT = MOUSE.PAN;
|
|
14428
14428
|
this.mouseButtons.RIGHT = MOUSE.ROTATE;
|
|
@@ -14850,6 +14850,232 @@ init_SceneObject();
|
|
|
14850
14850
|
// src/index.ts
|
|
14851
14851
|
init_request();
|
|
14852
14852
|
|
|
14853
|
+
// src/scene/SceneDocument.ts
|
|
14854
|
+
init_DisplayPosition();
|
|
14855
|
+
function fail(path, message) {
|
|
14856
|
+
throw new Error(`${path}: ${message}`);
|
|
14857
|
+
}
|
|
14858
|
+
function object2(value, path) {
|
|
14859
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail(path, "expected a JSON object");
|
|
14860
|
+
for (const key of Object.keys(value)) {
|
|
14861
|
+
if (["__proto__", "prototype", "constructor"].includes(key)) fail(`${path}.${key}`, "unsupported property");
|
|
14862
|
+
}
|
|
14863
|
+
return value;
|
|
14864
|
+
}
|
|
14865
|
+
function fields(value, path, allowed, required = []) {
|
|
14866
|
+
const input = object2(value, path);
|
|
14867
|
+
for (const key of required) if (input[key] === void 0) fail(`${path}.${key}`, "required");
|
|
14868
|
+
for (const [key, entry] of Object.entries(input)) {
|
|
14869
|
+
if (!Object.prototype.hasOwnProperty.call(allowed, key)) fail(`${path}.${key}`, "unsupported property");
|
|
14870
|
+
if (entry !== void 0) allowed[key](entry, `${path}.${key}`);
|
|
14871
|
+
}
|
|
14872
|
+
return input;
|
|
14873
|
+
}
|
|
14874
|
+
var text = (value, path) => {
|
|
14875
|
+
if (typeof value !== "string" || !value.trim()) fail(path, "expected a nonempty string");
|
|
14876
|
+
};
|
|
14877
|
+
var literalText = (value, path) => {
|
|
14878
|
+
if (typeof value !== "string") fail(path, "expected a string");
|
|
14879
|
+
};
|
|
14880
|
+
var boolean = (value, path) => {
|
|
14881
|
+
if (typeof value !== "boolean") fail(path, "expected a boolean");
|
|
14882
|
+
};
|
|
14883
|
+
var number = (value, path) => {
|
|
14884
|
+
if (typeof value !== "number" || !Number.isFinite(value)) fail(path, "expected a finite number");
|
|
14885
|
+
};
|
|
14886
|
+
var positive = (value, path) => {
|
|
14887
|
+
number(value, path);
|
|
14888
|
+
if (value <= 0) fail(path, "expected a positive number");
|
|
14889
|
+
};
|
|
14890
|
+
var nonnegative = (value, path) => {
|
|
14891
|
+
number(value, path);
|
|
14892
|
+
if (value < 0) fail(path, "expected a nonnegative number");
|
|
14893
|
+
};
|
|
14894
|
+
var color = (value, path) => {
|
|
14895
|
+
number(value, path);
|
|
14896
|
+
if (!Number.isInteger(value) || value < 0 || value > 16777215) {
|
|
14897
|
+
fail(path, "expected an RGB integer from 0 to 16777215");
|
|
14898
|
+
}
|
|
14899
|
+
};
|
|
14900
|
+
var asset = (value, path) => {
|
|
14901
|
+
text(value, path);
|
|
14902
|
+
if (!/^(?:[a-z0-9_.-]+:)?[a-z0-9_./-]+$/.test(value) || value.split(/[:/]/).some((part) => !part || part === "." || part === "..")) {
|
|
14903
|
+
fail(path, "expected a resource ID such as minecraft:stone");
|
|
14904
|
+
}
|
|
14905
|
+
};
|
|
14906
|
+
var version = (value, path) => {
|
|
14907
|
+
text(value, path);
|
|
14908
|
+
if (!/^[a-zA-Z0-9._-]+$/.test(value)) fail(path, "expected a Minecraft version without slashes");
|
|
14909
|
+
};
|
|
14910
|
+
var tuple = (size, item = number) => (value, path) => {
|
|
14911
|
+
if (!Array.isArray(value) || value.length !== size) fail(path, `expected ${size} numbers`);
|
|
14912
|
+
for (let index = 0; index < size; index++) item(value[index], `${path}[${index}]`);
|
|
14913
|
+
};
|
|
14914
|
+
var list = (item) => (value, path) => {
|
|
14915
|
+
if (!Array.isArray(value)) fail(path, "expected an array");
|
|
14916
|
+
for (let index = 0; index < value.length; index++) item(value[index], `${path}[${index}]`);
|
|
14917
|
+
};
|
|
14918
|
+
var dictionary = (item, numericKeys = false) => (value, path) => {
|
|
14919
|
+
for (const [key, entry] of Object.entries(object2(value, path))) {
|
|
14920
|
+
if (numericKeys && !/^\d+$/.test(key)) fail(`${path}.${key}`, "expected a nonnegative tint index");
|
|
14921
|
+
item(entry, `${path}.${key}`);
|
|
14922
|
+
}
|
|
14923
|
+
};
|
|
14924
|
+
var enumeration = (values) => (value, path) => {
|
|
14925
|
+
if (!values.includes(value)) fail(path, `expected one of: ${values.join(", ")}`);
|
|
14926
|
+
};
|
|
14927
|
+
var textStyle = { color, bold: boolean, italic: boolean };
|
|
14928
|
+
function guiLayer(value, path) {
|
|
14929
|
+
const layer = object2(value, path);
|
|
14930
|
+
if (["texture", "item", "text"].filter((key) => layer[key] !== void 0).length !== 1) {
|
|
14931
|
+
fail(path, "expected exactly one of texture, item, or text");
|
|
14932
|
+
}
|
|
14933
|
+
const layout = { name: text, position: tuple(2), size: tuple(2, positive) };
|
|
14934
|
+
if (layer.texture !== void 0) {
|
|
14935
|
+
fields(value, path, { ...layout, texture: asset, crop: (value2, path2) => {
|
|
14936
|
+
tuple(4)(value2, path2);
|
|
14937
|
+
const [x, y, width, height] = value2;
|
|
14938
|
+
nonnegative(x, `${path2}[0]`);
|
|
14939
|
+
nonnegative(y, `${path2}[1]`);
|
|
14940
|
+
positive(width, `${path2}[2]`);
|
|
14941
|
+
positive(height, `${path2}[3]`);
|
|
14942
|
+
} });
|
|
14943
|
+
} else if (layer.item !== void 0) {
|
|
14944
|
+
fields(value, path, { ...layout, item: asset, tints: dictionary(color, true) });
|
|
14945
|
+
} else {
|
|
14946
|
+
fields(value, path, {
|
|
14947
|
+
...layout,
|
|
14948
|
+
...textStyle,
|
|
14949
|
+
font: asset,
|
|
14950
|
+
shadow: boolean,
|
|
14951
|
+
maxWidth: positive,
|
|
14952
|
+
lineHeight: positive,
|
|
14953
|
+
text: (value2, path2) => {
|
|
14954
|
+
if (typeof value2 === "string") return;
|
|
14955
|
+
list((run, path3) => {
|
|
14956
|
+
fields(run, path3, { text: literalText, ...textStyle }, ["text"]);
|
|
14957
|
+
})(value2, path2);
|
|
14958
|
+
}
|
|
14959
|
+
});
|
|
14960
|
+
}
|
|
14961
|
+
}
|
|
14962
|
+
function validateObject(value, path) {
|
|
14963
|
+
const input = object2(value, path);
|
|
14964
|
+
const common = { id: text, name: text, type: text, position: tuple(3), rotation: tuple(3), scale: tuple(3), visible: boolean };
|
|
14965
|
+
const required = ["id", "type"];
|
|
14966
|
+
const renderOptions = { wireframe: boolean };
|
|
14967
|
+
switch (input.type) {
|
|
14968
|
+
case "skin":
|
|
14969
|
+
fields(value, path, {
|
|
14970
|
+
...common,
|
|
14971
|
+
skin: text,
|
|
14972
|
+
cape: (value2, path2) => {
|
|
14973
|
+
fields(value2, path2, { texture: text, layout: enumeration(["minecraft", "optifine", "labymod"]) }, ["texture"]);
|
|
14974
|
+
},
|
|
14975
|
+
hiddenParts: list(enumeration(SKIN_PARTS)),
|
|
14976
|
+
pose: (value2, path2) => {
|
|
14977
|
+
fields(value2, path2, {
|
|
14978
|
+
head: tuple(3),
|
|
14979
|
+
body: tuple(3),
|
|
14980
|
+
rightArm: tuple(3),
|
|
14981
|
+
leftArm: tuple(3),
|
|
14982
|
+
rightLeg: tuple(3),
|
|
14983
|
+
leftLeg: tuple(3),
|
|
14984
|
+
cape: tuple(3)
|
|
14985
|
+
});
|
|
14986
|
+
},
|
|
14987
|
+
options: (value2, path2) => {
|
|
14988
|
+
fields(value2, path2, { slim: boolean, legacy: boolean });
|
|
14989
|
+
}
|
|
14990
|
+
}, required);
|
|
14991
|
+
break;
|
|
14992
|
+
case "block":
|
|
14993
|
+
fields(value, path, {
|
|
14994
|
+
...common,
|
|
14995
|
+
asset,
|
|
14996
|
+
state: dictionary(text),
|
|
14997
|
+
options: (value2, path2) => {
|
|
14998
|
+
fields(value2, path2, { ...renderOptions, tints: dictionary(color, true) });
|
|
14999
|
+
}
|
|
15000
|
+
}, [...required, "asset"]);
|
|
15001
|
+
break;
|
|
15002
|
+
case "item":
|
|
15003
|
+
case "model":
|
|
15004
|
+
fields(value, path, {
|
|
15005
|
+
...common,
|
|
15006
|
+
asset,
|
|
15007
|
+
options: (value2, path2) => {
|
|
15008
|
+
fields(value2, path2, { ...renderOptions, displayPosition: enumeration(DISPLAY_POSITIONS), tints: dictionary(color, true) });
|
|
15009
|
+
}
|
|
15010
|
+
}, [...required, "asset"]);
|
|
15011
|
+
break;
|
|
15012
|
+
case "entity":
|
|
15013
|
+
fields(value, path, {
|
|
15014
|
+
...common,
|
|
15015
|
+
asset,
|
|
15016
|
+
texture: asset,
|
|
15017
|
+
layers: list(text),
|
|
15018
|
+
when: list(text),
|
|
15019
|
+
textures: dictionary(asset),
|
|
15020
|
+
options: (value2, path2) => {
|
|
15021
|
+
fields(value2, path2, {
|
|
15022
|
+
...renderOptions,
|
|
15023
|
+
flip: boolean,
|
|
15024
|
+
tints: dictionary((value3, path3) => {
|
|
15025
|
+
typeof value3 === "string" ? text(value3, path3) : color(value3, path3);
|
|
15026
|
+
})
|
|
15027
|
+
});
|
|
15028
|
+
},
|
|
15029
|
+
animation: (value2, path2) => {
|
|
15030
|
+
fields(value2, path2, { name: text, loop: boolean, speed: nonnegative, time: nonnegative, paused: boolean }, ["name"]);
|
|
15031
|
+
}
|
|
15032
|
+
}, [...required, "asset"]);
|
|
15033
|
+
if (Array.isArray(input.layers) && !input.layers.length) fail(`${path}.layers`, "expected at least one layer");
|
|
15034
|
+
break;
|
|
15035
|
+
case "gui":
|
|
15036
|
+
fields(value, path, { ...common, layers: list(guiLayer) }, [...required, "layers"]);
|
|
15037
|
+
break;
|
|
15038
|
+
default:
|
|
15039
|
+
fail(`${path}.type`, "expected skin, block, item, entity, model, or gui");
|
|
15040
|
+
}
|
|
15041
|
+
}
|
|
15042
|
+
function parseSceneDocument(value) {
|
|
15043
|
+
if (typeof value === "string") {
|
|
15044
|
+
try {
|
|
15045
|
+
value = JSON.parse(value);
|
|
15046
|
+
} catch {
|
|
15047
|
+
fail("scene", "invalid JSON");
|
|
15048
|
+
}
|
|
15049
|
+
}
|
|
15050
|
+
const input = fields(value, "scene", {
|
|
15051
|
+
format: enumeration(["minerender-scene"]),
|
|
15052
|
+
version: (value2, path) => {
|
|
15053
|
+
if (value2 !== 1) fail(path, "only scene document version 1 is supported");
|
|
15054
|
+
},
|
|
15055
|
+
minecraftVersion: version,
|
|
15056
|
+
camera: (value2, path) => {
|
|
15057
|
+
fields(value2, path, { position: tuple(3), target: tuple(3) }, ["position", "target"]);
|
|
15058
|
+
},
|
|
15059
|
+
objects: list(validateObject)
|
|
15060
|
+
}, ["format", "version", "objects"]);
|
|
15061
|
+
const ids = /* @__PURE__ */ new Set();
|
|
15062
|
+
for (const [index, entry] of input.objects.entries()) {
|
|
15063
|
+
if (ids.has(entry.id)) fail(`scene.objects[${index}].id`, `duplicate object ID "${entry.id}"`);
|
|
15064
|
+
ids.add(entry.id);
|
|
15065
|
+
}
|
|
15066
|
+
return JSON.parse(JSON.stringify(input));
|
|
15067
|
+
}
|
|
15068
|
+
|
|
15069
|
+
// src/scene/SceneDocumentLoader.ts
|
|
15070
|
+
init_AssetKey();
|
|
15071
|
+
init_AssetLoader();
|
|
15072
|
+
init_BlockStates();
|
|
15073
|
+
init_Entities();
|
|
15074
|
+
init_Models();
|
|
15075
|
+
init_DisplayPosition();
|
|
15076
|
+
import { Group as Group2 } from "three";
|
|
15077
|
+
init_SceneObject();
|
|
15078
|
+
|
|
14853
15079
|
// src/skin/Skins.ts
|
|
14854
15080
|
init_Requests();
|
|
14855
15081
|
var Skins = class {
|
|
@@ -15020,6 +15246,195 @@ var Skins = class {
|
|
|
15020
15246
|
//</editor-fold>
|
|
15021
15247
|
};
|
|
15022
15248
|
|
|
15249
|
+
// src/scene/SceneDocumentLoader.ts
|
|
15250
|
+
var DocumentObjectScene = class extends MineRenderScene {
|
|
15251
|
+
async addSceneObject(_asset, supplier, _options, parent = this) {
|
|
15252
|
+
const object3 = await supplier();
|
|
15253
|
+
return this.initialize(object3, parent);
|
|
15254
|
+
}
|
|
15255
|
+
async initialize(object3, parent = this) {
|
|
15256
|
+
object3.scene = this;
|
|
15257
|
+
try {
|
|
15258
|
+
await object3.init();
|
|
15259
|
+
parent.add(object3);
|
|
15260
|
+
return object3;
|
|
15261
|
+
} catch (error) {
|
|
15262
|
+
object3.dispose();
|
|
15263
|
+
object3.removeFromParent();
|
|
15264
|
+
throw error;
|
|
15265
|
+
}
|
|
15266
|
+
}
|
|
15267
|
+
dispose() {
|
|
15268
|
+
for (const child of [...this.children]) {
|
|
15269
|
+
if (child.parent !== this) continue;
|
|
15270
|
+
if (isSceneObject(child)) child.dispose();
|
|
15271
|
+
child.removeFromParent();
|
|
15272
|
+
}
|
|
15273
|
+
}
|
|
15274
|
+
};
|
|
15275
|
+
async function skinTexture(value, cape = false) {
|
|
15276
|
+
if (!/^[a-zA-Z0-9_-]{1,36}$/.test(value)) return value;
|
|
15277
|
+
const texture = await (cape ? Skins.capeFromUuidOrUsername(value) : Skins.fromUuidOrUsername(value));
|
|
15278
|
+
if (!texture) throw new Error(`Could not find ${cape ? "cape" : "skin"} for "${value}"`);
|
|
15279
|
+
return texture;
|
|
15280
|
+
}
|
|
15281
|
+
var SceneDocumentLoader = class {
|
|
15282
|
+
static parse(value) {
|
|
15283
|
+
return parseSceneDocument(value);
|
|
15284
|
+
}
|
|
15285
|
+
/**
|
|
15286
|
+
* Loads objects concurrently and attaches them in document order after every load succeeds.
|
|
15287
|
+
* A failure waits for all loads, disposes staged objects, and reports the first error in document order.
|
|
15288
|
+
*/
|
|
15289
|
+
static async load(scene, value, parent = scene) {
|
|
15290
|
+
const definition = this.parse(value);
|
|
15291
|
+
if (definition.minecraftVersion !== void 0 && definition.minecraftVersion !== AssetLoader.version) {
|
|
15292
|
+
throw new Error(`Scene requires Minecraft ${definition.minecraftVersion}; call AssetLoader.setVersion("${definition.minecraftVersion}") before loading it`);
|
|
15293
|
+
}
|
|
15294
|
+
const root = new Group2();
|
|
15295
|
+
root.name = "MineRender scene document";
|
|
15296
|
+
const objects = [];
|
|
15297
|
+
let disposed = false;
|
|
15298
|
+
const loaded = {
|
|
15299
|
+
root,
|
|
15300
|
+
objects,
|
|
15301
|
+
definition,
|
|
15302
|
+
advanceAnimations: (delta) => {
|
|
15303
|
+
if (!disposed) for (const object3 of objects) object3.advanceAnimation(delta);
|
|
15304
|
+
},
|
|
15305
|
+
dispose: () => {
|
|
15306
|
+
if (disposed) return;
|
|
15307
|
+
disposed = true;
|
|
15308
|
+
root.removeFromParent();
|
|
15309
|
+
for (const object3 of objects) object3.dispose();
|
|
15310
|
+
root.clear();
|
|
15311
|
+
scene.dirty = true;
|
|
15312
|
+
}
|
|
15313
|
+
};
|
|
15314
|
+
try {
|
|
15315
|
+
const results = await Promise.allSettled(definition.objects.map((object3) => this.loadValidatedObject(scene, object3)));
|
|
15316
|
+
for (const result of results) if (result.status === "fulfilled") objects.push(result.value);
|
|
15317
|
+
const failure = results.find((result) => result.status === "rejected");
|
|
15318
|
+
if (failure) throw failure.reason;
|
|
15319
|
+
for (const object3 of objects) root.add(object3.root);
|
|
15320
|
+
parent.add(root);
|
|
15321
|
+
scene.dirty = true;
|
|
15322
|
+
return loaded;
|
|
15323
|
+
} catch (error) {
|
|
15324
|
+
loaded.dispose();
|
|
15325
|
+
throw error;
|
|
15326
|
+
}
|
|
15327
|
+
}
|
|
15328
|
+
/** Loads an independently editable object. Its root owns the document's position, rotation, and scale. */
|
|
15329
|
+
static async loadObject(scene, value, parent = scene) {
|
|
15330
|
+
const definition = this.parse({ format: "minerender-scene", version: 1, objects: [value] }).objects[0];
|
|
15331
|
+
return this.loadValidatedObject(scene, definition, parent);
|
|
15332
|
+
}
|
|
15333
|
+
static async loadValidatedObject(scene, definition, parent) {
|
|
15334
|
+
const root = new Group2();
|
|
15335
|
+
root.name = definition.name ?? definition.id;
|
|
15336
|
+
root.userData.sceneObjectId = definition.id;
|
|
15337
|
+
root.position.fromArray(definition.position ?? [0, 0, 0]);
|
|
15338
|
+
root.rotation.set(...definition.rotation ?? [0, 0, 0]);
|
|
15339
|
+
root.scale.fromArray(definition.scale ?? [1, 1, 1]);
|
|
15340
|
+
root.visible = definition.visible ?? true;
|
|
15341
|
+
const content = new DocumentObjectScene();
|
|
15342
|
+
root.add(content);
|
|
15343
|
+
let object3;
|
|
15344
|
+
try {
|
|
15345
|
+
switch (definition.type) {
|
|
15346
|
+
case "skin": {
|
|
15347
|
+
const skin = new SkinObject({ ...definition.options, instanceMeshes: false });
|
|
15348
|
+
object3 = skin;
|
|
15349
|
+
const texture = definition.skin ? await skinTexture(definition.skin) : `${AssetLoader.ROOT}/assets/minecraft/textures/entity/player/${definition.options?.slim ? "slim/alex" : "wide/steve"}.png`;
|
|
15350
|
+
await skin.setSkinTexture(texture);
|
|
15351
|
+
await content.initialize(skin);
|
|
15352
|
+
if (definition.cape) await skin.setCapeTexture(await skinTexture(definition.cape.texture, true), definition.cape.layout);
|
|
15353
|
+
for (const [part, rotation] of Object.entries(definition.pose ?? {})) {
|
|
15354
|
+
skin.getGroupByName(part)?.rotation.set(...rotation, "XYZ");
|
|
15355
|
+
}
|
|
15356
|
+
for (const part of definition.hiddenParts ?? []) {
|
|
15357
|
+
const mesh = skin.getMeshByName(part);
|
|
15358
|
+
if (mesh) mesh.visible = false;
|
|
15359
|
+
}
|
|
15360
|
+
break;
|
|
15361
|
+
}
|
|
15362
|
+
case "block": {
|
|
15363
|
+
const state = await BlockStates.get(AssetKey.parse("blockstates", definition.asset));
|
|
15364
|
+
if (!state) throw new Error(`Could not load block ${definition.asset}`);
|
|
15365
|
+
object3 = await content.addBlock(state, { ...definition.options, initialState: definition.state, instanceMeshes: false });
|
|
15366
|
+
break;
|
|
15367
|
+
}
|
|
15368
|
+
case "item":
|
|
15369
|
+
case "model": {
|
|
15370
|
+
let key = AssetKey.parse("models", definition.asset);
|
|
15371
|
+
if (definition.type === "item" && key.type !== "item") {
|
|
15372
|
+
key = new AssetKey(key.namespace, key.getFullPath(), "models", "item");
|
|
15373
|
+
}
|
|
15374
|
+
const model = await Models.getMerged(key);
|
|
15375
|
+
if (!model) throw new Error(`Could not load ${definition.type} ${definition.asset}`);
|
|
15376
|
+
object3 = await content.addModel(model, {
|
|
15377
|
+
...definition.type === "item" ? { displayPosition: "gui" /* GUI */ } : {},
|
|
15378
|
+
...definition.options,
|
|
15379
|
+
instanceMeshes: false
|
|
15380
|
+
});
|
|
15381
|
+
break;
|
|
15382
|
+
}
|
|
15383
|
+
case "entity": {
|
|
15384
|
+
const key = AssetKey.parse("entity-models", definition.asset);
|
|
15385
|
+
const model = await Entities.getEntity(key, definition.texture ? AssetKey.parse("textures", definition.texture) : void 0, {
|
|
15386
|
+
layers: definition.layers,
|
|
15387
|
+
when: definition.when,
|
|
15388
|
+
textures: definition.textures && Object.fromEntries(Object.entries(definition.textures).map(([name, texture]) => [name, AssetKey.parse("textures", texture)]))
|
|
15389
|
+
});
|
|
15390
|
+
if (!model) throw new Error(`Could not load entity ${definition.asset}`);
|
|
15391
|
+
const entity = await content.addEntity(model, { ...definition.options, instanceMeshes: false });
|
|
15392
|
+
object3 = entity;
|
|
15393
|
+
if (definition.animation) {
|
|
15394
|
+
const animations = await Entities.getAnimations(key);
|
|
15395
|
+
const clip = animations?.[definition.animation.name];
|
|
15396
|
+
if (!clip) throw new Error(`Entity ${definition.asset} has no animation "${definition.animation.name}"`);
|
|
15397
|
+
entity.playAnimation(clip, definition.animation);
|
|
15398
|
+
}
|
|
15399
|
+
break;
|
|
15400
|
+
}
|
|
15401
|
+
case "gui":
|
|
15402
|
+
object3 = await content.initialize(new GuiObject(definition.layers));
|
|
15403
|
+
break;
|
|
15404
|
+
}
|
|
15405
|
+
let disposed = false;
|
|
15406
|
+
const loaded = {
|
|
15407
|
+
root,
|
|
15408
|
+
object: object3,
|
|
15409
|
+
definition,
|
|
15410
|
+
advanceAnimation: (delta) => {
|
|
15411
|
+
if (!disposed && definition.type === "entity" && !definition.animation?.paused) object3.advanceAnimation(delta);
|
|
15412
|
+
},
|
|
15413
|
+
dispose: () => {
|
|
15414
|
+
if (disposed) return;
|
|
15415
|
+
disposed = true;
|
|
15416
|
+
root.removeFromParent();
|
|
15417
|
+
object3.dispose();
|
|
15418
|
+
object3.removeFromParent();
|
|
15419
|
+
content.dispose();
|
|
15420
|
+
root.clear();
|
|
15421
|
+
scene.dirty = true;
|
|
15422
|
+
}
|
|
15423
|
+
};
|
|
15424
|
+
parent?.add(root);
|
|
15425
|
+
scene.dirty = true;
|
|
15426
|
+
return loaded;
|
|
15427
|
+
} catch (error) {
|
|
15428
|
+
object3?.dispose();
|
|
15429
|
+
object3?.removeFromParent();
|
|
15430
|
+
content.dispose();
|
|
15431
|
+
root.removeFromParent();
|
|
15432
|
+
root.clear();
|
|
15433
|
+
throw new Error(`Scene object "${definition.name ?? definition.id}": ${error instanceof Error ? error.message : String(error)}`);
|
|
15434
|
+
}
|
|
15435
|
+
}
|
|
15436
|
+
};
|
|
15437
|
+
|
|
15023
15438
|
// src/texture/index.ts
|
|
15024
15439
|
init_Colormaps();
|
|
15025
15440
|
init_TextureAtlas();
|
|
@@ -15373,16 +15788,16 @@ var SectionModels = class {
|
|
|
15373
15788
|
if (!models) this.models.set(model, models = /* @__PURE__ */ new Map());
|
|
15374
15789
|
const key = JSON.stringify([rotation.x, rotation.y, rotation.z, variant.uvlock, tints]);
|
|
15375
15790
|
const template = await cached(models, key, async () => {
|
|
15376
|
-
const
|
|
15791
|
+
const object3 = new SectionModel(model, {
|
|
15377
15792
|
instanceMeshes: false,
|
|
15378
15793
|
mergeMeshes: false,
|
|
15379
15794
|
tints,
|
|
15380
15795
|
uvLockRotation: variant.uvlock && (rotation.x !== 0 || rotation.y !== 0) ? [rotation.x, rotation.y, rotation.z] : void 0
|
|
15381
15796
|
});
|
|
15382
|
-
await
|
|
15383
|
-
const geometry =
|
|
15797
|
+
await object3.init();
|
|
15798
|
+
const geometry = object3.children[0].geometry;
|
|
15384
15799
|
geometry.applyMatrix4(new Matrix412().makeRotationFromEuler(rotation));
|
|
15385
|
-
|
|
15800
|
+
object3.clear();
|
|
15386
15801
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
15387
15802
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
15388
15803
|
if (local < 0) return 0;
|
|
@@ -15598,10 +16013,10 @@ var MineRenderWorld = class {
|
|
|
15598
16013
|
await block.object.updateFluid((x, y, z) => {
|
|
15599
16014
|
const neighbor = pos.clone().add(new Vector316(x, y, z));
|
|
15600
16015
|
const section = this.getChunkAt(neighbor);
|
|
15601
|
-
const
|
|
16016
|
+
const object3 = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
|
|
15602
16017
|
return {
|
|
15603
|
-
fluid:
|
|
15604
|
-
level:
|
|
16018
|
+
fluid: object3?.fluidKind,
|
|
16019
|
+
level: object3?.fluidLevel,
|
|
15605
16020
|
solid: section?.isOccludingAt(neighbor) ?? false
|
|
15606
16021
|
};
|
|
15607
16022
|
});
|
|
@@ -15677,8 +16092,8 @@ init_Model();
|
|
|
15677
16092
|
// src/world/SectionMesh.ts
|
|
15678
16093
|
init_CanvasCompat();
|
|
15679
16094
|
init_Materials();
|
|
15680
|
-
import { BufferGeometry as BufferGeometry8, Float32BufferAttribute as Float32BufferAttribute8, Group as
|
|
15681
|
-
var SectionMesh = class _SectionMesh extends
|
|
16095
|
+
import { BufferGeometry as BufferGeometry8, Float32BufferAttribute as Float32BufferAttribute8, Group as Group3, Mesh as Mesh9 } from "three";
|
|
16096
|
+
var SectionMesh = class _SectionMesh extends Group3 {
|
|
15682
16097
|
constructor() {
|
|
15683
16098
|
super(...arguments);
|
|
15684
16099
|
this.ownedMeshes = [];
|
|
@@ -15731,7 +16146,7 @@ var SectionMesh = class _SectionMesh extends Group2 {
|
|
|
15731
16146
|
const normal = template.geometry.getAttribute("normal");
|
|
15732
16147
|
const uv = template.geometry.getAttribute("uv");
|
|
15733
16148
|
const bounds = template.geometry.getAttribute("uvBounds");
|
|
15734
|
-
const
|
|
16149
|
+
const color2 = template.geometry.getAttribute("color");
|
|
15735
16150
|
const sourceIndices = template.geometry.getIndex();
|
|
15736
16151
|
const placement = locations.get(template.atlas).placement;
|
|
15737
16152
|
const mapU = (u) => (placement.x + u * template.atlas.image.width) / page.width;
|
|
@@ -15753,7 +16168,7 @@ var SectionMesh = class _SectionMesh extends Group2 {
|
|
|
15753
16168
|
mapU(bounds?.getZ(vertex) ?? 1),
|
|
15754
16169
|
mapV(bounds?.getW(vertex) ?? 1)
|
|
15755
16170
|
);
|
|
15756
|
-
colors.push(
|
|
16171
|
+
colors.push(color2?.getX(vertex) ?? 1, color2?.getY(vertex) ?? 1, color2?.getZ(vertex) ?? 1);
|
|
15757
16172
|
}
|
|
15758
16173
|
for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
|
|
15759
16174
|
}
|
|
@@ -15841,7 +16256,7 @@ var Chunk = class _Chunk {
|
|
|
15841
16256
|
this.renderedBlocks.get(index)?.object?.removeFromScene();
|
|
15842
16257
|
if (this.sectionBlocks.delete(index)) this.meshDirty = true;
|
|
15843
16258
|
this.renderedBlocks.delete(index);
|
|
15844
|
-
let
|
|
16259
|
+
let object3;
|
|
15845
16260
|
try {
|
|
15846
16261
|
if (!readBlock) return void 0;
|
|
15847
16262
|
const stored = readBlock();
|
|
@@ -15856,22 +16271,22 @@ var Chunk = class _Chunk {
|
|
|
15856
16271
|
this.sectionBlocks.set(index, { index, template, cullMask: 0 });
|
|
15857
16272
|
this.meshDirty = true;
|
|
15858
16273
|
} else {
|
|
15859
|
-
|
|
16274
|
+
object3 = await this.scene.addBlock(blockState, {
|
|
15860
16275
|
mergeMeshes: true,
|
|
15861
16276
|
instanceMeshes: true,
|
|
15862
16277
|
maxInstanceCount: 2e3,
|
|
15863
16278
|
initialState: stored.properties
|
|
15864
16279
|
});
|
|
15865
|
-
|
|
16280
|
+
object3.setPosition(MineRenderWorld.worldToScenePosition(worldPos));
|
|
15866
16281
|
}
|
|
15867
16282
|
const info = { get block() {
|
|
15868
16283
|
return readBlock();
|
|
15869
|
-
}, object:
|
|
16284
|
+
}, object: object3 };
|
|
15870
16285
|
this.renderedBlocks.set(index, info);
|
|
15871
16286
|
return info;
|
|
15872
16287
|
} catch (error) {
|
|
15873
16288
|
this.data.set(index, void 0);
|
|
15874
|
-
|
|
16289
|
+
object3?.removeFromScene();
|
|
15875
16290
|
throw error;
|
|
15876
16291
|
} finally {
|
|
15877
16292
|
await onBlocksChanged?.([worldPos]);
|
|
@@ -16054,6 +16469,7 @@ export {
|
|
|
16054
16469
|
RequestError,
|
|
16055
16470
|
Requests,
|
|
16056
16471
|
SKIN_PARTS,
|
|
16472
|
+
SceneDocumentLoader,
|
|
16057
16473
|
SceneExporter,
|
|
16058
16474
|
SceneInspector,
|
|
16059
16475
|
SceneObject,
|
|
@@ -16129,6 +16545,7 @@ export {
|
|
|
16129
16545
|
mergeBufferAttributes,
|
|
16130
16546
|
mergeBufferGeometries,
|
|
16131
16547
|
mergeVertices,
|
|
16548
|
+
parseSceneDocument,
|
|
16132
16549
|
prefix,
|
|
16133
16550
|
probeImageSize,
|
|
16134
16551
|
registerBrowserEnv,
|