@react-three/drei 9.82.0 → 9.82.1
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/README.md +6 -2
- package/core/BBAnchor.cjs.js +1 -1
- package/core/BBAnchor.js +1 -1
- package/core/useGLTF.cjs.js +1 -1
- package/core/useGLTF.d.ts +1 -0
- package/core/useGLTF.js +6 -1
- package/index.cjs.js +1 -1
- package/package.json +2 -1
- package/react-three-drei-0.0.0-semantic-release.tgz +0 -0
package/README.md
CHANGED
|
@@ -2796,6 +2796,10 @@ useGLTF(url, '/draco-gltf')
|
|
|
2796
2796
|
useGLTF.preload(url)
|
|
2797
2797
|
```
|
|
2798
2798
|
|
|
2799
|
+
If you want to use your own draco decoder globally, you can pass it through `useGLTF.setDecoderPath(path)`:
|
|
2800
|
+
|
|
2801
|
+
````jsx
|
|
2802
|
+
|
|
2799
2803
|
> **Note** <br>If you are using the CDN loaded draco binaries, you can get a small speedup in loading time by prefetching them.
|
|
2800
2804
|
>
|
|
2801
2805
|
> You can accomplish this by adding two `<link>` tags to your `<head>` tag, as below. The version in those URLs must exactly match what [useGLTF](src/core/useGLTF.tsx#L18) uses for this to work. If you're using create-react-app, `public/index.html` file contains the `<head>` tag.
|
|
@@ -2828,7 +2832,7 @@ function SuzanneFBX() {
|
|
|
2828
2832
|
let fbx = useFBX('suzanne/suzanne.fbx')
|
|
2829
2833
|
return <primitive object={fbx} />
|
|
2830
2834
|
}
|
|
2831
|
-
|
|
2835
|
+
````
|
|
2832
2836
|
|
|
2833
2837
|
#### useTexture
|
|
2834
2838
|
|
|
@@ -3320,7 +3324,7 @@ return (
|
|
|
3320
3324
|
If you still experience flip flops despite the bounds you can define a limit of `flipflops`. If it is met `onFallback` will be triggered which typically sets a lowest possible baseline for the app. After the fallback has been called PerformanceMonitor will shut down.
|
|
3321
3325
|
|
|
3322
3326
|
```jsx
|
|
3323
|
-
<PerformanceMonitor flipflops={3} onFallback={() => setDpr(1)}/>
|
|
3327
|
+
<PerformanceMonitor flipflops={3} onFallback={() => setDpr(1)} />
|
|
3324
3328
|
```
|
|
3325
3329
|
|
|
3326
3330
|
PerformanceMonitor can also have children, if you wrap your app in it you get to use `usePerformanceMonitor` which allows individual components down the nested tree to respond to performance changes on their own.
|
package/core/BBAnchor.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("react"),t=require("three"),n=require("@react-three/fiber");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function c(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("react"),t=require("three"),n=require("@react-three/fiber");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function c(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var a=u(e),o=c(r),i=c(t);const s=new i.Box3,f=new i.Vector3;exports.BBAnchor=({anchor:e,...r})=>{const t=o.useRef(null),u=o.useRef(null);return o.useEffect((()=>{var e,r;null!=(e=t.current)&&null!=(r=e.parent)&&r.parent&&(u.current=t.current.parent,t.current.parent.parent.add(t.current))}),[]),n.useFrame((()=>{u.current&&(s.setFromObject(u.current),s.getSize(f),t.current.position.set(u.current.position.x+f.x*(Array.isArray(e)?e[0]:e.x)/2,u.current.position.y+f.y*(Array.isArray(e)?e[1]:e.y)/2,u.current.position.z+f.z*(Array.isArray(e)?e[2]:e.z)/2))})),o.createElement("group",a.default({ref:t},r))};
|
package/core/BBAnchor.js
CHANGED
|
@@ -26,7 +26,7 @@ const BBAnchor = ({
|
|
|
26
26
|
if (parentRef.current) {
|
|
27
27
|
boundingBox.setFromObject(parentRef.current);
|
|
28
28
|
boundingBox.getSize(boundingBoxSize);
|
|
29
|
-
ref.current.position.set(parentRef.current.position.x + boundingBoxSize.x * anchor[0] / 2, parentRef.current.position.y + boundingBoxSize.y * anchor[1] / 2, parentRef.current.position.z + boundingBoxSize.z * anchor[2] / 2);
|
|
29
|
+
ref.current.position.set(parentRef.current.position.x + boundingBoxSize.x * (Array.isArray(anchor) ? anchor[0] : anchor.x) / 2, parentRef.current.position.y + boundingBoxSize.y * (Array.isArray(anchor) ? anchor[1] : anchor.y) / 2, parentRef.current.position.z + boundingBoxSize.z * (Array.isArray(anchor) ? anchor[2] : anchor.z) / 2);
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
return /*#__PURE__*/React.createElement("group", _extends({
|
package/core/useGLTF.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three-stdlib"),r=require("@react-three/fiber");let o=null;function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three-stdlib"),r=require("@react-three/fiber");let o=null,t="https://www.gstatic.com/draco/versioned/decoders/1.5.5/";function d(r,d,s){return a=>{s&&s(a),r&&(o||(o=new e.DRACOLoader),o.setDecoderPath("string"==typeof r?r:t),a.setDRACOLoader(o)),d&&a.setMeshoptDecoder("function"==typeof e.MeshoptDecoder?e.MeshoptDecoder():e.MeshoptDecoder)}}function s(o,t=!0,s=!0,a){return r.useLoader(e.GLTFLoader,o,d(t,s,a))}s.preload=(o,t=!0,s=!0,a)=>r.useLoader.preload(e.GLTFLoader,o,d(t,s,a)),s.clear=o=>r.useLoader.clear(e.GLTFLoader,o),s.setDecoderPath=e=>{t=e},exports.useGLTF=s;
|
package/core/useGLTF.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export declare function useGLTF<T extends string | string[]>(path: T, useDraco?:
|
|
|
3
3
|
export declare namespace useGLTF {
|
|
4
4
|
var preload: (path: string | string[], useDraco?: string | boolean, useMeshOpt?: boolean, extendLoader?: ((loader: GLTFLoader) => void) | undefined) => undefined;
|
|
5
5
|
var clear: (input: string | string[]) => void;
|
|
6
|
+
var setDecoderPath: (path: string) => void;
|
|
6
7
|
}
|
package/core/useGLTF.js
CHANGED
|
@@ -3,6 +3,7 @@ import { useLoader } from '@react-three/fiber';
|
|
|
3
3
|
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
let dracoLoader = null;
|
|
6
|
+
let decoderPath = 'https://www.gstatic.com/draco/versioned/decoders/1.5.5/';
|
|
6
7
|
|
|
7
8
|
function extensions(useDraco, useMeshopt, extendLoader) {
|
|
8
9
|
return loader => {
|
|
@@ -15,7 +16,7 @@ function extensions(useDraco, useMeshopt, extendLoader) {
|
|
|
15
16
|
dracoLoader = new DRACOLoader();
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
dracoLoader.setDecoderPath(typeof useDraco === 'string' ? useDraco :
|
|
19
|
+
dracoLoader.setDecoderPath(typeof useDraco === 'string' ? useDraco : decoderPath);
|
|
19
20
|
loader.setDRACOLoader(dracoLoader);
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -34,4 +35,8 @@ useGLTF.preload = (path, useDraco = true, useMeshOpt = true, extendLoader) => us
|
|
|
34
35
|
|
|
35
36
|
useGLTF.clear = input => useLoader.clear(GLTFLoader, input);
|
|
36
37
|
|
|
38
|
+
useGLTF.setDecoderPath = path => {
|
|
39
|
+
decoderPath = path;
|
|
40
|
+
};
|
|
41
|
+
|
|
37
42
|
export { useGLTF };
|