minerender 2.1.0-alpha.125 → 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/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,132 +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.withHandFallbacks(display)?.[position] ?? {};
43102
- const left = position === "firstperson_lefthand" /* FIRSTPERSON_LEFTHAND */ || position === "thirdperson_lefthand" /* THIRDPERSON_LEFTHAND */;
43103
- const sign = left ? -1 : 1;
43104
- const [x4, y5, z4] = transform.rotation ?? [0, 0, 0];
43105
- const rotation = new Quaternion().setFromEuler(new Euler(toRadians(x4), sign * toRadians(y5), sign * toRadians(z4), "XYZ"));
43106
- const translation = new Vector3(...transform.translation ?? [0, 0, 0]).clampScalar(-80, 80);
43107
- translation.x *= sign;
43108
- const scale = new Vector3(...transform.scale ?? [1, 1, 1]).clampScalar(-4, 4);
43109
- return new Matrix4().compose(translation, rotation, scale);
43110
- }
43111
- /** Transforms geometry in place and reverses triangle winding when the matrix reflects it. */
43112
- static apply(geometry, matrix) {
43113
- geometry.applyMatrix4(matrix);
43114
- if (matrix.determinant() < 0) {
43115
- if (!geometry.index) geometry.setIndex(Array.from({ length: geometry.getAttribute("position").count }, (_4, i4) => i4));
43116
- const index = geometry.index;
43117
- for (let i4 = 0; i4 < index.count; i4 += 3) {
43118
- const second = index.getX(i4 + 1);
43119
- index.setX(i4 + 1, index.getX(i4 + 2));
43120
- index.setX(i4 + 2, second);
43121
- }
43122
- index.needsUpdate = true;
43123
- }
43124
- }
43125
- };
43126
- }
43127
- });
43128
-
43129
- // src/model/ModelMerger.ts
43130
- var import_ts_deepmerge, ModelMerger;
43131
- var init_ModelMerger = __esm({
43132
- "src/model/ModelMerger.ts"() {
43133
- init_dirname();
43134
- init_buffer2();
43135
- init_process2();
43136
- init_Model();
43137
- init_Models();
43138
- import_ts_deepmerge = __toESM(require_dist());
43139
- init_AssetKey();
43140
- init_DisplayTransforms();
43141
- ModelMerger = class {
43142
- /** Loads the parent chain and returns a merged model without modifying the supplied definition. */
43143
- static async mergeWithParents(model) {
43144
- const parts = model.parts;
43145
- if (parts) return { ...model, parts: await Promise.all(parts.map((part) => this.mergeWithParents(part))) };
43146
- const models = await this.collectAllParents(model);
43147
- let merged = {};
43148
- for (const source of [...models, model]) {
43149
- const inheritedDisplay = merged.display;
43150
- merged = import_ts_deepmerge.default.withOptions({ mergeArrays: false }, merged, source);
43151
- if (source.display) {
43152
- merged.display = { ...inheritedDisplay, ...DisplayTransforms.withHandFallbacks(source.display) };
43153
- }
43154
- }
43155
- merged.hierarchy = models.map((m4) => m4.parent).filter((p14) => `${p14}`);
43156
- merged.hierarchy.push(`${merged.parent}`);
43157
- if (model.components) merged.components = model.components;
43158
- return merged;
43159
- }
43160
- static async collectAllParents(model) {
43161
- if (!model.parent) {
43162
- return [];
43163
- }
43164
- const models = [];
43165
- const parentKey = AssetKey.parse("models", model.parent);
43166
- if (parentKey.namespace === "minecraft" && parentKey.getFullPath() === BUILTIN_ENTITY) return models;
43167
- parentKey.root = model.key?.root;
43168
- const parentModel = await Models.getRaw(parentKey);
43169
- if (parentModel) {
43170
- models.unshift(parentModel);
43171
- models.unshift(...await this.collectAllParents(parentModel));
43172
- }
43173
- return models;
43174
- }
43175
- };
43176
- }
43177
- });
43178
-
43179
42935
  // src/assets/source/parser/AssetParsers.ts
43180
42936
  var AssetParser;
43181
42937
  var init_AssetParsers = __esm({
@@ -43299,7 +43055,9 @@ ${key}` : key, async () => {
43299
43055
  static validDataset(dataset, data) {
43300
43056
  if (!object(data)) return false;
43301
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")));
43302
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")));
43303
43061
  return Object.values(data).every((value) => {
43304
43062
  if (!object(value)) return false;
43305
43063
  switch (dataset) {
@@ -43322,6 +43080,293 @@ ${key}` : key, async () => {
43322
43080
  }
43323
43081
  });
43324
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
+
43325
43370
  // src/assets/BannerPatterns.ts
43326
43371
  var DYE_COLORS, BannerPatterns;
