@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,202 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import { useThree } from '@react-three/fiber';
|
|
4
|
+
import { Line } from '../../core/Line.js';
|
|
5
|
+
import { Html } from '../Html.js';
|
|
6
|
+
import { context } from './context.js';
|
|
7
|
+
|
|
8
|
+
const decomposeIntoBasis = (e1, e2, offset) => {
|
|
9
|
+
const i1 = Math.abs(e1.x) >= Math.abs(e1.y) && Math.abs(e1.x) >= Math.abs(e1.z) ? 0 : Math.abs(e1.y) >= Math.abs(e1.x) && Math.abs(e1.y) >= Math.abs(e1.z) ? 1 : 2;
|
|
10
|
+
const e2DegrowthOrder = [0, 1, 2].sort((a, b) => Math.abs(e2.getComponent(b)) - Math.abs(e2.getComponent(a)));
|
|
11
|
+
const i2 = i1 === e2DegrowthOrder[0] ? e2DegrowthOrder[1] : e2DegrowthOrder[0];
|
|
12
|
+
const a1 = e1.getComponent(i1);
|
|
13
|
+
const a2 = e1.getComponent(i2);
|
|
14
|
+
const b1 = e2.getComponent(i1);
|
|
15
|
+
const b2 = e2.getComponent(i2);
|
|
16
|
+
const c1 = offset.getComponent(i1);
|
|
17
|
+
const c2 = offset.getComponent(i2);
|
|
18
|
+
const y = (c2 - c1 * (a2 / a1)) / (b2 - b1 * (a2 / a1));
|
|
19
|
+
const x = (c1 - y * b1) / a1;
|
|
20
|
+
return [x, y];
|
|
21
|
+
};
|
|
22
|
+
const ray = /* @__PURE__ */new THREE.Ray();
|
|
23
|
+
const intersection = /* @__PURE__ */new THREE.Vector3();
|
|
24
|
+
const offsetMatrix = /* @__PURE__ */new THREE.Matrix4();
|
|
25
|
+
const PlaneSlider = ({
|
|
26
|
+
dir1,
|
|
27
|
+
dir2,
|
|
28
|
+
axis
|
|
29
|
+
}) => {
|
|
30
|
+
const {
|
|
31
|
+
translation,
|
|
32
|
+
translationLimits,
|
|
33
|
+
annotations,
|
|
34
|
+
annotationsClass,
|
|
35
|
+
depthTest,
|
|
36
|
+
scale,
|
|
37
|
+
lineWidth,
|
|
38
|
+
fixed,
|
|
39
|
+
axisColors,
|
|
40
|
+
hoveredColor,
|
|
41
|
+
opacity,
|
|
42
|
+
renderOrder,
|
|
43
|
+
onDragStart,
|
|
44
|
+
onDrag,
|
|
45
|
+
onDragEnd,
|
|
46
|
+
userData
|
|
47
|
+
} = React.useContext(context);
|
|
48
|
+
const camControls = useThree(state => state.controls);
|
|
49
|
+
const divRef = React.useRef(null);
|
|
50
|
+
const objRef = React.useRef(null);
|
|
51
|
+
const clickInfo = React.useRef(null);
|
|
52
|
+
const offsetX0 = React.useRef(0);
|
|
53
|
+
const offsetY0 = React.useRef(0);
|
|
54
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
55
|
+
const onPointerDown = React.useCallback(e => {
|
|
56
|
+
if (annotations) {
|
|
57
|
+
divRef.current.innerText = `${translation.current[(axis + 1) % 3].toFixed(2)}, ${translation.current[(axis + 2) % 3].toFixed(2)}`;
|
|
58
|
+
divRef.current.style.display = 'block';
|
|
59
|
+
}
|
|
60
|
+
e.stopPropagation();
|
|
61
|
+
const clickPoint = e.point.clone();
|
|
62
|
+
const origin = new THREE.Vector3().setFromMatrixPosition(objRef.current.matrixWorld);
|
|
63
|
+
const e1 = new THREE.Vector3().setFromMatrixColumn(objRef.current.matrixWorld, 0).normalize();
|
|
64
|
+
const e2 = new THREE.Vector3().setFromMatrixColumn(objRef.current.matrixWorld, 1).normalize();
|
|
65
|
+
const normal = new THREE.Vector3().setFromMatrixColumn(objRef.current.matrixWorld, 2).normalize();
|
|
66
|
+
const plane = new THREE.Plane().setFromNormalAndCoplanarPoint(normal, origin);
|
|
67
|
+
clickInfo.current = {
|
|
68
|
+
clickPoint,
|
|
69
|
+
e1,
|
|
70
|
+
e2,
|
|
71
|
+
plane
|
|
72
|
+
};
|
|
73
|
+
offsetX0.current = translation.current[(axis + 1) % 3];
|
|
74
|
+
offsetY0.current = translation.current[(axis + 2) % 3];
|
|
75
|
+
onDragStart({
|
|
76
|
+
component: 'Slider',
|
|
77
|
+
axis,
|
|
78
|
+
origin,
|
|
79
|
+
directions: [e1, e2, normal]
|
|
80
|
+
});
|
|
81
|
+
camControls && (camControls.enabled = false);
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
e.target.setPointerCapture(e.pointerId);
|
|
84
|
+
}, [annotations, camControls, onDragStart, axis]);
|
|
85
|
+
const onPointerMove = React.useCallback(e => {
|
|
86
|
+
e.stopPropagation();
|
|
87
|
+
if (!isHovered) setIsHovered(true);
|
|
88
|
+
if (clickInfo.current) {
|
|
89
|
+
const {
|
|
90
|
+
clickPoint,
|
|
91
|
+
e1,
|
|
92
|
+
e2,
|
|
93
|
+
plane
|
|
94
|
+
} = clickInfo.current;
|
|
95
|
+
const [minX, maxX] = (translationLimits == null ? void 0 : translationLimits[(axis + 1) % 3]) || [undefined, undefined];
|
|
96
|
+
const [minY, maxY] = (translationLimits == null ? void 0 : translationLimits[(axis + 2) % 3]) || [undefined, undefined];
|
|
97
|
+
ray.copy(e.ray);
|
|
98
|
+
ray.intersectPlane(plane, intersection);
|
|
99
|
+
ray.direction.negate();
|
|
100
|
+
ray.intersectPlane(plane, intersection);
|
|
101
|
+
intersection.sub(clickPoint);
|
|
102
|
+
let [offsetX, offsetY] = decomposeIntoBasis(e1, e2, intersection);
|
|
103
|
+
/* let offsetY = (intersection.y - (intersection.x * e1.y) / e1.x) / (e2.y - (e2.x * e1.y) / e1.x)
|
|
104
|
+
let offsetX = (intersection.x - offsetY * e2.x) / e1.x */
|
|
105
|
+
if (minX !== undefined) {
|
|
106
|
+
offsetX = Math.max(offsetX, minX - offsetX0.current);
|
|
107
|
+
}
|
|
108
|
+
if (maxX !== undefined) {
|
|
109
|
+
offsetX = Math.min(offsetX, maxX - offsetX0.current);
|
|
110
|
+
}
|
|
111
|
+
if (minY !== undefined) {
|
|
112
|
+
offsetY = Math.max(offsetY, minY - offsetY0.current);
|
|
113
|
+
}
|
|
114
|
+
if (maxY !== undefined) {
|
|
115
|
+
offsetY = Math.min(offsetY, maxY - offsetY0.current);
|
|
116
|
+
}
|
|
117
|
+
translation.current[(axis + 1) % 3] = offsetX0.current + offsetX;
|
|
118
|
+
translation.current[(axis + 2) % 3] = offsetY0.current + offsetY;
|
|
119
|
+
if (annotations) {
|
|
120
|
+
divRef.current.innerText = `${translation.current[(axis + 1) % 3].toFixed(2)}, ${translation.current[(axis + 2) % 3].toFixed(2)}`;
|
|
121
|
+
}
|
|
122
|
+
offsetMatrix.makeTranslation(offsetX * e1.x + offsetY * e2.x, offsetX * e1.y + offsetY * e2.y, offsetX * e1.z + offsetY * e2.z);
|
|
123
|
+
onDrag(offsetMatrix);
|
|
124
|
+
}
|
|
125
|
+
}, [annotations, onDrag, isHovered, translation, translationLimits, axis]);
|
|
126
|
+
const onPointerUp = React.useCallback(e => {
|
|
127
|
+
if (annotations) {
|
|
128
|
+
divRef.current.style.display = 'none';
|
|
129
|
+
}
|
|
130
|
+
e.stopPropagation();
|
|
131
|
+
clickInfo.current = null;
|
|
132
|
+
onDragEnd();
|
|
133
|
+
camControls && (camControls.enabled = true);
|
|
134
|
+
// @ts-ignore
|
|
135
|
+
e.target.releasePointerCapture(e.pointerId);
|
|
136
|
+
}, [annotations, camControls, onDragEnd]);
|
|
137
|
+
const onPointerOut = React.useCallback(e => {
|
|
138
|
+
e.stopPropagation();
|
|
139
|
+
setIsHovered(false);
|
|
140
|
+
}, []);
|
|
141
|
+
const matrixL = React.useMemo(() => {
|
|
142
|
+
const dir1N = dir1.clone().normalize();
|
|
143
|
+
const dir2N = dir2.clone().normalize();
|
|
144
|
+
return new THREE.Matrix4().makeBasis(dir1N, dir2N, dir1N.clone().cross(dir2N));
|
|
145
|
+
}, [dir1, dir2]);
|
|
146
|
+
const pos1 = fixed ? 1 / 7 : scale / 7;
|
|
147
|
+
const length = fixed ? 0.225 : scale * 0.225;
|
|
148
|
+
const color = isHovered ? hoveredColor : axisColors[axis];
|
|
149
|
+
const points = React.useMemo(() => [new THREE.Vector3(0, 0, 0), new THREE.Vector3(0, length, 0), new THREE.Vector3(length, length, 0), new THREE.Vector3(length, 0, 0), new THREE.Vector3(0, 0, 0)], [length]);
|
|
150
|
+
return /*#__PURE__*/React.createElement("group", {
|
|
151
|
+
ref: objRef,
|
|
152
|
+
matrix: matrixL,
|
|
153
|
+
matrixAutoUpdate: false
|
|
154
|
+
}, annotations && /*#__PURE__*/React.createElement(Html, {
|
|
155
|
+
position: [0, 0, 0]
|
|
156
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
157
|
+
style: {
|
|
158
|
+
display: 'none',
|
|
159
|
+
background: '#151520',
|
|
160
|
+
color: 'white',
|
|
161
|
+
padding: '6px 8px',
|
|
162
|
+
borderRadius: 7,
|
|
163
|
+
whiteSpace: 'nowrap'
|
|
164
|
+
},
|
|
165
|
+
className: annotationsClass,
|
|
166
|
+
ref: divRef
|
|
167
|
+
})), /*#__PURE__*/React.createElement("group", {
|
|
168
|
+
position: [pos1 * 1.7, pos1 * 1.7, 0]
|
|
169
|
+
}, /*#__PURE__*/React.createElement("mesh", {
|
|
170
|
+
visible: true,
|
|
171
|
+
onPointerDown: onPointerDown,
|
|
172
|
+
onPointerMove: onPointerMove,
|
|
173
|
+
onPointerUp: onPointerUp,
|
|
174
|
+
onPointerOut: onPointerOut,
|
|
175
|
+
scale: length,
|
|
176
|
+
userData: userData,
|
|
177
|
+
renderOrder: renderOrder
|
|
178
|
+
}, /*#__PURE__*/React.createElement("planeGeometry", null), /*#__PURE__*/React.createElement("meshBasicMaterial", {
|
|
179
|
+
transparent: true,
|
|
180
|
+
depthTest: depthTest,
|
|
181
|
+
color: color,
|
|
182
|
+
polygonOffset: true,
|
|
183
|
+
polygonOffsetFactor: -10,
|
|
184
|
+
side: THREE.DoubleSide,
|
|
185
|
+
fog: false
|
|
186
|
+
})), /*#__PURE__*/React.createElement(Line, {
|
|
187
|
+
position: [-length / 2, -length / 2, 0],
|
|
188
|
+
transparent: true,
|
|
189
|
+
depthTest: depthTest,
|
|
190
|
+
points: points,
|
|
191
|
+
lineWidth: lineWidth,
|
|
192
|
+
color: color,
|
|
193
|
+
opacity: opacity,
|
|
194
|
+
polygonOffset: true,
|
|
195
|
+
polygonOffsetFactor: -10,
|
|
196
|
+
userData: userData,
|
|
197
|
+
fog: false,
|
|
198
|
+
renderOrder: renderOrder
|
|
199
|
+
})));
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export { PlaneSlider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("three"),r=require("@react-three/fiber"),n=require("../Html.cjs.js"),o=require("./context.cjs.js"),a=require("../../core/calculateScaleFactor.cjs.js");function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}require("@babel/runtime/helpers/extends"),require("react-dom/client");var c=i(e),l=i(t);const s=new l.Vector3,u=new l.Vector3,p=(e,t,r,n)=>{const o=t.dot(t),a=t.dot(e)-t.dot(r),i=t.dot(n);if(0===i)return-a/o;s.copy(n).multiplyScalar(o/i).sub(t),u.copy(n).multiplyScalar(a/i).add(r).sub(e);return-s.dot(u)/s.dot(s)},d=new l.Vector3(0,1,0),m=new l.Vector3,f=new l.Matrix4;exports.ScalingSphere=({direction:e,axis:t})=>{const{scaleLimits:i,annotations:u,annotationsClass:x,depthTest:y,scale:g,lineWidth:h,fixed:b,axisColors:P,hoveredColor:M,opacity:w,renderOrder:v,onDragStart:O,onDrag:j,onDragEnd:k,userData:C}=c.useContext(o.context),S=r.useThree((e=>e.size)),E=r.useThree((e=>e.controls)),R=c.useRef(null),q=c.useRef(null),F=c.useRef(null),D=c.useRef(1),L=c.useRef(1),T=c.useRef(null),[V,z]=c.useState(!1),G=b?1.2:1.2*g,W=c.useCallback((r=>{u&&(R.current.innerText=`${L.current.toFixed(2)}`,R.current.style.display="block"),r.stopPropagation();const n=(new l.Matrix4).extractRotation(q.current.matrixWorld),o=r.point.clone(),i=(new l.Vector3).setFromMatrixPosition(q.current.matrixWorld),c=e.clone().applyMatrix4(n).normalize(),p=q.current.matrixWorld.clone(),d=p.clone().invert(),m=b?1/a.calculateScaleFactor(q.current.getWorldPosition(s),g,r.camera,S):1;T.current={clickPoint:o,dir:c,mPLG:p,mPLGInv:d,offsetMultiplier:m},O({component:"Sphere",axis:t,origin:i,directions:[c]}),E&&(E.enabled=!1),r.target.setPointerCapture(r.pointerId)}),[u,E,e,O,t,b,g,S]),I=c.useCallback((e=>{if(e.stopPropagation(),V||z(!0),T.current){const{clickPoint:r,dir:n,mPLG:o,mPLGInv:a,offsetMultiplier:c}=T.current,[l,s]=(null==i?void 0:i[t])||[1e-5,void 0],d=p(r,n,e.ray.origin,e.ray.direction)*c,x=b?d:d/g;let y=Math.pow(2,.2*x);e.shiftKey&&(y=Math.round(10*y)/10),y=Math.max(y,l/D.current),void 0!==s&&(y=Math.min(y,s/D.current)),L.current=D.current*y,F.current.position.set(0,G+d,0),u&&(R.current.innerText=`${L.current.toFixed(2)}`),m.set(1,1,1),m.setComponent(t,y),f.makeScale(m.x,m.y,m.z).premultiply(o).multiply(a),j(f)}}),[u,G,j,V,i,t]),_=c.useCallback((e=>{u&&(R.current.style.display="none"),e.stopPropagation(),D.current=L.current,T.current=null,F.current.position.set(0,G,0),k(),E&&(E.enabled=!0),e.target.releasePointerCapture(e.pointerId)}),[u,E,k,G]),U=c.useCallback((e=>{e.stopPropagation(),z(!1)}),[]),{radius:H,matrixL:Q}=c.useMemo((()=>{const t=b?h/g*1.8:g/22.5,r=(new l.Quaternion).setFromUnitVectors(d,e.clone().normalize());return{radius:t,matrixL:(new l.Matrix4).makeRotationFromQuaternion(r)}}),[e,g,h,b]),$=V?M:P[t];return c.createElement("group",{ref:q},c.createElement("group",{matrix:Q,matrixAutoUpdate:!1,onPointerDown:W,onPointerMove:I,onPointerUp:_,onPointerOut:U},u&&c.createElement(n.Html,{position:[0,G/2,0]},c.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:x,ref:R})),c.createElement("mesh",{ref:F,position:[0,G,0],renderOrder:v,userData:C},c.createElement("sphereGeometry",{args:[H,12,12]}),c.createElement("meshBasicMaterial",{transparent:!0,depthTest:y,color:$,opacity:w,polygonOffset:!0,polygonOffsetFactor:-10}))))},exports.calculateOffset=p;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
export declare const calculateOffset: (clickPoint: THREE.Vector3, normal: THREE.Vector3, rayStart: THREE.Vector3, rayDir: THREE.Vector3) => number;
|
|
4
|
+
export declare const ScalingSphere: React.FC<{
|
|
5
|
+
direction: THREE.Vector3;
|
|
6
|
+
axis: 0 | 1 | 2;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import { useThree } from '@react-three/fiber';
|
|
4
|
+
import { Html } from '../Html.js';
|
|
5
|
+
import { context } from './context.js';
|
|
6
|
+
import { calculateScaleFactor } from '../../core/calculateScaleFactor.js';
|
|
7
|
+
|
|
8
|
+
const vec1 = /* @__PURE__ */new THREE.Vector3();
|
|
9
|
+
const vec2 = /* @__PURE__ */new THREE.Vector3();
|
|
10
|
+
const calculateOffset = (clickPoint, normal, rayStart, rayDir) => {
|
|
11
|
+
const e1 = normal.dot(normal);
|
|
12
|
+
const e2 = normal.dot(clickPoint) - normal.dot(rayStart);
|
|
13
|
+
const e3 = normal.dot(rayDir);
|
|
14
|
+
if (e3 === 0) {
|
|
15
|
+
return -e2 / e1;
|
|
16
|
+
}
|
|
17
|
+
vec1.copy(rayDir).multiplyScalar(e1 / e3).sub(normal);
|
|
18
|
+
vec2.copy(rayDir).multiplyScalar(e2 / e3).add(rayStart).sub(clickPoint);
|
|
19
|
+
const offset = -vec1.dot(vec2) / vec1.dot(vec1);
|
|
20
|
+
return offset;
|
|
21
|
+
};
|
|
22
|
+
const upV = /* @__PURE__ */new THREE.Vector3(0, 1, 0);
|
|
23
|
+
const scaleV = /* @__PURE__ */new THREE.Vector3();
|
|
24
|
+
const scaleMatrix = /* @__PURE__ */new THREE.Matrix4();
|
|
25
|
+
const ScalingSphere = ({
|
|
26
|
+
direction,
|
|
27
|
+
axis
|
|
28
|
+
}) => {
|
|
29
|
+
const {
|
|
30
|
+
scaleLimits,
|
|
31
|
+
annotations,
|
|
32
|
+
annotationsClass,
|
|
33
|
+
depthTest,
|
|
34
|
+
scale,
|
|
35
|
+
lineWidth,
|
|
36
|
+
fixed,
|
|
37
|
+
axisColors,
|
|
38
|
+
hoveredColor,
|
|
39
|
+
opacity,
|
|
40
|
+
renderOrder,
|
|
41
|
+
onDragStart,
|
|
42
|
+
onDrag,
|
|
43
|
+
onDragEnd,
|
|
44
|
+
userData
|
|
45
|
+
} = React.useContext(context);
|
|
46
|
+
const size = useThree(state => state.size);
|
|
47
|
+
const camControls = useThree(state => state.controls);
|
|
48
|
+
const divRef = React.useRef(null);
|
|
49
|
+
const objRef = React.useRef(null);
|
|
50
|
+
const meshRef = React.useRef(null);
|
|
51
|
+
const scale0 = React.useRef(1);
|
|
52
|
+
const scaleCur = React.useRef(1);
|
|
53
|
+
const clickInfo = React.useRef(null);
|
|
54
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
55
|
+
const position = fixed ? 1.2 : 1.2 * scale;
|
|
56
|
+
const onPointerDown = React.useCallback(e => {
|
|
57
|
+
if (annotations) {
|
|
58
|
+
divRef.current.innerText = `${scaleCur.current.toFixed(2)}`;
|
|
59
|
+
divRef.current.style.display = 'block';
|
|
60
|
+
}
|
|
61
|
+
e.stopPropagation();
|
|
62
|
+
const rotation = new THREE.Matrix4().extractRotation(objRef.current.matrixWorld);
|
|
63
|
+
const clickPoint = e.point.clone();
|
|
64
|
+
const origin = new THREE.Vector3().setFromMatrixPosition(objRef.current.matrixWorld);
|
|
65
|
+
const dir = direction.clone().applyMatrix4(rotation).normalize();
|
|
66
|
+
const mPLG = objRef.current.matrixWorld.clone();
|
|
67
|
+
const mPLGInv = mPLG.clone().invert();
|
|
68
|
+
const offsetMultiplier = fixed ? 1 / calculateScaleFactor(objRef.current.getWorldPosition(vec1), scale, e.camera, size) : 1;
|
|
69
|
+
clickInfo.current = {
|
|
70
|
+
clickPoint,
|
|
71
|
+
dir,
|
|
72
|
+
mPLG,
|
|
73
|
+
mPLGInv,
|
|
74
|
+
offsetMultiplier
|
|
75
|
+
};
|
|
76
|
+
onDragStart({
|
|
77
|
+
component: 'Sphere',
|
|
78
|
+
axis,
|
|
79
|
+
origin,
|
|
80
|
+
directions: [dir]
|
|
81
|
+
});
|
|
82
|
+
camControls && (camControls.enabled = false);
|
|
83
|
+
// @ts-ignore - setPointerCapture is not in the type definition
|
|
84
|
+
e.target.setPointerCapture(e.pointerId);
|
|
85
|
+
}, [annotations, camControls, direction, onDragStart, axis, fixed, scale, size]);
|
|
86
|
+
const onPointerMove = React.useCallback(e => {
|
|
87
|
+
e.stopPropagation();
|
|
88
|
+
if (!isHovered) setIsHovered(true);
|
|
89
|
+
if (clickInfo.current) {
|
|
90
|
+
const {
|
|
91
|
+
clickPoint,
|
|
92
|
+
dir,
|
|
93
|
+
mPLG,
|
|
94
|
+
mPLGInv,
|
|
95
|
+
offsetMultiplier
|
|
96
|
+
} = clickInfo.current;
|
|
97
|
+
const [min, max] = (scaleLimits == null ? void 0 : scaleLimits[axis]) || [1e-5, undefined]; // always limit the minimal value, since setting it very low might break the transform
|
|
98
|
+
|
|
99
|
+
const offsetW = calculateOffset(clickPoint, dir, e.ray.origin, e.ray.direction);
|
|
100
|
+
const offsetL = offsetW * offsetMultiplier;
|
|
101
|
+
const offsetH = fixed ? offsetL : offsetL / scale;
|
|
102
|
+
let upscale = Math.pow(2, offsetH * 0.2);
|
|
103
|
+
|
|
104
|
+
// @ts-ignore
|
|
105
|
+
if (e.shiftKey) {
|
|
106
|
+
upscale = Math.round(upscale * 10) / 10;
|
|
107
|
+
}
|
|
108
|
+
upscale = Math.max(upscale, min / scale0.current);
|
|
109
|
+
if (max !== undefined) {
|
|
110
|
+
upscale = Math.min(upscale, max / scale0.current);
|
|
111
|
+
}
|
|
112
|
+
scaleCur.current = scale0.current * upscale;
|
|
113
|
+
meshRef.current.position.set(0, position + offsetL, 0);
|
|
114
|
+
if (annotations) {
|
|
115
|
+
divRef.current.innerText = `${scaleCur.current.toFixed(2)}`;
|
|
116
|
+
}
|
|
117
|
+
scaleV.set(1, 1, 1);
|
|
118
|
+
scaleV.setComponent(axis, upscale);
|
|
119
|
+
scaleMatrix.makeScale(scaleV.x, scaleV.y, scaleV.z).premultiply(mPLG).multiply(mPLGInv);
|
|
120
|
+
onDrag(scaleMatrix);
|
|
121
|
+
}
|
|
122
|
+
}, [annotations, position, onDrag, isHovered, scaleLimits, axis]);
|
|
123
|
+
const onPointerUp = React.useCallback(e => {
|
|
124
|
+
if (annotations) {
|
|
125
|
+
divRef.current.style.display = 'none';
|
|
126
|
+
}
|
|
127
|
+
e.stopPropagation();
|
|
128
|
+
scale0.current = scaleCur.current;
|
|
129
|
+
clickInfo.current = null;
|
|
130
|
+
meshRef.current.position.set(0, position, 0);
|
|
131
|
+
onDragEnd();
|
|
132
|
+
camControls && (camControls.enabled = true);
|
|
133
|
+
// @ts-ignore - releasePointerCapture & PointerEvent#pointerId is not in the type definition
|
|
134
|
+
e.target.releasePointerCapture(e.pointerId);
|
|
135
|
+
}, [annotations, camControls, onDragEnd, position]);
|
|
136
|
+
const onPointerOut = React.useCallback(e => {
|
|
137
|
+
e.stopPropagation();
|
|
138
|
+
setIsHovered(false);
|
|
139
|
+
}, []);
|
|
140
|
+
const {
|
|
141
|
+
radius,
|
|
142
|
+
matrixL
|
|
143
|
+
} = React.useMemo(() => {
|
|
144
|
+
const radius = fixed ? lineWidth / scale * 1.8 : scale / 22.5;
|
|
145
|
+
const quaternion = new THREE.Quaternion().setFromUnitVectors(upV, direction.clone().normalize());
|
|
146
|
+
const matrixL = new THREE.Matrix4().makeRotationFromQuaternion(quaternion);
|
|
147
|
+
return {
|
|
148
|
+
radius,
|
|
149
|
+
matrixL
|
|
150
|
+
};
|
|
151
|
+
}, [direction, scale, lineWidth, fixed]);
|
|
152
|
+
const color = isHovered ? hoveredColor : axisColors[axis];
|
|
153
|
+
return /*#__PURE__*/React.createElement("group", {
|
|
154
|
+
ref: objRef
|
|
155
|
+
}, /*#__PURE__*/React.createElement("group", {
|
|
156
|
+
matrix: matrixL,
|
|
157
|
+
matrixAutoUpdate: false,
|
|
158
|
+
onPointerDown: onPointerDown,
|
|
159
|
+
onPointerMove: onPointerMove,
|
|
160
|
+
onPointerUp: onPointerUp,
|
|
161
|
+
onPointerOut: onPointerOut
|
|
162
|
+
}, annotations && /*#__PURE__*/React.createElement(Html, {
|
|
163
|
+
position: [0, position / 2, 0]
|
|
164
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
165
|
+
style: {
|
|
166
|
+
display: 'none',
|
|
167
|
+
background: '#151520',
|
|
168
|
+
color: 'white',
|
|
169
|
+
padding: '6px 8px',
|
|
170
|
+
borderRadius: 7,
|
|
171
|
+
whiteSpace: 'nowrap'
|
|
172
|
+
},
|
|
173
|
+
className: annotationsClass,
|
|
174
|
+
ref: divRef
|
|
175
|
+
})), /*#__PURE__*/React.createElement("mesh", {
|
|
176
|
+
ref: meshRef,
|
|
177
|
+
position: [0, position, 0],
|
|
178
|
+
renderOrder: renderOrder,
|
|
179
|
+
userData: userData
|
|
180
|
+
}, /*#__PURE__*/React.createElement("sphereGeometry", {
|
|
181
|
+
args: [radius, 12, 12]
|
|
182
|
+
}), /*#__PURE__*/React.createElement("meshBasicMaterial", {
|
|
183
|
+
transparent: true,
|
|
184
|
+
depthTest: depthTest,
|
|
185
|
+
color: color,
|
|
186
|
+
opacity: opacity,
|
|
187
|
+
polygonOffset: true,
|
|
188
|
+
polygonOffsetFactor: -10
|
|
189
|
+
}))));
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export { ScalingSphere, calculateOffset };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}Object.defineProperty(exports,"__esModule",{value:!0});const t=e(require("react")).createContext(null);exports.context=t;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export type OnDragStartProps = {
|
|
4
|
+
component: 'Arrow' | 'Slider' | 'Rotator' | 'Sphere';
|
|
5
|
+
axis: 0 | 1 | 2;
|
|
6
|
+
origin: THREE.Vector3;
|
|
7
|
+
directions: THREE.Vector3[];
|
|
8
|
+
};
|
|
9
|
+
export type PivotContext = {
|
|
10
|
+
onDragStart: (props: OnDragStartProps) => void;
|
|
11
|
+
onDrag: (mdW: THREE.Matrix4) => void;
|
|
12
|
+
onDragEnd: () => void;
|
|
13
|
+
translation: {
|
|
14
|
+
current: [number, number, number];
|
|
15
|
+
};
|
|
16
|
+
translationLimits?: [[number, number] | undefined, [number, number] | undefined, [number, number] | undefined];
|
|
17
|
+
rotationLimits?: [[number, number] | undefined, [number, number] | undefined, [number, number] | undefined];
|
|
18
|
+
scaleLimits?: [[number, number] | undefined, [number, number] | undefined, [number, number] | undefined];
|
|
19
|
+
axisColors: [string | number, string | number, string | number];
|
|
20
|
+
hoveredColor: string | number;
|
|
21
|
+
opacity: number;
|
|
22
|
+
scale: number;
|
|
23
|
+
lineWidth: number;
|
|
24
|
+
fixed: boolean;
|
|
25
|
+
depthTest: boolean;
|
|
26
|
+
renderOrder: number;
|
|
27
|
+
userData?: {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
};
|
|
30
|
+
annotations?: boolean;
|
|
31
|
+
annotationsClass?: string;
|
|
32
|
+
};
|
|
33
|
+
export declare const context: React.Context<PivotContext>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("@react-three/fiber"),t=require("react"),i=require("three"),a=require("./AxisArrow.cjs.js"),n=require("./AxisRotator.cjs.js"),o=require("./PlaneSlider.cjs.js"),c=require("./ScalingSphere.cjs.js"),l=require("./context.cjs.js"),s=require("../../core/calculateScaleFactor.cjs.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function d(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}require("../../core/Line.cjs.js"),require("three-stdlib"),require("../Html.cjs.js"),require("react-dom/client");var m=u(e),x=d(t),p=d(i);const f=new p.Matrix4,y=new p.Matrix4,w=new p.Matrix4,g=new p.Matrix4,b=new p.Matrix4,E=new p.Matrix4,j=new p.Matrix4,S=new p.Matrix4,h=new p.Matrix4,v=new p.Box3,M=new p.Box3,A=new p.Vector3,q=new p.Vector3,R=new p.Vector3,V=new p.Vector3,P=new p.Vector3,W=new p.Vector3(1,0,0),D=new p.Vector3(0,1,0),O=new p.Vector3(0,0,1),C=x.forwardRef((({enabled:e=!0,matrix:t,onDragStart:i,onDrag:u,onDragEnd:d,autoTransform:C=!0,anchor:L,disableAxes:B=!1,disableSliders:F=!1,disableRotations:z=!1,disableScaling:T=!1,activeAxes:_=[!0,!0,!0],offset:k=[0,0,0],rotation:H=[0,0,0],scale:I=1,lineWidth:U=4,fixed:G=!1,translationLimits:J,rotationLimits:K,scaleLimits:N,depthTest:Q=!0,renderOrder:X=500,axisColors:Y=["#ff2060","#20df80","#2080ff"],hoveredColor:Z="#ffff40",annotations:$=!1,annotationsClass:ee,opacity:re=1,visible:te=!0,userData:ie,children:ae,...ne},oe)=>{const ce=r.useThree((e=>e.invalidate)),le=x.useRef(null),se=x.useRef(null),ue=x.useRef(null),de=x.useRef(null),me=x.useRef([0,0,0]),xe=x.useRef(new p.Vector3(1,1,1)),pe=x.useRef(new p.Vector3(1,1,1));x.useLayoutEffect((()=>{L&&(de.current.updateWorldMatrix(!0,!0),g.copy(de.current.matrixWorld).invert(),v.makeEmpty(),de.current.traverse((e=>{e.geometry&&(e.geometry.boundingBox||e.geometry.computeBoundingBox(),E.copy(e.matrixWorld).premultiply(g),M.copy(e.geometry.boundingBox),M.applyMatrix4(E),v.union(M))})),A.copy(v.max).add(v.min).multiplyScalar(.5),q.copy(v.max).sub(v.min).multiplyScalar(.5),R.copy(q).multiply(new p.Vector3(...L)).add(A),V.set(...k).add(R),ue.current.position.copy(V),ce())}));const fe=x.useMemo((()=>({onDragStart:e=>{f.copy(se.current.matrix),y.copy(se.current.matrixWorld),i&&i(e),ce()},onDrag:e=>{w.copy(le.current.matrixWorld),g.copy(w).invert(),b.copy(y).premultiply(e),E.copy(b).premultiply(g),j.copy(f).invert(),S.copy(E).multiply(j),C&&se.current.matrix.copy(E),u&&u(E,S,b,e),ce()},onDragEnd:()=>{d&&d(),ce()},translation:me,translationLimits:J,rotationLimits:K,axisColors:Y,hoveredColor:Z,opacity:re,scale:I,lineWidth:U,fixed:G,depthTest:Q,renderOrder:X,userData:ie,annotations:$,annotationsClass:ee})),[i,u,d,me,J,K,N,Q,I,U,G,...Y,Z,re,ie,C,$,ee]),ye=new p.Vector3;return r.useFrame((e=>{if(G){const r=s.calculateScaleFactor(ue.current.getWorldPosition(ye),I,e.camera,e.size);xe.current.setScalar(r)}t&&t instanceof p.Matrix4&&(se.current.matrix=t),se.current.updateWorldMatrix(!0,!0),h.makeRotationFromEuler(ue.current.rotation).setPosition(ue.current.position).premultiply(se.current.matrixWorld),pe.current.setFromMatrixScale(h),P.copy(xe.current).divide(pe.current),(Math.abs(ue.current.scale.x-P.x)>1e-4||Math.abs(ue.current.scale.y-P.y)>1e-4||Math.abs(ue.current.scale.z-P.z)>1e-4)&&(ue.current.scale.copy(P),e.invalidate())})),x.useImperativeHandle(oe,(()=>se.current),[]),x.createElement(l.context.Provider,{value:fe},x.createElement("group",{ref:le},x.createElement("group",m.default({ref:se,matrix:t,matrixAutoUpdate:!1},ne),x.createElement("group",{visible:te,ref:ue,position:k,rotation:H},e&&x.createElement(x.Fragment,null,!B&&_[0]&&x.createElement(a.AxisArrow,{axis:0,direction:W}),!B&&_[1]&&x.createElement(a.AxisArrow,{axis:1,direction:D}),!B&&_[2]&&x.createElement(a.AxisArrow,{axis:2,direction:O}),!F&&_[0]&&_[1]&&x.createElement(o.PlaneSlider,{axis:2,dir1:W,dir2:D}),!F&&_[0]&&_[2]&&x.createElement(o.PlaneSlider,{axis:1,dir1:O,dir2:W}),!F&&_[2]&&_[1]&&x.createElement(o.PlaneSlider,{axis:0,dir1:D,dir2:O}),!z&&_[0]&&_[1]&&x.createElement(n.AxisRotator,{axis:2,dir1:W,dir2:D}),!z&&_[0]&&_[2]&&x.createElement(n.AxisRotator,{axis:1,dir1:O,dir2:W}),!z&&_[2]&&_[1]&&x.createElement(n.AxisRotator,{axis:0,dir1:D,dir2:O}),!T&&_[0]&&x.createElement(c.ScalingSphere,{axis:0,direction:W}),!T&&_[1]&&x.createElement(c.ScalingSphere,{axis:1,direction:D}),!T&&_[2]&&x.createElement(c.ScalingSphere,{axis:2,direction:O}))),x.createElement("group",{ref:de},ae))))}));exports.PivotControls=C;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import { ForwardRefComponent } from '../../helpers/ts-utils';
|
|
4
|
+
import { OnDragStartProps } from './context';
|
|
5
|
+
export type PivotControlsProps = {
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
scale?: number;
|
|
8
|
+
lineWidth?: number;
|
|
9
|
+
fixed?: boolean;
|
|
10
|
+
offset?: [number, number, number];
|
|
11
|
+
rotation?: [number, number, number];
|
|
12
|
+
matrix?: THREE.Matrix4;
|
|
13
|
+
anchor?: [number, number, number];
|
|
14
|
+
autoTransform?: boolean;
|
|
15
|
+
activeAxes?: [boolean, boolean, boolean];
|
|
16
|
+
disableAxes?: boolean;
|
|
17
|
+
disableSliders?: boolean;
|
|
18
|
+
disableRotations?: boolean;
|
|
19
|
+
disableScaling?: boolean;
|
|
20
|
+
translationLimits?: [[number, number] | undefined, [number, number] | undefined, [number, number] | undefined];
|
|
21
|
+
rotationLimits?: [[number, number] | undefined, [number, number] | undefined, [number, number] | undefined];
|
|
22
|
+
scaleLimits?: [[number, number] | undefined, [number, number] | undefined, [number, number] | undefined];
|
|
23
|
+
axisColors?: [string | number, string | number, string | number];
|
|
24
|
+
hoveredColor?: string | number;
|
|
25
|
+
annotations?: boolean;
|
|
26
|
+
annotationsClass?: string;
|
|
27
|
+
onDragStart?: (props: OnDragStartProps) => void;
|
|
28
|
+
onDrag?: (l: THREE.Matrix4, deltaL: THREE.Matrix4, w: THREE.Matrix4, deltaW: THREE.Matrix4) => void;
|
|
29
|
+
onDragEnd?: () => void;
|
|
30
|
+
depthTest?: boolean;
|
|
31
|
+
renderOrder?: number;
|
|
32
|
+
opacity?: number;
|
|
33
|
+
visible?: boolean;
|
|
34
|
+
userData?: {
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
};
|
|
37
|
+
children?: React.ReactNode;
|
|
38
|
+
};
|
|
39
|
+
export declare const PivotControls: ForwardRefComponent<PivotControlsProps, THREE.Group>;
|