@react-three/fiber 9.0.0-rc.7 → 9.0.0-rc.9
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/declarations/src/core/events.d.ts +1 -0
- package/dist/declarations/src/core/utils.d.ts +1 -0
- package/dist/{events-12fa3319.esm.js → events-aba3c3d1.esm.js} +14 -18
- package/dist/{events-56f909a9.cjs.dev.js → events-b02714fc.cjs.dev.js} +14 -18
- package/dist/{events-858f07e7.cjs.prod.js → events-bd708dc8.cjs.prod.js} +14 -18
- package/dist/react-three-fiber.cjs.dev.js +1 -1
- package/dist/react-three-fiber.cjs.prod.js +1 -1
- package/dist/react-three-fiber.esm.js +2 -2
- package/native/dist/react-three-fiber-native.cjs.dev.js +1 -1
- package/native/dist/react-three-fiber-native.cjs.prod.js +1 -1
- package/native/dist/react-three-fiber-native.esm.js +2 -2
- package/package.json +1 -1
|
@@ -56,6 +56,7 @@ export interface EventHandlers {
|
|
|
56
56
|
onPointerMissed?: (event: MouseEvent) => void;
|
|
57
57
|
onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void;
|
|
58
58
|
onWheel?: (event: ThreeEvent<WheelEvent>) => void;
|
|
59
|
+
onLostPointerCapture?: (event: ThreeEvent<PointerEvent>) => void;
|
|
59
60
|
}
|
|
60
61
|
export type FilterFunction = (items: THREE.Intersection[], state: RootState) => THREE.Intersection[];
|
|
61
62
|
export type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void;
|
|
@@ -27,6 +27,7 @@ export type Camera = (THREE.OrthographicCamera | THREE.PerspectiveCamera) & {
|
|
|
27
27
|
};
|
|
28
28
|
export declare const isOrthographicCamera: (def: Camera) => def is THREE.OrthographicCamera;
|
|
29
29
|
export declare const isRef: (obj: any) => obj is React.RefObject<unknown>;
|
|
30
|
+
export declare const isColorRepresentation: (value: unknown) => value is THREE.ColorRepresentation;
|
|
30
31
|
/**
|
|
31
32
|
* An SSR-friendly useLayoutEffect.
|
|
32
33
|
*
|
|
@@ -26,6 +26,7 @@ function findInitialRoot(instance) {
|
|
|
26
26
|
const act = React.act;
|
|
27
27
|
const isOrthographicCamera = def => def && def.isOrthographicCamera;
|
|
28
28
|
const isRef = obj => obj && obj.hasOwnProperty('current');
|
|
29
|
+
const isColorRepresentation = value => value != null && (typeof value === 'string' || typeof value === 'number' || value.isColor);
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* An SSR-friendly useLayoutEffect.
|
|
@@ -366,29 +367,24 @@ function applyProps(object, props) {
|
|
|
366
367
|
target
|
|
367
368
|
} = resolve(object, prop);
|
|
368
369
|
|
|
369
|
-
//
|
|
370
|
-
if (target
|
|
371
|
-
// fetch the default state of the target
|
|
372
|
-
const ctor = getMemoizedPrototype(root);
|
|
373
|
-
// The target key was originally null or undefined, which indicates that the object which
|
|
374
|
-
// is now present was externally set by the user, we should therefore assign the value directly
|
|
375
|
-
if (!is.und(ctor) && (is.und(ctor[key]) || is.nul(ctor[key]))) root[key] = value;
|
|
376
|
-
// Otherwise copy is correct
|
|
377
|
-
else target.copy(value);
|
|
378
|
-
}
|
|
379
|
-
// Layers have no copy function, we must therefore copy the mask property
|
|
380
|
-
else if (target instanceof THREE.Layers && value instanceof THREE.Layers) {
|
|
370
|
+
// Layers must be written to the mask property
|
|
371
|
+
if (target instanceof THREE.Layers && value instanceof THREE.Layers) {
|
|
381
372
|
target.mask = value.mask;
|
|
373
|
+
} else if (target instanceof THREE.Color && isColorRepresentation(value)) {
|
|
374
|
+
target.set(value);
|
|
375
|
+
}
|
|
376
|
+
// Copy if properties match signatures and implement math interface (likely read-only)
|
|
377
|
+
else if (target && typeof target.set === 'function' && typeof target.copy === 'function' && value != null && value.constructor && target.constructor === value.constructor) {
|
|
378
|
+
target.copy(value);
|
|
382
379
|
}
|
|
383
380
|
// Set array types
|
|
384
|
-
else if (target
|
|
385
|
-
if (target.fromArray) target.fromArray(value);else target.set(...value);
|
|
381
|
+
else if (target && typeof target.set === 'function' && Array.isArray(value)) {
|
|
382
|
+
if (typeof target.fromArray === 'function') target.fromArray(value);else target.set(...value);
|
|
386
383
|
}
|
|
387
384
|
// Set literal types
|
|
388
|
-
else if (target
|
|
389
|
-
const isColor = target == null ? void 0 : target.isColor;
|
|
385
|
+
else if (target && typeof target.set === 'function' && typeof value === 'number') {
|
|
390
386
|
// Allow setting array scalars
|
|
391
|
-
if (
|
|
387
|
+
if (typeof target.setScalar === 'function') target.setScalar(value);
|
|
392
388
|
// Otherwise just set single value
|
|
393
389
|
else target.set(value);
|
|
394
390
|
}
|
|
@@ -2302,7 +2298,7 @@ function createPointerEvents(store) {
|
|
|
2302
2298
|
compute(event, state, previous) {
|
|
2303
2299
|
// https://github.com/pmndrs/react-three-fiber/pull/782
|
|
2304
2300
|
// Events trigger outside of canvas when moved, use offsetX/Y by default and allow overrides
|
|
2305
|
-
state.pointer.set(
|
|
2301
|
+
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
2306
2302
|
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
2307
2303
|
},
|
|
2308
2304
|
connected: undefined,
|
|
@@ -52,6 +52,7 @@ function findInitialRoot(instance) {
|
|
|
52
52
|
const act = React__namespace.act;
|
|
53
53
|
const isOrthographicCamera = def => def && def.isOrthographicCamera;
|
|
54
54
|
const isRef = obj => obj && obj.hasOwnProperty('current');
|
|
55
|
+
const isColorRepresentation = value => value != null && (typeof value === 'string' || typeof value === 'number' || value.isColor);
|
|
55
56
|
|
|
56
57
|
/**
|
|
57
58
|
* An SSR-friendly useLayoutEffect.
|
|
@@ -392,29 +393,24 @@ function applyProps(object, props) {
|
|
|
392
393
|
target
|
|
393
394
|
} = resolve(object, prop);
|
|
394
395
|
|
|
395
|
-
//
|
|
396
|
-
if (target
|
|
397
|
-
// fetch the default state of the target
|
|
398
|
-
const ctor = getMemoizedPrototype(root);
|
|
399
|
-
// The target key was originally null or undefined, which indicates that the object which
|
|
400
|
-
// is now present was externally set by the user, we should therefore assign the value directly
|
|
401
|
-
if (!is.und(ctor) && (is.und(ctor[key]) || is.nul(ctor[key]))) root[key] = value;
|
|
402
|
-
// Otherwise copy is correct
|
|
403
|
-
else target.copy(value);
|
|
404
|
-
}
|
|
405
|
-
// Layers have no copy function, we must therefore copy the mask property
|
|
406
|
-
else if (target instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) {
|
|
396
|
+
// Layers must be written to the mask property
|
|
397
|
+
if (target instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) {
|
|
407
398
|
target.mask = value.mask;
|
|
399
|
+
} else if (target instanceof THREE__namespace.Color && isColorRepresentation(value)) {
|
|
400
|
+
target.set(value);
|
|
401
|
+
}
|
|
402
|
+
// Copy if properties match signatures and implement math interface (likely read-only)
|
|
403
|
+
else if (target && typeof target.set === 'function' && typeof target.copy === 'function' && value != null && value.constructor && target.constructor === value.constructor) {
|
|
404
|
+
target.copy(value);
|
|
408
405
|
}
|
|
409
406
|
// Set array types
|
|
410
|
-
else if (target
|
|
411
|
-
if (target.fromArray) target.fromArray(value);else target.set(...value);
|
|
407
|
+
else if (target && typeof target.set === 'function' && Array.isArray(value)) {
|
|
408
|
+
if (typeof target.fromArray === 'function') target.fromArray(value);else target.set(...value);
|
|
412
409
|
}
|
|
413
410
|
// Set literal types
|
|
414
|
-
else if (target
|
|
415
|
-
const isColor = target == null ? void 0 : target.isColor;
|
|
411
|
+
else if (target && typeof target.set === 'function' && typeof value === 'number') {
|
|
416
412
|
// Allow setting array scalars
|
|
417
|
-
if (
|
|
413
|
+
if (typeof target.setScalar === 'function') target.setScalar(value);
|
|
418
414
|
// Otherwise just set single value
|
|
419
415
|
else target.set(value);
|
|
420
416
|
}
|
|
@@ -2328,7 +2324,7 @@ function createPointerEvents(store) {
|
|
|
2328
2324
|
compute(event, state, previous) {
|
|
2329
2325
|
// https://github.com/pmndrs/react-three-fiber/pull/782
|
|
2330
2326
|
// Events trigger outside of canvas when moved, use offsetX/Y by default and allow overrides
|
|
2331
|
-
state.pointer.set(
|
|
2327
|
+
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
2332
2328
|
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
2333
2329
|
},
|
|
2334
2330
|
connected: undefined,
|
|
@@ -52,6 +52,7 @@ function findInitialRoot(instance) {
|
|
|
52
52
|
const act = React__namespace.act;
|
|
53
53
|
const isOrthographicCamera = def => def && def.isOrthographicCamera;
|
|
54
54
|
const isRef = obj => obj && obj.hasOwnProperty('current');
|
|
55
|
+
const isColorRepresentation = value => value != null && (typeof value === 'string' || typeof value === 'number' || value.isColor);
|
|
55
56
|
|
|
56
57
|
/**
|
|
57
58
|
* An SSR-friendly useLayoutEffect.
|
|
@@ -392,29 +393,24 @@ function applyProps(object, props) {
|
|
|
392
393
|
target
|
|
393
394
|
} = resolve(object, prop);
|
|
394
395
|
|
|
395
|
-
//
|
|
396
|
-
if (target
|
|
397
|
-
// fetch the default state of the target
|
|
398
|
-
const ctor = getMemoizedPrototype(root);
|
|
399
|
-
// The target key was originally null or undefined, which indicates that the object which
|
|
400
|
-
// is now present was externally set by the user, we should therefore assign the value directly
|
|
401
|
-
if (!is.und(ctor) && (is.und(ctor[key]) || is.nul(ctor[key]))) root[key] = value;
|
|
402
|
-
// Otherwise copy is correct
|
|
403
|
-
else target.copy(value);
|
|
404
|
-
}
|
|
405
|
-
// Layers have no copy function, we must therefore copy the mask property
|
|
406
|
-
else if (target instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) {
|
|
396
|
+
// Layers must be written to the mask property
|
|
397
|
+
if (target instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) {
|
|
407
398
|
target.mask = value.mask;
|
|
399
|
+
} else if (target instanceof THREE__namespace.Color && isColorRepresentation(value)) {
|
|
400
|
+
target.set(value);
|
|
401
|
+
}
|
|
402
|
+
// Copy if properties match signatures and implement math interface (likely read-only)
|
|
403
|
+
else if (target && typeof target.set === 'function' && typeof target.copy === 'function' && value != null && value.constructor && target.constructor === value.constructor) {
|
|
404
|
+
target.copy(value);
|
|
408
405
|
}
|
|
409
406
|
// Set array types
|
|
410
|
-
else if (target
|
|
411
|
-
if (target.fromArray) target.fromArray(value);else target.set(...value);
|
|
407
|
+
else if (target && typeof target.set === 'function' && Array.isArray(value)) {
|
|
408
|
+
if (typeof target.fromArray === 'function') target.fromArray(value);else target.set(...value);
|
|
412
409
|
}
|
|
413
410
|
// Set literal types
|
|
414
|
-
else if (target
|
|
415
|
-
const isColor = target == null ? void 0 : target.isColor;
|
|
411
|
+
else if (target && typeof target.set === 'function' && typeof value === 'number') {
|
|
416
412
|
// Allow setting array scalars
|
|
417
|
-
if (
|
|
413
|
+
if (typeof target.setScalar === 'function') target.setScalar(value);
|
|
418
414
|
// Otherwise just set single value
|
|
419
415
|
else target.set(value);
|
|
420
416
|
}
|
|
@@ -2328,7 +2324,7 @@ function createPointerEvents(store) {
|
|
|
2328
2324
|
compute(event, state, previous) {
|
|
2329
2325
|
// https://github.com/pmndrs/react-three-fiber/pull/782
|
|
2330
2326
|
// Events trigger outside of canvas when moved, use offsetX/Y by default and allow overrides
|
|
2331
|
-
state.pointer.set(
|
|
2327
|
+
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
2332
2328
|
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
2333
2329
|
},
|
|
2334
2330
|
connected: undefined,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var events = require('./events-
|
|
5
|
+
var events = require('./events-b02714fc.cjs.dev.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var THREE = require('three');
|
|
8
8
|
var useMeasure = require('react-use-measure');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var events = require('./events-
|
|
5
|
+
var events = require('./events-bd708dc8.cjs.prod.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var THREE = require('three');
|
|
8
8
|
var useMeasure = require('react-use-measure');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as extend, u as useBridge, a as useMutableCallback, b as useIsomorphicLayoutEffect, c as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode, f as createPointerEvents } from './events-
|
|
2
|
-
export { t as ReactThreeFiber, _ as _roots, w as act, k as addAfterEffect, j as addEffect, l as addTail, n as advance, q as applyProps, x as buildGraph, p as context, g as createEvents, o as createPortal, c as createRoot, v as dispose, f as events, e as extend, h as flushGlobalEffects, s as getRootState, m as invalidate, r as reconciler, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from './events-
|
|
1
|
+
import { e as extend, u as useBridge, a as useMutableCallback, b as useIsomorphicLayoutEffect, c as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode, f as createPointerEvents } from './events-aba3c3d1.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, _ as _roots, w as act, k as addAfterEffect, j as addEffect, l as addTail, n as advance, q as applyProps, x as buildGraph, p as context, g as createEvents, o as createPortal, c as createRoot, v as dispose, f as events, e as extend, h as flushGlobalEffects, s as getRootState, m as invalidate, r as reconciler, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from './events-aba3c3d1.esm.js';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import * as THREE from 'three';
|
|
5
5
|
import useMeasure from 'react-use-measure';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var events = require('../../dist/events-
|
|
5
|
+
var events = require('../../dist/events-b02714fc.cjs.dev.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var THREE = require('three');
|
|
8
8
|
var reactNative = require('react-native');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var events = require('../../dist/events-
|
|
5
|
+
var events = require('../../dist/events-bd708dc8.cjs.prod.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var THREE = require('three');
|
|
8
8
|
var reactNative = require('react-native');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as extend, u as useBridge, a as useMutableCallback, c as createRoot, b as useIsomorphicLayoutEffect, E as ErrorBoundary, B as Block, d as unmountComponentAtNode, f as createPointerEvents, g as createEvents } from '../../dist/events-
|
|
2
|
-
export { t as ReactThreeFiber, _ as _roots, w as act, k as addAfterEffect, j as addEffect, l as addTail, n as advance, q as applyProps, x as buildGraph, p as context, g as createEvents, o as createPortal, c as createRoot, v as dispose, e as extend, h as flushGlobalEffects, s as getRootState, m as invalidate, r as reconciler, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/events-
|
|
1
|
+
import { e as extend, u as useBridge, a as useMutableCallback, c as createRoot, b as useIsomorphicLayoutEffect, E as ErrorBoundary, B as Block, d as unmountComponentAtNode, f as createPointerEvents, g as createEvents } from '../../dist/events-aba3c3d1.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, _ as _roots, w as act, k as addAfterEffect, j as addEffect, l as addTail, n as advance, q as applyProps, x as buildGraph, p as context, g as createEvents, o as createPortal, c as createRoot, v as dispose, e as extend, h as flushGlobalEffects, s as getRootState, m as invalidate, r as reconciler, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/events-aba3c3d1.esm.js';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import * as THREE from 'three';
|
|
5
5
|
import { PanResponder, PixelRatio, StyleSheet, View, Platform, Image, NativeModules } from 'react-native';
|