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.
- package/README.md +38 -0
- package/dist/browser/index.d.mts +44 -4
- package/dist/browser/index.d.ts +44 -4
- package/dist/browser/index.js +416 -196
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +416 -196
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +974 -748
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +44 -4
- package/dist/node/index.d.ts +44 -4
- package/dist/node/index.js +420 -196
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +418 -196
- package/dist/node/index.mjs.map +1 -1
- package/package.json +12 -4
package/dist/node/index.js
CHANGED
|
@@ -801,7 +801,7 @@ var init_TextureLoader = __esm({
|
|
|
801
801
|
static createTexture() {
|
|
802
802
|
return new import_three3.Texture();
|
|
803
803
|
}
|
|
804
|
-
static loadInBackground(src,
|
|
804
|
+
static loadInBackground(src, format2 = import_three3.RGBAFormat, rotation = 0) {
|
|
805
805
|
const texture = this.createTexture();
|
|
806
806
|
texture.colorSpace = THREE.SRGBColorSpace;
|
|
807
807
|
const image = ImageLoader.loadElement(src, () => {
|
|
@@ -811,11 +811,11 @@ var init_TextureLoader = __esm({
|
|
|
811
811
|
console.warn("Failed to load texture", src, error);
|
|
812
812
|
});
|
|
813
813
|
texture.image = image;
|
|
814
|
-
texture.format =
|
|
814
|
+
texture.format = format2;
|
|
815
815
|
texture.rotation = rotation;
|
|
816
816
|
return Textures.initTextureProps(texture);
|
|
817
817
|
}
|
|
818
|
-
static load(src,
|
|
818
|
+
static load(src, format2 = import_three3.RGBAFormat, rotation = 0) {
|
|
819
819
|
const texture = new import_three3.Texture();
|
|
820
820
|
texture.colorSpace = THREE.SRGBColorSpace;
|
|
821
821
|
ImageLoader.getData(src).then((image) => {
|
|
@@ -825,7 +825,7 @@ var init_TextureLoader = __esm({
|
|
|
825
825
|
this.failedTextures.add(texture);
|
|
826
826
|
console.warn("Failed to load texture", src, error);
|
|
827
827
|
});
|
|
828
|
-
texture.format =
|
|
828
|
+
texture.format = format2;
|
|
829
829
|
texture.rotation = rotation;
|
|
830
830
|
return Textures.initTextureProps(texture);
|
|
831
831
|
}
|
|
@@ -1754,6 +1754,10 @@ var init_AssetSource = __esm({
|
|
|
1754
1754
|
AssetSource = class {
|
|
1755
1755
|
constructor() {
|
|
1756
1756
|
}
|
|
1757
|
+
/** Whether this source prevents lower-priority sources from supplying the key. Its own assets remain available. */
|
|
1758
|
+
blocks(key) {
|
|
1759
|
+
return false;
|
|
1760
|
+
}
|
|
1757
1761
|
/**
|
|
1758
1762
|
* Identifies this source's content across sessions for persistent caching. Sources that
|
|
1759
1763
|
* cannot tell whether their content changed (an unnamed archive, for example) return
|
|
@@ -1934,10 +1938,10 @@ var init_NBTHelper = __esm({
|
|
|
1934
1938
|
"src/nbt/NBTHelper.ts"() {
|
|
1935
1939
|
import_buffer2 = require("buffer");
|
|
1936
1940
|
NBTHelper = class {
|
|
1937
|
-
static async fromBuffer(data,
|
|
1941
|
+
static async fromBuffer(data, format2) {
|
|
1938
1942
|
const buffer = import_buffer2.Buffer.from(data instanceof Uint8Array ? data : new Uint8Array(data));
|
|
1939
1943
|
const prismarineNbt = await import("prismarine-nbt");
|
|
1940
|
-
const { parsed, type, metadata } = await prismarineNbt.parse(buffer,
|
|
1944
|
+
const { parsed, type, metadata } = await prismarineNbt.parse(buffer, format2);
|
|
1941
1945
|
return Object.assign(parsed, {
|
|
1942
1946
|
format: type,
|
|
1943
1947
|
metadata,
|
|
@@ -2186,6 +2190,164 @@ var init_BrowserArchiveProxy = __esm({
|
|
|
2186
2190
|
}
|
|
2187
2191
|
});
|
|
2188
2192
|
|
|
2193
|
+
// src/assets/source/archive/PackMetadata.ts
|
|
2194
|
+
function object(value, field) {
|
|
2195
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
2196
|
+
throw new Error(`Invalid ${field}: expected an object`);
|
|
2197
|
+
}
|
|
2198
|
+
return value;
|
|
2199
|
+
}
|
|
2200
|
+
function integer(value, field) {
|
|
2201
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
2202
|
+
throw new Error(`Invalid ${field}: expected a nonnegative integer`);
|
|
2203
|
+
}
|
|
2204
|
+
return value;
|
|
2205
|
+
}
|
|
2206
|
+
function format(value, field, upper = false) {
|
|
2207
|
+
const parts = Array.isArray(value) ? value : [value];
|
|
2208
|
+
if (parts.length < 1 || parts.length > 2) {
|
|
2209
|
+
throw new Error(`Invalid ${field}: expected a major version or [major, minor]`);
|
|
2210
|
+
}
|
|
2211
|
+
return [integer(parts[0], field), parts.length === 2 ? integer(parts[1], field) : upper ? Infinity : 0];
|
|
2212
|
+
}
|
|
2213
|
+
function compare(a, b) {
|
|
2214
|
+
return a[0] === b[0] ? a[1] - b[1] : a[0] - b[0];
|
|
2215
|
+
}
|
|
2216
|
+
function overlay(value, field) {
|
|
2217
|
+
const entry = object(value, field);
|
|
2218
|
+
const directory = entry.directory;
|
|
2219
|
+
if (typeof directory !== "string" || !directory || /[^-_a-zA-Z0-9.]/.test(directory) || directory === "." || directory === "..") {
|
|
2220
|
+
throw new Error(`Invalid ${field}.directory: expected a directory name without path separators`);
|
|
2221
|
+
}
|
|
2222
|
+
let min, max;
|
|
2223
|
+
if ("min_format" in entry || "max_format" in entry) {
|
|
2224
|
+
min = format(entry.min_format, `${field}.min_format`);
|
|
2225
|
+
max = format(entry.max_format, `${field}.max_format`, true);
|
|
2226
|
+
} else {
|
|
2227
|
+
const range = entry.formats;
|
|
2228
|
+
let lower, upper;
|
|
2229
|
+
if (typeof range === "number") {
|
|
2230
|
+
lower = upper = range;
|
|
2231
|
+
} else if (Array.isArray(range)) {
|
|
2232
|
+
if (range.length !== 2) throw new Error(`Invalid ${field}.formats: expected [min, max]`);
|
|
2233
|
+
[lower, upper] = range;
|
|
2234
|
+
} else {
|
|
2235
|
+
const bounds = object(range, `${field}.formats`);
|
|
2236
|
+
lower = bounds.min_inclusive;
|
|
2237
|
+
upper = bounds.max_inclusive;
|
|
2238
|
+
}
|
|
2239
|
+
min = [integer(lower, `${field}.formats.min_inclusive`), 0];
|
|
2240
|
+
max = [integer(upper, `${field}.formats.max_inclusive`), Infinity];
|
|
2241
|
+
}
|
|
2242
|
+
if (compare(min, max) > 0) throw new Error(`Invalid ${field}: minimum format exceeds maximum format`);
|
|
2243
|
+
return { directory, min, max };
|
|
2244
|
+
}
|
|
2245
|
+
function pattern(value, field) {
|
|
2246
|
+
if (value === void 0) return void 0;
|
|
2247
|
+
if (typeof value !== "string") throw new Error(`Invalid ${field}: expected a regular expression string`);
|
|
2248
|
+
try {
|
|
2249
|
+
return new RegExp(value);
|
|
2250
|
+
} catch (cause) {
|
|
2251
|
+
throw new Error(`Invalid ${field}: ${String(cause)}`);
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
var PackMetadata;
|
|
2255
|
+
var init_PackMetadata = __esm({
|
|
2256
|
+
"src/assets/source/archive/PackMetadata.ts"() {
|
|
2257
|
+
PackMetadata = class _PackMetadata {
|
|
2258
|
+
constructor(overlays, filters) {
|
|
2259
|
+
this.overlays = overlays;
|
|
2260
|
+
this.filters = filters;
|
|
2261
|
+
this.hasOverlays = overlays.length > 0;
|
|
2262
|
+
}
|
|
2263
|
+
static parse(value) {
|
|
2264
|
+
const metadata = object(value, "pack.mcmeta");
|
|
2265
|
+
let overlays = [];
|
|
2266
|
+
if ("overlays" in metadata) {
|
|
2267
|
+
const entries = object(metadata.overlays, "overlays").entries;
|
|
2268
|
+
if (!Array.isArray(entries)) throw new Error("Invalid overlays.entries: expected an array");
|
|
2269
|
+
overlays = entries.map((entry, index) => overlay(entry, `overlays.entries[${index}]`));
|
|
2270
|
+
}
|
|
2271
|
+
let filters = [];
|
|
2272
|
+
if ("filter" in metadata) {
|
|
2273
|
+
const entries = object(metadata.filter, "filter").block;
|
|
2274
|
+
if (!Array.isArray(entries)) throw new Error("Invalid filter.block: expected an array");
|
|
2275
|
+
filters = entries.map((value2, index) => {
|
|
2276
|
+
const field = `filter.block[${index}]`;
|
|
2277
|
+
const entry = object(value2, field);
|
|
2278
|
+
return { namespace: pattern(entry.namespace, `${field}.namespace`), path: pattern(entry.path, `${field}.path`) };
|
|
2279
|
+
});
|
|
2280
|
+
}
|
|
2281
|
+
return new _PackMetadata(overlays, filters);
|
|
2282
|
+
}
|
|
2283
|
+
/** Returns applicable directories in lookup order, with the last declared overlay first. */
|
|
2284
|
+
overlayDirectories(target) {
|
|
2285
|
+
const selected = format(target, "target format");
|
|
2286
|
+
return this.overlays.filter((entry) => compare(selected, entry.min) >= 0 && compare(selected, entry.max) <= 0).map((entry) => entry.directory).reverse();
|
|
2287
|
+
}
|
|
2288
|
+
blocks(namespace, path) {
|
|
2289
|
+
return this.filters.some((entry) => entry.namespace?.test(namespace) ?? true) && this.filters.some((entry) => entry.path?.test(path) ?? true);
|
|
2290
|
+
}
|
|
2291
|
+
};
|
|
2292
|
+
}
|
|
2293
|
+
});
|
|
2294
|
+
|
|
2295
|
+
// src/assets/source/archive/PackFormats.ts
|
|
2296
|
+
var PackFormats;
|
|
2297
|
+
var init_PackFormats = __esm({
|
|
2298
|
+
"src/assets/source/archive/PackFormats.ts"() {
|
|
2299
|
+
init_Requests();
|
|
2300
|
+
PackFormats = class {
|
|
2301
|
+
static {
|
|
2302
|
+
this.versions = /* @__PURE__ */ new Map();
|
|
2303
|
+
}
|
|
2304
|
+
/** Resolves pack formats from Mojang's client metadata hosted on assets.mcasset.cloud. */
|
|
2305
|
+
static async get(version, type) {
|
|
2306
|
+
let pending = this.versions.get(version);
|
|
2307
|
+
if (!pending || pending.expires <= Date.now()) {
|
|
2308
|
+
pending = {
|
|
2309
|
+
formats: this.load(version),
|
|
2310
|
+
expires: ["latest", "release", "snapshot"].includes(version) ? Date.now() + 3e5 : Infinity
|
|
2311
|
+
};
|
|
2312
|
+
this.versions.set(version, pending);
|
|
2313
|
+
}
|
|
2314
|
+
try {
|
|
2315
|
+
return (await pending.formats)[type];
|
|
2316
|
+
} catch (cause) {
|
|
2317
|
+
if (this.versions.get(version) === pending) this.versions.delete(version);
|
|
2318
|
+
const option = type === "assets" ? "resourcePackFormat" : "dataPackFormat";
|
|
2319
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
2320
|
+
throw new Error(`Could not resolve the pack format for Minecraft ${version}. Set ArchiveAssetSource ${option} explicitly. ${reason}`);
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
static async load(version) {
|
|
2324
|
+
const response = await Requests.genericRequest({
|
|
2325
|
+
url: `https://assets.mcasset.cloud/${encodeURIComponent(version)}/game-version.json`,
|
|
2326
|
+
responseType: "json"
|
|
2327
|
+
});
|
|
2328
|
+
const data = response.data;
|
|
2329
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
2330
|
+
throw new Error("Expected version metadata to be an object");
|
|
2331
|
+
}
|
|
2332
|
+
const packs = data.pack_version;
|
|
2333
|
+
if (typeof packs !== "number" && (!packs || typeof packs !== "object" || Array.isArray(packs))) {
|
|
2334
|
+
throw new Error("Expected pack_version to be a number or an object");
|
|
2335
|
+
}
|
|
2336
|
+
const format2 = (type) => {
|
|
2337
|
+
const modern = typeof packs === "object" && ["resource_major", "resource_minor", "data_major", "data_minor"].some((key) => key in packs);
|
|
2338
|
+
const major = typeof packs === "number" ? packs : packs[modern ? `${type}_major` : type];
|
|
2339
|
+
const minor = modern ? packs[`${type}_minor`] : 0;
|
|
2340
|
+
if (typeof major !== "number" || !Number.isSafeInteger(major) || major < 0 || typeof minor !== "number" || !Number.isSafeInteger(minor) || minor < 0) {
|
|
2341
|
+
throw new Error(`Invalid ${type} pack format in version metadata`);
|
|
2342
|
+
}
|
|
2343
|
+
return Object.freeze([major, minor]);
|
|
2344
|
+
};
|
|
2345
|
+
return { assets: format2("resource"), data: format2("data") };
|
|
2346
|
+
}
|
|
2347
|
+
};
|
|
2348
|
+
}
|
|
2349
|
+
});
|
|
2350
|
+
|
|
2189
2351
|
// src/assets/source/archive/ArchiveAssetSource.ts
|
|
2190
2352
|
var ArchiveAssetSource;
|
|
2191
2353
|
var init_ArchiveAssetSource = __esm({
|
|
@@ -2194,35 +2356,77 @@ var init_ArchiveAssetSource = __esm({
|
|
|
2194
2356
|
init_request();
|
|
2195
2357
|
init_HostedAssetSource();
|
|
2196
2358
|
init_BrowserArchiveProxy();
|
|
2359
|
+
init_AssetLoader();
|
|
2360
|
+
init_PackMetadata();
|
|
2361
|
+
init_PackFormats();
|
|
2197
2362
|
ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
|
|
2198
|
-
constructor(archiveProxy) {
|
|
2363
|
+
constructor(archiveProxy, options = {}) {
|
|
2199
2364
|
super();
|
|
2200
|
-
console.log(archiveProxy);
|
|
2201
2365
|
this._archiveProxy = archiveProxy;
|
|
2366
|
+
const copyFormat = (format2) => typeof format2 === "object" ? [format2[0], format2[1]] : format2;
|
|
2367
|
+
this.options = {
|
|
2368
|
+
resourcePackFormat: copyFormat(options.resourcePackFormat),
|
|
2369
|
+
dataPackFormat: copyFormat(options.dataPackFormat)
|
|
2370
|
+
};
|
|
2202
2371
|
}
|
|
2203
|
-
static blob(blob) {
|
|
2204
|
-
return new _ArchiveAssetSource(new BrowserArchiveProxy(blob));
|
|
2372
|
+
static blob(blob, options) {
|
|
2373
|
+
return new _ArchiveAssetSource(new BrowserArchiveProxy(blob), options);
|
|
2205
2374
|
}
|
|
2206
2375
|
get cacheId() {
|
|
2207
2376
|
const id = this._archiveProxy.id;
|
|
2208
|
-
|
|
2377
|
+
const formats = [this.options.resourcePackFormat ?? AssetLoader.version, this.options.dataPackFormat ?? AssetLoader.version];
|
|
2378
|
+
return id === void 0 ? void 0 : `archive-metadata:1:${id}:${JSON.stringify(formats)}`;
|
|
2209
2379
|
}
|
|
2210
2380
|
async getEntries() {
|
|
2211
|
-
return this._archiveProxy.getEntries()
|
|
2381
|
+
return this.entries ??= this._archiveProxy.getEntries().catch((error) => {
|
|
2382
|
+
this.entries = void 0;
|
|
2383
|
+
throw error;
|
|
2384
|
+
});
|
|
2212
2385
|
}
|
|
2213
2386
|
async getEntry(path) {
|
|
2214
2387
|
const entries = await this.getEntries();
|
|
2215
2388
|
return entries.find((e) => e.filename === path);
|
|
2216
2389
|
}
|
|
2390
|
+
async getMetadata(key) {
|
|
2391
|
+
try {
|
|
2392
|
+
return await (this.metadata ??= this.getEntry("pack.mcmeta").then(async (entry) => PackMetadata.parse(entry ? JSON.parse(await (await entry.getData()).text()) : {})).catch((error) => {
|
|
2393
|
+
this.metadata = void 0;
|
|
2394
|
+
throw error;
|
|
2395
|
+
}));
|
|
2396
|
+
} catch (cause) {
|
|
2397
|
+
throw new AssetLoadError(this, key, "pack.mcmeta", cause);
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
async blocks(key) {
|
|
2401
|
+
if (key.rootType !== "assets" && key.rootType !== "data") return false;
|
|
2402
|
+
const metadata = await this.getMetadata(key);
|
|
2403
|
+
const path = `${key.assetType !== void 0 ? key.assetType + "/" : ""}${key.getFullPath()}${key.extension}`;
|
|
2404
|
+
return metadata.blocks(key.namespace, path);
|
|
2405
|
+
}
|
|
2217
2406
|
async get(key, parser) {
|
|
2218
2407
|
const responseParser = HostedAssetSource.PARSER_MAP.get(parser);
|
|
2219
2408
|
return this.load(key, responseParser);
|
|
2220
2409
|
}
|
|
2221
2410
|
async load(key, parser) {
|
|
2222
2411
|
const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
|
|
2412
|
+
const version = AssetLoader.version;
|
|
2413
|
+
let selectedPath = path;
|
|
2223
2414
|
let url;
|
|
2224
2415
|
try {
|
|
2225
|
-
|
|
2416
|
+
let directories = [];
|
|
2417
|
+
if (key.rootType === "assets" || key.rootType === "data") {
|
|
2418
|
+
const metadata = await this.getMetadata(key);
|
|
2419
|
+
if (metadata.hasOverlays) {
|
|
2420
|
+
const format2 = (key.rootType === "assets" ? this.options.resourcePackFormat : this.options.dataPackFormat) ?? await PackFormats.get(version, key.rootType);
|
|
2421
|
+
directories = metadata.overlayDirectories(format2);
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
let entry;
|
|
2425
|
+
for (const directory of [...directories, ""]) {
|
|
2426
|
+
selectedPath = directory ? `${directory}/${path}` : path;
|
|
2427
|
+
entry = await this.getEntry(selectedPath);
|
|
2428
|
+
if (entry) break;
|
|
2429
|
+
}
|
|
2226
2430
|
if (!entry) {
|
|
2227
2431
|
return void 0;
|
|
2228
2432
|
}
|
|
@@ -2235,7 +2439,8 @@ var init_ArchiveAssetSource = __esm({
|
|
|
2235
2439
|
}
|
|
2236
2440
|
return await parser.parse(response);
|
|
2237
2441
|
} catch (cause) {
|
|
2238
|
-
|
|
2442
|
+
if (cause instanceof AssetLoadError) throw cause;
|
|
2443
|
+
throw new AssetLoadError(this, key, selectedPath, cause);
|
|
2239
2444
|
} finally {
|
|
2240
2445
|
if (url !== void 0) {
|
|
2241
2446
|
URL.revokeObjectURL(url);
|
|
@@ -2268,6 +2473,8 @@ var init_archive = __esm({
|
|
|
2268
2473
|
init_ArchiveEntry();
|
|
2269
2474
|
init_ArchiveProxy();
|
|
2270
2475
|
init_BrowserArchiveProxy();
|
|
2476
|
+
init_PackFormats();
|
|
2477
|
+
init_PackMetadata();
|
|
2271
2478
|
}
|
|
2272
2479
|
});
|
|
2273
2480
|
|
|
@@ -2364,13 +2571,14 @@ ${key}` : key;
|
|
|
2364
2571
|
this.addSource("mcassets", new HostedAssetSource(this.ROOT, { retryDefaults: false }));
|
|
2365
2572
|
}
|
|
2366
2573
|
static async getAll(key, parser) {
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2574
|
+
const sources = [...this._SOURCES];
|
|
2575
|
+
const results = [];
|
|
2576
|
+
for (const { source } of sources) {
|
|
2577
|
+
const asset = await source.get(key, parser);
|
|
2578
|
+
if (asset != void 0) results.push(asset);
|
|
2579
|
+
if (await source.blocks(key)) break;
|
|
2370
2580
|
}
|
|
2371
|
-
return
|
|
2372
|
-
return results.filter((r) => r != void 0);
|
|
2373
|
-
});
|
|
2581
|
+
return results;
|
|
2374
2582
|
}
|
|
2375
2583
|
/** Returns the first defined result in source-priority order, without merging assets. */
|
|
2376
2584
|
static async get(key, parser) {
|
|
@@ -2391,13 +2599,17 @@ ${key}` : key;
|
|
|
2391
2599
|
/** Tries each path within a source before considering lower-priority sources. */
|
|
2392
2600
|
static async getFirst(keys, parser) {
|
|
2393
2601
|
const sources = [...this._SOURCES];
|
|
2602
|
+
let remaining = [...keys];
|
|
2394
2603
|
for (const source of sources) {
|
|
2395
|
-
for (const key of
|
|
2604
|
+
for (const key of remaining) {
|
|
2396
2605
|
const result = await source.source.get(key, parser);
|
|
2397
2606
|
if (result !== void 0) {
|
|
2398
2607
|
return { key, asset: result };
|
|
2399
2608
|
}
|
|
2400
2609
|
}
|
|
2610
|
+
const blocked = await Promise.all(remaining.map((key) => source.source.blocks(key)));
|
|
2611
|
+
remaining = remaining.filter((_, index) => !blocked[index]);
|
|
2612
|
+
if (!remaining.length) break;
|
|
2401
2613
|
}
|
|
2402
2614
|
return void 0;
|
|
2403
2615
|
}
|
|
@@ -3512,27 +3724,27 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
3512
3724
|
for (const layer of layers) {
|
|
3513
3725
|
const objects = [];
|
|
3514
3726
|
if (poses) {
|
|
3515
|
-
layer.traverse((
|
|
3516
|
-
if (poses.has(
|
|
3727
|
+
layer.traverse((object2) => {
|
|
3728
|
+
if (poses.has(object2)) objects.push(object2);
|
|
3517
3729
|
});
|
|
3518
3730
|
} else {
|
|
3519
3731
|
for (const bone of Object.keys(animation.bones)) {
|
|
3520
|
-
const
|
|
3521
|
-
if (
|
|
3732
|
+
const object2 = layer.getObjectByName(`group:${bone}`);
|
|
3733
|
+
if (object2) objects.push(object2);
|
|
3522
3734
|
}
|
|
3523
3735
|
}
|
|
3524
|
-
for (const
|
|
3525
|
-
const bone =
|
|
3526
|
-
const pose = poses?.get(
|
|
3736
|
+
for (const object2 of objects) {
|
|
3737
|
+
const bone = object2.name.slice("group:".length);
|
|
3738
|
+
const pose = poses?.get(object2);
|
|
3527
3739
|
this.parts.push({
|
|
3528
3740
|
bone,
|
|
3529
|
-
object,
|
|
3530
|
-
position:
|
|
3531
|
-
rotation:
|
|
3532
|
-
scale:
|
|
3533
|
-
basePosition: pose ? new import_three11.Vector3(...pose.offset) :
|
|
3534
|
-
baseRotation: pose ? new import_three11.Euler(...pose.rotation, "ZYX") :
|
|
3535
|
-
baseScale: pose ? new import_three11.Vector3(...pose.scale ?? [1, 1, 1]) :
|
|
3741
|
+
object: object2,
|
|
3742
|
+
position: object2.position.clone(),
|
|
3743
|
+
rotation: object2.rotation.clone(),
|
|
3744
|
+
scale: object2.scale.clone(),
|
|
3745
|
+
basePosition: pose ? new import_three11.Vector3(...pose.offset) : object2.position.clone(),
|
|
3746
|
+
baseRotation: pose ? new import_three11.Euler(...pose.rotation, "ZYX") : object2.rotation.clone(),
|
|
3747
|
+
baseScale: pose ? new import_three11.Vector3(...pose.scale ?? [1, 1, 1]) : object2.scale.clone()
|
|
3536
3748
|
});
|
|
3537
3749
|
}
|
|
3538
3750
|
}
|
|
@@ -4059,15 +4271,15 @@ var init_SceneObject = __esm({
|
|
|
4059
4271
|
}
|
|
4060
4272
|
}
|
|
4061
4273
|
//</editor-fold>
|
|
4062
|
-
toggleObjectVisibility(
|
|
4063
|
-
if (
|
|
4274
|
+
toggleObjectVisibility(object2, visible) {
|
|
4275
|
+
if (object2) {
|
|
4064
4276
|
if (typeof visible !== "undefined") {
|
|
4065
|
-
|
|
4277
|
+
object2.visible = visible;
|
|
4066
4278
|
} else {
|
|
4067
|
-
|
|
4279
|
+
object2.visible = !object2.visible;
|
|
4068
4280
|
}
|
|
4069
4281
|
this.notifyDirty();
|
|
4070
|
-
return
|
|
4282
|
+
return object2.visible;
|
|
4071
4283
|
}
|
|
4072
4284
|
this.notifyDirty();
|
|
4073
4285
|
return false;
|
|
@@ -4358,8 +4570,8 @@ var init_EntityObject = __esm({
|
|
|
4358
4570
|
this.scrollMaterials.push({ material: mat, offset: mat.map.offset, speed: scroll });
|
|
4359
4571
|
}
|
|
4360
4572
|
}
|
|
4361
|
-
this.getLayerGroup(name)?.traverse((
|
|
4362
|
-
if (isMesh(
|
|
4573
|
+
this.getLayerGroup(name)?.traverse((object2) => {
|
|
4574
|
+
if (isMesh(object2)) object2.material = mat;
|
|
4363
4575
|
});
|
|
4364
4576
|
}));
|
|
4365
4577
|
if (!this.children.length) {
|
|
@@ -4687,8 +4899,8 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
4687
4899
|
return geometry;
|
|
4688
4900
|
}
|
|
4689
4901
|
}
|
|
4690
|
-
function computeMorphedAttributes(
|
|
4691
|
-
if (
|
|
4902
|
+
function computeMorphedAttributes(object2) {
|
|
4903
|
+
if (object2.geometry.isBufferGeometry !== true) {
|
|
4692
4904
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4693
4905
|
return null;
|
|
4694
4906
|
}
|
|
@@ -4701,11 +4913,11 @@ function computeMorphedAttributes(object) {
|
|
|
4701
4913
|
const _morphA = new import_three22.Vector3();
|
|
4702
4914
|
const _morphB = new import_three22.Vector3();
|
|
4703
4915
|
const _morphC = new import_three22.Vector3();
|
|
4704
|
-
function _calculateMorphedAttributeData(
|
|
4916
|
+
function _calculateMorphedAttributeData(object3, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4705
4917
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4706
4918
|
_vB.fromBufferAttribute(attribute, b2);
|
|
4707
4919
|
_vC.fromBufferAttribute(attribute, c2);
|
|
4708
|
-
const morphInfluences =
|
|
4920
|
+
const morphInfluences = object3.morphTargetInfluences;
|
|
4709
4921
|
if (material2.morphTargets && morphAttribute && morphInfluences) {
|
|
4710
4922
|
_morphA.set(0, 0, 0);
|
|
4711
4923
|
_morphB.set(0, 0, 0);
|
|
@@ -4731,10 +4943,10 @@ function computeMorphedAttributes(object) {
|
|
|
4731
4943
|
_vB.add(_morphB);
|
|
4732
4944
|
_vC.add(_morphC);
|
|
4733
4945
|
}
|
|
4734
|
-
if (
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4946
|
+
if (object3.isSkinnedMesh) {
|
|
4947
|
+
object3.boneTransform(a2, _vA);
|
|
4948
|
+
object3.boneTransform(b2, _vB);
|
|
4949
|
+
object3.boneTransform(c2, _vC);
|
|
4738
4950
|
}
|
|
4739
4951
|
modifiedAttributeArray[a2 * 3 + 0] = _vA.x;
|
|
4740
4952
|
modifiedAttributeArray[a2 * 3 + 1] = _vA.y;
|
|
@@ -4746,8 +4958,8 @@ function computeMorphedAttributes(object) {
|
|
|
4746
4958
|
modifiedAttributeArray[c2 * 3 + 1] = _vC.y;
|
|
4747
4959
|
modifiedAttributeArray[c2 * 3 + 2] = _vC.z;
|
|
4748
4960
|
}
|
|
4749
|
-
const geometry =
|
|
4750
|
-
const material =
|
|
4961
|
+
const geometry = object2.geometry;
|
|
4962
|
+
const material = object2.material;
|
|
4751
4963
|
let a, b, c;
|
|
4752
4964
|
const index = geometry.index;
|
|
4753
4965
|
const positionAttribute = geometry.attributes.position;
|
|
@@ -4774,7 +4986,7 @@ function computeMorphedAttributes(object) {
|
|
|
4774
4986
|
b = index.getX(j + 1);
|
|
4775
4987
|
c = index.getX(j + 2);
|
|
4776
4988
|
_calculateMorphedAttributeData(
|
|
4777
|
-
|
|
4989
|
+
object2,
|
|
4778
4990
|
groupMaterial,
|
|
4779
4991
|
positionAttribute,
|
|
4780
4992
|
morphPosition,
|
|
@@ -4785,7 +4997,7 @@ function computeMorphedAttributes(object) {
|
|
|
4785
4997
|
modifiedPosition
|
|
4786
4998
|
);
|
|
4787
4999
|
_calculateMorphedAttributeData(
|
|
4788
|
-
|
|
5000
|
+
object2,
|
|
4789
5001
|
groupMaterial,
|
|
4790
5002
|
normalAttribute,
|
|
4791
5003
|
morphNormal,
|
|
@@ -4805,7 +5017,7 @@ function computeMorphedAttributes(object) {
|
|
|
4805
5017
|
b = index.getX(i + 1);
|
|
4806
5018
|
c = index.getX(i + 2);
|
|
4807
5019
|
_calculateMorphedAttributeData(
|
|
4808
|
-
|
|
5020
|
+
object2,
|
|
4809
5021
|
material,
|
|
4810
5022
|
positionAttribute,
|
|
4811
5023
|
morphPosition,
|
|
@@ -4816,7 +5028,7 @@ function computeMorphedAttributes(object) {
|
|
|
4816
5028
|
modifiedPosition
|
|
4817
5029
|
);
|
|
4818
5030
|
_calculateMorphedAttributeData(
|
|
4819
|
-
|
|
5031
|
+
object2,
|
|
4820
5032
|
material,
|
|
4821
5033
|
normalAttribute,
|
|
4822
5034
|
morphNormal,
|
|
@@ -4840,7 +5052,7 @@ function computeMorphedAttributes(object) {
|
|
|
4840
5052
|
b = j + 1;
|
|
4841
5053
|
c = j + 2;
|
|
4842
5054
|
_calculateMorphedAttributeData(
|
|
4843
|
-
|
|
5055
|
+
object2,
|
|
4844
5056
|
groupMaterial,
|
|
4845
5057
|
positionAttribute,
|
|
4846
5058
|
morphPosition,
|
|
@@ -4851,7 +5063,7 @@ function computeMorphedAttributes(object) {
|
|
|
4851
5063
|
modifiedPosition
|
|
4852
5064
|
);
|
|
4853
5065
|
_calculateMorphedAttributeData(
|
|
4854
|
-
|
|
5066
|
+
object2,
|
|
4855
5067
|
groupMaterial,
|
|
4856
5068
|
normalAttribute,
|
|
4857
5069
|
morphNormal,
|
|
@@ -4871,7 +5083,7 @@ function computeMorphedAttributes(object) {
|
|
|
4871
5083
|
b = i + 1;
|
|
4872
5084
|
c = i + 2;
|
|
4873
5085
|
_calculateMorphedAttributeData(
|
|
4874
|
-
|
|
5086
|
+
object2,
|
|
4875
5087
|
material,
|
|
4876
5088
|
positionAttribute,
|
|
4877
5089
|
morphPosition,
|
|
@@ -4882,7 +5094,7 @@ function computeMorphedAttributes(object) {
|
|
|
4882
5094
|
modifiedPosition
|
|
4883
5095
|
);
|
|
4884
5096
|
_calculateMorphedAttributeData(
|
|
4885
|
-
|
|
5097
|
+
object2,
|
|
4886
5098
|
material,
|
|
4887
5099
|
normalAttribute,
|
|
4888
5100
|
morphNormal,
|
|
@@ -5196,13 +5408,13 @@ var init_ModelObject = __esm({
|
|
|
5196
5408
|
transform.multiply(new import_three25.Matrix4().makeTranslation(-8, -8, -8));
|
|
5197
5409
|
try {
|
|
5198
5410
|
for (const part of parts) {
|
|
5199
|
-
const
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
this.add(
|
|
5204
|
-
await
|
|
5205
|
-
|
|
5411
|
+
const object2 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
|
|
5412
|
+
object2.matrix.copy(transform).multiply(part.transform);
|
|
5413
|
+
object2.matrixWorldNeedsUpdate = true;
|
|
5414
|
+
object2.matrixAutoUpdate = false;
|
|
5415
|
+
this.add(object2);
|
|
5416
|
+
await object2.init();
|
|
5417
|
+
object2.iterateAllMeshes((mesh) => {
|
|
5206
5418
|
const source = mesh.material;
|
|
5207
5419
|
let material = this.specialMaterials.get(source);
|
|
5208
5420
|
if (!material) {
|
|
@@ -5213,7 +5425,7 @@ var init_ModelObject = __esm({
|
|
|
5213
5425
|
mesh.material = material;
|
|
5214
5426
|
});
|
|
5215
5427
|
for (const [name, rotation] of Object.entries(part.rotations)) {
|
|
5216
|
-
|
|
5428
|
+
object2.getGroupByName(name)?.rotation.set(...rotation, "ZYX");
|
|
5217
5429
|
}
|
|
5218
5430
|
}
|
|
5219
5431
|
} catch (error) {
|
|
@@ -5688,6 +5900,8 @@ __export(index_node_exports, {
|
|
|
5688
5900
|
NodeCache: () => NodeCache,
|
|
5689
5901
|
NodeEnv: () => NodeEnv,
|
|
5690
5902
|
OrbitControls: () => OrbitControls,
|
|
5903
|
+
PackFormats: () => PackFormats,
|
|
5904
|
+
PackMetadata: () => PackMetadata,
|
|
5691
5905
|
PersistentCache: () => PersistentCache,
|
|
5692
5906
|
Renderer: () => Renderer,
|
|
5693
5907
|
RequestError: () => RequestError,
|
|
@@ -6159,7 +6373,7 @@ var OBJExporter = class {
|
|
|
6159
6373
|
* @param {Object3D} object - The 3D object to export.
|
|
6160
6374
|
* @return {string} The exported OBJ.
|
|
6161
6375
|
*/
|
|
6162
|
-
parse(
|
|
6376
|
+
parse(object2) {
|
|
6163
6377
|
let output = "";
|
|
6164
6378
|
let indexVertex = 0;
|
|
6165
6379
|
let indexVertexUvs = 0;
|
|
@@ -6278,7 +6492,7 @@ var OBJExporter = class {
|
|
|
6278
6492
|
}
|
|
6279
6493
|
indexVertex += nbVertex;
|
|
6280
6494
|
}
|
|
6281
|
-
|
|
6495
|
+
object2.traverse(function(child) {
|
|
6282
6496
|
if (child.isMesh === true) {
|
|
6283
6497
|
parseMesh(child);
|
|
6284
6498
|
}
|
|
@@ -6306,9 +6520,9 @@ var PLYExporter = class {
|
|
|
6306
6520
|
* @param {PLYExporter~Options} options - The export options.
|
|
6307
6521
|
* @return {?(string|ArrayBuffer)} The exported PLY.
|
|
6308
6522
|
*/
|
|
6309
|
-
parse(
|
|
6523
|
+
parse(object2, onDone, options = {}) {
|
|
6310
6524
|
function traverseMeshes(cb) {
|
|
6311
|
-
|
|
6525
|
+
object2.traverse(function(child) {
|
|
6312
6526
|
if (child.isMesh === true || child.isPoints) {
|
|
6313
6527
|
const mesh = child;
|
|
6314
6528
|
const geometry = mesh.geometry;
|
|
@@ -6341,7 +6555,7 @@ var PLYExporter = class {
|
|
|
6341
6555
|
for (const name of customAttributeNames) customTypes[name] = "float";
|
|
6342
6556
|
let vertexCount = 0;
|
|
6343
6557
|
let faceCount = 0;
|
|
6344
|
-
|
|
6558
|
+
object2.traverse(function(child) {
|
|
6345
6559
|
if (child.isMesh === true) {
|
|
6346
6560
|
const mesh = child;
|
|
6347
6561
|
const geometry = mesh.geometry;
|
|
@@ -7129,12 +7343,12 @@ var GLTFWriter = class {
|
|
|
7129
7343
|
* @param {THREE.Object3D|THREE.Material|THREE.BufferGeometry|THREE.AnimationClip} object
|
|
7130
7344
|
* @param {Object} objectDef
|
|
7131
7345
|
*/
|
|
7132
|
-
serializeUserData(
|
|
7133
|
-
if (Object.keys(
|
|
7346
|
+
serializeUserData(object2, objectDef) {
|
|
7347
|
+
if (Object.keys(object2.userData).length === 0) return;
|
|
7134
7348
|
const options = this.options;
|
|
7135
7349
|
const extensionsUsed = this.extensionsUsed;
|
|
7136
7350
|
try {
|
|
7137
|
-
const json = JSON.parse(JSON.stringify(
|
|
7351
|
+
const json = JSON.parse(JSON.stringify(object2.userData));
|
|
7138
7352
|
if (options.includeCustomExtensions && json.gltfExtensions) {
|
|
7139
7353
|
if (objectDef.extensions === void 0) objectDef.extensions = {};
|
|
7140
7354
|
for (const extensionName in json.gltfExtensions) {
|
|
@@ -7145,7 +7359,7 @@ var GLTFWriter = class {
|
|
|
7145
7359
|
}
|
|
7146
7360
|
if (Object.keys(json).length > 0) objectDef.extras = json;
|
|
7147
7361
|
} catch (error) {
|
|
7148
|
-
console.warn("THREE.GLTFExporter: userData of '" +
|
|
7362
|
+
console.warn("THREE.GLTFExporter: userData of '" + object2.name + "' won't be serialized because of JSON.stringify error - " + error.message);
|
|
7149
7363
|
}
|
|
7150
7364
|
}
|
|
7151
7365
|
/**
|
|
@@ -7518,7 +7732,7 @@ var GLTFWriter = class {
|
|
|
7518
7732
|
* @param {string} mimeType export format
|
|
7519
7733
|
* @return {number} Index of the processed texture in the "images" array
|
|
7520
7734
|
*/
|
|
7521
|
-
processImage(image,
|
|
7735
|
+
processImage(image, format2, flipY, mimeType = "image/png") {
|
|
7522
7736
|
if (image !== null) {
|
|
7523
7737
|
const writer = this;
|
|
7524
7738
|
const cache = writer.cache;
|
|
@@ -7542,8 +7756,8 @@ var GLTFWriter = class {
|
|
|
7542
7756
|
ctx.scale(1, -1);
|
|
7543
7757
|
}
|
|
7544
7758
|
if (image.data !== void 0) {
|
|
7545
|
-
if (
|
|
7546
|
-
console.error("GLTFExporter: Only RGBAFormat is supported.",
|
|
7759
|
+
if (format2 !== import_three18.RGBAFormat) {
|
|
7760
|
+
console.error("GLTFExporter: Only RGBAFormat is supported.", format2);
|
|
7547
7761
|
}
|
|
7548
7762
|
if (image.width > options.maxTextureSize || image.height > options.maxTextureSize) {
|
|
7549
7763
|
console.warn("GLTFExporter: Image size is bigger than maxTextureSize", image);
|
|
@@ -8071,13 +8285,13 @@ var GLTFWriter = class {
|
|
|
8071
8285
|
* @param {THREE.Object3D} object
|
|
8072
8286
|
* @return {?number}
|
|
8073
8287
|
*/
|
|
8074
|
-
processSkin(
|
|
8288
|
+
processSkin(object2) {
|
|
8075
8289
|
const json = this.json;
|
|
8076
8290
|
const nodeMap = this.nodeMap;
|
|
8077
|
-
const node = json.nodes[nodeMap.get(
|
|
8078
|
-
const skeleton =
|
|
8291
|
+
const node = json.nodes[nodeMap.get(object2)];
|
|
8292
|
+
const skeleton = object2.skeleton;
|
|
8079
8293
|
if (skeleton === void 0) return null;
|
|
8080
|
-
const rootJoint =
|
|
8294
|
+
const rootJoint = object2.skeleton.bones[0];
|
|
8081
8295
|
if (rootJoint === void 0) return null;
|
|
8082
8296
|
const joints = [];
|
|
8083
8297
|
const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
|
|
@@ -8085,7 +8299,7 @@ var GLTFWriter = class {
|
|
|
8085
8299
|
for (let i = 0; i < skeleton.bones.length; ++i) {
|
|
8086
8300
|
joints.push(nodeMap.get(skeleton.bones[i]));
|
|
8087
8301
|
temporaryBoneInverse.copy(skeleton.boneInverses[i]);
|
|
8088
|
-
temporaryBoneInverse.multiply(
|
|
8302
|
+
temporaryBoneInverse.multiply(object2.bindMatrix).toArray(inverseBindMatrices, i * 16);
|
|
8089
8303
|
}
|
|
8090
8304
|
if (json.skins === void 0) json.skins = [];
|
|
8091
8305
|
json.skins.push({
|
|
@@ -8101,19 +8315,19 @@ var GLTFWriter = class {
|
|
|
8101
8315
|
* @param {THREE.Object3D} object Object3D to processNodeAsync
|
|
8102
8316
|
* @return {Promise<number>} Index of the node in the nodes list
|
|
8103
8317
|
*/
|
|
8104
|
-
async processNodeAsync(
|
|
8318
|
+
async processNodeAsync(object2) {
|
|
8105
8319
|
const json = this.json;
|
|
8106
8320
|
const options = this.options;
|
|
8107
8321
|
const nodeMap = this.nodeMap;
|
|
8108
8322
|
if (!json.nodes) json.nodes = [];
|
|
8109
|
-
if (
|
|
8110
|
-
return await this._processNodeWithPivotAsync(
|
|
8323
|
+
if (object2.pivot !== null) {
|
|
8324
|
+
return await this._processNodeWithPivotAsync(object2);
|
|
8111
8325
|
}
|
|
8112
8326
|
const nodeDef = {};
|
|
8113
8327
|
if (options.trs) {
|
|
8114
|
-
const rotation =
|
|
8115
|
-
const position =
|
|
8116
|
-
const scale =
|
|
8328
|
+
const rotation = object2.quaternion.toArray();
|
|
8329
|
+
const position = object2.position.toArray();
|
|
8330
|
+
const scale = object2.scale.toArray();
|
|
8117
8331
|
if (!equalArray(rotation, [0, 0, 0, 1])) {
|
|
8118
8332
|
nodeDef.rotation = rotation;
|
|
8119
8333
|
}
|
|
@@ -8124,28 +8338,28 @@ var GLTFWriter = class {
|
|
|
8124
8338
|
nodeDef.scale = scale;
|
|
8125
8339
|
}
|
|
8126
8340
|
} else {
|
|
8127
|
-
if (
|
|
8128
|
-
|
|
8341
|
+
if (object2.matrixAutoUpdate) {
|
|
8342
|
+
object2.updateMatrix();
|
|
8129
8343
|
}
|
|
8130
|
-
if (isIdentityMatrix(
|
|
8131
|
-
nodeDef.matrix =
|
|
8344
|
+
if (isIdentityMatrix(object2.matrix) === false) {
|
|
8345
|
+
nodeDef.matrix = object2.matrix.elements;
|
|
8132
8346
|
}
|
|
8133
8347
|
}
|
|
8134
|
-
if (
|
|
8135
|
-
this.serializeUserData(
|
|
8136
|
-
if (
|
|
8137
|
-
const meshIndex = await this.processMeshAsync(
|
|
8348
|
+
if (object2.name !== "") nodeDef.name = String(object2.name);
|
|
8349
|
+
this.serializeUserData(object2, nodeDef);
|
|
8350
|
+
if (object2.isMesh || object2.isLine || object2.isPoints) {
|
|
8351
|
+
const meshIndex = await this.processMeshAsync(object2);
|
|
8138
8352
|
if (meshIndex !== null) nodeDef.mesh = meshIndex;
|
|
8139
|
-
} else if (
|
|
8140
|
-
nodeDef.camera = this.processCamera(
|
|
8353
|
+
} else if (object2.isCamera) {
|
|
8354
|
+
nodeDef.camera = this.processCamera(object2);
|
|
8141
8355
|
}
|
|
8142
|
-
if (
|
|
8356
|
+
if (object2.isSkinnedMesh) this.skins.push(object2);
|
|
8143
8357
|
const nodeIndex = json.nodes.push(nodeDef) - 1;
|
|
8144
|
-
nodeMap.set(
|
|
8145
|
-
if (
|
|
8358
|
+
nodeMap.set(object2, nodeIndex);
|
|
8359
|
+
if (object2.children.length > 0) {
|
|
8146
8360
|
const children = [];
|
|
8147
|
-
for (let i = 0, l =
|
|
8148
|
-
const child =
|
|
8361
|
+
for (let i = 0, l = object2.children.length; i < l; i++) {
|
|
8362
|
+
const child = object2.children[i];
|
|
8149
8363
|
if (child.visible || options.onlyVisible === false) {
|
|
8150
8364
|
const childNodeIndex = await this.processNodeAsync(child);
|
|
8151
8365
|
if (childNodeIndex !== null) children.push(childNodeIndex);
|
|
@@ -8154,7 +8368,7 @@ var GLTFWriter = class {
|
|
|
8154
8368
|
if (children.length > 0) nodeDef.children = children;
|
|
8155
8369
|
}
|
|
8156
8370
|
await this._invokeAllAsync(function(ext) {
|
|
8157
|
-
ext.writeNode && ext.writeNode(
|
|
8371
|
+
ext.writeNode && ext.writeNode(object2, nodeDef);
|
|
8158
8372
|
});
|
|
8159
8373
|
return nodeIndex;
|
|
8160
8374
|
}
|
|
@@ -8163,19 +8377,19 @@ var GLTFWriter = class {
|
|
|
8163
8377
|
* @param {THREE.Object3D} object Object3D with pivot
|
|
8164
8378
|
* @return {Promise<number>} Index of the container node
|
|
8165
8379
|
*/
|
|
8166
|
-
async _processNodeWithPivotAsync(
|
|
8380
|
+
async _processNodeWithPivotAsync(object2) {
|
|
8167
8381
|
const json = this.json;
|
|
8168
8382
|
const options = this.options;
|
|
8169
8383
|
const nodeMap = this.nodeMap;
|
|
8170
|
-
const pivot =
|
|
8384
|
+
const pivot = object2.pivot;
|
|
8171
8385
|
const containerDef = {};
|
|
8172
|
-
const rotation =
|
|
8386
|
+
const rotation = object2.quaternion.toArray();
|
|
8173
8387
|
const position = [
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8388
|
+
object2.position.x + pivot.x,
|
|
8389
|
+
object2.position.y + pivot.y,
|
|
8390
|
+
object2.position.z + pivot.z
|
|
8177
8391
|
];
|
|
8178
|
-
const scale =
|
|
8392
|
+
const scale = object2.scale.toArray();
|
|
8179
8393
|
if (!equalArray(rotation, [0, 0, 0, 1])) {
|
|
8180
8394
|
containerDef.rotation = rotation;
|
|
8181
8395
|
}
|
|
@@ -8186,28 +8400,28 @@ var GLTFWriter = class {
|
|
|
8186
8400
|
containerDef.scale = scale;
|
|
8187
8401
|
}
|
|
8188
8402
|
containerDef.extras = { pivot: pivot.toArray() };
|
|
8189
|
-
if (
|
|
8190
|
-
this.serializeUserData(
|
|
8403
|
+
if (object2.name !== "") containerDef.name = String(object2.name);
|
|
8404
|
+
this.serializeUserData(object2, containerDef);
|
|
8191
8405
|
const containerIndex = json.nodes.push(containerDef) - 1;
|
|
8192
|
-
nodeMap.set(
|
|
8406
|
+
nodeMap.set(object2, containerIndex);
|
|
8193
8407
|
const childDef = {};
|
|
8194
8408
|
const childPosition = [-pivot.x, -pivot.y, -pivot.z];
|
|
8195
8409
|
if (!equalArray(childPosition, [0, 0, 0])) {
|
|
8196
8410
|
childDef.translation = childPosition;
|
|
8197
8411
|
}
|
|
8198
|
-
if (
|
|
8199
|
-
const meshIndex = await this.processMeshAsync(
|
|
8412
|
+
if (object2.isMesh || object2.isLine || object2.isPoints) {
|
|
8413
|
+
const meshIndex = await this.processMeshAsync(object2);
|
|
8200
8414
|
if (meshIndex !== null) childDef.mesh = meshIndex;
|
|
8201
|
-
} else if (
|
|
8202
|
-
childDef.camera = this.processCamera(
|
|
8415
|
+
} else if (object2.isCamera) {
|
|
8416
|
+
childDef.camera = this.processCamera(object2);
|
|
8203
8417
|
}
|
|
8204
|
-
if (
|
|
8418
|
+
if (object2.isSkinnedMesh) this.skins.push(object2);
|
|
8205
8419
|
const childIndex = json.nodes.push(childDef) - 1;
|
|
8206
8420
|
const containerChildren = [childIndex];
|
|
8207
|
-
if (
|
|
8421
|
+
if (object2.children.length > 0) {
|
|
8208
8422
|
const grandchildren = [];
|
|
8209
|
-
for (let i = 0, l =
|
|
8210
|
-
const child =
|
|
8423
|
+
for (let i = 0, l = object2.children.length; i < l; i++) {
|
|
8424
|
+
const child = object2.children[i];
|
|
8211
8425
|
if (child.visible || options.onlyVisible === false) {
|
|
8212
8426
|
const childNodeIndex = await this.processNodeAsync(child);
|
|
8213
8427
|
if (childNodeIndex !== null) grandchildren.push(childNodeIndex);
|
|
@@ -8217,7 +8431,7 @@ var GLTFWriter = class {
|
|
|
8217
8431
|
}
|
|
8218
8432
|
containerDef.children = containerChildren;
|
|
8219
8433
|
await this._invokeAllAsync(function(ext) {
|
|
8220
|
-
ext.writeNode && ext.writeNode(
|
|
8434
|
+
ext.writeNode && ext.writeNode(object2, containerDef);
|
|
8221
8435
|
});
|
|
8222
8436
|
return containerIndex;
|
|
8223
8437
|
}
|
|
@@ -8660,10 +8874,10 @@ var GLTFMeshGpuInstancing = class {
|
|
|
8660
8874
|
this.writer = writer;
|
|
8661
8875
|
this.name = "EXT_mesh_gpu_instancing";
|
|
8662
8876
|
}
|
|
8663
|
-
writeNode(
|
|
8664
|
-
if (!
|
|
8877
|
+
writeNode(object2, nodeDef) {
|
|
8878
|
+
if (!object2.isInstancedMesh) return;
|
|
8665
8879
|
const writer = this.writer;
|
|
8666
|
-
const mesh =
|
|
8880
|
+
const mesh = object2;
|
|
8667
8881
|
const translationAttr = new Float32Array(mesh.count * 3);
|
|
8668
8882
|
const rotationAttr = new Float32Array(mesh.count * 4);
|
|
8669
8883
|
const scaleAttr = new Float32Array(mesh.count * 3);
|
|
@@ -8853,8 +9067,8 @@ var SceneExporter = class {
|
|
|
8853
9067
|
}
|
|
8854
9068
|
}
|
|
8855
9069
|
};
|
|
8856
|
-
function localMatrix(
|
|
8857
|
-
return
|
|
9070
|
+
function localMatrix(object2) {
|
|
9071
|
+
return object2.matrixAutoUpdate ? new import_three19.Matrix4().compose(object2.position, object2.quaternion, object2.scale) : object2.matrix.clone();
|
|
8858
9072
|
}
|
|
8859
9073
|
function createSnapshot(root, gltf, bakeColors = false) {
|
|
8860
9074
|
const scene = new import_three19.Scene();
|
|
@@ -8958,10 +9172,10 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8958
9172
|
scene.add(copy);
|
|
8959
9173
|
}
|
|
8960
9174
|
};
|
|
8961
|
-
const visit = (
|
|
8962
|
-
if (!
|
|
8963
|
-
const world = parentWorld.clone().multiply(localMatrix(
|
|
8964
|
-
const mesh =
|
|
9175
|
+
const visit = (object2, parentWorld) => {
|
|
9176
|
+
if (!object2.visible) return;
|
|
9177
|
+
const world = parentWorld.clone().multiply(localMatrix(object2));
|
|
9178
|
+
const mesh = object2;
|
|
8965
9179
|
if (mesh.isMesh) {
|
|
8966
9180
|
const instanced = mesh;
|
|
8967
9181
|
if (instanced.isInstancedMesh) {
|
|
@@ -8975,7 +9189,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8975
9189
|
addMesh(mesh, world);
|
|
8976
9190
|
}
|
|
8977
9191
|
}
|
|
8978
|
-
for (const child of
|
|
9192
|
+
for (const child of object2.children) visit(child, world);
|
|
8979
9193
|
};
|
|
8980
9194
|
try {
|
|
8981
9195
|
const ancestors = [];
|
|
@@ -9207,11 +9421,11 @@ var GuiHelper = class {
|
|
|
9207
9421
|
switch (recipe.type) {
|
|
9208
9422
|
case "minecraft:crafting_shaped":
|
|
9209
9423
|
case "crafting_shaped": {
|
|
9210
|
-
const
|
|
9211
|
-
if (!
|
|
9424
|
+
const pattern2 = recipe.pattern;
|
|
9425
|
+
if (!pattern2.length || pattern2.length > 3 || !pattern2[0].length || pattern2[0].length > 3 || pattern2.some((row) => row.length !== pattern2[0].length)) {
|
|
9212
9426
|
throw new Error("Crafting patterns must be rectangular, with 1\u20133 rows and columns");
|
|
9213
9427
|
}
|
|
9214
|
-
const cells =
|
|
9428
|
+
const cells = pattern2.flatMap((row, y) => row.split("").map((symbol, x) => ({ symbol, x, y }))).filter((cell) => cell.symbol !== " ");
|
|
9215
9429
|
if (!cells.length) throw new Error("Crafting patterns must contain an ingredient");
|
|
9216
9430
|
const minX = Math.min(...cells.map((cell) => cell.x)), maxX = Math.max(...cells.map((cell) => cell.x));
|
|
9217
9431
|
const minY = Math.min(...cells.map((cell) => cell.y)), maxY = Math.max(...cells.map((cell) => cell.y));
|
|
@@ -9623,29 +9837,29 @@ var SceneInspector = class {
|
|
|
9623
9837
|
this.objectControlsContainer.innerHTML = "";
|
|
9624
9838
|
this.addControls(targetObject, targetIntersection, instance);
|
|
9625
9839
|
}
|
|
9626
|
-
addControls(
|
|
9840
|
+
addControls(object2, intersection, instance) {
|
|
9627
9841
|
const container = document.createElement("div");
|
|
9628
9842
|
container.append(this.separator("Select Parent/Child"));
|
|
9629
|
-
if (
|
|
9630
|
-
container.append(this.buttonControl("Select Parent " +
|
|
9631
|
-
this.selectObject(
|
|
9843
|
+
if (object2.parent) {
|
|
9844
|
+
container.append(this.buttonControl("Select Parent " + object2.parent.constructor.name + " " + object2.parent.name, "P", () => {
|
|
9845
|
+
this.selectObject(object2.parent, intersection, instance);
|
|
9632
9846
|
}));
|
|
9633
9847
|
}
|
|
9634
|
-
if (
|
|
9848
|
+
if (object2.children.length > 0) {
|
|
9635
9849
|
let i = 1;
|
|
9636
|
-
for (let child of
|
|
9850
|
+
for (let child of object2.children) {
|
|
9637
9851
|
container.append(this.buttonControl("Select Child " + child.constructor.name + " " + child.name, "C" + i++, () => {
|
|
9638
9852
|
this.selectObject(child, intersection, instance);
|
|
9639
9853
|
}));
|
|
9640
9854
|
}
|
|
9641
9855
|
}
|
|
9642
9856
|
container.append(this.separator());
|
|
9643
|
-
const selectedInstance = instance && (
|
|
9857
|
+
const selectedInstance = instance && (object2 === instance.instanceable || object2 === intersection?.object) ? instance : void 0;
|
|
9644
9858
|
if (!selectedInstance) {
|
|
9645
|
-
container.append(this.toggleControl("Visibility", "V",
|
|
9859
|
+
container.append(this.toggleControl("Visibility", "V", object2.visible, (v) => object2.visible = v));
|
|
9646
9860
|
}
|
|
9647
9861
|
container.append(this.separator("Mesh"));
|
|
9648
|
-
this.addObjectControls(
|
|
9862
|
+
this.addObjectControls(object2, intersection, container, selectedInstance);
|
|
9649
9863
|
container.append(this.separator());
|
|
9650
9864
|
this.objectControlsContainer.append(container);
|
|
9651
9865
|
}
|
|
@@ -10216,8 +10430,8 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
10216
10430
|
return false;
|
|
10217
10431
|
}
|
|
10218
10432
|
return this._models.some((model) => {
|
|
10219
|
-
const
|
|
10220
|
-
return
|
|
10433
|
+
const object2 = isInstanceReference(model) ? model.instanceable : model;
|
|
10434
|
+
return object2.isOpaqueFullCube && this.getModelCullMask(model, 63) === 63;
|
|
10221
10435
|
});
|
|
10222
10436
|
}
|
|
10223
10437
|
getModelMatrix(model) {
|
|
@@ -10226,8 +10440,8 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
10226
10440
|
return model.matrix.clone();
|
|
10227
10441
|
}
|
|
10228
10442
|
getModelCullMask(model, worldMask) {
|
|
10229
|
-
const
|
|
10230
|
-
if (
|
|
10443
|
+
const object2 = isInstanceReference(model) ? model.instanceable : model;
|
|
10444
|
+
if (object2.options.displayPosition) return 0;
|
|
10231
10445
|
const position = new import_three32.Vector3();
|
|
10232
10446
|
const rotation = new import_three32.Quaternion();
|
|
10233
10447
|
const scale = new import_three32.Vector3();
|
|
@@ -10244,14 +10458,14 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
10244
10458
|
replacements.push(model);
|
|
10245
10459
|
continue;
|
|
10246
10460
|
}
|
|
10247
|
-
const
|
|
10461
|
+
const object2 = isInstanceReference(model) ? model.instanceable : model;
|
|
10248
10462
|
const cullMask = this.getModelCullMask(model, worldMask);
|
|
10249
|
-
if (cullMask === (
|
|
10463
|
+
if (cullMask === (object2.options.cullMask ?? 0)) {
|
|
10250
10464
|
replacements.push(model);
|
|
10251
10465
|
continue;
|
|
10252
10466
|
}
|
|
10253
10467
|
const matrix = this.getModelMatrix(model);
|
|
10254
|
-
const replacement = await this.scene.addModel(
|
|
10468
|
+
const replacement = await this.scene.addModel(object2.originalModel, { ...object2.options, cullMask });
|
|
10255
10469
|
replacements.push(replacement);
|
|
10256
10470
|
if (isInstanceReference(replacement)) {
|
|
10257
10471
|
replacement.setMatrix(matrix);
|
|
@@ -10259,8 +10473,8 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
10259
10473
|
replacement.matrix.copy(matrix);
|
|
10260
10474
|
replacement.matrixWorldNeedsUpdate = true;
|
|
10261
10475
|
matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
10262
|
-
replacement.matrixAutoUpdate =
|
|
10263
|
-
replacement.visible =
|
|
10476
|
+
replacement.matrixAutoUpdate = object2.matrixAutoUpdate;
|
|
10477
|
+
replacement.visible = object2.visible;
|
|
10264
10478
|
}
|
|
10265
10479
|
}
|
|
10266
10480
|
} catch (error) {
|
|
@@ -12178,9 +12392,9 @@ var SchematicParser = class {
|
|
|
12178
12392
|
* Parses a legacy schematic using custom mappings before the bundled defaults.
|
|
12179
12393
|
* Keys are `id:metadata`; values are block states such as `minecraft:oak_log[axis=x]`.
|
|
12180
12394
|
*/
|
|
12181
|
-
static async parse(nbt, customMappings = {}) {
|
|
12395
|
+
static async parse(nbt, customMappings = {}, options = {}) {
|
|
12182
12396
|
const tags = nbt.value;
|
|
12183
|
-
if (tags.Materials?.type !== "string" || tags.Materials.value !== "Alpha") {
|
|
12397
|
+
if (!options.lenient && (tags.Materials?.type !== "string" || tags.Materials.value !== "Alpha")) {
|
|
12184
12398
|
throw new MineRenderError("Schematic Materials must be Alpha");
|
|
12185
12399
|
}
|
|
12186
12400
|
const size = ["Width", "Height", "Length"].map((name) => {
|
|
@@ -12221,8 +12435,16 @@ var SchematicParser = class {
|
|
|
12221
12435
|
const id = high << 8 | ids.value[index] & 255;
|
|
12222
12436
|
const metadata = data.value[index] & 255;
|
|
12223
12437
|
const key = `${id}:${metadata}`;
|
|
12224
|
-
|
|
12225
|
-
if (!mapped
|
|
12438
|
+
let mapped = customMappings[key] ?? mapping[key];
|
|
12439
|
+
if (!mapped && options.lenient) {
|
|
12440
|
+
mapped = customMappings[`${id}:0`] ?? mapping[`${id}:0`];
|
|
12441
|
+
}
|
|
12442
|
+
if (!mapped) {
|
|
12443
|
+
if (options.lenient) {
|
|
12444
|
+
continue;
|
|
12445
|
+
}
|
|
12446
|
+
throw new MineRenderError(`Unsupported legacy block ${id}:${metadata} at schematic index ${index}`);
|
|
12447
|
+
}
|
|
12226
12448
|
const [type, state] = mapped.split("[");
|
|
12227
12449
|
if (type === "minecraft:air") continue;
|
|
12228
12450
|
const properties = {};
|
|
@@ -13383,53 +13605,53 @@ var MineRenderScene = class _MineRenderScene extends import_three34.Scene {
|
|
|
13383
13605
|
this.DEFAULT_OPTIONS = (0, import_ts_deepmerge8.default)({}, {});
|
|
13384
13606
|
}
|
|
13385
13607
|
add(...objects) {
|
|
13386
|
-
for (const
|
|
13608
|
+
for (const object2 of objects) {
|
|
13387
13609
|
this.dirty = true;
|
|
13388
13610
|
try {
|
|
13389
|
-
super.add(
|
|
13611
|
+
super.add(object2);
|
|
13390
13612
|
} finally {
|
|
13391
|
-
if (
|
|
13392
|
-
this.updateObjectRegistration(
|
|
13613
|
+
if (object2?.isObject3D && object2 !== this) {
|
|
13614
|
+
this.updateObjectRegistration(object2, object2.parent === this);
|
|
13393
13615
|
}
|
|
13394
13616
|
}
|
|
13395
13617
|
}
|
|
13396
13618
|
return this;
|
|
13397
13619
|
}
|
|
13398
13620
|
remove(...objects) {
|
|
13399
|
-
for (const
|
|
13400
|
-
if (!this.children.includes(
|
|
13621
|
+
for (const object2 of objects) {
|
|
13622
|
+
if (!this.children.includes(object2)) continue;
|
|
13401
13623
|
this.dirty = true;
|
|
13402
|
-
this.updateObjectRegistration(
|
|
13624
|
+
this.updateObjectRegistration(object2, false);
|
|
13403
13625
|
try {
|
|
13404
|
-
super.remove(
|
|
13626
|
+
super.remove(object2);
|
|
13405
13627
|
} finally {
|
|
13406
|
-
this.updateObjectRegistration(
|
|
13628
|
+
this.updateObjectRegistration(object2, object2.parent === this);
|
|
13407
13629
|
}
|
|
13408
13630
|
}
|
|
13409
13631
|
return this;
|
|
13410
13632
|
}
|
|
13411
|
-
updateObjectRegistration(
|
|
13412
|
-
if (this.observedObjects.has(
|
|
13413
|
-
const observable =
|
|
13633
|
+
updateObjectRegistration(object2, attached) {
|
|
13634
|
+
if (this.observedObjects.has(object2) === attached) return;
|
|
13635
|
+
const observable = object2;
|
|
13414
13636
|
if (attached) {
|
|
13415
|
-
this.observedObjects.add(
|
|
13637
|
+
this.observedObjects.add(object2);
|
|
13416
13638
|
observable.addEventListener("change", this.onObjectChange);
|
|
13417
13639
|
} else {
|
|
13418
|
-
this.observedObjects.delete(
|
|
13640
|
+
this.observedObjects.delete(object2);
|
|
13419
13641
|
observable.removeEventListener("change", this.onObjectChange);
|
|
13420
13642
|
}
|
|
13421
13643
|
const change = attached ? 1 : -1;
|
|
13422
13644
|
this.stats.objectCount += change;
|
|
13423
|
-
if (isSceneObject(
|
|
13645
|
+
if (isSceneObject(object2)) {
|
|
13424
13646
|
this.stats.sceneObjectCount += change;
|
|
13425
13647
|
}
|
|
13426
13648
|
}
|
|
13427
|
-
async initAndAdd(...
|
|
13649
|
+
async initAndAdd(...object2) {
|
|
13428
13650
|
this.dirty = true;
|
|
13429
|
-
for (let obj of
|
|
13651
|
+
for (let obj of object2) {
|
|
13430
13652
|
await obj.init();
|
|
13431
13653
|
}
|
|
13432
|
-
return this.add(...
|
|
13654
|
+
return this.add(...object2);
|
|
13433
13655
|
}
|
|
13434
13656
|
async addSceneObject(asset, objectSupplier, _options, parent = this) {
|
|
13435
13657
|
this.dirty = true;
|
|
@@ -13508,11 +13730,11 @@ var _changeEvent = { type: "change" };
|
|
|
13508
13730
|
var _startEvent = { type: "start" };
|
|
13509
13731
|
var _endEvent = { type: "end" };
|
|
13510
13732
|
var OrbitControls = class extends import_three35.EventDispatcher {
|
|
13511
|
-
constructor(
|
|
13733
|
+
constructor(object2, domElement) {
|
|
13512
13734
|
super();
|
|
13513
13735
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
13514
13736
|
if (domElement === document) console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
|
|
13515
|
-
this.object =
|
|
13737
|
+
this.object = object2;
|
|
13516
13738
|
this.domElement = domElement;
|
|
13517
13739
|
this.domElement.style.touchAction = "none";
|
|
13518
13740
|
this.enabled = true;
|
|
@@ -13569,7 +13791,7 @@ var OrbitControls = class extends import_three35.EventDispatcher {
|
|
|
13569
13791
|
};
|
|
13570
13792
|
this.update = function() {
|
|
13571
13793
|
const offset = new import_three35.Vector3();
|
|
13572
|
-
const quat = new import_three35.Quaternion().setFromUnitVectors(
|
|
13794
|
+
const quat = new import_three35.Quaternion().setFromUnitVectors(object2.up, new import_three35.Vector3(0, 1, 0));
|
|
13573
13795
|
const quatInverse = quat.clone().invert();
|
|
13574
13796
|
const lastPosition = new import_three35.Vector3();
|
|
13575
13797
|
const lastQuaternion = new import_three35.Quaternion();
|
|
@@ -14134,8 +14356,8 @@ var OrbitControls = class extends import_three35.EventDispatcher {
|
|
|
14134
14356
|
}
|
|
14135
14357
|
};
|
|
14136
14358
|
var MapControls = class extends OrbitControls {
|
|
14137
|
-
constructor(
|
|
14138
|
-
super(
|
|
14359
|
+
constructor(object2, domElement) {
|
|
14360
|
+
super(object2, domElement);
|
|
14139
14361
|
this.screenSpacePanning = false;
|
|
14140
14362
|
this.mouseButtons.LEFT = import_three35.MOUSE.PAN;
|
|
14141
14363
|
this.mouseButtons.RIGHT = import_three35.MOUSE.ROTATE;
|
|
@@ -15063,16 +15285,16 @@ var SectionModels = class {
|
|
|
15063
15285
|
if (!models) this.models.set(model, models = /* @__PURE__ */ new Map());
|
|
15064
15286
|
const key = JSON.stringify([rotation.x, rotation.y, rotation.z, variant.uvlock, tints]);
|
|
15065
15287
|
const template = await cached(models, key, async () => {
|
|
15066
|
-
const
|
|
15288
|
+
const object2 = new SectionModel(model, {
|
|
15067
15289
|
instanceMeshes: false,
|
|
15068
15290
|
mergeMeshes: false,
|
|
15069
15291
|
tints,
|
|
15070
15292
|
uvLockRotation: variant.uvlock && (rotation.x !== 0 || rotation.y !== 0) ? [rotation.x, rotation.y, rotation.z] : void 0
|
|
15071
15293
|
});
|
|
15072
|
-
await
|
|
15073
|
-
const geometry =
|
|
15294
|
+
await object2.init();
|
|
15295
|
+
const geometry = object2.children[0].geometry;
|
|
15074
15296
|
geometry.applyMatrix4(new import_three38.Matrix4().makeRotationFromEuler(rotation));
|
|
15075
|
-
|
|
15297
|
+
object2.clear();
|
|
15076
15298
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
15077
15299
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
15078
15300
|
if (local < 0) return 0;
|
|
@@ -15260,10 +15482,10 @@ var MineRenderWorld = class {
|
|
|
15260
15482
|
await block.object.updateFluid((x, y, z) => {
|
|
15261
15483
|
const neighbor = pos.clone().add(new import_three39.Vector3(x, y, z));
|
|
15262
15484
|
const section = this.getChunkAt(neighbor);
|
|
15263
|
-
const
|
|
15485
|
+
const object2 = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
|
|
15264
15486
|
return {
|
|
15265
|
-
fluid:
|
|
15266
|
-
level:
|
|
15487
|
+
fluid: object2?.fluidKind,
|
|
15488
|
+
level: object2?.fluidLevel,
|
|
15267
15489
|
solid: section?.isOccludingAt(neighbor) ?? false
|
|
15268
15490
|
};
|
|
15269
15491
|
});
|
|
@@ -15492,7 +15714,7 @@ var Chunk = class _Chunk {
|
|
|
15492
15714
|
this.renderedBlocks.get(index)?.object?.removeFromScene();
|
|
15493
15715
|
if (this.sectionBlocks.delete(index)) this.meshDirty = true;
|
|
15494
15716
|
this.renderedBlocks.delete(index);
|
|
15495
|
-
let
|
|
15717
|
+
let object2;
|
|
15496
15718
|
try {
|
|
15497
15719
|
if (!readBlock) return void 0;
|
|
15498
15720
|
const stored = readBlock();
|
|
@@ -15507,22 +15729,22 @@ var Chunk = class _Chunk {
|
|
|
15507
15729
|
this.sectionBlocks.set(index, { index, template, cullMask: 0 });
|
|
15508
15730
|
this.meshDirty = true;
|
|
15509
15731
|
} else {
|
|
15510
|
-
|
|
15732
|
+
object2 = await this.scene.addBlock(blockState, {
|
|
15511
15733
|
mergeMeshes: true,
|
|
15512
15734
|
instanceMeshes: true,
|
|
15513
15735
|
maxInstanceCount: 2e3,
|
|
15514
15736
|
initialState: stored.properties
|
|
15515
15737
|
});
|
|
15516
|
-
|
|
15738
|
+
object2.setPosition(MineRenderWorld.worldToScenePosition(worldPos));
|
|
15517
15739
|
}
|
|
15518
15740
|
const info = { get block() {
|
|
15519
15741
|
return readBlock();
|
|
15520
|
-
}, object };
|
|
15742
|
+
}, object: object2 };
|
|
15521
15743
|
this.renderedBlocks.set(index, info);
|
|
15522
15744
|
return info;
|
|
15523
15745
|
} catch (error) {
|
|
15524
15746
|
this.data.set(index, void 0);
|
|
15525
|
-
|
|
15747
|
+
object2?.removeFromScene();
|
|
15526
15748
|
throw error;
|
|
15527
15749
|
} finally {
|
|
15528
15750
|
await onBlocksChanged?.([worldPos]);
|
|
@@ -15696,6 +15918,8 @@ var Chunk = class _Chunk {
|
|
|
15696
15918
|
NodeCache,
|
|
15697
15919
|
NodeEnv,
|
|
15698
15920
|
OrbitControls,
|
|
15921
|
+
PackFormats,
|
|
15922
|
+
PackMetadata,
|
|
15699
15923
|
PersistentCache,
|
|
15700
15924
|
Renderer,
|
|
15701
15925
|
RequestError,
|