minerender 2.1.0-alpha.116 → 2.1.0-alpha.118
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/dist/browser/index.d.mts +14 -5
- package/dist/browser/index.d.ts +14 -5
- package/dist/browser/index.js +50 -69
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +50 -69
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +50 -69
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +14 -5
- package/dist/node/index.d.ts +14 -5
- package/dist/node/index.js +50 -69
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +50 -69
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -1606,7 +1606,8 @@ var init_MineRenderData = __esm({
|
|
|
1606
1606
|
}
|
|
1607
1607
|
/**
|
|
1608
1608
|
* Uses the exact version when published. Otherwise, selects the nearest patch in the same
|
|
1609
|
-
* release line (older on ties), then the latest earlier release
|
|
1609
|
+
* release line (older on ties), then the latest earlier release or the oldest published release.
|
|
1610
|
+
* Unpublished snapshots reject.
|
|
1610
1611
|
*/
|
|
1611
1612
|
static async resolve(root) {
|
|
1612
1613
|
const requestRoot = root?.replace(/\/+$/, "");
|
|
@@ -1615,11 +1616,11 @@ var init_MineRenderData = __esm({
|
|
|
1615
1616
|
const scope = AssetLoader.persistentScope;
|
|
1616
1617
|
return this.cached(`resolve:${requestRoot === void 0 ? "sources" : "explicit"}:${root}`, scope, defaultRoot, async () => {
|
|
1617
1618
|
const requestedVersion = root.slice(root.lastIndexOf("/") + 1);
|
|
1618
|
-
let manifest = await this.manifest(root, release(requestedVersion) ? requestedVersion : void 0, requestRoot);
|
|
1619
|
+
let manifest = await this.manifest(root, requestRoot !== void 0 && release(requestedVersion) ? requestedVersion : void 0, requestRoot);
|
|
1619
1620
|
if (manifest) return { requestedVersion, version: manifest.minecraftVersion, root, manifest };
|
|
1620
1621
|
const requested = release(requestedVersion);
|
|
1621
|
-
if (!requested
|
|
1622
|
-
throw new Error(`No MineRender data is published for ${requestedVersion}; automatic fallback requires a release
|
|
1622
|
+
if (!requested) {
|
|
1623
|
+
throw new Error(`No MineRender data is published for ${requestedVersion}; automatic fallback requires a release`);
|
|
1623
1624
|
}
|
|
1624
1625
|
const base = root.slice(0, root.lastIndexOf("/"));
|
|
1625
1626
|
const index = await this.cached(`versions:${base}`, scope, defaultRoot, async () => {
|
|
@@ -1629,9 +1630,9 @@ var init_MineRenderData = __esm({
|
|
|
1629
1630
|
}
|
|
1630
1631
|
return value.versions;
|
|
1631
1632
|
});
|
|
1632
|
-
const versions = index.map((entry) => ({ name: entry.name, number: release(entry.name) })).filter((entry) => !!entry.number
|
|
1633
|
+
const versions = index.map((entry) => ({ name: entry.name, number: release(entry.name) })).filter((entry) => !!entry.number).sort((left, right) => compare(left.number, right.number));
|
|
1633
1634
|
const sameLine = versions.filter((entry) => entry.number[0] === requested[0] && entry.number[1] === requested[1]);
|
|
1634
|
-
const selected = sameLine.sort((left, right) => Math.abs((left.number[2] ?? 0) - (requested[2] ?? 0)) - Math.abs((right.number[2] ?? 0) - (requested[2] ?? 0)) || compare(left.number, right.number))[0] ?? versions.filter((entry) => compare(entry.number, requested) <= 0).pop();
|
|
1635
|
+
const selected = sameLine.sort((left, right) => Math.abs((left.number[2] ?? 0) - (requested[2] ?? 0)) - Math.abs((right.number[2] ?? 0) - (requested[2] ?? 0)) || compare(left.number, right.number))[0] ?? versions.filter((entry) => compare(entry.number, requested) <= 0).pop() ?? versions[0];
|
|
1635
1636
|
if (!selected) throw new Error(`No compatible MineRender data is published for ${requestedVersion}`);
|
|
1636
1637
|
const resolvedRoot = `${base}/${selected.name}`;
|
|
1637
1638
|
manifest = await this.manifest(resolvedRoot, selected.name, resolvedRoot);
|
|
@@ -1747,12 +1748,7 @@ var init_BannerPatterns = __esm({
|
|
|
1747
1748
|
static async getLayers(value, target, root) {
|
|
1748
1749
|
if (value === void 0) return [];
|
|
1749
1750
|
if (!Array.isArray(value)) throw new Error("banner_patterns must be an array");
|
|
1750
|
-
const activeRoot = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
1751
|
-
const checkSources = () => {
|
|
1752
|
-
if (activeRoot !== AssetLoader.ROOT || scope !== AssetLoader.persistentScope) throw new Error("Asset sources changed while loading banner patterns; retry the request");
|
|
1753
|
-
};
|
|
1754
1751
|
const colors = value.length ? await this.getColors(root) : void 0;
|
|
1755
|
-
checkSources();
|
|
1756
1752
|
return Promise.all(value.slice(0, 16).map(async (layer) => {
|
|
1757
1753
|
if (!layer || typeof layer !== "object" || Array.isArray(layer)) throw new Error("Each banner pattern requires a pattern and dye color");
|
|
1758
1754
|
if (typeof layer.color !== "string" || !Object.prototype.hasOwnProperty.call(colors, layer.color)) throw new Error(`Unsupported dye color ${layer.color}`);
|
|
@@ -1762,7 +1758,6 @@ var init_BannerPatterns = __esm({
|
|
|
1762
1758
|
const id = this.identifier(pattern2);
|
|
1763
1759
|
const key = new AssetKey(id.namespace, id.getFullPath(), "banner_pattern", void 0, "data", ".json", root);
|
|
1764
1760
|
pattern2 = await Caching.bannerPatternCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
|
|
1765
|
-
checkSources();
|
|
1766
1761
|
if (!pattern2) throw new Error(`Missing banner pattern ${layer.pattern}`);
|
|
1767
1762
|
}
|
|
1768
1763
|
if (!pattern2 || typeof pattern2 !== "object" || Array.isArray(pattern2) || typeof pattern2.translation_key !== "string") throw new Error("Banner patterns require asset_id and translation_key");
|
|
@@ -2047,30 +2042,24 @@ var init_Models = __esm({
|
|
|
2047
2042
|
}).then((r) => r?.files ?? []);
|
|
2048
2043
|
}
|
|
2049
2044
|
static async loadAndMerge(key, context = {}) {
|
|
2050
|
-
const checkSources = this.sourceCheck();
|
|
2051
2045
|
const model = key.type === "item" ? await this.getItemModel(key, context) : await this.getRaw(key);
|
|
2052
2046
|
if (!model) {
|
|
2053
2047
|
return void 0;
|
|
2054
2048
|
}
|
|
2055
2049
|
const merged = await ModelMerger.mergeWithParents(model);
|
|
2056
|
-
checkSources();
|
|
2057
2050
|
return merged;
|
|
2058
2051
|
}
|
|
2059
2052
|
static async getItemModel(key, context = {}) {
|
|
2060
|
-
const checkSources = this.sourceCheck();
|
|
2061
2053
|
const preview = this.snapshotContext(key, context);
|
|
2062
2054
|
const dataKey = await this.applyDefaults(key, preview);
|
|
2063
|
-
checkSources();
|
|
2064
2055
|
return this.getPreparedItemModel(key, preview, dataKey);
|
|
2065
2056
|
}
|
|
2066
2057
|
static async getPreparedItemModel(key, preview, dataKey) {
|
|
2067
|
-
const checkSources = this.sourceCheck();
|
|
2068
2058
|
const itemId = `${key.namespace}:${key.path}`;
|
|
2069
2059
|
const itemKey2 = new AssetKey(key.namespace, key.path, "items", void 0, key.rootType, ".json", key.root);
|
|
2070
2060
|
const cacheKey = itemKey2.serialize() + this.contextKey(preview) + dataKey;
|
|
2071
2061
|
const model = await this.PERSISTENT_CACHE.getOrLoad(`${this.ITEM_CACHE_VERSION}:${AssetLoader.persistentKey(cacheKey)}`, async () => {
|
|
2072
2062
|
const result = await AssetLoader.getFirst([itemKey2, key], "json" /* JSON */);
|
|
2073
|
-
checkSources();
|
|
2074
2063
|
if (!result) return void 0;
|
|
2075
2064
|
if (result.key.assetType !== "items") return { ...result.asset, key, itemId, components: preview.components };
|
|
2076
2065
|
const load = async (selected) => {
|
|
@@ -2089,10 +2078,8 @@ var init_Models = __esm({
|
|
|
2089
2078
|
return { ...model3, itemId, components: preview.components, ...selected.special && { special: selected.special }, ...selected.tints && { tints: selected.tints } };
|
|
2090
2079
|
};
|
|
2091
2080
|
const model2 = await load(this.selectItemModel(result.asset.model, key, preview));
|
|
2092
|
-
checkSources();
|
|
2093
2081
|
return model2;
|
|
2094
2082
|
});
|
|
2095
|
-
checkSources();
|
|
2096
2083
|
const restore = (model2) => ({
|
|
2097
2084
|
...model2,
|
|
2098
2085
|
key: Object.assign(new AssetKey("", ""), model2.key),
|
|
@@ -2156,22 +2143,14 @@ var init_Models = __esm({
|
|
|
2156
2143
|
}
|
|
2157
2144
|
static async applyDefaults(key, preview) {
|
|
2158
2145
|
if (key.type !== "item") return "";
|
|
2159
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
2160
2146
|
const resolved = await MineRenderData.resolve(key.root);
|
|
2161
2147
|
const defaults = await ItemDefaults.get(`${key.namespace}:${key.path}`, key.root);
|
|
2162
2148
|
preview.components = { ...defaults, ...preview.components };
|
|
2163
2149
|
if (resolved.manifest.dataVersion < 3337 && key.namespace === DEFAULT_NAMESPACE && ["potion", "splash_potion", "lingering_potion"].includes(key.path) && !Object.prototype.hasOwnProperty.call(preview.components, "minecraft:enchantment_glint_override") && await ItemTints.hasPotionEffects(preview.components["minecraft:potion_contents"], key.root)) {
|
|
2164
2150
|
preview.components["minecraft:enchantment_glint_override"] = true;
|
|
2165
2151
|
}
|
|
2166
|
-
if (AssetLoader.ROOT !== root || AssetLoader.persistentScope !== scope) throw new Error("Asset sources changed while loading item defaults; retry the request");
|
|
2167
2152
|
return `|data:${resolved.root}:${resolved.manifest.datasets.itemDefaults?.sha256}:${resolved.manifest.datasets.potionColors?.sha256}`;
|
|
2168
2153
|
}
|
|
2169
|
-
static sourceCheck() {
|
|
2170
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
2171
|
-
return () => {
|
|
2172
|
-
if (AssetLoader.ROOT !== root || AssetLoader.persistentScope !== scope) throw new Error("Asset sources changed while loading item models; retry the request");
|
|
2173
|
-
};
|
|
2174
|
-
}
|
|
2175
2154
|
static contextKey(context) {
|
|
2176
2155
|
const itemReferences = Object.fromEntries(Object.entries(context.itemReferences).map(([id, key]) => [id, key.serialize()]));
|
|
2177
2156
|
return `|${this.ITEM_CACHE_VERSION}:${JSON.stringify(this.snapshotJson({ ...context, itemReferences }))}`;
|
|
@@ -2358,7 +2337,6 @@ var init_Models = __esm({
|
|
|
2358
2337
|
* @param key - Model key, for example `AssetKey.parse("models", "minecraft:item/diamond_sword")`.
|
|
2359
2338
|
*/
|
|
2360
2339
|
static async getMerged(key, context = {}) {
|
|
2361
|
-
const checkSources = this.sourceCheck();
|
|
2362
2340
|
if (!key.assetType) {
|
|
2363
2341
|
key.assetType = "models";
|
|
2364
2342
|
}
|
|
@@ -2367,15 +2345,12 @@ var init_Models = __esm({
|
|
|
2367
2345
|
}
|
|
2368
2346
|
const preview = this.snapshotContext(key, context);
|
|
2369
2347
|
const dataKey = await this.applyDefaults(key, preview);
|
|
2370
|
-
checkSources();
|
|
2371
2348
|
const keyStr = AssetLoader.persistentKey(key.serialize() + (key.type === "item" ? this.contextKey(preview) + dataKey : ""));
|
|
2372
2349
|
const model = await Caching.mergedModelCache.get(keyStr, async () => {
|
|
2373
2350
|
const raw = key.type === "item" ? await this.getPreparedItemModel(key, preview, dataKey) : await this.getRaw(key);
|
|
2374
2351
|
const merged = raw ? await ModelMerger.mergeWithParents(raw) : void 0;
|
|
2375
|
-
checkSources();
|
|
2376
2352
|
return merged;
|
|
2377
2353
|
});
|
|
2378
|
-
checkSources();
|
|
2379
2354
|
return model;
|
|
2380
2355
|
}
|
|
2381
2356
|
/** Alias for {@link getMerged}. */
|
|
@@ -12365,7 +12340,6 @@ import { Euler as Euler10, Matrix4 as Matrix411, Quaternion as Quaternion5, Vect
|
|
|
12365
12340
|
init_ModelCulling();
|
|
12366
12341
|
init_FluidGeometry();
|
|
12367
12342
|
init_MineRenderData();
|
|
12368
|
-
init_AssetLoader();
|
|
12369
12343
|
init_Entities();
|
|
12370
12344
|
var _BlockObject = class _BlockObject extends SceneObject {
|
|
12371
12345
|
constructor(blockState3, options) {
|
|
@@ -12390,19 +12364,12 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
12390
12364
|
this.biomePosition = options?.biomePosition ? [...options.biomePosition] : void 0;
|
|
12391
12365
|
}
|
|
12392
12366
|
async init() {
|
|
12393
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
12394
|
-
const checkSources = () => {
|
|
12395
|
-
if (root !== AssetLoader.ROOT || scope !== AssetLoader.persistentScope) throw new Error("Asset sources changed while loading a block; retry the request");
|
|
12396
|
-
};
|
|
12397
12367
|
this._fluidRules = await MineRenderData.get("fluids", this.blockState.key?.root);
|
|
12398
|
-
checkSources();
|
|
12399
12368
|
if (this.options.applyDefaultState) {
|
|
12400
12369
|
this._setState(await BlockStateResolver.defaults(this.blockState));
|
|
12401
|
-
checkSources();
|
|
12402
12370
|
}
|
|
12403
12371
|
if (this.options.initialState !== void 0) this._setState(this.options.initialState);
|
|
12404
12372
|
await this.recreateModels();
|
|
12405
|
-
checkSources();
|
|
12406
12373
|
}
|
|
12407
12374
|
dispose() {
|
|
12408
12375
|
this.clearModels();
|
|
@@ -13254,6 +13221,8 @@ import { Controls, Euler as Euler11, MathUtils as MathUtils2, Quaternion as Quat
|
|
|
13254
13221
|
var VANILLA_FLY_SPEED = 10.89;
|
|
13255
13222
|
var PITCH_LIMIT = Math.PI / 2;
|
|
13256
13223
|
var MOVE_EPSILON = 1e-6;
|
|
13224
|
+
var MAX_STEP_SECONDS = 0.1;
|
|
13225
|
+
var CLICK_SLOP_PIXELS = 4;
|
|
13257
13226
|
var _euler = new Euler11(0, 0, 0, "YXZ");
|
|
13258
13227
|
var _forward = new Vector313();
|
|
13259
13228
|
var _right = new Vector313();
|
|
@@ -13288,7 +13257,8 @@ var FlyControls = class extends Controls {
|
|
|
13288
13257
|
right: ["KeyD", "ArrowRight"],
|
|
13289
13258
|
up: ["Space"],
|
|
13290
13259
|
down: ["ShiftLeft", "ShiftRight"],
|
|
13291
|
-
|
|
13260
|
+
// Not Control: Ctrl+W closes the browser tab on Windows and Linux, and a page cannot block it.
|
|
13261
|
+
sprint: ["KeyR"]
|
|
13292
13262
|
};
|
|
13293
13263
|
this._pressed = /* @__PURE__ */ new Set();
|
|
13294
13264
|
this._velocity = new Vector313();
|
|
@@ -13296,8 +13266,12 @@ var FlyControls = class extends Controls {
|
|
|
13296
13266
|
this._lastQuaternion = new Quaternion6();
|
|
13297
13267
|
this._position0 = new Vector313();
|
|
13298
13268
|
this._quaternion0 = new Quaternion6();
|
|
13269
|
+
this._dragX = 0;
|
|
13270
|
+
this._dragY = 0;
|
|
13299
13271
|
this._dragMoved = false;
|
|
13272
|
+
this._dragTravel = 0;
|
|
13300
13273
|
this._locked = false;
|
|
13274
|
+
this._madeFocusable = false;
|
|
13301
13275
|
this._onKeyDown = (event) => this.handleKey(event, true);
|
|
13302
13276
|
this._onKeyUp = (event) => this.handleKey(event, false);
|
|
13303
13277
|
this._onPointerDown = (event) => this.handlePointerDown(event);
|
|
@@ -13327,7 +13301,10 @@ var FlyControls = class extends Controls {
|
|
|
13327
13301
|
element.addEventListener("wheel", this._onWheel, { passive: false });
|
|
13328
13302
|
element.addEventListener("blur", this._onBlur);
|
|
13329
13303
|
element.style.touchAction = "none";
|
|
13330
|
-
if (element.tabIndex < 0)
|
|
13304
|
+
if (element.tabIndex < 0) {
|
|
13305
|
+
element.tabIndex = 0;
|
|
13306
|
+
this._madeFocusable = true;
|
|
13307
|
+
}
|
|
13331
13308
|
}
|
|
13332
13309
|
disconnect() {
|
|
13333
13310
|
const element = this.domElement;
|
|
@@ -13345,6 +13322,10 @@ var FlyControls = class extends Controls {
|
|
|
13345
13322
|
element.removeEventListener("wheel", this._onWheel);
|
|
13346
13323
|
element.removeEventListener("blur", this._onBlur);
|
|
13347
13324
|
element.style.touchAction = "auto";
|
|
13325
|
+
if (this._madeFocusable) {
|
|
13326
|
+
element.removeAttribute("tabindex");
|
|
13327
|
+
this._madeFocusable = false;
|
|
13328
|
+
}
|
|
13348
13329
|
this.unlock();
|
|
13349
13330
|
this._locked = false;
|
|
13350
13331
|
this.releaseKeys();
|
|
@@ -13415,6 +13396,7 @@ var FlyControls = class extends Controls {
|
|
|
13415
13396
|
/**
|
|
13416
13397
|
* Advances movement by `delta` seconds (measured since the previous call when omitted)
|
|
13417
13398
|
* and dispatches `change` when the camera moved.
|
|
13399
|
+
* A step longer than 0.1 s is applied as 0.1 s.
|
|
13418
13400
|
*/
|
|
13419
13401
|
update(delta) {
|
|
13420
13402
|
if (delta === void 0) {
|
|
@@ -13426,7 +13408,7 @@ var FlyControls = class extends Controls {
|
|
|
13426
13408
|
this._velocity.set(0, 0, 0);
|
|
13427
13409
|
return;
|
|
13428
13410
|
}
|
|
13429
|
-
if (delta > 0) this.move(delta);
|
|
13411
|
+
if (delta > 0) this.move(Math.min(delta, MAX_STEP_SECONDS));
|
|
13430
13412
|
this.notifyChange();
|
|
13431
13413
|
}
|
|
13432
13414
|
move(delta) {
|
|
@@ -13473,15 +13455,21 @@ var FlyControls = class extends Controls {
|
|
|
13473
13455
|
this._pressed.clear();
|
|
13474
13456
|
}
|
|
13475
13457
|
handleKey(event, down) {
|
|
13458
|
+
if (event.code === "MetaLeft" || event.code === "MetaRight") this.releaseKeys();
|
|
13476
13459
|
const action = this.actionFor(event.code);
|
|
13477
13460
|
if (!action) return;
|
|
13478
13461
|
const ownsInput = this.enabled && (this._locked || event.target === this.domElement);
|
|
13479
|
-
if (down && !ownsInput) return;
|
|
13462
|
+
if (down && (!ownsInput || this.isBrowserShortcut(event))) return;
|
|
13480
13463
|
const pressed = this._pressed.has(action);
|
|
13481
13464
|
if (down) this._pressed.add(action);
|
|
13482
13465
|
else this._pressed.delete(action);
|
|
13483
13466
|
if (ownsInput || this.enabled && pressed) event.preventDefault();
|
|
13484
13467
|
}
|
|
13468
|
+
/** A key pressed with Control, Alt, or Command stays a browser shortcut unless that modifier is bound to an action. */
|
|
13469
|
+
isBrowserShortcut(event) {
|
|
13470
|
+
const bound = (modifier) => Object.values(this.keys).some((codes) => codes.some((code) => code.startsWith(modifier)));
|
|
13471
|
+
return event.ctrlKey && !bound("Control") || event.altKey && !bound("Alt") || event.metaKey && !bound("Meta");
|
|
13472
|
+
}
|
|
13485
13473
|
actionFor(code) {
|
|
13486
13474
|
for (const action in this.keys) {
|
|
13487
13475
|
if (this.keys[action].includes(code)) return action;
|
|
@@ -13501,7 +13489,10 @@ var FlyControls = class extends Controls {
|
|
|
13501
13489
|
if (this._dragPointer !== void 0) return;
|
|
13502
13490
|
if (event.pointerType === "mouse" && event.button !== 0 && event.button !== 2) return;
|
|
13503
13491
|
this._dragPointer = event.pointerId;
|
|
13492
|
+
this._dragX = event.clientX;
|
|
13493
|
+
this._dragY = event.clientY;
|
|
13504
13494
|
this._dragMoved = false;
|
|
13495
|
+
this._dragTravel = 0;
|
|
13505
13496
|
element.setPointerCapture?.(event.pointerId);
|
|
13506
13497
|
}
|
|
13507
13498
|
onJoystickSide(event) {
|
|
@@ -13517,8 +13508,20 @@ var FlyControls = class extends Controls {
|
|
|
13517
13508
|
return;
|
|
13518
13509
|
}
|
|
13519
13510
|
if (!this._locked && event.pointerId !== this._dragPointer) return;
|
|
13520
|
-
|
|
13521
|
-
|
|
13511
|
+
let dx, dy;
|
|
13512
|
+
if (this._locked) {
|
|
13513
|
+
dx = event.movementX ?? 0;
|
|
13514
|
+
dy = event.movementY ?? 0;
|
|
13515
|
+
} else {
|
|
13516
|
+
dx = event.clientX - this._dragX;
|
|
13517
|
+
dy = event.clientY - this._dragY;
|
|
13518
|
+
this._dragX = event.clientX;
|
|
13519
|
+
this._dragY = event.clientY;
|
|
13520
|
+
if (!this._dragMoved) {
|
|
13521
|
+
this._dragTravel += Math.hypot(dx, dy);
|
|
13522
|
+
if (this._dragTravel <= CLICK_SLOP_PIXELS) return;
|
|
13523
|
+
}
|
|
13524
|
+
}
|
|
13522
13525
|
if (!dx && !dy) return;
|
|
13523
13526
|
this._dragMoved = true;
|
|
13524
13527
|
this.turn(dx, dy);
|
|
@@ -15436,6 +15439,7 @@ var _Renderer = class _Renderer {
|
|
|
15436
15439
|
/**
|
|
15437
15440
|
* Replaces renderer-owned controls with the selected mode, keeping the camera where it is.
|
|
15438
15441
|
* Switching to orbit controls targets the point the camera looks at, at the previous orbit distance.
|
|
15442
|
+
* The previous controls object is disposed, so its listeners and settings do not carry over.
|
|
15439
15443
|
* Returns the new controls, or undefined when controls were disabled at construction or after disposal.
|
|
15440
15444
|
*/
|
|
15441
15445
|
setControlsMode(mode) {
|
|
@@ -16325,7 +16329,6 @@ init_util2();
|
|
|
16325
16329
|
// src/world/AnvilParser.ts
|
|
16326
16330
|
init_MineRenderError();
|
|
16327
16331
|
init_MineRenderData();
|
|
16328
|
-
init_AssetLoader();
|
|
16329
16332
|
init_NBTHelper();
|
|
16330
16333
|
|
|
16331
16334
|
// src/world/ChunkData.ts
|
|
@@ -16596,14 +16599,12 @@ var AnvilParser = class {
|
|
|
16596
16599
|
/** Decodes all stored chunks. Gzip, zlib, LZ4, and uncompressed payloads are supported. */
|
|
16597
16600
|
static async parse(data, options = {}) {
|
|
16598
16601
|
options = { ...options };
|
|
16599
|
-
const checkSources = this.assetGuard();
|
|
16600
16602
|
options.signal?.throwIfAborted();
|
|
16601
16603
|
const bytes = this.bytes(data);
|
|
16602
16604
|
const chunks = [];
|
|
16603
16605
|
for (const location of this.locations(bytes)) {
|
|
16604
16606
|
chunks.push(await this.abortable(this.readChunk(bytes, location, options), options.signal));
|
|
16605
16607
|
}
|
|
16606
|
-
checkSources();
|
|
16607
16608
|
return { chunks };
|
|
16608
16609
|
}
|
|
16609
16610
|
/**
|
|
@@ -16614,22 +16615,12 @@ var AnvilParser = class {
|
|
|
16614
16615
|
*/
|
|
16615
16616
|
static async parseChunk(data, localX, localZ, options = {}) {
|
|
16616
16617
|
options = { ...options };
|
|
16617
|
-
const checkSources = this.assetGuard();
|
|
16618
16618
|
options.signal?.throwIfAborted();
|
|
16619
16619
|
const bytes = this.bytes(data);
|
|
16620
16620
|
const location = this.location(bytes, localX, localZ);
|
|
16621
16621
|
const chunk = location ? await this.abortable(this.readChunk(bytes, location, options), options.signal) : void 0;
|
|
16622
|
-
checkSources();
|
|
16623
16622
|
return chunk;
|
|
16624
16623
|
}
|
|
16625
|
-
static assetGuard() {
|
|
16626
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
16627
|
-
return () => {
|
|
16628
|
-
if (AssetLoader.ROOT !== root || AssetLoader.persistentScope !== scope) {
|
|
16629
|
-
throw new MineRenderError("Asset sources changed while parsing Anvil data; retry the request");
|
|
16630
|
-
}
|
|
16631
|
-
};
|
|
16632
|
-
}
|
|
16633
16624
|
/**
|
|
16634
16625
|
* Decodes one chunk from an `entities/r.x.z.mca` file without migrating its NBT.
|
|
16635
16626
|
* @param localX - Chunk x within the region, from 0 to 31.
|
|
@@ -17350,7 +17341,6 @@ function resolveSavedEntity(entity) {
|
|
|
17350
17341
|
|
|
17351
17342
|
// src/world/_entities/WorldEntities.ts
|
|
17352
17343
|
init_BannerPatterns();
|
|
17353
|
-
init_AssetLoader();
|
|
17354
17344
|
var WorldEntities = class {
|
|
17355
17345
|
constructor(scene) {
|
|
17356
17346
|
this.scene = scene;
|
|
@@ -17358,10 +17348,6 @@ var WorldEntities = class {
|
|
|
17358
17348
|
}
|
|
17359
17349
|
/** Captures column ownership before asynchronous block or asset loading starts. */
|
|
17360
17350
|
prepare(entities = [], column) {
|
|
17361
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
17362
|
-
const checkSources = () => {
|
|
17363
|
-
if (root !== AssetLoader.ROOT || scope !== AssetLoader.persistentScope) throw new Error("Asset sources changed while loading saved entities; retry the request");
|
|
17364
|
-
};
|
|
17365
17351
|
const placements = entities.flatMap((entity) => {
|
|
17366
17352
|
const resolved = resolveSavedEntity(entity);
|
|
17367
17353
|
if (!resolved) return [];
|
|
@@ -17377,17 +17363,13 @@ var WorldEntities = class {
|
|
|
17377
17363
|
let object4;
|
|
17378
17364
|
try {
|
|
17379
17365
|
if (!current()) return;
|
|
17380
|
-
checkSources();
|
|
17381
17366
|
const models = await Entities.getEntityList();
|
|
17382
|
-
checkSources();
|
|
17383
17367
|
if (!models.includes(placement.key.path) || !current()) return;
|
|
17384
17368
|
const model = await Entities.getEntity(placement.key, placement.texture, { when: placement.when });
|
|
17385
|
-
checkSources();
|
|
17386
17369
|
if (!model || !current()) return;
|
|
17387
17370
|
let tints = placement.tints;
|
|
17388
17371
|
if (placement.woolDye) {
|
|
17389
17372
|
const dye = (await BannerPatterns.getColors(placement.key.root))[placement.woolDye];
|
|
17390
|
-
checkSources();
|
|
17391
17373
|
const tint = placement.woolDye === "white" ? 15132390 : Math.floor((dye >> 16 & 255) * 0.75) << 16 | Math.floor((dye >> 8 & 255) * 0.75) << 8 | Math.floor((dye & 255) * 0.75);
|
|
17392
17374
|
tints = { ...tints, wool_color: tint };
|
|
17393
17375
|
}
|
|
@@ -17397,7 +17379,6 @@ var WorldEntities = class {
|
|
|
17397
17379
|
object4.position.fromArray(placement.position).multiplyScalar(16).addScalar(-8);
|
|
17398
17380
|
object4.rotation.y = placement.yaw;
|
|
17399
17381
|
await object4.init();
|
|
17400
|
-
checkSources();
|
|
17401
17382
|
if (!current()) return;
|
|
17402
17383
|
placement.owner.add(object4);
|
|
17403
17384
|
this.scene.add(object4);
|