@needle-tools/three 0.169.20-experimental.0 → 0.183.2-canary.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/LICENSE +1 -1
- package/README.md +5 -6
- package/build/three.cjs +54184 -56703
- package/build/three.core.js +59506 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +11645 -73000
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +648 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +53912 -51652
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +53888 -51806
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/Addons.js +5 -15
- package/examples/jsm/animation/AnimationClipCreator.js +58 -6
- package/examples/jsm/animation/CCDIKSolver.js +152 -45
- package/examples/jsm/capabilities/WebGL.js +28 -29
- package/examples/jsm/capabilities/WebGPU.js +19 -17
- package/examples/jsm/controls/ArcballControls.js +474 -178
- package/examples/jsm/controls/DragControls.js +100 -58
- package/examples/jsm/controls/FirstPersonControls.js +116 -6
- package/examples/jsm/controls/FlyControls.js +50 -2
- package/examples/jsm/controls/MapControls.js +96 -8
- package/examples/jsm/controls/OrbitControls.js +496 -57
- package/examples/jsm/controls/PointerLockControls.js +115 -22
- package/examples/jsm/controls/TrackballControls.js +166 -14
- package/examples/jsm/controls/TransformControls.js +336 -26
- package/examples/jsm/csm/CSM.js +232 -18
- package/examples/jsm/csm/CSMFrustum.js +61 -4
- package/examples/jsm/csm/CSMHelper.js +50 -0
- package/examples/jsm/csm/CSMShader.js +13 -1
- package/examples/jsm/csm/CSMShadowNode.js +599 -0
- package/examples/jsm/curves/CurveExtras.js +303 -31
- package/examples/jsm/curves/NURBSCurve.js +91 -16
- package/examples/jsm/curves/NURBSSurface.js +52 -6
- package/examples/jsm/curves/NURBSUtils.js +102 -112
- package/examples/jsm/curves/NURBSVolume.js +24 -4
- package/examples/jsm/effects/AnaglyphEffect.js +134 -7
- package/examples/jsm/effects/AsciiEffect.js +69 -22
- package/examples/jsm/effects/OutlineEffect.js +61 -111
- package/examples/jsm/effects/ParallaxBarrierEffect.js +30 -0
- package/examples/jsm/effects/StereoEffect.js +31 -0
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/DebugEnvironment.js +50 -0
- package/examples/jsm/environments/RoomEnvironment.js +83 -42
- package/examples/jsm/exporters/DRACOExporter.js +56 -14
- package/examples/jsm/exporters/EXRExporter.js +40 -9
- package/examples/jsm/exporters/GLTFExporter.js +502 -169
- package/examples/jsm/exporters/OBJExporter.js +21 -1
- package/examples/jsm/exporters/PLYExporter.js +44 -12
- package/examples/jsm/exporters/STLExporter.js +27 -5
- package/examples/jsm/exporters/USDZExporter.js +781 -291
- package/examples/jsm/geometries/BoxLineGeometry.js +23 -0
- package/examples/jsm/geometries/ConvexGeometry.js +19 -0
- package/examples/jsm/geometries/DecalGeometry.js +91 -30
- package/examples/jsm/geometries/ParametricFunctions.js +100 -0
- package/examples/jsm/geometries/ParametricGeometry.js +38 -5
- package/examples/jsm/geometries/RoundedBoxGeometry.js +68 -7
- package/examples/jsm/geometries/TeapotGeometry.js +23 -38
- package/examples/jsm/geometries/TextGeometry.js +48 -29
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeHelper.js +36 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +38 -1
- package/examples/jsm/helpers/OctreeHelper.js +36 -0
- package/examples/jsm/helpers/PositionalAudioHelper.js +60 -0
- package/examples/jsm/helpers/RapierHelper.js +59 -0
- package/examples/jsm/helpers/RectAreaLightHelper.js +36 -3
- package/examples/jsm/helpers/TextureHelper.js +28 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +214 -0
- package/examples/jsm/helpers/VertexNormalsHelper.js +61 -2
- package/examples/jsm/helpers/VertexTangentsHelper.js +47 -2
- package/examples/jsm/helpers/ViewHelper.js +181 -9
- package/examples/jsm/inspector/Inspector.js +487 -0
- package/examples/jsm/inspector/RendererInspector.js +425 -0
- package/examples/jsm/inspector/tabs/Console.js +238 -0
- package/examples/jsm/inspector/tabs/Parameters.js +348 -0
- package/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/examples/jsm/inspector/tabs/Viewer.js +166 -0
- package/examples/jsm/inspector/ui/Graph.js +95 -0
- package/examples/jsm/inspector/ui/Item.js +170 -0
- package/examples/jsm/inspector/ui/List.js +75 -0
- package/examples/jsm/inspector/ui/Profiler.js +1975 -0
- package/examples/jsm/inspector/ui/Style.js +1613 -0
- package/examples/jsm/inspector/ui/Tab.js +233 -0
- package/examples/jsm/inspector/ui/Values.js +439 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +43 -12
- package/examples/jsm/interactive/InteractiveGroup.js +170 -52
- package/examples/jsm/interactive/SelectionBox.js +106 -9
- package/examples/jsm/interactive/SelectionHelper.js +76 -30
- package/examples/jsm/libs/demuxer_mp4.js +109 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +76 -58
- package/examples/jsm/libs/motion-controllers.module.js +1 -1
- package/examples/jsm/lighting/TiledLighting.js +42 -0
- package/examples/jsm/lights/LightProbeGenerator.js +44 -7
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +50 -14
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +16 -0
- package/examples/jsm/lines/Line2.js +41 -4
- package/examples/jsm/lines/LineGeometry.js +80 -2
- package/examples/jsm/lines/LineMaterial.js +105 -5
- package/examples/jsm/lines/LineSegments2.js +54 -4
- package/examples/jsm/lines/LineSegmentsGeometry.js +65 -8
- package/examples/jsm/lines/Wireframe.js +41 -4
- package/examples/jsm/lines/WireframeGeometry2.js +27 -2
- package/examples/jsm/lines/webgpu/Line2.js +28 -2
- package/examples/jsm/lines/webgpu/LineSegments2.js +59 -24
- package/examples/jsm/lines/webgpu/Wireframe.js +86 -0
- package/examples/jsm/loaders/3DMLoader.js +78 -6
- package/examples/jsm/loaders/3MFLoader.js +148 -7
- package/examples/jsm/loaders/AMFLoader.js +34 -14
- package/examples/jsm/loaders/BVHLoader.js +59 -12
- package/examples/jsm/loaders/ColladaLoader.js +61 -4027
- package/examples/jsm/loaders/DDSLoader.js +68 -1
- package/examples/jsm/loaders/DRACOLoader.js +146 -22
- package/examples/jsm/loaders/EXRLoader.js +255 -34
- package/examples/jsm/loaders/FBXLoader.js +80 -42
- package/examples/jsm/loaders/FontLoader.js +83 -6
- package/examples/jsm/loaders/GCodeLoader.js +71 -14
- package/examples/jsm/loaders/GLTFLoader.js +381 -263
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +52 -3
- package/examples/jsm/loaders/HDRLoader.js +485 -0
- package/examples/jsm/loaders/IESLoader.js +42 -0
- package/examples/jsm/loaders/KMZLoader.js +39 -6
- package/examples/jsm/loaders/KTX2Loader.js +124 -48
- package/examples/jsm/loaders/KTXLoader.js +31 -10
- package/examples/jsm/loaders/LDrawLoader.js +192 -145
- package/examples/jsm/loaders/LUT3dlLoader.js +47 -10
- package/examples/jsm/loaders/LUTCubeLoader.js +46 -9
- package/examples/jsm/loaders/LUTImageLoader.js +79 -38
- package/examples/jsm/loaders/LWOLoader.js +54 -59
- package/examples/jsm/loaders/LottieLoader.js +54 -1
- package/examples/jsm/loaders/MD2Loader.js +37 -1
- package/examples/jsm/loaders/MDDLoader.js +57 -12
- package/examples/jsm/loaders/MTLLoader.js +60 -35
- package/examples/jsm/loaders/MaterialXLoader.js +268 -34
- package/examples/jsm/loaders/NRRDLoader.js +40 -8
- package/examples/jsm/loaders/OBJLoader.js +51 -2
- package/examples/jsm/loaders/PCDLoader.js +173 -21
- package/examples/jsm/loaders/PDBLoader.js +41 -2
- package/examples/jsm/loaders/PLYLoader.js +70 -39
- package/examples/jsm/loaders/PVRLoader.js +25 -6
- package/examples/jsm/loaders/RGBELoader.js +6 -438
- package/examples/jsm/loaders/STLLoader.js +48 -38
- package/examples/jsm/loaders/SVGLoader.js +119 -25
- package/examples/jsm/loaders/TDSLoader.js +92 -74
- package/examples/jsm/loaders/TGALoader.js +23 -2
- package/examples/jsm/loaders/TIFFLoader.js +23 -0
- package/examples/jsm/loaders/TTFLoader.js +50 -3
- package/examples/jsm/loaders/USDLoader.js +279 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -858
- package/examples/jsm/loaders/UltraHDRLoader.js +338 -166
- package/examples/jsm/loaders/VOXLoader.js +688 -87
- package/examples/jsm/loaders/VRMLLoader.js +121 -12
- package/examples/jsm/loaders/VTKLoader.js +77 -25
- package/examples/jsm/loaders/XYZLoader.js +36 -0
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/lwo/IFFParser.js +77 -77
- package/examples/jsm/loaders/usd/USDAParser.js +822 -0
- package/examples/jsm/loaders/usd/USDCParser.js +1852 -0
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +183 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +154 -0
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/Capsule.js +91 -14
- package/examples/jsm/math/ColorConverter.js +22 -0
- package/examples/jsm/math/ColorSpaces.js +74 -2
- package/examples/jsm/math/ConvexHull.js +517 -93
- package/examples/jsm/math/ImprovedNoise.js +32 -15
- package/examples/jsm/math/Lut.js +113 -0
- package/examples/jsm/math/MeshSurfaceSampler.js +78 -13
- package/examples/jsm/math/OBB.js +141 -29
- package/examples/jsm/math/Octree.js +283 -7
- package/examples/jsm/math/SimplexNoise.js +68 -42
- package/examples/jsm/misc/ConvexObjectBreaker.js +45 -25
- package/examples/jsm/misc/GPUComputationRenderer.js +96 -20
- package/examples/jsm/misc/Gyroscope.js +12 -0
- package/examples/jsm/misc/MD2Character.js +117 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +175 -11
- package/examples/jsm/misc/MorphAnimMesh.js +44 -0
- package/examples/jsm/misc/MorphBlendMesh.js +103 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +100 -54
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +322 -0
- package/examples/jsm/misc/RollerCoaster.js +57 -0
- package/examples/jsm/misc/TubePainter.js +437 -40
- package/examples/jsm/misc/Volume.js +123 -76
- package/examples/jsm/misc/VolumeSlice.js +95 -49
- package/examples/jsm/modifiers/CurveModifier.js +66 -38
- package/examples/jsm/modifiers/CurveModifierGPU.js +42 -19
- package/examples/jsm/modifiers/EdgeSplitModifier.js +20 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +24 -10
- package/examples/jsm/modifiers/TessellateModifier.js +35 -2
- package/examples/jsm/objects/GroundedSkybox.js +25 -6
- package/examples/jsm/objects/Lensflare.js +94 -2
- package/examples/jsm/objects/LensflareMesh.js +64 -10
- package/examples/jsm/objects/MarchingCubes.js +90 -5
- package/examples/jsm/objects/Reflector.js +76 -2
- package/examples/jsm/objects/ReflectorForSSRPass.js +41 -0
- package/examples/jsm/objects/Refractor.js +62 -0
- package/examples/jsm/objects/ShadowMesh.js +54 -4
- package/examples/jsm/objects/Sky.js +106 -16
- package/examples/jsm/objects/SkyMesh.js +211 -38
- package/examples/jsm/objects/Water.js +49 -8
- package/examples/jsm/objects/Water2.js +49 -7
- package/examples/jsm/objects/Water2Mesh.js +50 -9
- package/examples/jsm/objects/WaterMesh.js +136 -43
- package/examples/jsm/physics/AmmoPhysics.js +60 -7
- package/examples/jsm/physics/JoltPhysics.js +65 -12
- package/examples/jsm/physics/RapierPhysics.js +217 -21
- package/examples/jsm/postprocessing/AfterimagePass.js +110 -29
- package/examples/jsm/postprocessing/BloomPass.js +128 -26
- package/examples/jsm/postprocessing/BokehPass.js +99 -22
- package/examples/jsm/postprocessing/ClearPass.js +54 -3
- package/examples/jsm/postprocessing/CubeTexturePass.js +82 -21
- package/examples/jsm/postprocessing/DotScreenPass.js +59 -10
- package/examples/jsm/postprocessing/EffectComposer.js +140 -6
- package/examples/jsm/postprocessing/FXAAPass.js +40 -0
- package/examples/jsm/postprocessing/FilmPass.js +54 -5
- package/examples/jsm/postprocessing/GTAOPass.js +202 -57
- package/examples/jsm/postprocessing/GlitchPass.js +86 -34
- package/examples/jsm/postprocessing/HalftonePass.js +65 -10
- package/examples/jsm/postprocessing/LUTPass.js +38 -8
- package/examples/jsm/postprocessing/MaskPass.js +91 -0
- package/examples/jsm/postprocessing/OutlinePass.js +272 -135
- package/examples/jsm/postprocessing/OutputPass.js +65 -14
- package/examples/jsm/postprocessing/Pass.js +100 -4
- package/examples/jsm/postprocessing/RenderPass.js +94 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +124 -45
- package/examples/jsm/postprocessing/RenderTransitionPass.js +120 -21
- package/examples/jsm/postprocessing/SAOPass.js +128 -55
- package/examples/jsm/postprocessing/SMAAPass.js +106 -75
- package/examples/jsm/postprocessing/SSAARenderPass.js +118 -35
- package/examples/jsm/postprocessing/SSAOPass.js +173 -60
- package/examples/jsm/postprocessing/SSRPass.js +268 -53
- package/examples/jsm/postprocessing/SavePass.js +69 -16
- package/examples/jsm/postprocessing/ShaderPass.js +65 -7
- package/examples/jsm/postprocessing/TAARenderPass.js +79 -24
- package/examples/jsm/postprocessing/TexturePass.js +72 -8
- package/examples/jsm/postprocessing/UnrealBloomPass.js +168 -59
- package/examples/jsm/renderers/CSS2DRenderer.js +98 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +111 -7
- package/examples/jsm/renderers/Projector.js +288 -32
- package/examples/jsm/renderers/SVGRenderer.js +323 -61
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +3 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +5 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +12 -5
- package/examples/jsm/shaders/AfterimageShader.js +8 -3
- package/examples/jsm/shaders/BasicShader.js +8 -1
- package/examples/jsm/shaders/BleachBypassShader.js +10 -3
- package/examples/jsm/shaders/BlendShader.js +8 -1
- package/examples/jsm/shaders/BokehShader.js +9 -3
- package/examples/jsm/shaders/BokehShader2.js +11 -4
- package/examples/jsm/shaders/BrightnessContrastShader.js +10 -4
- package/examples/jsm/shaders/ColorCorrectionShader.js +8 -1
- package/examples/jsm/shaders/ColorifyShader.js +8 -1
- package/examples/jsm/shaders/ConvolutionShader.js +9 -38
- package/examples/jsm/shaders/CopyShader.js +8 -1
- package/examples/jsm/shaders/DOFMipMapShader.js +10 -3
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +10 -1
- package/examples/jsm/shaders/DigitalGlitch.js +10 -7
- package/examples/jsm/shaders/DotScreenShader.js +8 -3
- package/examples/jsm/shaders/ExposureShader.js +8 -1
- package/examples/jsm/shaders/FXAAShader.js +233 -221
- package/examples/jsm/shaders/FilmShader.js +13 -0
- package/examples/jsm/shaders/FocusShader.js +8 -3
- package/examples/jsm/shaders/FreiChenShader.js +10 -3
- package/examples/jsm/shaders/GTAOShader.js +55 -45
- package/examples/jsm/shaders/GammaCorrectionShader.js +11 -2
- package/examples/jsm/shaders/HalftoneShader.js +24 -4
- package/examples/jsm/shaders/HorizontalBlurShader.js +12 -3
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +9 -2
- package/examples/jsm/shaders/HueSaturationShader.js +10 -3
- package/examples/jsm/shaders/KaleidoShader.js +11 -4
- package/examples/jsm/shaders/LuminosityHighPassShader.js +8 -4
- package/examples/jsm/shaders/LuminosityShader.js +8 -2
- package/examples/jsm/shaders/MirrorShader.js +10 -4
- package/examples/jsm/shaders/NormalMapShader.js +7 -2
- package/examples/jsm/shaders/OutputShader.js +19 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +30 -17
- package/examples/jsm/shaders/RGBShiftShader.js +8 -1
- package/examples/jsm/shaders/SAOShader.js +27 -5
- package/examples/jsm/shaders/SMAAShader.js +24 -1
- package/examples/jsm/shaders/SSAOShader.js +37 -6
- package/examples/jsm/shaders/SSRShader.js +32 -6
- package/examples/jsm/shaders/SepiaShader.js +8 -3
- package/examples/jsm/shaders/SobelOperatorShader.js +9 -3
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +13 -8
- package/examples/jsm/shaders/TechnicolorShader.js +10 -4
- package/examples/jsm/shaders/ToonShader.js +29 -6
- package/examples/jsm/shaders/TriangleBlurShader.js +9 -4
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +19 -6
- package/examples/jsm/shaders/VelocityShader.js +8 -1
- package/examples/jsm/shaders/VerticalBlurShader.js +9 -2
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +8 -1
- package/examples/jsm/shaders/VignetteShader.js +8 -3
- package/examples/jsm/shaders/VolumeShader.js +11 -2
- package/examples/jsm/shaders/WaterRefractionShader.js +11 -0
- package/examples/jsm/textures/FlakesTexture.js +14 -0
- package/examples/jsm/transpiler/AST.js +436 -31
- package/examples/jsm/transpiler/GLSLDecoder.js +380 -135
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +3 -1
- package/examples/jsm/transpiler/TSLEncoder.js +363 -97
- package/examples/jsm/transpiler/Transpiler.js +50 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +839 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +244 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +549 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +282 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +11 -4
- package/examples/jsm/tsl/display/BloomNode.js +534 -0
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +207 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +334 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +554 -0
- package/examples/jsm/tsl/display/DotScreenNode.js +104 -0
- package/examples/jsm/tsl/display/FXAANode.js +365 -0
- package/examples/jsm/tsl/display/FilmNode.js +101 -0
- package/examples/jsm/tsl/display/GTAONode.js +571 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +389 -0
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +279 -0
- package/examples/jsm/tsl/display/Lut3DNode.js +109 -0
- package/examples/jsm/tsl/display/MotionBlur.js +33 -0
- package/examples/jsm/tsl/display/OutlineNode.js +762 -0
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +89 -0
- package/examples/jsm/tsl/display/PixelationPassNode.js +335 -0
- package/examples/jsm/tsl/display/RGBShiftNode.js +96 -0
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +768 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +120 -49
- package/examples/jsm/tsl/display/SSGINode.js +642 -0
- package/examples/jsm/tsl/display/SSRNode.js +656 -0
- package/examples/jsm/tsl/display/SSSNode.js +490 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +9 -2
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +61 -19
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +192 -0
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +48 -12
- package/examples/jsm/tsl/display/TRAANode.js +726 -0
- package/examples/jsm/tsl/display/TransitionNode.js +141 -0
- package/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/display/hashBlur.js +54 -0
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +442 -0
- package/examples/jsm/tsl/math/Bayer.js +73 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +456 -0
- package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +212 -0
- package/examples/jsm/tsl/utils/Raymarching.js +70 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +91 -29
- package/examples/jsm/utils/CameraUtils.js +15 -6
- package/examples/jsm/utils/GeometryCompressionUtils.js +23 -30
- package/examples/jsm/utils/GeometryUtils.js +32 -27
- package/examples/jsm/utils/LDrawUtils.js +14 -5
- package/examples/jsm/utils/SceneOptimizer.js +458 -0
- package/examples/jsm/utils/SceneUtils.js +53 -3
- package/examples/jsm/utils/ShadowMapViewer.js +72 -33
- package/examples/jsm/utils/ShadowMapViewerGPU.js +61 -29
- package/examples/jsm/utils/SkeletonUtils.js +48 -0
- package/examples/jsm/utils/SortUtils.js +17 -5
- package/examples/jsm/utils/UVsDebug.js +12 -4
- package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +16 -0
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +20 -2
- package/examples/jsm/utils/WorkerPool.js +67 -2
- package/examples/jsm/webxr/ARButton.js +19 -0
- package/examples/jsm/webxr/OculusHandModel.js +84 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +148 -22
- package/examples/jsm/webxr/Text2D.js +20 -6
- package/examples/jsm/webxr/VRButton.js +31 -0
- package/examples/jsm/webxr/XRButton.js +23 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +94 -3
- package/examples/jsm/webxr/XREstimatedLight.js +35 -4
- package/examples/jsm/webxr/XRHandMeshModel.js +37 -0
- package/examples/jsm/webxr/XRHandModelFactory.js +96 -6
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +44 -0
- package/examples/jsm/webxr/XRPlanes.js +18 -0
- package/package.json +29 -37
- package/src/Three.Core.js +198 -0
- package/src/Three.Legacy.js +0 -21
- package/src/Three.TSL.js +641 -0
- package/src/Three.WebGPU.Nodes.js +14 -186
- package/src/Three.WebGPU.js +16 -186
- package/src/Three.js +2 -197
- package/src/animation/AnimationAction.js +263 -31
- package/src/animation/AnimationClip.js +162 -7
- package/src/animation/AnimationMixer.js +105 -15
- package/src/animation/AnimationObjectGroup.js +45 -21
- package/src/animation/AnimationUtils.js +163 -24
- package/src/animation/KeyframeTrack.js +191 -17
- package/src/animation/PropertyBinding.js +91 -16
- package/src/animation/PropertyMixer.js +72 -5
- package/src/animation/tracks/BooleanKeyframeTrack.js +33 -6
- package/src/animation/tracks/ColorKeyframeTrack.js +26 -5
- package/src/animation/tracks/NumberKeyframeTrack.js +26 -2
- package/src/animation/tracks/QuaternionKeyframeTrack.js +30 -1
- package/src/animation/tracks/StringKeyframeTrack.js +33 -2
- package/src/animation/tracks/VectorKeyframeTrack.js +26 -2
- package/src/audio/Audio.js +386 -8
- package/src/audio/AudioAnalyser.js +58 -1
- package/src/audio/AudioContext.js +15 -0
- package/src/audio/AudioListener.js +94 -13
- package/src/audio/PositionalAudio.js +107 -0
- package/src/cameras/ArrayCamera.js +37 -0
- package/src/cameras/Camera.js +61 -0
- package/src/cameras/CubeCamera.js +86 -0
- package/src/cameras/OrthographicCamera.js +110 -1
- package/src/cameras/PerspectiveCamera.js +174 -35
- package/src/cameras/StereoCamera.js +48 -2
- package/src/constants.js +1546 -11
- package/src/core/BufferAttribute.js +417 -3
- package/src/core/BufferGeometry.js +407 -22
- package/src/core/Clock.js +69 -8
- package/src/core/EventDispatcher.js +52 -8
- package/src/core/GLBufferAttribute.js +113 -2
- package/src/core/InstancedBufferAttribute.js +29 -0
- package/src/core/InstancedBufferGeometry.js +20 -0
- package/src/core/InstancedInterleavedBuffer.js +26 -0
- package/src/core/InterleavedBuffer.js +141 -7
- package/src/core/InterleavedBufferAttribute.js +200 -2
- package/src/core/Layers.js +71 -10
- package/src/core/Object3D.js +673 -26
- package/src/core/Raycaster.js +136 -2
- package/src/core/RenderTarget.js +256 -27
- package/src/core/RenderTarget3D.js +48 -0
- package/src/core/Timer.js +184 -0
- package/src/core/Uniform.js +29 -0
- package/src/core/UniformsGroup.js +84 -2
- package/src/extras/Controls.js +89 -1
- package/src/extras/DataUtils.js +50 -9
- package/src/extras/Earcut.js +18 -779
- package/src/extras/ImageUtils.js +22 -14
- package/src/extras/PMREMGenerator.js +316 -67
- package/src/extras/ShapeUtils.js +24 -2
- package/src/extras/TextureUtils.js +101 -15
- package/src/extras/core/Curve.js +156 -55
- package/src/extras/core/CurvePath.js +63 -22
- package/src/extras/core/Interpolations.js +34 -2
- package/src/extras/core/Path.js +134 -1
- package/src/extras/core/Shape.js +66 -3
- package/src/extras/core/ShapePath.js +80 -4
- package/src/extras/curves/ArcCurve.js +22 -0
- package/src/extras/curves/CatmullRomCurve3.js +89 -18
- package/src/extras/curves/CubicBezierCurve.js +67 -0
- package/src/extras/curves/CubicBezierCurve3.js +50 -0
- package/src/extras/curves/EllipseCurve.js +102 -0
- package/src/extras/curves/LineCurve.js +36 -0
- package/src/extras/curves/LineCurve3.js +36 -0
- package/src/extras/curves/QuadraticBezierCurve.js +59 -0
- package/src/extras/curves/QuadraticBezierCurve3.js +43 -0
- package/src/extras/curves/SplineCurve.js +48 -0
- package/src/extras/lib/earcut.js +685 -0
- package/src/geometries/BoxGeometry.js +39 -0
- package/src/geometries/CapsuleGeometry.js +196 -11
- package/src/geometries/CircleGeometry.js +41 -0
- package/src/geometries/ConeGeometry.js +39 -0
- package/src/geometries/CylinderGeometry.js +42 -2
- package/src/geometries/DodecahedronGeometry.js +33 -0
- package/src/geometries/EdgesGeometry.js +30 -2
- package/src/geometries/ExtrudeGeometry.js +148 -52
- package/src/geometries/IcosahedronGeometry.js +33 -0
- package/src/geometries/LatheGeometry.js +44 -3
- package/src/geometries/OctahedronGeometry.js +33 -0
- package/src/geometries/PlaneGeometry.js +35 -0
- package/src/geometries/PolyhedronGeometry.js +30 -1
- package/src/geometries/RingGeometry.js +37 -0
- package/src/geometries/ShapeGeometry.js +38 -0
- package/src/geometries/SphereGeometry.js +38 -0
- package/src/geometries/TetrahedronGeometry.js +33 -0
- package/src/geometries/TorusGeometry.js +44 -3
- package/src/geometries/TorusKnotGeometry.js +39 -0
- package/src/geometries/TubeGeometry.js +50 -0
- package/src/geometries/WireframeGeometry.js +32 -0
- package/src/helpers/ArrowHelper.js +62 -5
- package/src/helpers/AxesHelper.js +28 -0
- package/src/helpers/Box3Helper.js +28 -0
- package/src/helpers/BoxHelper.js +43 -7
- package/src/helpers/CameraHelper.js +103 -27
- package/src/helpers/DirectionalLightHelper.js +55 -0
- package/src/helpers/GridHelper.js +26 -0
- package/src/helpers/HemisphereLightHelper.js +42 -0
- package/src/helpers/PlaneHelper.js +33 -0
- package/src/helpers/PointLightHelper.js +43 -24
- package/src/helpers/PolarGridHelper.js +30 -0
- package/src/helpers/SkeletonHelper.js +73 -7
- package/src/helpers/SpotLightHelper.js +43 -0
- package/src/lights/AmbientLight.js +25 -0
- package/src/lights/DirectionalLight.js +70 -0
- package/src/lights/DirectionalLightShadow.js +15 -0
- package/src/lights/HemisphereLight.js +42 -0
- package/src/lights/Light.js +37 -11
- package/src/lights/LightProbe.js +37 -9
- package/src/lights/LightShadow.js +202 -7
- package/src/lights/PointLight.js +74 -0
- package/src/lights/PointLightShadow.js +15 -80
- package/src/lights/RectAreaLight.js +59 -0
- package/src/lights/SpotLight.js +124 -1
- package/src/lights/SpotLightShadow.js +33 -3
- package/src/lights/webgpu/IESSpotLight.js +22 -0
- package/src/lights/webgpu/ProjectorLight.js +46 -0
- package/src/loaders/AnimationLoader.js +34 -2
- package/src/loaders/AudioLoader.js +34 -2
- package/src/loaders/BufferGeometryLoader.js +38 -13
- package/src/loaders/Cache.js +75 -2
- package/src/loaders/CompressedTextureLoader.js +36 -3
- package/src/loaders/CubeTextureLoader.js +45 -0
- package/src/loaders/DataTextureLoader.js +45 -4
- package/src/loaders/FileLoader.js +85 -5
- package/src/loaders/ImageBitmapLoader.js +113 -11
- package/src/loaders/ImageLoader.js +85 -8
- package/src/loaders/Loader.js +150 -0
- package/src/loaders/LoaderUtils.js +18 -36
- package/src/loaders/LoadingManager.js +187 -0
- package/src/loaders/MaterialLoader.js +62 -3
- package/src/loaders/ObjectLoader.js +131 -31
- package/src/loaders/TextureLoader.js +33 -0
- package/src/loaders/nodes/NodeLoader.js +68 -4
- package/src/loaders/nodes/NodeMaterialLoader.js +45 -0
- package/src/loaders/nodes/NodeObjectLoader.js +61 -0
- package/src/materials/LineBasicMaterial.js +74 -1
- package/src/materials/LineDashedMaterial.js +52 -1
- package/src/materials/Material.js +502 -8
- package/src/materials/MeshBasicMaterial.js +168 -2
- package/src/materials/MeshDepthMaterial.js +94 -0
- package/src/materials/MeshDistanceMaterial.js +76 -0
- package/src/materials/MeshLambertMaterial.js +283 -0
- package/src/materials/MeshMatcapMaterial.js +164 -0
- package/src/materials/MeshNormalMaterial.js +114 -0
- package/src/materials/MeshPhongMaterial.js +298 -0
- package/src/materials/MeshPhysicalMaterial.js +296 -4
- package/src/materials/MeshStandardMaterial.js +300 -2
- package/src/materials/MeshToonMaterial.js +219 -0
- package/src/materials/PointsMaterial.js +89 -0
- package/src/materials/RawShaderMaterial.js +25 -0
- package/src/materials/ShaderMaterial.js +234 -6
- package/src/materials/ShadowMaterial.js +54 -0
- package/src/materials/SpriteMaterial.js +82 -0
- package/src/materials/nodes/Line2NodeMaterial.js +158 -53
- package/src/materials/nodes/LineBasicNodeMaterial.js +17 -2
- package/src/materials/nodes/LineDashedNodeMaterial.js +81 -6
- package/src/materials/nodes/MeshBasicNodeMaterial.js +59 -2
- package/src/materials/nodes/MeshLambertNodeMaterial.js +35 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +23 -3
- package/src/materials/nodes/MeshNormalNodeMaterial.js +27 -4
- package/src/materials/nodes/MeshPhongNodeMaterial.js +64 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +276 -3
- package/src/materials/nodes/MeshSSSNodeMaterial.js +98 -10
- package/src/materials/nodes/MeshStandardNodeMaterial.js +83 -4
- package/src/materials/nodes/MeshToonNodeMaterial.js +28 -0
- package/src/materials/nodes/NodeMaterial.js +789 -74
- package/src/materials/nodes/NodeMaterials.js +0 -1
- package/src/materials/nodes/PointsNodeMaterial.js +180 -11
- package/src/materials/nodes/ShadowNodeMaterial.js +38 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +86 -23
- package/src/materials/nodes/VolumeNodeMaterial.js +57 -84
- package/src/materials/nodes/manager/NodeMaterialObserver.js +329 -12
- package/src/math/Box2.js +177 -0
- package/src/math/Box3.js +271 -0
- package/src/math/Color.js +355 -11
- package/src/math/ColorManagement.js +158 -92
- package/src/math/Cylindrical.js +65 -6
- package/src/math/Euler.js +139 -5
- package/src/math/Frustum.js +108 -9
- package/src/math/FrustumArray.js +258 -0
- package/src/math/Interpolant.js +87 -8
- package/src/math/Line3.js +221 -2
- package/src/math/MathUtils.js +408 -20
- package/src/math/Matrix2.js +70 -0
- package/src/math/Matrix3.js +229 -4
- package/src/math/Matrix4.js +489 -94
- package/src/math/Plane.js +164 -2
- package/src/math/Quaternion.js +322 -90
- package/src/math/Ray.js +162 -0
- package/src/math/Sphere.js +175 -0
- package/src/math/Spherical.js +73 -11
- package/src/math/SphericalHarmonics3.js +112 -14
- package/src/math/Triangle.js +206 -2
- package/src/math/Vector2.js +396 -10
- package/src/math/Vector3.js +550 -15
- package/src/math/Vector4.js +415 -9
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/math/interpolants/CubicInterpolant.js +10 -1
- package/src/math/interpolants/DiscreteInterpolant.js +10 -2
- package/src/math/interpolants/LinearInterpolant.js +13 -0
- package/src/math/interpolants/QuaternionLinearInterpolant.js +10 -1
- package/src/nodes/Nodes.js +91 -88
- package/src/nodes/TSL.js +32 -38
- package/src/nodes/accessors/AccessorsUtils.js +37 -9
- package/src/nodes/accessors/Arrays.js +68 -0
- package/src/nodes/accessors/BatchNode.js +49 -14
- package/src/nodes/accessors/Bitangent.js +82 -13
- package/src/nodes/accessors/BufferAttributeNode.js +269 -8
- package/src/nodes/accessors/BufferNode.js +91 -2
- package/src/nodes/accessors/BuiltinNode.js +63 -0
- package/src/nodes/accessors/Camera.js +400 -10
- package/src/nodes/accessors/ClippingNode.js +149 -45
- package/src/nodes/accessors/CubeTextureNode.js +137 -7
- package/src/nodes/accessors/InstanceNode.js +245 -40
- package/src/nodes/accessors/InstancedMeshNode.js +50 -0
- package/src/nodes/accessors/Lights.js +88 -0
- package/src/nodes/accessors/MaterialNode.js +355 -13
- package/src/nodes/accessors/MaterialProperties.js +57 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +52 -14
- package/src/nodes/accessors/ModelNode.js +117 -5
- package/src/nodes/accessors/ModelViewProjectionNode.js +10 -39
- package/src/nodes/accessors/MorphNode.js +73 -26
- package/src/nodes/accessors/Normal.js +174 -19
- package/src/nodes/accessors/Object3DNode.js +146 -12
- package/src/nodes/accessors/PointUVNode.js +25 -0
- package/src/nodes/accessors/Position.js +119 -7
- package/src/nodes/accessors/ReferenceBaseNode.js +190 -4
- package/src/nodes/accessors/ReferenceNode.js +223 -8
- package/src/nodes/accessors/ReflectVector.js +29 -3
- package/src/nodes/accessors/RendererReferenceNode.js +45 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +180 -43
- package/src/nodes/accessors/StorageBufferNode.js +278 -26
- package/src/nodes/accessors/StorageTextureNode.js +205 -12
- package/src/nodes/accessors/Tangent.js +48 -10
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/Texture3DNode.js +104 -11
- package/src/nodes/accessors/TextureBicubic.js +31 -4
- package/src/nodes/accessors/TextureNode.js +564 -52
- package/src/nodes/accessors/TextureSizeNode.js +42 -1
- package/src/nodes/accessors/UV.js +9 -1
- package/src/nodes/accessors/UniformArrayNode.js +226 -34
- package/src/nodes/accessors/UserDataNode.js +46 -2
- package/src/nodes/accessors/VelocityNode.js +93 -3
- package/src/nodes/accessors/VertexColorNode.js +39 -4
- package/src/nodes/code/CodeNode.js +101 -8
- package/src/nodes/code/ExpressionNode.js +29 -2
- package/src/nodes/code/FunctionCallNode.js +98 -10
- package/src/nodes/code/FunctionNode.js +69 -2
- package/src/nodes/core/ArrayNode.js +174 -0
- package/src/nodes/core/AssignNode.js +80 -9
- package/src/nodes/core/AttributeNode.js +47 -4
- package/src/nodes/core/BypassNode.js +47 -3
- package/src/nodes/core/ConstNode.js +32 -0
- package/src/nodes/core/ContextNode.js +220 -14
- package/src/nodes/core/IndexNode.js +72 -7
- package/src/nodes/core/InputNode.js +50 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/IsolateNode.js +133 -0
- package/src/nodes/core/LightingModel.js +65 -5
- package/src/nodes/core/MRTNode.js +113 -2
- package/src/nodes/core/Node.js +595 -36
- package/src/nodes/core/NodeAttribute.js +38 -0
- package/src/nodes/core/NodeBuilder.js +1840 -121
- package/src/nodes/core/NodeCache.js +41 -2
- package/src/nodes/core/NodeCode.js +31 -0
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +153 -24
- package/src/nodes/core/NodeFunction.js +48 -1
- package/src/nodes/core/NodeFunctionInput.js +44 -0
- package/src/nodes/core/NodeParser.js +13 -1
- package/src/nodes/core/NodeUniform.js +53 -1
- package/src/nodes/core/NodeUtils.js +201 -51
- package/src/nodes/core/NodeVar.js +47 -1
- package/src/nodes/core/NodeVarying.js +47 -1
- package/src/nodes/core/OutputStructNode.js +54 -12
- package/src/nodes/core/ParameterNode.js +60 -2
- package/src/nodes/core/PropertyNode.js +286 -7
- package/src/nodes/core/StackNode.js +337 -20
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +134 -0
- package/src/nodes/core/StructType.js +13 -0
- package/src/nodes/core/StructTypeNode.js +126 -6
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/TempNode.js +31 -5
- package/src/nodes/core/UniformGroupNode.js +85 -7
- package/src/nodes/core/UniformNode.js +163 -16
- package/src/nodes/core/VarNode.js +317 -10
- package/src/nodes/core/VaryingNode.js +115 -13
- package/src/nodes/core/constants.js +40 -0
- package/src/nodes/display/BlendModes.js +171 -0
- package/src/nodes/display/BumpMapNode.js +38 -2
- package/src/nodes/display/ColorAdjustment.js +118 -6
- package/src/nodes/display/ColorSpaceFunctions.js +22 -6
- package/src/nodes/display/ColorSpaceNode.js +97 -47
- package/src/nodes/display/FrontFacingNode.js +64 -7
- package/src/nodes/display/NormalMapNode.js +101 -54
- package/src/nodes/display/PassNode.js +690 -33
- package/src/nodes/display/RenderOutputNode.js +94 -4
- package/src/nodes/display/ScreenNode.js +138 -27
- package/src/nodes/display/ToneMappingFunctions.js +62 -10
- package/src/nodes/display/ToneMappingNode.js +88 -8
- package/src/nodes/display/ToonOutlinePassNode.js +84 -4
- package/src/nodes/display/ViewportDepthNode.js +227 -10
- package/src/nodes/display/ViewportDepthTextureNode.js +39 -5
- package/src/nodes/display/ViewportSharedTextureNode.js +35 -1
- package/src/nodes/display/ViewportTextureNode.js +171 -7
- package/src/nodes/fog/Fog.js +97 -0
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +45 -1
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/BasicLightingModel.js +28 -6
- package/src/nodes/functions/PhongLightingModel.js +36 -6
- package/src/nodes/functions/PhysicalLightingModel.js +336 -91
- package/src/nodes/functions/ShadowMaskModel.js +30 -3
- package/src/nodes/functions/ToonLightingModel.js +21 -2
- package/src/nodes/functions/VolumetricLightingModel.js +183 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.js +68 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +10 -4
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +37 -0
- package/src/nodes/geometry/RangeNode.js +97 -8
- package/src/nodes/gpgpu/AtomicFunctionNode.js +198 -23
- package/src/nodes/gpgpu/BarrierNode.js +52 -3
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +135 -6
- package/src/nodes/gpgpu/ComputeNode.js +212 -16
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +143 -9
- package/src/nodes/lighting/AONode.js +18 -0
- package/src/nodes/lighting/AmbientLightNode.js +10 -0
- package/src/nodes/lighting/AnalyticLightNode.js +186 -399
- package/src/nodes/lighting/BasicEnvironmentNode.js +19 -0
- package/src/nodes/lighting/BasicLightMapNode.js +17 -0
- package/src/nodes/lighting/DirectionalLightNode.js +12 -11
- package/src/nodes/lighting/EnvironmentNode.js +59 -19
- package/src/nodes/lighting/HemisphereLightNode.js +33 -2
- package/src/nodes/lighting/IESSpotLightNode.js +13 -1
- package/src/nodes/lighting/IrradianceNode.js +17 -0
- package/src/nodes/lighting/LightProbeNode.js +20 -0
- package/src/nodes/lighting/LightUtils.js +11 -3
- package/src/nodes/lighting/LightingContextNode.js +52 -4
- package/src/nodes/lighting/LightingNode.js +15 -6
- package/src/nodes/lighting/LightsNode.js +238 -35
- package/src/nodes/lighting/PointLightNode.js +60 -25
- package/src/nodes/lighting/PointShadowNode.js +325 -0
- package/src/nodes/lighting/ProjectorLightNode.js +91 -0
- package/src/nodes/lighting/RectAreaLightNode.js +50 -14
- package/src/nodes/lighting/ShadowBaseNode.js +81 -0
- package/src/nodes/lighting/ShadowFilterNode.js +264 -0
- package/src/nodes/lighting/ShadowNode.js +867 -0
- package/src/nodes/lighting/SpotLightNode.js +99 -18
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +166 -2
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +110 -21
- package/src/nodes/math/Hash.js +8 -0
- package/src/nodes/math/MathNode.js +820 -97
- package/src/nodes/math/MathUtils.js +47 -1
- package/src/nodes/math/OperatorNode.js +517 -84
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/TriNoise3D.js +17 -7
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/parsers/GLSLNodeFunction.js +16 -0
- package/src/nodes/parsers/GLSLNodeParser.js +11 -0
- package/src/nodes/pmrem/PMREMNode.js +180 -23
- package/src/nodes/pmrem/PMREMUtils.js +114 -5
- package/src/nodes/procedural/Checker.js +8 -0
- package/src/nodes/shapes/Shapes.js +33 -0
- package/src/nodes/tsl/TSLBase.js +10 -4
- package/src/nodes/tsl/TSLCore.js +732 -160
- package/src/nodes/utils/ArrayElementNode.js +55 -4
- package/src/nodes/utils/ConvertNode.js +31 -0
- package/src/nodes/utils/CubeMapNode.js +79 -2
- package/src/nodes/utils/DebugNode.js +83 -0
- package/src/nodes/utils/Discard.js +18 -2
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +118 -0
- package/src/nodes/utils/FlipNode.js +38 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +91 -22
- package/src/nodes/utils/JoinNode.js +57 -4
- package/src/nodes/utils/LoopNode.js +193 -55
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/MaxMipLevelNode.js +49 -1
- package/src/nodes/utils/MemberNode.js +120 -0
- package/src/nodes/utils/Oscillators.js +41 -0
- package/src/nodes/utils/Packing.js +30 -1
- package/src/nodes/utils/PostProcessingUtils.js +154 -0
- package/src/nodes/utils/RTTNode.js +165 -9
- package/src/nodes/utils/ReflectorNode.js +407 -21
- package/src/nodes/utils/RemapNode.js +81 -2
- package/src/nodes/utils/RotateNode.js +41 -1
- package/src/nodes/utils/SampleNode.js +91 -0
- package/src/nodes/utils/SetNode.js +44 -1
- package/src/nodes/utils/SplitNode.js +66 -3
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/SpriteUtils.js +16 -0
- package/src/nodes/utils/StorageArrayElementNode.js +56 -3
- package/src/nodes/utils/Timer.js +26 -0
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/nodes/utils/UVUtils.js +48 -0
- package/src/nodes/utils/ViewportUtils.js +12 -0
- package/src/objects/BatchedMesh.js +798 -309
- package/src/objects/Bone.js +24 -0
- package/src/objects/ClippingGroup.js +68 -0
- package/src/objects/Group.js +24 -0
- package/src/objects/InstancedMesh.js +131 -2
- package/src/objects/LOD.js +99 -5
- package/src/objects/Line.js +90 -7
- package/src/objects/LineLoop.js +20 -0
- package/src/objects/LineSegments.js +20 -1
- package/src/objects/Mesh.js +84 -0
- package/src/objects/Points.js +60 -0
- package/src/objects/Skeleton.js +120 -5
- package/src/objects/SkinnedMesh.js +102 -6
- package/src/objects/Sprite.js +65 -1
- package/src/renderers/WebGL3DRenderTarget.js +26 -0
- package/src/renderers/WebGLArrayRenderTarget.js +26 -0
- package/src/renderers/WebGLCubeRenderTarget.js +41 -5
- package/src/renderers/WebGLRenderTarget.js +19 -0
- package/src/renderers/WebGLRenderer.js +1016 -278
- package/src/renderers/common/Animation.js +123 -14
- package/src/renderers/common/Attributes.js +41 -1
- package/src/renderers/common/Backend.js +623 -44
- package/src/renderers/common/Background.js +99 -16
- package/src/renderers/common/BindGroup.js +37 -2
- package/src/renderers/common/Binding.js +46 -0
- package/src/renderers/common/Bindings.js +211 -20
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +89 -0
- package/src/renderers/common/BufferUtils.js +25 -0
- package/src/renderers/common/BundleGroup.js +57 -0
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/ChainMap.js +73 -10
- package/src/renderers/common/ClippingContext.js +172 -87
- package/src/renderers/common/Color4.js +40 -0
- package/src/renderers/common/ComputePipeline.js +24 -0
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/CubeRenderTarget.js +77 -7
- package/src/renderers/common/DataMap.js +37 -1
- package/src/renderers/common/Geometries.js +163 -14
- package/src/renderers/common/IndirectStorageBufferAttribute.js +38 -0
- package/src/renderers/common/Info.js +81 -36
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/Lighting.js +57 -0
- package/src/renderers/common/Pipeline.js +22 -0
- package/src/renderers/common/Pipelines.js +150 -7
- package/src/renderers/common/PostProcessing.js +22 -84
- package/src/renderers/common/ProgrammableStage.js +60 -2
- package/src/renderers/common/QuadMesh.js +63 -6
- package/src/renderers/common/RenderBundle.js +14 -8
- package/src/renderers/common/RenderBundles.js +40 -10
- package/src/renderers/common/RenderContext.js +219 -4
- package/src/renderers/common/RenderContexts.js +54 -17
- package/src/renderers/common/RenderList.js +233 -24
- package/src/renderers/common/RenderLists.js +46 -6
- package/src/renderers/common/RenderObject.js +548 -46
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +133 -15
- package/src/renderers/common/RenderPipeline.js +216 -6
- package/src/renderers/common/Renderer.js +2155 -332
- package/src/renderers/common/RendererUtils.js +200 -0
- package/src/renderers/common/SampledTexture.js +99 -39
- package/src/renderers/common/Sampler.js +148 -1
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageBuffer.js +38 -2
- package/src/renderers/common/StorageBufferAttribute.js +31 -2
- package/src/renderers/common/StorageInstancedBufferAttribute.js +31 -2
- package/src/renderers/common/StorageTexture.js +65 -0
- package/src/renderers/common/Textures.js +273 -57
- package/src/renderers/common/TimestampQueryPool.js +163 -0
- package/src/renderers/common/Uniform.js +233 -3
- package/src/renderers/common/UniformBuffer.js +19 -0
- package/src/renderers/common/UniformsGroup.js +235 -26
- package/src/renderers/common/XRManager.js +1677 -0
- package/src/renderers/common/XRRenderTarget.js +91 -0
- package/src/renderers/common/extras/PMREMGenerator.js +371 -108
- package/src/renderers/common/nodes/NodeBuilderState.js +100 -6
- package/src/renderers/common/nodes/NodeLibrary.js +95 -17
- package/src/renderers/common/nodes/NodeManager.js +852 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +84 -8
- package/src/renderers/common/nodes/NodeSampler.js +41 -1
- package/src/renderers/common/nodes/NodeStorageBuffer.js +48 -3
- package/src/renderers/common/nodes/NodeUniform.js +285 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +81 -0
- package/src/renderers/common/nodes/NodeUniformsGroup.js +31 -18
- package/src/renderers/shaders/DFGLUTData.js +49 -0
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +154 -59
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +230 -181
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +14 -2
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +7 -5
- package/src/renderers/shaders/UniformsLib.js +2 -7
- package/src/renderers/shaders/UniformsUtils.js +21 -2
- package/src/renderers/webgl/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLBackground.js +30 -5
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +7 -14
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLGeometries.js +10 -35
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +87 -148
- package/src/renderers/webgl/WebGLPrograms.js +53 -51
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +204 -28
- package/src/renderers/webgl/WebGLState.js +88 -56
- package/src/renderers/webgl/WebGLTextures.js +293 -59
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl/WebGLUtils.js +7 -5
- package/src/renderers/webgl-fallback/WebGLBackend.js +1416 -293
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +5 -10
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +785 -92
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +62 -1
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +3 -3
- package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +584 -20
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +468 -80
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +396 -0
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +72 -24
- package/src/renderers/webgpu/WebGPUBackend.js +1517 -428
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +31 -4
- package/src/renderers/webgpu/WebGPURenderer.js +55 -4
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +23 -16
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +37 -42
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +1335 -241
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +32 -4
- package/src/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +144 -20
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +460 -116
- package/src/renderers/webgpu/utils/WebGPUConstants.js +17 -4
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +283 -69
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +225 -178
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +583 -191
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +310 -0
- package/src/renderers/webgpu/utils/WebGPUUtils.js +150 -28
- package/src/renderers/webxr/WebXRController.js +87 -2
- package/src/renderers/webxr/WebXRDepthSensing.js +52 -7
- package/src/renderers/webxr/WebXRManager.js +275 -15
- package/src/scenes/Fog.js +60 -0
- package/src/scenes/FogExp2.js +51 -0
- package/src/scenes/Scene.js +88 -0
- package/src/textures/CanvasTexture.js +28 -0
- package/src/textures/CompressedArrayTexture.js +57 -0
- package/src/textures/CompressedCubeTexture.js +29 -0
- package/src/textures/CompressedTexture.js +64 -6
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/CubeTexture.js +52 -4
- package/src/textures/Data3DTexture.js +79 -2
- package/src/textures/DataArrayTexture.js +93 -0
- package/src/textures/DataTexture.js +65 -0
- package/src/textures/DepthTexture.js +59 -11
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +62 -0
- package/src/textures/Source.js +106 -4
- package/src/textures/Texture.js +488 -6
- package/src/textures/VideoFrameTexture.js +72 -0
- package/src/textures/VideoTexture.js +78 -6
- package/src/utils.js +322 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +0 -1207
- package/examples/jsm/animation/MMDPhysics.js +0 -1406
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/examples/jsm/effects/PeppersGhostEffect.js +0 -153
- package/examples/jsm/exporters/MMDExporter.js +0 -217
- package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -174
- package/examples/jsm/geometries/ParametricGeometries.js +0 -254
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/loaders/GLTFLoaderAnimationPointer.js +0 -729
- package/examples/jsm/loaders/MMDLoader.js +0 -2295
- package/examples/jsm/loaders/RGBMLoader.js +0 -1081
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -432
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -144
- package/examples/jsm/misc/Timer.js +0 -128
- package/examples/jsm/objects/InstancedPoints.js +0 -21
- package/examples/jsm/shaders/GodRaysShader.js +0 -321
- package/examples/jsm/shaders/MMDToonShader.js +0 -134
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -156
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -24
- package/src/nodes/accessors/SceneNode.js +0 -55
- package/src/nodes/code/ScriptableNode.js +0 -505
- package/src/nodes/code/ScriptableValueNode.js +0 -170
- package/src/nodes/core/CacheNode.js +0 -50
- package/src/nodes/core/UniformGroup.js +0 -13
- package/src/nodes/display/AfterImageNode.js +0 -158
- package/src/nodes/display/AnaglyphPassNode.js +0 -67
- package/src/nodes/display/AnamorphicNode.js +0 -151
- package/src/nodes/display/BlendMode.js +0 -54
- package/src/nodes/display/BloomNode.js +0 -341
- package/src/nodes/display/DenoiseNode.js +0 -204
- package/src/nodes/display/DepthOfFieldNode.js +0 -124
- package/src/nodes/display/DotScreenNode.js +0 -66
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/display/FilmNode.js +0 -56
- package/src/nodes/display/GTAONode.js +0 -331
- package/src/nodes/display/GaussianBlurNode.js +0 -213
- package/src/nodes/display/Lut3DNode.js +0 -57
- package/src/nodes/display/MotionBlur.js +0 -25
- package/src/nodes/display/ParallaxBarrierPassNode.js +0 -58
- package/src/nodes/display/PixelationPassNode.js +0 -213
- package/src/nodes/display/PosterizeNode.js +0 -33
- package/src/nodes/display/RGBShiftNode.js +0 -53
- package/src/nodes/display/StereoCompositePassNode.js +0 -110
- package/src/nodes/display/TransitionNode.js +0 -80
- package/src/nodes/fog/FogExp2Node.js +0 -35
- package/src/nodes/fog/FogNode.js +0 -50
- package/src/nodes/fog/FogRangeNode.js +0 -36
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -30
- package/src/nodes/utils/EquirectUVNode.js +0 -36
- package/src/nodes/utils/MatcapUVNode.js +0 -33
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -45
- package/src/nodes/utils/TimerNode.js +0 -97
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -64
- package/src/renderers/common/nodes/Nodes.js +0 -534
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -136
|
@@ -1,29 +1,37 @@
|
|
|
1
1
|
import { Material } from '../Material.js';
|
|
2
|
-
import { NormalBlending } from '../../constants.js';
|
|
3
2
|
|
|
4
|
-
import {
|
|
5
|
-
import { attribute } from '../../nodes/core/AttributeNode.js';
|
|
3
|
+
import { hashArray, hashString } from '../../nodes/core/NodeUtils.js';
|
|
6
4
|
import { output, diffuseColor, emissive, varyingProperty } from '../../nodes/core/PropertyNode.js';
|
|
7
|
-
import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal, materialLightMap,
|
|
5
|
+
import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal, materialLightMap, materialAO } from '../../nodes/accessors/MaterialNode.js';
|
|
8
6
|
import { modelViewProjection } from '../../nodes/accessors/ModelViewProjectionNode.js';
|
|
9
7
|
import { normalLocal } from '../../nodes/accessors/Normal.js';
|
|
10
|
-
import {
|
|
8
|
+
import { instancedMesh } from '../../nodes/accessors/InstancedMeshNode.js';
|
|
11
9
|
import { batch } from '../../nodes/accessors/BatchNode.js';
|
|
12
10
|
import { materialReference } from '../../nodes/accessors/MaterialReferenceNode.js';
|
|
13
|
-
import { positionLocal } from '../../nodes/accessors/Position.js';
|
|
14
|
-
import {
|
|
11
|
+
import { positionLocal, positionView } from '../../nodes/accessors/Position.js';
|
|
12
|
+
import { skinning } from '../../nodes/accessors/SkinningNode.js';
|
|
15
13
|
import { morphReference } from '../../nodes/accessors/MorphNode.js';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { float, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
|
|
14
|
+
import { fwidth, mix, smoothstep } from '../../nodes/math/MathNode.js';
|
|
15
|
+
import { float, vec3, vec4, bool } from '../../nodes/tsl/TSLBase.js';
|
|
19
16
|
import AONode from '../../nodes/lighting/AONode.js';
|
|
20
17
|
import { lightingContext } from '../../nodes/lighting/LightingContextNode.js';
|
|
21
18
|
import IrradianceNode from '../../nodes/lighting/IrradianceNode.js';
|
|
22
|
-
import { depth } from '../../nodes/display/ViewportDepthNode.js';
|
|
23
|
-
import {
|
|
24
|
-
import { clipping, clippingAlpha } from '../../nodes/accessors/ClippingNode.js';
|
|
19
|
+
import { depth, viewZToLogarithmicDepth, viewZToOrthographicDepth } from '../../nodes/display/ViewportDepthNode.js';
|
|
20
|
+
import { cameraFar, cameraNear, cameraProjectionMatrix } from '../../nodes/accessors/Camera.js';
|
|
21
|
+
import { clipping, clippingAlpha, hardwareClipping } from '../../nodes/accessors/ClippingNode.js';
|
|
25
22
|
import NodeMaterialObserver from './manager/NodeMaterialObserver.js';
|
|
26
|
-
|
|
23
|
+
import getAlphaHashThreshold from '../../nodes/functions/material/getAlphaHashThreshold.js';
|
|
24
|
+
import { modelViewMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
25
|
+
import { vertexColor } from '../../nodes/accessors/VertexColorNode.js';
|
|
26
|
+
import { premultiplyAlpha } from '../../nodes/display/BlendModes.js';
|
|
27
|
+
import { subBuild } from '../../nodes/core/SubBuildNode.js';
|
|
28
|
+
import { error } from '../../utils.js';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Base class for all node materials.
|
|
32
|
+
*
|
|
33
|
+
* @augments Material
|
|
34
|
+
*/
|
|
27
35
|
class NodeMaterial extends Material {
|
|
28
36
|
|
|
29
37
|
static get type() {
|
|
@@ -32,71 +40,496 @@ class NodeMaterial extends Material {
|
|
|
32
40
|
|
|
33
41
|
}
|
|
34
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Represents the type of the node material.
|
|
45
|
+
*
|
|
46
|
+
* @type {string}
|
|
47
|
+
*/
|
|
48
|
+
get type() {
|
|
49
|
+
|
|
50
|
+
return this.constructor.type;
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
set type( _value ) { /* */ }
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Constructs a new node material.
|
|
58
|
+
*/
|
|
35
59
|
constructor() {
|
|
36
60
|
|
|
37
61
|
super();
|
|
38
62
|
|
|
63
|
+
/**
|
|
64
|
+
* This flag can be used for type testing.
|
|
65
|
+
*
|
|
66
|
+
* @type {boolean}
|
|
67
|
+
* @readonly
|
|
68
|
+
* @default true
|
|
69
|
+
*/
|
|
39
70
|
this.isNodeMaterial = true;
|
|
40
71
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Whether this material is affected by fog or not.
|
|
74
|
+
*
|
|
75
|
+
* @type {boolean}
|
|
76
|
+
* @default true
|
|
77
|
+
*/
|
|
45
78
|
this.fog = true;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Whether this material is affected by lights or not.
|
|
82
|
+
*
|
|
83
|
+
* @type {boolean}
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
46
86
|
this.lights = false;
|
|
47
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Whether this material uses hardware clipping or not.
|
|
90
|
+
* This property is managed by the engine and should not be
|
|
91
|
+
* modified by apps.
|
|
92
|
+
*
|
|
93
|
+
* @type {boolean}
|
|
94
|
+
* @default false
|
|
95
|
+
*/
|
|
96
|
+
this.hardwareClipping = false;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Node materials which set their `lights` property to `true`
|
|
100
|
+
* are affected by all lights of the scene. Sometimes selective
|
|
101
|
+
* lighting is wanted which means only _some_ lights in the scene
|
|
102
|
+
* affect a material. This can be achieved by creating an instance
|
|
103
|
+
* of {@link LightsNode} with a list of selective
|
|
104
|
+
* lights and assign the node to this property.
|
|
105
|
+
*
|
|
106
|
+
* ```js
|
|
107
|
+
* const customLightsNode = lights( [ light1, light2 ] );
|
|
108
|
+
* material.lightsNode = customLightsNode;
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* @type {?LightsNode}
|
|
112
|
+
* @default null
|
|
113
|
+
*/
|
|
48
114
|
this.lightsNode = null;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The environment of node materials can be defined by an environment
|
|
118
|
+
* map assigned to the `envMap` property or by `Scene.environment`
|
|
119
|
+
* if the node material is a PBR material. This node property allows to overwrite
|
|
120
|
+
* the default behavior and define the environment with a custom node.
|
|
121
|
+
*
|
|
122
|
+
* ```js
|
|
123
|
+
* material.envNode = pmremTexture( renderTarget.texture );
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @type {?Node<vec3>}
|
|
127
|
+
* @default null
|
|
128
|
+
*/
|
|
49
129
|
this.envNode = null;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The lighting of node materials might be influenced by ambient occlusion.
|
|
133
|
+
* The default AO is inferred from an ambient occlusion map assigned to `aoMap`
|
|
134
|
+
* and the respective `aoMapIntensity`. This node property allows to overwrite
|
|
135
|
+
* the default and define the ambient occlusion with a custom node instead.
|
|
136
|
+
*
|
|
137
|
+
* If you don't want to overwrite the diffuse color but modify the existing
|
|
138
|
+
* values instead, use {@link materialAO}.
|
|
139
|
+
*
|
|
140
|
+
* @type {?Node<float>}
|
|
141
|
+
* @default null
|
|
142
|
+
*/
|
|
50
143
|
this.aoNode = null;
|
|
51
144
|
|
|
145
|
+
/**
|
|
146
|
+
* The diffuse color of node materials is by default inferred from the
|
|
147
|
+
* `color` and `map` properties. This node property allows to overwrite the default
|
|
148
|
+
* and define the diffuse color with a node instead.
|
|
149
|
+
*
|
|
150
|
+
* ```js
|
|
151
|
+
* material.colorNode = color( 0xff0000 ); // define red color
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* If you don't want to overwrite the diffuse color but modify the existing
|
|
155
|
+
* values instead, use {@link materialColor}.
|
|
156
|
+
*
|
|
157
|
+
* ```js
|
|
158
|
+
* material.colorNode = materialColor.mul( color( 0xff0000 ) ); // give diffuse colors a red tint
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @type {?Node<vec3>}
|
|
162
|
+
* @default null
|
|
163
|
+
*/
|
|
52
164
|
this.colorNode = null;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The normals of node materials are by default inferred from the `normalMap`/`normalScale`
|
|
168
|
+
* or `bumpMap`/`bumpScale` properties. This node property allows to overwrite the default
|
|
169
|
+
* and define the normals with a node instead.
|
|
170
|
+
*
|
|
171
|
+
* If you don't want to overwrite the normals but modify the existing values instead,
|
|
172
|
+
* use {@link materialNormal}.
|
|
173
|
+
*
|
|
174
|
+
* @type {?Node<vec3>}
|
|
175
|
+
* @default null
|
|
176
|
+
*/
|
|
53
177
|
this.normalNode = null;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* The opacity of node materials is by default inferred from the `opacity`
|
|
181
|
+
* and `alphaMap` properties. This node property allows to overwrite the default
|
|
182
|
+
* and define the opacity with a node instead.
|
|
183
|
+
*
|
|
184
|
+
* If you don't want to overwrite the opacity but modify the existing
|
|
185
|
+
* value instead, use {@link materialOpacity}.
|
|
186
|
+
*
|
|
187
|
+
* @type {?Node<float>}
|
|
188
|
+
* @default null
|
|
189
|
+
*/
|
|
54
190
|
this.opacityNode = null;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* This node can be used to implement a variety of filter-like effects. The idea is
|
|
194
|
+
* to store the current rendering into a texture e.g. via `viewportSharedTexture()`, use it
|
|
195
|
+
* to create an arbitrary effect and then assign the node composition to this property.
|
|
196
|
+
* Everything behind the object using this material will now be affected by a filter.
|
|
197
|
+
*
|
|
198
|
+
* ```js
|
|
199
|
+
* const material = new NodeMaterial()
|
|
200
|
+
* material.transparent = true;
|
|
201
|
+
*
|
|
202
|
+
* // everything behind the object will be monochromatic
|
|
203
|
+
* material.backdropNode = saturation( viewportSharedTexture().rgb, 0 );
|
|
204
|
+
* ```
|
|
205
|
+
*
|
|
206
|
+
* Backdrop computations are part of the lighting so only lit materials can use this property.
|
|
207
|
+
*
|
|
208
|
+
* @type {?Node<vec3>}
|
|
209
|
+
* @default null
|
|
210
|
+
*/
|
|
55
211
|
this.backdropNode = null;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* This node allows to modulate the influence of `backdropNode` to the outgoing light.
|
|
215
|
+
*
|
|
216
|
+
* @type {?Node<float>}
|
|
217
|
+
* @default null
|
|
218
|
+
*/
|
|
56
219
|
this.backdropAlphaNode = null;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The alpha test of node materials is by default inferred from the `alphaTest`
|
|
223
|
+
* property. This node property allows to overwrite the default and define the
|
|
224
|
+
* alpha test with a node instead.
|
|
225
|
+
*
|
|
226
|
+
* If you don't want to overwrite the alpha test but modify the existing
|
|
227
|
+
* value instead, use {@link materialAlphaTest}.
|
|
228
|
+
*
|
|
229
|
+
* @type {?Node<float>}
|
|
230
|
+
* @default null
|
|
231
|
+
*/
|
|
57
232
|
this.alphaTestNode = null;
|
|
58
233
|
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Discards the fragment if the mask value is `false`.
|
|
237
|
+
*
|
|
238
|
+
* @type {?Node<bool>}
|
|
239
|
+
* @default null
|
|
240
|
+
*/
|
|
241
|
+
this.maskNode = null;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* This node can be used to implement a shadow mask for the material.
|
|
245
|
+
*
|
|
246
|
+
* @type {?Node<bool>}
|
|
247
|
+
* @default null
|
|
248
|
+
*/
|
|
249
|
+
this.maskShadowNode = null;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* The local vertex positions are computed based on multiple factors like the
|
|
253
|
+
* attribute data, morphing or skinning. This node property allows to overwrite
|
|
254
|
+
* the default and define local vertex positions with nodes instead.
|
|
255
|
+
*
|
|
256
|
+
* If you don't want to overwrite the vertex positions but modify the existing
|
|
257
|
+
* values instead, use {@link positionLocal}.
|
|
258
|
+
*
|
|
259
|
+
*```js
|
|
260
|
+
* material.positionNode = positionLocal.add( displace );
|
|
261
|
+
* ```
|
|
262
|
+
*
|
|
263
|
+
* @type {?Node<vec3>}
|
|
264
|
+
* @default null
|
|
265
|
+
*/
|
|
59
266
|
this.positionNode = null;
|
|
60
267
|
|
|
268
|
+
/**
|
|
269
|
+
* This node property is intended for logic which modifies geometry data once or per animation step.
|
|
270
|
+
* Apps usually place such logic randomly in initialization routines or in the animation loop.
|
|
271
|
+
* `geometryNode` is intended as a dedicated API so there is an intended spot where geometry modifications
|
|
272
|
+
* can be implemented.
|
|
273
|
+
*
|
|
274
|
+
* The idea is to assign a `Fn` definition that holds the geometry modification logic. A typical example
|
|
275
|
+
* would be a GPU based particle system that provides a node material for usage on app level. The particle
|
|
276
|
+
* simulation would be implemented as compute shaders and managed inside a `Fn` function. This function is
|
|
277
|
+
* eventually assigned to `geometryNode`.
|
|
278
|
+
*
|
|
279
|
+
* @type {?Function}
|
|
280
|
+
* @default null
|
|
281
|
+
*/
|
|
282
|
+
this.geometryNode = null;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Allows to overwrite depth values in the fragment shader.
|
|
286
|
+
*
|
|
287
|
+
* @type {?Node<float>}
|
|
288
|
+
* @default null
|
|
289
|
+
*/
|
|
61
290
|
this.depthNode = null;
|
|
62
|
-
this.shadowNode = null;
|
|
63
|
-
this.shadowPositionNode = null;
|
|
64
291
|
|
|
292
|
+
/**
|
|
293
|
+
* Allows to overwrite the position used for shadow map rendering which
|
|
294
|
+
* is by default {@link positionWorld}, the vertex position
|
|
295
|
+
* in world space.
|
|
296
|
+
*
|
|
297
|
+
* @type {?Node<float>}
|
|
298
|
+
* @default null
|
|
299
|
+
*/
|
|
300
|
+
this.receivedShadowPositionNode = null;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Allows to overwrite the geometry position used for shadow map projection which
|
|
304
|
+
* is by default {@link positionLocal}, the vertex position in local space.
|
|
305
|
+
*
|
|
306
|
+
* @type {?Node<float>}
|
|
307
|
+
* @default null
|
|
308
|
+
*/
|
|
309
|
+
this.castShadowPositionNode = null;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* This node can be used to influence how an object using this node material
|
|
313
|
+
* receive shadows.
|
|
314
|
+
*
|
|
315
|
+
* ```js
|
|
316
|
+
* const totalShadows = float( 1 ).toVar();
|
|
317
|
+
* material.receivedShadowNode = Fn( ( [ shadow ] ) => {
|
|
318
|
+
* totalShadows.mulAssign( shadow );
|
|
319
|
+
* //return float( 1 ); // bypass received shadows
|
|
320
|
+
* return shadow.mix( color( 0xff0000 ), 1 ); // modify shadow color
|
|
321
|
+
* } );
|
|
322
|
+
*
|
|
323
|
+
* @type {?(Function|FunctionNode<vec4>)}
|
|
324
|
+
* @default null
|
|
325
|
+
*/
|
|
326
|
+
this.receivedShadowNode = null;
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* This node can be used to influence how an object using this node material
|
|
330
|
+
* casts shadows. To apply a color to shadows, you can simply do:
|
|
331
|
+
*
|
|
332
|
+
* ```js
|
|
333
|
+
* material.castShadowNode = vec4( 1, 0, 0, 1 );
|
|
334
|
+
* ```
|
|
335
|
+
*
|
|
336
|
+
* Which can be nice to fake colored shadows of semi-transparent objects. It
|
|
337
|
+
* is also common to use the property with `Fn` function so checks are performed
|
|
338
|
+
* per fragment.
|
|
339
|
+
*
|
|
340
|
+
* ```js
|
|
341
|
+
* materialCustomShadow.castShadowNode = Fn( () => {
|
|
342
|
+
* hash( vertexIndex ).greaterThan( 0.5 ).discard();
|
|
343
|
+
* return materialColor;
|
|
344
|
+
* } )();
|
|
345
|
+
* ```
|
|
346
|
+
*
|
|
347
|
+
* @type {?Node<vec4>}
|
|
348
|
+
* @default null
|
|
349
|
+
*/
|
|
350
|
+
this.castShadowNode = null;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* This node can be used to define the final output of the material.
|
|
354
|
+
*
|
|
355
|
+
* TODO: Explain the differences to `fragmentNode`.
|
|
356
|
+
*
|
|
357
|
+
* @type {?Node<vec4>}
|
|
358
|
+
* @default null
|
|
359
|
+
*/
|
|
65
360
|
this.outputNode = null;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* MRT configuration is done on renderer or pass level. This node allows to
|
|
364
|
+
* overwrite what values are written into MRT targets on material level. This
|
|
365
|
+
* can be useful for implementing selective FX features that should only affect
|
|
366
|
+
* specific objects.
|
|
367
|
+
*
|
|
368
|
+
* @type {?MRTNode}
|
|
369
|
+
* @default null
|
|
370
|
+
*/
|
|
66
371
|
this.mrtNode = null;
|
|
67
372
|
|
|
373
|
+
/**
|
|
374
|
+
* This node property can be used if you need complete freedom in implementing
|
|
375
|
+
* the fragment shader. Assigning a node will replace the built-in material
|
|
376
|
+
* logic used in the fragment stage.
|
|
377
|
+
*
|
|
378
|
+
* @type {?Node<vec4>}
|
|
379
|
+
* @default null
|
|
380
|
+
*/
|
|
68
381
|
this.fragmentNode = null;
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* This node property can be used if you need complete freedom in implementing
|
|
385
|
+
* the vertex shader. Assigning a node will replace the built-in material logic
|
|
386
|
+
* used in the vertex stage.
|
|
387
|
+
*
|
|
388
|
+
* @type {?Node<vec4>}
|
|
389
|
+
* @default null
|
|
390
|
+
*/
|
|
69
391
|
this.vertexNode = null;
|
|
70
392
|
|
|
393
|
+
/**
|
|
394
|
+
* This node can be used as a global context management component for this material.
|
|
395
|
+
*
|
|
396
|
+
* @type {?ContextNode}
|
|
397
|
+
* @default null
|
|
398
|
+
*/
|
|
399
|
+
this.contextNode = null;
|
|
400
|
+
|
|
71
401
|
}
|
|
72
402
|
|
|
403
|
+
/**
|
|
404
|
+
* Returns an array of child nodes for this material.
|
|
405
|
+
*
|
|
406
|
+
* @private
|
|
407
|
+
* @returns {Array<{property: string, childNode: Node}>}
|
|
408
|
+
*/
|
|
409
|
+
_getNodeChildren() {
|
|
410
|
+
|
|
411
|
+
const children = [];
|
|
412
|
+
|
|
413
|
+
for ( const property of Object.getOwnPropertyNames( this ) ) {
|
|
414
|
+
|
|
415
|
+
if ( property.startsWith( '_' ) === true ) continue;
|
|
416
|
+
|
|
417
|
+
const object = this[ property ];
|
|
418
|
+
|
|
419
|
+
if ( object && object.isNode === true ) {
|
|
420
|
+
|
|
421
|
+
children.push( { property, childNode: object } );
|
|
422
|
+
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return children;
|
|
428
|
+
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Allows to define a custom cache key that influence the material key computation
|
|
433
|
+
* for render objects.
|
|
434
|
+
*
|
|
435
|
+
* @return {string} The custom cache key.
|
|
436
|
+
*/
|
|
73
437
|
customProgramCacheKey() {
|
|
74
438
|
|
|
75
|
-
|
|
439
|
+
const values = [];
|
|
440
|
+
|
|
441
|
+
for ( const { property, childNode } of this._getNodeChildren() ) {
|
|
442
|
+
|
|
443
|
+
values.push( hashString( property.slice( 0, - 4 ) ), childNode.getCacheKey() );
|
|
444
|
+
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
return this.type + hashArray( values );
|
|
76
448
|
|
|
77
449
|
}
|
|
78
450
|
|
|
451
|
+
/**
|
|
452
|
+
* Builds this material with the given node builder.
|
|
453
|
+
*
|
|
454
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
455
|
+
*/
|
|
79
456
|
build( builder ) {
|
|
80
457
|
|
|
81
458
|
this.setup( builder );
|
|
82
459
|
|
|
83
460
|
}
|
|
84
461
|
|
|
462
|
+
/**
|
|
463
|
+
* Setups a node material observer with the given builder.
|
|
464
|
+
*
|
|
465
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
466
|
+
* @return {NodeMaterialObserver} The node material observer.
|
|
467
|
+
*/
|
|
85
468
|
setupObserver( builder ) {
|
|
86
469
|
|
|
87
470
|
return new NodeMaterialObserver( builder );
|
|
88
471
|
|
|
89
472
|
}
|
|
90
473
|
|
|
474
|
+
/**
|
|
475
|
+
* Setups the vertex and fragment stage of this node material.
|
|
476
|
+
*
|
|
477
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
478
|
+
*/
|
|
91
479
|
setup( builder ) {
|
|
92
480
|
|
|
93
|
-
builder.context.setupNormal = () => this.setupNormal( builder );
|
|
481
|
+
builder.context.setupNormal = () => subBuild( this.setupNormal( builder ), 'NORMAL', 'vec3' );
|
|
482
|
+
builder.context.setupPositionView = () => this.setupPositionView( builder );
|
|
483
|
+
builder.context.setupModelViewProjection = () => this.setupModelViewProjection( builder );
|
|
484
|
+
|
|
485
|
+
const renderer = builder.renderer;
|
|
486
|
+
const renderTarget = renderer.getRenderTarget();
|
|
487
|
+
|
|
488
|
+
// < CONTEXT >
|
|
489
|
+
|
|
490
|
+
if ( renderer.contextNode.isContextNode === true ) {
|
|
491
|
+
|
|
492
|
+
builder.context = { ...builder.context, ...renderer.contextNode.getFlowContextData() };
|
|
493
|
+
|
|
494
|
+
} else {
|
|
495
|
+
|
|
496
|
+
error( 'NodeMaterial: "renderer.contextNode" must be an instance of `context()`.' );
|
|
497
|
+
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
if ( this.contextNode !== null ) {
|
|
501
|
+
|
|
502
|
+
if ( this.contextNode.isContextNode === true ) {
|
|
503
|
+
|
|
504
|
+
builder.context = { ...builder.context, ...this.contextNode.getFlowContextData() };
|
|
505
|
+
|
|
506
|
+
} else {
|
|
507
|
+
|
|
508
|
+
error( 'NodeMaterial: "material.contextNode" must be an instance of `context()`.' );
|
|
509
|
+
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
}
|
|
94
513
|
|
|
95
514
|
// < VERTEX STAGE >
|
|
96
515
|
|
|
97
516
|
builder.addStack();
|
|
98
517
|
|
|
99
|
-
|
|
518
|
+
const mvp = this.setupVertex( builder );
|
|
519
|
+
|
|
520
|
+
const vertexNode = subBuild( this.vertexNode || mvp, 'VERTEX' );
|
|
521
|
+
|
|
522
|
+
builder.context.clipSpace = vertexNode;
|
|
523
|
+
|
|
524
|
+
builder.stack.outputNode = vertexNode;
|
|
525
|
+
|
|
526
|
+
this.setupHardwareClipping( builder );
|
|
527
|
+
|
|
528
|
+
if ( this.geometryNode !== null ) {
|
|
529
|
+
|
|
530
|
+
builder.stack.outputNode = builder.stack.outputNode.bypass( this.geometryNode );
|
|
531
|
+
|
|
532
|
+
}
|
|
100
533
|
|
|
101
534
|
builder.addFlow( 'vertex', builder.removeStack() );
|
|
102
535
|
|
|
@@ -108,7 +541,21 @@ class NodeMaterial extends Material {
|
|
|
108
541
|
|
|
109
542
|
const clippingNode = this.setupClipping( builder );
|
|
110
543
|
|
|
111
|
-
if ( this.depthWrite === true
|
|
544
|
+
if ( this.depthWrite === true || this.depthTest === true ) {
|
|
545
|
+
|
|
546
|
+
// only write depth if depth buffer is configured
|
|
547
|
+
|
|
548
|
+
if ( renderTarget !== null ) {
|
|
549
|
+
|
|
550
|
+
if ( renderTarget.depthBuffer === true ) this.setupDepth( builder );
|
|
551
|
+
|
|
552
|
+
} else {
|
|
553
|
+
|
|
554
|
+
if ( renderer.depth === true ) this.setupDepth( builder );
|
|
555
|
+
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
}
|
|
112
559
|
|
|
113
560
|
if ( this.fragmentNode === null ) {
|
|
114
561
|
|
|
@@ -117,7 +564,7 @@ class NodeMaterial extends Material {
|
|
|
117
564
|
|
|
118
565
|
const outgoingLightNode = this.setupLighting( builder );
|
|
119
566
|
|
|
120
|
-
if ( clippingNode !== null ) builder.stack.
|
|
567
|
+
if ( clippingNode !== null ) builder.stack.addToStack( clippingNode );
|
|
121
568
|
|
|
122
569
|
// force unsigned floats - useful for RenderTargets
|
|
123
570
|
|
|
@@ -131,19 +578,29 @@ class NodeMaterial extends Material {
|
|
|
131
578
|
|
|
132
579
|
//
|
|
133
580
|
|
|
134
|
-
|
|
581
|
+
const isCustomOutput = this.outputNode !== null;
|
|
135
582
|
|
|
136
|
-
|
|
583
|
+
if ( isCustomOutput ) resultNode = this.outputNode;
|
|
584
|
+
|
|
585
|
+
//
|
|
586
|
+
|
|
587
|
+
if ( builder.context.getOutput ) {
|
|
137
588
|
|
|
138
|
-
|
|
589
|
+
resultNode = builder.context.getOutput( resultNode, builder );
|
|
590
|
+
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// MRT
|
|
139
594
|
|
|
140
595
|
if ( renderTarget !== null ) {
|
|
141
596
|
|
|
142
|
-
const mrt =
|
|
597
|
+
const mrt = renderer.getMRT();
|
|
143
598
|
const materialMRT = this.mrtNode;
|
|
144
599
|
|
|
145
600
|
if ( mrt !== null ) {
|
|
146
601
|
|
|
602
|
+
if ( isCustomOutput ) output.assign( resultNode );
|
|
603
|
+
|
|
147
604
|
resultNode = mrt;
|
|
148
605
|
|
|
149
606
|
if ( materialMRT !== null ) {
|
|
@@ -178,23 +635,29 @@ class NodeMaterial extends Material {
|
|
|
178
635
|
|
|
179
636
|
builder.addFlow( 'fragment', builder.removeStack() );
|
|
180
637
|
|
|
181
|
-
// <
|
|
638
|
+
// < OBSERVER >
|
|
182
639
|
|
|
183
|
-
builder.
|
|
640
|
+
builder.observer = this.setupObserver( builder );
|
|
184
641
|
|
|
185
642
|
}
|
|
186
643
|
|
|
644
|
+
/**
|
|
645
|
+
* Setups the clipping node.
|
|
646
|
+
*
|
|
647
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
648
|
+
* @return {ClippingNode} The clipping node.
|
|
649
|
+
*/
|
|
187
650
|
setupClipping( builder ) {
|
|
188
651
|
|
|
189
652
|
if ( builder.clippingContext === null ) return null;
|
|
190
653
|
|
|
191
|
-
const {
|
|
654
|
+
const { unionPlanes, intersectionPlanes } = builder.clippingContext;
|
|
192
655
|
|
|
193
656
|
let result = null;
|
|
194
657
|
|
|
195
|
-
if (
|
|
658
|
+
if ( unionPlanes.length > 0 || intersectionPlanes.length > 0 ) {
|
|
196
659
|
|
|
197
|
-
const samples = builder.renderer.
|
|
660
|
+
const samples = builder.renderer.currentSamples;
|
|
198
661
|
|
|
199
662
|
if ( this.alphaToCoverage && samples > 1 ) {
|
|
200
663
|
|
|
@@ -203,7 +666,7 @@ class NodeMaterial extends Material {
|
|
|
203
666
|
|
|
204
667
|
} else {
|
|
205
668
|
|
|
206
|
-
builder.stack.
|
|
669
|
+
builder.stack.addToStack( clipping() );
|
|
207
670
|
|
|
208
671
|
}
|
|
209
672
|
|
|
@@ -213,9 +676,41 @@ class NodeMaterial extends Material {
|
|
|
213
676
|
|
|
214
677
|
}
|
|
215
678
|
|
|
679
|
+
/**
|
|
680
|
+
* Setups the hardware clipping if available on the current device.
|
|
681
|
+
*
|
|
682
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
683
|
+
*/
|
|
684
|
+
setupHardwareClipping( builder ) {
|
|
685
|
+
|
|
686
|
+
this.hardwareClipping = false;
|
|
687
|
+
|
|
688
|
+
if ( builder.clippingContext === null ) return;
|
|
689
|
+
|
|
690
|
+
const candidateCount = builder.clippingContext.unionPlanes.length;
|
|
691
|
+
|
|
692
|
+
// 8 planes supported by WebGL ANGLE_clip_cull_distance and WebGPU clip-distances
|
|
693
|
+
|
|
694
|
+
if ( candidateCount > 0 && candidateCount <= 8 && builder.isAvailable( 'clipDistance' ) ) {
|
|
695
|
+
|
|
696
|
+
builder.stack.addToStack( hardwareClipping() );
|
|
697
|
+
|
|
698
|
+
this.hardwareClipping = true;
|
|
699
|
+
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
return;
|
|
703
|
+
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* Setups the depth of this material.
|
|
708
|
+
*
|
|
709
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
710
|
+
*/
|
|
216
711
|
setupDepth( builder ) {
|
|
217
712
|
|
|
218
|
-
const { renderer } = builder;
|
|
713
|
+
const { renderer, camera } = builder;
|
|
219
714
|
|
|
220
715
|
// Depth
|
|
221
716
|
|
|
@@ -231,9 +726,15 @@ class NodeMaterial extends Material {
|
|
|
231
726
|
|
|
232
727
|
} else if ( renderer.logarithmicDepthBuffer === true ) {
|
|
233
728
|
|
|
234
|
-
|
|
729
|
+
if ( camera.isPerspectiveCamera ) {
|
|
730
|
+
|
|
731
|
+
depthNode = viewZToLogarithmicDepth( positionView.z, cameraNear, cameraFar );
|
|
235
732
|
|
|
236
|
-
|
|
733
|
+
} else {
|
|
734
|
+
|
|
735
|
+
depthNode = viewZToOrthographicDepth( positionView.z, cameraNear, cameraFar );
|
|
736
|
+
|
|
737
|
+
}
|
|
237
738
|
|
|
238
739
|
}
|
|
239
740
|
|
|
@@ -241,30 +742,74 @@ class NodeMaterial extends Material {
|
|
|
241
742
|
|
|
242
743
|
if ( depthNode !== null ) {
|
|
243
744
|
|
|
244
|
-
depth.assign( depthNode ).
|
|
745
|
+
depth.assign( depthNode ).toStack();
|
|
245
746
|
|
|
246
747
|
}
|
|
247
748
|
|
|
248
749
|
}
|
|
249
750
|
|
|
250
|
-
|
|
751
|
+
/**
|
|
752
|
+
* Setups the position node in view space. This method exists
|
|
753
|
+
* so derived node materials can modify the implementation e.g. sprite materials.
|
|
754
|
+
*
|
|
755
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
756
|
+
* @return {Node<vec3>} The position in view space.
|
|
757
|
+
*/
|
|
758
|
+
setupPositionView( /*builder*/ ) {
|
|
759
|
+
|
|
760
|
+
return modelViewMatrix.mul( positionLocal ).xyz;
|
|
761
|
+
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* Setups the position in clip space.
|
|
766
|
+
*
|
|
767
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
768
|
+
* @return {Node<vec4>} The position in view space.
|
|
769
|
+
*/
|
|
770
|
+
setupModelViewProjection( /*builder*/ ) {
|
|
251
771
|
|
|
252
|
-
|
|
253
|
-
|
|
772
|
+
return cameraProjectionMatrix.mul( positionView );
|
|
773
|
+
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* Setups the logic for the vertex stage.
|
|
778
|
+
*
|
|
779
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
780
|
+
* @return {Node<vec4>} The position in clip space.
|
|
781
|
+
*/
|
|
782
|
+
setupVertex( builder ) {
|
|
254
783
|
|
|
255
784
|
builder.addStack();
|
|
256
785
|
|
|
257
|
-
|
|
786
|
+
this.setupPosition( builder );
|
|
787
|
+
|
|
788
|
+
builder.context.position = builder.removeStack();
|
|
789
|
+
|
|
790
|
+
return modelViewProjection;
|
|
791
|
+
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* Setups the computation of the position in local space.
|
|
796
|
+
*
|
|
797
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
798
|
+
* @return {Node<vec3>} The position in local space.
|
|
799
|
+
*/
|
|
800
|
+
setupPosition( builder ) {
|
|
801
|
+
|
|
802
|
+
const { object, geometry } = builder;
|
|
258
803
|
|
|
259
804
|
if ( geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color ) {
|
|
260
805
|
|
|
261
|
-
morphReference( object ).
|
|
806
|
+
morphReference( object ).toStack();
|
|
262
807
|
|
|
263
808
|
}
|
|
264
809
|
|
|
265
810
|
if ( object.isSkinnedMesh === true ) {
|
|
266
811
|
|
|
267
|
-
|
|
812
|
+
skinning( object ).toStack();
|
|
268
813
|
|
|
269
814
|
}
|
|
270
815
|
|
|
@@ -280,32 +825,47 @@ class NodeMaterial extends Material {
|
|
|
280
825
|
|
|
281
826
|
if ( object.isBatchedMesh ) {
|
|
282
827
|
|
|
283
|
-
batch( object ).
|
|
828
|
+
batch( object ).toStack();
|
|
284
829
|
|
|
285
830
|
}
|
|
286
831
|
|
|
287
|
-
if ( ( object.instanceMatrix && object.instanceMatrix.isInstancedBufferAttribute === true ) ) {
|
|
832
|
+
if ( ( object.isInstancedMesh && object.instanceMatrix && object.instanceMatrix.isInstancedBufferAttribute === true ) ) {
|
|
288
833
|
|
|
289
|
-
|
|
834
|
+
instancedMesh( object ).toStack();
|
|
290
835
|
|
|
291
836
|
}
|
|
292
837
|
|
|
293
838
|
if ( this.positionNode !== null ) {
|
|
294
839
|
|
|
295
|
-
positionLocal.assign( this.positionNode );
|
|
840
|
+
positionLocal.assign( subBuild( this.positionNode, 'POSITION', 'vec3' ) );
|
|
296
841
|
|
|
297
842
|
}
|
|
298
843
|
|
|
299
|
-
|
|
844
|
+
return positionLocal;
|
|
300
845
|
|
|
301
|
-
|
|
302
|
-
builder.context.mvp = mvp;
|
|
846
|
+
}
|
|
303
847
|
|
|
304
|
-
|
|
848
|
+
/**
|
|
849
|
+
* Setups the computation of the material's diffuse color.
|
|
850
|
+
*
|
|
851
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
852
|
+
* @param {BufferGeometry} geometry - The geometry.
|
|
853
|
+
*/
|
|
854
|
+
setupDiffuseColor( builder ) {
|
|
305
855
|
|
|
306
|
-
|
|
856
|
+
const { object, geometry } = builder;
|
|
857
|
+
|
|
858
|
+
// MASK
|
|
859
|
+
|
|
860
|
+
if ( this.maskNode !== null ) {
|
|
861
|
+
|
|
862
|
+
// Discard if the mask is `false`
|
|
863
|
+
|
|
864
|
+
bool( this.maskNode ).not().discard();
|
|
307
865
|
|
|
308
|
-
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
// COLOR
|
|
309
869
|
|
|
310
870
|
let colorNode = this.colorNode ? vec4( this.colorNode ) : materialColor;
|
|
311
871
|
|
|
@@ -313,11 +873,11 @@ class NodeMaterial extends Material {
|
|
|
313
873
|
|
|
314
874
|
if ( this.vertexColors === true && geometry.hasAttribute( 'color' ) ) {
|
|
315
875
|
|
|
316
|
-
colorNode =
|
|
876
|
+
colorNode = colorNode.mul( vertexColor() );
|
|
317
877
|
|
|
318
878
|
}
|
|
319
879
|
|
|
320
|
-
//
|
|
880
|
+
// INSTANCED COLORS
|
|
321
881
|
|
|
322
882
|
if ( object.instanceColor ) {
|
|
323
883
|
|
|
@@ -335,8 +895,7 @@ class NodeMaterial extends Material {
|
|
|
335
895
|
|
|
336
896
|
}
|
|
337
897
|
|
|
338
|
-
|
|
339
|
-
// COLOR
|
|
898
|
+
// DIFFUSE COLOR
|
|
340
899
|
|
|
341
900
|
diffuseColor.assign( colorNode );
|
|
342
901
|
|
|
@@ -347,15 +906,36 @@ class NodeMaterial extends Material {
|
|
|
347
906
|
|
|
348
907
|
// ALPHA TEST
|
|
349
908
|
|
|
909
|
+
let alphaTestNode = null;
|
|
910
|
+
|
|
350
911
|
if ( this.alphaTestNode !== null || this.alphaTest > 0 ) {
|
|
351
912
|
|
|
352
|
-
|
|
913
|
+
alphaTestNode = this.alphaTestNode !== null ? float( this.alphaTestNode ) : materialAlphaTest;
|
|
914
|
+
|
|
915
|
+
if ( this.alphaToCoverage === true ) {
|
|
916
|
+
|
|
917
|
+
diffuseColor.a = smoothstep( alphaTestNode, alphaTestNode.add( fwidth( diffuseColor.a ) ), diffuseColor.a );
|
|
918
|
+
diffuseColor.a.lessThanEqual( 0 ).discard();
|
|
353
919
|
|
|
354
|
-
|
|
920
|
+
} else {
|
|
921
|
+
|
|
922
|
+
diffuseColor.a.lessThanEqual( alphaTestNode ).discard();
|
|
923
|
+
|
|
924
|
+
}
|
|
355
925
|
|
|
356
926
|
}
|
|
357
927
|
|
|
358
|
-
|
|
928
|
+
// ALPHA HASH
|
|
929
|
+
|
|
930
|
+
if ( this.alphaHash === true ) {
|
|
931
|
+
|
|
932
|
+
diffuseColor.a.lessThan( getAlphaHashThreshold( positionLocal ) ).discard();
|
|
933
|
+
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
// OPAQUE
|
|
937
|
+
|
|
938
|
+
if ( builder.isOpaque() ) {
|
|
359
939
|
|
|
360
940
|
diffuseColor.a.assign( 1.0 );
|
|
361
941
|
|
|
@@ -363,24 +943,47 @@ class NodeMaterial extends Material {
|
|
|
363
943
|
|
|
364
944
|
}
|
|
365
945
|
|
|
946
|
+
/**
|
|
947
|
+
* Abstract interface method that can be implemented by derived materials
|
|
948
|
+
* to setup material-specific node variables.
|
|
949
|
+
*
|
|
950
|
+
* @abstract
|
|
951
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
952
|
+
*/
|
|
366
953
|
setupVariants( /*builder*/ ) {
|
|
367
954
|
|
|
368
955
|
// Interface function.
|
|
369
956
|
|
|
370
957
|
}
|
|
371
958
|
|
|
959
|
+
/**
|
|
960
|
+
* Setups the outgoing light node variable
|
|
961
|
+
*
|
|
962
|
+
* @return {Node<vec3>} The outgoing light node.
|
|
963
|
+
*/
|
|
372
964
|
setupOutgoingLight() {
|
|
373
965
|
|
|
374
966
|
return ( this.lights === true ) ? vec3( 0 ) : diffuseColor.rgb;
|
|
375
967
|
|
|
376
968
|
}
|
|
377
969
|
|
|
970
|
+
/**
|
|
971
|
+
* Setups the normal node from the material.
|
|
972
|
+
*
|
|
973
|
+
* @return {Node<vec3>} The normal node.
|
|
974
|
+
*/
|
|
378
975
|
setupNormal() {
|
|
379
976
|
|
|
380
977
|
return this.normalNode ? vec3( this.normalNode ) : materialNormal;
|
|
381
978
|
|
|
382
979
|
}
|
|
383
980
|
|
|
981
|
+
/**
|
|
982
|
+
* Setups the environment node from the material.
|
|
983
|
+
*
|
|
984
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
985
|
+
* @return {Node<vec4>} The environment node.
|
|
986
|
+
*/
|
|
384
987
|
setupEnvironment( /*builder*/ ) {
|
|
385
988
|
|
|
386
989
|
let node = null;
|
|
@@ -399,6 +1002,12 @@ class NodeMaterial extends Material {
|
|
|
399
1002
|
|
|
400
1003
|
}
|
|
401
1004
|
|
|
1005
|
+
/**
|
|
1006
|
+
* Setups the light map node from the material.
|
|
1007
|
+
*
|
|
1008
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
1009
|
+
* @return {Node<vec3>} The light map node.
|
|
1010
|
+
*/
|
|
402
1011
|
setupLightMap( builder ) {
|
|
403
1012
|
|
|
404
1013
|
let node = null;
|
|
@@ -413,6 +1022,12 @@ class NodeMaterial extends Material {
|
|
|
413
1022
|
|
|
414
1023
|
}
|
|
415
1024
|
|
|
1025
|
+
/**
|
|
1026
|
+
* Setups the lights node based on the scene, environment and material.
|
|
1027
|
+
*
|
|
1028
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
1029
|
+
* @return {LightsNode} The lights node.
|
|
1030
|
+
*/
|
|
416
1031
|
setupLights( builder ) {
|
|
417
1032
|
|
|
418
1033
|
const materialLightsNode = [];
|
|
@@ -435,9 +1050,21 @@ class NodeMaterial extends Material {
|
|
|
435
1050
|
|
|
436
1051
|
}
|
|
437
1052
|
|
|
438
|
-
|
|
1053
|
+
let aoNode = this.aoNode;
|
|
1054
|
+
|
|
1055
|
+
if ( aoNode === null && builder.material.aoMap ) {
|
|
1056
|
+
|
|
1057
|
+
aoNode = materialAO;
|
|
1058
|
+
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
if ( builder.context.getAO ) {
|
|
1062
|
+
|
|
1063
|
+
aoNode = builder.context.getAO( aoNode, builder );
|
|
1064
|
+
|
|
1065
|
+
}
|
|
439
1066
|
|
|
440
|
-
|
|
1067
|
+
if ( aoNode ) {
|
|
441
1068
|
|
|
442
1069
|
materialLightsNode.push( new AONode( aoNode ) );
|
|
443
1070
|
|
|
@@ -447,7 +1074,7 @@ class NodeMaterial extends Material {
|
|
|
447
1074
|
|
|
448
1075
|
if ( materialLightsNode.length > 0 ) {
|
|
449
1076
|
|
|
450
|
-
lightsN =
|
|
1077
|
+
lightsN = builder.renderer.lighting.createNode( [ ...lightsN.getLights(), ...materialLightsNode ] );
|
|
451
1078
|
|
|
452
1079
|
}
|
|
453
1080
|
|
|
@@ -455,12 +1082,26 @@ class NodeMaterial extends Material {
|
|
|
455
1082
|
|
|
456
1083
|
}
|
|
457
1084
|
|
|
1085
|
+
/**
|
|
1086
|
+
* This method should be implemented by most derived materials
|
|
1087
|
+
* since it defines the material's lighting model.
|
|
1088
|
+
*
|
|
1089
|
+
* @abstract
|
|
1090
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
1091
|
+
* @return {LightingModel} The lighting model.
|
|
1092
|
+
*/
|
|
458
1093
|
setupLightingModel( /*builder*/ ) {
|
|
459
1094
|
|
|
460
1095
|
// Interface function.
|
|
461
1096
|
|
|
462
1097
|
}
|
|
463
1098
|
|
|
1099
|
+
/**
|
|
1100
|
+
* Setups the outgoing light node.
|
|
1101
|
+
*
|
|
1102
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
1103
|
+
* @return {Node<vec3>} The outgoing light node.
|
|
1104
|
+
*/
|
|
464
1105
|
setupLighting( builder ) {
|
|
465
1106
|
|
|
466
1107
|
const { material } = builder;
|
|
@@ -474,9 +1115,9 @@ class NodeMaterial extends Material {
|
|
|
474
1115
|
|
|
475
1116
|
let outgoingLightNode = this.setupOutgoingLight( builder );
|
|
476
1117
|
|
|
477
|
-
if ( lightsNode && lightsNode.getScope().
|
|
1118
|
+
if ( lightsNode && lightsNode.getScope().hasLights ) {
|
|
478
1119
|
|
|
479
|
-
const lightingModel = this.setupLightingModel( builder );
|
|
1120
|
+
const lightingModel = this.setupLightingModel( builder ) || null;
|
|
480
1121
|
|
|
481
1122
|
outgoingLightNode = lightingContext( lightsNode, lightingModel, backdropNode, backdropAlphaNode );
|
|
482
1123
|
|
|
@@ -500,15 +1141,64 @@ class NodeMaterial extends Material {
|
|
|
500
1141
|
|
|
501
1142
|
}
|
|
502
1143
|
|
|
1144
|
+
/**
|
|
1145
|
+
* Setup the fog.
|
|
1146
|
+
*
|
|
1147
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
1148
|
+
* @param {Node<vec4>} outputNode - The existing output node.
|
|
1149
|
+
* @return {Node<vec4>} The output node.
|
|
1150
|
+
*/
|
|
1151
|
+
setupFog( builder, outputNode ) {
|
|
1152
|
+
|
|
1153
|
+
const fogNode = builder.fogNode;
|
|
1154
|
+
|
|
1155
|
+
if ( fogNode ) {
|
|
1156
|
+
|
|
1157
|
+
output.assign( outputNode );
|
|
1158
|
+
|
|
1159
|
+
outputNode = vec4( fogNode.toVar() );
|
|
1160
|
+
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
return outputNode;
|
|
1164
|
+
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
/**
|
|
1168
|
+
* Setups premultiplied alpha.
|
|
1169
|
+
*
|
|
1170
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
1171
|
+
* @param {Node<vec4>} outputNode - The existing output node.
|
|
1172
|
+
* @return {Node<vec4>} The output node.
|
|
1173
|
+
*/
|
|
1174
|
+
setupPremultipliedAlpha( builder, outputNode ) {
|
|
1175
|
+
|
|
1176
|
+
return premultiplyAlpha( outputNode );
|
|
1177
|
+
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* Setups the output node.
|
|
1182
|
+
*
|
|
1183
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
1184
|
+
* @param {Node<vec4>} outputNode - The existing output node.
|
|
1185
|
+
* @return {Node<vec4>} The output node.
|
|
1186
|
+
*/
|
|
503
1187
|
setupOutput( builder, outputNode ) {
|
|
504
1188
|
|
|
505
1189
|
// FOG
|
|
506
1190
|
|
|
507
1191
|
if ( this.fog === true ) {
|
|
508
1192
|
|
|
509
|
-
|
|
1193
|
+
outputNode = this.setupFog( builder, outputNode );
|
|
1194
|
+
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
// PREMULTIPLIED ALPHA
|
|
1198
|
+
|
|
1199
|
+
if ( this.premultipliedAlpha === true ) {
|
|
510
1200
|
|
|
511
|
-
|
|
1201
|
+
outputNode = this.setupPremultipliedAlpha( builder, outputNode );
|
|
512
1202
|
|
|
513
1203
|
}
|
|
514
1204
|
|
|
@@ -516,6 +1206,13 @@ class NodeMaterial extends Material {
|
|
|
516
1206
|
|
|
517
1207
|
}
|
|
518
1208
|
|
|
1209
|
+
/**
|
|
1210
|
+
* Most classic material types have a node pendant e.g. for `MeshBasicMaterial`
|
|
1211
|
+
* there is `MeshBasicNodeMaterial`. This utility method is intended for
|
|
1212
|
+
* defining all material properties of the classic type in the node type.
|
|
1213
|
+
*
|
|
1214
|
+
* @param {Material} material - The material to copy properties with their values to this node material.
|
|
1215
|
+
*/
|
|
519
1216
|
setDefaultValues( material ) {
|
|
520
1217
|
|
|
521
1218
|
// This approach is to reuse the native refreshUniforms*
|
|
@@ -550,6 +1247,12 @@ class NodeMaterial extends Material {
|
|
|
550
1247
|
|
|
551
1248
|
}
|
|
552
1249
|
|
|
1250
|
+
/**
|
|
1251
|
+
* Serializes this material to JSON.
|
|
1252
|
+
*
|
|
1253
|
+
* @param {?(Object|string)} meta - The meta information for serialization.
|
|
1254
|
+
* @return {Object} The serialized node.
|
|
1255
|
+
*/
|
|
553
1256
|
toJSON( meta ) {
|
|
554
1257
|
|
|
555
1258
|
const isRoot = ( meta === undefined || typeof meta === 'string' );
|
|
@@ -565,11 +1268,9 @@ class NodeMaterial extends Material {
|
|
|
565
1268
|
}
|
|
566
1269
|
|
|
567
1270
|
const data = Material.prototype.toJSON.call( this, meta );
|
|
568
|
-
const nodeChildren = getNodeChildren( this );
|
|
569
|
-
|
|
570
1271
|
data.inputNodes = {};
|
|
571
1272
|
|
|
572
|
-
for ( const { property, childNode } of
|
|
1273
|
+
for ( const { property, childNode } of this._getNodeChildren() ) {
|
|
573
1274
|
|
|
574
1275
|
data.inputNodes[ property ] = childNode.toJSON( meta ).uuid;
|
|
575
1276
|
|
|
@@ -609,10 +1310,17 @@ class NodeMaterial extends Material {
|
|
|
609
1310
|
|
|
610
1311
|
}
|
|
611
1312
|
|
|
1313
|
+
/**
|
|
1314
|
+
* Copies the properties of the given node material to this instance.
|
|
1315
|
+
*
|
|
1316
|
+
* @param {NodeMaterial} source - The material to copy.
|
|
1317
|
+
* @return {NodeMaterial} A reference to this node material.
|
|
1318
|
+
*/
|
|
612
1319
|
copy( source ) {
|
|
613
1320
|
|
|
614
1321
|
this.lightsNode = source.lightsNode;
|
|
615
1322
|
this.envNode = source.envNode;
|
|
1323
|
+
this.aoNode = source.aoNode;
|
|
616
1324
|
|
|
617
1325
|
this.colorNode = source.colorNode;
|
|
618
1326
|
this.normalNode = source.normalNode;
|
|
@@ -620,12 +1328,17 @@ class NodeMaterial extends Material {
|
|
|
620
1328
|
this.backdropNode = source.backdropNode;
|
|
621
1329
|
this.backdropAlphaNode = source.backdropAlphaNode;
|
|
622
1330
|
this.alphaTestNode = source.alphaTestNode;
|
|
1331
|
+
this.maskNode = source.maskNode;
|
|
1332
|
+
this.maskShadowNode = source.maskShadowNode;
|
|
623
1333
|
|
|
624
1334
|
this.positionNode = source.positionNode;
|
|
1335
|
+
this.geometryNode = source.geometryNode;
|
|
625
1336
|
|
|
626
1337
|
this.depthNode = source.depthNode;
|
|
627
|
-
this.
|
|
628
|
-
this.
|
|
1338
|
+
this.receivedShadowPositionNode = source.receivedShadowPositionNode;
|
|
1339
|
+
this.castShadowPositionNode = source.castShadowPositionNode;
|
|
1340
|
+
this.receivedShadowNode = source.receivedShadowNode;
|
|
1341
|
+
this.castShadowNode = source.castShadowNode;
|
|
629
1342
|
|
|
630
1343
|
this.outputNode = source.outputNode;
|
|
631
1344
|
this.mrtNode = source.mrtNode;
|
|
@@ -633,6 +1346,8 @@ class NodeMaterial extends Material {
|
|
|
633
1346
|
this.fragmentNode = source.fragmentNode;
|
|
634
1347
|
this.vertexNode = source.vertexNode;
|
|
635
1348
|
|
|
1349
|
+
this.contextNode = source.contextNode;
|
|
1350
|
+
|
|
636
1351
|
return super.copy( source );
|
|
637
1352
|
|
|
638
1353
|
}
|