super-three 0.184.0 → 0.185.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +1260 -927
- package/build/three.core.js +1104 -829
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +156 -98
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +11 -4
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +7538 -3367
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +7538 -3366
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -0
- package/examples/jsm/controls/ArcballControls.js +6 -2
- package/examples/jsm/controls/FirstPersonControls.js +79 -42
- package/examples/jsm/controls/TransformControls.js +68 -15
- package/examples/jsm/csm/CSMFrustum.js +31 -6
- package/examples/jsm/csm/CSMShadowNode.js +4 -1
- package/examples/jsm/effects/AsciiEffect.js +14 -1
- package/examples/jsm/exporters/DRACOExporter.js +27 -6
- package/examples/jsm/exporters/GLTFExporter.js +114 -12
- package/examples/jsm/exporters/PLYExporter.js +286 -73
- package/examples/jsm/exporters/USDZExporter.js +347 -112
- package/examples/jsm/generators/CityGenerator.js +346 -0
- package/examples/jsm/generators/ForestGenerator.js +347 -0
- package/examples/jsm/generators/TerrainGenerator.js +504 -0
- package/examples/jsm/generators/TreeGenerator.js +377 -0
- package/examples/jsm/generators/city/SidewalkGenerator.js +253 -0
- package/examples/jsm/generators/city/SkyscraperGenerator.js +1357 -0
- package/examples/jsm/geometries/LoftGeometry.js +355 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +5 -4
- package/examples/jsm/helpers/ViewHelper.js +16 -6
- package/examples/jsm/inspector/Inspector.js +53 -15
- package/examples/jsm/inspector/RendererInspector.js +152 -36
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +1 -1
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +1 -1
- package/examples/jsm/inspector/tabs/Console.js +200 -18
- package/examples/jsm/inspector/tabs/Memory.js +8 -0
- package/examples/jsm/inspector/tabs/Parameters.js +64 -4
- package/examples/jsm/inspector/tabs/Performance.js +21 -6
- package/examples/jsm/inspector/tabs/Settings.js +51 -9
- package/examples/jsm/inspector/tabs/Timeline.js +178 -93
- package/examples/jsm/inspector/tabs/Viewer.js +628 -16
- package/examples/jsm/inspector/ui/Graph.js +162 -25
- package/examples/jsm/inspector/ui/Item.js +92 -13
- package/examples/jsm/inspector/ui/List.js +1 -1
- package/examples/jsm/inspector/ui/Profiler.js +90 -45
- package/examples/jsm/inspector/ui/Style.js +1788 -1401
- package/examples/jsm/inspector/ui/Tab.js +5 -3
- package/examples/jsm/inspector/ui/Values.js +71 -6
- package/examples/jsm/inspector/ui/utils.js +130 -10
- package/examples/jsm/libs/basis/README.md +0 -1
- package/examples/jsm/libs/demuxer_mp4.js +3 -3
- package/examples/jsm/libs/draco/README.md +0 -1
- package/examples/jsm/libs/meshopt_clusterizer.module.js +421 -0
- package/examples/jsm/libs/meshopt_simplifier.module.js +627 -0
- package/examples/jsm/libs/mikktspace.module.js +34 -9
- package/examples/jsm/lighting/ClusteredLighting.js +55 -0
- package/examples/jsm/lighting/LightProbeGrid.js +106 -76
- package/examples/jsm/lines/LineMaterial.js +38 -15
- package/examples/jsm/lines/LineSegments2.js +8 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +8 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +46 -13
- package/examples/jsm/loaders/EXRLoader.js +27 -55
- package/examples/jsm/loaders/HDRLoader.js +6 -28
- package/examples/jsm/loaders/KTX2Loader.js +31 -12
- package/examples/jsm/loaders/LDrawLoader.js +8 -8
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +2 -2
- package/examples/jsm/loaders/LWOLoader.js +4 -0
- package/examples/jsm/loaders/LottieLoader.js +1 -1
- package/examples/jsm/loaders/MaterialXLoader.js +31 -9
- package/examples/jsm/loaders/NRRDLoader.js +3 -3
- package/examples/jsm/loaders/PCDLoader.js +7 -7
- package/examples/jsm/loaders/PLYLoader.js +218 -55
- package/examples/jsm/loaders/SVGLoader.js +547 -495
- package/examples/jsm/loaders/TTFLoader.js +1 -1
- package/examples/jsm/loaders/USDLoader.js +33 -9
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/loaders/usd/USDAParser.js +93 -20
- package/examples/jsm/loaders/usd/USDCParser.js +1 -1
- package/examples/jsm/loaders/usd/USDComposer.js +52 -19
- package/examples/jsm/misc/TileCreasedNormalsPlugin.js +270 -0
- package/examples/jsm/misc/Volume.js +2 -2
- package/examples/jsm/objects/GroundedSkybox.js +1 -1
- package/examples/jsm/objects/Reflector.js +2 -3
- package/examples/jsm/objects/Water2Mesh.js +1 -1
- package/examples/jsm/physics/AmmoPhysics.js +15 -8
- package/examples/jsm/physics/RapierPhysics.js +27 -2
- package/examples/jsm/shaders/VolumeShader.js +31 -44
- package/examples/jsm/transpiler/GLSLDecoder.js +6 -6
- package/examples/jsm/transpiler/Linker.js +1 -1
- package/examples/jsm/tsl/display/BloomNode.js +59 -19
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +2 -2
- package/examples/jsm/tsl/display/FXAANode.js +11 -12
- package/examples/jsm/tsl/display/GTAONode.js +34 -13
- package/examples/jsm/tsl/display/GodraysNode.js +1 -1
- package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +560 -0
- package/examples/jsm/tsl/display/PixelationPassNode.js +2 -2
- package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +912 -0
- package/examples/jsm/tsl/display/SSAAPassNode.js +13 -25
- package/examples/jsm/tsl/display/SSGINode.js +89 -39
- package/examples/jsm/tsl/display/SSRNode.js +829 -132
- package/examples/jsm/tsl/display/SSSNode.js +2 -2
- package/examples/jsm/tsl/display/TemporalReprojectNode.js +1023 -0
- package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +622 -0
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +1 -1
- package/examples/jsm/tsl/math/curlNoise.js +107 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +1 -1
- package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +3 -3
- package/examples/jsm/tsl/utils/GroundedSkybox.js +62 -0
- package/examples/jsm/tsl/utils/RNoise.js +51 -0
- package/examples/jsm/tsl/utils/SpecularHelpers.js +325 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +126 -59
- package/examples/jsm/utils/GeometryCompressionUtils.js +1 -1
- package/examples/jsm/utils/SceneOptimizer.js +1 -1
- package/examples/jsm/webxr/ARButton.js +1 -1
- package/examples/jsm/webxr/WebGLXRFallback.js +89 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +2 -2
- package/package.json +7 -7
- package/src/Three.TSL.js +10 -3
- package/src/Three.WebGPU.js +4 -0
- package/src/animation/AnimationAction.js +15 -11
- package/src/animation/AnimationClip.js +0 -139
- package/src/animation/KeyframeTrack.js +2 -2
- package/src/animation/PropertyBinding.js +2 -2
- package/src/cameras/Camera.js +2 -2
- package/src/cameras/StereoCamera.js +5 -2
- package/src/constants.js +1 -1
- package/src/core/BufferGeometry.js +29 -7
- package/src/core/Object3D.js +17 -7
- package/src/core/Raycaster.js +1 -1
- package/src/core/RenderTarget.js +15 -2
- package/src/extras/PMREMGenerator.js +6 -4
- package/src/extras/TextureUtils.js +1 -1
- package/src/extras/core/ShapePath.js +149 -160
- package/src/geometries/SphereGeometry.js +8 -3
- package/src/helpers/DirectionalLightHelper.js +2 -0
- package/src/helpers/HemisphereLightHelper.js +2 -0
- package/src/helpers/PointLightHelper.js +2 -0
- package/src/helpers/SpotLightHelper.js +1 -1
- package/src/loaders/DataTextureLoader.js +69 -38
- package/src/loaders/LoadingManager.js +5 -0
- package/src/loaders/MaterialLoader.js +36 -266
- package/src/loaders/ObjectLoader.js +3 -1
- package/src/materials/LineBasicMaterial.js +4 -0
- package/src/materials/Material.js +196 -1
- package/src/materials/MeshBasicMaterial.js +24 -0
- package/src/materials/MeshDepthMaterial.js +10 -0
- package/src/materials/MeshDistanceMaterial.js +10 -0
- package/src/materials/MeshLambertMaterial.js +40 -1
- package/src/materials/MeshMatcapMaterial.js +25 -1
- package/src/materials/MeshNormalMaterial.js +9 -1
- package/src/materials/MeshPhongMaterial.js +40 -1
- package/src/materials/MeshPhysicalMaterial.js +38 -0
- package/src/materials/MeshStandardMaterial.js +42 -1
- package/src/materials/MeshToonMaterial.js +34 -1
- package/src/materials/PointsMaterial.js +7 -0
- package/src/materials/ShaderMaterial.js +86 -0
- package/src/materials/SpriteMaterial.js +7 -0
- package/src/materials/nodes/Line2NodeMaterial.js +378 -322
- package/src/materials/nodes/MeshBasicNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhongNodeMaterial.js +0 -9
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +0 -30
- package/src/materials/nodes/MeshSSSNodeMaterial.js +0 -13
- package/src/materials/nodes/MeshStandardNodeMaterial.js +0 -11
- package/src/materials/nodes/NodeMaterial.js +115 -71
- package/src/materials/nodes/SpriteNodeMaterial.js +0 -10
- package/src/materials/nodes/manager/NodeMaterialObserver.js +49 -20
- package/src/math/Box3.js +5 -0
- package/src/math/FrustumArray.js +103 -133
- package/src/math/Interpolant.js +1 -1
- package/src/math/MathUtils.js +2 -2
- package/src/math/Matrix3.js +11 -0
- package/src/math/Matrix4.js +28 -3
- package/src/math/Vector2.js +2 -2
- package/src/math/Vector3.js +2 -2
- package/src/math/Vector4.js +2 -2
- package/src/math/interpolants/BezierInterpolant.js +4 -6
- package/src/nodes/Nodes.js +2 -5
- package/src/nodes/TSL.js +8 -6
- package/src/nodes/accessors/Arrays.js +4 -4
- package/src/nodes/accessors/Batch.js +108 -0
- package/src/nodes/accessors/Bitangent.js +2 -2
- package/src/nodes/accessors/BufferAttributeNode.js +13 -2
- package/src/nodes/accessors/Camera.js +7 -7
- package/src/nodes/accessors/ClippingNode.js +1 -1
- package/src/nodes/accessors/Instance.js +264 -0
- package/src/nodes/accessors/MaterialNode.js +18 -2
- package/src/nodes/accessors/MaterialProperties.js +4 -3
- package/src/nodes/accessors/{MorphNode.js → Morph.js} +99 -112
- package/src/nodes/accessors/Normal.js +13 -13
- package/src/nodes/accessors/Position.js +5 -1
- package/src/nodes/accessors/ReferenceNode.js +1 -0
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/SceneProperties.js +1 -1
- package/src/nodes/accessors/Skinning.js +263 -0
- package/src/nodes/accessors/StorageBufferNode.js +2 -2
- package/src/nodes/accessors/StorageTexture3DNode.js +100 -0
- package/src/nodes/accessors/StorageTextureNode.js +39 -7
- package/src/nodes/accessors/Tangent.js +4 -4
- package/src/nodes/accessors/TextureNode.js +60 -5
- package/src/nodes/code/FunctionNode.js +2 -16
- package/src/nodes/core/MRTNode.js +7 -2
- package/src/nodes/core/Node.js +39 -2
- package/src/nodes/core/NodeBuilder.js +201 -41
- package/src/nodes/core/NodeUtils.js +13 -13
- package/src/nodes/core/OutputStructNode.js +1 -1
- package/src/nodes/core/OverrideContextNode.js +153 -0
- package/src/nodes/core/PropertyNode.js +51 -5
- package/src/nodes/core/StackNode.js +56 -34
- package/src/nodes/core/StructNode.js +4 -6
- package/src/nodes/core/StructTypeNode.js +6 -6
- package/src/nodes/core/VarNode.js +8 -0
- package/src/nodes/core/VaryingNode.js +12 -2
- package/src/nodes/display/BlendModes.js +1 -41
- package/src/nodes/display/BumpMapNode.js +6 -1
- package/src/nodes/display/ColorAdjustment.js +10 -9
- package/src/nodes/display/FrontFacingNode.js +38 -9
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +35 -43
- package/src/nodes/display/PremultiplyAlphaFunctions.js +39 -0
- package/src/nodes/display/RenderOutputNode.js +12 -3
- package/src/nodes/functions/VolumetricLightingModel.js +40 -7
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +1 -1
- package/src/nodes/lighting/EnvironmentNode.js +2 -2
- package/src/nodes/lighting/IESSpotLightNode.js +40 -2
- package/src/nodes/lighting/LightingContextNode.js +10 -2
- package/src/nodes/lighting/LightsNode.js +90 -37
- package/src/nodes/lighting/PointShadowNode.js +6 -1
- package/src/nodes/lighting/ShadowFilterNode.js +21 -52
- package/src/nodes/lighting/ShadowNode.js +34 -14
- package/src/nodes/materialx/lib/mx_noise.js +2 -2
- package/src/nodes/math/ConditionalNode.js +3 -3
- package/src/nodes/math/MathNode.js +39 -11
- package/src/nodes/math/OperatorNode.js +23 -23
- package/src/nodes/parsers/GLSLNodeFunction.js +1 -1
- package/src/nodes/pmrem/PMREMNode.js +33 -2
- package/src/nodes/tsl/TSLCore.js +63 -18
- package/src/nodes/utils/EquirectUV.js +30 -5
- package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
- package/src/nodes/utils/Packing.js +35 -4
- package/src/nodes/utils/RTTNode.js +40 -24
- package/src/nodes/utils/ReflectorNode.js +1 -0
- package/src/nodes/utils/StorageArrayElementNode.js +1 -1
- package/src/objects/BatchedMesh.js +22 -14
- package/src/objects/InstancedMesh.js +0 -11
- package/src/objects/Skeleton.js +0 -9
- package/src/renderers/WebGLRenderer.js +19 -15
- package/src/renderers/common/Backend.js +49 -5
- package/src/renderers/common/Bindings.js +114 -45
- package/src/renderers/common/Buffer.js +9 -0
- package/src/renderers/common/ClippingContext.js +10 -2
- package/src/renderers/common/Info.js +63 -22
- package/src/renderers/common/Lighting.js +53 -5
- package/src/renderers/common/RenderList.js +41 -4
- package/src/renderers/common/RenderObject.js +73 -13
- package/src/renderers/common/Renderer.js +281 -108
- package/src/renderers/common/Sampler.js +16 -48
- package/src/renderers/common/Textures.js +32 -5
- package/src/renderers/common/TimestampQueryPool.js +1 -1
- package/src/renderers/common/UniformsGroup.js +31 -9
- package/src/renderers/common/XRManager.js +340 -22
- package/src/renderers/common/extras/PMREMGenerator.js +15 -38
- package/src/renderers/common/nodes/NodeBuilderState.js +9 -1
- package/src/renderers/common/nodes/NodeLibrary.js +4 -4
- package/src/renderers/common/nodes/NodeManager.js +63 -14
- package/src/renderers/common/nodes/NodeUniformBuffer.js +13 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +13 -4
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +0 -6
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/distance.glsl.js +1 -1
- package/src/renderers/webgl/WebGLOutput.js +2 -1
- package/src/renderers/webgl/WebGLProgram.js +5 -4
- package/src/renderers/webgl/WebGLPrograms.js +12 -5
- package/src/renderers/webgl/WebGLRenderLists.js +9 -1
- package/src/renderers/webgl/WebGLShaderCache.js +5 -11
- package/src/renderers/webgl/WebGLTextures.js +20 -7
- package/src/renderers/webgl/WebGLUniformsGroups.js +66 -38
- package/src/renderers/webgl-fallback/WebGLBackend.js +84 -25
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +138 -8
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +1 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -22
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +4 -2
- package/src/renderers/webgpu/WebGPUBackend.js +480 -169
- package/src/renderers/webgpu/descriptors/GPUBindGroupDescriptor.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUBufferDescriptor.js +57 -0
- package/src/renderers/webgpu/descriptors/GPUCommandEncoderDescriptor.js +30 -0
- package/src/renderers/webgpu/descriptors/GPUComputePassDescriptor.js +38 -0
- package/src/renderers/webgpu/descriptors/GPUComputePipelineDescriptor.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUCopyExternalImageDestInfo.js +47 -0
- package/src/renderers/webgpu/descriptors/GPUCopyExternalImageSourceInfo.js +50 -0
- package/src/renderers/webgpu/descriptors/GPUExtent3D.js +51 -0
- package/src/renderers/webgpu/descriptors/GPUPipelineLayoutDescriptor.js +39 -0
- package/src/renderers/webgpu/descriptors/GPUQuerySetDescriptor.js +47 -0
- package/src/renderers/webgpu/descriptors/GPURenderBundleEncoderDescriptor.js +74 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassColorAttachment.js +72 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassDepthStencilAttachment.js +99 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassDescriptor.js +72 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassTimestampWrites.js +49 -0
- package/src/renderers/webgpu/descriptors/GPURenderPipelineDescriptor.js +130 -0
- package/src/renderers/webgpu/descriptors/GPUSamplerDescriptor.js +119 -0
- package/src/renderers/webgpu/descriptors/GPUShaderModuleDescriptor.js +46 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferInfo.js +57 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferLayout.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyTextureInfo.js +61 -0
- package/src/renderers/webgpu/descriptors/GPUTextureDescriptor.js +99 -0
- package/src/renderers/webgpu/descriptors/GPUTextureViewDescriptor.js +108 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +0 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +164 -7
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +98 -38
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -68
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +164 -69
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +158 -95
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +297 -141
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +33 -18
- package/src/renderers/webgpu/utils/WebGPUUtils.js +38 -3
- package/src/textures/DepthTexture.js +1 -1
- package/src/textures/ExternalTexture.js +0 -3
- package/examples/fonts/LICENSE +0 -13
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +0 -91
- package/examples/fonts/README.md +0 -11
- package/examples/fonts/droid/NOTICE +0 -190
- package/examples/fonts/droid/README.txt +0 -18
- package/examples/fonts/droid/droid_sans_bold.typeface.json +0 -1
- package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +0 -1
- package/examples/fonts/droid/droid_sans_regular.typeface.json +0 -1
- package/examples/fonts/droid/droid_serif_bold.typeface.json +0 -1
- package/examples/fonts/droid/droid_serif_regular.typeface.json +0 -1
- package/examples/fonts/gentilis_bold.typeface.json +0 -1
- package/examples/fonts/gentilis_regular.typeface.json +0 -1
- package/examples/fonts/helvetiker_bold.typeface.json +0 -1
- package/examples/fonts/helvetiker_regular.typeface.json +0 -1
- package/examples/fonts/optimer_bold.typeface.json +0 -1
- package/examples/fonts/optimer_regular.typeface.json +0 -1
- package/examples/fonts/ttf/README.md +0 -9
- package/examples/fonts/ttf/kenpixel.ttf +0 -0
- package/examples/jsm/inspector/extensions/extensions.json +0 -6
- package/examples/jsm/libs/ammo.wasm.js +0 -822
- package/examples/jsm/libs/ammo.wasm.wasm +0 -0
- package/examples/jsm/libs/draco/draco_encoder.js +0 -33
- package/examples/jsm/libs/draco/gltf/draco_encoder.js +0 -33
- package/examples/jsm/libs/lottie_canvas.module.js +0 -14849
- package/examples/jsm/libs/opentype.module.js +0 -14506
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +0 -21
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +0 -16
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/lighting/TiledLighting.js +0 -42
- package/examples/jsm/tsl/display/AnamorphicNode.js +0 -293
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +0 -442
- package/src/nodes/accessors/BatchNode.js +0 -163
- package/src/nodes/accessors/InstanceNode.js +0 -349
- package/src/nodes/accessors/InstancedMeshNode.js +0 -50
- package/src/nodes/accessors/SkinningNode.js +0 -328
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import NodeMaterial from './NodeMaterial.js';
|
|
2
|
-
import { dashSize, gapSize, varyingProperty } from '../../nodes/core/PropertyNode.js';
|
|
2
|
+
import { dashSize, diffuseColor, gapSize, varyingProperty } from '../../nodes/core/PropertyNode.js';
|
|
3
3
|
import { attribute } from '../../nodes/core/AttributeNode.js';
|
|
4
4
|
import { cameraProjectionMatrix } from '../../nodes/accessors/Camera.js';
|
|
5
|
-
import {
|
|
5
|
+
import { materialLineScale, materialLineDashSize, materialLineGapSize, materialLineDashOffset, materialLineWidth } from '../../nodes/accessors/MaterialNode.js';
|
|
6
6
|
import { modelViewMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
7
7
|
import { positionGeometry } from '../../nodes/accessors/Position.js';
|
|
8
8
|
import { mix, smoothstep } from '../../nodes/math/MathNode.js';
|
|
@@ -13,457 +13,540 @@ import { viewportOpaqueMipTexture } from '../../nodes/display/ViewportTextureNod
|
|
|
13
13
|
|
|
14
14
|
import { LineDashedMaterial } from '../LineDashedMaterial.js';
|
|
15
15
|
import { NoBlending } from '../../constants.js';
|
|
16
|
+
import { warnOnce } from '../../utils.js';
|
|
16
17
|
|
|
17
18
|
const _defaultValues = /*@__PURE__*/ new LineDashedMaterial();
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @augments NodeMaterial
|
|
21
|
+
* Varying node representing the world position of the segment start in view space.
|
|
22
|
+
* Used for distance and coordinate calculations across the fragment shader.
|
|
23
|
+
* @type {VaryingNode<vec3>}
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
const worldStart = varyingProperty( 'vec3', 'worldStart' );
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Varying node representing the world position of the segment end in view space.
|
|
29
|
+
* Used for distance and coordinate calculations across the fragment shader.
|
|
30
|
+
* @type {VaryingNode<vec3>}
|
|
31
|
+
*/
|
|
32
|
+
const worldEnd = varyingProperty( 'vec3', 'worldEnd' );
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Varying node representing the accumulated distance along the line.
|
|
36
|
+
* Crucial for correctly computing dashed line intervals in fragment stage.
|
|
37
|
+
* @type {VaryingNode<float>}
|
|
38
|
+
*/
|
|
39
|
+
const lineDistance = varyingProperty( 'float', 'lineDistance' );
|
|
30
40
|
|
|
31
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Varying node representing the interpolated world/view position of the current fragment.
|
|
43
|
+
* Used for line/ray distance checks under perspective projection.
|
|
44
|
+
* @type {VaryingNode<vec4>}
|
|
45
|
+
*/
|
|
46
|
+
const worldPos = varyingProperty( 'vec4', 'worldPos' );
|
|
32
47
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Trims the line segment to avoid rendering behind the camera near plane.
|
|
50
|
+
* Computes an interpolation factor (alpha) to clamp the segment's coordinate.
|
|
51
|
+
*
|
|
52
|
+
* @param {Object} inputs
|
|
53
|
+
* @param {Node<vec4>} inputs.start - Segment start position in view space.
|
|
54
|
+
* @param {Node<vec4>} inputs.end - Segment end position in view space.
|
|
55
|
+
* @returns {Node<float>} The interpolation factor (alpha) to trim the segment.
|
|
56
|
+
*/
|
|
57
|
+
const trimSegmentAlpha = Fn( ( { start, end } ) => {
|
|
39
58
|
|
|
40
|
-
|
|
59
|
+
const a = cameraProjectionMatrix.element( 2 ).element( 2 ); // 3nd entry in 3th column
|
|
60
|
+
const b = cameraProjectionMatrix.element( 3 ).element( 2 ); // 3nd entry in 4th column
|
|
41
61
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
*
|
|
45
|
-
* @type {boolean}
|
|
46
|
-
* @readonly
|
|
47
|
-
* @default true
|
|
48
|
-
*/
|
|
49
|
-
this.isLine2NodeMaterial = true;
|
|
62
|
+
// we need different nearEstimate formula for reversed and default depth buffer
|
|
63
|
+
// a is positive with a reversed depth buffer so it can be used for controlling the code flow
|
|
50
64
|
|
|
51
|
-
|
|
65
|
+
const nearEstimate = a.greaterThan( 0 ).select( b.negate().div( a.add( 1 ) ), b.mul( - 0.5 ).div( a ) );
|
|
52
66
|
|
|
53
|
-
|
|
54
|
-
* Whether vertex colors should be used or not.
|
|
55
|
-
*
|
|
56
|
-
* @type {boolean}
|
|
57
|
-
* @default false
|
|
58
|
-
*/
|
|
59
|
-
this.vertexColors = parameters.vertexColors;
|
|
67
|
+
return nearEstimate.sub( start.z ).div( end.z.sub( start.z ) );
|
|
60
68
|
|
|
61
|
-
|
|
62
|
-
* The dash offset.
|
|
63
|
-
*
|
|
64
|
-
* @type {number}
|
|
65
|
-
* @default 0
|
|
66
|
-
*/
|
|
67
|
-
this.dashOffset = 0;
|
|
69
|
+
}, { start: 'vec4', end: 'vec4', return: 'float' } );
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Calculates the closest points on two 3D lines.
|
|
73
|
+
* Used for perspective-correct line rendering and coordinates interpolation.
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} inputs
|
|
76
|
+
* @param {Node<vec3>} inputs.p1 - Start of line 1.
|
|
77
|
+
* @param {Node<vec3>} inputs.p2 - End of line 1.
|
|
78
|
+
* @param {Node<vec3>} inputs.p3 - Start of line 2.
|
|
79
|
+
* @param {Node<vec3>} inputs.p4 - End of line 2.
|
|
80
|
+
* @returns {Node<vec2>} A vec2 containing the parametric coordinates (mua, mub) of the closest points on line 1 and line 2.
|
|
81
|
+
*/
|
|
82
|
+
const closestLineToLine = Fn( ( { p1, p2, p3, p4 } ) => {
|
|
76
83
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
*
|
|
80
|
-
* @type {?Node<float>}
|
|
81
|
-
* @default null
|
|
82
|
-
*/
|
|
83
|
-
this.offsetNode = null;
|
|
84
|
+
const p13 = p1.sub( p3 );
|
|
85
|
+
const p43 = p4.sub( p3 );
|
|
84
86
|
|
|
85
|
-
|
|
86
|
-
* Defines the dash scale.
|
|
87
|
-
*
|
|
88
|
-
* @type {?Node<float>}
|
|
89
|
-
* @default null
|
|
90
|
-
*/
|
|
91
|
-
this.dashScaleNode = null;
|
|
87
|
+
const p21 = p2.sub( p1 );
|
|
92
88
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*/
|
|
99
|
-
this.dashSizeNode = null;
|
|
89
|
+
const d1343 = p13.dot( p43 );
|
|
90
|
+
const d4321 = p43.dot( p21 );
|
|
91
|
+
const d1321 = p13.dot( p21 );
|
|
92
|
+
const d4343 = p43.dot( p43 );
|
|
93
|
+
const d2121 = p21.dot( p21 );
|
|
100
94
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
*
|
|
104
|
-
* @type {?Node<float>}
|
|
105
|
-
* @default null
|
|
106
|
-
*/
|
|
107
|
-
this.gapSizeNode = null;
|
|
95
|
+
const denom = d2121.mul( d4343 ).sub( d4321.mul( d4321 ) );
|
|
96
|
+
const numer = d1343.mul( d4321 ).sub( d1321.mul( d4343 ) );
|
|
108
97
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
* is not supported, yet.
|
|
112
|
-
*
|
|
113
|
-
* @type {number}
|
|
114
|
-
* @default 0
|
|
115
|
-
*/
|
|
116
|
-
this.blending = NoBlending;
|
|
98
|
+
const mua = numer.div( denom ).clamp();
|
|
99
|
+
const mub = d1343.add( d4321.mul( mua ) ).div( d4343 ).clamp();
|
|
117
100
|
|
|
118
|
-
|
|
119
|
-
this._useAlphaToCoverage = true;
|
|
120
|
-
this._useWorldUnits = false;
|
|
101
|
+
return vec2( mua, mub );
|
|
121
102
|
|
|
122
|
-
|
|
103
|
+
}, { p1: 'vec3', p2: 'vec3', p3: 'vec3', p4: 'vec3', return: 'vec2' } );
|
|
123
104
|
|
|
124
|
-
|
|
105
|
+
/**
|
|
106
|
+
* TSL node acting as a custom Model-View-Projection (MVP) for fat lines,
|
|
107
|
+
* expanding 3D segments into screen/world-facing ribbons of a specified width.
|
|
108
|
+
*
|
|
109
|
+
* @tsl
|
|
110
|
+
* @type {Node<vec4>}
|
|
111
|
+
*/
|
|
112
|
+
const mvpLine = Fn( ( { material } ) => {
|
|
125
113
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
129
|
-
* @param {NodeBuilder} builder - The current node builder.
|
|
130
|
-
*/
|
|
131
|
-
setup( builder ) {
|
|
114
|
+
const useDash = material._useDash;
|
|
115
|
+
const useWorldUnits = material._useWorldUnits;
|
|
132
116
|
|
|
133
|
-
|
|
117
|
+
const instanceStart = attribute( 'instanceStart' );
|
|
118
|
+
const instanceEnd = attribute( 'instanceEnd' );
|
|
134
119
|
|
|
135
|
-
|
|
136
|
-
const vertexColors = this.vertexColors;
|
|
137
|
-
const useDash = this._useDash;
|
|
138
|
-
const useWorldUnits = this._useWorldUnits;
|
|
120
|
+
// camera space
|
|
139
121
|
|
|
140
|
-
|
|
122
|
+
const start = vec4( modelViewMatrix.mul( vec4( instanceStart, 1.0 ) ) ).toVar( 'start' );
|
|
123
|
+
const end = vec4( modelViewMatrix.mul( vec4( instanceEnd, 1.0 ) ) ).toVar( 'end' );
|
|
141
124
|
|
|
142
|
-
|
|
143
|
-
const b = cameraProjectionMatrix.element( 3 ).element( 2 ); // 3nd entry in 4th column
|
|
144
|
-
const nearEstimate = b.mul( - 0.5 ).div( a );
|
|
125
|
+
let distanceStart, distanceEnd;
|
|
145
126
|
|
|
146
|
-
|
|
127
|
+
if ( useDash ) {
|
|
147
128
|
|
|
148
|
-
|
|
129
|
+
distanceStart = float( attribute( 'instanceDistanceStart' ) ).toVar( 'distanceStart' );
|
|
130
|
+
distanceEnd = float( attribute( 'instanceDistanceEnd' ) ).toVar( 'distanceEnd' );
|
|
149
131
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
inputs: [
|
|
154
|
-
{ name: 'start', type: 'vec4' },
|
|
155
|
-
{ name: 'end', type: 'vec4' }
|
|
156
|
-
]
|
|
157
|
-
} );
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if ( useWorldUnits ) {
|
|
158
135
|
|
|
159
|
-
|
|
136
|
+
worldStart.assign( start.xyz );
|
|
137
|
+
worldEnd.assign( end.xyz );
|
|
160
138
|
|
|
161
|
-
|
|
162
|
-
const instanceEnd = attribute( 'instanceEnd' );
|
|
139
|
+
}
|
|
163
140
|
|
|
164
|
-
|
|
141
|
+
const aspect = viewport.z.div( viewport.w );
|
|
165
142
|
|
|
166
|
-
|
|
167
|
-
|
|
143
|
+
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
|
|
144
|
+
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
|
|
145
|
+
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
|
|
146
|
+
// perhaps there is a more elegant solution -- WestLangley
|
|
168
147
|
|
|
169
|
-
|
|
148
|
+
const perspective = cameraProjectionMatrix.element( 2 ).element( 3 ).equal( - 1.0 ); // 4th entry in the 3rd column
|
|
170
149
|
|
|
171
|
-
|
|
172
|
-
const offsetNode = this.offsetNode ? float( this.offsetNode ) : materialLineDashOffset;
|
|
150
|
+
If( perspective, () => {
|
|
173
151
|
|
|
174
|
-
|
|
175
|
-
const instanceDistanceEnd = attribute( 'instanceDistanceEnd' );
|
|
152
|
+
If( start.z.lessThan( 0.0 ).and( end.z.greaterThan( 0.0 ) ), () => {
|
|
176
153
|
|
|
177
|
-
|
|
178
|
-
|
|
154
|
+
const alpha = trimSegmentAlpha( { start, end } );
|
|
155
|
+
end.assign( vec4( mix( start.xyz, end.xyz, alpha ), end.w ) );
|
|
156
|
+
|
|
157
|
+
if ( useDash ) {
|
|
179
158
|
|
|
180
|
-
|
|
159
|
+
distanceEnd.assign( mix( distanceStart, distanceEnd, alpha ) );
|
|
181
160
|
|
|
182
161
|
}
|
|
183
162
|
|
|
184
|
-
|
|
163
|
+
} ).ElseIf( end.z.lessThan( 0.0 ).and( start.z.greaterThanEqual( 0.0 ) ), () => {
|
|
185
164
|
|
|
186
|
-
|
|
187
|
-
|
|
165
|
+
const alpha = trimSegmentAlpha( { start: end, end: start } );
|
|
166
|
+
start.assign( vec4( mix( end.xyz, start.xyz, alpha ), start.w ) );
|
|
188
167
|
|
|
189
|
-
|
|
168
|
+
if ( useDash ) {
|
|
190
169
|
|
|
191
|
-
|
|
170
|
+
distanceStart.assign( mix( distanceEnd, distanceStart, alpha ) );
|
|
192
171
|
|
|
193
|
-
|
|
194
|
-
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
|
|
195
|
-
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
|
|
196
|
-
// perhaps there is a more elegant solution -- WestLangley
|
|
172
|
+
}
|
|
197
173
|
|
|
198
|
-
|
|
174
|
+
} );
|
|
199
175
|
|
|
200
|
-
|
|
176
|
+
} );
|
|
201
177
|
|
|
202
|
-
|
|
178
|
+
if ( useDash ) {
|
|
203
179
|
|
|
204
|
-
|
|
180
|
+
const dashScaleNode = material.dashScaleNode ? float( material.dashScaleNode ) : materialLineScale;
|
|
181
|
+
const offsetNode = material.offsetNode ? float( material.offsetNode ) : materialLineDashOffset;
|
|
205
182
|
|
|
206
|
-
|
|
183
|
+
let lineDist = positionGeometry.y.lessThan( 0.5 ).select( dashScaleNode.mul( distanceStart ), dashScaleNode.mul( distanceEnd ) );
|
|
184
|
+
lineDist = lineDist.add( offsetNode );
|
|
207
185
|
|
|
208
|
-
|
|
186
|
+
lineDistance.assign( lineDist );
|
|
209
187
|
|
|
210
|
-
|
|
188
|
+
}
|
|
211
189
|
|
|
212
|
-
|
|
190
|
+
// clip space
|
|
191
|
+
const clipStart = cameraProjectionMatrix.mul( start );
|
|
192
|
+
const clipEnd = cameraProjectionMatrix.mul( end );
|
|
213
193
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
194
|
+
// ndc space
|
|
195
|
+
const ndcStart = clipStart.xyz.div( clipStart.w );
|
|
196
|
+
const ndcEnd = clipEnd.xyz.div( clipEnd.w );
|
|
217
197
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const ndcEnd = clipEnd.xyz.div( clipEnd.w );
|
|
198
|
+
// direction
|
|
199
|
+
const dir = ndcEnd.xy.sub( ndcStart.xy ).toVar();
|
|
221
200
|
|
|
222
|
-
|
|
223
|
-
|
|
201
|
+
// account for clip-space aspect ratio
|
|
202
|
+
dir.x.assign( dir.x.mul( aspect ) );
|
|
203
|
+
dir.assign( dir.normalize() );
|
|
224
204
|
|
|
225
|
-
|
|
226
|
-
dir.x.assign( dir.x.mul( aspect ) );
|
|
227
|
-
dir.assign( dir.normalize() );
|
|
205
|
+
const clip = vec4().toVar();
|
|
228
206
|
|
|
229
|
-
|
|
207
|
+
if ( useWorldUnits ) {
|
|
230
208
|
|
|
231
|
-
|
|
209
|
+
// get the offset direction as perpendicular to the view vector
|
|
232
210
|
|
|
233
|
-
|
|
211
|
+
const worldDir = end.xyz.sub( start.xyz ).normalize();
|
|
212
|
+
const tmpFwd = mix( start.xyz, end.xyz, 0.5 ).normalize();
|
|
213
|
+
const worldUp = worldDir.cross( tmpFwd ).normalize();
|
|
214
|
+
const worldFwd = worldDir.cross( worldUp );
|
|
234
215
|
|
|
235
|
-
|
|
236
|
-
const tmpFwd = mix( start.xyz, end.xyz, 0.5 ).normalize();
|
|
237
|
-
const worldUp = worldDir.cross( tmpFwd ).normalize();
|
|
238
|
-
const worldFwd = worldDir.cross( worldUp );
|
|
216
|
+
worldPos.assign( positionGeometry.y.lessThan( 0.5 ).select( start, end ) );
|
|
239
217
|
|
|
240
|
-
|
|
218
|
+
// height offset
|
|
219
|
+
const hw = materialLineWidth.mul( 0.5 );
|
|
220
|
+
worldPos.addAssign( vec4( positionGeometry.x.lessThan( 0.0 ).select( worldUp.mul( hw ), worldUp.mul( hw ).negate() ), 0 ) );
|
|
241
221
|
|
|
242
|
-
|
|
222
|
+
// don't extend the line if we're rendering dashes because we
|
|
223
|
+
// won't be rendering the endcaps
|
|
224
|
+
if ( ! useDash ) {
|
|
243
225
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
worldPos.addAssign( vec4( positionGeometry.x.lessThan( 0.0 ).select( worldUp.mul( hw ), worldUp.mul( hw ).negate() ), 0 ) );
|
|
226
|
+
// cap extension
|
|
227
|
+
worldPos.addAssign( vec4( positionGeometry.y.lessThan( 0.5 ).select( worldDir.mul( hw ).negate(), worldDir.mul( hw ) ), 0 ) );
|
|
247
228
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if ( ! useDash ) {
|
|
229
|
+
// add width to the box
|
|
230
|
+
worldPos.addAssign( vec4( worldFwd.mul( hw ), 0 ) );
|
|
251
231
|
|
|
252
|
-
|
|
253
|
-
|
|
232
|
+
// endcaps
|
|
233
|
+
If( positionGeometry.y.greaterThan( 1.0 ).or( positionGeometry.y.lessThan( 0.0 ) ), () => {
|
|
254
234
|
|
|
255
|
-
|
|
256
|
-
worldPos.addAssign( vec4( worldFwd.mul( hw ), 0 ) );
|
|
235
|
+
worldPos.subAssign( vec4( worldFwd.mul( 2.0 ).mul( hw ), 0 ) );
|
|
257
236
|
|
|
258
|
-
|
|
259
|
-
If( positionGeometry.y.greaterThan( 1.0 ).or( positionGeometry.y.lessThan( 0.0 ) ), () => {
|
|
237
|
+
} );
|
|
260
238
|
|
|
261
|
-
|
|
239
|
+
}
|
|
262
240
|
|
|
263
|
-
|
|
241
|
+
// project the worldpos
|
|
242
|
+
clip.assign( cameraProjectionMatrix.mul( worldPos ) );
|
|
264
243
|
|
|
265
|
-
|
|
244
|
+
// shift the depth of the projected points so the line
|
|
245
|
+
// segments overlap neatly
|
|
246
|
+
const clipPose = vec3().toVar();
|
|
266
247
|
|
|
267
|
-
|
|
268
|
-
|
|
248
|
+
clipPose.assign( positionGeometry.y.lessThan( 0.5 ).select( ndcStart, ndcEnd ) );
|
|
249
|
+
clip.z.assign( clipPose.z.mul( clip.w ) );
|
|
269
250
|
|
|
270
|
-
|
|
271
|
-
// segments overlap neatly
|
|
272
|
-
const clipPose = vec3().toVar();
|
|
251
|
+
} else {
|
|
273
252
|
|
|
274
|
-
|
|
275
|
-
clip.z.assign( clipPose.z.mul( clip.w ) );
|
|
253
|
+
const offset = vec2( dir.y, dir.x.negate() ).toVar( 'offset' );
|
|
276
254
|
|
|
277
|
-
|
|
255
|
+
// undo aspect ratio adjustment
|
|
256
|
+
dir.x.assign( dir.x.div( aspect ) );
|
|
257
|
+
offset.x.assign( offset.x.div( aspect ) );
|
|
278
258
|
|
|
279
|
-
|
|
259
|
+
// sign flip
|
|
260
|
+
offset.assign( positionGeometry.x.lessThan( 0.0 ).select( offset.negate(), offset ) );
|
|
280
261
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
offset.x.assign( offset.x.div( aspect ) );
|
|
262
|
+
// endcaps
|
|
263
|
+
If( positionGeometry.y.lessThan( 0.0 ), () => {
|
|
284
264
|
|
|
285
|
-
|
|
286
|
-
offset.assign( positionGeometry.x.lessThan( 0.0 ).select( offset.negate(), offset ) );
|
|
265
|
+
offset.assign( offset.sub( dir ) );
|
|
287
266
|
|
|
288
|
-
|
|
289
|
-
If( positionGeometry.y.lessThan( 0.0 ), () => {
|
|
267
|
+
} ).ElseIf( positionGeometry.y.greaterThan( 1.0 ), () => {
|
|
290
268
|
|
|
291
|
-
|
|
269
|
+
offset.assign( offset.add( dir ) );
|
|
292
270
|
|
|
293
|
-
|
|
271
|
+
} );
|
|
294
272
|
|
|
295
|
-
|
|
273
|
+
// adjust for linewidth
|
|
274
|
+
offset.assign( offset.mul( materialLineWidth ) );
|
|
296
275
|
|
|
297
|
-
|
|
276
|
+
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
|
|
277
|
+
offset.assign( offset.div( viewport.w.div( screenDPR ) ) );
|
|
298
278
|
|
|
299
|
-
|
|
300
|
-
|
|
279
|
+
// select end
|
|
280
|
+
clip.assign( positionGeometry.y.lessThan( 0.5 ).select( clipStart, clipEnd ) );
|
|
301
281
|
|
|
302
|
-
|
|
303
|
-
|
|
282
|
+
// back to clip space
|
|
283
|
+
offset.assign( offset.mul( clip.w ) );
|
|
304
284
|
|
|
305
|
-
|
|
306
|
-
clip.assign( positionGeometry.y.lessThan( 0.5 ).select( clipStart, clipEnd ) );
|
|
285
|
+
clip.assign( clip.add( vec4( offset, 0, 0 ) ) );
|
|
307
286
|
|
|
308
|
-
|
|
309
|
-
offset.assign( offset.mul( clip.w ) );
|
|
287
|
+
}
|
|
310
288
|
|
|
311
|
-
|
|
289
|
+
return clip;
|
|
312
290
|
|
|
313
|
-
|
|
291
|
+
} )();
|
|
314
292
|
|
|
315
|
-
|
|
293
|
+
/**
|
|
294
|
+
* TSL fragment node that computes the shape/coverage (alpha) of the fat line segment.
|
|
295
|
+
* Handles dash/gap generation, alpha-to-coverage rendering, and round endcaps.
|
|
296
|
+
*
|
|
297
|
+
* @tsl
|
|
298
|
+
* @type {Node<float>}
|
|
299
|
+
*/
|
|
300
|
+
const alphaLine = Fn( ( { material, renderer } ) => {
|
|
316
301
|
|
|
317
|
-
|
|
302
|
+
const useAlphaToCoverage = material._useAlphaToCoverage;
|
|
303
|
+
const useDash = material._useDash;
|
|
304
|
+
const useWorldUnits = material._useWorldUnits;
|
|
318
305
|
|
|
319
|
-
|
|
306
|
+
const vUv = uv();
|
|
320
307
|
|
|
321
|
-
|
|
322
|
-
const p43 = p4.sub( p3 );
|
|
308
|
+
if ( useDash ) {
|
|
323
309
|
|
|
324
|
-
|
|
310
|
+
const dashSizeNode = material.dashSizeNode ? float( material.dashSizeNode ) : materialLineDashSize;
|
|
311
|
+
const gapSizeNode = material.gapSizeNode ? float( material.gapSizeNode ) : materialLineGapSize;
|
|
325
312
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const d1321 = p13.dot( p21 );
|
|
329
|
-
const d4343 = p43.dot( p43 );
|
|
330
|
-
const d2121 = p21.dot( p21 );
|
|
313
|
+
dashSize.assign( dashSizeNode );
|
|
314
|
+
gapSize.assign( gapSizeNode );
|
|
331
315
|
|
|
332
|
-
|
|
333
|
-
|
|
316
|
+
vUv.y.lessThan( - 1.0 ).or( vUv.y.greaterThan( 1.0 ) ).discard(); // discard endcaps
|
|
317
|
+
lineDistance.mod( dashSize.add( gapSize ) ).greaterThan( dashSize ).discard(); // todo - FIX
|
|
334
318
|
|
|
335
|
-
|
|
336
|
-
const mub = d1343.add( d4321.mul( mua ) ).div( d4343 ).clamp();
|
|
319
|
+
}
|
|
337
320
|
|
|
338
|
-
|
|
321
|
+
const alpha = float( 1 ).toVar( 'alpha' );
|
|
339
322
|
|
|
340
|
-
|
|
323
|
+
if ( useWorldUnits ) {
|
|
341
324
|
|
|
342
|
-
|
|
325
|
+
// Find the closest points on the view ray and the line segment
|
|
326
|
+
const rayEnd = worldPos.xyz.normalize().mul( 1e5 );
|
|
327
|
+
const lineDir = worldEnd.sub( worldStart );
|
|
328
|
+
const params = closestLineToLine( { p1: worldStart, p2: worldEnd, p3: vec3( 0.0, 0.0, 0.0 ), p4: rayEnd } );
|
|
343
329
|
|
|
344
|
-
|
|
330
|
+
const p1 = worldStart.add( lineDir.mul( params.x ) );
|
|
331
|
+
const p2 = rayEnd.mul( params.y );
|
|
332
|
+
const delta = p1.sub( p2 );
|
|
333
|
+
const len = delta.length();
|
|
334
|
+
const norm = len.div( materialLineWidth );
|
|
345
335
|
|
|
346
|
-
|
|
336
|
+
if ( ! useDash ) {
|
|
347
337
|
|
|
348
|
-
|
|
349
|
-
const gapSizeNode = this.gapSizeNode ? float( this.gapSizeNode ) : materialLineGapSize;
|
|
338
|
+
if ( useAlphaToCoverage && renderer.currentSamples > 0 ) {
|
|
350
339
|
|
|
351
|
-
|
|
352
|
-
|
|
340
|
+
const dnorm = norm.fwidth();
|
|
341
|
+
alpha.assign( smoothstep( dnorm.negate().add( 0.5 ), dnorm.add( 0.5 ), norm ).oneMinus() );
|
|
353
342
|
|
|
354
|
-
|
|
343
|
+
} else {
|
|
355
344
|
|
|
356
|
-
|
|
357
|
-
vLineDistance.mod( dashSize.add( gapSize ) ).greaterThan( dashSize ).discard(); // todo - FIX
|
|
345
|
+
norm.greaterThan( 0.5 ).discard();
|
|
358
346
|
|
|
359
347
|
}
|
|
360
348
|
|
|
361
|
-
|
|
349
|
+
}
|
|
362
350
|
|
|
363
|
-
|
|
351
|
+
} else {
|
|
364
352
|
|
|
365
|
-
|
|
366
|
-
const worldEnd = varyingProperty( 'vec3', 'worldEnd' );
|
|
353
|
+
// round endcaps
|
|
367
354
|
|
|
368
|
-
|
|
369
|
-
const rayEnd = varyingProperty( 'vec4', 'worldPos' ).xyz.normalize().mul( 1e5 );
|
|
370
|
-
const lineDir = worldEnd.sub( worldStart );
|
|
371
|
-
const params = closestLineToLine( { p1: worldStart, p2: worldEnd, p3: vec3( 0.0, 0.0, 0.0 ), p4: rayEnd } );
|
|
355
|
+
if ( useAlphaToCoverage && renderer.currentSamples > 0 ) {
|
|
372
356
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
const delta = p1.sub( p2 );
|
|
376
|
-
const len = delta.length();
|
|
377
|
-
const norm = len.div( materialLineWidth );
|
|
357
|
+
const a = vUv.x;
|
|
358
|
+
const b = vUv.y.greaterThan( 0.0 ).select( vUv.y.sub( 1.0 ), vUv.y.add( 1.0 ) );
|
|
378
359
|
|
|
379
|
-
|
|
360
|
+
const len2 = a.mul( a ).add( b.mul( b ) );
|
|
380
361
|
|
|
381
|
-
|
|
362
|
+
const dlen = float( len2.fwidth() ).toVar( 'dlen' );
|
|
382
363
|
|
|
383
|
-
|
|
384
|
-
alpha.assign( smoothstep( dnorm.negate().add( 0.5 ), dnorm.add( 0.5 ), norm ).oneMinus() );
|
|
364
|
+
If( vUv.y.abs().greaterThan( 1.0 ), () => {
|
|
385
365
|
|
|
386
|
-
|
|
366
|
+
alpha.assign( smoothstep( dlen.oneMinus(), dlen.add( 1 ), len2 ).oneMinus() );
|
|
387
367
|
|
|
388
|
-
|
|
368
|
+
} );
|
|
389
369
|
|
|
390
|
-
|
|
370
|
+
} else {
|
|
391
371
|
|
|
392
|
-
|
|
372
|
+
If( vUv.y.abs().greaterThan( 1.0 ), () => {
|
|
393
373
|
|
|
394
|
-
|
|
374
|
+
const a = vUv.x;
|
|
375
|
+
const b = vUv.y.greaterThan( 0.0 ).select( vUv.y.sub( 1.0 ), vUv.y.add( 1.0 ) );
|
|
376
|
+
const len2 = a.mul( a ).add( b.mul( b ) );
|
|
395
377
|
|
|
396
|
-
|
|
378
|
+
len2.greaterThan( 1.0 ).discard();
|
|
397
379
|
|
|
398
|
-
|
|
380
|
+
} );
|
|
399
381
|
|
|
400
|
-
|
|
401
|
-
const b = vUv.y.greaterThan( 0.0 ).select( vUv.y.sub( 1.0 ), vUv.y.add( 1.0 ) );
|
|
382
|
+
}
|
|
402
383
|
|
|
403
|
-
|
|
384
|
+
}
|
|
404
385
|
|
|
405
|
-
|
|
386
|
+
return alpha;
|
|
406
387
|
|
|
407
|
-
|
|
388
|
+
} )();
|
|
408
389
|
|
|
409
|
-
|
|
390
|
+
/**
|
|
391
|
+
* This node material can be used to render lines with a size larger than one
|
|
392
|
+
* by representing them as instanced meshes.
|
|
393
|
+
*
|
|
394
|
+
* @augments NodeMaterial
|
|
395
|
+
*/
|
|
396
|
+
class Line2NodeMaterial extends NodeMaterial {
|
|
410
397
|
|
|
411
|
-
|
|
398
|
+
static get type() {
|
|
412
399
|
|
|
413
|
-
|
|
400
|
+
return 'Line2NodeMaterial';
|
|
414
401
|
|
|
415
|
-
|
|
402
|
+
}
|
|
416
403
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
404
|
+
/**
|
|
405
|
+
* Constructs a new node material for wide line rendering.
|
|
406
|
+
*
|
|
407
|
+
* @param {Object} [parameters={}] - The configuration parameter.
|
|
408
|
+
*/
|
|
409
|
+
constructor( parameters = {} ) {
|
|
420
410
|
|
|
421
|
-
|
|
411
|
+
super();
|
|
422
412
|
|
|
423
|
-
|
|
413
|
+
/**
|
|
414
|
+
* This flag can be used for type testing.
|
|
415
|
+
*
|
|
416
|
+
* @type {boolean}
|
|
417
|
+
* @readonly
|
|
418
|
+
* @default true
|
|
419
|
+
*/
|
|
420
|
+
this.isLine2NodeMaterial = true;
|
|
424
421
|
|
|
425
|
-
|
|
422
|
+
this.setDefaultValues( _defaultValues );
|
|
426
423
|
|
|
427
|
-
|
|
424
|
+
/**
|
|
425
|
+
* Whether vertex colors should be used or not.
|
|
426
|
+
*
|
|
427
|
+
* @type {boolean}
|
|
428
|
+
* @default false
|
|
429
|
+
*/
|
|
430
|
+
this.vertexColors = parameters.vertexColors;
|
|
428
431
|
|
|
429
|
-
|
|
432
|
+
/**
|
|
433
|
+
* The dash offset.
|
|
434
|
+
*
|
|
435
|
+
* @type {number}
|
|
436
|
+
* @default 0
|
|
437
|
+
*/
|
|
438
|
+
this.dashOffset = 0;
|
|
430
439
|
|
|
431
|
-
|
|
440
|
+
/**
|
|
441
|
+
* Defines the offset.
|
|
442
|
+
*
|
|
443
|
+
* @type {?Node<float>}
|
|
444
|
+
* @default null
|
|
445
|
+
*/
|
|
446
|
+
this.offsetNode = null;
|
|
432
447
|
|
|
433
|
-
|
|
448
|
+
/**
|
|
449
|
+
* Defines the dash scale.
|
|
450
|
+
*
|
|
451
|
+
* @type {?Node<float>}
|
|
452
|
+
* @default null
|
|
453
|
+
*/
|
|
454
|
+
this.dashScaleNode = null;
|
|
434
455
|
|
|
435
|
-
|
|
456
|
+
/**
|
|
457
|
+
* Defines the dash size.
|
|
458
|
+
*
|
|
459
|
+
* @type {?Node<float>}
|
|
460
|
+
* @default null
|
|
461
|
+
*/
|
|
462
|
+
this.dashSizeNode = null;
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Defines the gap size.
|
|
466
|
+
*
|
|
467
|
+
* @type {?Node<float>}
|
|
468
|
+
* @default null
|
|
469
|
+
*/
|
|
470
|
+
this.gapSizeNode = null;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Blending is set to `NoBlending` since transparency
|
|
474
|
+
* is not supported, yet.
|
|
475
|
+
*
|
|
476
|
+
* @type {number}
|
|
477
|
+
* @default 0
|
|
478
|
+
*/
|
|
479
|
+
this.blending = NoBlending;
|
|
436
480
|
|
|
437
|
-
|
|
481
|
+
this._useDash = parameters.dashed;
|
|
482
|
+
this._useAlphaToCoverage = true;
|
|
483
|
+
this._useWorldUnits = false;
|
|
438
484
|
|
|
439
|
-
|
|
440
|
-
const instanceColorEnd = attribute( 'instanceColorEnd' );
|
|
485
|
+
this.setValues( parameters );
|
|
441
486
|
|
|
442
|
-
|
|
487
|
+
}
|
|
443
488
|
|
|
444
|
-
|
|
489
|
+
/**
|
|
490
|
+
* Setups the diffuse color of the line material in the fragment stage.
|
|
491
|
+
* Overrides the base setup to incorporate line/dash rendering and blending.
|
|
492
|
+
*
|
|
493
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
494
|
+
*/
|
|
495
|
+
setupDiffuseColor( builder ) {
|
|
445
496
|
|
|
446
|
-
|
|
497
|
+
super.setupDiffuseColor( builder );
|
|
447
498
|
|
|
448
|
-
|
|
499
|
+
diffuseColor.a.mulAssign( alphaLine );
|
|
449
500
|
|
|
450
|
-
|
|
501
|
+
if ( this.vertexColors === true && builder.geometry.hasAttribute( 'instanceColorStart' ) ) {
|
|
451
502
|
|
|
452
|
-
|
|
503
|
+
const instanceColorStart = attribute( 'instanceColorStart' );
|
|
504
|
+
const instanceColorEnd = attribute( 'instanceColorEnd' );
|
|
453
505
|
|
|
454
|
-
|
|
506
|
+
const instanceColor = positionGeometry.y.lessThan( 0.5 ).select( instanceColorStart, instanceColorEnd );
|
|
455
507
|
|
|
456
|
-
|
|
508
|
+
diffuseColor.rgb.mulAssign( instanceColor );
|
|
457
509
|
|
|
458
|
-
|
|
510
|
+
}
|
|
459
511
|
|
|
460
|
-
|
|
512
|
+
if ( this.transparent ) {
|
|
461
513
|
|
|
462
|
-
|
|
514
|
+
diffuseColor.rgb.assign( diffuseColor.rgb.mul( diffuseColor.a ).add( viewportOpaqueMipTexture().rgb.mul( diffuseColor.a.oneMinus() ) ) );
|
|
463
515
|
|
|
464
516
|
}
|
|
465
517
|
|
|
466
|
-
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Setups the position in clip space for the vertex stage of the fat line.
|
|
522
|
+
* Overrides the default model-view-projection to return the expanded fat line vertex coordinates.
|
|
523
|
+
*
|
|
524
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
525
|
+
* @return {Node<vec4>} The position of the fat line vertex in clip space.
|
|
526
|
+
*/
|
|
527
|
+
setupModelViewProjection( /*builder*/ ) {
|
|
528
|
+
|
|
529
|
+
return mvpLine;
|
|
530
|
+
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Defines the lines color.
|
|
535
|
+
*
|
|
536
|
+
* @deprecated since r185. Use {@link NodeMaterial#colorNode} instead.
|
|
537
|
+
* @type {?Node<vec3>}
|
|
538
|
+
*/
|
|
539
|
+
get lineColorNode() {
|
|
540
|
+
|
|
541
|
+
return this.colorNode;
|
|
542
|
+
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
set lineColorNode( value ) {
|
|
546
|
+
|
|
547
|
+
warnOnce( 'Line2NodeMaterial: "lineColorNode" has been deprecated. Use "colorNode" instead.' ); // @deprecated r185
|
|
548
|
+
|
|
549
|
+
this.colorNode = value;
|
|
467
550
|
|
|
468
551
|
}
|
|
469
552
|
|
|
@@ -537,33 +620,6 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
537
620
|
|
|
538
621
|
}
|
|
539
622
|
|
|
540
|
-
/**
|
|
541
|
-
* Copies the properties of the given material to this instance.
|
|
542
|
-
*
|
|
543
|
-
* @param {Line2NodeMaterial} source - The material to copy.
|
|
544
|
-
* @return {Line2NodeMaterial} A reference to this material.
|
|
545
|
-
*/
|
|
546
|
-
copy( source ) {
|
|
547
|
-
|
|
548
|
-
super.copy( source );
|
|
549
|
-
|
|
550
|
-
this.vertexColors = source.vertexColors;
|
|
551
|
-
this.dashOffset = source.dashOffset;
|
|
552
|
-
|
|
553
|
-
this.lineColorNode = source.lineColorNode;
|
|
554
|
-
this.offsetNode = source.offsetNode;
|
|
555
|
-
this.dashScaleNode = source.dashScaleNode;
|
|
556
|
-
this.dashSizeNode = source.dashSizeNode;
|
|
557
|
-
this.gapSizeNode = source.gapSizeNode;
|
|
558
|
-
|
|
559
|
-
this._useDash = source._useDash;
|
|
560
|
-
this._useAlphaToCoverage = source._useAlphaToCoverage;
|
|
561
|
-
this._useWorldUnits = source._useWorldUnits;
|
|
562
|
-
|
|
563
|
-
return this;
|
|
564
|
-
|
|
565
|
-
}
|
|
566
|
-
|
|
567
623
|
}
|
|
568
624
|
|
|
569
625
|
export default Line2NodeMaterial;
|