minerender 2.1.0-alpha.62 → 2.1.0-alpha.63
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 +16 -0
- package/dist/browser/index.d.ts +16 -0
- package/dist/browser/index.js +105 -5
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +105 -5
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +105 -5
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +16 -0
- package/dist/node/index.d.ts +16 -0
- package/dist/node/index.js +105 -5
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +105 -5
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.d.mts
CHANGED
|
@@ -1055,6 +1055,7 @@ interface Instanceable {
|
|
|
1055
1055
|
isInstanceActive(index: number, reference: InstanceReference<Instanceable>): boolean;
|
|
1056
1056
|
getMatrixAt(index: number, matrix?: Matrix4): Matrix4;
|
|
1057
1057
|
setMatrixAt(index: number, matrix: Matrix4): void;
|
|
1058
|
+
setInstanceVisibleAt(index: number, visible: boolean): void;
|
|
1058
1059
|
setPositionRotationScaleAt(index: number, position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
1059
1060
|
setPositionAt(index: number, position: Vector3): void;
|
|
1060
1061
|
getPositionAt(index: number, vector?: Vector3): Vector3;
|
|
@@ -1076,6 +1077,7 @@ declare class InstanceReference<T extends Instanceable> implements Transformable
|
|
|
1076
1077
|
dispose(): void;
|
|
1077
1078
|
getMatrix(matrix?: Matrix4): Matrix4;
|
|
1078
1079
|
setMatrix(matrix: Matrix4): void;
|
|
1080
|
+
setVisible(visible: boolean): void;
|
|
1079
1081
|
setPositionRotationScale(position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
1080
1082
|
setPosition(position: Vector3): void;
|
|
1081
1083
|
getPosition(): Vector3;
|
|
@@ -1366,6 +1368,7 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
|
1366
1368
|
protected instanceMesh?: InstancedMesh;
|
|
1367
1369
|
private readonly instanceReferences;
|
|
1368
1370
|
private readonly freeInstanceIndices;
|
|
1371
|
+
private readonly hiddenInstanceMatrices;
|
|
1369
1372
|
constructor(options?: Partial<SceneObjectOptions>);
|
|
1370
1373
|
set scene(scene: MineRenderScene);
|
|
1371
1374
|
get scene(): MineRenderScene;
|
|
@@ -1413,6 +1416,7 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
|
1413
1416
|
protected activeInstanceIndices(): Iterable<number>;
|
|
1414
1417
|
getMatrixAt(index: number, matrix?: Matrix4): Matrix4;
|
|
1415
1418
|
setMatrixAt(index: number, matrix: Matrix4): void;
|
|
1419
|
+
setInstanceVisibleAt(index: number, visible: boolean): void;
|
|
1416
1420
|
setPositionRotationScaleAt(index: number, position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
1417
1421
|
setPositionAt(index: number, position: Vector3): void;
|
|
1418
1422
|
getPositionAt(index: number, vector?: Vector3): Vector3;
|
|
@@ -1480,6 +1484,8 @@ declare class BlockObject extends SceneObject {
|
|
|
1480
1484
|
private removeEntities;
|
|
1481
1485
|
/** Entity models drawn for this block instead of its block model; they are scene children, unlike the block. */
|
|
1482
1486
|
get blockEntities(): readonly EntityObject[];
|
|
1487
|
+
/** Sets visibility for this block's model instances and block entities. */
|
|
1488
|
+
setVisible(visible: boolean): void;
|
|
1483
1489
|
/**
|
|
1484
1490
|
* Draws the block through the dataset's block-entity index. Returns false, leaving nothing behind,
|
|
1485
1491
|
* when the block is not listed or one of its models cannot be loaded.
|
|
@@ -2309,6 +2315,7 @@ declare class Chunk<SectionMeshing extends boolean = false> {
|
|
|
2309
2315
|
private readonly data;
|
|
2310
2316
|
private readonly renderedBlocks;
|
|
2311
2317
|
private readonly sectionBlocks;
|
|
2318
|
+
private readonly hiddenBlocks;
|
|
2312
2319
|
private sectionMesh?;
|
|
2313
2320
|
private meshDirty;
|
|
2314
2321
|
constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined, sectionModels?: SectionModels | undefined);
|
|
@@ -2325,6 +2332,8 @@ declare class Chunk<SectionMeshing extends boolean = false> {
|
|
|
2325
2332
|
* Set a block at integer chunk-local coordinates from 0 to 15.
|
|
2326
2333
|
*/
|
|
2327
2334
|
setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2335
|
+
setBlockVisibleAt(pos: Vector3, visible: boolean): Promise<void>;
|
|
2336
|
+
isBlockVisibleAt(pos: Vector3): boolean;
|
|
2328
2337
|
isOccludingAt(pos: Vector3): boolean;
|
|
2329
2338
|
setCullMaskAt(pos: Vector3, mask: number): Promise<void>;
|
|
2330
2339
|
rebuildSectionMesh(): void;
|
|
@@ -2350,6 +2359,13 @@ declare class MineRenderWorld<SectionMeshing extends boolean = false> {
|
|
|
2350
2359
|
setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2351
2360
|
setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2352
2361
|
private placeBlock;
|
|
2362
|
+
/**
|
|
2363
|
+
* Shows or hides a placed block without changing its data. Hidden blocks do not occlude neighbors.
|
|
2364
|
+
* Missing blocks are ignored; replacing or removing a block resets its visibility.
|
|
2365
|
+
*/
|
|
2366
|
+
setBlockVisibleAt(x: number, y: number, z: number, visible: boolean): Promise<void>;
|
|
2367
|
+
setBlockVisibleAt(pos: Vector3, visible: boolean): Promise<void>;
|
|
2368
|
+
setBlockVisibleAt(pos: TripleArray, visible: boolean): Promise<void>;
|
|
2353
2369
|
placeMultiBlock(multiblock: MultiBlockStructure, useBatches?: boolean, executor?: BatchedExecutor): Promise<void>;
|
|
2354
2370
|
private placeBlocks;
|
|
2355
2371
|
/** Replaces one chunk column's blocks. Entity NBT remains available on the parsed chunk. */
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1055,6 +1055,7 @@ interface Instanceable {
|
|
|
1055
1055
|
isInstanceActive(index: number, reference: InstanceReference<Instanceable>): boolean;
|
|
1056
1056
|
getMatrixAt(index: number, matrix?: Matrix4): Matrix4;
|
|
1057
1057
|
setMatrixAt(index: number, matrix: Matrix4): void;
|
|
1058
|
+
setInstanceVisibleAt(index: number, visible: boolean): void;
|
|
1058
1059
|
setPositionRotationScaleAt(index: number, position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
1059
1060
|
setPositionAt(index: number, position: Vector3): void;
|
|
1060
1061
|
getPositionAt(index: number, vector?: Vector3): Vector3;
|
|
@@ -1076,6 +1077,7 @@ declare class InstanceReference<T extends Instanceable> implements Transformable
|
|
|
1076
1077
|
dispose(): void;
|
|
1077
1078
|
getMatrix(matrix?: Matrix4): Matrix4;
|
|
1078
1079
|
setMatrix(matrix: Matrix4): void;
|
|
1080
|
+
setVisible(visible: boolean): void;
|
|
1079
1081
|
setPositionRotationScale(position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
1080
1082
|
setPosition(position: Vector3): void;
|
|
1081
1083
|
getPosition(): Vector3;
|
|
@@ -1366,6 +1368,7 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
|
1366
1368
|
protected instanceMesh?: InstancedMesh;
|
|
1367
1369
|
private readonly instanceReferences;
|
|
1368
1370
|
private readonly freeInstanceIndices;
|
|
1371
|
+
private readonly hiddenInstanceMatrices;
|
|
1369
1372
|
constructor(options?: Partial<SceneObjectOptions>);
|
|
1370
1373
|
set scene(scene: MineRenderScene);
|
|
1371
1374
|
get scene(): MineRenderScene;
|
|
@@ -1413,6 +1416,7 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
|
1413
1416
|
protected activeInstanceIndices(): Iterable<number>;
|
|
1414
1417
|
getMatrixAt(index: number, matrix?: Matrix4): Matrix4;
|
|
1415
1418
|
setMatrixAt(index: number, matrix: Matrix4): void;
|
|
1419
|
+
setInstanceVisibleAt(index: number, visible: boolean): void;
|
|
1416
1420
|
setPositionRotationScaleAt(index: number, position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
1417
1421
|
setPositionAt(index: number, position: Vector3): void;
|
|
1418
1422
|
getPositionAt(index: number, vector?: Vector3): Vector3;
|
|
@@ -1480,6 +1484,8 @@ declare class BlockObject extends SceneObject {
|
|
|
1480
1484
|
private removeEntities;
|
|
1481
1485
|
/** Entity models drawn for this block instead of its block model; they are scene children, unlike the block. */
|
|
1482
1486
|
get blockEntities(): readonly EntityObject[];
|
|
1487
|
+
/** Sets visibility for this block's model instances and block entities. */
|
|
1488
|
+
setVisible(visible: boolean): void;
|
|
1483
1489
|
/**
|
|
1484
1490
|
* Draws the block through the dataset's block-entity index. Returns false, leaving nothing behind,
|
|
1485
1491
|
* when the block is not listed or one of its models cannot be loaded.
|
|
@@ -2309,6 +2315,7 @@ declare class Chunk<SectionMeshing extends boolean = false> {
|
|
|
2309
2315
|
private readonly data;
|
|
2310
2316
|
private readonly renderedBlocks;
|
|
2311
2317
|
private readonly sectionBlocks;
|
|
2318
|
+
private readonly hiddenBlocks;
|
|
2312
2319
|
private sectionMesh?;
|
|
2313
2320
|
private meshDirty;
|
|
2314
2321
|
constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined, sectionModels?: SectionModels | undefined);
|
|
@@ -2325,6 +2332,8 @@ declare class Chunk<SectionMeshing extends boolean = false> {
|
|
|
2325
2332
|
* Set a block at integer chunk-local coordinates from 0 to 15.
|
|
2326
2333
|
*/
|
|
2327
2334
|
setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2335
|
+
setBlockVisibleAt(pos: Vector3, visible: boolean): Promise<void>;
|
|
2336
|
+
isBlockVisibleAt(pos: Vector3): boolean;
|
|
2328
2337
|
isOccludingAt(pos: Vector3): boolean;
|
|
2329
2338
|
setCullMaskAt(pos: Vector3, mask: number): Promise<void>;
|
|
2330
2339
|
rebuildSectionMesh(): void;
|
|
@@ -2350,6 +2359,13 @@ declare class MineRenderWorld<SectionMeshing extends boolean = false> {
|
|
|
2350
2359
|
setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2351
2360
|
setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2352
2361
|
private placeBlock;
|
|
2362
|
+
/**
|
|
2363
|
+
* Shows or hides a placed block without changing its data. Hidden blocks do not occlude neighbors.
|
|
2364
|
+
* Missing blocks are ignored; replacing or removing a block resets its visibility.
|
|
2365
|
+
*/
|
|
2366
|
+
setBlockVisibleAt(x: number, y: number, z: number, visible: boolean): Promise<void>;
|
|
2367
|
+
setBlockVisibleAt(pos: Vector3, visible: boolean): Promise<void>;
|
|
2368
|
+
setBlockVisibleAt(pos: TripleArray, visible: boolean): Promise<void>;
|
|
2353
2369
|
placeMultiBlock(multiblock: MultiBlockStructure, useBatches?: boolean, executor?: BatchedExecutor): Promise<void>;
|
|
2354
2370
|
private placeBlocks;
|
|
2355
2371
|
/** Replaces one chunk column's blocks. Entity NBT remains available on the parsed chunk. */
|
package/dist/node/index.js
CHANGED
|
@@ -3547,6 +3547,9 @@ var init_InstanceReference = __esm({
|
|
|
3547
3547
|
setMatrix(matrix) {
|
|
3548
3548
|
this.activeInstanceable.setMatrixAt(this.index, matrix);
|
|
3549
3549
|
}
|
|
3550
|
+
setVisible(visible) {
|
|
3551
|
+
this.activeInstanceable.setInstanceVisibleAt(this.index, visible);
|
|
3552
|
+
}
|
|
3550
3553
|
setPositionRotationScale(position, rotation, scale) {
|
|
3551
3554
|
this.activeInstanceable.setPositionRotationScaleAt(this.index, position, rotation, scale);
|
|
3552
3555
|
}
|
|
@@ -3601,6 +3604,7 @@ var init_SceneObject = __esm({
|
|
|
3601
3604
|
this._instanceCounter = 0;
|
|
3602
3605
|
this.instanceReferences = /* @__PURE__ */ new Map();
|
|
3603
3606
|
this.freeInstanceIndices = [];
|
|
3607
|
+
this.hiddenInstanceMatrices = /* @__PURE__ */ new Map();
|
|
3604
3608
|
this.options = (0, import_ts_deepmerge3.default)({}, _SceneObject.DEFAULT_OPTIONS, options ?? {});
|
|
3605
3609
|
console.log("SceneObject options", this.options);
|
|
3606
3610
|
}
|
|
@@ -3803,6 +3807,7 @@ var init_SceneObject = __esm({
|
|
|
3803
3807
|
removeInstanceAt(index) {
|
|
3804
3808
|
if (!this.instanceReferences.has(index)) return;
|
|
3805
3809
|
const mesh = this.instanceMesh;
|
|
3810
|
+
this.hiddenInstanceMatrices.delete(index);
|
|
3806
3811
|
this.setMatrixAt(index, new import_three12.Matrix4().makeScale(0, 0, 0));
|
|
3807
3812
|
this.instanceReferences.delete(index);
|
|
3808
3813
|
this.freeInstanceIndices.push(index);
|
|
@@ -3835,18 +3840,46 @@ var init_SceneObject = __esm({
|
|
|
3835
3840
|
//<editor-fold desc="TRANSFORMATION">
|
|
3836
3841
|
getMatrixAt(index, matrix = new import_three12.Matrix4()) {
|
|
3837
3842
|
if (!this.instanceReferences.has(index)) throw new MineRenderError("Instance is not active");
|
|
3843
|
+
const hidden = this.hiddenInstanceMatrices.get(index);
|
|
3844
|
+
if (hidden) {
|
|
3845
|
+
return matrix.copy(hidden);
|
|
3846
|
+
}
|
|
3838
3847
|
this.instanceMesh.getMatrixAt(index, matrix);
|
|
3839
3848
|
return matrix;
|
|
3840
3849
|
}
|
|
3841
3850
|
setMatrixAt(index, matrix) {
|
|
3842
3851
|
if (!this.instanceReferences.has(index)) throw new MineRenderError("Instance is not active");
|
|
3843
3852
|
const mesh = this.instanceMesh;
|
|
3844
|
-
|
|
3853
|
+
const hidden = this.hiddenInstanceMatrices.get(index);
|
|
3854
|
+
if (hidden) {
|
|
3855
|
+
hidden.copy(matrix);
|
|
3856
|
+
}
|
|
3857
|
+
mesh.setMatrixAt(index, hidden ? new import_three12.Matrix4().makeScale(0, 0, 0) : matrix);
|
|
3845
3858
|
mesh.instanceMatrix.needsUpdate = true;
|
|
3846
3859
|
mesh.boundingBox = null;
|
|
3847
3860
|
mesh.boundingSphere = null;
|
|
3848
3861
|
this.notifyDirty();
|
|
3849
3862
|
}
|
|
3863
|
+
setInstanceVisibleAt(index, visible) {
|
|
3864
|
+
if (!this.instanceReferences.has(index)) {
|
|
3865
|
+
throw new MineRenderError("Instance is not active");
|
|
3866
|
+
}
|
|
3867
|
+
const hidden = this.hiddenInstanceMatrices.get(index);
|
|
3868
|
+
if (visible) {
|
|
3869
|
+
if (!hidden) {
|
|
3870
|
+
return;
|
|
3871
|
+
}
|
|
3872
|
+
this.hiddenInstanceMatrices.delete(index);
|
|
3873
|
+
this.setMatrixAt(index, hidden);
|
|
3874
|
+
} else {
|
|
3875
|
+
if (hidden) {
|
|
3876
|
+
return;
|
|
3877
|
+
}
|
|
3878
|
+
const matrix = this.getMatrixAt(index);
|
|
3879
|
+
this.hiddenInstanceMatrices.set(index, matrix);
|
|
3880
|
+
this.setMatrixAt(index, matrix);
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3850
3883
|
setPositionRotationScaleAt(index, position, rotation, scale) {
|
|
3851
3884
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
3852
3885
|
const oldPosition = new import_three12.Vector3();
|
|
@@ -3986,6 +4019,7 @@ var init_SceneObject = __esm({
|
|
|
3986
4019
|
if (this._scene) this._scene.stats.instanceCount -= this.instanceReferences.size;
|
|
3987
4020
|
this.instanceReferences.clear();
|
|
3988
4021
|
this.freeInstanceIndices.length = 0;
|
|
4022
|
+
this.hiddenInstanceMatrices.clear();
|
|
3989
4023
|
this._instanceCounter = 0;
|
|
3990
4024
|
this.instanceMesh.count = 0;
|
|
3991
4025
|
this.instanceMesh.dispose();
|
|
@@ -9318,6 +9352,21 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9318
9352
|
get blockEntities() {
|
|
9319
9353
|
return this._entities;
|
|
9320
9354
|
}
|
|
9355
|
+
/** Sets visibility for this block's model instances and block entities. */
|
|
9356
|
+
setVisible(visible) {
|
|
9357
|
+
this.visible = visible;
|
|
9358
|
+
for (const model of this._models) {
|
|
9359
|
+
if (isInstanceReference(model)) {
|
|
9360
|
+
model.setVisible(visible);
|
|
9361
|
+
} else {
|
|
9362
|
+
model.visible = visible;
|
|
9363
|
+
}
|
|
9364
|
+
}
|
|
9365
|
+
for (const entity of this._entities) {
|
|
9366
|
+
entity.visible = visible;
|
|
9367
|
+
}
|
|
9368
|
+
this.notifyDirty();
|
|
9369
|
+
}
|
|
9321
9370
|
/**
|
|
9322
9371
|
* Draws the block through the dataset's block-entity index. Returns false, leaving nothing behind,
|
|
9323
9372
|
* when the block is not listed or one of its models cannot be loaded.
|
|
@@ -9351,6 +9400,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9351
9400
|
BlockEntities.matrix(resolved, this._entityPlacement);
|
|
9352
9401
|
this._entities = created;
|
|
9353
9402
|
this.placeEntities();
|
|
9403
|
+
this.setVisible(this.visible);
|
|
9354
9404
|
return true;
|
|
9355
9405
|
}
|
|
9356
9406
|
placeEntities() {
|
|
@@ -9360,6 +9410,9 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9360
9410
|
}
|
|
9361
9411
|
}
|
|
9362
9412
|
get isOccluding() {
|
|
9413
|
+
if (!this.visible) {
|
|
9414
|
+
return false;
|
|
9415
|
+
}
|
|
9363
9416
|
return this._models.some((model) => {
|
|
9364
9417
|
const object = isInstanceReference(model) ? model.instanceable : model;
|
|
9365
9418
|
return object.isOpaqueFullCube && this.getModelCullMask(model, 63) === 63;
|
|
@@ -9415,6 +9468,9 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9415
9468
|
this._models = replacements;
|
|
9416
9469
|
this._cullMask = worldMask;
|
|
9417
9470
|
this.removeModels(previous.filter((model) => !replacements.includes(model)));
|
|
9471
|
+
if (!this.visible) {
|
|
9472
|
+
this.setVisible(false);
|
|
9473
|
+
}
|
|
9418
9474
|
this.notifyDirty();
|
|
9419
9475
|
}
|
|
9420
9476
|
get state() {
|
|
@@ -9450,6 +9506,9 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9450
9506
|
this._isInstanced ||= isInstanceReference(replacement);
|
|
9451
9507
|
this._instanceCounter = this._isInstanced ? 1 : 0;
|
|
9452
9508
|
if (previous) this.removeModels([previous]);
|
|
9509
|
+
if (!this.visible) {
|
|
9510
|
+
this.setVisible(false);
|
|
9511
|
+
}
|
|
9453
9512
|
this.notifyDirty();
|
|
9454
9513
|
}
|
|
9455
9514
|
nextInstance() {
|
|
@@ -9478,6 +9537,7 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
9478
9537
|
this._models.push(await this.createVariant(blockStateVariant));
|
|
9479
9538
|
}
|
|
9480
9539
|
await this.updateFluid(this._fluidSampler);
|
|
9540
|
+
this.setVisible(this.visible);
|
|
9481
9541
|
}
|
|
9482
9542
|
async hasGeometry(variant) {
|
|
9483
9543
|
const modelKey = AssetKey.parse("models", variant.model);
|
|
@@ -14259,6 +14319,16 @@ var MineRenderWorld = class {
|
|
|
14259
14319
|
const chunk = Chunk.isAir(value) ? this.getChunkAt(pos) : this.getOrCreateChunkAt(pos);
|
|
14260
14320
|
return chunk?.setBlockInChunkAt(chunk.worldPosToChunkPos(pos), value, pos, onBlocksChanged);
|
|
14261
14321
|
}
|
|
14322
|
+
async setBlockVisibleAt(posOrX, yOrVisible, z, visible) {
|
|
14323
|
+
if (typeof posOrX === "number") {
|
|
14324
|
+
return this.setBlockVisibleAt(new import_three38.Vector3(posOrX, yOrVisible, z), visible);
|
|
14325
|
+
}
|
|
14326
|
+
if (isTripleArray(posOrX)) {
|
|
14327
|
+
return this.setBlockVisibleAt(new import_three38.Vector3(...posOrX), yOrVisible);
|
|
14328
|
+
}
|
|
14329
|
+
this.validatePosBounds(posOrX);
|
|
14330
|
+
await this.getChunkAt(posOrX)?.setBlockVisibleAt(posOrX, yOrVisible);
|
|
14331
|
+
}
|
|
14262
14332
|
async placeMultiBlock(multiblock, useBatches = true, executor) {
|
|
14263
14333
|
const changes = /* @__PURE__ */ new Map();
|
|
14264
14334
|
try {
|
|
@@ -14374,12 +14444,14 @@ var MineRenderWorld = class {
|
|
|
14374
14444
|
if (!chunk) continue;
|
|
14375
14445
|
changed.add(chunk);
|
|
14376
14446
|
const block = chunk.getBlockAt(pos);
|
|
14377
|
-
if (!block)
|
|
14447
|
+
if (!block || !chunk.isBlockVisibleAt(pos)) {
|
|
14448
|
+
continue;
|
|
14449
|
+
}
|
|
14378
14450
|
if (block.object?.fluidKind) {
|
|
14379
14451
|
await block.object.updateFluid((x, y, z) => {
|
|
14380
14452
|
const neighbor = pos.clone().add(new import_three38.Vector3(x, y, z));
|
|
14381
14453
|
const section = this.getChunkAt(neighbor);
|
|
14382
|
-
const object = section?.getBlockAt(neighbor)?.object;
|
|
14454
|
+
const object = section?.isBlockVisibleAt(neighbor) ? section.getBlockAt(neighbor)?.object : void 0;
|
|
14383
14455
|
return {
|
|
14384
14456
|
fluid: object?.fluidKind,
|
|
14385
14457
|
level: object?.fluidLevel,
|
|
@@ -14566,6 +14638,7 @@ var Chunk = class _Chunk {
|
|
|
14566
14638
|
this.data = new ChunkData();
|
|
14567
14639
|
this.renderedBlocks = /* @__PURE__ */ new Map();
|
|
14568
14640
|
this.sectionBlocks = /* @__PURE__ */ new Map();
|
|
14641
|
+
this.hiddenBlocks = /* @__PURE__ */ new Set();
|
|
14569
14642
|
this.meshDirty = false;
|
|
14570
14643
|
this.scene = scene;
|
|
14571
14644
|
this.x = x;
|
|
@@ -14603,6 +14676,7 @@ var Chunk = class _Chunk {
|
|
|
14603
14676
|
worldPos = this.chunkPosToWorldPos(pos);
|
|
14604
14677
|
}
|
|
14605
14678
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
14679
|
+
this.hiddenBlocks.delete(index);
|
|
14606
14680
|
this.data.set(index, block);
|
|
14607
14681
|
const readBlock = this.data.snapshot(index);
|
|
14608
14682
|
this.renderedBlocks.get(index)?.object?.removeFromScene();
|
|
@@ -14644,9 +14718,31 @@ var Chunk = class _Chunk {
|
|
|
14644
14718
|
await onBlocksChanged?.([worldPos]);
|
|
14645
14719
|
}
|
|
14646
14720
|
}
|
|
14721
|
+
async setBlockVisibleAt(pos, visible) {
|
|
14722
|
+
const index = _Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos));
|
|
14723
|
+
const block = this.renderedBlocks.get(index);
|
|
14724
|
+
if (!block || visible === !this.hiddenBlocks.has(index)) {
|
|
14725
|
+
return;
|
|
14726
|
+
}
|
|
14727
|
+
if (visible) {
|
|
14728
|
+
this.hiddenBlocks.delete(index);
|
|
14729
|
+
} else {
|
|
14730
|
+
this.hiddenBlocks.add(index);
|
|
14731
|
+
}
|
|
14732
|
+
block.object?.setVisible(visible);
|
|
14733
|
+
if (this.sectionBlocks.has(index)) {
|
|
14734
|
+
this.meshDirty = true;
|
|
14735
|
+
}
|
|
14736
|
+
this.scene.dirty = true;
|
|
14737
|
+
await this.onBlocksChanged?.([pos]);
|
|
14738
|
+
}
|
|
14739
|
+
isBlockVisibleAt(pos) {
|
|
14740
|
+
const index = _Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos));
|
|
14741
|
+
return this.renderedBlocks.has(index) && !this.hiddenBlocks.has(index);
|
|
14742
|
+
}
|
|
14647
14743
|
isOccludingAt(pos) {
|
|
14648
14744
|
const index = _Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos));
|
|
14649
|
-
return this.sectionBlocks.has(index) || (this.renderedBlocks.get(index)?.object?.isOccluding ?? false);
|
|
14745
|
+
return !this.hiddenBlocks.has(index) && (this.sectionBlocks.has(index) || (this.renderedBlocks.get(index)?.object?.isOccluding ?? false));
|
|
14650
14746
|
}
|
|
14651
14747
|
async setCullMaskAt(pos, mask) {
|
|
14652
14748
|
const index = _Chunk.chunkPosToBlockIndex(this.worldPosToChunkPos(pos));
|
|
@@ -14662,7 +14758,10 @@ var Chunk = class _Chunk {
|
|
|
14662
14758
|
}
|
|
14663
14759
|
rebuildSectionMesh() {
|
|
14664
14760
|
if (!this.meshDirty) return;
|
|
14665
|
-
const next = this.sectionBlocks.size ? SectionMesh.build(
|
|
14761
|
+
const next = this.sectionBlocks.size ? SectionMesh.build(
|
|
14762
|
+
[...this.sectionBlocks.values()].filter((entry) => !this.hiddenBlocks.has(entry.index)),
|
|
14763
|
+
this.sectionModels.maxAtlasSize
|
|
14764
|
+
) : void 0;
|
|
14666
14765
|
this.sectionMesh?.dispose();
|
|
14667
14766
|
this.sectionMesh = next;
|
|
14668
14767
|
if (next) {
|
|
@@ -14682,6 +14781,7 @@ var Chunk = class _Chunk {
|
|
|
14682
14781
|
this.sectionMesh = void 0;
|
|
14683
14782
|
this.meshDirty = false;
|
|
14684
14783
|
this.renderedBlocks.clear();
|
|
14784
|
+
this.hiddenBlocks.clear();
|
|
14685
14785
|
this.data.clear();
|
|
14686
14786
|
await onBlocksChanged?.(positions);
|
|
14687
14787
|
}
|