@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
|
@@ -37,6 +37,7 @@ class WebGPURenderer extends Renderer {
|
|
|
37
37
|
* @property {boolean} [antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not.
|
|
38
38
|
* @property {number} [samples=0] - When `antialias` is `true`, `4` samples are used by default. Set this parameter to any other integer value than 0 to overwrite the default.
|
|
39
39
|
* @property {boolean} [forceWebGL=false] - If set to `true`, the renderer uses a WebGL 2 backend no matter if WebGPU is supported or not.
|
|
40
|
+
* @property {boolean} [multiview=false] - If set to `true`, the renderer will use multiview during WebXR rendering if supported.
|
|
40
41
|
* @property {number} [outputType=undefined] - Texture type for output to canvas. By default, device's preferred format is used; other formats may incur overhead.
|
|
41
42
|
* @property {number} [colorBufferType=HalfFloatType] - Defines the type of color buffers. The default `HalfFloatType` is recommend for best
|
|
42
43
|
* quality. To save memory and bandwidth, `UnsignedByteType` might be used. This will reduce rendering quality though.
|
|
@@ -91,6 +92,12 @@ class WebGPURenderer extends Renderer {
|
|
|
91
92
|
*/
|
|
92
93
|
this.isWebGPURenderer = true;
|
|
93
94
|
|
|
95
|
+
if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
|
|
96
|
+
|
|
97
|
+
__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) );
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
94
101
|
}
|
|
95
102
|
|
|
96
103
|
}
|
|
@@ -9,6 +9,7 @@ import { AmbientLight } from '../../../lights/AmbientLight.js';
|
|
|
9
9
|
import { HemisphereLight } from '../../../lights/HemisphereLight.js';
|
|
10
10
|
import { LightProbe } from '../../../lights/LightProbe.js';
|
|
11
11
|
import IESSpotLight from '../../../lights/webgpu/IESSpotLight.js';
|
|
12
|
+
import ProjectorLight from '../../../lights/webgpu/ProjectorLight.js';
|
|
12
13
|
import {
|
|
13
14
|
PointLightNode,
|
|
14
15
|
DirectionalLightNode,
|
|
@@ -17,7 +18,8 @@ import {
|
|
|
17
18
|
AmbientLightNode,
|
|
18
19
|
HemisphereLightNode,
|
|
19
20
|
LightProbeNode,
|
|
20
|
-
IESSpotLightNode
|
|
21
|
+
IESSpotLightNode,
|
|
22
|
+
ProjectorLightNode
|
|
21
23
|
} from '../../../nodes/Nodes.js';
|
|
22
24
|
|
|
23
25
|
// Tone Mapping
|
|
@@ -48,6 +50,7 @@ class BasicNodeLibrary extends NodeLibrary {
|
|
|
48
50
|
this.addLight( HemisphereLightNode, HemisphereLight );
|
|
49
51
|
this.addLight( LightProbeNode, LightProbe );
|
|
50
52
|
this.addLight( IESSpotLightNode, IESSpotLight );
|
|
53
|
+
this.addLight( ProjectorLightNode, ProjectorLight );
|
|
51
54
|
|
|
52
55
|
this.addToneMapping( linearToneMapping, LinearToneMapping );
|
|
53
56
|
this.addToneMapping( reinhardToneMapping, ReinhardToneMapping );
|
|
@@ -28,6 +28,7 @@ import { AmbientLight } from '../../../lights/AmbientLight.js';
|
|
|
28
28
|
import { HemisphereLight } from '../../../lights/HemisphereLight.js';
|
|
29
29
|
import { LightProbe } from '../../../lights/LightProbe.js';
|
|
30
30
|
import IESSpotLight from '../../../lights/webgpu/IESSpotLight.js';
|
|
31
|
+
import ProjectorLight from '../../../lights/webgpu/ProjectorLight.js';
|
|
31
32
|
import {
|
|
32
33
|
PointLightNode,
|
|
33
34
|
DirectionalLightNode,
|
|
@@ -36,7 +37,8 @@ import {
|
|
|
36
37
|
AmbientLightNode,
|
|
37
38
|
HemisphereLightNode,
|
|
38
39
|
LightProbeNode,
|
|
39
|
-
IESSpotLightNode
|
|
40
|
+
IESSpotLightNode,
|
|
41
|
+
ProjectorLightNode
|
|
40
42
|
} from '../../../nodes/Nodes.js';
|
|
41
43
|
|
|
42
44
|
// Tone Mapping
|
|
@@ -82,6 +84,7 @@ class StandardNodeLibrary extends NodeLibrary {
|
|
|
82
84
|
this.addLight( HemisphereLightNode, HemisphereLight );
|
|
83
85
|
this.addLight( LightProbeNode, LightProbe );
|
|
84
86
|
this.addLight( IESSpotLightNode, IESSpotLight );
|
|
87
|
+
this.addLight( ProjectorLightNode, ProjectorLight );
|
|
85
88
|
|
|
86
89
|
this.addToneMapping( linearToneMapping, LinearToneMapping );
|
|
87
90
|
this.addToneMapping( reinhardToneMapping, ReinhardToneMapping );
|
|
@@ -16,7 +16,7 @@ import { NodeAccess } from '../../../nodes/core/constants.js';
|
|
|
16
16
|
import VarNode from '../../../nodes/core/VarNode.js';
|
|
17
17
|
import ExpressionNode from '../../../nodes/code/ExpressionNode.js';
|
|
18
18
|
|
|
19
|
-
import {
|
|
19
|
+
import { FloatType, RepeatWrapping, ClampToEdgeWrapping, MirroredRepeatWrapping, NearestFilter } from '../../../constants.js';
|
|
20
20
|
|
|
21
21
|
// GPUShaderStage is not defined in browsers not supporting WebGPU
|
|
22
22
|
const GPUShaderStage = ( typeof self !== 'undefined' ) ? self.GPUShaderStage : { VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 };
|
|
@@ -211,18 +211,6 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
211
211
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
/**
|
|
215
|
-
* Checks if the given texture requires a manual conversion to the working color space.
|
|
216
|
-
*
|
|
217
|
-
* @param {Texture} texture - The texture to check.
|
|
218
|
-
* @return {boolean} Whether the given texture requires a conversion to working color space or not.
|
|
219
|
-
*/
|
|
220
|
-
needsToWorkingColorSpace( texture ) {
|
|
221
|
-
|
|
222
|
-
return texture.isVideoTexture === true && texture.colorSpace !== NoColorSpace;
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
226
214
|
/**
|
|
227
215
|
* Generates the WGSL snippet for sampled textures.
|
|
228
216
|
*
|
|
@@ -248,36 +236,9 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
248
236
|
|
|
249
237
|
}
|
|
250
238
|
|
|
251
|
-
} else if ( this.isFilteredTexture( texture ) ) {
|
|
252
|
-
|
|
253
|
-
return this.generateFilteredTexture( texture, textureProperty, uvSnippet );
|
|
254
|
-
|
|
255
239
|
} else {
|
|
256
240
|
|
|
257
|
-
return this.
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Generates the WGSL snippet when sampling video textures.
|
|
265
|
-
*
|
|
266
|
-
* @private
|
|
267
|
-
* @param {string} textureProperty - The name of the video texture uniform in the shader.
|
|
268
|
-
* @param {string} uvSnippet - A WGSL snippet that represents texture coordinates used for sampling.
|
|
269
|
-
* @param {string} [shaderStage=this.shaderStage] - The shader stage this code snippet is generated for.
|
|
270
|
-
* @return {string} The WGSL snippet.
|
|
271
|
-
*/
|
|
272
|
-
_generateVideoSample( textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
|
|
273
|
-
|
|
274
|
-
if ( shaderStage === 'fragment' ) {
|
|
275
|
-
|
|
276
|
-
return `textureSampleBaseClampToEdge( ${ textureProperty }, ${ textureProperty }_sampler, vec2<f32>( ${ uvSnippet }.x, 1.0 - ${ uvSnippet }.y ) )`;
|
|
277
|
-
|
|
278
|
-
} else {
|
|
279
|
-
|
|
280
|
-
console.error( `WebGPURenderer: THREE.VideoTexture does not support ${ shaderStage } shader.` );
|
|
241
|
+
return this.generateTextureSampleLevel( texture, textureProperty, uvSnippet, '0', depthSnippet );
|
|
281
242
|
|
|
282
243
|
}
|
|
283
244
|
|
|
@@ -291,13 +252,12 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
291
252
|
* @param {string} textureProperty - The name of the texture uniform in the shader.
|
|
292
253
|
* @param {string} uvSnippet - A WGSL snippet that represents texture coordinates used for sampling.
|
|
293
254
|
* @param {string} levelSnippet - A WGSL snippet that represents the mip level, with level 0 containing a full size version of the texture.
|
|
294
|
-
* @param {
|
|
295
|
-
* @param {string} [shaderStage=this.shaderStage] - The shader stage this code snippet is generated for.
|
|
255
|
+
* @param {string} depthSnippet - A WGSL snippet that represents 0-based texture array index to sample.
|
|
296
256
|
* @return {string} The WGSL snippet.
|
|
297
257
|
*/
|
|
298
|
-
|
|
258
|
+
generateTextureSampleLevel( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet ) {
|
|
299
259
|
|
|
300
|
-
if (
|
|
260
|
+
if ( this.isUnfilterable( texture ) === false ) {
|
|
301
261
|
|
|
302
262
|
return `textureSampleLevel( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ levelSnippet } )`;
|
|
303
263
|
|
|
@@ -439,7 +399,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
439
399
|
}
|
|
440
400
|
|
|
441
401
|
// Build parameters string based on texture type and multisampling
|
|
442
|
-
if ( isMultisampled || texture.
|
|
402
|
+
if ( isMultisampled || texture.isStorageTexture ) {
|
|
443
403
|
|
|
444
404
|
textureDimensionsParams = textureProperty;
|
|
445
405
|
|
|
@@ -453,7 +413,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
453
413
|
|
|
454
414
|
textureData.dimensionsSnippet[ levelSnippet ] = textureDimensionNode;
|
|
455
415
|
|
|
456
|
-
if ( texture.isDataArrayTexture || texture.isData3DTexture ) {
|
|
416
|
+
if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.isData3DTexture ) {
|
|
457
417
|
|
|
458
418
|
textureData.arrayLayerCount = new VarNode(
|
|
459
419
|
new ExpressionNode(
|
|
@@ -516,7 +476,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
516
476
|
const textureDimension = this.generateTextureDimension( texture, textureProperty, levelSnippet );
|
|
517
477
|
|
|
518
478
|
const vecType = texture.isData3DTexture ? 'vec3' : 'vec2';
|
|
519
|
-
const coordSnippet = `${ vecType }<u32>(${ wrapFunction }(${ uvSnippet }) * ${ vecType }<f32>(${ textureDimension }))`;
|
|
479
|
+
const coordSnippet = `${ vecType }<u32>( ${ wrapFunction }( ${ uvSnippet } ) * ${ vecType }<f32>( ${ textureDimension } ) )`;
|
|
520
480
|
|
|
521
481
|
return this.generateTextureLoad( texture, textureProperty, coordSnippet, depthSnippet, levelSnippet );
|
|
522
482
|
|
|
@@ -534,20 +494,26 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
534
494
|
*/
|
|
535
495
|
generateTextureLoad( texture, textureProperty, uvIndexSnippet, depthSnippet, levelSnippet = '0u' ) {
|
|
536
496
|
|
|
537
|
-
|
|
497
|
+
let snippet;
|
|
538
498
|
|
|
539
|
-
|
|
499
|
+
if ( depthSnippet ) {
|
|
540
500
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
return `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet }, u32( ${ levelSnippet } ) )`;
|
|
501
|
+
snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet }, u32( ${ levelSnippet } ) )`;
|
|
544
502
|
|
|
545
503
|
} else {
|
|
546
504
|
|
|
547
|
-
|
|
505
|
+
snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, u32( ${ levelSnippet } ) )`;
|
|
506
|
+
|
|
507
|
+
if ( this.renderer.backend.compatibilityMode && texture.isDepthTexture ) {
|
|
508
|
+
|
|
509
|
+
snippet += '.x';
|
|
510
|
+
|
|
511
|
+
}
|
|
548
512
|
|
|
549
513
|
}
|
|
550
514
|
|
|
515
|
+
return snippet;
|
|
516
|
+
|
|
551
517
|
}
|
|
552
518
|
|
|
553
519
|
/**
|
|
@@ -556,12 +522,25 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
556
522
|
* @param {Texture} texture - The texture.
|
|
557
523
|
* @param {string} textureProperty - The name of the texture uniform in the shader.
|
|
558
524
|
* @param {string} uvIndexSnippet - A WGSL snippet that represents texture coordinates used for sampling.
|
|
525
|
+
* @param {?string} depthSnippet - A WGSL snippet that represents 0-based texture array index to sample.
|
|
559
526
|
* @param {string} valueSnippet - A WGSL snippet that represent the new texel value.
|
|
560
527
|
* @return {string} The WGSL snippet.
|
|
561
528
|
*/
|
|
562
|
-
generateTextureStore( texture, textureProperty, uvIndexSnippet, valueSnippet ) {
|
|
529
|
+
generateTextureStore( texture, textureProperty, uvIndexSnippet, depthSnippet, valueSnippet ) {
|
|
530
|
+
|
|
531
|
+
let snippet;
|
|
563
532
|
|
|
564
|
-
|
|
533
|
+
if ( depthSnippet ) {
|
|
534
|
+
|
|
535
|
+
snippet = `textureStore( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet }, ${ valueSnippet } )`;
|
|
536
|
+
|
|
537
|
+
} else {
|
|
538
|
+
|
|
539
|
+
snippet = `textureStore( ${ textureProperty }, ${ uvIndexSnippet }, ${ valueSnippet } )`;
|
|
540
|
+
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
return snippet;
|
|
565
544
|
|
|
566
545
|
}
|
|
567
546
|
|
|
@@ -606,11 +585,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
606
585
|
|
|
607
586
|
let snippet = null;
|
|
608
587
|
|
|
609
|
-
if (
|
|
610
|
-
|
|
611
|
-
snippet = this._generateVideoSample( textureProperty, uvSnippet, shaderStage );
|
|
612
|
-
|
|
613
|
-
} else if ( this.isUnfilterable( texture ) ) {
|
|
588
|
+
if ( this.isUnfilterable( texture ) ) {
|
|
614
589
|
|
|
615
590
|
snippet = this.generateTextureLod( texture, textureProperty, uvSnippet, depthSnippet, '0', shaderStage );
|
|
616
591
|
|
|
@@ -666,6 +641,12 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
666
641
|
|
|
667
642
|
if ( shaderStage === 'fragment' ) {
|
|
668
643
|
|
|
644
|
+
if ( texture.isDepthTexture === true && texture.isArrayTexture === true ) {
|
|
645
|
+
|
|
646
|
+
return `textureSampleCompare( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ depthSnippet }, ${ compareSnippet } )`;
|
|
647
|
+
|
|
648
|
+
}
|
|
649
|
+
|
|
669
650
|
return `textureSampleCompare( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ compareSnippet } )`;
|
|
670
651
|
|
|
671
652
|
} else {
|
|
@@ -687,22 +668,22 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
687
668
|
* @param {string} [shaderStage=this.shaderStage] - The shader stage this code snippet is generated for.
|
|
688
669
|
* @return {string} The WGSL snippet.
|
|
689
670
|
*/
|
|
690
|
-
generateTextureLevel( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet
|
|
671
|
+
generateTextureLevel( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet ) {
|
|
691
672
|
|
|
692
|
-
|
|
673
|
+
if ( this.isUnfilterable( texture ) === false ) {
|
|
693
674
|
|
|
694
|
-
|
|
675
|
+
return `textureSampleLevel( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ levelSnippet } )`;
|
|
695
676
|
|
|
696
|
-
|
|
677
|
+
} else if ( this.isFilteredTexture( texture ) ) {
|
|
678
|
+
|
|
679
|
+
return this.generateFilteredTexture( texture, textureProperty, uvSnippet, levelSnippet );
|
|
697
680
|
|
|
698
681
|
} else {
|
|
699
682
|
|
|
700
|
-
|
|
683
|
+
return this.generateTextureLod( texture, textureProperty, uvSnippet, depthSnippet, levelSnippet );
|
|
701
684
|
|
|
702
685
|
}
|
|
703
686
|
|
|
704
|
-
return snippet;
|
|
705
|
-
|
|
706
687
|
}
|
|
707
688
|
|
|
708
689
|
/**
|
|
@@ -820,9 +801,20 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
820
801
|
*/
|
|
821
802
|
getNodeAccess( node, shaderStage ) {
|
|
822
803
|
|
|
823
|
-
if ( shaderStage !== 'compute' )
|
|
804
|
+
if ( shaderStage !== 'compute' ) {
|
|
805
|
+
|
|
806
|
+
if ( node.isAtomic === true ) {
|
|
807
|
+
|
|
808
|
+
console.warn( 'WebGPURenderer: Atomic operations are only supported in compute shaders.' );
|
|
809
|
+
|
|
810
|
+
return NodeAccess.READ_WRITE;
|
|
811
|
+
|
|
812
|
+
}
|
|
813
|
+
|
|
824
814
|
return NodeAccess.READ_ONLY;
|
|
825
815
|
|
|
816
|
+
}
|
|
817
|
+
|
|
826
818
|
return node.access;
|
|
827
819
|
|
|
828
820
|
}
|
|
@@ -875,7 +867,15 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
875
867
|
|
|
876
868
|
if ( type === 'texture' || type === 'storageTexture' ) {
|
|
877
869
|
|
|
878
|
-
|
|
870
|
+
if ( node.value.is3DTexture === true ) {
|
|
871
|
+
|
|
872
|
+
texture = new NodeSampledTexture3D( uniformNode.name, uniformNode.node, group, access );
|
|
873
|
+
|
|
874
|
+
} else {
|
|
875
|
+
|
|
876
|
+
texture = new NodeSampledTexture( uniformNode.name, uniformNode.node, group, access );
|
|
877
|
+
|
|
878
|
+
}
|
|
879
879
|
|
|
880
880
|
} else if ( type === 'cubeTexture' ) {
|
|
881
881
|
|
|
@@ -890,7 +890,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
890
890
|
texture.store = node.isStorageTextureNode === true;
|
|
891
891
|
texture.setVisibility( gpuShaderStageLib[ shaderStage ] );
|
|
892
892
|
|
|
893
|
-
if (
|
|
893
|
+
if ( this.isUnfilterable( node.value ) === false && texture.store === false ) {
|
|
894
894
|
|
|
895
895
|
const sampler = new NodeSampler( `${ uniformNode.name }_sampler`, uniformNode.node, group );
|
|
896
896
|
sampler.setVisibility( gpuShaderStageLib[ shaderStage ] );
|
|
@@ -1560,10 +1560,17 @@ ${ flowData.code }
|
|
|
1560
1560
|
|
|
1561
1561
|
let attributesSnippet = `@location( ${index} )`;
|
|
1562
1562
|
|
|
1563
|
-
if (
|
|
1563
|
+
if ( varying.interpolationType ) {
|
|
1564
|
+
|
|
1565
|
+
const samplingSnippet = varying.interpolationSampling !== null ? `, ${ varying.interpolationSampling } )` : ' )';
|
|
1566
|
+
|
|
1567
|
+
attributesSnippet += ` @interpolate( ${ varying.interpolationType }${ samplingSnippet }`;
|
|
1568
|
+
|
|
1569
|
+
// Otherwise, optimize interpolation when sensible
|
|
1564
1570
|
|
|
1565
|
-
|
|
1571
|
+
} else if ( /^(int|uint|ivec|uvec)/.test( varying.type ) ) {
|
|
1566
1572
|
|
|
1573
|
+
attributesSnippet += ` @interpolate( ${ this.renderer.backend.compatibilityMode ? 'flat, either' : 'flat' } )`;
|
|
1567
1574
|
|
|
1568
1575
|
}
|
|
1569
1576
|
|
|
@@ -1591,7 +1598,16 @@ ${ flowData.code }
|
|
|
1591
1598
|
|
|
1592
1599
|
isCustomStruct( nodeUniform ) {
|
|
1593
1600
|
|
|
1594
|
-
|
|
1601
|
+
const attribute = nodeUniform.value;
|
|
1602
|
+
const bufferNode = nodeUniform.node;
|
|
1603
|
+
|
|
1604
|
+
const isAttributeStructType = ( attribute.isBufferAttribute || attribute.isInstancedBufferAttribute ) && bufferNode.structTypeNode !== null;
|
|
1605
|
+
|
|
1606
|
+
const isStructArray =
|
|
1607
|
+
( bufferNode.value && bufferNode.value.array ) &&
|
|
1608
|
+
( typeof bufferNode.value.itemSize === 'number' && bufferNode.value.array.length > bufferNode.value.itemSize );
|
|
1609
|
+
|
|
1610
|
+
return isAttributeStructType && ! isStructArray;
|
|
1595
1611
|
|
|
1596
1612
|
}
|
|
1597
1613
|
|
|
@@ -1619,7 +1635,7 @@ ${ flowData.code }
|
|
|
1619
1635
|
|
|
1620
1636
|
const texture = uniform.node.value;
|
|
1621
1637
|
|
|
1622
|
-
if (
|
|
1638
|
+
if ( this.isUnfilterable( texture ) === false && uniform.node.isStorageTextureNode !== true ) {
|
|
1623
1639
|
|
|
1624
1640
|
if ( this.isSampleCompare( texture ) ) {
|
|
1625
1641
|
|
|
@@ -1649,28 +1665,37 @@ ${ flowData.code }
|
|
|
1649
1665
|
|
|
1650
1666
|
textureType = 'texture_cube<f32>';
|
|
1651
1667
|
|
|
1652
|
-
} else if ( texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true ) {
|
|
1653
|
-
|
|
1654
|
-
textureType = 'texture_2d_array<f32>';
|
|
1655
|
-
|
|
1656
1668
|
} else if ( texture.isDepthTexture === true ) {
|
|
1657
1669
|
|
|
1658
|
-
|
|
1670
|
+
if ( this.renderer.backend.compatibilityMode && texture.compareFunction === null ) {
|
|
1659
1671
|
|
|
1660
|
-
|
|
1672
|
+
textureType = `texture${ multisampled }_2d<f32>`;
|
|
1661
1673
|
|
|
1662
|
-
|
|
1674
|
+
} else {
|
|
1663
1675
|
|
|
1664
|
-
|
|
1676
|
+
textureType = `texture_depth${ multisampled }_2d${ texture.isArrayTexture === true ? '_array' : '' }`;
|
|
1665
1677
|
|
|
1666
|
-
|
|
1678
|
+
}
|
|
1667
1679
|
|
|
1668
1680
|
} else if ( uniform.node.isStorageTextureNode === true ) {
|
|
1669
1681
|
|
|
1670
1682
|
const format = getFormat( texture );
|
|
1671
1683
|
const access = this.getStorageAccess( uniform.node, shaderStage );
|
|
1672
1684
|
|
|
1673
|
-
|
|
1685
|
+
const is3D = uniform.node.value.is3DTexture;
|
|
1686
|
+
const isArrayTexture = uniform.node.value.isArrayTexture;
|
|
1687
|
+
|
|
1688
|
+
const dimension = is3D ? '3d' : `2d${ isArrayTexture ? '_array' : '' }`;
|
|
1689
|
+
|
|
1690
|
+
textureType = `texture_storage_${ dimension }<${ format }, ${ access }>`;
|
|
1691
|
+
|
|
1692
|
+
} else if ( texture.isArrayTexture === true || texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true ) {
|
|
1693
|
+
|
|
1694
|
+
textureType = 'texture_2d_array<f32>';
|
|
1695
|
+
|
|
1696
|
+
} else if ( texture.is3DTexture === true || texture.isData3DTexture === true ) {
|
|
1697
|
+
|
|
1698
|
+
textureType = 'texture_3d<f32>';
|
|
1674
1699
|
|
|
1675
1700
|
} else {
|
|
1676
1701
|
|
|
@@ -1837,7 +1862,11 @@ ${ flowData.code }
|
|
|
1837
1862
|
|
|
1838
1863
|
} else {
|
|
1839
1864
|
|
|
1840
|
-
|
|
1865
|
+
// Early strictly validated in computeNode
|
|
1866
|
+
|
|
1867
|
+
const workgroupSize = this.object.workgroupSize;
|
|
1868
|
+
|
|
1869
|
+
this.computeShader = this._getWGSLComputeCode( shadersData.compute, workgroupSize );
|
|
1841
1870
|
|
|
1842
1871
|
}
|
|
1843
1872
|
|
|
@@ -2042,36 +2071,40 @@ fn main( ${shaderData.varyings} ) -> ${shaderData.returnType} {
|
|
|
2042
2071
|
*/
|
|
2043
2072
|
_getWGSLComputeCode( shaderData, workgroupSize ) {
|
|
2044
2073
|
|
|
2074
|
+
const [ workgroupSizeX, workgroupSizeY, workgroupSizeZ ] = workgroupSize;
|
|
2075
|
+
|
|
2045
2076
|
return `${ this.getSignature() }
|
|
2046
2077
|
// directives
|
|
2047
|
-
${shaderData.directives}
|
|
2078
|
+
${ shaderData.directives }
|
|
2048
2079
|
|
|
2049
2080
|
// system
|
|
2050
2081
|
var<private> instanceIndex : u32;
|
|
2051
2082
|
|
|
2052
2083
|
// locals
|
|
2053
|
-
${shaderData.scopedArrays}
|
|
2084
|
+
${ shaderData.scopedArrays }
|
|
2054
2085
|
|
|
2055
2086
|
// structs
|
|
2056
|
-
${shaderData.structs}
|
|
2087
|
+
${ shaderData.structs }
|
|
2057
2088
|
|
|
2058
2089
|
// uniforms
|
|
2059
|
-
${shaderData.uniforms}
|
|
2090
|
+
${ shaderData.uniforms }
|
|
2060
2091
|
|
|
2061
2092
|
// codes
|
|
2062
|
-
${shaderData.codes}
|
|
2093
|
+
${ shaderData.codes }
|
|
2063
2094
|
|
|
2064
|
-
@compute @workgroup_size( ${
|
|
2065
|
-
fn main( ${shaderData.attributes} ) {
|
|
2095
|
+
@compute @workgroup_size( ${ workgroupSizeX }, ${ workgroupSizeY }, ${ workgroupSizeZ } )
|
|
2096
|
+
fn main( ${ shaderData.attributes } ) {
|
|
2066
2097
|
|
|
2067
2098
|
// system
|
|
2068
|
-
instanceIndex = globalId.x
|
|
2099
|
+
instanceIndex = globalId.x
|
|
2100
|
+
+ globalId.y * ( ${ workgroupSizeX } * numWorkgroups.x )
|
|
2101
|
+
+ globalId.z * ( ${ workgroupSizeX } * numWorkgroups.x ) * ( ${ workgroupSizeY } * numWorkgroups.y );
|
|
2069
2102
|
|
|
2070
2103
|
// vars
|
|
2071
|
-
${shaderData.vars}
|
|
2104
|
+
${ shaderData.vars }
|
|
2072
2105
|
|
|
2073
2106
|
// flow
|
|
2074
|
-
${shaderData.flow}
|
|
2107
|
+
${ shaderData.flow }
|
|
2075
2108
|
|
|
2076
2109
|
}
|
|
2077
2110
|
`;
|
|
@@ -58,7 +58,10 @@ const wgslTypeLib = {
|
|
|
58
58
|
'texture_multisampled_2d': 'cubeTexture',
|
|
59
59
|
|
|
60
60
|
'texture_depth_2d': 'depthTexture',
|
|
61
|
+
'texture_depth_2d_array': 'depthTexture',
|
|
61
62
|
'texture_depth_multisampled_2d': 'depthTexture',
|
|
63
|
+
'texture_depth_cube': 'depthTexture',
|
|
64
|
+
'texture_depth_cube_array': 'depthTexture',
|
|
62
65
|
|
|
63
66
|
'texture_3d': 'texture3D',
|
|
64
67
|
|
|
@@ -12,6 +12,12 @@ const typedArraysToVertexFormatPrefix = new Map( [
|
|
|
12
12
|
[ Float32Array, [ 'float32', ]],
|
|
13
13
|
] );
|
|
14
14
|
|
|
15
|
+
if ( typeof Float16Array !== 'undefined' ) {
|
|
16
|
+
|
|
17
|
+
typedArraysToVertexFormatPrefix.set( Float16Array, [ 'float16' ] );
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
15
21
|
const typedAttributeToVertexFormatPrefix = new Map( [
|
|
16
22
|
[ Float16BufferAttribute, [ 'float16', ]],
|
|
17
23
|
] );
|
|
@@ -113,7 +119,9 @@ class WebGPUAttributeUtils {
|
|
|
113
119
|
|
|
114
120
|
}
|
|
115
121
|
|
|
116
|
-
|
|
122
|
+
// ensure 4 byte alignment
|
|
123
|
+
const byteLength = array.byteLength;
|
|
124
|
+
const size = byteLength + ( ( 4 - ( byteLength % 4 ) ) % 4 );
|
|
117
125
|
|
|
118
126
|
buffer = device.createBuffer( {
|
|
119
127
|
label: bufferAttribute.name,
|