@react-three/drei 9.89.1 → 9.89.2
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/core/useTexture.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),r=require("@react-three/fiber"),t=require("react");const u=e=>e===Object(e)&&!Array.isArray(e)&&"function"!=typeof e;function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),r=require("@react-three/fiber"),t=require("react");const u=e=>e===Object(e)&&!Array.isArray(e)&&"function"!=typeof e;function o(o,a){const s=r.useThree((e=>e.gl)),c=r.useLoader(e.TextureLoader,u(o)?Object.values(o):o);if(t.useLayoutEffect((()=>{null==a||a(c)}),[a]),t.useEffect((()=>{if("initTexture"in s){(Array.isArray(c)?c:[c]).forEach(s.initTexture)}}),[s,c]),u(o)){const e={};let r=0;for(const t in o)e[t]=c[r++];return e}return c}o.preload=t=>r.useLoader.preload(e.TextureLoader,t),o.clear=t=>r.useLoader.clear(e.TextureLoader,t),exports.IsObject=u,exports.useTexture=o;
|
package/core/useTexture.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Texture } from 'three';
|
|
2
2
|
export declare const IsObject: (url: any) => url is Record<string, string>;
|
|
3
|
-
export
|
|
4
|
-
[key in keyof
|
|
3
|
+
export type MappedTextureType<T extends string[] | string | Record<string, string>> = T extends any[] ? Texture[] : T extends Record<string, string> ? {
|
|
4
|
+
[key in keyof T]: Texture;
|
|
5
5
|
} : Texture;
|
|
6
|
+
export declare function useTexture<Url extends string[] | string | Record<string, string>>(input: Url, onLoad?: (texture: MappedTextureType<Url>) => void): MappedTextureType<Url>;
|
|
6
7
|
export declare namespace useTexture {
|
|
7
8
|
var preload: (url: string) => undefined;
|
|
8
9
|
var clear: (input: string | string[]) => void;
|
package/core/useTexture.js
CHANGED
|
@@ -20,11 +20,9 @@ function useTexture(input, onLoad) {
|
|
|
20
20
|
}
|
|
21
21
|
}, [gl, textures]);
|
|
22
22
|
if (IsObject(input)) {
|
|
23
|
-
const keys = Object.keys(input);
|
|
24
23
|
const keyed = {};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}));
|
|
24
|
+
let i = 0;
|
|
25
|
+
for (const key in input) keyed[key] = textures[i++];
|
|
28
26
|
return keyed;
|
|
29
27
|
} else {
|
|
30
28
|
return textures;
|