super-three 0.169.1 → 0.170.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 +24628 -24228
- package/build/three.core.js +37002 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +10519 -47108
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +533 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +17071 -53583
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +17134 -53623
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
- package/examples/jsm/animation/MMDPhysics.js +2 -0
- package/examples/jsm/capabilities/WebGPU.js +1 -10
- package/examples/jsm/controls/ArcballControls.js +25 -21
- package/examples/jsm/controls/OrbitControls.js +41 -9
- package/examples/jsm/controls/PointerLockControls.js +2 -5
- package/examples/jsm/controls/TransformControls.js +22 -6
- package/examples/jsm/csm/CSM.js +2 -2
- package/examples/jsm/csm/CSMFrustum.js +7 -4
- package/examples/jsm/csm/CSMHelper.js +2 -0
- package/examples/jsm/csm/CSMShadowNode.js +437 -0
- package/examples/jsm/curves/NURBSCurve.js +34 -3
- package/examples/jsm/exporters/GLTFExporter.js +138 -71
- package/examples/jsm/exporters/KTX2Exporter.js +35 -12
- package/examples/jsm/exporters/MMDExporter.js +6 -0
- package/examples/jsm/exporters/USDZExporter.js +21 -3
- package/examples/jsm/geometries/DecalGeometry.js +70 -21
- package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
- package/examples/jsm/interactive/HTMLMesh.js +1 -0
- package/examples/jsm/lighting/TiledLighting.js +18 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/LineGeometry.js +25 -0
- package/examples/jsm/lines/LineMaterial.js +0 -1
- package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
- package/examples/jsm/lines/webgpu/Line2.js +2 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +2 -16
- package/examples/jsm/lines/webgpu/Wireframe.js +57 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -0
- package/examples/jsm/loaders/3MFLoader.js +91 -0
- package/examples/jsm/loaders/FBXLoader.js +12 -2
- package/examples/jsm/loaders/GLTFLoader.js +2 -0
- package/examples/jsm/loaders/KTX2Loader.js +143 -49
- package/examples/jsm/loaders/LDrawLoader.js +22 -136
- package/examples/jsm/loaders/LottieLoader.js +1 -0
- package/examples/jsm/loaders/MMDLoader.js +3 -0
- package/examples/jsm/loaders/MaterialXLoader.js +2 -2
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
- package/examples/jsm/math/ColorSpaces.js +76 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
- package/examples/jsm/misc/VolumeSlice.js +1 -0
- package/examples/jsm/objects/InstancedPoints.js +2 -4
- package/examples/jsm/objects/LensflareMesh.js +4 -2
- package/examples/jsm/objects/SkyMesh.js +5 -3
- package/examples/jsm/objects/Water2Mesh.js +7 -3
- package/examples/jsm/objects/WaterMesh.js +12 -10
- package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
- package/examples/jsm/postprocessing/SSRPass.js +6 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
- package/examples/jsm/shaders/FXAAShader.js +225 -224
- package/examples/jsm/transpiler/AST.js +2 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +57 -25
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +11 -6
- package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +18 -21
- package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
- package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
- package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +12 -41
- package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +60 -47
- package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +4 -9
- package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
- package/examples/jsm/tsl/display/FXAANode.js +316 -0
- package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +4 -7
- package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +73 -78
- package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +78 -42
- package/examples/jsm/tsl/display/LensflareNode.js +161 -0
- package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +3 -5
- package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
- package/examples/jsm/tsl/display/OutlineNode.js +434 -0
- package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +2 -5
- package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +5 -17
- package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +2 -6
- package/examples/jsm/tsl/display/SMAANode.js +620 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
- package/examples/jsm/tsl/display/SSRNode.js +366 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +4 -12
- package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
- package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
- package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +3 -7
- package/examples/jsm/tsl/display/hashBlur.js +24 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +389 -0
- package/examples/jsm/utils/SceneOptimizer.js +410 -0
- package/examples/jsm/utils/UVsDebug.js +1 -1
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
- package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
- package/examples/jsm/webxr/Text2D.js +6 -6
- package/package.json +4 -4
- package/src/Three.Core.js +178 -0
- package/src/Three.TSL.js +526 -0
- package/src/Three.WebGPU.Nodes.js +9 -186
- package/src/Three.WebGPU.js +8 -186
- package/src/Three.js +1 -177
- package/src/animation/AnimationClip.js +2 -2
- package/src/animation/AnimationObjectGroup.js +2 -2
- package/src/audio/Audio.js +38 -0
- package/src/cameras/PerspectiveCamera.js +6 -6
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +1 -6
- package/src/core/BufferGeometry.js +48 -8
- package/src/core/InterleavedBuffer.js +4 -4
- package/src/core/Object3D.js +2 -2
- package/src/extras/core/Curve.js +3 -3
- package/src/extras/core/Shape.js +2 -2
- package/src/geometries/CylinderGeometry.js +2 -2
- package/src/geometries/EdgesGeometry.js +2 -2
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/lights/SpotLightShadow.js +2 -2
- package/src/materials/LineDashedMaterial.js +0 -1
- package/src/materials/Material.js +2 -2
- package/src/materials/MeshPhongMaterial.js +1 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -2
- package/src/materials/MeshStandardMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +32 -13
- package/src/materials/nodes/LineDashedNodeMaterial.js +4 -2
- package/src/materials/nodes/NodeMaterial.js +93 -23
- package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
- package/src/materials/nodes/manager/NodeMaterialObserver.js +119 -7
- package/src/math/ColorManagement.js +143 -102
- package/src/math/Line3.js +2 -2
- package/src/math/Quaternion.js +2 -2
- package/src/math/Spherical.js +3 -3
- package/src/math/Vector2.js +7 -7
- package/src/math/Vector3.js +9 -9
- package/src/math/Vector4.js +22 -9
- package/src/nodes/Nodes.js +2 -21
- package/src/nodes/TSL.js +9 -25
- package/src/nodes/accessors/Arrays.js +27 -0
- package/src/nodes/accessors/BuiltinNode.js +26 -0
- package/src/nodes/accessors/Camera.js +0 -1
- package/src/nodes/accessors/ClippingNode.js +76 -42
- package/src/nodes/accessors/InstanceNode.js +17 -20
- package/src/nodes/accessors/InstancedMeshNode.js +26 -0
- package/src/nodes/accessors/Lights.js +32 -0
- package/src/nodes/accessors/SceneNode.js +35 -1
- package/src/nodes/accessors/StorageBufferNode.js +61 -19
- package/src/nodes/accessors/StorageTextureNode.js +10 -4
- package/src/nodes/accessors/TextureNode.js +1 -1
- package/src/nodes/accessors/VelocityNode.js +13 -3
- package/src/nodes/code/FunctionCallNode.js +16 -5
- package/src/nodes/code/ScriptableNode.js +4 -4
- package/src/nodes/core/Node.js +1 -0
- package/src/nodes/core/NodeBuilder.js +31 -14
- package/src/nodes/core/NodeUtils.js +28 -0
- package/src/nodes/core/VarNode.js +15 -3
- package/src/nodes/core/constants.js +6 -0
- package/src/nodes/display/BlendModes.js +99 -0
- package/src/nodes/display/ColorAdjustment.js +53 -4
- package/src/nodes/display/ColorSpaceFunctions.js +5 -5
- package/src/nodes/display/ColorSpaceNode.js +27 -39
- package/src/nodes/display/PassNode.js +6 -4
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +3 -3
- package/src/nodes/display/ViewportDepthNode.js +48 -1
- package/src/nodes/functions/PhysicalLightingModel.js +21 -15
- package/src/nodes/functions/material/getAlphaHashThreshold.js +70 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
- package/src/nodes/gpgpu/ComputeNode.js +9 -1
- package/src/nodes/lighting/AnalyticLightNode.js +23 -419
- package/src/nodes/lighting/LightsNode.js +24 -12
- package/src/nodes/lighting/PointLightNode.js +41 -22
- package/src/nodes/lighting/PointShadowNode.js +254 -0
- package/src/nodes/lighting/RectAreaLightNode.js +3 -0
- package/src/nodes/lighting/ShadowNode.js +593 -0
- package/src/nodes/lighting/SpotLightNode.js +14 -2
- package/src/nodes/utils/LoopNode.js +2 -2
- package/src/nodes/utils/Oscillators.js +6 -0
- package/src/nodes/utils/PostProcessingUtils.js +89 -0
- package/src/nodes/utils/RTTNode.js +9 -1
- package/src/nodes/utils/ReflectorNode.js +101 -15
- package/src/nodes/utils/StorageArrayElementNode.js +2 -2
- package/src/nodes/utils/Timer.js +29 -0
- package/src/objects/BatchedMesh.js +472 -296
- package/src/objects/ClippingGroup.js +19 -0
- package/src/objects/Skeleton.js +2 -2
- package/src/renderers/WebGLRenderer.js +183 -109
- package/src/renderers/common/Animation.js +23 -11
- package/src/renderers/common/Attributes.js +4 -0
- package/src/renderers/common/Backend.js +2 -0
- package/src/renderers/common/Background.js +15 -5
- package/src/renderers/common/Bindings.js +23 -6
- package/src/renderers/common/ClippingContext.js +77 -85
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/Geometries.js +20 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
- package/src/renderers/common/Lighting.js +45 -0
- package/src/renderers/common/PostProcessingUtils.js +86 -0
- package/src/renderers/common/RenderList.js +48 -17
- package/src/renderers/common/RenderLists.js +4 -2
- package/src/renderers/common/RenderObject.js +45 -28
- package/src/renderers/common/RenderObjects.js +12 -6
- package/src/renderers/common/Renderer.js +222 -77
- package/src/renderers/common/Textures.js +41 -17
- package/src/renderers/common/UniformsGroup.js +16 -4
- package/src/renderers/common/extras/PMREMGenerator.js +89 -13
- package/src/renderers/common/nodes/NodeLibrary.js +2 -15
- package/src/renderers/common/nodes/NodeStorageBuffer.js +2 -3
- package/src/renderers/common/nodes/NodeUniform.js +42 -0
- package/src/renderers/common/nodes/Nodes.js +2 -2
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +20 -1
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +0 -7
- package/src/renderers/webgl/WebGLGeometries.js +0 -28
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -28
- package/src/renderers/webgl/WebGLPrograms.js +5 -2
- package/src/renderers/webgl/WebGLState.js +37 -1
- package/src/renderers/webgl/WebGLTextures.js +29 -12
- package/src/renderers/webgl-fallback/WebGLBackend.js +111 -37
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +43 -12
- package/src/renderers/webgl-fallback/utils/WebGLState.js +26 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +37 -9
- package/src/renderers/webgpu/WebGPUBackend.js +152 -56
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +13 -34
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +192 -92
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -2
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -7
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +29 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
- package/src/renderers/webxr/WebXRManager.js +4 -4
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/src/nodes/display/BlendMode.js +0 -54
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/TimerNode.js +0 -97
- /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
|
@@ -75,15 +75,11 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
|
|
|
75
75
|
let elementCount = 0;
|
|
76
76
|
for ( let i = 0; i < drawCount; i ++ ) {
|
|
77
77
|
|
|
78
|
-
elementCount += counts[ i ];
|
|
78
|
+
elementCount += counts[ i ] * primcount[ i ];
|
|
79
79
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
info.update( elementCount, mode, primcount[ i ] );
|
|
85
|
-
|
|
86
|
-
}
|
|
82
|
+
info.update( elementCount, mode, 1 );
|
|
87
83
|
|
|
88
84
|
}
|
|
89
85
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { WebGLUniforms } from './WebGLUniforms.js';
|
|
2
2
|
import { WebGLShader } from './WebGLShader.js';
|
|
3
3
|
import { ShaderChunk } from '../shaders/ShaderChunk.js';
|
|
4
|
-
import { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, CubeRefractionMapping, CubeUVReflectionMapping, CubeReflectionMapping, PCFSoftShadowMap, PCFShadowMap, VSMShadowMap, AgXToneMapping, ACESFilmicToneMapping, NeutralToneMapping, CineonToneMapping, CustomToneMapping, ReinhardToneMapping, LinearToneMapping, GLSL3,
|
|
4
|
+
import { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, CubeRefractionMapping, CubeUVReflectionMapping, CubeReflectionMapping, PCFSoftShadowMap, PCFShadowMap, VSMShadowMap, AgXToneMapping, ACESFilmicToneMapping, NeutralToneMapping, CineonToneMapping, CustomToneMapping, ReinhardToneMapping, LinearToneMapping, GLSL3, LinearTransfer, SRGBTransfer } from '../../constants.js';
|
|
5
5
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
6
6
|
import { Vector3 } from '../../math/Vector3.js';
|
|
7
|
+
import { Matrix3 } from '../../math/Matrix3.js';
|
|
7
8
|
|
|
8
9
|
// From https://www.khronos.org/registry/webgl/extensions/KHR_parallel_shader_compile/
|
|
9
10
|
const COMPLETION_STATUS_KHR = 0x91B1;
|
|
@@ -29,40 +30,25 @@ function handleSource( string, errorLine ) {
|
|
|
29
30
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
|
|
35
|
-
const encodingPrimaries = ColorManagement.getPrimaries( colorSpace );
|
|
36
|
-
|
|
37
|
-
let gamutMapping;
|
|
38
|
-
|
|
39
|
-
if ( workingPrimaries === encodingPrimaries ) {
|
|
33
|
+
const _m0 = /*@__PURE__*/ new Matrix3();
|
|
40
34
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} else if ( workingPrimaries === P3Primaries && encodingPrimaries === Rec709Primaries ) {
|
|
44
|
-
|
|
45
|
-
gamutMapping = 'LinearDisplayP3ToLinearSRGB';
|
|
46
|
-
|
|
47
|
-
} else if ( workingPrimaries === Rec709Primaries && encodingPrimaries === P3Primaries ) {
|
|
35
|
+
function getEncodingComponents( colorSpace ) {
|
|
48
36
|
|
|
49
|
-
|
|
37
|
+
ColorManagement._getMatrix( _m0, ColorManagement.workingColorSpace, colorSpace );
|
|
50
38
|
|
|
51
|
-
}
|
|
39
|
+
const encodingMatrix = `mat3( ${ _m0.elements.map( ( v ) => v.toFixed( 4 ) ) } )`;
|
|
52
40
|
|
|
53
|
-
switch ( colorSpace ) {
|
|
41
|
+
switch ( ColorManagement.getTransfer( colorSpace ) ) {
|
|
54
42
|
|
|
55
|
-
case
|
|
56
|
-
|
|
57
|
-
return [ gamutMapping, 'LinearTransferOETF' ];
|
|
43
|
+
case LinearTransfer:
|
|
44
|
+
return [ encodingMatrix, 'LinearTransferOETF' ];
|
|
58
45
|
|
|
59
|
-
case
|
|
60
|
-
|
|
61
|
-
return [ gamutMapping, 'sRGBTransferOETF' ];
|
|
46
|
+
case SRGBTransfer:
|
|
47
|
+
return [ encodingMatrix, 'sRGBTransferOETF' ];
|
|
62
48
|
|
|
63
49
|
default:
|
|
64
|
-
console.warn( 'THREE.WebGLProgram: Unsupported color space:', colorSpace );
|
|
65
|
-
return [
|
|
50
|
+
console.warn( 'THREE.WebGLProgram: Unsupported color space: ', colorSpace );
|
|
51
|
+
return [ encodingMatrix, 'LinearTransferOETF' ];
|
|
66
52
|
|
|
67
53
|
}
|
|
68
54
|
|
|
@@ -95,7 +81,16 @@ function getShaderErrors( gl, shader, type ) {
|
|
|
95
81
|
function getTexelEncodingFunction( functionName, colorSpace ) {
|
|
96
82
|
|
|
97
83
|
const components = getEncodingComponents( colorSpace );
|
|
98
|
-
|
|
84
|
+
|
|
85
|
+
return [
|
|
86
|
+
|
|
87
|
+
`vec4 ${functionName}( vec4 value ) {`,
|
|
88
|
+
|
|
89
|
+
` return ${components[ 1 ]}( vec4( value.rgb * ${components[ 0 ]}, value.a ) );`,
|
|
90
|
+
|
|
91
|
+
'}',
|
|
92
|
+
|
|
93
|
+
].join( '\n' );
|
|
99
94
|
|
|
100
95
|
}
|
|
101
96
|
|
|
@@ -823,6 +818,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
823
818
|
parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
|
|
824
819
|
|
|
825
820
|
parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
|
|
821
|
+
parameters.decodeVideoTextureEmissive ? '#define DECODE_VIDEO_TEXTURE_EMISSIVE' : '',
|
|
826
822
|
|
|
827
823
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
828
824
|
parameters.reverseDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
|
|
@@ -14,7 +14,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
14
14
|
const programs = [];
|
|
15
15
|
|
|
16
16
|
const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
|
|
17
|
-
const reverseDepthBuffer = capabilities.reverseDepthBuffer;
|
|
18
17
|
const SUPPORTS_VERTEX_TEXTURES = capabilities.vertexTextures;
|
|
19
18
|
|
|
20
19
|
let precision = capabilities.precision;
|
|
@@ -109,6 +108,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
const currentRenderTarget = renderer.getRenderTarget();
|
|
111
|
+
const reverseDepthBuffer = renderer.state.buffers.depth.getReversed();
|
|
112
112
|
|
|
113
113
|
const numMultiviewViews = currentRenderTarget && currentRenderTarget.isWebGLMultiviewRenderTarget ? currentRenderTarget.numViews : 0;
|
|
114
114
|
|
|
@@ -344,6 +344,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
344
344
|
toneMapping: toneMapping,
|
|
345
345
|
|
|
346
346
|
decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( ColorManagement.getTransfer( material.map.colorSpace ) === SRGBTransfer ),
|
|
347
|
+
decodeVideoTextureEmissive: HAS_EMISSIVEMAP && ( material.emissiveMap.isVideoTexture === true ) && ( ColorManagement.getTransfer( material.emissiveMap.colorSpace ) === SRGBTransfer ),
|
|
347
348
|
|
|
348
349
|
premultipliedAlpha: material.premultipliedAlpha,
|
|
349
350
|
|
|
@@ -561,8 +562,10 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
561
562
|
_programLayers.enable( 18 );
|
|
562
563
|
if ( parameters.decodeVideoTexture )
|
|
563
564
|
_programLayers.enable( 19 );
|
|
564
|
-
if ( parameters.
|
|
565
|
+
if ( parameters.decodeVideoTextureEmissive )
|
|
565
566
|
_programLayers.enable( 20 );
|
|
567
|
+
if ( parameters.alphaToCoverage )
|
|
568
|
+
_programLayers.enable( 21 );
|
|
566
569
|
if ( parameters.numMultiviewViews )
|
|
567
570
|
_programLayers.enable( 21 );
|
|
568
571
|
|
|
@@ -14,7 +14,7 @@ const reversedFuncs = {
|
|
|
14
14
|
[ GreaterEqualDepth ]: LessEqualDepth,
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
function WebGLState( gl ) {
|
|
17
|
+
function WebGLState( gl, extensions ) {
|
|
18
18
|
|
|
19
19
|
function ColorBuffer() {
|
|
20
20
|
|
|
@@ -88,10 +88,36 @@ function WebGLState( gl ) {
|
|
|
88
88
|
|
|
89
89
|
setReversed: function ( value ) {
|
|
90
90
|
|
|
91
|
+
if ( reversed !== value ) {
|
|
92
|
+
|
|
93
|
+
const ext = extensions.get( 'EXT_clip_control' );
|
|
94
|
+
|
|
95
|
+
if ( reversed ) {
|
|
96
|
+
|
|
97
|
+
ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.ZERO_TO_ONE_EXT );
|
|
98
|
+
|
|
99
|
+
} else {
|
|
100
|
+
|
|
101
|
+
ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.NEGATIVE_ONE_TO_ONE_EXT );
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const oldDepth = currentDepthClear;
|
|
106
|
+
currentDepthClear = null;
|
|
107
|
+
this.setClear( oldDepth );
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
91
111
|
reversed = value;
|
|
92
112
|
|
|
93
113
|
},
|
|
94
114
|
|
|
115
|
+
getReversed: function () {
|
|
116
|
+
|
|
117
|
+
return reversed;
|
|
118
|
+
|
|
119
|
+
},
|
|
120
|
+
|
|
95
121
|
setTest: function ( depthTest ) {
|
|
96
122
|
|
|
97
123
|
if ( depthTest ) {
|
|
@@ -187,6 +213,12 @@ function WebGLState( gl ) {
|
|
|
187
213
|
|
|
188
214
|
if ( currentDepthClear !== depth ) {
|
|
189
215
|
|
|
216
|
+
if ( reversed ) {
|
|
217
|
+
|
|
218
|
+
depth = 1 - depth;
|
|
219
|
+
|
|
220
|
+
}
|
|
221
|
+
|
|
190
222
|
gl.clearDepth( depth );
|
|
191
223
|
currentDepthClear = depth;
|
|
192
224
|
|
|
@@ -201,6 +233,7 @@ function WebGLState( gl ) {
|
|
|
201
233
|
currentDepthMask = null;
|
|
202
234
|
currentDepthFunc = null;
|
|
203
235
|
currentDepthClear = null;
|
|
236
|
+
reversed = false;
|
|
204
237
|
|
|
205
238
|
}
|
|
206
239
|
|
|
@@ -1171,6 +1204,9 @@ function WebGLState( gl ) {
|
|
|
1171
1204
|
|
|
1172
1205
|
gl.depthMask( true );
|
|
1173
1206
|
gl.depthFunc( gl.LESS );
|
|
1207
|
+
|
|
1208
|
+
depthBuffer.setReversed( false );
|
|
1209
|
+
|
|
1174
1210
|
gl.clearDepth( 1 );
|
|
1175
1211
|
|
|
1176
1212
|
gl.stencilMask( 0xffffffff );
|
|
@@ -111,7 +111,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
111
111
|
|
|
112
112
|
function textureNeedsGenerateMipmaps( texture ) {
|
|
113
113
|
|
|
114
|
-
return texture.generateMipmaps
|
|
114
|
+
return texture.generateMipmaps;
|
|
115
115
|
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -121,6 +121,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
121
121
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
function getTargetType( texture ) {
|
|
125
|
+
|
|
126
|
+
if ( texture.isWebGLCubeRenderTarget ) return _gl.TEXTURE_CUBE_MAP;
|
|
127
|
+
if ( texture.isWebGL3DRenderTarget ) return _gl.TEXTURE_3D;
|
|
128
|
+
if ( texture.isWebGLArrayRenderTarget || texture.isCompressedArrayTexture ) return _gl.TEXTURE_2D_ARRAY;
|
|
129
|
+
return _gl.TEXTURE_2D;
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
|
|
124
133
|
function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
|
|
125
134
|
|
|
126
135
|
if ( internalFormatName !== null ) {
|
|
@@ -380,6 +389,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
380
389
|
|
|
381
390
|
renderTarget.depthTexture.dispose();
|
|
382
391
|
|
|
392
|
+
properties.remove( renderTarget.depthTexture );
|
|
393
|
+
|
|
383
394
|
}
|
|
384
395
|
|
|
385
396
|
if ( renderTarget.isWebGLCubeRenderTarget ) {
|
|
@@ -929,7 +940,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
929
940
|
layerIndex * layerByteLength / mipmap.data.BYTES_PER_ELEMENT,
|
|
930
941
|
( layerIndex + 1 ) * layerByteLength / mipmap.data.BYTES_PER_ELEMENT
|
|
931
942
|
);
|
|
932
|
-
state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, layerIndex, mipmap.width, mipmap.height, 1, glFormat, layerData
|
|
943
|
+
state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, layerIndex, mipmap.width, mipmap.height, 1, glFormat, layerData );
|
|
933
944
|
|
|
934
945
|
}
|
|
935
946
|
|
|
@@ -937,7 +948,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
937
948
|
|
|
938
949
|
} else {
|
|
939
950
|
|
|
940
|
-
state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data
|
|
951
|
+
state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data );
|
|
941
952
|
|
|
942
953
|
}
|
|
943
954
|
|
|
@@ -1453,6 +1464,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1453
1464
|
const glType = utils.convert( texture.type );
|
|
1454
1465
|
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
1455
1466
|
const renderTargetProperties = properties.get( renderTarget );
|
|
1467
|
+
const textureProperties = properties.get( texture );
|
|
1468
|
+
|
|
1469
|
+
textureProperties.__renderTarget = renderTarget;
|
|
1456
1470
|
|
|
1457
1471
|
if ( ! renderTargetProperties.__hasExternalTextures ) {
|
|
1458
1472
|
|
|
@@ -1483,11 +1497,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1483
1497
|
|
|
1484
1498
|
if ( multisampled ) {
|
|
1485
1499
|
|
|
1486
|
-
multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0,
|
|
1500
|
+
multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, 0, getRenderTargetSamples( renderTarget ), 0, renderTarget.numViews );
|
|
1487
1501
|
|
|
1488
1502
|
} else {
|
|
1489
1503
|
|
|
1490
|
-
multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0,
|
|
1504
|
+
multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, 0, 0, renderTarget.numViews );
|
|
1491
1505
|
|
|
1492
1506
|
}
|
|
1493
1507
|
|
|
@@ -1495,11 +1509,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1495
1509
|
|
|
1496
1510
|
if ( multisampled ) {
|
|
1497
1511
|
|
|
1498
|
-
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, attachment, textureTarget,
|
|
1512
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, attachment, textureTarget, textureProperties.__webglTexture, 0, getRenderTargetSamples( renderTarget ) );
|
|
1499
1513
|
|
|
1500
1514
|
} else {
|
|
1501
1515
|
|
|
1502
|
-
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget,
|
|
1516
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, textureProperties.__webglTexture, level );
|
|
1503
1517
|
|
|
1504
1518
|
}
|
|
1505
1519
|
|
|
@@ -1642,8 +1656,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1642
1656
|
|
|
1643
1657
|
}
|
|
1644
1658
|
|
|
1659
|
+
const textureProperties = properties.get( renderTarget.depthTexture );
|
|
1660
|
+
textureProperties.__renderTarget = renderTarget;
|
|
1661
|
+
|
|
1645
1662
|
// upload an empty depth texture with framebuffer size
|
|
1646
|
-
if ( !
|
|
1663
|
+
if ( ! textureProperties.__webglTexture ||
|
|
1647
1664
|
renderTarget.depthTexture.image.width !== renderTarget.width ||
|
|
1648
1665
|
renderTarget.depthTexture.image.height !== renderTarget.height ) {
|
|
1649
1666
|
|
|
@@ -1664,7 +1681,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1664
1681
|
|
|
1665
1682
|
}
|
|
1666
1683
|
|
|
1667
|
-
const webglDepthTexture =
|
|
1684
|
+
const webglDepthTexture = textureProperties.__webglTexture;
|
|
1668
1685
|
const samples = getRenderTargetSamples( renderTarget );
|
|
1669
1686
|
|
|
1670
1687
|
if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
|
|
@@ -2100,11 +2117,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2100
2117
|
|
|
2101
2118
|
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
2102
2119
|
|
|
2103
|
-
const
|
|
2120
|
+
const targetType = getTargetType( renderTarget );
|
|
2104
2121
|
const webglTexture = properties.get( texture ).__webglTexture;
|
|
2105
2122
|
|
|
2106
|
-
state.bindTexture(
|
|
2107
|
-
generateMipmap(
|
|
2123
|
+
state.bindTexture( targetType, webglTexture );
|
|
2124
|
+
generateMipmap( targetType );
|
|
2108
2125
|
state.unbindTexture();
|
|
2109
2126
|
|
|
2110
2127
|
}
|
|
@@ -36,6 +36,25 @@ class WebGLBackend extends Backend {
|
|
|
36
36
|
|
|
37
37
|
const glContext = ( parameters.context !== undefined ) ? parameters.context : renderer.domElement.getContext( 'webgl2' );
|
|
38
38
|
|
|
39
|
+
function onContextLost( event ) {
|
|
40
|
+
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
|
|
43
|
+
const contextLossInfo = {
|
|
44
|
+
api: 'WebGL',
|
|
45
|
+
message: event.statusMessage || 'Unknown reason',
|
|
46
|
+
reason: null,
|
|
47
|
+
originalEvent: event
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
renderer.onDeviceLost( contextLossInfo );
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this._onContextLost = onContextLost;
|
|
55
|
+
|
|
56
|
+
renderer.domElement.addEventListener( 'webglcontextlost', onContextLost, false );
|
|
57
|
+
|
|
39
58
|
this.gl = glContext;
|
|
40
59
|
|
|
41
60
|
this.extensions = new WebGLExtensions( this );
|
|
@@ -63,6 +82,8 @@ class WebGLBackend extends Backend {
|
|
|
63
82
|
this.disjoint = this.extensions.get( 'EXT_disjoint_timer_query_webgl2' );
|
|
64
83
|
this.parallel = this.extensions.get( 'KHR_parallel_shader_compile' );
|
|
65
84
|
|
|
85
|
+
this._knownBindings = new WeakSet();
|
|
86
|
+
|
|
66
87
|
this._currentContext = null;
|
|
67
88
|
|
|
68
89
|
}
|
|
@@ -79,6 +100,11 @@ class WebGLBackend extends Backend {
|
|
|
79
100
|
|
|
80
101
|
}
|
|
81
102
|
|
|
103
|
+
async waitForGPU() {
|
|
104
|
+
|
|
105
|
+
await this.utils._clientWaitAsync();
|
|
106
|
+
|
|
107
|
+
}
|
|
82
108
|
|
|
83
109
|
initTimestampQuery( renderContext ) {
|
|
84
110
|
|
|
@@ -140,7 +166,7 @@ class WebGLBackend extends Backend {
|
|
|
140
166
|
|
|
141
167
|
}
|
|
142
168
|
|
|
143
|
-
|
|
169
|
+
async resolveTimestampAsync( renderContext, type = 'render' ) {
|
|
144
170
|
|
|
145
171
|
if ( ! this.disjoint || ! this.trackTimestamp ) return;
|
|
146
172
|
|
|
@@ -433,9 +459,17 @@ class WebGLBackend extends Backend {
|
|
|
433
459
|
|
|
434
460
|
if ( descriptor === null ) {
|
|
435
461
|
|
|
462
|
+
const clearColor = this.getClearColor();
|
|
463
|
+
|
|
464
|
+
// premultiply alpha
|
|
465
|
+
|
|
466
|
+
clearColor.r *= clearColor.a;
|
|
467
|
+
clearColor.g *= clearColor.a;
|
|
468
|
+
clearColor.b *= clearColor.a;
|
|
469
|
+
|
|
436
470
|
descriptor = {
|
|
437
471
|
textures: null,
|
|
438
|
-
clearColorValue:
|
|
472
|
+
clearColorValue: clearColor
|
|
439
473
|
};
|
|
440
474
|
|
|
441
475
|
}
|
|
@@ -450,13 +484,23 @@ class WebGLBackend extends Backend {
|
|
|
450
484
|
|
|
451
485
|
if ( clear !== 0 ) {
|
|
452
486
|
|
|
453
|
-
|
|
487
|
+
let clearColor;
|
|
454
488
|
|
|
455
|
-
|
|
489
|
+
if ( descriptor.clearColorValue ) {
|
|
456
490
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
491
|
+
clearColor = descriptor.clearColorValue;
|
|
492
|
+
|
|
493
|
+
} else {
|
|
494
|
+
|
|
495
|
+
clearColor = this.getClearColor();
|
|
496
|
+
|
|
497
|
+
// premultiply alpha
|
|
498
|
+
|
|
499
|
+
clearColor.r *= clearColor.a;
|
|
500
|
+
clearColor.g *= clearColor.a;
|
|
501
|
+
clearColor.b *= clearColor.a;
|
|
502
|
+
|
|
503
|
+
}
|
|
460
504
|
|
|
461
505
|
if ( depth ) this.state.setDepthMask( true );
|
|
462
506
|
|
|
@@ -587,20 +631,26 @@ class WebGLBackend extends Backend {
|
|
|
587
631
|
|
|
588
632
|
this.prepareTimestampBuffer( computeGroup );
|
|
589
633
|
|
|
634
|
+
if ( this._currentContext ) {
|
|
635
|
+
|
|
636
|
+
this._setFramebuffer( this._currentContext );
|
|
637
|
+
|
|
638
|
+
}
|
|
639
|
+
|
|
590
640
|
}
|
|
591
641
|
|
|
592
642
|
draw( renderObject/*, info*/ ) {
|
|
593
643
|
|
|
594
|
-
const { object, pipeline, material, context } = renderObject;
|
|
644
|
+
const { object, pipeline, material, context, hardwareClippingPlanes } = renderObject;
|
|
595
645
|
const { programGPU } = this.get( pipeline );
|
|
596
646
|
|
|
597
647
|
const { gl, state } = this;
|
|
598
648
|
|
|
599
649
|
const contextData = this.get( context );
|
|
600
650
|
|
|
601
|
-
const
|
|
651
|
+
const drawParams = renderObject.getDrawParameters();
|
|
602
652
|
|
|
603
|
-
if (
|
|
653
|
+
if ( drawParams === null ) return;
|
|
604
654
|
|
|
605
655
|
//
|
|
606
656
|
|
|
@@ -608,15 +658,17 @@ class WebGLBackend extends Backend {
|
|
|
608
658
|
|
|
609
659
|
const frontFaceCW = ( object.isMesh && object.matrixWorld.determinant() < 0 );
|
|
610
660
|
|
|
611
|
-
state.setMaterial( material, frontFaceCW );
|
|
661
|
+
state.setMaterial( material, frontFaceCW, hardwareClippingPlanes );
|
|
612
662
|
|
|
613
663
|
state.useProgram( programGPU );
|
|
614
664
|
|
|
615
665
|
//
|
|
616
666
|
|
|
617
|
-
|
|
667
|
+
const renderObjectData = this.get( renderObject );
|
|
618
668
|
|
|
619
|
-
|
|
669
|
+
let vaoGPU = renderObjectData.staticVao;
|
|
670
|
+
|
|
671
|
+
if ( vaoGPU === undefined || renderObjectData.geometryId !== renderObject.geometry.id ) {
|
|
620
672
|
|
|
621
673
|
const vaoKey = this._getVaoKey( renderObject.getIndex(), renderObject.getAttributes() );
|
|
622
674
|
|
|
@@ -628,7 +680,12 @@ class WebGLBackend extends Backend {
|
|
|
628
680
|
|
|
629
681
|
( { vaoGPU, staticVao } = this._createVao( renderObject.getIndex(), renderObject.getAttributes() ) );
|
|
630
682
|
|
|
631
|
-
if ( staticVao )
|
|
683
|
+
if ( staticVao ) {
|
|
684
|
+
|
|
685
|
+
renderObjectData.staticVao = vaoGPU;
|
|
686
|
+
renderObjectData.geometryId = renderObject.geometry.id;
|
|
687
|
+
|
|
688
|
+
}
|
|
632
689
|
|
|
633
690
|
}
|
|
634
691
|
|
|
@@ -693,8 +750,8 @@ class WebGLBackend extends Backend {
|
|
|
693
750
|
|
|
694
751
|
//
|
|
695
752
|
|
|
696
|
-
const { vertexCount, instanceCount } =
|
|
697
|
-
let { firstVertex } =
|
|
753
|
+
const { vertexCount, instanceCount } = drawParams;
|
|
754
|
+
let { firstVertex } = drawParams;
|
|
698
755
|
|
|
699
756
|
renderer.object = object;
|
|
700
757
|
|
|
@@ -1059,8 +1116,6 @@ class WebGLBackend extends Backend {
|
|
|
1059
1116
|
|
|
1060
1117
|
// Bindings
|
|
1061
1118
|
|
|
1062
|
-
this.createBindings( null, bindings );
|
|
1063
|
-
|
|
1064
1119
|
this._setupBindings( bindings, programGPU );
|
|
1065
1120
|
|
|
1066
1121
|
const attributeNodes = computeProgram.attributes;
|
|
@@ -1101,33 +1156,43 @@ class WebGLBackend extends Backend {
|
|
|
1101
1156
|
|
|
1102
1157
|
createBindings( bindGroup, bindings ) {
|
|
1103
1158
|
|
|
1104
|
-
this.
|
|
1159
|
+
if ( this._knownBindings.has( bindings ) === false ) {
|
|
1105
1160
|
|
|
1106
|
-
|
|
1161
|
+
this._knownBindings.add( bindings );
|
|
1107
1162
|
|
|
1108
|
-
|
|
1163
|
+
let uniformBuffers = 0;
|
|
1164
|
+
let textures = 0;
|
|
1109
1165
|
|
|
1110
|
-
|
|
1166
|
+
for ( const bindGroup of bindings ) {
|
|
1111
1167
|
|
|
1112
|
-
|
|
1168
|
+
this.set( bindGroup, {
|
|
1169
|
+
textures: textures,
|
|
1170
|
+
uniformBuffers: uniformBuffers
|
|
1171
|
+
} );
|
|
1113
1172
|
|
|
1114
|
-
|
|
1115
|
-
const bindGroupData = this.get( bindGroup );
|
|
1173
|
+
for ( const binding of bindGroup.bindings ) {
|
|
1116
1174
|
|
|
1117
|
-
|
|
1175
|
+
if ( binding.isUniformBuffer ) uniformBuffers ++;
|
|
1176
|
+
if ( binding.isSampledTexture ) textures ++;
|
|
1118
1177
|
|
|
1119
|
-
|
|
1178
|
+
}
|
|
1120
1179
|
|
|
1121
|
-
|
|
1180
|
+
}
|
|
1122
1181
|
|
|
1123
|
-
}
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
this.updateBindings( bindGroup, bindings );
|
|
1124
1185
|
|
|
1125
|
-
|
|
1126
|
-
bindingsData.textureIndex = bindGroupData.textureIndex;
|
|
1186
|
+
}
|
|
1127
1187
|
|
|
1128
|
-
|
|
1188
|
+
updateBindings( bindGroup /*, bindings*/ ) {
|
|
1129
1189
|
|
|
1130
|
-
|
|
1190
|
+
const { gl } = this;
|
|
1191
|
+
|
|
1192
|
+
const bindGroupData = this.get( bindGroup );
|
|
1193
|
+
|
|
1194
|
+
let i = bindGroupData.uniformBuffers;
|
|
1195
|
+
let t = bindGroupData.textures;
|
|
1131
1196
|
|
|
1132
1197
|
for ( const binding of bindGroup.bindings ) {
|
|
1133
1198
|
|
|
@@ -1140,7 +1205,7 @@ class WebGLBackend extends Backend {
|
|
|
1140
1205
|
gl.bufferData( gl.UNIFORM_BUFFER, data, gl.DYNAMIC_DRAW );
|
|
1141
1206
|
|
|
1142
1207
|
this.set( binding, {
|
|
1143
|
-
index:
|
|
1208
|
+
index: i ++,
|
|
1144
1209
|
bufferGPU
|
|
1145
1210
|
} );
|
|
1146
1211
|
|
|
@@ -1149,7 +1214,7 @@ class WebGLBackend extends Backend {
|
|
|
1149
1214
|
const { textureGPU, glTextureType } = this.get( binding.texture );
|
|
1150
1215
|
|
|
1151
1216
|
this.set( binding, {
|
|
1152
|
-
index:
|
|
1217
|
+
index: t ++,
|
|
1153
1218
|
textureGPU,
|
|
1154
1219
|
glTextureType
|
|
1155
1220
|
} );
|
|
@@ -1247,9 +1312,9 @@ class WebGLBackend extends Backend {
|
|
|
1247
1312
|
|
|
1248
1313
|
}
|
|
1249
1314
|
|
|
1250
|
-
copyTextureToTexture(
|
|
1315
|
+
copyTextureToTexture( srcTexture, dstTexture, srcRegion, dstPosition, level ) {
|
|
1251
1316
|
|
|
1252
|
-
this.textureUtils.copyTextureToTexture(
|
|
1317
|
+
this.textureUtils.copyTextureToTexture( srcTexture, dstTexture, srcRegion, dstPosition, level );
|
|
1253
1318
|
|
|
1254
1319
|
}
|
|
1255
1320
|
|
|
@@ -1321,6 +1386,7 @@ class WebGLBackend extends Backend {
|
|
|
1321
1386
|
const texture = textures[ i ];
|
|
1322
1387
|
const textureData = this.get( texture );
|
|
1323
1388
|
textureData.renderTarget = descriptor.renderTarget;
|
|
1389
|
+
textureData.cacheKey = cacheKey; // required for copyTextureToTexture()
|
|
1324
1390
|
|
|
1325
1391
|
const attachment = gl.COLOR_ATTACHMENT0 + i;
|
|
1326
1392
|
|
|
@@ -1336,6 +1402,8 @@ class WebGLBackend extends Backend {
|
|
|
1336
1402
|
|
|
1337
1403
|
const textureData = this.get( descriptor.depthTexture );
|
|
1338
1404
|
const depthStyle = stencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;
|
|
1405
|
+
textureData.renderTarget = descriptor.renderTarget;
|
|
1406
|
+
textureData.cacheKey = cacheKey; // required for copyTextureToTexture()
|
|
1339
1407
|
|
|
1340
1408
|
gl.framebufferTexture2D( gl.FRAMEBUFFER, depthStyle, gl.TEXTURE_2D, textureData.textureGPU, 0 );
|
|
1341
1409
|
|
|
@@ -1614,6 +1682,12 @@ class WebGLBackend extends Backend {
|
|
|
1614
1682
|
|
|
1615
1683
|
}
|
|
1616
1684
|
|
|
1685
|
+
dispose() {
|
|
1686
|
+
|
|
1687
|
+
this.renderer.domElement.removeEventListener( 'webglcontextlost', this._onContextLost );
|
|
1688
|
+
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1617
1691
|
}
|
|
1618
1692
|
|
|
1619
1693
|
export default WebGLBackend;
|
|
@@ -120,18 +120,13 @@ class WebGLBufferRenderer {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
let elementCount = 0;
|
|
123
|
-
|
|
124
123
|
for ( let i = 0; i < drawCount; i ++ ) {
|
|
125
124
|
|
|
126
|
-
elementCount += counts[ i ];
|
|
125
|
+
elementCount += counts[ i ] * primcount[ i ];
|
|
127
126
|
|
|
128
127
|
}
|
|
129
128
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
info.update( object, elementCount, mode, primcount[ i ] );
|
|
133
|
-
|
|
134
|
-
}
|
|
129
|
+
info.update( object, elementCount, mode, 1 );
|
|
135
130
|
|
|
136
131
|
}
|
|
137
132
|
|