super-three 0.171.0 → 0.173.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/build/three.cjs +594 -427
- package/build/three.core.js +515 -81
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +79 -350
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +20 -7
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +29362 -3427
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +29361 -3427
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +0 -5
- package/examples/jsm/animation/CCDIKSolver.js +9 -7
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +48 -37
- package/examples/jsm/controls/OrbitControls.js +5 -4
- package/examples/jsm/csm/CSMShadowNode.js +16 -11
- package/examples/jsm/curves/NURBSCurve.js +1 -1
- package/examples/jsm/curves/NURBSUtils.js +3 -0
- package/examples/jsm/effects/OutlineEffect.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +34 -29
- package/examples/jsm/exporters/KTX2Exporter.js +1 -1
- package/examples/jsm/exporters/PLYExporter.js +2 -2
- package/examples/jsm/geometries/TextGeometry.js +1 -12
- package/examples/jsm/helpers/TextureHelperGPU.js +15 -5
- package/examples/jsm/helpers/VertexNormalsHelper.js +2 -0
- package/examples/jsm/interactive/InteractiveGroup.js +108 -51
- package/examples/jsm/libs/demuxer_mp4.js +109 -0
- package/examples/jsm/lights/LightProbeGenerator.js +3 -3
- package/examples/jsm/lines/webgpu/LineSegments2.js +15 -6
- package/examples/jsm/loaders/3MFLoader.js +6 -3
- package/examples/jsm/loaders/BVHLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +5 -5
- package/examples/jsm/loaders/DDSLoader.js +42 -0
- package/examples/jsm/loaders/GCodeLoader.js +4 -2
- package/examples/jsm/loaders/GLTFLoader.js +22 -4
- package/examples/jsm/loaders/KTX2Loader.js +6 -1
- package/examples/jsm/loaders/KTXLoader.js +4 -4
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LottieLoader.js +1 -1
- package/examples/jsm/loaders/MTLLoader.js +1 -0
- package/examples/jsm/loaders/NRRDLoader.js +1 -1
- package/examples/jsm/loaders/PLYLoader.js +7 -7
- package/examples/jsm/loaders/PVRLoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/TDSLoader.js +1 -2
- package/examples/jsm/loaders/VRMLLoader.js +7 -7
- package/examples/jsm/loaders/lwo/IFFParser.js +4 -4
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -1
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
- package/examples/jsm/math/ConvexHull.js +1 -1
- package/examples/jsm/math/OBB.js +17 -0
- package/examples/jsm/misc/GPUComputationRenderer.js +6 -7
- package/examples/jsm/misc/ProgressiveLightMap.js +4 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +14 -13
- package/examples/jsm/misc/Volume.js +27 -17
- package/examples/jsm/misc/VolumeSlice.js +7 -5
- package/examples/jsm/modifiers/CurveModifier.js +10 -8
- package/examples/jsm/modifiers/CurveModifierGPU.js +9 -7
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -2
- package/examples/jsm/objects/GroundedSkybox.js +4 -4
- package/examples/jsm/objects/Sky.js +2 -2
- package/examples/jsm/objects/SkyMesh.js +3 -3
- package/examples/jsm/objects/Water2.js +1 -1
- package/examples/jsm/objects/Water2Mesh.js +2 -2
- package/examples/jsm/objects/WaterMesh.js +29 -24
- package/examples/jsm/physics/JoltPhysics.js +7 -7
- package/examples/jsm/physics/RapierPhysics.js +4 -4
- package/examples/jsm/postprocessing/BloomPass.js +2 -2
- package/examples/jsm/postprocessing/EffectComposer.js +1 -2
- package/examples/jsm/postprocessing/OutlinePass.js +4 -4
- package/examples/jsm/postprocessing/OutputPass.js +2 -0
- package/examples/jsm/postprocessing/SAOPass.js +1 -2
- package/examples/jsm/postprocessing/SMAAPass.js +1 -3
- package/examples/jsm/postprocessing/SSAOPass.js +2 -4
- package/examples/jsm/postprocessing/SSRPass.js +2 -4
- package/examples/jsm/postprocessing/UnrealBloomPass.js +2 -2
- package/examples/jsm/renderers/SVGRenderer.js +6 -4
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/GodRaysShader.js +3 -3
- package/examples/jsm/shaders/OutputShader.js +5 -1
- package/examples/jsm/shaders/SobelOperatorShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +2 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +93 -4
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +46 -2
- package/examples/jsm/tsl/display/AnamorphicNode.js +118 -5
- package/examples/jsm/tsl/display/BleachBypass.js +10 -0
- package/examples/jsm/tsl/display/BloomNode.js +233 -26
- package/examples/jsm/tsl/display/DenoiseNode.js +141 -25
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +80 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +50 -5
- package/examples/jsm/tsl/display/FXAANode.js +52 -3
- package/examples/jsm/tsl/display/FilmNode.js +47 -1
- package/examples/jsm/tsl/display/GTAONode.js +210 -14
- package/examples/jsm/tsl/display/GaussianBlurNode.js +152 -8
- package/examples/jsm/tsl/display/LensflareNode.js +131 -13
- package/examples/jsm/tsl/display/Lut3DNode.js +55 -1
- package/examples/jsm/tsl/display/MotionBlur.js +12 -2
- package/examples/jsm/tsl/display/OutlineNode.js +343 -26
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +36 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +142 -9
- package/examples/jsm/tsl/display/RGBShiftNode.js +49 -2
- package/examples/jsm/tsl/display/SMAANode.js +187 -46
- package/examples/jsm/tsl/display/SSAAPassNode.js +110 -25
- package/examples/jsm/tsl/display/SSRNode.js +194 -21
- package/examples/jsm/tsl/display/Sepia.js +9 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +54 -4
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +79 -3
- package/examples/jsm/tsl/display/StereoPassNode.js +41 -3
- package/examples/jsm/tsl/display/TRAAPassNode.js +116 -21
- package/examples/jsm/tsl/display/TransitionNode.js +71 -6
- package/examples/jsm/tsl/display/hashBlur.js +14 -3
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +40 -34
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/CameraUtils.js +4 -1
- package/examples/jsm/utils/GeometryUtils.js +22 -19
- package/examples/jsm/utils/SceneUtils.js +2 -2
- package/examples/jsm/webxr/XRControllerModelFactory.js +6 -1
- package/examples/jsm/webxr/XREstimatedLight.js +1 -1
- package/package.json +8 -3
- package/src/Three.Core.js +4 -0
- package/src/Three.Legacy.js +0 -21
- package/src/Three.TSL.js +18 -5
- package/src/Three.WebGPU.Nodes.js +2 -2
- package/src/Three.WebGPU.js +2 -2
- package/src/animation/PropertyBinding.js +2 -2
- package/src/cameras/ArrayCamera.js +1 -0
- package/src/cameras/PerspectiveCamera.js +18 -2
- package/src/constants.js +6 -1
- package/src/core/BufferAttribute.js +4 -0
- package/src/core/EventDispatcher.js +8 -6
- package/src/core/RenderTarget.js +18 -0
- package/src/core/RenderTarget3D.js +22 -0
- package/src/core/RenderTargetArray.js +22 -0
- package/src/extras/Earcut.js +1 -1
- package/src/extras/ImageUtils.js +1 -11
- package/src/extras/PMREMGenerator.js +20 -0
- package/src/extras/TextureUtils.js +6 -0
- package/src/helpers/CameraHelper.js +16 -13
- package/src/loaders/nodes/NodeLoader.js +59 -0
- package/src/loaders/nodes/NodeMaterialLoader.js +45 -0
- package/src/loaders/nodes/NodeObjectLoader.js +61 -0
- package/src/materials/nodes/Line2NodeMaterial.js +128 -34
- package/src/materials/nodes/LineBasicNodeMaterial.js +17 -2
- package/src/materials/nodes/LineDashedNodeMaterial.js +78 -5
- package/src/materials/nodes/MeshBasicNodeMaterial.js +56 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +35 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +22 -2
- package/src/materials/nodes/MeshNormalNodeMaterial.js +21 -2
- package/src/materials/nodes/MeshPhongNodeMaterial.js +64 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +269 -0
- package/src/materials/nodes/MeshSSSNodeMaterial.js +97 -6
- package/src/materials/nodes/MeshStandardNodeMaterial.js +78 -0
- package/src/materials/nodes/MeshToonNodeMaterial.js +28 -0
- package/src/materials/nodes/NodeMaterial.js +476 -23
- package/src/materials/nodes/NodeMaterials.js +0 -1
- package/src/materials/nodes/PointsNodeMaterial.js +121 -10
- package/src/materials/nodes/ShadowNodeMaterial.js +29 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +78 -20
- package/src/materials/nodes/VolumeNodeMaterial.js +80 -4
- package/src/materials/nodes/manager/NodeMaterialObserver.js +95 -0
- package/src/nodes/Nodes.js +5 -6
- package/src/nodes/TSL.js +6 -3
- package/src/nodes/accessors/AccessorsUtils.js +27 -0
- package/src/nodes/accessors/Arrays.js +47 -6
- package/src/nodes/accessors/BatchNode.js +42 -6
- package/src/nodes/accessors/Bitangent.js +37 -0
- package/src/nodes/accessors/BufferAttributeNode.js +178 -5
- package/src/nodes/accessors/BufferNode.js +63 -0
- package/src/nodes/accessors/BuiltinNode.js +38 -0
- package/src/nodes/accessors/Camera.js +113 -3
- package/src/nodes/accessors/ClippingNode.js +71 -2
- package/src/nodes/accessors/CubeTextureNode.js +64 -0
- package/src/nodes/accessors/InstanceNode.js +85 -2
- package/src/nodes/accessors/InstancedMeshNode.js +28 -3
- package/src/nodes/accessors/Lights.js +50 -1
- package/src/nodes/accessors/MaterialNode.js +306 -12
- package/src/nodes/accessors/MaterialProperties.js +7 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +53 -13
- package/src/nodes/accessors/ModelNode.js +100 -5
- package/src/nodes/accessors/ModelViewProjectionNode.js +10 -38
- package/src/nodes/accessors/MorphNode.js +48 -4
- package/src/nodes/accessors/Normal.js +65 -5
- package/src/nodes/accessors/Object3DNode.js +101 -1
- package/src/nodes/accessors/PointUVNode.js +26 -0
- package/src/nodes/accessors/Position.js +56 -7
- package/src/nodes/accessors/ReferenceBaseNode.js +186 -0
- package/src/nodes/accessors/ReferenceNode.js +201 -2
- package/src/nodes/accessors/ReflectVector.js +24 -0
- package/src/nodes/accessors/RendererReferenceNode.js +46 -1
- package/src/nodes/accessors/SceneNode.js +54 -0
- package/src/nodes/accessors/SkinningNode.js +127 -1
- package/src/nodes/accessors/StorageBufferNode.js +209 -8
- package/src/nodes/accessors/StorageTextureNode.js +118 -0
- package/src/nodes/accessors/Tangent.js +38 -2
- package/src/nodes/accessors/Texture3DNode.js +91 -7
- package/src/nodes/accessors/TextureBicubic.js +12 -2
- package/src/nodes/accessors/TextureNode.js +316 -10
- package/src/nodes/accessors/TextureSizeNode.js +42 -0
- package/src/nodes/accessors/UV.js +10 -1
- package/src/nodes/accessors/UniformArrayNode.js +231 -25
- package/src/nodes/accessors/UserDataNode.js +46 -0
- package/src/nodes/accessors/VelocityNode.js +80 -0
- package/src/nodes/accessors/VertexColorNode.js +39 -2
- package/src/nodes/code/CodeNode.js +95 -1
- package/src/nodes/code/ExpressionNode.js +28 -0
- package/src/nodes/code/FunctionCallNode.js +37 -0
- package/src/nodes/code/FunctionNode.js +45 -0
- package/src/nodes/code/ScriptableNode.js +223 -1
- package/src/nodes/code/ScriptableValueNode.js +85 -1
- package/src/nodes/core/ArrayNode.js +125 -0
- package/src/nodes/core/AssignNode.js +48 -2
- package/src/nodes/core/AttributeNode.js +43 -0
- package/src/nodes/core/BypassNode.js +47 -2
- package/src/nodes/core/CacheNode.js +53 -2
- package/src/nodes/core/ConstNode.js +32 -0
- package/src/nodes/core/ContextNode.js +65 -0
- package/src/nodes/core/IndexNode.js +68 -7
- package/src/nodes/core/InputNode.js +48 -0
- package/src/nodes/core/LightingModel.js +60 -0
- package/src/nodes/core/MRTNode.js +66 -0
- package/src/nodes/core/Node.js +350 -12
- package/src/nodes/core/NodeAttribute.js +38 -0
- package/src/nodes/core/NodeBuilder.js +1166 -26
- package/src/nodes/core/NodeCache.js +41 -2
- package/src/nodes/core/NodeCode.js +31 -0
- package/src/nodes/core/NodeFrame.js +123 -2
- package/src/nodes/core/NodeFunction.js +46 -0
- package/src/nodes/core/NodeFunctionInput.js +44 -0
- package/src/nodes/core/NodeParser.js +11 -0
- package/src/nodes/core/NodeUniform.js +52 -0
- package/src/nodes/core/NodeUtils.js +152 -1
- package/src/nodes/core/NodeVar.js +47 -1
- package/src/nodes/core/NodeVarying.js +28 -0
- package/src/nodes/core/OutputStructNode.js +51 -10
- package/src/nodes/core/ParameterNode.js +28 -0
- package/src/nodes/core/PropertyNode.js +232 -0
- package/src/nodes/core/StackNode.js +98 -1
- package/src/nodes/core/StructNode.js +121 -0
- package/src/nodes/core/StructType.js +13 -0
- package/src/nodes/core/StructTypeNode.js +105 -6
- package/src/nodes/core/TempNode.js +31 -5
- package/src/nodes/core/UniformGroupNode.js +82 -7
- package/src/nodes/core/UniformNode.js +66 -0
- package/src/nodes/core/VarNode.js +146 -7
- package/src/nodes/core/VaryingNode.js +100 -3
- package/src/nodes/core/constants.js +36 -0
- package/src/nodes/display/BlendModes.js +88 -1
- package/src/nodes/display/BumpMapNode.js +37 -0
- package/src/nodes/display/ColorAdjustment.js +53 -11
- package/src/nodes/display/ColorSpaceFunctions.js +16 -0
- package/src/nodes/display/ColorSpaceNode.js +82 -0
- package/src/nodes/display/FrontFacingNode.js +29 -0
- package/src/nodes/display/NormalMapNode.js +43 -0
- package/src/nodes/display/PassNode.js +300 -7
- package/src/nodes/display/PosterizeNode.js +33 -0
- package/src/nodes/display/RenderOutputNode.js +66 -1
- package/src/nodes/display/ScreenNode.js +96 -0
- package/src/nodes/display/ToneMappingFunctions.js +58 -10
- package/src/nodes/display/ToneMappingNode.js +55 -2
- package/src/nodes/display/ToonOutlinePassNode.js +73 -0
- package/src/nodes/display/ViewportDepthNode.js +122 -8
- package/src/nodes/display/ViewportDepthTextureNode.js +23 -0
- package/src/nodes/display/ViewportSharedTextureNode.js +23 -0
- package/src/nodes/display/ViewportTextureNode.js +57 -0
- package/src/nodes/fog/Fog.js +110 -0
- package/src/nodes/functions/BasicLightingModel.js +24 -0
- package/src/nodes/functions/PhongLightingModel.js +34 -2
- package/src/nodes/functions/PhysicalLightingModel.js +167 -8
- package/src/nodes/functions/ShadowMaskModel.js +23 -0
- package/src/nodes/functions/ToonLightingModel.js +20 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.js +1 -3
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +16 -1
- package/src/nodes/geometry/RangeNode.js +54 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +174 -2
- package/src/nodes/gpgpu/BarrierNode.js +47 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +134 -0
- package/src/nodes/gpgpu/ComputeNode.js +106 -2
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +115 -6
- package/src/nodes/lighting/AONode.js +18 -0
- package/src/nodes/lighting/AmbientLightNode.js +10 -0
- package/src/nodes/lighting/AnalyticLightNode.js +97 -2
- package/src/nodes/lighting/BasicEnvironmentNode.js +19 -0
- package/src/nodes/lighting/BasicLightMapNode.js +17 -0
- package/src/nodes/lighting/DirectionalLightNode.js +10 -0
- package/src/nodes/lighting/EnvironmentNode.js +18 -0
- package/src/nodes/lighting/HemisphereLightNode.js +31 -0
- package/src/nodes/lighting/IESSpotLightNode.js +11 -0
- package/src/nodes/lighting/IrradianceNode.js +17 -0
- package/src/nodes/lighting/LightProbeNode.js +20 -0
- package/src/nodes/lighting/LightUtils.js +12 -0
- package/src/nodes/lighting/LightingContextNode.js +48 -0
- package/src/nodes/lighting/LightingNode.js +15 -6
- package/src/nodes/lighting/LightsNode.js +132 -1
- package/src/nodes/lighting/PointLightNode.js +32 -1
- package/src/nodes/lighting/PointShadowNode.js +54 -1
- package/src/nodes/lighting/RectAreaLightNode.js +44 -6
- package/src/nodes/lighting/ShadowBaseNode.js +93 -0
- package/src/nodes/lighting/ShadowNode.js +241 -35
- package/src/nodes/lighting/SpotLightNode.js +43 -0
- package/src/nodes/math/ConditionalNode.js +78 -4
- package/src/nodes/math/Hash.js +9 -0
- package/src/nodes/math/MathNode.js +627 -11
- package/src/nodes/math/MathUtils.js +45 -1
- package/src/nodes/math/OperatorNode.js +329 -18
- package/src/nodes/math/TriNoise3D.js +18 -7
- package/src/nodes/parsers/GLSLNodeFunction.js +16 -0
- package/src/nodes/parsers/GLSLNodeParser.js +11 -0
- package/src/nodes/pmrem/PMREMNode.js +133 -0
- package/src/nodes/pmrem/PMREMUtils.js +2 -2
- package/src/nodes/procedural/Checker.js +9 -0
- package/src/nodes/shapes/Shapes.js +33 -0
- package/src/nodes/tsl/TSLBase.js +3 -2
- package/src/nodes/tsl/TSLCore.js +22 -2
- package/src/nodes/utils/ArrayElementNode.js +39 -3
- package/src/nodes/utils/ConvertNode.js +31 -0
- package/src/nodes/utils/CubeMapNode.js +78 -0
- package/src/nodes/utils/Discard.js +16 -0
- package/src/nodes/utils/EquirectUVNode.js +31 -1
- package/src/nodes/utils/FlipNode.js +38 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +53 -1
- package/src/nodes/utils/JoinNode.js +25 -0
- package/src/nodes/utils/LoopNode.js +82 -2
- package/src/nodes/utils/MatcapUVNode.js +17 -0
- package/src/nodes/utils/MaxMipLevelNode.js +49 -0
- package/src/nodes/utils/MemberNode.js +68 -0
- package/src/nodes/utils/Oscillators.js +33 -0
- package/src/nodes/utils/Packing.js +17 -0
- package/src/nodes/utils/PostProcessingUtils.js +28 -23
- package/src/nodes/utils/RTTNode.js +123 -2
- package/src/nodes/utils/ReflectorNode.js +174 -4
- package/src/nodes/utils/RemapNode.js +79 -0
- package/src/nodes/utils/RotateNode.js +41 -0
- package/src/nodes/utils/SetNode.js +44 -1
- package/src/nodes/utils/SplitNode.js +55 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +46 -0
- package/src/nodes/utils/SpriteUtils.js +17 -0
- package/src/nodes/utils/StorageArrayElementNode.js +54 -0
- package/src/nodes/utils/Timer.js +40 -0
- package/src/nodes/utils/TriplanarTexturesNode.js +84 -0
- package/src/nodes/utils/UVUtils.js +20 -0
- package/src/nodes/utils/ViewportUtils.js +13 -0
- package/src/objects/BatchedMesh.js +2 -3
- package/src/objects/ClippingGroup.js +49 -0
- package/src/objects/Line.js +6 -6
- package/src/renderers/WebGLRenderer.js +30 -4
- package/src/renderers/common/Animation.js +85 -0
- package/src/renderers/common/Attributes.js +36 -0
- package/src/renderers/common/Backend.js +502 -44
- package/src/renderers/common/Background.js +48 -1
- package/src/renderers/common/BindGroup.js +43 -0
- package/src/renderers/common/Binding.js +35 -0
- package/src/renderers/common/Bindings.js +93 -1
- package/src/renderers/common/Buffer.js +49 -0
- package/src/renderers/common/BufferUtils.js +27 -0
- package/src/renderers/common/BundleGroup.js +57 -0
- package/src/renderers/common/ChainMap.js +45 -6
- package/src/renderers/common/ClippingContext.js +108 -15
- package/src/renderers/common/Color4.js +40 -0
- package/src/renderers/common/ComputePipeline.js +24 -0
- package/src/renderers/common/CubeRenderTarget.js +13 -0
- package/src/renderers/common/DataMap.js +37 -1
- package/src/renderers/common/Geometries.js +91 -14
- package/src/renderers/common/IndirectStorageBufferAttribute.js +25 -2
- package/src/renderers/common/Info.js +78 -35
- package/src/renderers/common/Lighting.js +34 -6
- package/src/renderers/common/Pipeline.js +22 -0
- package/src/renderers/common/Pipelines.js +148 -5
- package/src/renderers/common/PostProcessing.js +99 -11
- package/src/renderers/common/ProgrammableStage.js +60 -2
- package/src/renderers/common/QuadMesh.js +54 -5
- package/src/renderers/common/RenderBundle.js +14 -8
- package/src/renderers/common/RenderBundles.js +39 -10
- package/src/renderers/common/RenderContext.js +201 -2
- package/src/renderers/common/RenderContexts.js +59 -6
- package/src/renderers/common/RenderList.js +178 -0
- package/src/renderers/common/RenderLists.js +40 -3
- package/src/renderers/common/RenderObject.js +400 -17
- package/src/renderers/common/RenderObjects.js +103 -7
- package/src/renderers/common/RenderPipeline.js +24 -0
- package/src/renderers/common/Renderer.js +1170 -86
- package/src/renderers/common/RendererUtils.js +193 -0
- package/src/renderers/common/SampledTexture.js +120 -0
- package/src/renderers/common/Sampler.js +30 -0
- package/src/renderers/common/StorageBuffer.js +24 -0
- package/src/renderers/common/StorageBufferAttribute.js +31 -2
- package/src/renderers/common/StorageInstancedBufferAttribute.js +31 -2
- package/src/renderers/common/StorageTexture.js +38 -0
- package/src/renderers/common/Textures.js +97 -7
- package/src/renderers/common/TimestampQueryPool.js +39 -0
- package/src/renderers/common/Uniform.js +225 -3
- package/src/renderers/common/UniformBuffer.js +19 -0
- package/src/renderers/common/UniformsGroup.js +141 -2
- package/src/renderers/common/XRManager.js +1193 -0
- package/src/renderers/common/XRRenderTarget.js +74 -0
- package/src/renderers/common/extras/PMREMGenerator.js +76 -10
- package/src/renderers/common/nodes/NodeBuilderState.js +99 -5
- package/src/renderers/common/nodes/NodeLibrary.js +89 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +90 -2
- package/src/renderers/common/nodes/NodeSampler.js +28 -0
- package/src/renderers/common/nodes/NodeStorageBuffer.js +35 -0
- package/src/renderers/common/nodes/NodeUniform.js +243 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +29 -0
- package/src/renderers/common/nodes/NodeUniformsGroup.js +31 -18
- package/src/renderers/common/nodes/Nodes.js +352 -78
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +7 -7
- package/src/renderers/webgl/WebGLBackground.js +4 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +819 -116
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +347 -18
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +58 -1
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
- package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +323 -11
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +168 -22
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +359 -0
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +43 -0
- package/src/renderers/webgpu/WebGPUBackend.js +578 -164
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +36 -0
- package/src/renderers/webgpu/WebGPURenderer.js +36 -0
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +20 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +21 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +674 -52
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +17 -0
- package/src/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +95 -14
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +94 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +102 -3
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +98 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +262 -18
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +274 -0
- package/src/renderers/webgpu/utils/WebGPUUtils.js +116 -4
- package/src/renderers/webxr/WebXRDepthSensing.js +1 -1
- package/src/renderers/webxr/WebXRManager.js +19 -2
- package/src/textures/Data3DTexture.js +2 -2
- package/src/textures/Texture.js +4 -0
- package/src/textures/VideoFrameTexture.js +35 -0
- package/examples/jsm/animation/MMDAnimationHelper.js +0 -1209
- package/examples/jsm/animation/MMDPhysics.js +0 -1408
- package/examples/jsm/exporters/MMDExporter.js +0 -223
- package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -176
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/loaders/MMDLoader.js +0 -2298
- package/examples/jsm/objects/InstancedPoints.js +0 -19
- package/examples/jsm/shaders/MMDToonShader.js +0 -134
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -156
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -24
- package/src/nodes/core/UniformGroup.js +0 -13
- package/src/nodes/fog/FogExp2Node.js +0 -35
- package/src/nodes/fog/FogNode.js +0 -50
- package/src/nodes/fog/FogRangeNode.js +0 -36
- package/src/renderers/common/PostProcessingUtils.js +0 -86
package/src/nodes/Nodes.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export * from './core/constants.js';
|
|
3
3
|
|
|
4
4
|
// core
|
|
5
|
+
export { default as ArrayNode } from './core/ArrayNode.js';
|
|
5
6
|
export { default as AssignNode } from './core/AssignNode.js';
|
|
6
7
|
export { default as AttributeNode } from './core/AttributeNode.js';
|
|
7
8
|
export { default as BypassNode } from './core/BypassNode.js';
|
|
@@ -28,6 +29,8 @@ export { default as TempNode } from './core/TempNode.js';
|
|
|
28
29
|
export { default as UniformGroupNode } from './core/UniformGroupNode.js';
|
|
29
30
|
export { default as UniformNode } from './core/UniformNode.js';
|
|
30
31
|
export { default as VaryingNode } from './core/VaryingNode.js';
|
|
32
|
+
export { default as StructNode } from './core/StructNode.js';
|
|
33
|
+
export { default as StructTypeNode } from './core/StructTypeNode.js';
|
|
31
34
|
export { default as OutputStructNode } from './core/OutputStructNode.js';
|
|
32
35
|
export { default as MRTNode } from './core/MRTNode.js';
|
|
33
36
|
|
|
@@ -52,6 +55,7 @@ export { default as StorageArrayElementNode } from './utils/StorageArrayElementN
|
|
|
52
55
|
export { default as TriplanarTexturesNode } from './utils/TriplanarTexturesNode.js';
|
|
53
56
|
export { default as ReflectorNode } from './utils/ReflectorNode.js';
|
|
54
57
|
export { default as RTTNode } from './utils/RTTNode.js';
|
|
58
|
+
export { default as MemberNode } from './utils/MemberNode.js';
|
|
55
59
|
|
|
56
60
|
// accessors
|
|
57
61
|
export { default as UniformArrayNode } from './accessors/UniformArrayNode.js';
|
|
@@ -67,7 +71,6 @@ export { default as MaterialReferenceNode } from './accessors/MaterialReferenceN
|
|
|
67
71
|
export { default as RendererReferenceNode } from './accessors/RendererReferenceNode.js';
|
|
68
72
|
export { default as MorphNode } from './accessors/MorphNode.js';
|
|
69
73
|
export { default as ModelNode } from './accessors/ModelNode.js';
|
|
70
|
-
export { default as ModelViewProjectionNode } from './accessors/ModelViewProjectionNode.js';
|
|
71
74
|
export { default as Object3DNode } from './accessors/Object3DNode.js';
|
|
72
75
|
export { default as PointUVNode } from './accessors/PointUVNode.js';
|
|
73
76
|
export { default as ReferenceNode } from './accessors/ReferenceNode.js';
|
|
@@ -104,11 +107,6 @@ export { default as FunctionNode } from './code/FunctionNode.js';
|
|
|
104
107
|
export { default as ScriptableNode } from './code/ScriptableNode.js';
|
|
105
108
|
export { default as ScriptableValueNode } from './code/ScriptableValueNode.js';
|
|
106
109
|
|
|
107
|
-
// fog
|
|
108
|
-
export { default as FogNode } from './fog/FogNode.js';
|
|
109
|
-
export { default as FogRangeNode } from './fog/FogRangeNode.js';
|
|
110
|
-
export { default as FogExp2Node } from './fog/FogExp2Node.js';
|
|
111
|
-
|
|
112
110
|
// geometry
|
|
113
111
|
export { default as RangeNode } from './geometry/RangeNode.js';
|
|
114
112
|
|
|
@@ -132,6 +130,7 @@ export { default as BasicEnvironmentNode } from './lighting/BasicEnvironmentNode
|
|
|
132
130
|
export { default as IrradianceNode } from './lighting/IrradianceNode.js';
|
|
133
131
|
export { default as AONode } from './lighting/AONode.js';
|
|
134
132
|
export { default as AnalyticLightNode } from './lighting/AnalyticLightNode.js';
|
|
133
|
+
export { default as ShadowBaseNode } from './lighting/ShadowBaseNode.js';
|
|
135
134
|
export { default as ShadowNode } from './lighting/ShadowNode.js';
|
|
136
135
|
|
|
137
136
|
// pmrem
|
package/src/nodes/TSL.js
CHANGED
|
@@ -11,6 +11,7 @@ export * from './core/IndexNode.js';
|
|
|
11
11
|
export * from './core/ParameterNode.js';
|
|
12
12
|
export * from './core/PropertyNode.js';
|
|
13
13
|
export * from './core/StackNode.js';
|
|
14
|
+
export * from './core/StructNode.js';
|
|
14
15
|
export * from './core/UniformGroupNode.js';
|
|
15
16
|
export * from './core/UniformNode.js';
|
|
16
17
|
export * from './core/VaryingNode.js';
|
|
@@ -115,9 +116,7 @@ export * from './code/ScriptableNode.js';
|
|
|
115
116
|
export * from './code/ScriptableValueNode.js';
|
|
116
117
|
|
|
117
118
|
// fog
|
|
118
|
-
export * from './fog/
|
|
119
|
-
export * from './fog/FogRangeNode.js';
|
|
120
|
-
export * from './fog/FogExp2Node.js';
|
|
119
|
+
export * from './fog/Fog.js';
|
|
121
120
|
|
|
122
121
|
// geometry
|
|
123
122
|
export * from './geometry/RangeNode.js';
|
|
@@ -133,6 +132,7 @@ export * from './gpgpu/AtomicFunctionNode.js';
|
|
|
133
132
|
export * from './accessors/Lights.js';
|
|
134
133
|
export * from './lighting/LightsNode.js';
|
|
135
134
|
export * from './lighting/LightingContextNode.js';
|
|
135
|
+
export * from './lighting/ShadowBaseNode.js';
|
|
136
136
|
export * from './lighting/ShadowNode.js';
|
|
137
137
|
export * from './lighting/PointLightNode.js';
|
|
138
138
|
|
|
@@ -143,6 +143,9 @@ export * from './pmrem/PMREMUtils.js';
|
|
|
143
143
|
// procedural
|
|
144
144
|
export * from './procedural/Checker.js';
|
|
145
145
|
|
|
146
|
+
// shapes
|
|
147
|
+
export * from './shapes/Shapes.js';
|
|
148
|
+
|
|
146
149
|
// materialX
|
|
147
150
|
export * from './materialx/MaterialXNodes.js';
|
|
148
151
|
|
|
@@ -6,11 +6,38 @@ import { mix } from '../math/MathNode.js';
|
|
|
6
6
|
import { anisotropy, anisotropyB, roughness } from '../core/PropertyNode.js';
|
|
7
7
|
import { positionViewDirection } from './Position.js';
|
|
8
8
|
|
|
9
|
+
/** @module AccessorsUtils **/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* TSL object that represents the TBN matrix in view space.
|
|
13
|
+
*
|
|
14
|
+
* @type {Node<mat3>}
|
|
15
|
+
*/
|
|
9
16
|
export const TBNViewMatrix = /*@__PURE__*/ mat3( tangentView, bitangentView, normalView );
|
|
10
17
|
|
|
18
|
+
/**
|
|
19
|
+
* TSL object that represents the parallax direction.
|
|
20
|
+
*
|
|
21
|
+
* @type {Node<mat3>}
|
|
22
|
+
*/
|
|
11
23
|
export const parallaxDirection = /*@__PURE__*/ positionViewDirection.mul( TBNViewMatrix )/*.normalize()*/;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* TSL function for computing parallax uv coordinates.
|
|
27
|
+
*
|
|
28
|
+
* @function
|
|
29
|
+
* @param {Node<vec2>} uv - A uv node.
|
|
30
|
+
* @param {Node<vec2>} scale - A scale node.
|
|
31
|
+
* @returns {Node<vec2>} Parallax uv coordinates.
|
|
32
|
+
*/
|
|
12
33
|
export const parallaxUV = ( uv, scale ) => uv.sub( parallaxDirection.mul( scale ) );
|
|
13
34
|
|
|
35
|
+
/**
|
|
36
|
+
* TSL function for computing bent normals.
|
|
37
|
+
*
|
|
38
|
+
* @function
|
|
39
|
+
* @returns {Node<vec3>} Bent normals.
|
|
40
|
+
*/
|
|
14
41
|
export const transformedBentNormalView = /*@__PURE__*/ ( () => {
|
|
15
42
|
|
|
16
43
|
// https://google.github.io/filament/Filament.md.html#lighting/imagebasedlights/anisotropy
|
|
@@ -1,25 +1,66 @@
|
|
|
1
1
|
import StorageInstancedBufferAttribute from '../../renderers/common/StorageInstancedBufferAttribute.js';
|
|
2
2
|
import StorageBufferAttribute from '../../renderers/common/StorageBufferAttribute.js';
|
|
3
3
|
import { storage } from './StorageBufferNode.js';
|
|
4
|
-
import { getLengthFromType } from '../core/NodeUtils.js';
|
|
4
|
+
import { getLengthFromType, getTypedArrayFromType } from '../core/NodeUtils.js';
|
|
5
5
|
|
|
6
|
+
/** @module Arrays **/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* TSL function for creating a storage buffer node with a configured `StorageBufferAttribute`.
|
|
10
|
+
*
|
|
11
|
+
* @function
|
|
12
|
+
* @param {Number|TypedArray} count - The data count. It is also valid to pass a typed array as an argument.
|
|
13
|
+
* @param {String|Struct} [type='float'] - The data type.
|
|
14
|
+
* @returns {StorageBufferNode}
|
|
15
|
+
*/
|
|
6
16
|
export const attributeArray = ( count, type = 'float' ) => {
|
|
7
17
|
|
|
8
|
-
|
|
18
|
+
let itemSize, typedArray;
|
|
19
|
+
|
|
20
|
+
if ( type.isStruct === true ) {
|
|
21
|
+
|
|
22
|
+
itemSize = type.layout.getLength();
|
|
23
|
+
typedArray = getTypedArrayFromType( 'float' );
|
|
24
|
+
|
|
25
|
+
} else {
|
|
26
|
+
|
|
27
|
+
itemSize = getLengthFromType( type );
|
|
28
|
+
typedArray = getTypedArrayFromType( type );
|
|
29
|
+
|
|
30
|
+
}
|
|
9
31
|
|
|
10
|
-
const buffer = new StorageBufferAttribute( count, itemSize );
|
|
32
|
+
const buffer = new StorageBufferAttribute( count, itemSize, typedArray );
|
|
11
33
|
const node = storage( buffer, type, count );
|
|
12
34
|
|
|
13
35
|
return node;
|
|
14
36
|
|
|
15
37
|
};
|
|
16
38
|
|
|
17
|
-
|
|
39
|
+
/**
|
|
40
|
+
* TSL function for creating a storage buffer node with a configured `StorageInstancedBufferAttribute`.
|
|
41
|
+
*
|
|
42
|
+
* @function
|
|
43
|
+
* @param {Number|TypedArray} count - The data count. It is also valid to pass a typed array as an argument.
|
|
44
|
+
* @param {String|Struct} [type='float'] - The data type.
|
|
45
|
+
* @returns {StorageBufferNode}
|
|
46
|
+
*/
|
|
18
47
|
export const instancedArray = ( count, type = 'float' ) => {
|
|
19
48
|
|
|
20
|
-
|
|
49
|
+
let itemSize, typedArray;
|
|
50
|
+
|
|
51
|
+
if ( type.isStruct === true ) {
|
|
52
|
+
|
|
53
|
+
itemSize = type.layout.getLength();
|
|
54
|
+
typedArray = getTypedArrayFromType( 'float' );
|
|
55
|
+
|
|
56
|
+
} else {
|
|
57
|
+
|
|
58
|
+
itemSize = getLengthFromType( type );
|
|
59
|
+
typedArray = getTypedArrayFromType( type );
|
|
60
|
+
|
|
61
|
+
}
|
|
21
62
|
|
|
22
|
-
const buffer = new StorageInstancedBufferAttribute( count, itemSize );
|
|
63
|
+
const buffer = new StorageInstancedBufferAttribute( count, itemSize, typedArray );
|
|
23
64
|
const node = storage( buffer, type, count );
|
|
24
65
|
|
|
25
66
|
return node;
|
|
@@ -8,6 +8,15 @@ import { tangentLocal } from './Tangent.js';
|
|
|
8
8
|
import { instanceIndex, drawIndex } from '../core/IndexNode.js';
|
|
9
9
|
import { varyingProperty } from '../core/PropertyNode.js';
|
|
10
10
|
|
|
11
|
+
/** @module BatchNode **/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This node implements the vertex shader logic which is required
|
|
15
|
+
* when rendering 3D objects via batching. `BatchNode` must be used
|
|
16
|
+
* with instances of {@link BatchedMesh}.
|
|
17
|
+
*
|
|
18
|
+
* @augments Node
|
|
19
|
+
*/
|
|
11
20
|
class BatchNode extends Node {
|
|
12
21
|
|
|
13
22
|
static get type() {
|
|
@@ -16,21 +25,41 @@ class BatchNode extends Node {
|
|
|
16
25
|
|
|
17
26
|
}
|
|
18
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Constructs a new batch node.
|
|
30
|
+
*
|
|
31
|
+
* @param {BatchedMesh} batchMesh - A reference to batched mesh.
|
|
32
|
+
*/
|
|
19
33
|
constructor( batchMesh ) {
|
|
20
34
|
|
|
21
35
|
super( 'void' );
|
|
22
36
|
|
|
37
|
+
/**
|
|
38
|
+
* A reference to batched mesh.
|
|
39
|
+
*
|
|
40
|
+
* @type {BatchedMesh}
|
|
41
|
+
*/
|
|
23
42
|
this.batchMesh = batchMesh;
|
|
24
43
|
|
|
25
|
-
|
|
44
|
+
/**
|
|
45
|
+
* The batching index node.
|
|
46
|
+
*
|
|
47
|
+
* @type {IndexNode?}
|
|
48
|
+
* @default null
|
|
49
|
+
*/
|
|
26
50
|
this.batchingIdNode = null;
|
|
27
51
|
|
|
28
52
|
}
|
|
29
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Setups the internal buffers and nodes and assigns the transformed vertex data
|
|
56
|
+
* to predefined node variables for accumulation. That follows the same patterns
|
|
57
|
+
* like with morph and skinning nodes.
|
|
58
|
+
*
|
|
59
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
60
|
+
*/
|
|
30
61
|
setup( builder ) {
|
|
31
62
|
|
|
32
|
-
// POSITION
|
|
33
|
-
|
|
34
63
|
if ( this.batchingIdNode === null ) {
|
|
35
64
|
|
|
36
65
|
if ( builder.getDrawIndex() === null ) {
|
|
@@ -47,9 +76,9 @@ class BatchNode extends Node {
|
|
|
47
76
|
|
|
48
77
|
const getIndirectIndex = Fn( ( [ id ] ) => {
|
|
49
78
|
|
|
50
|
-
const size = textureSize( textureLoad( this.batchMesh._indirectTexture ), 0 );
|
|
51
|
-
const x = int( id ).modInt(
|
|
52
|
-
const y = int( id ).div(
|
|
79
|
+
const size = int( textureSize( textureLoad( this.batchMesh._indirectTexture ), 0 ) );
|
|
80
|
+
const x = int( id ).modInt( size );
|
|
81
|
+
const y = int( id ).div( size );
|
|
53
82
|
return textureLoad( this.batchMesh._indirectTexture, ivec2( x, y ) ).x;
|
|
54
83
|
|
|
55
84
|
} ).setLayout( {
|
|
@@ -125,4 +154,11 @@ class BatchNode extends Node {
|
|
|
125
154
|
|
|
126
155
|
export default BatchNode;
|
|
127
156
|
|
|
157
|
+
/**
|
|
158
|
+
* TSL function for creating a batch node.
|
|
159
|
+
*
|
|
160
|
+
* @function
|
|
161
|
+
* @param {BatchedMesh} batchMesh - A reference to batched mesh.
|
|
162
|
+
* @returns {BatchNode}
|
|
163
|
+
*/
|
|
128
164
|
export const batch = /*@__PURE__*/ nodeProxy( BatchNode );
|
|
@@ -3,11 +3,48 @@ import { cameraViewMatrix } from './Camera.js';
|
|
|
3
3
|
import { normalGeometry, normalLocal, normalView, normalWorld, transformedNormalView } from './Normal.js';
|
|
4
4
|
import { tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTangentView } from './Tangent.js';
|
|
5
5
|
|
|
6
|
+
/** @module Bitangent **/
|
|
7
|
+
|
|
6
8
|
const getBitangent = ( crossNormalTangent ) => crossNormalTangent.mul( tangentGeometry.w ).xyz;
|
|
7
9
|
|
|
10
|
+
/**
|
|
11
|
+
* TSL object that represents the bitangent attribute of the current rendered object.
|
|
12
|
+
*
|
|
13
|
+
* @type {Node<vec3>}
|
|
14
|
+
*/
|
|
8
15
|
export const bitangentGeometry = /*@__PURE__*/ varying( getBitangent( normalGeometry.cross( tangentGeometry ) ), 'v_bitangentGeometry' ).normalize().toVar( 'bitangentGeometry' );
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* TSL object that represents the vertex bitangent in local space of the current rendered object.
|
|
19
|
+
*
|
|
20
|
+
* @type {Node<vec3>}
|
|
21
|
+
*/
|
|
9
22
|
export const bitangentLocal = /*@__PURE__*/ varying( getBitangent( normalLocal.cross( tangentLocal ) ), 'v_bitangentLocal' ).normalize().toVar( 'bitangentLocal' );
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* TSL object that represents the vertex bitangent in view space of the current rendered object.
|
|
26
|
+
*
|
|
27
|
+
* @type {Node<vec4>}
|
|
28
|
+
*/
|
|
10
29
|
export const bitangentView = /*@__PURE__*/ varying( getBitangent( normalView.cross( tangentView ) ), 'v_bitangentView' ).normalize().toVar( 'bitangentView' );
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* TSL object that represents the vertex bitangent in world space of the current rendered object.
|
|
33
|
+
*
|
|
34
|
+
* @type {Node<vec4>}
|
|
35
|
+
*/
|
|
11
36
|
export const bitangentWorld = /*@__PURE__*/ varying( getBitangent( normalWorld.cross( tangentWorld ) ), 'v_bitangentWorld' ).normalize().toVar( 'bitangentWorld' );
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* TSL object that represents the transformed vertex bitangent in view space of the current rendered object.
|
|
40
|
+
*
|
|
41
|
+
* @type {Node<vec4>}
|
|
42
|
+
*/
|
|
12
43
|
export const transformedBitangentView = /*@__PURE__*/ getBitangent( transformedNormalView.cross( transformedTangentView ) ).normalize().toVar( 'transformedBitangentView' );
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* TSL object that represents the transformed vertex bitangent in world space of the current rendered object.
|
|
47
|
+
*
|
|
48
|
+
* @type {Node<vec4>}
|
|
49
|
+
*/
|
|
13
50
|
export const transformedBitangentWorld = /*@__PURE__*/ transformedBitangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedBitangentWorld' );
|
|
@@ -6,6 +6,30 @@ import { InterleavedBufferAttribute } from '../../core/InterleavedBufferAttribut
|
|
|
6
6
|
import { InterleavedBuffer } from '../../core/InterleavedBuffer.js';
|
|
7
7
|
import { StaticDrawUsage, DynamicDrawUsage } from '../../constants.js';
|
|
8
8
|
|
|
9
|
+
/** @module BufferAttributeNode **/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* In earlier `three.js` versions it was only possible to define attribute data
|
|
13
|
+
* on geometry level. With `BufferAttributeNode`, it is also possible to do this
|
|
14
|
+
* on the node level.
|
|
15
|
+
* ```js
|
|
16
|
+
* const geometry = new THREE.PlaneGeometry();
|
|
17
|
+
* const positionAttribute = geometry.getAttribute( 'position' );
|
|
18
|
+
*
|
|
19
|
+
* const colors = [];
|
|
20
|
+
* for ( let i = 0; i < position.count; i ++ ) {
|
|
21
|
+
* colors.push( 1, 0, 0 );
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* material.colorNode = bufferAttribute( new THREE.Float32BufferAttribute( colors, 3 ) );
|
|
25
|
+
* ```
|
|
26
|
+
* This new approach is especially interesting when geometry data are generated via
|
|
27
|
+
* compute shaders. The below line converts a storage buffer into an attribute node.
|
|
28
|
+
* ```js
|
|
29
|
+
* material.positionNode = positionBuffer.toAttribute();
|
|
30
|
+
* ```
|
|
31
|
+
* @augments InputNode
|
|
32
|
+
*/
|
|
9
33
|
class BufferAttributeNode extends InputNode {
|
|
10
34
|
|
|
11
35
|
static get type() {
|
|
@@ -14,21 +38,82 @@ class BufferAttributeNode extends InputNode {
|
|
|
14
38
|
|
|
15
39
|
}
|
|
16
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Constructs a new buffer attribute node.
|
|
43
|
+
*
|
|
44
|
+
* @param {BufferAttribute|InterleavedBuffer|TypedArray} value - The attribute data.
|
|
45
|
+
* @param {String?} [bufferType=null] - The buffer type (e.g. `'vec3'`).
|
|
46
|
+
* @param {Number} [bufferStride=0] - The buffer stride.
|
|
47
|
+
* @param {Number} [bufferOffset=0] - The buffer offset.
|
|
48
|
+
*/
|
|
17
49
|
constructor( value, bufferType = null, bufferStride = 0, bufferOffset = 0 ) {
|
|
18
50
|
|
|
19
51
|
super( value, bufferType );
|
|
20
52
|
|
|
53
|
+
/**
|
|
54
|
+
* This flag can be used for type testing.
|
|
55
|
+
*
|
|
56
|
+
* @type {Boolean}
|
|
57
|
+
* @readonly
|
|
58
|
+
* @default true
|
|
59
|
+
*/
|
|
21
60
|
this.isBufferNode = true;
|
|
22
61
|
|
|
62
|
+
/**
|
|
63
|
+
* The buffer type (e.g. `'vec3'`).
|
|
64
|
+
*
|
|
65
|
+
* @type {String}
|
|
66
|
+
* @default null
|
|
67
|
+
*/
|
|
23
68
|
this.bufferType = bufferType;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The buffer stride.
|
|
72
|
+
*
|
|
73
|
+
* @type {Number}
|
|
74
|
+
* @default 0
|
|
75
|
+
*/
|
|
24
76
|
this.bufferStride = bufferStride;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The buffer offset.
|
|
80
|
+
*
|
|
81
|
+
* @type {Number}
|
|
82
|
+
* @default 0
|
|
83
|
+
*/
|
|
25
84
|
this.bufferOffset = bufferOffset;
|
|
26
85
|
|
|
86
|
+
/**
|
|
87
|
+
* The usage property. Set this to `THREE.DynamicDrawUsage` via `.setUsage()`,
|
|
88
|
+
* if you are planning to update the attribute data per frame.
|
|
89
|
+
*
|
|
90
|
+
* @type {Number}
|
|
91
|
+
* @default StaticDrawUsage
|
|
92
|
+
*/
|
|
27
93
|
this.usage = StaticDrawUsage;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Whether the attribute is instanced or not.
|
|
97
|
+
*
|
|
98
|
+
* @type {Boolean}
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
28
101
|
this.instanced = false;
|
|
29
102
|
|
|
103
|
+
/**
|
|
104
|
+
* A reference to the buffer attribute.
|
|
105
|
+
*
|
|
106
|
+
* @type {BufferAttribute?}
|
|
107
|
+
* @default null
|
|
108
|
+
*/
|
|
30
109
|
this.attribute = null;
|
|
31
110
|
|
|
111
|
+
/**
|
|
112
|
+
* `BufferAttributeNode` sets this property to `true` by default.
|
|
113
|
+
*
|
|
114
|
+
* @type {Boolean}
|
|
115
|
+
* @default true
|
|
116
|
+
*/
|
|
32
117
|
this.global = true;
|
|
33
118
|
|
|
34
119
|
if ( value && value.isBufferAttribute === true ) {
|
|
@@ -41,6 +126,13 @@ class BufferAttributeNode extends InputNode {
|
|
|
41
126
|
|
|
42
127
|
}
|
|
43
128
|
|
|
129
|
+
/**
|
|
130
|
+
* This method is overwritten since the attribute data might be shared
|
|
131
|
+
* and thus the hash should be shared as well.
|
|
132
|
+
*
|
|
133
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
134
|
+
* @return {String} The hash.
|
|
135
|
+
*/
|
|
44
136
|
getHash( builder ) {
|
|
45
137
|
|
|
46
138
|
if ( this.bufferStride === 0 && this.bufferOffset === 0 ) {
|
|
@@ -65,6 +157,13 @@ class BufferAttributeNode extends InputNode {
|
|
|
65
157
|
|
|
66
158
|
}
|
|
67
159
|
|
|
160
|
+
/**
|
|
161
|
+
* This method is overwritten since the node type is inferred from
|
|
162
|
+
* the buffer attribute.
|
|
163
|
+
*
|
|
164
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
165
|
+
* @return {String} The node type.
|
|
166
|
+
*/
|
|
68
167
|
getNodeType( builder ) {
|
|
69
168
|
|
|
70
169
|
if ( this.bufferType === null ) {
|
|
@@ -77,6 +176,13 @@ class BufferAttributeNode extends InputNode {
|
|
|
77
176
|
|
|
78
177
|
}
|
|
79
178
|
|
|
179
|
+
/**
|
|
180
|
+
* Depending on which value was passed to the node, `setup()` behaves
|
|
181
|
+
* differently. If no instance of `BufferAttribute` was passed, the method
|
|
182
|
+
* creates an internal attribute and configures it respectively.
|
|
183
|
+
*
|
|
184
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
185
|
+
*/
|
|
80
186
|
setup( builder ) {
|
|
81
187
|
|
|
82
188
|
if ( this.attribute !== null ) return;
|
|
@@ -97,6 +203,12 @@ class BufferAttributeNode extends InputNode {
|
|
|
97
203
|
|
|
98
204
|
}
|
|
99
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Generates the code snippet of the buffer attribute node.
|
|
208
|
+
*
|
|
209
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
210
|
+
* @return {String} The generated code snippet.
|
|
211
|
+
*/
|
|
100
212
|
generate( builder ) {
|
|
101
213
|
|
|
102
214
|
const nodeType = this.getNodeType( builder );
|
|
@@ -124,12 +236,24 @@ class BufferAttributeNode extends InputNode {
|
|
|
124
236
|
|
|
125
237
|
}
|
|
126
238
|
|
|
239
|
+
/**
|
|
240
|
+
* Overwrites the default implementation to return a fixed value `'bufferAttribute'`.
|
|
241
|
+
*
|
|
242
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
243
|
+
* @return {String} The input type.
|
|
244
|
+
*/
|
|
127
245
|
getInputType( /*builder*/ ) {
|
|
128
246
|
|
|
129
247
|
return 'bufferAttribute';
|
|
130
248
|
|
|
131
249
|
}
|
|
132
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Sets the `usage` property to the given value.
|
|
253
|
+
*
|
|
254
|
+
* @param {Number} value - The usage to set.
|
|
255
|
+
* @return {BufferAttributeNode} A reference to this node.
|
|
256
|
+
*/
|
|
133
257
|
setUsage( value ) {
|
|
134
258
|
|
|
135
259
|
this.usage = value;
|
|
@@ -144,6 +268,12 @@ class BufferAttributeNode extends InputNode {
|
|
|
144
268
|
|
|
145
269
|
}
|
|
146
270
|
|
|
271
|
+
/**
|
|
272
|
+
* Sets the `instanced` property to the given value.
|
|
273
|
+
*
|
|
274
|
+
* @param {Boolean} value - The value to set.
|
|
275
|
+
* @return {BufferAttributeNode} A reference to this node.
|
|
276
|
+
*/
|
|
147
277
|
setInstanced( value ) {
|
|
148
278
|
|
|
149
279
|
this.instanced = value;
|
|
@@ -156,10 +286,53 @@ class BufferAttributeNode extends InputNode {
|
|
|
156
286
|
|
|
157
287
|
export default BufferAttributeNode;
|
|
158
288
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
289
|
+
/**
|
|
290
|
+
* TSL function for creating a buffer attribute node.
|
|
291
|
+
*
|
|
292
|
+
* @function
|
|
293
|
+
* @param {BufferAttribute|InterleavedBuffer|TypedArray} array - The attribute data.
|
|
294
|
+
* @param {String?} [type=null] - The buffer type (e.g. `'vec3'`).
|
|
295
|
+
* @param {Number} [stride=0] - The buffer stride.
|
|
296
|
+
* @param {Number} [offset=0] - The buffer offset.
|
|
297
|
+
* @returns {BufferAttributeNode}
|
|
298
|
+
*/
|
|
299
|
+
export const bufferAttribute = ( array, type = null, stride = 0, offset = 0 ) => nodeObject( new BufferAttributeNode( array, type, stride, offset ) );
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* TSL function for creating a buffer attribute node but with dynamic draw usage.
|
|
303
|
+
* Use this function if attribute data are updated per frame.
|
|
304
|
+
*
|
|
305
|
+
* @function
|
|
306
|
+
* @param {BufferAttribute|InterleavedBuffer|TypedArray} array - The attribute data.
|
|
307
|
+
* @param {String?} [type=null] - The buffer type (e.g. `'vec3'`).
|
|
308
|
+
* @param {Number} [stride=0] - The buffer stride.
|
|
309
|
+
* @param {Number} [offset=0] - The buffer offset.
|
|
310
|
+
* @returns {BufferAttributeNode}
|
|
311
|
+
*/
|
|
312
|
+
export const dynamicBufferAttribute = ( array, type = null, stride = 0, offset = 0 ) => bufferAttribute( array, type, stride, offset ).setUsage( DynamicDrawUsage );
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* TSL function for creating a buffer attribute node but with enabled instancing
|
|
316
|
+
*
|
|
317
|
+
* @function
|
|
318
|
+
* @param {BufferAttribute|InterleavedBuffer|TypedArray} array - The attribute data.
|
|
319
|
+
* @param {String?} [type=null] - The buffer type (e.g. `'vec3'`).
|
|
320
|
+
* @param {Number} [stride=0] - The buffer stride.
|
|
321
|
+
* @param {Number} [offset=0] - The buffer offset.
|
|
322
|
+
* @returns {BufferAttributeNode}
|
|
323
|
+
*/
|
|
324
|
+
export const instancedBufferAttribute = ( array, type = null, stride = 0, offset = 0 ) => bufferAttribute( array, type, stride, offset ).setInstanced( true );
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* TSL function for creating a buffer attribute node but with dynamic draw usage and enabled instancing
|
|
328
|
+
*
|
|
329
|
+
* @function
|
|
330
|
+
* @param {BufferAttribute|InterleavedBuffer|TypedArray} array - The attribute data.
|
|
331
|
+
* @param {String?} [type=null] - The buffer type (e.g. `'vec3'`).
|
|
332
|
+
* @param {Number} [stride=0] - The buffer stride.
|
|
333
|
+
* @param {Number} [offset=0] - The buffer offset.
|
|
334
|
+
* @returns {BufferAttributeNode}
|
|
335
|
+
*/
|
|
336
|
+
export const instancedDynamicBufferAttribute = ( array, type = null, stride = 0, offset = 0 ) => dynamicBufferAttribute( array, type, stride, offset ).setInstanced( true );
|
|
164
337
|
|
|
165
338
|
addMethodChaining( 'toAttribute', ( bufferNode ) => bufferAttribute( bufferNode.value ) );
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import UniformNode from '../core/UniformNode.js';
|
|
2
2
|
import { nodeObject } from '../tsl/TSLBase.js';
|
|
3
3
|
|
|
4
|
+
/** @module BufferNode **/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A special type of uniform node which represents array-like data
|
|
8
|
+
* as uniform buffers. The access usually happens via `element()`
|
|
9
|
+
* which returns an instance of {@link ArrayElementNode}. For example:
|
|
10
|
+
*
|
|
11
|
+
* ```js
|
|
12
|
+
* const bufferNode = buffer( array, 'mat4', count );
|
|
13
|
+
* const matrixNode = bufferNode.element( index ); // access a matrix from the buffer
|
|
14
|
+
* ```
|
|
15
|
+
* In general, it is recommended to use the more managed {@link UniformArrayNode}
|
|
16
|
+
* since it handles more input types and automatically cares about buffer paddings.
|
|
17
|
+
*
|
|
18
|
+
* @augments module:UniformNode~UniformNode
|
|
19
|
+
*/
|
|
4
20
|
class BufferNode extends UniformNode {
|
|
5
21
|
|
|
6
22
|
static get type() {
|
|
@@ -9,23 +25,61 @@ class BufferNode extends UniformNode {
|
|
|
9
25
|
|
|
10
26
|
}
|
|
11
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Constructs a new buffer node.
|
|
30
|
+
*
|
|
31
|
+
* @param {Array<Number>} value - Array-like buffer data.
|
|
32
|
+
* @param {String} bufferType - The data type of the buffer.
|
|
33
|
+
* @param {Number} [bufferCount=0] - The count of buffer elements.
|
|
34
|
+
*/
|
|
12
35
|
constructor( value, bufferType, bufferCount = 0 ) {
|
|
13
36
|
|
|
14
37
|
super( value, bufferType );
|
|
15
38
|
|
|
39
|
+
/**
|
|
40
|
+
* This flag can be used for type testing.
|
|
41
|
+
*
|
|
42
|
+
* @type {Boolean}
|
|
43
|
+
* @readonly
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
16
46
|
this.isBufferNode = true;
|
|
17
47
|
|
|
48
|
+
/**
|
|
49
|
+
* The data type of the buffer.
|
|
50
|
+
*
|
|
51
|
+
* @type {String}
|
|
52
|
+
*/
|
|
18
53
|
this.bufferType = bufferType;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The uniform node that holds the value of the reference node.
|
|
57
|
+
*
|
|
58
|
+
* @type {Number}
|
|
59
|
+
* @default 0
|
|
60
|
+
*/
|
|
19
61
|
this.bufferCount = bufferCount;
|
|
20
62
|
|
|
21
63
|
}
|
|
22
64
|
|
|
65
|
+
/**
|
|
66
|
+
* The data type of the buffer elements.
|
|
67
|
+
*
|
|
68
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
69
|
+
* @return {String} The element type.
|
|
70
|
+
*/
|
|
23
71
|
getElementType( builder ) {
|
|
24
72
|
|
|
25
73
|
return this.getNodeType( builder );
|
|
26
74
|
|
|
27
75
|
}
|
|
28
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Overwrites the default implementation to return a fixed value `'buffer'`.
|
|
79
|
+
*
|
|
80
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
81
|
+
* @return {String} The input type.
|
|
82
|
+
*/
|
|
29
83
|
getInputType( /*builder*/ ) {
|
|
30
84
|
|
|
31
85
|
return 'buffer';
|
|
@@ -36,4 +90,13 @@ class BufferNode extends UniformNode {
|
|
|
36
90
|
|
|
37
91
|
export default BufferNode;
|
|
38
92
|
|
|
93
|
+
/**
|
|
94
|
+
* TSL function for creating a buffer node.
|
|
95
|
+
*
|
|
96
|
+
* @function
|
|
97
|
+
* @param {Array} value - Array-like buffer data.
|
|
98
|
+
* @param {String} type - The data type of a buffer element.
|
|
99
|
+
* @param {Number} count - The count of buffer elements.
|
|
100
|
+
* @returns {BufferNode}
|
|
101
|
+
*/
|
|
39
102
|
export const buffer = ( value, type, count ) => nodeObject( new BufferNode( value, type, count ) );
|