@react-three/drei 8.2.0 → 8.2.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/core/SpotLight.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("react"),r=require("three"),a=require("@react-three/fiber"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("react"),r=require("three"),a=require("@react-three/fiber"),o=require("../materials/SpotLightMaterial.cjs.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var u=i(e),l=n(t);const s=new r.Vector3,c=l.forwardRef((({opacity:e=1,radiusTop:t,radiusBottom:i,depthBuffer:n,color:c="white",distance:f=5,angle:m=.15,attenuation:p=5,anglePower:d=5,...h},v)=>{const g=l.useRef(null),y=a.useThree((e=>e.size)),b=a.useThree((e=>e.camera)),w=a.useThree((e=>e.viewport.dpr)),[j]=l.useState((()=>new o.SpotLightMaterial));t=void 0===t?.1:t,i=void 0===i?7*m:i,a.useFrame((()=>{j.uniforms.spotPosition.value.copy(g.current.getWorldPosition(s)),g.current.lookAt(g.current.parent.target.getWorldPosition(s))}));const M=l.useMemo((()=>{const e=new r.CylinderGeometry(t,i,f,128,64,!0);return e.applyMatrix4((new r.Matrix4).makeTranslation(0,-f/2,0)),e.applyMatrix4((new r.Matrix4).makeRotationX(-Math.PI/2)),e}),[m,f,t,i]);return l.createElement("spotLight",u.default({ref:v,angle:m,color:c,distance:f},h),l.createElement("mesh",{ref:g,geometry:M,raycast:()=>null},l.createElement("primitive",{object:j,attach:"material","uniforms-opacity-value":e,"uniforms-lightColor-value":c,"uniforms-attenuation-value":p,"uniforms-anglePower-value":d,"uniforms-depth-value":n,"uniforms-cameraNear-value":b.near,"uniforms-cameraFar-value":b.far,"uniforms-resolution-value":n?[y.width*w,y.height*w]:[0,0]})))}));exports.SpotLight=c;
|
package/core/SpotLight.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ declare const SpotLight: React.ForwardRefExoticComponent<Pick<Omit<import("@reac
|
|
|
6
6
|
depthBuffer?: DepthTexture | undefined;
|
|
7
7
|
attenuation?: number | undefined;
|
|
8
8
|
anglePower?: number | undefined;
|
|
9
|
+
radiusTop?: number | undefined;
|
|
10
|
+
radiusBottom?: number | undefined;
|
|
11
|
+
opacity?: number | undefined;
|
|
9
12
|
color?: string | number | undefined;
|
|
10
|
-
}, "visible" | "attach" | "attachArray" | "attachObject" | "args" | "children" | "key" | "onUpdate" | "position" | "up" | "scale" | "rotation" | "matrix" | "quaternion" | "layers" | "dispose" | "type" | "id" | "uuid" | "name" | "parent" | "modelViewMatrix" | "normalMatrix" | "matrixWorld" | "matrixAutoUpdate" | "matrixWorldNeedsUpdate" | "castShadow" | "receiveShadow" | "frustumCulled" | "renderOrder" | "animations" | "userData" | "customDepthMaterial" | "customDistanceMaterial" | "isObject3D" | "onBeforeRender" | "onAfterRender" | "applyMatrix4" | "applyQuaternion" | "setRotationFromAxisAngle" | "setRotationFromEuler" | "setRotationFromMatrix" | "setRotationFromQuaternion" | "rotateOnAxis" | "rotateOnWorldAxis" | "rotateX" | "rotateY" | "rotateZ" | "translateOnAxis" | "translateX" | "translateY" | "translateZ" | "localToWorld" | "worldToLocal" | "lookAt" | "add" | "remove" | "removeFromParent" | "clear" | "getObjectById" | "getObjectByName" | "getObjectByProperty" | "getWorldPosition" | "getWorldQuaternion" | "getWorldScale" | "getWorldDirection" | "raycast" | "traverse" | "traverseVisible" | "traverseAncestors" | "updateMatrix" | "updateMatrixWorld" | "updateWorldMatrix" | "toJSON" | "clone" | "copy" | "addEventListener" | "hasEventListener" | "removeEventListener" | "dispatchEvent" | "color" | keyof import("@react-three/fiber/dist/declarations/src/core/events").EventHandlers | "distance" | "decay" | "target" | "angle" | "intensity" | "isLight" | "shadow" | "shadowCameraFov" | "shadowCameraLeft" | "shadowCameraRight" | "shadowCameraTop" | "shadowCameraBottom" | "shadowCameraNear" | "shadowCameraFar" | "shadowBias" | "shadowMapWidth" | "shadowMapHeight" | "power" | "depthBuffer" | "penumbra" | "isSpotLight" | "attenuation" | "anglePower"> & React.RefAttributes<SpotLightImpl>>;
|
|
13
|
+
}, "visible" | "attach" | "attachArray" | "attachObject" | "args" | "children" | "key" | "onUpdate" | "position" | "up" | "scale" | "rotation" | "matrix" | "quaternion" | "layers" | "dispose" | "type" | "id" | "uuid" | "name" | "parent" | "modelViewMatrix" | "normalMatrix" | "matrixWorld" | "matrixAutoUpdate" | "matrixWorldNeedsUpdate" | "castShadow" | "receiveShadow" | "frustumCulled" | "renderOrder" | "animations" | "userData" | "customDepthMaterial" | "customDistanceMaterial" | "isObject3D" | "onBeforeRender" | "onAfterRender" | "applyMatrix4" | "applyQuaternion" | "setRotationFromAxisAngle" | "setRotationFromEuler" | "setRotationFromMatrix" | "setRotationFromQuaternion" | "rotateOnAxis" | "rotateOnWorldAxis" | "rotateX" | "rotateY" | "rotateZ" | "translateOnAxis" | "translateX" | "translateY" | "translateZ" | "localToWorld" | "worldToLocal" | "lookAt" | "add" | "remove" | "removeFromParent" | "clear" | "getObjectById" | "getObjectByName" | "getObjectByProperty" | "getWorldPosition" | "getWorldQuaternion" | "getWorldScale" | "getWorldDirection" | "raycast" | "traverse" | "traverseVisible" | "traverseAncestors" | "updateMatrix" | "updateMatrixWorld" | "updateWorldMatrix" | "toJSON" | "clone" | "copy" | "addEventListener" | "hasEventListener" | "removeEventListener" | "dispatchEvent" | "color" | keyof import("@react-three/fiber/dist/declarations/src/core/events").EventHandlers | "distance" | "opacity" | "decay" | "target" | "angle" | "intensity" | "isLight" | "shadow" | "shadowCameraFov" | "shadowCameraLeft" | "shadowCameraRight" | "shadowCameraTop" | "shadowCameraBottom" | "shadowCameraNear" | "shadowCameraFar" | "shadowBias" | "shadowMapWidth" | "shadowMapHeight" | "power" | "depthBuffer" | "penumbra" | "isSpotLight" | "attenuation" | "anglePower" | "radiusTop" | "radiusBottom"> & React.RefAttributes<SpotLightImpl>>;
|
|
11
14
|
export { SpotLight };
|
package/core/SpotLight.js
CHANGED
|
@@ -6,6 +6,9 @@ import { SpotLightMaterial } from '../materials/SpotLightMaterial.js';
|
|
|
6
6
|
|
|
7
7
|
const vec = new Vector3();
|
|
8
8
|
const SpotLight = /*#__PURE__*/React.forwardRef(({
|
|
9
|
+
opacity = 1,
|
|
10
|
+
radiusTop,
|
|
11
|
+
radiusBottom,
|
|
9
12
|
depthBuffer,
|
|
10
13
|
color = 'white',
|
|
11
14
|
distance = 5,
|
|
@@ -19,16 +22,18 @@ const SpotLight = /*#__PURE__*/React.forwardRef(({
|
|
|
19
22
|
const camera = useThree(state => state.camera);
|
|
20
23
|
const dpr = useThree(state => state.viewport.dpr);
|
|
21
24
|
const [material] = React.useState(() => new SpotLightMaterial());
|
|
25
|
+
radiusTop = radiusTop === undefined ? 0.1 : radiusTop;
|
|
26
|
+
radiusBottom = radiusBottom === undefined ? angle * 7 : radiusBottom;
|
|
22
27
|
useFrame(() => {
|
|
23
28
|
material.uniforms.spotPosition.value.copy(mesh.current.getWorldPosition(vec));
|
|
24
29
|
mesh.current.lookAt(mesh.current.parent.target.getWorldPosition(vec));
|
|
25
30
|
});
|
|
26
31
|
const geom = React.useMemo(() => {
|
|
27
|
-
const geometry = new CylinderGeometry(
|
|
32
|
+
const geometry = new CylinderGeometry(radiusTop, radiusBottom, distance, 128, 64, true);
|
|
28
33
|
geometry.applyMatrix4(new Matrix4().makeTranslation(0, -distance / 2, 0));
|
|
29
34
|
geometry.applyMatrix4(new Matrix4().makeRotationX(-Math.PI / 2));
|
|
30
35
|
return geometry;
|
|
31
|
-
}, [angle, distance]);
|
|
36
|
+
}, [angle, distance, radiusTop, radiusBottom]);
|
|
32
37
|
return /*#__PURE__*/React.createElement("spotLight", _extends({
|
|
33
38
|
ref: ref,
|
|
34
39
|
angle: angle,
|
|
@@ -36,10 +41,12 @@ const SpotLight = /*#__PURE__*/React.forwardRef(({
|
|
|
36
41
|
distance: distance
|
|
37
42
|
}, props), /*#__PURE__*/React.createElement("mesh", {
|
|
38
43
|
ref: mesh,
|
|
39
|
-
geometry: geom
|
|
44
|
+
geometry: geom,
|
|
45
|
+
raycast: () => null
|
|
40
46
|
}, /*#__PURE__*/React.createElement("primitive", {
|
|
41
47
|
object: material,
|
|
42
48
|
attach: "material",
|
|
49
|
+
"uniforms-opacity-value": opacity,
|
|
43
50
|
"uniforms-lightColor-value": color,
|
|
44
51
|
"uniforms-attenuation-value": attenuation,
|
|
45
52
|
"uniforms-anglePower-value": anglePower,
|