@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
|
@@ -107,19 +107,19 @@
|
|
|
107
107
|
|
|
108
108
|
super();
|
|
109
109
|
this.isLightningStrike = true;
|
|
110
|
-
this.type = 'LightningStrike';
|
|
110
|
+
this.type = 'LightningStrike';
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
// Set parameters, and set undefined parameters to default values
|
|
113
|
+
this.init( LightningStrike.copyParameters( rayParameters, rayParameters ) );
|
|
113
114
|
|
|
115
|
+
// Creates and populates the mesh
|
|
114
116
|
this.createMesh();
|
|
115
117
|
|
|
116
118
|
}
|
|
117
|
-
|
|
118
119
|
static createRandomGenerator() {
|
|
119
120
|
|
|
120
121
|
const numSeeds = 2053;
|
|
121
122
|
const seeds = [];
|
|
122
|
-
|
|
123
123
|
for ( let i = 0; i < numSeeds; i ++ ) {
|
|
124
124
|
|
|
125
125
|
seeds.push( Math.random() );
|
|
@@ -149,7 +149,6 @@
|
|
|
149
149
|
return generator;
|
|
150
150
|
|
|
151
151
|
}
|
|
152
|
-
|
|
153
152
|
static copyParameters( dest = {}, source = {} ) {
|
|
154
153
|
|
|
155
154
|
const vecCopy = function ( v ) {
|
|
@@ -167,8 +166,12 @@
|
|
|
167
166
|
};
|
|
168
167
|
|
|
169
168
|
dest.sourceOffset = source.sourceOffset !== undefined ? vecCopy( source.sourceOffset ) : new THREE.Vector3( 0, 100, 0 ), dest.destOffset = source.destOffset !== undefined ? vecCopy( source.destOffset ) : new THREE.Vector3( 0, 0, 0 ), dest.timeScale = source.timeScale !== undefined ? source.timeScale : 1, dest.roughness = source.roughness !== undefined ? source.roughness : 0.9, dest.straightness = source.straightness !== undefined ? source.straightness : 0.7, dest.up0 = source.up0 !== undefined ? vecCopy( source.up0 ) : new THREE.Vector3( 0, 0, 1 );
|
|
170
|
-
dest.up1 = source.up1 !== undefined ? vecCopy( source.up1 ) : new THREE.Vector3( 0, 0, 1 ), dest.radius0 = source.radius0 !== undefined ? source.radius0 : 1, dest.radius1 = source.radius1 !== undefined ? source.radius1 : 1, dest.radius0Factor = source.radius0Factor !== undefined ? source.radius0Factor : 0.5, dest.radius1Factor = source.radius1Factor !== undefined ? source.radius1Factor : 0.2, dest.minRadius = source.minRadius !== undefined ? source.minRadius : 0.2,
|
|
171
|
-
|
|
169
|
+
dest.up1 = source.up1 !== undefined ? vecCopy( source.up1 ) : new THREE.Vector3( 0, 0, 1 ), dest.radius0 = source.radius0 !== undefined ? source.radius0 : 1, dest.radius1 = source.radius1 !== undefined ? source.radius1 : 1, dest.radius0Factor = source.radius0Factor !== undefined ? source.radius0Factor : 0.5, dest.radius1Factor = source.radius1Factor !== undefined ? source.radius1Factor : 0.2, dest.minRadius = source.minRadius !== undefined ? source.minRadius : 0.2,
|
|
170
|
+
// These parameters should not be changed after lightning creation. They can be changed but the ray will change its form abruptly:
|
|
171
|
+
|
|
172
|
+
dest.isEternal = source.isEternal !== undefined ? source.isEternal : source.birthTime === undefined || source.deathTime === undefined, dest.birthTime = source.birthTime, dest.deathTime = source.deathTime, dest.propagationTimeFactor = source.propagationTimeFactor !== undefined ? source.propagationTimeFactor : 0.1, dest.vanishingTimeFactor = source.vanishingTimeFactor !== undefined ? source.vanishingTimeFactor : 0.9, dest.subrayPeriod = source.subrayPeriod !== undefined ? source.subrayPeriod : 4, dest.subrayDutyCycle = source.subrayDutyCycle !== undefined ? source.subrayDutyCycle : 0.6;
|
|
173
|
+
|
|
174
|
+
// These parameters cannot change after lightning creation:
|
|
172
175
|
|
|
173
176
|
dest.maxIterations = source.maxIterations !== undefined ? source.maxIterations : 9;
|
|
174
177
|
dest.isStatic = source.isStatic !== undefined ? source.isStatic : false;
|
|
@@ -180,15 +183,12 @@
|
|
|
180
183
|
return dest;
|
|
181
184
|
|
|
182
185
|
}
|
|
183
|
-
|
|
184
186
|
update( time ) {
|
|
185
187
|
|
|
186
188
|
if ( this.isStatic ) return;
|
|
187
|
-
|
|
188
189
|
if ( this.rayParameters.isEternal || this.rayParameters.birthTime <= time && time <= this.rayParameters.deathTime ) {
|
|
189
190
|
|
|
190
191
|
this.updateMesh( time );
|
|
191
|
-
|
|
192
192
|
if ( time < this.subrays[ 0 ].endPropagationTime ) {
|
|
193
193
|
|
|
194
194
|
this.state = LightningStrike.RAY_PROPAGATING;
|
|
@@ -208,7 +208,6 @@
|
|
|
208
208
|
} else {
|
|
209
209
|
|
|
210
210
|
this.visible = false;
|
|
211
|
-
|
|
212
211
|
if ( time < this.rayParameters.birthTime ) {
|
|
213
212
|
|
|
214
213
|
this.state = LightningStrike.RAY_UNBORN;
|
|
@@ -222,11 +221,13 @@
|
|
|
222
221
|
}
|
|
223
222
|
|
|
224
223
|
}
|
|
225
|
-
|
|
226
224
|
init( rayParameters ) {
|
|
227
225
|
|
|
228
226
|
// Init all the state from the parameters
|
|
229
|
-
|
|
227
|
+
|
|
228
|
+
this.rayParameters = rayParameters;
|
|
229
|
+
|
|
230
|
+
// These parameters cannot change after lightning creation:
|
|
230
231
|
|
|
231
232
|
this.maxIterations = rayParameters.maxIterations !== undefined ? Math.floor( rayParameters.maxIterations ) : 9;
|
|
232
233
|
rayParameters.maxIterations = this.maxIterations;
|
|
@@ -239,13 +240,13 @@
|
|
|
239
240
|
this.recursionProbability = rayParameters.recursionProbability !== undefined ? rayParameters.recursionProbability : 0.6;
|
|
240
241
|
rayParameters.recursionProbability = this.recursionProbability;
|
|
241
242
|
this.generateUVs = rayParameters.generateUVs !== undefined ? rayParameters.generateUVs : false;
|
|
242
|
-
rayParameters.generateUVs = this.generateUVs;
|
|
243
|
+
rayParameters.generateUVs = this.generateUVs;
|
|
243
244
|
|
|
245
|
+
// Random generator
|
|
244
246
|
if ( rayParameters.randomGenerator !== undefined ) {
|
|
245
247
|
|
|
246
248
|
this.randomGenerator = rayParameters.randomGenerator;
|
|
247
249
|
this.seedGenerator = rayParameters.randomGenerator;
|
|
248
|
-
|
|
249
250
|
if ( rayParameters.noiseSeed !== undefined ) {
|
|
250
251
|
|
|
251
252
|
this.seedGenerator.setSeed( rayParameters.noiseSeed );
|
|
@@ -257,9 +258,9 @@
|
|
|
257
258
|
this.randomGenerator = LightningStrike.createRandomGenerator();
|
|
258
259
|
this.seedGenerator = Math;
|
|
259
260
|
|
|
260
|
-
}
|
|
261
|
-
|
|
261
|
+
}
|
|
262
262
|
|
|
263
|
+
// Ray creation callbacks
|
|
263
264
|
if ( rayParameters.onDecideSubrayCreation !== undefined ) {
|
|
264
265
|
|
|
265
266
|
this.onDecideSubrayCreation = rayParameters.onDecideSubrayCreation;
|
|
@@ -267,22 +268,21 @@
|
|
|
267
268
|
} else {
|
|
268
269
|
|
|
269
270
|
this.createDefaultSubrayCreationCallbacks();
|
|
270
|
-
|
|
271
271
|
if ( rayParameters.onSubrayCreation !== undefined ) {
|
|
272
272
|
|
|
273
273
|
this.onSubrayCreation = rayParameters.onSubrayCreation;
|
|
274
274
|
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
}
|
|
277
|
+
}
|
|
278
278
|
|
|
279
|
+
// Internal state
|
|
279
280
|
|
|
280
281
|
this.state = LightningStrike.RAY_INITIALIZED;
|
|
281
282
|
this.maxSubrays = Math.ceil( 1 + Math.pow( this.ramification, Math.max( 0, this.maxSubrayRecursion - 1 ) ) );
|
|
282
283
|
rayParameters.maxSubrays = this.maxSubrays;
|
|
283
284
|
this.maxRaySegments = 2 * ( 1 << this.maxIterations );
|
|
284
285
|
this.subrays = [];
|
|
285
|
-
|
|
286
286
|
for ( let i = 0; i < this.maxSubrays; i ++ ) {
|
|
287
287
|
|
|
288
288
|
this.subrays.push( this.createSubray() );
|
|
@@ -290,7 +290,6 @@
|
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
this.raySegments = [];
|
|
293
|
-
|
|
294
293
|
for ( let i = 0; i < this.maxRaySegments; i ++ ) {
|
|
295
294
|
|
|
296
295
|
this.raySegments.push( this.createSegment() );
|
|
@@ -317,8 +316,9 @@
|
|
|
317
316
|
this.uvsAttribute = null;
|
|
318
317
|
this.simplexX = new THREE.SimplexNoise( this.seedGenerator );
|
|
319
318
|
this.simplexY = new THREE.SimplexNoise( this.seedGenerator );
|
|
320
|
-
this.simplexZ = new THREE.SimplexNoise( this.seedGenerator );
|
|
319
|
+
this.simplexZ = new THREE.SimplexNoise( this.seedGenerator );
|
|
321
320
|
|
|
321
|
+
// Temp vectors
|
|
322
322
|
this.forwards = new THREE.Vector3();
|
|
323
323
|
this.forwardsFill = new THREE.Vector3();
|
|
324
324
|
this.side = new THREE.Vector3();
|
|
@@ -330,7 +330,6 @@
|
|
|
330
330
|
this.cross1 = new THREE.Vector3();
|
|
331
331
|
|
|
332
332
|
}
|
|
333
|
-
|
|
334
333
|
createMesh() {
|
|
335
334
|
|
|
336
335
|
const maxDrawableSegmentsPerSubRay = 1 << this.maxIterations;
|
|
@@ -338,19 +337,17 @@
|
|
|
338
337
|
const maxIndices = 18 * maxDrawableSegmentsPerSubRay * this.maxSubrays;
|
|
339
338
|
this.vertices = new Float32Array( maxVerts * 3 );
|
|
340
339
|
this.indices = new Uint32Array( maxIndices );
|
|
341
|
-
|
|
342
340
|
if ( this.generateUVs ) {
|
|
343
341
|
|
|
344
342
|
this.uvs = new Float32Array( maxVerts * 2 );
|
|
345
343
|
|
|
346
|
-
}
|
|
347
|
-
|
|
344
|
+
}
|
|
348
345
|
|
|
346
|
+
// Populate the mesh
|
|
349
347
|
this.fillMesh( 0 );
|
|
350
348
|
this.setIndex( new THREE.Uint32BufferAttribute( this.indices, 1 ) );
|
|
351
349
|
this.positionAttribute = new THREE.Float32BufferAttribute( this.vertices, 3 );
|
|
352
350
|
this.setAttribute( 'position', this.positionAttribute );
|
|
353
|
-
|
|
354
351
|
if ( this.generateUVs ) {
|
|
355
352
|
|
|
356
353
|
this.uvsAttribute = new THREE.Float32BufferAttribute( new Float32Array( this.uvs ), 2 );
|
|
@@ -362,19 +359,17 @@
|
|
|
362
359
|
|
|
363
360
|
this.index.usage = THREE.DynamicDrawUsage;
|
|
364
361
|
this.positionAttribute.usage = THREE.DynamicDrawUsage;
|
|
365
|
-
|
|
366
362
|
if ( this.generateUVs ) {
|
|
367
363
|
|
|
368
364
|
this.uvsAttribute.usage = THREE.DynamicDrawUsage;
|
|
369
365
|
|
|
370
366
|
}
|
|
371
367
|
|
|
372
|
-
}
|
|
373
|
-
|
|
368
|
+
}
|
|
374
369
|
|
|
370
|
+
// Store buffers for later modification
|
|
375
371
|
this.vertices = this.positionAttribute.array;
|
|
376
372
|
this.indices = this.index.array;
|
|
377
|
-
|
|
378
373
|
if ( this.generateUVs ) {
|
|
379
374
|
|
|
380
375
|
this.uvs = this.uvsAttribute.array;
|
|
@@ -382,14 +377,12 @@
|
|
|
382
377
|
}
|
|
383
378
|
|
|
384
379
|
}
|
|
385
|
-
|
|
386
380
|
updateMesh( time ) {
|
|
387
381
|
|
|
388
382
|
this.fillMesh( time );
|
|
389
383
|
this.drawRange.count = this.currentIndex;
|
|
390
384
|
this.index.needsUpdate = true;
|
|
391
385
|
this.positionAttribute.needsUpdate = true;
|
|
392
|
-
|
|
393
386
|
if ( this.generateUVs ) {
|
|
394
387
|
|
|
395
388
|
this.uvsAttribute.needsUpdate = true;
|
|
@@ -397,7 +390,6 @@
|
|
|
397
390
|
}
|
|
398
391
|
|
|
399
392
|
}
|
|
400
|
-
|
|
401
393
|
fillMesh( time ) {
|
|
402
394
|
|
|
403
395
|
const scope = this;
|
|
@@ -408,15 +400,16 @@
|
|
|
408
400
|
this.fractalRay( time, function fillVertices( segment ) {
|
|
409
401
|
|
|
410
402
|
const subray = scope.currentSubray;
|
|
411
|
-
|
|
412
403
|
if ( time < subray.birthTime ) {
|
|
413
404
|
|
|
414
405
|
//&& ( ! this.rayParameters.isEternal || scope.currentSubray.recursion > 0 ) ) {
|
|
406
|
+
|
|
415
407
|
return;
|
|
416
408
|
|
|
417
409
|
} else if ( this.rayParameters.isEternal && scope.currentSubray.recursion == 0 ) {
|
|
418
410
|
|
|
419
411
|
// Eternal rays don't propagate nor vanish, but its subrays do
|
|
412
|
+
|
|
420
413
|
scope.createPrism( segment );
|
|
421
414
|
scope.onDecideSubrayCreation( segment, scope );
|
|
422
415
|
|
|
@@ -425,6 +418,7 @@
|
|
|
425
418
|
if ( scope.timeFraction >= segment.fraction0 * subray.propagationTimeFactor ) {
|
|
426
419
|
|
|
427
420
|
// Ray propagation has arrived to this segment
|
|
421
|
+
|
|
428
422
|
scope.createPrism( segment );
|
|
429
423
|
scope.onDecideSubrayCreation( segment, scope );
|
|
430
424
|
|
|
@@ -433,6 +427,7 @@
|
|
|
433
427
|
} else if ( time < subray.beginVanishingTime ) {
|
|
434
428
|
|
|
435
429
|
// Ray is steady (nor propagating nor vanishing)
|
|
430
|
+
|
|
436
431
|
scope.createPrism( segment );
|
|
437
432
|
scope.onDecideSubrayCreation( segment, scope );
|
|
438
433
|
|
|
@@ -441,6 +436,7 @@
|
|
|
441
436
|
if ( scope.timeFraction <= subray.vanishingTimeFactor + segment.fraction1 * ( 1 - subray.vanishingTimeFactor ) ) {
|
|
442
437
|
|
|
443
438
|
// Segment has not yet vanished
|
|
439
|
+
|
|
444
440
|
scope.createPrism( segment );
|
|
445
441
|
|
|
446
442
|
}
|
|
@@ -452,13 +448,11 @@
|
|
|
452
448
|
} );
|
|
453
449
|
|
|
454
450
|
}
|
|
455
|
-
|
|
456
451
|
addNewSubray() {
|
|
457
452
|
|
|
458
453
|
return this.subrays[ this.numSubrays ++ ];
|
|
459
454
|
|
|
460
455
|
}
|
|
461
|
-
|
|
462
456
|
initSubray( subray, rayParameters ) {
|
|
463
457
|
|
|
464
458
|
subray.pos0.copy( rayParameters.sourceOffset );
|
|
@@ -479,15 +473,16 @@
|
|
|
479
473
|
subray.recursion = 0;
|
|
480
474
|
|
|
481
475
|
}
|
|
482
|
-
|
|
483
476
|
fractalRay( time, segmentCallback ) {
|
|
484
477
|
|
|
485
478
|
this.time = time;
|
|
486
479
|
this.currentSegmentCallback = segmentCallback;
|
|
487
|
-
this.numSubrays = 0;
|
|
480
|
+
this.numSubrays = 0;
|
|
488
481
|
|
|
489
|
-
|
|
482
|
+
// Add the top level subray
|
|
483
|
+
this.initSubray( this.addNewSubray(), this.rayParameters );
|
|
490
484
|
|
|
485
|
+
// Process all subrays that are being generated until consuming all of them
|
|
491
486
|
for ( let subrayIndex = 0; subrayIndex < this.numSubrays; subrayIndex ++ ) {
|
|
492
487
|
|
|
493
488
|
const subray = this.subrays[ subrayIndex ];
|
|
@@ -523,7 +518,6 @@
|
|
|
523
518
|
this.currentSubray = null;
|
|
524
519
|
|
|
525
520
|
}
|
|
526
|
-
|
|
527
521
|
fractalRayRecursive( segment ) {
|
|
528
522
|
|
|
529
523
|
// Leave recursion condition
|
|
@@ -532,12 +526,11 @@
|
|
|
532
526
|
this.currentSegmentCallback( segment );
|
|
533
527
|
return;
|
|
534
528
|
|
|
535
|
-
}
|
|
536
|
-
|
|
529
|
+
}
|
|
537
530
|
|
|
531
|
+
// Interpolation
|
|
538
532
|
this.forwards.subVectors( segment.pos1, segment.pos0 );
|
|
539
533
|
let lForwards = this.forwards.length();
|
|
540
|
-
|
|
541
534
|
if ( lForwards < 0.000001 ) {
|
|
542
535
|
|
|
543
536
|
this.forwards.set( 0, 0, 0.01 );
|
|
@@ -550,11 +543,14 @@
|
|
|
550
543
|
const timeDimension = this.time * this.currentSubray.timeScale * Math.pow( 2, segment.iteration );
|
|
551
544
|
this.middlePos.lerpVectors( segment.pos0, segment.pos1, 0.5 );
|
|
552
545
|
this.middleLinPos.lerpVectors( segment.linPos0, segment.linPos1, 0.5 );
|
|
553
|
-
const p = this.middleLinPos;
|
|
546
|
+
const p = this.middleLinPos;
|
|
554
547
|
|
|
548
|
+
// Noise
|
|
555
549
|
this.newPos.set( this.simplexX.noise4d( p.x, p.y, p.z, timeDimension ), this.simplexY.noise4d( p.x, p.y, p.z, timeDimension ), this.simplexZ.noise4d( p.x, p.y, p.z, timeDimension ) );
|
|
556
550
|
this.newPos.multiplyScalar( segment.positionVariationFactor * lForwards );
|
|
557
|
-
this.newPos.add( this.middlePos );
|
|
551
|
+
this.newPos.add( this.middlePos );
|
|
552
|
+
|
|
553
|
+
// Recursion
|
|
558
554
|
|
|
559
555
|
const newSegment1 = this.getNewSegment();
|
|
560
556
|
newSegment1.pos0.copy( segment.pos0 );
|
|
@@ -587,12 +583,11 @@
|
|
|
587
583
|
this.fractalRayRecursive( newSegment2 );
|
|
588
584
|
|
|
589
585
|
}
|
|
590
|
-
|
|
591
586
|
createPrism( segment ) {
|
|
592
587
|
|
|
593
588
|
// Creates one triangular prism and its vertices at the segment
|
|
594
|
-
this.forwardsFill.subVectors( segment.pos1, segment.pos0 ).normalize();
|
|
595
589
|
|
|
590
|
+
this.forwardsFill.subVectors( segment.pos1, segment.pos0 ).normalize();
|
|
596
591
|
if ( this.isInitialSegment ) {
|
|
597
592
|
|
|
598
593
|
this.currentCreateTriangleVertices( segment.pos0, segment.up0, this.forwardsFill, segment.radius0, 0 );
|
|
@@ -604,10 +599,10 @@
|
|
|
604
599
|
this.createPrismFaces();
|
|
605
600
|
|
|
606
601
|
}
|
|
607
|
-
|
|
608
602
|
createTriangleVerticesWithoutUVs( pos, up, forwards, radius ) {
|
|
609
603
|
|
|
610
604
|
// Create an equilateral triangle (only vertices)
|
|
605
|
+
|
|
611
606
|
this.side.crossVectors( up, forwards ).multiplyScalar( radius * LightningStrike.COS30DEG );
|
|
612
607
|
this.down.copy( up ).multiplyScalar( - radius * LightningStrike.SIN30DEG );
|
|
613
608
|
const p = this.vPos;
|
|
@@ -627,10 +622,10 @@
|
|
|
627
622
|
this.currentVertex += 3;
|
|
628
623
|
|
|
629
624
|
}
|
|
630
|
-
|
|
631
625
|
createTriangleVerticesWithUVs( pos, up, forwards, radius, u ) {
|
|
632
626
|
|
|
633
627
|
// Create an equilateral triangle (only vertices)
|
|
628
|
+
|
|
634
629
|
this.side.crossVectors( up, forwards ).multiplyScalar( radius * LightningStrike.COS30DEG );
|
|
635
630
|
this.down.copy( up ).multiplyScalar( - radius * LightningStrike.SIN30DEG );
|
|
636
631
|
const p = this.vPos;
|
|
@@ -657,10 +652,7 @@
|
|
|
657
652
|
this.currentVertex += 3;
|
|
658
653
|
|
|
659
654
|
}
|
|
660
|
-
|
|
661
|
-
createPrismFaces( vertex
|
|
662
|
-
/*, index*/
|
|
663
|
-
) {
|
|
655
|
+
createPrismFaces( vertex /*, index*/ ) {
|
|
664
656
|
|
|
665
657
|
const indices = this.indices;
|
|
666
658
|
vertex = this.currentVertex - 6;
|
|
@@ -684,14 +676,13 @@
|
|
|
684
676
|
indices[ this.currentIndex ++ ] = vertex + 5;
|
|
685
677
|
|
|
686
678
|
}
|
|
687
|
-
|
|
688
679
|
createDefaultSubrayCreationCallbacks() {
|
|
689
680
|
|
|
690
681
|
const random1 = this.randomGenerator.random;
|
|
691
|
-
|
|
692
682
|
this.onDecideSubrayCreation = function ( segment, lightningStrike ) {
|
|
693
683
|
|
|
694
684
|
// Decide subrays creation at parent (sub)ray segment
|
|
685
|
+
|
|
695
686
|
const subray = lightningStrike.currentSubray;
|
|
696
687
|
const period = lightningStrike.rayParameters.subrayPeriod;
|
|
697
688
|
const dutyCycle = lightningStrike.rayParameters.subrayDutyCycle;
|
|
@@ -701,10 +692,10 @@
|
|
|
701
692
|
const childSubraySeed = random1() * ( currentCycle + 1 );
|
|
702
693
|
const isActive = phase % period <= dutyCycle * period;
|
|
703
694
|
let probability = 0;
|
|
704
|
-
|
|
705
695
|
if ( isActive ) {
|
|
706
696
|
|
|
707
|
-
probability = lightningStrike.subrayProbability;
|
|
697
|
+
probability = lightningStrike.subrayProbability;
|
|
698
|
+
// Distribution test: probability *= segment.fraction0 > 0.5 && segment.fraction0 < 0.9 ? 1 / 0.4 : 0;
|
|
708
699
|
|
|
709
700
|
}
|
|
710
701
|
|
|
@@ -724,7 +715,6 @@
|
|
|
724
715
|
childSubray.radius1 = Math.min( lightningStrike.rayParameters.minRadius, segment.radius1 * lightningStrike.rayParameters.radius1Factor );
|
|
725
716
|
childSubray.birthTime = phase0 + currentCycle * period;
|
|
726
717
|
childSubray.deathTime = childSubray.birthTime + period * dutyCycle;
|
|
727
|
-
|
|
728
718
|
if ( ! lightningStrike.rayParameters.isEternal && subray.recursion == 0 ) {
|
|
729
719
|
|
|
730
720
|
childSubray.birthTime = Math.max( childSubray.birthTime, subray.birthTime );
|
|
@@ -748,10 +738,10 @@
|
|
|
748
738
|
const vec2Forward = new THREE.Vector3();
|
|
749
739
|
const vec3Side = new THREE.Vector3();
|
|
750
740
|
const vec4Up = new THREE.Vector3();
|
|
751
|
-
|
|
752
741
|
this.onSubrayCreation = function ( segment, parentSubray, childSubray, lightningStrike ) {
|
|
753
742
|
|
|
754
743
|
// Decide childSubray origin and destination positions (pos0 and pos1) and possibly other properties of childSubray
|
|
744
|
+
|
|
755
745
|
// Just use the default cone position generator
|
|
756
746
|
lightningStrike.subrayCylinderPosition( segment, parentSubray, childSubray, 0.5, 0.6, 0.2 );
|
|
757
747
|
|
|
@@ -760,6 +750,7 @@
|
|
|
760
750
|
this.subrayConePosition = function ( segment, parentSubray, childSubray, heightFactor, sideWidthFactor, minSideWidthFactor ) {
|
|
761
751
|
|
|
762
752
|
// Sets childSubray pos0 and pos1 in a cone
|
|
753
|
+
|
|
763
754
|
childSubray.pos0.copy( segment.pos0 );
|
|
764
755
|
vec1Pos.subVectors( parentSubray.pos1, parentSubray.pos0 );
|
|
765
756
|
vec2Forward.copy( vec1Pos ).normalize();
|
|
@@ -776,6 +767,7 @@
|
|
|
776
767
|
this.subrayCylinderPosition = function ( segment, parentSubray, childSubray, heightFactor, sideWidthFactor, minSideWidthFactor ) {
|
|
777
768
|
|
|
778
769
|
// Sets childSubray pos0 and pos1 in a cylinder
|
|
770
|
+
|
|
779
771
|
childSubray.pos0.copy( segment.pos0 );
|
|
780
772
|
vec1Pos.subVectors( parentSubray.pos1, parentSubray.pos0 );
|
|
781
773
|
vec2Forward.copy( vec1Pos ).normalize();
|
|
@@ -790,7 +782,6 @@
|
|
|
790
782
|
};
|
|
791
783
|
|
|
792
784
|
}
|
|
793
|
-
|
|
794
785
|
createSubray() {
|
|
795
786
|
|
|
796
787
|
return {
|
|
@@ -817,7 +808,6 @@
|
|
|
817
808
|
};
|
|
818
809
|
|
|
819
810
|
}
|
|
820
|
-
|
|
821
811
|
createSegment() {
|
|
822
812
|
|
|
823
813
|
return {
|
|
@@ -836,13 +826,11 @@
|
|
|
836
826
|
};
|
|
837
827
|
|
|
838
828
|
}
|
|
839
|
-
|
|
840
829
|
getNewSegment() {
|
|
841
830
|
|
|
842
831
|
return this.raySegments[ this.currentSegmentIndex ++ ];
|
|
843
832
|
|
|
844
833
|
}
|
|
845
|
-
|
|
846
834
|
copy( source ) {
|
|
847
835
|
|
|
848
836
|
super.copy( source );
|
|
@@ -850,16 +838,15 @@
|
|
|
850
838
|
return this;
|
|
851
839
|
|
|
852
840
|
}
|
|
853
|
-
|
|
854
841
|
clone() {
|
|
855
842
|
|
|
856
843
|
return new this.constructor( LightningStrike.copyParameters( {}, this.rayParameters ) );
|
|
857
844
|
|
|
858
845
|
}
|
|
859
846
|
|
|
860
|
-
}
|
|
861
|
-
|
|
847
|
+
}
|
|
862
848
|
|
|
849
|
+
// Ray states
|
|
863
850
|
LightningStrike.RAY_INITIALIZED = 0;
|
|
864
851
|
LightningStrike.RAY_UNBORN = 1;
|
|
865
852
|
LightningStrike.RAY_PROPAGATING = 2;
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
v *= 2 * Math.PI;
|
|
12
12
|
u = u * 2;
|
|
13
13
|
let x, z;
|
|
14
|
-
|
|
15
14
|
if ( u < Math.PI ) {
|
|
16
15
|
|
|
17
16
|
x = 3 * Math.cos( u ) * ( 1 + Math.sin( u ) ) + 2 * ( 1 - Math.cos( u ) / 2 ) * Math.cos( u ) * Math.cos( v );
|
|
@@ -56,6 +55,7 @@
|
|
|
56
55
|
mobius3d: function ( u, t, target ) {
|
|
57
56
|
|
|
58
57
|
// volumetric mobius strip
|
|
58
|
+
|
|
59
59
|
u *= Math.PI;
|
|
60
60
|
t *= 2 * Math.PI;
|
|
61
61
|
u = u * 2;
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
|
+
|
|
74
75
|
/*********************************************
|
|
75
76
|
*
|
|
76
77
|
* Parametric Replacement for TubeGeometry
|
|
@@ -87,7 +88,6 @@
|
|
|
87
88
|
normals = frames.normals,
|
|
88
89
|
binormals = frames.binormals;
|
|
89
90
|
const position = new THREE.Vector3();
|
|
90
|
-
|
|
91
91
|
function ParametricTube( u, v, target ) {
|
|
92
92
|
|
|
93
93
|
v *= 2 * Math.PI;
|
|
@@ -96,7 +96,6 @@
|
|
|
96
96
|
const normal = normals[ i ];
|
|
97
97
|
const binormal = binormals[ i ];
|
|
98
98
|
const cx = - radius * Math.cos( v ); // TODO: Hack: Negating it so it faces outside.
|
|
99
|
-
|
|
100
99
|
const cy = radius * Math.sin( v );
|
|
101
100
|
position.x += cx * normal.x + cy * binormal.x;
|
|
102
101
|
position.y += cx * normal.y + cy * binormal.y;
|
|
@@ -105,7 +104,9 @@
|
|
|
105
104
|
|
|
106
105
|
}
|
|
107
106
|
|
|
108
|
-
super( ParametricTube, segments, segmentsRadius );
|
|
107
|
+
super( ParametricTube, segments, segmentsRadius );
|
|
108
|
+
|
|
109
|
+
// proxy internals
|
|
109
110
|
|
|
110
111
|
this.tangents = tangents;
|
|
111
112
|
this.normals = normals;
|
|
@@ -119,12 +120,12 @@
|
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
};
|
|
123
|
+
|
|
122
124
|
/*********************************************
|
|
123
125
|
*
|
|
124
126
|
* Parametric Replacement for TorusKnotGeometry
|
|
125
127
|
*
|
|
126
128
|
*********************************************/
|
|
127
|
-
|
|
128
129
|
ParametricGeometries.TorusKnotGeometry = class TorusKnotGeometry extends ParametricGeometries.TubeGeometry {
|
|
129
130
|
|
|
130
131
|
constructor( radius = 200, tube = 40, segmentsT = 64, segmentsR = 8, p = 2, q = 3 ) {
|
|
@@ -144,7 +145,6 @@
|
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
}
|
|
147
|
-
|
|
148
148
|
const segments = segmentsT;
|
|
149
149
|
const radiusSegments = segmentsR;
|
|
150
150
|
const extrudePath = new TorusKnotCurve();
|
|
@@ -159,12 +159,12 @@
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
};
|
|
162
|
+
|
|
162
163
|
/*********************************************
|
|
163
164
|
*
|
|
164
165
|
* Parametric Replacement for SphereGeometry
|
|
165
166
|
*
|
|
166
167
|
*********************************************/
|
|
167
|
-
|
|
168
168
|
ParametricGeometries.SphereGeometry = class SphereGeometry extends THREE.ParametricGeometry {
|
|
169
169
|
|
|
170
170
|
constructor( size, u, v ) {
|
|
@@ -185,6 +185,7 @@
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
};
|
|
188
|
+
|
|
188
189
|
/*********************************************
|
|
189
190
|
*
|
|
190
191
|
* Parametric Replacement for PlaneGeometry
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* Parametric Surfaces Geometry
|
|
5
5
|
* based on the brilliant article by @prideout https://prideout.net/blog/old/blog/index.html@p=44.html
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
class ParametricGeometry extends THREE.BufferGeometry {
|
|
9
8
|
|
|
10
9
|
constructor( func = ( u, v, target ) => target.set( u, v, Math.cos( u ) * Math.sin( v ) ), slices = 8, stacks = 8 ) {
|
|
@@ -15,7 +14,9 @@
|
|
|
15
14
|
func: func,
|
|
16
15
|
slices: slices,
|
|
17
16
|
stacks: stacks
|
|
18
|
-
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// buffers
|
|
19
20
|
|
|
20
21
|
const indices = [];
|
|
21
22
|
const vertices = [];
|
|
@@ -26,20 +27,25 @@
|
|
|
26
27
|
const p0 = new THREE.Vector3(),
|
|
27
28
|
p1 = new THREE.Vector3();
|
|
28
29
|
const pu = new THREE.Vector3(),
|
|
29
|
-
pv = new THREE.Vector3();
|
|
30
|
+
pv = new THREE.Vector3();
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
// generate vertices, normals and uvs
|
|
32
33
|
|
|
34
|
+
const sliceCount = slices + 1;
|
|
33
35
|
for ( let i = 0; i <= stacks; i ++ ) {
|
|
34
36
|
|
|
35
37
|
const v = i / stacks;
|
|
36
|
-
|
|
37
38
|
for ( let j = 0; j <= slices; j ++ ) {
|
|
38
39
|
|
|
39
|
-
const u = j / slices;
|
|
40
|
+
const u = j / slices;
|
|
41
|
+
|
|
42
|
+
// vertex
|
|
40
43
|
|
|
41
44
|
func( u, v, p0 );
|
|
42
|
-
vertices.push( p0.x, p0.y, p0.z );
|
|
45
|
+
vertices.push( p0.x, p0.y, p0.z );
|
|
46
|
+
|
|
47
|
+
// normal
|
|
48
|
+
|
|
43
49
|
// approximate tangent vectors via finite differences
|
|
44
50
|
|
|
45
51
|
if ( u - EPS >= 0 ) {
|
|
@@ -64,18 +70,22 @@
|
|
|
64
70
|
func( u, v + EPS, p1 );
|
|
65
71
|
pv.subVectors( p1, p0 );
|
|
66
72
|
|
|
67
|
-
}
|
|
73
|
+
}
|
|
68
74
|
|
|
75
|
+
// cross product of tangent vectors returns surface normal
|
|
69
76
|
|
|
70
77
|
normal.crossVectors( pu, pv ).normalize();
|
|
71
|
-
normals.push( normal.x, normal.y, normal.z );
|
|
78
|
+
normals.push( normal.x, normal.y, normal.z );
|
|
79
|
+
|
|
80
|
+
// uv
|
|
72
81
|
|
|
73
82
|
uvs.push( u, v );
|
|
74
83
|
|
|
75
84
|
}
|
|
76
85
|
|
|
77
|
-
}
|
|
86
|
+
}
|
|
78
87
|
|
|
88
|
+
// generate indices
|
|
79
89
|
|
|
80
90
|
for ( let i = 0; i < stacks; i ++ ) {
|
|
81
91
|
|
|
@@ -84,15 +94,18 @@
|
|
|
84
94
|
const a = i * sliceCount + j;
|
|
85
95
|
const b = i * sliceCount + j + 1;
|
|
86
96
|
const c = ( i + 1 ) * sliceCount + j + 1;
|
|
87
|
-
const d = ( i + 1 ) * sliceCount + j;
|
|
97
|
+
const d = ( i + 1 ) * sliceCount + j;
|
|
98
|
+
|
|
99
|
+
// faces one and two
|
|
88
100
|
|
|
89
101
|
indices.push( a, b, d );
|
|
90
102
|
indices.push( b, c, d );
|
|
91
103
|
|
|
92
104
|
}
|
|
93
105
|
|
|
94
|
-
}
|
|
106
|
+
}
|
|
95
107
|
|
|
108
|
+
// build geometry
|
|
96
109
|
|
|
97
110
|
this.setIndex( indices );
|
|
98
111
|
this.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
|