@react-three/drei 9.120.3 → 9.120.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/drei",
3
- "version": "9.120.3",
3
+ "version": "9.120.5",
4
4
  "private": false,
5
5
  "description": "useful add-ons for react-three-fiber",
6
6
  "keywords": [
@@ -55,7 +55,7 @@
55
55
  "zustand": "^5.0.1"
56
56
  },
57
57
  "peerDependencies": {
58
- "@react-three/fiber": "^8",
58
+ "@react-three/fiber": "^8 || ^9.0.0-0",
59
59
  "react": "^18",
60
60
  "react-dom": "^18",
61
61
  "three": ">=0.137"
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("three"),t=require("react"),o=require("@react-three/fiber"),n=require("maath"),c=require("./Facemesh.cjs.js"),a=require("./FaceLandmarker.cjs.js"),u=require("./WebcamVideoTexture.cjs.js"),s=require("../core/VideoTexture.cjs.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}require("../core/Line.cjs.js"),require("three-stdlib"),require("suspend-react"),require("hls.js");var f=i(e),d=l(r),p=l(t);function m(e,r){return e.clone().add(r).multiplyScalar(.5)}function b(e,r,t){const o=e.localToWorld(r);return t.worldToLocal(o)}const h=t.createContext({}),y=t.forwardRef((({camera:e,videoTexture:r={start:!0},manualDetect:i=!1,faceLandmarkerResult:l,manualUpdate:y=!1,makeDefault:j,smoothTime:v=.25,offset:T=!0,offsetScalar:V=80,eyes:w=!1,eyesAsOrigin:g=!0,depth:q=.15,debug:x=!1,facemesh:O},k)=>{var S,R;const E=o.useThree((e=>e.scene)),D=o.useThree((e=>e.camera)),F=o.useThree((e=>e.set)),C=o.useThree((e=>e.get)),L=e||D,M=t.useRef(null),[A]=t.useState((()=>new d.Object3D)),[P]=t.useState((()=>new d.Vector3)),[W]=t.useState((()=>new d.Vector3)),[_]=t.useState((()=>new d.Vector3)),[z]=t.useState((()=>new d.Vector3)),B=t.useCallback((()=>{A.parent=L.parent;const e=M.current;if(e){const{outerRef:r,eyeRightRef:t,eyeLeftRef:o}=e;if(t.current&&o.current){const{irisDirRef:e}=t.current,{irisDirRef:n}=o.current;e.current&&n.current&&r.current&&(P.copy(b(e.current,new d.Vector3(0,0,0),r.current)),W.copy(b(n.current,new d.Vector3(0,0,0),r.current)),A.position.copy(b(r.current,m(P,W),L.parent||E)),_.copy(b(e.current,new d.Vector3(0,0,1),r.current)),z.copy(b(n.current,new d.Vector3(0,0,1),r.current)),A.lookAt(r.current.localToWorld(m(_,z))))}else r.current&&(A.position.copy(b(r.current,new d.Vector3(0,0,0),L.parent||E)),A.lookAt(r.current.localToWorld(new d.Vector3(0,0,1))))}return A}),[L,W,z,P,_,E,A]),[I]=t.useState((()=>new d.Object3D)),H=t.useCallback((function(e,r){if(L){var t;if(null!==(t=r)&&void 0!==t||(r=B()),v>0){const t=1e-9;n.easing.damp3(I.position,r.position,v,e,void 0,void 0,t),n.easing.dampE(I.rotation,r.rotation,v,e,void 0,void 0,t)}else I.position.copy(r.position),I.rotation.copy(r.rotation);L.position.copy(I.position),L.rotation.copy(I.rotation)}}),[L,B,v,I.position,I.rotation]);o.useFrame(((e,r)=>{y||H(r)}));const N=t.useRef(null),[U,G]=t.useState(),J=a.useFaceLandmarker(),K=t.useCallback(((e,r)=>{const t=N.current;if(!t)return;const o=t.source.data,n=null==J?void 0:J.detectForVideo(o,e);G(n)}),[J]),Q=t.useMemo((()=>Object.assign(Object.create(d.EventDispatcher.prototype),{computeTarget:B,update:H,facemeshApiRef:M})),[B,H]);t.useImperativeHandle(k,(()=>Q),[Q]),t.useEffect((()=>{if(j){const e=C().controls;return F({controls:Q}),()=>F({controls:e})}}),[j,Q,C,F]);const X=null!=l?l:U,Y=null==X?void 0:X.faceLandmarks[0],Z=null==X||null==(S=X.facialTransformationMatrixes)?void 0:S[0],$=null==X||null==(R=X.faceBlendshapes)?void 0:R[0],ee={onVideoFrame:K,...r};return p.createElement(h.Provider,{value:Q},!i&&p.createElement(t.Suspense,{fallback:null},"src"in ee?p.createElement(s.VideoTexture,f.default({ref:N},ee)):p.createElement(u.WebcamVideoTexture,f.default({ref:N},ee))),p.createElement(c.Facemesh,f.default({ref:M,children:p.createElement("meshNormalMaterial",{side:d.DoubleSide})},O,{points:Y,depth:q,facialTransformationMatrix:Z,faceBlendshapes:$,eyes:w,eyesAsOrigin:g,offset:T,offsetScalar:V,debug:x,"rotation-z":Math.PI,visible:x})))}));exports.FaceControls=y,exports.useFaceControls=()=>t.useContext(h);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("three"),t=require("react"),o=require("@react-three/fiber"),n=require("maath"),c=require("../core/VideoTexture.cjs.js"),a=require("./WebcamVideoTexture.cjs.js"),u=require("./Facemesh.cjs.js"),s=require("./FaceLandmarker.cjs.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}require("suspend-react"),require("hls.js"),require("../core/Line.cjs.js"),require("three-stdlib");var f=i(e),d=l(r),p=l(t);function m(e,r){return e.clone().add(r).multiplyScalar(.5)}function b(e,r,t){const o=e.localToWorld(r);return t.worldToLocal(o)}const h=t.createContext({}),y=t.forwardRef((({camera:e,videoTexture:r={start:!0},manualDetect:i=!1,faceLandmarkerResult:l,manualUpdate:y=!1,makeDefault:j,smoothTime:v=.25,offset:T=!0,offsetScalar:V=80,eyes:w=!1,eyesAsOrigin:g=!0,depth:q=.15,debug:x=!1,facemesh:O},k)=>{var S,R;const E=o.useThree((e=>e.scene)),D=o.useThree((e=>e.camera)),F=o.useThree((e=>e.set)),C=o.useThree((e=>e.get)),L=e||D,M=t.useRef(null),[A]=t.useState((()=>new d.Object3D)),[P]=t.useState((()=>new d.Vector3)),[W]=t.useState((()=>new d.Vector3)),[_]=t.useState((()=>new d.Vector3)),[z]=t.useState((()=>new d.Vector3)),B=t.useCallback((()=>{A.parent=L.parent;const e=M.current;if(e){const{outerRef:r,eyeRightRef:t,eyeLeftRef:o}=e;if(t.current&&o.current){const{irisDirRef:e}=t.current,{irisDirRef:n}=o.current;e.current&&n.current&&r.current&&(P.copy(b(e.current,new d.Vector3(0,0,0),r.current)),W.copy(b(n.current,new d.Vector3(0,0,0),r.current)),A.position.copy(b(r.current,m(P,W),L.parent||E)),_.copy(b(e.current,new d.Vector3(0,0,1),r.current)),z.copy(b(n.current,new d.Vector3(0,0,1),r.current)),A.lookAt(r.current.localToWorld(m(_,z))))}else r.current&&(A.position.copy(b(r.current,new d.Vector3(0,0,0),L.parent||E)),A.lookAt(r.current.localToWorld(new d.Vector3(0,0,1))))}return A}),[L,W,z,P,_,E,A]),[I]=t.useState((()=>new d.Object3D)),H=t.useCallback((function(e,r){if(L){var t;if(null!==(t=r)&&void 0!==t||(r=B()),v>0){const t=1e-9;n.easing.damp3(I.position,r.position,v,e,void 0,void 0,t),n.easing.dampE(I.rotation,r.rotation,v,e,void 0,void 0,t)}else I.position.copy(r.position),I.rotation.copy(r.rotation);L.position.copy(I.position),L.rotation.copy(I.rotation)}}),[L,B,v,I.position,I.rotation]);o.useFrame(((e,r)=>{y||H(r)}));const N=t.useRef(null),[U,G]=t.useState(),J=s.useFaceLandmarker(),K=t.useCallback(((e,r)=>{const t=N.current;if(!t)return;const o=t.source.data,n=null==J?void 0:J.detectForVideo(o,e);G(n)}),[J]),Q=t.useMemo((()=>Object.assign(Object.create(d.EventDispatcher.prototype),{computeTarget:B,update:H,facemeshApiRef:M})),[B,H]);t.useImperativeHandle(k,(()=>Q),[Q]),t.useEffect((()=>{if(j){const e=C().controls;return F({controls:Q}),()=>F({controls:e})}}),[j,Q,C,F]);const X=null!=l?l:U,Y=null==X?void 0:X.faceLandmarks[0],Z=null==X||null==(S=X.facialTransformationMatrixes)?void 0:S[0],$=null==X||null==(R=X.faceBlendshapes)?void 0:R[0],ee={onVideoFrame:K,...r};return p.createElement(h.Provider,{value:Q},!i&&p.createElement(t.Suspense,{fallback:null},"src"in ee?p.createElement(c.VideoTexture,f.default({ref:N},ee)):p.createElement(a.WebcamVideoTexture,f.default({ref:N},ee))),p.createElement(u.Facemesh,f.default({ref:M,children:p.createElement("meshNormalMaterial",{side:d.DoubleSide})},O,{points:Y,depth:q,facialTransformationMatrix:Z,faceBlendshapes:$,eyes:w,eyesAsOrigin:g,offset:T,offsetScalar:V,debug:x,"rotation-z":Math.PI,visible:x})))}));exports.FaceControls=y,exports.useFaceControls=()=>t.useContext(h);
@@ -2,7 +2,7 @@ import * as THREE from 'three';
2
2
  import * as React from 'react';
3
3
  import { RefObject } from 'react';
4
4
  import type { FaceLandmarkerResult } from '@mediapipe/tasks-vision';
5
- import { VideoTextureProps } from '..';
5
+ import { VideoTextureProps } from '../core/VideoTexture';
6
6
  import { FacemeshApi, FacemeshProps } from './Facemesh';
7
7
  export type FaceControlsProps = {
8
8
  camera?: THREE.Camera;
@@ -4,10 +4,10 @@ import * as React from 'react';
4
4
  import { forwardRef, useRef, useState, useCallback, useMemo, useImperativeHandle, useEffect, Suspense, useContext, createContext } from 'react';
5
5
  import { useThree, useFrame } from '@react-three/fiber';
6
6
  import { easing } from 'maath';
7
+ import { VideoTexture } from '../core/VideoTexture.js';
8
+ import { WebcamVideoTexture } from './WebcamVideoTexture.js';
7
9
  import { Facemesh } from './Facemesh.js';
8
10
  import { useFaceLandmarker } from './FaceLandmarker.js';
9
- import { WebcamVideoTexture } from './WebcamVideoTexture.js';
10
- import { VideoTexture } from '../core/VideoTexture.js';
11
11
 
12
12
  function mean(v1, v2) {
13
13
  return v1.clone().add(v2).multiplyScalar(0.5);
@@ -1,10 +1,11 @@
1
1
  import * as React from 'react';
2
- import { VideoTextureProps } from '..';
2
+ import * as THREE from 'three';
3
+ import { VideoTextureProps } from '../core/VideoTexture';
3
4
  export type ScreenVideoTextureProps = Omit<VideoTextureProps, 'src'> & {
4
5
  options?: DisplayMediaStreamOptions;
5
6
  };
6
7
  export declare const ScreenVideoTexture: React.ForwardRefExoticComponent<Omit<{
7
- children?: (texture: import("three").VideoTexture) => React.ReactNode;
8
+ children?: (texture: THREE.VideoTexture) => React.ReactNode;
8
9
  src: string | MediaProvider | null;
9
10
  } & {
10
11
  unsuspend?: keyof HTMLVideoElementEventMap;
@@ -13,4 +14,4 @@ export declare const ScreenVideoTexture: React.ForwardRefExoticComponent<Omit<{
13
14
  onVideoFrame?: VideoFrameRequestCallback;
14
15
  } & Partial<Omit<HTMLVideoElement, "children" | "src" | "srcObject">>, "src"> & {
15
16
  options?: DisplayMediaStreamOptions;
16
- } & React.RefAttributes<import("three").VideoTexture>>;
17
+ } & React.RefAttributes<THREE.VideoTexture>>;
@@ -1,10 +1,11 @@
1
1
  import * as React from 'react';
2
- import { VideoTextureProps } from '..';
2
+ import * as THREE from 'three';
3
+ import { VideoTextureProps } from '../core/VideoTexture';
3
4
  export type WebcamVideoTextureProps = Omit<VideoTextureProps, 'src'> & {
4
5
  constraints?: MediaStreamConstraints;
5
6
  };
6
7
  export declare const WebcamVideoTexture: React.ForwardRefExoticComponent<Omit<{
7
- children?: (texture: import("three").VideoTexture) => React.ReactNode;
8
+ children?: (texture: THREE.VideoTexture) => React.ReactNode;
8
9
  src: string | MediaProvider | null;
9
10
  } & {
10
11
  unsuspend?: keyof HTMLVideoElementEventMap;
@@ -13,4 +14,4 @@ export declare const WebcamVideoTexture: React.ForwardRefExoticComponent<Omit<{
13
14
  onVideoFrame?: VideoFrameRequestCallback;
14
15
  } & Partial<Omit<HTMLVideoElement, "children" | "src" | "srcObject">>, "src"> & {
15
16
  constraints?: MediaStreamConstraints;
16
- } & React.RefAttributes<import("three").VideoTexture>>;
17
+ } & React.RefAttributes<THREE.VideoTexture>>;