super-three 0.167.0 → 0.169.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/build/three.cjs +532 -173
- package/build/three.module.js +532 -174
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +18173 -14266
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +79941 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +0 -4
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +469 -448
- package/examples/jsm/controls/TransformControls.js +97 -62
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +43 -44
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +3 -1
- package/examples/jsm/loaders/FBXLoader.js +30 -20
- package/examples/jsm/loaders/GLTFLoader.js +5 -10
- package/examples/jsm/loaders/KTX2Loader.js +27 -12
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +40 -14
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +14 -13
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/VRMLLoader.js +10 -10
- package/examples/jsm/loaders/VTKLoader.js +4 -3
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +187 -0
- package/examples/jsm/objects/Water2Mesh.js +158 -0
- package/examples/jsm/objects/WaterMesh.js +101 -0
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/physics/RapierPhysics.js +21 -1
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/TextureUtils.js +2 -1
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/package.json +3 -2
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +7 -0
- package/src/Three.js +1 -0
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/extras/Controls.js +32 -0
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/loaders/MaterialLoader.js +7 -1
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +25 -5
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +21 -18
- package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +19 -0
- package/src/materials/Material.js +4 -7
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +56 -59
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +12 -10
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +16 -12
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +10 -6
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshNormalNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +14 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +22 -18
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +10 -7
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +22 -12
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +71 -115
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +3 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +47 -14
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +24 -22
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Triangle.js +24 -0
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +179 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +53 -21
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +8 -5
- package/src/nodes/accessors/BufferNode.js +7 -4
- package/src/nodes/accessors/Camera.js +13 -0
- package/src/nodes/accessors/ClippingNode.js +19 -13
- package/src/nodes/accessors/CubeTextureNode.js +9 -8
- package/src/nodes/accessors/InstanceNode.js +19 -15
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +8 -5
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +56 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +9 -4
- package/src/nodes/accessors/ModelNode.js +47 -12
- package/src/nodes/accessors/ModelViewProjectionNode.js +12 -9
- package/src/nodes/accessors/MorphNode.js +17 -13
- package/src/nodes/accessors/Normal.js +88 -0
- package/src/nodes/accessors/Object3DNode.js +17 -33
- package/src/nodes/accessors/PointUVNode.js +9 -5
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
- package/src/nodes/accessors/ReferenceNode.js +50 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +12 -6
- package/src/nodes/accessors/SceneNode.js +9 -6
- package/src/nodes/accessors/SkinningNode.js +88 -21
- package/src/nodes/accessors/StorageBufferNode.js +22 -5
- package/src/nodes/accessors/StorageTextureNode.js +9 -6
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +16 -13
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +29 -23
- package/src/nodes/accessors/TextureSizeNode.js +10 -9
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +26 -14
- package/src/nodes/accessors/UserDataNode.js +10 -7
- package/src/nodes/accessors/VelocityNode.js +134 -0
- package/src/nodes/accessors/VertexColorNode.js +7 -4
- package/src/nodes/code/CodeNode.js +9 -5
- package/src/nodes/code/ExpressionNode.js +10 -6
- package/src/nodes/code/FunctionCallNode.js +8 -5
- package/src/nodes/code/FunctionNode.js +8 -23
- package/src/nodes/code/ScriptableNode.js +13 -10
- package/src/nodes/code/ScriptableValueNode.js +9 -7
- package/src/nodes/core/AssignNode.js +12 -9
- package/src/nodes/core/AttributeNode.js +12 -21
- package/src/nodes/core/BypassNode.js +11 -7
- package/src/nodes/core/CacheNode.js +10 -6
- package/src/nodes/core/ConstNode.js +6 -3
- package/src/nodes/core/ContextNode.js +21 -11
- package/src/nodes/core/IndexNode.js +35 -8
- package/src/nodes/core/InputNode.js +7 -3
- package/src/nodes/core/MRTNode.js +16 -7
- package/src/nodes/core/Node.js +19 -40
- package/src/nodes/core/NodeBuilder.js +117 -38
- package/src/nodes/core/NodeUtils.js +49 -6
- package/src/nodes/core/OutputStructNode.js +10 -6
- package/src/nodes/core/ParameterNode.js +7 -4
- package/src/nodes/core/PropertyNode.js +36 -32
- package/src/nodes/core/StackNode.js +31 -11
- package/src/nodes/core/StructTypeNode.js +7 -3
- package/src/nodes/core/TempNode.js +8 -4
- package/src/nodes/core/UniformGroupNode.js +14 -11
- package/src/nodes/core/UniformNode.js +7 -4
- package/src/nodes/core/VarNode.js +12 -8
- package/src/nodes/core/VaryingNode.js +10 -6
- package/src/nodes/display/AfterImageNode.js +15 -9
- package/src/nodes/display/AnaglyphPassNode.js +67 -0
- package/src/nodes/display/AnamorphicNode.js +17 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +27 -19
- package/src/nodes/display/BumpMapNode.js +13 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +67 -61
- package/src/nodes/display/DenoiseNode.js +23 -17
- package/src/nodes/display/DepthOfFieldNode.js +12 -7
- package/src/nodes/display/DotScreenNode.js +13 -22
- package/src/nodes/display/FXAANode.js +21 -16
- package/src/nodes/display/FilmNode.js +11 -7
- package/src/nodes/display/FrontFacingNode.js +10 -6
- package/src/nodes/display/GTAONode.js +22 -15
- package/src/nodes/display/GaussianBlurNode.js +14 -8
- package/src/nodes/display/Lut3DNode.js +10 -6
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +13 -13
- package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
- package/src/nodes/display/PassNode.js +95 -8
- package/src/nodes/display/PixelationPassNode.js +20 -8
- package/src/nodes/display/PosterizeNode.js +8 -7
- package/src/nodes/display/RGBShiftNode.js +11 -7
- package/src/nodes/display/RenderOutputNode.js +15 -11
- package/src/nodes/display/SSAAPassNode.js +287 -0
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +13 -8
- package/src/nodes/display/StereoCompositePassNode.js +110 -0
- package/src/nodes/display/StereoPassNode.js +83 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +15 -175
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +12 -8
- package/src/nodes/display/ViewportDepthNode.js +34 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +10 -9
- package/src/nodes/display/ViewportSharedTextureNode.js +10 -9
- package/src/nodes/display/ViewportTextureNode.js +11 -11
- package/src/nodes/fog/FogExp2Node.js +8 -7
- package/src/nodes/fog/FogNode.js +10 -8
- package/src/nodes/fog/FogRangeNode.js +8 -7
- package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +6 -6
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +5 -5
- package/src/nodes/functions/PhysicalLightingModel.js +34 -33
- package/src/nodes/functions/ShadowMaskModel.js +1 -1
- package/src/nodes/functions/ToonLightingModel.js +3 -3
- package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
- package/src/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.js +9 -5
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/src/nodes/gpgpu/ComputeNode.js +10 -6
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +6 -3
- package/src/nodes/lighting/AmbientLightNode.js +6 -8
- package/src/nodes/lighting/AnalyticLightNode.js +225 -36
- package/src/nodes/lighting/BasicEnvironmentNode.js +8 -4
- package/src/nodes/lighting/BasicLightMapNode.js +7 -4
- package/src/nodes/lighting/DirectionalLightNode.js +7 -9
- package/src/nodes/lighting/EnvironmentNode.js +23 -19
- package/src/nodes/lighting/HemisphereLightNode.js +11 -11
- package/src/nodes/lighting/IESSpotLightNode.js +7 -9
- package/src/nodes/lighting/IrradianceNode.js +6 -3
- package/src/nodes/lighting/LightProbeNode.js +53 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +19 -18
- package/src/nodes/lighting/LightingNode.js +7 -3
- package/src/nodes/lighting/LightsNode.js +112 -75
- package/src/nodes/lighting/PointLightNode.js +12 -13
- package/src/nodes/lighting/RectAreaLightNode.js +11 -11
- package/src/nodes/lighting/SpotLightNode.js +14 -16
- package/src/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +36 -31
- package/src/nodes/materialx/lib/mx_noise.js +96 -96
- package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
- package/src/nodes/math/{CondNode.js → ConditionalNode.js} +38 -10
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +127 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +97 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +61 -15
- package/src/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
- package/src/nodes/utils/ArrayElementNode.js +8 -4
- package/src/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +160 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +9 -6
- package/src/nodes/utils/FlipNode.js +68 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +9 -5
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +16 -6
- package/src/nodes/utils/MatcapUVNode.js +10 -7
- package/src/nodes/utils/MaxMipLevelNode.js +8 -5
- package/src/nodes/utils/OscNode.js +12 -8
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +11 -8
- package/src/nodes/utils/ReflectorNode.js +12 -4
- package/src/nodes/utils/RemapNode.js +12 -8
- package/src/nodes/utils/RotateNode.js +8 -13
- package/src/nodes/utils/SetNode.js +7 -4
- package/src/nodes/utils/SplitNode.js +7 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +10 -6
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +11 -12
- package/src/nodes/utils/TimerNode.js +8 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +11 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +78 -13
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +1 -0
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +88 -41
- package/src/renderers/common/Backend.js +2 -2
- package/src/renderers/common/Background.js +3 -1
- package/src/renderers/common/BindGroup.js +3 -1
- package/src/renderers/common/Bindings.js +13 -15
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ClippingContext.js +15 -5
- package/src/renderers/common/CubeRenderTarget.js +9 -3
- package/src/renderers/common/PostProcessing.js +4 -1
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderContext.js +23 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +117 -6
- package/src/renderers/common/RenderObjects.js +8 -1
- package/src/renderers/common/Renderer.js +128 -94
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +19 -22
- package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/src/renderers/common/nodes/Nodes.js +65 -19
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/webgl/WebGLAttributes.js +45 -14
- package/src/renderers/webgl/WebGLCapabilities.js +9 -0
- package/src/renderers/webgl/WebGLProgram.js +3 -1
- package/src/renderers/webgl/WebGLPrograms.js +21 -17
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLState.js +21 -0
- package/src/renderers/webgl/WebGLTextures.js +83 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +135 -110
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +60 -12
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +20 -2
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +89 -37
- package/src/renderers/webgpu/WebGPUBackend.js +112 -86
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/src/renderers/webgpu/WebGPURenderer.js +9 -6
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +189 -73
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +7 -16
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +43 -26
- package/src/renderers/webgpu/utils/WebGPUUtils.js +19 -2
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/src/utils.js +33 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/utils/GPUStatsPanel.js +0 -95
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/nodes/accessors/CameraNode.js +0 -19
- package/src/nodes/accessors/NormalNode.js +0 -14
- package/src/nodes/accessors/PositionNode.js +0 -10
- package/src/nodes/accessors/ReflectVectorNode.js +0 -10
- package/src/nodes/accessors/TangentNode.js +0 -23
- package/src/nodes/core/NodeKeywords.js +0 -80
- package/src/nodes/display/BlendModeNode.js +0 -128
- package/src/nodes/display/ColorAdjustmentNode.js +0 -104
- package/src/nodes/display/ViewportNode.js +0 -137
- package/src/nodes/lighting/LightNode.js +0 -57
- package/src/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
- package/src/nodes/math/HashNode.js +0 -34
- package/src/nodes/procedural/CheckerNode.js +0 -42
- package/src/nodes/utils/DiscardNode.js +0 -28
- package/src/nodes/utils/PackingNode.js +0 -55
- package/src/nodes/utils/RotateUVNode.js +0 -35
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -145,6 +145,9 @@ class BatchedMesh extends Mesh {
|
|
|
145
145
|
// stores visible, active, and geometry id per object
|
|
146
146
|
this._drawInfo = [];
|
|
147
147
|
|
|
148
|
+
// instance ids that have been set as inactive, and are available to be overwritten
|
|
149
|
+
this._availableInstanceIds = [];
|
|
150
|
+
|
|
148
151
|
// geometry information
|
|
149
152
|
this._drawRanges = [];
|
|
150
153
|
this._reservedRanges = [];
|
|
@@ -206,7 +209,7 @@ class BatchedMesh extends Mesh {
|
|
|
206
209
|
|
|
207
210
|
_initColorsTexture() {
|
|
208
211
|
|
|
209
|
-
let size = Math.sqrt( this.
|
|
212
|
+
let size = Math.sqrt( this._maxInstanceCount );
|
|
210
213
|
size = Math.ceil( size );
|
|
211
214
|
|
|
212
215
|
// 4 floats per RGBA pixel initialized to white
|
|
@@ -300,12 +303,11 @@ class BatchedMesh extends Mesh {
|
|
|
300
303
|
|
|
301
304
|
}
|
|
302
305
|
|
|
303
|
-
const geometryCount = this._geometryCount;
|
|
304
306
|
const boundingBox = this.boundingBox;
|
|
305
307
|
const drawInfo = this._drawInfo;
|
|
306
308
|
|
|
307
309
|
boundingBox.makeEmpty();
|
|
308
|
-
for ( let i = 0; i <
|
|
310
|
+
for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
|
|
309
311
|
|
|
310
312
|
if ( drawInfo[ i ].active === false ) continue;
|
|
311
313
|
|
|
@@ -345,23 +347,36 @@ class BatchedMesh extends Mesh {
|
|
|
345
347
|
|
|
346
348
|
addInstance( geometryId ) {
|
|
347
349
|
|
|
350
|
+
const atCapacity = this._drawInfo.length >= this.maxInstanceCount;
|
|
351
|
+
|
|
348
352
|
// ensure we're not over geometry
|
|
349
|
-
if ( this.
|
|
353
|
+
if ( atCapacity && this._availableInstanceIds.length === 0 ) {
|
|
350
354
|
|
|
351
355
|
throw new Error( 'BatchedMesh: Maximum item count reached.' );
|
|
352
356
|
|
|
353
357
|
}
|
|
354
358
|
|
|
355
|
-
|
|
356
|
-
|
|
359
|
+
const instanceDrawInfo = {
|
|
357
360
|
visible: true,
|
|
358
361
|
active: true,
|
|
359
362
|
geometryIndex: geometryId,
|
|
363
|
+
};
|
|
360
364
|
|
|
361
|
-
|
|
365
|
+
let drawId = null;
|
|
366
|
+
|
|
367
|
+
// Prioritize using previously freed instance ids
|
|
368
|
+
if ( this._availableInstanceIds.length > 0 ) {
|
|
369
|
+
|
|
370
|
+
drawId = this._availableInstanceIds.pop();
|
|
371
|
+
this._drawInfo[ drawId ] = instanceDrawInfo;
|
|
372
|
+
|
|
373
|
+
} else {
|
|
374
|
+
|
|
375
|
+
drawId = this._drawInfo.length;
|
|
376
|
+
this._drawInfo.push( instanceDrawInfo );
|
|
377
|
+
|
|
378
|
+
}
|
|
362
379
|
|
|
363
|
-
// initialize the matrix
|
|
364
|
-
const drawId = this._drawInfo.length - 1;
|
|
365
380
|
const matricesTexture = this._matricesTexture;
|
|
366
381
|
const matricesArray = matricesTexture.image.data;
|
|
367
382
|
_identityMatrix.toArray( matricesArray, drawId * 16 );
|
|
@@ -610,11 +625,8 @@ class BatchedMesh extends Mesh {
|
|
|
610
625
|
}
|
|
611
626
|
*/
|
|
612
627
|
|
|
613
|
-
/*
|
|
614
628
|
deleteInstance( instanceId ) {
|
|
615
629
|
|
|
616
|
-
// Note: User needs to call optimize() afterward to pack the data.
|
|
617
|
-
|
|
618
630
|
const drawInfo = this._drawInfo;
|
|
619
631
|
if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
|
|
620
632
|
|
|
@@ -623,12 +635,12 @@ class BatchedMesh extends Mesh {
|
|
|
623
635
|
}
|
|
624
636
|
|
|
625
637
|
drawInfo[ instanceId ].active = false;
|
|
638
|
+
this._availableInstanceIds.push( instanceId );
|
|
626
639
|
this._visibilityChanged = true;
|
|
627
640
|
|
|
628
641
|
return this;
|
|
629
642
|
|
|
630
643
|
}
|
|
631
|
-
*/
|
|
632
644
|
|
|
633
645
|
// get bounding box and compute it if it doesn't exist
|
|
634
646
|
getBoundingBoxAt( geometryId, target ) {
|
|
@@ -833,6 +845,59 @@ class BatchedMesh extends Mesh {
|
|
|
833
845
|
|
|
834
846
|
}
|
|
835
847
|
|
|
848
|
+
setGeometryIdAt( instanceId, geometryId ) {
|
|
849
|
+
|
|
850
|
+
// return early if the geometry is out of range or not active
|
|
851
|
+
const drawInfo = this._drawInfo;
|
|
852
|
+
if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
|
|
853
|
+
|
|
854
|
+
return null;
|
|
855
|
+
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
// check if the provided geometryId is within the valid range
|
|
859
|
+
if ( geometryId < 0 || geometryId >= this._geometryCount ) {
|
|
860
|
+
|
|
861
|
+
return null;
|
|
862
|
+
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
drawInfo[ instanceId ].geometryIndex = geometryId;
|
|
866
|
+
|
|
867
|
+
return this;
|
|
868
|
+
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
getGeometryIdAt( instanceId ) {
|
|
872
|
+
|
|
873
|
+
const drawInfo = this._drawInfo;
|
|
874
|
+
if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
|
|
875
|
+
|
|
876
|
+
return - 1;
|
|
877
|
+
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
return drawInfo[ instanceId ].geometryIndex;
|
|
881
|
+
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
getGeometryRangeAt( geometryId, target = {} ) {
|
|
885
|
+
|
|
886
|
+
if ( geometryId < 0 || geometryId >= this._geometryCount ) {
|
|
887
|
+
|
|
888
|
+
return null;
|
|
889
|
+
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
const drawRange = this._drawRanges[ geometryId ];
|
|
893
|
+
|
|
894
|
+
target.start = drawRange.start;
|
|
895
|
+
target.count = drawRange.count;
|
|
896
|
+
|
|
897
|
+
return target;
|
|
898
|
+
|
|
899
|
+
}
|
|
900
|
+
|
|
836
901
|
raycast( raycaster, intersects ) {
|
|
837
902
|
|
|
838
903
|
const drawInfo = this._drawInfo;
|
package/src/objects/LOD.js
CHANGED
|
@@ -74,6 +74,27 @@ class LOD extends Object3D {
|
|
|
74
74
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
removeLevel( distance ) {
|
|
78
|
+
|
|
79
|
+
const levels = this.levels;
|
|
80
|
+
|
|
81
|
+
for ( let i = 0; i < levels.length; i ++ ) {
|
|
82
|
+
|
|
83
|
+
if ( levels[ i ].distance === distance ) {
|
|
84
|
+
|
|
85
|
+
const removedElements = levels.splice( i, 1 );
|
|
86
|
+
this.remove( removedElements[ 0 ].object );
|
|
87
|
+
|
|
88
|
+
return true;
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return false;
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
77
98
|
getCurrentLevel() {
|
|
78
99
|
|
|
79
100
|
return this._currentLevel;
|
package/src/objects/Line.js
CHANGED
package/src/objects/Mesh.js
CHANGED
|
@@ -21,14 +21,6 @@ const _vC = /*@__PURE__*/ new Vector3();
|
|
|
21
21
|
const _tempA = /*@__PURE__*/ new Vector3();
|
|
22
22
|
const _morphA = /*@__PURE__*/ new Vector3();
|
|
23
23
|
|
|
24
|
-
const _uvA = /*@__PURE__*/ new Vector2();
|
|
25
|
-
const _uvB = /*@__PURE__*/ new Vector2();
|
|
26
|
-
const _uvC = /*@__PURE__*/ new Vector2();
|
|
27
|
-
|
|
28
|
-
const _normalA = /*@__PURE__*/ new Vector3();
|
|
29
|
-
const _normalB = /*@__PURE__*/ new Vector3();
|
|
30
|
-
const _normalC = /*@__PURE__*/ new Vector3();
|
|
31
|
-
|
|
32
24
|
const _intersectionPoint = /*@__PURE__*/ new Vector3();
|
|
33
25
|
const _intersectionPointWorld = /*@__PURE__*/ new Vector3();
|
|
34
26
|
|
|
@@ -371,33 +363,24 @@ function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, n
|
|
|
371
363
|
|
|
372
364
|
if ( intersection ) {
|
|
373
365
|
|
|
374
|
-
|
|
366
|
+
const barycoord = new Vector3();
|
|
367
|
+
Triangle.getBarycoord( _intersectionPoint, _vA, _vB, _vC, barycoord );
|
|
375
368
|
|
|
376
|
-
|
|
377
|
-
_uvB.fromBufferAttribute( uv, b );
|
|
378
|
-
_uvC.fromBufferAttribute( uv, c );
|
|
369
|
+
if ( uv ) {
|
|
379
370
|
|
|
380
|
-
intersection.uv = Triangle.
|
|
371
|
+
intersection.uv = Triangle.getInterpolatedAttribute( uv, a, b, c, barycoord, new Vector2() );
|
|
381
372
|
|
|
382
373
|
}
|
|
383
374
|
|
|
384
375
|
if ( uv1 ) {
|
|
385
376
|
|
|
386
|
-
|
|
387
|
-
_uvB.fromBufferAttribute( uv1, b );
|
|
388
|
-
_uvC.fromBufferAttribute( uv1, c );
|
|
389
|
-
|
|
390
|
-
intersection.uv1 = Triangle.getInterpolation( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );
|
|
377
|
+
intersection.uv1 = Triangle.getInterpolatedAttribute( uv1, a, b, c, barycoord, new Vector2() );
|
|
391
378
|
|
|
392
379
|
}
|
|
393
380
|
|
|
394
381
|
if ( normal ) {
|
|
395
382
|
|
|
396
|
-
|
|
397
|
-
_normalB.fromBufferAttribute( normal, b );
|
|
398
|
-
_normalC.fromBufferAttribute( normal, c );
|
|
399
|
-
|
|
400
|
-
intersection.normal = Triangle.getInterpolation( _intersectionPoint, _vA, _vB, _vC, _normalA, _normalB, _normalC, new Vector3() );
|
|
383
|
+
intersection.normal = Triangle.getInterpolatedAttribute( normal, a, b, c, barycoord, new Vector3() );
|
|
401
384
|
|
|
402
385
|
if ( intersection.normal.dot( ray.direction ) > 0 ) {
|
|
403
386
|
|
|
@@ -418,6 +401,7 @@ function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, n
|
|
|
418
401
|
Triangle.getNormal( _vA, _vB, _vC, face.normal );
|
|
419
402
|
|
|
420
403
|
intersection.face = face;
|
|
404
|
+
intersection.barycoord = barycoord;
|
|
421
405
|
|
|
422
406
|
}
|
|
423
407
|
|
package/src/objects/Points.js
CHANGED
|
@@ -56,7 +56,7 @@ import { WebVRManager } from './webvr/WebVRManager.js';
|
|
|
56
56
|
import { WebXRManager } from './webxr/WebXRManager.js';
|
|
57
57
|
import { WebGLMaterials } from './webgl/WebGLMaterials.js';
|
|
58
58
|
import { WebGLUniformsGroups } from './webgl/WebGLUniformsGroups.js';
|
|
59
|
-
import { createCanvasElement, probeAsync, warnOnce } from '../utils.js';
|
|
59
|
+
import { createCanvasElement, probeAsync, toNormalizedProjectionMatrix, toReversedProjectionMatrix, warnOnce } from '../utils.js';
|
|
60
60
|
import { ColorManagement } from '../math/ColorManagement.js';
|
|
61
61
|
|
|
62
62
|
class WebGLRenderer {
|
|
@@ -199,6 +199,7 @@ class WebGLRenderer {
|
|
|
199
199
|
|
|
200
200
|
// camera matrices cache
|
|
201
201
|
|
|
202
|
+
const _currentProjectionMatrix = new Matrix4();
|
|
202
203
|
const _projScreenMatrix = new Matrix4();
|
|
203
204
|
|
|
204
205
|
const _vector3 = new Vector3();
|
|
@@ -295,6 +296,8 @@ class WebGLRenderer {
|
|
|
295
296
|
|
|
296
297
|
state = new WebGLState( _gl );
|
|
297
298
|
|
|
299
|
+
if ( capabilities.reverseDepthBuffer ) state.buffers.depth.setReversed( true );
|
|
300
|
+
|
|
298
301
|
info = new WebGLInfo( _gl );
|
|
299
302
|
properties = new WebGLProperties();
|
|
300
303
|
textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
|
|
@@ -595,7 +598,13 @@ class WebGLRenderer {
|
|
|
595
598
|
|
|
596
599
|
}
|
|
597
600
|
|
|
598
|
-
if ( depth )
|
|
601
|
+
if ( depth ) {
|
|
602
|
+
|
|
603
|
+
bits |= _gl.DEPTH_BUFFER_BIT;
|
|
604
|
+
_gl.clearDepth( this.capabilities.reverseDepthBuffer ? 0 : 1 );
|
|
605
|
+
|
|
606
|
+
}
|
|
607
|
+
|
|
599
608
|
if ( stencil ) {
|
|
600
609
|
|
|
601
610
|
bits |= _gl.STENCIL_BUFFER_BIT;
|
|
@@ -984,6 +993,12 @@ class WebGLRenderer {
|
|
|
984
993
|
|
|
985
994
|
scene.traverse( function ( object ) {
|
|
986
995
|
|
|
996
|
+
if ( ! ( object.isMesh || object.isPoints || object.isLine || object.isSprite ) ) {
|
|
997
|
+
|
|
998
|
+
return;
|
|
999
|
+
|
|
1000
|
+
}
|
|
1001
|
+
|
|
987
1002
|
const material = object.material;
|
|
988
1003
|
|
|
989
1004
|
if ( material ) {
|
|
@@ -1615,6 +1630,8 @@ class WebGLRenderer {
|
|
|
1615
1630
|
object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
|
|
1616
1631
|
object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
|
|
1617
1632
|
|
|
1633
|
+
material.onBeforeRender( _this, scene, camera, geometry, object, group );
|
|
1634
|
+
|
|
1618
1635
|
if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {
|
|
1619
1636
|
|
|
1620
1637
|
material.side = BackSide;
|
|
@@ -1999,7 +2016,21 @@ class WebGLRenderer {
|
|
|
1999
2016
|
|
|
2000
2017
|
} else {
|
|
2001
2018
|
|
|
2002
|
-
|
|
2019
|
+
if ( capabilities.reverseDepthBuffer ) {
|
|
2020
|
+
|
|
2021
|
+
_currentProjectionMatrix.copy( camera.projectionMatrix );
|
|
2022
|
+
|
|
2023
|
+
toNormalizedProjectionMatrix( _currentProjectionMatrix );
|
|
2024
|
+
toReversedProjectionMatrix( _currentProjectionMatrix );
|
|
2025
|
+
|
|
2026
|
+
p_uniforms.setValue( _gl, 'projectionMatrix', _currentProjectionMatrix );
|
|
2027
|
+
|
|
2028
|
+
} else {
|
|
2029
|
+
|
|
2030
|
+
p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
|
|
2031
|
+
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2003
2034
|
p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
|
|
2004
2035
|
|
|
2005
2036
|
}
|
|
@@ -2331,6 +2362,28 @@ class WebGLRenderer {
|
|
|
2331
2362
|
// Color and depth texture must be rebound in order for the swapchain to update.
|
|
2332
2363
|
textures.rebindTextures( renderTarget, properties.get( renderTarget.texture ).__webglTexture, properties.get( renderTarget.depthTexture ).__webglTexture );
|
|
2333
2364
|
|
|
2365
|
+
} else if ( renderTarget.depthBuffer ) {
|
|
2366
|
+
|
|
2367
|
+
// check if the depth texture is already bound to the frame buffer and that it's been initialized
|
|
2368
|
+
const depthTexture = renderTarget.depthTexture;
|
|
2369
|
+
if ( renderTargetProperties.__boundDepthTexture !== depthTexture ) {
|
|
2370
|
+
|
|
2371
|
+
// check if the depth texture is compatible
|
|
2372
|
+
if (
|
|
2373
|
+
depthTexture !== null &&
|
|
2374
|
+
properties.has( depthTexture ) &&
|
|
2375
|
+
( renderTarget.width !== depthTexture.image.width || renderTarget.height !== depthTexture.image.height )
|
|
2376
|
+
) {
|
|
2377
|
+
|
|
2378
|
+
throw new Error( 'WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.' );
|
|
2379
|
+
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
// Swap the depth buffer to the currently attached one
|
|
2383
|
+
textures.setupDepthRenderbuffer( renderTarget );
|
|
2384
|
+
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2334
2387
|
}
|
|
2335
2388
|
|
|
2336
2389
|
const texture = renderTarget.texture;
|
|
@@ -2495,61 +2548,55 @@ class WebGLRenderer {
|
|
|
2495
2548
|
|
|
2496
2549
|
if ( framebuffer ) {
|
|
2497
2550
|
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
const texture = renderTarget.texture;
|
|
2503
|
-
const textureFormat = texture.format;
|
|
2504
|
-
const textureType = texture.type;
|
|
2505
|
-
|
|
2506
|
-
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
2507
|
-
|
|
2508
|
-
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
|
|
2551
|
+
const texture = renderTarget.texture;
|
|
2552
|
+
const textureFormat = texture.format;
|
|
2553
|
+
const textureType = texture.type;
|
|
2509
2554
|
|
|
2510
|
-
|
|
2555
|
+
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
2511
2556
|
|
|
2512
|
-
|
|
2557
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
|
|
2513
2558
|
|
|
2514
|
-
|
|
2559
|
+
}
|
|
2515
2560
|
|
|
2516
|
-
|
|
2561
|
+
if ( ! capabilities.textureTypeReadable( textureType ) ) {
|
|
2517
2562
|
|
|
2518
|
-
|
|
2519
|
-
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
2563
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
2520
2564
|
|
|
2521
|
-
|
|
2522
|
-
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
2523
|
-
_gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
|
|
2524
|
-
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
|
|
2525
|
-
_gl.flush();
|
|
2565
|
+
}
|
|
2526
2566
|
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
await probeAsync( _gl, sync, 4 );
|
|
2567
|
+
// the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
|
|
2568
|
+
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
2530
2569
|
|
|
2531
|
-
|
|
2570
|
+
// set the active frame buffer to the one we want to read
|
|
2571
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
2532
2572
|
|
|
2533
|
-
|
|
2534
|
-
|
|
2573
|
+
const glBuffer = _gl.createBuffer();
|
|
2574
|
+
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
2575
|
+
_gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
|
|
2576
|
+
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
|
|
2535
2577
|
|
|
2536
|
-
|
|
2578
|
+
// reset the frame buffer to the currently set buffer before waiting
|
|
2579
|
+
const currFramebuffer = _currentRenderTarget !== null ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
|
|
2580
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, currFramebuffer );
|
|
2537
2581
|
|
|
2538
|
-
|
|
2539
|
-
|
|
2582
|
+
// check if the commands have finished every 8 ms
|
|
2583
|
+
const sync = _gl.fenceSync( _gl.SYNC_GPU_COMMANDS_COMPLETE, 0 );
|
|
2540
2584
|
|
|
2541
|
-
|
|
2585
|
+
_gl.flush();
|
|
2542
2586
|
|
|
2543
|
-
|
|
2587
|
+
await probeAsync( _gl, sync, 4 );
|
|
2544
2588
|
|
|
2545
|
-
|
|
2589
|
+
// read the data and delete the buffer
|
|
2590
|
+
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
2591
|
+
_gl.getBufferSubData( _gl.PIXEL_PACK_BUFFER, 0, buffer );
|
|
2592
|
+
_gl.deleteBuffer( glBuffer );
|
|
2593
|
+
_gl.deleteSync( sync );
|
|
2546
2594
|
|
|
2547
|
-
|
|
2595
|
+
return buffer;
|
|
2548
2596
|
|
|
2549
|
-
|
|
2597
|
+
} else {
|
|
2550
2598
|
|
|
2551
|
-
|
|
2552
|
-
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
2599
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.' );
|
|
2553
2600
|
|
|
2554
2601
|
}
|
|
2555
2602
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import DataMap from './DataMap.js';
|
|
2
2
|
import Color4 from './Color4.js';
|
|
3
|
-
import { vec4, context, normalWorld, backgroundBlurriness, backgroundIntensity,
|
|
3
|
+
import { vec4, context, normalWorld, backgroundBlurriness, backgroundIntensity, modelViewProjection } from '../../nodes/TSL.js';
|
|
4
|
+
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
4
5
|
|
|
5
6
|
import { Mesh } from '../../objects/Mesh.js';
|
|
6
7
|
import { SphereGeometry } from '../../geometries/SphereGeometry.js';
|
|
@@ -90,6 +91,7 @@ class Background extends DataMap {
|
|
|
90
91
|
if ( sceneData.backgroundCacheKey !== backgroundCacheKey ) {
|
|
91
92
|
|
|
92
93
|
sceneData.backgroundMeshNode.node = vec4( backgroundNode ).mul( backgroundIntensity );
|
|
94
|
+
sceneData.backgroundMeshNode.needsUpdate = true;
|
|
93
95
|
|
|
94
96
|
backgroundMesh.material.needsUpdate = true;
|
|
95
97
|
|
|
@@ -2,10 +2,12 @@ let _id = 0;
|
|
|
2
2
|
|
|
3
3
|
class BindGroup {
|
|
4
4
|
|
|
5
|
-
constructor( name = '', bindings = [] ) {
|
|
5
|
+
constructor( name = '', bindings = [], index = 0, bindingsReference = [] ) {
|
|
6
6
|
|
|
7
7
|
this.name = name;
|
|
8
8
|
this.bindings = bindings;
|
|
9
|
+
this.index = index;
|
|
10
|
+
this.bindingsReference = bindingsReference;
|
|
9
11
|
|
|
10
12
|
this.id = _id ++;
|
|
11
13
|
|
|
@@ -70,21 +70,21 @@ class Bindings extends DataMap {
|
|
|
70
70
|
|
|
71
71
|
updateForCompute( computeNode ) {
|
|
72
72
|
|
|
73
|
-
this._updateBindings(
|
|
73
|
+
this._updateBindings( this.getForCompute( computeNode ) );
|
|
74
74
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
updateForRender( renderObject ) {
|
|
78
78
|
|
|
79
|
-
this._updateBindings(
|
|
79
|
+
this._updateBindings( this.getForRender( renderObject ) );
|
|
80
80
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
_updateBindings(
|
|
83
|
+
_updateBindings( bindings ) {
|
|
84
84
|
|
|
85
85
|
for ( const bindGroup of bindings ) {
|
|
86
86
|
|
|
87
|
-
this._update(
|
|
87
|
+
this._update( bindGroup, bindings );
|
|
88
88
|
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -110,7 +110,7 @@ class Bindings extends DataMap {
|
|
|
110
110
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
_update(
|
|
113
|
+
_update( bindGroup, bindings ) {
|
|
114
114
|
|
|
115
115
|
const { backend } = this;
|
|
116
116
|
|
|
@@ -144,26 +144,26 @@ class Bindings extends DataMap {
|
|
|
144
144
|
|
|
145
145
|
} else if ( binding.isSampledTexture ) {
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if ( binding.needsBindingsUpdate ) needsBindingsUpdate = true;
|
|
147
|
+
if ( binding.needsBindingsUpdate( this.textures.get( binding.texture ).generation ) ) needsBindingsUpdate = true;
|
|
150
148
|
|
|
151
149
|
const updated = binding.update();
|
|
152
150
|
|
|
151
|
+
const texture = binding.texture;
|
|
152
|
+
|
|
153
153
|
if ( updated ) {
|
|
154
154
|
|
|
155
|
-
this.textures.updateTexture(
|
|
155
|
+
this.textures.updateTexture( texture );
|
|
156
156
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
const textureData = backend.get(
|
|
159
|
+
const textureData = backend.get( texture );
|
|
160
160
|
|
|
161
161
|
if ( backend.isWebGPUBackend === true && textureData.texture === undefined && textureData.externalTexture === undefined ) {
|
|
162
162
|
|
|
163
163
|
// TODO: Remove this once we found why updated === false isn't bound to a texture in the WebGPU backend
|
|
164
|
-
console.error( 'Bindings._update: binding should be available:', binding, updated,
|
|
164
|
+
console.error( 'Bindings._update: binding should be available:', binding, updated, texture, binding.textureNode.value, needsBindingsUpdate );
|
|
165
165
|
|
|
166
|
-
this.textures.updateTexture(
|
|
166
|
+
this.textures.updateTexture( texture );
|
|
167
167
|
needsBindingsUpdate = true;
|
|
168
168
|
|
|
169
169
|
}
|
|
@@ -192,9 +192,7 @@ class Bindings extends DataMap {
|
|
|
192
192
|
|
|
193
193
|
if ( needsBindingsUpdate === true ) {
|
|
194
194
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
this.backend.updateBindings( bindGroup, bindings, pipeline );
|
|
195
|
+
this.backend.updateBindings( bindGroup, bindings );
|
|
198
196
|
|
|
199
197
|
}
|
|
200
198
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Group } from '../../objects/Group.js';
|
|
2
|
+
|
|
3
|
+
class BundleGroup extends Group {
|
|
4
|
+
|
|
5
|
+
constructor() {
|
|
6
|
+
|
|
7
|
+
super();
|
|
8
|
+
|
|
9
|
+
this.isBundleGroup = true;
|
|
10
|
+
|
|
11
|
+
this.type = 'BundleGroup';
|
|
12
|
+
|
|
13
|
+
this.static = true;
|
|
14
|
+
this.version = 0;
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
set needsUpdate( value ) {
|
|
19
|
+
|
|
20
|
+
if ( value === true ) this.version ++;
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default BundleGroup;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { Matrix3 } from '../../math/Matrix3.js';
|
|
2
2
|
import { Plane } from '../../math/Plane.js';
|
|
3
3
|
import { Vector4 } from '../../math/Vector4.js';
|
|
4
|
+
import { hash } from '../../nodes/core/NodeUtils.js';
|
|
4
5
|
|
|
5
6
|
const _plane = /*@__PURE__*/ new Plane();
|
|
6
7
|
|
|
7
|
-
let _clippingContextVersion = 0;
|
|
8
|
-
|
|
9
8
|
class ClippingContext {
|
|
10
9
|
|
|
11
10
|
constructor() {
|
|
12
11
|
|
|
13
|
-
this.version =
|
|
12
|
+
this.version = 0;
|
|
14
13
|
|
|
15
14
|
this.globalClippingCount = 0;
|
|
16
15
|
|
|
@@ -22,6 +21,7 @@ class ClippingContext {
|
|
|
22
21
|
|
|
23
22
|
this.parentVersion = 0;
|
|
24
23
|
this.viewNormalMatrix = new Matrix3();
|
|
24
|
+
this.cacheKey = 0;
|
|
25
25
|
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -93,7 +93,12 @@ class ClippingContext {
|
|
|
93
93
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
if ( update )
|
|
96
|
+
if ( update ) {
|
|
97
|
+
|
|
98
|
+
this.version ++;
|
|
99
|
+
this.cacheKey = hash( this.globalClippingCount, this.localClippingEnabled === true ? 1 : 0 );
|
|
100
|
+
|
|
101
|
+
}
|
|
97
102
|
|
|
98
103
|
}
|
|
99
104
|
|
|
@@ -158,7 +163,12 @@ class ClippingContext {
|
|
|
158
163
|
|
|
159
164
|
}
|
|
160
165
|
|
|
161
|
-
if ( update )
|
|
166
|
+
if ( update ) {
|
|
167
|
+
|
|
168
|
+
this.version += parent.version;
|
|
169
|
+
this.cacheKey = hash( parent.cacheKey, this.localClippingCount, this.localClipIntersection === true ? 1 : 0 );
|
|
170
|
+
|
|
171
|
+
}
|
|
162
172
|
|
|
163
173
|
}
|
|
164
174
|
|