postext-folio 0.74.2 → 0.76.0

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.
Files changed (40) hide show
  1. package/dist/bookGeometry.d.ts +6 -1
  2. package/dist/bookGeometry.d.ts.map +1 -1
  3. package/dist/bookGeometry.js +41 -20
  4. package/dist/bookGeometry.js.map +1 -1
  5. package/dist/pageFlip/finish.d.ts +8 -2
  6. package/dist/pageFlip/finish.d.ts.map +1 -1
  7. package/dist/pageFlip/finish.js +10 -2
  8. package/dist/pageFlip/finish.js.map +1 -1
  9. package/dist/pageFlip/leaf.d.ts +9 -1
  10. package/dist/pageFlip/leaf.d.ts.map +1 -1
  11. package/dist/pageFlip/leaf.js +22 -1
  12. package/dist/pageFlip/leaf.js.map +1 -1
  13. package/dist/pageFlip/materials.d.ts.map +1 -1
  14. package/dist/pageFlip/materials.js +15 -0
  15. package/dist/pageFlip/materials.js.map +1 -1
  16. package/dist/pageFlip/through.d.ts +78 -28
  17. package/dist/pageFlip/through.d.ts.map +1 -1
  18. package/dist/pageFlip/through.js +136 -27
  19. package/dist/pageFlip/through.js.map +1 -1
  20. package/dist/pageFlip.d.ts +8 -0
  21. package/dist/pageFlip.d.ts.map +1 -1
  22. package/dist/pageFlip.js +30 -12
  23. package/dist/pageFlip.js.map +1 -1
  24. package/dist/pageFlipFlat/shaders.d.ts.map +1 -1
  25. package/dist/pageFlipFlat/shaders.js +5 -1
  26. package/dist/pageFlipFlat/shaders.js.map +1 -1
  27. package/dist/postext/book.d.ts +9 -0
  28. package/dist/postext/book.d.ts.map +1 -1
  29. package/dist/postext/book.js +41 -1
  30. package/dist/postext/book.js.map +1 -1
  31. package/dist/postext/through.d.ts +2 -1
  32. package/dist/postext/through.d.ts.map +1 -1
  33. package/dist/postext/through.js +61 -3
  34. package/dist/postext/through.js.map +1 -1
  35. package/dist/viewer/layout.d.ts.map +1 -1
  36. package/dist/viewer/layout.js +1 -0
  37. package/dist/viewer/layout.js.map +1 -1
  38. package/dist/viewer/types.d.ts +5 -0
  39. package/dist/viewer/types.d.ts.map +1 -1
  40. package/package.json +3 -3
package/dist/pageFlip.js CHANGED
@@ -12,12 +12,12 @@ import { VideoAtlas, ATLAS_MAX, MAX_PAGE_VIDEOS } from './videoAtlas.js';
12
12
  import { cachedDesk, cachedRelief, deskKind } from './procedural.js';
13
13
  import { Loupe } from './loupe.js';
14
14
  import { FOV, NX_OPEN, NX, NY, BLOCK_PAGES, DURATION, BLOCK_DURATION, GAP, GRIP } from './pageFlip/constants.js';
15
- import { spreadColumns, column, MAX_PITCH, disposeLeaf, progressFrom, reach, foldOf, layLeaf, pagePlane } from './pageFlip/leaf.js';
15
+ import { spreadColumns, leafGeometry, setLeafFace, column, MAX_PITCH, disposeLeaf, progressFrom, reach, foldOf, layLeaf, pagePlane } from './pageFlip/leaf.js';
16
16
  import { edgeMaterial, pageMaterial, withStockForExtent, edgeUniforms, edgeColorOf, ease, easeOut, smooth, behindUniforms } from './pageFlip/materials.js';
17
17
  import { occluded, casterMaterial, casterGeometry, occlusionUniforms, syncCaster } from './pageFlip/occlusion.js';
18
18
  import { FinishTextures, dressFinish } from './pageFlip/finish.js';
