@plastic-software/three 0.175.14 → 0.179.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/build/three.cjs +8402 -6787
- package/build/three.core.js +8007 -6688
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +397 -102
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +84 -27
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +6831 -2838
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +6648 -2838
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +1 -3
- package/examples/jsm/animation/AnimationClipCreator.js +1 -0
- package/examples/jsm/animation/CCDIKSolver.js +6 -3
- package/examples/jsm/capabilities/WebGL.js +1 -27
- package/examples/jsm/capabilities/WebGPU.js +2 -1
- package/examples/jsm/controls/ArcballControls.js +15 -4
- package/examples/jsm/controls/DragControls.js +1 -0
- package/examples/jsm/controls/FirstPersonControls.js +1 -0
- package/examples/jsm/controls/FlyControls.js +1 -0
- package/examples/jsm/controls/MapControls.js +1 -0
- package/examples/jsm/controls/OrbitControls.js +1 -0
- package/examples/jsm/controls/PointerLockControls.js +5 -3
- package/examples/jsm/controls/TrackballControls.js +1 -0
- package/examples/jsm/controls/TransformControls.js +62 -14
- package/examples/jsm/csm/CSM.js +2 -0
- package/examples/jsm/csm/CSMFrustum.js +2 -0
- package/examples/jsm/csm/CSMHelper.js +1 -0
- package/examples/jsm/csm/CSMShader.js +4 -1
- package/examples/jsm/csm/CSMShadowNode.js +22 -8
- package/examples/jsm/curves/CurveExtras.js +14 -0
- package/examples/jsm/curves/NURBSCurve.js +1 -0
- package/examples/jsm/curves/NURBSSurface.js +2 -0
- package/examples/jsm/curves/NURBSUtils.js +4 -1
- package/examples/jsm/curves/NURBSVolume.js +2 -0
- package/examples/jsm/effects/AnaglyphEffect.js +2 -0
- package/examples/jsm/effects/AsciiEffect.js +2 -0
- package/examples/jsm/effects/OutlineEffect.js +2 -0
- package/examples/jsm/effects/ParallaxBarrierEffect.js +2 -0
- package/examples/jsm/effects/StereoEffect.js +2 -0
- package/examples/jsm/environments/DebugEnvironment.js +1 -0
- package/examples/jsm/environments/RoomEnvironment.js +57 -38
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +2 -0
- package/examples/jsm/exporters/GLTFExporter.js +7 -4
- package/examples/jsm/exporters/KTX2Exporter.js +2 -0
- package/examples/jsm/exporters/OBJExporter.js +3 -1
- package/examples/jsm/exporters/PLYExporter.js +4 -2
- package/examples/jsm/exporters/STLExporter.js +2 -0
- package/examples/jsm/exporters/USDZExporter.js +679 -300
- package/examples/jsm/geometries/BoxLineGeometry.js +1 -0
- package/examples/jsm/geometries/ConvexGeometry.js +1 -0
- package/examples/jsm/geometries/DecalGeometry.js +1 -0
- package/examples/jsm/geometries/ParametricFunctions.js +4 -1
- package/examples/jsm/geometries/ParametricGeometry.js +1 -0
- package/examples/jsm/geometries/RoundedBoxGeometry.js +48 -8
- package/examples/jsm/geometries/TeapotGeometry.js +1 -0
- package/examples/jsm/geometries/TextGeometry.js +1 -0
- package/examples/jsm/helpers/LightProbeHelper.js +1 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -0
- package/examples/jsm/helpers/OctreeHelper.js +1 -0
- package/examples/jsm/helpers/PositionalAudioHelper.js +1 -0
- package/examples/jsm/helpers/RapierHelper.js +59 -0
- package/examples/jsm/helpers/RectAreaLightHelper.js +1 -0
- package/examples/jsm/helpers/TextureHelper.js +1 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +5 -4
- package/examples/jsm/helpers/VertexNormalsHelper.js +1 -0
- package/examples/jsm/helpers/VertexTangentsHelper.js +1 -0
- package/examples/jsm/helpers/ViewHelper.js +1 -0
- package/examples/jsm/interactive/HTMLMesh.js +11 -2
- package/examples/jsm/interactive/InteractiveGroup.js +1 -0
- package/examples/jsm/interactive/SelectionBox.js +2 -0
- package/examples/jsm/interactive/SelectionHelper.js +2 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lighting/TiledLighting.js +1 -0
- package/examples/jsm/lights/LightProbeGenerator.js +15 -3
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +1 -0
- package/examples/jsm/lines/Line2.js +1 -0
- package/examples/jsm/lines/LineGeometry.js +1 -0
- package/examples/jsm/lines/LineMaterial.js +4 -4
- package/examples/jsm/lines/LineSegments2.js +1 -0
- package/examples/jsm/lines/LineSegmentsGeometry.js +1 -0
- package/examples/jsm/lines/Wireframe.js +1 -0
- package/examples/jsm/lines/WireframeGeometry2.js +1 -0
- package/examples/jsm/lines/webgpu/Line2.js +1 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +3 -1
- package/examples/jsm/lines/webgpu/Wireframe.js +1 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -0
- package/examples/jsm/loaders/3MFLoader.js +1 -0
- package/examples/jsm/loaders/AMFLoader.js +1 -0
- package/examples/jsm/loaders/BVHLoader.js +1 -0
- package/examples/jsm/loaders/ColladaLoader.js +6 -5
- package/examples/jsm/loaders/DDSLoader.js +1 -0
- package/examples/jsm/loaders/DRACOLoader.js +2 -1
- package/examples/jsm/loaders/EXRLoader.js +211 -22
- package/examples/jsm/loaders/FBXLoader.js +25 -23
- package/examples/jsm/loaders/FontLoader.js +1 -0
- package/examples/jsm/loaders/GCodeLoader.js +1 -0
- package/examples/jsm/loaders/GLTFLoader.js +10 -82
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +1 -0
- package/examples/jsm/loaders/IESLoader.js +1 -0
- package/examples/jsm/loaders/KMZLoader.js +1 -0
- package/examples/jsm/loaders/KTX2Loader.js +67 -26
- package/examples/jsm/loaders/KTXLoader.js +1 -0
- package/examples/jsm/loaders/LDrawLoader.js +55 -3
- package/examples/jsm/loaders/LUT3dlLoader.js +1 -0
- package/examples/jsm/loaders/LUTCubeLoader.js +1 -0
- package/examples/jsm/loaders/LUTImageLoader.js +1 -0
- package/examples/jsm/loaders/LWOLoader.js +1 -13
- package/examples/jsm/loaders/LottieLoader.js +15 -0
- package/examples/jsm/loaders/MD2Loader.js +1 -0
- package/examples/jsm/loaders/MDDLoader.js +1 -0
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +213 -30
- package/examples/jsm/loaders/NRRDLoader.js +1 -0
- package/examples/jsm/loaders/OBJLoader.js +1 -0
- package/examples/jsm/loaders/PCDLoader.js +122 -19
- package/examples/jsm/loaders/PDBLoader.js +1 -0
- package/examples/jsm/loaders/PLYLoader.js +1 -0
- package/examples/jsm/loaders/PVRLoader.js +1 -0
- package/examples/jsm/loaders/RGBELoader.js +1 -0
- package/examples/jsm/loaders/RGBMLoader.js +1 -0
- package/examples/jsm/loaders/STLLoader.js +1 -0
- package/examples/jsm/loaders/SVGLoader.js +1 -0
- package/examples/jsm/loaders/TDSLoader.js +1 -0
- package/examples/jsm/loaders/TGALoader.js +1 -0
- package/examples/jsm/loaders/TIFFLoader.js +1 -0
- package/examples/jsm/loaders/TTFLoader.js +14 -1
- package/examples/jsm/loaders/USDLoader.js +219 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -891
- package/examples/jsm/loaders/UltraHDRLoader.js +1 -0
- package/examples/jsm/loaders/VOXLoader.js +1 -0
- package/examples/jsm/loaders/VRMLLoader.js +3 -2
- package/examples/jsm/loaders/VTKLoader.js +1 -0
- package/examples/jsm/loaders/XYZLoader.js +1 -0
- package/examples/jsm/loaders/lwo/IFFParser.js +74 -74
- package/examples/jsm/loaders/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +1 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -0
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +1 -0
- package/examples/jsm/math/Capsule.js +2 -0
- package/examples/jsm/math/ColorConverter.js +1 -0
- package/examples/jsm/math/ConvexHull.js +2 -0
- package/examples/jsm/math/ImprovedNoise.js +19 -14
- package/examples/jsm/math/Lut.js +2 -0
- package/examples/jsm/math/MeshSurfaceSampler.js +2 -0
- package/examples/jsm/math/OBB.js +2 -0
- package/examples/jsm/math/Octree.js +20 -1
- package/examples/jsm/math/SimplexNoise.js +2 -0
- package/examples/jsm/misc/ConvexObjectBreaker.js +3 -1
- package/examples/jsm/misc/GPUComputationRenderer.js +2 -0
- package/examples/jsm/misc/Gyroscope.js +1 -0
- package/examples/jsm/misc/MD2Character.js +2 -0
- package/examples/jsm/misc/MD2CharacterComplex.js +5 -3
- package/examples/jsm/misc/MorphAnimMesh.js +1 -0
- package/examples/jsm/misc/MorphBlendMesh.js +1 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +2 -0
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +2 -0
- package/examples/jsm/misc/RollerCoaster.js +5 -0
- package/examples/jsm/misc/TubePainter.js +1 -0
- package/examples/jsm/misc/Volume.js +2 -0
- package/examples/jsm/misc/VolumeSlice.js +1 -0
- package/examples/jsm/modifiers/CurveModifier.js +3 -0
- package/examples/jsm/modifiers/CurveModifierGPU.js +2 -0
- package/examples/jsm/modifiers/EdgeSplitModifier.js +2 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -0
- package/examples/jsm/modifiers/TessellateModifier.js +2 -0
- package/examples/jsm/objects/GroundedSkybox.js +1 -0
- package/examples/jsm/objects/Lensflare.js +3 -0
- package/examples/jsm/objects/LensflareMesh.js +4 -3
- package/examples/jsm/objects/MarchingCubes.js +2 -0
- package/examples/jsm/objects/Reflector.js +1 -0
- package/examples/jsm/objects/ReflectorForSSRPass.js +1 -0
- package/examples/jsm/objects/Refractor.js +1 -0
- package/examples/jsm/objects/ShadowMesh.js +1 -0
- package/examples/jsm/objects/Sky.js +2 -1
- package/examples/jsm/objects/SkyMesh.js +22 -19
- package/examples/jsm/objects/Water.js +1 -0
- package/examples/jsm/objects/Water2.js +1 -0
- package/examples/jsm/objects/Water2Mesh.js +3 -1
- package/examples/jsm/objects/WaterMesh.js +2 -1
- package/examples/jsm/physics/AmmoPhysics.js +1 -0
- package/examples/jsm/physics/JoltPhysics.js +1 -0
- package/examples/jsm/physics/RapierPhysics.js +149 -13
- package/examples/jsm/postprocessing/AfterimagePass.js +20 -2
- package/examples/jsm/postprocessing/BloomPass.js +2 -1
- package/examples/jsm/postprocessing/BokehPass.js +2 -1
- package/examples/jsm/postprocessing/ClearPass.js +1 -0
- package/examples/jsm/postprocessing/CubeTexturePass.js +1 -0
- package/examples/jsm/postprocessing/DotScreenPass.js +1 -0
- package/examples/jsm/postprocessing/EffectComposer.js +4 -2
- package/examples/jsm/postprocessing/FXAAPass.js +40 -0
- package/examples/jsm/postprocessing/FilmPass.js +1 -0
- package/examples/jsm/postprocessing/GTAOPass.js +14 -12
- package/examples/jsm/postprocessing/GlitchPass.js +2 -1
- package/examples/jsm/postprocessing/HalftonePass.js +2 -1
- package/examples/jsm/postprocessing/LUTPass.js +1 -0
- package/examples/jsm/postprocessing/MaskPass.js +1 -0
- package/examples/jsm/postprocessing/OutlinePass.js +22 -19
- package/examples/jsm/postprocessing/OutputPass.js +1 -0
- package/examples/jsm/postprocessing/Pass.js +3 -1
- package/examples/jsm/postprocessing/RenderPass.js +1 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +2 -1
- package/examples/jsm/postprocessing/RenderTransitionPass.js +4 -3
- package/examples/jsm/postprocessing/SAOPass.js +3 -2
- package/examples/jsm/postprocessing/SMAAPass.js +3 -2
- package/examples/jsm/postprocessing/SSAARenderPass.js +2 -1
- package/examples/jsm/postprocessing/SSAOPass.js +12 -10
- package/examples/jsm/postprocessing/SSRPass.js +4 -3
- package/examples/jsm/postprocessing/SavePass.js +2 -1
- package/examples/jsm/postprocessing/ShaderPass.js +1 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -0
- package/examples/jsm/postprocessing/TexturePass.js +1 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +2 -1
- package/examples/jsm/renderers/CSS2DRenderer.js +3 -0
- package/examples/jsm/renderers/CSS3DRenderer.js +4 -0
- package/examples/jsm/renderers/Projector.js +2 -0
- package/examples/jsm/renderers/SVGRenderer.js +3 -0
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +4 -1
- package/examples/jsm/shaders/AfterimageShader.js +4 -1
- package/examples/jsm/shaders/BasicShader.js +4 -1
- package/examples/jsm/shaders/BleachBypassShader.js +4 -1
- package/examples/jsm/shaders/BlendShader.js +4 -1
- package/examples/jsm/shaders/BokehShader.js +4 -1
- package/examples/jsm/shaders/BokehShader2.js +4 -1
- package/examples/jsm/shaders/BrightnessContrastShader.js +4 -1
- package/examples/jsm/shaders/ColorCorrectionShader.js +4 -1
- package/examples/jsm/shaders/ColorifyShader.js +4 -1
- package/examples/jsm/shaders/ConvolutionShader.js +4 -1
- package/examples/jsm/shaders/CopyShader.js +4 -1
- package/examples/jsm/shaders/DOFMipMapShader.js +4 -1
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +4 -1
- package/examples/jsm/shaders/DigitalGlitch.js +4 -1
- package/examples/jsm/shaders/DotScreenShader.js +4 -1
- package/examples/jsm/shaders/ExposureShader.js +4 -1
- package/examples/jsm/shaders/FXAAShader.js +4 -1
- package/examples/jsm/shaders/FilmShader.js +4 -1
- package/examples/jsm/shaders/FocusShader.js +4 -1
- package/examples/jsm/shaders/FreiChenShader.js +4 -1
- package/examples/jsm/shaders/GTAOShader.js +4 -1
- package/examples/jsm/shaders/GammaCorrectionShader.js +4 -1
- package/examples/jsm/shaders/GodRaysShader.js +4 -1
- package/examples/jsm/shaders/HalftoneShader.js +4 -1
- package/examples/jsm/shaders/HorizontalBlurShader.js +4 -1
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +4 -1
- package/examples/jsm/shaders/HueSaturationShader.js +4 -1
- package/examples/jsm/shaders/KaleidoShader.js +4 -1
- package/examples/jsm/shaders/LuminosityHighPassShader.js +4 -1
- package/examples/jsm/shaders/LuminosityShader.js +4 -1
- package/examples/jsm/shaders/MirrorShader.js +4 -1
- package/examples/jsm/shaders/NormalMapShader.js +4 -1
- package/examples/jsm/shaders/OutputShader.js +4 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +4 -1
- package/examples/jsm/shaders/RGBShiftShader.js +4 -1
- package/examples/jsm/shaders/SAOShader.js +4 -1
- package/examples/jsm/shaders/SMAAShader.js +1 -0
- package/examples/jsm/shaders/SSAOShader.js +4 -1
- package/examples/jsm/shaders/SSRShader.js +1 -0
- package/examples/jsm/shaders/SepiaShader.js +4 -1
- package/examples/jsm/shaders/SobelOperatorShader.js +4 -1
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +4 -1
- package/examples/jsm/shaders/TechnicolorShader.js +4 -1
- package/examples/jsm/shaders/ToonShader.js +2 -1
- package/examples/jsm/shaders/TriangleBlurShader.js +4 -1
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +15 -3
- package/examples/jsm/shaders/VelocityShader.js +4 -1
- package/examples/jsm/shaders/VerticalBlurShader.js +4 -1
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +4 -1
- package/examples/jsm/shaders/VignetteShader.js +4 -1
- package/examples/jsm/shaders/VolumeShader.js +5 -2
- package/examples/jsm/shaders/WaterRefractionShader.js +4 -1
- package/examples/jsm/textures/FlakesTexture.js +2 -0
- package/examples/jsm/transpiler/AST.js +381 -30
- package/examples/jsm/transpiler/GLSLDecoder.js +227 -88
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/TSLEncoder.js +234 -85
- package/examples/jsm/transpiler/Transpiler.js +19 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +788 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +2 -3
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +1 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +5 -4
- package/examples/jsm/tsl/display/BloomNode.js +9 -7
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +206 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +33 -33
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -0
- package/examples/jsm/tsl/display/DotScreenNode.js +1 -0
- package/examples/jsm/tsl/display/FXAANode.js +3 -2
- package/examples/jsm/tsl/display/FilmNode.js +1 -0
- package/examples/jsm/tsl/display/GTAONode.js +1 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +9 -36
- package/examples/jsm/tsl/display/LensflareNode.js +1 -0
- package/examples/jsm/tsl/display/Lut3DNode.js +1 -0
- package/examples/jsm/tsl/display/OutlineNode.js +1 -0
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +1 -0
- package/examples/jsm/tsl/display/PixelationPassNode.js +1 -0
- package/examples/jsm/tsl/display/RGBShiftNode.js +1 -0
- package/examples/jsm/tsl/display/SMAANode.js +9 -8
- package/examples/jsm/tsl/display/SSAAPassNode.js +5 -4
- package/examples/jsm/tsl/display/SSRNode.js +1 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +1 -0
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +1 -0
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -0
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +184 -174
- package/examples/jsm/tsl/display/TransitionNode.js +1 -0
- package/examples/jsm/tsl/display/hashBlur.js +28 -6
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +5 -4
- package/examples/jsm/tsl/math/Bayer.js +4 -1
- package/examples/jsm/tsl/shadows/TileShadowNode.js +456 -0
- package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +212 -0
- package/examples/jsm/tsl/utils/Raymarching.js +6 -3
- package/examples/jsm/utils/BufferGeometryUtils.js +4 -1
- package/examples/jsm/utils/CameraUtils.js +4 -1
- package/examples/jsm/utils/GeometryCompressionUtils.js +4 -1
- package/examples/jsm/utils/GeometryUtils.js +4 -1
- package/examples/jsm/utils/LDrawUtils.js +2 -0
- package/examples/jsm/utils/SceneOptimizer.js +2 -0
- package/examples/jsm/utils/SceneUtils.js +4 -1
- package/examples/jsm/utils/ShadowMapViewer.js +2 -0
- package/examples/jsm/utils/ShadowMapViewerGPU.js +2 -0
- package/examples/jsm/utils/SkeletonUtils.js +4 -1
- package/examples/jsm/utils/SortUtils.js +4 -1
- package/examples/jsm/utils/UVsDebug.js +4 -1
- package/examples/jsm/utils/WebGLTextureUtils.js +4 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +4 -1
- package/examples/jsm/utils/WorkerPool.js +2 -0
- package/examples/jsm/webxr/ARButton.js +1 -0
- package/examples/jsm/webxr/OculusHandModel.js +1 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +1 -0
- package/examples/jsm/webxr/Text2D.js +4 -1
- package/examples/jsm/webxr/VRButton.js +1 -0
- package/examples/jsm/webxr/XRButton.js +1 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +2 -0
- package/examples/jsm/webxr/XREstimatedLight.js +1 -0
- package/examples/jsm/webxr/XRHandMeshModel.js +2 -0
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -0
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +2 -0
- package/examples/jsm/webxr/XRPlanes.js +1 -0
- package/package.json +6 -4
- package/src/Three.Core.js +2 -1
- package/src/Three.TSL.js +83 -26
- package/src/Three.WebGPU.Nodes.js +1 -0
- package/src/Three.WebGPU.js +3 -0
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/audio/AudioListener.js +13 -10
- package/src/cameras/ArrayCamera.js +9 -1
- package/src/cameras/Camera.js +14 -0
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +47 -20
- package/src/core/BufferAttribute.js +3 -3
- package/src/core/BufferGeometry.js +2 -5
- package/src/core/Clock.js +2 -8
- package/src/core/GLBufferAttribute.js +13 -1
- package/src/core/Object3D.js +23 -22
- package/src/core/RenderTarget.js +65 -21
- package/src/core/RenderTarget3D.js +1 -0
- package/{examples/jsm/misc → src/core}/Timer.js +4 -40
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/extras/TextureUtils.js +1 -5
- package/src/extras/core/Curve.js +1 -1
- package/src/extras/core/Path.js +22 -22
- package/src/geometries/CapsuleGeometry.js +167 -17
- package/src/geometries/ExtrudeGeometry.js +39 -29
- package/src/helpers/ArrowHelper.js +2 -2
- package/src/helpers/CameraHelper.js +41 -11
- package/src/helpers/SkeletonHelper.js +36 -7
- package/src/lights/LightShadow.js +34 -7
- package/src/lights/PointLightShadow.js +1 -1
- package/src/lights/SpotLightShadow.js +9 -1
- package/src/lights/webgpu/ProjectorLight.js +46 -0
- package/src/loaders/BufferGeometryLoader.js +1 -10
- package/src/loaders/FileLoader.js +27 -4
- package/src/loaders/ImageBitmapLoader.js +48 -9
- package/src/loaders/ImageLoader.js +55 -8
- package/src/loaders/Loader.js +14 -0
- package/src/loaders/LoadingManager.js +23 -0
- package/src/loaders/ObjectLoader.js +44 -16
- package/src/loaders/nodes/NodeObjectLoader.js +2 -2
- package/src/materials/Material.js +1 -7
- package/src/materials/MeshBasicMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +0 -8
- package/src/materials/nodes/MeshBasicNodeMaterial.js +4 -3
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +1 -1
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -1
- package/src/materials/nodes/MeshSSSNodeMaterial.js +2 -2
- package/src/materials/nodes/NodeMaterial.js +106 -20
- package/src/materials/nodes/PointsNodeMaterial.js +5 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +107 -4
- package/src/math/Box3.js +28 -0
- package/src/math/Color.js +7 -7
- package/src/math/ColorManagement.js +22 -3
- package/src/math/Frustum.js +25 -9
- package/src/math/FrustumArray.js +258 -0
- package/src/math/Line3.js +129 -2
- package/src/math/Matrix4.js +48 -27
- package/src/math/Quaternion.js +1 -1
- package/src/math/Ray.js +2 -0
- package/src/math/Sphere.js +28 -0
- package/src/math/Spherical.js +2 -2
- package/src/nodes/Nodes.js +3 -3
- package/src/nodes/TSL.js +6 -3
- package/src/nodes/accessors/AccessorsUtils.js +7 -8
- package/src/nodes/accessors/Bitangent.js +54 -26
- package/src/nodes/accessors/Camera.js +40 -13
- package/src/nodes/accessors/CubeTextureNode.js +50 -2
- package/src/nodes/accessors/InstanceNode.js +5 -4
- package/src/nodes/accessors/Lights.js +2 -2
- package/src/nodes/accessors/MaterialNode.js +4 -0
- package/src/nodes/accessors/ModelNode.js +1 -1
- package/src/nodes/accessors/Normal.js +110 -24
- package/src/nodes/accessors/Object3DNode.js +7 -8
- package/src/nodes/accessors/Position.js +14 -4
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +19 -4
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/SkinningNode.js +3 -2
- package/src/nodes/accessors/StorageBufferNode.js +25 -0
- package/src/nodes/accessors/StorageTextureNode.js +15 -4
- package/src/nodes/accessors/Tangent.js +25 -17
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/TextureBicubic.js +21 -3
- package/src/nodes/accessors/TextureNode.js +71 -8
- package/src/nodes/accessors/UniformArrayNode.js +0 -16
- package/src/nodes/accessors/VelocityNode.js +1 -0
- package/src/nodes/accessors/VertexColorNode.js +4 -4
- package/src/nodes/code/CodeNode.js +8 -11
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +30 -5
- package/src/nodes/core/AttributeNode.js +2 -2
- package/src/nodes/core/ContextNode.js +27 -4
- package/src/nodes/core/Node.js +83 -22
- package/src/nodes/core/NodeBuilder.js +273 -49
- package/src/nodes/core/NodeUtils.js +46 -1
- package/src/nodes/core/NodeVarying.js +19 -1
- package/src/nodes/core/PropertyNode.js +8 -12
- package/src/nodes/core/StackNode.js +171 -26
- package/src/nodes/core/StructTypeNode.js +26 -4
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/UniformNode.js +63 -5
- package/src/nodes/core/VarNode.js +102 -4
- package/src/nodes/core/VaryingNode.js +45 -24
- package/src/nodes/display/BlendModes.js +42 -1
- package/src/nodes/display/ColorSpaceNode.js +4 -27
- package/src/nodes/display/FrontFacingNode.js +34 -2
- package/src/nodes/display/NormalMapNode.js +19 -50
- package/src/nodes/display/PassNode.js +165 -20
- package/src/nodes/display/ScreenNode.js +0 -26
- package/src/nodes/display/ViewportTextureNode.js +67 -7
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/PhongLightingModel.js +3 -3
- package/src/nodes/functions/PhysicalLightingModel.js +16 -16
- package/src/nodes/functions/ShadowMaskModel.js +5 -1
- package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +1 -1
- package/src/nodes/gpgpu/AtomicFunctionNode.js +28 -10
- package/src/nodes/gpgpu/BarrierNode.js +3 -3
- package/src/nodes/gpgpu/ComputeNode.js +68 -24
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
- package/src/nodes/lighting/AnalyticLightNode.js +7 -13
- package/src/nodes/lighting/EnvironmentNode.js +5 -5
- package/src/nodes/lighting/HemisphereLightNode.js +2 -2
- package/src/nodes/lighting/IESSpotLightNode.js +2 -1
- package/src/nodes/lighting/LightsNode.js +29 -11
- package/src/nodes/lighting/ProjectorLightNode.js +91 -0
- package/src/nodes/lighting/ShadowBaseNode.js +1 -12
- package/src/nodes/lighting/ShadowFilterNode.js +274 -0
- package/src/nodes/lighting/ShadowNode.js +174 -242
- package/src/nodes/lighting/SpotLightNode.js +44 -7
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +166 -2
- package/src/nodes/math/ConditionalNode.js +1 -20
- package/src/nodes/math/MathNode.js +146 -75
- package/src/nodes/math/OperatorNode.js +129 -119
- package/src/nodes/shapes/Shapes.js +5 -4
- package/src/nodes/tsl/TSLBase.js +1 -0
- package/src/nodes/tsl/TSLCore.js +222 -72
- package/src/nodes/utils/DebugNode.js +16 -4
- package/src/nodes/utils/Discard.js +2 -2
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/LoopNode.js +64 -34
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/RTTNode.js +22 -5
- package/src/nodes/utils/ReflectorNode.js +77 -7
- package/src/nodes/utils/SampleNode.js +81 -0
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/objects/BatchedMesh.js +20 -6
- package/src/objects/Mesh.js +9 -0
- package/src/objects/Skeleton.js +1 -1
- package/src/objects/Sprite.js +9 -0
- package/src/renderers/WebGL3DRenderTarget.js +1 -0
- package/src/renderers/WebGLArrayRenderTarget.js +1 -0
- package/src/renderers/WebGLCubeRenderTarget.js +2 -4
- package/src/renderers/WebGLRenderer.js +45 -32
- package/src/renderers/common/Animation.js +2 -2
- package/src/renderers/common/Background.js +13 -2
- package/src/renderers/common/Bindings.js +19 -18
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/RenderList.js +0 -4
- package/src/renderers/common/RenderObject.js +80 -4
- package/src/renderers/common/Renderer.js +133 -22
- package/src/renderers/common/SampledTexture.js +3 -71
- package/src/renderers/common/Sampler.js +79 -0
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageTexture.js +19 -0
- package/src/renderers/common/Textures.js +34 -24
- package/src/renderers/common/TimestampQueryPool.js +1 -0
- package/src/renderers/common/Uniform.js +1 -1
- package/src/renderers/common/UniformsGroup.js +14 -18
- package/src/renderers/common/XRManager.js +183 -35
- package/src/renderers/common/XRRenderTarget.js +21 -4
- package/src/renderers/common/extras/PMREMGenerator.js +30 -23
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- package/src/renderers/common/nodes/Nodes.js +13 -3
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +20 -2
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/webgl/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLMaterials.js +6 -6
- package/src/renderers/webgl/WebGLProgram.js +22 -16
- package/src/renderers/webgl/WebGLPrograms.js +8 -6
- package/src/renderers/webgl/WebGLShadowMap.js +14 -3
- package/src/renderers/webgl/WebGLState.js +4 -4
- package/src/renderers/webgl/WebGLTextures.js +163 -11
- package/src/renderers/webgl/WebGLUtils.js +1 -3
- package/src/renderers/webgl-fallback/WebGLBackend.js +261 -94
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +75 -9
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +4 -0
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +1 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +4 -4
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +44 -29
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +22 -21
- package/src/renderers/webgpu/WebGPUBackend.js +505 -143
- package/src/renderers/webgpu/WebGPURenderer.js +7 -0
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +4 -1
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +4 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +129 -96
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +3 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +9 -1
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +58 -31
- package/src/renderers/webgpu/utils/WebGPUConstants.js +8 -2
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +39 -9
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +50 -108
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRController.js +1 -1
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +70 -9
- package/src/textures/DepthTexture.js +6 -10
- package/src/textures/ExternalTexture.js +45 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +32 -0
- package/src/textures/Texture.js +118 -1
- package/src/textures/VideoTexture.js +31 -3
- package/examples/jsm/effects/PeppersGhostEffect.js +0 -172
- package/src/core/RenderTargetArray.js +0 -40
- package/src/nodes/utils/EquirectUVNode.js +0 -65
- package/src/nodes/utils/MatcapUVNode.js +0 -49
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -148
|
@@ -31,6 +31,7 @@ class WebGPUBackend extends Backend {
|
|
|
31
31
|
* @typedef {Object} WebGPUBackend~Options
|
|
32
32
|
* @property {boolean} [logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
|
|
33
33
|
* @property {boolean} [alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
|
|
34
|
+
* @property {boolean} [compatibilityMode=false] - Whether the backend should be in compatibility mode or not.
|
|
34
35
|
* @property {boolean} [depth=true] - Whether the default framebuffer should have a depth buffer or not.
|
|
35
36
|
* @property {boolean} [stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
|
|
36
37
|
* @property {boolean} [antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not.
|
|
@@ -63,9 +64,17 @@ class WebGPUBackend extends Backend {
|
|
|
63
64
|
|
|
64
65
|
// some parameters require default values other than "undefined"
|
|
65
66
|
this.parameters.alpha = ( parameters.alpha === undefined ) ? true : parameters.alpha;
|
|
67
|
+
this.parameters.compatibilityMode = ( parameters.compatibilityMode === undefined ) ? false : parameters.compatibilityMode;
|
|
66
68
|
|
|
67
69
|
this.parameters.requiredLimits = ( parameters.requiredLimits === undefined ) ? {} : parameters.requiredLimits;
|
|
68
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Indicates whether the backend is in compatibility mode or not.
|
|
73
|
+
* @type {boolean}
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
this.compatibilityMode = this.parameters.compatibilityMode;
|
|
77
|
+
|
|
69
78
|
/**
|
|
70
79
|
* A reference to the device.
|
|
71
80
|
*
|
|
@@ -168,7 +177,8 @@ class WebGPUBackend extends Backend {
|
|
|
168
177
|
if ( parameters.device === undefined ) {
|
|
169
178
|
|
|
170
179
|
const adapterOptions = {
|
|
171
|
-
powerPreference: parameters.powerPreference
|
|
180
|
+
powerPreference: parameters.powerPreference,
|
|
181
|
+
featureLevel: parameters.compatibilityMode ? 'compatibility' : undefined
|
|
172
182
|
};
|
|
173
183
|
|
|
174
184
|
const adapter = ( typeof navigator !== 'undefined' ) ? await navigator.gpu.requestAdapter( adapterOptions ) : null;
|
|
@@ -342,6 +352,20 @@ class WebGPUBackend extends Backend {
|
|
|
342
352
|
|
|
343
353
|
}
|
|
344
354
|
|
|
355
|
+
/**
|
|
356
|
+
* Internal to determine if the current render target is a render target array with depth 2D array texture.
|
|
357
|
+
*
|
|
358
|
+
* @param {RenderContext} renderContext - The render context.
|
|
359
|
+
* @return {boolean} Whether the render target is a render target array with depth 2D array texture.
|
|
360
|
+
*
|
|
361
|
+
* @private
|
|
362
|
+
*/
|
|
363
|
+
_isRenderCameraDepthArray( renderContext ) {
|
|
364
|
+
|
|
365
|
+
return renderContext.depthTexture && renderContext.depthTexture.image.depth > 1 && renderContext.camera.isArrayCamera;
|
|
366
|
+
|
|
367
|
+
}
|
|
368
|
+
|
|
345
369
|
/**
|
|
346
370
|
* Returns the render pass descriptor for the given render context.
|
|
347
371
|
*
|
|
@@ -397,6 +421,8 @@ class WebGPUBackend extends Backend {
|
|
|
397
421
|
|
|
398
422
|
let sliceIndex;
|
|
399
423
|
|
|
424
|
+
const isRenderCameraDepthArray = this._isRenderCameraDepthArray( renderContext );
|
|
425
|
+
|
|
400
426
|
for ( let i = 0; i < textures.length; i ++ ) {
|
|
401
427
|
|
|
402
428
|
const textureData = this.get( textures[ i ] );
|
|
@@ -418,34 +444,62 @@ class WebGPUBackend extends Backend {
|
|
|
418
444
|
viewDescriptor.dimension = GPUTextureViewDimension.ThreeD;
|
|
419
445
|
viewDescriptor.depthOrArrayLayers = textures[ i ].image.depth;
|
|
420
446
|
|
|
421
|
-
} else if ( renderTarget.
|
|
447
|
+
} else if ( renderTarget.isRenderTarget && textures[ i ].image.depth > 1 ) {
|
|
422
448
|
|
|
423
|
-
|
|
424
|
-
|
|
449
|
+
if ( isRenderCameraDepthArray === true ) {
|
|
450
|
+
|
|
451
|
+
const cameras = renderContext.camera.cameras;
|
|
452
|
+
for ( let layer = 0; layer < cameras.length; layer ++ ) {
|
|
453
|
+
|
|
454
|
+
const layerViewDescriptor = {
|
|
455
|
+
...viewDescriptor,
|
|
456
|
+
baseArrayLayer: layer,
|
|
457
|
+
arrayLayerCount: 1,
|
|
458
|
+
dimension: GPUTextureViewDimension.TwoD
|
|
459
|
+
};
|
|
460
|
+
const textureView = textureData.texture.createView( layerViewDescriptor );
|
|
461
|
+
textureViews.push( {
|
|
462
|
+
view: textureView,
|
|
463
|
+
resolveTarget: undefined,
|
|
464
|
+
depthSlice: undefined
|
|
465
|
+
} );
|
|
466
|
+
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
} else {
|
|
470
|
+
|
|
471
|
+
viewDescriptor.dimension = GPUTextureViewDimension.TwoDArray;
|
|
472
|
+
viewDescriptor.depthOrArrayLayers = textures[ i ].image.depth;
|
|
473
|
+
|
|
474
|
+
}
|
|
425
475
|
|
|
426
476
|
}
|
|
427
477
|
|
|
428
|
-
|
|
478
|
+
if ( isRenderCameraDepthArray !== true ) {
|
|
429
479
|
|
|
430
|
-
|
|
480
|
+
const textureView = textureData.texture.createView( viewDescriptor );
|
|
431
481
|
|
|
432
|
-
|
|
482
|
+
let view, resolveTarget;
|
|
433
483
|
|
|
434
|
-
|
|
435
|
-
resolveTarget = textureView;
|
|
484
|
+
if ( textureData.msaaTexture !== undefined ) {
|
|
436
485
|
|
|
437
|
-
|
|
486
|
+
view = textureData.msaaTexture.createView();
|
|
487
|
+
resolveTarget = textureView;
|
|
438
488
|
|
|
439
|
-
|
|
440
|
-
resolveTarget = undefined;
|
|
489
|
+
} else {
|
|
441
490
|
|
|
442
|
-
|
|
491
|
+
view = textureView;
|
|
492
|
+
resolveTarget = undefined;
|
|
443
493
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
textureViews.push( {
|
|
497
|
+
view,
|
|
498
|
+
resolveTarget,
|
|
499
|
+
depthSlice: sliceIndex
|
|
500
|
+
} );
|
|
501
|
+
|
|
502
|
+
}
|
|
449
503
|
|
|
450
504
|
}
|
|
451
505
|
|
|
@@ -454,7 +508,16 @@ class WebGPUBackend extends Backend {
|
|
|
454
508
|
if ( renderContext.depth ) {
|
|
455
509
|
|
|
456
510
|
const depthTextureData = this.get( renderContext.depthTexture );
|
|
457
|
-
|
|
511
|
+
const options = {};
|
|
512
|
+
if ( renderContext.depthTexture.isArrayTexture ) {
|
|
513
|
+
|
|
514
|
+
options.dimension = GPUTextureViewDimension.TwoD;
|
|
515
|
+
options.arrayLayerCount = 1;
|
|
516
|
+
options.baseArrayLayer = renderContext.activeCubeFace;
|
|
517
|
+
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
descriptorBase.depthStencilView = depthTextureData.texture.createView( options );
|
|
458
521
|
|
|
459
522
|
}
|
|
460
523
|
|
|
@@ -576,15 +639,15 @@ class WebGPUBackend extends Backend {
|
|
|
576
639
|
|
|
577
640
|
colorAttachment.clearValue = i === 0 ? renderContext.clearColorValue : { r: 0, g: 0, b: 0, a: 1 };
|
|
578
641
|
colorAttachment.loadOp = GPULoadOp.Clear;
|
|
579
|
-
colorAttachment.storeOp = GPUStoreOp.Store;
|
|
580
642
|
|
|
581
643
|
} else {
|
|
582
644
|
|
|
583
645
|
colorAttachment.loadOp = GPULoadOp.Load;
|
|
584
|
-
colorAttachment.storeOp = GPUStoreOp.Store;
|
|
585
646
|
|
|
586
647
|
}
|
|
587
648
|
|
|
649
|
+
colorAttachment.storeOp = GPUStoreOp.Store;
|
|
650
|
+
|
|
588
651
|
}
|
|
589
652
|
|
|
590
653
|
} else {
|
|
@@ -595,15 +658,15 @@ class WebGPUBackend extends Backend {
|
|
|
595
658
|
|
|
596
659
|
colorAttachment.clearValue = renderContext.clearColorValue;
|
|
597
660
|
colorAttachment.loadOp = GPULoadOp.Clear;
|
|
598
|
-
colorAttachment.storeOp = GPUStoreOp.Store;
|
|
599
661
|
|
|
600
662
|
} else {
|
|
601
663
|
|
|
602
664
|
colorAttachment.loadOp = GPULoadOp.Load;
|
|
603
|
-
colorAttachment.storeOp = GPUStoreOp.Store;
|
|
604
665
|
|
|
605
666
|
}
|
|
606
667
|
|
|
668
|
+
colorAttachment.storeOp = GPUStoreOp.Store;
|
|
669
|
+
|
|
607
670
|
}
|
|
608
671
|
|
|
609
672
|
//
|
|
@@ -614,60 +677,235 @@ class WebGPUBackend extends Backend {
|
|
|
614
677
|
|
|
615
678
|
depthStencilAttachment.depthClearValue = renderContext.clearDepthValue;
|
|
616
679
|
depthStencilAttachment.depthLoadOp = GPULoadOp.Clear;
|
|
617
|
-
depthStencilAttachment.depthStoreOp = GPUStoreOp.Store;
|
|
618
680
|
|
|
619
681
|
} else {
|
|
620
682
|
|
|
621
683
|
depthStencilAttachment.depthLoadOp = GPULoadOp.Load;
|
|
622
|
-
depthStencilAttachment.depthStoreOp = GPUStoreOp.Store;
|
|
623
684
|
|
|
624
685
|
}
|
|
625
686
|
|
|
687
|
+
depthStencilAttachment.depthStoreOp = GPUStoreOp.Store;
|
|
688
|
+
|
|
626
689
|
}
|
|
627
690
|
|
|
628
691
|
if ( renderContext.stencil ) {
|
|
629
692
|
|
|
630
|
-
|
|
693
|
+
if ( renderContext.clearStencil ) {
|
|
631
694
|
|
|
632
695
|
depthStencilAttachment.stencilClearValue = renderContext.clearStencilValue;
|
|
633
696
|
depthStencilAttachment.stencilLoadOp = GPULoadOp.Clear;
|
|
634
|
-
depthStencilAttachment.stencilStoreOp = GPUStoreOp.Store;
|
|
635
697
|
|
|
636
698
|
} else {
|
|
637
699
|
|
|
638
700
|
depthStencilAttachment.stencilLoadOp = GPULoadOp.Load;
|
|
639
|
-
depthStencilAttachment.stencilStoreOp = GPUStoreOp.Store;
|
|
640
701
|
|
|
641
702
|
}
|
|
642
703
|
|
|
704
|
+
depthStencilAttachment.stencilStoreOp = GPUStoreOp.Store;
|
|
705
|
+
|
|
643
706
|
}
|
|
644
707
|
|
|
645
708
|
//
|
|
646
709
|
|
|
647
710
|
const encoder = device.createCommandEncoder( { label: 'renderContext_' + renderContext.id } );
|
|
648
|
-
|
|
711
|
+
|
|
712
|
+
// shadow arrays - prepare bundle encoders for each camera in an array camera
|
|
713
|
+
|
|
714
|
+
if ( this._isRenderCameraDepthArray( renderContext ) === true ) {
|
|
715
|
+
|
|
716
|
+
const cameras = renderContext.camera.cameras;
|
|
717
|
+
|
|
718
|
+
if ( ! renderContextData.layerDescriptors || renderContextData.layerDescriptors.length !== cameras.length ) {
|
|
719
|
+
|
|
720
|
+
this._createDepthLayerDescriptors( renderContext, renderContextData, descriptor, cameras );
|
|
721
|
+
|
|
722
|
+
} else {
|
|
723
|
+
|
|
724
|
+
this._updateDepthLayerDescriptors( renderContext, renderContextData, cameras );
|
|
725
|
+
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// Create bundle encoders for each layer
|
|
729
|
+
renderContextData.bundleEncoders = [];
|
|
730
|
+
renderContextData.bundleSets = [];
|
|
731
|
+
|
|
732
|
+
// Create separate bundle encoders for each camera in the array
|
|
733
|
+
for ( let i = 0; i < cameras.length; i ++ ) {
|
|
734
|
+
|
|
735
|
+
const bundleEncoder = this.pipelineUtils.createBundleEncoder(
|
|
736
|
+
renderContext,
|
|
737
|
+
'renderBundleArrayCamera_' + i
|
|
738
|
+
);
|
|
739
|
+
|
|
740
|
+
// Initialize state tracking for this bundle
|
|
741
|
+
const bundleSets = {
|
|
742
|
+
attributes: {},
|
|
743
|
+
bindingGroups: [],
|
|
744
|
+
pipeline: null,
|
|
745
|
+
index: null
|
|
746
|
+
};
|
|
747
|
+
|
|
748
|
+
renderContextData.bundleEncoders.push( bundleEncoder );
|
|
749
|
+
renderContextData.bundleSets.push( bundleSets );
|
|
750
|
+
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
// We'll complete the bundles in finishRender
|
|
754
|
+
renderContextData.currentPass = null;
|
|
755
|
+
|
|
756
|
+
} else {
|
|
757
|
+
|
|
758
|
+
const currentPass = encoder.beginRenderPass( descriptor );
|
|
759
|
+
renderContextData.currentPass = currentPass;
|
|
760
|
+
|
|
761
|
+
if ( renderContext.viewport ) {
|
|
762
|
+
|
|
763
|
+
this.updateViewport( renderContext );
|
|
764
|
+
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
if ( renderContext.scissor ) {
|
|
768
|
+
|
|
769
|
+
const { x, y, width, height } = renderContext.scissorValue;
|
|
770
|
+
currentPass.setScissorRect( x, y, width, height );
|
|
771
|
+
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
}
|
|
649
775
|
|
|
650
776
|
//
|
|
651
777
|
|
|
652
778
|
renderContextData.descriptor = descriptor;
|
|
653
779
|
renderContextData.encoder = encoder;
|
|
654
|
-
renderContextData.currentPass = currentPass;
|
|
655
780
|
renderContextData.currentSets = { attributes: {}, bindingGroups: [], pipeline: null, index: null };
|
|
656
781
|
renderContextData.renderBundles = [];
|
|
657
782
|
|
|
658
|
-
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* This method creates layer descriptors for each camera in an array camera
|
|
787
|
+
* to prepare for rendering to a depth array texture.
|
|
788
|
+
*
|
|
789
|
+
* @param {RenderContext} renderContext - The render context.
|
|
790
|
+
* @param {Object} renderContextData - The render context data.
|
|
791
|
+
* @param {Object} descriptor - The render pass descriptor.
|
|
792
|
+
* @param {ArrayCamera} cameras - The array camera.
|
|
793
|
+
*
|
|
794
|
+
* @private
|
|
795
|
+
*/
|
|
796
|
+
_createDepthLayerDescriptors( renderContext, renderContextData, descriptor, cameras ) {
|
|
797
|
+
|
|
798
|
+
const depthStencilAttachment = descriptor.depthStencilAttachment;
|
|
799
|
+
renderContextData.layerDescriptors = [];
|
|
800
|
+
|
|
801
|
+
const depthTextureData = this.get( renderContext.depthTexture );
|
|
802
|
+
if ( ! depthTextureData.viewCache ) {
|
|
803
|
+
|
|
804
|
+
depthTextureData.viewCache = [];
|
|
805
|
+
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
for ( let i = 0; i < cameras.length; i ++ ) {
|
|
809
|
+
|
|
810
|
+
const layerDescriptor = {
|
|
811
|
+
...descriptor,
|
|
812
|
+
colorAttachments: [ {
|
|
813
|
+
...descriptor.colorAttachments[ 0 ],
|
|
814
|
+
view: descriptor.colorAttachments[ i ].view
|
|
815
|
+
} ]
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
if ( descriptor.depthStencilAttachment ) {
|
|
819
|
+
|
|
820
|
+
const layerIndex = i;
|
|
821
|
+
|
|
822
|
+
if ( ! depthTextureData.viewCache[ layerIndex ] ) {
|
|
823
|
+
|
|
824
|
+
depthTextureData.viewCache[ layerIndex ] = depthTextureData.texture.createView( {
|
|
825
|
+
dimension: GPUTextureViewDimension.TwoD,
|
|
826
|
+
baseArrayLayer: i,
|
|
827
|
+
arrayLayerCount: 1
|
|
828
|
+
} );
|
|
829
|
+
|
|
830
|
+
}
|
|
659
831
|
|
|
660
|
-
|
|
832
|
+
layerDescriptor.depthStencilAttachment = {
|
|
833
|
+
view: depthTextureData.viewCache[ layerIndex ],
|
|
834
|
+
depthLoadOp: depthStencilAttachment.depthLoadOp || GPULoadOp.Clear,
|
|
835
|
+
depthStoreOp: depthStencilAttachment.depthStoreOp || GPUStoreOp.Store,
|
|
836
|
+
depthClearValue: depthStencilAttachment.depthClearValue || 1.0
|
|
837
|
+
};
|
|
838
|
+
|
|
839
|
+
if ( renderContext.stencil ) {
|
|
840
|
+
|
|
841
|
+
layerDescriptor.depthStencilAttachment.stencilLoadOp = depthStencilAttachment.stencilLoadOp;
|
|
842
|
+
layerDescriptor.depthStencilAttachment.stencilStoreOp = depthStencilAttachment.stencilStoreOp;
|
|
843
|
+
layerDescriptor.depthStencilAttachment.stencilClearValue = depthStencilAttachment.stencilClearValue;
|
|
844
|
+
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
} else {
|
|
848
|
+
|
|
849
|
+
layerDescriptor.depthStencilAttachment = { ...depthStencilAttachment };
|
|
850
|
+
|
|
851
|
+
}
|
|
661
852
|
|
|
662
|
-
|
|
853
|
+
renderContextData.layerDescriptors.push( layerDescriptor );
|
|
663
854
|
|
|
664
855
|
}
|
|
665
856
|
|
|
666
|
-
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* This method updates the layer descriptors for each camera in an array camera
|
|
861
|
+
* to prepare for rendering to a depth array texture.
|
|
862
|
+
*
|
|
863
|
+
* @param {RenderContext} renderContext - The render context.
|
|
864
|
+
* @param {Object} renderContextData - The render context data.
|
|
865
|
+
* @param {ArrayCamera} cameras - The array camera.
|
|
866
|
+
*
|
|
867
|
+
*/
|
|
868
|
+
_updateDepthLayerDescriptors( renderContext, renderContextData, cameras ) {
|
|
869
|
+
|
|
870
|
+
for ( let i = 0; i < cameras.length; i ++ ) {
|
|
871
|
+
|
|
872
|
+
const layerDescriptor = renderContextData.layerDescriptors[ i ];
|
|
873
|
+
|
|
874
|
+
if ( layerDescriptor.depthStencilAttachment ) {
|
|
875
|
+
|
|
876
|
+
const depthAttachment = layerDescriptor.depthStencilAttachment;
|
|
877
|
+
|
|
878
|
+
if ( renderContext.depth ) {
|
|
879
|
+
|
|
880
|
+
if ( renderContext.clearDepth ) {
|
|
881
|
+
|
|
882
|
+
depthAttachment.depthClearValue = renderContext.clearDepthValue;
|
|
883
|
+
depthAttachment.depthLoadOp = GPULoadOp.Clear;
|
|
884
|
+
|
|
885
|
+
} else {
|
|
886
|
+
|
|
887
|
+
depthAttachment.depthLoadOp = GPULoadOp.Load;
|
|
888
|
+
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
if ( renderContext.stencil ) {
|
|
894
|
+
|
|
895
|
+
if ( renderContext.clearStencil ) {
|
|
896
|
+
|
|
897
|
+
depthAttachment.stencilClearValue = renderContext.clearStencilValue;
|
|
898
|
+
depthAttachment.stencilLoadOp = GPULoadOp.Clear;
|
|
899
|
+
|
|
900
|
+
} else {
|
|
901
|
+
|
|
902
|
+
depthAttachment.stencilLoadOp = GPULoadOp.Load;
|
|
667
903
|
|
|
668
|
-
|
|
904
|
+
}
|
|
669
905
|
|
|
670
|
-
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
}
|
|
671
909
|
|
|
672
910
|
}
|
|
673
911
|
|
|
@@ -696,7 +934,55 @@ class WebGPUBackend extends Backend {
|
|
|
696
934
|
|
|
697
935
|
}
|
|
698
936
|
|
|
699
|
-
|
|
937
|
+
// shadow arrays - Execute bundles for each layer
|
|
938
|
+
|
|
939
|
+
const encoder = renderContextData.encoder;
|
|
940
|
+
|
|
941
|
+
if ( this._isRenderCameraDepthArray( renderContext ) === true ) {
|
|
942
|
+
|
|
943
|
+
const bundles = [];
|
|
944
|
+
|
|
945
|
+
for ( let i = 0; i < renderContextData.bundleEncoders.length; i ++ ) {
|
|
946
|
+
|
|
947
|
+
const bundleEncoder = renderContextData.bundleEncoders[ i ];
|
|
948
|
+
bundles.push( bundleEncoder.finish() );
|
|
949
|
+
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
for ( let i = 0; i < renderContextData.layerDescriptors.length; i ++ ) {
|
|
953
|
+
|
|
954
|
+
if ( i < bundles.length ) {
|
|
955
|
+
|
|
956
|
+
const layerDescriptor = renderContextData.layerDescriptors[ i ];
|
|
957
|
+
const renderPass = encoder.beginRenderPass( layerDescriptor );
|
|
958
|
+
|
|
959
|
+
if ( renderContext.viewport ) {
|
|
960
|
+
|
|
961
|
+
const { x, y, width, height, minDepth, maxDepth } = renderContext.viewportValue;
|
|
962
|
+
renderPass.setViewport( x, y, width, height, minDepth, maxDepth );
|
|
963
|
+
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
if ( renderContext.scissor ) {
|
|
967
|
+
|
|
968
|
+
const { x, y, width, height } = renderContext.scissorValue;
|
|
969
|
+
renderPass.setScissorRect( x, y, width, height );
|
|
970
|
+
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
renderPass.executeBundles( [ bundles[ i ] ] );
|
|
974
|
+
|
|
975
|
+
renderPass.end();
|
|
976
|
+
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
} else if ( renderContextData.currentPass ) {
|
|
982
|
+
|
|
983
|
+
renderContextData.currentPass.end();
|
|
984
|
+
|
|
985
|
+
}
|
|
700
986
|
|
|
701
987
|
if ( occlusionQueryCount > 0 ) {
|
|
702
988
|
|
|
@@ -950,7 +1236,7 @@ class WebGPUBackend extends Backend {
|
|
|
950
1236
|
|
|
951
1237
|
}
|
|
952
1238
|
|
|
953
|
-
if ( supportsDepth && depthStencilAttachment
|
|
1239
|
+
if ( supportsDepth && depthStencilAttachment ) {
|
|
954
1240
|
|
|
955
1241
|
if ( depth ) {
|
|
956
1242
|
|
|
@@ -969,7 +1255,7 @@ class WebGPUBackend extends Backend {
|
|
|
969
1255
|
|
|
970
1256
|
//
|
|
971
1257
|
|
|
972
|
-
if ( supportsStencil && depthStencilAttachment
|
|
1258
|
+
if ( supportsStencil && depthStencilAttachment ) {
|
|
973
1259
|
|
|
974
1260
|
if ( stencil ) {
|
|
975
1261
|
|
|
@@ -1012,7 +1298,6 @@ class WebGPUBackend extends Backend {
|
|
|
1012
1298
|
|
|
1013
1299
|
const groupGPU = this.get( computeGroup );
|
|
1014
1300
|
|
|
1015
|
-
|
|
1016
1301
|
const descriptor = {
|
|
1017
1302
|
label: 'computeGroup_' + computeGroup.id
|
|
1018
1303
|
};
|
|
@@ -1032,15 +1317,18 @@ class WebGPUBackend extends Backend {
|
|
|
1032
1317
|
* @param {Node} computeNode - The compute node.
|
|
1033
1318
|
* @param {Array<BindGroup>} bindings - The bindings.
|
|
1034
1319
|
* @param {ComputePipeline} pipeline - The compute pipeline.
|
|
1320
|
+
* @param {Array<number>|number} [dispatchSizeOrCount=null] - Array with [ x, y, z ] values for dispatch or a single number for the count.
|
|
1035
1321
|
*/
|
|
1036
|
-
compute( computeGroup, computeNode, bindings, pipeline ) {
|
|
1322
|
+
compute( computeGroup, computeNode, bindings, pipeline, dispatchSizeOrCount = null ) {
|
|
1037
1323
|
|
|
1324
|
+
const computeNodeData = this.get( computeNode );
|
|
1038
1325
|
const { passEncoderGPU } = this.get( computeGroup );
|
|
1039
1326
|
|
|
1040
1327
|
// pipeline
|
|
1041
1328
|
|
|
1042
1329
|
const pipelineGPU = this.get( pipeline ).pipeline;
|
|
1043
|
-
|
|
1330
|
+
|
|
1331
|
+
this.pipelineUtils.setPipeline( passEncoderGPU, pipelineGPU );
|
|
1044
1332
|
|
|
1045
1333
|
// bind groups
|
|
1046
1334
|
|
|
@@ -1053,29 +1341,67 @@ class WebGPUBackend extends Backend {
|
|
|
1053
1341
|
|
|
1054
1342
|
}
|
|
1055
1343
|
|
|
1056
|
-
|
|
1344
|
+
let dispatchSize;
|
|
1057
1345
|
|
|
1058
|
-
|
|
1346
|
+
if ( dispatchSizeOrCount === null ) {
|
|
1347
|
+
|
|
1348
|
+
dispatchSizeOrCount = computeNode.count;
|
|
1349
|
+
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
if ( typeof dispatchSizeOrCount === 'number' ) {
|
|
1353
|
+
|
|
1354
|
+
// If a single number is given, we calculate the dispatch size based on the workgroup size
|
|
1355
|
+
|
|
1356
|
+
const count = dispatchSizeOrCount;
|
|
1357
|
+
|
|
1358
|
+
if ( computeNodeData.dispatchSize === undefined || computeNodeData.count !== count ) {
|
|
1359
|
+
|
|
1360
|
+
// cache dispatch size to avoid recalculating it every time
|
|
1361
|
+
|
|
1362
|
+
computeNodeData.dispatchSize = [ 0, 1, 1 ];
|
|
1363
|
+
computeNodeData.count = count;
|
|
1364
|
+
|
|
1365
|
+
const workgroupSize = computeNode.workgroupSize;
|
|
1366
|
+
|
|
1367
|
+
let size = workgroupSize[ 0 ];
|
|
1368
|
+
|
|
1369
|
+
for ( let i = 1; i < workgroupSize.length; i ++ )
|
|
1370
|
+
size *= workgroupSize[ i ];
|
|
1371
|
+
|
|
1372
|
+
const dispatchCount = Math.ceil( count / size );
|
|
1373
|
+
|
|
1374
|
+
//
|
|
1375
|
+
|
|
1376
|
+
const maxComputeWorkgroupsPerDimension = this.device.limits.maxComputeWorkgroupsPerDimension;
|
|
1377
|
+
|
|
1378
|
+
dispatchSize = [ dispatchCount, 1, 1 ];
|
|
1379
|
+
|
|
1380
|
+
if ( dispatchCount > maxComputeWorkgroupsPerDimension ) {
|
|
1059
1381
|
|
|
1060
|
-
|
|
1382
|
+
dispatchSize[ 0 ] = Math.min( dispatchCount, maxComputeWorkgroupsPerDimension );
|
|
1383
|
+
dispatchSize[ 1 ] = Math.ceil( dispatchCount / maxComputeWorkgroupsPerDimension );
|
|
1061
1384
|
|
|
1062
|
-
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
computeNodeData.dispatchSize = dispatchSize;
|
|
1063
1388
|
|
|
1064
|
-
|
|
1389
|
+
}
|
|
1065
1390
|
|
|
1066
|
-
dispatchSize
|
|
1067
|
-
dispatchSize.y = Math.ceil( computeNode.dispatchCount / maxComputeWorkgroupsPerDimension );
|
|
1391
|
+
dispatchSize = computeNodeData.dispatchSize;
|
|
1068
1392
|
|
|
1069
1393
|
} else {
|
|
1070
1394
|
|
|
1071
|
-
dispatchSize
|
|
1395
|
+
dispatchSize = dispatchSizeOrCount;
|
|
1072
1396
|
|
|
1073
1397
|
}
|
|
1074
1398
|
|
|
1399
|
+
//
|
|
1400
|
+
|
|
1075
1401
|
passEncoderGPU.dispatchWorkgroups(
|
|
1076
|
-
dispatchSize
|
|
1077
|
-
dispatchSize
|
|
1078
|
-
dispatchSize
|
|
1402
|
+
dispatchSize[ 0 ],
|
|
1403
|
+
dispatchSize[ 1 ] || 1,
|
|
1404
|
+
dispatchSize[ 2 ] || 1
|
|
1079
1405
|
);
|
|
1080
1406
|
|
|
1081
1407
|
}
|
|
@@ -1123,123 +1449,89 @@ class WebGPUBackend extends Backend {
|
|
|
1123
1449
|
const bindings = renderObject.getBindings();
|
|
1124
1450
|
const renderContextData = this.get( context );
|
|
1125
1451
|
const pipelineGPU = this.get( pipeline ).pipeline;
|
|
1126
|
-
const currentSets = renderContextData.currentSets;
|
|
1127
|
-
const passEncoderGPU = renderContextData.currentPass;
|
|
1128
1452
|
|
|
1129
|
-
const
|
|
1453
|
+
const index = renderObject.getIndex();
|
|
1454
|
+
const hasIndex = ( index !== null );
|
|
1455
|
+
|
|
1130
1456
|
|
|
1457
|
+
const drawParams = renderObject.getDrawParameters();
|
|
1131
1458
|
if ( drawParams === null ) return;
|
|
1132
1459
|
|
|
1133
1460
|
// pipeline
|
|
1134
1461
|
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
passEncoderGPU.setPipeline( pipelineGPU );
|
|
1462
|
+
const setPipelineAndBindings = ( passEncoderGPU, currentSets ) => {
|
|
1138
1463
|
|
|
1464
|
+
// pipeline
|
|
1465
|
+
this.pipelineUtils.setPipeline( passEncoderGPU, pipelineGPU );
|
|
1139
1466
|
currentSets.pipeline = pipelineGPU;
|
|
1140
1467
|
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
const currentBindingGroups = currentSets.bindingGroups;
|
|
1146
|
-
|
|
1147
|
-
for ( let i = 0, l = bindings.length; i < l; i ++ ) {
|
|
1148
|
-
|
|
1149
|
-
const bindGroup = bindings[ i ];
|
|
1150
|
-
const bindingsData = this.get( bindGroup );
|
|
1151
|
-
|
|
1152
|
-
if ( currentBindingGroups[ bindGroup.index ] !== bindGroup.id ) {
|
|
1153
|
-
|
|
1154
|
-
passEncoderGPU.setBindGroup( bindGroup.index, bindingsData.group );
|
|
1155
|
-
currentBindingGroups[ bindGroup.index ] = bindGroup.id;
|
|
1156
|
-
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
// attributes
|
|
1468
|
+
// bind groups
|
|
1469
|
+
const currentBindingGroups = currentSets.bindingGroups;
|
|
1470
|
+
for ( let i = 0, l = bindings.length; i < l; i ++ ) {
|
|
1162
1471
|
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
// index
|
|
1168
|
-
|
|
1169
|
-
if ( hasIndex === true ) {
|
|
1472
|
+
const bindGroup = bindings[ i ];
|
|
1473
|
+
const bindingsData = this.get( bindGroup );
|
|
1474
|
+
if ( currentBindingGroups[ bindGroup.index ] !== bindGroup.id ) {
|
|
1170
1475
|
|
|
1171
|
-
|
|
1476
|
+
passEncoderGPU.setBindGroup( bindGroup.index, bindingsData.group );
|
|
1477
|
+
currentBindingGroups[ bindGroup.index ] = bindGroup.id;
|
|
1172
1478
|
|
|
1173
|
-
|
|
1174
|
-
const indexFormat = ( index.array instanceof Uint16Array ) ? GPUIndexFormat.Uint16 : GPUIndexFormat.Uint32;
|
|
1175
|
-
|
|
1176
|
-
passEncoderGPU.setIndexBuffer( buffer, indexFormat );
|
|
1177
|
-
|
|
1178
|
-
currentSets.index = index;
|
|
1479
|
+
}
|
|
1179
1480
|
|
|
1180
1481
|
}
|
|
1181
1482
|
|
|
1182
|
-
|
|
1483
|
+
// attributes
|
|
1183
1484
|
|
|
1184
|
-
|
|
1485
|
+
// index
|
|
1185
1486
|
|
|
1186
|
-
|
|
1487
|
+
if ( hasIndex === true ) {
|
|
1187
1488
|
|
|
1188
|
-
|
|
1489
|
+
if ( currentSets.index !== index ) {
|
|
1189
1490
|
|
|
1190
|
-
|
|
1491
|
+
const buffer = this.get( index ).buffer;
|
|
1492
|
+
const indexFormat = ( index.array instanceof Uint16Array ) ? GPUIndexFormat.Uint16 : GPUIndexFormat.Uint32;
|
|
1191
1493
|
|
|
1192
|
-
|
|
1494
|
+
passEncoderGPU.setIndexBuffer( buffer, indexFormat );
|
|
1193
1495
|
|
|
1194
|
-
|
|
1195
|
-
passEncoderGPU.setVertexBuffer( i, buffer );
|
|
1496
|
+
currentSets.index = index;
|
|
1196
1497
|
|
|
1197
|
-
|
|
1498
|
+
}
|
|
1198
1499
|
|
|
1199
1500
|
}
|
|
1501
|
+
// vertex buffers
|
|
1200
1502
|
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
// occlusion queries - handle multiple consecutive draw calls for an object
|
|
1503
|
+
const vertexBuffers = renderObject.getVertexBuffers();
|
|
1204
1504
|
|
|
1205
|
-
|
|
1505
|
+
for ( let i = 0, l = vertexBuffers.length; i < l; i ++ ) {
|
|
1206
1506
|
|
|
1207
|
-
|
|
1507
|
+
const vertexBuffer = vertexBuffers[ i ];
|
|
1208
1508
|
|
|
1209
|
-
|
|
1509
|
+
if ( currentSets.attributes[ i ] !== vertexBuffer ) {
|
|
1210
1510
|
|
|
1211
|
-
|
|
1511
|
+
const buffer = this.get( vertexBuffer ).buffer;
|
|
1512
|
+
passEncoderGPU.setVertexBuffer( i, buffer );
|
|
1212
1513
|
|
|
1213
|
-
|
|
1214
|
-
renderContextData.occlusionQueryIndex ++;
|
|
1514
|
+
currentSets.attributes[ i ] = vertexBuffer;
|
|
1215
1515
|
|
|
1216
1516
|
}
|
|
1217
1517
|
|
|
1218
|
-
if ( object.occlusionTest === true ) {
|
|
1219
|
-
|
|
1220
|
-
passEncoderGPU.beginOcclusionQuery( renderContextData.occlusionQueryIndex );
|
|
1221
|
-
renderContextData.occlusionQueryObjects[ renderContextData.occlusionQueryIndex ] = object;
|
|
1222
|
-
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
renderContextData.lastOcclusionObject = object;
|
|
1226
|
-
|
|
1227
1518
|
}
|
|
1519
|
+
// stencil
|
|
1228
1520
|
|
|
1229
|
-
|
|
1521
|
+
if ( context.stencil === true && material.stencilWrite === true && renderContextData.currentStencilRef !== material.stencilRef ) {
|
|
1230
1522
|
|
|
1231
|
-
|
|
1523
|
+
passEncoderGPU.setStencilReference( material.stencilRef );
|
|
1524
|
+
renderContextData.currentStencilRef = material.stencilRef;
|
|
1232
1525
|
|
|
1233
|
-
|
|
1526
|
+
}
|
|
1234
1527
|
|
|
1235
|
-
passEncoderGPU.setStencilReference( material.stencilRef );
|
|
1236
|
-
renderContextData.currentStencilRef = material.stencilRef;
|
|
1237
1528
|
|
|
1238
|
-
}
|
|
1529
|
+
};
|
|
1239
1530
|
|
|
1240
|
-
// draw
|
|
1531
|
+
// Define draw function
|
|
1532
|
+
const draw = ( passEncoderGPU, currentSets ) => {
|
|
1241
1533
|
|
|
1242
|
-
|
|
1534
|
+
setPipelineAndBindings( passEncoderGPU, currentSets );
|
|
1243
1535
|
|
|
1244
1536
|
if ( object.isBatchedMesh === true ) {
|
|
1245
1537
|
|
|
@@ -1355,18 +1647,45 @@ class WebGPUBackend extends Backend {
|
|
|
1355
1647
|
|
|
1356
1648
|
const vp = subCamera.viewport;
|
|
1357
1649
|
|
|
1358
|
-
passEncoderGPU.setViewport(
|
|
1359
|
-
Math.floor( vp.x * pixelRatio ),
|
|
1360
|
-
Math.floor( vp.y * pixelRatio ),
|
|
1361
|
-
Math.floor( vp.width * pixelRatio ),
|
|
1362
|
-
Math.floor( vp.height * pixelRatio ),
|
|
1363
|
-
context.viewportValue.minDepth,
|
|
1364
|
-
context.viewportValue.maxDepth
|
|
1365
|
-
);
|
|
1366
1650
|
|
|
1367
|
-
passEncoderGPU.setBindGroup( cameraIndex.index, cameraData.indexesGPU[ i ] );
|
|
1368
1651
|
|
|
1369
|
-
|
|
1652
|
+
let pass = renderContextData.currentPass;
|
|
1653
|
+
let sets = renderContextData.currentSets;
|
|
1654
|
+
if ( renderContextData.bundleEncoders ) {
|
|
1655
|
+
|
|
1656
|
+
const bundleEncoder = renderContextData.bundleEncoders[ i ];
|
|
1657
|
+
const bundleSets = renderContextData.bundleSets[ i ];
|
|
1658
|
+
pass = bundleEncoder;
|
|
1659
|
+
sets = bundleSets;
|
|
1660
|
+
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
|
|
1664
|
+
|
|
1665
|
+
if ( vp ) {
|
|
1666
|
+
|
|
1667
|
+
pass.setViewport(
|
|
1668
|
+
Math.floor( vp.x * pixelRatio ),
|
|
1669
|
+
Math.floor( vp.y * pixelRatio ),
|
|
1670
|
+
Math.floor( vp.width * pixelRatio ),
|
|
1671
|
+
Math.floor( vp.height * pixelRatio ),
|
|
1672
|
+
context.viewportValue.minDepth,
|
|
1673
|
+
context.viewportValue.maxDepth
|
|
1674
|
+
);
|
|
1675
|
+
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
|
|
1679
|
+
// Set camera index binding for this layer
|
|
1680
|
+
if ( cameraIndex && cameraData.indexesGPU ) {
|
|
1681
|
+
|
|
1682
|
+
pass.setBindGroup( cameraIndex.index, cameraData.indexesGPU[ i ] );
|
|
1683
|
+
sets.bindingGroups[ cameraIndex.index ] = cameraIndex.id;
|
|
1684
|
+
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
draw( pass, sets );
|
|
1688
|
+
|
|
1370
1689
|
|
|
1371
1690
|
}
|
|
1372
1691
|
|
|
@@ -1374,7 +1693,38 @@ class WebGPUBackend extends Backend {
|
|
|
1374
1693
|
|
|
1375
1694
|
} else {
|
|
1376
1695
|
|
|
1377
|
-
|
|
1696
|
+
// Regular single camera rendering
|
|
1697
|
+
if ( renderContextData.currentPass ) {
|
|
1698
|
+
|
|
1699
|
+
// Handle occlusion queries
|
|
1700
|
+
if ( renderContextData.occlusionQuerySet !== undefined ) {
|
|
1701
|
+
|
|
1702
|
+
const lastObject = renderContextData.lastOcclusionObject;
|
|
1703
|
+
if ( lastObject !== object ) {
|
|
1704
|
+
|
|
1705
|
+
if ( lastObject !== null && lastObject.occlusionTest === true ) {
|
|
1706
|
+
|
|
1707
|
+
renderContextData.currentPass.endOcclusionQuery();
|
|
1708
|
+
renderContextData.occlusionQueryIndex ++;
|
|
1709
|
+
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
if ( object.occlusionTest === true ) {
|
|
1713
|
+
|
|
1714
|
+
renderContextData.currentPass.beginOcclusionQuery( renderContextData.occlusionQueryIndex );
|
|
1715
|
+
renderContextData.occlusionQueryObjects[ renderContextData.occlusionQueryIndex ] = object;
|
|
1716
|
+
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
renderContextData.lastOcclusionObject = object;
|
|
1720
|
+
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
draw( renderContextData.currentPass, renderContextData.currentSets );
|
|
1726
|
+
|
|
1727
|
+
}
|
|
1378
1728
|
|
|
1379
1729
|
}
|
|
1380
1730
|
|
|
@@ -1781,7 +2131,15 @@ class WebGPUBackend extends Backend {
|
|
|
1781
2131
|
*/
|
|
1782
2132
|
createIndexAttribute( attribute ) {
|
|
1783
2133
|
|
|
1784
|
-
|
|
2134
|
+
let usage = GPUBufferUsage.INDEX | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST;
|
|
2135
|
+
|
|
2136
|
+
if ( attribute.isStorageBufferAttribute || attribute.isStorageInstancedBufferAttribute ) {
|
|
2137
|
+
|
|
2138
|
+
usage |= GPUBufferUsage.STORAGE;
|
|
2139
|
+
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2142
|
+
this.attributeUtils.createAttribute( attribute, usage );
|
|
1785
2143
|
|
|
1786
2144
|
}
|
|
1787
2145
|
|
|
@@ -2045,8 +2403,6 @@ class WebGPUBackend extends Backend {
|
|
|
2045
2403
|
]
|
|
2046
2404
|
);
|
|
2047
2405
|
|
|
2048
|
-
if ( texture.generateMipmaps ) this.textureUtils.generateMipmaps( texture );
|
|
2049
|
-
|
|
2050
2406
|
if ( renderContextData.currentPass ) {
|
|
2051
2407
|
|
|
2052
2408
|
const { descriptor } = renderContextData;
|
|
@@ -2083,6 +2439,12 @@ class WebGPUBackend extends Backend {
|
|
|
2083
2439
|
|
|
2084
2440
|
}
|
|
2085
2441
|
|
|
2442
|
+
if ( texture.generateMipmaps ) {
|
|
2443
|
+
|
|
2444
|
+
this.textureUtils.generateMipmaps( texture );
|
|
2445
|
+
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2086
2448
|
}
|
|
2087
2449
|
|
|
2088
2450
|
}
|