@plastic-software/three 0.179.0 → 0.181.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +1108 -591
- package/build/three.core.js +616 -345
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +488 -250
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +37 -6
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +6576 -2152
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +6575 -2151
- 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 +1 -1
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +8 -8
- 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 +1 -1
- package/examples/jsm/effects/AsciiEffect.js +8 -8
- 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 +9 -2
- package/examples/jsm/geometries/DecalGeometry.js +2 -2
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- 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 +6 -10
- 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/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 +3 -3
- package/examples/jsm/loaders/DDSLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +73 -22
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- 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 +22 -5
- 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 +4 -4
- package/examples/jsm/loaders/UltraHDRLoader.js +2 -2
- package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
- 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/ReflectorForSSRPass.js +1 -0
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/SkyMesh.js +1 -1
- package/examples/jsm/objects/Water.js +3 -3
- package/examples/jsm/objects/WaterMesh.js +6 -6
- package/examples/jsm/postprocessing/GlitchPass.js +2 -2
- package/examples/jsm/postprocessing/OutlinePass.js +1 -1
- 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 +1 -1
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +22 -19
- package/examples/jsm/transpiler/TSLEncoder.js +9 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +24 -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 +7 -3
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
- 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 +49 -35
- package/examples/jsm/tsl/display/OutlineNode.js +13 -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 +124 -7
- package/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/examples/jsm/tsl/display/hashBlur.js +16 -18
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +21 -1
- 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 +4 -2
- package/src/Three.TSL.js +36 -5
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +2 -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 +7 -6
- package/src/animation/PropertyBinding.js +12 -11
- package/src/audio/Audio.js +10 -9
- package/src/audio/PositionalAudio.js +1 -1
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +11 -3
- package/src/core/BufferGeometry.js +10 -10
- package/src/core/EventDispatcher.js +1 -1
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +3 -2
- package/src/core/Object3D.js +3 -2
- package/src/core/Raycaster.js +2 -1
- package/src/core/RenderTarget.js +10 -1
- 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 +268 -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/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 +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 +3 -2
- package/src/loaders/ImageBitmapLoader.js +5 -4
- package/src/loaders/ImageLoader.js +1 -1
- package/src/loaders/Loader.js +3 -3
- package/src/loaders/LoadingManager.js +25 -3
- 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 +1 -0
- 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 -2
- package/src/materials/nodes/MeshSSSNodeMaterial.js +1 -1
- package/src/materials/nodes/NodeMaterial.js +62 -22
- package/src/materials/nodes/PointsNodeMaterial.js +81 -28
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
- package/src/materials/nodes/manager/NodeMaterialObserver.js +3 -2
- 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/MathUtils.js +13 -11
- package/src/math/Matrix2.js +1 -1
- package/src/math/Matrix3.js +2 -2
- package/src/math/Matrix4.js +7 -7
- package/src/math/Plane.js +1 -1
- package/src/math/Quaternion.js +68 -66
- package/src/math/Spherical.js +1 -1
- package/src/nodes/Nodes.js +4 -1
- package/src/nodes/TSL.js +4 -1
- package/src/nodes/accessors/BufferNode.js +1 -1
- package/src/nodes/accessors/Camera.js +133 -7
- 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 +5 -4
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/Position.js +18 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +3 -2
- package/src/nodes/accessors/SceneNode.js +2 -1
- package/src/nodes/accessors/StorageBufferNode.js +2 -1
- package/src/nodes/accessors/StorageTextureNode.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +14 -1
- package/src/nodes/accessors/TextureNode.js +130 -44
- package/src/nodes/code/FunctionCallNode.js +24 -4
- package/src/nodes/code/FunctionNode.js +23 -0
- package/src/nodes/core/ArrayNode.js +1 -0
- package/src/nodes/core/AssignNode.js +4 -3
- package/src/nodes/core/AttributeNode.js +2 -1
- package/src/nodes/core/ContextNode.js +29 -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} +40 -7
- package/src/nodes/core/Node.js +152 -31
- package/src/nodes/core/NodeBuilder.js +183 -35
- 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 -91
- package/src/nodes/core/ParameterNode.js +31 -0
- package/src/nodes/core/PropertyNode.js +7 -0
- package/src/nodes/core/StackNode.js +43 -16
- package/src/nodes/core/StructNode.js +5 -5
- package/src/nodes/core/StructTypeNode.js +1 -0
- package/src/nodes/core/SubBuildNode.js +2 -2
- package/src/nodes/core/UniformNode.js +18 -10
- package/src/nodes/core/VarNode.js +70 -33
- package/src/nodes/core/VaryingNode.js +3 -2
- package/src/nodes/display/BlendModes.js +5 -4
- package/src/nodes/display/BumpMapNode.js +1 -1
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/FrontFacingNode.js +4 -8
- package/src/nodes/display/NormalMapNode.js +2 -1
- package/src/nodes/display/PassNode.js +52 -11
- package/src/nodes/display/RenderOutputNode.js +28 -2
- package/src/nodes/display/ScreenNode.js +44 -14
- 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 +42 -12
- package/src/nodes/fog/Fog.js +3 -2
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/DFGApprox.js +60 -19
- package/src/nodes/functions/BasicLightingModel.js +2 -1
- package/src/nodes/functions/PhysicalLightingModel.js +3 -2
- package/src/nodes/functions/VolumetricLightingModel.js +5 -5
- package/src/nodes/geometry/RangeNode.js +40 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -1
- package/src/nodes/gpgpu/ComputeNode.js +17 -5
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
- package/src/nodes/lighting/EnvironmentNode.js +6 -6
- package/src/nodes/lighting/LightsNode.js +3 -4
- package/src/nodes/lighting/PointShadowNode.js +6 -0
- package/src/nodes/lighting/ShadowFilterNode.js +2 -0
- package/src/nodes/lighting/ShadowNode.js +75 -8
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/ConditionalNode.js +24 -7
- package/src/nodes/math/MathNode.js +25 -19
- package/src/nodes/math/OperatorNode.js +7 -5
- package/src/nodes/pmrem/PMREMUtils.js +117 -2
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLBase.js +5 -2
- package/src/nodes/tsl/TSLCore.js +460 -159
- package/src/nodes/utils/DebugNode.js +2 -1
- package/src/nodes/utils/EventNode.js +36 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +37 -19
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +20 -24
- package/src/nodes/utils/MemberNode.js +59 -7
- package/src/nodes/utils/PostProcessingUtils.js +28 -1
- package/src/nodes/utils/RTTNode.js +13 -3
- package/src/nodes/utils/ReflectorNode.js +58 -7
- package/src/nodes/utils/SampleNode.js +12 -2
- package/src/nodes/utils/SplitNode.js +11 -0
- package/src/nodes/utils/Timer.js +0 -47
- package/src/objects/BatchedMesh.js +2 -2
- 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 +48 -41
- 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 +2 -1
- package/src/renderers/common/Bindings.js +58 -2
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/ChainMap.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 +6 -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 +16 -2
- package/src/renderers/common/RenderObjects.js +1 -1
- package/src/renderers/common/Renderer.js +473 -245
- package/src/renderers/common/RendererUtils.js +9 -0
- package/src/renderers/common/SampledTexture.js +9 -1
- package/src/renderers/common/Sampler.js +50 -12
- package/src/renderers/common/StorageTexture.js +9 -1
- package/src/renderers/common/Textures.js +121 -45
- package/src/renderers/common/TimestampQueryPool.js +65 -3
- package/src/renderers/common/UniformsGroup.js +2 -1
- package/src/renderers/common/XRManager.js +42 -22
- package/src/renderers/common/extras/PMREMGenerator.js +160 -65
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +9 -7
- 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 +7 -15
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +1 -1
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/shaders/UniformsUtils.js +25 -4
- package/src/renderers/webgl/WebGLCapabilities.js +2 -1
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +15 -14
- package/src/renderers/webgl/WebGLPrograms.js +2 -1
- package/src/renderers/webgl/WebGLShadowMap.js +3 -2
- package/src/renderers/webgl/WebGLState.js +15 -14
- package/src/renderers/webgl/WebGLTextures.js +19 -14
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl/WebGLUtils.js +3 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +199 -167
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +181 -25
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +2 -3
- package/src/renderers/webgl-fallback/utils/WebGLState.js +7 -6
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +169 -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 +153 -123
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +2 -1
- package/src/renderers/webgpu/WebGPURenderer.js +3 -2
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +142 -50
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +5 -3
- package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -2
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +53 -34
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +6 -8
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +260 -99
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +32 -9
- package/src/renderers/webgpu/utils/WebGPUUtils.js +22 -2
- package/src/renderers/webxr/WebXRManager.js +42 -26
- package/src/textures/ExternalTexture.js +15 -4
- package/src/textures/Source.js +3 -2
- package/src/textures/Texture.js +3 -2
- package/src/textures/VideoTexture.js +2 -3
- package/src/utils.js +67 -3
- package/examples/jsm/loaders/RGBMLoader.js +0 -1148
|
@@ -4,12 +4,13 @@ import { textureSize } from './TextureSizeNode.js';
|
|
|
4
4
|
import { colorSpaceToWorking } from '../display/ColorSpaceNode.js';
|
|
5
5
|
import { expression } from '../code/ExpressionNode.js';
|
|
6
6
|
import { maxMipLevel } from '../utils/MaxMipLevelNode.js';
|
|
7
|
-
import { nodeProxy, vec3, nodeObject, int } from '../tsl/TSLBase.js';
|
|
7
|
+
import { nodeProxy, vec3, nodeObject, int, Fn } from '../tsl/TSLBase.js';
|
|
8
8
|
import { NodeUpdateType } from '../core/constants.js';
|
|
9
9
|
|
|
10
10
|
import { IntType, NearestFilter, UnsignedIntType } from '../../constants.js';
|
|
11
11
|
|
|
12
12
|
import { Texture } from '../../textures/Texture.js';
|
|
13
|
+
import { warn } from '../../utils.js';
|
|
13
14
|
|
|
14
15
|
const EmptyTexture = /*@__PURE__*/ new Texture();
|
|
15
16
|
|
|
@@ -95,6 +96,15 @@ class TextureNode extends UniformNode {
|
|
|
95
96
|
*/
|
|
96
97
|
this.gradNode = null;
|
|
97
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Represents the optional texel offset applied to the unnormalized texture
|
|
101
|
+
* coordinate before sampling the texture.
|
|
102
|
+
*
|
|
103
|
+
* @type {?Node<ivec2|ivec3>}
|
|
104
|
+
* @default null
|
|
105
|
+
*/
|
|
106
|
+
this.offsetNode = null;
|
|
107
|
+
|
|
98
108
|
/**
|
|
99
109
|
* Whether texture values should be sampled or fetched.
|
|
100
110
|
*
|
|
@@ -114,9 +124,9 @@ class TextureNode extends UniformNode {
|
|
|
114
124
|
this.updateMatrix = false;
|
|
115
125
|
|
|
116
126
|
/**
|
|
117
|
-
* By default the `update()` method is not executed.
|
|
118
|
-
*
|
|
119
|
-
*
|
|
127
|
+
* By default the `update()` method is not executed. Depending on
|
|
128
|
+
* whether a uv transformation matrix and/or flipY is applied, `update()`
|
|
129
|
+
* is executed per object.
|
|
120
130
|
*
|
|
121
131
|
* @type {string}
|
|
122
132
|
* @default 'none'
|
|
@@ -144,9 +154,19 @@ class TextureNode extends UniformNode {
|
|
|
144
154
|
*
|
|
145
155
|
* @private
|
|
146
156
|
* @type {?UniformNode<mat3>}
|
|
157
|
+
* @default null
|
|
147
158
|
*/
|
|
148
159
|
this._matrixUniform = null;
|
|
149
160
|
|
|
161
|
+
/**
|
|
162
|
+
* The uniform node that represents the y-flip. Only required for WebGL.
|
|
163
|
+
*
|
|
164
|
+
* @private
|
|
165
|
+
* @type {?UniformNode<bool>}
|
|
166
|
+
* @default null
|
|
167
|
+
*/
|
|
168
|
+
this._flipYUniform = null;
|
|
169
|
+
|
|
150
170
|
this.setUpdateMatrix( uvNode === null );
|
|
151
171
|
|
|
152
172
|
}
|
|
@@ -270,7 +290,6 @@ class TextureNode extends UniformNode {
|
|
|
270
290
|
setUpdateMatrix( value ) {
|
|
271
291
|
|
|
272
292
|
this.updateMatrix = value;
|
|
273
|
-
this.updateType = value ? NodeUpdateType.OBJECT : NodeUpdateType.NONE;
|
|
274
293
|
|
|
275
294
|
return this;
|
|
276
295
|
|
|
@@ -286,17 +305,19 @@ class TextureNode extends UniformNode {
|
|
|
286
305
|
*/
|
|
287
306
|
setupUV( builder, uvNode ) {
|
|
288
307
|
|
|
289
|
-
|
|
308
|
+
if ( builder.isFlipY() ) {
|
|
309
|
+
|
|
310
|
+
if ( this._flipYUniform === null ) this._flipYUniform = uniform( false );
|
|
290
311
|
|
|
291
|
-
|
|
312
|
+
uvNode = uvNode.toVar();
|
|
292
313
|
|
|
293
314
|
if ( this.sampler ) {
|
|
294
315
|
|
|
295
|
-
uvNode = uvNode.flipY();
|
|
316
|
+
uvNode = this._flipYUniform.select( uvNode.flipY(), uvNode );
|
|
296
317
|
|
|
297
318
|
} else {
|
|
298
319
|
|
|
299
|
-
uvNode = uvNode.setY( int( textureSize( this, this.levelNode ).y ).sub( uvNode.y ).sub( 1 ) );
|
|
320
|
+
uvNode = this._flipYUniform.select( uvNode.setY( int( textureSize( this, this.levelNode ).y ).sub( uvNode.y ).sub( 1 ) ), uvNode );
|
|
300
321
|
|
|
301
322
|
}
|
|
302
323
|
|
|
@@ -328,23 +349,35 @@ class TextureNode extends UniformNode {
|
|
|
328
349
|
|
|
329
350
|
//
|
|
330
351
|
|
|
331
|
-
|
|
352
|
+
const uvNode = Fn( () => {
|
|
332
353
|
|
|
333
|
-
|
|
354
|
+
let uvNode = this.uvNode;
|
|
334
355
|
|
|
335
|
-
uvNode
|
|
356
|
+
if ( ( uvNode === null || builder.context.forceUVContext === true ) && builder.context.getUV ) {
|
|
336
357
|
|
|
337
|
-
|
|
358
|
+
uvNode = builder.context.getUV( this, builder );
|
|
338
359
|
|
|
339
|
-
|
|
360
|
+
}
|
|
340
361
|
|
|
341
|
-
|
|
362
|
+
if ( ! uvNode ) uvNode = this.getDefaultUV();
|
|
342
363
|
|
|
343
|
-
|
|
364
|
+
if ( this.updateMatrix === true ) {
|
|
344
365
|
|
|
345
|
-
|
|
366
|
+
uvNode = this.getTransformedUV( uvNode );
|
|
367
|
+
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
uvNode = this.setupUV( builder, uvNode );
|
|
371
|
+
|
|
372
|
+
//
|
|
373
|
+
|
|
374
|
+
this.updateType = ( this._matrixUniform !== null || this._flipYUniform !== null ) ? NodeUpdateType.OBJECT : NodeUpdateType.NONE;
|
|
375
|
+
|
|
376
|
+
//
|
|
377
|
+
|
|
378
|
+
return uvNode;
|
|
346
379
|
|
|
347
|
-
|
|
380
|
+
} )();
|
|
348
381
|
|
|
349
382
|
//
|
|
350
383
|
|
|
@@ -364,6 +397,7 @@ class TextureNode extends UniformNode {
|
|
|
364
397
|
properties.compareNode = this.compareNode;
|
|
365
398
|
properties.gradNode = this.gradNode;
|
|
366
399
|
properties.depthNode = this.depthNode;
|
|
400
|
+
properties.offsetNode = this.offsetNode;
|
|
367
401
|
|
|
368
402
|
}
|
|
369
403
|
|
|
@@ -380,6 +414,19 @@ class TextureNode extends UniformNode {
|
|
|
380
414
|
|
|
381
415
|
}
|
|
382
416
|
|
|
417
|
+
/**
|
|
418
|
+
* Generates the offset code snippet.
|
|
419
|
+
*
|
|
420
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
421
|
+
* @param {Node} offsetNode - The offset node to generate code for.
|
|
422
|
+
* @return {string} The generated code snippet.
|
|
423
|
+
*/
|
|
424
|
+
generateOffset( builder, offsetNode ) {
|
|
425
|
+
|
|
426
|
+
return offsetNode.build( builder, 'ivec2' );
|
|
427
|
+
|
|
428
|
+
}
|
|
429
|
+
|
|
383
430
|
/**
|
|
384
431
|
* Generates the snippet for the texture sampling.
|
|
385
432
|
*
|
|
@@ -391,37 +438,38 @@ class TextureNode extends UniformNode {
|
|
|
391
438
|
* @param {?string} depthSnippet - The depth snippet.
|
|
392
439
|
* @param {?string} compareSnippet - The compare snippet.
|
|
393
440
|
* @param {?Array<string>} gradSnippet - The grad snippet.
|
|
441
|
+
* @param {?string} offsetSnippet - The offset snippet.
|
|
394
442
|
* @return {string} The generated code snippet.
|
|
395
443
|
*/
|
|
396
|
-
generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, depthSnippet, compareSnippet, gradSnippet ) {
|
|
444
|
+
generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, depthSnippet, compareSnippet, gradSnippet, offsetSnippet ) {
|
|
397
445
|
|
|
398
446
|
const texture = this.value;
|
|
399
447
|
|
|
400
448
|
let snippet;
|
|
401
449
|
|
|
402
|
-
if (
|
|
403
|
-
|
|
404
|
-
snippet = builder.generateTextureLevel( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet );
|
|
405
|
-
|
|
406
|
-
} else if ( biasSnippet ) {
|
|
450
|
+
if ( biasSnippet ) {
|
|
407
451
|
|
|
408
|
-
snippet = builder.generateTextureBias( texture, textureProperty, uvSnippet, biasSnippet, depthSnippet );
|
|
452
|
+
snippet = builder.generateTextureBias( texture, textureProperty, uvSnippet, biasSnippet, depthSnippet, offsetSnippet );
|
|
409
453
|
|
|
410
454
|
} else if ( gradSnippet ) {
|
|
411
455
|
|
|
412
|
-
snippet = builder.generateTextureGrad( texture, textureProperty, uvSnippet, gradSnippet, depthSnippet );
|
|
456
|
+
snippet = builder.generateTextureGrad( texture, textureProperty, uvSnippet, gradSnippet, depthSnippet, offsetSnippet );
|
|
413
457
|
|
|
414
458
|
} else if ( compareSnippet ) {
|
|
415
459
|
|
|
416
|
-
snippet = builder.generateTextureCompare( texture, textureProperty, uvSnippet, compareSnippet, depthSnippet );
|
|
460
|
+
snippet = builder.generateTextureCompare( texture, textureProperty, uvSnippet, compareSnippet, depthSnippet, offsetSnippet );
|
|
417
461
|
|
|
418
462
|
} else if ( this.sampler === false ) {
|
|
419
463
|
|
|
420
|
-
snippet = builder.generateTextureLoad( texture, textureProperty, uvSnippet, depthSnippet );
|
|
464
|
+
snippet = builder.generateTextureLoad( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet, offsetSnippet );
|
|
465
|
+
|
|
466
|
+
} else if ( levelSnippet ) {
|
|
467
|
+
|
|
468
|
+
snippet = builder.generateTextureLevel( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet, offsetSnippet );
|
|
421
469
|
|
|
422
470
|
} else {
|
|
423
471
|
|
|
424
|
-
snippet = builder.generateTexture( texture, textureProperty, uvSnippet, depthSnippet );
|
|
472
|
+
snippet = builder.generateTexture( texture, textureProperty, uvSnippet, depthSnippet, offsetSnippet );
|
|
425
473
|
|
|
426
474
|
}
|
|
427
475
|
|
|
@@ -459,7 +507,7 @@ class TextureNode extends UniformNode {
|
|
|
459
507
|
|
|
460
508
|
if ( propertyName === undefined ) {
|
|
461
509
|
|
|
462
|
-
const { uvNode, levelNode, biasNode, compareNode, depthNode, gradNode } = properties;
|
|
510
|
+
const { uvNode, levelNode, biasNode, compareNode, depthNode, gradNode, offsetNode } = properties;
|
|
463
511
|
|
|
464
512
|
const uvSnippet = this.generateUV( builder, uvNode );
|
|
465
513
|
const levelSnippet = levelNode ? levelNode.build( builder, 'float' ) : null;
|
|
@@ -467,12 +515,13 @@ class TextureNode extends UniformNode {
|
|
|
467
515
|
const depthSnippet = depthNode ? depthNode.build( builder, 'int' ) : null;
|
|
468
516
|
const compareSnippet = compareNode ? compareNode.build( builder, 'float' ) : null;
|
|
469
517
|
const gradSnippet = gradNode ? [ gradNode[ 0 ].build( builder, 'vec2' ), gradNode[ 1 ].build( builder, 'vec2' ) ] : null;
|
|
518
|
+
const offsetSnippet = offsetNode ? this.generateOffset( builder, offsetNode ) : null;
|
|
470
519
|
|
|
471
520
|
const nodeVar = builder.getVarFromNode( this );
|
|
472
521
|
|
|
473
522
|
propertyName = builder.getPropertyName( nodeVar );
|
|
474
523
|
|
|
475
|
-
const snippet = this.generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, depthSnippet, compareSnippet, gradSnippet );
|
|
524
|
+
const snippet = this.generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, depthSnippet, compareSnippet, gradSnippet, offsetSnippet );
|
|
476
525
|
|
|
477
526
|
builder.addLineFlowCode( `${propertyName} = ${snippet}`, this );
|
|
478
527
|
|
|
@@ -532,7 +581,7 @@ class TextureNode extends UniformNode {
|
|
|
532
581
|
*/
|
|
533
582
|
uv( uvNode ) { // @deprecated, r172
|
|
534
583
|
|
|
535
|
-
|
|
584
|
+
warn( 'TextureNode: .uv() has been renamed. Use .sample() instead.' );
|
|
536
585
|
|
|
537
586
|
return this.sample( uvNode );
|
|
538
587
|
|
|
@@ -548,7 +597,7 @@ class TextureNode extends UniformNode {
|
|
|
548
597
|
|
|
549
598
|
const textureNode = this.clone();
|
|
550
599
|
textureNode.uvNode = nodeObject( uvNode );
|
|
551
|
-
textureNode.referenceNode = this.
|
|
600
|
+
textureNode.referenceNode = this.getBase();
|
|
552
601
|
|
|
553
602
|
return nodeObject( textureNode );
|
|
554
603
|
|
|
@@ -576,13 +625,13 @@ class TextureNode extends UniformNode {
|
|
|
576
625
|
|
|
577
626
|
const textureNode = this.clone();
|
|
578
627
|
textureNode.biasNode = nodeObject( amountNode ).mul( maxMipLevel( textureNode ) );
|
|
579
|
-
textureNode.referenceNode = this.
|
|
628
|
+
textureNode.referenceNode = this.getBase();
|
|
580
629
|
|
|
581
630
|
const map = textureNode.value;
|
|
582
631
|
|
|
583
632
|
if ( textureNode.generateMipmaps === false && ( map && map.generateMipmaps === false || map.minFilter === NearestFilter || map.magFilter === NearestFilter ) ) {
|
|
584
633
|
|
|
585
|
-
|
|
634
|
+
warn( 'TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture.' );
|
|
586
635
|
|
|
587
636
|
textureNode.biasNode = null;
|
|
588
637
|
|
|
@@ -602,7 +651,7 @@ class TextureNode extends UniformNode {
|
|
|
602
651
|
|
|
603
652
|
const textureNode = this.clone();
|
|
604
653
|
textureNode.levelNode = nodeObject( levelNode );
|
|
605
|
-
textureNode.referenceNode = this.
|
|
654
|
+
textureNode.referenceNode = this.getBase();
|
|
606
655
|
|
|
607
656
|
return nodeObject( textureNode );
|
|
608
657
|
|
|
@@ -630,12 +679,22 @@ class TextureNode extends UniformNode {
|
|
|
630
679
|
|
|
631
680
|
const textureNode = this.clone();
|
|
632
681
|
textureNode.biasNode = nodeObject( biasNode );
|
|
633
|
-
textureNode.referenceNode = this.
|
|
682
|
+
textureNode.referenceNode = this.getBase();
|
|
634
683
|
|
|
635
684
|
return nodeObject( textureNode );
|
|
636
685
|
|
|
637
686
|
}
|
|
638
687
|
|
|
688
|
+
/**
|
|
689
|
+
* Returns the base texture of this node.
|
|
690
|
+
* @return {TextureNode} The base texture node.
|
|
691
|
+
*/
|
|
692
|
+
getBase() {
|
|
693
|
+
|
|
694
|
+
return this.referenceNode ? this.referenceNode.getBase() : this;
|
|
695
|
+
|
|
696
|
+
}
|
|
697
|
+
|
|
639
698
|
/**
|
|
640
699
|
* Samples the texture by executing a compare operation.
|
|
641
700
|
*
|
|
@@ -646,7 +705,7 @@ class TextureNode extends UniformNode {
|
|
|
646
705
|
|
|
647
706
|
const textureNode = this.clone();
|
|
648
707
|
textureNode.compareNode = nodeObject( compareNode );
|
|
649
|
-
textureNode.referenceNode = this.
|
|
708
|
+
textureNode.referenceNode = this.getBase();
|
|
650
709
|
|
|
651
710
|
return nodeObject( textureNode );
|
|
652
711
|
|
|
@@ -663,7 +722,7 @@ class TextureNode extends UniformNode {
|
|
|
663
722
|
|
|
664
723
|
const textureNode = this.clone();
|
|
665
724
|
textureNode.gradNode = [ nodeObject( gradNodeX ), nodeObject( gradNodeY ) ];
|
|
666
|
-
textureNode.referenceNode = this.
|
|
725
|
+
textureNode.referenceNode = this.getBase();
|
|
667
726
|
|
|
668
727
|
return nodeObject( textureNode );
|
|
669
728
|
|
|
@@ -679,7 +738,23 @@ class TextureNode extends UniformNode {
|
|
|
679
738
|
|
|
680
739
|
const textureNode = this.clone();
|
|
681
740
|
textureNode.depthNode = nodeObject( depthNode );
|
|
682
|
-
textureNode.referenceNode = this.
|
|
741
|
+
textureNode.referenceNode = this.getBase();
|
|
742
|
+
|
|
743
|
+
return nodeObject( textureNode );
|
|
744
|
+
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* Samples the texture by defining an offset node.
|
|
749
|
+
*
|
|
750
|
+
* @param {Node<ivec2>} offsetNode - The offset node.
|
|
751
|
+
* @return {TextureNode} A texture node representing the texture sample.
|
|
752
|
+
*/
|
|
753
|
+
offset( offsetNode ) {
|
|
754
|
+
|
|
755
|
+
const textureNode = this.clone();
|
|
756
|
+
textureNode.offsetNode = nodeObject( offsetNode );
|
|
757
|
+
textureNode.referenceNode = this.getBase();
|
|
683
758
|
|
|
684
759
|
return nodeObject( textureNode );
|
|
685
760
|
|
|
@@ -725,6 +800,16 @@ class TextureNode extends UniformNode {
|
|
|
725
800
|
|
|
726
801
|
}
|
|
727
802
|
|
|
803
|
+
//
|
|
804
|
+
|
|
805
|
+
const flipYUniform = this._flipYUniform;
|
|
806
|
+
|
|
807
|
+
if ( flipYUniform !== null ) {
|
|
808
|
+
|
|
809
|
+
flipYUniform.value = ( ( texture.image instanceof ImageBitmap && texture.flipY === true ) || texture.isRenderTargetTexture === true || texture.isFramebufferTexture === true || texture.isDepthTexture === true );
|
|
810
|
+
|
|
811
|
+
}
|
|
812
|
+
|
|
728
813
|
}
|
|
729
814
|
|
|
730
815
|
/**
|
|
@@ -739,6 +824,7 @@ class TextureNode extends UniformNode {
|
|
|
739
824
|
newNode.depthNode = this.depthNode;
|
|
740
825
|
newNode.compareNode = this.compareNode;
|
|
741
826
|
newNode.gradNode = this.gradNode;
|
|
827
|
+
newNode.offsetNode = this.offsetNode;
|
|
742
828
|
|
|
743
829
|
return newNode;
|
|
744
830
|
|
|
@@ -766,7 +852,7 @@ const textureBase = /*@__PURE__*/ nodeProxy( TextureNode ).setParameterLength( 1
|
|
|
766
852
|
*
|
|
767
853
|
* @tsl
|
|
768
854
|
* @function
|
|
769
|
-
* @param {?Texture|TextureNode} [value=EmptyTexture] - The texture.
|
|
855
|
+
* @param {?(Texture|TextureNode)} [value=EmptyTexture] - The texture.
|
|
770
856
|
* @param {?Node<vec2|vec3>} [uvNode=null] - The uv node.
|
|
771
857
|
* @param {?Node<int>} [levelNode=null] - The level node.
|
|
772
858
|
* @param {?Node<float>} [biasNode=null] - The bias node.
|
|
@@ -779,7 +865,7 @@ export const texture = ( value = EmptyTexture, uvNode = null, levelNode = null,
|
|
|
779
865
|
if ( value && value.isTextureNode === true ) {
|
|
780
866
|
|
|
781
867
|
textureNode = nodeObject( value.clone() );
|
|
782
|
-
textureNode.referenceNode = value.
|
|
868
|
+
textureNode.referenceNode = value.getBase(); // Ensure the reference is set to the original node
|
|
783
869
|
|
|
784
870
|
if ( uvNode !== null ) textureNode.uvNode = nodeObject( uvNode );
|
|
785
871
|
if ( levelNode !== null ) textureNode.levelNode = nodeObject( levelNode );
|
|
@@ -810,7 +896,7 @@ export const uniformTexture = ( value = EmptyTexture ) => texture( value );
|
|
|
810
896
|
*
|
|
811
897
|
* @tsl
|
|
812
898
|
* @function
|
|
813
|
-
* @param {?Texture|TextureNode} [value=EmptyTexture] - The texture.
|
|
899
|
+
* @param {?(Texture|TextureNode)} [value=EmptyTexture] - The texture.
|
|
814
900
|
* @param {?Node<vec2|vec3>} [uvNode=null] - The uv node.
|
|
815
901
|
* @param {?Node<int>} [levelNode=null] - The level node.
|
|
816
902
|
* @param {?Node<float>} [biasNode=null] - The bias node.
|
|
@@ -818,7 +904,7 @@ export const uniformTexture = ( value = EmptyTexture ) => texture( value );
|
|
|
818
904
|
*/
|
|
819
905
|
export const textureLoad = ( ...params ) => texture( ...params ).setSampler( false );
|
|
820
906
|
|
|
821
|
-
|
|
907
|
+
export const textureLevel = ( value, uv, level ) => texture( value, uv ).level( level );
|
|
822
908
|
|
|
823
909
|
/**
|
|
824
910
|
* Converts a texture or texture node to a sampler.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
2
|
import { addMethodChaining, nodeArray, nodeObject, nodeObjects, float } from '../tsl/TSLCore.js';
|
|
3
|
+
import { error } from '../../utils.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* This module represents the call of a {@link FunctionNode}. Developers are usually not confronted
|
|
@@ -69,12 +70,31 @@ class FunctionCallNode extends TempNode {
|
|
|
69
70
|
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Returns the type of this function call node.
|
|
75
|
+
*
|
|
76
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
77
|
+
* @returns {string} The type of this node.
|
|
78
|
+
*/
|
|
72
79
|
getNodeType( builder ) {
|
|
73
80
|
|
|
74
81
|
return this.functionNode.getNodeType( builder );
|
|
75
82
|
|
|
76
83
|
}
|
|
77
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Returns the function node of this function call node.
|
|
87
|
+
*
|
|
88
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
89
|
+
* @param {string} [name] - The name of the member.
|
|
90
|
+
* @returns {string} The type of the member.
|
|
91
|
+
*/
|
|
92
|
+
getMemberType( builder, name ) {
|
|
93
|
+
|
|
94
|
+
return this.functionNode.getMemberType( builder, name );
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
78
98
|
generate( builder ) {
|
|
79
99
|
|
|
80
100
|
const params = [];
|
|
@@ -102,13 +122,13 @@ class FunctionCallNode extends TempNode {
|
|
|
102
122
|
|
|
103
123
|
if ( parameters.length > inputs.length ) {
|
|
104
124
|
|
|
105
|
-
|
|
125
|
+
error( 'TSL: The number of provided parameters exceeds the expected number of inputs in \'Fn()\'.' );
|
|
106
126
|
|
|
107
127
|
parameters.length = inputs.length;
|
|
108
128
|
|
|
109
129
|
} else if ( parameters.length < inputs.length ) {
|
|
110
130
|
|
|
111
|
-
|
|
131
|
+
error( 'TSL: The number of provided parameters is less than the expected number of inputs in \'Fn()\'.' );
|
|
112
132
|
|
|
113
133
|
while ( parameters.length < inputs.length ) {
|
|
114
134
|
|
|
@@ -136,7 +156,7 @@ class FunctionCallNode extends TempNode {
|
|
|
136
156
|
|
|
137
157
|
} else {
|
|
138
158
|
|
|
139
|
-
|
|
159
|
+
error( `TSL: Input '${ inputNode.name }' not found in \'Fn()\'.` );
|
|
140
160
|
|
|
141
161
|
params.push( generateInput( float( 0 ), inputNode ) );
|
|
142
162
|
|
|
@@ -160,7 +180,7 @@ export const call = ( func, ...params ) => {
|
|
|
160
180
|
|
|
161
181
|
params = params.length > 1 || ( params[ 0 ] && params[ 0 ].isNode === true ) ? nodeArray( params ) : nodeObjects( params[ 0 ] );
|
|
162
182
|
|
|
163
|
-
return
|
|
183
|
+
return new FunctionCallNode( nodeObject( func ), params );
|
|
164
184
|
|
|
165
185
|
};
|
|
166
186
|
|
|
@@ -48,12 +48,35 @@ class FunctionNode extends CodeNode {
|
|
|
48
48
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Returns the type of this function node.
|
|
53
|
+
*
|
|
54
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
55
|
+
* @return {string} The type.
|
|
56
|
+
*/
|
|
51
57
|
getNodeType( builder ) {
|
|
52
58
|
|
|
53
59
|
return this.getNodeFunction( builder ).type;
|
|
54
60
|
|
|
55
61
|
}
|
|
56
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Returns the type of a member of this function node.
|
|
65
|
+
*
|
|
66
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
67
|
+
* @param {string} name - The name of the member.
|
|
68
|
+
* @return {string} The type of the member.
|
|
69
|
+
*/
|
|
70
|
+
getMemberType( builder, name ) {
|
|
71
|
+
|
|
72
|
+
const type = this.getNodeType( builder );
|
|
73
|
+
|
|
74
|
+
const structType = builder.getStructTypeNode( type );
|
|
75
|
+
|
|
76
|
+
return structType.getMemberType( builder, name );
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
57
80
|
/**
|
|
58
81
|
* Returns the inputs of this function node.
|
|
59
82
|
*
|
|
@@ -97,7 +97,9 @@ class AssignNode extends TempNode {
|
|
|
97
97
|
|
|
98
98
|
const { targetNode, sourceNode } = this;
|
|
99
99
|
|
|
100
|
-
const
|
|
100
|
+
const scope = targetNode.getScope();
|
|
101
|
+
|
|
102
|
+
const targetProperties = builder.getNodeProperties( scope );
|
|
101
103
|
targetProperties.assign = true;
|
|
102
104
|
|
|
103
105
|
const properties = builder.getNodeProperties( this );
|
|
@@ -112,11 +114,10 @@ class AssignNode extends TempNode {
|
|
|
112
114
|
|
|
113
115
|
const needsSplitAssign = this.needsSplitAssign( builder );
|
|
114
116
|
|
|
117
|
+
const target = targetNode.build( builder );
|
|
115
118
|
const targetType = targetNode.getNodeType( builder );
|
|
116
119
|
|
|
117
|
-
const target = targetNode.build( builder );
|
|
118
120
|
const source = sourceNode.build( builder, targetType );
|
|
119
|
-
|
|
120
121
|
const sourceType = sourceNode.getNodeType( builder );
|
|
121
122
|
|
|
122
123
|
const nodeData = builder.getDataFromNode( this );
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Node from './Node.js';
|
|
2
2
|
import { nodeObject, varying } from '../tsl/TSLBase.js';
|
|
3
|
+
import { warn } from '../../utils.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Base class for representing shader attributes as nodes.
|
|
@@ -125,7 +126,7 @@ class AttributeNode extends Node {
|
|
|
125
126
|
|
|
126
127
|
} else {
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
warn( `AttributeNode: Vertex attribute "${ attributeName }" not found on geometry.` );
|
|
129
130
|
|
|
130
131
|
return builder.generateConst( nodeType );
|
|
131
132
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Node from './Node.js';
|
|
2
2
|
import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
|
|
3
|
+
import { warn } from '../../utils.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* This node can be used as a context management component for another node.
|
|
@@ -78,11 +79,22 @@ class ContextNode extends Node {
|
|
|
78
79
|
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
|
|
82
|
+
/**
|
|
83
|
+
* This method is overwritten to ensure it returns the member type of {@link ContextNode#node}.
|
|
84
|
+
*
|
|
85
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
86
|
+
* @param {string} name - The member name.
|
|
87
|
+
* @returns {string} The member type.
|
|
88
|
+
*/
|
|
89
|
+
getMemberType( builder, name ) {
|
|
82
90
|
|
|
83
|
-
|
|
91
|
+
return this.node.getMemberType( builder, name );
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
analyze( builder ) {
|
|
84
96
|
|
|
85
|
-
|
|
97
|
+
const previousContext = builder.addContext( this.value );
|
|
86
98
|
|
|
87
99
|
this.node.build( builder );
|
|
88
100
|
|
|
@@ -92,9 +104,7 @@ class ContextNode extends Node {
|
|
|
92
104
|
|
|
93
105
|
setup( builder ) {
|
|
94
106
|
|
|
95
|
-
const previousContext = builder.
|
|
96
|
-
|
|
97
|
-
builder.setContext( { ...builder.context, ...this.value } );
|
|
107
|
+
const previousContext = builder.addContext( this.value );
|
|
98
108
|
|
|
99
109
|
this.node.build( builder );
|
|
100
110
|
|
|
@@ -104,9 +114,7 @@ class ContextNode extends Node {
|
|
|
104
114
|
|
|
105
115
|
generate( builder, output ) {
|
|
106
116
|
|
|
107
|
-
const previousContext = builder.
|
|
108
|
-
|
|
109
|
-
builder.setContext( { ...builder.context, ...this.value } );
|
|
117
|
+
const previousContext = builder.addContext( this.value );
|
|
110
118
|
|
|
111
119
|
const snippet = this.node.build( builder, output );
|
|
112
120
|
|
|
@@ -131,6 +139,16 @@ export default ContextNode;
|
|
|
131
139
|
*/
|
|
132
140
|
export const context = /*@__PURE__*/ nodeProxy( ContextNode ).setParameterLength( 1, 2 );
|
|
133
141
|
|
|
142
|
+
/**
|
|
143
|
+
* TSL function for defining a uniformFlow context value for a given node.
|
|
144
|
+
*
|
|
145
|
+
* @tsl
|
|
146
|
+
* @function
|
|
147
|
+
* @param {Node} node - The node whose dependencies should all execute within a uniform control-flow path.
|
|
148
|
+
* @returns {ContextNode}
|
|
149
|
+
*/
|
|
150
|
+
export const uniformFlow = ( node ) => context( node, { uniformFlow: true } );
|
|
151
|
+
|
|
134
152
|
/**
|
|
135
153
|
* TSL function for defining a name for the context value for a given node.
|
|
136
154
|
*
|
|
@@ -154,7 +172,7 @@ export const setName = ( node, name ) => context( node, { nodeName: name } );
|
|
|
154
172
|
*/
|
|
155
173
|
export function label( node, name ) {
|
|
156
174
|
|
|
157
|
-
|
|
175
|
+
warn( 'TSL: "label()" has been deprecated. Use "setName()" instead.' ); // @deprecated r179
|
|
158
176
|
|
|
159
177
|
return setName( node, name );
|
|
160
178
|
|
|
@@ -162,4 +180,5 @@ export function label( node, name ) {
|
|
|
162
180
|
|
|
163
181
|
addMethodChaining( 'context', context );
|
|
164
182
|
addMethodChaining( 'label', label );
|
|
183
|
+
addMethodChaining( 'uniformFlow', uniformFlow );
|
|
165
184
|
addMethodChaining( 'setName', setName );
|
|
@@ -10,7 +10,7 @@ import { nodeImmutable, varying } from '../tsl/TSLBase.js';
|
|
|
10
10
|
* - `drawIndex`: The index of a draw call.
|
|
11
11
|
* - `invocationLocalIndex`: The index of a compute invocation within the scope of a workgroup load.
|
|
12
12
|
* - `invocationSubgroupIndex`: The index of a compute invocation within the scope of a subgroup.
|
|
13
|
-
* - `subgroupIndex`: The index of
|
|
13
|
+
* - `subgroupIndex`: The index of a compute invocation's subgroup within its workgroup.
|
|
14
14
|
*
|
|
15
15
|
* @augments Node
|
|
16
16
|
*/
|
|
@@ -25,7 +25,7 @@ class IndexNode extends Node {
|
|
|
25
25
|
/**
|
|
26
26
|
* Constructs a new index node.
|
|
27
27
|
*
|
|
28
|
-
* @param {('vertex'|'instance'|'subgroup'|'invocationLocal'|'invocationSubgroup'|'draw')} scope - The scope of the index node.
|
|
28
|
+
* @param {('vertex'|'instance'|'subgroup'|'invocationLocal'|'invocationGlobal'|'invocationSubgroup'|'draw')} scope - The scope of the index node.
|
|
29
29
|
*/
|
|
30
30
|
constructor( scope ) {
|
|
31
31
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Node from './Node.js';
|
|
2
2
|
import { getValueType, getValueFromType, arrayBufferToBase64 } from './NodeUtils.js';
|
|
3
|
+
import { warn } from '../../utils.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Base class for representing data input nodes.
|
|
@@ -126,7 +127,7 @@ class InputNode extends Node {
|
|
|
126
127
|
|
|
127
128
|
generate( /*builder, output*/ ) {
|
|
128
129
|
|
|
129
|
-
|
|
130
|
+
warn( 'Abstract function.' );
|
|
130
131
|
|
|
131
132
|
}
|
|
132
133
|
|