19
19
  import { drawMirror } from './pageFlip/mirror.js';
20
- import { CUT_AIR, CUT_OPEN, casterCut, dressCut } from './pageFlip/through.js';
20
+ import { CUT_AIR, CUT_OPEN, boardEdges, casterCut, dressCut, leafCutOf } from './pageFlip/through.js';
21
21
  export { BLOCK_PAGES } from './pageFlip/constants.js';
22
22
  export { withStockForExtent } from './pageFlip/materials.js';
23
23
  export { foldOf, progressFrom, layLeaf, pagePlane } from './pageFlip/leaf.js';
@@ -494,7 +494,16 @@ export class PageFlipper {
494
494
  const f = this.finishes;
495
495
  const spec = mesh.material.userData.spec;
496
496
  dressFinish(mesh.material, f.maskOf(mesh.userData.Front), f.maskOf(mesh.userData.Back), spec?.clearcoat ?? 0);
497
- dressCut(mesh, f, (spec ?? this.bookSpec).caliperMm * this.pxPerMm(), { shared: this.leafCaster, cut: () => casterMaterial(true, casterCut()) });
497
+ // An open page's caster is the book's at rest; a leaf's, its own.
498
+ const open = mesh === this.left || mesh === this.right;
499
+ const caster = open ? { shared: this.staticCaster, cut: () => casterMaterial(false, casterCut()) } : { shared: this.leafCaster, cut: () => casterMaterial(true, casterCut()) };
500
+ dressCut(mesh, f, (spec ?? this.bookSpec).caliperMm * this.pxPerMm(), caster, this.onDesk());
501
+ }
502
+ /** Nothing lies under the book's outer leaves but the desk: its own
503
+ * printed covers stand for the case (or folded sheets have none), so a
504
+ * hole through to the end of the book shows the desk (#1586). */
505
+ onDesk() {
506
+ return !!this.coverSpec || this.resolved.binding.type === "folded";
498
507
  }
499
508
  /** The special inks of the pages (#1568): page source → its finish
500
509
  * mask. Pages left out have none; their textures are freed. */
@@ -682,7 +691,7 @@ export class PageFlipper {
682
691
  color: this.boardColor(),
683
692
  }
684
693
  : undefined;
685
- const mesh = new Mesh(stackGeometry(p, side, W, H, Math.round(n * half)), bands ? edgeMaterial(this.sign, bands, this.edges.color) : this.edges);
694
+ const mesh = new Mesh(stackGeometry(p, side, W, H, Math.round(n * half), this.appearance.edgeOutline), bands ? edgeMaterial(this.sign, bands, this.edges.color) : this.edges);
686
695
  mesh.castShadow = mesh.receiveShadow = true;
687
696
  this.stacks.push(mesh);
688
697
  this.stage.add(mesh);
@@ -763,6 +772,11 @@ export class PageFlipper {
763
772
  this.shadowScene.add(c);
764
773
  return c;
765
774
  });
775
+ // The open pages' casters drop holes that go through to the desk.
776
+ this.left.userData.caster = this.staticCasters[0];
777
+ this.right.userData.caster = this.staticCasters[1];
778
+ this.dressFinish(this.left);
779
+ this.dressFinish(this.right);
766
780
  occlusionUniforms.uOccRadius.value = 0.14 * W;
767
781
  this.layoutLight();
768
782
  }
@@ -1218,9 +1232,7 @@ export class PageFlipper {
1218
1232
  }
1219
1233
  /** A leaf's mesh, its pages not yet assigned. */
