minerender 2.1.0-alpha.44 → 2.1.0-alpha.45
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 +4 -2
- package/dist/browser/index.d.ts +4 -2
- package/dist/browser/index.js +26 -17
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +26 -17
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +26 -17
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +4 -2
- package/dist/node/index.d.ts +4 -2
- package/dist/node/index.js +26 -17
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +26 -17
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -4222,9 +4222,9 @@ var init_ModelObject = __esm({
|
|
|
4222
4222
|
|
|
4223
4223
|
// src/model/fluid/FluidGeometry.ts
|
|
4224
4224
|
import { BufferGeometry as BufferGeometry2, Float32BufferAttribute as Float32BufferAttribute4 } from "three";
|
|
4225
|
-
function getFluidKind(key) {
|
|
4226
|
-
if (key?.namespace
|
|
4227
|
-
return
|
|
4225
|
+
function getFluidKind(key, state) {
|
|
4226
|
+
if (key?.namespace === "minecraft" && !key.type && (key.path === "water" || key.path === "lava")) return key.path;
|
|
4227
|
+
return state?.waterlogged === "true" ? "water" : void 0;
|
|
4228
4228
|
}
|
|
4229
4229
|
function ownHeight(sample) {
|
|
4230
4230
|
const level = sample.level ?? 0;
|
|
@@ -4376,7 +4376,7 @@ var init_FluidModelObject = __esm({
|
|
|
4376
4376
|
FluidModelObject = class extends ModelObject {
|
|
4377
4377
|
constructor(kind, sample, origin, options) {
|
|
4378
4378
|
super({
|
|
4379
|
-
key: new AssetKey("minecraft", kind, "models", "fluid", "assets", ".json", origin
|
|
4379
|
+
key: new AssetKey("minecraft", kind, "models", "fluid", "assets", ".json", origin?.root),
|
|
4380
4380
|
textures: { still: `minecraft:block/${kind}_still`, flow: `minecraft:block/${kind}_flow` },
|
|
4381
4381
|
elements: []
|
|
4382
4382
|
}, options);
|
|
@@ -5562,6 +5562,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5562
5562
|
clearModels() {
|
|
5563
5563
|
this.removeModels(this._models.splice(0));
|
|
5564
5564
|
this._fluidKey = void 0;
|
|
5565
|
+
this._fluidModel = void 0;
|
|
5565
5566
|
this._isInstanced = false;
|
|
5566
5567
|
this._instanceCounter = 0;
|
|
5567
5568
|
}
|
|
@@ -5593,11 +5594,14 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5593
5594
|
return ModelCulling.toLocalMask(worldMask, new Euler7().setFromQuaternion(rotation));
|
|
5594
5595
|
}
|
|
5595
5596
|
async setCullMask(worldMask) {
|
|
5596
|
-
if (this.fluidKind) return;
|
|
5597
5597
|
worldMask &= 63;
|
|
5598
5598
|
const replacements = [];
|
|
5599
5599
|
try {
|
|
5600
5600
|
for (const model of this._models) {
|
|
5601
|
+
if (model === this._fluidModel) {
|
|
5602
|
+
replacements.push(model);
|
|
5603
|
+
continue;
|
|
5604
|
+
}
|
|
5601
5605
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
5602
5606
|
const cullMask = this.getModelCullMask(model, worldMask);
|
|
5603
5607
|
if (cullMask === (object.options.cullMask ?? 0)) {
|
|
@@ -5630,7 +5634,10 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5630
5634
|
return this._state;
|
|
5631
5635
|
}
|
|
5632
5636
|
get fluidKind() {
|
|
5633
|
-
return getFluidKind(this.blockState.key);
|
|
5637
|
+
return getFluidKind(this.blockState.key, this.state);
|
|
5638
|
+
}
|
|
5639
|
+
get fluidLevel() {
|
|
5640
|
+
return getFluidKind(this.blockState.key) ? Number(this.state.level ?? 0) : 0;
|
|
5634
5641
|
}
|
|
5635
5642
|
/** Refreshes fluid surfaces from relative neighbors; standalone previews use air around the block. */
|
|
5636
5643
|
async updateFluid(sample) {
|
|
@@ -5638,22 +5645,24 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5638
5645
|
if (!kind) return;
|
|
5639
5646
|
const { FluidModelObject: FluidModelObject2, sampleFluid: sampleFluid2 } = await Promise.resolve().then(() => (init_FluidModelObject(), FluidModelObject_exports));
|
|
5640
5647
|
this._fluidSampler = sample;
|
|
5641
|
-
const surface = sampleFluid2(kind, (x, y, z) => x === 0 && y === 0 && z === 0 ? { fluid: kind, level:
|
|
5648
|
+
const surface = sampleFluid2(kind, (x, y, z) => x === 0 && y === 0 && z === 0 ? { fluid: kind, level: this.fluidLevel } : sample?.(x, y, z) ?? {});
|
|
5642
5649
|
if (this._fluidKey === surface.key) return;
|
|
5643
|
-
const key = new AssetKey("minecraft", `${kind}/${surface.key}`, "models", "fluid", "assets", ".json", this.blockState.key
|
|
5650
|
+
const key = new AssetKey("minecraft", `${kind}/${surface.key}`, "models", "fluid", "assets", ".json", this.blockState.key?.root);
|
|
5644
5651
|
const replacement = await this.scene.addSceneObject(
|
|
5645
5652
|
{ key },
|
|
5646
5653
|
() => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
|
|
5647
5654
|
);
|
|
5648
|
-
const previous = this.
|
|
5649
|
-
const matrix = previous
|
|
5655
|
+
const previous = this._fluidModel;
|
|
5656
|
+
const matrix = previous ? this.getModelMatrix(previous) : new Matrix45().makeTranslation(...this.position.toArray());
|
|
5650
5657
|
if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
|
|
5651
5658
|
else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
5652
|
-
this._models =
|
|
5659
|
+
this._models = this._models.filter((model) => model !== previous);
|
|
5660
|
+
this._models.push(replacement);
|
|
5661
|
+
this._fluidModel = replacement;
|
|
5653
5662
|
this._fluidKey = surface.key;
|
|
5654
|
-
this._isInstanced
|
|
5663
|
+
this._isInstanced ||= isInstanceReference(replacement);
|
|
5655
5664
|
this._instanceCounter = this._isInstanced ? 1 : 0;
|
|
5656
|
-
this.removeModels(previous);
|
|
5665
|
+
if (previous) this.removeModels([previous]);
|
|
5657
5666
|
this.notifyDirty();
|
|
5658
5667
|
}
|
|
5659
5668
|
nextInstance() {
|
|
@@ -5670,7 +5679,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5670
5679
|
}
|
|
5671
5680
|
async recreateModels() {
|
|
5672
5681
|
this.clearModels();
|
|
5673
|
-
if (this.
|
|
5682
|
+
if (getFluidKind(this.blockState.key)) {
|
|
5674
5683
|
await this.updateFluid(this._fluidSampler);
|
|
5675
5684
|
return;
|
|
5676
5685
|
}
|
|
@@ -5679,6 +5688,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5679
5688
|
for (let blockStateVariant of variantsToCreate) {
|
|
5680
5689
|
this._models.push(await this.createVariant(blockStateVariant));
|
|
5681
5690
|
}
|
|
5691
|
+
await this.updateFluid(this._fluidSampler);
|
|
5682
5692
|
}
|
|
5683
5693
|
getSingleVariant(variants) {
|
|
5684
5694
|
return BlockStateResolver.choose(variants);
|
|
@@ -10504,11 +10514,10 @@ var MineRenderWorld = class {
|
|
|
10504
10514
|
const object = section?.getBlockAt(neighbor)?.object;
|
|
10505
10515
|
return {
|
|
10506
10516
|
fluid: object?.fluidKind,
|
|
10507
|
-
level:
|
|
10517
|
+
level: object?.fluidLevel,
|
|
10508
10518
|
solid: section?.isOccludingAt(neighbor) ?? false
|
|
10509
10519
|
};
|
|
10510
10520
|
});
|
|
10511
|
-
continue;
|
|
10512
10521
|
}
|
|
10513
10522
|
let mask = 0;
|
|
10514
10523
|
for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
@@ -10737,7 +10746,7 @@ var Chunk = class _Chunk {
|
|
|
10737
10746
|
this.data.set(index, void 0);
|
|
10738
10747
|
return void 0;
|
|
10739
10748
|
}
|
|
10740
|
-
const template = getFluidKind(blockState.key) ? void 0 : await this.sectionModels?.get(blockState, stored.properties);
|
|
10749
|
+
const template = getFluidKind(blockState.key, stored.properties) ? void 0 : await this.sectionModels?.get(blockState, stored.properties);
|
|
10741
10750
|
if (template) {
|
|
10742
10751
|
this.sectionBlocks.set(index, { index, template, cullMask: 0 });
|
|
10743
10752
|
this.meshDirty = true;
|