minerender 2.1.0-alpha.44 → 2.1.0-alpha.46
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 +11 -3
- package/dist/browser/index.d.ts +11 -3
- package/dist/browser/index.js +54 -18
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +54 -18
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +54 -18
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +11 -3
- package/dist/node/index.d.ts +11 -3
- package/dist/node/index.js +55 -18
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +54 -18
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -4220,11 +4220,35 @@ var init_ModelObject = __esm({
|
|
|
4220
4220
|
}
|
|
4221
4221
|
});
|
|
4222
4222
|
|
|
4223
|
+
// src/model/fluid/fluidBlocks.json
|
|
4224
|
+
var fluidBlocks_default;
|
|
4225
|
+
var init_fluidBlocks = __esm({
|
|
4226
|
+
"src/model/fluid/fluidBlocks.json"() {
|
|
4227
|
+
fluidBlocks_default = {
|
|
4228
|
+
"minecraft:water": { kind: "water", levelProperty: "level", renderModel: false },
|
|
4229
|
+
"minecraft:lava": { kind: "lava", levelProperty: "level", renderModel: false },
|
|
4230
|
+
"minecraft:kelp": { kind: "water", renderModel: true },
|
|
4231
|
+
"minecraft:kelp_plant": { kind: "water", renderModel: true },
|
|
4232
|
+
"minecraft:seagrass": { kind: "water", renderModel: true },
|
|
4233
|
+
"minecraft:tall_seagrass": { kind: "water", renderModel: true },
|
|
4234
|
+
"minecraft:bubble_column": { kind: "water", renderModel: false }
|
|
4235
|
+
};
|
|
4236
|
+
}
|
|
4237
|
+
});
|
|
4238
|
+
|
|
4223
4239
|
// src/model/fluid/FluidGeometry.ts
|
|
4224
4240
|
import { BufferGeometry as BufferGeometry2, Float32BufferAttribute as Float32BufferAttribute4 } from "three";
|
|
4225
|
-
function
|
|
4226
|
-
|
|
4227
|
-
|
|
4241
|
+
function getBlockFluidState(key, state) {
|
|
4242
|
+
const rule = key && fluidRules[key.toNamespacedString()];
|
|
4243
|
+
if (rule) return {
|
|
4244
|
+
kind: rule.kind,
|
|
4245
|
+
level: rule.levelProperty ? Number(state?.[rule.levelProperty] ?? 0) : 0,
|
|
4246
|
+
renderModel: rule.renderModel
|
|
4247
|
+
};
|
|
4248
|
+
return state?.waterlogged === "true" ? { kind: "water", level: 0, renderModel: true } : void 0;
|
|
4249
|
+
}
|
|
4250
|
+
function getFluidKind(key, state) {
|
|
4251
|
+
return getBlockFluidState(key, state)?.kind;
|
|
4228
4252
|
}
|
|
4229
4253
|
function ownHeight(sample) {
|
|
4230
4254
|
const level = sample.level ?? 0;
|
|
@@ -4336,9 +4360,11 @@ function createFluidGeometry(kind, sample) {
|
|
|
4336
4360
|
geometry.setIndex(indices);
|
|
4337
4361
|
return geometry;
|
|
4338
4362
|
}
|
|
4339
|
-
var HORIZONTAL, EPSILON;
|
|
4363
|
+
var fluidRules, HORIZONTAL, EPSILON;
|
|
4340
4364
|
var init_FluidGeometry = __esm({
|
|
4341
4365
|
"src/model/fluid/FluidGeometry.ts"() {
|
|
4366
|
+
init_fluidBlocks();
|
|
4367
|
+
fluidRules = fluidBlocks_default;
|
|
4342
4368
|
HORIZONTAL = [[0, -1], [0, 1], [-1, 0], [1, 0]];
|
|
4343
4369
|
EPSILON = 1e-3;
|
|
4344
4370
|
}
|
|
@@ -4376,7 +4402,7 @@ var init_FluidModelObject = __esm({
|
|
|
4376
4402
|
FluidModelObject = class extends ModelObject {
|
|
4377
4403
|
constructor(kind, sample, origin, options) {
|
|
4378
4404
|
super({
|
|
4379
|
-
key: new AssetKey("minecraft", kind, "models", "fluid", "assets", ".json", origin
|
|
4405
|
+
key: new AssetKey("minecraft", kind, "models", "fluid", "assets", ".json", origin?.root),
|
|
4380
4406
|
textures: { still: `minecraft:block/${kind}_still`, flow: `minecraft:block/${kind}_flow` },
|
|
4381
4407
|
elements: []
|
|
4382
4408
|
}, options);
|
|
@@ -5562,6 +5588,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5562
5588
|
clearModels() {
|
|
5563
5589
|
this.removeModels(this._models.splice(0));
|
|
5564
5590
|
this._fluidKey = void 0;
|
|
5591
|
+
this._fluidModel = void 0;
|
|
5565
5592
|
this._isInstanced = false;
|
|
5566
5593
|
this._instanceCounter = 0;
|
|
5567
5594
|
}
|
|
@@ -5593,11 +5620,14 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5593
5620
|
return ModelCulling.toLocalMask(worldMask, new Euler7().setFromQuaternion(rotation));
|
|
5594
5621
|
}
|
|
5595
5622
|
async setCullMask(worldMask) {
|
|
5596
|
-
if (this.fluidKind) return;
|
|
5597
5623
|
worldMask &= 63;
|
|
5598
5624
|
const replacements = [];
|
|
5599
5625
|
try {
|
|
5600
5626
|
for (const model of this._models) {
|
|
5627
|
+
if (model === this._fluidModel) {
|
|
5628
|
+
replacements.push(model);
|
|
5629
|
+
continue;
|
|
5630
|
+
}
|
|
5601
5631
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
5602
5632
|
const cullMask = this.getModelCullMask(model, worldMask);
|
|
5603
5633
|
if (cullMask === (object.options.cullMask ?? 0)) {
|
|
@@ -5630,7 +5660,10 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5630
5660
|
return this._state;
|
|
5631
5661
|
}
|
|
5632
5662
|
get fluidKind() {
|
|
5633
|
-
return getFluidKind(this.blockState.key);
|
|
5663
|
+
return getFluidKind(this.blockState.key, this.state);
|
|
5664
|
+
}
|
|
5665
|
+
get fluidLevel() {
|
|
5666
|
+
return getBlockFluidState(this.blockState.key, this.state)?.level ?? 0;
|
|
5634
5667
|
}
|
|
5635
5668
|
/** Refreshes fluid surfaces from relative neighbors; standalone previews use air around the block. */
|
|
5636
5669
|
async updateFluid(sample) {
|
|
@@ -5638,22 +5671,24 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5638
5671
|
if (!kind) return;
|
|
5639
5672
|
const { FluidModelObject: FluidModelObject2, sampleFluid: sampleFluid2 } = await Promise.resolve().then(() => (init_FluidModelObject(), FluidModelObject_exports));
|
|
5640
5673
|
this._fluidSampler = sample;
|
|
5641
|
-
const surface = sampleFluid2(kind, (x, y, z) => x === 0 && y === 0 && z === 0 ? { fluid: kind, level:
|
|
5674
|
+
const surface = sampleFluid2(kind, (x, y, z) => x === 0 && y === 0 && z === 0 ? { fluid: kind, level: this.fluidLevel } : sample?.(x, y, z) ?? {});
|
|
5642
5675
|
if (this._fluidKey === surface.key) return;
|
|
5643
|
-
const key = new AssetKey("minecraft", `${kind}/${surface.key}`, "models", "fluid", "assets", ".json", this.blockState.key
|
|
5676
|
+
const key = new AssetKey("minecraft", `${kind}/${surface.key}`, "models", "fluid", "assets", ".json", this.blockState.key?.root);
|
|
5644
5677
|
const replacement = await this.scene.addSceneObject(
|
|
5645
5678
|
{ key },
|
|
5646
5679
|
() => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
|
|
5647
5680
|
);
|
|
5648
|
-
const previous = this.
|
|
5649
|
-
const matrix = previous
|
|
5681
|
+
const previous = this._fluidModel;
|
|
5682
|
+
const matrix = previous ? this.getModelMatrix(previous) : new Matrix45().makeTranslation(...this.position.toArray());
|
|
5650
5683
|
if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
|
|
5651
5684
|
else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
5652
|
-
this._models =
|
|
5685
|
+
this._models = this._models.filter((model) => model !== previous);
|
|
5686
|
+
this._models.push(replacement);
|
|
5687
|
+
this._fluidModel = replacement;
|
|
5653
5688
|
this._fluidKey = surface.key;
|
|
5654
|
-
this._isInstanced
|
|
5689
|
+
this._isInstanced ||= isInstanceReference(replacement);
|
|
5655
5690
|
this._instanceCounter = this._isInstanced ? 1 : 0;
|
|
5656
|
-
this.removeModels(previous);
|
|
5691
|
+
if (previous) this.removeModels([previous]);
|
|
5657
5692
|
this.notifyDirty();
|
|
5658
5693
|
}
|
|
5659
5694
|
nextInstance() {
|
|
@@ -5670,7 +5705,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5670
5705
|
}
|
|
5671
5706
|
async recreateModels() {
|
|
5672
5707
|
this.clearModels();
|
|
5673
|
-
if (this.
|
|
5708
|
+
if (getBlockFluidState(this.blockState.key, this.state)?.renderModel === false) {
|
|
5674
5709
|
await this.updateFluid(this._fluidSampler);
|
|
5675
5710
|
return;
|
|
5676
5711
|
}
|
|
@@ -5679,6 +5714,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5679
5714
|
for (let blockStateVariant of variantsToCreate) {
|
|
5680
5715
|
this._models.push(await this.createVariant(blockStateVariant));
|
|
5681
5716
|
}
|
|
5717
|
+
await this.updateFluid(this._fluidSampler);
|
|
5682
5718
|
}
|
|
5683
5719
|
getSingleVariant(variants) {
|
|
5684
5720
|
return BlockStateResolver.choose(variants);
|
|
@@ -10504,11 +10540,10 @@ var MineRenderWorld = class {
|
|
|
10504
10540
|
const object = section?.getBlockAt(neighbor)?.object;
|
|
10505
10541
|
return {
|
|
10506
10542
|
fluid: object?.fluidKind,
|
|
10507
|
-
level:
|
|
10543
|
+
level: object?.fluidLevel,
|
|
10508
10544
|
solid: section?.isOccludingAt(neighbor) ?? false
|
|
10509
10545
|
};
|
|
10510
10546
|
});
|
|
10511
|
-
continue;
|
|
10512
10547
|
}
|
|
10513
10548
|
let mask = 0;
|
|
10514
10549
|
for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
@@ -10737,7 +10772,7 @@ var Chunk = class _Chunk {
|
|
|
10737
10772
|
this.data.set(index, void 0);
|
|
10738
10773
|
return void 0;
|
|
10739
10774
|
}
|
|
10740
|
-
const template = getFluidKind(blockState.key) ? void 0 : await this.sectionModels?.get(blockState, stored.properties);
|
|
10775
|
+
const template = getFluidKind(blockState.key, stored.properties) ? void 0 : await this.sectionModels?.get(blockState, stored.properties);
|
|
10741
10776
|
if (template) {
|
|
10742
10777
|
this.sectionBlocks.set(index, { index, template, cullMask: 0 });
|
|
10743
10778
|
this.meshDirty = true;
|
|
@@ -10942,6 +10977,7 @@ export {
|
|
|
10942
10977
|
createFluidGeometry,
|
|
10943
10978
|
createImage,
|
|
10944
10979
|
estimateBytesUsed,
|
|
10980
|
+
getBlockFluidState,
|
|
10945
10981
|
getFluidKind,
|
|
10946
10982
|
interleaveAttributes,
|
|
10947
10983
|
isAssetKey,
|