@objectifthunes/react-three-book 0.2.0 → 0.2.2

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/index.d.ts CHANGED
@@ -445,6 +445,13 @@ export declare class Cylinder {
445
445
  */
446
446
  export declare function drawImageWithFit(ctx: CanvasRenderingContext2D, image: HTMLImageElement, x: number, y: number, width: number, height: number, fit: ImageFitMode): void;
447
447
 
448
+ /**
449
+ * Returns the 0-indexed page indices where a spread can start.
450
+ * In a staple-bound book, facing page pairs are (1,2), (3,4), (5,6), …
451
+ * — i.e. odd indices where i+1 < pageCount.
452
+ */
453
+ export declare function getSpreadPairs(pageCount: number): number[];
454
+
448
455
  /** Minimal Book interface consumed by the binding. */
449
456
  declare interface IBook {
450
457
  readonly totalThickness: number;
@@ -1009,6 +1016,52 @@ export declare class RendererFactory {
1009
1016
  getBounds(): THREE.Box3;
1010
1017
  }
1011
1018
 
1019
+ export declare class SpreadContent {
1020
+ readonly canvas: HTMLCanvasElement;
1021
+ readonly texts: TextBlock[];
1022
+ readonly left: IPageContent;
1023
+ readonly right: IPageContent;
1024
+ /** Width of a single page in pixels. */
1025
+ readonly pageWidth: number;
1026
+ /** Height of a single page in pixels. */
1027
+ readonly pageHeight: number;
1028
+ private readonly ctx;
1029
+ private readonly _texture;
1030
+ private _source;
1031
+ get texture(): THREE.Texture;
1032
+ /** The base layer drawn beneath text blocks (full spread width). */
1033
+ get source(): HTMLCanvasElement | HTMLImageElement | null;
1034
+ set source(v: HTMLCanvasElement | HTMLImageElement | null);
1035
+ constructor(options?: SpreadContentOptions);
1036
+ addText(options?: TextBlockOptions): TextBlock;
1037
+ removeText(text: TextBlock): void;
1038
+ /** Update a text block by index. Only provided fields are changed. */
1039
+ updateText(index: number, options: Partial<TextBlockOptions>): void;
1040
+ /**
1041
+ * Re-composite the canvas: source layer + text blocks.
1042
+ * Call every frame (or when content changes).
1043
+ *
1044
+ * @param root Optional THREE.Object3D to traverse for texture sync
1045
+ * (needed because three-book clones material textures).
1046
+ */
1047
+ update(root?: THREE.Object3D): void;
1048
+ /**
1049
+ * Traverse `root` and set `needsUpdate = true` on every material map whose
1050
+ * source image is this spread's canvas.
1051
+ */
1052
+ syncMaterials(root: THREE.Object3D): void;
1053
+ dispose(): void;
1054
+ }
1055
+
1056
+ export declare interface SpreadContentOptions {
1057
+ /** Width of a single page in pixels. The spread canvas will be 2x this. */
1058
+ pageWidth?: number;
1059
+ /** Height of a single page in pixels. */
1060
+ pageHeight?: number;
1061
+ /** Source canvas or image to draw as the base layer (full spread width). */
1062
+ source?: HTMLCanvasElement | HTMLImageElement | null;
1063
+ }
1064
+
1012
1065
  export declare class SpritePageContent2 implements IPageContent {
1013
1066
  private m_Texture;
1014
1067
  private m_TextureST;