@objectifthunes/react-three-book 0.1.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 (3) hide show
  1. package/dist/index.d.ts +1266 -0
  2. package/dist/index.js +2880 -0
  3. package/package.json +35 -0
@@ -0,0 +1,1266 @@
1
+ import { Context } from 'react';
2
+ import { ForwardRefExoticComponent } from 'react';
3
+ import { ReactNode } from 'react';
4
+ import { RefAttributes } from 'react';
5
+ import * as THREE from 'three';
6
+
7
+ export declare class AnimationCurve {
8
+ keys: Keyframe_2[];
9
+ constructor(keys?: Keyframe_2[]);
10
+ /**
11
+ * Evaluate the curve at parameter `t`.
12
+ * Linear interpolation between keyframes (Unity default is cubic,
13
+ * but the exact tangent data is not available here).
14
+ */
15
+ evaluate(t: number): number;
16
+ }
17
+
18
+ export declare interface AutoTurnControls {
19
+ /** Turn one page forward. */
20
+ turnNext: (settings?: AutoTurnSettings) => boolean;
21
+ /** Turn one page backward. */
22
+ turnPrev: (settings?: AutoTurnSettings) => boolean;
23
+ /** Turn all remaining pages in the given direction. */
24
+ turnAll: (direction: AutoTurnDirection, settings?: AutoTurnSettings) => boolean;
25
+ /** Full control: queue `turnCount` auto-turns in one call. */
26
+ startAutoTurning: (direction: AutoTurnDirection, settings?: AutoTurnSettings, turnCount?: number, delayPerTurn?: number | AutoTurnSetting) => boolean;
27
+ /** Remove queued turns that haven't started yet. */
28
+ cancelPendingAutoTurns: () => void;
29
+ }
30
+
31
+ /**
32
+ * Ported from Book.cs — AutoTurn enums, settings, and value types (lines ~1076-1418).
33
+ *
34
+ * Faithful line-by-line port of:
35
+ * - AutoTurnDirection enum
36
+ * - AutoTurnMode enum
37
+ * - AutoTurnSettings class
38
+ * - AutoTurnSetting struct (→ class with clone())
39
+ * - AutoTurnSettingMode enum
40
+ * - AutoTurnSettingCurveTimeMode enum
41
+ *
42
+ * Unity `AnimationCurve` is approximated by a simple keyframe array
43
+ * with linear interpolation (evaluate).
44
+ */
45
+ /**
46
+ * Defines the direction for auto page turning.
47
+ */
48
+ export declare enum AutoTurnDirection {
49
+ /** Indicates the next page direction. */
50
+ Next = 0,
51
+ /** Indicates the previous page direction. */
52
+ Back = 1
53
+ }
54
+
55
+ /**
56
+ * Defines the mode for auto page turning.
57
+ */
58
+ export declare enum AutoTurnMode {
59
+ /** This mode simulates swiping the paper surface to turn it. */
60
+ Surface = 0,
61
+ /** This mode simulates holding the paper edge and turning it. */
62
+ Edge = 1
63
+ }
64
+
65
+ /** Mirrors C# AutoTurnMode enum */
66
+ declare enum AutoTurnMode_2 {
67
+ Surface = 0,
68
+ Edge = 1
69
+ }
70
+
71
+ /**
72
+ * Represents an individual setting for auto page turning.
73
+ *
74
+ * C# struct — emulated with clone().
75
+ */
76
+ export declare class AutoTurnSetting {
77
+ private m_Mode;
78
+ private m_Constant;
79
+ private m_ConstantMin;
80
+ private m_ConstantMax;
81
+ private m_Curve;
82
+ private m_CurveMin;
83
+ private m_CurveMax;
84
+ private m_CurveTimeMode;
85
+ get mode(): AutoTurnSettingMode;
86
+ set mode(value: AutoTurnSettingMode);
87
+ get constant(): number;
88
+ set constant(value: number);
89
+ get constantMin(): number;
90
+ set constantMin(value: number);
91
+ get constantMax(): number;
92
+ set constantMax(value: number);
93
+ get curve(): AnimationCurve | null;
94
+ set curve(value: AnimationCurve | null);
95
+ get curveMin(): AnimationCurve | null;
96
+ set curveMin(value: AnimationCurve | null);
97
+ get curveMax(): AnimationCurve | null;
98
+ set curveMax(value: AnimationCurve | null);
99
+ get curveTimeMode(): AutoTurnSettingCurveTimeMode;
100
+ set curveTimeMode(value: AutoTurnSettingCurveTimeMode);
101
+ constructor();
102
+ /** A constant value. */
103
+ constructor(constant: number);
104
+ /** A random value generated between two constant values. */
105
+ constructor(constantMin: number, constantMax: number);
106
+ /** A value based on a curve. */
107
+ static fromCurve(curve: AnimationCurve, curveTimeMode: AutoTurnSettingCurveTimeMode): AutoTurnSetting;
108
+ /** A random value generated between two curves. */
109
+ static fromCurveRange(curveMin: AnimationCurve, curveMax: AnimationCurve, curveTimeMode: AutoTurnSettingCurveTimeMode): AutoTurnSetting;
110
+ /* Excluded from this release type: getValue */
111
+ /* Excluded from this release type: clampValues */
112
+ private clampCurve;
113
+ clone(): AutoTurnSetting;
114
+ }
115
+
116
+ /**
117
+ * Defines the curve time mode of AutoTurnSetting when AutoTurnSettingMode is
118
+ * Curve or RandomBetweenTwoCurves.
119
+ */
120
+ export declare enum AutoTurnSettingCurveTimeMode {
121
+ /**
122
+ * Evaluates the curve based on the current paper index divided by the
123
+ * total paper count. This gives a time value proportional to the
124
+ * progression through the papers.
125
+ */
126
+ PaperIndexTime = 0,
127
+ /**
128
+ * Evaluates the curve based on the current turn index divided by the
129
+ * total turn count. This provides a time value proportional to the
130
+ * progression through the turns.
131
+ */
132
+ TurnIndexTime = 1
133
+ }
134
+
135
+ /**
136
+ * Defines the mode of AutoTurnSetting.
137
+ */
138
+ export declare enum AutoTurnSettingMode {
139
+ /** Specifies a constant value for the auto turn setting. */
140
+ Constant = 0,
141
+ /** Specifies a random value generated between two constant values for the auto turn setting. */
142
+ RandomBetweenTwoConstants = 1,
143
+ /** Specifies a value based on a curve for the auto turn setting. */
144
+ Curve = 2,
145
+ /** Specifies a random value generated between two curves for the auto turn setting. */
146
+ RandomBetweenTwoCurves = 3
147
+ }
148
+
149
+ /**
150
+ * Represents settings for auto page turning.
151
+ */
152
+ export declare class AutoTurnSettings {
153
+ /* Excluded from this release type: kMinTwist */
154
+ /* Excluded from this release type: kMaxTwist */
155
+ /* Excluded from this release type: kMinBend */
156
+ /* Excluded from this release type: kMaxBend */
157
+ /* Excluded from this release type: kMinDuration */
158
+ /* Excluded from this release type: kMaxDuration */
159
+ private m_Mode;
160
+ private m_Twist;
161
+ private m_Bend;
162
+ private m_Duration;
163
+ get mode(): AutoTurnMode;
164
+ set mode(value: AutoTurnMode);
165
+ get twist(): AutoTurnSetting;
166
+ set twist(value: AutoTurnSetting);
167
+ get bend(): AutoTurnSetting;
168
+ set bend(value: AutoTurnSetting);
169
+ get duration(): AutoTurnSetting;
170
+ set duration(value: AutoTurnSetting);
171
+ /* Excluded from this release type: getModeValue */
172
+ /* Excluded from this release type: getBendValue */
173
+ /* Excluded from this release type: getDurationValue */
174
+ /* Excluded from this release type: getTwistValue */
175
+ }
176
+
177
+ /**
178
+ * R3F component that manages the complete lifecycle of a ThreeBook.
179
+ * Forward-refs to the underlying `ThreeBook` instance.
180
+ */
181
+ export declare const Book: ForwardRefExoticComponent<BookProps & RefAttributes<ThreeBook>>;
182
+
183
+ export declare abstract class BookBinding {
184
+ abstract createBound(book: ThreeBook, root: THREE.Object3D, rendererFactory: RendererFactory, meshFactory: MeshFactory): BookBound;
185
+ }
186
+
187
+ export declare abstract class BookBound {
188
+ protected m_Book: ThreeBook;
189
+ protected m_Root: THREE.Object3D;
190
+ abstract get useSharedMeshDataForLowpoly(): boolean;
191
+ abstract get binderRenderer(): BookRenderer;
192
+ constructor(book: ThreeBook, root: THREE.Object3D);
193
+ abstract createPaperPattern(quality: number, size: THREE.Vector2, thickness: number, uvMargin: PaperUVMargin, reduceOverdraw: boolean, reduceSubMeshes: boolean): PaperPattern;
194
+ abstract resetPaperPosition(paper: Paper): void;
195
+ abstract updatePaperPosition(paper: Paper): void;
196
+ abstract onLateUpdate(): void;
197
+ }
198
+
199
+ /**
200
+ * Content for the book: covers and pages.
201
+ *
202
+ * In Unity, list items can be Sprite, SpritePageContent, or LivePageContent.
203
+ * In Three.js, list items are either THREE.Texture or IPageContent instances.
204
+ */
205
+ export declare class BookContent {
206
+ private m_Direction;
207
+ private m_Covers;
208
+ private m_Pages;
209
+ private m_Book;
210
+ private get coverCount4();
211
+ private get pageCount4();
212
+ get book(): ThreeBook | null;
213
+ get covers(): (THREE.Texture | IPageContent | null)[];
214
+ get pages(): (THREE.Texture | IPageContent | null)[];
215
+ get isEmpty(): boolean;
216
+ get direction(): BookDirection;
217
+ set direction(value: BookDirection);
218
+ get coverContents(): IPageContent[];
219
+ get pageContents(): IPageContent[];
220
+ private getContents;
221
+ private nextMultipleOf4;
222
+ private getContent;
223
+ init(book: ThreeBook): void;
224
+ convertCoverIndexToPaperSideIndex(coverIndex: number): number;
225
+ convertPageIndexToPaperSideIndex(pageIndex: number): number;
226
+ convertPaperSideIndexToCoverIndex(paperSideIndex: number): number;
227
+ convertPaperSideIndexToPageIndex(paperSideIndex: number): number;
228
+ convertPaperSideIndexToOpenProgress(paperSideIndex: number): number;
229
+ isCoverPaperSideIndex(paperSideIndex: number): boolean;
230
+ isPagePaperSideIndex(paperSideIndex: number): boolean;
231
+ }
232
+
233
+ export declare const BookContext: Context<ThreeBook | null>;
234
+
235
+ export declare interface BookControls {
236
+ /** Jump to open progress 0–1 (0 = closed, 1 = fully open). */
237
+ setOpenProgress: (progress: number) => void;
238
+ /** Jump to a specific paper-side index. */
239
+ setOpenProgressByIndex: (index: number) => void;
240
+ /** Cancel any in-progress interactive drag turn. */
241
+ stopTurning: () => void;
242
+ }
243
+
244
+ /**
245
+ * Ported from BookContent.cs — BookDirection enum.
246
+ */
247
+ export declare enum BookDirection {
248
+ LeftToRight = 0,
249
+ RightToLeft = 1,
250
+ UpToDown = 2,
251
+ DownToUp = 3
252
+ }
253
+
254
+ export declare class BookHeightException extends Error {
255
+ constructor();
256
+ }
257
+
258
+ /**
259
+ * Wires pointer-drag events for interactive page turning. Renders nothing.
260
+ *
261
+ * Place inside `<Book>` to pick up the book automatically:
262
+ * <Book ...><BookInteraction orbitControlsRef={orbitRef} /></Book>
263
+ *
264
+ * Or pass an explicit ref when used outside a `<Book>` tree:
265
+ * <BookInteraction bookRef={bookRef} orbitControlsRef={orbitRef} />
266
+ */
267
+ export declare function BookInteraction({ bookRef: externalRef, enabled, orbitControlsRef }: BookInteractionProps): null;
268
+
269
+ export declare interface BookInteractionProps {
270
+ /** Explicit book ref. If omitted, the nearest `<Book>` context is used. */
271
+ bookRef?: React.RefObject<ThreeBook | null>;
272
+ /** Disable turning without unmounting. Default: true. */
273
+ enabled?: boolean;
274
+ /** OrbitControls ref — disabled during drag, re-enabled on release. */
275
+ orbitControlsRef?: React.RefObject<{
276
+ enabled: boolean;
277
+ } | null>;
278
+ }
279
+
280
+ export declare interface BookOptions {
281
+ content?: BookContent;
282
+ binding?: BookBinding;
283
+ initialOpenProgress?: number;
284
+ buildOnAwake?: boolean;
285
+ castShadows?: boolean;
286
+ alignToGround?: boolean;
287
+ hideBinder?: boolean;
288
+ createColliders?: boolean;
289
+ reduceShadows?: boolean;
290
+ reduceSubMeshes?: boolean;
291
+ reduceOverdraw?: boolean;
292
+ coverPaperSetup?: Partial<PaperSetupInit>;
293
+ pagePaperSetup?: Partial<PaperSetupInit>;
294
+ }
295
+
296
+ export declare interface BookProps extends BookOptions {
297
+ /** Called after `book.init()` succeeds. */
298
+ onBuilt?: (book: ThreeBook) => void;
299
+ /**
300
+ * Called if `book.init()` throws (e.g. BookHeightException when the stack
301
+ * is too tall for the given page dimensions).
302
+ */
303
+ onError?: (err: Error) => void;
304
+ /**
305
+ * Children are rendered inside the BookContext so they can call
306
+ * `useBook()`, `useBookControls()`, `useAutoTurn()`, etc. without a ref.
307
+ *
308
+ * Example: <BookInteraction> placed here automatically discovers the book.
309
+ */
310
+ children?: ReactNode;
311
+ }
312
+
313
+ export declare interface BookRaycastHit {
314
+ point: THREE.Vector3;
315
+ textureCoordinate: THREE.Vector2;
316
+ pageContent: IPageContent | null;
317
+ paperIndex: number;
318
+ pageIndex: number;
319
+ }
320
+
321
+ /** Mirrors C# BookRaycastHit struct */
322
+ declare interface BookRaycastHit_2 {
323
+ point: THREE.Vector3;
324
+ textureCoordinate: THREE.Vector2;
325
+ pageContent: IPageContent_2 | null;
326
+ paperIndex: number;
327
+ pageIndex: number;
328
+ }
329
+
330
+ export declare class BookRenderer {
331
+ private m_Object3D;
332
+ private m_Mesh;
333
+ private m_Visibility;
334
+ private m_CreateCollider;
335
+ private m_Id;
336
+ private m_PropertyBlocks;
337
+ private m_MaterialTextures;
338
+ get createCollider(): boolean;
339
+ set createCollider(value: boolean);
340
+ get bounds(): THREE.Box3;
341
+ get id(): number;
342
+ get transform(): THREE.Object3D;
343
+ get visibility(): boolean;
344
+ set castShadows(value: boolean);
345
+ set mesh(value: THREE.BufferGeometry | null);
346
+ get meshObject(): THREE.Mesh;
347
+ constructor(root: THREE.Object3D, name: string, createCollider: boolean);
348
+ setMaterials(materials: THREE.Material | THREE.Material[]): void;
349
+ setPropertyBlock(properties: Record<string, unknown>, materialIndex: number): void;
350
+ reset(name: string): void;
351
+ clear(): void;
352
+ destroy(): void;
353
+ setVisibility(visibility: boolean): void;
354
+ updateCollider(): void;
355
+ private getMaterial;
356
+ private isMapCapable;
357
+ private isColorCapable;
358
+ private getSTKey;
359
+ private applyTextureProperty;
360
+ private clearMaterialTexture;
361
+ private clearManagedTexture;
362
+ private disposeManagedTextures;
363
+ private disposeCurrentMaterials;
364
+ }
365
+
366
+ export declare interface BookState {
367
+ /** True once `book.init()` has been called successfully. */
368
+ isBuilt: boolean;
369
+ /** True while the user is dragging a page. */
370
+ isTurning: boolean;
371
+ /** True while any page is in its falling/settling animation. */
372
+ isFalling: boolean;
373
+ /** True when no turning, falling, or auto-turning is happening. */
374
+ isIdle: boolean;
375
+ /** True while an auto-turn is currently playing. */
376
+ isAutoTurning: boolean;
377
+ /** True while there are queued auto-turns waiting to start. */
378
+ hasPendingAutoTurns: boolean;
379
+ /** Total number of papers (covers + pages). */
380
+ paperCount: number;
381
+ /** Number of cover papers (2 physical sheets = 4 surfaces). */
382
+ coverPaperCount: number;
383
+ /** Number of interior page papers. */
384
+ pagePaperCount: number;
385
+ }
386
+
387
+ /**
388
+ * Creates a 512×512 `THREE.CanvasTexture` suitable for use as a book page.
389
+ *
390
+ * - Fills the background with `color`.
391
+ * - If `image` is provided, draws it using `fitMode` and `fullBleed`.
392
+ * - Otherwise, renders `label` as centred text (useful for debugging).
393
+ */
394
+ export declare function createPageTexture(color: string, label: string, image: HTMLImageElement | null, fitMode: ImageFitMode, fullBleed: boolean): THREE.Texture;
395
+
396
+ /**
397
+ * Ported from Book.cs — Cylinder struct (lines ~3805-3902).
398
+ *
399
+ * Rolling-deformation core used to curl paper around a cylindrical axis.
400
+ *
401
+ * C# value-type (struct) semantics are emulated with a clone() method.
402
+ *
403
+ * Unity's `Quaternion.Euler(0, eulerY, z) * Vector3(x, 0, 0)` is replaced
404
+ * with manual trig: first rotate by Z around the Z-axis, then rotate by Y
405
+ * around the Y-axis.
406
+ */
407
+ export declare class Cylinder {
408
+ private m_PositionX;
409
+ private m_PositionZ;
410
+ private m_DirectionX;
411
+ private m_DirectionZ;
412
+ private m_EulerY;
413
+ private m_Radius;
414
+ get position(): THREE.Vector3;
415
+ set position(value: THREE.Vector3);
416
+ set direction(value: THREE.Vector3);
417
+ set radius(value: number);
418
+ rollPoint(point: THREE.Vector3): THREE.Vector3;
419
+ /**
420
+ * Apply Quaternion.Euler(0, eulerY, z) * Vector3(x, 0, 0) manually.
421
+ *
422
+ * Unity Euler convention (ZXY intrinsic, i.e. applied Z then X then Y):
423
+ * 1. Rotate (x, 0, 0) by Z degrees around Z-axis.
424
+ * 2. Rotate by X degrees around X-axis (X = 0 here, so skip).
425
+ * 3. Rotate by Y degrees around Y-axis.
426
+ */
427
+ private eulerRotateVector;
428
+ private roll;
429
+ private getOffset;
430
+ private getClosestPoint;
431
+ private getSide;
432
+ clone(): Cylinder;
433
+ }
434
+
435
+ /**
436
+ * Draws `image` into a 2D canvas context within the rectangle
437
+ * (x, y, width, height) using the given fit mode.
438
+ *
439
+ * - `'fill'` — stretches to fill exactly, ignoring aspect ratio
440
+ * - `'contain'` — scales uniformly to fit inside, letterboxed
441
+ * - `'cover'` — scales uniformly to fill, cropping the overflow
442
+ */
443
+ export declare function drawImageWithFit(ctx: CanvasRenderingContext2D, image: HTMLImageElement, x: number, y: number, width: number, height: number, fit: ImageFitMode): void;
444
+
445
+ /** Minimal Book interface consumed by the binding. */
446
+ declare interface IBook {
447
+ readonly totalThickness: number;
448
+ readonly minPaperWidth: number;
449
+ readonly minPaperHeight: number;
450
+ readonly maxPaperThickness: number;
451
+ readonly minPaperThickness: number;
452
+ readonly papers: IPaper[];
453
+ readonly hasCover: boolean;
454
+ readonly coverPaperCount: number;
455
+ readonly alignToGround: boolean;
456
+ readonly castShadows: boolean;
457
+ readonly direction: number;
458
+ readonly coverPaperSetup: {
459
+ thickness: number;
460
+ margin: number;
461
+ };
462
+ readonly pagePaperSetup: {
463
+ margin: number;
464
+ };
465
+ }
466
+
467
+ /** Minimal interface for BookBound as used by Paper */
468
+ declare interface IBookBound {
469
+ resetPaperPosition(paper: Paper): void;
470
+ updatePaperPosition(paper: Paper): void;
471
+ }
472
+
473
+ /**
474
+ * Minimal interface the Paper class expects from the Book owner.
475
+ * Keeps the file self-contained without importing the full Book class.
476
+ */
477
+ declare interface IBookOwner {
478
+ bound: IBookBound;
479
+ castShadows: boolean;
480
+ reduceShadows: boolean;
481
+ direction: BookDirection;
482
+ }
483
+
484
+ /** How an image is scaled to fit a rectangular area. */
485
+ export declare type ImageFitMode = 'contain' | 'cover' | 'fill';
486
+
487
+ export declare interface IPageContent {
488
+ readonly texture: THREE.Texture | null;
489
+ readonly textureST: THREE.Vector4;
490
+ isPointOverUI(textureCoord: THREE.Vector2): boolean;
491
+ init(bookContent: BookContent): void;
492
+ setActive(active: boolean): void;
493
+ }
494
+
495
+ /** Mirrors C# IPageContent */
496
+ declare interface IPageContent_2 {
497
+ texture: THREE.Texture | null;
498
+ textureST: THREE.Vector4;
499
+ isPointOverUI(textureCoord: THREE.Vector2): boolean;
500
+ init(bookContent: unknown): void;
501
+ setActive(active: boolean): void;
502
+ }
503
+
504
+ /** Minimal Paper interface consumed by the binding. */
505
+ declare interface IPaper {
506
+ readonly index: number;
507
+ thickness: number;
508
+ size: THREE.Vector2;
509
+ sizeXOffset: number;
510
+ readonly margin: number;
511
+ readonly zTime: number;
512
+ readonly isFlipped: boolean;
513
+ readonly isTurning: boolean;
514
+ readonly isFalling: boolean;
515
+ readonly transform: THREE.Object3D;
516
+ readonly meshData: {
517
+ readonly pattern: {
518
+ baseXArray: number[];
519
+ baseZArray: number[];
520
+ xNoneSeamIndexes: number[];
521
+ };
522
+ baseVertices: THREE.Vector3[];
523
+ };
524
+ setMinTurningRadius(radius: number): void;
525
+ updateTurningRadius(): void;
526
+ updateTime(): void;
527
+ updateMesh(): void;
528
+ getDirection(z: number): THREE.Vector3;
529
+ }
530
+
531
+ /**
532
+ * Minimal wrapper mirroring the C# Renderer helper class used by Paper.
533
+ * In Three.js this maps to THREE.Mesh + THREE.Object3D.
534
+ */
535
+ declare interface IPaperRenderer {
536
+ readonly transform: THREE.Object3D;
537
+ mesh: THREE.BufferGeometry | null;
538
+ castShadows: boolean;
539
+ setMaterials(materials: THREE.Material[]): void;
540
+ setPropertyBlock(props: Record<string, unknown>, materialIndex: number): void;
541
+ readonly bounds: THREE.Box3;
542
+ }
543
+
544
+ /**
545
+ * Minimal replacement for Unity's AnimationCurve.
546
+ * Stores an array of { time, value } keyframes and evaluates them
547
+ * with linear interpolation (matches the most common Unity curve
548
+ * usage; tangent / bezier evaluation is omitted since the C# plugin
549
+ * only reads curve values via `Evaluate`).
550
+ */
551
+ declare interface Keyframe_2 {
552
+ time: number;
553
+ value: number;
554
+ }
555
+ export { Keyframe_2 as Keyframe }
556
+
557
+ /** Resolved image ready to be passed to createPageTexture. */
558
+ export declare interface LoadedImage {
559
+ image: HTMLImageElement;
560
+ /** Object URL created by URL.createObjectURL — revoke when no longer needed. */
561
+ objectUrl: string;
562
+ }
563
+
564
+ /**
565
+ * Loads a `File` into an `HTMLImageElement` and returns both the element
566
+ * and the object URL it was decoded from.
567
+ *
568
+ * The caller is responsible for calling `URL.revokeObjectURL(result.objectUrl)`
569
+ * when the image is no longer needed.
570
+ *
571
+ * Returns `null` if `file` is null/undefined or if decoding fails.
572
+ */
573
+ export declare function loadImage(file: File | null | undefined): Promise<LoadedImage | null>;
574
+
575
+ export declare class MeshFactory {
576
+ private m_UsedMeshs;
577
+ private m_FreeMeshs;
578
+ private m_Meshs;
579
+ get(): THREE.BufferGeometry;
580
+ recycle(): void;
581
+ destroy(): void;
582
+ }
583
+
584
+ export declare abstract class PageContent implements IPageContent {
585
+ private m_BookContent;
586
+ private m_IsActive;
587
+ get bookContent(): BookContent | null;
588
+ get isActive(): boolean;
589
+ abstract get texture(): THREE.Texture | null;
590
+ get textureST(): THREE.Vector4;
591
+ get isShareable(): boolean;
592
+ onActiveChangedCallback: (() => void) | null;
593
+ protected onInit(): void;
594
+ protected onActiveChanged(): void;
595
+ protected onIsPointOverUI(_textureCoord: THREE.Vector2): boolean;
596
+ isPointOverUI(textureCoord: THREE.Vector2): boolean;
597
+ init(bookContent: BookContent): void;
598
+ setActive(active: boolean): void;
599
+ }
600
+
601
+ export declare class Paper {
602
+ private m_Index;
603
+ private m_Transform;
604
+ private m_FrontContent;
605
+ private m_BackContent;
606
+ private m_UseBackContentForSides;
607
+ private m_Book;
608
+ private m_Prev;
609
+ private m_Next;
610
+ private m_NoHole;
611
+ private m_MaterialData;
612
+ private m_Renderer;
613
+ private m_Size;
614
+ private m_Thickness;
615
+ private m_Stiffness;
616
+ private m_Margin;
617
+ private m_IsCover;
618
+ private m_UVMargin;
619
+ private m_MeshData;
620
+ private m_LowpolyMeshData;
621
+ private m_LowpolyHoleMeshData;
622
+ private m_HighpolyMeshDataPool;
623
+ private m_MeshDataType;
624
+ private m_Cylinder;
625
+ private m_IsRolling;
626
+ private m_IsAutoTurning;
627
+ private m_WorldPlane;
628
+ private m_StartHandle;
629
+ private m_CurrentHandle;
630
+ private m_EndHandle;
631
+ private m_PrevHandle;
632
+ private m_HandleOffset;
633
+ private m_HandleVelocity;
634
+ private m_HandleVelocities;
635
+ private m_SubMeshCount;
636
+ private m_MinTurningRadius;
637
+ private m_TurningRadius;
638
+ private m_FallDuration;
639
+ private m_FallTime;
640
+ private m_XTime;
641
+ private m_ZTime;
642
+ private m_IsTurning;
643
+ private m_IsFalling;
644
+ private m_IsFallingLeft;
645
+ private m_isMeshChanged;
646
+ sizeXOffset: number;
647
+ get isMeshChanged(): boolean;
648
+ set isMeshChanged(value: boolean);
649
+ get isCover(): boolean;
650
+ get index(): number;
651
+ get transform(): THREE.Object3D;
652
+ get renderer(): IPaperRenderer;
653
+ get meshData(): PaperMeshData;
654
+ get size(): THREE.Vector2;
655
+ set size(value: THREE.Vector2);
656
+ get thickness(): number;
657
+ get margin(): number;
658
+ get zTime(): number;
659
+ get direction(): THREE.Vector3;
660
+ get isTurning(): boolean;
661
+ get isFalling(): boolean;
662
+ get isFlipped(): boolean;
663
+ get isOnRightStack(): boolean;
664
+ get frontContent(): IPageContent_2;
665
+ get backContent(): IPageContent_2;
666
+ get currentContent(): IPageContent_2;
667
+ private get needHole();
668
+ set prev(value: Paper | null);
669
+ set next(value: Paper | null);
670
+ set noHole(value: boolean);
671
+ private get isIdle();
672
+ get isInMiddelOfStack(): boolean;
673
+ constructor(isCover: boolean, index: number, book: IBookOwner, renderer: IPaperRenderer);
674
+ setTime(time: number): void;
675
+ setMeshData(lowpolyMeshData: PaperMeshData, lowpolyHoleMeshData: PaperMeshData | null, highpolyMeshDataPool: PaperMeshDataPool): void;
676
+ restState(rightStack: boolean): void;
677
+ restMesh(): void;
678
+ setMaterialData(data: PaperMaterialData): void;
679
+ setPaperSetup(settings: PaperSetup): void;
680
+ setContentData(frontContent: IPageContent_2, backContent: IPageContent_2, useBackContentForSides?: boolean): void;
681
+ setMinTurningRadius(min: number): void;
682
+ updateTurningRadius(bend?: number): void;
683
+ startTurning(ray: THREE.Ray): boolean;
684
+ stopTurning(): void;
685
+ /**
686
+ * Called each frame while the user is dragging.
687
+ * `dt` replaces Time.deltaTime.
688
+ */
689
+ updateTurning(ray: THREE.Ray, dt?: number): void;
690
+ /**
691
+ * Called each frame while the page is falling back into place.
692
+ * `dt` replaces Time.deltaTime.
693
+ */
694
+ updateFalling(dt?: number): void;
695
+ getTextureCoordinate(ray: THREE.Ray): THREE.Vector2;
696
+ raycast(ray: THREE.Ray): {
697
+ hit: boolean;
698
+ hitInfo: BookRaycastHit_2;
699
+ };
700
+ private hit2UV;
701
+ /**
702
+ * Internal raycast against the paper plane in local space.
703
+ * Returns the local-space hit point, or null if no hit / out of bounds.
704
+ */
705
+ raycastLocal(ray: THREE.Ray, noBoundsCheck?: boolean): THREE.Vector3 | null;
706
+ private trySwitchMeshData;
707
+ private switchMeshData;
708
+ updateMaterials(): void;
709
+ updateBaseVertices(): void;
710
+ updateMesh(): void;
711
+ getDirection(z: number): THREE.Vector3;
712
+ updateTime(): void;
713
+ private findTime;
714
+ private clampHandle;
715
+ private updateCylinder;
716
+ private rollPoint;
717
+ drawWireframe(_color: unknown): void;
718
+ startAutoTurning(mode: AutoTurnMode_2, twist: number, bend: number, duration: number): void;
719
+ get cylinder(): Cylinder;
720
+ }
721
+
722
+ /**
723
+ * Rectangle defined by two corner indices (startX/Z, endX/Z) plus flip/left flags.
724
+ * C# struct — emulated with clone().
725
+ */
726
+ export declare class PaperBorder {
727
+ startX: number;
728
+ startZ: number;
729
+ endX: number;
730
+ endZ: number;
731
+ flip: boolean;
732
+ left: boolean;
733
+ constructor(startX: number, startZ: number, endX: number, endZ: number, flip: boolean, left?: boolean);
734
+ clone(): PaperBorder;
735
+ }
736
+
737
+ export declare class PaperMaterialData {
738
+ private m_Materials1;
739
+ private m_Materials3;
740
+ private m_Color;
741
+ private m_Texture;
742
+ private m_TextureST;
743
+ get materials1(): THREE.Material[];
744
+ get materials3(): THREE.Material[];
745
+ get color(): THREE.Color;
746
+ get texture(): THREE.Texture | null;
747
+ get textureST(): THREE.Vector4;
748
+ constructor(paperSetup: PaperSetup);
749
+ /**
750
+ * Mirrors Unity's MaterialPropertyBlock: stores color, texture, and textureST.
751
+ * Paper.ts reads this after calling updatePropertyBlock.
752
+ */
753
+ get propertyBlock(): Record<string, unknown>;
754
+ updatePropertyBlock(texture: THREE.Texture | null, textureST: THREE.Vector4): void;
755
+ }
756
+
757
+ export declare class PaperMeshData {
758
+ private m_Geometry;
759
+ private m_Pattern;
760
+ private m_BaseVertices;
761
+ private m_Vertices;
762
+ private m_Normals;
763
+ get geometry(): THREE.BufferGeometry;
764
+ get pattern(): PaperPattern;
765
+ get baseVertices(): THREE.Vector3[];
766
+ constructor(geometry: THREE.BufferGeometry, pattern: PaperPattern);
767
+ /**
768
+ * Recalculates base vertex positions from the pattern's X/Z arrays
769
+ * and offset.
770
+ *
771
+ * Ported from lines ~2167-2183.
772
+ */
773
+ updateBaseVertices(): void;
774
+ /**
775
+ * Recomputes all vertex positions and normals.
776
+ *
777
+ * Algorithm:
778
+ * 1. Clear normals for all base vertices.
779
+ * 2. Interpolate seam positions in X and Z.
780
+ * 3. Accumulate face normals per quad onto each vertex.
781
+ * 4. Normalise by dividing by weight and re-normalising.
782
+ * 5. Interpolate seam normals (with slerp).
783
+ * 6. Offset front/back by +/- halfThickness along normal.
784
+ * 7. Update border vertex positions and normals.
785
+ * 8. Push data into BufferGeometry attributes.
786
+ *
787
+ * Ported from lines ~2185-2255.
788
+ */
789
+ updateMesh(): void;
790
+ /**
791
+ * Returns wireframe quad data for debug visualisation.
792
+ *
793
+ * Ported from lines ~2257-2262.
794
+ */
795
+ drawWireframe(matrix: THREE.Matrix4): Array<[THREE.Vector3, THREE.Vector3, THREE.Vector3, THREE.Vector3]>;
796
+ }
797
+
798
+ export declare class PaperMeshDataPool {
799
+ private m_Stack;
800
+ private m_MeshFactory;
801
+ private m_Pattern;
802
+ private m_SharedData;
803
+ private m_UseSharedData;
804
+ constructor(meshFactory: MeshFactory, pattern: PaperPattern, useSharedData?: boolean);
805
+ get(): PaperMeshData;
806
+ free(mesh: PaperMeshData): void;
807
+ }
808
+
809
+ /**
810
+ * Ported from Book.cs — PaperNode class (lines ~2292-2430).
811
+ *
812
+ * Doubly-linked-list node used during paper mesh tessellation.
813
+ * Each node stores a 1-D position `value` along an axis, plus flags
814
+ * that mark whether it sits on a hole or a seam.
815
+ */
816
+ export declare class PaperNode {
817
+ prev: PaperNode | null;
818
+ next: PaperNode | null;
819
+ value: number;
820
+ index: number;
821
+ hole: boolean;
822
+ seam: boolean;
823
+ constructor(value: number, hole?: boolean, seam?: boolean);
824
+ get prevNoneSeam(): PaperNode;
825
+ get nextNoneSeam(): PaperNode;
826
+ get prevNoneHole(): PaperNode;
827
+ get nextNoneHole(): PaperNode;
828
+ createNext(value: number, hole?: boolean, seam?: boolean): PaperNode;
829
+ createNextFromDouble(value: number, hole?: boolean, seam?: boolean): PaperNode;
830
+ insert(node: PaperNode): boolean;
831
+ updateIndex(index: number): void;
832
+ getValues(): number[];
833
+ getValues(values: number[]): void;
834
+ private _getValuesRecursive;
835
+ getHoles(): boolean[];
836
+ getHoles(holes: boolean[]): void;
837
+ private _getHolesRecursive;
838
+ }
839
+
840
+ /**
841
+ * Creates four seam nodes (left, right, down, up) from a UV margin and
842
+ * inserts them into the existing X / Z linked-lists.
843
+ */
844
+ export declare class PaperNodeMargin {
845
+ leftNode: PaperNode;
846
+ rightNode: PaperNode;
847
+ downNode: PaperNode;
848
+ upNode: PaperNode;
849
+ constructor(pattern: PaperPattern, margin: PaperUVMargin, hole: boolean);
850
+ insert(xRootNode: PaperNode, zRootNode: PaperNode, xSeamNodes: PaperNode[], zSeamNodes: PaperNode[]): void;
851
+ }
852
+
853
+ /**
854
+ * Ported from Book.cs — PaperPattern class (lines ~2265-2290).
855
+ *
856
+ * Holds the tessellation layout of a single paper sheet: vertex arrays,
857
+ * seam information, triangle indices, UV coordinates and border definitions.
858
+ */
859
+ export declare class PaperPattern {
860
+ baseXArray: number[];
861
+ baseZArray: number[];
862
+ baseXOffset: number;
863
+ baseVertexCount: number;
864
+ xSeams: PaperSeam[];
865
+ zSeams: PaperSeam[];
866
+ xNoneSeamIndexes: number[];
867
+ borders: PaperBorder[];
868
+ texcoords: THREE.Vector2[];
869
+ weights: number[];
870
+ triangles: number[];
871
+ frontTriangles: number[];
872
+ backTriangles: number[];
873
+ borderTriangles: number[];
874
+ vertexCount: number;
875
+ subMeshCount: number;
876
+ size: THREE.Vector2;
877
+ thickness: number;
878
+ }
879
+
880
+ /**
881
+ * Describes a seam (extra split) in the paper mesh along one axis.
882
+ * C# struct — emulated with clone().
883
+ */
884
+ export declare class PaperSeam {
885
+ active: boolean;
886
+ prevIndex: number;
887
+ index: number;
888
+ nextIndex: number;
889
+ time: number;
890
+ constructor(prevIndex: number, index: number, nextIndex: number, time: number);
891
+ clone(): PaperSeam;
892
+ }
893
+
894
+ /**
895
+ * Ported from Book.cs — PaperSetup class (lines ~1617-1712).
896
+ *
897
+ * Holds the serialised configuration for a single paper sheet: material,
898
+ * colour, dimensions, stiffness, quality and UV margin.
899
+ */
900
+ export declare class PaperSetup {
901
+ private static readonly kMinSize;
902
+ private static readonly kMinThickness;
903
+ private static readonly kMinQuality;
904
+ private static readonly kMaxQuality;
905
+ private m_Material;
906
+ private m_Color;
907
+ private m_Width;
908
+ private m_Height;
909
+ private m_Thickness;
910
+ private m_Stiffness;
911
+ private m_Quality;
912
+ private m_UVMargin;
913
+ margin: number;
914
+ bookDirection: BookDirection;
915
+ constructor(opts?: {
916
+ color?: THREE.Color;
917
+ width?: number;
918
+ height?: number;
919
+ thickness?: number;
920
+ stiffness?: number;
921
+ quality?: number;
922
+ material?: THREE.Material | null;
923
+ });
924
+ get material(): THREE.Material | null;
925
+ set material(value: THREE.Material | null);
926
+ get color(): THREE.Color;
927
+ set color(value: THREE.Color);
928
+ get width(): number;
929
+ set width(value: number);
930
+ get height(): number;
931
+ set height(value: number);
932
+ get thickness(): number;
933
+ set thickness(value: number);
934
+ get stiffness(): number;
935
+ set stiffness(value: number);
936
+ get quality(): number;
937
+ set quality(value: number);
938
+ get uvMargin(): PaperUVMargin;
939
+ set uvMargin(value: PaperUVMargin);
940
+ get size(): THREE.Vector2;
941
+ }
942
+
943
+ export declare interface PaperSetupInit {
944
+ color: THREE.Color;
945
+ width: number;
946
+ height: number;
947
+ thickness: number;
948
+ stiffness: number;
949
+ material: THREE.Material | null;
950
+ }
951
+
952
+ /**
953
+ * Ported from Book.cs — PaperUVMargin struct (lines ~1714-1796).
954
+ *
955
+ * Defines the blank space around content on each of the four sides.
956
+ * C# struct — emulated with clone().
957
+ */
958
+ export declare class PaperUVMargin {
959
+ /* Excluded from this release type: kMin */
960
+ /* Excluded from this release type: kMax */
961
+ private m_Left;
962
+ private m_Right;
963
+ private m_Down;
964
+ private m_Up;
965
+ get left(): number;
966
+ set left(value: number);
967
+ get right(): number;
968
+ set right(value: number);
969
+ get down(): number;
970
+ set down(value: number);
971
+ get up(): number;
972
+ set up(value: number);
973
+ private clamp;
974
+ /**
975
+ * Returns a new PaperUVMargin with margins remapped according to the
976
+ * book direction.
977
+ */
978
+ transform(direction: BookDirection): PaperUVMargin;
979
+ /**
980
+ * Remap a UV coordinate so that (0,0) and (1,1) correspond to the
981
+ * content area inside the margins.
982
+ *
983
+ * Unity's `Mathf.InverseLerp(a, b, v)` = `(v - a) / (b - a)` clamped to [0,1].
984
+ */
985
+ fixUV(uv: THREE.Vector2): THREE.Vector2;
986
+ private static inverseLerp;
987
+ clone(): PaperUVMargin;
988
+ }
989
+
990
+ export declare class RendererFactory {
991
+ private m_Root;
992
+ private m_CreateMeshCollider;
993
+ private m_UsedRenderers;
994
+ private m_FreeRenderers;
995
+ private m_Renderers;
996
+ private m_Ids;
997
+ set createColliders(value: boolean);
998
+ get ids(): number[];
999
+ constructor(root: THREE.Object3D);
1000
+ get(name: string): BookRenderer;
1001
+ recycle(): void;
1002
+ destroy(): void;
1003
+ getBounds(): THREE.Box3;
1004
+ }
1005
+
1006
+ export declare class SpritePageContent2 implements IPageContent {
1007
+ private m_Texture;
1008
+ private m_TextureST;
1009
+ constructor(texture: THREE.Texture | null, textureST?: THREE.Vector4);
1010
+ get texture(): THREE.Texture | null;
1011
+ get textureST(): THREE.Vector4;
1012
+ isPointOverUI(_textureCoord: THREE.Vector2): boolean;
1013
+ init(_bookContent: BookContent): void;
1014
+ setActive(_active: boolean): void;
1015
+ }
1016
+
1017
+ export declare class StapleBookBinding extends BookBinding {
1018
+ quality: number;
1019
+ stapleSetup: StapleSetup;
1020
+ createBound(book: ThreeBook, root: THREE.Object3D, _rendererFactory: RendererFactory, _meshFactory: MeshFactory): BookBound;
1021
+ }
1022
+
1023
+ export declare class StapleBookBound {
1024
+ private m_Book;
1025
+ private m_Root;
1026
+ /** The Three.js Mesh for the staple geometry. */
1027
+ stapleMesh: THREE.Mesh;
1028
+ private m_StapleMargin;
1029
+ private m_StapleThickness;
1030
+ private m_BindingRadius;
1031
+ private m_BindingMidSpace;
1032
+ private m_StackHeight;
1033
+ private m_BindingVertexCount;
1034
+ private m_Quality;
1035
+ /** C#: `useSharedMeshDataForLowpoly => false` */
1036
+ readonly useSharedMeshDataForLowpoly: boolean;
1037
+ /** Adapter that wraps the THREE.Mesh in a BookRenderer-compatible shape. */
1038
+ private _binderRendererAdapter;
1039
+ get binderRenderer(): StapleRendererAdapter;
1040
+ constructor(quality: number, stapleSetup: StapleSetup, book: IBook, root: THREE.Object3D, stapleMaterial?: THREE.Material);
1041
+ private updateStapleMesh;
1042
+ createPaperPattern(quality: number, size: THREE.Vector2, thickness: number, uvMargin: PaperUVMargin, reduceOverdraw: boolean, reduceSubMeshes: boolean): PaperPattern;
1043
+ private updateRootPosition;
1044
+ resetPaperPosition(paper: IPaper): void;
1045
+ private getPX;
1046
+ updatePaperPosition(paper: IPaper): void;
1047
+ private getStackHeight;
1048
+ private getStackZ;
1049
+ onLateUpdate(): void;
1050
+ private updateBindingVertices;
1051
+ get bindingRadius(): number;
1052
+ get bindingMidSpace(): number;
1053
+ get stackHeight(): number;
1054
+ get bindingVertexCount(): number;
1055
+ get quality(): number;
1056
+ get stapleMargin(): number;
1057
+ get stapleThickness(): number;
1058
+ }
1059
+
1060
+ declare class StapleRendererAdapter {
1061
+ private mesh;
1062
+ constructor(mesh: THREE.Mesh);
1063
+ setVisibility(visible: boolean): void;
1064
+ updateCollider(): void;
1065
+ get castShadows(): boolean;
1066
+ set castShadows(value: boolean);
1067
+ get bounds(): THREE.Box3;
1068
+ get transform(): THREE.Object3D;
1069
+ get meshObject(): THREE.Mesh;
1070
+ }
1071
+
1072
+ export declare class StapleSetup {
1073
+ private _material;
1074
+ private _color;
1075
+ private _thickness;
1076
+ private _crown;
1077
+ private _margin;
1078
+ private _count;
1079
+ private _quality;
1080
+ get material(): THREE.Material | null;
1081
+ set material(value: THREE.Material | null);
1082
+ get color(): THREE.Color;
1083
+ set color(value: THREE.Color);
1084
+ get thickness(): number;
1085
+ set thickness(value: number);
1086
+ get margin(): number;
1087
+ set margin(value: number);
1088
+ get crown(): number;
1089
+ set crown(value: number);
1090
+ get count(): number;
1091
+ set count(value: number);
1092
+ get quality(): number;
1093
+ set quality(value: number);
1094
+ }
1095
+
1096
+ export declare class ThreeBook extends THREE.Group {
1097
+ private static s_Instances;
1098
+ static get instances(): ThreeBook[];
1099
+ private m_Content;
1100
+ private m_Binding;
1101
+ private m_InitialOpenProgress;
1102
+ private m_BuildOnAwake;
1103
+ private m_CastShadows;
1104
+ private m_AlignToGround;
1105
+ private m_HideBinder;
1106
+ private m_CreateColliders;
1107
+ private m_ReduceShadows;
1108
+ private m_ReduceSubMeshes;
1109
+ private m_ReduceOverdraw;
1110
+ private m_CoverPaperSetup;
1111
+ private m_PagePaperSetup;
1112
+ private m_Root;
1113
+ private m_IsBuilt;
1114
+ private m_HasCover;
1115
+ private m_RendererFactory;
1116
+ private m_MeshFactory;
1117
+ private m_Bound;
1118
+ private m_Papers;
1119
+ private m_SelectedPaper;
1120
+ private m_Direction;
1121
+ private m_AutoTurnQueue;
1122
+ private m_AutoTurnTimer;
1123
+ private m_AutoTurningEndTime;
1124
+ private m_CurrentTime;
1125
+ private m_CoverPaperCount;
1126
+ private m_PagePaperCount;
1127
+ private m_TotalThickness;
1128
+ private m_MinPaperWidth;
1129
+ private m_MinPaperHeight;
1130
+ private m_MinPaperThickness;
1131
+ private m_MaxPaperThickness;
1132
+ private m_RendererIds;
1133
+ private m_WasIdle;
1134
+ get minPaperWidth(): number;
1135
+ get minPaperHeight(): number;
1136
+ get minPaperThickness(): number;
1137
+ get maxPaperThickness(): number;
1138
+ get totalThickness(): number;
1139
+ get hasCover(): boolean;
1140
+ get castShadowsFlag(): boolean;
1141
+ /** Alias matching IBookOwner interface expected by Paper.ts */
1142
+ get castShadows(): boolean;
1143
+ get alignToGround(): boolean;
1144
+ get reduceShadows(): boolean;
1145
+ get coverPaperSetup(): PaperSetup;
1146
+ get pagePaperSetup(): PaperSetup;
1147
+ get bound(): BookBound | null;
1148
+ get papers(): Paper[];
1149
+ get rendererIds(): number[];
1150
+ get direction(): BookDirection;
1151
+ get binding(): BookBinding | null;
1152
+ set binding(value: BookBinding | null);
1153
+ get content(): BookContent | null;
1154
+ set content(value: BookContent | null);
1155
+ get initialOpenProgress(): number;
1156
+ set initialOpenProgress(value: number);
1157
+ get isBuilt(): boolean;
1158
+ get paperCount(): number;
1159
+ get coverPaperCount(): number;
1160
+ get pagePaperCount(): number;
1161
+ get isTurning(): boolean;
1162
+ get isFalling(): boolean;
1163
+ get isIdle(): boolean;
1164
+ get isAutoTurning(): boolean;
1165
+ get hasPendingAutoTurns(): boolean;
1166
+ get autoTurningEndTime(): number;
1167
+ constructor(options?: BookOptions);
1168
+ startTurning(ray: THREE.Ray): boolean;
1169
+ updateTurning(ray: THREE.Ray): void;
1170
+ stopTurning(): void;
1171
+ getActivePaperSideIndices(indices: number[]): void;
1172
+ setOpenProgress(openProgress: number): void;
1173
+ setOpenProgressByIndex(paperSideIndex: number): void;
1174
+ startAutoTurning(direction: AutoTurnDirection, settings: AutoTurnSettings, turnCount?: number, delayPerTurn?: number | AutoTurnSetting): boolean;
1175
+ cancelPendingAutoTurns(): void;
1176
+ private processAutoTurnQueue;
1177
+ private getAutoTurnPaper;
1178
+ private getMaxAutoTurnCount;
1179
+ private canAutoTurn;
1180
+ private getAutoTurnPaperIndexTime;
1181
+ /**
1182
+ * Initialize the book. Call this after adding to scene.
1183
+ * Equivalent to Unity's Start/Awake.
1184
+ */
1185
+ init(): void;
1186
+ /**
1187
+ * Call every frame with delta time.
1188
+ * Equivalent to Unity's LateUpdate.
1189
+ */
1190
+ update(dt: number): void;
1191
+ dispose(): void;
1192
+ build(): void;
1193
+ clear(): this;
1194
+ private hardClear;
1195
+ private createPaperMeshDataPool;
1196
+ private getFrontPapers;
1197
+ getAverageTime(): number;
1198
+ bookRaycast(ray: THREE.Ray): BookRaycastHit | null;
1199
+ private updateLivePages;
1200
+ }
1201
+
1202
+ /**
1203
+ * Auto-turn controls. Reads from the nearest `<Book>` context, or from an explicit ref.
1204
+ */
1205
+ export declare function useAutoTurn(bookRef?: React.RefObject<ThreeBook | null>): AutoTurnControls;
1206
+
1207
+ /** Returns the nearest ancestor Book instance, or null if none. */
1208
+ export declare function useBook(): ThreeBook | null;
1209
+
1210
+ /**
1211
+ * @param factory Pure function that creates a BookContent. Treated as
1212
+ * unstable — only called when `deps` change.
1213
+ * @param deps Dependency array, like useMemo.
1214
+ */
1215
+ export declare function useBookContent(factory: () => BookContent, deps: React.DependencyList): BookContent;
1216
+
1217
+ /**
1218
+ * Stable imperative controls for open-progress and drag-turn management.
1219
+ * Reads from the nearest `<Book>` context, or from an explicit ref.
1220
+ */
1221
+ export declare function useBookControls(bookRef?: React.RefObject<ThreeBook | null>): BookControls;
1222
+
1223
+ /**
1224
+ * Creates and manages the lifecycle of a ThreeBook instance.
1225
+ *
1226
+ * @param options Passed directly to `new Book(options)`. Changes after
1227
+ * mount are **ignored** — trigger a rebuild via `key` instead.
1228
+ * @param onBuilt Called after `book.init()` succeeds.
1229
+ * @param onError Called if `book.init()` throws.
1230
+ */
1231
+ export declare function useBookRef(options: BookOptions, onBuilt?: (book: ThreeBook) => void, onError?: (err: Error) => void): UseBookRefResult;
1232
+
1233
+ export declare interface UseBookRefResult {
1234
+ /** Ref to the ThreeBook instance (null until init succeeds). */
1235
+ bookRef: React.MutableRefObject<ThreeBook | null>;
1236
+ /** True once init() has returned without error. */
1237
+ ready: boolean;
1238
+ }
1239
+
1240
+ /**
1241
+ * Returns a reactive snapshot of the ThreeBook's runtime state.
1242
+ *
1243
+ * @param bookRef Optional explicit ref. If omitted, the nearest
1244
+ * `<Book>` context is used.
1245
+ */
1246
+ export declare function useBookState(bookRef?: React.RefObject<ThreeBook | null>): BookState;
1247
+
1248
+ /**
1249
+ * Attaches pointer-drag events on the R3F canvas for interactive page turning.
1250
+ * Prefer the declarative `<BookInteraction>` component unless you need raw access.
1251
+ */
1252
+ export declare function usePageTurning(bookRef: React.RefObject<ThreeBook | null>, { enabled, orbitControlsRef }?: UsePageTurningOptions): void;
1253
+
1254
+ export declare interface UsePageTurningOptions {
1255
+ /** Disable pointer events without unmounting. Default: true. */
1256
+ enabled?: boolean;
1257
+ /** OrbitControls ref — disabled during drag, re-enabled on release. */
1258
+ orbitControlsRef?: React.RefObject<{
1259
+ enabled: boolean;
1260
+ } | null>;
1261
+ }
1262
+
1263
+ /** Returns the nearest ancestor Book instance. Throws outside a <Book> tree. */
1264
+ export declare function useRequiredBook(): ThreeBook;
1265
+
1266
+ export { }