@react-three/fiber 8.0.0-alpha.0 → 8.0.0-beta-01

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/declarations/src/core/events.d.ts +63 -59
  3. package/dist/declarations/src/core/hooks.d.ts +21 -29
  4. package/dist/declarations/src/core/loop.d.ts +12 -12
  5. package/dist/declarations/src/core/renderer.d.ts +50 -52
  6. package/dist/declarations/src/core/store.d.ts +111 -106
  7. package/dist/declarations/src/core/utils.d.ts +43 -0
  8. package/dist/declarations/src/index.d.ts +7 -7
  9. package/dist/declarations/src/native/Canvas.d.ts +16 -0
  10. package/dist/declarations/src/native/events.d.ts +6 -0
  11. package/dist/declarations/src/native/hooks.d.ts +9 -0
  12. package/dist/declarations/src/native/index.d.ts +37 -0
  13. package/dist/declarations/src/native.d.ts +7 -0
  14. package/dist/declarations/src/three-types.d.ts +320 -320
  15. package/dist/declarations/src/web/Canvas.d.ts +13 -13
  16. package/dist/declarations/src/web/events.d.ts +5 -4
  17. package/dist/declarations/src/web/index.d.ts +34 -30
  18. package/dist/hooks-c89a6f88.esm.js +1455 -0
  19. package/dist/hooks-dd693347.cjs.dev.js +1501 -0
  20. package/dist/hooks-e01f12ec.cjs.prod.js +1501 -0
  21. package/dist/react-three-fiber.cjs.dev.js +142 -1551
  22. package/dist/react-three-fiber.cjs.prod.js +142 -1551
  23. package/dist/react-three-fiber.esm.js +123 -1529
  24. package/native/dist/react-three-fiber-native.cjs.d.ts +1 -0
  25. package/native/dist/react-three-fiber-native.cjs.dev.js +590 -0
  26. package/native/dist/react-three-fiber-native.cjs.js +7 -0
  27. package/native/dist/react-three-fiber-native.cjs.prod.js +590 -0
  28. package/native/dist/react-three-fiber-native.esm.js +538 -0
  29. package/native/package.json +5 -0
  30. package/package.json +16 -6
  31. package/__mocks__/react-use-measure/index.ts +0 -22
  32. package/dist/declarations/src/core/is.d.ts +0 -9
@@ -2,16 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var hooks = require('./hooks-dd693347.cjs.dev.js');
5
6
  var THREE = require('three');
6
7
  var React = require('react');
7
8
  var constants = require('react-reconciler/constants');
8
- var create = require('zustand');
9
- var shallow = require('zustand/shallow');
10
- var Reconciler = require('react-reconciler');
11
- var scheduler = require('scheduler');
12
- var useAsset = require('use-asset');
9
+ var _extends = require('@babel/runtime/helpers/extends');
13
10
  var mergeRefs = require('react-merge-refs');
14
11
  var useMeasure = require('react-use-measure');
12
+ var pick = require('lodash-es/pick');
13
+ var omit = require('lodash-es/omit');
14
+ require('react-reconciler');
15
+ require('suspend-react');
16
+ require('zustand');
15
17
 
16
18
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
17
19
 
@@ -24,1410 +26,77 @@ function _interopNamespace(e) {
24
26
  var d = Object.getOwnPropertyDescriptor(e, k);
25
27
  Object.defineProperty(n, k, d.get ? d : {
26
28
  enumerable: true,
27
- get: function () {
28
- return e[k];
29
- }
29
+ get: function () { return e[k]; }
30
30
  });
31
31
  }
32
32
  });
33
33
  }
34
- n['default'] = e;
34
+ n["default"] = e;
35
35
  return Object.freeze(n);
36
36
  }
37
37
 
38
38
  var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
39
39
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
40
- var create__default = /*#__PURE__*/_interopDefault(create);
41
- var shallow__default = /*#__PURE__*/_interopDefault(shallow);
42
- var Reconciler__default = /*#__PURE__*/_interopDefault(Reconciler);
43
40
  var mergeRefs__default = /*#__PURE__*/_interopDefault(mergeRefs);
44
41
  var useMeasure__default = /*#__PURE__*/_interopDefault(useMeasure);
