@plastic-software/three 0.183.3 → 0.184.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 +783 -290
- package/build/three.core.js +372 -110
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +436 -184
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +7 -1
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +2979 -1281
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +2942 -1281
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +11 -0
- package/examples/jsm/animation/CCDIKSolver.js +5 -1
- package/examples/jsm/controls/ArcballControls.js +4 -1
- package/examples/jsm/controls/DragControls.js +2 -2
- package/examples/jsm/controls/FirstPersonControls.js +58 -54
- package/examples/jsm/controls/FlyControls.js +4 -0
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/TrackballControls.js +2 -2
- package/examples/jsm/controls/TransformControls.js +34 -2
- package/examples/jsm/csm/CSMShadowNode.js +6 -2
- package/examples/jsm/exporters/GLTFExporter.js +21 -5
- package/examples/jsm/geometries/TextGeometry.js +18 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
- package/examples/jsm/inspector/Extension.js +13 -0
- package/examples/jsm/inspector/Inspector.js +169 -114
- package/examples/jsm/inspector/RendererInspector.js +2 -2
- package/examples/jsm/inspector/extensions/extensions.json +6 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
- package/examples/jsm/inspector/tabs/Memory.js +128 -0
- package/examples/jsm/inspector/tabs/Parameters.js +34 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Settings.js +264 -0
- package/examples/jsm/inspector/tabs/Timeline.js +1611 -0
- package/examples/jsm/inspector/tabs/Viewer.js +105 -3
- package/examples/jsm/inspector/ui/Graph.js +2 -2
- package/examples/jsm/inspector/ui/List.js +1 -1
- package/examples/jsm/inspector/ui/Profiler.js +273 -176
- package/examples/jsm/inspector/ui/Style.js +64 -10
- package/examples/jsm/inspector/ui/Tab.js +39 -7
- package/examples/jsm/inspector/ui/Values.js +39 -2
- package/examples/jsm/inspector/ui/utils.js +13 -0
- package/examples/jsm/interaction/InteractionManager.js +226 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +8 -8
- package/examples/jsm/lighting/DynamicLighting.js +82 -0
- package/examples/jsm/lighting/LightProbeGrid.js +651 -0
- package/examples/jsm/lines/LineMaterial.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +682 -43
- package/examples/jsm/loaders/FBXLoader.js +233 -33
- package/examples/jsm/loaders/GLTFLoader.js +24 -7
- package/examples/jsm/loaders/HDRLoader.js +1 -1
- package/examples/jsm/loaders/KTX2Loader.js +8 -2
- package/examples/jsm/loaders/LDrawLoader.js +39 -47
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/VTKLoader.js +5 -1
- package/examples/jsm/loaders/collada/ColladaComposer.js +101 -7
- package/examples/jsm/loaders/collada/ColladaParser.js +19 -4
- package/examples/jsm/loaders/usd/USDAParser.js +6 -0
- package/examples/jsm/loaders/usd/USDCParser.js +26 -0
- package/examples/jsm/loaders/usd/USDComposer.js +656 -103
- package/examples/jsm/misc/GPUComputationRenderer.js +2 -0
- package/examples/jsm/misc/RollerCoaster.js +42 -4
- package/examples/jsm/modifiers/TessellateModifier.js +1 -1
- package/examples/jsm/objects/Reflector.js +73 -25
- package/examples/jsm/objects/Sky.js +14 -2
- package/examples/jsm/objects/SkyMesh.js +23 -6
- package/examples/jsm/renderers/Projector.js +18 -38
- package/examples/jsm/renderers/SVGRenderer.js +6 -25
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +10 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +11 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +10 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +3 -36
- package/examples/jsm/tsl/display/FSR1Node.js +477 -0
- package/examples/jsm/tsl/display/GTAONode.js +2 -1
- package/examples/jsm/tsl/display/GaussianBlurNode.js +10 -0
- package/examples/jsm/tsl/display/GodraysNode.js +2 -11
- package/examples/jsm/tsl/display/OutlineNode.js +66 -16
- package/examples/jsm/tsl/display/SSGINode.js +0 -4
- package/examples/jsm/tsl/display/SharpenNode.js +283 -0
- package/examples/jsm/tsl/display/TAAUNode.js +835 -0
- package/examples/jsm/tsl/display/TRAANode.js +48 -7
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +300 -0
- package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
- package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
- package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
- package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
- package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
- package/examples/jsm/tsl/math/Bayer.js +13 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +2 -3
- package/examples/jsm/utils/ColorUtils.js +76 -0
- package/examples/jsm/utils/SkeletonUtils.js +14 -8
- package/examples/jsm/webxr/XRHandMeshModel.js +36 -10
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -1
- package/package.json +4 -4
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +6 -0
- package/src/Three.WebGPU.Nodes.js +3 -0
- package/src/Three.WebGPU.js +6 -0
- package/src/animation/AnimationAction.js +11 -1
- package/src/audio/AudioContext.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +13 -1
- package/src/core/Clock.js +1 -1
- package/src/core/Object3D.js +1 -5
- package/src/core/RenderTarget.js +1 -0
- package/src/extras/PMREMGenerator.js +1 -1
- package/src/extras/curves/CatmullRomCurve3.js +3 -2
- package/src/loaders/AudioLoader.js +11 -1
- package/src/loaders/DataTextureLoader.js +6 -4
- package/src/loaders/FileLoader.js +1 -2
- package/src/loaders/ImageBitmapLoader.js +4 -6
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/loaders/ObjectLoader.js +25 -4
- package/src/loaders/nodes/NodeObjectLoader.js +18 -0
- package/src/materials/MeshToonMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +27 -0
- package/src/materials/nodes/NodeMaterial.js +0 -27
- package/src/materials/nodes/manager/NodeMaterialObserver.js +188 -89
- package/src/math/Line3.js +3 -0
- package/src/math/Matrix2.js +13 -9
- package/src/math/Matrix3.js +13 -9
- package/src/math/Matrix4.js +13 -9
- package/src/math/Plane.js +4 -3
- package/src/math/Triangle.js +1 -1
- package/src/math/Vector2.js +11 -7
- package/src/math/Vector3.js +12 -8
- package/src/math/Vector4.js +13 -9
- package/src/nodes/Nodes.js +0 -1
- package/src/nodes/TSL.js +1 -1
- package/src/nodes/accessors/BufferAttributeNode.js +9 -3
- package/src/nodes/accessors/CubeTextureNode.js +7 -1
- package/src/nodes/accessors/MaterialProperties.js +2 -5
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/ReferenceBaseNode.js +2 -2
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/SceneProperties.js +2 -8
- package/src/nodes/accessors/StorageBufferNode.js +10 -4
- package/src/nodes/accessors/StorageTextureNode.js +4 -9
- package/src/nodes/accessors/TextureNode.js +10 -2
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/code/FunctionCallNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +1 -1
- package/src/nodes/core/ArrayNode.js +1 -1
- package/src/nodes/core/AssignNode.js +1 -1
- package/src/nodes/core/AttributeNode.js +1 -1
- package/src/nodes/core/BypassNode.js +1 -1
- package/src/nodes/core/ContextNode.js +1 -1
- package/src/nodes/core/IndexNode.js +2 -1
- package/src/nodes/core/InputNode.js +1 -1
- package/src/nodes/core/InspectorNode.js +1 -1
- package/src/nodes/core/IsolateNode.js +1 -1
- package/src/nodes/core/Node.js +83 -12
- package/src/nodes/core/NodeBuilder.js +117 -16
- package/src/nodes/core/NodeUtils.js +1 -1
- package/src/nodes/core/OutputStructNode.js +1 -1
- package/src/nodes/core/ParameterNode.js +1 -1
- package/src/nodes/core/StackNode.js +1 -1
- package/src/nodes/core/StructNode.js +1 -1
- package/src/nodes/core/StructTypeNode.js +1 -1
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformGroupNode.js +36 -6
- package/src/nodes/core/VarNode.js +1 -1
- package/src/nodes/core/VaryingNode.js +1 -1
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +27 -7
- package/src/nodes/display/RenderOutputNode.js +4 -4
- package/src/nodes/display/ScreenNode.js +1 -1
- package/src/nodes/display/ViewportDepthTextureNode.js +11 -15
- package/src/nodes/display/ViewportTextureNode.js +18 -7
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/geometry/RangeNode.js +1 -1
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/BarrierNode.js +9 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +69 -44
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/lighting/LightsNode.js +6 -27
- package/src/nodes/lighting/ShadowNode.js +24 -2
- package/src/nodes/math/BitcastNode.js +1 -1
- package/src/nodes/math/ConditionalNode.js +1 -1
- package/src/nodes/math/MathNode.js +73 -1
- package/src/nodes/math/OperatorNode.js +1 -1
- package/src/nodes/math/PackFloatNode.js +1 -1
- package/src/nodes/math/UnpackFloatNode.js +1 -1
- package/src/nodes/tsl/TSLBase.js +1 -1
- package/src/nodes/tsl/TSLCore.js +21 -3
- package/src/nodes/utils/ArrayElementNode.js +1 -1
- package/src/nodes/utils/ConvertNode.js +1 -1
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +30 -0
- package/src/nodes/utils/FlipNode.js +1 -1
- package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
- package/src/nodes/utils/JoinNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/Remap.js +48 -0
- package/src/nodes/utils/RotateNode.js +1 -1
- package/src/nodes/utils/SetNode.js +1 -1
- package/src/nodes/utils/SplitNode.js +1 -1
- package/src/objects/BatchedMesh.js +17 -2
- package/src/objects/InstancedMesh.js +19 -3
- package/src/objects/SkinnedMesh.js +26 -9
- package/src/renderers/WebGLRenderer.js +148 -49
- package/src/renderers/common/Animation.js +3 -3
- package/src/renderers/common/Attributes.js +15 -1
- package/src/renderers/common/Backend.js +0 -8
- package/src/renderers/common/Background.js +2 -2
- package/src/renderers/common/BindGroup.js +1 -8
- package/src/renderers/common/Bindings.js +2 -2
- package/src/renderers/common/ComputePipeline.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/Info.js +333 -4
- package/src/renderers/common/InspectorBase.js +6 -1
- package/src/renderers/common/Pipelines.js +36 -3
- package/src/renderers/common/ReadbackBuffer.js +78 -0
- package/src/renderers/common/RenderBundle.js +3 -1
- package/src/renderers/common/RenderBundles.js +5 -2
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/RenderObjects.js +3 -3
- package/src/renderers/common/RenderPipeline.js +35 -6
- package/src/renderers/common/Renderer.js +232 -53
- package/src/renderers/common/Textures.js +72 -3
- package/src/renderers/common/UniformsGroup.js +1 -1
- package/src/renderers/common/XRManager.js +34 -27
- package/src/renderers/common/extras/PMREMGenerator.js +23 -15
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeManager.js +230 -99
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +2 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -3
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +12 -2
- package/src/renderers/shaders/ShaderChunk.js +2 -0
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib.js +0 -1
- package/src/renderers/shaders/UniformsLib.js +7 -2
- package/src/renderers/shaders/UniformsUtils.js +27 -5
- package/src/renderers/webgl/WebGLAnimation.js +2 -1
- package/src/renderers/webgl/WebGLBackground.js +13 -13
- package/src/renderers/webgl/WebGLBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLCapabilities.js +6 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLMaterials.js +12 -13
- package/src/renderers/webgl/WebGLOutput.js +4 -1
- package/src/renderers/webgl/WebGLProgram.js +5 -0
- package/src/renderers/webgl/WebGLPrograms.js +24 -3
- package/src/renderers/webgl/WebGLRenderStates.js +13 -2
- package/src/renderers/webgl/WebGLState.js +43 -0
- package/src/renderers/webgl/WebGLTextures.js +129 -26
- package/src/renderers/webgl/WebGLUniformsGroups.js +19 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +106 -65
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +0 -41
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +29 -51
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +53 -19
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +25 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +42 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +63 -50
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +1 -1
- package/src/renderers/webgpu/WebGPUBackend.js +160 -146
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +55 -33
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +103 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
- package/src/renderers/webgpu/utils/WebGPUConstants.js +8 -0
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +91 -17
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -2
- package/src/renderers/webxr/WebXRController.js +12 -0
- package/src/textures/HTMLTexture.js +74 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +13 -2
- package/src/utils.js +23 -1
- package/src/nodes/utils/RemapNode.js +0 -125
|
@@ -10,12 +10,15 @@ import Backend from '../common/Backend.js';
|
|
|
10
10
|
import WebGPUUtils from './utils/WebGPUUtils.js';
|
|
11
11
|
import WebGPUAttributeUtils from './utils/WebGPUAttributeUtils.js';
|
|
12
12
|
import WebGPUBindingUtils from './utils/WebGPUBindingUtils.js';
|
|
13
|
+
import WebGPUCapabilities from './utils/WebGPUCapabilities.js';
|
|
13
14
|
import WebGPUPipelineUtils from './utils/WebGPUPipelineUtils.js';
|
|
14
15
|
import WebGPUTextureUtils from './utils/WebGPUTextureUtils.js';
|
|
15
16
|
|
|
16
17
|
import { WebGPUCoordinateSystem, TimestampQuery, REVISION, HalfFloatType, Compatibility } from '../../constants.js';
|
|
17
18
|
import WebGPUTimestampQueryPool from './utils/WebGPUTimestampQueryPool.js';
|
|
18
|
-
import {
|
|
19
|
+
import { error } from '../../utils.js';
|
|
20
|
+
|
|
21
|
+
const _clearValue = { r: 0, g: 0, b: 0, a: 1 };
|
|
19
22
|
|
|
20
23
|
/**
|
|
21
24
|
* A backend implementation targeting WebGPU.
|
|
@@ -116,6 +119,14 @@ class WebGPUBackend extends Backend {
|
|
|
116
119
|
*/
|
|
117
120
|
this.bindingUtils = new WebGPUBindingUtils( this );
|
|
118
121
|
|
|
122
|
+
/**
|
|
123
|
+
* A reference to a backend module holding device capability related
|
|
124
|
+
* utility functions.
|
|
125
|
+
*
|
|
126
|
+
* @type {WebGPUCapabilities}
|
|
127
|
+
*/
|
|
128
|
+
this.capabilities = new WebGPUCapabilities( this );
|
|
129
|
+
|
|
119
130
|
/**
|
|
120
131
|
* A reference to a backend module holding shader pipeline-related
|
|
121
132
|
* utility functions.
|
|
@@ -314,15 +325,20 @@ class WebGPUBackend extends Backend {
|
|
|
314
325
|
|
|
315
326
|
/**
|
|
316
327
|
* This method performs a readback operation by moving buffer data from
|
|
317
|
-
* a storage buffer attribute from the GPU to the CPU.
|
|
328
|
+
* a storage buffer attribute from the GPU to the CPU. ReadbackBuffer can
|
|
329
|
+
* be used to retain and reuse handles to the intermediate buffers and prevent
|
|
330
|
+
* new allocation.
|
|
318
331
|
*
|
|
319
332
|
* @async
|
|
320
|
-
* @param {
|
|
321
|
-
* @
|
|
333
|
+
* @param {BufferAttribute} attribute - The storage buffer attribute to read frm.
|
|
334
|
+
* @param {number} count - The offset from which to start reading the
|
|
335
|
+
* @param {number} offset - The storage buffer attribute.
|
|
336
|
+
* @param {ReadbackBuffer|ArrayBuffer} target - The storage buffer attribute.
|
|
337
|
+
* @return {Promise<ArrayBuffer|ReadbackBuffer>} A promise that resolves with the buffer data when the data are ready.
|
|
322
338
|
*/
|
|
323
|
-
async getArrayBufferAsync( attribute ) {
|
|
339
|
+
async getArrayBufferAsync( attribute, target = null, offset = 0, count = - 1 ) {
|
|
324
340
|
|
|
325
|
-
return await this.attributeUtils.getArrayBufferAsync( attribute );
|
|
341
|
+
return await this.attributeUtils.getArrayBufferAsync( attribute, target, offset, count );
|
|
326
342
|
|
|
327
343
|
}
|
|
328
344
|
|
|
@@ -673,7 +689,21 @@ class WebGPUBackend extends Backend {
|
|
|
673
689
|
|
|
674
690
|
if ( renderContext.clearColor ) {
|
|
675
691
|
|
|
676
|
-
|
|
692
|
+
if ( i === 0 ) {
|
|
693
|
+
|
|
694
|
+
colorAttachment.clearValue = renderContext.clearColorValue;
|
|
695
|
+
|
|
696
|
+
} else {
|
|
697
|
+
|
|
698
|
+
_clearValue.r = 0;
|
|
699
|
+
_clearValue.g = 0;
|
|
700
|
+
_clearValue.b = 0;
|
|
701
|
+
_clearValue.a = 1;
|
|
702
|
+
|
|
703
|
+
colorAttachment.clearValue = _clearValue;
|
|
704
|
+
|
|
705
|
+
}
|
|
706
|
+
|
|
677
707
|
colorAttachment.loadOp = GPULoadOp.Clear;
|
|
678
708
|
|
|
679
709
|
} else {
|
|
@@ -1215,7 +1245,6 @@ class WebGPUBackend extends Backend {
|
|
|
1215
1245
|
|
|
1216
1246
|
let colorAttachments = [];
|
|
1217
1247
|
let depthStencilAttachment;
|
|
1218
|
-
let clearValue;
|
|
1219
1248
|
|
|
1220
1249
|
let supportsDepth;
|
|
1221
1250
|
let supportsStencil;
|
|
@@ -1223,7 +1252,11 @@ class WebGPUBackend extends Backend {
|
|
|
1223
1252
|
if ( color ) {
|
|
1224
1253
|
|
|
1225
1254
|
const clearColor = this.getClearColor();
|
|
1226
|
-
|
|
1255
|
+
|
|
1256
|
+
_clearValue.r = clearColor.r;
|
|
1257
|
+
_clearValue.g = clearColor.g;
|
|
1258
|
+
_clearValue.b = clearColor.b;
|
|
1259
|
+
_clearValue.a = clearColor.a;
|
|
1227
1260
|
|
|
1228
1261
|
}
|
|
1229
1262
|
|
|
@@ -1240,7 +1273,7 @@ class WebGPUBackend extends Backend {
|
|
|
1240
1273
|
|
|
1241
1274
|
const colorAttachment = colorAttachments[ 0 ];
|
|
1242
1275
|
|
|
1243
|
-
colorAttachment.clearValue =
|
|
1276
|
+
colorAttachment.clearValue = _clearValue;
|
|
1244
1277
|
colorAttachment.loadOp = GPULoadOp.Clear;
|
|
1245
1278
|
colorAttachment.storeOp = GPUStoreOp.Store;
|
|
1246
1279
|
|
|
@@ -1259,7 +1292,7 @@ class WebGPUBackend extends Backend {
|
|
|
1259
1292
|
|
|
1260
1293
|
const clearConfig = {
|
|
1261
1294
|
loadOp: color ? GPULoadOp.Clear : GPULoadOp.Load,
|
|
1262
|
-
clearValue: color ?
|
|
1295
|
+
clearValue: color ? _clearValue : undefined
|
|
1263
1296
|
};
|
|
1264
1297
|
|
|
1265
1298
|
if ( supportsDepth ) {
|
|
@@ -1397,13 +1430,13 @@ class WebGPUBackend extends Backend {
|
|
|
1397
1430
|
|
|
1398
1431
|
if ( dispatchSize === null ) {
|
|
1399
1432
|
|
|
1400
|
-
dispatchSize = computeNode.count;
|
|
1433
|
+
dispatchSize = computeNode.dispatchSize || computeNode.count;
|
|
1401
1434
|
|
|
1402
1435
|
}
|
|
1403
1436
|
|
|
1404
1437
|
// When the dispatchSize is set with a StorageBuffer from the GPU.
|
|
1405
1438
|
|
|
1406
|
-
if ( dispatchSize &&
|
|
1439
|
+
if ( dispatchSize && dispatchSize.isIndirectStorageBufferAttribute ) {
|
|
1407
1440
|
|
|
1408
1441
|
const dispatchBuffer = this.get( dispatchSize ).buffer;
|
|
1409
1442
|
|
|
@@ -1482,204 +1515,201 @@ class WebGPUBackend extends Backend {
|
|
|
1482
1515
|
|
|
1483
1516
|
}
|
|
1484
1517
|
|
|
1485
|
-
// render object
|
|
1486
|
-
|
|
1487
1518
|
/**
|
|
1488
|
-
*
|
|
1519
|
+
* Internal draw function that performs the draw with the given pass encoder.
|
|
1489
1520
|
*
|
|
1490
|
-
* @
|
|
1521
|
+
* @private
|
|
1522
|
+
* @param {RenderObject} renderObject - The render object.
|
|
1491
1523
|
* @param {Info} info - Holds a series of statistical information about the GPU memory and the rendering process.
|
|
1524
|
+
* @param {Object} renderContextData - The render context data object, holding current pass state and occlusion query tracking.
|
|
1525
|
+
* @param {GPURenderPipeline} pipelineGPU - The GPU render pipeline.
|
|
1526
|
+
* @param {Array<BindGroup>} bindings - The bind groups.
|
|
1527
|
+
* @param {Array<BufferAttribute>} vertexBuffers - The vertex buffers.
|
|
1528
|
+
* @param {{vertexCount: number, firstVertex: number, instanceCount: number, firstInstance: number}} drawParams - The draw parameters.
|
|
1529
|
+
* @param {GPURenderPassEncoder|GPURenderBundleEncoder} passEncoderGPU - The GPU pass encoder used for recording draw commands.
|
|
1530
|
+
* @param {Object} currentSets - Tracking object for currently set pipeline, attributes, bind groups, and index state.
|
|
1492
1531
|
*/
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
const { object, material, context, pipeline } = renderObject;
|
|
1496
|
-
const bindings = renderObject.getBindings();
|
|
1497
|
-
const renderContextData = this.get( context );
|
|
1498
|
-
const pipelineData = this.get( pipeline );
|
|
1499
|
-
const pipelineGPU = pipelineData.pipeline;
|
|
1532
|
+
_draw( renderObject, info, renderContextData, pipelineGPU, bindings, vertexBuffers, drawParams, passEncoderGPU, currentSets ) {
|
|
1500
1533
|
|
|
1501
|
-
|
|
1534
|
+
const { object, material, context } = renderObject;
|
|
1502
1535
|
|
|
1503
1536
|
const index = renderObject.getIndex();
|
|
1504
1537
|
const hasIndex = ( index !== null );
|
|
1505
1538
|
|
|
1506
|
-
|
|
1507
|
-
const drawParams = renderObject.getDrawParameters();
|
|
1508
|
-
if ( drawParams === null ) return;
|
|
1509
|
-
|
|
1510
1539
|
// pipeline
|
|
1540
|
+
this.pipelineUtils.setPipeline( passEncoderGPU, pipelineGPU );
|
|
1541
|
+
currentSets.pipeline = pipelineGPU;
|
|
1511
1542
|
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
this.pipelineUtils.setPipeline( passEncoderGPU, pipelineGPU );
|
|
1516
|
-
currentSets.pipeline = pipelineGPU;
|
|
1517
|
-
|
|
1518
|
-
// bind groups
|
|
1519
|
-
const currentBindingGroups = currentSets.bindingGroups;
|
|
1520
|
-
for ( let i = 0, l = bindings.length; i < l; i ++ ) {
|
|
1521
|
-
|
|
1522
|
-
const bindGroup = bindings[ i ];
|
|
1523
|
-
const bindingsData = this.get( bindGroup );
|
|
1524
|
-
if ( currentBindingGroups[ bindGroup.index ] !== bindGroup.id ) {
|
|
1543
|
+
// bind groups
|
|
1544
|
+
const currentBindingGroups = currentSets.bindingGroups;
|
|
1545
|
+
for ( let i = 0, l = bindings.length; i < l; i ++ ) {
|
|
1525
1546
|
|
|
1526
|
-
|
|
1527
|
-
|
|
1547
|
+
const bindGroup = bindings[ i ];
|
|
1548
|
+
const bindingsData = this.get( bindGroup );
|
|
1549
|
+
if ( currentBindingGroups[ i ] !== bindGroup.id ) {
|
|
1528
1550
|
|
|
1529
|
-
|
|
1551
|
+
passEncoderGPU.setBindGroup( i, bindingsData.group );
|
|
1552
|
+
currentBindingGroups[ i ] = bindGroup.id;
|
|
1530
1553
|
|
|
1531
1554
|
}
|
|
1532
1555
|
|
|
1533
|
-
|
|
1556
|
+
}
|
|
1534
1557
|
|
|
1535
|
-
|
|
1558
|
+
// attributes
|
|
1536
1559
|
|
|
1537
|
-
|
|
1560
|
+
// index
|
|
1538
1561
|
|
|
1539
|
-
|
|
1562
|
+
if ( hasIndex === true ) {
|
|
1540
1563
|
|
|
1541
|
-
|
|
1542
|
-
const indexFormat = ( index.array instanceof Uint16Array ) ? GPUIndexFormat.Uint16 : GPUIndexFormat.Uint32;
|
|
1564
|
+
if ( currentSets.index !== index ) {
|
|
1543
1565
|
|
|
1544
|
-
|
|
1566
|
+
const buffer = this.get( index ).buffer;
|
|
1567
|
+
const indexFormat = ( index.array instanceof Uint16Array ) ? GPUIndexFormat.Uint16 : GPUIndexFormat.Uint32;
|
|
1545
1568
|
|
|
1546
|
-
|
|
1569
|
+
passEncoderGPU.setIndexBuffer( buffer, indexFormat );
|
|
1547
1570
|
|
|
1548
|
-
|
|
1571
|
+
currentSets.index = index;
|
|
1549
1572
|
|
|
1550
1573
|
}
|
|
1551
|
-
// vertex buffers
|
|
1552
|
-
|
|
1553
|
-
const vertexBuffers = renderObject.getVertexBuffers();
|
|
1554
1574
|
|
|
1555
|
-
|
|
1575
|
+
}
|
|
1556
1576
|
|
|
1557
|
-
|
|
1577
|
+
for ( let i = 0, l = vertexBuffers.length; i < l; i ++ ) {
|
|
1558
1578
|
|
|
1559
|
-
|
|
1579
|
+
const vertexBuffer = vertexBuffers[ i ];
|
|
1560
1580
|
|
|
1561
|
-
|
|
1562
|
-
passEncoderGPU.setVertexBuffer( i, buffer );
|
|
1581
|
+
if ( currentSets.attributes[ i ] !== vertexBuffer ) {
|
|
1563
1582
|
|
|
1564
|
-
|
|
1583
|
+
const buffer = this.get( vertexBuffer ).buffer;
|
|
1584
|
+
passEncoderGPU.setVertexBuffer( i, buffer );
|
|
1565
1585
|
|
|
1566
|
-
|
|
1586
|
+
currentSets.attributes[ i ] = vertexBuffer;
|
|
1567
1587
|
|
|
1568
1588
|
}
|
|
1569
|
-
// stencil
|
|
1570
1589
|
|
|
1571
|
-
|
|
1590
|
+
}
|
|
1591
|
+
// stencil
|
|
1572
1592
|
|
|
1573
|
-
|
|
1574
|
-
renderContextData.currentStencilRef = material.stencilRef;
|
|
1593
|
+
if ( context.stencil === true && material.stencilWrite === true && renderContextData.currentStencilRef !== material.stencilRef ) {
|
|
1575
1594
|
|
|
1576
|
-
|
|
1595
|
+
passEncoderGPU.setStencilReference( material.stencilRef );
|
|
1596
|
+
renderContextData.currentStencilRef = material.stencilRef;
|
|
1577
1597
|
|
|
1598
|
+
}
|
|
1578
1599
|
|
|
1579
|
-
|
|
1600
|
+
if ( object.isBatchedMesh === true ) {
|
|
1580
1601
|
|
|
1581
|
-
|
|
1582
|
-
|
|
1602
|
+
const starts = object._multiDrawStarts;
|
|
1603
|
+
const counts = object._multiDrawCounts;
|
|
1604
|
+
const drawCount = object._multiDrawCount;
|
|
1583
1605
|
|
|
1584
|
-
|
|
1606
|
+
let bytesPerElement = ( hasIndex === true ) ? index.array.BYTES_PER_ELEMENT : 1;
|
|
1585
1607
|
|
|
1586
|
-
if (
|
|
1608
|
+
if ( material.wireframe ) {
|
|
1587
1609
|
|
|
1588
|
-
|
|
1589
|
-
const counts = object._multiDrawCounts;
|
|
1590
|
-
const drawCount = object._multiDrawCount;
|
|
1591
|
-
const drawInstances = object._multiDrawInstances;
|
|
1610
|
+
bytesPerElement = object.geometry.attributes.position.count > 65535 ? 4 : 2;
|
|
1592
1611
|
|
|
1593
|
-
|
|
1612
|
+
}
|
|
1594
1613
|
|
|
1595
|
-
|
|
1596
|
-
warnOnce( 'WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.' );
|
|
1614
|
+
for ( let i = 0; i < drawCount; i ++ ) {
|
|
1597
1615
|
|
|
1598
|
-
|
|
1616
|
+
if ( hasIndex === true ) {
|
|
1599
1617
|
|
|
1600
|
-
|
|
1618
|
+
passEncoderGPU.drawIndexed( counts[ i ], 1, starts[ i ] / bytesPerElement, 0, i );
|
|
1601
1619
|
|
|
1602
|
-
|
|
1620
|
+
} else {
|
|
1603
1621
|
|
|
1604
|
-
|
|
1622
|
+
passEncoderGPU.draw( counts[ i ], 1, starts[ i ], i );
|
|
1605
1623
|
|
|
1606
1624
|
}
|
|
1607
1625
|
|
|
1608
|
-
|
|
1626
|
+
info.update( object, counts[ i ], 1 );
|
|
1609
1627
|
|
|
1610
|
-
|
|
1611
|
-
const firstInstance = count > 1 ? 0 : i;
|
|
1628
|
+
}
|
|
1612
1629
|
|
|
1613
|
-
|
|
1630
|
+
} else if ( hasIndex === true ) {
|
|
1614
1631
|
|
|
1615
|
-
|
|
1632
|
+
const { vertexCount: indexCount, instanceCount, firstVertex: firstIndex } = drawParams;
|
|
1616
1633
|
|
|
1617
|
-
|
|
1634
|
+
const indirect = renderObject.getIndirect();
|
|
1618
1635
|
|
|
1619
|
-
|
|
1636
|
+
if ( indirect !== null ) {
|
|
1620
1637
|
|
|
1621
|
-
|
|
1638
|
+
const buffer = this.get( indirect ).buffer;
|
|
1639
|
+
const indirectOffset = renderObject.getIndirectOffset();
|
|
1640
|
+
const indirectOffsets = Array.isArray( indirectOffset ) ? indirectOffset : [ indirectOffset ];
|
|
1641
|
+
|
|
1642
|
+
for ( let i = 0; i < indirectOffsets.length; i ++ ) {
|
|
1622
1643
|
|
|
1623
|
-
|
|
1644
|
+
passEncoderGPU.drawIndexedIndirect( buffer, indirectOffsets[ i ] );
|
|
1624
1645
|
|
|
1625
1646
|
}
|
|
1626
1647
|
|
|
1627
|
-
} else
|
|
1648
|
+
} else {
|
|
1649
|
+
|
|
1650
|
+
passEncoderGPU.drawIndexed( indexCount, instanceCount, firstIndex, 0, 0 );
|
|
1628
1651
|
|
|
1629
|
-
|
|
1652
|
+
}
|
|
1630
1653
|
|
|
1631
|
-
|
|
1654
|
+
info.update( object, indexCount, instanceCount );
|
|
1632
1655
|
|
|
1633
|
-
|
|
1656
|
+
} else {
|
|
1634
1657
|
|
|
1635
|
-
|
|
1636
|
-
const indirectOffset = renderObject.getIndirectOffset();
|
|
1637
|
-
const indirectOffsets = Array.isArray( indirectOffset ) ? indirectOffset : [ indirectOffset ];
|
|
1658
|
+
const { vertexCount, instanceCount, firstVertex } = drawParams;
|
|
1638
1659
|
|
|
1639
|
-
|
|
1660
|
+
const indirect = renderObject.getIndirect();
|
|
1640
1661
|
|
|
1641
|
-
|
|
1662
|
+
if ( indirect !== null ) {
|
|
1642
1663
|
|
|
1643
|
-
|
|
1664
|
+
const buffer = this.get( indirect ).buffer;
|
|
1665
|
+
const indirectOffset = renderObject.getIndirectOffset();
|
|
1666
|
+
const indirectOffsets = Array.isArray( indirectOffset ) ? indirectOffset : [ indirectOffset ];
|
|
1644
1667
|
|
|
1645
|
-
|
|
1668
|
+
for ( let i = 0; i < indirectOffsets.length; i ++ ) {
|
|
1646
1669
|
|
|
1647
|
-
passEncoderGPU.
|
|
1670
|
+
passEncoderGPU.drawIndirect( buffer, indirectOffsets[ i ] );
|
|
1648
1671
|
|
|
1649
1672
|
}
|
|
1650
1673
|
|
|
1651
|
-
info.update( object, indexCount, instanceCount );
|
|
1652
1674
|
|
|
1653
1675
|
} else {
|
|
1654
1676
|
|
|
1655
|
-
|
|
1677
|
+
passEncoderGPU.draw( vertexCount, instanceCount, firstVertex, 0 );
|
|
1656
1678
|
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
if ( indirect !== null ) {
|
|
1679
|
+
}
|
|
1660
1680
|
|
|
1661
|
-
|
|
1662
|
-
const indirectOffset = renderObject.getIndirectOffset();
|
|
1663
|
-
const indirectOffsets = Array.isArray( indirectOffset ) ? indirectOffset : [ indirectOffset ];
|
|
1681
|
+
info.update( object, vertexCount, instanceCount );
|
|
1664
1682
|
|
|
1665
|
-
|
|
1683
|
+
}
|
|
1666
1684
|
|
|
1667
|
-
|
|
1685
|
+
}
|
|
1668
1686
|
|
|
1669
|
-
|
|
1687
|
+
// render object
|
|
1670
1688
|
|
|
1689
|
+
/**
|
|
1690
|
+
* Executes a draw command for the given render object.
|
|
1691
|
+
*
|
|
1692
|
+
* @param {RenderObject} renderObject - The render object to draw.
|
|
1693
|
+
* @param {Info} info - Holds a series of statistical information about the GPU memory and the rendering process.
|
|
1694
|
+
*/
|
|
1695
|
+
draw( renderObject, info ) {
|
|
1671
1696
|
|
|
1672
|
-
|
|
1697
|
+
const { object, context, pipeline } = renderObject;
|
|
1698
|
+
const renderContextData = this.get( context );
|
|
1699
|
+
const pipelineData = this.get( pipeline );
|
|
1700
|
+
const pipelineGPU = pipelineData.pipeline;
|
|
1673
1701
|
|
|
1674
|
-
|
|
1702
|
+
// Skip if pipeline has error
|
|
1703
|
+
if ( pipelineData.error === true ) return;
|
|
1675
1704
|
|
|
1676
|
-
|
|
1705
|
+
const drawParams = renderObject.getDrawParameters();
|
|
1706
|
+
if ( drawParams === null ) return;
|
|
1677
1707
|
|
|
1678
|
-
|
|
1708
|
+
const bindings = renderObject.getBindings();
|
|
1679
1709
|
|
|
1680
|
-
|
|
1710
|
+
// vertex buffers
|
|
1681
1711
|
|
|
1682
|
-
|
|
1712
|
+
const vertexBuffers = renderObject.getVertexBuffers();
|
|
1683
1713
|
|
|
1684
1714
|
if ( renderObject.camera.isArrayCamera && renderObject.camera.cameras.length > 0 ) {
|
|
1685
1715
|
|
|
@@ -1720,8 +1750,6 @@ class WebGPUBackend extends Backend {
|
|
|
1720
1750
|
|
|
1721
1751
|
const vp = subCamera.viewport;
|
|
1722
1752
|
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
1753
|
let pass = renderContextData.currentPass;
|
|
1726
1754
|
let sets = renderContextData.currentSets;
|
|
1727
1755
|
if ( renderContextData.bundleEncoders ) {
|
|
@@ -1733,8 +1761,6 @@ class WebGPUBackend extends Backend {
|
|
|
1733
1761
|
|
|
1734
1762
|
}
|
|
1735
1763
|
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
1764
|
if ( vp ) {
|
|
1739
1765
|
|
|
1740
1766
|
pass.setViewport(
|
|
@@ -1748,17 +1774,16 @@ class WebGPUBackend extends Backend {
|
|
|
1748
1774
|
|
|
1749
1775
|
}
|
|
1750
1776
|
|
|
1751
|
-
|
|
1752
1777
|
// Set camera index binding for this layer
|
|
1753
1778
|
if ( cameraIndex && cameraData.indexesGPU ) {
|
|
1754
1779
|
|
|
1755
|
-
|
|
1756
|
-
|
|
1780
|
+
const indexPos = bindings.indexOf( cameraIndex );
|
|
1781
|
+
pass.setBindGroup( indexPos, cameraData.indexesGPU[ i ] );
|
|
1782
|
+
sets.bindingGroups[ indexPos ] = cameraIndex.id;
|
|
1757
1783
|
|
|
1758
1784
|
}
|
|
1759
1785
|
|
|
1760
|
-
|
|
1761
|
-
|
|
1786
|
+
this._draw( renderObject, info, renderContextData, pipelineGPU, bindings, vertexBuffers, drawParams, pass, sets );
|
|
1762
1787
|
|
|
1763
1788
|
}
|
|
1764
1789
|
|
|
@@ -1795,7 +1820,7 @@ class WebGPUBackend extends Backend {
|
|
|
1795
1820
|
|
|
1796
1821
|
}
|
|
1797
1822
|
|
|
1798
|
-
|
|
1823
|
+
this._draw( renderObject, info, renderContextData, pipelineGPU, bindings, vertexBuffers, drawParams, renderContextData.currentPass, renderContextData.currentSets );
|
|
1799
1824
|
|
|
1800
1825
|
}
|
|
1801
1826
|
|
|
@@ -2292,17 +2317,6 @@ class WebGPUBackend extends Backend {
|
|
|
2292
2317
|
|
|
2293
2318
|
// utils public
|
|
2294
2319
|
|
|
2295
|
-
/**
|
|
2296
|
-
* Returns the maximum anisotropy texture filtering value.
|
|
2297
|
-
*
|
|
2298
|
-
* @return {number} The maximum anisotropy texture filtering value.
|
|
2299
|
-
*/
|
|
2300
|
-
getMaxAnisotropy() {
|
|
2301
|
-
|
|
2302
|
-
return 16;
|
|
2303
|
-
|
|
2304
|
-
}
|
|
2305
|
-
|
|
2306
2320
|
/**
|
|
2307
2321
|
* Checks if the given feature is supported by the backend.
|
|
2308
2322
|
*
|
|
@@ -2538,9 +2552,9 @@ class WebGPUBackend extends Backend {
|
|
|
2538
2552
|
*/
|
|
2539
2553
|
hasCompatibility( name ) {
|
|
2540
2554
|
|
|
2541
|
-
if ( this._compatibility[
|
|
2555
|
+
if ( this._compatibility[ name ] !== undefined ) {
|
|
2542
2556
|
|
|
2543
|
-
return this._compatibility[
|
|
2557
|
+
return this._compatibility[ name ];
|
|
2544
2558
|
|
|
2545
2559
|
}
|
|
2546
2560
|
|