43327
43372
  var init_BannerPatterns = __esm({
@@ -43662,6 +43707,7 @@ ${key}` : key, async () => {
43662
43707
  init_dirname();
43663
43708
  init_buffer2();
43664
43709
  init_process2();
43710
+ init_Renames();
43665
43711
  init_Caching();
43666
43712
  init_ModelMerger();
43667
43713
  init_AssetLoader();
@@ -43991,6 +44037,11 @@ ${key}` : key, async () => {
43991
44037
  key.extension = ".json";
43992
44038
  }
43993
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
+ }
43994
44045
  const dataKey = await this.applyDefaults(key, preview);
43995
44046
  const keyStr = AssetLoader.persistentKey(key.serialize() + (key.type === "item" ? this.contextKey(preview) + dataKey : ""));
43996
44047
  const model = await Caching.mergedModelCache.get(keyStr, async () => {
@@ -44027,6 +44078,7 @@ ${key}` : key, async () => {
44027
44078
  init_AssetKey();
44028
44079
  init_PersistentCache();
44029
44080
  init_AssetParsers();
44081
+ init_Renames();
44030
44082
  init_MineRenderData();
44031
44083
  BlockStates = class {
44032
44084
  static get PERSISTENT_CACHE() {
@@ -44067,6 +44119,9 @@ ${key}` : key, async () => {
44067
44119
  if (!key.extension) {
44068
44120
  key.extension = ".json";
44069
44121
  }
44122
+ const renamed = await Renames.key("blocks", key);
44123
+ const replacement = renamed && await this.get(renamed);
44124
+ if (replacement) return replacement;
44070
44125
  const keyStr = key.serialize();
44071
44126
  return Caching.blockStateCache.get(keyStr, (k4) => {
44072
44127
  return this.PERSISTENT_CACHE.getOrLoad(AssetLoader.persistentKey(keyStr), (k1) => {
@@ -94784,16 +94839,21 @@ ${shader.fragmentShader}`.replace(
94784
94839
  const special = this.originalModel.special;
94785
94840
  if (special) {
94786
94841
  const parts2 = await SpecialItems.getParts(special, this.originalModel.key?.root, this.originalModel.components);
94787
- const transform = this.options.displayPosition ? DisplayTransforms.getMatrix(this.originalModel.display, this.options.displayPosition) : new Matrix4();
94788
- transform.multiply(new Matrix4().makeTranslation(-8, -8, -8));
94842
+ const display = new SceneObject();
94843
+ if (this.options.displayPosition) {
94844
+ const transform = DisplayTransforms.getTransform(this.originalModel.display, this.options.displayPosition);
94845
+ display.position.copy(transform.position);
94846
+ display.quaternion.copy(transform.quaternion);
94847
+ display.scale.copy(transform.scale);
94848
+ }
94849
+ this.add(display);
94850
+ const offset = new Matrix4().makeTranslation(-8, -8, -8);
94789
94851
  try {
94790
94852
  const targets = [];
94791
94853
  for (const part of parts2) {
94792
94854
  const object4 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe, tints: part.tints, faces: part.faces });
94793
- object4.matrix.copy(transform).multiply(part.transform);
94794
- object4.matrixWorldNeedsUpdate = true;
94795
- object4.matrixAutoUpdate = false;
94796
- this.add(object4);
94855
+ object4.matrix.multiplyMatrices(offset, part.transform).decompose(object4.position, object4.quaternion, object4.scale);
94856
+ display.add(object4);
94797
94857
  await object4.init(part.material);
94798
94858
  object4.iterateAllMeshes((mesh) => {
94799
94859
  const source = mesh.material;
@@ -95439,6 +95499,7 @@ ${shader.fragmentShader}`.replace(
95439
95499
  PackMetadata: () => PackMetadata,
95440
95500
  PersistentCache: () => PersistentCache,
95441
95501
  PlayerHeadTextures: () => PlayerHeadTextures,
95502
+ Renames: () => Renames,
95442
95503
  Renderer: () => Renderer,
95443
95504
  RequestError: () => RequestError,
95444
95505
  Requests: () => Requests,
@@ -96133,6 +96194,7 @@ ${shader.fragmentShader}`.replace(
96133
96194
  init_MineRenderData();
96134
96195
  init_ModelTextures();
96135
96196
  init_Models();
96197
+ init_Renames();
96136
96198
  init_source();
96137
96199
 
96138
96200
  // src/bedrock/index.ts
@@ -107785,6 +107847,7 @@ gl_FragDepth=readDepth(vUv);
107785
107847
  init_dirname();
107786
107848
  init_buffer2();
107787
107849
  init_process2();
107850
+ init_Renames();
107788
107851
  init_Entities();
107789
107852
  init_EntityObject();
107790
107853
 
@@ -107950,8 +108013,10 @@ gl_FragDepth=readDepth(vUv);
107950
108013
  try {
107951
108014
  if (!current()) return;
107952
108015
  const models = await Entities.getEntityList();
107953
- if (!models.includes(placement.key.path) || !current()) return;
107954
- const model = await Entities.getEntity(placement.key, placement.texture, { when: placement.when });
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 });
107955
108020
  if (!model || !current()) return;
107956
108021
  let tints = placement.tints;
107957
108022
  if (placement.woolDye) {
@@ -107966,7 +108031,7 @@ gl_FragDepth=readDepth(vUv);
107966
108031
  object4.rotation.y = placement.yaw;
107967
108032
  await object4.init();
107968
108033
  if (!current()) return;
107969
- placement.owner.set(object4, { type: placement.key.toNamespacedString(), position: placement.position });
108034
+ placement.owner.set(object4, { type: key.toNamespacedString(), position: placement.position });
107970
108035
  this.scene.add(object4);
107971
108036
  } catch (error2) {
107972
108037
  console.warn(`Could not draw saved entity ${placement.key.toNamespacedString()}, skipping it`, error2);
@@ -108023,6 +108088,41 @@ gl_FragDepth=readDepth(vUv);
108023
108088
  };
108024
108089
  }
108025
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
+
108026
108126
  // src/world/MineRenderWorld.ts
108027
108127
  var MineRenderWorld = class {
108028
108128
  constructor(scene, options = {}) {
@@ -108411,15 +108511,23 @@ gl_FragDepth=readDepth(vUv);
108411
108511
  return this.culling ?? (this.culling = Promise.resolve().then(async () => {
108412
108512
  let sliceStart = performance.now();
108413
108513
  try {
108514
+ const culling = await loadBlockCulling();
108414
108515
  while (this.pendingCulling.size) {
108415
108516
  const batch = [...this.pendingCulling];
108416
108517
  this.pendingCulling.clear();
108417
108518
  for (const [chunk, indices] of batch) {
108418
108519
  const neighbors = CUBE_FACE_OFFSETS.map(([x4, y5, z4]) => this._chunks.get(`${chunk.x + x4}_${chunk.y + y5}_${chunk.z + z4}`));
108419
- const masks = chunk.updateCullMasks(indices === "all" ? void 0 : indices, (x4, y5, z4) => {
108520
+ const neighborAt = (x4, y5, z4) => {
108420
108521
  const lx = x4 - chunk.x * 16, ly = y5 - chunk.y * 16, lz = z4 - chunk.z * 16;
108421
108522
  const section = neighbors[lx >= 16 ? 0 : lx < 0 ? 1 : ly >= 16 ? 2 : ly < 0 ? 3 : lz >= 16 ? 4 : 5];
108422
- return section?.isOccludingIndex((ly & 15) * 256 + (lz & 15) * 16 + (lx & 15)) ?? false;
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);
108423
108531
  });
108424
108532
  const fluidIndices = indices === "all" ? function* () {
108425
108533
  for (let index = 0; index < 4096; index++) yield index;
@@ -109549,6 +109657,10 @@ gl_FragDepth=readDepth(vUv);
109549
109657
  isBlockVisibleIndex(index) {
109550
109658
  return this.renderedBlocks.has(index) && !this.hiddenBlocks.has(index);
109551
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
+ }
109552
109664
  /** Fluid kind bits and level of a cell, or 0. Hidden cells report 0. */
109553
109665
  fluidByteIndex(index) {
109554
109666
  return this.hiddenBlocks.has(index) ? 0 : this.fluidCells[index];
@@ -109567,18 +109679,30 @@ gl_FragDepth=readDepth(vUv);
109567
109679
  async setCullMaskAt(pos, mask) {
109568
109680
  await this.setCullMaskIndex(_Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos)), mask);
109569
109681
  }
109570
- /** Recomputes section masks and returns changed per-block masks. Omit indices to visit every cell. */
109571
- updateCullMasks(indices, occludes) {
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) {
109572
109687
  const changed = [];
109688
+ const rules = [];
109573
109689
  for (const index of indices ?? this.fluidCells.keys()) {
109574
109690
  if (!this.isBlockVisibleIndex(index)) continue;
109575
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;
109576
109696
  let mask = 0;
109577
109697
  for (let face = 0; face < CUBE_FACE_OFFSETS.length; face++) {
109578
109698
  const [dx, dy, dz] = CUBE_FACE_OFFSETS[face];
109579
109699
  const nx = x4 + dx, ny = y5 + dy, nz = z4 + dz;
109580
109700
  const inner = nx >= 0 && nx < 16 && ny >= 0 && ny < 16 && nz >= 0 && nz < 16;
109581
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
+ }
109582
109706
  }
109583
109707
  if (this.fluidCells[index]) this.meshDirty = true;
109584
109708
  const entries = this.sectionBlocks.get(index);