minerender 2.1.0-alpha.70 → 2.1.0-alpha.73

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.
@@ -749,7 +749,7 @@ var init_TextureLoader = __esm({
749
749
  static createTexture() {
750
750
  return new Texture();
751
751
  }
752
- static loadInBackground(src, format = RGBAFormat, rotation = 0) {
752
+ static loadInBackground(src, format2 = RGBAFormat, rotation = 0) {
753
753
  const texture = this.createTexture();
754
754
  texture.colorSpace = THREE.SRGBColorSpace;
755
755
  const image = ImageLoader.loadElement(src, () => {
@@ -759,11 +759,11 @@ var init_TextureLoader = __esm({
759
759
  console.warn("Failed to load texture", src, error);
760
760
  });
761
761
  texture.image = image;
762
- texture.format = format;
762
+ texture.format = format2;
763
763
  texture.rotation = rotation;
764
764
  return Textures.initTextureProps(texture);
765
765
  }
766
- static load(src, format = RGBAFormat, rotation = 0) {
766
+ static load(src, format2 = RGBAFormat, rotation = 0) {
767
767
  const texture = new Texture();
768
768
  texture.colorSpace = THREE.SRGBColorSpace;
769
769
  ImageLoader.getData(src).then((image) => {
@@ -773,7 +773,7 @@ var init_TextureLoader = __esm({
773
773
  this.failedTextures.add(texture);
774
774
  console.warn("Failed to load texture", src, error);
775
775
  });
776
- texture.format = format;
776
+ texture.format = format2;
777
777
  texture.rotation = rotation;
778
778
  return Textures.initTextureProps(texture);
779
779
  }
@@ -1703,6 +1703,10 @@ var init_AssetSource = __esm({
1703
1703
  AssetSource = class {
1704
1704
  constructor() {
1705
1705
  }
1706
+ /** Whether this source prevents lower-priority sources from supplying the key. Its own assets remain available. */
1707
+ blocks(key) {
1708
+ return false;
1709
+ }
1706
1710
  /**
1707
1711
  * Identifies this source's content across sessions for persistent caching. Sources that
1708
1712
  * cannot tell whether their content changed (an unnamed archive, for example) return
@@ -1882,10 +1886,10 @@ var NBTHelper;
1882
1886
  var init_NBTHelper = __esm({
1883
1887
  "src/nbt/NBTHelper.ts"() {
1884
1888
  NBTHelper = class {
1885
- static async fromBuffer(data, format) {
1889
+ static async fromBuffer(data, format2) {
1886
1890
  const buffer = Buffer3.from(data instanceof Uint8Array ? data : new Uint8Array(data));
1887
1891
  const prismarineNbt = await import("prismarine-nbt");
1888
- const { parsed, type, metadata } = await prismarineNbt.parse(buffer, format);
1892
+ const { parsed, type, metadata } = await prismarineNbt.parse(buffer, format2);
1889
1893
  return Object.assign(parsed, {
1890
1894
  format: type,
1891
1895
  metadata,
@@ -2119,6 +2123,162 @@ var init_BrowserArchiveProxy = __esm({
2119
2123
  }
2120
2124
  });
2121
2125
 
2126
+ // src/assets/source/archive/PackMetadata.ts
2127
+ function object(value, field) {
2128
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
2129
+ throw new Error(`Invalid ${field}: expected an object`);
2130
+ }
2131
+ return value;
2132
+ }
2133
+ function integer(value, field) {
2134
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
2135
+ throw new Error(`Invalid ${field}: expected a nonnegative integer`);
2136
+ }
2137
+ return value;
2138
+ }
2139
+ function format(value, field, upper = false) {
2140
+ const parts = Array.isArray(value) ? value : [value];
2141
+ if (parts.length < 1 || parts.length > 2) {
2142
+ throw new Error(`Invalid ${field}: expected a major version or [major, minor]`);
2143
+ }
2144
+ return [integer(parts[0], field), parts.length === 2 ? integer(parts[1], field) : upper ? Infinity : 0];
2145
+ }
2146
+ function compare(a, b) {
2147
+ return a[0] === b[0] ? a[1] - b[1] : a[0] - b[0];
2148
+ }
2149
+ function overlay(value, field) {
2150
+ const entry = object(value, field);
2151
+ const directory = entry.directory;
2152
+ if (typeof directory !== "string" || !directory || /[^-_a-zA-Z0-9.]/.test(directory) || directory === "." || directory === "..") {
2153
+ throw new Error(`Invalid ${field}.directory: expected a directory name without path separators`);
2154
+ }
2155
+ let min, max;
2156
+ if ("min_format" in entry || "max_format" in entry) {
2157
+ min = format(entry.min_format, `${field}.min_format`);
2158
+ max = format(entry.max_format, `${field}.max_format`, true);
2159
+ } else {
2160
+ const range = entry.formats;
2161
+ let lower, upper;
2162
+ if (typeof range === "number") {
2163
+ lower = upper = range;
2164
+ } else if (Array.isArray(range)) {
2165
+ if (range.length !== 2) throw new Error(`Invalid ${field}.formats: expected [min, max]`);
2166
+ [lower, upper] = range;
2167
+ } else {
2168
+ const bounds = object(range, `${field}.formats`);
2169
+ lower = bounds.min_inclusive;
2170
+ upper = bounds.max_inclusive;
2171
+ }
2172
+ min = [integer(lower, `${field}.formats.min_inclusive`), 0];
2173
+ max = [integer(upper, `${field}.formats.max_inclusive`), Infinity];
2174
+ }
2175
+ if (compare(min, max) > 0) throw new Error(`Invalid ${field}: minimum format exceeds maximum format`);
2176
+ return { directory, min, max };
2177
+ }
2178
+ function pattern(value, field) {
2179
+ if (value === void 0) return void 0;
2180
+ if (typeof value !== "string") throw new Error(`Invalid ${field}: expected a regular expression string`);
2181
+ try {
2182
+ return new RegExp(value);
2183
+ } catch (cause) {
2184
+ throw new Error(`Invalid ${field}: ${String(cause)}`);
2185
+ }
2186
+ }
2187
+ var PackMetadata;
2188
+ var init_PackMetadata = __esm({
2189
+ "src/assets/source/archive/PackMetadata.ts"() {
2190
+ PackMetadata = class _PackMetadata {
2191
+ constructor(overlays, filters) {
2192
+ this.overlays = overlays;
2193
+ this.filters = filters;
2194
+ this.hasOverlays = overlays.length > 0;
2195
+ }
2196
+ static parse(value) {
2197
+ const metadata = object(value, "pack.mcmeta");
2198
+ let overlays = [];
2199
+ if ("overlays" in metadata) {
2200
+ const entries = object(metadata.overlays, "overlays").entries;
2201
+ if (!Array.isArray(entries)) throw new Error("Invalid overlays.entries: expected an array");
2202
+ overlays = entries.map((entry, index) => overlay(entry, `overlays.entries[${index}]`));
2203
+ }
2204
+ let filters = [];
2205
+ if ("filter" in metadata) {
2206
+ const entries = object(metadata.filter, "filter").block;
2207
+ if (!Array.isArray(entries)) throw new Error("Invalid filter.block: expected an array");
2208
+ filters = entries.map((value2, index) => {
2209
+ const field = `filter.block[${index}]`;
2210
+ const entry = object(value2, field);
2211
+ return { namespace: pattern(entry.namespace, `${field}.namespace`), path: pattern(entry.path, `${field}.path`) };
2212
+ });
2213
+ }
2214
+ return new _PackMetadata(overlays, filters);
2215
+ }
2216
+ /** Returns applicable directories in lookup order, with the last declared overlay first. */
2217
+ overlayDirectories(target) {
2218
+ const selected = format(target, "target format");
2219
+ return this.overlays.filter((entry) => compare(selected, entry.min) >= 0 && compare(selected, entry.max) <= 0).map((entry) => entry.directory).reverse();
2220
+ }
2221
+ blocks(namespace, path) {
2222
+ return this.filters.some((entry) => entry.namespace?.test(namespace) ?? true) && this.filters.some((entry) => entry.path?.test(path) ?? true);
2223
+ }
2224
+ };
2225
+ }
2226
+ });
2227
+
2228
+ // src/assets/source/archive/PackFormats.ts
2229
+ var PackFormats;
2230
+ var init_PackFormats = __esm({
2231
+ "src/assets/source/archive/PackFormats.ts"() {
2232
+ init_Requests();
2233
+ PackFormats = class {
2234
+ /** Resolves pack formats from Mojang's client metadata hosted on assets.mcasset.cloud. */
2235
+ static async get(version, type) {
2236
+ let pending = this.versions.get(version);
2237
+ if (!pending || pending.expires <= Date.now()) {
2238
+ pending = {
2239
+ formats: this.load(version),
2240
+ expires: ["latest", "release", "snapshot"].includes(version) ? Date.now() + 3e5 : Infinity
2241
+ };
2242
+ this.versions.set(version, pending);
2243
+ }
2244
+ try {
2245
+ return (await pending.formats)[type];
2246
+ } catch (cause) {
2247
+ if (this.versions.get(version) === pending) this.versions.delete(version);
2248
+ const option = type === "assets" ? "resourcePackFormat" : "dataPackFormat";
2249
+ const reason = cause instanceof Error ? cause.message : String(cause);
2250
+ throw new Error(`Could not resolve the pack format for Minecraft ${version}. Set ArchiveAssetSource ${option} explicitly. ${reason}`);
2251
+ }
2252
+ }
2253
+ static async load(version) {
2254
+ const response = await Requests.genericRequest({
2255
+ url: `https://assets.mcasset.cloud/${encodeURIComponent(version)}/game-version.json`,
2256
+ responseType: "json"
2257
+ });
2258
+ const data = response.data;
2259
+ if (!data || typeof data !== "object" || Array.isArray(data)) {
2260
+ throw new Error("Expected version metadata to be an object");
2261
+ }
2262
+ const packs = data.pack_version;
2263
+ if (typeof packs !== "number" && (!packs || typeof packs !== "object" || Array.isArray(packs))) {
2264
+ throw new Error("Expected pack_version to be a number or an object");
2265
+ }
2266
+ const format2 = (type) => {
2267
+ const modern = typeof packs === "object" && ["resource_major", "resource_minor", "data_major", "data_minor"].some((key) => key in packs);
2268
+ const major = typeof packs === "number" ? packs : packs[modern ? `${type}_major` : type];
2269
+ const minor = modern ? packs[`${type}_minor`] : 0;
2270
+ if (typeof major !== "number" || !Number.isSafeInteger(major) || major < 0 || typeof minor !== "number" || !Number.isSafeInteger(minor) || minor < 0) {
2271
+ throw new Error(`Invalid ${type} pack format in version metadata`);
2272
+ }
2273
+ return Object.freeze([major, minor]);
2274
+ };
2275
+ return { assets: format2("resource"), data: format2("data") };
2276
+ }
2277
+ };
2278
+ PackFormats.versions = /* @__PURE__ */ new Map();
2279
+ }
2280
+ });
2281
+
2122
2282
  // src/assets/source/archive/ArchiveAssetSource.ts
2123
2283
  var ArchiveAssetSource;
2124
2284
  var init_ArchiveAssetSource = __esm({
@@ -2127,35 +2287,77 @@ var init_ArchiveAssetSource = __esm({
2127
2287
  init_request();
2128
2288
  init_HostedAssetSource();
2129
2289
  init_BrowserArchiveProxy();
2290
+ init_AssetLoader();
2291
+ init_PackMetadata();
2292
+ init_PackFormats();
2130
2293
  ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
2131
- constructor(archiveProxy) {
2294
+ constructor(archiveProxy, options = {}) {
2132
2295
  super();
2133
- console.log(archiveProxy);
2134
2296
  this._archiveProxy = archiveProxy;
2297
+ const copyFormat = (format2) => typeof format2 === "object" ? [format2[0], format2[1]] : format2;
2298
+ this.options = {
2299
+ resourcePackFormat: copyFormat(options.resourcePackFormat),
2300
+ dataPackFormat: copyFormat(options.dataPackFormat)
2301
+ };
2135
2302
  }
2136
- static blob(blob) {
2137
- return new _ArchiveAssetSource(new BrowserArchiveProxy(blob));
2303
+ static blob(blob, options) {
2304
+ return new _ArchiveAssetSource(new BrowserArchiveProxy(blob), options);
2138
2305
  }
2139
2306
  get cacheId() {
2140
2307
  const id = this._archiveProxy.id;
2141
- return id === void 0 ? void 0 : `archive:${id}`;
2308
+ const formats = [this.options.resourcePackFormat ?? AssetLoader.version, this.options.dataPackFormat ?? AssetLoader.version];
2309
+ return id === void 0 ? void 0 : `archive-metadata:1:${id}:${JSON.stringify(formats)}`;
2142
2310
  }
2143
2311
  async getEntries() {
2144
- return this._archiveProxy.getEntries();
2312
+ return this.entries ?? (this.entries = this._archiveProxy.getEntries().catch((error) => {
2313
+ this.entries = void 0;
2314
+ throw error;
2315
+ }));
2145
2316
  }
2146
2317
  async getEntry(path) {
2147
2318
  const entries = await this.getEntries();
2148
2319
  return entries.find((e) => e.filename === path);
2149
2320
  }
2321
+ async getMetadata(key) {
2322
+ try {
2323
+ return await (this.metadata ?? (this.metadata = this.getEntry("pack.mcmeta").then(async (entry) => PackMetadata.parse(entry ? JSON.parse(await (await entry.getData()).text()) : {})).catch((error) => {
2324
+ this.metadata = void 0;
2325
+ throw error;
2326
+ })));
2327
+ } catch (cause) {
2328
+ throw new AssetLoadError(this, key, "pack.mcmeta", cause);
2329
+ }
2330
+ }
2331
+ async blocks(key) {
2332
+ if (key.rootType !== "assets" && key.rootType !== "data") return false;
2333
+ const metadata = await this.getMetadata(key);
2334
+ const path = `${key.assetType !== void 0 ? key.assetType + "/" : ""}${key.getFullPath()}${key.extension}`;
2335
+ return metadata.blocks(key.namespace, path);
2336
+ }
2150
2337
  async get(key, parser) {
2151
2338
  const responseParser = HostedAssetSource.PARSER_MAP.get(parser);
2152
2339
  return this.load(key, responseParser);
2153
2340
  }
2154
2341
  async load(key, parser) {
2155
2342
  const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
2343
+ const version = AssetLoader.version;
2344
+ let selectedPath = path;
2156
2345
  let url;
2157
2346
  try {
2158
- const entry = await this.getEntry(path);
2347
+ let directories = [];
2348
+ if (key.rootType === "assets" || key.rootType === "data") {
2349
+ const metadata = await this.getMetadata(key);
2350
+ if (metadata.hasOverlays) {
2351
+ const format2 = (key.rootType === "assets" ? this.options.resourcePackFormat : this.options.dataPackFormat) ?? await PackFormats.get(version, key.rootType);
2352
+ directories = metadata.overlayDirectories(format2);
2353
+ }
2354
+ }
2355
+ let entry;
2356
+ for (const directory of [...directories, ""]) {
2357
+ selectedPath = directory ? `${directory}/${path}` : path;
2358
+ entry = await this.getEntry(selectedPath);
2359
+ if (entry) break;
2360
+ }
2159
2361
  if (!entry) {
2160
2362
  return void 0;
2161
2363
  }
@@ -2168,7 +2370,8 @@ var init_ArchiveAssetSource = __esm({
2168
2370
  }
2169
2371
  return await parser.parse(response);
2170
2372
  } catch (cause) {
2171
- throw new AssetLoadError(this, key, path, cause);
2373
+ if (cause instanceof AssetLoadError) throw cause;
2374
+ throw new AssetLoadError(this, key, selectedPath, cause);
2172
2375
  } finally {
2173
2376
  if (url !== void 0) {
2174
2377
  URL.revokeObjectURL(url);
@@ -2201,6 +2404,8 @@ var init_archive = __esm({
2201
2404
  init_ArchiveEntry();
2202
2405
  init_ArchiveProxy();
2203
2406
  init_BrowserArchiveProxy();
2407
+ init_PackFormats();
2408
+ init_PackMetadata();
2204
2409
  }
2205
2410
  });
2206
2411
 
@@ -2283,13 +2488,14 @@ ${key}` : key;
2283
2488
  return void 0;
2284
2489
  }
2285
2490
  static async getAll(key, parser) {
2286
- let promises = [];
2287
- for (const source of this._SOURCES) {
2288
- promises.push(source.source.get(key, parser));
2491
+ const sources = [...this._SOURCES];
2492
+ const results = [];
2493
+ for (const { source } of sources) {
2494
+ const asset = await source.get(key, parser);
2495
+ if (asset != void 0) results.push(asset);
2496
+ if (await source.blocks(key)) break;
2289
2497
  }
2290
- return Promise.all(promises).then((results) => {
2291
- return results.filter((r) => r != void 0);
2292
- });
2498
+ return results;
2293
2499
  }
2294
2500
  /** Returns the first defined result in source-priority order, without merging assets. */
2295
2501
  static async get(key, parser) {
@@ -2310,13 +2516,17 @@ ${key}` : key;
2310
2516
  /** Tries each path within a source before considering lower-priority sources. */
2311
2517
  static async getFirst(keys, parser) {
2312
2518
  const sources = [...this._SOURCES];
2519
+ let remaining = [...keys];
2313
2520
  for (const source of sources) {
2314
- for (const key of keys) {
2521
+ for (const key of remaining) {
2315
2522
  const result = await source.source.get(key, parser);
2316
2523
  if (result !== void 0) {
2317
2524
  return { key, asset: result };
2318
2525
  }
2319
2526
  }
2527
+ const blocked = await Promise.all(remaining.map((key) => source.source.blocks(key)));
2528
+ remaining = remaining.filter((_, index) => !blocked[index]);
2529
+ if (!remaining.length) break;
2320
2530
  }
2321
2531
  return void 0;
2322
2532
  }
@@ -3423,27 +3633,27 @@ var init_EntityAnimationPlayer = __esm({
3423
3633
  for (const layer of layers) {
3424
3634
  const objects = [];
3425
3635
  if (poses) {
3426
- layer.traverse((object) => {
3427
- if (poses.has(object)) objects.push(object);
3636
+ layer.traverse((object2) => {
3637
+ if (poses.has(object2)) objects.push(object2);
3428
3638
  });
3429
3639
  } else {
3430
3640
  for (const bone of Object.keys(animation.bones)) {
3431
- const object = layer.getObjectByName(`group:${bone}`);
3432
- if (object) objects.push(object);
3641
+ const object2 = layer.getObjectByName(`group:${bone}`);
3642
+ if (object2) objects.push(object2);
3433
3643
  }
3434
3644
  }
3435
- for (const object of objects) {
3436
- const bone = object.name.slice("group:".length);
3437
- const pose = poses?.get(object);
3645
+ for (const object2 of objects) {
3646
+ const bone = object2.name.slice("group:".length);
3647
+ const pose = poses?.get(object2);
3438
3648
  this.parts.push({
3439
3649
  bone,
3440
- object,
3441
- position: object.position.clone(),
3442
- rotation: object.rotation.clone(),
3443
- scale: object.scale.clone(),
3444
- basePosition: pose ? new Vector35(...pose.offset) : object.position.clone(),
3445
- baseRotation: pose ? new Euler3(...pose.rotation, "ZYX") : object.rotation.clone(),
3446
- baseScale: pose ? new Vector35(...pose.scale ?? [1, 1, 1]) : object.scale.clone()
3650
+ object: object2,
3651
+ position: object2.position.clone(),
3652
+ rotation: object2.rotation.clone(),
3653
+ scale: object2.scale.clone(),
3654
+ basePosition: pose ? new Vector35(...pose.offset) : object2.position.clone(),
3655
+ baseRotation: pose ? new Euler3(...pose.rotation, "ZYX") : object2.rotation.clone(),
3656
+ baseScale: pose ? new Vector35(...pose.scale ?? [1, 1, 1]) : object2.scale.clone()
3447
3657
  });
3448
3658
  }
3449
3659
  }
@@ -3962,15 +4172,15 @@ var init_SceneObject = __esm({
3962
4172
  }
3963
4173
  }
3964
4174
  //</editor-fold>
3965
- toggleObjectVisibility(object, visible) {
3966
- if (object) {
4175
+ toggleObjectVisibility(object2, visible) {
4176
+ if (object2) {
3967
4177
  if (typeof visible !== "undefined") {
3968
- object.visible = visible;
4178
+ object2.visible = visible;
3969
4179
  } else {
3970
- object.visible = !object.visible;
4180
+ object2.visible = !object2.visible;
3971
4181
  }
3972
4182
  this.notifyDirty();
3973
- return object.visible;
4183
+ return object2.visible;
3974
4184
  }
3975
4185
  this.notifyDirty();
3976
4186
  return false;
@@ -4265,8 +4475,8 @@ var init_EntityObject = __esm({
4265
4475
  this.scrollMaterials.push({ material: mat, offset: mat.map.offset, speed: scroll });
4266
4476
  }
4267
4477
  }
4268
- this.getLayerGroup(name)?.traverse((object) => {
4269
- if (isMesh(object)) object.material = mat;
4478
+ this.getLayerGroup(name)?.traverse((object2) => {
4479
+ if (isMesh(object2)) object2.material = mat;
4270
4480
  });
4271
4481
  }));
4272
4482
  if (!this.children.length) {
@@ -4607,8 +4817,8 @@ function toTrianglesDrawMode(geometry, drawMode) {
4607
4817
  return geometry;
4608
4818
  }
4609
4819
  }
4610
- function computeMorphedAttributes(object) {
4611
- if (object.geometry.isBufferGeometry !== true) {
4820
+ function computeMorphedAttributes(object2) {
4821
+ if (object2.geometry.isBufferGeometry !== true) {
4612
4822
  console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
4613
4823
  return null;
4614
4824
  }
@@ -4621,11 +4831,11 @@ function computeMorphedAttributes(object) {
4621
4831
  const _morphA = new Vector310();
4622
4832
  const _morphB = new Vector310();
4623
4833
  const _morphC = new Vector310();
4624
- function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
4834
+ function _calculateMorphedAttributeData(object3, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
4625
4835
  _vA.fromBufferAttribute(attribute, a2);
4626
4836
  _vB.fromBufferAttribute(attribute, b2);
4627
4837
  _vC.fromBufferAttribute(attribute, c2);
4628
- const morphInfluences = object2.morphTargetInfluences;
4838
+ const morphInfluences = object3.morphTargetInfluences;
4629
4839
  if (material2.morphTargets && morphAttribute && morphInfluences) {
4630
4840
  _morphA.set(0, 0, 0);
4631
4841
  _morphB.set(0, 0, 0);
@@ -4651,10 +4861,10 @@ function computeMorphedAttributes(object) {
4651
4861
  _vB.add(_morphB);
4652
4862
  _vC.add(_morphC);
4653
4863
  }
4654
- if (object2.isSkinnedMesh) {
4655
- object2.boneTransform(a2, _vA);
4656
- object2.boneTransform(b2, _vB);
4657
- object2.boneTransform(c2, _vC);
4864
+ if (object3.isSkinnedMesh) {
4865
+ object3.boneTransform(a2, _vA);
4866
+ object3.boneTransform(b2, _vB);
4867
+ object3.boneTransform(c2, _vC);
4658
4868
  }
4659
4869
  modifiedAttributeArray[a2 * 3 + 0] = _vA.x;
4660
4870
  modifiedAttributeArray[a2 * 3 + 1] = _vA.y;
@@ -4666,8 +4876,8 @@ function computeMorphedAttributes(object) {
4666
4876
  modifiedAttributeArray[c2 * 3 + 1] = _vC.y;
4667
4877
  modifiedAttributeArray[c2 * 3 + 2] = _vC.z;
4668
4878
  }
4669
- const geometry = object.geometry;
4670
- const material = object.material;
4879
+ const geometry = object2.geometry;
4880
+ const material = object2.material;
4671
4881
  let a, b, c;
4672
4882
  const index = geometry.index;
4673
4883
  const positionAttribute = geometry.attributes.position;
@@ -4694,7 +4904,7 @@ function computeMorphedAttributes(object) {
4694
4904
  b = index.getX(j + 1);
4695
4905
  c = index.getX(j + 2);
4696
4906
  _calculateMorphedAttributeData(
4697
- object,
4907
+ object2,
4698
4908
  groupMaterial,
4699
4909
  positionAttribute,
4700
4910
  morphPosition,
@@ -4705,7 +4915,7 @@ function computeMorphedAttributes(object) {
4705
4915
  modifiedPosition
4706
4916
  );
4707
4917
  _calculateMorphedAttributeData(
4708
- object,
4918
+ object2,
4709
4919
  groupMaterial,
4710
4920
  normalAttribute,
4711
4921
  morphNormal,
@@ -4725,7 +4935,7 @@ function computeMorphedAttributes(object) {
4725
4935
  b = index.getX(i + 1);
4726
4936
  c = index.getX(i + 2);
4727
4937
  _calculateMorphedAttributeData(
4728
- object,
4938
+ object2,
4729
4939
  material,
4730
4940
  positionAttribute,
4731
4941
  morphPosition,
@@ -4736,7 +4946,7 @@ function computeMorphedAttributes(object) {
4736
4946
  modifiedPosition
4737
4947
  );
4738
4948
  _calculateMorphedAttributeData(
4739
- object,
4949
+ object2,
4740
4950
  material,
4741
4951
  normalAttribute,
4742
4952
  morphNormal,
@@ -4760,7 +4970,7 @@ function computeMorphedAttributes(object) {
4760
4970
  b = j + 1;
4761
4971
  c = j + 2;
4762
4972
  _calculateMorphedAttributeData(
4763
- object,
4973
+ object2,
4764
4974
  groupMaterial,
4765
4975
  positionAttribute,
4766
4976
  morphPosition,
@@ -4771,7 +4981,7 @@ function computeMorphedAttributes(object) {
4771
4981
  modifiedPosition
4772
4982
  );
4773
4983
  _calculateMorphedAttributeData(
4774
- object,
4984
+ object2,
4775
4985
  groupMaterial,
4776
4986
  normalAttribute,
4777
4987
  morphNormal,
@@ -4791,7 +5001,7 @@ function computeMorphedAttributes(object) {
4791
5001
  b = i + 1;
4792
5002
  c = i + 2;
4793
5003
  _calculateMorphedAttributeData(
4794
- object,
5004
+ object2,
4795
5005
  material,
4796
5006
  positionAttribute,
4797
5007
  morphPosition,
@@ -4802,7 +5012,7 @@ function computeMorphedAttributes(object) {
4802
5012
  modifiedPosition
4803
5013
  );
4804
5014
  _calculateMorphedAttributeData(
4805
- object,
5015
+ object2,
4806
5016
  material,
4807
5017
  normalAttribute,
4808
5018
  morphNormal,
@@ -5111,13 +5321,13 @@ var init_ModelObject = __esm({
5111
5321
  transform.multiply(new Matrix49().makeTranslation(-8, -8, -8));
5112
5322
  try {
5113
5323
  for (const part of parts) {
5114
- const object = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
5115
- object.matrix.copy(transform).multiply(part.transform);
5116
- object.matrixWorldNeedsUpdate = true;
5117
- object.matrixAutoUpdate = false;
5118
- this.add(object);
5119
- await object.init();
5120
- object.iterateAllMeshes((mesh) => {
5324
+ const object2 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
5325
+ object2.matrix.copy(transform).multiply(part.transform);
5326
+ object2.matrixWorldNeedsUpdate = true;
5327
+ object2.matrixAutoUpdate = false;
5328
+ this.add(object2);
5329
+ await object2.init();
5330
+ object2.iterateAllMeshes((mesh) => {
5121
5331
  const source = mesh.material;
5122
5332
  let material = this.specialMaterials.get(source);
5123
5333
  if (!material) {
@@ -5128,7 +5338,7 @@ var init_ModelObject = __esm({
5128
5338
  mesh.material = material;
5129
5339
  });
5130
5340
  for (const [name, rotation] of Object.entries(part.rotations)) {
5131
- object.getGroupByName(name)?.rotation.set(...rotation, "ZYX");
5341
+ object2.getGroupByName(name)?.rotation.set(...rotation, "ZYX");
5132
5342
  }
5133
5343
  }
5134
5344
  } catch (error) {
@@ -5940,7 +6150,7 @@ var OBJExporter = class {
5940
6150
  * @param {Object3D} object - The 3D object to export.
5941
6151
  * @return {string} The exported OBJ.
5942
6152
  */
5943
- parse(object) {
6153
+ parse(object2) {
5944
6154
  let output = "";
5945
6155
  let indexVertex = 0;
5946
6156
  let indexVertexUvs = 0;
@@ -6059,7 +6269,7 @@ var OBJExporter = class {
6059
6269
  }
6060
6270
  indexVertex += nbVertex;
6061
6271
  }
6062
- object.traverse(function(child) {
6272
+ object2.traverse(function(child) {
6063
6273
  if (child.isMesh === true) {
6064
6274
  parseMesh(child);
6065
6275
  }
@@ -6093,9 +6303,9 @@ var PLYExporter = class {
6093
6303
  * @param {PLYExporter~Options} options - The export options.
6094
6304
  * @return {?(string|ArrayBuffer)} The exported PLY.
6095
6305
  */
6096
- parse(object, onDone, options = {}) {
6306
+ parse(object2, onDone, options = {}) {
6097
6307
  function traverseMeshes(cb) {
6098
- object.traverse(function(child) {
6308
+ object2.traverse(function(child) {
6099
6309
  if (child.isMesh === true || child.isPoints) {
6100
6310
  const mesh = child;
6101
6311
  const geometry = mesh.geometry;
@@ -6128,7 +6338,7 @@ var PLYExporter = class {
6128
6338
  for (const name of customAttributeNames) customTypes[name] = "float";
6129
6339
  let vertexCount = 0;
6130
6340
  let faceCount = 0;
6131
- object.traverse(function(child) {
6341
+ object2.traverse(function(child) {
6132
6342
  if (child.isMesh === true) {
6133
6343
  const mesh = child;
6134
6344
  const geometry = mesh.geometry;
@@ -6944,12 +7154,12 @@ var GLTFWriter = class {
6944
7154
  * @param {THREE.Object3D|THREE.Material|THREE.BufferGeometry|THREE.AnimationClip} object
6945
7155
  * @param {Object} objectDef
6946
7156
  */
6947
- serializeUserData(object, objectDef) {
6948
- if (Object.keys(object.userData).length === 0) return;
7157
+ serializeUserData(object2, objectDef) {
7158
+ if (Object.keys(object2.userData).length === 0) return;
6949
7159
  const options = this.options;
6950
7160
  const extensionsUsed = this.extensionsUsed;
6951
7161
  try {
6952
- const json = JSON.parse(JSON.stringify(object.userData));
7162
+ const json = JSON.parse(JSON.stringify(object2.userData));
6953
7163
  if (options.includeCustomExtensions && json.gltfExtensions) {
6954
7164
  if (objectDef.extensions === void 0) objectDef.extensions = {};
6955
7165
  for (const extensionName in json.gltfExtensions) {
@@ -6960,7 +7170,7 @@ var GLTFWriter = class {
6960
7170
  }
6961
7171
  if (Object.keys(json).length > 0) objectDef.extras = json;
6962
7172
  } catch (error) {
6963
- console.warn("THREE.GLTFExporter: userData of '" + object.name + "' won't be serialized because of JSON.stringify error - " + error.message);
7173
+ console.warn("THREE.GLTFExporter: userData of '" + object2.name + "' won't be serialized because of JSON.stringify error - " + error.message);
6964
7174
  }
6965
7175
  }
6966
7176
  /**
@@ -7333,7 +7543,7 @@ var GLTFWriter = class {
7333
7543
  * @param {string} mimeType export format
7334
7544
  * @return {number} Index of the processed texture in the "images" array
7335
7545
  */
7336
- processImage(image, format, flipY, mimeType = "image/png") {
7546
+ processImage(image, format2, flipY, mimeType = "image/png") {
7337
7547
  if (image !== null) {
7338
7548
  const writer = this;
7339
7549
  const cache = writer.cache;
@@ -7357,8 +7567,8 @@ var GLTFWriter = class {
7357
7567
  ctx.scale(1, -1);
7358
7568
  }
7359
7569
  if (image.data !== void 0) {
7360
- if (format !== RGBAFormat2) {
7361
- console.error("GLTFExporter: Only RGBAFormat is supported.", format);
7570
+ if (format2 !== RGBAFormat2) {
7571
+ console.error("GLTFExporter: Only RGBAFormat is supported.", format2);
7362
7572
  }
7363
7573
  if (image.width > options.maxTextureSize || image.height > options.maxTextureSize) {
7364
7574
  console.warn("GLTFExporter: Image size is bigger than maxTextureSize", image);
@@ -7886,13 +8096,13 @@ var GLTFWriter = class {
7886
8096
  * @param {THREE.Object3D} object
7887
8097
  * @return {?number}
7888
8098
  */
7889
- processSkin(object) {
8099
+ processSkin(object2) {
7890
8100
  const json = this.json;
7891
8101
  const nodeMap = this.nodeMap;
7892
- const node = json.nodes[nodeMap.get(object)];
7893
- const skeleton = object.skeleton;
8102
+ const node = json.nodes[nodeMap.get(object2)];
8103
+ const skeleton = object2.skeleton;
7894
8104
  if (skeleton === void 0) return null;
7895
- const rootJoint = object.skeleton.bones[0];
8105
+ const rootJoint = object2.skeleton.bones[0];
7896
8106
  if (rootJoint === void 0) return null;
7897
8107
  const joints = [];
7898
8108
  const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
@@ -7900,7 +8110,7 @@ var GLTFWriter = class {
7900
8110
  for (let i = 0; i < skeleton.bones.length; ++i) {
7901
8111
  joints.push(nodeMap.get(skeleton.bones[i]));
7902
8112
  temporaryBoneInverse.copy(skeleton.boneInverses[i]);
7903
- temporaryBoneInverse.multiply(object.bindMatrix).toArray(inverseBindMatrices, i * 16);
8113
+ temporaryBoneInverse.multiply(object2.bindMatrix).toArray(inverseBindMatrices, i * 16);
7904
8114
  }
7905
8115
  if (json.skins === void 0) json.skins = [];
7906
8116
  json.skins.push({
@@ -7916,19 +8126,19 @@ var GLTFWriter = class {
7916
8126
  * @param {THREE.Object3D} object Object3D to processNodeAsync
7917
8127
  * @return {Promise<number>} Index of the node in the nodes list
7918
8128
  */
7919
- async processNodeAsync(object) {
8129
+ async processNodeAsync(object2) {
7920
8130
  const json = this.json;
7921
8131
  const options = this.options;
7922
8132
  const nodeMap = this.nodeMap;
7923
8133
  if (!json.nodes) json.nodes = [];
7924
- if (object.pivot !== null) {
7925
- return await this._processNodeWithPivotAsync(object);
8134
+ if (object2.pivot !== null) {
8135
+ return await this._processNodeWithPivotAsync(object2);
7926
8136
  }
7927
8137
  const nodeDef = {};
7928
8138
  if (options.trs) {
7929
- const rotation = object.quaternion.toArray();
7930
- const position = object.position.toArray();
7931
- const scale = object.scale.toArray();
8139
+ const rotation = object2.quaternion.toArray();
8140
+ const position = object2.position.toArray();
8141
+ const scale = object2.scale.toArray();
7932
8142
  if (!equalArray(rotation, [0, 0, 0, 1])) {
7933
8143
  nodeDef.rotation = rotation;
7934
8144
  }
@@ -7939,28 +8149,28 @@ var GLTFWriter = class {
7939
8149
  nodeDef.scale = scale;
7940
8150
  }
7941
8151
  } else {
7942
- if (object.matrixAutoUpdate) {
7943
- object.updateMatrix();
8152
+ if (object2.matrixAutoUpdate) {
8153
+ object2.updateMatrix();
7944
8154
  }
7945
- if (isIdentityMatrix(object.matrix) === false) {
7946
- nodeDef.matrix = object.matrix.elements;
8155
+ if (isIdentityMatrix(object2.matrix) === false) {
8156
+ nodeDef.matrix = object2.matrix.elements;
7947
8157
  }
7948
8158
  }
7949
- if (object.name !== "") nodeDef.name = String(object.name);
7950
- this.serializeUserData(object, nodeDef);
7951
- if (object.isMesh || object.isLine || object.isPoints) {
7952
- const meshIndex = await this.processMeshAsync(object);
8159
+ if (object2.name !== "") nodeDef.name = String(object2.name);
8160
+ this.serializeUserData(object2, nodeDef);
8161
+ if (object2.isMesh || object2.isLine || object2.isPoints) {
8162
+ const meshIndex = await this.processMeshAsync(object2);
7953
8163
  if (meshIndex !== null) nodeDef.mesh = meshIndex;
7954
- } else if (object.isCamera) {
7955
- nodeDef.camera = this.processCamera(object);
8164
+ } else if (object2.isCamera) {
8165
+ nodeDef.camera = this.processCamera(object2);
7956
8166
  }
7957
- if (object.isSkinnedMesh) this.skins.push(object);
8167
+ if (object2.isSkinnedMesh) this.skins.push(object2);
7958
8168
  const nodeIndex = json.nodes.push(nodeDef) - 1;
7959
- nodeMap.set(object, nodeIndex);
7960
- if (object.children.length > 0) {
8169
+ nodeMap.set(object2, nodeIndex);
8170
+ if (object2.children.length > 0) {
7961
8171
  const children = [];
7962
- for (let i = 0, l = object.children.length; i < l; i++) {
7963
- const child = object.children[i];
8172
+ for (let i = 0, l = object2.children.length; i < l; i++) {
8173
+ const child = object2.children[i];
7964
8174
  if (child.visible || options.onlyVisible === false) {
7965
8175
  const childNodeIndex = await this.processNodeAsync(child);
7966
8176
  if (childNodeIndex !== null) children.push(childNodeIndex);
@@ -7969,7 +8179,7 @@ var GLTFWriter = class {
7969
8179
  if (children.length > 0) nodeDef.children = children;
7970
8180
  }
7971
8181
  await this._invokeAllAsync(function(ext) {
7972
- ext.writeNode && ext.writeNode(object, nodeDef);
8182
+ ext.writeNode && ext.writeNode(object2, nodeDef);
7973
8183
  });
7974
8184
  return nodeIndex;
7975
8185
  }
@@ -7978,19 +8188,19 @@ var GLTFWriter = class {
7978
8188
  * @param {THREE.Object3D} object Object3D with pivot
7979
8189
  * @return {Promise<number>} Index of the container node
7980
8190
  */
7981
- async _processNodeWithPivotAsync(object) {
8191
+ async _processNodeWithPivotAsync(object2) {
7982
8192
  const json = this.json;
7983
8193
  const options = this.options;
7984
8194
  const nodeMap = this.nodeMap;
7985
- const pivot = object.pivot;
8195
+ const pivot = object2.pivot;
7986
8196
  const containerDef = {};
7987
- const rotation = object.quaternion.toArray();
8197
+ const rotation = object2.quaternion.toArray();
7988
8198
  const position = [
7989
- object.position.x + pivot.x,
7990
- object.position.y + pivot.y,
7991
- object.position.z + pivot.z
8199
+ object2.position.x + pivot.x,
8200
+ object2.position.y + pivot.y,
8201
+ object2.position.z + pivot.z
7992
8202
  ];
7993
- const scale = object.scale.toArray();
8203
+ const scale = object2.scale.toArray();
7994
8204
  if (!equalArray(rotation, [0, 0, 0, 1])) {
7995
8205
  containerDef.rotation = rotation;
7996
8206
  }
@@ -8001,28 +8211,28 @@ var GLTFWriter = class {
8001
8211
  containerDef.scale = scale;
8002
8212
  }
8003
8213
  containerDef.extras = { pivot: pivot.toArray() };
8004
- if (object.name !== "") containerDef.name = String(object.name);
8005
- this.serializeUserData(object, containerDef);
8214
+ if (object2.name !== "") containerDef.name = String(object2.name);
8215
+ this.serializeUserData(object2, containerDef);
8006
8216
  const containerIndex = json.nodes.push(containerDef) - 1;
8007
- nodeMap.set(object, containerIndex);
8217
+ nodeMap.set(object2, containerIndex);
8008
8218
  const childDef = {};
8009
8219
  const childPosition = [-pivot.x, -pivot.y, -pivot.z];
8010
8220
  if (!equalArray(childPosition, [0, 0, 0])) {
8011
8221
  childDef.translation = childPosition;
8012
8222
  }
8013
- if (object.isMesh || object.isLine || object.isPoints) {
8014
- const meshIndex = await this.processMeshAsync(object);
8223
+ if (object2.isMesh || object2.isLine || object2.isPoints) {
8224
+ const meshIndex = await this.processMeshAsync(object2);
8015
8225
  if (meshIndex !== null) childDef.mesh = meshIndex;
8016
- } else if (object.isCamera) {
8017
- childDef.camera = this.processCamera(object);
8226
+ } else if (object2.isCamera) {
8227
+ childDef.camera = this.processCamera(object2);
8018
8228
  }
8019
- if (object.isSkinnedMesh) this.skins.push(object);
8229
+ if (object2.isSkinnedMesh) this.skins.push(object2);
8020
8230
  const childIndex = json.nodes.push(childDef) - 1;
8021
8231
  const containerChildren = [childIndex];
8022
- if (object.children.length > 0) {
8232
+ if (object2.children.length > 0) {
8023
8233
  const grandchildren = [];
8024
- for (let i = 0, l = object.children.length; i < l; i++) {
8025
- const child = object.children[i];
8234
+ for (let i = 0, l = object2.children.length; i < l; i++) {
8235
+ const child = object2.children[i];
8026
8236
  if (child.visible || options.onlyVisible === false) {
8027
8237
  const childNodeIndex = await this.processNodeAsync(child);
8028
8238
  if (childNodeIndex !== null) grandchildren.push(childNodeIndex);
@@ -8032,7 +8242,7 @@ var GLTFWriter = class {
8032
8242
  }
8033
8243
  containerDef.children = containerChildren;
8034
8244
  await this._invokeAllAsync(function(ext) {
8035
- ext.writeNode && ext.writeNode(object, containerDef);
8245
+ ext.writeNode && ext.writeNode(object2, containerDef);
8036
8246
  });
8037
8247
  return containerIndex;
8038
8248
  }
@@ -8475,10 +8685,10 @@ var GLTFMeshGpuInstancing = class {
8475
8685
  this.writer = writer;
8476
8686
  this.name = "EXT_mesh_gpu_instancing";
8477
8687
  }
8478
- writeNode(object, nodeDef) {
8479
- if (!object.isInstancedMesh) return;
8688
+ writeNode(object2, nodeDef) {
8689
+ if (!object2.isInstancedMesh) return;
8480
8690
  const writer = this.writer;
8481
- const mesh = object;
8691
+ const mesh = object2;
8482
8692
  const translationAttr = new Float32Array(mesh.count * 3);
8483
8693
  const rotationAttr = new Float32Array(mesh.count * 4);
8484
8694
  const scaleAttr = new Float32Array(mesh.count * 3);
@@ -8668,8 +8878,8 @@ var SceneExporter = class {
8668
8878
  }
8669
8879
  }
8670
8880
  };
8671
- function localMatrix(object) {
8672
- return object.matrixAutoUpdate ? new Matrix47().compose(object.position, object.quaternion, object.scale) : object.matrix.clone();
8881
+ function localMatrix(object2) {
8882
+ return object2.matrixAutoUpdate ? new Matrix47().compose(object2.position, object2.quaternion, object2.scale) : object2.matrix.clone();
8673
8883
  }
8674
8884
  function createSnapshot(root, gltf, bakeColors = false) {
8675
8885
  const scene = new Scene3();
@@ -8773,10 +8983,10 @@ function createSnapshot(root, gltf, bakeColors = false) {
8773
8983
  scene.add(copy);
8774
8984
  }
8775
8985
  };
8776
- const visit = (object, parentWorld) => {
8777
- if (!object.visible) return;
8778
- const world = parentWorld.clone().multiply(localMatrix(object));
8779
- const mesh = object;
8986
+ const visit = (object2, parentWorld) => {
8987
+ if (!object2.visible) return;
8988
+ const world = parentWorld.clone().multiply(localMatrix(object2));
8989
+ const mesh = object2;
8780
8990
  if (mesh.isMesh) {
8781
8991
  const instanced = mesh;
8782
8992
  if (instanced.isInstancedMesh) {
@@ -8790,7 +9000,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
8790
9000
  addMesh(mesh, world);
8791
9001
  }
8792
9002
  }
8793
- for (const child of object.children) visit(child, world);
9003
+ for (const child of object2.children) visit(child, world);
8794
9004
  };
8795
9005
  try {
8796
9006
  const ancestors = [];
@@ -9022,11 +9232,11 @@ var GuiHelper = class {
9022
9232
  switch (recipe.type) {
9023
9233
  case "minecraft:crafting_shaped":
9024
9234
  case "crafting_shaped": {
9025
- const pattern = recipe.pattern;
9026
- if (!pattern.length || pattern.length > 3 || !pattern[0].length || pattern[0].length > 3 || pattern.some((row) => row.length !== pattern[0].length)) {
9235
+ const pattern2 = recipe.pattern;
9236
+ if (!pattern2.length || pattern2.length > 3 || !pattern2[0].length || pattern2[0].length > 3 || pattern2.some((row) => row.length !== pattern2[0].length)) {
9027
9237
  throw new Error("Crafting patterns must be rectangular, with 1\u20133 rows and columns");
9028
9238
  }
9029
- const cells = pattern.flatMap((row, y) => row.split("").map((symbol, x) => ({ symbol, x, y }))).filter((cell) => cell.symbol !== " ");
9239
+ const cells = pattern2.flatMap((row, y) => row.split("").map((symbol, x) => ({ symbol, x, y }))).filter((cell) => cell.symbol !== " ");
9030
9240
  if (!cells.length) throw new Error("Crafting patterns must contain an ingredient");
9031
9241
  const minX = Math.min(...cells.map((cell) => cell.x)), maxX = Math.max(...cells.map((cell) => cell.x));
9032
9242
  const minY = Math.min(...cells.map((cell) => cell.y)), maxY = Math.max(...cells.map((cell) => cell.y));
@@ -9438,29 +9648,29 @@ var SceneInspector = class {
9438
9648
  this.objectControlsContainer.innerHTML = "";
9439
9649
  this.addControls(targetObject, targetIntersection, instance);
9440
9650
  }
9441
- addControls(object, intersection, instance) {
9651
+ addControls(object2, intersection, instance) {
9442
9652
  const container = document.createElement("div");
9443
9653
  container.append(this.separator("Select Parent/Child"));
9444
- if (object.parent) {
9445
- container.append(this.buttonControl("Select Parent " + object.parent.constructor.name + " " + object.parent.name, "P", () => {
9446
- this.selectObject(object.parent, intersection, instance);
9654
+ if (object2.parent) {
9655
+ container.append(this.buttonControl("Select Parent " + object2.parent.constructor.name + " " + object2.parent.name, "P", () => {
9656
+ this.selectObject(object2.parent, intersection, instance);
9447
9657
  }));
9448
9658
  }
9449
- if (object.children.length > 0) {
9659
+ if (object2.children.length > 0) {
9450
9660
  let i = 1;
9451
- for (let child of object.children) {
9661
+ for (let child of object2.children) {
9452
9662
  container.append(this.buttonControl("Select Child " + child.constructor.name + " " + child.name, "C" + i++, () => {
9453
9663
  this.selectObject(child, intersection, instance);
9454
9664
  }));
9455
9665
  }
9456
9666
  }
9457
9667
  container.append(this.separator());
9458
- const selectedInstance = instance && (object === instance.instanceable || object === intersection?.object) ? instance : void 0;
9668
+ const selectedInstance = instance && (object2 === instance.instanceable || object2 === intersection?.object) ? instance : void 0;
9459
9669
  if (!selectedInstance) {
9460
- container.append(this.toggleControl("Visibility", "V", object.visible, (v) => object.visible = v));
9670
+ container.append(this.toggleControl("Visibility", "V", object2.visible, (v) => object2.visible = v));
9461
9671
  }
9462
9672
  container.append(this.separator("Mesh"));
9463
- this.addObjectControls(object, intersection, container, selectedInstance);
9673
+ this.addObjectControls(object2, intersection, container, selectedInstance);
9464
9674
  container.append(this.separator());
9465
9675
  this.objectControlsContainer.append(container);
9466
9676
  }
@@ -10026,8 +10236,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
10026
10236
  return false;
10027
10237
  }
10028
10238
  return this._models.some((model) => {
10029
- const object = isInstanceReference(model) ? model.instanceable : model;
10030
- return object.isOpaqueFullCube && this.getModelCullMask(model, 63) === 63;
10239
+ const object2 = isInstanceReference(model) ? model.instanceable : model;
10240
+ return object2.isOpaqueFullCube && this.getModelCullMask(model, 63) === 63;
10031
10241
  });
10032
10242
  }
10033
10243
  getModelMatrix(model) {
@@ -10036,8 +10246,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
10036
10246
  return model.matrix.clone();
10037
10247
  }
10038
10248
  getModelCullMask(model, worldMask) {
10039
- const object = isInstanceReference(model) ? model.instanceable : model;
10040
- if (object.options.displayPosition) return 0;
10249
+ const object2 = isInstanceReference(model) ? model.instanceable : model;
10250
+ if (object2.options.displayPosition) return 0;
10041
10251
  const position = new Vector312();
10042
10252
  const rotation = new Quaternion5();
10043
10253
  const scale = new Vector312();
@@ -10054,14 +10264,14 @@ var _BlockObject = class _BlockObject extends SceneObject {
10054
10264
  replacements.push(model);
10055
10265
  continue;
10056
10266
  }
10057
- const object = isInstanceReference(model) ? model.instanceable : model;
10267
+ const object2 = isInstanceReference(model) ? model.instanceable : model;
10058
10268
  const cullMask = this.getModelCullMask(model, worldMask);
10059
- if (cullMask === (object.options.cullMask ?? 0)) {
10269
+ if (cullMask === (object2.options.cullMask ?? 0)) {
10060
10270
  replacements.push(model);
10061
10271
  continue;
10062
10272
  }
10063
10273
  const matrix = this.getModelMatrix(model);
10064
- const replacement = await this.scene.addModel(object.originalModel, { ...object.options, cullMask });
10274
+ const replacement = await this.scene.addModel(object2.originalModel, { ...object2.options, cullMask });
10065
10275
  replacements.push(replacement);
10066
10276
  if (isInstanceReference(replacement)) {
10067
10277
  replacement.setMatrix(matrix);
@@ -10069,8 +10279,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
10069
10279
  replacement.matrix.copy(matrix);
10070
10280
  replacement.matrixWorldNeedsUpdate = true;
10071
10281
  matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
10072
- replacement.matrixAutoUpdate = object.matrixAutoUpdate;
10073
- replacement.visible = object.visible;
10282
+ replacement.matrixAutoUpdate = object2.matrixAutoUpdate;
10283
+ replacement.visible = object2.visible;
10074
10284
  }
10075
10285
  }
10076
10286
  } catch (error) {
@@ -11992,9 +12202,9 @@ var SchematicParser = class {
11992
12202
  * Parses a legacy schematic using custom mappings before the bundled defaults.
11993
12203
  * Keys are `id:metadata`; values are block states such as `minecraft:oak_log[axis=x]`.
11994
12204
  */
11995
- static async parse(nbt, customMappings = {}) {
12205
+ static async parse(nbt, customMappings = {}, options = {}) {
11996
12206
  const tags = nbt.value;
11997
- if (tags.Materials?.type !== "string" || tags.Materials.value !== "Alpha") {
12207
+ if (!options.lenient && (tags.Materials?.type !== "string" || tags.Materials.value !== "Alpha")) {
11998
12208
  throw new MineRenderError("Schematic Materials must be Alpha");
11999
12209
  }
12000
12210
  const size = ["Width", "Height", "Length"].map((name) => {
@@ -12035,8 +12245,16 @@ var SchematicParser = class {
12035
12245
  const id = high << 8 | ids.value[index] & 255;
12036
12246
  const metadata = data.value[index] & 255;
12037
12247
  const key = `${id}:${metadata}`;
12038
- const mapped = customMappings[key] ?? mapping[key];
12039
- if (!mapped) throw new MineRenderError(`Unsupported legacy block ${id}:${metadata} at schematic index ${index}`);
12248
+ let mapped = customMappings[key] ?? mapping[key];
12249
+ if (!mapped && options.lenient) {
12250
+ mapped = customMappings[`${id}:0`] ?? mapping[`${id}:0`];
12251
+ }
12252
+ if (!mapped) {
12253
+ if (options.lenient) {
12254
+ continue;
12255
+ }
12256
+ throw new MineRenderError(`Unsupported legacy block ${id}:${metadata} at schematic index ${index}`);
12257
+ }
12040
12258
  const [type, state] = mapped.split("[");
12041
12259
  if (type === "minecraft:air") continue;
12042
12260
  const properties = {};
@@ -13194,53 +13412,53 @@ var _MineRenderScene = class _MineRenderScene extends Scene4 {
13194
13412
  this.options = (0, import_ts_deepmerge8.default)({}, _MineRenderScene.DEFAULT_OPTIONS, options ?? {});
13195
13413
  }
13196
13414
  add(...objects) {
13197
- for (const object of objects) {
13415
+ for (const object2 of objects) {
13198
13416
  this.dirty = true;
13199
13417
  try {
13200
- super.add(object);
13418
+ super.add(object2);
13201
13419
  } finally {
13202
- if (object?.isObject3D && object !== this) {
13203
- this.updateObjectRegistration(object, object.parent === this);
13420
+ if (object2?.isObject3D && object2 !== this) {
13421
+ this.updateObjectRegistration(object2, object2.parent === this);
13204
13422
  }
13205
13423
  }
13206
13424
  }
13207
13425
  return this;
13208
13426
  }
13209
13427
  remove(...objects) {
13210
- for (const object of objects) {
13211
- if (!this.children.includes(object)) continue;
13428
+ for (const object2 of objects) {
13429
+ if (!this.children.includes(object2)) continue;
13212
13430
  this.dirty = true;
13213
- this.updateObjectRegistration(object, false);
13431
+ this.updateObjectRegistration(object2, false);
13214
13432
  try {
13215
- super.remove(object);
13433
+ super.remove(object2);
13216
13434
  } finally {
13217
- this.updateObjectRegistration(object, object.parent === this);
13435
+ this.updateObjectRegistration(object2, object2.parent === this);
13218
13436
  }
13219
13437
  }
13220
13438
  return this;
13221
13439
  }
13222
- updateObjectRegistration(object, attached) {
13223
- if (this.observedObjects.has(object) === attached) return;
13224
- const observable = object;
13440
+ updateObjectRegistration(object2, attached) {
13441
+ if (this.observedObjects.has(object2) === attached) return;
13442
+ const observable = object2;
13225
13443
  if (attached) {
13226
- this.observedObjects.add(object);
13444
+ this.observedObjects.add(object2);
13227
13445
  observable.addEventListener("change", this.onObjectChange);
13228
13446
  } else {
13229
- this.observedObjects.delete(object);
13447
+ this.observedObjects.delete(object2);
13230
13448
  observable.removeEventListener("change", this.onObjectChange);
13231
13449
  }
13232
13450
  const change = attached ? 1 : -1;
13233
13451
  this.stats.objectCount += change;
13234
- if (isSceneObject(object)) {
13452
+ if (isSceneObject(object2)) {
13235
13453
  this.stats.sceneObjectCount += change;
13236
13454
  }
13237
13455
  }
13238
- async initAndAdd(...object) {
13456
+ async initAndAdd(...object2) {
13239
13457
  this.dirty = true;
13240
- for (let obj of object) {
13458
+ for (let obj of object2) {
13241
13459
  await obj.init();
13242
13460
  }
13243
- return this.add(...object);
13461
+ return this.add(...object2);
13244
13462
  }
13245
13463
  async addSceneObject(asset, objectSupplier, _options, parent = this) {
13246
13464
  this.dirty = true;
@@ -13329,11 +13547,11 @@ var _changeEvent = { type: "change" };
13329
13547
  var _startEvent = { type: "start" };
13330
13548
  var _endEvent = { type: "end" };
13331
13549
  var OrbitControls = class extends EventDispatcher {
13332
- constructor(object, domElement) {
13550
+ constructor(object2, domElement) {
13333
13551
  super();
13334
13552
  if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
13335
13553
  if (domElement === document) console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
13336
- this.object = object;
13554
+ this.object = object2;
13337
13555
  this.domElement = domElement;
13338
13556
  this.domElement.style.touchAction = "none";
13339
13557
  this.enabled = true;
@@ -13390,7 +13608,7 @@ var OrbitControls = class extends EventDispatcher {
13390
13608
  };
13391
13609
  this.update = function() {
13392
13610
  const offset = new Vector313();
13393
- const quat = new Quaternion6().setFromUnitVectors(object.up, new Vector313(0, 1, 0));
13611
+ const quat = new Quaternion6().setFromUnitVectors(object2.up, new Vector313(0, 1, 0));
13394
13612
  const quatInverse = quat.clone().invert();
13395
13613
  const lastPosition = new Vector313();
13396
13614
  const lastQuaternion = new Quaternion6();
@@ -13955,8 +14173,8 @@ var OrbitControls = class extends EventDispatcher {
13955
14173
  }
13956
14174
  };
13957
14175
  var MapControls = class extends OrbitControls {
13958
- constructor(object, domElement) {
13959
- super(object, domElement);
14176
+ constructor(object2, domElement) {
14177
+ super(object2, domElement);
13960
14178
  this.screenSpacePanning = false;
13961
14179
  this.mouseButtons.LEFT = MOUSE.PAN;
13962
14180
  this.mouseButtons.RIGHT = MOUSE.ROTATE;
@@ -14883,16 +15101,16 @@ var SectionModels = class {
14883
15101
  if (!models) this.models.set(model, models = /* @__PURE__ */ new Map());
14884
15102
  const key = JSON.stringify([rotation.x, rotation.y, rotation.z, variant.uvlock, tints]);
14885
15103
  const template = await cached(models, key, async () => {
14886
- const object = new SectionModel(model, {
15104
+ const object2 = new SectionModel(model, {
14887
15105
  instanceMeshes: false,
14888
15106
  mergeMeshes: false,
14889
15107
  tints,
14890
15108
  uvLockRotation: variant.uvlock && (rotation.x !== 0 || rotation.y !== 0) ? [rotation.x, rotation.y, rotation.z] : void 0
14891
15109
  });
14892
- await object.init();
14893
- const geometry = object.children[0].geometry;
15110
+ await object2.init();
15111
+ const geometry = object2.children[0].geometry;
14894
15112
  geometry.applyMatrix4(new Matrix412().makeRotationFromEuler(rotation));
14895
- object.clear();
15113
+ object2.clear();
14896
15114
  const cullFaces = CUBE_FACES.map((face) => {
14897
15115
  const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
14898
15116
  if (local < 0) return 0;
@@ -15080,10 +15298,10 @@ var MineRenderWorld = class {
15080
15298
  await block.object.updateFluid((x, y, z) => {
15081
15299
  const neighbor = pos.clone().add(new Vector316(x, y, z));
15082
15300
  const section = this.getChunkAt(neighbor);
15083
- const object = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
15301
+ const object2 = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
15084
15302
  return {
15085
- fluid: object?.fluidKind,
15086
- level: object?.fluidLevel,
15303
+ fluid: object2?.fluidKind,
15304
+ level: object2?.fluidLevel,
15087
15305
  solid: section?.isOccludingAt(neighbor) ?? false
15088
15306
  };
15089
15307
  });
@@ -15312,7 +15530,7 @@ var Chunk = class _Chunk {
15312
15530
  this.renderedBlocks.get(index)?.object?.removeFromScene();
15313
15531
  if (this.sectionBlocks.delete(index)) this.meshDirty = true;
15314
15532
  this.renderedBlocks.delete(index);
15315
- let object;
15533
+ let object2;
15316
15534
  try {
15317
15535
  if (!readBlock) return void 0;
15318
15536
  const stored = readBlock();
@@ -15327,22 +15545,22 @@ var Chunk = class _Chunk {
15327
15545
  this.sectionBlocks.set(index, { index, template, cullMask: 0 });
15328
15546
  this.meshDirty = true;
15329
15547
  } else {
15330
- object = await this.scene.addBlock(blockState, {
15548
+ object2 = await this.scene.addBlock(blockState, {
15331
15549
  mergeMeshes: true,
15332
15550
  instanceMeshes: true,
15333
15551
  maxInstanceCount: 2e3,
15334
15552
  initialState: stored.properties
15335
15553
  });
15336
- object.setPosition(MineRenderWorld.worldToScenePosition(worldPos));
15554
+ object2.setPosition(MineRenderWorld.worldToScenePosition(worldPos));
15337
15555
  }
15338
15556
  const info = { get block() {
15339
15557
  return readBlock();
15340
- }, object };
15558
+ }, object: object2 };
15341
15559
  this.renderedBlocks.set(index, info);
15342
15560
  return info;
15343
15561
  } catch (error) {
15344
15562
  this.data.set(index, void 0);
15345
- object?.removeFromScene();
15563
+ object2?.removeFromScene();
15346
15564
  throw error;
15347
15565
  } finally {
15348
15566
  await onBlocksChanged?.([worldPos]);
@@ -15515,6 +15733,8 @@ export {
15515
15733
  Models,
15516
15734
  NBTHelper,
15517
15735
  OrbitControls,
15736
+ PackFormats,
15737
+ PackMetadata,
15518
15738
  PersistentCache,
15519
15739
  Renderer,
15520
15740
  RequestError,