@react-three/fiber 8.11.2 → 8.11.4
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/declarations/src/core/utils.d.ts +6 -1
- package/dist/{index-ce6281d5.cjs.prod.js → index-17c44482.cjs.prod.js} +25 -23
- package/dist/{index-3c94c6e9.esm.js → index-37bd4d5c.esm.js} +25 -23
- package/dist/{index-b2f18198.cjs.dev.js → index-d1fc6689.cjs.dev.js} +25 -23
- 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;
|
|
@@ -2,6 +2,12 @@ import * as THREE from 'three';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { AttachType, Instance, InstanceProps, LocalState } from './renderer';
|
|
4
4
|
import { Dpr, RootState, Size } from './store';
|
|
5
|
+
export declare type ColorManagementRepresentation = {
|
|
6
|
+
enabled: boolean | never;
|
|
7
|
+
} | {
|
|
8
|
+
legacyMode: boolean | never;
|
|
9
|
+
};
|
|
10
|
+
export declare const ColorManagement: ColorManagementRepresentation | null;
|
|
5
11
|
export declare type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
|
|
6
12
|
export declare const isOrthographicCamera: (def: Camera) => def is THREE.OrthographicCamera;
|
|
7
13
|
export declare const isRef: (obj: any) => obj is React.MutableRefObject<unknown>;
|
|
@@ -81,4 +87,3 @@ export declare function updateInstance(instance: Instance): void;
|
|
|
81
87
|
export declare function updateCamera(camera: Camera & {
|
|
82
88
|
manual?: boolean;
|
|
83
89
|
}, size: Size): void;
|
|
84
|
-
export declare function setDeep(obj: any, value: any, keys: string[]): any;
|
|
@@ -38,6 +38,14 @@ var threeTypes = /*#__PURE__*/Object.freeze({
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
var _window$document, _window$navigator;
|
|
41
|
+
/**
|
|
42
|
+
* Safely accesses a deeply-nested value on an object to get around static bundler analysis.
|
|
43
|
+
*/
|
|
44
|
+
const getDeep = (obj, ...keys) => keys.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
|
|
45
|
+
/**
|
|
46
|
+
* The current THREE.ColorManagement instance, if present.
|
|
47
|
+
*/
|
|
48
|
+
const ColorManagement = 'ColorManagement' in THREE__namespace && getDeep(THREE__namespace, 'ColorManagement') || null;
|
|
41
49
|
const isOrthographicCamera = def => def && def.isOrthographicCamera;
|
|
42
50
|
const isRef = obj => obj && obj.hasOwnProperty('current');
|
|
43
51
|
|
|
@@ -363,8 +371,7 @@ function applyProps$1(instance, data) {
|
|
|
363
371
|
// For versions of three which don't support THREE.ColorManagement,
|
|
364
372
|
// Auto-convert sRGB colors
|
|
365
373
|
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
366
|
-
|
|
367
|
-
if (!supportsColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
|
|
374
|
+
if (!ColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
|
|
368
375
|
}
|
|
369
376
|
// Else, just overwrite the value
|
|
370
377
|
} else {
|
|
@@ -420,15 +427,6 @@ function updateCamera(camera, size) {
|
|
|
420
427
|
}
|
|
421
428
|
}
|
|
422
429
|
|
|
423
|
-
/**
|
|
424
|
-
* Safely sets a deeply-nested value on an object.
|
|
425
|
-
*/
|
|
426
|
-
function setDeep(obj, value, keys) {
|
|
427
|
-
const key = keys.pop();
|
|
428
|
-
const target = keys.reduce((acc, key) => acc[key], obj);
|
|
429
|
-
return target[key] = value;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
430
|
function makeId(event) {
|
|
433
431
|
return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
|
|
434
432
|
}
|
|
@@ -1394,12 +1392,14 @@ const createStore = (invalidate, advance) => {
|
|
|
1394
1392
|
|
|
1395
1393
|
// Resize camera and renderer on changes to size and pixelratio
|
|
1396
1394
|
if (size !== oldSize || viewport.dpr !== oldDpr) {
|
|
1395
|
+
var _size$updateStyle;
|
|
1397
1396
|
oldSize = size;
|
|
1398
1397
|
oldDpr = viewport.dpr;
|
|
1399
1398
|
// Update camera & renderer
|
|
1400
1399
|
updateCamera(camera, size);
|
|
1401
1400
|
gl.setPixelRatio(viewport.dpr);
|
|
1402
|
-
|
|
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);
|
|
1403
1403
|
}
|
|
1404
1404
|
|
|
1405
1405
|
// Update viewport once the camera changes
|
|
@@ -1675,14 +1675,9 @@ const createRendererInstance = (gl, canvas) => {
|
|
|
1675
1675
|
...gl
|
|
1676
1676
|
});
|
|
1677
1677
|
};
|
|
1678
|
-
function isCanvas(maybeCanvas) {
|
|
1679
|
-
return maybeCanvas instanceof HTMLCanvasElement;
|
|
1680
|
-
}
|
|
1681
1678
|
function computeInitialSize(canvas, defaultSize) {
|
|
1682
|
-
if (defaultSize)
|
|
1683
|
-
|
|
1684
|
-
}
|
|
1685
|
-
if (isCanvas(canvas) && canvas.parentElement) {
|
|
1679
|
+
if (defaultSize) return defaultSize;
|
|
1680
|
+
if (typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement && canvas.parentElement) {
|
|
1686
1681
|
const {
|
|
1687
1682
|
width,
|
|
1688
1683
|
height,
|
|
@@ -1695,6 +1690,13 @@ function computeInitialSize(canvas, defaultSize) {
|
|
|
1695
1690
|
top,
|
|
1696
1691
|
left
|
|
1697
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
|
+
};
|
|
1698
1700
|
}
|
|
1699
1701
|
return {
|
|
1700
1702
|
width: 0,
|
|
@@ -1857,8 +1859,8 @@ function createRoot(canvas) {
|
|
|
1857
1859
|
|
|
1858
1860
|
// Safely set color management if available.
|
|
1859
1861
|
// Avoid accessing THREE.ColorManagement to play nice with older versions
|
|
1860
|
-
if (
|
|
1861
|
-
|
|
1862
|
+
if (ColorManagement) {
|
|
1863
|
+
if ('enabled' in ColorManagement) ColorManagement.enabled = !legacy;else if ('legacyMode' in ColorManagement) ColorManagement.legacyMode = legacy;
|
|
1862
1864
|
}
|
|
1863
1865
|
const outputEncoding = linear ? THREE__namespace.LinearEncoding : THREE__namespace.sRGBEncoding;
|
|
1864
1866
|
const toneMapping = flat ? THREE__namespace.NoToneMapping : THREE__namespace.ACESFilmicToneMapping;
|
|
@@ -1882,13 +1884,13 @@ function createRoot(canvas) {
|
|
|
1882
1884
|
if (events && !state.events.handlers) state.set({
|
|
1883
1885
|
events: events(store)
|
|
1884
1886
|
});
|
|
1885
|
-
// Check pixelratio
|
|
1886
|
-
if (dpr && state.viewport.dpr !== calculateDpr(dpr)) state.setDpr(dpr);
|
|
1887
1887
|
// Check size, allow it to take on container bounds initially
|
|
1888
1888
|
const size = computeInitialSize(canvas, propsSize);
|
|
1889
1889
|
if (!is.equ(size, state.size, shallowLoose)) {
|
|
1890
1890
|
state.setSize(size.width, size.height, size.updateStyle, size.top, size.left);
|
|
1891
1891
|
}
|
|
1892
|
+
// Check pixelratio
|
|
1893
|
+
if (dpr && state.viewport.dpr !== calculateDpr(dpr)) state.setDpr(dpr);
|
|
1892
1894
|
// Check frameloop
|
|
1893
1895
|
if (state.frameloop !== frameloop) state.setFrameloop(frameloop);
|
|
1894
1896
|
// Check pointer missed
|
|
@@ -11,6 +11,14 @@ var threeTypes = /*#__PURE__*/Object.freeze({
|
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
var _window$document, _window$navigator;
|
|
14
|
+
/**
|
|
15
|
+
* Safely accesses a deeply-nested value on an object to get around static bundler analysis.
|
|
16
|
+
*/
|
|
17
|
+
const getDeep = (obj, ...keys) => keys.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
|
|
18
|
+
/**
|
|
19
|
+
* The current THREE.ColorManagement instance, if present.
|
|
20
|
+
*/
|
|
21
|
+
const ColorManagement = 'ColorManagement' in THREE && getDeep(THREE, 'ColorManagement') || null;
|
|
14
22
|
const isOrthographicCamera = def => def && def.isOrthographicCamera;
|
|
15
23
|
const isRef = obj => obj && obj.hasOwnProperty('current');
|
|
16
24
|
|
|
@@ -336,8 +344,7 @@ function applyProps$1(instance, data) {
|
|
|
336
344
|
// For versions of three which don't support THREE.ColorManagement,
|
|
337
345
|
// Auto-convert sRGB colors
|
|
338
346
|
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
339
|
-
|
|
340
|
-
if (!supportsColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
|
|
347
|
+
if (!ColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
|
|
341
348
|
}
|
|
342
349
|
// Else, just overwrite the value
|
|
343
350
|
} else {
|
|
@@ -393,15 +400,6 @@ function updateCamera(camera, size) {
|
|
|
393
400
|
}
|
|
394
401
|
}
|
|
395
402
|
|
|
396
|
-
/**
|
|
397
|
-
* Safely sets a deeply-nested value on an object.
|
|
398
|
-
*/
|
|
399
|
-
function setDeep(obj, value, keys) {
|
|
400
|
-
const key = keys.pop();
|
|
401
|
-
const target = keys.reduce((acc, key) => acc[key], obj);
|
|
402
|
-
return target[key] = value;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
403
|
function makeId(event) {
|
|
406
404
|
return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
|
|
407
405
|
}
|
|
@@ -1367,12 +1365,14 @@ const createStore = (invalidate, advance) => {
|
|
|
1367
1365
|
|
|
1368
1366
|
// Resize camera and renderer on changes to size and pixelratio
|
|
1369
1367
|
if (size !== oldSize || viewport.dpr !== oldDpr) {
|
|
1368
|
+
var _size$updateStyle;
|
|
1370
1369
|
oldSize = size;
|
|
1371
1370
|
oldDpr = viewport.dpr;
|
|
1372
1371
|
// Update camera & renderer
|
|
1373
1372
|
updateCamera(camera, size);
|
|
1374
1373
|
gl.setPixelRatio(viewport.dpr);
|
|
1375
|
-
|
|
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);
|
|
1376
1376
|
}
|
|
1377
1377
|
|
|
1378
1378
|
// Update viewport once the camera changes
|
|
@@ -1648,14 +1648,9 @@ const createRendererInstance = (gl, canvas) => {
|
|
|
1648
1648
|
...gl
|
|
1649
1649
|
});
|
|
1650
1650
|
};
|
|
1651
|
-
function isCanvas(maybeCanvas) {
|
|
1652
|
-
return maybeCanvas instanceof HTMLCanvasElement;
|
|
1653
|
-
}
|
|
1654
1651
|
function computeInitialSize(canvas, defaultSize) {
|
|
1655
|
-
if (defaultSize)
|
|
1656
|
-
|
|
1657
|
-
}
|
|
1658
|
-
if (isCanvas(canvas) && canvas.parentElement) {
|
|
1652
|
+
if (defaultSize) return defaultSize;
|
|
1653
|
+
if (typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement && canvas.parentElement) {
|
|
1659
1654
|
const {
|
|
1660
1655
|
width,
|
|
1661
1656
|
height,
|
|
@@ -1668,6 +1663,13 @@ function computeInitialSize(canvas, defaultSize) {
|
|
|
1668
1663
|
top,
|
|
1669
1664
|
left
|
|
1670
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
|
+
};
|
|
1671
1673
|
}
|
|
1672
1674
|
return {
|
|
1673
1675
|
width: 0,
|
|
@@ -1830,8 +1832,8 @@ function createRoot(canvas) {
|
|
|
1830
1832
|
|
|
1831
1833
|
// Safely set color management if available.
|
|
1832
1834
|
// Avoid accessing THREE.ColorManagement to play nice with older versions
|
|
1833
|
-
if (
|
|
1834
|
-
|
|
1835
|
+
if (ColorManagement) {
|
|
1836
|
+
if ('enabled' in ColorManagement) ColorManagement.enabled = !legacy;else if ('legacyMode' in ColorManagement) ColorManagement.legacyMode = legacy;
|
|
1835
1837
|
}
|
|
1836
1838
|
const outputEncoding = linear ? THREE.LinearEncoding : THREE.sRGBEncoding;
|
|
1837
1839
|
const toneMapping = flat ? THREE.NoToneMapping : THREE.ACESFilmicToneMapping;
|
|
@@ -1855,13 +1857,13 @@ function createRoot(canvas) {
|
|
|
1855
1857
|
if (events && !state.events.handlers) state.set({
|
|
1856
1858
|
events: events(store)
|
|
1857
1859
|
});
|
|
1858
|
-
// Check pixelratio
|
|
1859
|
-
if (dpr && state.viewport.dpr !== calculateDpr(dpr)) state.setDpr(dpr);
|
|
1860
1860
|
// Check size, allow it to take on container bounds initially
|
|
1861
1861
|
const size = computeInitialSize(canvas, propsSize);
|
|
1862
1862
|
if (!is.equ(size, state.size, shallowLoose)) {
|
|
1863
1863
|
state.setSize(size.width, size.height, size.updateStyle, size.top, size.left);
|
|
1864
1864
|
}
|
|
1865
|
+
// Check pixelratio
|
|
1866
|
+
if (dpr && state.viewport.dpr !== calculateDpr(dpr)) state.setDpr(dpr);
|
|
1865
1867
|
// Check frameloop
|
|
1866
1868
|
if (state.frameloop !== frameloop) state.setFrameloop(frameloop);
|
|
1867
1869
|
// Check pointer missed
|
|
@@ -38,6 +38,14 @@ var threeTypes = /*#__PURE__*/Object.freeze({
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
var _window$document, _window$navigator;
|
|
41
|
+
/**
|
|
42
|
+
* Safely accesses a deeply-nested value on an object to get around static bundler analysis.
|
|
43
|
+
*/
|
|
44
|
+
const getDeep = (obj, ...keys) => keys.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
|
|
45
|
+
/**
|
|
46
|
+
* The current THREE.ColorManagement instance, if present.
|
|
47
|
+
*/
|
|
48
|
+
const ColorManagement = 'ColorManagement' in THREE__namespace && getDeep(THREE__namespace, 'ColorManagement') || null;
|
|
41
49
|
const isOrthographicCamera = def => def && def.isOrthographicCamera;
|
|
42
50
|
const isRef = obj => obj && obj.hasOwnProperty('current');
|
|
43
51
|
|
|
@@ -363,8 +371,7 @@ function applyProps$1(instance, data) {
|
|
|
363
371
|
// For versions of three which don't support THREE.ColorManagement,
|
|
364
372
|
// Auto-convert sRGB colors
|
|
365
373
|
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
366
|
-
|
|
367
|
-
if (!supportsColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
|
|
374
|
+
if (!ColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
|
|
368
375
|
}
|
|
369
376
|
// Else, just overwrite the value
|
|
370
377
|
} else {
|
|
@@ -420,15 +427,6 @@ function updateCamera(camera, size) {
|
|
|
420
427
|
}
|
|
421
428
|
}
|
|
422
429
|
|
|
423
|
-
/**
|
|
424
|
-
* Safely sets a deeply-nested value on an object.
|
|
425
|
-
*/
|
|
426
|
-
function setDeep(obj, value, keys) {
|
|
427
|
-
const key = keys.pop();
|
|
428
|
-
const target = keys.reduce((acc, key) => acc[key], obj);
|
|
429
|
-
return target[key] = value;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
430
|
function makeId(event) {
|
|
433
431
|
return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
|
|
434
432
|
}
|
|
@@ -1394,12 +1392,14 @@ const createStore = (invalidate, advance) => {
|
|
|
1394
1392
|
|
|
1395
1393
|
// Resize camera and renderer on changes to size and pixelratio
|
|
1396
1394
|
if (size !== oldSize || viewport.dpr !== oldDpr) {
|
|
1395
|
+
var _size$updateStyle;
|
|
1397
1396
|
oldSize = size;
|
|
1398
1397
|
oldDpr = viewport.dpr;
|
|
1399
1398
|
// Update camera & renderer
|
|
1400
1399
|
updateCamera(camera, size);
|
|
1401
1400
|
gl.setPixelRatio(viewport.dpr);
|
|
1402
|
-
|
|
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);
|
|
1403
1403
|
}
|
|
1404
1404
|
|
|
1405
1405
|
// Update viewport once the camera changes
|
|
@@ -1675,14 +1675,9 @@ const createRendererInstance = (gl, canvas) => {
|
|
|
1675
1675
|
...gl
|
|
1676
1676
|
});
|
|
1677
1677
|
};
|
|
1678
|
-
function isCanvas(maybeCanvas) {
|
|
1679
|
-
return maybeCanvas instanceof HTMLCanvasElement;
|
|
1680
|
-
}
|
|
1681
1678
|
function computeInitialSize(canvas, defaultSize) {
|
|
1682
|
-
if (defaultSize)
|
|
1683
|
-
|
|
1684
|
-
}
|
|
1685
|
-
if (isCanvas(canvas) && canvas.parentElement) {
|
|
1679
|
+
if (defaultSize) return defaultSize;
|
|
1680
|
+
if (typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement && canvas.parentElement) {
|
|
1686
1681
|
const {
|
|
1687
1682
|
width,
|
|
1688
1683
|
height,
|
|
@@ -1695,6 +1690,13 @@ function computeInitialSize(canvas, defaultSize) {
|
|
|
1695
1690
|
top,
|
|
1696
1691
|
left
|
|
1697
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
|
+
};
|
|
1698
1700
|
}
|
|
1699
1701
|
return {
|
|
1700
1702
|
width: 0,
|
|
@@ -1857,8 +1859,8 @@ function createRoot(canvas) {
|
|
|
1857
1859
|
|
|
1858
1860
|
// Safely set color management if available.
|
|
1859
1861
|
// Avoid accessing THREE.ColorManagement to play nice with older versions
|
|
1860
|
-
if (
|
|
1861
|
-
|
|
1862
|
+
if (ColorManagement) {
|
|
1863
|
+
if ('enabled' in ColorManagement) ColorManagement.enabled = !legacy;else if ('legacyMode' in ColorManagement) ColorManagement.legacyMode = legacy;
|
|
1862
1864
|
}
|
|
1863
1865
|
const outputEncoding = linear ? THREE__namespace.LinearEncoding : THREE__namespace.sRGBEncoding;
|
|
1864
1866
|
const toneMapping = flat ? THREE__namespace.NoToneMapping : THREE__namespace.ACESFilmicToneMapping;
|
|
@@ -1882,13 +1884,13 @@ function createRoot(canvas) {
|
|
|
1882
1884
|
if (events && !state.events.handlers) state.set({
|
|
1883
1885
|
events: events(store)
|
|
1884
1886
|
});
|
|
1885
|
-
// Check pixelratio
|
|
1886
|
-
if (dpr && state.viewport.dpr !== calculateDpr(dpr)) state.setDpr(dpr);
|
|
1887
1887
|
// Check size, allow it to take on container bounds initially
|
|
1888
1888
|
const size = computeInitialSize(canvas, propsSize);
|
|
1889
1889
|
if (!is.equ(size, state.size, shallowLoose)) {
|
|
1890
1890
|
state.setSize(size.width, size.height, size.updateStyle, size.top, size.left);
|
|
1891
1891
|
}
|
|
1892
|
+
// Check pixelratio
|
|
1893
|
+
if (dpr && state.viewport.dpr !== calculateDpr(dpr)) state.setDpr(dpr);
|
|
1892
1894
|
// Check frameloop
|
|
1893
1895
|
if (state.frameloop !== frameloop) state.setFrameloop(frameloop);
|
|
1894
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';
|