minerender 2.1.0-alpha.76 → 2.1.0-alpha.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -814,8 +814,8 @@ var init_Textures = __esm({
814
814
  for (let y = 0; y < size; y++) {
815
815
  for (let x = 0; x < size; x++) {
816
816
  const offset = (y * size + x) * 4;
817
- const color = (x + y) % 2 === 0 ? 255 : 0;
818
- data[offset] = data[offset + 2] = color;
817
+ const color2 = (x + y) % 2 === 0 ? 255 : 0;
818
+ data[offset] = data[offset + 2] = color2;
819
819
  data[offset + 3] = 255;
820
820
  }
821
821
  }
@@ -1400,17 +1400,17 @@ var init_AssetKey = __esm({
1400
1400
  var DisplayPosition, DISPLAY_POSITIONS;
1401
1401
  var init_DisplayPosition = __esm({
1402
1402
  "src/model/DisplayPosition.ts"() {
1403
- DisplayPosition = /* @__PURE__ */ ((DisplayPosition2) => {
1404
- DisplayPosition2["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
1405
- DisplayPosition2["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
1406
- DisplayPosition2["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
1407
- DisplayPosition2["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
1408
- DisplayPosition2["GUI"] = "gui";
1409
- DisplayPosition2["HEAD"] = "head";
1410
- DisplayPosition2["GROUND"] = "ground";
1411
- DisplayPosition2["FIXED"] = "fixed";
1412
- DisplayPosition2["ON_SHELF"] = "on_shelf";
1413
- return DisplayPosition2;
1403
+ DisplayPosition = /* @__PURE__ */ ((DisplayPosition3) => {
1404
+ DisplayPosition3["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
1405
+ DisplayPosition3["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
1406
+ DisplayPosition3["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
1407
+ DisplayPosition3["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
1408
+ DisplayPosition3["GUI"] = "gui";
1409
+ DisplayPosition3["HEAD"] = "head";
1410
+ DisplayPosition3["GROUND"] = "ground";
1411
+ DisplayPosition3["FIXED"] = "fixed";
1412
+ DisplayPosition3["ON_SHELF"] = "on_shelf";
1413
+ return DisplayPosition3;
1414
1414
  })(DisplayPosition || {});
1415
1415
  DISPLAY_POSITIONS = Object.values(DisplayPosition);
1416
1416
  }
@@ -1628,11 +1628,11 @@ var init_Models = __esm({
1628
1628
  return this.PERSISTENT_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), (k1) => {
1629
1629
  return AssetLoader.get(key, "model" /* MODEL */);
1630
1630
  });
1631
- }).then((asset) => {
1632
- if (asset) {
1633
- asset.key = key;
1631
+ }).then((asset2) => {
1632
+ if (asset2) {
1633
+ asset2.key = key;
1634
1634
  }
1635
- return asset;
1635
+ return asset2;
1636
1636
  });
1637
1637
  }
1638
1638
  /**
@@ -1722,11 +1722,11 @@ var init_BlockStates = __esm({
1722
1722
  return this.PERSISTENT_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), (k1) => {
1723
1723
  return AssetLoader.get(key, "blockstate" /* BLOCKSTATE */);
1724
1724
  });
1725
- }).then((asset) => {
1726
- if (asset) {
1727
- asset.key = key;
1725
+ }).then((asset2) => {
1726
+ if (asset2) {
1727
+ asset2.key = key;
1728
1728
  }
1729
- return asset;
1729
+ return asset2;
1730
1730
  });
1731
1731
  }
1732
1732
  static getAll(keys) {
@@ -1875,29 +1875,29 @@ function applyGenericRotation(axis, rotation, obj) {
1875
1875
  break;
1876
1876
  }
1877
1877
  }
1878
- function addBox3WireframeToObject(box, obj, color = 16777215, w = 2) {
1878
+ function addBox3WireframeToObject(box, obj, color2 = 16777215, w = 2) {
1879
1879
  let size = new import_three8.Vector3();
1880
1880
  box.getSize(size);
1881
1881
  let boxGeo = new import_three8.BoxGeometry(size.x, size.y, size.z, 1, 1, 1);
1882
1882
  let wireGeo = new import_three8.EdgesGeometry(boxGeo);
1883
- let wireMat = new import_three8.LineBasicMaterial({ color, linewidth: w });
1883
+ let wireMat = new import_three8.LineBasicMaterial({ color: color2, linewidth: w });
1884
1884
  let wireframe = new import_three8.LineSegments(wireGeo, wireMat);
1885
1885
  obj.add(wireframe);
1886
1886
  let axes = new import_three8.AxesHelper(1);
1887
1887
  obj.add(axes);
1888
1888
  }
1889
- function addWireframeToObject(obj, color = 16777215, w = 2) {
1889
+ function addWireframeToObject(obj, color2 = 16777215, w = 2) {
1890
1890
  let boxGeo = new import_three8.BoxGeometry(16, 16, 16, 1, 1, 1);
1891
1891
  let wireGeo = new import_three8.EdgesGeometry(boxGeo);
1892
- let wireMat = new import_three8.LineBasicMaterial({ color, linewidth: w });
1892
+ let wireMat = new import_three8.LineBasicMaterial({ color: color2, linewidth: w });
1893
1893
  let wireframe = new import_three8.LineSegments(wireGeo, wireMat);
1894
1894
  obj.add(wireframe);
1895
1895
  let axes = new import_three8.AxesHelper(1);
1896
1896
  obj.add(axes);
1897
1897
  }
1898
- function addWireframeToMesh(geo, mesh, color = 16777215, w = 2) {
1898
+ function addWireframeToMesh(geo, mesh, color2 = 16777215, w = 2) {
1899
1899
  let wireGeo = new import_three8.EdgesGeometry(geo);
1900
- let wireMat = new import_three8.LineBasicMaterial({ color, linewidth: w });
1900
+ let wireMat = new import_three8.LineBasicMaterial({ color: color2, linewidth: w });
1901
1901
  let wireframe = new import_three8.LineSegments(wireGeo, wireMat);
1902
1902
  mesh.add(wireframe);
1903
1903
  let axes = new import_three8.AxesHelper(1);
@@ -2328,27 +2328,27 @@ var init_PackFormats = __esm({
2328
2328
  init_Requests();
2329
2329
  PackFormats = class {
2330
2330
  /** Resolves pack formats from Mojang's client metadata hosted on assets.mcasset.cloud. */
2331
- static async get(version, type) {
2332
- let pending = this.versions.get(version);
2331
+ static async get(version2, type) {
2332
+ let pending = this.versions.get(version2);
2333
2333
  if (!pending || pending.expires <= Date.now()) {
2334
2334
  pending = {
2335
- formats: this.load(version),
2336
- expires: ["latest", "release", "snapshot"].includes(version) ? Date.now() + 3e5 : Infinity
2335
+ formats: this.load(version2),
2336
+ expires: ["latest", "release", "snapshot"].includes(version2) ? Date.now() + 3e5 : Infinity
2337
2337
  };
2338
- this.versions.set(version, pending);
2338
+ this.versions.set(version2, pending);
2339
2339
  }
2340
2340
  try {
2341
2341
  return (await pending.formats)[type];
2342
2342
  } catch (cause) {
2343
- if (this.versions.get(version) === pending) this.versions.delete(version);
2343
+ if (this.versions.get(version2) === pending) this.versions.delete(version2);
2344
2344
  const option = type === "assets" ? "resourcePackFormat" : "dataPackFormat";
2345
2345
  const reason = cause instanceof Error ? cause.message : String(cause);
2346
- throw new Error(`Could not resolve the pack format for Minecraft ${version}. Set ArchiveAssetSource ${option} explicitly. ${reason}`);
2346
+ throw new Error(`Could not resolve the pack format for Minecraft ${version2}. Set ArchiveAssetSource ${option} explicitly. ${reason}`);
2347
2347
  }
2348
2348
  }
2349
- static async load(version) {
2349
+ static async load(version2) {
2350
2350
  const response = await Requests.genericRequest({
2351
- url: `https://assets.mcasset.cloud/${encodeURIComponent(version)}/game-version.json`,
2351
+ url: `https://assets.mcasset.cloud/${encodeURIComponent(version2)}/game-version.json`,
2352
2352
  responseType: "json"
2353
2353
  });
2354
2354
  const data = response.data;
@@ -2437,7 +2437,7 @@ var init_ArchiveAssetSource = __esm({
2437
2437
  }
2438
2438
  async load(key, parser) {
2439
2439
  const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
2440
- const version = AssetLoader.version;
2440
+ const version2 = AssetLoader.version;
2441
2441
  let selectedPath = path;
2442
2442
  let url;
2443
2443
  try {
@@ -2445,7 +2445,7 @@ var init_ArchiveAssetSource = __esm({
2445
2445
  if (key.rootType === "assets" || key.rootType === "data") {
2446
2446
  const metadata = await this.getMetadata(key);
2447
2447
  if (metadata.hasOverlays) {
2448
- const format2 = (key.rootType === "assets" ? this.options.resourcePackFormat : this.options.dataPackFormat) ?? await PackFormats.get(version, key.rootType);
2448
+ const format2 = (key.rootType === "assets" ? this.options.resourcePackFormat : this.options.dataPackFormat) ?? await PackFormats.get(version2, key.rootType);
2449
2449
  directories = metadata.overlayDirectories(format2);
2450
2450
  }
2451
2451
  }
@@ -2532,8 +2532,8 @@ var init_AssetLoader = __esm({
2532
2532
  return this.ROOT.substring(this.ROOT.lastIndexOf("/") + 1);
2533
2533
  }
2534
2534
  /** Selects an mcasset.cloud version, updates the vanilla source, and clears in-memory caches. */
2535
- static setVersion(version) {
2536
- this.ROOT = `https://assets.mcasset.cloud/${version}`;
2535
+ static setVersion(version2) {
2536
+ this.ROOT = `https://assets.mcasset.cloud/${version2}`;
2537
2537
  const source = new HostedAssetSource(this.ROOT, { retryDefaults: false });
2538
2538
  const index = this._SOURCES.findIndex((s) => s.key === "mcassets");
2539
2539
  if (index !== -1) {
@@ -2598,8 +2598,8 @@ ${key}` : key;
2598
2598
  const sources = [...this._SOURCES];
2599
2599
  const results = [];
2600
2600
  for (const { source } of sources) {
2601
- const asset = await source.get(key, parser);
2602
- if (asset != void 0) results.push(asset);
2601
+ const asset2 = await source.get(key, parser);
2602
+ if (asset2 != void 0) results.push(asset2);
2603
2603
  if (await source.blocks(key)) break;
2604
2604
  }
2605
2605
  return results;
@@ -2669,9 +2669,9 @@ var init_ModelTextures = __esm({
2669
2669
  const pending = this.preload(key);
2670
2670
  const cached2 = Caching.textureAssetCache.getIfPresent(keyStr);
2671
2671
  try {
2672
- const asset = await pending;
2673
- if (asset) {
2674
- return await ImageLoader.infoToCanvasData(asset);
2672
+ const asset2 = await pending;
2673
+ if (asset2) {
2674
+ return await ImageLoader.infoToCanvasData(asset2);
2675
2675
  }
2676
2676
  return void 0;
2677
2677
  } catch (err) {
@@ -2685,10 +2685,10 @@ var init_ModelTextures = __esm({
2685
2685
  static async preload(key) {
2686
2686
  const keyStr = key.serialize();
2687
2687
  return Caching.textureAssetCache.get(keyStr, (k) => {
2688
- return AssetLoader.get(key, "image" /* IMAGE */).then((asset) => {
2689
- if (asset)
2690
- asset.key = key;
2691
- return asset;
2688
+ return AssetLoader.get(key, "image" /* IMAGE */).then((asset2) => {
2689
+ if (asset2)
2690
+ asset2.key = key;
2691
+ return asset2;
2692
2692
  });
2693
2693
  });
2694
2694
  }
@@ -2701,10 +2701,10 @@ var init_ModelTextures = __esm({
2701
2701
  const keyStr = key.serialize();
2702
2702
  return Caching.textureMetaCache.get(keyStr, (k) => {
2703
2703
  return this.PERSISTENT_META_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), (k1) => {
2704
- return AssetLoader.get(key, "meta" /* META */).then((asset) => {
2705
- if (asset)
2706
- asset.key = key;
2707
- return asset;
2704
+ return AssetLoader.get(key, "meta" /* META */).then((asset2) => {
2705
+ if (asset2)
2706
+ asset2.key = key;
2707
+ return asset2;
2708
2708
  });
2709
2709
  });
2710
2710
  });
@@ -3258,12 +3258,12 @@ var init_UVMapper = __esm({
3258
3258
  } else {
3259
3259
  uniqueTextureNames.push(textureKey);
3260
3260
  const assetKey = AssetKey.parse("textures", textureValue, model.key);
3261
- promises.push(ModelTextures.get(assetKey).then((asset) => {
3262
- if (!asset) {
3261
+ promises.push(ModelTextures.get(assetKey).then((asset2) => {
3262
+ if (!asset2) {
3263
3263
  console.warn(p5, "Missing texture", assetKey);
3264
3264
  return;
3265
3265
  }
3266
- textureMap[textureKey] = new WrappedImage(asset);
3266
+ textureMap[textureKey] = new WrappedImage(asset2);
3267
3267
  }));
3268
3268
  promises.push(ModelTextures.getMeta(assetKey).then((meta) => {
3269
3269
  metaMap[textureKey] = meta;
@@ -3607,10 +3607,10 @@ var init_Entities = __esm({
3607
3607
  const collect = async (path) => {
3608
3608
  const prefix2 = path ? `${path}/` : "";
3609
3609
  const key = new AssetKey(DEFAULT_NAMESPACE, `${prefix2}_list`, void 0, void 0, "entity-models", ".json");
3610
- const list = await Caching.listAssetCache.get(key.serialize(), () => AssetLoader.get(key, "list" /* LIST */));
3611
- if (!list) return [];
3612
- const files = list.files.filter((file) => file.endsWith(".json") && file !== "_list.json").map((file) => `${prefix2}${file.slice(0, -5)}`);
3613
- const children = await Promise.all(list.directories.map((directory) => collect(`${prefix2}${directory}`)));
3610
+ const list2 = await Caching.listAssetCache.get(key.serialize(), () => AssetLoader.get(key, "list" /* LIST */));
3611
+ if (!list2) return [];
3612
+ const files = list2.files.filter((file) => file.endsWith(".json") && file !== "_list.json").map((file) => `${prefix2}${file.slice(0, -5)}`);
3613
+ const children = await Promise.all(list2.directories.map((directory) => collect(`${prefix2}${directory}`)));
3614
3614
  return [...files, ...children.flat()];
3615
3615
  };
3616
3616
  return collect("");
@@ -3694,8 +3694,8 @@ var init_Entities = __esm({
3694
3694
  if (await ModelTextures.get(texture2)) return texture2;
3695
3695
  }
3696
3696
  const listKey = new AssetKey(modelKey.namespace, "_list", `${name}_variant`, void 0, "data", ".json", root);
3697
- const list = await AssetLoader.get(listKey, "list" /* LIST */);
3698
- const files = list?.files.filter((file2) => file2.endsWith(".json") && file2 !== "_list.json");
3697
+ const list2 = await AssetLoader.get(listKey, "list" /* LIST */);
3698
+ const files = list2?.files.filter((file2) => file2.endsWith(".json") && file2 !== "_list.json");
3699
3699
  const file = files?.find((file2) => file2 === "temperate.json") ?? files?.[0];
3700
3700
  if (!file) return void 0;
3701
3701
  const variantKey = new AssetKey(modelKey.namespace, file.slice(0, -5), `${name}_variant`, void 0, "data", ".json", root);
@@ -3800,27 +3800,27 @@ var init_EntityAnimationPlayer = __esm({
3800
3800
  for (const layer of layers) {
3801
3801
  const objects = [];
3802
3802
  if (poses) {
3803
- layer.traverse((object2) => {
3804
- if (poses.has(object2)) objects.push(object2);
3803
+ layer.traverse((object3) => {
3804
+ if (poses.has(object3)) objects.push(object3);
3805
3805
  });
3806
3806
  } else {
3807
3807
  for (const bone of Object.keys(animation.bones)) {
3808
- const object2 = layer.getObjectByName(`group:${bone}`);
3809
- if (object2) objects.push(object2);
3808
+ const object3 = layer.getObjectByName(`group:${bone}`);
3809
+ if (object3) objects.push(object3);
3810
3810
  }
3811
3811
  }
3812
- for (const object2 of objects) {
3813
- const bone = object2.name.slice("group:".length);
3814
- const pose = poses?.get(object2);
3812
+ for (const object3 of objects) {
3813
+ const bone = object3.name.slice("group:".length);
3814
+ const pose = poses?.get(object3);
3815
3815
  this.parts.push({
3816
3816
  bone,
3817
- object: object2,
3818
- position: object2.position.clone(),
3819
- rotation: object2.rotation.clone(),
3820
- scale: object2.scale.clone(),
3821
- basePosition: pose ? new import_three11.Vector3(...pose.offset) : object2.position.clone(),
3822
- baseRotation: pose ? new import_three11.Euler(...pose.rotation, "ZYX") : object2.rotation.clone(),
3823
- baseScale: pose ? new import_three11.Vector3(...pose.scale ?? [1, 1, 1]) : object2.scale.clone()
3817
+ object: object3,
3818
+ position: object3.position.clone(),
3819
+ rotation: object3.rotation.clone(),
3820
+ scale: object3.scale.clone(),
3821
+ basePosition: pose ? new import_three11.Vector3(...pose.offset) : object3.position.clone(),
3822
+ baseRotation: pose ? new import_three11.Euler(...pose.rotation, "ZYX") : object3.rotation.clone(),
3823
+ baseScale: pose ? new import_three11.Vector3(...pose.scale ?? [1, 1, 1]) : object3.scale.clone()
3824
3824
  });
3825
3825
  }
3826
3826
  }
@@ -4178,10 +4178,10 @@ var init_SceneObject = __esm({
4178
4178
  return new import_three12.InstancedBufferAttribute(array, attribute.itemSize, attribute.normalized, attribute.meshPerAttribute).setUsage(attribute.usage);
4179
4179
  };
4180
4180
  const matrix = grow(mesh.instanceMatrix, 0);
4181
- const color = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
4181
+ const color2 = mesh.instanceColor ? grow(mesh.instanceColor, 1) : null;
4182
4182
  mesh.dispose();
4183
4183
  mesh.instanceMatrix = matrix;
4184
- mesh.instanceColor = color;
4184
+ mesh.instanceColor = color2;
4185
4185
  }
4186
4186
  *activeInstanceIndices() {
4187
4187
  if (this.instanceMesh) {
@@ -4354,15 +4354,15 @@ var init_SceneObject = __esm({
4354
4354
  }
4355
4355
  }
4356
4356
  //</editor-fold>
4357
- toggleObjectVisibility(object2, visible) {
4358
- if (object2) {
4357
+ toggleObjectVisibility(object3, visible) {
4358
+ if (object3) {
4359
4359
  if (typeof visible !== "undefined") {
4360
- object2.visible = visible;
4360
+ object3.visible = visible;
4361
4361
  } else {
4362
- object2.visible = !object2.visible;
4362
+ object3.visible = !object3.visible;
4363
4363
  }
4364
4364
  this.notifyDirty();
4365
- return object2.visible;
4365
+ return object3.visible;
4366
4366
  }
4367
4367
  this.notifyDirty();
4368
4368
  return false;
@@ -4662,8 +4662,8 @@ var init_EntityObject = __esm({
4662
4662
  this.scrollMaterials.push({ material: mat, offset: mat.map.offset, speed: scroll });
4663
4663
  }
4664
4664
  }
4665
- this.getLayerGroup(name)?.traverse((object2) => {
4666
- if (isMesh(object2)) object2.material = mat;
4665
+ this.getLayerGroup(name)?.traverse((object3) => {
4666
+ if (isMesh(object3)) object3.material = mat;
4667
4667
  });
4668
4668
  }));
4669
4669
  if (!this.children.length) {
@@ -4993,8 +4993,8 @@ function toTrianglesDrawMode(geometry, drawMode) {
4993
4993
  return geometry;
4994
4994
  }
4995
4995
  }
4996
- function computeMorphedAttributes(object2) {
4997
- if (object2.geometry.isBufferGeometry !== true) {
4996
+ function computeMorphedAttributes(object3) {
4997
+ if (object3.geometry.isBufferGeometry !== true) {
4998
4998
  console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
4999
4999
  return null;
5000
5000
  }
@@ -5007,11 +5007,11 @@ function computeMorphedAttributes(object2) {
5007
5007
  const _morphA = new import_three22.Vector3();
5008
5008
  const _morphB = new import_three22.Vector3();
5009
5009
  const _morphC = new import_three22.Vector3();
5010
- function _calculateMorphedAttributeData(object3, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
5010
+ function _calculateMorphedAttributeData(object4, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
5011
5011
  _vA.fromBufferAttribute(attribute, a2);
5012
5012
  _vB.fromBufferAttribute(attribute, b2);
5013
5013
  _vC.fromBufferAttribute(attribute, c2);
5014
- const morphInfluences = object3.morphTargetInfluences;
5014
+ const morphInfluences = object4.morphTargetInfluences;
5015
5015
  if (material2.morphTargets && morphAttribute && morphInfluences) {
5016
5016
  _morphA.set(0, 0, 0);
5017
5017
  _morphB.set(0, 0, 0);
@@ -5037,10 +5037,10 @@ function computeMorphedAttributes(object2) {
5037
5037
  _vB.add(_morphB);
5038
5038
  _vC.add(_morphC);
5039
5039
  }
5040
- if (object3.isSkinnedMesh) {
5041
- object3.boneTransform(a2, _vA);
5042
- object3.boneTransform(b2, _vB);
5043
- object3.boneTransform(c2, _vC);
5040
+ if (object4.isSkinnedMesh) {
5041
+ object4.boneTransform(a2, _vA);
5042
+ object4.boneTransform(b2, _vB);
5043
+ object4.boneTransform(c2, _vC);
5044
5044
  }
5045
5045
  modifiedAttributeArray[a2 * 3 + 0] = _vA.x;
5046
5046
  modifiedAttributeArray[a2 * 3 + 1] = _vA.y;
@@ -5052,8 +5052,8 @@ function computeMorphedAttributes(object2) {
5052
5052
  modifiedAttributeArray[c2 * 3 + 1] = _vC.y;
5053
5053
  modifiedAttributeArray[c2 * 3 + 2] = _vC.z;
5054
5054
  }
5055
- const geometry = object2.geometry;
5056
- const material = object2.material;
5055
+ const geometry = object3.geometry;
5056
+ const material = object3.material;
5057
5057
  let a, b, c;
5058
5058
  const index = geometry.index;
5059
5059
  const positionAttribute = geometry.attributes.position;
@@ -5080,7 +5080,7 @@ function computeMorphedAttributes(object2) {
5080
5080
  b = index.getX(j + 1);
5081
5081
  c = index.getX(j + 2);
5082
5082
  _calculateMorphedAttributeData(
5083
- object2,
5083
+ object3,
5084
5084
  groupMaterial,
5085
5085
  positionAttribute,
5086
5086
  morphPosition,
@@ -5091,7 +5091,7 @@ function computeMorphedAttributes(object2) {
5091
5091
  modifiedPosition
5092
5092
  );
5093
5093
  _calculateMorphedAttributeData(
5094
- object2,
5094
+ object3,
5095
5095
  groupMaterial,
5096
5096
  normalAttribute,
5097
5097
  morphNormal,
@@ -5111,7 +5111,7 @@ function computeMorphedAttributes(object2) {
5111
5111
  b = index.getX(i + 1);
5112
5112
  c = index.getX(i + 2);
5113
5113
  _calculateMorphedAttributeData(
5114
- object2,
5114
+ object3,
5115
5115
  material,
5116
5116
  positionAttribute,
5117
5117
  morphPosition,
@@ -5122,7 +5122,7 @@ function computeMorphedAttributes(object2) {
5122
5122
  modifiedPosition
5123
5123
  );
5124
5124
  _calculateMorphedAttributeData(
5125
- object2,
5125
+ object3,
5126
5126
  material,
5127
5127
  normalAttribute,
5128
5128
  morphNormal,
@@ -5146,7 +5146,7 @@ function computeMorphedAttributes(object2) {
5146
5146
  b = j + 1;
5147
5147
  c = j + 2;
5148
5148
  _calculateMorphedAttributeData(
5149
- object2,
5149
+ object3,
5150
5150
  groupMaterial,
5151
5151
  positionAttribute,
5152
5152
  morphPosition,
@@ -5157,7 +5157,7 @@ function computeMorphedAttributes(object2) {
5157
5157
  modifiedPosition
5158
5158
  );
5159
5159
  _calculateMorphedAttributeData(
5160
- object2,
5160
+ object3,
5161
5161
  groupMaterial,
5162
5162
  normalAttribute,
5163
5163
  morphNormal,
@@ -5177,7 +5177,7 @@ function computeMorphedAttributes(object2) {
5177
5177
  b = i + 1;
5178
5178
  c = i + 2;
5179
5179
  _calculateMorphedAttributeData(
5180
- object2,
5180
+ object3,
5181
5181
  material,
5182
5182
  positionAttribute,
5183
5183
  morphPosition,
@@ -5188,7 +5188,7 @@ function computeMorphedAttributes(object2) {
5188
5188
  modifiedPosition
5189
5189
  );
5190
5190
  _calculateMorphedAttributeData(
5191
- object2,
5191
+ object3,
5192
5192
  material,
5193
5193
  normalAttribute,
5194
5194
  morphNormal,
@@ -5446,9 +5446,9 @@ var init_ItemTints = __esm({
5446
5446
  }));
5447
5447
  return colors;
5448
5448
  }
5449
- static rgb(color) {
5450
- if (!Array.isArray(color)) return color & 16777215;
5451
- const [red, green, blue] = color.map((channel) => Math.floor(Math.fround(Math.fround(channel) * 255)));
5449
+ static rgb(color2) {
5450
+ if (!Array.isArray(color2)) return color2 & 16777215;
5451
+ const [red, green, blue] = color2.map((channel) => Math.floor(Math.fround(Math.fround(channel) * 255)));
5452
5452
  return red << 16 | green << 8 | blue;
5453
5453
  }
5454
5454
  };
@@ -5501,13 +5501,13 @@ var init_ModelObject = __esm({
5501
5501
  transform.multiply(new import_three25.Matrix4().makeTranslation(-8, -8, -8));
5502
5502
  try {
5503
5503
  for (const part of parts) {
5504
- const object2 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
5505
- object2.matrix.copy(transform).multiply(part.transform);
5506
- object2.matrixWorldNeedsUpdate = true;
5507
- object2.matrixAutoUpdate = false;
5508
- this.add(object2);
5509
- await object2.init();
5510
- object2.iterateAllMeshes((mesh) => {
5504
+ const object3 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
5505
+ object3.matrix.copy(transform).multiply(part.transform);
5506
+ object3.matrixWorldNeedsUpdate = true;
5507
+ object3.matrixAutoUpdate = false;
5508
+ this.add(object3);
5509
+ await object3.init();
5510
+ object3.iterateAllMeshes((mesh) => {
5511
5511
  const source = mesh.material;
5512
5512
  let material = this.specialMaterials.get(source);
5513
5513
  if (!material) {
@@ -5518,7 +5518,7 @@ var init_ModelObject = __esm({
5518
5518
  mesh.material = material;
5519
5519
  });
5520
5520
  for (const [name, rotation] of Object.entries(part.rotations)) {
5521
- object2.getGroupByName(name)?.rotation.set(...rotation, "ZYX");
5521
+ object3.getGroupByName(name)?.rotation.set(...rotation, "ZYX");
5522
5522
  }
5523
5523
  }
5524
5524
  } catch (error) {
@@ -5571,9 +5571,9 @@ var init_ModelObject = __esm({
5571
5571
  if (tintIndex === void 0 || tintIndex < 0) continue;
5572
5572
  const tint = this.options.tints[tintIndex];
5573
5573
  if (tint === void 0) continue;
5574
- const color = new import_three25.Color(tint);
5574
+ const color2 = new import_three25.Color(tint);
5575
5575
  for (let vertex = 0; vertex < 4; vertex++) {
5576
- color.toArray(colors, (faceIndex * 4 + vertex) * 3);
5576
+ color2.toArray(colors, (faceIndex * 4 + vertex) * 3);
5577
5577
  }
5578
5578
  }
5579
5579
  elGeo.setAttribute("color", new import_three25.BufferAttribute(colors, 3));
@@ -5890,9 +5890,9 @@ var init_FluidModelObject = __esm({
5890
5890
  }
5891
5891
  }
5892
5892
  geometry.clearGroups();
5893
- const color = new import_three31.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
5893
+ const color2 = new import_three31.Color(this.options.tints?.[0] ?? (this.kind === "water" ? 4159204 : 16777215));
5894
5894
  const colors = new Float32Array(geometry.getAttribute("position").count * 3);
5895
- for (let i = 0; i < colors.length; i += 3) color.toArray(colors, i);
5895
+ for (let i = 0; i < colors.length; i += 3) color2.toArray(colors, i);
5896
5896
  geometry.setAttribute("color", new import_three31.BufferAttribute(colors, 3));
5897
5897
  geometry.computeBoundingBox();
5898
5898
  geometry.computeBoundingSphere();
@@ -6003,6 +6003,7 @@ __export(index_browser_exports, {
6003
6003
  RequestError: () => RequestError,
6004
6004
  Requests: () => Requests,
6005
6005
  SKIN_PARTS: () => SKIN_PARTS,
6006
+ SceneDocumentLoader: () => SceneDocumentLoader,
6006
6007
  SceneExporter: () => SceneExporter,
6007
6008
  SceneInspector: () => SceneInspector,
6008
6009
  SceneObject: () => SceneObject,
@@ -6078,6 +6079,7 @@ __export(index_browser_exports, {
6078
6079
  mergeBufferAttributes: () => mergeBufferAttributes,
6079
6080
  mergeBufferGeometries: () => mergeBufferGeometries,
6080
6081
  mergeVertices: () => mergeVertices,
6082
+ parseSceneDocument: () => parseSceneDocument,
6081
6083
  prefix: () => prefix,
6082
6084
  probeImageSize: () => probeImageSize,
6083
6085
  registerBrowserEnv: () => registerBrowserEnv,
@@ -6206,11 +6208,11 @@ var BrowserEnv = class {
6206
6208
  imageSize(data) {
6207
6209
  return probeImageSize(data);
6208
6210
  }
6209
- openCache(name, version) {
6211
+ openCache(name, version2) {
6210
6212
  return new BrowserCache(import_localforage.default.createInstance({
6211
6213
  // IndexedDB schema upgrades retain records; each cache generation needs its own database.
6212
- name: name + version,
6213
- version
6214
+ name: name + version2,
6215
+ version: version2
6214
6216
  }));
6215
6217
  }
6216
6218
  };
@@ -6370,8 +6372,8 @@ var Fonts = class {
6370
6372
  const stack = await AssetLoader.getAll(key, "json" /* JSON */);
6371
6373
  if (stack.length === 0) throw new Error(`Could not load font ${key.toNamespacedString()}`);
6372
6374
  const glyphs = /* @__PURE__ */ new Map();
6373
- for (const asset of stack) {
6374
- for (const provider of asset.providers) {
6375
+ for (const asset2 of stack) {
6376
+ for (const provider of asset2.providers) {
6375
6377
  if (provider.filter?.uniform || provider.filter?.jp) continue;
6376
6378
  let provided;
6377
6379
  switch (provider.type) {
@@ -6510,13 +6512,13 @@ var OBJExporter = class {
6510
6512
  * @param {Object3D} object - The 3D object to export.
6511
6513
  * @return {string} The exported OBJ.
6512
6514
  */
6513
- parse(object2) {
6515
+ parse(object3) {
6514
6516
  let output = "";
6515
6517
  let indexVertex = 0;
6516
6518
  let indexVertexUvs = 0;
6517
6519
  let indexNormals = 0;
6518
6520
  const vertex = new import_three16.Vector3();
6519
- const color = new import_three16.Color();
6521
+ const color2 = new import_three16.Color();
6520
6522
  const normal = new import_three16.Vector3();
6521
6523
  const uv = new import_three16.Vector2();
6522
6524
  const face = [];
@@ -6615,9 +6617,9 @@ var OBJExporter = class {
6615
6617
  vertex.applyMatrix4(points.matrixWorld);
6616
6618
  output += "v " + vertex.x + " " + vertex.y + " " + vertex.z;
6617
6619
  if (colors !== void 0) {
6618
- color.fromBufferAttribute(colors, i);
6619
- import_three16.ColorManagement.workingToColorSpace(color, import_three16.SRGBColorSpace);
6620
- output += " " + color.r + " " + color.g + " " + color.b;
6620
+ color2.fromBufferAttribute(colors, i);
6621
+ import_three16.ColorManagement.workingToColorSpace(color2, import_three16.SRGBColorSpace);
6622
+ output += " " + color2.r + " " + color2.g + " " + color2.b;
6621
6623
  }
6622
6624
  output += "\n";
6623
6625
  }
@@ -6629,7 +6631,7 @@ var OBJExporter = class {
6629
6631
  }
6630
6632
  indexVertex += nbVertex;
6631
6633
  }
6632
- object2.traverse(function(child) {
6634
+ object3.traverse(function(child) {
6633
6635
  if (child.isMesh === true) {
6634
6636
  parseMesh(child);
6635
6637
  }
@@ -6657,9 +6659,9 @@ var PLYExporter = class {
6657
6659
  * @param {PLYExporter~Options} options - The export options.
6658
6660
  * @return {?(string|ArrayBuffer)} The exported PLY.
6659
6661
  */
6660
- parse(object2, onDone, options = {}) {
6662
+ parse(object3, onDone, options = {}) {
6661
6663
  function traverseMeshes(cb) {
6662
- object2.traverse(function(child) {
6664
+ object3.traverse(function(child) {
6663
6665
  if (child.isMesh === true || child.isPoints) {
6664
6666
  const mesh = child;
6665
6667
  const geometry = mesh.geometry;
@@ -6692,7 +6694,7 @@ var PLYExporter = class {
6692
6694
  for (const name of customAttributeNames) customTypes[name] = "float";
6693
6695
  let vertexCount = 0;
6694
6696
  let faceCount = 0;
6695
- object2.traverse(function(child) {
6697
+ object3.traverse(function(child) {
6696
6698
  if (child.isMesh === true) {
6697
6699
  const mesh = child;
6698
6700
  const geometry = mesh.geometry;
@@ -7286,8 +7288,8 @@ function equalArray(array1, array2) {
7286
7288
  return element === array2[index];
7287
7289
  });
7288
7290
  }
7289
- function stringToArrayBuffer(text) {
7290
- return new TextEncoder().encode(text).buffer;
7291
+ function stringToArrayBuffer(text2) {
7292
+ return new TextEncoder().encode(text2).buffer;
7291
7293
  }
7292
7294
  function isIdentityMatrix(matrix) {
7293
7295
  return equalArray(matrix.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
@@ -7480,12 +7482,12 @@ var GLTFWriter = class {
7480
7482
  * @param {THREE.Object3D|THREE.Material|THREE.BufferGeometry|THREE.AnimationClip} object
7481
7483
  * @param {Object} objectDef
7482
7484
  */
7483
- serializeUserData(object2, objectDef) {
7484
- if (Object.keys(object2.userData).length === 0) return;
7485
+ serializeUserData(object3, objectDef) {
7486
+ if (Object.keys(object3.userData).length === 0) return;
7485
7487
  const options = this.options;
7486
7488
  const extensionsUsed = this.extensionsUsed;
7487
7489
  try {
7488
- const json = JSON.parse(JSON.stringify(object2.userData));
7490
+ const json = JSON.parse(JSON.stringify(object3.userData));
7489
7491
  if (options.includeCustomExtensions && json.gltfExtensions) {
7490
7492
  if (objectDef.extensions === void 0) objectDef.extensions = {};
7491
7493
  for (const extensionName in json.gltfExtensions) {
@@ -7496,7 +7498,7 @@ var GLTFWriter = class {
7496
7498
  }
7497
7499
  if (Object.keys(json).length > 0) objectDef.extras = json;
7498
7500
  } catch (error) {
7499
- console.warn("THREE.GLTFExporter: userData of '" + object2.name + "' won't be serialized because of JSON.stringify error - " + error.message);
7501
+ console.warn("THREE.GLTFExporter: userData of '" + object3.name + "' won't be serialized because of JSON.stringify error - " + error.message);
7500
7502
  }
7501
7503
  }
7502
7504
  /**
@@ -8005,9 +8007,9 @@ var GLTFWriter = class {
8005
8007
  if (material.isMeshStandardMaterial !== true && material.isMeshBasicMaterial !== true) {
8006
8008
  console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");
8007
8009
  }
8008
- const color = material.color.toArray().concat([material.opacity]);
8009
- if (!equalArray(color, [1, 1, 1, 1])) {
8010
- materialDef.pbrMetallicRoughness.baseColorFactor = color;
8010
+ const color2 = material.color.toArray().concat([material.opacity]);
8011
+ if (!equalArray(color2, [1, 1, 1, 1])) {
8012
+ materialDef.pbrMetallicRoughness.baseColorFactor = color2;
8011
8013
  }
8012
8014
  if (material.isMeshStandardMaterial) {
8013
8015
  materialDef.pbrMetallicRoughness.metallicFactor = material.metalness;
@@ -8422,13 +8424,13 @@ var GLTFWriter = class {
8422
8424
  * @param {THREE.Object3D} object
8423
8425
  * @return {?number}
8424
8426
  */
8425
- processSkin(object2) {
8427
+ processSkin(object3) {
8426
8428
  const json = this.json;
8427
8429
  const nodeMap = this.nodeMap;
8428
- const node = json.nodes[nodeMap.get(object2)];
8429
- const skeleton = object2.skeleton;
8430
+ const node = json.nodes[nodeMap.get(object3)];
8431
+ const skeleton = object3.skeleton;
8430
8432
  if (skeleton === void 0) return null;
8431
- const rootJoint = object2.skeleton.bones[0];
8433
+ const rootJoint = object3.skeleton.bones[0];
8432
8434
  if (rootJoint === void 0) return null;
8433
8435
  const joints = [];
8434
8436
  const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
@@ -8436,7 +8438,7 @@ var GLTFWriter = class {
8436
8438
  for (let i = 0; i < skeleton.bones.length; ++i) {
8437
8439
  joints.push(nodeMap.get(skeleton.bones[i]));
8438
8440
  temporaryBoneInverse.copy(skeleton.boneInverses[i]);
8439
- temporaryBoneInverse.multiply(object2.bindMatrix).toArray(inverseBindMatrices, i * 16);
8441
+ temporaryBoneInverse.multiply(object3.bindMatrix).toArray(inverseBindMatrices, i * 16);
8440
8442
  }
8441
8443
  if (json.skins === void 0) json.skins = [];
8442
8444
  json.skins.push({
@@ -8452,19 +8454,19 @@ var GLTFWriter = class {
8452
8454
  * @param {THREE.Object3D} object Object3D to processNodeAsync
8453
8455
  * @return {Promise<number>} Index of the node in the nodes list
8454
8456
  */
8455
- async processNodeAsync(object2) {
8457
+ async processNodeAsync(object3) {
8456
8458
  const json = this.json;
8457
8459
  const options = this.options;
8458
8460
  const nodeMap = this.nodeMap;
8459
8461
  if (!json.nodes) json.nodes = [];
8460
- if (object2.pivot !== null) {
8461
- return await this._processNodeWithPivotAsync(object2);
8462
+ if (object3.pivot !== null) {
8463
+ return await this._processNodeWithPivotAsync(object3);
8462
8464
  }
8463
8465
  const nodeDef = {};
8464
8466
  if (options.trs) {
8465
- const rotation = object2.quaternion.toArray();
8466
- const position = object2.position.toArray();
8467
- const scale = object2.scale.toArray();
8467
+ const rotation = object3.quaternion.toArray();
8468
+ const position = object3.position.toArray();
8469
+ const scale = object3.scale.toArray();
8468
8470
  if (!equalArray(rotation, [0, 0, 0, 1])) {
8469
8471
  nodeDef.rotation = rotation;
8470
8472
  }
@@ -8475,28 +8477,28 @@ var GLTFWriter = class {
8475
8477
  nodeDef.scale = scale;
8476
8478
  }
8477
8479
  } else {
8478
- if (object2.matrixAutoUpdate) {
8479
- object2.updateMatrix();
8480
+ if (object3.matrixAutoUpdate) {
8481
+ object3.updateMatrix();
8480
8482
  }
8481
- if (isIdentityMatrix(object2.matrix) === false) {
8482
- nodeDef.matrix = object2.matrix.elements;
8483
+ if (isIdentityMatrix(object3.matrix) === false) {
8484
+ nodeDef.matrix = object3.matrix.elements;
8483
8485
  }
8484
8486
  }
8485
- if (object2.name !== "") nodeDef.name = String(object2.name);
8486
- this.serializeUserData(object2, nodeDef);
8487
- if (object2.isMesh || object2.isLine || object2.isPoints) {
8488
- const meshIndex = await this.processMeshAsync(object2);
8487
+ if (object3.name !== "") nodeDef.name = String(object3.name);
8488
+ this.serializeUserData(object3, nodeDef);
8489
+ if (object3.isMesh || object3.isLine || object3.isPoints) {
8490
+ const meshIndex = await this.processMeshAsync(object3);
8489
8491
  if (meshIndex !== null) nodeDef.mesh = meshIndex;
8490
- } else if (object2.isCamera) {
8491
- nodeDef.camera = this.processCamera(object2);
8492
+ } else if (object3.isCamera) {
8493
+ nodeDef.camera = this.processCamera(object3);
8492
8494
  }
8493
- if (object2.isSkinnedMesh) this.skins.push(object2);
8495
+ if (object3.isSkinnedMesh) this.skins.push(object3);
8494
8496
  const nodeIndex = json.nodes.push(nodeDef) - 1;
8495
- nodeMap.set(object2, nodeIndex);
8496
- if (object2.children.length > 0) {
8497
+ nodeMap.set(object3, nodeIndex);
8498
+ if (object3.children.length > 0) {
8497
8499
  const children = [];
8498
- for (let i = 0, l = object2.children.length; i < l; i++) {
8499
- const child = object2.children[i];
8500
+ for (let i = 0, l = object3.children.length; i < l; i++) {
8501
+ const child = object3.children[i];
8500
8502
  if (child.visible || options.onlyVisible === false) {
8501
8503
  const childNodeIndex = await this.processNodeAsync(child);
8502
8504
  if (childNodeIndex !== null) children.push(childNodeIndex);
@@ -8505,7 +8507,7 @@ var GLTFWriter = class {
8505
8507
  if (children.length > 0) nodeDef.children = children;
8506
8508
  }
8507
8509
  await this._invokeAllAsync(function(ext) {
8508
- ext.writeNode && ext.writeNode(object2, nodeDef);
8510
+ ext.writeNode && ext.writeNode(object3, nodeDef);
8509
8511
  });
8510
8512
  return nodeIndex;
8511
8513
  }
@@ -8514,19 +8516,19 @@ var GLTFWriter = class {
8514
8516
  * @param {THREE.Object3D} object Object3D with pivot
8515
8517
  * @return {Promise<number>} Index of the container node
8516
8518
  */
8517
- async _processNodeWithPivotAsync(object2) {
8519
+ async _processNodeWithPivotAsync(object3) {
8518
8520
  const json = this.json;
8519
8521
  const options = this.options;
8520
8522
  const nodeMap = this.nodeMap;
8521
- const pivot = object2.pivot;
8523
+ const pivot = object3.pivot;
8522
8524
  const containerDef = {};
8523
- const rotation = object2.quaternion.toArray();
8525
+ const rotation = object3.quaternion.toArray();
8524
8526
  const position = [
8525
- object2.position.x + pivot.x,
8526
- object2.position.y + pivot.y,
8527
- object2.position.z + pivot.z
8527
+ object3.position.x + pivot.x,
8528
+ object3.position.y + pivot.y,
8529
+ object3.position.z + pivot.z
8528
8530
  ];
8529
- const scale = object2.scale.toArray();
8531
+ const scale = object3.scale.toArray();
8530
8532
  if (!equalArray(rotation, [0, 0, 0, 1])) {
8531
8533
  containerDef.rotation = rotation;
8532
8534
  }
@@ -8537,28 +8539,28 @@ var GLTFWriter = class {
8537
8539
  containerDef.scale = scale;
8538
8540
  }
8539
8541
  containerDef.extras = { pivot: pivot.toArray() };
8540
- if (object2.name !== "") containerDef.name = String(object2.name);
8541
- this.serializeUserData(object2, containerDef);
8542
+ if (object3.name !== "") containerDef.name = String(object3.name);
8543
+ this.serializeUserData(object3, containerDef);
8542
8544
  const containerIndex = json.nodes.push(containerDef) - 1;
8543
- nodeMap.set(object2, containerIndex);
8545
+ nodeMap.set(object3, containerIndex);
8544
8546
  const childDef = {};
8545
8547
  const childPosition = [-pivot.x, -pivot.y, -pivot.z];
8546
8548
  if (!equalArray(childPosition, [0, 0, 0])) {
8547
8549
  childDef.translation = childPosition;
8548
8550
  }
8549
- if (object2.isMesh || object2.isLine || object2.isPoints) {
8550
- const meshIndex = await this.processMeshAsync(object2);
8551
+ if (object3.isMesh || object3.isLine || object3.isPoints) {
8552
+ const meshIndex = await this.processMeshAsync(object3);
8551
8553
  if (meshIndex !== null) childDef.mesh = meshIndex;
8552
- } else if (object2.isCamera) {
8553
- childDef.camera = this.processCamera(object2);
8554
+ } else if (object3.isCamera) {
8555
+ childDef.camera = this.processCamera(object3);
8554
8556
  }
8555
- if (object2.isSkinnedMesh) this.skins.push(object2);
8557
+ if (object3.isSkinnedMesh) this.skins.push(object3);
8556
8558
  const childIndex = json.nodes.push(childDef) - 1;
8557
8559
  const containerChildren = [childIndex];
8558
- if (object2.children.length > 0) {
8560
+ if (object3.children.length > 0) {
8559
8561
  const grandchildren = [];
8560
- for (let i = 0, l = object2.children.length; i < l; i++) {
8561
- const child = object2.children[i];
8562
+ for (let i = 0, l = object3.children.length; i < l; i++) {
8563
+ const child = object3.children[i];
8562
8564
  if (child.visible || options.onlyVisible === false) {
8563
8565
  const childNodeIndex = await this.processNodeAsync(child);
8564
8566
  if (childNodeIndex !== null) grandchildren.push(childNodeIndex);
@@ -8568,7 +8570,7 @@ var GLTFWriter = class {
8568
8570
  }
8569
8571
  containerDef.children = containerChildren;
8570
8572
  await this._invokeAllAsync(function(ext) {
8571
- ext.writeNode && ext.writeNode(object2, containerDef);
8573
+ ext.writeNode && ext.writeNode(object3, containerDef);
8572
8574
  });
8573
8575
  return containerIndex;
8574
8576
  }
@@ -9011,10 +9013,10 @@ var GLTFMeshGpuInstancing = class {
9011
9013
  this.writer = writer;
9012
9014
  this.name = "EXT_mesh_gpu_instancing";
9013
9015
  }
9014
- writeNode(object2, nodeDef) {
9015
- if (!object2.isInstancedMesh) return;
9016
+ writeNode(object3, nodeDef) {
9017
+ if (!object3.isInstancedMesh) return;
9016
9018
  const writer = this.writer;
9017
- const mesh = object2;
9019
+ const mesh = object3;
9018
9020
  const translationAttr = new Float32Array(mesh.count * 3);
9019
9021
  const rotationAttr = new Float32Array(mesh.count * 4);
9020
9022
  const scaleAttr = new Float32Array(mesh.count * 3);
@@ -9204,8 +9206,8 @@ var SceneExporter = class {
9204
9206
  }
9205
9207
  }
9206
9208
  };
9207
- function localMatrix(object2) {
9208
- return object2.matrixAutoUpdate ? new import_three19.Matrix4().compose(object2.position, object2.quaternion, object2.scale) : object2.matrix.clone();
9209
+ function localMatrix(object3) {
9210
+ return object3.matrixAutoUpdate ? new import_three19.Matrix4().compose(object3.position, object3.quaternion, object3.scale) : object3.matrix.clone();
9209
9211
  }
9210
9212
  function createSnapshot(root, gltf, bakeColors = false) {
9211
9213
  const scene = new import_three19.Scene();
@@ -9309,24 +9311,24 @@ function createSnapshot(root, gltf, bakeColors = false) {
9309
9311
  scene.add(copy);
9310
9312
  }
9311
9313
  };
9312
- const visit = (object2, parentWorld) => {
9313
- if (!object2.visible) return;
9314
- const world = parentWorld.clone().multiply(localMatrix(object2));
9315
- const mesh = object2;
9314
+ const visit = (object3, parentWorld) => {
9315
+ if (!object3.visible) return;
9316
+ const world = parentWorld.clone().multiply(localMatrix(object3));
9317
+ const mesh = object3;
9316
9318
  if (mesh.isMesh) {
9317
9319
  const instanced = mesh;
9318
9320
  if (instanced.isInstancedMesh) {
9319
9321
  for (let i = 0; i < instanced.count; i++) {
9320
9322
  const matrix = new import_three19.Matrix4();
9321
9323
  instanced.getMatrixAt(i, matrix);
9322
- const color = instanced.instanceColor ? new import_three19.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
9323
- addMesh(mesh, world.clone().multiply(matrix), color);
9324
+ const color2 = instanced.instanceColor ? new import_three19.Color().fromBufferAttribute(instanced.instanceColor, i) : void 0;
9325
+ addMesh(mesh, world.clone().multiply(matrix), color2);
9324
9326
  }
9325
9327
  } else {
9326
9328
  addMesh(mesh, world);
9327
9329
  }
9328
9330
  }
9329
- for (const child of object2.children) visit(child, world);
9331
+ for (const child of object3.children) visit(child, world);
9330
9332
  };
9331
9333
  try {
9332
9334
  const ancestors = [];
@@ -9402,13 +9404,13 @@ init_AssetKey();
9402
9404
 
9403
9405
  // src/gui/GuiText.ts
9404
9406
  var import_three20 = require("three");
9405
- async function layoutGuiText(text, options = {}) {
9407
+ async function layoutGuiText(text2, options = {}) {
9406
9408
  const maxWidth = options.maxWidth ?? Infinity, lineHeight = options.lineHeight ?? 9;
9407
9409
  if (!(maxWidth > 0) || !Number.isFinite(lineHeight) || lineHeight <= 0) {
9408
9410
  throw new Error("Text wrap width and line height must be positive");
9409
9411
  }
9410
9412
  const font = await Fonts.get(options.font);
9411
- const runs = typeof text === "string" ? [{ text }] : text;
9413
+ const runs = typeof text2 === "string" ? [{ text: text2 }] : text2;
9412
9414
  const glyphs = [], lineWidths = [];
9413
9415
  let line = [], width = 0;
9414
9416
  let trailingNewline = false;
@@ -9462,7 +9464,7 @@ function createGuiTextGeometry(layout, shadow = true) {
9462
9464
  batch = { image: glyph?.image, positions: [], uvs: [], colors: [], indices: [] };
9463
9465
  batches.push(batch);
9464
9466
  }
9465
- const color = new import_three20.Color(isShadow ? (style.color & 16579836) >> 2 : style.color);
9467
+ const color2 = new import_three20.Color(isShadow ? (style.color & 16579836) >> 2 : style.color);
9466
9468
  const offset = isShadow ? 1 : 0;
9467
9469
  const top = glyph ? 7 - glyph.ascent : 0;
9468
9470
  const height = glyph ? glyph.height * glyph.scale : 8;
@@ -9490,7 +9492,7 @@ function createGuiTextGeometry(layout, shadow = true) {
9490
9492
  const v0 = glyph ? 1 - glyph.y / glyph.image.height : 1;
9491
9493
  const v1 = glyph ? 1 - (glyph.y + glyph.height) / glyph.image.height : 0;
9492
9494
  batch.uvs.push(u0, v0, u1, v0, u0, v1, u1, v1);
9493
- for (let i = 0; i < 4; i++) batch.colors.push(color.r, color.g, color.b);
9495
+ for (let i = 0; i < 4; i++) batch.colors.push(color2.r, color2.g, color2.b);
9494
9496
  batch.indices.push(base, base + 2, base + 1, base + 2, base + 3, base + 1);
9495
9497
  };
9496
9498
  for (const boldOffset of style.bold ? [0, 1] : [0]) {
@@ -9524,8 +9526,8 @@ var GuiHelper = class {
9524
9526
  size: [width + 24, height + 24]
9525
9527
  }));
9526
9528
  let y = position[1];
9527
- lines.forEach((text, index) => {
9528
- layers.push({ ...textOptions, name: `tooltip-line-${index}`, text, position: [position[0], y] });
9529
+ lines.forEach((text2, index) => {
9530
+ layers.push({ ...textOptions, name: `tooltip-line-${index}`, text: text2, position: [position[0], y] });
9529
9531
  y += layouts[index].height + (index === 0 ? titleGap : 0);
9530
9532
  });
9531
9533
  return layers;
@@ -9981,29 +9983,29 @@ var SceneInspector = class {
9981
9983
  this.objectControlsContainer.innerHTML = "";
9982
9984
  this.addControls(targetObject, targetIntersection, instance);
9983
9985
  }
9984
- addControls(object2, intersection, instance) {
9986
+ addControls(object3, intersection, instance) {
9985
9987
  const container = document.createElement("div");
9986
9988
  container.append(this.separator("Select Parent/Child"));
9987
- if (object2.parent) {
9988
- container.append(this.buttonControl("Select Parent " + object2.parent.constructor.name + " " + object2.parent.name, "P", () => {
9989
- this.selectObject(object2.parent, intersection, instance);
9989
+ if (object3.parent) {
9990
+ container.append(this.buttonControl("Select Parent " + object3.parent.constructor.name + " " + object3.parent.name, "P", () => {
9991
+ this.selectObject(object3.parent, intersection, instance);
9990
9992
  }));
9991
9993
  }
9992
- if (object2.children.length > 0) {
9994
+ if (object3.children.length > 0) {
9993
9995
  let i = 1;
9994
- for (let child of object2.children) {
9996
+ for (let child of object3.children) {
9995
9997
  container.append(this.buttonControl("Select Child " + child.constructor.name + " " + child.name, "C" + i++, () => {
9996
9998
  this.selectObject(child, intersection, instance);
9997
9999
  }));
9998
10000
  }
9999
10001
  }
10000
10002
  container.append(this.separator());
10001
- const selectedInstance = instance && (object2 === instance.instanceable || object2 === intersection?.object) ? instance : void 0;
10003
+ const selectedInstance = instance && (object3 === instance.instanceable || object3 === intersection?.object) ? instance : void 0;
10002
10004
  if (!selectedInstance) {
10003
- container.append(this.toggleControl("Visibility", "V", object2.visible, (v) => object2.visible = v));
10005
+ container.append(this.toggleControl("Visibility", "V", object3.visible, (v) => object3.visible = v));
10004
10006
  }
10005
10007
  container.append(this.separator("Mesh"));
10006
- this.addObjectControls(object2, intersection, container, selectedInstance);
10008
+ this.addObjectControls(object3, intersection, container, selectedInstance);
10007
10009
  container.append(this.separator());
10008
10010
  this.objectControlsContainer.append(container);
10009
10011
  }
@@ -10419,29 +10421,29 @@ var BlockTints = class {
10419
10421
  }
10420
10422
  }
10421
10423
  if (!indices.size) return tints;
10422
- let color;
10424
+ let color2;
10423
10425
  switch (rule.source) {
10424
10426
  case "constant":
10425
- color = rule.color;
10427
+ color2 = rule.color;
10426
10428
  break;
10427
10429
  case "grass":
10428
- color = await Colormaps.grassColor(key);
10430
+ color2 = await Colormaps.grassColor(key);
10429
10431
  break;
10430
10432
  case "redstone": {
10431
10433
  const power = Number(state.power ?? 0) / 15;
10432
10434
  const red = power * 0.6 + (power > 0 ? 0.4 : 0.3);
10433
10435
  const green = Math.max(0, power * power * 0.7 - 0.5);
10434
10436
  const blue = Math.max(0, power * power * 0.6 - 0.7);
10435
- color = Math.floor(red * 255) << 16 | Math.floor(green * 255) << 8 | Math.floor(blue * 255);
10437
+ color2 = Math.floor(red * 255) << 16 | Math.floor(green * 255) << 8 | Math.floor(blue * 255);
10436
10438
  break;
10437
10439
  }
10438
10440
  case "stem": {
10439
10441
  const age = Number(state.age ?? 0);
10440
- color = age * 32 << 16 | 255 - age * 8 << 8 | age * 4;
10442
+ color2 = age * 32 << 16 | 255 - age * 8 << 8 | age * 4;
10441
10443
  break;
10442
10444
  }
10443
10445
  }
10444
- return { ...Object.fromEntries([...indices].map((index) => [index, color])), ...tints };
10446
+ return { ...Object.fromEntries([...indices].map((index) => [index, color2])), ...tints };
10445
10447
  }
10446
10448
  };
10447
10449
 
@@ -10578,8 +10580,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
10578
10580
  return false;
10579
10581
  }
10580
10582
  return this._models.some((model) => {
10581
- const object2 = isInstanceReference(model) ? model.instanceable : model;
10582
- return object2.isOpaqueFullCube && this.getModelCullMask(model, 63) === 63;
10583
+ const object3 = isInstanceReference(model) ? model.instanceable : model;
10584
+ return object3.isOpaqueFullCube && this.getModelCullMask(model, 63) === 63;
10583
10585
  });
10584
10586
  }
10585
10587
  getModelMatrix(model) {
@@ -10588,8 +10590,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
10588
10590
  return model.matrix.clone();
10589
10591
  }
10590
10592
  getModelCullMask(model, worldMask) {
10591
- const object2 = isInstanceReference(model) ? model.instanceable : model;
10592
- if (object2.options.displayPosition) return 0;
10593
+ const object3 = isInstanceReference(model) ? model.instanceable : model;
10594
+ if (object3.options.displayPosition) return 0;
10593
10595
  const position = new import_three32.Vector3();
10594
10596
  const rotation = new import_three32.Quaternion();
10595
10597
  const scale = new import_three32.Vector3();
@@ -10606,14 +10608,14 @@ var _BlockObject = class _BlockObject extends SceneObject {
10606
10608
  replacements.push(model);
10607
10609
  continue;
10608
10610
  }
10609
- const object2 = isInstanceReference(model) ? model.instanceable : model;
10611
+ const object3 = isInstanceReference(model) ? model.instanceable : model;
10610
10612
  const cullMask = this.getModelCullMask(model, worldMask);
10611
- if (cullMask === (object2.options.cullMask ?? 0)) {
10613
+ if (cullMask === (object3.options.cullMask ?? 0)) {
10612
10614
  replacements.push(model);
10613
10615
  continue;
10614
10616
  }
10615
10617
  const matrix = this.getModelMatrix(model);
10616
- const replacement = await this.scene.addModel(object2.originalModel, { ...object2.options, cullMask });
10618
+ const replacement = await this.scene.addModel(object3.originalModel, { ...object3.options, cullMask });
10617
10619
  replacements.push(replacement);
10618
10620
  if (isInstanceReference(replacement)) {
10619
10621
  replacement.setMatrix(matrix);
@@ -10621,8 +10623,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
10621
10623
  replacement.matrix.copy(matrix);
10622
10624
  replacement.matrixWorldNeedsUpdate = true;
10623
10625
  matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
10624
- replacement.matrixAutoUpdate = object2.matrixAutoUpdate;
10625
- replacement.visible = object2.visible;
10626
+ replacement.matrixAutoUpdate = object3.matrixAutoUpdate;
10627
+ replacement.visible = object3.visible;
10626
10628
  }
10627
10629
  }
10628
10630
  } catch (error) {
@@ -13770,60 +13772,60 @@ var _MineRenderScene = class _MineRenderScene extends import_three34.Scene {
13770
13772
  this.options = (0, import_ts_deepmerge8.default)({}, _MineRenderScene.DEFAULT_OPTIONS, options ?? {});
13771
13773
  }
13772
13774
  add(...objects) {
13773
- for (const object2 of objects) {
13775
+ for (const object3 of objects) {
13774
13776
  this.dirty = true;
13775
13777
  try {
13776
- super.add(object2);
13778
+ super.add(object3);
13777
13779
  } finally {
13778
- if (object2?.isObject3D && object2 !== this) {
13779
- this.updateObjectRegistration(object2, object2.parent === this);
13780
+ if (object3?.isObject3D && object3 !== this) {
13781
+ this.updateObjectRegistration(object3, object3.parent === this);
13780
13782
  }
13781
13783
  }
13782
13784
  }
13783
13785
  return this;
13784
13786
  }
13785
13787
  remove(...objects) {
13786
- for (const object2 of objects) {
13787
- if (!this.children.includes(object2)) continue;
13788
+ for (const object3 of objects) {
13789
+ if (!this.children.includes(object3)) continue;
13788
13790
  this.dirty = true;
13789
- this.updateObjectRegistration(object2, false);
13791
+ this.updateObjectRegistration(object3, false);
13790
13792
  try {
13791
- super.remove(object2);
13793
+ super.remove(object3);
13792
13794
  } finally {
13793
- this.updateObjectRegistration(object2, object2.parent === this);
13795
+ this.updateObjectRegistration(object3, object3.parent === this);
13794
13796
  }
13795
13797
  }
13796
13798
  return this;
13797
13799
  }
13798
- updateObjectRegistration(object2, attached) {
13799
- if (this.observedObjects.has(object2) === attached) return;
13800
- const observable = object2;
13800
+ updateObjectRegistration(object3, attached) {
13801
+ if (this.observedObjects.has(object3) === attached) return;
13802
+ const observable = object3;
13801
13803
  if (attached) {
13802
- this.observedObjects.add(object2);
13804
+ this.observedObjects.add(object3);
13803
13805
  observable.addEventListener("change", this.onObjectChange);
13804
13806
  } else {
13805
- this.observedObjects.delete(object2);
13807
+ this.observedObjects.delete(object3);
13806
13808
  observable.removeEventListener("change", this.onObjectChange);
13807
13809
  }
13808
13810
  const change = attached ? 1 : -1;
13809
13811
  this.stats.objectCount += change;
13810
- if (isSceneObject(object2)) {
13812
+ if (isSceneObject(object3)) {
13811
13813
  this.stats.sceneObjectCount += change;
13812
13814
  }
13813
13815
  }
13814
13816
  /** Initializes each object before attaching it to the scene. */
13815
- async initAndAdd(...object2) {
13817
+ async initAndAdd(...object3) {
13816
13818
  this.dirty = true;
13817
- for (let obj of object2) {
13819
+ for (let obj of object3) {
13818
13820
  await obj.init();
13819
13821
  }
13820
- return this.add(...object2);
13822
+ return this.add(...object3);
13821
13823
  }
13822
- async addSceneObject(asset, objectSupplier, _options, parent = this) {
13824
+ async addSceneObject(asset2, objectSupplier, _options, parent = this) {
13823
13825
  this.dirty = true;
13824
13826
  const obj = await objectSupplier();
13825
- if (obj?.options?.instanceMeshes && asset.key && asset.key?.assetType === "models") {
13826
- let key = asset.key.serialize();
13827
+ if (obj?.options?.instanceMeshes && asset2.key && asset2.key?.assetType === "models") {
13828
+ let key = asset2.key.serialize();
13827
13829
  if (isModelObject(obj)) {
13828
13830
  const { displayPosition, uvLockRotation, tints, cullMask } = obj.options;
13829
13831
  if (displayPosition) key += `|display:${displayPosition}`;
@@ -13923,11 +13925,11 @@ var _changeEvent = { type: "change" };
13923
13925
  var _startEvent = { type: "start" };
13924
13926
  var _endEvent = { type: "end" };
13925
13927
  var OrbitControls = class extends import_three35.EventDispatcher {
13926
- constructor(object2, domElement) {
13928
+ constructor(object3, domElement) {
13927
13929
  super();
13928
13930
  if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
13929
13931
  if (domElement === document) console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
13930
- this.object = object2;
13932
+ this.object = object3;
13931
13933
  this.domElement = domElement;
13932
13934
  this.domElement.style.touchAction = "none";
13933
13935
  this.enabled = true;
@@ -13984,7 +13986,7 @@ var OrbitControls = class extends import_three35.EventDispatcher {
13984
13986
  };
13985
13987
  this.update = function() {
13986
13988
  const offset = new import_three35.Vector3();
13987
- const quat = new import_three35.Quaternion().setFromUnitVectors(object2.up, new import_three35.Vector3(0, 1, 0));
13989
+ const quat = new import_three35.Quaternion().setFromUnitVectors(object3.up, new import_three35.Vector3(0, 1, 0));
13988
13990
  const quatInverse = quat.clone().invert();
13989
13991
  const lastPosition = new import_three35.Vector3();
13990
13992
  const lastQuaternion = new import_three35.Quaternion();
@@ -14549,8 +14551,8 @@ var OrbitControls = class extends import_three35.EventDispatcher {
14549
14551
  }
14550
14552
  };
14551
14553
  var MapControls = class extends OrbitControls {
14552
- constructor(object2, domElement) {
14553
- super(object2, domElement);
14554
+ constructor(object3, domElement) {
14555
+ super(object3, domElement);
14554
14556
  this.screenSpacePanning = false;
14555
14557
  this.mouseButtons.LEFT = import_three35.MOUSE.PAN;
14556
14558
  this.mouseButtons.RIGHT = import_three35.MOUSE.ROTATE;
@@ -14978,6 +14980,232 @@ init_SceneObject();
14978
14980
  // src/index.ts
14979
14981
  init_request();
14980
14982
 
14983
+ // src/scene/SceneDocument.ts
14984
+ init_DisplayPosition();
14985
+ function fail(path, message) {
14986
+ throw new Error(`${path}: ${message}`);
14987
+ }
14988
+ function object2(value, path) {
14989
+ if (!value || typeof value !== "object" || Array.isArray(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail(path, "expected a JSON object");
14990
+ for (const key of Object.keys(value)) {
14991
+ if (["__proto__", "prototype", "constructor"].includes(key)) fail(`${path}.${key}`, "unsupported property");
14992
+ }
14993
+ return value;
14994
+ }
14995
+ function fields(value, path, allowed, required = []) {
14996
+ const input = object2(value, path);
14997
+ for (const key of required) if (input[key] === void 0) fail(`${path}.${key}`, "required");
14998
+ for (const [key, entry] of Object.entries(input)) {
14999
+ if (!Object.prototype.hasOwnProperty.call(allowed, key)) fail(`${path}.${key}`, "unsupported property");
15000
+ if (entry !== void 0) allowed[key](entry, `${path}.${key}`);
15001
+ }
15002
+ return input;
15003
+ }
15004
+ var text = (value, path) => {
15005
+ if (typeof value !== "string" || !value.trim()) fail(path, "expected a nonempty string");
15006
+ };
15007
+ var literalText = (value, path) => {
15008
+ if (typeof value !== "string") fail(path, "expected a string");
15009
+ };
15010
+ var boolean = (value, path) => {
15011
+ if (typeof value !== "boolean") fail(path, "expected a boolean");
15012
+ };
15013
+ var number = (value, path) => {
15014
+ if (typeof value !== "number" || !Number.isFinite(value)) fail(path, "expected a finite number");
15015
+ };
15016
+ var positive = (value, path) => {
15017
+ number(value, path);
15018
+ if (value <= 0) fail(path, "expected a positive number");
15019
+ };
15020
+ var nonnegative = (value, path) => {
15021
+ number(value, path);
15022
+ if (value < 0) fail(path, "expected a nonnegative number");
15023
+ };
15024
+ var color = (value, path) => {
15025
+ number(value, path);
15026
+ if (!Number.isInteger(value) || value < 0 || value > 16777215) {
15027
+ fail(path, "expected an RGB integer from 0 to 16777215");
15028
+ }
15029
+ };
15030
+ var asset = (value, path) => {
15031
+ text(value, path);
15032
+ if (!/^(?:[a-z0-9_.-]+:)?[a-z0-9_./-]+$/.test(value) || value.split(/[:/]/).some((part) => !part || part === "." || part === "..")) {
15033
+ fail(path, "expected a resource ID such as minecraft:stone");
15034
+ }
15035
+ };
15036
+ var version = (value, path) => {
15037
+ text(value, path);
15038
+ if (!/^[a-zA-Z0-9._-]+$/.test(value)) fail(path, "expected a Minecraft version without slashes");
15039
+ };
15040
+ var tuple = (size, item = number) => (value, path) => {
15041
+ if (!Array.isArray(value) || value.length !== size) fail(path, `expected ${size} numbers`);
15042
+ for (let index = 0; index < size; index++) item(value[index], `${path}[${index}]`);
15043
+ };
15044
+ var list = (item) => (value, path) => {
15045
+ if (!Array.isArray(value)) fail(path, "expected an array");
15046
+ for (let index = 0; index < value.length; index++) item(value[index], `${path}[${index}]`);
15047
+ };
15048
+ var dictionary = (item, numericKeys = false) => (value, path) => {
15049
+ for (const [key, entry] of Object.entries(object2(value, path))) {
15050
+ if (numericKeys && !/^\d+$/.test(key)) fail(`${path}.${key}`, "expected a nonnegative tint index");
15051
+ item(entry, `${path}.${key}`);
15052
+ }
15053
+ };
15054
+ var enumeration = (values) => (value, path) => {
15055
+ if (!values.includes(value)) fail(path, `expected one of: ${values.join(", ")}`);
15056
+ };
15057
+ var textStyle = { color, bold: boolean, italic: boolean };
15058
+ function guiLayer(value, path) {
15059
+ const layer = object2(value, path);
15060
+ if (["texture", "item", "text"].filter((key) => layer[key] !== void 0).length !== 1) {
15061
+ fail(path, "expected exactly one of texture, item, or text");
15062
+ }
15063
+ const layout = { name: text, position: tuple(2), size: tuple(2, positive) };
15064
+ if (layer.texture !== void 0) {
15065
+ fields(value, path, { ...layout, texture: asset, crop: (value2, path2) => {
15066
+ tuple(4)(value2, path2);
15067
+ const [x, y, width, height] = value2;
15068
+ nonnegative(x, `${path2}[0]`);
15069
+ nonnegative(y, `${path2}[1]`);
15070
+ positive(width, `${path2}[2]`);
15071
+ positive(height, `${path2}[3]`);
15072
+ } });
15073
+ } else if (layer.item !== void 0) {
15074
+ fields(value, path, { ...layout, item: asset, tints: dictionary(color, true) });
15075
+ } else {
15076
+ fields(value, path, {
15077
+ ...layout,
15078
+ ...textStyle,
15079
+ font: asset,
15080
+ shadow: boolean,
15081
+ maxWidth: positive,
15082
+ lineHeight: positive,
15083
+ text: (value2, path2) => {
15084
+ if (typeof value2 === "string") return;
15085
+ list((run, path3) => {
15086
+ fields(run, path3, { text: literalText, ...textStyle }, ["text"]);
15087
+ })(value2, path2);
15088
+ }
15089
+ });
15090
+ }
15091
+ }
15092
+ function validateObject(value, path) {
15093
+ const input = object2(value, path);
15094
+ const common = { id: text, name: text, type: text, position: tuple(3), rotation: tuple(3), scale: tuple(3), visible: boolean };
15095
+ const required = ["id", "type"];
15096
+ const renderOptions = { wireframe: boolean };
15097
+ switch (input.type) {
15098
+ case "skin":
15099
+ fields(value, path, {
15100
+ ...common,
15101
+ skin: text,
15102
+ cape: (value2, path2) => {
15103
+ fields(value2, path2, { texture: text, layout: enumeration(["minecraft", "optifine", "labymod"]) }, ["texture"]);
15104
+ },
15105
+ hiddenParts: list(enumeration(SKIN_PARTS)),
15106
+ pose: (value2, path2) => {
15107
+ fields(value2, path2, {
15108
+ head: tuple(3),
15109
+ body: tuple(3),
15110
+ rightArm: tuple(3),
15111
+ leftArm: tuple(3),
15112
+ rightLeg: tuple(3),
15113
+ leftLeg: tuple(3),
15114
+ cape: tuple(3)
15115
+ });
15116
+ },
15117
+ options: (value2, path2) => {
15118
+ fields(value2, path2, { slim: boolean, legacy: boolean });
15119
+ }
15120
+ }, required);
15121
+ break;
15122
+ case "block":
15123
+ fields(value, path, {
15124
+ ...common,
15125
+ asset,
15126
+ state: dictionary(text),
15127
+ options: (value2, path2) => {
15128
+ fields(value2, path2, { ...renderOptions, tints: dictionary(color, true) });
15129
+ }
15130
+ }, [...required, "asset"]);
15131
+ break;
15132
+ case "item":
15133
+ case "model":
15134
+ fields(value, path, {
15135
+ ...common,
15136
+ asset,
15137
+ options: (value2, path2) => {
15138
+ fields(value2, path2, { ...renderOptions, displayPosition: enumeration(DISPLAY_POSITIONS), tints: dictionary(color, true) });
15139
+ }
15140
+ }, [...required, "asset"]);
15141
+ break;
15142
+ case "entity":
15143
+ fields(value, path, {
15144
+ ...common,
15145
+ asset,
15146
+ texture: asset,
15147
+ layers: list(text),
15148
+ when: list(text),
15149
+ textures: dictionary(asset),
15150
+ options: (value2, path2) => {
15151
+ fields(value2, path2, {
15152
+ ...renderOptions,
15153
+ flip: boolean,
15154
+ tints: dictionary((value3, path3) => {
15155
+ typeof value3 === "string" ? text(value3, path3) : color(value3, path3);
15156
+ })
15157
+ });
15158
+ },
15159
+ animation: (value2, path2) => {
15160
+ fields(value2, path2, { name: text, loop: boolean, speed: nonnegative, time: nonnegative, paused: boolean }, ["name"]);
15161
+ }
15162
+ }, [...required, "asset"]);
15163
+ if (Array.isArray(input.layers) && !input.layers.length) fail(`${path}.layers`, "expected at least one layer");
15164
+ break;
15165
+ case "gui":
15166
+ fields(value, path, { ...common, layers: list(guiLayer) }, [...required, "layers"]);
15167
+ break;
15168
+ default:
15169
+ fail(`${path}.type`, "expected skin, block, item, entity, model, or gui");
15170
+ }
15171
+ }
15172
+ function parseSceneDocument(value) {
15173
+ if (typeof value === "string") {
15174
+ try {
15175
+ value = JSON.parse(value);
15176
+ } catch {
15177
+ fail("scene", "invalid JSON");
15178
+ }
15179
+ }
15180
+ const input = fields(value, "scene", {
15181
+ format: enumeration(["minerender-scene"]),
15182
+ version: (value2, path) => {
15183
+ if (value2 !== 1) fail(path, "only scene document version 1 is supported");
15184
+ },
15185
+ minecraftVersion: version,
15186
+ camera: (value2, path) => {
15187
+ fields(value2, path, { position: tuple(3), target: tuple(3) }, ["position", "target"]);
15188
+ },
15189
+ objects: list(validateObject)
15190
+ }, ["format", "version", "objects"]);
15191
+ const ids = /* @__PURE__ */ new Set();
15192
+ for (const [index, entry] of input.objects.entries()) {
15193
+ if (ids.has(entry.id)) fail(`scene.objects[${index}].id`, `duplicate object ID "${entry.id}"`);
15194
+ ids.add(entry.id);
15195
+ }
15196
+ return JSON.parse(JSON.stringify(input));
15197
+ }
15198
+
15199
+ // src/scene/SceneDocumentLoader.ts
15200
+ var import_three38 = require("three");
15201
+ init_AssetKey();
15202
+ init_AssetLoader();
15203
+ init_BlockStates();
15204
+ init_Entities();
15205
+ init_Models();
15206
+ init_DisplayPosition();
15207
+ init_SceneObject();
15208
+
14981
15209
  // src/skin/Skins.ts
14982
15210
  init_Requests();
14983
15211
  var Skins = class {
@@ -15148,6 +15376,195 @@ var Skins = class {
15148
15376
  //</editor-fold>
15149
15377
  };
15150
15378
 
15379
+ // src/scene/SceneDocumentLoader.ts
15380
+ var DocumentObjectScene = class extends MineRenderScene {
15381
+ async addSceneObject(_asset, supplier, _options, parent = this) {
15382
+ const object3 = await supplier();
15383
+ return this.initialize(object3, parent);
15384
+ }
15385
+ async initialize(object3, parent = this) {
15386
+ object3.scene = this;
15387
+ try {
15388
+ await object3.init();
15389
+ parent.add(object3);
15390
+ return object3;
15391
+ } catch (error) {
15392
+ object3.dispose();
15393
+ object3.removeFromParent();
15394
+ throw error;
15395
+ }
15396
+ }
15397
+ dispose() {
15398
+ for (const child of [...this.children]) {
15399
+ if (child.parent !== this) continue;
15400
+ if (isSceneObject(child)) child.dispose();
15401
+ child.removeFromParent();
15402
+ }
15403
+ }
15404
+ };
15405
+ async function skinTexture(value, cape = false) {
15406
+ if (!/^[a-zA-Z0-9_-]{1,36}$/.test(value)) return value;
15407
+ const texture = await (cape ? Skins.capeFromUuidOrUsername(value) : Skins.fromUuidOrUsername(value));
15408
+ if (!texture) throw new Error(`Could not find ${cape ? "cape" : "skin"} for "${value}"`);
15409
+ return texture;
15410
+ }
15411
+ var SceneDocumentLoader = class {
15412
+ static parse(value) {
15413
+ return parseSceneDocument(value);
15414
+ }
15415
+ /**
15416
+ * Loads objects concurrently and attaches them in document order after every load succeeds.
15417
+ * A failure waits for all loads, disposes staged objects, and reports the first error in document order.
15418
+ */
15419
+ static async load(scene, value, parent = scene) {
15420
+ const definition = this.parse(value);
15421
+ if (definition.minecraftVersion !== void 0 && definition.minecraftVersion !== AssetLoader.version) {
15422
+ throw new Error(`Scene requires Minecraft ${definition.minecraftVersion}; call AssetLoader.setVersion("${definition.minecraftVersion}") before loading it`);
15423
+ }
15424
+ const root = new import_three38.Group();
15425
+ root.name = "MineRender scene document";
15426
+ const objects = [];
15427
+ let disposed = false;
15428
+ const loaded = {
15429
+ root,
15430
+ objects,
15431
+ definition,
15432
+ advanceAnimations: (delta) => {
15433
+ if (!disposed) for (const object3 of objects) object3.advanceAnimation(delta);
15434
+ },
15435
+ dispose: () => {
15436
+ if (disposed) return;
15437
+ disposed = true;
15438
+ root.removeFromParent();
15439
+ for (const object3 of objects) object3.dispose();
15440
+ root.clear();
15441
+ scene.dirty = true;
15442
+ }
15443
+ };
15444
+ try {
15445
+ const results = await Promise.allSettled(definition.objects.map((object3) => this.loadValidatedObject(scene, object3)));
15446
+ for (const result of results) if (result.status === "fulfilled") objects.push(result.value);
15447
+ const failure = results.find((result) => result.status === "rejected");
15448
+ if (failure) throw failure.reason;
15449
+ for (const object3 of objects) root.add(object3.root);
15450
+ parent.add(root);
15451
+ scene.dirty = true;
15452
+ return loaded;
15453
+ } catch (error) {
15454
+ loaded.dispose();
15455
+ throw error;
15456
+ }
15457
+ }
15458
+ /** Loads an independently editable object. Its root owns the document's position, rotation, and scale. */
15459
+ static async loadObject(scene, value, parent = scene) {
15460
+ const definition = this.parse({ format: "minerender-scene", version: 1, objects: [value] }).objects[0];
15461
+ return this.loadValidatedObject(scene, definition, parent);
15462
+ }
15463
+ static async loadValidatedObject(scene, definition, parent) {
15464
+ const root = new import_three38.Group();
15465
+ root.name = definition.name ?? definition.id;
15466
+ root.userData.sceneObjectId = definition.id;
15467
+ root.position.fromArray(definition.position ?? [0, 0, 0]);
15468
+ root.rotation.set(...definition.rotation ?? [0, 0, 0]);
15469
+ root.scale.fromArray(definition.scale ?? [1, 1, 1]);
15470
+ root.visible = definition.visible ?? true;
15471
+ const content = new DocumentObjectScene();
15472
+ root.add(content);
15473
+ let object3;
15474
+ try {
15475
+ switch (definition.type) {
15476
+ case "skin": {
15477
+ const skin = new SkinObject({ ...definition.options, instanceMeshes: false });
15478
+ object3 = skin;
15479
+ const texture = definition.skin ? await skinTexture(definition.skin) : `${AssetLoader.ROOT}/assets/minecraft/textures/entity/player/${definition.options?.slim ? "slim/alex" : "wide/steve"}.png`;
15480
+ await skin.setSkinTexture(texture);
15481
+ await content.initialize(skin);
15482
+ if (definition.cape) await skin.setCapeTexture(await skinTexture(definition.cape.texture, true), definition.cape.layout);
15483
+ for (const [part, rotation] of Object.entries(definition.pose ?? {})) {
15484
+ skin.getGroupByName(part)?.rotation.set(...rotation, "XYZ");
15485
+ }
15486
+ for (const part of definition.hiddenParts ?? []) {
15487
+ const mesh = skin.getMeshByName(part);
15488
+ if (mesh) mesh.visible = false;
15489
+ }
15490
+ break;
15491
+ }
15492
+ case "block": {
15493
+ const state = await BlockStates.get(AssetKey.parse("blockstates", definition.asset));
15494
+ if (!state) throw new Error(`Could not load block ${definition.asset}`);
15495
+ object3 = await content.addBlock(state, { ...definition.options, initialState: definition.state, instanceMeshes: false });
15496
+ break;
15497
+ }
15498
+ case "item":
15499
+ case "model": {
15500
+ let key = AssetKey.parse("models", definition.asset);
15501
+ if (definition.type === "item" && key.type !== "item") {
15502
+ key = new AssetKey(key.namespace, key.getFullPath(), "models", "item");
15503
+ }
15504
+ const model = await Models.getMerged(key);
15505
+ if (!model) throw new Error(`Could not load ${definition.type} ${definition.asset}`);
15506
+ object3 = await content.addModel(model, {
15507
+ ...definition.type === "item" ? { displayPosition: "gui" /* GUI */ } : {},
15508
+ ...definition.options,
15509
+ instanceMeshes: false
15510
+ });
15511
+ break;
15512
+ }
15513
+ case "entity": {
15514
+ const key = AssetKey.parse("entity-models", definition.asset);
15515
+ const model = await Entities.getEntity(key, definition.texture ? AssetKey.parse("textures", definition.texture) : void 0, {
15516
+ layers: definition.layers,
15517
+ when: definition.when,
15518
+ textures: definition.textures && Object.fromEntries(Object.entries(definition.textures).map(([name, texture]) => [name, AssetKey.parse("textures", texture)]))
15519
+ });
15520
+ if (!model) throw new Error(`Could not load entity ${definition.asset}`);
15521
+ const entity = await content.addEntity(model, { ...definition.options, instanceMeshes: false });
15522
+ object3 = entity;
15523
+ if (definition.animation) {
15524
+ const animations = await Entities.getAnimations(key);
15525
+ const clip = animations?.[definition.animation.name];
15526
+ if (!clip) throw new Error(`Entity ${definition.asset} has no animation "${definition.animation.name}"`);
15527
+ entity.playAnimation(clip, definition.animation);
15528
+ }
15529
+ break;
15530
+ }
15531
+ case "gui":
15532
+ object3 = await content.initialize(new GuiObject(definition.layers));
15533
+ break;
15534
+ }
15535
+ let disposed = false;
15536
+ const loaded = {
15537
+ root,
15538
+ object: object3,
15539
+ definition,
15540
+ advanceAnimation: (delta) => {
15541
+ if (!disposed && definition.type === "entity" && !definition.animation?.paused) object3.advanceAnimation(delta);
15542
+ },
15543
+ dispose: () => {
15544
+ if (disposed) return;
15545
+ disposed = true;
15546
+ root.removeFromParent();
15547
+ object3.dispose();
15548
+ object3.removeFromParent();
15549
+ content.dispose();
15550
+ root.clear();
15551
+ scene.dirty = true;
15552
+ }
15553
+ };
15554
+ parent?.add(root);
15555
+ scene.dirty = true;
15556
+ return loaded;
15557
+ } catch (error) {
15558
+ object3?.dispose();
15559
+ object3?.removeFromParent();
15560
+ content.dispose();
15561
+ root.removeFromParent();
15562
+ root.clear();
15563
+ throw new Error(`Scene object "${definition.name ?? definition.id}": ${error instanceof Error ? error.message : String(error)}`);
15564
+ }
15565
+ }
15566
+ };
15567
+
15151
15568
  // src/texture/index.ts
15152
15569
  init_Colormaps();
15153
15570
  init_TextureAtlas();
@@ -15429,12 +15846,12 @@ var AnvilParser = class {
15429
15846
  };
15430
15847
 
15431
15848
  // src/world/Chunk.ts
15432
- var import_three41 = require("three");
15849
+ var import_three42 = require("three");
15433
15850
  init_BlockStates();
15434
15851
  init_AssetKey();
15435
15852
 
15436
15853
  // src/world/MineRenderWorld.ts
15437
- var import_three39 = require("three");
15854
+ var import_three40 = require("three");
15438
15855
  init_Model();
15439
15856
  init_BatchedExecutor();
15440
15857
  init_AssetKey();
@@ -15442,7 +15859,7 @@ init_BlockStates();
15442
15859
  init_CubeFace();
15443
15860
 
15444
15861
  // src/world/SectionModels.ts
15445
- var import_three38 = require("three");
15862
+ var import_three39 = require("three");
15446
15863
  init_AssetKey();
15447
15864
  init_Models();
15448
15865
  init_CubeFace();
@@ -15501,20 +15918,20 @@ var SectionModels = class {
15501
15918
  if (!models) this.models.set(model, models = /* @__PURE__ */ new Map());
15502
15919
  const key = JSON.stringify([rotation.x, rotation.y, rotation.z, variant.uvlock, tints]);
15503
15920
  const template = await cached(models, key, async () => {
15504
- const object2 = new SectionModel(model, {
15921
+ const object3 = new SectionModel(model, {
15505
15922
  instanceMeshes: false,
15506
15923
  mergeMeshes: false,
15507
15924
  tints,
15508
15925
  uvLockRotation: variant.uvlock && (rotation.x !== 0 || rotation.y !== 0) ? [rotation.x, rotation.y, rotation.z] : void 0
15509
15926
  });
15510
- await object2.init();
15511
- const geometry = object2.children[0].geometry;
15512
- geometry.applyMatrix4(new import_three38.Matrix4().makeRotationFromEuler(rotation));
15513
- object2.clear();
15927
+ await object3.init();
15928
+ const geometry = object3.children[0].geometry;
15929
+ geometry.applyMatrix4(new import_three39.Matrix4().makeRotationFromEuler(rotation));
15930
+ object3.clear();
15514
15931
  const cullFaces = CUBE_FACES.map((face) => {
15515
15932
  const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
15516
15933
  if (local < 0) return 0;
15517
- const normal = new import_three38.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
15934
+ const normal = new import_three39.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
15518
15935
  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);
15519
15936
  return 1 << world;
15520
15937
  });
@@ -15545,20 +15962,20 @@ var MineRenderWorld = class {
15545
15962
  }
15546
15963
  getBlockAt(posOrX, y, z) {
15547
15964
  if (typeof posOrX == "number") {
15548
- return this.getBlockAt(new import_three39.Vector3(posOrX, y, z));
15965
+ return this.getBlockAt(new import_three40.Vector3(posOrX, y, z));
15549
15966
  }
15550
15967
  if (isTripleArray(posOrX)) {
15551
- return this.getBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]));
15968
+ return this.getBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]));
15552
15969
  }
15553
15970
  this.validatePosBounds(posOrX);
15554
15971
  return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
15555
15972
  }
15556
15973
  async setBlockAt(posOrX, yOrBlock, z, block) {
15557
15974
  if (typeof posOrX == "number") {
15558
- return this.setBlockAt(new import_three39.Vector3(posOrX, yOrBlock, z), block);
15975
+ return this.setBlockAt(new import_three40.Vector3(posOrX, yOrBlock, z), block);
15559
15976
  }
15560
15977
  if (isTripleArray(posOrX)) {
15561
- return this.setBlockAt(new import_three39.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
15978
+ return this.setBlockAt(new import_three40.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
15562
15979
  }
15563
15980
  return this.placeBlock(posOrX, yOrBlock);
15564
15981
  }
@@ -15569,10 +15986,10 @@ var MineRenderWorld = class {
15569
15986
  }
15570
15987
  async setBlockVisibleAt(posOrX, yOrVisible, z, visible) {
15571
15988
  if (typeof posOrX === "number") {
15572
- return this.setBlockVisibleAt(new import_three39.Vector3(posOrX, yOrVisible, z), visible);
15989
+ return this.setBlockVisibleAt(new import_three40.Vector3(posOrX, yOrVisible, z), visible);
15573
15990
  }
15574
15991
  if (isTripleArray(posOrX)) {
15575
- return this.setBlockVisibleAt(new import_three39.Vector3(...posOrX), yOrVisible);
15992
+ return this.setBlockVisibleAt(new import_three40.Vector3(...posOrX), yOrVisible);
15576
15993
  }
15577
15994
  this.validatePosBounds(posOrX);
15578
15995
  await this.getChunkAt(posOrX)?.setBlockVisibleAt(posOrX, yOrVisible);
@@ -15596,7 +16013,7 @@ var MineRenderWorld = class {
15596
16013
  const collect = async (positions2) => {
15597
16014
  for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
15598
16015
  };
15599
- const place = (block) => this.placeBlock(new import_three39.Vector3(...block.position), block, collect);
16016
+ const place = (block) => this.placeBlock(new import_three40.Vector3(...block.position), block, collect);
15600
16017
  const keys = /* @__PURE__ */ new Map();
15601
16018
  for (const block of multiblock.blocks) {
15602
16019
  if (Chunk.isAir(block)) continue;
@@ -15694,13 +16111,13 @@ var MineRenderWorld = class {
15694
16111
  for (const pos of positions) {
15695
16112
  this.pendingCulling.set(pos.toArray().join(","), pos.clone());
15696
16113
  for (const offset of CUBE_FACE_OFFSETS) {
15697
- const neighbor = pos.clone().add(new import_three39.Vector3(...offset));
16114
+ const neighbor = pos.clone().add(new import_three40.Vector3(...offset));
15698
16115
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
15699
16116
  }
15700
16117
  for (let y = -1; y <= 1; y++) {
15701
16118
  for (let z = -1; z <= 1; z++) {
15702
16119
  for (let x = -1; x <= 1; x++) {
15703
- const neighbor = pos.clone().add(new import_three39.Vector3(x, y, z));
16120
+ const neighbor = pos.clone().add(new import_three40.Vector3(x, y, z));
15704
16121
  if (this.getBlockAt(neighbor)?.object?.fluidKind) {
15705
16122
  this.pendingCulling.set(neighbor.toArray().join(","), neighbor);
15706
16123
  }
@@ -15724,19 +16141,19 @@ var MineRenderWorld = class {
15724
16141
  }
15725
16142
  if (block.object?.fluidKind) {
15726
16143
  await block.object.updateFluid((x, y, z) => {
15727
- const neighbor = pos.clone().add(new import_three39.Vector3(x, y, z));
16144
+ const neighbor = pos.clone().add(new import_three40.Vector3(x, y, z));
15728
16145
  const section = this.getChunkAt(neighbor);
15729
- const object2 = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
16146
+ const object3 = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
15730
16147
  return {
15731
- fluid: object2?.fluidKind,
15732
- level: object2?.fluidLevel,
16148
+ fluid: object3?.fluidKind,
16149
+ level: object3?.fluidLevel,
15733
16150
  solid: section?.isOccludingAt(neighbor) ?? false
15734
16151
  };
15735
16152
  });
15736
16153
  }
15737
16154
  let mask = 0;
15738
16155
  for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
15739
- const neighbor = pos.clone().add(new import_three39.Vector3(...offset));
16156
+ const neighbor = pos.clone().add(new import_three40.Vector3(...offset));
15740
16157
  if (this.getChunkAt(neighbor)?.isOccludingAt(neighbor)) {
15741
16158
  mask |= 1 << face;
15742
16159
  }
@@ -15772,7 +16189,7 @@ var MineRenderWorld = class {
15772
16189
  }
15773
16190
  /** Converts block coordinates to scene units by multiplying each component by 16. */
15774
16191
  static worldToScenePosition(pos) {
15775
- return new import_three39.Vector3(
16192
+ return new import_three40.Vector3(
15776
16193
  pos.x * 16,
15777
16194
  pos.y * 16,
15778
16195
  pos.z * 16
@@ -15780,7 +16197,7 @@ var MineRenderWorld = class {
15780
16197
  }
15781
16198
  /** Converts scene units to block coordinates without rounding to an integer block. */
15782
16199
  static sceneToWorldPosition(pos) {
15783
- return new import_three39.Vector3(
16200
+ return new import_three40.Vector3(
15784
16201
  pos.x / 16,
15785
16202
  pos.y / 16,
15786
16203
  pos.z / 16
@@ -15803,10 +16220,10 @@ var MineRenderWorld = class {
15803
16220
  init_Model();
15804
16221
 
15805
16222
  // src/world/SectionMesh.ts
15806
- var import_three40 = require("three");
16223
+ var import_three41 = require("three");
15807
16224
  init_CanvasCompat();
15808
16225
  init_Materials();
15809
- var SectionMesh = class _SectionMesh extends import_three40.Group {
16226
+ var SectionMesh = class _SectionMesh extends import_three41.Group {
15810
16227
  constructor() {
15811
16228
  super(...arguments);
15812
16229
  this.ownedMeshes = [];
@@ -15859,7 +16276,7 @@ var SectionMesh = class _SectionMesh extends import_three40.Group {
15859
16276
  const normal = template.geometry.getAttribute("normal");
15860
16277
  const uv = template.geometry.getAttribute("uv");
15861
16278
  const bounds = template.geometry.getAttribute("uvBounds");
15862
- const color = template.geometry.getAttribute("color");
16279
+ const color2 = template.geometry.getAttribute("color");
15863
16280
  const sourceIndices = template.geometry.getIndex();
15864
16281
  const placement = locations.get(template.atlas).placement;
15865
16282
  const mapU = (u) => (placement.x + u * template.atlas.image.width) / page.width;
@@ -15881,24 +16298,24 @@ var SectionMesh = class _SectionMesh extends import_three40.Group {
15881
16298
  mapU(bounds?.getZ(vertex) ?? 1),
15882
16299
  mapV(bounds?.getW(vertex) ?? 1)
15883
16300
  );
15884
- colors.push(color?.getX(vertex) ?? 1, color?.getY(vertex) ?? 1, color?.getZ(vertex) ?? 1);
16301
+ colors.push(color2?.getX(vertex) ?? 1, color2?.getY(vertex) ?? 1, color2?.getZ(vertex) ?? 1);
15885
16302
  }
15886
16303
  for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
15887
16304
  }
15888
16305
  }
15889
- const geometry = new import_three40.BufferGeometry();
15890
- geometry.setAttribute("position", new import_three40.Float32BufferAttribute(positions, 3));
15891
- geometry.setAttribute("normal", new import_three40.Float32BufferAttribute(normals, 3));
15892
- geometry.setAttribute("uv", new import_three40.Float32BufferAttribute(uvs, 2));
15893
- geometry.setAttribute("uvBounds", new import_three40.Float32BufferAttribute(uvBounds, 4));
15894
- geometry.setAttribute("color", new import_three40.Float32BufferAttribute(colors, 3));
16306
+ const geometry = new import_three41.BufferGeometry();
16307
+ geometry.setAttribute("position", new import_three41.Float32BufferAttribute(positions, 3));
16308
+ geometry.setAttribute("normal", new import_three41.Float32BufferAttribute(normals, 3));
16309
+ geometry.setAttribute("uv", new import_three41.Float32BufferAttribute(uvs, 2));
16310
+ geometry.setAttribute("uvBounds", new import_three41.Float32BufferAttribute(uvBounds, 4));
16311
+ geometry.setAttribute("color", new import_three41.Float32BufferAttribute(colors, 3));
15895
16312
  geometry.setIndex(indices);
15896
16313
  geometry.computeBoundingBox();
15897
16314
  geometry.computeBoundingSphere();
15898
16315
  const material = Materials.createShadedCanvasMaterial(canvas, false, false, true);
15899
16316
  material.vertexColors = true;
15900
16317
  const texture = material.uniforms?.map?.value ?? material.map;
15901
- const mesh = new import_three40.Mesh(geometry, material);
16318
+ const mesh = new import_three41.Mesh(geometry, material);
15902
16319
  section.add(mesh);
15903
16320
  section.ownedMeshes.push({ mesh, texture });
15904
16321
  }
@@ -15934,10 +16351,10 @@ var Chunk = class _Chunk {
15934
16351
  }
15935
16352
  getBlockAt(posOrX, y, z) {
15936
16353
  if (typeof posOrX == "number") {
15937
- return this.getBlockAt(new import_three41.Vector3(posOrX, y, z));
16354
+ return this.getBlockAt(new import_three42.Vector3(posOrX, y, z));
15938
16355
  }
15939
16356
  if (isTripleArray(posOrX)) {
15940
- return this.getBlockAt(new import_three41.Vector3(posOrX[0], posOrX[1], posOrX[2]));
16357
+ return this.getBlockAt(new import_three42.Vector3(posOrX[0], posOrX[1], posOrX[2]));
15941
16358
  }
15942
16359
  const pos = this.worldPosToChunkPos(posOrX);
15943
16360
  const index = _Chunk.chunkPosToBlockIndex(pos);
@@ -15945,10 +16362,10 @@ var Chunk = class _Chunk {
15945
16362
  }
15946
16363
  async setBlockAt(posOrX, yOrBlock, z, block) {
15947
16364
  if (typeof posOrX == "number") {
15948
- return this.setBlockAt(new import_three41.Vector3(posOrX, yOrBlock, z), block);
16365
+ return this.setBlockAt(new import_three42.Vector3(posOrX, yOrBlock, z), block);
15949
16366
  }
15950
16367
  if (isTripleArray(posOrX)) {
15951
- return this.setBlockAt(new import_three41.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
16368
+ return this.setBlockAt(new import_three42.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
15952
16369
  }
15953
16370
  const worldPos = posOrX;
15954
16371
  const pos = this.worldPosToChunkPos(worldPos);
@@ -15969,7 +16386,7 @@ var Chunk = class _Chunk {
15969
16386
  this.renderedBlocks.get(index)?.object?.removeFromScene();
15970
16387
  if (this.sectionBlocks.delete(index)) this.meshDirty = true;
15971
16388
  this.renderedBlocks.delete(index);
15972
- let object2;
16389
+ let object3;
15973
16390
  try {
15974
16391
  if (!readBlock) return void 0;
15975
16392
  const stored = readBlock();
@@ -15984,22 +16401,22 @@ var Chunk = class _Chunk {
15984
16401
  this.sectionBlocks.set(index, { index, template, cullMask: 0 });
15985
16402
  this.meshDirty = true;
15986
16403
  } else {
15987
- object2 = await this.scene.addBlock(blockState, {
16404
+ object3 = await this.scene.addBlock(blockState, {
15988
16405
  mergeMeshes: true,
15989
16406
  instanceMeshes: true,
15990
16407
  maxInstanceCount: 2e3,
15991
16408
  initialState: stored.properties
15992
16409
  });
15993
- object2.setPosition(MineRenderWorld.worldToScenePosition(worldPos));
16410
+ object3.setPosition(MineRenderWorld.worldToScenePosition(worldPos));
15994
16411
  }
15995
16412
  const info = { get block() {
15996
16413
  return readBlock();
15997
- }, object: object2 };
16414
+ }, object: object3 };
15998
16415
  this.renderedBlocks.set(index, info);
15999
16416
  return info;
16000
16417
  } catch (error) {
16001
16418
  this.data.set(index, void 0);
16002
- object2?.removeFromScene();
16419
+ object3?.removeFromScene();
16003
16420
  throw error;
16004
16421
  } finally {
16005
16422
  await onBlocksChanged?.([worldPos]);
@@ -16062,7 +16479,7 @@ var Chunk = class _Chunk {
16062
16479
  /** Removes stored blocks and their render objects, then notifies the owning world of changed positions. */
16063
16480
  async clear(onBlocksChanged = this.onBlocksChanged) {
16064
16481
  const positions = [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
16065
- new import_three41.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
16482
+ new import_three42.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
16066
16483
  ));
16067
16484
  for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
16068
16485
  this.sectionBlocks.clear();
@@ -16088,14 +16505,14 @@ var Chunk = class _Chunk {
16088
16505
  return pos.y * 16 * 16 + pos.z * 16 + pos.x;
16089
16506
  }
16090
16507
  worldPosToChunkPos(pos) {
16091
- return new import_three41.Vector3(
16508
+ return new import_three42.Vector3(
16092
16509
  pos.x - this.x * 16,
16093
16510
  pos.y - this.y * 16,
16094
16511
  pos.z - this.z * 16
16095
16512
  );
16096
16513
  }
16097
16514
  chunkPosToWorldPos(pos) {
16098
- return new import_three41.Vector3(
16515
+ return new import_three42.Vector3(
16099
16516
  this.x * 16 + pos.x,
16100
16517
  this.y * 16 + pos.y,
16101
16518
  this.z * 16 + pos.z