@plastic-software/three 0.183.4 → 0.184.1
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 +775 -287
- package/build/three.core.js +372 -110
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +428 -181
- 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/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 +147 -48
- 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/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 +4 -0
- package/src/renderers/webgl/WebGLPrograms.js +21 -4
- 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
|
@@ -271,7 +271,23 @@ class WebGLBackend extends Backend {
|
|
|
271
271
|
this.parallel = this.extensions.get( 'KHR_parallel_shader_compile' );
|
|
272
272
|
this.drawBuffersIndexedExt = this.extensions.get( 'OES_draw_buffers_indexed' );
|
|
273
273
|
|
|
274
|
-
if ( parameters.reversedDepthBuffer
|
|
274
|
+
if ( parameters.reversedDepthBuffer ) {
|
|
275
|
+
|
|
276
|
+
if ( this.extensions.has( 'EXT_clip_control' ) ) {
|
|
277
|
+
|
|
278
|
+
renderer.reversedDepthBuffer = true;
|
|
279
|
+
|
|
280
|
+
} else {
|
|
281
|
+
|
|
282
|
+
warn( 'WebGPURenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.' );
|
|
283
|
+
|
|
284
|
+
renderer.reversedDepthBuffer = false;
|
|
285
|
+
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if ( renderer.reversedDepthBuffer ) {
|
|
275
291
|
|
|
276
292
|
this.state.setReversedDepth( true );
|
|
277
293
|
|
|
@@ -293,15 +309,20 @@ class WebGLBackend extends Backend {
|
|
|
293
309
|
|
|
294
310
|
/**
|
|
295
311
|
* This method performs a readback operation by moving buffer data from
|
|
296
|
-
* a storage buffer attribute from the GPU to the CPU.
|
|
312
|
+
* a storage buffer attribute from the GPU to the CPU. ReadbackBuffer can
|
|
313
|
+
* be used to retain and reuse handles to the intermediate buffers and prevent
|
|
314
|
+
* new allocation.
|
|
297
315
|
*
|
|
298
316
|
* @async
|
|
299
|
-
* @param {
|
|
300
|
-
* @
|
|
317
|
+
* @param {BufferAttribute} attribute - The storage buffer attribute to read frm.
|
|
318
|
+
* @param {ReadbackBuffer|ArrayBuffer} target - The storage buffer attribute.
|
|
319
|
+
* @param {number} offset - The storage buffer attribute.
|
|
320
|
+
* @param {number} count - The offset from which to start reading the
|
|
321
|
+
* @return {Promise<ArrayBuffer|ReadbackBuffer>} A promise that resolves with the buffer data when the data are ready.
|
|
301
322
|
*/
|
|
302
|
-
async getArrayBufferAsync( attribute ) {
|
|
323
|
+
async getArrayBufferAsync( attribute, target = null, offset = 0, count = - 1 ) {
|
|
303
324
|
|
|
304
|
-
return await this.attributeUtils.getArrayBufferAsync( attribute );
|
|
325
|
+
return await this.attributeUtils.getArrayBufferAsync( attribute, target, offset, count );
|
|
305
326
|
|
|
306
327
|
}
|
|
307
328
|
|
|
@@ -966,6 +987,56 @@ class WebGLBackend extends Backend {
|
|
|
966
987
|
|
|
967
988
|
}
|
|
968
989
|
|
|
990
|
+
/**
|
|
991
|
+
* Internal draw function.
|
|
992
|
+
*
|
|
993
|
+
* @private
|
|
994
|
+
* @param {Object3D} object - The object to render.
|
|
995
|
+
* @param {WebGLBufferRenderer} renderer - The internal renderer.
|
|
996
|
+
* @param {number} firstVertex - The first vertex to render.
|
|
997
|
+
* @param {number} vertexCount - The vertex count.
|
|
998
|
+
* @param {number} instanceCount - The intance count.
|
|
999
|
+
* @param {WebGLProgram} programGPU - The raw WebGL shader program.
|
|
1000
|
+
*/
|
|
1001
|
+
_draw( object, renderer, firstVertex, vertexCount, instanceCount, programGPU ) {
|
|
1002
|
+
|
|
1003
|
+
if ( object.isBatchedMesh ) {
|
|
1004
|
+
|
|
1005
|
+
if ( this.hasFeature( 'WEBGL_multi_draw' ) === false ) {
|
|
1006
|
+
|
|
1007
|
+
const { gl } = this;
|
|
1008
|
+
|
|
1009
|
+
const drawIdLocation = gl.getUniformLocation( programGPU, 'nodeUniformDrawId' );
|
|
1010
|
+
|
|
1011
|
+
const starts = object._multiDrawStarts;
|
|
1012
|
+
const counts = object._multiDrawCounts;
|
|
1013
|
+
const drawCount = object._multiDrawCount;
|
|
1014
|
+
|
|
1015
|
+
for ( let i = 0; i < drawCount; i ++ ) {
|
|
1016
|
+
|
|
1017
|
+
gl.uniform1ui( drawIdLocation, i );
|
|
1018
|
+
renderer.render( starts[ i ], counts[ i ] );
|
|
1019
|
+
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
} else {
|
|
1023
|
+
|
|
1024
|
+
renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
|
|
1025
|
+
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
} else if ( instanceCount > 1 ) {
|
|
1029
|
+
|
|
1030
|
+
renderer.renderInstances( firstVertex, vertexCount, instanceCount );
|
|
1031
|
+
|
|
1032
|
+
} else {
|
|
1033
|
+
|
|
1034
|
+
renderer.render( firstVertex, vertexCount );
|
|
1035
|
+
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
}
|
|
1039
|
+
|
|
969
1040
|
/**
|
|
970
1041
|
* Executes a draw command for the given render object.
|
|
971
1042
|
*
|
|
@@ -1103,38 +1174,6 @@ class WebGLBackend extends Backend {
|
|
|
1103
1174
|
|
|
1104
1175
|
}
|
|
1105
1176
|
|
|
1106
|
-
const draw = () => {
|
|
1107
|
-
|
|
1108
|
-
if ( object.isBatchedMesh ) {
|
|
1109
|
-
|
|
1110
|
-
if ( object._multiDrawInstances !== null ) {
|
|
1111
|
-
|
|
1112
|
-
// @deprecated, r174
|
|
1113
|
-
warnOnce( 'WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.' );
|
|
1114
|
-
renderer.renderMultiDrawInstances( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount, object._multiDrawInstances );
|
|
1115
|
-
|
|
1116
|
-
} else if ( ! this.hasFeature( 'WEBGL_multi_draw' ) ) {
|
|
1117
|
-
|
|
1118
|
-
warnOnce( 'WebGLBackend: WEBGL_multi_draw not supported.' );
|
|
1119
|
-
|
|
1120
|
-
} else {
|
|
1121
|
-
|
|
1122
|
-
renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
|
|
1123
|
-
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
} else if ( instanceCount > 1 ) {
|
|
1127
|
-
|
|
1128
|
-
renderer.renderInstances( firstVertex, vertexCount, instanceCount );
|
|
1129
|
-
|
|
1130
|
-
} else {
|
|
1131
|
-
|
|
1132
|
-
renderer.render( firstVertex, vertexCount );
|
|
1133
|
-
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
};
|
|
1137
|
-
|
|
1138
1177
|
if ( renderObject.camera.isArrayCamera === true && renderObject.camera.cameras.length > 0 && renderObject.camera.isMultiViewCamera === false ) {
|
|
1139
1178
|
|
|
1140
1179
|
const cameraData = this.get( renderObject.camera );
|
|
@@ -1163,7 +1202,20 @@ class WebGLBackend extends Backend {
|
|
|
1163
1202
|
|
|
1164
1203
|
}
|
|
1165
1204
|
|
|
1166
|
-
|
|
1205
|
+
let cameraIndexBufferIndex = 0;
|
|
1206
|
+
|
|
1207
|
+
bindingsSearch: for ( const bindGroup of renderObject.getBindings() ) {
|
|
1208
|
+
|
|
1209
|
+
for ( const binding of bindGroup.bindings ) {
|
|
1210
|
+
|
|
1211
|
+
if ( binding === cameraIndex ) break bindingsSearch;
|
|
1212
|
+
|
|
1213
|
+
if ( binding.isUniformsGroup || binding.isUniformBuffer ) cameraIndexBufferIndex ++;
|
|
1214
|
+
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1167
1219
|
const pixelRatio = this.renderer.getPixelRatio();
|
|
1168
1220
|
|
|
1169
1221
|
const renderTarget = this._currentContext.renderTarget;
|
|
@@ -1232,9 +1284,9 @@ class WebGLBackend extends Backend {
|
|
|
1232
1284
|
|
|
1233
1285
|
}
|
|
1234
1286
|
|
|
1235
|
-
state.bindBufferBase( gl.UNIFORM_BUFFER,
|
|
1287
|
+
state.bindBufferBase( gl.UNIFORM_BUFFER, cameraIndexBufferIndex, cameraData.indexesGPU[ i ] );
|
|
1236
1288
|
|
|
1237
|
-
|
|
1289
|
+
this._draw( object, renderer, firstVertex, vertexCount, instanceCount, programGPU );
|
|
1238
1290
|
|
|
1239
1291
|
}
|
|
1240
1292
|
|
|
@@ -1245,7 +1297,7 @@ class WebGLBackend extends Backend {
|
|
|
1245
1297
|
|
|
1246
1298
|
} else {
|
|
1247
1299
|
|
|
1248
|
-
|
|
1300
|
+
this._draw( object, renderer, firstVertex, vertexCount, instanceCount, programGPU );
|
|
1249
1301
|
|
|
1250
1302
|
}
|
|
1251
1303
|
|
|
@@ -1618,7 +1670,8 @@ class WebGLBackend extends Backend {
|
|
|
1618
1670
|
//
|
|
1619
1671
|
|
|
1620
1672
|
this.set( pipeline, {
|
|
1621
|
-
programGPU
|
|
1673
|
+
programGPU,
|
|
1674
|
+
pipeline: programGPU
|
|
1622
1675
|
} );
|
|
1623
1676
|
|
|
1624
1677
|
}
|
|
@@ -1774,11 +1827,6 @@ class WebGLBackend extends Backend {
|
|
|
1774
1827
|
|
|
1775
1828
|
const { gl } = this;
|
|
1776
1829
|
|
|
1777
|
-
const bindGroupData = this.get( bindGroup );
|
|
1778
|
-
|
|
1779
|
-
let i = bindGroupData.uniformBuffers;
|
|
1780
|
-
let t = bindGroupData.textures;
|
|
1781
|
-
|
|
1782
1830
|
for ( const binding of bindGroup.bindings ) {
|
|
1783
1831
|
|
|
1784
1832
|
const map = this.get( binding );
|
|
@@ -1835,7 +1883,6 @@ class WebGLBackend extends Backend {
|
|
|
1835
1883
|
|
|
1836
1884
|
}
|
|
1837
1885
|
|
|
1838
|
-
map.index = i ++;
|
|
1839
1886
|
map.bufferGPU = bufferGPU;
|
|
1840
1887
|
|
|
1841
1888
|
this.set( binding, map );
|
|
@@ -1844,7 +1891,6 @@ class WebGLBackend extends Backend {
|
|
|
1844
1891
|
|
|
1845
1892
|
const { textureGPU, glTextureType } = this.get( binding.texture );
|
|
1846
1893
|
|
|
1847
|
-
map.index = t ++;
|
|
1848
1894
|
map.textureGPU = textureGPU;
|
|
1849
1895
|
map.glTextureType = glTextureType;
|
|
1850
1896
|
|
|
@@ -1992,17 +2038,6 @@ class WebGLBackend extends Backend {
|
|
|
1992
2038
|
|
|
1993
2039
|
}
|
|
1994
2040
|
|
|
1995
|
-
/**
|
|
1996
|
-
* Returns the maximum anisotropy texture filtering value.
|
|
1997
|
-
*
|
|
1998
|
-
* @return {number} The maximum anisotropy texture filtering value.
|
|
1999
|
-
*/
|
|
2000
|
-
getMaxAnisotropy() {
|
|
2001
|
-
|
|
2002
|
-
return this.capabilities.getMaxAnisotropy();
|
|
2003
|
-
|
|
2004
|
-
}
|
|
2005
|
-
|
|
2006
2041
|
/**
|
|
2007
2042
|
* Copies data of the given source texture to the given destination texture.
|
|
2008
2043
|
*
|
|
@@ -2530,20 +2565,22 @@ class WebGLBackend extends Backend {
|
|
|
2530
2565
|
|
|
2531
2566
|
const gl = this.gl;
|
|
2532
2567
|
|
|
2568
|
+
let uniformBuffers = 0;
|
|
2569
|
+
let textures = 0;
|
|
2570
|
+
|
|
2533
2571
|
for ( const bindGroup of bindings ) {
|
|
2534
2572
|
|
|
2535
2573
|
for ( const binding of bindGroup.bindings ) {
|
|
2536
2574
|
|
|
2537
|
-
const bindingData = this.get( binding );
|
|
2538
|
-
const index = bindingData.index;
|
|
2539
|
-
|
|
2540
2575
|
if ( binding.isUniformsGroup || binding.isUniformBuffer ) {
|
|
2541
2576
|
|
|
2577
|
+
const index = uniformBuffers ++;
|
|
2542
2578
|
const location = gl.getUniformBlockIndex( programGPU, binding.name );
|
|
2543
2579
|
gl.uniformBlockBinding( programGPU, location, index );
|
|
2544
2580
|
|
|
2545
2581
|
} else if ( binding.isSampledTexture ) {
|
|
2546
2582
|
|
|
2583
|
+
const index = textures ++;
|
|
2547
2584
|
const location = gl.getUniformLocation( programGPU, binding.name );
|
|
2548
2585
|
gl.uniform1i( location, index );
|
|
2549
2586
|
|
|
@@ -2565,20 +2602,24 @@ class WebGLBackend extends Backend {
|
|
|
2565
2602
|
|
|
2566
2603
|
const { gl, state } = this;
|
|
2567
2604
|
|
|
2605
|
+
let uniformBuffers = 0;
|
|
2606
|
+
let textures = 0;
|
|
2607
|
+
|
|
2568
2608
|
for ( const bindGroup of bindings ) {
|
|
2569
2609
|
|
|
2570
2610
|
for ( const binding of bindGroup.bindings ) {
|
|
2571
2611
|
|
|
2572
2612
|
const bindingData = this.get( binding );
|
|
2573
|
-
const index = bindingData.index;
|
|
2574
2613
|
|
|
2575
2614
|
if ( binding.isUniformsGroup || binding.isUniformBuffer ) {
|
|
2576
2615
|
|
|
2616
|
+
const index = uniformBuffers ++;
|
|
2577
2617
|
// TODO USE bindBufferRange to group multiple uniform buffers
|
|
2578
2618
|
state.bindBufferBase( gl.UNIFORM_BUFFER, index, bindingData.bufferGPU );
|
|
2579
2619
|
|
|
2580
2620
|
} else if ( binding.isSampledTexture ) {
|
|
2581
2621
|
|
|
2622
|
+
const index = textures ++;
|
|
2582
2623
|
state.bindTexture( bindingData.glTextureType, bindingData.textureGPU, gl.TEXTURE0 + index );
|
|
2583
2624
|
|
|
2584
2625
|
}
|
|
@@ -91,47 +91,6 @@ class WebGLBufferRenderer {
|
|
|
91
91
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
|
|
95
|
-
|
|
96
|
-
const { extensions, mode, object, info } = this;
|
|
97
|
-
|
|
98
|
-
if ( drawCount === 0 ) return;
|
|
99
|
-
|
|
100
|
-
const extension = extensions.get( 'WEBGL_multi_draw' );
|
|
101
|
-
|
|
102
|
-
if ( extension === null ) {
|
|
103
|
-
|
|
104
|
-
for ( let i = 0; i < drawCount; i ++ ) {
|
|
105
|
-
|
|
106
|
-
this.renderInstances( starts[ i ], counts[ i ], primcount[ i ] );
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
} else {
|
|
111
|
-
|
|
112
|
-
if ( this.index !== 0 ) {
|
|
113
|
-
|
|
114
|
-
extension.multiDrawElementsInstancedWEBGL( mode, counts, 0, this.type, starts, 0, primcount, 0, drawCount );
|
|
115
|
-
|
|
116
|
-
} else {
|
|
117
|
-
|
|
118
|
-
extension.multiDrawArraysInstancedWEBGL( mode, starts, 0, counts, 0, primcount, 0, drawCount );
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
let elementCount = 0;
|
|
123
|
-
for ( let i = 0; i < drawCount; i ++ ) {
|
|
124
|
-
|
|
125
|
-
elementCount += counts[ i ] * primcount[ i ];
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
info.update( object, elementCount, 1 );
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
94
|
//
|
|
136
95
|
|
|
137
96
|
}
|
|
@@ -478,11 +478,11 @@ ${ flowData.code }
|
|
|
478
478
|
|
|
479
479
|
if ( offsetSnippet ) {
|
|
480
480
|
|
|
481
|
-
snippet = `texelFetchOffset( ${ textureProperty }, ivec3( ${ uvIndexSnippet }, ${ depthSnippet } ), ${ levelSnippet }, ${ offsetSnippet } )`;
|
|
481
|
+
snippet = `texelFetchOffset( ${ textureProperty }, ivec3( ${ uvIndexSnippet }, ${ depthSnippet } ), int( ${ levelSnippet } ), ${ offsetSnippet } )`;
|
|
482
482
|
|
|
483
483
|
} else {
|
|
484
484
|
|
|
485
|
-
snippet = `texelFetch( ${ textureProperty }, ivec3( ${ uvIndexSnippet }, ${ depthSnippet } ), ${ levelSnippet } )`;
|
|
485
|
+
snippet = `texelFetch( ${ textureProperty }, ivec3( ${ uvIndexSnippet }, ${ depthSnippet } ), int( ${ levelSnippet } ) )`;
|
|
486
486
|
|
|
487
487
|
}
|
|
488
488
|
|
|
@@ -490,11 +490,11 @@ ${ flowData.code }
|
|
|
490
490
|
|
|
491
491
|
if ( offsetSnippet ) {
|
|
492
492
|
|
|
493
|
-
snippet = `texelFetchOffset( ${ textureProperty }, ${ uvIndexSnippet }, ${ levelSnippet }, ${ offsetSnippet } )`;
|
|
493
|
+
snippet = `texelFetchOffset( ${ textureProperty }, ${ uvIndexSnippet }, int( ${ levelSnippet } ), ${ offsetSnippet } )`;
|
|
494
494
|
|
|
495
495
|
} else {
|
|
496
496
|
|
|
497
|
-
snippet = `texelFetch( ${ textureProperty }, ${ uvIndexSnippet }, ${ levelSnippet } )`;
|
|
497
|
+
snippet = `texelFetch( ${ textureProperty }, ${ uvIndexSnippet }, int( ${ levelSnippet } ) )`;
|
|
498
498
|
|
|
499
499
|
}
|
|
500
500
|
|
|
@@ -665,32 +665,6 @@ ${ flowData.code }
|
|
|
665
665
|
|
|
666
666
|
}
|
|
667
667
|
|
|
668
|
-
/**
|
|
669
|
-
* Returns the variables of the given shader stage as a GLSL string.
|
|
670
|
-
*
|
|
671
|
-
* @param {string} shaderStage - The shader stage.
|
|
672
|
-
* @return {string} The GLSL snippet that defines the variables.
|
|
673
|
-
*/
|
|
674
|
-
getVars( shaderStage ) {
|
|
675
|
-
|
|
676
|
-
const snippets = [];
|
|
677
|
-
|
|
678
|
-
const vars = this.vars[ shaderStage ];
|
|
679
|
-
|
|
680
|
-
if ( vars !== undefined ) {
|
|
681
|
-
|
|
682
|
-
for ( const variable of vars ) {
|
|
683
|
-
|
|
684
|
-
snippets.push( `${ this.getVar( variable.type, variable.name, variable.count ) };` );
|
|
685
|
-
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
return snippets.join( '\n\t' );
|
|
691
|
-
|
|
692
|
-
}
|
|
693
|
-
|
|
694
668
|
/**
|
|
695
669
|
* Returns the uniforms of the given shader stage as a GLSL string.
|
|
696
670
|
*
|
|
@@ -1145,9 +1119,11 @@ ${ flowData.code }
|
|
|
1145
1119
|
|
|
1146
1120
|
return 'uint( gl_DrawID )';
|
|
1147
1121
|
|
|
1148
|
-
}
|
|
1122
|
+
} else {
|
|
1123
|
+
|
|
1124
|
+
return 'nodeUniformDrawId'; // fallback to uniform
|
|
1149
1125
|
|
|
1150
|
-
|
|
1126
|
+
}
|
|
1151
1127
|
|
|
1152
1128
|
}
|
|
1153
1129
|
|
|
@@ -1316,18 +1292,6 @@ ${ flowData.code }
|
|
|
1316
1292
|
|
|
1317
1293
|
}
|
|
1318
1294
|
|
|
1319
|
-
/**
|
|
1320
|
-
* Returns the maximum number of bytes available for uniform buffers.
|
|
1321
|
-
*
|
|
1322
|
-
* @return {number} The maximum number of bytes available for uniform buffers.
|
|
1323
|
-
*/
|
|
1324
|
-
getUniformBufferLimit() {
|
|
1325
|
-
|
|
1326
|
-
const gl = this.renderer.backend.gl;
|
|
1327
|
-
return gl.getParameter( gl.MAX_UNIFORM_BLOCK_SIZE );
|
|
1328
|
-
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
1295
|
/**
|
|
1332
1296
|
* Enables hardware clipping.
|
|
1333
1297
|
*
|
|
@@ -1435,14 +1399,14 @@ ${shaderData.varyings}
|
|
|
1435
1399
|
// attributes
|
|
1436
1400
|
${shaderData.attributes}
|
|
1437
1401
|
|
|
1402
|
+
// vars
|
|
1403
|
+
${shaderData.vars}
|
|
1404
|
+
|
|
1438
1405
|
// codes
|
|
1439
1406
|
${shaderData.codes}
|
|
1440
1407
|
|
|
1441
1408
|
void main() {
|
|
1442
1409
|
|
|
1443
|
-
// vars
|
|
1444
|
-
${shaderData.vars}
|
|
1445
|
-
|
|
1446
1410
|
// transforms
|
|
1447
1411
|
${shaderData.transforms}
|
|
1448
1412
|
|
|
@@ -1484,14 +1448,14 @@ ${shaderData.uniforms}
|
|
|
1484
1448
|
// varyings
|
|
1485
1449
|
${shaderData.varyings}
|
|
1486
1450
|
|
|
1451
|
+
// vars
|
|
1452
|
+
${shaderData.vars}
|
|
1453
|
+
|
|
1487
1454
|
// codes
|
|
1488
1455
|
${shaderData.codes}
|
|
1489
1456
|
|
|
1490
1457
|
void main() {
|
|
1491
1458
|
|
|
1492
|
-
// vars
|
|
1493
|
-
${shaderData.vars}
|
|
1494
|
-
|
|
1495
1459
|
// flow
|
|
1496
1460
|
${shaderData.flow}
|
|
1497
1461
|
|
|
@@ -1562,12 +1526,26 @@ void main() {
|
|
|
1562
1526
|
stageData.uniforms = this.getUniforms( shaderStage );
|
|
1563
1527
|
stageData.attributes = this.getAttributes( shaderStage );
|
|
1564
1528
|
stageData.varyings = this.getVaryings( shaderStage );
|
|
1565
|
-
stageData.vars = this.getVars( shaderStage );
|
|
1529
|
+
stageData.vars = this.getVars( shaderStage, true );
|
|
1566
1530
|
stageData.structs = this.getStructs( shaderStage );
|
|
1567
1531
|
stageData.codes = this.getCodes( shaderStage );
|
|
1568
1532
|
stageData.transforms = this.getTransforms( shaderStage );
|
|
1569
1533
|
stageData.flow = flow;
|
|
1570
1534
|
|
|
1535
|
+
// fallbacks
|
|
1536
|
+
|
|
1537
|
+
if ( shaderStage === 'vertex' ) {
|
|
1538
|
+
|
|
1539
|
+
const ext = this.renderer.backend.extensions;
|
|
1540
|
+
|
|
1541
|
+
if ( this.object.isBatchedMesh && ext.has( 'WEBGL_multi_draw' ) === false ) {
|
|
1542
|
+
|
|
1543
|
+
stageData.uniforms += '\nuniform uint nodeUniformDrawId;\n';
|
|
1544
|
+
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1571
1549
|
}
|
|
1572
1550
|
|
|
1573
1551
|
if ( this.material !== null ) {
|
|
@@ -254,47 +254,81 @@ class WebGLAttributeUtils {
|
|
|
254
254
|
|
|
255
255
|
/**
|
|
256
256
|
* This method performs a readback operation by moving buffer data from
|
|
257
|
-
* a storage buffer attribute from the GPU to the CPU.
|
|
257
|
+
* a storage buffer attribute from the GPU to the CPU. ReadbackBuffer can
|
|
258
|
+
* be used to retain and reuse handles to the intermediate buffers and prevent
|
|
259
|
+
* new allocation.
|
|
258
260
|
*
|
|
259
261
|
* @async
|
|
260
|
-
* @param {
|
|
261
|
-
* @
|
|
262
|
+
* @param {BufferAttribute} attribute - The storage buffer attribute to read frm.
|
|
263
|
+
* @param {ReadbackBuffer|ArrayBuffer} target - The storage buffer attribute.
|
|
264
|
+
* @param {number} offset - The storage buffer attribute.
|
|
265
|
+
* @param {number} count - The offset from which to start reading the
|
|
266
|
+
* @return {Promise<ArrayBuffer|ReadbackBuffer>} A promise that resolves with the buffer data when the data are ready.
|
|
262
267
|
*/
|
|
263
|
-
async getArrayBufferAsync( attribute ) {
|
|
268
|
+
async getArrayBufferAsync( attribute, target = null, offset = 0, count = - 1 ) {
|
|
264
269
|
|
|
265
270
|
const backend = this.backend;
|
|
266
271
|
const { gl } = backend;
|
|
267
272
|
|
|
268
273
|
const bufferAttribute = attribute.isInterleavedBufferAttribute ? attribute.data : attribute;
|
|
269
|
-
const
|
|
274
|
+
const attributeInfo = backend.get( bufferAttribute );
|
|
275
|
+
const { bufferGPU } = attributeInfo;
|
|
270
276
|
|
|
271
|
-
const
|
|
272
|
-
const byteLength = array.byteLength;
|
|
277
|
+
const byteLength = count === - 1 ? attributeInfo.byteLength - offset : count;
|
|
273
278
|
|
|
274
|
-
|
|
279
|
+
// read the data back
|
|
280
|
+
let dstBuffer;
|
|
281
|
+
if ( target === null ) {
|
|
275
282
|
|
|
276
|
-
|
|
283
|
+
dstBuffer = new Uint8Array( new ArrayBuffer( byteLength ) );
|
|
277
284
|
|
|
278
|
-
|
|
279
|
-
gl.bufferData( gl.COPY_WRITE_BUFFER, byteLength, gl.STREAM_READ );
|
|
285
|
+
} else if ( target.isReadbackBuffer ) {
|
|
280
286
|
|
|
281
|
-
|
|
287
|
+
if ( target._mapped === true ) {
|
|
282
288
|
|
|
283
|
-
|
|
289
|
+
throw new Error( 'WebGPURenderer: ReadbackBuffer must be released before being used again.' );
|
|
284
290
|
|
|
285
|
-
|
|
291
|
+
}
|
|
286
292
|
|
|
287
|
-
|
|
288
|
-
|
|
293
|
+
const releaseCallback = () => {
|
|
294
|
+
|
|
295
|
+
target.buffer = null;
|
|
296
|
+
target._mapped = false;
|
|
297
|
+
target.removeEventListener( 'release', releaseCallback );
|
|
298
|
+
target.removeEventListener( 'dispose', releaseCallback );
|
|
299
|
+
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
target.addEventListener( 'release', releaseCallback );
|
|
303
|
+
target.addEventListener( 'dispose', releaseCallback );
|
|
304
|
+
|
|
305
|
+
// WebGL has no concept of a "mapped" data buffer so we create a new buffer, instead.
|
|
306
|
+
dstBuffer = new Uint8Array( new ArrayBuffer( byteLength ) );
|
|
307
|
+
target.buffer = dstBuffer.buffer;
|
|
308
|
+
|
|
309
|
+
} else {
|
|
289
310
|
|
|
290
|
-
|
|
311
|
+
dstBuffer = new Uint8Array( target );
|
|
291
312
|
|
|
292
|
-
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Ensure the buffer is bound before reading
|
|
316
|
+
gl.bindBuffer( gl.COPY_READ_BUFFER, bufferGPU );
|
|
317
|
+
gl.getBufferSubData( gl.COPY_READ_BUFFER, offset, dstBuffer );
|
|
293
318
|
|
|
294
319
|
gl.bindBuffer( gl.COPY_READ_BUFFER, null );
|
|
295
320
|
gl.bindBuffer( gl.COPY_WRITE_BUFFER, null );
|
|
296
321
|
|
|
297
|
-
return
|
|
322
|
+
// return the appropriate type
|
|
323
|
+
if ( target && target.isReadbackBuffer ) {
|
|
324
|
+
|
|
325
|
+
return target;
|
|
326
|
+
|
|
327
|
+
} else {
|
|
328
|
+
|
|
329
|
+
return dstBuffer.buffer;
|
|
330
|
+
|
|
331
|
+
}
|
|
298
332
|
|
|
299
333
|
}
|
|
300
334
|
|
|
@@ -27,6 +27,14 @@ class WebGLCapabilities {
|
|
|
27
27
|
*/
|
|
28
28
|
this.maxAnisotropy = null;
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* This value holds the cached max uniform block size value.
|
|
32
|
+
*
|
|
33
|
+
* @type {?number}
|
|
34
|
+
* @default null
|
|
35
|
+
*/
|
|
36
|
+
this.maxUniformBlockSize = null;
|
|
37
|
+
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
/**
|
|
@@ -59,6 +67,23 @@ class WebGLCapabilities {
|
|
|
59
67
|
|
|
60
68
|
}
|
|
61
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Returns the maximum number of bytes available for uniform buffers.
|
|
72
|
+
*
|
|
73
|
+
* @return {number} The maximum number of bytes available for uniform buffers.
|
|
74
|
+
*/
|
|
75
|
+
getUniformBufferLimit() {
|
|
76
|
+
|
|
77
|
+
if ( this.maxUniformBlockSize !== null ) return this.maxUniformBlockSize;
|
|
78
|
+
|
|
79
|
+
const gl = this.backend.gl;
|
|
80
|
+
|
|
81
|
+
this.maxUniformBlockSize = gl.getParameter( gl.MAX_UNIFORM_BLOCK_SIZE );
|
|
82
|
+
|
|
83
|
+
return this.maxUniformBlockSize;
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
62
87
|
}
|
|
63
88
|
|
|
64
89
|
export default WebGLCapabilities;
|
|
@@ -50,6 +50,7 @@ class WebGLState {
|
|
|
50
50
|
// documented for convenience reasons.
|
|
51
51
|
|
|
52
52
|
this.enabled = {};
|
|
53
|
+
this.parameters = {};
|
|
53
54
|
this.currentFlipSided = null;
|
|
54
55
|
this.currentCullFace = null;
|
|
55
56
|
this.currentProgram = null;
|
|
@@ -1291,7 +1292,6 @@ class WebGLState {
|
|
|
1291
1292
|
|
|
1292
1293
|
}
|
|
1293
1294
|
|
|
1294
|
-
|
|
1295
1295
|
/**
|
|
1296
1296
|
* Unbinds the current bound texture.
|
|
1297
1297
|
*
|
|
@@ -1315,6 +1315,47 @@ class WebGLState {
|
|
|
1315
1315
|
|
|
1316
1316
|
}
|
|
1317
1317
|
|
|
1318
|
+
/**
|
|
1319
|
+
* Returns the value for the given parameter.
|
|
1320
|
+
*
|
|
1321
|
+
* @param {number} name - The paramter to get the value for.
|
|
1322
|
+
* @return {any} The value for the given parameter.
|
|
1323
|
+
*/
|
|
1324
|
+
getParameter( name ) {
|
|
1325
|
+
|
|
1326
|
+
const { gl, parameters } = this;
|
|
1327
|
+
|
|
1328
|
+
if ( parameters[ name ] !== undefined ) {
|
|
1329
|
+
|
|
1330
|
+
return parameters[ name ];
|
|
1331
|
+
|
|
1332
|
+
} else {
|
|
1333
|
+
|
|
1334
|
+
return gl.getParameter( name );
|
|
1335
|
+
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* Specifies a pixel storage mode.
|
|
1342
|
+
*
|
|
1343
|
+
* @param {number} name - The parameter to set.
|
|
1344
|
+
* @param {any} value - A value to set the parameter to.
|
|
1345
|
+
*/
|
|
1346
|
+
pixelStorei( name, value ) {
|
|
1347
|
+
|
|
1348
|
+
const { gl, parameters } = this;
|
|
1349
|
+
|
|
1350
|
+
if ( parameters[ name ] !== value ) {
|
|
1351
|
+
|
|
1352
|
+
gl.pixelStorei( name, value );
|
|
1353
|
+
parameters[ name ] = value;
|
|
1354
|
+
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1318
1359
|
}
|
|
1319
1360
|
|
|
1320
1361
|
export default WebGLState;
|