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,9 +1,8 @@
|
|
|
1
|
-
import { addNodeMaterial } from './NodeMaterial.js';
|
|
2
|
-
import { transformedNormalView } from '../accessors/NormalNode.js';
|
|
3
|
-
import { positionViewDirection } from '../accessors/PositionNode.js';
|
|
4
|
-
import PhysicalLightingModel from '../functions/PhysicalLightingModel.js';
|
|
5
1
|
import MeshPhysicalNodeMaterial from './MeshPhysicalNodeMaterial.js';
|
|
6
|
-
import
|
|
2
|
+
import PhysicalLightingModel from '../../nodes/functions/PhysicalLightingModel.js';
|
|
3
|
+
import { transformedNormalView } from '../../nodes/accessors/Normal.js';
|
|
4
|
+
import { positionViewDirection } from '../../nodes/accessors/Position.js';
|
|
5
|
+
import { float, vec3 } from '../../nodes/tsl/TSLBase.js';
|
|
7
6
|
|
|
8
7
|
class SSSLightingModel extends PhysicalLightingModel {
|
|
9
8
|
|
|
@@ -39,6 +38,12 @@ class SSSLightingModel extends PhysicalLightingModel {
|
|
|
39
38
|
|
|
40
39
|
class MeshSSSNodeMaterial extends MeshPhysicalNodeMaterial {
|
|
41
40
|
|
|
41
|
+
static get type() {
|
|
42
|
+
|
|
43
|
+
return 'MeshSSSNodeMaterial';
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
42
47
|
constructor( parameters ) {
|
|
43
48
|
|
|
44
49
|
super( parameters );
|
|
@@ -80,5 +85,3 @@ class MeshSSSNodeMaterial extends MeshPhysicalNodeMaterial {
|
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
export default MeshSSSNodeMaterial;
|
|
83
|
-
|
|
84
|
-
addNodeMaterial( 'MeshSSSNodeMaterial', MeshSSSNodeMaterial );
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import NodeMaterial
|
|
2
|
-
import { diffuseColor, metalness, roughness, specularColor, specularF90 } from '
|
|
3
|
-
import { mix } from '
|
|
4
|
-
import { materialRoughness, materialMetalness } from '
|
|
5
|
-
import getRoughness from '
|
|
6
|
-
import PhysicalLightingModel from '
|
|
7
|
-
import EnvironmentNode from '
|
|
8
|
-
import { float, vec3, vec4 } from '
|
|
1
|
+
import NodeMaterial from './NodeMaterial.js';
|
|
2
|
+
import { diffuseColor, metalness, roughness, specularColor, specularF90 } from '../../nodes/core/PropertyNode.js';
|
|
3
|
+
import { mix } from '../../nodes/math/MathNode.js';
|
|
4
|
+
import { materialRoughness, materialMetalness } from '../../nodes/accessors/MaterialNode.js';
|
|
5
|
+
import getRoughness from '../../nodes/functions/material/getRoughness.js';
|
|
6
|
+
import PhysicalLightingModel from '../../nodes/functions/PhysicalLightingModel.js';
|
|
7
|
+
import EnvironmentNode from '../../nodes/lighting/EnvironmentNode.js';
|
|
8
|
+
import { float, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
|
|
9
9
|
|
|
10
|
-
import { MeshStandardMaterial } from '
|
|
10
|
+
import { MeshStandardMaterial } from '../MeshStandardMaterial.js';
|
|
11
11
|
|
|
12
12
|
const _defaultValues = /*@__PURE__*/ new MeshStandardMaterial();
|
|
13
13
|
|
|
14
14
|
class MeshStandardNodeMaterial extends NodeMaterial {
|
|
15
15
|
|
|
16
|
+
static get type() {
|
|
17
|
+
|
|
18
|
+
return 'MeshStandardNodeMaterial';
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
16
22
|
constructor( parameters ) {
|
|
17
23
|
|
|
18
24
|
super();
|
|
@@ -34,7 +40,13 @@ class MeshStandardNodeMaterial extends NodeMaterial {
|
|
|
34
40
|
|
|
35
41
|
setupEnvironment( builder ) {
|
|
36
42
|
|
|
37
|
-
|
|
43
|
+
let envNode = super.setupEnvironment( builder );
|
|
44
|
+
|
|
45
|
+
if ( envNode === null && builder.environmentNode ) {
|
|
46
|
+
|
|
47
|
+
envNode = builder.environmentNode;
|
|
48
|
+
|
|
49
|
+
}
|
|
38
50
|
|
|
39
51
|
return envNode ? new EnvironmentNode( envNode ) : null;
|
|
40
52
|
|
|
@@ -94,5 +106,3 @@ class MeshStandardNodeMaterial extends NodeMaterial {
|
|
|
94
106
|
}
|
|
95
107
|
|
|
96
108
|
export default MeshStandardNodeMaterial;
|
|
97
|
-
|
|
98
|
-
addNodeMaterial( 'MeshStandardNodeMaterial', MeshStandardNodeMaterial );
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import NodeMaterial
|
|
2
|
-
import ToonLightingModel from '
|
|
1
|
+
import NodeMaterial from './NodeMaterial.js';
|
|
2
|
+
import ToonLightingModel from '../../nodes/functions/ToonLightingModel.js';
|
|
3
3
|
|
|
4
|
-
import { MeshToonMaterial } from '
|
|
4
|
+
import { MeshToonMaterial } from '../MeshToonMaterial.js';
|
|
5
5
|
|
|
6
6
|
const _defaultValues = /*@__PURE__*/ new MeshToonMaterial();
|
|
7
7
|
|
|
8
8
|
class MeshToonNodeMaterial extends NodeMaterial {
|
|
9
9
|
|
|
10
|
+
static get type() {
|
|
11
|
+
|
|
12
|
+
return 'MeshToonNodeMaterial';
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
constructor( parameters ) {
|
|
11
17
|
|
|
12
18
|
super();
|
|
@@ -30,5 +36,3 @@ class MeshToonNodeMaterial extends NodeMaterial {
|
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
export default MeshToonNodeMaterial;
|
|
33
|
-
|
|
34
|
-
addNodeMaterial( 'MeshToonNodeMaterial', MeshToonNodeMaterial );
|
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
import { Material } from '
|
|
1
|
+
import { Material } from '../Material.js';
|
|
2
2
|
import { NormalBlending } from '../../constants.js';
|
|
3
3
|
|
|
4
|
-
import { getNodeChildren, getCacheKey } from '
|
|
5
|
-
import { attribute } from '
|
|
6
|
-
import { output, diffuseColor, emissive, varyingProperty } from '
|
|
7
|
-
import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal, materialLightMap, materialAOMap } from '
|
|
8
|
-
import { modelViewProjection } from '
|
|
9
|
-
import {
|
|
10
|
-
import { instance } from '
|
|
11
|
-
import { batch } from '
|
|
12
|
-
import { materialReference } from '
|
|
13
|
-
import { positionLocal
|
|
14
|
-
import { skinningReference } from '
|
|
15
|
-
import { morphReference } from '
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
import {
|
|
21
|
-
import
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
24
|
-
import {
|
|
25
|
-
import
|
|
26
|
-
import { clipping, clippingAlpha } from '../accessors/ClippingNode.js';
|
|
27
|
-
import { faceDirection } from '../display/FrontFacingNode.js';
|
|
28
|
-
|
|
29
|
-
const NodeMaterials = new Map();
|
|
4
|
+
import { getNodeChildren, getCacheKey } from '../../nodes/core/NodeUtils.js';
|
|
5
|
+
import { attribute } from '../../nodes/core/AttributeNode.js';
|
|
6
|
+
import { output, diffuseColor, emissive, varyingProperty } from '../../nodes/core/PropertyNode.js';
|
|
7
|
+
import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal, materialLightMap, materialAOMap } from '../../nodes/accessors/MaterialNode.js';
|
|
8
|
+
import { modelViewProjection } from '../../nodes/accessors/ModelViewProjectionNode.js';
|
|
9
|
+
import { normalLocal } from '../../nodes/accessors/Normal.js';
|
|
10
|
+
import { instance } from '../../nodes/accessors/InstanceNode.js';
|
|
11
|
+
import { batch } from '../../nodes/accessors/BatchNode.js';
|
|
12
|
+
import { materialReference } from '../../nodes/accessors/MaterialReferenceNode.js';
|
|
13
|
+
import { positionLocal } from '../../nodes/accessors/Position.js';
|
|
14
|
+
import { skinningReference } from '../../nodes/accessors/SkinningNode.js';
|
|
15
|
+
import { morphReference } from '../../nodes/accessors/MorphNode.js';
|
|
16
|
+
import { lights } from '../../nodes/lighting/LightsNode.js';
|
|
17
|
+
import { mix } from '../../nodes/math/MathNode.js';
|
|
18
|
+
import { float, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
|
|
19
|
+
import AONode from '../../nodes/lighting/AONode.js';
|
|
20
|
+
import { lightingContext } from '../../nodes/lighting/LightingContextNode.js';
|
|
21
|
+
import IrradianceNode from '../../nodes/lighting/IrradianceNode.js';
|
|
22
|
+
import { depth } from '../../nodes/display/ViewportDepthNode.js';
|
|
23
|
+
import { cameraLogDepth } from '../../nodes/accessors/Camera.js';
|
|
24
|
+
import { clipping, clippingAlpha } from '../../nodes/accessors/ClippingNode.js';
|
|
25
|
+
import NodeMaterialObserver from './manager/NodeMaterialObserver.js';
|
|
30
26
|
|
|
31
27
|
class NodeMaterial extends Material {
|
|
32
28
|
|
|
29
|
+
static get type() {
|
|
30
|
+
|
|
31
|
+
return 'NodeMaterial';
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
33
35
|
constructor() {
|
|
34
36
|
|
|
35
37
|
super();
|
|
@@ -42,7 +44,6 @@ class NodeMaterial extends Material {
|
|
|
42
44
|
|
|
43
45
|
this.fog = true;
|
|
44
46
|
this.lights = false;
|
|
45
|
-
this.normals = true;
|
|
46
47
|
|
|
47
48
|
this.lightsNode = null;
|
|
48
49
|
this.envNode = null;
|
|
@@ -81,8 +82,16 @@ class NodeMaterial extends Material {
|
|
|
81
82
|
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
setupObserver( builder ) {
|
|
86
|
+
|
|
87
|
+
return new NodeMaterialObserver( builder );
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
84
91
|
setup( builder ) {
|
|
85
92
|
|
|
93
|
+
builder.context.setupNormal = () => this.setupNormal( builder );
|
|
94
|
+
|
|
86
95
|
// < VERTEX STAGE >
|
|
87
96
|
|
|
88
97
|
builder.addStack();
|
|
@@ -103,8 +112,6 @@ class NodeMaterial extends Material {
|
|
|
103
112
|
|
|
104
113
|
if ( this.fragmentNode === null ) {
|
|
105
114
|
|
|
106
|
-
if ( this.normals === true ) this.setupNormal( builder );
|
|
107
|
-
|
|
108
115
|
this.setupDiffuseColor( builder );
|
|
109
116
|
this.setupVariants( builder );
|
|
110
117
|
|
|
@@ -171,6 +178,10 @@ class NodeMaterial extends Material {
|
|
|
171
178
|
|
|
172
179
|
builder.addFlow( 'fragment', builder.removeStack() );
|
|
173
180
|
|
|
181
|
+
// < MONITOR >
|
|
182
|
+
|
|
183
|
+
builder.monitor = this.setupObserver( builder );
|
|
184
|
+
|
|
174
185
|
}
|
|
175
186
|
|
|
176
187
|
setupClipping( builder ) {
|
|
@@ -183,7 +194,9 @@ class NodeMaterial extends Material {
|
|
|
183
194
|
|
|
184
195
|
if ( globalClippingCount || localClippingCount ) {
|
|
185
196
|
|
|
186
|
-
|
|
197
|
+
const samples = builder.renderer.samples;
|
|
198
|
+
|
|
199
|
+
if ( this.alphaToCoverage && samples > 1 ) {
|
|
187
200
|
|
|
188
201
|
// to be added to flow when the color/alpha value has been determined
|
|
189
202
|
result = clippingAlpha();
|
|
@@ -208,11 +221,21 @@ class NodeMaterial extends Material {
|
|
|
208
221
|
|
|
209
222
|
let depthNode = this.depthNode;
|
|
210
223
|
|
|
211
|
-
if ( depthNode === null
|
|
224
|
+
if ( depthNode === null ) {
|
|
225
|
+
|
|
226
|
+
const mrt = renderer.getMRT();
|
|
227
|
+
|
|
228
|
+
if ( mrt && mrt.has( 'depth' ) ) {
|
|
229
|
+
|
|
230
|
+
depthNode = mrt.get( 'depth' );
|
|
231
|
+
|
|
232
|
+
} else if ( renderer.logarithmicDepthBuffer === true ) {
|
|
233
|
+
|
|
234
|
+
const fragDepth = modelViewProjection().w.add( 1 );
|
|
212
235
|
|
|
213
|
-
|
|
236
|
+
depthNode = fragDepth.log2().mul( cameraLogDepth ).mul( 0.5 );
|
|
214
237
|
|
|
215
|
-
|
|
238
|
+
}
|
|
216
239
|
|
|
217
240
|
}
|
|
218
241
|
|
|
@@ -304,6 +327,15 @@ class NodeMaterial extends Material {
|
|
|
304
327
|
|
|
305
328
|
}
|
|
306
329
|
|
|
330
|
+
if ( object.isBatchedMesh && object._colorsTexture ) {
|
|
331
|
+
|
|
332
|
+
const batchColor = varyingProperty( 'vec3', 'vBatchColor' );
|
|
333
|
+
|
|
334
|
+
colorNode = batchColor.mul( colorNode );
|
|
335
|
+
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
|
|
307
339
|
// COLOR
|
|
308
340
|
|
|
309
341
|
diffuseColor.assign( colorNode );
|
|
@@ -337,7 +369,6 @@ class NodeMaterial extends Material {
|
|
|
337
369
|
|
|
338
370
|
}
|
|
339
371
|
|
|
340
|
-
|
|
341
372
|
setupOutgoingLight() {
|
|
342
373
|
|
|
343
374
|
return ( this.lights === true ) ? vec3( 0 ) : diffuseColor.rgb;
|
|
@@ -346,25 +377,11 @@ class NodeMaterial extends Material {
|
|
|
346
377
|
|
|
347
378
|
setupNormal() {
|
|
348
379
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
if ( this.flatShading === true ) {
|
|
352
|
-
|
|
353
|
-
const normalNode = positionView.dFdx().cross( positionView.dFdy() ).normalize();
|
|
354
|
-
|
|
355
|
-
transformedNormalView.assign( normalNode.mul( faceDirection ) );
|
|
356
|
-
|
|
357
|
-
} else {
|
|
358
|
-
|
|
359
|
-
const normalNode = this.normalNode ? vec3( this.normalNode ) : materialNormal;
|
|
360
|
-
|
|
361
|
-
transformedNormalView.assign( normalNode.mul( faceDirection ) );
|
|
362
|
-
|
|
363
|
-
}
|
|
380
|
+
return this.normalNode ? vec3( this.normalNode ) : materialNormal;
|
|
364
381
|
|
|
365
382
|
}
|
|
366
383
|
|
|
367
|
-
setupEnvironment( builder ) {
|
|
384
|
+
setupEnvironment( /*builder*/ ) {
|
|
368
385
|
|
|
369
386
|
let node = null;
|
|
370
387
|
|
|
@@ -374,11 +391,7 @@ class NodeMaterial extends Material {
|
|
|
374
391
|
|
|
375
392
|
} else if ( this.envMap ) {
|
|
376
393
|
|
|
377
|
-
node = this.envMap.isCubeTexture ?
|
|
378
|
-
|
|
379
|
-
} else if ( builder.environmentNode ) {
|
|
380
|
-
|
|
381
|
-
node = builder.environmentNode;
|
|
394
|
+
node = this.envMap.isCubeTexture ? materialReference( 'envMap', 'cubeTexture' ) : materialReference( 'envMap', 'texture' );
|
|
382
395
|
|
|
383
396
|
}
|
|
384
397
|
|
|
@@ -434,7 +447,7 @@ class NodeMaterial extends Material {
|
|
|
434
447
|
|
|
435
448
|
if ( materialLightsNode.length > 0 ) {
|
|
436
449
|
|
|
437
|
-
lightsN =
|
|
450
|
+
lightsN = lights( [ ...lightsN.getLights(), ...materialLightsNode ] );
|
|
438
451
|
|
|
439
452
|
}
|
|
440
453
|
|
|
@@ -461,7 +474,7 @@ class NodeMaterial extends Material {
|
|
|
461
474
|
|
|
462
475
|
let outgoingLightNode = this.setupOutgoingLight( builder );
|
|
463
476
|
|
|
464
|
-
if ( lightsNode && lightsNode.
|
|
477
|
+
if ( lightsNode && lightsNode.getScope().getLights().length > 0 ) {
|
|
465
478
|
|
|
466
479
|
const lightingModel = this.setupLightingModel( builder );
|
|
467
480
|
|
|
@@ -624,63 +637,6 @@ class NodeMaterial extends Material {
|
|
|
624
637
|
|
|
625
638
|
}
|
|
626
639
|
|
|
627
|
-
static fromMaterial( material ) {
|
|
628
|
-
|
|
629
|
-
if ( material.isNodeMaterial === true ) { // is already a node material
|
|
630
|
-
|
|
631
|
-
return material;
|
|
632
|
-
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
const type = material.type.replace( 'Material', 'NodeMaterial' );
|
|
636
|
-
|
|
637
|
-
const nodeMaterial = createNodeMaterialFromType( type );
|
|
638
|
-
|
|
639
|
-
if ( nodeMaterial === undefined ) {
|
|
640
|
-
|
|
641
|
-
throw new Error( `NodeMaterial: Material "${ material.type }" is not compatible.` );
|
|
642
|
-
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
for ( const key in material ) {
|
|
646
|
-
|
|
647
|
-
nodeMaterial[ key ] = material[ key ];
|
|
648
|
-
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
return nodeMaterial;
|
|
652
|
-
|
|
653
|
-
}
|
|
654
|
-
|
|
655
640
|
}
|
|
656
641
|
|
|
657
642
|
export default NodeMaterial;
|
|
658
|
-
|
|
659
|
-
export function addNodeMaterial( type, nodeMaterial ) {
|
|
660
|
-
|
|
661
|
-
if ( typeof nodeMaterial !== 'function' || ! type ) throw new Error( `Node material ${ type } is not a class` );
|
|
662
|
-
if ( NodeMaterials.has( type ) ) {
|
|
663
|
-
|
|
664
|
-
console.warn( `Redefinition of node material ${ type }` );
|
|
665
|
-
return;
|
|
666
|
-
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
NodeMaterials.set( type, nodeMaterial );
|
|
670
|
-
nodeMaterial.type = type;
|
|
671
|
-
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
export function createNodeMaterialFromType( type ) {
|
|
675
|
-
|
|
676
|
-
const Material = NodeMaterials.get( type );
|
|
677
|
-
|
|
678
|
-
if ( Material !== undefined ) {
|
|
679
|
-
|
|
680
|
-
return new Material();
|
|
681
|
-
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
addNodeMaterial( 'NodeMaterial', NodeMaterial );
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// @TODO: We can simplify "export { default as SomeNode, other, exports } from '...'" to just "export * from '...'" if we will use only named exports
|
|
2
2
|
|
|
3
|
-
export { default as
|
|
3
|
+
export { default as NodeMaterialObserver } from './manager/NodeMaterialObserver.js';
|
|
4
|
+
|
|
5
|
+
export { default as NodeMaterial } from './NodeMaterial.js';
|
|
4
6
|
export { default as InstancedPointsNodeMaterial } from './InstancedPointsNodeMaterial.js';
|
|
5
7
|
export { default as LineBasicNodeMaterial } from './LineBasicNodeMaterial.js';
|
|
6
8
|
export { default as LineDashedNodeMaterial } from './LineDashedNodeMaterial.js';
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import NodeMaterial
|
|
1
|
+
import NodeMaterial from './NodeMaterial.js';
|
|
2
2
|
|
|
3
|
-
import { PointsMaterial } from '
|
|
3
|
+
import { PointsMaterial } from '../PointsMaterial.js';
|
|
4
4
|
|
|
5
5
|
const _defaultValues = /*@__PURE__*/ new PointsMaterial();
|
|
6
6
|
|
|
7
7
|
class PointsNodeMaterial extends NodeMaterial {
|
|
8
8
|
|
|
9
|
+
static get type() {
|
|
10
|
+
|
|
11
|
+
return 'PointsNodeMaterial';
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
constructor( parameters ) {
|
|
10
16
|
|
|
11
17
|
super();
|
|
@@ -13,7 +19,6 @@ class PointsNodeMaterial extends NodeMaterial {
|
|
|
13
19
|
this.isPointsNodeMaterial = true;
|
|
14
20
|
|
|
15
21
|
this.lights = false;
|
|
16
|
-
this.normals = false;
|
|
17
22
|
this.transparent = true;
|
|
18
23
|
|
|
19
24
|
this.sizeNode = null;
|
|
@@ -35,5 +40,3 @@ class PointsNodeMaterial extends NodeMaterial {
|
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
export default PointsNodeMaterial;
|
|
38
|
-
|
|
39
|
-
addNodeMaterial( 'PointsNodeMaterial', PointsNodeMaterial );
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import NodeMaterial
|
|
2
|
-
import ShadowMaskModel from '
|
|
1
|
+
import NodeMaterial from './NodeMaterial.js';
|
|
2
|
+
import ShadowMaskModel from '../../nodes/functions/ShadowMaskModel.js';
|
|
3
3
|
|
|
4
|
-
import { ShadowMaterial } from '
|
|
4
|
+
import { ShadowMaterial } from '../ShadowMaterial.js';
|
|
5
5
|
|
|
6
6
|
const _defaultValues = /*@__PURE__*/ new ShadowMaterial();
|
|
7
7
|
|
|
8
8
|
class ShadowNodeMaterial extends NodeMaterial {
|
|
9
9
|
|
|
10
|
+
static get type() {
|
|
11
|
+
|
|
12
|
+
return 'ShadowNodeMaterial';
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
constructor( parameters ) {
|
|
11
17
|
|
|
12
18
|
super();
|
|
@@ -30,5 +36,3 @@ class ShadowNodeMaterial extends NodeMaterial {
|
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
export default ShadowNodeMaterial;
|
|
33
|
-
|
|
34
|
-
addNodeMaterial( 'ShadowNodeMaterial', ShadowNodeMaterial );
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import NodeMaterial
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { float, vec2, vec3, vec4 } from '
|
|
1
|
+
import NodeMaterial from './NodeMaterial.js';
|
|
2
|
+
import { cameraProjectionMatrix } from '../../nodes/accessors/Camera.js';
|
|
3
|
+
import { materialRotation } from '../../nodes/accessors/MaterialNode.js';
|
|
4
|
+
import { modelViewMatrix, modelWorldMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
5
|
+
import { positionLocal } from '../../nodes/accessors/Position.js';
|
|
6
|
+
import { rotate } from '../../nodes/utils/RotateNode.js';
|
|
7
|
+
import { float, vec2, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
|
|
8
8
|
|
|
9
|
-
import { SpriteMaterial } from '
|
|
9
|
+
import { SpriteMaterial } from '../SpriteMaterial.js';
|
|
10
|
+
import { reference } from '../../nodes/accessors/ReferenceBaseNode.js';
|
|
10
11
|
|
|
11
12
|
const _defaultValues = /*@__PURE__*/ new SpriteMaterial();
|
|
12
13
|
|
|
13
14
|
class SpriteNodeMaterial extends NodeMaterial {
|
|
14
15
|
|
|
16
|
+
static get type() {
|
|
17
|
+
|
|
18
|
+
return 'SpriteNodeMaterial';
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
15
22
|
constructor( parameters ) {
|
|
16
23
|
|
|
17
24
|
super();
|
|
@@ -19,7 +26,7 @@ class SpriteNodeMaterial extends NodeMaterial {
|
|
|
19
26
|
this.isSpriteNodeMaterial = true;
|
|
20
27
|
|
|
21
28
|
this.lights = false;
|
|
22
|
-
this.
|
|
29
|
+
this._useSizeAttenuation = true;
|
|
23
30
|
|
|
24
31
|
this.positionNode = null;
|
|
25
32
|
this.rotationNode = null;
|
|
@@ -31,7 +38,9 @@ class SpriteNodeMaterial extends NodeMaterial {
|
|
|
31
38
|
|
|
32
39
|
}
|
|
33
40
|
|
|
34
|
-
setupPosition( { object, context } ) {
|
|
41
|
+
setupPosition( { object, camera, context } ) {
|
|
42
|
+
|
|
43
|
+
const sizeAttenuation = this.sizeAttenuation;
|
|
35
44
|
|
|
36
45
|
// < VERTEX STAGE >
|
|
37
46
|
|
|
@@ -49,11 +58,20 @@ class SpriteNodeMaterial extends NodeMaterial {
|
|
|
49
58
|
|
|
50
59
|
}
|
|
51
60
|
|
|
61
|
+
|
|
62
|
+
if ( ! sizeAttenuation && camera.isPerspectiveCamera ) {
|
|
63
|
+
|
|
64
|
+
scale = scale.mul( mvPosition.z.negate() );
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
52
68
|
let alignedPosition = vertex.xy;
|
|
53
69
|
|
|
54
70
|
if ( object.center && object.center.isVector2 === true ) {
|
|
55
71
|
|
|
56
|
-
|
|
72
|
+
const center = reference( 'center', 'vec2' );
|
|
73
|
+
|
|
74
|
+
alignedPosition = alignedPosition.sub( center.sub( 0.5 ) );
|
|
57
75
|
|
|
58
76
|
}
|
|
59
77
|
|
|
@@ -61,7 +79,7 @@ class SpriteNodeMaterial extends NodeMaterial {
|
|
|
61
79
|
|
|
62
80
|
const rotation = float( rotationNode || materialRotation );
|
|
63
81
|
|
|
64
|
-
const rotatedPosition =
|
|
82
|
+
const rotatedPosition = rotate( alignedPosition, rotation );
|
|
65
83
|
|
|
66
84
|
mvPosition = vec4( mvPosition.xy.add( rotatedPosition ), mvPosition.zw );
|
|
67
85
|
|
|
@@ -83,8 +101,23 @@ class SpriteNodeMaterial extends NodeMaterial {
|
|
|
83
101
|
|
|
84
102
|
}
|
|
85
103
|
|
|
104
|
+
get sizeAttenuation() {
|
|
105
|
+
|
|
106
|
+
return this._useSizeAttenuation;
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
set sizeAttenuation( value ) {
|
|
111
|
+
|
|
112
|
+
if ( this._useSizeAttenuation !== value ) {
|
|
113
|
+
|
|
114
|
+
this._useSizeAttenuation = value;
|
|
115
|
+
this.needsUpdate = true;
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
86
121
|
}
|
|
87
122
|
|
|
88
123
|
export default SpriteNodeMaterial;
|
|
89
|
-
|
|
90
|
-
addNodeMaterial( 'SpriteNodeMaterial', SpriteNodeMaterial );
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import NodeMaterial
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { texture3D } from '../accessors/Texture3DNode.js';
|
|
1
|
+
import NodeMaterial from './NodeMaterial.js';
|
|
2
|
+
import { property } from '../../nodes/core/PropertyNode.js';
|
|
3
|
+
import { materialReference } from '../../nodes/accessors/MaterialReferenceNode.js';
|
|
4
|
+
import { modelWorldMatrixInverse } from '../../nodes/accessors/ModelNode.js';
|
|
5
|
+
import { cameraPosition } from '../../nodes/accessors/Camera.js';
|
|
6
|
+
import { positionGeometry } from '../../nodes/accessors/Position.js';
|
|
7
|
+
import { Fn, varying, float, vec2, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
|
|
8
|
+
import { min, max } from '../../nodes/math/MathNode.js';
|
|
9
|
+
import { Loop, Break } from '../../nodes/utils/LoopNode.js';
|
|
10
|
+
import { texture3D } from '../../nodes/accessors/Texture3DNode.js';
|
|
12
11
|
|
|
13
12
|
class VolumeNodeMaterial extends NodeMaterial {
|
|
14
13
|
|
|
14
|
+
static get type() {
|
|
15
|
+
|
|
16
|
+
return 'VolumeNodeMaterial';
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
constructor( params = {} ) {
|
|
16
21
|
|
|
17
22
|
super();
|
|
18
23
|
|
|
19
|
-
this.normals = false;
|
|
20
24
|
this.lights = false;
|
|
21
25
|
this.isVolumeNodeMaterial = true;
|
|
22
26
|
this.testNode = null;
|
|
@@ -29,7 +33,7 @@ class VolumeNodeMaterial extends NodeMaterial {
|
|
|
29
33
|
|
|
30
34
|
const map = texture3D( this.map, null, 0 );
|
|
31
35
|
|
|
32
|
-
const hitBox =
|
|
36
|
+
const hitBox = Fn( ( { orig, dir } ) => {
|
|
33
37
|
|
|
34
38
|
const box_min = vec3( - 0.5 );
|
|
35
39
|
const box_max = vec3( 0.5 );
|
|
@@ -49,27 +53,27 @@ class VolumeNodeMaterial extends NodeMaterial {
|
|
|
49
53
|
|
|
50
54
|
} );
|
|
51
55
|
|
|
52
|
-
this.fragmentNode =
|
|
56
|
+
this.fragmentNode = Fn( () => {
|
|
53
57
|
|
|
54
58
|
const vOrigin = varying( vec3( modelWorldMatrixInverse.mul( vec4( cameraPosition, 1.0 ) ) ) );
|
|
55
59
|
const vDirection = varying( positionGeometry.sub( vOrigin ) );
|
|
56
60
|
|
|
57
61
|
const rayDir = vDirection.normalize();
|
|
58
|
-
const bounds =
|
|
62
|
+
const bounds = vec2( hitBox( { orig: vOrigin, dir: rayDir } ) ).toVar();
|
|
59
63
|
|
|
60
64
|
bounds.x.greaterThan( bounds.y ).discard();
|
|
61
65
|
|
|
62
66
|
bounds.assign( vec2( max( bounds.x, 0.0 ), bounds.y ) );
|
|
63
67
|
|
|
64
|
-
const p =
|
|
65
|
-
const inc =
|
|
66
|
-
const delta =
|
|
68
|
+
const p = vec3( vOrigin.add( bounds.x.mul( rayDir ) ) ).toVar();
|
|
69
|
+
const inc = vec3( rayDir.abs().reciprocal() ).toVar();
|
|
70
|
+
const delta = float( min( inc.x, min( inc.y, inc.z ) ) ).toVar( 'delta' ); // used 'delta' name in loop
|
|
67
71
|
|
|
68
72
|
delta.divAssign( materialReference( 'steps', 'float' ) );
|
|
69
73
|
|
|
70
|
-
const ac =
|
|
74
|
+
const ac = vec4( materialReference( 'base', 'color' ), 0.0 ).toVar();
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
Loop( { type: 'float', start: bounds.x, end: bounds.y, update: '+= delta' }, () => {
|
|
73
77
|
|
|
74
78
|
const d = property( 'float', 'd' ).assign( map.uv( p.add( 0.5 ) ).r );
|
|
75
79
|
|
|
@@ -102,5 +106,3 @@ class VolumeNodeMaterial extends NodeMaterial {
|
|
|
102
106
|
}
|
|
103
107
|
|
|
104
108
|
export default VolumeNodeMaterial;
|
|
105
|
-
|
|
106
|
-
addNodeMaterial( 'VolumeNodeMaterial', VolumeNodeMaterial );
|