super-three 0.167.0 → 0.169.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 +532 -173
- package/build/three.module.js +532 -174
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +18173 -14266
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +79941 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +0 -4
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +469 -448
- package/examples/jsm/controls/TransformControls.js +97 -62
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +43 -44
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +3 -1
- package/examples/jsm/loaders/FBXLoader.js +30 -20
- package/examples/jsm/loaders/GLTFLoader.js +5 -10
- package/examples/jsm/loaders/KTX2Loader.js +27 -12
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +40 -14
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +14 -13
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/VRMLLoader.js +10 -10
- package/examples/jsm/loaders/VTKLoader.js +4 -3
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +187 -0
- package/examples/jsm/objects/Water2Mesh.js +158 -0
- package/examples/jsm/objects/WaterMesh.js +101 -0
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/physics/RapierPhysics.js +21 -1
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/TextureUtils.js +2 -1
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/package.json +3 -2
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +7 -0
- package/src/Three.js +1 -0
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/extras/Controls.js +32 -0
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/loaders/MaterialLoader.js +7 -1
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +25 -5
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +21 -18
- package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +19 -0
- package/src/materials/Material.js +4 -7
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +56 -59
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +12 -10
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +16 -12
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +10 -6
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshNormalNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +14 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +22 -18
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +10 -7
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +22 -12
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +71 -115
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +3 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +47 -14
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +24 -22
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Triangle.js +24 -0
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +179 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +53 -21
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +8 -5
- package/src/nodes/accessors/BufferNode.js +7 -4
- package/src/nodes/accessors/Camera.js +13 -0
- package/src/nodes/accessors/ClippingNode.js +19 -13
- package/src/nodes/accessors/CubeTextureNode.js +9 -8
- package/src/nodes/accessors/InstanceNode.js +19 -15
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +8 -5
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +56 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +9 -4
- package/src/nodes/accessors/ModelNode.js +47 -12
- package/src/nodes/accessors/ModelViewProjectionNode.js +12 -9
- package/src/nodes/accessors/MorphNode.js +17 -13
- package/src/nodes/accessors/Normal.js +88 -0
- package/src/nodes/accessors/Object3DNode.js +17 -33
- package/src/nodes/accessors/PointUVNode.js +9 -5
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
- package/src/nodes/accessors/ReferenceNode.js +50 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +12 -6
- package/src/nodes/accessors/SceneNode.js +9 -6
- package/src/nodes/accessors/SkinningNode.js +88 -21
- package/src/nodes/accessors/StorageBufferNode.js +22 -5
- package/src/nodes/accessors/StorageTextureNode.js +9 -6
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +16 -13
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +29 -23
- package/src/nodes/accessors/TextureSizeNode.js +10 -9
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +26 -14
- package/src/nodes/accessors/UserDataNode.js +10 -7
- package/src/nodes/accessors/VelocityNode.js +134 -0
- package/src/nodes/accessors/VertexColorNode.js +7 -4
- package/src/nodes/code/CodeNode.js +9 -5
- package/src/nodes/code/ExpressionNode.js +10 -6
- package/src/nodes/code/FunctionCallNode.js +8 -5
- package/src/nodes/code/FunctionNode.js +8 -23
- package/src/nodes/code/ScriptableNode.js +13 -10
- package/src/nodes/code/ScriptableValueNode.js +9 -7
- package/src/nodes/core/AssignNode.js +12 -9
- package/src/nodes/core/AttributeNode.js +12 -21
- package/src/nodes/core/BypassNode.js +11 -7
- package/src/nodes/core/CacheNode.js +10 -6
- package/src/nodes/core/ConstNode.js +6 -3
- package/src/nodes/core/ContextNode.js +21 -11
- package/src/nodes/core/IndexNode.js +35 -8
- package/src/nodes/core/InputNode.js +7 -3
- package/src/nodes/core/MRTNode.js +16 -7
- package/src/nodes/core/Node.js +19 -40
- package/src/nodes/core/NodeBuilder.js +117 -38
- package/src/nodes/core/NodeUtils.js +49 -6
- package/src/nodes/core/OutputStructNode.js +10 -6
- package/src/nodes/core/ParameterNode.js +7 -4
- package/src/nodes/core/PropertyNode.js +36 -32
- package/src/nodes/core/StackNode.js +31 -11
- package/src/nodes/core/StructTypeNode.js +7 -3
- package/src/nodes/core/TempNode.js +8 -4
- package/src/nodes/core/UniformGroupNode.js +14 -11
- package/src/nodes/core/UniformNode.js +7 -4
- package/src/nodes/core/VarNode.js +12 -8
- package/src/nodes/core/VaryingNode.js +10 -6
- package/src/nodes/display/AfterImageNode.js +15 -9
- package/src/nodes/display/AnaglyphPassNode.js +67 -0
- package/src/nodes/display/AnamorphicNode.js +17 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +27 -19
- package/src/nodes/display/BumpMapNode.js +13 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +67 -61
- package/src/nodes/display/DenoiseNode.js +23 -17
- package/src/nodes/display/DepthOfFieldNode.js +12 -7
- package/src/nodes/display/DotScreenNode.js +13 -22
- package/src/nodes/display/FXAANode.js +21 -16
- package/src/nodes/display/FilmNode.js +11 -7
- package/src/nodes/display/FrontFacingNode.js +10 -6
- package/src/nodes/display/GTAONode.js +22 -15
- package/src/nodes/display/GaussianBlurNode.js +14 -8
- package/src/nodes/display/Lut3DNode.js +10 -6
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +13 -13
- package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
- package/src/nodes/display/PassNode.js +95 -8
- package/src/nodes/display/PixelationPassNode.js +20 -8
- package/src/nodes/display/PosterizeNode.js +8 -7
- package/src/nodes/display/RGBShiftNode.js +11 -7
- package/src/nodes/display/RenderOutputNode.js +15 -11
- package/src/nodes/display/SSAAPassNode.js +287 -0
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +13 -8
- package/src/nodes/display/StereoCompositePassNode.js +110 -0
- package/src/nodes/display/StereoPassNode.js +83 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +15 -175
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +12 -8
- package/src/nodes/display/ViewportDepthNode.js +34 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +10 -9
- package/src/nodes/display/ViewportSharedTextureNode.js +10 -9
- package/src/nodes/display/ViewportTextureNode.js +11 -11
- package/src/nodes/fog/FogExp2Node.js +8 -7
- package/src/nodes/fog/FogNode.js +10 -8
- package/src/nodes/fog/FogRangeNode.js +8 -7
- package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +6 -6
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +5 -5
- package/src/nodes/functions/PhysicalLightingModel.js +34 -33
- package/src/nodes/functions/ShadowMaskModel.js +1 -1
- package/src/nodes/functions/ToonLightingModel.js +3 -3
- package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
- package/src/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.js +9 -5
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/src/nodes/gpgpu/ComputeNode.js +10 -6
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +6 -3
- package/src/nodes/lighting/AmbientLightNode.js +6 -8
- package/src/nodes/lighting/AnalyticLightNode.js +225 -36
- package/src/nodes/lighting/BasicEnvironmentNode.js +8 -4
- package/src/nodes/lighting/BasicLightMapNode.js +7 -4
- package/src/nodes/lighting/DirectionalLightNode.js +7 -9
- package/src/nodes/lighting/EnvironmentNode.js +23 -19
- package/src/nodes/lighting/HemisphereLightNode.js +11 -11
- package/src/nodes/lighting/IESSpotLightNode.js +7 -9
- package/src/nodes/lighting/IrradianceNode.js +6 -3
- package/src/nodes/lighting/LightProbeNode.js +53 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +19 -18
- package/src/nodes/lighting/LightingNode.js +7 -3
- package/src/nodes/lighting/LightsNode.js +112 -75
- package/src/nodes/lighting/PointLightNode.js +12 -13
- package/src/nodes/lighting/RectAreaLightNode.js +11 -11
- package/src/nodes/lighting/SpotLightNode.js +14 -16
- package/src/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +36 -31
- package/src/nodes/materialx/lib/mx_noise.js +96 -96
- package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
- package/src/nodes/math/{CondNode.js → ConditionalNode.js} +38 -10
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +127 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +97 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +61 -15
- package/src/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
- package/src/nodes/utils/ArrayElementNode.js +8 -4
- package/src/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +160 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +9 -6
- package/src/nodes/utils/FlipNode.js +68 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +9 -5
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +16 -6
- package/src/nodes/utils/MatcapUVNode.js +10 -7
- package/src/nodes/utils/MaxMipLevelNode.js +8 -5
- package/src/nodes/utils/OscNode.js +12 -8
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +11 -8
- package/src/nodes/utils/ReflectorNode.js +12 -4
- package/src/nodes/utils/RemapNode.js +12 -8
- package/src/nodes/utils/RotateNode.js +8 -13
- package/src/nodes/utils/SetNode.js +7 -4
- package/src/nodes/utils/SplitNode.js +7 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +10 -6
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +11 -12
- package/src/nodes/utils/TimerNode.js +8 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +11 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +78 -13
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +1 -0
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +88 -41
- package/src/renderers/common/Backend.js +2 -2
- package/src/renderers/common/Background.js +3 -1
- package/src/renderers/common/BindGroup.js +3 -1
- package/src/renderers/common/Bindings.js +13 -15
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ClippingContext.js +15 -5
- package/src/renderers/common/CubeRenderTarget.js +9 -3
- package/src/renderers/common/PostProcessing.js +4 -1
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderContext.js +23 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +117 -6
- package/src/renderers/common/RenderObjects.js +8 -1
- package/src/renderers/common/Renderer.js +128 -94
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +19 -22
- package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/src/renderers/common/nodes/Nodes.js +65 -19
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/webgl/WebGLAttributes.js +45 -14
- package/src/renderers/webgl/WebGLCapabilities.js +9 -0
- package/src/renderers/webgl/WebGLProgram.js +3 -1
- package/src/renderers/webgl/WebGLPrograms.js +21 -17
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLState.js +21 -0
- package/src/renderers/webgl/WebGLTextures.js +83 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +135 -110
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +60 -12
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +20 -2
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +89 -37
- package/src/renderers/webgpu/WebGPUBackend.js +112 -86
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/src/renderers/webgpu/WebGPURenderer.js +9 -6
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +189 -73
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +7 -16
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +43 -26
- package/src/renderers/webgpu/utils/WebGPUUtils.js +19 -2
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/src/utils.js +33 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/utils/GPUStatsPanel.js +0 -95
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/nodes/accessors/CameraNode.js +0 -19
- package/src/nodes/accessors/NormalNode.js +0 -14
- package/src/nodes/accessors/PositionNode.js +0 -10
- package/src/nodes/accessors/ReflectVectorNode.js +0 -10
- package/src/nodes/accessors/TangentNode.js +0 -23
- package/src/nodes/core/NodeKeywords.js +0 -80
- package/src/nodes/display/BlendModeNode.js +0 -128
- package/src/nodes/display/ColorAdjustmentNode.js +0 -104
- package/src/nodes/display/ViewportNode.js +0 -137
- package/src/nodes/lighting/LightNode.js +0 -57
- package/src/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
- package/src/nodes/math/HashNode.js +0 -34
- package/src/nodes/procedural/CheckerNode.js +0 -42
- package/src/nodes/utils/DiscardNode.js +0 -28
- package/src/nodes/utils/PackingNode.js +0 -55
- package/src/nodes/utils/RotateUVNode.js +0 -35
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
2
|
import { NodeUpdateType } from '../core/constants.js';
|
|
3
3
|
import { uniform } from '../core/UniformNode.js';
|
|
4
4
|
import { texture } from './TextureNode.js';
|
|
5
|
+
import { cubeTexture } from './CubeTextureNode.js';
|
|
5
6
|
import { buffer } from './BufferNode.js';
|
|
6
|
-
import { nodeObject } from '../
|
|
7
|
-
import {
|
|
7
|
+
import { nodeObject } from '../tsl/TSLBase.js';
|
|
8
|
+
import { uniformArray } from './UniformArrayNode.js';
|
|
8
9
|
import ArrayElementNode from '../utils/ArrayElementNode.js';
|
|
9
10
|
|
|
10
11
|
class ReferenceElementNode extends ArrayElementNode {
|
|
11
12
|
|
|
13
|
+
static get type() {
|
|
14
|
+
|
|
15
|
+
return 'ReferenceElementNode';
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
constructor( referenceNode, indexNode ) {
|
|
13
20
|
|
|
14
21
|
super( referenceNode, indexNode );
|
|
@@ -37,8 +44,15 @@ class ReferenceElementNode extends ArrayElementNode {
|
|
|
37
44
|
|
|
38
45
|
}
|
|
39
46
|
|
|
47
|
+
// TODO: Extends this from ReferenceBaseNode
|
|
40
48
|
class ReferenceNode extends Node {
|
|
41
49
|
|
|
50
|
+
static get type() {
|
|
51
|
+
|
|
52
|
+
return 'ReferenceNode';
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
42
56
|
constructor( property, uniformType, object = null, count = null ) {
|
|
43
57
|
|
|
44
58
|
super();
|
|
@@ -51,6 +65,8 @@ class ReferenceNode extends Node {
|
|
|
51
65
|
this.properties = property.split( '.' );
|
|
52
66
|
this.reference = object;
|
|
53
67
|
this.node = null;
|
|
68
|
+
this.group = null;
|
|
69
|
+
this.name = null;
|
|
54
70
|
|
|
55
71
|
this.updateType = NodeUpdateType.OBJECT;
|
|
56
72
|
|
|
@@ -62,6 +78,22 @@ class ReferenceNode extends Node {
|
|
|
62
78
|
|
|
63
79
|
}
|
|
64
80
|
|
|
81
|
+
setGroup( group ) {
|
|
82
|
+
|
|
83
|
+
this.group = group;
|
|
84
|
+
|
|
85
|
+
return this;
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
label( name ) {
|
|
90
|
+
|
|
91
|
+
this.name = name;
|
|
92
|
+
|
|
93
|
+
return this;
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
65
97
|
setNodeType( uniformType ) {
|
|
66
98
|
|
|
67
99
|
let node = null;
|
|
@@ -72,19 +104,31 @@ class ReferenceNode extends Node {
|
|
|
72
104
|
|
|
73
105
|
} else if ( Array.isArray( this.getValueFromReference() ) ) {
|
|
74
106
|
|
|
75
|
-
node =
|
|
107
|
+
node = uniformArray( null, uniformType );
|
|
76
108
|
|
|
77
109
|
} else if ( uniformType === 'texture' ) {
|
|
78
110
|
|
|
79
111
|
node = texture( null );
|
|
80
112
|
|
|
113
|
+
} else if ( uniformType === 'cubeTexture' ) {
|
|
114
|
+
|
|
115
|
+
node = cubeTexture( null );
|
|
116
|
+
|
|
81
117
|
} else {
|
|
82
118
|
|
|
83
119
|
node = uniform( null, uniformType );
|
|
84
120
|
|
|
85
121
|
}
|
|
86
122
|
|
|
87
|
-
this.
|
|
123
|
+
if ( this.group !== null ) {
|
|
124
|
+
|
|
125
|
+
node.setGroup( this.group );
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if ( this.name !== null ) node.label( this.name );
|
|
130
|
+
|
|
131
|
+
this.node = node.getSelf();
|
|
88
132
|
|
|
89
133
|
}
|
|
90
134
|
|
|
@@ -92,6 +136,7 @@ class ReferenceNode extends Node {
|
|
|
92
136
|
|
|
93
137
|
if ( this.node === null ) {
|
|
94
138
|
|
|
139
|
+
this.updateReference( builder );
|
|
95
140
|
this.updateValue();
|
|
96
141
|
|
|
97
142
|
}
|
|
@@ -162,5 +207,3 @@ export default ReferenceNode;
|
|
|
162
207
|
|
|
163
208
|
export const reference = ( name, type, object ) => nodeObject( new ReferenceNode( name, type, object ) );
|
|
164
209
|
export const referenceBuffer = ( name, type, count, object ) => nodeObject( new ReferenceNode( name, type, object, count ) );
|
|
165
|
-
|
|
166
|
-
addNodeClass( 'ReferenceNode', ReferenceNode );
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { cameraViewMatrix } from './Camera.js';
|
|
2
|
+
import { transformedNormalView } from './Normal.js';
|
|
3
|
+
import { positionViewDirection } from './Position.js';
|
|
4
|
+
import { materialRefractionRatio } from './MaterialProperties.js';
|
|
5
|
+
|
|
6
|
+
export const reflectView = /*@__PURE__*/ positionViewDirection.negate().reflect( transformedNormalView );
|
|
7
|
+
export const refractView = /*@__PURE__*/ positionViewDirection.negate().refract( transformedNormalView, materialRefractionRatio );
|
|
8
|
+
|
|
9
|
+
export const reflectVector = /*@__PURE__*/ reflectView.transformDirection( cameraViewMatrix ).toVar( 'reflectVector' );
|
|
10
|
+
export const refractVector = /*@__PURE__*/ refractView.transformDirection( cameraViewMatrix ).toVar( 'reflectVector' );
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import ReferenceBaseNode from './ReferenceBaseNode.js';
|
|
2
|
+
import { nodeObject } from '../tsl/TSLCore.js';
|
|
3
|
+
import { renderGroup } from '../core/UniformGroupNode.js';
|
|
4
4
|
|
|
5
|
-
class RendererReferenceNode extends
|
|
5
|
+
class RendererReferenceNode extends ReferenceBaseNode {
|
|
6
|
+
|
|
7
|
+
static get type() {
|
|
8
|
+
|
|
9
|
+
return 'RendererReferenceNode';
|
|
10
|
+
|
|
11
|
+
}
|
|
6
12
|
|
|
7
13
|
constructor( property, inputType, renderer = null ) {
|
|
8
14
|
|
|
@@ -10,6 +16,8 @@ class RendererReferenceNode extends ReferenceNode {
|
|
|
10
16
|
|
|
11
17
|
this.renderer = renderer;
|
|
12
18
|
|
|
19
|
+
this.setGroup( renderGroup );
|
|
20
|
+
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
updateReference( state ) {
|
|
@@ -25,5 +33,3 @@ class RendererReferenceNode extends ReferenceNode {
|
|
|
25
33
|
export default RendererReferenceNode;
|
|
26
34
|
|
|
27
35
|
export const rendererReference = ( name, type, renderer ) => nodeObject( new RendererReferenceNode( name, type, renderer ) );
|
|
28
|
-
|
|
29
|
-
addNodeClass( 'RendererReferenceNode', RendererReferenceNode );
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import Node from '../core/Node.js';
|
|
2
|
-
import {
|
|
3
|
-
import { nodeImmutable } from '../shadernode/ShaderNode.js';
|
|
2
|
+
import { nodeImmutable } from '../tsl/TSLBase.js';
|
|
4
3
|
import { reference } from './ReferenceNode.js';
|
|
5
4
|
|
|
6
5
|
class SceneNode extends Node {
|
|
7
6
|
|
|
7
|
+
static get type() {
|
|
8
|
+
|
|
9
|
+
return 'SceneNode';
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
constructor( scope = SceneNode.BACKGROUND_BLURRINESS, scene = null ) {
|
|
9
14
|
|
|
10
15
|
super();
|
|
@@ -46,7 +51,5 @@ SceneNode.BACKGROUND_INTENSITY = 'backgroundIntensity';
|
|
|
46
51
|
|
|
47
52
|
export default SceneNode;
|
|
48
53
|
|
|
49
|
-
export const backgroundBlurriness = nodeImmutable( SceneNode, SceneNode.BACKGROUND_BLURRINESS );
|
|
50
|
-
export const backgroundIntensity = nodeImmutable( SceneNode, SceneNode.BACKGROUND_INTENSITY );
|
|
51
|
-
|
|
52
|
-
addNodeClass( 'SceneNode', SceneNode );
|
|
54
|
+
export const backgroundBlurriness = /*@__PURE__*/ nodeImmutable( SceneNode, SceneNode.BACKGROUND_BLURRINESS );
|
|
55
|
+
export const backgroundIntensity = /*@__PURE__*/ nodeImmutable( SceneNode, SceneNode.BACKGROUND_INTENSITY );
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
2
|
import { NodeUpdateType } from '../core/constants.js';
|
|
3
|
-
import { nodeObject } from '../
|
|
3
|
+
import { nodeObject } from '../tsl/TSLBase.js';
|
|
4
4
|
import { attribute } from '../core/AttributeNode.js';
|
|
5
5
|
import { reference, referenceBuffer } from './ReferenceNode.js';
|
|
6
6
|
import { add } from '../math/OperatorNode.js';
|
|
7
|
-
import { normalLocal } from './
|
|
8
|
-
import { positionLocal } from './
|
|
9
|
-
import { tangentLocal } from './
|
|
7
|
+
import { normalLocal } from './Normal.js';
|
|
8
|
+
import { positionLocal, positionPrevious } from './Position.js';
|
|
9
|
+
import { tangentLocal } from './Tangent.js';
|
|
10
10
|
import { uniform } from '../core/UniformNode.js';
|
|
11
11
|
import { buffer } from './BufferNode.js';
|
|
12
12
|
|
|
13
|
+
const _frameId = new WeakMap();
|
|
14
|
+
|
|
13
15
|
class SkinningNode extends Node {
|
|
14
16
|
|
|
17
|
+
static get type() {
|
|
18
|
+
|
|
19
|
+
return 'SkinningNode';
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
constructor( skinnedMesh, useReference = false ) {
|
|
16
24
|
|
|
17
25
|
super( 'void' );
|
|
@@ -45,21 +53,22 @@ class SkinningNode extends Node {
|
|
|
45
53
|
this.bindMatrixNode = bindMatrixNode;
|
|
46
54
|
this.bindMatrixInverseNode = bindMatrixInverseNode;
|
|
47
55
|
this.boneMatricesNode = boneMatricesNode;
|
|
56
|
+
this.previousBoneMatricesNode = null;
|
|
48
57
|
|
|
49
58
|
}
|
|
50
59
|
|
|
51
|
-
|
|
60
|
+
getSkinnedPosition( boneMatrices = this.boneMatricesNode, position = positionLocal ) {
|
|
52
61
|
|
|
53
|
-
const { skinIndexNode, skinWeightNode, bindMatrixNode, bindMatrixInverseNode
|
|
62
|
+
const { skinIndexNode, skinWeightNode, bindMatrixNode, bindMatrixInverseNode } = this;
|
|
54
63
|
|
|
55
|
-
const boneMatX =
|
|
56
|
-
const boneMatY =
|
|
57
|
-
const boneMatZ =
|
|
58
|
-
const boneMatW =
|
|
64
|
+
const boneMatX = boneMatrices.element( skinIndexNode.x );
|
|
65
|
+
const boneMatY = boneMatrices.element( skinIndexNode.y );
|
|
66
|
+
const boneMatZ = boneMatrices.element( skinIndexNode.z );
|
|
67
|
+
const boneMatW = boneMatrices.element( skinIndexNode.w );
|
|
59
68
|
|
|
60
69
|
// POSITION
|
|
61
70
|
|
|
62
|
-
const skinVertex = bindMatrixNode.mul(
|
|
71
|
+
const skinVertex = bindMatrixNode.mul( position );
|
|
63
72
|
|
|
64
73
|
const skinned = add(
|
|
65
74
|
boneMatX.mul( skinWeightNode.x ).mul( skinVertex ),
|
|
@@ -68,7 +77,18 @@ class SkinningNode extends Node {
|
|
|
68
77
|
boneMatW.mul( skinWeightNode.w ).mul( skinVertex )
|
|
69
78
|
);
|
|
70
79
|
|
|
71
|
-
|
|
80
|
+
return bindMatrixInverseNode.mul( skinned ).xyz;
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
getSkinnedNormal( boneMatrices = this.boneMatricesNode, normal = normalLocal ) {
|
|
85
|
+
|
|
86
|
+
const { skinIndexNode, skinWeightNode, bindMatrixNode, bindMatrixInverseNode } = this;
|
|
87
|
+
|
|
88
|
+
const boneMatX = boneMatrices.element( skinIndexNode.x );
|
|
89
|
+
const boneMatY = boneMatrices.element( skinIndexNode.y );
|
|
90
|
+
const boneMatZ = boneMatrices.element( skinIndexNode.z );
|
|
91
|
+
const boneMatW = boneMatrices.element( skinIndexNode.w );
|
|
72
92
|
|
|
73
93
|
// NORMAL
|
|
74
94
|
|
|
@@ -81,16 +101,58 @@ class SkinningNode extends Node {
|
|
|
81
101
|
|
|
82
102
|
skinMatrix = bindMatrixInverseNode.mul( skinMatrix ).mul( bindMatrixNode );
|
|
83
103
|
|
|
84
|
-
|
|
104
|
+
return skinMatrix.transformDirection( normal ).xyz;
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
getPreviousSkinnedPosition( builder ) {
|
|
109
|
+
|
|
110
|
+
const skinnedMesh = builder.object;
|
|
111
|
+
|
|
112
|
+
if ( this.previousBoneMatricesNode === null ) {
|
|
113
|
+
|
|
114
|
+
skinnedMesh.skeleton.previousBoneMatrices = new Float32Array( skinnedMesh.skeleton.boneMatrices );
|
|
115
|
+
|
|
116
|
+
this.previousBoneMatricesNode = referenceBuffer( 'skeleton.previousBoneMatrices', 'mat4', skinnedMesh.skeleton.bones.length );
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return this.getSkinnedPosition( this.previousBoneMatricesNode, positionPrevious );
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
needsPreviousBoneMatrices( builder ) {
|
|
125
|
+
|
|
126
|
+
const mrt = builder.renderer.getMRT();
|
|
127
|
+
|
|
128
|
+
return mrt && mrt.has( 'velocity' );
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
setup( builder ) {
|
|
133
|
+
|
|
134
|
+
if ( this.needsPreviousBoneMatrices( builder ) ) {
|
|
135
|
+
|
|
136
|
+
positionPrevious.assign( this.getPreviousSkinnedPosition( builder ) );
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const skinPosition = this.getSkinnedPosition();
|
|
85
141
|
|
|
86
|
-
// ASSIGNS
|
|
87
142
|
|
|
88
143
|
positionLocal.assign( skinPosition );
|
|
89
|
-
normalLocal.assign( skinNormal );
|
|
90
144
|
|
|
91
|
-
if ( builder.hasGeometryAttribute( '
|
|
145
|
+
if ( builder.hasGeometryAttribute( 'normal' ) ) {
|
|
146
|
+
|
|
147
|
+
const skinNormal = this.getSkinnedNormal();
|
|
148
|
+
|
|
149
|
+
normalLocal.assign( skinNormal );
|
|
150
|
+
|
|
151
|
+
if ( builder.hasGeometryAttribute( 'tangent' ) ) {
|
|
92
152
|
|
|
93
|
-
|
|
153
|
+
tangentLocal.assign( skinNormal );
|
|
154
|
+
|
|
155
|
+
}
|
|
94
156
|
|
|
95
157
|
}
|
|
96
158
|
|
|
@@ -109,8 +171,15 @@ class SkinningNode extends Node {
|
|
|
109
171
|
update( frame ) {
|
|
110
172
|
|
|
111
173
|
const object = this.useReference ? frame.object : this.skinnedMesh;
|
|
174
|
+
const skeleton = object.skeleton;
|
|
175
|
+
|
|
176
|
+
if ( _frameId.get( skeleton ) === frame.frameId ) return;
|
|
177
|
+
|
|
178
|
+
_frameId.set( skeleton, frame.frameId );
|
|
112
179
|
|
|
113
|
-
|
|
180
|
+
if ( this.previousBoneMatricesNode !== null ) skeleton.previousBoneMatrices.set( skeleton.boneMatrices );
|
|
181
|
+
|
|
182
|
+
skeleton.update();
|
|
114
183
|
|
|
115
184
|
}
|
|
116
185
|
|
|
@@ -120,5 +189,3 @@ export default SkinningNode;
|
|
|
120
189
|
|
|
121
190
|
export const skinning = ( skinnedMesh ) => nodeObject( new SkinningNode( skinnedMesh ) );
|
|
122
191
|
export const skinningReference = ( skinnedMesh ) => nodeObject( new SkinningNode( skinnedMesh, true ) );
|
|
123
|
-
|
|
124
|
-
addNodeClass( 'SkinningNode', SkinningNode );
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import BufferNode from './BufferNode.js';
|
|
2
2
|
import { bufferAttribute } from './BufferAttributeNode.js';
|
|
3
|
-
import {
|
|
4
|
-
import { nodeObject } from '../shadernode/ShaderNode.js';
|
|
5
|
-
import { varying } from '../core/VaryingNode.js';
|
|
3
|
+
import { nodeObject, varying } from '../tsl/TSLBase.js';
|
|
6
4
|
import { storageElement } from '../utils/StorageArrayElementNode.js';
|
|
7
5
|
import { GPUBufferBindingType } from '../../renderers/webgpu/utils/WebGPUConstants.js';
|
|
8
6
|
|
|
9
7
|
class StorageBufferNode extends BufferNode {
|
|
10
8
|
|
|
9
|
+
static get type() {
|
|
10
|
+
|
|
11
|
+
return 'StorageBufferNode';
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
constructor( value, bufferType, bufferCount = 0 ) {
|
|
12
16
|
|
|
13
17
|
super( value, bufferType, bufferCount );
|
|
@@ -15,6 +19,7 @@ class StorageBufferNode extends BufferNode {
|
|
|
15
19
|
this.isStorageBufferNode = true;
|
|
16
20
|
|
|
17
21
|
this.access = GPUBufferBindingType.Storage;
|
|
22
|
+
this.isAtomic = false;
|
|
18
23
|
|
|
19
24
|
this.bufferObject = false;
|
|
20
25
|
this.bufferCount = bufferCount;
|
|
@@ -93,6 +98,20 @@ class StorageBufferNode extends BufferNode {
|
|
|
93
98
|
|
|
94
99
|
}
|
|
95
100
|
|
|
101
|
+
setAtomic( value ) {
|
|
102
|
+
|
|
103
|
+
this.isAtomic = value;
|
|
104
|
+
|
|
105
|
+
return this;
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
toAtomic() {
|
|
110
|
+
|
|
111
|
+
return this.setAtomic( true );
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
96
115
|
generate( builder ) {
|
|
97
116
|
|
|
98
117
|
if ( builder.isAvailable( 'storageBuffer' ) ) {
|
|
@@ -126,5 +145,3 @@ export default StorageBufferNode;
|
|
|
126
145
|
// Read-Write Storage
|
|
127
146
|
export const storage = ( value, type, count ) => nodeObject( new StorageBufferNode( value, type, count ) );
|
|
128
147
|
export const storageObject = ( value, type, count ) => nodeObject( new StorageBufferNode( value, type, count ).setBufferObject( true ) );
|
|
129
|
-
|
|
130
|
-
addNodeClass( 'StorageBufferNode', StorageBufferNode );
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { addNodeClass } from '../core/Node.js';
|
|
2
1
|
import TextureNode from './TextureNode.js';
|
|
3
|
-
import { nodeProxy } from '../
|
|
2
|
+
import { nodeProxy } from '../tsl/TSLBase.js';
|
|
4
3
|
import { GPUStorageTextureAccess } from '../../renderers/webgpu/utils/WebGPUConstants.js';
|
|
5
4
|
|
|
6
5
|
class StorageTextureNode extends TextureNode {
|
|
7
6
|
|
|
7
|
+
static get type() {
|
|
8
|
+
|
|
9
|
+
return 'StorageTextureNode';
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
constructor( value, uvNode, storeNode = null ) {
|
|
9
14
|
|
|
10
15
|
super( value, uvNode );
|
|
@@ -81,7 +86,7 @@ class StorageTextureNode extends TextureNode {
|
|
|
81
86
|
|
|
82
87
|
const snippet = builder.generateTextureStore( builder, textureProperty, uvSnippet, storeSnippet );
|
|
83
88
|
|
|
84
|
-
builder.addLineFlowCode( snippet );
|
|
89
|
+
builder.addLineFlowCode( snippet, this );
|
|
85
90
|
|
|
86
91
|
}
|
|
87
92
|
|
|
@@ -89,7 +94,7 @@ class StorageTextureNode extends TextureNode {
|
|
|
89
94
|
|
|
90
95
|
export default StorageTextureNode;
|
|
91
96
|
|
|
92
|
-
export const storageTexture = nodeProxy( StorageTextureNode );
|
|
97
|
+
export const storageTexture = /*@__PURE__*/ nodeProxy( StorageTextureNode );
|
|
93
98
|
|
|
94
99
|
export const textureStore = ( value, uvNode, storeNode ) => {
|
|
95
100
|
|
|
@@ -100,5 +105,3 @@ export const textureStore = ( value, uvNode, storeNode ) => {
|
|
|
100
105
|
return node;
|
|
101
106
|
|
|
102
107
|
};
|
|
103
|
-
|
|
104
|
-
addNodeClass( 'StorageTextureNode', StorageTextureNode );
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { attribute } from '../core/AttributeNode.js';
|
|
2
|
+
import { cameraViewMatrix } from './Camera.js';
|
|
3
|
+
import { modelViewMatrix } from './ModelNode.js';
|
|
4
|
+
import { Fn, vec4 } from '../tsl/TSLBase.js';
|
|
5
|
+
|
|
6
|
+
export const tangentGeometry = /*@__PURE__*/ Fn( ( builder ) => {
|
|
7
|
+
|
|
8
|
+
if ( builder.geometry.hasAttribute( 'tangent' ) === false ) {
|
|
9
|
+
|
|
10
|
+
builder.geometry.computeTangents();
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return attribute( 'tangent', 'vec4' );
|
|
15
|
+
|
|
16
|
+
} )();
|
|
17
|
+
|
|
18
|
+
export const tangentLocal = /*@__PURE__*/ tangentGeometry.xyz.toVar( 'tangentLocal' );
|
|
19
|
+
export const tangentView = /*@__PURE__*/ modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz.varying( 'v_tangentView' ).normalize().toVar( 'tangentView' );
|
|
20
|
+
export const tangentWorld = /*@__PURE__*/ tangentView.transformDirection( cameraViewMatrix ).varying( 'v_tangentWorld' ).normalize().toVar( 'tangentWorld' );
|
|
21
|
+
export const transformedTangentView = /*@__PURE__*/ tangentView.toVar( 'transformedTangentView' );
|
|
22
|
+
export const transformedTangentWorld = /*@__PURE__*/ transformedTangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedTangentWorld' );
|
|
@@ -1,38 +1,37 @@
|
|
|
1
1
|
import TextureNode from './TextureNode.js';
|
|
2
|
-
import {
|
|
3
|
-
import { nodeProxy, vec3, tslFn, If } from '../shadernode/ShaderNode.js';
|
|
2
|
+
import { nodeProxy, vec3, Fn, If } from '../tsl/TSLBase.js';
|
|
4
3
|
|
|
5
|
-
const normal =
|
|
4
|
+
const normal = Fn( ( { texture, uv } ) => {
|
|
6
5
|
|
|
7
6
|
const epsilon = 0.0001;
|
|
8
7
|
|
|
9
|
-
const ret = vec3().
|
|
8
|
+
const ret = vec3().toVar();
|
|
10
9
|
|
|
11
10
|
If( uv.x.lessThan( epsilon ), () => {
|
|
12
11
|
|
|
13
12
|
ret.assign( vec3( 1, 0, 0 ) );
|
|
14
13
|
|
|
15
|
-
} ).
|
|
14
|
+
} ).ElseIf( uv.y.lessThan( epsilon ), () => {
|
|
16
15
|
|
|
17
16
|
ret.assign( vec3( 0, 1, 0 ) );
|
|
18
17
|
|
|
19
|
-
} ).
|
|
18
|
+
} ).ElseIf( uv.z.lessThan( epsilon ), () => {
|
|
20
19
|
|
|
21
20
|
ret.assign( vec3( 0, 0, 1 ) );
|
|
22
21
|
|
|
23
|
-
} ).
|
|
22
|
+
} ).ElseIf( uv.x.greaterThan( 1 - epsilon ), () => {
|
|
24
23
|
|
|
25
24
|
ret.assign( vec3( - 1, 0, 0 ) );
|
|
26
25
|
|
|
27
|
-
} ).
|
|
26
|
+
} ).ElseIf( uv.y.greaterThan( 1 - epsilon ), () => {
|
|
28
27
|
|
|
29
28
|
ret.assign( vec3( 0, - 1, 0 ) );
|
|
30
29
|
|
|
31
|
-
} ).
|
|
30
|
+
} ).ElseIf( uv.z.greaterThan( 1 - epsilon ), () => {
|
|
32
31
|
|
|
33
32
|
ret.assign( vec3( 0, 0, - 1 ) );
|
|
34
33
|
|
|
35
|
-
} ).
|
|
34
|
+
} ).Else( () => {
|
|
36
35
|
|
|
37
36
|
const step = 0.01;
|
|
38
37
|
|
|
@@ -51,6 +50,12 @@ const normal = tslFn( ( { texture, uv } ) => {
|
|
|
51
50
|
|
|
52
51
|
class Texture3DNode extends TextureNode {
|
|
53
52
|
|
|
53
|
+
static get type() {
|
|
54
|
+
|
|
55
|
+
return 'Texture3DNode';
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
54
59
|
constructor( value, uvNode = null, levelNode = null ) {
|
|
55
60
|
|
|
56
61
|
super( value, uvNode, levelNode );
|
|
@@ -95,6 +100,4 @@ class Texture3DNode extends TextureNode {
|
|
|
95
100
|
|
|
96
101
|
export default Texture3DNode;
|
|
97
102
|
|
|
98
|
-
export const texture3D = nodeProxy( Texture3DNode );
|
|
99
|
-
|
|
100
|
-
addNodeClass( 'Texture3DNode', Texture3DNode );
|
|
103
|
+
export const texture3D = /*@__PURE__*/ nodeProxy( Texture3DNode );
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import { addNodeClass } from '../core/Node.js';
|
|
3
1
|
import { add, mul, div } from '../math/OperatorNode.js';
|
|
4
2
|
import { floor, ceil, fract, pow } from '../math/MathNode.js';
|
|
5
|
-
import {
|
|
3
|
+
import { Fn, float, vec2, vec4, int } from '../tsl/TSLBase.js';
|
|
6
4
|
|
|
7
5
|
// Mipped Bicubic Texture Filtering by N8
|
|
8
6
|
// https://www.shadertoy.com/view/Dl2SDW
|
|
@@ -53,7 +51,7 @@ const bicubic = ( textureNode, texelSize, lod ) => {
|
|
|
53
51
|
|
|
54
52
|
};
|
|
55
53
|
|
|
56
|
-
const
|
|
54
|
+
export const textureBicubic = /*@__PURE__*/ Fn( ( [ textureNode, lodNode = float( 3 ) ] ) => {
|
|
57
55
|
|
|
58
56
|
const fLodSize = vec2( textureNode.size( int( lodNode ) ) );
|
|
59
57
|
const cLodSize = vec2( textureNode.size( int( lodNode.add( 1.0 ) ) ) );
|
|
@@ -64,31 +62,4 @@ const textureBicubicMethod = ( textureNode, lodNode ) => {
|
|
|
64
62
|
|
|
65
63
|
return fract( lodNode ).mix( fSample, cSample );
|
|
66
64
|
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
class TextureBicubicNode extends TempNode {
|
|
70
|
-
|
|
71
|
-
constructor( textureNode, blurNode = float( 3 ) ) {
|
|
72
|
-
|
|
73
|
-
super( 'vec4' );
|
|
74
|
-
|
|
75
|
-
this.textureNode = textureNode;
|
|
76
|
-
this.blurNode = blurNode;
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
setup() {
|
|
81
|
-
|
|
82
|
-
return textureBicubicMethod( this.textureNode, this.blurNode );
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export default TextureBicubicNode;
|
|
89
|
-
|
|
90
|
-
export const textureBicubic = nodeProxy( TextureBicubicNode );
|
|
91
|
-
|
|
92
|
-
addNodeElement( 'bicubic', textureBicubic );
|
|
93
|
-
|
|
94
|
-
addNodeClass( 'TextureBicubicNode', TextureBicubicNode );
|
|
65
|
+
} );
|