45
-
46
- var threeTypes = /*#__PURE__*/Object.freeze({
47
- __proto__: null
48
- });
49
-
50
- const is = {
51
- obj: a => a === Object(a) && !is.arr(a) && typeof a !== 'function',
52
- fun: a => typeof a === 'function',
53
- str: a => typeof a === 'string',
54
- num: a => typeof a === 'number',
55
- und: a => a === void 0,
56
- arr: a => Array.isArray(a),
57
-
58
- equ(a, b) {
59
- // Wrong type or one of the two undefined, doesn't match
60
- if (typeof a !== typeof b || !!a !== !!b) return false; // Atomic, just compare a against b
61
-
62
- if (is.str(a) || is.num(a) || is.obj(a)) return a === b; // Array, shallow compare first to see if it's a match
63
-
64
- if (is.arr(a) && a == b) return true; // Last resort, go through keys
65
-
66
- let i;
67
-
68
- for (i in a) if (!(i in b)) return false;
69
-
70
- for (i in b) if (a[i] !== b[i]) return false;
71
-
72
- return is.und(i) ? a === b : true;
73
- }
74
-
75
- };
76
-
77
- function makeId(event) {
78
- return (event.eventObject || event.object).uuid + '/' + event.index;
79
- }
80
-
81
- function removeInteractivity(store, object) {
82
- const {
83
- internal
84
- } = store.getState(); // Removes every trace of an object from the data store
85
-
86
- internal.interaction = internal.interaction.filter(o => o !== object);
87
- internal.initialHits = internal.initialHits.filter(o => o !== object);
88
- internal.hovered.forEach((value, key) => {
89
- if (value.eventObject === object || value.object === object) {
90
- internal.hovered.delete(key);
91
- }
92
- });
93
- }
94
- function createEvents(store) {
95
- const temp = new THREE__namespace.Vector3();
96
- /** Sets up defaultRaycaster */
97
-
98
- function prepareRay(event) {
99
- var _raycaster$computeOff;
100
-
101
- const state = store.getState();
102
- const {
103
- raycaster,
104
- mouse,
105
- camera,
106
- size
107
- } = state; // https://github.com/pmndrs/react-three-fiber/pull/782
108
- // Events trigger outside of canvas when moved
109
-
110
- const {
111
- offsetX,
112
- offsetY
113
- } = (_raycaster$computeOff = raycaster.computeOffsets == null ? void 0 : raycaster.computeOffsets(event, state)) != null ? _raycaster$computeOff : event;
114
- const {
115
- width,
116
- height
117
- } = size;
118
- mouse.set(offsetX / width * 2 - 1, -(offsetY / height) * 2 + 1);
119
- raycaster.setFromCamera(mouse, camera);
120
- }
121
- /** Calculates delta */
122
-
123
-
124
- function calculateDistance(event) {
125
- const {
126
- internal
127
- } = store.getState();
128
- const dx = event.offsetX - internal.initialClick[0];
129
- const dy = event.offsetY - internal.initialClick[1];
130
- return Math.round(Math.sqrt(dx * dx + dy * dy));
131
- }
132
- /** Returns true if an instance has a valid pointer-event registered, this excludes scroll, clicks etc */
133
-
134
-
135
- function filterPointerEvents(objects) {
136
- return objects.filter(obj => ['Move', 'Over', 'Enter', 'Out', 'Leave'].some(name => {
137
- var _r3f$handlers;
138
-
139
- return (_r3f$handlers = obj.__r3f.handlers) == null ? void 0 : _r3f$handlers['onPointer' + name];
140
- }));
141
- }
142
-
143
- function intersect(filter) {
144
- const state = store.getState();
145
- const {
146
- raycaster,
147
- internal
148
- } = state; // Skip event handling when noEvents is set
149
-
150
- if (!raycaster.enabled) return [];
151
- const seen = new Set();
152
- const intersections = []; // Allow callers to eliminate event objects
153
-
154
- const eventsObjects = filter ? filter(internal.interaction) : internal.interaction; // Intersect known handler objects and filter against duplicates
155
-
156
- let intersects = raycaster.intersectObjects(eventsObjects, true).filter(item => {
157
- const id = makeId(item);
158
- if (seen.has(id)) return false;
159
- seen.add(id);
160
- return true;
161
- }); // https://github.com/mrdoob/three.js/issues/16031
162
- // Allow custom userland intersect sort order
163
-
164
- if (raycaster.filter) intersects = raycaster.filter(intersects, state);
165
-
166
- for (const intersect of intersects) {
167
- let eventObject = intersect.object; // Bubble event up
168
-
169
- while (eventObject) {
170
- var _r3f;
171
-
172
- const handlers = (_r3f = eventObject.__r3f) == null ? void 0 : _r3f.handlers;
173
- if (handlers) intersections.push({ ...intersect,
174
- eventObject
175
- });
176
- eventObject = eventObject.parent;
177
- }
178
- }
179
-
180
- return intersections;
181
- }
182
- /** Creates filtered intersects and returns an array of positive hits */
183
-
184
-
185
- function patchIntersects(intersections, event) {
186
- const {
187
- internal
188
- } = store.getState(); // If the interaction is captured, make all capturing targets part of the
189
- // intersect.
190
-
191
- if ('pointerId' in event && internal.capturedMap.has(event.pointerId)) {
192
- intersections.push(...internal.capturedMap.get(event.pointerId).values());
193
- }
194
-
195
- return intersections;
196
- }
197
- /** Handles intersections by forwarding them to handlers */
198
-
199
-
200
- function handleIntersects(intersections, event, callback) {
201
- const {
202
- raycaster,
203
- mouse,
204
- camera,
205
- internal
206
- } = store.getState(); // If anything has been found, forward it to the event listeners
207
-
208
- if (intersections.length) {
209
- const unprojectedPoint = temp.set(mouse.x, mouse.y, 0).unproject(camera);
210
- const delta = event.type === 'click' ? calculateDistance(event) : 0;
211
-
212
- const releasePointerCapture = id => event.target.releasePointerCapture(id);
213
-
214
- const localState = {
215
- stopped: false
216
- };
217
-
218
- for (const hit of intersections) {
219
- const hasPointerCapture = id => {
220
- var _internal$capturedMap, _internal$capturedMap2;
221
-
222
- return (_internal$capturedMap = (_internal$capturedMap2 = internal.capturedMap.get(id)) == null ? void 0 : _internal$capturedMap2.has(hit.eventObject)) != null ? _internal$capturedMap : false;
223
- };
224
-
225
- const setPointerCapture = id => {
226
- if (internal.capturedMap.has(id)) {
227
- // if the pointerId was previously captured, we add the hit to the
228
- // event capturedMap.
229
- internal.capturedMap.get(id).set(hit.eventObject, hit);
230
- } else {
231
- // if the pointerId was not previously captured, we create a map
232
- // containing the hitObject, and the hit. hitObject is used for
233
- // faster access.
234
- internal.capturedMap.set(id, new Map([[hit.eventObject, hit]]));
235
- } // Call the original event now
236
- event.target.setPointerCapture(id);
237
- }; // Add native event props
238
-
239
-
240
- let extractEventProps = {};
241
-
242
- for (let prop in Object.getPrototypeOf(event)) {
243
- let property = event[prop]; // Only copy over atomics, leave functions alone as these should be
244
- // called as event.nativeEvent.fn()
245
-
246
- if (typeof property !== 'function') extractEventProps[prop] = property;
247
- }
248
-
249
- let raycastEvent = { ...hit,
250
- ...extractEventProps,
251
- spaceX: mouse.x,
252
- spaceY: mouse.y,
253
- intersections,
254
- stopped: localState.stopped,
255
- delta,
256
- unprojectedPoint,
257
- ray: raycaster.ray,
258
- camera: camera,
259
- // Hijack stopPropagation, which just sets a flag
260
- stopPropagation: () => {
261
- // https://github.com/pmndrs/react-three-fiber/issues/596
262
- // Events are not allowed to stop propagation if the pointer has been captured
263
- const capturesForPointer = 'pointerId' in event && internal.capturedMap.get(event.pointerId); // We only authorize stopPropagation...
264
-
265
- if ( // ...if this pointer hasn't been captured
266
- !capturesForPointer || // ... or if the hit object is capturing the pointer
267
- capturesForPointer.has(hit.eventObject)) {
268
- raycastEvent.stopped = localState.stopped = true; // Propagation is stopped, remove all other hover records
269
- // An event handler is only allowed to flush other handlers if it is hovered itself
270
-
271
- if (internal.hovered.size && Array.from(internal.hovered.values()).find(i => i.eventObject === hit.eventObject)) {
272
- // Objects cannot flush out higher up objects that have already caught the event
273
- const higher = intersections.slice(0, intersections.indexOf(hit));
274
- cancelPointer([...higher, hit]);
275
- }
276
- }
277
- },
278
- // there should be a distinction between target and currentTarget
279
- target: {
280
- hasPointerCapture,
281
- setPointerCapture,
282
- releasePointerCapture
283
- },
284
- currentTarget: {
285
- hasPointerCapture,
286
- setPointerCapture,
287
- releasePointerCapture
288
- },
289
- sourceEvent: event,
290
- // deprecated
291
- nativeEvent: event
292
- }; // Call subscribers
293
-
294
- callback(raycastEvent); // Event bubbling may be interrupted by stopPropagation
295
-
296
- if (localState.stopped === true) break;
297
- }
298
- }
299
-
300
- return intersections;
301
- }
302
-
303
- function cancelPointer(hits) {
304
- const {
305
- internal
306
- } = store.getState();
307
- Array.from(internal.hovered.values()).forEach(hoveredObj => {
308
- // When no objects were hit or the the hovered object wasn't found underneath the cursor
309
- // we call onPointerOut and delete the object from the hovered-elements map
310
- if (!hits.length || !hits.find(hit => hit.object === hoveredObj.object && hit.index === hoveredObj.index)) {
311
- const eventObject = hoveredObj.eventObject;
312
- const handlers = eventObject.__r3f.handlers;
313
- internal.hovered.delete(makeId(hoveredObj));
314
-
315
- if (handlers) {
316
- // Clear out intersects, they are outdated by now
317
- const data = { ...hoveredObj,
318
- intersections: hits || []
319
- };
320
- handlers.onPointerOut == null ? void 0 : handlers.onPointerOut(data);
321
- handlers.onPointerLeave == null ? void 0 : handlers.onPointerLeave(data);
322
- }
323
- }
324
- });
325
- }
326
-
327
- const handlePointer = name => {
328
- // Deal with cancelation
329
- switch (name) {
330
- case 'onPointerLeave':
331
- case 'onPointerCancel':
332
- return () => cancelPointer([]);
333
-
334
- case 'onLostPointerCapture':
335
- return event => {
336
- if ('pointerId' in event) {
337
- // this will be a problem if one target releases the pointerId
338
- // and another one is still keeping it, as the line below
339
- // indifferently deletes all capturing references.
340
- store.getState().internal.capturedMap.delete(event.pointerId);
341
- }
342
-
343
- cancelPointer([]);
344
- };
345
- } // Any other pointer goes here ...
346
-
347
-
348
- return event => {
349
- const {
350
- onPointerMissed,
351
- internal
352
- } = store.getState();
353
- prepareRay(event); // Get fresh intersects
354
-
355
- const isPointerMove = name === 'onPointerMove';
356
- const filter = isPointerMove ? filterPointerEvents : undefined;
357
- const hits = patchIntersects(intersect(filter), event); // Take care of unhover
358
-
359
- if (isPointerMove) cancelPointer(hits);
360
- handleIntersects(hits, event, data => {
361
- const eventObject = data.eventObject;
362
- const handlers = eventObject.__r3f.handlers; // Check presence of handlers
363
-
364
- if (!handlers) return;
365
-
366
- if (isPointerMove) {
367
- // Move event ...
368
- if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
369
- // When enter or out is present take care of hover-state
370
- const id = makeId(data);
371
- const hoveredItem = internal.hovered.get(id);
372
-
373
- if (!hoveredItem) {
374
- // If the object wasn't previously hovered, book it and call its handler
375
- internal.hovered.set(id, data);
376
- handlers.onPointerOver == null ? void 0 : handlers.onPointerOver(data);
377
- handlers.onPointerEnter == null ? void 0 : handlers.onPointerEnter(data);
378
- } else if (hoveredItem.stopped) {
379
- // If the object was previously hovered and stopped, we shouldn't allow other items to proceed
380
- data.stopPropagation();
381
- }
382
- } // Call mouse move
383
-
384
-
385
- handlers.onPointerMove == null ? void 0 : handlers.onPointerMove(data);
386
- } else {
387
- // All other events ...
388
- const handler = handlers == null ? void 0 : handlers[name];
389
-
390
- if (handler) {
391
- // Forward all events back to their respective handlers with the exception of click events,
392
- // which must use the initial target
393
- if (name !== 'onClick' && name !== 'onContextMenu' && name !== 'onDoubleClick' || internal.initialHits.includes(eventObject)) {
394
- handler(data);
395
- pointerMissed(event, internal.interaction.filter(object => object !== eventObject));
396
- }
397
- }
398
- }
399
- }); // Save initial coordinates on pointer-down
400
-
401
- if (name === 'onPointerDown') {
402
- internal.initialClick = [event.offsetX, event.offsetY];
403
- internal.initialHits = hits.map(hit => hit.eventObject);
404
- } // If a click yields no results, pass it back to the user as a miss
405
-
406
-
407
- if ((name === 'onClick' || name === 'onContextMenu' || name === 'onDoubleClick') && !hits.length) {
408
- if (calculateDistance(event) <= 2) {
409
- pointerMissed(event, internal.interaction);
410
- if (onPointerMissed) onPointerMissed(event);
411
- }
412
- }
413
- };
414
- };
415
-
416
- function pointerMissed(event, objects) {
417
- objects.forEach(object => {
418
- var _r3f$handlers2;
419
-
420
- return (_r3f$handlers2 = object.__r3f.handlers) == null ? void 0 : _r3f$handlers2.onPointerMissed == null ? void 0 : _r3f$handlers2.onPointerMissed(event);
421
- });
422
- }
423
-
424
- return {
425
- handlePointer
426
- };
427
- }
428
-
429
- // Type guard to tell a store from a portal
430
- const isStore = def => def && !!def.getState;
431
-
432
- const getContainer = (container, child) => {
433
- var _container$__r3f$root, _container$__r3f;
434
-
435
- return {
436
- // If the container is not a root-store then it must be a THREE.Object3D into which part of the
437
- // scene is portalled into. Now there can be two variants of this, either that object is part of
438
- // the regular jsx tree, in which case it already has __r3f with a valid root attached, or it lies
439
- // outside react, in which case we must take the root of the child that is about to be attached to it.
440
- root: isStore(container) ? container : (_container$__r3f$root = (_container$__r3f = container.__r3f) == null ? void 0 : _container$__r3f.root) != null ? _container$__r3f$root : child.__r3f.root,
441
- // The container is the eventual target into which objects are mounted, it has to be a THREE.Object3D
442
- container: isStore(container) ? container.getState().scene : container
443
- };
444
- };
445
-
446
- const DEFAULT = '__default';
447
- const EMPTY = {};
448
- const FILTER = ['children', 'key', 'ref'];
449
- let catalogue = {};
450
-
451
- let extend = objects => void (catalogue = { ...catalogue,
452
- ...objects
453
- }); // Each object in the scene carries a small LocalState descriptor
454
-
455
-
456
- function prepare(object, state) {
457
- const instance = object;
458
-
459
- if (state != null && state.instance || !instance.__r3f) {
460
- instance.__r3f = {
461
- root: null,
462
- memoizedProps: {},
463
- objects: [],
464
- ...state
465
- };
466
- }
467
-
468
- return object;
469
- }
470
-
471
- function createRenderer(roots) {
472
- function applyProps(instance, newProps, oldProps = {}, accumulative = false) {
473
- var _instance$__r3f, _root$getState, _instance$__r3f2;
474
-
475
- // Filter equals, events and reserved props
476
- const localState = (_instance$__r3f = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f : {};
477
- const root = localState.root;
478
- const rootState = (_root$getState = root == null ? void 0 : root.getState == null ? void 0 : root.getState()) != null ? _root$getState : {};
479
- const sameProps = [];
480
- const handlers = [];
481
- const newMemoizedProps = {};
482
- let i = 0;
483
- Object.entries(newProps).forEach(([key, entry]) => {
484
- // we don't want children, ref or key in the memoized props
485
- if (FILTER.indexOf(key) === -1) {
486
- newMemoizedProps[key] = entry;
487
- }
488
- });
489
-
490
- if (localState.memoizedProps && localState.memoizedProps.args) {
491
- newMemoizedProps.args = localState.memoizedProps.args;
492
- }
493
-
494
- if (localState.memoizedProps && localState.memoizedProps.attach) {
495
- newMemoizedProps.attach = localState.memoizedProps.attach;
496
- }
497
-
498
- if (instance.__r3f) {
499
- instance.__r3f.memoizedProps = newMemoizedProps;
500
- }
501
-
502
- let objectKeys = Object.keys(newProps);
503
-
504
- for (i = 0; i < objectKeys.length; i++) {
505
- if (is.equ(newProps[objectKeys[i]], oldProps[objectKeys[i]])) {
506
- sameProps.push(objectKeys[i]);
507
- } // Event-handlers ...
508
- // are functions, that
509
- // start with "on", and
510
- // contain the name "Pointer", "Click", "DoubleClick", "ContextMenu", or "Wheel"
511
-
512
-
513
- if (is.fun(newProps[objectKeys[i]]) && /^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(objectKeys[i])) {
514
- handlers.push(objectKeys[i]);
515
- }
516
- } // Catch props that existed, but now exist no more ...
517
-
518
-
519
- const leftOvers = [];
520
-
521
- if (accumulative) {
522
- objectKeys = Object.keys(oldProps);
523
-
524
- for (i = 0; i < objectKeys.length; i++) {
525
- if (!newProps.hasOwnProperty(objectKeys[i])) {
526
- leftOvers.push(objectKeys[i]);
527
- }
528
- }
529
- }
530
-
531
- const toFilter = [...sameProps, ...FILTER]; // Instances use "object" as a reserved identifier
532
-
533
- if ((_instance$__r3f2 = instance.__r3f) != null && _instance$__r3f2.instance) toFilter.push('object');
534
- const filteredProps = { ...newProps
535
- }; // Removes sameProps and reserved props from newProps
536
-
537
- objectKeys = Object.keys(filteredProps);
538
-
539
- for (i = 0; i < objectKeys.length; i++) {
540
- if (toFilter.indexOf(objectKeys[i]) > -1) {
541
- delete filteredProps[objectKeys[i]];
542
- }
543
- } // Collect all new props
544
-
545
-
546
- const filteredPropsEntries = Object.entries(filteredProps); // Prepend left-overs so they can be reset or removed
547
- // Left-overs must come first!
548
-
549
- for (i = 0; i < leftOvers.length; i++) {
550
- if (leftOvers[i] !== 'children') {
551
- filteredPropsEntries.unshift([leftOvers[i], DEFAULT + 'remove']);
552
- }
553
- }
554
-
555
- if (filteredPropsEntries.length > 0) {
556
- filteredPropsEntries.forEach(([key, value]) => {
557
- if (!handlers.includes(key)) {
558
- let currentInstance = instance;
559
- let targetProp = currentInstance[key];
560
-
561
- if (key.includes('-')) {
562
- const entries = key.split('-');
563
- targetProp = entries.reduce((acc, key) => acc[key], instance); // If the target is atomic, it forces us to switch the root
564
-
565
- if (!(targetProp && targetProp.set)) {
566
- const [name, ...reverseEntries] = entries.reverse();
567
- currentInstance = reverseEntries.reverse().reduce((acc, key) => acc[key], instance);
568
- key = name;
569
- }
570
- } // https://github.com/mrdoob/three.js/issues/21209
571
- // HMR/fast-refresh relies on the ability to cancel out props, but threejs
572
- // has no means to do this. Hence we curate a small collection of value-classes
573
- // with their respective constructor/set arguments
574
- // For removed props, try to set default values, if possible
575
-
576
-
577
- if (value === DEFAULT + 'remove') {
578
- if (targetProp && targetProp.constructor) {
579
- // use the prop constructor to find the default it should be
580
- value = new targetProp.constructor(newMemoizedProps.args);
581
- } else if (currentInstance.constructor) {
582
- // create a blank slate of the instance and copy the particular parameter.
583
- // @ts-ignore
584
- const defaultClassCall = new currentInstance.constructor(currentInstance.__r3f.memoizedProps.args);
585
- value = defaultClassCall[targetProp]; // destory the instance
586
-
587
- if (defaultClassCall.dispose) {
588
- defaultClassCall.dispose();
589
- }
590
- } else {
591
- // instance does not have constructor, just set it to 0
592
- value = 0;
593
- }
594
- } // Special treatment for objects with support for set/copy, and layers
595
-
596
-
597
- if (targetProp && targetProp.set && (targetProp.copy || targetProp instanceof THREE__namespace.Layers)) {
598
- // If value is an array
599
- if (Array.isArray(value)) {
600
- if (targetProp.fromArray) {
601
- targetProp.fromArray(value);
602
- } else {
603
- targetProp.set(...value);
604
- }
605
- } // Test again target.copy(class) next ...
606
- else if (targetProp.copy && value && value.constructor && targetProp.constructor.name === value.constructor.name) {
607
- targetProp.copy(value);
608
- } // If nothing else fits, just set the single value, ignore undefined
609
- // https://github.com/react-spring/react-three-fiber/issues/274
610
- else if (value !== undefined) {
611
- const isColor = targetProp instanceof THREE__namespace.Color; // Allow setting array scalars
612
-
613
- if (!isColor && targetProp.setScalar) targetProp.setScalar(value); // Layers have no copy function, we must therefore copy the mask property
614
- else if (targetProp instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) targetProp.mask = value.mask; // Otherwise just set ...
615
- else targetProp.set(value); // Auto-convert sRGB colors, for now ...
616
- // https://github.com/react-spring/react-three-fiber/issues/344
617
-
618
- if (!rootState.linear && isColor) targetProp.convertSRGBToLinear();
619
- } // Else, just overwrite the value
620
-
621
- } else {
622
- currentInstance[key] = value; // Auto-convert sRGB textures, for now ...
623
- // https://github.com/react-spring/react-three-fiber/issues/344
624
-
625
- if (!rootState.linear && currentInstance[key] instanceof THREE__namespace.Texture) currentInstance[key].encoding = THREE__namespace.sRGBEncoding;
626
- }
627
-
628
- invalidateInstance(instance);
629
- }
630
- }); // Preemptively delete the instance from the containers interaction
631
-
632
- if (accumulative && root && instance.raycast && localState.handlers) {
633
- localState.handlers = undefined;
634
- const index = rootState.internal.interaction.indexOf(instance);
635
- if (index > -1) rootState.internal.interaction.splice(index, 1);
636
- } // Prep interaction handlers
637
-
638
-
639
- if (handlers.length) {
640
- if (accumulative && root && instance.raycast) {
641
- rootState.internal.interaction.push(instance);
642
- } // Add handlers to the instances handler-map
643
-
644
-
645
- localState.handlers = handlers.reduce((acc, key) => ({ ...acc,
646
- [key]: newProps[key]
647
- }), {});
648
- } // Call the update lifecycle when it is being updated, but only when it is part of the scene
649
-
650
-
651
- if (instance.parent) updateInstance(instance);
652
- }
653
- }
654
-
655
- function invalidateInstance(instance) {
656
- var _instance$__r3f3, _instance$__r3f3$root;
657
-
658
- const state = (_instance$__r3f3 = instance.__r3f) == null ? void 0 : (_instance$__r3f3$root = _instance$__r3f3.root) == null ? void 0 : _instance$__r3f3$root.getState == null ? void 0 : _instance$__r3f3$root.getState();
659
- if (state && state.internal.frames === 0) state.invalidate();
660
- }
661
-
662
- function updateInstance(instance) {
663
- instance.onUpdate == null ? void 0 : instance.onUpdate(instance);
664
- }
665
-
666
- function createInstance(type, {
667
- args = [],
668
- ...props
669
- }, root, hostContext, internalInstanceHandle) {
670
- let name = `${type[0].toUpperCase()}${type.slice(1)}`;
671
- let instance; // https://github.com/facebook/react/issues/17147
672
- // Portals do not give us a root, they are themselves treated as a root by the reconciler
673
- // In order to figure out the actual root we have to climb through fiber internals :(
674
-
675
- if (!isStore(root) && internalInstanceHandle) {
676
- const fn = node => {
677
- if (!node.return) return node.stateNode && node.stateNode.containerInfo;else return fn(node.return);
678
- };
679
-
680
- root = fn(internalInstanceHandle);
681
- } // Assert that by now we have a valid root
682
-
683
-
684
- if (!root || !isStore(root)) throw `No valid root for ${name}!`;
685
-
686
- if (type === 'primitive') {
687
- if (props.object === undefined) throw `Primitives without 'object' are invalid!`;
688
- const object = props.object;
689
- instance = prepare(object, {
690
- root,
691
- instance: true
692
- });
693
- } else {
694
- const target = catalogue[name] || THREE__namespace[name];
695
- if (!target) throw `${name} is not part of the THREE namespace! Did you forget to extend? See: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#using-3rd-party-objects-declaratively`;
696
- const isArgsArr = is.arr(args); // Instanciate new object, link it to the root
697
-
698
- instance = prepare(isArgsArr ? new target(...args) : new target(args), {
699
- root,
700
- // append memoized props with args so it's not forgotten
701
- memoizedProps: {
702
- args: isArgsArr && args.length === 0 ? null : args
703
- }
704
- });
705
- } // Auto-attach geometries and materials
706
-
707
-
708
- if (!('attachFns' in props)) {
709
- if (name.endsWith('Geometry')) {
710
- props = {
711
- attach: 'geometry',
712
- ...props
713
- };
714
- } else if (name.endsWith('Material')) {
715
- props = {
716
- attach: 'material',
717
- ...props
718
- };
719
- }
720
- } // It should NOT call onUpdate on object instanciation, because it hasn't been added to the
721
- // view yet. If the callback relies on references for instance, they won't be ready yet, this is
722
- // why it passes "true" here
723
-
724
-
725
- applyProps(instance, props, {});
726
- return instance;
727
- }
728
-
729
- function appendChild(parentInstance, child) {
730
- let addedAsChild = false;
731
-
732
- if (child) {
733
- // The attach attribute implies that the object attaches itself on the parent
734
- if (child.attachArray) {
735
- if (!is.arr(parentInstance[child.attachArray])) parentInstance[child.attachArray] = [];
736
- parentInstance[child.attachArray].push(child);
737
- } else if (child.attachObject) {
738
- if (!is.obj(parentInstance[child.attachObject[0]])) parentInstance[child.attachObject[0]] = {};
739
- parentInstance[child.attachObject[0]][child.attachObject[1]] = child;
740
- } else if (child.attach && !is.fun(child.attach)) {
741
- parentInstance[child.attach] = child;
742
- } else if (is.arr(child.attachFns)) {
743
- const [attachFn] = child.attachFns;
744
-
745
- if (is.str(attachFn) && is.fun(parentInstance[attachFn])) {
746
- parentInstance[attachFn](child);
747
- } else if (is.fun(attachFn)) {
748
- attachFn(child, parentInstance);
749
- }
750
- } else if (child.isObject3D) {
751
- // add in the usual parent-child way
752
- parentInstance.add(child);
753
- addedAsChild = true;
754
- }
755
-
756
- if (!addedAsChild) {
757
- // This is for anything that used attach, and for non-Object3Ds that don't get attached to props;
758
- // that is, anything that's a child in React but not a child in the scenegraph.
759
- parentInstance.__r3f.objects.push(child);
760
-
761
- child.parent = parentInstance;
762
- }
763
-
764
- updateInstance(child);
765
- invalidateInstance(child);
766
- }
767
- }
768
-
769
- function insertBefore(parentInstance, child, beforeChild) {
770
- let added = false;
771
-
772
- if (child) {
773
- if (child.attachArray) {
774
- const array = parentInstance[child.attachArray];
775
- if (!is.arr(array)) parentInstance[child.attachArray] = [];
776
- array.splice(array.indexOf(beforeChild), 0, child);
777
- } else if (child.attachObject || child.attach && !is.fun(child.attach)) {
778
- // attach and attachObject don't have an order anyway, so just append
779
- return appendChild(parentInstance, child);
780
- } else if (child.isObject3D) {
781
- child.parent = parentInstance;
782
- child.dispatchEvent({
783
- type: 'added'
784
- });
785
- const restSiblings = parentInstance.children.filter(sibling => sibling !== child);
786
- const index = restSiblings.indexOf(beforeChild);
787
- parentInstance.children = [...restSiblings.slice(0, index), child, ...restSiblings.slice(index)];
788
- added = true;
789
- }
790
-
791
- if (!added) {
792
- parentInstance.__r3f.objects.push(child);
793
-
794
- child.parent = parentInstance;
795
- }
796
-
797
- updateInstance(child);
798
- invalidateInstance(child);
799
- }
42
+ var pick__default = /*#__PURE__*/_interopDefault(pick);
43
+ var omit__default = /*#__PURE__*/_interopDefault(omit);
44
+
45
+ // @ts-ignore
46
+ const CLICK = 'click';
47
+ const CONTEXTMENU = 'contextmenu';
48
+ const DBLCLICK = 'dblclick';
49
+ const POINTERCANCEL = 'pointercancel';
50
+ const POINTERDOWN = 'pointerdown';
51
+ const POINTERUP = 'pointerup';
52
+ const POINTERMOVE = 'pointermove';
53
+ const POINTEROUT = 'pointerout';
54
+ const POINTEROVER = 'pointerover';
55
+ const POINTERENTER = 'pointerenter';
56
+ const POINTERLEAVE = 'pointerleave';
57
+ const WHEEL = 'wheel'; // https://github.com/facebook/react/tree/main/packages/react-reconciler#getcurrenteventpriority
58
+ // Gives React a clue as to how import the current interaction is
59
+
60
+ function getEventPriority() {
61
+ var _window, _window$event;
62
+
63
+ let name = (_window = window) == null ? void 0 : (_window$event = _window.event) == null ? void 0 : _window$event.type;
64
+
65
+ switch (name) {
66
+ case CLICK:
67
+ case CONTEXTMENU:
68
+ case DBLCLICK:
69
+ case POINTERCANCEL:
70
+ case POINTERDOWN:
71
+ case POINTERUP:
72
+ return constants.DiscreteEventPriority;
73
+
74
+ case POINTERMOVE:
75
+ case POINTEROUT:
76
+ case POINTEROVER:
77
+ case POINTERENTER:
78
+ case POINTERLEAVE:
79
+ case WHEEL:
80
+ return constants.ContinuousEventPriority;
81
+
82
+ default:
83
+ return constants.DefaultEventPriority;
800
84
  }
801
-
802
- function removeRecursive(array, parent, dispose = false) {
803
- if (array) [...array].forEach(child => removeChild(parent, child, dispose));
804
- }
805
-
806
- function removeChild(parentInstance, child, dispose) {
807
- if (child) {
808
- var _child$__r3f2;
809
-
810
- if (parentInstance.__r3f.objects) {
811
- const oldLength = parentInstance.__r3f.objects.length;
812
- parentInstance.__r3f.objects = parentInstance.__r3f.objects.filter(x => x !== child);
813
- const newLength = parentInstance.__r3f.objects.length; // was it in the list?
814
-
815
- if (newLength < oldLength) {
816
- // we had also set this, so we must clear it now
817
- child.parent = null;
818
- }
819
- } // Remove attachment
820
-
821
-
822
- if (child.attachArray) {
823
- parentInstance[child.attachArray] = parentInstance[child.attachArray].filter(x => x !== child);
824
- } else if (child.attachObject) {
825
- delete parentInstance[child.attachObject[0]][child.attachObject[1]];
826
- } else if (child.attach && !is.fun(child.attach)) {
827
- parentInstance[child.attach] = null;
828
- } else if (is.arr(child.attachFns)) {
829
- const [, detachFn] = child.attachFns;
830
-
831
- if (is.str(detachFn) && is.fun(parentInstance[detachFn])) {
832
- parentInstance[detachFn](child);
833
- } else if (is.fun(detachFn)) {
834
- detachFn(child, parentInstance);
835
- }
836
- } else if (child.isObject3D) {
837
- var _child$__r3f;
838
-
839
- parentInstance.remove(child); // Remove interactivity
840
-
841
- if ((_child$__r3f = child.__r3f) != null && _child$__r3f.root) {
842
- removeInteractivity(child.__r3f.root, child);
843
- }
844
- } // Allow objects to bail out of recursive dispose alltogether by passing dispose={null}
845
- // Never dispose of primitives because their state may be kept outside of React!
846
- // In order for an object to be able to dispose it has to have
847
- // - a dispose method,
848
- // - it cannot be an <instance object={...} />
849
- // - it cannot be a THREE.Scene, because three has broken it's own api
850
- //
851
- // Since disposal is recursive, we can check the optional dispose arg, which will be undefined
852
- // when the reconciler calls it, but then carry our own check recursively
853
-
854
-
855
- const isInstance = (_child$__r3f2 = child.__r3f) == null ? void 0 : _child$__r3f2.instance;
856
- const shouldDispose = dispose === undefined ? child.dispose !== null && !isInstance : dispose; // Remove nested child objects. Primitives should not have objects and children that are
857
- // attached to them declaratively ...
858
-
859
- if (!isInstance) {
860
- var _child$__r3f3;
861
-
862
- removeRecursive((_child$__r3f3 = child.__r3f) == null ? void 0 : _child$__r3f3.objects, child, shouldDispose);
863
- removeRecursive(child.children, child, shouldDispose);
864
- } // Remove references
865
-
866
-
867
- if (child.__r3f) {
868
- delete child.__r3f.root;
869
- delete child.__r3f.objects;
870
- delete child.__r3f.handlers;
871
- delete child.__r3f.memoizedProps;
872
- if (!isInstance) delete child.__r3f;
873
- } // Dispose item whenever the reconciler feels like it
874
-
875
-
876
- if (shouldDispose && child.dispose && child.type !== 'Scene') {
877
- scheduler.unstable_runWithPriority(scheduler.unstable_IdlePriority, () => child.dispose());
878
- }
879
-
880
- invalidateInstance(parentInstance);
881
- }
882
- }
883
-
884
- function switchInstance(instance, type, newProps, fiber) {
885
- const parent = instance.parent;
886
- if (!parent) return;
887
- const newInstance = createInstance(type, newProps, instance.__r3f.root); // https://github.com/pmndrs/react-three-fiber/issues/1348
888
- // When args change the instance has to be re-constructed, which then
889
- // forces r3f to re-parent the children and non-scene objects
890
-
891
- if (instance.children) {
892
- instance.children.forEach(child => appendChild(newInstance, child));
893
- instance.children = [];
894
- }
895
-
896
- instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
897
-
898
- instance.__r3f.objects = [];
899
- removeChild(parent, instance);
900
- appendChild(parent, newInstance) // This evil hack switches the react-internal fiber node
901
- // https://github.com/facebook/react/issues/14983
902
- // https://github.com/facebook/react/pull/15021
903
- ;
904
- [fiber, fiber.alternate].forEach(fiber => {
905
- if (fiber !== null) {
906
- fiber.stateNode = newInstance;
907
-
908
- if (fiber.ref) {
909
- if (typeof fiber.ref === 'function') fiber.ref(newInstance);else fiber.ref.current = newInstance;
910
- }
911
- }
912
- });
913
- }
914
-
915
- const reconciler = Reconciler__default['default']({
916
- now: scheduler.unstable_now,
917
- createInstance,
918
- removeChild,
919
- appendChild,
920
- appendInitialChild: appendChild,
921
- insertBefore,
922
- warnsIfNotActing: true,
923
- supportsMutation: true,
924
- isPrimaryRenderer: false,
925
- getCurrentEventPriority: () => constants.DefaultEventPriority,
926
- // @ts-ignore
927
- scheduleTimeout: is.fun(setTimeout) ? setTimeout : undefined,
928
- // @ts-ignore
929
- cancelTimeout: is.fun(clearTimeout) ? clearTimeout : undefined,
930
- // @ts-ignore
931
- setTimeout: is.fun(setTimeout) ? setTimeout : undefined,
932
- // @ts-ignore
933
- clearTimeout: is.fun(clearTimeout) ? clearTimeout : undefined,
934
- noTimeout: -1,
935
- appendChildToContainer: (parentInstance, child) => {
936
- const {
937
- container,
938
- root
939
- } = getContainer(parentInstance, child); // Link current root to the default scene
940
-
941
- container.__r3f.root = root;
942
- appendChild(container, child);
943
- },
944
- removeChildFromContainer: (parentInstance, child) => {
945
- const {
946
- container
947
- } = getContainer(parentInstance, child);
948
- removeChild(container, child);
949
- },
950
- insertInContainerBefore: (parentInstance, child, beforeChild) => {
951
- const {
952
- container
953
- } = getContainer(parentInstance, child);
954
- insertBefore(container, child, beforeChild);
955
- },
956
-
957
- commitUpdate(instance, updatePayload, type, oldProps, newProps, fiber) {
958
- if (instance.__r3f.instance && newProps.object && newProps.object !== instance) {
959
- // <instance object={...} /> where the object reference has changed
960
- switchInstance(instance, type, newProps, fiber);
961
- } else {
962
- // This is a data object, let's extract critical information about it
963
- const {
964
- args: argsNew = [],
965
- ...restNew
966
- } = newProps;
967
- const {
968
- args: argsOld = [],
969
- ...restOld
970
- } = oldProps; // If it has new props or arguments, then it needs to be re-instanciated
971
-
972
- const hasNewArgs = argsNew.some((value, index) => is.obj(value) ? Object.entries(value).some(([key, val]) => val !== argsOld[index][key]) : value !== argsOld[index]);
973
-
974
- if (hasNewArgs) {
975
- // Next we create a new instance and append it again
976
- switchInstance(instance, type, newProps, fiber);
977
- } else {
978
- // Otherwise just overwrite props
979
- applyProps(instance, restNew, restOld, true);
980
- }
981
- }
982
- },
983
-
984
- hideInstance(instance) {
985
- if (instance.isObject3D) {
986
- instance.visible = false;
987
- invalidateInstance(instance);
988
- }
989
- },
990
-
991
- unhideInstance(instance, props) {
992
- if (instance.isObject3D && props.visible == null || props.visible) {
993
- instance.visible = true;
994
- invalidateInstance(instance);
995
- }
996
- },
997
-
998
- hideTextInstance() {
999
- throw new Error('Text is not allowed in the R3F tree.');
1000
- },
1001
-
1002
- getPublicInstance(instance) {
1003
- // TODO: might fix switchInstance (?)
1004
- return instance;
1005
- },
1006
-
1007
- getRootHostContext(rootContainer) {
1008
- return EMPTY;
1009
- },
1010
-
1011
- getChildHostContext(parentHostContext) {
1012
- return EMPTY;
1013
- },
1014
-
1015
- createTextInstance() {},
1016
-
1017
- finalizeInitialChildren(instance) {
1018
- // https://github.com/facebook/react/issues/20271
1019
- // Returning true will trigger commitMount
1020
- return !!instance.__r3f.handlers;
1021
- },
1022
-
1023
- commitMount(instance)
1024
- /*, type, props*/
1025
- {
1026
- // https://github.com/facebook/react/issues/20271
1027
- // This will make sure events are only added once to the central container
1028
- if (instance.raycast && instance.__r3f.handlers) instance.__r3f.root.getState().internal.interaction.push(instance);
1029
- },
1030
-
1031
- prepareUpdate() {
1032
- return EMPTY;
1033
- },
1034
-
1035
- shouldDeprioritizeSubtree() {
1036
- return false;
1037
- },
1038
-
1039
- prepareForCommit() {
1040
- return null;
1041
- },
1042
-
1043
- preparePortalMount(...args) {// noop
1044
- },
1045
-
1046
- resetAfterCommit() {// noop
1047
- },
1048
-
1049
- shouldSetTextContent() {
1050
- return false;
1051
- },
1052
-
1053
- clearContainer() {
1054
- return false;
1055
- },
1056
-
1057
- detachDeletedInstance() {// noop
1058
- }
1059
-
1060
- });
1061
- return {
1062
- reconciler,
1063
- applyProps
1064
- };
1065
- }
1066
-
1067
- const isRenderer = def => def && !!def.render;
1068
- const isOrthographicCamera = def => def && def.isOrthographicCamera;
1069
- const context = /*#__PURE__*/React__namespace.createContext(null);
1070
-
1071
- const createStore = (applyProps, invalidate, advance, props) => {
1072
- const {
1073
- gl,
1074
- size,
1075
- shadows = false,
1076
- linear = false,
1077
- flat = false,
1078
- vr = false,
1079
- orthographic = false,
1080
- frameloop = 'always',
1081
- dpr = 1,
1082
- performance,
1083
- clock = new THREE__namespace.Clock(),
1084
- raycaster: raycastOptions,
1085
- camera: cameraOptions,
1086
- onPointerMissed
1087
- } = props; // Set shadowmap
1088
-
1089
- if (shadows) {
1090
- gl.shadowMap.enabled = true;
1091
- if (typeof shadows === 'object') Object.assign(gl.shadowMap, shadows);else gl.shadowMap.type = THREE__namespace.PCFSoftShadowMap;
1092
- } // Set color management
1093
-
1094
-
1095
- if (!linear) {
1096
- if (!flat) gl.toneMapping = THREE__namespace.ACESFilmicToneMapping;
1097
- gl.outputEncoding = THREE__namespace.sRGBEncoding;
1098
- } // clock.elapsedTime is updated using advance(timestamp)
1099
-
1100
-
1101
- if (frameloop === 'never') {
1102
- clock.stop();
1103
- clock.elapsedTime = 0;
1104
- }
1105
-
1106
- const rootState = create__default['default']((set, get) => {
1107
- // Create custom raycaster
1108
- const raycaster = new THREE__namespace.Raycaster();
1109
- const {
1110
- params,
1111
- ...options
1112
- } = raycastOptions || {};
1113
- applyProps(raycaster, {
1114
- enabled: true,
1115
- ...options,
1116
- params: { ...raycaster.params,
1117
- ...params
1118
- }
1119
- }, {}); // Create default camera
1120
-
1121
- const isCamera = cameraOptions instanceof THREE__namespace.Camera;
1122
- const camera = isCamera ? cameraOptions : orthographic ? new THREE__namespace.OrthographicCamera(0, 0, 0, 0, 0.1, 1000) : new THREE__namespace.PerspectiveCamera(75, 0, 0.1, 1000);
1123
-
1124
- if (!isCamera) {
1125
- camera.position.z = 5;
1126
- if (cameraOptions) applyProps(camera, cameraOptions, {}); // Always look at center by default
1127
-
1128
- camera.lookAt(0, 0, 0);
1129
- }
1130
-
1131
- function setDpr(dpr) {
1132
- return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], window.devicePixelRatio), dpr[1]) : dpr;
1133
- }
1134
-
1135
- const initialDpr = setDpr(dpr);
1136
- const position = new THREE__namespace.Vector3();
1137
- const defaultTarget = new THREE__namespace.Vector3();
1138
-
1139
- function getCurrentViewport(camera = get().camera, target = defaultTarget, size = get().size) {
1140
- const {
1141
- width,
1142
- height
1143
- } = size;
1144
- const aspect = width / height;
1145
- const distance = camera.getWorldPosition(position).distanceTo(target);
1146
-
1147
- if (isOrthographicCamera(camera)) {
1148
- return {
1149
- width: width / camera.zoom,
1150
- height: height / camera.zoom,
1151
- factor: 1,
1152
- distance,
1153
- aspect
1154
- };
1155
- } else {
1156
- const fov = camera.fov * Math.PI / 180; // convert vertical fov to radians
1157
-
1158
- const h = 2 * Math.tan(fov / 2) * distance; // visible height
1159
-
1160
- const w = h * (width / height);
1161
- return {
1162
- width: w,
1163
- height: h,
1164
- factor: width / w,
1165
- distance,
1166
- aspect
1167
- };
1168
- }
1169
- }
1170
-
1171
- let performanceTimeout = undefined;
1172
-
1173
- const setPerformanceCurrent = current => set(state => ({
1174
- performance: { ...state.performance,
1175
- current
1176
- }
1177
- }));
1178
-
1179
- return {
1180
- gl,
1181
- set,
1182
- get,
1183
- invalidate: () => invalidate(get()),
1184
- advance: (timestamp, runGlobalEffects) => advance(timestamp, runGlobalEffects, get()),
1185
- linear,
1186
- flat,
1187
- scene: prepare(new THREE__namespace.Scene()),
1188
- camera,
1189
- controls: null,
1190
- raycaster,
1191
- clock,
1192
- mouse: new THREE__namespace.Vector2(),
1193
- vr,
1194
- frameloop,
1195
- onPointerMissed,
1196
- performance: {
1197
- current: 1,
1198
- min: 0.5,
1199
- max: 1,
1200
- debounce: 200,
1201
- ...performance,
1202
- regress: () => {
1203
- const state = get(); // Clear timeout
1204
-
1205
- if (performanceTimeout) clearTimeout(performanceTimeout); // Set lower bound performance
1206
-
1207
- if (state.performance.current !== state.performance.min) setPerformanceCurrent(state.performance.min); // Go back to upper bound performance after a while unless something regresses meanwhile
1208
-
1209
- performanceTimeout = setTimeout(() => setPerformanceCurrent(get().performance.max), state.performance.debounce);
1210
- }
1211
- },
1212
- size: {
1213
- width: 0,
1214
- height: 0
1215
- },
1216
- viewport: {
1217
- initialDpr,
1218
- dpr: initialDpr,
1219
- width: 0,
1220
- height: 0,
1221
- aspect: 0,
1222
- distance: 0,
1223
- factor: 0,
1224
- getCurrentViewport
1225
- },
1226
- setSize: (width, height) => {
1227
- const size = {
1228
- width,
1229
- height
1230
- };
1231
- set(state => ({
1232
- size,
1233
- viewport: { ...state.viewport,
1234
- ...getCurrentViewport(camera, defaultTarget, size)
1235
- }
1236
- }));
1237
- },
1238
- setDpr: dpr => set(state => ({
1239
- viewport: { ...state.viewport,
1240
- dpr: setDpr(dpr)
1241
- }
1242
- })),
1243
- events: {
1244
- connected: false
1245
- },
1246
- internal: {
1247
- active: false,
1248
- priority: 0,
1249
- frames: 0,
1250
- lastProps: props,
1251
- interaction: [],
1252
- hovered: new Map(),
1253
- subscribers: [],
1254
- initialClick: [0, 0],
1255
- initialHits: [],
1256
- capturedMap: new Map(),
1257
- subscribe: (ref, priority = 0) => {
1258
- set(({
1259
- internal
1260
- }) => ({
1261
- internal: { ...internal,
1262
- // If this subscription was given a priority, it takes rendering into its own hands
1263
- // For that reason we switch off automatic rendering and increase the manual flag
1264
- // As long as this flag is positive (there could be multiple render subscription)
1265
- // ..there can be no internal rendering at all
1266
- priority: internal.priority + (priority > 0 ? 1 : 0),
1267
- // Register subscriber and sort layers from lowest to highest, meaning,
1268
- // highest priority renders last (on top of the other frames)
1269
- subscribers: [...internal.subscribers, {
1270
- ref,
1271
- priority
1272
- }].sort((a, b) => a.priority - b.priority)
1273
- }
1274
- }));
1275
- return () => {
1276
- set(({
1277
- internal
1278
- }) => ({
1279
- internal: { ...internal,
1280
- // Decrease manual flag if this subscription had a priority
1281
- priority: internal.priority - (priority > 0 ? 1 : 0),
1282
- // Remove subscriber from list
1283
- subscribers: internal.subscribers.filter(s => s.ref !== ref)
1284
- }
1285
- }));
1286
- };
1287
- }
1288
- }
1289
- };
1290
- }); // Resize camera and renderer on changes to size and pixelratio
1291
-
1292
- rootState.subscribe(() => {
1293
- const {
1294
- camera,
1295
- size,
1296
- viewport,
1297
- internal
1298
- } = rootState.getState(); // https://github.com/pmndrs/react-three-fiber/issues/92
1299
- // Do not mess with the camera if it belongs to the user
1300
-
1301
- if (!(internal.lastProps.camera instanceof THREE__namespace.Camera)) {
1302
- if (isOrthographicCamera(camera)) {
1303
- camera.left = size.width / -2;
1304
- camera.right = size.width / 2;
1305
- camera.top = size.height / 2;
1306
- camera.bottom = size.height / -2;
1307
- } else {
1308
- camera.aspect = size.width / size.height;
1309
- }
1310
-
1311
- camera.updateProjectionMatrix(); // https://github.com/pmndrs/react-three-fiber/issues/178
1312
- // Update matrix world since the renderer is a frame late
1313
-
1314
- camera.updateMatrixWorld();
1315
- } // Update renderer
1316
-
1317
-
1318
- gl.setPixelRatio(viewport.dpr);
1319
- gl.setSize(size.width, size.height);
1320
- }, state => [state.viewport.dpr, state.size], shallow__default['default']);
1321
- const state = rootState.getState(); // Update size
1322
-
1323
- if (size) state.setSize(size.width, size.height); // Invalidate on any change
1324
-
1325
- rootState.subscribe(state => invalidate(state)); // Return root state
1326
-
1327
- return rootState;
1328
- };
1329
-
1330
- function createSubs(callback, subs) {
1331
- const index = subs.length;
1332
- subs.push(callback);
1333
- return () => void subs.splice(index, 1);
1334
- }
1335
-
1336
- let i;
1337
- let globalEffects = [];
1338
- let globalAfterEffects = [];
1339
- let globalTailEffects = [];
1340
- const addEffect = callback => createSubs(callback, globalEffects);
1341
- const addAfterEffect = callback => createSubs(callback, globalAfterEffects);
1342
- const addTail = callback => createSubs(callback, globalTailEffects);
1343
-
1344
- function run(effects, timestamp) {
1345
- for (i = 0; i < effects.length; i++) effects[i](timestamp);
1346
- }
1347
-
1348
- function render$1(timestamp, state) {
1349
- // Run local effects
1350
- let delta = state.clock.getDelta(); // In frameloop='never' mode, clock times are updated using the provided timestamp
1351
-
1352
- if (state.frameloop === 'never' && typeof timestamp === 'number') {
1353
- delta = timestamp - state.clock.elapsedTime;
1354
- state.clock.oldTime = state.clock.elapsedTime;
1355
- state.clock.elapsedTime = timestamp;
1356
- } // Call subscribers (useFrame)
1357
-
1358
-
1359
- for (i = 0; i < state.internal.subscribers.length; i++) state.internal.subscribers[i].ref.current(state, delta); // Render content
1360
-
1361
-
1362
- if (!state.internal.priority && state.gl.render) state.gl.render(state.scene, state.camera); // Decrease frame count
1363
-
1364
- state.internal.frames = Math.max(0, state.internal.frames - 1);
1365
- return state.frameloop === 'always' ? 1 : state.internal.frames;
1366
85
  }
