minerender 2.1.0-alpha.126 → 2.1.0-alpha.128
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 +43 -3
- package/dist/browser/index.d.ts +43 -3
- package/dist/browser/index.js +349 -241
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +349 -241
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +370 -256
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +43 -3
- package/dist/node/index.d.ts +43 -3
- package/dist/node/index.js +350 -241
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +349 -241
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -42813,124 +42813,6 @@ void main() {
|
|
|
42813
42813
|
}
|
|
42814
42814
|
});
|
|
42815
42815
|
|
|
42816
|
-
// src/model/Model.ts
|
|
42817
|
-
function isDoubleArray(obj) {
|
|
42818
|
-
return Array.isArray(obj) && obj.length === 2;
|
|
42819
|
-
}
|
|
42820
|
-
function isTripleArray(obj) {
|
|
42821
|
-
return Array.isArray(obj) && obj.length === 3;
|
|
42822
|
-
}
|
|
42823
|
-
function isQuadArray(obj) {
|
|
42824
|
-
return Array.isArray(obj) && obj.length === 4;
|
|
42825
|
-
}
|
|
42826
|
-
var ITEM_GENERATED, BUILTIN_GENERATED, BUILTIN_ENTITY, DEFAULT_ELEMENTS;
|
|
42827
|
-
var init_Model = __esm({
|
|
42828
|
-
"src/model/Model.ts"() {
|
|
42829
|
-
init_dirname();
|
|
42830
|
-
init_buffer2();
|
|
42831
|
-
init_process2();
|
|
42832
|
-
ITEM_GENERATED = "item/generated";
|
|
42833
|
-
BUILTIN_GENERATED = "builtin/generated";
|
|
42834
|
-
BUILTIN_ENTITY = "builtin/entity";
|
|
42835
|
-
DEFAULT_ELEMENTS = [];
|
|
42836
|
-
}
|
|
42837
|
-
});
|
|
42838
|
-
|
|
42839
|
-
// ../../node_modules/ts-deepmerge/dist/index.js
|
|
42840
|
-
var require_dist = __commonJS({
|
|
42841
|
-
"../../node_modules/ts-deepmerge/dist/index.js"(exports13) {
|
|
42842
|
-
"use strict";
|
|
42843
|
-
init_dirname();
|
|
42844
|
-
init_buffer2();
|
|
42845
|
-
init_process2();
|
|
42846
|
-
var __assign = exports13 && exports13.__assign || function() {
|
|
42847
|
-
__assign = Object.assign || function(t5) {
|
|
42848
|
-
for (var s4, i4 = 1, n4 = arguments.length; i4 < n4; i4++) {
|
|
42849
|
-
s4 = arguments[i4];
|
|
42850
|
-
for (var p14 in s4) if (Object.prototype.hasOwnProperty.call(s4, p14))
|
|
42851
|
-
t5[p14] = s4[p14];
|
|
42852
|
-
}
|
|
42853
|
-
return t5;
|
|
42854
|
-
};
|
|
42855
|
-
return __assign.apply(this, arguments);
|
|
42856
|
-
};
|
|
42857
|
-
var __read = exports13 && exports13.__read || function(o4, n4) {
|
|
42858
|
-
var m4 = typeof Symbol === "function" && o4[Symbol.iterator];
|
|
42859
|
-
if (!m4) return o4;
|
|
42860
|
-
var i4 = m4.call(o4), r5, ar = [], e6;
|
|
42861
|
-
try {
|
|
42862
|
-
while ((n4 === void 0 || n4-- > 0) && !(r5 = i4.next()).done) ar.push(r5.value);
|
|
42863
|
-
} catch (error2) {
|
|
42864
|
-
e6 = { error: error2 };
|
|
42865
|
-
} finally {
|
|
42866
|
-
try {
|
|
42867
|
-
if (r5 && !r5.done && (m4 = i4["return"])) m4.call(i4);
|
|
42868
|
-
} finally {
|
|
42869
|
-
if (e6) throw e6.error;
|
|
42870
|
-
}
|
|
42871
|
-
}
|
|
42872
|
-
return ar;
|
|
42873
|
-
};
|
|
42874
|
-
var __spreadArray = exports13 && exports13.__spreadArray || function(to, from, pack) {
|
|
42875
|
-
if (pack || arguments.length === 2) for (var i4 = 0, l4 = from.length, ar; i4 < l4; i4++) {
|
|
42876
|
-
if (ar || !(i4 in from)) {
|
|
42877
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i4);
|
|
42878
|
-
ar[i4] = from[i4];
|
|
42879
|
-
}
|
|
42880
|
-
}
|
|
42881
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
42882
|
-
};
|
|
42883
|
-
Object.defineProperty(exports13, "__esModule", { value: true });
|
|
42884
|
-
var isObject2 = function(obj) {
|
|
42885
|
-
if (typeof obj === "object" && obj !== null) {
|
|
42886
|
-
if (typeof Object.getPrototypeOf === "function") {
|
|
42887
|
-
var prototype = Object.getPrototypeOf(obj);
|
|
42888
|
-
return prototype === Object.prototype || prototype === null;
|
|
42889
|
-
}
|
|
42890
|
-
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
42891
|
-
}
|
|
42892
|
-
return false;
|
|
42893
|
-
};
|
|
42894
|
-
var PROTECTED_KEYS = ["__proto__"];
|
|
42895
|
-
var merge10 = function() {
|
|
42896
|
-
var objects = [];
|
|
42897
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
42898
|
-
objects[_i] = arguments[_i];
|
|
42899
|
-
}
|
|
42900
|
-
return objects.reduce(function(result, current) {
|
|
42901
|
-
Object.keys(current).forEach(function(key) {
|
|
42902
|
-
if (PROTECTED_KEYS.includes(key)) {
|
|
42903
|
-
return;
|
|
42904
|
-
}
|
|
42905
|
-
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
42906
|
-
result[key] = merge10.options.mergeArrays ? Array.from(new Set(result[key].concat(current[key]))) : current[key];
|
|
42907
|
-
} else if (isObject2(result[key]) && isObject2(current[key])) {
|
|
42908
|
-
result[key] = merge10(result[key], current[key]);
|
|
42909
|
-
} else {
|
|
42910
|
-
result[key] = current[key];
|
|
42911
|
-
}
|
|
42912
|
-
});
|
|
42913
|
-
return result;
|
|
42914
|
-
}, {});
|
|
42915
|
-
};
|
|
42916
|
-
var defaultOptions = {
|
|
42917
|
-
mergeArrays: true
|
|
42918
|
-
};
|
|
42919
|
-
merge10.options = defaultOptions;
|
|
42920
|
-
merge10.withOptions = function(options) {
|
|
42921
|
-
var objects = [];
|
|
42922
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
42923
|
-
objects[_i - 1] = arguments[_i];
|
|
42924
|
-
}
|
|
42925
|
-
merge10.options = __assign({ mergeArrays: true }, options);
|
|
42926
|
-
var result = merge10.apply(void 0, __spreadArray([], __read(objects), false));
|
|
42927
|
-
merge10.options = defaultOptions;
|
|
42928
|
-
return result;
|
|
42929
|
-
};
|
|
42930
|
-
exports13.default = merge10;
|
|
42931
|
-
}
|
|
42932
|
-
});
|
|
42933
|
-
|
|
42934
42816
|
// src/assets/AssetKey.ts
|
|
42935
42817
|
function isResourceLocation(value) {
|
|
42936
42818
|
return typeof value === "string" && /^(?:[a-z0-9_.-]+:)?[a-z0-9_./-]+$/.test(value);
|
|
@@ -43050,137 +42932,6 @@ void main() {
|
|
|
43050
42932
|
}
|
|
43051
42933
|
});
|
|
43052
42934
|
|
|
43053
|
-
// src/model/DisplayPosition.ts
|
|
43054
|
-
var DisplayPosition, DISPLAY_POSITIONS;
|
|
43055
|
-
var init_DisplayPosition = __esm({
|
|
43056
|
-
"src/model/DisplayPosition.ts"() {
|
|
43057
|
-
init_dirname();
|
|
43058
|
-
init_buffer2();
|
|
43059
|
-
init_process2();
|
|
43060
|
-
DisplayPosition = /* @__PURE__ */ ((DisplayPosition3) => {
|
|
43061
|
-
DisplayPosition3["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
|
|
43062
|
-
DisplayPosition3["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
|
|
43063
|
-
DisplayPosition3["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
|
|
43064
|
-
DisplayPosition3["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
|
|
43065
|
-
DisplayPosition3["GUI"] = "gui";
|
|
43066
|
-
DisplayPosition3["HEAD"] = "head";
|
|
43067
|
-
DisplayPosition3["GROUND"] = "ground";
|
|
43068
|
-
DisplayPosition3["FIXED"] = "fixed";
|
|
43069
|
-
DisplayPosition3["ON_SHELF"] = "on_shelf";
|
|
43070
|
-
return DisplayPosition3;
|
|
43071
|
-
})(DisplayPosition || {});
|
|
43072
|
-
DISPLAY_POSITIONS = Object.values(DisplayPosition);
|
|
43073
|
-
}
|
|
43074
|
-
});
|
|
43075
|
-
|
|
43076
|
-
// src/model/DisplayTransforms.ts
|
|
43077
|
-
var DisplayTransforms;
|
|
43078
|
-
var init_DisplayTransforms = __esm({
|
|
43079
|
-
"src/model/DisplayTransforms.ts"() {
|
|
43080
|
-
init_dirname();
|
|
43081
|
-
init_buffer2();
|
|
43082
|
-
init_process2();
|
|
43083
|
-
init_three_module();
|
|
43084
|
-
init_DisplayPosition();
|
|
43085
|
-
init_util();
|
|
43086
|
-
DisplayTransforms = class {
|
|
43087
|
-
/** Resolve hand fallbacks within one model, before inheriting parent display entries. */
|
|
43088
|
-
static withHandFallbacks(display) {
|
|
43089
|
-
if (!display) return void 0;
|
|
43090
|
-
const resolved = { ...display };
|
|
43091
|
-
for (const [left, right] of [
|
|
43092
|
-
["thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */, "thirdperson_righthand" /* THIRDPERSON_RIGHTHAND */],
|
|
43093
|
-
["firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */, "firstperson_righthand" /* FIRSTPERSON_RIGHTHAND */]
|
|
43094
|
-
]) {
|
|
43095
|
-
if (resolved[left] === void 0 && resolved[right] !== void 0) resolved[left] = resolved[right];
|
|
43096
|
-
}
|
|
43097
|
-
return resolved;
|
|
43098
|
-
}
|
|
43099
|
-
/** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
43100
|
-
static getMatrix(display, position) {
|
|
43101
|
-
const transform = this.getTransform(display, position);
|
|
43102
|
-
return new Matrix4().compose(transform.position, transform.quaternion, transform.scale);
|
|
43103
|
-
}
|
|
43104
|
-
/** Position, rotation, and scale of a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
43105
|
-
static getTransform(display, position) {
|
|
43106
|
-
const transform = this.withHandFallbacks(display)?.[position] ?? {};
|
|
43107
|
-
const left = position === "firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */ || position === "thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */;
|
|
43108
|
-
const sign = left ? -1 : 1;
|
|
43109
|
-
const [x4, y5, z4] = transform.rotation ?? [0, 0, 0];
|
|
43110
|
-
const rotation = new Quaternion().setFromEuler(new Euler(toRadians(x4), sign * toRadians(y5), sign * toRadians(z4), "XYZ"));
|
|
43111
|
-
const translation = new Vector3(...transform.translation ?? [0, 0, 0]).clampScalar(-80, 80);
|
|
43112
|
-
translation.x *= sign;
|
|
43113
|
-
const scale = new Vector3(...transform.scale ?? [1, 1, 1]).clampScalar(-4, 4);
|
|
43114
|
-
return { position: translation, quaternion: rotation, scale };
|
|
43115
|
-
}
|
|
43116
|
-
/** Transforms geometry in place and reverses triangle winding when the matrix reflects it. */
|
|
43117
|
-
static apply(geometry, matrix) {
|
|
43118
|
-
geometry.applyMatrix4(matrix);
|
|
43119
|
-
if (matrix.determinant() < 0) {
|
|
43120
|
-
if (!geometry.index) geometry.setIndex(Array.from({ length: geometry.getAttribute("position").count }, (_4, i4) => i4));
|
|
43121
|
-
const index = geometry.index;
|
|
43122
|
-
for (let i4 = 0; i4 < index.count; i4 += 3) {
|
|
43123
|
-
const second = index.getX(i4 + 1);
|
|
43124
|
-
index.setX(i4 + 1, index.getX(i4 + 2));
|
|
43125
|
-
index.setX(i4 + 2, second);
|
|
43126
|
-
}
|
|
43127
|
-
index.needsUpdate = true;
|
|
43128
|
-
}
|
|
43129
|
-
}
|
|
43130
|
-
};
|
|
43131
|
-
}
|
|
43132
|
-
});
|
|
43133
|
-
|
|
43134
|
-
// src/model/ModelMerger.ts
|
|
43135
|
-
var import_ts_deepmerge, ModelMerger;
|
|
43136
|
-
var init_ModelMerger = __esm({
|
|
43137
|
-
"src/model/ModelMerger.ts"() {
|
|
43138
|
-
init_dirname();
|
|
43139
|
-
init_buffer2();
|
|
43140
|
-
init_process2();
|
|
43141
|
-
init_Model();
|
|
43142
|
-
init_Models();
|
|
43143
|
-
import_ts_deepmerge = __toESM(require_dist());
|
|
43144
|
-
init_AssetKey();
|
|
43145
|
-
init_DisplayTransforms();
|
|
43146
|
-
ModelMerger = class {
|
|
43147
|
-
/** Loads the parent chain and returns a merged model without modifying the supplied definition. */
|
|
43148
|
-
static async mergeWithParents(model) {
|
|
43149
|
-
const parts = model.parts;
|
|
43150
|
-
if (parts) return { ...model, parts: await Promise.all(parts.map((part) => this.mergeWithParents(part))) };
|
|
43151
|
-
const models = await this.collectAllParents(model);
|
|
43152
|
-
let merged = {};
|
|
43153
|
-
for (const source of [...models, model]) {
|
|
43154
|
-
const inheritedDisplay = merged.display;
|
|
43155
|
-
merged = import_ts_deepmerge.default.withOptions({ mergeArrays: false }, merged, source);
|
|
43156
|
-
if (source.display) {
|
|
43157
|
-
merged.display = { ...inheritedDisplay, ...DisplayTransforms.withHandFallbacks(source.display) };
|
|
43158
|
-
}
|
|
43159
|
-
}
|
|
43160
|
-
merged.hierarchy = models.map((m4) => m4.parent).filter((p14) => `${p14}`);
|
|
43161
|
-
merged.hierarchy.push(`${merged.parent}`);
|
|
43162
|
-
if (model.components) merged.components = model.components;
|
|
43163
|
-
return merged;
|
|
43164
|
-
}
|
|
43165
|
-
static async collectAllParents(model) {
|
|
43166
|
-
if (!model.parent) {
|
|
43167
|
-
return [];
|
|
43168
|
-
}
|
|
43169
|
-
const models = [];
|
|
43170
|
-
const parentKey = AssetKey.parse("models", model.parent);
|
|
43171
|
-
if (parentKey.namespace === "minecraft" && parentKey.getFullPath() === BUILTIN_ENTITY) return models;
|
|
43172
|
-
parentKey.root = model.key?.root;
|
|
43173
|
-
const parentModel = await Models.getRaw(parentKey);
|
|
43174
|
-
if (parentModel) {
|
|
43175
|
-
models.unshift(parentModel);
|
|
43176
|
-
models.unshift(...await this.collectAllParents(parentModel));
|
|
43177
|
-
}
|
|
43178
|
-
return models;
|
|
43179
|
-
}
|
|
43180
|
-
};
|
|
43181
|
-
}
|
|
43182
|
-
});
|
|
43183
|
-
|
|
43184
42935
|
// src/assets/source/parser/AssetParsers.ts
|
|
43185
42936
|
var AssetParser;
|
|
43186
42937
|
var init_AssetParsers = __esm({
|
|
@@ -43304,7 +43055,9 @@ ${key}` : key, async () => {
|
|
|
43304
43055
|
static validDataset(dataset, data) {
|
|
43305
43056
|
if (!object(data)) return false;
|
|
43306
43057
|
if (dataset === "potionColors") return object(data.effects) && Object.values(data.effects).every(Number.isInteger) && object(data.potions) && Object.values(data.potions).every((effects) => Array.isArray(effects) && effects.every((effect) => object(effect) && typeof effect.id === "string" && Number.isInteger(effect.amplifier)));
|
|
43058
|
+
if (dataset === "renames") return data.format === "data-fixer-renames" && Number.isInteger(data.baseDataVersion) && ["blocks", "items", "entities"].every((kind) => object(data[kind]) && Object.values(data[kind]).every((entry) => object(entry) && typeof entry.registered === "boolean" && Array.isArray(entry.ranges) && entry.ranges.length > 0 && entry.ranges.every((range) => object(range) && Number.isInteger(range.before) && typeof range.to === "string")));
|
|
43307
43059
|
if (dataset === "legacyBlocks") return object(data.blocks) && Object.values(data.blocks).every((value) => typeof value === "string");
|
|
43060
|
+
if (dataset === "blockCulling") return Array.isArray(data.profiles) && data.profiles.every((profile) => object(profile) && typeof profile.type === "string") && object(data.blocks) && Object.values(data.blocks).every((index) => Number.isInteger(index) && index >= 0 && index < data.profiles.length) && (data.groups === void 0 || object(data.groups) && Object.values(data.groups).every((group) => Array.isArray(group) && group.every((type) => typeof type === "string")));
|
|
43308
43061
|
return Object.values(data).every((value) => {
|
|
43309
43062
|
if (!object(value)) return false;
|
|
43310
43063
|
switch (dataset) {
|
|
@@ -43327,6 +43080,293 @@ ${key}` : key, async () => {
|
|
|
43327
43080
|
}
|
|
43328
43081
|
});
|
|
43329
43082
|
|
|
43083
|
+
// src/assets/Renames.ts
|
|
43084
|
+
var Renames;
|
|
43085
|
+
var init_Renames = __esm({
|
|
43086
|
+
"src/assets/Renames.ts"() {
|
|
43087
|
+
init_dirname();
|
|
43088
|
+
init_buffer2();
|
|
43089
|
+
init_process2();
|
|
43090
|
+
init_AssetKey();
|
|
43091
|
+
init_MineRenderData();
|
|
43092
|
+
Renames = class {
|
|
43093
|
+
/** Loads the selected version's rename table, or `undefined` when its published data has none. */
|
|
43094
|
+
static async get(root) {
|
|
43095
|
+
const resolved = await MineRenderData.resolve(root);
|
|
43096
|
+
return resolved.manifest.datasets.renames ? MineRenderData.get("renames", root) : void 0;
|
|
43097
|
+
}
|
|
43098
|
+
/**
|
|
43099
|
+
* Returns the ID that replaced `id`, or `undefined` when `id` keeps its meaning.
|
|
43100
|
+
* Without a data version, an ID that the selected version still registers keeps its meaning.
|
|
43101
|
+
*/
|
|
43102
|
+
static async resolve(kind, id, dataVersion, root) {
|
|
43103
|
+
const data = await this.get(root);
|
|
43104
|
+
if (!data || !Object.prototype.hasOwnProperty.call(data[kind], id)) return void 0;
|
|
43105
|
+
const entry = data[kind][id];
|
|
43106
|
+
if (dataVersion === void 0) return entry.registered ? void 0 : entry.ranges[entry.ranges.length - 1].to;
|
|
43107
|
+
if (dataVersion < data.baseDataVersion) return void 0;
|
|
43108
|
+
return entry.ranges.find((range) => dataVersion < range.before)?.to;
|
|
43109
|
+
}
|
|
43110
|
+
/** Returns a copy of `key` for the replacement ID, or `undefined` when the ID keeps its meaning. */
|
|
43111
|
+
static async key(kind, key) {
|
|
43112
|
+
const renamed = await this.resolve(kind, `${key.namespace}:${key.path}`, void 0, key.root);
|
|
43113
|
+
if (!renamed) return void 0;
|
|
43114
|
+
const [namespace, path] = renamed.split(":");
|
|
43115
|
+
return new AssetKey(namespace, path, key.assetType, key.type, key.rootType, key.extension, key.root);
|
|
43116
|
+
}
|
|
43117
|
+
};
|
|
43118
|
+
}
|
|
43119
|
+
});
|
|
43120
|
+
|
|
43121
|
+
// src/model/Model.ts
|
|
43122
|
+
function isDoubleArray(obj) {
|
|
43123
|
+
return Array.isArray(obj) && obj.length === 2;
|
|
43124
|
+
}
|
|
43125
|
+
function isTripleArray(obj) {
|
|
43126
|
+
return Array.isArray(obj) && obj.length === 3;
|
|
43127
|
+
}
|
|
43128
|
+
function isQuadArray(obj) {
|
|
43129
|
+
return Array.isArray(obj) && obj.length === 4;
|
|
43130
|
+
}
|
|
43131
|
+
var ITEM_GENERATED, BUILTIN_GENERATED, BUILTIN_ENTITY, DEFAULT_ELEMENTS;
|
|
43132
|
+
var init_Model = __esm({
|
|
43133
|
+
"src/model/Model.ts"() {
|
|
43134
|
+
init_dirname();
|
|
43135
|
+
init_buffer2();
|
|
43136
|
+
init_process2();
|
|
43137
|
+
ITEM_GENERATED = "item/generated";
|
|
43138
|
+
BUILTIN_GENERATED = "builtin/generated";
|
|
43139
|
+
BUILTIN_ENTITY = "builtin/entity";
|
|
43140
|
+
DEFAULT_ELEMENTS = [];
|
|
43141
|
+
}
|
|
43142
|
+
});
|
|
43143
|
+
|
|
43144
|
+
// ../../node_modules/ts-deepmerge/dist/index.js
|
|
43145
|
+
var require_dist = __commonJS({
|
|
43146
|
+
"../../node_modules/ts-deepmerge/dist/index.js"(exports13) {
|
|
43147
|
+
"use strict";
|
|
43148
|
+
init_dirname();
|
|
43149
|
+
init_buffer2();
|
|
43150
|
+
init_process2();
|
|
43151
|
+
var __assign = exports13 && exports13.__assign || function() {
|
|
43152
|
+
__assign = Object.assign || function(t5) {
|
|
43153
|
+
for (var s4, i4 = 1, n4 = arguments.length; i4 < n4; i4++) {
|
|
43154
|
+
s4 = arguments[i4];
|
|
43155
|
+
for (var p14 in s4) if (Object.prototype.hasOwnProperty.call(s4, p14))
|
|
43156
|
+
t5[p14] = s4[p14];
|
|
43157
|
+
}
|
|
43158
|
+
return t5;
|
|
43159
|
+
};
|
|
43160
|
+
return __assign.apply(this, arguments);
|
|
43161
|
+
};
|
|
43162
|
+
var __read = exports13 && exports13.__read || function(o4, n4) {
|
|
43163
|
+
var m4 = typeof Symbol === "function" && o4[Symbol.iterator];
|
|
43164
|
+
if (!m4) return o4;
|
|
43165
|
+
var i4 = m4.call(o4), r5, ar = [], e6;
|
|
43166
|
+
try {
|
|
43167
|
+
while ((n4 === void 0 || n4-- > 0) && !(r5 = i4.next()).done) ar.push(r5.value);
|
|
43168
|
+
} catch (error2) {
|
|
43169
|
+
e6 = { error: error2 };
|
|
43170
|
+
} finally {
|
|
43171
|
+
try {
|
|
43172
|
+
if (r5 && !r5.done && (m4 = i4["return"])) m4.call(i4);
|
|
43173
|
+
} finally {
|
|
43174
|
+
if (e6) throw e6.error;
|
|
43175
|
+
}
|
|
43176
|
+
}
|
|
43177
|
+
return ar;
|
|
43178
|
+
};
|
|
43179
|
+
var __spreadArray = exports13 && exports13.__spreadArray || function(to, from, pack) {
|
|
43180
|
+
if (pack || arguments.length === 2) for (var i4 = 0, l4 = from.length, ar; i4 < l4; i4++) {
|
|
43181
|
+
if (ar || !(i4 in from)) {
|
|
43182
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i4);
|
|
43183
|
+
ar[i4] = from[i4];
|
|
43184
|
+
}
|
|
43185
|
+
}
|
|
43186
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
43187
|
+
};
|
|
43188
|
+
Object.defineProperty(exports13, "__esModule", { value: true });
|
|
43189
|
+
var isObject2 = function(obj) {
|
|
43190
|
+
if (typeof obj === "object" && obj !== null) {
|
|
43191
|
+
if (typeof Object.getPrototypeOf === "function") {
|
|
43192
|
+
var prototype = Object.getPrototypeOf(obj);
|
|
43193
|
+
return prototype === Object.prototype || prototype === null;
|
|
43194
|
+
}
|
|
43195
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
43196
|
+
}
|
|
43197
|
+
return false;
|
|
43198
|
+
};
|
|
43199
|
+
var PROTECTED_KEYS = ["__proto__"];
|
|
43200
|
+
var merge10 = function() {
|
|
43201
|
+
var objects = [];
|
|
43202
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
43203
|
+
objects[_i] = arguments[_i];
|
|
43204
|
+
}
|
|
43205
|
+
return objects.reduce(function(result, current) {
|
|
43206
|
+
Object.keys(current).forEach(function(key) {
|
|
43207
|
+
if (PROTECTED_KEYS.includes(key)) {
|
|
43208
|
+
return;
|
|
43209
|
+
}
|
|
43210
|
+
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
43211
|
+
result[key] = merge10.options.mergeArrays ? Array.from(new Set(result[key].concat(current[key]))) : current[key];
|
|
43212
|
+
} else if (isObject2(result[key]) && isObject2(current[key])) {
|
|
43213
|
+
result[key] = merge10(result[key], current[key]);
|
|
43214
|
+
} else {
|
|
43215
|
+
result[key] = current[key];
|
|
43216
|
+
}
|
|
43217
|
+
});
|
|
43218
|
+
return result;
|
|
43219
|
+
}, {});
|
|
43220
|
+
};
|
|
43221
|
+
var defaultOptions = {
|
|
43222
|
+
mergeArrays: true
|
|
43223
|
+
};
|
|
43224
|
+
merge10.options = defaultOptions;
|
|
43225
|
+
merge10.withOptions = function(options) {
|
|
43226
|
+
var objects = [];
|
|
43227
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
43228
|
+
objects[_i - 1] = arguments[_i];
|
|
43229
|
+
}
|
|
43230
|
+
merge10.options = __assign({ mergeArrays: true }, options);
|
|
43231
|
+
var result = merge10.apply(void 0, __spreadArray([], __read(objects), false));
|
|
43232
|
+
merge10.options = defaultOptions;
|
|
43233
|
+
return result;
|
|
43234
|
+
};
|
|
43235
|
+
exports13.default = merge10;
|
|
43236
|
+
}
|
|
43237
|
+
});
|
|
43238
|
+
|
|
43239
|
+
// src/model/DisplayPosition.ts
|
|
43240
|
+
var DisplayPosition, DISPLAY_POSITIONS;
|
|
43241
|
+
var init_DisplayPosition = __esm({
|
|
43242
|
+
"src/model/DisplayPosition.ts"() {
|
|
43243
|
+
init_dirname();
|
|
43244
|
+
init_buffer2();
|
|
43245
|
+
init_process2();
|
|
43246
|
+
DisplayPosition = /* @__PURE__ */ ((DisplayPosition3) => {
|
|
43247
|
+
DisplayPosition3["THIRDPERSON_RIGHTHAND"] = "thirdperson_righthand";
|
|
43248
|
+
DisplayPosition3["THIRDPERSON_LEFTHAND"] = "thirdperson_lefthand";
|
|
43249
|
+
DisplayPosition3["FIRSTPERSON_RIGHTHAND"] = "firstperson_righthand";
|
|
43250
|
+
DisplayPosition3["FIRSTPERSON_LEFTHAND"] = "firstperson_lefthand";
|
|
43251
|
+
DisplayPosition3["GUI"] = "gui";
|
|
43252
|
+
DisplayPosition3["HEAD"] = "head";
|
|
43253
|
+
DisplayPosition3["GROUND"] = "ground";
|
|
43254
|
+
DisplayPosition3["FIXED"] = "fixed";
|
|
43255
|
+
DisplayPosition3["ON_SHELF"] = "on_shelf";
|
|
43256
|
+
return DisplayPosition3;
|
|
43257
|
+
})(DisplayPosition || {});
|
|
43258
|
+
DISPLAY_POSITIONS = Object.values(DisplayPosition);
|
|
43259
|
+
}
|
|
43260
|
+
});
|
|
43261
|
+
|
|
43262
|
+
// src/model/DisplayTransforms.ts
|
|
43263
|
+
var DisplayTransforms;
|
|
43264
|
+
var init_DisplayTransforms = __esm({
|
|
43265
|
+
"src/model/DisplayTransforms.ts"() {
|
|
43266
|
+
init_dirname();
|
|
43267
|
+
init_buffer2();
|
|
43268
|
+
init_process2();
|
|
43269
|
+
init_three_module();
|
|
43270
|
+
init_DisplayPosition();
|
|
43271
|
+
init_util();
|
|
43272
|
+
DisplayTransforms = class {
|
|
43273
|
+
/** Resolve hand fallbacks within one model, before inheriting parent display entries. */
|
|
43274
|
+
static withHandFallbacks(display) {
|
|
43275
|
+
if (!display) return void 0;
|
|
43276
|
+
const resolved = { ...display };
|
|
43277
|
+
for (const [left, right] of [
|
|
43278
|
+
["thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */, "thirdperson_righthand" /* THIRDPERSON_RIGHTHAND */],
|
|
43279
|
+
["firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */, "firstperson_righthand" /* FIRSTPERSON_RIGHTHAND */]
|
|
43280
|
+
]) {
|
|
43281
|
+
if (resolved[left] === void 0 && resolved[right] !== void 0) resolved[left] = resolved[right];
|
|
43282
|
+
}
|
|
43283
|
+
return resolved;
|
|
43284
|
+
}
|
|
43285
|
+
/** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
43286
|
+
static getMatrix(display, position) {
|
|
43287
|
+
const transform = this.getTransform(display, position);
|
|
43288
|
+
return new Matrix4().compose(transform.position, transform.quaternion, transform.scale);
|
|
43289
|
+
}
|
|
43290
|
+
/** Position, rotation, and scale of a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
43291
|
+
static getTransform(display, position) {
|
|
43292
|
+
const transform = this.withHandFallbacks(display)?.[position] ?? {};
|
|
43293
|
+
const left = position === "firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */ || position === "thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */;
|
|
43294
|
+
const sign = left ? -1 : 1;
|
|
43295
|
+
const [x4, y5, z4] = transform.rotation ?? [0, 0, 0];
|
|
43296
|
+
const rotation = new Quaternion().setFromEuler(new Euler(toRadians(x4), sign * toRadians(y5), sign * toRadians(z4), "XYZ"));
|
|
43297
|
+
const translation = new Vector3(...transform.translation ?? [0, 0, 0]).clampScalar(-80, 80);
|
|
43298
|
+
translation.x *= sign;
|
|
43299
|
+
const scale = new Vector3(...transform.scale ?? [1, 1, 1]).clampScalar(-4, 4);
|
|
43300
|
+
return { position: translation, quaternion: rotation, scale };
|
|
43301
|
+
}
|
|
43302
|
+
/** Transforms geometry in place and reverses triangle winding when the matrix reflects it. */
|
|
43303
|
+
static apply(geometry, matrix) {
|
|
43304
|
+
geometry.applyMatrix4(matrix);
|
|
43305
|
+
if (matrix.determinant() < 0) {
|
|
43306
|
+
if (!geometry.index) geometry.setIndex(Array.from({ length: geometry.getAttribute("position").count }, (_4, i4) => i4));
|
|
43307
|
+
const index = geometry.index;
|
|
43308
|
+
for (let i4 = 0; i4 < index.count; i4 += 3) {
|
|
43309
|
+
const second = index.getX(i4 + 1);
|
|
43310
|
+
index.setX(i4 + 1, index.getX(i4 + 2));
|
|
43311
|
+
index.setX(i4 + 2, second);
|
|
43312
|
+
}
|
|
43313
|
+
index.needsUpdate = true;
|
|
43314
|
+
}
|
|
43315
|
+
}
|
|
43316
|
+
};
|
|
43317
|
+
}
|
|
43318
|
+
});
|
|
43319
|
+
|
|
43320
|
+
// src/model/ModelMerger.ts
|
|
43321
|
+
var import_ts_deepmerge, ModelMerger;
|
|
43322
|
+
var init_ModelMerger = __esm({
|
|
43323
|
+
"src/model/ModelMerger.ts"() {
|
|
43324
|
+
init_dirname();
|
|
43325
|
+
init_buffer2();
|
|
43326
|
+
init_process2();
|
|
43327
|
+
init_Model();
|
|
43328
|
+
init_Models();
|
|
43329
|
+
import_ts_deepmerge = __toESM(require_dist());
|
|
43330
|
+
init_AssetKey();
|
|
43331
|
+
init_DisplayTransforms();
|
|
43332
|
+
ModelMerger = class {
|
|
43333
|
+
/** Loads the parent chain and returns a merged model without modifying the supplied definition. */
|
|
43334
|
+
static async mergeWithParents(model) {
|
|
43335
|
+
const parts = model.parts;
|
|
43336
|
+
if (parts) return { ...model, parts: await Promise.all(parts.map((part) => this.mergeWithParents(part))) };
|
|
43337
|
+
const models = await this.collectAllParents(model);
|
|
43338
|
+
let merged = {};
|
|
43339
|
+
for (const source of [...models, model]) {
|
|
43340
|
+
const inheritedDisplay = merged.display;
|
|
43341
|
+
merged = import_ts_deepmerge.default.withOptions({ mergeArrays: false }, merged, source);
|
|
43342
|
+
if (source.display) {
|
|
43343
|
+
merged.display = { ...inheritedDisplay, ...DisplayTransforms.withHandFallbacks(source.display) };
|
|
43344
|
+
}
|
|
43345
|
+
}
|
|
43346
|
+
merged.hierarchy = models.map((m4) => m4.parent).filter((p14) => `${p14}`);
|
|
43347
|
+
merged.hierarchy.push(`${merged.parent}`);
|
|
43348
|
+
if (model.components) merged.components = model.components;
|
|
43349
|
+
return merged;
|
|
43350
|
+
}
|
|
43351
|
+
static async collectAllParents(model) {
|
|
43352
|
+
if (!model.parent) {
|
|
43353
|
+
return [];
|
|
43354
|
+
}
|
|
43355
|
+
const models = [];
|
|
43356
|
+
const parentKey = AssetKey.parse("models", model.parent);
|
|
43357
|
+
if (parentKey.namespace === "minecraft" && parentKey.getFullPath() === BUILTIN_ENTITY) return models;
|
|
43358
|
+
parentKey.root = model.key?.root;
|
|
43359
|
+
const parentModel = await Models.getRaw(parentKey);
|
|
43360
|
+
if (parentModel) {
|
|
43361
|
+
models.unshift(parentModel);
|
|
43362
|
+
models.unshift(...await this.collectAllParents(parentModel));
|
|
43363
|
+
}
|
|
43364
|
+
return models;
|
|
43365
|
+
}
|
|
43366
|
+
};
|
|
43367
|
+
}
|
|
43368
|
+
});
|
|
43369
|
+
|
|
43330
43370
|
// src/assets/BannerPatterns.ts
|
|
43331
43371
|
var DYE_COLORS, BannerPatterns;
|
|
43332
43372
|
var init_BannerPatterns = __esm({
|
|
@@ -43667,6 +43707,7 @@ ${key}` : key, async () => {
|
|
|
43667
43707
|
init_dirname();
|
|
43668
43708
|
init_buffer2();
|
|
43669
43709
|
init_process2();
|
|
43710
|
+
init_Renames();
|
|
43670
43711
|
init_Caching();
|
|
43671
43712
|
init_ModelMerger();
|
|
43672
43713
|
init_AssetLoader();
|
|
@@ -43996,6 +44037,11 @@ ${key}` : key, async () => {
|
|
|
43996
44037
|
key.extension = ".json";
|
|
43997
44038
|
}
|
|
43998
44039
|
const preview = this.snapshotContext(key, context);
|
|
44040
|
+
if (key.type === "item") {
|
|
44041
|
+
const renamed = await Renames.key("items", key);
|
|
44042
|
+
const replacement = renamed && await this.getMerged(renamed, preview);
|
|
44043
|
+
if (replacement) return replacement;
|
|
44044
|
+
}
|
|
43999
44045
|
const dataKey = await this.applyDefaults(key, preview);
|
|
44000
44046
|
const keyStr = AssetLoader.persistentKey(key.serialize() + (key.type === "item" ? this.contextKey(preview) + dataKey : ""));
|
|
44001
44047
|
const model = await Caching.mergedModelCache.get(keyStr, async () => {
|
|
@@ -44032,6 +44078,7 @@ ${key}` : key, async () => {
|
|
|
44032
44078
|
init_AssetKey();
|
|
44033
44079
|
init_PersistentCache();
|
|
44034
44080
|
init_AssetParsers();
|
|
44081
|
+
init_Renames();
|
|
44035
44082
|
init_MineRenderData();
|
|
44036
44083
|
BlockStates = class {
|
|
44037
44084
|
static get PERSISTENT_CACHE() {
|
|
@@ -44072,6 +44119,9 @@ ${key}` : key, async () => {
|
|
|
44072
44119
|
if (!key.extension) {
|
|
44073
44120
|
key.extension = ".json";
|
|
44074
44121
|
}
|
|
44122
|
+
const renamed = await Renames.key("blocks", key);
|
|
44123
|
+
const replacement = renamed && await this.get(renamed);
|
|
44124
|
+
if (replacement) return replacement;
|
|
44075
44125
|
const keyStr = key.serialize();
|
|
44076
44126
|
return Caching.blockStateCache.get(keyStr, (k4) => {
|
|
44077
44127
|
return this.PERSISTENT_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), (k1) => {
|
|
@@ -95449,6 +95499,7 @@ ${shader.fragmentShader}`.replace(
|
|
|
95449
95499
|
PackMetadata: () => PackMetadata,
|
|
95450
95500
|
PersistentCache: () => PersistentCache,
|
|
95451
95501
|
PlayerHeadTextures: () => PlayerHeadTextures,
|
|
95502
|
+
Renames: () => Renames,
|
|
95452
95503
|
Renderer: () => Renderer,
|
|
95453
95504
|
RequestError: () => RequestError,
|
|
95454
95505
|
Requests: () => Requests,
|
|
@@ -96143,6 +96194,7 @@ ${shader.fragmentShader}`.replace(
|
|
|
96143
96194
|
init_MineRenderData();
|
|
96144
96195
|
init_ModelTextures();
|
|
96145
96196
|
init_Models();
|
|
96197
|
+
init_Renames();
|
|
96146
96198
|
init_source();
|
|
96147
96199
|
|
|
96148
96200
|
// src/bedrock/index.ts
|
|
@@ -107795,6 +107847,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
107795
107847
|
init_dirname();
|
|
107796
107848
|
init_buffer2();
|
|
107797
107849
|
init_process2();
|
|
107850
|
+
init_Renames();
|
|
107798
107851
|
init_Entities();
|
|
107799
107852
|
init_EntityObject();
|
|
107800
107853
|
|
|
@@ -107960,8 +108013,10 @@ gl_FragDepth=readDepth(vUv);
|
|
|
107960
108013
|
try {
|
|
107961
108014
|
if (!current()) return;
|
|
107962
108015
|
const models = await Entities.getEntityList();
|
|
107963
|
-
|
|
107964
|
-
const
|
|
108016
|
+
const renamed = models.includes(placement.key.path) ? void 0 : await Renames.key("entities", placement.key);
|
|
108017
|
+
const key = renamed && models.includes(renamed.path) ? renamed : placement.key;
|
|
108018
|
+
if (!models.includes(key.path) || !current()) return;
|
|
108019
|
+
const model = await Entities.getEntity(key, placement.texture, { when: placement.when });
|
|
107965
108020
|
if (!model || !current()) return;
|
|
107966
108021
|
let tints = placement.tints;
|
|
107967
108022
|
if (placement.woolDye) {
|
|
@@ -107976,7 +108031,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
107976
108031
|
object4.rotation.y = placement.yaw;
|
|
107977
108032
|
await object4.init();
|
|
107978
108033
|
if (!current()) return;
|
|
107979
|
-
placement.owner.set(object4, { type:
|
|
108034
|
+
placement.owner.set(object4, { type: key.toNamespacedString(), position: placement.position });
|
|
107980
108035
|
this.scene.add(object4);
|
|
107981
108036
|
} catch (error2) {
|
|
107982
108037
|
console.warn(`Could not draw saved entity ${placement.key.toNamespacedString()}, skipping it`, error2);
|
|
@@ -108033,6 +108088,41 @@ gl_FragDepth=readDepth(vUv);
|
|
|
108033
108088
|
};
|
|
108034
108089
|
}
|
|
108035
108090
|
|
|
108091
|
+
// src/world/_culling/BlockCulling.ts
|
|
108092
|
+
init_dirname();
|
|
108093
|
+
init_buffer2();
|
|
108094
|
+
init_process2();
|
|
108095
|
+
init_Assets();
|
|
108096
|
+
init_MineRenderData();
|
|
108097
|
+
init_CubeFace();
|
|
108098
|
+
async function loadBlockCulling(root) {
|
|
108099
|
+
const { manifest } = await MineRenderData.resolve(root);
|
|
108100
|
+
return manifest.datasets.blockCulling ? MineRenderData.get("blockCulling", root) : void 0;
|
|
108101
|
+
}
|
|
108102
|
+
function blockCullingRule(data, type) {
|
|
108103
|
+
if (!type.includes(":")) type = `${DEFAULT_NAMESPACE}:${type}`;
|
|
108104
|
+
return Object.prototype.hasOwnProperty.call(data.blocks, type) ? data.profiles[data.blocks[type]] : void 0;
|
|
108105
|
+
}
|
|
108106
|
+
function skipsBlockFace(data, rule, block, neighbor, face) {
|
|
108107
|
+
const type = block.type.includes(":") ? block.type : `${DEFAULT_NAMESPACE}:${block.type}`;
|
|
108108
|
+
const other = neighbor.type.includes(":") ? neighbor.type : `${DEFAULT_NAMESPACE}:${neighbor.type}`;
|
|
108109
|
+
const same = type === other;
|
|
108110
|
+
const vertical = CUBE_FACES[face] === "up" /* UP */ || CUBE_FACES[face] === "down" /* DOWN */;
|
|
108111
|
+
switch (rule.type) {
|
|
108112
|
+
case "same_block":
|
|
108113
|
+
return same;
|
|
108114
|
+
case "same_block_vertical":
|
|
108115
|
+
return same && vertical;
|
|
108116
|
+
case "connected": {
|
|
108117
|
+
if (vertical) return same;
|
|
108118
|
+
const group = rule.group ? data.groups?.[rule.group] : void 0;
|
|
108119
|
+
return (same || !!group?.includes(type) && group.includes(other)) && String(block.properties?.[CUBE_FACES[face]]) === "true" && String(neighbor.properties?.[CUBE_FACES[face ^ 1]]) === "true";
|
|
108120
|
+
}
|
|
108121
|
+
default:
|
|
108122
|
+
return false;
|
|
108123
|
+
}
|
|
108124
|
+
}
|
|
108125
|
+
|
|
108036
108126
|
// src/world/MineRenderWorld.ts
|
|
108037
108127
|
var MineRenderWorld = class {
|
|
108038
108128
|
constructor(scene, options = {}) {
|
|
@@ -108421,15 +108511,23 @@ gl_FragDepth=readDepth(vUv);
|
|
|
108421
108511
|
return this.culling ?? (this.culling = Promise.resolve().then(async () => {
|
|
108422
108512
|
let sliceStart = performance.now();
|
|
108423
108513
|
try {
|
|
108514
|
+
const culling = await loadBlockCulling();
|
|
108424
108515
|
while (this.pendingCulling.size) {
|
|
108425
108516
|
const batch = [...this.pendingCulling];
|
|
108426
108517
|
this.pendingCulling.clear();
|
|
108427
108518
|
for (const [chunk, indices] of batch) {
|
|
108428
108519
|
const neighbors = CUBE_FACE_OFFSETS.map(([x4, y5, z4]) => this._chunks.get(`${chunk.x + x4}_${chunk.y + y5}_${chunk.z + z4}`));
|
|
108429
|
-
const
|
|
108520
|
+
const neighborAt = (x4, y5, z4) => {
|
|
108430
108521
|
const lx = x4 - chunk.x * 16, ly = y5 - chunk.y * 16, lz = z4 - chunk.z * 16;
|
|
108431
108522
|
const section = neighbors[lx >= 16 ? 0 : lx < 0 ? 1 : ly >= 16 ? 2 : ly < 0 ? 3 : lz >= 16 ? 4 : 5];
|
|
108432
|
-
return section
|
|
108523
|
+
return [section, (ly & 15) * 256 + (lz & 15) * 16 + (lx & 15)];
|
|
108524
|
+
};
|
|
108525
|
+
const masks = chunk.updateCullMasks(indices === "all" ? void 0 : indices, (x4, y5, z4) => {
|
|
108526
|
+
const [section, i4] = neighborAt(x4, y5, z4);
|
|
108527
|
+
return section?.isOccludingIndex(i4) ?? false;
|
|
108528
|
+
}, culling, (x4, y5, z4) => {
|
|
108529
|
+
const [section, i4] = neighborAt(x4, y5, z4);
|
|
108530
|
+
return section?.visibleBlockIndex(i4);
|
|
108433
108531
|
});
|
|
108434
108532
|
const fluidIndices = indices === "all" ? function* () {
|
|
108435
108533
|
for (let index = 0; index < 4096; index++) yield index;
|
|
@@ -109559,6 +109657,10 @@ gl_FragDepth=readDepth(vUv);
|
|
|
109559
109657
|
isBlockVisibleIndex(index) {
|
|
109560
109658
|
return this.renderedBlocks.has(index) && !this.hiddenBlocks.has(index);
|
|
109561
109659
|
}
|
|
109660
|
+
/** Stored state of a rendered, visible cell, or `undefined`. */
|
|
109661
|
+
visibleBlockIndex(index) {
|
|
109662
|
+
return this.isBlockVisibleIndex(index) ? this.data.stateAt(this.data.idAt(index)) : void 0;
|
|
109663
|
+
}
|
|
109562
109664
|
/** Fluid kind bits and level of a cell, or 0. Hidden cells report 0. */
|
|
109563
109665
|
fluidByteIndex(index) {
|
|
109564
109666
|
return this.hiddenBlocks.has(index) ? 0 : this.fluidCells[index];
|
|
@@ -109577,18 +109679,30 @@ gl_FragDepth=readDepth(vUv);
|
|
|
109577
109679
|
async setCullMaskAt(pos, mask) {
|
|
109578
109680
|
await this.setCullMaskIndex(_Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos)), mask);
|
|
109579
109681
|
}
|
|
109580
|
-
/**
|
|
109581
|
-
|
|
109682
|
+
/**
|
|
109683
|
+
* Recomputes section masks and returns changed per-block masks. Omit indices to visit every cell.
|
|
109684
|
+
* `culling` supplies neighbor face rules; `blockAt` supplies visible states outside this chunk.
|
|
109685
|
+
*/
|
|
109686
|
+
updateCullMasks(indices, occludes, culling, blockAt) {
|
|
109582
109687
|
const changed = [];
|
|
109688
|
+
const rules = [];
|
|
109583
109689
|
for (const index of indices ?? this.fluidCells.keys()) {
|
|
109584
109690
|
if (!this.isBlockVisibleIndex(index)) continue;
|
|
109585
109691
|
const x4 = index % 16, y5 = Math.floor(index / 256), z4 = Math.floor(index / 16) % 16;
|
|
109692
|
+
const id = this.data.idAt(index);
|
|
109693
|
+
let rule = rules[id];
|
|
109694
|
+
if (culling && rule === void 0) rules[id] = rule = blockCullingRule(culling, this.data.stateAt(id).type) ?? null;
|
|
109695
|
+
const block = rule ? this.data.stateAt(id) : void 0;
|
|
109586
109696
|
let mask = 0;
|
|
109587
109697
|
for (let face = 0; face < CUBE_FACE_OFFSETS.length; face++) {
|
|
109588
109698
|
const [dx, dy, dz] = CUBE_FACE_OFFSETS[face];
|
|
109589
109699
|
const nx = x4 + dx, ny = y5 + dy, nz = z4 + dz;
|
|
109590
109700
|
const inner = nx >= 0 && nx < 16 && ny >= 0 && ny < 16 && nz >= 0 && nz < 16;
|
|
109591
109701
|
if (inner ? this.isOccludingIndex(ny * 256 + nz * 16 + nx) : occludes(this.x * 16 + nx, this.y * 16 + ny, this.z * 16 + nz)) mask |= 1 << face;
|
|
109702
|
+
else if (rule) {
|
|
109703
|
+
const neighbor = inner ? this.visibleBlockIndex(ny * 256 + nz * 16 + nx) : blockAt?.(this.x * 16 + nx, this.y * 16 + ny, this.z * 16 + nz);
|
|
109704
|
+
if (neighbor && skipsBlockFace(culling, rule, block, neighbor, face)) mask |= 1 << face;
|
|
109705
|
+
}
|
|
109592
109706
|
}
|
|
109593
109707
|
if (this.fluidCells[index]) this.meshDirty = true;
|
|
109594
109708
|
const entries = this.sectionBlocks.get(index);
|