minerender 2.1.0-alpha.133 → 2.1.0-alpha.134
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/esm/Materials.mjs +3 -2
- package/dist/browser/esm/Materials.mjs.map +1 -1
- package/dist/browser/esm/env/browser/section.worker.mjs +5 -3
- package/dist/browser/esm/env/browser/section.worker.mjs.map +1 -1
- package/dist/browser/esm/index.browser.d.mts +2 -0
- package/dist/browser/esm/model/scene/ModelObject.mjs +4 -0
- package/dist/browser/esm/model/scene/ModelObject.mjs.map +1 -1
- package/dist/browser/esm/world/SectionGeometry.mjs +5 -3
- package/dist/browser/esm/world/SectionGeometry.mjs.map +1 -1
- package/dist/browser/esm/world/SectionMesh.mjs +4 -0
- package/dist/browser/esm/world/SectionMesh.mjs.map +1 -1
- package/dist/browser/esm/world/SectionModels.mjs +2 -2
- package/dist/browser/esm/world/SectionModels.mjs.map +1 -1
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.js +18 -7
- package/dist/browser/index.js.map +1 -1
- package/dist/bundle.js +18 -7
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +2 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.js +18 -7
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +18 -7
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.d.mts
CHANGED
|
@@ -3832,6 +3832,7 @@ interface SectionTemplateData {
|
|
|
3832
3832
|
uvs: Float32Array;
|
|
3833
3833
|
uvBounds: Float32Array;
|
|
3834
3834
|
colors: Float32Array;
|
|
3835
|
+
shade?: Float32Array;
|
|
3835
3836
|
indices: Uint16Array;
|
|
3836
3837
|
cullFaces: Uint8Array;
|
|
3837
3838
|
biomeTint?: Uint8Array;
|
|
@@ -3895,6 +3896,7 @@ interface SectionGeometryPage {
|
|
|
3895
3896
|
uvs: Float32Array;
|
|
3896
3897
|
uvBounds: Float32Array;
|
|
3897
3898
|
colors: Float32Array;
|
|
3899
|
+
shade: Float32Array;
|
|
3898
3900
|
indices: Uint32Array;
|
|
3899
3901
|
/** Owning section cell for each quad; each quad contributes two consecutive triangles. */
|
|
3900
3902
|
blockIndices: Uint16Array;
|
package/dist/node/index.d.ts
CHANGED
|
@@ -3832,6 +3832,7 @@ interface SectionTemplateData {
|
|
|
3832
3832
|
uvs: Float32Array;
|
|
3833
3833
|
uvBounds: Float32Array;
|
|
3834
3834
|
colors: Float32Array;
|
|
3835
|
+
shade?: Float32Array;
|
|
3835
3836
|
indices: Uint16Array;
|
|
3836
3837
|
cullFaces: Uint8Array;
|
|
3837
3838
|
biomeTint?: Uint8Array;
|
|
@@ -3895,6 +3896,7 @@ interface SectionGeometryPage {
|
|
|
3895
3896
|
uvs: Float32Array;
|
|
3896
3897
|
uvBounds: Float32Array;
|
|
3897
3898
|
colors: Float32Array;
|
|
3899
|
+
shade: Float32Array;
|
|
3898
3900
|
indices: Uint32Array;
|
|
3899
3901
|
/** Owning section cell for each quad; each quad contributes two consecutive triangles. */
|
|
3900
3902
|
blockIndices: Uint16Array;
|
package/dist/node/index.js
CHANGED
|
@@ -1117,6 +1117,7 @@ var init_Materials = __esm({
|
|
|
1117
1117
|
static createShadedCanvasMaterial(canvas, transparent = false, shade = false, boundUvs = false) {
|
|
1118
1118
|
const vertShader = `
|
|
1119
1119
|
uniform bool SHADE;
|
|
1120
|
+
attribute float shade;
|
|
1120
1121
|
|
|
1121
1122
|
// Keep MSAA edge pixels from sampling outside the face's atlas region.
|
|
1122
1123
|
#if __VERSION__ >= 300
|
|
@@ -1139,7 +1140,7 @@ var init_Materials = __esm({
|
|
|
1139
1140
|
void main()
|
|
1140
1141
|
{
|
|
1141
1142
|
|
|
1142
|
-
if (SHADE) {
|
|
1143
|
+
if (SHADE && shade > 0.5) {
|
|
1143
1144
|
|
|
1144
1145
|
#ifdef USE_INSTANCING
|
|
1145
1146
|
vec3 N = vec3( modelMatrix * instanceMatrix * vec4(normal, 0.0) );
|
|
@@ -1248,7 +1249,7 @@ var init_Materials = __esm({
|
|
|
1248
1249
|
side: transparent ? import_three5.DoubleSide : import_three5.FrontSide,
|
|
1249
1250
|
alphaTest: 0.5
|
|
1250
1251
|
});
|
|
1251
|
-
Object.assign(material.defaultAttributeValues, { uvBounds: [0, 0, 1, 1] });
|
|
1252
|
+
Object.assign(material.defaultAttributeValues, { shade: [1], uvBounds: [0, 0, 1, 1] });
|
|
1252
1253
|
return material;
|
|
1253
1254
|
} catch (e) {
|
|
1254
1255
|
console.warn(e);
|
|
@@ -10197,6 +10198,10 @@ var init_ModelObject = __esm({
|
|
|
10197
10198
|
this.atlas.model.elements?.forEach((el) => {
|
|
10198
10199
|
const elGeo = this._getBoxGeometryFromElement(el).clone();
|
|
10199
10200
|
this.geometries.add(elGeo);
|
|
10201
|
+
elGeo.setAttribute("shade", new import_three27.BufferAttribute(
|
|
10202
|
+
new Float32Array(elGeo.getAttribute("position").count).fill(!this.originalModel.itemId && el.shade === false ? 0 : 1),
|
|
10203
|
+
1
|
|
10204
|
+
));
|
|
10200
10205
|
if (this.options.cullMask) {
|
|
10201
10206
|
const indices = Array.from(elGeo.getIndex().array);
|
|
10202
10207
|
elGeo.setIndex(indices.filter((_, index) => {
|
|
@@ -17989,9 +17994,9 @@ function cached(map, key, load) {
|
|
|
17989
17994
|
function compactQuads(geometry, keep) {
|
|
17990
17995
|
const quads = keep.flatMap((kept, index) => kept ? [index] : []);
|
|
17991
17996
|
const compact = new import_three41.BufferGeometry();
|
|
17992
|
-
for (const [name, size] of Object.entries({ position: 3, normal: 3, uv: 2, uvBounds: 4, color: 3 })) {
|
|
17997
|
+
for (const [name, size] of Object.entries({ position: 3, normal: 3, uv: 2, uvBounds: 4, color: 3, shade: 1 })) {
|
|
17993
17998
|
const source2 = geometry.getAttribute(name);
|
|
17994
|
-
const defaults = name === "uvBounds" ? [0, 0, 1, 1] : name === "color" ? [1, 1, 1] : void 0;
|
|
17999
|
+
const defaults = name === "uvBounds" ? [0, 0, 1, 1] : name === "color" ? [1, 1, 1] : name === "shade" ? [1] : void 0;
|
|
17995
18000
|
const values = new Float32Array(quads.length * 4 * size);
|
|
17996
18001
|
for (let q = 0; q < quads.length; q++) {
|
|
17997
18002
|
for (let vertex = 0; vertex < 4; vertex++) {
|
|
@@ -19257,7 +19262,7 @@ function buildSectionGeometry(input) {
|
|
|
19257
19262
|
const cornerBrightness2 = ambientOcclusion ? new Float32Array(4) : void 0;
|
|
19258
19263
|
for (const template of templateData) {
|
|
19259
19264
|
const { quads } = template;
|
|
19260
|
-
if (template.positions.length !== quads * 12 || template.normals.length !== quads * 12 || template.uvs.length !== quads * 8 || template.uvBounds.length !== quads * 16 || template.colors.length !== quads * 12 || template.indices.length !== quads * 6 || template.cullFaces.length !== quads || template.biomeTint && template.biomeTint.length !== quads) {
|
|
19265
|
+
if (template.positions.length !== quads * 12 || template.normals.length !== quads * 12 || template.uvs.length !== quads * 8 || template.uvBounds.length !== quads * 16 || template.colors.length !== quads * 12 || template.indices.length !== quads * 6 || template.cullFaces.length !== quads || template.shade && template.shade.length !== quads * 4 || template.biomeTint && template.biomeTint.length !== quads) {
|
|
19261
19266
|
throw new RangeError("Section template arrays do not match its quad count");
|
|
19262
19267
|
}
|
|
19263
19268
|
}
|
|
@@ -19348,6 +19353,7 @@ function buildSectionGeometry(input) {
|
|
|
19348
19353
|
}
|
|
19349
19354
|
const positions = new Float32Array(faces * 12), normals = new Float32Array(faces * 12);
|
|
19350
19355
|
const uvs = new Float32Array(faces * 8), uvBounds = new Float32Array(faces * 16), colors = new Float32Array(faces * 12);
|
|
19356
|
+
const shade = new Float32Array(faces * 4).fill(1);
|
|
19351
19357
|
const outputIndices = new Uint32Array(faces * 6);
|
|
19352
19358
|
const blockIndices = new Uint16Array(faces);
|
|
19353
19359
|
let vertex = 0, indexOffset = 0;
|
|
@@ -19377,6 +19383,7 @@ function buildSectionGeometry(input) {
|
|
|
19377
19383
|
normals[vertex * 3] = template.normals[source * 3];
|
|
19378
19384
|
normals[vertex * 3 + 1] = template.normals[source * 3 + 1];
|
|
19379
19385
|
normals[vertex * 3 + 2] = template.normals[source * 3 + 2];
|
|
19386
|
+
shade[vertex] = template.shade?.[source] ?? 1;
|
|
19380
19387
|
uvs[vertex * 2] = mapU(template.uvs[source * 2]);
|
|
19381
19388
|
uvs[vertex * 2 + 1] = mapV(template.uvs[source * 2 + 1]);
|
|
19382
19389
|
uvBounds[vertex * 4] = mapU(template.uvBounds[source * 4]);
|
|
@@ -19429,11 +19436,11 @@ function buildSectionGeometry(input) {
|
|
|
19429
19436
|
indexOffset += 6;
|
|
19430
19437
|
}
|
|
19431
19438
|
}
|
|
19432
|
-
return { layer: page.layer, width: page.width, height: page.height, placements: page.placements, positions, normals, uvs, uvBounds, colors, indices: outputIndices, blockIndices };
|
|
19439
|
+
return { layer: page.layer, width: page.width, height: page.height, placements: page.placements, positions, normals, uvs, uvBounds, colors, shade, indices: outputIndices, blockIndices };
|
|
19433
19440
|
});
|
|
19434
19441
|
}
|
|
19435
19442
|
function sectionGeometryTransferables(pages) {
|
|
19436
|
-
return pages.flatMap((page) => [page.positions.buffer, page.normals.buffer, page.uvs.buffer, page.uvBounds.buffer, page.colors.buffer, page.indices.buffer, page.blockIndices.buffer]);
|
|
19443
|
+
return pages.flatMap((page) => [page.positions.buffer, page.normals.buffer, page.uvs.buffer, page.uvBounds.buffer, page.colors.buffer, page.shade.buffer, page.indices.buffer, page.blockIndices.buffer]);
|
|
19437
19444
|
}
|
|
19438
19445
|
|
|
19439
19446
|
// src/world/SectionWorker.ts
|
|
@@ -19537,6 +19544,7 @@ function toInput(entries, maxAtlasSize, fluids, lighting) {
|
|
|
19537
19544
|
uvs: new Float32Array(quads * 8),
|
|
19538
19545
|
uvBounds: new Float32Array(quads * 16),
|
|
19539
19546
|
colors: new Float32Array(quads * 12),
|
|
19547
|
+
shade: new Float32Array(quads * 4),
|
|
19540
19548
|
indices: new Uint16Array(quads * 6),
|
|
19541
19549
|
cullFaces: new Uint8Array(template.cullFaces),
|
|
19542
19550
|
biomeTint: template.biomeTint ? new Uint8Array(template.biomeTint) : void 0,
|
|
@@ -19548,6 +19556,7 @@ function toInput(entries, maxAtlasSize, fluids, lighting) {
|
|
|
19548
19556
|
const uv = template.geometry.getAttribute("uv");
|
|
19549
19557
|
const bounds = template.geometry.getAttribute("uvBounds");
|
|
19550
19558
|
const color2 = template.geometry.getAttribute("color");
|
|
19559
|
+
const shade = template.geometry.getAttribute("shade");
|
|
19551
19560
|
for (let vertex = 0; vertex < quads * 4; vertex++) {
|
|
19552
19561
|
data.positions.set([position.getX(vertex), position.getY(vertex), position.getZ(vertex)], vertex * 3);
|
|
19553
19562
|
data.normals.set([normal.getX(vertex), normal.getY(vertex), normal.getZ(vertex)], vertex * 3);
|
|
@@ -19559,6 +19568,7 @@ function toInput(entries, maxAtlasSize, fluids, lighting) {
|
|
|
19559
19568
|
bounds?.getW(vertex) ?? 1
|
|
19560
19569
|
], vertex * 4);
|
|
19561
19570
|
data.colors.set([color2?.getX(vertex) ?? 1, color2?.getY(vertex) ?? 1, color2?.getZ(vertex) ?? 1], vertex * 3);
|
|
19571
|
+
data.shade[vertex] = shade?.getX(vertex) ?? 1;
|
|
19562
19572
|
}
|
|
19563
19573
|
for (let i2 = 0; i2 < data.indices.length; i2++) data.indices[i2] = indices.getX(i2) - 4 * Math.floor(i2 / 6);
|
|
19564
19574
|
templateCache.set(template, data);
|
|
@@ -19630,6 +19640,7 @@ var SectionMesh = class _SectionMesh extends import_three46.Group {
|
|
|
19630
19640
|
geometry.setAttribute("uv", new import_three46.Float32BufferAttribute(page.uvs.buffer, 2));
|
|
19631
19641
|
geometry.setAttribute("uvBounds", new import_three46.Float32BufferAttribute(page.uvBounds.buffer, 4));
|
|
19632
19642
|
geometry.setAttribute("color", new import_three46.Float32BufferAttribute(page.colors.buffer, 3));
|
|
19643
|
+
geometry.setAttribute("shade", new import_three46.Float32BufferAttribute(page.shade.buffer, 1));
|
|
19633
19644
|
geometry.setIndex(new import_three46.Uint32BufferAttribute(page.indices.buffer, 1));
|
|
19634
19645
|
geometry.computeBoundingBox();
|
|
19635
19646
|
geometry.computeBoundingSphere();
|