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/browser/index.js
CHANGED
|
@@ -750,7 +750,7 @@ var init_TextureLoader = __esm({
|
|
|
750
750
|
static createTexture() {
|
|
751
751
|
return new import_three3.Texture();
|
|
752
752
|
}
|
|
753
|
-
static loadInBackground(src,
|
|
753
|
+
static loadInBackground(src, format2 = import_three3.RGBAFormat, rotation = 0) {
|
|
754
754
|
const texture = this.createTexture();
|
|
755
755
|
texture.colorSpace = THREE.SRGBColorSpace;
|
|
756
756
|
const image = ImageLoader.loadElement(src, () => {
|
|
@@ -760,11 +760,11 @@ var init_TextureLoader = __esm({
|
|
|
760
760
|
console.warn("Failed to load texture", src, error);
|
|
761
761
|
});
|
|
762
762
|
texture.image = image;
|
|
763
|
-
texture.format =
|
|
763
|
+
texture.format = format2;
|
|
764
764
|
texture.rotation = rotation;
|
|
765
765
|
return Textures.initTextureProps(texture);
|
|
766
766
|
}
|
|
767
|
-
static load(src,
|
|
767
|
+
static load(src, format2 = import_three3.RGBAFormat, rotation = 0) {
|
|
768
768
|
const texture = new import_three3.Texture();
|
|
769
769
|
texture.colorSpace = THREE.SRGBColorSpace;
|
|
770
770
|
ImageLoader.getData(src).then((image) => {
|
|
@@ -774,7 +774,7 @@ var init_TextureLoader = __esm({
|
|
|
774
774
|
this.failedTextures.add(texture);
|
|
775
775
|
console.warn("Failed to load texture", src, error);
|
|
776
776
|
});
|
|
777
|
-
texture.format =
|
|
777
|
+
texture.format = format2;
|
|
778
778
|
texture.rotation = rotation;
|
|
779
779
|
return Textures.initTextureProps(texture);
|
|
780
780
|
}
|
|
@@ -1704,6 +1704,10 @@ var init_AssetSource = __esm({
|
|
|
1704
1704
|
AssetSource = class {
|
|
1705
1705
|
constructor() {
|
|
1706
1706
|
}
|
|
1707
|
+
/** Whether this source prevents lower-priority sources from supplying the key. Its own assets remain available. */
|
|
1708
|
+
blocks(key) {
|
|
1709
|
+
return false;
|
|
1710
|
+
}
|
|
1707
1711
|
/**
|
|
1708
1712
|
* Identifies this source's content across sessions for persistent caching. Sources that
|
|
1709
1713
|
* cannot tell whether their content changed (an unnamed archive, for example) return
|
|
@@ -1884,10 +1888,10 @@ var init_NBTHelper = __esm({
|
|
|
1884
1888
|
"src/nbt/NBTHelper.ts"() {
|
|
1885
1889
|
import_buffer2 = require("buffer");
|
|
1886
1890
|
NBTHelper = class {
|
|
1887
|
-
static async fromBuffer(data,
|
|
1891
|
+
static async fromBuffer(data, format2) {
|
|
1888
1892
|
const buffer = import_buffer2.Buffer.from(data instanceof Uint8Array ? data : new Uint8Array(data));
|
|
1889
1893
|
const prismarineNbt = await import("prismarine-nbt");
|
|
1890
|
-
const { parsed, type, metadata } = await prismarineNbt.parse(buffer,
|
|
1894
|
+
const { parsed, type, metadata } = await prismarineNbt.parse(buffer, format2);
|
|
1891
1895
|
return Object.assign(parsed, {
|
|
1892
1896
|
format: type,
|
|
1893
1897
|
metadata,
|
|
@@ -2121,6 +2125,162 @@ var init_BrowserArchiveProxy = __esm({
|
|
|
2121
2125
|
}
|
|
2122
2126
|
});
|
|
2123
2127
|
|
|
2128
|
+
// src/assets/source/archive/PackMetadata.ts
|
|
2129
|
+
function object(value, field) {
|
|
2130
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
2131
|
+
throw new Error(`Invalid ${field}: expected an object`);
|
|
2132
|
+
}
|
|
2133
|
+
return value;
|
|
2134
|
+
}
|
|
2135
|
+
function integer(value, field) {
|
|
2136
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
2137
|
+
throw new Error(`Invalid ${field}: expected a nonnegative integer`);
|
|
2138
|
+
}
|
|
2139
|
+
return value;
|
|
2140
|
+
}
|
|
2141
|
+
function format(value, field, upper = false) {
|
|
2142
|
+
const parts = Array.isArray(value) ? value : [value];
|
|
2143
|
+
if (parts.length < 1 || parts.length > 2) {
|
|
2144
|
+
throw new Error(`Invalid ${field}: expected a major version or [major, minor]`);
|
|
2145
|
+
}
|
|
2146
|
+
return [integer(parts[0], field), parts.length === 2 ? integer(parts[1], field) : upper ? Infinity : 0];
|
|
2147
|
+
}
|
|
2148
|
+
function compare(a, b) {
|
|
2149
|
+
return a[0] === b[0] ? a[1] - b[1] : a[0] - b[0];
|
|
2150
|
+
}
|
|
2151
|
+
function overlay(value, field) {
|
|
2152
|
+
const entry = object(value, field);
|
|
2153
|
+
const directory = entry.directory;
|
|
2154
|
+
if (typeof directory !== "string" || !directory || /[^-_a-zA-Z0-9.]/.test(directory) || directory === "." || directory === "..") {
|
|
2155
|
+
throw new Error(`Invalid ${field}.directory: expected a directory name without path separators`);
|
|
2156
|
+
}
|
|
2157
|
+
let min, max;
|
|
2158
|
+
if ("min_format" in entry || "max_format" in entry) {
|
|
2159
|
+
min = format(entry.min_format, `${field}.min_format`);
|
|
2160
|
+
max = format(entry.max_format, `${field}.max_format`, true);
|
|
2161
|
+
} else {
|
|
2162
|
+
const range = entry.formats;
|
|
2163
|
+
let lower, upper;
|
|
2164
|
+
if (typeof range === "number") {
|
|
2165
|
+
lower = upper = range;
|
|
2166
|
+
} else if (Array.isArray(range)) {
|
|
2167
|
+
if (range.length !== 2) throw new Error(`Invalid ${field}.formats: expected [min, max]`);
|
|
2168
|
+
[lower, upper] = range;
|
|
2169
|
+
} else {
|
|
2170
|
+
const bounds = object(range, `${field}.formats`);
|
|
2171
|
+
lower = bounds.min_inclusive;
|
|
2172
|
+
upper = bounds.max_inclusive;
|
|
2173
|
+
}
|
|
2174
|
+
min = [integer(lower, `${field}.formats.min_inclusive`), 0];
|
|
2175
|
+
max = [integer(upper, `${field}.formats.max_inclusive`), Infinity];
|
|
2176
|
+
}
|
|
2177
|
+
if (compare(min, max) > 0) throw new Error(`Invalid ${field}: minimum format exceeds maximum format`);
|
|
2178
|
+
return { directory, min, max };
|
|
2179
|
+
}
|
|
2180
|
+
function pattern(value, field) {
|
|
2181
|
+
if (value === void 0) return void 0;
|
|
2182
|
+
if (typeof value !== "string") throw new Error(`Invalid ${field}: expected a regular expression string`);
|
|
2183
|
+
try {
|
|
2184
|
+
return new RegExp(value);
|
|
2185
|
+
} catch (cause) {
|
|
2186
|
+
throw new Error(`Invalid ${field}: ${String(cause)}`);
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
var PackMetadata;
|
|
2190
|
+
var init_PackMetadata = __esm({
|
|
2191
|
+
"src/assets/source/archive/PackMetadata.ts"() {
|
|
2192
|
+
PackMetadata = class _PackMetadata {
|
|
2193
|
+
constructor(overlays, filters) {
|
|
2194
|
+
this.overlays = overlays;
|
|
2195
|
+
this.filters = filters;
|
|
2196
|
+
this.hasOverlays = overlays.length > 0;
|
|
2197
|
+
}
|
|
2198
|
+
static parse(value) {
|
|
2199
|
+
const metadata = object(value, "pack.mcmeta");
|
|
2200
|
+
let overlays = [];
|
|
2201
|
+
if ("overlays" in metadata) {
|
|
2202
|
+
const entries = object(metadata.overlays, "overlays").entries;
|
|
2203
|
+
if (!Array.isArray(entries)) throw new Error("Invalid overlays.entries: expected an array");
|
|
2204
|
+
overlays = entries.map((entry, index) => overlay(entry, `overlays.entries[${index}]`));
|
|
2205
|
+
}
|
|
2206
|
+
let filters = [];
|
|
2207
|
+
if ("filter" in metadata) {
|
|
2208
|
+
const entries = object(metadata.filter, "filter").block;
|
|
2209
|
+
if (!Array.isArray(entries)) throw new Error("Invalid filter.block: expected an array");
|
|
2210
|
+
filters = entries.map((value2, index) => {
|
|
2211
|
+
const field = `filter.block[${index}]`;
|
|
2212
|
+
const entry = object(value2, field);
|
|
2213
|
+
return { namespace: pattern(entry.namespace, `${field}.namespace`), path: pattern(entry.path, `${field}.path`) };
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
2216
|
+
return new _PackMetadata(overlays, filters);
|
|
2217
|
+
}
|
|
2218
|
+
/** Returns applicable directories in lookup order, with the last declared overlay first. */
|
|
2219
|
+
overlayDirectories(target) {
|
|
2220
|
+
const selected = format(target, "target format");
|
|
2221
|
+
return this.overlays.filter((entry) => compare(selected, entry.min) >= 0 && compare(selected, entry.max) <= 0).map((entry) => entry.directory).reverse();
|
|
2222
|
+
}
|
|
2223
|
+
blocks(namespace, path) {
|
|
2224
|
+
return this.filters.some((entry) => entry.namespace?.test(namespace) ?? true) && this.filters.some((entry) => entry.path?.test(path) ?? true);
|
|
2225
|
+
}
|
|
2226
|
+
};
|
|
2227
|
+
}
|
|
2228
|
+
});
|
|
2229
|
+
|
|
2230
|
+
// src/assets/source/archive/PackFormats.ts
|
|
2231
|
+
var PackFormats;
|
|
2232
|
+
var init_PackFormats = __esm({
|
|
2233
|
+
"src/assets/source/archive/PackFormats.ts"() {
|
|
2234
|
+
init_Requests();
|
|
2235
|
+
PackFormats = class {
|
|
2236
|
+
/** Resolves pack formats from Mojang's client metadata hosted on assets.mcasset.cloud. */
|
|
2237
|
+
static async get(version, type) {
|
|
2238
|
+
let pending = this.versions.get(version);
|
|
2239
|
+
if (!pending || pending.expires <= Date.now()) {
|
|
2240
|
+
pending = {
|
|
2241
|
+
formats: this.load(version),
|
|
2242
|
+
expires: ["latest", "release", "snapshot"].includes(version) ? Date.now() + 3e5 : Infinity
|
|
2243
|
+
};
|
|
2244
|
+
this.versions.set(version, pending);
|
|
2245
|
+
}
|
|
2246
|
+
try {
|
|
2247
|
+
return (await pending.formats)[type];
|
|
2248
|
+
} catch (cause) {
|
|
2249
|
+
if (this.versions.get(version) === pending) this.versions.delete(version);
|
|
2250
|
+
const option = type === "assets" ? "resourcePackFormat" : "dataPackFormat";
|
|
2251
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
2252
|
+
throw new Error(`Could not resolve the pack format for Minecraft ${version}. Set ArchiveAssetSource ${option} explicitly. ${reason}`);
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
static async load(version) {
|
|
2256
|
+
const response = await Requests.genericRequest({
|
|
2257
|
+
url: `https://assets.mcasset.cloud/${encodeURIComponent(version)}/game-version.json`,
|
|
2258
|
+
responseType: "json"
|
|
2259
|
+
});
|
|
2260
|
+
const data = response.data;
|
|
2261
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
2262
|
+
throw new Error("Expected version metadata to be an object");
|
|
2263
|
+
}
|
|
2264
|
+
const packs = data.pack_version;
|
|
2265
|
+
if (typeof packs !== "number" && (!packs || typeof packs !== "object" || Array.isArray(packs))) {
|
|
2266
|
+
throw new Error("Expected pack_version to be a number or an object");
|
|
2267
|
+
}
|
|
2268
|
+
const format2 = (type) => {
|
|
2269
|
+
const modern = typeof packs === "object" && ["resource_major", "resource_minor", "data_major", "data_minor"].some((key) => key in packs);
|
|
2270
|
+
const major = typeof packs === "number" ? packs : packs[modern ? `${type}_major` : type];
|
|
2271
|
+
const minor = modern ? packs[`${type}_minor`] : 0;
|
|
2272
|
+
if (typeof major !== "number" || !Number.isSafeInteger(major) || major < 0 || typeof minor !== "number" || !Number.isSafeInteger(minor) || minor < 0) {
|
|
2273
|
+
throw new Error(`Invalid ${type} pack format in version metadata`);
|
|
2274
|
+
}
|
|
2275
|
+
return Object.freeze([major, minor]);
|
|
2276
|
+
};
|
|
2277
|
+
return { assets: format2("resource"), data: format2("data") };
|
|
2278
|
+
}
|
|
2279
|
+
};
|
|
2280
|
+
PackFormats.versions = /* @__PURE__ */ new Map();
|
|
2281
|
+
}
|
|
2282
|
+
});
|
|
2283
|
+
|
|
2124
2284
|
// src/assets/source/archive/ArchiveAssetSource.ts
|
|
2125
2285
|
var ArchiveAssetSource;
|
|
2126
2286
|
var init_ArchiveAssetSource = __esm({
|
|
@@ -2129,35 +2289,77 @@ var init_ArchiveAssetSource = __esm({
|
|
|
2129
2289
|
init_request();
|
|
2130
2290
|
init_HostedAssetSource();
|
|
2131
2291
|
init_BrowserArchiveProxy();
|
|
2292
|
+
init_AssetLoader();
|
|
2293
|
+
init_PackMetadata();
|
|
2294
|
+
init_PackFormats();
|
|
2132
2295
|
ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
|
|
2133
|
-
constructor(archiveProxy) {
|
|
2296
|
+
constructor(archiveProxy, options = {}) {
|
|
2134
2297
|
super();
|
|
2135
|
-
console.log(archiveProxy);
|
|
2136
2298
|
this._archiveProxy = archiveProxy;
|
|
2299
|
+
const copyFormat = (format2) => typeof format2 === "object" ? [format2[0], format2[1]] : format2;
|
|
2300
|
+
this.options = {
|
|
2301
|
+
resourcePackFormat: copyFormat(options.resourcePackFormat),
|
|
2302
|
+
dataPackFormat: copyFormat(options.dataPackFormat)
|
|
2303
|
+
};
|
|
2137
2304
|
}
|
|
2138
|
-
static blob(blob) {
|
|
2139
|
-
return new _ArchiveAssetSource(new BrowserArchiveProxy(blob));
|
|
2305
|
+
static blob(blob, options) {
|
|
2306
|
+
return new _ArchiveAssetSource(new BrowserArchiveProxy(blob), options);
|
|
2140
2307
|
}
|
|
2141
2308
|
get cacheId() {
|
|
2142
2309
|
const id = this._archiveProxy.id;
|
|
2143
|
-
|
|
2310
|
+
const formats = [this.options.resourcePackFormat ?? AssetLoader.version, this.options.dataPackFormat ?? AssetLoader.version];
|
|
2311
|
+
return id === void 0 ? void 0 : `archive-metadata:1:${id}:${JSON.stringify(formats)}`;
|
|
2144
2312
|
}
|
|
2145
2313
|
async getEntries() {
|
|
2146
|
-
return this._archiveProxy.getEntries()
|
|
2314
|
+
return this.entries ?? (this.entries = this._archiveProxy.getEntries().catch((error) => {
|
|
2315
|
+
this.entries = void 0;
|
|
2316
|
+
throw error;
|
|
2317
|
+
}));
|
|
2147
2318
|
}
|
|
2148
2319
|
async getEntry(path) {
|
|
2149
2320
|
const entries = await this.getEntries();
|
|
2150
2321
|
return entries.find((e) => e.filename === path);
|
|
2151
2322
|
}
|
|
2323
|
+
async getMetadata(key) {
|
|
2324
|
+
try {
|
|
2325
|
+
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) => {
|
|
2326
|
+
this.metadata = void 0;
|
|
2327
|
+
throw error;
|
|
2328
|
+
})));
|
|
2329
|
+
} catch (cause) {
|
|
2330
|
+
throw new AssetLoadError(this, key, "pack.mcmeta", cause);
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
async blocks(key) {
|
|
2334
|
+
if (key.rootType !== "assets" && key.rootType !== "data") return false;
|
|
2335
|
+
const metadata = await this.getMetadata(key);
|
|
2336
|
+
const path = `${key.assetType !== void 0 ? key.assetType + "/" : ""}${key.getFullPath()}${key.extension}`;
|
|
2337
|
+
return metadata.blocks(key.namespace, path);
|
|
2338
|
+
}
|
|
2152
2339
|
async get(key, parser) {
|
|
2153
2340
|
const responseParser = HostedAssetSource.PARSER_MAP.get(parser);
|
|
2154
2341
|
return this.load(key, responseParser);
|
|
2155
2342
|
}
|
|
2156
2343
|
async load(key, parser) {
|
|
2157
2344
|
const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
|
|
2345
|
+
const version = AssetLoader.version;
|
|
2346
|
+
let selectedPath = path;
|
|
2158
2347
|
let url;
|
|
2159
2348
|
try {
|
|
2160
|
-
|
|
2349
|
+
let directories = [];
|
|
2350
|
+
if (key.rootType === "assets" || key.rootType === "data") {
|
|
2351
|
+
const metadata = await this.getMetadata(key);
|
|
2352
|
+
if (metadata.hasOverlays) {
|
|
2353
|
+
const format2 = (key.rootType === "assets" ? this.options.resourcePackFormat : this.options.dataPackFormat) ?? await PackFormats.get(version, key.rootType);
|
|
2354
|
+
directories = metadata.overlayDirectories(format2);
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
let entry;
|
|
2358
|
+
for (const directory of [...directories, ""]) {
|
|
2359
|
+
selectedPath = directory ? `${directory}/${path}` : path;
|
|
2360
|
+
entry = await this.getEntry(selectedPath);
|
|
2361
|
+
if (entry) break;
|
|
2362
|
+
}
|
|
2161
2363
|
if (!entry) {
|
|
2162
2364
|
return void 0;
|
|
2163
2365
|
}
|
|
@@ -2170,7 +2372,8 @@ var init_ArchiveAssetSource = __esm({
|
|
|
2170
2372
|
}
|
|
2171
2373
|
return await parser.parse(response);
|
|
2172
2374
|
} catch (cause) {
|
|
2173
|
-
|
|
2375
|
+
if (cause instanceof AssetLoadError) throw cause;
|
|
2376
|
+
throw new AssetLoadError(this, key, selectedPath, cause);
|
|
2174
2377
|
} finally {
|
|
2175
2378
|
if (url !== void 0) {
|
|
2176
2379
|
URL.revokeObjectURL(url);
|
|
@@ -2203,6 +2406,8 @@ var init_archive = __esm({
|
|
|
2203
2406
|
init_ArchiveEntry();
|
|
2204
2407
|
init_ArchiveProxy();
|
|
2205
2408
|
init_BrowserArchiveProxy();
|
|
2409
|
+
init_PackFormats();
|
|
2410
|
+
init_PackMetadata();
|
|
2206
2411
|
}
|
|
2207
2412
|
});
|
|
2208
2413
|
|
|
@@ -2285,13 +2490,14 @@ ${key}` : key;
|
|
|
2285
2490
|
return void 0;
|
|
2286
2491
|
}
|
|
2287
2492
|
static async getAll(key, parser) {
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2493
|
+
const sources = [...this._SOURCES];
|
|
2494
|
+
const results = [];
|
|
2495
|
+
for (const { source } of sources) {
|
|
2496
|
+
const asset = await source.get(key, parser);
|
|
2497
|
+
if (asset != void 0) results.push(asset);
|
|
2498
|
+
if (await source.blocks(key)) break;
|
|
2291
2499
|
}
|
|
2292
|
-
return
|
|
2293
|
-
return results.filter((r) => r != void 0);
|
|
2294
|
-
});
|
|
2500
|
+
return results;
|
|
2295
2501
|
}
|
|
2296
2502
|
/** Returns the first defined result in source-priority order, without merging assets. */
|
|
2297
2503
|
static async get(key, parser) {
|
|
@@ -2312,13 +2518,17 @@ ${key}` : key;
|
|
|
2312
2518
|
/** Tries each path within a source before considering lower-priority sources. */
|
|
2313
2519
|
static async getFirst(keys, parser) {
|
|
2314
2520
|
const sources = [...this._SOURCES];
|
|
2521
|
+
let remaining = [...keys];
|
|
2315
2522
|
for (const source of sources) {
|
|
2316
|
-
for (const key of
|
|
2523
|
+
for (const key of remaining) {
|
|
2317
2524
|
const result = await source.source.get(key, parser);
|
|
2318
2525
|
if (result !== void 0) {
|
|
2319
2526
|
return { key, asset: result };
|
|
2320
2527
|
}
|
|
2321
2528
|
}
|
|
2529
|
+
const blocked = await Promise.all(remaining.map((key) => source.source.blocks(key)));
|
|
2530
|
+
remaining = remaining.filter((_, index) => !blocked[index]);
|
|
2531
|
+
if (!remaining.length) break;
|
|
2322
2532
|
}
|
|
2323
2533
|
return void 0;
|
|
2324
2534
|
}
|
|
@@ -3425,27 +3635,27 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
3425
3635
|
for (const layer of layers) {
|
|
3426
3636
|
const objects = [];
|
|
3427
3637
|
if (poses) {
|
|
3428
|
-
layer.traverse((
|
|
3429
|
-
if (poses.has(
|
|
3638
|
+
layer.traverse((object2) => {
|
|
3639
|
+
if (poses.has(object2)) objects.push(object2);
|
|
3430
3640
|
});
|
|
3431
3641
|
} else {
|
|
3432
3642
|
for (const bone of Object.keys(animation.bones)) {
|
|
3433
|
-
const
|
|
3434
|
-
if (
|
|
3643
|
+
const object2 = layer.getObjectByName(`group:${bone}`);
|
|
3644
|
+
if (object2) objects.push(object2);
|
|
3435
3645
|
}
|
|
3436
3646
|
}
|
|
3437
|
-
for (const
|
|
3438
|
-
const bone =
|
|
3439
|
-
const pose = poses?.get(
|
|
3647
|
+
for (const object2 of objects) {
|
|
3648
|
+
const bone = object2.name.slice("group:".length);
|
|
3649
|
+
const pose = poses?.get(object2);
|
|
3440
3650
|
this.parts.push({
|
|
3441
3651
|
bone,
|
|
3442
|
-
object,
|
|
3443
|
-
position:
|
|
3444
|
-
rotation:
|
|
3445
|
-
scale:
|
|
3446
|
-
basePosition: pose ? new import_three11.Vector3(...pose.offset) :
|
|
3447
|
-
baseRotation: pose ? new import_three11.Euler(...pose.rotation, "ZYX") :
|
|
3448
|
-
baseScale: pose ? new import_three11.Vector3(...pose.scale ?? [1, 1, 1]) :
|
|
3652
|
+
object: object2,
|
|
3653
|
+
position: object2.position.clone(),
|
|
3654
|
+
rotation: object2.rotation.clone(),
|
|
3655
|
+
scale: object2.scale.clone(),
|
|
3656
|
+
basePosition: pose ? new import_three11.Vector3(...pose.offset) : object2.position.clone(),
|
|
3657
|
+
baseRotation: pose ? new import_three11.Euler(...pose.rotation, "ZYX") : object2.rotation.clone(),
|
|
3658
|
+
baseScale: pose ? new import_three11.Vector3(...pose.scale ?? [1, 1, 1]) : object2.scale.clone()
|
|
3449
3659
|
});
|
|
3450
3660
|
}
|
|
3451
3661
|
}
|
|
@@ -3964,15 +4174,15 @@ var init_SceneObject = __esm({
|
|
|
3964
4174
|
}
|
|
3965
4175
|
}
|
|
3966
4176
|
//</editor-fold>
|
|
3967
|
-
toggleObjectVisibility(
|
|
3968
|
-
if (
|
|
4177
|
+
toggleObjectVisibility(object2, visible) {
|
|
4178
|
+
if (object2) {
|
|
3969
4179
|
if (typeof visible !== "undefined") {
|
|
3970
|
-
|
|
4180
|
+
object2.visible = visible;
|
|
3971
4181
|
} else {
|
|
3972
|
-
|
|
4182
|
+
object2.visible = !object2.visible;
|
|
3973
4183
|
}
|
|
3974
4184
|
this.notifyDirty();
|
|
3975
|
-
return
|
|
4185
|
+
return object2.visible;
|
|
3976
4186
|
}
|
|
3977
4187
|
this.notifyDirty();
|
|
3978
4188
|
return false;
|
|
@@ -4267,8 +4477,8 @@ var init_EntityObject = __esm({
|
|
|
4267
4477
|
this.scrollMaterials.push({ material: mat, offset: mat.map.offset, speed: scroll });
|
|
4268
4478
|
}
|
|
4269
4479
|
}
|
|
4270
|
-
this.getLayerGroup(name)?.traverse((
|
|
4271
|
-
if (isMesh(
|
|
4480
|
+
this.getLayerGroup(name)?.traverse((object2) => {
|
|
4481
|
+
if (isMesh(object2)) object2.material = mat;
|
|
4272
4482
|
});
|
|
4273
4483
|
}));
|
|
4274
4484
|
if (!this.children.length) {
|
|
@@ -4598,8 +4808,8 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
4598
4808
|
return geometry;
|
|
4599
4809
|
}
|
|
4600
4810
|
}
|
|
4601
|
-
function computeMorphedAttributes(
|
|
4602
|
-
if (
|
|
4811
|
+
function computeMorphedAttributes(object2) {
|
|
4812
|
+
if (object2.geometry.isBufferGeometry !== true) {
|
|
4603
4813
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4604
4814
|
return null;
|
|
4605
4815
|
}
|
|
@@ -4612,11 +4822,11 @@ function computeMorphedAttributes(object) {
|
|
|
4612
4822
|
const _morphA = new import_three22.Vector3();
|
|
4613
4823
|
const _morphB = new import_three22.Vector3();
|
|
4614
4824
|
const _morphC = new import_three22.Vector3();
|
|
4615
|
-
function _calculateMorphedAttributeData(
|
|
4825
|
+
function _calculateMorphedAttributeData(object3, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4616
4826
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4617
4827
|
_vB.fromBufferAttribute(attribute, b2);
|
|
4618
4828
|
_vC.fromBufferAttribute(attribute, c2);
|
|
4619
|
-
const morphInfluences =
|
|
4829
|
+
const morphInfluences = object3.morphTargetInfluences;
|
|
4620
4830
|
if (material2.morphTargets && morphAttribute && morphInfluences) {
|
|
4621
4831
|
_morphA.set(0, 0, 0);
|
|
4622
4832
|
_morphB.set(0, 0, 0);
|
|
@@ -4642,10 +4852,10 @@ function computeMorphedAttributes(object) {
|
|
|
4642
4852
|
_vB.add(_morphB);
|
|
4643
4853
|
_vC.add(_morphC);
|
|
4644
4854
|
}
|
|
4645
|
-
if (
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4855
|
+
if (object3.isSkinnedMesh) {
|
|
4856
|
+
object3.boneTransform(a2, _vA);
|
|
4857
|
+
object3.boneTransform(b2, _vB);
|
|
4858
|
+
object3.boneTransform(c2, _vC);
|
|
4649
4859
|
}
|
|
4650
4860
|
modifiedAttributeArray[a2 * 3 + 0] = _vA.x;
|
|
4651
4861
|
modifiedAttributeArray[a2 * 3 + 1] = _vA.y;
|
|
@@ -4657,8 +4867,8 @@ function computeMorphedAttributes(object) {
|
|
|
4657
4867
|
modifiedAttributeArray[c2 * 3 + 1] = _vC.y;
|
|
4658
4868
|
modifiedAttributeArray[c2 * 3 + 2] = _vC.z;
|
|
4659
4869
|
}
|
|
4660
|
-
const geometry =
|
|
4661
|
-
const material =
|
|
4870
|
+
const geometry = object2.geometry;
|
|
4871
|
+
const material = object2.material;
|
|
4662
4872
|
let a, b, c;
|
|
4663
4873
|
const index = geometry.index;
|
|
4664
4874
|
const positionAttribute = geometry.attributes.position;
|
|
@@ -4685,7 +4895,7 @@ function computeMorphedAttributes(object) {
|
|
|
4685
4895
|
b = index.getX(j + 1);
|
|
4686
4896
|
c = index.getX(j + 2);
|
|
4687
4897
|
_calculateMorphedAttributeData(
|
|
4688
|
-
|
|
4898
|
+
object2,
|
|
4689
4899
|
groupMaterial,
|
|
4690
4900
|
positionAttribute,
|
|
4691
4901
|
morphPosition,
|
|
@@ -4696,7 +4906,7 @@ function computeMorphedAttributes(object) {
|
|
|
4696
4906
|
modifiedPosition
|
|
4697
4907
|
);
|
|
4698
4908
|
_calculateMorphedAttributeData(
|
|
4699
|
-
|
|
4909
|
+
object2,
|
|
4700
4910
|
groupMaterial,
|
|
4701
4911
|
normalAttribute,
|
|
4702
4912
|
morphNormal,
|
|
@@ -4716,7 +4926,7 @@ function computeMorphedAttributes(object) {
|
|
|
4716
4926
|
b = index.getX(i + 1);
|
|
4717
4927
|
c = index.getX(i + 2);
|
|
4718
4928
|
_calculateMorphedAttributeData(
|
|
4719
|
-
|
|
4929
|
+
object2,
|
|
4720
4930
|
material,
|
|
4721
4931
|
positionAttribute,
|
|
4722
4932
|
morphPosition,
|
|
@@ -4727,7 +4937,7 @@ function computeMorphedAttributes(object) {
|
|
|
4727
4937
|
modifiedPosition
|
|
4728
4938
|
);
|
|
4729
4939
|
_calculateMorphedAttributeData(
|
|
4730
|
-
|
|
4940
|
+
object2,
|
|
4731
4941
|
material,
|
|
4732
4942
|
normalAttribute,
|
|
4733
4943
|
morphNormal,
|
|
@@ -4751,7 +4961,7 @@ function computeMorphedAttributes(object) {
|
|
|
4751
4961
|
b = j + 1;
|
|
4752
4962
|
c = j + 2;
|
|
4753
4963
|
_calculateMorphedAttributeData(
|
|
4754
|
-
|
|
4964
|
+
object2,
|
|
4755
4965
|
groupMaterial,
|
|
4756
4966
|
positionAttribute,
|
|
4757
4967
|
morphPosition,
|
|
@@ -4762,7 +4972,7 @@ function computeMorphedAttributes(object) {
|
|
|
4762
4972
|
modifiedPosition
|
|
4763
4973
|
);
|
|
4764
4974
|
_calculateMorphedAttributeData(
|
|
4765
|
-
|
|
4975
|
+
object2,
|
|
4766
4976
|
groupMaterial,
|
|
4767
4977
|
normalAttribute,
|
|
4768
4978
|
morphNormal,
|
|
@@ -4782,7 +4992,7 @@ function computeMorphedAttributes(object) {
|
|
|
4782
4992
|
b = i + 1;
|
|
4783
4993
|
c = i + 2;
|
|
4784
4994
|
_calculateMorphedAttributeData(
|
|
4785
|
-
|
|
4995
|
+
object2,
|
|
4786
4996
|
material,
|
|
4787
4997
|
positionAttribute,
|
|
4788
4998
|
morphPosition,
|
|
@@ -4793,7 +5003,7 @@ function computeMorphedAttributes(object) {
|
|
|
4793
5003
|
modifiedPosition
|
|
4794
5004
|
);
|
|
4795
5005
|
_calculateMorphedAttributeData(
|
|
4796
|
-
|
|
5006
|
+
object2,
|
|
4797
5007
|
material,
|
|
4798
5008
|
normalAttribute,
|
|
4799
5009
|
morphNormal,
|
|
@@ -5104,13 +5314,13 @@ var init_ModelObject = __esm({
|
|
|
5104
5314
|
transform.multiply(new import_three25.Matrix4().makeTranslation(-8, -8, -8));
|
|
5105
5315
|
try {
|
|
5106
5316
|
for (const part of parts) {
|
|
5107
|
-
const
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
this.add(
|
|
5112
|
-
await
|
|
5113
|
-
|
|
5317
|
+
const object2 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
|
|
5318
|
+
object2.matrix.copy(transform).multiply(part.transform);
|
|
5319
|
+
object2.matrixWorldNeedsUpdate = true;
|
|
5320
|
+
object2.matrixAutoUpdate = false;
|
|
5321
|
+
this.add(object2);
|
|
5322
|
+
await object2.init();
|
|
5323
|
+
object2.iterateAllMeshes((mesh) => {
|
|
5114
5324
|
const source = mesh.material;
|
|
5115
5325
|
let material = this.specialMaterials.get(source);
|
|
5116
5326
|
if (!material) {
|
|
@@ -5121,7 +5331,7 @@ var init_ModelObject = __esm({
|
|
|
5121
5331
|
mesh.material = material;
|
|
5122
5332
|
});
|
|
5123
5333
|
for (const [name, rotation] of Object.entries(part.rotations)) {
|
|
5124
|
-
|
|
5334
|
+
object2.getGroupByName(name)?.rotation.set(...rotation, "ZYX");
|
|
5125
5335
|
}
|
|
5126
5336
|
}
|
|
5127
5337
|
} catch (error) {
|
|
@@ -5598,6 +5808,8 @@ __export(index_browser_exports, {
|
|
|
5598
5808
|
Models: () => Models,
|
|
5599
5809
|
NBTHelper: () => NBTHelper,
|
|
5600
5810
|
OrbitControls: () => OrbitControls,
|
|
5811
|
+
PackFormats: () => PackFormats,
|
|
5812
|
+
PackMetadata: () => PackMetadata,
|
|
5601
5813
|
PersistentCache: () => PersistentCache,
|
|
5602
5814
|
Renderer: () => Renderer,
|
|
5603
5815
|
RequestError: () => RequestError,
|
|
@@ -6108,7 +6320,7 @@ var OBJExporter = class {
|
|
|
6108
6320
|
* @param {Object3D} object - The 3D object to export.
|
|
6109
6321
|
* @return {string} The exported OBJ.
|
|
6110
6322
|
*/
|
|
6111
|
-
parse(
|
|
6323
|
+
parse(object2) {
|
|
6112
6324
|
let output = "";
|
|
6113
6325
|
let indexVertex = 0;
|
|
6114
6326
|
let indexVertexUvs = 0;
|
|
@@ -6227,7 +6439,7 @@ var OBJExporter = class {
|
|
|
6227
6439
|
}
|
|
6228
6440
|
indexVertex += nbVertex;
|
|
6229
6441
|
}
|
|
6230
|
-
|
|
6442
|
+
object2.traverse(function(child) {
|
|
6231
6443
|
if (child.isMesh === true) {
|
|
6232
6444
|
parseMesh(child);
|
|
6233
6445
|
}
|
|
@@ -6255,9 +6467,9 @@ var PLYExporter = class {
|
|
|
6255
6467
|
* @param {PLYExporter~Options} options - The export options.
|
|
6256
6468
|
* @return {?(string|ArrayBuffer)} The exported PLY.
|
|
6257
6469
|
*/
|
|
6258
|
-
parse(
|
|
6470
|
+
parse(object2, onDone, options = {}) {
|
|
6259
6471
|
function traverseMeshes(cb) {
|
|
6260
|
-
|
|
6472
|
+
object2.traverse(function(child) {
|
|
6261
6473
|
if (child.isMesh === true || child.isPoints) {
|
|
6262
6474
|
const mesh = child;
|
|
6263
6475
|
const geometry = mesh.geometry;
|
|
@@ -6290,7 +6502,7 @@ var PLYExporter = class {
|
|
|
6290
6502
|
for (const name of customAttributeNames) customTypes[name] = "float";
|
|
6291
6503
|
let vertexCount = 0;
|
|
6292
6504
|
let faceCount = 0;
|
|
6293
|
-
|
|
6505
|
+
object2.traverse(function(child) {
|
|
6294
6506
|
if (child.isMesh === true) {
|
|
6295
6507
|
const mesh = child;
|
|
6296
6508
|
const geometry = mesh.geometry;
|
|
@@ -7078,12 +7290,12 @@ var GLTFWriter = class {
|
|
|
7078
7290
|
* @param {THREE.Object3D|THREE.Material|THREE.BufferGeometry|THREE.AnimationClip} object
|
|
7079
7291
|
* @param {Object} objectDef
|
|
7080
7292
|
*/
|
|
7081
|
-
serializeUserData(
|
|
7082
|
-
if (Object.keys(
|
|
7293
|
+
serializeUserData(object2, objectDef) {
|
|
7294
|
+
if (Object.keys(object2.userData).length === 0) return;
|
|
7083
7295
|
const options = this.options;
|
|
7084
7296
|
const extensionsUsed = this.extensionsUsed;
|
|
7085
7297
|
try {
|
|
7086
|
-
const json = JSON.parse(JSON.stringify(
|
|
7298
|
+
const json = JSON.parse(JSON.stringify(object2.userData));
|
|
7087
7299
|
if (options.includeCustomExtensions && json.gltfExtensions) {
|
|
7088
7300
|
if (objectDef.extensions === void 0) objectDef.extensions = {};
|
|
7089
7301
|
for (const extensionName in json.gltfExtensions) {
|
|
@@ -7094,7 +7306,7 @@ var GLTFWriter = class {
|
|
|
7094
7306
|
}
|
|
7095
7307
|
if (Object.keys(json).length > 0) objectDef.extras = json;
|
|
7096
7308
|
} catch (error) {
|
|
7097
|
-
console.warn("THREE.GLTFExporter: userData of '" +
|
|
7309
|
+
console.warn("THREE.GLTFExporter: userData of '" + object2.name + "' won't be serialized because of JSON.stringify error - " + error.message);
|
|
7098
7310
|
}
|
|
7099
7311
|
}
|
|
7100
7312
|
/**
|
|
@@ -7467,7 +7679,7 @@ var GLTFWriter = class {
|
|
|
7467
7679
|
* @param {string} mimeType export format
|
|
7468
7680
|
* @return {number} Index of the processed texture in the "images" array
|
|
7469
7681
|
*/
|
|
7470
|
-
processImage(image,
|
|
7682
|
+
processImage(image, format2, flipY, mimeType = "image/png") {
|
|
7471
7683
|
if (image !== null) {
|
|
7472
7684
|
const writer = this;
|
|
7473
7685
|
const cache = writer.cache;
|
|
@@ -7491,8 +7703,8 @@ var GLTFWriter = class {
|
|
|
7491
7703
|
ctx.scale(1, -1);
|
|
7492
7704
|
}
|
|
7493
7705
|
if (image.data !== void 0) {
|
|
7494
|
-
if (
|
|
7495
|
-
console.error("GLTFExporter: Only RGBAFormat is supported.",
|
|
7706
|
+
if (format2 !== import_three18.RGBAFormat) {
|
|
7707
|
+
console.error("GLTFExporter: Only RGBAFormat is supported.", format2);
|
|
7496
7708
|
}
|
|
7497
7709
|
if (image.width > options.maxTextureSize || image.height > options.maxTextureSize) {
|
|
7498
7710
|
console.warn("GLTFExporter: Image size is bigger than maxTextureSize", image);
|
|
@@ -8020,13 +8232,13 @@ var GLTFWriter = class {
|
|
|
8020
8232
|
* @param {THREE.Object3D} object
|
|
8021
8233
|
* @return {?number}
|
|
8022
8234
|
*/
|
|
8023
|
-
processSkin(
|
|
8235
|
+
processSkin(object2) {
|
|
8024
8236
|
const json = this.json;
|
|
8025
8237
|
const nodeMap = this.nodeMap;
|
|
8026
|
-
const node = json.nodes[nodeMap.get(
|
|
8027
|
-
const skeleton =
|
|
8238
|
+
const node = json.nodes[nodeMap.get(object2)];
|
|
8239
|
+
const skeleton = object2.skeleton;
|
|
8028
8240
|
if (skeleton === void 0) return null;
|
|
8029
|
-
const rootJoint =
|
|
8241
|
+
const rootJoint = object2.skeleton.bones[0];
|
|
8030
8242
|
if (rootJoint === void 0) return null;
|
|
8031
8243
|
const joints = [];
|
|
8032
8244
|
const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
|
|
@@ -8034,7 +8246,7 @@ var GLTFWriter = class {
|
|
|
8034
8246
|
for (let i = 0; i < skeleton.bones.length; ++i) {
|
|
8035
8247
|
joints.push(nodeMap.get(skeleton.bones[i]));
|
|
8036
8248
|
temporaryBoneInverse.copy(skeleton.boneInverses[i]);
|
|
8037
|
-
temporaryBoneInverse.multiply(
|
|
8249
|
+
temporaryBoneInverse.multiply(object2.bindMatrix).toArray(inverseBindMatrices, i * 16);
|
|
8038
8250
|
}
|
|
8039
8251
|
if (json.skins === void 0) json.skins = [];
|
|
8040
8252
|
json.skins.push({
|
|
@@ -8050,19 +8262,19 @@ var GLTFWriter = class {
|
|
|
8050
8262
|
* @param {THREE.Object3D} object Object3D to processNodeAsync
|
|
8051
8263
|
* @return {Promise<number>} Index of the node in the nodes list
|
|
8052
8264
|
*/
|
|
8053
|
-
async processNodeAsync(
|
|
8265
|
+
async processNodeAsync(object2) {
|
|
8054
8266
|
const json = this.json;
|
|
8055
8267
|
const options = this.options;
|
|
8056
8268
|
const nodeMap = this.nodeMap;
|
|
8057
8269
|
if (!json.nodes) json.nodes = [];
|
|
8058
|
-
if (
|
|
8059
|
-
return await this._processNodeWithPivotAsync(
|
|
8270
|
+
if (object2.pivot !== null) {
|
|
8271
|
+
return await this._processNodeWithPivotAsync(object2);
|
|
8060
8272
|
}
|
|
8061
8273
|
const nodeDef = {};
|
|
8062
8274
|
if (options.trs) {
|
|
8063
|
-
const rotation =
|
|
8064
|
-
const position =
|
|
8065
|
-
const scale =
|
|
8275
|
+
const rotation = object2.quaternion.toArray();
|
|
8276
|
+
const position = object2.position.toArray();
|
|
8277
|
+
const scale = object2.scale.toArray();
|
|
8066
8278
|
if (!equalArray(rotation, [0, 0, 0, 1])) {
|
|
8067
8279
|
nodeDef.rotation = rotation;
|
|
8068
8280
|
}
|
|
@@ -8073,28 +8285,28 @@ var GLTFWriter = class {
|
|
|
8073
8285
|
nodeDef.scale = scale;
|
|
8074
8286
|
}
|
|
8075
8287
|
} else {
|
|
8076
|
-
if (
|
|
8077
|
-
|
|
8288
|
+
if (object2.matrixAutoUpdate) {
|
|
8289
|
+
object2.updateMatrix();
|
|
8078
8290
|
}
|
|
8079
|
-
if (isIdentityMatrix(
|
|
8080
|
-
nodeDef.matrix =
|
|
8291
|
+
if (isIdentityMatrix(object2.matrix) === false) {
|
|
8292
|
+
nodeDef.matrix = object2.matrix.elements;
|
|
8081
8293
|
}
|
|
8082
8294
|
}
|
|
8083
|
-
if (
|
|
8084
|
-
this.serializeUserData(
|
|
8085
|
-
if (
|
|
8086
|
-
const meshIndex = await this.processMeshAsync(
|
|
8295
|
+
if (object2.name !== "") nodeDef.name = String(object2.name);
|
|
8296
|
+
this.serializeUserData(object2, nodeDef);
|
|
8297
|
+
if (object2.isMesh || object2.isLine || object2.isPoints) {
|
|
8298
|
+
const meshIndex = await this.processMeshAsync(object2);
|
|
8087
8299
|
if (meshIndex !== null) nodeDef.mesh = meshIndex;
|
|
8088
|
-
} else if (
|
|
8089
|
-
nodeDef.camera = this.processCamera(
|
|
8300
|
+
} else if (object2.isCamera) {
|
|
8301
|
+
nodeDef.camera = this.processCamera(object2);
|
|
8090
8302
|
}
|
|
8091
|
-
if (
|
|
8303
|
+
if (object2.isSkinnedMesh) this.skins.push(object2);
|
|
8092
8304
|
const nodeIndex = json.nodes.push(nodeDef) - 1;
|
|
8093
|
-
nodeMap.set(
|
|
8094
|
-
if (
|
|
8305
|
+
nodeMap.set(object2, nodeIndex);
|
|
8306
|
+
if (object2.children.length > 0) {
|
|
8095
8307
|
const children = [];
|
|
8096
|
-
for (let i = 0, l =
|
|
8097
|
-
const child =
|
|
8308
|
+
for (let i = 0, l = object2.children.length; i < l; i++) {
|
|
8309
|
+
const child = object2.children[i];
|
|
8098
8310
|
if (child.visible || options.onlyVisible === false) {
|
|
8099
8311
|
const childNodeIndex = await this.processNodeAsync(child);
|
|
8100
8312
|
if (childNodeIndex !== null) children.push(childNodeIndex);
|
|
@@ -8103,7 +8315,7 @@ var GLTFWriter = class {
|
|
|
8103
8315
|
if (children.length > 0) nodeDef.children = children;
|
|
8104
8316
|
}
|
|
8105
8317
|
await this._invokeAllAsync(function(ext) {
|
|
8106
|
-
ext.writeNode && ext.writeNode(
|
|
8318
|
+
ext.writeNode && ext.writeNode(object2, nodeDef);
|
|
8107
8319
|
});
|
|
8108
8320
|
return nodeIndex;
|
|
8109
8321
|
}
|
|
@@ -8112,19 +8324,19 @@ var GLTFWriter = class {
|
|
|
8112
8324
|
* @param {THREE.Object3D} object Object3D with pivot
|
|
8113
8325
|
* @return {Promise<number>} Index of the container node
|
|
8114
8326
|
*/
|
|
8115
|
-
async _processNodeWithPivotAsync(
|
|
8327
|
+
async _processNodeWithPivotAsync(object2) {
|
|
8116
8328
|
const json = this.json;
|
|
8117
8329
|
const options = this.options;
|
|
8118
8330
|
const nodeMap = this.nodeMap;
|
|
8119
|
-
const pivot =
|
|
8331
|
+
const pivot = object2.pivot;
|
|
8120
8332
|
const containerDef = {};
|
|
8121
|
-
const rotation =
|
|
8333
|
+
const rotation = object2.quaternion.toArray();
|
|
8122
8334
|
const position = [
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8335
|
+
object2.position.x + pivot.x,
|
|
8336
|
+
object2.position.y + pivot.y,
|
|
8337
|
+
object2.position.z + pivot.z
|
|
8126
8338
|
];
|
|
8127
|
-
const scale =
|
|
8339
|
+
const scale = object2.scale.toArray();
|
|
8128
8340
|
if (!equalArray(rotation, [0, 0, 0, 1])) {
|
|
8129
8341
|
containerDef.rotation = rotation;
|
|
8130
8342
|
}
|
|
@@ -8135,28 +8347,28 @@ var GLTFWriter = class {
|
|
|
8135
8347
|
containerDef.scale = scale;
|
|
8136
8348
|
}
|
|
8137
8349
|
containerDef.extras = { pivot: pivot.toArray() };
|
|
8138
|
-
if (
|
|
8139
|
-
this.serializeUserData(
|
|
8350
|
+
if (object2.name !== "") containerDef.name = String(object2.name);
|
|
8351
|
+
this.serializeUserData(object2, containerDef);
|
|
8140
8352
|
const containerIndex = json.nodes.push(containerDef) - 1;
|
|
8141
|
-
nodeMap.set(
|
|
8353
|
+
nodeMap.set(object2, containerIndex);
|
|
8142
8354
|
const childDef = {};
|
|
8143
8355
|
const childPosition = [-pivot.x, -pivot.y, -pivot.z];
|
|
8144
8356
|
if (!equalArray(childPosition, [0, 0, 0])) {
|
|
8145
8357
|
childDef.translation = childPosition;
|
|
8146
8358
|
}
|
|
8147
|
-
if (
|
|
8148
|
-
const meshIndex = await this.processMeshAsync(
|
|
8359
|
+
if (object2.isMesh || object2.isLine || object2.isPoints) {
|
|
8360
|
+
const meshIndex = await this.processMeshAsync(object2);
|
|
8149
8361
|
if (meshIndex !== null) childDef.mesh = meshIndex;
|
|
8150
|
-
} else if (
|
|
8151
|
-
childDef.camera = this.processCamera(
|
|
8362
|
+
} else if (object2.isCamera) {
|
|
8363
|
+
childDef.camera = this.processCamera(object2);
|
|
8152
8364
|
}
|
|
8153
|
-
if (
|
|
8365
|
+
if (object2.isSkinnedMesh) this.skins.push(object2);
|
|
8154
8366
|
const childIndex = json.nodes.push(childDef) - 1;
|
|
8155
8367
|
const containerChildren = [childIndex];
|
|
8156
|
-
if (
|
|
8368
|
+
if (object2.children.length > 0) {
|
|
8157
8369
|
const grandchildren = [];
|
|
8158
|
-
for (let i = 0, l =
|
|
8159
|
-
const child =
|
|
8370
|
+
for (let i = 0, l = object2.children.length; i < l; i++) {
|
|
8371
|
+
const child = object2.children[i];
|
|
8160
8372
|
if (child.visible || options.onlyVisible === false) {
|
|
8161
8373
|
const childNodeIndex = await this.processNodeAsync(child);
|
|
8162
8374
|
if (childNodeIndex !== null) grandchildren.push(childNodeIndex);
|
|
@@ -8166,7 +8378,7 @@ var GLTFWriter = class {
|
|
|
8166
8378
|
}
|
|
8167
8379
|
containerDef.children = containerChildren;
|
|
8168
8380
|
await this._invokeAllAsync(function(ext) {
|
|
8169
|
-
ext.writeNode && ext.writeNode(
|
|
8381
|
+
ext.writeNode && ext.writeNode(object2, containerDef);
|
|
8170
8382
|
});
|
|
8171
8383
|
return containerIndex;
|
|
8172
8384
|
}
|
|
@@ -8609,10 +8821,10 @@ var GLTFMeshGpuInstancing = class {
|
|
|
8609
8821
|
this.writer = writer;
|
|
8610
8822
|
this.name = "EXT_mesh_gpu_instancing";
|
|
8611
8823
|
}
|
|
8612
|
-
writeNode(
|
|
8613
|
-
if (!
|
|
8824
|
+
writeNode(object2, nodeDef) {
|
|
8825
|
+
if (!object2.isInstancedMesh) return;
|
|
8614
8826
|
const writer = this.writer;
|
|
8615
|
-
const mesh =
|
|
8827
|
+
const mesh = object2;
|
|
8616
8828
|
const translationAttr = new Float32Array(mesh.count * 3);
|
|
8617
8829
|
const rotationAttr = new Float32Array(mesh.count * 4);
|
|
8618
8830
|
const scaleAttr = new Float32Array(mesh.count * 3);
|
|
@@ -8802,8 +9014,8 @@ var SceneExporter = class {
|
|
|
8802
9014
|
}
|
|
8803
9015
|
}
|
|
8804
9016
|
};
|
|
8805
|
-
function localMatrix(
|
|
8806
|
-
return
|
|
9017
|
+
function localMatrix(object2) {
|
|
9018
|
+
return object2.matrixAutoUpdate ? new import_three19.Matrix4().compose(object2.position, object2.quaternion, object2.scale) : object2.matrix.clone();
|
|
8807
9019
|
}
|
|
8808
9020
|
function createSnapshot(root, gltf, bakeColors = false) {
|
|
8809
9021
|
const scene = new import_three19.Scene();
|
|
@@ -8907,10 +9119,10 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8907
9119
|
scene.add(copy);
|
|
8908
9120
|
}
|
|
8909
9121
|
};
|
|
8910
|
-
const visit = (
|
|
8911
|
-
if (!
|
|
8912
|
-
const world = parentWorld.clone().multiply(localMatrix(
|
|
8913
|
-
const mesh =
|
|
9122
|
+
const visit = (object2, parentWorld) => {
|
|
9123
|
+
if (!object2.visible) return;
|
|
9124
|
+
const world = parentWorld.clone().multiply(localMatrix(object2));
|
|
9125
|
+
const mesh = object2;
|
|
8914
9126
|
if (mesh.isMesh) {
|
|
8915
9127
|
const instanced = mesh;
|
|
8916
9128
|
if (instanced.isInstancedMesh) {
|
|
@@ -8924,7 +9136,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8924
9136
|
addMesh(mesh, world);
|
|
8925
9137
|
}
|
|
8926
9138
|
}
|
|
8927
|
-
for (const child of
|
|
9139
|
+
for (const child of object2.children) visit(child, world);
|
|
8928
9140
|
};
|
|
8929
9141
|
try {
|
|
8930
9142
|
const ancestors = [];
|
|
@@ -9156,11 +9368,11 @@ var GuiHelper = class {
|
|
|
9156
9368
|
switch (recipe.type) {
|
|
9157
9369
|
case "minecraft:crafting_shaped":
|
|
9158
9370
|
case "crafting_shaped": {
|
|
9159
|
-
const
|
|
9160
|
-
if (!
|
|
9371
|
+
const pattern2 = recipe.pattern;
|
|
9372
|
+
if (!pattern2.length || pattern2.length > 3 || !pattern2[0].length || pattern2[0].length > 3 || pattern2.some((row) => row.length !== pattern2[0].length)) {
|
|
9161
9373
|
throw new Error("Crafting patterns must be rectangular, with 1\u20133 rows and columns");
|
|
9162
9374
|
}
|
|
9163
|
-
const cells =
|
|
9375
|
+
const cells = pattern2.flatMap((row, y) => row.split("").map((symbol, x) => ({ symbol, x, y }))).filter((cell) => cell.symbol !== " ");
|
|
9164
9376
|
if (!cells.length) throw new Error("Crafting patterns must contain an ingredient");
|
|
9165
9377
|
const minX = Math.min(...cells.map((cell) => cell.x)), maxX = Math.max(...cells.map((cell) => cell.x));
|
|
9166
9378
|
const minY = Math.min(...cells.map((cell) => cell.y)), maxY = Math.max(...cells.map((cell) => cell.y));
|
|
@@ -9572,29 +9784,29 @@ var SceneInspector = class {
|
|
|
9572
9784
|
this.objectControlsContainer.innerHTML = "";
|
|
9573
9785
|
this.addControls(targetObject, targetIntersection, instance);
|
|
9574
9786
|
}
|
|
9575
|
-
addControls(
|
|
9787
|
+
addControls(object2, intersection, instance) {
|
|
9576
9788
|
const container = document.createElement("div");
|
|
9577
9789
|
container.append(this.separator("Select Parent/Child"));
|
|
9578
|
-
if (
|
|
9579
|
-
container.append(this.buttonControl("Select Parent " +
|
|
9580
|
-
this.selectObject(
|
|
9790
|
+
if (object2.parent) {
|
|
9791
|
+
container.append(this.buttonControl("Select Parent " + object2.parent.constructor.name + " " + object2.parent.name, "P", () => {
|
|
9792
|
+
this.selectObject(object2.parent, intersection, instance);
|
|
9581
9793
|
}));
|
|
9582
9794
|
}
|
|
9583
|
-
if (
|
|
9795
|
+
if (object2.children.length > 0) {
|
|
9584
9796
|
let i = 1;
|
|
9585
|
-
for (let child of
|
|
9797
|
+
for (let child of object2.children) {
|
|
9586
9798
|
container.append(this.buttonControl("Select Child " + child.constructor.name + " " + child.name, "C" + i++, () => {
|
|
9587
9799
|
this.selectObject(child, intersection, instance);
|
|
9588
9800
|
}));
|
|
9589
9801
|
}
|
|
9590
9802
|
}
|
|
9591
9803
|
container.append(this.separator());
|
|
9592
|
-
const selectedInstance = instance && (
|
|
9804
|
+
const selectedInstance = instance && (object2 === instance.instanceable || object2 === intersection?.object) ? instance : void 0;
|
|
9593
9805
|
if (!selectedInstance) {
|
|
9594
|
-
container.append(this.toggleControl("Visibility", "V",
|
|
9806
|
+
container.append(this.toggleControl("Visibility", "V", object2.visible, (v) => object2.visible = v));
|
|
9595
9807
|
}
|
|
9596
9808
|
container.append(this.separator("Mesh"));
|
|
9597
|
-
this.addObjectControls(
|
|
9809
|
+
this.addObjectControls(object2, intersection, container, selectedInstance);
|
|
9598
9810
|
container.append(this.separator());
|
|
9599
9811
|
this.objectControlsContainer.append(container);
|
|
9600
9812
|
}
|
|
@@ -10160,8 +10372,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
10160
10372
|
return false;
|
|
10161
10373
|
}
|
|
10162
10374
|
return this._models.some((model) => {
|
|
10163
|
-
const
|
|
10164
|
-
return
|
|
10375
|
+
const object2 = isInstanceReference(model) ? model.instanceable : model;
|
|
10376
|
+
return object2.isOpaqueFullCube && this.getModelCullMask(model, 63) === 63;
|
|
10165
10377
|
});
|
|
10166
10378
|
}
|
|
10167
10379
|
getModelMatrix(model) {
|
|
@@ -10170,8 +10382,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
10170
10382
|
return model.matrix.clone();
|
|
10171
10383
|
}
|
|
10172
10384
|
getModelCullMask(model, worldMask) {
|
|
10173
|
-
const
|
|
10174
|
-
if (
|
|
10385
|
+
const object2 = isInstanceReference(model) ? model.instanceable : model;
|
|
10386
|
+
if (object2.options.displayPosition) return 0;
|
|
10175
10387
|
const position = new import_three32.Vector3();
|
|
10176
10388
|
const rotation = new import_three32.Quaternion();
|
|
10177
10389
|
const scale = new import_three32.Vector3();
|
|
@@ -10188,14 +10400,14 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
10188
10400
|
replacements.push(model);
|
|
10189
10401
|
continue;
|
|
10190
10402
|
}
|
|
10191
|
-
const
|
|
10403
|
+
const object2 = isInstanceReference(model) ? model.instanceable : model;
|
|
10192
10404
|
const cullMask = this.getModelCullMask(model, worldMask);
|
|
10193
|
-
if (cullMask === (
|
|
10405
|
+
if (cullMask === (object2.options.cullMask ?? 0)) {
|
|
10194
10406
|
replacements.push(model);
|
|
10195
10407
|
continue;
|
|
10196
10408
|
}
|
|
10197
10409
|
const matrix = this.getModelMatrix(model);
|
|
10198
|
-
const replacement = await this.scene.addModel(
|
|
10410
|
+
const replacement = await this.scene.addModel(object2.originalModel, { ...object2.options, cullMask });
|
|
10199
10411
|
replacements.push(replacement);
|
|
10200
10412
|
if (isInstanceReference(replacement)) {
|
|
10201
10413
|
replacement.setMatrix(matrix);
|
|
@@ -10203,8 +10415,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
10203
10415
|
replacement.matrix.copy(matrix);
|
|
10204
10416
|
replacement.matrixWorldNeedsUpdate = true;
|
|
10205
10417
|
matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
10206
|
-
replacement.matrixAutoUpdate =
|
|
10207
|
-
replacement.visible =
|
|
10418
|
+
replacement.matrixAutoUpdate = object2.matrixAutoUpdate;
|
|
10419
|
+
replacement.visible = object2.visible;
|
|
10208
10420
|
}
|
|
10209
10421
|
}
|
|
10210
10422
|
} catch (error) {
|
|
@@ -12126,9 +12338,9 @@ var SchematicParser = class {
|
|
|
12126
12338
|
* Parses a legacy schematic using custom mappings before the bundled defaults.
|
|
12127
12339
|
* Keys are `id:metadata`; values are block states such as `minecraft:oak_log[axis=x]`.
|
|
12128
12340
|
*/
|
|
12129
|
-
static async parse(nbt, customMappings = {}) {
|
|
12341
|
+
static async parse(nbt, customMappings = {}, options = {}) {
|
|
12130
12342
|
const tags = nbt.value;
|
|
12131
|
-
if (tags.Materials?.type !== "string" || tags.Materials.value !== "Alpha") {
|
|
12343
|
+
if (!options.lenient && (tags.Materials?.type !== "string" || tags.Materials.value !== "Alpha")) {
|
|
12132
12344
|
throw new MineRenderError("Schematic Materials must be Alpha");
|
|
12133
12345
|
}
|
|
12134
12346
|
const size = ["Width", "Height", "Length"].map((name) => {
|
|
@@ -12169,8 +12381,16 @@ var SchematicParser = class {
|
|
|
12169
12381
|
const id = high << 8 | ids.value[index] & 255;
|
|
12170
12382
|
const metadata = data.value[index] & 255;
|
|
12171
12383
|
const key = `${id}:${metadata}`;
|
|
12172
|
-
|
|
12173
|
-
if (!mapped
|
|
12384
|
+
let mapped = customMappings[key] ?? mapping[key];
|
|
12385
|
+
if (!mapped && options.lenient) {
|
|
12386
|
+
mapped = customMappings[`${id}:0`] ?? mapping[`${id}:0`];
|
|
12387
|
+
}
|
|
12388
|
+
if (!mapped) {
|
|
12389
|
+
if (options.lenient) {
|
|
12390
|
+
continue;
|
|
12391
|
+
}
|
|
12392
|
+
throw new MineRenderError(`Unsupported legacy block ${id}:${metadata} at schematic index ${index}`);
|
|
12393
|
+
}
|
|
12174
12394
|
const [type, state] = mapped.split("[");
|
|
12175
12395
|
if (type === "minecraft:air") continue;
|
|
12176
12396
|
const properties = {};
|
|
@@ -13328,53 +13548,53 @@ var _MineRenderScene = class _MineRenderScene extends import_three34.Scene {
|
|
|
13328
13548
|
this.options = (0, import_ts_deepmerge8.default)({}, _MineRenderScene.DEFAULT_OPTIONS, options ?? {});
|
|
13329
13549
|
}
|
|
13330
13550
|
add(...objects) {
|
|
13331
|
-
for (const
|
|
13551
|
+
for (const object2 of objects) {
|
|
13332
13552
|
this.dirty = true;
|
|
13333
13553
|
try {
|
|
13334
|
-
super.add(
|
|
13554
|
+
super.add(object2);
|
|
13335
13555
|
} finally {
|
|
13336
|
-
if (
|
|
13337
|
-
this.updateObjectRegistration(
|
|
13556
|
+
if (object2?.isObject3D && object2 !== this) {
|
|
13557
|
+
this.updateObjectRegistration(object2, object2.parent === this);
|
|
13338
13558
|
}
|
|
13339
13559
|
}
|
|
13340
13560
|
}
|
|
13341
13561
|
return this;
|
|
13342
13562
|
}
|
|
13343
13563
|
remove(...objects) {
|
|
13344
|
-
for (const
|
|
13345
|
-
if (!this.children.includes(
|
|
13564
|
+
for (const object2 of objects) {
|
|
13565
|
+
if (!this.children.includes(object2)) continue;
|
|
13346
13566
|
this.dirty = true;
|
|
13347
|
-
this.updateObjectRegistration(
|
|
13567
|
+
this.updateObjectRegistration(object2, false);
|
|
13348
13568
|
try {
|
|
13349
|
-
super.remove(
|
|
13569
|
+
super.remove(object2);
|
|
13350
13570
|
} finally {
|
|
13351
|
-
this.updateObjectRegistration(
|
|
13571
|
+
this.updateObjectRegistration(object2, object2.parent === this);
|
|
13352
13572
|
}
|
|
13353
13573
|
}
|
|
13354
13574
|
return this;
|
|
13355
13575
|
}
|
|
13356
|
-
updateObjectRegistration(
|
|
13357
|
-
if (this.observedObjects.has(
|
|
13358
|
-
const observable =
|
|
13576
|
+
updateObjectRegistration(object2, attached) {
|
|
13577
|
+
if (this.observedObjects.has(object2) === attached) return;
|
|
13578
|
+
const observable = object2;
|
|
13359
13579
|
if (attached) {
|
|
13360
|
-
this.observedObjects.add(
|
|
13580
|
+
this.observedObjects.add(object2);
|
|
13361
13581
|
observable.addEventListener("change", this.onObjectChange);
|
|
13362
13582
|
} else {
|
|
13363
|
-
this.observedObjects.delete(
|
|
13583
|
+
this.observedObjects.delete(object2);
|
|
13364
13584
|
observable.removeEventListener("change", this.onObjectChange);
|
|
13365
13585
|
}
|
|
13366
13586
|
const change = attached ? 1 : -1;
|
|
13367
13587
|
this.stats.objectCount += change;
|
|
13368
|
-
if (isSceneObject(
|
|
13588
|
+
if (isSceneObject(object2)) {
|
|
13369
13589
|
this.stats.sceneObjectCount += change;
|
|
13370
13590
|
}
|
|
13371
13591
|
}
|
|
13372
|
-
async initAndAdd(...
|
|
13592
|
+
async initAndAdd(...object2) {
|
|
13373
13593
|
this.dirty = true;
|
|
13374
|
-
for (let obj of
|
|
13594
|
+
for (let obj of object2) {
|
|
13375
13595
|
await obj.init();
|
|
13376
13596
|
}
|
|
13377
|
-
return this.add(...
|
|
13597
|
+
return this.add(...object2);
|
|
13378
13598
|
}
|
|
13379
13599
|
async addSceneObject(asset, objectSupplier, _options, parent = this) {
|
|
13380
13600
|
this.dirty = true;
|
|
@@ -13455,11 +13675,11 @@ var _changeEvent = { type: "change" };
|
|
|
13455
13675
|
var _startEvent = { type: "start" };
|
|
13456
13676
|
var _endEvent = { type: "end" };
|
|
13457
13677
|
var OrbitControls = class extends import_three35.EventDispatcher {
|
|
13458
|
-
constructor(
|
|
13678
|
+
constructor(object2, domElement) {
|
|
13459
13679
|
super();
|
|
13460
13680
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
13461
13681
|
if (domElement === document) console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
|
|
13462
|
-
this.object =
|
|
13682
|
+
this.object = object2;
|
|
13463
13683
|
this.domElement = domElement;
|
|
13464
13684
|
this.domElement.style.touchAction = "none";
|
|
13465
13685
|
this.enabled = true;
|
|
@@ -13516,7 +13736,7 @@ var OrbitControls = class extends import_three35.EventDispatcher {
|
|
|
13516
13736
|
};
|
|
13517
13737
|
this.update = function() {
|
|
13518
13738
|
const offset = new import_three35.Vector3();
|
|
13519
|
-
const quat = new import_three35.Quaternion().setFromUnitVectors(
|
|
13739
|
+
const quat = new import_three35.Quaternion().setFromUnitVectors(object2.up, new import_three35.Vector3(0, 1, 0));
|
|
13520
13740
|
const quatInverse = quat.clone().invert();
|
|
13521
13741
|
const lastPosition = new import_three35.Vector3();
|
|
13522
13742
|
const lastQuaternion = new import_three35.Quaternion();
|
|
@@ -14081,8 +14301,8 @@ var OrbitControls = class extends import_three35.EventDispatcher {
|
|
|
14081
14301
|
}
|
|
14082
14302
|
};
|
|
14083
14303
|
var MapControls = class extends OrbitControls {
|
|
14084
|
-
constructor(
|
|
14085
|
-
super(
|
|
14304
|
+
constructor(object2, domElement) {
|
|
14305
|
+
super(object2, domElement);
|
|
14086
14306
|
this.screenSpacePanning = false;
|
|
14087
14307
|
this.mouseButtons.LEFT = import_three35.MOUSE.PAN;
|
|
14088
14308
|
this.mouseButtons.RIGHT = import_three35.MOUSE.ROTATE;
|
|
@@ -15009,16 +15229,16 @@ var SectionModels = class {
|
|
|
15009
15229
|
if (!models) this.models.set(model, models = /* @__PURE__ */ new Map());
|
|
15010
15230
|
const key = JSON.stringify([rotation.x, rotation.y, rotation.z, variant.uvlock, tints]);
|
|
15011
15231
|
const template = await cached(models, key, async () => {
|
|
15012
|
-
const
|
|
15232
|
+
const object2 = new SectionModel(model, {
|
|
15013
15233
|
instanceMeshes: false,
|
|
15014
15234
|
mergeMeshes: false,
|
|
15015
15235
|
tints,
|
|
15016
15236
|
uvLockRotation: variant.uvlock && (rotation.x !== 0 || rotation.y !== 0) ? [rotation.x, rotation.y, rotation.z] : void 0
|
|
15017
15237
|
});
|
|
15018
|
-
await
|
|
15019
|
-
const geometry =
|
|
15238
|
+
await object2.init();
|
|
15239
|
+
const geometry = object2.children[0].geometry;
|
|
15020
15240
|
geometry.applyMatrix4(new import_three38.Matrix4().makeRotationFromEuler(rotation));
|
|
15021
|
-
|
|
15241
|
+
object2.clear();
|
|
15022
15242
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
15023
15243
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
15024
15244
|
if (local < 0) return 0;
|
|
@@ -15206,10 +15426,10 @@ var MineRenderWorld = class {
|
|
|
15206
15426
|
await block.object.updateFluid((x, y, z) => {
|
|
15207
15427
|
const neighbor = pos.clone().add(new import_three39.Vector3(x, y, z));
|
|
15208
15428
|
const section = this.getChunkAt(neighbor);
|
|
15209
|
-
const
|
|
15429
|
+
const object2 = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
|
|
15210
15430
|
return {
|
|
15211
|
-
fluid:
|
|
15212
|
-
level:
|
|
15431
|
+
fluid: object2?.fluidKind,
|
|
15432
|
+
level: object2?.fluidLevel,
|
|
15213
15433
|
solid: section?.isOccludingAt(neighbor) ?? false
|
|
15214
15434
|
};
|
|
15215
15435
|
});
|
|
@@ -15438,7 +15658,7 @@ var Chunk = class _Chunk {
|
|
|
15438
15658
|
this.renderedBlocks.get(index)?.object?.removeFromScene();
|
|
15439
15659
|
if (this.sectionBlocks.delete(index)) this.meshDirty = true;
|
|
15440
15660
|
this.renderedBlocks.delete(index);
|
|
15441
|
-
let
|
|
15661
|
+
let object2;
|
|
15442
15662
|
try {
|
|
15443
15663
|
if (!readBlock) return void 0;
|
|
15444
15664
|
const stored = readBlock();
|
|
@@ -15453,22 +15673,22 @@ var Chunk = class _Chunk {
|
|
|
15453
15673
|
this.sectionBlocks.set(index, { index, template, cullMask: 0 });
|
|
15454
15674
|
this.meshDirty = true;
|
|
15455
15675
|
} else {
|
|
15456
|
-
|
|
15676
|
+
object2 = await this.scene.addBlock(blockState, {
|
|
15457
15677
|
mergeMeshes: true,
|
|
15458
15678
|
instanceMeshes: true,
|
|
15459
15679
|
maxInstanceCount: 2e3,
|
|
15460
15680
|
initialState: stored.properties
|
|
15461
15681
|
});
|
|
15462
|
-
|
|
15682
|
+
object2.setPosition(MineRenderWorld.worldToScenePosition(worldPos));
|
|
15463
15683
|
}
|
|
15464
15684
|
const info = { get block() {
|
|
15465
15685
|
return readBlock();
|
|
15466
|
-
}, object };
|
|
15686
|
+
}, object: object2 };
|
|
15467
15687
|
this.renderedBlocks.set(index, info);
|
|
15468
15688
|
return info;
|
|
15469
15689
|
} catch (error) {
|
|
15470
15690
|
this.data.set(index, void 0);
|
|
15471
|
-
|
|
15691
|
+
object2?.removeFromScene();
|
|
15472
15692
|
throw error;
|
|
15473
15693
|
} finally {
|
|
15474
15694
|
await onBlocksChanged?.([worldPos]);
|