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.
@@ -1116,6 +1116,7 @@ var init_Materials = __esm({
1116
1116
  static createShadedCanvasMaterial(canvas, transparent = false, shade = false, boundUvs = false) {
1117
1117
  const vertShader = `
1118
1118
  uniform bool SHADE;
1119
+ attribute float shade;
1119
1120
 
1120
1121
  // Keep MSAA edge pixels from sampling outside the face's atlas region.
1121
1122
  #if __VERSION__ >= 300
@@ -1138,7 +1139,7 @@ var init_Materials = __esm({
1138
1139
  void main()
1139
1140
  {
1140
1141
 
1141
- if (SHADE) {
1142
+ if (SHADE && shade > 0.5) {
1142
1143
 
1143
1144
  #ifdef USE_INSTANCING
1144
1145
  vec3 N = vec3( modelMatrix * instanceMatrix * vec4(normal, 0.0) );
@@ -1247,7 +1248,7 @@ var init_Materials = __esm({
1247
1248
  side: transparent ? DoubleSide : FrontSide,
1248
1249
  alphaTest: 0.5
1249
1250
  });
1250
- Object.assign(material.defaultAttributeValues, { uvBounds: [0, 0, 1, 1] });
1251
+ Object.assign(material.defaultAttributeValues, { shade: [1], uvBounds: [0, 0, 1, 1] });
1251
1252
  return material;
1252
1253
  } catch (e) {
1253
1254
  console.warn(e);
@@ -10229,6 +10230,10 @@ var init_ModelObject = __esm({
10229
10230
  this.atlas.model.elements?.forEach((el) => {
10230
10231
  const elGeo = this._getBoxGeometryFromElement(el).clone();
10231
10232
  this.geometries.add(elGeo);
10233
+ elGeo.setAttribute("shade", new BufferAttribute5(
10234
+ new Float32Array(elGeo.getAttribute("position").count).fill(!this.originalModel.itemId && el.shade === false ? 0 : 1),
10235
+ 1
10236
+ ));
10232
10237
  if (this.options.cullMask) {
10233
10238
  const indices = Array.from(elGeo.getIndex().array);
10234
10239
  elGeo.setIndex(indices.filter((_, index) => {
@@ -17822,9 +17827,9 @@ function cached(map, key, load) {
17822
17827
  function compactQuads(geometry, keep) {
17823
17828
  const quads = keep.flatMap((kept, index) => kept ? [index] : []);
17824
17829
  const compact = new BufferGeometry8();
17825
- for (const [name, size] of Object.entries({ position: 3, normal: 3, uv: 2, uvBounds: 4, color: 3 })) {
17830
+ for (const [name, size] of Object.entries({ position: 3, normal: 3, uv: 2, uvBounds: 4, color: 3, shade: 1 })) {
17826
17831
  const source2 = geometry.getAttribute(name);
17827
- const defaults = name === "uvBounds" ? [0, 0, 1, 1] : name === "color" ? [1, 1, 1] : void 0;
17832
+ const defaults = name === "uvBounds" ? [0, 0, 1, 1] : name === "color" ? [1, 1, 1] : name === "shade" ? [1] : void 0;
17828
17833
  const values = new Float32Array(quads.length * 4 * size);
17829
17834
  for (let q = 0; q < quads.length; q++) {
17830
17835
  for (let vertex = 0; vertex < 4; vertex++) {
@@ -19090,7 +19095,7 @@ function buildSectionGeometry(input) {
19090
19095
  const cornerBrightness2 = ambientOcclusion ? new Float32Array(4) : void 0;
19091
19096
  for (const template of templateData) {
19092
19097
  const { quads } = template;
19093
- 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) {
19098
+ 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) {
19094
19099
  throw new RangeError("Section template arrays do not match its quad count");
19095
19100
  }
19096
19101
  }
@@ -19181,6 +19186,7 @@ function buildSectionGeometry(input) {
19181
19186
  }
19182
19187
  const positions = new Float32Array(faces * 12), normals = new Float32Array(faces * 12);
19183
19188
  const uvs = new Float32Array(faces * 8), uvBounds = new Float32Array(faces * 16), colors = new Float32Array(faces * 12);
19189
+ const shade = new Float32Array(faces * 4).fill(1);
19184
19190
  const outputIndices = new Uint32Array(faces * 6);
19185
19191
  const blockIndices = new Uint16Array(faces);
19186
19192
  let vertex = 0, indexOffset = 0;
@@ -19210,6 +19216,7 @@ function buildSectionGeometry(input) {
19210
19216
  normals[vertex * 3] = template.normals[source * 3];
19211
19217
  normals[vertex * 3 + 1] = template.normals[source * 3 + 1];
19212
19218
  normals[vertex * 3 + 2] = template.normals[source * 3 + 2];
19219
+ shade[vertex] = template.shade?.[source] ?? 1;
19213
19220
  uvs[vertex * 2] = mapU(template.uvs[source * 2]);
19214
19221
  uvs[vertex * 2 + 1] = mapV(template.uvs[source * 2 + 1]);
19215
19222
  uvBounds[vertex * 4] = mapU(template.uvBounds[source * 4]);
@@ -19262,11 +19269,11 @@ function buildSectionGeometry(input) {
19262
19269
  indexOffset += 6;
19263
19270
  }
19264
19271
  }
19265
- return { layer: page.layer, width: page.width, height: page.height, placements: page.placements, positions, normals, uvs, uvBounds, colors, indices: outputIndices, blockIndices };
19272
+ return { layer: page.layer, width: page.width, height: page.height, placements: page.placements, positions, normals, uvs, uvBounds, colors, shade, indices: outputIndices, blockIndices };
19266
19273
  });
19267
19274
  }
19268
19275
  function sectionGeometryTransferables(pages) {
19269
- 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]);
19276
+ 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]);
19270
19277
  }
19271
19278
 
19272
19279
  // src/world/SectionWorker.ts
@@ -19370,6 +19377,7 @@ function toInput(entries, maxAtlasSize, fluids, lighting) {
19370
19377
  uvs: new Float32Array(quads * 8),
19371
19378
  uvBounds: new Float32Array(quads * 16),
19372
19379
  colors: new Float32Array(quads * 12),
19380
+ shade: new Float32Array(quads * 4),
19373
19381
  indices: new Uint16Array(quads * 6),
19374
19382
  cullFaces: new Uint8Array(template.cullFaces),
19375
19383
  biomeTint: template.biomeTint ? new Uint8Array(template.biomeTint) : void 0,
@@ -19381,6 +19389,7 @@ function toInput(entries, maxAtlasSize, fluids, lighting) {
19381
19389
  const uv = template.geometry.getAttribute("uv");
19382
19390
  const bounds = template.geometry.getAttribute("uvBounds");
19383
19391
  const color2 = template.geometry.getAttribute("color");
19392
+ const shade = template.geometry.getAttribute("shade");
19384
19393
  for (let vertex = 0; vertex < quads * 4; vertex++) {
19385
19394
  data.positions.set([position.getX(vertex), position.getY(vertex), position.getZ(vertex)], vertex * 3);
19386
19395
  data.normals.set([normal.getX(vertex), normal.getY(vertex), normal.getZ(vertex)], vertex * 3);
@@ -19392,6 +19401,7 @@ function toInput(entries, maxAtlasSize, fluids, lighting) {
19392
19401
  bounds?.getW(vertex) ?? 1
19393
19402
  ], vertex * 4);
19394
19403
  data.colors.set([color2?.getX(vertex) ?? 1, color2?.getY(vertex) ?? 1, color2?.getZ(vertex) ?? 1], vertex * 3);
19404
+ data.shade[vertex] = shade?.getX(vertex) ?? 1;
19395
19405
  }
19396
19406
  for (let i2 = 0; i2 < data.indices.length; i2++) data.indices[i2] = indices.getX(i2) - 4 * Math.floor(i2 / 6);
19397
19407
  templateCache.set(template, data);
@@ -19463,6 +19473,7 @@ var SectionMesh = class _SectionMesh extends Group3 {
19463
19473
  geometry.setAttribute("uv", new Float32BufferAttribute10(page.uvs.buffer, 2));
19464
19474
  geometry.setAttribute("uvBounds", new Float32BufferAttribute10(page.uvBounds.buffer, 4));
19465
19475
  geometry.setAttribute("color", new Float32BufferAttribute10(page.colors.buffer, 3));
19476
+ geometry.setAttribute("shade", new Float32BufferAttribute10(page.shade.buffer, 1));
19466
19477
  geometry.setIndex(new Uint32BufferAttribute(page.indices.buffer, 1));
19467
19478
  geometry.computeBoundingBox();
19468
19479
  geometry.computeBoundingSphere();