@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
package/core/Splat.js
ADDED
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { extend, useThree, useLoader, useFrame } from '@react-three/fiber';
|
|
5
|
+
import { shaderMaterial } from './shaderMaterial.js';
|
|
6
|
+
import { version } from '../helpers/constants.js';
|
|
7
|
+
|
|
8
|
+
const SplatMaterial = /* @__PURE__ */shaderMaterial({
|
|
9
|
+
alphaTest: 0,
|
|
10
|
+
viewport: /* @__PURE__ */new THREE.Vector2(1980, 1080),
|
|
11
|
+
focal: 1000.0,
|
|
12
|
+
centerAndScaleTexture: null,
|
|
13
|
+
covAndColorTexture: null
|
|
14
|
+
}, /*glsl*/`
|
|
15
|
+
precision highp sampler2D;
|
|
16
|
+
precision highp usampler2D;
|
|
17
|
+
out vec4 vColor;
|
|
18
|
+
out vec3 vPosition;
|
|
19
|
+
uniform vec2 resolution;
|
|
20
|
+
uniform vec2 viewport;
|
|
21
|
+
uniform float focal;
|
|
22
|
+
attribute uint splatIndex;
|
|
23
|
+
uniform sampler2D centerAndScaleTexture;
|
|
24
|
+
uniform usampler2D covAndColorTexture;
|
|
25
|
+
|
|
26
|
+
vec2 unpackInt16(in uint value) {
|
|
27
|
+
int v = int(value);
|
|
28
|
+
int v0 = v >> 16;
|
|
29
|
+
int v1 = (v & 0xFFFF);
|
|
30
|
+
if((v & 0x8000) != 0)
|
|
31
|
+
v1 |= 0xFFFF0000;
|
|
32
|
+
return vec2(float(v1), float(v0));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
void main () {
|
|
36
|
+
ivec2 texSize = textureSize(centerAndScaleTexture, 0);
|
|
37
|
+
ivec2 texPos = ivec2(splatIndex%uint(texSize.x), splatIndex/uint(texSize.x));
|
|
38
|
+
vec4 centerAndScaleData = texelFetch(centerAndScaleTexture, texPos, 0);
|
|
39
|
+
vec4 center = vec4(centerAndScaleData.xyz, 1);
|
|
40
|
+
vec4 camspace = modelViewMatrix * center;
|
|
41
|
+
vec4 pos2d = projectionMatrix * camspace;
|
|
42
|
+
|
|
43
|
+
float bounds = 1.2 * pos2d.w;
|
|
44
|
+
if (pos2d.z < -pos2d.w || pos2d.x < -bounds || pos2d.x > bounds
|
|
45
|
+
|| pos2d.y < -bounds || pos2d.y > bounds) {
|
|
46
|
+
gl_Position = vec4(0.0, 0.0, 2.0, 1.0);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
uvec4 covAndColorData = texelFetch(covAndColorTexture, texPos, 0);
|
|
51
|
+
vec2 cov3D_M11_M12 = unpackInt16(covAndColorData.x) * centerAndScaleData.w;
|
|
52
|
+
vec2 cov3D_M13_M22 = unpackInt16(covAndColorData.y) * centerAndScaleData.w;
|
|
53
|
+
vec2 cov3D_M23_M33 = unpackInt16(covAndColorData.z) * centerAndScaleData.w;
|
|
54
|
+
mat3 Vrk = mat3(
|
|
55
|
+
cov3D_M11_M12.x, cov3D_M11_M12.y, cov3D_M13_M22.x,
|
|
56
|
+
cov3D_M11_M12.y, cov3D_M13_M22.y, cov3D_M23_M33.x,
|
|
57
|
+
cov3D_M13_M22.x, cov3D_M23_M33.x, cov3D_M23_M33.y
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
mat3 J = mat3(
|
|
61
|
+
focal / camspace.z, 0., -(focal * camspace.x) / (camspace.z * camspace.z),
|
|
62
|
+
0., focal / camspace.z, -(focal * camspace.y) / (camspace.z * camspace.z),
|
|
63
|
+
0., 0., 0.
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
mat3 W = transpose(mat3(modelViewMatrix));
|
|
67
|
+
mat3 T = W * J;
|
|
68
|
+
mat3 cov = transpose(T) * Vrk * T;
|
|
69
|
+
vec2 vCenter = vec2(pos2d) / pos2d.w;
|
|
70
|
+
float diagonal1 = cov[0][0] + 0.3;
|
|
71
|
+
float offDiagonal = cov[0][1];
|
|
72
|
+
float diagonal2 = cov[1][1] + 0.3;
|
|
73
|
+
float mid = 0.5 * (diagonal1 + diagonal2);
|
|
74
|
+
float radius = length(vec2((diagonal1 - diagonal2) / 2.0, offDiagonal));
|
|
75
|
+
float lambda1 = mid + radius;
|
|
76
|
+
float lambda2 = max(mid - radius, 0.1);
|
|
77
|
+
vec2 diagonalVector = normalize(vec2(offDiagonal, lambda1 - diagonal1));
|
|
78
|
+
vec2 v1 = min(sqrt(2.0 * lambda1), 1024.0) * diagonalVector;
|
|
79
|
+
vec2 v2 = min(sqrt(2.0 * lambda2), 1024.0) * vec2(diagonalVector.y, -diagonalVector.x);
|
|
80
|
+
uint colorUint = covAndColorData.w;
|
|
81
|
+
vColor = vec4(
|
|
82
|
+
float(colorUint & uint(0xFF)) / 255.0,
|
|
83
|
+
float((colorUint >> uint(8)) & uint(0xFF)) / 255.0,
|
|
84
|
+
float((colorUint >> uint(16)) & uint(0xFF)) / 255.0,
|
|
85
|
+
float(colorUint >> uint(24)) / 255.0
|
|
86
|
+
);
|
|
87
|
+
vPosition = position;
|
|
88
|
+
|
|
89
|
+
gl_Position = vec4(
|
|
90
|
+
vCenter
|
|
91
|
+
+ position.x * v2 / viewport * 2.0
|
|
92
|
+
+ position.y * v1 / viewport * 2.0, pos2d.z / pos2d.w, 1.0);
|
|
93
|
+
}
|
|
94
|
+
`, /*glsl*/`
|
|
95
|
+
#include <alphatest_pars_fragment>
|
|
96
|
+
#include <alphahash_pars_fragment>
|
|
97
|
+
in vec4 vColor;
|
|
98
|
+
in vec3 vPosition;
|
|
99
|
+
void main () {
|
|
100
|
+
float A = -dot(vPosition.xy, vPosition.xy);
|
|
101
|
+
if (A < -4.0) discard;
|
|
102
|
+
float B = exp(A) * vColor.a;
|
|
103
|
+
vec4 diffuseColor = vec4(vColor.rgb, B);
|
|
104
|
+
#include <alphatest_fragment>
|
|
105
|
+
#include <alphahash_fragment>
|
|
106
|
+
gl_FragColor = diffuseColor;
|
|
107
|
+
#include <tonemapping_fragment>
|
|
108
|
+
#include <${version >= 154 ? 'colorspace_fragment' : 'encodings_fragment'}>
|
|
109
|
+
}
|
|
110
|
+
`);
|
|
111
|
+
function createWorker(self) {
|
|
112
|
+
let matrices = null;
|
|
113
|
+
let offset = 0;
|
|
114
|
+
function sortSplats(view, hashed = false) {
|
|
115
|
+
const vertexCount = matrices.length / 16;
|
|
116
|
+
const threshold = -0.0001;
|
|
117
|
+
let maxDepth = -Infinity;
|
|
118
|
+
let minDepth = Infinity;
|
|
119
|
+
const depthList = new Float32Array(vertexCount);
|
|
120
|
+
const sizeList = new Int32Array(depthList.buffer);
|
|
121
|
+
const validIndexList = new Int32Array(vertexCount);
|
|
122
|
+
let validCount = 0;
|
|
123
|
+
for (let i = 0; i < vertexCount; i++) {
|
|
124
|
+
// Sign of depth is reversed
|
|
125
|
+
const depth = view[0] * matrices[i * 16 + 12] + view[1] * matrices[i * 16 + 13] + view[2] * matrices[i * 16 + 14] + view[3];
|
|
126
|
+
// Skip behind of camera and small, transparent splat
|
|
127
|
+
if (hashed || depth < 0 && matrices[i * 16 + 15] > threshold * depth) {
|
|
128
|
+
depthList[validCount] = depth;
|
|
129
|
+
validIndexList[validCount] = i;
|
|
130
|
+
validCount++;
|
|
131
|
+
if (depth > maxDepth) maxDepth = depth;
|
|
132
|
+
if (depth < minDepth) minDepth = depth;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// This is a 16 bit single-pass counting sort
|
|
137
|
+
const depthInv = (256 * 256 - 1) / (maxDepth - minDepth);
|
|
138
|
+
const counts0 = new Uint32Array(256 * 256);
|
|
139
|
+
for (let i = 0; i < validCount; i++) {
|
|
140
|
+
sizeList[i] = (depthList[i] - minDepth) * depthInv | 0;
|
|
141
|
+
counts0[sizeList[i]]++;
|
|
142
|
+
}
|
|
143
|
+
const starts0 = new Uint32Array(256 * 256);
|
|
144
|
+
for (let i = 1; i < 256 * 256; i++) starts0[i] = starts0[i - 1] + counts0[i - 1];
|
|
145
|
+
const depthIndex = new Uint32Array(validCount);
|
|
146
|
+
for (let i = 0; i < validCount; i++) depthIndex[starts0[sizeList[i]]++] = validIndexList[i];
|
|
147
|
+
return depthIndex;
|
|
148
|
+
}
|
|
149
|
+
self.onmessage = e => {
|
|
150
|
+
if (e.data.method == 'push') {
|
|
151
|
+
if (offset === 0) matrices = new Float32Array(e.data.length);
|
|
152
|
+
const new_matrices = new Float32Array(e.data.matrices);
|
|
153
|
+
matrices.set(new_matrices, offset);
|
|
154
|
+
offset += new_matrices.length;
|
|
155
|
+
} else if (e.data.method == 'sort') {
|
|
156
|
+
if (matrices !== null) {
|
|
157
|
+
const indices = sortSplats(new Float32Array(e.data.view), e.data.hashed);
|
|
158
|
+
// @ts-ignore
|
|
159
|
+
self.postMessage({
|
|
160
|
+
indices,
|
|
161
|
+
key: e.data.key
|
|
162
|
+
}, [indices.buffer]);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
class SplatLoader extends THREE.Loader {
|
|
168
|
+
constructor(...args) {
|
|
169
|
+
super(...args);
|
|
170
|
+
// WebGLRenderer, needs to be filled out!
|
|
171
|
+
this.gl = null;
|
|
172
|
+
// Default chunk size for lazy loading
|
|
173
|
+
this.chunkSize = 25000;
|
|
174
|
+
}
|
|
175
|
+
load(url, onLoad, onProgress, onError) {
|
|
176
|
+
const shared = {
|
|
177
|
+
gl: this.gl,
|
|
178
|
+
url: this.manager.resolveURL(url),
|
|
179
|
+
worker: new Worker(URL.createObjectURL(new Blob(['(', createWorker.toString(), ')(self)'], {
|
|
180
|
+
type: 'application/javascript'
|
|
181
|
+
}))),
|
|
182
|
+
manager: this.manager,
|
|
183
|
+
update: (target, camera, hashed) => update(camera, shared, target, hashed),
|
|
184
|
+
connect: target => connect(shared, target),
|
|
185
|
+
loading: false,
|
|
186
|
+
loaded: false,
|
|
187
|
+
loadedVertexCount: 0,
|
|
188
|
+
chunkSize: this.chunkSize,
|
|
189
|
+
totalDownloadBytes: 0,
|
|
190
|
+
numVertices: 0,
|
|
191
|
+
rowLength: 3 * 4 + 3 * 4 + 4 + 4,
|
|
192
|
+
maxVertexes: 0,
|
|
193
|
+
bufferTextureWidth: 0,
|
|
194
|
+
bufferTextureHeight: 0,
|
|
195
|
+
stream: null,
|
|
196
|
+
centerAndScaleData: null,
|
|
197
|
+
covAndColorData: null,
|
|
198
|
+
covAndColorTexture: null,
|
|
199
|
+
centerAndScaleTexture: null,
|
|
200
|
+
onProgress
|
|
201
|
+
};
|
|
202
|
+
load(shared).then(onLoad).catch(e => {
|
|
203
|
+
onError == null || onError(e);
|
|
204
|
+
shared.manager.itemError(shared.url);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
async function load(shared) {
|
|
209
|
+
shared.manager.itemStart(shared.url);
|
|
210
|
+
const data = await fetch(shared.url);
|
|
211
|
+
if (data.body === null) throw 'Failed to fetch file';
|
|
212
|
+
let _totalDownloadBytes = data.headers.get('Content-Length');
|
|
213
|
+
const totalDownloadBytes = _totalDownloadBytes ? parseInt(_totalDownloadBytes) : undefined;
|
|
214
|
+
if (totalDownloadBytes == undefined) throw 'Failed to get content length';
|
|
215
|
+
shared.stream = data.body.getReader();
|
|
216
|
+
shared.totalDownloadBytes = totalDownloadBytes;
|
|
217
|
+
shared.numVertices = Math.floor(shared.totalDownloadBytes / shared.rowLength);
|
|
218
|
+
const context = shared.gl.getContext();
|
|
219
|
+
let maxTextureSize = context.getParameter(context.MAX_TEXTURE_SIZE);
|
|
220
|
+
shared.maxVertexes = maxTextureSize * maxTextureSize;
|
|
221
|
+
if (shared.numVertices > shared.maxVertexes) shared.numVertices = shared.maxVertexes;
|
|
222
|
+
shared.bufferTextureWidth = maxTextureSize;
|
|
223
|
+
shared.bufferTextureHeight = Math.floor((shared.numVertices - 1) / maxTextureSize) + 1;
|
|
224
|
+
shared.centerAndScaleData = new Float32Array(shared.bufferTextureWidth * shared.bufferTextureHeight * 4);
|
|
225
|
+
shared.covAndColorData = new Uint32Array(shared.bufferTextureWidth * shared.bufferTextureHeight * 4);
|
|
226
|
+
shared.centerAndScaleTexture = new THREE.DataTexture(shared.centerAndScaleData, shared.bufferTextureWidth, shared.bufferTextureHeight, THREE.RGBAFormat, THREE.FloatType);
|
|
227
|
+
shared.centerAndScaleTexture.needsUpdate = true;
|
|
228
|
+
shared.covAndColorTexture = new THREE.DataTexture(shared.covAndColorData, shared.bufferTextureWidth, shared.bufferTextureHeight, THREE.RGBAIntegerFormat, THREE.UnsignedIntType);
|
|
229
|
+
shared.covAndColorTexture.internalFormat = 'RGBA32UI';
|
|
230
|
+
shared.covAndColorTexture.needsUpdate = true;
|
|
231
|
+
return shared;
|
|
232
|
+
}
|
|
233
|
+
async function lazyLoad(shared) {
|
|
234
|
+
shared.loading = true;
|
|
235
|
+
let bytesDownloaded = 0;
|
|
236
|
+
let bytesProcessed = 0;
|
|
237
|
+
const chunks = [];
|
|
238
|
+
let lastReportedProgress = 0;
|
|
239
|
+
const lengthComputable = shared.totalDownloadBytes !== 0;
|
|
240
|
+
while (true) {
|
|
241
|
+
try {
|
|
242
|
+
const {
|
|
243
|
+
value,
|
|
244
|
+
done
|
|
245
|
+
} = await shared.stream.read();
|
|
246
|
+
if (done) break;
|
|
247
|
+
bytesDownloaded += value.length;
|
|
248
|
+
if (shared.totalDownloadBytes != undefined) {
|
|
249
|
+
const percent = bytesDownloaded / shared.totalDownloadBytes * 100;
|
|
250
|
+
if (shared.onProgress && percent - lastReportedProgress > 1) {
|
|
251
|
+
const event = new ProgressEvent('progress', {
|
|
252
|
+
lengthComputable,
|
|
253
|
+
loaded: bytesDownloaded,
|
|
254
|
+
total: shared.totalDownloadBytes
|
|
255
|
+
});
|
|
256
|
+
shared.onProgress(event);
|
|
257
|
+
lastReportedProgress = percent;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
chunks.push(value);
|
|
261
|
+
const bytesRemains = bytesDownloaded - bytesProcessed;
|
|
262
|
+
if (shared.totalDownloadBytes != undefined && bytesRemains > shared.rowLength * shared.chunkSize) {
|
|
263
|
+
let vertexCount = Math.floor(bytesRemains / shared.rowLength);
|
|
264
|
+
const concatenatedChunksbuffer = new Uint8Array(bytesRemains);
|
|
265
|
+
let offset = 0;
|
|
266
|
+
for (const chunk of chunks) {
|
|
267
|
+
concatenatedChunksbuffer.set(chunk, offset);
|
|
268
|
+
offset += chunk.length;
|
|
269
|
+
}
|
|
270
|
+
chunks.length = 0;
|
|
271
|
+
if (bytesRemains > vertexCount * shared.rowLength) {
|
|
272
|
+
const extra_data = new Uint8Array(bytesRemains - vertexCount * shared.rowLength);
|
|
273
|
+
extra_data.set(concatenatedChunksbuffer.subarray(bytesRemains - extra_data.length, bytesRemains), 0);
|
|
274
|
+
chunks.push(extra_data);
|
|
275
|
+
}
|
|
276
|
+
const buffer = new Uint8Array(vertexCount * shared.rowLength);
|
|
277
|
+
buffer.set(concatenatedChunksbuffer.subarray(0, buffer.byteLength), 0);
|
|
278
|
+
const matrices = pushDataBuffer(shared, buffer.buffer, vertexCount);
|
|
279
|
+
shared.worker.postMessage({
|
|
280
|
+
method: 'push',
|
|
281
|
+
src: shared.url,
|
|
282
|
+
length: shared.numVertices * 16,
|
|
283
|
+
matrices: matrices.buffer
|
|
284
|
+
}, [matrices.buffer]);
|
|
285
|
+
bytesProcessed += vertexCount * shared.rowLength;
|
|
286
|
+
if (shared.onProgress) {
|
|
287
|
+
const event = new ProgressEvent('progress', {
|
|
288
|
+
lengthComputable,
|
|
289
|
+
loaded: shared.totalDownloadBytes,
|
|
290
|
+
total: shared.totalDownloadBytes
|
|
291
|
+
});
|
|
292
|
+
shared.onProgress(event);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
} catch (error) {
|
|
296
|
+
console.error(error);
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (bytesDownloaded - bytesProcessed > 0) {
|
|
301
|
+
// Concatenate the chunks into a single Uint8Array
|
|
302
|
+
let concatenatedChunks = new Uint8Array(chunks.reduce((acc, chunk) => acc + chunk.length, 0));
|
|
303
|
+
let offset = 0;
|
|
304
|
+
for (const chunk of chunks) {
|
|
305
|
+
concatenatedChunks.set(chunk, offset);
|
|
306
|
+
offset += chunk.length;
|
|
307
|
+
}
|
|
308
|
+
let numVertices = Math.floor(concatenatedChunks.byteLength / shared.rowLength);
|
|
309
|
+
const matrices = pushDataBuffer(shared, concatenatedChunks.buffer, numVertices);
|
|
310
|
+
shared.worker.postMessage({
|
|
311
|
+
method: 'push',
|
|
312
|
+
src: shared.url,
|
|
313
|
+
length: numVertices * 16,
|
|
314
|
+
matrices: matrices.buffer
|
|
315
|
+
}, [matrices.buffer]);
|
|
316
|
+
}
|
|
317
|
+
shared.loaded = true;
|
|
318
|
+
shared.manager.itemEnd(shared.url);
|
|
319
|
+
}
|
|
320
|
+
function update(camera, shared, target, hashed) {
|
|
321
|
+
camera.updateMatrixWorld();
|
|
322
|
+
shared.gl.getCurrentViewport(target.viewport);
|
|
323
|
+
// @ts-ignore
|
|
324
|
+
target.material.viewport.x = target.viewport.z;
|
|
325
|
+
// @ts-ignore
|
|
326
|
+
target.material.viewport.y = target.viewport.w;
|
|
327
|
+
target.material.focal = target.viewport.w / 2.0 * Math.abs(camera.projectionMatrix.elements[5]);
|
|
328
|
+
if (target.ready) {
|
|
329
|
+
if (hashed && target.sorted) return;
|
|
330
|
+
target.ready = false;
|
|
331
|
+
const view = new Float32Array([target.modelViewMatrix.elements[2], -target.modelViewMatrix.elements[6], target.modelViewMatrix.elements[10], target.modelViewMatrix.elements[14]]);
|
|
332
|
+
shared.worker.postMessage({
|
|
333
|
+
method: 'sort',
|
|
334
|
+
src: shared.url,
|
|
335
|
+
key: target.uuid,
|
|
336
|
+
view: view.buffer,
|
|
337
|
+
hashed
|
|
338
|
+
}, [view.buffer]);
|
|
339
|
+
if (hashed && shared.loaded) target.sorted = true;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function connect(shared, target) {
|
|
343
|
+
if (!shared.loading) lazyLoad(shared);
|
|
344
|
+
target.ready = false;
|
|
345
|
+
target.pm = new THREE.Matrix4();
|
|
346
|
+
target.vm1 = new THREE.Matrix4();
|
|
347
|
+
target.vm2 = new THREE.Matrix4();
|
|
348
|
+
target.viewport = new THREE.Vector4();
|
|
349
|
+
let splatIndexArray = new Uint32Array(shared.bufferTextureWidth * shared.bufferTextureHeight);
|
|
350
|
+
const splatIndexes = new THREE.InstancedBufferAttribute(splatIndexArray, 1, false);
|
|
351
|
+
splatIndexes.setUsage(THREE.DynamicDrawUsage);
|
|
352
|
+
const geometry = target.geometry = new THREE.InstancedBufferGeometry();
|
|
353
|
+
const positionsArray = new Float32Array(6 * 3);
|
|
354
|
+
const positions = new THREE.BufferAttribute(positionsArray, 3);
|
|
355
|
+
geometry.setAttribute('position', positions);
|
|
356
|
+
positions.setXYZ(2, -2.0, 2.0, 0.0);
|
|
357
|
+
positions.setXYZ(1, 2.0, 2.0, 0.0);
|
|
358
|
+
positions.setXYZ(0, -2.0, -2.0, 0.0);
|
|
359
|
+
positions.setXYZ(5, -2.0, -2.0, 0.0);
|
|
360
|
+
positions.setXYZ(4, 2.0, 2.0, 0.0);
|
|
361
|
+
positions.setXYZ(3, 2.0, -2.0, 0.0);
|
|
362
|
+
positions.needsUpdate = true;
|
|
363
|
+
geometry.setAttribute('splatIndex', splatIndexes);
|
|
364
|
+
geometry.instanceCount = 1;
|
|
365
|
+
function listener(e) {
|
|
366
|
+
if (target && e.data.key === target.uuid) {
|
|
367
|
+
let indexes = new Uint32Array(e.data.indices);
|
|
368
|
+
// @ts-ignore
|
|
369
|
+
geometry.attributes.splatIndex.set(indexes);
|
|
370
|
+
geometry.attributes.splatIndex.needsUpdate = true;
|
|
371
|
+
geometry.instanceCount = indexes.length;
|
|
372
|
+
target.ready = true;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
shared.worker.addEventListener('message', listener);
|
|
376
|
+
async function wait() {
|
|
377
|
+
while (true) {
|
|
378
|
+
const centerAndScaleTextureProperties = shared.gl.properties.get(shared.centerAndScaleTexture);
|
|
379
|
+
const covAndColorTextureProperties = shared.gl.properties.get(shared.covAndColorTexture);
|
|
380
|
+
if (centerAndScaleTextureProperties != null && centerAndScaleTextureProperties.__webglTexture && covAndColorTextureProperties != null && covAndColorTextureProperties.__webglTexture && shared.loadedVertexCount > 0) break;
|
|
381
|
+
await new Promise(resolve => setTimeout(resolve, 10));
|
|
382
|
+
}
|
|
383
|
+
target.ready = true;
|
|
384
|
+
}
|
|
385
|
+
wait();
|
|
386
|
+
return () => shared.worker.removeEventListener('message', listener);
|
|
387
|
+
}
|
|
388
|
+
function pushDataBuffer(shared, buffer, vertexCount) {
|
|
389
|
+
const context = shared.gl.getContext();
|
|
390
|
+
if (shared.loadedVertexCount + vertexCount > shared.maxVertexes) vertexCount = shared.maxVertexes - shared.loadedVertexCount;
|
|
391
|
+
if (vertexCount <= 0) throw 'Failed to parse file';
|
|
392
|
+
const u_buffer = new Uint8Array(buffer);
|
|
393
|
+
const f_buffer = new Float32Array(buffer);
|
|
394
|
+
const matrices = new Float32Array(vertexCount * 16);
|
|
395
|
+
const covAndColorData_uint8 = new Uint8Array(shared.covAndColorData.buffer);
|
|
396
|
+
const covAndColorData_int16 = new Int16Array(shared.covAndColorData.buffer);
|
|
397
|
+
for (let i = 0; i < vertexCount; i++) {
|
|
398
|
+
const quat = new THREE.Quaternion(-(u_buffer[32 * i + 28 + 1] - 128) / 128.0, (u_buffer[32 * i + 28 + 2] - 128) / 128.0, (u_buffer[32 * i + 28 + 3] - 128) / 128.0, -(u_buffer[32 * i + 28 + 0] - 128) / 128.0);
|
|
399
|
+
quat.invert();
|
|
400
|
+
const center = new THREE.Vector3(f_buffer[8 * i + 0], f_buffer[8 * i + 1], -f_buffer[8 * i + 2]);
|
|
401
|
+
const scale = new THREE.Vector3(f_buffer[8 * i + 3 + 0], f_buffer[8 * i + 3 + 1], f_buffer[8 * i + 3 + 2]);
|
|
402
|
+
const mtx = new THREE.Matrix4();
|
|
403
|
+
mtx.makeRotationFromQuaternion(quat);
|
|
404
|
+
mtx.transpose();
|
|
405
|
+
mtx.scale(scale);
|
|
406
|
+
const mtx_t = mtx.clone();
|
|
407
|
+
mtx.transpose();
|
|
408
|
+
mtx.premultiply(mtx_t);
|
|
409
|
+
mtx.setPosition(center);
|
|
410
|
+
const cov_indexes = [0, 1, 2, 5, 6, 10];
|
|
411
|
+
let max_value = 0.0;
|
|
412
|
+
for (let j = 0; j < cov_indexes.length; j++) if (Math.abs(mtx.elements[cov_indexes[j]]) > max_value) max_value = Math.abs(mtx.elements[cov_indexes[j]]);
|
|
413
|
+
let destOffset = shared.loadedVertexCount * 4 + i * 4;
|
|
414
|
+
shared.centerAndScaleData[destOffset + 0] = center.x;
|
|
415
|
+
shared.centerAndScaleData[destOffset + 1] = -center.y;
|
|
416
|
+
shared.centerAndScaleData[destOffset + 2] = center.z;
|
|
417
|
+
shared.centerAndScaleData[destOffset + 3] = max_value / 32767.0;
|
|
418
|
+
destOffset = shared.loadedVertexCount * 8 + i * 4 * 2;
|
|
419
|
+
for (let j = 0; j < cov_indexes.length; j++) covAndColorData_int16[destOffset + j] = mtx.elements[cov_indexes[j]] * 32767.0 / max_value;
|
|
420
|
+
|
|
421
|
+
// RGBA
|
|
422
|
+
destOffset = shared.loadedVertexCount * 16 + (i * 4 + 3) * 4;
|
|
423
|
+
const col = new THREE.Color(u_buffer[32 * i + 24 + 0] / 255, u_buffer[32 * i + 24 + 1] / 255, u_buffer[32 * i + 24 + 2] / 255);
|
|
424
|
+
col.convertSRGBToLinear();
|
|
425
|
+
covAndColorData_uint8[destOffset + 0] = col.r * 255;
|
|
426
|
+
covAndColorData_uint8[destOffset + 1] = col.g * 255;
|
|
427
|
+
covAndColorData_uint8[destOffset + 2] = col.b * 255;
|
|
428
|
+
covAndColorData_uint8[destOffset + 3] = u_buffer[32 * i + 24 + 3];
|
|
429
|
+
|
|
430
|
+
// Store scale and transparent to remove splat in sorting process
|
|
431
|
+
mtx.elements[15] = Math.max(scale.x, scale.y, scale.z) * u_buffer[32 * i + 24 + 3] / 255.0;
|
|
432
|
+
for (let j = 0; j < 16; j++) matrices[i * 16 + j] = mtx.elements[j];
|
|
433
|
+
}
|
|
434
|
+
while (vertexCount > 0) {
|
|
435
|
+
let width = 0;
|
|
436
|
+
let height = 0;
|
|
437
|
+
const xoffset = shared.loadedVertexCount % shared.bufferTextureWidth;
|
|
438
|
+
const yoffset = Math.floor(shared.loadedVertexCount / shared.bufferTextureWidth);
|
|
439
|
+
if (shared.loadedVertexCount % shared.bufferTextureWidth != 0) {
|
|
440
|
+
width = Math.min(shared.bufferTextureWidth, xoffset + vertexCount) - xoffset;
|
|
441
|
+
height = 1;
|
|
442
|
+
} else if (Math.floor(vertexCount / shared.bufferTextureWidth) > 0) {
|
|
443
|
+
width = shared.bufferTextureWidth;
|
|
444
|
+
height = Math.floor(vertexCount / shared.bufferTextureWidth);
|
|
445
|
+
} else {
|
|
446
|
+
width = vertexCount % shared.bufferTextureWidth;
|
|
447
|
+
height = 1;
|
|
448
|
+
}
|
|
449
|
+
const centerAndScaleTextureProperties = shared.gl.properties.get(shared.centerAndScaleTexture);
|
|
450
|
+
context.bindTexture(context.TEXTURE_2D, centerAndScaleTextureProperties.__webglTexture);
|
|
451
|
+
context.texSubImage2D(context.TEXTURE_2D, 0, xoffset, yoffset, width, height, context.RGBA, context.FLOAT, shared.centerAndScaleData, shared.loadedVertexCount * 4);
|
|
452
|
+
const covAndColorTextureProperties = shared.gl.properties.get(shared.covAndColorTexture);
|
|
453
|
+
context.bindTexture(context.TEXTURE_2D, covAndColorTextureProperties.__webglTexture);
|
|
454
|
+
context.texSubImage2D(context.TEXTURE_2D, 0, xoffset, yoffset, width, height,
|
|
455
|
+
// @ts-ignore
|
|
456
|
+
context.RGBA_INTEGER, context.UNSIGNED_INT, shared.covAndColorData, shared.loadedVertexCount * 4);
|
|
457
|
+
shared.gl.resetState();
|
|
458
|
+
shared.loadedVertexCount += width * height;
|
|
459
|
+
vertexCount -= width * height;
|
|
460
|
+
}
|
|
461
|
+
return matrices;
|
|
462
|
+
}
|
|
463
|
+
function Splat({
|
|
464
|
+
src,
|
|
465
|
+
toneMapped = false,
|
|
466
|
+
alphaTest = 0,
|
|
467
|
+
alphaHash = false,
|
|
468
|
+
chunkSize = 25000,
|
|
469
|
+
...props
|
|
470
|
+
}) {
|
|
471
|
+
extend({
|
|
472
|
+
SplatMaterial
|
|
473
|
+
});
|
|
474
|
+
const ref = React.useRef(null);
|
|
475
|
+
const gl = useThree(state => state.gl);
|
|
476
|
+
const camera = useThree(state => state.camera);
|
|
477
|
+
|
|
478
|
+
// Shared state, globally memoized, the same url re-uses the same daza
|
|
479
|
+
const shared = useLoader(SplatLoader, src, loader => {
|
|
480
|
+
loader.gl = gl;
|
|
481
|
+
loader.chunkSize = chunkSize;
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
// Listen to worker results, apply them to the target mesh
|
|
485
|
+
React.useLayoutEffect(() => shared.connect(ref.current), [src]);
|
|
486
|
+
// Update the worker
|
|
487
|
+
useFrame(() => shared.update(ref.current, camera, alphaHash));
|
|
488
|
+
return /*#__PURE__*/React.createElement("mesh", _extends({
|
|
489
|
+
ref: ref,
|
|
490
|
+
frustumCulled: false
|
|
491
|
+
}, props), /*#__PURE__*/React.createElement("splatMaterial", {
|
|
492
|
+
key: `${src}/${alphaTest}/${alphaHash}${SplatMaterial.key}`,
|
|
493
|
+
transparent: !alphaHash,
|
|
494
|
+
depthTest: true,
|
|
495
|
+
alphaTest: alphaHash ? 0 : alphaTest,
|
|
496
|
+
centerAndScaleTexture: shared.centerAndScaleTexture,
|
|
497
|
+
covAndColorTexture: shared.covAndColorTexture,
|
|
498
|
+
depthWrite: alphaHash ? true : alphaTest > 0,
|
|
499
|
+
blending: alphaHash ? THREE.NormalBlending : THREE.CustomBlending,
|
|
500
|
+
blendSrcAlpha: THREE.OneFactor,
|
|
501
|
+
alphaHash: !!alphaHash,
|
|
502
|
+
toneMapped: toneMapped
|
|
503
|
+
}));
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export { Splat };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("react"),r=require("three"),a=require("@react-three/fiber"),n=require("three-stdlib"),o=require("../materials/SpotLightMaterial.cjs.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function u(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}require("../helpers/constants.cjs.js");var l=i(e),s=u(t);function c({opacity:e=1,radiusTop:t,radiusBottom:n,depthBuffer:i,color:u="white",distance:l=5,angle:c=.15,attenuation:p=5,anglePower:d=5}){const m=s.useRef(null),h=a.useThree((e=>e.size)),f=a.useThree((e=>e.camera)),g=a.useThree((e=>e.viewport.dpr)),[v]=s.useState((()=>new o.SpotLightMaterial)),[w]=s.useState((()=>new r.Vector3));t=void 0===t?.1:t,n=void 0===n?7*c:n,a.useFrame((()=>{v.uniforms.spotPosition.value.copy(m.current.getWorldPosition(w)),m.current.lookAt(m.current.parent.target.getWorldPosition(w))}));const S=s.useMemo((()=>{const e=new r.CylinderGeometry(t,n,l,128,64,!0);return e.applyMatrix4((new r.Matrix4).makeTranslation(0,-l/2,0)),e.applyMatrix4((new r.Matrix4).makeRotationX(-Math.PI/2)),e}),[l,t,n]);return s.createElement(s.Fragment,null,s.createElement("mesh",{ref:m,geometry:S,raycast:()=>null},s.createElement("primitive",{object:v,attach:"material","uniforms-opacity-value":e,"uniforms-lightColor-value":u,"uniforms-attenuation-value":p,"uniforms-anglePower-value":d,"uniforms-depth-value":i,"uniforms-cameraNear-value":f.near,"uniforms-cameraFar-value":f.far,"uniforms-resolution-value":i?[h.width*g,h.height*g]:[0,0]})))}function p(e,t,n,o,i){const[[u,l]]=s.useState((()=>[new r.Vector3,new r.Vector3]));s.useLayoutEffect((()=>{if(!(null==(t=e.current)?void 0:t.isSpotLight))throw new Error("SpotlightShadow must be a child of a SpotLight");var t;e.current.shadow.mapSize.set(n,o),e.current.shadow.needsUpdate=!0}),[e,n,o]),a.useFrame((()=>{if(!e.current)return;const r=e.current.position,a=e.current.target.position;l.copy(a).sub(r);var n=l.length();l.normalize().multiplyScalar(n*i),u.copy(r).add(l),t.current.position.copy(u),t.current.lookAt(e.current.target.position)}))}function d({distance:e=.4,alphaTest:t=.5,map:o,shader:i="#define GLSLIFY 1\nvarying vec2 vUv;uniform sampler2D uShadowMap;uniform float uTime;void main(){vec3 color=texture2D(uShadowMap,vUv).xyz;gl_FragColor=vec4(color,1.);}",width:u=512,height:l=512,scale:c=1,children:d,...m}){const h=s.useRef(null),f=m.spotlightRef,g=m.debug;p(f,h,u,l,e);const v=s.useMemo((()=>new r.WebGLRenderTarget(u,l,{format:r.RGBAFormat,stencilBuffer:!1})),[u,l]),w=s.useRef({uShadowMap:{value:o},uTime:{value:0}});s.useEffect((()=>{w.current.uShadowMap.value=o}),[o]);const S=s.useMemo((()=>new n.FullScreenQuad(new r.ShaderMaterial({uniforms:w.current,vertexShader:"\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:i}))),[i]);return s.useEffect((()=>()=>{S.material.dispose(),S.dispose()}),[S]),s.useEffect((()=>()=>v.dispose()),[v]),a.useFrame((({gl:e},t)=>{w.current.uTime.value+=t,e.setRenderTarget(v),S.render(e),e.setRenderTarget(null)})),s.createElement(s.Fragment,null,s.createElement("mesh",{ref:h,scale:c,castShadow:!0},s.createElement("planeGeometry",null),s.createElement("meshBasicMaterial",{transparent:!0,side:r.DoubleSide,alphaTest:t,alphaMap:v.texture,"alphaMap-wrapS":r.RepeatWrapping,"alphaMap-wrapT":r.RepeatWrapping,opacity:g?1:0},d)))}function m({distance:e=.4,alphaTest:t=.5,map:a,width:n=512,height:o=512,scale:i,children:u,...l}){const c=s.useRef(null),d=l.spotlightRef,m=l.debug;return p(d,c,n,o,e),s.createElement(s.Fragment,null,s.createElement("mesh",{ref:c,scale:i,castShadow:!0},s.createElement("planeGeometry",null),s.createElement("meshBasicMaterial",{transparent:!0,side:r.DoubleSide,alphaTest:t,alphaMap:a,"alphaMap-wrapS":r.RepeatWrapping,"alphaMap-wrapT":r.RepeatWrapping,opacity:m?1:0},u)))}const h=s.forwardRef((({opacity:e=1,radiusTop:t,radiusBottom:r,depthBuffer:a,color:n="white",distance:o=5,angle:i=.15,attenuation:u=5,anglePower:p=5,volumetric:d=!0,debug:m=!1,children:h,...f},g)=>{const v=s.useRef(null);return s.useImperativeHandle(g,(()=>v.current),[]),s.createElement("group",null,m&&v.current&&s.createElement("spotLightHelper",{args:[v.current]}),s.createElement("spotLight",l.default({ref:v,angle:i,color:n,distance:o,castShadow:!0},f),d&&s.createElement(c,{debug:m,opacity:e,radiusTop:t,radiusBottom:r,depthBuffer:a,color:n,distance:o,angle:i,attenuation:u,anglePower:p})),h&&s.cloneElement(h,{spotlightRef:v,debug:m}))}));exports.SpotLight=h,exports.SpotLightShadow=function(e){return e.shader?s.createElement(d,e):s.createElement(m,e)};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DepthTexture, SpotLight as SpotLightImpl, Texture } from 'three';
|
|
3
|
+
import { ThreeElements } from '@react-three/fiber';
|
|
4
|
+
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
5
|
+
export type SpotLightProps = Omit<ThreeElements['spotLight'], 'ref'> & {
|
|
6
|
+
depthBuffer?: DepthTexture;
|
|
7
|
+
attenuation?: number;
|
|
8
|
+
anglePower?: number;
|
|
9
|
+
radiusTop?: number;
|
|
10
|
+
radiusBottom?: number;
|
|
11
|
+
opacity?: number;
|
|
12
|
+
color?: string | number;
|
|
13
|
+
volumetric?: boolean;
|
|
14
|
+
debug?: boolean;
|
|
15
|
+
};
|
|
16
|
+
interface ShadowMeshProps {
|
|
17
|
+
distance?: number;
|
|
18
|
+
alphaTest?: number;
|
|
19
|
+
scale?: number;
|
|
20
|
+
map?: Texture;
|
|
21
|
+
shader?: string;
|
|
22
|
+
width?: number;
|
|
23
|
+
height?: number;
|
|
24
|
+
}
|
|
25
|
+
export declare function SpotLightShadow(props: React.PropsWithChildren<ShadowMeshProps>): React.JSX.Element;
|
|
26
|
+
declare const SpotLight: ForwardRefComponent<React.PropsWithChildren<SpotLightProps>, SpotLightImpl>;
|
|
27
|
+
export { SpotLight };
|