@react-three/drei 9.66.4 → 9.66.5
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 +0 -13
- package/core/Points.cjs.js +1 -1
- package/core/Points.js +2 -2
- package/core/useAnimations.cjs.js +1 -1
- package/core/useAnimations.js +2 -1
- package/index.cjs.js +1 -1
- package/package.json +1 -1
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://drei.pmnd.rs/?path=/story/loaders-ktx2--use-ktx-2-scene-st)
|
package/core/Points.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("three"),r=require("react"),
|
|
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(
|
|
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(
|
|
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"),
|
|
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(),[a]=c.useState((()=>n?n instanceof r.Object3D?{current:n}:n:u)),[i]=c.useState((()=>new r.AnimationMixer(void 0))),o=c.useRef({}),[s]=c.useState((()=>{const r={};return e.forEach((e=>Object.defineProperty(r,e.name,{enumerable:!0,get(){if(a.current)return o.current[e.name]||(o.current[e.name]=i.clipAction(e,a.current))},configurable:!0}))),{ref:a,clips:e,actions:r,names:e.map((e=>e.name)),mixer:i}}));return t.useFrame(((e,r)=>i.update(r))),c.useEffect((()=>{const e=a.current;return()=>{o.current={},Object.values(s.actions).forEach((r=>{e&&i.uncacheAction(r,e)}))}}),[e]),c.useEffect((()=>()=>{i.stopAllAction()}),[i]),s};
|
package/core/useAnimations.js
CHANGED
|
@@ -19,8 +19,9 @@ function useAnimations(clips, root) {
|
|
|
19
19
|
if (actualRef.current) {
|
|
20
20
|
return lazyActions.current[clip.name] || (lazyActions.current[clip.name] = mixer.clipAction(clip, actualRef.current));
|
|
21
21
|
}
|
|
22
|
-
}
|
|
22
|
+
},
|
|
23
23
|
|
|
24
|
+
configurable: true
|
|
24
25
|
}));
|
|
25
26
|
return {
|
|
26
27
|
ref: actualRef,
|