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.d.mts
CHANGED
|
@@ -1113,7 +1113,7 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
|
1113
1113
|
declare function isSceneObject(obj: any): obj is SceneObject;
|
|
1114
1114
|
|
|
1115
1115
|
type FluidKind = "water" | "lava";
|
|
1116
|
-
declare function getFluidKind(key?: AssetKey): FluidKind | undefined;
|
|
1116
|
+
declare function getFluidKind(key?: AssetKey, state?: BlockStateProperties): FluidKind | undefined;
|
|
1117
1117
|
interface FluidSample {
|
|
1118
1118
|
fluid?: FluidKind;
|
|
1119
1119
|
level?: number;
|
|
@@ -1139,6 +1139,7 @@ declare class BlockObject extends SceneObject {
|
|
|
1139
1139
|
private _cullMask;
|
|
1140
1140
|
private _fluidKey?;
|
|
1141
1141
|
private _fluidSampler?;
|
|
1142
|
+
private _fluidModel?;
|
|
1142
1143
|
constructor(blockState: BlockState, options?: Partial<BlockObjectOptions>);
|
|
1143
1144
|
init(): Promise<void>;
|
|
1144
1145
|
dispose(): void;
|
|
@@ -1153,6 +1154,7 @@ declare class BlockObject extends SceneObject {
|
|
|
1153
1154
|
[key: string]: string;
|
|
1154
1155
|
};
|
|
1155
1156
|
get fluidKind(): FluidKind | undefined;
|
|
1157
|
+
get fluidLevel(): number;
|
|
1156
1158
|
/** Refreshes fluid surfaces from relative neighbors; standalone previews use air around the block. */
|
|
1157
1159
|
updateFluid(sample?: FluidSampler): Promise<void>;
|
|
1158
1160
|
nextInstance(): InstanceReference<SceneObject>;
|
|
@@ -1187,7 +1189,7 @@ declare class FluidModelObject extends ModelObject {
|
|
|
1187
1189
|
readonly kind: FluidKind;
|
|
1188
1190
|
private readonly sample;
|
|
1189
1191
|
private geometry?;
|
|
1190
|
-
constructor(kind: FluidKind, sample: FluidSampler, origin
|
|
1192
|
+
constructor(kind: FluidKind, sample: FluidSampler, origin?: AssetKey, options?: Partial<ModelObjectOptions>);
|
|
1191
1193
|
protected createMeshes(): void;
|
|
1192
1194
|
protected applyTextures(): void;
|
|
1193
1195
|
disposeAndRemoveAllChildren(): void;
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1113,7 +1113,7 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
|
1113
1113
|
declare function isSceneObject(obj: any): obj is SceneObject;
|
|
1114
1114
|
|
|
1115
1115
|
type FluidKind = "water" | "lava";
|
|
1116
|
-
declare function getFluidKind(key?: AssetKey): FluidKind | undefined;
|
|
1116
|
+
declare function getFluidKind(key?: AssetKey, state?: BlockStateProperties): FluidKind | undefined;
|
|
1117
1117
|
interface FluidSample {
|
|
1118
1118
|
fluid?: FluidKind;
|
|
1119
1119
|
level?: number;
|
|
@@ -1139,6 +1139,7 @@ declare class BlockObject extends SceneObject {
|
|
|
1139
1139
|
private _cullMask;
|
|
1140
1140
|
private _fluidKey?;
|
|
1141
1141
|
private _fluidSampler?;
|
|
1142
|
+
private _fluidModel?;
|
|
1142
1143
|
constructor(blockState: BlockState, options?: Partial<BlockObjectOptions>);
|
|
1143
1144
|
init(): Promise<void>;
|
|
1144
1145
|
dispose(): void;
|
|
@@ -1153,6 +1154,7 @@ declare class BlockObject extends SceneObject {
|
|
|
1153
1154
|
[key: string]: string;
|
|
1154
1155
|
};
|
|
1155
1156
|
get fluidKind(): FluidKind | undefined;
|
|
1157
|
+
get fluidLevel(): number;
|
|
1156
1158
|
/** Refreshes fluid surfaces from relative neighbors; standalone previews use air around the block. */
|
|
1157
1159
|
updateFluid(sample?: FluidSampler): Promise<void>;
|
|
1158
1160
|
nextInstance(): InstanceReference<SceneObject>;
|
|
@@ -1187,7 +1189,7 @@ declare class FluidModelObject extends ModelObject {
|
|
|
1187
1189
|
readonly kind: FluidKind;
|
|
1188
1190
|
private readonly sample;
|
|
1189
1191
|
private geometry?;
|
|
1190
|
-
constructor(kind: FluidKind, sample: FluidSampler, origin
|
|
1192
|
+
constructor(kind: FluidKind, sample: FluidSampler, origin?: AssetKey, options?: Partial<ModelObjectOptions>);
|
|
1191
1193
|
protected createMeshes(): void;
|
|
1192
1194
|
protected applyTextures(): void;
|
|
1193
1195
|
disposeAndRemoveAllChildren(): void;
|
package/dist/node/index.js
CHANGED
|
@@ -4214,9 +4214,9 @@ var init_ModelObject = __esm({
|
|
|
4214
4214
|
});
|
|
4215
4215
|
|
|
4216
4216
|
// src/model/fluid/FluidGeometry.ts
|
|
4217
|
-
function getFluidKind(key) {
|
|
4218
|
-
if (key?.namespace
|
|
4219
|
-
return
|
|
4217
|
+
function getFluidKind(key, state) {
|
|
4218
|
+
if (key?.namespace === "minecraft" && !key.type && (key.path === "water" || key.path === "lava")) return key.path;
|
|
4219
|
+
return state?.waterlogged === "true" ? "water" : void 0;
|
|
4220
4220
|
}
|
|
4221
4221
|
function ownHeight(sample) {
|
|
4222
4222
|
const level = sample.level ?? 0;
|
|
@@ -4369,7 +4369,7 @@ var init_FluidModelObject = __esm({
|
|
|
4369
4369
|
FluidModelObject = class extends ModelObject {
|
|
4370
4370
|
constructor(kind, sample, origin, options) {
|
|
4371
4371
|
super({
|
|
4372
|
-
key: new AssetKey("minecraft", kind, "models", "fluid", "assets", ".json", origin
|
|
4372
|
+
key: new AssetKey("minecraft", kind, "models", "fluid", "assets", ".json", origin?.root),
|
|
4373
4373
|
textures: { still: `minecraft:block/${kind}_still`, flow: `minecraft:block/${kind}_flow` },
|
|
4374
4374
|
elements: []
|
|
4375
4375
|
}, options);
|
|
@@ -5718,6 +5718,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5718
5718
|
clearModels() {
|
|
5719
5719
|
this.removeModels(this._models.splice(0));
|
|
5720
5720
|
this._fluidKey = void 0;
|
|
5721
|
+
this._fluidModel = void 0;
|
|
5721
5722
|
this._isInstanced = false;
|
|
5722
5723
|
this._instanceCounter = 0;
|
|
5723
5724
|
}
|
|
@@ -5749,11 +5750,14 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5749
5750
|
return ModelCulling.toLocalMask(worldMask, new import_three22.Euler().setFromQuaternion(rotation));
|
|
5750
5751
|
}
|
|
5751
5752
|
async setCullMask(worldMask) {
|
|
5752
|
-
if (this.fluidKind) return;
|
|
5753
5753
|
worldMask &= 63;
|
|
5754
5754
|
const replacements = [];
|
|
5755
5755
|
try {
|
|
5756
5756
|
for (const model of this._models) {
|
|
5757
|
+
if (model === this._fluidModel) {
|
|
5758
|
+
replacements.push(model);
|
|
5759
|
+
continue;
|
|
5760
|
+
}
|
|
5757
5761
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
5758
5762
|
const cullMask = this.getModelCullMask(model, worldMask);
|
|
5759
5763
|
if (cullMask === (object.options.cullMask ?? 0)) {
|
|
@@ -5786,7 +5790,10 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5786
5790
|
return this._state;
|
|
5787
5791
|
}
|
|
5788
5792
|
get fluidKind() {
|
|
5789
|
-
return getFluidKind(this.blockState.key);
|
|
5793
|
+
return getFluidKind(this.blockState.key, this.state);
|
|
5794
|
+
}
|
|
5795
|
+
get fluidLevel() {
|
|
5796
|
+
return getFluidKind(this.blockState.key) ? Number(this.state.level ?? 0) : 0;
|
|
5790
5797
|
}
|
|
5791
5798
|
/** Refreshes fluid surfaces from relative neighbors; standalone previews use air around the block. */
|
|
5792
5799
|
async updateFluid(sample) {
|
|
@@ -5794,22 +5801,24 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5794
5801
|
if (!kind) return;
|
|
5795
5802
|
const { FluidModelObject: FluidModelObject2, sampleFluid: sampleFluid2 } = await Promise.resolve().then(() => (init_FluidModelObject(), FluidModelObject_exports));
|
|
5796
5803
|
this._fluidSampler = sample;
|
|
5797
|
-
const surface = sampleFluid2(kind, (x, y, z) => x === 0 && y === 0 && z === 0 ? { fluid: kind, level:
|
|
5804
|
+
const surface = sampleFluid2(kind, (x, y, z) => x === 0 && y === 0 && z === 0 ? { fluid: kind, level: this.fluidLevel } : sample?.(x, y, z) ?? {});
|
|
5798
5805
|
if (this._fluidKey === surface.key) return;
|
|
5799
|
-
const key = new AssetKey("minecraft", `${kind}/${surface.key}`, "models", "fluid", "assets", ".json", this.blockState.key
|
|
5806
|
+
const key = new AssetKey("minecraft", `${kind}/${surface.key}`, "models", "fluid", "assets", ".json", this.blockState.key?.root);
|
|
5800
5807
|
const replacement = await this.scene.addSceneObject(
|
|
5801
5808
|
{ key },
|
|
5802
5809
|
() => new FluidModelObject2(kind, surface.sample, this.blockState.key, this.options)
|
|
5803
5810
|
);
|
|
5804
|
-
const previous = this.
|
|
5805
|
-
const matrix = previous
|
|
5811
|
+
const previous = this._fluidModel;
|
|
5812
|
+
const matrix = previous ? this.getModelMatrix(previous) : new import_three22.Matrix4().makeTranslation(...this.position.toArray());
|
|
5806
5813
|
if (isInstanceReference(replacement)) replacement.setMatrix(matrix);
|
|
5807
5814
|
else matrix.decompose(replacement.position, replacement.quaternion, replacement.scale);
|
|
5808
|
-
this._models =
|
|
5815
|
+
this._models = this._models.filter((model) => model !== previous);
|
|
5816
|
+
this._models.push(replacement);
|
|
5817
|
+
this._fluidModel = replacement;
|
|
5809
5818
|
this._fluidKey = surface.key;
|
|
5810
|
-
this._isInstanced
|
|
5819
|
+
this._isInstanced ||= isInstanceReference(replacement);
|
|
5811
5820
|
this._instanceCounter = this._isInstanced ? 1 : 0;
|
|
5812
|
-
this.removeModels(previous);
|
|
5821
|
+
if (previous) this.removeModels([previous]);
|
|
5813
5822
|
this.notifyDirty();
|
|
5814
5823
|
}
|
|
5815
5824
|
nextInstance() {
|
|
@@ -5826,7 +5835,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5826
5835
|
}
|
|
5827
5836
|
async recreateModels() {
|
|
5828
5837
|
this.clearModels();
|
|
5829
|
-
if (this.
|
|
5838
|
+
if (getFluidKind(this.blockState.key)) {
|
|
5830
5839
|
await this.updateFluid(this._fluidSampler);
|
|
5831
5840
|
return;
|
|
5832
5841
|
}
|
|
@@ -5835,6 +5844,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
5835
5844
|
for (let blockStateVariant of variantsToCreate) {
|
|
5836
5845
|
this._models.push(await this.createVariant(blockStateVariant));
|
|
5837
5846
|
}
|
|
5847
|
+
await this.updateFluid(this._fluidSampler);
|
|
5838
5848
|
}
|
|
5839
5849
|
getSingleVariant(variants) {
|
|
5840
5850
|
return BlockStateResolver.choose(variants);
|
|
@@ -10652,11 +10662,10 @@ var MineRenderWorld = class {
|
|
|
10652
10662
|
const object = section?.getBlockAt(neighbor)?.object;
|
|
10653
10663
|
return {
|
|
10654
10664
|
fluid: object?.fluidKind,
|
|
10655
|
-
level:
|
|
10665
|
+
level: object?.fluidLevel,
|
|
10656
10666
|
solid: section?.isOccludingAt(neighbor) ?? false
|
|
10657
10667
|
};
|
|
10658
10668
|
});
|
|
10659
|
-
continue;
|
|
10660
10669
|
}
|
|
10661
10670
|
let mask = 0;
|
|
10662
10671
|
for (const [face, offset] of CUBE_FACE_OFFSETS.entries()) {
|
|
@@ -10885,7 +10894,7 @@ var Chunk = class _Chunk {
|
|
|
10885
10894
|
this.data.set(index, void 0);
|
|
10886
10895
|
return void 0;
|
|
10887
10896
|
}
|
|
10888
|
-
const template = getFluidKind(blockState.key) ? void 0 : await this.sectionModels?.get(blockState, stored.properties);
|
|
10897
|
+
const template = getFluidKind(blockState.key, stored.properties) ? void 0 : await this.sectionModels?.get(blockState, stored.properties);
|
|
10889
10898
|
if (template) {
|
|
10890
10899
|
this.sectionBlocks.set(index, { index, template, cullMask: 0 });
|
|
10891
10900
|
this.meshDirty = true;
|