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
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A special type of render target that is used when rendering
|
|
5
|
+
* with the WebXR Device API.
|
|
6
|
+
*
|
|
7
|
+
* @private
|
|
8
|
+
* @augments RenderTarget
|
|
9
|
+
*/
|
|
10
|
+
class XRRenderTarget extends RenderTarget {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Constructs a new XR render target.
|
|
14
|
+
*
|
|
15
|
+
* @param {Number} [width=1] - The width of the render target.
|
|
16
|
+
* @param {Number} [height=1] - The height of the render target.
|
|
17
|
+
* @param {Object} [options={}] - The configuration options.
|
|
18
|
+
*/
|
|
19
|
+
constructor( width = 1, height = 1, options = {} ) {
|
|
20
|
+
|
|
21
|
+
super( width, height, options );
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* This flag can be used for type testing.
|
|
25
|
+
*
|
|
26
|
+
* @type {Boolean}
|
|
27
|
+
* @readonly
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
|
+
this.isXRRenderTarget = true;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Whether the attachments of the render target
|
|
34
|
+
* are defined by external textures. This flag is
|
|
35
|
+
* set to `true` when using the WebXR Layers API.
|
|
36
|
+
*
|
|
37
|
+
* @type {Boolean}
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
40
|
+
this.hasExternalTextures = false;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Whether a depth buffer should automatically be allocated
|
|
44
|
+
* for this XR render target or not.
|
|
45
|
+
*
|
|
46
|
+
* Allocating a depth buffer is the default behavior of XR render
|
|
47
|
+
* targets. However, when using the WebXR Layers API, this flag
|
|
48
|
+
* must be set to `false` when the `ignoreDepthValues` property of
|
|
49
|
+
* the projection layers evaluates to `false`.
|
|
50
|
+
*
|
|
51
|
+
* Reference: {@link https://www.w3.org/TR/webxrlayers-1/#dom-xrprojectionlayer-ignoredepthvalues}.
|
|
52
|
+
*
|
|
53
|
+
* @type {Boolean}
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
this.autoAllocateDepthBuffer = true;
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
copy( source ) {
|
|
61
|
+
|
|
62
|
+
super.copy( source );
|
|
63
|
+
|
|
64
|
+
this.hasExternalTextures = source.hasExternalTextures;
|
|
65
|
+
this.autoAllocateDepthBuffer = source.autoAllocateDepthBuffer;
|
|
66
|
+
|
|
67
|
+
return this;
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { XRRenderTarget };
|
|
@@ -69,7 +69,9 @@ const _axisDirections = [
|
|
|
69
69
|
/*@__PURE__*/ new Vector3( 1, 1, 1 )
|
|
70
70
|
];
|
|
71
71
|
|
|
72
|
-
//
|
|
72
|
+
// maps blur materials to their uniforms dictionary
|
|
73
|
+
|
|
74
|
+
const _uniformsMap = new WeakMap();
|
|
73
75
|
|
|
74
76
|
// WebGPU Face indices
|
|
75
77
|
const _faceLib = [
|
|
@@ -77,8 +79,8 @@ const _faceLib = [
|
|
|
77
79
|
0, 4, 2
|
|
78
80
|
];
|
|
79
81
|
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
+
const _direction = /*@__PURE__*/ getDirection( uv(), attribute( 'faceIndex' ) ).normalize();
|
|
83
|
+
const _outputDirection = /*@__PURE__*/ vec3( _direction.x, _direction.y, _direction.z );
|
|
82
84
|
|
|
83
85
|
/**
|
|
84
86
|
* This class generates a Prefiltered, Mipmapped Radiance Environment Map
|
|
@@ -128,6 +130,14 @@ class PMREMGenerator {
|
|
|
128
130
|
* in radians to be applied to the scene before PMREM generation. Optional near
|
|
129
131
|
* and far planes ensure the scene is rendered in its entirety (the cubeCamera
|
|
130
132
|
* is placed at the origin).
|
|
133
|
+
*
|
|
134
|
+
* @param {Scene} scene - The scene to be captured.
|
|
135
|
+
* @param {Number} [sigma=0] - The blur radius in radians.
|
|
136
|
+
* @param {Number} [near=0.1] - The near plane distance.
|
|
137
|
+
* @param {Number} [far=100] - The far plane distance.
|
|
138
|
+
* @param {RenderTarget?} [renderTarget=null] - The render target to use.
|
|
139
|
+
* @return {RenderTarget} The resulting PMREM.
|
|
140
|
+
* @see fromSceneAsync
|
|
131
141
|
*/
|
|
132
142
|
fromScene( scene, sigma = 0, near = 0.1, far = 100, renderTarget = null ) {
|
|
133
143
|
|
|
@@ -168,6 +178,21 @@ class PMREMGenerator {
|
|
|
168
178
|
|
|
169
179
|
}
|
|
170
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Generates a PMREM from a supplied Scene, which can be faster than using an
|
|
183
|
+
* image if networking bandwidth is low. Optional sigma specifies a blur radius
|
|
184
|
+
* in radians to be applied to the scene before PMREM generation. Optional near
|
|
185
|
+
* and far planes ensure the scene is rendered in its entirety (the cubeCamera
|
|
186
|
+
* is placed at the origin).
|
|
187
|
+
*
|
|
188
|
+
* @param {Scene} scene - The scene to be captured.
|
|
189
|
+
* @param {Number} [sigma=0] - The blur radius in radians.
|
|
190
|
+
* @param {Number} [near=0.1] - The near plane distance.
|
|
191
|
+
* @param {Number} [far=100] - The far plane distance.
|
|
192
|
+
* @param {RenderTarget?} [renderTarget=null] - The render target to use.
|
|
193
|
+
* @return {Promise<RenderTarget>} The resulting PMREM.
|
|
194
|
+
* @see fromScene
|
|
195
|
+
*/
|
|
171
196
|
async fromSceneAsync( scene, sigma = 0, near = 0.1, far = 100, renderTarget = null ) {
|
|
172
197
|
|
|
173
198
|
if ( this._hasInitialized === false ) await this._renderer.init();
|
|
@@ -180,6 +205,11 @@ class PMREMGenerator {
|
|
|
180
205
|
* Generates a PMREM from an equirectangular texture, which can be either LDR
|
|
181
206
|
* or HDR. The ideal input image size is 1k (1024 x 512),
|
|
182
207
|
* as this matches best with the 256 x 256 cubemap output.
|
|
208
|
+
*
|
|
209
|
+
* @param {Texture} equirectangular - The equirectangular texture to be converted.
|
|
210
|
+
* @param {RenderTarget?} [renderTarget=null] - The render target to use.
|
|
211
|
+
* @return {RenderTarget} The resulting PMREM.
|
|
212
|
+
* @see fromEquirectangularAsync
|
|
183
213
|
*/
|
|
184
214
|
fromEquirectangular( equirectangular, renderTarget = null ) {
|
|
185
215
|
|
|
@@ -201,6 +231,16 @@ class PMREMGenerator {
|
|
|
201
231
|
|
|
202
232
|
}
|
|
203
233
|
|
|
234
|
+
/**
|
|
235
|
+
* Generates a PMREM from an equirectangular texture, which can be either LDR
|
|
236
|
+
* or HDR. The ideal input image size is 1k (1024 x 512),
|
|
237
|
+
* as this matches best with the 256 x 256 cubemap output.
|
|
238
|
+
*
|
|
239
|
+
* @param {Texture} equirectangular - The equirectangular texture to be converted.
|
|
240
|
+
* @param {RenderTarget?} [renderTarget=null] - The render target to use.
|
|
241
|
+
* @return {Promise<RenderTarget>} The resulting PMREM.
|
|
242
|
+
* @see fromEquirectangular
|
|
243
|
+
*/
|
|
204
244
|
async fromEquirectangularAsync( equirectangular, renderTarget = null ) {
|
|
205
245
|
|
|
206
246
|
if ( this._hasInitialized === false ) await this._renderer.init();
|
|
@@ -213,6 +253,11 @@ class PMREMGenerator {
|
|
|
213
253
|
* Generates a PMREM from an cubemap texture, which can be either LDR
|
|
214
254
|
* or HDR. The ideal input cube size is 256 x 256,
|
|
215
255
|
* as this matches best with the 256 x 256 cubemap output.
|
|
256
|
+
*
|
|
257
|
+
* @param {Texture} cubemap - The cubemap texture to be converted.
|
|
258
|
+
* @param {RenderTarget?} [renderTarget=null] - The render target to use.
|
|
259
|
+
* @return {RenderTarget} The resulting PMREM.
|
|
260
|
+
* @see fromCubemapAsync
|
|
216
261
|
*/
|
|
217
262
|
fromCubemap( cubemap, renderTarget = null ) {
|
|
218
263
|
|
|
@@ -234,6 +279,16 @@ class PMREMGenerator {
|
|
|
234
279
|
|
|
235
280
|
}
|
|
236
281
|
|
|
282
|
+
/**
|
|
283
|
+
* Generates a PMREM from an cubemap texture, which can be either LDR
|
|
284
|
+
* or HDR. The ideal input cube size is 256 x 256,
|
|
285
|
+
* with the 256 x 256 cubemap output.
|
|
286
|
+
*
|
|
287
|
+
* @param {Texture} cubemap - The cubemap texture to be converted.
|
|
288
|
+
* @param {RenderTarget?} [renderTarget=null] - The render target to use.
|
|
289
|
+
* @return {Promise<RenderTarget>} The resulting PMREM.
|
|
290
|
+
* @see fromCubemap
|
|
291
|
+
*/
|
|
237
292
|
async fromCubemapAsync( cubemap, renderTarget = null ) {
|
|
238
293
|
|
|
239
294
|
if ( this._hasInitialized === false ) await this._renderer.init();
|
|
@@ -245,6 +300,8 @@ class PMREMGenerator {
|
|
|
245
300
|
/**
|
|
246
301
|
* Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during
|
|
247
302
|
* your texture's network fetch for increased concurrency.
|
|
303
|
+
*
|
|
304
|
+
* @returns {Promise}
|
|
248
305
|
*/
|
|
249
306
|
async compileCubemapShader() {
|
|
250
307
|
|
|
@@ -260,6 +317,8 @@ class PMREMGenerator {
|
|
|
260
317
|
/**
|
|
261
318
|
* Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during
|
|
262
319
|
* your texture's network fetch for increased concurrency.
|
|
320
|
+
*
|
|
321
|
+
* @returns {Promise}
|
|
263
322
|
*/
|
|
264
323
|
async compileEquirectangularShader() {
|
|
265
324
|
|
|
@@ -406,8 +465,8 @@ class PMREMGenerator {
|
|
|
406
465
|
cubeCamera.far = far;
|
|
407
466
|
|
|
408
467
|
// px, py, pz, nx, ny, nz
|
|
409
|
-
const upSign = [
|
|
410
|
-
const forwardSign = [ 1, 1, 1, - 1,
|
|
468
|
+
const upSign = [ 1, 1, 1, 1, - 1, 1 ];
|
|
469
|
+
const forwardSign = [ 1, - 1, 1, - 1, 1, - 1 ];
|
|
411
470
|
|
|
412
471
|
const renderer = this._renderer;
|
|
413
472
|
|
|
@@ -562,6 +621,12 @@ class PMREMGenerator {
|
|
|
562
621
|
* the blur latitudinally (around the poles), and then longitudinally (towards
|
|
563
622
|
* the poles) to approximate the orthogonally-separable blur. It is least
|
|
564
623
|
* accurate at the poles, but still does a decent job.
|
|
624
|
+
*
|
|
625
|
+
* @param {RenderTarget} cubeUVRenderTarget - The cubemap render target.
|
|
626
|
+
* @param {Number} lodIn - The input level-of-detail.
|
|
627
|
+
* @param {Number} lodOut - The output level-of-detail.
|
|
628
|
+
* @param {Number} sigma - The blur radius in radians.
|
|
629
|
+
* @param {Vector3} [poleAxis] - The pole axis.
|
|
565
630
|
*/
|
|
566
631
|
_blur( cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis ) {
|
|
567
632
|
|
|
@@ -604,7 +669,7 @@ class PMREMGenerator {
|
|
|
604
669
|
const blurMesh = this._lodMeshes[ lodOut ];
|
|
605
670
|
blurMesh.material = blurMaterial;
|
|
606
671
|
|
|
607
|
-
const blurUniforms = blurMaterial
|
|
672
|
+
const blurUniforms = _uniformsMap.get( blurMaterial );
|
|
608
673
|
|
|
609
674
|
const pixels = this._sizeLods[ lodIn ] - 1;
|
|
610
675
|
const radiansPerPixel = isFinite( sigmaRadians ) ? Math.PI / ( 2 * pixels ) : 2 * Math.PI / ( 2 * MAX_SAMPLES - 1 );
|
|
@@ -808,7 +873,7 @@ function _getBlurShader( lodMax, width, height ) {
|
|
|
808
873
|
latitudinal,
|
|
809
874
|
weights,
|
|
810
875
|
poleAxis,
|
|
811
|
-
outputDirection,
|
|
876
|
+
outputDirection: _outputDirection,
|
|
812
877
|
dTheta,
|
|
813
878
|
samples,
|
|
814
879
|
envMap,
|
|
@@ -819,9 +884,10 @@ function _getBlurShader( lodMax, width, height ) {
|
|
|
819
884
|
};
|
|
820
885
|
|
|
821
886
|
const material = _getMaterial( 'blur' );
|
|
822
|
-
material.uniforms = materialUniforms; // TODO: Move to outside of the material
|
|
823
887
|
material.fragmentNode = blur( { ...materialUniforms, latitudinal: latitudinal.equal( 1 ) } );
|
|
824
888
|
|
|
889
|
+
_uniformsMap.set( material, materialUniforms );
|
|
890
|
+
|
|
825
891
|
return material;
|
|
826
892
|
|
|
827
893
|
}
|
|
@@ -829,7 +895,7 @@ function _getBlurShader( lodMax, width, height ) {
|
|
|
829
895
|
function _getCubemapMaterial( envTexture ) {
|
|
830
896
|
|
|
831
897
|
const material = _getMaterial( 'cubemap' );
|
|
832
|
-
material.fragmentNode = cubeTexture( envTexture,
|
|
898
|
+
material.fragmentNode = cubeTexture( envTexture, _outputDirection );
|
|
833
899
|
|
|
834
900
|
return material;
|
|
835
901
|
|
|
@@ -838,7 +904,7 @@ function _getCubemapMaterial( envTexture ) {
|
|
|
838
904
|
function _getEquirectMaterial( envTexture ) {
|
|
839
905
|
|
|
840
906
|
const material = _getMaterial( 'equirect' );
|
|
841
|
-
material.fragmentNode = texture( envTexture, equirectUV(
|
|
907
|
+
material.fragmentNode = texture( envTexture, equirectUV( _outputDirection ), 0 );
|
|
842
908
|
|
|
843
909
|
return material;
|
|
844
910
|
|
|
@@ -1,34 +1,128 @@
|
|
|
1
1
|
import BindGroup from '../BindGroup.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* This module represents the state of a node builder after it was
|
|
5
|
+
* used to build the nodes for a render object. The state holds the
|
|
6
|
+
* results of the build for further processing in the renderer.
|
|
7
|
+
*
|
|
8
|
+
* Render objects with identical cache keys share the same node builder state.
|
|
9
|
+
*
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
3
12
|
class NodeBuilderState {
|
|
4
13
|
|
|
5
|
-
|
|
6
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Constructs a new node builder state.
|
|
16
|
+
*
|
|
17
|
+
* @param {String?} vertexShader - The native vertex shader code.
|
|
18
|
+
* @param {String?} fragmentShader - The native fragment shader code.
|
|
19
|
+
* @param {String?} computeShader - The native compute shader code.
|
|
20
|
+
* @param {Array<NodeAttribute>} nodeAttributes - An array of node attributes.
|
|
21
|
+
* @param {Array<BindGroup>} bindings - An array of bind groups.
|
|
22
|
+
* @param {Array<Node>} updateNodes - An array of nodes that implement their `update()` method.
|
|
23
|
+
* @param {Array<Node>} updateBeforeNodes - An array of nodes that implement their `updateBefore()` method.
|
|
24
|
+
* @param {Array<Node>} updateAfterNodes - An array of nodes that implement their `updateAfter()` method.
|
|
25
|
+
* @param {NodeMaterialObserver} observer - A node material observer.
|
|
26
|
+
* @param {Array<Object>} transforms - An array with transform attribute objects. Only relevant when using compute shaders with WebGL 2.
|
|
27
|
+
*/
|
|
28
|
+
constructor( vertexShader, fragmentShader, computeShader, nodeAttributes, bindings, updateNodes, updateBeforeNodes, updateAfterNodes, observer, transforms = [] ) {
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The native vertex shader code.
|
|
32
|
+
*
|
|
33
|
+
* @type {String}
|
|
34
|
+
*/
|
|
7
35
|
this.vertexShader = vertexShader;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The native fragment shader code.
|
|
39
|
+
*
|
|
40
|
+
* @type {String}
|
|
41
|
+
*/
|
|
8
42
|
this.fragmentShader = fragmentShader;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The native compute shader code.
|
|
46
|
+
*
|
|
47
|
+
* @type {String}
|
|
48
|
+
*/
|
|
9
49
|
this.computeShader = computeShader;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* An array with transform attribute objects.
|
|
53
|
+
* Only relevant when using compute shaders with WebGL 2.
|
|
54
|
+
*
|
|
55
|
+
* @type {Array<Object>}
|
|
56
|
+
*/
|
|
10
57
|
this.transforms = transforms;
|
|
11
58
|
|
|
59
|
+
/**
|
|
60
|
+
* An array of node attributes representing
|
|
61
|
+
* the attributes of the shaders.
|
|
62
|
+
*
|
|
63
|
+
* @type {Array<NodeAttribute>}
|
|
64
|
+
*/
|
|
12
65
|
this.nodeAttributes = nodeAttributes;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* An array of bind groups representing the uniform or storage
|
|
69
|
+
* buffers, texture or samplers of the shader.
|
|
70
|
+
*
|
|
71
|
+
* @type {Array<BindGroup>}
|
|
72
|
+
*/
|
|
13
73
|
this.bindings = bindings;
|
|
14
74
|
|
|
75
|
+
/**
|
|
76
|
+
* An array of nodes that implement their `update()` method.
|
|
77
|
+
*
|
|
78
|
+
* @type {Array<Node>}
|
|
79
|
+
*/
|
|
15
80
|
this.updateNodes = updateNodes;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* An array of nodes that implement their `updateBefore()` method.
|
|
84
|
+
*
|
|
85
|
+
* @type {Array<Node>}
|
|
86
|
+
*/
|
|
16
87
|
this.updateBeforeNodes = updateBeforeNodes;
|
|
17
|
-
this.updateAfterNodes = updateAfterNodes;
|
|
18
88
|
|
|
19
|
-
|
|
89
|
+
/**
|
|
90
|
+
* An array of nodes that implement their `updateAfter()` method.
|
|
91
|
+
*
|
|
92
|
+
* @type {Array<Node>}
|
|
93
|
+
*/
|
|
94
|
+
this.updateAfterNodes = updateAfterNodes;
|
|
20
95
|
|
|
96
|
+
/**
|
|
97
|
+
* A node material observer.
|
|
98
|
+
*
|
|
99
|
+
* @type {NodeMaterialObserver}
|
|
100
|
+
*/
|
|
101
|
+
this.observer = observer;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* How often this state is used by render objects.
|
|
105
|
+
*
|
|
106
|
+
* @type {Number}
|
|
107
|
+
*/
|
|
21
108
|
this.usedTimes = 0;
|
|
22
109
|
|
|
23
110
|
}
|
|
24
111
|
|
|
112
|
+
/**
|
|
113
|
+
* This method is used to create a array of bind groups based
|
|
114
|
+
* on the existing bind groups of this state. Shared groups are
|
|
115
|
+
* not cloned.
|
|
116
|
+
*
|
|
117
|
+
* @return {Array<BindGroup>} A array of bind groups.
|
|
118
|
+
*/
|
|
25
119
|
createBindings() {
|
|
26
120
|
|
|
27
121
|
const bindings = [];
|
|
28
122
|
|
|
29
123
|
for ( const instanceGroup of this.bindings ) {
|
|
30
124
|
|
|
31
|
-
const shared = instanceGroup.bindings[ 0 ].groupNode.shared;
|
|
125
|
+
const shared = instanceGroup.bindings[ 0 ].groupNode.shared; // All bindings in the group must have the same groupNode.
|
|
32
126
|
|
|
33
127
|
if ( shared !== true ) {
|
|
34
128
|
|
|
@@ -1,13 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The purpose of a node library is to assign node implementations
|
|
3
|
+
* to existing library features. In `WebGPURenderer` lights, materials
|
|
4
|
+
* which are not based on `NodeMaterial` as well as tone mapping techniques
|
|
5
|
+
* are implemented with node-based modules.
|
|
6
|
+
*
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
1
9
|
class NodeLibrary {
|
|
2
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Constructs a new node library.
|
|
13
|
+
*/
|
|
3
14
|
constructor() {
|
|
4
15
|
|
|
16
|
+
/**
|
|
17
|
+
* A weak map that maps lights to light nodes.
|
|
18
|
+
*
|
|
19
|
+
* @type {WeakMap<Light.constructor,AnalyticLightNode.constructor>}
|
|
20
|
+
*/
|
|
5
21
|
this.lightNodes = new WeakMap();
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A map that maps materials to node materials.
|
|
25
|
+
*
|
|
26
|
+
* @type {Map<String,NodeMaterial.constructor>}
|
|
27
|
+
*/
|
|
6
28
|
this.materialNodes = new Map();
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A map that maps tone mapping techniques (constants)
|
|
32
|
+
* to tone mapping node functions.
|
|
33
|
+
*
|
|
34
|
+
* @type {Map<Number,Function>}
|
|
35
|
+
*/
|
|
7
36
|
this.toneMappingNodes = new Map();
|
|
8
37
|
|
|
9
38
|
}
|
|
10
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Returns a matching node material instance for the given material object.
|
|
42
|
+
*
|
|
43
|
+
* This method also assigns/copies the properties of the given material object
|
|
44
|
+
* to the node material. This is done to make sure the current material
|
|
45
|
+
* configuration carries over to the node version.
|
|
46
|
+
*
|
|
47
|
+
* @param {Material} material - A material.
|
|
48
|
+
* @return {NodeMaterial} The corresponding node material.
|
|
49
|
+
*/
|
|
11
50
|
fromMaterial( material ) {
|
|
12
51
|
|
|
13
52
|
if ( material.isNodeMaterial ) return material;
|
|
@@ -32,42 +71,85 @@ class NodeLibrary {
|
|
|
32
71
|
|
|
33
72
|
}
|
|
34
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Adds a tone mapping node function for a tone mapping technique (constant).
|
|
76
|
+
*
|
|
77
|
+
* @param {Function} toneMappingNode - The tone mapping node function.
|
|
78
|
+
* @param {Number} toneMapping - The tone mapping.
|
|
79
|
+
*/
|
|
35
80
|
addToneMapping( toneMappingNode, toneMapping ) {
|
|
36
81
|
|
|
37
82
|
this.addType( toneMappingNode, toneMapping, this.toneMappingNodes );
|
|
38
83
|
|
|
39
84
|
}
|
|
40
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Returns a tone mapping node function for a tone mapping technique (constant).
|
|
88
|
+
*
|
|
89
|
+
* @param {Number} toneMapping - The tone mapping.
|
|
90
|
+
* @return {Function?} The tone mapping node function. Returns `null` if no node function is found.
|
|
91
|
+
*/
|
|
41
92
|
getToneMappingFunction( toneMapping ) {
|
|
42
93
|
|
|
43
94
|
return this.toneMappingNodes.get( toneMapping ) || null;
|
|
44
95
|
|
|
45
96
|
}
|
|
46
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Returns a node material class definition for a material type.
|
|
100
|
+
*
|
|
101
|
+
* @param {String} materialType - The material type.
|
|
102
|
+
* @return {NodeMaterial.constructor?} The node material class definition. Returns `null` if no node material is found.
|
|
103
|
+
*/
|
|
47
104
|
getMaterialNodeClass( materialType ) {
|
|
48
105
|
|
|
49
106
|
return this.materialNodes.get( materialType ) || null;
|
|
50
107
|
|
|
51
108
|
}
|
|
52
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Adds a node material class definition for a given material type.
|
|
112
|
+
*
|
|
113
|
+
* @param {NodeMaterial.constructor} materialNodeClass - The node material class definition.
|
|
114
|
+
* @param {String} materialClassType - The material type.
|
|
115
|
+
*/
|
|
53
116
|
addMaterial( materialNodeClass, materialClassType ) {
|
|
54
117
|
|
|
55
118
|
this.addType( materialNodeClass, materialClassType, this.materialNodes );
|
|
56
119
|
|
|
57
120
|
}
|
|
58
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Returns a light node class definition for a light class definition.
|
|
124
|
+
*
|
|
125
|
+
* @param {Light.constructor} light - The light class definition.
|
|
126
|
+
* @return {AnalyticLightNode.constructor?} The light node class definition. Returns `null` if no light node is found.
|
|
127
|
+
*/
|
|
59
128
|
getLightNodeClass( light ) {
|
|
60
129
|
|
|
61
130
|
return this.lightNodes.get( light ) || null;
|
|
62
131
|
|
|
63
132
|
}
|
|
64
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Adds a light node class definition for a given light class definition.
|
|
136
|
+
*
|
|
137
|
+
* @param {AnalyticLightNode.constructor} lightNodeClass - The light node class definition.
|
|
138
|
+
* @param {Light.constructor} lightClass - The light class definition.
|
|
139
|
+
*/
|
|
65
140
|
addLight( lightNodeClass, lightClass ) {
|
|
66
141
|
|
|
67
142
|
this.addClass( lightNodeClass, lightClass, this.lightNodes );
|
|
68
143
|
|
|
69
144
|
}
|
|
70
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Adds a node class definition for the given type to the provided type library.
|
|
148
|
+
*
|
|
149
|
+
* @param {Any} nodeClass - The node class definition.
|
|
150
|
+
* @param {Number|String} type - The object type.
|
|
151
|
+
* @param {Map} library - The type library.
|
|
152
|
+
*/
|
|
71
153
|
addType( nodeClass, type, library ) {
|
|
72
154
|
|
|
73
155
|
if ( library.has( type ) ) {
|
|
@@ -84,6 +166,13 @@ class NodeLibrary {
|
|
|
84
166
|
|
|
85
167
|
}
|
|
86
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Adds a node class definition for the given class definition to the provided type library.
|
|
171
|
+
*
|
|
172
|
+
* @param {Any} nodeClass - The node class definition.
|
|
173
|
+
* @param {Any} baseClass - The class definition.
|
|
174
|
+
* @param {WeakMap} library - The type library.
|
|
175
|
+
*/
|
|
87
176
|
addClass( nodeClass, baseClass, library ) {
|
|
88
177
|
|
|
89
178
|
if ( library.has( baseClass ) ) {
|
|
@@ -1,24 +1,68 @@
|
|
|
1
1
|
import { SampledTexture } from '../SampledTexture.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A special form of sampled texture binding type.
|
|
5
|
+
* It's texture value is managed by a node object.
|
|
6
|
+
*
|
|
7
|
+
* @private
|
|
8
|
+
* @augments SampledTexture
|
|
9
|
+
*/
|
|
3
10
|
class NodeSampledTexture extends SampledTexture {
|
|
4
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Constructs a new node-based sampled texture.
|
|
14
|
+
*
|
|
15
|
+
* @param {String} name - The textures's name.
|
|
16
|
+
* @param {TextureNode} textureNode - The texture node.
|
|
17
|
+
* @param {UniformGroupNode} groupNode - The uniform group node.
|
|
18
|
+
* @param {String?} [access=null] - The access type.
|
|
19
|
+
*/
|
|
5
20
|
constructor( name, textureNode, groupNode, access = null ) {
|
|
6
21
|
|
|
7
22
|
super( name, textureNode ? textureNode.value : null );
|
|
8
23
|
|
|
24
|
+
/**
|
|
25
|
+
* The texture node.
|
|
26
|
+
*
|
|
27
|
+
* @type {TextureNode}
|
|
28
|
+
*/
|
|
9
29
|
this.textureNode = textureNode;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The uniform group node.
|
|
33
|
+
*
|
|
34
|
+
* @type {UniformGroupNode}
|
|
35
|
+
*/
|
|
10
36
|
this.groupNode = groupNode;
|
|
11
37
|
|
|
38
|
+
/**
|
|
39
|
+
* The access type.
|
|
40
|
+
*
|
|
41
|
+
* @type {String?}
|
|
42
|
+
* @default null
|
|
43
|
+
*/
|
|
12
44
|
this.access = access;
|
|
13
45
|
|
|
14
46
|
}
|
|
15
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Overwrites the default to additionally check if the node value has changed.
|
|
50
|
+
*
|
|
51
|
+
* @param {Number} generation - The generation.
|
|
52
|
+
* @return {Boolean} Whether an update is required or not.
|
|
53
|
+
*/
|
|
16
54
|
needsBindingsUpdate( generation ) {
|
|
17
55
|
|
|
18
56
|
return this.textureNode.value !== this.texture || super.needsBindingsUpdate( generation );
|
|
19
57
|
|
|
20
58
|
}
|
|
21
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Updates the binding.
|
|
62
|
+
*
|
|
63
|
+
* @return {Boolean} Whether the texture has been updated and must be
|
|
64
|
+
* uploaded to the GPU.
|
|
65
|
+
*/
|
|
22
66
|
update() {
|
|
23
67
|
|
|
24
68
|
const { textureNode } = this;
|
|
@@ -37,24 +81,68 @@ class NodeSampledTexture extends SampledTexture {
|
|
|
37
81
|
|
|
38
82
|
}
|
|
39
83
|
|
|
84
|
+
/**
|
|
85
|
+
* A special form of sampled cube texture binding type.
|
|
86
|
+
* It's texture value is managed by a node object.
|
|
87
|
+
*
|
|
88
|
+
* @private
|
|
89
|
+
* @augments NodeSampledTexture
|
|
90
|
+
*/
|
|
40
91
|
class NodeSampledCubeTexture extends NodeSampledTexture {
|
|
41
92
|
|
|
42
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Constructs a new node-based sampled cube texture.
|
|
95
|
+
*
|
|
96
|
+
* @param {String} name - The textures's name.
|
|
97
|
+
* @param {TextureNode} textureNode - The texture node.
|
|
98
|
+
* @param {UniformGroupNode} groupNode - The uniform group node.
|
|
99
|
+
* @param {String?} [access=null] - The access type.
|
|
100
|
+
*/
|
|
101
|
+
constructor( name, textureNode, groupNode, access = null ) {
|
|
43
102
|
|
|
44
103
|
super( name, textureNode, groupNode, access );
|
|
45
104
|
|
|
105
|
+
/**
|
|
106
|
+
* This flag can be used for type testing.
|
|
107
|
+
*
|
|
108
|
+
* @type {Boolean}
|
|
109
|
+
* @readonly
|
|
110
|
+
* @default true
|
|
111
|
+
*/
|
|
46
112
|
this.isSampledCubeTexture = true;
|
|
47
113
|
|
|
48
114
|
}
|
|
49
115
|
|
|
50
116
|
}
|
|
51
117
|
|
|
118
|
+
/**
|
|
119
|
+
* A special form of sampled 3D texture binding type.
|
|
120
|
+
* It's texture value is managed by a node object.
|
|
121
|
+
*
|
|
122
|
+
* @private
|
|
123
|
+
* @augments NodeSampledTexture
|
|
124
|
+
*/
|
|
52
125
|
class NodeSampledTexture3D extends NodeSampledTexture {
|
|
53
126
|
|
|
54
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Constructs a new node-based sampled 3D texture.
|
|
129
|
+
*
|
|
130
|
+
* @param {String} name - The textures's name.
|
|
131
|
+
* @param {TextureNode} textureNode - The texture node.
|
|
132
|
+
* @param {UniformGroupNode} groupNode - The uniform group node.
|
|
133
|
+
* @param {String?} [access=null] - The access type.
|
|
134
|
+
*/
|
|
135
|
+
constructor( name, textureNode, groupNode, access = null ) {
|
|
55
136
|
|
|
56
137
|
super( name, textureNode, groupNode, access );
|
|
57
138
|
|
|
139
|
+
/**
|
|
140
|
+
* This flag can be used for type testing.
|
|
141
|
+
*
|
|
142
|
+
* @type {Boolean}
|
|
143
|
+
* @readonly
|
|
144
|
+
* @default true
|
|
145
|
+
*/
|
|
58
146
|
this.isSampledTexture3D = true;
|
|
59
147
|
|
|
60
148
|
}
|