minerender 2.1.0-alpha.76 → 2.1.0-alpha.78

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.
@@ -864,8 +864,8 @@ var init_Textures = __esm({
864
864
  for (let y = 0; y < size; y++) {
865
865
  for (let x = 0; x < size; x++) {
866
866
  const offset = (y * size + x) * 4;
867
- const color = (x + y) % 2 === 0 ? 255 : 0;
868
- data[offset] = data[offset + 2] = color;
867
+ const color2 = (x + y) % 2 === 0 ? 255 : 0;
868
+ data[offset] = data[offset + 2] = color2;
869
869
  data[offset + 3] = 255;
870
870
  }
871
871
  }
@@ -1450,17 +1450,17 @@ var init_AssetKey = __esm({
1450
1450
  var DisplayPosition, DISPLAY_POSITIONS;
1451
1451
  var init_DisplayPosition = __esm({
1452
1452
  "src/model/DisplayPosition.ts"() {
1453
- DisplayPosition = /* @__PURE__ */ ((DisplayPosition2) => {
1454
- DisplayPosition2["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
1455
- DisplayPosition2["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
1456
- DisplayPosition2["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
1457
- DisplayPosition2["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
1458
- DisplayPosition2["GUI"] = "gui";
1459
- DisplayPosition2["HEAD"] = "head";
1460
- DisplayPosition2["GROUND"] = "ground";
1461
- DisplayPosition2["FIXED"] = "fixed";
1462
- DisplayPosition2["ON_SHELF"] = "on_shelf";
1463
- return DisplayPosition2;
1453
+ DisplayPosition = /* @__PURE__ */ ((DisplayPosition3) => {
1454
+ DisplayPosition3["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
1455
+ DisplayPosition3["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
1456
+ DisplayPosition3["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
1457
+ DisplayPosition3["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
1458
+ DisplayPosition3["GUI"] = "gui";
1459
+ DisplayPosition3["HEAD"] = "head";
1460
+ DisplayPosition3["GROUND"] = "ground";
1461
+ DisplayPosition3["FIXED"] = "fixed";
1462
+ DisplayPosition3["ON_SHELF"] = "on_shelf";
1463
+ return DisplayPosition3;
1464
1464
  })(DisplayPosition || {});
1465
1465
  DISPLAY_POSITIONS = Object.values(DisplayPosition);
1466
1466
  }
@@ -1678,11 +1678,11 @@ var init_Models = __esm({
1678
1678
  return this.PERSISTENT_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), (k1) => {
1679
1679
  return AssetLoader.get(key, "model" /* MODEL */);
1680
1680
  });
1681
- }).then((asset) => {
1682
- if (asset) {
1683
- asset.key = key;
1681
+ }).then((asset2) => {
1682
+ if (asset2) {
1683
+ asset2.key = key;
1684
1684
  }
1685
- return asset;
1685
+ return asset2;
1686
1686
  });
1687
1687
  }
1688
1688
  /**
@@ -1772,11 +1772,11 @@ var init_BlockStates = __esm({
1772
1772
  return this.PERSISTENT_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), (k1) => {
1773
1773
  return AssetLoader.get(key, "blockstate" /* BLOCKSTATE */);
1774
1774
  });
1775
- }).then((asset) => {
1776
- if (asset) {
1777
- asset.key = key;
1775
+ }).then((asset2) => {
1776
+ if (asset2) {
1777
+ asset2.key = key;
1778
1778
  }
1779
- return asset;
1779
+ return asset2;
1780
1780
  });
1781
1781
  }
1782
1782
  static getAll(keys) {
@@ -1925,29 +1925,29 @@ function applyGenericRotation(axis, rotation, obj) {
1925
1925
  break;
1926
1926
  }
1927
1927
  }
1928
- function addBox3WireframeToObject(box, obj, color = 16777215, w = 2) {
1928
+ function addBox3WireframeToObject(box, obj, color2 = 16777215, w = 2) {
1929
1929
  let size = new import_three8.Vector3();
1930
1930
  box.getSize(size);
1931
1931
  let boxGeo = new import_three8.BoxGeometry(size.x, size.y, size.z, 1, 1, 1);
1932
1932
  let wireGeo = new import_three8.EdgesGeometry(boxGeo);
1933
- let wireMat = new import_three8.LineBasicMaterial({ color, linewidth: w });
1933
+ let wireMat = new import_three8.LineBasicMaterial({ color: color2, linewidth: w });
1934
1934
  let wireframe = new import_three8.LineSegments(wireGeo, wireMat);
1935
1935
  obj.add(wireframe);
1936
1936
  let axes = new import_three8.AxesHelper(1);
1937
1937
  obj.add(axes);
1938
1938
  }
1939
- function addWireframeToObject(obj, color = 16777215, w = 2) {
1939
+ function addWireframeToObject(obj, color2 = 16777215, w = 2) {
1940
1940
  let boxGeo = new import_three8.BoxGeometry(16, 16, 16, 1, 1, 1);
1941
1941
  let wireGeo = new import_three8.EdgesGeometry(boxGeo);
1942
- let wireMat = new import_three8.LineBasicMaterial({ color, linewidth: w });
1942
+ let wireMat = new import_three8.LineBasicMaterial({ color: color2, linewidth: w });
1943
1943
  let wireframe = new import_three8.LineSegments(wireGeo, wireMat);
1944
1944
  obj.add(wireframe);
1945
1945
  let axes = new import_three8.AxesHelper(1);
1946
1946
  obj.add(axes);
1947
1947
  }
1948
- function addWireframeToMesh(geo, mesh, color = 16777215, w = 2) {
1948
+ function addWireframeToMesh(geo, mesh, color2 = 16777215, w = 2) {
1949
1949
  let wireGeo = new import_three8.EdgesGeometry(geo);
1950
- let wireMat = new import_three8.LineBasicMaterial({ color, linewidth: w });
1950
+ let wireMat = new import_three8.LineBasicMaterial({ color: color2, linewidth: w });
1951
1951
  let wireframe = new import_three8.LineSegments(wireGeo, wireMat);
1952
1952
  mesh.add(wireframe);
1953
1953
  let axes = new import_three8.AxesHelper(1);
@@ -2396,27 +2396,27 @@ var init_PackFormats = __esm({
2396
2396
  this.versions = /* @__PURE__ */ new Map();
2397
2397
  }
2398
2398
  /** Resolves pack formats from Mojang's client metadata hosted on assets.mcasset.cloud. */
2399
- static async get(version, type) {
2400
- let pending = this.versions.get(version);
2399
+ static async get(version2, type) {
2400
+ let pending = this.versions.get(version2);
2401
2401
  if (!pending || pending.expires <= Date.now()) {
2402
2402
  pending = {
2403
- formats: this.load(version),
2404
- expires: ["latest", "release", "snapshot"].includes(version) ? Date.now() + 3e5 : Infinity
2403
+ formats: this.load(version2),
2404
+ expires: ["latest", "release", "snapshot"].includes(version2) ? Date.now() + 3e5 : Infinity
2405
2405
  };
2406
- this.versions.set(version, pending);
2406
+ this.versions.set(version2, pending);
2407
2407
  }
2408
2408
  try {
2409
2409
  return (await pending.formats)[type];
2410
2410
  } catch (cause) {
2411
- if (this.versions.get(version) === pending) this.versions.delete(version);
2411
+ if (this.versions.get(version2) === pending) this.versions.delete(version2);
2412
2412
  const option = type === "assets" ? "resourcePackFormat" : "dataPackFormat";
2413
2413
  const reason = cause instanceof Error ? cause.message : String(cause);
2414
- throw new Error(`Could not resolve the pack format for Minecraft ${version}. Set ArchiveAssetSource ${option} explicitly. ${reason}`);
2414
+ throw new Error(`Could not resolve the pack format for Minecraft ${version2}. Set ArchiveAssetSource ${option} explicitly. ${reason}`);
2415
2415
  }
2416
2416
  }
2417
- static async load(version) {
2417
+ static async load(version2) {
2418
2418
  const response = await Requests.genericRequest({
2419
- url: `https://assets.mcasset.cloud/${encodeURIComponent(version)}/game-version.json`,
2419
+ url: `https://assets.mcasset.cloud/${encodeURIComponent(version2)}/game-version.json`,
2420
2420
  responseType: "json"
2421
2421
  });
2422
2422
  const data = response.data;
@@ -2504,7 +2504,7 @@ var init_ArchiveAssetSource = __esm({
2504
2504
  }
2505
2505
  async load(key, parser) {
2506
2506
  const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
2507
- const version = AssetLoader.version;
2507
+ const version2 = AssetLoader.version;
2508
2508
  let selectedPath = path;
2509
2509
  let url;
2510
2510
  try {
@@ -2512,7 +2512,7 @@ var init_ArchiveAssetSource = __esm({
2512
2512
  if (key.rootType === "assets" || key.rootType === "data") {
2513
2513
  const metadata = await this.getMetadata(key);
2514
2514
  if (metadata.hasOverlays) {
2515
- const format2 = (key.rootType === "assets" ? this.options.resourcePackFormat : this.options.dataPackFormat) ?? await PackFormats.get(version, key.rootType);
2515
+ const format2 = (key.rootType === "assets" ? this.options.resourcePackFormat : this.options.dataPackFormat) ?? await PackFormats.get(version2, key.rootType);
2516
2516
  directories = metadata.overlayDirectories(format2);
2517
2517
  }
2518
2518
  }
@@ -2610,8 +2610,8 @@ var init_AssetLoader = __esm({
2610
2610
  return this.ROOT.substring(this.ROOT.lastIndexOf("/") + 1);
2611
2611
  }
2612
2612
  /** Selects an mcasset.cloud version, updates the vanilla source, and clears in-memory caches. */
2613
- static setVersion(version) {
2614
- this.ROOT = `https://assets.mcasset.cloud/${version}`;
2613
+ static setVersion(version2) {
2614
+ this.ROOT = `https://assets.mcasset.cloud/${version2}`;
2615
2615
  const source = new HostedAssetSource(this.ROOT, { retryDefaults: false });
2616
2616
  const index = this._SOURCES.findIndex((s) => s.key === "mcassets");
2617
2617
  if (index !== -1) {
@@ -2680,8 +2680,8 @@ ${key}` : key;
2680
2680
  const sources = [...this._SOURCES];
2681
2681
  const results = [];
2682
2682
  for (const { source } of sources) {
2683
- const asset = await source.get(key, parser);
2684
- if (asset != void 0) results.push(asset);
2683
+ const asset2 = await source.get(key, parser);
2684
+ if (asset2 != void 0) results.push(asset2);
2685
2685
  if (await source.blocks(key)) break;
2686
2686
  }
2687
2687
  return results;
@@ -2743,9 +2743,9 @@ var init_ModelTextures = __esm({
2743
2743
  const pending = this.preload(key);
2744
2744
  const cached2 = Caching.textureAssetCache.getIfPresent(keyStr);
2745
2745
  try {
2746
- const asset = await pending;
2747
- if (asset) {
2748
- return await ImageLoader.infoToCanvasData(asset);
2746
+ const asset2 = await pending;
2747
+ if (asset2) {
2748
+ return await ImageLoader.infoToCanvasData(asset2);
2749
2749
  }
2750
2750
  return void 0;
2751
2751
  } catch (err) {
@@ -2759,10 +2759,10 @@ var init_ModelTextures = __esm({
2759
2759
  static async preload(key) {
2760
2760
  const keyStr = key.serialize();
2761
2761
  return Caching.textureAssetCache.get(keyStr, (k) => {
2762
- return AssetLoader.get(key, "image" /* IMAGE */).then((asset) => {
2763
- if (asset)
2764
- asset.key = key;
2765
- return asset;
2762
+ return AssetLoader.get(key, "image" /* IMAGE */).then((asset2) => {
2763
+ if (asset2)
2764
+ asset2.key = key;
2765
+ return asset2;
2766
2766
  });
2767
2767
  });
2768
2768
  }
@@ -2775,10 +2775,10 @@ var init_ModelTextures = __esm({
2775
2775
  const keyStr = key.serialize();
2776
2776
  return Caching.textureMetaCache.get(keyStr, (k) => {
2777
2777
  return this.PERSISTENT_META_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), (k1) => {
2778
- return AssetLoader.get(key, "meta" /* META */).then((asset) => {
2779
- if (asset)
2780
- asset.key = key;
2781
- return asset;
2778
+ return AssetLoader.get(key, "meta" /* META */).then((asset2) => {
2779
+ if (asset2)
2780
+ asset2.key = key;
2781
+ return asset2;
2782
2782
  });
2783
2783
  });
2784
2784
  });
@@ -3347,12 +3347,12 @@ var init_UVMapper = __esm({
3347
3347
  } else {
3348
3348
  uniqueTextureNames.push(textureKey);
3349
3349
  const assetKey = AssetKey.parse("textures", textureValue, model.key);
3350
- promises.push(ModelTextures.get(assetKey).then((asset) => {
3351
- if (!asset) {
3350
+ promises.push(ModelTextures.get(assetKey).then((asset2) => {
3351
+ if (!asset2) {
3352
3352
  console.warn(p5, "Missing texture", assetKey);
3353
3353
  return;
3354
3354
  }
3355
- textureMap[textureKey] = new WrappedImage(asset);
3355
+ textureMap[textureKey] = new WrappedImage(asset2);
3356
3356
  }));
3357
3357
  promises.push(ModelTextures.getMeta(assetKey).then((meta) => {
3358
3358
  metaMap[textureKey] = meta;
@@ -3696,10 +3696,10 @@ var init_Entities = __esm({
3696
3696
  const collect = async (path) => {
3697
3697
  const prefix2 = path ? `${path}/` : "";
3698
3698
  const key = new AssetKey(DEFAULT_NAMESPACE, `${prefix2}_list`, void 0, void 0, "entity-models", ".json");
3699
- const list = await Caching.listAssetCache.get(key.serialize(), () => AssetLoader.get(key, "list" /* LIST */));
3700
- if (!list) return [];
3701
- const files = list.files.filter((file) => file.endsWith(".json") && file !== "_list.json").map((file) => `${prefix2}${file.slice(0, -5)}`);
3702
- const children = await Promise.all(list.directories.map((directory) => collect(`${prefix2}${directory}`)));
3699
+ const list2 = await Caching.listAssetCache.get(key.serialize(), () => AssetLoader.get(key, "list" /* LIST */));
3700
+ if (!list2) return [];
3701
+ const files = list2.files.filter((file) => file.endsWith(".json") && file !== "_list.json").map((file) => `${prefix2}${file.slice(0, -5)}`);
3702
+ const children = await Promise.all(list2.directories.map((directory) => collect(`${prefix2}${directory}`)));
3703
3703
  return [...files, ...children.flat()];
3704
3704
  };
3705
3705
  return collect("");
@@ -3783,8 +3783,8 @@ var init_Entities = __esm({
3783
3783
  if (await ModelTextures.get(texture2)) return texture2;
3784
3784
  }
3785
3785
  const listKey = new AssetKey(modelKey.namespace, "_list", `${name}_variant`, void 0, "data", ".json", root);
3786
- const list = await AssetLoader.get(listKey, "list" /* LIST */);
3787
- const files = list?.files.filter((file2) => file2.endsWith(".json") && file2 !== "_list.json");
3786
+ const list2 = await AssetLoader.get(listKey, "list" /* LIST */);
3787
+ const files = list2?.files.filter((file2) => file2.endsWith(".json") && file2 !== "_list.json");
3788
3788
  const file = files?.find((file2) => file2 === "temperate.json") ?? files?.[0];
3789
3789
  if (!file) return void 0;
3790
3790
  const variantKey = new AssetKey(modelKey.namespace, file.slice(0, -5), `${name}_variant`, void 0, "data", ".json", root);
@@ -3889,27 +3889,27 @@ var init_EntityAnimationPlayer = __esm({
3889
3889
  for (const layer of layers) {
3890
3890
  const objects = [];
3891
3891
  if (poses) {
3892
- layer.traverse((object2) => {
3893
- if (poses.has(object2)) objects.push(object2);
3892
+ layer.traverse((object3) => {
3893
+ if (poses.has(object3)) objects.push(object3);
3894
3894
  });
3895
3895
  } else {
3896
3896
  for (const bone of Object.keys(animation.bones)) {
3897
- const object2 = layer.getObjectByName(`group:${bone}`);
3898
- if (object2) objects.push(object2);
3897
+ const object3 = layer.getObjectByName(`group:${bone}`);
3898
+ if (object3) objects.push(object3);
3899
3899
  }
3900
3900
  }
3901
- for (const object2 of objects) {
3902
- const bone = object2.name.slice("group:".length);
3903
- const pose = poses?.get(object2);
3901
+ for (const object3 of objects) {
3902
+ const bone = object3.name.slice("group:".length);
3903
+ const pose = poses?.get(object3);
3904
3904
  this.parts.push({
3905
3905
  bone,
3906
- object: object2,
3907
- position: object2.position.clone(),
3908
- rotation: object2.rotation.clone(),
3909
- scale: object2.scale.clone(),
3910
- basePosition: pose ? new import_three11.Vector3(...pose.offset) : object2.position.clone(),
3911
- baseRotation: pose ? new import_three11.Euler(...pose.rotation, "ZYX") : object2.rotation.clone(),
3912
- baseScale: pose ? new import_three11.Vector3(...pose.scale ?? [1, 1, 1]) : object2.scale.clone()
3906
+ object: object3,
3907
+ position: object3.position.clone(),
3908
+ rotation: object3.rotation.clone(),
3909
+ scale: object3.scale.clone(),
3910
+ basePosition: pose ? new import_three11.Vector3(...pose.offset) : object3.position.clone(),
3911
+ baseRotation: pose ? new import_three11.Euler(...pose.rotation, "ZYX") : object3.rotation.clone(),
3912
+ baseScale: pose ? new import_three11.Vector3(...pose.scale ?? [1, 1, 1]) : object3.scale.clone()
3913
3913
  });
3914
3914
  }
3915
3915
  }
@@ -4275,10 +4275,10 @@ var init_SceneObject = __esm({
4275
4275
  return new import_three12.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
4276
4276
  };
4277
4277
  const matrix = grow(mesh.instanceMatrix, 0);
4278
- const color = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
4278
+ const color2 = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
4279
4279
  mesh.dispose();
4280
4280
  mesh.instanceMatrix = matrix;
4281
- mesh.instanceColor = color;
4281
+ mesh.instanceColor = color2;
4282
4282
  }
4283
4283
  *activeInstanceIndices() {
4284
4284
  if (this.instanceMesh) {
@@ -4451,15 +4451,15 @@ var init_SceneObject = __esm({
4451
4451
  }
4452
4452
  }
4453
4453
  //</editor-fold>
4454
- toggleObjectVisibility(object2, visible) {
4455
- if (object2) {
4454
+ toggleObjectVisibility(object3, visible) {
4455
+ if (object3) {
4456
4456
  if (typeof visible !== "undefined") {
4457
- object2.visible = visible;
4457
+ object3.visible = visible;
4458
4458
  } else {
4459
- object2.visible = !object2.visible;
4459
+ object3.visible = !object3.visible;
4460
4460
  }
4461
4461
  this.notifyDirty();
4462
- return object2.visible;
4462
+ return object3.visible;
4463
4463
  }
4464
4464
  this.notifyDirty();
4465
4465
  return false;
@@ -4755,8 +4755,8 @@ var init_EntityObject = __esm({
4755
4755
  this.scrollMaterials.push({ material: mat, offset: mat.map.offset, speed: scroll });
4756
4756
  }
4757
4757
  }
4758
- this.getLayerGroup(name)?.traverse((object2) => {
4759
- if (isMesh(object2)) object2.material = mat;
4758
+ this.getLayerGroup(name)?.traverse((object3) => {
4759
+ if (isMesh(object3)) object3.material = mat;
4760
4760
  });
4761
4761
  }));
4762
4762
  if (!this.children.length) {
@@ -5084,8 +5084,8 @@ function toTrianglesDrawMode(geometry, drawMode) {
5084
5084
  return geometry;
5085
5085
  }
5086
5086
  }
5087
- function computeMorphedAttributes(object2) {
5088
- if (object2.geometry.isBufferGeometry !== true) {
5087
+ function computeMorphedAttributes(object3) {
5088
+ if (object3.geometry.isBufferGeometry !== true) {
5089
5089
  console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
5090
5090
  return null;
5091
5091
  }
@@ -5098,11 +5098,11 @@ function computeMorphedAttributes(object2) {
5098
5098
  const _morphA = new import_three22.Vector3();
5099
5099
  const _morphB = new import_three22.Vector3();
5100
5100
  const _morphC = new import_three22.Vector3();
5101
- function _calculateMorphedAttributeData(object3, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
5101
+ function _calculateMorphedAttributeData(object4, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
5102
5102
  _vA.fromBufferAttribute(attribute, a2);
5103
5103
  _vB.fromBufferAttribute(attribute, b2);
5104
5104
  _vC.fromBufferAttribute(attribute, c2);
5105
- const morphInfluences = object3.morphTargetInfluences;
5105
+ const morphInfluences = object4.morphTargetInfluences;
5106
5106
  if (material2.morphTargets && morphAttribute && morphInfluences) {
5107
5107
  _morphA.set(0, 0, 0);
5108
5108
  _morphB.set(0, 0, 0);
@@ -5128,10 +5128,10 @@ function computeMorphedAttributes(object2) {
5128
5128
  _vB.add(_morphB);
5129
5129
  _vC.add(_morphC);
5130
5130
  }
5131
- if (object3.isSkinnedMesh) {
5132
- object3.boneTransform(a2, _vA);
5133
- object3.boneTransform(b2, _vB);
5134
- object3.boneTransform(c2, _vC);
5131
+ if (object4.isSkinnedMesh) {
5132
+ object4.boneTransform(a2, _vA);
5133
+ object4.boneTransform(b2, _vB);
5134
+ object4.boneTransform(c2, _vC);
5135
5135
  }
5136
5136
  modifiedAttributeArray[a2 * 3 + 0] = _vA.x;
5137
5137
  modifiedAttributeArray[a2 * 3 + 1] = _vA.y;
@@ -5143,8 +5143,8 @@ function computeMorphedAttributes(object2) {
5143
5143
  modifiedAttributeArray[c2 * 3 + 1] = _vC.y;
5144
5144
  modifiedAttributeArray[c2 * 3 + 2] = _vC.z;
5145
5145
  }
5146
- const geometry = object2.geometry;
5147
- const material = object2.material;
5146
+ const geometry = object3.geometry;
5147
+ const material = object3.material;
5148
5148
  let a, b, c;
5149
5149
  const index = geometry.index;
5150
5150
  const positionAttribute = geometry.attributes.position;
@@ -5171,7 +5171,7 @@ function computeMorphedAttributes(object2) {
5171
5171
  b = index.getX(j + 1);
5172
5172
  c = index.getX(j + 2);
5173
5173
  _calculateMorphedAttributeData(
5174
- object2,
5174
+ object3,
5175
5175
  groupMaterial,
5176
5176
  positionAttribute,
5177
5177
  morphPosition,
@@ -5182,7 +5182,7 @@ function computeMorphedAttributes(object2) {
5182
5182
  modifiedPosition
5183
5183
  );
5184
5184
  _calculateMorphedAttributeData(
5185
- object2,
5185
+ object3,
5186
5186
  groupMaterial,
5187
5187
  normalAttribute,
5188
5188
  morphNormal,
@@ -5202,7 +5202,7 @@ function computeMorphedAttributes(object2) {
5202
5202
  b = index.getX(i + 1);
5203
5203
  c = index.getX(i + 2);
5204
5204
  _calculateMorphedAttributeData(
5205
- object2,
5205
+ object3,
5206
5206
  material,
5207
5207
  positionAttribute,
5208
5208
  morphPosition,
@@ -5213,7 +5213,7 @@ function computeMorphedAttributes(object2) {
5213
5213
  modifiedPosition
5214
5214
  );
5215
5215
  _calculateMorphedAttributeData(
5216
- object2,
5216
+ object3,
5217
5217
  material,
5218
5218
  normalAttribute,
5219
5219
  morphNormal,
@@ -5237,7 +5237,7 @@ function computeMorphedAttributes(object2) {
5237
5237
  b = j + 1;
5238
5238
  c = j + 2;
5239
5239
  _calculateMorphedAttributeData(
5240
- object2,
5240
+ object3,
5241
5241
  groupMaterial,
5242
5242
  positionAttribute,
5243
5243
  morphPosition,
@@ -5248,7 +5248,7 @@ function computeMorphedAttributes(object2) {
5248
5248
  modifiedPosition
5249
5249
  );
5250
5250
  _calculateMorphedAttributeData(
5251
- object2,
5251
+ object3,
5252
5252
  groupMaterial,
5253
5253
  normalAttribute,
5254
5254
  morphNormal,
@@ -5268,7 +5268,7 @@ function computeMorphedAttributes(object2) {
5268
5268
  b = i + 1;
5269
5269
  c = i + 2;
5270
5270
  _calculateMorphedAttributeData(
5271
- object2,
5271
+ object3,
5272
5272
  material,
5273
5273
  positionAttribute,
5274
5274
  morphPosition,
@@ -5279,7 +5279,7 @@ function computeMorphedAttributes(object2) {
5279
5279
  modifiedPosition
5280
5280
  );
5281
5281
  _calculateMorphedAttributeData(
5282
- object2,
5282
+ object3,
5283
5283
  material,
5284
5284
  normalAttribute,
5285
5285
  morphNormal,
@@ -5537,9 +5537,9 @@ var init_ItemTints = __esm({
5537
5537
  }));
5538
5538
  return colors;
5539
5539
  }
5540
- static rgb(color) {
5541
- if (!Array.isArray(color)) return color & 16777215;
5542
- const [red, green, blue] = color.map((channel) => Math.floor(Math.fround(Math.fround(channel) * 255)));
5540
+ static rgb(color2) {
5541
+ if (!Array.isArray(color2)) return color2 & 16777215;
5542
+ const [red, green, blue] = color2.map((channel) => Math.floor(Math.fround(Math.fround(channel) * 255)));
5543
5543
  return red << 16 | green << 8 | blue;
5544
5544
  }
5545
5545
  };
@@ -5595,13 +5595,13 @@ var init_ModelObject = __esm({
5595
5595
  transform.multiply(new import_three25.Matrix4().makeTranslation(-8, -8, -8));
5596
5596
  try {
5597
5597
  for (const part of parts) {
5598
- const object2 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
5599
- object2.matrix.copy(transform).multiply(part.transform);
5600
- object2.matrixWorldNeedsUpdate = true;
5601
- object2.matrixAutoUpdate = false;
5602
- this.add(object2);
5603
- await object2.init();
5604
- object2.iterateAllMeshes((mesh) => {
5598
+ const object3 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
5599
+ object3.matrix.copy(transform).multiply(part.transform);
5600
+ object3.matrixWorldNeedsUpdate = true;
5601
+ object3.matrixAutoUpdate = false;
5602
+ this.add(object3);
5603
+ await object3.init();
5604
+ object3.iterateAllMeshes((mesh) => {
5605
5605
  const source = mesh.material;
5606
5606
  let material = this.specialMaterials.get(source);
5607
5607
  if (!material) {
@@ -5612,7 +5612,7 @@ var init_ModelObject = __esm({
5612
5612
  mesh.material = material;
5613
5613
  });
5614
5614
  for (const [name, rotation] of Object.entries(part.rotations)) {
5615
- object2.getGroupByName(name)?.rotation.set(...rotation, "ZYX");
5615
+ object3.getGroupByName(name)?.rotation.set(...rotation, "ZYX");
5616
5616
  }
5617
5617
  }
5618
5618
  } catch (error) {
@@ -5665,9 +5665,9 @@ var init_ModelObject = __esm({
5665
5665
  if (tintIndex === void 0 || tintIndex < 0) continue;
5666
5666
  const tint = this.options.tints[tintIndex];
5667
5667
  if (tint === void 0) continue;
5668
- const color = new import_three25.Color(tint);
5668
+ const color2 = new import_three25.Color(tint);
5669
5669
  for (let vertex = 0; vertex < 4; vertex++) {
5670
- color.toArray(colors, (faceIndex * 4 + vertex) * 3);
5670
+ color2.toArray(colors, (faceIndex * 4 + vertex) * 3);
5671
5671
  }
5672
5672
  }
5673
5673
  elGeo.setAttribute("color", new import_three25.BufferAttribute(colors, 3));
@@ -5982,9 +5982,9 @@ var init_FluidModelObject = __esm({
5982
5982
  }
5983
5983
  }
5984
5984
  geometry.clearGroups();
5985
- const color = new import_three31.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
5985
+ const color2 = new import_three31.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
5986
5986
  const colors = new Float32Array(geometry.getAttribute("position").count * 3);
5987
- for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
5987
+ for (let i = 0; i < colors.length; i += 3) color2.toArray(colors, i);
5988
5988
  geometry.setAttribute("color", new import_three31.BufferAttribute(colors, 3));
5989
5989
  geometry.computeBoundingBox();
5990
5990
  geometry.computeBoundingSphere();
@@ -6060,6 +6060,7 @@ __export(index_node_exports, {
6060
6060
  Env: () => Env,
6061
6061
  FluidModelObject: () => FluidModelObject,
6062
6062
  Fonts: () => Fonts,
6063
+ GUI_CONTAINER_LAYOUTS: () => GUI_CONTAINER_LAYOUTS,
6063
6064
  Geometries: () => Geometries,
6064
6065
  GuiHelper: () => GuiHelper,
6065
6066
  GuiLight: () => GuiLight,
@@ -6095,6 +6096,7 @@ __export(index_node_exports, {
6095
6096
  RequestError: () => RequestError,
6096
6097
  Requests: () => Requests,
6097
6098
  SKIN_PARTS: () => SKIN_PARTS,
6099
+ SceneDocumentLoader: () => SceneDocumentLoader,
6098
6100
  SceneExporter: () => SceneExporter,
6099
6101
  SceneInspector: () => SceneInspector,
6100
6102
  SceneObject: () => SceneObject,
@@ -6170,6 +6172,7 @@ __export(index_node_exports, {
6170
6172
  mergeBufferAttributes: () => mergeBufferAttributes,
6171
6173
  mergeBufferGeometries: () => mergeBufferGeometries,
6172
6174
  mergeVertices: () => mergeVertices,
6175
+ parseSceneDocument: () => parseSceneDocument,
6173
6176
  prefix: () => prefix,
6174
6177
  registerNodeEnv: () => registerNodeEnv,
6175
6178
  sampleEntityAnimation: () => sampleEntityAnimation,
@@ -6260,9 +6263,9 @@ var NodeEnv = class {
6260
6263
  imageSize(data) {
6261
6264
  return (0, import_image_size.default)(Buffer.isBuffer(data) ? data : Buffer.from(data));
6262
6265
  }
6263
- openCache(name, version) {
6266
+ openCache(name, version2) {
6264
6267
  return new NodeCache(import_node_persist.default.create({
6265
- dir: name + version,
6268
+ dir: name + version2,
6266
6269
  encoding: "utf8"
6267
6270
  }));
6268
6271
  }
@@ -6423,8 +6426,8 @@ var Fonts = class {
6423
6426
  const stack = await AssetLoader.getAll(key, "json" /* JSON */);
6424
6427
  if (stack.length === 0) throw new Error(`Could not load font ${key.toNamespacedString()}`);
6425
6428
  const glyphs = /* @__PURE__ */ new Map();
6426
- for (const asset of stack) {
6427
- for (const provider of asset.providers) {
6429
+ for (const asset2 of stack) {
6430
+ for (const provider of asset2.providers) {
6428
6431
  if (provider.filter?.uniform || provider.filter?.jp) continue;
6429
6432
  let provided;
6430
6433
  switch (provider.type) {
@@ -6563,13 +6566,13 @@ var OBJExporter = class {
6563
6566
  * @param {Object3D} object - The 3D object to export.
6564
6567
  * @return {string} The exported OBJ.
6565
6568
  */
6566
- parse(object2) {
6569
+ parse(object3) {
6567
6570
  let output = "";
6568
6571
  let indexVertex = 0;
6569
6572
  let indexVertexUvs = 0;
6570
6573
  let indexNormals = 0;
6571
6574
  const vertex = new import_three16.Vector3();
6572
- const color = new import_three16.Color();
6575
+ const color2 = new import_three16.Color();
6573
6576
  const normal = new import_three16.Vector3();
6574
6577
  const uv = new import_three16.Vector2();
6575
6578
  const face = [];
@@ -6668,9 +6671,9 @@ var OBJExporter = class {
6668
6671
  vertex.applyMatrix4(points.matrixWorld);
6669
6672
  output += "v " + vertex.x + " " + vertex.y + " " + vertex.z;
6670
6673
  if (colors !== void 0) {
6671
- color.fromBufferAttribute(colors, i);
6672
- import_three16.ColorManagement.workingToColorSpace(color, import_three16.SRGBColorSpace);
6673
- output += " " + color.r + " " + color.g + " " + color.b;
6674
+ color2.fromBufferAttribute(colors, i);
6675
+ import_three16.ColorManagement.workingToColorSpace(color2, import_three16.SRGBColorSpace);
6676
+ output += " " + color2.r + " " + color2.g + " " + color2.b;
6674
6677
  }
6675
6678
  output += "\n";
6676
6679
  }
@@ -6682,7 +6685,7 @@ var OBJExporter = class {
6682
6685
  }
6683
6686
  indexVertex += nbVertex;
6684
6687
  }
6685
- object2.traverse(function(child) {
6688
+ object3.traverse(function(child) {
6686
6689
  if (child.isMesh === true) {
6687
6690
  parseMesh(child);
6688
6691
  }
@@ -6710,9 +6713,9 @@ var PLYExporter = class {
6710
6713
  * @param {PLYExporter~Options} options - The export options.
6711
6714
  * @return {?(string|ArrayBuffer)} The exported PLY.
6712
6715
  */
6713
- parse(object2, onDone, options = {}) {
6716
+ parse(object3, onDone, options = {}) {
6714
6717
  function traverseMeshes(cb) {
6715
- object2.traverse(function(child) {
6718
+ object3.traverse(function(child) {
6716
6719
  if (child.isMesh === true || child.isPoints) {
6717
6720
  const mesh = child;
6718
6721
  const geometry = mesh.geometry;
@@ -6745,7 +6748,7 @@ var PLYExporter = class {
6745
6748
  for (const name of customAttributeNames) customTypes[name] = "float";
6746
6749
  let vertexCount = 0;
6747
6750
  let faceCount = 0;
6748
- object2.traverse(function(child) {
6751
+ object3.traverse(function(child) {
6749
6752
  if (child.isMesh === true) {
6750
6753
  const mesh = child;
6751
6754
  const geometry = mesh.geometry;
@@ -7339,8 +7342,8 @@ function equalArray(array1, array2) {
7339
7342
  return element === array2[index];
7340
7343
  });
7341
7344
  }
7342
- function stringToArrayBuffer(text) {
7343
- return new TextEncoder().encode(text).buffer;
7345
+ function stringToArrayBuffer(text2) {
7346
+ return new TextEncoder().encode(text2).buffer;
7344
7347
  }
7345
7348
  function isIdentityMatrix(matrix) {
7346
7349
  return equalArray(matrix.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
@@ -7533,12 +7536,12 @@ var GLTFWriter = class {
7533
7536
  * @param {THREE.Object3D|THREE.Material|THREE.BufferGeometry|THREE.AnimationClip} object
7534
7537
  * @param {Object} objectDef
7535
7538
  */
7536
- serializeUserData(object2, objectDef) {
7537
- if (Object.keys(object2.userData).length === 0) return;
7539
+ serializeUserData(object3, objectDef) {
7540
+ if (Object.keys(object3.userData).length === 0) return;
7538
7541
  const options = this.options;
7539
7542
  const extensionsUsed = this.extensionsUsed;
7540
7543
  try {
7541
- const json = JSON.parse(JSON.stringify(object2.userData));
7544
+ const json = JSON.parse(JSON.stringify(object3.userData));
7542
7545
  if (options.includeCustomExtensions && json.gltfExtensions) {
7543
7546
  if (objectDef.extensions === void 0) objectDef.extensions = {};
7544
7547
  for (const extensionName in json.gltfExtensions) {
@@ -7549,7 +7552,7 @@ var GLTFWriter = class {
7549
7552
  }
7550
7553
  if (Object.keys(json).length > 0) objectDef.extras = json;
7551
7554
  } catch (error) {
7552
- console.warn("THREE.GLTFExporter: userData of '" + object2.name + "' won't be serialized because of JSON.stringify error - " + error.message);
7555
+ console.warn("THREE.GLTFExporter: userData of '" + object3.name + "' won't be serialized because of JSON.stringify error - " + error.message);
7553
7556
  }
7554
7557
  }
7555
7558
  /**
@@ -8058,9 +8061,9 @@ var GLTFWriter = class {
8058
8061
  if (material.isMeshStandardMaterial !== true && material.isMeshBasicMaterial !== true) {
8059
8062
  console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");
8060
8063
  }
8061
- const color = material.color.toArray().concat([material.opacity]);
8062
- if (!equalArray(color, [1, 1, 1, 1])) {
8063
- materialDef.pbrMetallicRoughness.baseColorFactor = color;
8064
+ const color2 = material.color.toArray().concat([material.opacity]);
8065
+ if (!equalArray(color2, [1, 1, 1, 1])) {
8066
+ materialDef.pbrMetallicRoughness.baseColorFactor = color2;
8064
8067
  }
8065
8068
  if (material.isMeshStandardMaterial) {
8066
8069
  materialDef.pbrMetallicRoughness.metallicFactor = material.metalness;
@@ -8475,13 +8478,13 @@ var GLTFWriter = class {
8475
8478
  * @param {THREE.Object3D} object
8476
8479
  * @return {?number}
8477
8480
  */
8478
- processSkin(object2) {
8481
+ processSkin(object3) {
8479
8482
  const json = this.json;
8480
8483
  const nodeMap = this.nodeMap;
8481
- const node = json.nodes[nodeMap.get(object2)];
8482
- const skeleton = object2.skeleton;
8484
+ const node = json.nodes[nodeMap.get(object3)];
8485
+ const skeleton = object3.skeleton;
8483
8486
  if (skeleton === void 0) return null;
8484
- const rootJoint = object2.skeleton.bones[0];
8487
+ const rootJoint = object3.skeleton.bones[0];
8485
8488
  if (rootJoint === void 0) return null;
8486
8489
  const joints = [];
8487
8490
  const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
@@ -8489,7 +8492,7 @@ var GLTFWriter = class {
8489
8492
  for (let i = 0; i < skeleton.bones.length; ++i) {
8490
8493
  joints.push(nodeMap.get(skeleton.bones[i]));
8491
8494
  temporaryBoneInverse.copy(skeleton.boneInverses[i]);
8492
- temporaryBoneInverse.multiply(object2.bindMatrix).toArray(inverseBindMatrices, i * 16);
8495
+ temporaryBoneInverse.multiply(object3.bindMatrix).toArray(inverseBindMatrices, i * 16);
8493
8496
  }
8494
8497
  if (json.skins === void 0) json.skins = [];
8495
8498
  json.skins.push({
@@ -8505,19 +8508,19 @@ var GLTFWriter = class {
8505
8508
  * @param {THREE.Object3D} object Object3D to processNodeAsync
8506
8509
  * @return {Promise<number>} Index of the node in the nodes list
8507
8510
  */
8508
- async processNodeAsync(object2) {
8511
+ async processNodeAsync(object3) {
8509
8512
  const json = this.json;
8510
8513
  const options = this.options;
8511
8514
  const nodeMap = this.nodeMap;
8512
8515
  if (!json.nodes) json.nodes = [];
8513
- if (object2.pivot !== null) {
8514
- return await this._processNodeWithPivotAsync(object2);
8516
+ if (object3.pivot !== null) {
8517
+ return await this._processNodeWithPivotAsync(object3);
8515
8518
  }
8516
8519
  const nodeDef = {};
8517
8520
  if (options.trs) {
8518
- const rotation = object2.quaternion.toArray();
8519
- const position = object2.position.toArray();
8520
- const scale = object2.scale.toArray();
8521
+ const rotation = object3.quaternion.toArray();
8522
+ const position = object3.position.toArray();
8523
+ const scale = object3.scale.toArray();
8521
8524
  if (!equalArray(rotation, [0, 0, 0, 1])) {
8522
8525
  nodeDef.rotation = rotation;
8523
8526
  }
@@ -8528,28 +8531,28 @@ var GLTFWriter = class {
8528
8531
  nodeDef.scale = scale;
8529
8532
  }
8530
8533
  } else {
8531
- if (object2.matrixAutoUpdate) {
8532
- object2.updateMatrix();
8534
+ if (object3.matrixAutoUpdate) {
8535
+ object3.updateMatrix();
8533
8536
  }
8534
- if (isIdentityMatrix(object2.matrix) === false) {
8535
- nodeDef.matrix = object2.matrix.elements;
8537
+ if (isIdentityMatrix(object3.matrix) === false) {
8538
+ nodeDef.matrix = object3.matrix.elements;
8536
8539
  }
8537
8540
  }
8538
- if (object2.name !== "") nodeDef.name = String(object2.name);
8539
- this.serializeUserData(object2, nodeDef);
8540
- if (object2.isMesh || object2.isLine || object2.isPoints) {
8541
- const meshIndex = await this.processMeshAsync(object2);
8541
+ if (object3.name !== "") nodeDef.name = String(object3.name);
8542
+ this.serializeUserData(object3, nodeDef);
8543
+ if (object3.isMesh || object3.isLine || object3.isPoints) {
8544
+ const meshIndex = await this.processMeshAsync(object3);
8542
8545
  if (meshIndex !== null) nodeDef.mesh = meshIndex;
8543
- } else if (object2.isCamera) {
8544
- nodeDef.camera = this.processCamera(object2);
8546
+ } else if (object3.isCamera) {
8547
+ nodeDef.camera = this.processCamera(object3);
8545
8548
  }
8546
- if (object2.isSkinnedMesh) this.skins.push(object2);
8549
+ if (object3.isSkinnedMesh) this.skins.push(object3);
8547
8550
  const nodeIndex = json.nodes.push(nodeDef) - 1;
8548
- nodeMap.set(object2, nodeIndex);
8549
- if (object2.children.length > 0) {
8551
+ nodeMap.set(object3, nodeIndex);
8552
+ if (object3.children.length > 0) {
8550
8553
  const children = [];
8551
- for (let i = 0, l = object2.children.length; i < l; i++) {
8552
- const child = object2.children[i];
8554
+ for (let i = 0, l = object3.children.length; i < l; i++) {
8555
+ const child = object3.children[i];
8553
8556
  if (child.visible || options.onlyVisible === false) {
8554
8557
  const childNodeIndex = await this.processNodeAsync(child);
8555
8558
  if (childNodeIndex !== null) children.push(childNodeIndex);
@@ -8558,7 +8561,7 @@ var GLTFWriter = class {
8558
8561
  if (children.length > 0) nodeDef.children = children;
8559
8562
  }
8560
8563
  await this._invokeAllAsync(function(ext) {
8561
- ext.writeNode && ext.writeNode(object2, nodeDef);
8564
+ ext.writeNode && ext.writeNode(object3, nodeDef);
8562
8565
  });
8563
8566
  return nodeIndex;
8564
8567
  }
@@ -8567,19 +8570,19 @@ var GLTFWriter = class {
8567
8570
  * @param {THREE.Object3D} object Object3D with pivot
8568
8571
  * @return {Promise<number>} Index of the container node
8569
8572
  */
8570
- async _processNodeWithPivotAsync(object2) {
8573
+ async _processNodeWithPivotAsync(object3) {
8571
8574
  const json = this.json;
8572
8575
  const options = this.options;
8573
8576
  const nodeMap = this.nodeMap;
8574
- const pivot = object2.pivot;
8577
+ const pivot = object3.pivot;
8575
8578
  const containerDef = {};
8576
- const rotation = object2.quaternion.toArray();
8579
+ const rotation = object3.quaternion.toArray();
8577
8580
  const position = [
8578
- object2.position.x + pivot.x,
8579
- object2.position.y + pivot.y,
8580
- object2.position.z + pivot.z
8581
+ object3.position.x + pivot.x,
8582
+ object3.position.y + pivot.y,
8583
+ object3.position.z + pivot.z
8581
8584
  ];
8582
- const scale = object2.scale.toArray();
8585
+ const scale = object3.scale.toArray();
8583
8586
  if (!equalArray(rotation, [0, 0, 0, 1])) {
8584
8587
  containerDef.rotation = rotation;
8585
8588
  }
@@ -8590,28 +8593,28 @@ var GLTFWriter = class {
8590
8593
  containerDef.scale = scale;
8591
8594
  }
8592
8595
  containerDef.extras = { pivot: pivot.toArray() };
8593
- if (object2.name !== "") containerDef.name = String(object2.name);
8594
- this.serializeUserData(object2, containerDef);
8596
+ if (object3.name !== "") containerDef.name = String(object3.name);
8597
+ this.serializeUserData(object3, containerDef);
8595
8598
  const containerIndex = json.nodes.push(containerDef) - 1;
8596
- nodeMap.set(object2, containerIndex);
8599
+ nodeMap.set(object3, containerIndex);
8597
8600
  const childDef = {};
8598
8601
  const childPosition = [-pivot.x, -pivot.y, -pivot.z];
8599
8602
  if (!equalArray(childPosition, [0, 0, 0])) {
8600
8603
  childDef.translation = childPosition;
8601
8604
  }
8602
- if (object2.isMesh || object2.isLine || object2.isPoints) {
8603
- const meshIndex = await this.processMeshAsync(object2);
8605
+ if (object3.isMesh || object3.isLine || object3.isPoints) {
8606
+ const meshIndex = await this.processMeshAsync(object3);
8604
8607
  if (meshIndex !== null) childDef.mesh = meshIndex;
8605
- } else if (object2.isCamera) {
8606
- childDef.camera = this.processCamera(object2);
8608
+ } else if (object3.isCamera) {
8609
+ childDef.camera = this.processCamera(object3);
8607
8610
  }
8608
- if (object2.isSkinnedMesh) this.skins.push(object2);
8611
+ if (object3.isSkinnedMesh) this.skins.push(object3);
8609
8612
  const childIndex = json.nodes.push(childDef) - 1;
8610
8613
  const containerChildren = [childIndex];
8611
- if (object2.children.length > 0) {
8614
+ if (object3.children.length > 0) {
8612
8615
  const grandchildren = [];
8613
- for (let i = 0, l = object2.children.length; i < l; i++) {
8614
- const child = object2.children[i];
8616
+ for (let i = 0, l = object3.children.length; i < l; i++) {
8617
+ const child = object3.children[i];
8615
8618
  if (child.visible || options.onlyVisible === false) {
8616
8619
  const childNodeIndex = await this.processNodeAsync(child);
8617
8620
  if (childNodeIndex !== null) grandchildren.push(childNodeIndex);
@@ -8621,7 +8624,7 @@ var GLTFWriter = class {
8621
8624
  }
8622
8625
  containerDef.children = containerChildren;
8623
8626
  await this._invokeAllAsync(function(ext) {
8624
- ext.writeNode && ext.writeNode(object2, containerDef);
8627
+ ext.writeNode && ext.writeNode(object3, containerDef);
8625
8628
  });
8626
8629
  return containerIndex;
8627
8630
  }
@@ -9064,10 +9067,10 @@ var GLTFMeshGpuInstancing = class {
9064
9067
  this.writer = writer;
9065
9068
  this.name = "EXT_mesh_gpu_instancing";
9066
9069
  }
9067
- writeNode(object2, nodeDef) {
9068
- if (!object2.isInstancedMesh) return;
9070
+ writeNode(object3, nodeDef) {
9071
+ if (!object3.isInstancedMesh) return;
9069
9072
  const writer = this.writer;
9070
- const mesh = object2;
9073
+ const mesh = object3;
9071
9074
  const translationAttr = new Float32Array(mesh.count * 3);
9072
9075
  const rotationAttr = new Float32Array(mesh.count * 4);
9073
9076
  const scaleAttr = new Float32Array(mesh.count * 3);
@@ -9257,8 +9260,8 @@ var SceneExporter = class {
9257
9260
  }
9258
9261
  }
9259
9262
  };
9260
- function localMatrix(object2) {
9261
- return object2.matrixAutoUpdate ? new import_three19.Matrix4().compose(object2.position, object2.quaternion, object2.scale) : object2.matrix.clone();
9263
+ function localMatrix(object3) {
9264
+ return object3.matrixAutoUpdate ? new import_three19.Matrix4().compose(object3.position, object3.quaternion, object3.scale) : object3.matrix.clone();
9262
9265
  }
9263
9266
  function createSnapshot(root, gltf, bakeColors = false) {
9264
9267
  const scene = new import_three19.Scene();
@@ -9362,24 +9365,24 @@ function createSnapshot(root, gltf, bakeColors = false) {
9362
9365
  scene.add(copy);
9363
9366
  }
9364
9367
  };
9365
- const visit = (object2, parentWorld) => {
9366
- if (!object2.visible) return;
9367
- const world = parentWorld.clone().multiply(localMatrix(object2));
9368
- const mesh = object2;
9368
+ const visit = (object3, parentWorld) => {
9369
+ if (!object3.visible) return;
9370
+ const world = parentWorld.clone().multiply(localMatrix(object3));
9371
+ const mesh = object3;
9369
9372
  if (mesh.isMesh) {
9370
9373
  const instanced = mesh;
9371
9374
  if (instanced.isInstancedMesh) {
9372
9375
  for (let i = 0; i < instanced.count; i++) {
9373
9376
  const matrix = new import_three19.Matrix4();
9374
9377
  instanced.getMatrixAt(i, matrix);
9375
- const color = instanced.instanceColor ? new import_three19.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
9376
- addMesh(mesh, world.clone().multiply(matrix), color);
9378
+ const color2 = instanced.instanceColor ? new import_three19.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
9379
+ addMesh(mesh, world.clone().multiply(matrix), color2);
9377
9380
  }
9378
9381
  } else {
9379
9382
  addMesh(mesh, world);
9380
9383
  }
9381
9384
  }
9382
- for (const child of object2.children) visit(child, world);
9385
+ for (const child of object3.children) visit(child, world);
9383
9386
  };
9384
9387
  try {
9385
9388
  const ancestors = [];
@@ -9452,16 +9455,17 @@ function copyDataTexture(source) {
9452
9455
 
9453
9456
  // src/gui/GuiHelper.ts
9454
9457
  init_AssetKey();
9458
+ init_ModelTextures();
9455
9459
 
9456
9460
  // src/gui/GuiText.ts
9457
9461
  var import_three20 = require("three");
9458
- async function layoutGuiText(text, options = {}) {
9462
+ async function layoutGuiText(text2, options = {}) {
9459
9463
  const maxWidth = options.maxWidth ?? Infinity, lineHeight = options.lineHeight ?? 9;
9460
9464
  if (!(maxWidth > 0) || !Number.isFinite(lineHeight) || lineHeight <= 0) {
9461
9465
  throw new Error("Text wrap width and line height must be positive");
9462
9466
  }
9463
9467
  const font = await Fonts.get(options.font);
9464
- const runs = typeof text === "string" ? [{ text }] : text;
9468
+ const runs = typeof text2 === "string" ? [{ text: text2 }] : text2;
9465
9469
  const glyphs = [], lineWidths = [];
9466
9470
  let line = [], width = 0;
9467
9471
  let trailingNewline = false;
@@ -9515,7 +9519,7 @@ function createGuiTextGeometry(layout, shadow = true) {
9515
9519
  batch = { image: glyph?.image, positions: [], uvs: [], colors: [], indices: [] };
9516
9520
  batches.push(batch);
9517
9521
  }
9518
- const color = new import_three20.Color(isShadow ? (style.color & 16579836) >> 2 : style.color);
9522
+ const color2 = new import_three20.Color(isShadow ? (style.color & 16579836) >> 2 : style.color);
9519
9523
  const offset = isShadow ? 1 : 0;
9520
9524
  const top = glyph ? 7 - glyph.ascent : 0;
9521
9525
  const height = glyph ? glyph.height * glyph.scale : 8;
@@ -9543,7 +9547,7 @@ function createGuiTextGeometry(layout, shadow = true) {
9543
9547
  const v0 = glyph ? 1 - glyph.y / glyph.image.height : 1;
9544
9548
  const v1 = glyph ? 1 - (glyph.y + glyph.height) / glyph.image.height : 0;
9545
9549
  batch.uvs.push(u0, v0, u1, v0, u0, v1, u1, v1);
9546
- for (let i = 0; i < 4; i++) batch.colors.push(color.r, color.g, color.b);
9550
+ for (let i = 0; i < 4; i++) batch.colors.push(color2.r, color2.g, color2.b);
9547
9551
  batch.indices.push(base, base + 2, base + 1, base + 2, base + 3, base + 1);
9548
9552
  };
9549
9553
  for (const boldOffset of style.bold ? [0, 1] : [0]) {
@@ -9561,7 +9565,128 @@ function createGuiTextGeometry(layout, shadow = true) {
9561
9565
  }
9562
9566
 
9563
9567
  // src/gui/GuiHelper.ts
9568
+ var GUI_CONTAINER_LAYOUTS = {
9569
+ generic_54: {
9570
+ texture: "minecraft:gui/container/generic_54",
9571
+ crop: [0, 0, 176, 222],
9572
+ slotOrigin: [8, 18],
9573
+ slotOffset: [18, 18],
9574
+ rowSize: 9,
9575
+ slotCount: 54
9576
+ },
9577
+ crafting_table: {
9578
+ texture: "minecraft:gui/container/crafting_table",
9579
+ crop: [0, 0, 176, 166],
9580
+ slotOrigin: [30, 17],
9581
+ slotOffset: [18, 18],
9582
+ rowSize: 3,
9583
+ slotCount: 9,
9584
+ resultPosition: [124, 35]
9585
+ }
9586
+ };
9564
9587
  var GuiHelper = class {
9588
+ /**
9589
+ * Creates a 182×5 boss bar using the active resource pack. Finite progress is clamped to 0–1.
9590
+ * The fill crops the source image; explicit crops do not apply `.mcmeta` sprite scaling.
9591
+ */
9592
+ static async bossBar(options = {}) {
9593
+ const { color: color2 = "pink", progress = 1, position = [0, 0] } = options;
9594
+ this.validatePosition(position);
9595
+ if (!["pink", "blue", "red", "green", "yellow", "purple", "white"].includes(color2)) {
9596
+ throw new Error(`Unsupported boss bar color: ${color2}`);
9597
+ }
9598
+ if (!Number.isFinite(progress)) throw new Error("Boss bar progress must be finite");
9599
+ const value = Math.max(0, Math.min(1, progress));
9600
+ const width = value > 0 ? Math.floor(value * 181) + 1 : 0;
9601
+ const texture = `minecraft:gui/sprites/boss_bar/${color2}`;
9602
+ const layers = [{
9603
+ name: "boss-bar-background",
9604
+ texture: `${texture}_background`,
9605
+ position: [...position],
9606
+ size: [182, 5]
9607
+ }];
9608
+ if (width > 0) {
9609
+ layers.push({
9610
+ ...await this.cropTexture(`${texture}_progress`, [0, 0, width, 5], [182, 5], position),
9611
+ name: "boss-bar-progress"
9612
+ });
9613
+ }
9614
+ return layers;
9615
+ }
9616
+ /**
9617
+ * Creates a 192×192 book page with optional arrows and supplied text. Buttons are hidden by default.
9618
+ * Callers choose the page content and button states; this helper does not paginate or handle clicks.
9619
+ */
9620
+ static async book(options = {}) {
9621
+ const {
9622
+ position = [0, 0],
9623
+ previous = "hidden",
9624
+ next = "hidden",
9625
+ text: text2,
9626
+ color: color2 = 0,
9627
+ shadow = false,
9628
+ maxWidth = 114,
9629
+ lineHeight = 9,
9630
+ ...style
9631
+ } = options;
9632
+ this.validatePosition(position);
9633
+ for (const state of [previous, next]) {
9634
+ if (!["hidden", "normal", "hover"].includes(state)) throw new Error(`Unsupported book button state: ${state}`);
9635
+ }
9636
+ const layers = [{
9637
+ ...await this.cropTexture("minecraft:gui/book", [0, 0, 192, 192], [256, 256], position),
9638
+ name: "book-background"
9639
+ }];
9640
+ for (const [name, direction, state, x] of [
9641
+ ["previous", "backward", previous, 43],
9642
+ ["next", "forward", next, 116]
9643
+ ]) {
9644
+ if (state === "hidden") continue;
9645
+ layers.push({
9646
+ name: `book-${name}`,
9647
+ texture: `minecraft:gui/sprites/widget/page_${direction}${state === "hover" ? "_highlighted" : ""}`,
9648
+ position: [position[0] + x, position[1] + 157],
9649
+ size: [23, 13]
9650
+ });
9651
+ }
9652
+ if (text2 !== void 0) {
9653
+ layers.push({
9654
+ name: "book-text",
9655
+ text: text2,
9656
+ position: [position[0] + 36, position[1] + 30],
9657
+ color: color2,
9658
+ shadow,
9659
+ maxWidth,
9660
+ lineHeight,
9661
+ ...style
9662
+ });
9663
+ }
9664
+ return layers;
9665
+ }
9666
+ /** Creates a container background. Use {@link GUI_CONTAINER_LAYOUTS} with {@link inventorySlot} to place its items. */
9667
+ static async container(type, position = [0, 0]) {
9668
+ this.validatePosition(position);
9669
+ if (type !== "generic_54" && type !== "crafting_table") throw new Error(`Unsupported GUI container: ${type}`);
9670
+ const layout = GUI_CONTAINER_LAYOUTS[type];
9671
+ return [{ ...await this.cropTexture(layout.texture, layout.crop, [256, 256], position), name: "background" }];
9672
+ }
9673
+ static validatePosition(position) {
9674
+ if (!Array.isArray(position) || position.length !== 2 || !position.every(Number.isFinite)) {
9675
+ throw new Error("GUI position must contain two finite coordinates");
9676
+ }
9677
+ }
9678
+ static async cropTexture(texture, crop, referenceSize, position) {
9679
+ const image = await ModelTextures.preload(AssetKey.parse("textures", texture));
9680
+ if (!image) throw new Error(`Could not load GUI texture ${texture}`);
9681
+ const [x, y, width, height] = crop;
9682
+ const scaleX = image.width / referenceSize[0], scaleY = image.height / referenceSize[1];
9683
+ return {
9684
+ texture,
9685
+ crop: [x * scaleX, y * scaleY, width * scaleX, height * scaleY],
9686
+ position: [...position],
9687
+ size: [width, height]
9688
+ };
9689
+ }
9565
9690
  /** Sizes a tooltip around supplied text; the first entry is its title. */
9566
9691
  static async tooltip(lines, options = {}) {
9567
9692
  if (!lines.length) return [];
@@ -9577,8 +9702,8 @@ var GuiHelper = class {
9577
9702
  size: [width + 24, height + 24]
9578
9703
  }));
9579
9704
  let y = position[1];
9580
- lines.forEach((text, index) => {
9581
- layers.push({ ...textOptions, name: `tooltip-line-${index}`, text, position: [position[0], y] });
9705
+ lines.forEach((text2, index) => {
9706
+ layers.push({ ...textOptions, name: `tooltip-line-${index}`, text: text2, position: [position[0], y] });
9582
9707
  y += layouts[index].height + (index === 0 ? titleGap : 0);
9583
9708
  });
9584
9709
  return layers;
@@ -9596,8 +9721,9 @@ var GuiHelper = class {
9596
9721
  }
9597
9722
  /** Creates crafting-table layers for ingredients and the result; stack counts are not drawn. */
9598
9723
  static recipe(recipe, options = {}) {
9724
+ const layout = GUI_CONTAINER_LAYOUTS.crafting_table;
9599
9725
  const layers = [
9600
- { name: "background", texture: "minecraft:gui/container/crafting_table", crop: [0, 0, 176, 166] }
9726
+ { name: "background", texture: layout.texture, crop: [...layout.crop] }
9601
9727
  ];
9602
9728
  const itemKey = (ingredient) => {
9603
9729
  const item = typeof ingredient === "string" && !ingredient.startsWith("#") ? ingredient : typeof ingredient === "object" && "item" in ingredient ? ingredient.item : options.resolveIngredient?.(ingredient);
@@ -9612,7 +9738,7 @@ var GuiHelper = class {
9612
9738
  layers.push({
9613
9739
  name: `ingredient-${slot}`,
9614
9740
  item: itemKey(ingredient),
9615
- position: this.inventorySlot(slot, [30, 17], [18, 18], 3)
9741
+ position: this.inventorySlot(slot, layout.slotOrigin, layout.slotOffset, layout.rowSize)
9616
9742
  });
9617
9743
  };
9618
9744
  switch (recipe.type) {
@@ -9647,7 +9773,7 @@ var GuiHelper = class {
9647
9773
  layers.push({
9648
9774
  name: "result",
9649
9775
  item: itemKey("id" in recipe.result ? recipe.result.id : recipe.result.item),
9650
- position: [124, 35]
9776
+ position: [...layout.resultPosition]
9651
9777
  });
9652
9778
  return layers;
9653
9779
  }
@@ -10034,29 +10160,29 @@ var SceneInspector = class {
10034
10160
  this.objectControlsContainer.innerHTML = "";
10035
10161
  this.addControls(targetObject, targetIntersection, instance);
10036
10162
  }
10037
- addControls(object2, intersection, instance) {
10163
+ addControls(object3, intersection, instance) {
10038
10164
  const container = document.createElement("div");
10039
10165
  container.append(this.separator("Select Parent/Child"));
10040
- if (object2.parent) {
10041
- container.append(this.buttonControl("Select Parent " + object2.parent.constructor.name + " " + object2.parent.name, "P", () => {
10042
- this.selectObject(object2.parent, intersection, instance);
10166
+ if (object3.parent) {
10167
+ container.append(this.buttonControl("Select Parent " + object3.parent.constructor.name + " " + object3.parent.name, "P", () => {
10168
+ this.selectObject(object3.parent, intersection, instance);
10043
10169
  }));
10044
10170
  }
10045
- if (object2.children.length > 0) {
10171
+ if (object3.children.length > 0) {
10046
10172
  let i = 1;
10047
- for (let child of object2.children) {
10173
+ for (let child of object3.children) {
10048
10174
  container.append(this.buttonControl("Select Child " + child.constructor.name + " " + child.name, "C" + i++, () => {
10049
10175
  this.selectObject(child, intersection, instance);
10050
10176
  }));
10051
10177
  }
10052
10178
  }
10053
10179
  container.append(this.separator());
10054
- const selectedInstance = instance && (object2 === instance.instanceable || object2 === intersection?.object) ? instance : void 0;
10180
+ const selectedInstance = instance && (object3 === instance.instanceable || object3 === intersection?.object) ? instance : void 0;
10055
10181
  if (!selectedInstance) {
10056
- container.append(this.toggleControl("Visibility", "V", object2.visible, (v) => object2.visible = v));
10182
+ container.append(this.toggleControl("Visibility", "V", object3.visible, (v) => object3.visible = v));
10057
10183
  }
10058
10184
  container.append(this.separator("Mesh"));
10059
- this.addObjectControls(object2, intersection, container, selectedInstance);
10185
+ this.addObjectControls(object3, intersection, container, selectedInstance);
10060
10186
  container.append(this.separator());
10061
10187
  this.objectControlsContainer.append(container);
10062
10188
  }
@@ -10472,29 +10598,29 @@ var BlockTints = class {
10472
10598
  }
10473
10599
  }
10474
10600
  if (!indices.size) return tints;
10475
- let color;
10601
+ let color2;
10476
10602
  switch (rule.source) {
10477
10603
  case "constant":
10478
- color = rule.color;
10604
+ color2 = rule.color;
10479
10605
  break;
10480
10606
  case "grass":
10481
- color = await Colormaps.grassColor(key);
10607
+ color2 = await Colormaps.grassColor(key);
10482
10608
  break;
10483
10609
  case "redstone": {
10484
10610
  const power = Number(state.power ?? 0) / 15;
10485
10611
  const red = power * 0.6 + (power > 0 ? 0.4 : 0.3);
10486
10612
  const green = Math.max(0, power * power * 0.7 - 0.5);
10487
10613
  const blue = Math.max(0, power * power * 0.6 - 0.7);
10488
- color = Math.floor(red * 255) << 16 | Math.floor(green * 255) << 8 | Math.floor(blue * 255);
10614
+ color2 = Math.floor(red * 255) << 16 | Math.floor(green * 255) << 8 | Math.floor(blue * 255);
10489
10615
  break;
10490
10616
  }
10491
10617
  case "stem": {
10492
10618
  const age = Number(state.age ?? 0);
10493
- color = age * 32 << 16 | 255 - age * 8 << 8 | age * 4;
10619
+ color2 = age * 32 << 16 | 255 - age * 8 << 8 | age * 4;
10494
10620
  break;
10495
10621
  }
10496
10622
  }
10497
- return { ...Object.fromEntries([...indices].map((index) => [index, color])), ...tints };
10623
+ return { ...Object.fromEntries([...indices].map((index) => [index, color2])), ...tints };
10498
10624
  }
10499
10625
  };
10500
10626
 
@@ -10636,8 +10762,8 @@ var BlockObject = class _BlockObject extends SceneObject {
10636
10762
  return false;
10637
10763
  }
10638
10764
  return this._models.some((model) => {
10639
- const object2 = isInstanceReference(model) ? model.instanceable : model;
10640
- return object2.isOpaqueFullCube && this.getModelCullMask(model, 63) === 63;
10765
+ const object3 = isInstanceReference(model) ? model.instanceable : model;
10766
+ return object3.isOpaqueFullCube && this.getModelCullMask(model, 63) === 63;
10641
10767
  });
10642
10768
  }
10643
10769
  getModelMatrix(model) {
@@ -10646,8 +10772,8 @@ var BlockObject = class _BlockObject extends SceneObject {
10646
10772
  return model.matrix.clone();
10647
10773
  }
10648
10774
  getModelCullMask(model, worldMask) {
10649
- const object2 = isInstanceReference(model) ? model.instanceable : model;
10650
- if (object2.options.displayPosition) return 0;
10775
+ const object3 = isInstanceReference(model) ? model.instanceable : model;
10776
+ if (object3.options.displayPosition) return 0;
10651
10777
  const position = new import_three32.Vector3();
10652
10778
  const rotation = new import_three32.Quaternion();
10653
10779
  const scale = new import_three32.Vector3();
@@ -10664,14 +10790,14 @@ var BlockObject = class _BlockObject extends SceneObject {
10664
10790
  replacements.push(model);
10665
10791
  continue;
10666
10792
  }
10667
- const object2 = isInstanceReference(model) ? model.instanceable : model;
10793
+ const object3 = isInstanceReference(model) ? model.instanceable : model;
10668
10794
  const cullMask = this.getModelCullMask(model, worldMask);
10669
- if (cullMask === (object2.options.cullMask ?? 0)) {
10795
+ if (cullMask === (object3.options.cullMask ?? 0)) {
10670
10796
  replacements.push(model);
10671
10797
  continue;
10672
10798
  }
10673
10799
  const matrix = this.getModelMatrix(model);
10674
- const replacement = await this.scene.addModel(object2.originalModel, { ...object2.options, cullMask });
10800
+ const replacement = await this.scene.addModel(object3.originalModel, { ...object3.options, cullMask });
10675
10801
  replacements.push(replacement);
10676
10802
  if (isInstanceReference(replacement)) {
10677
10803
  replacement.setMatrix(matrix);
@@ -10679,8 +10805,8 @@ var BlockObject = class _BlockObject extends SceneObject {
10679
10805
  replacement.matrix.copy(matrix);
10680
10806
  replacement.matrixWorldNeedsUpdate = true;
10681
10807
  matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
10682
- replacement.matrixAutoUpdate = object2.matrixAutoUpdate;
10683
- replacement.visible = object2.visible;
10808
+ replacement.matrixAutoUpdate = object3.matrixAutoUpdate;
10809
+ replacement.visible = object3.visible;
10684
10810
  }
10685
10811
  }
10686
10812
  } catch (error) {
@@ -13827,60 +13953,60 @@ var MineRenderScene = class _MineRenderScene extends import_three34.Scene {
13827
13953
  this.DEFAULT_OPTIONS = (0, import_ts_deepmerge8.default)({}, {});
13828
13954
  }
13829
13955
  add(...objects) {
13830
- for (const object2 of objects) {
13956
+ for (const object3 of objects) {
13831
13957
  this.dirty = true;
13832
13958
  try {
13833
- super.add(object2);
13959
+ super.add(object3);
13834
13960
  } finally {
13835
- if (object2?.isObject3D && object2 !== this) {
13836
- this.updateObjectRegistration(object2, object2.parent === this);
13961
+ if (object3?.isObject3D && object3 !== this) {
13962
+ this.updateObjectRegistration(object3, object3.parent === this);
13837
13963
  }
13838
13964
  }
13839
13965
  }
13840
13966
  return this;
13841
13967
  }
13842
13968
  remove(...objects) {
13843
- for (const object2 of objects) {
13844
- if (!this.children.includes(object2)) continue;
13969
+ for (const object3 of objects) {
13970
+ if (!this.children.includes(object3)) continue;
13845
13971
  this.dirty = true;
13846
- this.updateObjectRegistration(object2, false);
13972
+ this.updateObjectRegistration(object3, false);
13847
13973
  try {
13848
- super.remove(object2);
13974
+ super.remove(object3);
13849
13975
  } finally {
13850
- this.updateObjectRegistration(object2, object2.parent === this);
13976
+ this.updateObjectRegistration(object3, object3.parent === this);
13851
13977
  }
13852
13978
  }
13853
13979
  return this;
13854
13980
  }
13855
- updateObjectRegistration(object2, attached) {
13856
- if (this.observedObjects.has(object2) === attached) return;
13857
- const observable = object2;
13981
+ updateObjectRegistration(object3, attached) {
13982
+ if (this.observedObjects.has(object3) === attached) return;
13983
+ const observable = object3;
13858
13984
  if (attached) {
13859
- this.observedObjects.add(object2);
13985
+ this.observedObjects.add(object3);
13860
13986
  observable.addEventListener("change", this.onObjectChange);
13861
13987
  } else {
13862
- this.observedObjects.delete(object2);
13988
+ this.observedObjects.delete(object3);
13863
13989
  observable.removeEventListener("change", this.onObjectChange);
13864
13990
  }
13865
13991
  const change = attached ? 1 : -1;
13866
13992
  this.stats.objectCount += change;
13867
- if (isSceneObject(object2)) {
13993
+ if (isSceneObject(object3)) {
13868
13994
  this.stats.sceneObjectCount += change;
13869
13995
  }
13870
13996
  }
13871
13997
  /** Initializes each object before attaching it to the scene. */
13872
- async initAndAdd(...object2) {
13998
+ async initAndAdd(...object3) {
13873
13999
  this.dirty = true;
13874
- for (let obj of object2) {
14000
+ for (let obj of object3) {
13875
14001
  await obj.init();
13876
14002
  }
13877
- return this.add(...object2);
14003
+ return this.add(...object3);
13878
14004
  }
13879
- async addSceneObject(asset, objectSupplier, _options, parent = this) {
14005
+ async addSceneObject(asset2, objectSupplier, _options, parent = this) {
13880
14006
  this.dirty = true;
13881
14007
  const obj = await objectSupplier();
13882
- if (obj?.options?.instanceMeshes && asset.key && asset.key?.assetType === "models") {
13883
- let key = asset.key.serialize();
14008
+ if (obj?.options?.instanceMeshes && asset2.key && asset2.key?.assetType === "models") {
14009
+ let key = asset2.key.serialize();
13884
14010
  if (isModelObject(obj)) {
13885
14011
  const { displayPosition, uvLockRotation, tints, cullMask } = obj.options;
13886
14012
  if (displayPosition) key += `|display:${displayPosition}`;
@@ -13978,11 +14104,11 @@ var _changeEvent = { type: "change" };
13978
14104
  var _startEvent = { type: "start" };
13979
14105
  var _endEvent = { type: "end" };
13980
14106
  var OrbitControls = class extends import_three35.EventDispatcher {
13981
- constructor(object2, domElement) {
14107
+ constructor(object3, domElement) {
13982
14108
  super();
13983
14109
  if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
13984
14110
  if (domElement === document) console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
13985
- this.object = object2;
14111
+ this.object = object3;
13986
14112
  this.domElement = domElement;
13987
14113
  this.domElement.style.touchAction = "none";
13988
14114
  this.enabled = true;
@@ -14039,7 +14165,7 @@ var OrbitControls = class extends import_three35.EventDispatcher {
14039
14165
  };
14040
14166
  this.update = function() {
14041
14167
  const offset = new import_three35.Vector3();
14042
- const quat = new import_three35.Quaternion().setFromUnitVectors(object2.up, new import_three35.Vector3(0, 1, 0));
14168
+ const quat = new import_three35.Quaternion().setFromUnitVectors(object3.up, new import_three35.Vector3(0, 1, 0));
14043
14169
  const quatInverse = quat.clone().invert();
14044
14170
  const lastPosition = new import_three35.Vector3();
14045
14171
  const lastQuaternion = new import_three35.Quaternion();
@@ -14604,8 +14730,8 @@ var OrbitControls = class extends import_three35.EventDispatcher {
14604
14730
  }
14605
14731
  };
14606
14732
  var MapControls = class extends OrbitControls {
14607
- constructor(object2, domElement) {
14608
- super(object2, domElement);
14733
+ constructor(object3, domElement) {
14734
+ super(object3, domElement);
14609
14735
  this.screenSpacePanning = false;
14610
14736
  this.mouseButtons.LEFT = import_three35.MOUSE.PAN;
14611
14737
  this.mouseButtons.RIGHT = import_three35.MOUSE.ROTATE;
@@ -15034,6 +15160,232 @@ init_SceneObject();
15034
15160
  // src/index.ts
15035
15161
  init_request();
15036
15162
 
15163
+ // src/scene/SceneDocument.ts
15164
+ init_DisplayPosition();
15165
+ function fail(path, message) {
15166
+ throw new Error(`${path}: ${message}`);
15167
+ }
15168
+ function object2(value, path) {
15169
+ if (!value || typeof value !== "object" || Array.isArray(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail(path, "expected a JSON object");
15170
+ for (const key of Object.keys(value)) {
15171
+ if (["__proto__", "prototype", "constructor"].includes(key)) fail(`${path}.${key}`, "unsupported property");
15172
+ }
15173
+ return value;
15174
+ }
15175
+ function fields(value, path, allowed, required = []) {
15176
+ const input = object2(value, path);
15177
+ for (const key of required) if (input[key] === void 0) fail(`${path}.${key}`, "required");
15178
+ for (const [key, entry] of Object.entries(input)) {
15179
+ if (!Object.prototype.hasOwnProperty.call(allowed, key)) fail(`${path}.${key}`, "unsupported property");
15180
+ if (entry !== void 0) allowed[key](entry, `${path}.${key}`);
15181
+ }
15182
+ return input;
15183
+ }
15184
+ var text = (value, path) => {
15185
+ if (typeof value !== "string" || !value.trim()) fail(path, "expected a nonempty string");
15186
+ };
15187
+ var literalText = (value, path) => {
15188
+ if (typeof value !== "string") fail(path, "expected a string");
15189
+ };
15190
+ var boolean = (value, path) => {
15191
+ if (typeof value !== "boolean") fail(path, "expected a boolean");
15192
+ };
15193
+ var number = (value, path) => {
15194
+ if (typeof value !== "number" || !Number.isFinite(value)) fail(path, "expected a finite number");
15195
+ };
15196
+ var positive = (value, path) => {
15197
+ number(value, path);
15198
+ if (value <= 0) fail(path, "expected a positive number");
15199
+ };
15200
+ var nonnegative = (value, path) => {
15201
+ number(value, path);
15202
+ if (value < 0) fail(path, "expected a nonnegative number");
15203
+ };
15204
+ var color = (value, path) => {
15205
+ number(value, path);
15206
+ if (!Number.isInteger(value) || value < 0 || value > 16777215) {
15207
+ fail(path, "expected an RGB integer from 0 to 16777215");
15208
+ }
15209
+ };
15210
+ var asset = (value, path) => {
15211
+ text(value, path);
15212
+ if (!/^(?:[a-z0-9_.-]+:)?[a-z0-9_./-]+$/.test(value) || value.split(/[:/]/).some((part) => !part || part === "." || part === "..")) {
15213
+ fail(path, "expected a resource ID such as minecraft:stone");
15214
+ }
15215
+ };
15216
+ var version = (value, path) => {
15217
+ text(value, path);
15218
+ if (!/^[a-zA-Z0-9._-]+$/.test(value)) fail(path, "expected a Minecraft version without slashes");
15219
+ };
15220
+ var tuple = (size, item = number) => (value, path) => {
15221
+ if (!Array.isArray(value) || value.length !== size) fail(path, `expected ${size} numbers`);
15222
+ for (let index = 0; index < size; index++) item(value[index], `${path}[${index}]`);
15223
+ };
15224
+ var list = (item) => (value, path) => {
15225
+ if (!Array.isArray(value)) fail(path, "expected an array");
15226
+ for (let index = 0; index < value.length; index++) item(value[index], `${path}[${index}]`);
15227
+ };
15228
+ var dictionary = (item, numericKeys = false) => (value, path) => {
15229
+ for (const [key, entry] of Object.entries(object2(value, path))) {
15230
+ if (numericKeys && !/^\d+$/.test(key)) fail(`${path}.${key}`, "expected a nonnegative tint index");
15231
+ item(entry, `${path}.${key}`);
15232
+ }
15233
+ };
15234
+ var enumeration = (values) => (value, path) => {
15235
+ if (!values.includes(value)) fail(path, `expected one of: ${values.join(", ")}`);
15236
+ };
15237
+ var textStyle = { color, bold: boolean, italic: boolean };
15238
+ function guiLayer(value, path) {
15239
+ const layer = object2(value, path);
15240
+ if (["texture", "item", "text"].filter((key) => layer[key] !== void 0).length !== 1) {
15241
+ fail(path, "expected exactly one of texture, item, or text");
15242
+ }
15243
+ const layout = { name: text, position: tuple(2), size: tuple(2, positive) };
15244
+ if (layer.texture !== void 0) {
15245
+ fields(value, path, { ...layout, texture: asset, crop: (value2, path2) => {
15246
+ tuple(4)(value2, path2);
15247
+ const [x, y, width, height] = value2;
15248
+ nonnegative(x, `${path2}[0]`);
15249
+ nonnegative(y, `${path2}[1]`);
15250
+ positive(width, `${path2}[2]`);
15251
+ positive(height, `${path2}[3]`);
15252
+ } });
15253
+ } else if (layer.item !== void 0) {
15254
+ fields(value, path, { ...layout, item: asset, tints: dictionary(color, true) });
15255
+ } else {
15256
+ fields(value, path, {
15257
+ ...layout,
15258
+ ...textStyle,
15259
+ font: asset,
15260
+ shadow: boolean,
15261
+ maxWidth: positive,
15262
+ lineHeight: positive,
15263
+ text: (value2, path2) => {
15264
+ if (typeof value2 === "string") return;
15265
+ list((run, path3) => {
15266
+ fields(run, path3, { text: literalText, ...textStyle }, ["text"]);
15267
+ })(value2, path2);
15268
+ }
15269
+ });
15270
+ }
15271
+ }
15272
+ function validateObject(value, path) {
15273
+ const input = object2(value, path);
15274
+ const common = { id: text, name: text, type: text, position: tuple(3), rotation: tuple(3), scale: tuple(3), visible: boolean };
15275
+ const required = ["id", "type"];
15276
+ const renderOptions = { wireframe: boolean };
15277
+ switch (input.type) {
15278
+ case "skin":
15279
+ fields(value, path, {
15280
+ ...common,
15281
+ skin: text,
15282
+ cape: (value2, path2) => {
15283
+ fields(value2, path2, { texture: text, layout: enumeration(["minecraft", "optifine", "labymod"]) }, ["texture"]);
15284
+ },
15285
+ hiddenParts: list(enumeration(SKIN_PARTS)),
15286
+ pose: (value2, path2) => {
15287
+ fields(value2, path2, {
15288
+ head: tuple(3),
15289
+ body: tuple(3),
15290
+ rightArm: tuple(3),
15291
+ leftArm: tuple(3),
15292
+ rightLeg: tuple(3),
15293
+ leftLeg: tuple(3),
15294
+ cape: tuple(3)
15295
+ });
15296
+ },
15297
+ options: (value2, path2) => {
15298
+ fields(value2, path2, { slim: boolean, legacy: boolean });
15299
+ }
15300
+ }, required);
15301
+ break;
15302
+ case "block":
15303
+ fields(value, path, {
15304
+ ...common,
15305
+ asset,
15306
+ state: dictionary(text),
15307
+ options: (value2, path2) => {
15308
+ fields(value2, path2, { ...renderOptions, tints: dictionary(color, true) });
15309
+ }
15310
+ }, [...required, "asset"]);
15311
+ break;
15312
+ case "item":
15313
+ case "model":
15314
+ fields(value, path, {
15315
+ ...common,
15316
+ asset,
15317
+ options: (value2, path2) => {
15318
+ fields(value2, path2, { ...renderOptions, displayPosition: enumeration(DISPLAY_POSITIONS), tints: dictionary(color, true) });
15319
+ }
15320
+ }, [...required, "asset"]);
15321
+ break;
15322
+ case "entity":
15323
+ fields(value, path, {
15324
+ ...common,
15325
+ asset,
15326
+ texture: asset,
15327
+ layers: list(text),
15328
+ when: list(text),
15329
+ textures: dictionary(asset),
15330
+ options: (value2, path2) => {
15331
+ fields(value2, path2, {
15332
+ ...renderOptions,
15333
+ flip: boolean,
15334
+ tints: dictionary((value3, path3) => {
15335
+ typeof value3 === "string" ? text(value3, path3) : color(value3, path3);
15336
+ })
15337
+ });
15338
+ },
15339
+ animation: (value2, path2) => {
15340
+ fields(value2, path2, { name: text, loop: boolean, speed: nonnegative, time: nonnegative, paused: boolean }, ["name"]);
15341
+ }
15342
+ }, [...required, "asset"]);
15343
+ if (Array.isArray(input.layers) && !input.layers.length) fail(`${path}.layers`, "expected at least one layer");
15344
+ break;
15345
+ case "gui":
15346
+ fields(value, path, { ...common, layers: list(guiLayer) }, [...required, "layers"]);
15347
+ break;
15348
+ default:
15349
+ fail(`${path}.type`, "expected skin, block, item, entity, model, or gui");
15350
+ }
15351
+ }
15352
+ function parseSceneDocument(value) {
15353
+ if (typeof value === "string") {
15354
+ try {
15355
+ value = JSON.parse(value);
15356
+ } catch {
15357
+ fail("scene", "invalid JSON");
15358
+ }
15359
+ }
15360
+ const input = fields(value, "scene", {
15361
+ format: enumeration(["minerender-scene"]),
15362
+ version: (value2, path) => {
15363
+ if (value2 !== 1) fail(path, "only scene document version 1 is supported");
15364
+ },
15365
+ minecraftVersion: version,
15366
+ camera: (value2, path) => {
15367
+ fields(value2, path, { position: tuple(3), target: tuple(3) }, ["position", "target"]);
15368
+ },
15369
+ objects: list(validateObject)
15370
+ }, ["format", "version", "objects"]);
15371
+ const ids = /* @__PURE__ */ new Set();
15372
+ for (const [index, entry] of input.objects.entries()) {
15373
+ if (ids.has(entry.id)) fail(`scene.objects[${index}].id`, `duplicate object ID "${entry.id}"`);
15374
+ ids.add(entry.id);
15375
+ }
15376
+ return JSON.parse(JSON.stringify(input));
15377
+ }
15378
+
15379
+ // src/scene/SceneDocumentLoader.ts
15380
+ var import_three38 = require("three");
15381
+ init_AssetKey();
15382
+ init_AssetLoader();
15383
+ init_BlockStates();
15384
+ init_Entities();
15385
+ init_Models();
15386
+ init_DisplayPosition();
15387
+ init_SceneObject();
15388
+
15037
15389
  // src/skin/Skins.ts
15038
15390
  init_Requests();
15039
15391
  var Skins = class {
@@ -15204,6 +15556,195 @@ var Skins = class {
15204
15556
  //</editor-fold>
15205
15557
  };
15206
15558
 
15559
+ // src/scene/SceneDocumentLoader.ts
15560
+ var DocumentObjectScene = class extends MineRenderScene {
15561
+ async addSceneObject(_asset, supplier, _options, parent = this) {
15562
+ const object3 = await supplier();
15563
+ return this.initialize(object3, parent);
15564
+ }
15565
+ async initialize(object3, parent = this) {
15566
+ object3.scene = this;
15567
+ try {
15568
+ await object3.init();
15569
+ parent.add(object3);
15570
+ return object3;
15571
+ } catch (error) {
15572
+ object3.dispose();
15573
+ object3.removeFromParent();
15574
+ throw error;
15575
+ }
15576
+ }
15577
+ dispose() {
15578
+ for (const child of [...this.children]) {
15579
+ if (child.parent !== this) continue;
15580
+ if (isSceneObject(child)) child.dispose();
15581
+ child.removeFromParent();
15582
+ }
15583
+ }
15584
+ };
15585
+ async function skinTexture(value, cape = false) {
15586
+ if (!/^[a-zA-Z0-9_-]{1,36}$/.test(value)) return value;
15587
+ const texture = await (cape ? Skins.capeFromUuidOrUsername(value) : Skins.fromUuidOrUsername(value));
15588
+ if (!texture) throw new Error(`Could not find ${cape ? "cape" : "skin"} for "${value}"`);
15589
+ return texture;
15590
+ }
15591
+ var SceneDocumentLoader = class {
15592
+ static parse(value) {
15593
+ return parseSceneDocument(value);
15594
+ }
15595
+ /**
15596
+ * Loads objects concurrently and attaches them in document order after every load succeeds.
15597
+ * A failure waits for all loads, disposes staged objects, and reports the first error in document order.
15598
+ */
15599
+ static async load(scene, value, parent = scene) {
15600
+ const definition = this.parse(value);
15601
+ if (definition.minecraftVersion !== void 0 && definition.minecraftVersion !== AssetLoader.version) {
15602
+ throw new Error(`Scene requires Minecraft ${definition.minecraftVersion}; call AssetLoader.setVersion("${definition.minecraftVersion}") before loading it`);
15603
+ }
15604
+ const root = new import_three38.Group();
15605
+ root.name = "MineRender scene document";
15606
+ const objects = [];
15607
+ let disposed = false;
15608
+ const loaded = {
15609
+ root,
15610
+ objects,
15611
+ definition,
15612
+ advanceAnimations: (delta) => {
15613
+ if (!disposed) for (const object3 of objects) object3.advanceAnimation(delta);
15614
+ },
15615
+ dispose: () => {
15616
+ if (disposed) return;
15617
+ disposed = true;
15618
+ root.removeFromParent();
15619
+ for (const object3 of objects) object3.dispose();
15620
+ root.clear();
15621
+ scene.dirty = true;
15622
+ }
15623
+ };
15624
+ try {
15625
+ const results = await Promise.allSettled(definition.objects.map((object3) => this.loadValidatedObject(scene, object3)));
15626
+ for (const result of results) if (result.status === "fulfilled") objects.push(result.value);
15627
+ const failure = results.find((result) => result.status === "rejected");
15628
+ if (failure) throw failure.reason;
15629
+ for (const object3 of objects) root.add(object3.root);
15630
+ parent.add(root);
15631
+ scene.dirty = true;
15632
+ return loaded;
15633
+ } catch (error) {
15634
+ loaded.dispose();
15635
+ throw error;
15636
+ }
15637
+ }
15638
+ /** Loads an independently editable object. Its root owns the document's position, rotation, and scale. */
15639
+ static async loadObject(scene, value, parent = scene) {
15640
+ const definition = this.parse({ format: "minerender-scene", version: 1, objects: [value] }).objects[0];
15641
+ return this.loadValidatedObject(scene, definition, parent);
15642
+ }
15643
+ static async loadValidatedObject(scene, definition, parent) {
15644
+ const root = new import_three38.Group();
15645
+ root.name = definition.name ?? definition.id;
15646
+ root.userData.sceneObjectId = definition.id;
15647
+ root.position.fromArray(definition.position ?? [0, 0, 0]);
15648
+ root.rotation.set(...definition.rotation ?? [0, 0, 0]);
15649
+ root.scale.fromArray(definition.scale ?? [1, 1, 1]);
15650
+ root.visible = definition.visible ?? true;
15651
+ const content = new DocumentObjectScene();
15652
+ root.add(content);
15653
+ let object3;
15654
+ try {
15655
+ switch (definition.type) {
15656
+ case "skin": {
15657
+ const skin = new SkinObject({ ...definition.options, instanceMeshes: false });
15658
+ object3 = skin;
15659
+ const texture = definition.skin ? await skinTexture(definition.skin) : `${AssetLoader.ROOT}/assets/minecraft/textures/entity/player/${definition.options?.slim ? "slim/alex" : "wide/steve"}.png`;
15660
+ await skin.setSkinTexture(texture);
15661
+ await content.initialize(skin);
15662
+ if (definition.cape) await skin.setCapeTexture(await skinTexture(definition.cape.texture, true), definition.cape.layout);
15663
+ for (const [part, rotation] of Object.entries(definition.pose ?? {})) {
15664
+ skin.getGroupByName(part)?.rotation.set(...rotation, "XYZ");
15665
+ }
15666
+ for (const part of definition.hiddenParts ?? []) {
15667
+ const mesh = skin.getMeshByName(part);
15668
+ if (mesh) mesh.visible = false;
15669
+ }
15670
+ break;
15671
+ }
15672
+ case "block": {
15673
+ const state = await BlockStates.get(AssetKey.parse("blockstates", definition.asset));
15674
+ if (!state) throw new Error(`Could not load block ${definition.asset}`);
15675
+ object3 = await content.addBlock(state, { ...definition.options, initialState: definition.state, instanceMeshes: false });
15676
+ break;
15677
+ }
15678
+ case "item":
15679
+ case "model": {
15680
+ let key = AssetKey.parse("models", definition.asset);
15681
+ if (definition.type === "item" && key.type !== "item") {
15682
+ key = new AssetKey(key.namespace, key.getFullPath(), "models", "item");
15683
+ }
15684
+ const model = await Models.getMerged(key);
15685
+ if (!model) throw new Error(`Could not load ${definition.type} ${definition.asset}`);
15686
+ object3 = await content.addModel(model, {
15687
+ ...definition.type === "item" ? { displayPosition: "gui" /* GUI */ } : {},
15688
+ ...definition.options,
15689
+ instanceMeshes: false
15690
+ });
15691
+ break;
15692
+ }
15693
+ case "entity": {
15694
+ const key = AssetKey.parse("entity-models", definition.asset);
15695
+ const model = await Entities.getEntity(key, definition.texture ? AssetKey.parse("textures", definition.texture) : void 0, {
15696
+ layers: definition.layers,
15697
+ when: definition.when,
15698
+ textures: definition.textures && Object.fromEntries(Object.entries(definition.textures).map(([name, texture]) => [name, AssetKey.parse("textures", texture)]))
15699
+ });
15700
+ if (!model) throw new Error(`Could not load entity ${definition.asset}`);
15701
+ const entity = await content.addEntity(model, { ...definition.options, instanceMeshes: false });
15702
+ object3 = entity;
15703
+ if (definition.animation) {
15704
+ const animations = await Entities.getAnimations(key);
15705
+ const clip = animations?.[definition.animation.name];
15706
+ if (!clip) throw new Error(`Entity ${definition.asset} has no animation "${definition.animation.name}"`);
15707
+ entity.playAnimation(clip, definition.animation);
15708
+ }
15709
+ break;
15710
+ }
15711
+ case "gui":
15712
+ object3 = await content.initialize(new GuiObject(definition.layers));
15713
+ break;
15714
+ }
15715
+ let disposed = false;
15716
+ const loaded = {
15717
+ root,
15718
+ object: object3,
15719
+ definition,
15720
+ advanceAnimation: (delta) => {
15721
+ if (!disposed && definition.type === "entity" && !definition.animation?.paused) object3.advanceAnimation(delta);
15722
+ },
15723
+ dispose: () => {
15724
+ if (disposed) return;
15725
+ disposed = true;
15726
+ root.removeFromParent();
15727
+ object3.dispose();
15728
+ object3.removeFromParent();
15729
+ content.dispose();
15730
+ root.clear();
15731
+ scene.dirty = true;
15732
+ }
15733
+ };
15734
+ parent?.add(root);
15735
+ scene.dirty = true;
15736
+ return loaded;
15737
+ } catch (error) {
15738
+ object3?.dispose();
15739
+ object3?.removeFromParent();
15740
+ content.dispose();
15741
+ root.removeFromParent();
15742
+ root.clear();
15743
+ throw new Error(`Scene object "${definition.name ?? definition.id}": ${error instanceof Error ? error.message : String(error)}`);
15744
+ }
15745
+ }
15746
+ };
15747
+
15207
15748
  // src/texture/index.ts
15208
15749
  init_Colormaps();
15209
15750
  init_TextureAtlas();
@@ -15485,12 +16026,12 @@ var AnvilParser = class {
15485
16026
  };
15486
16027
 
15487
16028
  // src/world/Chunk.ts
15488
- var import_three41 = require("three");
16029
+ var import_three42 = require("three");
15489
16030
  init_BlockStates();
15490
16031
  init_AssetKey();
15491
16032
 
15492
16033
  // src/world/MineRenderWorld.ts
15493
- var import_three39 = require("three");
16034
+ var import_three40 = require("three");
15494
16035
  init_Model();
15495
16036
  init_BatchedExecutor();
15496
16037
  init_AssetKey();
@@ -15498,7 +16039,7 @@ init_BlockStates();
15498
16039
  init_CubeFace();
15499
16040
 
15500
16041
  // src/world/SectionModels.ts
15501
- var import_three38 = require("three");
16042
+ var import_three39 = require("three");
15502
16043
  init_AssetKey();
15503
16044
  init_Models();
15504
16045
  init_CubeFace();
@@ -15557,20 +16098,20 @@ var SectionModels = class {
15557
16098
  if (!models) this.models.set(model, models = /* @__PURE__ */ new Map());
15558
16099
  const key = JSON.stringify([rotation.x, rotation.y, rotation.z, variant.uvlock, tints]);
15559
16100
  const template = await cached(models, key, async () => {
15560
- const object2 = new SectionModel(model, {
16101
+ const object3 = new SectionModel(model, {
15561
16102
  instanceMeshes: false,
15562
16103
  mergeMeshes: false,
15563
16104
  tints,
15564
16105
  uvLockRotation: variant.uvlock && (rotation.x !== 0 || rotation.y !== 0) ? [rotation.x, rotation.y, rotation.z] : void 0
15565
16106
  });
15566
- await object2.init();
15567
- const geometry = object2.children[0].geometry;
15568
- geometry.applyMatrix4(new import_three38.Matrix4().makeRotationFromEuler(rotation));
15569
- object2.clear();
16107
+ await object3.init();
16108
+ const geometry = object3.children[0].geometry;
16109
+ geometry.applyMatrix4(new import_three39.Matrix4().makeRotationFromEuler(rotation));
16110
+ object3.clear();
15570
16111
  const cullFaces = CUBE_FACES.map((face) => {
15571
16112
  const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
15572
16113
  if (local < 0) return 0;
15573
- const normal = new import_three38.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
16114
+ const normal = new import_three39.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
15574
16115
  const world = CUBE_FACE_OFFSETS.findIndex(([x, y, z]) => Math.abs(normal.x - x) < 1e-6 && Math.abs(normal.y - y) < 1e-6 && Math.abs(normal.z - z) < 1e-6);
15575
16116
  return 1 << world;
15576
16117
  });
@@ -15601,20 +16142,20 @@ var MineRenderWorld = class {
15601
16142
  }
15602
16143
  getBlockAt(posOrX, y, z) {
15603
16144
  if (typeof posOrX == "number") {
15604
- return this.getBlockAt(new import_three39.Vector3(posOrX, y, z));
16145
+ return this.getBlockAt(new import_three40.Vector3(posOrX, y, z));
15605
16146
  }
15606
16147
  if (isTripleArray(posOrX)) {
15607
- return this.getBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]));
16148
+ return this.getBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]));
15608
16149
  }
15609
16150
  this.validatePosBounds(posOrX);
15610
16151
  return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
15611
16152
  }
15612
16153
  async setBlockAt(posOrX, yOrBlock, z, block) {
15613
16154
  if (typeof posOrX == "number") {
15614
- return this.setBlockAt(new import_three39.Vector3(posOrX, yOrBlock, z), block);
16155
+ return this.setBlockAt(new import_three40.Vector3(posOrX, yOrBlock, z), block);
15615
16156
  }
15616
16157
  if (isTripleArray(posOrX)) {
15617
- return this.setBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
16158
+ return this.setBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
15618
16159
  }
15619
16160
  return this.placeBlock(posOrX, yOrBlock);
15620
16161
  }
@@ -15625,10 +16166,10 @@ var MineRenderWorld = class {
15625
16166
  }
15626
16167
  async setBlockVisibleAt(posOrX, yOrVisible, z, visible) {
15627
16168
  if (typeof posOrX === "number") {
15628
- return this.setBlockVisibleAt(new import_three39.Vector3(posOrX, yOrVisible, z), visible);
16169
+ return this.setBlockVisibleAt(new import_three40.Vector3(posOrX, yOrVisible, z), visible);
15629
16170
  }
15630
16171
  if (isTripleArray(posOrX)) {
15631
- return this.setBlockVisibleAt(new import_three39.Vector3(...posOrX), yOrVisible);
16172
+ return this.setBlockVisibleAt(new import_three40.Vector3(...posOrX), yOrVisible);
15632
16173
  }
15633
16174
  this.validatePosBounds(posOrX);
15634
16175
  await this.getChunkAt(posOrX)?.setBlockVisibleAt(posOrX, yOrVisible);
@@ -15652,7 +16193,7 @@ var MineRenderWorld = class {
15652
16193
  const collect = async (positions2) => {
15653
16194
  for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
15654
16195
  };
15655
- const place = (block) => this.placeBlock(new import_three39.Vector3(...block.position), block, collect);
16196
+ const place = (block) => this.placeBlock(new import_three40.Vector3(...block.position), block, collect);
15656
16197
  const keys = /* @__PURE__ */ new Map();
15657
16198
  for (const block of multiblock.blocks) {
15658
16199
  if (Chunk.isAir(block)) continue;
@@ -15750,13 +16291,13 @@ var MineRenderWorld = class {
15750
16291
  for (const pos of positions) {
15751
16292
  this.pendingCulling.set(pos.toArray().join(","), pos.clone());
15752
16293
  for (const offset of CUBE_FACE_OFFSETS) {
15753
- const neighbor = pos.clone().add(new import_three39.Vector3(...offset));
16294
+ const neighbor = pos.clone().add(new import_three40.Vector3(...offset));
15754
16295
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
15755
16296
  }
15756
16297
  for (let y = -1; y <= 1; y++) {
15757
16298
  for (let z = -1; z <= 1; z++) {
15758
16299
  for (let x = -1; x <= 1; x++) {
15759
- const neighbor = pos.clone().add(new import_three39.Vector3(x, y, z));
16300
+ const neighbor = pos.clone().add(new import_three40.Vector3(x, y, z));
15760
16301
  if (this.getBlockAt(neighbor)?.object?.fluidKind) {
15761
16302
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
15762
16303
  }
@@ -15780,19 +16321,19 @@ var MineRenderWorld = class {
15780
16321
  }
15781
16322
  if (block.object?.fluidKind) {
15782
16323
  await block.object.updateFluid((x, y, z) => {
15783
- const neighbor = pos.clone().add(new import_three39.Vector3(x, y, z));
16324
+ const neighbor = pos.clone().add(new import_three40.Vector3(x, y, z));
15784
16325
  const section = this.getChunkAt(neighbor);
15785
- const object2 = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
16326
+ const object3 = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
15786
16327
  return {
15787
- fluid: object2?.fluidKind,
15788
- level: object2?.fluidLevel,
16328
+ fluid: object3?.fluidKind,
16329
+ level: object3?.fluidLevel,
15789
16330
  solid: section?.isOccludingAt(neighbor) ?? false
15790
16331
  };
15791
16332
  });
15792
16333
  }
15793
16334
  let mask = 0;
15794
16335
  for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
15795
- const neighbor = pos.clone().add(new import_three39.Vector3(...offset));
16336
+ const neighbor = pos.clone().add(new import_three40.Vector3(...offset));
15796
16337
  if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
15797
16338
  mask |= 1 << face;
15798
16339
  }
@@ -15828,7 +16369,7 @@ var MineRenderWorld = class {
15828
16369
  }
15829
16370
  /** Converts block coordinates to scene units by multiplying each component by 16. */
15830
16371
  static worldToScenePosition(pos) {
15831
- return new import_three39.Vector3(
16372
+ return new import_three40.Vector3(
15832
16373
  pos.x * 16,
15833
16374
  pos.y * 16,
15834
16375
  pos.z * 16
@@ -15836,7 +16377,7 @@ var MineRenderWorld = class {
15836
16377
  }
15837
16378
  /** Converts scene units to block coordinates without rounding to an integer block. */
15838
16379
  static sceneToWorldPosition(pos) {
15839
- return new import_three39.Vector3(
16380
+ return new import_three40.Vector3(
15840
16381
  pos.x / 16,
15841
16382
  pos.y / 16,
15842
16383
  pos.z / 16
@@ -15859,10 +16400,10 @@ var MineRenderWorld = class {
15859
16400
  init_Model();
15860
16401
 
15861
16402
  // src/world/SectionMesh.ts
15862
- var import_three40 = require("three");
16403
+ var import_three41 = require("three");
15863
16404
  init_CanvasCompat();
15864
16405
  init_Materials();
15865
- var SectionMesh = class _SectionMesh extends import_three40.Group {
16406
+ var SectionMesh = class _SectionMesh extends import_three41.Group {
15866
16407
  constructor() {
15867
16408
  super(...arguments);
15868
16409
  this.ownedMeshes = [];
@@ -15915,7 +16456,7 @@ var SectionMesh = class _SectionMesh extends import_three40.Group {
15915
16456
  const normal = template.geometry.getAttribute("normal");
15916
16457
  const uv = template.geometry.getAttribute("uv");
15917
16458
  const bounds = template.geometry.getAttribute("uvBounds");
15918
- const color = template.geometry.getAttribute("color");
16459
+ const color2 = template.geometry.getAttribute("color");
15919
16460
  const sourceIndices = template.geometry.getIndex();
15920
16461
  const placement = locations.get(template.atlas).placement;
15921
16462
  const mapU = (u) => (placement.x + u * template.atlas.image.width) / page.width;
@@ -15937,24 +16478,24 @@ var SectionMesh = class _SectionMesh extends import_three40.Group {
15937
16478
  mapU(bounds?.getZ(vertex) ?? 1),
15938
16479
  mapV(bounds?.getW(vertex) ?? 1)
15939
16480
  );
15940
- colors.push(color?.getX(vertex) ?? 1, color?.getY(vertex) ?? 1, color?.getZ(vertex) ?? 1);
16481
+ colors.push(color2?.getX(vertex) ?? 1, color2?.getY(vertex) ?? 1, color2?.getZ(vertex) ?? 1);
15941
16482
  }
15942
16483
  for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
15943
16484
  }
15944
16485
  }
15945
- const geometry = new import_three40.BufferGeometry();
15946
- geometry.setAttribute("position", new import_three40.Float32BufferAttribute(positions, 3));
15947
- geometry.setAttribute("normal", new import_three40.Float32BufferAttribute(normals, 3));
15948
- geometry.setAttribute("uv", new import_three40.Float32BufferAttribute(uvs, 2));
15949
- geometry.setAttribute("uvBounds", new import_three40.Float32BufferAttribute(uvBounds, 4));
15950
- geometry.setAttribute("color", new import_three40.Float32BufferAttribute(colors, 3));
16486
+ const geometry = new import_three41.BufferGeometry();
16487
+ geometry.setAttribute("position", new import_three41.Float32BufferAttribute(positions, 3));
16488
+ geometry.setAttribute("normal", new import_three41.Float32BufferAttribute(normals, 3));
16489
+ geometry.setAttribute("uv", new import_three41.Float32BufferAttribute(uvs, 2));
16490
+ geometry.setAttribute("uvBounds", new import_three41.Float32BufferAttribute(uvBounds, 4));
16491
+ geometry.setAttribute("color", new import_three41.Float32BufferAttribute(colors, 3));
15951
16492
  geometry.setIndex(indices);
15952
16493
  geometry.computeBoundingBox();
15953
16494
  geometry.computeBoundingSphere();
15954
16495
  const material = Materials.createShadedCanvasMaterial(canvas, false, false, true);
15955
16496
  material.vertexColors = true;
15956
16497
  const texture = material.uniforms?.map?.value ?? material.map;
15957
- const mesh = new import_three40.Mesh(geometry, material);
16498
+ const mesh = new import_three41.Mesh(geometry, material);
15958
16499
  section.add(mesh);
15959
16500
  section.ownedMeshes.push({ mesh, texture });
15960
16501
  }
@@ -15990,10 +16531,10 @@ var Chunk = class _Chunk {
15990
16531
  }
15991
16532
  getBlockAt(posOrX, y, z) {
15992
16533
  if (typeof posOrX == "number") {
15993
- return this.getBlockAt(new import_three41.Vector3(posOrX, y, z));
16534
+ return this.getBlockAt(new import_three42.Vector3(posOrX, y, z));
15994
16535
  }
15995
16536
  if (isTripleArray(posOrX)) {
15996
- return this.getBlockAt(new import_three41.Vector3(posOrX[0], posOrX[1], posOrX[2]));
16537
+ return this.getBlockAt(new import_three42.Vector3(posOrX[0], posOrX[1], posOrX[2]));
15997
16538
  }
15998
16539
  const pos = this.worldPosToChunkPos(posOrX);
15999
16540
  const index = _Chunk.chunkPosToBlockIndex(pos);
@@ -16001,10 +16542,10 @@ var Chunk = class _Chunk {
16001
16542
  }
16002
16543
  async setBlockAt(posOrX, yOrBlock, z, block) {
16003
16544
  if (typeof posOrX == "number") {
16004
- return this.setBlockAt(new import_three41.Vector3(posOrX, yOrBlock, z), block);
16545
+ return this.setBlockAt(new import_three42.Vector3(posOrX, yOrBlock, z), block);
16005
16546
  }
16006
16547
  if (isTripleArray(posOrX)) {
16007
- return this.setBlockAt(new import_three41.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
16548
+ return this.setBlockAt(new import_three42.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
16008
16549
  }
16009
16550
  const worldPos = posOrX;
16010
16551
  const pos = this.worldPosToChunkPos(worldPos);
@@ -16025,7 +16566,7 @@ var Chunk = class _Chunk {
16025
16566
  this.renderedBlocks.get(index)?.object?.removeFromScene();
16026
16567
  if (this.sectionBlocks.delete(index)) this.meshDirty = true;
16027
16568
  this.renderedBlocks.delete(index);
16028
- let object2;
16569
+ let object3;
16029
16570
  try {
16030
16571
  if (!readBlock) return void 0;
16031
16572
  const stored = readBlock();
@@ -16040,22 +16581,22 @@ var Chunk = class _Chunk {
16040
16581
  this.sectionBlocks.set(index, { index, template, cullMask: 0 });
16041
16582
  this.meshDirty = true;
16042
16583
  } else {
16043
- object2 = await this.scene.addBlock(blockState, {
16584
+ object3 = await this.scene.addBlock(blockState, {
16044
16585
  mergeMeshes: true,
16045
16586
  instanceMeshes: true,
16046
16587
  maxInstanceCount: 2e3,
16047
16588
  initialState: stored.properties
16048
16589
  });
16049
- object2.setPosition(MineRenderWorld.worldToScenePosition(worldPos));
16590
+ object3.setPosition(MineRenderWorld.worldToScenePosition(worldPos));
16050
16591
  }
16051
16592
  const info = { get block() {
16052
16593
  return readBlock();
16053
- }, object: object2 };
16594
+ }, object: object3 };
16054
16595
  this.renderedBlocks.set(index, info);
16055
16596
  return info;
16056
16597
  } catch (error) {
16057
16598
  this.data.set(index, void 0);
16058
- object2?.removeFromScene();
16599
+ object3?.removeFromScene();
16059
16600
  throw error;
16060
16601
  } finally {
16061
16602
  await onBlocksChanged?.([worldPos]);
@@ -16118,7 +16659,7 @@ var Chunk = class _Chunk {
16118
16659
  /** Removes stored blocks and their render objects, then notifies the owning world of changed positions. */
16119
16660
  async clear(onBlocksChanged = this.onBlocksChanged) {
16120
16661
  const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
16121
- new import_three41.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
16662
+ new import_three42.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
16122
16663
  ));
16123
16664
  for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
16124
16665
  this.sectionBlocks.clear();
@@ -16144,14 +16685,14 @@ var Chunk = class _Chunk {
16144
16685
  return pos.y * 16 * 16 + pos.z * 16 + pos.x;
16145
16686
  }
16146
16687
  worldPosToChunkPos(pos) {
16147
- return new import_three41.Vector3(
16688
+ return new import_three42.Vector3(
16148
16689
  pos.x - this.x * 16,
16149
16690
  pos.y - this.y * 16,
16150
16691
  pos.z - this.z * 16
16151
16692
  );
16152
16693
  }
16153
16694
  chunkPosToWorldPos(pos) {
16154
- return new import_three41.Vector3(
16695
+ return new import_three42.Vector3(
16155
16696
  this.x * 16 + pos.x,
16156
16697
  this.y * 16 + pos.y,
16157
16698
  this.z * 16 + pos.z
@@ -16204,6 +16745,7 @@ var Chunk = class _Chunk {
16204
16745
  Env,
16205
16746
  FluidModelObject,
16206
16747
  Fonts,
16748
+ GUI_CONTAINER_LAYOUTS,
16207
16749
  Geometries,
16208
16750
  GuiHelper,
16209
16751
  GuiLight,
@@ -16239,6 +16781,7 @@ var Chunk = class _Chunk {
16239
16781
  RequestError,
16240
16782
  Requests,
16241
16783
  SKIN_PARTS,
16784
+ SceneDocumentLoader,
16242
16785
  SceneExporter,
16243
16786
  SceneInspector,
16244
16787
  SceneObject,
@@ -16314,6 +16857,7 @@ var Chunk = class _Chunk {
16314
16857
  mergeBufferAttributes,
16315
16858
  mergeBufferGeometries,
16316
16859
  mergeVertices,
16860
+ parseSceneDocument,
16317
16861
  prefix,
16318
16862
  registerNodeEnv,
16319
16863
  sampleEntityAnimation,