@react-three/fiber 10.0.0-alpha.2 → 10.0.0-canary.b0fafc8
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/LICENSE +21 -21
- package/dist/index.cjs +1122 -558
- package/dist/index.d.cts +2001 -1285
- package/dist/index.d.mts +2001 -1285
- package/dist/index.d.ts +2001 -1285
- package/dist/index.mjs +1107 -562
- package/dist/legacy.cjs +1093 -547
- package/dist/legacy.d.cts +2002 -1286
- package/dist/legacy.d.mts +2002 -1286
- package/dist/legacy.d.ts +2002 -1286
- package/dist/legacy.mjs +1078 -551
- package/dist/webgpu/index.cjs +1176 -548
- package/dist/webgpu/index.d.cts +2097 -1300
- package/dist/webgpu/index.d.mts +2097 -1300
- package/dist/webgpu/index.d.ts +2097 -1300
- package/dist/webgpu/index.mjs +1161 -552
- package/package.json +3 -1
- package/readme.md +244 -318
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as three_webgpu from 'three/webgpu';
|
|
2
|
-
import { RenderTarget, Node, ShaderNodeObject, Euler as Euler$
|
|
2
|
+
import { RenderTarget, WebGPURenderer, CanvasTarget, Node, ShaderNodeObject, Euler as Euler$2, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, Loader as Loader$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D, Frustum, OrthographicCamera } from 'three/webgpu';
|
|
3
3
|
import * as THREE$1 from 'three';
|
|
4
|
-
import { WebGLRenderTarget, WebGLRenderer, Color as Color$1, ColorRepresentation, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
|
|
4
|
+
import { WebGLRenderTarget, WebGLRenderer, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
|
|
5
5
|
import { WebGLRendererParameters } from 'three/src/renderers/WebGLRenderer.js';
|
|
6
6
|
import { Inspector } from 'three/addons/inspector/Inspector.js';
|
|
7
7
|
import * as React$1 from 'react';
|
|
@@ -10,6 +10,8 @@ import { StoreApi } from 'zustand';
|
|
|
10
10
|
import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
|
|
11
11
|
import { Options } from 'react-use-measure';
|
|
12
12
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
13
|
+
import { ThreeElement as ThreeElement$1, Euler as Euler$3 } from '@react-three/fiber';
|
|
14
|
+
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
13
15
|
|
|
14
16
|
function _mergeNamespaces(n, m) {
|
|
15
17
|
m.forEach(function (e) {
|
|
@@ -55,1282 +57,1614 @@ var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
|
55
57
|
WebGLRendererParameters: WebGLRendererParameters
|
|
56
58
|
}, [three_webgpu]);
|
|
57
59
|
|
|
58
|
-
//* Utility Types ==============================
|
|
59
|
-
|
|
60
|
-
type NonFunctionKeys<P> = { [K in keyof P]-?: P[K] extends Function ? never : K }[keyof P]
|
|
61
|
-
type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O
|
|
62
|
-
type Properties<T> = Pick<T, NonFunctionKeys<T>>
|
|
63
|
-
type Mutable<P> = { [K in keyof P]: P[K]
|
|
64
|
-
type IsOptional<T> = undefined extends T ? true : false
|
|
65
|
-
type IsAllOptional<T extends any[]> = T extends [infer First, ...infer Rest]
|
|
66
|
-
? IsOptional<First> extends true
|
|
67
|
-
? IsAllOptional<Rest>
|
|
68
|
-
: false
|
|
69
|
-
: true
|
|
70
|
-
|
|
71
|
-
//* Camera Types ==============================
|
|
72
|
-
|
|
73
|
-
type ThreeCamera = (THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera) & { manual?: boolean }
|
|
74
|
-
|
|
75
|
-
//* Act Type ==============================
|
|
76
|
-
|
|
77
|
-
type Act = <T = any>(cb: () => Promise<T>) => Promise<T>
|
|
78
|
-
|
|
79
|
-
//* Bridge & Block Types ==============================
|
|
80
|
-
|
|
81
|
-
type Bridge = React$1.FC<{ children?: React$1.ReactNode }>
|
|
82
|
-
|
|
83
|
-
type SetBlock = false | Promise<null> | null
|
|
84
|
-
type UnblockProps = { set: React$1.Dispatch<React$1.SetStateAction<SetBlock>>; children: React$1.ReactNode }
|
|
85
|
-
|
|
86
|
-
//* Object Map Type ==============================
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
|
|
314
|
-
*/
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
*/
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
gl
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
/**
|
|
569
|
-
|
|
570
|
-
/**
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
/**
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
/**
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
/**
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
/**
|
|
612
|
-
|
|
613
|
-
/**
|
|
614
|
-
|
|
615
|
-
/**
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
/**
|
|
632
|
-
|
|
633
|
-
/**
|
|
634
|
-
|
|
635
|
-
/**
|
|
636
|
-
|
|
637
|
-
/**
|
|
638
|
-
|
|
639
|
-
/**
|
|
640
|
-
|
|
641
|
-
/**
|
|
642
|
-
|
|
643
|
-
/**
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
|
|
647
|
-
/**
|
|
648
|
-
|
|
649
|
-
/**
|
|
650
|
-
|
|
651
|
-
/**
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
60
|
+
//* Utility Types ==============================
|
|
61
|
+
|
|
62
|
+
type NonFunctionKeys<P> = { [K in keyof P]-?: P[K] extends Function ? never : K }[keyof P]
|
|
63
|
+
type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O
|
|
64
|
+
type Properties<T> = Pick<T, NonFunctionKeys<T>>
|
|
65
|
+
type Mutable<P> = { -readonly [K in keyof P]: P[K] }
|
|
66
|
+
type IsOptional<T> = undefined extends T ? true : false
|
|
67
|
+
type IsAllOptional<T extends any[]> = T extends [infer First, ...infer Rest]
|
|
68
|
+
? IsOptional<First> extends true
|
|
69
|
+
? IsAllOptional<Rest>
|
|
70
|
+
: false
|
|
71
|
+
: true
|
|
72
|
+
|
|
73
|
+
//* Camera Types ==============================
|
|
74
|
+
|
|
75
|
+
type ThreeCamera = (THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera) & { manual?: boolean }
|
|
76
|
+
|
|
77
|
+
//* Act Type ==============================
|
|
78
|
+
|
|
79
|
+
type Act = <T = any>(cb: () => Promise<T>) => Promise<T>
|
|
80
|
+
|
|
81
|
+
//* Bridge & Block Types ==============================
|
|
82
|
+
|
|
83
|
+
type Bridge = React$1.FC<{ children?: React$1.ReactNode }>
|
|
84
|
+
|
|
85
|
+
type SetBlock = false | Promise<null> | null
|
|
86
|
+
type UnblockProps = { set: React$1.Dispatch<React$1.SetStateAction<SetBlock>>; children: React$1.ReactNode }
|
|
87
|
+
|
|
88
|
+
//* Object Map Type ==============================
|
|
89
|
+
|
|
90
|
+
/* Original version
|
|
91
|
+
export interface ObjectMap {
|
|
92
|
+
nodes: { [name: string]: THREE.Object3D }
|
|
93
|
+
materials: { [name: string]: THREE.Material }
|
|
94
|
+
meshes: { [name: string]: THREE.Mesh }
|
|
95
|
+
}
|
|
96
|
+
*/
|
|
97
|
+
/* This version is an expansion found in a PR by itsdouges that seems abandoned but looks useful.
|
|
98
|
+
It allows expansion but falls back to the original shape. (deleted due to stale, but If it doesnt conflict
|
|
99
|
+
I will keep the use here)
|
|
100
|
+
https://github.com/pmndrs/react-three-fiber/commits/generic-object-map/
|
|
101
|
+
His description is:
|
|
102
|
+
The object map type is now generic and can optionally declare the available properties for nodes, materials, and meshes.
|
|
103
|
+
*/
|
|
104
|
+
interface ObjectMap<
|
|
105
|
+
T extends { nodes?: string; materials?: string; meshes?: string } = {
|
|
106
|
+
nodes: string
|
|
107
|
+
materials: string
|
|
108
|
+
meshes: string
|
|
109
|
+
},
|
|
110
|
+
> {
|
|
111
|
+
nodes: Record<T['nodes'] extends string ? T['nodes'] : string, THREE$1.Object3D>
|
|
112
|
+
materials: Record<T['materials'] extends string ? T['materials'] : string, THREE$1.Material>
|
|
113
|
+
meshes: Record<T['meshes'] extends string ? T['meshes'] : string, THREE$1.Mesh>
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//* Equality Config ==============================
|
|
117
|
+
|
|
118
|
+
interface EquConfig {
|
|
119
|
+
/** Compare arrays by reference equality a === b (default), or by shallow equality */
|
|
120
|
+
arrays?: 'reference' | 'shallow'
|
|
121
|
+
/** Compare objects by reference equality a === b (default), or by shallow equality */
|
|
122
|
+
objects?: 'reference' | 'shallow'
|
|
123
|
+
/** If true the keys in both a and b must match 1:1 (default), if false a's keys must intersect b's */
|
|
124
|
+
strict?: boolean
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
//* Disposable Type ==============================
|
|
128
|
+
|
|
129
|
+
interface Disposable {
|
|
130
|
+
type?: string
|
|
131
|
+
dispose?: () => void
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
//* Event-related Types =====================================
|
|
135
|
+
|
|
136
|
+
interface Intersection extends THREE$1.Intersection {
|
|
137
|
+
/** The event source (the object which registered the handler) */
|
|
138
|
+
eventObject: THREE$1.Object3D
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
type Camera = THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera
|
|
142
|
+
|
|
143
|
+
interface IntersectionEvent<TSourceEvent> extends Intersection {
|
|
144
|
+
/** The event source (the object which registered the handler) */
|
|
145
|
+
eventObject: THREE$1.Object3D
|
|
146
|
+
/** An array of intersections */
|
|
147
|
+
intersections: Intersection[]
|
|
148
|
+
/** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
|
|
149
|
+
unprojectedPoint: THREE$1.Vector3
|
|
150
|
+
/** Normalized event coordinates */
|
|
151
|
+
pointer: THREE$1.Vector2
|
|
152
|
+
/** Delta between first click and this event */
|
|
153
|
+
delta: number
|
|
154
|
+
/** The ray that pierced it */
|
|
155
|
+
ray: THREE$1.Ray
|
|
156
|
+
/** The camera that was used by the raycaster */
|
|
157
|
+
camera: Camera
|
|
158
|
+
/** stopPropagation will stop underlying handlers from firing */
|
|
159
|
+
stopPropagation: () => void
|
|
160
|
+
/** The original host event */
|
|
161
|
+
nativeEvent: TSourceEvent
|
|
162
|
+
/** If the event was stopped by calling stopPropagation */
|
|
163
|
+
stopped: boolean
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>
|
|
167
|
+
type DomEvent = PointerEvent | MouseEvent | WheelEvent
|
|
168
|
+
|
|
169
|
+
/** DOM event handlers registered on the canvas element */
|
|
170
|
+
interface Events {
|
|
171
|
+
onClick: EventListener
|
|
172
|
+
onContextMenu: EventListener
|
|
173
|
+
onDoubleClick: EventListener
|
|
174
|
+
onWheel: EventListener
|
|
175
|
+
onPointerDown: EventListener
|
|
176
|
+
onPointerUp: EventListener
|
|
177
|
+
onPointerLeave: EventListener
|
|
178
|
+
onPointerMove: EventListener
|
|
179
|
+
onPointerCancel: EventListener
|
|
180
|
+
onLostPointerCapture: EventListener
|
|
181
|
+
onDragEnter: EventListener
|
|
182
|
+
onDragLeave: EventListener
|
|
183
|
+
onDragOver: EventListener
|
|
184
|
+
onDrop: EventListener
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Event handlers that can be attached to R3F objects (meshes, groups, etc.) */
|
|
188
|
+
interface EventHandlers {
|
|
189
|
+
onClick?: (event: ThreeEvent<MouseEvent>) => void
|
|
190
|
+
onContextMenu?: (event: ThreeEvent<MouseEvent>) => void
|
|
191
|
+
onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void
|
|
192
|
+
/** Fires continuously while dragging over the object */
|
|
193
|
+
onDragOver?: (event: ThreeEvent<DragEvent>) => void
|
|
194
|
+
/** Fires once when drag enters the object */
|
|
195
|
+
onDragOverEnter?: (event: ThreeEvent<DragEvent>) => void
|
|
196
|
+
/** Fires once when drag leaves the object */
|
|
197
|
+
onDragOverLeave?: (event: ThreeEvent<DragEvent>) => void
|
|
198
|
+
/** Fires when drag misses this object (for objects that have drag handlers) */
|
|
199
|
+
onDragOverMissed?: (event: DragEvent) => void
|
|
200
|
+
/** Fires when a drop occurs on this object */
|
|
201
|
+
onDrop?: (event: ThreeEvent<DragEvent>) => void
|
|
202
|
+
/** Fires when a drop misses this object (for objects that have drop handlers) */
|
|
203
|
+
onDropMissed?: (event: DragEvent) => void
|
|
204
|
+
onPointerUp?: (event: ThreeEvent<PointerEvent>) => void
|
|
205
|
+
onPointerDown?: (event: ThreeEvent<PointerEvent>) => void
|
|
206
|
+
onPointerOver?: (event: ThreeEvent<PointerEvent>) => void
|
|
207
|
+
onPointerOut?: (event: ThreeEvent<PointerEvent>) => void
|
|
208
|
+
onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void
|
|
209
|
+
onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void
|
|
210
|
+
onPointerMove?: (event: ThreeEvent<PointerEvent>) => void
|
|
211
|
+
onPointerMissed?: (event: MouseEvent) => void
|
|
212
|
+
onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void
|
|
213
|
+
onWheel?: (event: ThreeEvent<WheelEvent>) => void
|
|
214
|
+
onLostPointerCapture?: (event: ThreeEvent<PointerEvent>) => void
|
|
215
|
+
|
|
216
|
+
//* Visibility Events --------------------------------
|
|
217
|
+
/** Fires when object enters/exits camera frustum. Receives true when in view, false when out. */
|
|
218
|
+
onFramed?: (inView: boolean) => void
|
|
219
|
+
/** Fires when object occlusion state changes (WebGPU only, requires occlusionTest=true on object) */
|
|
220
|
+
onOccluded?: (occluded: boolean) => void
|
|
221
|
+
/** Fires when combined visibility changes (frustum + occlusion + visible prop) */
|
|
222
|
+
onVisible?: (visible: boolean) => void
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
type FilterFunction = (items: THREE$1.Intersection[], state: RootState) => THREE$1.Intersection[]
|
|
226
|
+
type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void
|
|
227
|
+
|
|
228
|
+
interface EventManager<TTarget> {
|
|
229
|
+
/** Determines if the event layer is active */
|
|
230
|
+
enabled: boolean
|
|
231
|
+
/** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
|
|
232
|
+
priority: number
|
|
233
|
+
/** The compute function needs to set up the raycaster and an xy- pointer */
|
|
234
|
+
compute?: ComputeFunction
|
|
235
|
+
/** The filter can re-order or re-structure the intersections */
|
|
236
|
+
filter?: FilterFunction
|
|
237
|
+
/** The target node the event layer is tied to */
|
|
238
|
+
connected?: TTarget
|
|
239
|
+
/** All the pointer event handlers through which the host forwards native events */
|
|
240
|
+
handlers?: Events
|
|
241
|
+
/** Allows re-connecting to another target */
|
|
242
|
+
connect?: (target: TTarget) => void
|
|
243
|
+
/** Removes all existing events handlers from the target */
|
|
244
|
+
disconnect?: () => void
|
|
245
|
+
/** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
|
|
246
|
+
* explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
|
|
247
|
+
*/
|
|
248
|
+
update?: () => void
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
interface PointerCaptureTarget {
|
|
252
|
+
intersection: Intersection
|
|
253
|
+
target: Element
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
//* Visibility System Types =====================================
|
|
257
|
+
|
|
258
|
+
/** Entry in the visibility registry for tracking object visibility state */
|
|
259
|
+
interface VisibilityEntry {
|
|
260
|
+
object: THREE$1.Object3D
|
|
261
|
+
handlers: Pick<EventHandlers, 'onFramed' | 'onOccluded' | 'onVisible'>
|
|
262
|
+
lastFramedState: boolean | null
|
|
263
|
+
lastOccludedState: boolean | null
|
|
264
|
+
lastVisibleState: boolean | null
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
//* Scheduler Types (useFrame) ==============================
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
// Public Options --------------------------------
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Options for useFrame hook
|
|
275
|
+
*/
|
|
276
|
+
interface UseFrameNextOptions {
|
|
277
|
+
/** Optional stable id for the job. Auto-generated if not provided */
|
|
278
|
+
id?: string
|
|
279
|
+
/** Named phase to run in. Default: 'update' */
|
|
280
|
+
phase?: string
|
|
281
|
+
/** Run before this phase or job id */
|
|
282
|
+
before?: string | string[]
|
|
283
|
+
/** Run after this phase or job id */
|
|
284
|
+
after?: string | string[]
|
|
285
|
+
/** Priority within phase. Higher runs first. Default: 0 */
|
|
286
|
+
priority?: number
|
|
287
|
+
/** Max frames per second for this job */
|
|
288
|
+
fps?: number
|
|
289
|
+
/** If true, skip frames when behind. If false, try to catch up. Default: true */
|
|
290
|
+
drop?: boolean
|
|
291
|
+
/** Enable/disable without unregistering. Default: true */
|
|
292
|
+
enabled?: boolean
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** Alias for UseFrameNextOptions */
|
|
296
|
+
type UseFrameOptions = UseFrameNextOptions
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Options for addPhase
|
|
300
|
+
*/
|
|
301
|
+
interface AddPhaseOptions {
|
|
302
|
+
/** Insert this phase before the specified phase */
|
|
303
|
+
before?: string
|
|
304
|
+
/** Insert this phase after the specified phase */
|
|
305
|
+
after?: string
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// Frame State --------------------------------
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Timing-only state for independent/outside mode (no RootState)
|
|
312
|
+
*/
|
|
313
|
+
interface FrameTimingState {
|
|
314
|
+
/** High-resolution timestamp from RAF (ms) */
|
|
315
|
+
time: number
|
|
316
|
+
/** Time since last frame in seconds (for legacy compatibility with THREE.Clock) */
|
|
317
|
+
delta: number
|
|
318
|
+
/** Elapsed time since first frame in seconds (for legacy compatibility with THREE.Clock) */
|
|
319
|
+
elapsed: number
|
|
320
|
+
/** Incrementing frame counter */
|
|
321
|
+
frame: number
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* State passed to useFrame callbacks (extends RootState with timing)
|
|
326
|
+
*/
|
|
327
|
+
interface FrameNextState extends RootState, FrameTimingState {}
|
|
328
|
+
|
|
329
|
+
/** Alias for FrameNextState */
|
|
330
|
+
type FrameState = FrameNextState
|
|
331
|
+
|
|
332
|
+
// Root Options --------------------------------
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Options for registerRoot
|
|
336
|
+
*/
|
|
337
|
+
interface RootOptions {
|
|
338
|
+
/** State provider for callbacks. Optional in independent mode. */
|
|
339
|
+
getState?: () => any
|
|
340
|
+
/** Error handler for job errors. Falls back to console.error if not provided. */
|
|
341
|
+
onError?: (error: Error) => void
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Callback Types --------------------------------
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Callback function for useFrame
|
|
348
|
+
*/
|
|
349
|
+
type FrameNextCallback = (state: FrameNextState, delta: number) => void
|
|
350
|
+
|
|
351
|
+
/** Alias for FrameNextCallback */
|
|
352
|
+
type FrameCallback = FrameNextCallback
|
|
353
|
+
|
|
354
|
+
// Controls returned from useFrame --------------------------------
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Controls object returned from useFrame hook
|
|
358
|
+
*/
|
|
359
|
+
interface FrameNextControls {
|
|
360
|
+
/** The job's unique ID */
|
|
361
|
+
id: string
|
|
362
|
+
/** Access to the global scheduler for frame loop control */
|
|
363
|
+
scheduler: SchedulerApi
|
|
364
|
+
/** Manually step this job only (bypasses FPS limiting) */
|
|
365
|
+
step(timestamp?: number): void
|
|
366
|
+
/** Manually step ALL jobs in the scheduler */
|
|
367
|
+
stepAll(timestamp?: number): void
|
|
368
|
+
/** Pause this job (set enabled=false) */
|
|
369
|
+
pause(): void
|
|
370
|
+
/** Resume this job (set enabled=true) */
|
|
371
|
+
resume(): void
|
|
372
|
+
/** Reactive paused state - automatically triggers re-render when changed */
|
|
373
|
+
isPaused: boolean
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** Alias for FrameNextControls */
|
|
377
|
+
type FrameControls = FrameNextControls
|
|
378
|
+
|
|
379
|
+
// Scheduler Interface --------------------------------
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Public interface for the global Scheduler
|
|
383
|
+
*/
|
|
384
|
+
interface SchedulerApi {
|
|
385
|
+
//* Phase Management --------------------------------
|
|
386
|
+
|
|
387
|
+
/** Add a named phase to the scheduler */
|
|
388
|
+
addPhase(name: string, options?: AddPhaseOptions): void
|
|
389
|
+
/** Get the ordered list of phase names */
|
|
390
|
+
readonly phases: string[]
|
|
391
|
+
/** Check if a phase exists */
|
|
392
|
+
hasPhase(name: string): boolean
|
|
393
|
+
|
|
394
|
+
//* Root Management --------------------------------
|
|
395
|
+
|
|
396
|
+
/** Register a root (Canvas) with the scheduler. Returns unsubscribe function. */
|
|
397
|
+
registerRoot(id: string, options?: RootOptions): () => void
|
|
398
|
+
/** Unregister a root */
|
|
399
|
+
unregisterRoot(id: string): void
|
|
400
|
+
/** Generate a unique root ID */
|
|
401
|
+
generateRootId(): string
|
|
402
|
+
/** Get the number of registered roots */
|
|
403
|
+
getRootCount(): number
|
|
404
|
+
/** Check if any root is registered and ready */
|
|
405
|
+
readonly isReady: boolean
|
|
406
|
+
/** Subscribe to root-ready event. Fires immediately if already ready. Returns unsubscribe. */
|
|
407
|
+
onRootReady(callback: () => void): () => void
|
|
408
|
+
|
|
409
|
+
//* Job Registration --------------------------------
|
|
410
|
+
|
|
411
|
+
/** Register a job with the scheduler (returns unsubscribe function) */
|
|
412
|
+
register(
|
|
413
|
+
callback: FrameNextCallback,
|
|
414
|
+
options?: {
|
|
415
|
+
id?: string
|
|
416
|
+
rootId?: string
|
|
417
|
+
phase?: string
|
|
418
|
+
before?: string | string[]
|
|
419
|
+
after?: string | string[]
|
|
420
|
+
priority?: number
|
|
421
|
+
fps?: number
|
|
422
|
+
drop?: boolean
|
|
423
|
+
enabled?: boolean
|
|
424
|
+
},
|
|
425
|
+
): () => void
|
|
426
|
+
/** Update a job's options */
|
|
427
|
+
updateJob(
|
|
428
|
+
id: string,
|
|
429
|
+
options: {
|
|
430
|
+
priority?: number
|
|
431
|
+
fps?: number
|
|
432
|
+
drop?: boolean
|
|
433
|
+
enabled?: boolean
|
|
434
|
+
phase?: string
|
|
435
|
+
before?: string | string[]
|
|
436
|
+
after?: string | string[]
|
|
437
|
+
},
|
|
438
|
+
): void
|
|
439
|
+
/** Unregister a job by ID */
|
|
440
|
+
unregister(id: string, rootId?: string): void
|
|
441
|
+
/** Get the number of registered jobs */
|
|
442
|
+
getJobCount(): number
|
|
443
|
+
/** Get all job IDs */
|
|
444
|
+
getJobIds(): string[]
|
|
445
|
+
|
|
446
|
+
//* Global Jobs (for legacy addEffect/addAfterEffect) --------------------------------
|
|
447
|
+
|
|
448
|
+
/** Register a global job (runs once per frame, not per-root). Returns unsubscribe function. */
|
|
449
|
+
registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void
|
|
450
|
+
|
|
451
|
+
//* Idle Callbacks (for legacy addTail) --------------------------------
|
|
452
|
+
|
|
453
|
+
/** Register an idle callback (fires when loop stops). Returns unsubscribe function. */
|
|
454
|
+
onIdle(callback: (timestamp: number) => void): () => void
|
|
455
|
+
|
|
456
|
+
//* Frame Loop Control --------------------------------
|
|
457
|
+
|
|
458
|
+
/** Start the scheduler loop */
|
|
459
|
+
start(): void
|
|
460
|
+
/** Stop the scheduler loop */
|
|
461
|
+
stop(): void
|
|
462
|
+
/** Check if the scheduler is running */
|
|
463
|
+
readonly isRunning: boolean
|
|
464
|
+
/** Get/set the frameloop mode ('always', 'demand', 'never') */
|
|
465
|
+
frameloop: Frameloop
|
|
466
|
+
/** Independent mode - runs without Canvas, callbacks receive timing-only state */
|
|
467
|
+
independent: boolean
|
|
468
|
+
|
|
469
|
+
//* Manual Stepping --------------------------------
|
|
470
|
+
|
|
471
|
+
/** Manually step all jobs once (for frameloop='never' or testing) */
|
|
472
|
+
step(timestamp?: number): void
|
|
473
|
+
/** Manually step a single job by ID */
|
|
474
|
+
stepJob(id: string, timestamp?: number): void
|
|
475
|
+
/** Request frame(s) to be rendered (for frameloop='demand') */
|
|
476
|
+
invalidate(frames?: number): void
|
|
477
|
+
|
|
478
|
+
//* Per-Job Control --------------------------------
|
|
479
|
+
|
|
480
|
+
/** Check if a job is paused */
|
|
481
|
+
isJobPaused(id: string): boolean
|
|
482
|
+
/** Pause a job */
|
|
483
|
+
pauseJob(id: string): void
|
|
484
|
+
/** Resume a job */
|
|
485
|
+
resumeJob(id: string): void
|
|
486
|
+
/** Subscribe to job state changes (for reactive isPaused). Returns unsubscribe function. */
|
|
487
|
+
subscribeJobState(id: string, listener: () => void): () => void
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
//* Renderer Types ========================================
|
|
491
|
+
|
|
492
|
+
/** Default renderer type - union of WebGL and WebGPU renderers */
|
|
493
|
+
type R3FRenderer = THREE$1.WebGLRenderer | WebGPURenderer
|
|
494
|
+
|
|
495
|
+
//* Core Store Types ========================================
|
|
496
|
+
|
|
497
|
+
type Subscription = {
|
|
498
|
+
ref: React$1.RefObject<RenderCallback>
|
|
499
|
+
priority: number
|
|
500
|
+
store: RootStore
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
type Dpr = number | [min: number, max: number]
|
|
504
|
+
|
|
505
|
+
interface Size {
|
|
506
|
+
width: number
|
|
507
|
+
height: number
|
|
508
|
+
top: number
|
|
509
|
+
left: number
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
type Frameloop = 'always' | 'demand' | 'never'
|
|
513
|
+
|
|
514
|
+
interface Viewport extends Size {
|
|
515
|
+
/** The initial pixel ratio */
|
|
516
|
+
initialDpr: number
|
|
517
|
+
/** Current pixel ratio */
|
|
518
|
+
dpr: number
|
|
519
|
+
/** size.width / viewport.width */
|
|
520
|
+
factor: number
|
|
521
|
+
/** Camera distance */
|
|
522
|
+
distance: number
|
|
523
|
+
/** Camera aspect ratio: width / height */
|
|
524
|
+
aspect: number
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
type RenderCallback = (state: RootState, delta: number, frame?: XRFrame) => void
|
|
528
|
+
|
|
529
|
+
interface Performance {
|
|
530
|
+
/** Current performance normal, between min and max */
|
|
531
|
+
current: number
|
|
532
|
+
/** How low the performance can go, between 0 and max */
|
|
533
|
+
min: number
|
|
534
|
+
/** How high the performance can go, between min and max */
|
|
535
|
+
max: number
|
|
536
|
+
/** Time until current returns to max in ms */
|
|
537
|
+
debounce: number
|
|
538
|
+
/** Sets current to min, puts the system in regression */
|
|
539
|
+
regress: () => void
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
interface InternalState {
|
|
543
|
+
interaction: THREE$1.Object3D[]
|
|
544
|
+
hovered: Map<string, ThreeEvent<DomEvent>>
|
|
545
|
+
subscribers: Subscription[]
|
|
546
|
+
capturedMap: Map<number, Map<THREE$1.Object3D, PointerCaptureTarget>>
|
|
547
|
+
initialClick: [x: number, y: number]
|
|
548
|
+
initialHits: THREE$1.Object3D[]
|
|
549
|
+
lastEvent: React$1.RefObject<DomEvent | null>
|
|
550
|
+
/** Visibility event registry (onFramed, onOccluded, onVisible) */
|
|
551
|
+
visibilityRegistry: Map<string, VisibilityEntry>
|
|
552
|
+
/** Whether occlusion queries are enabled (WebGPU only) */
|
|
553
|
+
occlusionEnabled: boolean
|
|
554
|
+
/** Reference to the invisible occlusion observer mesh */
|
|
555
|
+
occlusionObserver: THREE$1.Mesh | null
|
|
556
|
+
/** Cached occlusion results from render pass - keyed by Object3D */
|
|
557
|
+
occlusionCache: Map<THREE$1.Object3D, boolean | null>
|
|
558
|
+
/** Internal helper group for R3F system objects (occlusion observer, etc.) */
|
|
559
|
+
helperGroup: THREE$1.Group | null
|
|
560
|
+
active: boolean
|
|
561
|
+
priority: number
|
|
562
|
+
frames: number
|
|
563
|
+
subscribe: (callback: React$1.RefObject<RenderCallback>, priority: number, store: RootStore) => () => void
|
|
564
|
+
/** Internal renderer storage - use state.renderer or state.gl to access */
|
|
565
|
+
actualRenderer: R3FRenderer
|
|
566
|
+
/** Global scheduler reference (for useFrame hook) */
|
|
567
|
+
scheduler: SchedulerApi | null
|
|
568
|
+
/** This root's unique ID in the global scheduler */
|
|
569
|
+
rootId?: string
|
|
570
|
+
/** Function to unregister this root from the global scheduler */
|
|
571
|
+
unregisterRoot?: () => void
|
|
572
|
+
/** Container for child attachment (scene for root, original container for portals) */
|
|
573
|
+
container?: THREE$1.Object3D
|
|
574
|
+
/**
|
|
575
|
+
* CanvasTarget for multi-canvas WebGPU rendering.
|
|
576
|
+
* Created for all WebGPU canvases to support renderer sharing.
|
|
577
|
+
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
578
|
+
*/
|
|
579
|
+
canvasTarget?: CanvasTarget
|
|
580
|
+
/**
|
|
581
|
+
* Whether multi-canvas rendering is active.
|
|
582
|
+
* True when any canvas uses `target` prop to share a renderer.
|
|
583
|
+
* When true, setCanvasTarget is called before each render.
|
|
584
|
+
*/
|
|
585
|
+
isMultiCanvas?: boolean
|
|
586
|
+
/**
|
|
587
|
+
* Whether this canvas is a secondary canvas sharing another's renderer.
|
|
588
|
+
* True when `target` prop is used.
|
|
589
|
+
*/
|
|
590
|
+
isSecondary?: boolean
|
|
591
|
+
/**
|
|
592
|
+
* The id of the primary canvas this secondary canvas targets.
|
|
593
|
+
* Only set when isSecondary is true.
|
|
594
|
+
*/
|
|
595
|
+
targetId?: string
|
|
596
|
+
/**
|
|
597
|
+
* Function to unregister this primary canvas from the registry.
|
|
598
|
+
* Only set when this canvas has an `id` prop.
|
|
599
|
+
*/
|
|
600
|
+
unregisterPrimary?: () => void
|
|
601
|
+
/** Whether canvas dimensions are forced to even numbers */
|
|
602
|
+
forceEven?: boolean
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
interface XRManager {
|
|
606
|
+
connect: () => void
|
|
607
|
+
disconnect: () => void
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
//* Root State Interface ====================================
|
|
611
|
+
|
|
612
|
+
interface RootState {
|
|
613
|
+
/** Set current state */
|
|
614
|
+
set: StoreApi<RootState>['setState']
|
|
615
|
+
/** Get current state */
|
|
616
|
+
get: StoreApi<RootState>['getState']
|
|
617
|
+
/**
|
|
618
|
+
* Reference to the authoritative store for shared TSL resources (uniforms, nodes, etc).
|
|
619
|
+
* - For primary/independent canvases: points to its own store (self-reference)
|
|
620
|
+
* - For secondary canvases: points to the primary canvas's store
|
|
621
|
+
*
|
|
622
|
+
* Hooks like useNodes/useUniforms should read from primaryStore to ensure
|
|
623
|
+
* consistent shared state across all canvases sharing a renderer.
|
|
624
|
+
*/
|
|
625
|
+
primaryStore: RootStore
|
|
626
|
+
/** @deprecated Use `renderer` instead. The instance of the renderer (typed as WebGLRenderer for backwards compat) */
|
|
627
|
+
gl: THREE$1.WebGLRenderer
|
|
628
|
+
/** The renderer instance - type depends on entry point (WebGPU, Legacy, or union for default) */
|
|
629
|
+
renderer: R3FRenderer
|
|
630
|
+
/** Inspector of the webGPU Renderer. Init in the canvas */
|
|
631
|
+
inspector: any // Inspector type from three/webgpu
|
|
632
|
+
|
|
633
|
+
/** Default camera */
|
|
634
|
+
camera: ThreeCamera
|
|
635
|
+
/** Camera frustum for visibility checks - auto-updated each frame when autoUpdateFrustum is true */
|
|
636
|
+
frustum: THREE$1.Frustum
|
|
637
|
+
/** Whether to automatically update the frustum each frame (default: true) */
|
|
638
|
+
autoUpdateFrustum: boolean
|
|
639
|
+
/** Default scene (may be overridden in portals to point to the portal container) */
|
|
640
|
+
scene: THREE$1.Scene
|
|
641
|
+
/** The actual root THREE.Scene - always points to the true scene, even inside portals */
|
|
642
|
+
rootScene: THREE$1.Scene
|
|
643
|
+
/** Default raycaster */
|
|
644
|
+
raycaster: THREE$1.Raycaster
|
|
645
|
+
/** Event layer interface, contains the event handler and the node they're connected to */
|
|
646
|
+
events: EventManager<any>
|
|
647
|
+
/** XR interface */
|
|
648
|
+
xr: XRManager
|
|
649
|
+
/** Currently used controls */
|
|
650
|
+
controls: THREE$1.EventDispatcher | null
|
|
651
|
+
/** Normalized event coordinates */
|
|
652
|
+
pointer: THREE$1.Vector2
|
|
653
|
+
/** @deprecated Normalized event coordinates, use "pointer" instead! */
|
|
654
|
+
mouse: THREE$1.Vector2
|
|
655
|
+
/** Color space assigned to 8-bit input textures (color maps). Most textures are authored in sRGB. */
|
|
656
|
+
textureColorSpace: THREE$1.ColorSpace
|
|
657
|
+
/** Render loop flags */
|
|
658
|
+
frameloop: Frameloop
|
|
659
|
+
performance: Performance
|
|
660
|
+
/** Reactive pixel-size of the canvas */
|
|
661
|
+
size: Size
|
|
662
|
+
/** Reactive size of the viewport in threejs units */
|
|
663
|
+
viewport: Viewport & {
|
|
664
|
+
getCurrentViewport: (
|
|
665
|
+
camera?: ThreeCamera,
|
|
666
|
+
target?: THREE$1.Vector3 | Parameters<THREE$1.Vector3['set']>,
|
|
667
|
+
size?: Size,
|
|
668
|
+
) => Omit<Viewport, 'dpr' | 'initialDpr'>
|
|
669
|
+
}
|
|
670
|
+
/** Flags the canvas for render, but doesn't render in itself */
|
|
671
|
+
invalidate: (frames?: number, stackFrames?: boolean) => void
|
|
672
|
+
/** Advance (render) one step */
|
|
673
|
+
advance: (timestamp: number, runGlobalEffects?: boolean) => void
|
|
674
|
+
/** Shortcut to setting the event layer */
|
|
675
|
+
setEvents: (events: Partial<EventManager<any>>) => void
|
|
676
|
+
/** Shortcut to manual sizing. No args resets to props/container. Single arg creates square. */
|
|
677
|
+
setSize: (width?: number, height?: number, top?: number, left?: number) => void
|
|
678
|
+
/** Shortcut to manual setting the pixel ratio */
|
|
679
|
+
setDpr: (dpr: Dpr) => void
|
|
680
|
+
/** Shortcut to setting frameloop flags */
|
|
681
|
+
setFrameloop: (frameloop: Frameloop) => void
|
|
682
|
+
/** Set error state to propagate to error boundary */
|
|
683
|
+
setError: (error: Error | null) => void
|
|
684
|
+
/** Current error state (null when no error) */
|
|
685
|
+
error: Error | null
|
|
686
|
+
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
687
|
+
uniforms: UniformStore
|
|
688
|
+
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
689
|
+
nodes: Record<string, any>
|
|
690
|
+
/** Global TSL texture nodes - use useTextures() hook for operations */
|
|
691
|
+
textures: Map<string, any>
|
|
692
|
+
/** WebGPU PostProcessing instance - use usePostProcessing() hook */
|
|
693
|
+
postProcessing: any | null // THREE.PostProcessing when available
|
|
694
|
+
/** Global TSL pass nodes for post-processing - use usePostProcessing() hook */
|
|
695
|
+
passes: Record<string, any>
|
|
696
|
+
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
697
|
+
_hmrVersion: number
|
|
698
|
+
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
699
|
+
_sizeImperative: boolean
|
|
700
|
+
/** Internal: stored size props from Canvas for reset functionality */
|
|
701
|
+
_sizeProps: { width?: number; height?: number } | null
|
|
702
|
+
/** When the canvas was clicked but nothing was hit */
|
|
703
|
+
onPointerMissed?: (event: MouseEvent) => void
|
|
704
|
+
/** When a dragover event has missed any target */
|
|
705
|
+
onDragOverMissed?: (event: DragEvent) => void
|
|
706
|
+
/** When a drop event has missed any target */
|
|
707
|
+
onDropMissed?: (event: DragEvent) => void
|
|
708
|
+
/** If this state model is layered (via createPortal) then this contains the previous layer */
|
|
709
|
+
previousRoot?: RootStore
|
|
710
|
+
/** Internals */
|
|
711
|
+
internal: InternalState
|
|
712
|
+
// flags for triggers
|
|
713
|
+
// if we are using the webGl renderer, this will be true
|
|
714
|
+
isLegacy: boolean
|
|
715
|
+
// regardless of renderer, if the system supports webGpu, this will be true
|
|
716
|
+
webGPUSupported: boolean
|
|
717
|
+
//if we are on native
|
|
718
|
+
isNative: boolean
|
|
719
|
+
}
|
|
720
|
+
|
|
662
721
|
type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
|
|
663
722
|
|
|
664
|
-
//* Base Renderer Types =====================================
|
|
665
|
-
|
|
666
|
-
// Shim for OffscreenCanvas since it was removed from DOM types
|
|
667
|
-
interface OffscreenCanvas$1 extends EventTarget {}
|
|
668
|
-
|
|
669
|
-
interface BaseRendererProps {
|
|
670
|
-
canvas: HTMLCanvasElement | OffscreenCanvas$1
|
|
671
|
-
powerPreference?: 'high-performance' | 'low-power' | 'default'
|
|
672
|
-
antialias?: boolean
|
|
673
|
-
alpha?: boolean
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
type RendererFactory<TRenderer, TParams> =
|
|
677
|
-
| TRenderer
|
|
678
|
-
| ((defaultProps: TParams) => TRenderer)
|
|
679
|
-
| ((defaultProps: TParams) => Promise<TRenderer>)
|
|
680
|
-
|
|
681
|
-
interface Renderer {
|
|
682
|
-
render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
//* WebGL Renderer Props ==============================
|
|
686
|
-
|
|
687
|
-
type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
|
|
688
|
-
canvas: HTMLCanvasElement | OffscreenCanvas$1
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
type GLProps =
|
|
692
|
-
| Renderer
|
|
693
|
-
| ((defaultProps: DefaultGLProps) => Renderer)
|
|
694
|
-
| ((defaultProps: DefaultGLProps) => Promise<Renderer>)
|
|
695
|
-
| Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
|
|
696
|
-
|
|
697
|
-
//* WebGPU Renderer Props ==============================
|
|
698
|
-
|
|
699
|
-
type DefaultRendererProps = {
|
|
700
|
-
canvas: HTMLCanvasElement | OffscreenCanvas$1
|
|
701
|
-
[key: string]: any
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
/**
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
/**
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
/**
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
*
|
|
785
|
-
*
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
723
|
+
//* Base Renderer Types =====================================
|
|
724
|
+
|
|
725
|
+
// Shim for OffscreenCanvas since it was removed from DOM types
|
|
726
|
+
interface OffscreenCanvas$1 extends EventTarget {}
|
|
727
|
+
|
|
728
|
+
interface BaseRendererProps {
|
|
729
|
+
canvas: HTMLCanvasElement | OffscreenCanvas$1
|
|
730
|
+
powerPreference?: 'high-performance' | 'low-power' | 'default'
|
|
731
|
+
antialias?: boolean
|
|
732
|
+
alpha?: boolean
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
type RendererFactory<TRenderer, TParams> =
|
|
736
|
+
| TRenderer
|
|
737
|
+
| ((defaultProps: TParams) => TRenderer)
|
|
738
|
+
| ((defaultProps: TParams) => Promise<TRenderer>)
|
|
739
|
+
|
|
740
|
+
interface Renderer {
|
|
741
|
+
render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
//* WebGL Renderer Props ==============================
|
|
745
|
+
|
|
746
|
+
type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
|
|
747
|
+
canvas: HTMLCanvasElement | OffscreenCanvas$1
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
type GLProps =
|
|
751
|
+
| Renderer
|
|
752
|
+
| ((defaultProps: DefaultGLProps) => Renderer)
|
|
753
|
+
| ((defaultProps: DefaultGLProps) => Promise<Renderer>)
|
|
754
|
+
| Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
|
|
755
|
+
|
|
756
|
+
//* WebGPU Renderer Props ==============================
|
|
757
|
+
|
|
758
|
+
type DefaultRendererProps = {
|
|
759
|
+
canvas: HTMLCanvasElement | OffscreenCanvas$1
|
|
760
|
+
[key: string]: any
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Canvas-level scheduler configuration.
|
|
765
|
+
* Controls render timing relative to other canvases.
|
|
766
|
+
*/
|
|
767
|
+
interface CanvasSchedulerConfig {
|
|
768
|
+
/**
|
|
769
|
+
* Render this canvas after another canvas completes.
|
|
770
|
+
* Pass the `id` of another canvas.
|
|
771
|
+
*/
|
|
772
|
+
after?: string
|
|
773
|
+
/**
|
|
774
|
+
* Limit this canvas's render rate (frames per second).
|
|
775
|
+
*/
|
|
776
|
+
fps?: number
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Extended renderer configuration for multi-canvas support.
|
|
781
|
+
*/
|
|
782
|
+
interface RendererConfigExtended {
|
|
783
|
+
/** Share renderer from another canvas (WebGPU only) */
|
|
784
|
+
primaryCanvas?: string
|
|
785
|
+
/** Canvas-level scheduler options */
|
|
786
|
+
scheduler?: CanvasSchedulerConfig
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
type RendererProps =
|
|
790
|
+
| any // WebGPURenderer
|
|
791
|
+
| ((defaultProps: DefaultRendererProps) => any)
|
|
792
|
+
| ((defaultProps: DefaultRendererProps) => Promise<any>)
|
|
793
|
+
| (Partial<Properties<any> | Record<string, any>> & RendererConfigExtended)
|
|
794
|
+
|
|
795
|
+
//* Camera Props ==============================
|
|
796
|
+
|
|
797
|
+
type CameraProps = (
|
|
798
|
+
| THREE$1.Camera
|
|
799
|
+
| Partial<
|
|
800
|
+
ThreeElement<typeof THREE$1.Camera> &
|
|
801
|
+
ThreeElement<typeof THREE$1.PerspectiveCamera> &
|
|
802
|
+
ThreeElement<typeof THREE$1.OrthographicCamera>
|
|
803
|
+
>
|
|
804
|
+
) & {
|
|
805
|
+
/** Flags the camera as manual, putting projection into your own hands */
|
|
806
|
+
manual?: boolean
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
//* Render Props ==============================
|
|
810
|
+
|
|
811
|
+
interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
812
|
+
/**
|
|
813
|
+
* Unique identifier for multi-canvas renderer sharing.
|
|
814
|
+
* Makes this canvas targetable by other canvases using the `primaryCanvas` prop.
|
|
815
|
+
* Also sets the HTML `id` attribute on the canvas element.
|
|
816
|
+
* @example <Canvas id="main-viewer">...</Canvas>
|
|
817
|
+
*/
|
|
818
|
+
id?: string
|
|
819
|
+
/**
|
|
820
|
+
* Share the renderer from another canvas instead of creating a new one.
|
|
821
|
+
* Pass the `id` of the primary canvas to share its WebGPURenderer.
|
|
822
|
+
* Only available with WebGPU (not legacy WebGL).
|
|
823
|
+
*
|
|
824
|
+
* Note: This is extracted from `renderer={{ primaryCanvas: "id" }}` by Canvas.
|
|
825
|
+
* @internal
|
|
826
|
+
*/
|
|
827
|
+
primaryCanvas?: string
|
|
828
|
+
/**
|
|
829
|
+
* Canvas-level scheduler options. Controls render timing relative to other canvases.
|
|
830
|
+
*
|
|
831
|
+
* Note: This is extracted from `renderer={{ scheduler: {...} }}` by Canvas.
|
|
832
|
+
* @internal
|
|
833
|
+
*/
|
|
834
|
+
scheduler?: CanvasSchedulerConfig
|
|
835
|
+
/** A threejs renderer instance or props that go into the default renderer */
|
|
836
|
+
gl?: GLProps
|
|
837
|
+
/** A WebGPU renderer instance or props that go into the default renderer */
|
|
838
|
+
renderer?: RendererProps
|
|
839
|
+
/** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
|
|
840
|
+
size?: Size
|
|
841
|
+
/**
|
|
842
|
+
* Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
|
|
843
|
+
* but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
|
|
844
|
+
* @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
|
|
845
|
+
*/
|
|
846
|
+
shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
|
|
847
|
+
/** Color space assigned to 8-bit input textures (color maps). Defaults to sRGB. Most textures are authored in sRGB. */
|
|
848
|
+
textureColorSpace?: THREE$1.ColorSpace
|
|
849
|
+
/** Creates an orthographic camera */
|
|
850
|
+
orthographic?: boolean
|
|
851
|
+
/**
|
|
852
|
+
* R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
|
|
853
|
+
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
|
|
854
|
+
*/
|
|
855
|
+
frameloop?: Frameloop
|
|
856
|
+
/**
|
|
857
|
+
* R3F performance options for adaptive performance.
|
|
858
|
+
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
|
|
859
|
+
*/
|
|
860
|
+
performance?: Partial<Omit<Performance, 'regress'>>
|
|
861
|
+
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
862
|
+
dpr?: Dpr
|
|
863
|
+
/** Props that go into the default raycaster */
|
|
864
|
+
raycaster?: Partial<THREE$1.Raycaster>
|
|
865
|
+
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
866
|
+
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
867
|
+
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
868
|
+
camera?: CameraProps
|
|
869
|
+
/** An R3F event manager to manage elements' pointer events */
|
|
870
|
+
events?: (store: RootStore) => EventManager<HTMLElement>
|
|
871
|
+
/** Callback after the canvas has rendered (but not yet committed) */
|
|
872
|
+
onCreated?: (state: RootState) => void
|
|
873
|
+
/** Response for pointer clicks that have missed any target */
|
|
874
|
+
onPointerMissed?: (event: MouseEvent) => void
|
|
875
|
+
/** Response for dragover events that have missed any target */
|
|
876
|
+
onDragOverMissed?: (event: DragEvent) => void
|
|
877
|
+
/** Response for drop events that have missed any target */
|
|
878
|
+
onDropMissed?: (event: DragEvent) => void
|
|
879
|
+
/** Whether to automatically update the frustum each frame (default: true) */
|
|
880
|
+
autoUpdateFrustum?: boolean
|
|
881
|
+
/**
|
|
882
|
+
* Enable WebGPU occlusion queries for onOccluded/onVisible events.
|
|
883
|
+
* Auto-enabled when any object uses onOccluded or onVisible handlers.
|
|
884
|
+
* Only works with WebGPU renderer - WebGL will log a warning.
|
|
885
|
+
*/
|
|
886
|
+
occlusion?: boolean
|
|
887
|
+
/** Internal: stored size props from Canvas for reset functionality */
|
|
888
|
+
_sizeProps?: { width?: number; height?: number } | null
|
|
889
|
+
/** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
|
|
890
|
+
forceEven?: boolean
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
//* Reconciler Root ==============================
|
|
894
|
+
|
|
895
|
+
interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
896
|
+
configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>
|
|
897
|
+
render: (element: ReactNode) => RootStore
|
|
898
|
+
unmount: () => void
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
//* Inject State ==============================
|
|
902
|
+
|
|
903
|
+
type InjectState = Partial<
|
|
904
|
+
Omit<RootState, 'events'> & {
|
|
905
|
+
events?: {
|
|
906
|
+
enabled?: boolean
|
|
907
|
+
priority?: number
|
|
908
|
+
compute?: ComputeFunction
|
|
909
|
+
connected?: any
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* When true (default), injects a THREE.Scene between container and children if container isn't already a Scene.
|
|
913
|
+
* This ensures state.scene is always a real THREE.Scene with proper properties (background, environment, fog).
|
|
914
|
+
* Set to false to use the container directly as scene (anti-pattern, but supported for edge cases).
|
|
915
|
+
*/
|
|
916
|
+
injectScene?: boolean
|
|
917
|
+
}
|
|
818
918
|
>
|
|
819
919
|
|
|
820
|
-
//* Reconciler Types ==============================
|
|
821
|
-
|
|
822
|
-
// FiberRoot is an opaque internal React type - we define it locally
|
|
823
|
-
// to avoid bundling @types/react-reconciler which causes absolute path issues
|
|
824
|
-
type FiberRoot = any
|
|
825
|
-
|
|
826
|
-
interface Root {
|
|
827
|
-
fiber: FiberRoot
|
|
828
|
-
store: RootStore
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
type AttachFnType<O = any> = (parent: any, self: O) => () => void
|
|
832
|
-
type AttachType<O = any> = string | AttachFnType<O>
|
|
833
|
-
|
|
834
|
-
type ConstructorRepresentation<T = any> = new (...args: any[]) => T
|
|
835
|
-
|
|
836
|
-
interface Catalogue {
|
|
837
|
-
[name: string]: ConstructorRepresentation
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
// TODO: handle constructor overloads
|
|
841
|
-
// https://github.com/pmndrs/react-three-fiber/pull/2931
|
|
842
|
-
// https://github.com/microsoft/TypeScript/issues/37079
|
|
843
|
-
type Args<T> = T extends ConstructorRepresentation
|
|
844
|
-
? T extends typeof Color$1
|
|
845
|
-
? [r: number, g: number, b: number] | [color: ColorRepresentation]
|
|
846
|
-
: ConstructorParameters<T>
|
|
847
|
-
: any[]
|
|
848
|
-
|
|
849
|
-
type ArgsProp<P> = P extends ConstructorRepresentation
|
|
850
|
-
? IsAllOptional<ConstructorParameters<P>> extends true
|
|
851
|
-
? { args?: Args<P> }
|
|
852
|
-
: { args: Args<P> }
|
|
853
|
-
: { args: unknown[] }
|
|
854
|
-
|
|
855
|
-
type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
856
|
-
object?: T
|
|
857
|
-
dispose?: null
|
|
858
|
-
attach?: AttachType<T>
|
|
859
|
-
onUpdate?: (self: T) => void
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
interface Instance<O = any> {
|
|
863
|
-
root: RootStore
|
|
864
|
-
type: string
|
|
865
|
-
parent: Instance | null
|
|
866
|
-
children: Instance[]
|
|
867
|
-
props: InstanceProps<O> & Record<string, unknown>
|
|
868
|
-
object: O & { __r3f?: Instance<O> }
|
|
869
|
-
eventCount: number
|
|
870
|
-
handlers: Partial<EventHandlers>
|
|
871
|
-
attach?: AttachType<O>
|
|
872
|
-
previousAttach?: any
|
|
873
|
-
isHidden: boolean
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
920
|
+
//* Reconciler Types ==============================
|
|
921
|
+
|
|
922
|
+
// FiberRoot is an opaque internal React type - we define it locally
|
|
923
|
+
// to avoid bundling @types/react-reconciler which causes absolute path issues
|
|
924
|
+
type FiberRoot = any
|
|
925
|
+
|
|
926
|
+
interface Root {
|
|
927
|
+
fiber: FiberRoot
|
|
928
|
+
store: RootStore
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
type AttachFnType<O = any> = (parent: any, self: O) => () => void
|
|
932
|
+
type AttachType<O = any> = string | AttachFnType<O>
|
|
933
|
+
|
|
934
|
+
type ConstructorRepresentation<T = any> = new (...args: any[]) => T
|
|
935
|
+
|
|
936
|
+
interface Catalogue {
|
|
937
|
+
[name: string]: ConstructorRepresentation
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
// TODO: handle constructor overloads
|
|
941
|
+
// https://github.com/pmndrs/react-three-fiber/pull/2931
|
|
942
|
+
// https://github.com/microsoft/TypeScript/issues/37079
|
|
943
|
+
type Args<T> = T extends ConstructorRepresentation
|
|
944
|
+
? T extends typeof Color$1
|
|
945
|
+
? [r: number, g: number, b: number] | [color: ColorRepresentation]
|
|
946
|
+
: ConstructorParameters<T>
|
|
947
|
+
: any[]
|
|
948
|
+
|
|
949
|
+
type ArgsProp<P> = P extends ConstructorRepresentation
|
|
950
|
+
? IsAllOptional<ConstructorParameters<P>> extends true
|
|
951
|
+
? { args?: Args<P> }
|
|
952
|
+
: { args: Args<P> }
|
|
953
|
+
: { args: unknown[] }
|
|
954
|
+
|
|
955
|
+
type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
956
|
+
object?: T
|
|
957
|
+
dispose?: null
|
|
958
|
+
attach?: AttachType<T>
|
|
959
|
+
onUpdate?: (self: T) => void
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
interface Instance<O = any> {
|
|
963
|
+
root: RootStore
|
|
964
|
+
type: string
|
|
965
|
+
parent: Instance | null
|
|
966
|
+
children: Instance[]
|
|
967
|
+
props: InstanceProps<O> & Record<string, unknown>
|
|
968
|
+
object: O & { __r3f?: Instance<O> }
|
|
969
|
+
eventCount: number
|
|
970
|
+
handlers: Partial<EventHandlers>
|
|
971
|
+
attach?: AttachType<O>
|
|
972
|
+
previousAttach?: any
|
|
973
|
+
isHidden: boolean
|
|
974
|
+
/** Deferred ref props to apply in commitMount */
|
|
975
|
+
deferredRefs?: Array<{ prop: string; ref: React$1.RefObject<any> }>
|
|
976
|
+
/** Set of props that have been applied via once() */
|
|
977
|
+
appliedOnce?: Set<string>
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
interface HostConfig {
|
|
981
|
+
type: string
|
|
982
|
+
props: Instance['props']
|
|
983
|
+
container: RootStore
|
|
984
|
+
instance: Instance
|
|
985
|
+
textInstance: void
|
|
986
|
+
suspenseInstance: Instance
|
|
987
|
+
hydratableInstance: never
|
|
988
|
+
formInstance: never
|
|
989
|
+
publicInstance: Instance['object']
|
|
990
|
+
hostContext: {}
|
|
991
|
+
childSet: never
|
|
992
|
+
timeoutHandle: number | undefined
|
|
993
|
+
noTimeout: -1
|
|
994
|
+
TransitionStatus: null
|
|
995
|
+
}
|
|
996
|
+
declare global {
|
|
997
|
+
var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
//* Loop Types ==============================
|
|
1001
|
+
|
|
1002
|
+
type GlobalRenderCallback = (timestamp: number) => void
|
|
1003
|
+
|
|
900
1004
|
type GlobalEffectType = 'before' | 'after' | 'tail'
|
|
901
1005
|
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
/**
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
1006
|
+
declare const presetsObj: {
|
|
1007
|
+
apartment: string;
|
|
1008
|
+
city: string;
|
|
1009
|
+
dawn: string;
|
|
1010
|
+
forest: string;
|
|
1011
|
+
lobby: string;
|
|
1012
|
+
night: string;
|
|
1013
|
+
park: string;
|
|
1014
|
+
studio: string;
|
|
1015
|
+
sunset: string;
|
|
1016
|
+
warehouse: string;
|
|
1017
|
+
};
|
|
1018
|
+
type PresetsType = keyof typeof presetsObj;
|
|
1019
|
+
|
|
1020
|
+
//* Background Types ==============================
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* Expanded object form for background configuration.
|
|
1024
|
+
* Allows separate textures for background (visual backdrop) and environment (PBR lighting).
|
|
1025
|
+
*/
|
|
1026
|
+
interface BackgroundConfig {
|
|
1027
|
+
/** HDRI preset name: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse' */
|
|
1028
|
+
preset?: PresetsType
|
|
1029
|
+
/** Files for cube texture (6 faces) or single HDR/EXR */
|
|
1030
|
+
files?: string | string[]
|
|
1031
|
+
/** Separate files for scene.background (visual backdrop) */
|
|
1032
|
+
backgroundMap?: string | string[]
|
|
1033
|
+
backgroundRotation?: Euler$1 | [number, number, number]
|
|
1034
|
+
backgroundBlurriness?: number
|
|
1035
|
+
backgroundIntensity?: number
|
|
1036
|
+
/** Separate files for scene.environment (PBR lighting/reflections) */
|
|
1037
|
+
envMap?: string | string[]
|
|
1038
|
+
environmentRotation?: Euler$1 | [number, number, number]
|
|
1039
|
+
environmentIntensity?: number
|
|
1040
|
+
path?: string
|
|
1041
|
+
extensions?: (loader: Loader) => void
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
/**
|
|
1045
|
+
* Background prop type for Canvas.
|
|
1046
|
+
*
|
|
1047
|
+
* String detection priority:
|
|
1048
|
+
* 1. Preset - exact match against known presets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
|
|
1049
|
+
* 2. URL - starts with /, ./, ../, http://, https://, OR has image extension
|
|
1050
|
+
* 3. Color - default fallback (CSS color names, hex values, rgb(), etc.)
|
|
1051
|
+
*
|
|
1052
|
+
* @example Color
|
|
1053
|
+
* ```tsx
|
|
1054
|
+
* <Canvas background="red" />
|
|
1055
|
+
* <Canvas background="#ff0000" />
|
|
1056
|
+
* <Canvas background={0xff0000} />
|
|
1057
|
+
* ```
|
|
1058
|
+
*
|
|
1059
|
+
* @example Preset
|
|
1060
|
+
* ```tsx
|
|
1061
|
+
* <Canvas background="city" />
|
|
1062
|
+
* ```
|
|
1063
|
+
*
|
|
1064
|
+
* @example URL
|
|
1065
|
+
* ```tsx
|
|
1066
|
+
* <Canvas background="/path/to/env.hdr" />
|
|
1067
|
+
* <Canvas background="./sky.jpg" />
|
|
1068
|
+
* ```
|
|
1069
|
+
*
|
|
1070
|
+
* @example Object form
|
|
1071
|
+
* ```tsx
|
|
1072
|
+
* <Canvas background={{
|
|
1073
|
+
* files: ['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png'],
|
|
1074
|
+
* backgroundMap: 'path/to/sky.jpg',
|
|
1075
|
+
* envMap: 'path/to/lighting.hdr',
|
|
1076
|
+
* backgroundBlurriness: 0.5,
|
|
1077
|
+
* }} />
|
|
1078
|
+
* ```
|
|
1079
|
+
*/
|
|
1080
|
+
type BackgroundProp =
|
|
1081
|
+
| ColorRepresentation // "red", "#ff0000", 0xff0000
|
|
1082
|
+
| string // URL or preset
|
|
1083
|
+
| BackgroundConfig // Expanded object form
|
|
1084
|
+
|
|
1085
|
+
//* Canvas Types ==============================
|
|
1086
|
+
|
|
1087
|
+
interface CanvasProps
|
|
1088
|
+
extends
|
|
1089
|
+
Omit<RenderProps<HTMLCanvasElement>, 'size' | 'primaryCanvas' | 'scheduler'>,
|
|
1090
|
+
React$1.HTMLAttributes<HTMLDivElement> {
|
|
1091
|
+
children?: React$1.ReactNode
|
|
1092
|
+
ref?: React$1.Ref<HTMLCanvasElement>
|
|
1093
|
+
/** Canvas fallback content, similar to img's alt prop */
|
|
1094
|
+
fallback?: React$1.ReactNode
|
|
1095
|
+
/**
|
|
1096
|
+
* Options to pass to useMeasure.
|
|
1097
|
+
* @see https://github.com/pmndrs/react-use-measure#api
|
|
1098
|
+
*/
|
|
1099
|
+
resize?: Options
|
|
1100
|
+
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1101
|
+
eventSource?: HTMLElement | React$1.RefObject<HTMLElement>
|
|
1102
|
+
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1103
|
+
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1104
|
+
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
1105
|
+
hmr?: boolean
|
|
1106
|
+
/** Canvas resolution width in pixels. If omitted, uses container width. */
|
|
1107
|
+
width?: number
|
|
1108
|
+
/** Canvas resolution height in pixels. If omitted, uses container height. */
|
|
1109
|
+
height?: number
|
|
1110
|
+
/** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
|
|
1111
|
+
forceEven?: boolean
|
|
1112
|
+
/**
|
|
1113
|
+
* Scene background configuration.
|
|
1114
|
+
* Accepts colors, URLs, presets, or an expanded object for separate background/environment.
|
|
1115
|
+
* @see BackgroundProp for full documentation and examples
|
|
1116
|
+
*/
|
|
1117
|
+
background?: BackgroundProp
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
//* Loader Types ==============================
|
|
1121
|
+
|
|
1122
|
+
type InputLike = string | string[] | string[][] | Readonly<string | string[] | string[][]>
|
|
1123
|
+
|
|
1124
|
+
// Define a loader-like interface that matches THREE.Loader's load signature
|
|
1125
|
+
// This works for both generic and non-generic THREE.Loader instances
|
|
1126
|
+
interface LoaderLike {
|
|
1127
|
+
load(
|
|
1128
|
+
url: InputLike,
|
|
1129
|
+
onLoad?: (result: any) => void,
|
|
1130
|
+
onProgress?: (event: ProgressEvent<EventTarget>) => void,
|
|
1131
|
+
onError?: (error: unknown) => void,
|
|
1132
|
+
): any
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
type GLTFLike = { scene: THREE$1.Object3D }
|
|
1136
|
+
|
|
1137
|
+
type LoaderInstance<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
|
|
1138
|
+
T extends ConstructorRepresentation<LoaderLike> ? InstanceType<T> : T
|
|
1139
|
+
|
|
1140
|
+
// Infer result type from the load method's callback parameter
|
|
1141
|
+
type InferLoadResult<T> = T extends {
|
|
1142
|
+
load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
|
|
1143
|
+
}
|
|
1144
|
+
? R
|
|
1145
|
+
: T extends ConstructorRepresentation<any>
|
|
1146
|
+
? InstanceType<T> extends {
|
|
1147
|
+
load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
|
|
1148
|
+
}
|
|
1149
|
+
? R
|
|
1150
|
+
: any
|
|
1151
|
+
: any
|
|
1152
|
+
|
|
1153
|
+
type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
|
|
1154
|
+
InferLoadResult<LoaderInstance<T>> extends infer R ? (R extends GLTFLike ? R & ObjectMap : R) : never
|
|
1155
|
+
|
|
1156
|
+
type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (
|
|
1157
|
+
loader: LoaderInstance<T>,
|
|
965
1158
|
) => void
|
|
966
1159
|
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
type
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
1160
|
+
//* Renderer Props ========================================
|
|
1161
|
+
|
|
1162
|
+
type WebGLDefaultProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & BaseRendererProps
|
|
1163
|
+
|
|
1164
|
+
type WebGLProps =
|
|
1165
|
+
| RendererFactory<THREE$1.WebGLRenderer, WebGLDefaultProps>
|
|
1166
|
+
| Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
|
|
1167
|
+
|
|
1168
|
+
interface WebGLShadowConfig {
|
|
1169
|
+
shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
|
|
975
1170
|
}
|
|
976
1171
|
|
|
977
|
-
//*
|
|
978
|
-
|
|
979
|
-
|
|
1172
|
+
//* Legacy-specific Types ========================================
|
|
1173
|
+
|
|
1174
|
+
/** Legacy (WebGL) renderer type - re-exported as R3FRenderer from @react-three/fiber/legacy */
|
|
1175
|
+
type LegacyRenderer = THREE$1.WebGLRenderer
|
|
1176
|
+
|
|
1177
|
+
/** Legacy internal state with narrowed renderer type */
|
|
1178
|
+
interface LegacyInternalState extends Omit<InternalState, 'actualRenderer'> {
|
|
1179
|
+
actualRenderer: THREE$1.WebGLRenderer
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
/**
|
|
1183
|
+
* Legacy-specific RootState with narrowed renderer type.
|
|
1184
|
+
* Automatically used when importing from `@react-three/fiber/legacy`.
|
|
1185
|
+
*
|
|
1186
|
+
* @example
|
|
1187
|
+
* ```tsx
|
|
1188
|
+
* import { useThree } from '@react-three/fiber/legacy'
|
|
1189
|
+
*
|
|
1190
|
+
* function MyComponent() {
|
|
1191
|
+
* const { renderer } = useThree()
|
|
1192
|
+
* // renderer is typed as THREE.WebGLRenderer
|
|
1193
|
+
* renderer.shadowMap.enabled = true
|
|
1194
|
+
* }
|
|
1195
|
+
* ```
|
|
1196
|
+
*/
|
|
1197
|
+
interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
1198
|
+
/** The WebGL renderer instance */
|
|
1199
|
+
renderer: THREE$1.WebGLRenderer
|
|
1200
|
+
/** Internals with WebGL renderer */
|
|
1201
|
+
internal: LegacyInternalState
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
//* RenderTarget Types ==============================
|
|
1205
|
+
|
|
1206
|
+
|
|
980
1207
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
981
1208
|
|
|
982
|
-
//* Global Types ==============================
|
|
983
|
-
|
|
984
|
-
declare global {
|
|
985
|
-
/** Uniform node type - a Node with a value property (matches Three.js UniformNode) */
|
|
986
|
-
interface UniformNode<T = unknown> extends Node {
|
|
987
|
-
value: T
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
/**
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
*
|
|
995
|
-
*
|
|
996
|
-
*
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
*
|
|
1002
|
-
*
|
|
1003
|
-
*
|
|
1004
|
-
*
|
|
1005
|
-
*
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
*
|
|
1042
|
-
*
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
*
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
/**
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
/**
|
|
1153
|
-
|
|
1154
|
-
/**
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
//
|
|
1173
|
-
|
|
1174
|
-
/**
|
|
1175
|
-
* Internal
|
|
1176
|
-
*/
|
|
1177
|
-
interface
|
|
1178
|
-
/**
|
|
1179
|
-
|
|
1180
|
-
/**
|
|
1181
|
-
|
|
1182
|
-
/**
|
|
1183
|
-
|
|
1184
|
-
/**
|
|
1185
|
-
|
|
1186
|
-
/**
|
|
1187
|
-
|
|
1188
|
-
/**
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
/**
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
*
|
|
1218
|
-
*/
|
|
1219
|
-
interface
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
:
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
interface
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1209
|
+
//* Global Types ==============================
|
|
1210
|
+
|
|
1211
|
+
declare global {
|
|
1212
|
+
/** Uniform node type - a Node with a value property (matches Three.js UniformNode) */
|
|
1213
|
+
interface UniformNode<T = unknown> extends Node {
|
|
1214
|
+
value: T
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
/**
|
|
1218
|
+
* ShaderCallable - the return type of Fn()
|
|
1219
|
+
* A callable shader function node that can be invoked with parameters.
|
|
1220
|
+
* The function returns a ShaderNodeObject when called.
|
|
1221
|
+
*
|
|
1222
|
+
* @example
|
|
1223
|
+
* ```tsx
|
|
1224
|
+
* // Define a shader function
|
|
1225
|
+
* const blendColorFn = Fn(([color1, color2, factor]) => {
|
|
1226
|
+
* return mix(color1, color2, factor)
|
|
1227
|
+
* })
|
|
1228
|
+
*
|
|
1229
|
+
* // Type when retrieving from nodes store
|
|
1230
|
+
* const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
|
|
1231
|
+
*
|
|
1232
|
+
* // Or with specific return type
|
|
1233
|
+
* const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
|
|
1234
|
+
* ```
|
|
1235
|
+
*/
|
|
1236
|
+
type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
|
|
1237
|
+
|
|
1238
|
+
/**
|
|
1239
|
+
* ShaderNodeRef - a ShaderNodeObject wrapper around a Node
|
|
1240
|
+
* This is the common return type for TSL operations (add, mul, sin, etc.)
|
|
1241
|
+
*
|
|
1242
|
+
* @example
|
|
1243
|
+
* ```tsx
|
|
1244
|
+
* const { wobble } = nodes as { wobble: ShaderNodeRef }
|
|
1245
|
+
* ```
|
|
1246
|
+
*/
|
|
1247
|
+
type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
|
|
1248
|
+
|
|
1249
|
+
/**
|
|
1250
|
+
* TSLNodeType - Union of all common TSL node types
|
|
1251
|
+
* Used by ScopedStore to properly type node access from the store.
|
|
1252
|
+
*
|
|
1253
|
+
* Includes:
|
|
1254
|
+
* - Node: base Three.js node type
|
|
1255
|
+
* - ShaderCallable: function nodes created with Fn()
|
|
1256
|
+
* - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
|
|
1257
|
+
*
|
|
1258
|
+
* @example
|
|
1259
|
+
* ```tsx
|
|
1260
|
+
* // In useLocalNodes, nodes are typed as TSLNodeType
|
|
1261
|
+
* const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
|
|
1262
|
+
* positionNode: nodes.myPosition, // Works - Node is in union
|
|
1263
|
+
* blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
|
|
1264
|
+
* }))
|
|
1265
|
+
*
|
|
1266
|
+
* // Can narrow with type guard or assertion when needed
|
|
1267
|
+
* if (typeof blendColorFn === 'function') {
|
|
1268
|
+
* blendColorFn(someColor, 0.5)
|
|
1269
|
+
* }
|
|
1270
|
+
* ```
|
|
1271
|
+
*/
|
|
1272
|
+
type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
|
|
1273
|
+
|
|
1274
|
+
/** Flat record of uniform nodes (no nested scopes) */
|
|
1275
|
+
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Uniform store that can contain both root-level uniforms and scoped uniform objects
|
|
1279
|
+
* Used by state.uniforms which has structure like:
|
|
1280
|
+
* { uTime: UniformNode, player: { uHealth: UniformNode }, enemy: { uHealth: UniformNode } }
|
|
1281
|
+
*/
|
|
1282
|
+
type UniformStore = Record<string, UniformNode | UniformRecord>
|
|
1283
|
+
|
|
1284
|
+
/**
|
|
1285
|
+
* Helper to safely access a uniform node from the store.
|
|
1286
|
+
* Use this when accessing state.uniforms to get proper typing.
|
|
1287
|
+
* @example
|
|
1288
|
+
* const uTime = uniforms.uTime as UniformNode<number>
|
|
1289
|
+
* const uColor = uniforms.uColor as UniformNode<import('three/webgpu').Color>
|
|
1290
|
+
*/
|
|
1291
|
+
type GetUniform<T = unknown> = UniformNode<T>
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1295
|
+
* Supports:
|
|
1296
|
+
* - Primitives: number, string (color), boolean
|
|
1297
|
+
* - Three.js types: Color, Vector2/3/4, Matrix3/4, Euler, Quaternion
|
|
1298
|
+
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1299
|
+
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1300
|
+
* - UniformNode: existing uniforms (reused as-is)
|
|
1301
|
+
*/
|
|
1302
|
+
type UniformValue =
|
|
1303
|
+
| number
|
|
1304
|
+
| string
|
|
1305
|
+
| boolean
|
|
1306
|
+
| three_webgpu.Color
|
|
1307
|
+
| three_webgpu.Vector2
|
|
1308
|
+
| three_webgpu.Vector3
|
|
1309
|
+
| three_webgpu.Vector4
|
|
1310
|
+
| three_webgpu.Matrix3
|
|
1311
|
+
| three_webgpu.Matrix4
|
|
1312
|
+
| three_webgpu.Euler
|
|
1313
|
+
| three_webgpu.Quaternion
|
|
1314
|
+
| { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
|
|
1315
|
+
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1316
|
+
| UniformNode
|
|
1317
|
+
|
|
1318
|
+
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1319
|
+
type UniformInputRecord = Record<string, UniformValue>
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
//* Module Augmentation ==============================
|
|
1323
|
+
|
|
1324
|
+
declare module 'three/tsl' {
|
|
1325
|
+
/**
|
|
1326
|
+
* Fn with array parameter destructuring
|
|
1327
|
+
* @example Fn(([uv, skew]) => { ... })
|
|
1328
|
+
*/
|
|
1329
|
+
export function Fn<R extends Node = Node>(
|
|
1330
|
+
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1331
|
+
): ShaderCallable<R>
|
|
1332
|
+
|
|
1333
|
+
/**
|
|
1334
|
+
* Fn with object parameter destructuring
|
|
1335
|
+
* @example Fn(({ color, intensity }) => { ... })
|
|
1336
|
+
*/
|
|
1337
|
+
export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
|
|
1338
|
+
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1339
|
+
): ShaderCallable<R>
|
|
1340
|
+
|
|
1341
|
+
/**
|
|
1342
|
+
* Fn with array params + layout
|
|
1343
|
+
* @example Fn(([a, b]) => { ... }, { layout: [...] })
|
|
1344
|
+
*/
|
|
1345
|
+
export function Fn<R extends Node = Node>(
|
|
1346
|
+
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1347
|
+
layout: { layout?: unknown },
|
|
1348
|
+
): ShaderCallable<R>
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* Fn with object params + layout
|
|
1352
|
+
*/
|
|
1353
|
+
export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
|
|
1354
|
+
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1355
|
+
layout: { layout?: unknown },
|
|
1356
|
+
): ShaderCallable<R>
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
/**
|
|
1360
|
+
* PostProcessing Types for usePostProcessing hook (WebGPU only)
|
|
1361
|
+
*/
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
declare global {
|
|
1366
|
+
/** Pass record - stores TSL pass nodes for post-processing */
|
|
1367
|
+
type PassRecord = Record<string, any>
|
|
1368
|
+
|
|
1369
|
+
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1370
|
+
type PostProcessingSetupCallback = (state: RootState) => PassRecord | void
|
|
1371
|
+
|
|
1372
|
+
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1373
|
+
type PostProcessingMainCallback = (state: RootState) => PassRecord | void
|
|
1374
|
+
|
|
1375
|
+
/** Return type for usePostProcessing hook */
|
|
1376
|
+
interface UsePostProcessingReturn {
|
|
1377
|
+
/** Current passes from state */
|
|
1378
|
+
passes: PassRecord
|
|
1379
|
+
/** PostProcessing instance (null if not initialized) */
|
|
1380
|
+
postProcessing: any | null // THREE.PostProcessing
|
|
1381
|
+
/** Clear all passes from state */
|
|
1382
|
+
clearPasses: () => void
|
|
1383
|
+
/** Reset PostProcessing entirely (clears PP + passes) */
|
|
1384
|
+
reset: () => void
|
|
1385
|
+
/** Re-run setup/main callbacks with current closure values */
|
|
1386
|
+
rebuild: () => void
|
|
1387
|
+
/** True when PostProcessing is configured and ready */
|
|
1388
|
+
isReady: boolean
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
//* useFrameNext Types ==============================
|
|
1393
|
+
|
|
1394
|
+
|
|
1395
|
+
|
|
1396
|
+
//* Global Type Declarations ==============================
|
|
1397
|
+
|
|
1398
|
+
declare global {
|
|
1399
|
+
// Job --------------------------------
|
|
1400
|
+
|
|
1401
|
+
/**
|
|
1402
|
+
* Internal job representation in the scheduler
|
|
1403
|
+
*/
|
|
1404
|
+
interface Job {
|
|
1405
|
+
/** Unique identifier */
|
|
1406
|
+
id: string
|
|
1407
|
+
/** The callback to execute */
|
|
1408
|
+
callback: FrameNextCallback
|
|
1409
|
+
/** Phase this job belongs to */
|
|
1410
|
+
phase: string
|
|
1411
|
+
/** Run before these phases/job ids */
|
|
1412
|
+
before: Set<string>
|
|
1413
|
+
/** Run after these phases/job ids */
|
|
1414
|
+
after: Set<string>
|
|
1415
|
+
/** Priority within phase (higher first) */
|
|
1416
|
+
priority: number
|
|
1417
|
+
/** Insertion order for deterministic tie-breaking */
|
|
1418
|
+
index: number
|
|
1419
|
+
/** Max FPS for this job (undefined = no limit) */
|
|
1420
|
+
fps?: number
|
|
1421
|
+
/** Drop frames when behind (true) or catch up (false) */
|
|
1422
|
+
drop: boolean
|
|
1423
|
+
/** Last run timestamp (ms) */
|
|
1424
|
+
lastRun?: number
|
|
1425
|
+
/** Whether job is enabled */
|
|
1426
|
+
enabled: boolean
|
|
1427
|
+
/** Internal flag: system jobs (like default render) don't block user render takeover */
|
|
1428
|
+
system?: boolean
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
// Phase Graph --------------------------------
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* A node in the phase graph
|
|
1435
|
+
*/
|
|
1436
|
+
interface PhaseNode {
|
|
1437
|
+
/** Phase name */
|
|
1438
|
+
name: string
|
|
1439
|
+
/** Whether this was auto-generated from a before/after constraint */
|
|
1440
|
+
isAutoGenerated: boolean
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
/**
|
|
1444
|
+
* Options for creating a job from hook options
|
|
1445
|
+
*/
|
|
1446
|
+
interface JobOptions {
|
|
1447
|
+
id?: string
|
|
1448
|
+
phase?: string
|
|
1449
|
+
before?: string | string[]
|
|
1450
|
+
after?: string | string[]
|
|
1451
|
+
priority?: number
|
|
1452
|
+
fps?: number
|
|
1453
|
+
drop?: boolean
|
|
1454
|
+
enabled?: boolean
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
// Frame Loop State --------------------------------
|
|
1458
|
+
|
|
1459
|
+
/**
|
|
1460
|
+
* Internal frame loop state
|
|
1461
|
+
*/
|
|
1462
|
+
interface FrameLoopState {
|
|
1463
|
+
/** Whether the loop is running */
|
|
1464
|
+
running: boolean
|
|
1465
|
+
/** Current RAF handle */
|
|
1466
|
+
rafHandle: number | null
|
|
1467
|
+
/** Last frame timestamp in ms (null = uninitialized) */
|
|
1468
|
+
lastTime: number | null
|
|
1469
|
+
/** Frame counter */
|
|
1470
|
+
frameCount: number
|
|
1471
|
+
/** Elapsed time since first frame in ms */
|
|
1472
|
+
elapsedTime: number
|
|
1473
|
+
/** createdAt timestamp in ms */
|
|
1474
|
+
createdAt: number
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
// Root Entry --------------------------------
|
|
1478
|
+
|
|
1479
|
+
/**
|
|
1480
|
+
* Internal representation of a registered root (Canvas).
|
|
1481
|
+
* Tracks jobs and manages rebuild state for this root.
|
|
1482
|
+
* @internal
|
|
1483
|
+
*/
|
|
1484
|
+
interface RootEntry {
|
|
1485
|
+
/** Unique identifier for this root */
|
|
1486
|
+
id: string
|
|
1487
|
+
/** Function to get the root's current state. Returns any to support independent mode. */
|
|
1488
|
+
getState: () => any
|
|
1489
|
+
/** Map of job IDs to Job objects */
|
|
1490
|
+
jobs: Map<string, Job>
|
|
1491
|
+
/** Cached sorted job list for execution order */
|
|
1492
|
+
sortedJobs: Job[]
|
|
1493
|
+
/** Whether sortedJobs needs rebuilding */
|
|
1494
|
+
needsRebuild: boolean
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
/**
|
|
1498
|
+
* Internal representation of a global job (deprecated API).
|
|
1499
|
+
* Global jobs run once per frame, not per-root.
|
|
1500
|
+
* Used by legacy addEffect/addAfterEffect APIs.
|
|
1501
|
+
* @internal
|
|
1502
|
+
* @deprecated Use useFrame with phases instead
|
|
1503
|
+
*/
|
|
1504
|
+
interface GlobalJob {
|
|
1505
|
+
/** Unique identifier for this global job */
|
|
1506
|
+
id: string
|
|
1507
|
+
/** Callback invoked with RAF timestamp in ms */
|
|
1508
|
+
callback: (timestamp: number) => void
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
// HMR Support --------------------------------
|
|
1512
|
+
|
|
1513
|
+
/**
|
|
1514
|
+
* Hot Module Replacement data structure for preserving scheduler state
|
|
1515
|
+
* @internal
|
|
1516
|
+
*/
|
|
1517
|
+
interface HMRData {
|
|
1518
|
+
/** Shared data object for storing values across reloads */
|
|
1519
|
+
data: Record<string, any>
|
|
1520
|
+
/** Optional function to accept HMR updates */
|
|
1521
|
+
accept?: () => void
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
// Default Phases --------------------------------
|
|
1525
|
+
|
|
1526
|
+
/**
|
|
1527
|
+
* Default phase names for the scheduler
|
|
1528
|
+
*/
|
|
1529
|
+
type DefaultPhase = 'start' | 'input' | 'physics' | 'update' | 'render' | 'finish'
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
1533
|
+
|
|
1534
|
+
interface MathRepresentation {
|
|
1535
|
+
set(...args: number[]): any
|
|
1536
|
+
}
|
|
1537
|
+
interface VectorRepresentation extends MathRepresentation {
|
|
1538
|
+
setScalar(value: number): any
|
|
1539
|
+
}
|
|
1540
|
+
type MathTypes = MathRepresentation | Euler$2 | Color$2
|
|
1541
|
+
|
|
1542
|
+
type MathType<T extends MathTypes> = T extends Color$2
|
|
1543
|
+
? Args<typeof Color$2> | ColorRepresentation$1
|
|
1544
|
+
: T extends VectorRepresentation | Layers$1 | Euler$2
|
|
1545
|
+
? T | MutableOrReadonlyParameters<T['set']> | number
|
|
1546
|
+
: T | MutableOrReadonlyParameters<T['set']>
|
|
1547
|
+
|
|
1548
|
+
type MathProps<P> = {
|
|
1549
|
+
[K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
type Vector2 = MathType<Vector2$1>
|
|
1553
|
+
type Vector3 = MathType<Vector3$1>
|
|
1554
|
+
type Vector4 = MathType<Vector4$1>
|
|
1555
|
+
type Color = MathType<Color$2>
|
|
1556
|
+
type Layers = MathType<Layers$1>
|
|
1557
|
+
type Quaternion = MathType<Quaternion$1>
|
|
1558
|
+
type Euler = MathType<Euler$2>
|
|
1559
|
+
type Matrix3 = MathType<Matrix3$1>
|
|
1560
|
+
type Matrix4 = MathType<Matrix4$1>
|
|
1561
|
+
|
|
1562
|
+
interface RaycastableRepresentation {
|
|
1563
|
+
raycast(raycaster: Raycaster, intersects: Intersection$1[]): void
|
|
1564
|
+
}
|
|
1565
|
+
type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
|
|
1566
|
+
|
|
1567
|
+
/**
|
|
1568
|
+
* Props for geometry transform methods that can be called with `once()`.
|
|
1569
|
+
* These methods modify the geometry in-place and only make sense to call once on mount.
|
|
1570
|
+
*
|
|
1571
|
+
* @example
|
|
1572
|
+
* import { once } from '@react-three/fiber'
|
|
1573
|
+
*
|
|
1574
|
+
* <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
|
|
1575
|
+
* <planeGeometry args={[10, 10]} translate={once(0, 0, 5)} />
|
|
1576
|
+
* <bufferGeometry applyMatrix4={once(matrix)} center={once()} />
|
|
1577
|
+
*/
|
|
1578
|
+
interface GeometryTransformProps {
|
|
1579
|
+
/** Rotate the geometry about the X axis (radians). Use with once(). */
|
|
1580
|
+
rotateX?: number
|
|
1581
|
+
/** Rotate the geometry about the Y axis (radians). Use with once(). */
|
|
1582
|
+
rotateY?: number
|
|
1583
|
+
/** Rotate the geometry about the Z axis (radians). Use with once(). */
|
|
1584
|
+
rotateZ?: number
|
|
1585
|
+
/** Translate the geometry (x, y, z). Use with once(). */
|
|
1586
|
+
translate?: [x: number, y: number, z: number]
|
|
1587
|
+
/** Scale the geometry (x, y, z). Use with once(). */
|
|
1588
|
+
scale?: [x: number, y: number, z: number]
|
|
1589
|
+
/** Center the geometry based on bounding box. Use with once(). */
|
|
1590
|
+
center?: true
|
|
1591
|
+
/** Apply a Matrix4 transformation. Use with once(). */
|
|
1592
|
+
applyMatrix4?: Matrix4$1
|
|
1593
|
+
/** Apply a Quaternion rotation. Use with once(). */
|
|
1594
|
+
applyQuaternion?: Quaternion$1
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
type GeometryProps<P> = P extends BufferGeometry ? GeometryTransformProps : {}
|
|
1598
|
+
|
|
1599
|
+
/**
|
|
1600
|
+
* Workaround for @types/three TSL node type issues.
|
|
1601
|
+
* The Node base class has properties that subclasses (OperatorNode, ConstNode, etc.) don't inherit.
|
|
1602
|
+
* This transforms `Node | null` properties to accept any object with node-like shape.
|
|
1603
|
+
*/
|
|
1604
|
+
type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
1605
|
+
|
|
1606
|
+
/**
|
|
1607
|
+
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1608
|
+
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1609
|
+
*/
|
|
1610
|
+
type NodeProps<P> = {
|
|
1611
|
+
[K in keyof P as P[K] extends Node | null ? K : never]?: TSLNodeInput
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
interface ReactProps<P> {
|
|
1615
|
+
children?: React.ReactNode
|
|
1616
|
+
ref?: React.Ref<P>
|
|
1617
|
+
key?: React.Key
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
|
|
1621
|
+
Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P> & GeometryProps<P> & NodeProps<P>>
|
|
1622
|
+
>
|
|
1623
|
+
|
|
1624
|
+
type ThreeElement<T extends ConstructorRepresentation> = Mutable<
|
|
1625
|
+
Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
|
|
1626
|
+
>
|
|
1627
|
+
|
|
1628
|
+
type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
1629
|
+
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
type ThreeExports = typeof THREE
|
|
1633
|
+
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1634
|
+
|
|
1635
|
+
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1636
|
+
primitive: Omit<ThreeElement<any>, 'args'> & { object: object }
|
|
1637
|
+
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1638
|
+
threeAudio: ThreeElementsImpl['audio']
|
|
1639
|
+
threeSource: ThreeElementsImpl['source']
|
|
1640
|
+
threeLine: ThreeElementsImpl['line']
|
|
1641
|
+
threePath: ThreeElementsImpl['path']
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
declare module 'react' {
|
|
1645
|
+
namespace JSX {
|
|
1646
|
+
interface IntrinsicElements extends ThreeElements {}
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
declare module 'react/jsx-runtime' {
|
|
1651
|
+
namespace JSX {
|
|
1652
|
+
interface IntrinsicElements extends ThreeElements {}
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
declare module 'react/jsx-dev-runtime' {
|
|
1657
|
+
namespace JSX {
|
|
1658
|
+
interface IntrinsicElements extends ThreeElements {}
|
|
1659
|
+
}
|
|
1328
1660
|
}
|
|
1329
1661
|
|
|
1330
1662
|
type three_d_Color = Color;
|
|
1331
1663
|
type three_d_ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = ElementProps<T, P>;
|
|
1332
1664
|
type three_d_Euler = Euler;
|
|
1333
1665
|
type three_d_EventProps<P> = EventProps<P>;
|
|
1666
|
+
type three_d_GeometryProps<P> = GeometryProps<P>;
|
|
1667
|
+
type three_d_GeometryTransformProps = GeometryTransformProps;
|
|
1334
1668
|
type three_d_Layers = Layers;
|
|
1335
1669
|
type three_d_MathProps<P> = MathProps<P>;
|
|
1336
1670
|
type three_d_MathRepresentation = MathRepresentation;
|
|
@@ -1339,9 +1673,11 @@ type three_d_MathTypes = MathTypes;
|
|
|
1339
1673
|
type three_d_Matrix3 = Matrix3;
|
|
1340
1674
|
type three_d_Matrix4 = Matrix4;
|
|
1341
1675
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1676
|
+
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1342
1677
|
type three_d_Quaternion = Quaternion;
|
|
1343
1678
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1344
1679
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
1680
|
+
type three_d_TSLNodeInput = TSLNodeInput;
|
|
1345
1681
|
type three_d_ThreeElement<T extends ConstructorRepresentation> = ThreeElement<T>;
|
|
1346
1682
|
type three_d_ThreeElements = ThreeElements;
|
|
1347
1683
|
type three_d_ThreeElementsImpl = ThreeElementsImpl;
|
|
@@ -1352,8 +1688,318 @@ type three_d_Vector3 = Vector3;
|
|
|
1352
1688
|
type three_d_Vector4 = Vector4;
|
|
1353
1689
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1354
1690
|
declare namespace three_d {
|
|
1355
|
-
export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
|
|
1691
|
+
export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
/**
|
|
1695
|
+
* @fileoverview Registry for primary canvases that can be targeted by secondary canvases
|
|
1696
|
+
*
|
|
1697
|
+
* Enables multi-canvas WebGPU rendering where multiple Canvas components share
|
|
1698
|
+
* a single WebGPURenderer using Three.js CanvasTarget API.
|
|
1699
|
+
*
|
|
1700
|
+
* Primary canvas: Has `id` prop, creates its own renderer, registers here
|
|
1701
|
+
* Secondary canvas: Has `target="id"` prop, shares primary's renderer via CanvasTarget
|
|
1702
|
+
*/
|
|
1703
|
+
|
|
1704
|
+
interface PrimaryCanvasEntry {
|
|
1705
|
+
/** The WebGPURenderer instance owned by this primary canvas */
|
|
1706
|
+
renderer: WebGPURenderer;
|
|
1707
|
+
/** The zustand store for this canvas */
|
|
1708
|
+
store: RootStore;
|
|
1709
|
+
}
|
|
1710
|
+
/**
|
|
1711
|
+
* Register a primary canvas that can be targeted by secondary canvases.
|
|
1712
|
+
*
|
|
1713
|
+
* @param id - Unique identifier for this primary canvas
|
|
1714
|
+
* @param renderer - The WebGPURenderer owned by this canvas
|
|
1715
|
+
* @param store - The zustand store for this canvas
|
|
1716
|
+
* @returns Cleanup function to unregister on unmount
|
|
1717
|
+
*/
|
|
1718
|
+
declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore): () => void;
|
|
1719
|
+
/**
|
|
1720
|
+
* Get a registered primary canvas by id.
|
|
1721
|
+
*
|
|
1722
|
+
* @param id - The id of the primary canvas to look up
|
|
1723
|
+
* @returns The primary canvas entry or undefined if not found
|
|
1724
|
+
*/
|
|
1725
|
+
declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
|
|
1726
|
+
/**
|
|
1727
|
+
* Wait for a primary canvas to be registered.
|
|
1728
|
+
* Returns immediately if already registered, otherwise waits.
|
|
1729
|
+
*
|
|
1730
|
+
* @param id - The id of the primary canvas to wait for
|
|
1731
|
+
* @param timeout - Optional timeout in ms (default: 5000)
|
|
1732
|
+
* @returns Promise that resolves with the primary canvas entry
|
|
1733
|
+
*/
|
|
1734
|
+
declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
|
|
1735
|
+
/**
|
|
1736
|
+
* Check if a primary canvas with the given id exists.
|
|
1737
|
+
*
|
|
1738
|
+
* @param id - The id to check
|
|
1739
|
+
* @returns True if a primary canvas with this id is registered
|
|
1740
|
+
*/
|
|
1741
|
+
declare function hasPrimary(id: string): boolean;
|
|
1742
|
+
/**
|
|
1743
|
+
* Unregister a primary canvas. Called on unmount.
|
|
1744
|
+
*
|
|
1745
|
+
* @param id - The id of the primary canvas to unregister
|
|
1746
|
+
*/
|
|
1747
|
+
declare function unregisterPrimary(id: string): void;
|
|
1748
|
+
/**
|
|
1749
|
+
* Get all registered primary canvas ids. Useful for debugging.
|
|
1750
|
+
*/
|
|
1751
|
+
declare function getPrimaryIds(): string[];
|
|
1752
|
+
|
|
1753
|
+
type EnvironmentLoaderProps = {
|
|
1754
|
+
files?: string | string[];
|
|
1755
|
+
path?: string;
|
|
1756
|
+
preset?: PresetsType;
|
|
1757
|
+
extensions?: (loader: Loader$1) => void;
|
|
1758
|
+
colorSpace?: ColorSpace;
|
|
1759
|
+
};
|
|
1760
|
+
/**
|
|
1761
|
+
* Loads environment textures for reflections and lighting.
|
|
1762
|
+
* Supports HDR files, presets, and cubemaps.
|
|
1763
|
+
*
|
|
1764
|
+
* @example Basic usage
|
|
1765
|
+
* ```jsx
|
|
1766
|
+
* const texture = useEnvironment({ preset: 'sunset' })
|
|
1767
|
+
* ```
|
|
1768
|
+
*/
|
|
1769
|
+
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown> | CubeTexture;
|
|
1770
|
+
declare namespace useEnvironment {
|
|
1771
|
+
var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
|
|
1772
|
+
var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
|
|
1773
|
+
}
|
|
1774
|
+
type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'encoding'>;
|
|
1775
|
+
type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
|
|
1776
|
+
|
|
1777
|
+
/**
|
|
1778
|
+
* Props for Environment component that sets up global cubemap for PBR materials and backgrounds.
|
|
1779
|
+
*
|
|
1780
|
+
* @property children - React children to render into custom environment portal
|
|
1781
|
+
* @property frames - Number of frames to render the environment. Use 1 for static, Infinity for animated (default: 1)
|
|
1782
|
+
* @property near - Near clipping plane for cube camera (default: 0.1)
|
|
1783
|
+
* @property far - Far clipping plane for cube camera (default: 1000)
|
|
1784
|
+
* @property resolution - Resolution of the cube render target (default: 256)
|
|
1785
|
+
* @property background - Whether to set scene.background. Can be true, false, or "only" (which only sets background) (default: false)
|
|
1786
|
+
*
|
|
1787
|
+
* @property blur - @deprecated Use backgroundBlurriness instead
|
|
1788
|
+
* @property backgroundBlurriness - Blur factor between 0 and 1 for background (default: 0, requires three.js 0.146+)
|
|
1789
|
+
* @property backgroundIntensity - Intensity factor for background (default: 1, requires three.js 0.163+)
|
|
1790
|
+
* @property backgroundRotation - Rotation for background as Euler angles (default: [0,0,0], requires three.js 0.163+)
|
|
1791
|
+
* @property environmentIntensity - Intensity factor for environment lighting (default: 1, requires three.js 0.163+)
|
|
1792
|
+
* @property environmentRotation - Rotation for environment as Euler angles (default: [0,0,0], requires three.js 0.163+)
|
|
1793
|
+
*
|
|
1794
|
+
* @property map - Pre-existing texture to use as environment map
|
|
1795
|
+
* @property preset - HDRI Haven preset: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse'. Not for production use.
|
|
1796
|
+
* @property scene - Custom THREE.Scene or ref to apply environment to (default: uses default scene)
|
|
1797
|
+
* @property ground - Ground projection settings. Use true for defaults or object with:
|
|
1798
|
+
* - height: Height of camera used to create env map (default: 15)
|
|
1799
|
+
* - radius: Radius of the world (default: 60)
|
|
1800
|
+
* - scale: Scale of backside projected sphere (default: 1000)
|
|
1801
|
+
*
|
|
1802
|
+
* Additional loader props:
|
|
1803
|
+
* @property files - File path(s) for environment. Supports .hdr, .exr, gainmap .jpg/.webp, or array of 6 cube faces
|
|
1804
|
+
* @property path - Base path for file loading
|
|
1805
|
+
* @property extensions - Texture extensions override
|
|
1806
|
+
*/
|
|
1807
|
+
type EnvironmentProps = {
|
|
1808
|
+
children?: React$1.ReactNode;
|
|
1809
|
+
frames?: number;
|
|
1810
|
+
near?: number;
|
|
1811
|
+
far?: number;
|
|
1812
|
+
resolution?: number;
|
|
1813
|
+
background?: boolean | 'only';
|
|
1814
|
+
/** deprecated, use backgroundBlurriness */
|
|
1815
|
+
blur?: number;
|
|
1816
|
+
backgroundBlurriness?: number;
|
|
1817
|
+
backgroundIntensity?: number;
|
|
1818
|
+
backgroundRotation?: Euler$3;
|
|
1819
|
+
environmentIntensity?: number;
|
|
1820
|
+
environmentRotation?: Euler$3;
|
|
1821
|
+
map?: Texture$1;
|
|
1822
|
+
preset?: PresetsType;
|
|
1823
|
+
scene?: Scene | React$1.RefObject<Scene>;
|
|
1824
|
+
ground?: boolean | {
|
|
1825
|
+
radius?: number;
|
|
1826
|
+
height?: number;
|
|
1827
|
+
scale?: number;
|
|
1828
|
+
};
|
|
1829
|
+
/** Solid color for background (alternative to files/preset) */
|
|
1830
|
+
color?: ColorRepresentation$1;
|
|
1831
|
+
/** Separate files for background (when different from environment files) */
|
|
1832
|
+
backgroundFiles?: string | string[];
|
|
1833
|
+
} & EnvironmentLoaderProps;
|
|
1834
|
+
/**
|
|
1835
|
+
* Internal component that applies a pre-existing texture as environment map.
|
|
1836
|
+
* Sets scene.environment and optionally scene.background.
|
|
1837
|
+
*
|
|
1838
|
+
* @example
|
|
1839
|
+
* ```jsx
|
|
1840
|
+
* <CubeCamera>{(texture) => <EnvironmentMap map={texture} />}</CubeCamera>
|
|
1841
|
+
* ```
|
|
1842
|
+
*/
|
|
1843
|
+
declare function EnvironmentMap({ scene, background, map, ...config }: EnvironmentProps): null;
|
|
1844
|
+
/**
|
|
1845
|
+
* Internal component that loads environment textures from files or presets.
|
|
1846
|
+
* Uses HDRLoader for .hdr, EXRLoader for .exr, UltraHDRLoader for .jpg/.jpeg HDR,
|
|
1847
|
+
* GainMapLoader for gainmap .webp, or CubeTextureLoader for arrays of images.
|
|
1848
|
+
*
|
|
1849
|
+
* @example With preset
|
|
1850
|
+
* ```jsx
|
|
1851
|
+
* <EnvironmentCube preset="sunset" />
|
|
1852
|
+
* ```
|
|
1853
|
+
*
|
|
1854
|
+
* @example From HDR file
|
|
1855
|
+
* ```jsx
|
|
1856
|
+
* <EnvironmentCube files="environment.hdr" />
|
|
1857
|
+
* ```
|
|
1858
|
+
*
|
|
1859
|
+
* @example From gainmap (smallest footprint)
|
|
1860
|
+
* ```jsx
|
|
1861
|
+
* <EnvironmentCube files={['file.webp', 'file-gainmap.webp', 'file.json']} />
|
|
1862
|
+
* ```
|
|
1863
|
+
*
|
|
1864
|
+
* @example From cube faces
|
|
1865
|
+
* ```jsx
|
|
1866
|
+
* <EnvironmentCube files={['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png']} />
|
|
1867
|
+
* ```
|
|
1868
|
+
*/
|
|
1869
|
+
declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, ...rest }: EnvironmentProps): null;
|
|
1870
|
+
/**
|
|
1871
|
+
* Internal component that renders custom environment using a portal and cube camera.
|
|
1872
|
+
* Renders children into an off-buffer and films with a cube camera to create environment map.
|
|
1873
|
+
* Can be static (frames=1) or animated (frames=Infinity).
|
|
1874
|
+
*
|
|
1875
|
+
* @example Custom environment with sphere
|
|
1876
|
+
* ```jsx
|
|
1877
|
+
* <EnvironmentPortal background near={1} far={1000} resolution={256}>
|
|
1878
|
+
* <mesh scale={100}>
|
|
1879
|
+
* <sphereGeometry args={[1, 64, 64]} />
|
|
1880
|
+
* <meshBasicMaterial map={texture} side={THREE.BackSide} />
|
|
1881
|
+
* </mesh>
|
|
1882
|
+
* </EnvironmentPortal>
|
|
1883
|
+
* ```
|
|
1884
|
+
*
|
|
1885
|
+
* @example Animated environment
|
|
1886
|
+
* ```jsx
|
|
1887
|
+
* <EnvironmentPortal frames={Infinity} resolution={256}>
|
|
1888
|
+
* <Float>
|
|
1889
|
+
* <mesh />
|
|
1890
|
+
* </Float>
|
|
1891
|
+
* </EnvironmentPortal>
|
|
1892
|
+
* ```
|
|
1893
|
+
*
|
|
1894
|
+
* @example Mixed with preset
|
|
1895
|
+
* ```jsx
|
|
1896
|
+
* <EnvironmentPortal preset="warehouse">
|
|
1897
|
+
* <mesh />
|
|
1898
|
+
* </EnvironmentPortal>
|
|
1899
|
+
* ```
|
|
1900
|
+
*/
|
|
1901
|
+
declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, scene, files, path, preset, extensions, }: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
1902
|
+
declare module '@react-three/fiber' {
|
|
1903
|
+
interface ThreeElements {
|
|
1904
|
+
groundProjectedEnvImpl: ThreeElement$1<typeof GroundedSkybox>;
|
|
1905
|
+
}
|
|
1356
1906
|
}
|
|
1907
|
+
/**
|
|
1908
|
+
* Sets up a global environment map for PBR materials and backgrounds.
|
|
1909
|
+
* Affects scene.environment and optionally scene.background unless a custom scene is passed.
|
|
1910
|
+
*
|
|
1911
|
+
* Supports multiple input methods:
|
|
1912
|
+
* - **Presets**: Selection of HDRI Haven assets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
|
|
1913
|
+
* - **Files**: HDR (.hdr), EXR (.exr), gainmap JPEG (.jpg), gainmap WebP (.webp), or cube faces (array of 6 images)
|
|
1914
|
+
* - **Texture**: Pre-existing cube texture via `map` prop
|
|
1915
|
+
* - **Custom Scene**: Render children into environment using portal and cube camera
|
|
1916
|
+
* - **Ground Projection**: Project environment onto ground plane
|
|
1917
|
+
*
|
|
1918
|
+
* @remarks
|
|
1919
|
+
* - Preset property is NOT meant for production and may fail (relies on CDNs)
|
|
1920
|
+
* - Gainmap format has the smallest file footprint
|
|
1921
|
+
* - Use `frames={Infinity}` for animated environments with low resolution for performance
|
|
1922
|
+
* - Ground projection places models on the "ground" within the environment map
|
|
1923
|
+
* - Supports self-hosting with @pmndrs/assets using dynamic imports
|
|
1924
|
+
*
|
|
1925
|
+
* @example Basic preset usage
|
|
1926
|
+
* ```jsx
|
|
1927
|
+
* <Environment preset="sunset" />
|
|
1928
|
+
* ```
|
|
1929
|
+
*
|
|
1930
|
+
* @example From HDR file
|
|
1931
|
+
* ```jsx
|
|
1932
|
+
* <Environment files="/hdr/environment.hdr" />
|
|
1933
|
+
* ```
|
|
1934
|
+
*
|
|
1935
|
+
* @example From gainmap (smallest footprint)
|
|
1936
|
+
* ```jsx
|
|
1937
|
+
* <Environment files={['file.webp', 'file-gainmap.webp', 'file.json']} />
|
|
1938
|
+
* ```
|
|
1939
|
+
*
|
|
1940
|
+
* @example With self-hosted assets
|
|
1941
|
+
* ```jsx
|
|
1942
|
+
* import { suspend } from 'suspend-react'
|
|
1943
|
+
* const city = import('@pmndrs/assets/hdri/city.exr').then(m => m.default)
|
|
1944
|
+
*
|
|
1945
|
+
* <Environment files={suspend(city)} />
|
|
1946
|
+
* ```
|
|
1947
|
+
*
|
|
1948
|
+
* @example From existing texture
|
|
1949
|
+
* ```jsx
|
|
1950
|
+
* <CubeCamera>{(texture) => <Environment map={texture} />}</CubeCamera>
|
|
1951
|
+
* ```
|
|
1952
|
+
*
|
|
1953
|
+
* @example Custom environment scene
|
|
1954
|
+
* ```jsx
|
|
1955
|
+
* <Environment background near={1} far={1000} resolution={256}>
|
|
1956
|
+
* <mesh scale={100}>
|
|
1957
|
+
* <sphereGeometry args={[1, 64, 64]} />
|
|
1958
|
+
* <meshBasicMaterial map={texture} side={THREE.BackSide} />
|
|
1959
|
+
* </mesh>
|
|
1960
|
+
* </Environment>
|
|
1961
|
+
* ```
|
|
1962
|
+
*
|
|
1963
|
+
* @example Animated environment
|
|
1964
|
+
* ```jsx
|
|
1965
|
+
* <Environment frames={Infinity} resolution={256}>
|
|
1966
|
+
* <Float>
|
|
1967
|
+
* <mesh />
|
|
1968
|
+
* </Float>
|
|
1969
|
+
* </Environment>
|
|
1970
|
+
* ```
|
|
1971
|
+
*
|
|
1972
|
+
* @example Mixed custom scene with preset
|
|
1973
|
+
* ```jsx
|
|
1974
|
+
* <Environment background preset="warehouse">
|
|
1975
|
+
* <mesh />
|
|
1976
|
+
* </Environment>
|
|
1977
|
+
* ```
|
|
1978
|
+
*
|
|
1979
|
+
* @example With ground projection
|
|
1980
|
+
* ```jsx
|
|
1981
|
+
* <Environment ground={{ height: 15, radius: 60 }} preset="city" />
|
|
1982
|
+
* ```
|
|
1983
|
+
*
|
|
1984
|
+
* @example As background only
|
|
1985
|
+
* ```jsx
|
|
1986
|
+
* <Environment background="only" preset="sunset" />
|
|
1987
|
+
* ```
|
|
1988
|
+
*
|
|
1989
|
+
* @example With rotation and intensity
|
|
1990
|
+
* ```jsx
|
|
1991
|
+
* <Environment
|
|
1992
|
+
* background
|
|
1993
|
+
* backgroundBlurriness={0.5}
|
|
1994
|
+
* backgroundIntensity={0.8}
|
|
1995
|
+
* backgroundRotation={[0, Math.PI / 2, 0]}
|
|
1996
|
+
* environmentIntensity={1.2}
|
|
1997
|
+
* environmentRotation={[0, Math.PI / 4, 0]}
|
|
1998
|
+
* preset="studio"
|
|
1999
|
+
* />
|
|
2000
|
+
* ```
|
|
2001
|
+
*/
|
|
2002
|
+
declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
1357
2003
|
|
|
1358
2004
|
declare function removeInteractivity(store: RootStore, object: Object3D): void;
|
|
1359
2005
|
declare function createEvents(store: RootStore): {
|
|
@@ -1916,31 +2562,30 @@ declare function useTextures(): UseTexturesReturn;
|
|
|
1916
2562
|
* - WebGPU build: Returns RenderTarget
|
|
1917
2563
|
* - Default build: Returns whichever matches the active renderer
|
|
1918
2564
|
*
|
|
1919
|
-
* @param width - Target width (defaults to canvas width)
|
|
1920
|
-
* @param height - Target height (defaults to canvas height)
|
|
1921
|
-
* @param options - Three.js RenderTarget options
|
|
1922
|
-
*
|
|
1923
2565
|
* @example
|
|
1924
2566
|
* ```tsx
|
|
1925
|
-
*
|
|
1926
|
-
*
|
|
1927
|
-
*
|
|
1928
|
-
*
|
|
1929
|
-
*
|
|
1930
|
-
*
|
|
1931
|
-
*
|
|
1932
|
-
*
|
|
1933
|
-
*
|
|
1934
|
-
*
|
|
1935
|
-
*
|
|
1936
|
-
*
|
|
1937
|
-
*
|
|
1938
|
-
*
|
|
1939
|
-
*
|
|
1940
|
-
*
|
|
2567
|
+
* // Use canvas size
|
|
2568
|
+
* const fbo = useRenderTarget()
|
|
2569
|
+
*
|
|
2570
|
+
* // Use canvas size with options
|
|
2571
|
+
* const fbo = useRenderTarget({ samples: 4 })
|
|
2572
|
+
*
|
|
2573
|
+
* // Square render target
|
|
2574
|
+
* const fbo = useRenderTarget(512)
|
|
2575
|
+
*
|
|
2576
|
+
* // Square render target with options
|
|
2577
|
+
* const fbo = useRenderTarget(512, { depthBuffer: true })
|
|
2578
|
+
*
|
|
2579
|
+
* // Explicit dimensions
|
|
2580
|
+
* const fbo = useRenderTarget(512, 256)
|
|
2581
|
+
*
|
|
2582
|
+
* // Explicit dimensions with options
|
|
2583
|
+
* const fbo = useRenderTarget(512, 256, { samples: 4 })
|
|
1941
2584
|
* ```
|
|
1942
2585
|
*/
|
|
1943
|
-
declare function useRenderTarget(
|
|
2586
|
+
declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget | WebGLRenderTarget;
|
|
2587
|
+
declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget | WebGLRenderTarget;
|
|
2588
|
+
declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget | WebGLRenderTarget;
|
|
1944
2589
|
|
|
1945
2590
|
/**
|
|
1946
2591
|
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
@@ -2045,7 +2690,7 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2045
2690
|
*
|
|
2046
2691
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2047
2692
|
*/
|
|
2048
|
-
declare function advance(timestamp: number
|
|
2693
|
+
declare function advance(timestamp: number): void;
|
|
2049
2694
|
|
|
2050
2695
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2051
2696
|
declare function ReactReconciler<
|
|
@@ -3099,6 +3744,12 @@ declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
|
|
|
3099
3744
|
declare function createRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
|
|
3100
3745
|
declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
|
|
3101
3746
|
declare function createPortal(children: ReactNode, container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>, state?: InjectState): JSX.Element;
|
|
3747
|
+
interface PortalProps {
|
|
3748
|
+
children: ReactNode;
|
|
3749
|
+
state?: InjectState;
|
|
3750
|
+
container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>;
|
|
3751
|
+
}
|
|
3752
|
+
declare function Portal({ children, container, state }: PortalProps): JSX.Element;
|
|
3102
3753
|
/**
|
|
3103
3754
|
* Force React to flush any updates inside the provided callback synchronously and immediately.
|
|
3104
3755
|
* All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
|
|
@@ -3527,11 +4178,76 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
3527
4178
|
constructor?: Function;
|
|
3528
4179
|
};
|
|
3529
4180
|
|
|
4181
|
+
/**
|
|
4182
|
+
* Symbol marker for deferred ref resolution.
|
|
4183
|
+
* Used to identify values that should be resolved from refs after mount.
|
|
4184
|
+
*/
|
|
4185
|
+
declare const FROM_REF: unique symbol;
|
|
4186
|
+
/**
|
|
4187
|
+
* Defers prop application until the referenced object is available.
|
|
4188
|
+
* Useful for props like `target` that need sibling refs to be populated.
|
|
4189
|
+
*
|
|
4190
|
+
* @param ref - React ref object to resolve at mount time
|
|
4191
|
+
* @returns A marker value that applyProps will resolve after mount
|
|
4192
|
+
*
|
|
4193
|
+
* @example
|
|
4194
|
+
* const targetRef = useRef<THREE.Object3D>(null)
|
|
4195
|
+
*
|
|
4196
|
+
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
4197
|
+
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
4198
|
+
*/
|
|
4199
|
+
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
4200
|
+
/**
|
|
4201
|
+
* Type guard to check if a value is a fromRef marker.
|
|
4202
|
+
*
|
|
4203
|
+
* @param value - Value to check
|
|
4204
|
+
* @returns True if value is a fromRef marker
|
|
4205
|
+
*/
|
|
4206
|
+
declare function isFromRef(value: unknown): value is {
|
|
4207
|
+
[FROM_REF]: React$1.RefObject<any>;
|
|
4208
|
+
};
|
|
4209
|
+
|
|
4210
|
+
/**
|
|
4211
|
+
* Symbol marker for mount-only method calls.
|
|
4212
|
+
* Used to identify methods that should only be called once on initial mount.
|
|
4213
|
+
*/
|
|
4214
|
+
declare const ONCE: unique symbol;
|
|
4215
|
+
/**
|
|
4216
|
+
* Marks a method call to be executed only on initial mount.
|
|
4217
|
+
* Useful for geometry transforms that should not be reapplied on every render.
|
|
4218
|
+
*
|
|
4219
|
+
* When `args` prop changes (triggering reconstruction), the method will be
|
|
4220
|
+
* called again on the new instance since appliedOnce is not carried over.
|
|
4221
|
+
*
|
|
4222
|
+
* @param args - Arguments to pass to the method
|
|
4223
|
+
* @returns A marker value that applyProps will execute once
|
|
4224
|
+
*
|
|
4225
|
+
* @example
|
|
4226
|
+
* // Rotate geometry on mount
|
|
4227
|
+
* <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
|
|
4228
|
+
*
|
|
4229
|
+
* // Multiple arguments
|
|
4230
|
+
* <bufferGeometry applyMatrix4={once(matrix)} />
|
|
4231
|
+
*
|
|
4232
|
+
* // No arguments
|
|
4233
|
+
* <geometry center={once()} />
|
|
4234
|
+
*/
|
|
4235
|
+
declare function once<T>(...args: T[]): T;
|
|
4236
|
+
/**
|
|
4237
|
+
* Type guard to check if a value is a once marker.
|
|
4238
|
+
*
|
|
4239
|
+
* @param value - Value to check
|
|
4240
|
+
* @returns True if value is a once marker
|
|
4241
|
+
*/
|
|
4242
|
+
declare function isOnce(value: unknown): value is {
|
|
4243
|
+
[ONCE]: any[] | true;
|
|
4244
|
+
};
|
|
4245
|
+
|
|
3530
4246
|
/**
|
|
3531
4247
|
* A DOM canvas which accepts threejs elements as children.
|
|
3532
4248
|
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
3533
4249
|
*/
|
|
3534
4250
|
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3535
4251
|
|
|
3536
|
-
export { Block, Canvas, ErrorBoundary, IsObject, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Scheduler, Texture, _roots, act, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, getInstanceProps, getRootState, getScheduler, getUuidPrefix, hasConstructor, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isObject3D, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, prepare, reconciler, removeInteractivity, resolve, unmountComponentAtNode, updateCamera, updateFrustum, useBridge, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree };
|
|
3537
|
-
export type { Act, AddPhaseOptions, Args, ArgsProp, AttachFnType, AttachType, BaseRendererProps, Bridge, Camera, CameraProps, CanvasProps, Catalogue, Color, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DomEvent, Dpr, ElementProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameControls, FrameNextCallback, FrameNextControls, FrameNextState, FrameState, FrameTimingState, Frameloop, GLProps, GLTFLike, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, Properties, Quaternion, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererFactory, RendererProps, Root, RootOptions, RootState, RootStore, SchedulerApi, SetBlock, Size, Subscription, TextureEntry, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseFrameNextOptions, UseFrameOptions, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager };
|
|
4252
|
+
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Scheduler, Texture, _roots, act, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getScheduler, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, reconciler, registerPrimary, removeInteractivity, resolve, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|
|
4253
|
+
export type { Act, AddPhaseOptions, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameControls, FrameNextCallback, FrameNextControls, FrameNextState, FrameState, FrameTimingState, Frameloop, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeProps, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootOptions, RootState, RootStore, SchedulerApi, SetBlock, Size, Subscription, TSLNodeInput, TextureEntry, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseFrameNextOptions, UseFrameOptions, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager };
|