super-three 0.161.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 +822 -1332
- package/build/three.module.js +820 -1328
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/DragControls.js +91 -30
- package/examples/jsm/controls/OrbitControls.js +32 -6
- package/examples/jsm/controls/TransformControls.js +9 -9
- package/examples/jsm/exporters/GLTFExporter.js +30 -3
- 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/interactive/InteractiveGroup.js +15 -25
- package/examples/jsm/libs/fflate.module.js +694 -496
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/libs/tween.module.js +32 -14
- package/examples/jsm/lines/LineMaterial.js +0 -2
- package/examples/jsm/loaders/3DMLoader.js +13 -21
- 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/loaders/VOXLoader.js +9 -2
- package/examples/jsm/loaders/VRMLLoader.js +6 -2
- package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
- package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
- package/examples/jsm/nodes/Nodes.js +15 -8
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
- package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
- package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
- package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
- package/examples/jsm/nodes/accessors/MaterialNode.js +2 -2
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -12
- package/examples/jsm/nodes/accessors/MorphNode.js +20 -10
- package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
- package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
- package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
- package/examples/jsm/nodes/accessors/SkinningNode.js +31 -10
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +18 -0
- package/examples/jsm/nodes/accessors/TangentNode.js +8 -2
- package/examples/jsm/nodes/accessors/TextureNode.js +30 -7
- package/examples/jsm/nodes/accessors/UniformsNode.js +140 -0
- package/examples/jsm/nodes/code/CodeNode.js +6 -0
- package/examples/jsm/nodes/core/AssignNode.js +68 -12
- package/examples/jsm/nodes/core/Node.js +67 -6
- package/examples/jsm/nodes/core/NodeBuilder.js +23 -24
- package/examples/jsm/nodes/core/NodeFrame.js +8 -8
- package/examples/jsm/nodes/core/NodeUtils.js +2 -2
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/UniformNode.js +20 -0
- package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
- 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 +70 -17
- package/examples/jsm/nodes/math/CondNode.js +42 -7
- package/examples/jsm/nodes/math/MathNode.js +20 -0
- 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/ArrayElementNode.js +0 -6
- package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
- package/examples/jsm/nodes/utils/LoopNode.js +2 -0
- package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
- 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/OutputPass.js +2 -0
- 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 +3 -3
- package/examples/jsm/renderers/common/ClippingContext.js +165 -0
- 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 +3 -1
- package/examples/jsm/renderers/common/RenderContexts.js +2 -13
- package/examples/jsm/renderers/common/RenderObject.js +46 -3
- package/examples/jsm/renderers/common/RenderObjects.js +2 -0
- package/examples/jsm/renderers/common/Renderer.js +113 -39
- package/examples/jsm/renderers/common/StorageBufferAttribute.js +2 -2
- package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +3 -13
- package/examples/jsm/renderers/common/UniformsGroup.js +6 -4
- package/examples/jsm/renderers/common/extras/PMREMGenerator.js +777 -0
- package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -0
- package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +6 -18
- package/examples/jsm/renderers/webgl/WebGLBackend.js +174 -30
- package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +141 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +136 -11
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +8 -2
- package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +90 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -1
- 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 +67 -37
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +20 -43
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +32 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +94 -20
- package/examples/jsm/shaders/OutputShader.js +4 -0
- package/examples/jsm/utils/GPUStatsPanel.js +10 -45
- package/examples/jsm/utils/SkeletonUtils.js +14 -3
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/examples/jsm/webxr/VRButton.js +13 -5
- package/examples/jsm/webxr/XRButton.js +0 -1
- package/examples/jsm/webxr/XRControllerModelFactory.js +8 -0
- package/package.json +4 -3
- package/src/Three.Legacy.js +20 -0
- package/src/Three.js +0 -2
- package/src/animation/AnimationClip.js +1 -1
- package/src/constants.js +4 -7
- package/src/core/BufferAttribute.js +0 -11
- package/src/core/BufferGeometry.js +23 -29
- package/src/core/Object3D.js +21 -7
- package/src/core/Raycaster.js +18 -4
- package/src/core/RenderTarget.js +44 -21
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/extras/curves/EllipseCurve.js +2 -2
- package/src/helpers/SpotLightHelper.js +18 -1
- package/src/loaders/DataTextureLoader.js +0 -4
- package/src/loaders/MaterialLoader.js +1 -0
- package/src/loaders/ObjectLoader.js +4 -1
- package/src/materials/Material.js +2 -1
- package/src/materials/MeshBasicMaterial.js +3 -0
- package/src/materials/MeshLambertMaterial.js +3 -0
- package/src/materials/MeshPhongMaterial.js +3 -0
- package/src/materials/MeshStandardMaterial.js +3 -0
- package/src/materials/ShaderMaterial.js +0 -4
- package/src/math/Quaternion.js +13 -12
- package/src/math/Spherical.js +4 -5
- package/src/math/Vector3.js +7 -7
- package/src/objects/BatchedMesh.js +4 -3
- package/src/objects/InstancedMesh.js +63 -0
- package/src/objects/Mesh.js +0 -1
- package/src/renderers/WebGLCubeRenderTarget.js +1 -10
- package/src/renderers/WebGLRenderer.js +70 -136
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
- 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/map_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +11 -2
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +23 -0
- package/src/renderers/shaders/ShaderChunk.js +2 -0
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib.js +3 -2
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/shaders/UniformsUtils.js +10 -1
- package/src/renderers/webgl/WebGLAttributes.js +6 -33
- package/src/renderers/webgl/WebGLBackground.js +18 -0
- 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 +26 -4
- package/src/renderers/webgl/WebGLMorphtargets.js +79 -210
- package/src/renderers/webgl/WebGLProgram.js +30 -48
- package/src/renderers/webgl/WebGLPrograms.js +5 -14
- package/src/renderers/webgl/WebGLRenderStates.js +8 -6
- package/src/renderers/webgl/WebGLState.js +21 -75
- package/src/renderers/webgl/WebGLTextures.js +143 -275
- 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 +14 -0
- package/src/textures/Texture.js +6 -24
- package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/src/renderers/WebGL1Renderer.js +0 -7
- package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, RGB_ETC1_Format, DepthFormat, DepthStencilFormat,
|
|
2
|
-
import * as MathUtils from '../../math/MathUtils.js';
|
|
3
|
-
import { ImageUtils } from '../../extras/ImageUtils.js';
|
|
1
|
+
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, RGB_ETC1_Format, DepthFormat, DepthStencilFormat, UnsignedIntType, UnsignedInt248Type, FloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, NoColorSpace, LinearSRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, SRGBTransfer, LinearTransfer } from '../../constants.js';
|
|
4
2
|
import { createElementNS } from '../../utils.js';
|
|
5
3
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
4
|
+
import { Vector2 } from '../../math/Vector2.js';
|
|
6
5
|
|
|
7
6
|
function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
|
|
8
7
|
|
|
9
|
-
const isWebGL2 = capabilities.isWebGL2;
|
|
10
8
|
const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
|
|
11
9
|
const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
|
|
12
10
|
const multiviewExt = extensions.has( 'OCULUS_multiview' ) ? extensions.get( 'OCULUS_multiview' ) : null;
|
|
13
11
|
|
|
12
|
+
const _imageDimensions = new Vector2();
|
|
14
13
|
const _videoTextures = new WeakMap();
|
|
15
14
|
let _canvas;
|
|
16
15
|
|
|
@@ -47,32 +46,33 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
47
46
|
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
function resizeImage( image,
|
|
49
|
+
function resizeImage( image, needsNewCanvas, maxSize ) {
|
|
51
50
|
|
|
52
51
|
let scale = 1;
|
|
53
52
|
|
|
53
|
+
const dimensions = getDimensions( image );
|
|
54
|
+
|
|
54
55
|
// handle case if texture exceeds max size
|
|
55
56
|
|
|
56
|
-
if (
|
|
57
|
+
if ( dimensions.width > maxSize || dimensions.height > maxSize ) {
|
|
57
58
|
|
|
58
|
-
scale = maxSize / Math.max(
|
|
59
|
+
scale = maxSize / Math.max( dimensions.width, dimensions.height );
|
|
59
60
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
// only perform resize if necessary
|
|
63
64
|
|
|
64
|
-
if ( scale < 1
|
|
65
|
+
if ( scale < 1 ) {
|
|
65
66
|
|
|
66
67
|
// only perform resize for certain image types
|
|
67
68
|
|
|
68
69
|
if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
|
|
69
70
|
( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
|
|
70
|
-
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap )
|
|
71
|
-
|
|
72
|
-
const floor = needsPowerOfTwo ? MathUtils.floorPowerOfTwo : Math.floor;
|
|
71
|
+
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ||
|
|
72
|
+
( typeof VideoFrame !== 'undefined' && image instanceof VideoFrame ) ) {
|
|
73
73
|
|
|
74
|
-
const width = floor( scale *
|
|
75
|
-
const height = floor( scale *
|
|
74
|
+
const width = Math.floor( scale * dimensions.width );
|
|
75
|
+
const height = Math.floor( scale * dimensions.height );
|
|
76
76
|
|
|
77
77
|
if ( _canvas === undefined ) _canvas = createCanvas( width, height );
|
|
78
78
|
|
|
@@ -86,7 +86,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
86
86
|
const context = canvas.getContext( '2d' );
|
|
87
87
|
context.drawImage( image, 0, 0, width, height );
|
|
88
88
|
|
|
89
|
-
console.warn( 'THREE.WebGLRenderer: Texture has been resized from (' +
|
|
89
|
+
console.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + dimensions.width + 'x' + dimensions.height + ') to (' + width + 'x' + height + ').' );
|
|
90
90
|
|
|
91
91
|
return canvas;
|
|
92
92
|
|
|
@@ -94,7 +94,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
94
94
|
|
|
95
95
|
if ( 'data' in image ) {
|
|
96
96
|
|
|
97
|
-
console.warn( 'THREE.WebGLRenderer: Image in DataTexture is too big (' +
|
|
97
|
+
console.warn( 'THREE.WebGLRenderer: Image in DataTexture is too big (' + dimensions.width + 'x' + dimensions.height + ').' );
|
|
98
98
|
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -108,25 +108,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
108
108
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
function
|
|
112
|
-
|
|
113
|
-
return MathUtils.isPowerOfTwo( image.width ) && MathUtils.isPowerOfTwo( image.height );
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function textureNeedsPowerOfTwo( texture ) {
|
|
118
|
-
|
|
119
|
-
if ( isWebGL2 ) return false;
|
|
111
|
+
function textureNeedsGenerateMipmaps( texture ) {
|
|
120
112
|
|
|
121
|
-
return
|
|
122
|
-
( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter );
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function textureNeedsGenerateMipmaps( texture, supportsMips ) {
|
|
127
|
-
|
|
128
|
-
return texture.generateMipmaps && supportsMips &&
|
|
129
|
-
texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
|
|
113
|
+
return texture.generateMipmaps && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
|
|
130
114
|
|
|
131
115
|
}
|
|
132
116
|
|
|
@@ -138,8 +122,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
138
122
|
|
|
139
123
|
function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
|
|
140
124
|
|
|
141
|
-
if ( isWebGL2 === false ) return glFormat;
|
|
142
|
-
|
|
143
125
|
if ( internalFormatName !== null ) {
|
|
144
126
|
|
|
145
127
|
if ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ];
|
|
@@ -177,6 +159,23 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
177
159
|
|
|
178
160
|
}
|
|
179
161
|
|
|
162
|
+
if ( glFormat === _gl.RG_INTEGER ) {
|
|
163
|
+
|
|
164
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RG8UI;
|
|
165
|
+
if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RG16UI;
|
|
166
|
+
if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RG32UI;
|
|
167
|
+
if ( glType === _gl.BYTE ) internalFormat = _gl.RG8I;
|
|
168
|
+
if ( glType === _gl.SHORT ) internalFormat = _gl.RG16I;
|
|
169
|
+
if ( glType === _gl.INT ) internalFormat = _gl.RG32I;
|
|
170
|
+
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if ( glFormat === _gl.RGB ) {
|
|
174
|
+
|
|
175
|
+
if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
|
|
176
|
+
|
|
177
|
+
}
|
|
178
|
+
|
|
180
179
|
if ( glFormat === _gl.RGBA ) {
|
|
181
180
|
|
|
182
181
|
const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
|
|
@@ -201,9 +200,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
201
200
|
|
|
202
201
|
}
|
|
203
202
|
|
|
204
|
-
function getMipLevels( texture, image
|
|
203
|
+
function getMipLevels( texture, image ) {
|
|
205
204
|
|
|
206
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
205
|
+
if ( textureNeedsGenerateMipmaps( texture ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
|
|
207
206
|
|
|
208
207
|
return Math.log2( Math.max( image.width, image.height ) ) + 1;
|
|
209
208
|
|
|
@@ -227,20 +226,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
227
226
|
|
|
228
227
|
}
|
|
229
228
|
|
|
230
|
-
// Fallback filters for non-power-of-2 textures
|
|
231
|
-
|
|
232
|
-
function filterFallback( f ) {
|
|
233
|
-
|
|
234
|
-
if ( f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter ) {
|
|
235
|
-
|
|
236
|
-
return _gl.NEAREST;
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return _gl.LINEAR;
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
|
|
244
229
|
//
|
|
245
230
|
|
|
246
231
|
function onTextureDispose( event ) {
|
|
@@ -324,18 +309,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
324
309
|
|
|
325
310
|
function deallocateRenderTarget( renderTarget ) {
|
|
326
311
|
|
|
327
|
-
const texture = renderTarget.texture;
|
|
328
|
-
|
|
329
312
|
const renderTargetProperties = properties.get( renderTarget );
|
|
330
|
-
const textureProperties = properties.get( texture );
|
|
331
|
-
|
|
332
|
-
if ( textureProperties.__webglTexture !== undefined ) {
|
|
333
|
-
|
|
334
|
-
_gl.deleteTexture( textureProperties.__webglTexture );
|
|
335
|
-
|
|
336
|
-
info.memory.textures --;
|
|
337
|
-
|
|
338
|
-
}
|
|
339
313
|
|
|
340
314
|
if ( renderTarget.depthTexture ) {
|
|
341
315
|
|
|
@@ -390,27 +364,24 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
390
364
|
|
|
391
365
|
}
|
|
392
366
|
|
|
393
|
-
|
|
367
|
+
const textures = renderTarget.textures;
|
|
394
368
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
const attachmentProperties = properties.get( texture[ i ] );
|
|
369
|
+
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
398
370
|
|
|
399
|
-
|
|
371
|
+
const attachmentProperties = properties.get( textures[ i ] );
|
|
400
372
|
|
|
401
|
-
|
|
373
|
+
if ( attachmentProperties.__webglTexture ) {
|
|
402
374
|
|
|
403
|
-
|
|
375
|
+
_gl.deleteTexture( attachmentProperties.__webglTexture );
|
|
404
376
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
properties.remove( texture[ i ] );
|
|
377
|
+
info.memory.textures --;
|
|
408
378
|
|
|
409
379
|
}
|
|
410
380
|
|
|
381
|
+
properties.remove( textures[ i ] );
|
|
382
|
+
|
|
411
383
|
}
|
|
412
384
|
|
|
413
|
-
properties.remove( texture );
|
|
414
385
|
properties.remove( renderTarget );
|
|
415
386
|
|
|
416
387
|
}
|
|
@@ -572,7 +543,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
572
543
|
[ NotEqualCompare ]: _gl.NOTEQUAL
|
|
573
544
|
};
|
|
574
545
|
|
|
575
|
-
function setTextureParameters( textureType, texture
|
|
546
|
+
function setTextureParameters( textureType, texture ) {
|
|
576
547
|
|
|
577
548
|
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false &&
|
|
578
549
|
( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || texture.magFilter === NearestMipmapLinearFilter || texture.magFilter === LinearMipmapLinearFilter ||
|
|
@@ -582,48 +553,18 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
582
553
|
|
|
583
554
|
}
|
|
584
555
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
|
|
588
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
|
|
589
|
-
|
|
590
|
-
if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
|
|
591
|
-
|
|
592
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
|
|
593
|
-
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
|
|
597
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );
|
|
598
|
-
|
|
599
|
-
} else {
|
|
600
|
-
|
|
601
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );
|
|
602
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );
|
|
603
|
-
|
|
604
|
-
if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
|
|
605
|
-
|
|
606
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, _gl.CLAMP_TO_EDGE );
|
|
607
|
-
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
if ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) {
|
|
611
|
-
|
|
612
|
-
console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' );
|
|
613
|
-
|
|
614
|
-
}
|
|
556
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
|
|
557
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
|
|
615
558
|
|
|
616
|
-
|
|
617
|
-
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterFallback( texture.minFilter ) );
|
|
559
|
+
if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
|
|
618
560
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.' );
|
|
622
|
-
|
|
623
|
-
}
|
|
561
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
|
|
624
562
|
|
|
625
563
|
}
|
|
626
564
|
|
|
565
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
|
|
566
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );
|
|
567
|
+
|
|
627
568
|
if ( texture.compareFunction ) {
|
|
628
569
|
|
|
629
570
|
_gl.texParameteri( textureType, _gl.TEXTURE_COMPARE_MODE, _gl.COMPARE_REF_TO_TEXTURE );
|
|
@@ -633,15 +574,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
633
574
|
|
|
634
575
|
if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) {
|
|
635
576
|
|
|
636
|
-
const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
|
|
637
|
-
|
|
638
577
|
if ( texture.magFilter === NearestFilter ) return;
|
|
639
578
|
if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return;
|
|
640
|
-
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension
|
|
641
|
-
if ( isWebGL2 === false && ( texture.type === HalfFloatType && extensions.has( 'OES_texture_half_float_linear' ) === false ) ) return; // verify extension for WebGL 1 only
|
|
579
|
+
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension
|
|
642
580
|
|
|
643
581
|
if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {
|
|
644
582
|
|
|
583
|
+
const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
|
|
645
584
|
_gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, capabilities.getMaxAnisotropy() ) );
|
|
646
585
|
properties.get( texture ).__currentAnisotropy = texture.anisotropy;
|
|
647
586
|
|
|
@@ -795,97 +734,41 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
795
734
|
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
796
735
|
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
|
|
797
736
|
|
|
798
|
-
|
|
799
|
-
let image = resizeImage( texture.image, needsPowerOfTwo, false, capabilities.maxTextureSize );
|
|
737
|
+
let image = resizeImage( texture.image, false, capabilities.maxTextureSize );
|
|
800
738
|
image = verifyColorSpace( texture, image );
|
|
801
739
|
|
|
802
|
-
const
|
|
803
|
-
glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
740
|
+
const glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
804
741
|
|
|
805
|
-
|
|
806
|
-
|
|
742
|
+
const glType = utils.convert( texture.type );
|
|
743
|
+
let glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
|
|
807
744
|
|
|
808
|
-
setTextureParameters( textureType, texture
|
|
745
|
+
setTextureParameters( textureType, texture );
|
|
809
746
|
|
|
810
747
|
let mipmap;
|
|
811
748
|
const mipmaps = texture.mipmaps;
|
|
812
749
|
|
|
813
|
-
const useTexStorage = (
|
|
750
|
+
const useTexStorage = ( texture.isVideoTexture !== true && glInternalFormat !== RGB_ETC1_Format );
|
|
814
751
|
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
815
752
|
const dataReady = source.dataReady;
|
|
816
|
-
const levels = getMipLevels( texture, image
|
|
753
|
+
const levels = getMipLevels( texture, image );
|
|
817
754
|
|
|
818
755
|
if ( texture.isDepthTexture ) {
|
|
819
756
|
|
|
820
757
|
// populate depth texture with dummy data
|
|
821
758
|
|
|
822
|
-
glInternalFormat = _gl.
|
|
823
|
-
|
|
824
|
-
if ( isWebGL2 ) {
|
|
825
|
-
|
|
826
|
-
if ( texture.type === FloatType ) {
|
|
827
|
-
|
|
828
|
-
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
829
|
-
|
|
830
|
-
} else if ( texture.type === UnsignedIntType ) {
|
|
831
|
-
|
|
832
|
-
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
833
|
-
|
|
834
|
-
} else if ( texture.type === UnsignedInt248Type ) {
|
|
759
|
+
glInternalFormat = _gl.DEPTH_COMPONENT16;
|
|
835
760
|
|
|
836
|
-
|
|
761
|
+
if ( texture.type === FloatType ) {
|
|
837
762
|
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
glInternalFormat = _gl.DEPTH_COMPONENT16; // WebGL2 requires sized internalformat for glTexImage2D
|
|
841
|
-
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
} else {
|
|
845
|
-
|
|
846
|
-
if ( texture.type === FloatType ) {
|
|
847
|
-
|
|
848
|
-
console.error( 'WebGLRenderer: Floating point depth texture requires WebGL2.' );
|
|
849
|
-
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
// validation checks for WebGL 1
|
|
855
|
-
|
|
856
|
-
if ( texture.format === DepthFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {
|
|
857
|
-
|
|
858
|
-
// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
|
|
859
|
-
// DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT
|
|
860
|
-
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
861
|
-
if ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) {
|
|
862
|
-
|
|
863
|
-
console.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' );
|
|
864
|
-
|
|
865
|
-
texture.type = UnsignedIntType;
|
|
866
|
-
glType = utils.convert( texture.type );
|
|
867
|
-
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
if ( texture.format === DepthStencilFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {
|
|
873
|
-
|
|
874
|
-
// Depth stencil textures need the DEPTH_STENCIL internal format
|
|
875
|
-
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
876
|
-
glInternalFormat = _gl.DEPTH_STENCIL;
|
|
763
|
+
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
877
764
|
|
|
878
|
-
|
|
879
|
-
// DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.
|
|
880
|
-
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
881
|
-
if ( texture.type !== UnsignedInt248Type ) {
|
|
765
|
+
} else if ( texture.type === UnsignedIntType ) {
|
|
882
766
|
|
|
883
|
-
|
|
767
|
+
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
884
768
|
|
|
885
|
-
|
|
886
|
-
glType = utils.convert( texture.type );
|
|
769
|
+
} else if ( texture.type === UnsignedInt248Type ) {
|
|
887
770
|
|
|
888
|
-
|
|
771
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
889
772
|
|
|
890
773
|
}
|
|
891
774
|
|
|
@@ -911,7 +794,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
911
794
|
// if there are no manual mipmaps
|
|
912
795
|
// set 0 level mipmap and then use GL to generate other mipmap levels
|
|
913
796
|
|
|
914
|
-
if ( mipmaps.length > 0
|
|
797
|
+
if ( mipmaps.length > 0 ) {
|
|
915
798
|
|
|
916
799
|
if ( useTexStorage && allocateMemory ) {
|
|
917
800
|
|
|
@@ -1158,11 +1041,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1158
1041
|
// if there are no manual mipmaps
|
|
1159
1042
|
// set 0 level mipmap and then use GL to generate other mipmap levels
|
|
1160
1043
|
|
|
1161
|
-
if ( mipmaps.length > 0
|
|
1044
|
+
if ( mipmaps.length > 0 ) {
|
|
1162
1045
|
|
|
1163
1046
|
if ( useTexStorage && allocateMemory ) {
|
|
1164
1047
|
|
|
1165
|
-
|
|
1048
|
+
const dimensions = getDimensions( mipmaps[ 0 ] );
|
|
1049
|
+
|
|
1050
|
+
state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, dimensions.width, dimensions.height );
|
|
1166
1051
|
|
|
1167
1052
|
}
|
|
1168
1053
|
|
|
@@ -1194,7 +1079,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1194
1079
|
|
|
1195
1080
|
if ( allocateMemory ) {
|
|
1196
1081
|
|
|
1197
|
-
|
|
1082
|
+
const dimensions = getDimensions( image );
|
|
1083
|
+
|
|
1084
|
+
state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, dimensions.width, dimensions.height );
|
|
1198
1085
|
|
|
1199
1086
|
}
|
|
1200
1087
|
|
|
@@ -1214,7 +1101,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1214
1101
|
|
|
1215
1102
|
}
|
|
1216
1103
|
|
|
1217
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
1104
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
1218
1105
|
|
|
1219
1106
|
generateMipmap( textureType );
|
|
1220
1107
|
|
|
@@ -1264,7 +1151,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1264
1151
|
|
|
1265
1152
|
if ( ! isCompressed && ! isDataTexture ) {
|
|
1266
1153
|
|
|
1267
|
-
cubeImage[ i ] = resizeImage( texture.image[ i ],
|
|
1154
|
+
cubeImage[ i ] = resizeImage( texture.image[ i ], true, capabilities.maxCubemapSize );
|
|
1268
1155
|
|
|
1269
1156
|
} else {
|
|
1270
1157
|
|
|
@@ -1277,17 +1164,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1277
1164
|
}
|
|
1278
1165
|
|
|
1279
1166
|
const image = cubeImage[ 0 ],
|
|
1280
|
-
supportsMips = isPowerOfTwo( image ) || isWebGL2,
|
|
1281
1167
|
glFormat = utils.convert( texture.format, texture.colorSpace ),
|
|
1282
1168
|
glType = utils.convert( texture.type ),
|
|
1283
1169
|
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
1284
1170
|
|
|
1285
|
-
const useTexStorage = (
|
|
1171
|
+
const useTexStorage = ( texture.isVideoTexture !== true );
|
|
1286
1172
|
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
1287
1173
|
const dataReady = source.dataReady;
|
|
1288
|
-
let levels = getMipLevels( texture, image
|
|
1174
|
+
let levels = getMipLevels( texture, image );
|
|
1289
1175
|
|
|
1290
|
-
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture
|
|
1176
|
+
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture );
|
|
1291
1177
|
|
|
1292
1178
|
let mipmaps;
|
|
1293
1179
|
|
|
@@ -1365,7 +1251,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1365
1251
|
|
|
1366
1252
|
if ( mipmaps.length > 0 ) levels ++;
|
|
1367
1253
|
|
|
1368
|
-
|
|
1254
|
+
const dimensions = getDimensions( cubeImage[ 0 ] );
|
|
1255
|
+
|
|
1256
|
+
state.texStorage2D( _gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, dimensions.width, dimensions.height );
|
|
1369
1257
|
|
|
1370
1258
|
}
|
|
1371
1259
|
|
|
@@ -1450,7 +1338,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1450
1338
|
|
|
1451
1339
|
}
|
|
1452
1340
|
|
|
1453
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
1341
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
1454
1342
|
|
|
1455
1343
|
// We assume images for cube map have the same size.
|
|
1456
1344
|
generateMipmap( _gl.TEXTURE_CUBE_MAP );
|
|
@@ -1592,7 +1480,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1592
1480
|
|
|
1593
1481
|
} else if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
|
|
1594
1482
|
|
|
1595
|
-
let glInternalFormat =
|
|
1483
|
+
let glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
1596
1484
|
|
|
1597
1485
|
if ( isMultisample || useMultisampledRTT( renderTarget ) ) {
|
|
1598
1486
|
|
|
@@ -1655,7 +1543,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1655
1543
|
|
|
1656
1544
|
} else {
|
|
1657
1545
|
|
|
1658
|
-
const textures = renderTarget.
|
|
1546
|
+
const textures = renderTarget.textures;
|
|
1659
1547
|
|
|
1660
1548
|
for ( let i = 0; i < textures.length; i ++ ) {
|
|
1661
1549
|
|
|
@@ -1867,7 +1755,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1867
1755
|
|
|
1868
1756
|
renderTarget.addEventListener( 'dispose', onRenderTargetDispose );
|
|
1869
1757
|
|
|
1870
|
-
|
|
1758
|
+
const textures = renderTarget.textures;
|
|
1759
|
+
|
|
1760
|
+
const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
|
|
1761
|
+
const isMultipleRenderTargets = ( textures.length > 1 );
|
|
1762
|
+
|
|
1763
|
+
if ( ! isMultipleRenderTargets ) {
|
|
1871
1764
|
|
|
1872
1765
|
if ( textureProperties.__webglTexture === undefined ) {
|
|
1873
1766
|
|
|
@@ -1880,10 +1773,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1880
1773
|
|
|
1881
1774
|
}
|
|
1882
1775
|
|
|
1883
|
-
const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
|
|
1884
|
-
const isMultipleRenderTargets = ( renderTarget.isWebGLMultipleRenderTargets === true );
|
|
1885
|
-
const supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
|
|
1886
|
-
|
|
1887
1776
|
// Setup framebuffer
|
|
1888
1777
|
|
|
1889
1778
|
if ( isCube ) {
|
|
@@ -1892,7 +1781,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1892
1781
|
|
|
1893
1782
|
for ( let i = 0; i < 6; i ++ ) {
|
|
1894
1783
|
|
|
1895
|
-
if (
|
|
1784
|
+
if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
1896
1785
|
|
|
1897
1786
|
renderTargetProperties.__webglFramebuffer[ i ] = [];
|
|
1898
1787
|
|
|
@@ -1912,7 +1801,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1912
1801
|
|
|
1913
1802
|
} else {
|
|
1914
1803
|
|
|
1915
|
-
if (
|
|
1804
|
+
if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
1916
1805
|
|
|
1917
1806
|
renderTargetProperties.__webglFramebuffer = [];
|
|
1918
1807
|
|
|
@@ -1930,35 +1819,23 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1930
1819
|
|
|
1931
1820
|
if ( isMultipleRenderTargets ) {
|
|
1932
1821
|
|
|
1933
|
-
|
|
1822
|
+
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
1934
1823
|
|
|
1935
|
-
const
|
|
1824
|
+
const attachmentProperties = properties.get( textures[ i ] );
|
|
1936
1825
|
|
|
1937
|
-
|
|
1826
|
+
if ( attachmentProperties.__webglTexture === undefined ) {
|
|
1938
1827
|
|
|
1939
|
-
|
|
1828
|
+
attachmentProperties.__webglTexture = _gl.createTexture();
|
|
1940
1829
|
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
attachmentProperties.__webglTexture = _gl.createTexture();
|
|
1944
|
-
|
|
1945
|
-
info.memory.textures ++;
|
|
1946
|
-
|
|
1947
|
-
}
|
|
1830
|
+
info.memory.textures ++;
|
|
1948
1831
|
|
|
1949
1832
|
}
|
|
1950
1833
|
|
|
1951
|
-
} else {
|
|
1952
|
-
|
|
1953
|
-
console.warn( 'THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.' );
|
|
1954
|
-
|
|
1955
1834
|
}
|
|
1956
1835
|
|
|
1957
1836
|
}
|
|
1958
1837
|
|
|
1959
|
-
if ( (
|
|
1960
|
-
|
|
1961
|
-
const textures = isMultipleRenderTargets ? texture : [ texture ];
|
|
1838
|
+
if ( ( renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
|
|
1962
1839
|
|
|
1963
1840
|
renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
|
|
1964
1841
|
renderTargetProperties.__webglColorRenderbuffer = [];
|
|
@@ -2002,11 +1879,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2002
1879
|
if ( isCube ) {
|
|
2003
1880
|
|
|
2004
1881
|
state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );
|
|
2005
|
-
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture
|
|
1882
|
+
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture );
|
|
2006
1883
|
|
|
2007
1884
|
for ( let i = 0; i < 6; i ++ ) {
|
|
2008
1885
|
|
|
2009
|
-
if (
|
|
1886
|
+
if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
2010
1887
|
|
|
2011
1888
|
for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
|
|
2012
1889
|
|
|
@@ -2022,7 +1899,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2022
1899
|
|
|
2023
1900
|
}
|
|
2024
1901
|
|
|
2025
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
1902
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
2026
1903
|
|
|
2027
1904
|
generateMipmap( _gl.TEXTURE_CUBE_MAP );
|
|
2028
1905
|
|
|
@@ -2032,18 +1909,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2032
1909
|
|
|
2033
1910
|
} else if ( isMultipleRenderTargets ) {
|
|
2034
1911
|
|
|
2035
|
-
const textures = renderTarget.texture;
|
|
2036
|
-
|
|
2037
1912
|
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
2038
1913
|
|
|
2039
1914
|
const attachment = textures[ i ];
|
|
2040
1915
|
const attachmentProperties = properties.get( attachment );
|
|
2041
1916
|
|
|
2042
1917
|
state.bindTexture( _gl.TEXTURE_2D, attachmentProperties.__webglTexture );
|
|
2043
|
-
setTextureParameters( _gl.TEXTURE_2D, attachment
|
|
1918
|
+
setTextureParameters( _gl.TEXTURE_2D, attachment );
|
|
2044
1919
|
setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, 0 );
|
|
2045
1920
|
|
|
2046
|
-
if ( textureNeedsGenerateMipmaps( attachment
|
|
1921
|
+
if ( textureNeedsGenerateMipmaps( attachment ) ) {
|
|
2047
1922
|
|
|
2048
1923
|
generateMipmap( _gl.TEXTURE_2D );
|
|
2049
1924
|
|
|
@@ -2059,15 +1934,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2059
1934
|
|
|
2060
1935
|
if ( renderTarget.isWebGL3DRenderTarget || renderTarget.isWebGLArrayRenderTarget ) {
|
|
2061
1936
|
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
|
|
2065
|
-
|
|
2066
|
-
} else {
|
|
2067
|
-
|
|
2068
|
-
console.error( 'THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.' );
|
|
2069
|
-
|
|
2070
|
-
}
|
|
1937
|
+
glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
|
|
2071
1938
|
|
|
2072
1939
|
}
|
|
2073
1940
|
|
|
@@ -2078,9 +1945,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2078
1945
|
}
|
|
2079
1946
|
|
|
2080
1947
|
state.bindTexture( glTextureType, textureProperties.__webglTexture );
|
|
2081
|
-
setTextureParameters( glTextureType, texture
|
|
1948
|
+
setTextureParameters( glTextureType, texture );
|
|
2082
1949
|
|
|
2083
|
-
if (
|
|
1950
|
+
if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
2084
1951
|
|
|
2085
1952
|
for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
|
|
2086
1953
|
|
|
@@ -2094,7 +1961,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2094
1961
|
|
|
2095
1962
|
}
|
|
2096
1963
|
|
|
2097
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
1964
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
2098
1965
|
|
|
2099
1966
|
generateMipmap( glTextureType );
|
|
2100
1967
|
|
|
@@ -2116,15 +1983,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2116
1983
|
|
|
2117
1984
|
function updateRenderTargetMipmap( renderTarget ) {
|
|
2118
1985
|
|
|
2119
|
-
const
|
|
2120
|
-
|
|
2121
|
-
const textures = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture : [ renderTarget.texture ];
|
|
1986
|
+
const textures = renderTarget.textures;
|
|
2122
1987
|
|
|
2123
1988
|
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
2124
1989
|
|
|
2125
1990
|
const texture = textures[ i ];
|
|
2126
1991
|
|
|
2127
|
-
if ( textureNeedsGenerateMipmaps( texture
|
|
1992
|
+
if ( textureNeedsGenerateMipmaps( texture ) ) {
|
|
2128
1993
|
|
|
2129
1994
|
const target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D;
|
|
2130
1995
|
const webglTexture = properties.get( texture ).__webglTexture;
|
|
@@ -2141,16 +2006,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2141
2006
|
|
|
2142
2007
|
function updateMultisampleRenderTarget( renderTarget ) {
|
|
2143
2008
|
|
|
2144
|
-
if ( (
|
|
2009
|
+
if ( ( renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
|
|
2145
2010
|
|
|
2146
|
-
const textures = renderTarget.
|
|
2011
|
+
const textures = renderTarget.textures;
|
|
2147
2012
|
const width = renderTarget.width;
|
|
2148
2013
|
const height = renderTarget.height;
|
|
2149
2014
|
let mask = _gl.COLOR_BUFFER_BIT;
|
|
2150
2015
|
const invalidationArray = [];
|
|
2151
2016
|
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
2152
2017
|
const renderTargetProperties = properties.get( renderTarget );
|
|
2153
|
-
const isMultipleRenderTargets = (
|
|
2018
|
+
const isMultipleRenderTargets = ( textures.length > 1 );
|
|
2154
2019
|
|
|
2155
2020
|
// If MRT we need to remove FBO attachments
|
|
2156
2021
|
if ( isMultipleRenderTargets ) {
|
|
@@ -2185,7 +2050,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2185
2050
|
if ( ignoreDepthValues === false ) {
|
|
2186
2051
|
|
|
2187
2052
|
if ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;
|
|
2188
|
-
|
|
2053
|
+
|
|
2054
|
+
// resolving stencil is slow with a D3D backend. disable it for all transmission render targets (see #27799)
|
|
2055
|
+
|
|
2056
|
+
if ( renderTarget.stencilBuffer && renderTargetProperties.__isTransmissionRenderTarget !== true ) mask |= _gl.STENCIL_BUFFER_BIT;
|
|
2189
2057
|
|
|
2190
2058
|
}
|
|
2191
2059
|
|
|
@@ -2256,7 +2124,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2256
2124
|
|
|
2257
2125
|
const renderTargetProperties = properties.get( renderTarget );
|
|
2258
2126
|
|
|
2259
|
-
return
|
|
2127
|
+
return renderTarget.samples > 0 && extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true && renderTargetProperties.__useRenderToTexture !== false;
|
|
2260
2128
|
|
|
2261
2129
|
}
|
|
2262
2130
|
|
|
@@ -2281,7 +2149,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2281
2149
|
const format = texture.format;
|
|
2282
2150
|
const type = texture.type;
|
|
2283
2151
|
|
|
2284
|
-
if ( texture.isCompressedTexture === true || texture.isVideoTexture === true
|
|
2152
|
+
if ( texture.isCompressedTexture === true || texture.isVideoTexture === true ) return image;
|
|
2285
2153
|
|
|
2286
2154
|
if ( colorSpace !== LinearSRGBColorSpace && colorSpace !== NoColorSpace ) {
|
|
2287
2155
|
|
|
@@ -2289,48 +2157,48 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2289
2157
|
|
|
2290
2158
|
if ( ColorManagement.getTransfer( colorSpace ) === SRGBTransfer ) {
|
|
2291
2159
|
|
|
2292
|
-
if
|
|
2160
|
+
// in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format
|
|
2293
2161
|
|
|
2294
|
-
|
|
2162
|
+
if ( format !== RGBAFormat || type !== UnsignedByteType ) {
|
|
2295
2163
|
|
|
2296
|
-
|
|
2164
|
+
console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
|
|
2297
2165
|
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
// it's not possible to generate mips in WebGL 1 with this extension
|
|
2166
|
+
}
|
|
2301
2167
|
|
|
2302
|
-
|
|
2303
|
-
texture.generateMipmaps = false;
|
|
2168
|
+
} else {
|
|
2304
2169
|
|
|
2305
|
-
|
|
2170
|
+
console.error( 'THREE.WebGLTextures: Unsupported texture color space:', colorSpace );
|
|
2306
2171
|
|
|
2307
|
-
|
|
2172
|
+
}
|
|
2308
2173
|
|
|
2309
|
-
|
|
2174
|
+
}
|
|
2310
2175
|
|
|
2311
|
-
|
|
2176
|
+
return image;
|
|
2312
2177
|
|
|
2313
|
-
|
|
2178
|
+
}
|
|
2314
2179
|
|
|
2315
|
-
|
|
2180
|
+
function getDimensions( image ) {
|
|
2316
2181
|
|
|
2317
|
-
|
|
2182
|
+
if ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) {
|
|
2318
2183
|
|
|
2319
|
-
|
|
2184
|
+
// if intrinsic data are not available, fallback to width/height
|
|
2320
2185
|
|
|
2321
|
-
|
|
2186
|
+
_imageDimensions.width = image.naturalWidth || image.width;
|
|
2187
|
+
_imageDimensions.height = image.naturalHeight || image.height;
|
|
2322
2188
|
|
|
2323
|
-
|
|
2189
|
+
} else if ( typeof VideoFrame !== 'undefined' && image instanceof VideoFrame ) {
|
|
2324
2190
|
|
|
2325
|
-
|
|
2191
|
+
_imageDimensions.width = image.displayWidth;
|
|
2192
|
+
_imageDimensions.height = image.displayHeight;
|
|
2326
2193
|
|
|
2327
|
-
|
|
2194
|
+
} else {
|
|
2328
2195
|
|
|
2329
|
-
|
|
2196
|
+
_imageDimensions.width = image.width;
|
|
2197
|
+
_imageDimensions.height = image.height;
|
|
2330
2198
|
|
|
2331
2199
|
}
|
|
2332
2200
|
|
|
2333
|
-
return
|
|
2201
|
+
return _imageDimensions;
|
|
2334
2202
|
|
|
2335
2203
|
}
|
|
2336
2204
|
|