minerender 2.1.0-alpha.70 → 2.1.0-alpha.74
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 +47 -5
- package/dist/browser/index.d.ts +47 -5
- package/dist/browser/index.js +487 -208
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +487 -208
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +1045 -760
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +47 -5
- package/dist/node/index.d.ts +47 -5
- package/dist/node/index.js +491 -208
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +489 -208
- 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
|
}
|
|
@@ -1032,7 +1032,7 @@ var init_Materials = __esm({
|
|
|
1032
1032
|
};
|
|
1033
1033
|
return material;
|
|
1034
1034
|
}
|
|
1035
|
-
static createShadedCanvasMaterial(canvas, transparent = false, shade = false) {
|
|
1035
|
+
static createShadedCanvasMaterial(canvas, transparent = false, shade = false, boundUvs = false) {
|
|
1036
1036
|
const vertShader = `
|
|
1037
1037
|
uniform bool SHADE;
|
|
1038
1038
|
|
|
@@ -1042,6 +1042,10 @@ var init_Materials = __esm({
|
|
|
1042
1042
|
#else
|
|
1043
1043
|
varying vec2 vUv;
|
|
1044
1044
|
#endif
|
|
1045
|
+
#ifdef BOUND_UVS
|
|
1046
|
+
attribute vec4 uvBounds;
|
|
1047
|
+
flat out vec4 vUvBounds;
|
|
1048
|
+
#endif
|
|
1045
1049
|
varying vec3 vTint;
|
|
1046
1050
|
varying float light;
|
|
1047
1051
|
varying float lift;
|
|
@@ -1077,13 +1081,17 @@ var init_Materials = __esm({
|
|
|
1077
1081
|
}
|
|
1078
1082
|
|
|
1079
1083
|
vUv = uv;
|
|
1084
|
+
#ifdef BOUND_UVS
|
|
1085
|
+
vUvBounds = uvBounds;
|
|
1086
|
+
#endif
|
|
1080
1087
|
vTint = color;
|
|
1081
1088
|
|
|
1089
|
+
vec4 mvPosition = vec4(position, 1.0);
|
|
1082
1090
|
#ifdef USE_INSTANCING
|
|
1083
|
-
|
|
1084
|
-
#else
|
|
1085
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
1091
|
+
mvPosition = instanceMatrix * mvPosition;
|
|
1086
1092
|
#endif
|
|
1093
|
+
mvPosition = modelViewMatrix * mvPosition;
|
|
1094
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
1087
1095
|
|
|
1088
1096
|
}
|
|
1089
1097
|
`;
|
|
@@ -1103,13 +1111,22 @@ var init_Materials = __esm({
|
|
|
1103
1111
|
#else
|
|
1104
1112
|
varying vec2 vUv;
|
|
1105
1113
|
#endif
|
|
1114
|
+
#ifdef BOUND_UVS
|
|
1115
|
+
flat in vec4 vUvBounds;
|
|
1116
|
+
#endif
|
|
1106
1117
|
varying vec3 vTint;
|
|
1107
1118
|
varying float light;
|
|
1108
1119
|
varying float lift;
|
|
1109
1120
|
|
|
1110
1121
|
void main(void)
|
|
1111
1122
|
{
|
|
1112
|
-
|
|
1123
|
+
#ifdef BOUND_UVS
|
|
1124
|
+
// Keep edge samples inside their texture even without centroid interpolation.
|
|
1125
|
+
vec2 mapUv = clamp(vUv, vUvBounds.xy, vUvBounds.zw);
|
|
1126
|
+
#else
|
|
1127
|
+
vec2 mapUv = vUv;
|
|
1128
|
+
#endif
|
|
1129
|
+
vec4 color = texture2D(map, mapUv);
|
|
1113
1130
|
color.rgb *= vTint;
|
|
1114
1131
|
|
|
1115
1132
|
if (color.a < 0.01) discard;
|
|
@@ -1130,7 +1147,8 @@ var init_Materials = __esm({
|
|
|
1130
1147
|
}
|
|
1131
1148
|
`;
|
|
1132
1149
|
try {
|
|
1133
|
-
|
|
1150
|
+
const material = new import_three5.ShaderMaterial({
|
|
1151
|
+
defines: boundUvs ? { BOUND_UVS: true } : {},
|
|
1134
1152
|
uniforms: {
|
|
1135
1153
|
SHADE: { value: true },
|
|
1136
1154
|
BRIGHTNESS: { value: 1 },
|
|
@@ -1148,6 +1166,8 @@ var init_Materials = __esm({
|
|
|
1148
1166
|
side: transparent ? import_three5.DoubleSide : import_three5.FrontSide,
|
|
1149
1167
|
alphaTest: 0.5
|
|
1150
1168
|
});
|
|
1169
|
+
Object.assign(material.defaultAttributeValues, { uvBounds: [0, 0, 1, 1] });
|
|
1170
|
+
return material;
|
|
1151
1171
|
} catch (e) {
|
|
1152
1172
|
console.warn(e);
|
|
1153
1173
|
}
|
|
@@ -1754,6 +1774,10 @@ var init_AssetSource = __esm({
|
|
|
1754
1774
|
AssetSource = class {
|
|
1755
1775
|
constructor() {
|
|
1756
1776
|
}
|
|
1777
|
+
/** Whether this source prevents lower-priority sources from supplying the key. Its own assets remain available. */
|
|
1778
|
+
blocks(key) {
|
|
1779
|
+
return false;
|
|
1780
|
+
}
|
|
1757
1781
|
/**
|
|
1758
1782
|
* Identifies this source's content across sessions for persistent caching. Sources that
|
|
1759
1783
|
* cannot tell whether their content changed (an unnamed archive, for example) return
|
|
@@ -1934,10 +1958,10 @@ var init_NBTHelper = __esm({
|
|
|
1934
1958
|
"src/nbt/NBTHelper.ts"() {
|
|
1935
1959
|
import_buffer2 = require("buffer");
|
|
1936
1960
|
NBTHelper = class {
|
|
1937
|
-
static async fromBuffer(data,
|
|
1961
|
+
static async fromBuffer(data, format2) {
|
|
1938
1962
|
const buffer = import_buffer2.Buffer.from(data instanceof Uint8Array ? data : new Uint8Array(data));
|
|
1939
1963
|
const prismarineNbt = await import("prismarine-nbt");
|
|
1940
|
-
const { parsed, type, metadata } = await prismarineNbt.parse(buffer,
|
|
1964
|
+
const { parsed, type, metadata } = await prismarineNbt.parse(buffer, format2);
|
|
1941
1965
|
return Object.assign(parsed, {
|
|
1942
1966
|
format: type,
|
|
1943
1967
|
metadata,
|
|
@@ -2186,6 +2210,164 @@ var init_BrowserArchiveProxy = __esm({
|
|
|
2186
2210
|
}
|
|
2187
2211
|
});
|
|
2188
2212
|
|
|
2213
|
+
// src/assets/source/archive/PackMetadata.ts
|
|
2214
|
+
function object(value, field) {
|
|
2215
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
2216
|
+
throw new Error(`Invalid ${field}: expected an object`);
|
|
2217
|
+
}
|
|
2218
|
+
return value;
|
|
2219
|
+
}
|
|
2220
|
+
function integer(value, field) {
|
|
2221
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
2222
|
+
throw new Error(`Invalid ${field}: expected a nonnegative integer`);
|
|
2223
|
+
}
|
|
2224
|
+
return value;
|
|
2225
|
+
}
|
|
2226
|
+
function format(value, field, upper = false) {
|
|
2227
|
+
const parts = Array.isArray(value) ? value : [value];
|
|
2228
|
+
if (parts.length < 1 || parts.length > 2) {
|
|
2229
|
+
throw new Error(`Invalid ${field}: expected a major version or [major, minor]`);
|
|
2230
|
+
}
|
|
2231
|
+
return [integer(parts[0], field), parts.length === 2 ? integer(parts[1], field) : upper ? Infinity : 0];
|
|
2232
|
+
}
|
|
2233
|
+
function compare(a, b) {
|
|
2234
|
+
return a[0] === b[0] ? a[1] - b[1] : a[0] - b[0];
|
|
2235
|
+
}
|
|
2236
|
+
function overlay(value, field) {
|
|
2237
|
+
const entry = object(value, field);
|
|
2238
|
+
const directory = entry.directory;
|
|
2239
|
+
if (typeof directory !== "string" || !directory || /[^-_a-zA-Z0-9.]/.test(directory) || directory === "." || directory === "..") {
|
|
2240
|
+
throw new Error(`Invalid ${field}.directory: expected a directory name without path separators`);
|
|
2241
|
+
}
|
|
2242
|
+
let min, max;
|
|
2243
|
+
if ("min_format" in entry || "max_format" in entry) {
|
|
2244
|
+
min = format(entry.min_format, `${field}.min_format`);
|
|
2245
|
+
max = format(entry.max_format, `${field}.max_format`, true);
|
|
2246
|
+
} else {
|
|
2247
|
+
const range = entry.formats;
|
|
2248
|
+
let lower, upper;
|
|
2249
|
+
if (typeof range === "number") {
|
|
2250
|
+
lower = upper = range;
|
|
2251
|
+
} else if (Array.isArray(range)) {
|
|
2252
|
+
if (range.length !== 2) throw new Error(`Invalid ${field}.formats: expected [min, max]`);
|
|
2253
|
+
[lower, upper] = range;
|
|
2254
|
+
} else {
|
|
2255
|
+
const bounds = object(range, `${field}.formats`);
|
|
2256
|
+
lower = bounds.min_inclusive;
|
|
2257
|
+
upper = bounds.max_inclusive;
|
|
2258
|
+
}
|
|
2259
|
+
min = [integer(lower, `${field}.formats.min_inclusive`), 0];
|
|
2260
|
+
max = [integer(upper, `${field}.formats.max_inclusive`), Infinity];
|
|
2261
|
+
}
|
|
2262
|
+
if (compare(min, max) > 0) throw new Error(`Invalid ${field}: minimum format exceeds maximum format`);
|
|
2263
|
+
return { directory, min, max };
|
|
2264
|
+
}
|
|
2265
|
+
function pattern(value, field) {
|
|
2266
|
+
if (value === void 0) return void 0;
|
|
2267
|
+
if (typeof value !== "string") throw new Error(`Invalid ${field}: expected a regular expression string`);
|
|
2268
|
+
try {
|
|
2269
|
+
return new RegExp(value);
|
|
2270
|
+
} catch (cause) {
|
|
2271
|
+
throw new Error(`Invalid ${field}: ${String(cause)}`);
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
var PackMetadata;
|
|
2275
|
+
var init_PackMetadata = __esm({
|
|
2276
|
+
"src/assets/source/archive/PackMetadata.ts"() {
|
|
2277
|
+
PackMetadata = class _PackMetadata {
|
|
2278
|
+
constructor(overlays, filters) {
|
|
2279
|
+
this.overlays = overlays;
|
|
2280
|
+
this.filters = filters;
|
|
2281
|
+
this.hasOverlays = overlays.length > 0;
|
|
2282
|
+
}
|
|
2283
|
+
static parse(value) {
|
|
2284
|
+
const metadata = object(value, "pack.mcmeta");
|
|
2285
|
+
let overlays = [];
|
|
2286
|
+
if ("overlays" in metadata) {
|
|
2287
|
+
const entries = object(metadata.overlays, "overlays").entries;
|
|
2288
|
+
if (!Array.isArray(entries)) throw new Error("Invalid overlays.entries: expected an array");
|
|
2289
|
+
overlays = entries.map((entry, index) => overlay(entry, `overlays.entries[${index}]`));
|
|
2290
|
+
}
|
|
2291
|
+
let filters = [];
|
|
2292
|
+
if ("filter" in metadata) {
|
|
2293
|
+
const entries = object(metadata.filter, "filter").block;
|
|
2294
|
+
if (!Array.isArray(entries)) throw new Error("Invalid filter.block: expected an array");
|
|
2295
|
+
filters = entries.map((value2, index) => {
|
|
2296
|
+
const field = `filter.block[${index}]`;
|
|
2297
|
+
const entry = object(value2, field);
|
|
2298
|
+
return { namespace: pattern(entry.namespace, `${field}.namespace`), path: pattern(entry.path, `${field}.path`) };
|
|
2299
|
+
});
|
|
2300
|
+
}
|
|
2301
|
+
return new _PackMetadata(overlays, filters);
|
|
2302
|
+
}
|
|
2303
|
+
/** Returns applicable directories in lookup order, with the last declared overlay first. */
|
|
2304
|
+
overlayDirectories(target) {
|
|
2305
|
+
const selected = format(target, "target format");
|
|
2306
|
+
return this.overlays.filter((entry) => compare(selected, entry.min) >= 0 && compare(selected, entry.max) <= 0).map((entry) => entry.directory).reverse();
|
|
2307
|
+
}
|
|
2308
|
+
blocks(namespace, path) {
|
|
2309
|
+
return this.filters.some((entry) => entry.namespace?.test(namespace) ?? true) && this.filters.some((entry) => entry.path?.test(path) ?? true);
|
|
2310
|
+
}
|
|
2311
|
+
};
|
|
2312
|
+
}
|
|
2313
|
+
});
|
|
2314
|
+
|
|
2315
|
+
// src/assets/source/archive/PackFormats.ts
|
|
2316
|
+
var PackFormats;
|
|
2317
|
+
var init_PackFormats = __esm({
|
|
2318
|
+
"src/assets/source/archive/PackFormats.ts"() {
|
|
2319
|
+
init_Requests();
|
|
2320
|
+
PackFormats = class {
|
|
2321
|
+
static {
|
|
2322
|
+
this.versions = /* @__PURE__ */ new Map();
|
|
2323
|
+
}
|
|
2324
|
+
/** Resolves pack formats from Mojang's client metadata hosted on assets.mcasset.cloud. */
|
|
2325
|
+
static async get(version, type) {
|
|
2326
|
+
let pending = this.versions.get(version);
|
|
2327
|
+
if (!pending || pending.expires <= Date.now()) {
|
|
2328
|
+
pending = {
|
|
2329
|
+
formats: this.load(version),
|
|
2330
|
+
expires: ["latest", "release", "snapshot"].includes(version) ? Date.now() + 3e5 : Infinity
|
|
2331
|
+
};
|
|
2332
|
+
this.versions.set(version, pending);
|
|
2333
|
+
}
|
|
2334
|
+
try {
|
|
2335
|
+
return (await pending.formats)[type];
|
|
2336
|
+
} catch (cause) {
|
|
2337
|
+
if (this.versions.get(version) === pending) this.versions.delete(version);
|
|
2338
|
+
const option = type === "assets" ? "resourcePackFormat" : "dataPackFormat";
|
|
2339
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
2340
|
+
throw new Error(`Could not resolve the pack format for Minecraft ${version}. Set ArchiveAssetSource ${option} explicitly. ${reason}`);
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
static async load(version) {
|
|
2344
|
+
const response = await Requests.genericRequest({
|
|
2345
|
+
url: `https://assets.mcasset.cloud/${encodeURIComponent(version)}/game-version.json`,
|
|
2346
|
+
responseType: "json"
|
|
2347
|
+
});
|
|
2348
|
+
const data = response.data;
|
|
2349
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
2350
|
+
throw new Error("Expected version metadata to be an object");
|
|
2351
|
+
}
|
|
2352
|
+
const packs = data.pack_version;
|
|
2353
|
+
if (typeof packs !== "number" && (!packs || typeof packs !== "object" || Array.isArray(packs))) {
|
|
2354
|
+
throw new Error("Expected pack_version to be a number or an object");
|
|
2355
|
+
}
|
|
2356
|
+
const format2 = (type) => {
|
|
2357
|
+
const modern = typeof packs === "object" && ["resource_major", "resource_minor", "data_major", "data_minor"].some((key) => key in packs);
|
|
2358
|
+
const major = typeof packs === "number" ? packs : packs[modern ? `${type}_major` : type];
|
|
2359
|
+
const minor = modern ? packs[`${type}_minor`] : 0;
|
|
2360
|
+
if (typeof major !== "number" || !Number.isSafeInteger(major) || major < 0 || typeof minor !== "number" || !Number.isSafeInteger(minor) || minor < 0) {
|
|
2361
|
+
throw new Error(`Invalid ${type} pack format in version metadata`);
|
|
2362
|
+
}
|
|
2363
|
+
return Object.freeze([major, minor]);
|
|
2364
|
+
};
|
|
2365
|
+
return { assets: format2("resource"), data: format2("data") };
|
|
2366
|
+
}
|
|
2367
|
+
};
|
|
2368
|
+
}
|
|
2369
|
+
});
|
|
2370
|
+
|
|
2189
2371
|
// src/assets/source/archive/ArchiveAssetSource.ts
|
|
2190
2372
|
var ArchiveAssetSource;
|
|
2191
2373
|
var init_ArchiveAssetSource = __esm({
|
|
@@ -2194,35 +2376,77 @@ var init_ArchiveAssetSource = __esm({
|
|
|
2194
2376
|
init_request();
|
|
2195
2377
|
init_HostedAssetSource();
|
|
2196
2378
|
init_BrowserArchiveProxy();
|
|
2379
|
+
init_AssetLoader();
|
|
2380
|
+
init_PackMetadata();
|
|
2381
|
+
init_PackFormats();
|
|
2197
2382
|
ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
|
|
2198
|
-
constructor(archiveProxy) {
|
|
2383
|
+
constructor(archiveProxy, options = {}) {
|
|
2199
2384
|
super();
|
|
2200
|
-
console.log(archiveProxy);
|
|
2201
2385
|
this._archiveProxy = archiveProxy;
|
|
2386
|
+
const copyFormat = (format2) => typeof format2 === "object" ? [format2[0], format2[1]] : format2;
|
|
2387
|
+
this.options = {
|
|
2388
|
+
resourcePackFormat: copyFormat(options.resourcePackFormat),
|
|
2389
|
+
dataPackFormat: copyFormat(options.dataPackFormat)
|
|
2390
|
+
};
|
|
2202
2391
|
}
|
|
2203
|
-
static blob(blob) {
|
|
2204
|
-
return new _ArchiveAssetSource(new BrowserArchiveProxy(blob));
|
|
2392
|
+
static blob(blob, options) {
|
|
2393
|
+
return new _ArchiveAssetSource(new BrowserArchiveProxy(blob), options);
|
|
2205
2394
|
}
|
|
2206
2395
|
get cacheId() {
|
|
2207
2396
|
const id = this._archiveProxy.id;
|
|
2208
|
-
|
|
2397
|
+
const formats = [this.options.resourcePackFormat ?? AssetLoader.version, this.options.dataPackFormat ?? AssetLoader.version];
|
|
2398
|
+
return id === void 0 ? void 0 : `archive-metadata:1:${id}:${JSON.stringify(formats)}`;
|
|
2209
2399
|
}
|
|
2210
2400
|
async getEntries() {
|
|
2211
|
-
return this._archiveProxy.getEntries()
|
|
2401
|
+
return this.entries ??= this._archiveProxy.getEntries().catch((error) => {
|
|
2402
|
+
this.entries = void 0;
|
|
2403
|
+
throw error;
|
|
2404
|
+
});
|
|
2212
2405
|
}
|
|
2213
2406
|
async getEntry(path) {
|
|
2214
2407
|
const entries = await this.getEntries();
|
|
2215
2408
|
return entries.find((e) => e.filename === path);
|
|
2216
2409
|
}
|
|
2410
|
+
async getMetadata(key) {
|
|
2411
|
+
try {
|
|
2412
|
+
return await (this.metadata ??= this.getEntry("pack.mcmeta").then(async (entry) => PackMetadata.parse(entry ? JSON.parse(await (await entry.getData()).text()) : {})).catch((error) => {
|
|
2413
|
+
this.metadata = void 0;
|
|
2414
|
+
throw error;
|
|
2415
|
+
}));
|
|
2416
|
+
} catch (cause) {
|
|
2417
|
+
throw new AssetLoadError(this, key, "pack.mcmeta", cause);
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
async blocks(key) {
|
|
2421
|
+
if (key.rootType !== "assets" && key.rootType !== "data") return false;
|
|
2422
|
+
const metadata = await this.getMetadata(key);
|
|
2423
|
+
const path = `${key.assetType !== void 0 ? key.assetType + "/" : ""}${key.getFullPath()}${key.extension}`;
|
|
2424
|
+
return metadata.blocks(key.namespace, path);
|
|
2425
|
+
}
|
|
2217
2426
|
async get(key, parser) {
|
|
2218
2427
|
const responseParser = HostedAssetSource.PARSER_MAP.get(parser);
|
|
2219
2428
|
return this.load(key, responseParser);
|
|
2220
2429
|
}
|
|
2221
2430
|
async load(key, parser) {
|
|
2222
2431
|
const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
|
|
2432
|
+
const version = AssetLoader.version;
|
|
2433
|
+
let selectedPath = path;
|
|
2223
2434
|
let url;
|
|
2224
2435
|
try {
|
|
2225
|
-
|
|
2436
|
+
let directories = [];
|
|
2437
|
+
if (key.rootType === "assets" || key.rootType === "data") {
|
|
2438
|
+
const metadata = await this.getMetadata(key);
|
|
2439
|
+
if (metadata.hasOverlays) {
|
|
2440
|
+
const format2 = (key.rootType === "assets" ? this.options.resourcePackFormat : this.options.dataPackFormat) ?? await PackFormats.get(version, key.rootType);
|
|
2441
|
+
directories = metadata.overlayDirectories(format2);
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
let entry;
|
|
2445
|
+
for (const directory of [...directories, ""]) {
|
|
2446
|
+
selectedPath = directory ? `${directory}/${path}` : path;
|
|
2447
|
+
entry = await this.getEntry(selectedPath);
|
|
2448
|
+
if (entry) break;
|
|
2449
|
+
}
|
|
2226
2450
|
if (!entry) {
|
|
2227
2451
|
return void 0;
|
|
2228
2452
|
}
|
|
@@ -2235,7 +2459,8 @@ var init_ArchiveAssetSource = __esm({
|
|
|
2235
2459
|
}
|
|
2236
2460
|
return await parser.parse(response);
|
|
2237
2461
|
} catch (cause) {
|
|
2238
|
-
|
|
2462
|
+
if (cause instanceof AssetLoadError) throw cause;
|
|
2463
|
+
throw new AssetLoadError(this, key, selectedPath, cause);
|
|
2239
2464
|
} finally {
|
|
2240
2465
|
if (url !== void 0) {
|
|
2241
2466
|
URL.revokeObjectURL(url);
|
|
@@ -2268,6 +2493,8 @@ var init_archive = __esm({
|
|
|
2268
2493
|
init_ArchiveEntry();
|
|
2269
2494
|
init_ArchiveProxy();
|
|
2270
2495
|
init_BrowserArchiveProxy();
|
|
2496
|
+
init_PackFormats();
|
|
2497
|
+
init_PackMetadata();
|
|
2271
2498
|
}
|
|
2272
2499
|
});
|
|
2273
2500
|
|
|
@@ -2364,13 +2591,14 @@ ${key}` : key;
|
|
|
2364
2591
|
this.addSource("mcassets", new HostedAssetSource(this.ROOT, { retryDefaults: false }));
|
|
2365
2592
|
}
|
|
2366
2593
|
static async getAll(key, parser) {
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2594
|
+
const sources = [...this._SOURCES];
|
|
2595
|
+
const results = [];
|
|
2596
|
+
for (const { source } of sources) {
|
|
2597
|
+
const asset = await source.get(key, parser);
|
|
2598
|
+
if (asset != void 0) results.push(asset);
|
|
2599
|
+
if (await source.blocks(key)) break;
|
|
2370
2600
|
}
|
|
2371
|
-
return
|
|
2372
|
-
return results.filter((r) => r != void 0);
|
|
2373
|
-
});
|
|
2601
|
+
return results;
|
|
2374
2602
|
}
|
|
2375
2603
|
/** Returns the first defined result in source-priority order, without merging assets. */
|
|
2376
2604
|
static async get(key, parser) {
|
|
@@ -2391,13 +2619,17 @@ ${key}` : key;
|
|
|
2391
2619
|
/** Tries each path within a source before considering lower-priority sources. */
|
|
2392
2620
|
static async getFirst(keys, parser) {
|
|
2393
2621
|
const sources = [...this._SOURCES];
|
|
2622
|
+
let remaining = [...keys];
|
|
2394
2623
|
for (const source of sources) {
|
|
2395
|
-
for (const key of
|
|
2624
|
+
for (const key of remaining) {
|
|
2396
2625
|
const result = await source.source.get(key, parser);
|
|
2397
2626
|
if (result !== void 0) {
|
|
2398
2627
|
return { key, asset: result };
|
|
2399
2628
|
}
|
|
2400
2629
|
}
|
|
2630
|
+
const blocked = await Promise.all(remaining.map((key) => source.source.blocks(key)));
|
|
2631
|
+
remaining = remaining.filter((_, index) => !blocked[index]);
|
|
2632
|
+
if (!remaining.length) break;
|
|
2401
2633
|
}
|
|
2402
2634
|
return void 0;
|
|
2403
2635
|
}
|
|
@@ -2856,6 +3088,37 @@ var init_UVMapper = __esm({
|
|
|
2856
3088
|
static facesToUv(faces, originalTextureSize, actualTextureSize) {
|
|
2857
3089
|
return new import_three9.Float32BufferAttribute(this.facesToUvArray(faces, originalTextureSize, actualTextureSize), 2);
|
|
2858
3090
|
}
|
|
3091
|
+
/** Bounds texture sampling to texel centres without changing cropped face UVs. */
|
|
3092
|
+
static setAtlasUvBounds(geometry, faces, atlas) {
|
|
3093
|
+
const uv = geometry.getAttribute("uv");
|
|
3094
|
+
const bounds = new Float32Array(uv.count * 4);
|
|
3095
|
+
for (const [faceIndex, faceName] of CUBE_FACES.entries()) {
|
|
3096
|
+
const texture = faces[faceName]?.texture?.substring(1);
|
|
3097
|
+
const position = texture && atlas.positions[texture];
|
|
3098
|
+
const size = texture && atlas.sizes[texture];
|
|
3099
|
+
let minU = Infinity, minV = Infinity, maxU = -Infinity, maxV = -Infinity;
|
|
3100
|
+
if (position && size) {
|
|
3101
|
+
minU = position[0] / atlas.image.width;
|
|
3102
|
+
maxU = (position[0] + size[0]) / atlas.image.width;
|
|
3103
|
+
minV = 1 - (position[1] + size[1]) / atlas.image.height;
|
|
3104
|
+
maxV = 1 - position[1] / atlas.image.height;
|
|
3105
|
+
} else {
|
|
3106
|
+
for (let corner = 0; corner < 4; corner++) {
|
|
3107
|
+
const index = faceIndex * 4 + corner;
|
|
3108
|
+
minU = Math.min(minU, uv.getX(index));
|
|
3109
|
+
minV = Math.min(minV, uv.getY(index));
|
|
3110
|
+
maxU = Math.max(maxU, uv.getX(index));
|
|
3111
|
+
maxV = Math.max(maxV, uv.getY(index));
|
|
3112
|
+
}
|
|
3113
|
+
}
|
|
3114
|
+
const insetU = Math.min(0.5 / atlas.image.width, (maxU - minU) / 2);
|
|
3115
|
+
const insetV = Math.min(0.5 / atlas.image.height, (maxV - minV) / 2);
|
|
3116
|
+
for (let corner = 0; corner < 4; corner++) {
|
|
3117
|
+
bounds.set([minU + insetU, minV + insetV, maxU - insetU, maxV - insetV], (faceIndex * 4 + corner) * 4);
|
|
3118
|
+
}
|
|
3119
|
+
}
|
|
3120
|
+
geometry.setAttribute("uvBounds", new import_three9.Float32BufferAttribute(bounds, 4));
|
|
3121
|
+
}
|
|
2859
3122
|
static lockUvs(geometry, faces, atlas, rotation) {
|
|
2860
3123
|
const uv = geometry.getAttribute("uv");
|
|
2861
3124
|
for (let faceIndex = 0; faceIndex < CUBE_FACES.length; faceIndex++) {
|
|
@@ -3512,27 +3775,27 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
3512
3775
|
for (const layer of layers) {
|
|
3513
3776
|
const objects = [];
|
|
3514
3777
|
if (poses) {
|
|
3515
|
-
layer.traverse((
|
|
3516
|
-
if (poses.has(
|
|
3778
|
+
layer.traverse((object2) => {
|
|
3779
|
+
if (poses.has(object2)) objects.push(object2);
|
|
3517
3780
|
});
|
|
3518
3781
|
} else {
|
|
3519
3782
|
for (const bone of Object.keys(animation.bones)) {
|
|
3520
|
-
const
|
|
3521
|
-
if (
|
|
3783
|
+
const object2 = layer.getObjectByName(`group:${bone}`);
|
|
3784
|
+
if (object2) objects.push(object2);
|
|
3522
3785
|
}
|
|
3523
3786
|
}
|
|
3524
|
-
for (const
|
|
3525
|
-
const bone =
|
|
3526
|
-
const pose = poses?.get(
|
|
3787
|
+
for (const object2 of objects) {
|
|
3788
|
+
const bone = object2.name.slice("group:".length);
|
|
3789
|
+
const pose = poses?.get(object2);
|
|
3527
3790
|
this.parts.push({
|
|
3528
3791
|
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]) :
|
|
3792
|
+
object: object2,
|
|
3793
|
+
position: object2.position.clone(),
|
|
3794
|
+
rotation: object2.rotation.clone(),
|
|
3795
|
+
scale: object2.scale.clone(),
|
|
3796
|
+
basePosition: pose ? new import_three11.Vector3(...pose.offset) : object2.position.clone(),
|
|
3797
|
+
baseRotation: pose ? new import_three11.Euler(...pose.rotation, "ZYX") : object2.rotation.clone(),
|
|
3798
|
+
baseScale: pose ? new import_three11.Vector3(...pose.scale ?? [1, 1, 1]) : object2.scale.clone()
|
|
3536
3799
|
});
|
|
3537
3800
|
}
|
|
3538
3801
|
}
|
|
@@ -4059,15 +4322,15 @@ var init_SceneObject = __esm({
|
|
|
4059
4322
|
}
|
|
4060
4323
|
}
|
|
4061
4324
|
//</editor-fold>
|
|
4062
|
-
toggleObjectVisibility(
|
|
4063
|
-
if (
|
|
4325
|
+
toggleObjectVisibility(object2, visible) {
|
|
4326
|
+
if (object2) {
|
|
4064
4327
|
if (typeof visible !== "undefined") {
|
|
4065
|
-
|
|
4328
|
+
object2.visible = visible;
|
|
4066
4329
|
} else {
|
|
4067
|
-
|
|
4330
|
+
object2.visible = !object2.visible;
|
|
4068
4331
|
}
|
|
4069
4332
|
this.notifyDirty();
|
|
4070
|
-
return
|
|
4333
|
+
return object2.visible;
|
|
4071
4334
|
}
|
|
4072
4335
|
this.notifyDirty();
|
|
4073
4336
|
return false;
|
|
@@ -4358,8 +4621,8 @@ var init_EntityObject = __esm({
|
|
|
4358
4621
|
this.scrollMaterials.push({ material: mat, offset: mat.map.offset, speed: scroll });
|
|
4359
4622
|
}
|
|
4360
4623
|
}
|
|
4361
|
-
this.getLayerGroup(name)?.traverse((
|
|
4362
|
-
if (isMesh(
|
|
4624
|
+
this.getLayerGroup(name)?.traverse((object2) => {
|
|
4625
|
+
if (isMesh(object2)) object2.material = mat;
|
|
4363
4626
|
});
|
|
4364
4627
|
}));
|
|
4365
4628
|
if (!this.children.length) {
|
|
@@ -4687,8 +4950,8 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
4687
4950
|
return geometry;
|
|
4688
4951
|
}
|
|
4689
4952
|
}
|
|
4690
|
-
function computeMorphedAttributes(
|
|
4691
|
-
if (
|
|
4953
|
+
function computeMorphedAttributes(object2) {
|
|
4954
|
+
if (object2.geometry.isBufferGeometry !== true) {
|
|
4692
4955
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4693
4956
|
return null;
|
|
4694
4957
|
}
|
|
@@ -4701,11 +4964,11 @@ function computeMorphedAttributes(object) {
|
|
|
4701
4964
|
const _morphA = new import_three22.Vector3();
|
|
4702
4965
|
const _morphB = new import_three22.Vector3();
|
|
4703
4966
|
const _morphC = new import_three22.Vector3();
|
|
4704
|
-
function _calculateMorphedAttributeData(
|
|
4967
|
+
function _calculateMorphedAttributeData(object3, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4705
4968
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4706
4969
|
_vB.fromBufferAttribute(attribute, b2);
|
|
4707
4970
|
_vC.fromBufferAttribute(attribute, c2);
|
|
4708
|
-
const morphInfluences =
|
|
4971
|
+
const morphInfluences = object3.morphTargetInfluences;
|
|
4709
4972
|
if (material2.morphTargets && morphAttribute && morphInfluences) {
|
|
4710
4973
|
_morphA.set(0, 0, 0);
|
|
4711
4974
|
_morphB.set(0, 0, 0);
|
|
@@ -4731,10 +4994,10 @@ function computeMorphedAttributes(object) {
|
|
|
4731
4994
|
_vB.add(_morphB);
|
|
4732
4995
|
_vC.add(_morphC);
|
|
4733
4996
|
}
|
|
4734
|
-
if (
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4997
|
+
if (object3.isSkinnedMesh) {
|
|
4998
|
+
object3.boneTransform(a2, _vA);
|
|
4999
|
+
object3.boneTransform(b2, _vB);
|
|
5000
|
+
object3.boneTransform(c2, _vC);
|
|
4738
5001
|
}
|
|
4739
5002
|
modifiedAttributeArray[a2 * 3 + 0] = _vA.x;
|
|
4740
5003
|
modifiedAttributeArray[a2 * 3 + 1] = _vA.y;
|
|
@@ -4746,8 +5009,8 @@ function computeMorphedAttributes(object) {
|
|
|
4746
5009
|
modifiedAttributeArray[c2 * 3 + 1] = _vC.y;
|
|
4747
5010
|
modifiedAttributeArray[c2 * 3 + 2] = _vC.z;
|
|
4748
5011
|
}
|
|
4749
|
-
const geometry =
|
|
4750
|
-
const material =
|
|
5012
|
+
const geometry = object2.geometry;
|
|
5013
|
+
const material = object2.material;
|
|
4751
5014
|
let a, b, c;
|
|
4752
5015
|
const index = geometry.index;
|
|
4753
5016
|
const positionAttribute = geometry.attributes.position;
|
|
@@ -4774,7 +5037,7 @@ function computeMorphedAttributes(object) {
|
|
|
4774
5037
|
b = index.getX(j + 1);
|
|
4775
5038
|
c = index.getX(j + 2);
|
|
4776
5039
|
_calculateMorphedAttributeData(
|
|
4777
|
-
|
|
5040
|
+
object2,
|
|
4778
5041
|
groupMaterial,
|
|
4779
5042
|
positionAttribute,
|
|
4780
5043
|
morphPosition,
|
|
@@ -4785,7 +5048,7 @@ function computeMorphedAttributes(object) {
|
|
|
4785
5048
|
modifiedPosition
|
|
4786
5049
|
);
|
|
4787
5050
|
_calculateMorphedAttributeData(
|
|
4788
|
-
|
|
5051
|
+
object2,
|
|
4789
5052
|
groupMaterial,
|
|
4790
5053
|
normalAttribute,
|
|
4791
5054
|
morphNormal,
|
|
@@ -4805,7 +5068,7 @@ function computeMorphedAttributes(object) {
|
|
|
4805
5068
|
b = index.getX(i + 1);
|
|
4806
5069
|
c = index.getX(i + 2);
|
|
4807
5070
|
_calculateMorphedAttributeData(
|
|
4808
|
-
|
|
5071
|
+
object2,
|
|
4809
5072
|
material,
|
|
4810
5073
|
positionAttribute,
|
|
4811
5074
|
morphPosition,
|
|
@@ -4816,7 +5079,7 @@ function computeMorphedAttributes(object) {
|
|
|
4816
5079
|
modifiedPosition
|
|
4817
5080
|
);
|
|
4818
5081
|
_calculateMorphedAttributeData(
|
|
4819
|
-
|
|
5082
|
+
object2,
|
|
4820
5083
|
material,
|
|
4821
5084
|
normalAttribute,
|
|
4822
5085
|
morphNormal,
|
|
@@ -4840,7 +5103,7 @@ function computeMorphedAttributes(object) {
|
|
|
4840
5103
|
b = j + 1;
|
|
4841
5104
|
c = j + 2;
|
|
4842
5105
|
_calculateMorphedAttributeData(
|
|
4843
|
-
|
|
5106
|
+
object2,
|
|
4844
5107
|
groupMaterial,
|
|
4845
5108
|
positionAttribute,
|
|
4846
5109
|
morphPosition,
|
|
@@ -4851,7 +5114,7 @@ function computeMorphedAttributes(object) {
|
|
|
4851
5114
|
modifiedPosition
|
|
4852
5115
|
);
|
|
4853
5116
|
_calculateMorphedAttributeData(
|
|
4854
|
-
|
|
5117
|
+
object2,
|
|
4855
5118
|
groupMaterial,
|
|
4856
5119
|
normalAttribute,
|
|
4857
5120
|
morphNormal,
|
|
@@ -4871,7 +5134,7 @@ function computeMorphedAttributes(object) {
|
|
|
4871
5134
|
b = i + 1;
|
|
4872
5135
|
c = i + 2;
|
|
4873
5136
|
_calculateMorphedAttributeData(
|
|
4874
|
-
|
|
5137
|
+
object2,
|
|
4875
5138
|
material,
|
|
4876
5139
|
positionAttribute,
|
|
4877
5140
|
morphPosition,
|
|
@@ -4882,7 +5145,7 @@ function computeMorphedAttributes(object) {
|
|
|
4882
5145
|
modifiedPosition
|
|
4883
5146
|
);
|
|
4884
5147
|
_calculateMorphedAttributeData(
|
|
4885
|
-
|
|
5148
|
+
object2,
|
|
4886
5149
|
material,
|
|
4887
5150
|
normalAttribute,
|
|
4888
5151
|
morphNormal,
|
|
@@ -5196,13 +5459,13 @@ var init_ModelObject = __esm({
|
|
|
5196
5459
|
transform.multiply(new import_three25.Matrix4().makeTranslation(-8, -8, -8));
|
|
5197
5460
|
try {
|
|
5198
5461
|
for (const part of parts) {
|
|
5199
|
-
const
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
this.add(
|
|
5204
|
-
await
|
|
5205
|
-
|
|
5462
|
+
const object2 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
|
|
5463
|
+
object2.matrix.copy(transform).multiply(part.transform);
|
|
5464
|
+
object2.matrixWorldNeedsUpdate = true;
|
|
5465
|
+
object2.matrixAutoUpdate = false;
|
|
5466
|
+
this.add(object2);
|
|
5467
|
+
await object2.init();
|
|
5468
|
+
object2.iterateAllMeshes((mesh) => {
|
|
5206
5469
|
const source = mesh.material;
|
|
5207
5470
|
let material = this.specialMaterials.get(source);
|
|
5208
5471
|
if (!material) {
|
|
@@ -5213,7 +5476,7 @@ var init_ModelObject = __esm({
|
|
|
5213
5476
|
mesh.material = material;
|
|
5214
5477
|
});
|
|
5215
5478
|
for (const [name, rotation] of Object.entries(part.rotations)) {
|
|
5216
|
-
|
|
5479
|
+
object2.getGroupByName(name)?.rotation.set(...rotation, "ZYX");
|
|
5217
5480
|
}
|
|
5218
5481
|
}
|
|
5219
5482
|
} catch (error) {
|
|
@@ -5258,6 +5521,7 @@ var init_ModelObject = __esm({
|
|
|
5258
5521
|
if (this.options.uvLockRotation) {
|
|
5259
5522
|
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three25.Euler(...this.options.uvLockRotation));
|
|
5260
5523
|
}
|
|
5524
|
+
UVMapper.setAtlasUvBounds(elGeo, el.faces, this.atlas);
|
|
5261
5525
|
if (this.options.tints) {
|
|
5262
5526
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
5263
5527
|
for (const [faceIndex, faceName] of CUBE_FACES.entries()) {
|
|
@@ -5323,7 +5587,7 @@ var init_ModelObject = __esm({
|
|
|
5323
5587
|
}
|
|
5324
5588
|
applyTextures() {
|
|
5325
5589
|
if (this.atlas) {
|
|
5326
|
-
const mat = Materials.createShadedCanvasMaterial(this.atlas.image.canvas, this.atlas.hasTransparency, false);
|
|
5590
|
+
const mat = Materials.createShadedCanvasMaterial(this.atlas.image.canvas, this.atlas.hasTransparency, false, true);
|
|
5327
5591
|
this.atlasMaterial = mat;
|
|
5328
5592
|
this.atlasTexture = mat.uniforms?.map?.value ?? mat.map;
|
|
5329
5593
|
this.iterateAllMeshes((mesh) => {
|
|
@@ -5688,6 +5952,8 @@ __export(index_node_exports, {
|
|
|
5688
5952
|
NodeCache: () => NodeCache,
|
|
5689
5953
|
NodeEnv: () => NodeEnv,
|
|
5690
5954
|
OrbitControls: () => OrbitControls,
|
|
5955
|
+
PackFormats: () => PackFormats,
|
|
5956
|
+
PackMetadata: () => PackMetadata,
|
|
5691
5957
|
PersistentCache: () => PersistentCache,
|
|
5692
5958
|
Renderer: () => Renderer,
|
|
5693
5959
|
RequestError: () => RequestError,
|
|
@@ -6159,7 +6425,7 @@ var OBJExporter = class {
|
|
|
6159
6425
|
* @param {Object3D} object - The 3D object to export.
|
|
6160
6426
|
* @return {string} The exported OBJ.
|
|
6161
6427
|
*/
|
|
6162
|
-
parse(
|
|
6428
|
+
parse(object2) {
|
|
6163
6429
|
let output = "";
|
|
6164
6430
|
let indexVertex = 0;
|
|
6165
6431
|
let indexVertexUvs = 0;
|
|
@@ -6278,7 +6544,7 @@ var OBJExporter = class {
|
|
|
6278
6544
|
}
|
|
6279
6545
|
indexVertex += nbVertex;
|
|
6280
6546
|
}
|
|
6281
|
-
|
|
6547
|
+
object2.traverse(function(child) {
|
|
6282
6548
|
if (child.isMesh === true) {
|
|
6283
6549
|
parseMesh(child);
|
|
6284
6550
|
}
|
|
@@ -6306,9 +6572,9 @@ var PLYExporter = class {
|
|
|
6306
6572
|
* @param {PLYExporter~Options} options - The export options.
|
|
6307
6573
|
* @return {?(string|ArrayBuffer)} The exported PLY.
|
|
6308
6574
|
*/
|
|
6309
|
-
parse(
|
|
6575
|
+
parse(object2, onDone, options = {}) {
|
|
6310
6576
|
function traverseMeshes(cb) {
|
|
6311
|
-
|
|
6577
|
+
object2.traverse(function(child) {
|
|
6312
6578
|
if (child.isMesh === true || child.isPoints) {
|
|
6313
6579
|
const mesh = child;
|
|
6314
6580
|
const geometry = mesh.geometry;
|
|
@@ -6341,7 +6607,7 @@ var PLYExporter = class {
|
|
|
6341
6607
|
for (const name of customAttributeNames) customTypes[name] = "float";
|
|
6342
6608
|
let vertexCount = 0;
|
|
6343
6609
|
let faceCount = 0;
|
|
6344
|
-
|
|
6610
|
+
object2.traverse(function(child) {
|
|
6345
6611
|
if (child.isMesh === true) {
|
|
6346
6612
|
const mesh = child;
|
|
6347
6613
|
const geometry = mesh.geometry;
|
|
@@ -7129,12 +7395,12 @@ var GLTFWriter = class {
|
|
|
7129
7395
|
* @param {THREE.Object3D|THREE.Material|THREE.BufferGeometry|THREE.AnimationClip} object
|
|
7130
7396
|
* @param {Object} objectDef
|
|
7131
7397
|
*/
|
|
7132
|
-
serializeUserData(
|
|
7133
|
-
if (Object.keys(
|
|
7398
|
+
serializeUserData(object2, objectDef) {
|
|
7399
|
+
if (Object.keys(object2.userData).length === 0) return;
|
|
7134
7400
|
const options = this.options;
|
|
7135
7401
|
const extensionsUsed = this.extensionsUsed;
|
|
7136
7402
|
try {
|
|
7137
|
-
const json = JSON.parse(JSON.stringify(
|
|
7403
|
+
const json = JSON.parse(JSON.stringify(object2.userData));
|
|
7138
7404
|
if (options.includeCustomExtensions && json.gltfExtensions) {
|
|
7139
7405
|
if (objectDef.extensions === void 0) objectDef.extensions = {};
|
|
7140
7406
|
for (const extensionName in json.gltfExtensions) {
|
|
@@ -7145,7 +7411,7 @@ var GLTFWriter = class {
|
|
|
7145
7411
|
}
|
|
7146
7412
|
if (Object.keys(json).length > 0) objectDef.extras = json;
|
|
7147
7413
|
} catch (error) {
|
|
7148
|
-
console.warn("THREE.GLTFExporter: userData of '" +
|
|
7414
|
+
console.warn("THREE.GLTFExporter: userData of '" + object2.name + "' won't be serialized because of JSON.stringify error - " + error.message);
|
|
7149
7415
|
}
|
|
7150
7416
|
}
|
|
7151
7417
|
/**
|
|
@@ -7518,7 +7784,7 @@ var GLTFWriter = class {
|
|
|
7518
7784
|
* @param {string} mimeType export format
|
|
7519
7785
|
* @return {number} Index of the processed texture in the "images" array
|
|
7520
7786
|
*/
|
|
7521
|
-
processImage(image,
|
|
7787
|
+
processImage(image, format2, flipY, mimeType = "image/png") {
|
|
7522
7788
|
if (image !== null) {
|
|
7523
7789
|
const writer = this;
|
|
7524
7790
|
const cache = writer.cache;
|
|
@@ -7542,8 +7808,8 @@ var GLTFWriter = class {
|
|
|
7542
7808
|
ctx.scale(1, -1);
|
|
7543
7809
|
}
|
|
7544
7810
|
if (image.data !== void 0) {
|
|
7545
|
-
if (
|
|
7546
|
-
console.error("GLTFExporter: Only RGBAFormat is supported.",
|
|
7811
|
+
if (format2 !== import_three18.RGBAFormat) {
|
|
7812
|
+
console.error("GLTFExporter: Only RGBAFormat is supported.", format2);
|
|
7547
7813
|
}
|
|
7548
7814
|
if (image.width > options.maxTextureSize || image.height > options.maxTextureSize) {
|
|
7549
7815
|
console.warn("GLTFExporter: Image size is bigger than maxTextureSize", image);
|
|
@@ -8071,13 +8337,13 @@ var GLTFWriter = class {
|
|
|
8071
8337
|
* @param {THREE.Object3D} object
|
|
8072
8338
|
* @return {?number}
|
|
8073
8339
|
*/
|
|
8074
|
-
processSkin(
|
|
8340
|
+
processSkin(object2) {
|
|
8075
8341
|
const json = this.json;
|
|
8076
8342
|
const nodeMap = this.nodeMap;
|
|
8077
|
-
const node = json.nodes[nodeMap.get(
|
|
8078
|
-
const skeleton =
|
|
8343
|
+
const node = json.nodes[nodeMap.get(object2)];
|
|
8344
|
+
const skeleton = object2.skeleton;
|
|
8079
8345
|
if (skeleton === void 0) return null;
|
|
8080
|
-
const rootJoint =
|
|
8346
|
+
const rootJoint = object2.skeleton.bones[0];
|
|
8081
8347
|
if (rootJoint === void 0) return null;
|
|
8082
8348
|
const joints = [];
|
|
8083
8349
|
const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
|
|
@@ -8085,7 +8351,7 @@ var GLTFWriter = class {
|
|
|
8085
8351
|
for (let i = 0; i < skeleton.bones.length; ++i) {
|
|
8086
8352
|
joints.push(nodeMap.get(skeleton.bones[i]));
|
|
8087
8353
|
temporaryBoneInverse.copy(skeleton.boneInverses[i]);
|
|
8088
|
-
temporaryBoneInverse.multiply(
|
|
8354
|
+
temporaryBoneInverse.multiply(object2.bindMatrix).toArray(inverseBindMatrices, i * 16);
|
|
8089
8355
|
}
|
|
8090
8356
|
if (json.skins === void 0) json.skins = [];
|
|
8091
8357
|
json.skins.push({
|
|
@@ -8101,19 +8367,19 @@ var GLTFWriter = class {
|
|
|
8101
8367
|
* @param {THREE.Object3D} object Object3D to processNodeAsync
|
|
8102
8368
|
* @return {Promise<number>} Index of the node in the nodes list
|
|
8103
8369
|
*/
|
|
8104
|
-
async processNodeAsync(
|
|
8370
|
+
async processNodeAsync(object2) {
|
|
8105
8371
|
const json = this.json;
|
|
8106
8372
|
const options = this.options;
|
|
8107
8373
|
const nodeMap = this.nodeMap;
|
|
8108
8374
|
if (!json.nodes) json.nodes = [];
|
|
8109
|
-
if (
|
|
8110
|
-
return await this._processNodeWithPivotAsync(
|
|
8375
|
+
if (object2.pivot !== null) {
|
|
8376
|
+
return await this._processNodeWithPivotAsync(object2);
|
|
8111
8377
|
}
|
|
8112
8378
|
const nodeDef = {};
|
|
8113
8379
|
if (options.trs) {
|
|
8114
|
-
const rotation =
|
|
8115
|
-
const position =
|
|
8116
|
-
const scale =
|
|
8380
|
+
const rotation = object2.quaternion.toArray();
|
|
8381
|
+
const position = object2.position.toArray();
|
|
8382
|
+
const scale = object2.scale.toArray();
|
|
8117
8383
|
if (!equalArray(rotation, [0, 0, 0, 1])) {
|
|
8118
8384
|
nodeDef.rotation = rotation;
|
|
8119
8385
|
}
|
|
@@ -8124,28 +8390,28 @@ var GLTFWriter = class {
|
|
|
8124
8390
|
nodeDef.scale = scale;
|
|
8125
8391
|
}
|
|
8126
8392
|
} else {
|
|
8127
|
-
if (
|
|
8128
|
-
|
|
8393
|
+
if (object2.matrixAutoUpdate) {
|
|
8394
|
+
object2.updateMatrix();
|
|
8129
8395
|
}
|
|
8130
|
-
if (isIdentityMatrix(
|
|
8131
|
-
nodeDef.matrix =
|
|
8396
|
+
if (isIdentityMatrix(object2.matrix) === false) {
|
|
8397
|
+
nodeDef.matrix = object2.matrix.elements;
|
|
8132
8398
|
}
|
|
8133
8399
|
}
|
|
8134
|
-
if (
|
|
8135
|
-
this.serializeUserData(
|
|
8136
|
-
if (
|
|
8137
|
-
const meshIndex = await this.processMeshAsync(
|
|
8400
|
+
if (object2.name !== "") nodeDef.name = String(object2.name);
|
|
8401
|
+
this.serializeUserData(object2, nodeDef);
|
|
8402
|
+
if (object2.isMesh || object2.isLine || object2.isPoints) {
|
|
8403
|
+
const meshIndex = await this.processMeshAsync(object2);
|
|
8138
8404
|
if (meshIndex !== null) nodeDef.mesh = meshIndex;
|
|
8139
|
-
} else if (
|
|
8140
|
-
nodeDef.camera = this.processCamera(
|
|
8405
|
+
} else if (object2.isCamera) {
|
|
8406
|
+
nodeDef.camera = this.processCamera(object2);
|
|
8141
8407
|
}
|
|
8142
|
-
if (
|
|
8408
|
+
if (object2.isSkinnedMesh) this.skins.push(object2);
|
|
8143
8409
|
const nodeIndex = json.nodes.push(nodeDef) - 1;
|
|
8144
|
-
nodeMap.set(
|
|
8145
|
-
if (
|
|
8410
|
+
nodeMap.set(object2, nodeIndex);
|
|
8411
|
+
if (object2.children.length > 0) {
|
|
8146
8412
|
const children = [];
|
|
8147
|
-
for (let i = 0, l =
|
|
8148
|
-
const child =
|
|
8413
|
+
for (let i = 0, l = object2.children.length; i < l; i++) {
|
|
8414
|
+
const child = object2.children[i];
|
|
8149
8415
|
if (child.visible || options.onlyVisible === false) {
|
|
8150
8416
|
const childNodeIndex = await this.processNodeAsync(child);
|
|
8151
8417
|
if (childNodeIndex !== null) children.push(childNodeIndex);
|
|
@@ -8154,7 +8420,7 @@ var GLTFWriter = class {
|
|
|
8154
8420
|
if (children.length > 0) nodeDef.children = children;
|
|
8155
8421
|
}
|
|
8156
8422
|
await this._invokeAllAsync(function(ext) {
|
|
8157
|
-
ext.writeNode && ext.writeNode(
|
|
8423
|
+
ext.writeNode && ext.writeNode(object2, nodeDef);
|
|
8158
8424
|
});
|
|
8159
8425
|
return nodeIndex;
|
|
8160
8426
|
}
|
|
@@ -8163,19 +8429,19 @@ var GLTFWriter = class {
|
|
|
8163
8429
|
* @param {THREE.Object3D} object Object3D with pivot
|
|
8164
8430
|
* @return {Promise<number>} Index of the container node
|
|
8165
8431
|
*/
|
|
8166
|
-
async _processNodeWithPivotAsync(
|
|
8432
|
+
async _processNodeWithPivotAsync(object2) {
|
|
8167
8433
|
const json = this.json;
|
|
8168
8434
|
const options = this.options;
|
|
8169
8435
|
const nodeMap = this.nodeMap;
|
|
8170
|
-
const pivot =
|
|
8436
|
+
const pivot = object2.pivot;
|
|
8171
8437
|
const containerDef = {};
|
|
8172
|
-
const rotation =
|
|
8438
|
+
const rotation = object2.quaternion.toArray();
|
|
8173
8439
|
const position = [
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8440
|
+
object2.position.x + pivot.x,
|
|
8441
|
+
object2.position.y + pivot.y,
|
|
8442
|
+
object2.position.z + pivot.z
|
|
8177
8443
|
];
|
|
8178
|
-
const scale =
|
|
8444
|
+
const scale = object2.scale.toArray();
|
|
8179
8445
|
if (!equalArray(rotation, [0, 0, 0, 1])) {
|
|
8180
8446
|
containerDef.rotation = rotation;
|
|
8181
8447
|
}
|
|
@@ -8186,28 +8452,28 @@ var GLTFWriter = class {
|
|
|
8186
8452
|
containerDef.scale = scale;
|
|
8187
8453
|
}
|
|
8188
8454
|
containerDef.extras = { pivot: pivot.toArray() };
|
|
8189
|
-
if (
|
|
8190
|
-
this.serializeUserData(
|
|
8455
|
+
if (object2.name !== "") containerDef.name = String(object2.name);
|
|
8456
|
+
this.serializeUserData(object2, containerDef);
|
|
8191
8457
|
const containerIndex = json.nodes.push(containerDef) - 1;
|
|
8192
|
-
nodeMap.set(
|
|
8458
|
+
nodeMap.set(object2, containerIndex);
|
|
8193
8459
|
const childDef = {};
|
|
8194
8460
|
const childPosition = [-pivot.x, -pivot.y, -pivot.z];
|
|
8195
8461
|
if (!equalArray(childPosition, [0, 0, 0])) {
|
|
8196
8462
|
childDef.translation = childPosition;
|
|
8197
8463
|
}
|
|
8198
|
-
if (
|
|
8199
|
-
const meshIndex = await this.processMeshAsync(
|
|
8464
|
+
if (object2.isMesh || object2.isLine || object2.isPoints) {
|
|
8465
|
+
const meshIndex = await this.processMeshAsync(object2);
|
|
8200
8466
|
if (meshIndex !== null) childDef.mesh = meshIndex;
|
|
8201
|
-
} else if (
|
|
8202
|
-
childDef.camera = this.processCamera(
|
|
8467
|
+
} else if (object2.isCamera) {
|
|
8468
|
+
childDef.camera = this.processCamera(object2);
|
|
8203
8469
|
}
|
|
8204
|
-
if (
|
|
8470
|
+
if (object2.isSkinnedMesh) this.skins.push(object2);
|
|
8205
8471
|
const childIndex = json.nodes.push(childDef) - 1;
|
|
8206
8472
|
const containerChildren = [childIndex];
|
|
8207
|
-
if (
|
|
8473
|
+
if (object2.children.length > 0) {
|
|
8208
8474
|
const grandchildren = [];
|
|
8209
|
-
for (let i = 0, l =
|
|
8210
|
-
const child =
|
|
8475
|
+
for (let i = 0, l = object2.children.length; i < l; i++) {
|
|
8476
|
+
const child = object2.children[i];
|
|
8211
8477
|
if (child.visible || options.onlyVisible === false) {
|
|
8212
8478
|
const childNodeIndex = await this.processNodeAsync(child);
|
|
8213
8479
|
if (childNodeIndex !== null) grandchildren.push(childNodeIndex);
|
|
@@ -8217,7 +8483,7 @@ var GLTFWriter = class {
|
|
|
8217
8483
|
}
|
|
8218
8484
|
containerDef.children = containerChildren;
|
|
8219
8485
|
await this._invokeAllAsync(function(ext) {
|
|
8220
|
-
ext.writeNode && ext.writeNode(
|
|
8486
|
+
ext.writeNode && ext.writeNode(object2, containerDef);
|
|
8221
8487
|
});
|
|
8222
8488
|
return containerIndex;
|
|
8223
8489
|
}
|
|
@@ -8660,10 +8926,10 @@ var GLTFMeshGpuInstancing = class {
|
|
|
8660
8926
|
this.writer = writer;
|
|
8661
8927
|
this.name = "EXT_mesh_gpu_instancing";
|
|
8662
8928
|
}
|
|
8663
|
-
writeNode(
|
|
8664
|
-
if (!
|
|
8929
|
+
writeNode(object2, nodeDef) {
|
|
8930
|
+
if (!object2.isInstancedMesh) return;
|
|
8665
8931
|
const writer = this.writer;
|
|
8666
|
-
const mesh =
|
|
8932
|
+
const mesh = object2;
|
|
8667
8933
|
const translationAttr = new Float32Array(mesh.count * 3);
|
|
8668
8934
|
const rotationAttr = new Float32Array(mesh.count * 4);
|
|
8669
8935
|
const scaleAttr = new Float32Array(mesh.count * 3);
|
|
@@ -8853,8 +9119,8 @@ var SceneExporter = class {
|
|
|
8853
9119
|
}
|
|
8854
9120
|
}
|
|
8855
9121
|
};
|
|
8856
|
-
function localMatrix(
|
|
8857
|
-
return
|
|
9122
|
+
function localMatrix(object2) {
|
|
9123
|
+
return object2.matrixAutoUpdate ? new import_three19.Matrix4().compose(object2.position, object2.quaternion, object2.scale) : object2.matrix.clone();
|
|
8858
9124
|
}
|
|
8859
9125
|
function createSnapshot(root, gltf, bakeColors = false) {
|
|
8860
9126
|
const scene = new import_three19.Scene();
|
|
@@ -8958,10 +9224,10 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8958
9224
|
scene.add(copy);
|
|
8959
9225
|
}
|
|
8960
9226
|
};
|
|
8961
|
-
const visit = (
|
|
8962
|
-
if (!
|
|
8963
|
-
const world = parentWorld.clone().multiply(localMatrix(
|
|
8964
|
-
const mesh =
|
|
9227
|
+
const visit = (object2, parentWorld) => {
|
|
9228
|
+
if (!object2.visible) return;
|
|
9229
|
+
const world = parentWorld.clone().multiply(localMatrix(object2));
|
|
9230
|
+
const mesh = object2;
|
|
8965
9231
|
if (mesh.isMesh) {
|
|
8966
9232
|
const instanced = mesh;
|
|
8967
9233
|
if (instanced.isInstancedMesh) {
|
|
@@ -8975,7 +9241,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8975
9241
|
addMesh(mesh, world);
|
|
8976
9242
|
}
|
|
8977
9243
|
}
|
|
8978
|
-
for (const child of
|
|
9244
|
+
for (const child of object2.children) visit(child, world);
|
|
8979
9245
|
};
|
|
8980
9246
|
try {
|
|
8981
9247
|
const ancestors = [];
|
|
@@ -9207,11 +9473,11 @@ var GuiHelper = class {
|
|
|
9207
9473
|
switch (recipe.type) {
|
|
9208
9474
|
case "minecraft:crafting_shaped":
|
|
9209
9475
|
case "crafting_shaped": {
|
|
9210
|
-
const
|
|
9211
|
-
if (!
|
|
9476
|
+
const pattern2 = recipe.pattern;
|
|
9477
|
+
if (!pattern2.length || pattern2.length > 3 || !pattern2[0].length || pattern2[0].length > 3 || pattern2.some((row) => row.length !== pattern2[0].length)) {
|
|
9212
9478
|
throw new Error("Crafting patterns must be rectangular, with 1\u20133 rows and columns");
|
|
9213
9479
|
}
|
|
9214
|
-
const cells =
|
|
9480
|
+
const cells = pattern2.flatMap((row, y) => row.split("").map((symbol, x) => ({ symbol, x, y }))).filter((cell) => cell.symbol !== " ");
|
|
9215
9481
|
if (!cells.length) throw new Error("Crafting patterns must contain an ingredient");
|
|
9216
9482
|
const minX = Math.min(...cells.map((cell) => cell.x)), maxX = Math.max(...cells.map((cell) => cell.x));
|
|
9217
9483
|
const minY = Math.min(...cells.map((cell) => cell.y)), maxY = Math.max(...cells.map((cell) => cell.y));
|
|
@@ -9623,29 +9889,29 @@ var SceneInspector = class {
|
|
|
9623
9889
|
this.objectControlsContainer.innerHTML = "";
|
|
9624
9890
|
this.addControls(targetObject, targetIntersection, instance);
|
|
9625
9891
|
}
|
|
9626
|
-
addControls(
|
|
9892
|
+
addControls(object2, intersection, instance) {
|
|
9627
9893
|
const container = document.createElement("div");
|
|
9628
9894
|
container.append(this.separator("Select Parent/Child"));
|
|
9629
|
-
if (
|
|
9630
|
-
container.append(this.buttonControl("Select Parent " +
|
|
9631
|
-
this.selectObject(
|
|
9895
|
+
if (object2.parent) {
|
|
9896
|
+
container.append(this.buttonControl("Select Parent " + object2.parent.constructor.name + " " + object2.parent.name, "P", () => {
|
|
9897
|
+
this.selectObject(object2.parent, intersection, instance);
|
|
9632
9898
|
}));
|
|
9633
9899
|
}
|
|
9634
|
-
if (
|
|
9900
|
+
if (object2.children.length > 0) {
|
|
9635
9901
|
let i = 1;
|
|
9636
|
-
for (let child of
|
|
9902
|
+
for (let child of object2.children) {
|
|
9637
9903
|
container.append(this.buttonControl("Select Child " + child.constructor.name + " " + child.name, "C" + i++, () => {
|
|
9638
9904
|
this.selectObject(child, intersection, instance);
|
|
9639
9905
|
}));
|
|
9640
9906
|
}
|
|
9641
9907
|
}
|
|
9642
9908
|
container.append(this.separator());
|
|
9643
|
-
const selectedInstance = instance && (
|
|
9909
|
+
const selectedInstance = instance && (object2 === instance.instanceable || object2 === intersection?.object) ? instance : void 0;
|
|
9644
9910
|
if (!selectedInstance) {
|
|
9645
|
-
container.append(this.toggleControl("Visibility", "V",
|
|
9911
|
+
container.append(this.toggleControl("Visibility", "V", object2.visible, (v) => object2.visible = v));
|
|
9646
9912
|
}
|
|
9647
9913
|
container.append(this.separator("Mesh"));
|
|
9648
|
-
this.addObjectControls(
|
|
9914
|
+
this.addObjectControls(object2, intersection, container, selectedInstance);
|
|
9649
9915
|
container.append(this.separator());
|
|
9650
9916
|
this.objectControlsContainer.append(container);
|
|
9651
9917
|
}
|
|
@@ -10216,8 +10482,8 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
10216
10482
|
return false;
|
|
10217
10483
|
}
|
|
10218
10484
|
return this._models.some((model) => {
|
|
10219
|
-
const
|
|
10220
|
-
return
|
|
10485
|
+
const object2 = isInstanceReference(model) ? model.instanceable : model;
|
|
10486
|
+
return object2.isOpaqueFullCube && this.getModelCullMask(model, 63) === 63;
|
|
10221
10487
|
});
|
|
10222
10488
|
}
|
|
10223
10489
|
getModelMatrix(model) {
|
|
@@ -10226,8 +10492,8 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
10226
10492
|
return model.matrix.clone();
|
|
10227
10493
|
}
|
|
10228
10494
|
getModelCullMask(model, worldMask) {
|
|
10229
|
-
const
|
|
10230
|
-
if (
|
|
10495
|
+
const object2 = isInstanceReference(model) ? model.instanceable : model;
|
|
10496
|
+
if (object2.options.displayPosition) return 0;
|
|
10231
10497
|
const position = new import_three32.Vector3();
|
|
10232
10498
|
const rotation = new import_three32.Quaternion();
|
|
10233
10499
|
const scale = new import_three32.Vector3();
|
|
@@ -10244,14 +10510,14 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
10244
10510
|
replacements.push(model);
|
|
10245
10511
|
continue;
|
|
10246
10512
|
}
|
|
10247
|
-
const
|
|
10513
|
+
const object2 = isInstanceReference(model) ? model.instanceable : model;
|
|
10248
10514
|
const cullMask = this.getModelCullMask(model, worldMask);
|
|
10249
|
-
if (cullMask === (
|
|
10515
|
+
if (cullMask === (object2.options.cullMask ?? 0)) {
|
|
10250
10516
|
replacements.push(model);
|
|
10251
10517
|
continue;
|
|
10252
10518
|
}
|
|
10253
10519
|
const matrix = this.getModelMatrix(model);
|
|
10254
|
-
const replacement = await this.scene.addModel(
|
|
10520
|
+
const replacement = await this.scene.addModel(object2.originalModel, { ...object2.options, cullMask });
|
|
10255
10521
|
replacements.push(replacement);
|
|
10256
10522
|
if (isInstanceReference(replacement)) {
|
|
10257
10523
|
replacement.setMatrix(matrix);
|
|
@@ -10259,8 +10525,8 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
10259
10525
|
replacement.matrix.copy(matrix);
|
|
10260
10526
|
replacement.matrixWorldNeedsUpdate = true;
|
|
10261
10527
|
matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
10262
|
-
replacement.matrixAutoUpdate =
|
|
10263
|
-
replacement.visible =
|
|
10528
|
+
replacement.matrixAutoUpdate = object2.matrixAutoUpdate;
|
|
10529
|
+
replacement.visible = object2.visible;
|
|
10264
10530
|
}
|
|
10265
10531
|
}
|
|
10266
10532
|
} catch (error) {
|
|
@@ -12178,9 +12444,9 @@ var SchematicParser = class {
|
|
|
12178
12444
|
* Parses a legacy schematic using custom mappings before the bundled defaults.
|
|
12179
12445
|
* Keys are `id:metadata`; values are block states such as `minecraft:oak_log[axis=x]`.
|
|
12180
12446
|
*/
|
|
12181
|
-
static async parse(nbt, customMappings = {}) {
|
|
12447
|
+
static async parse(nbt, customMappings = {}, options = {}) {
|
|
12182
12448
|
const tags = nbt.value;
|
|
12183
|
-
if (tags.Materials?.type !== "string" || tags.Materials.value !== "Alpha") {
|
|
12449
|
+
if (!options.lenient && (tags.Materials?.type !== "string" || tags.Materials.value !== "Alpha")) {
|
|
12184
12450
|
throw new MineRenderError("Schematic Materials must be Alpha");
|
|
12185
12451
|
}
|
|
12186
12452
|
const size = ["Width", "Height", "Length"].map((name) => {
|
|
@@ -12221,8 +12487,16 @@ var SchematicParser = class {
|
|
|
12221
12487
|
const id = high << 8 | ids.value[index] & 255;
|
|
12222
12488
|
const metadata = data.value[index] & 255;
|
|
12223
12489
|
const key = `${id}:${metadata}`;
|
|
12224
|
-
|
|
12225
|
-
if (!mapped
|
|
12490
|
+
let mapped = customMappings[key] ?? mapping[key];
|
|
12491
|
+
if (!mapped && options.lenient) {
|
|
12492
|
+
mapped = customMappings[`${id}:0`] ?? mapping[`${id}:0`];
|
|
12493
|
+
}
|
|
12494
|
+
if (!mapped) {
|
|
12495
|
+
if (options.lenient) {
|
|
12496
|
+
continue;
|
|
12497
|
+
}
|
|
12498
|
+
throw new MineRenderError(`Unsupported legacy block ${id}:${metadata} at schematic index ${index}`);
|
|
12499
|
+
}
|
|
12226
12500
|
const [type, state] = mapped.split("[");
|
|
12227
12501
|
if (type === "minecraft:air") continue;
|
|
12228
12502
|
const properties = {};
|
|
@@ -13383,53 +13657,53 @@ var MineRenderScene = class _MineRenderScene extends import_three34.Scene {
|
|
|
13383
13657
|
this.DEFAULT_OPTIONS = (0, import_ts_deepmerge8.default)({}, {});
|
|
13384
13658
|
}
|
|
13385
13659
|
add(...objects) {
|
|
13386
|
-
for (const
|
|
13660
|
+
for (const object2 of objects) {
|
|
13387
13661
|
this.dirty = true;
|
|
13388
13662
|
try {
|
|
13389
|
-
super.add(
|
|
13663
|
+
super.add(object2);
|
|
13390
13664
|
} finally {
|
|
13391
|
-
if (
|
|
13392
|
-
this.updateObjectRegistration(
|
|
13665
|
+
if (object2?.isObject3D && object2 !== this) {
|
|
13666
|
+
this.updateObjectRegistration(object2, object2.parent === this);
|
|
13393
13667
|
}
|
|
13394
13668
|
}
|
|
13395
13669
|
}
|
|
13396
13670
|
return this;
|
|
13397
13671
|
}
|
|
13398
13672
|
remove(...objects) {
|
|
13399
|
-
for (const
|
|
13400
|
-
if (!this.children.includes(
|
|
13673
|
+
for (const object2 of objects) {
|
|
13674
|
+
if (!this.children.includes(object2)) continue;
|
|
13401
13675
|
this.dirty = true;
|
|
13402
|
-
this.updateObjectRegistration(
|
|
13676
|
+
this.updateObjectRegistration(object2, false);
|
|
13403
13677
|
try {
|
|
13404
|
-
super.remove(
|
|
13678
|
+
super.remove(object2);
|
|
13405
13679
|
} finally {
|
|
13406
|
-
this.updateObjectRegistration(
|
|
13680
|
+
this.updateObjectRegistration(object2, object2.parent === this);
|
|
13407
13681
|
}
|
|
13408
13682
|
}
|
|
13409
13683
|
return this;
|
|
13410
13684
|
}
|
|
13411
|
-
updateObjectRegistration(
|
|
13412
|
-
if (this.observedObjects.has(
|
|
13413
|
-
const observable =
|
|
13685
|
+
updateObjectRegistration(object2, attached) {
|
|
13686
|
+
if (this.observedObjects.has(object2) === attached) return;
|
|
13687
|
+
const observable = object2;
|
|
13414
13688
|
if (attached) {
|
|
13415
|
-
this.observedObjects.add(
|
|
13689
|
+
this.observedObjects.add(object2);
|
|
13416
13690
|
observable.addEventListener("change", this.onObjectChange);
|
|
13417
13691
|
} else {
|
|
13418
|
-
this.observedObjects.delete(
|
|
13692
|
+
this.observedObjects.delete(object2);
|
|
13419
13693
|
observable.removeEventListener("change", this.onObjectChange);
|
|
13420
13694
|
}
|
|
13421
13695
|
const change = attached ? 1 : -1;
|
|
13422
13696
|
this.stats.objectCount += change;
|
|
13423
|
-
if (isSceneObject(
|
|
13697
|
+
if (isSceneObject(object2)) {
|
|
13424
13698
|
this.stats.sceneObjectCount += change;
|
|
13425
13699
|
}
|
|
13426
13700
|
}
|
|
13427
|
-
async initAndAdd(...
|
|
13701
|
+
async initAndAdd(...object2) {
|
|
13428
13702
|
this.dirty = true;
|
|
13429
|
-
for (let obj of
|
|
13703
|
+
for (let obj of object2) {
|
|
13430
13704
|
await obj.init();
|
|
13431
13705
|
}
|
|
13432
|
-
return this.add(...
|
|
13706
|
+
return this.add(...object2);
|
|
13433
13707
|
}
|
|
13434
13708
|
async addSceneObject(asset, objectSupplier, _options, parent = this) {
|
|
13435
13709
|
this.dirty = true;
|
|
@@ -13508,11 +13782,11 @@ var _changeEvent = { type: "change" };
|
|
|
13508
13782
|
var _startEvent = { type: "start" };
|
|
13509
13783
|
var _endEvent = { type: "end" };
|
|
13510
13784
|
var OrbitControls = class extends import_three35.EventDispatcher {
|
|
13511
|
-
constructor(
|
|
13785
|
+
constructor(object2, domElement) {
|
|
13512
13786
|
super();
|
|
13513
13787
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
13514
13788
|
if (domElement === document) console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
|
|
13515
|
-
this.object =
|
|
13789
|
+
this.object = object2;
|
|
13516
13790
|
this.domElement = domElement;
|
|
13517
13791
|
this.domElement.style.touchAction = "none";
|
|
13518
13792
|
this.enabled = true;
|
|
@@ -13569,7 +13843,7 @@ var OrbitControls = class extends import_three35.EventDispatcher {
|
|
|
13569
13843
|
};
|
|
13570
13844
|
this.update = function() {
|
|
13571
13845
|
const offset = new import_three35.Vector3();
|
|
13572
|
-
const quat = new import_three35.Quaternion().setFromUnitVectors(
|
|
13846
|
+
const quat = new import_three35.Quaternion().setFromUnitVectors(object2.up, new import_three35.Vector3(0, 1, 0));
|
|
13573
13847
|
const quatInverse = quat.clone().invert();
|
|
13574
13848
|
const lastPosition = new import_three35.Vector3();
|
|
13575
13849
|
const lastQuaternion = new import_three35.Quaternion();
|
|
@@ -14134,8 +14408,8 @@ var OrbitControls = class extends import_three35.EventDispatcher {
|
|
|
14134
14408
|
}
|
|
14135
14409
|
};
|
|
14136
14410
|
var MapControls = class extends OrbitControls {
|
|
14137
|
-
constructor(
|
|
14138
|
-
super(
|
|
14411
|
+
constructor(object2, domElement) {
|
|
14412
|
+
super(object2, domElement);
|
|
14139
14413
|
this.screenSpacePanning = false;
|
|
14140
14414
|
this.mouseButtons.LEFT = import_three35.MOUSE.PAN;
|
|
14141
14415
|
this.mouseButtons.RIGHT = import_three35.MOUSE.ROTATE;
|
|
@@ -15063,16 +15337,16 @@ var SectionModels = class {
|
|
|
15063
15337
|
if (!models) this.models.set(model, models = /* @__PURE__ */ new Map());
|
|
15064
15338
|
const key = JSON.stringify([rotation.x, rotation.y, rotation.z, variant.uvlock, tints]);
|
|
15065
15339
|
const template = await cached(models, key, async () => {
|
|
15066
|
-
const
|
|
15340
|
+
const object2 = new SectionModel(model, {
|
|
15067
15341
|
instanceMeshes: false,
|
|
15068
15342
|
mergeMeshes: false,
|
|
15069
15343
|
tints,
|
|
15070
15344
|
uvLockRotation: variant.uvlock && (rotation.x !== 0 || rotation.y !== 0) ? [rotation.x, rotation.y, rotation.z] : void 0
|
|
15071
15345
|
});
|
|
15072
|
-
await
|
|
15073
|
-
const geometry =
|
|
15346
|
+
await object2.init();
|
|
15347
|
+
const geometry = object2.children[0].geometry;
|
|
15074
15348
|
geometry.applyMatrix4(new import_three38.Matrix4().makeRotationFromEuler(rotation));
|
|
15075
|
-
|
|
15349
|
+
object2.clear();
|
|
15076
15350
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
15077
15351
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
15078
15352
|
if (local < 0) return 0;
|
|
@@ -15260,10 +15534,10 @@ var MineRenderWorld = class {
|
|
|
15260
15534
|
await block.object.updateFluid((x, y, z) => {
|
|
15261
15535
|
const neighbor = pos.clone().add(new import_three39.Vector3(x, y, z));
|
|
15262
15536
|
const section = this.getChunkAt(neighbor);
|
|
15263
|
-
const
|
|
15537
|
+
const object2 = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
|
|
15264
15538
|
return {
|
|
15265
|
-
fluid:
|
|
15266
|
-
level:
|
|
15539
|
+
fluid: object2?.fluidKind,
|
|
15540
|
+
level: object2?.fluidLevel,
|
|
15267
15541
|
solid: section?.isOccludingAt(neighbor) ?? false
|
|
15268
15542
|
};
|
|
15269
15543
|
});
|
|
@@ -15383,14 +15657,17 @@ var SectionMesh = class _SectionMesh extends import_three40.Group {
|
|
|
15383
15657
|
for (const { atlas, x, y } of page.placements) {
|
|
15384
15658
|
context.drawImage(atlas.image.canvas, x, y);
|
|
15385
15659
|
}
|
|
15386
|
-
const positions = [], normals = [], uvs = [], colors = [], indices = [];
|
|
15660
|
+
const positions = [], normals = [], uvs = [], uvBounds = [], colors = [], indices = [];
|
|
15387
15661
|
for (const { index, template, cullMask } of page.entries) {
|
|
15388
15662
|
const position = template.geometry.getAttribute("position");
|
|
15389
15663
|
const normal = template.geometry.getAttribute("normal");
|
|
15390
15664
|
const uv = template.geometry.getAttribute("uv");
|
|
15665
|
+
const bounds = template.geometry.getAttribute("uvBounds");
|
|
15391
15666
|
const color = template.geometry.getAttribute("color");
|
|
15392
15667
|
const sourceIndices = template.geometry.getIndex();
|
|
15393
15668
|
const placement = locations.get(template.atlas).placement;
|
|
15669
|
+
const mapU = (u) => (placement.x + u * template.atlas.image.width) / page.width;
|
|
15670
|
+
const mapV = (v) => 1 - (placement.y + (1 - v) * template.atlas.image.height) / page.height;
|
|
15394
15671
|
const offsetX = index % 16 * 16;
|
|
15395
15672
|
const offsetY = Math.floor(index / 256) * 16;
|
|
15396
15673
|
const offsetZ = Math.floor(index / 16) % 16 * 16;
|
|
@@ -15401,9 +15678,12 @@ var SectionMesh = class _SectionMesh extends import_three40.Group {
|
|
|
15401
15678
|
const vertex = face * 4 + corner;
|
|
15402
15679
|
positions.push(position.getX(vertex) + offsetX, position.getY(vertex) + offsetY, position.getZ(vertex) + offsetZ);
|
|
15403
15680
|
normals.push(normal.getX(vertex), normal.getY(vertex), normal.getZ(vertex));
|
|
15404
|
-
uvs.push(
|
|
15405
|
-
|
|
15406
|
-
|
|
15681
|
+
uvs.push(mapU(uv.getX(vertex)), mapV(uv.getY(vertex)));
|
|
15682
|
+
uvBounds.push(
|
|
15683
|
+
mapU(bounds?.getX(vertex) ?? 0),
|
|
15684
|
+
mapV(bounds?.getY(vertex) ?? 0),
|
|
15685
|
+
mapU(bounds?.getZ(vertex) ?? 1),
|
|
15686
|
+
mapV(bounds?.getW(vertex) ?? 1)
|
|
15407
15687
|
);
|
|
15408
15688
|
colors.push(color?.getX(vertex) ?? 1, color?.getY(vertex) ?? 1, color?.getZ(vertex) ?? 1);
|
|
15409
15689
|
}
|
|
@@ -15414,11 +15694,12 @@ var SectionMesh = class _SectionMesh extends import_three40.Group {
|
|
|
15414
15694
|
geometry.setAttribute("position", new import_three40.Float32BufferAttribute(positions, 3));
|
|
15415
15695
|
geometry.setAttribute("normal", new import_three40.Float32BufferAttribute(normals, 3));
|
|
15416
15696
|
geometry.setAttribute("uv", new import_three40.Float32BufferAttribute(uvs, 2));
|
|
15697
|
+
geometry.setAttribute("uvBounds", new import_three40.Float32BufferAttribute(uvBounds, 4));
|
|
15417
15698
|
geometry.setAttribute("color", new import_three40.Float32BufferAttribute(colors, 3));
|
|
15418
15699
|
geometry.setIndex(indices);
|
|
15419
15700
|
geometry.computeBoundingBox();
|
|
15420
15701
|
geometry.computeBoundingSphere();
|
|
15421
|
-
const material = Materials.createShadedCanvasMaterial(canvas, false);
|
|
15702
|
+
const material = Materials.createShadedCanvasMaterial(canvas, false, false, true);
|
|
15422
15703
|
material.vertexColors = true;
|
|
15423
15704
|
const texture = material.uniforms?.map?.value ?? material.map;
|
|
15424
15705
|
const mesh = new import_three40.Mesh(geometry, material);
|
|
@@ -15492,7 +15773,7 @@ var Chunk = class _Chunk {
|
|
|
15492
15773
|
this.renderedBlocks.get(index)?.object?.removeFromScene();
|
|
15493
15774
|
if (this.sectionBlocks.delete(index)) this.meshDirty = true;
|
|
15494
15775
|
this.renderedBlocks.delete(index);
|
|
15495
|
-
let
|
|
15776
|
+
let object2;
|
|
15496
15777
|
try {
|
|
15497
15778
|
if (!readBlock) return void 0;
|
|
15498
15779
|
const stored = readBlock();
|
|
@@ -15507,22 +15788,22 @@ var Chunk = class _Chunk {
|
|
|
15507
15788
|
this.sectionBlocks.set(index, { index, template, cullMask: 0 });
|
|
15508
15789
|
this.meshDirty = true;
|
|
15509
15790
|
} else {
|
|
15510
|
-
|
|
15791
|
+
object2 = await this.scene.addBlock(blockState, {
|
|
15511
15792
|
mergeMeshes: true,
|
|
15512
15793
|
instanceMeshes: true,
|
|
15513
15794
|
maxInstanceCount: 2e3,
|
|
15514
15795
|
initialState: stored.properties
|
|
15515
15796
|
});
|
|
15516
|
-
|
|
15797
|
+
object2.setPosition(MineRenderWorld.worldToScenePosition(worldPos));
|
|
15517
15798
|
}
|
|
15518
15799
|
const info = { get block() {
|
|
15519
15800
|
return readBlock();
|
|
15520
|
-
}, object };
|
|
15801
|
+
}, object: object2 };
|
|
15521
15802
|
this.renderedBlocks.set(index, info);
|
|
15522
15803
|
return info;
|
|
15523
15804
|
} catch (error) {
|
|
15524
15805
|
this.data.set(index, void 0);
|
|
15525
|
-
|
|
15806
|
+
object2?.removeFromScene();
|
|
15526
15807
|
throw error;
|
|
15527
15808
|
} finally {
|
|
15528
15809
|
await onBlocksChanged?.([worldPos]);
|
|
@@ -15696,6 +15977,8 @@ var Chunk = class _Chunk {
|
|
|
15696
15977
|
NodeCache,
|
|
15697
15978
|
NodeEnv,
|
|
15698
15979
|
OrbitControls,
|
|
15980
|
+
PackFormats,
|
|
15981
|
+
PackMetadata,
|
|
15699
15982
|
PersistentCache,
|
|
15700
15983
|
Renderer,
|
|
15701
15984
|
RequestError,
|