@react-three/drei 9.121.3 → 10.0.0-rc.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/LICENSE +21 -21
- package/README.md +852 -852
- package/core/AccumulativeShadows.d.ts +8 -10
- package/core/ArcballControls.d.ts +3 -3
- package/core/AsciiRenderer.d.ts +1 -2
- package/core/BBAnchor.d.ts +3 -3
- package/core/Backdrop.d.ts +2 -1
- package/core/Billboard.d.ts +3 -2
- package/core/Billboard.js +8 -8
- package/core/Bounds.d.ts +2 -1
- package/core/Bounds.js +2 -2
- package/core/Bvh.d.ts +3 -2
- package/core/Bvh.js +2 -2
- package/core/CameraControls.d.ts +4 -4
- package/core/CatmullRomLine.d.ts +2 -3
- package/core/Caustics.d.ts +14 -17
- package/core/Center.d.ts +3 -2
- package/core/Clone.d.ts +4 -4
- package/core/Cloud.cjs.js +1 -1
- package/core/Cloud.d.ts +50 -12
- package/core/Cloud.js +3 -3
- package/core/ComputedAttribute.cjs.js +1 -1
- package/core/ComputedAttribute.d.ts +3 -4
- package/core/ComputedAttribute.js +5 -5
- package/core/ContactShadows.d.ts +3 -2
- package/core/CubeCamera.d.ts +3 -3
- package/core/CubeTexture.d.ts +5 -6
- package/core/CubeTexture.js +2 -7
- package/core/CubicBezierLine.d.ts +2 -3
- package/core/CurveModifier.d.ts +2 -1
- package/core/Decal.d.ts +2 -2
- package/core/Detailed.d.ts +3 -3
- package/core/DetectGPU.d.ts +1 -2
- package/core/DeviceOrientationControls.d.ts +2 -2
- package/core/Edges.cjs.js +1 -1
- package/core/Edges.d.ts +2 -2
- package/core/Edges.js +2 -2
- package/core/Effects.cjs.js +1 -1
- package/core/Effects.d.ts +9 -13
- package/core/Effects.js +3 -3
- package/core/Environment.cjs.js +1 -1
- package/core/Environment.d.ts +5 -7
- package/core/Example.js +2 -2
- package/core/Fbo.d.ts +1 -4
- package/core/Fbo.js +0 -2
- package/core/Fbx.d.ts +1 -1
- package/core/FirstPersonControls.d.ts +2 -2
- package/core/Fisheye.d.ts +2 -1
- package/core/Float.d.ts +2 -1
- package/core/FlyControls.d.ts +2 -2
- package/core/GizmoHelper.d.ts +2 -1
- package/core/GizmoViewport.d.ts +2 -2
- package/core/Gltf.d.ts +9 -5
- package/core/GradientTexture.d.ts +4 -4
- package/core/GradientTexture.js +0 -2
- package/core/Grid.d.ts +6 -7
- package/core/Helper.cjs.js +1 -1
- package/core/Helper.d.ts +1 -1
- package/core/Helper.js +1 -1
- package/core/Hud.d.ts +1 -2
- package/core/Image.d.ts +6 -8
- package/core/Instances.cjs.js +1 -1
- package/core/Instances.d.ts +27 -35
- package/core/Instances.js +38 -33
- package/core/Ktx2.d.ts +1 -1
- package/core/Lightformer.d.ts +3 -3
- package/core/Line.d.ts +4 -4
- package/core/MapControls.d.ts +4 -4
- package/core/MarchingCubes.d.ts +6 -6
- package/core/Mask.d.ts +3 -3
- package/core/MeshDiscardMaterial.d.ts +6 -7
- package/core/MeshDistortMaterial.d.ts +15 -17
- package/core/MeshPortalMaterial.cjs.js +1 -1
- package/core/MeshPortalMaterial.d.ts +14 -17
- package/core/MeshPortalMaterial.js +2 -2
- package/core/MeshReflectorMaterial.cjs.js +1 -1
- package/core/MeshReflectorMaterial.d.ts +9 -22
- package/core/MeshReflectorMaterial.js +2 -4
- package/core/MeshRefractionMaterial.cjs.js +1 -1
- package/core/MeshRefractionMaterial.d.ts +5 -8
- package/core/MeshRefractionMaterial.js +2 -2
- package/core/MeshTransmissionMaterial.cjs.js +1 -1
- package/core/MeshTransmissionMaterial.d.ts +7 -8
- package/core/MeshTransmissionMaterial.js +2 -1
- package/core/MeshWobbleMaterial.d.ts +15 -17
- package/core/MotionPathControls.cjs.js +1 -1
- package/core/MotionPathControls.d.ts +18 -6
- package/core/MotionPathControls.js +2 -3
- package/core/MultiMaterial.cjs.js +1 -1
- package/core/MultiMaterial.d.ts +3 -1
- package/core/MultiMaterial.js +2 -3
- package/core/OrbitControls.d.ts +4 -4
- package/core/OrthographicCamera.d.ts +3 -3
- package/core/Outlines.cjs.js +1 -1
- package/core/Outlines.d.ts +2 -3
- package/core/Outlines.js +2 -2
- package/core/PerformanceMonitor.d.ts +2 -2
- package/core/PerspectiveCamera.d.ts +3 -3
- package/core/PointMaterial.d.ts +3 -11
- package/core/PointerLockControls.d.ts +2 -2
- package/core/Points.cjs.js +1 -1
- package/core/Points.d.ts +10 -13
- package/core/Points.js +10 -20
- package/core/PositionalAudio.d.ts +3 -3
- package/core/Preload.d.ts +2 -3
- package/core/QuadraticBezierLine.d.ts +5 -7
- package/core/RenderCubeTexture.d.ts +2 -2
- package/core/RenderTexture.cjs.js +1 -1
- package/core/RenderTexture.d.ts +3 -3
- package/core/RenderTexture.js +3 -2
- package/core/Resize.d.ts +9 -2
- package/core/RoundedBox.d.ts +4 -4
- package/core/Sampler.d.ts +4 -4
- package/core/ScreenQuad.d.ts +3 -3
- package/core/ScreenSizer.d.ts +3 -3
- package/core/ScreenSizer.js +12 -12
- package/core/ScreenSpace.d.ts +3 -2
- package/core/Segments.d.ts +6 -8
- package/core/Shadow.d.ts +3 -3
- package/core/ShadowAlpha.cjs.js +1 -1
- package/core/ShadowAlpha.d.ts +1 -2
- package/core/ShadowAlpha.js +9 -9
- package/core/Sky.d.ts +2 -3
- package/core/Sparkles.d.ts +14 -16
- package/core/Splat.d.ts +6 -8
- package/core/SpotLight.d.ts +2 -1
- package/core/SpriteAnimator.cjs.js +1 -1
- package/core/SpriteAnimator.d.ts +36 -3
- package/core/Stage.cjs.js +1 -1
- package/core/Stage.d.ts +3 -2
- package/core/Stars.cjs.js +1 -1
- package/core/Stars.d.ts +6 -8
- package/core/Stars.js +1 -1
- package/core/Stats.d.ts +2 -3
- package/core/StatsGl.d.ts +2 -2
- package/core/Svg.d.ts +6 -6
- package/core/Text.d.ts +3 -4
- package/core/Text3D.d.ts +7 -10
- package/core/Text3D.js +3 -3
- package/core/Texture.d.ts +1 -1
- package/core/TrackballControls.d.ts +4 -4
- package/core/Trail.cjs.js +1 -1
- package/core/Trail.d.ts +3 -3
- package/core/Trail.js +3 -3
- package/core/TrailTexture.d.ts +3 -2
- package/core/TransformControls.cjs.js +1 -1
- package/core/TransformControls.d.ts +3 -3
- package/core/TransformControls.js +4 -5
- package/core/VideoTexture.cjs.js +1 -1
- package/core/VideoTexture.js +1 -1
- package/core/Wireframe.d.ts +5 -7
- package/core/index.cjs.js +1 -1
- package/core/index.d.ts +0 -1
- package/core/index.js +2 -4
- package/core/shapes.d.ts +21 -20
- package/core/softShadows.d.ts +1 -2
- package/core/softShadows.js +13 -13
- package/core/useAnimations.cjs.js +1 -1
- package/core/useAnimations.d.ts +2 -2
- package/core/useAnimations.js +1 -1
- package/core/useBoxProjectedEnv.d.ts +1 -1
- package/core/useCamera.cjs.js +1 -1
- package/core/useCamera.d.ts +1 -1
- package/core/useCamera.js +1 -8
- package/core/useContextBridge.d.ts +1 -1
- package/core/useContextBridge.js +4 -4
- package/core/useEnvironment.cjs.js +1 -1
- package/core/useEnvironment.d.ts +3 -4
- package/core/useEnvironment.js +11 -19
- package/core/useIntersect.d.ts +1 -1
- package/core/useSpriteLoader.d.ts +1 -1
- package/helpers/deprecated.cjs.js +1 -1
- package/helpers/deprecated.d.ts +1 -4
- package/helpers/deprecated.js +4 -16
- package/helpers/ts-utils.d.ts +4 -0
- package/helpers/useEffectfulState.d.ts +1 -1
- package/index.cjs.js +1 -1
- package/index.js +0 -1
- package/materials/BlurPass.js +0 -1
- package/materials/MeshReflectorMaterial.d.ts +0 -16
- package/native/index.cjs.js +1 -1
- package/native/index.js +0 -2
- package/package.json +7 -8
- package/web/CycleRaycast.d.ts +1 -1
- package/web/FaceControls.js +8 -8
- package/web/FaceLandmarker.d.ts +1 -2
- package/web/Facemesh.d.ts +3 -2
- package/web/Html.cjs.js +1 -1
- package/web/Html.d.ts +4 -4
- package/web/Html.js +1 -1
- package/web/KeyboardControls.d.ts +1 -1
- package/web/PresentationControls.cjs.js +1 -1
- package/web/PresentationControls.d.ts +3 -4
- package/web/PresentationControls.js +20 -28
- package/web/ScreenVideoTexture.js +2 -2
- package/web/ScrollControls.d.ts +1 -1
- package/web/Select.d.ts +3 -3
- package/web/Select.js +6 -2
- package/web/View.cjs.js +1 -1
- package/web/View.d.ts +8 -10
- package/web/View.js +4 -34
- package/web/WebcamVideoTexture.js +2 -2
- package/web/index.cjs.js +1 -1
- package/web/index.js +1 -4
- package/web/pivotControls/AxisArrow.js +0 -2
- package/web/pivotControls/AxisRotator.js +0 -2
- package/web/pivotControls/PlaneSlider.js +1 -3
- package/web/pivotControls/ScalingSphere.js +0 -1
- package/web/pivotControls/index.d.ts +1 -2
- package/core/Reflector.cjs.js +0 -1
- package/core/Reflector.d.ts +0 -30
- package/core/Reflector.js +0 -180
package/core/softShadows.js
CHANGED
|
@@ -2,19 +2,19 @@ import * as React from 'react';
|
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
import { useThree } from '@react-three/fiber';
|
|
4
4
|
|
|
5
|
-
/* Integration and compilation: @N8Programs
|
|
6
|
-
Inspired by:
|
|
7
|
-
https://github.com/mrdoob/three.js/blob/dev/examples/webgl_shadowmap_pcss.html
|
|
8
|
-
https://developer.nvidia.com/gpugems/gpugems2/part-ii-shading-lighting-and-shadows/chapter-17-efficient-soft-edged-shadows-using
|
|
9
|
-
https://developer.download.nvidia.com/whitepapers/2008/PCSS_Integration.pdf
|
|
10
|
-
https://github.com/mrdoob/three.js/blob/master/examples/webgl_shadowmap_pcss.html [spidersharma03]
|
|
11
|
-
https://spline.design/
|
|
12
|
-
Concept:
|
|
13
|
-
https://www.gamedev.net/tutorials/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
|
|
14
|
-
Vogel Disk Implementation:
|
|
15
|
-
https://www.shadertoy.com/view/4l3yRM [ashalah]
|
|
16
|
-
High-Frequency Noise Implementation:
|
|
17
|
-
https://www.shadertoy.com/view/tt3fDH [spawner64]
|
|
5
|
+
/* Integration and compilation: @N8Programs
|
|
6
|
+
Inspired by:
|
|
7
|
+
https://github.com/mrdoob/three.js/blob/dev/examples/webgl_shadowmap_pcss.html
|
|
8
|
+
https://developer.nvidia.com/gpugems/gpugems2/part-ii-shading-lighting-and-shadows/chapter-17-efficient-soft-edged-shadows-using
|
|
9
|
+
https://developer.download.nvidia.com/whitepapers/2008/PCSS_Integration.pdf
|
|
10
|
+
https://github.com/mrdoob/three.js/blob/master/examples/webgl_shadowmap_pcss.html [spidersharma03]
|
|
11
|
+
https://spline.design/
|
|
12
|
+
Concept:
|
|
13
|
+
https://www.gamedev.net/tutorials/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
|
|
14
|
+
Vogel Disk Implementation:
|
|
15
|
+
https://www.shadertoy.com/view/4l3yRM [ashalah]
|
|
16
|
+
High-Frequency Noise Implementation:
|
|
17
|
+
https://www.shadertoy.com/view/tt3fDH [spawner64]
|
|
18
18
|
*/
|
|
19
19
|
const pcss = ({
|
|
20
20
|
focus = 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("three"),t=require("@react-three/fiber");function n(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 c=n(e);exports.useAnimations=function(e,n){const u=c.useRef(),[o]=c.useState((()=>n?n instanceof r.Object3D?{current:n}:n:u)),[a]=c.useState((()=>new r.AnimationMixer(void 0)));c.useLayoutEffect((()=>{n&&(o.current=n instanceof r.Object3D?n:n.current),a._root=o.current}));const i=c.useRef({}),s=c.useMemo((()=>{const r={};return e.forEach((e=>Object.defineProperty(r,e.name,{enumerable:!0,get(){if(o.current)return i.current[e.name]||(i.current[e.name]=a.clipAction(e,o.current))},configurable:!0}))),{ref:o,clips:e,actions:r,names:e.map((e=>e.name)),mixer:a}}),[e]);return t.useFrame(((e,r)=>a.update(r))),c.useEffect((()=>{const e=o.current;return()=>{i.current={},a.stopAllAction(),Object.values(s.actions).forEach((r=>{e&&a.uncacheAction(r,e)}))}}),[e]),s};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("three"),t=require("@react-three/fiber");function n(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 c=n(e);exports.useAnimations=function(e,n){const u=c.useRef(null),[o]=c.useState((()=>n?n instanceof r.Object3D?{current:n}:n:u)),[a]=c.useState((()=>new r.AnimationMixer(void 0)));c.useLayoutEffect((()=>{n&&(o.current=n instanceof r.Object3D?n:n.current),a._root=o.current}));const i=c.useRef({}),s=c.useMemo((()=>{const r={};return e.forEach((e=>Object.defineProperty(r,e.name,{enumerable:!0,get(){if(o.current)return i.current[e.name]||(i.current[e.name]=a.clipAction(e,o.current))},configurable:!0}))),{ref:o,clips:e,actions:r,names:e.map((e=>e.name)),mixer:a}}),[e]);return t.useFrame(((e,r)=>a.update(r))),c.useEffect((()=>{const e=o.current;return()=>{i.current={},a.stopAllAction(),Object.values(s.actions).forEach((r=>{e&&a.uncacheAction(r,e)}))}}),[e]),s};
|
package/core/useAnimations.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Object3D, AnimationClip, AnimationAction, AnimationMixer } from 'three';
|
|
3
3
|
type Api<T extends AnimationClip> = {
|
|
4
|
-
ref: React.
|
|
4
|
+
ref: React.RefObject<Object3D | undefined | null>;
|
|
5
5
|
clips: AnimationClip[];
|
|
6
6
|
mixer: AnimationMixer;
|
|
7
7
|
names: T['name'][];
|
|
@@ -9,5 +9,5 @@ type Api<T extends AnimationClip> = {
|
|
|
9
9
|
[key in T['name']]: AnimationAction | null;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export declare function useAnimations<T extends AnimationClip>(clips: T[], root?: React.
|
|
12
|
+
export declare function useAnimations<T extends AnimationClip>(clips: T[], root?: React.RefObject<Object3D | undefined | null> | Object3D): Api<T>;
|
|
13
13
|
export {};
|
package/core/useAnimations.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Object3D, AnimationMixer } from 'three';
|
|
|
3
3
|
import { useFrame } from '@react-three/fiber';
|
|
4
4
|
|
|
5
5
|
function useAnimations(clips, root) {
|
|
6
|
-
const ref = React.useRef();
|
|
6
|
+
const ref = React.useRef(null);
|
|
7
7
|
const [actualRef] = React.useState(() => root ? root instanceof Object3D ? {
|
|
8
8
|
current: root
|
|
9
9
|
} : root : ref);
|
|
@@ -12,7 +12,7 @@ interface MaterialShader {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
export declare function useBoxProjectedEnv(position?: ReactThreeFiber.Vector3, size?: ReactThreeFiber.Vector3): {
|
|
15
|
-
ref: React.
|
|
15
|
+
ref: React.RefObject<THREE.Material>;
|
|
16
16
|
onBeforeCompile: (shader: MaterialShader) => void;
|
|
17
17
|
customProgramCacheKey: () => string;
|
|
18
18
|
};
|
package/core/useCamera.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("three"),t=require("@react-three/fiber");function n(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 c=n(e);exports.useCamera=function(e,n){const u=t.useThree((e=>e.pointer)),[a]=c.useState((()=>{const c=new r.Raycaster;return n&&t.applyProps(c,n
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("three"),t=require("@react-three/fiber");function n(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 c=n(e);exports.useCamera=function(e,n){const u=t.useThree((e=>e.pointer)),[a]=c.useState((()=>{const c=new r.Raycaster;return n&&t.applyProps(c,n),function(t,n){c.setFromCamera(u,e instanceof r.Camera?e:e.current);const a=this.constructor.prototype.raycast.bind(this);a&&a(c,n)}}));return a};
|
package/core/useCamera.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Raycaster, Camera, Intersection } from 'three';
|
|
3
|
-
export declare function useCamera(camera: Camera | React.
|
|
3
|
+
export declare function useCamera(camera: Camera | React.RefObject<Camera>, props?: Partial<Raycaster>): (_: Raycaster, intersects: Intersection[]) => void;
|
package/core/useCamera.js
CHANGED
|
@@ -6,14 +6,7 @@ function useCamera(camera, props) {
|
|
|
6
6
|
const pointer = useThree(state => state.pointer);
|
|
7
7
|
const [raycast] = React.useState(() => {
|
|
8
8
|
const raycaster = new Raycaster();
|
|
9
|
-
|
|
10
|
-
* applyProps is an internal method of r3f and
|
|
11
|
-
* therefore requires its first arg to be an
|
|
12
|
-
* "Instance" a term used with the Reconciler
|
|
13
|
-
* so we have an expect error to mask this
|
|
14
|
-
*/
|
|
15
|
-
// @ts-expect-error
|
|
16
|
-
if (props) applyProps(raycaster, props, {});
|
|
9
|
+
if (props) applyProps(raycaster, props);
|
|
17
10
|
return function (_, intersects) {
|
|
18
11
|
raycaster.setFromCamera(pointer, camera instanceof Camera ? camera : camera.current);
|
|
19
12
|
const rc = this.constructor.prototype.raycast.bind(this);
|
package/core/useContextBridge.js
CHANGED
|
@@ -10,10 +10,10 @@ function useContextBridge(...contexts) {
|
|
|
10
10
|
value: cRef.current[i],
|
|
11
11
|
children: acc
|
|
12
12
|
}), children
|
|
13
|
-
/*
|
|
14
|
-
* done this way in reference to:
|
|
15
|
-
* https://github.com/DefinitelyTyped/DefinitelyTyped/issues/44572#issuecomment-625878049
|
|
16
|
-
* https://github.com/microsoft/TypeScript/issues/14729
|
|
13
|
+
/*
|
|
14
|
+
* done this way in reference to:
|
|
15
|
+
* https://github.com/DefinitelyTyped/DefinitelyTyped/issues/44572#issuecomment-625878049
|
|
16
|
+
* https://github.com/microsoft/TypeScript/issues/14729
|
|
17
17
|
*/), []);
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@react-three/fiber"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@react-three/fiber"),t=require("three"),n=require("three-stdlib"),r=require("@monogrid/gainmap-js"),s=require("../helpers/environment-assets.cjs.js"),o=require("react");const i="https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/",p=e=>Array.isArray(e),a=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"];function l({files:n=a,path:r="",preset:l,colorSpace:c,extensions:u}={}){l&&(d(l),n=s.presetsObj[l],r=i);const h=p(n),{extension:f,isCubemap:j}=g(n),m=b(f);if(!m)throw new Error("useEnvironment: Unrecognized file extension: "+n);const x=e.useThree((e=>e.gl));o.useLayoutEffect((()=>{"webp"!==f&&"jpg"!==f&&"jpeg"!==f||x.domElement.addEventListener("webglcontextlost",(function(){e.useLoader.clear(m,h?[n]:n)}),{once:!0})}),[n,x.domElement]);const w=e.useLoader(m,h?[n]:n,(e=>{"webp"!==f&&"jpg"!==f&&"jpeg"!==f||e.setRenderer(x),null==e.setPath||e.setPath(r),u&&u(e)}));let E=h?w[0]:w;var v;"jpg"!==f&&"jpeg"!==f&&"webp"!==f||(E=null==(v=E.renderTarget)?void 0:v.texture);return E.mapping=j?t.CubeReflectionMapping:t.EquirectangularReflectionMapping,E.colorSpace=null!=c?c:j?"srgb":"srgb-linear",E}const c={files:a,path:"",preset:void 0,extensions:void 0};l.preload=t=>{const n={...c,...t};let{files:r,path:o=""}=n;const{preset:a,extensions:l}=n;a&&(d(a),r=s.presetsObj[a],o=i);const{extension:u}=g(r);if("webp"===u||"jpg"===u||"jpeg"===u)throw new Error("useEnvironment: Preloading gainmaps is not supported");const h=b(u);if(!h)throw new Error("useEnvironment: Unrecognized file extension: "+r);e.useLoader.preload(h,p(r)?[r]:r,(e=>{null==e.setPath||e.setPath(o),l&&l(e)}))};const u={files:a,preset:void 0};function d(e){if(!(e in s.presetsObj))throw new Error("Preset must be one of: "+Object.keys(s.presetsObj).join(", "))}function g(e){var t;const n=p(e)&&6===e.length,r=p(e)&&3===e.length&&e.some((e=>e.endsWith("json"))),s=p(e)?e[0]:e;return{extension:n?"cube":r?"webp":s.startsWith("data:application/exr")?"exr":s.startsWith("data:application/hdr")?"hdr":s.startsWith("data:image/jpeg")?"jpg":null==(t=s.split(".").pop())||null==(t=t.split("?"))||null==(t=t.shift())?void 0:t.toLowerCase(),isCubemap:n,isGainmap:r}}function b(e){return"cube"===e?t.CubeTextureLoader:"hdr"===e?n.RGBELoader:"exr"===e?n.EXRLoader:"jpg"===e||"jpeg"===e?r.HDRJPGLoader:"webp"===e?r.GainMapLoader:null}l.clear=t=>{const n={...u,...t};let{files:r}=n;const{preset:o}=n;o&&(d(o),r=s.presetsObj[o]);const{extension:i}=g(r),a=b(i);if(!a)throw new Error("useEnvironment: Unrecognized file extension: "+r);e.useLoader.clear(a,p(r)?[r]:r)},exports.useEnvironment=l;
|
package/core/useEnvironment.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { Texture, Loader } from 'three';
|
|
1
|
+
import { Texture, Loader, CubeTexture } from 'three';
|
|
2
2
|
import { PresetsType } from '../helpers/environment-assets';
|
|
3
|
-
import { TextureEncoding } from '../helpers/deprecated';
|
|
4
3
|
export type EnvironmentLoaderProps = {
|
|
5
4
|
files?: string | string[];
|
|
6
5
|
path?: string;
|
|
7
6
|
preset?: PresetsType;
|
|
8
7
|
extensions?: (loader: Loader) => void;
|
|
9
|
-
|
|
8
|
+
colorSpace?: THREE.ColorSpace;
|
|
10
9
|
};
|
|
11
|
-
export declare function useEnvironment({ files, path, preset,
|
|
10
|
+
export declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture | CubeTexture;
|
|
12
11
|
export declare namespace useEnvironment {
|
|
13
12
|
var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
|
|
14
13
|
var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
|
package/core/useEnvironment.js
CHANGED
|
@@ -3,7 +3,6 @@ import { CubeReflectionMapping, EquirectangularReflectionMapping, CubeTextureLoa
|
|
|
3
3
|
import { RGBELoader, EXRLoader } from 'three-stdlib';
|
|
4
4
|
import { HDRJPGLoader, GainMapLoader } from '@monogrid/gainmap-js';
|
|
5
5
|
import { presetsObj } from '../helpers/environment-assets.js';
|
|
6
|
-
import { sRGBEncoding, LinearEncoding } from '../helpers/deprecated.js';
|
|
7
6
|
import { useLayoutEffect } from 'react';
|
|
8
7
|
|
|
9
8
|
const CUBEMAP_ROOT = 'https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/';
|
|
@@ -13,11 +12,9 @@ function useEnvironment({
|
|
|
13
12
|
files = defaultFiles,
|
|
14
13
|
path = '',
|
|
15
14
|
preset = undefined,
|
|
16
|
-
|
|
15
|
+
colorSpace = undefined,
|
|
17
16
|
extensions
|
|
18
17
|
} = {}) {
|
|
19
|
-
let loader = null;
|
|
20
|
-
let multiFile = false;
|
|
21
18
|
if (preset) {
|
|
22
19
|
validatePreset(preset);
|
|
23
20
|
files = presetsObj[preset];
|
|
@@ -25,34 +22,32 @@ function useEnvironment({
|
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
// Everything else
|
|
28
|
-
multiFile = isArray(files);
|
|
25
|
+
const multiFile = isArray(files);
|
|
29
26
|
const {
|
|
30
27
|
extension,
|
|
31
28
|
isCubemap
|
|
32
29
|
} = getExtension(files);
|
|
33
|
-
loader = getLoader(extension);
|
|
30
|
+
const loader = getLoader(extension);
|
|
34
31
|
if (!loader) throw new Error('useEnvironment: Unrecognized file extension: ' + files);
|
|
35
32
|
const gl = useThree(state => state.gl);
|
|
36
33
|
useLayoutEffect(() => {
|
|
37
34
|
// Only required for gainmap
|
|
38
35
|
if (extension !== 'webp' && extension !== 'jpg' && extension !== 'jpeg') return;
|
|
39
36
|
function clearGainmapTexture() {
|
|
40
|
-
useLoader.clear(
|
|
41
|
-
// @ts-expect-error
|
|
42
|
-
loader, multiFile ? [files] : files);
|
|
37
|
+
useLoader.clear(loader, multiFile ? [files] : files);
|
|
43
38
|
}
|
|
44
39
|
gl.domElement.addEventListener('webglcontextlost', clearGainmapTexture, {
|
|
45
40
|
once: true
|
|
46
41
|
});
|
|
47
42
|
}, [files, gl.domElement]);
|
|
48
|
-
const loaderResult = useLoader(
|
|
49
|
-
// @ts-expect-error
|
|
50
|
-
loader, multiFile ? [files] : files, loader => {
|
|
43
|
+
const loaderResult = useLoader(loader, multiFile ? [files] : files, loader => {
|
|
51
44
|
// Gainmap requires a renderer
|
|
52
45
|
if (extension === 'webp' || extension === 'jpg' || extension === 'jpeg') {
|
|
46
|
+
// @ts-expect-error
|
|
53
47
|
loader.setRenderer(gl);
|
|
54
48
|
}
|
|
55
49
|
loader.setPath == null || loader.setPath(path);
|
|
50
|
+
// @ts-expect-error
|
|
56
51
|
if (extensions) extensions(loader);
|
|
57
52
|
});
|
|
58
53
|
let texture = multiFile ?
|
|
@@ -63,7 +58,7 @@ function useEnvironment({
|
|
|
63
58
|
texture = (_renderTarget = texture.renderTarget) == null ? void 0 : _renderTarget.texture;
|
|
64
59
|
}
|
|
65
60
|
texture.mapping = isCubemap ? CubeReflectionMapping : EquirectangularReflectionMapping;
|
|
66
|
-
|
|
61
|
+
texture.colorSpace = colorSpace !== null && colorSpace !== void 0 ? colorSpace : isCubemap ? 'srgb' : 'srgb-linear';
|
|
67
62
|
return texture;
|
|
68
63
|
}
|
|
69
64
|
const preloadDefaultOptions = {
|
|
@@ -98,10 +93,9 @@ useEnvironment.preload = preloadOptions => {
|
|
|
98
93
|
}
|
|
99
94
|
const loader = getLoader(extension);
|
|
100
95
|
if (!loader) throw new Error('useEnvironment: Unrecognized file extension: ' + files);
|
|
101
|
-
useLoader.preload(
|
|
102
|
-
// @ts-expect-error
|
|
103
|
-
loader, isArray(files) ? [files] : files, loader => {
|
|
96
|
+
useLoader.preload(loader, isArray(files) ? [files] : files, loader => {
|
|
104
97
|
loader.setPath == null || loader.setPath(path);
|
|
98
|
+
// @ts-expect-error
|
|
105
99
|
if (extensions) extensions(loader);
|
|
106
100
|
});
|
|
107
101
|
};
|
|
@@ -129,9 +123,7 @@ useEnvironment.clear = clearOptions => {
|
|
|
129
123
|
} = getExtension(files);
|
|
130
124
|
const loader = getLoader(extension);
|
|
131
125
|
if (!loader) throw new Error('useEnvironment: Unrecognized file extension: ' + files);
|
|
132
|
-
useLoader.clear(
|
|
133
|
-
// @ts-expect-error
|
|
134
|
-
loader, isArray(files) ? [files] : files);
|
|
126
|
+
useLoader.clear(loader, isArray(files) ? [files] : files);
|
|
135
127
|
};
|
|
136
128
|
function validatePreset(preset) {
|
|
137
129
|
if (!(preset in presetsObj)) throw new Error('Preset must be one of: ' + Object.keys(presetsObj).join(', '));
|
package/core/useIntersect.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Object3D } from 'three';
|
|
3
|
-
export declare function useIntersect<T extends Object3D>(onChange: (visible: boolean) => void): React.
|
|
3
|
+
export declare function useIntersect<T extends Object3D>(onChange: (visible: boolean) => void): React.RefObject<T>;
|
|
@@ -51,7 +51,7 @@ export declare function useSpriteLoader<Url extends string>(input: Url | null, j
|
|
|
51
51
|
loadJsonAndTexture: (textureUrl: string, jsonUrl?: string) => void;
|
|
52
52
|
};
|
|
53
53
|
export declare namespace useSpriteLoader {
|
|
54
|
-
var preload: (url: string) =>
|
|
54
|
+
var preload: (url: string) => void;
|
|
55
55
|
var clear: (input: string) => void;
|
|
56
56
|
}
|
|
57
57
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.setUpdateRange=(e,t)=>{e.updateRanges[0]=t};
|
package/helpers/deprecated.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
export declare const setUpdateRange: (attribute: THREE.BufferAttribute, updateRange: {
|
|
3
|
-
|
|
3
|
+
start: number;
|
|
4
4
|
count: number;
|
|
5
5
|
}) => void;
|
|
6
|
-
export declare const LinearEncoding = 3000;
|
|
7
|
-
export declare const sRGBEncoding = 3001;
|
|
8
|
-
export type TextureEncoding = typeof LinearEncoding | typeof sRGBEncoding;
|
package/helpers/deprecated.js
CHANGED
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sets `BufferAttribute.updateRange` since r159.
|
|
1
|
+
/**
|
|
2
|
+
* Sets `BufferAttribute.updateRange` since r159.
|
|
3
3
|
*/
|
|
4
4
|
const setUpdateRange = (attribute, updateRange) => {
|
|
5
|
-
|
|
6
|
-
// r159
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
attribute.updateRanges[0] = updateRange;
|
|
9
|
-
} else {
|
|
10
|
-
attribute.updateRange = updateRange;
|
|
11
|
-
}
|
|
5
|
+
attribute.updateRanges[0] = updateRange;
|
|
12
6
|
};
|
|
13
|
-
const LinearEncoding = 3000;
|
|
14
|
-
const sRGBEncoding = 3001;
|
|
15
7
|
|
|
16
|
-
|
|
17
|
-
* TextureEncoding was deprecated in r152, and removed in r162.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
export { LinearEncoding, sRGBEncoding, setUpdateRange };
|
|
8
|
+
export { setUpdateRange };
|
package/helpers/ts-utils.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react';
|
|
2
2
|
export type NamedArrayTuple<T extends (...args: any) => any> = Parameters<T>;
|
|
3
3
|
export type ForwardRefComponent<P, T> = ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
|
|
4
|
+
export type NonFunctionKeys<T> = {
|
|
5
|
+
[K in keyof T]-?: T[K] extends Function ? never : K;
|
|
6
|
+
}[keyof T];
|
|
7
|
+
export type Overwrite<T, O> = Omit<T, NonFunctionKeys<O>> & O;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
type RefType<T> = React.
|
|
2
|
+
type RefType<T> = React.RefObject<T> | ((state: T) => void);
|
|
3
3
|
export declare function useEffectfulState<T>(fn: () => T, deps?: React.DependencyList, cb?: RefType<T>): T | undefined;
|
|
4
4
|
export {};
|