1220
1234
  leafMesh() {
1221
- const geometry = new PlaneGeometry(1, 1, NX, NY);
1222
- spreadColumns(geometry, NX);
1223
- geometry.setAttribute("ao", new BufferAttribute(new Float32Array(geometry.attributes.position.count).fill(1), 1));
1235
+ const geometry = leafGeometry();
1224
1236
  const mesh = new Mesh(geometry, pageMaterial(this.sign < 0, this.sign, CUT_AIR));
1225
1237
  mesh.material.userData.uniforms.uPaper.value.setRGB(...this.paper, SRGBColorSpace);
1226
1238
  mesh.castShadow = mesh.receiveShadow = true;
@@ -1296,13 +1308,11 @@ export class PageFlipper {
1296
1308
  boardParts(mesh) {
1297
1309
  let parts = mesh.userData.board;
1298
1310
  if (!parts) {
1299
- const geometry = new PlaneGeometry(1, 1, NX, NY);
1300
- spreadColumns(geometry, NX);
1301
- geometry.setAttribute("ao", new BufferAttribute(new Float32Array(geometry.attributes.position.count).fill(1), 1));
1302
- const back = new Mesh(geometry, mesh.material);
1311
+ const back = new Mesh(leafGeometry(), mesh.material);
1303
1312
  back.castShadow = back.receiveShadow = true;
1304
1313
  back.frustumCulled = false;
1305
- const slab = new Mesh(new BoxGeometry(1, 1, 1), new MeshStandardMaterial({ roughness: 0.8 }));
1314
+ const edges = boardEdges(leafCutOf(mesh));
1315
+ const slab = new Mesh(edges.geometry, edges.material);
1306
1316
  slab.castShadow = slab.receiveShadow = true;
1307
1317
  mesh.add(back, slab);
1308
1318
  parts = { back, slab };
@@ -1730,6 +1740,8 @@ export class PageFlipper {
1730
1740
  const lay = (geometry, face) => layLeaf(geometry, fold, forward, W, H, Math.min(lift, 0.6), book, 1, q, 0, now, { thick, face });
1731
1741
  const { phi, pivot } = lay(mesh.geometry, 1);
1732
1742
  lay(parts.back.geometry, -1);
1743
+ setLeafFace(mesh.geometry, 1);
1744
+ setLeafFace(parts.back.geometry, -1);
1733
1745
  parts.slab.position.set((W / 2) * Math.cos(phi), 0, pivot + (W / 2) * Math.sin(phi));
1734
1746
  parts.slab.rotation.set(0, -phi, 0);
1735
1747
  parts.slab.scale.set(W, H, thick * 0.97);
@@ -1738,6 +1750,7 @@ export class PageFlipper {
1738
1750
  }
1739
1751
  else {
1740
1752
  layLeaf(mesh.geometry, fold, forward, W, H, lift, book, spec.rigidity, q, flutter, now);
1753
+ setLeafFace(mesh.geometry, 0);
1741
1754
  const parts = mesh.userData.board;
1742
1755
  if (parts)
1743
1756
  parts.back.visible = parts.slab.visible = false;
@@ -1765,6 +1778,8 @@ export class PageFlipper {
1765
1778
  const lay = (geometry, face) => layLeaf(geometry, null, turn.forward, W, H, 0.5, book, 1, q, 0, 0, { thick, face });
1766
1779
  const { phi, pivot } = lay(mesh.geometry, 1);
1767
1780
  lay(parts.back.geometry, -1);
1781
+ setLeafFace(mesh.geometry, 1);
1782
+ setLeafFace(parts.back.geometry, -1);
1768
1783
  parts.slab.position.set((W / 2) * Math.cos(phi), 0, pivot + (W / 2) * Math.sin(phi));
1769
1784
  parts.slab.rotation.set(0, -phi, 0);
1770
1785
  parts.slab.scale.set(W, H, thick * 0.97);
@@ -2076,6 +2091,9 @@ export class PageFlipper {
2076
2091
  disposeLeaf(mesh);
2077
2092
  if (this.blockMesh)
2078
2093
  disposeLeaf(this.blockMesh);
2094
+ for (const mesh of [this.left, this.right])
2095
+ for (const key of ["cutDepth", "cutCaster"])
2096
+ mesh.userData[key]?.dispose();
2079
2097
  for (const mesh of [this.left, this.right, this.desk, ...this.stacks]) {
2080
2098
  mesh.geometry.dispose();
2081
2099
  mesh.material.dispose();