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/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
|
}
|
|
@@ -982,7 +982,7 @@ var init_Materials = __esm({
|
|
|
982
982
|
};
|
|
983
983
|
return material;
|
|
984
984
|
}
|
|
985
|
-
static createShadedCanvasMaterial(canvas, transparent = false, shade = false) {
|
|
985
|
+
static createShadedCanvasMaterial(canvas, transparent = false, shade = false, boundUvs = false) {
|
|
986
986
|
const vertShader = `
|
|
987
987
|
uniform bool SHADE;
|
|
988
988
|
|
|
@@ -992,6 +992,10 @@ var init_Materials = __esm({
|
|
|
992
992
|
#else
|
|
993
993
|
varying vec2 vUv;
|
|
994
994
|
#endif
|
|
995
|
+
#ifdef BOUND_UVS
|
|
996
|
+
attribute vec4 uvBounds;
|
|
997
|
+
flat out vec4 vUvBounds;
|
|
998
|
+
#endif
|
|
995
999
|
varying vec3 vTint;
|
|
996
1000
|
varying float light;
|
|
997
1001
|
varying float lift;
|
|
@@ -1027,13 +1031,17 @@ var init_Materials = __esm({
|
|
|
1027
1031
|
}
|
|
1028
1032
|
|
|
1029
1033
|
vUv = uv;
|
|
1034
|
+
#ifdef BOUND_UVS
|
|
1035
|
+
vUvBounds = uvBounds;
|
|
1036
|
+
#endif
|
|
1030
1037
|
vTint = color;
|
|
1031
1038
|
|
|
1039
|
+
vec4 mvPosition = vec4(position, 1.0);
|
|
1032
1040
|
#ifdef USE_INSTANCING
|
|
1033
|
-
|
|
1034
|
-
#else
|
|
1035
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
1041
|
+
mvPosition = instanceMatrix * mvPosition;
|
|
1036
1042
|
#endif
|
|
1043
|
+
mvPosition = modelViewMatrix * mvPosition;
|
|
1044
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
1037
1045
|
|
|
1038
1046
|
}
|
|
1039
1047
|
`;
|
|
@@ -1053,13 +1061,22 @@ var init_Materials = __esm({
|
|
|
1053
1061
|
#else
|
|
1054
1062
|
varying vec2 vUv;
|
|
1055
1063
|
#endif
|
|
1064
|
+
#ifdef BOUND_UVS
|
|
1065
|
+
flat in vec4 vUvBounds;
|
|
1066
|
+
#endif
|
|
1056
1067
|
varying vec3 vTint;
|
|
1057
1068
|
varying float light;
|
|
1058
1069
|
varying float lift;
|
|
1059
1070
|
|
|
1060
1071
|
void main(void)
|
|
1061
1072
|
{
|
|
1062
|
-
|
|
1073
|
+
#ifdef BOUND_UVS
|
|
1074
|
+
// Keep edge samples inside their texture even without centroid interpolation.
|
|
1075
|
+
vec2 mapUv = clamp(vUv, vUvBounds.xy, vUvBounds.zw);
|
|
1076
|
+
#else
|
|
1077
|
+
vec2 mapUv = vUv;
|
|
1078
|
+
#endif
|
|
1079
|
+
vec4 color = texture2D(map, mapUv);
|
|
1063
1080
|
color.rgb *= vTint;
|
|
1064
1081
|
|
|
1065
1082
|
if (color.a < 0.01) discard;
|
|
@@ -1080,7 +1097,8 @@ var init_Materials = __esm({
|
|
|
1080
1097
|
}
|
|
1081
1098
|
`;
|
|
1082
1099
|
try {
|
|
1083
|
-
|
|
1100
|
+
const material = new import_three5.ShaderMaterial({
|
|
1101
|
+
defines: boundUvs ? { BOUND_UVS: true } : {},
|
|
1084
1102
|
uniforms: {
|
|
1085
1103
|
SHADE: { value: true },
|
|
1086
1104
|
BRIGHTNESS: { value: 1 },
|
|
@@ -1098,6 +1116,8 @@ var init_Materials = __esm({
|
|
|
1098
1116
|
side: transparent ? import_three5.DoubleSide : import_three5.FrontSide,
|
|
1099
1117
|
alphaTest: 0.5
|
|
1100
1118
|
});
|
|
1119
|
+
Object.assign(material.defaultAttributeValues, { uvBounds: [0, 0, 1, 1] });
|
|
1120
|
+
return material;
|
|
1101
1121
|
} catch (e) {
|
|
1102
1122
|
console.warn(e);
|
|
1103
1123
|
}
|
|
@@ -1704,6 +1724,10 @@ var init_AssetSource = __esm({
|
|
|
1704
1724
|
AssetSource = class {
|
|
1705
1725
|
constructor() {
|
|
1706
1726
|
}
|
|
1727
|
+
/** Whether this source prevents lower-priority sources from supplying the key. Its own assets remain available. */
|
|
1728
|
+
blocks(key) {
|
|
1729
|
+
return false;
|
|
1730
|
+
}
|
|
1707
1731
|
/**
|
|
1708
1732
|
* Identifies this source's content across sessions for persistent caching. Sources that
|
|
1709
1733
|
* cannot tell whether their content changed (an unnamed archive, for example) return
|
|
@@ -1884,10 +1908,10 @@ var init_NBTHelper = __esm({
|
|
|
1884
1908
|
"src/nbt/NBTHelper.ts"() {
|
|
1885
1909
|
import_buffer2 = require("buffer");
|
|
1886
1910
|
NBTHelper = class {
|
|
1887
|
-
static async fromBuffer(data,
|
|
1911
|
+
static async fromBuffer(data, format2) {
|
|
1888
1912
|
const buffer = import_buffer2.Buffer.from(data instanceof Uint8Array ? data : new Uint8Array(data));
|
|
1889
1913
|
const prismarineNbt = await import("prismarine-nbt");
|
|
1890
|
-
const { parsed, type, metadata } = await prismarineNbt.parse(buffer,
|
|
1914
|
+
const { parsed, type, metadata } = await prismarineNbt.parse(buffer, format2);
|
|
1891
1915
|
return Object.assign(parsed, {
|
|
1892
1916
|
format: type,
|
|
1893
1917
|
metadata,
|
|
@@ -2121,6 +2145,162 @@ var init_BrowserArchiveProxy = __esm({
|
|
|
2121
2145
|
}
|
|
2122
2146
|
});
|
|
2123
2147
|
|
|
2148
|
+
// src/assets/source/archive/PackMetadata.ts
|
|
2149
|
+
function object(value, field) {
|
|
2150
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
2151
|
+
throw new Error(`Invalid ${field}: expected an object`);
|
|
2152
|
+
}
|
|
2153
|
+
return value;
|
|
2154
|
+
}
|
|
2155
|
+
function integer(value, field) {
|
|
2156
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
2157
|
+
throw new Error(`Invalid ${field}: expected a nonnegative integer`);
|
|
2158
|
+
}
|
|
2159
|
+
return value;
|
|
2160
|
+
}
|
|
2161
|
+
function format(value, field, upper = false) {
|
|
2162
|
+
const parts = Array.isArray(value) ? value : [value];
|
|
2163
|
+
if (parts.length < 1 || parts.length > 2) {
|
|
2164
|
+
throw new Error(`Invalid ${field}: expected a major version or [major, minor]`);
|
|
2165
|
+
}
|
|
2166
|
+
return [integer(parts[0], field), parts.length === 2 ? integer(parts[1], field) : upper ? Infinity : 0];
|
|
2167
|
+
}
|
|
2168
|
+
function compare(a, b) {
|
|
2169
|
+
return a[0] === b[0] ? a[1] - b[1] : a[0] - b[0];
|
|
2170
|
+
}
|
|
2171
|
+
function overlay(value, field) {
|
|
2172
|
+
const entry = object(value, field);
|
|
2173
|
+
const directory = entry.directory;
|
|
2174
|
+
if (typeof directory !== "string" || !directory || /[^-_a-zA-Z0-9.]/.test(directory) || directory === "." || directory === "..") {
|
|
2175
|
+
throw new Error(`Invalid ${field}.directory: expected a directory name without path separators`);
|
|
2176
|
+
}
|
|
2177
|
+
let min, max;
|
|
2178
|
+
if ("min_format" in entry || "max_format" in entry) {
|
|
2179
|
+
min = format(entry.min_format, `${field}.min_format`);
|
|
2180
|
+
max = format(entry.max_format, `${field}.max_format`, true);
|
|
2181
|
+
} else {
|
|
2182
|
+
const range = entry.formats;
|
|
2183
|
+
let lower, upper;
|
|
2184
|
+
if (typeof range === "number") {
|
|
2185
|
+
lower = upper = range;
|
|
2186
|
+
} else if (Array.isArray(range)) {
|
|
2187
|
+
if (range.length !== 2) throw new Error(`Invalid ${field}.formats: expected [min, max]`);
|
|
2188
|
+
[lower, upper] = range;
|
|
2189
|
+
} else {
|
|
2190
|
+
const bounds = object(range, `${field}.formats`);
|
|
2191
|
+
lower = bounds.min_inclusive;
|
|
2192
|
+
upper = bounds.max_inclusive;
|
|
2193
|
+
}
|
|
2194
|
+
min = [integer(lower, `${field}.formats.min_inclusive`), 0];
|
|
2195
|
+
max = [integer(upper, `${field}.formats.max_inclusive`), Infinity];
|
|
2196
|
+
}
|
|
2197
|
+
if (compare(min, max) > 0) throw new Error(`Invalid ${field}: minimum format exceeds maximum format`);
|
|
2198
|
+
return { directory, min, max };
|
|
2199
|
+
}
|
|
2200
|
+
function pattern(value, field) {
|
|
2201
|
+
if (value === void 0) return void 0;
|
|
2202
|
+
if (typeof value !== "string") throw new Error(`Invalid ${field}: expected a regular expression string`);
|
|
2203
|
+
try {
|
|
2204
|
+
return new RegExp(value);
|
|
2205
|
+
} catch (cause) {
|
|
2206
|
+
throw new Error(`Invalid ${field}: ${String(cause)}`);
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
var PackMetadata;
|
|
2210
|
+
var init_PackMetadata = __esm({
|
|
2211
|
+
"src/assets/source/archive/PackMetadata.ts"() {
|
|
2212
|
+
PackMetadata = class _PackMetadata {
|
|
2213
|
+
constructor(overlays, filters) {
|
|
2214
|
+
this.overlays = overlays;
|
|
2215
|
+
this.filters = filters;
|
|
2216
|
+
this.hasOverlays = overlays.length > 0;
|
|
2217
|
+
}
|
|
2218
|
+
static parse(value) {
|
|
2219
|
+
const metadata = object(value, "pack.mcmeta");
|
|
2220
|
+
let overlays = [];
|
|
2221
|
+
if ("overlays" in metadata) {
|
|
2222
|
+
const entries = object(metadata.overlays, "overlays").entries;
|
|
2223
|
+
if (!Array.isArray(entries)) throw new Error("Invalid overlays.entries: expected an array");
|
|
2224
|
+
overlays = entries.map((entry, index) => overlay(entry, `overlays.entries[${index}]`));
|
|
2225
|
+
}
|
|
2226
|
+
let filters = [];
|
|
2227
|
+
if ("filter" in metadata) {
|
|
2228
|
+
const entries = object(metadata.filter, "filter").block;
|
|
2229
|
+
if (!Array.isArray(entries)) throw new Error("Invalid filter.block: expected an array");
|
|
2230
|
+
filters = entries.map((value2, index) => {
|
|
2231
|
+
const field = `filter.block[${index}]`;
|
|
2232
|
+
const entry = object(value2, field);
|
|
2233
|
+
return { namespace: pattern(entry.namespace, `${field}.namespace`), path: pattern(entry.path, `${field}.path`) };
|
|
2234
|
+
});
|
|
2235
|
+
}
|
|
2236
|
+
return new _PackMetadata(overlays, filters);
|
|
2237
|
+
}
|
|
2238
|
+
/** Returns applicable directories in lookup order, with the last declared overlay first. */
|
|
2239
|
+
overlayDirectories(target) {
|
|
2240
|
+
const selected = format(target, "target format");
|
|
2241
|
+
return this.overlays.filter((entry) => compare(selected, entry.min) >= 0 && compare(selected, entry.max) <= 0).map((entry) => entry.directory).reverse();
|
|
2242
|
+
}
|
|
2243
|
+
blocks(namespace, path) {
|
|
2244
|
+
return this.filters.some((entry) => entry.namespace?.test(namespace) ?? true) && this.filters.some((entry) => entry.path?.test(path) ?? true);
|
|
2245
|
+
}
|
|
2246
|
+
};
|
|
2247
|
+
}
|
|
2248
|
+
});
|
|
2249
|
+
|
|
2250
|
+
// src/assets/source/archive/PackFormats.ts
|
|
2251
|
+
var PackFormats;
|
|
2252
|
+
var init_PackFormats = __esm({
|
|
2253
|
+
"src/assets/source/archive/PackFormats.ts"() {
|
|
2254
|
+
init_Requests();
|
|
2255
|
+
PackFormats = class {
|
|
2256
|
+
/** Resolves pack formats from Mojang's client metadata hosted on assets.mcasset.cloud. */
|
|
2257
|
+
static async get(version, type) {
|
|
2258
|
+
let pending = this.versions.get(version);
|
|
2259
|
+
if (!pending || pending.expires <= Date.now()) {
|
|
2260
|
+
pending = {
|
|
2261
|
+
formats: this.load(version),
|
|
2262
|
+
expires: ["latest", "release", "snapshot"].includes(version) ? Date.now() + 3e5 : Infinity
|
|
2263
|
+
};
|
|
2264
|
+
this.versions.set(version, pending);
|
|
2265
|
+
}
|
|
2266
|
+
try {
|
|
2267
|
+
return (await pending.formats)[type];
|
|
2268
|
+
} catch (cause) {
|
|
2269
|
+
if (this.versions.get(version) === pending) this.versions.delete(version);
|
|
2270
|
+
const option = type === "assets" ? "resourcePackFormat" : "dataPackFormat";
|
|
2271
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
2272
|
+
throw new Error(`Could not resolve the pack format for Minecraft ${version}. Set ArchiveAssetSource ${option} explicitly. ${reason}`);
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
static async load(version) {
|
|
2276
|
+
const response = await Requests.genericRequest({
|
|
2277
|
+
url: `https://assets.mcasset.cloud/${encodeURIComponent(version)}/game-version.json`,
|
|
2278
|
+
responseType: "json"
|
|
2279
|
+
});
|
|
2280
|
+
const data = response.data;
|
|
2281
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
2282
|
+
throw new Error("Expected version metadata to be an object");
|
|
2283
|
+
}
|
|
2284
|
+
const packs = data.pack_version;
|
|
2285
|
+
if (typeof packs !== "number" && (!packs || typeof packs !== "object" || Array.isArray(packs))) {
|
|
2286
|
+
throw new Error("Expected pack_version to be a number or an object");
|
|
2287
|
+
}
|
|
2288
|
+
const format2 = (type) => {
|
|
2289
|
+
const modern = typeof packs === "object" && ["resource_major", "resource_minor", "data_major", "data_minor"].some((key) => key in packs);
|
|
2290
|
+
const major = typeof packs === "number" ? packs : packs[modern ? `${type}_major` : type];
|
|
2291
|
+
const minor = modern ? packs[`${type}_minor`] : 0;
|
|
2292
|
+
if (typeof major !== "number" || !Number.isSafeInteger(major) || major < 0 || typeof minor !== "number" || !Number.isSafeInteger(minor) || minor < 0) {
|
|
2293
|
+
throw new Error(`Invalid ${type} pack format in version metadata`);
|
|
2294
|
+
}
|
|
2295
|
+
return Object.freeze([major, minor]);
|
|
2296
|
+
};
|
|
2297
|
+
return { assets: format2("resource"), data: format2("data") };
|
|
2298
|
+
}
|
|
2299
|
+
};
|
|
2300
|
+
PackFormats.versions = /* @__PURE__ */ new Map();
|
|
2301
|
+
}
|
|
2302
|
+
});
|
|
2303
|
+
|
|
2124
2304
|
// src/assets/source/archive/ArchiveAssetSource.ts
|
|
2125
2305
|
var ArchiveAssetSource;
|
|
2126
2306
|
var init_ArchiveAssetSource = __esm({
|
|
@@ -2129,35 +2309,77 @@ var init_ArchiveAssetSource = __esm({
|
|
|
2129
2309
|
init_request();
|
|
2130
2310
|
init_HostedAssetSource();
|
|
2131
2311
|
init_BrowserArchiveProxy();
|
|
2312
|
+
init_AssetLoader();
|
|
2313
|
+
init_PackMetadata();
|
|
2314
|
+
init_PackFormats();
|
|
2132
2315
|
ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
|
|
2133
|
-
constructor(archiveProxy) {
|
|
2316
|
+
constructor(archiveProxy, options = {}) {
|
|
2134
2317
|
super();
|
|
2135
|
-
console.log(archiveProxy);
|
|
2136
2318
|
this._archiveProxy = archiveProxy;
|
|
2319
|
+
const copyFormat = (format2) => typeof format2 === "object" ? [format2[0], format2[1]] : format2;
|
|
2320
|
+
this.options = {
|
|
2321
|
+
resourcePackFormat: copyFormat(options.resourcePackFormat),
|
|
2322
|
+
dataPackFormat: copyFormat(options.dataPackFormat)
|
|
2323
|
+
};
|
|
2137
2324
|
}
|
|
2138
|
-
static blob(blob) {
|
|
2139
|
-
return new _ArchiveAssetSource(new BrowserArchiveProxy(blob));
|
|
2325
|
+
static blob(blob, options) {
|
|
2326
|
+
return new _ArchiveAssetSource(new BrowserArchiveProxy(blob), options);
|
|
2140
2327
|
}
|
|
2141
2328
|
get cacheId() {
|
|
2142
2329
|
const id = this._archiveProxy.id;
|
|
2143
|
-
|
|
2330
|
+
const formats = [this.options.resourcePackFormat ?? AssetLoader.version, this.options.dataPackFormat ?? AssetLoader.version];
|
|
2331
|
+
return id === void 0 ? void 0 : `archive-metadata:1:${id}:${JSON.stringify(formats)}`;
|
|
2144
2332
|
}
|
|
2145
2333
|
async getEntries() {
|
|
2146
|
-
return this._archiveProxy.getEntries()
|
|
2334
|
+
return this.entries ?? (this.entries = this._archiveProxy.getEntries().catch((error) => {
|
|
2335
|
+
this.entries = void 0;
|
|
2336
|
+
throw error;
|
|
2337
|
+
}));
|
|
2147
2338
|
}
|
|
2148
2339
|
async getEntry(path) {
|
|
2149
2340
|
const entries = await this.getEntries();
|
|
2150
2341
|
return entries.find((e) => e.filename === path);
|
|
2151
2342
|
}
|
|
2343
|
+
async getMetadata(key) {
|
|
2344
|
+
try {
|
|
2345
|
+
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) => {
|
|
2346
|
+
this.metadata = void 0;
|
|
2347
|
+
throw error;
|
|
2348
|
+
})));
|
|
2349
|
+
} catch (cause) {
|
|
2350
|
+
throw new AssetLoadError(this, key, "pack.mcmeta", cause);
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
async blocks(key) {
|
|
2354
|
+
if (key.rootType !== "assets" && key.rootType !== "data") return false;
|
|
2355
|
+
const metadata = await this.getMetadata(key);
|
|
2356
|
+
const path = `${key.assetType !== void 0 ? key.assetType + "/" : ""}${key.getFullPath()}${key.extension}`;
|
|
2357
|
+
return metadata.blocks(key.namespace, path);
|
|
2358
|
+
}
|
|
2152
2359
|
async get(key, parser) {
|
|
2153
2360
|
const responseParser = HostedAssetSource.PARSER_MAP.get(parser);
|
|
2154
2361
|
return this.load(key, responseParser);
|
|
2155
2362
|
}
|
|
2156
2363
|
async load(key, parser) {
|
|
2157
2364
|
const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
|
|
2365
|
+
const version = AssetLoader.version;
|
|
2366
|
+
let selectedPath = path;
|
|
2158
2367
|
let url;
|
|
2159
2368
|
try {
|
|
2160
|
-
|
|
2369
|
+
let directories = [];
|
|
2370
|
+
if (key.rootType === "assets" || key.rootType === "data") {
|
|
2371
|
+
const metadata = await this.getMetadata(key);
|
|
2372
|
+
if (metadata.hasOverlays) {
|
|
2373
|
+
const format2 = (key.rootType === "assets" ? this.options.resourcePackFormat : this.options.dataPackFormat) ?? await PackFormats.get(version, key.rootType);
|
|
2374
|
+
directories = metadata.overlayDirectories(format2);
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
let entry;
|
|
2378
|
+
for (const directory of [...directories, ""]) {
|
|
2379
|
+
selectedPath = directory ? `${directory}/${path}` : path;
|
|
2380
|
+
entry = await this.getEntry(selectedPath);
|
|
2381
|
+
if (entry) break;
|
|
2382
|
+
}
|
|
2161
2383
|
if (!entry) {
|
|
2162
2384
|
return void 0;
|
|
2163
2385
|
}
|
|
@@ -2170,7 +2392,8 @@ var init_ArchiveAssetSource = __esm({
|
|
|
2170
2392
|
}
|
|
2171
2393
|
return await parser.parse(response);
|
|
2172
2394
|
} catch (cause) {
|
|
2173
|
-
|
|
2395
|
+
if (cause instanceof AssetLoadError) throw cause;
|
|
2396
|
+
throw new AssetLoadError(this, key, selectedPath, cause);
|
|
2174
2397
|
} finally {
|
|
2175
2398
|
if (url !== void 0) {
|
|
2176
2399
|
URL.revokeObjectURL(url);
|
|
@@ -2203,6 +2426,8 @@ var init_archive = __esm({
|
|
|
2203
2426
|
init_ArchiveEntry();
|
|
2204
2427
|
init_ArchiveProxy();
|
|
2205
2428
|
init_BrowserArchiveProxy();
|
|
2429
|
+
init_PackFormats();
|
|
2430
|
+
init_PackMetadata();
|
|
2206
2431
|
}
|
|
2207
2432
|
});
|
|
2208
2433
|
|
|
@@ -2285,13 +2510,14 @@ ${key}` : key;
|
|
|
2285
2510
|
return void 0;
|
|
2286
2511
|
}
|
|
2287
2512
|
static async getAll(key, parser) {
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2513
|
+
const sources = [...this._SOURCES];
|
|
2514
|
+
const results = [];
|
|
2515
|
+
for (const { source } of sources) {
|
|
2516
|
+
const asset = await source.get(key, parser);
|
|
2517
|
+
if (asset != void 0) results.push(asset);
|
|
2518
|
+
if (await source.blocks(key)) break;
|
|
2291
2519
|
}
|
|
2292
|
-
return
|
|
2293
|
-
return results.filter((r) => r != void 0);
|
|
2294
|
-
});
|
|
2520
|
+
return results;
|
|
2295
2521
|
}
|
|
2296
2522
|
/** Returns the first defined result in source-priority order, without merging assets. */
|
|
2297
2523
|
static async get(key, parser) {
|
|
@@ -2312,13 +2538,17 @@ ${key}` : key;
|
|
|
2312
2538
|
/** Tries each path within a source before considering lower-priority sources. */
|
|
2313
2539
|
static async getFirst(keys, parser) {
|
|
2314
2540
|
const sources = [...this._SOURCES];
|
|
2541
|
+
let remaining = [...keys];
|
|
2315
2542
|
for (const source of sources) {
|
|
2316
|
-
for (const key of
|
|
2543
|
+
for (const key of remaining) {
|
|
2317
2544
|
const result = await source.source.get(key, parser);
|
|
2318
2545
|
if (result !== void 0) {
|
|
2319
2546
|
return { key, asset: result };
|
|
2320
2547
|
}
|
|
2321
2548
|
}
|
|
2549
|
+
const blocked = await Promise.all(remaining.map((key) => source.source.blocks(key)));
|
|
2550
|
+
remaining = remaining.filter((_, index) => !blocked[index]);
|
|
2551
|
+
if (!remaining.length) break;
|
|
2322
2552
|
}
|
|
2323
2553
|
return void 0;
|
|
2324
2554
|
}
|
|
@@ -2769,6 +2999,37 @@ var init_UVMapper = __esm({
|
|
|
2769
2999
|
static facesToUv(faces, originalTextureSize, actualTextureSize) {
|
|
2770
3000
|
return new import_three9.Float32BufferAttribute(this.facesToUvArray(faces, originalTextureSize, actualTextureSize), 2);
|
|
2771
3001
|
}
|
|
3002
|
+
/** Bounds texture sampling to texel centres without changing cropped face UVs. */
|
|
3003
|
+
static setAtlasUvBounds(geometry, faces, atlas) {
|
|
3004
|
+
const uv = geometry.getAttribute("uv");
|
|
3005
|
+
const bounds = new Float32Array(uv.count * 4);
|
|
3006
|
+
for (const [faceIndex, faceName] of CUBE_FACES.entries()) {
|
|
3007
|
+
const texture = faces[faceName]?.texture?.substring(1);
|
|
3008
|
+
const position = texture && atlas.positions[texture];
|
|
3009
|
+
const size = texture && atlas.sizes[texture];
|
|
3010
|
+
let minU = Infinity, minV = Infinity, maxU = -Infinity, maxV = -Infinity;
|
|
3011
|
+
if (position && size) {
|
|
3012
|
+
minU = position[0] / atlas.image.width;
|
|
3013
|
+
maxU = (position[0] + size[0]) / atlas.image.width;
|
|
3014
|
+
minV = 1 - (position[1] + size[1]) / atlas.image.height;
|
|
3015
|
+
maxV = 1 - position[1] / atlas.image.height;
|
|
3016
|
+
} else {
|
|
3017
|
+
for (let corner = 0; corner < 4; corner++) {
|
|
3018
|
+
const index = faceIndex * 4 + corner;
|
|
3019
|
+
minU = Math.min(minU, uv.getX(index));
|
|
3020
|
+
minV = Math.min(minV, uv.getY(index));
|
|
3021
|
+
maxU = Math.max(maxU, uv.getX(index));
|
|
3022
|
+
maxV = Math.max(maxV, uv.getY(index));
|
|
3023
|
+
}
|
|
3024
|
+
}
|
|
3025
|
+
const insetU = Math.min(0.5 / atlas.image.width, (maxU - minU) / 2);
|
|
3026
|
+
const insetV = Math.min(0.5 / atlas.image.height, (maxV - minV) / 2);
|
|
3027
|
+
for (let corner = 0; corner < 4; corner++) {
|
|
3028
|
+
bounds.set([minU + insetU, minV + insetV, maxU - insetU, maxV - insetV], (faceIndex * 4 + corner) * 4);
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
geometry.setAttribute("uvBounds", new import_three9.Float32BufferAttribute(bounds, 4));
|
|
3032
|
+
}
|
|
2772
3033
|
static lockUvs(geometry, faces, atlas, rotation) {
|
|
2773
3034
|
const uv = geometry.getAttribute("uv");
|
|
2774
3035
|
for (let faceIndex = 0; faceIndex < CUBE_FACES.length; faceIndex++) {
|
|
@@ -3425,27 +3686,27 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
3425
3686
|
for (const layer of layers) {
|
|
3426
3687
|
const objects = [];
|
|
3427
3688
|
if (poses) {
|
|
3428
|
-
layer.traverse((
|
|
3429
|
-
if (poses.has(
|
|
3689
|
+
layer.traverse((object2) => {
|
|
3690
|
+
if (poses.has(object2)) objects.push(object2);
|
|
3430
3691
|
});
|
|
3431
3692
|
} else {
|
|
3432
3693
|
for (const bone of Object.keys(animation.bones)) {
|
|
3433
|
-
const
|
|
3434
|
-
if (
|
|
3694
|
+
const object2 = layer.getObjectByName(`group:${bone}`);
|
|
3695
|
+
if (object2) objects.push(object2);
|
|
3435
3696
|
}
|
|
3436
3697
|
}
|
|
3437
|
-
for (const
|
|
3438
|
-
const bone =
|
|
3439
|
-
const pose = poses?.get(
|
|
3698
|
+
for (const object2 of objects) {
|
|
3699
|
+
const bone = object2.name.slice("group:".length);
|
|
3700
|
+
const pose = poses?.get(object2);
|
|
3440
3701
|
this.parts.push({
|
|
3441
3702
|
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]) :
|
|
3703
|
+
object: object2,
|
|
3704
|
+
position: object2.position.clone(),
|
|
3705
|
+
rotation: object2.rotation.clone(),
|
|
3706
|
+
scale: object2.scale.clone(),
|
|
3707
|
+
basePosition: pose ? new import_three11.Vector3(...pose.offset) : object2.position.clone(),
|
|
3708
|
+
baseRotation: pose ? new import_three11.Euler(...pose.rotation, "ZYX") : object2.rotation.clone(),
|
|
3709
|
+
baseScale: pose ? new import_three11.Vector3(...pose.scale ?? [1, 1, 1]) : object2.scale.clone()
|
|
3449
3710
|
});
|
|
3450
3711
|
}
|
|
3451
3712
|
}
|
|
@@ -3964,15 +4225,15 @@ var init_SceneObject = __esm({
|
|
|
3964
4225
|
}
|
|
3965
4226
|
}
|
|
3966
4227
|
//</editor-fold>
|
|
3967
|
-
toggleObjectVisibility(
|
|
3968
|
-
if (
|
|
4228
|
+
toggleObjectVisibility(object2, visible) {
|
|
4229
|
+
if (object2) {
|
|
3969
4230
|
if (typeof visible !== "undefined") {
|
|
3970
|
-
|
|
4231
|
+
object2.visible = visible;
|
|
3971
4232
|
} else {
|
|
3972
|
-
|
|
4233
|
+
object2.visible = !object2.visible;
|
|
3973
4234
|
}
|
|
3974
4235
|
this.notifyDirty();
|
|
3975
|
-
return
|
|
4236
|
+
return object2.visible;
|
|
3976
4237
|
}
|
|
3977
4238
|
this.notifyDirty();
|
|
3978
4239
|
return false;
|
|
@@ -4267,8 +4528,8 @@ var init_EntityObject = __esm({
|
|
|
4267
4528
|
this.scrollMaterials.push({ material: mat, offset: mat.map.offset, speed: scroll });
|
|
4268
4529
|
}
|
|
4269
4530
|
}
|
|
4270
|
-
this.getLayerGroup(name)?.traverse((
|
|
4271
|
-
if (isMesh(
|
|
4531
|
+
this.getLayerGroup(name)?.traverse((object2) => {
|
|
4532
|
+
if (isMesh(object2)) object2.material = mat;
|
|
4272
4533
|
});
|
|
4273
4534
|
}));
|
|
4274
4535
|
if (!this.children.length) {
|
|
@@ -4598,8 +4859,8 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
4598
4859
|
return geometry;
|
|
4599
4860
|
}
|
|
4600
4861
|
}
|
|
4601
|
-
function computeMorphedAttributes(
|
|
4602
|
-
if (
|
|
4862
|
+
function computeMorphedAttributes(object2) {
|
|
4863
|
+
if (object2.geometry.isBufferGeometry !== true) {
|
|
4603
4864
|
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
|
|
4604
4865
|
return null;
|
|
4605
4866
|
}
|
|
@@ -4612,11 +4873,11 @@ function computeMorphedAttributes(object) {
|
|
|
4612
4873
|
const _morphA = new import_three22.Vector3();
|
|
4613
4874
|
const _morphB = new import_three22.Vector3();
|
|
4614
4875
|
const _morphC = new import_three22.Vector3();
|
|
4615
|
-
function _calculateMorphedAttributeData(
|
|
4876
|
+
function _calculateMorphedAttributeData(object3, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
|
|
4616
4877
|
_vA.fromBufferAttribute(attribute, a2);
|
|
4617
4878
|
_vB.fromBufferAttribute(attribute, b2);
|
|
4618
4879
|
_vC.fromBufferAttribute(attribute, c2);
|
|
4619
|
-
const morphInfluences =
|
|
4880
|
+
const morphInfluences = object3.morphTargetInfluences;
|
|
4620
4881
|
if (material2.morphTargets && morphAttribute && morphInfluences) {
|
|
4621
4882
|
_morphA.set(0, 0, 0);
|
|
4622
4883
|
_morphB.set(0, 0, 0);
|
|
@@ -4642,10 +4903,10 @@ function computeMorphedAttributes(object) {
|
|
|
4642
4903
|
_vB.add(_morphB);
|
|
4643
4904
|
_vC.add(_morphC);
|
|
4644
4905
|
}
|
|
4645
|
-
if (
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4906
|
+
if (object3.isSkinnedMesh) {
|
|
4907
|
+
object3.boneTransform(a2, _vA);
|
|
4908
|
+
object3.boneTransform(b2, _vB);
|
|
4909
|
+
object3.boneTransform(c2, _vC);
|
|
4649
4910
|
}
|
|
4650
4911
|
modifiedAttributeArray[a2 * 3 + 0] = _vA.x;
|
|
4651
4912
|
modifiedAttributeArray[a2 * 3 + 1] = _vA.y;
|
|
@@ -4657,8 +4918,8 @@ function computeMorphedAttributes(object) {
|
|
|
4657
4918
|
modifiedAttributeArray[c2 * 3 + 1] = _vC.y;
|
|
4658
4919
|
modifiedAttributeArray[c2 * 3 + 2] = _vC.z;
|
|
4659
4920
|
}
|
|
4660
|
-
const geometry =
|
|
4661
|
-
const material =
|
|
4921
|
+
const geometry = object2.geometry;
|
|
4922
|
+
const material = object2.material;
|
|
4662
4923
|
let a, b, c;
|
|
4663
4924
|
const index = geometry.index;
|
|
4664
4925
|
const positionAttribute = geometry.attributes.position;
|
|
@@ -4685,7 +4946,7 @@ function computeMorphedAttributes(object) {
|
|
|
4685
4946
|
b = index.getX(j + 1);
|
|
4686
4947
|
c = index.getX(j + 2);
|
|
4687
4948
|
_calculateMorphedAttributeData(
|
|
4688
|
-
|
|
4949
|
+
object2,
|
|
4689
4950
|
groupMaterial,
|
|
4690
4951
|
positionAttribute,
|
|
4691
4952
|
morphPosition,
|
|
@@ -4696,7 +4957,7 @@ function computeMorphedAttributes(object) {
|
|
|
4696
4957
|
modifiedPosition
|
|
4697
4958
|
);
|
|
4698
4959
|
_calculateMorphedAttributeData(
|
|
4699
|
-
|
|
4960
|
+
object2,
|
|
4700
4961
|
groupMaterial,
|
|
4701
4962
|
normalAttribute,
|
|
4702
4963
|
morphNormal,
|
|
@@ -4716,7 +4977,7 @@ function computeMorphedAttributes(object) {
|
|
|
4716
4977
|
b = index.getX(i + 1);
|
|
4717
4978
|
c = index.getX(i + 2);
|
|
4718
4979
|
_calculateMorphedAttributeData(
|
|
4719
|
-
|
|
4980
|
+
object2,
|
|
4720
4981
|
material,
|
|
4721
4982
|
positionAttribute,
|
|
4722
4983
|
morphPosition,
|
|
@@ -4727,7 +4988,7 @@ function computeMorphedAttributes(object) {
|
|
|
4727
4988
|
modifiedPosition
|
|
4728
4989
|
);
|
|
4729
4990
|
_calculateMorphedAttributeData(
|
|
4730
|
-
|
|
4991
|
+
object2,
|
|
4731
4992
|
material,
|
|
4732
4993
|
normalAttribute,
|
|
4733
4994
|
morphNormal,
|
|
@@ -4751,7 +5012,7 @@ function computeMorphedAttributes(object) {
|
|
|
4751
5012
|
b = j + 1;
|
|
4752
5013
|
c = j + 2;
|
|
4753
5014
|
_calculateMorphedAttributeData(
|
|
4754
|
-
|
|
5015
|
+
object2,
|
|
4755
5016
|
groupMaterial,
|
|
4756
5017
|
positionAttribute,
|
|
4757
5018
|
morphPosition,
|
|
@@ -4762,7 +5023,7 @@ function computeMorphedAttributes(object) {
|
|
|
4762
5023
|
modifiedPosition
|
|
4763
5024
|
);
|
|
4764
5025
|
_calculateMorphedAttributeData(
|
|
4765
|
-
|
|
5026
|
+
object2,
|
|
4766
5027
|
groupMaterial,
|
|
4767
5028
|
normalAttribute,
|
|
4768
5029
|
morphNormal,
|
|
@@ -4782,7 +5043,7 @@ function computeMorphedAttributes(object) {
|
|
|
4782
5043
|
b = i + 1;
|
|
4783
5044
|
c = i + 2;
|
|
4784
5045
|
_calculateMorphedAttributeData(
|
|
4785
|
-
|
|
5046
|
+
object2,
|
|
4786
5047
|
material,
|
|
4787
5048
|
positionAttribute,
|
|
4788
5049
|
morphPosition,
|
|
@@ -4793,7 +5054,7 @@ function computeMorphedAttributes(object) {
|
|
|
4793
5054
|
modifiedPosition
|
|
4794
5055
|
);
|
|
4795
5056
|
_calculateMorphedAttributeData(
|
|
4796
|
-
|
|
5057
|
+
object2,
|
|
4797
5058
|
material,
|
|
4798
5059
|
normalAttribute,
|
|
4799
5060
|
morphNormal,
|
|
@@ -5104,13 +5365,13 @@ var init_ModelObject = __esm({
|
|
|
5104
5365
|
transform.multiply(new import_three25.Matrix4().makeTranslation(-8, -8, -8));
|
|
5105
5366
|
try {
|
|
5106
5367
|
for (const part of parts) {
|
|
5107
|
-
const
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
this.add(
|
|
5112
|
-
await
|
|
5113
|
-
|
|
5368
|
+
const object2 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe });
|
|
5369
|
+
object2.matrix.copy(transform).multiply(part.transform);
|
|
5370
|
+
object2.matrixWorldNeedsUpdate = true;
|
|
5371
|
+
object2.matrixAutoUpdate = false;
|
|
5372
|
+
this.add(object2);
|
|
5373
|
+
await object2.init();
|
|
5374
|
+
object2.iterateAllMeshes((mesh) => {
|
|
5114
5375
|
const source = mesh.material;
|
|
5115
5376
|
let material = this.specialMaterials.get(source);
|
|
5116
5377
|
if (!material) {
|
|
@@ -5121,7 +5382,7 @@ var init_ModelObject = __esm({
|
|
|
5121
5382
|
mesh.material = material;
|
|
5122
5383
|
});
|
|
5123
5384
|
for (const [name, rotation] of Object.entries(part.rotations)) {
|
|
5124
|
-
|
|
5385
|
+
object2.getGroupByName(name)?.rotation.set(...rotation, "ZYX");
|
|
5125
5386
|
}
|
|
5126
5387
|
}
|
|
5127
5388
|
} catch (error) {
|
|
@@ -5166,6 +5427,7 @@ var init_ModelObject = __esm({
|
|
|
5166
5427
|
if (this.options.uvLockRotation) {
|
|
5167
5428
|
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new import_three25.Euler(...this.options.uvLockRotation));
|
|
5168
5429
|
}
|
|
5430
|
+
UVMapper.setAtlasUvBounds(elGeo, el.faces, this.atlas);
|
|
5169
5431
|
if (this.options.tints) {
|
|
5170
5432
|
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
5171
5433
|
for (const [faceIndex, faceName] of CUBE_FACES.entries()) {
|
|
@@ -5231,7 +5493,7 @@ var init_ModelObject = __esm({
|
|
|
5231
5493
|
}
|
|
5232
5494
|
applyTextures() {
|
|
5233
5495
|
if (this.atlas) {
|
|
5234
|
-
const mat = Materials.createShadedCanvasMaterial(this.atlas.image.canvas, this.atlas.hasTransparency, false);
|
|
5496
|
+
const mat = Materials.createShadedCanvasMaterial(this.atlas.image.canvas, this.atlas.hasTransparency, false, true);
|
|
5235
5497
|
this.atlasMaterial = mat;
|
|
5236
5498
|
this.atlasTexture = mat.uniforms?.map?.value ?? mat.map;
|
|
5237
5499
|
this.iterateAllMeshes((mesh) => {
|
|
@@ -5598,6 +5860,8 @@ __export(index_browser_exports, {
|
|
|
5598
5860
|
Models: () => Models,
|
|
5599
5861
|
NBTHelper: () => NBTHelper,
|
|
5600
5862
|
OrbitControls: () => OrbitControls,
|
|
5863
|
+
PackFormats: () => PackFormats,
|
|
5864
|
+
PackMetadata: () => PackMetadata,
|
|
5601
5865
|
PersistentCache: () => PersistentCache,
|
|
5602
5866
|
Renderer: () => Renderer,
|
|
5603
5867
|
RequestError: () => RequestError,
|
|
@@ -6108,7 +6372,7 @@ var OBJExporter = class {
|
|
|
6108
6372
|
* @param {Object3D} object - The 3D object to export.
|
|
6109
6373
|
* @return {string} The exported OBJ.
|
|
6110
6374
|
*/
|
|
6111
|
-
parse(
|
|
6375
|
+
parse(object2) {
|
|
6112
6376
|
let output = "";
|
|
6113
6377
|
let indexVertex = 0;
|
|
6114
6378
|
let indexVertexUvs = 0;
|
|
@@ -6227,7 +6491,7 @@ var OBJExporter = class {
|
|
|
6227
6491
|
}
|
|
6228
6492
|
indexVertex += nbVertex;
|
|
6229
6493
|
}
|
|
6230
|
-
|
|
6494
|
+
object2.traverse(function(child) {
|
|
6231
6495
|
if (child.isMesh === true) {
|
|
6232
6496
|
parseMesh(child);
|
|
6233
6497
|
}
|
|
@@ -6255,9 +6519,9 @@ var PLYExporter = class {
|
|
|
6255
6519
|
* @param {PLYExporter~Options} options - The export options.
|
|
6256
6520
|
* @return {?(string|ArrayBuffer)} The exported PLY.
|
|
6257
6521
|
*/
|
|
6258
|
-
parse(
|
|
6522
|
+
parse(object2, onDone, options = {}) {
|
|
6259
6523
|
function traverseMeshes(cb) {
|
|
6260
|
-
|
|
6524
|
+
object2.traverse(function(child) {
|
|
6261
6525
|
if (child.isMesh === true || child.isPoints) {
|
|
6262
6526
|
const mesh = child;
|
|
6263
6527
|
const geometry = mesh.geometry;
|
|
@@ -6290,7 +6554,7 @@ var PLYExporter = class {
|
|
|
6290
6554
|
for (const name of customAttributeNames) customTypes[name] = "float";
|
|
6291
6555
|
let vertexCount = 0;
|
|
6292
6556
|
let faceCount = 0;
|
|
6293
|
-
|
|
6557
|
+
object2.traverse(function(child) {
|
|
6294
6558
|
if (child.isMesh === true) {
|
|
6295
6559
|
const mesh = child;
|
|
6296
6560
|
const geometry = mesh.geometry;
|
|
@@ -7078,12 +7342,12 @@ var GLTFWriter = class {
|
|
|
7078
7342
|
* @param {THREE.Object3D|THREE.Material|THREE.BufferGeometry|THREE.AnimationClip} object
|
|
7079
7343
|
* @param {Object} objectDef
|
|
7080
7344
|
*/
|
|
7081
|
-
serializeUserData(
|
|
7082
|
-
if (Object.keys(
|
|
7345
|
+
serializeUserData(object2, objectDef) {
|
|
7346
|
+
if (Object.keys(object2.userData).length === 0) return;
|
|
7083
7347
|
const options = this.options;
|
|
7084
7348
|
const extensionsUsed = this.extensionsUsed;
|
|
7085
7349
|
try {
|
|
7086
|
-
const json = JSON.parse(JSON.stringify(
|
|
7350
|
+
const json = JSON.parse(JSON.stringify(object2.userData));
|
|
7087
7351
|
if (options.includeCustomExtensions && json.gltfExtensions) {
|
|
7088
7352
|
if (objectDef.extensions === void 0) objectDef.extensions = {};
|
|
7089
7353
|
for (const extensionName in json.gltfExtensions) {
|
|
@@ -7094,7 +7358,7 @@ var GLTFWriter = class {
|
|
|
7094
7358
|
}
|
|
7095
7359
|
if (Object.keys(json).length > 0) objectDef.extras = json;
|
|
7096
7360
|
} catch (error) {
|
|
7097
|
-
console.warn("THREE.GLTFExporter: userData of '" +
|
|
7361
|
+
console.warn("THREE.GLTFExporter: userData of '" + object2.name + "' won't be serialized because of JSON.stringify error - " + error.message);
|
|
7098
7362
|
}
|
|
7099
7363
|
}
|
|
7100
7364
|
/**
|
|
@@ -7467,7 +7731,7 @@ var GLTFWriter = class {
|
|
|
7467
7731
|
* @param {string} mimeType export format
|
|
7468
7732
|
* @return {number} Index of the processed texture in the "images" array
|
|
7469
7733
|
*/
|
|
7470
|
-
processImage(image,
|
|
7734
|
+
processImage(image, format2, flipY, mimeType = "image/png") {
|
|
7471
7735
|
if (image !== null) {
|
|
7472
7736
|
const writer = this;
|
|
7473
7737
|
const cache = writer.cache;
|
|
@@ -7491,8 +7755,8 @@ var GLTFWriter = class {
|
|
|
7491
7755
|
ctx.scale(1, -1);
|
|
7492
7756
|
}
|
|
7493
7757
|
if (image.data !== void 0) {
|
|
7494
|
-
if (
|
|
7495
|
-
console.error("GLTFExporter: Only RGBAFormat is supported.",
|
|
7758
|
+
if (format2 !== import_three18.RGBAFormat) {
|
|
7759
|
+
console.error("GLTFExporter: Only RGBAFormat is supported.", format2);
|
|
7496
7760
|
}
|
|
7497
7761
|
if (image.width > options.maxTextureSize || image.height > options.maxTextureSize) {
|
|
7498
7762
|
console.warn("GLTFExporter: Image size is bigger than maxTextureSize", image);
|
|
@@ -8020,13 +8284,13 @@ var GLTFWriter = class {
|
|
|
8020
8284
|
* @param {THREE.Object3D} object
|
|
8021
8285
|
* @return {?number}
|
|
8022
8286
|
*/
|
|
8023
|
-
processSkin(
|
|
8287
|
+
processSkin(object2) {
|
|
8024
8288
|
const json = this.json;
|
|
8025
8289
|
const nodeMap = this.nodeMap;
|
|
8026
|
-
const node = json.nodes[nodeMap.get(
|
|
8027
|
-
const skeleton =
|
|
8290
|
+
const node = json.nodes[nodeMap.get(object2)];
|
|
8291
|
+
const skeleton = object2.skeleton;
|
|
8028
8292
|
if (skeleton === void 0) return null;
|
|
8029
|
-
const rootJoint =
|
|
8293
|
+
const rootJoint = object2.skeleton.bones[0];
|
|
8030
8294
|
if (rootJoint === void 0) return null;
|
|
8031
8295
|
const joints = [];
|
|
8032
8296
|
const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
|
|
@@ -8034,7 +8298,7 @@ var GLTFWriter = class {
|
|
|
8034
8298
|
for (let i = 0; i < skeleton.bones.length; ++i) {
|
|
8035
8299
|
joints.push(nodeMap.get(skeleton.bones[i]));
|
|
8036
8300
|
temporaryBoneInverse.copy(skeleton.boneInverses[i]);
|
|
8037
|
-
temporaryBoneInverse.multiply(
|
|
8301
|
+
temporaryBoneInverse.multiply(object2.bindMatrix).toArray(inverseBindMatrices, i * 16);
|
|
8038
8302
|
}
|
|
8039
8303
|
if (json.skins === void 0) json.skins = [];
|
|
8040
8304
|
json.skins.push({
|
|
@@ -8050,19 +8314,19 @@ var GLTFWriter = class {
|
|
|
8050
8314
|
* @param {THREE.Object3D} object Object3D to processNodeAsync
|
|
8051
8315
|
* @return {Promise<number>} Index of the node in the nodes list
|
|
8052
8316
|
*/
|
|
8053
|
-
async processNodeAsync(
|
|
8317
|
+
async processNodeAsync(object2) {
|
|
8054
8318
|
const json = this.json;
|
|
8055
8319
|
const options = this.options;
|
|
8056
8320
|
const nodeMap = this.nodeMap;
|
|
8057
8321
|
if (!json.nodes) json.nodes = [];
|
|
8058
|
-
if (
|
|
8059
|
-
return await this._processNodeWithPivotAsync(
|
|
8322
|
+
if (object2.pivot !== null) {
|
|
8323
|
+
return await this._processNodeWithPivotAsync(object2);
|
|
8060
8324
|
}
|
|
8061
8325
|
const nodeDef = {};
|
|
8062
8326
|
if (options.trs) {
|
|
8063
|
-
const rotation =
|
|
8064
|
-
const position =
|
|
8065
|
-
const scale =
|
|
8327
|
+
const rotation = object2.quaternion.toArray();
|
|
8328
|
+
const position = object2.position.toArray();
|
|
8329
|
+
const scale = object2.scale.toArray();
|
|
8066
8330
|
if (!equalArray(rotation, [0, 0, 0, 1])) {
|
|
8067
8331
|
nodeDef.rotation = rotation;
|
|
8068
8332
|
}
|
|
@@ -8073,28 +8337,28 @@ var GLTFWriter = class {
|
|
|
8073
8337
|
nodeDef.scale = scale;
|
|
8074
8338
|
}
|
|
8075
8339
|
} else {
|
|
8076
|
-
if (
|
|
8077
|
-
|
|
8340
|
+
if (object2.matrixAutoUpdate) {
|
|
8341
|
+
object2.updateMatrix();
|
|
8078
8342
|
}
|
|
8079
|
-
if (isIdentityMatrix(
|
|
8080
|
-
nodeDef.matrix =
|
|
8343
|
+
if (isIdentityMatrix(object2.matrix) === false) {
|
|
8344
|
+
nodeDef.matrix = object2.matrix.elements;
|
|
8081
8345
|
}
|
|
8082
8346
|
}
|
|
8083
|
-
if (
|
|
8084
|
-
this.serializeUserData(
|
|
8085
|
-
if (
|
|
8086
|
-
const meshIndex = await this.processMeshAsync(
|
|
8347
|
+
if (object2.name !== "") nodeDef.name = String(object2.name);
|
|
8348
|
+
this.serializeUserData(object2, nodeDef);
|
|
8349
|
+
if (object2.isMesh || object2.isLine || object2.isPoints) {
|
|
8350
|
+
const meshIndex = await this.processMeshAsync(object2);
|
|
8087
8351
|
if (meshIndex !== null) nodeDef.mesh = meshIndex;
|
|
8088
|
-
} else if (
|
|
8089
|
-
nodeDef.camera = this.processCamera(
|
|
8352
|
+
} else if (object2.isCamera) {
|
|
8353
|
+
nodeDef.camera = this.processCamera(object2);
|
|
8090
8354
|
}
|
|
8091
|
-
if (
|
|
8355
|
+
if (object2.isSkinnedMesh) this.skins.push(object2);
|
|
8092
8356
|
const nodeIndex = json.nodes.push(nodeDef) - 1;
|
|
8093
|
-
nodeMap.set(
|
|
8094
|
-
if (
|
|
8357
|
+
nodeMap.set(object2, nodeIndex);
|
|
8358
|
+
if (object2.children.length > 0) {
|
|
8095
8359
|
const children = [];
|
|
8096
|
-
for (let i = 0, l =
|
|
8097
|
-
const child =
|
|
8360
|
+
for (let i = 0, l = object2.children.length; i < l; i++) {
|
|
8361
|
+
const child = object2.children[i];
|
|
8098
8362
|
if (child.visible || options.onlyVisible === false) {
|
|
8099
8363
|
const childNodeIndex = await this.processNodeAsync(child);
|
|
8100
8364
|
if (childNodeIndex !== null) children.push(childNodeIndex);
|
|
@@ -8103,7 +8367,7 @@ var GLTFWriter = class {
|
|
|
8103
8367
|
if (children.length > 0) nodeDef.children = children;
|
|
8104
8368
|
}
|
|
8105
8369
|
await this._invokeAllAsync(function(ext) {
|
|
8106
|
-
ext.writeNode && ext.writeNode(
|
|
8370
|
+
ext.writeNode && ext.writeNode(object2, nodeDef);
|
|
8107
8371
|
});
|
|
8108
8372
|
return nodeIndex;
|
|
8109
8373
|
}
|
|
@@ -8112,19 +8376,19 @@ var GLTFWriter = class {
|
|
|
8112
8376
|
* @param {THREE.Object3D} object Object3D with pivot
|
|
8113
8377
|
* @return {Promise<number>} Index of the container node
|
|
8114
8378
|
*/
|
|
8115
|
-
async _processNodeWithPivotAsync(
|
|
8379
|
+
async _processNodeWithPivotAsync(object2) {
|
|
8116
8380
|
const json = this.json;
|
|
8117
8381
|
const options = this.options;
|
|
8118
8382
|
const nodeMap = this.nodeMap;
|
|
8119
|
-
const pivot =
|
|
8383
|
+
const pivot = object2.pivot;
|
|
8120
8384
|
const containerDef = {};
|
|
8121
|
-
const rotation =
|
|
8385
|
+
const rotation = object2.quaternion.toArray();
|
|
8122
8386
|
const position = [
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8387
|
+
object2.position.x + pivot.x,
|
|
8388
|
+
object2.position.y + pivot.y,
|
|
8389
|
+
object2.position.z + pivot.z
|
|
8126
8390
|
];
|
|
8127
|
-
const scale =
|
|
8391
|
+
const scale = object2.scale.toArray();
|
|
8128
8392
|
if (!equalArray(rotation, [0, 0, 0, 1])) {
|
|
8129
8393
|
containerDef.rotation = rotation;
|
|
8130
8394
|
}
|
|
@@ -8135,28 +8399,28 @@ var GLTFWriter = class {
|
|
|
8135
8399
|
containerDef.scale = scale;
|
|
8136
8400
|
}
|
|
8137
8401
|
containerDef.extras = { pivot: pivot.toArray() };
|
|
8138
|
-
if (
|
|
8139
|
-
this.serializeUserData(
|
|
8402
|
+
if (object2.name !== "") containerDef.name = String(object2.name);
|
|
8403
|
+
this.serializeUserData(object2, containerDef);
|
|
8140
8404
|
const containerIndex = json.nodes.push(containerDef) - 1;
|
|
8141
|
-
nodeMap.set(
|
|
8405
|
+
nodeMap.set(object2, containerIndex);
|
|
8142
8406
|
const childDef = {};
|
|
8143
8407
|
const childPosition = [-pivot.x, -pivot.y, -pivot.z];
|
|
8144
8408
|
if (!equalArray(childPosition, [0, 0, 0])) {
|
|
8145
8409
|
childDef.translation = childPosition;
|
|
8146
8410
|
}
|
|
8147
|
-
if (
|
|
8148
|
-
const meshIndex = await this.processMeshAsync(
|
|
8411
|
+
if (object2.isMesh || object2.isLine || object2.isPoints) {
|
|
8412
|
+
const meshIndex = await this.processMeshAsync(object2);
|
|
8149
8413
|
if (meshIndex !== null) childDef.mesh = meshIndex;
|
|
8150
|
-
} else if (
|
|
8151
|
-
childDef.camera = this.processCamera(
|
|
8414
|
+
} else if (object2.isCamera) {
|
|
8415
|
+
childDef.camera = this.processCamera(object2);
|
|
8152
8416
|
}
|
|
8153
|
-
if (
|
|
8417
|
+
if (object2.isSkinnedMesh) this.skins.push(object2);
|
|
8154
8418
|
const childIndex = json.nodes.push(childDef) - 1;
|
|
8155
8419
|
const containerChildren = [childIndex];
|
|
8156
|
-
if (
|
|
8420
|
+
if (object2.children.length > 0) {
|
|
8157
8421
|
const grandchildren = [];
|
|
8158
|
-
for (let i = 0, l =
|
|
8159
|
-
const child =
|
|
8422
|
+
for (let i = 0, l = object2.children.length; i < l; i++) {
|
|
8423
|
+
const child = object2.children[i];
|
|
8160
8424
|
if (child.visible || options.onlyVisible === false) {
|
|
8161
8425
|
const childNodeIndex = await this.processNodeAsync(child);
|
|
8162
8426
|
if (childNodeIndex !== null) grandchildren.push(childNodeIndex);
|
|
@@ -8166,7 +8430,7 @@ var GLTFWriter = class {
|
|
|
8166
8430
|
}
|
|
8167
8431
|
containerDef.children = containerChildren;
|
|
8168
8432
|
await this._invokeAllAsync(function(ext) {
|
|
8169
|
-
ext.writeNode && ext.writeNode(
|
|
8433
|
+
ext.writeNode && ext.writeNode(object2, containerDef);
|
|
8170
8434
|
});
|
|
8171
8435
|
return containerIndex;
|
|
8172
8436
|
}
|
|
@@ -8609,10 +8873,10 @@ var GLTFMeshGpuInstancing = class {
|
|
|
8609
8873
|
this.writer = writer;
|
|
8610
8874
|
this.name = "EXT_mesh_gpu_instancing";
|
|
8611
8875
|
}
|
|
8612
|
-
writeNode(
|
|
8613
|
-
if (!
|
|
8876
|
+
writeNode(object2, nodeDef) {
|
|
8877
|
+
if (!object2.isInstancedMesh) return;
|
|
8614
8878
|
const writer = this.writer;
|
|
8615
|
-
const mesh =
|
|
8879
|
+
const mesh = object2;
|
|
8616
8880
|
const translationAttr = new Float32Array(mesh.count * 3);
|
|
8617
8881
|
const rotationAttr = new Float32Array(mesh.count * 4);
|
|
8618
8882
|
const scaleAttr = new Float32Array(mesh.count * 3);
|
|
@@ -8802,8 +9066,8 @@ var SceneExporter = class {
|
|
|
8802
9066
|
}
|
|
8803
9067
|
}
|
|
8804
9068
|
};
|
|
8805
|
-
function localMatrix(
|
|
8806
|
-
return
|
|
9069
|
+
function localMatrix(object2) {
|
|
9070
|
+
return object2.matrixAutoUpdate ? new import_three19.Matrix4().compose(object2.position, object2.quaternion, object2.scale) : object2.matrix.clone();
|
|
8807
9071
|
}
|
|
8808
9072
|
function createSnapshot(root, gltf, bakeColors = false) {
|
|
8809
9073
|
const scene = new import_three19.Scene();
|
|
@@ -8907,10 +9171,10 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8907
9171
|
scene.add(copy);
|
|
8908
9172
|
}
|
|
8909
9173
|
};
|
|
8910
|
-
const visit = (
|
|
8911
|
-
if (!
|
|
8912
|
-
const world = parentWorld.clone().multiply(localMatrix(
|
|
8913
|
-
const mesh =
|
|
9174
|
+
const visit = (object2, parentWorld) => {
|
|
9175
|
+
if (!object2.visible) return;
|
|
9176
|
+
const world = parentWorld.clone().multiply(localMatrix(object2));
|
|
9177
|
+
const mesh = object2;
|
|
8914
9178
|
if (mesh.isMesh) {
|
|
8915
9179
|
const instanced = mesh;
|
|
8916
9180
|
if (instanced.isInstancedMesh) {
|
|
@@ -8924,7 +9188,7 @@ function createSnapshot(root, gltf, bakeColors = false) {
|
|
|
8924
9188
|
addMesh(mesh, world);
|
|
8925
9189
|
}
|
|
8926
9190
|
}
|
|
8927
|
-
for (const child of
|
|
9191
|
+
for (const child of object2.children) visit(child, world);
|
|
8928
9192
|
};
|
|
8929
9193
|
try {
|
|
8930
9194
|
const ancestors = [];
|
|
@@ -9156,11 +9420,11 @@ var GuiHelper = class {
|
|
|
9156
9420
|
switch (recipe.type) {
|
|
9157
9421
|
case "minecraft:crafting_shaped":
|
|
9158
9422
|
case "crafting_shaped": {
|
|
9159
|
-
const
|
|
9160
|
-
if (!
|
|
9423
|
+
const pattern2 = recipe.pattern;
|
|
9424
|
+
if (!pattern2.length || pattern2.length > 3 || !pattern2[0].length || pattern2[0].length > 3 || pattern2.some((row) => row.length !== pattern2[0].length)) {
|
|
9161
9425
|
throw new Error("Crafting patterns must be rectangular, with 1\u20133 rows and columns");
|
|
9162
9426
|
}
|
|
9163
|
-
const cells =
|
|
9427
|
+
const cells = pattern2.flatMap((row, y) => row.split("").map((symbol, x) => ({ symbol, x, y }))).filter((cell) => cell.symbol !== " ");
|
|
9164
9428
|
if (!cells.length) throw new Error("Crafting patterns must contain an ingredient");
|
|
9165
9429
|
const minX = Math.min(...cells.map((cell) => cell.x)), maxX = Math.max(...cells.map((cell) => cell.x));
|
|
9166
9430
|
const minY = Math.min(...cells.map((cell) => cell.y)), maxY = Math.max(...cells.map((cell) => cell.y));
|
|
@@ -9572,29 +9836,29 @@ var SceneInspector = class {
|
|
|
9572
9836
|
this.objectControlsContainer.innerHTML = "";
|
|
9573
9837
|
this.addControls(targetObject, targetIntersection, instance);
|
|
9574
9838
|
}
|
|
9575
|
-
addControls(
|
|
9839
|
+
addControls(object2, intersection, instance) {
|
|
9576
9840
|
const container = document.createElement("div");
|
|
9577
9841
|
container.append(this.separator("Select Parent/Child"));
|
|
9578
|
-
if (
|
|
9579
|
-
container.append(this.buttonControl("Select Parent " +
|
|
9580
|
-
this.selectObject(
|
|
9842
|
+
if (object2.parent) {
|
|
9843
|
+
container.append(this.buttonControl("Select Parent " + object2.parent.constructor.name + " " + object2.parent.name, "P", () => {
|
|
9844
|
+
this.selectObject(object2.parent, intersection, instance);
|
|
9581
9845
|
}));
|
|
9582
9846
|
}
|
|
9583
|
-
if (
|
|
9847
|
+
if (object2.children.length > 0) {
|
|
9584
9848
|
let i = 1;
|
|
9585
|
-
for (let child of
|
|
9849
|
+
for (let child of object2.children) {
|
|
9586
9850
|
container.append(this.buttonControl("Select Child " + child.constructor.name + " " + child.name, "C" + i++, () => {
|
|
9587
9851
|
this.selectObject(child, intersection, instance);
|
|
9588
9852
|
}));
|
|
9589
9853
|
}
|
|
9590
9854
|
}
|
|
9591
9855
|
container.append(this.separator());
|
|
9592
|
-
const selectedInstance = instance && (
|
|
9856
|
+
const selectedInstance = instance && (object2 === instance.instanceable || object2 === intersection?.object) ? instance : void 0;
|
|
9593
9857
|
if (!selectedInstance) {
|
|
9594
|
-
container.append(this.toggleControl("Visibility", "V",
|
|
9858
|
+
container.append(this.toggleControl("Visibility", "V", object2.visible, (v) => object2.visible = v));
|
|
9595
9859
|
}
|
|
9596
9860
|
container.append(this.separator("Mesh"));
|
|
9597
|
-
this.addObjectControls(
|
|
9861
|
+
this.addObjectControls(object2, intersection, container, selectedInstance);
|
|
9598
9862
|
container.append(this.separator());
|
|
9599
9863
|
this.objectControlsContainer.append(container);
|
|
9600
9864
|
}
|
|
@@ -10160,8 +10424,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
10160
10424
|
return false;
|
|
10161
10425
|
}
|
|
10162
10426
|
return this._models.some((model) => {
|
|
10163
|
-
const
|
|
10164
|
-
return
|
|
10427
|
+
const object2 = isInstanceReference(model) ? model.instanceable : model;
|
|
10428
|
+
return object2.isOpaqueFullCube && this.getModelCullMask(model, 63) === 63;
|
|
10165
10429
|
});
|
|
10166
10430
|
}
|
|
10167
10431
|
getModelMatrix(model) {
|
|
@@ -10170,8 +10434,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
10170
10434
|
return model.matrix.clone();
|
|
10171
10435
|
}
|
|
10172
10436
|
getModelCullMask(model, worldMask) {
|
|
10173
|
-
const
|
|
10174
|
-
if (
|
|
10437
|
+
const object2 = isInstanceReference(model) ? model.instanceable : model;
|
|
10438
|
+
if (object2.options.displayPosition) return 0;
|
|
10175
10439
|
const position = new import_three32.Vector3();
|
|
10176
10440
|
const rotation = new import_three32.Quaternion();
|
|
10177
10441
|
const scale = new import_three32.Vector3();
|
|
@@ -10188,14 +10452,14 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
10188
10452
|
replacements.push(model);
|
|
10189
10453
|
continue;
|
|
10190
10454
|
}
|
|
10191
|
-
const
|
|
10455
|
+
const object2 = isInstanceReference(model) ? model.instanceable : model;
|
|
10192
10456
|
const cullMask = this.getModelCullMask(model, worldMask);
|
|
10193
|
-
if (cullMask === (
|
|
10457
|
+
if (cullMask === (object2.options.cullMask ?? 0)) {
|
|
10194
10458
|
replacements.push(model);
|
|
10195
10459
|
continue;
|
|
10196
10460
|
}
|
|
10197
10461
|
const matrix = this.getModelMatrix(model);
|
|
10198
|
-
const replacement = await this.scene.addModel(
|
|
10462
|
+
const replacement = await this.scene.addModel(object2.originalModel, { ...object2.options, cullMask });
|
|
10199
10463
|
replacements.push(replacement);
|
|
10200
10464
|
if (isInstanceReference(replacement)) {
|
|
10201
10465
|
replacement.setMatrix(matrix);
|
|
@@ -10203,8 +10467,8 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
10203
10467
|
replacement.matrix.copy(matrix);
|
|
10204
10468
|
replacement.matrixWorldNeedsUpdate = true;
|
|
10205
10469
|
matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
10206
|
-
replacement.matrixAutoUpdate =
|
|
10207
|
-
replacement.visible =
|
|
10470
|
+
replacement.matrixAutoUpdate = object2.matrixAutoUpdate;
|
|
10471
|
+
replacement.visible = object2.visible;
|
|
10208
10472
|
}
|
|
10209
10473
|
}
|
|
10210
10474
|
} catch (error) {
|
|
@@ -12126,9 +12390,9 @@ var SchematicParser = class {
|
|
|
12126
12390
|
* Parses a legacy schematic using custom mappings before the bundled defaults.
|
|
12127
12391
|
* Keys are `id:metadata`; values are block states such as `minecraft:oak_log[axis=x]`.
|
|
12128
12392
|
*/
|
|
12129
|
-
static async parse(nbt, customMappings = {}) {
|
|
12393
|
+
static async parse(nbt, customMappings = {}, options = {}) {
|
|
12130
12394
|
const tags = nbt.value;
|
|
12131
|
-
if (tags.Materials?.type !== "string" || tags.Materials.value !== "Alpha") {
|
|
12395
|
+
if (!options.lenient && (tags.Materials?.type !== "string" || tags.Materials.value !== "Alpha")) {
|
|
12132
12396
|
throw new MineRenderError("Schematic Materials must be Alpha");
|
|
12133
12397
|
}
|
|
12134
12398
|
const size = ["Width", "Height", "Length"].map((name) => {
|
|
@@ -12169,8 +12433,16 @@ var SchematicParser = class {
|
|
|
12169
12433
|
const id = high << 8 | ids.value[index] & 255;
|
|
12170
12434
|
const metadata = data.value[index] & 255;
|
|
12171
12435
|
const key = `${id}:${metadata}`;
|
|
12172
|
-
|
|
12173
|
-
if (!mapped
|
|
12436
|
+
let mapped = customMappings[key] ?? mapping[key];
|
|
12437
|
+
if (!mapped && options.lenient) {
|
|
12438
|
+
mapped = customMappings[`${id}:0`] ?? mapping[`${id}:0`];
|
|
12439
|
+
}
|
|
12440
|
+
if (!mapped) {
|
|
12441
|
+
if (options.lenient) {
|
|
12442
|
+
continue;
|
|
12443
|
+
}
|
|
12444
|
+
throw new MineRenderError(`Unsupported legacy block ${id}:${metadata} at schematic index ${index}`);
|
|
12445
|
+
}
|
|
12174
12446
|
const [type, state] = mapped.split("[");
|
|
12175
12447
|
if (type === "minecraft:air") continue;
|
|
12176
12448
|
const properties = {};
|
|
@@ -13328,53 +13600,53 @@ var _MineRenderScene = class _MineRenderScene extends import_three34.Scene {
|
|
|
13328
13600
|
this.options = (0, import_ts_deepmerge8.default)({}, _MineRenderScene.DEFAULT_OPTIONS, options ?? {});
|
|
13329
13601
|
}
|
|
13330
13602
|
add(...objects) {
|
|
13331
|
-
for (const
|
|
13603
|
+
for (const object2 of objects) {
|
|
13332
13604
|
this.dirty = true;
|
|
13333
13605
|
try {
|
|
13334
|
-
super.add(
|
|
13606
|
+
super.add(object2);
|
|
13335
13607
|
} finally {
|
|
13336
|
-
if (
|
|
13337
|
-
this.updateObjectRegistration(
|
|
13608
|
+
if (object2?.isObject3D && object2 !== this) {
|
|
13609
|
+
this.updateObjectRegistration(object2, object2.parent === this);
|
|
13338
13610
|
}
|
|
13339
13611
|
}
|
|
13340
13612
|
}
|
|
13341
13613
|
return this;
|
|
13342
13614
|
}
|
|
13343
13615
|
remove(...objects) {
|
|
13344
|
-
for (const
|
|
13345
|
-
if (!this.children.includes(
|
|
13616
|
+
for (const object2 of objects) {
|
|
13617
|
+
if (!this.children.includes(object2)) continue;
|
|
13346
13618
|
this.dirty = true;
|
|
13347
|
-
this.updateObjectRegistration(
|
|
13619
|
+
this.updateObjectRegistration(object2, false);
|
|
13348
13620
|
try {
|
|
13349
|
-
super.remove(
|
|
13621
|
+
super.remove(object2);
|
|
13350
13622
|
} finally {
|
|
13351
|
-
this.updateObjectRegistration(
|
|
13623
|
+
this.updateObjectRegistration(object2, object2.parent === this);
|
|
13352
13624
|
}
|
|
13353
13625
|
}
|
|
13354
13626
|
return this;
|
|
13355
13627
|
}
|
|
13356
|
-
updateObjectRegistration(
|
|
13357
|
-
if (this.observedObjects.has(
|
|
13358
|
-
const observable =
|
|
13628
|
+
updateObjectRegistration(object2, attached) {
|
|
13629
|
+
if (this.observedObjects.has(object2) === attached) return;
|
|
13630
|
+
const observable = object2;
|
|
13359
13631
|
if (attached) {
|
|
13360
|
-
this.observedObjects.add(
|
|
13632
|
+
this.observedObjects.add(object2);
|
|
13361
13633
|
observable.addEventListener("change", this.onObjectChange);
|
|
13362
13634
|
} else {
|
|
13363
|
-
this.observedObjects.delete(
|
|
13635
|
+
this.observedObjects.delete(object2);
|
|
13364
13636
|
observable.removeEventListener("change", this.onObjectChange);
|
|
13365
13637
|
}
|
|
13366
13638
|
const change = attached ? 1 : -1;
|
|
13367
13639
|
this.stats.objectCount += change;
|
|
13368
|
-
if (isSceneObject(
|
|
13640
|
+
if (isSceneObject(object2)) {
|
|
13369
13641
|
this.stats.sceneObjectCount += change;
|
|
13370
13642
|
}
|
|
13371
13643
|
}
|
|
13372
|
-
async initAndAdd(...
|
|
13644
|
+
async initAndAdd(...object2) {
|
|
13373
13645
|
this.dirty = true;
|
|
13374
|
-
for (let obj of
|
|
13646
|
+
for (let obj of object2) {
|
|
13375
13647
|
await obj.init();
|
|
13376
13648
|
}
|
|
13377
|
-
return this.add(...
|
|
13649
|
+
return this.add(...object2);
|
|
13378
13650
|
}
|
|
13379
13651
|
async addSceneObject(asset, objectSupplier, _options, parent = this) {
|
|
13380
13652
|
this.dirty = true;
|
|
@@ -13455,11 +13727,11 @@ var _changeEvent = { type: "change" };
|
|
|
13455
13727
|
var _startEvent = { type: "start" };
|
|
13456
13728
|
var _endEvent = { type: "end" };
|
|
13457
13729
|
var OrbitControls = class extends import_three35.EventDispatcher {
|
|
13458
|
-
constructor(
|
|
13730
|
+
constructor(object2, domElement) {
|
|
13459
13731
|
super();
|
|
13460
13732
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
13461
13733
|
if (domElement === document) console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
|
|
13462
|
-
this.object =
|
|
13734
|
+
this.object = object2;
|
|
13463
13735
|
this.domElement = domElement;
|
|
13464
13736
|
this.domElement.style.touchAction = "none";
|
|
13465
13737
|
this.enabled = true;
|
|
@@ -13516,7 +13788,7 @@ var OrbitControls = class extends import_three35.EventDispatcher {
|
|
|
13516
13788
|
};
|
|
13517
13789
|
this.update = function() {
|
|
13518
13790
|
const offset = new import_three35.Vector3();
|
|
13519
|
-
const quat = new import_three35.Quaternion().setFromUnitVectors(
|
|
13791
|
+
const quat = new import_three35.Quaternion().setFromUnitVectors(object2.up, new import_three35.Vector3(0, 1, 0));
|
|
13520
13792
|
const quatInverse = quat.clone().invert();
|
|
13521
13793
|
const lastPosition = new import_three35.Vector3();
|
|
13522
13794
|
const lastQuaternion = new import_three35.Quaternion();
|
|
@@ -14081,8 +14353,8 @@ var OrbitControls = class extends import_three35.EventDispatcher {
|
|
|
14081
14353
|
}
|
|
14082
14354
|
};
|
|
14083
14355
|
var MapControls = class extends OrbitControls {
|
|
14084
|
-
constructor(
|
|
14085
|
-
super(
|
|
14356
|
+
constructor(object2, domElement) {
|
|
14357
|
+
super(object2, domElement);
|
|
14086
14358
|
this.screenSpacePanning = false;
|
|
14087
14359
|
this.mouseButtons.LEFT = import_three35.MOUSE.PAN;
|
|
14088
14360
|
this.mouseButtons.RIGHT = import_three35.MOUSE.ROTATE;
|
|
@@ -15009,16 +15281,16 @@ var SectionModels = class {
|
|
|
15009
15281
|
if (!models) this.models.set(model, models = /* @__PURE__ */ new Map());
|
|
15010
15282
|
const key = JSON.stringify([rotation.x, rotation.y, rotation.z, variant.uvlock, tints]);
|
|
15011
15283
|
const template = await cached(models, key, async () => {
|
|
15012
|
-
const
|
|
15284
|
+
const object2 = new SectionModel(model, {
|
|
15013
15285
|
instanceMeshes: false,
|
|
15014
15286
|
mergeMeshes: false,
|
|
15015
15287
|
tints,
|
|
15016
15288
|
uvLockRotation: variant.uvlock && (rotation.x !== 0 || rotation.y !== 0) ? [rotation.x, rotation.y, rotation.z] : void 0
|
|
15017
15289
|
});
|
|
15018
|
-
await
|
|
15019
|
-
const geometry =
|
|
15290
|
+
await object2.init();
|
|
15291
|
+
const geometry = object2.children[0].geometry;
|
|
15020
15292
|
geometry.applyMatrix4(new import_three38.Matrix4().makeRotationFromEuler(rotation));
|
|
15021
|
-
|
|
15293
|
+
object2.clear();
|
|
15022
15294
|
const cullFaces = CUBE_FACES.map((face) => {
|
|
15023
15295
|
const local = CUBE_FACES.findIndex((name) => name === atlas.model.elements[0].faces[face]?.cullface);
|
|
15024
15296
|
if (local < 0) return 0;
|
|
@@ -15206,10 +15478,10 @@ var MineRenderWorld = class {
|
|
|
15206
15478
|
await block.object.updateFluid((x, y, z) => {
|
|
15207
15479
|
const neighbor = pos.clone().add(new import_three39.Vector3(x, y, z));
|
|
15208
15480
|
const section = this.getChunkAt(neighbor);
|
|
15209
|
-
const
|
|
15481
|
+
const object2 = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
|
|
15210
15482
|
return {
|
|
15211
|
-
fluid:
|
|
15212
|
-
level:
|
|
15483
|
+
fluid: object2?.fluidKind,
|
|
15484
|
+
level: object2?.fluidLevel,
|
|
15213
15485
|
solid: section?.isOccludingAt(neighbor) ?? false
|
|
15214
15486
|
};
|
|
15215
15487
|
});
|
|
@@ -15329,14 +15601,17 @@ var SectionMesh = class _SectionMesh extends import_three40.Group {
|
|
|
15329
15601
|
for (const { atlas, x, y } of page.placements) {
|
|
15330
15602
|
context.drawImage(atlas.image.canvas, x, y);
|
|
15331
15603
|
}
|
|
15332
|
-
const positions = [], normals = [], uvs = [], colors = [], indices = [];
|
|
15604
|
+
const positions = [], normals = [], uvs = [], uvBounds = [], colors = [], indices = [];
|
|
15333
15605
|
for (const { index, template, cullMask } of page.entries) {
|
|
15334
15606
|
const position = template.geometry.getAttribute("position");
|
|
15335
15607
|
const normal = template.geometry.getAttribute("normal");
|
|
15336
15608
|
const uv = template.geometry.getAttribute("uv");
|
|
15609
|
+
const bounds = template.geometry.getAttribute("uvBounds");
|
|
15337
15610
|
const color = template.geometry.getAttribute("color");
|
|
15338
15611
|
const sourceIndices = template.geometry.getIndex();
|
|
15339
15612
|
const placement = locations.get(template.atlas).placement;
|
|
15613
|
+
const mapU = (u) => (placement.x + u * template.atlas.image.width) / page.width;
|
|
15614
|
+
const mapV = (v) => 1 - (placement.y + (1 - v) * template.atlas.image.height) / page.height;
|
|
15340
15615
|
const offsetX = index % 16 * 16;
|
|
15341
15616
|
const offsetY = Math.floor(index / 256) * 16;
|
|
15342
15617
|
const offsetZ = Math.floor(index / 16) % 16 * 16;
|
|
@@ -15347,9 +15622,12 @@ var SectionMesh = class _SectionMesh extends import_three40.Group {
|
|
|
15347
15622
|
const vertex = face * 4 + corner;
|
|
15348
15623
|
positions.push(position.getX(vertex) + offsetX, position.getY(vertex) + offsetY, position.getZ(vertex) + offsetZ);
|
|
15349
15624
|
normals.push(normal.getX(vertex), normal.getY(vertex), normal.getZ(vertex));
|
|
15350
|
-
uvs.push(
|
|
15351
|
-
|
|
15352
|
-
|
|
15625
|
+
uvs.push(mapU(uv.getX(vertex)), mapV(uv.getY(vertex)));
|
|
15626
|
+
uvBounds.push(
|
|
15627
|
+
mapU(bounds?.getX(vertex) ?? 0),
|
|
15628
|
+
mapV(bounds?.getY(vertex) ?? 0),
|
|
15629
|
+
mapU(bounds?.getZ(vertex) ?? 1),
|
|
15630
|
+
mapV(bounds?.getW(vertex) ?? 1)
|
|
15353
15631
|
);
|
|
15354
15632
|
colors.push(color?.getX(vertex) ?? 1, color?.getY(vertex) ?? 1, color?.getZ(vertex) ?? 1);
|
|
15355
15633
|
}
|
|
@@ -15360,11 +15638,12 @@ var SectionMesh = class _SectionMesh extends import_three40.Group {
|
|
|
15360
15638
|
geometry.setAttribute("position", new import_three40.Float32BufferAttribute(positions, 3));
|
|
15361
15639
|
geometry.setAttribute("normal", new import_three40.Float32BufferAttribute(normals, 3));
|
|
15362
15640
|
geometry.setAttribute("uv", new import_three40.Float32BufferAttribute(uvs, 2));
|
|
15641
|
+
geometry.setAttribute("uvBounds", new import_three40.Float32BufferAttribute(uvBounds, 4));
|
|
15363
15642
|
geometry.setAttribute("color", new import_three40.Float32BufferAttribute(colors, 3));
|
|
15364
15643
|
geometry.setIndex(indices);
|
|
15365
15644
|
geometry.computeBoundingBox();
|
|
15366
15645
|
geometry.computeBoundingSphere();
|
|
15367
|
-
const material = Materials.createShadedCanvasMaterial(canvas, false);
|
|
15646
|
+
const material = Materials.createShadedCanvasMaterial(canvas, false, false, true);
|
|
15368
15647
|
material.vertexColors = true;
|
|
15369
15648
|
const texture = material.uniforms?.map?.value ?? material.map;
|
|
15370
15649
|
const mesh = new import_three40.Mesh(geometry, material);
|
|
@@ -15438,7 +15717,7 @@ var Chunk = class _Chunk {
|
|
|
15438
15717
|
this.renderedBlocks.get(index)?.object?.removeFromScene();
|
|
15439
15718
|
if (this.sectionBlocks.delete(index)) this.meshDirty = true;
|
|
15440
15719
|
this.renderedBlocks.delete(index);
|
|
15441
|
-
let
|
|
15720
|
+
let object2;
|
|
15442
15721
|
try {
|
|
15443
15722
|
if (!readBlock) return void 0;
|
|
15444
15723
|
const stored = readBlock();
|
|
@@ -15453,22 +15732,22 @@ var Chunk = class _Chunk {
|
|
|
15453
15732
|
this.sectionBlocks.set(index, { index, template, cullMask: 0 });
|
|
15454
15733
|
this.meshDirty = true;
|
|
15455
15734
|
} else {
|
|
15456
|
-
|
|
15735
|
+
object2 = await this.scene.addBlock(blockState, {
|
|
15457
15736
|
mergeMeshes: true,
|
|
15458
15737
|
instanceMeshes: true,
|
|
15459
15738
|
maxInstanceCount: 2e3,
|
|
15460
15739
|
initialState: stored.properties
|
|
15461
15740
|
});
|
|
15462
|
-
|
|
15741
|
+
object2.setPosition(MineRenderWorld.worldToScenePosition(worldPos));
|
|
15463
15742
|
}
|
|
15464
15743
|
const info = { get block() {
|
|
15465
15744
|
return readBlock();
|
|
15466
|
-
}, object };
|
|
15745
|
+
}, object: object2 };
|
|
15467
15746
|
this.renderedBlocks.set(index, info);
|
|
15468
15747
|
return info;
|
|
15469
15748
|
} catch (error) {
|
|
15470
15749
|
this.data.set(index, void 0);
|
|
15471
|
-
|
|
15750
|
+
object2?.removeFromScene();
|
|
15472
15751
|
throw error;
|
|
15473
15752
|
} finally {
|
|
15474
15753
|
await onBlocksChanged?.([worldPos]);
|