1367
-
1368
- function createLoop(roots) {
1369
- let running = false;
1370
- let repeat;
1371
-
1372
- function loop(timestamp) {
1373
- running = true;
1374
- repeat = 0; // Run effects
1375
-
1376
- run(globalEffects, timestamp); // Render all roots
1377
-
1378
- roots.forEach(root => {
1379
- const state = root.store.getState(); // If the frameloop is invalidated, do not run another frame
1380
-
1381
- if (state.internal.active && (state.frameloop === 'always' || state.internal.frames > 0)) repeat += render$1(timestamp, state);
1382
- }); // Run after-effects
1383
-
1384
- run(globalAfterEffects, timestamp); // Keep on looping if anything invalidates the frameloop
1385
-
1386
- if (repeat > 0) return requestAnimationFrame(loop); // Tail call effects, they are called when rendering stops
1387
- else run(globalTailEffects, timestamp); // Flag end of operation
1388
-
1389
- running = false;
1390
- }
1391
-
1392
- function invalidate(state) {
1393
- if (!state) return roots.forEach(root => invalidate(root.store.getState()));
1394
- if (state.vr || !state.internal.active || state.frameloop === 'never') return; // Increase frames, do not go higher than 60
1395
-
1396
- state.internal.frames = Math.min(60, state.internal.frames + 1); // If the render-loop isn't active, start it
1397
-
1398
- if (!running) {
1399
- running = true;
1400
- requestAnimationFrame(loop);
1401
- }
1402
- }
1403
-
1404
- function advance(timestamp, runGlobalEffects = true, state) {
1405
- if (runGlobalEffects) run(globalEffects, timestamp);
1406
- if (!state) roots.forEach(root => render$1(timestamp, root.store.getState()));else render$1(timestamp, state);
1407
- if (runGlobalEffects) run(globalAfterEffects, timestamp);
1408
- }
1409
-
1410
- return {
1411
- loop,
1412
- invalidate,
1413
- advance
1414
- };
1415
- }
1416
-
1417
86
  function createPointerEvents(store) {
1418
87
  const {
1419
88
  handlePointer
1420
- } = createEvents(store);
89
+ } = hooks.createEvents(store);
1421
90
  const names = {
1422
- onClick: ['click', false],
1423
- onContextMenu: ['contextmenu', false],
1424
- onDoubleClick: ['dblclick', false],
1425
- onWheel: ['wheel', true],
1426
- onPointerDown: ['pointerdown', true],
1427
- onPointerUp: ['pointerup', true],
1428
- onPointerLeave: ['pointerleave', true],
1429
- onPointerMove: ['pointermove', true],
1430
- onPointerCancel: ['pointercancel', true],
91
+ onClick: [CLICK, false],
92
+ onContextMenu: [CONTEXTMENU, false],
93
+ onDoubleClick: [DBLCLICK, false],
94
+ onWheel: [WHEEL, true],
95
+ onPointerDown: [POINTERDOWN, true],
96
+ onPointerUp: [POINTERUP, true],
97
+ onPointerLeave: [POINTERLEAVE, true],
98
+ onPointerMove: [POINTERMOVE, true],
99
+ onPointerCancel: [POINTERCANCEL, true],
1431
100
  onLostPointerCapture: ['lostpointercapture', true]
1432
101
  };
