super-three 0.168.0 → 0.169.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 +384 -700
- package/build/three.module.js +384 -700
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +24644 -22406
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +79941 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +0 -6
- package/examples/jsm/controls/TrackballControls.js +32 -12
- package/examples/jsm/controls/TransformControls.js +97 -62
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +1 -1
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +3 -1
- package/examples/jsm/loaders/FBXLoader.js +30 -20
- package/examples/jsm/loaders/GLTFLoader.js +5 -10
- package/examples/jsm/loaders/KTX2Loader.js +10 -7
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +29 -10
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +5 -4
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/VRMLLoader.js +10 -10
- package/examples/jsm/loaders/VTKLoader.js +4 -3
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +1 -2
- package/examples/jsm/objects/Water2Mesh.js +2 -3
- package/examples/jsm/objects/WaterMesh.js +1 -2
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/physics/RapierPhysics.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/TextureUtils.js +1 -0
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/package.json +2 -2
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +2 -1
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/extras/Controls.js +1 -1
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/loaders/MaterialLoader.js +7 -1
- package/src/loaders/nodes/NodeLoader.js +24 -4
- package/src/loaders/nodes/NodeMaterialLoader.js +21 -17
- package/src/loaders/nodes/NodeObjectLoader.js +19 -0
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +19 -34
- package/src/materials/nodes/Line2NodeMaterial.js +26 -26
- package/src/materials/nodes/LineBasicNodeMaterial.js +7 -3
- package/src/materials/nodes/LineDashedNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshBasicNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshLambertNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshNormalNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshPhongNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +6 -3
- package/src/materials/nodes/MeshSSSNodeMaterial.js +6 -3
- package/src/materials/nodes/MeshStandardNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshToonNodeMaterial.js +7 -3
- package/src/materials/nodes/NodeMaterial.js +20 -45
- package/src/materials/nodes/NodeMaterials.js +2 -0
- package/src/materials/nodes/PointsNodeMaterial.js +7 -3
- package/src/materials/nodes/ShadowNodeMaterial.js +7 -3
- package/src/materials/nodes/SpriteNodeMaterial.js +39 -6
- package/src/materials/nodes/VolumeNodeMaterial.js +13 -9
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Triangle.js +24 -0
- package/src/nodes/Nodes.js +3 -3
- package/src/nodes/TSL.js +96 -93
- package/src/nodes/accessors/BatchNode.js +7 -3
- package/src/nodes/accessors/BufferAttributeNode.js +6 -3
- package/src/nodes/accessors/BufferNode.js +6 -3
- package/src/nodes/accessors/Camera.js +10 -16
- package/src/nodes/accessors/ClippingNode.js +7 -3
- package/src/nodes/accessors/CubeTextureNode.js +6 -3
- package/src/nodes/accessors/InstanceNode.js +11 -11
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +6 -3
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +8 -4
- package/src/nodes/accessors/MaterialReferenceNode.js +6 -3
- package/src/nodes/accessors/ModelNode.js +42 -7
- package/src/nodes/accessors/ModelViewProjectionNode.js +9 -5
- package/src/nodes/accessors/MorphNode.js +7 -3
- package/src/nodes/accessors/Normal.js +32 -6
- package/src/nodes/accessors/Object3DNode.js +11 -27
- package/src/nodes/accessors/PointUVNode.js +7 -3
- package/src/nodes/accessors/ReferenceBaseNode.js +32 -4
- package/src/nodes/accessors/ReferenceNode.js +40 -3
- package/src/nodes/accessors/RendererReferenceNode.js +9 -3
- package/src/nodes/accessors/SceneNode.js +7 -3
- package/src/nodes/accessors/SkinningNode.js +7 -3
- package/src/nodes/accessors/StorageBufferNode.js +21 -3
- package/src/nodes/accessors/StorageTextureNode.js +7 -4
- package/src/nodes/accessors/Texture3DNode.js +7 -4
- package/src/nodes/accessors/TextureNode.js +19 -8
- package/src/nodes/accessors/TextureSizeNode.js +8 -5
- package/src/nodes/accessors/UniformArrayNode.js +12 -9
- package/src/nodes/accessors/UserDataNode.js +9 -6
- package/src/nodes/accessors/VelocityNode.js +74 -23
- package/src/nodes/accessors/VertexColorNode.js +6 -3
- package/src/nodes/code/CodeNode.js +7 -3
- package/src/nodes/code/ExpressionNode.js +8 -4
- package/src/nodes/code/FunctionCallNode.js +6 -3
- package/src/nodes/code/FunctionNode.js +6 -3
- package/src/nodes/code/ScriptableNode.js +11 -6
- package/src/nodes/code/ScriptableValueNode.js +7 -3
- package/src/nodes/core/AssignNode.js +9 -6
- package/src/nodes/core/AttributeNode.js +7 -3
- package/src/nodes/core/BypassNode.js +8 -4
- package/src/nodes/core/CacheNode.js +8 -4
- package/src/nodes/core/ConstNode.js +6 -3
- package/src/nodes/core/ContextNode.js +7 -3
- package/src/nodes/core/IndexNode.js +25 -3
- package/src/nodes/core/InputNode.js +7 -3
- package/src/nodes/core/MRTNode.js +6 -3
- package/src/nodes/core/Node.js +10 -51
- package/src/nodes/core/NodeBuilder.js +71 -5
- package/src/nodes/core/NodeUtils.js +48 -6
- package/src/nodes/core/OutputStructNode.js +8 -4
- package/src/nodes/core/ParameterNode.js +6 -3
- package/src/nodes/core/PropertyNode.js +7 -3
- package/src/nodes/core/StackNode.js +7 -3
- package/src/nodes/core/StructTypeNode.js +7 -3
- package/src/nodes/core/TempNode.js +8 -4
- package/src/nodes/core/UniformGroupNode.js +10 -6
- package/src/nodes/core/UniformNode.js +6 -3
- package/src/nodes/core/VarNode.js +8 -4
- package/src/nodes/core/VaryingNode.js +7 -3
- package/src/nodes/display/AfterImageNode.js +6 -0
- package/src/nodes/display/AnaglyphPassNode.js +6 -0
- package/src/nodes/display/AnamorphicNode.js +6 -0
- package/src/nodes/display/BloomNode.js +6 -0
- package/src/nodes/display/BumpMapNode.js +6 -0
- package/src/nodes/display/ColorSpaceFunctions.js +4 -4
- package/src/nodes/display/ColorSpaceNode.js +43 -14
- package/src/nodes/display/DenoiseNode.js +6 -3
- package/src/nodes/display/DepthOfFieldNode.js +6 -3
- package/src/nodes/display/DotScreenNode.js +8 -5
- package/src/nodes/display/FXAANode.js +6 -3
- package/src/nodes/display/FilmNode.js +6 -3
- package/src/nodes/display/FrontFacingNode.js +7 -3
- package/src/nodes/display/GTAONode.js +6 -3
- package/src/nodes/display/GaussianBlurNode.js +6 -3
- package/src/nodes/display/Lut3DNode.js +6 -3
- package/src/nodes/display/NormalMapNode.js +8 -6
- package/src/nodes/display/ParallaxBarrierPassNode.js +8 -5
- package/src/nodes/display/PassNode.js +18 -7
- package/src/nodes/display/PixelationPassNode.js +12 -5
- package/src/nodes/display/PosterizeNode.js +6 -3
- package/src/nodes/display/RGBShiftNode.js +6 -3
- package/src/nodes/display/RenderOutputNode.js +12 -8
- package/src/nodes/display/SSAAPassNode.js +6 -3
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/SobelOperatorNode.js +6 -3
- package/src/nodes/display/StereoCompositePassNode.js +6 -3
- package/src/nodes/display/StereoPassNode.js +6 -3
- package/src/nodes/display/ToneMappingFunctions.js +12 -12
- package/src/nodes/display/ToneMappingNode.js +8 -7
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +6 -3
- package/src/nodes/display/ViewportDepthNode.js +7 -3
- package/src/nodes/display/ViewportDepthTextureNode.js +8 -5
- package/src/nodes/display/ViewportSharedTextureNode.js +8 -5
- package/src/nodes/display/ViewportTextureNode.js +8 -5
- package/src/nodes/fog/FogExp2Node.js +6 -3
- package/src/nodes/fog/FogNode.js +7 -3
- package/src/nodes/fog/FogRangeNode.js +6 -3
- package/src/nodes/functions/PhysicalLightingModel.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.js +7 -3
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/src/nodes/gpgpu/ComputeNode.js +8 -4
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +6 -3
- package/src/nodes/lighting/AmbientLightNode.js +6 -3
- package/src/nodes/lighting/AnalyticLightNode.js +198 -30
- package/src/nodes/lighting/BasicEnvironmentNode.js +6 -3
- package/src/nodes/lighting/BasicLightMapNode.js +6 -3
- package/src/nodes/lighting/DirectionalLightNode.js +7 -4
- package/src/nodes/lighting/EnvironmentNode.js +6 -3
- package/src/nodes/lighting/HemisphereLightNode.js +10 -6
- package/src/nodes/lighting/IESSpotLightNode.js +6 -3
- package/src/nodes/lighting/IrradianceNode.js +6 -3
- package/src/nodes/lighting/LightProbeNode.js +8 -31
- package/src/nodes/lighting/LightingContextNode.js +6 -3
- package/src/nodes/lighting/LightingNode.js +7 -3
- package/src/nodes/lighting/LightsNode.js +24 -5
- package/src/nodes/lighting/PointLightNode.js +11 -7
- package/src/nodes/lighting/RectAreaLightNode.js +11 -7
- package/src/nodes/lighting/SpotLightNode.js +13 -10
- package/src/nodes/math/ConditionalNode.js +23 -6
- package/src/nodes/math/MathNode.js +6 -3
- package/src/nodes/math/OperatorNode.js +6 -3
- package/src/nodes/pmrem/PMREMNode.js +6 -3
- package/src/nodes/utils/ArrayElementNode.js +8 -4
- package/src/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +6 -3
- package/src/nodes/utils/EquirectUVNode.js +6 -3
- package/src/nodes/utils/FlipNode.js +7 -4
- package/src/nodes/utils/FunctionOverloadingNode.js +7 -3
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +7 -3
- package/src/nodes/utils/MatcapUVNode.js +6 -3
- package/src/nodes/utils/MaxMipLevelNode.js +6 -3
- package/src/nodes/utils/OscNode.js +7 -3
- package/src/nodes/utils/RTTNode.js +6 -3
- package/src/nodes/utils/ReflectorNode.js +8 -5
- package/src/nodes/utils/RemapNode.js +7 -3
- package/src/nodes/utils/RotateNode.js +6 -3
- package/src/nodes/utils/SetNode.js +7 -4
- package/src/nodes/utils/SplitNode.js +7 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +7 -3
- package/src/nodes/utils/StorageArrayElementNode.js +9 -8
- package/src/nodes/utils/TimerNode.js +6 -3
- package/src/nodes/utils/TriplanarTexturesNode.js +7 -3
- package/src/nodes/utils/ViewportUtils.js +2 -2
- package/src/objects/BatchedMesh.js +76 -10
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +1 -0
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +65 -50
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ClippingContext.js +4 -3
- package/src/renderers/common/RenderContext.js +4 -5
- package/src/renderers/common/RenderObject.js +116 -5
- package/src/renderers/common/RenderObjects.js +8 -1
- package/src/renderers/common/Renderer.js +57 -49
- package/src/renderers/common/extras/PMREMGenerator.js +7 -9
- package/src/renderers/common/nodes/NodeBuilderState.js +3 -3
- package/src/renderers/common/nodes/Nodes.js +33 -14
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/webgl/WebGLAttributes.js +45 -14
- package/src/renderers/webgl/WebGLCapabilities.js +9 -0
- package/src/renderers/webgl/WebGLProgram.js +2 -0
- package/src/renderers/webgl/WebGLPrograms.js +21 -17
- package/src/renderers/webgl/WebGLState.js +21 -0
- package/src/renderers/webgl/WebGLTextures.js +22 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +50 -45
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +4 -4
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -4
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +61 -16
- package/src/renderers/webgpu/WebGPUBackend.js +33 -25
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/src/renderers/webgpu/WebGPURenderer.js +5 -2
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/{common → webgpu}/nodes/StandardNodeLibrary.js +11 -11
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +91 -11
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +7 -5
- package/src/renderers/webgpu/utils/WebGPUUtils.js +1 -1
- package/src/utils.js +33 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/utils/GPUStatsPanel.js +0 -95
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/nodes/display/ViewportNode.js +0 -138
- package/src/nodes/lighting/LightNode.js +0 -57
- package/src/renderers/common/StandardRenderer.js +0 -18
- package/src/renderers/webvr/WebVRManager.js +0 -495
- package/src/renderers/webvr/WebVRUtils.js +0 -66
|
@@ -14,6 +14,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
14
14
|
const programs = [];
|
|
15
15
|
|
|
16
16
|
const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
|
|
17
|
+
const reverseDepthBuffer = capabilities.reverseDepthBuffer;
|
|
17
18
|
const SUPPORTS_VERTEX_TEXTURES = capabilities.vertexTextures;
|
|
18
19
|
|
|
19
20
|
let precision = capabilities.precision;
|
|
@@ -308,6 +309,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
308
309
|
|
|
309
310
|
sizeAttenuation: material.sizeAttenuation === true,
|
|
310
311
|
logarithmicDepthBuffer: logarithmicDepthBuffer,
|
|
312
|
+
reverseDepthBuffer: reverseDepthBuffer,
|
|
311
313
|
|
|
312
314
|
skinning: object.isSkinnedMesh === true,
|
|
313
315
|
|
|
@@ -527,40 +529,42 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
527
529
|
_programLayers.enable( 2 );
|
|
528
530
|
if ( parameters.logarithmicDepthBuffer )
|
|
529
531
|
_programLayers.enable( 3 );
|
|
530
|
-
if ( parameters.
|
|
532
|
+
if ( parameters.reverseDepthBuffer )
|
|
531
533
|
_programLayers.enable( 4 );
|
|
532
|
-
if ( parameters.
|
|
534
|
+
if ( parameters.skinning )
|
|
533
535
|
_programLayers.enable( 5 );
|
|
534
|
-
if ( parameters.
|
|
536
|
+
if ( parameters.morphTargets )
|
|
535
537
|
_programLayers.enable( 6 );
|
|
536
|
-
if ( parameters.
|
|
538
|
+
if ( parameters.morphNormals )
|
|
537
539
|
_programLayers.enable( 7 );
|
|
538
|
-
if ( parameters.
|
|
540
|
+
if ( parameters.morphColors )
|
|
539
541
|
_programLayers.enable( 8 );
|
|
540
|
-
if ( parameters.
|
|
542
|
+
if ( parameters.premultipliedAlpha )
|
|
541
543
|
_programLayers.enable( 9 );
|
|
542
|
-
if ( parameters.
|
|
544
|
+
if ( parameters.shadowMapEnabled )
|
|
543
545
|
_programLayers.enable( 10 );
|
|
544
|
-
if ( parameters.
|
|
546
|
+
if ( parameters.doubleSided )
|
|
545
547
|
_programLayers.enable( 11 );
|
|
546
|
-
if ( parameters.
|
|
548
|
+
if ( parameters.flipSided )
|
|
547
549
|
_programLayers.enable( 12 );
|
|
548
|
-
if ( parameters.
|
|
550
|
+
if ( parameters.useDepthPacking )
|
|
549
551
|
_programLayers.enable( 13 );
|
|
550
|
-
if ( parameters.
|
|
552
|
+
if ( parameters.dithering )
|
|
551
553
|
_programLayers.enable( 14 );
|
|
552
|
-
if ( parameters.
|
|
554
|
+
if ( parameters.transmission )
|
|
553
555
|
_programLayers.enable( 15 );
|
|
554
|
-
if ( parameters.
|
|
556
|
+
if ( parameters.sheen )
|
|
555
557
|
_programLayers.enable( 16 );
|
|
556
|
-
if ( parameters.
|
|
558
|
+
if ( parameters.opaque )
|
|
557
559
|
_programLayers.enable( 17 );
|
|
558
|
-
if ( parameters.
|
|
560
|
+
if ( parameters.pointsUvs )
|
|
559
561
|
_programLayers.enable( 18 );
|
|
560
|
-
if ( parameters.
|
|
562
|
+
if ( parameters.decodeVideoTexture )
|
|
561
563
|
_programLayers.enable( 19 );
|
|
562
|
-
if ( parameters.
|
|
564
|
+
if ( parameters.alphaToCoverage )
|
|
563
565
|
_programLayers.enable( 20 );
|
|
566
|
+
if ( parameters.numMultiviewViews )
|
|
567
|
+
_programLayers.enable( 21 );
|
|
564
568
|
|
|
565
569
|
array.push( _programLayers.mask );
|
|
566
570
|
|
|
@@ -2,6 +2,18 @@ import { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDe
|
|
|
2
2
|
import { Color } from '../../math/Color.js';
|
|
3
3
|
import { Vector4 } from '../../math/Vector4.js';
|
|
4
4
|
|
|
5
|
+
const reversedFuncs = {
|
|
6
|
+
[ NeverDepth ]: AlwaysDepth,
|
|
7
|
+
[ LessDepth ]: GreaterDepth,
|
|
8
|
+
[ EqualDepth ]: NotEqualDepth,
|
|
9
|
+
[ LessEqualDepth ]: GreaterEqualDepth,
|
|
10
|
+
|
|
11
|
+
[ AlwaysDepth ]: NeverDepth,
|
|
12
|
+
[ GreaterDepth ]: LessDepth,
|
|
13
|
+
[ NotEqualDepth ]: EqualDepth,
|
|
14
|
+
[ GreaterEqualDepth ]: LessEqualDepth,
|
|
15
|
+
};
|
|
16
|
+
|
|
5
17
|
function WebGLState( gl ) {
|
|
6
18
|
|
|
7
19
|
function ColorBuffer() {
|
|
@@ -66,6 +78,7 @@ function WebGLState( gl ) {
|
|
|
66
78
|
function DepthBuffer() {
|
|
67
79
|
|
|
68
80
|
let locked = false;
|
|
81
|
+
let reversed = false;
|
|
69
82
|
|
|
70
83
|
let currentDepthMask = null;
|
|
71
84
|
let currentDepthFunc = null;
|
|
@@ -73,6 +86,12 @@ function WebGLState( gl ) {
|
|
|
73
86
|
|
|
74
87
|
return {
|
|
75
88
|
|
|
89
|
+
setReversed: function ( value ) {
|
|
90
|
+
|
|
91
|
+
reversed = value;
|
|
92
|
+
|
|
93
|
+
},
|
|
94
|
+
|
|
76
95
|
setTest: function ( depthTest ) {
|
|
77
96
|
|
|
78
97
|
if ( depthTest ) {
|
|
@@ -100,6 +119,8 @@ function WebGLState( gl ) {
|
|
|
100
119
|
|
|
101
120
|
setFunc: function ( depthFunc ) {
|
|
102
121
|
|
|
122
|
+
if ( reversed ) depthFunc = reversedFuncs[ depthFunc ];
|
|
123
|
+
|
|
103
124
|
if ( currentDepthFunc !== depthFunc ) {
|
|
104
125
|
|
|
105
126
|
switch ( depthFunc ) {
|
|
@@ -171,6 +171,28 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
171
171
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
if ( glFormat === _gl.RGB_INTEGER ) {
|
|
175
|
+
|
|
176
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGB8UI;
|
|
177
|
+
if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RGB16UI;
|
|
178
|
+
if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RGB32UI;
|
|
179
|
+
if ( glType === _gl.BYTE ) internalFormat = _gl.RGB8I;
|
|
180
|
+
if ( glType === _gl.SHORT ) internalFormat = _gl.RGB16I;
|
|
181
|
+
if ( glType === _gl.INT ) internalFormat = _gl.RGB32I;
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if ( glFormat === _gl.RGBA_INTEGER ) {
|
|
186
|
+
|
|
187
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGBA8UI;
|
|
188
|
+
if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RGBA16UI;
|
|
189
|
+
if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RGBA32UI;
|
|
190
|
+
if ( glType === _gl.BYTE ) internalFormat = _gl.RGBA8I;
|
|
191
|
+
if ( glType === _gl.SHORT ) internalFormat = _gl.RGBA16I;
|
|
192
|
+
if ( glType === _gl.INT ) internalFormat = _gl.RGBA32I;
|
|
193
|
+
|
|
194
|
+
}
|
|
195
|
+
|
|
174
196
|
if ( glFormat === _gl.RGB ) {
|
|
175
197
|
|
|
176
198
|
if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
|
|
@@ -62,6 +62,7 @@ class WebGLBackend extends Backend {
|
|
|
62
62
|
|
|
63
63
|
this.disjoint = this.extensions.get( 'EXT_disjoint_timer_query_webgl2' );
|
|
64
64
|
this.parallel = this.extensions.get( 'KHR_parallel_shader_compile' );
|
|
65
|
+
|
|
65
66
|
this._currentContext = null;
|
|
66
67
|
|
|
67
68
|
}
|
|
@@ -597,6 +598,10 @@ class WebGLBackend extends Backend {
|
|
|
597
598
|
|
|
598
599
|
const contextData = this.get( context );
|
|
599
600
|
|
|
601
|
+
const drawParms = renderObject.getDrawParameters();
|
|
602
|
+
|
|
603
|
+
if ( drawParms === null ) return;
|
|
604
|
+
|
|
600
605
|
//
|
|
601
606
|
|
|
602
607
|
this._bindUniforms( renderObject.getBindings() );
|
|
@@ -635,10 +640,6 @@ class WebGLBackend extends Backend {
|
|
|
635
640
|
|
|
636
641
|
const index = renderObject.getIndex();
|
|
637
642
|
|
|
638
|
-
const geometry = renderObject.geometry;
|
|
639
|
-
const drawRange = renderObject.drawRange;
|
|
640
|
-
const firstVertex = drawRange.start;
|
|
641
|
-
|
|
642
643
|
//
|
|
643
644
|
|
|
644
645
|
const lastObject = contextData.lastOcclusionObject;
|
|
@@ -669,7 +670,6 @@ class WebGLBackend extends Backend {
|
|
|
669
670
|
}
|
|
670
671
|
|
|
671
672
|
//
|
|
672
|
-
|
|
673
673
|
const renderer = this.bufferRenderer;
|
|
674
674
|
|
|
675
675
|
if ( object.isPoints ) renderer.mode = gl.POINTS;
|
|
@@ -693,33 +693,26 @@ class WebGLBackend extends Backend {
|
|
|
693
693
|
|
|
694
694
|
//
|
|
695
695
|
|
|
696
|
-
|
|
697
|
-
let
|
|
696
|
+
const { vertexCount, instanceCount } = drawParms;
|
|
697
|
+
let { firstVertex } = drawParms;
|
|
698
698
|
|
|
699
699
|
renderer.object = object;
|
|
700
700
|
|
|
701
701
|
if ( index !== null ) {
|
|
702
702
|
|
|
703
|
+
firstVertex *= index.array.BYTES_PER_ELEMENT;
|
|
704
|
+
|
|
703
705
|
const indexData = this.get( index );
|
|
704
|
-
const indexCount = ( drawRange.count !== Infinity ) ? drawRange.count : index.count;
|
|
705
706
|
|
|
706
707
|
renderer.index = index.count;
|
|
707
708
|
renderer.type = indexData.type;
|
|
708
709
|
|
|
709
|
-
count = indexCount;
|
|
710
|
-
|
|
711
710
|
} else {
|
|
712
711
|
|
|
713
712
|
renderer.index = 0;
|
|
714
713
|
|
|
715
|
-
const vertexCount = ( drawRange.count !== Infinity ) ? drawRange.count : geometry.attributes.position.count;
|
|
716
|
-
|
|
717
|
-
count = vertexCount;
|
|
718
|
-
|
|
719
714
|
}
|
|
720
715
|
|
|
721
|
-
const instanceCount = this.getInstanceCount( renderObject );
|
|
722
|
-
|
|
723
716
|
if ( object.isBatchedMesh ) {
|
|
724
717
|
|
|
725
718
|
if ( object._multiDrawInstances !== null ) {
|
|
@@ -738,11 +731,11 @@ class WebGLBackend extends Backend {
|
|
|
738
731
|
|
|
739
732
|
} else if ( instanceCount > 1 ) {
|
|
740
733
|
|
|
741
|
-
renderer.renderInstances( firstVertex,
|
|
734
|
+
renderer.renderInstances( firstVertex, vertexCount, instanceCount );
|
|
742
735
|
|
|
743
736
|
} else {
|
|
744
737
|
|
|
745
|
-
renderer.render( firstVertex,
|
|
738
|
+
renderer.render( firstVertex, vertexCount );
|
|
746
739
|
|
|
747
740
|
}
|
|
748
741
|
//
|
|
@@ -796,9 +789,9 @@ class WebGLBackend extends Backend {
|
|
|
796
789
|
|
|
797
790
|
}
|
|
798
791
|
|
|
799
|
-
copyTextureToBuffer( texture, x, y, width, height ) {
|
|
792
|
+
copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
|
|
800
793
|
|
|
801
|
-
return this.textureUtils.copyTextureToBuffer( texture, x, y, width, height );
|
|
794
|
+
return this.textureUtils.copyTextureToBuffer( texture, x, y, width, height, faceIndex );
|
|
802
795
|
|
|
803
796
|
}
|
|
804
797
|
|
|
@@ -1114,40 +1107,52 @@ class WebGLBackend extends Backend {
|
|
|
1114
1107
|
|
|
1115
1108
|
updateBindings( bindGroup, bindings ) {
|
|
1116
1109
|
|
|
1117
|
-
|
|
1110
|
+
if ( ! bindGroup ) return;
|
|
1111
|
+
|
|
1112
|
+
const { gl } = this;
|
|
1118
1113
|
|
|
1119
|
-
|
|
1120
|
-
|
|
1114
|
+
const bindingsData = this.get( bindings );
|
|
1115
|
+
const bindGroupData = this.get( bindGroup );
|
|
1121
1116
|
|
|
1122
|
-
|
|
1117
|
+
if ( bindingsData.textureIndex === undefined ) bindingsData.textureIndex = 0;
|
|
1123
1118
|
|
|
1124
|
-
|
|
1119
|
+
if ( bindGroupData.textureIndex === undefined ) {
|
|
1125
1120
|
|
|
1126
|
-
|
|
1121
|
+
bindGroupData.textureIndex = bindingsData.textureIndex;
|
|
1127
1122
|
|
|
1128
|
-
|
|
1129
|
-
const data = binding.buffer;
|
|
1123
|
+
} else {
|
|
1130
1124
|
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
state.bindBufferBase( gl.UNIFORM_BUFFER, groupIndex, bufferGPU );
|
|
1125
|
+
// reset textureIndex to match previous mappimgs when rebuilt
|
|
1126
|
+
bindingsData.textureIndex = bindGroupData.textureIndex;
|
|
1134
1127
|
|
|
1135
|
-
|
|
1136
|
-
index: groupIndex ++,
|
|
1137
|
-
bufferGPU
|
|
1138
|
-
} );
|
|
1128
|
+
}
|
|
1139
1129
|
|
|
1140
|
-
|
|
1130
|
+
let i = 0;
|
|
1141
1131
|
|
|
1142
|
-
|
|
1132
|
+
for ( const binding of bindGroup.bindings ) {
|
|
1143
1133
|
|
|
1144
|
-
|
|
1145
|
-
index: textureIndex ++,
|
|
1146
|
-
textureGPU,
|
|
1147
|
-
glTextureType
|
|
1148
|
-
} );
|
|
1134
|
+
if ( binding.isUniformsGroup || binding.isUniformBuffer ) {
|
|
1149
1135
|
|
|
1150
|
-
|
|
1136
|
+
const data = binding.buffer;
|
|
1137
|
+
const bufferGPU = gl.createBuffer();
|
|
1138
|
+
|
|
1139
|
+
gl.bindBuffer( gl.UNIFORM_BUFFER, bufferGPU );
|
|
1140
|
+
gl.bufferData( gl.UNIFORM_BUFFER, data, gl.DYNAMIC_DRAW );
|
|
1141
|
+
|
|
1142
|
+
this.set( binding, {
|
|
1143
|
+
index: bindGroup.index * 2 + i ++,
|
|
1144
|
+
bufferGPU
|
|
1145
|
+
} );
|
|
1146
|
+
|
|
1147
|
+
} else if ( binding.isSampledTexture ) {
|
|
1148
|
+
|
|
1149
|
+
const { textureGPU, glTextureType } = this.get( binding.texture );
|
|
1150
|
+
|
|
1151
|
+
this.set( binding, {
|
|
1152
|
+
index: bindingsData.textureIndex ++,
|
|
1153
|
+
textureGPU,
|
|
1154
|
+
glTextureType
|
|
1155
|
+
} );
|
|
1151
1156
|
|
|
1152
1157
|
}
|
|
1153
1158
|
|
|
@@ -1248,9 +1253,9 @@ class WebGLBackend extends Backend {
|
|
|
1248
1253
|
|
|
1249
1254
|
}
|
|
1250
1255
|
|
|
1251
|
-
copyFramebufferToTexture( texture, renderContext ) {
|
|
1256
|
+
copyFramebufferToTexture( texture, renderContext, rectangle ) {
|
|
1252
1257
|
|
|
1253
|
-
this.textureUtils.copyFramebufferToTexture( texture, renderContext );
|
|
1258
|
+
this.textureUtils.copyFramebufferToTexture( texture, renderContext, rectangle );
|
|
1254
1259
|
|
|
1255
1260
|
}
|
|
1256
1261
|
|
|
@@ -56,8 +56,6 @@ class GLSLNodeBuilder extends NodeBuilder {
|
|
|
56
56
|
this.transforms = [];
|
|
57
57
|
this.extensions = {};
|
|
58
58
|
|
|
59
|
-
this.instanceBindGroups = false;
|
|
60
|
-
|
|
61
59
|
this.useComparisonMethod = true;
|
|
62
60
|
|
|
63
61
|
}
|
|
@@ -234,7 +232,7 @@ ${ flowData.code }
|
|
|
234
232
|
|
|
235
233
|
this.getVarFromNode( node, propertySizeName, 'uint' );
|
|
236
234
|
|
|
237
|
-
this.addLineFlowCode( `${ propertySizeName } = uint( textureSize( ${ textureName }, 0 ).x )
|
|
235
|
+
this.addLineFlowCode( `${ propertySizeName } = uint( textureSize( ${ textureName }, 0 ).x )`, storageArrayElementNode );
|
|
238
236
|
|
|
239
237
|
bufferNodeData.propertySizeName = propertySizeName;
|
|
240
238
|
|
|
@@ -264,7 +262,7 @@ ${ flowData.code }
|
|
|
264
262
|
|
|
265
263
|
}
|
|
266
264
|
|
|
267
|
-
this.addLineFlowCode( `${ propertyName } = ${prefix}(${ snippet })${channel}
|
|
265
|
+
this.addLineFlowCode( `${ propertyName } = ${prefix}(${ snippet })${channel}`, storageArrayElementNode );
|
|
268
266
|
|
|
269
267
|
elementNodeData.propertyName = propertyName;
|
|
270
268
|
|
|
@@ -854,6 +852,8 @@ void main() {
|
|
|
854
852
|
|
|
855
853
|
const shadersData = this.material !== null ? { fragment: {}, vertex: {} } : { compute: {} };
|
|
856
854
|
|
|
855
|
+
this.sortBindingGroups();
|
|
856
|
+
|
|
857
857
|
for ( const shaderStage in shadersData ) {
|
|
858
858
|
|
|
859
859
|
let flow = '// code\n\n';
|
|
@@ -233,10 +233,16 @@ class WebGLAttributeUtils {
|
|
|
233
233
|
|
|
234
234
|
const dstBuffer = new attribute.array.constructor( array.length );
|
|
235
235
|
|
|
236
|
+
// Ensure the buffer is bound before reading
|
|
237
|
+
gl.bindBuffer( gl.COPY_WRITE_BUFFER, writeBuffer );
|
|
238
|
+
|
|
236
239
|
gl.getBufferSubData( gl.COPY_WRITE_BUFFER, 0, dstBuffer );
|
|
237
240
|
|
|
238
241
|
gl.deleteBuffer( writeBuffer );
|
|
239
242
|
|
|
243
|
+
gl.bindBuffer( gl.COPY_READ_BUFFER, null );
|
|
244
|
+
gl.bindBuffer( gl.COPY_WRITE_BUFFER, null );
|
|
245
|
+
|
|
240
246
|
return dstBuffer.buffer;
|
|
241
247
|
|
|
242
248
|
}
|
|
@@ -512,7 +512,7 @@ class WebGLState {
|
|
|
512
512
|
|
|
513
513
|
this.setPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits );
|
|
514
514
|
|
|
515
|
-
material.alphaToCoverage === true
|
|
515
|
+
material.alphaToCoverage === true && this.backend.renderer.samples > 1
|
|
516
516
|
? this.enable( gl.SAMPLE_ALPHA_TO_COVERAGE )
|
|
517
517
|
: this.disable( gl.SAMPLE_ALPHA_TO_COVERAGE );
|
|
518
518
|
|
|
@@ -649,7 +649,6 @@ class WebGLState {
|
|
|
649
649
|
|
|
650
650
|
}
|
|
651
651
|
|
|
652
|
-
|
|
653
652
|
}
|
|
654
653
|
|
|
655
654
|
|
|
@@ -711,10 +710,8 @@ class WebGLState {
|
|
|
711
710
|
boundTexture.type = webglType;
|
|
712
711
|
boundTexture.texture = webglTexture;
|
|
713
712
|
|
|
714
|
-
|
|
715
713
|
}
|
|
716
714
|
|
|
717
|
-
|
|
718
715
|
}
|
|
719
716
|
|
|
720
717
|
bindBufferBase( target, index, buffer ) {
|
|
@@ -692,20 +692,22 @@ class WebGLTextureUtils {
|
|
|
692
692
|
|
|
693
693
|
}
|
|
694
694
|
|
|
695
|
-
copyFramebufferToTexture( texture, renderContext ) {
|
|
695
|
+
copyFramebufferToTexture( texture, renderContext, rectangle ) {
|
|
696
696
|
|
|
697
697
|
const { gl } = this;
|
|
698
698
|
const { state } = this.backend;
|
|
699
699
|
|
|
700
700
|
const { textureGPU } = this.backend.get( texture );
|
|
701
701
|
|
|
702
|
-
const width =
|
|
703
|
-
const height = texture.image.height;
|
|
702
|
+
const { x, y, z: width, w: height } = rectangle;
|
|
704
703
|
|
|
705
704
|
const requireDrawFrameBuffer = texture.isDepthTexture === true || ( renderContext.renderTarget && renderContext.renderTarget.samples > 0 );
|
|
706
705
|
|
|
706
|
+
const srcHeight = renderContext.renderTarget ? renderContext.renderTarget.height : this.backend.gerDrawingBufferSize().y;
|
|
707
|
+
|
|
707
708
|
if ( requireDrawFrameBuffer ) {
|
|
708
709
|
|
|
710
|
+
const partial = ( x !== 0 || y !== 0 );
|
|
709
711
|
let mask;
|
|
710
712
|
let attachment;
|
|
711
713
|
|
|
@@ -727,19 +729,45 @@ class WebGLTextureUtils {
|
|
|
727
729
|
|
|
728
730
|
}
|
|
729
731
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
+
if ( partial ) {
|
|
733
|
+
|
|
734
|
+
const renderTargetContextData = this.backend.get( renderContext.renderTarget );
|
|
735
|
+
|
|
736
|
+
const fb = renderTargetContextData.framebuffers[ renderContext.getCacheKey() ];
|
|
737
|
+
const msaaFrameBuffer = renderTargetContextData.msaaFrameBuffer;
|
|
738
|
+
|
|
739
|
+
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, fb );
|
|
740
|
+
state.bindFramebuffer( gl.READ_FRAMEBUFFER, msaaFrameBuffer );
|
|
741
|
+
|
|
742
|
+
const flippedY = srcHeight - y - height;
|
|
743
|
+
|
|
744
|
+
gl.blitFramebuffer( x, flippedY, x + width, flippedY + height, x, flippedY, x + width, flippedY + height, mask, gl.NEAREST );
|
|
732
745
|
|
|
733
|
-
|
|
746
|
+
state.bindFramebuffer( gl.READ_FRAMEBUFFER, fb );
|
|
747
|
+
|
|
748
|
+
state.bindTexture( gl.TEXTURE_2D, textureGPU );
|
|
749
|
+
|
|
750
|
+
gl.copyTexSubImage2D( gl.TEXTURE_2D, 0, 0, 0, x, flippedY, width, height );
|
|
751
|
+
|
|
752
|
+
state.unbindTexture();
|
|
753
|
+
|
|
754
|
+
} else {
|
|
734
755
|
|
|
735
|
-
|
|
756
|
+
const fb = gl.createFramebuffer();
|
|
736
757
|
|
|
737
|
-
|
|
758
|
+
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, fb );
|
|
759
|
+
|
|
760
|
+
gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, textureGPU, 0 );
|
|
761
|
+
gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, gl.NEAREST );
|
|
762
|
+
|
|
763
|
+
gl.deleteFramebuffer( fb );
|
|
764
|
+
|
|
765
|
+
}
|
|
738
766
|
|
|
739
767
|
} else {
|
|
740
768
|
|
|
741
769
|
state.bindTexture( gl.TEXTURE_2D, textureGPU );
|
|
742
|
-
gl.copyTexSubImage2D( gl.TEXTURE_2D, 0, 0, 0,
|
|
770
|
+
gl.copyTexSubImage2D( gl.TEXTURE_2D, 0, 0, 0, x, srcHeight - height - y, width, height );
|
|
743
771
|
|
|
744
772
|
state.unbindTexture();
|
|
745
773
|
|
|
@@ -806,7 +834,7 @@ class WebGLTextureUtils {
|
|
|
806
834
|
|
|
807
835
|
}
|
|
808
836
|
|
|
809
|
-
async copyTextureToBuffer( texture, x, y, width, height ) {
|
|
837
|
+
async copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
|
|
810
838
|
|
|
811
839
|
const { backend, gl } = this;
|
|
812
840
|
|
|
@@ -815,10 +843,13 @@ class WebGLTextureUtils {
|
|
|
815
843
|
const fb = gl.createFramebuffer();
|
|
816
844
|
|
|
817
845
|
gl.bindFramebuffer( gl.READ_FRAMEBUFFER, fb );
|
|
818
|
-
|
|
846
|
+
|
|
847
|
+
const target = texture.isCubeTexture ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D;
|
|
848
|
+
|
|
849
|
+
gl.framebufferTexture2D( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, target, textureGPU, 0 );
|
|
819
850
|
|
|
820
851
|
const typedArrayType = this._getTypedArrayType( glType );
|
|
821
|
-
const bytesPerTexel = this._getBytesPerTexel( glFormat );
|
|
852
|
+
const bytesPerTexel = this._getBytesPerTexel( glType, glFormat );
|
|
822
853
|
|
|
823
854
|
const elementCount = width * height;
|
|
824
855
|
const byteLength = elementCount * bytesPerTexel;
|
|
@@ -856,19 +887,33 @@ class WebGLTextureUtils {
|
|
|
856
887
|
if ( glType === gl.UNSIGNED_SHORT ) return Uint16Array;
|
|
857
888
|
if ( glType === gl.UNSIGNED_INT ) return Uint32Array;
|
|
858
889
|
|
|
890
|
+
if ( glType === gl.HALF_FLOAT ) return Uint16Array;
|
|
859
891
|
if ( glType === gl.FLOAT ) return Float32Array;
|
|
860
892
|
|
|
861
893
|
throw new Error( `Unsupported WebGL type: ${glType}` );
|
|
862
894
|
|
|
863
895
|
}
|
|
864
896
|
|
|
865
|
-
_getBytesPerTexel( glFormat ) {
|
|
897
|
+
_getBytesPerTexel( glType, glFormat ) {
|
|
866
898
|
|
|
867
899
|
const { gl } = this;
|
|
868
900
|
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
if (
|
|
901
|
+
let bytesPerComponent = 0;
|
|
902
|
+
|
|
903
|
+
if ( glType === gl.UNSIGNED_BYTE ) bytesPerComponent = 1;
|
|
904
|
+
|
|
905
|
+
if ( glType === gl.UNSIGNED_SHORT_4_4_4_4 ||
|
|
906
|
+
glType === gl.UNSIGNED_SHORT_5_5_5_1 ||
|
|
907
|
+
glType === gl.UNSIGNED_SHORT_5_6_5 ||
|
|
908
|
+
glType === gl.UNSIGNED_SHORT ||
|
|
909
|
+
glType === gl.HALF_FLOAT ) bytesPerComponent = 2;
|
|
910
|
+
|
|
911
|
+
if ( glType === gl.UNSIGNED_INT ||
|
|
912
|
+
glType === gl.FLOAT ) bytesPerComponent = 4;
|
|
913
|
+
|
|
914
|
+
if ( glFormat === gl.RGBA ) return bytesPerComponent * 4;
|
|
915
|
+
if ( glFormat === gl.RGB ) return bytesPerComponent * 3;
|
|
916
|
+
if ( glFormat === gl.ALPHA ) return bytesPerComponent;
|
|
872
917
|
|
|
873
918
|
}
|
|
874
919
|
|