@ohos-ports/react-three-drei 10.7.7-beta.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/LICENSE +21 -0
- package/README.md +852 -0
- package/core/AccumulativeShadows.cjs.js +1 -0
- package/core/AccumulativeShadows.d.ts +59 -0
- package/core/AccumulativeShadows.js +310 -0
- package/core/AdaptiveDpr.cjs.js +1 -0
- package/core/AdaptiveDpr.d.ts +3 -0
- package/core/AdaptiveDpr.js +28 -0
- package/core/AdaptiveEvents.cjs.js +1 -0
- package/core/AdaptiveEvents.d.ts +1 -0
- package/core/AdaptiveEvents.js +20 -0
- package/core/ArcballControls.cjs.js +1 -0
- package/core/ArcballControls.d.ts +15 -0
- package/core/ArcballControls.js +67 -0
- package/core/AsciiRenderer.cjs.js +1 -0
- package/core/AsciiRenderer.d.ts +11 -0
- package/core/AsciiRenderer.js +66 -0
- package/core/BBAnchor.cjs.js +1 -0
- package/core/BBAnchor.d.ts +7 -0
- package/core/BBAnchor.js +37 -0
- package/core/Backdrop.cjs.js +1 -0
- package/core/Backdrop.d.ts +15 -0
- package/core/Backdrop.js +33 -0
- package/core/BakeShadows.cjs.js +1 -0
- package/core/BakeShadows.d.ts +1 -0
- package/core/BakeShadows.js +16 -0
- package/core/Billboard.cjs.js +1 -0
- package/core/Billboard.d.ts +10 -0
- package/core/Billboard.js +53 -0
- package/core/Bounds.cjs.js +1 -0
- package/core/Bounds.d.ts +36 -0
- package/core/Bounds.js +254 -0
- package/core/Bvh.cjs.js +1 -0
- package/core/Bvh.d.ts +19 -0
- package/core/Bvh.js +92 -0
- package/core/CameraControls.cjs.js +1 -0
- package/core/CameraControls.d.ts +48 -0
- package/core/CameraControls.js +151 -0
- package/core/CameraShake.cjs.js +1 -0
- package/core/CameraShake.d.ts +17 -0
- package/core/CameraShake.js +57 -0
- package/core/CatmullRomLine.cjs.js +1 -0
- package/core/CatmullRomLine.d.ts +10 -0
- package/core/CatmullRomLine.js +42 -0
- package/core/Caustics.cjs.js +1 -0
- package/core/Caustics.d.ts +32 -0
- package/core/Caustics.js +388 -0
- package/core/Center.cjs.js +1 -0
- package/core/Center.d.ts +33 -0
- package/core/Center.js +67 -0
- package/core/Clone.cjs.js +1 -0
- package/core/Clone.d.ts +15 -0
- package/core/Clone.js +100 -0
- package/core/Cloud.cjs.js +1 -0
- package/core/Cloud.d.ts +97 -0
- package/core/Cloud.js +231 -0
- package/core/ComputedAttribute.cjs.js +1 -0
- package/core/ComputedAttribute.d.ts +8 -0
- package/core/ComputedAttribute.js +33 -0
- package/core/ContactShadows.cjs.js +1 -0
- package/core/ContactShadows.d.ts +18 -0
- package/core/ContactShadows.js +114 -0
- package/core/CubeCamera.cjs.js +1 -0
- package/core/CubeCamera.d.ts +21 -0
- package/core/CubeCamera.js +86 -0
- package/core/CubeTexture.cjs.js +1 -0
- package/core/CubeTexture.d.ts +14 -0
- package/core/CubeTexture.js +25 -0
- package/core/CubicBezierLine.cjs.js +1 -0
- package/core/CubicBezierLine.d.ts +12 -0
- package/core/CubicBezierLine.js +28 -0
- package/core/CurveModifier.cjs.js +1 -0
- package/core/CurveModifier.d.ts +11 -0
- package/core/CurveModifier.js +27 -0
- package/core/Decal.cjs.js +1 -0
- package/core/Decal.d.ts +16 -0
- package/core/Decal.js +128 -0
- package/core/Detailed.cjs.js +1 -0
- package/core/Detailed.d.ts +10 -0
- package/core/Detailed.js +33 -0
- package/core/DetectGPU.cjs.js +1 -0
- package/core/DetectGPU.d.ts +7 -0
- package/core/DetectGPU.js +14 -0
- package/core/DeviceOrientationControls.cjs.js +1 -0
- package/core/DeviceOrientationControls.d.ts +10 -0
- package/core/DeviceOrientationControls.js +51 -0
- package/core/Edges.cjs.js +1 -0
- package/core/Edges.d.ts +13 -0
- package/core/Edges.js +38 -0
- package/core/Effects.cjs.js +1 -0
- package/core/Effects.d.ts +25 -0
- package/core/Effects.js +91 -0
- package/core/Environment.cjs.js +1 -0
- package/core/Environment.d.ts +37 -0
- package/core/Environment.js +189 -0
- package/core/Example.cjs.js +1 -0
- package/core/Example.d.ts +13 -0
- package/core/Example.js +46 -0
- package/core/Fbo.cjs.js +1 -0
- package/core/Fbo.d.ts +22 -0
- package/core/Fbo.js +63 -0
- package/core/Fbx.cjs.js +1 -0
- package/core/Fbx.d.ts +11 -0
- package/core/Fbx.js +23 -0
- package/core/FirstPersonControls.cjs.js +1 -0
- package/core/FirstPersonControls.d.ts +8 -0
- package/core/FirstPersonControls.js +38 -0
- package/core/Fisheye.cjs.js +1 -0
- package/core/Fisheye.d.ts +10 -0
- package/core/Fisheye.js +95 -0
- package/core/Float.cjs.js +1 -0
- package/core/Float.d.ts +14 -0
- package/core/Float.js +37 -0
- package/core/FlyControls.cjs.js +1 -0
- package/core/FlyControls.d.ts +10 -0
- package/core/FlyControls.js +55 -0
- package/core/GizmoHelper.cjs.js +1 -0
- package/core/GizmoHelper.d.ts +16 -0
- package/core/GizmoHelper.js +116 -0
- package/core/GizmoViewcube.cjs.js +1 -0
- package/core/GizmoViewcube.d.ts +14 -0
- package/core/GizmoViewcube.js +133 -0
- package/core/GizmoViewport.cjs.js +1 -0
- package/core/GizmoViewport.d.ts +16 -0
- package/core/GizmoViewport.js +140 -0
- package/core/Gltf.cjs.js +1 -0
- package/core/Gltf.d.ts +27 -0
- package/core/Gltf.js +52 -0
- package/core/GradientTexture.cjs.js +1 -0
- package/core/GradientTexture.d.ts +18 -0
- package/core/GradientTexture.js +54 -0
- package/core/Grid.cjs.js +1 -0
- package/core/Grid.d.ts +26 -0
- package/core/Grid.js +142 -0
- package/core/Helper.cjs.js +1 -0
- package/core/Helper.d.ts +16 -0
- package/core/Helper.js +47 -0
- package/core/Hud.cjs.js +1 -0
- package/core/Hud.d.ts +6 -0
- package/core/Hud.js +55 -0
- package/core/Image.cjs.js +1 -0
- package/core/Image.d.ts +38 -0
- package/core/Image.js +160 -0
- package/core/Instances.cjs.js +1 -0
- package/core/Instances.d.ts +64 -0
- package/core/Instances.js +313 -0
- package/core/Ktx2.cjs.js +1 -0
- package/core/Ktx2.d.ts +14 -0
- package/core/Ktx2.js +48 -0
- package/core/Lightformer.cjs.js +1 -0
- package/core/Lightformer.d.ts +15 -0
- package/core/Lightformer.js +63 -0
- package/core/Line.cjs.js +1 -0
- package/core/Line.d.ts +13 -0
- package/core/Line.js +73 -0
- package/core/MapControls.cjs.js +1 -0
- package/core/MapControls.d.ts +14 -0
- package/core/MapControls.js +63 -0
- package/core/MarchingCubes.cjs.js +1 -0
- package/core/MarchingCubes.d.ts +24 -0
- package/core/MarchingCubes.js +78 -0
- package/core/Mask.cjs.js +1 -0
- package/core/Mask.d.ts +17 -0
- package/core/Mask.js +42 -0
- package/core/MatcapTexture.cjs.js +1 -0
- package/core/MatcapTexture.d.ts +9 -0
- package/core/MatcapTexture.js +51 -0
- package/core/MeshDiscardMaterial.cjs.js +1 -0
- package/core/MeshDiscardMaterial.d.ts +10 -0
- package/core/MeshDiscardMaterial.js +15 -0
- package/core/MeshDistortMaterial.cjs.js +1 -0
- package/core/MeshDistortMaterial.d.ts +39 -0
- package/core/MeshDistortMaterial.js +72 -0
- package/core/MeshPortalMaterial.cjs.js +1 -0
- package/core/MeshPortalMaterial.d.ts +25 -0
- package/core/MeshPortalMaterial.js +467 -0
- package/core/MeshReflectorMaterial.cjs.js +1 -0
- package/core/MeshReflectorMaterial.d.ts +14 -0
- package/core/MeshReflectorMaterial.js +180 -0
- package/core/MeshRefractionMaterial.cjs.js +1 -0
- package/core/MeshRefractionMaterial.d.ts +19 -0
- package/core/MeshRefractionMaterial.js +73 -0
- package/core/MeshTransmissionMaterial.cjs.js +1 -0
- package/core/MeshTransmissionMaterial.d.ts +34 -0
- package/core/MeshTransmissionMaterial.js +402 -0
- package/core/MeshWobbleMaterial.cjs.js +1 -0
- package/core/MeshWobbleMaterial.d.ts +36 -0
- package/core/MeshWobbleMaterial.js +60 -0
- package/core/MotionPathControls.cjs.js +1 -0
- package/core/MotionPathControls.d.ts +33 -0
- package/core/MotionPathControls.js +121 -0
- package/core/MultiMaterial.cjs.js +1 -0
- package/core/MultiMaterial.d.ts +4 -0
- package/core/MultiMaterial.js +29 -0
- package/core/NormalTexture.cjs.js +1 -0
- package/core/NormalTexture.d.ts +14 -0
- package/core/NormalTexture.js +42 -0
- package/core/OrbitControls.cjs.js +1 -0
- package/core/OrbitControls.d.ts +22 -0
- package/core/OrbitControls.js +79 -0
- package/core/OrthographicCamera.cjs.js +1 -0
- package/core/OrthographicCamera.d.ts +14 -0
- package/core/OrthographicCamera.js +76 -0
- package/core/Outlines.cjs.js +1 -0
- package/core/Outlines.d.ts +17 -0
- package/core/Outlines.js +166 -0
- package/core/PerformanceMonitor.cjs.js +1 -0
- package/core/PerformanceMonitor.d.ts +36 -0
- package/core/PerformanceMonitor.js +116 -0
- package/core/PerspectiveCamera.cjs.js +1 -0
- package/core/PerspectiveCamera.d.ts +14 -0
- package/core/PerspectiveCamera.js +72 -0
- package/core/PointMaterial.cjs.js +1 -0
- package/core/PointMaterial.d.ts +8 -0
- package/core/PointMaterial.js +36 -0
- package/core/PointerLockControls.cjs.js +1 -0
- package/core/PointerLockControls.d.ts +15 -0
- package/core/PointerLockControls.js +89 -0
- package/core/Points.cjs.js +1 -0
- package/core/Points.d.ts +31 -0
- package/core/Points.js +202 -0
- package/core/PositionalAudio.cjs.js +1 -0
- package/core/PositionalAudio.d.ts +9 -0
- package/core/PositionalAudio.js +46 -0
- package/core/Preload.cjs.js +1 -0
- package/core/Preload.d.ts +7 -0
- package/core/Preload.js +44 -0
- package/core/Progress.cjs.js +1 -0
- package/core/Progress.d.ts +14 -0
- package/core/Progress.js +55 -0
- package/core/QuadraticBezierLine.cjs.js +1 -0
- package/core/QuadraticBezierLine.d.ts +14 -0
- package/core/QuadraticBezierLine.js +42 -0
- package/core/RenderCubeTexture.cjs.js +1 -0
- package/core/RenderCubeTexture.d.ts +30 -0
- package/core/RenderCubeTexture.js +96 -0
- package/core/RenderTexture.cjs.js +1 -0
- package/core/RenderTexture.d.ts +18 -0
- package/core/RenderTexture.js +105 -0
- package/core/Resize.cjs.js +1 -0
- package/core/Resize.d.ts +17 -0
- package/core/Resize.js +39 -0
- package/core/RoundedBox.cjs.js +1 -0
- package/core/RoundedBox.d.ts +14 -0
- package/core/RoundedBox.js +70 -0
- package/core/Sampler.cjs.js +1 -0
- package/core/Sampler.d.ts +28 -0
- package/core/Sampler.js +75 -0
- package/core/ScreenQuad.cjs.js +1 -0
- package/core/ScreenQuad.d.ts +5 -0
- package/core/ScreenQuad.js +25 -0
- package/core/ScreenSizer.cjs.js +1 -0
- package/core/ScreenSizer.d.ts +7 -0
- package/core/ScreenSizer.js +39 -0
- package/core/ScreenSpace.cjs.js +1 -0
- package/core/ScreenSpace.d.ts +7 -0
- package/core/ScreenSpace.js +25 -0
- package/core/Segments.cjs.js +1 -0
- package/core/Segments.d.ts +29 -0
- package/core/Segments.js +96 -0
- package/core/Shadow.cjs.js +1 -0
- package/core/Shadow.d.ts +12 -0
- package/core/Shadow.js +42 -0
- package/core/ShadowAlpha.cjs.js +1 -0
- package/core/ShadowAlpha.d.ts +7 -0
- package/core/ShadowAlpha.js +108 -0
- package/core/Sky.cjs.js +1 -0
- package/core/Sky.d.ts +16 -0
- package/core/Sky.js +39 -0
- package/core/Sparkles.cjs.js +1 -0
- package/core/Sparkles.d.ts +26 -0
- package/core/Sparkles.js +161 -0
- package/core/Splat.cjs.js +1 -0
- package/core/Splat.d.ts +56 -0
- package/core/Splat.js +506 -0
- package/core/SpotLight.cjs.js +1 -0
- package/core/SpotLight.d.ts +27 -0
- package/core/SpotLight.js +223 -0
- package/core/SpriteAnimator.cjs.js +1 -0
- package/core/SpriteAnimator.d.ts +88 -0
- package/core/SpriteAnimator.js +413 -0
- package/core/Stage.cjs.js +1 -0
- package/core/Stage.d.ts +27 -0
- package/core/Stage.js +133 -0
- package/core/Stars.cjs.js +1 -0
- package/core/Stars.d.ts +22 -0
- package/core/Stars.js +100 -0
- package/core/Stats.cjs.js +1 -0
- package/core/Stats.d.ts +7 -0
- package/core/Stats.js +32 -0
- package/core/StatsGl.cjs.js +1 -0
- package/core/StatsGl.d.ts +14 -0
- package/core/StatsGl.js +44 -0
- package/core/Svg.cjs.js +1 -0
- package/core/Svg.d.ts +13 -0
- package/core/Svg.js +62 -0
- package/core/Text.cjs.js +1 -0
- package/core/Text.d.ts +38 -0
- package/core/Text.js +57 -0
- package/core/Text3D.cjs.js +1 -0
- package/core/Text3D.d.ts +20 -0
- package/core/Text3D.js +74 -0
- package/core/Texture.cjs.js +1 -0
- package/core/Texture.d.ts +20 -0
- package/core/Texture.js +60 -0
- package/core/TrackballControls.cjs.js +1 -0
- package/core/TrackballControls.d.ts +15 -0
- package/core/TrackballControls.js +72 -0
- package/core/Trail.cjs.js +1 -0
- package/core/Trail.d.ts +21 -0
- package/core/Trail.js +150 -0
- package/core/TrailTexture.cjs.js +1 -0
- package/core/TrailTexture.d.ts +19 -0
- package/core/TrailTexture.js +159 -0
- package/core/TransformControls.cjs.js +1 -0
- package/core/TransformControls.d.ts +28 -0
- package/core/TransformControls.js +114 -0
- package/core/VideoTexture.cjs.js +1 -0
- package/core/VideoTexture.d.ts +26 -0
- package/core/VideoTexture.js +111 -0
- package/core/Wireframe.cjs.js +1 -0
- package/core/Wireframe.d.ts +15 -0
- package/core/Wireframe.js +157 -0
- package/core/calculateScaleFactor.cjs.js +1 -0
- package/core/calculateScaleFactor.d.ts +3 -0
- package/core/calculateScaleFactor.js +31 -0
- package/core/index.cjs.js +1 -0
- package/core/index.d.ts +122 -0
- package/core/index.js +150 -0
- package/core/meshBounds.cjs.js +1 -0
- package/core/meshBounds.d.ts +2 -0
- package/core/meshBounds.js +28 -0
- package/core/shaderMaterial.cjs.js +1 -0
- package/core/shaderMaterial.d.ts +9 -0
- package/core/shaderMaterial.js +29 -0
- package/core/shapes.cjs.js +1 -0
- package/core/shapes.d.ts +26 -0
- package/core/shapes.js +65 -0
- package/core/softShadows.cjs.js +1 -0
- package/core/softShadows.d.ts +6 -0
- package/core/softShadows.js +158 -0
- package/core/useAnimations.cjs.js +1 -0
- package/core/useAnimations.d.ts +13 -0
- package/core/useAnimations.js +52 -0
- package/core/useAspect.cjs.js +1 -0
- package/core/useAspect.d.ts +1 -0
- package/core/useAspect.js +10 -0
- package/core/useBoxProjectedEnv.cjs.js +1 -0
- package/core/useBoxProjectedEnv.d.ts +19 -0
- package/core/useBoxProjectedEnv.js +95 -0
- package/core/useCamera.cjs.js +1 -0
- package/core/useCamera.d.ts +3 -0
- package/core/useCamera.js +19 -0
- package/core/useContextBridge.cjs.js +1 -0
- package/core/useContextBridge.d.ts +4 -0
- package/core/useContextBridge.js +20 -0
- package/core/useDepthBuffer.cjs.js +1 -0
- package/core/useDepthBuffer.d.ts +6 -0
- package/core/useDepthBuffer.js +38 -0
- package/core/useEnvironment.cjs.js +1 -0
- package/core/useEnvironment.d.ts +17 -0
- package/core/useEnvironment.js +150 -0
- package/core/useFont.cjs.js +1 -0
- package/core/useFont.d.ts +24 -0
- package/core/useFont.js +24 -0
- package/core/useIntersect.cjs.js +1 -0
- package/core/useIntersect.d.ts +3 -0
- package/core/useIntersect.js +36 -0
- package/core/useSpriteLoader.cjs.js +1 -0
- package/core/useSpriteLoader.d.ts +57 -0
- package/core/useSpriteLoader.js +402 -0
- package/helpers/constants.cjs.js +1 -0
- package/helpers/constants.d.ts +1 -0
- package/helpers/constants.js +6 -0
- package/helpers/deprecated.cjs.js +1 -0
- package/helpers/deprecated.d.ts +5 -0
- package/helpers/deprecated.js +8 -0
- package/helpers/environment-assets.cjs.js +1 -0
- package/helpers/environment-assets.d.ts +13 -0
- package/helpers/environment-assets.js +14 -0
- package/helpers/glsl/DefaultSpotlightShadowShadows.glsl.js +3 -0
- package/helpers/glsl/distort.vert.glsl.js +3 -0
- package/helpers/ts-utils.cjs.js +1 -0
- package/helpers/ts-utils.d.ts +7 -0
- package/helpers/ts-utils.js +1 -0
- package/helpers/useEffectfulState.cjs.js +1 -0
- package/helpers/useEffectfulState.d.ts +4 -0
- package/helpers/useEffectfulState.js +17 -0
- package/index.cjs.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +139 -0
- package/materials/BlurPass.cjs.js +1 -0
- package/materials/BlurPass.d.ts +23 -0
- package/materials/BlurPass.js +72 -0
- package/materials/ConvolutionMaterial.cjs.js +1 -0
- package/materials/ConvolutionMaterial.d.ts +7 -0
- package/materials/ConvolutionMaterial.js +97 -0
- package/materials/DiscardMaterial.cjs.js +1 -0
- package/materials/DiscardMaterial.d.ts +3 -0
- package/materials/DiscardMaterial.js +5 -0
- package/materials/MeshReflectorMaterial.cjs.js +1 -0
- package/materials/MeshReflectorMaterial.d.ts +50 -0
- package/materials/MeshReflectorMaterial.js +256 -0
- package/materials/MeshRefractionMaterial.cjs.js +1 -0
- package/materials/MeshRefractionMaterial.d.ts +18 -0
- package/materials/MeshRefractionMaterial.js +163 -0
- package/materials/SpotLightMaterial.cjs.js +1 -0
- package/materials/SpotLightMaterial.d.ts +4 -0
- package/materials/SpotLightMaterial.js +115 -0
- package/materials/WireframeMaterial.cjs.js +1 -0
- package/materials/WireframeMaterial.d.ts +64 -0
- package/materials/WireframeMaterial.js +217 -0
- package/native/index.cjs.js +1 -0
- package/native/index.d.ts +1 -0
- package/native/index.js +150 -0
- package/native/package.json +5 -0
- package/package.json +83 -0
- package/web/CycleRaycast.cjs.js +1 -0
- package/web/CycleRaycast.d.ts +10 -0
- package/web/CycleRaycast.js +93 -0
- package/web/DragControls.cjs.js +1 -0
- package/web/DragControls.d.ts +17 -0
- package/web/DragControls.js +127 -0
- package/web/FaceControls.cjs.js +1 -0
- package/web/FaceControls.d.ts +29 -0
- package/web/FaceControls.js +236 -0
- package/web/FaceLandmarker.cjs.js +1 -0
- package/web/FaceLandmarker.d.ts +14 -0
- package/web/FaceLandmarker.js +49 -0
- package/web/Facemesh.cjs.js +1 -0
- package/web/Facemesh.d.ts +118 -0
- package/web/Facemesh.js +4538 -0
- package/web/Html.cjs.js +1 -0
- package/web/Html.d.ts +34 -0
- package/web/Html.js +375 -0
- package/web/KeyboardControls.cjs.js +1 -0
- package/web/KeyboardControls.d.ts +37 -0
- package/web/KeyboardControls.js +104 -0
- package/web/Loader.cjs.js +1 -0
- package/web/Loader.d.ts +12 -0
- package/web/Loader.js +101 -0
- package/web/PresentationControls.cjs.js +1 -0
- package/web/PresentationControls.d.ts +16 -0
- package/web/PresentationControls.js +79 -0
- package/web/ScreenVideoTexture.cjs.js +1 -0
- package/web/ScreenVideoTexture.d.ts +17 -0
- package/web/ScreenVideoTexture.js +30 -0
- package/web/ScrollControls.cjs.js +1 -0
- package/web/ScrollControls.d.ts +45 -0
- package/web/ScrollControls.js +237 -0
- package/web/Select.cjs.js +1 -0
- package/web/Select.d.ts +14 -0
- package/web/Select.js +171 -0
- package/web/View.cjs.js +1 -0
- package/web/View.d.ts +34 -0
- package/web/View.js +259 -0
- package/web/WebcamVideoTexture.cjs.js +1 -0
- package/web/WebcamVideoTexture.d.ts +17 -0
- package/web/WebcamVideoTexture.js +33 -0
- package/web/index.cjs.js +1 -0
- package/web/index.d.ts +17 -0
- package/web/index.js +176 -0
- package/web/pivotControls/AxisArrow.cjs.js +1 -0
- package/web/pivotControls/AxisArrow.d.ts +7 -0
- package/web/pivotControls/AxisArrow.js +193 -0
- package/web/pivotControls/AxisRotator.cjs.js +1 -0
- package/web/pivotControls/AxisRotator.d.ts +7 -0
- package/web/pivotControls/AxisRotator.js +220 -0
- package/web/pivotControls/PlaneSlider.cjs.js +1 -0
- package/web/pivotControls/PlaneSlider.d.ts +7 -0
- package/web/pivotControls/PlaneSlider.js +202 -0
- package/web/pivotControls/ScalingSphere.cjs.js +1 -0
- package/web/pivotControls/ScalingSphere.d.ts +7 -0
- package/web/pivotControls/ScalingSphere.js +192 -0
- package/web/pivotControls/context.cjs.js +1 -0
- package/web/pivotControls/context.d.ts +33 -0
- package/web/pivotControls/context.js +5 -0
- package/web/pivotControls/index.cjs.js +1 -0
- package/web/pivotControls/index.d.ts +39 -0
- package/web/pivotControls/index.js +213 -0
- package/web/useCursor.cjs.js +1 -0
- package/web/useCursor.d.ts +1 -0
- package/web/useCursor.js +12 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
import { useThree } from '@react-three/fiber';
|
|
5
|
+
import { useGesture } from '@use-gesture/react';
|
|
6
|
+
|
|
7
|
+
const initialModelPosition = /* @__PURE__ */new THREE.Vector3();
|
|
8
|
+
const mousePosition2D = /* @__PURE__ */new THREE.Vector2();
|
|
9
|
+
const mousePosition3D = /* @__PURE__ */new THREE.Vector3();
|
|
10
|
+
const dragOffset = /* @__PURE__ */new THREE.Vector3();
|
|
11
|
+
const dragPlaneNormal = /* @__PURE__ */new THREE.Vector3();
|
|
12
|
+
const dragPlane = /* @__PURE__ */new THREE.Plane();
|
|
13
|
+
const DragControls = /*#__PURE__*/React.forwardRef(({
|
|
14
|
+
autoTransform = true,
|
|
15
|
+
matrix,
|
|
16
|
+
axisLock,
|
|
17
|
+
dragLimits,
|
|
18
|
+
onHover,
|
|
19
|
+
onDragStart,
|
|
20
|
+
onDrag,
|
|
21
|
+
onDragEnd,
|
|
22
|
+
children,
|
|
23
|
+
dragConfig,
|
|
24
|
+
...props
|
|
25
|
+
}, fRef) => {
|
|
26
|
+
const defaultControls = useThree(state => state.controls);
|
|
27
|
+
const {
|
|
28
|
+
camera,
|
|
29
|
+
size,
|
|
30
|
+
raycaster,
|
|
31
|
+
invalidate
|
|
32
|
+
} = useThree();
|
|
33
|
+
const ref = React.useRef(null);
|
|
34
|
+
const bind = useGesture({
|
|
35
|
+
onHover: ({
|
|
36
|
+
hovering
|
|
37
|
+
}) => onHover && onHover(hovering !== null && hovering !== void 0 ? hovering : false),
|
|
38
|
+
onDragStart: ({
|
|
39
|
+
event
|
|
40
|
+
}) => {
|
|
41
|
+
if (defaultControls) defaultControls.enabled = false;
|
|
42
|
+
const {
|
|
43
|
+
point
|
|
44
|
+
} = event;
|
|
45
|
+
ref.current.matrix.decompose(initialModelPosition, new THREE.Quaternion(), new THREE.Vector3());
|
|
46
|
+
mousePosition3D.copy(point);
|
|
47
|
+
dragOffset.copy(mousePosition3D).sub(initialModelPosition);
|
|
48
|
+
onDragStart && onDragStart(initialModelPosition);
|
|
49
|
+
invalidate();
|
|
50
|
+
},
|
|
51
|
+
onDrag: ({
|
|
52
|
+
xy: [dragX, dragY],
|
|
53
|
+
intentional
|
|
54
|
+
}) => {
|
|
55
|
+
if (!intentional) return;
|
|
56
|
+
const normalizedMouseX = (dragX - size.left) / size.width * 2 - 1;
|
|
57
|
+
const normalizedMouseY = -((dragY - size.top) / size.height) * 2 + 1;
|
|
58
|
+
mousePosition2D.set(normalizedMouseX, normalizedMouseY);
|
|
59
|
+
raycaster.setFromCamera(mousePosition2D, camera);
|
|
60
|
+
if (!axisLock) {
|
|
61
|
+
camera.getWorldDirection(dragPlaneNormal).negate();
|
|
62
|
+
} else {
|
|
63
|
+
switch (axisLock) {
|
|
64
|
+
case 'x':
|
|
65
|
+
dragPlaneNormal.set(1, 0, 0);
|
|
66
|
+
break;
|
|
67
|
+
case 'y':
|
|
68
|
+
dragPlaneNormal.set(0, 1, 0);
|
|
69
|
+
break;
|
|
70
|
+
case 'z':
|
|
71
|
+
dragPlaneNormal.set(0, 0, 1);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
dragPlane.setFromNormalAndCoplanarPoint(dragPlaneNormal, mousePosition3D);
|
|
76
|
+
raycaster.ray.intersectPlane(dragPlane, mousePosition3D);
|
|
77
|
+
const previousLocalMatrix = ref.current.matrix.clone();
|
|
78
|
+
const previousWorldMatrix = ref.current.matrixWorld.clone();
|
|
79
|
+
const intendedNewPosition = new THREE.Vector3(mousePosition3D.x - dragOffset.x, mousePosition3D.y - dragOffset.y, mousePosition3D.z - dragOffset.z);
|
|
80
|
+
if (dragLimits) {
|
|
81
|
+
intendedNewPosition.x = dragLimits[0] ? Math.max(Math.min(intendedNewPosition.x, dragLimits[0][1]), dragLimits[0][0]) : intendedNewPosition.x;
|
|
82
|
+
intendedNewPosition.y = dragLimits[1] ? Math.max(Math.min(intendedNewPosition.y, dragLimits[1][1]), dragLimits[1][0]) : intendedNewPosition.y;
|
|
83
|
+
intendedNewPosition.z = dragLimits[2] ? Math.max(Math.min(intendedNewPosition.z, dragLimits[2][1]), dragLimits[2][0]) : intendedNewPosition.z;
|
|
84
|
+
}
|
|
85
|
+
if (autoTransform) {
|
|
86
|
+
ref.current.matrix.setPosition(intendedNewPosition);
|
|
87
|
+
const deltaLocalMatrix = ref.current.matrix.clone().multiply(previousLocalMatrix.invert());
|
|
88
|
+
const deltaWorldMatrix = ref.current.matrix.clone().multiply(previousWorldMatrix.invert());
|
|
89
|
+
onDrag && onDrag(ref.current.matrix, deltaLocalMatrix, ref.current.matrixWorld, deltaWorldMatrix);
|
|
90
|
+
} else {
|
|
91
|
+
const tempMatrix = new THREE.Matrix4().copy(ref.current.matrix);
|
|
92
|
+
tempMatrix.setPosition(intendedNewPosition);
|
|
93
|
+
const deltaLocalMatrix = tempMatrix.clone().multiply(previousLocalMatrix.invert());
|
|
94
|
+
const deltaWorldMatrix = tempMatrix.clone().multiply(previousWorldMatrix.invert());
|
|
95
|
+
onDrag && onDrag(tempMatrix, deltaLocalMatrix, ref.current.matrixWorld, deltaWorldMatrix);
|
|
96
|
+
}
|
|
97
|
+
invalidate();
|
|
98
|
+
},
|
|
99
|
+
onDragEnd: () => {
|
|
100
|
+
if (defaultControls) defaultControls.enabled = true;
|
|
101
|
+
onDragEnd && onDragEnd();
|
|
102
|
+
invalidate();
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
drag: {
|
|
106
|
+
filterTaps: true,
|
|
107
|
+
threshold: 1,
|
|
108
|
+
...(typeof dragConfig === 'object' ? dragConfig : {})
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
React.useImperativeHandle(fRef, () => ref.current, []);
|
|
112
|
+
React.useLayoutEffect(() => {
|
|
113
|
+
if (!matrix) return;
|
|
114
|
+
|
|
115
|
+
// If the matrix is a real matrix4 it means that the user wants to control the gizmo
|
|
116
|
+
// In that case it should just be set, as a bare prop update would merely copy it
|
|
117
|
+
ref.current.matrix = matrix;
|
|
118
|
+
}, [matrix]);
|
|
119
|
+
return /*#__PURE__*/React.createElement("group", _extends({
|
|
120
|
+
ref: ref
|
|
121
|
+
}, bind(), {
|
|
122
|
+
matrix: matrix,
|
|
123
|
+
matrixAutoUpdate: false
|
|
124
|
+
}, props), children);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
export { DragControls };
|
|
@@ -0,0 +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("../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);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { RefObject } from 'react';
|
|
4
|
+
import type { FaceLandmarkerResult } from '@mediapipe/tasks-vision';
|
|
5
|
+
import { VideoTextureProps } from '../core/VideoTexture';
|
|
6
|
+
import { FacemeshApi, FacemeshProps } from './Facemesh';
|
|
7
|
+
export type FaceControlsProps = {
|
|
8
|
+
camera?: THREE.Camera;
|
|
9
|
+
videoTexture?: VideoTextureProps;
|
|
10
|
+
manualDetect?: boolean;
|
|
11
|
+
faceLandmarkerResult?: FaceLandmarkerResult;
|
|
12
|
+
manualUpdate?: boolean;
|
|
13
|
+
makeDefault?: boolean;
|
|
14
|
+
smoothTime?: number;
|
|
15
|
+
offset?: boolean;
|
|
16
|
+
offsetScalar?: number;
|
|
17
|
+
eyes?: boolean;
|
|
18
|
+
eyesAsOrigin?: boolean;
|
|
19
|
+
depth?: number;
|
|
20
|
+
debug?: boolean;
|
|
21
|
+
facemesh?: FacemeshProps;
|
|
22
|
+
};
|
|
23
|
+
export type FaceControlsApi = THREE.EventDispatcher & {
|
|
24
|
+
computeTarget: () => THREE.Object3D;
|
|
25
|
+
update: (delta: number, target?: THREE.Object3D) => void;
|
|
26
|
+
facemeshApiRef: RefObject<FacemeshApi>;
|
|
27
|
+
};
|
|
28
|
+
export declare const FaceControls: React.ForwardRefExoticComponent<FaceControlsProps & React.RefAttributes<FaceControlsApi>>;
|
|
29
|
+
export declare const useFaceControls: () => FaceControlsApi;
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { forwardRef, useRef, useState, useCallback, useMemo, useImperativeHandle, useEffect, Suspense, useContext, createContext } from 'react';
|
|
5
|
+
import { useThree, useFrame } from '@react-three/fiber';
|
|
6
|
+
import { easing } from 'maath';
|
|
7
|
+
import { VideoTexture } from '../core/VideoTexture.js';
|
|
8
|
+
import { WebcamVideoTexture } from './WebcamVideoTexture.js';
|
|
9
|
+
import { Facemesh } from './Facemesh.js';
|
|
10
|
+
import { useFaceLandmarker } from './FaceLandmarker.js';
|
|
11
|
+
|
|
12
|
+
function mean(v1, v2) {
|
|
13
|
+
return v1.clone().add(v2).multiplyScalar(0.5);
|
|
14
|
+
}
|
|
15
|
+
function localToLocal(objSrc, v, objDst) {
|
|
16
|
+
// see: https://discourse.threejs.org/t/object3d-localtolocal/51564
|
|
17
|
+
const v_world = objSrc.localToWorld(v);
|
|
18
|
+
return objDst.worldToLocal(v_world);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//
|
|
22
|
+
//
|
|
23
|
+
//
|
|
24
|
+
|
|
25
|
+
const FaceControlsContext = /* @__PURE__ */createContext({});
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The camera follows your face.
|
|
29
|
+
*
|
|
30
|
+
* Pre-requisite: wrap into a `FaceLandmarker` provider:
|
|
31
|
+
*
|
|
32
|
+
* ```jsx
|
|
33
|
+
* <FaceLandmarker>...</FaceLandmarker>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
const FaceControls = /* @__PURE__ */forwardRef(({
|
|
38
|
+
camera,
|
|
39
|
+
videoTexture = {
|
|
40
|
+
start: true
|
|
41
|
+
},
|
|
42
|
+
manualDetect = false,
|
|
43
|
+
faceLandmarkerResult,
|
|
44
|
+
manualUpdate = false,
|
|
45
|
+
makeDefault,
|
|
46
|
+
smoothTime = 0.25,
|
|
47
|
+
offset = true,
|
|
48
|
+
offsetScalar = 80,
|
|
49
|
+
eyes = false,
|
|
50
|
+
eyesAsOrigin = true,
|
|
51
|
+
depth = 0.15,
|
|
52
|
+
debug = false,
|
|
53
|
+
facemesh
|
|
54
|
+
}, fref) => {
|
|
55
|
+
var _result$facialTransfo, _result$faceBlendshap;
|
|
56
|
+
const scene = useThree(state => state.scene);
|
|
57
|
+
const defaultCamera = useThree(state => state.camera);
|
|
58
|
+
const set = useThree(state => state.set);
|
|
59
|
+
const get = useThree(state => state.get);
|
|
60
|
+
const explCamera = camera || defaultCamera;
|
|
61
|
+
const facemeshApiRef = useRef(null);
|
|
62
|
+
|
|
63
|
+
//
|
|
64
|
+
// computeTarget()
|
|
65
|
+
//
|
|
66
|
+
// Compute `target` position and rotation for the camera (according to <Facemesh>)
|
|
67
|
+
//
|
|
68
|
+
// 1. 👀 either following the 2 eyes
|
|
69
|
+
// 2. 👤 or just the head mesh
|
|
70
|
+
//
|
|
71
|
+
|
|
72
|
+
const [target] = useState(() => new THREE.Object3D());
|
|
73
|
+
const [irisRightDirPos] = useState(() => new THREE.Vector3());
|
|
74
|
+
const [irisLeftDirPos] = useState(() => new THREE.Vector3());
|
|
75
|
+
const [irisRightLookAt] = useState(() => new THREE.Vector3());
|
|
76
|
+
const [irisLeftLookAt] = useState(() => new THREE.Vector3());
|
|
77
|
+
const computeTarget = useCallback(() => {
|
|
78
|
+
// same parent as the camera
|
|
79
|
+
target.parent = explCamera.parent;
|
|
80
|
+
const facemeshApi = facemeshApiRef.current;
|
|
81
|
+
if (facemeshApi) {
|
|
82
|
+
const {
|
|
83
|
+
outerRef,
|
|
84
|
+
eyeRightRef,
|
|
85
|
+
eyeLeftRef
|
|
86
|
+
} = facemeshApi;
|
|
87
|
+
if (eyeRightRef.current && eyeLeftRef.current) {
|
|
88
|
+
// 1. 👀
|
|
89
|
+
|
|
90
|
+
const {
|
|
91
|
+
irisDirRef: irisRightDirRef
|
|
92
|
+
} = eyeRightRef.current;
|
|
93
|
+
const {
|
|
94
|
+
irisDirRef: irisLeftDirRef
|
|
95
|
+
} = eyeLeftRef.current;
|
|
96
|
+
if (irisRightDirRef.current && irisLeftDirRef.current && outerRef.current) {
|
|
97
|
+
//
|
|
98
|
+
// position: mean of irisRightDirPos,irisLeftDirPos
|
|
99
|
+
//
|
|
100
|
+
irisRightDirPos.copy(localToLocal(irisRightDirRef.current, new THREE.Vector3(0, 0, 0), outerRef.current));
|
|
101
|
+
irisLeftDirPos.copy(localToLocal(irisLeftDirRef.current, new THREE.Vector3(0, 0, 0), outerRef.current));
|
|
102
|
+
target.position.copy(localToLocal(outerRef.current, mean(irisRightDirPos, irisLeftDirPos), explCamera.parent || scene));
|
|
103
|
+
|
|
104
|
+
//
|
|
105
|
+
// lookAt: mean of irisRightLookAt,irisLeftLookAt
|
|
106
|
+
//
|
|
107
|
+
irisRightLookAt.copy(localToLocal(irisRightDirRef.current, new THREE.Vector3(0, 0, 1), outerRef.current));
|
|
108
|
+
irisLeftLookAt.copy(localToLocal(irisLeftDirRef.current, new THREE.Vector3(0, 0, 1), outerRef.current));
|
|
109
|
+
target.lookAt(outerRef.current.localToWorld(mean(irisRightLookAt, irisLeftLookAt)));
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
// 2. 👤
|
|
113
|
+
|
|
114
|
+
if (outerRef.current) {
|
|
115
|
+
target.position.copy(localToLocal(outerRef.current, new THREE.Vector3(0, 0, 0), explCamera.parent || scene));
|
|
116
|
+
target.lookAt(outerRef.current.localToWorld(new THREE.Vector3(0, 0, 1)));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return target;
|
|
121
|
+
}, [explCamera, irisLeftDirPos, irisLeftLookAt, irisRightDirPos, irisRightLookAt, scene, target]);
|
|
122
|
+
|
|
123
|
+
//
|
|
124
|
+
// update()
|
|
125
|
+
//
|
|
126
|
+
// Updating the camera `current` position and rotation, following `target`
|
|
127
|
+
//
|
|
128
|
+
|
|
129
|
+
const [current] = useState(() => new THREE.Object3D());
|
|
130
|
+
const update = useCallback(function (delta, target) {
|
|
131
|
+
if (explCamera) {
|
|
132
|
+
var _target;
|
|
133
|
+
(_target = target) !== null && _target !== void 0 ? _target : target = computeTarget();
|
|
134
|
+
if (smoothTime > 0) {
|
|
135
|
+
// damping current
|
|
136
|
+
const eps = 1e-9;
|
|
137
|
+
easing.damp3(current.position, target.position, smoothTime, delta, undefined, undefined, eps);
|
|
138
|
+
easing.dampE(current.rotation, target.rotation, smoothTime, delta, undefined, undefined, eps);
|
|
139
|
+
} else {
|
|
140
|
+
// instant
|
|
141
|
+
current.position.copy(target.position);
|
|
142
|
+
current.rotation.copy(target.rotation);
|
|
143
|
+
}
|
|
144
|
+
explCamera.position.copy(current.position);
|
|
145
|
+
explCamera.rotation.copy(current.rotation);
|
|
146
|
+
}
|
|
147
|
+
}, [explCamera, computeTarget, smoothTime, current.position, current.rotation]);
|
|
148
|
+
useFrame((_, delta) => {
|
|
149
|
+
if (manualUpdate) return;
|
|
150
|
+
update(delta);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
//
|
|
154
|
+
// onVideoFrame (only used if !manualDetect)
|
|
155
|
+
//
|
|
156
|
+
|
|
157
|
+
const videoTextureRef = useRef(null);
|
|
158
|
+
const [_faceLandmarkerResult, setFaceLandmarkerResult] = useState();
|
|
159
|
+
const faceLandmarker = useFaceLandmarker();
|
|
160
|
+
const onVideoFrame = useCallback((now, metadata) => {
|
|
161
|
+
const texture = videoTextureRef.current;
|
|
162
|
+
if (!texture) return;
|
|
163
|
+
const videoFrame = texture.source.data;
|
|
164
|
+
const result = faceLandmarker == null ? void 0 : faceLandmarker.detectForVideo(videoFrame, now);
|
|
165
|
+
setFaceLandmarkerResult(result);
|
|
166
|
+
}, [faceLandmarker]);
|
|
167
|
+
|
|
168
|
+
//
|
|
169
|
+
// Ref API
|
|
170
|
+
//
|
|
171
|
+
|
|
172
|
+
const api = useMemo(() => Object.assign(Object.create(THREE.EventDispatcher.prototype), {
|
|
173
|
+
computeTarget,
|
|
174
|
+
update,
|
|
175
|
+
facemeshApiRef
|
|
176
|
+
}), [computeTarget, update]);
|
|
177
|
+
useImperativeHandle(fref, () => api, [api]);
|
|
178
|
+
|
|
179
|
+
//
|
|
180
|
+
// makeDefault (`controls` global state)
|
|
181
|
+
//
|
|
182
|
+
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
if (makeDefault) {
|
|
185
|
+
const old = get().controls;
|
|
186
|
+
set({
|
|
187
|
+
controls: api
|
|
188
|
+
});
|
|
189
|
+
return () => set({
|
|
190
|
+
controls: old
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}, [makeDefault, api, get, set]);
|
|
194
|
+
|
|
195
|
+
//
|
|
196
|
+
//
|
|
197
|
+
//
|
|
198
|
+
|
|
199
|
+
const result = faceLandmarkerResult !== null && faceLandmarkerResult !== void 0 ? faceLandmarkerResult : _faceLandmarkerResult;
|
|
200
|
+
const points = result == null ? void 0 : result.faceLandmarks[0];
|
|
201
|
+
const facialTransformationMatrix = result == null || (_result$facialTransfo = result.facialTransformationMatrixes) == null ? void 0 : _result$facialTransfo[0];
|
|
202
|
+
const faceBlendshapes = result == null || (_result$faceBlendshap = result.faceBlendshapes) == null ? void 0 : _result$faceBlendshap[0];
|
|
203
|
+
const videoTextureProps = {
|
|
204
|
+
onVideoFrame,
|
|
205
|
+
...videoTexture
|
|
206
|
+
};
|
|
207
|
+
return /*#__PURE__*/React.createElement(FaceControlsContext.Provider, {
|
|
208
|
+
value: api
|
|
209
|
+
}, !manualDetect && /*#__PURE__*/React.createElement(Suspense, {
|
|
210
|
+
fallback: null
|
|
211
|
+
}, 'src' in videoTextureProps ? /*#__PURE__*/React.createElement(VideoTexture, _extends({
|
|
212
|
+
ref: videoTextureRef
|
|
213
|
+
}, videoTextureProps)) : /*#__PURE__*/React.createElement(WebcamVideoTexture, _extends({
|
|
214
|
+
ref: videoTextureRef
|
|
215
|
+
}, videoTextureProps))), /*#__PURE__*/React.createElement(Facemesh, _extends({
|
|
216
|
+
ref: facemeshApiRef,
|
|
217
|
+
children: /*#__PURE__*/React.createElement("meshNormalMaterial", {
|
|
218
|
+
side: THREE.DoubleSide
|
|
219
|
+
})
|
|
220
|
+
}, facemesh, {
|
|
221
|
+
points: points,
|
|
222
|
+
depth: depth,
|
|
223
|
+
facialTransformationMatrix: facialTransformationMatrix,
|
|
224
|
+
faceBlendshapes: faceBlendshapes,
|
|
225
|
+
eyes: eyes,
|
|
226
|
+
eyesAsOrigin: eyesAsOrigin,
|
|
227
|
+
offset: offset,
|
|
228
|
+
offsetScalar: offsetScalar,
|
|
229
|
+
debug: debug,
|
|
230
|
+
"rotation-z": Math.PI,
|
|
231
|
+
visible: debug
|
|
232
|
+
})));
|
|
233
|
+
});
|
|
234
|
+
const useFaceControls = () => useContext(FaceControlsContext);
|
|
235
|
+
|
|
236
|
+
export { FaceControls, useFaceControls };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("suspend-react");function r(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 a=r(e);const s=e.createContext({}),n={basePath:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.17/wasm",options:{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task",delegate:"GPU"},runningMode:"VIDEO",outputFaceBlendshapes:!0,outputFacialTransformationMatrixes:!0}},o=e.forwardRef((({basePath:o=n.basePath,options:i=n.options,children:c},u)=>{const l=JSON.stringify(i),d=t.suspend((async()=>{const{FilesetResolver:e,FaceLandmarker:t}=await Promise.resolve().then((function(){return r(require("@mediapipe/tasks-vision"))})),a=await e.forVisionTasks(o);return t.createFromOptions(a,i)}),[o,l]);return e.useEffect((()=>()=>{null==d||d.close(),t.clear([o,l])}),[d,o,l]),e.useImperativeHandle(u,(()=>d),[d]),a.createElement(s.Provider,{value:d},c)}));exports.FaceLandmarker=o,exports.FaceLandmarkerDefaults=n,exports.useFaceLandmarker=function(){return e.useContext(s)};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import type { FaceLandmarker as FaceLandmarkerImpl, FaceLandmarkerOptions } from '@mediapipe/tasks-vision';
|
|
4
|
+
export type FaceLandmarkerProps = {
|
|
5
|
+
basePath?: string;
|
|
6
|
+
options?: FaceLandmarkerOptions;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export declare const FaceLandmarkerDefaults: {
|
|
10
|
+
basePath: string;
|
|
11
|
+
options: FaceLandmarkerOptions;
|
|
12
|
+
};
|
|
13
|
+
export declare const FaceLandmarker: React.ForwardRefExoticComponent<FaceLandmarkerProps & React.RefAttributes<FaceLandmarkerImpl>>;
|
|
14
|
+
export declare function useFaceLandmarker(): FaceLandmarkerImpl | undefined;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useContext, createContext } from 'react';
|
|
3
|
+
import { suspend, clear } from 'suspend-react';
|
|
4
|
+
|
|
5
|
+
/* eslint react-hooks/exhaustive-deps: 1 */
|
|
6
|
+
const FaceLandmarkerContext = /* @__PURE__ */createContext({});
|
|
7
|
+
const FaceLandmarkerDefaults = {
|
|
8
|
+
basePath: 'https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.17/wasm',
|
|
9
|
+
options: {
|
|
10
|
+
baseOptions: {
|
|
11
|
+
modelAssetPath: 'https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task',
|
|
12
|
+
delegate: 'GPU'
|
|
13
|
+
},
|
|
14
|
+
runningMode: 'VIDEO',
|
|
15
|
+
outputFaceBlendshapes: true,
|
|
16
|
+
outputFacialTransformationMatrixes: true
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const FaceLandmarker = /*#__PURE__*/forwardRef(({
|
|
20
|
+
basePath = FaceLandmarkerDefaults.basePath,
|
|
21
|
+
options = FaceLandmarkerDefaults.options,
|
|
22
|
+
children
|
|
23
|
+
}, fref) => {
|
|
24
|
+
const opts = JSON.stringify(options);
|
|
25
|
+
const faceLandmarker = suspend(async () => {
|
|
26
|
+
const {
|
|
27
|
+
FilesetResolver,
|
|
28
|
+
FaceLandmarker
|
|
29
|
+
} = await import('@mediapipe/tasks-vision');
|
|
30
|
+
const vision = await FilesetResolver.forVisionTasks(basePath);
|
|
31
|
+
return FaceLandmarker.createFromOptions(vision, options);
|
|
32
|
+
}, [basePath, opts]);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
return () => {
|
|
35
|
+
faceLandmarker == null || faceLandmarker.close();
|
|
36
|
+
clear([basePath, opts]);
|
|
37
|
+
};
|
|
38
|
+
}, [faceLandmarker, basePath, opts]);
|
|
39
|
+
useImperativeHandle(fref, () => faceLandmarker, [faceLandmarker]); // expose faceLandmarker through ref
|
|
40
|
+
|
|
41
|
+
return /*#__PURE__*/React.createElement(FaceLandmarkerContext.Provider, {
|
|
42
|
+
value: faceLandmarker
|
|
43
|
+
}, children);
|
|
44
|
+
});
|
|
45
|
+
function useFaceLandmarker() {
|
|
46
|
+
return useContext(FaceLandmarkerContext);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { FaceLandmarker, FaceLandmarkerDefaults, useFaceLandmarker };
|