@react-three/fiber 8.9.1 → 8.10.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/CHANGELOG.md +12 -0
- package/dist/declarations/src/core/events.d.ts +70 -70
- package/dist/declarations/src/core/hooks.d.ts +28 -28
- package/dist/declarations/src/core/index.d.ts +55 -55
- package/dist/declarations/src/core/loop.d.ts +14 -14
- package/dist/declarations/src/core/renderer.d.ts +52 -51
- package/dist/declarations/src/core/store.d.ts +95 -95
- package/dist/declarations/src/core/utils.d.ts +83 -83
- package/dist/declarations/src/index.d.ts +12 -12
- package/dist/declarations/src/native/Canvas.d.ts +8 -8
- package/dist/declarations/src/native/events.d.ts +4 -4
- package/dist/declarations/src/native/polyfills.d.ts +1 -1
- package/dist/declarations/src/native.d.ts +12 -12
- package/dist/declarations/src/three-types.d.ts +335 -335
- package/dist/declarations/src/web/Canvas.d.ts +11 -11
- package/dist/declarations/src/web/events.d.ts +4 -4
- package/dist/{index-6f0019d1.esm.js → index-27a1523b.esm.js} +29 -8
- package/dist/{index-8539ced2.cjs.dev.js → index-4ea38fa1.cjs.dev.js} +29 -8
- package/dist/{index-57cb2f85.cjs.prod.js → index-d957aeb6.cjs.prod.js} +29 -8
- 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
- package/readme.md +3 -3
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { Options as ResizeOptions } from 'react-use-measure';
|
|
3
|
-
import { RenderProps } from '../core';
|
|
4
|
-
export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
fallback?: React.ReactNode;
|
|
7
|
-
resize?: ResizeOptions;
|
|
8
|
-
eventSource?: HTMLElement | React.MutableRefObject<HTMLElement>;
|
|
9
|
-
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
|
|
10
|
-
}
|
|
11
|
-
export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Options as ResizeOptions } from 'react-use-measure';
|
|
3
|
+
import { RenderProps } from '../core';
|
|
4
|
+
export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
fallback?: React.ReactNode;
|
|
7
|
+
resize?: ResizeOptions;
|
|
8
|
+
eventSource?: HTMLElement | React.MutableRefObject<HTMLElement>;
|
|
9
|
+
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
|
|
10
|
+
}
|
|
11
|
+
export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UseBoundStore } from 'zustand';
|
|
2
|
-
import { RootState } from '../core/store';
|
|
3
|
-
import { EventManager } from '../core/events';
|
|
4
|
-
export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
|
|
1
|
+
import { UseBoundStore } from 'zustand';
|
|
2
|
+
import { RootState } from '../core/store';
|
|
3
|
+
import { EventManager } from '../core/events';
|
|
4
|
+
export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
|
|
@@ -1050,7 +1050,15 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
1050
1050
|
instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
|
|
1051
1051
|
|
|
1052
1052
|
instance.__r3f.objects = [];
|
|
1053
|
-
|
|
1053
|
+
|
|
1054
|
+
if (!instance.__r3f.autoRemovedBeforeAppend) {
|
|
1055
|
+
removeChild(parent, instance);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
if (newInstance.parent) {
|
|
1059
|
+
newInstance.__r3f.autoRemovedBeforeAppend = true;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1054
1062
|
appendChild(parent, newInstance); // Re-bind event handlers
|
|
1055
1063
|
|
|
1056
1064
|
if (newInstance.raycast && newInstance.__r3f.eventCount) {
|
|
@@ -1886,14 +1894,27 @@ function createRoot(canvas) {
|
|
|
1886
1894
|
|
|
1887
1895
|
|
|
1888
1896
|
if (gl.shadowMap) {
|
|
1889
|
-
const
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1897
|
+
const oldEnabled = gl.shadowMap.enabled;
|
|
1898
|
+
const oldType = gl.shadowMap.type;
|
|
1899
|
+
gl.shadowMap.enabled = !!shadows;
|
|
1900
|
+
|
|
1901
|
+
if (is.boo(shadows)) {
|
|
1902
|
+
gl.shadowMap.type = THREE.PCFSoftShadowMap;
|
|
1903
|
+
} else if (is.str(shadows)) {
|
|
1904
|
+
var _types$shadows;
|
|
1905
|
+
|
|
1906
|
+
const types = {
|
|
1907
|
+
basic: THREE.BasicShadowMap,
|
|
1908
|
+
percentage: THREE.PCFShadowMap,
|
|
1909
|
+
soft: THREE.PCFSoftShadowMap,
|
|
1910
|
+
variance: THREE.VSMShadowMap
|
|
1911
|
+
};
|
|
1912
|
+
gl.shadowMap.type = (_types$shadows = types[shadows]) != null ? _types$shadows : THREE.PCFSoftShadowMap;
|
|
1913
|
+
} else if (is.obj(shadows)) {
|
|
1914
|
+
Object.assign(gl.shadowMap, shadows);
|
|
1896
1915
|
}
|
|
1916
|
+
|
|
1917
|
+
if (oldEnabled !== gl.shadowMap.enabled || oldType !== gl.shadowMap.type) gl.shadowMap.needsUpdate = true;
|
|
1897
1918
|
} // Safely set color management if available.
|
|
1898
1919
|
// Avoid accessing THREE.ColorManagement to play nice with older versions
|
|
1899
1920
|
|
|
@@ -1077,7 +1077,15 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
1077
1077
|
instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
|
|
1078
1078
|
|
|
1079
1079
|
instance.__r3f.objects = [];
|
|
1080
|
-
|
|
1080
|
+
|
|
1081
|
+
if (!instance.__r3f.autoRemovedBeforeAppend) {
|
|
1082
|
+
removeChild(parent, instance);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
if (newInstance.parent) {
|
|
1086
|
+
newInstance.__r3f.autoRemovedBeforeAppend = true;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1081
1089
|
appendChild(parent, newInstance); // Re-bind event handlers
|
|
1082
1090
|
|
|
1083
1091
|
if (newInstance.raycast && newInstance.__r3f.eventCount) {
|
|
@@ -1913,14 +1921,27 @@ function createRoot(canvas) {
|
|
|
1913
1921
|
|
|
1914
1922
|
|
|
1915
1923
|
if (gl.shadowMap) {
|
|
1916
|
-
const
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1924
|
+
const oldEnabled = gl.shadowMap.enabled;
|
|
1925
|
+
const oldType = gl.shadowMap.type;
|
|
1926
|
+
gl.shadowMap.enabled = !!shadows;
|
|
1927
|
+
|
|
1928
|
+
if (is.boo(shadows)) {
|
|
1929
|
+
gl.shadowMap.type = THREE__namespace.PCFSoftShadowMap;
|
|
1930
|
+
} else if (is.str(shadows)) {
|
|
1931
|
+
var _types$shadows;
|
|
1932
|
+
|
|
1933
|
+
const types = {
|
|
1934
|
+
basic: THREE__namespace.BasicShadowMap,
|
|
1935
|
+
percentage: THREE__namespace.PCFShadowMap,
|
|
1936
|
+
soft: THREE__namespace.PCFSoftShadowMap,
|
|
1937
|
+
variance: THREE__namespace.VSMShadowMap
|
|
1938
|
+
};
|
|
1939
|
+
gl.shadowMap.type = (_types$shadows = types[shadows]) != null ? _types$shadows : THREE__namespace.PCFSoftShadowMap;
|
|
1940
|
+
} else if (is.obj(shadows)) {
|
|
1941
|
+
Object.assign(gl.shadowMap, shadows);
|
|
1923
1942
|
}
|
|
1943
|
+
|
|
1944
|
+
if (oldEnabled !== gl.shadowMap.enabled || oldType !== gl.shadowMap.type) gl.shadowMap.needsUpdate = true;
|
|
1924
1945
|
} // Safely set color management if available.
|
|
1925
1946
|
// Avoid accessing THREE.ColorManagement to play nice with older versions
|
|
1926
1947
|
|
|
@@ -1077,7 +1077,15 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
1077
1077
|
instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
|
|
1078
1078
|
|
|
1079
1079
|
instance.__r3f.objects = [];
|
|
1080
|
-
|
|
1080
|
+
|
|
1081
|
+
if (!instance.__r3f.autoRemovedBeforeAppend) {
|
|
1082
|
+
removeChild(parent, instance);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
if (newInstance.parent) {
|
|
1086
|
+
newInstance.__r3f.autoRemovedBeforeAppend = true;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1081
1089
|
appendChild(parent, newInstance); // Re-bind event handlers
|
|
1082
1090
|
|
|
1083
1091
|
if (newInstance.raycast && newInstance.__r3f.eventCount) {
|
|
@@ -1913,14 +1921,27 @@ function createRoot(canvas) {
|
|
|
1913
1921
|
|
|
1914
1922
|
|
|
1915
1923
|
if (gl.shadowMap) {
|
|
1916
|
-
const
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1924
|
+
const oldEnabled = gl.shadowMap.enabled;
|
|
1925
|
+
const oldType = gl.shadowMap.type;
|
|
1926
|
+
gl.shadowMap.enabled = !!shadows;
|
|
1927
|
+
|
|
1928
|
+
if (is.boo(shadows)) {
|
|
1929
|
+
gl.shadowMap.type = THREE__namespace.PCFSoftShadowMap;
|
|
1930
|
+
} else if (is.str(shadows)) {
|
|
1931
|
+
var _types$shadows;
|
|
1932
|
+
|
|
1933
|
+
const types = {
|
|
1934
|
+
basic: THREE__namespace.BasicShadowMap,
|
|
1935
|
+
percentage: THREE__namespace.PCFShadowMap,
|
|
1936
|
+
soft: THREE__namespace.PCFSoftShadowMap,
|
|
1937
|
+
variance: THREE__namespace.VSMShadowMap
|
|
1938
|
+
};
|
|
1939
|
+
gl.shadowMap.type = (_types$shadows = types[shadows]) != null ? _types$shadows : THREE__namespace.PCFSoftShadowMap;
|
|
1940
|
+
} else if (is.obj(shadows)) {
|
|
1941
|
+
Object.assign(gl.shadowMap, shadows);
|
|
1923
1942
|
}
|
|
1943
|
+
|
|
1944
|
+
if (oldEnabled !== gl.shadowMap.enabled || oldType !== gl.shadowMap.type) gl.shadowMap.needsUpdate = true;
|
|
1924
1945
|
} // Safely set color management if available.
|
|
1925
1946
|
// Avoid accessing THREE.ColorManagement to play nice with older versions
|
|
1926
1947
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./index-
|
|
5
|
+
var index = require('./index-4ea38fa1.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./index-
|
|
5
|
+
var index = require('./index-d957aeb6.cjs.prod.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, i as isRef, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-
|
|
2
|
-
export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, a as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from './index-
|
|
1
|
+
import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, i as isRef, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-27a1523b.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, a as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from './index-27a1523b.esm.js';
|
|
3
3
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import * as THREE from 'three';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('../../dist/index-
|
|
5
|
+
var index = require('../../dist/index-4ea38fa1.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('../../dist/index-
|
|
5
|
+
var index = require('../../dist/index-d957aeb6.cjs.prod.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-
|
|
2
|
-
export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, a as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from '../../dist/index-
|
|
1
|
+
import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-27a1523b.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, a as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from '../../dist/index-27a1523b.esm.js';
|
|
3
3
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import * as THREE from 'three';
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -55,7 +55,7 @@ function Box(props) {
|
|
|
55
55
|
const [hovered, hover] = useState(false)
|
|
56
56
|
const [clicked, click] = useState(false)
|
|
57
57
|
// Subscribe this component to the render-loop, rotate the mesh every frame
|
|
58
|
-
useFrame((state, delta) => (ref.current.rotation.x +=
|
|
58
|
+
useFrame((state, delta) => (ref.current.rotation.x += delta))
|
|
59
59
|
// Return the view, these are regular Threejs elements expressed in JSX
|
|
60
60
|
return (
|
|
61
61
|
<mesh
|
|
@@ -98,7 +98,7 @@ function Box(props: ThreeElements['mesh']) {
|
|
|
98
98
|
const ref = useRef<THREE.Mesh>(null!)
|
|
99
99
|
const [hovered, hover] = useState(false)
|
|
100
100
|
const [clicked, click] = useState(false)
|
|
101
|
-
useFrame((state, delta) => (ref.current.rotation.x +=
|
|
101
|
+
useFrame((state, delta) => (ref.current.rotation.x += delta))
|
|
102
102
|
return (
|
|
103
103
|
<mesh
|
|
104
104
|
{...props}
|
|
@@ -163,7 +163,7 @@ function Box(props) {
|
|
|
163
163
|
const mesh = useRef(null)
|
|
164
164
|
const [hovered, setHover] = useState(false)
|
|
165
165
|
const [active, setActive] = useState(false)
|
|
166
|
-
useFrame((state, delta) => (mesh.current.rotation.x +=
|
|
166
|
+
useFrame((state, delta) => (mesh.current.rotation.x += delta))
|
|
167
167
|
return (
|
|
168
168
|
<mesh
|
|
169
169
|
{...props}
|