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/node/index.mjs
CHANGED
|
@@ -863,8 +863,8 @@ var init_Textures = __esm({
|
|
|
863
863
|
for (let y = 0; y < size; y++) {
|
|
864
864
|
for (let x = 0; x < size; x++) {
|
|
865
865
|
const offset = (y * size + x) * 4;
|
|
866
|
-
const
|
|
867
|
-
data[offset] = data[offset + 2] =
|
|
866
|
+
const color2 = (x + y) % 2 === 0 ? 255 : 0;
|
|
867
|
+
data[offset] = data[offset + 2] = color2;
|
|
868
868
|
data[offset + 3] = 255;
|
|
869
869
|
}
|
|
870
870
|
}
|
|
@@ -1449,17 +1449,17 @@ var init_AssetKey = __esm({
|
|
|
1449
1449
|
var DisplayPosition, DISPLAY_POSITIONS;
|
|
1450
1450
|
var init_DisplayPosition = __esm({
|
|
1451
1451
|
"src/model/DisplayPosition.ts"() {
|
|
1452
|
-
DisplayPosition = /* @__PURE__ */ ((
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
return
|
|
1452
|
+
DisplayPosition = /* @__PURE__ */ ((DisplayPosition3) => {
|
|
1453
|
+
DisplayPosition3["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
|
|
1454
|
+
DisplayPosition3["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
|
|
1455
|
+
DisplayPosition3["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
|
|
1456
|
+
DisplayPosition3["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
|
|
1457
|
+
DisplayPosition3["GUI"] = "gui";
|
|
1458
|
+
DisplayPosition3["HEAD"] = "head";
|
|
1459
|
+
DisplayPosition3["GROUND"] = "ground";
|
|
1460
|
+
DisplayPosition3["FIXED"] = "fixed";
|
|
1461
|
+
DisplayPosition3["ON_SHELF"] = "on_shelf";
|
|
1462
|
+
return DisplayPosition3;
|
|
1463
1463
|
})(DisplayPosition || {});
|
|
1464
1464
|
DISPLAY_POSITIONS = Object.values(DisplayPosition);
|
|
1465
1465
|
}
|
|
@@ -1677,11 +1677,11 @@ var init_Models = __esm({
|
|
|
1677
1677
|
return this.PERSISTENT_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), (k1) => {
|
|
1678
1678
|
return AssetLoader.get(key, "model" /* MODEL */);
|
|
1679
1679
|
});
|
|
1680
|
-
}).then((
|
|
1681
|
-
if (
|
|
1682
|
-
|
|
1680
|
+
}).then((asset2) => {
|
|
1681
|
+
if (asset2) {
|
|
1682
|
+
asset2.key = key;
|
|
1683
1683
|
}
|
|
1684
|
-
return
|
|
1684
|
+
return asset2;
|
|
1685
1685
|
});
|
|
1686
1686
|
}
|
|
1687
1687
|
/**
|
|
@@ -1771,11 +1771,11 @@ var init_BlockStates = __esm({
|
|
|
1771
1771
|
return this.PERSISTENT_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), (k1) => {
|
|
1772
1772
|
return AssetLoader.get(key, "blockstate" /* BLOCKSTATE */);
|
|
1773
1773
|
});
|
|
1774
|
-
}).then((
|
|
1775
|
-
if (
|
|
1776
|
-
|
|
1774
|
+
}).then((asset2) => {
|
|
1775
|
+
if (asset2) {
|
|
1776
|
+
asset2.key = key;
|
|
1777
1777
|
}
|
|
1778
|
-
return
|
|
1778
|
+
return asset2;
|
|
1779
1779
|
});
|
|
1780
1780
|
}
|
|
1781
1781
|
static getAll(keys) {
|
|
@@ -1925,29 +1925,29 @@ function applyGenericRotation(axis, rotation, obj) {
|
|
|
1925
1925
|
break;
|
|
1926
1926
|
}
|
|
1927
1927
|
}
|
|
1928
|
-
function addBox3WireframeToObject(box, obj,
|
|
1928
|
+
function addBox3WireframeToObject(box, obj, color2 = 16777215, w = 2) {
|
|
1929
1929
|
let size = new Vector33();
|
|
1930
1930
|
box.getSize(size);
|
|
1931
1931
|
let boxGeo = new BoxGeometry2(size.x, size.y, size.z, 1, 1, 1);
|
|
1932
1932
|
let wireGeo = new EdgesGeometry(boxGeo);
|
|
1933
|
-
let wireMat = new LineBasicMaterial({ color, linewidth: w });
|
|
1933
|
+
let wireMat = new LineBasicMaterial({ color: color2, linewidth: w });
|
|
1934
1934
|
let wireframe = new LineSegments(wireGeo, wireMat);
|
|
1935
1935
|
obj.add(wireframe);
|
|
1936
1936
|
let axes = new AxesHelper(1);
|
|
1937
1937
|
obj.add(axes);
|
|
1938
1938
|
}
|
|
1939
|
-
function addWireframeToObject(obj,
|
|
1939
|
+
function addWireframeToObject(obj, color2 = 16777215, w = 2) {
|
|
1940
1940
|
let boxGeo = new BoxGeometry2(16, 16, 16, 1, 1, 1);
|
|
1941
1941
|
let wireGeo = new EdgesGeometry(boxGeo);
|
|
1942
|
-
let wireMat = new LineBasicMaterial({ color, linewidth: w });
|
|
1942
|
+
let wireMat = new LineBasicMaterial({ color: color2, linewidth: w });
|
|
1943
1943
|
let wireframe = new LineSegments(wireGeo, wireMat);
|
|
1944
1944
|
obj.add(wireframe);
|
|
1945
1945
|
let axes = new AxesHelper(1);
|
|
1946
1946
|
obj.add(axes);
|
|
1947
1947
|
}
|
|
1948
|
-
function addWireframeToMesh(geo, mesh,
|
|
1948
|
+
function addWireframeToMesh(geo, mesh, color2 = 16777215, w = 2) {
|
|
1949
1949
|
let wireGeo = new EdgesGeometry(geo);
|
|
1950
|
-
let wireMat = new LineBasicMaterial({ color, linewidth: w });
|
|
1950
|
+
let wireMat = new LineBasicMaterial({ color: color2, linewidth: w });
|
|
1951
1951
|
let wireframe = new LineSegments(wireGeo, wireMat);
|
|
1952
1952
|
mesh.add(wireframe);
|
|
1953
1953
|
let axes = new AxesHelper(1);
|
|
@@ -2394,27 +2394,27 @@ var init_PackFormats = __esm({
|
|
|
2394
2394
|
this.versions = /* @__PURE__ */ new Map();
|
|
2395
2395
|
}
|
|
2396
2396
|
/** Resolves pack formats from Mojang's client metadata hosted on assets.mcasset.cloud. */
|
|
2397
|
-
static async get(
|
|
2398
|
-
let pending = this.versions.get(
|
|
2397
|
+
static async get(version2, type) {
|
|
2398
|
+
let pending = this.versions.get(version2);
|
|
2399
2399
|
if (!pending || pending.expires <= Date.now()) {
|
|
2400
2400
|
pending = {
|
|
2401
|
-
formats: this.load(
|
|
2402
|
-
expires: ["latest", "release", "snapshot"].includes(
|
|
2401
|
+
formats: this.load(version2),
|
|
2402
|
+
expires: ["latest", "release", "snapshot"].includes(version2) ? Date.now() + 3e5 : Infinity
|
|
2403
2403
|
};
|
|
2404
|
-
this.versions.set(
|
|
2404
|
+
this.versions.set(version2, pending);
|
|
2405
2405
|
}
|
|
2406
2406
|
try {
|
|
2407
2407
|
return (await pending.formats)[type];
|
|
2408
2408
|
} catch (cause) {
|
|
2409
|
-
if (this.versions.get(
|
|
2409
|
+
if (this.versions.get(version2) === pending) this.versions.delete(version2);
|
|
2410
2410
|
const option = type === "assets" ? "resourcePackFormat" : "dataPackFormat";
|
|
2411
2411
|
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
2412
|
-
throw new Error(`Could not resolve the pack format for Minecraft ${
|
|
2412
|
+
throw new Error(`Could not resolve the pack format for Minecraft ${version2}. Set ArchiveAssetSource ${option} explicitly. ${reason}`);
|
|
2413
2413
|
}
|
|
2414
2414
|
}
|
|
2415
|
-
static async load(
|
|
2415
|
+
static async load(version2) {
|
|
2416
2416
|
const response = await Requests.genericRequest({
|
|
2417
|
-
url: `https://assets.mcasset.cloud/${encodeURIComponent(
|
|
2417
|
+
url: `https://assets.mcasset.cloud/${encodeURIComponent(version2)}/game-version.json`,
|
|
2418
2418
|
responseType: "json"
|
|
2419
2419
|
});
|
|
2420
2420
|
const data = response.data;
|
|
@@ -2502,7 +2502,7 @@ var init_ArchiveAssetSource = __esm({
|
|
|
2502
2502
|
}
|
|
2503
2503
|
async load(key, parser) {
|
|
2504
2504
|
const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
|
|
2505
|
-
const
|
|
2505
|
+
const version2 = AssetLoader.version;
|
|
2506
2506
|
let selectedPath = path;
|
|
2507
2507
|
let url;
|
|
2508
2508
|
try {
|
|
@@ -2510,7 +2510,7 @@ var init_ArchiveAssetSource = __esm({
|
|
|
2510
2510
|
if (key.rootType === "assets" || key.rootType === "data") {
|
|
2511
2511
|
const metadata = await this.getMetadata(key);
|
|
2512
2512
|
if (metadata.hasOverlays) {
|
|
2513
|
-
const format2 = (key.rootType === "assets" ? this.options.resourcePackFormat : this.options.dataPackFormat) ?? await PackFormats.get(
|
|
2513
|
+
const format2 = (key.rootType === "assets" ? this.options.resourcePackFormat : this.options.dataPackFormat) ?? await PackFormats.get(version2, key.rootType);
|
|
2514
2514
|
directories = metadata.overlayDirectories(format2);
|
|
2515
2515
|
}
|
|
2516
2516
|
}
|
|
@@ -2608,8 +2608,8 @@ var init_AssetLoader = __esm({
|
|
|
2608
2608
|
return this.ROOT.substring(this.ROOT.lastIndexOf("/") + 1);
|
|
2609
2609
|
}
|
|
2610
2610
|
/** Selects an mcasset.cloud version, updates the vanilla source, and clears in-memory caches. */
|
|
2611
|
-
static setVersion(
|
|
2612
|
-
this.ROOT = `https://assets.mcasset.cloud/${
|
|
2611
|
+
static setVersion(version2) {
|
|
2612
|
+
this.ROOT = `https://assets.mcasset.cloud/${version2}`;
|
|
2613
2613
|
const source = new HostedAssetSource(this.ROOT, { retryDefaults: false });
|
|
2614
2614
|
const index = this._SOURCES.findIndex((s) => s.key === "mcassets");
|
|
2615
2615
|
if (index !== -1) {
|
|
@@ -2678,8 +2678,8 @@ ${key}` : key;
|
|
|
2678
2678
|
const sources = [...this._SOURCES];
|
|
2679
2679
|
const results = [];
|
|
2680
2680
|
for (const { source } of sources) {
|
|
2681
|
-
const
|
|
2682
|
-
if (
|
|
2681
|
+
const asset2 = await source.get(key, parser);
|
|
2682
|
+
if (asset2 != void 0) results.push(asset2);
|
|
2683
2683
|
if (await source.blocks(key)) break;
|
|
2684
2684
|
}
|
|
2685
2685
|
return results;
|
|
@@ -2741,9 +2741,9 @@ var init_ModelTextures = __esm({
|
|
|
2741
2741
|
const pending = this.preload(key);
|
|
2742
2742
|
const cached2 = Caching.textureAssetCache.getIfPresent(keyStr);
|
|
2743
2743
|
try {
|
|
2744
|
-
const
|
|
2745
|
-
if (
|
|
2746
|
-
return await ImageLoader.infoToCanvasData(
|
|
2744
|
+
const asset2 = await pending;
|
|
2745
|
+
if (asset2) {
|
|
2746
|
+
return await ImageLoader.infoToCanvasData(asset2);
|
|
2747
2747
|
}
|
|
2748
2748
|
return void 0;
|
|
2749
2749
|
} catch (err) {
|
|
@@ -2757,10 +2757,10 @@ var init_ModelTextures = __esm({
|
|
|
2757
2757
|
static async preload(key) {
|
|
2758
2758
|
const keyStr = key.serialize();
|
|
2759
2759
|
return Caching.textureAssetCache.get(keyStr, (k) => {
|
|
2760
|
-
return AssetLoader.get(key, "image" /* IMAGE */).then((
|
|
2761
|
-
if (
|
|
2762
|
-
|
|
2763
|
-
return
|
|
2760
|
+
return AssetLoader.get(key, "image" /* IMAGE */).then((asset2) => {
|
|
2761
|
+
if (asset2)
|
|
2762
|
+
asset2.key = key;
|
|
2763
|
+
return asset2;
|
|
2764
2764
|
});
|
|
2765
2765
|
});
|
|
2766
2766
|
}
|
|
@@ -2773,10 +2773,10 @@ var init_ModelTextures = __esm({
|
|
|
2773
2773
|
const keyStr = key.serialize();
|
|
2774
2774
|
return Caching.textureMetaCache.get(keyStr, (k) => {
|
|
2775
2775
|
return this.PERSISTENT_META_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), (k1) => {
|
|
2776
|
-
return AssetLoader.get(key, "meta" /* META */).then((
|
|
2777
|
-
if (
|
|
2778
|
-
|
|
2779
|
-
return
|
|
2776
|
+
return AssetLoader.get(key, "meta" /* META */).then((asset2) => {
|
|
2777
|
+
if (asset2)
|
|
2778
|
+
asset2.key = key;
|
|
2779
|
+
return asset2;
|
|
2780
2780
|
});
|
|
2781
2781
|
});
|
|
2782
2782
|
});
|
|
@@ -3345,12 +3345,12 @@ var init_UVMapper = __esm({
|
|
|
3345
3345
|
} else {
|
|
3346
3346
|
uniqueTextureNames.push(textureKey);
|
|
3347
3347
|
const assetKey = AssetKey.parse("textures", textureValue, model.key);
|
|
3348
|
-
promises.push(ModelTextures.get(assetKey).then((
|
|
3349
|
-
if (!
|
|
3348
|
+
promises.push(ModelTextures.get(assetKey).then((asset2) => {
|
|
3349
|
+
if (!asset2) {
|
|
3350
3350
|
console.warn(p5, "Missing texture", assetKey);
|
|
3351
3351
|
return;
|
|
3352
3352
|
}
|
|
3353
|
-
textureMap[textureKey] = new WrappedImage(
|
|
3353
|
+
textureMap[textureKey] = new WrappedImage(asset2);
|
|
3354
3354
|
}));
|
|
3355
3355
|
promises.push(ModelTextures.getMeta(assetKey).then((meta) => {
|
|
3356
3356
|
metaMap[textureKey] = meta;
|
|
@@ -3694,10 +3694,10 @@ var init_Entities = __esm({
|
|
|
3694
3694
|
const collect = async (path) => {
|
|
3695
3695
|
const prefix2 = path ? `${path}/` : "";
|
|
3696
3696
|
const key = new AssetKey(DEFAULT_NAMESPACE, `${prefix2}_list`, void 0, void 0, "entity-models", ".json");
|
|
3697
|
-
const
|
|
3698
|
-
if (!
|
|
3699
|
-
const files =
|
|
3700
|
-
const children = await Promise.all(
|
|
3697
|
+
const list2 = await Caching.listAssetCache.get(key.serialize(), () => AssetLoader.get(key, "list" /* LIST */));
|
|
3698
|
+
if (!list2) return [];
|
|
3699
|
+
const files = list2.files.filter((file) => file.endsWith(".json") && file !== "_list.json").map((file) => `${prefix2}${file.slice(0, -5)}`);
|
|
3700
|
+
const children = await Promise.all(list2.directories.map((directory) => collect(`${prefix2}${directory}`)));
|
|
3701
3701
|
return [...files, ...children.flat()];
|
|
3702
3702
|
};
|
|
3703
3703
|
return collect("");
|
|
@@ -3781,8 +3781,8 @@ var init_Entities = __esm({
|
|
|
3781
3781
|
if (await ModelTextures.get(texture2)) return texture2;
|
|
3782
3782
|
}
|
|
3783
3783
|
const listKey = new AssetKey(modelKey.namespace, "_list", `${name}_variant`, void 0, "data", ".json", root);
|
|
3784
|
-
const
|
|
3785
|
-
const files =
|
|
3784
|
+
const list2 = await AssetLoader.get(listKey, "list" /* LIST */);
|
|
3785
|
+
const files = list2?.files.filter((file2) => file2.endsWith(".json") && file2 !== "_list.json");
|
|
3786
3786
|
const file = files?.find((file2) => file2 === "temperate.json") ?? files?.[0];
|
|
3787
3787
|
if (!file) return void 0;
|
|
3788
3788
|
const variantKey = new AssetKey(modelKey.namespace, file.slice(0, -5), `${name}_variant`, void 0, "data", ".json", root);
|
|
@@ -3887,27 +3887,27 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
3887
3887
|
for (const layer of layers) {
|
|
3888
3888
|
const objects = [];
|
|
3889
3889
|
if (poses) {
|
|
3890
|
-
layer.traverse((
|
|
3891
|
-
if (poses.has(
|
|
3890
|
+
layer.traverse((object3) => {
|
|
3891
|
+
if (poses.has(object3)) objects.push(object3);
|
|
3892
3892
|
});
|
|
3893
3893
|
} else {
|
|
3894
3894
|
for (const bone of Object.keys(animation.bones)) {
|
|
3895
|
-
const
|
|
3896
|
-
if (
|
|
3895
|
+
const object3 = layer.getObjectByName(`group:${bone}`);
|
|
3896
|
+
if (object3) objects.push(object3);
|
|
3897
3897
|
}
|
|
3898
3898
|
}
|
|
3899
|
-
for (const
|
|
3900
|
-
const bone =
|
|
3901
|
-
const pose = poses?.get(
|
|
3899
|
+
for (const object3 of objects) {
|
|
3900
|
+
const bone = object3.name.slice("group:".length);
|
|
3901
|
+
const pose = poses?.get(object3);
|
|
3902
3902
|
this.parts.push({
|
|
3903
3903
|
bone,
|
|
3904
|
-
object:
|
|
3905
|
-
position:
|
|
3906
|
-
rotation:
|
|
3907
|
-
scale:
|
|
3908
|
-
basePosition: pose ? new Vector35(...pose.offset) :
|
|
3909
|
-
baseRotation: pose ? new Euler3(...pose.rotation, "ZYX") :
|
|
3910
|
-
baseScale: pose ? new Vector35(...pose.scale ?? [1, 1, 1]) :
|
|
3904
|
+
object: object3,
|
|
3905
|
+
position: object3.position.clone(),
|
|
3906
|
+
rotation: object3.rotation.clone(),
|
|
3907
|
+
scale: object3.scale.clone(),
|
|
3908
|
+
basePosition: pose ? new Vector35(...pose.offset) : object3.position.clone(),
|
|
3909
|
+
baseRotation: pose ? new Euler3(...pose.rotation, "ZYX") : object3.rotation.clone(),
|
|
3910
|
+
baseScale: pose ? new Vector35(...pose.scale ?? [1, 1, 1]) : object3.scale.clone()
|
|
3911
3911
|
});
|
|
3912
3912
|
}
|
|
3913
3913
|
}
|
|
@@ -4273,10 +4273,10 @@ var init_SceneObject = __esm({
|
|
|
4273
4273
|
return new InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
|
|
4274
4274
|
};
|
|
4275
4275
|
const matrix = grow(mesh.instanceMatrix, 0);
|
|
4276
|
-
const
|
|
4276
|
+
const color2 = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
|
|
4277
4277
|
mesh.dispose();
|
|
4278
4278
|
mesh.instanceMatrix = matrix;
|
|
4279
|
-
mesh.instanceColor =
|
|
4279
|
+
mesh.instanceColor = color2;
|
|
4280
4280
|
}
|
|
4281
4281
|
*activeInstanceIndices() {
|
|
4282
4282
|
if (this.instanceMesh) {
|
|
@@ -4449,15 +4449,15 @@ var init_SceneObject = __esm({
|
|
|
4449
4449
|
}
|
|
4450
4450
|
}
|
|
4451
4451
|
//</editor-fold>
|
|
4452
|
-
toggleObjectVisibility(
|
|
4453
|
-
if (
|
|
4452
|
+
toggleObjectVisibility(object3, visible) {
|
|
4453
|
+
if (object3) {
|
|
4454
4454
|
if (typeof visible !== "undefined") {
|
|
4455
|
-
|
|
4455
|
+
object3.visible = visible;
|
|
4456
4456
|
} else {
|
|
4457
|
-
|
|
4457
|
+
object3.visible = !object3.visible;
|
|
4458
4458
|
}
|
|
4459
4459
|
this.notifyDirty();
|
|
4460
|
-
return
|
|
4460
|
+
return object3.visible;
|
|
4461
4461
|
}
|
|
4462
4462
|
this.notifyDirty();
|
|
4463
4463
|
return false;
|
|
@@ -4753,8 +4753,8 @@ var init_EntityObject = __esm({
|
|
|
4753
4753
|
this.scrollMaterials.push({ material: mat, offset: mat.map.offset, speed: scroll });
|
|
4754
4754
|
}
|
|
4755
4755
|
}
|
|
4756
|
-
this.getLayerGroup(name)?.traverse((
|
|
4757
|
-
if (isMesh(
|
|
4756
|
+
this.getLayerGroup(name)?.traverse((object3) => {
|
|
4757
|
+
if (isMesh(object3)) object3.material = mat;
|
|
4758
4758
|
});
|
|
4759
4759
|
}));
|
|
4760
4760
|
if (!this.children.length) {
|
|
@@ -5093,8 +5093,8 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
5093
5093
|
return geometry;
|
|
5094
5094
|
}
|
|
5095
5095
|
}
|
|
5096
|
-
function computeMorphedAttributes(
|
|
5097
|
-
if (
|
|
5096
|
+
function computeMorphedAttributes(object3) {
|
|
5097
|
+
if (object3.geometry.isBufferGeometry !== true) {
|
|
5098
5098
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
5099
5099
|
return null;
|
|
5100
5100
|
}
|
|
@@ -5107,11 +5107,11 @@ function computeMorphedAttributes(object2) {
|
|
|
5107
5107
|
const _morphA = new Vector310();
|
|
5108
5108
|
const _morphB = new Vector310();
|
|
5109
5109
|
const _morphC = new Vector310();
|
|
5110
|
-
function _calculateMorphedAttributeData(
|
|
5110
|
+
function _calculateMorphedAttributeData(object4, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
5111
5111
|
_vA.fromBufferAttribute(attribute, a2);
|
|
5112
5112
|
_vB.fromBufferAttribute(attribute, b2);
|
|
5113
5113
|
_vC.fromBufferAttribute(attribute, c2);
|
|
5114
|
-
const morphInfluences =
|
|
5114
|
+
const morphInfluences = object4.morphTargetInfluences;
|
|
5115
5115
|
if (material2.morphTargets && morphAttribute && morphInfluences) {
|
|
5116
5116
|
_morphA.set(0, 0, 0);
|
|
5117
5117
|
_morphB.set(0, 0, 0);
|
|
@@ -5137,10 +5137,10 @@ function computeMorphedAttributes(object2) {
|
|
|
5137
5137
|
_vB.add(_morphB);
|
|
5138
5138
|
_vC.add(_morphC);
|
|
5139
5139
|
}
|
|
5140
|
-
if (
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5140
|
+
if (object4.isSkinnedMesh) {
|
|
5141
|
+
object4.boneTransform(a2, _vA);
|
|
5142
|
+
object4.boneTransform(b2, _vB);
|
|
5143
|
+
object4.boneTransform(c2, _vC);
|
|
5144
5144
|
}
|
|
5145
5145
|
modifiedAttributeArray[a2 * 3 + 0] = _vA.x;
|
|
5146
5146
|
modifiedAttributeArray[a2 * 3 + 1] = _vA.y;
|
|
@@ -5152,8 +5152,8 @@ function computeMorphedAttributes(object2) {
|
|
|
5152
5152
|
modifiedAttributeArray[c2 * 3 + 1] = _vC.y;
|
|
5153
5153
|
modifiedAttributeArray[c2 * 3 + 2] = _vC.z;
|
|
5154
5154
|
}
|
|
5155
|
-
const geometry =
|
|
5156
|
-
const material =
|
|
5155
|
+
const geometry = object3.geometry;
|
|
5156
|
+
const material = object3.material;
|
|
5157
5157
|
let a, b, c;
|
|
5158
5158
|
const index = geometry.index;
|
|
5159
5159
|
const positionAttribute = geometry.attributes.position;
|
|
@@ -5180,7 +5180,7 @@ function computeMorphedAttributes(object2) {
|
|
|
5180
5180
|
b = index.getX(j + 1);
|
|
5181
5181
|
c = index.getX(j + 2);
|
|
5182
5182
|
_calculateMorphedAttributeData(
|
|
5183
|
-
|
|
5183
|
+
object3,
|
|
5184
5184
|
groupMaterial,
|
|
5185
5185
|
positionAttribute,
|
|
5186
5186
|
morphPosition,
|
|
@@ -5191,7 +5191,7 @@ function computeMorphedAttributes(object2) {
|
|
|
5191
5191
|
modifiedPosition
|
|
5192
5192
|
);
|
|
5193
5193
|
_calculateMorphedAttributeData(
|
|
5194
|
-
|
|
5194
|
+
object3,
|
|
5195
5195
|
groupMaterial,
|
|
5196
5196
|
normalAttribute,
|
|
5197
5197
|
morphNormal,
|
|
@@ -5211,7 +5211,7 @@ function computeMorphedAttributes(object2) {
|
|
|
5211
5211
|
b = index.getX(i + 1);
|
|
5212
5212
|
c = index.getX(i + 2);
|
|
5213
5213
|
_calculateMorphedAttributeData(
|
|
5214
|
-
|
|
5214
|
+
object3,
|
|
5215
5215
|
material,
|
|
5216
5216
|
positionAttribute,
|
|
5217
5217
|
morphPosition,
|
|
@@ -5222,7 +5222,7 @@ function computeMorphedAttributes(object2) {
|
|
|
5222
5222
|
modifiedPosition
|
|
5223
5223
|
);
|
|
5224
5224
|
_calculateMorphedAttributeData(
|
|
5225
|
-
|
|
5225
|
+
object3,
|
|
5226
5226
|
material,
|
|
5227
5227
|
normalAttribute,
|
|
5228
5228
|
morphNormal,
|
|
@@ -5246,7 +5246,7 @@ function computeMorphedAttributes(object2) {
|
|
|
5246
5246
|
b = j + 1;
|
|
5247
5247
|
c = j + 2;
|
|
5248
5248
|
_calculateMorphedAttributeData(
|
|
5249
|
-
|
|
5249
|
+
object3,
|
|
5250
5250
|
groupMaterial,
|
|
5251
5251
|
positionAttribute,
|
|
5252
5252
|
morphPosition,
|
|
@@ -5257,7 +5257,7 @@ function computeMorphedAttributes(object2) {
|
|
|
5257
5257
|
modifiedPosition
|
|
5258
5258
|
);
|
|
5259
5259
|
_calculateMorphedAttributeData(
|
|
5260
|
-
|
|
5260
|
+
object3,
|
|
5261
5261
|
groupMaterial,
|
|
5262
5262
|
normalAttribute,
|
|
5263
5263
|
morphNormal,
|
|
@@ -5277,7 +5277,7 @@ function computeMorphedAttributes(object2) {
|
|
|
5277
5277
|
b = i + 1;
|
|
5278
5278
|
c = i + 2;
|
|
5279
5279
|
_calculateMorphedAttributeData(
|
|
5280
|
-
|
|
5280
|
+
object3,
|
|
5281
5281
|
material,
|
|
5282
5282
|
positionAttribute,
|
|
5283
5283
|
morphPosition,
|
|
@@ -5288,7 +5288,7 @@ function computeMorphedAttributes(object2) {
|
|
|
5288
5288
|
modifiedPosition
|
|
5289
5289
|
);
|
|
5290
5290
|
_calculateMorphedAttributeData(
|
|
5291
|
-
|
|
5291
|
+
object3,
|
|
5292
5292
|
material,
|
|
5293
5293
|
normalAttribute,
|
|
5294
5294
|
morphNormal,
|
|
@@ -5544,9 +5544,9 @@ var init_ItemTints = __esm({
|
|
|
5544
5544
|
}));
|
|
5545
5545
|
return colors;
|
|
5546
5546
|
}
|
|
5547
|
-
static rgb(
|
|
5548
|
-
if (!Array.isArray(
|
|
5549
|
-
const [red, green, blue] =
|
|
5547
|
+
static rgb(color2) {
|
|
5548
|
+
if (!Array.isArray(color2)) return color2 & 16777215;
|
|
5549
|
+
const [red, green, blue] = color2.map((channel) => Math.floor(Math.fround(Math.fround(channel) * 255)));
|
|
5550
5550
|
return red << 16 | green << 8 | blue;
|
|
5551
5551
|
}
|
|
5552
5552
|
};
|
|
@@ -5602,13 +5602,13 @@ var init_ModelObject = __esm({
|
|
|
5602
5602
|
transform.multiply(new Matrix49().makeTranslation(-8, -8, -8));
|
|
5603
5603
|
try {
|
|
5604
5604
|
for (const part of parts) {
|
|
5605
|
-
const
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
this.add(
|
|
5610
|
-
await
|
|
5611
|
-
|
|
5605
|
+
const object3 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
|
|
5606
|
+
object3.matrix.copy(transform).multiply(part.transform);
|
|
5607
|
+
object3.matrixWorldNeedsUpdate = true;
|
|
5608
|
+
object3.matrixAutoUpdate = false;
|
|
5609
|
+
this.add(object3);
|
|
5610
|
+
await object3.init();
|
|
5611
|
+
object3.iterateAllMeshes((mesh) => {
|
|
5612
5612
|
const source = mesh.material;
|
|
5613
5613
|
let material = this.specialMaterials.get(source);
|
|
5614
5614
|
if (!material) {
|
|
@@ -5619,7 +5619,7 @@ var init_ModelObject = __esm({
|
|
|
5619
5619
|
mesh.material = material;
|
|
5620
5620
|
});
|
|
5621
5621
|
for (const [name, rotation] of Object.entries(part.rotations)) {
|
|
5622
|
-
|
|
5622
|
+
object3.getGroupByName(name)?.rotation.set(...rotation, "ZYX");
|
|
5623
5623
|
}
|
|
5624
5624
|
}
|
|
5625
5625
|
} catch (error) {
|
|
@@ -5672,9 +5672,9 @@ var init_ModelObject = __esm({
|
|
|
5672
5672
|
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
5673
5673
|
const tint = this.options.tints[tintIndex];
|
|
5674
5674
|
if (tint === void 0) continue;
|
|
5675
|
-
const
|
|
5675
|
+
const color2 = new Color9(tint);
|
|
5676
5676
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
5677
|
-
|
|
5677
|
+
color2.toArray(colors, (faceIndex * 4 + vertex) * 3);
|
|
5678
5678
|
}
|
|
5679
5679
|
}
|
|
5680
5680
|
elGeo.setAttribute("color", new BufferAttribute5(colors, 3));
|
|
@@ -5989,9 +5989,9 @@ var init_FluidModelObject = __esm({
|
|
|
5989
5989
|
}
|
|
5990
5990
|
}
|
|
5991
5991
|
geometry.clearGroups();
|
|
5992
|
-
const
|
|
5992
|
+
const color2 = new Color10(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
|
|
5993
5993
|
const colors = new Float32Array(geometry.getAttribute("position").count * 3);
|
|
5994
|
-
for (let i = 0; i < colors.length; i += 3)
|
|
5994
|
+
for (let i = 0; i < colors.length; i += 3) color2.toArray(colors, i);
|
|
5995
5995
|
geometry.setAttribute("color", new BufferAttribute6(colors, 3));
|
|
5996
5996
|
geometry.computeBoundingBox();
|
|
5997
5997
|
geometry.computeBoundingSphere();
|
|
@@ -6084,9 +6084,9 @@ var NodeEnv = class {
|
|
|
6084
6084
|
imageSize(data) {
|
|
6085
6085
|
return imageSize(Buffer.isBuffer(data) ? data : Buffer.from(data));
|
|
6086
6086
|
}
|
|
6087
|
-
openCache(name,
|
|
6087
|
+
openCache(name, version2) {
|
|
6088
6088
|
return new NodeCache(NodePersist.create({
|
|
6089
|
-
dir: name +
|
|
6089
|
+
dir: name + version2,
|
|
6090
6090
|
encoding: "utf8"
|
|
6091
6091
|
}));
|
|
6092
6092
|
}
|
|
@@ -6247,8 +6247,8 @@ var Fonts = class {
|
|
|
6247
6247
|
const stack = await AssetLoader.getAll(key, "json" /* JSON */);
|
|
6248
6248
|
if (stack.length === 0) throw new Error(`Could not load font ${key.toNamespacedString()}`);
|
|
6249
6249
|
const glyphs = /* @__PURE__ */ new Map();
|
|
6250
|
-
for (const
|
|
6251
|
-
for (const provider of
|
|
6250
|
+
for (const asset2 of stack) {
|
|
6251
|
+
for (const provider of asset2.providers) {
|
|
6252
6252
|
if (provider.filter?.uniform || provider.filter?.jp) continue;
|
|
6253
6253
|
let provided;
|
|
6254
6254
|
switch (provider.type) {
|
|
@@ -6394,13 +6394,13 @@ var OBJExporter = class {
|
|
|
6394
6394
|
* @param {Object3D} object - The 3D object to export.
|
|
6395
6395
|
* @return {string} The exported OBJ.
|
|
6396
6396
|
*/
|
|
6397
|
-
parse(
|
|
6397
|
+
parse(object3) {
|
|
6398
6398
|
let output = "";
|
|
6399
6399
|
let indexVertex = 0;
|
|
6400
6400
|
let indexVertexUvs = 0;
|
|
6401
6401
|
let indexNormals = 0;
|
|
6402
6402
|
const vertex = new Vector37();
|
|
6403
|
-
const
|
|
6403
|
+
const color2 = new Color4();
|
|
6404
6404
|
const normal = new Vector37();
|
|
6405
6405
|
const uv = new Vector22();
|
|
6406
6406
|
const face = [];
|
|
@@ -6499,9 +6499,9 @@ var OBJExporter = class {
|
|
|
6499
6499
|
vertex.applyMatrix4(points.matrixWorld);
|
|
6500
6500
|
output += "v " + vertex.x + " " + vertex.y + " " + vertex.z;
|
|
6501
6501
|
if (colors !== void 0) {
|
|
6502
|
-
|
|
6503
|
-
ColorManagement.workingToColorSpace(
|
|
6504
|
-
output += " " +
|
|
6502
|
+
color2.fromBufferAttribute(colors, i);
|
|
6503
|
+
ColorManagement.workingToColorSpace(color2, SRGBColorSpace3);
|
|
6504
|
+
output += " " + color2.r + " " + color2.g + " " + color2.b;
|
|
6505
6505
|
}
|
|
6506
6506
|
output += "\n";
|
|
6507
6507
|
}
|
|
@@ -6513,7 +6513,7 @@ var OBJExporter = class {
|
|
|
6513
6513
|
}
|
|
6514
6514
|
indexVertex += nbVertex;
|
|
6515
6515
|
}
|
|
6516
|
-
|
|
6516
|
+
object3.traverse(function(child) {
|
|
6517
6517
|
if (child.isMesh === true) {
|
|
6518
6518
|
parseMesh(child);
|
|
6519
6519
|
}
|
|
@@ -6547,9 +6547,9 @@ var PLYExporter = class {
|
|
|
6547
6547
|
* @param {PLYExporter~Options} options - The export options.
|
|
6548
6548
|
* @return {?(string|ArrayBuffer)} The exported PLY.
|
|
6549
6549
|
*/
|
|
6550
|
-
parse(
|
|
6550
|
+
parse(object3, onDone, options = {}) {
|
|
6551
6551
|
function traverseMeshes(cb) {
|
|
6552
|
-
|
|
6552
|
+
object3.traverse(function(child) {
|
|
6553
6553
|
if (child.isMesh === true || child.isPoints) {
|
|
6554
6554
|
const mesh = child;
|
|
6555
6555
|
const geometry = mesh.geometry;
|
|
@@ -6582,7 +6582,7 @@ var PLYExporter = class {
|
|
|
6582
6582
|
for (const name of customAttributeNames) customTypes[name] = "float";
|
|
6583
6583
|
let vertexCount = 0;
|
|
6584
6584
|
let faceCount = 0;
|
|
6585
|
-
|
|
6585
|
+
object3.traverse(function(child) {
|
|
6586
6586
|
if (child.isMesh === true) {
|
|
6587
6587
|
const mesh = child;
|
|
6588
6588
|
const geometry = mesh.geometry;
|
|
@@ -7204,8 +7204,8 @@ function equalArray(array1, array2) {
|
|
|
7204
7204
|
return element === array2[index];
|
|
7205
7205
|
});
|
|
7206
7206
|
}
|
|
7207
|
-
function stringToArrayBuffer(
|
|
7208
|
-
return new TextEncoder().encode(
|
|
7207
|
+
function stringToArrayBuffer(text2) {
|
|
7208
|
+
return new TextEncoder().encode(text2).buffer;
|
|
7209
7209
|
}
|
|
7210
7210
|
function isIdentityMatrix(matrix) {
|
|
7211
7211
|
return equalArray(matrix.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
@@ -7398,12 +7398,12 @@ var GLTFWriter = class {
|
|
|
7398
7398
|
* @param {THREE.Object3D|THREE.Material|THREE.BufferGeometry|THREE.AnimationClip} object
|
|
7399
7399
|
* @param {Object} objectDef
|
|
7400
7400
|
*/
|
|
7401
|
-
serializeUserData(
|
|
7402
|
-
if (Object.keys(
|
|
7401
|
+
serializeUserData(object3, objectDef) {
|
|
7402
|
+
if (Object.keys(object3.userData).length === 0) return;
|
|
7403
7403
|
const options = this.options;
|
|
7404
7404
|
const extensionsUsed = this.extensionsUsed;
|
|
7405
7405
|
try {
|
|
7406
|
-
const json = JSON.parse(JSON.stringify(
|
|
7406
|
+
const json = JSON.parse(JSON.stringify(object3.userData));
|
|
7407
7407
|
if (options.includeCustomExtensions && json.gltfExtensions) {
|
|
7408
7408
|
if (objectDef.extensions === void 0) objectDef.extensions = {};
|
|
7409
7409
|
for (const extensionName in json.gltfExtensions) {
|
|
@@ -7414,7 +7414,7 @@ var GLTFWriter = class {
|
|
|
7414
7414
|
}
|
|
7415
7415
|
if (Object.keys(json).length > 0) objectDef.extras = json;
|
|
7416
7416
|
} catch (error) {
|
|
7417
|
-
console.warn("THREE.GLTFExporter: userData of '" +
|
|
7417
|
+
console.warn("THREE.GLTFExporter: userData of '" + object3.name + "' won't be serialized because of JSON.stringify error - " + error.message);
|
|
7418
7418
|
}
|
|
7419
7419
|
}
|
|
7420
7420
|
/**
|
|
@@ -7923,9 +7923,9 @@ var GLTFWriter = class {
|
|
|
7923
7923
|
if (material.isMeshStandardMaterial !== true && material.isMeshBasicMaterial !== true) {
|
|
7924
7924
|
console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");
|
|
7925
7925
|
}
|
|
7926
|
-
const
|
|
7927
|
-
if (!equalArray(
|
|
7928
|
-
materialDef.pbrMetallicRoughness.baseColorFactor =
|
|
7926
|
+
const color2 = material.color.toArray().concat([material.opacity]);
|
|
7927
|
+
if (!equalArray(color2, [1, 1, 1, 1])) {
|
|
7928
|
+
materialDef.pbrMetallicRoughness.baseColorFactor = color2;
|
|
7929
7929
|
}
|
|
7930
7930
|
if (material.isMeshStandardMaterial) {
|
|
7931
7931
|
materialDef.pbrMetallicRoughness.metallicFactor = material.metalness;
|
|
@@ -8340,13 +8340,13 @@ var GLTFWriter = class {
|
|
|
8340
8340
|
* @param {THREE.Object3D} object
|
|
8341
8341
|
* @return {?number}
|
|
8342
8342
|
*/
|
|
8343
|
-
processSkin(
|
|
8343
|
+
processSkin(object3) {
|
|
8344
8344
|
const json = this.json;
|
|
8345
8345
|
const nodeMap = this.nodeMap;
|
|
8346
|
-
const node = json.nodes[nodeMap.get(
|
|
8347
|
-
const skeleton =
|
|
8346
|
+
const node = json.nodes[nodeMap.get(object3)];
|
|
8347
|
+
const skeleton = object3.skeleton;
|
|
8348
8348
|
if (skeleton === void 0) return null;
|
|
8349
|
-
const rootJoint =
|
|
8349
|
+
const rootJoint = object3.skeleton.bones[0];
|
|
8350
8350
|
if (rootJoint === void 0) return null;
|
|
8351
8351
|
const joints = [];
|
|
8352
8352
|
const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
|
|
@@ -8354,7 +8354,7 @@ var GLTFWriter = class {
|
|
|
8354
8354
|
for (let i = 0; i < skeleton.bones.length; ++i) {
|
|
8355
8355
|
joints.push(nodeMap.get(skeleton.bones[i]));
|
|
8356
8356
|
temporaryBoneInverse.copy(skeleton.boneInverses[i]);
|
|
8357
|
-
temporaryBoneInverse.multiply(
|
|
8357
|
+
temporaryBoneInverse.multiply(object3.bindMatrix).toArray(inverseBindMatrices, i * 16);
|
|
8358
8358
|
}
|
|
8359
8359
|
if (json.skins === void 0) json.skins = [];
|
|
8360
8360
|
json.skins.push({
|
|
@@ -8370,19 +8370,19 @@ var GLTFWriter = class {
|
|
|
8370
8370
|
* @param {THREE.Object3D} object Object3D to processNodeAsync
|
|
8371
8371
|
* @return {Promise<number>} Index of the node in the nodes list
|
|
8372
8372
|
*/
|
|
8373
|
-
async processNodeAsync(
|
|
8373
|
+
async processNodeAsync(object3) {
|
|
8374
8374
|
const json = this.json;
|
|
8375
8375
|
const options = this.options;
|
|
8376
8376
|
const nodeMap = this.nodeMap;
|
|
8377
8377
|
if (!json.nodes) json.nodes = [];
|
|
8378
|
-
if (
|
|
8379
|
-
return await this._processNodeWithPivotAsync(
|
|
8378
|
+
if (object3.pivot !== null) {
|
|
8379
|
+
return await this._processNodeWithPivotAsync(object3);
|
|
8380
8380
|
}
|
|
8381
8381
|
const nodeDef = {};
|
|
8382
8382
|
if (options.trs) {
|
|
8383
|
-
const rotation =
|
|
8384
|
-
const position =
|
|
8385
|
-
const scale =
|
|
8383
|
+
const rotation = object3.quaternion.toArray();
|
|
8384
|
+
const position = object3.position.toArray();
|
|
8385
|
+
const scale = object3.scale.toArray();
|
|
8386
8386
|
if (!equalArray(rotation, [0, 0, 0, 1])) {
|
|
8387
8387
|
nodeDef.rotation = rotation;
|
|
8388
8388
|
}
|
|
@@ -8393,28 +8393,28 @@ var GLTFWriter = class {
|
|
|
8393
8393
|
nodeDef.scale = scale;
|
|
8394
8394
|
}
|
|
8395
8395
|
} else {
|
|
8396
|
-
if (
|
|
8397
|
-
|
|
8396
|
+
if (object3.matrixAutoUpdate) {
|
|
8397
|
+
object3.updateMatrix();
|
|
8398
8398
|
}
|
|
8399
|
-
if (isIdentityMatrix(
|
|
8400
|
-
nodeDef.matrix =
|
|
8399
|
+
if (isIdentityMatrix(object3.matrix) === false) {
|
|
8400
|
+
nodeDef.matrix = object3.matrix.elements;
|
|
8401
8401
|
}
|
|
8402
8402
|
}
|
|
8403
|
-
if (
|
|
8404
|
-
this.serializeUserData(
|
|
8405
|
-
if (
|
|
8406
|
-
const meshIndex = await this.processMeshAsync(
|
|
8403
|
+
if (object3.name !== "") nodeDef.name = String(object3.name);
|
|
8404
|
+
this.serializeUserData(object3, nodeDef);
|
|
8405
|
+
if (object3.isMesh || object3.isLine || object3.isPoints) {
|
|
8406
|
+
const meshIndex = await this.processMeshAsync(object3);
|
|
8407
8407
|
if (meshIndex !== null) nodeDef.mesh = meshIndex;
|
|
8408
|
-
} else if (
|
|
8409
|
-
nodeDef.camera = this.processCamera(
|
|
8408
|
+
} else if (object3.isCamera) {
|
|
8409
|
+
nodeDef.camera = this.processCamera(object3);
|
|
8410
8410
|
}
|
|
8411
|
-
if (
|
|
8411
|
+
if (object3.isSkinnedMesh) this.skins.push(object3);
|
|
8412
8412
|
const nodeIndex = json.nodes.push(nodeDef) - 1;
|
|
8413
|
-
nodeMap.set(
|
|
8414
|
-
if (
|
|
8413
|
+
nodeMap.set(object3, nodeIndex);
|
|
8414
|
+
if (object3.children.length > 0) {
|
|
8415
8415
|
const children = [];
|
|
8416
|
-
for (let i = 0, l =
|
|
8417
|
-
const child =
|
|
8416
|
+
for (let i = 0, l = object3.children.length; i < l; i++) {
|
|
8417
|
+
const child = object3.children[i];
|
|
8418
8418
|
if (child.visible || options.onlyVisible === false) {
|
|
8419
8419
|
const childNodeIndex = await this.processNodeAsync(child);
|
|
8420
8420
|
if (childNodeIndex !== null) children.push(childNodeIndex);
|
|
@@ -8423,7 +8423,7 @@ var GLTFWriter = class {
|
|
|
8423
8423
|
if (children.length > 0) nodeDef.children = children;
|
|
8424
8424
|
}
|
|
8425
8425
|
await this._invokeAllAsync(function(ext) {
|
|
8426
|
-
ext.writeNode && ext.writeNode(
|
|
8426
|
+
ext.writeNode && ext.writeNode(object3, nodeDef);
|
|
8427
8427
|
});
|
|
8428
8428
|
return nodeIndex;
|
|
8429
8429
|
}
|
|
@@ -8432,19 +8432,19 @@ var GLTFWriter = class {
|
|
|
8432
8432
|
* @param {THREE.Object3D} object Object3D with pivot
|
|
8433
8433
|
* @return {Promise<number>} Index of the container node
|
|
8434
8434
|
*/
|
|
8435
|
-
async _processNodeWithPivotAsync(
|
|
8435
|
+
async _processNodeWithPivotAsync(object3) {
|
|
8436
8436
|
const json = this.json;
|
|
8437
8437
|
const options = this.options;
|
|
8438
8438
|
const nodeMap = this.nodeMap;
|
|
8439
|
-
const pivot =
|
|
8439
|
+
const pivot = object3.pivot;
|
|
8440
8440
|
const containerDef = {};
|
|
8441
|
-
const rotation =
|
|
8441
|
+
const rotation = object3.quaternion.toArray();
|
|
8442
8442
|
const position = [
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
|
|
8443
|
+
object3.position.x + pivot.x,
|
|
8444
|
+
object3.position.y + pivot.y,
|
|
8445
|
+
object3.position.z + pivot.z
|
|
8446
8446
|
];
|
|
8447
|
-
const scale =
|
|
8447
|
+
const scale = object3.scale.toArray();
|
|
8448
8448
|
if (!equalArray(rotation, [0, 0, 0, 1])) {
|
|
8449
8449
|
containerDef.rotation = rotation;
|
|
8450
8450
|
}
|
|
@@ -8455,28 +8455,28 @@ var GLTFWriter = class {
|
|
|
8455
8455
|
containerDef.scale = scale;
|
|
8456
8456
|
}
|
|
8457
8457
|
containerDef.extras = { pivot: pivot.toArray() };
|
|
8458
|
-
if (
|
|
8459
|
-
this.serializeUserData(
|
|
8458
|
+
if (object3.name !== "") containerDef.name = String(object3.name);
|
|
8459
|
+
this.serializeUserData(object3, containerDef);
|
|
8460
8460
|
const containerIndex = json.nodes.push(containerDef) - 1;
|
|
8461
|
-
nodeMap.set(
|
|
8461
|
+
nodeMap.set(object3, containerIndex);
|
|
8462
8462
|
const childDef = {};
|
|
8463
8463
|
const childPosition = [-pivot.x, -pivot.y, -pivot.z];
|
|
8464
8464
|
if (!equalArray(childPosition, [0, 0, 0])) {
|
|
8465
8465
|
childDef.translation = childPosition;
|
|
8466
8466
|
}
|
|
8467
|
-
if (
|
|
8468
|
-
const meshIndex = await this.processMeshAsync(
|
|
8467
|
+
if (object3.isMesh || object3.isLine || object3.isPoints) {
|
|
8468
|
+
const meshIndex = await this.processMeshAsync(object3);
|
|
8469
8469
|
if (meshIndex !== null) childDef.mesh = meshIndex;
|
|
8470
|
-
} else if (
|
|
8471
|
-
childDef.camera = this.processCamera(
|
|
8470
|
+
} else if (object3.isCamera) {
|
|
8471
|
+
childDef.camera = this.processCamera(object3);
|
|
8472
8472
|
}
|
|
8473
|
-
if (
|
|
8473
|
+
if (object3.isSkinnedMesh) this.skins.push(object3);
|
|
8474
8474
|
const childIndex = json.nodes.push(childDef) - 1;
|
|
8475
8475
|
const containerChildren = [childIndex];
|
|
8476
|
-
if (
|
|
8476
|
+
if (object3.children.length > 0) {
|
|
8477
8477
|
const grandchildren = [];
|
|
8478
|
-
for (let i = 0, l =
|
|
8479
|
-
const child =
|
|
8478
|
+
for (let i = 0, l = object3.children.length; i < l; i++) {
|
|
8479
|
+
const child = object3.children[i];
|
|
8480
8480
|
if (child.visible || options.onlyVisible === false) {
|
|
8481
8481
|
const childNodeIndex = await this.processNodeAsync(child);
|
|
8482
8482
|
if (childNodeIndex !== null) grandchildren.push(childNodeIndex);
|
|
@@ -8486,7 +8486,7 @@ var GLTFWriter = class {
|
|
|
8486
8486
|
}
|
|
8487
8487
|
containerDef.children = containerChildren;
|
|
8488
8488
|
await this._invokeAllAsync(function(ext) {
|
|
8489
|
-
ext.writeNode && ext.writeNode(
|
|
8489
|
+
ext.writeNode && ext.writeNode(object3, containerDef);
|
|
8490
8490
|
});
|
|
8491
8491
|
return containerIndex;
|
|
8492
8492
|
}
|
|
@@ -8929,10 +8929,10 @@ var GLTFMeshGpuInstancing = class {
|
|
|
8929
8929
|
this.writer = writer;
|
|
8930
8930
|
this.name = "EXT_mesh_gpu_instancing";
|
|
8931
8931
|
}
|
|
8932
|
-
writeNode(
|
|
8933
|
-
if (!
|
|
8932
|
+
writeNode(object3, nodeDef) {
|
|
8933
|
+
if (!object3.isInstancedMesh) return;
|
|
8934
8934
|
const writer = this.writer;
|
|
8935
|
-
const mesh =
|
|
8935
|
+
const mesh = object3;
|
|
8936
8936
|
const translationAttr = new Float32Array(mesh.count * 3);
|
|
8937
8937
|
const rotationAttr = new Float32Array(mesh.count * 4);
|
|
8938
8938
|
const scaleAttr = new Float32Array(mesh.count * 3);
|
|
@@ -9122,8 +9122,8 @@ var SceneExporter = class {
|
|
|
9122
9122
|
}
|
|
9123
9123
|
}
|
|
9124
9124
|
};
|
|
9125
|
-
function localMatrix(
|
|
9126
|
-
return
|
|
9125
|
+
function localMatrix(object3) {
|
|
9126
|
+
return object3.matrixAutoUpdate ? new Matrix47().compose(object3.position, object3.quaternion, object3.scale) : object3.matrix.clone();
|
|
9127
9127
|
}
|
|
9128
9128
|
function createSnapshot(root, gltf, bakeColors = false) {
|
|
9129
9129
|
const scene = new Scene3();
|
|
@@ -9227,24 +9227,24 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
9227
9227
|
scene.add(copy);
|
|
9228
9228
|
}
|
|
9229
9229
|
};
|
|
9230
|
-
const visit = (
|
|
9231
|
-
if (!
|
|
9232
|
-
const world = parentWorld.clone().multiply(localMatrix(
|
|
9233
|
-
const mesh =
|
|
9230
|
+
const visit = (object3, parentWorld) => {
|
|
9231
|
+
if (!object3.visible) return;
|
|
9232
|
+
const world = parentWorld.clone().multiply(localMatrix(object3));
|
|
9233
|
+
const mesh = object3;
|
|
9234
9234
|
if (mesh.isMesh) {
|
|
9235
9235
|
const instanced = mesh;
|
|
9236
9236
|
if (instanced.isInstancedMesh) {
|
|
9237
9237
|
for (let i = 0; i < instanced.count; i++) {
|
|
9238
9238
|
const matrix = new Matrix47();
|
|
9239
9239
|
instanced.getMatrixAt(i, matrix);
|
|
9240
|
-
const
|
|
9241
|
-
addMesh(mesh, world.clone().multiply(matrix),
|
|
9240
|
+
const color2 = instanced.instanceColor ? new Color7().fromBufferAttribute(instanced.instanceColor, i) : void 0;
|
|
9241
|
+
addMesh(mesh, world.clone().multiply(matrix), color2);
|
|
9242
9242
|
}
|
|
9243
9243
|
} else {
|
|
9244
9244
|
addMesh(mesh, world);
|
|
9245
9245
|
}
|
|
9246
9246
|
}
|
|
9247
|
-
for (const child of
|
|
9247
|
+
for (const child of object3.children) visit(child, world);
|
|
9248
9248
|
};
|
|
9249
9249
|
try {
|
|
9250
9250
|
const ancestors = [];
|
|
@@ -9320,13 +9320,13 @@ init_AssetKey();
|
|
|
9320
9320
|
|
|
9321
9321
|
// src/gui/GuiText.ts
|
|
9322
9322
|
import { BufferGeometry as BufferGeometry2, Color as Color8, Float32BufferAttribute as Float32BufferAttribute4 } from "three";
|
|
9323
|
-
async function layoutGuiText(
|
|
9323
|
+
async function layoutGuiText(text2, options = {}) {
|
|
9324
9324
|
const maxWidth = options.maxWidth ?? Infinity, lineHeight = options.lineHeight ?? 9;
|
|
9325
9325
|
if (!(maxWidth > 0) || !Number.isFinite(lineHeight) || lineHeight <= 0) {
|
|
9326
9326
|
throw new Error("Text wrap width and line height must be positive");
|
|
9327
9327
|
}
|
|
9328
9328
|
const font = await Fonts.get(options.font);
|
|
9329
|
-
const runs = typeof
|
|
9329
|
+
const runs = typeof text2 === "string" ? [{ text: text2 }] : text2;
|
|
9330
9330
|
const glyphs = [], lineWidths = [];
|
|
9331
9331
|
let line = [], width = 0;
|
|
9332
9332
|
let trailingNewline = false;
|
|
@@ -9380,7 +9380,7 @@ function createGuiTextGeometry(layout, shadow = true) {
|
|
|
9380
9380
|
batch = { image: glyph?.image, positions: [], uvs: [], colors: [], indices: [] };
|
|
9381
9381
|
batches.push(batch);
|
|
9382
9382
|
}
|
|
9383
|
-
const
|
|
9383
|
+
const color2 = new Color8(isShadow ? (style.color & 16579836) >> 2 : style.color);
|
|
9384
9384
|
const offset = isShadow ? 1 : 0;
|
|
9385
9385
|
const top = glyph ? 7 - glyph.ascent : 0;
|
|
9386
9386
|
const height = glyph ? glyph.height * glyph.scale : 8;
|
|
@@ -9408,7 +9408,7 @@ function createGuiTextGeometry(layout, shadow = true) {
|
|
|
9408
9408
|
const v0 = glyph ? 1 - glyph.y / glyph.image.height : 1;
|
|
9409
9409
|
const v1 = glyph ? 1 - (glyph.y + glyph.height) / glyph.image.height : 0;
|
|
9410
9410
|
batch.uvs.push(u0, v0, u1, v0, u0, v1, u1, v1);
|
|
9411
|
-
for (let i = 0; i < 4; i++) batch.colors.push(
|
|
9411
|
+
for (let i = 0; i < 4; i++) batch.colors.push(color2.r, color2.g, color2.b);
|
|
9412
9412
|
batch.indices.push(base, base + 2, base + 1, base + 2, base + 3, base + 1);
|
|
9413
9413
|
};
|
|
9414
9414
|
for (const boldOffset of style.bold ? [0, 1] : [0]) {
|
|
@@ -9442,8 +9442,8 @@ var GuiHelper = class {
|
|
|
9442
9442
|
size: [width + 24, height + 24]
|
|
9443
9443
|
}));
|
|
9444
9444
|
let y = position[1];
|
|
9445
|
-
lines.forEach((
|
|
9446
|
-
layers.push({ ...textOptions, name: `tooltip-line-${index}`, text, position: [position[0], y] });
|
|
9445
|
+
lines.forEach((text2, index) => {
|
|
9446
|
+
layers.push({ ...textOptions, name: `tooltip-line-${index}`, text: text2, position: [position[0], y] });
|
|
9447
9447
|
y += layouts[index].height + (index === 0 ? titleGap : 0);
|
|
9448
9448
|
});
|
|
9449
9449
|
return layers;
|
|
@@ -9899,29 +9899,29 @@ var SceneInspector = class {
|
|
|
9899
9899
|
this.objectControlsContainer.innerHTML = "";
|
|
9900
9900
|
this.addControls(targetObject, targetIntersection, instance);
|
|
9901
9901
|
}
|
|
9902
|
-
addControls(
|
|
9902
|
+
addControls(object3, intersection, instance) {
|
|
9903
9903
|
const container = document.createElement("div");
|
|
9904
9904
|
container.append(this.separator("Select Parent/Child"));
|
|
9905
|
-
if (
|
|
9906
|
-
container.append(this.buttonControl("Select Parent " +
|
|
9907
|
-
this.selectObject(
|
|
9905
|
+
if (object3.parent) {
|
|
9906
|
+
container.append(this.buttonControl("Select Parent " + object3.parent.constructor.name + " " + object3.parent.name, "P", () => {
|
|
9907
|
+
this.selectObject(object3.parent, intersection, instance);
|
|
9908
9908
|
}));
|
|
9909
9909
|
}
|
|
9910
|
-
if (
|
|
9910
|
+
if (object3.children.length > 0) {
|
|
9911
9911
|
let i = 1;
|
|
9912
|
-
for (let child of
|
|
9912
|
+
for (let child of object3.children) {
|
|
9913
9913
|
container.append(this.buttonControl("Select Child " + child.constructor.name + " " + child.name, "C" + i++, () => {
|
|
9914
9914
|
this.selectObject(child, intersection, instance);
|
|
9915
9915
|
}));
|
|
9916
9916
|
}
|
|
9917
9917
|
}
|
|
9918
9918
|
container.append(this.separator());
|
|
9919
|
-
const selectedInstance = instance && (
|
|
9919
|
+
const selectedInstance = instance && (object3 === instance.instanceable || object3 === intersection?.object) ? instance : void 0;
|
|
9920
9920
|
if (!selectedInstance) {
|
|
9921
|
-
container.append(this.toggleControl("Visibility", "V",
|
|
9921
|
+
container.append(this.toggleControl("Visibility", "V", object3.visible, (v) => object3.visible = v));
|
|
9922
9922
|
}
|
|
9923
9923
|
container.append(this.separator("Mesh"));
|
|
9924
|
-
this.addObjectControls(
|
|
9924
|
+
this.addObjectControls(object3, intersection, container, selectedInstance);
|
|
9925
9925
|
container.append(this.separator());
|
|
9926
9926
|
this.objectControlsContainer.append(container);
|
|
9927
9927
|
}
|
|
@@ -10337,29 +10337,29 @@ var BlockTints = class {
|
|
|
10337
10337
|
}
|
|
10338
10338
|
}
|
|
10339
10339
|
if (!indices.size) return tints;
|
|
10340
|
-
let
|
|
10340
|
+
let color2;
|
|
10341
10341
|
switch (rule.source) {
|
|
10342
10342
|
case "constant":
|
|
10343
|
-
|
|
10343
|
+
color2 = rule.color;
|
|
10344
10344
|
break;
|
|
10345
10345
|
case "grass":
|
|
10346
|
-
|
|
10346
|
+
color2 = await Colormaps.grassColor(key);
|
|
10347
10347
|
break;
|
|
10348
10348
|
case "redstone": {
|
|
10349
10349
|
const power = Number(state.power ?? 0) / 15;
|
|
10350
10350
|
const red = power * 0.6 + (power > 0 ? 0.4 : 0.3);
|
|
10351
10351
|
const green = Math.max(0, power * power * 0.7 - 0.5);
|
|
10352
10352
|
const blue = Math.max(0, power * power * 0.6 - 0.7);
|
|
10353
|
-
|
|
10353
|
+
color2 = Math.floor(red * 255) << 16 | Math.floor(green * 255) << 8 | Math.floor(blue * 255);
|
|
10354
10354
|
break;
|
|
10355
10355
|
}
|
|
10356
10356
|
case "stem": {
|
|
10357
10357
|
const age = Number(state.age ?? 0);
|
|
10358
|
-
|
|
10358
|
+
color2 = age * 32 << 16 | 255 - age * 8 << 8 | age * 4;
|
|
10359
10359
|
break;
|
|
10360
10360
|
}
|
|
10361
10361
|
}
|
|
10362
|
-
return { ...Object.fromEntries([...indices].map((index) => [index,
|
|
10362
|
+
return { ...Object.fromEntries([...indices].map((index) => [index, color2])), ...tints };
|
|
10363
10363
|
}
|
|
10364
10364
|
};
|
|
10365
10365
|
|
|
@@ -10501,8 +10501,8 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
10501
10501
|
return false;
|
|
10502
10502
|
}
|
|
10503
10503
|
return this._models.some((model) => {
|
|
10504
|
-
const
|
|
10505
|
-
return
|
|
10504
|
+
const object3 = isInstanceReference(model) ? model.instanceable : model;
|
|
10505
|
+
return object3.isOpaqueFullCube && this.getModelCullMask(model, 63) === 63;
|
|
10506
10506
|
});
|
|
10507
10507
|
}
|
|
10508
10508
|
getModelMatrix(model) {
|
|
@@ -10511,8 +10511,8 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
10511
10511
|
return model.matrix.clone();
|
|
10512
10512
|
}
|
|
10513
10513
|
getModelCullMask(model, worldMask) {
|
|
10514
|
-
const
|
|
10515
|
-
if (
|
|
10514
|
+
const object3 = isInstanceReference(model) ? model.instanceable : model;
|
|
10515
|
+
if (object3.options.displayPosition) return 0;
|
|
10516
10516
|
const position = new Vector312();
|
|
10517
10517
|
const rotation = new Quaternion5();
|
|
10518
10518
|
const scale = new Vector312();
|
|
@@ -10529,14 +10529,14 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
10529
10529
|
replacements.push(model);
|
|
10530
10530
|
continue;
|
|
10531
10531
|
}
|
|
10532
|
-
const
|
|
10532
|
+
const object3 = isInstanceReference(model) ? model.instanceable : model;
|
|
10533
10533
|
const cullMask = this.getModelCullMask(model, worldMask);
|
|
10534
|
-
if (cullMask === (
|
|
10534
|
+
if (cullMask === (object3.options.cullMask ?? 0)) {
|
|
10535
10535
|
replacements.push(model);
|
|
10536
10536
|
continue;
|
|
10537
10537
|
}
|
|
10538
10538
|
const matrix = this.getModelMatrix(model);
|
|
10539
|
-
const replacement = await this.scene.addModel(
|
|
10539
|
+
const replacement = await this.scene.addModel(object3.originalModel, { ...object3.options, cullMask });
|
|
10540
10540
|
replacements.push(replacement);
|
|
10541
10541
|
if (isInstanceReference(replacement)) {
|
|
10542
10542
|
replacement.setMatrix(matrix);
|
|
@@ -10544,8 +10544,8 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
10544
10544
|
replacement.matrix.copy(matrix);
|
|
10545
10545
|
replacement.matrixWorldNeedsUpdate = true;
|
|
10546
10546
|
matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
10547
|
-
replacement.matrixAutoUpdate =
|
|
10548
|
-
replacement.visible =
|
|
10547
|
+
replacement.matrixAutoUpdate = object3.matrixAutoUpdate;
|
|
10548
|
+
replacement.visible = object3.visible;
|
|
10549
10549
|
}
|
|
10550
10550
|
}
|
|
10551
10551
|
} catch (error) {
|
|
@@ -13692,60 +13692,60 @@ var MineRenderScene = class _MineRenderScene extends Scene4 {
|
|
|
13692
13692
|
this.DEFAULT_OPTIONS = (0, import_ts_deepmerge8.default)({}, {});
|
|
13693
13693
|
}
|
|
13694
13694
|
add(...objects) {
|
|
13695
|
-
for (const
|
|
13695
|
+
for (const object3 of objects) {
|
|
13696
13696
|
this.dirty = true;
|
|
13697
13697
|
try {
|
|
13698
|
-
super.add(
|
|
13698
|
+
super.add(object3);
|
|
13699
13699
|
} finally {
|
|
13700
|
-
if (
|
|
13701
|
-
this.updateObjectRegistration(
|
|
13700
|
+
if (object3?.isObject3D && object3 !== this) {
|
|
13701
|
+
this.updateObjectRegistration(object3, object3.parent === this);
|
|
13702
13702
|
}
|
|
13703
13703
|
}
|
|
13704
13704
|
}
|
|
13705
13705
|
return this;
|
|
13706
13706
|
}
|
|
13707
13707
|
remove(...objects) {
|
|
13708
|
-
for (const
|
|
13709
|
-
if (!this.children.includes(
|
|
13708
|
+
for (const object3 of objects) {
|
|
13709
|
+
if (!this.children.includes(object3)) continue;
|
|
13710
13710
|
this.dirty = true;
|
|
13711
|
-
this.updateObjectRegistration(
|
|
13711
|
+
this.updateObjectRegistration(object3, false);
|
|
13712
13712
|
try {
|
|
13713
|
-
super.remove(
|
|
13713
|
+
super.remove(object3);
|
|
13714
13714
|
} finally {
|
|
13715
|
-
this.updateObjectRegistration(
|
|
13715
|
+
this.updateObjectRegistration(object3, object3.parent === this);
|
|
13716
13716
|
}
|
|
13717
13717
|
}
|
|
13718
13718
|
return this;
|
|
13719
13719
|
}
|
|
13720
|
-
updateObjectRegistration(
|
|
13721
|
-
if (this.observedObjects.has(
|
|
13722
|
-
const observable =
|
|
13720
|
+
updateObjectRegistration(object3, attached) {
|
|
13721
|
+
if (this.observedObjects.has(object3) === attached) return;
|
|
13722
|
+
const observable = object3;
|
|
13723
13723
|
if (attached) {
|
|
13724
|
-
this.observedObjects.add(
|
|
13724
|
+
this.observedObjects.add(object3);
|
|
13725
13725
|
observable.addEventListener("change", this.onObjectChange);
|
|
13726
13726
|
} else {
|
|
13727
|
-
this.observedObjects.delete(
|
|
13727
|
+
this.observedObjects.delete(object3);
|
|
13728
13728
|
observable.removeEventListener("change", this.onObjectChange);
|
|
13729
13729
|
}
|
|
13730
13730
|
const change = attached ? 1 : -1;
|
|
13731
13731
|
this.stats.objectCount += change;
|
|
13732
|
-
if (isSceneObject(
|
|
13732
|
+
if (isSceneObject(object3)) {
|
|
13733
13733
|
this.stats.sceneObjectCount += change;
|
|
13734
13734
|
}
|
|
13735
13735
|
}
|
|
13736
13736
|
/** Initializes each object before attaching it to the scene. */
|
|
13737
|
-
async initAndAdd(...
|
|
13737
|
+
async initAndAdd(...object3) {
|
|
13738
13738
|
this.dirty = true;
|
|
13739
|
-
for (let obj of
|
|
13739
|
+
for (let obj of object3) {
|
|
13740
13740
|
await obj.init();
|
|
13741
13741
|
}
|
|
13742
|
-
return this.add(...
|
|
13742
|
+
return this.add(...object3);
|
|
13743
13743
|
}
|
|
13744
|
-
async addSceneObject(
|
|
13744
|
+
async addSceneObject(asset2, objectSupplier, _options, parent = this) {
|
|
13745
13745
|
this.dirty = true;
|
|
13746
13746
|
const obj = await objectSupplier();
|
|
13747
|
-
if (obj?.options?.instanceMeshes &&
|
|
13748
|
-
let key =
|
|
13747
|
+
if (obj?.options?.instanceMeshes && asset2.key && asset2.key?.assetType === "models") {
|
|
13748
|
+
let key = asset2.key.serialize();
|
|
13749
13749
|
if (isModelObject(obj)) {
|
|
13750
13750
|
const { displayPosition, uvLockRotation, tints, cullMask } = obj.options;
|
|
13751
13751
|
if (displayPosition) key += `|display:${displayPosition}`;
|
|
@@ -13851,11 +13851,11 @@ var _changeEvent = { type: "change" };
|
|
|
13851
13851
|
var _startEvent = { type: "start" };
|
|
13852
13852
|
var _endEvent = { type: "end" };
|
|
13853
13853
|
var OrbitControls = class extends EventDispatcher {
|
|
13854
|
-
constructor(
|
|
13854
|
+
constructor(object3, domElement) {
|
|
13855
13855
|
super();
|
|
13856
13856
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
13857
13857
|
if (domElement === document) console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
|
|
13858
|
-
this.object =
|
|
13858
|
+
this.object = object3;
|
|
13859
13859
|
this.domElement = domElement;
|
|
13860
13860
|
this.domElement.style.touchAction = "none";
|
|
13861
13861
|
this.enabled = true;
|
|
@@ -13912,7 +13912,7 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
13912
13912
|
};
|
|
13913
13913
|
this.update = function() {
|
|
13914
13914
|
const offset = new Vector313();
|
|
13915
|
-
const quat = new Quaternion6().setFromUnitVectors(
|
|
13915
|
+
const quat = new Quaternion6().setFromUnitVectors(object3.up, new Vector313(0, 1, 0));
|
|
13916
13916
|
const quatInverse = quat.clone().invert();
|
|
13917
13917
|
const lastPosition = new Vector313();
|
|
13918
13918
|
const lastQuaternion = new Quaternion6();
|
|
@@ -14477,8 +14477,8 @@ var OrbitControls = class extends EventDispatcher {
|
|
|
14477
14477
|
}
|
|
14478
14478
|
};
|
|
14479
14479
|
var MapControls = class extends OrbitControls {
|
|
14480
|
-
constructor(
|
|
14481
|
-
super(
|
|
14480
|
+
constructor(object3, domElement) {
|
|
14481
|
+
super(object3, domElement);
|
|
14482
14482
|
this.screenSpacePanning = false;
|
|
14483
14483
|
this.mouseButtons.LEFT = MOUSE.PAN;
|
|
14484
14484
|
this.mouseButtons.RIGHT = MOUSE.ROTATE;
|
|
@@ -14907,6 +14907,232 @@ init_SceneObject();
|
|
|
14907
14907
|
// src/index.ts
|
|
14908
14908
|
init_request();
|
|
14909
14909
|
|
|
14910
|
+
// src/scene/SceneDocument.ts
|
|
14911
|
+
init_DisplayPosition();
|
|
14912
|
+
function fail(path, message) {
|
|
14913
|
+
throw new Error(`${path}: ${message}`);
|
|
14914
|
+
}
|
|
14915
|
+
function object2(value, path) {
|
|
14916
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail(path, "expected a JSON object");
|
|
14917
|
+
for (const key of Object.keys(value)) {
|
|
14918
|
+
if (["__proto__", "prototype", "constructor"].includes(key)) fail(`${path}.${key}`, "unsupported property");
|
|
14919
|
+
}
|
|
14920
|
+
return value;
|
|
14921
|
+
}
|
|
14922
|
+
function fields(value, path, allowed, required = []) {
|
|
14923
|
+
const input = object2(value, path);
|
|
14924
|
+
for (const key of required) if (input[key] === void 0) fail(`${path}.${key}`, "required");
|
|
14925
|
+
for (const [key, entry] of Object.entries(input)) {
|
|
14926
|
+
if (!Object.prototype.hasOwnProperty.call(allowed, key)) fail(`${path}.${key}`, "unsupported property");
|
|
14927
|
+
if (entry !== void 0) allowed[key](entry, `${path}.${key}`);
|
|
14928
|
+
}
|
|
14929
|
+
return input;
|
|
14930
|
+
}
|
|
14931
|
+
var text = (value, path) => {
|
|
14932
|
+
if (typeof value !== "string" || !value.trim()) fail(path, "expected a nonempty string");
|
|
14933
|
+
};
|
|
14934
|
+
var literalText = (value, path) => {
|
|
14935
|
+
if (typeof value !== "string") fail(path, "expected a string");
|
|
14936
|
+
};
|
|
14937
|
+
var boolean = (value, path) => {
|
|
14938
|
+
if (typeof value !== "boolean") fail(path, "expected a boolean");
|
|
14939
|
+
};
|
|
14940
|
+
var number = (value, path) => {
|
|
14941
|
+
if (typeof value !== "number" || !Number.isFinite(value)) fail(path, "expected a finite number");
|
|
14942
|
+
};
|
|
14943
|
+
var positive = (value, path) => {
|
|
14944
|
+
number(value, path);
|
|
14945
|
+
if (value <= 0) fail(path, "expected a positive number");
|
|
14946
|
+
};
|
|
14947
|
+
var nonnegative = (value, path) => {
|
|
14948
|
+
number(value, path);
|
|
14949
|
+
if (value < 0) fail(path, "expected a nonnegative number");
|
|
14950
|
+
};
|
|
14951
|
+
var color = (value, path) => {
|
|
14952
|
+
number(value, path);
|
|
14953
|
+
if (!Number.isInteger(value) || value < 0 || value > 16777215) {
|
|
14954
|
+
fail(path, "expected an RGB integer from 0 to 16777215");
|
|
14955
|
+
}
|
|
14956
|
+
};
|
|
14957
|
+
var asset = (value, path) => {
|
|
14958
|
+
text(value, path);
|
|
14959
|
+
if (!/^(?:[a-z0-9_.-]+:)?[a-z0-9_./-]+$/.test(value) || value.split(/[:/]/).some((part) => !part || part === "." || part === "..")) {
|
|
14960
|
+
fail(path, "expected a resource ID such as minecraft:stone");
|
|
14961
|
+
}
|
|
14962
|
+
};
|
|
14963
|
+
var version = (value, path) => {
|
|
14964
|
+
text(value, path);
|
|
14965
|
+
if (!/^[a-zA-Z0-9._-]+$/.test(value)) fail(path, "expected a Minecraft version without slashes");
|
|
14966
|
+
};
|
|
14967
|
+
var tuple = (size, item = number) => (value, path) => {
|
|
14968
|
+
if (!Array.isArray(value) || value.length !== size) fail(path, `expected ${size} numbers`);
|
|
14969
|
+
for (let index = 0; index < size; index++) item(value[index], `${path}[${index}]`);
|
|
14970
|
+
};
|
|
14971
|
+
var list = (item) => (value, path) => {
|
|
14972
|
+
if (!Array.isArray(value)) fail(path, "expected an array");
|
|
14973
|
+
for (let index = 0; index < value.length; index++) item(value[index], `${path}[${index}]`);
|
|
14974
|
+
};
|
|
14975
|
+
var dictionary = (item, numericKeys = false) => (value, path) => {
|
|
14976
|
+
for (const [key, entry] of Object.entries(object2(value, path))) {
|
|
14977
|
+
if (numericKeys && !/^\d+$/.test(key)) fail(`${path}.${key}`, "expected a nonnegative tint index");
|
|
14978
|
+
item(entry, `${path}.${key}`);
|
|
14979
|
+
}
|
|
14980
|
+
};
|
|
14981
|
+
var enumeration = (values) => (value, path) => {
|
|
14982
|
+
if (!values.includes(value)) fail(path, `expected one of: ${values.join(", ")}`);
|
|
14983
|
+
};
|
|
14984
|
+
var textStyle = { color, bold: boolean, italic: boolean };
|
|
14985
|
+
function guiLayer(value, path) {
|
|
14986
|
+
const layer = object2(value, path);
|
|
14987
|
+
if (["texture", "item", "text"].filter((key) => layer[key] !== void 0).length !== 1) {
|
|
14988
|
+
fail(path, "expected exactly one of texture, item, or text");
|
|
14989
|
+
}
|
|
14990
|
+
const layout = { name: text, position: tuple(2), size: tuple(2, positive) };
|
|
14991
|
+
if (layer.texture !== void 0) {
|
|
14992
|
+
fields(value, path, { ...layout, texture: asset, crop: (value2, path2) => {
|
|
14993
|
+
tuple(4)(value2, path2);
|
|
14994
|
+
const [x, y, width, height] = value2;
|
|
14995
|
+
nonnegative(x, `${path2}[0]`);
|
|
14996
|
+
nonnegative(y, `${path2}[1]`);
|
|
14997
|
+
positive(width, `${path2}[2]`);
|
|
14998
|
+
positive(height, `${path2}[3]`);
|
|
14999
|
+
} });
|
|
15000
|
+
} else if (layer.item !== void 0) {
|
|
15001
|
+
fields(value, path, { ...layout, item: asset, tints: dictionary(color, true) });
|
|
15002
|
+
} else {
|
|
15003
|
+
fields(value, path, {
|
|
15004
|
+
...layout,
|
|
15005
|
+
...textStyle,
|
|
15006
|
+
font: asset,
|
|
15007
|
+
shadow: boolean,
|
|
15008
|
+
maxWidth: positive,
|
|
15009
|
+
lineHeight: positive,
|
|
15010
|
+
text: (value2, path2) => {
|
|
15011
|
+
if (typeof value2 === "string") return;
|
|
15012
|
+
list((run, path3) => {
|
|
15013
|
+
fields(run, path3, { text: literalText, ...textStyle }, ["text"]);
|
|
15014
|
+
})(value2, path2);
|
|
15015
|
+
}
|
|
15016
|
+
});
|
|
15017
|
+
}
|
|
15018
|
+
}
|
|
15019
|
+
function validateObject(value, path) {
|
|
15020
|
+
const input = object2(value, path);
|
|
15021
|
+
const common = { id: text, name: text, type: text, position: tuple(3), rotation: tuple(3), scale: tuple(3), visible: boolean };
|
|
15022
|
+
const required = ["id", "type"];
|
|
15023
|
+
const renderOptions = { wireframe: boolean };
|
|
15024
|
+
switch (input.type) {
|
|
15025
|
+
case "skin":
|
|
15026
|
+
fields(value, path, {
|
|
15027
|
+
...common,
|
|
15028
|
+
skin: text,
|
|
15029
|
+
cape: (value2, path2) => {
|
|
15030
|
+
fields(value2, path2, { texture: text, layout: enumeration(["minecraft", "optifine", "labymod"]) }, ["texture"]);
|
|
15031
|
+
},
|
|
15032
|
+
hiddenParts: list(enumeration(SKIN_PARTS)),
|
|
15033
|
+
pose: (value2, path2) => {
|
|
15034
|
+
fields(value2, path2, {
|
|
15035
|
+
head: tuple(3),
|
|
15036
|
+
body: tuple(3),
|
|
15037
|
+
rightArm: tuple(3),
|
|
15038
|
+
leftArm: tuple(3),
|
|
15039
|
+
rightLeg: tuple(3),
|
|
15040
|
+
leftLeg: tuple(3),
|
|
15041
|
+
cape: tuple(3)
|
|
15042
|
+
});
|
|
15043
|
+
},
|
|
15044
|
+
options: (value2, path2) => {
|
|
15045
|
+
fields(value2, path2, { slim: boolean, legacy: boolean });
|
|
15046
|
+
}
|
|
15047
|
+
}, required);
|
|
15048
|
+
break;
|
|
15049
|
+
case "block":
|
|
15050
|
+
fields(value, path, {
|
|
15051
|
+
...common,
|
|
15052
|
+
asset,
|
|
15053
|
+
state: dictionary(text),
|
|
15054
|
+
options: (value2, path2) => {
|
|
15055
|
+
fields(value2, path2, { ...renderOptions, tints: dictionary(color, true) });
|
|
15056
|
+
}
|
|
15057
|
+
}, [...required, "asset"]);
|
|
15058
|
+
break;
|
|
15059
|
+
case "item":
|
|
15060
|
+
case "model":
|
|
15061
|
+
fields(value, path, {
|
|
15062
|
+
...common,
|
|
15063
|
+
asset,
|
|
15064
|
+
options: (value2, path2) => {
|
|
15065
|
+
fields(value2, path2, { ...renderOptions, displayPosition: enumeration(DISPLAY_POSITIONS), tints: dictionary(color, true) });
|
|
15066
|
+
}
|
|
15067
|
+
}, [...required, "asset"]);
|
|
15068
|
+
break;
|
|
15069
|
+
case "entity":
|
|
15070
|
+
fields(value, path, {
|
|
15071
|
+
...common,
|
|
15072
|
+
asset,
|
|
15073
|
+
texture: asset,
|
|
15074
|
+
layers: list(text),
|
|
15075
|
+
when: list(text),
|
|
15076
|
+
textures: dictionary(asset),
|
|
15077
|
+
options: (value2, path2) => {
|
|
15078
|
+
fields(value2, path2, {
|
|
15079
|
+
...renderOptions,
|
|
15080
|
+
flip: boolean,
|
|
15081
|
+
tints: dictionary((value3, path3) => {
|
|
15082
|
+
typeof value3 === "string" ? text(value3, path3) : color(value3, path3);
|
|
15083
|
+
})
|
|
15084
|
+
});
|
|
15085
|
+
},
|
|
15086
|
+
animation: (value2, path2) => {
|
|
15087
|
+
fields(value2, path2, { name: text, loop: boolean, speed: nonnegative, time: nonnegative, paused: boolean }, ["name"]);
|
|
15088
|
+
}
|
|
15089
|
+
}, [...required, "asset"]);
|
|
15090
|
+
if (Array.isArray(input.layers) && !input.layers.length) fail(`${path}.layers`, "expected at least one layer");
|
|
15091
|
+
break;
|
|
15092
|
+
case "gui":
|
|
15093
|
+
fields(value, path, { ...common, layers: list(guiLayer) }, [...required, "layers"]);
|
|
15094
|
+
break;
|
|
15095
|
+
default:
|
|
15096
|
+
fail(`${path}.type`, "expected skin, block, item, entity, model, or gui");
|
|
15097
|
+
}
|
|
15098
|
+
}
|
|
15099
|
+
function parseSceneDocument(value) {
|
|
15100
|
+
if (typeof value === "string") {
|
|
15101
|
+
try {
|
|
15102
|
+
value = JSON.parse(value);
|
|
15103
|
+
} catch {
|
|
15104
|
+
fail("scene", "invalid JSON");
|
|
15105
|
+
}
|
|
15106
|
+
}
|
|
15107
|
+
const input = fields(value, "scene", {
|
|
15108
|
+
format: enumeration(["minerender-scene"]),
|
|
15109
|
+
version: (value2, path) => {
|
|
15110
|
+
if (value2 !== 1) fail(path, "only scene document version 1 is supported");
|
|
15111
|
+
},
|
|
15112
|
+
minecraftVersion: version,
|
|
15113
|
+
camera: (value2, path) => {
|
|
15114
|
+
fields(value2, path, { position: tuple(3), target: tuple(3) }, ["position", "target"]);
|
|
15115
|
+
},
|
|
15116
|
+
objects: list(validateObject)
|
|
15117
|
+
}, ["format", "version", "objects"]);
|
|
15118
|
+
const ids = /* @__PURE__ */ new Set();
|
|
15119
|
+
for (const [index, entry] of input.objects.entries()) {
|
|
15120
|
+
if (ids.has(entry.id)) fail(`scene.objects[${index}].id`, `duplicate object ID "${entry.id}"`);
|
|
15121
|
+
ids.add(entry.id);
|
|
15122
|
+
}
|
|
15123
|
+
return JSON.parse(JSON.stringify(input));
|
|
15124
|
+
}
|
|
15125
|
+
|
|
15126
|
+
// src/scene/SceneDocumentLoader.ts
|
|
15127
|
+
init_AssetKey();
|
|
15128
|
+
init_AssetLoader();
|
|
15129
|
+
init_BlockStates();
|
|
15130
|
+
init_Entities();
|
|
15131
|
+
init_Models();
|
|
15132
|
+
init_DisplayPosition();
|
|
15133
|
+
import { Group as Group2 } from "three";
|
|
15134
|
+
init_SceneObject();
|
|
15135
|
+
|
|
14910
15136
|
// src/skin/Skins.ts
|
|
14911
15137
|
init_Requests();
|
|
14912
15138
|
var Skins = class {
|
|
@@ -15077,6 +15303,195 @@ var Skins = class {
|
|
|
15077
15303
|
//</editor-fold>
|
|
15078
15304
|
};
|
|
15079
15305
|
|
|
15306
|
+
// src/scene/SceneDocumentLoader.ts
|
|
15307
|
+
var DocumentObjectScene = class extends MineRenderScene {
|
|
15308
|
+
async addSceneObject(_asset, supplier, _options, parent = this) {
|
|
15309
|
+
const object3 = await supplier();
|
|
15310
|
+
return this.initialize(object3, parent);
|
|
15311
|
+
}
|
|
15312
|
+
async initialize(object3, parent = this) {
|
|
15313
|
+
object3.scene = this;
|
|
15314
|
+
try {
|
|
15315
|
+
await object3.init();
|
|
15316
|
+
parent.add(object3);
|
|
15317
|
+
return object3;
|
|
15318
|
+
} catch (error) {
|
|
15319
|
+
object3.dispose();
|
|
15320
|
+
object3.removeFromParent();
|
|
15321
|
+
throw error;
|
|
15322
|
+
}
|
|
15323
|
+
}
|
|
15324
|
+
dispose() {
|
|
15325
|
+
for (const child of [...this.children]) {
|
|
15326
|
+
if (child.parent !== this) continue;
|
|
15327
|
+
if (isSceneObject(child)) child.dispose();
|
|
15328
|
+
child.removeFromParent();
|
|
15329
|
+
}
|
|
15330
|
+
}
|
|
15331
|
+
};
|
|
15332
|
+
async function skinTexture(value, cape = false) {
|
|
15333
|
+
if (!/^[a-zA-Z0-9_-]{1,36}$/.test(value)) return value;
|
|
15334
|
+
const texture = await (cape ? Skins.capeFromUuidOrUsername(value) : Skins.fromUuidOrUsername(value));
|
|
15335
|
+
if (!texture) throw new Error(`Could not find ${cape ? "cape" : "skin"} for "${value}"`);
|
|
15336
|
+
return texture;
|
|
15337
|
+
}
|
|
15338
|
+
var SceneDocumentLoader = class {
|
|
15339
|
+
static parse(value) {
|
|
15340
|
+
return parseSceneDocument(value);
|
|
15341
|
+
}
|
|
15342
|
+
/**
|
|
15343
|
+
* Loads objects concurrently and attaches them in document order after every load succeeds.
|
|
15344
|
+
* A failure waits for all loads, disposes staged objects, and reports the first error in document order.
|
|
15345
|
+
*/
|
|
15346
|
+
static async load(scene, value, parent = scene) {
|
|
15347
|
+
const definition = this.parse(value);
|
|
15348
|
+
if (definition.minecraftVersion !== void 0 && definition.minecraftVersion !== AssetLoader.version) {
|
|
15349
|
+
throw new Error(`Scene requires Minecraft ${definition.minecraftVersion}; call AssetLoader.setVersion("${definition.minecraftVersion}") before loading it`);
|
|
15350
|
+
}
|
|
15351
|
+
const root = new Group2();
|
|
15352
|
+
root.name = "MineRender scene document";
|
|
15353
|
+
const objects = [];
|
|
15354
|
+
let disposed = false;
|
|
15355
|
+
const loaded = {
|
|
15356
|
+
root,
|
|
15357
|
+
objects,
|
|
15358
|
+
definition,
|
|
15359
|
+
advanceAnimations: (delta) => {
|
|
15360
|
+
if (!disposed) for (const object3 of objects) object3.advanceAnimation(delta);
|
|
15361
|
+
},
|
|
15362
|
+
dispose: () => {
|
|
15363
|
+
if (disposed) return;
|
|
15364
|
+
disposed = true;
|
|
15365
|
+
root.removeFromParent();
|
|
15366
|
+
for (const object3 of objects) object3.dispose();
|
|
15367
|
+
root.clear();
|
|
15368
|
+
scene.dirty = true;
|
|
15369
|
+
}
|
|
15370
|
+
};
|
|
15371
|
+
try {
|
|
15372
|
+
const results = await Promise.allSettled(definition.objects.map((object3) => this.loadValidatedObject(scene, object3)));
|
|
15373
|
+
for (const result of results) if (result.status === "fulfilled") objects.push(result.value);
|
|
15374
|
+
const failure = results.find((result) => result.status === "rejected");
|
|
15375
|
+
if (failure) throw failure.reason;
|
|
15376
|
+
for (const object3 of objects) root.add(object3.root);
|
|
15377
|
+
parent.add(root);
|
|
15378
|
+
scene.dirty = true;
|
|
15379
|
+
return loaded;
|
|
15380
|
+
} catch (error) {
|
|
15381
|
+
loaded.dispose();
|
|
15382
|
+
throw error;
|
|
15383
|
+
}
|
|
15384
|
+
}
|
|
15385
|
+
/** Loads an independently editable object. Its root owns the document's position, rotation, and scale. */
|
|
15386
|
+
static async loadObject(scene, value, parent = scene) {
|
|
15387
|
+
const definition = this.parse({ format: "minerender-scene", version: 1, objects: [value] }).objects[0];
|
|
15388
|
+
return this.loadValidatedObject(scene, definition, parent);
|
|
15389
|
+
}
|
|
15390
|
+
static async loadValidatedObject(scene, definition, parent) {
|
|
15391
|
+
const root = new Group2();
|
|
15392
|
+
root.name = definition.name ?? definition.id;
|
|
15393
|
+
root.userData.sceneObjectId = definition.id;
|
|
15394
|
+
root.position.fromArray(definition.position ?? [0, 0, 0]);
|
|
15395
|
+
root.rotation.set(...definition.rotation ?? [0, 0, 0]);
|
|
15396
|
+
root.scale.fromArray(definition.scale ?? [1, 1, 1]);
|
|
15397
|
+
root.visible = definition.visible ?? true;
|
|
15398
|
+
const content = new DocumentObjectScene();
|
|
15399
|
+
root.add(content);
|
|
15400
|
+
let object3;
|
|
15401
|
+
try {
|
|
15402
|
+
switch (definition.type) {
|
|
15403
|
+
case "skin": {
|
|
15404
|
+
const skin = new SkinObject({ ...definition.options, instanceMeshes: false });
|
|
15405
|
+
object3 = skin;
|
|
15406
|
+
const texture = definition.skin ? await skinTexture(definition.skin) : `${AssetLoader.ROOT}/assets/minecraft/textures/entity/player/${definition.options?.slim ? "slim/alex" : "wide/steve"}.png`;
|
|
15407
|
+
await skin.setSkinTexture(texture);
|
|
15408
|
+
await content.initialize(skin);
|
|
15409
|
+
if (definition.cape) await skin.setCapeTexture(await skinTexture(definition.cape.texture, true), definition.cape.layout);
|
|
15410
|
+
for (const [part, rotation] of Object.entries(definition.pose ?? {})) {
|
|
15411
|
+
skin.getGroupByName(part)?.rotation.set(...rotation, "XYZ");
|
|
15412
|
+
}
|
|
15413
|
+
for (const part of definition.hiddenParts ?? []) {
|
|
15414
|
+
const mesh = skin.getMeshByName(part);
|
|
15415
|
+
if (mesh) mesh.visible = false;
|
|
15416
|
+
}
|
|
15417
|
+
break;
|
|
15418
|
+
}
|
|
15419
|
+
case "block": {
|
|
15420
|
+
const state = await BlockStates.get(AssetKey.parse("blockstates", definition.asset));
|
|
15421
|
+
if (!state) throw new Error(`Could not load block ${definition.asset}`);
|
|
15422
|
+
object3 = await content.addBlock(state, { ...definition.options, initialState: definition.state, instanceMeshes: false });
|
|
15423
|
+
break;
|
|
15424
|
+
}
|
|
15425
|
+
case "item":
|
|
15426
|
+
case "model": {
|
|
15427
|
+
let key = AssetKey.parse("models", definition.asset);
|
|
15428
|
+
if (definition.type === "item" && key.type !== "item") {
|
|
15429
|
+
key = new AssetKey(key.namespace, key.getFullPath(), "models", "item");
|
|
15430
|
+
}
|
|
15431
|
+
const model = await Models.getMerged(key);
|
|
15432
|
+
if (!model) throw new Error(`Could not load ${definition.type} ${definition.asset}`);
|
|
15433
|
+
object3 = await content.addModel(model, {
|
|
15434
|
+
...definition.type === "item" ? { displayPosition: "gui" /* GUI */ } : {},
|
|
15435
|
+
...definition.options,
|
|
15436
|
+
instanceMeshes: false
|
|
15437
|
+
});
|
|
15438
|
+
break;
|
|
15439
|
+
}
|
|
15440
|
+
case "entity": {
|
|
15441
|
+
const key = AssetKey.parse("entity-models", definition.asset);
|
|
15442
|
+
const model = await Entities.getEntity(key, definition.texture ? AssetKey.parse("textures", definition.texture) : void 0, {
|
|
15443
|
+
layers: definition.layers,
|
|
15444
|
+
when: definition.when,
|
|
15445
|
+
textures: definition.textures && Object.fromEntries(Object.entries(definition.textures).map(([name, texture]) => [name, AssetKey.parse("textures", texture)]))
|
|
15446
|
+
});
|
|
15447
|
+
if (!model) throw new Error(`Could not load entity ${definition.asset}`);
|
|
15448
|
+
const entity = await content.addEntity(model, { ...definition.options, instanceMeshes: false });
|
|
15449
|
+
object3 = entity;
|
|
15450
|
+
if (definition.animation) {
|
|
15451
|
+
const animations = await Entities.getAnimations(key);
|
|
15452
|
+
const clip = animations?.[definition.animation.name];
|
|
15453
|
+
if (!clip) throw new Error(`Entity ${definition.asset} has no animation "${definition.animation.name}"`);
|
|
15454
|
+
entity.playAnimation(clip, definition.animation);
|
|
15455
|
+
}
|
|
15456
|
+
break;
|
|
15457
|
+
}
|
|
15458
|
+
case "gui":
|
|
15459
|
+
object3 = await content.initialize(new GuiObject(definition.layers));
|
|
15460
|
+
break;
|
|
15461
|
+
}
|
|
15462
|
+
let disposed = false;
|
|
15463
|
+
const loaded = {
|
|
15464
|
+
root,
|
|
15465
|
+
object: object3,
|
|
15466
|
+
definition,
|
|
15467
|
+
advanceAnimation: (delta) => {
|
|
15468
|
+
if (!disposed && definition.type === "entity" && !definition.animation?.paused) object3.advanceAnimation(delta);
|
|
15469
|
+
},
|
|
15470
|
+
dispose: () => {
|
|
15471
|
+
if (disposed) return;
|
|
15472
|
+
disposed = true;
|
|
15473
|
+
root.removeFromParent();
|
|
15474
|
+
object3.dispose();
|
|
15475
|
+
object3.removeFromParent();
|
|
15476
|
+
content.dispose();
|
|
15477
|
+
root.clear();
|
|
15478
|
+
scene.dirty = true;
|
|
15479
|
+
}
|
|
15480
|
+
};
|
|
15481
|
+
parent?.add(root);
|
|
15482
|
+
scene.dirty = true;
|
|
15483
|
+
return loaded;
|
|
15484
|
+
} catch (error) {
|
|
15485
|
+
object3?.dispose();
|
|
15486
|
+
object3?.removeFromParent();
|
|
15487
|
+
content.dispose();
|
|
15488
|
+
root.removeFromParent();
|
|
15489
|
+
root.clear();
|
|
15490
|
+
throw new Error(`Scene object "${definition.name ?? definition.id}": ${error instanceof Error ? error.message : String(error)}`);
|
|
15491
|
+
}
|
|
15492
|
+
}
|
|
15493
|
+
};
|
|
15494
|
+
|
|
15080
15495
|
// src/texture/index.ts
|
|
15081
15496
|
init_Colormaps();
|
|
15082
15497
|
init_TextureAtlas();
|
|
@@ -15430,16 +15845,16 @@ var SectionModels = class {
|
|
|
15430
15845
|
if (!models) this.models.set(model, models = /* @__PURE__ */ new Map());
|
|
15431
15846
|
const key = JSON.stringify([rotation.x, rotation.y, rotation.z, variant.uvlock, tints]);
|
|
15432
15847
|
const template = await cached(models, key, async () => {
|
|
15433
|
-
const
|
|
15848
|
+
const object3 = new SectionModel(model, {
|
|
15434
15849
|
instanceMeshes: false,
|
|
15435
15850
|
mergeMeshes: false,
|
|
15436
15851
|
tints,
|
|
15437
15852
|
uvLockRotation: variant.uvlock && (rotation.x !== 0 || rotation.y !== 0) ? [rotation.x, rotation.y, rotation.z] : void 0
|
|
15438
15853
|
});
|
|
15439
|
-
await
|
|
15440
|
-
const geometry =
|
|
15854
|
+
await object3.init();
|
|
15855
|
+
const geometry = object3.children[0].geometry;
|
|
15441
15856
|
geometry.applyMatrix4(new Matrix412().makeRotationFromEuler(rotation));
|
|
15442
|
-
|
|
15857
|
+
object3.clear();
|
|
15443
15858
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
15444
15859
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
15445
15860
|
if (local < 0) return 0;
|
|
@@ -15655,10 +16070,10 @@ var MineRenderWorld = class {
|
|
|
15655
16070
|
await block.object.updateFluid((x, y, z) => {
|
|
15656
16071
|
const neighbor = pos.clone().add(new Vector316(x, y, z));
|
|
15657
16072
|
const section = this.getChunkAt(neighbor);
|
|
15658
|
-
const
|
|
16073
|
+
const object3 = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
|
|
15659
16074
|
return {
|
|
15660
|
-
fluid:
|
|
15661
|
-
level:
|
|
16075
|
+
fluid: object3?.fluidKind,
|
|
16076
|
+
level: object3?.fluidLevel,
|
|
15662
16077
|
solid: section?.isOccludingAt(neighbor) ?? false
|
|
15663
16078
|
};
|
|
15664
16079
|
});
|
|
@@ -15734,8 +16149,8 @@ init_Model();
|
|
|
15734
16149
|
// src/world/SectionMesh.ts
|
|
15735
16150
|
init_CanvasCompat();
|
|
15736
16151
|
init_Materials();
|
|
15737
|
-
import { BufferGeometry as BufferGeometry8, Float32BufferAttribute as Float32BufferAttribute8, Group as
|
|
15738
|
-
var SectionMesh = class _SectionMesh extends
|
|
16152
|
+
import { BufferGeometry as BufferGeometry8, Float32BufferAttribute as Float32BufferAttribute8, Group as Group3, Mesh as Mesh9 } from "three";
|
|
16153
|
+
var SectionMesh = class _SectionMesh extends Group3 {
|
|
15739
16154
|
constructor() {
|
|
15740
16155
|
super(...arguments);
|
|
15741
16156
|
this.ownedMeshes = [];
|
|
@@ -15788,7 +16203,7 @@ var SectionMesh = class _SectionMesh extends Group2 {
|
|
|
15788
16203
|
const normal = template.geometry.getAttribute("normal");
|
|
15789
16204
|
const uv = template.geometry.getAttribute("uv");
|
|
15790
16205
|
const bounds = template.geometry.getAttribute("uvBounds");
|
|
15791
|
-
const
|
|
16206
|
+
const color2 = template.geometry.getAttribute("color");
|
|
15792
16207
|
const sourceIndices = template.geometry.getIndex();
|
|
15793
16208
|
const placement = locations.get(template.atlas).placement;
|
|
15794
16209
|
const mapU = (u) => (placement.x + u * template.atlas.image.width) / page.width;
|
|
@@ -15810,7 +16225,7 @@ var SectionMesh = class _SectionMesh extends Group2 {
|
|
|
15810
16225
|
mapU(bounds?.getZ(vertex) ?? 1),
|
|
15811
16226
|
mapV(bounds?.getW(vertex) ?? 1)
|
|
15812
16227
|
);
|
|
15813
|
-
colors.push(
|
|
16228
|
+
colors.push(color2?.getX(vertex) ?? 1, color2?.getY(vertex) ?? 1, color2?.getZ(vertex) ?? 1);
|
|
15814
16229
|
}
|
|
15815
16230
|
for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
|
|
15816
16231
|
}
|
|
@@ -15898,7 +16313,7 @@ var Chunk = class _Chunk {
|
|
|
15898
16313
|
this.renderedBlocks.get(index)?.object?.removeFromScene();
|
|
15899
16314
|
if (this.sectionBlocks.delete(index)) this.meshDirty = true;
|
|
15900
16315
|
this.renderedBlocks.delete(index);
|
|
15901
|
-
let
|
|
16316
|
+
let object3;
|
|
15902
16317
|
try {
|
|
15903
16318
|
if (!readBlock) return void 0;
|
|
15904
16319
|
const stored = readBlock();
|
|
@@ -15913,22 +16328,22 @@ var Chunk = class _Chunk {
|
|
|
15913
16328
|
this.sectionBlocks.set(index, { index, template, cullMask: 0 });
|
|
15914
16329
|
this.meshDirty = true;
|
|
15915
16330
|
} else {
|
|
15916
|
-
|
|
16331
|
+
object3 = await this.scene.addBlock(blockState, {
|
|
15917
16332
|
mergeMeshes: true,
|
|
15918
16333
|
instanceMeshes: true,
|
|
15919
16334
|
maxInstanceCount: 2e3,
|
|
15920
16335
|
initialState: stored.properties
|
|
15921
16336
|
});
|
|
15922
|
-
|
|
16337
|
+
object3.setPosition(MineRenderWorld.worldToScenePosition(worldPos));
|
|
15923
16338
|
}
|
|
15924
16339
|
const info = { get block() {
|
|
15925
16340
|
return readBlock();
|
|
15926
|
-
}, object:
|
|
16341
|
+
}, object: object3 };
|
|
15927
16342
|
this.renderedBlocks.set(index, info);
|
|
15928
16343
|
return info;
|
|
15929
16344
|
} catch (error) {
|
|
15930
16345
|
this.data.set(index, void 0);
|
|
15931
|
-
|
|
16346
|
+
object3?.removeFromScene();
|
|
15932
16347
|
throw error;
|
|
15933
16348
|
} finally {
|
|
15934
16349
|
await onBlocksChanged?.([worldPos]);
|
|
@@ -16111,6 +16526,7 @@ export {
|
|
|
16111
16526
|
RequestError,
|
|
16112
16527
|
Requests,
|
|
16113
16528
|
SKIN_PARTS,
|
|
16529
|
+
SceneDocumentLoader,
|
|
16114
16530
|
SceneExporter,
|
|
16115
16531
|
SceneInspector,
|
|
16116
16532
|
SceneObject,
|
|
@@ -16186,6 +16602,7 @@ export {
|
|
|
16186
16602
|
mergeBufferAttributes,
|
|
16187
16603
|
mergeBufferGeometries,
|
|
16188
16604
|
mergeVertices,
|
|
16605
|
+
parseSceneDocument,
|
|
16189
16606
|
prefix,
|
|
16190
16607
|
registerNodeEnv,
|
|
16191
16608
|
sampleEntityAnimation,
|