super-three 0.177.0 → 0.181.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/README.md +1 -1
- package/build/three.cjs +1994 -749
- package/build/three.core.js +1358 -506
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +631 -247
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +113 -33
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +9571 -3424
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +9397 -3426
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/Addons.js +2 -3
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +0 -27
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +9 -9
- package/examples/jsm/controls/DragControls.js +7 -57
- package/examples/jsm/controls/FirstPersonControls.js +3 -3
- package/examples/jsm/controls/FlyControls.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/PointerLockControls.js +2 -10
- package/examples/jsm/controls/TrackballControls.js +1 -1
- package/examples/jsm/controls/TransformControls.js +62 -15
- package/examples/jsm/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/effects/AsciiEffect.js +8 -8
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- package/examples/jsm/exporters/DRACOExporter.js +2 -2
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +33 -25
- package/examples/jsm/exporters/KTX2Exporter.js +4 -2
- package/examples/jsm/exporters/PLYExporter.js +1 -1
- package/examples/jsm/exporters/USDZExporter.js +683 -299
- package/examples/jsm/geometries/DecalGeometry.js +2 -2
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
- package/examples/jsm/geometries/TeapotGeometry.js +2 -2
- package/examples/jsm/geometries/TextGeometry.js +3 -2
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/ViewHelper.js +43 -5
- package/examples/jsm/inspector/Inspector.js +427 -0
- package/examples/jsm/inspector/RendererInspector.js +415 -0
- package/examples/jsm/inspector/tabs/Console.js +204 -0
- package/examples/jsm/inspector/tabs/Parameters.js +332 -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 +170 -0
- package/examples/jsm/inspector/ui/Style.js +654 -0
- package/examples/jsm/inspector/ui/Tab.js +46 -0
- package/examples/jsm/inspector/ui/Values.js +423 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +11 -13
- package/examples/jsm/interactive/InteractiveGroup.js +1 -1
- package/examples/jsm/interactive/SelectionBox.js +30 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/Line2.js +3 -3
- package/examples/jsm/lines/LineGeometry.js +1 -1
- package/examples/jsm/lines/LineSegments2.js +2 -2
- package/examples/jsm/lines/Wireframe.js +2 -2
- package/examples/jsm/lines/WireframeGeometry2.js +1 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
- package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +4 -4
- package/examples/jsm/loaders/DDSLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +73 -22
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +4 -4
- package/examples/jsm/loaders/FontLoader.js +23 -5
- package/examples/jsm/loaders/GLTFLoader.js +14 -8
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
- package/examples/jsm/loaders/HDRLoader.js +486 -0
- package/examples/jsm/loaders/KTX2Loader.js +136 -49
- package/examples/jsm/loaders/KTXLoader.js +2 -2
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +1 -1
- package/examples/jsm/loaders/LWOLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +233 -34
- package/examples/jsm/loaders/OBJLoader.js +1 -1
- package/examples/jsm/loaders/PDBLoader.js +1 -1
- package/examples/jsm/loaders/RGBELoader.js +7 -473
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/TTFLoader.js +13 -1
- package/examples/jsm/loaders/USDLoader.js +219 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -892
- package/examples/jsm/loaders/UltraHDRLoader.js +2 -2
- package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
- package/examples/jsm/loaders/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/ColorSpaces.js +19 -1
- package/examples/jsm/math/ConvexHull.js +3 -3
- package/examples/jsm/math/ImprovedNoise.js +1 -1
- package/examples/jsm/math/Lut.js +2 -2
- package/examples/jsm/math/SimplexNoise.js +1 -1
- package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
- package/examples/jsm/misc/ProgressiveLightMap.js +9 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +7 -1
- package/examples/jsm/misc/TubePainter.js +383 -40
- package/examples/jsm/misc/Volume.js +1 -1
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/objects/LensflareMesh.js +3 -3
- package/examples/jsm/objects/ReflectorForSSRPass.js +1 -0
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/SkyMesh.js +3 -3
- package/examples/jsm/objects/Water.js +3 -3
- package/examples/jsm/objects/WaterMesh.js +6 -6
- package/examples/jsm/physics/RapierPhysics.js +95 -16
- package/examples/jsm/postprocessing/GTAOPass.js +10 -9
- package/examples/jsm/postprocessing/GlitchPass.js +2 -2
- package/examples/jsm/postprocessing/OutlinePass.js +17 -17
- package/examples/jsm/postprocessing/SSAOPass.js +10 -9
- package/examples/jsm/postprocessing/SSRPass.js +37 -8
- package/examples/jsm/postprocessing/UnrealBloomPass.js +8 -6
- package/examples/jsm/renderers/CSS2DRenderer.js +16 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -6
- package/examples/jsm/renderers/SVGRenderer.js +1 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +1 -1
- package/examples/jsm/shaders/AfterimageShader.js +1 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -1
- package/examples/jsm/shaders/BokehShader.js +1 -1
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/DotScreenShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +1 -1
- package/examples/jsm/shaders/GTAOShader.js +2 -2
- package/examples/jsm/shaders/GodRaysShader.js +1 -1
- package/examples/jsm/shaders/KaleidoShader.js +1 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +2 -2
- package/examples/jsm/shaders/SSRShader.js +1 -1
- package/examples/jsm/shaders/SepiaShader.js +1 -1
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +1 -1
- package/examples/jsm/shaders/TriangleBlurShader.js +1 -1
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/AST.js +381 -30
- package/examples/jsm/transpiler/GLSLDecoder.js +247 -104
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/TSLEncoder.js +196 -92
- package/examples/jsm/transpiler/Transpiler.js +17 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +812 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +26 -24
- package/examples/jsm/tsl/display/AnamorphicNode.js +28 -4
- package/examples/jsm/tsl/display/BloomNode.js +11 -6
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +207 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +2 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +446 -90
- package/examples/jsm/tsl/display/GTAONode.js +53 -5
- package/examples/jsm/tsl/display/GaussianBlurNode.js +55 -43
- package/examples/jsm/tsl/display/OutlineNode.js +13 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSGINode.js +654 -0
- package/examples/jsm/tsl/display/SSRNode.js +182 -65
- package/examples/jsm/tsl/display/SSSNode.js +488 -0
- package/examples/jsm/tsl/display/TRAANode.js +578 -0
- package/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/examples/jsm/tsl/display/hashBlur.js +18 -20
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +22 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -6
- package/package.json +5 -10
- package/src/Three.Core.js +5 -2
- package/src/Three.TSL.js +112 -32
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +4 -0
- package/src/animation/AnimationClip.js +20 -4
- package/src/animation/AnimationMixer.js +3 -3
- package/src/animation/AnimationObjectGroup.js +2 -1
- package/src/animation/KeyframeTrack.js +8 -7
- package/src/animation/PropertyBinding.js +12 -11
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/audio/Audio.js +10 -9
- package/src/audio/PositionalAudio.js +1 -1
- package/src/cameras/Camera.js +14 -0
- package/src/cameras/OrthographicCamera.js +2 -2
- package/src/cameras/PerspectiveCamera.js +2 -2
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +13 -5
- package/src/core/BufferAttribute.js +3 -3
- package/src/core/BufferGeometry.js +10 -10
- package/src/core/Clock.js +2 -8
- package/src/core/EventDispatcher.js +1 -1
- package/src/core/GLBufferAttribute.js +13 -1
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +3 -2
- package/src/core/Object3D.js +4 -3
- package/src/core/Raycaster.js +2 -1
- package/src/core/RenderTarget.js +10 -1
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/Controls.js +5 -4
- package/src/extras/DataUtils.js +2 -1
- package/src/extras/Earcut.js +6 -0
- package/src/extras/ImageUtils.js +2 -2
- package/src/extras/PMREMGenerator.js +279 -55
- package/src/extras/TextureUtils.js +2 -1
- package/src/extras/core/Curve.js +2 -1
- package/src/extras/core/Interpolations.js +7 -1
- package/src/extras/core/Path.js +22 -22
- package/src/extras/core/ShapePath.js +4 -4
- package/src/extras/lib/earcut.js +8 -8
- package/src/geometries/BoxGeometry.js +1 -0
- package/src/geometries/CapsuleGeometry.js +1 -0
- package/src/geometries/CircleGeometry.js +1 -0
- package/src/geometries/ConeGeometry.js +1 -0
- package/src/geometries/CylinderGeometry.js +1 -0
- package/src/geometries/DodecahedronGeometry.js +1 -0
- package/src/geometries/ExtrudeGeometry.js +8 -6
- package/src/geometries/IcosahedronGeometry.js +1 -0
- package/src/geometries/LatheGeometry.js +1 -0
- package/src/geometries/OctahedronGeometry.js +1 -0
- package/src/geometries/PlaneGeometry.js +1 -0
- package/src/geometries/RingGeometry.js +1 -0
- package/src/geometries/ShapeGeometry.js +1 -0
- package/src/geometries/SphereGeometry.js +1 -0
- package/src/geometries/TetrahedronGeometry.js +1 -0
- package/src/geometries/TorusGeometry.js +1 -0
- package/src/geometries/TorusKnotGeometry.js +1 -0
- package/src/geometries/TubeGeometry.js +1 -0
- package/src/helpers/CameraHelper.js +42 -12
- package/src/helpers/SkeletonHelper.js +35 -6
- package/src/lights/LightShadow.js +21 -8
- package/src/lights/PointLightShadow.js +1 -1
- package/src/lights/webgpu/ProjectorLight.js +1 -1
- package/src/loaders/AnimationLoader.js +2 -1
- package/src/loaders/AudioLoader.js +2 -1
- package/src/loaders/BufferGeometryLoader.js +2 -2
- package/src/loaders/Cache.js +2 -2
- package/src/loaders/DataTextureLoader.js +1 -1
- package/src/loaders/FileLoader.js +29 -5
- package/src/loaders/ImageBitmapLoader.js +32 -8
- package/src/loaders/ImageLoader.js +56 -9
- package/src/loaders/Loader.js +17 -3
- package/src/loaders/LoadingManager.js +45 -0
- package/src/loaders/MaterialLoader.js +3 -2
- package/src/loaders/ObjectLoader.js +13 -13
- package/src/loaders/TextureLoader.js +1 -1
- package/src/loaders/nodes/NodeLoader.js +3 -2
- package/src/materials/Material.js +16 -3
- package/src/materials/MeshBasicMaterial.js +2 -1
- package/src/materials/MeshDepthMaterial.js +1 -0
- package/src/materials/MeshDistanceMaterial.js +1 -1
- package/src/materials/MeshLambertMaterial.js +2 -1
- package/src/materials/MeshMatcapMaterial.js +22 -0
- package/src/materials/MeshNormalMaterial.js +1 -0
- package/src/materials/MeshPhongMaterial.js +2 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -1
- package/src/materials/MeshStandardMaterial.js +8 -7
- package/src/materials/MeshToonMaterial.js +1 -0
- package/src/materials/PointsMaterial.js +1 -1
- package/src/materials/ShaderMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +2 -10
- package/src/materials/nodes/MeshBasicNodeMaterial.js +4 -3
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +1 -1
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -1
- package/src/materials/nodes/MeshSSSNodeMaterial.js +3 -3
- package/src/materials/nodes/NodeMaterial.js +90 -27
- package/src/materials/nodes/PointsNodeMaterial.js +86 -28
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
- package/src/materials/nodes/manager/NodeMaterialObserver.js +89 -3
- package/src/math/Color.js +6 -5
- package/src/math/ColorManagement.js +9 -3
- package/src/math/Cylindrical.js +1 -1
- package/src/math/Euler.js +2 -1
- package/src/math/Frustum.js +25 -9
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/MathUtils.js +13 -11
- package/src/math/Matrix2.js +1 -1
- package/src/math/Matrix3.js +2 -2
- package/src/math/Matrix4.js +55 -34
- package/src/math/Plane.js +1 -1
- package/src/math/Quaternion.js +69 -67
- package/src/math/Spherical.js +3 -3
- package/src/nodes/Nodes.js +6 -4
- package/src/nodes/TSL.js +9 -4
- package/src/nodes/accessors/AccessorsUtils.js +7 -8
- package/src/nodes/accessors/Bitangent.js +31 -25
- package/src/nodes/accessors/BufferNode.js +1 -1
- package/src/nodes/accessors/Camera.js +142 -16
- package/src/nodes/accessors/ClippingNode.js +6 -5
- package/src/nodes/accessors/CubeTextureNode.js +5 -4
- package/src/nodes/accessors/InstanceNode.js +25 -5
- package/src/nodes/accessors/Lights.js +10 -0
- package/src/nodes/accessors/Normal.js +97 -30
- package/src/nodes/accessors/Object3DNode.js +2 -2
- package/src/nodes/accessors/Position.js +25 -9
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +20 -4
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/SceneNode.js +3 -2
- package/src/nodes/accessors/StorageBufferNode.js +2 -1
- package/src/nodes/accessors/StorageTextureNode.js +23 -1
- package/src/nodes/accessors/Tangent.js +25 -17
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/Texture3DNode.js +14 -1
- package/src/nodes/accessors/TextureBicubic.js +21 -3
- package/src/nodes/accessors/TextureNode.js +142 -44
- package/src/nodes/accessors/UniformArrayNode.js +0 -16
- package/src/nodes/code/FunctionCallNode.js +24 -4
- package/src/nodes/code/FunctionNode.js +23 -0
- package/src/nodes/core/ArrayNode.js +13 -0
- package/src/nodes/core/AssignNode.js +6 -2
- package/src/nodes/core/AttributeNode.js +2 -1
- package/src/nodes/core/ContextNode.js +48 -10
- package/src/nodes/core/IndexNode.js +2 -2
- package/src/nodes/core/InputNode.js +2 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/{CacheNode.js → IsolateNode.js} +36 -17
- package/src/nodes/core/Node.js +167 -34
- package/src/nodes/core/NodeBuilder.js +404 -120
- package/src/nodes/core/NodeFrame.js +21 -21
- package/src/nodes/core/NodeFunction.js +2 -1
- package/src/nodes/core/NodeParser.js +2 -1
- package/src/nodes/core/NodeUniform.js +1 -1
- package/src/nodes/core/NodeUtils.js +17 -88
- package/src/nodes/core/ParameterNode.js +31 -0
- package/src/nodes/core/PropertyNode.js +7 -0
- package/src/nodes/core/StackNode.js +77 -30
- package/src/nodes/core/StructNode.js +5 -5
- package/src/nodes/core/StructTypeNode.js +1 -0
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/UniformNode.js +80 -14
- package/src/nodes/core/VarNode.js +142 -16
- package/src/nodes/core/VaryingNode.js +9 -6
- package/src/nodes/display/BlendModes.js +7 -6
- package/src/nodes/display/BumpMapNode.js +1 -1
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/FrontFacingNode.js +35 -7
- package/src/nodes/display/NormalMapNode.js +20 -50
- package/src/nodes/display/PassNode.js +206 -17
- package/src/nodes/display/RenderOutputNode.js +28 -2
- package/src/nodes/display/ScreenNode.js +44 -40
- package/src/nodes/display/ToneMappingNode.js +31 -4
- package/src/nodes/display/ToonOutlinePassNode.js +8 -0
- package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
- package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
- package/src/nodes/display/ViewportTextureNode.js +94 -4
- package/src/nodes/fog/Fog.js +3 -2
- 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/DFGApprox.js +60 -19
- package/src/nodes/functions/BasicLightingModel.js +2 -1
- package/src/nodes/functions/PhongLightingModel.js +3 -3
- package/src/nodes/functions/PhysicalLightingModel.js +19 -18
- package/src/nodes/functions/VolumetricLightingModel.js +5 -5
- package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/src/nodes/geometry/RangeNode.js +40 -4
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -1
- package/src/nodes/gpgpu/ComputeNode.js +81 -25
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +29 -3
- package/src/nodes/lighting/EnvironmentNode.js +11 -11
- package/src/nodes/lighting/LightsNode.js +7 -8
- package/src/nodes/lighting/PointShadowNode.js +6 -0
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +3 -1
- package/src/nodes/lighting/ShadowNode.js +77 -10
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +165 -1
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/ConditionalNode.js +25 -27
- package/src/nodes/math/MathNode.js +106 -65
- package/src/nodes/math/OperatorNode.js +28 -43
- package/src/nodes/pmrem/PMREMUtils.js +117 -2
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLBase.js +6 -2
- package/src/nodes/tsl/TSLCore.js +546 -186
- package/src/nodes/utils/DebugNode.js +3 -2
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +119 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +37 -19
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +20 -41
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/MemberNode.js +59 -7
- package/src/nodes/utils/PostProcessingUtils.js +28 -1
- package/src/nodes/utils/RTTNode.js +33 -6
- package/src/nodes/utils/ReflectorNode.js +68 -10
- package/src/nodes/utils/SampleNode.js +91 -0
- package/src/nodes/utils/SplitNode.js +11 -0
- package/src/nodes/utils/Timer.js +0 -47
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/objects/BatchedMesh.js +6 -4
- package/src/objects/LOD.js +1 -1
- package/src/objects/Line.js +2 -1
- package/src/objects/LineSegments.js +2 -1
- package/src/objects/Skeleton.js +3 -2
- package/src/objects/SkinnedMesh.js +3 -1
- package/src/objects/Sprite.js +4 -3
- package/src/renderers/WebGLRenderer.js +77 -66
- package/src/renderers/common/Animation.js +13 -1
- package/src/renderers/common/Attributes.js +1 -1
- package/src/renderers/common/Backend.js +108 -27
- package/src/renderers/common/Background.js +4 -3
- package/src/renderers/common/Bindings.js +76 -19
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/ChainMap.js +1 -1
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/DataMap.js +1 -1
- package/src/renderers/common/Geometries.js +26 -0
- package/src/renderers/common/Info.js +4 -2
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/Pipelines.js +1 -1
- package/src/renderers/common/PostProcessing.js +61 -25
- package/src/renderers/common/QuadMesh.js +7 -1
- package/src/renderers/common/RenderContext.js +2 -2
- package/src/renderers/common/RenderList.js +7 -3
- package/src/renderers/common/RenderObject.js +84 -5
- package/src/renderers/common/RenderObjects.js +1 -1
- package/src/renderers/common/Renderer.js +486 -255
- package/src/renderers/common/RendererUtils.js +9 -0
- package/src/renderers/common/SampledTexture.js +8 -68
- package/src/renderers/common/Sampler.js +117 -0
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageTexture.js +27 -0
- package/src/renderers/common/Textures.js +138 -46
- package/src/renderers/common/TimestampQueryPool.js +65 -3
- package/src/renderers/common/UniformsGroup.js +2 -1
- package/src/renderers/common/XRManager.js +63 -24
- package/src/renderers/common/XRRenderTarget.js +21 -4
- package/src/renderers/common/extras/PMREMGenerator.js +161 -66
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +9 -7
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- package/src/renderers/common/nodes/NodeSampler.js +13 -1
- package/src/renderers/common/nodes/Nodes.js +38 -16
- package/src/renderers/shaders/DFGLUTData.js +64 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +52 -18
- 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/shadowmap_pars_fragment.glsl.js +21 -11
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/shaders/UniformsUtils.js +25 -4
- package/src/renderers/webgl/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLCapabilities.js +4 -3
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +25 -18
- package/src/renderers/webgl/WebGLPrograms.js +9 -6
- package/src/renderers/webgl/WebGLShadowMap.js +13 -2
- package/src/renderers/webgl/WebGLState.js +17 -16
- package/src/renderers/webgl/WebGLTextures.js +38 -21
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl/WebGLUtils.js +3 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +245 -182
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +184 -30
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +4 -0
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +2 -3
- package/src/renderers/webgl-fallback/utils/WebGLState.js +9 -8
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +171 -19
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +51 -22
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
- package/src/renderers/webgpu/WebGPUBackend.js +205 -128
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +2 -1
- package/src/renderers/webgpu/WebGPURenderer.js +3 -2
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +198 -121
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +8 -1
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +49 -33
- package/src/renderers/webgpu/utils/WebGPUConstants.js +14 -3
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +56 -37
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +6 -8
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +266 -158
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +32 -9
- package/src/renderers/webgpu/utils/WebGPUUtils.js +24 -19
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +89 -13
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +14 -3
- package/src/textures/Texture.js +3 -2
- package/src/textures/VideoTexture.js +29 -2
- package/src/utils.js +67 -3
- package/examples/jsm/loaders/RGBMLoader.js +0 -1148
- package/examples/jsm/tsl/display/TRAAPassNode.js +0 -452
- package/src/nodes/utils/EquirectUVNode.js +0 -65
- package/src/nodes/utils/MatcapUVNode.js +0 -49
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -148
|
@@ -24,13 +24,16 @@ import ChainMap from '../../renderers/common/ChainMap.js';
|
|
|
24
24
|
|
|
25
25
|
import BindGroup from '../../renderers/common/BindGroup.js';
|
|
26
26
|
|
|
27
|
-
import { REVISION, IntType, UnsignedIntType, LinearFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, LinearMipmapLinearFilter } from '../../constants.js';
|
|
27
|
+
import { REVISION, IntType, UnsignedIntType, LinearFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, LinearMipmapLinearFilter, NormalBlending } from '../../constants.js';
|
|
28
28
|
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
29
29
|
import { Color } from '../../math/Color.js';
|
|
30
30
|
import { Vector2 } from '../../math/Vector2.js';
|
|
31
31
|
import { Vector3 } from '../../math/Vector3.js';
|
|
32
32
|
import { Vector4 } from '../../math/Vector4.js';
|
|
33
33
|
import { Float16BufferAttribute } from '../../core/BufferAttribute.js';
|
|
34
|
+
import { warn, error } from '../../utils.js';
|
|
35
|
+
|
|
36
|
+
let _id = 0;
|
|
34
37
|
|
|
35
38
|
const rendererCache = new WeakMap();
|
|
36
39
|
|
|
@@ -196,7 +199,7 @@ class NodeBuilder {
|
|
|
196
199
|
/**
|
|
197
200
|
* A reference to the current fog node.
|
|
198
201
|
*
|
|
199
|
-
* @type {?
|
|
202
|
+
* @type {?Node}
|
|
200
203
|
* @default null
|
|
201
204
|
*/
|
|
202
205
|
this.fogNode = null;
|
|
@@ -259,6 +262,13 @@ class NodeBuilder {
|
|
|
259
262
|
*/
|
|
260
263
|
this.structs = { vertex: [], fragment: [], compute: [], index: 0 };
|
|
261
264
|
|
|
265
|
+
/**
|
|
266
|
+
* This dictionary holds the types of the builder.
|
|
267
|
+
*
|
|
268
|
+
* @type {Object}
|
|
269
|
+
*/
|
|
270
|
+
this.types = { vertex: [], fragment: [], compute: [], index: 0 };
|
|
271
|
+
|
|
262
272
|
/**
|
|
263
273
|
* This dictionary holds the bindings for each shader stage.
|
|
264
274
|
*
|
|
@@ -419,6 +429,53 @@ class NodeBuilder {
|
|
|
419
429
|
*/
|
|
420
430
|
this.buildStage = null;
|
|
421
431
|
|
|
432
|
+
/**
|
|
433
|
+
* The sub-build layers.
|
|
434
|
+
*
|
|
435
|
+
* @type {Array<SubBuildNode>}
|
|
436
|
+
* @default []
|
|
437
|
+
*/
|
|
438
|
+
this.subBuildLayers = [];
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* The active stack nodes.
|
|
443
|
+
*
|
|
444
|
+
* @type {Array<StackNode>}
|
|
445
|
+
*/
|
|
446
|
+
this.activeStacks = [];
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* The current sub-build TSL function(Fn).
|
|
450
|
+
*
|
|
451
|
+
* @type {?string}
|
|
452
|
+
* @default null
|
|
453
|
+
*/
|
|
454
|
+
this.subBuildFn = null;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* The current TSL function(Fn) call node.
|
|
458
|
+
*
|
|
459
|
+
* @type {?Node}
|
|
460
|
+
* @default null
|
|
461
|
+
*/
|
|
462
|
+
this.fnCall = null;
|
|
463
|
+
|
|
464
|
+
Object.defineProperty( this, 'id', { value: _id ++ } );
|
|
465
|
+
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Whether the material is opaque or not.
|
|
470
|
+
*
|
|
471
|
+
* @return {boolean} Whether the material is opaque or not.
|
|
472
|
+
*/
|
|
473
|
+
isOpaque() {
|
|
474
|
+
|
|
475
|
+
const material = this.material;
|
|
476
|
+
|
|
477
|
+
return material.transparent === false && material.blending === NormalBlending && material.alphaToCoverage === false;
|
|
478
|
+
|
|
422
479
|
}
|
|
423
480
|
|
|
424
481
|
/**
|
|
@@ -698,7 +755,7 @@ class NodeBuilder {
|
|
|
698
755
|
|
|
699
756
|
if ( updateType !== NodeUpdateType.NONE ) {
|
|
700
757
|
|
|
701
|
-
this.updateNodes.push( node
|
|
758
|
+
this.updateNodes.push( node );
|
|
702
759
|
|
|
703
760
|
}
|
|
704
761
|
|
|
@@ -711,13 +768,13 @@ class NodeBuilder {
|
|
|
711
768
|
|
|
712
769
|
if ( updateBeforeType !== NodeUpdateType.NONE ) {
|
|
713
770
|
|
|
714
|
-
this.updateBeforeNodes.push( node
|
|
771
|
+
this.updateBeforeNodes.push( node );
|
|
715
772
|
|
|
716
773
|
}
|
|
717
774
|
|
|
718
775
|
if ( updateAfterType !== NodeUpdateType.NONE ) {
|
|
719
776
|
|
|
720
|
-
this.updateAfterNodes.push( node
|
|
777
|
+
this.updateAfterNodes.push( node );
|
|
721
778
|
|
|
722
779
|
}
|
|
723
780
|
|
|
@@ -761,7 +818,7 @@ class NodeBuilder {
|
|
|
761
818
|
/*
|
|
762
819
|
if ( this.chaining.indexOf( node ) !== - 1 ) {
|
|
763
820
|
|
|
764
|
-
|
|
821
|
+
warn( 'Recursive node: ', node );
|
|
765
822
|
|
|
766
823
|
}
|
|
767
824
|
*/
|
|
@@ -802,6 +859,22 @@ class NodeBuilder {
|
|
|
802
859
|
|
|
803
860
|
}
|
|
804
861
|
|
|
862
|
+
/**
|
|
863
|
+
* Returns the native snippet for a ternary operation. E.g. GLSL would output
|
|
864
|
+
* a ternary op as `cond ? x : y` whereas WGSL would output it as `select(y, x, cond)`
|
|
865
|
+
*
|
|
866
|
+
* @abstract
|
|
867
|
+
* @param {string} condSnippet - The condition determining which expression gets resolved.
|
|
868
|
+
* @param {string} ifSnippet - The expression to resolve to if the condition is true.
|
|
869
|
+
* @param {string} elseSnippet - The expression to resolve to if the condition is false.
|
|
870
|
+
* @return {string} The resolved method name.
|
|
871
|
+
*/
|
|
872
|
+
getTernary( /* condSnippet, ifSnippet, elseSnippet*/ ) {
|
|
873
|
+
|
|
874
|
+
return null;
|
|
875
|
+
|
|
876
|
+
}
|
|
877
|
+
|
|
805
878
|
/**
|
|
806
879
|
* Returns a node for the given hash, see {@link NodeBuilder#setHashNode}.
|
|
807
880
|
*
|
|
@@ -851,6 +924,22 @@ class NodeBuilder {
|
|
|
851
924
|
|
|
852
925
|
}
|
|
853
926
|
|
|
927
|
+
/**
|
|
928
|
+
* Adds context data to the builder's current context.
|
|
929
|
+
*
|
|
930
|
+
* @param {Object} context - The context to add.
|
|
931
|
+
* @return {Object} The previous context.
|
|
932
|
+
*/
|
|
933
|
+
addContext( context ) {
|
|
934
|
+
|
|
935
|
+
const previousContext = this.getContext();
|
|
936
|
+
|
|
937
|
+
this.setContext( { ...this.context, ...context } );
|
|
938
|
+
|
|
939
|
+
return previousContext;
|
|
940
|
+
|
|
941
|
+
}
|
|
942
|
+
|
|
854
943
|
/**
|
|
855
944
|
* Gets a context used in shader construction that can be shared across different materials.
|
|
856
945
|
* This is necessary since the renderer cache can reuse shaders generated in one material and use them in another.
|
|
@@ -926,19 +1015,20 @@ class NodeBuilder {
|
|
|
926
1015
|
*/
|
|
927
1016
|
getVertexIndex() {
|
|
928
1017
|
|
|
929
|
-
|
|
1018
|
+
warn( 'Abstract function.' );
|
|
930
1019
|
|
|
931
1020
|
}
|
|
932
1021
|
|
|
933
1022
|
/**
|
|
934
|
-
*
|
|
1023
|
+
* Contextually returns either the vertex stage instance index builtin
|
|
1024
|
+
* or the linearized index of an compute invocation within a grid of workgroups.
|
|
935
1025
|
*
|
|
936
1026
|
* @abstract
|
|
937
1027
|
* @return {string} The instanceIndex shader string.
|
|
938
1028
|
*/
|
|
939
1029
|
getInstanceIndex() {
|
|
940
1030
|
|
|
941
|
-
|
|
1031
|
+
warn( 'Abstract function.' );
|
|
942
1032
|
|
|
943
1033
|
}
|
|
944
1034
|
|
|
@@ -951,7 +1041,7 @@ class NodeBuilder {
|
|
|
951
1041
|
*/
|
|
952
1042
|
getDrawIndex() {
|
|
953
1043
|
|
|
954
|
-
|
|
1044
|
+
warn( 'Abstract function.' );
|
|
955
1045
|
|
|
956
1046
|
}
|
|
957
1047
|
|
|
@@ -963,7 +1053,7 @@ class NodeBuilder {
|
|
|
963
1053
|
*/
|
|
964
1054
|
getFrontFacing() {
|
|
965
1055
|
|
|
966
|
-
|
|
1056
|
+
warn( 'Abstract function.' );
|
|
967
1057
|
|
|
968
1058
|
}
|
|
969
1059
|
|
|
@@ -975,7 +1065,7 @@ class NodeBuilder {
|
|
|
975
1065
|
*/
|
|
976
1066
|
getFragCoord() {
|
|
977
1067
|
|
|
978
|
-
|
|
1068
|
+
warn( 'Abstract function.' );
|
|
979
1069
|
|
|
980
1070
|
}
|
|
981
1071
|
|
|
@@ -1018,7 +1108,7 @@ class NodeBuilder {
|
|
|
1018
1108
|
*/
|
|
1019
1109
|
generateTexture( /* texture, textureProperty, uvSnippet */ ) {
|
|
1020
1110
|
|
|
1021
|
-
|
|
1111
|
+
warn( 'Abstract function.' );
|
|
1022
1112
|
|
|
1023
1113
|
}
|
|
1024
1114
|
|
|
@@ -1035,7 +1125,7 @@ class NodeBuilder {
|
|
|
1035
1125
|
*/
|
|
1036
1126
|
generateTextureLod( /* texture, textureProperty, uvSnippet, depthSnippet, levelSnippet */ ) {
|
|
1037
1127
|
|
|
1038
|
-
|
|
1128
|
+
warn( 'Abstract function.' );
|
|
1039
1129
|
|
|
1040
1130
|
}
|
|
1041
1131
|
|
|
@@ -1120,7 +1210,6 @@ class NodeBuilder {
|
|
|
1120
1210
|
|
|
1121
1211
|
}
|
|
1122
1212
|
|
|
1123
|
-
|
|
1124
1213
|
/**
|
|
1125
1214
|
* Generates the shader string for the given type and value.
|
|
1126
1215
|
*
|
|
@@ -1520,6 +1609,58 @@ class NodeBuilder {
|
|
|
1520
1609
|
|
|
1521
1610
|
}
|
|
1522
1611
|
|
|
1612
|
+
/**
|
|
1613
|
+
* Adds an active stack to the internal stack.
|
|
1614
|
+
*
|
|
1615
|
+
* @param {StackNode} stack - The stack node to add.
|
|
1616
|
+
*/
|
|
1617
|
+
setActiveStack( stack ) {
|
|
1618
|
+
|
|
1619
|
+
this.activeStacks.push( stack );
|
|
1620
|
+
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
/**
|
|
1624
|
+
* Removes the active stack from the internal stack.
|
|
1625
|
+
*
|
|
1626
|
+
* @param {StackNode} stack - The stack node to remove.
|
|
1627
|
+
*/
|
|
1628
|
+
removeActiveStack( stack ) {
|
|
1629
|
+
|
|
1630
|
+
if ( this.activeStacks[ this.activeStacks.length - 1 ] === stack ) {
|
|
1631
|
+
|
|
1632
|
+
this.activeStacks.pop();
|
|
1633
|
+
|
|
1634
|
+
} else {
|
|
1635
|
+
|
|
1636
|
+
throw new Error( 'NodeBuilder: Invalid active stack removal.' );
|
|
1637
|
+
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
/**
|
|
1643
|
+
* Returns the active stack.
|
|
1644
|
+
*
|
|
1645
|
+
* @return {StackNode} The active stack.
|
|
1646
|
+
*/
|
|
1647
|
+
getActiveStack() {
|
|
1648
|
+
|
|
1649
|
+
return this.activeStacks[ this.activeStacks.length - 1 ];
|
|
1650
|
+
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
/**
|
|
1654
|
+
* Returns the base stack.
|
|
1655
|
+
*
|
|
1656
|
+
* @return {StackNode} The base stack.
|
|
1657
|
+
*/
|
|
1658
|
+
getBaseStack() {
|
|
1659
|
+
|
|
1660
|
+
return this.activeStacks[ 0 ];
|
|
1661
|
+
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1523
1664
|
/**
|
|
1524
1665
|
* Adds a stack node to the internal stack.
|
|
1525
1666
|
*
|
|
@@ -1529,7 +1670,9 @@ class NodeBuilder {
|
|
|
1529
1670
|
|
|
1530
1671
|
this.stack = stack( this.stack );
|
|
1531
1672
|
|
|
1532
|
-
|
|
1673
|
+
const previousStack = getCurrentStack();
|
|
1674
|
+
|
|
1675
|
+
this.stacks.push( previousStack );
|
|
1533
1676
|
setCurrentStack( this.stack );
|
|
1534
1677
|
|
|
1535
1678
|
return this.stack;
|
|
@@ -1544,6 +1687,14 @@ class NodeBuilder {
|
|
|
1544
1687
|
removeStack() {
|
|
1545
1688
|
|
|
1546
1689
|
const lastStack = this.stack;
|
|
1690
|
+
|
|
1691
|
+
for ( const node of lastStack.nodes ) {
|
|
1692
|
+
|
|
1693
|
+
const nodeData = this.getDataFromNode( node );
|
|
1694
|
+
nodeData.stack = lastStack;
|
|
1695
|
+
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1547
1698
|
this.stack = lastStack.parent;
|
|
1548
1699
|
|
|
1549
1700
|
setCurrentStack( this.stacks.pop() );
|
|
@@ -1577,13 +1728,34 @@ class NodeBuilder {
|
|
|
1577
1728
|
|
|
1578
1729
|
if ( nodeData[ shaderStage ] === undefined ) nodeData[ shaderStage ] = {};
|
|
1579
1730
|
|
|
1580
|
-
|
|
1731
|
+
//
|
|
1732
|
+
|
|
1733
|
+
let data = nodeData[ shaderStage ];
|
|
1734
|
+
|
|
1735
|
+
const subBuilds = nodeData.any ? nodeData.any.subBuilds : null;
|
|
1736
|
+
const subBuild = this.getClosestSubBuild( subBuilds );
|
|
1737
|
+
|
|
1738
|
+
if ( subBuild ) {
|
|
1739
|
+
|
|
1740
|
+
if ( data.subBuildsCache === undefined ) data.subBuildsCache = {};
|
|
1741
|
+
|
|
1742
|
+
data = data.subBuildsCache[ subBuild ] || ( data.subBuildsCache[ subBuild ] = {} );
|
|
1743
|
+
data.subBuilds = subBuilds;
|
|
1744
|
+
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
return data;
|
|
1581
1748
|
|
|
1582
1749
|
}
|
|
1583
1750
|
|
|
1584
1751
|
/**
|
|
1585
1752
|
* Returns the properties for the given node and shader stage.
|
|
1586
1753
|
*
|
|
1754
|
+
* Properties are typically used within a build stage to reference a node's
|
|
1755
|
+
* child node or nodes manually assigned to the properties in a separate build stage.
|
|
1756
|
+
* A typical usage pattern for defining nodes manually would be assigning dependency nodes
|
|
1757
|
+
* to the current node's properties in the setup stage and building those properties in the generate stage.
|
|
1758
|
+
*
|
|
1587
1759
|
* @param {Node} node - The node to get the properties for.
|
|
1588
1760
|
* @param {('vertex'|'fragment'|'compute'|'any')} [shaderStage='any'] - The shader stage.
|
|
1589
1761
|
* @return {Object} The node properties.
|
|
@@ -1625,6 +1797,20 @@ class NodeBuilder {
|
|
|
1625
1797
|
|
|
1626
1798
|
}
|
|
1627
1799
|
|
|
1800
|
+
/**
|
|
1801
|
+
* Returns an instance of {@link StructType} for the given struct name and shader stage
|
|
1802
|
+
* or null if not found.
|
|
1803
|
+
*
|
|
1804
|
+
* @param {string} name - The name of the struct.
|
|
1805
|
+
* @param {('vertex'|'fragment'|'compute'|'any')} [shaderStage=this.shaderStage] - The shader stage.
|
|
1806
|
+
* @return {?StructType} The struct type or null if not found.
|
|
1807
|
+
*/
|
|
1808
|
+
getStructTypeNode( name, shaderStage = this.shaderStage ) {
|
|
1809
|
+
|
|
1810
|
+
return this.types[ shaderStage ][ name ] || null;
|
|
1811
|
+
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1628
1814
|
/**
|
|
1629
1815
|
* Returns an instance of {@link StructType} for the given output struct node.
|
|
1630
1816
|
*
|
|
@@ -1649,6 +1835,7 @@ class NodeBuilder {
|
|
|
1649
1835
|
structType = new StructType( name, membersLayout );
|
|
1650
1836
|
|
|
1651
1837
|
this.structs[ shaderStage ].push( structType );
|
|
1838
|
+
this.types[ shaderStage ][ name ] = node;
|
|
1652
1839
|
|
|
1653
1840
|
nodeData.structType = structType;
|
|
1654
1841
|
|
|
@@ -1707,23 +1894,6 @@ class NodeBuilder {
|
|
|
1707
1894
|
|
|
1708
1895
|
}
|
|
1709
1896
|
|
|
1710
|
-
/**
|
|
1711
|
-
* Returns the array length.
|
|
1712
|
-
*
|
|
1713
|
-
* @param {Node} node - The node.
|
|
1714
|
-
* @return {?number} The array length.
|
|
1715
|
-
*/
|
|
1716
|
-
getArrayCount( node ) {
|
|
1717
|
-
|
|
1718
|
-
let count = null;
|
|
1719
|
-
|
|
1720
|
-
if ( node.isArrayNode ) count = node.count;
|
|
1721
|
-
else if ( node.isVarNode && node.node.isArrayNode ) count = node.node.count;
|
|
1722
|
-
|
|
1723
|
-
return count;
|
|
1724
|
-
|
|
1725
|
-
}
|
|
1726
|
-
|
|
1727
1897
|
/**
|
|
1728
1898
|
* Returns an instance of {@link NodeVar} for the given variable node.
|
|
1729
1899
|
*
|
|
@@ -1738,8 +1908,9 @@ class NodeBuilder {
|
|
|
1738
1908
|
getVarFromNode( node, name = null, type = node.getNodeType( this ), shaderStage = this.shaderStage, readOnly = false ) {
|
|
1739
1909
|
|
|
1740
1910
|
const nodeData = this.getDataFromNode( node, shaderStage );
|
|
1911
|
+
const subBuildVariable = this.getSubBuildProperty( 'variable', nodeData.subBuilds );
|
|
1741
1912
|
|
|
1742
|
-
let nodeVar = nodeData
|
|
1913
|
+
let nodeVar = nodeData[ subBuildVariable ];
|
|
1743
1914
|
|
|
1744
1915
|
if ( nodeVar === undefined ) {
|
|
1745
1916
|
|
|
@@ -1758,7 +1929,15 @@ class NodeBuilder {
|
|
|
1758
1929
|
|
|
1759
1930
|
//
|
|
1760
1931
|
|
|
1761
|
-
|
|
1932
|
+
if ( subBuildVariable !== 'variable' ) {
|
|
1933
|
+
|
|
1934
|
+
name = this.getSubBuildProperty( name, nodeData.subBuilds );
|
|
1935
|
+
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
//
|
|
1939
|
+
|
|
1940
|
+
const count = node.getArrayCount( this );
|
|
1762
1941
|
|
|
1763
1942
|
nodeVar = new NodeVar( name, type, readOnly, count );
|
|
1764
1943
|
|
|
@@ -1770,7 +1949,7 @@ class NodeBuilder {
|
|
|
1770
1949
|
|
|
1771
1950
|
this.registerDeclaration( nodeVar );
|
|
1772
1951
|
|
|
1773
|
-
nodeData
|
|
1952
|
+
nodeData[ subBuildVariable ] = nodeVar;
|
|
1774
1953
|
|
|
1775
1954
|
}
|
|
1776
1955
|
|
|
@@ -1838,8 +2017,9 @@ class NodeBuilder {
|
|
|
1838
2017
|
getVaryingFromNode( node, name = null, type = node.getNodeType( this ), interpolationType = null, interpolationSampling = null ) {
|
|
1839
2018
|
|
|
1840
2019
|
const nodeData = this.getDataFromNode( node, 'any' );
|
|
2020
|
+
const subBuildVarying = this.getSubBuildProperty( 'varying', nodeData.subBuilds );
|
|
1841
2021
|
|
|
1842
|
-
let nodeVarying = nodeData
|
|
2022
|
+
let nodeVarying = nodeData[ subBuildVarying ];
|
|
1843
2023
|
|
|
1844
2024
|
if ( nodeVarying === undefined ) {
|
|
1845
2025
|
|
|
@@ -1848,69 +2028,27 @@ class NodeBuilder {
|
|
|
1848
2028
|
|
|
1849
2029
|
if ( name === null ) name = 'nodeVarying' + index;
|
|
1850
2030
|
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
varyings.push( nodeVarying );
|
|
1854
|
-
|
|
1855
|
-
this.registerDeclaration( nodeVarying );
|
|
1856
|
-
|
|
1857
|
-
nodeData.varying = nodeVarying;
|
|
1858
|
-
|
|
1859
|
-
}
|
|
1860
|
-
|
|
1861
|
-
return nodeVarying;
|
|
1862
|
-
|
|
1863
|
-
}
|
|
1864
|
-
|
|
1865
|
-
/**
|
|
1866
|
-
* Returns the current namespace for the node builder.
|
|
1867
|
-
*
|
|
1868
|
-
* @return {string} The current namespace.
|
|
1869
|
-
*/
|
|
1870
|
-
get namespace() {
|
|
1871
|
-
|
|
1872
|
-
return this.context.namespace;
|
|
1873
|
-
|
|
1874
|
-
}
|
|
1875
|
-
|
|
1876
|
-
/**
|
|
1877
|
-
* Returns the output namespace for the node builder, which is used for the current output node.
|
|
1878
|
-
*
|
|
1879
|
-
* @return {string} The output namespace.
|
|
1880
|
-
*/
|
|
1881
|
-
getOutputNamespace() {
|
|
1882
|
-
|
|
1883
|
-
return this.getNamespace( 'outputNode' );
|
|
2031
|
+
//
|
|
1884
2032
|
|
|
1885
|
-
|
|
2033
|
+
if ( subBuildVarying !== 'varying' ) {
|
|
1886
2034
|
|
|
1887
|
-
|
|
1888
|
-
* Returns the namespace for the given property.
|
|
1889
|
-
*
|
|
1890
|
-
* If the property name is not set, it returns the namespace only.
|
|
1891
|
-
* If the namespace is not set, it returns the property name.
|
|
1892
|
-
* If the namespace is set, it returns the namespace concatenated with the property name.
|
|
1893
|
-
*
|
|
1894
|
-
* @param {string} [property=''] - The property name.
|
|
1895
|
-
* @return {string} The namespace for the property.
|
|
1896
|
-
*/
|
|
1897
|
-
getNamespace( property = '' ) {
|
|
2035
|
+
name = this.getSubBuildProperty( name, nodeData.subBuilds );
|
|
1898
2036
|
|
|
1899
|
-
|
|
2037
|
+
}
|
|
1900
2038
|
|
|
1901
|
-
|
|
2039
|
+
//
|
|
1902
2040
|
|
|
1903
|
-
|
|
2041
|
+
nodeVarying = new NodeVarying( name, type, interpolationType, interpolationSampling );
|
|
1904
2042
|
|
|
1905
|
-
|
|
2043
|
+
varyings.push( nodeVarying );
|
|
1906
2044
|
|
|
1907
|
-
|
|
2045
|
+
this.registerDeclaration( nodeVarying );
|
|
1908
2046
|
|
|
1909
|
-
|
|
2047
|
+
nodeData[ subBuildVarying ] = nodeVarying;
|
|
1910
2048
|
|
|
1911
2049
|
}
|
|
1912
2050
|
|
|
1913
|
-
return
|
|
2051
|
+
return nodeVarying;
|
|
1914
2052
|
|
|
1915
2053
|
}
|
|
1916
2054
|
|
|
@@ -1941,7 +2079,7 @@ class NodeBuilder {
|
|
|
1941
2079
|
|
|
1942
2080
|
node.name = name;
|
|
1943
2081
|
|
|
1944
|
-
|
|
2082
|
+
warn( `TSL: Declaration name '${ property }' of '${ node.type }' already in use. Renamed to '${ name }'.` );
|
|
1945
2083
|
|
|
1946
2084
|
}
|
|
1947
2085
|
|
|
@@ -2225,6 +2363,34 @@ class NodeBuilder {
|
|
|
2225
2363
|
|
|
2226
2364
|
}
|
|
2227
2365
|
|
|
2366
|
+
/**
|
|
2367
|
+
* Executes the node in a specific build stage.
|
|
2368
|
+
*
|
|
2369
|
+
* This function can be used to arbitrarily execute the specified build stage
|
|
2370
|
+
* outside of the standard build process. For instance, if a node's type depends
|
|
2371
|
+
* on properties created by the 'setup' stage, then flowBuildStage(node, 'setup')
|
|
2372
|
+
* can be used to execute the setup build stage and access its generated nodes
|
|
2373
|
+
* before the standard build process begins.
|
|
2374
|
+
*
|
|
2375
|
+
* @param {Node} node - The node to execute.
|
|
2376
|
+
* @param {string} buildStage - The build stage to execute the node in.
|
|
2377
|
+
* @param {?(Node|string)} [output=null] - Expected output type. For example 'vec3'.
|
|
2378
|
+
* @return {?(Node|string)} The result of the node build.
|
|
2379
|
+
*/
|
|
2380
|
+
flowBuildStage( node, buildStage, output = null ) {
|
|
2381
|
+
|
|
2382
|
+
const previousBuildStage = this.getBuildStage();
|
|
2383
|
+
|
|
2384
|
+
this.setBuildStage( buildStage );
|
|
2385
|
+
|
|
2386
|
+
const result = node.build( this, output );
|
|
2387
|
+
|
|
2388
|
+
this.setBuildStage( previousBuildStage );
|
|
2389
|
+
|
|
2390
|
+
return result;
|
|
2391
|
+
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2228
2394
|
/**
|
|
2229
2395
|
* Runs the node flow through all the steps of creation, 'setup', 'analyze', 'generate'.
|
|
2230
2396
|
*
|
|
@@ -2296,7 +2462,7 @@ class NodeBuilder {
|
|
|
2296
2462
|
*/
|
|
2297
2463
|
buildFunctionCode( /* shaderNode */ ) {
|
|
2298
2464
|
|
|
2299
|
-
|
|
2465
|
+
warn( 'Abstract function.' );
|
|
2300
2466
|
|
|
2301
2467
|
}
|
|
2302
2468
|
|
|
@@ -2335,7 +2501,7 @@ class NodeBuilder {
|
|
|
2335
2501
|
* @param {Node} node - The node to execute.
|
|
2336
2502
|
* @param {?string} output - Expected output type. For example 'vec3'.
|
|
2337
2503
|
* @param {?string} propertyName - The property name to assign the result.
|
|
2338
|
-
* @return {Object|Node
|
|
2504
|
+
* @return {?(Object|Node)} The code flow or node.build() result.
|
|
2339
2505
|
*/
|
|
2340
2506
|
flowNodeFromShaderStage( shaderStage, node, output = null, propertyName = null ) {
|
|
2341
2507
|
|
|
@@ -2405,7 +2571,7 @@ class NodeBuilder {
|
|
|
2405
2571
|
*/
|
|
2406
2572
|
getAttributes( /*shaderStage*/ ) {
|
|
2407
2573
|
|
|
2408
|
-
|
|
2574
|
+
warn( 'Abstract function.' );
|
|
2409
2575
|
|
|
2410
2576
|
}
|
|
2411
2577
|
|
|
@@ -2418,7 +2584,7 @@ class NodeBuilder {
|
|
|
2418
2584
|
*/
|
|
2419
2585
|
getVaryings( /*shaderStage*/ ) {
|
|
2420
2586
|
|
|
2421
|
-
|
|
2587
|
+
warn( 'Abstract function.' );
|
|
2422
2588
|
|
|
2423
2589
|
}
|
|
2424
2590
|
|
|
@@ -2471,7 +2637,7 @@ class NodeBuilder {
|
|
|
2471
2637
|
*/
|
|
2472
2638
|
getUniforms( /*shaderStage*/ ) {
|
|
2473
2639
|
|
|
2474
|
-
|
|
2640
|
+
warn( 'Abstract function.' );
|
|
2475
2641
|
|
|
2476
2642
|
}
|
|
2477
2643
|
|
|
@@ -2563,7 +2729,146 @@ class NodeBuilder {
|
|
|
2563
2729
|
*/
|
|
2564
2730
|
buildCode() {
|
|
2565
2731
|
|
|
2566
|
-
|
|
2732
|
+
warn( 'Abstract function.' );
|
|
2733
|
+
|
|
2734
|
+
}
|
|
2735
|
+
|
|
2736
|
+
/**
|
|
2737
|
+
* Returns the current sub-build layer.
|
|
2738
|
+
*
|
|
2739
|
+
* @return {SubBuildNode} The current sub-build layers.
|
|
2740
|
+
*/
|
|
2741
|
+
get subBuild() {
|
|
2742
|
+
|
|
2743
|
+
return this.subBuildLayers[ this.subBuildLayers.length - 1 ] || null;
|
|
2744
|
+
|
|
2745
|
+
}
|
|
2746
|
+
|
|
2747
|
+
/**
|
|
2748
|
+
* Adds a sub-build layer to the node builder.
|
|
2749
|
+
*
|
|
2750
|
+
* @param {SubBuildNode} subBuild - The sub-build layer to add.
|
|
2751
|
+
*/
|
|
2752
|
+
addSubBuild( subBuild ) {
|
|
2753
|
+
|
|
2754
|
+
this.subBuildLayers.push( subBuild );
|
|
2755
|
+
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
/**
|
|
2759
|
+
* Removes the last sub-build layer from the node builder.
|
|
2760
|
+
*
|
|
2761
|
+
* @return {SubBuildNode} The removed sub-build layer.
|
|
2762
|
+
*/
|
|
2763
|
+
removeSubBuild() {
|
|
2764
|
+
|
|
2765
|
+
return this.subBuildLayers.pop();
|
|
2766
|
+
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2769
|
+
/**
|
|
2770
|
+
* Returns the closest sub-build layer for the given data.
|
|
2771
|
+
*
|
|
2772
|
+
* @param {Node|Set<string>|Array<string>} data - The data to get the closest sub-build layer from.
|
|
2773
|
+
* @return {?string} The closest sub-build name or null if none found.
|
|
2774
|
+
*/
|
|
2775
|
+
getClosestSubBuild( data ) {
|
|
2776
|
+
|
|
2777
|
+
let subBuilds;
|
|
2778
|
+
|
|
2779
|
+
if ( data && data.isNode ) {
|
|
2780
|
+
|
|
2781
|
+
if ( data.isShaderCallNodeInternal ) {
|
|
2782
|
+
|
|
2783
|
+
subBuilds = data.shaderNode.subBuilds;
|
|
2784
|
+
|
|
2785
|
+
} else if ( data.isStackNode ) {
|
|
2786
|
+
|
|
2787
|
+
subBuilds = [ data.subBuild ];
|
|
2788
|
+
|
|
2789
|
+
} else {
|
|
2790
|
+
|
|
2791
|
+
subBuilds = this.getDataFromNode( data, 'any' ).subBuilds;
|
|
2792
|
+
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
} else if ( data instanceof Set ) {
|
|
2796
|
+
|
|
2797
|
+
subBuilds = [ ...data ];
|
|
2798
|
+
|
|
2799
|
+
} else {
|
|
2800
|
+
|
|
2801
|
+
subBuilds = data;
|
|
2802
|
+
|
|
2803
|
+
}
|
|
2804
|
+
|
|
2805
|
+
if ( ! subBuilds ) return null;
|
|
2806
|
+
|
|
2807
|
+
const subBuildLayers = this.subBuildLayers;
|
|
2808
|
+
|
|
2809
|
+
for ( let i = subBuilds.length - 1; i >= 0; i -- ) {
|
|
2810
|
+
|
|
2811
|
+
const subBuild = subBuilds[ i ];
|
|
2812
|
+
|
|
2813
|
+
if ( subBuildLayers.includes( subBuild ) ) {
|
|
2814
|
+
|
|
2815
|
+
return subBuild;
|
|
2816
|
+
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2821
|
+
return null;
|
|
2822
|
+
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
|
|
2826
|
+
/**
|
|
2827
|
+
* Returns the output node of a sub-build layer.
|
|
2828
|
+
*
|
|
2829
|
+
* @param {Node} node - The node to get the output from.
|
|
2830
|
+
* @return {string} The output node name.
|
|
2831
|
+
*/
|
|
2832
|
+
getSubBuildOutput( node ) {
|
|
2833
|
+
|
|
2834
|
+
return this.getSubBuildProperty( 'outputNode', node );
|
|
2835
|
+
|
|
2836
|
+
}
|
|
2837
|
+
|
|
2838
|
+
/**
|
|
2839
|
+
* Returns the sub-build property name for the given property and node.
|
|
2840
|
+
*
|
|
2841
|
+
* @param {string} [property=''] - The property name.
|
|
2842
|
+
* @param {?Node} [node=null] - The node to get the sub-build from.
|
|
2843
|
+
* @return {string} The sub-build property name.
|
|
2844
|
+
*/
|
|
2845
|
+
getSubBuildProperty( property = '', node = null ) {
|
|
2846
|
+
|
|
2847
|
+
let subBuild;
|
|
2848
|
+
|
|
2849
|
+
if ( node !== null ) {
|
|
2850
|
+
|
|
2851
|
+
subBuild = this.getClosestSubBuild( node );
|
|
2852
|
+
|
|
2853
|
+
} else {
|
|
2854
|
+
|
|
2855
|
+
subBuild = this.subBuildFn;
|
|
2856
|
+
|
|
2857
|
+
}
|
|
2858
|
+
|
|
2859
|
+
let result;
|
|
2860
|
+
|
|
2861
|
+
if ( subBuild ) {
|
|
2862
|
+
|
|
2863
|
+
result = property ? ( subBuild + '_' + property ) : subBuild;
|
|
2864
|
+
|
|
2865
|
+
} else {
|
|
2866
|
+
|
|
2867
|
+
result = property;
|
|
2868
|
+
|
|
2869
|
+
}
|
|
2870
|
+
|
|
2871
|
+
return result;
|
|
2567
2872
|
|
|
2568
2873
|
}
|
|
2569
2874
|
|
|
@@ -2582,7 +2887,7 @@ class NodeBuilder {
|
|
|
2582
2887
|
|
|
2583
2888
|
if ( nodeMaterial === null ) {
|
|
2584
2889
|
|
|
2585
|
-
|
|
2890
|
+
error( `NodeMaterial: Material "${ material.type }" is not compatible.` );
|
|
2586
2891
|
|
|
2587
2892
|
nodeMaterial = new NodeMaterial();
|
|
2588
2893
|
|
|
@@ -2596,7 +2901,7 @@ class NodeBuilder {
|
|
|
2596
2901
|
|
|
2597
2902
|
}
|
|
2598
2903
|
|
|
2599
|
-
// setup() -> stage 1: create possible new nodes and
|
|
2904
|
+
// setup() -> stage 1: create possible new nodes and/or return an output reference node
|
|
2600
2905
|
// analyze() -> stage 2: analyze nodes to possible optimization and validation
|
|
2601
2906
|
// generate() -> stage 3: generate shader
|
|
2602
2907
|
|
|
@@ -2771,27 +3076,6 @@ class NodeBuilder {
|
|
|
2771
3076
|
|
|
2772
3077
|
}
|
|
2773
3078
|
|
|
2774
|
-
/**
|
|
2775
|
-
* Prevents the node builder from being used as an iterable in TSL.Fn(), avoiding potential runtime errors.
|
|
2776
|
-
*/
|
|
2777
|
-
*[ Symbol.iterator ]() { }
|
|
2778
|
-
|
|
2779
|
-
// Deprecated
|
|
2780
|
-
|
|
2781
|
-
/**
|
|
2782
|
-
* @function
|
|
2783
|
-
* @deprecated since r168. Use `new NodeMaterial()` instead, with targeted node material name.
|
|
2784
|
-
*
|
|
2785
|
-
* @param {string} [type='NodeMaterial'] - The node material type.
|
|
2786
|
-
* @throws {Error}
|
|
2787
|
-
*/
|
|
2788
|
-
createNodeMaterial( type = 'NodeMaterial' ) { // @deprecated, r168
|
|
2789
|
-
|
|
2790
|
-
throw new Error( `THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${ type }() instead.` );
|
|
2791
|
-
|
|
2792
|
-
}
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
3079
|
}
|
|
2796
3080
|
|
|
2797
3081
|
export default NodeBuilder;
|