@react-three/drei 9.83.8 → 9.84.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/README.md +70 -2
- package/core/AccumulativeShadows.d.ts +3 -3
- package/core/AccumulativeShadows.js +30 -36
- package/core/AdaptiveDpr.js +4 -4
- package/core/ArcballControls.d.ts +1 -1
- package/core/ArcballControls.js +0 -1
- package/core/AsciiRenderer.d.ts +3 -3
- package/core/AsciiRenderer.js +12 -6
- package/core/BBAnchor.cjs.js +1 -1
- package/core/BBAnchor.d.ts +2 -2
- package/core/BBAnchor.js +5 -5
- package/core/Backdrop.d.ts +2 -2
- package/core/Backdrop.js +0 -3
- package/core/Billboard.d.ts +1 -1
- package/core/Billboard.js +6 -3
- package/core/Bounds.d.ts +5 -5
- package/core/Bounds.js +5 -32
- package/core/CameraControls.d.ts +2 -2
- package/core/CameraControls.js +0 -3
- package/core/CameraShake.js +0 -4
- package/core/CatmullRomLine.d.ts +1 -1
- package/core/CatmullRomLine.js +0 -2
- package/core/Caustics.d.ts +1 -1
- package/core/Caustics.js +31 -32
- package/core/Center.d.ts +2 -2
- package/core/Center.js +2 -1
- package/core/Clone.d.ts +1 -1
- package/core/Clone.js +10 -13
- package/core/Cloud.cjs.js +1 -1
- package/core/Cloud.d.ts +2 -2
- package/core/Cloud.js +1 -2
- package/core/ComputedAttribute.d.ts +2 -2
- package/core/ComputedAttribute.js +0 -1
- package/core/ContactShadows.d.ts +1 -1
- package/core/ContactShadows.js +6 -7
- package/core/CubeCamera.cjs.js +1 -1
- package/core/CubeCamera.d.ts +2 -2
- package/core/CubeCamera.js +1 -1
- package/core/CubicBezierLine.d.ts +1 -1
- package/core/CurveModifier.d.ts +1 -1
- package/core/CurveModifier.js +2 -4
- package/core/Decal.d.ts +1 -1
- package/core/Decal.js +8 -15
- package/core/Detailed.d.ts +1 -1
- package/core/Detailed.js +0 -1
- package/core/DeviceOrientationControls.d.ts +1 -1
- package/core/DeviceOrientationControls.js +3 -4
- package/core/Edges.d.ts +1 -1
- package/core/Edges.js +0 -2
- package/core/Effects.d.ts +1 -1
- package/core/Effects.js +5 -7
- package/core/Environment.d.ts +3 -3
- package/core/Environment.js +6 -12
- package/core/Example.d.ts +3 -3
- package/core/Example.js +2 -1
- package/core/FaceControls.cjs.js +1 -1
- package/core/FaceControls.d.ts +5 -5
- package/core/FaceControls.js +42 -39
- package/core/FaceLandmarker.d.ts +3 -2
- package/core/FaceLandmarker.js +1 -1
- package/core/Facemesh.d.ts +6 -6
- package/core/Facemesh.js +47 -53
- package/core/FirstPersonControls.d.ts +1 -1
- package/core/Float.d.ts +1 -1
- package/core/Float.js +0 -1
- package/core/FlyControls.d.ts +1 -1
- package/core/FlyControls.js +1 -2
- package/core/GizmoHelper.cjs.js +1 -1
- package/core/GizmoHelper.d.ts +2 -2
- package/core/GizmoHelper.js +18 -19
- package/core/GizmoViewcube.d.ts +3 -3
- package/core/GizmoViewcube.js +0 -14
- package/core/GizmoViewport.d.ts +3 -3
- package/core/GizmoViewport.js +0 -7
- package/core/Gltf.d.ts +1 -1
- package/core/GradientTexture.d.ts +3 -3
- package/core/GradientTexture.js +2 -5
- package/core/Grid.d.ts +2 -2
- package/core/Grid.js +2 -6
- package/core/Hud.d.ts +2 -2
- package/core/Hud.js +6 -9
- package/core/Image.d.ts +2 -2
- package/core/Image.js +4 -6
- package/core/Instances.d.ts +6 -6
- package/core/Instances.js +20 -35
- package/core/Lightformer.d.ts +1 -1
- package/core/Lightformer.js +4 -2
- package/core/Line.d.ts +1 -1
- package/core/Line.js +0 -3
- package/core/MapControls.d.ts +1 -1
- package/core/MapControls.js +0 -2
- package/core/MarchingCubes.d.ts +3 -3
- package/core/Mask.d.ts +1 -1
- package/core/MeshDistortMaterial.d.ts +2 -2
- package/core/MeshDistortMaterial.js +0 -9
- package/core/MeshPortalMaterial.d.ts +4 -4
- package/core/MeshPortalMaterial.js +22 -61
- package/core/MeshReflectorMaterial.d.ts +1 -1
- package/core/MeshReflectorMaterial.js +12 -14
- package/core/MeshRefractionMaterial.cjs.js +1 -1
- package/core/MeshRefractionMaterial.d.ts +3 -3
- package/core/MeshRefractionMaterial.js +9 -14
- package/core/MeshTransmissionMaterial.d.ts +2 -2
- package/core/MeshTransmissionMaterial.js +32 -33
- package/core/MeshWobbleMaterial.d.ts +2 -2
- package/core/MeshWobbleMaterial.js +0 -7
- package/core/MotionPathControls.cjs.js +1 -0
- package/core/MotionPathControls.d.ts +15 -0
- package/core/MotionPathControls.js +114 -0
- package/core/OrbitControls.d.ts +2 -2
- package/core/OrbitControls.js +0 -4
- package/core/OrthographicCamera.d.ts +1 -1
- package/core/OrthographicCamera.js +2 -3
- package/core/Outlines.cjs.js +1 -1
- package/core/Outlines.d.ts +4 -3
- package/core/Outlines.js +5 -8
- package/core/PerformanceMonitor.d.ts +4 -4
- package/core/PerformanceMonitor.js +8 -12
- package/core/PerspectiveCamera.d.ts +1 -1
- package/core/PerspectiveCamera.js +2 -3
- package/core/PointMaterial.d.ts +1 -1
- package/core/PointMaterial.js +0 -2
- package/core/PointerLockControls.d.ts +1 -1
- package/core/PointerLockControls.js +4 -6
- package/core/Points.d.ts +2 -2
- package/core/Points.js +6 -23
- package/core/PositionalAudio.d.ts +1 -1
- package/core/PositionalAudio.js +0 -5
- package/core/Preload.d.ts +1 -1
- package/core/Preload.js +8 -9
- package/core/QuadraticBezierLine.d.ts +2 -2
- package/core/QuadraticBezierLine.js +0 -2
- package/core/Reflector.d.ts +1 -1
- package/core/Reflector.js +11 -12
- package/core/RenderTexture.d.ts +1 -1
- package/core/RenderTexture.js +9 -11
- package/core/Resize.d.ts +2 -2
- package/core/RoundedBox.cjs.js +1 -1
- package/core/RoundedBox.d.ts +1 -1
- package/core/RoundedBox.js +1 -3
- package/core/Sampler.d.ts +5 -5
- package/core/Sampler.js +0 -10
- package/core/ScreenQuad.d.ts +1 -1
- package/core/ScreenQuad.js +0 -1
- package/core/ScreenSpace.d.ts +1 -1
- package/core/Segments.d.ts +2 -2
- package/core/Segments.js +0 -6
- package/core/Shadow.d.ts +1 -1
- package/core/Sky.d.ts +1 -1
- package/core/Sparkles.js +0 -10
- package/core/SpotLight.d.ts +2 -2
- package/core/SpotLight.js +3 -10
- package/core/SpriteAnimator.d.ts +1 -1
- package/core/SpriteAnimator.js +16 -34
- package/core/Stage.d.ts +4 -4
- package/core/Stage.js +2 -4
- package/core/Stars.d.ts +1 -1
- package/core/Stars.js +2 -11
- package/core/Stats.d.ts +1 -1
- package/core/Stats.js +2 -2
- package/core/StatsGl.d.ts +1 -1
- package/core/StatsGl.js +4 -3
- package/core/Svg.js +0 -2
- package/core/Text.d.ts +1 -1
- package/core/Text3D.d.ts +1 -1
- package/core/Text3D.js +1 -3
- package/core/TrackballControls.d.ts +1 -1
- package/core/TrackballControls.js +0 -1
- package/core/Trail.d.ts +3 -3
- package/core/Trail.js +6 -17
- package/core/TransformControls.d.ts +1 -1
- package/core/TransformControls.js +3 -9
- package/core/Wireframe.d.ts +1 -1
- package/core/Wireframe.js +0 -28
- package/core/index.cjs.js +1 -1
- package/core/index.d.ts +1 -0
- package/core/index.js +1 -0
- package/core/meshBounds.js +4 -14
- package/core/shaderMaterial.js +10 -9
- package/core/shapes.d.ts +2 -2
- package/core/shapes.js +3 -6
- package/core/softShadows.d.ts +1 -1
- package/core/softShadows.js +1 -4
- package/core/useAnimations.d.ts +1 -1
- package/core/useAnimations.js +2 -4
- package/core/useBVH.d.ts +1 -1
- package/core/useBVH.js +3 -4
- package/core/useBoxProjectedEnv.js +15 -22
- package/core/useCamera.js +0 -1
- package/core/useContextBridge.js +1 -2
- package/core/useCubeCamera.d.ts +1 -1
- package/core/useCubeTexture.d.ts +1 -1
- package/core/useCubeTexture.js +4 -3
- package/core/useEnvironment.cjs.js +1 -1
- package/core/useEnvironment.d.ts +2 -2
- package/core/useEnvironment.js +9 -11
- package/core/useFBO.d.ts +1 -1
- package/core/useFBO.js +3 -12
- package/core/useFBX.js +0 -2
- package/core/useFont.d.ts +2 -2
- package/core/useFont.js +0 -4
- package/core/useGLTF.d.ts +2 -2
- package/core/useGLTF.js +0 -8
- package/core/useHelper.d.ts +3 -3
- package/core/useHelper.js +2 -5
- package/core/useIntersect.js +5 -8
- package/core/useKTX2.js +3 -5
- package/core/useMatcapTexture.js +0 -6
- package/core/useNormalTexture.d.ts +1 -1
- package/core/useProgress.d.ts +1 -1
- package/core/useProgress.js +0 -5
- package/core/useTexture.js +4 -6
- package/core/useTrailTexture.d.ts +1 -1
- package/core/useTrailTexture.js +10 -21
- package/helpers/environment-assets.d.ts +1 -1
- package/helpers/ts-utils.d.ts +2 -2
- package/helpers/useEffectfulState.d.ts +1 -1
- package/helpers/useEffectfulState.js +0 -1
- package/index.cjs.js +1 -1
- package/index.js +1 -0
- package/materials/BlurPass.js +2 -5
- package/materials/ConvolutionMaterial.js +0 -3
- package/materials/MeshReflectorMaterial.d.ts +1 -1
- package/materials/MeshReflectorMaterial.js +0 -34
- package/materials/MeshRefractionMaterial.js +2 -6
- package/materials/SpotLightMaterial.js +2 -7
- package/materials/WireframeMaterial.js +7 -25
- package/native/index.cjs.js +1 -1
- package/native/index.js +1 -0
- package/package.json +2 -2
- package/react-three-drei-0.0.0-semantic-release.tgz +0 -0
- package/web/CycleRaycast.d.ts +1 -1
- package/web/CycleRaycast.js +20 -24
- package/web/Html.d.ts +2 -2
- package/web/Html.js +6 -50
- package/web/KeyboardControls.d.ts +10 -10
- package/web/KeyboardControls.js +9 -6
- package/web/Loader.d.ts +2 -2
- package/web/Loader.js +8 -5
- package/web/PresentationControls.d.ts +2 -2
- package/web/PresentationControls.js +2 -1
- package/web/ScrollControls.d.ts +4 -4
- package/web/ScrollControls.js +5 -16
- package/web/Select.d.ts +3 -3
- package/web/Select.js +6 -17
- package/web/View.d.ts +5 -5
- package/web/View.js +7 -20
- package/web/index.cjs.js +1 -1
- package/web/index.js +1 -0
- package/web/pivotControls/AxisArrow.js +6 -15
- package/web/pivotControls/AxisRotator.js +8 -23
- package/web/pivotControls/PlaneSlider.js +6 -16
- package/web/pivotControls/context.d.ts +2 -2
- package/web/pivotControls/index.d.ts +1 -1
- package/web/pivotControls/index.js +2 -9
package/core/ContactShadows.js
CHANGED
|
@@ -34,27 +34,27 @@ const ContactShadows = /*#__PURE__*/React.forwardRef(({
|
|
|
34
34
|
const blurPlane = new THREE.Mesh(planeGeometry);
|
|
35
35
|
const depthMaterial = new THREE.MeshDepthMaterial();
|
|
36
36
|
depthMaterial.depthTest = depthMaterial.depthWrite = false;
|
|
37
|
-
|
|
38
37
|
depthMaterial.onBeforeCompile = shader => {
|
|
39
|
-
shader.uniforms = {
|
|
38
|
+
shader.uniforms = {
|
|
39
|
+
...shader.uniforms,
|
|
40
40
|
ucolor: {
|
|
41
41
|
value: new THREE.Color(color)
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
shader.fragmentShader = shader.fragmentShader.replace(`void main() {`,
|
|
44
|
+
shader.fragmentShader = shader.fragmentShader.replace(`void main() {`,
|
|
45
|
+
//
|
|
45
46
|
`uniform vec3 ucolor;
|
|
46
47
|
void main() {
|
|
47
48
|
`);
|
|
48
|
-
shader.fragmentShader = shader.fragmentShader.replace('vec4( vec3( 1.0 - fragCoordZ ), opacity );',
|
|
49
|
+
shader.fragmentShader = shader.fragmentShader.replace('vec4( vec3( 1.0 - fragCoordZ ), opacity );',
|
|
50
|
+
// Colorize the shadow, multiply by the falloff so that the center can remain darker
|
|
49
51
|
'vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );');
|
|
50
52
|
};
|
|
51
|
-
|
|
52
53
|
const horizontalBlurMaterial = new THREE.ShaderMaterial(HorizontalBlurShader);
|
|
53
54
|
const verticalBlurMaterial = new THREE.ShaderMaterial(VerticalBlurShader);
|
|
54
55
|
verticalBlurMaterial.depthTest = horizontalBlurMaterial.depthTest = false;
|
|
55
56
|
return [renderTarget, planeGeometry, depthMaterial, blurPlane, horizontalBlurMaterial, verticalBlurMaterial, renderTargetBlur];
|
|
56
57
|
}, [resolution, width, height, scale, color]);
|
|
57
|
-
|
|
58
58
|
const blurShadows = blur => {
|
|
59
59
|
blurPlane.visible = true;
|
|
60
60
|
blurPlane.material = horizontalBlurMaterial;
|
|
@@ -69,7 +69,6 @@ const ContactShadows = /*#__PURE__*/React.forwardRef(({
|
|
|
69
69
|
gl.render(blurPlane, shadowCamera.current);
|
|
70
70
|
blurPlane.visible = false;
|
|
71
71
|
};
|
|
72
|
-
|
|
73
72
|
let count = 0;
|
|
74
73
|
let initialBackground;
|
|
75
74
|
let initialOverrideMaterial;
|
package/core/CubeCamera.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("@react-three/fiber"),t=require("./useCubeCamera.cjs.js");function u(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var u=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,u.get?u:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}require("three");var a=u(e);exports.CubeCamera=function({children:e,frames:u=1/0,resolution:n,near:c,far:i,envMap:o,fog:f,...s}){const l=a.useRef(),{fbo:b,camera:p,update:m}=t.useCubeCamera({resolution:n,near:c,far:i,envMap:o,fog:f});let v=0;return r.useFrame((()=>{l.current&&(u===1/0||v<u)&&(l.current.visible=!1,m(),l.current.visible=!0,v++)})),a.createElement("group",s,a.createElement("primitive",{object:p}),a.createElement("group",{ref:l},e(b.texture)))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("@react-three/fiber"),t=require("./useCubeCamera.cjs.js");function u(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var u=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,u.get?u:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}require("three");var a=u(e);exports.CubeCamera=function({children:e,frames:u=1/0,resolution:n,near:c,far:i,envMap:o,fog:f,...s}){const l=a.useRef(null),{fbo:b,camera:p,update:m}=t.useCubeCamera({resolution:n,near:c,far:i,envMap:o,fog:f});let v=0;return r.useFrame((()=>{l.current&&(u===1/0||v<u)&&(l.current.visible=!1,m(),l.current.visible=!0,v++)})),a.createElement("group",s,a.createElement("primitive",{object:p}),a.createElement("group",{ref:l},e(b.texture)))};
|
package/core/CubeCamera.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Texture } from 'three';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { CubeCameraOptions } from './useCubeCamera';
|
|
4
|
-
|
|
4
|
+
type Props = Omit<JSX.IntrinsicElements['group'], 'children'> & {
|
|
5
5
|
children: (tex: Texture) => React.ReactNode;
|
|
6
6
|
frames?: number;
|
|
7
7
|
} & CubeCameraOptions;
|
|
8
|
-
export declare function CubeCamera({ children, frames, resolution, near, far, envMap, fog, ...props }: Props): JSX.Element;
|
|
8
|
+
export declare function CubeCamera({ children, frames, resolution, near, far, envMap, fog, ...props }: Props): React.JSX.Element;
|
|
9
9
|
export {};
|
package/core/CubeCamera.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Vector3 } from 'three';
|
|
|
2
2
|
import { Line2 } from 'three-stdlib';
|
|
3
3
|
import { LineProps } from './Line';
|
|
4
4
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
5
|
-
|
|
5
|
+
type Props = Omit<LineProps, 'points' | 'ref'> & {
|
|
6
6
|
start: Vector3 | [number, number, number];
|
|
7
7
|
end: Vector3 | [number, number, number];
|
|
8
8
|
midA: Vector3 | [number, number, number];
|
package/core/CurveModifier.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export interface CurveModifierProps {
|
|
|
6
6
|
children: React.ReactElement<JSX.IntrinsicElements['mesh']>;
|
|
7
7
|
curve?: THREE.Curve<THREE.Vector3>;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export type CurveModifierRef = Pick<Flow, 'moveAlongCurve'>;
|
|
10
10
|
export declare const CurveModifier: ForwardRefComponent<CurveModifierProps, CurveModifierRef>;
|
package/core/CurveModifier.js
CHANGED
|
@@ -16,14 +16,12 @@ const CurveModifier = /*#__PURE__*/React.forwardRef(({
|
|
|
16
16
|
}, [children]);
|
|
17
17
|
React.useEffect(() => {
|
|
18
18
|
var _modifier$current;
|
|
19
|
-
|
|
20
|
-
if (curve) (_modifier$current = modifier.current) == null ? void 0 : _modifier$current.updateCurve(0, curve);
|
|
19
|
+
if (curve) (_modifier$current = modifier.current) == null || _modifier$current.updateCurve(0, curve);
|
|
21
20
|
}, [curve]);
|
|
22
21
|
React.useImperativeHandle(ref, () => ({
|
|
23
22
|
moveAlongCurve: val => {
|
|
24
23
|
var _modifier$current2;
|
|
25
|
-
|
|
26
|
-
(_modifier$current2 = modifier.current) == null ? void 0 : _modifier$current2.moveAlongCurve(val);
|
|
24
|
+
(_modifier$current2 = modifier.current) == null || _modifier$current2.moveAlongCurve(val);
|
|
27
25
|
}
|
|
28
26
|
}));
|
|
29
27
|
return /*#__PURE__*/React.createElement(React.Fragment, null, createPortal(children, scene), obj && /*#__PURE__*/React.createElement("primitive", {
|
package/core/Decal.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
import * as FIBER from '@react-three/fiber';
|
|
4
4
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
5
|
-
export
|
|
5
|
+
export type DecalProps = Omit<JSX.IntrinsicElements['mesh'], 'children'> & {
|
|
6
6
|
debug?: boolean;
|
|
7
7
|
mesh?: React.MutableRefObject<THREE.Mesh>;
|
|
8
8
|
position?: FIBER.Vector3;
|
package/core/Decal.js
CHANGED
|
@@ -7,7 +7,6 @@ import { DecalGeometry } from 'three-stdlib';
|
|
|
7
7
|
function isArray(vec) {
|
|
8
8
|
return Array.isArray(vec);
|
|
9
9
|
}
|
|
10
|
-
|
|
11
10
|
function vecToArray(vec = [0, 0, 0]) {
|
|
12
11
|
if (isArray(vec)) {
|
|
13
12
|
return vec;
|
|
@@ -17,7 +16,6 @@ function vecToArray(vec = [0, 0, 0]) {
|
|
|
17
16
|
return [vec, vec, vec];
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
|
-
|
|
21
19
|
const Decal = /*#__PURE__*/React.forwardRef(function Decal({
|
|
22
20
|
debug,
|
|
23
21
|
depthTest = false,
|
|
@@ -36,26 +34,23 @@ const Decal = /*#__PURE__*/React.forwardRef(function Decal({
|
|
|
36
34
|
React.useLayoutEffect(() => {
|
|
37
35
|
const parent = (mesh == null ? void 0 : mesh.current) || ref.current.parent;
|
|
38
36
|
const target = ref.current;
|
|
39
|
-
|
|
40
37
|
if (!(parent instanceof THREE.Mesh)) {
|
|
41
38
|
throw new Error('Decal must have a Mesh as parent or specify its "mesh" prop');
|
|
42
39
|
}
|
|
43
|
-
|
|
44
40
|
const state = {
|
|
45
41
|
position: new THREE.Vector3(),
|
|
46
42
|
rotation: new THREE.Euler(),
|
|
47
43
|
scale: new THREE.Vector3(1, 1, 1)
|
|
48
44
|
};
|
|
49
|
-
|
|
50
45
|
if (parent) {
|
|
51
46
|
applyProps(state, {
|
|
52
47
|
position,
|
|
53
48
|
scale
|
|
54
|
-
});
|
|
49
|
+
});
|
|
55
50
|
|
|
51
|
+
// Zero out the parents matrix world for this operation
|
|
56
52
|
const matrixWorld = parent.matrixWorld.clone();
|
|
57
53
|
parent.matrixWorld.identity();
|
|
58
|
-
|
|
59
54
|
if (!rotation || typeof rotation === 'number') {
|
|
60
55
|
const o = new THREE.Object3D();
|
|
61
56
|
o.position.copy(state.position);
|
|
@@ -69,23 +64,21 @@ const Decal = /*#__PURE__*/React.forwardRef(function Decal({
|
|
|
69
64
|
rotation
|
|
70
65
|
});
|
|
71
66
|
}
|
|
72
|
-
|
|
73
67
|
target.geometry = new DecalGeometry(parent, state.position, state.rotation, state.scale);
|
|
74
|
-
|
|
75
68
|
if (helper.current) {
|
|
76
|
-
applyProps(helper.current, state);
|
|
77
|
-
|
|
69
|
+
applyProps(helper.current, state);
|
|
70
|
+
// Prevent the helpers from blocking rays
|
|
78
71
|
helper.current.traverse(child => child.raycast = () => null);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
}
|
|
73
|
+
// Reset parents matix-world
|
|
82
74
|
parent.matrixWorld = matrixWorld;
|
|
83
75
|
return () => {
|
|
84
76
|
target.geometry.dispose();
|
|
85
77
|
};
|
|
86
78
|
}
|
|
87
|
-
}, [mesh, ...vecToArray(position), ...vecToArray(scale), ...vecToArray(rotation)]);
|
|
79
|
+
}, [mesh, ...vecToArray(position), ...vecToArray(scale), ...vecToArray(rotation)]);
|
|
88
80
|
|
|
81
|
+
// <meshStandardMaterial transparent polygonOffset polygonOffsetFactor={-10} {...props} />}
|
|
89
82
|
return /*#__PURE__*/React.createElement("mesh", _extends({
|
|
90
83
|
ref: ref,
|
|
91
84
|
"material-transparent": true,
|
package/core/Detailed.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { LOD, Object3D } from 'three';
|
|
3
3
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
4
|
-
|
|
4
|
+
type Props = JSX.IntrinsicElements['lOD'] & {
|
|
5
5
|
children: React.ReactElement<Object3D>[];
|
|
6
6
|
hysteresis?: number;
|
|
7
7
|
distances: number[];
|
package/core/Detailed.js
CHANGED
|
@@ -23,7 +23,6 @@ const Detailed = /*#__PURE__*/React.forwardRef(({
|
|
|
23
23
|
});
|
|
24
24
|
useFrame(state => {
|
|
25
25
|
var _lodRef$current;
|
|
26
|
-
|
|
27
26
|
return (_lodRef$current = lodRef.current) == null ? void 0 : _lodRef$current.update(state.camera);
|
|
28
27
|
});
|
|
29
28
|
return /*#__PURE__*/React.createElement("lOD", _extends({
|
|
@@ -2,7 +2,7 @@ import { ReactThreeFiber } from '@react-three/fiber';
|
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
import { DeviceOrientationControls as DeviceOrientationControlsImp } from 'three-stdlib';
|
|
4
4
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
5
|
-
export
|
|
5
|
+
export type DeviceOrientationControlsProps = ReactThreeFiber.Object3DNode<DeviceOrientationControlsImp, typeof DeviceOrientationControlsImp> & {
|
|
6
6
|
camera?: THREE.Camera;
|
|
7
7
|
onChange?: (e?: THREE.Event) => void;
|
|
8
8
|
makeDefault?: boolean;
|
|
@@ -21,14 +21,13 @@ const DeviceOrientationControls = /*#__PURE__*/React.forwardRef((props, ref) =>
|
|
|
21
21
|
invalidate();
|
|
22
22
|
if (onChange) onChange(e);
|
|
23
23
|
};
|
|
24
|
-
|
|
25
|
-
controls == null
|
|
26
|
-
return () => controls == null ? void 0 : controls.removeEventListener == null ? void 0 : controls.removeEventListener('change', callback);
|
|
24
|
+
controls == null || controls.addEventListener == null || controls.addEventListener('change', callback);
|
|
25
|
+
return () => controls == null || controls.removeEventListener == null ? void 0 : controls.removeEventListener('change', callback);
|
|
27
26
|
}, [onChange, controls, invalidate]);
|
|
28
27
|
useFrame(() => controls == null ? void 0 : controls.update(), -1);
|
|
29
28
|
React.useEffect(() => {
|
|
30
29
|
const current = controls;
|
|
31
|
-
current == null
|
|
30
|
+
current == null || current.connect();
|
|
32
31
|
return () => current == null ? void 0 : current.dispose();
|
|
33
32
|
}, [controls]);
|
|
34
33
|
React.useEffect(() => {
|
package/core/Edges.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactThreeFiber } from '@react-three/fiber';
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
4
|
-
|
|
4
|
+
type Props = JSX.IntrinsicElements['lineSegments'] & {
|
|
5
5
|
threshold?: number;
|
|
6
6
|
color?: ReactThreeFiber.Color;
|
|
7
7
|
};
|
package/core/Edges.js
CHANGED
|
@@ -13,10 +13,8 @@ const Edges = /*#__PURE__*/React.forwardRef(({
|
|
|
13
13
|
const ref = React.useRef(null);
|
|
14
14
|
React.useLayoutEffect(() => {
|
|
15
15
|
const parent = ref.current.parent;
|
|
16
|
-
|
|
17
16
|
if (parent) {
|
|
18
17
|
const geom = geometry || parent.geometry;
|
|
19
|
-
|
|
20
18
|
if (geom !== ref.current.userData.currentGeom || threshold !== ref.current.userData.currentThreshold) {
|
|
21
19
|
ref.current.userData.currentGeom = geom;
|
|
22
20
|
ref.current.userData.currentThreshold = threshold;
|
package/core/Effects.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactThreeFiber } from '@react-three/fiber';
|
|
2
2
|
import { EffectComposer, RenderPass, ShaderPass } from 'three-stdlib';
|
|
3
3
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
4
|
-
|
|
4
|
+
type Props = ReactThreeFiber.Node<EffectComposer, typeof EffectComposer> & {
|
|
5
5
|
multisamping?: number;
|
|
6
6
|
encoding?: number;
|
|
7
7
|
type?: number;
|
package/core/Effects.js
CHANGED
|
@@ -47,25 +47,23 @@ const Effects = /*#__PURE__*/React.forwardRef(({
|
|
|
47
47
|
depthBuffer,
|
|
48
48
|
stencilBuffer,
|
|
49
49
|
anisotropy
|
|
50
|
-
});
|
|
50
|
+
});
|
|
51
51
|
|
|
52
|
+
// sRGB textures must be RGBA8 since r137 https://github.com/mrdoob/three.js/pull/23129
|
|
52
53
|
if (type === UnsignedByteType && encoding != null) {
|
|
53
54
|
if ('colorSpace' in t) t.texture.colorSpace = encoding;else t.texture.encoding = encoding;
|
|
54
55
|
}
|
|
55
|
-
|
|
56
56
|
t.samples = multisamping;
|
|
57
57
|
return t;
|
|
58
58
|
});
|
|
59
59
|
React.useEffect(() => {
|
|
60
60
|
var _composer$current, _composer$current2;
|
|
61
|
-
|
|
62
|
-
(_composer$
|
|
63
|
-
(_composer$current2 = composer.current) == null ? void 0 : _composer$current2.setPixelRatio(viewport.dpr);
|
|
61
|
+
(_composer$current = composer.current) == null || _composer$current.setSize(size.width, size.height);
|
|
62
|
+
(_composer$current2 = composer.current) == null || _composer$current2.setPixelRatio(viewport.dpr);
|
|
64
63
|
}, [gl, size, viewport.dpr]);
|
|
65
64
|
useFrame(() => {
|
|
66
65
|
var _composer$current3;
|
|
67
|
-
|
|
68
|
-
if (!disableRender) (_composer$current3 = composer.current) == null ? void 0 : _composer$current3.render();
|
|
66
|
+
if (!disableRender) (_composer$current3 = composer.current) == null || _composer$current3.render();
|
|
69
67
|
}, renderIndex);
|
|
70
68
|
const passes = [];
|
|
71
69
|
if (!disableRenderPass) passes.push( /*#__PURE__*/React.createElement("renderPass", {
|
package/core/Environment.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Scene } from 'three';
|
|
|
4
4
|
import { GroundProjectedEnv as GroundProjectedEnvImpl } from 'three-stdlib';
|
|
5
5
|
import { PresetsType } from '../helpers/environment-assets';
|
|
6
6
|
import { EnvironmentLoaderProps } from './useEnvironment';
|
|
7
|
-
export
|
|
7
|
+
export type EnvironmentProps = {
|
|
8
8
|
children?: React.ReactNode;
|
|
9
9
|
frames?: number;
|
|
10
10
|
near?: number;
|
|
@@ -23,7 +23,7 @@ export declare type EnvironmentProps = {
|
|
|
23
23
|
} & EnvironmentLoaderProps;
|
|
24
24
|
export declare function EnvironmentMap({ scene, background, blur, map }: EnvironmentProps): null;
|
|
25
25
|
export declare function EnvironmentCube({ background, scene, blur, ...rest }: EnvironmentProps): null;
|
|
26
|
-
export declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, scene, files, path, preset, extensions, }: EnvironmentProps): JSX.Element;
|
|
26
|
+
export declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, scene, files, path, preset, extensions, }: EnvironmentProps): React.JSX.Element;
|
|
27
27
|
declare global {
|
|
28
28
|
namespace JSX {
|
|
29
29
|
interface IntrinsicElements {
|
|
@@ -31,4 +31,4 @@ declare global {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
export declare function Environment(props: EnvironmentProps): JSX.Element;
|
|
34
|
+
export declare function Environment(props: EnvironmentProps): React.JSX.Element;
|
package/core/Environment.js
CHANGED
|
@@ -6,27 +6,24 @@ import { GroundProjectedEnv } from 'three-stdlib';
|
|
|
6
6
|
import { useEnvironment } from './useEnvironment.js';
|
|
7
7
|
|
|
8
8
|
const isRef = obj => obj.current && obj.current.isScene;
|
|
9
|
-
|
|
10
9
|
const resolveScene = scene => isRef(scene) ? scene.current : scene;
|
|
11
|
-
|
|
12
10
|
function setEnvProps(background, scene, defaultScene, texture, blur = 0) {
|
|
13
11
|
const target = resolveScene(scene || defaultScene);
|
|
14
12
|
const oldbg = target.background;
|
|
15
|
-
const oldenv = target.environment;
|
|
16
|
-
|
|
13
|
+
const oldenv = target.environment;
|
|
14
|
+
// @ts-ignore
|
|
17
15
|
const oldBlur = target.backgroundBlurriness || 0;
|
|
18
16
|
if (background !== 'only') target.environment = texture;
|
|
19
|
-
if (background) target.background = texture;
|
|
20
|
-
|
|
17
|
+
if (background) target.background = texture;
|
|
18
|
+
// @ts-ignore
|
|
21
19
|
if (background && target.backgroundBlurriness !== undefined) target.backgroundBlurriness = blur;
|
|
22
20
|
return () => {
|
|
23
21
|
if (background !== 'only') target.environment = oldenv;
|
|
24
|
-
if (background) target.background = oldbg;
|
|
25
|
-
|
|
22
|
+
if (background) target.background = oldbg;
|
|
23
|
+
// @ts-ignore
|
|
26
24
|
if (background && target.backgroundBlurriness !== undefined) target.backgroundBlurriness = oldBlur;
|
|
27
25
|
};
|
|
28
26
|
}
|
|
29
|
-
|
|
30
27
|
function EnvironmentMap({
|
|
31
28
|
scene,
|
|
32
29
|
background = false,
|
|
@@ -102,10 +99,8 @@ function EnvironmentPortal({
|
|
|
102
99
|
extensions: extensions
|
|
103
100
|
}) : null), virtualScene));
|
|
104
101
|
}
|
|
105
|
-
|
|
106
102
|
function EnvironmentGround(props) {
|
|
107
103
|
var _props$ground, _props$ground2, _scale, _props$ground3;
|
|
108
|
-
|
|
109
104
|
const textureDefault = useEnvironment(props);
|
|
110
105
|
const texture = props.map || textureDefault;
|
|
111
106
|
React.useMemo(() => extend({
|
|
@@ -124,7 +119,6 @@ function EnvironmentGround(props) {
|
|
|
124
119
|
radius: radius
|
|
125
120
|
}));
|
|
126
121
|
}
|
|
127
|
-
|
|
128
122
|
function Environment(props) {
|
|
129
123
|
return props.ground ? /*#__PURE__*/React.createElement(EnvironmentGround, props) : props.map ? /*#__PURE__*/React.createElement(EnvironmentMap, props) : props.children ? /*#__PURE__*/React.createElement(EnvironmentPortal, props) : /*#__PURE__*/React.createElement(EnvironmentCube, props);
|
|
130
124
|
}
|
package/core/Example.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { Color } from '@react-three/fiber';
|
|
3
|
-
export
|
|
3
|
+
export type ExampleProps = {
|
|
4
4
|
font: string;
|
|
5
5
|
color?: Color;
|
|
6
6
|
debug?: boolean;
|
|
7
7
|
bevelSize?: number;
|
|
8
8
|
} & JSX.IntrinsicElements['group'];
|
|
9
|
-
export
|
|
9
|
+
export type ExampleApi = {
|
|
10
10
|
incr: (x?: number) => void;
|
|
11
11
|
decr: (x?: number) => void;
|
|
12
12
|
};
|
|
13
|
-
export declare const Example: React.ForwardRefExoticComponent<
|
|
13
|
+
export declare const Example: React.ForwardRefExoticComponent<Omit<ExampleProps, "ref"> & React.RefAttributes<ExampleApi>>;
|
package/core/Example.js
CHANGED
|
@@ -13,8 +13,9 @@ const Example = /*#__PURE__*/React.forwardRef(({
|
|
|
13
13
|
}, fref) => {
|
|
14
14
|
const [counter, setCounter] = React.useState(0);
|
|
15
15
|
const incr = React.useCallback((x = 1) => setCounter(counter + x), [counter]);
|
|
16
|
-
const decr = React.useCallback((x = 1) => setCounter(counter - x), [counter]);
|
|
16
|
+
const decr = React.useCallback((x = 1) => setCounter(counter - x), [counter]);
|
|
17
17
|
|
|
18
|
+
// ref-API
|
|
18
19
|
const api = React.useMemo(() => ({
|
|
19
20
|
incr,
|
|
20
21
|
decr
|
package/core/FaceControls.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"),a=require("@react-three/fiber"),n=require("maath"),o=require("suspend-react"),c=require("./useVideoTexture.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 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)}require("./Line.cjs.js"),require("three-stdlib"),require("@mediapipe/tasks-vision");var d=i(e),f=l(t),p=l(r);function m(e,t){return e.clone().add(t).multiplyScalar(.5)}function v(e,t,r){const a=e.localToWorld(t);return r.worldToLocal(a)}const b=r.createContext({}),y=r.forwardRef((({camera:e,autostart:t=!0,webcam:o=!0,webcamVideoTextureSrc:c,manualUpdate:i=!1,manualDetect:l=!1,onVideoFrame:y,smoothTime:h=.25,offset:x=!0,offsetScalar:T=80,eyes:E=!1,eyesAsOrigin:j=!0,depth:k=.15,debug:V=!1,facemesh:g,makeDefault:F},R)=>{var S,q;const O=a.useThree((e=>e.scene)),C=a.useThree((e=>e.camera)),M=a.useThree((e=>e.set)),D=a.useThree((e=>e.get)),A=e||C,L=r.useRef(null),P=r.useRef(null),[I]=r.useState((()=>new f.Object3D)),[_]=r.useState((()=>new f.Vector3)),[B]=r.useState((()=>new f.Vector3)),[H]=r.useState((()=>new f.Vector3)),[W]=r.useState((()=>new f.Vector3)),z=r.useCallback((()=>{I.parent=A.parent;const e=P.current;if(e){const{outerRef:t,eyeRightRef:r,eyeLeftRef:a}=e;if(r.current&&a.current){const{irisDirRef:e}=r.current,{irisDirRef:n}=a.current;e.current&&n.current&&t.current&&(_.copy(v(e.current,new f.Vector3(0,0,0),t.current)),B.copy(v(n.current,new f.Vector3(0,0,0),t.current)),I.position.copy(v(t.current,m(_,B),A.parent||O)),H.copy(v(e.current,new f.Vector3(0,0,1),t.current)),W.copy(v(n.current,new f.Vector3(0,0,1),t.current)),I.lookAt(t.current.localToWorld(m(H,W))))}else t.current&&(I.position.copy(v(t.current,new f.Vector3(0,0,0),A.parent||O)),I.lookAt(t.current.localToWorld(new f.Vector3(0,0,1))))}return I}),[A,B,W,_,H,O,I]),[U]=r.useState((()=>new f.Object3D)),G=r.useCallback((function(e,t){if(A){var r;if(null!==(r=t)&&void 0!==r||(t=z()),h>0){const r=1e-9;n.easing.damp3(U.position,t.position,h,e,void 0,void 0,r),n.easing.dampE(U.rotation,t.rotation,h,e,void 0,void 0,r)}else U.position.copy(t.position),U.rotation.copy(t.rotation);A.position.copy(U.position),A.rotation.copy(U.rotation)}}),[A,z,h,U.position,U.rotation]),[J,K]=r.useState(),N=s.useFaceLandmarker(),Q=r.useCallback(((e,t)=>{const r=null==N?void 0:N.detectForVideo(e,t);K(r)}),[N]);a.useFrame(((e,t)=>{i||G(t)}));const X=r.useMemo((()=>Object.assign(Object.create(f.EventDispatcher.prototype),{detect:Q,computeTarget:z,update:G,facemeshApiRef:P,webcamApiRef:L,play:()=>{var e
|
|
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("maath"),o=require("suspend-react"),c=require("./useVideoTexture.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 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)}require("./Line.cjs.js"),require("three-stdlib"),require("@mediapipe/tasks-vision");var d=i(e),f=l(t),p=l(r);function m(e,t){return e.clone().add(t).multiplyScalar(.5)}function v(e,t,r){const a=e.localToWorld(t);return r.worldToLocal(a)}const b=r.createContext({}),y=r.forwardRef((({camera:e,autostart:t=!0,webcam:o=!0,webcamVideoTextureSrc:c,manualUpdate:i=!1,manualDetect:l=!1,onVideoFrame:y,smoothTime:h=.25,offset:x=!0,offsetScalar:T=80,eyes:E=!1,eyesAsOrigin:j=!0,depth:k=.15,debug:V=!1,facemesh:g,makeDefault:F},R)=>{var S,q;const O=a.useThree((e=>e.scene)),C=a.useThree((e=>e.camera)),M=a.useThree((e=>e.set)),D=a.useThree((e=>e.get)),A=e||C,L=r.useRef(null),P=r.useRef(null),[I]=r.useState((()=>new f.Object3D)),[_]=r.useState((()=>new f.Vector3)),[B]=r.useState((()=>new f.Vector3)),[H]=r.useState((()=>new f.Vector3)),[W]=r.useState((()=>new f.Vector3)),z=r.useCallback((()=>{I.parent=A.parent;const e=P.current;if(e){const{outerRef:t,eyeRightRef:r,eyeLeftRef:a}=e;if(r.current&&a.current){const{irisDirRef:e}=r.current,{irisDirRef:n}=a.current;e.current&&n.current&&t.current&&(_.copy(v(e.current,new f.Vector3(0,0,0),t.current)),B.copy(v(n.current,new f.Vector3(0,0,0),t.current)),I.position.copy(v(t.current,m(_,B),A.parent||O)),H.copy(v(e.current,new f.Vector3(0,0,1),t.current)),W.copy(v(n.current,new f.Vector3(0,0,1),t.current)),I.lookAt(t.current.localToWorld(m(H,W))))}else t.current&&(I.position.copy(v(t.current,new f.Vector3(0,0,0),A.parent||O)),I.lookAt(t.current.localToWorld(new f.Vector3(0,0,1))))}return I}),[A,B,W,_,H,O,I]),[U]=r.useState((()=>new f.Object3D)),G=r.useCallback((function(e,t){if(A){var r;if(null!==(r=t)&&void 0!==r||(t=z()),h>0){const r=1e-9;n.easing.damp3(U.position,t.position,h,e,void 0,void 0,r),n.easing.dampE(U.rotation,t.rotation,h,e,void 0,void 0,r)}else U.position.copy(t.position),U.rotation.copy(t.rotation);A.position.copy(U.position),A.rotation.copy(U.rotation)}}),[A,z,h,U.position,U.rotation]),[J,K]=r.useState(),N=s.useFaceLandmarker(),Q=r.useCallback(((e,t)=>{const r=null==N?void 0:N.detectForVideo(e,t);K(r)}),[N]);a.useFrame(((e,t)=>{i||G(t)}));const X=r.useMemo((()=>Object.assign(Object.create(f.EventDispatcher.prototype),{detect:Q,computeTarget:z,update:G,facemeshApiRef:P,webcamApiRef:L,play:()=>{var e;null==(e=L.current)||null==(e=e.videoTextureApiRef.current)||e.texture.source.data.play()},pause:()=>{var e;null==(e=L.current)||null==(e=e.videoTextureApiRef.current)||e.texture.source.data.pause()}})),[Q,z,G]);r.useImperativeHandle(R,(()=>X),[X]),r.useEffect((()=>{const e=e=>{l||Q(e.texture.source.data,e.time),y&&y(e)};return X.addEventListener("videoFrame",e),()=>{X.removeEventListener("videoFrame",e)}}),[X,Q,N,l,y]),r.useEffect((()=>{if(F){const e=D().controls;return M({controls:X}),()=>M({controls:e})}}),[F,X,D,M]);const Y=null==J?void 0:J.faceLandmarks[0],Z=null==J||null==(S=J.facialTransformationMatrixes)?void 0:S[0],$=null==J||null==(q=J.faceBlendshapes)?void 0:q[0];return p.createElement(b.Provider,{value:X},o&&p.createElement(r.Suspense,{fallback:null},p.createElement(w,{ref:L,autostart:t,videoTextureSrc:c})),p.createElement(u.Facemesh,d.default({ref:P},g,{points:Y,depth:k,facialTransformationMatrix:Z,faceBlendshapes:$,eyes:E,eyesAsOrigin:j,offset:x,offsetScalar:T,debug:V,"rotation-z":Math.PI,visible:V}),p.createElement("meshBasicMaterial",{side:f.DoubleSide})))})),h=()=>r.useContext(b),w=r.forwardRef((({videoTextureSrc:e,autostart:t=!0},a)=>{const n=r.useRef(null),c=h(),u=o.suspend((async()=>e?Promise.resolve(null):await navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:"user"}})),[e]);r.useEffect((()=>(c.dispatchEvent({type:"stream",stream:u}),()=>{null==u||u.getTracks().forEach((e=>e.stop())),o.clear([e])})),[u,c,e]);const s=r.useMemo((()=>({videoTextureApiRef:n})),[]);return r.useImperativeHandle(a,(()=>s),[s]),p.createElement(r.Suspense,{fallback:null},p.createElement(x,{ref:n,src:e||u,start:t}))})),x=r.forwardRef((({src:e,start:t},a)=>{const n=c.useVideoTexture(e,{start:t}),o=n.source.data,u=h(),s=r.useCallback((e=>{u.dispatchEvent({type:"videoFrame",texture:n,time:e})}),[n,u]);T(o,s);const i=r.useMemo((()=>({texture:n})),[n]);return r.useImperativeHandle(a,(()=>i),[i]),p.createElement(p.Fragment,null)})),T=(e,t)=>{r.useEffect((()=>{if(!e||!e.requestVideoFrameCallback)return;let r;return e.requestVideoFrameCallback((function a(...n){t(...n),r=e.requestVideoFrameCallback(a)})),()=>e.cancelVideoFrameCallback(r)}),[e,t])};exports.FaceControls=y,exports.useFaceControls=h;
|
package/core/FaceControls.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import * as React from 'react';
|
|
|
3
3
|
import { RefObject } from 'react';
|
|
4
4
|
import { useVideoTexture } from './useVideoTexture';
|
|
5
5
|
import { FacemeshApi, FacemeshProps } from './Facemesh';
|
|
6
|
-
|
|
7
|
-
export
|
|
6
|
+
type VideoTextureSrc = Parameters<typeof useVideoTexture>[0];
|
|
7
|
+
export type FaceControlsProps = {
|
|
8
8
|
camera?: THREE.Camera;
|
|
9
9
|
autostart?: boolean;
|
|
10
10
|
webcam?: boolean;
|
|
@@ -22,7 +22,7 @@ export declare type FaceControlsProps = {
|
|
|
22
22
|
debug?: boolean;
|
|
23
23
|
facemesh?: FacemeshProps;
|
|
24
24
|
};
|
|
25
|
-
export
|
|
25
|
+
export type FaceControlsApi = THREE.EventDispatcher & {
|
|
26
26
|
detect: (video: HTMLVideoElement, time: number) => void;
|
|
27
27
|
computeTarget: () => THREE.Object3D;
|
|
28
28
|
update: (delta: number, target?: THREE.Object3D) => void;
|
|
@@ -33,10 +33,10 @@ export declare type FaceControlsApi = THREE.EventDispatcher & {
|
|
|
33
33
|
};
|
|
34
34
|
export declare const FaceControls: React.ForwardRefExoticComponent<FaceControlsProps & React.RefAttributes<FaceControlsApi>>;
|
|
35
35
|
export declare const useFaceControls: () => FaceControlsApi;
|
|
36
|
-
|
|
36
|
+
type WebcamApi = {
|
|
37
37
|
videoTextureApiRef: RefObject<VideoTextureApi>;
|
|
38
38
|
};
|
|
39
|
-
|
|
39
|
+
type VideoTextureApi = {
|
|
40
40
|
texture: THREE.VideoTexture;
|
|
41
41
|
};
|
|
42
42
|
export {};
|