@react-three/drei 9.66.4 → 9.66.6

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 CHANGED
@@ -2406,19 +2406,6 @@ const props = useTexture({
2406
2406
  return <meshStandardMaterial {...props} />
2407
2407
  ```
2408
2408
 
2409
- Use the `onLoad` callback to set properties on loaded textures.
2410
-
2411
- ```jsx
2412
- const texture = useTexture(url, (texture) => {
2413
- texture.wrapS = texture.wrapT = THREE.RepeatWrapping
2414
- })
2415
-
2416
- const [texture1, texture2] = useTexture([texture1, texture2], ([texture1, texture2]) => {
2417
- texture1.wrapS = texture1.wrapT = THREE.RepeatWrapping
2418
- texture2.wrapS = texture2.wrapT = THREE.RepeatWrapping
2419
- })
2420
- ```
2421
-
2422
2409
  #### useKTX2
2423
2410
 
2424
2411
  [![](https://img.shields.io/badge/-storybook-%23ff69b4)](https://drei.pmnd.rs/?path=/story/loaders-ktx2--use-ktx-2-scene-st)
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("three"),r=require("react"),a=require("@react-three/fiber"),n=require("react-merge-refs");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function o(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 s=i(e),u=o(t),c=o(r),l=i(n);const f=new u.Matrix4,d=new u.Ray,m=new u.Sphere,y=new u.Vector3;class p extends u.Group{constructor(){super(),this.size=0,this.color=new u.Color("white"),this.instance={current:void 0},this.instanceKey={current:void 0}}get geometry(){var e;return null==(e=this.instance.current)?void 0:e.geometry}raycast(e,t){var r,a;const n=this.instance.current;if(!n||!n.geometry)return;const i=n.userData.instances.indexOf(this.instanceKey);if(-1===i||i>n.geometry.drawRange.count)return;const o=null!==(r=null==(a=e.params.Points)?void 0:a.threshold)&&void 0!==r?r:1;if(m.set(this.getWorldPosition(y),o),!1===e.ray.intersectsSphere(m))return;f.copy(n.matrixWorld).invert(),d.copy(e.ray).applyMatrix4(f);const s=o/((this.scale.x+this.scale.y+this.scale.z)/3),c=s*s,l=d.distanceSqToPoint(y);if(l<c){const r=new u.Vector3;d.closestPointToPoint(y,r),r.applyMatrix4(this.matrixWorld);const a=e.ray.origin.distanceTo(r);if(a<e.near||a>e.far)return;t.push({distance:a,distanceToRay:Math.sqrt(l),point:r,index:i,face:null,object:this})}}}let g,h;const b=c.createContext(null),x=new u.Matrix4,w=new u.Vector3,P=c.forwardRef((({children:e,range:t,limit:r=1e3,...n},i)=>{const o=c.useRef(null),[f,d]=c.useState([]),[[m,y,p]]=c.useState((()=>[new Float32Array(3*r),Float32Array.from({length:3*r},(()=>1)),Float32Array.from({length:r},(()=>1))]));c.useEffect((()=>{o.current.geometry.attributes.position.needsUpdate=!0})),a.useFrame((()=>{for(o.current.updateMatrix(),o.current.updateMatrixWorld(),x.copy(o.current.matrixWorld).invert(),o.current.geometry.drawRange.count=Math.min(r,void 0!==t?t:r,f.length),g=0;g<f.length;g++)h=f[g].current,h.getWorldPosition(w).applyMatrix4(x),w.toArray(m,3*g),o.current.geometry.attributes.position.needsUpdate=!0,h.matrixWorldNeedsUpdate=!0,h.color.toArray(y,3*g),o.current.geometry.attributes.color.needsUpdate=!0,p.set([h.size],g),o.current.geometry.attributes.size.needsUpdate=!0}));const P=c.useMemo((()=>({getParent:()=>o,subscribe:e=>(d((t=>[...t,e])),()=>d((t=>t.filter((t=>t.current!==e.current)))))})),[]);return c.createElement("points",s.default({userData:{instances:f},matrixAutoUpdate:!1,ref:l.default([i,o]),raycast:()=>null},n),c.createElement("bufferGeometry",null,c.createElement("bufferAttribute",{attach:"attributes-position",count:m.length/3,array:m,itemSize:3,usage:u.DynamicDrawUsage}),c.createElement("bufferAttribute",{attach:"attributes-color",count:y.length/3,array:y,itemSize:3,usage:u.DynamicDrawUsage}),c.createElement("bufferAttribute",{attach:"attributes-size",count:p.length,array:p,itemSize:1,usage:u.DynamicDrawUsage})),c.createElement(b.Provider,{value:P},e))})),v=c.forwardRef((({children:e,...t},r)=>{c.useMemo((()=>a.extend({PositionPoint:p})),[]);const n=c.useRef(),{subscribe:i,getParent:o}=c.useContext(b);return c.useLayoutEffect((()=>i(n)),[]),c.createElement("positionPoint",s.default({instance:o(),instanceKey:n,ref:l.default([r,n])},t),e)})),E=c.forwardRef((({children:e,positions:t,colors:r,sizes:n,stride:i=3,...o},f)=>{const d=c.useRef(null);return a.useFrame((()=>{const e=d.current.geometry.attributes;e.position.needsUpdate=!0,r&&(e.color.needsUpdate=!0),n&&(e.size.needsUpdate=!0)})),c.createElement("points",s.default({ref:l.default([f,d])},o),c.createElement("bufferGeometry",null,c.createElement("bufferAttribute",{attach:"attributes-position",count:t.length/i,array:t,itemSize:i,usage:u.DynamicDrawUsage}),r&&c.createElement("bufferAttribute",{attach:"attributes-color",count:r.length/i,array:r,itemSize:3,usage:u.DynamicDrawUsage}),n&&c.createElement("bufferAttribute",{attach:"attributes-size",count:n.length/i,array:n,itemSize:1,usage:u.DynamicDrawUsage})),e)})),z=c.forwardRef(((e,t)=>e.positions instanceof Float32Array?c.createElement(E,s.default({},e,{ref:t})):c.createElement(P,s.default({},e,{ref:t}))));exports.Point=v,exports.Points=z,exports.PointsBuffer=E,exports.PositionPoint=p;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("three"),r=require("react"),n=require("@react-three/fiber"),a=require("react-merge-refs");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var s=i(e),u=o(t),c=o(r),l=i(a);const f=new u.Matrix4,d=new u.Ray,m=new u.Sphere,y=new u.Vector3;class p extends u.Group{constructor(){super(),this.size=0,this.color=new u.Color("white"),this.instance={current:void 0},this.instanceKey={current:void 0}}get geometry(){var e;return null==(e=this.instance.current)?void 0:e.geometry}raycast(e,t){var r,n;const a=this.instance.current;if(!a||!a.geometry)return;const i=a.userData.instances.indexOf(this.instanceKey);if(-1===i||i>a.geometry.drawRange.count)return;const o=null!==(r=null==(n=e.params.Points)?void 0:n.threshold)&&void 0!==r?r:1;if(m.set(this.getWorldPosition(y),o),!1===e.ray.intersectsSphere(m))return;f.copy(a.matrixWorld).invert(),d.copy(e.ray).applyMatrix4(f);const s=o/((this.scale.x+this.scale.y+this.scale.z)/3),c=s*s,l=d.distanceSqToPoint(this.position);if(l<c){const r=new u.Vector3;d.closestPointToPoint(this.position,r),r.applyMatrix4(this.matrixWorld);const n=e.ray.origin.distanceTo(r);if(n<e.near||n>e.far)return;t.push({distance:n,distanceToRay:Math.sqrt(l),point:r,index:i,face:null,object:this})}}}let h,g;const b=c.createContext(null),x=new u.Matrix4,w=new u.Vector3,P=c.forwardRef((({children:e,range:t,limit:r=1e3,...a},i)=>{const o=c.useRef(null),[f,d]=c.useState([]),[[m,y,p]]=c.useState((()=>[new Float32Array(3*r),Float32Array.from({length:3*r},(()=>1)),Float32Array.from({length:r},(()=>1))]));c.useEffect((()=>{o.current.geometry.attributes.position.needsUpdate=!0})),n.useFrame((()=>{for(o.current.updateMatrix(),o.current.updateMatrixWorld(),x.copy(o.current.matrixWorld).invert(),o.current.geometry.drawRange.count=Math.min(r,void 0!==t?t:r,f.length),h=0;h<f.length;h++)g=f[h].current,g.getWorldPosition(w).applyMatrix4(x),w.toArray(m,3*h),o.current.geometry.attributes.position.needsUpdate=!0,g.matrixWorldNeedsUpdate=!0,g.color.toArray(y,3*h),o.current.geometry.attributes.color.needsUpdate=!0,p.set([g.size],h),o.current.geometry.attributes.size.needsUpdate=!0}));const P=c.useMemo((()=>({getParent:()=>o,subscribe:e=>(d((t=>[...t,e])),()=>d((t=>t.filter((t=>t.current!==e.current)))))})),[]);return c.createElement("points",s.default({userData:{instances:f},matrixAutoUpdate:!1,ref:l.default([i,o]),raycast:()=>null},a),c.createElement("bufferGeometry",null,c.createElement("bufferAttribute",{attach:"attributes-position",count:m.length/3,array:m,itemSize:3,usage:u.DynamicDrawUsage}),c.createElement("bufferAttribute",{attach:"attributes-color",count:y.length/3,array:y,itemSize:3,usage:u.DynamicDrawUsage}),c.createElement("bufferAttribute",{attach:"attributes-size",count:p.length,array:p,itemSize:1,usage:u.DynamicDrawUsage})),c.createElement(b.Provider,{value:P},e))})),v=c.forwardRef((({children:e,...t},r)=>{c.useMemo((()=>n.extend({PositionPoint:p})),[]);const a=c.useRef(),{subscribe:i,getParent:o}=c.useContext(b);return c.useLayoutEffect((()=>i(a)),[]),c.createElement("positionPoint",s.default({instance:o(),instanceKey:a,ref:l.default([r,a])},t),e)})),E=c.forwardRef((({children:e,positions:t,colors:r,sizes:a,stride:i=3,...o},f)=>{const d=c.useRef(null);return n.useFrame((()=>{const e=d.current.geometry.attributes;e.position.needsUpdate=!0,r&&(e.color.needsUpdate=!0),a&&(e.size.needsUpdate=!0)})),c.createElement("points",s.default({ref:l.default([f,d])},o),c.createElement("bufferGeometry",null,c.createElement("bufferAttribute",{attach:"attributes-position",count:t.length/i,array:t,itemSize:i,usage:u.DynamicDrawUsage}),r&&c.createElement("bufferAttribute",{attach:"attributes-color",count:r.length/i,array:r,itemSize:3,usage:u.DynamicDrawUsage}),a&&c.createElement("bufferAttribute",{attach:"attributes-size",count:a.length/i,array:a,itemSize:1,usage:u.DynamicDrawUsage})),e)})),z=c.forwardRef(((e,t)=>e.positions instanceof Float32Array?c.createElement(E,s.default({},e,{ref:t})):c.createElement(P,s.default({},e,{ref:t}))));exports.Point=v,exports.Points=z,exports.PointsBuffer=E,exports.PositionPoint=p;
package/core/Points.js CHANGED
@@ -53,12 +53,12 @@ class PositionPoint extends THREE.Group {
53
53
  const localThreshold = threshold / ((this.scale.x + this.scale.y + this.scale.z) / 3);
54
54
  const localThresholdSq = localThreshold * localThreshold;
55
55
 
56
- const rayPointDistanceSq = _ray.distanceSqToPoint(_position);
56
+ const rayPointDistanceSq = _ray.distanceSqToPoint(this.position);
57
57
 
58
58
  if (rayPointDistanceSq < localThresholdSq) {
59
59
  const intersectPoint = new THREE.Vector3();
60
60
 
61
- _ray.closestPointToPoint(_position, intersectPoint);
61
+ _ray.closestPointToPoint(this.position, intersectPoint);
62
62
 
63
63
  intersectPoint.applyMatrix4(this.matrixWorld);
64
64
  const distance = raycaster.ray.origin.distanceTo(intersectPoint);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("three"),r=require("@react-three/fiber");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 n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var c=n(e);exports.useAnimations=function(e,n){const u=c.useRef(),[a]=c.useState((()=>n?n instanceof t.Object3D?{current:n}:n:u)),[i]=c.useState((()=>new t.AnimationMixer(void 0))),o=c.useRef({}),[s]=c.useState((()=>{const t={};return e.forEach((e=>Object.defineProperty(t,e.name,{enumerable:!0,get(){if(a.current)return o.current[e.name]||(o.current[e.name]=i.clipAction(e,a.current))}}))),{ref:a,clips:e,actions:t,names:e.map((e=>e.name)),mixer:i}}));return r.useFrame(((e,t)=>i.update(t))),c.useEffect((()=>{const e=a.current;return()=>{o.current={},Object.values(s.actions).forEach((t=>{e&&i.uncacheAction(t,e)}))}}),[e]),c.useEffect((()=>()=>{i.stopAllAction()}),[i]),s};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("three"),r=require("@react-three/fiber");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 n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var c=n(e);exports.useAnimations=function(e,n){const u=c.useRef(),[a]=c.useState((()=>n?n instanceof t.Object3D?{current:n}:n:u)),[o]=c.useState((()=>new t.AnimationMixer(void 0)));c.useLayoutEffect((()=>{o._root=a.current}),[o,n]);const i=c.useRef({}),[s]=c.useState((()=>{const t={};return e.forEach((e=>Object.defineProperty(t,e.name,{enumerable:!0,get(){if(a.current)return i.current[e.name]||(i.current[e.name]=o.clipAction(e,a.current))},configurable:!0}))),{ref:a,clips:e,actions:t,names:e.map((e=>e.name)),mixer:o}}));return r.useFrame(((e,t)=>o.update(t))),c.useEffect((()=>{const e=a.current;return()=>{i.current={},Object.values(s.actions).forEach((t=>{e&&o.uncacheAction(t,e)}))}}),[e]),c.useEffect((()=>()=>{o.stopAllAction()}),[o]),s};
@@ -9,6 +9,7 @@ function useAnimations(clips, root) {
9
9
  } : root : ref); // eslint-disable-next-line prettier/prettier
10
10
 
11
11
  const [mixer] = React.useState(() => new AnimationMixer(undefined));
12
+ React.useLayoutEffect(() => void (mixer._root = actualRef.current), [mixer, root]);
12
13
  const lazyActions = React.useRef({});
13
14
  const [api] = React.useState(() => {
14
15
  const actions = {};
@@ -19,8 +20,9 @@ function useAnimations(clips, root) {
19
20
  if (actualRef.current) {
20
21
  return lazyActions.current[clip.name] || (lazyActions.current[clip.name] = mixer.clipAction(clip, actualRef.current));
21
22
  }
22
- }
23
+ },
23
24
 
25
+ configurable: true
24
26
  }));
25
27
  return {
26
28
  ref: actualRef,