@react-three/fiber 8.11.3 → 8.11.5
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/index.d.ts +9 -7
- package/dist/{index-e8867c70.cjs.prod.js → index-17c44482.cjs.prod.js} +14 -10
- package/dist/{index-606e613e.esm.js → index-37bd4d5c.esm.js} +14 -10
- package/dist/{index-e172420e.cjs.dev.js → index-d1fc6689.cjs.dev.js} +14 -10
- 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/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react-reconciler" />
|
|
2
|
+
/// <reference types="offscreencanvas" />
|
|
2
3
|
import * as THREE from 'three';
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
import { UseBoundStore } from 'zustand';
|
|
@@ -9,11 +10,12 @@ import { addEffect, addAfterEffect, addTail, flushGlobalEffects } from './loop';
|
|
|
9
10
|
import { EventManager, ComputeFunction } from './events';
|
|
10
11
|
import { dispose, getRootState, Camera } from './utils';
|
|
11
12
|
import type { Properties } from '../three-types';
|
|
12
|
-
declare
|
|
13
|
+
declare type Canvas = HTMLCanvasElement | OffscreenCanvas;
|
|
14
|
+
declare const roots: Map<Canvas, Root>;
|
|
13
15
|
declare const invalidate: (state?: RootState | undefined, frames?: number) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState | undefined, frame?: THREE.XRFrame | undefined) => void;
|
|
14
16
|
declare const reconciler: import("react-reconciler").Reconciler<UseBoundStore<RootState, import("zustand").StoreApi<RootState>>, import("./renderer").Instance, void, import("./renderer").Instance, import("./renderer").Instance>, applyProps: typeof import("./utils").applyProps;
|
|
15
|
-
declare type GLProps = Renderer | ((canvas:
|
|
16
|
-
export declare type RenderProps<TCanvas extends
|
|
17
|
+
declare type GLProps = Renderer | ((canvas: Canvas) => Renderer) | Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters> | undefined;
|
|
18
|
+
export declare type RenderProps<TCanvas extends Canvas> = {
|
|
17
19
|
gl?: GLProps;
|
|
18
20
|
size?: Size;
|
|
19
21
|
shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE.WebGLShadowMap>;
|
|
@@ -32,14 +34,14 @@ export declare type RenderProps<TCanvas extends Element> = {
|
|
|
32
34
|
onCreated?: (state: RootState) => void;
|
|
33
35
|
onPointerMissed?: (event: MouseEvent) => void;
|
|
34
36
|
};
|
|
35
|
-
export declare type ReconcilerRoot<TCanvas extends
|
|
37
|
+
export declare type ReconcilerRoot<TCanvas extends Canvas> = {
|
|
36
38
|
configure: (config?: RenderProps<TCanvas>) => ReconcilerRoot<TCanvas>;
|
|
37
39
|
render: (element: React.ReactNode) => UseBoundStore<RootState>;
|
|
38
40
|
unmount: () => void;
|
|
39
41
|
};
|
|
40
|
-
declare function createRoot<TCanvas extends
|
|
41
|
-
declare function render<TCanvas extends
|
|
42
|
-
declare function unmountComponentAtNode<
|
|
42
|
+
declare function createRoot<TCanvas extends Canvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
|
|
43
|
+
declare function render<TCanvas extends Canvas>(children: React.ReactNode, canvas: TCanvas, config: RenderProps<TCanvas>): UseBoundStore<RootState>;
|
|
44
|
+
declare function unmountComponentAtNode<TCanvas extends Canvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
|
|
43
45
|
export declare type InjectState = Partial<Omit<RootState, PrivateKeys> & {
|
|
44
46
|
events?: {
|
|
45
47
|
enabled?: boolean;
|
|
@@ -1392,12 +1392,14 @@ const createStore = (invalidate, advance) => {
|
|
|
1392
1392
|
|
|
1393
1393
|
// Resize camera and renderer on changes to size and pixelratio
|
|
1394
1394
|
if (size !== oldSize || viewport.dpr !== oldDpr) {
|
|
1395
|
+
var _size$updateStyle;
|
|
1395
1396
|
oldSize = size;
|
|
1396
1397
|
oldDpr = viewport.dpr;
|
|
1397
1398
|
// Update camera & renderer
|
|
1398
1399
|
updateCamera(camera, size);
|
|
1399
1400
|
gl.setPixelRatio(viewport.dpr);
|
|
1400
|
-
|
|
1401
|
+
const updateStyle = (_size$updateStyle = size.updateStyle) != null ? _size$updateStyle : typeof HTMLCanvasElement !== 'undefined' && gl.domElement instanceof HTMLCanvasElement;
|
|
1402
|
+
gl.setSize(size.width, size.height, updateStyle);
|
|
1401
1403
|
}
|
|
1402
1404
|
|
|
1403
1405
|
// Update viewport once the camera changes
|
|
@@ -1673,14 +1675,9 @@ const createRendererInstance = (gl, canvas) => {
|
|
|
1673
1675
|
...gl
|
|
1674
1676
|
});
|
|
1675
1677
|
};
|
|
1676
|
-
function isCanvas(maybeCanvas) {
|
|
1677
|
-
return maybeCanvas instanceof HTMLCanvasElement;
|
|
1678
|
-
}
|
|
1679
1678
|
function computeInitialSize(canvas, defaultSize) {
|
|
1680
|
-
if (defaultSize)
|
|
1681
|
-
|
|
1682
|
-
}
|
|
1683
|
-
if (isCanvas(canvas) && canvas.parentElement) {
|
|
1679
|
+
if (defaultSize) return defaultSize;
|
|
1680
|
+
if (typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement && canvas.parentElement) {
|
|
1684
1681
|
const {
|
|
1685
1682
|
width,
|
|
1686
1683
|
height,
|
|
@@ -1693,6 +1690,13 @@ function computeInitialSize(canvas, defaultSize) {
|
|
|
1693
1690
|
top,
|
|
1694
1691
|
left
|
|
1695
1692
|
};
|
|
1693
|
+
} else if (typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas) {
|
|
1694
|
+
return {
|
|
1695
|
+
width: canvas.width,
|
|
1696
|
+
height: canvas.height,
|
|
1697
|
+
top: 0,
|
|
1698
|
+
left: 0
|
|
1699
|
+
};
|
|
1696
1700
|
}
|
|
1697
1701
|
return {
|
|
1698
1702
|
width: 0,
|
|
@@ -1880,13 +1884,13 @@ function createRoot(canvas) {
|
|
|
1880
1884
|
if (events && !state.events.handlers) state.set({
|
|
1881
1885
|
events: events(store)
|
|
1882
1886
|
});
|
|
1883
|
-
// Check pixelratio
|
|
1884
|
-
if (dpr && state.viewport.dpr !== calculateDpr(dpr)) state.setDpr(dpr);
|
|
1885
1887
|
// Check size, allow it to take on container bounds initially
|
|
1886
1888
|
const size = computeInitialSize(canvas, propsSize);
|
|
1887
1889
|
if (!is.equ(size, state.size, shallowLoose)) {
|
|
1888
1890
|
state.setSize(size.width, size.height, size.updateStyle, size.top, size.left);
|
|
1889
1891
|
}
|
|
1892
|
+
// Check pixelratio
|
|
1893
|
+
if (dpr && state.viewport.dpr !== calculateDpr(dpr)) state.setDpr(dpr);
|
|
1890
1894
|
// Check frameloop
|
|
1891
1895
|
if (state.frameloop !== frameloop) state.setFrameloop(frameloop);
|
|
1892
1896
|
// Check pointer missed
|
|
@@ -1365,12 +1365,14 @@ const createStore = (invalidate, advance) => {
|
|
|
1365
1365
|
|
|
1366
1366
|
// Resize camera and renderer on changes to size and pixelratio
|
|
1367
1367
|
if (size !== oldSize || viewport.dpr !== oldDpr) {
|
|
1368
|
+
var _size$updateStyle;
|
|
1368
1369
|
oldSize = size;
|
|
1369
1370
|
oldDpr = viewport.dpr;
|
|
1370
1371
|
// Update camera & renderer
|
|
1371
1372
|
updateCamera(camera, size);
|
|
1372
1373
|
gl.setPixelRatio(viewport.dpr);
|
|
1373
|
-
|
|
1374
|
+
const updateStyle = (_size$updateStyle = size.updateStyle) != null ? _size$updateStyle : typeof HTMLCanvasElement !== 'undefined' && gl.domElement instanceof HTMLCanvasElement;
|
|
1375
|
+
gl.setSize(size.width, size.height, updateStyle);
|
|
1374
1376
|
}
|
|
1375
1377
|
|
|
1376
1378
|
// Update viewport once the camera changes
|
|
@@ -1646,14 +1648,9 @@ const createRendererInstance = (gl, canvas) => {
|
|
|
1646
1648
|
...gl
|
|
1647
1649
|
});
|
|
1648
1650
|
};
|
|
1649
|
-
function isCanvas(maybeCanvas) {
|
|
1650
|
-
return maybeCanvas instanceof HTMLCanvasElement;
|
|
1651
|
-
}
|
|
1652
1651
|
function computeInitialSize(canvas, defaultSize) {
|
|
1653
|
-
if (defaultSize)
|
|
1654
|
-
|
|
1655
|
-
}
|
|
1656
|
-
if (isCanvas(canvas) && canvas.parentElement) {
|
|
1652
|
+
if (defaultSize) return defaultSize;
|
|
1653
|
+
if (typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement && canvas.parentElement) {
|
|
1657
1654
|
const {
|
|
1658
1655
|
width,
|
|
1659
1656
|
height,
|
|
@@ -1666,6 +1663,13 @@ function computeInitialSize(canvas, defaultSize) {
|
|
|
1666
1663
|
top,
|
|
1667
1664
|
left
|
|
1668
1665
|
};
|
|
1666
|
+
} else if (typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas) {
|
|
1667
|
+
return {
|
|
1668
|
+
width: canvas.width,
|
|
1669
|
+
height: canvas.height,
|
|
1670
|
+
top: 0,
|
|
1671
|
+
left: 0
|
|
1672
|
+
};
|
|
1669
1673
|
}
|
|
1670
1674
|
return {
|
|
1671
1675
|
width: 0,
|
|
@@ -1853,13 +1857,13 @@ function createRoot(canvas) {
|
|
|
1853
1857
|
if (events && !state.events.handlers) state.set({
|
|
1854
1858
|
events: events(store)
|
|
1855
1859
|
});
|
|
1856
|
-
// Check pixelratio
|
|
1857
|
-
if (dpr && state.viewport.dpr !== calculateDpr(dpr)) state.setDpr(dpr);
|
|
1858
1860
|
// Check size, allow it to take on container bounds initially
|
|
1859
1861
|
const size = computeInitialSize(canvas, propsSize);
|
|
1860
1862
|
if (!is.equ(size, state.size, shallowLoose)) {
|
|
1861
1863
|
state.setSize(size.width, size.height, size.updateStyle, size.top, size.left);
|
|
1862
1864
|
}
|
|
1865
|
+
// Check pixelratio
|
|
1866
|
+
if (dpr && state.viewport.dpr !== calculateDpr(dpr)) state.setDpr(dpr);
|
|
1863
1867
|
// Check frameloop
|
|
1864
1868
|
if (state.frameloop !== frameloop) state.setFrameloop(frameloop);
|
|
1865
1869
|
// Check pointer missed
|
|
@@ -1392,12 +1392,14 @@ const createStore = (invalidate, advance) => {
|
|
|
1392
1392
|
|
|
1393
1393
|
// Resize camera and renderer on changes to size and pixelratio
|
|
1394
1394
|
if (size !== oldSize || viewport.dpr !== oldDpr) {
|
|
1395
|
+
var _size$updateStyle;
|
|
1395
1396
|
oldSize = size;
|
|
1396
1397
|
oldDpr = viewport.dpr;
|
|
1397
1398
|
// Update camera & renderer
|
|
1398
1399
|
updateCamera(camera, size);
|
|
1399
1400
|
gl.setPixelRatio(viewport.dpr);
|
|
1400
|
-
|
|
1401
|
+
const updateStyle = (_size$updateStyle = size.updateStyle) != null ? _size$updateStyle : typeof HTMLCanvasElement !== 'undefined' && gl.domElement instanceof HTMLCanvasElement;
|
|
1402
|
+
gl.setSize(size.width, size.height, updateStyle);
|
|
1401
1403
|
}
|
|
1402
1404
|
|
|
1403
1405
|
// Update viewport once the camera changes
|
|
@@ -1673,14 +1675,9 @@ const createRendererInstance = (gl, canvas) => {
|
|
|
1673
1675
|
...gl
|
|
1674
1676
|
});
|
|
1675
1677
|
};
|
|
1676
|
-
function isCanvas(maybeCanvas) {
|
|
1677
|
-
return maybeCanvas instanceof HTMLCanvasElement;
|
|
1678
|
-
}
|
|
1679
1678
|
function computeInitialSize(canvas, defaultSize) {
|
|
1680
|
-
if (defaultSize)
|
|
1681
|
-
|
|
1682
|
-
}
|
|
1683
|
-
if (isCanvas(canvas) && canvas.parentElement) {
|
|
1679
|
+
if (defaultSize) return defaultSize;
|
|
1680
|
+
if (typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement && canvas.parentElement) {
|
|
1684
1681
|
const {
|
|
1685
1682
|
width,
|
|
1686
1683
|
height,
|
|
@@ -1693,6 +1690,13 @@ function computeInitialSize(canvas, defaultSize) {
|
|
|
1693
1690
|
top,
|
|
1694
1691
|
left
|
|
1695
1692
|
};
|
|
1693
|
+
} else if (typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas) {
|
|
1694
|
+
return {
|
|
1695
|
+
width: canvas.width,
|
|
1696
|
+
height: canvas.height,
|
|
1697
|
+
top: 0,
|
|
1698
|
+
left: 0
|
|
1699
|
+
};
|
|
1696
1700
|
}
|
|
1697
1701
|
return {
|
|
1698
1702
|
width: 0,
|
|
@@ -1880,13 +1884,13 @@ function createRoot(canvas) {
|
|
|
1880
1884
|
if (events && !state.events.handlers) state.set({
|
|
1881
1885
|
events: events(store)
|
|
1882
1886
|
});
|
|
1883
|
-
// Check pixelratio
|
|
1884
|
-
if (dpr && state.viewport.dpr !== calculateDpr(dpr)) state.setDpr(dpr);
|
|
1885
1887
|
// Check size, allow it to take on container bounds initially
|
|
1886
1888
|
const size = computeInitialSize(canvas, propsSize);
|
|
1887
1889
|
if (!is.equ(size, state.size, shallowLoose)) {
|
|
1888
1890
|
state.setSize(size.width, size.height, size.updateStyle, size.top, size.left);
|
|
1889
1891
|
}
|
|
1892
|
+
// Check pixelratio
|
|
1893
|
+
if (dpr && state.viewport.dpr !== calculateDpr(dpr)) state.setDpr(dpr);
|
|
1890
1894
|
// Check frameloop
|
|
1891
1895
|
if (state.frameloop !== frameloop) state.setFrameloop(frameloop);
|
|
1892
1896
|
// Check pointer missed
|
|
@@ -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-d1fc6689.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-17c44482.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-37bd4d5c.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-37bd4d5c.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-d1fc6689.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-17c44482.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-37bd4d5c.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-37bd4d5c.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';
|