@react-three/fiber 10.0.0-canary.4f316e6 → 10.0.0-canary.4f9f64c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +35 -40
- package/dist/index.d.cts +155 -164
- package/dist/index.d.mts +155 -164
- package/dist/index.d.ts +155 -192
- package/dist/index.mjs +35 -40
- package/dist/legacy.cjs +37 -42
- package/dist/legacy.d.cts +159 -168
- package/dist/legacy.d.mts +159 -168
- package/dist/legacy.d.ts +159 -194
- package/dist/legacy.mjs +37 -42
- package/dist/webgpu/index.cjs +91 -97
- package/dist/webgpu/index.d.cts +214 -214
- package/dist/webgpu/index.d.mts +214 -214
- package/dist/webgpu/index.d.ts +214 -242
- package/dist/webgpu/index.mjs +91 -97
- package/package.json +1 -1
package/dist/legacy.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as THREE$1 from 'three';
|
|
2
|
-
import { WebGLCubeRenderTarget, WebGLRenderTarget, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1,
|
|
2
|
+
import { WebGLCubeRenderTarget, WebGLRenderTarget, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Object3D, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Frustum, OrthographicCamera } from 'three';
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
4
|
import { ReactNode, Component, RefObject, JSX } from 'react';
|
|
5
5
|
import * as three_webgpu from 'three/webgpu';
|
|
6
|
-
import { WebGPURenderer as WebGPURenderer$1, Node, StorageTexture, Data3DTexture, CanvasTarget
|
|
6
|
+
import { WebGPURenderer as WebGPURenderer$1, Node, StorageTexture, Storage3DTexture, StorageArrayTexture, Data3DTexture, CanvasTarget } from 'three/webgpu';
|
|
7
7
|
import { StoreApi } from 'zustand';
|
|
8
8
|
import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
|
|
9
9
|
import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
|
|
@@ -41,9 +41,9 @@ declare const R3F_BUILD_WEBGPU = false;
|
|
|
41
41
|
type Inspector = never;
|
|
42
42
|
/** Not available on the legacy (WebGL-only) entry. */
|
|
43
43
|
declare function loadInspector(): Promise<never>;
|
|
44
|
-
declare
|
|
45
|
-
|
|
46
|
-
}
|
|
44
|
+
declare class WebGPURenderer {
|
|
45
|
+
constructor();
|
|
46
|
+
}
|
|
47
47
|
|
|
48
48
|
declare const RenderTarget: any;
|
|
49
49
|
|
|
@@ -348,6 +348,7 @@ type BufferLike =
|
|
|
348
348
|
| Uint16Array
|
|
349
349
|
| Int16Array
|
|
350
350
|
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
351
|
+
| THREE$1.InterleavedBufferAttribute
|
|
351
352
|
| Node // TSL buffer nodes (instancedArray, storage)
|
|
352
353
|
|
|
353
354
|
/** Flat record of buffer-like values (no nested scopes) */
|
|
@@ -362,23 +363,15 @@ type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
|
362
363
|
//* Node Types (useNodes) ========================================
|
|
363
364
|
|
|
364
365
|
/**
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
* would reject values `useNodes` creators legitimately return. This is the same shape
|
|
370
|
-
* `useNodes` already constrains creators to (`TSLNodeLike`).
|
|
366
|
+
* Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
|
|
367
|
+
* the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
|
|
368
|
+
* code passes through. Creators are constrained to this same type, so the shape a creator returns
|
|
369
|
+
* and the shape the store holds are one type by construction.
|
|
371
370
|
*/
|
|
372
|
-
|
|
373
|
-
uuid?: string
|
|
374
|
-
nodeType?: string | null
|
|
375
|
-
/** label method for chaining - sets the node's label and returns self */
|
|
376
|
-
label?: ((label: string) => NodeLike) | string
|
|
377
|
-
setName?: (name: string) => this
|
|
378
|
-
}
|
|
371
|
+
type NodeLike = TSLNodeType | LegacyTSLNodeLike
|
|
379
372
|
|
|
380
373
|
/** Flat record of TSL nodes (no nested scopes) */
|
|
381
|
-
type NodeRecord = Record<string,
|
|
374
|
+
type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
|
|
382
375
|
|
|
383
376
|
/**
|
|
384
377
|
* Node store that can contain both root-level nodes and scoped node objects.
|
|
@@ -400,7 +393,9 @@ type NodeStore = Record<string, NodeLike | NodeRecord>
|
|
|
400
393
|
* ```
|
|
401
394
|
*/
|
|
402
395
|
type StorageLike =
|
|
403
|
-
| StorageTexture // GPU storage texture
|
|
396
|
+
| StorageTexture // 2D GPU storage texture
|
|
397
|
+
| Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
|
|
398
|
+
| StorageArrayTexture // 2D-array GPU storage texture
|
|
404
399
|
| Data3DTexture // 3D texture (can be used as storage)
|
|
405
400
|
| Node // TSL storage texture nodes (storageTexture)
|
|
406
401
|
|
|
@@ -849,14 +844,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
849
844
|
performance?: Partial<Omit<Performance, 'regress'>>
|
|
850
845
|
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
851
846
|
dpr?: Dpr
|
|
852
|
-
/**
|
|
853
|
-
|
|
847
|
+
/**
|
|
848
|
+
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
849
|
+
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
850
|
+
*/
|
|
851
|
+
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
854
852
|
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
855
853
|
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
856
854
|
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
857
855
|
camera?: CameraProps
|
|
858
856
|
/** An R3F event manager to manage elements' pointer events */
|
|
859
|
-
events?: (store: RootStore) => EventManager<
|
|
857
|
+
events?: (store: RootStore) => EventManager<Element>
|
|
860
858
|
/** Callback after the canvas has rendered (but not yet committed) */
|
|
861
859
|
onCreated?: (state: RootState) => void
|
|
862
860
|
/** Response for pointer clicks that have missed any target */
|
|
@@ -1085,7 +1083,7 @@ interface CanvasProps
|
|
|
1085
1083
|
*/
|
|
1086
1084
|
resize?: Options
|
|
1087
1085
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1088
|
-
eventSource?:
|
|
1086
|
+
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1089
1087
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1090
1088
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1091
1089
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1193,107 +1191,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
1193
1191
|
|
|
1194
1192
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
1195
1193
|
|
|
1196
|
-
//* Global Types ==============================
|
|
1194
|
+
//* Global TSL Types ==============================
|
|
1197
1195
|
|
|
1198
1196
|
declare global {
|
|
1199
1197
|
/**
|
|
1200
|
-
*
|
|
1201
|
-
*
|
|
1202
|
-
* This is three's own `UniformNode`, not a re-declaration of it. It previously was a
|
|
1203
|
-
* hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
|
|
1204
|
-
* exported type globally — so R3F's ~58 references resolved to an approximation that was
|
|
1205
|
-
* missing members three actually ships (`setName` among them) and had drifted to the wrong
|
|
1206
|
-
* arity when three made `UniformNode` two-parameter.
|
|
1207
|
-
*
|
|
1208
|
-
* three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
|
|
1209
|
-
* so the node type is fixed to `unknown` and the single parameter is kept for call-site
|
|
1210
|
-
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1211
|
-
* installed three instead of needing to be mirrored by hand.
|
|
1198
|
+
* Broad callable-node fallback for dynamic store readers.
|
|
1199
|
+
* Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
|
|
1212
1200
|
*/
|
|
1213
|
-
type
|
|
1201
|
+
type CallableTSLNode = ((...params: never[]) => unknown) & {
|
|
1202
|
+
readonly shaderNode: unknown
|
|
1203
|
+
readonly id: number
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
/** Legacy structural node accepted when at least one historical marker exists. */
|
|
1207
|
+
type LegacyTSLNodeLike = {
|
|
1208
|
+
label?: ((label: string) => unknown) | string
|
|
1209
|
+
setName?: (name: string) => unknown
|
|
1210
|
+
} & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
|
|
1211
|
+
|
|
1212
|
+
/** Node type accepted by broad dynamic node-store readers. */
|
|
1213
|
+
type TSLNodeType = three_webgpu.Node | CallableTSLNode
|
|
1214
1214
|
|
|
1215
1215
|
/**
|
|
1216
|
-
*
|
|
1217
|
-
*
|
|
1218
|
-
*
|
|
1219
|
-
*
|
|
1216
|
+
* Derive Three's shader node type from an existing node or a supported raw input.
|
|
1217
|
+
* Existing InputNode generics take precedence over structural value normalization.
|
|
1218
|
+
* Both generics must be inferred because Three's UniformNode intersects an unknown-typed
|
|
1219
|
+
* InputNode base with its concrete InputNode specialization.
|
|
1220
1220
|
*/
|
|
1221
|
-
type
|
|
1222
|
-
?
|
|
1223
|
-
: T extends
|
|
1224
|
-
?
|
|
1225
|
-
: T extends
|
|
1226
|
-
? '
|
|
1227
|
-
: T extends
|
|
1228
|
-
? '
|
|
1229
|
-
: T extends three_webgpu.
|
|
1230
|
-
? '
|
|
1231
|
-
: T extends three_webgpu.Vector4
|
|
1221
|
+
type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
|
|
1222
|
+
? TNodeType
|
|
1223
|
+
: T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
|
|
1224
|
+
? TNodeType
|
|
1225
|
+
: T extends number
|
|
1226
|
+
? 'float'
|
|
1227
|
+
: T extends boolean
|
|
1228
|
+
? 'bool'
|
|
1229
|
+
: T extends string | three_webgpu.Color | { r: number; g: number; b: number }
|
|
1230
|
+
? 'color'
|
|
1231
|
+
: T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
|
|
1232
1232
|
? 'vec4'
|
|
1233
|
-
: T extends three_webgpu.
|
|
1234
|
-
? '
|
|
1235
|
-
: T extends three_webgpu.
|
|
1236
|
-
? '
|
|
1233
|
+
: T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
|
|
1234
|
+
? 'vec3'
|
|
1235
|
+
: T extends three_webgpu.Vector2 | { x: number; y: number }
|
|
1236
|
+
? 'vec2'
|
|
1237
1237
|
: T extends three_webgpu.Matrix4
|
|
1238
1238
|
? 'mat4'
|
|
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
|
-
type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
|
|
1239
|
+
: T extends three_webgpu.Matrix3
|
|
1240
|
+
? 'mat3'
|
|
1241
|
+
: T extends three_webgpu.Matrix2
|
|
1242
|
+
? 'mat2'
|
|
1243
|
+
: unknown
|
|
1244
|
+
|
|
1245
|
+
/** Derive the normalized JavaScript value stored by a uniform node. */
|
|
1246
|
+
type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
|
|
1247
|
+
? TValue
|
|
1248
|
+
: T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
|
|
1249
|
+
? TValue
|
|
1250
|
+
: T extends string | { r: number; g: number; b: number }
|
|
1251
|
+
? three_webgpu.Color
|
|
1252
|
+
: T extends { x: number; y: number; z: number; w: number }
|
|
1253
|
+
? three_webgpu.Vector4
|
|
1254
|
+
: T extends { x: number; y: number; z: number }
|
|
1255
|
+
? three_webgpu.Vector3
|
|
1256
|
+
: T extends { x: number; y: number }
|
|
1257
|
+
? three_webgpu.Vector2
|
|
1258
|
+
: T extends number
|
|
1259
|
+
? number
|
|
1260
|
+
: T extends boolean
|
|
1261
|
+
? boolean
|
|
1262
|
+
: T
|
|
1263
|
+
|
|
1264
|
+
/** Three's exact UniformNode with shader and value generics derived from an input. */
|
|
1265
|
+
type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
|
|
1266
|
+
|
|
1267
|
+
/** Preserve every input key while mapping values to exact Three uniform nodes. */
|
|
1268
|
+
type UniformNodesFor<T extends UniformInputRecord> = {
|
|
1269
|
+
[K in keyof T]: UniformNodeFor<T[K]>
|
|
1270
|
+
}
|
|
1272
1271
|
|
|
1273
|
-
/**
|
|
1274
|
-
|
|
1275
|
-
* Used by ScopedStore to properly type node access from the store.
|
|
1276
|
-
*
|
|
1277
|
-
* Includes:
|
|
1278
|
-
* - Node: base Three.js node type
|
|
1279
|
-
* - ShaderCallable: function nodes created with Fn()
|
|
1280
|
-
* - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
|
|
1281
|
-
*
|
|
1282
|
-
* @example
|
|
1283
|
-
* ```tsx
|
|
1284
|
-
* // In useLocalNodes, nodes are typed as TSLNodeType
|
|
1285
|
-
* const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
|
|
1286
|
-
* positionNode: nodes.myPosition, // Works - Node is in union
|
|
1287
|
-
* blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
|
|
1288
|
-
* }))
|
|
1289
|
-
*
|
|
1290
|
-
* // Can narrow with type guard or assertion when needed
|
|
1291
|
-
* if (typeof blendColorFn === 'function') {
|
|
1292
|
-
* blendColorFn(someColor, 0.5)
|
|
1293
|
-
* }
|
|
1294
|
-
* ```
|
|
1295
|
-
*/
|
|
1296
|
-
type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
|
|
1272
|
+
/** Backward-compatible single-parameter uniform alias. */
|
|
1273
|
+
type UniformNode<T = unknown> = UniformNodeFor<T>
|
|
1297
1274
|
|
|
1298
1275
|
/** Flat record of uniform nodes (no nested scopes) */
|
|
1299
1276
|
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
@@ -1318,7 +1295,7 @@ declare global {
|
|
|
1318
1295
|
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1319
1296
|
* Supports:
|
|
1320
1297
|
* - Primitives: number, string (color), boolean
|
|
1321
|
-
* - Three.js types: Color, Vector2/3/4,
|
|
1298
|
+
* - Three.js types: Color, Vector2/3/4, Matrix2/3/4
|
|
1322
1299
|
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1323
1300
|
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1324
1301
|
* - UniformNode: existing uniforms (reused as-is)
|
|
@@ -1331,56 +1308,20 @@ declare global {
|
|
|
1331
1308
|
| three_webgpu.Vector2
|
|
1332
1309
|
| three_webgpu.Vector3
|
|
1333
1310
|
| three_webgpu.Vector4
|
|
1311
|
+
| three_webgpu.Matrix2
|
|
1334
1312
|
| three_webgpu.Matrix3
|
|
1335
1313
|
| three_webgpu.Matrix4
|
|
1336
|
-
|
|
|
1337
|
-
|
|
|
1338
|
-
| { x: number; y
|
|
1314
|
+
| { x: number; y: number }
|
|
1315
|
+
| { x: number; y: number; z: number }
|
|
1316
|
+
| { x: number; y: number; z: number; w: number }
|
|
1339
1317
|
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1340
|
-
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1318
|
+
| three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1341
1319
|
| UniformNode
|
|
1342
1320
|
|
|
1343
1321
|
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1344
1322
|
type UniformInputRecord = Record<string, UniformValue>
|
|
1345
1323
|
}
|
|
1346
1324
|
|
|
1347
|
-
//* Module Augmentation ==============================
|
|
1348
|
-
|
|
1349
|
-
declare module 'three/tsl' {
|
|
1350
|
-
/**
|
|
1351
|
-
* Fn with array parameter destructuring
|
|
1352
|
-
* @example Fn(([uv, skew]) => { ... })
|
|
1353
|
-
*/
|
|
1354
|
-
export function Fn<R extends Node = Node>(
|
|
1355
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1356
|
-
): ShaderCallable<R>
|
|
1357
|
-
|
|
1358
|
-
/**
|
|
1359
|
-
* Fn with object parameter destructuring
|
|
1360
|
-
* @example Fn(({ color, intensity }) => { ... })
|
|
1361
|
-
*/
|
|
1362
|
-
export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
|
|
1363
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1364
|
-
): ShaderCallable<R>
|
|
1365
|
-
|
|
1366
|
-
/**
|
|
1367
|
-
* Fn with array params + layout
|
|
1368
|
-
* @example Fn(([a, b]) => { ... }, { layout: [...] })
|
|
1369
|
-
*/
|
|
1370
|
-
export function Fn<R extends Node = Node>(
|
|
1371
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1372
|
-
layout: { layout?: unknown },
|
|
1373
|
-
): ShaderCallable<R>
|
|
1374
|
-
|
|
1375
|
-
/**
|
|
1376
|
-
* Fn with object params + layout
|
|
1377
|
-
*/
|
|
1378
|
-
export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
|
|
1379
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1380
|
-
layout: { layout?: unknown },
|
|
1381
|
-
): ShaderCallable<R>
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
1325
|
declare global {
|
|
1385
1326
|
/**
|
|
1386
1327
|
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
@@ -1408,10 +1349,15 @@ declare global {
|
|
|
1408
1349
|
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1409
1350
|
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1410
1351
|
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1352
|
+
*
|
|
1353
|
+
* The index signature admits `undefined` because a key may simply not be registered, and
|
|
1354
|
+
* because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
|
|
1355
|
+
* optional property whose type excludes `undefined` from the index signature is an error
|
|
1356
|
+
* (TS2411) for every consumer compiling these declarations.
|
|
1411
1357
|
*/
|
|
1412
1358
|
interface PassRecord {
|
|
1413
1359
|
scenePass?: ScenePassNode
|
|
1414
|
-
[key: string]: three_webgpu.Node
|
|
1360
|
+
[key: string]: three_webgpu.Node | undefined
|
|
1415
1361
|
}
|
|
1416
1362
|
|
|
1417
1363
|
/**
|
|
@@ -1558,10 +1504,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
|
1558
1504
|
|
|
1559
1505
|
/**
|
|
1560
1506
|
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1561
|
-
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1507
|
+
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
1508
|
+
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
1562
1509
|
*/
|
|
1563
1510
|
type NodeProps<P> = {
|
|
1564
|
-
[K in keyof P as P[K] extends
|
|
1511
|
+
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
1565
1512
|
}
|
|
1566
1513
|
|
|
1567
1514
|
interface ReactProps<P> {
|
|
@@ -1582,11 +1529,30 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
|
1582
1529
|
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1583
1530
|
}
|
|
1584
1531
|
|
|
1532
|
+
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
1533
|
+
type Object3DMethod = NonNullable<
|
|
1534
|
+
{
|
|
1535
|
+
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
1536
|
+
}[keyof Object3D]
|
|
1537
|
+
>
|
|
1538
|
+
|
|
1585
1539
|
type ThreeExports = typeof THREE
|
|
1586
1540
|
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1587
1541
|
|
|
1588
1542
|
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1589
|
-
|
|
1543
|
+
/**
|
|
1544
|
+
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
1545
|
+
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
1546
|
+
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
1547
|
+
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
1548
|
+
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
1549
|
+
*/
|
|
1550
|
+
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | 'onUpdate' | Object3DMethod> & {
|
|
1551
|
+
object: object
|
|
1552
|
+
ref?: React.Ref<any>
|
|
1553
|
+
onUpdate?: (self: any) => void
|
|
1554
|
+
[prop: string]: unknown
|
|
1555
|
+
}
|
|
1590
1556
|
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1591
1557
|
threeAudio: ThreeElementsImpl['audio']
|
|
1592
1558
|
threeSource: ThreeElementsImpl['source']
|
|
@@ -1627,6 +1593,7 @@ type three_d_Matrix3 = Matrix3;
|
|
|
1627
1593
|
type three_d_Matrix4 = Matrix4;
|
|
1628
1594
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1629
1595
|
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1596
|
+
type three_d_Object3DMethod = Object3DMethod;
|
|
1630
1597
|
type three_d_Quaternion = Quaternion;
|
|
1631
1598
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1632
1599
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
@@ -1641,7 +1608,7 @@ type three_d_Vector3 = Vector3;
|
|
|
1641
1608
|
type three_d_Vector4 = Vector4;
|
|
1642
1609
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1643
1610
|
declare namespace three_d {
|
|
1644
|
-
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 };
|
|
1611
|
+
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_Object3DMethod as Object3DMethod, 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 };
|
|
1645
1612
|
}
|
|
1646
1613
|
|
|
1647
1614
|
/**
|
|
@@ -1990,7 +1957,7 @@ declare function createEvents(store: RootStore): {
|
|
|
1990
1957
|
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
1991
1958
|
};
|
|
1992
1959
|
/** Default R3F event manager for web */
|
|
1993
|
-
declare function createPointerEvents(store: RootStore): EventManager<
|
|
1960
|
+
declare function createPointerEvents(store: RootStore): EventManager<Element>;
|
|
1994
1961
|
|
|
1995
1962
|
/**
|
|
1996
1963
|
* Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
|
|
@@ -3387,6 +3354,7 @@ declare namespace ReactReconciler {
|
|
|
3387
3354
|
|
|
3388
3355
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
3389
3356
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
3357
|
+
declare function extend(objects: Record<string, unknown>): void;
|
|
3390
3358
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
3391
3359
|
|
|
3392
3360
|
declare const isRenderer: (def: any) => boolean;
|
|
@@ -3830,29 +3798,44 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
3830
3798
|
* Used to identify values that should be resolved from refs after mount.
|
|
3831
3799
|
*/
|
|
3832
3800
|
declare const FROM_REF: unique symbol;
|
|
3801
|
+
/** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
|
|
3802
|
+
interface FromRefMarker<T = unknown, R = T> {
|
|
3803
|
+
[FROM_REF]: React$1.RefObject<T | null>;
|
|
3804
|
+
/** Optional transform applied to the resolved ref before assignment. */
|
|
3805
|
+
transform?: (value: T) => R;
|
|
3806
|
+
}
|
|
3833
3807
|
/**
|
|
3834
3808
|
* Defers prop application until the referenced object is available.
|
|
3835
3809
|
* Useful for props like `target` that need sibling refs to be populated.
|
|
3836
3810
|
*
|
|
3811
|
+
* Only top-level props on a three element are resolved: a marker nested inside another value
|
|
3812
|
+
* (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
|
|
3813
|
+
* than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
|
|
3814
|
+
* what gets assigned.
|
|
3815
|
+
*
|
|
3837
3816
|
* @param ref - React ref object to resolve at mount time
|
|
3838
|
-
* @
|
|
3817
|
+
* @param transform - Optional mapping from the resolved object to the value the prop expects
|
|
3818
|
+
* @returns A marker value that the reconciler resolves after mount
|
|
3839
3819
|
*
|
|
3840
3820
|
* @example
|
|
3841
3821
|
* const targetRef = useRef<THREE.Object3D>(null)
|
|
3842
3822
|
*
|
|
3843
3823
|
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
3844
3824
|
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
3825
|
+
*
|
|
3826
|
+
* @example
|
|
3827
|
+
* // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
|
|
3828
|
+
* <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
|
|
3845
3829
|
*/
|
|
3846
3830
|
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
3831
|
+
declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
|
|
3847
3832
|
/**
|
|
3848
3833
|
* Type guard to check if a value is a fromRef marker.
|
|
3849
3834
|
*
|
|
3850
3835
|
* @param value - Value to check
|
|
3851
3836
|
* @returns True if value is a fromRef marker
|
|
3852
3837
|
*/
|
|
3853
|
-
declare function isFromRef(value: unknown): value is
|
|
3854
|
-
[FROM_REF]: React$1.RefObject<any>;
|
|
3855
|
-
};
|
|
3838
|
+
declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
|
|
3856
3839
|
|
|
3857
3840
|
/**
|
|
3858
3841
|
* Symbol marker for mount-only method calls.
|
|
@@ -3879,7 +3862,15 @@ declare const ONCE: unique symbol;
|
|
|
3879
3862
|
* // No arguments
|
|
3880
3863
|
* <geometry center={once()} />
|
|
3881
3864
|
*/
|
|
3882
|
-
declare function once<
|
|
3865
|
+
declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
|
|
3866
|
+
/**
|
|
3867
|
+
* What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
|
|
3868
|
+
* the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
|
|
3869
|
+
* methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
|
|
3870
|
+
*
|
|
3871
|
+
* The runtime value is always the marker object; only the declared type follows the prop.
|
|
3872
|
+
*/
|
|
3873
|
+
type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
|
|
3883
3874
|
/**
|
|
3884
3875
|
* Type guard to check if a value is a once marker.
|
|
3885
3876
|
*
|
|
@@ -3897,4 +3888,4 @@ declare function isOnce(value: unknown): value is {
|
|
|
3897
3888
|
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3898
3889
|
|
|
3899
3890
|
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, Texture, _roots, 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, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, reconciler, registerPrimary, removeInteractivity, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|
|
3900
|
-
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DisposeOptions, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, LegacyInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeLike, NodeProps, NodeRecord, NodeStore, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, LegacyRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, LegacyRootState as RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
|
|
3891
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DisposeOptions, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, FromRefMarker, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, LegacyInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeLike, NodeProps, NodeRecord, NodeStore, NonFunctionKeys, Object3DMethod, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, OnceValue, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, LegacyRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, LegacyRootState as RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
|