@needle-tools/three 0.145.4 → 0.146.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/three.cjs +32586 -35951
- package/build/three.js +32600 -35965
- package/build/three.min.js +6 -7
- package/build/three.module.js +1547 -1154
- package/examples/js/animation/AnimationClipCreator.js +0 -8
- package/examples/js/animation/CCDIKSolver.js +49 -66
- package/examples/js/animation/MMDAnimationHelper.js +66 -137
- package/examples/js/animation/MMDPhysics.js +70 -134
- package/examples/js/cameras/CinematicCamera.js +33 -22
- package/examples/js/controls/ArcballControls.js +138 -405
- package/examples/js/controls/DragControls.js +8 -33
- package/examples/js/controls/FirstPersonControls.js +32 -54
- package/examples/js/controls/FlyControls.js +29 -55
- package/examples/js/controls/OrbitControls.js +85 -95
- package/examples/js/controls/PointerLockControls.js +5 -14
- package/examples/js/controls/TrackballControls.js +33 -86
- package/examples/js/controls/TransformControls.js +84 -169
- package/examples/js/csm/CSM.js +4 -39
- package/examples/js/csm/CSMFrustum.js +3 -9
- package/examples/js/csm/CSMHelper.js +24 -4
- package/examples/js/csm/CSMShader.js +2 -6
- package/examples/js/curves/CurveExtras.js +27 -27
- package/examples/js/curves/NURBSCurve.js +4 -16
- package/examples/js/curves/NURBSSurface.js +3 -9
- package/examples/js/curves/NURBSUtils.js +8 -45
- package/examples/js/effects/AnaglyphEffect.js +4 -18
- package/examples/js/effects/AsciiEffect.js +32 -31
- package/examples/js/effects/OutlineEffect.js +26 -30
- package/examples/js/effects/ParallaxBarrierEffect.js +0 -13
- package/examples/js/effects/PeppersGhostEffect.js +12 -39
- package/examples/js/effects/StereoEffect.js +0 -4
- package/examples/js/environments/RoomEnvironment.js +12 -10
- package/examples/js/exporters/ColladaExporter.js +48 -65
- package/examples/js/exporters/DRACOExporter.js +22 -22
- package/examples/js/exporters/EXRExporter.js +15 -18
- package/examples/js/exporters/GLTFExporter.js +143 -261
- package/examples/js/exporters/MMDExporter.js +5 -12
- package/examples/js/exporters/OBJExporter.js +42 -33
- package/examples/js/exporters/PLYExporter.js +38 -33
- package/examples/js/exporters/STLExporter.js +5 -7
- package/examples/js/exporters/USDZExporter.js +110 -25
- package/examples/js/geometries/BoxLineGeometry.js +0 -1
- package/examples/js/geometries/ConvexGeometry.js +11 -6
- package/examples/js/geometries/DecalGeometry.js +53 -20
- package/examples/js/geometries/LightningStrike.js +54 -67
- package/examples/js/geometries/ParametricGeometries.js +8 -7
- package/examples/js/geometries/ParametricGeometry.js +25 -12
- package/examples/js/geometries/RoundedBoxGeometry.js +21 -19
- package/examples/js/geometries/TeapotGeometry.js +54 -50
- package/examples/js/geometries/TextGeometry.js +6 -4
- package/examples/js/helpers/LightProbeHelper.js +1 -2
- package/examples/js/helpers/OctreeHelper.js +22 -20
- package/examples/js/helpers/PositionalAudioHelper.js +8 -6
- package/examples/js/helpers/RectAreaLightHelper.js +6 -7
- package/examples/js/helpers/VertexNormalsHelper.js +15 -13
- package/examples/js/helpers/VertexTangentsHelper.js +15 -9
- package/examples/js/helpers/ViewHelper.js +31 -16
- package/examples/js/interactive/HTMLMesh.js +22 -33
- package/examples/js/interactive/InteractiveGroup.js +6 -12
- package/examples/js/interactive/SelectionBox.js +3 -70
- package/examples/js/interactive/SelectionHelper.js +0 -8
- package/examples/js/lights/LightProbeGenerator.js +32 -39
- package/examples/js/lights/RectAreaLightUniformsLib.js +5 -1
- package/examples/js/lines/LineGeometry.js +3 -5
- package/examples/js/lines/LineMaterial.js +4 -11
- package/examples/js/lines/LineSegments2.js +38 -89
- package/examples/js/lines/LineSegmentsGeometry.js +7 -28
- package/examples/js/lines/Wireframe.js +2 -7
- package/examples/js/lines/WireframeGeometry2.js +3 -1
- package/examples/js/loaders/3DMLoader.js +58 -155
- package/examples/js/loaders/3MFLoader.js +72 -106
- package/examples/js/loaders/AMFLoader.js +0 -25
- package/examples/js/loaders/BVHLoader.js +44 -43
- package/examples/js/loaders/BasisTextureLoader.js +16 -46
- package/examples/js/loaders/ColladaLoader.js +201 -359
- package/examples/js/loaders/DDSLoader.js +24 -25
- package/examples/js/loaders/DRACOLoader.js +29 -66
- package/examples/js/loaders/EXRLoader.js +67 -164
- package/examples/js/loaders/FBXLoader.js +286 -441
- package/examples/js/loaders/FontLoader.js +6 -15
- package/examples/js/loaders/GCodeLoader.js +15 -16
- package/examples/js/loaders/GLTFLoader.js +354 -405
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -6
- package/examples/js/loaders/KMZLoader.js +3 -7
- package/examples/js/loaders/KTXLoader.js +12 -30
- package/examples/js/loaders/LDrawLoader.js +178 -289
- package/examples/js/loaders/LUT3dlLoader.js +7 -11
- package/examples/js/loaders/LUTCubeLoader.js +0 -8
- package/examples/js/loaders/LWOLoader.js +59 -124
- package/examples/js/loaders/LogLuvLoader.js +27 -77
- package/examples/js/loaders/LottieLoader.js +4 -4
- package/examples/js/loaders/MD2Loader.js +26 -27
- package/examples/js/loaders/MDDLoader.js +6 -10
- package/examples/js/loaders/MMDLoader.js +180 -189
- package/examples/js/loaders/MTLLoader.js +18 -47
- package/examples/js/loaders/MaterialXLoader.js +392 -0
- package/examples/js/loaders/NRRDLoader.js +44 -84
- package/examples/js/loaders/OBJLoader.js +50 -65
- package/examples/js/loaders/PCDLoader.js +34 -29
- package/examples/js/loaders/PDBLoader.js +17 -13
- package/examples/js/loaders/PLYLoader.js +9 -39
- package/examples/js/loaders/PRWMLoader.js +11 -22
- package/examples/js/loaders/PVRLoader.js +7 -16
- package/examples/js/loaders/RGBELoader.js +36 -61
- package/examples/js/loaders/RGBMLoader.js +26 -87
- package/examples/js/loaders/STLLoader.js +20 -27
- package/examples/js/loaders/SVGLoader.js +361 -233
- package/examples/js/loaders/TDSLoader.js +81 -118
- package/examples/js/loaders/TGALoader.js +39 -41
- package/examples/js/loaders/TIFFLoader.js +0 -1
- package/examples/js/loaders/TTFLoader.js +0 -8
- package/examples/js/loaders/TiltLoader.js +14 -15
- package/examples/js/loaders/VOXLoader.js +8 -16
- package/examples/js/loaders/VRMLLoader.js +243 -340
- package/examples/js/loaders/VTKLoader.js +101 -118
- package/examples/js/loaders/XYZLoader.js +2 -4
- package/examples/js/loaders/lwo/IFFParser.js +55 -136
- package/examples/js/loaders/lwo/LWO2Parser.js +32 -83
- package/examples/js/loaders/lwo/LWO3Parser.js +31 -73
- package/examples/js/materials/MeshGouraudMaterial.js +15 -13
- package/examples/js/math/Capsule.js +0 -17
- package/examples/js/math/ColorConverter.js +3 -3
- package/examples/js/math/ConvexHull.js +183 -139
- package/examples/js/math/ImprovedNoise.js +1 -1
- package/examples/js/math/Lut.js +8 -15
- package/examples/js/math/MeshSurfaceSampler.js +6 -28
- package/examples/js/math/OBB.js +90 -49
- package/examples/js/math/Octree.js +2 -57
- package/examples/js/math/SimplexNoise.js +74 -88
- package/examples/js/misc/ConvexObjectBreaker.js +37 -48
- package/examples/js/misc/GPUComputationRenderer.js +14 -18
- package/examples/js/misc/Gyroscope.js +5 -9
- package/examples/js/misc/MD2Character.js +14 -23
- package/examples/js/misc/MD2CharacterComplex.js +73 -54
- package/examples/js/misc/MorphAnimMesh.js +0 -6
- package/examples/js/misc/MorphBlendMesh.js +3 -30
- package/examples/js/misc/ProgressiveLightMap.js +47 -43
- package/examples/js/misc/RollerCoaster.js +17 -24
- package/examples/js/misc/TubePainter.js +18 -12
- package/examples/js/misc/Volume.js +16 -45
- package/examples/js/misc/VolumeSlice.js +14 -24
- package/examples/js/modifiers/CurveModifier.js +19 -21
- package/examples/js/modifiers/EdgeSplitModifier.js +0 -30
- package/examples/js/modifiers/SimplifyModifier.js +56 -59
- package/examples/js/modifiers/TessellateModifier.js +2 -9
- package/examples/js/objects/GroundProjectedEnv.js +2 -14
- package/examples/js/objects/Lensflare.js +47 -38
- package/examples/js/objects/LightningStorm.js +10 -13
- package/examples/js/objects/MarchingCubes.js +80 -59
- package/examples/js/objects/Reflector.js +22 -20
- package/examples/js/objects/ReflectorForSSRPass.js +19 -23
- package/examples/js/objects/Refractor.js +52 -30
- package/examples/js/objects/ShadowMesh.js +1 -2
- package/examples/js/objects/Sky.js +2 -7
- package/examples/js/objects/Water.js +23 -18
- package/examples/js/objects/Water2.js +20 -19
- package/examples/js/physics/AmmoPhysics.js +23 -20
- package/examples/js/physics/OimoPhysics.js +19 -17
- package/examples/js/postprocessing/AdaptiveToneMappingPass.js +13 -20
- package/examples/js/postprocessing/AfterimagePass.js +19 -12
- package/examples/js/postprocessing/BloomPass.js +38 -17
- package/examples/js/postprocessing/BokehPass.js +29 -12
- package/examples/js/postprocessing/ClearPass.js +1 -6
- package/examples/js/postprocessing/CubeTexturePass.js +12 -9
- package/examples/js/postprocessing/DotScreenPass.js +7 -5
- package/examples/js/postprocessing/EffectComposer.js +25 -32
- package/examples/js/postprocessing/FilmPass.js +7 -5
- package/examples/js/postprocessing/GlitchPass.js +10 -11
- package/examples/js/postprocessing/HalftonePass.js +9 -9
- package/examples/js/postprocessing/LUTPass.js +2 -15
- package/examples/js/postprocessing/MaskPass.js +20 -17
- package/examples/js/postprocessing/OutlinePass.js +45 -36
- package/examples/js/postprocessing/Pass.js +11 -14
- package/examples/js/postprocessing/RenderPass.js +3 -7
- package/examples/js/postprocessing/SAOPass.js +40 -32
- package/examples/js/postprocessing/SMAAPass.js +34 -17
- package/examples/js/postprocessing/SSAARenderPass.js +14 -14
- package/examples/js/postprocessing/SSAOPass.js +56 -42
- package/examples/js/postprocessing/SSRPass.js +78 -61
- package/examples/js/postprocessing/SavePass.js +14 -6
- package/examples/js/postprocessing/ShaderPass.js +9 -8
- package/examples/js/postprocessing/TAARenderPass.js +11 -9
- package/examples/js/postprocessing/TexturePass.js +7 -4
- package/examples/js/postprocessing/UnrealBloomPass.js +43 -25
- package/examples/js/renderers/CSS2DRenderer.js +2 -21
- package/examples/js/renderers/CSS3DRenderer.js +3 -24
- package/examples/js/renderers/Projector.js +29 -85
- package/examples/js/renderers/SVGRenderer.js +4 -50
- package/examples/js/shaders/ACESFilmicToneMappingShader.js +3 -6
- package/examples/js/shaders/AfterimageShader.js +3 -6
- package/examples/js/shaders/BasicShader.js +3 -6
- package/examples/js/shaders/BleachBypassShader.js +3 -6
- package/examples/js/shaders/BlendShader.js +3 -6
- package/examples/js/shaders/BokehShader.js +3 -6
- package/examples/js/shaders/BokehShader2.js +4 -13
- package/examples/js/shaders/BrightnessContrastShader.js +3 -6
- package/examples/js/shaders/ColorCorrectionShader.js +2 -6
- package/examples/js/shaders/ColorifyShader.js +2 -6
- package/examples/js/shaders/ConvolutionShader.js +5 -10
- package/examples/js/shaders/CopyShader.js +3 -6
- package/examples/js/shaders/DOFMipMapShader.js +3 -6
- package/examples/js/shaders/DepthLimitedBlurShader.js +2 -9
- package/examples/js/shaders/DigitalGlitch.js +3 -6
- package/examples/js/shaders/DotScreenShader.js +2 -6
- package/examples/js/shaders/FXAAShader.js +1 -3
- package/examples/js/shaders/FilmShader.js +3 -6
- package/examples/js/shaders/FocusShader.js +3 -6
- package/examples/js/shaders/FreiChenShader.js +2 -6
- package/examples/js/shaders/GammaCorrectionShader.js +3 -6
- package/examples/js/shaders/GodRaysShader.js +11 -24
- package/examples/js/shaders/HalftoneShader.js +3 -6
- package/examples/js/shaders/HorizontalBlurShader.js +3 -6
- package/examples/js/shaders/HorizontalTiltShiftShader.js +3 -6
- package/examples/js/shaders/HueSaturationShader.js +3 -6
- package/examples/js/shaders/KaleidoShader.js +3 -6
- package/examples/js/shaders/LuminosityHighPassShader.js +2 -6
- package/examples/js/shaders/LuminosityShader.js +3 -6
- package/examples/js/shaders/MMDToonShader.js +2 -6
- package/examples/js/shaders/MirrorShader.js +3 -6
- package/examples/js/shaders/NormalMapShader.js +2 -6
- package/examples/js/shaders/RGBShiftShader.js +3 -6
- package/examples/js/shaders/SAOShader.js +2 -6
- package/examples/js/shaders/SMAAShader.js +6 -18
- package/examples/js/shaders/SSAOShader.js +2 -6
- package/examples/js/shaders/SSRShader.js +6 -18
- package/examples/js/shaders/SepiaShader.js +3 -6
- package/examples/js/shaders/SobelOperatorShader.js +2 -6
- package/examples/js/shaders/TechnicolorShader.js +3 -6
- package/examples/js/shaders/ToneMapShader.js +3 -6
- package/examples/js/shaders/ToonShader.js +8 -24
- package/examples/js/shaders/TriangleBlurShader.js +2 -6
- package/examples/js/shaders/UnpackDepthRGBAShader.js +3 -6
- package/examples/js/shaders/VelocityShader.js +126 -0
- package/examples/js/shaders/VerticalBlurShader.js +3 -6
- package/examples/js/shaders/VerticalTiltShiftShader.js +3 -6
- package/examples/js/shaders/VignetteShader.js +3 -6
- package/examples/js/shaders/VolumeShader.js +2 -6
- package/examples/js/shaders/WaterRefractionShader.js +2 -6
- package/examples/js/textures/FlakesTexture.js +0 -1
- package/examples/js/utils/BufferGeometryUtils.js +234 -168
- package/examples/js/utils/CameraUtils.js +5 -20
- package/examples/js/utils/GPUStatsPanel.js +3 -12
- package/examples/js/utils/GeometryCompressionUtils.js +19 -44
- package/examples/js/utils/GeometryUtils.js +13 -18
- package/examples/js/utils/LDrawUtils.js +8 -11
- package/examples/js/utils/PackedPhongMaterial.js +6 -4
- package/examples/js/utils/SceneUtils.js +117 -6
- package/examples/js/utils/ShadowMapViewer.js +17 -14
- package/examples/js/utils/SkeletonUtils.js +13 -27
- package/examples/js/utils/UVsDebug.js +20 -12
- package/examples/js/utils/WorkerPool.js +1 -11
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/capabilities/WebGPU.js +3 -1
- package/examples/jsm/controls/OrbitControls.js +44 -4
- package/examples/jsm/exporters/GLTFExporter.js +17 -131
- package/examples/jsm/exporters/USDZExporter.js +75 -19
- package/examples/jsm/interactive/HTMLMesh.js +2 -0
- package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -2
- package/examples/jsm/loaders/ColladaLoader.js +28 -0
- package/examples/jsm/loaders/FBXLoader.js +16 -2
- package/examples/jsm/loaders/GLTFLoader.js +204 -377
- package/examples/jsm/loaders/KTX2Loader.js +68 -29
- package/examples/jsm/loaders/LDrawLoader.js +14 -13
- package/examples/jsm/loaders/LottieLoader.js +4 -2
- package/examples/jsm/loaders/MaterialXLoader.js +728 -0
- package/examples/jsm/loaders/PCDLoader.js +1 -1
- package/examples/jsm/loaders/PLYLoader.js +68 -16
- package/examples/jsm/loaders/SVGLoader.js +227 -14
- package/examples/jsm/loaders/USDZLoader.js +31 -16
- package/examples/jsm/nodes/Nodes.js +14 -2
- package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +6 -0
- package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/SkinningNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +1 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +36 -4
- package/examples/jsm/nodes/core/NodeFrame.js +2 -2
- package/examples/jsm/nodes/core/NodeVarying.js +7 -4
- package/examples/jsm/nodes/core/VaryingNode.js +6 -4
- package/examples/jsm/nodes/core/constants.js +13 -13
- package/examples/jsm/nodes/display/PosterizeNode.js +25 -0
- package/examples/jsm/nodes/display/ViewportNode.js +106 -0
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +3 -1
- package/examples/jsm/nodes/materials/Materials.js +9 -7
- package/examples/jsm/nodes/materials/NodeMaterial.js +9 -1
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +6 -2
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +18 -0
- package/examples/jsm/nodes/math/MathNode.js +5 -0
- package/examples/jsm/nodes/math/OperatorNode.js +6 -1
- package/examples/jsm/nodes/shadernode/ShaderNode.js +26 -13
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +2 -0
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +18 -0
- package/examples/jsm/nodes/utils/EquirectUVNode.js +27 -0
- package/examples/jsm/nodes/utils/JoinNode.js +8 -2
- package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -4
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +8 -10
- package/examples/jsm/nodes/utils/TimerNode.js +1 -1
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +51 -0
- package/examples/jsm/postprocessing/AfterimagePass.js +17 -4
- package/examples/jsm/postprocessing/BloomPass.js +22 -3
- package/examples/jsm/postprocessing/BokehPass.js +18 -4
- package/examples/jsm/postprocessing/CubeTexturePass.js +12 -5
- package/examples/jsm/postprocessing/DotScreenPass.js +8 -0
- package/examples/jsm/postprocessing/EffectComposer.js +9 -0
- package/examples/jsm/postprocessing/FilmPass.js +8 -0
- package/examples/jsm/postprocessing/GlitchPass.js +13 -1
- package/examples/jsm/postprocessing/HalftonePass.js +8 -0
- package/examples/jsm/postprocessing/OutlinePass.js +10 -0
- package/examples/jsm/postprocessing/Pass.js +2 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +234 -0
- package/examples/jsm/postprocessing/SAOPass.js +20 -0
- package/examples/jsm/postprocessing/SMAAPass.js +16 -0
- package/examples/jsm/postprocessing/SSAARenderPass.js +4 -0
- package/examples/jsm/postprocessing/SavePass.js +17 -1
- package/examples/jsm/postprocessing/ShaderPass.js +8 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +9 -0
- package/examples/jsm/postprocessing/TexturePass.js +8 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +16 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +39 -16
- package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +58 -0
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +63 -5
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +36 -7
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +47 -12
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +35 -5
- package/examples/jsm/shaders/MMDToonShader.js +0 -2
- package/examples/jsm/shaders/VelocityShader.js +128 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +130 -6
- package/examples/jsm/utils/SceneUtils.js +129 -4
- package/examples/jsm/utils/TextureUtils.js +85 -0
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/examples/jsm/webxr/XRHandMeshModel.js +6 -3
- package/package.json +11 -12
- package/src/Three.js +1 -0
- package/src/audio/AudioContext.js +5 -5
- package/src/cameras/CubeCamera.js +14 -14
- package/src/constants.js +1 -1
- package/src/core/InstancedBufferGeometry.js +1 -7
- package/src/extras/Earcut.js +67 -67
- package/src/helpers/DirectionalLightHelper.js +5 -1
- package/src/helpers/HemisphereLightHelper.js +4 -1
- package/src/helpers/PointLightHelper.js +2 -1
- package/src/helpers/SpotLightHelper.js +4 -2
- package/src/lights/PointLight.js +2 -2
- package/src/lights/SpotLight.js +2 -2
- package/src/loaders/FileLoader.js +4 -1
- package/src/loaders/ObjectLoader.js +5 -1
- package/src/materials/Material.js +1 -1
- package/src/math/Color.js +5 -5
- package/src/math/Matrix3.js +53 -18
- package/src/math/Ray.js +2 -5
- package/src/math/Sphere.js +19 -26
- package/src/objects/InstancedMesh.js +7 -0
- package/src/objects/LOD.js +25 -6
- package/src/renderers/WebGL3DRenderTarget.js +1 -1
- package/src/renderers/WebGLArrayRenderTarget.js +1 -1
- package/src/renderers/WebGLCubeRenderTarget.js +1 -1
- package/src/renderers/WebGLMultipleRenderTargets.js +1 -1
- package/src/renderers/WebGLRenderTarget.js +1 -1
- package/src/renderers/WebGLRenderer.js +36 -62
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk.js +3 -0
- package/src/renderers/shaders/ShaderLib/background.glsl.js +7 -2
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +20 -6
- package/src/renderers/shaders/UniformsLib.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +15 -0
- package/src/renderers/webgl/WebGLAttributes.js +2 -0
- package/src/renderers/webgl/WebGLBackground.js +15 -7
- package/src/renderers/webgl/WebGLLights.js +0 -4
- package/src/renderers/webgl/WebGLMaterials.js +2 -1
- package/src/renderers/webgl/WebGLShadowMap.js +3 -1
- package/src/renderers/webgl/WebGLState.js +31 -1
- package/src/renderers/webgl/WebGLTextures.js +71 -18
- package/src/renderers/webgl/WebGLUniforms.js +116 -20
- package/src/renderers/webgl/WebGLUtils.js +1 -1
- package/src/renderers/webxr/WebXRController.js +46 -13
- package/src/renderers/webxr/WebXRManager.js +85 -3
- package/src/scenes/Scene.js +8 -0
- package/src/textures/CompressedArrayTexture.js +18 -0
- package/examples/js/libs/lottie_canvas.js +0 -12751
- package/examples/js/shaders/PixelShader.js +0 -51
- package/examples/jsm/shaders/PixelShader.js +0 -44
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
* @param {string} type The type of data (uint8, uint16, ...)
|
|
13
13
|
* @param {ArrayBuffer} arrayBuffer The buffer with volume data
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
15
|
class Volume {
|
|
17
16
|
|
|
18
17
|
constructor( xLength, yLength, zLength, type, arrayBuffer ) {
|
|
@@ -26,17 +25,14 @@
|
|
|
26
25
|
/**
|
|
27
26
|
* @member {number} yLength Height of the volume in the IJK coordinate system
|
|
28
27
|
*/
|
|
29
|
-
|
|
30
28
|
this.yLength = Number( yLength ) || 1;
|
|
31
29
|
/**
|
|
32
30
|
* @member {number} zLength Depth of the volume in the IJK coordinate system
|
|
33
31
|
*/
|
|
34
|
-
|
|
35
32
|
this.zLength = Number( zLength ) || 1;
|
|
36
33
|
/**
|
|
37
34
|
* @member {Array<string>} The order of the Axis dictated by the NRRD header
|
|
38
35
|
*/
|
|
39
|
-
|
|
40
36
|
this.axisOrder = [ 'x', 'y', 'z' ];
|
|
41
37
|
/**
|
|
42
38
|
* @member {TypedArray} data Data of the volume
|
|
@@ -51,14 +47,12 @@
|
|
|
51
47
|
case 'uint8_t':
|
|
52
48
|
this.data = new Uint8Array( arrayBuffer );
|
|
53
49
|
break;
|
|
54
|
-
|
|
55
50
|
case 'Int8':
|
|
56
51
|
case 'int8':
|
|
57
52
|
case 'signed char':
|
|
58
53
|
case 'int8_t':
|
|
59
54
|
this.data = new Int8Array( arrayBuffer );
|
|
60
55
|
break;
|
|
61
|
-
|
|
62
56
|
case 'Int16':
|
|
63
57
|
case 'int16':
|
|
64
58
|
case 'short':
|
|
@@ -68,7 +62,6 @@
|
|
|
68
62
|
case 'int16_t':
|
|
69
63
|
this.data = new Int16Array( arrayBuffer );
|
|
70
64
|
break;
|
|
71
|
-
|
|
72
65
|
case 'Uint16':
|
|
73
66
|
case 'uint16':
|
|
74
67
|
case 'ushort':
|
|
@@ -77,7 +70,6 @@
|
|
|
77
70
|
case 'uint16_t':
|
|
78
71
|
this.data = new Uint16Array( arrayBuffer );
|
|
79
72
|
break;
|
|
80
|
-
|
|
81
73
|
case 'Int32':
|
|
82
74
|
case 'int32':
|
|
83
75
|
case 'int':
|
|
@@ -85,7 +77,6 @@
|
|
|
85
77
|
case 'int32_t':
|
|
86
78
|
this.data = new Int32Array( arrayBuffer );
|
|
87
79
|
break;
|
|
88
|
-
|
|
89
80
|
case 'Uint32':
|
|
90
81
|
case 'uint32':
|
|
91
82
|
case 'uint':
|
|
@@ -93,7 +84,6 @@
|
|
|
93
84
|
case 'uint32_t':
|
|
94
85
|
this.data = new Uint32Array( arrayBuffer );
|
|
95
86
|
break;
|
|
96
|
-
|
|
97
87
|
case 'longlong':
|
|
98
88
|
case 'long long':
|
|
99
89
|
case 'long long int':
|
|
@@ -108,19 +98,16 @@
|
|
|
108
98
|
case 'uint64_t':
|
|
109
99
|
throw new Error( 'Error in Volume constructor : this type is not supported in JavaScript' );
|
|
110
100
|
break;
|
|
111
|
-
|
|
112
101
|
case 'Float32':
|
|
113
102
|
case 'float32':
|
|
114
103
|
case 'float':
|
|
115
104
|
this.data = new Float32Array( arrayBuffer );
|
|
116
105
|
break;
|
|
117
|
-
|
|
118
106
|
case 'Float64':
|
|
119
107
|
case 'float64':
|
|
120
108
|
case 'double':
|
|
121
109
|
this.data = new Float64Array( arrayBuffer );
|
|
122
110
|
break;
|
|
123
|
-
|
|
124
111
|
default:
|
|
125
112
|
this.data = new Uint8Array( arrayBuffer );
|
|
126
113
|
|
|
@@ -133,32 +120,27 @@
|
|
|
133
120
|
}
|
|
134
121
|
|
|
135
122
|
}
|
|
123
|
+
|
|
136
124
|
/**
|
|
137
125
|
* @member {Array} spacing Spacing to apply to the volume from IJK to RAS coordinate system
|
|
138
126
|
*/
|
|
139
|
-
|
|
140
|
-
|
|
141
127
|
this.spacing = [ 1, 1, 1 ];
|
|
142
128
|
/**
|
|
143
129
|
* @member {Array} offset Offset of the volume in the RAS coordinate system
|
|
144
130
|
*/
|
|
145
|
-
|
|
146
131
|
this.offset = [ 0, 0, 0 ];
|
|
147
132
|
/**
|
|
148
133
|
* @member {Martrix3} matrix The IJK to RAS matrix
|
|
149
134
|
*/
|
|
150
|
-
|
|
151
135
|
this.matrix = new THREE.Matrix3();
|
|
152
136
|
this.matrix.identity();
|
|
153
137
|
/**
|
|
154
138
|
* @member {Martrix3} inverseMatrix The RAS to IJK matrix
|
|
155
139
|
*/
|
|
156
|
-
|
|
157
140
|
/**
|
|
158
141
|
* @member {number} lowerThreshold The voxels with values under this threshold won't appear in the slices.
|
|
159
142
|
* If changed, geometryNeedsUpdate is automatically set to true on all the slices associated to this volume
|
|
160
143
|
*/
|
|
161
|
-
|
|
162
144
|
let lowerThreshold = - Infinity;
|
|
163
145
|
Object.defineProperty( this, 'lowerThreshold', {
|
|
164
146
|
get: function () {
|
|
@@ -181,7 +163,6 @@
|
|
|
181
163
|
* @member {number} upperThreshold The voxels with values over this threshold won't appear in the slices.
|
|
182
164
|
* If changed, geometryNeedsUpdate is automatically set to true on all the slices associated to this volume
|
|
183
165
|
*/
|
|
184
|
-
|
|
185
166
|
let upperThreshold = Infinity;
|
|
186
167
|
Object.defineProperty( this, 'upperThreshold', {
|
|
187
168
|
get: function () {
|
|
@@ -200,16 +181,18 @@
|
|
|
200
181
|
|
|
201
182
|
}
|
|
202
183
|
} );
|
|
184
|
+
|
|
203
185
|
/**
|
|
204
186
|
* @member {Array} sliceList The list of all the slices associated to this volume
|
|
205
187
|
*/
|
|
206
|
-
|
|
207
188
|
this.sliceList = [];
|
|
189
|
+
|
|
208
190
|
/**
|
|
209
191
|
* @member {Array} RASDimensions This array holds the dimensions of the volume in the RAS space
|
|
210
192
|
*/
|
|
211
193
|
|
|
212
194
|
}
|
|
195
|
+
|
|
213
196
|
/**
|
|
214
197
|
* @member {Function} getData Shortcut for data[access(i,j,k)]
|
|
215
198
|
* @memberof Volume
|
|
@@ -218,13 +201,12 @@
|
|
|
218
201
|
* @param {number} k Third coordinate
|
|
219
202
|
* @returns {number} value in the data array
|
|
220
203
|
*/
|
|
221
|
-
|
|
222
|
-
|
|
223
204
|
getData( i, j, k ) {
|
|
224
205
|
|
|
225
206
|
return this.data[ k * this.xLength * this.yLength + j * this.xLength + i ];
|
|
226
207
|
|
|
227
208
|
}
|
|
209
|
+
|
|
228
210
|
/**
|
|
229
211
|
* @member {Function} access compute the index in the data array corresponding to the given coordinates in IJK system
|
|
230
212
|
* @memberof Volume
|
|
@@ -233,21 +215,18 @@
|
|
|
233
215
|
* @param {number} k Third coordinate
|
|
234
216
|
* @returns {number} index
|
|
235
217
|
*/
|
|
236
|
-
|
|
237
|
-
|
|
238
218
|
access( i, j, k ) {
|
|
239
219
|
|
|
240
220
|
return k * this.xLength * this.yLength + j * this.xLength + i;
|
|
241
221
|
|
|
242
222
|
}
|
|
223
|
+
|
|
243
224
|
/**
|
|
244
225
|
* @member {Function} reverseAccess Retrieve the IJK coordinates of the voxel corresponding of the given index in the data
|
|
245
226
|
* @memberof Volume
|
|
246
227
|
* @param {number} index index of the voxel
|
|
247
228
|
* @returns {Array} [x,y,z]
|
|
248
229
|
*/
|
|
249
|
-
|
|
250
|
-
|
|
251
230
|
reverseAccess( index ) {
|
|
252
231
|
|
|
253
232
|
const z = Math.floor( index / ( this.yLength * this.xLength ) );
|
|
@@ -256,6 +235,7 @@
|
|
|
256
235
|
return [ x, y, z ];
|
|
257
236
|
|
|
258
237
|
}
|
|
238
|
+
|
|
259
239
|
/**
|
|
260
240
|
* @member {Function} map Apply a function to all the voxels, be careful, the value will be replaced
|
|
261
241
|
* @memberof Volume
|
|
@@ -266,13 +246,10 @@
|
|
|
266
246
|
* @param {Object} context You can specify a context in which call the function, default if this Volume
|
|
267
247
|
* @returns {Volume} this
|
|
268
248
|
*/
|
|
269
|
-
|
|
270
|
-
|
|
271
249
|
map( functionToMap, context ) {
|
|
272
250
|
|
|
273
251
|
const length = this.data.length;
|
|
274
252
|
context = context || this;
|
|
275
|
-
|
|
276
253
|
for ( let i = 0; i < length; i ++ ) {
|
|
277
254
|
|
|
278
255
|
this.data[ i ] = functionToMap.call( context, this.data[ i ], i, this.data );
|
|
@@ -282,6 +259,7 @@
|
|
|
282
259
|
return this;
|
|
283
260
|
|
|
284
261
|
}
|
|
262
|
+
|
|
285
263
|
/**
|
|
286
264
|
* @member {Function} extractPerpendicularPlane Compute the orientation of the slice and returns all the information relative to the geometry such as sliceAccess, the plane matrix (orientation and position in RAS coordinate) and the dimensions of the plane in both coordinate system.
|
|
287
265
|
* @memberof Volume
|
|
@@ -289,8 +267,6 @@
|
|
|
289
267
|
* @param {number} index the index of the slice
|
|
290
268
|
* @returns {Object} an object containing all the usefull information on the geometry of the slice
|
|
291
269
|
*/
|
|
292
|
-
|
|
293
|
-
|
|
294
270
|
extractPerpendicularPlane( axis, RASIndex ) {
|
|
295
271
|
|
|
296
272
|
let firstSpacing, secondSpacing, positionOffset, IJKIndex;
|
|
@@ -300,7 +276,6 @@
|
|
|
300
276
|
planeMatrix = new THREE.Matrix4().identity(),
|
|
301
277
|
volume = this;
|
|
302
278
|
const dimensions = new THREE.Vector3( this.xLength, this.yLength, this.zLength );
|
|
303
|
-
|
|
304
279
|
switch ( axis ) {
|
|
305
280
|
|
|
306
281
|
case 'x':
|
|
@@ -314,7 +289,6 @@
|
|
|
314
289
|
positionOffset = ( volume.RASDimensions[ 0 ] - 1 ) / 2;
|
|
315
290
|
planeMatrix.setPosition( new THREE.Vector3( RASIndex - positionOffset, 0, 0 ) );
|
|
316
291
|
break;
|
|
317
|
-
|
|
318
292
|
case 'y':
|
|
319
293
|
axisInIJK.set( 0, 1, 0 );
|
|
320
294
|
firstDirection.set( 1, 0, 0 );
|
|
@@ -326,7 +300,6 @@
|
|
|
326
300
|
positionOffset = ( volume.RASDimensions[ 1 ] - 1 ) / 2;
|
|
327
301
|
planeMatrix.setPosition( new THREE.Vector3( 0, RASIndex - positionOffset, 0 ) );
|
|
328
302
|
break;
|
|
329
|
-
|
|
330
303
|
case 'z':
|
|
331
304
|
default:
|
|
332
305
|
axisInIJK.set( 0, 0, 1 );
|
|
@@ -367,12 +340,13 @@
|
|
|
367
340
|
return Math.abs( x.dot( base[ 2 ] ) ) > 0.9;
|
|
368
341
|
|
|
369
342
|
} );
|
|
370
|
-
|
|
371
343
|
function sliceAccess( i, j ) {
|
|
372
344
|
|
|
373
345
|
const si = iDirection === axisInIJK ? IJKIndex : iDirection.arglet === 'i' ? i : j;
|
|
374
346
|
const sj = jDirection === axisInIJK ? IJKIndex : jDirection.arglet === 'i' ? i : j;
|
|
375
|
-
const sk = kDirection === axisInIJK ? IJKIndex : kDirection.arglet === 'i' ? i : j;
|
|
347
|
+
const sk = kDirection === axisInIJK ? IJKIndex : kDirection.arglet === 'i' ? i : j;
|
|
348
|
+
|
|
349
|
+
// invert indices if necessary
|
|
376
350
|
|
|
377
351
|
const accessI = iDirection.dot( base[ 0 ] ) > 0 ? si : volume.xLength - 1 - si;
|
|
378
352
|
const accessJ = jDirection.dot( base[ 1 ] ) > 0 ? sj : volume.yLength - 1 - sj;
|
|
@@ -391,6 +365,7 @@
|
|
|
391
365
|
};
|
|
392
366
|
|
|
393
367
|
}
|
|
368
|
+
|
|
394
369
|
/**
|
|
395
370
|
* @member {Function} extractSlice Returns a slice corresponding to the given axis and index
|
|
396
371
|
* The coordinate are given in the Right Anterior Superior coordinate format
|
|
@@ -399,8 +374,6 @@
|
|
|
399
374
|
* @param {number} index the index of the slice
|
|
400
375
|
* @returns {VolumeSlice} the extracted slice
|
|
401
376
|
*/
|
|
402
|
-
|
|
403
|
-
|
|
404
377
|
extractSlice( axis, index ) {
|
|
405
378
|
|
|
406
379
|
const slice = new THREE.VolumeSlice( this, index, axis );
|
|
@@ -408,14 +381,13 @@
|
|
|
408
381
|
return slice;
|
|
409
382
|
|
|
410
383
|
}
|
|
384
|
+
|
|
411
385
|
/**
|
|
412
386
|
* @member {Function} repaintAllSlices Call repaint on all the slices extracted from this volume
|
|
413
387
|
* @see THREE.VolumeSlice.repaint
|
|
414
388
|
* @memberof Volume
|
|
415
389
|
* @returns {Volume} this
|
|
416
390
|
*/
|
|
417
|
-
|
|
418
|
-
|
|
419
391
|
repaintAllSlices() {
|
|
420
392
|
|
|
421
393
|
this.sliceList.forEach( function ( slice ) {
|
|
@@ -426,21 +398,20 @@
|
|
|
426
398
|
return this;
|
|
427
399
|
|
|
428
400
|
}
|
|
401
|
+
|
|
429
402
|
/**
|
|
430
403
|
* @member {Function} computeMinMax Compute the minimum and the maximum of the data in the volume
|
|
431
404
|
* @memberof Volume
|
|
432
405
|
* @returns {Array} [min,max]
|
|
433
406
|
*/
|
|
434
|
-
|
|
435
|
-
|
|
436
407
|
computeMinMax() {
|
|
437
408
|
|
|
438
409
|
let min = Infinity;
|
|
439
|
-
let max = - Infinity;
|
|
410
|
+
let max = - Infinity;
|
|
440
411
|
|
|
412
|
+
// buffer the length
|
|
441
413
|
const datasize = this.data.length;
|
|
442
414
|
let i = 0;
|
|
443
|
-
|
|
444
415
|
for ( i = 0; i < datasize; i ++ ) {
|
|
445
416
|
|
|
446
417
|
if ( ! isNaN( this.data[ i ] ) ) {
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
* @param {string} [axis='z'] For now only 'x', 'y' or 'z' but later it will change to a normal vector
|
|
9
9
|
* @see Volume
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
11
|
class VolumeSlice {
|
|
13
12
|
|
|
14
13
|
constructor( volume, index, axis ) {
|
|
@@ -17,12 +16,10 @@
|
|
|
17
16
|
/**
|
|
18
17
|
* @member {Volume} volume The associated volume
|
|
19
18
|
*/
|
|
20
|
-
|
|
21
19
|
this.volume = volume;
|
|
22
20
|
/**
|
|
23
21
|
* @member {Number} index The index of the slice, if changed, will automatically call updateGeometry at the next repaint
|
|
24
22
|
*/
|
|
25
|
-
|
|
26
23
|
index = index || 0;
|
|
27
24
|
Object.defineProperty( this, 'index', {
|
|
28
25
|
get: function () {
|
|
@@ -41,25 +38,21 @@
|
|
|
41
38
|
/**
|
|
42
39
|
* @member {String} axis The normal axis
|
|
43
40
|
*/
|
|
44
|
-
|
|
45
41
|
this.axis = axis || 'z';
|
|
42
|
+
|
|
46
43
|
/**
|
|
47
44
|
* @member {HTMLCanvasElement} canvas The final canvas used for the texture
|
|
48
45
|
*/
|
|
49
|
-
|
|
50
46
|
/**
|
|
51
47
|
* @member {CanvasRenderingContext2D} ctx Context of the canvas
|
|
52
48
|
*/
|
|
53
|
-
|
|
54
49
|
this.canvas = document.createElement( 'canvas' );
|
|
55
50
|
/**
|
|
56
51
|
* @member {HTMLCanvasElement} canvasBuffer The intermediary canvas used to paint the data
|
|
57
52
|
*/
|
|
58
|
-
|
|
59
53
|
/**
|
|
60
54
|
* @member {CanvasRenderingContext2D} ctxBuffer Context of the canvas buffer
|
|
61
55
|
*/
|
|
62
|
-
|
|
63
56
|
this.canvasBuffer = document.createElement( 'canvas' );
|
|
64
57
|
this.updateGeometry();
|
|
65
58
|
const canvasMap = new THREE.Texture( this.canvas );
|
|
@@ -73,15 +66,14 @@
|
|
|
73
66
|
/**
|
|
74
67
|
* @member {Mesh} mesh The mesh ready to get used in the scene
|
|
75
68
|
*/
|
|
76
|
-
|
|
77
69
|
this.mesh = new THREE.Mesh( this.geometry, material );
|
|
78
70
|
this.mesh.matrixAutoUpdate = false;
|
|
79
71
|
/**
|
|
80
72
|
* @member {Boolean} geometryNeedsUpdate If set to true, updateGeometry will be triggered at the next repaint
|
|
81
73
|
*/
|
|
82
|
-
|
|
83
74
|
this.geometryNeedsUpdate = true;
|
|
84
75
|
this.repaint();
|
|
76
|
+
|
|
85
77
|
/**
|
|
86
78
|
* @member {Number} iLength Width of slice in the original coordinate system, corresponds to the width of the buffer canvas
|
|
87
79
|
*/
|
|
@@ -99,12 +91,11 @@
|
|
|
99
91
|
*/
|
|
100
92
|
|
|
101
93
|
}
|
|
94
|
+
|
|
102
95
|
/**
|
|
103
96
|
* @member {Function} repaint Refresh the texture and the geometry if geometryNeedsUpdate is set to true
|
|
104
97
|
* @memberof VolumeSlice
|
|
105
98
|
*/
|
|
106
|
-
|
|
107
|
-
|
|
108
99
|
repaint() {
|
|
109
100
|
|
|
110
101
|
if ( this.geometryNeedsUpdate ) {
|
|
@@ -118,18 +109,19 @@
|
|
|
118
109
|
sliceAccess = this.sliceAccess,
|
|
119
110
|
volume = this.volume,
|
|
120
111
|
canvas = this.canvasBuffer,
|
|
121
|
-
ctx = this.ctxBuffer;
|
|
112
|
+
ctx = this.ctxBuffer;
|
|
122
113
|
|
|
114
|
+
// get the imageData and pixel array from the canvas
|
|
123
115
|
const imgData = ctx.getImageData( 0, 0, iLength, jLength );
|
|
124
116
|
const data = imgData.data;
|
|
125
117
|
const volumeData = volume.data;
|
|
126
118
|
const upperThreshold = volume.upperThreshold;
|
|
127
119
|
const lowerThreshold = volume.lowerThreshold;
|
|
128
120
|
const windowLow = volume.windowLow;
|
|
129
|
-
const windowHigh = volume.windowHigh;
|
|
121
|
+
const windowHigh = volume.windowHigh;
|
|
130
122
|
|
|
123
|
+
// manipulate some pixel elements
|
|
131
124
|
let pixelCount = 0;
|
|
132
|
-
|
|
133
125
|
if ( volume.dataType === 'label' ) {
|
|
134
126
|
|
|
135
127
|
//this part is currently useless but will be used when colortables will be handled
|
|
@@ -157,10 +149,10 @@
|
|
|
157
149
|
for ( let i = 0; i < iLength; i ++ ) {
|
|
158
150
|
|
|
159
151
|
let value = volumeData[ sliceAccess( i, j ) ];
|
|
160
|
-
let alpha = 0xff;
|
|
161
|
-
|
|
162
|
-
alpha = upperThreshold >= value ? lowerThreshold <= value ? alpha : 0 : 0;
|
|
163
|
-
|
|
152
|
+
let alpha = 0xff;
|
|
153
|
+
//apply threshold
|
|
154
|
+
alpha = upperThreshold >= value ? lowerThreshold <= value ? alpha : 0 : 0;
|
|
155
|
+
//apply window level
|
|
164
156
|
value = Math.floor( 255 * ( value - windowLow ) / ( windowHigh - windowLow ) );
|
|
165
157
|
value = value > 255 ? 255 : value < 0 ? 0 : value | 0;
|
|
166
158
|
data[ 4 * pixelCount ] = value;
|
|
@@ -180,13 +172,12 @@
|
|
|
180
172
|
this.mesh.material.map.needsUpdate = true;
|
|
181
173
|
|
|
182
174
|
}
|
|
175
|
+
|
|
183
176
|
/**
|
|
184
177
|
* @member {Function} Refresh the geometry according to axis and index
|
|
185
178
|
* @see Volume.extractPerpendicularPlane
|
|
186
179
|
* @memberof VolumeSlice
|
|
187
180
|
*/
|
|
188
|
-
|
|
189
|
-
|
|
190
181
|
updateGeometry() {
|
|
191
182
|
|
|
192
183
|
const extracted = this.volume.extractPerpendicularPlane( this.axis, this.index );
|
|
@@ -203,11 +194,10 @@
|
|
|
203
194
|
if ( this.geometry ) this.geometry.dispose(); // dispose existing geometry
|
|
204
195
|
|
|
205
196
|
this.geometry = new THREE.PlaneGeometry( extracted.planeWidth, extracted.planeHeight );
|
|
206
|
-
|
|
207
197
|
if ( this.mesh ) {
|
|
208
198
|
|
|
209
|
-
this.mesh.geometry = this.geometry;
|
|
210
|
-
|
|
199
|
+
this.mesh.geometry = this.geometry;
|
|
200
|
+
//reset mesh matrix
|
|
211
201
|
this.mesh.matrix.identity();
|
|
212
202
|
this.mesh.applyMatrix4( this.matrix );
|
|
213
203
|
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
const CHANNELS = 4;
|
|
5
5
|
const TEXTURE_WIDTH = 1024;
|
|
6
6
|
const TEXTURE_HEIGHT = 4;
|
|
7
|
+
|
|
7
8
|
/**
|
|
8
9
|
* Make a new THREE.DataTexture to store the descriptions of the curves.
|
|
9
10
|
*
|
|
10
11
|
* @param { number } numberOfCurves the number of curves needed to be described by this texture.
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
13
|
function initSplineTexture( numberOfCurves = 1 ) {
|
|
14
14
|
|
|
15
15
|
const dataArray = new Float32Array( TEXTURE_WIDTH * TEXTURE_HEIGHT * numberOfCurves * CHANNELS );
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
return dataTexture;
|
|
22
22
|
|
|
23
23
|
}
|
|
24
|
+
|
|
24
25
|
/**
|
|
25
26
|
* Write the curve description to the data texture
|
|
26
27
|
*
|
|
@@ -28,7 +29,6 @@
|
|
|
28
29
|
* @param { Curve } splineCurve The curve to describe
|
|
29
30
|
* @param { number } offset Which curve slot to write to
|
|
30
31
|
*/
|
|
31
|
-
|
|
32
32
|
function updateSplineTexture( texture, splineCurve, offset = 0 ) {
|
|
33
33
|
|
|
34
34
|
const numberOfPoints = Math.floor( TEXTURE_WIDTH * ( TEXTURE_HEIGHT / 4 ) );
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
splineCurve.updateArcLengths();
|
|
37
37
|
const points = splineCurve.getSpacedPoints( numberOfPoints );
|
|
38
38
|
const frenetFrames = splineCurve.computeFrenetFrames( numberOfPoints, true );
|
|
39
|
-
|
|
40
39
|
for ( let i = 0; i < numberOfPoints; i ++ ) {
|
|
41
40
|
|
|
42
41
|
const rowOffset = Math.floor( i / TEXTURE_WIDTH );
|
|
@@ -63,20 +62,18 @@
|
|
|
63
62
|
data
|
|
64
63
|
} = image;
|
|
65
64
|
const i = CHANNELS * TEXTURE_WIDTH * o; // Row Offset
|
|
66
|
-
|
|
67
65
|
data[ index * CHANNELS + i + 0 ] = x;
|
|
68
66
|
data[ index * CHANNELS + i + 1 ] = y;
|
|
69
67
|
data[ index * CHANNELS + i + 2 ] = z;
|
|
70
68
|
data[ index * CHANNELS + i + 3 ] = 1;
|
|
71
69
|
|
|
72
70
|
}
|
|
71
|
+
|
|
73
72
|
/**
|
|
74
73
|
* Create a new set of uniforms for describing the curve modifier
|
|
75
74
|
*
|
|
76
75
|
* @param { THREE.DataTexture } Texture which holds the curve description
|
|
77
76
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
77
|
function getUniforms( splineTexture ) {
|
|
81
78
|
|
|
82
79
|
const uniforms = {
|
|
@@ -114,7 +111,6 @@
|
|
|
114
111
|
|
|
115
112
|
if ( material.__ok ) return;
|
|
116
113
|
material.__ok = true;
|
|
117
|
-
|
|
118
114
|
material.onBeforeCompile = shader => {
|
|
119
115
|
|
|
120
116
|
if ( shader.__modified ) return;
|
|
@@ -132,10 +128,17 @@
|
|
|
132
128
|
float textureStacks = ${TEXTURE_HEIGHT / 4}.;
|
|
133
129
|
|
|
134
130
|
${shader.vertexShader}
|
|
135
|
-
`
|
|
136
|
-
|
|
137
|
-
.replace( '#include <
|
|
138
|
-
|
|
131
|
+
`
|
|
132
|
+
// chunk import moved in front of modified shader below
|
|
133
|
+
.replace( '#include <beginnormal_vertex>', '' )
|
|
134
|
+
|
|
135
|
+
// vec3 transformedNormal declaration overriden below
|
|
136
|
+
.replace( '#include <defaultnormal_vertex>', '' )
|
|
137
|
+
|
|
138
|
+
// vec3 transformed declaration overriden below
|
|
139
|
+
.replace( '#include <begin_vertex>', '' )
|
|
140
|
+
|
|
141
|
+
// shader override
|
|
139
142
|
.replace( /void\s*main\s*\(\)\s*\{/, `
|
|
140
143
|
void main() {
|
|
141
144
|
#include <beginnormal_vertex>
|
|
@@ -180,10 +183,10 @@ vec3 transformedNormal = normalMatrix * (basis * objectNormal);
|
|
|
180
183
|
};
|
|
181
184
|
|
|
182
185
|
}
|
|
186
|
+
|
|
183
187
|
/**
|
|
184
188
|
* A helper class for making meshes bend aroudn curves
|
|
185
189
|
*/
|
|
186
|
-
|
|
187
190
|
class Flow {
|
|
188
191
|
|
|
189
192
|
/**
|
|
@@ -212,7 +215,6 @@ vec3 transformedNormal = normalMatrix * (basis * objectNormal);
|
|
|
212
215
|
this.uniforms = uniforms;
|
|
213
216
|
|
|
214
217
|
}
|
|
215
|
-
|
|
216
218
|
updateCurve( index, curve ) {
|
|
217
219
|
|
|
218
220
|
if ( index >= this.curveArray.length ) throw Error( 'Index out of range for Flow' );
|
|
@@ -223,7 +225,6 @@ vec3 transformedNormal = normalMatrix * (basis * objectNormal);
|
|
|
223
225
|
updateSplineTexture( this.splineTexure, curve, index );
|
|
224
226
|
|
|
225
227
|
}
|
|
226
|
-
|
|
227
228
|
moveAlongCurve( amount ) {
|
|
228
229
|
|
|
229
230
|
this.uniforms.pathOffset.value += amount;
|
|
@@ -232,10 +233,10 @@ vec3 transformedNormal = normalMatrix * (basis * objectNormal);
|
|
|
232
233
|
|
|
233
234
|
}
|
|
234
235
|
const matrix = new THREE.Matrix4();
|
|
236
|
+
|
|
235
237
|
/**
|
|
236
238
|
* A helper class for creating instanced versions of flow, where the instances are placed on the curve.
|
|
237
239
|
*/
|
|
238
|
-
|
|
239
240
|
class InstancedFlow extends Flow {
|
|
240
241
|
|
|
241
242
|
/**
|
|
@@ -254,14 +255,13 @@ vec3 transformedNormal = normalMatrix * (basis * objectNormal);
|
|
|
254
255
|
this.whichCurve = new Array( count ).fill( 0 );
|
|
255
256
|
|
|
256
257
|
}
|
|
258
|
+
|
|
257
259
|
/**
|
|
258
260
|
* The extra information about which curve and curve position is stored in the translation components of the matrix for the instanced objects
|
|
259
261
|
* This writes that information to the matrix and marks it as needing update.
|
|
260
262
|
*
|
|
261
263
|
* @param {number} index of the instanced element to update
|
|
262
264
|
*/
|
|
263
|
-
|
|
264
|
-
|
|
265
265
|
writeChanges( index ) {
|
|
266
266
|
|
|
267
267
|
matrix.makeTranslation( this.curveLengthArray[ this.whichCurve[ index ] ], this.whichCurve[ index ], this.offsets[ index ] );
|
|
@@ -269,28 +269,26 @@ vec3 transformedNormal = normalMatrix * (basis * objectNormal);
|
|
|
269
269
|
this.object3D.instanceMatrix.needsUpdate = true;
|
|
270
270
|
|
|
271
271
|
}
|
|
272
|
+
|
|
272
273
|
/**
|
|
273
274
|
* Move an individual element along the curve by a specific amount
|
|
274
275
|
*
|
|
275
276
|
* @param {number} index Which element to update
|
|
276
277
|
* @param {number} offset Move by how much
|
|
277
278
|
*/
|
|
278
|
-
|
|
279
|
-
|
|
280
279
|
moveIndividualAlongCurve( index, offset ) {
|
|
281
280
|
|
|
282
281
|
this.offsets[ index ] += offset;
|
|
283
282
|
this.writeChanges( index );
|
|
284
283
|
|
|
285
284
|
}
|
|
285
|
+
|
|
286
286
|
/**
|
|
287
287
|
* Select which curve to use for an element
|
|
288
288
|
*
|
|
289
289
|
* @param {number} index the index of the instanced element to update
|
|
290
290
|
* @param {number} curveNo the index of the curve it should use
|
|
291
291
|
*/
|
|
292
|
-
|
|
293
|
-
|
|
294
292
|
setCurve( index, curveNo ) {
|
|
295
293
|
|
|
296
294
|
if ( isNaN( curveNo ) ) throw Error( 'curve index being set is Not a Number (NaN)' );
|