super-three 0.162.0 → 0.163.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +407 -1014
- package/build/three.module.js +406 -1013
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/TransformControls.js +3 -3
- package/examples/jsm/exporters/GLTFExporter.js +21 -4
- package/examples/jsm/exporters/USDZExporter.js +15 -0
- package/examples/jsm/geometries/TextGeometry.js +10 -2
- package/examples/jsm/interactive/HTMLMesh.js +7 -9
- package/examples/jsm/libs/fflate.module.js +694 -496
- package/examples/jsm/lines/LineMaterial.js +0 -2
- package/examples/jsm/loaders/3MFLoader.js +2 -0
- package/examples/jsm/loaders/EXRLoader.js +89 -19
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +6 -0
- package/examples/jsm/loaders/KTX2Loader.js +2 -6
- package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
- package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
- package/examples/jsm/loaders/LUTImageLoader.js +0 -14
- package/examples/jsm/loaders/RGBMLoader.js +16 -0
- package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
- package/examples/jsm/nodes/Nodes.js +6 -1
- package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
- package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/MorphNode.js +13 -3
- package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
- package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +30 -7
- package/examples/jsm/nodes/core/Node.js +55 -4
- package/examples/jsm/nodes/core/NodeBuilder.js +21 -16
- package/examples/jsm/nodes/core/NodeFrame.js +10 -10
- package/examples/jsm/nodes/core/NodeUtils.js +2 -2
- package/examples/jsm/nodes/core/UniformNode.js +20 -0
- package/examples/jsm/nodes/display/PassNode.js +17 -1
- package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
- package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
- package/examples/jsm/nodes/fog/FogNode.js +13 -3
- package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +12 -69
- package/examples/jsm/nodes/materials/NodeMaterial.js +33 -11
- package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
- package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +1 -1
- package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
- package/examples/jsm/objects/QuadMesh.js +7 -23
- package/examples/jsm/physics/RapierPhysics.js +4 -4
- package/examples/jsm/postprocessing/GlitchPass.js +0 -3
- package/examples/jsm/postprocessing/LUTPass.js +5 -71
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SSAOPass.js +0 -3
- package/examples/jsm/renderers/common/Animation.js +3 -0
- package/examples/jsm/renderers/common/Background.js +5 -5
- package/examples/jsm/renderers/common/Info.js +11 -19
- package/examples/jsm/renderers/common/PostProcessing.js +12 -4
- package/examples/jsm/renderers/common/RenderContext.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +4 -4
- package/examples/jsm/renderers/common/RenderObjects.js +1 -1
- package/examples/jsm/renderers/common/Renderer.js +25 -8
- package/examples/jsm/renderers/common/extras/PMREMGenerator.js +777 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +5 -18
- package/examples/jsm/renderers/webgl/WebGLBackend.js +148 -24
- package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +141 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +3 -3
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +1 -1
- package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +43 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -2
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -2
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +54 -25
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +5 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +25 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +92 -18
- package/examples/jsm/utils/GPUStatsPanel.js +10 -45
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +1 -1
- package/src/Three.js +0 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/constants.js +3 -3
- package/src/core/Object3D.js +10 -7
- package/src/extras/PMREMGenerator.js +9 -0
- package/src/loaders/ObjectLoader.js +2 -0
- package/src/materials/ShaderMaterial.js +0 -4
- package/src/math/Spherical.js +4 -5
- package/src/objects/BatchedMesh.js +4 -3
- package/src/objects/InstancedMesh.js +10 -0
- package/src/renderers/WebGLRenderer.js +55 -114
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +10 -1
- package/src/renderers/webgl/WebGLAttributes.js +6 -33
- package/src/renderers/webgl/WebGLBindingStates.js +14 -51
- package/src/renderers/webgl/WebGLBufferRenderer.js +3 -25
- package/src/renderers/webgl/WebGLCapabilities.js +2 -12
- package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
- package/src/renderers/webgl/WebGLExtensions.js +4 -19
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +3 -25
- package/src/renderers/webgl/WebGLLights.js +6 -32
- package/src/renderers/webgl/WebGLMaterials.js +2 -3
- package/src/renderers/webgl/WebGLMorphtargets.js +79 -217
- package/src/renderers/webgl/WebGLProgram.js +18 -47
- package/src/renderers/webgl/WebGLPrograms.js +20 -32
- package/src/renderers/webgl/WebGLRenderStates.js +8 -6
- package/src/renderers/webgl/WebGLState.js +15 -59
- package/src/renderers/webgl/WebGLTextures.js +75 -237
- package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
- package/src/renderers/webgl/WebGLUtils.js +6 -57
- package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/scenes/Scene.js +7 -1
- package/src/textures/Texture.js +11 -1
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/src/renderers/WebGL1Renderer.js +0 -7
package/build/three.cjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
const REVISION = '
|
|
8
|
+
const REVISION = '163';
|
|
9
9
|
|
|
10
10
|
const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
|
|
11
11
|
const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
|
|
@@ -98,7 +98,9 @@ const HalfFloatType = 1016;
|
|
|
98
98
|
const UnsignedShort4444Type = 1017;
|
|
99
99
|
const UnsignedShort5551Type = 1018;
|
|
100
100
|
const UnsignedInt248Type = 1020;
|
|
101
|
+
const UnsignedInt5999Type = 35902;
|
|
101
102
|
const AlphaFormat = 1021;
|
|
103
|
+
const RGBFormat = 1022;
|
|
102
104
|
const RGBAFormat = 1023;
|
|
103
105
|
const LuminanceFormat = 1024;
|
|
104
106
|
const LuminanceAlphaFormat = 1025;
|
|
@@ -214,8 +216,6 @@ const StreamCopyUsage = 35042;
|
|
|
214
216
|
const GLSL1 = '100';
|
|
215
217
|
const GLSL3 = '300 es';
|
|
216
218
|
|
|
217
|
-
const _SRGBAFormat = 1035; // fallback for WebGL 1
|
|
218
|
-
|
|
219
219
|
const WebGLCoordinateSystem = 2000;
|
|
220
220
|
const WebGPUCoordinateSystem = 2001;
|
|
221
221
|
|
|
@@ -2003,7 +2003,7 @@ class Texture extends EventDispatcher {
|
|
|
2003
2003
|
this.onUpdate = null;
|
|
2004
2004
|
|
|
2005
2005
|
this.isRenderTargetTexture = false; // indicates whether a texture belongs to a render target or not
|
|
2006
|
-
this.
|
|
2006
|
+
this.pmremVersion = 0; // indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target textures)
|
|
2007
2007
|
|
|
2008
2008
|
}
|
|
2009
2009
|
|
|
@@ -2234,6 +2234,16 @@ class Texture extends EventDispatcher {
|
|
|
2234
2234
|
|
|
2235
2235
|
}
|
|
2236
2236
|
|
|
2237
|
+
set needsPMREMUpdate( value ) {
|
|
2238
|
+
|
|
2239
|
+
if ( value === true ) {
|
|
2240
|
+
|
|
2241
|
+
this.pmremVersion ++;
|
|
2242
|
+
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2237
2247
|
}
|
|
2238
2248
|
|
|
2239
2249
|
Texture.DEFAULT_IMAGE = null;
|
|
@@ -7402,12 +7412,7 @@ class Object3D extends EventDispatcher {
|
|
|
7402
7412
|
|
|
7403
7413
|
if ( object && object.isObject3D ) {
|
|
7404
7414
|
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
object.parent.remove( object );
|
|
7408
|
-
|
|
7409
|
-
}
|
|
7410
|
-
|
|
7415
|
+
object.removeFromParent();
|
|
7411
7416
|
object.parent = this;
|
|
7412
7417
|
this.children.push( object );
|
|
7413
7418
|
|
|
@@ -7500,10 +7505,18 @@ class Object3D extends EventDispatcher {
|
|
|
7500
7505
|
|
|
7501
7506
|
object.applyMatrix4( _m1$3 );
|
|
7502
7507
|
|
|
7503
|
-
|
|
7508
|
+
object.removeFromParent();
|
|
7509
|
+
object.parent = this;
|
|
7510
|
+
this.children.push( object );
|
|
7504
7511
|
|
|
7505
7512
|
object.updateWorldMatrix( false, true );
|
|
7506
7513
|
|
|
7514
|
+
object.dispatchEvent( _addedEvent );
|
|
7515
|
+
|
|
7516
|
+
_childaddedEvent.child = object;
|
|
7517
|
+
this.dispatchEvent( _childaddedEvent );
|
|
7518
|
+
_childaddedEvent.child = null;
|
|
7519
|
+
|
|
7507
7520
|
return this;
|
|
7508
7521
|
|
|
7509
7522
|
}
|
|
@@ -12130,13 +12143,22 @@ function cloneUniformsGroups( src ) {
|
|
|
12130
12143
|
|
|
12131
12144
|
function getUnlitUniformColorSpace( renderer ) {
|
|
12132
12145
|
|
|
12133
|
-
|
|
12146
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
12147
|
+
|
|
12148
|
+
if ( currentRenderTarget === null ) {
|
|
12134
12149
|
|
|
12135
12150
|
// https://github.com/mrdoob/three.js/pull/23937#issuecomment-1111067398
|
|
12136
12151
|
return renderer.outputColorSpace;
|
|
12137
12152
|
|
|
12138
12153
|
}
|
|
12139
12154
|
|
|
12155
|
+
// https://github.com/mrdoob/three.js/issues/27868
|
|
12156
|
+
if ( currentRenderTarget.isXRRenderTarget === true ) {
|
|
12157
|
+
|
|
12158
|
+
return currentRenderTarget.texture.colorSpace;
|
|
12159
|
+
|
|
12160
|
+
}
|
|
12161
|
+
|
|
12140
12162
|
return ColorManagement.workingColorSpace;
|
|
12141
12163
|
|
|
12142
12164
|
}
|
|
@@ -12178,10 +12200,6 @@ class ShaderMaterial extends Material {
|
|
|
12178
12200
|
this.forceSinglePass = true;
|
|
12179
12201
|
|
|
12180
12202
|
this.extensions = {
|
|
12181
|
-
derivatives: false, // set to use derivatives
|
|
12182
|
-
fragDepth: false, // set to use fragment depth values
|
|
12183
|
-
drawBuffers: false, // set to use draw buffers
|
|
12184
|
-
shaderTextureLOD: false, // set to use shader texture LOD
|
|
12185
12203
|
clipCullDistance: false, // set to use vertex shader clipping
|
|
12186
12204
|
multiDraw: false // set to use vertex shader multi_draw / enable gl_DrawID
|
|
12187
12205
|
};
|
|
@@ -13422,9 +13440,7 @@ function WebGLAnimation() {
|
|
|
13422
13440
|
|
|
13423
13441
|
}
|
|
13424
13442
|
|
|
13425
|
-
function WebGLAttributes( gl
|
|
13426
|
-
|
|
13427
|
-
const isWebGL2 = capabilities.isWebGL2;
|
|
13443
|
+
function WebGLAttributes( gl ) {
|
|
13428
13444
|
|
|
13429
13445
|
const buffers = new WeakMap();
|
|
13430
13446
|
|
|
@@ -13451,15 +13467,7 @@ function WebGLAttributes( gl, capabilities ) {
|
|
|
13451
13467
|
|
|
13452
13468
|
if ( attribute.isFloat16BufferAttribute ) {
|
|
13453
13469
|
|
|
13454
|
-
|
|
13455
|
-
|
|
13456
|
-
type = gl.HALF_FLOAT;
|
|
13457
|
-
|
|
13458
|
-
} else {
|
|
13459
|
-
|
|
13460
|
-
throw new Error( 'THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.' );
|
|
13461
|
-
|
|
13462
|
-
}
|
|
13470
|
+
type = gl.HALF_FLOAT;
|
|
13463
13471
|
|
|
13464
13472
|
} else {
|
|
13465
13473
|
|
|
@@ -13527,17 +13535,9 @@ function WebGLAttributes( gl, capabilities ) {
|
|
|
13527
13535
|
for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
|
|
13528
13536
|
|
|
13529
13537
|
const range = updateRanges[ i ];
|
|
13530
|
-
if ( isWebGL2 ) {
|
|
13531
13538
|
|
|
13532
|
-
|
|
13533
|
-
|
|
13534
|
-
|
|
13535
|
-
} else {
|
|
13536
|
-
|
|
13537
|
-
gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
|
|
13538
|
-
array.subarray( range.start, range.start + range.count ) );
|
|
13539
|
-
|
|
13540
|
-
}
|
|
13539
|
+
gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
|
|
13540
|
+
array, range.start, range.count );
|
|
13541
13541
|
|
|
13542
13542
|
}
|
|
13543
13543
|
|
|
@@ -13548,17 +13548,8 @@ function WebGLAttributes( gl, capabilities ) {
|
|
|
13548
13548
|
// @deprecated, r159
|
|
13549
13549
|
if ( updateRange.count !== - 1 ) {
|
|
13550
13550
|
|
|
13551
|
-
|
|
13552
|
-
|
|
13553
|
-
gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
|
|
13554
|
-
array, updateRange.offset, updateRange.count );
|
|
13555
|
-
|
|
13556
|
-
} else {
|
|
13557
|
-
|
|
13558
|
-
gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
|
|
13559
|
-
array.subarray( updateRange.offset, updateRange.offset + updateRange.count ) );
|
|
13560
|
-
|
|
13561
|
-
}
|
|
13551
|
+
gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
|
|
13552
|
+
array, updateRange.offset, updateRange.count );
|
|
13562
13553
|
|
|
13563
13554
|
updateRange.count = - 1; // reset range
|
|
13564
13555
|
|
|
@@ -13857,13 +13848,13 @@ var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGH
|
|
|
13857
13848
|
|
|
13858
13849
|
var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif";
|
|
13859
13850
|
|
|
13860
|
-
var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF )
|
|
13851
|
+
var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
|
|
13861
13852
|
|
|
13862
|
-
var logdepthbuf_pars_fragment = "#if defined( USE_LOGDEPTHBUF )
|
|
13853
|
+
var logdepthbuf_pars_fragment = "#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif";
|
|
13863
13854
|
|
|
13864
|
-
var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\
|
|
13855
|
+
var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif";
|
|
13865
13856
|
|
|
13866
|
-
var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\
|
|
13857
|
+
var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif";
|
|
13867
13858
|
|
|
13868
13859
|
var map_fragment = "#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif";
|
|
13869
13860
|
|
|
@@ -13923,7 +13914,7 @@ var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUG
|
|
|
13923
13914
|
|
|
13924
13915
|
var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
|
|
13925
13916
|
|
|
13926
|
-
var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\
|
|
13917
|
+
var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n#endif";
|
|
13927
13918
|
|
|
13928
13919
|
var shadowmap_pars_vertex = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif";
|
|
13929
13920
|
|
|
@@ -13945,7 +13936,7 @@ var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D spe
|
|
|
13945
13936
|
|
|
13946
13937
|
var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
|
|
13947
13938
|
|
|
13948
|
-
var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tfloat startCompression = 0.8 - 0.04;\n\tfloat desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min(color.r, min(color.g, color.b));\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max(color.r, max(color.g, color.b));\n\tif (peak < startCompression) return color;\n\tfloat d = 1. - startCompression;\n\tfloat newPeak = 1. - d * d / (peak + d - startCompression);\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);\n\treturn mix(color, vec3(1, 1, 1), g);\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }";
|
|
13939
|
+
var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tfloat startCompression = 0.8 - 0.04;\n\tfloat desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min(color.r, min(color.g, color.b));\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max(color.r, max(color.g, color.b));\n\tif (peak < startCompression) return color;\n\tfloat d = 1. - startCompression;\n\tfloat newPeak = 1. - d * d / (peak + d - startCompression);\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);\n\treturn mix(color, newPeak * vec3(1, 1, 1), g);\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }";
|
|
13949
13940
|
|
|
13950
13941
|
var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif";
|
|
13951
13942
|
|
|
@@ -14486,7 +14477,7 @@ const ShaderLib = {
|
|
|
14486
14477
|
emissive: { value: /*@__PURE__*/ new Color( 0x000000 ) },
|
|
14487
14478
|
roughness: { value: 1.0 },
|
|
14488
14479
|
metalness: { value: 0.0 },
|
|
14489
|
-
envMapIntensity: { value: 1 }
|
|
14480
|
+
envMapIntensity: { value: 1 }
|
|
14490
14481
|
}
|
|
14491
14482
|
] ),
|
|
14492
14483
|
|
|
@@ -14992,13 +14983,10 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
14992
14983
|
|
|
14993
14984
|
}
|
|
14994
14985
|
|
|
14995
|
-
function WebGLBindingStates( gl,
|
|
14986
|
+
function WebGLBindingStates( gl, attributes ) {
|
|
14996
14987
|
|
|
14997
14988
|
const maxVertexAttributes = gl.getParameter( gl.MAX_VERTEX_ATTRIBS );
|
|
14998
14989
|
|
|
14999
|
-
const extension = capabilities.isWebGL2 ? null : extensions.get( 'OES_vertex_array_object' );
|
|
15000
|
-
const vaoAvailable = capabilities.isWebGL2 || extension !== null;
|
|
15001
|
-
|
|
15002
14990
|
const bindingStates = {};
|
|
15003
14991
|
|
|
15004
14992
|
const defaultState = createBindingState( null );
|
|
@@ -15009,38 +14997,18 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
|
|
|
15009
14997
|
|
|
15010
14998
|
let updateBuffers = false;
|
|
15011
14999
|
|
|
15012
|
-
|
|
15013
|
-
|
|
15014
|
-
const state = getBindingState( geometry, program, material );
|
|
15015
|
-
|
|
15016
|
-
if ( currentState !== state ) {
|
|
15017
|
-
|
|
15018
|
-
currentState = state;
|
|
15019
|
-
bindVertexArrayObject( currentState.object );
|
|
15000
|
+
const state = getBindingState( geometry, program, material );
|
|
15020
15001
|
|
|
15021
|
-
|
|
15022
|
-
|
|
15023
|
-
updateBuffers = needsUpdate( object, geometry, program, index );
|
|
15024
|
-
|
|
15025
|
-
if ( updateBuffers ) saveCache( object, geometry, program, index );
|
|
15026
|
-
|
|
15027
|
-
} else {
|
|
15002
|
+
if ( currentState !== state ) {
|
|
15028
15003
|
|
|
15029
|
-
|
|
15004
|
+
currentState = state;
|
|
15005
|
+
bindVertexArrayObject( currentState.object );
|
|
15030
15006
|
|
|
15031
|
-
|
|
15032
|
-
currentState.program !== program.id ||
|
|
15033
|
-
currentState.wireframe !== wireframe ) {
|
|
15034
|
-
|
|
15035
|
-
currentState.geometry = geometry.id;
|
|
15036
|
-
currentState.program = program.id;
|
|
15037
|
-
currentState.wireframe = wireframe;
|
|
15007
|
+
}
|
|
15038
15008
|
|
|
15039
|
-
|
|
15009
|
+
updateBuffers = needsUpdate( object, geometry, program, index );
|
|
15040
15010
|
|
|
15041
|
-
|
|
15042
|
-
|
|
15043
|
-
}
|
|
15011
|
+
if ( updateBuffers ) saveCache( object, geometry, program, index );
|
|
15044
15012
|
|
|
15045
15013
|
if ( index !== null ) {
|
|
15046
15014
|
|
|
@@ -15066,25 +15034,19 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
|
|
|
15066
15034
|
|
|
15067
15035
|
function createVertexArrayObject() {
|
|
15068
15036
|
|
|
15069
|
-
|
|
15070
|
-
|
|
15071
|
-
return extension.createVertexArrayOES();
|
|
15037
|
+
return gl.createVertexArray();
|
|
15072
15038
|
|
|
15073
15039
|
}
|
|
15074
15040
|
|
|
15075
15041
|
function bindVertexArrayObject( vao ) {
|
|
15076
15042
|
|
|
15077
|
-
|
|
15078
|
-
|
|
15079
|
-
return extension.bindVertexArrayOES( vao );
|
|
15043
|
+
return gl.bindVertexArray( vao );
|
|
15080
15044
|
|
|
15081
15045
|
}
|
|
15082
15046
|
|
|
15083
15047
|
function deleteVertexArrayObject( vao ) {
|
|
15084
15048
|
|
|
15085
|
-
|
|
15086
|
-
|
|
15087
|
-
return extension.deleteVertexArrayOES( vao );
|
|
15049
|
+
return gl.deleteVertexArray( vao );
|
|
15088
15050
|
|
|
15089
15051
|
}
|
|
15090
15052
|
|
|
@@ -15282,9 +15244,7 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
|
|
|
15282
15244
|
|
|
15283
15245
|
if ( attributeDivisors[ attribute ] !== meshPerAttribute ) {
|
|
15284
15246
|
|
|
15285
|
-
|
|
15286
|
-
|
|
15287
|
-
extension[ capabilities.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, meshPerAttribute );
|
|
15247
|
+
gl.vertexAttribDivisor( attribute, meshPerAttribute );
|
|
15288
15248
|
attributeDivisors[ attribute ] = meshPerAttribute;
|
|
15289
15249
|
|
|
15290
15250
|
}
|
|
@@ -15325,12 +15285,6 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
|
|
|
15325
15285
|
|
|
15326
15286
|
function setupVertexAttributes( object, material, program, geometry ) {
|
|
15327
15287
|
|
|
15328
|
-
if ( capabilities.isWebGL2 === false && ( object.isInstancedMesh || geometry.isInstancedBufferGeometry ) ) {
|
|
15329
|
-
|
|
15330
|
-
if ( extensions.get( 'ANGLE_instanced_arrays' ) === null ) return;
|
|
15331
|
-
|
|
15332
|
-
}
|
|
15333
|
-
|
|
15334
15288
|
initAttributes();
|
|
15335
15289
|
|
|
15336
15290
|
const geometryAttributes = geometry.attributes;
|
|
@@ -15369,9 +15323,9 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
|
|
|
15369
15323
|
const type = attribute.type;
|
|
15370
15324
|
const bytesPerElement = attribute.bytesPerElement;
|
|
15371
15325
|
|
|
15372
|
-
// check for integer attributes
|
|
15326
|
+
// check for integer attributes
|
|
15373
15327
|
|
|
15374
|
-
const integer = (
|
|
15328
|
+
const integer = ( type === gl.INT || type === gl.UNSIGNED_INT || geometryAttribute.gpuType === IntType );
|
|
15375
15329
|
|
|
15376
15330
|
if ( geometryAttribute.isInterleavedBufferAttribute ) {
|
|
15377
15331
|
|
|
@@ -15619,9 +15573,7 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
|
|
|
15619
15573
|
|
|
15620
15574
|
}
|
|
15621
15575
|
|
|
15622
|
-
function WebGLBufferRenderer( gl, extensions, info
|
|
15623
|
-
|
|
15624
|
-
const isWebGL2 = capabilities.isWebGL2;
|
|
15576
|
+
function WebGLBufferRenderer( gl, extensions, info ) {
|
|
15625
15577
|
|
|
15626
15578
|
let mode;
|
|
15627
15579
|
|
|
@@ -15643,28 +15595,7 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
|
|
|
15643
15595
|
|
|
15644
15596
|
if ( primcount === 0 ) return;
|
|
15645
15597
|
|
|
15646
|
-
|
|
15647
|
-
|
|
15648
|
-
if ( isWebGL2 ) {
|
|
15649
|
-
|
|
15650
|
-
extension = gl;
|
|
15651
|
-
methodName = 'drawArraysInstanced';
|
|
15652
|
-
|
|
15653
|
-
} else {
|
|
15654
|
-
|
|
15655
|
-
extension = extensions.get( 'ANGLE_instanced_arrays' );
|
|
15656
|
-
methodName = 'drawArraysInstancedANGLE';
|
|
15657
|
-
|
|
15658
|
-
if ( extension === null ) {
|
|
15659
|
-
|
|
15660
|
-
console.error( 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
|
|
15661
|
-
return;
|
|
15662
|
-
|
|
15663
|
-
}
|
|
15664
|
-
|
|
15665
|
-
}
|
|
15666
|
-
|
|
15667
|
-
extension[ methodName ]( mode, start, count, primcount );
|
|
15598
|
+
gl.drawArraysInstanced( mode, start, count, primcount );
|
|
15668
15599
|
|
|
15669
15600
|
info.update( count, mode, primcount );
|
|
15670
15601
|
|
|
@@ -15675,6 +15606,7 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
|
|
|
15675
15606
|
if ( drawCount === 0 ) return;
|
|
15676
15607
|
|
|
15677
15608
|
const extension = extensions.get( 'WEBGL_multi_draw' );
|
|
15609
|
+
|
|
15678
15610
|
if ( extension === null ) {
|
|
15679
15611
|
|
|
15680
15612
|
for ( let i = 0; i < drawCount; i ++ ) {
|
|
@@ -15763,8 +15695,6 @@ function WebGLCapabilities( gl, extensions, parameters ) {
|
|
|
15763
15695
|
|
|
15764
15696
|
}
|
|
15765
15697
|
|
|
15766
|
-
const isWebGL2 = typeof WebGL2RenderingContext !== 'undefined' && gl.constructor.name === 'WebGL2RenderingContext';
|
|
15767
|
-
|
|
15768
15698
|
let precision = parameters.precision !== undefined ? parameters.precision : 'highp';
|
|
15769
15699
|
const maxPrecision = getMaxPrecision( precision );
|
|
15770
15700
|
|
|
@@ -15775,8 +15705,6 @@ function WebGLCapabilities( gl, extensions, parameters ) {
|
|
|
15775
15705
|
|
|
15776
15706
|
}
|
|
15777
15707
|
|
|
15778
|
-
const drawBuffers = isWebGL2 || extensions.has( 'WEBGL_draw_buffers' );
|
|
15779
|
-
|
|
15780
15708
|
const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
|
|
15781
15709
|
|
|
15782
15710
|
const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
|
|
@@ -15790,16 +15718,12 @@ function WebGLCapabilities( gl, extensions, parameters ) {
|
|
|
15790
15718
|
const maxFragmentUniforms = gl.getParameter( gl.MAX_FRAGMENT_UNIFORM_VECTORS );
|
|
15791
15719
|
|
|
15792
15720
|
const vertexTextures = maxVertexTextures > 0;
|
|
15793
|
-
const floatFragmentTextures = isWebGL2 || extensions.has( 'OES_texture_float' );
|
|
15794
|
-
const floatVertexTextures = vertexTextures && floatFragmentTextures;
|
|
15795
15721
|
|
|
15796
|
-
const maxSamples =
|
|
15722
|
+
const maxSamples = gl.getParameter( gl.MAX_SAMPLES );
|
|
15797
15723
|
|
|
15798
15724
|
return {
|
|
15799
15725
|
|
|
15800
|
-
isWebGL2:
|
|
15801
|
-
|
|
15802
|
-
drawBuffers: drawBuffers,
|
|
15726
|
+
isWebGL2: true, // keeping this for backwards compatibility
|
|
15803
15727
|
|
|
15804
15728
|
getMaxAnisotropy: getMaxAnisotropy,
|
|
15805
15729
|
getMaxPrecision: getMaxPrecision,
|
|
@@ -15818,8 +15742,6 @@ function WebGLCapabilities( gl, extensions, parameters ) {
|
|
|
15818
15742
|
maxFragmentUniforms: maxFragmentUniforms,
|
|
15819
15743
|
|
|
15820
15744
|
vertexTextures: vertexTextures,
|
|
15821
|
-
floatFragmentTextures: floatFragmentTextures,
|
|
15822
|
-
floatVertexTextures: floatVertexTextures,
|
|
15823
15745
|
|
|
15824
15746
|
maxSamples: maxSamples
|
|
15825
15747
|
|
|
@@ -16238,6 +16160,7 @@ const _clearColor = /*@__PURE__*/ new Color();
|
|
|
16238
16160
|
let _oldTarget = null;
|
|
16239
16161
|
let _oldActiveCubeFace = 0;
|
|
16240
16162
|
let _oldActiveMipmapLevel = 0;
|
|
16163
|
+
let _oldXrEnabled = false;
|
|
16241
16164
|
|
|
16242
16165
|
// Golden Ratio
|
|
16243
16166
|
const PHI = ( 1 + Math.sqrt( 5 ) ) / 2;
|
|
@@ -16305,6 +16228,9 @@ class PMREMGenerator {
|
|
|
16305
16228
|
_oldTarget = this._renderer.getRenderTarget();
|
|
16306
16229
|
_oldActiveCubeFace = this._renderer.getActiveCubeFace();
|
|
16307
16230
|
_oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();
|
|
16231
|
+
_oldXrEnabled = this._renderer.xr.enabled;
|
|
16232
|
+
|
|
16233
|
+
this._renderer.xr.enabled = false;
|
|
16308
16234
|
|
|
16309
16235
|
this._setSize( 256 );
|
|
16310
16236
|
|
|
@@ -16420,6 +16346,8 @@ class PMREMGenerator {
|
|
|
16420
16346
|
_cleanup( outputTarget ) {
|
|
16421
16347
|
|
|
16422
16348
|
this._renderer.setRenderTarget( _oldTarget, _oldActiveCubeFace, _oldActiveMipmapLevel );
|
|
16349
|
+
this._renderer.xr.enabled = _oldXrEnabled;
|
|
16350
|
+
|
|
16423
16351
|
outputTarget.scissorTest = false;
|
|
16424
16352
|
_setViewport( outputTarget, 0, 0, outputTarget.width, outputTarget.height );
|
|
16425
16353
|
|
|
@@ -16440,6 +16368,9 @@ class PMREMGenerator {
|
|
|
16440
16368
|
_oldTarget = this._renderer.getRenderTarget();
|
|
16441
16369
|
_oldActiveCubeFace = this._renderer.getActiveCubeFace();
|
|
16442
16370
|
_oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();
|
|
16371
|
+
_oldXrEnabled = this._renderer.xr.enabled;
|
|
16372
|
+
|
|
16373
|
+
this._renderer.xr.enabled = false;
|
|
16443
16374
|
|
|
16444
16375
|
const cubeUVRenderTarget = renderTarget || this._allocateTargets();
|
|
16445
16376
|
this._textureToCubeUV( texture, cubeUVRenderTarget );
|
|
@@ -17122,24 +17053,26 @@ function WebGLCubeUVMaps( renderer ) {
|
|
|
17122
17053
|
|
|
17123
17054
|
if ( isEquirectMap || isCubeMap ) {
|
|
17124
17055
|
|
|
17125
|
-
|
|
17056
|
+
let renderTarget = cubeUVmaps.get( texture );
|
|
17126
17057
|
|
|
17127
|
-
|
|
17058
|
+
const currentPMREMVersion = renderTarget !== undefined ? renderTarget.texture.pmremVersion : 0;
|
|
17128
17059
|
|
|
17129
|
-
|
|
17060
|
+
if ( texture.isRenderTargetTexture && texture.pmremVersion !== currentPMREMVersion ) {
|
|
17130
17061
|
|
|
17131
17062
|
if ( pmremGenerator === null ) pmremGenerator = new PMREMGenerator( renderer );
|
|
17132
17063
|
|
|
17133
17064
|
renderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular( texture, renderTarget ) : pmremGenerator.fromCubemap( texture, renderTarget );
|
|
17065
|
+
renderTarget.texture.pmremVersion = texture.pmremVersion;
|
|
17066
|
+
|
|
17134
17067
|
cubeUVmaps.set( texture, renderTarget );
|
|
17135
17068
|
|
|
17136
17069
|
return renderTarget.texture;
|
|
17137
17070
|
|
|
17138
17071
|
} else {
|
|
17139
17072
|
|
|
17140
|
-
if (
|
|
17073
|
+
if ( renderTarget !== undefined ) {
|
|
17141
17074
|
|
|
17142
|
-
return
|
|
17075
|
+
return renderTarget.texture;
|
|
17143
17076
|
|
|
17144
17077
|
} else {
|
|
17145
17078
|
|
|
@@ -17149,7 +17082,9 @@ function WebGLCubeUVMaps( renderer ) {
|
|
|
17149
17082
|
|
|
17150
17083
|
if ( pmremGenerator === null ) pmremGenerator = new PMREMGenerator( renderer );
|
|
17151
17084
|
|
|
17152
|
-
|
|
17085
|
+
renderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular( texture ) : pmremGenerator.fromCubemap( texture );
|
|
17086
|
+
renderTarget.texture.pmremVersion = texture.pmremVersion;
|
|
17087
|
+
|
|
17153
17088
|
cubeUVmaps.set( texture, renderTarget );
|
|
17154
17089
|
|
|
17155
17090
|
texture.addEventListener( 'dispose', onTextureDispose );
|
|
@@ -17280,29 +17215,14 @@ function WebGLExtensions( gl ) {
|
|
|
17280
17215
|
|
|
17281
17216
|
},
|
|
17282
17217
|
|
|
17283
|
-
init: function (
|
|
17284
|
-
|
|
17285
|
-
if ( capabilities.isWebGL2 ) {
|
|
17286
|
-
|
|
17287
|
-
getExtension( 'EXT_color_buffer_float' );
|
|
17288
|
-
getExtension( 'WEBGL_clip_cull_distance' );
|
|
17289
|
-
|
|
17290
|
-
} else {
|
|
17291
|
-
|
|
17292
|
-
getExtension( 'WEBGL_depth_texture' );
|
|
17293
|
-
getExtension( 'OES_texture_float' );
|
|
17294
|
-
getExtension( 'OES_texture_half_float' );
|
|
17295
|
-
getExtension( 'OES_texture_half_float_linear' );
|
|
17296
|
-
getExtension( 'OES_standard_derivatives' );
|
|
17297
|
-
getExtension( 'OES_element_index_uint' );
|
|
17298
|
-
getExtension( 'OES_vertex_array_object' );
|
|
17299
|
-
getExtension( 'ANGLE_instanced_arrays' );
|
|
17300
|
-
|
|
17301
|
-
}
|
|
17218
|
+
init: function () {
|
|
17302
17219
|
|
|
17220
|
+
getExtension( 'EXT_color_buffer_float' );
|
|
17221
|
+
getExtension( 'WEBGL_clip_cull_distance' );
|
|
17303
17222
|
getExtension( 'OES_texture_float_linear' );
|
|
17304
17223
|
getExtension( 'EXT_color_buffer_half_float' );
|
|
17305
17224
|
getExtension( 'WEBGL_multisampled_render_to_texture' );
|
|
17225
|
+
getExtension( 'WEBGL_render_shared_exponent' );
|
|
17306
17226
|
|
|
17307
17227
|
},
|
|
17308
17228
|
|
|
@@ -17530,9 +17450,7 @@ function WebGLGeometries( gl, attributes, info, bindingStates ) {
|
|
|
17530
17450
|
|
|
17531
17451
|
}
|
|
17532
17452
|
|
|
17533
|
-
function WebGLIndexedBufferRenderer( gl, extensions, info
|
|
17534
|
-
|
|
17535
|
-
const isWebGL2 = capabilities.isWebGL2;
|
|
17453
|
+
function WebGLIndexedBufferRenderer( gl, extensions, info ) {
|
|
17536
17454
|
|
|
17537
17455
|
let mode;
|
|
17538
17456
|
|
|
@@ -17563,28 +17481,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {
|
|
|
17563
17481
|
|
|
17564
17482
|
if ( primcount === 0 ) return;
|
|
17565
17483
|
|
|
17566
|
-
|
|
17567
|
-
|
|
17568
|
-
if ( isWebGL2 ) {
|
|
17569
|
-
|
|
17570
|
-
extension = gl;
|
|
17571
|
-
methodName = 'drawElementsInstanced';
|
|
17572
|
-
|
|
17573
|
-
} else {
|
|
17574
|
-
|
|
17575
|
-
extension = extensions.get( 'ANGLE_instanced_arrays' );
|
|
17576
|
-
methodName = 'drawElementsInstancedANGLE';
|
|
17577
|
-
|
|
17578
|
-
if ( extension === null ) {
|
|
17579
|
-
|
|
17580
|
-
console.error( 'THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
|
|
17581
|
-
return;
|
|
17582
|
-
|
|
17583
|
-
}
|
|
17584
|
-
|
|
17585
|
-
}
|
|
17586
|
-
|
|
17587
|
-
extension[ methodName ]( mode, count, type, start * bytesPerElement, primcount );
|
|
17484
|
+
gl.drawElementsInstanced( mode, count, type, start * bytesPerElement, primcount );
|
|
17588
17485
|
|
|
17589
17486
|
info.update( count, mode, primcount );
|
|
17590
17487
|
|
|
@@ -17595,6 +17492,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {
|
|
|
17595
17492
|
if ( drawCount === 0 ) return;
|
|
17596
17493
|
|
|
17597
17494
|
const extension = extensions.get( 'WEBGL_multi_draw' );
|
|
17495
|
+
|
|
17598
17496
|
if ( extension === null ) {
|
|
17599
17497
|
|
|
17600
17498
|
for ( let i = 0; i < drawCount; i ++ ) {
|
|
@@ -17699,296 +17597,158 @@ function WebGLInfo( gl ) {
|
|
|
17699
17597
|
|
|
17700
17598
|
}
|
|
17701
17599
|
|
|
17702
|
-
function numericalSort( a, b ) {
|
|
17703
|
-
|
|
17704
|
-
return a[ 0 ] - b[ 0 ];
|
|
17705
|
-
|
|
17706
|
-
}
|
|
17707
|
-
|
|
17708
|
-
function absNumericalSort( a, b ) {
|
|
17709
|
-
|
|
17710
|
-
return Math.abs( b[ 1 ] ) - Math.abs( a[ 1 ] );
|
|
17711
|
-
|
|
17712
|
-
}
|
|
17713
|
-
|
|
17714
17600
|
function WebGLMorphtargets( gl, capabilities, textures ) {
|
|
17715
17601
|
|
|
17716
|
-
const influencesList = {};
|
|
17717
|
-
const morphInfluences = new Float32Array( 8 );
|
|
17718
17602
|
const morphTextures = new WeakMap();
|
|
17719
17603
|
const morph = new Vector4();
|
|
17720
17604
|
|
|
17721
|
-
const workInfluences = [];
|
|
17722
|
-
|
|
17723
|
-
for ( let i = 0; i < 8; i ++ ) {
|
|
17724
|
-
|
|
17725
|
-
workInfluences[ i ] = [ i, 0 ];
|
|
17726
|
-
|
|
17727
|
-
}
|
|
17728
|
-
|
|
17729
17605
|
function update( object, geometry, program ) {
|
|
17730
17606
|
|
|
17731
17607
|
const objectInfluences = object.morphTargetInfluences;
|
|
17732
17608
|
|
|
17733
|
-
|
|
17734
|
-
|
|
17735
|
-
// instead of using attributes, the WebGL 2 code path encodes morph targets
|
|
17736
|
-
// into an array of data textures. Each layer represents a single morph target.
|
|
17737
|
-
|
|
17738
|
-
const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
|
|
17739
|
-
const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
|
|
17740
|
-
|
|
17741
|
-
let entry = morphTextures.get( geometry );
|
|
17742
|
-
|
|
17743
|
-
if ( entry === undefined || entry.count !== morphTargetsCount ) {
|
|
17744
|
-
|
|
17745
|
-
if ( entry !== undefined ) entry.texture.dispose();
|
|
17746
|
-
|
|
17747
|
-
const hasMorphPosition = geometry.morphAttributes.position !== undefined;
|
|
17748
|
-
const hasMorphNormals = geometry.morphAttributes.normal !== undefined;
|
|
17749
|
-
const hasMorphColors = geometry.morphAttributes.color !== undefined;
|
|
17750
|
-
|
|
17751
|
-
const morphTargets = geometry.morphAttributes.position || [];
|
|
17752
|
-
const morphNormals = geometry.morphAttributes.normal || [];
|
|
17753
|
-
const morphColors = geometry.morphAttributes.color || [];
|
|
17609
|
+
// instead of using attributes, the WebGL 2 code path encodes morph targets
|
|
17610
|
+
// into an array of data textures. Each layer represents a single morph target.
|
|
17754
17611
|
|
|
17755
|
-
|
|
17612
|
+
const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
|
|
17613
|
+
const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
|
|
17756
17614
|
|
|
17757
|
-
|
|
17758
|
-
if ( hasMorphNormals === true ) vertexDataCount = 2;
|
|
17759
|
-
if ( hasMorphColors === true ) vertexDataCount = 3;
|
|
17615
|
+
let entry = morphTextures.get( geometry );
|
|
17760
17616
|
|
|
17761
|
-
|
|
17762
|
-
let height = 1;
|
|
17617
|
+
if ( entry === undefined || entry.count !== morphTargetsCount ) {
|
|
17763
17618
|
|
|
17764
|
-
|
|
17619
|
+
if ( entry !== undefined ) entry.texture.dispose();
|
|
17765
17620
|
|
|
17766
|
-
|
|
17767
|
-
|
|
17621
|
+
const hasMorphPosition = geometry.morphAttributes.position !== undefined;
|
|
17622
|
+
const hasMorphNormals = geometry.morphAttributes.normal !== undefined;
|
|
17623
|
+
const hasMorphColors = geometry.morphAttributes.color !== undefined;
|
|
17768
17624
|
|
|
17769
|
-
|
|
17625
|
+
const morphTargets = geometry.morphAttributes.position || [];
|
|
17626
|
+
const morphNormals = geometry.morphAttributes.normal || [];
|
|
17627
|
+
const morphColors = geometry.morphAttributes.color || [];
|
|
17770
17628
|
|
|
17771
|
-
|
|
17772
|
-
|
|
17773
|
-
const texture = new DataArrayTexture( buffer, width, height, morphTargetsCount );
|
|
17774
|
-
texture.type = FloatType;
|
|
17775
|
-
texture.needsUpdate = true;
|
|
17629
|
+
let vertexDataCount = 0;
|
|
17776
17630
|
|
|
17777
|
-
|
|
17631
|
+
if ( hasMorphPosition === true ) vertexDataCount = 1;
|
|
17632
|
+
if ( hasMorphNormals === true ) vertexDataCount = 2;
|
|
17633
|
+
if ( hasMorphColors === true ) vertexDataCount = 3;
|
|
17778
17634
|
|
|
17779
|
-
|
|
17635
|
+
let width = geometry.attributes.position.count * vertexDataCount;
|
|
17636
|
+
let height = 1;
|
|
17780
17637
|
|
|
17781
|
-
|
|
17638
|
+
if ( width > capabilities.maxTextureSize ) {
|
|
17782
17639
|
|
|
17783
|
-
|
|
17784
|
-
|
|
17785
|
-
const morphColor = morphColors[ i ];
|
|
17640
|
+
height = Math.ceil( width / capabilities.maxTextureSize );
|
|
17641
|
+
width = capabilities.maxTextureSize;
|
|
17786
17642
|
|
|
17787
|
-
|
|
17788
|
-
|
|
17789
|
-
for ( let j = 0; j < morphTarget.count; j ++ ) {
|
|
17790
|
-
|
|
17791
|
-
const stride = j * vertexDataStride;
|
|
17643
|
+
}
|
|
17792
17644
|
|
|
17793
|
-
|
|
17645
|
+
const buffer = new Float32Array( width * height * 4 * morphTargetsCount );
|
|
17794
17646
|
|
|
17795
|
-
|
|
17647
|
+
const texture = new DataArrayTexture( buffer, width, height, morphTargetsCount );
|
|
17648
|
+
texture.type = FloatType;
|
|
17649
|
+
texture.needsUpdate = true;
|
|
17796
17650
|
|
|
17797
|
-
|
|
17798
|
-
buffer[ offset + stride + 1 ] = morph.y;
|
|
17799
|
-
buffer[ offset + stride + 2 ] = morph.z;
|
|
17800
|
-
buffer[ offset + stride + 3 ] = 0;
|
|
17651
|
+
// fill buffer
|
|
17801
17652
|
|
|
17802
|
-
|
|
17653
|
+
const vertexDataStride = vertexDataCount * 4;
|
|
17803
17654
|
|
|
17804
|
-
|
|
17655
|
+
for ( let i = 0; i < morphTargetsCount; i ++ ) {
|
|
17805
17656
|
|
|
17806
|
-
|
|
17657
|
+
const morphTarget = morphTargets[ i ];
|
|
17658
|
+
const morphNormal = morphNormals[ i ];
|
|
17659
|
+
const morphColor = morphColors[ i ];
|
|
17807
17660
|
|
|
17808
|
-
|
|
17809
|
-
buffer[ offset + stride + 5 ] = morph.y;
|
|
17810
|
-
buffer[ offset + stride + 6 ] = morph.z;
|
|
17811
|
-
buffer[ offset + stride + 7 ] = 0;
|
|
17661
|
+
const offset = width * height * 4 * i;
|
|
17812
17662
|
|
|
17813
|
-
|
|
17663
|
+
for ( let j = 0; j < morphTarget.count; j ++ ) {
|
|
17814
17664
|
|
|
17815
|
-
|
|
17665
|
+
const stride = j * vertexDataStride;
|
|
17816
17666
|
|
|
17817
|
-
|
|
17667
|
+
if ( hasMorphPosition === true ) {
|
|
17818
17668
|
|
|
17819
|
-
|
|
17820
|
-
buffer[ offset + stride + 9 ] = morph.y;
|
|
17821
|
-
buffer[ offset + stride + 10 ] = morph.z;
|
|
17822
|
-
buffer[ offset + stride + 11 ] = ( morphColor.itemSize === 4 ) ? morph.w : 1;
|
|
17669
|
+
morph.fromBufferAttribute( morphTarget, j );
|
|
17823
17670
|
|
|
17824
|
-
|
|
17671
|
+
buffer[ offset + stride + 0 ] = morph.x;
|
|
17672
|
+
buffer[ offset + stride + 1 ] = morph.y;
|
|
17673
|
+
buffer[ offset + stride + 2 ] = morph.z;
|
|
17674
|
+
buffer[ offset + stride + 3 ] = 0;
|
|
17825
17675
|
|
|
17826
17676
|
}
|
|
17827
17677
|
|
|
17828
|
-
|
|
17829
|
-
|
|
17830
|
-
entry = {
|
|
17831
|
-
count: morphTargetsCount,
|
|
17832
|
-
texture: texture,
|
|
17833
|
-
size: new Vector2( width, height )
|
|
17834
|
-
};
|
|
17835
|
-
|
|
17836
|
-
morphTextures.set( geometry, entry );
|
|
17837
|
-
|
|
17838
|
-
function disposeTexture() {
|
|
17839
|
-
|
|
17840
|
-
texture.dispose();
|
|
17678
|
+
if ( hasMorphNormals === true ) {
|
|
17841
17679
|
|
|
17842
|
-
|
|
17680
|
+
morph.fromBufferAttribute( morphNormal, j );
|
|
17843
17681
|
|
|
17844
|
-
|
|
17682
|
+
buffer[ offset + stride + 4 ] = morph.x;
|
|
17683
|
+
buffer[ offset + stride + 5 ] = morph.y;
|
|
17684
|
+
buffer[ offset + stride + 6 ] = morph.z;
|
|
17685
|
+
buffer[ offset + stride + 7 ] = 0;
|
|
17845
17686
|
|
|
17846
|
-
|
|
17847
|
-
|
|
17848
|
-
geometry.addEventListener( 'dispose', disposeTexture );
|
|
17849
|
-
|
|
17850
|
-
}
|
|
17851
|
-
|
|
17852
|
-
//
|
|
17853
|
-
if ( object.isInstancedMesh === true && object.morphTexture !== null ) {
|
|
17687
|
+
}
|
|
17854
17688
|
|
|
17855
|
-
|
|
17689
|
+
if ( hasMorphColors === true ) {
|
|
17856
17690
|
|
|
17857
|
-
|
|
17691
|
+
morph.fromBufferAttribute( morphColor, j );
|
|
17858
17692
|
|
|
17859
|
-
|
|
17693
|
+
buffer[ offset + stride + 8 ] = morph.x;
|
|
17694
|
+
buffer[ offset + stride + 9 ] = morph.y;
|
|
17695
|
+
buffer[ offset + stride + 10 ] = morph.z;
|
|
17696
|
+
buffer[ offset + stride + 11 ] = ( morphColor.itemSize === 4 ) ? morph.w : 1;
|
|
17860
17697
|
|
|
17861
|
-
|
|
17862
|
-
|
|
17863
|
-
morphInfluencesSum += objectInfluences[ i ];
|
|
17698
|
+
}
|
|
17864
17699
|
|
|
17865
17700
|
}
|
|
17866
17701
|
|
|
17867
|
-
const morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;
|
|
17868
|
-
|
|
17869
|
-
|
|
17870
|
-
program.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence );
|
|
17871
|
-
program.getUniforms().setValue( gl, 'morphTargetInfluences', objectInfluences );
|
|
17872
|
-
|
|
17873
17702
|
}
|
|
17874
17703
|
|
|
17875
|
-
|
|
17876
|
-
|
|
17877
|
-
|
|
17878
|
-
|
|
17879
|
-
|
|
17880
|
-
// When object doesn't have morph target influences defined, we treat it as a 0-length array
|
|
17881
|
-
// This is important to make sure we set up morphTargetBaseInfluence / morphTargetInfluences
|
|
17882
|
-
|
|
17883
|
-
const length = objectInfluences === undefined ? 0 : objectInfluences.length;
|
|
17884
|
-
|
|
17885
|
-
let influences = influencesList[ geometry.id ];
|
|
17886
|
-
|
|
17887
|
-
if ( influences === undefined || influences.length !== length ) {
|
|
17888
|
-
|
|
17889
|
-
// initialise list
|
|
17890
|
-
|
|
17891
|
-
influences = [];
|
|
17892
|
-
|
|
17893
|
-
for ( let i = 0; i < length; i ++ ) {
|
|
17894
|
-
|
|
17895
|
-
influences[ i ] = [ i, 0 ];
|
|
17896
|
-
|
|
17897
|
-
}
|
|
17898
|
-
|
|
17899
|
-
influencesList[ geometry.id ] = influences;
|
|
17704
|
+
entry = {
|
|
17705
|
+
count: morphTargetsCount,
|
|
17706
|
+
texture: texture,
|
|
17707
|
+
size: new Vector2( width, height )
|
|
17708
|
+
};
|
|
17900
17709
|
|
|
17901
|
-
|
|
17710
|
+
morphTextures.set( geometry, entry );
|
|
17902
17711
|
|
|
17903
|
-
|
|
17712
|
+
function disposeTexture() {
|
|
17904
17713
|
|
|
17905
|
-
|
|
17714
|
+
texture.dispose();
|
|
17906
17715
|
|
|
17907
|
-
|
|
17716
|
+
morphTextures.delete( geometry );
|
|
17908
17717
|
|
|
17909
|
-
|
|
17910
|
-
influence[ 1 ] = objectInfluences[ i ];
|
|
17718
|
+
geometry.removeEventListener( 'dispose', disposeTexture );
|
|
17911
17719
|
|
|
17912
17720
|
}
|
|
17913
17721
|
|
|
17914
|
-
|
|
17722
|
+
geometry.addEventListener( 'dispose', disposeTexture );
|
|
17915
17723
|
|
|
17916
|
-
|
|
17917
|
-
|
|
17918
|
-
if ( i < length && influences[ i ][ 1 ] ) {
|
|
17919
|
-
|
|
17920
|
-
workInfluences[ i ][ 0 ] = influences[ i ][ 0 ];
|
|
17921
|
-
workInfluences[ i ][ 1 ] = influences[ i ][ 1 ];
|
|
17922
|
-
|
|
17923
|
-
} else {
|
|
17924
|
-
|
|
17925
|
-
workInfluences[ i ][ 0 ] = Number.MAX_SAFE_INTEGER;
|
|
17926
|
-
workInfluences[ i ][ 1 ] = 0;
|
|
17927
|
-
|
|
17928
|
-
}
|
|
17724
|
+
}
|
|
17929
17725
|
|
|
17930
|
-
|
|
17726
|
+
//
|
|
17727
|
+
if ( object.isInstancedMesh === true && object.morphTexture !== null ) {
|
|
17931
17728
|
|
|
17932
|
-
|
|
17729
|
+
program.getUniforms().setValue( gl, 'morphTexture', object.morphTexture, textures );
|
|
17933
17730
|
|
|
17934
|
-
|
|
17935
|
-
const morphNormals = geometry.morphAttributes.normal;
|
|
17731
|
+
} else {
|
|
17936
17732
|
|
|
17937
17733
|
let morphInfluencesSum = 0;
|
|
17938
17734
|
|
|
17939
|
-
for ( let i = 0; i <
|
|
17940
|
-
|
|
17941
|
-
const influence = workInfluences[ i ];
|
|
17942
|
-
const index = influence[ 0 ];
|
|
17943
|
-
const value = influence[ 1 ];
|
|
17944
|
-
|
|
17945
|
-
if ( index !== Number.MAX_SAFE_INTEGER && value ) {
|
|
17946
|
-
|
|
17947
|
-
if ( morphTargets && geometry.getAttribute( 'morphTarget' + i ) !== morphTargets[ index ] ) {
|
|
17948
|
-
|
|
17949
|
-
geometry.setAttribute( 'morphTarget' + i, morphTargets[ index ] );
|
|
17950
|
-
|
|
17951
|
-
}
|
|
17952
|
-
|
|
17953
|
-
if ( morphNormals && geometry.getAttribute( 'morphNormal' + i ) !== morphNormals[ index ] ) {
|
|
17954
|
-
|
|
17955
|
-
geometry.setAttribute( 'morphNormal' + i, morphNormals[ index ] );
|
|
17956
|
-
|
|
17957
|
-
}
|
|
17958
|
-
|
|
17959
|
-
morphInfluences[ i ] = value;
|
|
17960
|
-
morphInfluencesSum += value;
|
|
17961
|
-
|
|
17962
|
-
} else {
|
|
17963
|
-
|
|
17964
|
-
if ( morphTargets && geometry.hasAttribute( 'morphTarget' + i ) === true ) {
|
|
17965
|
-
|
|
17966
|
-
geometry.deleteAttribute( 'morphTarget' + i );
|
|
17967
|
-
|
|
17968
|
-
}
|
|
17735
|
+
for ( let i = 0; i < objectInfluences.length; i ++ ) {
|
|
17969
17736
|
|
|
17970
|
-
|
|
17971
|
-
|
|
17972
|
-
geometry.deleteAttribute( 'morphNormal' + i );
|
|
17973
|
-
|
|
17974
|
-
}
|
|
17975
|
-
|
|
17976
|
-
morphInfluences[ i ] = 0;
|
|
17977
|
-
|
|
17978
|
-
}
|
|
17737
|
+
morphInfluencesSum += objectInfluences[ i ];
|
|
17979
17738
|
|
|
17980
17739
|
}
|
|
17981
17740
|
|
|
17982
|
-
// GLSL shader uses formula baseinfluence * base + sum(target * influence)
|
|
17983
|
-
// This allows us to switch between absolute morphs and relative morphs without changing shader code
|
|
17984
|
-
// When baseinfluence = 1 - sum(influence), the above is equivalent to sum((target - base) * influence)
|
|
17985
17741
|
const morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;
|
|
17986
17742
|
|
|
17743
|
+
|
|
17987
17744
|
program.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence );
|
|
17988
|
-
program.getUniforms().setValue( gl, 'morphTargetInfluences',
|
|
17745
|
+
program.getUniforms().setValue( gl, 'morphTargetInfluences', objectInfluences );
|
|
17989
17746
|
|
|
17990
17747
|
}
|
|
17991
17748
|
|
|
17749
|
+
program.getUniforms().setValue( gl, 'morphTargetsTexture', entry.texture, textures );
|
|
17750
|
+
program.getUniforms().setValue( gl, 'morphTargetsTextureSize', entry.size );
|
|
17751
|
+
|
|
17992
17752
|
}
|
|
17993
17753
|
|
|
17994
17754
|
return {
|
|
@@ -19538,19 +19298,6 @@ function getToneMappingFunction( functionName, toneMapping ) {
|
|
|
19538
19298
|
|
|
19539
19299
|
}
|
|
19540
19300
|
|
|
19541
|
-
function generateExtensions( parameters ) {
|
|
19542
|
-
|
|
19543
|
-
const chunks = [
|
|
19544
|
-
( parameters.extensionDerivatives || !! parameters.envMapCubeUVHeight || parameters.bumpMap || parameters.normalMapTangentSpace || parameters.clearcoatNormalMap || parameters.flatShading || parameters.alphaToCoverage || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '',
|
|
19545
|
-
( parameters.extensionFragDepth || parameters.logarithmicDepthBuffer ) && parameters.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '',
|
|
19546
|
-
( parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ) ? '#extension GL_EXT_draw_buffers : require' : '',
|
|
19547
|
-
( parameters.extensionShaderTextureLOD || parameters.envMap || parameters.transmission ) && parameters.rendererExtensionShaderTextureLod ? '#extension GL_EXT_shader_texture_lod : enable' : ''
|
|
19548
|
-
];
|
|
19549
|
-
|
|
19550
|
-
return chunks.filter( filterEmptyLine ).join( '\n' );
|
|
19551
|
-
|
|
19552
|
-
}
|
|
19553
|
-
|
|
19554
19301
|
function generateVertexExtensions( parameters ) {
|
|
19555
19302
|
|
|
19556
19303
|
const chunks = [
|
|
@@ -19718,27 +19465,21 @@ function generatePrecision( parameters ) {
|
|
|
19718
19465
|
precision ${parameters.precision} int;
|
|
19719
19466
|
precision ${parameters.precision} sampler2D;
|
|
19720
19467
|
precision ${parameters.precision} samplerCube;
|
|
19468
|
+
precision ${parameters.precision} sampler3D;
|
|
19469
|
+
precision ${parameters.precision} sampler2DArray;
|
|
19470
|
+
precision ${parameters.precision} sampler2DShadow;
|
|
19471
|
+
precision ${parameters.precision} samplerCubeShadow;
|
|
19472
|
+
precision ${parameters.precision} sampler2DArrayShadow;
|
|
19473
|
+
precision ${parameters.precision} isampler2D;
|
|
19474
|
+
precision ${parameters.precision} isampler3D;
|
|
19475
|
+
precision ${parameters.precision} isamplerCube;
|
|
19476
|
+
precision ${parameters.precision} isampler2DArray;
|
|
19477
|
+
precision ${parameters.precision} usampler2D;
|
|
19478
|
+
precision ${parameters.precision} usampler3D;
|
|
19479
|
+
precision ${parameters.precision} usamplerCube;
|
|
19480
|
+
precision ${parameters.precision} usampler2DArray;
|
|
19721
19481
|
`;
|
|
19722
19482
|
|
|
19723
|
-
if ( parameters.isWebGL2 ) {
|
|
19724
|
-
|
|
19725
|
-
precisionstring += `precision ${parameters.precision} sampler3D;
|
|
19726
|
-
precision ${parameters.precision} sampler2DArray;
|
|
19727
|
-
precision ${parameters.precision} sampler2DShadow;
|
|
19728
|
-
precision ${parameters.precision} samplerCubeShadow;
|
|
19729
|
-
precision ${parameters.precision} sampler2DArrayShadow;
|
|
19730
|
-
precision ${parameters.precision} isampler2D;
|
|
19731
|
-
precision ${parameters.precision} isampler3D;
|
|
19732
|
-
precision ${parameters.precision} isamplerCube;
|
|
19733
|
-
precision ${parameters.precision} isampler2DArray;
|
|
19734
|
-
precision ${parameters.precision} usampler2D;
|
|
19735
|
-
precision ${parameters.precision} usampler3D;
|
|
19736
|
-
precision ${parameters.precision} usamplerCube;
|
|
19737
|
-
precision ${parameters.precision} usampler2DArray;
|
|
19738
|
-
`;
|
|
19739
|
-
|
|
19740
|
-
}
|
|
19741
|
-
|
|
19742
19483
|
if ( parameters.precision === 'highp' ) {
|
|
19743
19484
|
|
|
19744
19485
|
precisionstring += '\n#define HIGH_PRECISION';
|
|
@@ -19887,8 +19628,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19887
19628
|
const envMapBlendingDefine = generateEnvMapBlendingDefine( parameters );
|
|
19888
19629
|
const envMapCubeUVSize = generateCubeUVSize( parameters );
|
|
19889
19630
|
|
|
19890
|
-
const customExtensions = parameters.isWebGL2 ? '' : generateExtensions( parameters );
|
|
19891
|
-
|
|
19892
19631
|
const customVertexExtensions = generateVertexExtensions( parameters );
|
|
19893
19632
|
|
|
19894
19633
|
const customDefines = generateDefines( defines );
|
|
@@ -19919,8 +19658,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
19919
19658
|
|
|
19920
19659
|
prefixFragment = [
|
|
19921
19660
|
|
|
19922
|
-
customExtensions,
|
|
19923
|
-
|
|
19924
19661
|
'#define SHADER_TYPE ' + parameters.shaderType,
|
|
19925
19662
|
'#define SHADER_NAME ' + parameters.shaderName,
|
|
19926
19663
|
|
|
@@ -20042,10 +19779,10 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
20042
19779
|
|
|
20043
19780
|
parameters.morphTargets ? '#define USE_MORPHTARGETS' : '',
|
|
20044
19781
|
parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '',
|
|
20045
|
-
( parameters.morphColors
|
|
20046
|
-
( parameters.morphTargetsCount > 0
|
|
20047
|
-
( parameters.morphTargetsCount > 0
|
|
20048
|
-
( parameters.morphTargetsCount > 0
|
|
19782
|
+
( parameters.morphColors ) ? '#define USE_MORPHCOLORS' : '',
|
|
19783
|
+
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE' : '',
|
|
19784
|
+
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE_STRIDE ' + parameters.morphTextureStride : '',
|
|
19785
|
+
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '',
|
|
20049
19786
|
parameters.doubleSided ? '#define DOUBLE_SIDED' : '',
|
|
20050
19787
|
parameters.flipSided ? '#define FLIP_SIDED' : '',
|
|
20051
19788
|
|
|
@@ -20059,7 +19796,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
20059
19796
|
parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
|
|
20060
19797
|
|
|
20061
19798
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
20062
|
-
( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',
|
|
20063
19799
|
|
|
20064
19800
|
'uniform mat4 modelMatrix;',
|
|
20065
19801
|
'uniform mat4 modelViewMatrix;',
|
|
@@ -20163,8 +19899,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
20163
19899
|
|
|
20164
19900
|
prefixFragment = [
|
|
20165
19901
|
|
|
20166
|
-
customExtensions,
|
|
20167
|
-
|
|
20168
19902
|
generatePrecision( parameters ),
|
|
20169
19903
|
|
|
20170
19904
|
'#define SHADER_TYPE ' + parameters.shaderType,
|
|
@@ -20252,7 +19986,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
20252
19986
|
parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
|
|
20253
19987
|
|
|
20254
19988
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
20255
|
-
( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',
|
|
20256
19989
|
|
|
20257
19990
|
'uniform mat4 viewMatrix;',
|
|
20258
19991
|
'uniform vec3 cameraPosition;',
|
|
@@ -20287,7 +20020,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
20287
20020
|
vertexShader = unrollLoops( vertexShader );
|
|
20288
20021
|
fragmentShader = unrollLoops( fragmentShader );
|
|
20289
20022
|
|
|
20290
|
-
if ( parameters.
|
|
20023
|
+
if ( parameters.isRawShaderMaterial !== true ) {
|
|
20291
20024
|
|
|
20292
20025
|
// GLSL 3.0 conversion for built-in materials and ShaderMaterial
|
|
20293
20026
|
|
|
@@ -20295,14 +20028,12 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
20295
20028
|
|
|
20296
20029
|
prefixVertex = [
|
|
20297
20030
|
customVertexExtensions,
|
|
20298
|
-
'precision mediump sampler2DArray;',
|
|
20299
20031
|
'#define attribute in',
|
|
20300
20032
|
'#define varying out',
|
|
20301
20033
|
'#define texture2D texture'
|
|
20302
20034
|
].join( '\n' ) + '\n' + prefixVertex;
|
|
20303
20035
|
|
|
20304
20036
|
prefixFragment = [
|
|
20305
|
-
'precision mediump sampler2DArray;',
|
|
20306
20037
|
'#define varying in',
|
|
20307
20038
|
( parameters.glslVersion === GLSL3 ) ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;',
|
|
20308
20039
|
( parameters.glslVersion === GLSL3 ) ? '' : '#define gl_FragColor pc_fragColor',
|
|
@@ -20693,7 +20424,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20693
20424
|
const _activeChannels = new Set();
|
|
20694
20425
|
const programs = [];
|
|
20695
20426
|
|
|
20696
|
-
const IS_WEBGL2 = capabilities.isWebGL2;
|
|
20697
20427
|
const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
|
|
20698
20428
|
const SUPPORTS_VERTEX_TEXTURES = capabilities.vertexTextures;
|
|
20699
20429
|
|
|
@@ -20857,8 +20587,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
20857
20587
|
|
|
20858
20588
|
const parameters = {
|
|
20859
20589
|
|
|
20860
|
-
isWebGL2: IS_WEBGL2,
|
|
20861
|
-
|
|
20862
20590
|
shaderID: shaderID,
|
|
20863
20591
|
shaderType: material.type,
|
|
20864
20592
|
shaderName: material.name,
|
|
@@ -21033,16 +20761,9 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
21033
20761
|
|
|
21034
20762
|
index0AttributeName: material.index0AttributeName,
|
|
21035
20763
|
|
|
21036
|
-
extensionDerivatives: HAS_EXTENSIONS && material.extensions.derivatives === true,
|
|
21037
|
-
extensionFragDepth: HAS_EXTENSIONS && material.extensions.fragDepth === true,
|
|
21038
|
-
extensionDrawBuffers: HAS_EXTENSIONS && material.extensions.drawBuffers === true,
|
|
21039
|
-
extensionShaderTextureLOD: HAS_EXTENSIONS && material.extensions.shaderTextureLOD === true,
|
|
21040
20764
|
extensionClipCullDistance: HAS_EXTENSIONS && material.extensions.clipCullDistance === true && extensions.has( 'WEBGL_clip_cull_distance' ),
|
|
21041
20765
|
extensionMultiDraw: HAS_EXTENSIONS && material.extensions.multiDraw === true && extensions.has( 'WEBGL_multi_draw' ),
|
|
21042
20766
|
|
|
21043
|
-
rendererExtensionFragDepth: IS_WEBGL2 || extensions.has( 'EXT_frag_depth' ),
|
|
21044
|
-
rendererExtensionDrawBuffers: IS_WEBGL2 || extensions.has( 'WEBGL_draw_buffers' ),
|
|
21045
|
-
rendererExtensionShaderTextureLod: IS_WEBGL2 || extensions.has( 'EXT_shader_texture_lod' ),
|
|
21046
20767
|
rendererExtensionParallelShaderCompile: extensions.has( 'KHR_parallel_shader_compile' ),
|
|
21047
20768
|
|
|
21048
20769
|
customProgramCacheKey: material.customProgramCacheKey()
|
|
@@ -21158,48 +20879,46 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
21158
20879
|
|
|
21159
20880
|
_programLayers.disableAll();
|
|
21160
20881
|
|
|
21161
|
-
if ( parameters.isWebGL2 )
|
|
21162
|
-
_programLayers.enable( 0 );
|
|
21163
20882
|
if ( parameters.supportsVertexTextures )
|
|
21164
|
-
_programLayers.enable(
|
|
20883
|
+
_programLayers.enable( 0 );
|
|
21165
20884
|
if ( parameters.instancing )
|
|
21166
|
-
_programLayers.enable(
|
|
20885
|
+
_programLayers.enable( 1 );
|
|
21167
20886
|
if ( parameters.instancingColor )
|
|
21168
|
-
_programLayers.enable(
|
|
20887
|
+
_programLayers.enable( 2 );
|
|
21169
20888
|
if ( parameters.instancingMorph )
|
|
21170
|
-
_programLayers.enable(
|
|
20889
|
+
_programLayers.enable( 3 );
|
|
21171
20890
|
if ( parameters.matcap )
|
|
21172
|
-
_programLayers.enable(
|
|
20891
|
+
_programLayers.enable( 4 );
|
|
21173
20892
|
if ( parameters.envMap )
|
|
21174
|
-
_programLayers.enable(
|
|
20893
|
+
_programLayers.enable( 5 );
|
|
21175
20894
|
if ( parameters.normalMapObjectSpace )
|
|
21176
|
-
_programLayers.enable(
|
|
20895
|
+
_programLayers.enable( 6 );
|
|
21177
20896
|
if ( parameters.normalMapTangentSpace )
|
|
21178
|
-
_programLayers.enable(
|
|
20897
|
+
_programLayers.enable( 7 );
|
|
21179
20898
|
if ( parameters.clearcoat )
|
|
21180
|
-
_programLayers.enable(
|
|
20899
|
+
_programLayers.enable( 8 );
|
|
21181
20900
|
if ( parameters.iridescence )
|
|
21182
|
-
_programLayers.enable(
|
|
20901
|
+
_programLayers.enable( 9 );
|
|
21183
20902
|
if ( parameters.alphaTest )
|
|
21184
|
-
_programLayers.enable(
|
|
20903
|
+
_programLayers.enable( 10 );
|
|
21185
20904
|
if ( parameters.vertexColors )
|
|
21186
|
-
_programLayers.enable(
|
|
20905
|
+
_programLayers.enable( 11 );
|
|
21187
20906
|
if ( parameters.vertexAlphas )
|
|
21188
|
-
_programLayers.enable(
|
|
20907
|
+
_programLayers.enable( 12 );
|
|
21189
20908
|
if ( parameters.vertexUv1s )
|
|
21190
|
-
_programLayers.enable(
|
|
20909
|
+
_programLayers.enable( 13 );
|
|
21191
20910
|
if ( parameters.vertexUv2s )
|
|
21192
|
-
_programLayers.enable(
|
|
20911
|
+
_programLayers.enable( 14 );
|
|
21193
20912
|
if ( parameters.vertexUv3s )
|
|
21194
|
-
_programLayers.enable(
|
|
20913
|
+
_programLayers.enable( 15 );
|
|
21195
20914
|
if ( parameters.vertexTangents )
|
|
21196
|
-
_programLayers.enable(
|
|
20915
|
+
_programLayers.enable( 16 );
|
|
21197
20916
|
if ( parameters.anisotropy )
|
|
21198
|
-
_programLayers.enable(
|
|
20917
|
+
_programLayers.enable( 17 );
|
|
21199
20918
|
if ( parameters.alphaHash )
|
|
21200
|
-
_programLayers.enable(
|
|
20919
|
+
_programLayers.enable( 18 );
|
|
21201
20920
|
if ( parameters.batching )
|
|
21202
|
-
_programLayers.enable(
|
|
20921
|
+
_programLayers.enable( 19 );
|
|
21203
20922
|
|
|
21204
20923
|
array.push( _programLayers.mask );
|
|
21205
20924
|
_programLayers.disableAll();
|
|
@@ -21774,7 +21493,7 @@ function shadowCastingAndTexturingLightsFirst( lightA, lightB ) {
|
|
|
21774
21493
|
|
|
21775
21494
|
}
|
|
21776
21495
|
|
|
21777
|
-
function WebGLLights( extensions
|
|
21496
|
+
function WebGLLights( extensions ) {
|
|
21778
21497
|
|
|
21779
21498
|
const cache = new UniformsCache();
|
|
21780
21499
|
|
|
@@ -22023,41 +21742,15 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
22023
21742
|
|
|
22024
21743
|
if ( rectAreaLength > 0 ) {
|
|
22025
21744
|
|
|
22026
|
-
if (
|
|
21745
|
+
if ( extensions.has( 'OES_texture_float_linear' ) === true ) {
|
|
22027
21746
|
|
|
22028
|
-
|
|
22029
|
-
|
|
22030
|
-
if ( extensions.has( 'OES_texture_float_linear' ) === true ) {
|
|
22031
|
-
|
|
22032
|
-
state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;
|
|
22033
|
-
state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;
|
|
22034
|
-
|
|
22035
|
-
} else {
|
|
22036
|
-
|
|
22037
|
-
state.rectAreaLTC1 = UniformsLib.LTC_HALF_1;
|
|
22038
|
-
state.rectAreaLTC2 = UniformsLib.LTC_HALF_2;
|
|
22039
|
-
|
|
22040
|
-
}
|
|
21747
|
+
state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;
|
|
21748
|
+
state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;
|
|
22041
21749
|
|
|
22042
21750
|
} else {
|
|
22043
21751
|
|
|
22044
|
-
|
|
22045
|
-
|
|
22046
|
-
if ( extensions.has( 'OES_texture_float_linear' ) === true ) {
|
|
22047
|
-
|
|
22048
|
-
state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;
|
|
22049
|
-
state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;
|
|
22050
|
-
|
|
22051
|
-
} else if ( extensions.has( 'OES_texture_half_float_linear' ) === true ) {
|
|
22052
|
-
|
|
22053
|
-
state.rectAreaLTC1 = UniformsLib.LTC_HALF_1;
|
|
22054
|
-
state.rectAreaLTC2 = UniformsLib.LTC_HALF_2;
|
|
22055
|
-
|
|
22056
|
-
} else {
|
|
22057
|
-
|
|
22058
|
-
console.error( 'THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.' );
|
|
22059
|
-
|
|
22060
|
-
}
|
|
21752
|
+
state.rectAreaLTC1 = UniformsLib.LTC_HALF_1;
|
|
21753
|
+
state.rectAreaLTC2 = UniformsLib.LTC_HALF_2;
|
|
22061
21754
|
|
|
22062
21755
|
}
|
|
22063
21756
|
|
|
@@ -22210,9 +21903,9 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
22210
21903
|
|
|
22211
21904
|
}
|
|
22212
21905
|
|
|
22213
|
-
function WebGLRenderState( extensions
|
|
21906
|
+
function WebGLRenderState( extensions ) {
|
|
22214
21907
|
|
|
22215
|
-
const lights = new WebGLLights( extensions
|
|
21908
|
+
const lights = new WebGLLights( extensions );
|
|
22216
21909
|
|
|
22217
21910
|
const lightsArray = [];
|
|
22218
21911
|
const shadowsArray = [];
|
|
@@ -22252,7 +21945,9 @@ function WebGLRenderState( extensions, capabilities ) {
|
|
|
22252
21945
|
lightsArray: lightsArray,
|
|
22253
21946
|
shadowsArray: shadowsArray,
|
|
22254
21947
|
|
|
22255
|
-
lights: lights
|
|
21948
|
+
lights: lights,
|
|
21949
|
+
|
|
21950
|
+
transmissionRenderTarget: null
|
|
22256
21951
|
};
|
|
22257
21952
|
|
|
22258
21953
|
return {
|
|
@@ -22267,7 +21962,7 @@ function WebGLRenderState( extensions, capabilities ) {
|
|
|
22267
21962
|
|
|
22268
21963
|
}
|
|
22269
21964
|
|
|
22270
|
-
function WebGLRenderStates( extensions
|
|
21965
|
+
function WebGLRenderStates( extensions ) {
|
|
22271
21966
|
|
|
22272
21967
|
let renderStates = new WeakMap();
|
|
22273
21968
|
|
|
@@ -22278,14 +21973,14 @@ function WebGLRenderStates( extensions, capabilities ) {
|
|
|
22278
21973
|
|
|
22279
21974
|
if ( renderStateArray === undefined ) {
|
|
22280
21975
|
|
|
22281
|
-
renderState = new WebGLRenderState( extensions
|
|
21976
|
+
renderState = new WebGLRenderState( extensions );
|
|
22282
21977
|
renderStates.set( scene, [ renderState ] );
|
|
22283
21978
|
|
|
22284
21979
|
} else {
|
|
22285
21980
|
|
|
22286
21981
|
if ( renderCallDepth >= renderStateArray.length ) {
|
|
22287
21982
|
|
|
22288
|
-
renderState = new WebGLRenderState( extensions
|
|
21983
|
+
renderState = new WebGLRenderState( extensions );
|
|
22289
21984
|
renderStateArray.push( renderState );
|
|
22290
21985
|
|
|
22291
21986
|
} else {
|
|
@@ -22815,9 +22510,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
22815
22510
|
|
|
22816
22511
|
}
|
|
22817
22512
|
|
|
22818
|
-
function WebGLState( gl
|
|
22819
|
-
|
|
22820
|
-
const isWebGL2 = capabilities.isWebGL2;
|
|
22513
|
+
function WebGLState( gl ) {
|
|
22821
22514
|
|
|
22822
22515
|
function ColorBuffer() {
|
|
22823
22516
|
|
|
@@ -23189,7 +22882,7 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
23189
22882
|
|
|
23190
22883
|
for ( let i = 0; i < count; i ++ ) {
|
|
23191
22884
|
|
|
23192
|
-
if (
|
|
22885
|
+
if ( type === gl.TEXTURE_3D || type === gl.TEXTURE_2D_ARRAY ) {
|
|
23193
22886
|
|
|
23194
22887
|
gl.texImage3D( target, 0, gl.RGBA, 1, 1, dimensions, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );
|
|
23195
22888
|
|
|
@@ -23208,13 +22901,8 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
23208
22901
|
const emptyTextures = {};
|
|
23209
22902
|
emptyTextures[ gl.TEXTURE_2D ] = createTexture( gl.TEXTURE_2D, gl.TEXTURE_2D, 1 );
|
|
23210
22903
|
emptyTextures[ gl.TEXTURE_CUBE_MAP ] = createTexture( gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6 );
|
|
23211
|
-
|
|
23212
|
-
|
|
23213
|
-
|
|
23214
|
-
emptyTextures[ gl.TEXTURE_2D_ARRAY ] = createTexture( gl.TEXTURE_2D_ARRAY, gl.TEXTURE_2D_ARRAY, 1, 1 );
|
|
23215
|
-
emptyTextures[ gl.TEXTURE_3D ] = createTexture( gl.TEXTURE_3D, gl.TEXTURE_3D, 1, 1 );
|
|
23216
|
-
|
|
23217
|
-
}
|
|
22904
|
+
emptyTextures[ gl.TEXTURE_2D_ARRAY ] = createTexture( gl.TEXTURE_2D_ARRAY, gl.TEXTURE_2D_ARRAY, 1, 1 );
|
|
22905
|
+
emptyTextures[ gl.TEXTURE_3D ] = createTexture( gl.TEXTURE_3D, gl.TEXTURE_3D, 1, 1 );
|
|
23218
22906
|
|
|
23219
22907
|
// init
|
|
23220
22908
|
|
|
@@ -23263,21 +22951,17 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
23263
22951
|
|
|
23264
22952
|
currentBoundFramebuffers[ target ] = framebuffer;
|
|
23265
22953
|
|
|
23266
|
-
|
|
23267
|
-
|
|
23268
|
-
// gl.DRAW_FRAMEBUFFER is equivalent to gl.FRAMEBUFFER
|
|
22954
|
+
// gl.DRAW_FRAMEBUFFER is equivalent to gl.FRAMEBUFFER
|
|
23269
22955
|
|
|
23270
|
-
|
|
22956
|
+
if ( target === gl.DRAW_FRAMEBUFFER ) {
|
|
23271
22957
|
|
|
23272
|
-
|
|
22958
|
+
currentBoundFramebuffers[ gl.FRAMEBUFFER ] = framebuffer;
|
|
23273
22959
|
|
|
23274
|
-
|
|
23275
|
-
|
|
23276
|
-
if ( target === gl.FRAMEBUFFER ) {
|
|
22960
|
+
}
|
|
23277
22961
|
|
|
23278
|
-
|
|
22962
|
+
if ( target === gl.FRAMEBUFFER ) {
|
|
23279
22963
|
|
|
23280
|
-
|
|
22964
|
+
currentBoundFramebuffers[ gl.DRAW_FRAMEBUFFER ] = framebuffer;
|
|
23281
22965
|
|
|
23282
22966
|
}
|
|
23283
22967
|
|
|
@@ -23336,23 +23020,10 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
23336
23020
|
|
|
23337
23021
|
if ( needsUpdate ) {
|
|
23338
23022
|
|
|
23339
|
-
|
|
23340
|
-
|
|
23341
|
-
gl.drawBuffers( drawBuffers );
|
|
23342
|
-
|
|
23343
|
-
} else if ( extensions.has( 'WEBGL_draw_buffers' ) === true ) {
|
|
23344
|
-
|
|
23345
|
-
extensions.get( 'WEBGL_draw_buffers' ).drawBuffersWEBGL( drawBuffers );
|
|
23346
|
-
|
|
23347
|
-
} else {
|
|
23348
|
-
|
|
23349
|
-
throw new Error( 'THREE.WebGLState: Usage of gl.drawBuffers() require WebGL2 or WEBGL_draw_buffers extension' );
|
|
23350
|
-
|
|
23351
|
-
}
|
|
23023
|
+
gl.drawBuffers( drawBuffers );
|
|
23352
23024
|
|
|
23353
23025
|
}
|
|
23354
23026
|
|
|
23355
|
-
|
|
23356
23027
|
}
|
|
23357
23028
|
|
|
23358
23029
|
function useProgram( program ) {
|
|
@@ -23377,23 +23048,8 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
23377
23048
|
[ ReverseSubtractEquation ]: gl.FUNC_REVERSE_SUBTRACT
|
|
23378
23049
|
};
|
|
23379
23050
|
|
|
23380
|
-
|
|
23381
|
-
|
|
23382
|
-
equationToGL[ MinEquation ] = gl.MIN;
|
|
23383
|
-
equationToGL[ MaxEquation ] = gl.MAX;
|
|
23384
|
-
|
|
23385
|
-
} else {
|
|
23386
|
-
|
|
23387
|
-
const extension = extensions.get( 'EXT_blend_minmax' );
|
|
23388
|
-
|
|
23389
|
-
if ( extension !== null ) {
|
|
23390
|
-
|
|
23391
|
-
equationToGL[ MinEquation ] = extension.MIN_EXT;
|
|
23392
|
-
equationToGL[ MaxEquation ] = extension.MAX_EXT;
|
|
23393
|
-
|
|
23394
|
-
}
|
|
23395
|
-
|
|
23396
|
-
}
|
|
23051
|
+
equationToGL[ MinEquation ] = gl.MIN;
|
|
23052
|
+
equationToGL[ MaxEquation ] = gl.MAX;
|
|
23397
23053
|
|
|
23398
23054
|
const factorToGL = {
|
|
23399
23055
|
[ ZeroFactor ]: gl.ZERO,
|
|
@@ -24017,13 +23673,8 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
24017
23673
|
gl.activeTexture( gl.TEXTURE0 );
|
|
24018
23674
|
|
|
24019
23675
|
gl.bindFramebuffer( gl.FRAMEBUFFER, null );
|
|
24020
|
-
|
|
24021
|
-
|
|
24022
|
-
|
|
24023
|
-
gl.bindFramebuffer( gl.DRAW_FRAMEBUFFER, null );
|
|
24024
|
-
gl.bindFramebuffer( gl.READ_FRAMEBUFFER, null );
|
|
24025
|
-
|
|
24026
|
-
}
|
|
23676
|
+
gl.bindFramebuffer( gl.DRAW_FRAMEBUFFER, null );
|
|
23677
|
+
gl.bindFramebuffer( gl.READ_FRAMEBUFFER, null );
|
|
24027
23678
|
|
|
24028
23679
|
gl.useProgram( null );
|
|
24029
23680
|
|
|
@@ -24130,7 +23781,6 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
24130
23781
|
|
|
24131
23782
|
function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
|
|
24132
23783
|
|
|
24133
|
-
const isWebGL2 = capabilities.isWebGL2;
|
|
24134
23784
|
const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
|
|
24135
23785
|
const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
|
|
24136
23786
|
const multiviewExt = extensions.has( 'OCULUS_multiview' ) ? extensions.get( 'OCULUS_multiview' ) : null;
|
|
@@ -24172,7 +23822,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24172
23822
|
|
|
24173
23823
|
}
|
|
24174
23824
|
|
|
24175
|
-
function resizeImage( image,
|
|
23825
|
+
function resizeImage( image, needsNewCanvas, maxSize ) {
|
|
24176
23826
|
|
|
24177
23827
|
let scale = 1;
|
|
24178
23828
|
|
|
@@ -24188,7 +23838,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24188
23838
|
|
|
24189
23839
|
// only perform resize if necessary
|
|
24190
23840
|
|
|
24191
|
-
if ( scale < 1
|
|
23841
|
+
if ( scale < 1 ) {
|
|
24192
23842
|
|
|
24193
23843
|
// only perform resize for certain image types
|
|
24194
23844
|
|
|
@@ -24197,10 +23847,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24197
23847
|
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ||
|
|
24198
23848
|
( typeof VideoFrame !== 'undefined' && image instanceof VideoFrame ) ) {
|
|
24199
23849
|
|
|
24200
|
-
const
|
|
24201
|
-
|
|
24202
|
-
const width = floor( scale * dimensions.width );
|
|
24203
|
-
const height = floor( scale * dimensions.height );
|
|
23850
|
+
const width = Math.floor( scale * dimensions.width );
|
|
23851
|
+
const height = Math.floor( scale * dimensions.height );
|
|
24204
23852
|
|
|
24205
23853
|
if ( _canvas === undefined ) _canvas = createCanvas( width, height );
|
|
24206
23854
|
|
|
@@ -24236,27 +23884,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24236
23884
|
|
|
24237
23885
|
}
|
|
24238
23886
|
|
|
24239
|
-
function
|
|
24240
|
-
|
|
24241
|
-
const dimensions = getDimensions( image );
|
|
24242
|
-
|
|
24243
|
-
return isPowerOfTwo( dimensions.width ) && isPowerOfTwo( dimensions.height );
|
|
24244
|
-
|
|
24245
|
-
}
|
|
24246
|
-
|
|
24247
|
-
function textureNeedsPowerOfTwo( texture ) {
|
|
24248
|
-
|
|
24249
|
-
if ( isWebGL2 ) return false;
|
|
23887
|
+
function textureNeedsGenerateMipmaps( texture ) {
|
|
24250
23888
|
|
|
24251
|
-
return
|
|
24252
|
-
( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter );
|
|
24253
|
-
|
|
24254
|
-
}
|
|
24255
|
-
|
|
24256
|
-
function textureNeedsGenerateMipmaps( texture, supportsMips ) {
|
|
24257
|
-
|
|
24258
|
-
return texture.generateMipmaps && supportsMips &&
|
|
24259
|
-
texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
|
|
23889
|
+
return texture.generateMipmaps && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
|
|
24260
23890
|
|
|
24261
23891
|
}
|
|
24262
23892
|
|
|
@@ -24268,8 +23898,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24268
23898
|
|
|
24269
23899
|
function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
|
|
24270
23900
|
|
|
24271
|
-
if ( isWebGL2 === false ) return glFormat;
|
|
24272
|
-
|
|
24273
23901
|
if ( internalFormatName !== null ) {
|
|
24274
23902
|
|
|
24275
23903
|
if ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ];
|
|
@@ -24318,6 +23946,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24318
23946
|
|
|
24319
23947
|
}
|
|
24320
23948
|
|
|
23949
|
+
if ( glFormat === _gl.RGB ) {
|
|
23950
|
+
|
|
23951
|
+
if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
|
|
23952
|
+
|
|
23953
|
+
}
|
|
23954
|
+
|
|
24321
23955
|
if ( glFormat === _gl.RGBA ) {
|
|
24322
23956
|
|
|
24323
23957
|
const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
|
|
@@ -24342,9 +23976,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24342
23976
|
|
|
24343
23977
|
}
|
|
24344
23978
|
|
|
24345
|
-
function getMipLevels( texture, image
|
|
23979
|
+
function getMipLevels( texture, image ) {
|
|
24346
23980
|
|
|
24347
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
23981
|
+
if ( textureNeedsGenerateMipmaps( texture ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
|
|
24348
23982
|
|
|
24349
23983
|
return Math.log2( Math.max( image.width, image.height ) ) + 1;
|
|
24350
23984
|
|
|
@@ -24368,20 +24002,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24368
24002
|
|
|
24369
24003
|
}
|
|
24370
24004
|
|
|
24371
|
-
// Fallback filters for non-power-of-2 textures
|
|
24372
|
-
|
|
24373
|
-
function filterFallback( f ) {
|
|
24374
|
-
|
|
24375
|
-
if ( f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter ) {
|
|
24376
|
-
|
|
24377
|
-
return _gl.NEAREST;
|
|
24378
|
-
|
|
24379
|
-
}
|
|
24380
|
-
|
|
24381
|
-
return _gl.LINEAR;
|
|
24382
|
-
|
|
24383
|
-
}
|
|
24384
|
-
|
|
24385
24005
|
//
|
|
24386
24006
|
|
|
24387
24007
|
function onTextureDispose( event ) {
|
|
@@ -24699,7 +24319,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24699
24319
|
[ NotEqualCompare ]: _gl.NOTEQUAL
|
|
24700
24320
|
};
|
|
24701
24321
|
|
|
24702
|
-
function setTextureParameters( textureType, texture
|
|
24322
|
+
function setTextureParameters( textureType, texture ) {
|
|
24703
24323
|
|
|
24704
24324
|
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false &&
|
|
24705
24325
|
( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || texture.magFilter === NearestMipmapLinearFilter || texture.magFilter === LinearMipmapLinearFilter ||
|
|
@@ -24709,48 +24329,18 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24709
24329
|
|
|
24710
24330
|
}
|
|
24711
24331
|
|
|
24712
|
-
|
|
24713
|
-
|
|
24714
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
|
|
24715
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
|
|
24716
|
-
|
|
24717
|
-
if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
|
|
24718
|
-
|
|
24719
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
|
|
24720
|
-
|
|
24721
|
-
}
|
|
24722
|
-
|
|
24723
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
|
|
24724
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );
|
|
24725
|
-
|
|
24726
|
-
} else {
|
|
24727
|
-
|
|
24728
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );
|
|
24729
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );
|
|
24730
|
-
|
|
24731
|
-
if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
|
|
24732
|
-
|
|
24733
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, _gl.CLAMP_TO_EDGE );
|
|
24734
|
-
|
|
24735
|
-
}
|
|
24736
|
-
|
|
24737
|
-
if ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) {
|
|
24738
|
-
|
|
24739
|
-
console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' );
|
|
24740
|
-
|
|
24741
|
-
}
|
|
24742
|
-
|
|
24743
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterFallback( texture.magFilter ) );
|
|
24744
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterFallback( texture.minFilter ) );
|
|
24332
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
|
|
24333
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
|
|
24745
24334
|
|
|
24746
|
-
|
|
24335
|
+
if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
|
|
24747
24336
|
|
|
24748
|
-
|
|
24749
|
-
|
|
24750
|
-
}
|
|
24337
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
|
|
24751
24338
|
|
|
24752
24339
|
}
|
|
24753
24340
|
|
|
24341
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
|
|
24342
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );
|
|
24343
|
+
|
|
24754
24344
|
if ( texture.compareFunction ) {
|
|
24755
24345
|
|
|
24756
24346
|
_gl.texParameteri( textureType, _gl.TEXTURE_COMPARE_MODE, _gl.COMPARE_REF_TO_TEXTURE );
|
|
@@ -24762,8 +24352,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24762
24352
|
|
|
24763
24353
|
if ( texture.magFilter === NearestFilter ) return;
|
|
24764
24354
|
if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return;
|
|
24765
|
-
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension
|
|
24766
|
-
if ( isWebGL2 === false && ( texture.type === HalfFloatType && extensions.has( 'OES_texture_half_float_linear' ) === false ) ) return; // verify extension for WebGL 1 only
|
|
24355
|
+
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension
|
|
24767
24356
|
|
|
24768
24357
|
if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {
|
|
24769
24358
|
|
|
@@ -24921,97 +24510,41 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24921
24510
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
24922
24511
|
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
|
|
24923
24512
|
|
|
24924
|
-
|
|
24925
|
-
let image = resizeImage( texture.image, needsPowerOfTwo, false, capabilities.maxTextureSize );
|
|
24513
|
+
let image = resizeImage( texture.image, false, capabilities.maxTextureSize );
|
|
24926
24514
|
image = verifyColorSpace( texture, image );
|
|
24927
24515
|
|
|
24928
|
-
const
|
|
24929
|
-
glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
24516
|
+
const glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
24930
24517
|
|
|
24931
|
-
|
|
24932
|
-
|
|
24518
|
+
const glType = utils.convert( texture.type );
|
|
24519
|
+
let glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
|
|
24933
24520
|
|
|
24934
|
-
setTextureParameters( textureType, texture
|
|
24521
|
+
setTextureParameters( textureType, texture );
|
|
24935
24522
|
|
|
24936
24523
|
let mipmap;
|
|
24937
24524
|
const mipmaps = texture.mipmaps;
|
|
24938
24525
|
|
|
24939
|
-
const useTexStorage = (
|
|
24526
|
+
const useTexStorage = ( texture.isVideoTexture !== true && glInternalFormat !== RGB_ETC1_Format );
|
|
24940
24527
|
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
24941
24528
|
const dataReady = source.dataReady;
|
|
24942
|
-
const levels = getMipLevels( texture, image
|
|
24529
|
+
const levels = getMipLevels( texture, image );
|
|
24943
24530
|
|
|
24944
24531
|
if ( texture.isDepthTexture ) {
|
|
24945
24532
|
|
|
24946
24533
|
// populate depth texture with dummy data
|
|
24947
24534
|
|
|
24948
|
-
glInternalFormat = _gl.
|
|
24949
|
-
|
|
24950
|
-
if ( isWebGL2 ) {
|
|
24951
|
-
|
|
24952
|
-
if ( texture.type === FloatType ) {
|
|
24953
|
-
|
|
24954
|
-
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
24955
|
-
|
|
24956
|
-
} else if ( texture.type === UnsignedIntType ) {
|
|
24957
|
-
|
|
24958
|
-
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
24959
|
-
|
|
24960
|
-
} else if ( texture.type === UnsignedInt248Type ) {
|
|
24961
|
-
|
|
24962
|
-
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
24963
|
-
|
|
24964
|
-
} else {
|
|
24965
|
-
|
|
24966
|
-
glInternalFormat = _gl.DEPTH_COMPONENT16; // WebGL2 requires sized internalformat for glTexImage2D
|
|
24535
|
+
glInternalFormat = _gl.DEPTH_COMPONENT16;
|
|
24967
24536
|
|
|
24968
|
-
|
|
24969
|
-
|
|
24970
|
-
} else {
|
|
24971
|
-
|
|
24972
|
-
if ( texture.type === FloatType ) {
|
|
24973
|
-
|
|
24974
|
-
console.error( 'WebGLRenderer: Floating point depth texture requires WebGL2.' );
|
|
24975
|
-
|
|
24976
|
-
}
|
|
24977
|
-
|
|
24978
|
-
}
|
|
24979
|
-
|
|
24980
|
-
// validation checks for WebGL 1
|
|
24981
|
-
|
|
24982
|
-
if ( texture.format === DepthFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {
|
|
24983
|
-
|
|
24984
|
-
// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
|
|
24985
|
-
// DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT
|
|
24986
|
-
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
24987
|
-
if ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) {
|
|
24988
|
-
|
|
24989
|
-
console.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' );
|
|
24990
|
-
|
|
24991
|
-
texture.type = UnsignedIntType;
|
|
24992
|
-
glType = utils.convert( texture.type );
|
|
24993
|
-
|
|
24994
|
-
}
|
|
24537
|
+
if ( texture.type === FloatType ) {
|
|
24995
24538
|
|
|
24996
|
-
|
|
24997
|
-
|
|
24998
|
-
if ( texture.format === DepthStencilFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {
|
|
24999
|
-
|
|
25000
|
-
// Depth stencil textures need the DEPTH_STENCIL internal format
|
|
25001
|
-
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
25002
|
-
glInternalFormat = _gl.DEPTH_STENCIL;
|
|
24539
|
+
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
25003
24540
|
|
|
25004
|
-
|
|
25005
|
-
// DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.
|
|
25006
|
-
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
25007
|
-
if ( texture.type !== UnsignedInt248Type ) {
|
|
24541
|
+
} else if ( texture.type === UnsignedIntType ) {
|
|
25008
24542
|
|
|
25009
|
-
|
|
24543
|
+
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
25010
24544
|
|
|
25011
|
-
|
|
25012
|
-
glType = utils.convert( texture.type );
|
|
24545
|
+
} else if ( texture.type === UnsignedInt248Type ) {
|
|
25013
24546
|
|
|
25014
|
-
|
|
24547
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
25015
24548
|
|
|
25016
24549
|
}
|
|
25017
24550
|
|
|
@@ -25037,7 +24570,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
25037
24570
|
// if there are no manual mipmaps
|
|
25038
24571
|
// set 0 level mipmap and then use GL to generate other mipmap levels
|
|
25039
24572
|
|
|
25040
|
-
if ( mipmaps.length > 0
|
|
24573
|
+
if ( mipmaps.length > 0 ) {
|
|
25041
24574
|
|
|
25042
24575
|
if ( useTexStorage && allocateMemory ) {
|
|
25043
24576
|
|
|
@@ -25284,7 +24817,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
25284
24817
|
// if there are no manual mipmaps
|
|
25285
24818
|
// set 0 level mipmap and then use GL to generate other mipmap levels
|
|
25286
24819
|
|
|
25287
|
-
if ( mipmaps.length > 0
|
|
24820
|
+
if ( mipmaps.length > 0 ) {
|
|
25288
24821
|
|
|
25289
24822
|
if ( useTexStorage && allocateMemory ) {
|
|
25290
24823
|
|
|
@@ -25344,7 +24877,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
25344
24877
|
|
|
25345
24878
|
}
|
|
25346
24879
|
|
|
25347
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
24880
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
25348
24881
|
|
|
25349
24882
|
generateMipmap( textureType );
|
|
25350
24883
|
|
|
@@ -25394,7 +24927,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
25394
24927
|
|
|
25395
24928
|
if ( ! isCompressed && ! isDataTexture ) {
|
|
25396
24929
|
|
|
25397
|
-
cubeImage[ i ] = resizeImage( texture.image[ i ],
|
|
24930
|
+
cubeImage[ i ] = resizeImage( texture.image[ i ], true, capabilities.maxCubemapSize );
|
|
25398
24931
|
|
|
25399
24932
|
} else {
|
|
25400
24933
|
|
|
@@ -25407,17 +24940,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
25407
24940
|
}
|
|
25408
24941
|
|
|
25409
24942
|
const image = cubeImage[ 0 ],
|
|
25410
|
-
supportsMips = isPowerOfTwo$1( image ) || isWebGL2,
|
|
25411
24943
|
glFormat = utils.convert( texture.format, texture.colorSpace ),
|
|
25412
24944
|
glType = utils.convert( texture.type ),
|
|
25413
24945
|
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
25414
24946
|
|
|
25415
|
-
const useTexStorage = (
|
|
24947
|
+
const useTexStorage = ( texture.isVideoTexture !== true );
|
|
25416
24948
|
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
25417
24949
|
const dataReady = source.dataReady;
|
|
25418
|
-
let levels = getMipLevels( texture, image
|
|
24950
|
+
let levels = getMipLevels( texture, image );
|
|
25419
24951
|
|
|
25420
|
-
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture
|
|
24952
|
+
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture );
|
|
25421
24953
|
|
|
25422
24954
|
let mipmaps;
|
|
25423
24955
|
|
|
@@ -25582,7 +25114,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
25582
25114
|
|
|
25583
25115
|
}
|
|
25584
25116
|
|
|
25585
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
25117
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
25586
25118
|
|
|
25587
25119
|
// We assume images for cube map have the same size.
|
|
25588
25120
|
generateMipmap( _gl.TEXTURE_CUBE_MAP );
|
|
@@ -25724,7 +25256,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
25724
25256
|
|
|
25725
25257
|
} else if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
|
|
25726
25258
|
|
|
25727
|
-
let glInternalFormat =
|
|
25259
|
+
let glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
25728
25260
|
|
|
25729
25261
|
if ( isMultisample || useMultisampledRTT( renderTarget ) ) {
|
|
25730
25262
|
|
|
@@ -26003,7 +25535,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26003
25535
|
|
|
26004
25536
|
const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
|
|
26005
25537
|
const isMultipleRenderTargets = ( textures.length > 1 );
|
|
26006
|
-
const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
|
|
26007
25538
|
|
|
26008
25539
|
if ( ! isMultipleRenderTargets ) {
|
|
26009
25540
|
|
|
@@ -26026,7 +25557,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26026
25557
|
|
|
26027
25558
|
for ( let i = 0; i < 6; i ++ ) {
|
|
26028
25559
|
|
|
26029
|
-
if (
|
|
25560
|
+
if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
26030
25561
|
|
|
26031
25562
|
renderTargetProperties.__webglFramebuffer[ i ] = [];
|
|
26032
25563
|
|
|
@@ -26046,7 +25577,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26046
25577
|
|
|
26047
25578
|
} else {
|
|
26048
25579
|
|
|
26049
|
-
if (
|
|
25580
|
+
if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
26050
25581
|
|
|
26051
25582
|
renderTargetProperties.__webglFramebuffer = [];
|
|
26052
25583
|
|
|
@@ -26064,31 +25595,23 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26064
25595
|
|
|
26065
25596
|
if ( isMultipleRenderTargets ) {
|
|
26066
25597
|
|
|
26067
|
-
|
|
26068
|
-
|
|
26069
|
-
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
26070
|
-
|
|
26071
|
-
const attachmentProperties = properties.get( textures[ i ] );
|
|
25598
|
+
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
26072
25599
|
|
|
26073
|
-
|
|
25600
|
+
const attachmentProperties = properties.get( textures[ i ] );
|
|
26074
25601
|
|
|
26075
|
-
|
|
25602
|
+
if ( attachmentProperties.__webglTexture === undefined ) {
|
|
26076
25603
|
|
|
26077
|
-
|
|
25604
|
+
attachmentProperties.__webglTexture = _gl.createTexture();
|
|
26078
25605
|
|
|
26079
|
-
|
|
25606
|
+
info.memory.textures ++;
|
|
26080
25607
|
|
|
26081
25608
|
}
|
|
26082
25609
|
|
|
26083
|
-
} else {
|
|
26084
|
-
|
|
26085
|
-
console.warn( 'THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.' );
|
|
26086
|
-
|
|
26087
25610
|
}
|
|
26088
25611
|
|
|
26089
25612
|
}
|
|
26090
25613
|
|
|
26091
|
-
if ( (
|
|
25614
|
+
if ( ( renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
|
|
26092
25615
|
|
|
26093
25616
|
renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
|
|
26094
25617
|
renderTargetProperties.__webglColorRenderbuffer = [];
|
|
@@ -26132,11 +25655,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26132
25655
|
if ( isCube ) {
|
|
26133
25656
|
|
|
26134
25657
|
state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );
|
|
26135
|
-
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture
|
|
25658
|
+
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture );
|
|
26136
25659
|
|
|
26137
25660
|
for ( let i = 0; i < 6; i ++ ) {
|
|
26138
25661
|
|
|
26139
|
-
if (
|
|
25662
|
+
if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
26140
25663
|
|
|
26141
25664
|
for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
|
|
26142
25665
|
|
|
@@ -26152,7 +25675,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26152
25675
|
|
|
26153
25676
|
}
|
|
26154
25677
|
|
|
26155
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
25678
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
26156
25679
|
|
|
26157
25680
|
generateMipmap( _gl.TEXTURE_CUBE_MAP );
|
|
26158
25681
|
|
|
@@ -26168,10 +25691,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26168
25691
|
const attachmentProperties = properties.get( attachment );
|
|
26169
25692
|
|
|
26170
25693
|
state.bindTexture( _gl.TEXTURE_2D, attachmentProperties.__webglTexture );
|
|
26171
|
-
setTextureParameters( _gl.TEXTURE_2D, attachment
|
|
25694
|
+
setTextureParameters( _gl.TEXTURE_2D, attachment );
|
|
26172
25695
|
setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, 0 );
|
|
26173
25696
|
|
|
26174
|
-
if ( textureNeedsGenerateMipmaps( attachment
|
|
25697
|
+
if ( textureNeedsGenerateMipmaps( attachment ) ) {
|
|
26175
25698
|
|
|
26176
25699
|
generateMipmap( _gl.TEXTURE_2D );
|
|
26177
25700
|
|
|
@@ -26187,15 +25710,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26187
25710
|
|
|
26188
25711
|
if ( renderTarget.isWebGL3DRenderTarget || renderTarget.isWebGLArrayRenderTarget ) {
|
|
26189
25712
|
|
|
26190
|
-
|
|
26191
|
-
|
|
26192
|
-
glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
|
|
26193
|
-
|
|
26194
|
-
} else {
|
|
26195
|
-
|
|
26196
|
-
console.error( 'THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.' );
|
|
26197
|
-
|
|
26198
|
-
}
|
|
25713
|
+
glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
|
|
26199
25714
|
|
|
26200
25715
|
}
|
|
26201
25716
|
|
|
@@ -26206,9 +25721,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26206
25721
|
}
|
|
26207
25722
|
|
|
26208
25723
|
state.bindTexture( glTextureType, textureProperties.__webglTexture );
|
|
26209
|
-
setTextureParameters( glTextureType, texture
|
|
25724
|
+
setTextureParameters( glTextureType, texture );
|
|
26210
25725
|
|
|
26211
|
-
if (
|
|
25726
|
+
if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
26212
25727
|
|
|
26213
25728
|
for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
|
|
26214
25729
|
|
|
@@ -26222,7 +25737,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26222
25737
|
|
|
26223
25738
|
}
|
|
26224
25739
|
|
|
26225
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
25740
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
26226
25741
|
|
|
26227
25742
|
generateMipmap( glTextureType );
|
|
26228
25743
|
|
|
@@ -26244,15 +25759,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26244
25759
|
|
|
26245
25760
|
function updateRenderTargetMipmap( renderTarget ) {
|
|
26246
25761
|
|
|
26247
|
-
const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
|
|
26248
|
-
|
|
26249
25762
|
const textures = renderTarget.textures;
|
|
26250
25763
|
|
|
26251
25764
|
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
26252
25765
|
|
|
26253
25766
|
const texture = textures[ i ];
|
|
26254
25767
|
|
|
26255
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
25768
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
26256
25769
|
|
|
26257
25770
|
const target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D;
|
|
26258
25771
|
const webglTexture = properties.get( texture ).__webglTexture;
|
|
@@ -26269,7 +25782,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26269
25782
|
|
|
26270
25783
|
function updateMultisampleRenderTarget( renderTarget ) {
|
|
26271
25784
|
|
|
26272
|
-
if ( (
|
|
25785
|
+
if ( ( renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
|
|
26273
25786
|
|
|
26274
25787
|
const textures = renderTarget.textures;
|
|
26275
25788
|
const width = renderTarget.width;
|
|
@@ -26313,7 +25826,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26313
25826
|
if ( ignoreDepthValues === false ) {
|
|
26314
25827
|
|
|
26315
25828
|
if ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;
|
|
26316
|
-
|
|
25829
|
+
|
|
25830
|
+
// resolving stencil is slow with a D3D backend. disable it for all transmission render targets (see #27799)
|
|
25831
|
+
|
|
25832
|
+
if ( renderTarget.stencilBuffer && renderTargetProperties.__isTransmissionRenderTarget !== true ) mask |= _gl.STENCIL_BUFFER_BIT;
|
|
26317
25833
|
|
|
26318
25834
|
}
|
|
26319
25835
|
|
|
@@ -26384,7 +25900,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26384
25900
|
|
|
26385
25901
|
const renderTargetProperties = properties.get( renderTarget );
|
|
26386
25902
|
|
|
26387
|
-
return
|
|
25903
|
+
return renderTarget.samples > 0 && extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true && renderTargetProperties.__useRenderToTexture !== false;
|
|
26388
25904
|
|
|
26389
25905
|
}
|
|
26390
25906
|
|
|
@@ -26409,7 +25925,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26409
25925
|
const format = texture.format;
|
|
26410
25926
|
const type = texture.type;
|
|
26411
25927
|
|
|
26412
|
-
if ( texture.isCompressedTexture === true || texture.isVideoTexture === true
|
|
25928
|
+
if ( texture.isCompressedTexture === true || texture.isVideoTexture === true ) return image;
|
|
26413
25929
|
|
|
26414
25930
|
if ( colorSpace !== LinearSRGBColorSpace && colorSpace !== NoColorSpace ) {
|
|
26415
25931
|
|
|
@@ -26417,36 +25933,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26417
25933
|
|
|
26418
25934
|
if ( ColorManagement.getTransfer( colorSpace ) === SRGBTransfer ) {
|
|
26419
25935
|
|
|
26420
|
-
if
|
|
26421
|
-
|
|
26422
|
-
// in WebGL 1, try to use EXT_sRGB extension and unsized formats
|
|
26423
|
-
|
|
26424
|
-
if ( extensions.has( 'EXT_sRGB' ) === true && format === RGBAFormat ) {
|
|
26425
|
-
|
|
26426
|
-
texture.format = _SRGBAFormat;
|
|
26427
|
-
|
|
26428
|
-
// it's not possible to generate mips in WebGL 1 with this extension
|
|
26429
|
-
|
|
26430
|
-
texture.minFilter = LinearFilter;
|
|
26431
|
-
texture.generateMipmaps = false;
|
|
26432
|
-
|
|
26433
|
-
} else {
|
|
26434
|
-
|
|
26435
|
-
// slow fallback (CPU decode)
|
|
26436
|
-
|
|
26437
|
-
image = ImageUtils.sRGBToLinear( image );
|
|
25936
|
+
// in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format
|
|
26438
25937
|
|
|
26439
|
-
|
|
26440
|
-
|
|
26441
|
-
} else {
|
|
26442
|
-
|
|
26443
|
-
// in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format
|
|
26444
|
-
|
|
26445
|
-
if ( format !== RGBAFormat || type !== UnsignedByteType ) {
|
|
25938
|
+
if ( format !== RGBAFormat || type !== UnsignedByteType ) {
|
|
26446
25939
|
|
|
26447
|
-
|
|
26448
|
-
|
|
26449
|
-
}
|
|
25940
|
+
console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
|
|
26450
25941
|
|
|
26451
25942
|
}
|
|
26452
25943
|
|
|
@@ -26510,9 +26001,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
26510
26001
|
|
|
26511
26002
|
}
|
|
26512
26003
|
|
|
26513
|
-
function WebGLUtils( gl, extensions
|
|
26514
|
-
|
|
26515
|
-
const isWebGL2 = capabilities.isWebGL2;
|
|
26004
|
+
function WebGLUtils( gl, extensions ) {
|
|
26516
26005
|
|
|
26517
26006
|
function convert( p, colorSpace = NoColorSpace ) {
|
|
26518
26007
|
|
|
@@ -26523,6 +26012,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
26523
26012
|
if ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;
|
|
26524
26013
|
if ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;
|
|
26525
26014
|
if ( p === UnsignedShort5551Type ) return gl.UNSIGNED_SHORT_5_5_5_1;
|
|
26015
|
+
if ( p === UnsignedInt5999Type ) return gl.UNSIGNED_INT_5_9_9_9_REV;
|
|
26526
26016
|
|
|
26527
26017
|
if ( p === ByteType ) return gl.BYTE;
|
|
26528
26018
|
if ( p === ShortType ) return gl.SHORT;
|
|
@@ -26530,50 +26020,16 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
26530
26020
|
if ( p === IntType ) return gl.INT;
|
|
26531
26021
|
if ( p === UnsignedIntType ) return gl.UNSIGNED_INT;
|
|
26532
26022
|
if ( p === FloatType ) return gl.FLOAT;
|
|
26533
|
-
|
|
26534
|
-
if ( p === HalfFloatType ) {
|
|
26535
|
-
|
|
26536
|
-
if ( isWebGL2 ) return gl.HALF_FLOAT;
|
|
26537
|
-
|
|
26538
|
-
extension = extensions.get( 'OES_texture_half_float' );
|
|
26539
|
-
|
|
26540
|
-
if ( extension !== null ) {
|
|
26541
|
-
|
|
26542
|
-
return extension.HALF_FLOAT_OES;
|
|
26543
|
-
|
|
26544
|
-
} else {
|
|
26545
|
-
|
|
26546
|
-
return null;
|
|
26547
|
-
|
|
26548
|
-
}
|
|
26549
|
-
|
|
26550
|
-
}
|
|
26023
|
+
if ( p === HalfFloatType ) return gl.HALF_FLOAT;
|
|
26551
26024
|
|
|
26552
26025
|
if ( p === AlphaFormat ) return gl.ALPHA;
|
|
26026
|
+
if ( p === RGBFormat ) return gl.RGB;
|
|
26553
26027
|
if ( p === RGBAFormat ) return gl.RGBA;
|
|
26554
26028
|
if ( p === LuminanceFormat ) return gl.LUMINANCE;
|
|
26555
26029
|
if ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;
|
|
26556
26030
|
if ( p === DepthFormat ) return gl.DEPTH_COMPONENT;
|
|
26557
26031
|
if ( p === DepthStencilFormat ) return gl.DEPTH_STENCIL;
|
|
26558
26032
|
|
|
26559
|
-
// WebGL 1 sRGB fallback
|
|
26560
|
-
|
|
26561
|
-
if ( p === _SRGBAFormat ) {
|
|
26562
|
-
|
|
26563
|
-
extension = extensions.get( 'EXT_sRGB' );
|
|
26564
|
-
|
|
26565
|
-
if ( extension !== null ) {
|
|
26566
|
-
|
|
26567
|
-
return extension.SRGB_ALPHA_EXT;
|
|
26568
|
-
|
|
26569
|
-
} else {
|
|
26570
|
-
|
|
26571
|
-
return null;
|
|
26572
|
-
|
|
26573
|
-
}
|
|
26574
|
-
|
|
26575
|
-
}
|
|
26576
|
-
|
|
26577
26033
|
// WebGL2 formats.
|
|
26578
26034
|
|
|
26579
26035
|
if ( p === RedFormat ) return gl.RED;
|
|
@@ -26760,23 +26216,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
26760
26216
|
|
|
26761
26217
|
//
|
|
26762
26218
|
|
|
26763
|
-
if ( p === UnsignedInt248Type )
|
|
26764
|
-
|
|
26765
|
-
if ( isWebGL2 ) return gl.UNSIGNED_INT_24_8;
|
|
26766
|
-
|
|
26767
|
-
extension = extensions.get( 'WEBGL_depth_texture' );
|
|
26768
|
-
|
|
26769
|
-
if ( extension !== null ) {
|
|
26770
|
-
|
|
26771
|
-
return extension.UNSIGNED_INT_24_8_WEBGL;
|
|
26772
|
-
|
|
26773
|
-
} else {
|
|
26774
|
-
|
|
26775
|
-
return null;
|
|
26776
|
-
|
|
26777
|
-
}
|
|
26778
|
-
|
|
26779
|
-
}
|
|
26219
|
+
if ( p === UnsignedInt248Type ) return gl.UNSIGNED_INT_24_8;
|
|
26780
26220
|
|
|
26781
26221
|
// if "p" can't be resolved, assume the user defines a WebGL constant as a string (fallback/workaround for packed RGB formats)
|
|
26782
26222
|
|
|
@@ -27752,11 +27192,11 @@ void main() {
|
|
|
27752
27192
|
|
|
27753
27193
|
if ( coord.x >= 1.0 ) {
|
|
27754
27194
|
|
|
27755
|
-
|
|
27195
|
+
gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
|
|
27756
27196
|
|
|
27757
27197
|
} else {
|
|
27758
27198
|
|
|
27759
|
-
|
|
27199
|
+
gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
|
|
27760
27200
|
|
|
27761
27201
|
}
|
|
27762
27202
|
|
|
@@ -27804,7 +27244,6 @@ class WebXRDepthSensing {
|
|
|
27804
27244
|
|
|
27805
27245
|
const viewport = cameraXR.cameras[ 0 ].viewport;
|
|
27806
27246
|
const material = new ShaderMaterial( {
|
|
27807
|
-
extensions: { fragDepth: true },
|
|
27808
27247
|
vertexShader: _occlusion_vertex,
|
|
27809
27248
|
fragmentShader: _occlusion_fragment,
|
|
27810
27249
|
uniforms: {
|
|
@@ -28110,10 +27549,10 @@ class WebXRManager extends EventDispatcher {
|
|
|
28110
27549
|
currentPixelRatio = renderer.getPixelRatio();
|
|
28111
27550
|
renderer.getSize( currentSize );
|
|
28112
27551
|
|
|
28113
|
-
if (
|
|
27552
|
+
if ( session.renderState.layers === undefined ) {
|
|
28114
27553
|
|
|
28115
27554
|
const layerInit = {
|
|
28116
|
-
antialias:
|
|
27555
|
+
antialias: attributes.antialias,
|
|
28117
27556
|
alpha: true,
|
|
28118
27557
|
depth: attributes.depth,
|
|
28119
27558
|
stencil: attributes.stencil,
|
|
@@ -29092,11 +28531,10 @@ function WebGLMaterials( renderer, properties ) {
|
|
|
29092
28531
|
|
|
29093
28532
|
}
|
|
29094
28533
|
|
|
29095
|
-
|
|
29096
|
-
|
|
29097
|
-
if ( envMap ) {
|
|
28534
|
+
if ( material.envMap ) {
|
|
29098
28535
|
|
|
29099
28536
|
//uniforms.envMap.value = material.envMap; // part of uniforms common
|
|
28537
|
+
|
|
29100
28538
|
uniforms.envMapIntensity.value = material.envMapIntensity;
|
|
29101
28539
|
|
|
29102
28540
|
}
|
|
@@ -29292,7 +28730,7 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
|
|
|
29292
28730
|
let updateList = {};
|
|
29293
28731
|
let allocatedBindingPoints = [];
|
|
29294
28732
|
|
|
29295
|
-
const maxBindingPoints =
|
|
28733
|
+
const maxBindingPoints = gl.getParameter( gl.MAX_UNIFORM_BUFFER_BINDINGS ); // binding points are global whereas block indices are per shader program
|
|
29296
28734
|
|
|
29297
28735
|
function bind( uniformsGroup, program ) {
|
|
29298
28736
|
|
|
@@ -29684,7 +29122,7 @@ class WebGLRenderer {
|
|
|
29684
29122
|
canvas = createCanvasElement(),
|
|
29685
29123
|
context = null,
|
|
29686
29124
|
depth = true,
|
|
29687
|
-
stencil =
|
|
29125
|
+
stencil = false,
|
|
29688
29126
|
alpha = false,
|
|
29689
29127
|
antialias = false,
|
|
29690
29128
|
premultipliedAlpha = true,
|
|
@@ -29700,6 +29138,12 @@ class WebGLRenderer {
|
|
|
29700
29138
|
|
|
29701
29139
|
if ( context !== null ) {
|
|
29702
29140
|
|
|
29141
|
+
if ( typeof WebGLRenderingContext !== 'undefined' && context instanceof WebGLRenderingContext ) {
|
|
29142
|
+
|
|
29143
|
+
throw new Error( 'THREE.WebGLRenderer: WebGL 1 is not supported since r163.' );
|
|
29144
|
+
|
|
29145
|
+
}
|
|
29146
|
+
|
|
29703
29147
|
_alpha = context.getContextAttributes().alpha;
|
|
29704
29148
|
|
|
29705
29149
|
} else {
|
|
@@ -29812,10 +29256,6 @@ class WebGLRenderer {
|
|
|
29812
29256
|
let _clippingEnabled = false;
|
|
29813
29257
|
let _localClippingEnabled = false;
|
|
29814
29258
|
|
|
29815
|
-
// transmission
|
|
29816
|
-
|
|
29817
|
-
let _transmissionRenderTarget = null;
|
|
29818
|
-
|
|
29819
29259
|
// camera matrices cache
|
|
29820
29260
|
|
|
29821
29261
|
const _projScreenMatrix = new Matrix4();
|
|
@@ -29835,15 +29275,10 @@ class WebGLRenderer {
|
|
|
29835
29275
|
|
|
29836
29276
|
let _gl = context;
|
|
29837
29277
|
|
|
29838
|
-
function getContext(
|
|
29839
|
-
|
|
29840
|
-
for ( let i = 0; i < contextNames.length; i ++ ) {
|
|
29278
|
+
function getContext( contextName, contextAttributes ) {
|
|
29841
29279
|
|
|
29842
|
-
|
|
29843
|
-
|
|
29844
|
-
if ( context !== null ) return context;
|
|
29845
|
-
|
|
29846
|
-
}
|
|
29280
|
+
const context = canvas.getContext( contextName, contextAttributes );
|
|
29281
|
+
if ( context !== null ) return context;
|
|
29847
29282
|
|
|
29848
29283
|
return null;
|
|
29849
29284
|
|
|
@@ -29872,19 +29307,13 @@ class WebGLRenderer {
|
|
|
29872
29307
|
|
|
29873
29308
|
if ( _gl === null ) {
|
|
29874
29309
|
|
|
29875
|
-
const
|
|
29876
|
-
|
|
29877
|
-
if ( _this.isWebGL1Renderer === true ) {
|
|
29878
|
-
|
|
29879
|
-
contextNames.shift();
|
|
29880
|
-
|
|
29881
|
-
}
|
|
29310
|
+
const contextName = 'webgl2';
|
|
29882
29311
|
|
|
29883
|
-
_gl = getContext(
|
|
29312
|
+
_gl = getContext( contextName, contextAttributes );
|
|
29884
29313
|
|
|
29885
29314
|
if ( _gl === null ) {
|
|
29886
29315
|
|
|
29887
|
-
if ( getContext(
|
|
29316
|
+
if ( getContext( contextName ) ) {
|
|
29888
29317
|
|
|
29889
29318
|
throw new Error( 'Error creating WebGL context with your selected attributes.' );
|
|
29890
29319
|
|
|
@@ -29898,24 +29327,6 @@ class WebGLRenderer {
|
|
|
29898
29327
|
|
|
29899
29328
|
}
|
|
29900
29329
|
|
|
29901
|
-
if ( typeof WebGLRenderingContext !== 'undefined' && _gl instanceof WebGLRenderingContext ) { // @deprecated, r153
|
|
29902
|
-
|
|
29903
|
-
console.warn( 'THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163.' );
|
|
29904
|
-
|
|
29905
|
-
}
|
|
29906
|
-
|
|
29907
|
-
// Some experimental-webgl implementations do not have getShaderPrecisionFormat
|
|
29908
|
-
|
|
29909
|
-
if ( _gl.getShaderPrecisionFormat === undefined ) {
|
|
29910
|
-
|
|
29911
|
-
_gl.getShaderPrecisionFormat = function () {
|
|
29912
|
-
|
|
29913
|
-
return { 'rangeMin': 1, 'rangeMax': 1, 'precision': 1 };
|
|
29914
|
-
|
|
29915
|
-
};
|
|
29916
|
-
|
|
29917
|
-
}
|
|
29918
|
-
|
|
29919
29330
|
} catch ( error ) {
|
|
29920
29331
|
|
|
29921
29332
|
console.error( 'THREE.WebGLRenderer: ' + error.message );
|
|
@@ -29935,22 +29346,21 @@ class WebGLRenderer {
|
|
|
29935
29346
|
function initGLContext() {
|
|
29936
29347
|
|
|
29937
29348
|
extensions = new WebGLExtensions( _gl );
|
|
29349
|
+
extensions.init();
|
|
29938
29350
|
|
|
29939
29351
|
capabilities = new WebGLCapabilities( _gl, extensions, parameters );
|
|
29940
29352
|
|
|
29941
|
-
|
|
29942
|
-
|
|
29943
|
-
utils = new WebGLUtils( _gl, extensions, capabilities );
|
|
29353
|
+
utils = new WebGLUtils( _gl, extensions );
|
|
29944
29354
|
|
|
29945
|
-
state = new WebGLState( _gl
|
|
29355
|
+
state = new WebGLState( _gl );
|
|
29946
29356
|
|
|
29947
29357
|
info = new WebGLInfo( _gl );
|
|
29948
29358
|
properties = new WebGLProperties();
|
|
29949
29359
|
textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
|
|
29950
29360
|
cubemaps = new WebGLCubeMaps( _this );
|
|
29951
29361
|
cubeuvmaps = new WebGLCubeUVMaps( _this );
|
|
29952
|
-
attributes = new WebGLAttributes( _gl
|
|
29953
|
-
bindingStates = new WebGLBindingStates( _gl,
|
|
29362
|
+
attributes = new WebGLAttributes( _gl );
|
|
29363
|
+
bindingStates = new WebGLBindingStates( _gl, attributes );
|
|
29954
29364
|
geometries = new WebGLGeometries( _gl, attributes, info, bindingStates );
|
|
29955
29365
|
objects = new WebGLObjects( _gl, geometries, attributes, info );
|
|
29956
29366
|
morphtargets = new WebGLMorphtargets( _gl, capabilities, textures );
|
|
@@ -29958,14 +29368,14 @@ class WebGLRenderer {
|
|
|
29958
29368
|
programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping );
|
|
29959
29369
|
materials = new WebGLMaterials( _this, properties );
|
|
29960
29370
|
renderLists = new WebGLRenderLists();
|
|
29961
|
-
renderStates = new WebGLRenderStates( extensions
|
|
29371
|
+
renderStates = new WebGLRenderStates( extensions );
|
|
29962
29372
|
background = new WebGLBackground( _this, cubemaps, cubeuvmaps, state, objects, _alpha, premultipliedAlpha );
|
|
29963
29373
|
multiview = new WebGLMultiview( _this, extensions, _gl );
|
|
29964
29374
|
shadowMap = new WebGLShadowMap( _this, objects, capabilities );
|
|
29965
29375
|
uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
|
|
29966
29376
|
|
|
29967
|
-
bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info
|
|
29968
|
-
indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info
|
|
29377
|
+
bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info );
|
|
29378
|
+
indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info );
|
|
29969
29379
|
|
|
29970
29380
|
info.programs = programCache.programs;
|
|
29971
29381
|
|
|
@@ -30297,13 +29707,6 @@ class WebGLRenderer {
|
|
|
30297
29707
|
xr.removeEventListener( 'sessionstart', onXRSessionStart );
|
|
30298
29708
|
xr.removeEventListener( 'sessionend', onXRSessionEnd );
|
|
30299
29709
|
|
|
30300
|
-
if ( _transmissionRenderTarget ) {
|
|
30301
|
-
|
|
30302
|
-
_transmissionRenderTarget.dispose();
|
|
30303
|
-
_transmissionRenderTarget = null;
|
|
30304
|
-
|
|
30305
|
-
}
|
|
30306
|
-
|
|
30307
29710
|
animation.stop();
|
|
30308
29711
|
|
|
30309
29712
|
};
|
|
@@ -31072,17 +30475,19 @@ class WebGLRenderer {
|
|
|
31072
30475
|
|
|
31073
30476
|
}
|
|
31074
30477
|
|
|
31075
|
-
|
|
30478
|
+
if ( currentRenderState.state.transmissionRenderTarget === null ) {
|
|
31076
30479
|
|
|
31077
|
-
|
|
31078
|
-
|
|
31079
|
-
_transmissionRenderTarget = new WebGLRenderTarget( 1, 1, {
|
|
30480
|
+
currentRenderState.state.transmissionRenderTarget = new WebGLRenderTarget( 1, 1, {
|
|
31080
30481
|
generateMipmaps: true,
|
|
31081
|
-
type: extensions.has( 'EXT_color_buffer_half_float' ) ? HalfFloatType : UnsignedByteType,
|
|
30482
|
+
type: ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) ) ? HalfFloatType : UnsignedByteType,
|
|
31082
30483
|
minFilter: LinearMipmapLinearFilter,
|
|
31083
|
-
samples:
|
|
30484
|
+
samples: 4,
|
|
30485
|
+
stencilBuffer: stencil
|
|
31084
30486
|
} );
|
|
31085
30487
|
|
|
30488
|
+
const renderTargetProperties = properties.get( currentRenderState.state.transmissionRenderTarget );
|
|
30489
|
+
renderTargetProperties.__isTransmissionRenderTarget = true;
|
|
30490
|
+
|
|
31086
30491
|
// debug
|
|
31087
30492
|
|
|
31088
30493
|
/*
|
|
@@ -31095,22 +30500,15 @@ class WebGLRenderer {
|
|
|
31095
30500
|
|
|
31096
30501
|
}
|
|
31097
30502
|
|
|
31098
|
-
|
|
31099
|
-
|
|
31100
|
-
if ( isWebGL2 ) {
|
|
31101
|
-
|
|
31102
|
-
_transmissionRenderTarget.setSize( _vector2.x, _vector2.y );
|
|
31103
|
-
|
|
31104
|
-
} else {
|
|
31105
|
-
|
|
31106
|
-
_transmissionRenderTarget.setSize( floorPowerOfTwo( _vector2.x ), floorPowerOfTwo( _vector2.y ) );
|
|
30503
|
+
const transmissionRenderTarget = currentRenderState.state.transmissionRenderTarget;
|
|
31107
30504
|
|
|
31108
|
-
|
|
30505
|
+
_this.getDrawingBufferSize( _vector2 );
|
|
30506
|
+
transmissionRenderTarget.setSize( _vector2.x, _vector2.y );
|
|
31109
30507
|
|
|
31110
30508
|
//
|
|
31111
30509
|
|
|
31112
30510
|
const currentRenderTarget = _this.getRenderTarget();
|
|
31113
|
-
_this.setRenderTarget(
|
|
30511
|
+
_this.setRenderTarget( transmissionRenderTarget );
|
|
31114
30512
|
|
|
31115
30513
|
_this.getClearColor( _currentClearColor );
|
|
31116
30514
|
_currentClearAlpha = _this.getClearAlpha();
|
|
@@ -31125,8 +30523,8 @@ class WebGLRenderer {
|
|
|
31125
30523
|
|
|
31126
30524
|
renderObjects( opaqueObjects, scene, camera );
|
|
31127
30525
|
|
|
31128
|
-
textures.updateMultisampleRenderTarget(
|
|
31129
|
-
textures.updateRenderTargetMipmap(
|
|
30526
|
+
textures.updateMultisampleRenderTarget( transmissionRenderTarget );
|
|
30527
|
+
textures.updateRenderTargetMipmap( transmissionRenderTarget );
|
|
31130
30528
|
|
|
31131
30529
|
let renderTargetNeedsUpdate = false;
|
|
31132
30530
|
|
|
@@ -31159,8 +30557,8 @@ class WebGLRenderer {
|
|
|
31159
30557
|
|
|
31160
30558
|
if ( renderTargetNeedsUpdate === true ) {
|
|
31161
30559
|
|
|
31162
|
-
textures.updateMultisampleRenderTarget(
|
|
31163
|
-
textures.updateRenderTargetMipmap(
|
|
30560
|
+
textures.updateMultisampleRenderTarget( transmissionRenderTarget );
|
|
30561
|
+
textures.updateRenderTargetMipmap( transmissionRenderTarget );
|
|
31164
30562
|
|
|
31165
30563
|
}
|
|
31166
30564
|
|
|
@@ -31520,7 +30918,7 @@ class WebGLRenderer {
|
|
|
31520
30918
|
|
|
31521
30919
|
needsProgramChange = true;
|
|
31522
30920
|
|
|
31523
|
-
} else if (
|
|
30921
|
+
} else if ( materialProperties.morphTargetsCount !== morphTargetsCount ) {
|
|
31524
30922
|
|
|
31525
30923
|
needsProgramChange = true;
|
|
31526
30924
|
|
|
@@ -31642,17 +31040,9 @@ class WebGLRenderer {
|
|
|
31642
31040
|
|
|
31643
31041
|
if ( skeleton ) {
|
|
31644
31042
|
|
|
31645
|
-
if (
|
|
31646
|
-
|
|
31647
|
-
if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
|
|
31648
|
-
|
|
31649
|
-
p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
|
|
31043
|
+
if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
|
|
31650
31044
|
|
|
31651
|
-
|
|
31652
|
-
|
|
31653
|
-
console.warn( 'THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required.' );
|
|
31654
|
-
|
|
31655
|
-
}
|
|
31045
|
+
p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
|
|
31656
31046
|
|
|
31657
31047
|
}
|
|
31658
31048
|
|
|
@@ -31667,7 +31057,7 @@ class WebGLRenderer {
|
|
|
31667
31057
|
|
|
31668
31058
|
const morphAttributes = geometry.morphAttributes;
|
|
31669
31059
|
|
|
31670
|
-
if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined
|
|
31060
|
+
if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined ) ) {
|
|
31671
31061
|
|
|
31672
31062
|
morphtargets.update( object, geometry, program );
|
|
31673
31063
|
|
|
@@ -31690,6 +31080,12 @@ class WebGLRenderer {
|
|
|
31690
31080
|
|
|
31691
31081
|
}
|
|
31692
31082
|
|
|
31083
|
+
if ( material.isMeshStandardMaterial && material.envMap === null && scene.environment !== null ) {
|
|
31084
|
+
|
|
31085
|
+
m_uniforms.envMapIntensity.value = scene.environmentIntensity;
|
|
31086
|
+
|
|
31087
|
+
}
|
|
31088
|
+
|
|
31693
31089
|
if ( refreshMaterial ) {
|
|
31694
31090
|
|
|
31695
31091
|
p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
|
|
@@ -31717,7 +31113,7 @@ class WebGLRenderer {
|
|
|
31717
31113
|
|
|
31718
31114
|
}
|
|
31719
31115
|
|
|
31720
|
-
materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height,
|
|
31116
|
+
materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget );
|
|
31721
31117
|
|
|
31722
31118
|
WebGLUniforms.upload( _gl, getUniformList( materialProperties ), m_uniforms, textures );
|
|
31723
31119
|
|
|
@@ -31759,18 +31155,10 @@ class WebGLRenderer {
|
|
|
31759
31155
|
|
|
31760
31156
|
for ( let i = 0, l = groups.length; i < l; i ++ ) {
|
|
31761
31157
|
|
|
31762
|
-
|
|
31763
|
-
|
|
31764
|
-
const group = groups[ i ];
|
|
31765
|
-
|
|
31766
|
-
uniformsGroups.update( group, program );
|
|
31767
|
-
uniformsGroups.bind( group, program );
|
|
31768
|
-
|
|
31769
|
-
} else {
|
|
31770
|
-
|
|
31771
|
-
console.warn( 'THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.' );
|
|
31158
|
+
const group = groups[ i ];
|
|
31772
31159
|
|
|
31773
|
-
|
|
31160
|
+
uniformsGroups.update( group, program );
|
|
31161
|
+
uniformsGroups.bind( group, program );
|
|
31774
31162
|
|
|
31775
31163
|
}
|
|
31776
31164
|
|
|
@@ -31939,7 +31327,7 @@ class WebGLRenderer {
|
|
|
31939
31327
|
|
|
31940
31328
|
isCube = true;
|
|
31941
31329
|
|
|
31942
|
-
} else if ( (
|
|
31330
|
+
} else if ( ( renderTarget.samples > 0 ) && textures.useMultisampledRTT( renderTarget ) === false ) {
|
|
31943
31331
|
|
|
31944
31332
|
framebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer;
|
|
31945
31333
|
|
|
@@ -31971,7 +31359,7 @@ class WebGLRenderer {
|
|
|
31971
31359
|
|
|
31972
31360
|
const framebufferBound = state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
31973
31361
|
|
|
31974
|
-
if ( framebufferBound &&
|
|
31362
|
+
if ( framebufferBound && useDefaultFramebuffer ) {
|
|
31975
31363
|
|
|
31976
31364
|
state.drawBuffers( renderTarget, framebuffer );
|
|
31977
31365
|
|
|
@@ -32032,11 +31420,10 @@ class WebGLRenderer {
|
|
|
32032
31420
|
|
|
32033
31421
|
}
|
|
32034
31422
|
|
|
32035
|
-
const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) ||
|
|
31423
|
+
const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) );
|
|
32036
31424
|
|
|
32037
31425
|
if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // Edge and Chrome Mac < 52 (#9513)
|
|
32038
|
-
|
|
32039
|
-
! halfFloatSupportedByExt ) {
|
|
31426
|
+
textureType !== FloatType && ! halfFloatSupportedByExt ) {
|
|
32040
31427
|
|
|
32041
31428
|
console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
32042
31429
|
return;
|
|
@@ -32120,13 +31507,6 @@ class WebGLRenderer {
|
|
|
32120
31507
|
|
|
32121
31508
|
this.copyTextureToTexture3D = function ( sourceBox, position, srcTexture, dstTexture, level = 0 ) {
|
|
32122
31509
|
|
|
32123
|
-
if ( _this.isWebGL1Renderer ) {
|
|
32124
|
-
|
|
32125
|
-
console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.' );
|
|
32126
|
-
return;
|
|
32127
|
-
|
|
32128
|
-
}
|
|
32129
|
-
|
|
32130
31510
|
const width = Math.round( sourceBox.max.x - sourceBox.min.x );
|
|
32131
31511
|
const height = Math.round( sourceBox.max.y - sourceBox.min.y );
|
|
32132
31512
|
const depth = sourceBox.max.z - sourceBox.min.z + 1;
|
|
@@ -32281,10 +31661,6 @@ class WebGLRenderer {
|
|
|
32281
31661
|
|
|
32282
31662
|
}
|
|
32283
31663
|
|
|
32284
|
-
class WebGL1Renderer extends WebGLRenderer {}
|
|
32285
|
-
|
|
32286
|
-
WebGL1Renderer.prototype.isWebGL1Renderer = true;
|
|
32287
|
-
|
|
32288
31664
|
class FogExp2 {
|
|
32289
31665
|
|
|
32290
31666
|
constructor( color, density = 0.00025 ) {
|
|
@@ -32369,6 +31745,8 @@ class Scene extends Object3D {
|
|
|
32369
31745
|
this.backgroundBlurriness = 0;
|
|
32370
31746
|
this.backgroundIntensity = 1;
|
|
32371
31747
|
this.backgroundRotation = new Euler();
|
|
31748
|
+
|
|
31749
|
+
this.environmentIntensity = 1;
|
|
32372
31750
|
this.environmentRotation = new Euler();
|
|
32373
31751
|
|
|
32374
31752
|
this.overrideMaterial = null;
|
|
@@ -32392,6 +31770,8 @@ class Scene extends Object3D {
|
|
|
32392
31770
|
this.backgroundBlurriness = source.backgroundBlurriness;
|
|
32393
31771
|
this.backgroundIntensity = source.backgroundIntensity;
|
|
32394
31772
|
this.backgroundRotation.copy( source.backgroundRotation );
|
|
31773
|
+
|
|
31774
|
+
this.environmentIntensity = source.environmentIntensity;
|
|
32395
31775
|
this.environmentRotation.copy( source.environmentRotation );
|
|
32396
31776
|
|
|
32397
31777
|
if ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();
|
|
@@ -32407,10 +31787,12 @@ class Scene extends Object3D {
|
|
|
32407
31787
|
const data = super.toJSON( meta );
|
|
32408
31788
|
|
|
32409
31789
|
if ( this.fog !== null ) data.object.fog = this.fog.toJSON();
|
|
31790
|
+
|
|
32410
31791
|
if ( this.backgroundBlurriness > 0 ) data.object.backgroundBlurriness = this.backgroundBlurriness;
|
|
32411
31792
|
if ( this.backgroundIntensity !== 1 ) data.object.backgroundIntensity = this.backgroundIntensity;
|
|
32412
|
-
|
|
32413
31793
|
data.object.backgroundRotation = this.backgroundRotation.toArray();
|
|
31794
|
+
|
|
31795
|
+
if ( this.environmentIntensity !== 1 ) data.object.environmentIntensity = this.environmentIntensity;
|
|
32414
31796
|
data.object.environmentRotation = this.environmentRotation.toArray();
|
|
32415
31797
|
|
|
32416
31798
|
return data;
|
|
@@ -34039,6 +33421,7 @@ class InstancedMesh extends Mesh {
|
|
|
34039
33421
|
|
|
34040
33422
|
this.instanceMatrix.copy( source.instanceMatrix );
|
|
34041
33423
|
|
|
33424
|
+
if ( source.morphTexture !== null ) this.morphTexture = source.morphTexture.clone();
|
|
34042
33425
|
if ( source.instanceColor !== null ) this.instanceColor = source.instanceColor.clone();
|
|
34043
33426
|
|
|
34044
33427
|
this.count = source.count;
|
|
@@ -34190,6 +33573,15 @@ class InstancedMesh extends Mesh {
|
|
|
34190
33573
|
|
|
34191
33574
|
this.dispatchEvent( { type: 'dispose' } );
|
|
34192
33575
|
|
|
33576
|
+
if ( this.morphTexture !== null ) {
|
|
33577
|
+
|
|
33578
|
+
this.morphTexture.dispose();
|
|
33579
|
+
this.morphTexture = null;
|
|
33580
|
+
|
|
33581
|
+
}
|
|
33582
|
+
|
|
33583
|
+
return this;
|
|
33584
|
+
|
|
34193
33585
|
}
|
|
34194
33586
|
|
|
34195
33587
|
}
|
|
@@ -34379,8 +33771,7 @@ class BatchedMesh extends Mesh {
|
|
|
34379
33771
|
const { array, itemSize, normalized } = srcAttribute;
|
|
34380
33772
|
|
|
34381
33773
|
const dstArray = new array.constructor( maxVertexCount * itemSize );
|
|
34382
|
-
const dstAttribute = new
|
|
34383
|
-
dstAttribute.setUsage( srcAttribute.usage );
|
|
33774
|
+
const dstAttribute = new BufferAttribute( dstArray, itemSize, normalized );
|
|
34384
33775
|
|
|
34385
33776
|
geometry.setAttribute( attributeName, dstAttribute );
|
|
34386
33777
|
|
|
@@ -34407,7 +33798,7 @@ class BatchedMesh extends Mesh {
|
|
|
34407
33798
|
|
|
34408
33799
|
}
|
|
34409
33800
|
|
|
34410
|
-
// Make sure the geometry is compatible with the existing combined geometry
|
|
33801
|
+
// Make sure the geometry is compatible with the existing combined geometry attributes
|
|
34411
33802
|
_validateGeometry( geometry ) {
|
|
34412
33803
|
|
|
34413
33804
|
// check that the geometry doesn't have a version of our reserved id attribute
|
|
@@ -34698,6 +34089,7 @@ class BatchedMesh extends Mesh {
|
|
|
34698
34089
|
}
|
|
34699
34090
|
|
|
34700
34091
|
dstAttribute.needsUpdate = true;
|
|
34092
|
+
dstAttribute.addUpdateRange( vertexStart * itemSize, vertexCount * itemSize );
|
|
34701
34093
|
|
|
34702
34094
|
}
|
|
34703
34095
|
|
|
@@ -34721,6 +34113,7 @@ class BatchedMesh extends Mesh {
|
|
|
34721
34113
|
}
|
|
34722
34114
|
|
|
34723
34115
|
dstIndex.needsUpdate = true;
|
|
34116
|
+
dstIndex.addUpdateRange( indexStart, reservedRange.indexCount );
|
|
34724
34117
|
|
|
34725
34118
|
}
|
|
34726
34119
|
|
|
@@ -44067,7 +43460,7 @@ VectorKeyframeTrack.prototype.ValueTypeName = 'vector';
|
|
|
44067
43460
|
|
|
44068
43461
|
class AnimationClip {
|
|
44069
43462
|
|
|
44070
|
-
constructor( name, duration = - 1, tracks, blendMode = NormalAnimationBlendMode ) {
|
|
43463
|
+
constructor( name = '', duration = - 1, tracks = [], blendMode = NormalAnimationBlendMode ) {
|
|
44071
43464
|
|
|
44072
43465
|
this.name = name;
|
|
44073
43466
|
this.tracks = tracks;
|
|
@@ -47820,6 +47213,8 @@ class ObjectLoader extends Loader {
|
|
|
47820
47213
|
if ( data.backgroundBlurriness !== undefined ) object.backgroundBlurriness = data.backgroundBlurriness;
|
|
47821
47214
|
if ( data.backgroundIntensity !== undefined ) object.backgroundIntensity = data.backgroundIntensity;
|
|
47822
47215
|
if ( data.backgroundRotation !== undefined ) object.backgroundRotation.fromArray( data.backgroundRotation );
|
|
47216
|
+
|
|
47217
|
+
if ( data.environmentIntensity !== undefined ) object.environmentIntensity = data.environmentIntensity;
|
|
47823
47218
|
if ( data.environmentRotation !== undefined ) object.environmentRotation.fromArray( data.environmentRotation );
|
|
47824
47219
|
|
|
47825
47220
|
break;
|
|
@@ -52451,11 +51846,9 @@ function intersect( object, raycaster, intersects, recursive ) {
|
|
|
52451
51846
|
/**
|
|
52452
51847
|
* Ref: https://en.wikipedia.org/wiki/Spherical_coordinate_system
|
|
52453
51848
|
*
|
|
52454
|
-
*
|
|
52455
|
-
*
|
|
51849
|
+
* phi (the polar angle) is measured from the positive y-axis. The positive y-axis is up.
|
|
51850
|
+
* theta (the azimuthal angle) is measured from the positive z-axis.
|
|
52456
51851
|
*/
|
|
52457
|
-
|
|
52458
|
-
|
|
52459
51852
|
class Spherical {
|
|
52460
51853
|
|
|
52461
51854
|
constructor( radius = 1, phi = 0, theta = 0 ) {
|
|
@@ -54765,6 +54158,7 @@ exports.RGBA_PVRTC_4BPPV1_Format = RGBA_PVRTC_4BPPV1_Format;
|
|
|
54765
54158
|
exports.RGBA_S3TC_DXT1_Format = RGBA_S3TC_DXT1_Format;
|
|
54766
54159
|
exports.RGBA_S3TC_DXT3_Format = RGBA_S3TC_DXT3_Format;
|
|
54767
54160
|
exports.RGBA_S3TC_DXT5_Format = RGBA_S3TC_DXT5_Format;
|
|
54161
|
+
exports.RGBFormat = RGBFormat;
|
|
54768
54162
|
exports.RGB_BPTC_SIGNED_Format = RGB_BPTC_SIGNED_Format;
|
|
54769
54163
|
exports.RGB_BPTC_UNSIGNED_Format = RGB_BPTC_UNSIGNED_Format;
|
|
54770
54164
|
exports.RGB_ETC1_Format = RGB_ETC1_Format;
|
|
@@ -54850,6 +54244,7 @@ exports.UniformsLib = UniformsLib;
|
|
|
54850
54244
|
exports.UniformsUtils = UniformsUtils;
|
|
54851
54245
|
exports.UnsignedByteType = UnsignedByteType;
|
|
54852
54246
|
exports.UnsignedInt248Type = UnsignedInt248Type;
|
|
54247
|
+
exports.UnsignedInt5999Type = UnsignedInt5999Type;
|
|
54853
54248
|
exports.UnsignedIntType = UnsignedIntType;
|
|
54854
54249
|
exports.UnsignedShort4444Type = UnsignedShort4444Type;
|
|
54855
54250
|
exports.UnsignedShort5551Type = UnsignedShort5551Type;
|
|
@@ -54860,7 +54255,6 @@ exports.Vector3 = Vector3;
|
|
|
54860
54255
|
exports.Vector4 = Vector4;
|
|
54861
54256
|
exports.VectorKeyframeTrack = VectorKeyframeTrack;
|
|
54862
54257
|
exports.VideoTexture = VideoTexture;
|
|
54863
|
-
exports.WebGL1Renderer = WebGL1Renderer;
|
|
54864
54258
|
exports.WebGL3DRenderTarget = WebGL3DRenderTarget;
|
|
54865
54259
|
exports.WebGLArrayRenderTarget = WebGLArrayRenderTarget;
|
|
54866
54260
|
exports.WebGLCoordinateSystem = WebGLCoordinateSystem;
|
|
@@ -54876,5 +54270,4 @@ exports.ZeroCurvatureEnding = ZeroCurvatureEnding;
|
|
|
54876
54270
|
exports.ZeroFactor = ZeroFactor;
|
|
54877
54271
|
exports.ZeroSlopeEnding = ZeroSlopeEnding;
|
|
54878
54272
|
exports.ZeroStencilOp = ZeroStencilOp;
|
|
54879
|
-
exports._SRGBAFormat = _SRGBAFormat;
|
|
54880
54273
|
exports.createCanvasElement = createCanvasElement;
|