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
|
|
2
|
-
import { normalLocal } from './
|
|
3
|
-
import { positionLocal } from './
|
|
4
|
-
import { nodeProxy, vec3, mat3, mat4, int, ivec2, float,
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
|
+
import { normalLocal } from './Normal.js';
|
|
3
|
+
import { positionLocal } from './Position.js';
|
|
4
|
+
import { nodeProxy, vec3, mat3, mat4, int, ivec2, float, Fn } from '../tsl/TSLBase.js';
|
|
5
5
|
import { textureLoad } from './TextureNode.js';
|
|
6
6
|
import { textureSize } from './TextureSizeNode.js';
|
|
7
|
-
import { tangentLocal } from './
|
|
7
|
+
import { tangentLocal } from './Tangent.js';
|
|
8
8
|
import { instanceIndex, drawIndex } from '../core/IndexNode.js';
|
|
9
|
+
import { varyingProperty } from '../core/PropertyNode.js';
|
|
9
10
|
|
|
10
11
|
class BatchNode extends Node {
|
|
11
12
|
|
|
13
|
+
static get type() {
|
|
14
|
+
|
|
15
|
+
return 'BatchNode';
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
constructor( batchMesh ) {
|
|
13
20
|
|
|
14
21
|
super( 'void' );
|
|
@@ -16,8 +23,6 @@ class BatchNode extends Node {
|
|
|
16
23
|
this.batchMesh = batchMesh;
|
|
17
24
|
|
|
18
25
|
|
|
19
|
-
this.instanceColorNode = null;
|
|
20
|
-
|
|
21
26
|
this.batchingIdNode = null;
|
|
22
27
|
|
|
23
28
|
}
|
|
@@ -40,10 +45,10 @@ class BatchNode extends Node {
|
|
|
40
45
|
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
const getIndirectIndex =
|
|
48
|
+
const getIndirectIndex = Fn( ( [ id ] ) => {
|
|
44
49
|
|
|
45
50
|
const size = textureSize( textureLoad( this.batchMesh._indirectTexture ), 0 );
|
|
46
|
-
const x = int( id ).
|
|
51
|
+
const x = int( id ).modInt( int( size ) );
|
|
47
52
|
const y = int( id ).div( int( size ) );
|
|
48
53
|
return textureLoad( this.batchMesh._indirectTexture, ivec2( x, y ) ).x;
|
|
49
54
|
|
|
@@ -55,20 +60,49 @@ class BatchNode extends Node {
|
|
|
55
60
|
]
|
|
56
61
|
} );
|
|
57
62
|
|
|
58
|
-
const
|
|
63
|
+
const indirectId = getIndirectIndex( int( this.batchingIdNode ) );
|
|
59
64
|
|
|
60
|
-
const
|
|
61
|
-
const j = float( getIndirectIndex( int( this.batchingIdNode ) ) ).mul( 4 ).toVar();
|
|
65
|
+
const matricesTexture = this.batchMesh._matricesTexture;
|
|
62
66
|
|
|
63
|
-
const
|
|
64
|
-
const
|
|
67
|
+
const size = textureSize( textureLoad( matricesTexture ), 0 );
|
|
68
|
+
const j = float( indirectId ).mul( 4 ).toInt().toVar();
|
|
69
|
+
|
|
70
|
+
const x = j.modInt( size );
|
|
71
|
+
const y = j.div( int( size ) );
|
|
65
72
|
const batchingMatrix = mat4(
|
|
66
|
-
textureLoad(
|
|
67
|
-
textureLoad(
|
|
68
|
-
textureLoad(
|
|
69
|
-
textureLoad(
|
|
73
|
+
textureLoad( matricesTexture, ivec2( x, y ) ),
|
|
74
|
+
textureLoad( matricesTexture, ivec2( x.add( 1 ), y ) ),
|
|
75
|
+
textureLoad( matricesTexture, ivec2( x.add( 2 ), y ) ),
|
|
76
|
+
textureLoad( matricesTexture, ivec2( x.add( 3 ), y ) )
|
|
70
77
|
);
|
|
71
78
|
|
|
79
|
+
|
|
80
|
+
const colorsTexture = this.batchMesh._colorsTexture;
|
|
81
|
+
|
|
82
|
+
if ( colorsTexture !== null ) {
|
|
83
|
+
|
|
84
|
+
const getBatchingColor = Fn( ( [ id ] ) => {
|
|
85
|
+
|
|
86
|
+
const size = textureSize( textureLoad( colorsTexture ), 0 ).x;
|
|
87
|
+
const j = id;
|
|
88
|
+
const x = j.modInt( size );
|
|
89
|
+
const y = j.div( size );
|
|
90
|
+
return textureLoad( colorsTexture, ivec2( x, y ) ).rgb;
|
|
91
|
+
|
|
92
|
+
} ).setLayout( {
|
|
93
|
+
name: 'getBatchingColor',
|
|
94
|
+
type: 'vec3',
|
|
95
|
+
inputs: [
|
|
96
|
+
{ name: 'id', type: 'int' }
|
|
97
|
+
]
|
|
98
|
+
} );
|
|
99
|
+
|
|
100
|
+
const color = getBatchingColor( indirectId );
|
|
101
|
+
|
|
102
|
+
varyingProperty( 'vec3', 'vBatchColor' ).assign( color );
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
|
|
72
106
|
const bm = mat3( batchingMatrix );
|
|
73
107
|
|
|
74
108
|
positionLocal.assign( batchingMatrix.mul( positionLocal ) );
|
|
@@ -91,6 +125,4 @@ class BatchNode extends Node {
|
|
|
91
125
|
|
|
92
126
|
export default BatchNode;
|
|
93
127
|
|
|
94
|
-
export const batch = nodeProxy( BatchNode );
|
|
95
|
-
|
|
96
|
-
addNodeClass( 'batch', BatchNode );
|
|
128
|
+
export const batch = /*@__PURE__*/ nodeProxy( BatchNode );
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { varying } from '../core/VaryingNode.js';
|
|
2
|
-
import { cameraViewMatrix } from './
|
|
3
|
-
import { normalGeometry, normalLocal, normalView, normalWorld, transformedNormalView } from './
|
|
4
|
-
import { tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTangentView } from './
|
|
2
|
+
import { cameraViewMatrix } from './Camera.js';
|
|
3
|
+
import { normalGeometry, normalLocal, normalView, normalWorld, transformedNormalView } from './Normal.js';
|
|
4
|
+
import { tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTangentView } from './Tangent.js';
|
|
5
5
|
|
|
6
6
|
const getBitangent = ( crossNormalTangent ) => crossNormalTangent.mul( tangentGeometry.w ).xyz;
|
|
7
7
|
|
|
8
|
-
export const bitangentGeometry =
|
|
9
|
-
export const bitangentLocal =
|
|
10
|
-
export const bitangentView =
|
|
11
|
-
export const bitangentWorld =
|
|
12
|
-
export const transformedBitangentView =
|
|
13
|
-
export const transformedBitangentWorld =
|
|
8
|
+
export const bitangentGeometry = /*@__PURE__*/ varying( getBitangent( normalGeometry.cross( tangentGeometry ) ), 'v_bitangentGeometry' ).normalize().toVar( 'bitangentGeometry' );
|
|
9
|
+
export const bitangentLocal = /*@__PURE__*/ varying( getBitangent( normalLocal.cross( tangentLocal ) ), 'v_bitangentLocal' ).normalize().toVar( 'bitangentLocal' );
|
|
10
|
+
export const bitangentView = /*@__PURE__*/ varying( getBitangent( normalView.cross( tangentView ) ), 'v_bitangentView' ).normalize().toVar( 'bitangentView' );
|
|
11
|
+
export const bitangentWorld = /*@__PURE__*/ varying( getBitangent( normalWorld.cross( tangentWorld ) ), 'v_bitangentWorld' ).normalize().toVar( 'bitangentWorld' );
|
|
12
|
+
export const transformedBitangentView = /*@__PURE__*/ getBitangent( transformedNormalView.cross( transformedTangentView ) ).normalize().toVar( 'transformedBitangentView' );
|
|
13
|
+
export const transformedBitangentWorld = /*@__PURE__*/ transformedBitangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedBitangentWorld' );
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import InputNode from '../core/InputNode.js';
|
|
2
|
-
import {
|
|
2
|
+
import { nodeObject, addMethodChaining } from '../tsl/TSLCore.js';
|
|
3
3
|
import { varying } from '../core/VaryingNode.js';
|
|
4
|
-
import { nodeObject, addNodeElement } from '../shadernode/ShaderNode.js';
|
|
5
4
|
|
|
6
5
|
import { InterleavedBufferAttribute } from '../../core/InterleavedBufferAttribute.js';
|
|
7
6
|
import { InterleavedBuffer } from '../../core/InterleavedBuffer.js';
|
|
@@ -9,6 +8,12 @@ import { StaticDrawUsage, DynamicDrawUsage } from '../../constants.js';
|
|
|
9
8
|
|
|
10
9
|
class BufferAttributeNode extends InputNode {
|
|
11
10
|
|
|
11
|
+
static get type() {
|
|
12
|
+
|
|
13
|
+
return 'BufferAttributeNode';
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
constructor( value, bufferType = null, bufferStride = 0, bufferOffset = 0 ) {
|
|
13
18
|
|
|
14
19
|
super( value, bufferType );
|
|
@@ -157,6 +162,4 @@ export const dynamicBufferAttribute = ( array, type, stride, offset ) => bufferA
|
|
|
157
162
|
export const instancedBufferAttribute = ( array, type, stride, offset ) => bufferAttribute( array, type, stride, offset ).setInstanced( true );
|
|
158
163
|
export const instancedDynamicBufferAttribute = ( array, type, stride, offset ) => dynamicBufferAttribute( array, type, stride, offset ).setInstanced( true );
|
|
159
164
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
addNodeClass( 'BufferAttributeNode', BufferAttributeNode );
|
|
165
|
+
addMethodChaining( 'toAttribute', ( bufferNode ) => bufferAttribute( bufferNode.value ) );
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import UniformNode from '../core/UniformNode.js';
|
|
2
|
-
import {
|
|
3
|
-
import { nodeObject } from '../shadernode/ShaderNode.js';
|
|
2
|
+
import { nodeObject } from '../tsl/TSLBase.js';
|
|
4
3
|
|
|
5
4
|
class BufferNode extends UniformNode {
|
|
6
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'BufferNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
constructor( value, bufferType, bufferCount = 0 ) {
|
|
8
13
|
|
|
9
14
|
super( value, bufferType );
|
|
@@ -32,5 +37,3 @@ class BufferNode extends UniformNode {
|
|
|
32
37
|
export default BufferNode;
|
|
33
38
|
|
|
34
39
|
export const buffer = ( value, type, count ) => nodeObject( new BufferNode( value, type, count ) );
|
|
35
|
-
|
|
36
|
-
addNodeClass( 'BufferNode', BufferNode );
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { uniform } from '../core/UniformNode.js';
|
|
2
|
+
import { renderGroup } from '../core/UniformGroupNode.js';
|
|
3
|
+
import { Vector3 } from '../../math/Vector3.js';
|
|
4
|
+
|
|
5
|
+
export const cameraNear = /*@__PURE__*/ uniform( 'float' ).label( 'cameraNear' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.near );
|
|
6
|
+
export const cameraFar = /*@__PURE__*/ uniform( 'float' ).label( 'cameraFar' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.far );
|
|
7
|
+
export const cameraLogDepth = /*@__PURE__*/ uniform( 'float' ).label( 'cameraLogDepth' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
|
|
8
|
+
export const cameraProjectionMatrix = /*@__PURE__*/ uniform( 'mat4' ).label( 'cameraProjectionMatrix' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.projectionMatrix );
|
|
9
|
+
export const cameraProjectionMatrixInverse = /*@__PURE__*/ uniform( 'mat4' ).label( 'cameraProjectionMatrixInverse' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.projectionMatrixInverse );
|
|
10
|
+
export const cameraViewMatrix = /*@__PURE__*/ uniform( 'mat4' ).label( 'cameraViewMatrix' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.matrixWorldInverse );
|
|
11
|
+
export const cameraWorldMatrix = /*@__PURE__*/ uniform( 'mat4' ).label( 'cameraWorldMatrix' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.matrixWorld );
|
|
12
|
+
export const cameraNormalMatrix = /*@__PURE__*/ uniform( 'mat3' ).label( 'cameraNormalMatrix' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.normalMatrix );
|
|
13
|
+
export const cameraPosition = /*@__PURE__*/ uniform( new Vector3() ).label( 'cameraPosition' ).setGroup( renderGroup ).onRenderUpdate( ( { camera }, self ) => self.value.setFromMatrixPosition( camera.matrixWorld ) );
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
|
|
2
2
|
import Node from '../core/Node.js';
|
|
3
|
-
import { nodeObject } from '../
|
|
4
|
-
import { positionView } from './
|
|
3
|
+
import { nodeObject } from '../tsl/TSLBase.js';
|
|
4
|
+
import { positionView } from './Position.js';
|
|
5
5
|
import { diffuseColor, property } from '../core/PropertyNode.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { Fn } from '../tsl/TSLBase.js';
|
|
7
|
+
import { Loop } from '../utils/LoopNode.js';
|
|
8
8
|
import { smoothstep } from '../math/MathNode.js';
|
|
9
|
-
import {
|
|
9
|
+
import { uniformArray } from './UniformArrayNode.js';
|
|
10
10
|
|
|
11
11
|
class ClippingNode extends Node {
|
|
12
12
|
|
|
13
|
+
static get type() {
|
|
14
|
+
|
|
15
|
+
return 'ClippingNode';
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
constructor( scope = ClippingNode.DEFAULT ) {
|
|
14
20
|
|
|
15
21
|
super();
|
|
@@ -42,9 +48,9 @@ class ClippingNode extends Node {
|
|
|
42
48
|
|
|
43
49
|
setupAlphaToCoverage( planes, numClippingPlanes, numUnionClippingPlanes ) {
|
|
44
50
|
|
|
45
|
-
return
|
|
51
|
+
return Fn( () => {
|
|
46
52
|
|
|
47
|
-
const clippingPlanes =
|
|
53
|
+
const clippingPlanes = uniformArray( planes );
|
|
48
54
|
|
|
49
55
|
const distanceToPlane = property( 'float', 'distanceToPlane' );
|
|
50
56
|
const distanceGradient = property( 'float', 'distanceToGradient' );
|
|
@@ -55,7 +61,7 @@ class ClippingNode extends Node {
|
|
|
55
61
|
|
|
56
62
|
let plane;
|
|
57
63
|
|
|
58
|
-
|
|
64
|
+
Loop( numUnionClippingPlanes, ( { i } ) => {
|
|
59
65
|
|
|
60
66
|
plane = clippingPlanes.element( i );
|
|
61
67
|
|
|
@@ -74,7 +80,7 @@ class ClippingNode extends Node {
|
|
|
74
80
|
|
|
75
81
|
unionClipOpacity.assign( 1 );
|
|
76
82
|
|
|
77
|
-
|
|
83
|
+
Loop( { start: numUnionClippingPlanes, end: numClippingPlanes }, ( { i } ) => {
|
|
78
84
|
|
|
79
85
|
plane = clippingPlanes.element( i );
|
|
80
86
|
|
|
@@ -99,13 +105,13 @@ class ClippingNode extends Node {
|
|
|
99
105
|
|
|
100
106
|
setupDefault( planes, numClippingPlanes, numUnionClippingPlanes ) {
|
|
101
107
|
|
|
102
|
-
return
|
|
108
|
+
return Fn( () => {
|
|
103
109
|
|
|
104
|
-
const clippingPlanes =
|
|
110
|
+
const clippingPlanes = uniformArray( planes );
|
|
105
111
|
|
|
106
112
|
let plane;
|
|
107
113
|
|
|
108
|
-
|
|
114
|
+
Loop( numUnionClippingPlanes, ( { i } ) => {
|
|
109
115
|
|
|
110
116
|
plane = clippingPlanes.element( i );
|
|
111
117
|
positionView.dot( plane.xyz ).greaterThan( plane.w ).discard();
|
|
@@ -118,7 +124,7 @@ class ClippingNode extends Node {
|
|
|
118
124
|
|
|
119
125
|
clipped.assign( true );
|
|
120
126
|
|
|
121
|
-
|
|
127
|
+
Loop( { start: numUnionClippingPlanes, end: numClippingPlanes }, ( { i } ) => {
|
|
122
128
|
|
|
123
129
|
plane = clippingPlanes.element( i );
|
|
124
130
|
clipped.assign( positionView.dot( plane.xyz ).greaterThan( plane.w ).and( clipped ) );
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import TextureNode from './TextureNode.js';
|
|
2
|
-
import { reflectVector, refractVector } from './
|
|
3
|
-
import {
|
|
4
|
-
import { addNodeElement, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
|
|
2
|
+
import { reflectVector, refractVector } from './ReflectVector.js';
|
|
3
|
+
import { nodeProxy, vec3 } from '../tsl/TSLBase.js';
|
|
5
4
|
|
|
6
5
|
import { CubeReflectionMapping, CubeRefractionMapping, WebGPUCoordinateSystem } from '../../constants.js';
|
|
7
6
|
|
|
8
7
|
class CubeTextureNode extends TextureNode {
|
|
9
8
|
|
|
9
|
+
static get type() {
|
|
10
|
+
|
|
11
|
+
return 'CubeTextureNode';
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
constructor( value, uvNode = null, levelNode = null, biasNode = null ) {
|
|
11
16
|
|
|
12
17
|
super( value, uvNode, levelNode, biasNode );
|
|
@@ -71,8 +76,4 @@ class CubeTextureNode extends TextureNode {
|
|
|
71
76
|
|
|
72
77
|
export default CubeTextureNode;
|
|
73
78
|
|
|
74
|
-
export const cubeTexture = nodeProxy( CubeTextureNode );
|
|
75
|
-
|
|
76
|
-
addNodeElement( 'cubeTexture', cubeTexture );
|
|
77
|
-
|
|
78
|
-
addNodeClass( 'CubeTextureNode', CubeTextureNode );
|
|
79
|
+
export const cubeTexture = /*@__PURE__*/ nodeProxy( CubeTextureNode );
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
2
|
import { varyingProperty } from '../core/PropertyNode.js';
|
|
3
3
|
import { instancedBufferAttribute, instancedDynamicBufferAttribute } from './BufferAttributeNode.js';
|
|
4
|
-
import { normalLocal } from './
|
|
5
|
-
import { positionLocal } from './
|
|
6
|
-
import { nodeProxy, vec3,
|
|
4
|
+
import { normalLocal, transformNormal } from './Normal.js';
|
|
5
|
+
import { positionLocal } from './Position.js';
|
|
6
|
+
import { nodeProxy, vec3, mat4 } from '../tsl/TSLBase.js';
|
|
7
7
|
import { NodeUpdateType } from '../core/constants.js';
|
|
8
8
|
import { buffer } from '../accessors/BufferNode.js';
|
|
9
9
|
import { instanceIndex } from '../core/IndexNode.js';
|
|
@@ -14,6 +14,12 @@ import { DynamicDrawUsage } from '../../constants.js';
|
|
|
14
14
|
|
|
15
15
|
class InstanceNode extends Node {
|
|
16
16
|
|
|
17
|
+
static get type() {
|
|
18
|
+
|
|
19
|
+
return 'InstanceNode';
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
17
23
|
constructor( instanceMesh ) {
|
|
18
24
|
|
|
19
25
|
super( 'void' );
|
|
@@ -31,7 +37,7 @@ class InstanceNode extends Node {
|
|
|
31
37
|
|
|
32
38
|
}
|
|
33
39
|
|
|
34
|
-
setup(
|
|
40
|
+
setup( builder ) {
|
|
35
41
|
|
|
36
42
|
let instanceMatrixNode = this.instanceMatrixNode;
|
|
37
43
|
let instanceColorNode = this.instanceColorNode;
|
|
@@ -46,7 +52,7 @@ class InstanceNode extends Node {
|
|
|
46
52
|
|
|
47
53
|
if ( instanceMesh.count <= 1000 ) {
|
|
48
54
|
|
|
49
|
-
instanceMatrixNode = buffer( instanceAttribute.array, 'mat4', instanceMesh.count ).element( instanceIndex );
|
|
55
|
+
instanceMatrixNode = buffer( instanceAttribute.array, 'mat4', Math.max( instanceMesh.count, 1 ) ).element( instanceIndex );
|
|
50
56
|
|
|
51
57
|
} else {
|
|
52
58
|
|
|
@@ -91,19 +97,19 @@ class InstanceNode extends Node {
|
|
|
91
97
|
// POSITION
|
|
92
98
|
|
|
93
99
|
const instancePosition = instanceMatrixNode.mul( positionLocal ).xyz;
|
|
100
|
+
positionLocal.assign( instancePosition );
|
|
94
101
|
|
|
95
102
|
// NORMAL
|
|
96
103
|
|
|
97
|
-
|
|
104
|
+
if ( builder.hasGeometryAttribute( 'normal' ) ) {
|
|
98
105
|
|
|
99
|
-
|
|
106
|
+
const instanceNormal = transformNormal( normalLocal, instanceMatrixNode );
|
|
100
107
|
|
|
101
|
-
|
|
108
|
+
// ASSIGNS
|
|
102
109
|
|
|
103
|
-
|
|
110
|
+
normalLocal.assign( instanceNormal );
|
|
104
111
|
|
|
105
|
-
|
|
106
|
-
normalLocal.assign( instanceNormal );
|
|
112
|
+
}
|
|
107
113
|
|
|
108
114
|
// COLOR
|
|
109
115
|
|
|
@@ -135,6 +141,4 @@ class InstanceNode extends Node {
|
|
|
135
141
|
|
|
136
142
|
export default InstanceNode;
|
|
137
143
|
|
|
138
|
-
export const instance = nodeProxy( InstanceNode );
|
|
139
|
-
|
|
140
|
-
addNodeClass( 'InstanceNode', InstanceNode );
|
|
144
|
+
export const instance = /*@__PURE__*/ nodeProxy( InstanceNode );
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import MaterialNode from './MaterialNode.js';
|
|
2
|
-
import {
|
|
3
|
-
import { nodeImmutable } from '../shadernode/ShaderNode.js';
|
|
2
|
+
import { nodeImmutable } from '../tsl/TSLBase.js';
|
|
4
3
|
|
|
5
4
|
class InstancedPointsMaterialNode extends MaterialNode {
|
|
6
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'InstancedPointsMaterialNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
setup( /*builder*/ ) {
|
|
8
13
|
|
|
9
14
|
return this.getFloat( this.scope );
|
|
@@ -16,6 +21,4 @@ InstancedPointsMaterialNode.POINT_WIDTH = 'pointWidth';
|
|
|
16
21
|
|
|
17
22
|
export default InstancedPointsMaterialNode;
|
|
18
23
|
|
|
19
|
-
export const materialPointWidth = nodeImmutable( InstancedPointsMaterialNode, InstancedPointsMaterialNode.POINT_WIDTH );
|
|
20
|
-
|
|
21
|
-
addNodeClass( 'InstancedPointsMaterialNode', InstancedPointsMaterialNode );
|
|
24
|
+
export const materialPointWidth = /*@__PURE__*/ nodeImmutable( InstancedPointsMaterialNode, InstancedPointsMaterialNode.POINT_WIDTH );
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { uniform } from '../core/UniformNode.js';
|
|
2
|
+
import { renderGroup } from '../core/UniformGroupNode.js';
|
|
3
|
+
import { Vector3 } from '../../math/Vector3.js';
|
|
4
|
+
import { cameraViewMatrix } from './Camera.js';
|
|
5
|
+
|
|
6
|
+
let uniformsLib;
|
|
7
|
+
|
|
8
|
+
function getLightData( light ) {
|
|
9
|
+
|
|
10
|
+
uniformsLib = uniformsLib || new WeakMap();
|
|
11
|
+
|
|
12
|
+
let uniforms = uniformsLib.get( light );
|
|
13
|
+
|
|
14
|
+
if ( uniforms === undefined ) uniformsLib.set( light, uniforms = {} );
|
|
15
|
+
|
|
16
|
+
return uniforms;
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function lightPosition( light ) {
|
|
21
|
+
|
|
22
|
+
const data = getLightData( light );
|
|
23
|
+
|
|
24
|
+
return data.position || ( data.position = uniform( new Vector3() ).setGroup( renderGroup ).onRenderUpdate( ( _, self ) => self.value.setFromMatrixPosition( light.matrixWorld ) ) );
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function lightTargetPosition( light ) {
|
|
29
|
+
|
|
30
|
+
const data = getLightData( light );
|
|
31
|
+
|
|
32
|
+
return data.targetPosition || ( data.targetPosition = uniform( new Vector3() ).setGroup( renderGroup ).onRenderUpdate( ( _, self ) => self.value.setFromMatrixPosition( light.target.matrixWorld ) ) );
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function lightViewPosition( light ) {
|
|
37
|
+
|
|
38
|
+
const data = getLightData( light );
|
|
39
|
+
|
|
40
|
+
return data.viewPosition || ( data.viewPosition = uniform( new Vector3() ).setGroup( renderGroup ).onRenderUpdate( ( { camera }, self ) => {
|
|
41
|
+
|
|
42
|
+
self.value = self.value || new Vector3();
|
|
43
|
+
self.value.setFromMatrixPosition( light.matrixWorld );
|
|
44
|
+
|
|
45
|
+
self.value.applyMatrix4( camera.matrixWorldInverse );
|
|
46
|
+
|
|
47
|
+
} ) );
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const lightTargetDirection = ( light ) => cameraViewMatrix.transformDirection( lightPosition( light ).sub( lightTargetPosition( light ) ) );
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
2
|
import { reference } from './ReferenceNode.js';
|
|
3
3
|
import { materialReference } from './MaterialReferenceNode.js';
|
|
4
|
-
import { normalView } from './
|
|
5
|
-
import { nodeImmutable, float, vec2, mat2 } from '../
|
|
4
|
+
import { normalView } from './Normal.js';
|
|
5
|
+
import { nodeImmutable, float, vec2, vec3, mat2 } from '../tsl/TSLBase.js';
|
|
6
6
|
import { uniform } from '../core/UniformNode.js';
|
|
7
|
+
import { normalMap } from '../display/NormalMapNode.js';
|
|
8
|
+
import { bumpMap } from '../display/BumpMapNode.js';
|
|
7
9
|
|
|
8
10
|
import { Vector2 } from '../../math/Vector2.js';
|
|
9
11
|
|
|
@@ -11,6 +13,12 @@ const _propertyCache = new Map();
|
|
|
11
13
|
|
|
12
14
|
class MaterialNode extends Node {
|
|
13
15
|
|
|
16
|
+
static get type() {
|
|
17
|
+
|
|
18
|
+
return 'MaterialNode';
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
constructor( scope ) {
|
|
15
23
|
|
|
16
24
|
super();
|
|
@@ -62,7 +70,7 @@ class MaterialNode extends Node {
|
|
|
62
70
|
|
|
63
71
|
if ( scope === MaterialNode.COLOR ) {
|
|
64
72
|
|
|
65
|
-
const colorNode = this.getColor( scope );
|
|
73
|
+
const colorNode = material.color !== undefined ? this.getColor( scope ) : vec3();
|
|
66
74
|
|
|
67
75
|
if ( material.map && material.map.isTexture === true ) {
|
|
68
76
|
|
|
@@ -175,11 +183,12 @@ class MaterialNode extends Node {
|
|
|
175
183
|
|
|
176
184
|
if ( material.normalMap ) {
|
|
177
185
|
|
|
178
|
-
node = this.getTexture( 'normal' )
|
|
186
|
+
node = normalMap( this.getTexture( 'normal' ), this.getCache( 'normalScale', 'vec2' ) );
|
|
187
|
+
node.normalMapType = material.normalMapType;
|
|
179
188
|
|
|
180
189
|
} else if ( material.bumpMap ) {
|
|
181
190
|
|
|
182
|
-
node = this.getTexture( 'bump' ).r
|
|
191
|
+
node = bumpMap( this.getTexture( 'bump' ).r, this.getFloat( 'bumpScale' ) );
|
|
183
192
|
|
|
184
193
|
} else {
|
|
185
194
|
|
|
@@ -219,7 +228,7 @@ class MaterialNode extends Node {
|
|
|
219
228
|
|
|
220
229
|
if ( material.clearcoatNormalMap ) {
|
|
221
230
|
|
|
222
|
-
node = this.getTexture( scope )
|
|
231
|
+
node = normalMap( this.getTexture( scope ), this.getCache( scope + 'Scale', 'vec2' ) );
|
|
223
232
|
|
|
224
233
|
} else {
|
|
225
234
|
|
|
@@ -320,10 +329,6 @@ class MaterialNode extends Node {
|
|
|
320
329
|
|
|
321
330
|
node = this.getFloat( scope );
|
|
322
331
|
|
|
323
|
-
} else if ( scope === MaterialNode.REFRACTION_RATIO ) {
|
|
324
|
-
|
|
325
|
-
node = this.getFloat( scope );
|
|
326
|
-
|
|
327
332
|
} else if ( scope === MaterialNode.LIGHT_MAP ) {
|
|
328
333
|
|
|
329
334
|
node = this.getTexture( scope ).rgb.mul( this.getFloat( 'lightMapIntensity' ) );
|
|
@@ -383,51 +388,49 @@ MaterialNode.POINT_WIDTH = 'pointWidth';
|
|
|
383
388
|
MaterialNode.DISPERSION = 'dispersion';
|
|
384
389
|
MaterialNode.LIGHT_MAP = 'light';
|
|
385
390
|
MaterialNode.AO_MAP = 'ao';
|
|
386
|
-
MaterialNode.REFRACTION_RATIO = 'refractionRatio';
|
|
387
391
|
|
|
388
392
|
export default MaterialNode;
|
|
389
393
|
|
|
390
|
-
export const materialAlphaTest = nodeImmutable( MaterialNode, MaterialNode.ALPHA_TEST );
|
|
391
|
-
export const materialColor = nodeImmutable( MaterialNode, MaterialNode.COLOR );
|
|
392
|
-
export const materialShininess = nodeImmutable( MaterialNode, MaterialNode.SHININESS );
|
|
393
|
-
export const materialEmissive = nodeImmutable( MaterialNode, MaterialNode.EMISSIVE );
|
|
394
|
-
export const materialOpacity = nodeImmutable( MaterialNode, MaterialNode.OPACITY );
|
|
395
|
-
export const materialSpecular = nodeImmutable( MaterialNode, MaterialNode.SPECULAR );
|
|
396
|
-
|
|
397
|
-
export const materialSpecularIntensity = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_INTENSITY );
|
|
398
|
-
export const materialSpecularColor = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_COLOR );
|
|
399
|
-
|
|
400
|
-
export const materialSpecularStrength = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_STRENGTH );
|
|
401
|
-
export const materialReflectivity = nodeImmutable( MaterialNode, MaterialNode.REFLECTIVITY );
|
|
402
|
-
export const materialRoughness = nodeImmutable( MaterialNode, MaterialNode.ROUGHNESS );
|
|
403
|
-
export const materialMetalness = nodeImmutable( MaterialNode, MaterialNode.METALNESS );
|
|
404
|
-
export const materialNormal = nodeImmutable( MaterialNode, MaterialNode.NORMAL );
|
|
405
|
-
export const materialClearcoat = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT );
|
|
406
|
-
export const materialClearcoatRoughness = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_ROUGHNESS );
|
|
407
|
-
export const materialClearcoatNormal = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_NORMAL );
|
|
408
|
-
export const materialRotation = nodeImmutable( MaterialNode, MaterialNode.ROTATION );
|
|
409
|
-
export const materialSheen = nodeImmutable( MaterialNode, MaterialNode.SHEEN );
|
|
410
|
-
export const materialSheenRoughness = nodeImmutable( MaterialNode, MaterialNode.SHEEN_ROUGHNESS );
|
|
411
|
-
export const materialAnisotropy = nodeImmutable( MaterialNode, MaterialNode.ANISOTROPY );
|
|
412
|
-
export const materialIridescence = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE );
|
|
413
|
-
export const materialIridescenceIOR = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_IOR );
|
|
414
|
-
export const materialIridescenceThickness = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_THICKNESS );
|
|
415
|
-
export const materialTransmission = nodeImmutable( MaterialNode, MaterialNode.TRANSMISSION );
|
|
416
|
-
export const materialThickness = nodeImmutable( MaterialNode, MaterialNode.THICKNESS );
|
|
417
|
-
export const materialIOR = nodeImmutable( MaterialNode, MaterialNode.IOR );
|
|
418
|
-
export const materialAttenuationDistance = nodeImmutable( MaterialNode, MaterialNode.ATTENUATION_DISTANCE );
|
|
419
|
-
export const materialAttenuationColor = nodeImmutable( MaterialNode, MaterialNode.ATTENUATION_COLOR );
|
|
420
|
-
export const materialLineScale = nodeImmutable( MaterialNode, MaterialNode.LINE_SCALE );
|
|
421
|
-
export const materialLineDashSize = nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_SIZE );
|
|
422
|
-
export const materialLineGapSize = nodeImmutable( MaterialNode, MaterialNode.LINE_GAP_SIZE );
|
|
423
|
-
export const materialLineWidth = nodeImmutable( MaterialNode, MaterialNode.LINE_WIDTH );
|
|
424
|
-
export const materialLineDashOffset = nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_OFFSET );
|
|
425
|
-
export const materialPointWidth = nodeImmutable( MaterialNode, MaterialNode.POINT_WIDTH );
|
|
426
|
-
export const materialDispersion = nodeImmutable( MaterialNode, MaterialNode.DISPERSION );
|
|
427
|
-
export const materialLightMap = nodeImmutable( MaterialNode, MaterialNode.LIGHT_MAP );
|
|
428
|
-
export const materialAOMap = nodeImmutable( MaterialNode, MaterialNode.AO_MAP );
|
|
429
|
-
export const
|
|
430
|
-
export const materialAnisotropyVector = uniform( new Vector2() ).onReference( function ( frame ) {
|
|
394
|
+
export const materialAlphaTest = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ALPHA_TEST );
|
|
395
|
+
export const materialColor = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.COLOR );
|
|
396
|
+
export const materialShininess = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SHININESS );
|
|
397
|
+
export const materialEmissive = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.EMISSIVE );
|
|
398
|
+
export const materialOpacity = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.OPACITY );
|
|
399
|
+
export const materialSpecular = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SPECULAR );
|
|
400
|
+
|
|
401
|
+
export const materialSpecularIntensity = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SPECULAR_INTENSITY );
|
|
402
|
+
export const materialSpecularColor = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SPECULAR_COLOR );
|
|
403
|
+
|
|
404
|
+
export const materialSpecularStrength = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SPECULAR_STRENGTH );
|
|
405
|
+
export const materialReflectivity = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.REFLECTIVITY );
|
|
406
|
+
export const materialRoughness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ROUGHNESS );
|
|
407
|
+
export const materialMetalness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.METALNESS );
|
|
408
|
+
export const materialNormal = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.NORMAL ).context( { getUV: null } );
|
|
409
|
+
export const materialClearcoat = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT );
|
|
410
|
+
export const materialClearcoatRoughness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_ROUGHNESS );
|
|
411
|
+
export const materialClearcoatNormal = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_NORMAL ).context( { getUV: null } );
|
|
412
|
+
export const materialRotation = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ROTATION );
|
|
413
|
+
export const materialSheen = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SHEEN );
|
|
414
|
+
export const materialSheenRoughness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SHEEN_ROUGHNESS );
|
|
415
|
+
export const materialAnisotropy = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ANISOTROPY );
|
|
416
|
+
export const materialIridescence = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE );
|
|
417
|
+
export const materialIridescenceIOR = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_IOR );
|
|
418
|
+
export const materialIridescenceThickness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_THICKNESS );
|
|
419
|
+
export const materialTransmission = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.TRANSMISSION );
|
|
420
|
+
export const materialThickness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.THICKNESS );
|
|
421
|
+
export const materialIOR = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.IOR );
|
|
422
|
+
export const materialAttenuationDistance = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ATTENUATION_DISTANCE );
|
|
423
|
+
export const materialAttenuationColor = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ATTENUATION_COLOR );
|
|
424
|
+
export const materialLineScale = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LINE_SCALE );
|
|
425
|
+
export const materialLineDashSize = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_SIZE );
|
|
426
|
+
export const materialLineGapSize = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LINE_GAP_SIZE );
|
|
427
|
+
export const materialLineWidth = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LINE_WIDTH );
|
|
428
|
+
export const materialLineDashOffset = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_OFFSET );
|
|
429
|
+
export const materialPointWidth = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.POINT_WIDTH );
|
|
430
|
+
export const materialDispersion = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.DISPERSION );
|
|
431
|
+
export const materialLightMap = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LIGHT_MAP );
|
|
432
|
+
export const materialAOMap = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.AO_MAP );
|
|
433
|
+
export const materialAnisotropyVector = /*@__PURE__*/ uniform( new Vector2() ).onReference( function ( frame ) {
|
|
431
434
|
|
|
432
435
|
return frame.material;
|
|
433
436
|
|
|
@@ -436,5 +439,3 @@ export const materialAnisotropyVector = uniform( new Vector2() ).onReference( fu
|
|
|
436
439
|
this.value.set( material.anisotropy * Math.cos( material.anisotropyRotation ), material.anisotropy * Math.sin( material.anisotropyRotation ) );
|
|
437
440
|
|
|
438
441
|
} );
|
|
439
|
-
|
|
440
|
-
addNodeClass( 'MaterialNode', MaterialNode );
|