Selaa lähdekoodia

Updated builds.

Mr.doob 5 vuotta sitten
vanhempi
commit
7ff2535d75
3 muutettua tiedostoa jossa 35 lisäystä ja 39 poistoa
  1. 5 7
      build/three.js
  2. 25 25
      build/three.min.js
  3. 5 7
      build/three.module.js

+ 5 - 7
build/three.js

@@ -15423,11 +15423,11 @@
 					};
 
 					// enable code injection for non-built-in material
-					Object.defineProperty( boxMesh.material, 'map', {
+					Object.defineProperty( boxMesh.material, 'envMap', {
 
 						get: function () {
 
-							return this.envMap.value;
+							return this.uniforms.envMap.value;
 
 						}
 
@@ -15438,7 +15438,9 @@
 				}
 
 				var texture = background.isWebGLRenderTargetCube ? background.texture : background;
-				boxMesh.material.envMap = texture;
+
+				boxMesh.material.uniforms.envMap.value = texture;
+				boxMesh.material.uniforms.flipEnvMap.value = texture.isCubeTexture ? - 1 : 1;
 
 				if ( currentBackground !== background ||
 				     currentBackgroundVersion !== texture.version ) {
@@ -25087,10 +25089,6 @@
 					m_uniforms.color.value.copy( material.color );
 					m_uniforms.opacity.value = material.opacity;
 
-				} else if ( material.envMap ) {
-
-					refreshUniformsCommon( m_uniforms, material );
-
 				}
 
 				// RectAreaLight Texture

+ 25 - 25
build/three.min.js

@@ -30,29 +30,29 @@ d instanceof Int16Array?c=5122:d instanceof Uint32Array?c=5125:d instanceof Int3
 b,c,d){C.call(this);this.type="PlaneBufferGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};a=a||1;b=b||1;var e=a/2,f=b/2;c=Math.floor(c)||1;d=Math.floor(d)||1;var g=c+1,h=d+1,l=a/c,m=b/d,p=[],r=[],t=[],k=[];for(a=0;a<h;a++){var q=a*m-f;for(b=0;b<g;b++)r.push(b*l-e,-q,0),t.push(0,0,1),k.push(b/c),k.push(1-a/d)}for(a=0;a<d;a++)for(b=0;b<c;b++)e=b+g*(a+1),f=b+1+g*(a+1),h=b+1+g*a,p.push(b+g*a,e,h),p.push(e,f,h);this.setIndex(p);this.setAttribute("position",new D(r,3));this.setAttribute("normal",
 new D(t,3));this.setAttribute("uv",new D(k,2))}function bj(a,b,c,d){function e(a,c){b.buffers.color.setClear(a.r,a.g,a.b,c,d)}var f=new A(0),g=0,h,l,m=null,p=0;return{getClearColor:function(){return f},setClearColor:function(a,b){f.set(a);g=void 0!==b?b:1;e(f,g)},getClearAlpha:function(){return g},setClearAlpha:function(a){g=a;e(f,g)},render:function(b,d,k,q){d=d.background;k=a.xr;(k=k.getSession&&k.getSession())&&"additive"===k.environmentBlendMode&&(d=null);null===d?(e(f,g),m=null,p=0):d&&d.isColor&&
 (e(d,1),q=!0,m=null,p=0);(a.autoClear||q)&&a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil);if(d&&(d.isCubeTexture||d.isWebGLRenderTargetCube||306===d.mapping)){void 0===l&&(l=new V(new Gd(1,1,1),new za({type:"BackgroundCubeMaterial",uniforms:Yb(db.cube.uniforms),vertexShader:db.cube.vertexShader,fragmentShader:db.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(a,b,c){this.matrixWorld.copyPosition(c.matrixWorld)},
-Object.defineProperty(l.material,"map",{get:function(){return this.envMap.value}}),c.update(l));q=d.isWebGLRenderTargetCube?d.texture:d;l.material.envMap=q;if(m!==d||p!==q.version)l.material.needsUpdate=!0,m=d,p=q.version;b.unshift(l,l.geometry,l.material,0,0,null)}else if(d&&d.isTexture){void 0===h&&(h=new V(new $b(2,2),new za({type:"BackgroundMaterial",uniforms:Yb(db.background.uniforms),vertexShader:db.background.vertexShader,fragmentShader:db.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,
-fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),c.update(h));h.material.uniforms.t2D.value=d;!0===d.matrixAutoUpdate&&d.updateMatrix();h.material.uniforms.uvTransform.value.copy(d.matrix);if(m!==d||p!==d.version)h.material.needsUpdate=!0,m=d,p=d.version;b.unshift(h,h.geometry,h.material,0,0,null)}}}}function cj(a,b,c,d){var e=d.isWebGL2,f;this.setMode=function(a){f=a};this.render=function(b,d){a.drawArrays(f,b,
-d);c.update(d,f)};this.renderInstances=function(d,h,l,m){if(0!==m){if(e){d=a;var g="drawArraysInstanced"}else if(d=b.get("ANGLE_instanced_arrays"),g="drawArraysInstancedANGLE",null===d){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[g](f,h,l,m);c.update(l,f,m)}}}function dj(a,b,c){function d(b){if("highp"===b){if(0<a.getShaderPrecisionFormat(35633,36338).precision&&0<a.getShaderPrecisionFormat(35632,
-36338).precision)return"highp";b="mediump"}return"mediump"===b&&0<a.getShaderPrecisionFormat(35633,36337).precision&&0<a.getShaderPrecisionFormat(35632,36337).precision?"mediump":"lowp"}var e,f="undefined"!==typeof WebGL2RenderingContext&&a instanceof WebGL2RenderingContext||"undefined"!==typeof WebGL2ComputeRenderingContext&&a instanceof WebGL2ComputeRenderingContext,g=void 0!==c.precision?c.precision:"highp",h=d(g);h!==g&&(console.warn("THREE.WebGLRenderer:",g,"not supported, using",h,"instead."),
-g=h);c=!0===c.logarithmicDepthBuffer;h=a.getParameter(34930);var l=a.getParameter(35660),m=a.getParameter(3379),p=a.getParameter(34076),r=a.getParameter(34921),k=a.getParameter(36347),u=a.getParameter(36348),q=a.getParameter(36349),v=0<l,n=f||!!b.get("OES_texture_float"),w=v&&n,x=f?a.getParameter(36183):0;return{isWebGL2:f,getMaxAnisotropy:function(){if(void 0!==e)return e;var c=b.get("EXT_texture_filter_anisotropic");return e=null!==c?a.getParameter(c.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:d,
-precision:g,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:l,maxTextureSize:m,maxCubemapSize:p,maxAttributes:r,maxVertexUniforms:k,maxVaryings:u,maxFragmentUniforms:q,vertexTextures:v,floatFragmentTextures:n,floatVertexTextures:w,maxSamples:x}}function ej(){function a(){m.value!==d&&(m.value=d,m.needsUpdate=0<e);c.numPlanes=e;c.numIntersection=0}function b(a,b,d,e){var f=null!==a?a.length:0,g=null;if(0!==f){g=m.value;if(!0!==e||null===g){e=d+4*f;b=b.matrixWorldInverse;l.getNormalMatrix(b);
-if(null===g||g.length<e)g=new Float32Array(e);for(e=0;e!==f;++e,d+=4)h.copy(a[e]).applyMatrix4(b,l),h.normal.toArray(g,d),g[d+3]=h.constant}m.value=g;m.needsUpdate=!0}c.numPlanes=f;return g}var c=this,d=null,e=0,f=!1,g=!1,h=new Ta,l=new ca,m={value:null,needsUpdate:!1};this.uniform=m;this.numIntersection=this.numPlanes=0;this.init=function(a,c,g){var h=0!==a.length||c||0!==e||f;f=c;d=b(a,g,0);e=a.length;return h};this.beginShadows=function(){g=!0;b(null)};this.endShadows=function(){g=!1;a()};this.setState=
-function(c,h,l,k,q,v){if(!f||null===c||0===c.length||g&&!l)g?b(null):a();else{l=g?0:e;var p=4*l,r=q.clippingState||null;m.value=r;r=b(c,k,p,v);for(c=0;c!==p;++c)r[c]=d[c];q.clippingState=r;this.numIntersection=h?this.numPlanes:0;this.numPlanes+=l}}}function fj(a){var b={};return{get:function(c){if(void 0!==b[c])return b[c];switch(c){case "WEBGL_depth_texture":var d=a.getExtension("WEBGL_depth_texture")||a.getExtension("MOZ_WEBGL_depth_texture")||a.getExtension("WEBKIT_WEBGL_depth_texture");break;
-case "EXT_texture_filter_anisotropic":d=a.getExtension("EXT_texture_filter_anisotropic")||a.getExtension("MOZ_EXT_texture_filter_anisotropic")||a.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case "WEBGL_compressed_texture_s3tc":d=a.getExtension("WEBGL_compressed_texture_s3tc")||a.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case "WEBGL_compressed_texture_pvrtc":d=a.getExtension("WEBGL_compressed_texture_pvrtc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");
-break;default:d=a.getExtension(c)}null===d&&console.warn("THREE.WebGLRenderer: "+c+" extension not supported.");return b[c]=d}}}function gj(a,b,c){function d(a){var e=a.target;a=f.get(e);null!==a.index&&b.remove(a.index);for(var h in a.attributes)b.remove(a.attributes[h]);e.removeEventListener("dispose",d);f.delete(e);if(h=g.get(a))b.remove(h),g.delete(a);c.memory.geometries--}function e(a){var c=[],d=a.index,e=a.attributes.position;if(null!==d){var f=d.array;d=d.version;e=0;for(var h=f.length;e<
-h;e+=3){var k=f[e+0],q=f[e+1],v=f[e+2];c.push(k,q,q,v,v,k)}}else for(f=e.array,d=e.version,e=0,h=f.length/3-1;e<h;e+=3)k=e+0,q=e+1,v=e+2,c.push(k,q,q,v,v,k);c=new (65535<qh(c)?Ub:Tb)(c,1);c.version=d;b.update(c,34963);(f=g.get(a))&&b.remove(f);g.set(a,c)}var f=new WeakMap,g=new WeakMap;return{get:function(a,b){var e=f.get(b);if(e)return e;b.addEventListener("dispose",d);b.isBufferGeometry?e=b:b.isGeometry&&(void 0===b._bufferGeometry&&(b._bufferGeometry=(new C).setFromObject(a)),e=b._bufferGeometry);
-f.set(b,e);c.memory.geometries++;return e},update:function(a){var c=a.index,d=a.attributes;null!==c&&b.update(c,34963);for(var e in d)b.update(d[e],34962);a=a.morphAttributes;for(e in a){c=a[e];d=0;for(var f=c.length;d<f;d++)b.update(c[d],34962)}},getWireframeAttribute:function(a){var b=g.get(a);if(b){var c=a.index;null!==c&&b.version<c.version&&e(a)}else e(a);return g.get(a)}}}function hj(a,b,c,d){var e=d.isWebGL2,f,g,h;this.setMode=function(a){f=a};this.setIndex=function(a){g=a.type;h=a.bytesPerElement};
-this.render=function(b,d){a.drawElements(f,d,g,b*h);c.update(d,f)};this.renderInstances=function(d,m,p,r){if(0!==r){if(e){d=a;var l="drawElementsInstanced"}else if(d=b.get("ANGLE_instanced_arrays"),l="drawElementsInstancedANGLE",null===d){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[l](f,p,g,m*h,r);c.update(p,f,r)}}}function ij(a){var b={frame:0,calls:0,triangles:0,points:0,lines:0};
-return{memory:{geometries:0,textures:0},render:b,programs:null,autoReset:!0,reset:function(){b.frame++;b.calls=0;b.triangles=0;b.points=0;b.lines=0},update:function(a,d,e){e=e||1;b.calls++;switch(d){case 4:b.triangles+=a/3*e;break;case 1:b.lines+=a/2*e;break;case 3:b.lines+=e*(a-1);break;case 2:b.lines+=e*a;break;case 0:b.points+=e*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",d)}}}}function jj(a,b){return Math.abs(b[1])-Math.abs(a[1])}function kj(a){var b={},c=new Float32Array(8);
-return{update:function(d,e,f,g){var h=d.morphTargetInfluences,l=void 0===h?0:h.length;d=b[e.id];if(void 0===d){d=[];for(var m=0;m<l;m++)d[m]=[m,0];b[e.id]=d}var p=f.morphTargets&&e.morphAttributes.position;f=f.morphNormals&&e.morphAttributes.normal;for(m=0;m<l;m++){var r=d[m];0!==r[1]&&(p&&e.deleteAttribute("morphTarget"+m),f&&e.deleteAttribute("morphNormal"+m))}for(m=0;m<l;m++)r=d[m],r[0]=m,r[1]=h[m];d.sort(jj);for(m=h=0;8>m;m++){if(r=d[m])if(l=r[0],r=r[1]){p&&e.setAttribute("morphTarget"+m,p[l]);
-f&&e.setAttribute("morphNormal"+m,f[l]);c[m]=r;h+=r;continue}c[m]=0}e=e.morphTargetsRelative?1:1-h;g.getUniforms().setValue(a,"morphTargetBaseInfluence",e);g.getUniforms().setValue(a,"morphTargetInfluences",c)}}}function lj(a,b,c,d){var e={};return{update:function(a){var f=d.render.frame,h=a.geometry,l=b.get(a,h);e[l.id]!==f&&(h.isGeometry&&l.updateFromObject(a),b.update(l),e[l.id]=f);a.isInstancedMesh&&c.update(a.instanceMatrix,34962);return l},dispose:function(){e={}}}}function ob(a,b,c,d,e,f,g,
-h,l,m){a=void 0!==a?a:[];X.call(this,a,void 0!==b?b:301,c,d,e,f,void 0!==g?g:1022,h,l,m);this.flipY=!1}function Cc(a,b,c,d){X.call(this,null);this.image={data:a||null,width:b||1,height:c||1,depth:d||1};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1;this.needsUpdate=!0}function Dc(a,b,c,d){X.call(this,null);this.image={data:a||null,width:b||1,height:c||1,depth:d||1};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1;this.needsUpdate=
-!0}function Ec(a,b,c){var d=a[0];if(0>=d||0<d)return a;var e=b*c,f=th[e];void 0===f&&(f=new Float32Array(e),th[e]=f);if(0!==b)for(d.toArray(f,0),d=1,e=0;d!==b;++d)e+=c,a[d].toArray(f,e);return f}function Pa(a,b){if(a.length!==b.length)return!1;for(var c=0,d=a.length;c<d;c++)if(a[c]!==b[c])return!1;return!0}function Ka(a,b){for(var c=0,d=b.length;c<d;c++)a[c]=b[c]}function uh(a,b){var c=vh[b];void 0===c&&(c=new Int32Array(b),vh[b]=c);for(var d=0;d!==b;++d)c[d]=a.allocateTextureUnit();return c}function mj(a,
-b){var c=this.cache;c[0]!==b&&(a.uniform1f(this.addr,b),c[0]=b)}function nj(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y)a.uniform2f(this.addr,b.x,b.y),c[0]=b.x,c[1]=b.y}else Pa(c,b)||(a.uniform2fv(this.addr,b),Ka(c,b))}function oj(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y||c[2]!==b.z)a.uniform3f(this.addr,b.x,b.y,b.z),c[0]=b.x,c[1]=b.y,c[2]=b.z}else if(void 0!==b.r){if(c[0]!==b.r||c[1]!==b.g||c[2]!==b.b)a.uniform3f(this.addr,b.r,b.g,b.b),c[0]=b.r,c[1]=b.g,
-c[2]=b.b}else Pa(c,b)||(a.uniform3fv(this.addr,b),Ka(c,b))}function pj(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y||c[2]!==b.z||c[3]!==b.w)a.uniform4f(this.addr,b.x,b.y,b.z,b.w),c[0]=b.x,c[1]=b.y,c[2]=b.z,c[3]=b.w}else Pa(c,b)||(a.uniform4fv(this.addr,b),Ka(c,b))}function qj(a,b){var c=this.cache,d=b.elements;void 0===d?Pa(c,b)||(a.uniformMatrix2fv(this.addr,!1,b),Ka(c,b)):Pa(c,d)||(wh.set(d),a.uniformMatrix2fv(this.addr,!1,wh),Ka(c,d))}function rj(a,b){var c=this.cache,d=b.elements;
-void 0===d?Pa(c,b)||(a.uniformMatrix3fv(this.addr,!1,b),Ka(c,b)):Pa(c,d)||(xh.set(d),a.uniformMatrix3fv(this.addr,!1,xh),Ka(c,d))}function sj(a,b){var c=this.cache,d=b.elements;void 0===d?Pa(c,b)||(a.uniformMatrix4fv(this.addr,!1,b),Ka(c,b)):Pa(c,d)||(yh.set(d),a.uniformMatrix4fv(this.addr,!1,yh),Ka(c,d))}function tj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.safeSetTexture2D(b||zh,e)}function uj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();
-d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.setTexture2DArray(b||vj,e)}function wj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.setTexture3D(b||xj,e)}function yj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.safeSetTextureCube(b||Ah,e)}function zj(a,b){var c=this.cache;c[0]!==b&&(a.uniform1i(this.addr,b),c[0]=b)}function Aj(a,b){var c=this.cache;Pa(c,b)||(a.uniform2iv(this.addr,b),Ka(c,b))}function Bj(a,
-b){var c=this.cache;Pa(c,b)||(a.uniform3iv(this.addr,b),Ka(c,b))}function Cj(a,b){var c=this.cache;Pa(c,b)||(a.uniform4iv(this.addr,b),Ka(c,b))}function Dj(a){switch(a){case 5126:return mj;case 35664:return nj;case 35665:return oj;case 35666:return pj;case 35674:return qj;case 35675:return rj;case 35676:return sj;case 35678:case 36198:return tj;case 35679:return wj;case 35680:return yj;case 36289:return uj;case 5124:case 35670:return zj;case 35667:case 35671:return Aj;case 35668:case 35672:return Bj;
+Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),c.update(l));q=d.isWebGLRenderTargetCube?d.texture:d;l.material.uniforms.envMap.value=q;l.material.uniforms.flipEnvMap.value=q.isCubeTexture?-1:1;if(m!==d||p!==q.version)l.material.needsUpdate=!0,m=d,p=q.version;b.unshift(l,l.geometry,l.material,0,0,null)}else if(d&&d.isTexture){void 0===h&&(h=new V(new $b(2,2),new za({type:"BackgroundMaterial",uniforms:Yb(db.background.uniforms),vertexShader:db.background.vertexShader,
+fragmentShader:db.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),c.update(h));h.material.uniforms.t2D.value=d;!0===d.matrixAutoUpdate&&d.updateMatrix();h.material.uniforms.uvTransform.value.copy(d.matrix);if(m!==d||p!==d.version)h.material.needsUpdate=!0,m=d,p=d.version;b.unshift(h,h.geometry,h.material,0,0,null)}}}}function cj(a,b,c,d){var e=d.isWebGL2,
+f;this.setMode=function(a){f=a};this.render=function(b,d){a.drawArrays(f,b,d);c.update(d,f)};this.renderInstances=function(d,h,l,m){if(0!==m){if(e){d=a;var g="drawArraysInstanced"}else if(d=b.get("ANGLE_instanced_arrays"),g="drawArraysInstancedANGLE",null===d){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[g](f,h,l,m);c.update(l,f,m)}}}function dj(a,b,c){function d(b){if("highp"===b){if(0<a.getShaderPrecisionFormat(35633,
+36338).precision&&0<a.getShaderPrecisionFormat(35632,36338).precision)return"highp";b="mediump"}return"mediump"===b&&0<a.getShaderPrecisionFormat(35633,36337).precision&&0<a.getShaderPrecisionFormat(35632,36337).precision?"mediump":"lowp"}var e,f="undefined"!==typeof WebGL2RenderingContext&&a instanceof WebGL2RenderingContext||"undefined"!==typeof WebGL2ComputeRenderingContext&&a instanceof WebGL2ComputeRenderingContext,g=void 0!==c.precision?c.precision:"highp",h=d(g);h!==g&&(console.warn("THREE.WebGLRenderer:",
+g,"not supported, using",h,"instead."),g=h);c=!0===c.logarithmicDepthBuffer;h=a.getParameter(34930);var l=a.getParameter(35660),m=a.getParameter(3379),p=a.getParameter(34076),r=a.getParameter(34921),k=a.getParameter(36347),u=a.getParameter(36348),q=a.getParameter(36349),v=0<l,n=f||!!b.get("OES_texture_float"),w=v&&n,x=f?a.getParameter(36183):0;return{isWebGL2:f,getMaxAnisotropy:function(){if(void 0!==e)return e;var c=b.get("EXT_texture_filter_anisotropic");return e=null!==c?a.getParameter(c.MAX_TEXTURE_MAX_ANISOTROPY_EXT):
+0},getMaxPrecision:d,precision:g,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:l,maxTextureSize:m,maxCubemapSize:p,maxAttributes:r,maxVertexUniforms:k,maxVaryings:u,maxFragmentUniforms:q,vertexTextures:v,floatFragmentTextures:n,floatVertexTextures:w,maxSamples:x}}function ej(){function a(){m.value!==d&&(m.value=d,m.needsUpdate=0<e);c.numPlanes=e;c.numIntersection=0}function b(a,b,d,e){var f=null!==a?a.length:0,g=null;if(0!==f){g=m.value;if(!0!==e||null===g){e=d+4*f;b=b.matrixWorldInverse;
+l.getNormalMatrix(b);if(null===g||g.length<e)g=new Float32Array(e);for(e=0;e!==f;++e,d+=4)h.copy(a[e]).applyMatrix4(b,l),h.normal.toArray(g,d),g[d+3]=h.constant}m.value=g;m.needsUpdate=!0}c.numPlanes=f;return g}var c=this,d=null,e=0,f=!1,g=!1,h=new Ta,l=new ca,m={value:null,needsUpdate:!1};this.uniform=m;this.numIntersection=this.numPlanes=0;this.init=function(a,c,g){var h=0!==a.length||c||0!==e||f;f=c;d=b(a,g,0);e=a.length;return h};this.beginShadows=function(){g=!0;b(null)};this.endShadows=function(){g=
+!1;a()};this.setState=function(c,h,l,k,q,v){if(!f||null===c||0===c.length||g&&!l)g?b(null):a();else{l=g?0:e;var p=4*l,r=q.clippingState||null;m.value=r;r=b(c,k,p,v);for(c=0;c!==p;++c)r[c]=d[c];q.clippingState=r;this.numIntersection=h?this.numPlanes:0;this.numPlanes+=l}}}function fj(a){var b={};return{get:function(c){if(void 0!==b[c])return b[c];switch(c){case "WEBGL_depth_texture":var d=a.getExtension("WEBGL_depth_texture")||a.getExtension("MOZ_WEBGL_depth_texture")||a.getExtension("WEBKIT_WEBGL_depth_texture");
+break;case "EXT_texture_filter_anisotropic":d=a.getExtension("EXT_texture_filter_anisotropic")||a.getExtension("MOZ_EXT_texture_filter_anisotropic")||a.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case "WEBGL_compressed_texture_s3tc":d=a.getExtension("WEBGL_compressed_texture_s3tc")||a.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case "WEBGL_compressed_texture_pvrtc":d=a.getExtension("WEBGL_compressed_texture_pvrtc")||
+a.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:d=a.getExtension(c)}null===d&&console.warn("THREE.WebGLRenderer: "+c+" extension not supported.");return b[c]=d}}}function gj(a,b,c){function d(a){var e=a.target;a=f.get(e);null!==a.index&&b.remove(a.index);for(var h in a.attributes)b.remove(a.attributes[h]);e.removeEventListener("dispose",d);f.delete(e);if(h=g.get(a))b.remove(h),g.delete(a);c.memory.geometries--}function e(a){var c=[],d=a.index,e=a.attributes.position;if(null!==
+d){var f=d.array;d=d.version;e=0;for(var h=f.length;e<h;e+=3){var k=f[e+0],q=f[e+1],v=f[e+2];c.push(k,q,q,v,v,k)}}else for(f=e.array,d=e.version,e=0,h=f.length/3-1;e<h;e+=3)k=e+0,q=e+1,v=e+2,c.push(k,q,q,v,v,k);c=new (65535<qh(c)?Ub:Tb)(c,1);c.version=d;b.update(c,34963);(f=g.get(a))&&b.remove(f);g.set(a,c)}var f=new WeakMap,g=new WeakMap;return{get:function(a,b){var e=f.get(b);if(e)return e;b.addEventListener("dispose",d);b.isBufferGeometry?e=b:b.isGeometry&&(void 0===b._bufferGeometry&&(b._bufferGeometry=
+(new C).setFromObject(a)),e=b._bufferGeometry);f.set(b,e);c.memory.geometries++;return e},update:function(a){var c=a.index,d=a.attributes;null!==c&&b.update(c,34963);for(var e in d)b.update(d[e],34962);a=a.morphAttributes;for(e in a){c=a[e];d=0;for(var f=c.length;d<f;d++)b.update(c[d],34962)}},getWireframeAttribute:function(a){var b=g.get(a);if(b){var c=a.index;null!==c&&b.version<c.version&&e(a)}else e(a);return g.get(a)}}}function hj(a,b,c,d){var e=d.isWebGL2,f,g,h;this.setMode=function(a){f=a};
+this.setIndex=function(a){g=a.type;h=a.bytesPerElement};this.render=function(b,d){a.drawElements(f,d,g,b*h);c.update(d,f)};this.renderInstances=function(d,m,p,r){if(0!==r){if(e){d=a;var l="drawElementsInstanced"}else if(d=b.get("ANGLE_instanced_arrays"),l="drawElementsInstancedANGLE",null===d){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[l](f,p,g,m*h,r);c.update(p,f,r)}}}function ij(a){var b=
+{frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:b,programs:null,autoReset:!0,reset:function(){b.frame++;b.calls=0;b.triangles=0;b.points=0;b.lines=0},update:function(a,d,e){e=e||1;b.calls++;switch(d){case 4:b.triangles+=a/3*e;break;case 1:b.lines+=a/2*e;break;case 3:b.lines+=e*(a-1);break;case 2:b.lines+=e*a;break;case 0:b.points+=e*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",d)}}}}function jj(a,b){return Math.abs(b[1])-Math.abs(a[1])}
+function kj(a){var b={},c=new Float32Array(8);return{update:function(d,e,f,g){var h=d.morphTargetInfluences,l=void 0===h?0:h.length;d=b[e.id];if(void 0===d){d=[];for(var m=0;m<l;m++)d[m]=[m,0];b[e.id]=d}var p=f.morphTargets&&e.morphAttributes.position;f=f.morphNormals&&e.morphAttributes.normal;for(m=0;m<l;m++){var r=d[m];0!==r[1]&&(p&&e.deleteAttribute("morphTarget"+m),f&&e.deleteAttribute("morphNormal"+m))}for(m=0;m<l;m++)r=d[m],r[0]=m,r[1]=h[m];d.sort(jj);for(m=h=0;8>m;m++){if(r=d[m])if(l=r[0],
+r=r[1]){p&&e.setAttribute("morphTarget"+m,p[l]);f&&e.setAttribute("morphNormal"+m,f[l]);c[m]=r;h+=r;continue}c[m]=0}e=e.morphTargetsRelative?1:1-h;g.getUniforms().setValue(a,"morphTargetBaseInfluence",e);g.getUniforms().setValue(a,"morphTargetInfluences",c)}}}function lj(a,b,c,d){var e={};return{update:function(a){var f=d.render.frame,h=a.geometry,l=b.get(a,h);e[l.id]!==f&&(h.isGeometry&&l.updateFromObject(a),b.update(l),e[l.id]=f);a.isInstancedMesh&&c.update(a.instanceMatrix,34962);return l},dispose:function(){e=
+{}}}}function ob(a,b,c,d,e,f,g,h,l,m){a=void 0!==a?a:[];X.call(this,a,void 0!==b?b:301,c,d,e,f,void 0!==g?g:1022,h,l,m);this.flipY=!1}function Cc(a,b,c,d){X.call(this,null);this.image={data:a||null,width:b||1,height:c||1,depth:d||1};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1;this.needsUpdate=!0}function Dc(a,b,c,d){X.call(this,null);this.image={data:a||null,width:b||1,height:c||1,depth:d||1};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=
+!1;this.needsUpdate=!0}function Ec(a,b,c){var d=a[0];if(0>=d||0<d)return a;var e=b*c,f=th[e];void 0===f&&(f=new Float32Array(e),th[e]=f);if(0!==b)for(d.toArray(f,0),d=1,e=0;d!==b;++d)e+=c,a[d].toArray(f,e);return f}function Pa(a,b){if(a.length!==b.length)return!1;for(var c=0,d=a.length;c<d;c++)if(a[c]!==b[c])return!1;return!0}function Ka(a,b){for(var c=0,d=b.length;c<d;c++)a[c]=b[c]}function uh(a,b){var c=vh[b];void 0===c&&(c=new Int32Array(b),vh[b]=c);for(var d=0;d!==b;++d)c[d]=a.allocateTextureUnit();
+return c}function mj(a,b){var c=this.cache;c[0]!==b&&(a.uniform1f(this.addr,b),c[0]=b)}function nj(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y)a.uniform2f(this.addr,b.x,b.y),c[0]=b.x,c[1]=b.y}else Pa(c,b)||(a.uniform2fv(this.addr,b),Ka(c,b))}function oj(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y||c[2]!==b.z)a.uniform3f(this.addr,b.x,b.y,b.z),c[0]=b.x,c[1]=b.y,c[2]=b.z}else if(void 0!==b.r){if(c[0]!==b.r||c[1]!==b.g||c[2]!==b.b)a.uniform3f(this.addr,b.r,b.g,
+b.b),c[0]=b.r,c[1]=b.g,c[2]=b.b}else Pa(c,b)||(a.uniform3fv(this.addr,b),Ka(c,b))}function pj(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y||c[2]!==b.z||c[3]!==b.w)a.uniform4f(this.addr,b.x,b.y,b.z,b.w),c[0]=b.x,c[1]=b.y,c[2]=b.z,c[3]=b.w}else Pa(c,b)||(a.uniform4fv(this.addr,b),Ka(c,b))}function qj(a,b){var c=this.cache,d=b.elements;void 0===d?Pa(c,b)||(a.uniformMatrix2fv(this.addr,!1,b),Ka(c,b)):Pa(c,d)||(wh.set(d),a.uniformMatrix2fv(this.addr,!1,wh),Ka(c,d))}function rj(a,b){var c=
+this.cache,d=b.elements;void 0===d?Pa(c,b)||(a.uniformMatrix3fv(this.addr,!1,b),Ka(c,b)):Pa(c,d)||(xh.set(d),a.uniformMatrix3fv(this.addr,!1,xh),Ka(c,d))}function sj(a,b){var c=this.cache,d=b.elements;void 0===d?Pa(c,b)||(a.uniformMatrix4fv(this.addr,!1,b),Ka(c,b)):Pa(c,d)||(yh.set(d),a.uniformMatrix4fv(this.addr,!1,yh),Ka(c,d))}function tj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.safeSetTexture2D(b||zh,e)}function uj(a,b,c){var d=this.cache,
+e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.setTexture2DArray(b||vj,e)}function wj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.setTexture3D(b||xj,e)}function yj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.safeSetTextureCube(b||Ah,e)}function zj(a,b){var c=this.cache;c[0]!==b&&(a.uniform1i(this.addr,b),c[0]=b)}function Aj(a,b){var c=this.cache;Pa(c,b)||(a.uniform2iv(this.addr,
+b),Ka(c,b))}function Bj(a,b){var c=this.cache;Pa(c,b)||(a.uniform3iv(this.addr,b),Ka(c,b))}function Cj(a,b){var c=this.cache;Pa(c,b)||(a.uniform4iv(this.addr,b),Ka(c,b))}function Dj(a){switch(a){case 5126:return mj;case 35664:return nj;case 35665:return oj;case 35666:return pj;case 35674:return qj;case 35675:return rj;case 35676:return sj;case 35678:case 36198:return tj;case 35679:return wj;case 35680:return yj;case 36289:return uj;case 5124:case 35670:return zj;case 35667:case 35671:return Aj;case 35668:case 35672:return Bj;
 case 35669:case 35673:return Cj}}function Ej(a,b){a.uniform1fv(this.addr,b)}function Fj(a,b){a.uniform1iv(this.addr,b)}function Gj(a,b){a.uniform2iv(this.addr,b)}function Hj(a,b){a.uniform3iv(this.addr,b)}function Ij(a,b){a.uniform4iv(this.addr,b)}function Jj(a,b){b=Ec(b,this.size,2);a.uniform2fv(this.addr,b)}function Kj(a,b){b=Ec(b,this.size,3);a.uniform3fv(this.addr,b)}function Lj(a,b){b=Ec(b,this.size,4);a.uniform4fv(this.addr,b)}function Mj(a,b){b=Ec(b,this.size,4);a.uniformMatrix2fv(this.addr,
 !1,b)}function Nj(a,b){b=Ec(b,this.size,9);a.uniformMatrix3fv(this.addr,!1,b)}function Oj(a,b){b=Ec(b,this.size,16);a.uniformMatrix4fv(this.addr,!1,b)}function Pj(a,b,c){var d=b.length,e=uh(c,d);a.uniform1iv(this.addr,e);for(a=0;a!==d;++a)c.safeSetTexture2D(b[a]||zh,e[a])}function Qj(a,b,c){var d=b.length,e=uh(c,d);a.uniform1iv(this.addr,e);for(a=0;a!==d;++a)c.safeSetTextureCube(b[a]||Ah,e[a])}function Rj(a){switch(a){case 5126:return Ej;case 35664:return Jj;case 35665:return Kj;case 35666:return Lj;
 case 35674:return Mj;case 35675:return Nj;case 35676:return Oj;case 35678:return Pj;case 35680:return Qj;case 5124:case 35670:return Fj;case 35667:case 35671:return Gj;case 35668:case 35672:return Hj;case 35669:case 35673:return Ij}}function Sj(a,b,c){this.id=a;this.addr=c;this.cache=[];this.setValue=Dj(b.type)}function Bh(a,b,c){this.id=a;this.addr=c;this.cache=[];this.size=b.size;this.setValue=Rj(b.type)}function Ch(a){this.id=a;this.seq=[];this.map={}}function Cb(a,b){this.seq=[];this.map={};for(var c=
@@ -189,8 +189,8 @@ c.clearcoatNormalMap,1===c.side&&p.clearcoatNormalScale.value.negate()),p.transp
 c.displacementScale,p.displacementBias.value=c.displacementBias);else if(c.isMeshDepthMaterial)u(p,c),c.displacementMap&&(p.displacementMap.value=c.displacementMap,p.displacementScale.value=c.displacementScale,p.displacementBias.value=c.displacementBias);else if(c.isMeshDistanceMaterial)u(p,c),c.displacementMap&&(p.displacementMap.value=c.displacementMap,p.displacementScale.value=c.displacementScale,p.displacementBias.value=c.displacementBias),p.referencePosition.value.copy(c.referencePosition),p.nearDistance.value=
 c.nearDistance,p.farDistance.value=c.farDistance;else if(c.isMeshNormalMaterial)u(p,c),c.bumpMap&&(p.bumpMap.value=c.bumpMap,p.bumpScale.value=c.bumpScale,1===c.side&&(p.bumpScale.value*=-1)),c.normalMap&&(p.normalMap.value=c.normalMap,p.normalScale.value.copy(c.normalScale),1===c.side&&p.normalScale.value.negate()),c.displacementMap&&(p.displacementMap.value=c.displacementMap,p.displacementScale.value=c.displacementScale,p.displacementBias.value=c.displacementBias);else if(c.isLineBasicMaterial)p.diffuse.value.copy(c.color),
 p.opacity.value=c.opacity,c.isLineDashedMaterial&&(p.dashSize.value=c.dashSize,p.totalSize.value=c.dashSize+c.gapSize,p.scale.value=c.scale);else if(c.isPointsMaterial){p.diffuse.value.copy(c.color);p.opacity.value=c.opacity;p.size.value=c.size*U;p.scale.value=.5*J;c.map&&(p.map.value=c.map);c.alphaMap&&(p.alphaMap.value=c.alphaMap);if(c.map)var n=c.map;else c.alphaMap&&(n=c.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),p.uvTransform.value.copy(n.matrix))}else if(c.isSpriteMaterial){p.diffuse.value.copy(c.color);
-p.opacity.value=c.opacity;p.rotation.value=c.rotation;c.map&&(p.map.value=c.map);c.alphaMap&&(p.alphaMap.value=c.alphaMap);if(c.map)var w=c.map;else c.alphaMap&&(w=c.alphaMap);void 0!==w&&(!0===w.matrixAutoUpdate&&w.updateMatrix(),p.uvTransform.value.copy(w.matrix))}else c.isShadowMaterial?(p.color.value.copy(c.color),p.opacity.value=c.opacity):c.envMap&&u(p,c);void 0!==p.ltc_1&&(p.ltc_1.value=G.LTC_1);void 0!==p.ltc_2&&(p.ltc_2.value=G.LTC_2);Cb.upload(H,e.uniformsList,p,ca);c.isShaderMaterial&&
-(c.uniformsNeedUpdate=!1)}c.isShaderMaterial&&!0===c.uniformsNeedUpdate&&(Cb.upload(H,e.uniformsList,p,ca),c.uniformsNeedUpdate=!1);c.isSpriteMaterial&&m.setValue(H,"center",d.center);0<f.numMultiviewViews?ua.updateObjectMatricesUniforms(d,a,m):(m.setValue(H,"modelViewMatrix",d.modelViewMatrix),m.setValue(H,"normalMatrix",d.normalMatrix));m.setValue(H,"modelMatrix",d.matrixWorld);return f}function u(a,b){a.opacity.value=b.opacity;b.color&&a.diffuse.value.copy(b.color);b.emissive&&a.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity);
+p.opacity.value=c.opacity;p.rotation.value=c.rotation;c.map&&(p.map.value=c.map);c.alphaMap&&(p.alphaMap.value=c.alphaMap);if(c.map)var w=c.map;else c.alphaMap&&(w=c.alphaMap);void 0!==w&&(!0===w.matrixAutoUpdate&&w.updateMatrix(),p.uvTransform.value.copy(w.matrix))}else c.isShadowMaterial&&(p.color.value.copy(c.color),p.opacity.value=c.opacity);void 0!==p.ltc_1&&(p.ltc_1.value=G.LTC_1);void 0!==p.ltc_2&&(p.ltc_2.value=G.LTC_2);Cb.upload(H,e.uniformsList,p,ca);c.isShaderMaterial&&(c.uniformsNeedUpdate=
+!1)}c.isShaderMaterial&&!0===c.uniformsNeedUpdate&&(Cb.upload(H,e.uniformsList,p,ca),c.uniformsNeedUpdate=!1);c.isSpriteMaterial&&m.setValue(H,"center",d.center);0<f.numMultiviewViews?ua.updateObjectMatricesUniforms(d,a,m):(m.setValue(H,"modelViewMatrix",d.modelViewMatrix),m.setValue(H,"normalMatrix",d.normalMatrix));m.setValue(H,"modelMatrix",d.matrixWorld);return f}function u(a,b){a.opacity.value=b.opacity;b.color&&a.diffuse.value.copy(b.color);b.emissive&&a.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity);
 b.map&&(a.map.value=b.map);b.alphaMap&&(a.alphaMap.value=b.alphaMap);b.specularMap&&(a.specularMap.value=b.specularMap);b.envMap&&(a.envMap.value=b.envMap,a.flipEnvMap.value=b.envMap.isCubeTexture?-1:1,a.reflectivity.value=b.reflectivity,a.refractionRatio.value=b.refractionRatio,a.maxMipLevel.value=Ga.get(b.envMap).__maxMipLevel);b.lightMap&&(a.lightMap.value=b.lightMap,a.lightMapIntensity.value=b.lightMapIntensity);b.aoMap&&(a.aoMap.value=b.aoMap,a.aoMapIntensity.value=b.aoMapIntensity);if(b.map)var c=
 b.map;else b.specularMap?c=b.specularMap:b.displacementMap?c=b.displacementMap:b.normalMap?c=b.normalMap:b.bumpMap?c=b.bumpMap:b.roughnessMap?c=b.roughnessMap:b.metalnessMap?c=b.metalnessMap:b.alphaMap?c=b.alphaMap:b.emissiveMap&&(c=b.emissiveMap);void 0!==c&&(c.isWebGLRenderTarget&&(c=c.texture),!0===c.matrixAutoUpdate&&c.updateMatrix(),a.uvTransform.value.copy(c.matrix));if(b.aoMap)var d=b.aoMap;else b.lightMap&&(d=b.lightMap);void 0!==d&&(d.isWebGLRenderTarget&&(d=d.texture),!0===d.matrixAutoUpdate&&
 d.updateMatrix(),a.uv2Transform.value.copy(d.matrix))}function q(a,b){a.roughness.value=b.roughness;a.metalness.value=b.metalness;b.roughnessMap&&(a.roughnessMap.value=b.roughnessMap);b.metalnessMap&&(a.metalnessMap.value=b.metalnessMap);b.emissiveMap&&(a.emissiveMap.value=b.emissiveMap);b.bumpMap&&(a.bumpMap.value=b.bumpMap,a.bumpScale.value=b.bumpScale,1===b.side&&(a.bumpScale.value*=-1));b.normalMap&&(a.normalMap.value=b.normalMap,a.normalScale.value.copy(b.normalScale),1===b.side&&a.normalScale.value.negate());

+ 5 - 7
build/three.module.js

@@ -15410,11 +15410,11 @@ function WebGLBackground( renderer, state, objects, premultipliedAlpha ) {
 				};
 
 				// enable code injection for non-built-in material
-				Object.defineProperty( boxMesh.material, 'map', {
+				Object.defineProperty( boxMesh.material, 'envMap', {
 
 					get: function () {
 
-						return this.envMap.value;
+						return this.uniforms.envMap.value;
 
 					}
 
@@ -15425,7 +15425,9 @@ function WebGLBackground( renderer, state, objects, premultipliedAlpha ) {
 			}
 
 			var texture = background.isWebGLRenderTargetCube ? background.texture : background;
-			boxMesh.material.envMap = texture;
+
+			boxMesh.material.uniforms.envMap.value = texture;
+			boxMesh.material.uniforms.flipEnvMap.value = texture.isCubeTexture ? - 1 : 1;
 
 			if ( currentBackground !== background ||
 			     currentBackgroundVersion !== texture.version ) {
@@ -25079,10 +25081,6 @@ function WebGLRenderer( parameters ) {
 				m_uniforms.color.value.copy( material.color );
 				m_uniforms.opacity.value = material.opacity;
 
-			} else if ( material.envMap ) {
-
-				refreshUniformsCommon( m_uniforms, material );
-
 			}
 
 			// RectAreaLight Texture