@gnsx/three 0.184.20 → 0.185.3
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 +1261 -926
- package/build/three.core.js +1104 -829
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +157 -97
- 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 +7542 -3371
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +7542 -3370
- 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 +67 -58
- 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 +124 -91
- 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 -74
- 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 +92 -37
- package/src/nodes/lighting/PointShadowNode.js +7 -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 +21 -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 +42 -4
- package/src/renderers/common/RenderObject.js +73 -13
- package/src/renderers/common/Renderer.js +282 -109
- 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 +11 -4
- 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
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
|
|
2
|
+
import { Fn, add, uniform } from '../tsl/TSLBase.js';
|
|
3
|
+
import { attribute } from '../core/AttributeNode.js';
|
|
4
|
+
import { OnObjectUpdate } from '../utils/EventNode.js';
|
|
5
|
+
import { normalLocal } from './Normal.js';
|
|
6
|
+
import { positionLocal, positionPrevious } from './Position.js';
|
|
7
|
+
import { tangentLocal } from './Tangent.js';
|
|
8
|
+
import { reference, referenceBuffer } from './ReferenceNode.js';
|
|
9
|
+
import { buffer } from './BufferNode.js';
|
|
10
|
+
import { storage } from './StorageBufferNode.js';
|
|
11
|
+
import { instanceIndex } from '../core/IndexNode.js';
|
|
12
|
+
|
|
13
|
+
import { InstancedBufferAttribute } from '../../core/InstancedBufferAttribute.js';
|
|
14
|
+
|
|
15
|
+
const _skeletonsUpdated = /*@__PURE__*/ new WeakMap();
|
|
16
|
+
const _previousBoneMatricesData = /*@__PURE__*/ new WeakMap();
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Computes the skinned position by applying bone matrices based on weights.
|
|
20
|
+
*
|
|
21
|
+
* @param {Node} boneMatrices - The bone matrices buffer or storage node.
|
|
22
|
+
* @param {Node<vec3>} position - The vertex position to transform.
|
|
23
|
+
* @param {Node<mat4>} bindMatrix - The bind matrix node.
|
|
24
|
+
* @param {Node<mat4>} bindMatrixInverse - The inverse bind matrix node.
|
|
25
|
+
* @param {Node<uvec4>} skinIndex - The skin index attribute.
|
|
26
|
+
* @param {Node<vec4>} skinWeight - The skin weight attribute.
|
|
27
|
+
* @returns {Node<vec3>} The skinned position.
|
|
28
|
+
*/
|
|
29
|
+
function getSkinnedPosition( boneMatrices, position, bindMatrix, bindMatrixInverse, skinIndex, skinWeight ) {
|
|
30
|
+
|
|
31
|
+
const boneMatX = boneMatrices.element( skinIndex.x );
|
|
32
|
+
const boneMatY = boneMatrices.element( skinIndex.y );
|
|
33
|
+
const boneMatZ = boneMatrices.element( skinIndex.z );
|
|
34
|
+
const boneMatW = boneMatrices.element( skinIndex.w );
|
|
35
|
+
|
|
36
|
+
// POSITION
|
|
37
|
+
|
|
38
|
+
const skinVertex = bindMatrix.mul( position );
|
|
39
|
+
|
|
40
|
+
const skinned = add(
|
|
41
|
+
boneMatX.mul( skinWeight.x ).mul( skinVertex ),
|
|
42
|
+
boneMatY.mul( skinWeight.y ).mul( skinVertex ),
|
|
43
|
+
boneMatZ.mul( skinWeight.z ).mul( skinVertex ),
|
|
44
|
+
boneMatW.mul( skinWeight.w ).mul( skinVertex )
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return bindMatrixInverse.mul( skinned ).xyz;
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Computes the skinned normal and tangent vectors by applying bone matrices based on weights.
|
|
53
|
+
*
|
|
54
|
+
* @param {Node} boneMatrices - The bone matrices buffer or storage node.
|
|
55
|
+
* @param {Node<vec3>} normal - The normal vector in local space.
|
|
56
|
+
* @param {Node<vec3>} tangent - The tangent vector in local space.
|
|
57
|
+
* @param {Node<mat4>} bindMatrix - The bind matrix node.
|
|
58
|
+
* @param {Node<mat4>} bindMatrixInverse - The inverse bind matrix node.
|
|
59
|
+
* @param {Node<uvec4>} skinIndex - The skin index attribute.
|
|
60
|
+
* @param {Node<vec4>} skinWeight - The skin weight attribute.
|
|
61
|
+
* @returns {{skinNormal: Node<vec3>, skinTangent: Node<vec3>}} The skinned normal and tangent.
|
|
62
|
+
*/
|
|
63
|
+
function getSkinnedNormalAndTangent( boneMatrices, normal, tangent, bindMatrix, bindMatrixInverse, skinIndex, skinWeight ) {
|
|
64
|
+
|
|
65
|
+
const boneMatX = boneMatrices.element( skinIndex.x );
|
|
66
|
+
const boneMatY = boneMatrices.element( skinIndex.y );
|
|
67
|
+
const boneMatZ = boneMatrices.element( skinIndex.z );
|
|
68
|
+
const boneMatW = boneMatrices.element( skinIndex.w );
|
|
69
|
+
|
|
70
|
+
// NORMAL and TANGENT
|
|
71
|
+
|
|
72
|
+
let skinMatrix = add(
|
|
73
|
+
skinWeight.x.mul( boneMatX ),
|
|
74
|
+
skinWeight.y.mul( boneMatY ),
|
|
75
|
+
skinWeight.z.mul( boneMatZ ),
|
|
76
|
+
skinWeight.w.mul( boneMatW )
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
skinMatrix = bindMatrixInverse.mul( skinMatrix ).mul( bindMatrix );
|
|
80
|
+
|
|
81
|
+
const skinNormal = skinMatrix.transformDirection( normal ).xyz;
|
|
82
|
+
const skinTangent = skinMatrix.transformDirection( tangent ).xyz;
|
|
83
|
+
|
|
84
|
+
return { skinNormal, skinTangent };
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Retrieves or initializes the previous frame skinned position node for motion vectors.
|
|
90
|
+
* Uses a WeakMap to cache previous frame bone matrix arrays and their TSL buffer nodes.
|
|
91
|
+
*
|
|
92
|
+
* @param {SkinnedMesh} skinnedMesh - The skinned mesh.
|
|
93
|
+
* @param {Node<mat4>} bindMatrixNode - The bind matrix node.
|
|
94
|
+
* @param {Node<mat4>} bindMatrixInverseNode - The inverse bind matrix node.
|
|
95
|
+
* @param {Node<uvec4>} skinIndexNode - The skin index attribute.
|
|
96
|
+
* @param {Node<vec4>} skinWeightNode - The skin weight attribute.
|
|
97
|
+
* @returns {Node<vec3>} The skinned position from the previous frame.
|
|
98
|
+
*/
|
|
99
|
+
function getPreviousSkinnedPosition( skinnedMesh, bindMatrixNode, bindMatrixInverseNode, skinIndexNode, skinWeightNode ) {
|
|
100
|
+
|
|
101
|
+
const skeleton = skinnedMesh.skeleton;
|
|
102
|
+
|
|
103
|
+
let data = _previousBoneMatricesData.get( skeleton );
|
|
104
|
+
|
|
105
|
+
if ( data === undefined ) {
|
|
106
|
+
|
|
107
|
+
skeleton.update();
|
|
108
|
+
|
|
109
|
+
const previousBoneMatrices = new Float32Array( skeleton.boneMatrices );
|
|
110
|
+
|
|
111
|
+
data = {
|
|
112
|
+
previousBoneMatrices,
|
|
113
|
+
node: buffer( previousBoneMatrices, 'mat4', skeleton.bones.length )
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
_previousBoneMatricesData.set( skeleton, data );
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return getSkinnedPosition( data.node, positionPrevious, bindMatrixNode, bindMatrixInverseNode, skinIndexNode, skinWeightNode );
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* TSL function representing the standard skeletal animation vertex shader setup.
|
|
126
|
+
* Transforms positionLocal, normalLocal, and tangentLocal in-place.
|
|
127
|
+
*
|
|
128
|
+
* @tsl
|
|
129
|
+
* @function
|
|
130
|
+
* @param {SkinnedMesh} skinnedMesh - The skinned mesh.
|
|
131
|
+
*/
|
|
132
|
+
export const skinning = /*@__PURE__*/ Fn( ( [ skinnedMesh ], builder ) => {
|
|
133
|
+
|
|
134
|
+
const skinIndexNode = attribute( 'skinIndex', 'uvec4' );
|
|
135
|
+
const skinWeightNode = attribute( 'skinWeight', 'vec4' );
|
|
136
|
+
const bindMatrixNode = reference( 'bindMatrix', 'mat4' );
|
|
137
|
+
const bindMatrixInverseNode = reference( 'bindMatrixInverse', 'mat4' );
|
|
138
|
+
const boneMatricesNode = referenceBuffer( 'skeleton.boneMatrices', 'mat4', skinnedMesh.skeleton.bones.length );
|
|
139
|
+
|
|
140
|
+
OnObjectUpdate( ( { object, frameId } ) => {
|
|
141
|
+
|
|
142
|
+
const skeleton = object.skeleton;
|
|
143
|
+
|
|
144
|
+
if ( _skeletonsUpdated.get( skeleton ) !== frameId ) {
|
|
145
|
+
|
|
146
|
+
_skeletonsUpdated.set( skeleton, frameId );
|
|
147
|
+
|
|
148
|
+
const skeletonData = _previousBoneMatricesData.get( skeleton );
|
|
149
|
+
|
|
150
|
+
if ( skeletonData !== undefined ) {
|
|
151
|
+
|
|
152
|
+
skeletonData.previousBoneMatrices.set( skeleton.boneMatrices );
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
skeleton.update();
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
} );
|
|
161
|
+
|
|
162
|
+
if ( builder.needsPreviousData() ) {
|
|
163
|
+
|
|
164
|
+
const previousSkinnedPosition = getPreviousSkinnedPosition( skinnedMesh, bindMatrixNode, bindMatrixInverseNode, skinIndexNode, skinWeightNode );
|
|
165
|
+
|
|
166
|
+
positionPrevious.assign( previousSkinnedPosition );
|
|
167
|
+
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const skinPosition = getSkinnedPosition( boneMatricesNode, positionLocal, bindMatrixNode, bindMatrixInverseNode, skinIndexNode, skinWeightNode );
|
|
171
|
+
positionLocal.assign( skinPosition );
|
|
172
|
+
|
|
173
|
+
if ( builder.hasGeometryAttribute( 'normal' ) ) {
|
|
174
|
+
|
|
175
|
+
const { skinNormal, skinTangent } = getSkinnedNormalAndTangent( boneMatricesNode, normalLocal, tangentLocal, bindMatrixNode, bindMatrixInverseNode, skinIndexNode, skinWeightNode );
|
|
176
|
+
|
|
177
|
+
normalLocal.assign( skinNormal );
|
|
178
|
+
|
|
179
|
+
if ( builder.hasGeometryAttribute( 'tangent' ) ) {
|
|
180
|
+
|
|
181
|
+
tangentLocal.assign( skinTangent );
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
}, 'void' );
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* TSL function that computes skeletal animation for custom compute passes.
|
|
191
|
+
*
|
|
192
|
+
* @tsl
|
|
193
|
+
* @function
|
|
194
|
+
* @param {SkinnedMesh} skinnedMesh - The skinned mesh.
|
|
195
|
+
* @param {Node<vec3>} [toPosition=null] - The target position node to assign.
|
|
196
|
+
* @returns {Node<vec3>} The computed skinned position node.
|
|
197
|
+
*/
|
|
198
|
+
export const computeSkinning = /*@__PURE__*/ Fn( ( [ skinnedMesh, toPosition = null ], builder ) => {
|
|
199
|
+
|
|
200
|
+
const positionNode = storage( new InstancedBufferAttribute( skinnedMesh.geometry.getAttribute( 'position' ).array, 3 ), 'vec3' ).setPBO( true ).toReadOnly().element( instanceIndex ).toVar();
|
|
201
|
+
const skinIndexNode = storage( new InstancedBufferAttribute( new Uint32Array( skinnedMesh.geometry.getAttribute( 'skinIndex' ).array ), 4 ), 'uvec4' ).setPBO( true ).toReadOnly().element( instanceIndex ).toVar();
|
|
202
|
+
const skinWeightNode = storage( new InstancedBufferAttribute( skinnedMesh.geometry.getAttribute( 'skinWeight' ).array, 4 ), 'vec4' ).setPBO( true ).toReadOnly().element( instanceIndex ).toVar();
|
|
203
|
+
const bindMatrixNode = uniform( skinnedMesh.bindMatrix, 'mat4' );
|
|
204
|
+
const bindMatrixInverseNode = uniform( skinnedMesh.bindMatrixInverse, 'mat4' );
|
|
205
|
+
const boneMatricesNode = buffer( skinnedMesh.skeleton.boneMatrices, 'mat4', skinnedMesh.skeleton.bones.length );
|
|
206
|
+
|
|
207
|
+
const skeleton = skinnedMesh.skeleton;
|
|
208
|
+
|
|
209
|
+
OnObjectUpdate( ( { frameId } ) => {
|
|
210
|
+
|
|
211
|
+
if ( _skeletonsUpdated.get( skeleton ) !== frameId ) {
|
|
212
|
+
|
|
213
|
+
_skeletonsUpdated.set( skeleton, frameId );
|
|
214
|
+
|
|
215
|
+
const state = _previousBoneMatricesData.get( skeleton );
|
|
216
|
+
|
|
217
|
+
if ( state !== undefined ) {
|
|
218
|
+
|
|
219
|
+
state.previousBoneMatrices.set( skeleton.boneMatrices );
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
skeleton.update();
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
} );
|
|
228
|
+
|
|
229
|
+
if ( builder.needsPreviousData() ) {
|
|
230
|
+
|
|
231
|
+
const previousSkinnedPosition = getPreviousSkinnedPosition( skinnedMesh, bindMatrixNode, bindMatrixInverseNode, skinIndexNode, skinWeightNode );
|
|
232
|
+
|
|
233
|
+
positionPrevious.assign( previousSkinnedPosition );
|
|
234
|
+
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const skinPosition = getSkinnedPosition( boneMatricesNode, positionNode, bindMatrixNode, bindMatrixInverseNode, skinIndexNode, skinWeightNode );
|
|
238
|
+
|
|
239
|
+
if ( toPosition !== null ) {
|
|
240
|
+
|
|
241
|
+
toPosition.assign( skinPosition );
|
|
242
|
+
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if ( builder.hasGeometryAttribute( 'normal' ) ) {
|
|
246
|
+
|
|
247
|
+
const { skinNormal, skinTangent } = getSkinnedNormalAndTangent( boneMatricesNode, normalLocal, tangentLocal, bindMatrixNode, bindMatrixInverseNode, skinIndexNode, skinWeightNode );
|
|
248
|
+
|
|
249
|
+
normalLocal.assign( skinNormal );
|
|
250
|
+
|
|
251
|
+
if ( builder.hasGeometryAttribute( 'tangent' ) ) {
|
|
252
|
+
|
|
253
|
+
tangentLocal.assign( skinTangent );
|
|
254
|
+
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return skinPosition;
|
|
260
|
+
|
|
261
|
+
} );
|
|
262
|
+
|
|
263
|
+
|
|
@@ -55,10 +55,10 @@ class StorageBufferNode extends BufferNode {
|
|
|
55
55
|
|
|
56
56
|
let nodeType, structTypeNode = null;
|
|
57
57
|
|
|
58
|
-
if ( bufferType && bufferType.
|
|
58
|
+
if ( bufferType && bufferType.isStructTypeNode ) {
|
|
59
59
|
|
|
60
60
|
nodeType = 'struct';
|
|
61
|
-
structTypeNode = bufferType
|
|
61
|
+
structTypeNode = bufferType;
|
|
62
62
|
|
|
63
63
|
if ( value.isStorageBufferAttribute || value.isStorageInstancedBufferAttribute ) {
|
|
64
64
|
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { nodeProxy, vec3 } from '../tsl/TSLBase.js';
|
|
2
|
+
import StorageTextureNode from './StorageTextureNode.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This special version of a texture node can be used to
|
|
6
|
+
* write data into a 3D storage texture with a compute shader.
|
|
7
|
+
*
|
|
8
|
+
* @augments StorageTextureNode
|
|
9
|
+
*/
|
|
10
|
+
class StorageTexture3DNode extends StorageTextureNode {
|
|
11
|
+
|
|
12
|
+
static get type() {
|
|
13
|
+
|
|
14
|
+
return 'StorageTexture3DNode';
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Constructs a new 3D storage texture node.
|
|
20
|
+
*
|
|
21
|
+
* @param {Storage3DTexture} value - The 3D storage texture.
|
|
22
|
+
* @param {Node<vec3>} uvNode - The uv node.
|
|
23
|
+
* @param {?Node} [storeNode=null] - The value node that should be stored in the texture.
|
|
24
|
+
*/
|
|
25
|
+
constructor( value, uvNode, storeNode = null ) {
|
|
26
|
+
|
|
27
|
+
super( value, uvNode, storeNode );
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* This flag can be used for type testing.
|
|
31
|
+
*
|
|
32
|
+
* @type {boolean}
|
|
33
|
+
* @readonly
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
this.isStorageTexture3DNode = true;
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns a default uv node which is in context of 3D textures a three-dimensional
|
|
42
|
+
* uv node.
|
|
43
|
+
*
|
|
44
|
+
* @return {Node<vec3>} The default uv node.
|
|
45
|
+
*/
|
|
46
|
+
getDefaultUV() {
|
|
47
|
+
|
|
48
|
+
return vec3( 0.5, 0.5, 0.5 );
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Overwritten with an empty implementation since the `updateMatrix` flag is ignored
|
|
54
|
+
* for 3D textures. The uv transformation matrix is not applied to 3D textures.
|
|
55
|
+
*
|
|
56
|
+
* @param {boolean} value - The update toggle.
|
|
57
|
+
*/
|
|
58
|
+
setUpdateMatrix( /*value*/ ) { } // Ignore .updateMatrix for 3d TextureNode
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Generates the uv code snippet.
|
|
62
|
+
*
|
|
63
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
64
|
+
* @param {Node} uvNode - The uv node to generate code for.
|
|
65
|
+
* @return {string} The generated code snippet.
|
|
66
|
+
*/
|
|
67
|
+
generateUV( builder, uvNode ) {
|
|
68
|
+
|
|
69
|
+
return uvNode.build( builder, this.sampler === true ? 'vec3' : 'ivec3' );
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Generates the offset code snippet.
|
|
75
|
+
*
|
|
76
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
77
|
+
* @param {Node} offsetNode - The offset node to generate code for.
|
|
78
|
+
* @return {string} The generated code snippet.
|
|
79
|
+
*/
|
|
80
|
+
generateOffset( builder, offsetNode ) {
|
|
81
|
+
|
|
82
|
+
return offsetNode.build( builder, 'ivec3' );
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default StorageTexture3DNode;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* TSL function for creating a 3D storage texture node.
|
|
92
|
+
*
|
|
93
|
+
* @tsl
|
|
94
|
+
* @function
|
|
95
|
+
* @param {Storage3DTexture} value - The 3D storage texture.
|
|
96
|
+
* @param {?Node<vec3>} [uvNode=null] - The uv node.
|
|
97
|
+
* @param {?Node} [storeNode=null] - The value node that should be stored in the texture.
|
|
98
|
+
* @returns {StorageTexture3DNode}
|
|
99
|
+
*/
|
|
100
|
+
export const storageTexture3D = /*@__PURE__*/ nodeProxy( StorageTexture3DNode ).setParameterLength( 1, 3 );
|
|
@@ -99,6 +99,20 @@ class StorageTextureNode extends TextureNode {
|
|
|
99
99
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Overwrites the default implementation since storage texture
|
|
104
|
+
* coordinates are texel coordinates and should not be transformed
|
|
105
|
+
* by the texture uv matrix.
|
|
106
|
+
*
|
|
107
|
+
* @param {Node} uvNode - The uv node.
|
|
108
|
+
* @return {Node} The unmodified uv node.
|
|
109
|
+
*/
|
|
110
|
+
getTransformedUV( uvNode ) {
|
|
111
|
+
|
|
112
|
+
return uvNode;
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
102
116
|
setup( builder ) {
|
|
103
117
|
|
|
104
118
|
super.setup( builder );
|
|
@@ -212,6 +226,27 @@ class StorageTextureNode extends TextureNode {
|
|
|
212
226
|
|
|
213
227
|
}
|
|
214
228
|
|
|
229
|
+
/**
|
|
230
|
+
* Stores a value in this storage texture at the given coordinates.
|
|
231
|
+
*
|
|
232
|
+
* @param {Node<vec2|vec3>} uvNode - The storage texture coordinates.
|
|
233
|
+
* @param {?Node} [storeNode=null] - The value node that should be stored in the texture.
|
|
234
|
+
* @return {StorageTextureNode} A storage texture node representing the store operation.
|
|
235
|
+
*/
|
|
236
|
+
store( uvNode, storeNode ) {
|
|
237
|
+
|
|
238
|
+
const node = this.clone();
|
|
239
|
+
|
|
240
|
+
node.referenceNode = this.getBase();
|
|
241
|
+
node.uvNode = uvNode;
|
|
242
|
+
node.storeNode = storeNode;
|
|
243
|
+
|
|
244
|
+
if ( storeNode !== null ) node.toStack();
|
|
245
|
+
|
|
246
|
+
return node;
|
|
247
|
+
|
|
248
|
+
}
|
|
249
|
+
|
|
215
250
|
/**
|
|
216
251
|
* Generates the code snippet of the storage texture node.
|
|
217
252
|
*
|
|
@@ -266,7 +301,7 @@ export const storageTexture = /*@__PURE__*/ nodeProxy( StorageTextureNode ).setP
|
|
|
266
301
|
*
|
|
267
302
|
* @tsl
|
|
268
303
|
* @function
|
|
269
|
-
* @param {StorageTexture} value - The storage texture.
|
|
304
|
+
* @param {StorageTexture|StorageTextureNode} value - The storage texture.
|
|
270
305
|
* @param {Node<vec2|vec3>} uvNode - The uv node.
|
|
271
306
|
* @param {?Node} [storeNode=null] - The value node that should be stored in the texture.
|
|
272
307
|
* @returns {StorageTextureNode}
|
|
@@ -277,18 +312,15 @@ export const textureStore = ( value, uvNode, storeNode ) => {
|
|
|
277
312
|
|
|
278
313
|
if ( value.isStorageTextureNode === true ) {
|
|
279
314
|
|
|
280
|
-
|
|
281
|
-
node = value.clone();
|
|
282
|
-
node.uvNode = uvNode;
|
|
283
|
-
node.storeNode = storeNode;
|
|
315
|
+
node = value.store( uvNode, storeNode );
|
|
284
316
|
|
|
285
317
|
} else {
|
|
286
318
|
|
|
287
319
|
node = storageTexture( value, uvNode, storeNode );
|
|
288
320
|
|
|
289
|
-
|
|
321
|
+
if ( storeNode !== null ) node.toStack();
|
|
290
322
|
|
|
291
|
-
|
|
323
|
+
}
|
|
292
324
|
|
|
293
325
|
return node;
|
|
294
326
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { attribute } from '../core/AttributeNode.js';
|
|
2
|
-
import {
|
|
2
|
+
import { cameraWorldMatrix } from './Camera.js';
|
|
3
3
|
import { modelViewMatrix } from './ModelNode.js';
|
|
4
4
|
import { Fn, vec4 } from '../tsl/TSLBase.js';
|
|
5
5
|
import { tangentViewFrame } from './TangentUtils.js';
|
|
6
|
-
import {
|
|
6
|
+
import { negateOnBackSide } from '../display/FrontFacingNode.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* TSL object that represents the tangent attribute of the current rendered object.
|
|
@@ -43,7 +43,7 @@ export const tangentView = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
|
43
43
|
|
|
44
44
|
if ( builder.isFlatShading() !== true ) {
|
|
45
45
|
|
|
46
|
-
node =
|
|
46
|
+
node = negateOnBackSide( node );
|
|
47
47
|
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -57,4 +57,4 @@ export const tangentView = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
|
57
57
|
* @tsl
|
|
58
58
|
* @type {Node<vec3>}
|
|
59
59
|
*/
|
|
60
|
-
export const tangentWorld = /*@__PURE__*/ tangentView.transformDirection(
|
|
60
|
+
export const tangentWorld = /*@__PURE__*/ tangentView.transformDirection( cameraWorldMatrix ).toVarying( 'v_tangentWorld' ).normalize().toVar( 'tangentWorld' );
|
|
@@ -99,6 +99,15 @@ class TextureNode extends UniformNode {
|
|
|
99
99
|
*/
|
|
100
100
|
this.gradNode = null;
|
|
101
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Represents the optional index constant of the channel to gather.
|
|
104
|
+
* This must be in range [0, 3] and a compile-time constant.
|
|
105
|
+
*
|
|
106
|
+
* @type {?Node<int>}
|
|
107
|
+
* @default null
|
|
108
|
+
*/
|
|
109
|
+
this.gatherNode = null;
|
|
110
|
+
|
|
102
111
|
/**
|
|
103
112
|
* Represents the optional texel offset applied to the unnormalized texture
|
|
104
113
|
* coordinate before sampling the texture.
|
|
@@ -219,7 +228,13 @@ class TextureNode extends UniformNode {
|
|
|
219
228
|
*/
|
|
220
229
|
generateNodeType( /*builder*/ ) {
|
|
221
230
|
|
|
222
|
-
if ( this.value.isDepthTexture === true )
|
|
231
|
+
if ( this.value.isDepthTexture === true ) {
|
|
232
|
+
|
|
233
|
+
if ( this.gatherNode === null ) return 'float';
|
|
234
|
+
|
|
235
|
+
return 'vec4';
|
|
236
|
+
|
|
237
|
+
}
|
|
223
238
|
|
|
224
239
|
if ( this.value.type === UnsignedIntType ) {
|
|
225
240
|
|
|
@@ -449,6 +464,7 @@ class TextureNode extends UniformNode {
|
|
|
449
464
|
properties.compareNode = compareNode;
|
|
450
465
|
properties.compareStepNode = compareStepNode;
|
|
451
466
|
properties.gradNode = this.gradNode;
|
|
467
|
+
properties.gatherNode = this.gatherNode;
|
|
452
468
|
properties.depthNode = this.depthNode;
|
|
453
469
|
properties.offsetNode = this.offsetNode;
|
|
454
470
|
|
|
@@ -491,10 +507,12 @@ class TextureNode extends UniformNode {
|
|
|
491
507
|
* @param {?string} depthSnippet - The depth snippet.
|
|
492
508
|
* @param {?string} compareSnippet - The compare snippet.
|
|
493
509
|
* @param {?Array<string>} gradSnippet - The grad snippet.
|
|
510
|
+
* @param {?string} gatherSnippet - The gather snippet.
|
|
494
511
|
* @param {?string} offsetSnippet - The offset snippet.
|
|
512
|
+
* @param {?string} flipYSnippet - The y-flip snippet. Only used for WebGL.
|
|
495
513
|
* @return {string} The generated code snippet.
|
|
496
514
|
*/
|
|
497
|
-
generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, depthSnippet, compareSnippet, gradSnippet, offsetSnippet ) {
|
|
515
|
+
generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, depthSnippet, compareSnippet, gradSnippet, gatherSnippet, offsetSnippet, flipYSnippet ) {
|
|
498
516
|
|
|
499
517
|
const texture = this.value;
|
|
500
518
|
|
|
@@ -508,6 +526,18 @@ class TextureNode extends UniformNode {
|
|
|
508
526
|
|
|
509
527
|
snippet = builder.generateTextureGrad( texture, textureProperty, uvSnippet, gradSnippet, depthSnippet, offsetSnippet );
|
|
510
528
|
|
|
529
|
+
} else if ( gatherSnippet ) {
|
|
530
|
+
|
|
531
|
+
if ( compareSnippet ) {
|
|
532
|
+
|
|
533
|
+
snippet = builder.generateTextureGatherCompare( texture, textureProperty, uvSnippet, compareSnippet, depthSnippet, offsetSnippet, flipYSnippet );
|
|
534
|
+
|
|
535
|
+
} else {
|
|
536
|
+
|
|
537
|
+
snippet = builder.generateTextureGather( texture, textureProperty, uvSnippet, gatherSnippet, depthSnippet, offsetSnippet, flipYSnippet );
|
|
538
|
+
|
|
539
|
+
}
|
|
540
|
+
|
|
511
541
|
} else if ( compareSnippet ) {
|
|
512
542
|
|
|
513
543
|
snippet = builder.generateTextureCompare( texture, textureProperty, uvSnippet, compareSnippet, depthSnippet, offsetSnippet );
|
|
@@ -556,13 +586,13 @@ class TextureNode extends UniformNode {
|
|
|
556
586
|
|
|
557
587
|
const nodeData = builder.getDataFromNode( this );
|
|
558
588
|
|
|
559
|
-
|
|
589
|
+
let nodeType = this.getNodeType( builder );
|
|
560
590
|
|
|
561
591
|
let propertyName = nodeData.propertyName;
|
|
562
592
|
|
|
563
593
|
if ( propertyName === undefined ) {
|
|
564
594
|
|
|
565
|
-
const { uvNode, levelNode, biasNode, compareNode, compareStepNode, depthNode, gradNode, offsetNode } = properties;
|
|
595
|
+
const { uvNode, levelNode, biasNode, compareNode, compareStepNode, depthNode, gradNode, gatherNode, offsetNode } = properties;
|
|
566
596
|
|
|
567
597
|
const uvSnippet = this.generateUV( builder, uvNode );
|
|
568
598
|
const levelSnippet = levelNode ? levelNode.build( builder, 'float' ) : null;
|
|
@@ -571,7 +601,15 @@ class TextureNode extends UniformNode {
|
|
|
571
601
|
const compareSnippet = compareNode ? compareNode.build( builder, 'float' ) : null;
|
|
572
602
|
const compareStepSnippet = compareStepNode ? compareStepNode.build( builder, 'float' ) : null;
|
|
573
603
|
const gradSnippet = gradNode ? [ gradNode[ 0 ].build( builder, 'vec2' ), gradNode[ 1 ].build( builder, 'vec2' ) ] : null;
|
|
604
|
+
const gatherSnippet = gatherNode ? gatherNode.build( builder, 'int' ) : null;
|
|
574
605
|
const offsetSnippet = offsetNode ? this.generateOffset( builder, offsetNode ) : null;
|
|
606
|
+
const flipYSnippet = this._flipYUniform ? this._flipYUniform.build( builder, 'bool' ) : null;
|
|
607
|
+
|
|
608
|
+
if ( gatherSnippet ) {
|
|
609
|
+
|
|
610
|
+
nodeType = 'vec4';
|
|
611
|
+
|
|
612
|
+
}
|
|
575
613
|
|
|
576
614
|
let finalDepthSnippet = depthSnippet;
|
|
577
615
|
|
|
@@ -585,7 +623,7 @@ class TextureNode extends UniformNode {
|
|
|
585
623
|
|
|
586
624
|
propertyName = builder.getPropertyName( nodeVar );
|
|
587
625
|
|
|
588
|
-
let snippet = this.generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, finalDepthSnippet, compareSnippet, gradSnippet, offsetSnippet );
|
|
626
|
+
let snippet = this.generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, finalDepthSnippet, compareSnippet, gradSnippet, gatherSnippet, offsetSnippet, flipYSnippet );
|
|
589
627
|
|
|
590
628
|
if ( compareStepSnippet !== null ) {
|
|
591
629
|
|
|
@@ -792,6 +830,22 @@ class TextureNode extends UniformNode {
|
|
|
792
830
|
|
|
793
831
|
}
|
|
794
832
|
|
|
833
|
+
/**
|
|
834
|
+
* Gathers four texels from the texture.
|
|
835
|
+
*
|
|
836
|
+
* @param {Node<int>} gatherNode - The index of the channel to read. This must be in range [0, 3] and a compile-time constant.
|
|
837
|
+
* @return {TextureNode} A texture node representing the texture sample.
|
|
838
|
+
*/
|
|
839
|
+
gather( gatherNode = 0 ) {
|
|
840
|
+
|
|
841
|
+
const textureNode = this.clone();
|
|
842
|
+
textureNode.gatherNode = nodeObject( gatherNode );
|
|
843
|
+
textureNode.referenceNode = this.getBase();
|
|
844
|
+
|
|
845
|
+
return nodeObject( textureNode );
|
|
846
|
+
|
|
847
|
+
}
|
|
848
|
+
|
|
795
849
|
/**
|
|
796
850
|
* Samples the texture by defining a depth node.
|
|
797
851
|
*
|
|
@@ -888,6 +942,7 @@ class TextureNode extends UniformNode {
|
|
|
888
942
|
newNode.depthNode = this.depthNode;
|
|
889
943
|
newNode.compareNode = this.compareNode;
|
|
890
944
|
newNode.gradNode = this.gradNode;
|
|
945
|
+
newNode.gatherNode = this.gatherNode;
|
|
891
946
|
newNode.offsetNode = this.offsetNode;
|
|
892
947
|
|
|
893
948
|
return newNode;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import CodeNode from './CodeNode.js';
|
|
2
|
+
import { nodeProxyConstructor } from '../tsl/TSLCore.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* This class represents a native shader function. It can be used to implement
|
|
@@ -155,26 +156,11 @@ export default FunctionNode;
|
|
|
155
156
|
|
|
156
157
|
const nativeFn = ( code, includes = [], language = '' ) => {
|
|
157
158
|
|
|
158
|
-
for ( let i = 0; i < includes.length; i ++ ) {
|
|
159
|
-
|
|
160
|
-
const include = includes[ i ];
|
|
161
|
-
|
|
162
|
-
// TSL Function: glslFn, wgslFn
|
|
163
|
-
|
|
164
|
-
if ( typeof include === 'function' ) {
|
|
165
|
-
|
|
166
|
-
includes[ i ] = include.functionNode;
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
159
|
const functionNode = new FunctionNode( code, includes, language );
|
|
173
160
|
|
|
174
161
|
const fn = ( ...params ) => functionNode.call( ...params );
|
|
175
|
-
fn.functionNode = functionNode;
|
|
176
162
|
|
|
177
|
-
return fn;
|
|
163
|
+
return nodeProxyConstructor( fn, functionNode );
|
|
178
164
|
|
|
179
165
|
};
|
|
180
166
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import OutputStructNode from './OutputStructNode.js';
|
|
2
|
-
import { nodeProxy
|
|
2
|
+
import { nodeProxy } from '../tsl/TSLBase.js';
|
|
3
3
|
import { MaterialBlending, NoBlending } from '../../constants.js';
|
|
4
4
|
import BlendMode from '../../renderers/common/BlendMode.js';
|
|
5
5
|
|
|
@@ -171,7 +171,12 @@ class MRTNode extends OutputStructNode {
|
|
|
171
171
|
|
|
172
172
|
const index = getTextureIndex( textures, name );
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
// Ignore if the output exists in the MRT but has never been used.
|
|
175
|
+
if ( index === - 1 ) continue;
|
|
176
|
+
|
|
177
|
+
const type = builder.getOutputType( index );
|
|
178
|
+
|
|
179
|
+
members[ index ] = outputNodes[ name ].convert( type );
|
|
175
180
|
|
|
176
181
|
}
|
|
177
182
|
|