@react-three/fiber 9.0.0-rc.9 → 9.0.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/hooks.d.ts +9 -7
- package/dist/declarations/src/native/Canvas.d.ts +1 -1
- package/dist/declarations/src/three-types.d.ts +3 -2
- package/dist/declarations/src/web/Canvas.d.ts +1 -1
- package/dist/{events-aba3c3d1.esm.js → events-0dc84b81.esm.js} +6 -4
- package/dist/{events-b02714fc.cjs.dev.js → events-29e84b1f.cjs.dev.js} +6 -4
- package/dist/{events-bd708dc8.cjs.prod.js → events-8ef03cf1.cjs.prod.js} +6 -4
- package/dist/react-three-fiber.cjs.dev.js +2 -2
- package/dist/react-three-fiber.cjs.prod.js +2 -2
- package/dist/react-three-fiber.esm.js +3 -3
- package/native/dist/react-three-fiber-native.cjs.dev.js +2 -2
- package/native/dist/react-three-fiber-native.cjs.prod.js +2 -2
- package/native/dist/react-three-fiber-native.esm.js +3 -3
- package/package.json +6 -6
- package/readme.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -31,11 +31,13 @@ export declare function useFrame(callback: RenderCallback, renderPriority?: numb
|
|
|
31
31
|
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
|
|
32
32
|
*/
|
|
33
33
|
export declare function useGraph(object: THREE.Object3D): ObjectMap;
|
|
34
|
-
type
|
|
35
|
-
type
|
|
36
|
-
|
|
34
|
+
type InputLike = string | string[] | string[][] | Readonly<string | string[] | string[][]>;
|
|
35
|
+
type LoaderLike = THREE.Loader<any, InputLike>;
|
|
36
|
+
type GLTFLike = {
|
|
37
37
|
scene: THREE.Object3D;
|
|
38
|
-
}
|
|
38
|
+
};
|
|
39
|
+
type LoaderInstance<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = T extends ConstructorRepresentation<LoaderLike> ? InstanceType<T> : T;
|
|
40
|
+
export type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = Awaited<ReturnType<LoaderInstance<T>['loadAsync']>> extends infer R ? R extends GLTFLike ? R & ObjectMap : R : never;
|
|
39
41
|
export type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (loader: LoaderInstance<T>) => void;
|
|
40
42
|
/**
|
|
41
43
|
* Synchronously loads and caches assets with a three loader.
|
|
@@ -43,9 +45,9 @@ export type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLi
|
|
|
43
45
|
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
44
46
|
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
45
47
|
*/
|
|
46
|
-
export declare function useLoader<
|
|
48
|
+
export declare function useLoader<I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void): I extends any[] ? LoaderResult<L>[] : LoaderResult<L>;
|
|
47
49
|
export declare namespace useLoader {
|
|
48
|
-
var preload: <
|
|
49
|
-
var clear: <
|
|
50
|
+
var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L> | undefined) => void;
|
|
51
|
+
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I) => void;
|
|
50
52
|
}
|
|
51
53
|
export {};
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { View, type ViewProps, type ViewStyle } from 'react-native';
|
|
3
3
|
import { RenderProps } from "../core/index.js";
|
|
4
4
|
export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size' | 'dpr'>, Omit<ViewProps, 'children'> {
|
|
5
|
-
children
|
|
5
|
+
children?: React.ReactNode;
|
|
6
6
|
style?: ViewStyle;
|
|
7
7
|
ref?: React.Ref<View>;
|
|
8
8
|
}
|
|
@@ -37,9 +37,10 @@ type DuplicateKeys<T, U> = Extract<keyof T, keyof U>;
|
|
|
37
37
|
type Conflicts = DuplicateKeys<JSX.IntrinsicElements, {
|
|
38
38
|
[K in keyof ThreeExports as Uncapitalize<K>]: any;
|
|
39
39
|
}>;
|
|
40
|
-
type
|
|
41
|
-
[K in keyof
|
|
40
|
+
export type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
41
|
+
[K in keyof T & string as Uncapitalize<K> extends Conflicts ? `three${Capitalize<K>}` : Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never;
|
|
42
42
|
};
|
|
43
|
+
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>;
|
|
43
44
|
export interface ThreeElements extends ThreeElementsImpl {
|
|
44
45
|
primitive: Omit<ThreeElement<any>, 'args'> & {
|
|
45
46
|
object: object;
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { Options as ResizeOptions } from 'react-use-measure';
|
|
3
3
|
import { RenderProps } from "../core/index.js";
|
|
4
4
|
export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
-
children
|
|
5
|
+
children?: React.ReactNode;
|
|
6
6
|
ref?: React.Ref<HTMLCanvasElement>;
|
|
7
7
|
/** Canvas fallback content, similar to img's alt prop */
|
|
8
8
|
fallback?: React.ReactNode;
|
|
@@ -370,19 +370,21 @@ function applyProps(object, props) {
|
|
|
370
370
|
// Layers must be written to the mask property
|
|
371
371
|
if (target instanceof THREE.Layers && value instanceof THREE.Layers) {
|
|
372
372
|
target.mask = value.mask;
|
|
373
|
-
}
|
|
373
|
+
}
|
|
374
|
+
// Set colors if valid color representation for automatic conversion (copy)
|
|
375
|
+
else if (target instanceof THREE.Color && isColorRepresentation(value)) {
|
|
374
376
|
target.set(value);
|
|
375
377
|
}
|
|
376
378
|
// 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) {
|
|
379
|
+
else if (target !== null && typeof target === 'object' && typeof target.set === 'function' && typeof target.copy === 'function' && value != null && value.constructor && target.constructor === value.constructor) {
|
|
378
380
|
target.copy(value);
|
|
379
381
|
}
|
|
380
382
|
// Set array types
|
|
381
|
-
else if (target && typeof target.set === 'function' && Array.isArray(value)) {
|
|
383
|
+
else if (target !== null && typeof target === 'object' && typeof target.set === 'function' && Array.isArray(value)) {
|
|
382
384
|
if (typeof target.fromArray === 'function') target.fromArray(value);else target.set(...value);
|
|
383
385
|
}
|
|
384
386
|
// Set literal types
|
|
385
|
-
else if (target && typeof target.set === 'function' && typeof value === 'number') {
|
|
387
|
+
else if (target !== null && typeof target === 'object' && typeof target.set === 'function' && typeof value === 'number') {
|
|
386
388
|
// Allow setting array scalars
|
|
387
389
|
if (typeof target.setScalar === 'function') target.setScalar(value);
|
|
388
390
|
// Otherwise just set single value
|
|
@@ -396,19 +396,21 @@ function applyProps(object, props) {
|
|
|
396
396
|
// Layers must be written to the mask property
|
|
397
397
|
if (target instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) {
|
|
398
398
|
target.mask = value.mask;
|
|
399
|
-
}
|
|
399
|
+
}
|
|
400
|
+
// Set colors if valid color representation for automatic conversion (copy)
|
|
401
|
+
else if (target instanceof THREE__namespace.Color && isColorRepresentation(value)) {
|
|
400
402
|
target.set(value);
|
|
401
403
|
}
|
|
402
404
|
// 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) {
|
|
405
|
+
else if (target !== null && typeof target === 'object' && typeof target.set === 'function' && typeof target.copy === 'function' && value != null && value.constructor && target.constructor === value.constructor) {
|
|
404
406
|
target.copy(value);
|
|
405
407
|
}
|
|
406
408
|
// Set array types
|
|
407
|
-
else if (target && typeof target.set === 'function' && Array.isArray(value)) {
|
|
409
|
+
else if (target !== null && typeof target === 'object' && typeof target.set === 'function' && Array.isArray(value)) {
|
|
408
410
|
if (typeof target.fromArray === 'function') target.fromArray(value);else target.set(...value);
|
|
409
411
|
}
|
|
410
412
|
// Set literal types
|
|
411
|
-
else if (target && typeof target.set === 'function' && typeof value === 'number') {
|
|
413
|
+
else if (target !== null && typeof target === 'object' && typeof target.set === 'function' && typeof value === 'number') {
|
|
412
414
|
// Allow setting array scalars
|
|
413
415
|
if (typeof target.setScalar === 'function') target.setScalar(value);
|
|
414
416
|
// Otherwise just set single value
|
|
@@ -396,19 +396,21 @@ function applyProps(object, props) {
|
|
|
396
396
|
// Layers must be written to the mask property
|
|
397
397
|
if (target instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) {
|
|
398
398
|
target.mask = value.mask;
|
|
399
|
-
}
|
|
399
|
+
}
|
|
400
|
+
// Set colors if valid color representation for automatic conversion (copy)
|
|
401
|
+
else if (target instanceof THREE__namespace.Color && isColorRepresentation(value)) {
|
|
400
402
|
target.set(value);
|
|
401
403
|
}
|
|
402
404
|
// 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) {
|
|
405
|
+
else if (target !== null && typeof target === 'object' && typeof target.set === 'function' && typeof target.copy === 'function' && value != null && value.constructor && target.constructor === value.constructor) {
|
|
404
406
|
target.copy(value);
|
|
405
407
|
}
|
|
406
408
|
// Set array types
|
|
407
|
-
else if (target && typeof target.set === 'function' && Array.isArray(value)) {
|
|
409
|
+
else if (target !== null && typeof target === 'object' && typeof target.set === 'function' && Array.isArray(value)) {
|
|
408
410
|
if (typeof target.fromArray === 'function') target.fromArray(value);else target.set(...value);
|
|
409
411
|
}
|
|
410
412
|
// Set literal types
|
|
411
|
-
else if (target && typeof target.set === 'function' && typeof value === 'number') {
|
|
413
|
+
else if (target !== null && typeof target === 'object' && typeof target.set === 'function' && typeof value === 'number') {
|
|
412
414
|
// Allow setting array scalars
|
|
413
415
|
if (typeof target.setScalar === 'function') target.setScalar(value);
|
|
414
416
|
// Otherwise just set single value
|
|
@@ -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-29e84b1f.cjs.dev.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var THREE = require('three');
|
|
8
8
|
var useMeasure = require('react-use-measure');
|
|
@@ -135,7 +135,7 @@ function CanvasImpl({
|
|
|
135
135
|
fallback: /*#__PURE__*/jsxRuntime.jsx(events.Block, {
|
|
136
136
|
set: setBlock
|
|
137
137
|
}),
|
|
138
|
-
children: children
|
|
138
|
+
children: children != null ? children : null
|
|
139
139
|
})
|
|
140
140
|
})
|
|
141
141
|
}));
|
|
@@ -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-8ef03cf1.cjs.prod.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var THREE = require('three');
|
|
8
8
|
var useMeasure = require('react-use-measure');
|
|
@@ -135,7 +135,7 @@ function CanvasImpl({
|
|
|
135
135
|
fallback: /*#__PURE__*/jsxRuntime.jsx(events.Block, {
|
|
136
136
|
set: setBlock
|
|
137
137
|
}),
|
|
138
|
-
children: children
|
|
138
|
+
children: children != null ? children : null
|
|
139
139
|
})
|
|
140
140
|
})
|
|
141
141
|
}));
|
|
@@ -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-0dc84b81.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-0dc84b81.esm.js';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import * as THREE from 'three';
|
|
5
5
|
import useMeasure from 'react-use-measure';
|
|
@@ -108,7 +108,7 @@ function CanvasImpl({
|
|
|
108
108
|
fallback: /*#__PURE__*/jsx(Block, {
|
|
109
109
|
set: setBlock
|
|
110
110
|
}),
|
|
111
|
-
children: children
|
|
111
|
+
children: children != null ? children : null
|
|
112
112
|
})
|
|
113
113
|
})
|
|
114
114
|
}));
|
|
@@ -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-29e84b1f.cjs.dev.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var THREE = require('three');
|
|
8
8
|
var reactNative = require('react-native');
|
|
@@ -239,7 +239,7 @@ function CanvasImpl({
|
|
|
239
239
|
fallback: /*#__PURE__*/jsxRuntime.jsx(events.Block, {
|
|
240
240
|
set: setBlock
|
|
241
241
|
}),
|
|
242
|
-
children: children
|
|
242
|
+
children: children != null ? children : null
|
|
243
243
|
})
|
|
244
244
|
})
|
|
245
245
|
}));
|
|
@@ -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-8ef03cf1.cjs.prod.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var THREE = require('three');
|
|
8
8
|
var reactNative = require('react-native');
|
|
@@ -239,7 +239,7 @@ function CanvasImpl({
|
|
|
239
239
|
fallback: /*#__PURE__*/jsxRuntime.jsx(events.Block, {
|
|
240
240
|
set: setBlock
|
|
241
241
|
}),
|
|
242
|
-
children: children
|
|
242
|
+
children: children != null ? children : null
|
|
243
243
|
})
|
|
244
244
|
})
|
|
245
245
|
}));
|
|
@@ -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-0dc84b81.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-0dc84b81.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';
|
|
@@ -214,7 +214,7 @@ function CanvasImpl({
|
|
|
214
214
|
fallback: /*#__PURE__*/jsx(Block, {
|
|
215
215
|
set: setBlock
|
|
216
216
|
}),
|
|
217
|
-
children: children
|
|
217
|
+
children: children != null ? children : null
|
|
218
218
|
})
|
|
219
219
|
})
|
|
220
220
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-three/fiber",
|
|
3
|
-
"version": "9.0.0
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "A React renderer for Threejs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -43,16 +43,16 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@babel/runtime": "^7.17.8",
|
|
46
|
-
"@types/react-reconciler": "^0.28.
|
|
46
|
+
"@types/react-reconciler": "^0.28.9",
|
|
47
47
|
"@types/webxr": "*",
|
|
48
48
|
"base64-js": "^1.5.1",
|
|
49
49
|
"buffer": "^6.0.3",
|
|
50
|
-
"its-fine": "^
|
|
51
|
-
"react-reconciler": "0.31.0",
|
|
50
|
+
"its-fine": "^2.0.0",
|
|
51
|
+
"react-reconciler": "^0.31.0",
|
|
52
52
|
"react-use-measure": "^2.1.7",
|
|
53
|
-
"scheduler": "0.25.0",
|
|
53
|
+
"scheduler": "^0.25.0",
|
|
54
54
|
"suspend-react": "^0.1.3",
|
|
55
|
-
"zustand": "^
|
|
55
|
+
"zustand": "^5.0.3"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"expo": ">=43.0",
|