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,5 +1,5 @@
|
|
|
1
1
|
import Node from './Node.js';
|
|
2
|
-
import { nodeImmutable } from '../tsl/TSLCore.js';
|
|
2
|
+
import { nodeImmutable, nodeObject } from '../tsl/TSLCore.js';
|
|
3
3
|
import { hashString } from './NodeUtils.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -28,8 +28,9 @@ class PropertyNode extends Node {
|
|
|
28
28
|
* @param {string} nodeType - The type of the node.
|
|
29
29
|
* @param {?string} [name=null] - The name of the property in the shader.
|
|
30
30
|
* @param {boolean} [varying=false] - Whether this property is a varying or not.
|
|
31
|
+
* @param {?Node} [placeholderNode=null] - The placeholder node if not assigned.
|
|
31
32
|
*/
|
|
32
|
-
constructor( nodeType, name = null, varying = false ) {
|
|
33
|
+
constructor( nodeType, name = null, varying = false, placeholderNode = null ) {
|
|
33
34
|
|
|
34
35
|
super( nodeType );
|
|
35
36
|
|
|
@@ -50,6 +51,14 @@ class PropertyNode extends Node {
|
|
|
50
51
|
*/
|
|
51
52
|
this.varying = varying;
|
|
52
53
|
|
|
54
|
+
/**
|
|
55
|
+
* The placeholder node of the property if it is not assigned.
|
|
56
|
+
*
|
|
57
|
+
* @type {?Node}
|
|
58
|
+
* @default null
|
|
59
|
+
*/
|
|
60
|
+
this.placeholderNode = nodeObject( placeholderNode );
|
|
61
|
+
|
|
53
62
|
/**
|
|
54
63
|
* This flag can be used for type testing.
|
|
55
64
|
*
|
|
@@ -69,6 +78,20 @@ class PropertyNode extends Node {
|
|
|
69
78
|
|
|
70
79
|
}
|
|
71
80
|
|
|
81
|
+
getNodeType( builder ) {
|
|
82
|
+
|
|
83
|
+
const nodeType = super.getNodeType( builder );
|
|
84
|
+
|
|
85
|
+
if ( nodeType === 'output' ) {
|
|
86
|
+
|
|
87
|
+
return builder.getOutputType();
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return nodeType;
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
72
95
|
customCacheKey() {
|
|
73
96
|
|
|
74
97
|
return hashString( this.type + ':' + ( this.name || '' ) + ':' + ( this.varying ? '1' : '0' ) );
|
|
@@ -94,6 +117,18 @@ class PropertyNode extends Node {
|
|
|
94
117
|
|
|
95
118
|
nodeVar = builder.getVarFromNode( this, this.name );
|
|
96
119
|
|
|
120
|
+
if ( this.placeholderNode !== null ) {
|
|
121
|
+
|
|
122
|
+
if ( builder.hasWriteUsage( this ) === false ) {
|
|
123
|
+
|
|
124
|
+
const snippet = this.placeholderNode.build( builder, this.getNodeType( builder ) );
|
|
125
|
+
|
|
126
|
+
builder.addLineFlowCode( `${ builder.getPropertyName( nodeVar ) } = ${ snippet }`, this );
|
|
127
|
+
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
|
|
97
132
|
}
|
|
98
133
|
|
|
99
134
|
return builder.getPropertyName( nodeVar );
|
|
@@ -111,9 +146,10 @@ export default PropertyNode;
|
|
|
111
146
|
* @function
|
|
112
147
|
* @param {string} type - The type of the node.
|
|
113
148
|
* @param {?string} [name=null] - The name of the property in the shader.
|
|
149
|
+
* @param {?Node} [placeholderNode=null] - The placeholder node if not assigned.
|
|
114
150
|
* @returns {PropertyNode}
|
|
115
151
|
*/
|
|
116
|
-
export const property = ( type, name ) => new PropertyNode( type, name );
|
|
152
|
+
export const property = ( type, name, placeholderNode = null ) => new PropertyNode( type, name, false, placeholderNode );
|
|
117
153
|
|
|
118
154
|
/**
|
|
119
155
|
* TSL function for creating a varying property node.
|
|
@@ -122,9 +158,10 @@ export const property = ( type, name ) => new PropertyNode( type, name );
|
|
|
122
158
|
* @function
|
|
123
159
|
* @param {string} type - The type of the node.
|
|
124
160
|
* @param {?string} [name=null] - The name of the varying in the shader.
|
|
161
|
+
* @param {?Node} [placeholderNode=null] - The placeholder node if not assigned.
|
|
125
162
|
* @returns {PropertyNode}
|
|
126
163
|
*/
|
|
127
|
-
export const varyingProperty = ( type, name ) => new PropertyNode( type, name, true );
|
|
164
|
+
export const varyingProperty = ( type, name, placeholderNode = null ) => new PropertyNode( type, name, true, placeholderNode );
|
|
128
165
|
|
|
129
166
|
/**
|
|
130
167
|
* TSL object that represents the shader variable `DiffuseColor`.
|
|
@@ -292,7 +329,7 @@ export const shininess = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'Sh
|
|
|
292
329
|
* @tsl
|
|
293
330
|
* @type {PropertyNode<vec4>}
|
|
294
331
|
*/
|
|
295
|
-
export const output = /*@__PURE__*/ nodeImmutable( PropertyNode, '
|
|
332
|
+
export const output = /*@__PURE__*/ nodeImmutable( PropertyNode, 'output', 'Output' );
|
|
296
333
|
|
|
297
334
|
/**
|
|
298
335
|
* TSL object that represents the shader variable `dashSize`.
|
|
@@ -365,3 +402,12 @@ export const attenuationColor = /*@__PURE__*/ nodeImmutable( PropertyNode, 'colo
|
|
|
365
402
|
* @type {PropertyNode<float>}
|
|
366
403
|
*/
|
|
367
404
|
export const dispersion = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'Dispersion' );
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* TSL object that represents the shader variable `AmbientOcclusion`.
|
|
408
|
+
* If no value is assigned to this property, it defaults to a placeholder value of `1.0`.
|
|
409
|
+
*
|
|
410
|
+
* @tsl
|
|
411
|
+
* @type {PropertyNode<float>}
|
|
412
|
+
*/
|
|
413
|
+
export const ambientOcclusion = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'AmbientOcclusion', false, 1 );
|
|
@@ -78,6 +78,14 @@ class StackNode extends Node {
|
|
|
78
78
|
*/
|
|
79
79
|
this._currentNode = null;
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Stores additional data for nodes that are added to the stack.
|
|
83
|
+
*
|
|
84
|
+
* @private
|
|
85
|
+
* @type {Map<Node, {delta: number}>}
|
|
86
|
+
*/
|
|
87
|
+
this._nodeDataLibrary = new Map();
|
|
88
|
+
|
|
81
89
|
/**
|
|
82
90
|
* This flag can be used for type testing.
|
|
83
91
|
*
|
|
@@ -91,19 +99,19 @@ class StackNode extends Node {
|
|
|
91
99
|
|
|
92
100
|
getElementType( builder ) {
|
|
93
101
|
|
|
94
|
-
return this.
|
|
102
|
+
return this.outputNode ? this.outputNode.getElementType( builder ) : 'void';
|
|
95
103
|
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
generateNodeType( builder ) {
|
|
99
107
|
|
|
100
|
-
return this.
|
|
108
|
+
return this.outputNode ? this.outputNode.getNodeType( builder ) : 'void';
|
|
101
109
|
|
|
102
110
|
}
|
|
103
111
|
|
|
104
112
|
getMemberType( builder, name ) {
|
|
105
113
|
|
|
106
|
-
return this.
|
|
114
|
+
return this.outputNode ? this.outputNode.getMemberType( builder, name ) : 'void';
|
|
107
115
|
|
|
108
116
|
}
|
|
109
117
|
|
|
@@ -111,10 +119,10 @@ class StackNode extends Node {
|
|
|
111
119
|
* Adds a node to this stack.
|
|
112
120
|
*
|
|
113
121
|
* @param {Node} node - The node to add.
|
|
114
|
-
* @param {number} [index
|
|
122
|
+
* @param {number} [index=-1] - The index of the node. If not specified, the node will be added to the end of the stack.
|
|
115
123
|
* @return {StackNode} A reference to this stack node.
|
|
116
124
|
*/
|
|
117
|
-
addToStack( node, index =
|
|
125
|
+
addToStack( node, index = - 1 ) {
|
|
118
126
|
|
|
119
127
|
if ( node.isNode !== true ) {
|
|
120
128
|
|
|
@@ -123,6 +131,35 @@ class StackNode extends Node {
|
|
|
123
131
|
|
|
124
132
|
}
|
|
125
133
|
|
|
134
|
+
|
|
135
|
+
if ( index === - 1 ) {
|
|
136
|
+
|
|
137
|
+
if ( this._currentNode ) {
|
|
138
|
+
|
|
139
|
+
let nodeData = this._nodeDataLibrary.get( this._currentNode );
|
|
140
|
+
|
|
141
|
+
if ( nodeData === undefined ) {
|
|
142
|
+
|
|
143
|
+
nodeData = {
|
|
144
|
+
delta: 0
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
this._nodeDataLibrary.set( this._currentNode, nodeData );
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
nodeData.delta ++;
|
|
152
|
+
|
|
153
|
+
index = this.nodes.indexOf( this._currentNode ) + nodeData.delta;
|
|
154
|
+
|
|
155
|
+
} else {
|
|
156
|
+
|
|
157
|
+
index = this.nodes.length;
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
|
|
126
163
|
this.nodes.splice( index, 0, node );
|
|
127
164
|
|
|
128
165
|
return this;
|
|
@@ -312,12 +349,6 @@ class StackNode extends Node {
|
|
|
312
349
|
|
|
313
350
|
}
|
|
314
351
|
|
|
315
|
-
hasOutput( builder ) {
|
|
316
|
-
|
|
317
|
-
return this.outputNode && this.outputNode.isNode && this.outputNode.getNodeType( builder ) !== 'void';
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
|
|
321
352
|
build( builder, ...params ) {
|
|
322
353
|
|
|
323
354
|
const previousStack = getCurrentStack();
|
|
@@ -330,7 +361,10 @@ class StackNode extends Node {
|
|
|
330
361
|
|
|
331
362
|
//
|
|
332
363
|
|
|
333
|
-
|
|
364
|
+
for ( let i = 0; i < this.nodes.length; i ++ ) {
|
|
365
|
+
|
|
366
|
+
const node = this.nodes[ i ];
|
|
367
|
+
const previousNode = this._currentNode;
|
|
334
368
|
|
|
335
369
|
this._currentNode = node;
|
|
336
370
|
|
|
@@ -338,7 +372,7 @@ class StackNode extends Node {
|
|
|
338
372
|
|
|
339
373
|
if ( node.isAssign( builder ) !== true ) {
|
|
340
374
|
|
|
341
|
-
|
|
375
|
+
continue;
|
|
342
376
|
|
|
343
377
|
}
|
|
344
378
|
|
|
@@ -359,7 +393,7 @@ class StackNode extends Node {
|
|
|
359
393
|
|
|
360
394
|
if ( node.isVarNode && parents && parents.length === 1 && parents[ 0 ] && parents[ 0 ].isStackNode ) {
|
|
361
395
|
|
|
362
|
-
|
|
396
|
+
continue; // skip var nodes that are only used in .toVarying()
|
|
363
397
|
|
|
364
398
|
}
|
|
365
399
|
|
|
@@ -367,35 +401,23 @@ class StackNode extends Node {
|
|
|
367
401
|
|
|
368
402
|
}
|
|
369
403
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
//
|
|
373
|
-
|
|
374
|
-
const nodes = [ ...this.nodes ];
|
|
375
|
-
|
|
376
|
-
for ( const node of nodes ) {
|
|
377
|
-
|
|
378
|
-
buildNode( node );
|
|
404
|
+
this._currentNode = previousNode;
|
|
379
405
|
|
|
380
406
|
}
|
|
381
407
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
const newNodes = this.nodes.filter( ( node ) => nodes.indexOf( node ) === - 1 );
|
|
385
|
-
|
|
386
|
-
for ( const node of newNodes ) {
|
|
408
|
+
//
|
|
387
409
|
|
|
388
|
-
|
|
410
|
+
let result;
|
|
389
411
|
|
|
390
|
-
|
|
412
|
+
if ( this.outputNode ) {
|
|
391
413
|
|
|
392
|
-
|
|
414
|
+
const buildResult = this.outputNode.build( builder, ...params );
|
|
393
415
|
|
|
394
|
-
|
|
416
|
+
if ( builder.buildStage !== 'generate' || this.outputNode.getNodeType( builder ) !== 'void' ) {
|
|
395
417
|
|
|
396
|
-
|
|
418
|
+
result = buildResult;
|
|
397
419
|
|
|
398
|
-
|
|
420
|
+
}
|
|
399
421
|
|
|
400
422
|
} else {
|
|
401
423
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Node from './Node.js';
|
|
2
2
|
import StructTypeNode from './StructTypeNode.js';
|
|
3
|
+
import { nodeProxyConstructor } from '../tsl/TSLCore.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* StructNode allows to create custom structures with multiple members.
|
|
@@ -94,7 +95,7 @@ export default StructNode;
|
|
|
94
95
|
*/
|
|
95
96
|
export const struct = ( membersLayout, name = null ) => {
|
|
96
97
|
|
|
97
|
-
const
|
|
98
|
+
const structType = new StructTypeNode( membersLayout, name );
|
|
98
99
|
|
|
99
100
|
const struct = ( ...params ) => {
|
|
100
101
|
|
|
@@ -122,13 +123,10 @@ export const struct = ( membersLayout, name = null ) => {
|
|
|
122
123
|
|
|
123
124
|
}
|
|
124
125
|
|
|
125
|
-
return new StructNode(
|
|
126
|
+
return new StructNode( structType, values );
|
|
126
127
|
|
|
127
128
|
};
|
|
128
129
|
|
|
129
|
-
struct
|
|
130
|
-
struct.isStruct = true;
|
|
131
|
-
|
|
132
|
-
return struct;
|
|
130
|
+
return nodeProxyConstructor( struct, structType );
|
|
133
131
|
|
|
134
132
|
};
|
|
@@ -74,19 +74,19 @@ class StructTypeNode extends Node {
|
|
|
74
74
|
* @readonly
|
|
75
75
|
* @default true
|
|
76
76
|
*/
|
|
77
|
-
this.
|
|
77
|
+
this.isStructTypeNode = true;
|
|
78
78
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
|
-
* Returns the length of the struct.
|
|
83
|
-
* The length is calculated by summing the lengths of the struct's members.
|
|
82
|
+
* Returns the length of the struct in 4-byte elements (e.g. float or int components).
|
|
83
|
+
* The length is calculated by summing the lengths of the struct's members, accounting for memory alignment.
|
|
84
|
+
* To get the size in bytes, multiply the returned value by 4.
|
|
84
85
|
*
|
|
85
|
-
* @returns {number} The length of the struct.
|
|
86
|
+
* @returns {number} The length of the struct in 4-byte elements.
|
|
86
87
|
*/
|
|
87
88
|
getLength() {
|
|
88
89
|
|
|
89
|
-
const BYTES_PER_ELEMENT = Float32Array.BYTES_PER_ELEMENT;
|
|
90
90
|
let maxAlignment = 1; // maximum alignment value in this struct
|
|
91
91
|
let offset = 0; // global buffer offset in 4 byte elements
|
|
92
92
|
|
|
@@ -95,7 +95,7 @@ class StructTypeNode extends Node {
|
|
|
95
95
|
const type = member.type;
|
|
96
96
|
|
|
97
97
|
const itemSize = getMemoryLengthFromType( type );
|
|
98
|
-
const alignment = getAlignmentFromType( type )
|
|
98
|
+
const alignment = getAlignmentFromType( type );
|
|
99
99
|
maxAlignment = Math.max( maxAlignment, alignment );
|
|
100
100
|
|
|
101
101
|
const chunkOffset = offset % maxAlignment; // offset in the current chunk of maxAlignment elements
|
|
@@ -175,6 +175,14 @@ class VarNode extends Node {
|
|
|
175
175
|
|
|
176
176
|
const builder = params[ 0 ];
|
|
177
177
|
|
|
178
|
+
const refNode = this.getShared( builder );
|
|
179
|
+
|
|
180
|
+
if ( this !== refNode ) {
|
|
181
|
+
|
|
182
|
+
return refNode.build( ...params );
|
|
183
|
+
|
|
184
|
+
}
|
|
185
|
+
|
|
178
186
|
if ( this._hasStack( builder ) === false && builder.buildStage === 'setup' ) {
|
|
179
187
|
|
|
180
188
|
if ( builder.context.nodeLoop || builder.context.nodeBlock ) {
|
|
@@ -170,8 +170,18 @@ class VaryingNode extends Node {
|
|
|
170
170
|
const type = this.getNodeType( builder );
|
|
171
171
|
const propertyName = builder.getPropertyName( varying, NodeShaderStage.VERTEX );
|
|
172
172
|
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
if ( builder.shaderStage === NodeShaderStage.VERTEX ) {
|
|
174
|
+
|
|
175
|
+
const snippet = properties.node.build( builder, type );
|
|
176
|
+
|
|
177
|
+
builder.addLineFlowCode( `${ propertyName } = ${ snippet }`, this );
|
|
178
|
+
|
|
179
|
+
} else {
|
|
180
|
+
|
|
181
|
+
// force node run in vertex stage
|
|
182
|
+
builder.flowNodeFromShaderStage( NodeShaderStage.VERTEX, properties.node, type, propertyName );
|
|
183
|
+
|
|
184
|
+
}
|
|
175
185
|
|
|
176
186
|
properties[ propertyKey ] = propertyName;
|
|
177
187
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fn,
|
|
1
|
+
import { Fn, vec4 } from '../tsl/TSLCore.js';
|
|
2
2
|
import { mix, min, step } from '../math/MathNode.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -129,43 +129,3 @@ export const blendColor = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
|
129
129
|
{ name: 'blend', type: 'vec4' }
|
|
130
130
|
]
|
|
131
131
|
} );
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Premultiplies the RGB channels of a color by its alpha channel.
|
|
135
|
-
*
|
|
136
|
-
* This function is useful for converting a non-premultiplied alpha color
|
|
137
|
-
* into a premultiplied alpha format, where the RGB values are scaled
|
|
138
|
-
* by the alpha value. Premultiplied alpha is often used in graphics
|
|
139
|
-
* rendering for certain operations, such as compositing and image processing.
|
|
140
|
-
*
|
|
141
|
-
* @tsl
|
|
142
|
-
* @function
|
|
143
|
-
* @param {Node<vec4>} color - The input color with non-premultiplied alpha.
|
|
144
|
-
* @return {Node<vec4>} The color with premultiplied alpha.
|
|
145
|
-
*/
|
|
146
|
-
export const premultiplyAlpha = /*@__PURE__*/ Fn( ( [ color ] ) => {
|
|
147
|
-
|
|
148
|
-
return vec4( color.rgb.mul( color.a ), color.a );
|
|
149
|
-
|
|
150
|
-
}, { color: 'vec4', return: 'vec4' } );
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Unpremultiplies the RGB channels of a color by its alpha channel.
|
|
154
|
-
*
|
|
155
|
-
* This function is useful for converting a premultiplied alpha color
|
|
156
|
-
* back into a non-premultiplied alpha format, where the RGB values are
|
|
157
|
-
* divided by the alpha value. Unpremultiplied alpha is often used in graphics
|
|
158
|
-
* rendering for certain operations, such as compositing and image processing.
|
|
159
|
-
*
|
|
160
|
-
* @tsl
|
|
161
|
-
* @function
|
|
162
|
-
* @param {Node<vec4>} color - The input color with premultiplied alpha.
|
|
163
|
-
* @return {Node<vec4>} The color with non-premultiplied alpha.
|
|
164
|
-
*/
|
|
165
|
-
export const unpremultiplyAlpha = /*@__PURE__*/ Fn( ( [ color ] ) => {
|
|
166
|
-
|
|
167
|
-
If( color.a.equal( 0.0 ), () => vec4( 0.0 ) );
|
|
168
|
-
|
|
169
|
-
return vec4( color.rgb.div( color.a ), color.a );
|
|
170
|
-
|
|
171
|
-
}, { color: 'vec4', return: 'vec4' } );
|
|
@@ -88,7 +88,12 @@ class BumpMapNode extends TempNode {
|
|
|
88
88
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
setup() {
|
|
91
|
+
setup( builder ) {
|
|
92
|
+
|
|
93
|
+
// Screen-space derivatives are unreliable on thin lines, so the bump
|
|
94
|
+
// effect is disabled for wireframe rendering.
|
|
95
|
+
|
|
96
|
+
if ( builder.material.wireframe === true ) return normalView;
|
|
92
97
|
|
|
93
98
|
const bumpScale = this.scaleNode !== null ? this.scaleNode : 1;
|
|
94
99
|
const dHdxy = dHdxy_fwd( { textureNode: this.textureNode, bumpScale } );
|
|
@@ -30,7 +30,7 @@ export const grayscale = /*@__PURE__*/ Fn( ( [ color ] ) => {
|
|
|
30
30
|
*/
|
|
31
31
|
export const saturation = /*@__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ] ) => {
|
|
32
32
|
|
|
33
|
-
return adjustment.mix( luminance( color.rgb ), color.rgb );
|
|
33
|
+
return adjustment.mix( luminance( color.rgb ), color.rgb ).max( 0.0 );
|
|
34
34
|
|
|
35
35
|
} );
|
|
36
36
|
|
|
@@ -42,17 +42,17 @@ export const saturation = /*@__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ]
|
|
|
42
42
|
* @tsl
|
|
43
43
|
* @function
|
|
44
44
|
* @param {Node<vec3>} color - The input color.
|
|
45
|
-
* @param {Node<float>} [adjustment=
|
|
45
|
+
* @param {Node<float>} [adjustment=0] - Controls the intensity of the vibrance effect.
|
|
46
46
|
* @return {Node<vec3>} The updated color.
|
|
47
47
|
*/
|
|
48
|
-
export const vibrance = /*@__PURE__*/ Fn( ( [ color, adjustment = float(
|
|
48
|
+
export const vibrance = /*@__PURE__*/ Fn( ( [ color, adjustment = float( 0 ) ] ) => {
|
|
49
49
|
|
|
50
50
|
const average = add( color.r, color.g, color.b ).div( 3.0 );
|
|
51
51
|
|
|
52
52
|
const mx = color.r.max( color.g.max( color.b ) );
|
|
53
53
|
const amt = mx.sub( average ).mul( adjustment ).mul( - 3.0 );
|
|
54
54
|
|
|
55
|
-
return mix( color.rgb, mx, amt );
|
|
55
|
+
return mix( color.rgb, mx, amt ).max( 0.0 );
|
|
56
56
|
|
|
57
57
|
} );
|
|
58
58
|
|
|
@@ -71,7 +71,7 @@ export const hue = /*@__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ] ) => {
|
|
|
71
71
|
|
|
72
72
|
const cosAngle = adjustment.cos();
|
|
73
73
|
|
|
74
|
-
return vec3( color.rgb.mul( cosAngle ).add( k.cross( color.rgb ).mul( adjustment.sin() ).add( k.mul( dot( k, color.rgb ).mul( cosAngle.oneMinus() ) ) ) ) );
|
|
74
|
+
return vec3( color.rgb.mul( cosAngle ).add( k.cross( color.rgb ).mul( adjustment.sin() ).add( k.mul( dot( k, color.rgb ).mul( cosAngle.oneMinus() ) ) ) ) ).max( 0.0 );
|
|
75
75
|
|
|
76
76
|
} );
|
|
77
77
|
|
|
@@ -123,18 +123,19 @@ export const cdl = /*@__PURE__*/ Fn( ( [
|
|
|
123
123
|
|
|
124
124
|
// NOTE: The ASC CDL v1.2 defines a [0, 1] clamp on the slope+offset term, and another on the
|
|
125
125
|
// saturation term. Per the ACEScc specification and Filament, limits may be omitted to support
|
|
126
|
-
//
|
|
126
|
+
// if negative inputs to the power expression are avoided. We use `max( in, 0.0 )`
|
|
127
|
+
// on final output, but the lower limit may not be required in all cases.
|
|
127
128
|
|
|
128
129
|
const luma = color.rgb.dot( vec3( luminanceCoefficients ) );
|
|
129
130
|
|
|
130
|
-
const v = max( color.rgb.mul( slope ).add( offset ), 0.0 )
|
|
131
|
-
const pv = v.pow( power )
|
|
131
|
+
const v = max( color.rgb.mul( slope ).add( offset ), 0.0 );
|
|
132
|
+
const pv = v.pow( power );
|
|
132
133
|
|
|
133
134
|
If( v.r.greaterThan( 0.0 ), () => { v.r.assign( pv.r ); } ); // eslint-disable-line
|
|
134
135
|
If( v.g.greaterThan( 0.0 ), () => { v.g.assign( pv.g ); } ); // eslint-disable-line
|
|
135
136
|
If( v.b.greaterThan( 0.0 ), () => { v.b.assign( pv.b ); } ); // eslint-disable-line
|
|
136
137
|
|
|
137
|
-
v.assign( luma.add( v.sub( luma ).mul( saturation ) ) );
|
|
138
|
+
v.assign( luma.add( v.sub( luma ).mul( saturation ) ).max( 0 ) );
|
|
138
139
|
|
|
139
140
|
return vec4( v.rgb, color.a );
|
|
140
141
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Node from '../core/Node.js';
|
|
2
2
|
import { nodeImmutable, float, Fn } from '../tsl/TSLBase.js';
|
|
3
|
+
import { warnOnce } from '../../utils.js';
|
|
3
4
|
|
|
4
5
|
import { BackSide, DoubleSide } from '../../constants.js';
|
|
5
6
|
|
|
@@ -74,29 +75,57 @@ export const frontFacing = /*@__PURE__*/ nodeImmutable( FrontFacingNode );
|
|
|
74
75
|
export const faceDirection = /*@__PURE__*/ float( frontFacing ).mul( 2.0 ).sub( 1.0 );
|
|
75
76
|
|
|
76
77
|
/**
|
|
77
|
-
*
|
|
78
|
+
* Negates a vector if the rendering occurs on the back side of a face,
|
|
79
|
+
* based on the material's side configuration.
|
|
78
80
|
*
|
|
79
|
-
* If the material is
|
|
80
|
-
* If the material is
|
|
81
|
+
* - If the material's side is `BackSide`, the vector is inverted (negated).
|
|
82
|
+
* - If the material's side is `DoubleSide`, the vector is multiplied by `faceDirection`
|
|
83
|
+
* (negated only for back-facing fragments).
|
|
84
|
+
* - If the material's side is `FrontSide` (default), the vector remains unchanged.
|
|
81
85
|
*
|
|
82
86
|
* @tsl
|
|
83
|
-
* @
|
|
84
|
-
* @
|
|
87
|
+
* @function
|
|
88
|
+
* @param {Node<vec3>} vector - The vector to process.
|
|
89
|
+
* @returns {Node<vec3>} The processed vector.
|
|
85
90
|
*/
|
|
86
|
-
export const
|
|
91
|
+
export const negateOnBackSide = /*@__PURE__*/ Fn( ( [ vector ], { material } ) => {
|
|
87
92
|
|
|
88
93
|
const side = material.side;
|
|
89
94
|
|
|
90
95
|
if ( side === BackSide ) {
|
|
91
96
|
|
|
92
|
-
|
|
97
|
+
vector = vector.mul( - 1.0 );
|
|
93
98
|
|
|
94
99
|
} else if ( side === DoubleSide ) {
|
|
95
100
|
|
|
96
|
-
|
|
101
|
+
vector = vector.mul( faceDirection );
|
|
97
102
|
|
|
98
103
|
}
|
|
99
104
|
|
|
100
|
-
return
|
|
105
|
+
return vector;
|
|
101
106
|
|
|
102
107
|
} );
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Negates a vector if the rendering occurs on the back side of a face,
|
|
111
|
+
* based on the material's side configuration.
|
|
112
|
+
*
|
|
113
|
+
* - If the material's side is `BackSide`, the vector is inverted (negated).
|
|
114
|
+
* - If the material's side is `DoubleSide`, the vector is multiplied by `faceDirection`
|
|
115
|
+
* (negated only for back-facing fragments).
|
|
116
|
+
* - If the material's side is `FrontSide` (default), the vector remains unchanged.
|
|
117
|
+
*
|
|
118
|
+
* @tsl
|
|
119
|
+
* @function
|
|
120
|
+
* @deprecated since r185. Use {@link negateOnBackSide} instead.
|
|
121
|
+
* @param {Node<vec3>} vector - The vector to convert.
|
|
122
|
+
* @returns {Node<vec3>} The converted vector.
|
|
123
|
+
*/
|
|
124
|
+
export const directionToFaceDirection = ( vector ) => {
|
|
125
|
+
|
|
126
|
+
warnOnce( 'TSL: "directionToFaceDirection()" has been renamed to "negateOnBackSide()".' ); // @deprecated r185
|
|
127
|
+
|
|
128
|
+
return negateOnBackSide( vector );
|
|
129
|
+
|
|
130
|
+
};
|
|
131
|
+
|
|
@@ -5,7 +5,7 @@ import { TBNViewMatrix } from '../accessors/AccessorsUtils.js';
|
|
|
5
5
|
import { nodeProxy, vec3 } from '../tsl/TSLBase.js';
|
|
6
6
|
|
|
7
7
|
import { TangentSpaceNormalMap, ObjectSpaceNormalMap, NoNormalPacking, NormalRGPacking, NormalGAPacking } from '../../constants.js';
|
|
8
|
-
import {
|
|
8
|
+
import { negateOnBackSide } from './FrontFacingNode.js';
|
|
9
9
|
import { unpackNormal } from '../utils/Packing.js';
|
|
10
10
|
import { error } from '../../utils.js';
|
|
11
11
|
|
|
@@ -107,7 +107,7 @@ class NormalMapNode extends TempNode {
|
|
|
107
107
|
|
|
108
108
|
if ( builder.isFlatShading() === true ) {
|
|
109
109
|
|
|
110
|
-
scale =
|
|
110
|
+
scale = negateOnBackSide( scale );
|
|
111
111
|
|
|
112
112
|
}
|
|
113
113
|
|