|
@@ -7,7 +7,7 @@
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.THREE = {}));
|
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.THREE = {}));
|
|
-})(this, (function (exports) { 'use strict';
|
|
|
|
|
|
+}(this, (function (exports) { 'use strict';
|
|
|
|
|
|
const REVISION = '136dev';
|
|
const REVISION = '136dev';
|
|
const MOUSE = {
|
|
const MOUSE = {
|
|
@@ -9755,7 +9755,7 @@
|
|
|
|
|
|
var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif";
|
|
var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif";
|
|
|
|
|
|
- var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}";
|
|
|
|
|
|
+ var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}";
|
|
|
|
|
|
var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif";
|
|
var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif";
|
|
|
|
|
|
@@ -11214,12 +11214,8 @@
|
|
|
|
|
|
return 'lowp';
|
|
return 'lowp';
|
|
}
|
|
}
|
|
- /* eslint-disable no-undef */
|
|
|
|
-
|
|
|
|
|
|
|
|
const isWebGL2 = typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext || typeof WebGL2ComputeRenderingContext !== 'undefined' && gl instanceof WebGL2ComputeRenderingContext;
|
|
const isWebGL2 = typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext || typeof WebGL2ComputeRenderingContext !== 'undefined' && gl instanceof WebGL2ComputeRenderingContext;
|
|
- /* eslint-enable no-undef */
|
|
|
|
-
|
|
|
|
let precision = parameters.precision !== undefined ? parameters.precision : 'highp';
|
|
let precision = parameters.precision !== undefined ? parameters.precision : 'highp';
|
|
const maxPrecision = getMaxPrecision(precision);
|
|
const maxPrecision = getMaxPrecision(precision);
|
|
|
|
|
|
@@ -12806,7 +12802,6 @@
|
|
this.generateMipmaps = false;
|
|
this.generateMipmaps = false;
|
|
this.flipY = false;
|
|
this.flipY = false;
|
|
this.unpackAlignment = 1;
|
|
this.unpackAlignment = 1;
|
|
- this.needsUpdate = true;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -12868,7 +12863,8 @@
|
|
const texture = new DataTexture2DArray(buffer, width, height, numberOfMorphTargets);
|
|
const texture = new DataTexture2DArray(buffer, width, height, numberOfMorphTargets);
|
|
texture.format = RGBAFormat; // using RGBA since RGB might be emulated (and is thus slower)
|
|
texture.format = RGBAFormat; // using RGBA since RGB might be emulated (and is thus slower)
|
|
|
|
|
|
- texture.type = FloatType; // fill buffer
|
|
|
|
|
|
+ texture.type = FloatType;
|
|
|
|
+ texture.needsUpdate = true; // fill buffer
|
|
|
|
|
|
const vertexDataStride = numberOfVertexData * 4;
|
|
const vertexDataStride = numberOfVertexData * 4;
|
|
|
|
|
|
@@ -13068,7 +13064,6 @@
|
|
this.generateMipmaps = false;
|
|
this.generateMipmaps = false;
|
|
this.flipY = false;
|
|
this.flipY = false;
|
|
this.unpackAlignment = 1;
|
|
this.unpackAlignment = 1;
|
|
- this.needsUpdate = true;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -14210,7 +14205,7 @@
|
|
// GLSL 3.0 conversion for built-in materials and ShaderMaterial
|
|
// GLSL 3.0 conversion for built-in materials and ShaderMaterial
|
|
versionString = '#version 300 es\n';
|
|
versionString = '#version 300 es\n';
|
|
prefixVertex = ['precision mediump sampler2DArray;', '#define attribute in', '#define varying out', '#define texture2D texture'].join('\n') + '\n' + prefixVertex;
|
|
prefixVertex = ['precision mediump sampler2DArray;', '#define attribute in', '#define varying out', '#define texture2D texture'].join('\n') + '\n' + prefixVertex;
|
|
- prefixFragment = ['#define varying in', parameters.glslVersion === GLSL3 ? '' : 'out highp vec4 pc_fragColor;', parameters.glslVersion === GLSL3 ? '' : '#define gl_FragColor pc_fragColor', '#define gl_FragDepthEXT gl_FragDepth', '#define texture2D texture', '#define textureCube texture', '#define texture2DProj textureProj', '#define texture2DLodEXT textureLod', '#define texture2DProjLodEXT textureProjLod', '#define textureCubeLodEXT textureLod', '#define texture2DGradEXT textureGrad', '#define texture2DProjGradEXT textureProjGrad', '#define textureCubeGradEXT textureGrad'].join('\n') + '\n' + prefixFragment;
|
|
|
|
|
|
+ prefixFragment = ['#define varying in', parameters.glslVersion === GLSL3 ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;', parameters.glslVersion === GLSL3 ? '' : '#define gl_FragColor pc_fragColor', '#define gl_FragDepthEXT gl_FragDepth', '#define texture2D texture', '#define textureCube texture', '#define texture2DProj textureProj', '#define texture2DLodEXT textureLod', '#define texture2DProjLodEXT textureProjLod', '#define textureCubeLodEXT textureLod', '#define texture2DGradEXT textureGrad', '#define texture2DProjGradEXT textureProjGrad', '#define textureCubeGradEXT textureGrad'].join('\n') + '\n' + prefixFragment;
|
|
}
|
|
}
|
|
|
|
|
|
const vertexGlsl = versionString + prefixVertex + vertexShader;
|
|
const vertexGlsl = versionString + prefixVertex + vertexShader;
|
|
@@ -14336,7 +14331,7 @@
|
|
ShadowMaterial: 'shadow',
|
|
ShadowMaterial: 'shadow',
|
|
SpriteMaterial: 'sprite'
|
|
SpriteMaterial: 'sprite'
|
|
};
|
|
};
|
|
- const parameterNames = ['precision', 'isWebGL2', 'supportsVertexTextures', 'outputEncoding', 'instancing', 'instancingColor', 'map', 'mapEncoding', 'matcap', 'matcapEncoding', 'envMap', 'envMapMode', 'envMapEncoding', 'envMapCubeUV', 'lightMap', 'lightMapEncoding', 'aoMap', 'emissiveMap', 'emissiveMapEncoding', 'bumpMap', 'normalMap', 'objectSpaceNormalMap', 'tangentSpaceNormalMap', 'clearcoat', 'clearcoatMap', 'clearcoatRoughnessMap', 'clearcoatNormalMap', 'displacementMap', 'specularMap',, 'roughnessMap', 'metalnessMap', 'gradientMap', 'alphaMap', 'alphaTest', 'combine', 'vertexColors', 'vertexAlphas', 'vertexTangents', 'vertexUvs', 'uvsVertexOnly', 'fog', 'useFog', 'fogExp2', 'flatShading', 'sizeAttenuation', 'logarithmicDepthBuffer', 'skinning', 'maxBones', 'useVertexTexture', 'morphTargets', 'morphNormals', 'morphTargetsCount', 'premultipliedAlpha', 'numDirLights', 'numPointLights', 'numSpotLights', 'numHemiLights', 'numRectAreaLights', 'numDirLightShadows', 'numPointLightShadows', 'numSpotLightShadows', 'shadowMapEnabled', 'shadowMapType', 'toneMapping', 'physicallyCorrectLights', 'doubleSided', 'flipSided', 'numClippingPlanes', 'numClipIntersection', 'depthPacking', 'dithering', 'format', 'specularIntensityMap', 'specularColorMap', 'specularColorMapEncoding', 'transmission', 'transmissionMap', 'thicknessMap', 'sheen', 'sheenColorMap', 'sheenColorMapEncoding', 'sheenRoughnessMap'];
|
|
|
|
|
|
+ const parameterNames = ['precision', 'isWebGL2', 'supportsVertexTextures', 'outputEncoding', 'instancing', 'instancingColor', 'map', 'mapEncoding', 'matcap', 'matcapEncoding', 'envMap', 'envMapMode', 'envMapEncoding', 'envMapCubeUV', 'lightMap', 'lightMapEncoding', 'aoMap', 'emissiveMap', 'emissiveMapEncoding', 'bumpMap', 'normalMap', 'objectSpaceNormalMap', 'tangentSpaceNormalMap', 'clearcoat', 'clearcoatMap', 'clearcoatRoughnessMap', 'clearcoatNormalMap', 'displacementMap', 'specularMap', 'roughnessMap', 'metalnessMap', 'gradientMap', 'alphaMap', 'alphaTest', 'combine', 'vertexColors', 'vertexAlphas', 'vertexTangents', 'vertexUvs', 'uvsVertexOnly', 'fog', 'useFog', 'fogExp2', 'flatShading', 'sizeAttenuation', 'logarithmicDepthBuffer', 'skinning', 'maxBones', 'useVertexTexture', 'morphTargets', 'morphNormals', 'morphTargetsCount', 'premultipliedAlpha', 'numDirLights', 'numPointLights', 'numSpotLights', 'numHemiLights', 'numRectAreaLights', 'numDirLightShadows', 'numPointLightShadows', 'numSpotLightShadows', 'shadowMapEnabled', 'shadowMapType', 'toneMapping', 'physicallyCorrectLights', 'doubleSided', 'flipSided', 'numClippingPlanes', 'numClipIntersection', 'depthPacking', 'dithering', 'format', 'specularIntensityMap', 'specularColorMap', 'specularColorMapEncoding', 'transmission', 'transmissionMap', 'thicknessMap', 'sheen', 'sheenColorMap', 'sheenColorMapEncoding', 'sheenRoughnessMap'];
|
|
|
|
|
|
function getMaxBones(object) {
|
|
function getMaxBones(object) {
|
|
const skeleton = object.skeleton;
|
|
const skeleton = object.skeleton;
|
|
@@ -14470,7 +14465,7 @@
|
|
vertexTangents: !!material.normalMap && !!object.geometry && !!object.geometry.attributes.tangent,
|
|
vertexTangents: !!material.normalMap && !!object.geometry && !!object.geometry.attributes.tangent,
|
|
vertexColors: material.vertexColors,
|
|
vertexColors: material.vertexColors,
|
|
vertexAlphas: material.vertexColors === true && !!object.geometry && !!object.geometry.attributes.color && object.geometry.attributes.color.itemSize === 4,
|
|
vertexAlphas: material.vertexColors === true && !!object.geometry && !!object.geometry.attributes.color && object.geometry.attributes.color.itemSize === 4,
|
|
- vertexUvs: !!material.map || !!material.bumpMap || !!material.normalMap || !!material.specularMap || !!material.alphaMap || !!material.emissiveMap || !!material.roughnessMap || !!material.metalnessMap || !!material.clearcoatMap || !!material.clearcoatRoughnessMap || !!material.clearcoatNormalMap || !!material.displacementMap || !!material.transmissionMap || !!material.thicknessMap || !!material.specularIntensityMap || !!material.specularColorMap || !!material.sheenColorMap || material.sheenRoughnessMap,
|
|
|
|
|
|
+ vertexUvs: !!material.map || !!material.bumpMap || !!material.normalMap || !!material.specularMap || !!material.alphaMap || !!material.emissiveMap || !!material.roughnessMap || !!material.metalnessMap || !!material.clearcoatMap || !!material.clearcoatRoughnessMap || !!material.clearcoatNormalMap || !!material.displacementMap || !!material.transmissionMap || !!material.thicknessMap || !!material.specularIntensityMap || !!material.specularColorMap || !!material.sheenColorMap || !!material.sheenRoughnessMap,
|
|
uvsVertexOnly: !(!!material.map || !!material.bumpMap || !!material.normalMap || !!material.specularMap || !!material.alphaMap || !!material.emissiveMap || !!material.roughnessMap || !!material.metalnessMap || !!material.clearcoatNormalMap || material.transmission > 0 || !!material.transmissionMap || !!material.thicknessMap || !!material.specularIntensityMap || !!material.specularColorMap || material.sheen > 0 || !!material.sheenColorMap || !!material.sheenRoughnessMap) && !!material.displacementMap,
|
|
uvsVertexOnly: !(!!material.map || !!material.bumpMap || !!material.normalMap || !!material.specularMap || !!material.alphaMap || !!material.emissiveMap || !!material.roughnessMap || !!material.metalnessMap || !!material.clearcoatNormalMap || material.transmission > 0 || !!material.transmissionMap || !!material.thicknessMap || !!material.specularIntensityMap || !!material.specularColorMap || material.sheen > 0 || !!material.sheenColorMap || !!material.sheenRoughnessMap) && !!material.displacementMap,
|
|
fog: !!fog,
|
|
fog: !!fog,
|
|
useFog: material.fog,
|
|
useFog: material.fog,
|
|
@@ -16235,6 +16230,22 @@
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function texSubImage3D() {
|
|
|
|
+ try {
|
|
|
|
+ gl.texSubImage3D.apply(gl, arguments);
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('THREE.WebGLState:', error);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function compressedTexSubImage2D() {
|
|
|
|
+ try {
|
|
|
|
+ gl.compressedTexSubImage2D.apply(gl, arguments);
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('THREE.WebGLState:', error);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
function texStorage2D() {
|
|
function texStorage2D() {
|
|
try {
|
|
try {
|
|
gl.texStorage2D.apply(gl, arguments);
|
|
gl.texStorage2D.apply(gl, arguments);
|
|
@@ -16243,6 +16254,14 @@
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function texStorage3D() {
|
|
|
|
+ try {
|
|
|
|
+ gl.texStorage3D.apply(gl, arguments);
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('THREE.WebGLState:', error);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
function texImage2D() {
|
|
function texImage2D() {
|
|
try {
|
|
try {
|
|
gl.texImage2D.apply(gl, arguments);
|
|
gl.texImage2D.apply(gl, arguments);
|
|
@@ -16362,7 +16381,10 @@
|
|
texImage2D: texImage2D,
|
|
texImage2D: texImage2D,
|
|
texImage3D: texImage3D,
|
|
texImage3D: texImage3D,
|
|
texStorage2D: texStorage2D,
|
|
texStorage2D: texStorage2D,
|
|
|
|
+ texStorage3D: texStorage3D,
|
|
texSubImage2D: texSubImage2D,
|
|
texSubImage2D: texSubImage2D,
|
|
|
|
+ texSubImage3D: texSubImage3D,
|
|
|
|
+ compressedTexSubImage2D: compressedTexSubImage2D,
|
|
scissor: scissor,
|
|
scissor: scissor,
|
|
viewport: viewport,
|
|
viewport: viewport,
|
|
reset: reset
|
|
reset: reset
|
|
@@ -16491,9 +16513,11 @@
|
|
if (textureNeedsGenerateMipmaps(texture, supportsMips) === true) {
|
|
if (textureNeedsGenerateMipmaps(texture, supportsMips) === true) {
|
|
// generated mipmaps via gl.generateMipmap()
|
|
// generated mipmaps via gl.generateMipmap()
|
|
return Math.log2(Math.max(image.width, image.height)) + 1;
|
|
return Math.log2(Math.max(image.width, image.height)) + 1;
|
|
- } else if (texture.mipmaps.length > 0) {
|
|
|
|
|
|
+ } else if (texture.mipmaps !== undefined && texture.mipmaps.length > 0) {
|
|
// user-defined mipmaps
|
|
// user-defined mipmaps
|
|
return texture.mipmaps.length;
|
|
return texture.mipmaps.length;
|
|
|
|
+ } else if (texture.isCompressedTexture && Array.isArray(texture.image)) {
|
|
|
|
+ return image.mipmaps.length;
|
|
} else {
|
|
} else {
|
|
// texture without mipmaps (only base level)
|
|
// texture without mipmaps (only base level)
|
|
return 1;
|
|
return 1;
|
|
@@ -16762,6 +16786,7 @@
|
|
const mipmaps = texture.mipmaps;
|
|
const mipmaps = texture.mipmaps;
|
|
const useTexStorage = isWebGL2 && texture.isVideoTexture !== true;
|
|
const useTexStorage = isWebGL2 && texture.isVideoTexture !== true;
|
|
const allocateMemory = textureProperties.__version === undefined;
|
|
const allocateMemory = textureProperties.__version === undefined;
|
|
|
|
+ const levels = getMipLevels(texture, image, supportsMips);
|
|
|
|
|
|
if (texture.isDepthTexture) {
|
|
if (texture.isDepthTexture) {
|
|
// populate depth texture with dummy data
|
|
// populate depth texture with dummy data
|
|
@@ -16820,40 +16845,83 @@
|
|
// if there are no manual mipmaps
|
|
// if there are no manual mipmaps
|
|
// set 0 level mipmap and then use GL to generate other mipmap levels
|
|
// set 0 level mipmap and then use GL to generate other mipmap levels
|
|
if (mipmaps.length > 0 && supportsMips) {
|
|
if (mipmaps.length > 0 && supportsMips) {
|
|
|
|
+ if (useTexStorage && allocateMemory) {
|
|
|
|
+ state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);
|
|
|
|
+ }
|
|
|
|
+
|
|
for (let i = 0, il = mipmaps.length; i < il; i++) {
|
|
for (let i = 0, il = mipmaps.length; i < il; i++) {
|
|
mipmap = mipmaps[i];
|
|
mipmap = mipmaps[i];
|
|
- state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
|
|
|
|
|
|
+
|
|
|
|
+ if (useTexStorage) {
|
|
|
|
+ state.texSubImage2D(_gl.TEXTURE_2D, 0, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data);
|
|
|
|
+ } else {
|
|
|
|
+ state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
texture.generateMipmaps = false;
|
|
texture.generateMipmaps = false;
|
|
} else {
|
|
} else {
|
|
- state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data);
|
|
|
|
|
|
+ if (useTexStorage) {
|
|
|
|
+ if (allocateMemory) {
|
|
|
|
+ state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ state.texSubImage2D(_gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, glFormat, glType, image.data);
|
|
|
|
+ } else {
|
|
|
|
+ state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else if (texture.isCompressedTexture) {
|
|
} else if (texture.isCompressedTexture) {
|
|
|
|
+ if (useTexStorage && allocateMemory) {
|
|
|
|
+ state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);
|
|
|
|
+ }
|
|
|
|
+
|
|
for (let i = 0, il = mipmaps.length; i < il; i++) {
|
|
for (let i = 0, il = mipmaps.length; i < il; i++) {
|
|
mipmap = mipmaps[i];
|
|
mipmap = mipmaps[i];
|
|
|
|
|
|
if (texture.format !== RGBAFormat && texture.format !== RGBFormat) {
|
|
if (texture.format !== RGBAFormat && texture.format !== RGBFormat) {
|
|
if (glFormat !== null) {
|
|
if (glFormat !== null) {
|
|
- state.compressedTexImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
|
|
|
|
|
|
+ if (useTexStorage) {
|
|
|
|
+ state.compressedTexSubImage2D(_gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data);
|
|
|
|
+ } else {
|
|
|
|
+ state.compressedTexImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()');
|
|
console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()');
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
|
|
|
|
|
|
+ if (useTexStorage) {
|
|
|
|
+ state.texSubImage2D(_gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data);
|
|
|
|
+ } else {
|
|
|
|
+ state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (texture.isDataTexture2DArray) {
|
|
} else if (texture.isDataTexture2DArray) {
|
|
- state.texImage3D(_gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
|
|
|
|
|
|
+ if (useTexStorage) {
|
|
|
|
+ if (allocateMemory) {
|
|
|
|
+ state.texStorage3D(_gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, image.width, image.height, image.depth);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ state.texSubImage3D(_gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data);
|
|
|
|
+ } else {
|
|
|
|
+ state.texImage3D(_gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
|
|
|
|
+ }
|
|
} else if (texture.isDataTexture3D) {
|
|
} else if (texture.isDataTexture3D) {
|
|
- state.texImage3D(_gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
|
|
|
|
|
|
+ if (useTexStorage) {
|
|
|
|
+ if (allocateMemory) {
|
|
|
|
+ state.texStorage3D(_gl.TEXTURE_3D, levels, glInternalFormat, image.width, image.height, image.depth);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ state.texSubImage3D(_gl.TEXTURE_3D, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data);
|
|
|
|
+ } else {
|
|
|
|
+ state.texImage3D(_gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
|
|
|
|
+ }
|
|
} else if (texture.isFramebufferTexture) ; else {
|
|
} else if (texture.isFramebufferTexture) ; else {
|
|
// regular Texture (image, video, canvas)
|
|
// regular Texture (image, video, canvas)
|
|
// use manually created mipmaps if available
|
|
// use manually created mipmaps if available
|
|
// if there are no manual mipmaps
|
|
// if there are no manual mipmaps
|
|
// set 0 level mipmap and then use GL to generate other mipmap levels
|
|
// set 0 level mipmap and then use GL to generate other mipmap levels
|
|
- const levels = getMipLevels(texture, image, supportsMips);
|
|
|
|
-
|
|
|
|
if (mipmaps.length > 0 && supportsMips) {
|
|
if (mipmaps.length > 0 && supportsMips) {
|
|
if (useTexStorage && allocateMemory) {
|
|
if (useTexStorage && allocateMemory) {
|
|
state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);
|
|
state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);
|
|
@@ -16922,10 +16990,17 @@
|
|
glFormat = utils.convert(texture.format),
|
|
glFormat = utils.convert(texture.format),
|
|
glType = utils.convert(texture.type),
|
|
glType = utils.convert(texture.type),
|
|
glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
|
|
glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
|
|
|
|
+ const useTexStorage = isWebGL2 && texture.isVideoTexture !== true;
|
|
|
|
+ const allocateMemory = textureProperties.__version === undefined;
|
|
|
|
+ let levels = getMipLevels(texture, image, supportsMips);
|
|
setTextureParameters(_gl.TEXTURE_CUBE_MAP, texture, supportsMips);
|
|
setTextureParameters(_gl.TEXTURE_CUBE_MAP, texture, supportsMips);
|
|
let mipmaps;
|
|
let mipmaps;
|
|
|
|
|
|
if (isCompressed) {
|
|
if (isCompressed) {
|
|
|
|
+ if (useTexStorage && allocateMemory) {
|
|
|
|
+ state.texStorage2D(_gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, image.width, image.height);
|
|
|
|
+ }
|
|
|
|
+
|
|
for (let i = 0; i < 6; i++) {
|
|
for (let i = 0; i < 6; i++) {
|
|
mipmaps = cubeImage[i].mipmaps;
|
|
mipmaps = cubeImage[i].mipmaps;
|
|
|
|
|
|
@@ -16934,33 +17009,67 @@
|
|
|
|
|
|
if (texture.format !== RGBAFormat && texture.format !== RGBFormat) {
|
|
if (texture.format !== RGBAFormat && texture.format !== RGBFormat) {
|
|
if (glFormat !== null) {
|
|
if (glFormat !== null) {
|
|
- state.compressedTexImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
|
|
|
|
|
|
+ if (useTexStorage) {
|
|
|
|
+ state.compressedTexSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data);
|
|
|
|
+ } else {
|
|
|
|
+ state.compressedTexImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()');
|
|
console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()');
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
|
|
|
|
|
|
+ if (useTexStorage) {
|
|
|
|
+ state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data);
|
|
|
|
+ } else {
|
|
|
|
+ state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
mipmaps = texture.mipmaps;
|
|
mipmaps = texture.mipmaps;
|
|
|
|
|
|
|
|
+ if (useTexStorage && allocateMemory) {
|
|
|
|
+ // TODO: Uniformly handle mipmap definitions
|
|
|
|
+ // Normal textures and compressed cube textures define base level + mips with their mipmap array
|
|
|
|
+ // Uncompressed cube textures use their mipmap array only for mips (no base level)
|
|
|
|
+ if (mipmaps.length > 0) levels++;
|
|
|
|
+ state.texStorage2D(_gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, cubeImage[0].width, cubeImage[0].height);
|
|
|
|
+ }
|
|
|
|
+
|
|
for (let i = 0; i < 6; i++) {
|
|
for (let i = 0; i < 6; i++) {
|
|
if (isDataTexture) {
|
|
if (isDataTexture) {
|
|
- state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, cubeImage[i].width, cubeImage[i].height, 0, glFormat, glType, cubeImage[i].data);
|
|
|
|
|
|
+ if (useTexStorage) {
|
|
|
|
+ state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, cubeImage[i].width, cubeImage[i].height, glFormat, glType, cubeImage[i].data);
|
|
|
|
+ } else {
|
|
|
|
+ state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, cubeImage[i].width, cubeImage[i].height, 0, glFormat, glType, cubeImage[i].data);
|
|
|
|
+ }
|
|
|
|
|
|
for (let j = 0; j < mipmaps.length; j++) {
|
|
for (let j = 0; j < mipmaps.length; j++) {
|
|
const mipmap = mipmaps[j];
|
|
const mipmap = mipmaps[j];
|
|
const mipmapImage = mipmap.image[i].image;
|
|
const mipmapImage = mipmap.image[i].image;
|
|
- state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data);
|
|
|
|
|
|
+
|
|
|
|
+ if (useTexStorage) {
|
|
|
|
+ state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, mipmapImage.width, mipmapImage.height, glFormat, glType, mipmapImage.data);
|
|
|
|
+ } else {
|
|
|
|
+ state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[i]);
|
|
|
|
|
|
+ if (useTexStorage) {
|
|
|
|
+ state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, glFormat, glType, cubeImage[i]);
|
|
|
|
+ } else {
|
|
|
|
+ state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[i]);
|
|
|
|
+ }
|
|
|
|
|
|
for (let j = 0; j < mipmaps.length; j++) {
|
|
for (let j = 0; j < mipmaps.length; j++) {
|
|
const mipmap = mipmaps[j];
|
|
const mipmap = mipmaps[j];
|
|
- state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[i]);
|
|
|
|
|
|
+
|
|
|
|
+ if (useTexStorage) {
|
|
|
|
+ state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, glFormat, glType, mipmap.image[i]);
|
|
|
|
+ } else {
|
|
|
|
+ state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[i]);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -20299,8 +20408,7 @@
|
|
if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
|
|
if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
|
|
__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', {
|
|
__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', {
|
|
detail: this
|
|
detail: this
|
|
- })); // eslint-disable-line no-undef
|
|
|
|
-
|
|
|
|
|
|
+ }));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -20371,8 +20479,7 @@
|
|
if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
|
|
if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
|
|
__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', {
|
|
__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', {
|
|
detail: this
|
|
detail: this
|
|
- })); // eslint-disable-line no-undef
|
|
|
|
-
|
|
|
|
|
|
+ }));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -21137,7 +21244,6 @@
|
|
this.generateMipmaps = false;
|
|
this.generateMipmaps = false;
|
|
this.flipY = false;
|
|
this.flipY = false;
|
|
this.unpackAlignment = 1;
|
|
this.unpackAlignment = 1;
|
|
- this.needsUpdate = true;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -21261,6 +21367,7 @@
|
|
boneMatrices.set(this.boneMatrices); // copy current values
|
|
boneMatrices.set(this.boneMatrices); // copy current values
|
|
|
|
|
|
const boneTexture = new DataTexture(boneMatrices, size, size, RGBAFormat, FloatType);
|
|
const boneTexture = new DataTexture(boneMatrices, size, size, RGBAFormat, FloatType);
|
|
|
|
+ boneTexture.needsUpdate = true;
|
|
this.boneMatrices = boneMatrices;
|
|
this.boneMatrices = boneMatrices;
|
|
this.boneTexture = boneTexture;
|
|
this.boneTexture = boneTexture;
|
|
this.boneTextureSize = size;
|
|
this.boneTextureSize = size;
|
|
@@ -24358,9 +24465,7 @@
|
|
|
|
|
|
|
|
|
|
function isValidDiagonal(a, b) {
|
|
function isValidDiagonal(a, b) {
|
|
- return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && ( // dones't intersect other edges
|
|
|
|
- locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && ( // locally visible
|
|
|
|
- area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
|
|
|
|
|
|
+ return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
|
|
equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
|
|
equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
|
|
} // signed area of a triangle
|
|
} // signed area of a triangle
|
|
|
|
|
|
@@ -36021,14 +36126,11 @@
|
|
}
|
|
}
|
|
|
|
|
|
if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
|
|
if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
|
|
- /* eslint-disable no-undef */
|
|
|
|
__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('register', {
|
|
__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('register', {
|
|
detail: {
|
|
detail: {
|
|
revision: REVISION
|
|
revision: REVISION
|
|
}
|
|
}
|
|
}));
|
|
}));
|
|
- /* eslint-enable no-undef */
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
if (typeof window !== 'undefined') {
|
|
if (typeof window !== 'undefined') {
|
|
@@ -36500,4 +36602,4 @@
|
|
|
|
|
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
|
|
|
-}));
|
|
|
|
|
|
+})));
|