minerender 2.1.0-alpha.122 → 2.1.0-alpha.123
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 +23 -1
- package/dist/browser/index.d.ts +23 -1
- package/dist/browser/index.js +126 -75
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +113 -62
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +85 -26
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +23 -1
- package/dist/node/index.d.ts +23 -1
- package/dist/node/index.js +126 -75
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +113 -62
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -107853,11 +107853,77 @@ gl_FragDepth=readDepth(vUv);
|
|
|
107853
107853
|
|
|
107854
107854
|
// src/world/_entities/WorldEntities.ts
|
|
107855
107855
|
init_BannerPatterns();
|
|
107856
|
+
init_three_module();
|
|
107857
|
+
|
|
107858
|
+
// src/world/_picking/Picking.ts
|
|
107859
|
+
init_dirname();
|
|
107860
|
+
init_buffer2();
|
|
107861
|
+
init_process2();
|
|
107862
|
+
init_three_module();
|
|
107863
|
+
init_three();
|
|
107864
|
+
function pickableMeshes(root, scene, raycaster) {
|
|
107865
|
+
const result = [];
|
|
107866
|
+
let attached = false;
|
|
107867
|
+
for (let parent = root; parent; parent = parent.parent) {
|
|
107868
|
+
if (!parent.visible) return result;
|
|
107869
|
+
if (parent === scene) attached = true;
|
|
107870
|
+
}
|
|
107871
|
+
if (!attached) return result;
|
|
107872
|
+
root.updateWorldMatrix(true, true);
|
|
107873
|
+
root.traverseVisible((object4) => {
|
|
107874
|
+
if (isMesh(object4) && raycaster.layers.test(object4.layers)) result.push(object4);
|
|
107875
|
+
});
|
|
107876
|
+
return result;
|
|
107877
|
+
}
|
|
107878
|
+
function visibleHits(raycaster, meshes) {
|
|
107879
|
+
return raycaster.intersectObjects(meshes, false).filter((hit) => {
|
|
107880
|
+
if (!hit.face) return false;
|
|
107881
|
+
const mesh = hit.object;
|
|
107882
|
+
const material = Array.isArray(mesh.material) ? mesh.material[hit.face.materialIndex] : mesh.material;
|
|
107883
|
+
return material?.visible;
|
|
107884
|
+
});
|
|
107885
|
+
}
|
|
107886
|
+
function hitNormal(hit) {
|
|
107887
|
+
const mesh = hit.object;
|
|
107888
|
+
const matrix = mesh.matrixWorld.clone();
|
|
107889
|
+
if (isInstancedMesh(mesh) && hit.instanceId !== void 0) {
|
|
107890
|
+
const instance = new Matrix4();
|
|
107891
|
+
mesh.getMatrixAt(hit.instanceId, instance);
|
|
107892
|
+
matrix.multiply(instance);
|
|
107893
|
+
}
|
|
107894
|
+
return hit.face.normal.clone().applyNormalMatrix(new Matrix3().getNormalMatrix(matrix));
|
|
107895
|
+
}
|
|
107896
|
+
|
|
107897
|
+
// src/world/_entities/WorldEntities.ts
|
|
107856
107898
|
var WorldEntities = class {
|
|
107857
107899
|
constructor(scene) {
|
|
107858
107900
|
this.scene = scene;
|
|
107859
107901
|
this.columns = /* @__PURE__ */ new Map();
|
|
107860
107902
|
}
|
|
107903
|
+
/** Finds the nearest visible triangle belonging to an entity owned by this world. */
|
|
107904
|
+
raycast(raycaster) {
|
|
107905
|
+
const owners = /* @__PURE__ */ new Map();
|
|
107906
|
+
for (const column of this.columns.values()) {
|
|
107907
|
+
for (const [object4, placement] of column) {
|
|
107908
|
+
for (const mesh of pickableMeshes(object4, this.scene, raycaster)) {
|
|
107909
|
+
owners.set(mesh, { object: object4, ...placement });
|
|
107910
|
+
}
|
|
107911
|
+
}
|
|
107912
|
+
}
|
|
107913
|
+
for (const hit of visibleHits(raycaster, [...owners.keys()])) {
|
|
107914
|
+
const mesh = hit.object;
|
|
107915
|
+
const owner = owners.get(mesh);
|
|
107916
|
+
return {
|
|
107917
|
+
type: owner.type,
|
|
107918
|
+
position: new Vector3(...owner.position),
|
|
107919
|
+
object: owner.object,
|
|
107920
|
+
point: hit.point.clone(),
|
|
107921
|
+
normal: hitNormal(hit),
|
|
107922
|
+
distance: hit.distance
|
|
107923
|
+
};
|
|
107924
|
+
}
|
|
107925
|
+
return void 0;
|
|
107926
|
+
}
|
|
107861
107927
|
/** Captures column ownership before asynchronous block or asset loading starts. */
|
|
107862
107928
|
prepare(entities = [], column) {
|
|
107863
107929
|
const placements = entities.flatMap((entity) => {
|
|
@@ -107866,7 +107932,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
107866
107932
|
const position = [...entity.position];
|
|
107867
107933
|
const key = column?.join(",") ?? `${Math.floor(position[0] / 16)},${Math.floor(position[2] / 16)}`;
|
|
107868
107934
|
let owner = this.columns.get(key);
|
|
107869
|
-
if (!owner) this.columns.set(key, owner = /* @__PURE__ */ new
|
|
107935
|
+
if (!owner) this.columns.set(key, owner = /* @__PURE__ */ new Map());
|
|
107870
107936
|
return [{ ...resolved, position, column: key, owner }];
|
|
107871
107937
|
});
|
|
107872
107938
|
return async () => {
|
|
@@ -107892,7 +107958,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
107892
107958
|
object4.rotation.y = placement.yaw;
|
|
107893
107959
|
await object4.init();
|
|
107894
107960
|
if (!current()) return;
|
|
107895
|
-
placement.owner.
|
|
107961
|
+
placement.owner.set(object4, { type: placement.key.toNamespacedString(), position: placement.position });
|
|
107896
107962
|
this.scene.add(object4);
|
|
107897
107963
|
} catch (error2) {
|
|
107898
107964
|
console.warn(`Could not draw saved entity ${placement.key.toNamespacedString()}, skipping it`, error2);
|
|
@@ -107907,7 +107973,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
107907
107973
|
const objects = this.columns.get(key);
|
|
107908
107974
|
this.columns.delete(key);
|
|
107909
107975
|
if (!objects) return;
|
|
107910
|
-
for (const object4 of objects) {
|
|
107976
|
+
for (const object4 of objects.keys()) {
|
|
107911
107977
|
object4.removeFromScene();
|
|
107912
107978
|
object4.dispose();
|
|
107913
107979
|
}
|
|
@@ -107978,6 +108044,14 @@ gl_FragDepth=readDepth(vUv);
|
|
|
107978
108044
|
raycast(raycaster) {
|
|
107979
108045
|
return Chunk.raycast(this._chunks.values(), raycaster);
|
|
107980
108046
|
}
|
|
108047
|
+
/**
|
|
108048
|
+
* Returns the nearest visible mob geometry hit when renderEntities is enabled.
|
|
108049
|
+
* Respects layers and near/far; compare its distance with raycast() to account for blocks.
|
|
108050
|
+
* Texture alpha does not change triangle intersections.
|
|
108051
|
+
*/
|
|
108052
|
+
raycastEntities(raycaster) {
|
|
108053
|
+
return this.entities?.raycast(raycaster);
|
|
108054
|
+
}
|
|
107981
108055
|
/** Whether neighboring opaque cubes shade block-face corners. Defaults to false. */
|
|
107982
108056
|
get ambientOcclusion() {
|
|
107983
108057
|
return this._ambientOcclusion;
|
|
@@ -108993,7 +109067,6 @@ gl_FragDepth=readDepth(vUv);
|
|
|
108993
109067
|
init_FluidQuads();
|
|
108994
109068
|
init_CubeFace();
|
|
108995
109069
|
init_InstanceReference();
|
|
108996
|
-
init_three();
|
|
108997
109070
|
var WATER_TINT2 = new Color(4159204).toArray();
|
|
108998
109071
|
var Chunk = class _Chunk {
|
|
108999
109072
|
constructor(scene, x4, y5, z4, onBlocksChanged, sectionModels, neighborCell, biomeAt, onBiomesChanged, lightAt, onLightCleared, ambientLight = 0) {
|
|
@@ -109026,18 +109099,8 @@ gl_FragDepth=readDepth(vUv);
|
|
|
109026
109099
|
const meshes = (root, scene) => {
|
|
109027
109100
|
const cached2 = roots.get(root);
|
|
109028
109101
|
if (cached2) return cached2;
|
|
109029
|
-
const result =
|
|
109102
|
+
const result = pickableMeshes(root, scene, raycaster);
|
|
109030
109103
|
roots.set(root, result);
|
|
109031
|
-
let attached = false;
|
|
109032
|
-
for (let parent = root; parent; parent = parent.parent) {
|
|
109033
|
-
if (!parent.visible) return result;
|
|
109034
|
-
if (parent === scene) attached = true;
|
|
109035
|
-
}
|
|
109036
|
-
if (!attached) return result;
|
|
109037
|
-
root.updateWorldMatrix(true, true);
|
|
109038
|
-
root.traverseVisible((object4) => {
|
|
109039
|
-
if (isMesh(object4) && raycaster.layers.test(object4.layers)) result.push(object4);
|
|
109040
|
-
});
|
|
109041
109104
|
return result;
|
|
109042
109105
|
};
|
|
109043
109106
|
const add = (root, owner, reference) => {
|
|
@@ -109068,11 +109131,8 @@ gl_FragDepth=readDepth(vUv);
|
|
|
109068
109131
|
}
|
|
109069
109132
|
}
|
|
109070
109133
|
}
|
|
109071
|
-
for (const hit of raycaster
|
|
109072
|
-
if (!hit.face) continue;
|
|
109134
|
+
for (const hit of visibleHits(raycaster, [...targets.keys()])) {
|
|
109073
109135
|
const mesh = hit.object;
|
|
109074
|
-
const material = Array.isArray(mesh.material) ? mesh.material[hit.face.materialIndex] : mesh.material;
|
|
109075
|
-
if (!material?.visible) continue;
|
|
109076
109136
|
const entry = targets.get(mesh);
|
|
109077
109137
|
let owner = entry.owners.get(hit.instanceId) ?? entry.owners.get(void 0);
|
|
109078
109138
|
if (entry.section) {
|
|
@@ -109082,12 +109142,6 @@ gl_FragDepth=readDepth(vUv);
|
|
|
109082
109142
|
if (!owner || owner.chunk.hiddenBlocks.has(owner.index)) continue;
|
|
109083
109143
|
const info = owner.chunk.renderedBlocks.get(owner.index);
|
|
109084
109144
|
if (!info) continue;
|
|
109085
|
-
const matrix = mesh.matrixWorld.clone();
|
|
109086
|
-
if (isInstancedMesh(mesh) && hit.instanceId !== void 0) {
|
|
109087
|
-
const instance = new Matrix4();
|
|
109088
|
-
mesh.getMatrixAt(hit.instanceId, instance);
|
|
109089
|
-
matrix.multiply(instance);
|
|
109090
|
-
}
|
|
109091
109145
|
return {
|
|
109092
109146
|
position: new Vector3(
|
|
109093
109147
|
owner.chunk.x * 16 + owner.index % 16,
|
|
@@ -109096,7 +109150,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
109096
109150
|
),
|
|
109097
109151
|
block: info.block,
|
|
109098
109152
|
point: hit.point.clone(),
|
|
109099
|
-
normal: hit
|
|
109153
|
+
normal: hitNormal(hit),
|
|
109100
109154
|
distance: hit.distance
|
|
109101
109155
|
};
|
|
109102
109156
|
}
|
|
@@ -109678,6 +109732,11 @@ gl_FragDepth=readDepth(vUv);
|
|
|
109678
109732
|
init_buffer2();
|
|
109679
109733
|
init_process2();
|
|
109680
109734
|
|
|
109735
|
+
// src/world/WorldEntityIntersection.ts
|
|
109736
|
+
init_dirname();
|
|
109737
|
+
init_buffer2();
|
|
109738
|
+
init_process2();
|
|
109739
|
+
|
|
109681
109740
|
// src/world/WorldStreamer.ts
|
|
109682
109741
|
init_dirname();
|
|
109683
109742
|
init_buffer2();
|