minerender 2.1.0-alpha.143 → 2.1.0-alpha.145
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 +10 -1
- package/dist/browser/esm/env/browser/BrowserEnv.mjs +11 -4
- package/dist/browser/esm/env/browser/BrowserEnv.mjs.map +1 -1
- package/dist/browser/esm/index.browser.d.mts +19 -4
- package/dist/browser/esm/index.browser.mjs.map +1 -1
- package/dist/browser/esm/world/Chunk.mjs +62 -33
- package/dist/browser/esm/world/Chunk.mjs.map +1 -1
- package/dist/browser/esm/world/MineRenderWorld.mjs +16 -1
- package/dist/browser/esm/world/MineRenderWorld.mjs.map +1 -1
- package/dist/browser/esm/world/SectionModels.mjs +21 -15
- package/dist/browser/esm/world/SectionModels.mjs.map +1 -1
- package/dist/browser/esm/world/SectionWorker.mjs +8 -2
- package/dist/browser/esm/world/SectionWorker.mjs.map +1 -1
- package/dist/browser/index.d.ts +19 -4
- package/dist/browser/index.js +217 -155
- package/dist/browser/index.js.map +1 -1
- package/dist/bundle.js +227 -165
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +5 -2
- package/dist/node/index.d.ts +5 -2
- package/dist/node/index.js +106 -51
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +106 -51
- package/dist/node/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/bundle.js
CHANGED
|
@@ -1896,40 +1896,6 @@ var MineRender = (() => {
|
|
|
1896
1896
|
}
|
|
1897
1897
|
});
|
|
1898
1898
|
|
|
1899
|
-
// src/cache/PersistentCache.ts
|
|
1900
|
-
var _PersistentCache, PersistentCache;
|
|
1901
|
-
var init_PersistentCache = __esm({
|
|
1902
|
-
"src/cache/PersistentCache.ts"() {
|
|
1903
|
-
init_dirname();
|
|
1904
|
-
init_buffer2();
|
|
1905
|
-
init_process2();
|
|
1906
|
-
init_Env();
|
|
1907
|
-
_PersistentCache = class _PersistentCache {
|
|
1908
|
-
constructor(backing) {
|
|
1909
|
-
this.backing = backing;
|
|
1910
|
-
}
|
|
1911
|
-
/** Opens a named store in the active environment using the current cache schema version. */
|
|
1912
|
-
static open(name2) {
|
|
1913
|
-
return Env.provider.openCache(name2, _PersistentCache.VERSION);
|
|
1914
|
-
}
|
|
1915
|
-
/** Loads a missing entry and stores only non-nullish results. */
|
|
1916
|
-
async getOrLoad(key, loader) {
|
|
1917
|
-
let v5 = await this.get(key);
|
|
1918
|
-
if (typeof v5 === "undefined" || v5 === null) {
|
|
1919
|
-
v5 = await loader(key);
|
|
1920
|
-
if (typeof v5 !== "undefined" && v5 !== null) {
|
|
1921
|
-
await this.put(key, v5);
|
|
1922
|
-
}
|
|
1923
|
-
}
|
|
1924
|
-
return v5;
|
|
1925
|
-
}
|
|
1926
|
-
};
|
|
1927
|
-
/** Bump to invalidate every persisted entry. */
|
|
1928
|
-
_PersistentCache.VERSION = 2;
|
|
1929
|
-
PersistentCache = _PersistentCache;
|
|
1930
|
-
}
|
|
1931
|
-
});
|
|
1932
|
-
|
|
1933
1899
|
// src/util/log.ts
|
|
1934
1900
|
function readSwitch() {
|
|
1935
1901
|
switchRead = true;
|
|
@@ -2014,6 +1980,40 @@ var MineRender = (() => {
|
|
|
2014
1980
|
}
|
|
2015
1981
|
});
|
|
2016
1982
|
|
|
1983
|
+
// src/cache/PersistentCache.ts
|
|
1984
|
+
var _PersistentCache, PersistentCache;
|
|
1985
|
+
var init_PersistentCache = __esm({
|
|
1986
|
+
"src/cache/PersistentCache.ts"() {
|
|
1987
|
+
init_dirname();
|
|
1988
|
+
init_buffer2();
|
|
1989
|
+
init_process2();
|
|
1990
|
+
init_Env();
|
|
1991
|
+
_PersistentCache = class _PersistentCache {
|
|
1992
|
+
constructor(backing) {
|
|
1993
|
+
this.backing = backing;
|
|
1994
|
+
}
|
|
1995
|
+
/** Opens a named store in the active environment using the current cache schema version. */
|
|
1996
|
+
static open(name2) {
|
|
1997
|
+
return Env.provider.openCache(name2, _PersistentCache.VERSION);
|
|
1998
|
+
}
|
|
1999
|
+
/** Loads a missing entry and stores only non-nullish results. */
|
|
2000
|
+
async getOrLoad(key, loader) {
|
|
2001
|
+
let v5 = await this.get(key);
|
|
2002
|
+
if (typeof v5 === "undefined" || v5 === null) {
|
|
2003
|
+
v5 = await loader(key);
|
|
2004
|
+
if (typeof v5 !== "undefined" && v5 !== null) {
|
|
2005
|
+
await this.put(key, v5);
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
return v5;
|
|
2009
|
+
}
|
|
2010
|
+
};
|
|
2011
|
+
/** Bump to invalidate every persisted entry. */
|
|
2012
|
+
_PersistentCache.VERSION = 2;
|
|
2013
|
+
PersistentCache = _PersistentCache;
|
|
2014
|
+
}
|
|
2015
|
+
});
|
|
2016
|
+
|
|
2017
2017
|
// ../../node_modules/localforage/dist/localforage.js
|
|
2018
2018
|
var require_localforage = __commonJS({
|
|
2019
2019
|
"../../node_modules/localforage/dist/localforage.js"(exports13, module2) {
|
|
@@ -4180,7 +4180,7 @@ var MineRender = (() => {
|
|
|
4180
4180
|
canvas.style.display = "block";
|
|
4181
4181
|
return canvas;
|
|
4182
4182
|
}
|
|
4183
|
-
function
|
|
4183
|
+
function log3(...params) {
|
|
4184
4184
|
const message = "THREE." + params.shift();
|
|
4185
4185
|
if (_setConsoleFunction) {
|
|
4186
4186
|
_setConsoleFunction("log", message, ...params);
|
|
@@ -15870,7 +15870,7 @@ var MineRender = (() => {
|
|
|
15870
15870
|
*/
|
|
15871
15871
|
clone(data) {
|
|
15872
15872
|
if (data === void 0) {
|
|
15873
|
-
|
|
15873
|
+
log3("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");
|
|
15874
15874
|
const array = [];
|
|
15875
15875
|
for (let i4 = 0; i4 < this.count; i4++) {
|
|
15876
15876
|
const index = i4 * this.data.stride + this.offset;
|
|
@@ -15899,7 +15899,7 @@ var MineRender = (() => {
|
|
|
15899
15899
|
*/
|
|
15900
15900
|
toJSON(data) {
|
|
15901
15901
|
if (data === void 0) {
|
|
15902
|
-
|
|
15902
|
+
log3("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");
|
|
15903
15903
|
const array = [];
|
|
15904
15904
|
for (let i4 = 0; i4 < this.count; i4++) {
|
|
15905
15905
|
const index = i4 * this.data.stride + this.offset;
|
|
@@ -31890,11 +31890,11 @@ void main() {
|
|
|
31890
31890
|
};
|
|
31891
31891
|
function onContextLost(event) {
|
|
31892
31892
|
event.preventDefault();
|
|
31893
|
-
|
|
31893
|
+
log3("WebGLRenderer: Context Lost.");
|
|
31894
31894
|
_isContextLost = true;
|
|
31895
31895
|
}
|
|
31896
31896
|
function onContextRestore() {
|
|
31897
|
-
|
|
31897
|
+
log3("WebGLRenderer: Context Restored.");
|
|
31898
31898
|
_isContextLost = false;
|
|
31899
31899
|
const infoAutoReset = info.autoReset;
|
|
31900
31900
|
const shadowMapEnabled = shadowMap.enabled;
|
|
@@ -36232,7 +36232,7 @@ void main() {
|
|
|
36232
36232
|
signal.removeEventListener("abort", abort2);
|
|
36233
36233
|
}
|
|
36234
36234
|
}
|
|
36235
|
-
var import_jobqu,
|
|
36235
|
+
var import_jobqu, log4, RequestError, RequestQueue, Requests;
|
|
36236
36236
|
var init_Requests = __esm({
|
|
36237
36237
|
"src/request/Requests.ts"() {
|
|
36238
36238
|
init_dirname();
|
|
@@ -36240,7 +36240,7 @@ void main() {
|
|
|
36240
36240
|
init_process2();
|
|
36241
36241
|
import_jobqu = __toESM(require_src());
|
|
36242
36242
|
init_log();
|
|
36243
|
-
|
|
36243
|
+
log4 = logger("Requests");
|
|
36244
36244
|
RequestError = class extends Error {
|
|
36245
36245
|
constructor(message, response, cause) {
|
|
36246
36246
|
super(message);
|
|
@@ -36267,7 +36267,7 @@ void main() {
|
|
|
36267
36267
|
try {
|
|
36268
36268
|
return await abortable(this.queue.add(request), signal);
|
|
36269
36269
|
} catch (error2) {
|
|
36270
|
-
|
|
36270
|
+
log4.debug("Request failed", error2);
|
|
36271
36271
|
const delay = this.retryDelay(error2, request, retries);
|
|
36272
36272
|
if (delay === void 0) {
|
|
36273
36273
|
throw error2;
|
|
@@ -36455,7 +36455,7 @@ void main() {
|
|
|
36455
36455
|
});
|
|
36456
36456
|
|
|
36457
36457
|
// src/image/ImageLoader.ts
|
|
36458
|
-
var
|
|
36458
|
+
var log5, ImageLoader2;
|
|
36459
36459
|
var init_ImageLoader = __esm({
|
|
36460
36460
|
"src/image/ImageLoader.ts"() {
|
|
36461
36461
|
init_dirname();
|
|
@@ -36469,7 +36469,7 @@ void main() {
|
|
|
36469
36469
|
init_WrappedImage();
|
|
36470
36470
|
init_base64();
|
|
36471
36471
|
init_log();
|
|
36472
|
-
|
|
36472
|
+
log5 = logger("ImageLoader");
|
|
36473
36473
|
ImageLoader2 = class _ImageLoader {
|
|
36474
36474
|
static _createImage() {
|
|
36475
36475
|
return createImage();
|
|
@@ -36494,7 +36494,7 @@ void main() {
|
|
|
36494
36494
|
return image;
|
|
36495
36495
|
}
|
|
36496
36496
|
static async loadData(src) {
|
|
36497
|
-
|
|
36497
|
+
log5.debug("loadData", src);
|
|
36498
36498
|
const image = await this.loadCanvasData(src);
|
|
36499
36499
|
return image.data.getImageData(0, 0, image.width, image.height);
|
|
36500
36500
|
}
|
|
@@ -36601,7 +36601,7 @@ void main() {
|
|
|
36601
36601
|
});
|
|
36602
36602
|
|
|
36603
36603
|
// src/texture/TextureLoader.ts
|
|
36604
|
-
var
|
|
36604
|
+
var log6, TextureLoader2;
|
|
36605
36605
|
var init_TextureLoader = __esm({
|
|
36606
36606
|
"src/texture/TextureLoader.ts"() {
|
|
36607
36607
|
init_dirname();
|
|
@@ -36612,7 +36612,7 @@ void main() {
|
|
|
36612
36612
|
init_ImageLoader();
|
|
36613
36613
|
init_Textures();
|
|
36614
36614
|
init_log();
|
|
36615
|
-
|
|
36615
|
+
log6 = logger("TextureLoader");
|
|
36616
36616
|
TextureLoader2 = class {
|
|
36617
36617
|
/** Reports whether image loading failed, so cached textures can be retried. */
|
|
36618
36618
|
static hasFailed(texture) {
|
|
@@ -36628,7 +36628,7 @@ void main() {
|
|
|
36628
36628
|
texture.needsUpdate = true;
|
|
36629
36629
|
}, (error2) => {
|
|
36630
36630
|
this.failedTextures.add(texture);
|
|
36631
|
-
|
|
36631
|
+
log6.warn("Failed to load texture", src, error2);
|
|
36632
36632
|
});
|
|
36633
36633
|
texture.image = image;
|
|
36634
36634
|
texture.format = format3;
|
|
@@ -36644,7 +36644,7 @@ void main() {
|
|
|
36644
36644
|
texture.needsUpdate = true;
|
|
36645
36645
|
}).catch((error2) => {
|
|
36646
36646
|
this.failedTextures.add(texture);
|
|
36647
|
-
|
|
36647
|
+
log6.warn("Failed to load texture", src, error2);
|
|
36648
36648
|
});
|
|
36649
36649
|
texture.format = format3;
|
|
36650
36650
|
texture.rotation = rotation;
|
|
@@ -36723,7 +36723,7 @@ void main() {
|
|
|
36723
36723
|
});
|
|
36724
36724
|
|
|
36725
36725
|
// src/Materials.ts
|
|
36726
|
-
var
|
|
36726
|
+
var log7, Materials;
|
|
36727
36727
|
var init_Materials = __esm({
|
|
36728
36728
|
"src/Materials.ts"() {
|
|
36729
36729
|
init_dirname();
|
|
@@ -36735,7 +36735,7 @@ void main() {
|
|
|
36735
36735
|
init_TextureLoader();
|
|
36736
36736
|
init_Caching();
|
|
36737
36737
|
init_log();
|
|
36738
|
-
|
|
36738
|
+
log7 = logger("Materials");
|
|
36739
36739
|
Materials = class _Materials {
|
|
36740
36740
|
/** Shared checkerboard material, created on first access. */
|
|
36741
36741
|
static get MISSING_TEXTURE() {
|
|
@@ -37006,7 +37006,7 @@ void main() {
|
|
|
37006
37006
|
Object.assign(material.defaultAttributeValues, { shade: [1], uvBounds: [0, 0, 1, 1] });
|
|
37007
37007
|
return material;
|
|
37008
37008
|
} catch (e6) {
|
|
37009
|
-
|
|
37009
|
+
log7.warn(e6);
|
|
37010
37010
|
}
|
|
37011
37011
|
return this.createBasicCanvasMaterial(canvas, transparent, shade);
|
|
37012
37012
|
}
|
|
@@ -58568,7 +58568,7 @@ void main() {
|
|
|
58568
58568
|
exports$17.callbackify = callbackify2;
|
|
58569
58569
|
return exports$17;
|
|
58570
58570
|
}
|
|
58571
|
-
var exports$c4, _dewExec$b4, exports$b4, _dewExec$a4, exports$a4, _dewExec$94, exports$94, _dewExec$84, exports$84, _dewExec$74, exports$74, _dewExec$64, exports$64, _dewExec$54, _global$22, exports$54, _dewExec$44, _global$12, exports$44, _dewExec$34, exports$34, _dewExec$25, exports$25, _dewExec$15, exports$17, _dewExec9, _global4, exports11, _extend, callbackify, debuglog, deprecate, format, inherits, inspect, isArray, isBoolean, isBuffer, isDate, isError, isFunction, isNull, isNullOrUndefined, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined,
|
|
58571
|
+
var exports$c4, _dewExec$b4, exports$b4, _dewExec$a4, exports$a4, _dewExec$94, exports$94, _dewExec$84, exports$84, _dewExec$74, exports$74, _dewExec$64, exports$64, _dewExec$54, _global$22, exports$54, _dewExec$44, _global$12, exports$44, _dewExec$34, exports$34, _dewExec$25, exports$25, _dewExec$15, exports$17, _dewExec9, _global4, exports11, _extend, callbackify, debuglog, deprecate, format, inherits, inspect, isArray, isBoolean, isBuffer, isDate, isError, isFunction, isNull, isNullOrUndefined, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, log8, promisify3, types, TextEncoder2, TextDecoder2;
|
|
58572
58572
|
var init_util3 = __esm({
|
|
58573
58573
|
"../../node_modules/@jspm/core/nodelibs/browser/util.js"() {
|
|
58574
58574
|
init_dirname();
|
|
@@ -58652,7 +58652,7 @@ void main() {
|
|
|
58652
58652
|
isString = exports11.isString;
|
|
58653
58653
|
isSymbol = exports11.isSymbol;
|
|
58654
58654
|
isUndefined = exports11.isUndefined;
|
|
58655
|
-
|
|
58655
|
+
log8 = exports11.log;
|
|
58656
58656
|
promisify3 = exports11.promisify;
|
|
58657
58657
|
types = exports11.types;
|
|
58658
58658
|
TextEncoder2 = exports11.TextEncoder = globalThis.TextEncoder;
|
|
@@ -71058,7 +71058,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
71058
71058
|
});
|
|
71059
71059
|
|
|
71060
71060
|
// src/assets/source/HostedAssetSource.ts
|
|
71061
|
-
var BINARY_TIMEOUT,
|
|
71061
|
+
var BINARY_TIMEOUT, log9, DEFAULT_OPTIONS2, _HostedAssetSource, HostedAssetSource;
|
|
71062
71062
|
var init_HostedAssetSource = __esm({
|
|
71063
71063
|
"src/assets/source/HostedAssetSource.ts"() {
|
|
71064
71064
|
init_dirname();
|
|
@@ -71075,7 +71075,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
71075
71075
|
init_parser();
|
|
71076
71076
|
init_merge();
|
|
71077
71077
|
BINARY_TIMEOUT = 6e4;
|
|
71078
|
-
|
|
71078
|
+
log9 = logger("HostedAssetSource");
|
|
71079
71079
|
DEFAULT_OPTIONS2 = {
|
|
71080
71080
|
retryDefaults: true
|
|
71081
71081
|
};
|
|
@@ -71087,14 +71087,14 @@ return ${compiler2.callType("value", tagType)}
|
|
|
71087
71087
|
return direct;
|
|
71088
71088
|
}
|
|
71089
71089
|
if (key.namespace !== DEFAULT_NAMESPACE) {
|
|
71090
|
-
|
|
71090
|
+
log9.debug("Retrying", key, "with default namespace");
|
|
71091
71091
|
const namespaceKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, key.root);
|
|
71092
71092
|
const namespaced = await this.load(namespaceKey, parser);
|
|
71093
71093
|
if (typeof namespaced !== "undefined") {
|
|
71094
71094
|
return namespaced;
|
|
71095
71095
|
}
|
|
71096
71096
|
if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
|
|
71097
|
-
|
|
71097
|
+
log9.debug("Retrying", key, "with default root+namespace");
|
|
71098
71098
|
const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
|
|
71099
71099
|
const namespacedRooted = await this.load(namespacedRootedKey, parser);
|
|
71100
71100
|
if (typeof namespacedRooted !== "undefined") {
|
|
@@ -71102,7 +71102,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
71102
71102
|
}
|
|
71103
71103
|
}
|
|
71104
71104
|
} else if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
|
|
71105
|
-
|
|
71105
|
+
log9.debug("Retrying", key, "with default root");
|
|
71106
71106
|
const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
|
|
71107
71107
|
const rooted = await this.load(rootKey, parser);
|
|
71108
71108
|
if (typeof rooted !== "undefined") {
|
|
@@ -71113,7 +71113,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
71113
71113
|
}
|
|
71114
71114
|
async load(key, parser) {
|
|
71115
71115
|
const url = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
|
|
71116
|
-
|
|
71116
|
+
log9.debug("Loading", url);
|
|
71117
71117
|
const request = { url };
|
|
71118
71118
|
try {
|
|
71119
71119
|
parser.config(request);
|
|
@@ -81239,7 +81239,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
81239
81239
|
});
|
|
81240
81240
|
|
|
81241
81241
|
// src/assets/AssetLoader.ts
|
|
81242
|
-
var
|
|
81242
|
+
var log10, AssetLoader;
|
|
81243
81243
|
var init_AssetLoader = __esm({
|
|
81244
81244
|
"src/assets/AssetLoader.ts"() {
|
|
81245
81245
|
init_dirname();
|
|
@@ -81250,7 +81250,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
81250
81250
|
init_log();
|
|
81251
81251
|
init_source();
|
|
81252
81252
|
init_Caching();
|
|
81253
|
-
|
|
81253
|
+
log10 = logger("AssetLoader");
|
|
81254
81254
|
AssetLoader = class {
|
|
81255
81255
|
static get _SOURCES() {
|
|
81256
81256
|
return this.sources ?? (this.sources = [{ key: "mcassets", source: new HostedAssetSource(this.ROOT, { retryDefaults: false }) }]);
|
|
@@ -81305,11 +81305,11 @@ ${key}` : key;
|
|
|
81305
81305
|
if (override) {
|
|
81306
81306
|
const existing = this.removeSource(key);
|
|
81307
81307
|
if (existing) {
|
|
81308
|
-
|
|
81308
|
+
log10.info("Removed existing AssetSource", key);
|
|
81309
81309
|
}
|
|
81310
81310
|
}
|
|
81311
81311
|
this._SOURCES.unshift({ key, source });
|
|
81312
|
-
|
|
81312
|
+
log10.info("Added AssetSource", key);
|
|
81313
81313
|
}
|
|
81314
81314
|
/** Removes and returns the first source with this name. Call {@link Caching.clear} to reload assets. */
|
|
81315
81315
|
static removeSource(key) {
|
|
@@ -81495,14 +81495,14 @@ ${key}` : key;
|
|
|
81495
81495
|
});
|
|
81496
81496
|
|
|
81497
81497
|
// src/Ticker.ts
|
|
81498
|
-
var
|
|
81498
|
+
var log11, _Ticker, Ticker;
|
|
81499
81499
|
var init_Ticker = __esm({
|
|
81500
81500
|
"src/Ticker.ts"() {
|
|
81501
81501
|
init_dirname();
|
|
81502
81502
|
init_buffer2();
|
|
81503
81503
|
init_process2();
|
|
81504
81504
|
init_log();
|
|
81505
|
-
|
|
81505
|
+
log11 = logger("Ticker");
|
|
81506
81506
|
_Ticker = class _Ticker {
|
|
81507
81507
|
static schedule(fn, ms) {
|
|
81508
81508
|
const handle = setInterval(fn, ms);
|
|
@@ -81520,7 +81520,7 @@ ${key}` : key;
|
|
|
81520
81520
|
try {
|
|
81521
81521
|
t5();
|
|
81522
81522
|
} catch (e6) {
|
|
81523
|
-
|
|
81523
|
+
log11.warn(e6);
|
|
81524
81524
|
}
|
|
81525
81525
|
});
|
|
81526
81526
|
_Ticker.oneSecondTicks++;
|
|
@@ -81774,7 +81774,7 @@ ${key}` : key;
|
|
|
81774
81774
|
});
|
|
81775
81775
|
|
|
81776
81776
|
// src/UVMapper.ts
|
|
81777
|
-
var
|
|
81777
|
+
var log12, X3, Y4, Z3, FACE_UV_AXES, UVMapper, MinecraftFaceUV;
|
|
81778
81778
|
var init_UVMapper = __esm({
|
|
81779
81779
|
"src/UVMapper.ts"() {
|
|
81780
81780
|
init_dirname();
|
|
@@ -81792,7 +81792,7 @@ ${key}` : key;
|
|
|
81792
81792
|
init_ModelGenerator();
|
|
81793
81793
|
init_log();
|
|
81794
81794
|
init_cubeUv();
|
|
81795
|
-
|
|
81795
|
+
log12 = logger("UVMapper");
|
|
81796
81796
|
X3 = 0;
|
|
81797
81797
|
Y4 = 1;
|
|
81798
81798
|
Z3 = 2;
|
|
@@ -82025,7 +82025,7 @@ ${key}` : key;
|
|
|
82025
82025
|
model.elements = originalModel.elements.map((element) => ({ ...element }));
|
|
82026
82026
|
}
|
|
82027
82027
|
const isItemModel = !("elements" in model);
|
|
82028
|
-
|
|
82028
|
+
log12.debug("Creating Atlas for", model.key);
|
|
82029
82029
|
if (model.textures) {
|
|
82030
82030
|
const promises = [];
|
|
82031
82031
|
const uniqueTextureNames = [];
|
|
@@ -82039,7 +82039,7 @@ ${key}` : key;
|
|
|
82039
82039
|
const assetKey = AssetKey.parse("textures", textureValue, model.key);
|
|
82040
82040
|
promises.push(ModelTextures.get(assetKey).then((asset2) => {
|
|
82041
82041
|
if (!asset2) {
|
|
82042
|
-
|
|
82042
|
+
log12.warn("Missing texture", assetKey);
|
|
82043
82043
|
return;
|
|
82044
82044
|
}
|
|
82045
82045
|
textureMap[textureKey] = new WrappedImage(asset2);
|
|
@@ -82051,7 +82051,7 @@ ${key}` : key;
|
|
|
82051
82051
|
}
|
|
82052
82052
|
await Promise.all(promises);
|
|
82053
82053
|
const textureCount = uniqueTextureNames.length;
|
|
82054
|
-
|
|
82054
|
+
log12.debug("Creating Atlas for", textureCount, "textures");
|
|
82055
82055
|
this.fillMissingTextureKeys(model.textures, textureMap);
|
|
82056
82056
|
this.fillMissingTextureKeys(model.textures, metaMap);
|
|
82057
82057
|
const sizes = {};
|
|
@@ -82082,7 +82082,7 @@ ${key}` : key;
|
|
|
82082
82082
|
this.fillMissingTextureKeys(model.textures, sizes);
|
|
82083
82083
|
const s4 = Math.ceil(Math.sqrt(textureCount + 1));
|
|
82084
82084
|
const size = Math.ceil(s4 * maxWidth);
|
|
82085
|
-
|
|
82085
|
+
log12.debug("Atlas size:", size);
|
|
82086
82086
|
const squaredSize = size * size;
|
|
82087
82087
|
const image = new CanvasImage(size, size);
|
|
82088
82088
|
const missing = Textures.getMissing().image;
|
|
@@ -82161,7 +82161,7 @@ ${key}` : key;
|
|
|
82161
82161
|
}
|
|
82162
82162
|
this.fillMissingTextureKeys(model.textures, positions);
|
|
82163
82163
|
if (isItemModel) {
|
|
82164
|
-
|
|
82164
|
+
log12.debug("Generating item model for", model);
|
|
82165
82165
|
model.elements = [];
|
|
82166
82166
|
for (let layerName of ModelGenerator.ITEM_LAYERS) {
|
|
82167
82167
|
const textureImage = textureMap[layerName];
|
|
@@ -82177,7 +82177,7 @@ ${key}` : key;
|
|
|
82177
82177
|
), layerName));
|
|
82178
82178
|
}
|
|
82179
82179
|
}
|
|
82180
|
-
|
|
82180
|
+
log12.debug("Item model elements", model.elements);
|
|
82181
82181
|
}
|
|
82182
82182
|
if (!model.elements) {
|
|
82183
82183
|
}
|
|
@@ -82234,7 +82234,7 @@ ${key}` : key;
|
|
|
82234
82234
|
hasTranslucency
|
|
82235
82235
|
);
|
|
82236
82236
|
} else {
|
|
82237
|
-
|
|
82237
|
+
log12.warn("Model does not have any textures", model);
|
|
82238
82238
|
}
|
|
82239
82239
|
return void 0;
|
|
82240
82240
|
}
|
|
@@ -83770,7 +83770,7 @@ ${key}` : key, async () => {
|
|
|
83770
83770
|
});
|
|
83771
83771
|
|
|
83772
83772
|
// src/assets/BlockEntities.ts
|
|
83773
|
-
var
|
|
83773
|
+
var log13, BlockEntities;
|
|
83774
83774
|
var init_BlockEntities = __esm({
|
|
83775
83775
|
"src/assets/BlockEntities.ts"() {
|
|
83776
83776
|
init_dirname();
|
|
@@ -83783,7 +83783,7 @@ ${key}` : key, async () => {
|
|
|
83783
83783
|
init_source();
|
|
83784
83784
|
init_Caching();
|
|
83785
83785
|
init_log();
|
|
83786
|
-
|
|
83786
|
+
log13 = logger("BlockEntities");
|
|
83787
83787
|
BlockEntities = class {
|
|
83788
83788
|
/**
|
|
83789
83789
|
* Loads the block index of a version. Versions and sources without one yield an empty index, and so does
|
|
@@ -83798,7 +83798,7 @@ ${key}` : key, async () => {
|
|
|
83798
83798
|
key.root = await Entities.getDatasetRoot(root);
|
|
83799
83799
|
return await AssetLoader.get(key, "json" /* JSON */) ?? {};
|
|
83800
83800
|
} catch (error2) {
|
|
83801
|
-
|
|
83801
|
+
log13.warn("Could not load the block entity index; block entities are drawn as plain block models", error2);
|
|
83802
83802
|
return {};
|
|
83803
83803
|
}
|
|
83804
83804
|
});
|
|
@@ -83942,7 +83942,7 @@ ${key}` : key, async () => {
|
|
|
83942
83942
|
}
|
|
83943
83943
|
return { indices, rows, metrics };
|
|
83944
83944
|
} catch (error2) {
|
|
83945
|
-
|
|
83945
|
+
log14.warn(`Could not load Unihex file ${key.toNamespacedString()}`, error2);
|
|
83946
83946
|
return void 0;
|
|
83947
83947
|
}
|
|
83948
83948
|
}
|
|
@@ -83961,7 +83961,7 @@ ${key}` : key, async () => {
|
|
|
83961
83961
|
return { ...override, from, to };
|
|
83962
83962
|
});
|
|
83963
83963
|
} catch (error2) {
|
|
83964
|
-
|
|
83964
|
+
log14.warn(`Could not load Unihex file ${key.toNamespacedString()}`, error2);
|
|
83965
83965
|
return glyphs;
|
|
83966
83966
|
}
|
|
83967
83967
|
const file = await Caching.unihexCache.get(key.serialize(), () => parseUnihex(key));
|
|
@@ -84009,7 +84009,7 @@ ${key}` : key, async () => {
|
|
|
84009
84009
|
}
|
|
84010
84010
|
return glyphs;
|
|
84011
84011
|
}
|
|
84012
|
-
var
|
|
84012
|
+
var log14, ATLAS_SIZE, GLYPH_HEIGHT, UnihexAtlas, atlases;
|
|
84013
84013
|
var init_Unihex = __esm({
|
|
84014
84014
|
"src/assets/_fonts/Unihex.ts"() {
|
|
84015
84015
|
init_dirname();
|
|
@@ -84023,7 +84023,7 @@ ${key}` : key, async () => {
|
|
|
84023
84023
|
init_AssetParsers();
|
|
84024
84024
|
init_CanvasCompat();
|
|
84025
84025
|
init_log();
|
|
84026
|
-
|
|
84026
|
+
log14 = logger("Unihex");
|
|
84027
84027
|
ATLAS_SIZE = 512;
|
|
84028
84028
|
GLYPH_HEIGHT = 16;
|
|
84029
84029
|
UnihexAtlas = class {
|
|
@@ -88252,7 +88252,7 @@ ${key}` : key, async () => {
|
|
|
88252
88252
|
});
|
|
88253
88253
|
|
|
88254
88254
|
// src/skin/Skins.ts
|
|
88255
|
-
var
|
|
88255
|
+
var log15, Skins;
|
|
88256
88256
|
var init_Skins = __esm({
|
|
88257
88257
|
"src/skin/Skins.ts"() {
|
|
88258
88258
|
init_dirname();
|
|
@@ -88261,7 +88261,7 @@ ${key}` : key, async () => {
|
|
|
88261
88261
|
init_Requests();
|
|
88262
88262
|
init_Caching();
|
|
88263
88263
|
init_log();
|
|
88264
|
-
|
|
88264
|
+
log15 = logger("Skins");
|
|
88265
88265
|
Skins = class {
|
|
88266
88266
|
//<editor-fold desc="Skins">
|
|
88267
88267
|
/** Returns a skin URL for {@link MineRenderScene.addSkin}, or `undefined` if name lookup fails. */
|
|
@@ -88333,7 +88333,7 @@ ${key}` : key, async () => {
|
|
|
88333
88333
|
}
|
|
88334
88334
|
return void 0;
|
|
88335
88335
|
}).catch((err2) => {
|
|
88336
|
-
|
|
88336
|
+
log15.warn(err2);
|
|
88337
88337
|
return void 0;
|
|
88338
88338
|
});
|
|
88339
88339
|
}
|
|
@@ -88348,7 +88348,7 @@ ${key}` : key, async () => {
|
|
|
88348
88348
|
}
|
|
88349
88349
|
return void 0;
|
|
88350
88350
|
}).catch((err2) => {
|
|
88351
|
-
|
|
88351
|
+
log15.warn(err2);
|
|
88352
88352
|
return void 0;
|
|
88353
88353
|
});
|
|
88354
88354
|
}
|
|
@@ -88362,7 +88362,7 @@ ${key}` : key, async () => {
|
|
|
88362
88362
|
}
|
|
88363
88363
|
return void 0;
|
|
88364
88364
|
}).catch((err2) => {
|
|
88365
|
-
|
|
88365
|
+
log15.warn(err2);
|
|
88366
88366
|
return void 0;
|
|
88367
88367
|
});
|
|
88368
88368
|
}
|
|
@@ -88386,7 +88386,7 @@ ${key}` : key, async () => {
|
|
|
88386
88386
|
}
|
|
88387
88387
|
return void 0;
|
|
88388
88388
|
}).catch((err2) => {
|
|
88389
|
-
|
|
88389
|
+
log15.warn(err2);
|
|
88390
88390
|
return void 0;
|
|
88391
88391
|
});
|
|
88392
88392
|
}
|
|
@@ -91940,7 +91940,7 @@ ${shader.fragmentShader}`.replace(
|
|
|
91940
91940
|
function isModelObject(obj) {
|
|
91941
91941
|
return obj.isModelObject;
|
|
91942
91942
|
}
|
|
91943
|
-
var
|
|
91943
|
+
var log16, _ModelObject, ModelObject;
|
|
91944
91944
|
var init_ModelObject = __esm({
|
|
91945
91945
|
"src/model/scene/ModelObject.ts"() {
|
|
91946
91946
|
init_dirname();
|
|
@@ -91963,7 +91963,7 @@ ${shader.fragmentShader}`.replace(
|
|
|
91963
91963
|
init_GuiLight();
|
|
91964
91964
|
init_ItemTints();
|
|
91965
91965
|
init_ItemGlint();
|
|
91966
|
-
|
|
91966
|
+
log16 = logger("ModelObject");
|
|
91967
91967
|
_ModelObject = class _ModelObject extends SceneObject {
|
|
91968
91968
|
constructor(originalModel, options) {
|
|
91969
91969
|
super(options);
|
|
@@ -92145,10 +92145,10 @@ ${shader.fragmentShader}`.replace(
|
|
|
92145
92145
|
}
|
|
92146
92146
|
});
|
|
92147
92147
|
} else {
|
|
92148
|
-
|
|
92148
|
+
log16.debug(this.atlas.model, "has no elements");
|
|
92149
92149
|
}
|
|
92150
92150
|
} else {
|
|
92151
|
-
|
|
92151
|
+
log16.debug("Missing atlas for", this);
|
|
92152
92152
|
}
|
|
92153
92153
|
if (this.options.mergeMeshes) {
|
|
92154
92154
|
let combinedGeo;
|
|
@@ -92978,7 +92978,7 @@ ${shader.fragmentShader}`.replace(
|
|
|
92978
92978
|
function isBlockObject(obj) {
|
|
92979
92979
|
return obj.isBlockObject;
|
|
92980
92980
|
}
|
|
92981
|
-
var
|
|
92981
|
+
var log19, _BlockObject, BlockObject;
|
|
92982
92982
|
var init_BlockObject = __esm({
|
|
92983
92983
|
"src/model/block/scene/BlockObject.ts"() {
|
|
92984
92984
|
init_dirname();
|
|
@@ -93001,7 +93001,7 @@ ${shader.fragmentShader}`.replace(
|
|
|
93001
93001
|
init_Entities();
|
|
93002
93002
|
init_Biomes();
|
|
93003
93003
|
init_log();
|
|
93004
|
-
|
|
93004
|
+
log19 = logger("BlockObject");
|
|
93005
93005
|
_BlockObject = class _BlockObject extends SceneObject {
|
|
93006
93006
|
constructor(blockState3, options) {
|
|
93007
93007
|
super(options);
|
|
@@ -93106,7 +93106,7 @@ ${shader.fragmentShader}`.replace(
|
|
|
93106
93106
|
created.push(await this.scene.addEntity(entity, { wireframe: this.options.wireframe }));
|
|
93107
93107
|
}
|
|
93108
93108
|
} catch (error2) {
|
|
93109
|
-
|
|
93109
|
+
log19.warn(`Could not draw block entity ${key.toNamespacedString()}, using its block model`, error2);
|
|
93110
93110
|
this.removeEntities(created);
|
|
93111
93111
|
return false;
|
|
93112
93112
|
}
|
|
@@ -94486,6 +94486,7 @@ ${shader.fragmentShader}`.replace(
|
|
|
94486
94486
|
init_buffer2();
|
|
94487
94487
|
init_process2();
|
|
94488
94488
|
init_Env();
|
|
94489
|
+
init_log();
|
|
94489
94490
|
|
|
94490
94491
|
// src/env/browser/BrowserCache.ts
|
|
94491
94492
|
init_dirname();
|
|
@@ -94592,6 +94593,7 @@ ${shader.fragmentShader}`.replace(
|
|
|
94592
94593
|
|
|
94593
94594
|
// src/env/browser/BrowserEnv.ts
|
|
94594
94595
|
var import_meta = {};
|
|
94596
|
+
var log2 = logger("BrowserEnv");
|
|
94595
94597
|
function lazyLocalForage(options) {
|
|
94596
94598
|
let instance;
|
|
94597
94599
|
const store = () => instance ?? (instance = Promise.resolve().then(() => __toESM(require_localforage())).then((module2) => module2.default.createInstance(options)));
|
|
@@ -94607,7 +94609,8 @@ ${shader.fragmentShader}`.replace(
|
|
|
94607
94609
|
};
|
|
94608
94610
|
}
|
|
94609
94611
|
var BrowserEnv = class {
|
|
94610
|
-
constructor() {
|
|
94612
|
+
constructor(options = {}) {
|
|
94613
|
+
this.options = options;
|
|
94611
94614
|
this.name = "browser";
|
|
94612
94615
|
}
|
|
94613
94616
|
createCanvas(width, height) {
|
|
@@ -94636,14 +94639,18 @@ ${shader.fragmentShader}`.replace(
|
|
|
94636
94639
|
createWorker(name2) {
|
|
94637
94640
|
if (name2 !== "section" || typeof Worker === "undefined") return void 0;
|
|
94638
94641
|
try {
|
|
94642
|
+
const sectionWorker = this.options.sectionWorker;
|
|
94643
|
+
if (typeof sectionWorker === "function") return sectionWorker();
|
|
94644
|
+
if (sectionWorker !== void 0) return new Worker(sectionWorker, { type: "module" });
|
|
94639
94645
|
return new Worker(new URL("./section.worker.mjs", import_meta.url), { type: "module" });
|
|
94640
|
-
} catch {
|
|
94646
|
+
} catch (error2) {
|
|
94647
|
+
log2.warn("Could not start the section worker, so sections build on the main thread. Pass sectionWorker to registerBrowserEnv to load it from another URL.", error2);
|
|
94641
94648
|
return void 0;
|
|
94642
94649
|
}
|
|
94643
94650
|
}
|
|
94644
94651
|
};
|
|
94645
|
-
function registerBrowserEnv() {
|
|
94646
|
-
const env3 = new BrowserEnv();
|
|
94652
|
+
function registerBrowserEnv(options) {
|
|
94653
|
+
const env3 = new BrowserEnv(options);
|
|
94647
94654
|
Env.register(env3);
|
|
94648
94655
|
return env3;
|
|
94649
94656
|
}
|
|
@@ -96138,7 +96145,7 @@ property list uchar int vertex_index
|
|
|
96138
96145
|
init_util();
|
|
96139
96146
|
init_log();
|
|
96140
96147
|
init_three();
|
|
96141
|
-
var
|
|
96148
|
+
var log17 = logger("SceneInspector");
|
|
96142
96149
|
var help = "<span>Ctrl/Cmd+Click to Select<br/></span><br/>";
|
|
96143
96150
|
var SceneInspector = class {
|
|
96144
96151
|
constructor(renderer) {
|
|
@@ -96232,7 +96239,7 @@ property list uchar int vertex_index
|
|
|
96232
96239
|
}
|
|
96233
96240
|
selectObject(targetObject, targetIntersection, instance = this.getIntersectionInstance(targetIntersection)) {
|
|
96234
96241
|
this.selectedObject = targetObject;
|
|
96235
|
-
|
|
96242
|
+
log17.debug("selected", targetObject);
|
|
96236
96243
|
this.redraw(targetObject, targetIntersection, instance);
|
|
96237
96244
|
}
|
|
96238
96245
|
redraw(targetObject, targetIntersection, instance) {
|
|
@@ -96503,7 +96510,7 @@ property list uchar int vertex_index
|
|
|
96503
96510
|
init_buffer2();
|
|
96504
96511
|
init_process2();
|
|
96505
96512
|
init_log();
|
|
96506
|
-
var
|
|
96513
|
+
var log18 = logger("InstanceManager");
|
|
96507
96514
|
var InstanceManager = class {
|
|
96508
96515
|
constructor() {
|
|
96509
96516
|
this.isInstanceManager = true;
|
|
@@ -96512,7 +96519,7 @@ property list uchar int vertex_index
|
|
|
96512
96519
|
/** Allocates a new placement of a cached model, or returns `undefined` if the key is unknown. */
|
|
96513
96520
|
async get(key) {
|
|
96514
96521
|
if (key in this.instanceCache) {
|
|
96515
|
-
|
|
96522
|
+
log18.debug("key in cache", key);
|
|
96516
96523
|
return (await this.instanceCache[key]).nextInstance();
|
|
96517
96524
|
}
|
|
96518
96525
|
return void 0;
|
|
@@ -96522,7 +96529,7 @@ property list uchar int vertex_index
|
|
|
96522
96529
|
if (key in this.instanceCache) {
|
|
96523
96530
|
return await this.get(key);
|
|
96524
96531
|
}
|
|
96525
|
-
|
|
96532
|
+
log18.debug("key not in cache", key);
|
|
96526
96533
|
const pending = Promise.resolve().then(supplier).then((obj) => obj.nextInstance());
|
|
96527
96534
|
this.instanceCache[key] = pending;
|
|
96528
96535
|
try {
|
|
@@ -101213,7 +101220,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
101213
101220
|
|
|
101214
101221
|
// src/renderer/Renderer.ts
|
|
101215
101222
|
init_log();
|
|
101216
|
-
var
|
|
101223
|
+
var log20 = logger("Renderer");
|
|
101217
101224
|
var _Renderer = class _Renderer {
|
|
101218
101225
|
constructor(options, surface) {
|
|
101219
101226
|
this._width = 0;
|
|
@@ -101458,10 +101465,10 @@ gl_FragDepth=readDepth(vUv);
|
|
|
101458
101465
|
this._element = element;
|
|
101459
101466
|
this._element.appendChild(this.renderer.domElement);
|
|
101460
101467
|
if (this.viewWidth == 0) {
|
|
101461
|
-
|
|
101468
|
+
log20.warn("0 element width");
|
|
101462
101469
|
}
|
|
101463
101470
|
if (this.viewHeight == 0) {
|
|
101464
|
-
|
|
101471
|
+
log20.warn("0 element height");
|
|
101465
101472
|
}
|
|
101466
101473
|
this.resize(this.viewWidth, this.viewHeight);
|
|
101467
101474
|
}
|
|
@@ -103237,6 +103244,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
103237
103244
|
init_dirname();
|
|
103238
103245
|
init_buffer2();
|
|
103239
103246
|
init_process2();
|
|
103247
|
+
init_BlockObject();
|
|
103240
103248
|
init_three_module();
|
|
103241
103249
|
init_BlockStates();
|
|
103242
103250
|
init_AssetKey();
|
|
@@ -103250,6 +103258,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
103250
103258
|
init_util();
|
|
103251
103259
|
init_AssetKey();
|
|
103252
103260
|
init_BlockStates();
|
|
103261
|
+
init_BlockEntities();
|
|
103253
103262
|
init_CubeFace();
|
|
103254
103263
|
|
|
103255
103264
|
// src/world/SectionModels.ts
|
|
@@ -103350,6 +103359,10 @@ gl_FragDepth=readDepth(vUv);
|
|
|
103350
103359
|
biomeTint: source ? [...templates.values()].some((template) => template.biomeTint?.some((value) => value === 1)) || void 0 : void 0
|
|
103351
103360
|
};
|
|
103352
103361
|
}
|
|
103362
|
+
/** Starts loading the state's models and atlases so a later `prepareState` with the same properties finds them loaded. */
|
|
103363
|
+
async preload(blockState3, properties = {}) {
|
|
103364
|
+
await this.state(blockState3, properties);
|
|
103365
|
+
}
|
|
103353
103366
|
async state(blockState3, properties) {
|
|
103354
103367
|
let states = this.states.get(blockState3);
|
|
103355
103368
|
if (!states) this.states.set(blockState3, states = /* @__PURE__ */ new Map());
|
|
@@ -103372,22 +103385,24 @@ gl_FragDepth=readDepth(vUv);
|
|
|
103372
103385
|
async prepare(blockState3, properties) {
|
|
103373
103386
|
const state = { ...await BlockStateResolver.defaults(blockState3), ...properties };
|
|
103374
103387
|
const groups = BlockStateResolver.matching(blockState3, state);
|
|
103375
|
-
if (!groups.length) return void 0;
|
|
103388
|
+
if (!groups.length || groups.some((group) => Array.isArray(group) && !group.length)) return void 0;
|
|
103389
|
+
const variants = groups.flatMap((group) => Array.isArray(group) ? group : [group]);
|
|
103390
|
+
if (variants.some((variant) => !variant.model)) return void 0;
|
|
103391
|
+
const settled = await Promise.allSettled(variants.map(async (variant) => {
|
|
103392
|
+
const modelKey = AssetKey.parse("models", variant.model);
|
|
103393
|
+
modelKey.root = blockState3.key?.root;
|
|
103394
|
+
const model = await Models.getMerged(modelKey);
|
|
103395
|
+
if (!model?.elements?.length) return void 0;
|
|
103396
|
+
const atlas = await UVMapper.getAtlas(model);
|
|
103397
|
+
const rotation = BlockStateResolver.rotation(variant);
|
|
103398
|
+
if (!atlas || atlas.image.width > this.maxAtlasSize || atlas.image.height > this.maxAtlasSize) return void 0;
|
|
103399
|
+
return { model, atlas, rotation };
|
|
103400
|
+
}));
|
|
103376
103401
|
const prepared = /* @__PURE__ */ new Map();
|
|
103377
|
-
for (const
|
|
103378
|
-
|
|
103379
|
-
if (!
|
|
103380
|
-
|
|
103381
|
-
if (!variant.model) return void 0;
|
|
103382
|
-
const modelKey = AssetKey.parse("models", variant.model);
|
|
103383
|
-
modelKey.root = blockState3.key?.root;
|
|
103384
|
-
const model = await Models.getMerged(modelKey);
|
|
103385
|
-
if (!model?.elements?.length) return void 0;
|
|
103386
|
-
const atlas = await UVMapper.getAtlas(model);
|
|
103387
|
-
const rotation = BlockStateResolver.rotation(variant);
|
|
103388
|
-
if (!atlas || atlas.image.width > this.maxAtlasSize || atlas.image.height > this.maxAtlasSize) return void 0;
|
|
103389
|
-
prepared.set(variant, { model, atlas, rotation });
|
|
103390
|
-
}
|
|
103402
|
+
for (const [i4, result] of settled.entries()) {
|
|
103403
|
+
if (result.status === "rejected") throw result.reason;
|
|
103404
|
+
if (!result.value) return void 0;
|
|
103405
|
+
prepared.set(variants[i4], result.value);
|
|
103391
103406
|
}
|
|
103392
103407
|
return { state, groups, choices: prepared };
|
|
103393
103408
|
}
|
|
@@ -103573,7 +103588,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
103573
103588
|
|
|
103574
103589
|
// src/world/_entities/WorldEntities.ts
|
|
103575
103590
|
init_log();
|
|
103576
|
-
var
|
|
103591
|
+
var log21 = logger("WorldEntities");
|
|
103577
103592
|
var WorldEntities = class {
|
|
103578
103593
|
constructor(scene) {
|
|
103579
103594
|
this.scene = scene;
|
|
@@ -103642,7 +103657,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
103642
103657
|
placement.owner.set(object4, { type: key.toNamespacedString(), position: placement.position });
|
|
103643
103658
|
this.scene.add(object4);
|
|
103644
103659
|
} catch (error2) {
|
|
103645
|
-
|
|
103660
|
+
log21.warn(`Could not draw saved entity ${placement.key.toNamespacedString()}, skipping it`, error2);
|
|
103646
103661
|
} finally {
|
|
103647
103662
|
if (object4 && !placement.owner.has(object4)) object4.dispose();
|
|
103648
103663
|
}
|
|
@@ -103864,7 +103879,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
103864
103879
|
|
|
103865
103880
|
// src/world/MineRenderWorld.ts
|
|
103866
103881
|
init_log();
|
|
103867
|
-
var
|
|
103882
|
+
var log22 = logger("MineRenderWorld");
|
|
103868
103883
|
var YIELD_INTERVAL_MS = 8;
|
|
103869
103884
|
var MineRenderWorld = class {
|
|
103870
103885
|
constructor(scene, options = {}) {
|
|
@@ -104080,15 +104095,18 @@ gl_FragDepth=readDepth(vUv);
|
|
|
104080
104095
|
const key = AssetKey.parse("blockstates", block.type);
|
|
104081
104096
|
keys.set(key.serialize(), key);
|
|
104082
104097
|
}
|
|
104083
|
-
await BlockStates.getAll(keys.values());
|
|
104098
|
+
const loaded = await BlockStates.getAll(keys.values());
|
|
104099
|
+
const states = new Map([...keys.keys()].map((key, i4) => [key, loaded[i4]]));
|
|
104084
104100
|
if (!useBatches) {
|
|
104085
104101
|
for (const block of multiblock.blocks) await place(block);
|
|
104086
104102
|
return;
|
|
104087
104103
|
}
|
|
104088
104104
|
if (!executor) {
|
|
104089
104105
|
const groups2 = /* @__PURE__ */ new Map();
|
|
104106
|
+
const distinct = /* @__PURE__ */ new Map();
|
|
104090
104107
|
const position = new Vector3();
|
|
104091
104108
|
for (const block of multiblock.blocks) {
|
|
104109
|
+
if (this.sectionModels && !Chunk.isAir(block)) distinct.set(ChunkData.paletteKey(block), block);
|
|
104092
104110
|
const [x4, y5, z4] = block.position;
|
|
104093
104111
|
this.validatePosBounds(position.set(x4, y5, z4));
|
|
104094
104112
|
const cx = Math.floor(x4 / 16), cy = Math.floor(y5 / 16), cz = Math.floor(z4 / 16);
|
|
@@ -104099,6 +104117,16 @@ gl_FragDepth=readDepth(vUv);
|
|
|
104099
104117
|
if (!group) groups2.set(chunk, group = []);
|
|
104100
104118
|
group.push({ index: (y5 - cy * 16) * 256 + (z4 - cz * 16) * 16 + x4 - cx * 16, block });
|
|
104101
104119
|
}
|
|
104120
|
+
if (this.sectionModels) {
|
|
104121
|
+
for (const block of distinct.values()) {
|
|
104122
|
+
const state = states.get(AssetKey.parse("blockstates", block.type).serialize());
|
|
104123
|
+
if (!state) continue;
|
|
104124
|
+
void (async () => {
|
|
104125
|
+
if (state.key && BlockEntities.entry(await BlockEntities.getIndex(state.key.root), state.key.toNamespacedString())) return;
|
|
104126
|
+
await this.sectionModels.preload(state, block.properties);
|
|
104127
|
+
})().catch(() => void 0);
|
|
104128
|
+
}
|
|
104129
|
+
}
|
|
104102
104130
|
await this.placeChunkGroups(groups2, changes);
|
|
104103
104131
|
return;
|
|
104104
104132
|
}
|
|
@@ -104179,7 +104207,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
104179
104207
|
} finally {
|
|
104180
104208
|
try {
|
|
104181
104209
|
const failures = await this.refreshBiomes(true);
|
|
104182
|
-
if (failures.size)
|
|
104210
|
+
if (failures.size) log22.warn("Failed to refresh biome colors", failures.values().next().value);
|
|
104183
104211
|
} catch (error2) {
|
|
104184
104212
|
if (!failed) {
|
|
104185
104213
|
failed = true;
|
|
@@ -104285,7 +104313,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
104285
104313
|
if (deferCulling) await this.updateCulling([...changes.values()], true);
|
|
104286
104314
|
else {
|
|
104287
104315
|
const failures = await this.refreshBiomes();
|
|
104288
|
-
if (failures.size)
|
|
104316
|
+
if (failures.size) log22.warn("Failed to refresh biome colors", failures.values().next().value);
|
|
104289
104317
|
await this.updateCulling([...changes.values()]);
|
|
104290
104318
|
}
|
|
104291
104319
|
}
|
|
@@ -104324,7 +104352,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
104324
104352
|
}
|
|
104325
104353
|
} finally {
|
|
104326
104354
|
const failures = await this.refreshBiomes(true);
|
|
104327
|
-
if (failures.size)
|
|
104355
|
+
if (failures.size) log22.warn("Failed to refresh biome colors", failures.values().next().value);
|
|
104328
104356
|
await this.updateCulling([]);
|
|
104329
104357
|
}
|
|
104330
104358
|
}
|
|
@@ -104881,6 +104909,8 @@ gl_FragDepth=readDepth(vUv);
|
|
|
104881
104909
|
init_buffer2();
|
|
104882
104910
|
init_process2();
|
|
104883
104911
|
init_Env();
|
|
104912
|
+
init_log();
|
|
104913
|
+
var log23 = logger("SectionWorker");
|
|
104884
104914
|
var _SectionWorker = class _SectionWorker {
|
|
104885
104915
|
constructor(worker) {
|
|
104886
104916
|
this.worker = worker;
|
|
@@ -104894,8 +104924,12 @@ gl_FragDepth=readDepth(vUv);
|
|
|
104894
104924
|
if (reply.type === "pages") pending.resolve(reply.pages);
|
|
104895
104925
|
else pending.reject(new Error(reply.message));
|
|
104896
104926
|
});
|
|
104897
|
-
|
|
104898
|
-
|
|
104927
|
+
const fallBack = (message) => {
|
|
104928
|
+
log23.warn(`${message}, so sections build on the main thread`);
|
|
104929
|
+
this.fail(message);
|
|
104930
|
+
};
|
|
104931
|
+
worker.addEventListener("error", (event) => fallBack(event.message || "Section worker failed"));
|
|
104932
|
+
worker.addEventListener("messageerror", () => fallBack("Section worker message could not be deserialized"));
|
|
104899
104933
|
}
|
|
104900
104934
|
/** The shared worker, or undefined when the environment has none or a previous worker failed. */
|
|
104901
104935
|
static shared() {
|
|
@@ -105440,8 +105474,10 @@ gl_FragDepth=readDepth(vUv);
|
|
|
105440
105474
|
if (rejected?.status === "rejected") throw rejected.reason;
|
|
105441
105475
|
}
|
|
105442
105476
|
const positions = [];
|
|
105443
|
-
|
|
105444
|
-
|
|
105477
|
+
const jobs = /* @__PURE__ */ new Map();
|
|
105478
|
+
let failureOrder = Infinity, failure;
|
|
105479
|
+
for (const [order, { index, key, block }] of placements.entries()) {
|
|
105480
|
+
jobs.delete(index);
|
|
105445
105481
|
this.hiddenBlocks.delete(index);
|
|
105446
105482
|
this.data.assign(index, this.data.intern(block), block?.nbt);
|
|
105447
105483
|
const readBlock = this.data.snapshot(index);
|
|
@@ -105457,7 +105493,6 @@ gl_FragDepth=readDepth(vUv);
|
|
|
105457
105493
|
this.z * 16 + Math.floor(index / 16) % 16
|
|
105458
105494
|
);
|
|
105459
105495
|
positions.push(worldPos);
|
|
105460
|
-
let object4;
|
|
105461
105496
|
try {
|
|
105462
105497
|
if (!readBlock) continue;
|
|
105463
105498
|
const resolved = resolutions.get(key);
|
|
@@ -105479,7 +105514,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
105479
105514
|
this.sectionBlocks.set(index, templates.map((template) => ({ index, template, cullMask: 0, biomeTint: context?.tint })));
|
|
105480
105515
|
this.meshDirty = true;
|
|
105481
105516
|
} else {
|
|
105482
|
-
|
|
105517
|
+
jobs.set(index, { order, readBlock, blockState: blockState3, position: MineRenderWorld.worldToScenePosition(worldPos), options: {
|
|
105483
105518
|
mergeMeshes: true,
|
|
105484
105519
|
instanceMeshes: true,
|
|
105485
105520
|
maxInstanceCount: 2e3,
|
|
@@ -105487,13 +105522,12 @@ gl_FragDepth=readDepth(vUv);
|
|
|
105487
105522
|
variantPosition,
|
|
105488
105523
|
biome: context?.biome,
|
|
105489
105524
|
biomePosition: this.biomePosition(index, blockState3, stored)
|
|
105490
|
-
});
|
|
105491
|
-
|
|
105525
|
+
} });
|
|
105526
|
+
continue;
|
|
105492
105527
|
}
|
|
105493
105528
|
this.renderedBlocks.set(index, { get block() {
|
|
105494
105529
|
return readBlock();
|
|
105495
|
-
}, object:
|
|
105496
|
-
if (object4) this.objectBlocks.add(index);
|
|
105530
|
+
}, object: void 0 });
|
|
105497
105531
|
} catch (error2) {
|
|
105498
105532
|
if (preserveDataOnFailure && readBlock) {
|
|
105499
105533
|
this.renderedBlocks.set(index, { get block() {
|
|
@@ -105501,12 +105535,35 @@ gl_FragDepth=readDepth(vUv);
|
|
|
105501
105535
|
}, object: void 0 });
|
|
105502
105536
|
} else this.data.assign(index, 0);
|
|
105503
105537
|
this.fluidCells[index] = 0;
|
|
105504
|
-
|
|
105505
|
-
|
|
105506
|
-
|
|
105538
|
+
if (order < failureOrder) {
|
|
105539
|
+
failureOrder = order;
|
|
105540
|
+
failure = error2;
|
|
105541
|
+
}
|
|
105507
105542
|
}
|
|
105508
105543
|
}
|
|
105509
|
-
|
|
105544
|
+
const pending = [...jobs];
|
|
105545
|
+
const objects = await Promise.allSettled(pending.map(([, job]) => this.createBlockObject(job.blockState, job.position, job.options)));
|
|
105546
|
+
for (const [i4, [index, { order, readBlock }]] of pending.entries()) {
|
|
105547
|
+
const result = objects[i4];
|
|
105548
|
+
if (result.status === "fulfilled") {
|
|
105549
|
+
this.renderedBlocks.set(index, { get block() {
|
|
105550
|
+
return readBlock();
|
|
105551
|
+
}, object: result.value });
|
|
105552
|
+
this.objectBlocks.add(index);
|
|
105553
|
+
} else {
|
|
105554
|
+
if (preserveDataOnFailure) {
|
|
105555
|
+
this.renderedBlocks.set(index, { get block() {
|
|
105556
|
+
return readBlock();
|
|
105557
|
+
}, object: void 0 });
|
|
105558
|
+
} else this.data.assign(index, 0);
|
|
105559
|
+
this.fluidCells[index] = 0;
|
|
105560
|
+
if (order < failureOrder) {
|
|
105561
|
+
failureOrder = order;
|
|
105562
|
+
failure = result.reason;
|
|
105563
|
+
}
|
|
105564
|
+
}
|
|
105565
|
+
}
|
|
105566
|
+
if (failureOrder < Infinity) throw failure;
|
|
105510
105567
|
return positions;
|
|
105511
105568
|
}
|
|
105512
105569
|
/** Replaces every cell from parsed section data. The caller refreshes neighbor culling. */
|
|
@@ -105577,37 +105634,42 @@ gl_FragDepth=readDepth(vUv);
|
|
|
105577
105634
|
failed = true;
|
|
105578
105635
|
}
|
|
105579
105636
|
}
|
|
105580
|
-
|
|
105581
|
-
|
|
105582
|
-
|
|
105583
|
-
|
|
105584
|
-
|
|
105585
|
-
|
|
105586
|
-
|
|
105587
|
-
|
|
105588
|
-
|
|
105589
|
-
|
|
105590
|
-
|
|
105591
|
-
|
|
105592
|
-
|
|
105593
|
-
|
|
105594
|
-
|
|
105595
|
-
|
|
105596
|
-
)
|
|
105597
|
-
this.renderedBlocks.get(index).object = object4;
|
|
105637
|
+
const objects = await Promise.allSettled(perBlocks.map(({ index, blockState: blockState3, biome }) => this.createBlockObject(blockState3, new Vector3(
|
|
105638
|
+
this.x * 256 + index % 16 * 16,
|
|
105639
|
+
this.y * 256 + Math.floor(index / 256) * 16,
|
|
105640
|
+
this.z * 256 + Math.floor(index / 16) % 16 * 16
|
|
105641
|
+
), {
|
|
105642
|
+
mergeMeshes: true,
|
|
105643
|
+
instanceMeshes: true,
|
|
105644
|
+
maxInstanceCount: 2e3,
|
|
105645
|
+
initialState: this.data.stateAt(this.data.idAt(index)).properties,
|
|
105646
|
+
variantPosition: this.positionAt(index),
|
|
105647
|
+
biome,
|
|
105648
|
+
biomePosition: this.biomePosition(index, blockState3, this.data.stateAt(this.data.idAt(index)))
|
|
105649
|
+
})));
|
|
105650
|
+
for (const [i4, { index }] of perBlocks.entries()) {
|
|
105651
|
+
const result = objects[i4];
|
|
105652
|
+
if (result.status === "fulfilled") {
|
|
105653
|
+
this.renderedBlocks.get(index).object = result.value;
|
|
105598
105654
|
this.objectBlocks.add(index);
|
|
105599
|
-
}
|
|
105655
|
+
} else {
|
|
105600
105656
|
this.data.assign(index, 0);
|
|
105601
105657
|
this.fluidCells[index] = 0;
|
|
105602
105658
|
this.renderedBlocks.delete(index);
|
|
105603
105659
|
this.objectBlocks.delete(index);
|
|
105604
|
-
|
|
105605
|
-
if (!failed) failure = error2;
|
|
105660
|
+
if (!failed) failure = result.reason;
|
|
105606
105661
|
failed = true;
|
|
105607
105662
|
}
|
|
105608
105663
|
}
|
|
105609
105664
|
if (failed) throw failure;
|
|
105610
105665
|
}
|
|
105666
|
+
createBlockObject(blockState3, position, options) {
|
|
105667
|
+
return this.scene.addSceneObject(blockState3, () => {
|
|
105668
|
+
const object4 = new BlockObject(blockState3, options);
|
|
105669
|
+
object4.position.copy(position);
|
|
105670
|
+
return object4;
|
|
105671
|
+
}, options);
|
|
105672
|
+
}
|
|
105611
105673
|
positionAt(index) {
|
|
105612
105674
|
return [this.x * 16 + index % 16, this.y * 16 + Math.floor(index / 256), this.z * 16 + Math.floor(index / 16) % 16];
|
|
105613
105675
|
}
|