super-three 0.184.0 → 0.185.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +1260 -927
- package/build/three.core.js +1104 -829
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +156 -98
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +11 -4
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +7538 -3367
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +7538 -3366
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -0
- package/examples/jsm/controls/ArcballControls.js +6 -2
- package/examples/jsm/controls/FirstPersonControls.js +79 -42
- package/examples/jsm/controls/TransformControls.js +68 -15
- package/examples/jsm/csm/CSMFrustum.js +31 -6
- package/examples/jsm/csm/CSMShadowNode.js +4 -1
- package/examples/jsm/effects/AsciiEffect.js +14 -1
- package/examples/jsm/exporters/DRACOExporter.js +27 -6
- package/examples/jsm/exporters/GLTFExporter.js +114 -12
- package/examples/jsm/exporters/PLYExporter.js +286 -73
- package/examples/jsm/exporters/USDZExporter.js +347 -112
- package/examples/jsm/generators/CityGenerator.js +346 -0
- package/examples/jsm/generators/ForestGenerator.js +347 -0
- package/examples/jsm/generators/TerrainGenerator.js +504 -0
- package/examples/jsm/generators/TreeGenerator.js +377 -0
- package/examples/jsm/generators/city/SidewalkGenerator.js +253 -0
- package/examples/jsm/generators/city/SkyscraperGenerator.js +1357 -0
- package/examples/jsm/geometries/LoftGeometry.js +355 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +5 -4
- package/examples/jsm/helpers/ViewHelper.js +16 -6
- package/examples/jsm/inspector/Inspector.js +53 -15
- package/examples/jsm/inspector/RendererInspector.js +152 -36
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +1 -1
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +1 -1
- package/examples/jsm/inspector/tabs/Console.js +200 -18
- package/examples/jsm/inspector/tabs/Memory.js +8 -0
- package/examples/jsm/inspector/tabs/Parameters.js +64 -4
- package/examples/jsm/inspector/tabs/Performance.js +21 -6
- package/examples/jsm/inspector/tabs/Settings.js +51 -9
- package/examples/jsm/inspector/tabs/Timeline.js +178 -93
- package/examples/jsm/inspector/tabs/Viewer.js +628 -16
- package/examples/jsm/inspector/ui/Graph.js +162 -25
- package/examples/jsm/inspector/ui/Item.js +92 -13
- package/examples/jsm/inspector/ui/List.js +1 -1
- package/examples/jsm/inspector/ui/Profiler.js +90 -45
- package/examples/jsm/inspector/ui/Style.js +1788 -1401
- package/examples/jsm/inspector/ui/Tab.js +5 -3
- package/examples/jsm/inspector/ui/Values.js +71 -6
- package/examples/jsm/inspector/ui/utils.js +130 -10
- package/examples/jsm/libs/basis/README.md +0 -1
- package/examples/jsm/libs/demuxer_mp4.js +3 -3
- package/examples/jsm/libs/draco/README.md +0 -1
- package/examples/jsm/libs/meshopt_clusterizer.module.js +421 -0
- package/examples/jsm/libs/meshopt_simplifier.module.js +627 -0
- package/examples/jsm/libs/mikktspace.module.js +34 -9
- package/examples/jsm/lighting/ClusteredLighting.js +55 -0
- package/examples/jsm/lighting/LightProbeGrid.js +106 -76
- package/examples/jsm/lines/LineMaterial.js +38 -15
- package/examples/jsm/lines/LineSegments2.js +8 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +8 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +46 -13
- package/examples/jsm/loaders/EXRLoader.js +27 -55
- package/examples/jsm/loaders/HDRLoader.js +6 -28
- package/examples/jsm/loaders/KTX2Loader.js +31 -12
- package/examples/jsm/loaders/LDrawLoader.js +8 -8
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +2 -2
- package/examples/jsm/loaders/LWOLoader.js +4 -0
- package/examples/jsm/loaders/LottieLoader.js +1 -1
- package/examples/jsm/loaders/MaterialXLoader.js +31 -9
- package/examples/jsm/loaders/NRRDLoader.js +3 -3
- package/examples/jsm/loaders/PCDLoader.js +7 -7
- package/examples/jsm/loaders/PLYLoader.js +218 -55
- package/examples/jsm/loaders/SVGLoader.js +547 -495
- package/examples/jsm/loaders/TTFLoader.js +1 -1
- package/examples/jsm/loaders/USDLoader.js +33 -9
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/loaders/usd/USDAParser.js +93 -20
- package/examples/jsm/loaders/usd/USDCParser.js +1 -1
- package/examples/jsm/loaders/usd/USDComposer.js +52 -19
- package/examples/jsm/misc/TileCreasedNormalsPlugin.js +270 -0
- package/examples/jsm/misc/Volume.js +2 -2
- package/examples/jsm/objects/GroundedSkybox.js +1 -1
- package/examples/jsm/objects/Reflector.js +2 -3
- package/examples/jsm/objects/Water2Mesh.js +1 -1
- package/examples/jsm/physics/AmmoPhysics.js +15 -8
- package/examples/jsm/physics/RapierPhysics.js +27 -2
- package/examples/jsm/shaders/VolumeShader.js +31 -44
- package/examples/jsm/transpiler/GLSLDecoder.js +6 -6
- package/examples/jsm/transpiler/Linker.js +1 -1
- package/examples/jsm/tsl/display/BloomNode.js +59 -19
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +2 -2
- package/examples/jsm/tsl/display/FXAANode.js +11 -12
- package/examples/jsm/tsl/display/GTAONode.js +34 -13
- package/examples/jsm/tsl/display/GodraysNode.js +1 -1
- package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +560 -0
- package/examples/jsm/tsl/display/PixelationPassNode.js +2 -2
- package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +912 -0
- package/examples/jsm/tsl/display/SSAAPassNode.js +13 -25
- package/examples/jsm/tsl/display/SSGINode.js +89 -39
- package/examples/jsm/tsl/display/SSRNode.js +829 -132
- package/examples/jsm/tsl/display/SSSNode.js +2 -2
- package/examples/jsm/tsl/display/TemporalReprojectNode.js +1023 -0
- package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +622 -0
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +1 -1
- package/examples/jsm/tsl/math/curlNoise.js +107 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +1 -1
- package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +3 -3
- package/examples/jsm/tsl/utils/GroundedSkybox.js +62 -0
- package/examples/jsm/tsl/utils/RNoise.js +51 -0
- package/examples/jsm/tsl/utils/SpecularHelpers.js +325 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +126 -59
- package/examples/jsm/utils/GeometryCompressionUtils.js +1 -1
- package/examples/jsm/utils/SceneOptimizer.js +1 -1
- package/examples/jsm/webxr/ARButton.js +1 -1
- package/examples/jsm/webxr/WebGLXRFallback.js +89 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +2 -2
- package/package.json +7 -7
- package/src/Three.TSL.js +10 -3
- package/src/Three.WebGPU.js +4 -0
- package/src/animation/AnimationAction.js +15 -11
- package/src/animation/AnimationClip.js +0 -139
- package/src/animation/KeyframeTrack.js +2 -2
- package/src/animation/PropertyBinding.js +2 -2
- package/src/cameras/Camera.js +2 -2
- package/src/cameras/StereoCamera.js +5 -2
- package/src/constants.js +1 -1
- package/src/core/BufferGeometry.js +29 -7
- package/src/core/Object3D.js +17 -7
- package/src/core/Raycaster.js +1 -1
- package/src/core/RenderTarget.js +15 -2
- package/src/extras/PMREMGenerator.js +6 -4
- package/src/extras/TextureUtils.js +1 -1
- package/src/extras/core/ShapePath.js +149 -160
- package/src/geometries/SphereGeometry.js +8 -3
- package/src/helpers/DirectionalLightHelper.js +2 -0
- package/src/helpers/HemisphereLightHelper.js +2 -0
- package/src/helpers/PointLightHelper.js +2 -0
- package/src/helpers/SpotLightHelper.js +1 -1
- package/src/loaders/DataTextureLoader.js +69 -38
- package/src/loaders/LoadingManager.js +5 -0
- package/src/loaders/MaterialLoader.js +36 -266
- package/src/loaders/ObjectLoader.js +3 -1
- package/src/materials/LineBasicMaterial.js +4 -0
- package/src/materials/Material.js +196 -1
- package/src/materials/MeshBasicMaterial.js +24 -0
- package/src/materials/MeshDepthMaterial.js +10 -0
- package/src/materials/MeshDistanceMaterial.js +10 -0
- package/src/materials/MeshLambertMaterial.js +40 -1
- package/src/materials/MeshMatcapMaterial.js +25 -1
- package/src/materials/MeshNormalMaterial.js +9 -1
- package/src/materials/MeshPhongMaterial.js +40 -1
- package/src/materials/MeshPhysicalMaterial.js +38 -0
- package/src/materials/MeshStandardMaterial.js +42 -1
- package/src/materials/MeshToonMaterial.js +34 -1
- package/src/materials/PointsMaterial.js +7 -0
- package/src/materials/ShaderMaterial.js +86 -0
- package/src/materials/SpriteMaterial.js +7 -0
- package/src/materials/nodes/Line2NodeMaterial.js +378 -322
- package/src/materials/nodes/MeshBasicNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhongNodeMaterial.js +0 -9
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +0 -30
- package/src/materials/nodes/MeshSSSNodeMaterial.js +0 -13
- package/src/materials/nodes/MeshStandardNodeMaterial.js +0 -11
- package/src/materials/nodes/NodeMaterial.js +115 -71
- package/src/materials/nodes/SpriteNodeMaterial.js +0 -10
- package/src/materials/nodes/manager/NodeMaterialObserver.js +49 -20
- package/src/math/Box3.js +5 -0
- package/src/math/FrustumArray.js +103 -133
- package/src/math/Interpolant.js +1 -1
- package/src/math/MathUtils.js +2 -2
- package/src/math/Matrix3.js +11 -0
- package/src/math/Matrix4.js +28 -3
- package/src/math/Vector2.js +2 -2
- package/src/math/Vector3.js +2 -2
- package/src/math/Vector4.js +2 -2
- package/src/math/interpolants/BezierInterpolant.js +4 -6
- package/src/nodes/Nodes.js +2 -5
- package/src/nodes/TSL.js +8 -6
- package/src/nodes/accessors/Arrays.js +4 -4
- package/src/nodes/accessors/Batch.js +108 -0
- package/src/nodes/accessors/Bitangent.js +2 -2
- package/src/nodes/accessors/BufferAttributeNode.js +13 -2
- package/src/nodes/accessors/Camera.js +7 -7
- package/src/nodes/accessors/ClippingNode.js +1 -1
- package/src/nodes/accessors/Instance.js +264 -0
- package/src/nodes/accessors/MaterialNode.js +18 -2
- package/src/nodes/accessors/MaterialProperties.js +4 -3
- package/src/nodes/accessors/{MorphNode.js → Morph.js} +99 -112
- package/src/nodes/accessors/Normal.js +13 -13
- package/src/nodes/accessors/Position.js +5 -1
- package/src/nodes/accessors/ReferenceNode.js +1 -0
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/SceneProperties.js +1 -1
- package/src/nodes/accessors/Skinning.js +263 -0
- package/src/nodes/accessors/StorageBufferNode.js +2 -2
- package/src/nodes/accessors/StorageTexture3DNode.js +100 -0
- package/src/nodes/accessors/StorageTextureNode.js +39 -7
- package/src/nodes/accessors/Tangent.js +4 -4
- package/src/nodes/accessors/TextureNode.js +60 -5
- package/src/nodes/code/FunctionNode.js +2 -16
- package/src/nodes/core/MRTNode.js +7 -2
- package/src/nodes/core/Node.js +39 -2
- package/src/nodes/core/NodeBuilder.js +201 -41
- package/src/nodes/core/NodeUtils.js +13 -13
- package/src/nodes/core/OutputStructNode.js +1 -1
- package/src/nodes/core/OverrideContextNode.js +153 -0
- package/src/nodes/core/PropertyNode.js +51 -5
- package/src/nodes/core/StackNode.js +56 -34
- package/src/nodes/core/StructNode.js +4 -6
- package/src/nodes/core/StructTypeNode.js +6 -6
- package/src/nodes/core/VarNode.js +8 -0
- package/src/nodes/core/VaryingNode.js +12 -2
- package/src/nodes/display/BlendModes.js +1 -41
- package/src/nodes/display/BumpMapNode.js +6 -1
- package/src/nodes/display/ColorAdjustment.js +10 -9
- package/src/nodes/display/FrontFacingNode.js +38 -9
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +35 -43
- package/src/nodes/display/PremultiplyAlphaFunctions.js +39 -0
- package/src/nodes/display/RenderOutputNode.js +12 -3
- package/src/nodes/functions/VolumetricLightingModel.js +40 -7
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +1 -1
- package/src/nodes/lighting/EnvironmentNode.js +2 -2
- package/src/nodes/lighting/IESSpotLightNode.js +40 -2
- package/src/nodes/lighting/LightingContextNode.js +10 -2
- package/src/nodes/lighting/LightsNode.js +90 -37
- package/src/nodes/lighting/PointShadowNode.js +6 -1
- package/src/nodes/lighting/ShadowFilterNode.js +21 -52
- package/src/nodes/lighting/ShadowNode.js +34 -14
- package/src/nodes/materialx/lib/mx_noise.js +2 -2
- package/src/nodes/math/ConditionalNode.js +3 -3
- package/src/nodes/math/MathNode.js +39 -11
- package/src/nodes/math/OperatorNode.js +23 -23
- package/src/nodes/parsers/GLSLNodeFunction.js +1 -1
- package/src/nodes/pmrem/PMREMNode.js +33 -2
- package/src/nodes/tsl/TSLCore.js +63 -18
- package/src/nodes/utils/EquirectUV.js +30 -5
- package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
- package/src/nodes/utils/Packing.js +35 -4
- package/src/nodes/utils/RTTNode.js +40 -24
- package/src/nodes/utils/ReflectorNode.js +1 -0
- package/src/nodes/utils/StorageArrayElementNode.js +1 -1
- package/src/objects/BatchedMesh.js +22 -14
- package/src/objects/InstancedMesh.js +0 -11
- package/src/objects/Skeleton.js +0 -9
- package/src/renderers/WebGLRenderer.js +19 -15
- package/src/renderers/common/Backend.js +49 -5
- package/src/renderers/common/Bindings.js +114 -45
- package/src/renderers/common/Buffer.js +9 -0
- package/src/renderers/common/ClippingContext.js +10 -2
- package/src/renderers/common/Info.js +63 -22
- package/src/renderers/common/Lighting.js +53 -5
- package/src/renderers/common/RenderList.js +41 -4
- package/src/renderers/common/RenderObject.js +73 -13
- package/src/renderers/common/Renderer.js +281 -108
- package/src/renderers/common/Sampler.js +16 -48
- package/src/renderers/common/Textures.js +32 -5
- package/src/renderers/common/TimestampQueryPool.js +1 -1
- package/src/renderers/common/UniformsGroup.js +31 -9
- package/src/renderers/common/XRManager.js +340 -22
- package/src/renderers/common/extras/PMREMGenerator.js +15 -38
- package/src/renderers/common/nodes/NodeBuilderState.js +9 -1
- package/src/renderers/common/nodes/NodeLibrary.js +4 -4
- package/src/renderers/common/nodes/NodeManager.js +63 -14
- package/src/renderers/common/nodes/NodeUniformBuffer.js +13 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +13 -4
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +0 -6
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/distance.glsl.js +1 -1
- package/src/renderers/webgl/WebGLOutput.js +2 -1
- package/src/renderers/webgl/WebGLProgram.js +5 -4
- package/src/renderers/webgl/WebGLPrograms.js +12 -5
- package/src/renderers/webgl/WebGLRenderLists.js +9 -1
- package/src/renderers/webgl/WebGLShaderCache.js +5 -11
- package/src/renderers/webgl/WebGLTextures.js +20 -7
- package/src/renderers/webgl/WebGLUniformsGroups.js +66 -38
- package/src/renderers/webgl-fallback/WebGLBackend.js +84 -25
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +138 -8
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +1 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -22
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +4 -2
- package/src/renderers/webgpu/WebGPUBackend.js +480 -169
- package/src/renderers/webgpu/descriptors/GPUBindGroupDescriptor.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUBufferDescriptor.js +57 -0
- package/src/renderers/webgpu/descriptors/GPUCommandEncoderDescriptor.js +30 -0
- package/src/renderers/webgpu/descriptors/GPUComputePassDescriptor.js +38 -0
- package/src/renderers/webgpu/descriptors/GPUComputePipelineDescriptor.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUCopyExternalImageDestInfo.js +47 -0
- package/src/renderers/webgpu/descriptors/GPUCopyExternalImageSourceInfo.js +50 -0
- package/src/renderers/webgpu/descriptors/GPUExtent3D.js +51 -0
- package/src/renderers/webgpu/descriptors/GPUPipelineLayoutDescriptor.js +39 -0
- package/src/renderers/webgpu/descriptors/GPUQuerySetDescriptor.js +47 -0
- package/src/renderers/webgpu/descriptors/GPURenderBundleEncoderDescriptor.js +74 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassColorAttachment.js +72 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassDepthStencilAttachment.js +99 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassDescriptor.js +72 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassTimestampWrites.js +49 -0
- package/src/renderers/webgpu/descriptors/GPURenderPipelineDescriptor.js +130 -0
- package/src/renderers/webgpu/descriptors/GPUSamplerDescriptor.js +119 -0
- package/src/renderers/webgpu/descriptors/GPUShaderModuleDescriptor.js +46 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferInfo.js +57 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferLayout.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyTextureInfo.js +61 -0
- package/src/renderers/webgpu/descriptors/GPUTextureDescriptor.js +99 -0
- package/src/renderers/webgpu/descriptors/GPUTextureViewDescriptor.js +108 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +0 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +164 -7
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +98 -38
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -68
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +164 -69
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +158 -95
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +297 -141
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +33 -18
- package/src/renderers/webgpu/utils/WebGPUUtils.js +38 -3
- package/src/textures/DepthTexture.js +1 -1
- package/src/textures/ExternalTexture.js +0 -3
- package/examples/fonts/LICENSE +0 -13
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +0 -91
- package/examples/fonts/README.md +0 -11
- package/examples/fonts/droid/NOTICE +0 -190
- package/examples/fonts/droid/README.txt +0 -18
- package/examples/fonts/droid/droid_sans_bold.typeface.json +0 -1
- package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +0 -1
- package/examples/fonts/droid/droid_sans_regular.typeface.json +0 -1
- package/examples/fonts/droid/droid_serif_bold.typeface.json +0 -1
- package/examples/fonts/droid/droid_serif_regular.typeface.json +0 -1
- package/examples/fonts/gentilis_bold.typeface.json +0 -1
- package/examples/fonts/gentilis_regular.typeface.json +0 -1
- package/examples/fonts/helvetiker_bold.typeface.json +0 -1
- package/examples/fonts/helvetiker_regular.typeface.json +0 -1
- package/examples/fonts/optimer_bold.typeface.json +0 -1
- package/examples/fonts/optimer_regular.typeface.json +0 -1
- package/examples/fonts/ttf/README.md +0 -9
- package/examples/fonts/ttf/kenpixel.ttf +0 -0
- package/examples/jsm/inspector/extensions/extensions.json +0 -6
- package/examples/jsm/libs/ammo.wasm.js +0 -822
- package/examples/jsm/libs/ammo.wasm.wasm +0 -0
- package/examples/jsm/libs/draco/draco_encoder.js +0 -33
- package/examples/jsm/libs/draco/gltf/draco_encoder.js +0 -33
- package/examples/jsm/libs/lottie_canvas.module.js +0 -14849
- package/examples/jsm/libs/opentype.module.js +0 -14506
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +0 -21
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +0 -16
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/lighting/TiledLighting.js +0 -42
- package/examples/jsm/tsl/display/AnamorphicNode.js +0 -293
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +0 -442
- package/src/nodes/accessors/BatchNode.js +0 -163
- package/src/nodes/accessors/InstanceNode.js +0 -349
- package/src/nodes/accessors/InstancedMeshNode.js +0 -50
- package/src/nodes/accessors/SkinningNode.js +0 -328
|
@@ -8,6 +8,14 @@ import { NodeAccess } from '../../../nodes/core/constants.js';
|
|
|
8
8
|
import { isTypedArray, error } from '../../../utils.js';
|
|
9
9
|
import { hashString } from '../../../nodes/core/NodeUtils.js';
|
|
10
10
|
|
|
11
|
+
import GPUBindGroupDescriptor from '../descriptors/GPUBindGroupDescriptor.js';
|
|
12
|
+
import GPUBufferDescriptor from '../descriptors/GPUBufferDescriptor.js';
|
|
13
|
+
import GPUTextureViewDescriptor from '../descriptors/GPUTextureViewDescriptor.js';
|
|
14
|
+
|
|
15
|
+
const _bindGroupDescriptor = new GPUBindGroupDescriptor();
|
|
16
|
+
const _bufferDescriptor = new GPUBufferDescriptor();
|
|
17
|
+
const _viewDescriptor = new GPUTextureViewDescriptor();
|
|
18
|
+
|
|
11
19
|
/**
|
|
12
20
|
* Class representing a WebGPU bind group layout.
|
|
13
21
|
*
|
|
@@ -206,12 +214,26 @@ class WebGPUBindingUtils {
|
|
|
206
214
|
const isTyped = isTypedArray( array );
|
|
207
215
|
const byteOffsetFactor = isTyped ? 1 : array.BYTES_PER_ELEMENT;
|
|
208
216
|
|
|
217
|
+
// Update ranges arrive sorted and non-overlapping which makes
|
|
218
|
+
// it easy to merge contiguous ranges.
|
|
219
|
+
|
|
220
|
+
let start = updateRanges[ 0 ].start; // start of the current merged range
|
|
221
|
+
|
|
209
222
|
for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
|
|
210
223
|
|
|
211
224
|
const range = updateRanges[ i ];
|
|
225
|
+
const next = updateRanges[ i + 1 ];
|
|
226
|
+
|
|
227
|
+
const end = range.start + range.count; // exclusive end of the current range
|
|
228
|
+
|
|
229
|
+
// keep merging while the next range is contiguous
|
|
230
|
+
|
|
231
|
+
if ( next !== undefined && next.start === end ) continue;
|
|
212
232
|
|
|
213
|
-
|
|
214
|
-
|
|
233
|
+
// write the merged range
|
|
234
|
+
|
|
235
|
+
const dataOffset = start * byteOffsetFactor;
|
|
236
|
+
const size = ( end - start ) * byteOffsetFactor;
|
|
215
237
|
|
|
216
238
|
const bufferOffset = dataOffset * ( isTyped ? array.BYTES_PER_ELEMENT : 1 ); // bufferOffset is always in bytes
|
|
217
239
|
|
|
@@ -223,6 +245,10 @@ class WebGPUBindingUtils {
|
|
|
223
245
|
size
|
|
224
246
|
);
|
|
225
247
|
|
|
248
|
+
// start next if possible
|
|
249
|
+
|
|
250
|
+
if ( next !== undefined ) start = next.start;
|
|
251
|
+
|
|
226
252
|
}
|
|
227
253
|
|
|
228
254
|
}
|
|
@@ -244,21 +270,25 @@ class WebGPUBindingUtils {
|
|
|
244
270
|
const usage = GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST;
|
|
245
271
|
const index = data[ 0 ];
|
|
246
272
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
273
|
+
_bufferDescriptor.label = 'bindingCameraIndex_' + index;
|
|
274
|
+
_bufferDescriptor.size = 16; // uint(4) * 4
|
|
275
|
+
_bufferDescriptor.usage = usage;
|
|
276
|
+
|
|
277
|
+
const buffer = device.createBuffer( _bufferDescriptor );
|
|
278
|
+
|
|
279
|
+
_bufferDescriptor.reset();
|
|
252
280
|
|
|
253
281
|
device.queue.writeBuffer( buffer, 0, data, 0 );
|
|
254
282
|
|
|
255
|
-
|
|
283
|
+
_bindGroupDescriptor.label = 'bindGroupCameraIndex_' + index;
|
|
284
|
+
_bindGroupDescriptor.layout = layoutGPU;
|
|
285
|
+
_bindGroupDescriptor.entries.push( { binding: 0, resource: { buffer } } );
|
|
286
|
+
|
|
287
|
+
const bindGroup = device.createBindGroup( _bindGroupDescriptor );
|
|
256
288
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
entries
|
|
261
|
-
} );
|
|
289
|
+
_bindGroupDescriptor.reset();
|
|
290
|
+
|
|
291
|
+
return bindGroup;
|
|
262
292
|
|
|
263
293
|
}
|
|
264
294
|
|
|
@@ -275,7 +305,9 @@ class WebGPUBindingUtils {
|
|
|
275
305
|
const device = backend.device;
|
|
276
306
|
|
|
277
307
|
let bindingPoint = 0;
|
|
278
|
-
|
|
308
|
+
|
|
309
|
+
_bindGroupDescriptor.label = 'bindGroup_' + bindGroup.name;
|
|
310
|
+
_bindGroupDescriptor.layout = layoutGPU;
|
|
279
311
|
|
|
280
312
|
for ( const binding of bindGroup.bindings ) {
|
|
281
313
|
|
|
@@ -283,50 +315,13 @@ class WebGPUBindingUtils {
|
|
|
283
315
|
|
|
284
316
|
const bindingData = backend.get( binding );
|
|
285
317
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
const byteLength = binding.byteLength;
|
|
289
|
-
|
|
290
|
-
const usage = GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST;
|
|
291
|
-
|
|
292
|
-
const visibilities = [];
|
|
293
|
-
if ( binding.visibility & GPUShaderStage.VERTEX ) {
|
|
294
|
-
|
|
295
|
-
visibilities.push( 'vertex' );
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if ( binding.visibility & GPUShaderStage.FRAGMENT ) {
|
|
300
|
-
|
|
301
|
-
visibilities.push( 'fragment' );
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if ( binding.visibility & GPUShaderStage.COMPUTE ) {
|
|
306
|
-
|
|
307
|
-
visibilities.push( 'compute' );
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
const bufferVisibility = `(${visibilities.join( ',' )})`;
|
|
312
|
-
|
|
313
|
-
const bufferGPU = device.createBuffer( {
|
|
314
|
-
label: `bindingBuffer${binding.id}_${binding.name}_${bufferVisibility}`,
|
|
315
|
-
size: byteLength,
|
|
316
|
-
usage: usage
|
|
317
|
-
} );
|
|
318
|
-
|
|
319
|
-
bindingData.buffer = bufferGPU;
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
entriesGPU.push( { binding: bindingPoint, resource: { buffer: bindingData.buffer } } );
|
|
318
|
+
_bindGroupDescriptor.entries.push( { binding: bindingPoint, resource: { buffer: bindingData.buffer } } );
|
|
324
319
|
|
|
325
320
|
} else if ( binding.isStorageBuffer ) {
|
|
326
321
|
|
|
327
322
|
const buffer = backend.get( binding.attribute ).buffer;
|
|
328
323
|
|
|
329
|
-
|
|
324
|
+
_bindGroupDescriptor.entries.push( { binding: bindingPoint, resource: { buffer: buffer } } );
|
|
330
325
|
|
|
331
326
|
} else if ( binding.isSampledTexture ) {
|
|
332
327
|
|
|
@@ -364,33 +359,42 @@ class WebGPUBindingUtils {
|
|
|
364
359
|
|
|
365
360
|
dimensionViewGPU = GPUTextureViewDimension.Cube;
|
|
366
361
|
|
|
367
|
-
} else if ( binding.isSampledTexture3D ) {
|
|
368
|
-
|
|
369
|
-
dimensionViewGPU = GPUTextureViewDimension.ThreeD;
|
|
370
|
-
|
|
371
362
|
} else if ( binding.texture.isArrayTexture || binding.texture.isDataArrayTexture || binding.texture.isCompressedArrayTexture ) {
|
|
372
363
|
|
|
364
|
+
// Prefer the texture's actual array flag over the cached 3D binding type.
|
|
365
|
+
// Layered render targets can become array textures after shader compilation.
|
|
373
366
|
dimensionViewGPU = GPUTextureViewDimension.TwoDArray;
|
|
374
367
|
|
|
368
|
+
} else if ( binding.isSampledTexture3D ) {
|
|
369
|
+
|
|
370
|
+
dimensionViewGPU = GPUTextureViewDimension.ThreeD;
|
|
371
|
+
|
|
375
372
|
} else {
|
|
376
373
|
|
|
377
374
|
dimensionViewGPU = GPUTextureViewDimension.TwoD;
|
|
378
375
|
|
|
379
376
|
}
|
|
380
377
|
|
|
381
|
-
|
|
378
|
+
_viewDescriptor.aspect = aspectGPU;
|
|
379
|
+
_viewDescriptor.dimension = dimensionViewGPU;
|
|
380
|
+
_viewDescriptor.mipLevelCount = mipLevelCount;
|
|
381
|
+
_viewDescriptor.baseMipLevel = baseMipLevel;
|
|
382
|
+
|
|
383
|
+
resourceGPU = textureData[ propertyName ] = textureData.texture.createView( _viewDescriptor );
|
|
384
|
+
|
|
385
|
+
_viewDescriptor.reset();
|
|
382
386
|
|
|
383
387
|
}
|
|
384
388
|
|
|
385
389
|
}
|
|
386
390
|
|
|
387
|
-
|
|
391
|
+
_bindGroupDescriptor.entries.push( { binding: bindingPoint, resource: resourceGPU } );
|
|
388
392
|
|
|
389
393
|
} else if ( binding.isSampler ) {
|
|
390
394
|
|
|
391
|
-
const
|
|
395
|
+
const bindingData = backend.get( binding );
|
|
392
396
|
|
|
393
|
-
|
|
397
|
+
_bindGroupDescriptor.entries.push( { binding: bindingPoint, resource: bindingData.sampler } );
|
|
394
398
|
|
|
395
399
|
}
|
|
396
400
|
|
|
@@ -398,11 +402,11 @@ class WebGPUBindingUtils {
|
|
|
398
402
|
|
|
399
403
|
}
|
|
400
404
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
405
|
+
const bindGroupGPU = device.createBindGroup( _bindGroupDescriptor );
|
|
406
|
+
|
|
407
|
+
_bindGroupDescriptor.reset();
|
|
408
|
+
|
|
409
|
+
return bindGroupGPU;
|
|
406
410
|
|
|
407
411
|
}
|
|
408
412
|
|
|
@@ -520,7 +524,7 @@ class WebGPUBindingUtils {
|
|
|
520
524
|
|
|
521
525
|
}
|
|
522
526
|
|
|
523
|
-
} else
|
|
527
|
+
} else {
|
|
524
528
|
|
|
525
529
|
const type = binding.texture.type;
|
|
526
530
|
|
|
@@ -570,7 +574,7 @@ class WebGPUBindingUtils {
|
|
|
570
574
|
|
|
571
575
|
if ( binding.texture.isDepthTexture ) {
|
|
572
576
|
|
|
573
|
-
if ( binding.texture.compareFunction !== null && backend.hasCompatibility( Compatibility.TEXTURE_COMPARE ) ) {
|
|
577
|
+
if ( binding.texture.compareFunction !== null && binding.textureNode.compareNode !== null && backend.hasCompatibility( Compatibility.TEXTURE_COMPARE ) ) {
|
|
574
578
|
|
|
575
579
|
sampler.type = GPUSamplerBindingType.Comparison;
|
|
576
580
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BlendColorFactor, OneMinusBlendColorFactor, } from '../../common/Constants.js';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
GPUFrontFace, GPUCullMode, GPUColorWriteFlags, GPUCompareFunction, GPUBlendFactor, GPUBlendOperation, GPUIndexFormat, GPUStencilOperation
|
|
4
|
+
GPUFrontFace, GPUCullMode, GPUColorWriteFlags, GPUCompareFunction, GPUBlendFactor, GPUBlendOperation, GPUIndexFormat, GPUStencilOperation, GPUPrimitiveTopology
|
|
5
5
|
} from './WebGPUConstants.js';
|
|
6
6
|
|
|
7
7
|
import {
|
|
@@ -15,7 +15,17 @@ import {
|
|
|
15
15
|
NeverStencilFunc, AlwaysStencilFunc, LessStencilFunc, LessEqualStencilFunc, EqualStencilFunc, GreaterEqualStencilFunc, GreaterStencilFunc, NotEqualStencilFunc
|
|
16
16
|
} from '../../../constants.js';
|
|
17
17
|
|
|
18
|
-
import { error, ReversedDepthFuncs, warnOnce } from '../../../utils.js';
|
|
18
|
+
import { error, ReversedDepthFuncs, warn, warnOnce } from '../../../utils.js';
|
|
19
|
+
|
|
20
|
+
import GPUComputePipelineDescriptor from '../descriptors/GPUComputePipelineDescriptor.js';
|
|
21
|
+
import GPUPipelineLayoutDescriptor from '../descriptors/GPUPipelineLayoutDescriptor.js';
|
|
22
|
+
import GPURenderBundleEncoderDescriptor from '../descriptors/GPURenderBundleEncoderDescriptor.js';
|
|
23
|
+
import GPURenderPipelineDescriptor from '../descriptors/GPURenderPipelineDescriptor.js';
|
|
24
|
+
|
|
25
|
+
const _computePipelineDescriptor = new GPUComputePipelineDescriptor();
|
|
26
|
+
const _pipelineLayoutDescriptor = new GPUPipelineLayoutDescriptor();
|
|
27
|
+
const _renderBundleEncoderDescriptor = new GPURenderBundleEncoderDescriptor();
|
|
28
|
+
const _renderPipelineDescriptor = new GPURenderPipelineDescriptor();
|
|
19
29
|
|
|
20
30
|
/**
|
|
21
31
|
* A WebGPU backend utility module for managing pipelines.
|
|
@@ -38,35 +48,6 @@ class WebGPUPipelineUtils {
|
|
|
38
48
|
*/
|
|
39
49
|
this.backend = backend;
|
|
40
50
|
|
|
41
|
-
/**
|
|
42
|
-
* A Weak Map that tracks the active pipeline for render or compute passes.
|
|
43
|
-
*
|
|
44
|
-
* @private
|
|
45
|
-
* @type {WeakMap<(GPURenderPassEncoder|GPUComputePassEncoder),(GPURenderPipeline|GPUComputePipeline)>}
|
|
46
|
-
*/
|
|
47
|
-
this._activePipelines = new WeakMap();
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Sets the given pipeline for the given pass. The method makes sure to only set the
|
|
53
|
-
* pipeline when necessary.
|
|
54
|
-
*
|
|
55
|
-
* @param {(GPURenderPassEncoder|GPUComputePassEncoder)} pass - The pass encoder.
|
|
56
|
-
* @param {(GPURenderPipeline|GPUComputePipeline)} pipeline - The pipeline.
|
|
57
|
-
*/
|
|
58
|
-
setPipeline( pass, pipeline ) {
|
|
59
|
-
|
|
60
|
-
const currentPipeline = this._activePipelines.get( pass );
|
|
61
|
-
|
|
62
|
-
if ( currentPipeline !== pipeline ) {
|
|
63
|
-
|
|
64
|
-
pass.setPipeline( pipeline );
|
|
65
|
-
|
|
66
|
-
this._activePipelines.set( pass, pipeline );
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
51
|
}
|
|
71
52
|
|
|
72
53
|
/**
|
|
@@ -218,20 +199,19 @@ class WebGPUPipelineUtils {
|
|
|
218
199
|
|
|
219
200
|
const sampleCount = this._getSampleCount( renderObject.context );
|
|
220
201
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
multisample: {
|
|
227
|
-
count: sampleCount,
|
|
228
|
-
alphaToCoverageEnabled: material.alphaToCoverage && sampleCount > 1
|
|
229
|
-
},
|
|
230
|
-
layout: device.createPipelineLayout( {
|
|
231
|
-
bindGroupLayouts
|
|
232
|
-
} )
|
|
233
|
-
};
|
|
202
|
+
_pipelineLayoutDescriptor.bindGroupLayouts = bindGroupLayouts;
|
|
203
|
+
|
|
204
|
+
const pipelineLayout = device.createPipelineLayout( _pipelineLayoutDescriptor );
|
|
205
|
+
|
|
206
|
+
_pipelineLayoutDescriptor.reset();
|
|
234
207
|
|
|
208
|
+
_renderPipelineDescriptor.label = `renderPipeline_${ material.name || material.type }_${ material.id }`;
|
|
209
|
+
_renderPipelineDescriptor.vertex = Object.assign( {}, vertexModule, { buffers: vertexBuffers } );
|
|
210
|
+
_renderPipelineDescriptor.fragment = Object.assign( {}, fragmentModule, { targets } );
|
|
211
|
+
_renderPipelineDescriptor.primitive = primitiveState;
|
|
212
|
+
_renderPipelineDescriptor.multisample.count = sampleCount;
|
|
213
|
+
_renderPipelineDescriptor.multisample.alphaToCoverageEnabled = material.alphaToCoverage && sampleCount > 1;
|
|
214
|
+
_renderPipelineDescriptor.layout = pipelineLayout;
|
|
235
215
|
|
|
236
216
|
const depthStencil = {};
|
|
237
217
|
const renderDepth = renderObject.context.depth;
|
|
@@ -256,7 +236,7 @@ class WebGPUPipelineUtils {
|
|
|
256
236
|
|
|
257
237
|
}
|
|
258
238
|
|
|
259
|
-
if ( material.polygonOffset === true ) {
|
|
239
|
+
if ( material.polygonOffset === true && ( primitiveState.topology === GPUPrimitiveTopology.TriangleList ) ) {
|
|
260
240
|
|
|
261
241
|
depthStencil.depthBias = material.polygonOffsetUnits;
|
|
262
242
|
depthStencil.depthBiasSlopeScale = material.polygonOffsetFactor;
|
|
@@ -264,7 +244,7 @@ class WebGPUPipelineUtils {
|
|
|
264
244
|
|
|
265
245
|
}
|
|
266
246
|
|
|
267
|
-
|
|
247
|
+
_renderPipelineDescriptor.depthStencil = depthStencil;
|
|
268
248
|
|
|
269
249
|
}
|
|
270
250
|
|
|
@@ -272,9 +252,17 @@ class WebGPUPipelineUtils {
|
|
|
272
252
|
|
|
273
253
|
device.pushErrorScope( 'validation' );
|
|
274
254
|
|
|
255
|
+
const stages = [
|
|
256
|
+
{ program: vertexProgram, module: vertexModule.module },
|
|
257
|
+
{ program: fragmentProgram, module: fragmentModule.module }
|
|
258
|
+
];
|
|
259
|
+
const pipelineLabel = _renderPipelineDescriptor.label;
|
|
260
|
+
|
|
275
261
|
if ( promises === null ) {
|
|
276
262
|
|
|
277
|
-
pipelineData.pipeline = device.createRenderPipeline(
|
|
263
|
+
pipelineData.pipeline = device.createRenderPipeline( _renderPipelineDescriptor );
|
|
264
|
+
|
|
265
|
+
_renderPipelineDescriptor.reset();
|
|
278
266
|
|
|
279
267
|
device.popErrorScope().then( ( err ) => {
|
|
280
268
|
|
|
@@ -282,7 +270,9 @@ class WebGPUPipelineUtils {
|
|
|
282
270
|
|
|
283
271
|
pipelineData.error = true;
|
|
284
272
|
|
|
285
|
-
error( err.message );
|
|
273
|
+
error( `WebGPURenderer: Render pipeline creation failed (${ pipelineLabel }): ${ err.message }` );
|
|
274
|
+
|
|
275
|
+
this._reportShaderDiagnostics( stages, pipelineLabel );
|
|
286
276
|
|
|
287
277
|
}
|
|
288
278
|
|
|
@@ -294,21 +284,55 @@ class WebGPUPipelineUtils {
|
|
|
294
284
|
|
|
295
285
|
try {
|
|
296
286
|
|
|
297
|
-
|
|
287
|
+
let asyncError = null;
|
|
288
|
+
let pipelinePromise = null;
|
|
298
289
|
|
|
299
|
-
|
|
290
|
+
try {
|
|
300
291
|
|
|
301
|
-
|
|
292
|
+
pipelinePromise = device.createRenderPipelineAsync( _renderPipelineDescriptor );
|
|
302
293
|
|
|
303
|
-
|
|
294
|
+
} catch ( err ) {
|
|
304
295
|
|
|
305
|
-
|
|
296
|
+
asyncError = err;
|
|
297
|
+
|
|
298
|
+
}
|
|
306
299
|
|
|
307
|
-
|
|
300
|
+
_renderPipelineDescriptor.reset();
|
|
308
301
|
|
|
309
|
-
|
|
302
|
+
if ( pipelinePromise !== null ) {
|
|
303
|
+
|
|
304
|
+
try {
|
|
305
|
+
|
|
306
|
+
pipelineData.pipeline = await pipelinePromise;
|
|
307
|
+
|
|
308
|
+
} catch ( err ) {
|
|
309
|
+
|
|
310
|
+
asyncError = err;
|
|
311
|
+
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const errorScope = await device.popErrorScope();
|
|
317
|
+
|
|
318
|
+
if ( errorScope !== null || asyncError !== null ) {
|
|
319
|
+
|
|
320
|
+
pipelineData.error = true;
|
|
321
|
+
|
|
322
|
+
const reason = ( errorScope && errorScope.message ) || ( asyncError && asyncError.message ) || 'unknown';
|
|
323
|
+
error( `WebGPURenderer: Async render pipeline creation failed (${ pipelineLabel }): ${ reason }` );
|
|
324
|
+
|
|
325
|
+
await this._reportShaderDiagnostics( stages, pipelineLabel );
|
|
326
|
+
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
} finally {
|
|
310
330
|
|
|
311
|
-
|
|
331
|
+
// Guarantee resolution so `compileAsync`'s Promise.all cannot hang on an
|
|
332
|
+
// unexpected throw from any await above.
|
|
333
|
+
resolve();
|
|
334
|
+
|
|
335
|
+
}
|
|
312
336
|
|
|
313
337
|
} );
|
|
314
338
|
|
|
@@ -334,14 +358,16 @@ class WebGPUPipelineUtils {
|
|
|
334
358
|
const colorFormats = utils.getCurrentColorFormats( renderContext );
|
|
335
359
|
const sampleCount = this._getSampleCount( renderContext );
|
|
336
360
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
361
|
+
_renderBundleEncoderDescriptor.label = label;
|
|
362
|
+
_renderBundleEncoderDescriptor.colorFormats = colorFormats;
|
|
363
|
+
_renderBundleEncoderDescriptor.depthStencilFormat = depthStencilFormat;
|
|
364
|
+
_renderBundleEncoderDescriptor.sampleCount = sampleCount;
|
|
365
|
+
|
|
366
|
+
const bundleEncoder = device.createRenderBundleEncoder( _renderBundleEncoderDescriptor );
|
|
343
367
|
|
|
344
|
-
|
|
368
|
+
_renderBundleEncoderDescriptor.reset();
|
|
369
|
+
|
|
370
|
+
return bundleEncoder;
|
|
345
371
|
|
|
346
372
|
}
|
|
347
373
|
|
|
@@ -373,15 +399,84 @@ class WebGPUPipelineUtils {
|
|
|
373
399
|
|
|
374
400
|
}
|
|
375
401
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
402
|
+
const computeStage = pipeline.computeProgram;
|
|
403
|
+
const pipelineLabel = `computePipeline_${ computeStage.stage }${ computeStage.name ? `_${ computeStage.name }` : '' }`;
|
|
404
|
+
|
|
405
|
+
device.pushErrorScope( 'validation' );
|
|
406
|
+
|
|
407
|
+
_pipelineLayoutDescriptor.bindGroupLayouts = bindGroupLayouts;
|
|
408
|
+
|
|
409
|
+
const pipelineLayout = device.createPipelineLayout( _pipelineLayoutDescriptor );
|
|
410
|
+
|
|
411
|
+
_pipelineLayoutDescriptor.reset();
|
|
412
|
+
|
|
413
|
+
_computePipelineDescriptor.label = pipelineLabel;
|
|
414
|
+
_computePipelineDescriptor.compute = computeProgram;
|
|
415
|
+
_computePipelineDescriptor.layout = pipelineLayout;
|
|
416
|
+
|
|
417
|
+
pipelineGPU.pipeline = device.createComputePipeline( _computePipelineDescriptor );
|
|
418
|
+
|
|
419
|
+
_computePipelineDescriptor.reset();
|
|
420
|
+
|
|
421
|
+
device.popErrorScope().then( ( err ) => {
|
|
422
|
+
|
|
423
|
+
if ( err !== null ) {
|
|
424
|
+
|
|
425
|
+
pipelineGPU.error = true;
|
|
426
|
+
|
|
427
|
+
error( `WebGPURenderer: Compute pipeline creation failed (${ pipelineLabel }): ${ err.message }` );
|
|
428
|
+
|
|
429
|
+
this._reportShaderDiagnostics( [ { program: computeStage, module: computeProgram.module } ], pipelineLabel );
|
|
430
|
+
|
|
431
|
+
}
|
|
432
|
+
|
|
381
433
|
} );
|
|
382
434
|
|
|
383
435
|
}
|
|
384
436
|
|
|
437
|
+
/**
|
|
438
|
+
* Reads line-accurate diagnostics from shader modules and logs them.
|
|
439
|
+
* Called from pipeline creation error paths to turn opaque validation
|
|
440
|
+
* failures into actionable WGSL feedback.
|
|
441
|
+
*
|
|
442
|
+
* @private
|
|
443
|
+
* @param {Array<{program: ProgrammableStage, module: GPUShaderModule}>} stages - Pairs of program + compiled shader module.
|
|
444
|
+
* @param {string} pipelineLabel - Label of the owning pipeline, used as log prefix.
|
|
445
|
+
* @return {Promise<void>}
|
|
446
|
+
*/
|
|
447
|
+
async _reportShaderDiagnostics( stages, pipelineLabel ) {
|
|
448
|
+
|
|
449
|
+
for ( const { program, module } of stages ) {
|
|
450
|
+
|
|
451
|
+
const info = await module.getCompilationInfo();
|
|
452
|
+
if ( info.messages.length === 0 ) continue;
|
|
453
|
+
|
|
454
|
+
const sourceLines = program.code.split( '\n' );
|
|
455
|
+
|
|
456
|
+
for ( const msg of info.messages ) {
|
|
457
|
+
|
|
458
|
+
const location = msg.lineNum > 0
|
|
459
|
+
? ` at line ${ msg.lineNum }${ msg.linePos > 0 ? `:${ msg.linePos }` : '' }`
|
|
460
|
+
: '';
|
|
461
|
+
|
|
462
|
+
const header = `WebGPURenderer [${ pipelineLabel } / ${ program.stage } ${ msg.type }]${ location }: ${ msg.message }`;
|
|
463
|
+
|
|
464
|
+
let excerpt = '';
|
|
465
|
+
if ( msg.lineNum > 0 && msg.lineNum <= sourceLines.length ) {
|
|
466
|
+
|
|
467
|
+
excerpt = `\n ${ sourceLines[ msg.lineNum - 1 ] }`;
|
|
468
|
+
if ( msg.linePos > 0 ) excerpt += `\n ${ ' '.repeat( msg.linePos - 1 ) }^`;
|
|
469
|
+
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
( msg.type === 'error' ? error : warn )( header + excerpt );
|
|
473
|
+
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
}
|
|
479
|
+
|
|
385
480
|
/**
|
|
386
481
|
* Returns the blending state as a descriptor object required
|
|
387
482
|
* for the pipeline creation.
|
|
@@ -752,7 +847,7 @@ class WebGPUPipelineUtils {
|
|
|
752
847
|
|
|
753
848
|
let flipSided = ( material.side === BackSide );
|
|
754
849
|
|
|
755
|
-
if ( object.isMesh && object.matrixWorld.
|
|
850
|
+
if ( object.isMesh && object.matrixWorld.determinantAffine() < 0 ) flipSided = ! flipSided;
|
|
756
851
|
|
|
757
852
|
descriptor.frontFace = ( flipSided === true ) ? GPUFrontFace.CW : GPUFrontFace.CCW;
|
|
758
853
|
|