1433
102
  return {
@@ -1480,9 +149,10 @@ function createPointerEvents(store) {
1480
149
  };
1481
150
  }
1482
151
 
1483
- // React currently throws a warning when using useLayoutEffect on the server.
152
+ const CANVAS_PROPS = ['gl', 'events', 'size', 'shadows', 'linear', 'flat', 'orthographic', 'frameloop', 'dpr', 'performance', 'clock', 'raycaster', 'camera', 'onPointerMissed', 'onCreated']; // React currently throws a warning when using useLayoutEffect on the server.
1484
153
  // To get around it, we can conditionally useEffect on the server (no-op) and
1485
154
  // useLayoutEffect in the browser.
155
+
1486
156
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React__namespace.useLayoutEffect : React__namespace.useEffect;
1487
157
 
1488
158
  function Block({
@@ -1520,15 +190,17 @@ ErrorBoundary.getDerivedStateFromError = () => ({
1520
190
  const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
1521
191
  children,
1522
192
  fallback,
1523
- tabIndex,
1524
193
  resize,
1525
- id,
1526
194
  style,
1527
- className,
1528
195
  events,
1529
196
  ...props
1530
197
  }, forwardedRef) {
1531
- const [containerRef, size] = useMeasure__default['default']({
198
+ const canvasProps = pick__default["default"](props, CANVAS_PROPS);
199
+ const divProps = omit__default["default"](props, CANVAS_PROPS);
200
+ const [containerRef, {
201
+ width,
202
+ height
203
+ }] = useMeasure__default["default"]({
1532
204
  scroll: true,
1533
205
  debounce: {
1534
206
  scroll: 50,
@@ -1545,28 +217,28 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
1545
217
  if (error) throw error; // Execute JSX in the reconciler as a layout-effect
1546
218
 
1547
219
  useIsomorphicLayoutEffect(() => {
1548
- if (size.width > 0 && size.height > 0) {
220
+ if (width > 0 && height > 0) {
1549
221
  render( /*#__PURE__*/React__namespace.createElement(ErrorBoundary, {
1550
222
  set: setError
1551
223
  }, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
1552
224
  fallback: /*#__PURE__*/React__namespace.createElement(Block, {
1553
225
  set: setBlock
1554
226
  })
1555
- }, children)), canvasRef.current, { ...props,
1556
- size,
227
+ }, children)), canvasRef.current, { ...canvasProps,
228
+ size: {
229
+ width,
230
+ height
231
+ },
1557
232
  events: events || createPointerEvents
1558
233
  });
1559
234
  }
1560
- }, [size, children]);
235
+ }, [width, height, children, canvasProps]);
1561
236
  React__namespace.useEffect(() => {
1562
237
  const container = canvasRef.current;
1563
238
  return () => unmountComponentAtNode(container);
1564
239
  }, []);
1565
- return /*#__PURE__*/React__namespace.createElement("div", {
240
+ return /*#__PURE__*/React__namespace.createElement("div", _extends({
1566
241
  ref: containerRef,
1567
- id: id,
1568
- className: className,
1569
- tabIndex: tabIndex,
1570
242
  style: {
1571
243
  position: 'relative',
1572
244
  width: '100%',
@@ -1574,110 +246,48 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
1574
246
  overflow: 'hidden',
1575
247
  ...style
1576
248
  }
1577
- }, /*#__PURE__*/React__namespace.createElement("canvas", {
1578
- ref: mergeRefs__default['default']([canvasRef, forwardedRef]),
249
+ }, divProps), /*#__PURE__*/React__namespace.createElement("canvas", {
250
+ ref: mergeRefs__default["default"]([canvasRef, forwardedRef]),
1579
251
  style: {
1580
252
  display: 'block'
1581
253
  }
1582
254
  }, fallback));
1583
255
  });
1584
256
 
1585
- function useStore() {
1586
- const store = React__namespace.useContext(context);
1587
- if (!store) throw `R3F hooks can only be used within the Canvas component!`;
1588
- return store;
1589
- }
1590
- function useThree(selector = state => state, equalityFn) {
1591
- return useStore()(selector, equalityFn);
1592
- }
1593
- function useFrame(callback, renderPriority = 0) {
1594
- const {
1595
- subscribe
1596
- } = useStore().getState().internal; // Update ref
1597
-
1598
- const ref = React__namespace.useRef(callback);
1599
- React__namespace.useLayoutEffect(() => void (ref.current = callback), [callback]); // Subscribe/unsub
1600
-
1601
- React__namespace.useLayoutEffect(() => {
1602
- const unsubscribe = subscribe(ref, renderPriority);
1603
- return () => unsubscribe();
1604
- }, [renderPriority, subscribe]);
1605
- return null;
1606
- }
1607
-
1608
- function buildGraph(object) {
1609
- const data = {
1610
- nodes: {},
1611
- materials: {}
1612
- };
1613
-
1614
- if (object) {
1615
- object.traverse(obj => {
1616
- if (obj.name) {
1617
- data.nodes[obj.name] = obj;
1618
- }
1619
-
1620
- if (obj.material && !data.materials[obj.material.name]) {
1621
- data.materials[obj.material.name] = obj.material;
1622
- }
1623
- });
1624
- }
1625
-
1626
- return data;
1627
- }
1628
-
1629
- function useGraph(object) {
1630
- return React__namespace.useMemo(() => buildGraph(object), [object]);
1631
- }
1632
-
1633
- function loadingFn(extensions, onProgress) {
1634
- return function (Proto, ...input) {
1635
- // Construct new loader and run extensions
1636
- const loader = new Proto();
1637
- if (extensions) extensions(loader); // Go through the urls and load them
1638
-
1639
- return Promise.all(input.map(input => new Promise((res, reject) => loader.load(input, data => {
1640
- if (data.scene) Object.assign(data, buildGraph(data.scene));
1641
- res(data);
1642
- }, onProgress, error => reject(`Could not load ${input}: ${error.message}`)))));
1643
- };
1644
- }
1645
-
1646
- function useLoader(Proto, input, extensions, onProgress) {
1647
- // Use suspense to load async assets
1648
- const keys = Array.isArray(input) ? input : [input];
1649
- const results = useAsset.useAsset(loadingFn(extensions, onProgress), Proto, ...keys); // Return the object/s
1650
-
1651
- return Array.isArray(input) ? results : results[0];
1652
- }
1653
-
1654
- useLoader.preload = function (Proto, input, extensions) {
1655
- const keys = Array.isArray(input) ? input : [input];
1656
- return useAsset.useAsset.preload(loadingFn(extensions), Proto, ...keys);
1657
- };
1658
-
1659
- useLoader.clear = function (Proto, input) {
1660
- const keys = Array.isArray(input) ? input : [input];
1661
- return useAsset.useAsset.clear(Proto, ...keys);
1662
- };
1663
-
1664
257
  const roots = new Map();
1665
258
  const {
1666
259
  invalidate,
1667
260
  advance
1668
- } = createLoop(roots);
261
+ } = hooks.createLoop(roots);
1669
262
  const {
1670
263
  reconciler,
1671
264
  applyProps
1672
- } = createRenderer();
265
+ } = hooks.createRenderer(roots, getEventPriority);
266
+
267
+ const createRendererInstance = (gl, canvas) => {
268
+ const customRenderer = typeof gl === 'function' ? gl(canvas) : gl;
269
+ if (hooks.isRenderer(customRenderer)) return customRenderer;
270
+ const renderer = new THREE__namespace.WebGLRenderer({
271
+ powerPreference: 'high-performance',
272
+ canvas: canvas,
273
+ antialias: true,
274
+ alpha: true,
275
+ ...gl
276
+ }); // Set color management
277
+
278
+ renderer.outputEncoding = THREE__namespace.sRGBEncoding;
279
+ renderer.toneMapping = THREE__namespace.ACESFilmicToneMapping; // Set gl props
280
+
281
+ if (gl) applyProps(renderer, gl);
282
+ return renderer;
283
+ };
1673
284
 
1674
- const createRendererInstance = (gl, canvas) => isRenderer(gl) ? gl : new THREE__namespace.WebGLRenderer({
1675
- powerPreference: 'high-performance',
1676
- canvas: canvas,
1677
- antialias: true,
1678
- alpha: true,
1679
- ...gl
1680
- });
285
+ function createRoot(canvas, config) {
286
+ return {
287
+ render: element => render(element, canvas, config),
288
+ unmount: () => unmountComponentAtNode(canvas)
289
+ };
290
+ }
1681
291
 
1682
292
  function render(element, canvas, {
1683
293
  gl,
@@ -1704,15 +314,14 @@ function render(element, canvas, {
1704
314
  let state = (_store = store) == null ? void 0 : _store.getState();
1705
315
 
1706
316
  if (fiber && state) {
1707
- const lastProps = state.internal.lastProps; // When a root was found, see if any fundamental props must be changed or exchanged
317
+ // When a root was found, see if any fundamental props must be changed or exchanged
1708
318
  // Check pixelratio
319
+ if (props.dpr !== undefined && state.viewport.dpr !== hooks.calculateDpr(props.dpr)) state.setDpr(props.dpr); // Check size
1709
320
 
1710
- if (props.dpr !== undefined && !is.equ(lastProps.dpr, props.dpr)) state.setDpr(props.dpr); // Check size
1711
-
1712
- if (!is.equ(lastProps.size, size)) state.setSize(size.width, size.height); // For some props we want to reset the entire root
321
+ if (state.size.width !== size.width || state.size.height !== size.height) state.setSize(size.width, size.height); // For some props we want to reset the entire root
1713
322
  // Changes to the color-space
1714
323
 
1715
- const linearChanged = props.linear !== lastProps.linear;
324
+ const linearChanged = props.linear !== state.internal.lastProps.linear;
1716
325
 
1717
326
  if (linearChanged) {
1718
327
  unmountComponentAtNode(canvas);
@@ -1723,15 +332,9 @@ function render(element, canvas, {
1723
332
  if (!fiber) {
1724
333
  // If no root has been found, make one
1725
334
  // Create gl
1726
- const glRenderer = createRendererInstance(gl, canvas); // Enable VR if requested
335
+ const glRenderer = createRendererInstance(gl, canvas); // Create store
1727
336
 
1728
- if (props.vr) {
1729
- glRenderer.xr.enabled = true;
1730
- glRenderer.setAnimationLoop(timestamp => advance(timestamp, true));
1731
- } // Create store
1732
-
1733
-
1734
- store = createStore(applyProps, invalidate, advance, {
337
+ store = hooks.createStore(applyProps, invalidate, advance, {
1735
338
  gl: glRenderer,
1736
339
  size,
1737
340
  ...props
@@ -1780,9 +383,9 @@ function Provider({
1780
383
 
1781
384
  state.events.connect == null ? void 0 : state.events.connect(target); // Notifiy that init is completed, the scene graph exists, but nothing has yet rendered
1782
385
 
1783
- if (onCreated) onCreated(state);
386
+ if (onCreated) onCreated(state); // eslint-disable-next-line react-hooks/exhaustive-deps
1784
387
  }, []);
1785
- return /*#__PURE__*/React__namespace.createElement(context.Provider, {
388
+ return /*#__PURE__*/React__namespace.createElement(hooks.context.Provider, {
1786
389
  value: store
1787
390
  }, element);
1788
391
  }
@@ -1797,70 +400,58 @@ function unmountComponentAtNode(canvas, callback) {
1797
400
  reconciler.updateContainer(null, fiber, null, () => {
1798
401
  if (state) {
1799
402
  setTimeout(() => {
1800
- var _state$gl, _state$gl$renderLists, _state$gl2;
1801
-
1802
- state.events.disconnect == null ? void 0 : state.events.disconnect();
1803
- (_state$gl = state.gl) == null ? void 0 : (_state$gl$renderLists = _state$gl.renderLists) == null ? void 0 : _state$gl$renderLists.dispose == null ? void 0 : _state$gl$renderLists.dispose();
1804
- (_state$gl2 = state.gl) == null ? void 0 : _state$gl2.forceContextLoss == null ? void 0 : _state$gl2.forceContextLoss();
1805
- dispose(state);
1806
- roots.delete(canvas);
1807
- if (callback) callback(canvas);
403
+ try {
404
+ var _state$gl, _state$gl$renderLists, _state$gl2, _state$gl3;
405
+
406
+ state.events.disconnect == null ? void 0 : state.events.disconnect();
407
+ (_state$gl = state.gl) == null ? void 0 : (_state$gl$renderLists = _state$gl.renderLists) == null ? void 0 : _state$gl$renderLists.dispose == null ? void 0 : _state$gl$renderLists.dispose();
408
+ (_state$gl2 = state.gl) == null ? void 0 : _state$gl2.forceContextLoss == null ? void 0 : _state$gl2.forceContextLoss();
409
+ if ((_state$gl3 = state.gl) != null && _state$gl3.xr) state.internal.xr.disconnect();
410
+ hooks.dispose(state);
411
+ roots.delete(canvas);
412
+ if (callback) callback(canvas);
413
+ } catch (e) {
414
+ /* ... */
415
+ }
1808
416
  }, 500);
1809
417
  }
1810
418
  });
1811
419
  }
1812
420
  }
1813
421
 
1814
- function dispose(obj) {
1815
- if (obj.dispose && obj.type !== 'Scene') obj.dispose();
1816
-
1817
- for (const p in obj) {
1818
- var _dispose, _ref;
1819
- (_dispose = (_ref = p).dispose) == null ? void 0 : _dispose.call(_ref);
1820
- delete obj[p];
1821
- }
1822
- }
1823
-
1824
422
  const act = reconciler.act;
1825
- const hasSymbol = is.fun(Symbol) && Symbol.for;
1826
- const REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
1827
423
 
1828
- function createPortal(children, container, implementation, key = null) {
1829
- return {
1830
- $$typeof: REACT_PORTAL_TYPE,
1831
- key: key == null ? null : '' + key,
1832
- children,
1833
- containerInfo: prepare(container),
1834
- implementation
1835
- };
424
+ function createPortal(children, container) {
425
+ return reconciler.createPortal(children, container, null, null);
1836
426
  }
1837
427
 
1838
428
  reconciler.injectIntoDevTools({
1839
429
  bundleType: process.env.NODE_ENV === 'production' ? 0 : 1,
1840
430
  rendererPackageName: '@react-three/fiber',
1841
- version: '17.0.2'
431
+ version: '18.0.0'
1842
432
  });
1843
433
 
434
+ exports.ReactThreeFiber = hooks.threeTypes;
435
+ exports.addAfterEffect = hooks.addAfterEffect;
436
+ exports.addEffect = hooks.addEffect;
437
+ exports.addTail = hooks.addTail;
438
+ exports.context = hooks.context;
439
+ exports.dispose = hooks.dispose;
440
+ exports.extend = hooks.extend;
441
+ exports.useFrame = hooks.useFrame;
442
+ exports.useGraph = hooks.useGraph;
443
+ exports.useLoader = hooks.useLoader;
444
+ exports.useStore = hooks.useStore;
445
+ exports.useThree = hooks.useThree;
1844
446
  exports.Canvas = Canvas;
1845
- exports.ReactThreeFiber = threeTypes;
1846
447
  exports._roots = roots;
1847
448
  exports.act = act;
1848
- exports.addAfterEffect = addAfterEffect;
1849
- exports.addEffect = addEffect;
1850
- exports.addTail = addTail;
1851
449
  exports.advance = advance;
1852
450
  exports.applyProps = applyProps;
1853
- exports.context = context;
1854
451
  exports.createPortal = createPortal;
1855
- exports.dispose = dispose;
452
+ exports.createRoot = createRoot;
1856
453
  exports.events = createPointerEvents;
1857
- exports.extend = extend;
1858
454
  exports.invalidate = invalidate;
1859
455
  exports.reconciler = reconciler;
1860
456
  exports.render = render;
1861
457
  exports.unmountComponentAtNode = unmountComponentAtNode;
1862
- exports.useFrame = useFrame;
1863
- exports.useGraph = useGraph;
1864
- exports.useLoader = useLoader;
1865
- exports.useStore = useStore;
1866
- exports.useThree = useThree;