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/bundle.js CHANGED
@@ -36798,6 +36798,7 @@ void main() {
36798
36798
  static createShadedCanvasMaterial(canvas, transparent = false, shade = false, boundUvs = false) {
36799
36799
  const vertShader = `
36800
36800
  uniform bool SHADE;
36801
+ attribute float shade;
36801
36802
 
36802
36803
  // Keep MSAA edge pixels from sampling outside the face's atlas region.
36803
36804
  #if __VERSION__ >= 300
@@ -36820,7 +36821,7 @@ void main() {
36820
36821
  void main()
36821
36822
  {
36822
36823
 
36823
- if (SHADE) {
36824
+ if (SHADE && shade > 0.5) {
36824
36825
 
36825
36826
  #ifdef USE_INSTANCING
36826
36827
  vec3 N = vec3( modelMatrix * instanceMatrix * vec4(normal, 0.0) );
@@ -36929,7 +36930,7 @@ void main() {
36929
36930
  side: transparent ? DoubleSide : FrontSide,
36930
36931
  alphaTest: 0.5
36931
36932
  });
36932
- Object.assign(material.defaultAttributeValues, { uvBounds: [0, 0, 1, 1] });
36933
+ Object.assign(material.defaultAttributeValues, { shade: [1], uvBounds: [0, 0, 1, 1] });
36933
36934
  return material;
36934
36935
  } catch (e6) {
36935
36936
  console.warn(e6);
@@ -92843,6 +92844,10 @@ ${shader.fragmentShader}`.replace(
92843
92844
  this.atlas.model.elements?.forEach((el) => {
92844
92845
  const elGeo = this._getBoxGeometryFromElement(el).clone();
92845
92846
  this.geometries.add(elGeo);
92847
+ elGeo.setAttribute("shade", new BufferAttribute(
92848
+ new Float32Array(elGeo.getAttribute("position").count).fill(!this.originalModel.itemId && el.shade === false ? 0 : 1),
92849
+ 1
92850
+ ));
92846
92851
  if (this.options.cullMask) {
92847
92852
  const indices = Array.from(elGeo.getIndex().array);
92848
92853
  elGeo.setIndex(indices.filter((_4, index) => {
@@ -103135,9 +103140,9 @@ gl_FragDepth=readDepth(vUv);
103135
103140
  function compactQuads(geometry, keep) {
103136
103141
  const quads = keep.flatMap((kept, index) => kept ? [index] : []);
103137
103142
  const compact = new BufferGeometry();
103138
- for (const [name2, size] of Object.entries({ position: 3, normal: 3, uv: 2, uvBounds: 4, color: 3 })) {
103143
+ for (const [name2, size] of Object.entries({ position: 3, normal: 3, uv: 2, uvBounds: 4, color: 3, shade: 1 })) {
103139
103144
  const source2 = geometry.getAttribute(name2);
103140
- const defaults = name2 === "uvBounds" ? [0, 0, 1, 1] : name2 === "color" ? [1, 1, 1] : void 0;
103145
+ const defaults = name2 === "uvBounds" ? [0, 0, 1, 1] : name2 === "color" ? [1, 1, 1] : name2 === "shade" ? [1] : void 0;
103141
103146
  const values = new Float32Array(quads.length * 4 * size);
103142
103147
  for (let q3 = 0; q3 < quads.length; q3++) {
103143
103148
  for (let vertex2 = 0; vertex2 < 4; vertex2++) {
@@ -104433,7 +104438,7 @@ gl_FragDepth=readDepth(vUv);
104433
104438
  const cornerBrightness2 = ambientOcclusion ? new Float32Array(4) : void 0;
104434
104439
  for (const template of templateData) {
104435
104440
  const { quads } = template;
104436
- 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) {
104441
+ 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) {
104437
104442
  throw new RangeError("Section template arrays do not match its quad count");
104438
104443
  }
104439
104444
  }
@@ -104524,6 +104529,7 @@ gl_FragDepth=readDepth(vUv);
104524
104529
  }
104525
104530
  const positions = new Float32Array(faces * 12), normals = new Float32Array(faces * 12);
104526
104531
  const uvs = new Float32Array(faces * 8), uvBounds = new Float32Array(faces * 16), colors = new Float32Array(faces * 12);
104532
+ const shade = new Float32Array(faces * 4).fill(1);
104527
104533
  const outputIndices = new Uint32Array(faces * 6);
104528
104534
  const blockIndices = new Uint16Array(faces);
104529
104535
  let vertex2 = 0, indexOffset = 0;
@@ -104553,6 +104559,7 @@ gl_FragDepth=readDepth(vUv);
104553
104559
  normals[vertex2 * 3] = template.normals[source * 3];
104554
104560
  normals[vertex2 * 3 + 1] = template.normals[source * 3 + 1];
104555
104561
  normals[vertex2 * 3 + 2] = template.normals[source * 3 + 2];
104562
+ shade[vertex2] = template.shade?.[source] ?? 1;
104556
104563
  uvs[vertex2 * 2] = mapU(template.uvs[source * 2]);
104557
104564
  uvs[vertex2 * 2 + 1] = mapV(template.uvs[source * 2 + 1]);
104558
104565
  uvBounds[vertex2 * 4] = mapU(template.uvBounds[source * 4]);
@@ -104605,11 +104612,11 @@ gl_FragDepth=readDepth(vUv);
104605
104612
  indexOffset += 6;
104606
104613
  }
104607
104614
  }
104608
- return { layer: page.layer, width: page.width, height: page.height, placements: page.placements, positions, normals, uvs, uvBounds, colors, indices: outputIndices, blockIndices };
104615
+ return { layer: page.layer, width: page.width, height: page.height, placements: page.placements, positions, normals, uvs, uvBounds, colors, shade, indices: outputIndices, blockIndices };
104609
104616
  });
104610
104617
  }
104611
104618
  function sectionGeometryTransferables(pages) {
104612
- 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]);
104619
+ 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]);
104613
104620
  }
104614
104621
 
104615
104622
  // src/world/SectionWorker.ts
@@ -104715,6 +104722,7 @@ gl_FragDepth=readDepth(vUv);
104715
104722
  uvs: new Float32Array(quads * 8),
104716
104723
  uvBounds: new Float32Array(quads * 16),
104717
104724
  colors: new Float32Array(quads * 12),
104725
+ shade: new Float32Array(quads * 4),
104718
104726
  indices: new Uint16Array(quads * 6),
104719
104727
  cullFaces: new Uint8Array(template.cullFaces),
104720
104728
  biomeTint: template.biomeTint ? new Uint8Array(template.biomeTint) : void 0,
@@ -104726,6 +104734,7 @@ gl_FragDepth=readDepth(vUv);
104726
104734
  const uv = template.geometry.getAttribute("uv");
104727
104735
  const bounds = template.geometry.getAttribute("uvBounds");
104728
104736
  const color3 = template.geometry.getAttribute("color");
104737
+ const shade = template.geometry.getAttribute("shade");
104729
104738
  for (let vertex2 = 0; vertex2 < quads * 4; vertex2++) {
104730
104739
  data.positions.set([position.getX(vertex2), position.getY(vertex2), position.getZ(vertex2)], vertex2 * 3);
104731
104740
  data.normals.set([normal.getX(vertex2), normal.getY(vertex2), normal.getZ(vertex2)], vertex2 * 3);
@@ -104737,6 +104746,7 @@ gl_FragDepth=readDepth(vUv);
104737
104746
  bounds?.getW(vertex2) ?? 1
104738
104747
  ], vertex2 * 4);
104739
104748
  data.colors.set([color3?.getX(vertex2) ?? 1, color3?.getY(vertex2) ?? 1, color3?.getZ(vertex2) ?? 1], vertex2 * 3);
104749
+ data.shade[vertex2] = shade?.getX(vertex2) ?? 1;
104740
104750
  }
104741
104751
  for (let i5 = 0; i5 < data.indices.length; i5++) data.indices[i5] = indices.getX(i5) - 4 * Math.floor(i5 / 6);
104742
104752
  templateCache.set(template, data);
@@ -104808,6 +104818,7 @@ gl_FragDepth=readDepth(vUv);
104808
104818
  geometry.setAttribute("uv", new Float32BufferAttribute(page.uvs.buffer, 2));
104809
104819
  geometry.setAttribute("uvBounds", new Float32BufferAttribute(page.uvBounds.buffer, 4));
104810
104820
  geometry.setAttribute("color", new Float32BufferAttribute(page.colors.buffer, 3));
104821
+ geometry.setAttribute("shade", new Float32BufferAttribute(page.shade.buffer, 1));
104811
104822
  geometry.setIndex(new Uint32BufferAttribute(page.indices.buffer, 1));
104812
104823
  geometry.computeBoundingBox();
104813
104824
  geometry.computeBoundingSphere();