@react-three-dom/core 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1629 -691
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +552 -47
- package/dist/index.d.ts +552 -47
- package/dist/index.js +1627 -694
- package/dist/index.js.map +1 -1
- package/package.json +9 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Object3D, Camera, WebGLRenderer, Vector3 } from 'three';
|
|
1
|
+
import { Object3D, Scene, Camera, WebGLRenderer, Intersection, Vector3 } from 'three';
|
|
2
2
|
|
|
3
|
-
declare const version = "0.
|
|
3
|
+
declare const version = "0.4.0";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Enable or disable debug logging globally.
|
|
@@ -44,6 +44,14 @@ interface ObjectMetadata {
|
|
|
44
44
|
triangleCount?: number;
|
|
45
45
|
/** Instance count for InstancedMesh */
|
|
46
46
|
instanceCount?: number;
|
|
47
|
+
/** Field of view in degrees (PerspectiveCamera only) */
|
|
48
|
+
fov?: number;
|
|
49
|
+
/** Near clipping plane (cameras only) */
|
|
50
|
+
near?: number;
|
|
51
|
+
/** Far clipping plane (cameras only) */
|
|
52
|
+
far?: number;
|
|
53
|
+
/** Zoom level (cameras only) */
|
|
54
|
+
zoom?: number;
|
|
47
55
|
/** Local position as [x, y, z] */
|
|
48
56
|
position: [number, number, number];
|
|
49
57
|
/** Local euler rotation as [x, y, z] in radians */
|
|
@@ -57,6 +65,11 @@ interface ObjectMetadata {
|
|
|
57
65
|
/** Flag indicating bounds need recomputation */
|
|
58
66
|
boundsDirty: boolean;
|
|
59
67
|
}
|
|
68
|
+
/** Options for inspect(). Include geometry buffers only when needed to avoid perf impact. */
|
|
69
|
+
interface InspectOptions {
|
|
70
|
+
/** If true, include vertex positions and triangle indices in geometry. Default: false. */
|
|
71
|
+
includeGeometryData?: boolean;
|
|
72
|
+
}
|
|
60
73
|
interface GeometryInspection {
|
|
61
74
|
/** Geometry class type */
|
|
62
75
|
type: string;
|
|
@@ -74,6 +87,10 @@ interface GeometryInspection {
|
|
|
74
87
|
center: [number, number, number];
|
|
75
88
|
radius: number;
|
|
76
89
|
};
|
|
90
|
+
/** Position attribute data (x,y,z per vertex). Only set when inspect(..., { includeGeometryData: true }). */
|
|
91
|
+
positionData?: number[];
|
|
92
|
+
/** Index buffer (triangle indices). Only set when inspect(..., { includeGeometryData: true }) and geometry is indexed. */
|
|
93
|
+
indexData?: number[];
|
|
77
94
|
}
|
|
78
95
|
interface MaterialInspection {
|
|
79
96
|
/** Material class type */
|
|
@@ -164,10 +181,18 @@ interface R3FDOM {
|
|
|
164
181
|
getByUuid(uuid: string): ObjectMetadata | null;
|
|
165
182
|
/** Tier 1: O(1) lookup by name (returns array, names aren't unique) */
|
|
166
183
|
getByName(name: string): ObjectMetadata[];
|
|
184
|
+
/** Get direct children of an object by testId or uuid */
|
|
185
|
+
getChildren(idOrUuid: string): ObjectMetadata[];
|
|
186
|
+
/** Get parent of an object by testId or uuid (null if root or not found) */
|
|
187
|
+
getParent(idOrUuid: string): ObjectMetadata | null;
|
|
167
188
|
/** Total number of tracked objects */
|
|
168
189
|
getCount(): number;
|
|
169
190
|
/** Get all objects of a given Three.js type (Mesh, Group, Line, Points, etc.) */
|
|
170
191
|
getByType(type: string): ObjectMetadata[];
|
|
192
|
+
/** Get all objects with a given geometry type (e.g. "BoxGeometry", "BufferGeometry") */
|
|
193
|
+
getByGeometryType(type: string): ObjectMetadata[];
|
|
194
|
+
/** Get all objects with a given material type (e.g. "MeshStandardMaterial") */
|
|
195
|
+
getByMaterialType(type: string): ObjectMetadata[];
|
|
171
196
|
/** Get objects that have a specific userData key (and optionally matching value) */
|
|
172
197
|
getByUserData(key: string, value?: unknown): ObjectMetadata[];
|
|
173
198
|
/** Count objects of a given Three.js type */
|
|
@@ -176,8 +201,8 @@ interface R3FDOM {
|
|
|
176
201
|
getObjects(ids: string[]): Record<string, ObjectMetadata | null>;
|
|
177
202
|
/** Full structured JSON snapshot from Tier 1 store */
|
|
178
203
|
snapshot(): SceneSnapshot;
|
|
179
|
-
/** Tier 2: on-demand heavy inspection (reads live Three.js object) */
|
|
180
|
-
inspect(idOrUuid: string): ObjectInspection | null;
|
|
204
|
+
/** Tier 2: on-demand heavy inspection (reads live Three.js object). Use includeGeometryData: true to get vertex/index buffers. */
|
|
205
|
+
inspect(idOrUuid: string, options?: InspectOptions): ObjectInspection | null;
|
|
181
206
|
/** Deterministic click on a 3D object */
|
|
182
207
|
click(idOrUuid: string): void;
|
|
183
208
|
/** Deterministic double-click on a 3D object */
|
|
@@ -186,6 +211,8 @@ interface R3FDOM {
|
|
|
186
211
|
contextMenu(idOrUuid: string): void;
|
|
187
212
|
/** Deterministic hover on a 3D object */
|
|
188
213
|
hover(idOrUuid: string): void;
|
|
214
|
+
/** Unhover / pointer-leave — resets hover state by moving pointer off-canvas */
|
|
215
|
+
unhover(): void;
|
|
189
216
|
/** Deterministic drag on a 3D object (async — dispatches multi-step pointer sequence) */
|
|
190
217
|
drag(idOrUuid: string, delta: {
|
|
191
218
|
x: number;
|
|
@@ -220,17 +247,126 @@ interface R3FDOM {
|
|
|
220
247
|
getSelection(): string[];
|
|
221
248
|
/** Raw Three.js object access (for advanced debugging) */
|
|
222
249
|
getObject3D(idOrUuid: string): Object3D | null;
|
|
250
|
+
/**
|
|
251
|
+
* Resolve uuid for display: if the object is the first mesh of a Group (e.g. table top),
|
|
252
|
+
* returns the parent group uuid so the whole group is highlighted; otherwise returns the given uuid.
|
|
253
|
+
*/
|
|
254
|
+
getSelectionDisplayTarget(uuid: string): string;
|
|
255
|
+
/**
|
|
256
|
+
* Enable or disable "inspect mode" for the mirror DOM.
|
|
257
|
+
* When true, mirror elements use pointer-events: auto so the DevTools element picker
|
|
258
|
+
* can select 3D objects by clicking on the canvas (e.g. hold Alt while using the picker).
|
|
259
|
+
* When false, pointer-events: none so normal 3D interaction works.
|
|
260
|
+
*/
|
|
261
|
+
setInspectMode(on: boolean): void;
|
|
262
|
+
/** Returns true if inspect mode is currently active. */
|
|
263
|
+
getInspectMode(): boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Manually register a Three.js object (and materialize its mirror DOM node).
|
|
266
|
+
* Useful in `manual` mode or to add specific objects in `auto` mode that
|
|
267
|
+
* were excluded by a filter.
|
|
268
|
+
*/
|
|
269
|
+
r3fRegister(obj: Object3D): void;
|
|
270
|
+
/**
|
|
271
|
+
* Unregister a previously registered object and its descendants.
|
|
272
|
+
* Removes the mirror DOM node and store entry.
|
|
273
|
+
*/
|
|
274
|
+
r3fUnregister(obj: Object3D): void;
|
|
275
|
+
/**
|
|
276
|
+
* Manually sweep orphaned objects from the store.
|
|
277
|
+
* Removes objects that are no longer in any tracked scene graph.
|
|
278
|
+
* Runs automatically every ~30s, but can be called after large
|
|
279
|
+
* scene changes (e.g. floor unload) for immediate cleanup.
|
|
280
|
+
* Returns the number of orphans removed.
|
|
281
|
+
*/
|
|
282
|
+
sweepOrphans(): number;
|
|
283
|
+
/**
|
|
284
|
+
* Rich diagnostics for test runners and debugging.
|
|
285
|
+
* Returns bridge health, scene stats, and WebGL context info.
|
|
286
|
+
*/
|
|
287
|
+
getDiagnostics(): BridgeDiagnostics;
|
|
288
|
+
/**
|
|
289
|
+
* Fuzzy search: find objects whose testId or name contains the query string.
|
|
290
|
+
* Returns up to `limit` matches. Used by test runners to suggest corrections
|
|
291
|
+
* when an object is not found.
|
|
292
|
+
*/
|
|
293
|
+
fuzzyFind(query: string, limit?: number): ObjectMetadata[];
|
|
294
|
+
/** Get current camera state (position, rotation, fov, near, far, zoom, type) */
|
|
295
|
+
getCameraState(): CameraState;
|
|
296
|
+
/** Canvas identifier for multi-canvas apps. Undefined for the default/primary canvas. */
|
|
297
|
+
canvasId?: string;
|
|
223
298
|
/** Library version */
|
|
224
299
|
version: string;
|
|
225
300
|
}
|
|
301
|
+
interface CameraState {
|
|
302
|
+
type: 'PerspectiveCamera' | 'OrthographicCamera' | string;
|
|
303
|
+
position: [number, number, number];
|
|
304
|
+
rotation: [number, number, number];
|
|
305
|
+
/** World-space target the camera is looking at (derived from camera direction) */
|
|
306
|
+
target: [number, number, number];
|
|
307
|
+
/** Field of view in degrees (PerspectiveCamera only) */
|
|
308
|
+
fov?: number;
|
|
309
|
+
/** Near clipping plane */
|
|
310
|
+
near: number;
|
|
311
|
+
/** Far clipping plane */
|
|
312
|
+
far: number;
|
|
313
|
+
/** Zoom level */
|
|
314
|
+
zoom: number;
|
|
315
|
+
/** Aspect ratio (PerspectiveCamera only) */
|
|
316
|
+
aspect?: number;
|
|
317
|
+
/** Left/right/top/bottom (OrthographicCamera only) */
|
|
318
|
+
left?: number;
|
|
319
|
+
right?: number;
|
|
320
|
+
top?: number;
|
|
321
|
+
bottom?: number;
|
|
322
|
+
}
|
|
323
|
+
interface BridgeDiagnostics {
|
|
324
|
+
version: string;
|
|
325
|
+
ready: boolean;
|
|
326
|
+
error?: string;
|
|
327
|
+
objectCount: number;
|
|
328
|
+
meshCount: number;
|
|
329
|
+
groupCount: number;
|
|
330
|
+
lightCount: number;
|
|
331
|
+
cameraCount: number;
|
|
332
|
+
materializedDomNodes: number;
|
|
333
|
+
maxDomNodes: number;
|
|
334
|
+
canvasWidth: number;
|
|
335
|
+
canvasHeight: number;
|
|
336
|
+
webglRenderer: string;
|
|
337
|
+
dirtyQueueSize: number;
|
|
338
|
+
}
|
|
226
339
|
declare global {
|
|
227
340
|
interface Window {
|
|
341
|
+
/** Default / primary bridge instance (last mounted, or explicitly marked primary). */
|
|
228
342
|
__R3F_DOM__?: R3FDOM;
|
|
343
|
+
/** Registry of all active bridge instances keyed by canvasId. */
|
|
344
|
+
__R3F_DOM_INSTANCES__?: Record<string, R3FDOM>;
|
|
229
345
|
/** Set to true to enable debug logging from @react-three-dom/core */
|
|
230
346
|
__R3F_DOM_DEBUG__?: boolean;
|
|
347
|
+
/** @internal Mirror element currently hovered by DevTools inspector. */
|
|
348
|
+
__r3fdom_hovered__?: HTMLElement | null;
|
|
349
|
+
/** @internal Mirror element currently selected via DevTools / inspect mode. */
|
|
350
|
+
__r3fdom_selected_element__?: HTMLElement | null;
|
|
231
351
|
}
|
|
232
352
|
}
|
|
233
353
|
|
|
354
|
+
/**
|
|
355
|
+
* @module ObjectStore
|
|
356
|
+
*
|
|
357
|
+
* Central registry for all tracked Three.js objects in a react-three-dom session.
|
|
358
|
+
* Provides two-tier data access: Tier 1 (lightweight metadata cached per-frame)
|
|
359
|
+
* and Tier 2 (on-demand deep inspection of geometry, materials, and bounds).
|
|
360
|
+
* Designed for BIM-scale scenes (100k+ objects) with O(1) lookups by uuid,
|
|
361
|
+
* testId, and name, plus amortized flat-list iteration and async registration.
|
|
362
|
+
*/
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Source of truth for all tracked Three.js objects.
|
|
366
|
+
* Maintains O(1) indexes by uuid, testId, and name, a dirty queue for
|
|
367
|
+
* priority per-frame sync, and an event system for add/remove/update
|
|
368
|
+
* notifications consumed by DomMirror and the devtools panel.
|
|
369
|
+
*/
|
|
234
370
|
declare class ObjectStore {
|
|
235
371
|
private _metaByObject;
|
|
236
372
|
private _objectByUuid;
|
|
@@ -244,42 +380,65 @@ declare class ObjectStore {
|
|
|
244
380
|
/**
|
|
245
381
|
* Register a single object into the store.
|
|
246
382
|
* Populates Tier 1 metadata and all indexes.
|
|
383
|
+
* Tags the object with `__r3fdom_tracked = true` for O(1) scene membership checks.
|
|
247
384
|
*/
|
|
248
385
|
register(obj: Object3D): ObjectMetadata;
|
|
249
386
|
/**
|
|
250
|
-
* Register an entire subtree (object + all descendants).
|
|
251
|
-
*
|
|
252
|
-
* is enabled) so that one bad object doesn't prevent the rest from being
|
|
253
|
-
* tracked.
|
|
387
|
+
* Register an entire subtree (object + all descendants) synchronously.
|
|
388
|
+
* Prefer `registerTreeAsync` for large scenes (100k+) to avoid blocking.
|
|
254
389
|
*/
|
|
255
390
|
registerTree(root: Object3D): void;
|
|
391
|
+
private _asyncRegQueue;
|
|
392
|
+
private _asyncRegHandle;
|
|
393
|
+
private _asyncRegBatchSize;
|
|
394
|
+
/**
|
|
395
|
+
* Register an entire subtree asynchronously using requestIdleCallback.
|
|
396
|
+
* Processes ~1000 objects per idle slice to avoid blocking the main thread.
|
|
397
|
+
*
|
|
398
|
+
* IMPORTANT: install patchObject3D BEFORE calling this so that objects
|
|
399
|
+
* added to the scene during async registration are caught by the patch.
|
|
400
|
+
*
|
|
401
|
+
* Returns a cancel function. Also cancelled automatically by dispose().
|
|
402
|
+
*/
|
|
403
|
+
registerTreeAsync(root: Object3D): () => void;
|
|
404
|
+
private _scheduleRegChunk;
|
|
405
|
+
private _cancelAsyncRegistration;
|
|
256
406
|
/**
|
|
257
407
|
* Unregister a single object from the store.
|
|
408
|
+
* Clears the `__r3fdom_tracked` flag.
|
|
258
409
|
*/
|
|
259
410
|
unregister(obj: Object3D): void;
|
|
260
411
|
/**
|
|
261
412
|
* Unregister an entire subtree (object + all descendants).
|
|
262
413
|
*/
|
|
414
|
+
/** Mark a root as tracked without traversing/registering its children. */
|
|
415
|
+
addTrackedRoot(root: Object3D): void;
|
|
263
416
|
unregisterTree(root: Object3D): void;
|
|
264
417
|
/**
|
|
265
|
-
* Refresh Tier 1
|
|
418
|
+
* Refresh dynamic Tier 1 fields from the live Three.js object.
|
|
419
|
+
* Only reads transform, visibility, children count, and parent —
|
|
420
|
+
* skips static fields (geometry, material) that don't change per-frame.
|
|
421
|
+
* Mutates metadata in-place to avoid allocation.
|
|
266
422
|
* Returns true if any values changed.
|
|
267
|
-
* Returns false (no change) if extracting metadata throws so that the
|
|
268
|
-
* previous metadata is preserved.
|
|
269
423
|
*/
|
|
270
424
|
update(obj: Object3D): boolean;
|
|
271
425
|
/**
|
|
272
426
|
* Compute full inspection data from a live Three.js object.
|
|
273
427
|
* This reads geometry buffers, material properties, world bounds, etc.
|
|
274
428
|
* Cost: 0.1–2ms depending on geometry complexity.
|
|
429
|
+
* Pass { includeGeometryData: true } to include vertex positions and triangle indices (higher cost for large meshes).
|
|
275
430
|
*/
|
|
276
|
-
inspect(idOrUuid: string): ObjectInspection | null;
|
|
431
|
+
inspect(idOrUuid: string, options?: InspectOptions): ObjectInspection | null;
|
|
277
432
|
/** Get metadata by testId. O(1). */
|
|
278
433
|
getByTestId(testId: string): ObjectMetadata | null;
|
|
279
434
|
/** Get metadata by uuid. O(1). */
|
|
280
435
|
getByUuid(uuid: string): ObjectMetadata | null;
|
|
281
436
|
/** Get metadata by name (returns array since names aren't unique). O(1). */
|
|
282
437
|
getByName(name: string): ObjectMetadata[];
|
|
438
|
+
/** Get direct children of an object by testId or uuid. Returns empty array if not found. */
|
|
439
|
+
getChildren(idOrUuid: string): ObjectMetadata[];
|
|
440
|
+
/** Get parent of an object by testId or uuid. Returns null if not found or if root. */
|
|
441
|
+
getParent(idOrUuid: string): ObjectMetadata | null;
|
|
283
442
|
/**
|
|
284
443
|
* Batch lookup: get metadata for multiple objects by testId or uuid.
|
|
285
444
|
* Returns a Map from the requested id to its metadata (or null if not found).
|
|
@@ -293,6 +452,16 @@ declare class ObjectStore {
|
|
|
293
452
|
* Linear scan — O(n) where n is total tracked objects.
|
|
294
453
|
*/
|
|
295
454
|
getByType(type: string): ObjectMetadata[];
|
|
455
|
+
/**
|
|
456
|
+
* Get all objects with a given geometry type (e.g. "BoxGeometry", "BufferGeometry").
|
|
457
|
+
* Linear scan — O(n). Only meshes/points/lines have geometryType.
|
|
458
|
+
*/
|
|
459
|
+
getByGeometryType(type: string): ObjectMetadata[];
|
|
460
|
+
/**
|
|
461
|
+
* Get all objects with a given material type (e.g. "MeshStandardMaterial").
|
|
462
|
+
* Linear scan — O(n). Only meshes/points/lines have materialType.
|
|
463
|
+
*/
|
|
464
|
+
getByMaterialType(type: string): ObjectMetadata[];
|
|
296
465
|
/**
|
|
297
466
|
* Get all objects that have a specific userData key.
|
|
298
467
|
* If `value` is provided, only returns objects where `userData[key]` matches.
|
|
@@ -317,9 +486,10 @@ declare class ObjectStore {
|
|
|
317
486
|
/** Check if a root scene is tracked. */
|
|
318
487
|
isTrackedRoot(obj: Object3D): boolean;
|
|
319
488
|
/**
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
489
|
+
* Check if an object belongs to a tracked scene.
|
|
490
|
+
* Fast path: checks the `__r3fdom_tracked` flag set during register (O(1)).
|
|
491
|
+
* Fallback: walks up the parent chain to find a tracked root.
|
|
492
|
+
* The fallback is needed for newly added objects that aren't registered yet.
|
|
323
493
|
*/
|
|
324
494
|
isInTrackedScene(obj: Object3D): boolean;
|
|
325
495
|
/**
|
|
@@ -339,10 +509,32 @@ declare class ObjectStore {
|
|
|
339
509
|
/** Subscribe to store events (add, remove, update). */
|
|
340
510
|
subscribe(listener: StoreListener): () => void;
|
|
341
511
|
private _emit;
|
|
512
|
+
/**
|
|
513
|
+
* Sweep objects in `_objectByUuid` that are no longer in any tracked scene.
|
|
514
|
+
* This catches objects that were removed from the scene graph without
|
|
515
|
+
* triggering the patched Object3D.remove (e.g. direct `.children` splice,
|
|
516
|
+
* or the remove hook failing silently).
|
|
517
|
+
*
|
|
518
|
+
* At BIM scale, call this periodically (e.g. every 30s or after a floor
|
|
519
|
+
* load/unload) to prevent memory leaks from retained Object3D references.
|
|
520
|
+
*
|
|
521
|
+
* Returns the number of orphans cleaned up.
|
|
522
|
+
*/
|
|
523
|
+
sweepOrphans(): number;
|
|
342
524
|
/** Remove all tracked objects and reset state. */
|
|
343
525
|
dispose(): void;
|
|
344
526
|
}
|
|
345
527
|
|
|
528
|
+
/**
|
|
529
|
+
* @module DomMirror
|
|
530
|
+
*
|
|
531
|
+
* Maintains a parallel DOM tree that mirrors the Three.js scene graph using
|
|
532
|
+
* custom elements (<three-mesh>, <three-group>, etc.). This enables standard
|
|
533
|
+
* DOM tooling — CSS selectors, DevTools Elements panel, Accessibility tree —
|
|
534
|
+
* to work with 3D objects. Only a subset of objects are materialized as DOM
|
|
535
|
+
* nodes at any time (capped via LRU eviction) to stay performant at BIM scale.
|
|
536
|
+
*/
|
|
537
|
+
|
|
346
538
|
/**
|
|
347
539
|
* Manages the parallel DOM tree that mirrors the Three.js scene graph.
|
|
348
540
|
*
|
|
@@ -361,12 +553,30 @@ declare class DomMirror {
|
|
|
361
553
|
private _lruSize;
|
|
362
554
|
private _maxNodes;
|
|
363
555
|
private _parentMap;
|
|
556
|
+
/** When true, mirror elements use pointer-events: auto so DevTools element picker can select them. */
|
|
557
|
+
private _inspectMode;
|
|
558
|
+
/** Async materialization state for inspect mode */
|
|
559
|
+
private _asyncQueue;
|
|
560
|
+
private _asyncIdleHandle;
|
|
561
|
+
private _asyncBatchSize;
|
|
364
562
|
constructor(store: ObjectStore, maxNodes?: number);
|
|
365
563
|
/**
|
|
366
564
|
* Set the root DOM element where the mirror tree will be appended.
|
|
367
565
|
* Typically a hidden div: <div id="three-dom-root" style="display:none">
|
|
368
566
|
*/
|
|
369
567
|
setRoot(rootElement: HTMLElement): void;
|
|
568
|
+
/**
|
|
569
|
+
* Enable or disable "inspect mode". When turning on, kicks off async
|
|
570
|
+
* chunked materialization so the full tree becomes browsable in the
|
|
571
|
+
* Elements tab without blocking the main thread.
|
|
572
|
+
*
|
|
573
|
+
* At BIM scale (100k-200k objects) the old synchronous loop would freeze
|
|
574
|
+
* the page for 2-10s. The new approach uses requestIdleCallback to
|
|
575
|
+
* spread work across idle frames (~200 nodes per idle slice, ~5ms each).
|
|
576
|
+
*/
|
|
577
|
+
setInspectMode(on: boolean): void;
|
|
578
|
+
/** Whether inspect mode is currently enabled. */
|
|
579
|
+
getInspectMode(): boolean;
|
|
370
580
|
/**
|
|
371
581
|
* Build the initial DOM tree from the scene.
|
|
372
582
|
* Materializes the top 2 levels of the scene hierarchy.
|
|
@@ -385,8 +595,14 @@ declare class DomMirror {
|
|
|
385
595
|
/**
|
|
386
596
|
* Remove a DOM node but keep JS metadata in the ObjectStore.
|
|
387
597
|
* Called by LRU eviction or when an object is removed from the scene.
|
|
598
|
+
* Also dematerializes any materialized descendants so they don't become
|
|
599
|
+
* orphaned entries in the LRU / _nodes maps.
|
|
388
600
|
*/
|
|
389
601
|
dematerialize(uuid: string): void;
|
|
602
|
+
/**
|
|
603
|
+
* Collect all materialized descendants of a uuid by walking _parentMap.
|
|
604
|
+
*/
|
|
605
|
+
private _collectMaterializedDescendants;
|
|
390
606
|
/**
|
|
391
607
|
* Called when a new object is added to the tracked scene.
|
|
392
608
|
* Only materializes if the parent is already materialized (lazy expansion).
|
|
@@ -415,6 +631,14 @@ declare class DomMirror {
|
|
|
415
631
|
* Get the materialized DOM element for an object, if it exists.
|
|
416
632
|
*/
|
|
417
633
|
getElement(uuid: string): HTMLElement | null;
|
|
634
|
+
/**
|
|
635
|
+
* Get or lazily materialize a DOM element for an object.
|
|
636
|
+
* Also materializes the ancestor chain so the element is correctly
|
|
637
|
+
* nested in the DOM tree. Used by InspectController so that
|
|
638
|
+
* hover/click always produces a valid mirror element regardless
|
|
639
|
+
* of whether async materialization has reached it yet.
|
|
640
|
+
*/
|
|
641
|
+
getOrMaterialize(uuid: string): HTMLElement | null;
|
|
418
642
|
/**
|
|
419
643
|
* Check if an object has a materialized DOM node.
|
|
420
644
|
*/
|
|
@@ -446,6 +670,14 @@ declare class DomMirror {
|
|
|
446
670
|
* Insert a newly created element into the correct position in the DOM tree.
|
|
447
671
|
*/
|
|
448
672
|
private _insertIntoDom;
|
|
673
|
+
/**
|
|
674
|
+
* Materialize all ancestors of a uuid from root down, so the target
|
|
675
|
+
* element will be correctly nested when materialized.
|
|
676
|
+
*/
|
|
677
|
+
private _materializeAncestorChain;
|
|
678
|
+
private _startAsyncMaterialization;
|
|
679
|
+
private _cancelAsyncMaterialization;
|
|
680
|
+
private _scheduleAsyncChunk;
|
|
449
681
|
/**
|
|
450
682
|
* Parse common CSS selector patterns and resolve to a uuid from the store.
|
|
451
683
|
* Supports:
|
|
@@ -469,6 +701,15 @@ declare class DomMirror {
|
|
|
469
701
|
private _evictLRU;
|
|
470
702
|
}
|
|
471
703
|
|
|
704
|
+
/**
|
|
705
|
+
* @module CustomElements
|
|
706
|
+
*
|
|
707
|
+
* Defines and registers the custom HTML elements (<three-scene>, <three-mesh>,
|
|
708
|
+
* <three-light>, etc.) used by DomMirror to represent Three.js objects in the
|
|
709
|
+
* DOM. The ThreeElement base class exposes interactive properties (metadata,
|
|
710
|
+
* inspect, object3D) accessible from the DevTools console via `$0.metadata`.
|
|
711
|
+
*/
|
|
712
|
+
|
|
472
713
|
/**
|
|
473
714
|
* Maps Three.js object types to custom element tag names.
|
|
474
715
|
* Multiple Three.js types can map to the same tag.
|
|
@@ -560,6 +801,14 @@ declare class ThreeElement extends HTMLElement {
|
|
|
560
801
|
*/
|
|
561
802
|
declare function ensureCustomElements(store: ObjectStore): void;
|
|
562
803
|
|
|
804
|
+
/**
|
|
805
|
+
* @module attributes
|
|
806
|
+
*
|
|
807
|
+
* Serializes ObjectStore Tier 1 metadata into DOM data-attributes and applies
|
|
808
|
+
* them to mirror elements with minimal DOM writes. Only attributes whose values
|
|
809
|
+
* actually changed are written, keeping per-frame cost near zero for static objects.
|
|
810
|
+
*/
|
|
811
|
+
|
|
563
812
|
/** All attribute names we manage (for diffing). */
|
|
564
813
|
declare const MANAGED_ATTRIBUTES: string[];
|
|
565
814
|
/**
|
|
@@ -579,7 +828,20 @@ declare function computeAttributes(meta: ObjectMetadata): Map<string, string>;
|
|
|
579
828
|
*/
|
|
580
829
|
declare function applyAttributes(element: HTMLElement, meta: ObjectMetadata, prevAttrs: Map<string, string>): number;
|
|
581
830
|
|
|
831
|
+
/**
|
|
832
|
+
* @module SelectionManager
|
|
833
|
+
*
|
|
834
|
+
* Lightweight selection state manager for 3D objects. Supports single and
|
|
835
|
+
* multi-selection, notifies listeners on change so Highlighter and the
|
|
836
|
+
* devtools inspector panel can react. Decoupled from rendering — purely
|
|
837
|
+
* manages which Object3D references are "selected".
|
|
838
|
+
*/
|
|
839
|
+
|
|
582
840
|
type SelectionListener = (selected: Object3D[]) => void;
|
|
841
|
+
/**
|
|
842
|
+
* Tracks the set of currently selected Object3D instances and notifies
|
|
843
|
+
* subscribers when the selection changes.
|
|
844
|
+
*/
|
|
583
845
|
declare class SelectionManager {
|
|
584
846
|
/** Currently selected objects (ordered by selection time). */
|
|
585
847
|
private _selected;
|
|
@@ -609,56 +871,211 @@ declare class SelectionManager {
|
|
|
609
871
|
dispose(): void;
|
|
610
872
|
}
|
|
611
873
|
|
|
874
|
+
/**
|
|
875
|
+
* @module Highlighter
|
|
876
|
+
*
|
|
877
|
+
* Renders Chrome DevTools-style translucent fill overlays on hovered and
|
|
878
|
+
* selected Three.js objects. Subscribes to SelectionManager for selection
|
|
879
|
+
* state and polls `window.__r3fdom_hovered__` for DevTools element-picker
|
|
880
|
+
* hover. Highlight meshes are marked `__r3fdom_internal` so they're excluded
|
|
881
|
+
* from raycasting and the ObjectStore.
|
|
882
|
+
*/
|
|
883
|
+
|
|
612
884
|
interface HighlighterOptions {
|
|
613
|
-
/** Whether to show a tooltip above highlighted objects. Default: true */
|
|
614
885
|
showTooltip?: boolean;
|
|
615
886
|
}
|
|
887
|
+
/**
|
|
888
|
+
* Manages hover and selection highlight overlays in the 3D scene.
|
|
889
|
+
* Attaches to a Scene + SelectionManager and creates/disposes translucent
|
|
890
|
+
* mesh clones that track the source object's world transform each frame.
|
|
891
|
+
*/
|
|
616
892
|
declare class Highlighter {
|
|
617
|
-
|
|
618
|
-
private _selectedEntries;
|
|
619
|
-
/** Hover overlay (temporary, single object at a time) */
|
|
620
|
-
private _hoverEntries;
|
|
621
|
-
private _camera;
|
|
622
|
-
private _renderer;
|
|
893
|
+
private _scene;
|
|
623
894
|
private _unsubscribe;
|
|
624
|
-
private
|
|
625
|
-
|
|
895
|
+
private _hoverEntries;
|
|
896
|
+
private _hoverTarget;
|
|
897
|
+
private _selectedEntries;
|
|
626
898
|
private _hoverPollId;
|
|
627
|
-
private
|
|
628
|
-
/** Store reference for resolving objects */
|
|
899
|
+
private _lastHoveredUuid;
|
|
629
900
|
private _store;
|
|
630
|
-
constructor(
|
|
631
|
-
|
|
901
|
+
constructor(_options?: HighlighterOptions);
|
|
902
|
+
/** Bind to a scene and selection manager, start hover polling. */
|
|
903
|
+
attach(scene: Scene, selectionManager: SelectionManager, _camera: Camera, _renderer: WebGLRenderer, store: {
|
|
632
904
|
getObject3D(uuid: string): Object3D | null;
|
|
633
905
|
}): void;
|
|
906
|
+
/** Unbind from the scene, stop polling, and remove all highlights. */
|
|
634
907
|
detach(): void;
|
|
908
|
+
/** Sync highlight group transforms to their source objects. Call each frame. */
|
|
635
909
|
update(): void;
|
|
636
|
-
highlight(
|
|
637
|
-
unhighlight(obj: Object3D): void;
|
|
638
|
-
clearAll(): void;
|
|
639
|
-
isHighlighted(obj: Object3D): boolean;
|
|
640
|
-
/** Show a temporary hover highlight for an object and its children */
|
|
910
|
+
/** Show a hover highlight on the given object (replaces any previous hover). */
|
|
641
911
|
showHoverHighlight(obj: Object3D): void;
|
|
642
|
-
/**
|
|
912
|
+
/** Remove the current hover highlight. */
|
|
643
913
|
clearHoverHighlight(): void;
|
|
644
|
-
private
|
|
645
|
-
|
|
646
|
-
|
|
914
|
+
private _clearHoverVisuals;
|
|
915
|
+
/** Check if an object currently has a selection highlight. */
|
|
916
|
+
isHighlighted(obj: Object3D): boolean;
|
|
917
|
+
/** Remove all hover and selection highlights. */
|
|
918
|
+
clearAll(): void;
|
|
919
|
+
private _syncSelectionHighlights;
|
|
920
|
+
private _addSelectionHighlight;
|
|
921
|
+
private _removeSelectionHighlight;
|
|
922
|
+
private _clearAllSelectionHighlights;
|
|
647
923
|
private _startHoverPolling;
|
|
648
924
|
private _stopHoverPolling;
|
|
649
925
|
private _pollDevToolsHover;
|
|
650
|
-
private
|
|
651
|
-
|
|
926
|
+
private _disposeHighlightGroup;
|
|
927
|
+
/** Detach and release all resources. */
|
|
928
|
+
dispose(): void;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* @module RaycastAccelerator
|
|
933
|
+
*
|
|
934
|
+
* Two-layer acceleration structure for BIM-scale raycasting (100k+ objects).
|
|
935
|
+
* Layer 1 maintains a pre-filtered flat list of raycastable meshes from the
|
|
936
|
+
* ObjectStore (avoids recursive scene traversal). Layer 2 uses three-mesh-bvh
|
|
937
|
+
* to build per-geometry BVH trees, turning per-mesh triangle intersection
|
|
938
|
+
* from O(t) brute-force into O(log t). Combined: ~0.01–0.1ms at 200k objects.
|
|
939
|
+
*/
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* Maintains an accelerated raycast target list and per-geometry BVH trees.
|
|
943
|
+
* Rebuilds lazily when the ObjectStore emits changes, with a per-rebuild
|
|
944
|
+
* BVH budget to avoid blocking the main thread on large model loads.
|
|
945
|
+
*/
|
|
946
|
+
declare class RaycastAccelerator {
|
|
947
|
+
private _store;
|
|
948
|
+
private _targets;
|
|
949
|
+
private _dirty;
|
|
950
|
+
private _unsubscribe;
|
|
951
|
+
private _bvhBuiltFor;
|
|
952
|
+
constructor(store: ObjectStore);
|
|
953
|
+
/** Force a target list rebuild on the next raycast. */
|
|
954
|
+
markDirty(): void;
|
|
955
|
+
private _rebuild;
|
|
956
|
+
/**
|
|
957
|
+
* Build a BVH for a mesh's geometry if it doesn't have one yet.
|
|
958
|
+
* Uses indirect mode to avoid modifying the index buffer.
|
|
959
|
+
* Skips disposed geometries and does NOT mark failed builds so they
|
|
960
|
+
* can be retried (e.g. after geometry is re-uploaded).
|
|
961
|
+
*/
|
|
962
|
+
private _ensureBVH;
|
|
963
|
+
/**
|
|
964
|
+
* Raycast from mouse position against only raycastable meshes.
|
|
965
|
+
* Returns the closest non-internal hit, or null.
|
|
966
|
+
*/
|
|
967
|
+
raycastAtMouse(e: MouseEvent, camera: Camera, canvas: HTMLCanvasElement): Object3D | null;
|
|
968
|
+
/**
|
|
969
|
+
* Raycast from NDC coordinates. Used by raycastVerify.
|
|
970
|
+
*/
|
|
971
|
+
raycastAtNdc(ndcX: number, ndcY: number, camera: Camera): Intersection[];
|
|
972
|
+
/** Current number of raycastable targets. */
|
|
973
|
+
get targetCount(): number;
|
|
974
|
+
/** Unsubscribe from the store and release the target list. */
|
|
652
975
|
dispose(): void;
|
|
653
976
|
}
|
|
654
977
|
|
|
978
|
+
/**
|
|
979
|
+
* @module InspectController
|
|
980
|
+
*
|
|
981
|
+
* Chrome DevTools-style inspect mode for 3D scenes. When enabled, places a
|
|
982
|
+
* transparent overlay on top of the WebGL canvas that intercepts all pointer
|
|
983
|
+
* events (preventing R3F's event system and camera controls from consuming
|
|
984
|
+
* them), raycasts to identify the object under the cursor, drives
|
|
985
|
+
* hover/selection highlights, and sets a global reference so the DevTools
|
|
986
|
+
* extension can reveal the corresponding mirror DOM node.
|
|
987
|
+
* Zero overhead when disabled — no overlay, no listeners.
|
|
988
|
+
*/
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Manages the inspect-mode lifecycle: creates/removes an overlay div,
|
|
992
|
+
* throttles raycasts, and coordinates Highlighter + SelectionManager + DomMirror.
|
|
993
|
+
*/
|
|
994
|
+
declare class InspectController {
|
|
995
|
+
private _active;
|
|
996
|
+
private _camera;
|
|
997
|
+
private _renderer;
|
|
998
|
+
private _selectionManager;
|
|
999
|
+
private _highlighter;
|
|
1000
|
+
private _raycastAccelerator;
|
|
1001
|
+
private _mirror;
|
|
1002
|
+
private _store;
|
|
1003
|
+
private _lastRaycastTime;
|
|
1004
|
+
private _hoveredObject;
|
|
1005
|
+
private _hoverRevealTimer;
|
|
1006
|
+
private _overlay;
|
|
1007
|
+
private _boundPointerMove;
|
|
1008
|
+
private _boundPointerDown;
|
|
1009
|
+
private _boundContextMenu;
|
|
1010
|
+
constructor(opts: {
|
|
1011
|
+
camera: Camera;
|
|
1012
|
+
renderer: WebGLRenderer;
|
|
1013
|
+
selectionManager: SelectionManager;
|
|
1014
|
+
highlighter: Highlighter;
|
|
1015
|
+
raycastAccelerator: RaycastAccelerator;
|
|
1016
|
+
mirror: DomMirror;
|
|
1017
|
+
store: {
|
|
1018
|
+
getObject3D(uuid: string): Object3D | null;
|
|
1019
|
+
};
|
|
1020
|
+
});
|
|
1021
|
+
get active(): boolean;
|
|
1022
|
+
/** Update the camera reference (e.g. after a camera switch). */
|
|
1023
|
+
updateCamera(camera: Camera): void;
|
|
1024
|
+
/** Activate inspect mode — creates overlay on top of canvas. */
|
|
1025
|
+
enable(): void;
|
|
1026
|
+
/** Deactivate inspect mode — removes overlay and clears all inspect state. */
|
|
1027
|
+
disable(): void;
|
|
1028
|
+
/** Disable and release all resources. */
|
|
1029
|
+
dispose(): void;
|
|
1030
|
+
private _raycastFromEvent;
|
|
1031
|
+
/**
|
|
1032
|
+
* Resolve a raw raycast hit to the logical selection target.
|
|
1033
|
+
* Walks up to find the best Group parent if applicable.
|
|
1034
|
+
*/
|
|
1035
|
+
private _resolveTarget;
|
|
1036
|
+
private _onPointerMove;
|
|
1037
|
+
/**
|
|
1038
|
+
* After hovering an object for HOVER_REVEAL_DEBOUNCE_MS, auto-reveal its
|
|
1039
|
+
* mirror element in the Elements tab.
|
|
1040
|
+
*/
|
|
1041
|
+
private _scheduleHoverReveal;
|
|
1042
|
+
private _cancelHoverReveal;
|
|
1043
|
+
private _onPointerDown;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
655
1046
|
interface ThreeDomProps {
|
|
1047
|
+
/**
|
|
1048
|
+
* Unique identifier for this canvas instance. Required when using multiple
|
|
1049
|
+
* canvases. The bridge is registered in `window.__R3F_DOM_INSTANCES__[canvasId]`.
|
|
1050
|
+
* When omitted the bridge is only set on `window.__R3F_DOM__`.
|
|
1051
|
+
*/
|
|
1052
|
+
canvasId?: string;
|
|
1053
|
+
/**
|
|
1054
|
+
* Mark this canvas as the primary / default instance.
|
|
1055
|
+
* `window.__R3F_DOM__` always points to the primary bridge.
|
|
1056
|
+
* When only one canvas is used (no canvasId), it is implicitly primary.
|
|
1057
|
+
* Default: true when canvasId is omitted, false otherwise.
|
|
1058
|
+
*/
|
|
1059
|
+
primary?: boolean;
|
|
1060
|
+
/**
|
|
1061
|
+
* Registration mode:
|
|
1062
|
+
* - "auto" (default): traverses and registers all objects in the scene.
|
|
1063
|
+
* - "manual": nothing is auto-registered. Use `useR3FRegister` hook or
|
|
1064
|
+
* `__R3F_DOM__.r3fRegister()` to add objects explicitly.
|
|
1065
|
+
*/
|
|
1066
|
+
mode?: 'auto' | 'manual';
|
|
1067
|
+
/**
|
|
1068
|
+
* Filter function for auto mode. Only objects that pass the filter are
|
|
1069
|
+
* registered. Ignored in manual mode.
|
|
1070
|
+
* Example: `filter={(obj) => !!obj.userData.testId}`
|
|
1071
|
+
*/
|
|
1072
|
+
filter?: (obj: Object3D) => boolean;
|
|
656
1073
|
/** CSS selector or HTMLElement for the mirror DOM root. Default: "#three-dom-root" */
|
|
657
1074
|
root?: string | HTMLElement;
|
|
658
1075
|
/** Objects to process per amortized batch per frame. Default: 500 */
|
|
659
1076
|
batchSize?: number;
|
|
660
1077
|
/** Max time budget (ms) for sync work per frame. Default: 0.5 */
|
|
661
|
-
|
|
1078
|
+
syncBudgetMs?: number;
|
|
662
1079
|
/** Max materialized DOM nodes (LRU eviction). Default: 2000 */
|
|
663
1080
|
maxDomNodes?: number;
|
|
664
1081
|
/** Initial DOM tree materialization depth. Default: 3 */
|
|
@@ -667,12 +1084,22 @@ interface ThreeDomProps {
|
|
|
667
1084
|
enabled?: boolean;
|
|
668
1085
|
/** Enable debug logging to browser console. Default: false */
|
|
669
1086
|
debug?: boolean;
|
|
1087
|
+
/** Enable inspect mode on mount. Default: false */
|
|
1088
|
+
inspect?: boolean;
|
|
670
1089
|
}
|
|
671
|
-
|
|
672
|
-
declare function
|
|
673
|
-
|
|
674
|
-
declare function
|
|
675
|
-
|
|
1090
|
+
/** Get the store for a canvas instance. Default: primary ('') instance. */
|
|
1091
|
+
declare function getStore(canvasId?: string): ObjectStore | null;
|
|
1092
|
+
/** Get the mirror for a canvas instance. Default: primary ('') instance. */
|
|
1093
|
+
declare function getMirror(canvasId?: string): DomMirror | null;
|
|
1094
|
+
/** Get the selection manager for a canvas instance. */
|
|
1095
|
+
declare function getSelectionManager(canvasId?: string): SelectionManager | null;
|
|
1096
|
+
/** Get the highlighter for a canvas instance. */
|
|
1097
|
+
declare function getHighlighter(canvasId?: string): Highlighter | null;
|
|
1098
|
+
/** Get the inspect controller for a canvas instance. */
|
|
1099
|
+
declare function getInspectController(canvasId?: string): InspectController | null;
|
|
1100
|
+
/** List all active canvas IDs. */
|
|
1101
|
+
declare function getCanvasIds(): string[];
|
|
1102
|
+
declare function ThreeDom({ canvasId, primary, root, mode, filter, batchSize, syncBudgetMs, maxDomNodes, initialDepth, enabled, debug, inspect: inspectProp, }?: ThreeDomProps): null;
|
|
676
1103
|
|
|
677
1104
|
/**
|
|
678
1105
|
* Patch Object3D.prototype.add and Object3D.prototype.remove to intercept
|
|
@@ -682,7 +1109,7 @@ declare function ThreeDom({ root, batchSize, timeBudgetMs, maxDomNodes, initialD
|
|
|
682
1109
|
* @param mirror - The DomMirror managing the parallel DOM tree
|
|
683
1110
|
* @returns A cleanup function that unregisters this store/mirror pair
|
|
684
1111
|
*/
|
|
685
|
-
declare function patchObject3D(store: ObjectStore, mirror: DomMirror): () => void;
|
|
1112
|
+
declare function patchObject3D(store: ObjectStore, mirror: DomMirror, instanceKey?: string): () => void;
|
|
686
1113
|
/**
|
|
687
1114
|
* Restore the original Object3D.prototype.add and remove methods.
|
|
688
1115
|
* Called automatically when the last store/mirror pair is removed.
|
|
@@ -724,6 +1151,16 @@ declare function createFlatSnapshot(store: ObjectStore): {
|
|
|
724
1151
|
objects: ObjectMetadata[];
|
|
725
1152
|
};
|
|
726
1153
|
|
|
1154
|
+
/**
|
|
1155
|
+
* @module projection
|
|
1156
|
+
*
|
|
1157
|
+
* Projects Three.js objects from world space to screen-space CSS pixel
|
|
1158
|
+
* coordinates using a multi-strategy approach (bbox center → face centers →
|
|
1159
|
+
* corners → origin fallback). Also provides frustum visibility checks and
|
|
1160
|
+
* screen-to-world conversion for drag deltas. Core utility used by all
|
|
1161
|
+
* interaction modules to determine where to dispatch synthetic events.
|
|
1162
|
+
*/
|
|
1163
|
+
|
|
727
1164
|
/** Screen-space coordinates in CSS pixels relative to the canvas. */
|
|
728
1165
|
interface ScreenPoint {
|
|
729
1166
|
/** X coordinate in CSS pixels, left = 0. */
|
|
@@ -782,6 +1219,15 @@ declare function screenDeltaToWorld(dx: number, dy: number, obj: Object3D, camer
|
|
|
782
1219
|
*/
|
|
783
1220
|
declare function projectAllSamplePoints(obj: Object3D, camera: Camera, size: CanvasSize): ScreenPoint[];
|
|
784
1221
|
|
|
1222
|
+
/**
|
|
1223
|
+
* @module raycastVerify
|
|
1224
|
+
*
|
|
1225
|
+
* Post-dispatch raycast verification for interaction modules. After a synthetic
|
|
1226
|
+
* event is dispatched at projected screen coordinates, casts a ray to confirm
|
|
1227
|
+
* the intended object is actually the frontmost hit. Reports occlusion with
|
|
1228
|
+
* the identity of the occluding object for clear error messages.
|
|
1229
|
+
*/
|
|
1230
|
+
|
|
785
1231
|
/** Result of a raycast verification. */
|
|
786
1232
|
interface RaycastResult {
|
|
787
1233
|
/** Whether the intended object was hit. */
|
|
@@ -933,6 +1379,15 @@ declare function hover3D(idOrUuid: string, options?: Hover3DOptions): Hover3DRes
|
|
|
933
1379
|
*/
|
|
934
1380
|
declare function unhover3D(): void;
|
|
935
1381
|
|
|
1382
|
+
/**
|
|
1383
|
+
* @module dispatch
|
|
1384
|
+
*
|
|
1385
|
+
* Low-level synthetic PointerEvent/MouseEvent/WheelEvent dispatch on the
|
|
1386
|
+
* canvas element. Produces the exact DOM event sequences that R3F's internal
|
|
1387
|
+
* event system expects (e.g. pointerdown → pointerup → click). All higher-level
|
|
1388
|
+
* interaction modules (click3D, hover3D, drag3D, etc.) delegate here.
|
|
1389
|
+
*/
|
|
1390
|
+
|
|
936
1391
|
/**
|
|
937
1392
|
* Dispatch a full click sequence on the canvas at the given screen point.
|
|
938
1393
|
*
|
|
@@ -1016,6 +1471,15 @@ declare function dispatchPointerMiss(canvas: HTMLCanvasElement, point?: ScreenPo
|
|
|
1016
1471
|
*/
|
|
1017
1472
|
declare function dispatchUnhover(canvas: HTMLCanvasElement): void;
|
|
1018
1473
|
|
|
1474
|
+
/**
|
|
1475
|
+
* @module drag
|
|
1476
|
+
*
|
|
1477
|
+
* Deterministic drag interactions on 3D objects. Supports world-space deltas
|
|
1478
|
+
* (move N units along an axis) and screen-space deltas (move N pixels).
|
|
1479
|
+
* Projects start/end points and dispatches a full pointerdown → pointermove × N
|
|
1480
|
+
* → pointerup sequence on the canvas.
|
|
1481
|
+
*/
|
|
1482
|
+
|
|
1019
1483
|
/** World-space drag delta. */
|
|
1020
1484
|
interface WorldDelta {
|
|
1021
1485
|
x: number;
|
|
@@ -1313,10 +1777,51 @@ declare function circlePath(center: {
|
|
|
1313
1777
|
y: number;
|
|
1314
1778
|
}, radiusX: number, radiusY?: number, steps?: number, pressure?: number): DrawPoint[];
|
|
1315
1779
|
|
|
1780
|
+
/**
|
|
1781
|
+
* @module resolve
|
|
1782
|
+
*
|
|
1783
|
+
* Shared resolution helpers for all interaction modules. Caches references
|
|
1784
|
+
* to the current ObjectStore, Camera, WebGLRenderer, and canvas size (set
|
|
1785
|
+
* by ThreeDom each frame) so interaction functions can resolve objects and
|
|
1786
|
+
* access rendering state without prop-drilling.
|
|
1787
|
+
*/
|
|
1788
|
+
|
|
1316
1789
|
/**
|
|
1317
1790
|
* Resolve a testId or uuid to a live Object3D reference.
|
|
1318
1791
|
* Throws a descriptive error if the object is not found.
|
|
1319
1792
|
*/
|
|
1320
1793
|
declare function resolveObject(idOrUuid: string): Object3D;
|
|
1321
1794
|
|
|
1322
|
-
|
|
1795
|
+
/**
|
|
1796
|
+
* Registers a Three.js object with the react-three-dom bridge on mount and
|
|
1797
|
+
* unregisters it on unmount. Works in both `auto` and `manual` mode.
|
|
1798
|
+
*
|
|
1799
|
+
* - In `manual` mode this is the primary way to opt objects into the mirror DOM.
|
|
1800
|
+
* - In `auto` mode it can force-register objects excluded by a `filter`.
|
|
1801
|
+
* - Handles `ref.current` identity changes automatically.
|
|
1802
|
+
* - If the bridge isn't ready on mount, retries each frame until available.
|
|
1803
|
+
* - Supports multi-canvas via the optional `canvasId` parameter.
|
|
1804
|
+
*
|
|
1805
|
+
* @param ref - Ref to the Three.js object to register
|
|
1806
|
+
* @param canvasId - Optional canvas ID for multi-canvas setups. When omitted,
|
|
1807
|
+
* uses the primary bridge (`window.__R3F_DOM__`).
|
|
1808
|
+
*
|
|
1809
|
+
* @example
|
|
1810
|
+
* ```tsx
|
|
1811
|
+
* function Wall({ geometry }) {
|
|
1812
|
+
* const ref = useRef<Mesh>(null!);
|
|
1813
|
+
* useR3FRegister(ref);
|
|
1814
|
+
* return <mesh ref={ref} geometry={geometry} userData={{ testId: 'wall' }} />;
|
|
1815
|
+
* }
|
|
1816
|
+
*
|
|
1817
|
+
* // Multi-canvas
|
|
1818
|
+
* function Overlay() {
|
|
1819
|
+
* const ref = useRef<Mesh>(null!);
|
|
1820
|
+
* useR3FRegister(ref, 'overlay');
|
|
1821
|
+
* return <mesh ref={ref} />;
|
|
1822
|
+
* }
|
|
1823
|
+
* ```
|
|
1824
|
+
*/
|
|
1825
|
+
declare function useR3FRegister(ref: React.RefObject<Object3D | null>, canvasId?: string): void;
|
|
1826
|
+
|
|
1827
|
+
export { type CameraState, type CanvasSize, type Click3DOptions, type Click3DResult, DomMirror, type Drag3DOptions, type Drag3DResult, type DragOptions, type DrawPathOptions, type DrawPathResult, type DrawPoint, type GeometryInspection, Highlighter, type HighlighterOptions, type Hover3DOptions, type Hover3DResult, InspectController, type InspectOptions, MANAGED_ATTRIBUTES, type MaterialInspection, type ObjectInspection, type ObjectMetadata, ObjectStore, type PointerMiss3DOptions, type ProjectionResult, type R3FDOM, RaycastAccelerator, type RaycastResult, type SceneSnapshot, type ScreenDelta, type ScreenPoint, type SelectionListener, SelectionManager, type SnapshotNode, type StoreEvent, type StoreEventType, type StoreListener, TAG_MAP, ThreeDom, type ThreeDomProps, ThreeElement, type ThreeTagName, type Wheel3DOptions, type Wheel3DResult, type WheelOptions, type WorldDelta, applyAttributes, circlePath, click3D, computeAttributes, contextMenu3D, createFlatSnapshot, createSnapshot, curvePath, dispatchClick, dispatchContextMenu, dispatchDoubleClick, dispatchDrag, dispatchHover, dispatchPointerMiss, dispatchUnhover, dispatchWheel, doubleClick3D, drag3D, drawPath, enableDebug, ensureCustomElements, getCanvasIds, getHighlighter, getInspectController, getMirror, getSelectionManager, getStore, getTagForType, hover3D, isDebugEnabled, isInFrustum, isPatched, linePath, patchObject3D, pointerMiss3D, previewDragWorldDelta, projectAllSamplePoints, projectToScreen, r3fLog, rectPath, resolveObject, restoreObject3D, screenDeltaToWorld, unhover3D, useR3FRegister, verifyRaycastHit, verifyRaycastHitMultiPoint, version, wheel3D };
|