353 lines
1.3 MiB
JavaScript
353 lines
1.3 MiB
JavaScript
|
function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n,r=arguments[t];for(n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).v3d={})}(this,function(e){"use strict";void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}),void 0===Math.sign&&(Math.sign=function(e){return e<0?-1:0<e?1:+e}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");const t=Object(e);for(let e=1;e<arguments.length;e++){var n=arguments[e];if(null!=n)for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}),void 0===Object.values&&(Object.values=function(e){const t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(e[n]);return t}),void 0===Float32Array.prototype.slice&&(Float32Array.prototype.slice=function(e,t){return new this.constructor(this.subarray(e,t))}),String.prototype.endsWith||(String.prototype.endsWith=function(e,t){return(void 0===t||t>this.length)&&(t=this.length),this.substring(t-e.length,t)===e});class n{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0!==this._listeners){const n=this._listeners[e];void 0===n||-1!==(e=n.indexOf(t))&&n.splice(e,1)}}dispatchEvent(n){if(void 0!==this._listeners){const e=this._listeners[n.type];if(void 0!==e){n.target=this;const r=e.slice(0);for(let e=0,t=r.length;e<t;e++)r[e].call(this,n);n.target=null}}}}const o="3.9.1",fe={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2};const X=0,j=1,Y=2;const te=0,ne=1,ie=2,ae=3,oe=4,se=5,le=6,Ve=0,Fe=1,Ue=2;const ce=0,Z=1,q=2,Q=3,K=4,J=5,$=100,ue=101,me=102,ve=103,ge=104,_e=200,xe=201,ye=202,be=203,Me=204,Ae=205,we=206,Se=207,Te=208,Ce=209,Ee=210,Le=0,Re=1,Pe=2,Ie=3,Ne=4,De=5,Oe=6,Ge=7,ke=0;const s=300,L=301,R=302,P=303,I=304,N=306,D=307,U=1e3,ut=1001,G=1002,dt=1003,W=1004;const H=1005;const ht=1006,We=1007;const He=1008,Mt=1009,l=1010,c=1011,V=1012,u=1013,Xe=1014,At=1015,je=1016,d=1017,h=1018,p=1019,Ye=1020,f=1021,wt=1022,pt=1023,m=1024,v=1025,F=pt,Ze=1026,qe=1027,Qe=1028,M=1029,A=1030,w=1031,B=1032,z=1033,Ke=33776,Je=33777,$e=33778,et=33779,tt=35840,nt=35841,rt=35842,it=35843,at=36196,ot=37492,st=37496,lt=37808,ct=37809,St=37810,Tt=37811,Ct=37812,Et=37813,Lt=37814,Rt=37815,Pt=37816,It=37817,Nt=37818,Dt=37819,Ot=37820,Ft=37821,Bt=36492,zt=37840,Vt=37841,Ut=37842,Gt=37843,kt=37844,Wt=37845,Ht=37846,Xt=37847,jt=37848,Yt=37849,Zt=37850,qt=37851,Qt=37852,Kt=37853,Jt=2300,$t=2301,en=2302,tn=2400,nn=2401,rn=2402,an=3e3,on=3001,sn=3002,ln=3201,cn=3301,un=3302,dn=0,hn=1;const pn=34055,fn=34056;const mn=35044,vn=35048;const gn="300 es",_n="BLENDER",xn="__V3DL__0000000000",yn=[];for(let e=0;e<256;e++)yn[e]=(e<16?"0":"")+e.toString(16);let bn=1234567;const Mn=Math.PI/180,An=180/Math.PI;function wn(){var e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,r=4294967295*Math.random()|0;const i=yn[255&e]+yn[e>>8&255]+yn[e>>16&255]+yn[e>>24&255]+"-"+yn[255&t]+yn[t>>8&255]+"-"+yn[t>>16&15|64]+yn[t>>24&255]+"-"+yn[63&n|128]+yn[n>>8&255]+"-"+yn[n>>16&255]+yn[n>>24&255]+yn[255&r]+yn[r>>8&255]+yn[r>>16&255]+yn[r>>24&255];return i.toUpperCase()}function ft(e,t,n){return Math.max(t,Math.min(n,e))}function Sn(e,t){return(e%t+t)%t}function Tn(e,t,n){return(1-n)*e+n*t}function Cn(e,t,n){return e<=t?0:n<=e?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)}function En(e){return e*Mn}function Ln(e){ret
|
||
|
|
||
|
varying vec3 vWorldDirection;
|
||
|
|
||
|
vec3 transformDirection(in vec3 dir, in mat4 matrix) {
|
||
|
|
||
|
return normalize((matrix * vec4(dir, 0.0)).xyz);
|
||
|
|
||
|
}
|
||
|
|
||
|
void main() {
|
||
|
|
||
|
vWorldDirection = transformDirection(position, modelMatrix);
|
||
|
|
||
|
#include <begin_vertex>
|
||
|
#include <project_vertex>
|
||
|
|
||
|
}
|
||
|
`,fragmentShader:`
|
||
|
|
||
|
uniform sampler2D tEquirect;
|
||
|
|
||
|
varying vec3 vWorldDirection;
|
||
|
|
||
|
#include <common>
|
||
|
|
||
|
void main() {
|
||
|
|
||
|
vec3 direction = normalize(vWorldDirection);
|
||
|
|
||
|
vec2 sampleUV = equirectUv(direction);
|
||
|
|
||
|
gl_FragColor = texture2D(tEquirect, sampleUV);
|
||
|
|
||
|
}
|
||
|
`},r=new oa(5,5,5);const i=new T({name:"CubemapFromEquirect",uniforms:sa(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Fe,blending:ce}),a=(i.uniforms.tEquirect.value=t,new ee(r,i));n=t.minFilter;t.minFilter===He&&(t.minFilter=ht);const o=new ha(1,10,this);return o.update(e,a),t.minFilter=n,a.geometry.dispose(),a.material.dispose(),this}clear(t,n,r,i){var e=t.getRenderTarget();for(let e=0;e<6;e++)t.setRenderTarget(this,e),t.clear(n,r,i);t.setRenderTarget(e)}}fa.prototype.isWebGLCubeRenderTarget=!0;const ma={checkWebGL:function(){try{const e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("webgl")&&!e.getContext("experimental-webgl"))}catch(e){return!1}},checkWebGL2:function(){try{const e=document.createElement("canvas");return!(!window.WebGL2RenderingContext||!e.getContext("webgl2"))}catch(e){return!1}},checkWorkers:function(){return!!window.Worker},checkFileAPI:function(){return window.File&&window.FileReader&&window.FileList&&window.Blob},genWebGLErrorMessage:function(){const e=document.createElement("div");return e.setAttribute("class","v3d-webgl-error"),e.innerHTML=(window.WebGLRenderingContext?["Ouch! Your graphics card does not support WebGL.<br/>",'Find out how to fix it <a href="https://www.soft8soft.com/webgl-supported-browsers-and-troubleshooting/" target="_top" class="v3d-webgl-error-link">here</a>.']:["Ouch! Your browser does not support WebGL.<br/>",'Find out how to fix it <a href="https://www.soft8soft.com/webgl-supported-browsers-and-troubleshooting/" target="_top" class="v3d-webgl-error-link">here</a>.']).join("\n"),e},showWebGLErrorMessage:function(e){(e=e||document.body).appendChild(ma.genWebGLErrorMessage());const t=document.getElementById("v3d_preloader_container");t&&(t.style.visibility="hidden")},checkIOS:function(){return(/iPad|iPhone|iPod/.test(navigator.platform)||"MacIntel"===navigator.platform&&1<navigator.maxTouchPoints)&&!window.MSStream},checkAndroid:function(){return!!navigator.userAgent.match(/Android/i)},checkSafari:function(){return/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)},checkFloatTex:function(e,t){const n=e.getContext();return!(!e.capabilities.isWebGL2||!n.getExtension("EXT_color_buffer_float")||t&&!n.getExtension("OES_texture_float_linear"))||!(e.capabilities.isWebGL2||!n.getExtension("OES_texture_float")||t&&!n.getExtension("OES_texture_float_linear"))},checkHalfFloatTex:function(e,t){const n=e.getContext();return!(!e.capabilities.isWebGL2||!n.getExtension("EXT_color_buffer_float"))||!(e.capabilities.isWebGL2||!n.getExtension("OES_texture_half_float")||t&&!n.getExtension("OES_texture_half_float_linear"))},checkDepthTex:function(e){const t=e.getContext();return!(!e.capabilities.isWebGL2&&!t.getExtension("WEBGL_depth_texture"))},getGPUVendor:function(e){const t=e?e.getContext():document.createElement("canvas").getContext("webgl")||document.createElement("canvas").getContext("experimental-webgl");e=t.getExtension("WEBGL_debug_renderer_info");return null!=e?t.getParameter(e.UNMASKED_VENDOR_WEBGL):""},getGPUModel:function(e){const t=e?e.getContext():document.createElement("canvas").getContext("webgl")||document.createElement("canvas").getContext("experimental-webgl");e=t.getExtension("WEBGL_debug_renderer_info");return null!=e?t.getParameter(e.UNMASKED_RENDERER_WEBGL):""},checkWebXR:function(e,t,n){"xr"in navigator&&navigator.xr.isSessionSupported?navigator.xr.isSessionSupported(e).then(function(e){(e?t:n)()}).catch(n):n()},checkNativeWebXR:function(){var e="polyfill"in window&&"WebXRPolyfill"in window&&polyfill instanceof WebXRPolyfill;return"xr"in navigator&&(!e||polyfill.nativeWebXR)},checkCardboard:function(){return!1},checkSwiftShader:function(e){return"Google SwiftShader"==this.getGPUModel(e)},checkWebAudio:function(){return void 0!==(window.AudioContext||window.webkitAudioContext)},isSafariWithMultisamplingBug:function(){if(!this.checkSafari())return!1;const e=navigator.userAgent;return e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|1
|
||
|
uniform mat4 modelMatrix;
|
||
|
uniform mat4 modelViewMatrix;
|
||
|
uniform mat4 projectionMatrix;
|
||
|
uniform mat4 viewMatrix;
|
||
|
uniform mat3 normalMatrix;
|
||
|
uniform vec3 cameraPosition;
|
||
|
uniform bool isOrthographic;
|
||
|
|
||
|
#ifdef USE_INSTANCING
|
||
|
attribute mat4 instanceMatrix;
|
||
|
#endif
|
||
|
|
||
|
#ifdef USE_INSTANCING_COLOR
|
||
|
attribute vec3 instanceColor;
|
||
|
#endif
|
||
|
|
||
|
attribute vec3 position;
|
||
|
attribute vec3 normal;
|
||
|
attribute vec2 uv;
|
||
|
|
||
|
#ifdef USE_TANGENT
|
||
|
attribute vec4 tangent;
|
||
|
#endif
|
||
|
|
||
|
#if defined(USE_COLOR_ALPHA)
|
||
|
attribute vec4 color;
|
||
|
#elif defined(USE_COLOR)
|
||
|
attribute vec3 color;
|
||
|
#endif
|
||
|
|
||
|
#ifdef USE_MORPHTARGETS
|
||
|
#if NUM_MORPH_TARGETS > 0
|
||
|
attribute vec3 morphTarget0;
|
||
|
#endif
|
||
|
#if NUM_MORPH_TARGETS > 1
|
||
|
attribute vec3 morphTarget1;
|
||
|
#endif
|
||
|
#if NUM_MORPH_TARGETS > 2
|
||
|
attribute vec3 morphTarget2;
|
||
|
#endif
|
||
|
#if NUM_MORPH_TARGETS > 3
|
||
|
attribute vec3 morphTarget3;
|
||
|
#endif
|
||
|
#if NUM_MORPH_TARGETS > 4
|
||
|
attribute vec3 morphTarget4;
|
||
|
#endif
|
||
|
#if NUM_MORPH_TARGETS > 5
|
||
|
attribute vec3 morphTarget5;
|
||
|
#endif
|
||
|
|
||
|
#ifdef USE_MORPHNORMALS
|
||
|
#if NUM_MORPH_TARGETS > 0
|
||
|
attribute vec3 morphNormal0;
|
||
|
#endif
|
||
|
#if NUM_MORPH_TARGETS > 1
|
||
|
attribute vec3 morphNormal1;
|
||
|
#endif
|
||
|
#if NUM_MORPH_TARGETS > 2
|
||
|
attribute vec3 morphNormal2;
|
||
|
#endif
|
||
|
#if NUM_MORPH_TARGETS > 3
|
||
|
attribute vec3 morphNormal3;
|
||
|
#endif
|
||
|
#if NUM_MORPH_TARGETS > 4
|
||
|
attribute vec3 morphNormal4;
|
||
|
#endif
|
||
|
#if NUM_MORPH_TARGETS > 5
|
||
|
attribute vec3 morphNormal5;
|
||
|
#endif
|
||
|
#else
|
||
|
#if NUM_MORPH_TARGETS > 6
|
||
|
attribute vec3 morphTarget6;
|
||
|
#endif
|
||
|
#if NUM_MORPH_TARGETS > 7
|
||
|
attribute vec3 morphTarget7;
|
||
|
#endif
|
||
|
#if NUM_MORPH_TARGETS > 8
|
||
|
attribute vec3 morphTarget8;
|
||
|
#endif
|
||
|
#if NUM_MORPH_TARGETS > 9
|
||
|
attribute vec3 morphTarget9;
|
||
|
#endif
|
||
|
#if NUM_MORPH_TARGETS > 10
|
||
|
attribute vec3 morphTarget10;
|
||
|
#endif
|
||
|
#if NUM_MORPH_TARGETS > 11
|
||
|
attribute vec3 morphTarget11;
|
||
|
#endif
|
||
|
#endif
|
||
|
#endif
|
||
|
|
||
|
#ifdef USE_SKINNING
|
||
|
attribute vec4 skinIndex;
|
||
|
attribute vec4 skinWeight;
|
||
|
#endif
|
||
|
`].filter(Zo).join("\n"),x=[f,rs(n),"#define SHADER_NAME "+n.shaderName,m,function(e){switch(e){case"blender":return"#define MT_BLENDER";case"max":return"#define MT_MAX";case"maya":return"#define MT_MAYA";default:return""}}(n.materialProfile),e.compatSettings.saturateSpecEnvBlenderApprox?"#define COMPAT_SATURATE_SPEC_ENV_BLENDER_APPROX":"",e.compatSettings.useSpecEnvBlenderApprox?"#define COMPAT_USE_SPEC_ENV_BLENDER_APPROX":"",e.compatSettings.simplifiedSRGB?"#define COMPAT_SIMPLIFIED_SRGB":"",n.alphaTest?"#define ALPHATEST "+n.alphaTest+(n.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+h,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",0!==n.envMapCubeUVTileSize?"#define cubeUV_maxTileSize "+Ri(n.envMapCubeUVTileSize):"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.sheen?"#define USE_SHEEN":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"",n.physicallyCorrectLights?"#define UNITS_SCALE_FACTOR "+p:"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping===ke||n.useHDR?"":"#define TONE_MAPPING",n.toneMapping===ke||n.useHDR?"":yt.tonemapping_pars_fragment,n.toneMapping===ke||n.useHDR?"":function(e,t){let n;switch(t){case 1:n="Linear";break;case 2:n="Reinhard";break;case 3:n="OptimizedCineon";break;case 4:n="ACESFilmic";break;case 6:n="LogarithmicMax";break;case 7:n="PhysicalMax";break;case 8:n="FilmicBlender";break;default:console.warn("v3d.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"(vec3 color) { return "+n+"ToneMapping(color); }"}("toneMapping",n.toneMapping),n.dithering?"#define DITHERING":"",yt.encodings_pars_fragment,n.map?Yo("mapTexelToLinear",n.mapEncoding):"",n.matcap?Yo("matcapTexelToLinear",n.matcapEncoding):"",n.envMap?Yo("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMap?Yo("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.lightMap?Yo("lightMapTexelToLinear",n.lightMapEncoding):"",(i="linearToOutputTexel",h=Xo(h=n.outputEncoding),"vec4 "+i+"(vec4 value) { return LinearTo"+h[0]+h[1]+"; }"),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",n.distancePacking?"#define DISTANCE_PACKING "+n.distancePacking:"",n.useSlopeScaledBias?"#define USE_SLOPE_SCALED_BIAS":"","#define ESM_DISTANCE_SCALE "+Ri(n.esmDistanceScale),n.planeReflProbe?"#define USE_PLANE_REFLECTION":"",n.planeReflProbe?Yo("planeReflProbeT
|
||
|
precision highp float;
|
||
|
precision highp int;
|
||
|
varying vec3 vOutputDirection;
|
||
|
uniform sampler2D envMap;
|
||
|
uniform int samples;
|
||
|
uniform float weights[n];
|
||
|
uniform bool latitudinal;
|
||
|
uniform float dTheta;
|
||
|
uniform float lodIdx;
|
||
|
uniform vec3 poleAxis;
|
||
|
|
||
|
${Jp()}
|
||
|
|
||
|
#define ENVMAP_TYPE_CUBE_UV
|
||
|
#include <cube_uv_reflection_fragment>
|
||
|
|
||
|
vec3 getSample(float theta, vec3 axis) {
|
||
|
float cosTheta = cos(theta);
|
||
|
// Rodrigues' axis-angle rotation
|
||
|
vec3 sampleDirection = vOutputDirection * cosTheta
|
||
|
+ cross(axis, vOutputDirection) * sin(theta)
|
||
|
+ axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);
|
||
|
return bilinearCubeUV(envMap, sampleDirection, lodIdx);
|
||
|
}
|
||
|
|
||
|
void main() {
|
||
|
vec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);
|
||
|
if (all(equal(axis, vec3(0.0))))
|
||
|
axis = vec3(vOutputDirection.z, 0.0, - vOutputDirection.x);
|
||
|
axis = normalize(axis);
|
||
|
gl_FragColor = vec4(0.0);
|
||
|
gl_FragColor.rgb += weights[0] * getSample(0.0, axis);
|
||
|
for (int i = 1; i < n; i++) {
|
||
|
if (i >= samples)
|
||
|
break;
|
||
|
float theta = dTheta * float(i);
|
||
|
gl_FragColor.rgb += weights[i] * getSample(-1.0 * theta, axis);
|
||
|
gl_FragColor.rgb += weights[i] * getSample(theta, axis);
|
||
|
}
|
||
|
gl_FragColor = linearToOutputTexel(gl_FragColor);
|
||
|
}
|
||
|
`,blending:ce,depthTest:!1,depthWrite:!1});return a.type="SphericalGaussianBlur",a}(Rp,this.maxTileSize,this.blurLinEncodingOptimization))}fromScene(t,e=0,n=.1,r=100){zp=x.getRenderTarget();var i=Gp();{var a=t,o=(t=n,n=r,i);const c=new da(90,1,t,n),u=[1,1,1,1,-1,1],d=[1,1,-1,-1,-1,1],h=x.outputEncoding,p=x.toneMapping,f=x.toneMappingExposure,m=x.getClearColor(new _t),v=x.getClearAlpha();x.toneMapping=1,x.toneMappingExposure=1,x.outputEncoding=an,a.scale.z*=-1;let e=a.background;e&&e.isColor&&(e.convertSRGBToLinear(),t=Math.max(e.r,e.g,e.b),n=Math.min(Math.max(Math.ceil(Math.log2(t)),-128),127),e=e.multiplyScalar(Math.pow(2,-n)),t=(n+128)/255,x.setClearColor(e,t),a.background=null);for(let e=0;e<6;e++){var s=e%3,l=(0==s?(c.up.set(0,u[e],0),c.lookAt(d[e],0,0)):1==s?(c.up.set(0,0,u[e]),c.lookAt(0,d[e],0)):(c.up.set(0,u[e],0),c.lookAt(0,0,d[e])),Ep(0));Xp(o,s*l,2<e?l:0,l,l),x.setRenderTarget(o),x.render(a,c)}x.toneMapping=p,x.toneMappingExposure=f,x.outputEncoding=h,x.setClearColor(m,v),a.scale.z*=-1}return 0<e&&Yp(i,0,0,e),jp(i),kp(i),i}fromEquirectangular(e){return e.magFilter=ht,e.minFilter=ht,e.generateMipmaps=!1,this.fromCubemap(e)}fromCubemap(e){zp=x.getRenderTarget();var t=Gp(e);{var n=t,r=this.flipCubemapX;const i=new Js,a=(e.isCubeTexture?null==Op&&(Op=Qp()):null==Dp&&(Dp=qp()),e.isCubeTexture?Op:Dp),o=(i.add(new ee(Fp[0],a)),a.uniforms);(o.envMap.value=e).isCubeTexture?o.flipCubemapX.value=r||!1:o.texelSize.value.set(1/e.image.width,1/e.image.height),o.inputEncoding.value=Pp[e.encoding],o.outputEncoding.value=Pp[e.encoding],r=Ep(0),Xp(n,0,0,3*r,2*r),x.setRenderTarget(n),x.render(i,Ip)}return jp(t),kp(t),t}fromCubeRenderTarget(e,t){t=Gp(e.texture,t);{var n=t,r=this.flipCubemapX;const i=new Js,a=Op=null==Op?Qp():Op,o=(i.add(new ee(Fp[0],a)),a.uniforms),s=(o.envMap.value=e.texture,o.flipCubemapX.value=r||!1,o.inputEncoding.value=Pp[e.texture.encoding],o.outputEncoding.value=Pp[n.texture.encoding],Ep(0));Xp(n,0,0,3*s,2*s),x.setRenderTarget(n),x.render(i,Ip)}return jp(t),kp(t),t}compileCubemapShader(){null==Op&&Wp(Op=Qp())}compileEquirectangularShader(){null==Dp&&Wp(Dp=qp())}dispose(){Np.dispose(),null!=Op&&Op.dispose(),null!=Dp&&Dp.dispose();for(let e=0;e<Fp.length;e++)Fp[e].dispose()}}function Gp(e,t){var n={magFilter:ht,minFilter:ht,generateMipmaps:!1,type:e?e.type:Mt,format:e?e.format:F,encoding:e?e.encoding:sn,depthBuffer:!1,stencilBuffer:!1};Object.assign(n,t);const r=Hp(n);return r.depthBuffer=!e,Bp=Hp(n),r}function kp(e){Bp.dispose(),x.setRenderTarget(zp),e.scissorTest=!1,e.setSize(e.width,e.height)}function Wp(e){const t=new Js;t.add(new ee(Fp[0],e)),x.compile(t,Ip)}function Hp(e){var t=Ep(0);const n=new ze(3*t,3*t,e);return n.texture.mapping=N,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Xp(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function jp(t){var e=x.autoClear;x.autoClear=!1;for(let e=1;e<Cp.length;e++){var n=Cp[e].sigma,r=Cp[e-1].sigma,n=Math.sqrt(n*n-r*r),r=Vp[(e-1)%Vp.length];Yp(t,e-1,e,n,r)}x.autoClear=e}function Yp(e,t,n,r,i){Zp(e,Bp,t,n,r,"latitudinal",i),Zp(Bp,e,n,n,r,"longitudinal",i)}function Zp(e,t,n,r,i,a,o){"latitudinal"!==a&&"longitudinal"!==a&&console.error("blur direction must be either latitudinal or longitudinal!");const s=new Js,l=(s.add(new ee(Fp[r],Np)),Np.uniforms);var c=Ep(n)-1;let u=isFinite(i)?Math.PI/(2*c):2*Math.PI/(2*Rp-1),d=i/u,h=isFinite(i)?1+Math.floor(3*d):Rp;h>Rp&&(h=Rp,d=(Rp-1)/3,u=i/d);const p=[];let f=0;for(let e=0;e<Rp;++e){const g=e/d;var m=Math.exp(-g*g/2);p.push(m),0==e?f+=m:e<h&&(f+=2*m)}for(let e=0;e<p.length;e++)p[e]=p[e]/f;l.envMap.value=e.texture,l.samples.value=h,l.weights.value=p,l.latitudinal.value="latitudinal"===a,o&&(l.poleAxis.value=o),l.dTheta.value=u,l.lodIdx.value=n,l.inputEncoding.value=Pp[e.texture.encoding],l.outputEncoding.value=Pp[e.texture.encoding];const v=Np.defines,[g,_]=(v.cubeUV_maxTileSize=Ri(Ep(0)),v.linEncodingOptimization=Lp?1:0,c=r,Cp[c].origin.map(function(e){return e*Tp*3}));i=Ep(r);Xp(t,g,_,3*i,2*i),x.setRenderTarget(t),x.render(s,Ip)}function qp(){var e=new Be(1,1);const t=new yu({defines:{linEnc
|
||
|
precision mediump float;
|
||
|
precision mediump int;
|
||
|
varying vec3 vOutputDirection;
|
||
|
uniform sampler2D envMap;
|
||
|
uniform vec2 texelSize;
|
||
|
|
||
|
${Jp()}
|
||
|
|
||
|
#define RECIPROCAL_PI 0.31830988618
|
||
|
#define RECIPROCAL_PI2 0.15915494
|
||
|
|
||
|
void main() {
|
||
|
gl_FragColor = vec4(0.0);
|
||
|
vec3 outputDirection = normalize(vOutputDirection);
|
||
|
vec2 uv;
|
||
|
uv.y = asin(clamp(outputDirection.y, -1.0, 1.0)) * RECIPROCAL_PI + 0.5;
|
||
|
uv.x = atan(outputDirection.z, outputDirection.x) * RECIPROCAL_PI2 + 0.5;
|
||
|
vec2 f = fract(uv / texelSize - 0.5);
|
||
|
uv -= f * texelSize;
|
||
|
vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
|
||
|
uv.x += texelSize.x;
|
||
|
vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
|
||
|
uv.y += texelSize.y;
|
||
|
vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
|
||
|
uv.x -= texelSize.x;
|
||
|
vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
|
||
|
vec3 tm = mix(tl, tr, f.x);
|
||
|
vec3 bm = mix(bl, br, f.x);
|
||
|
gl_FragColor.rgb = mix(tm, bm, f.y);
|
||
|
gl_FragColor = linearToOutputTexel(gl_FragColor);
|
||
|
}
|
||
|
`,blending:ce,depthTest:!1,depthWrite:!1});return t.type="EquirectangularToCubeUV",t}function Qp(){const e=new yu({defines:{linEncodingOptimization:0},uniforms:{envMap:{value:null},inputEncoding:{value:Pp[an]},outputEncoding:{value:Pp[an]},flipCubemapX:{value:!0}},vertexShader:Kp(),fragmentShader:`
|
||
|
precision mediump float;
|
||
|
precision mediump int;
|
||
|
varying vec3 vOutputDirection;
|
||
|
uniform samplerCube envMap;
|
||
|
uniform bool flipCubemapX;
|
||
|
|
||
|
${Jp()}
|
||
|
|
||
|
void main() {
|
||
|
gl_FragColor = vec4(0.0);
|
||
|
gl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3(vOutputDirection.x * (flipCubemapX ? -1.0 : 1.0), vOutputDirection.yz))).rgb;
|
||
|
gl_FragColor = linearToOutputTexel(gl_FragColor);
|
||
|
}
|
||
|
`,blending:ce,depthTest:!1,depthWrite:!1});return e.type="CubemapToCubeUV",e}function Kp(){return`
|
||
|
precision mediump float;
|
||
|
precision mediump int;
|
||
|
attribute vec3 position;
|
||
|
attribute vec2 uv;
|
||
|
attribute float faceIndex;
|
||
|
varying vec3 vOutputDirection;
|
||
|
vec3 getDirection(vec2 uv, float face) {
|
||
|
uv = 2.0 * uv - 1.0;
|
||
|
vec3 direction = vec3(uv, 1.0);
|
||
|
if (face == 0.0) {
|
||
|
direction = direction.zyx;
|
||
|
direction.z *= -1.0;
|
||
|
} else if (face == 1.0) {
|
||
|
direction = direction.xzy;
|
||
|
direction.z *= -1.0;
|
||
|
} else if (face == 3.0) {
|
||
|
direction = direction.zyx;
|
||
|
direction.x *= -1.0;
|
||
|
} else if (face == 4.0) {
|
||
|
direction = direction.xzy;
|
||
|
direction.y *= -1.0;
|
||
|
} else if (face == 5.0) {
|
||
|
direction.xz *= -1.0;
|
||
|
}
|
||
|
return direction;
|
||
|
}
|
||
|
void main() {
|
||
|
vOutputDirection = getDirection(uv, faceIndex);
|
||
|
gl_Position = vec4(position, 1.0);
|
||
|
}
|
||
|
`}function Jp(){return`
|
||
|
|
||
|
#if linEncodingOptimization
|
||
|
|
||
|
vec4 linearToOutputTexel(vec4 value) {
|
||
|
return value;
|
||
|
}
|
||
|
|
||
|
vec4 envMapTexelToLinear(vec4 color) {
|
||
|
return color;
|
||
|
}
|
||
|
|
||
|
#else
|
||
|
|
||
|
uniform int inputEncoding;
|
||
|
uniform int outputEncoding;
|
||
|
|
||
|
#include <encodings_pars_fragment>
|
||
|
|
||
|
vec4 inputTexelToLinear(vec4 value){
|
||
|
if(inputEncoding == 0){
|
||
|
return value;
|
||
|
}else if(inputEncoding == 1){
|
||
|
return sRGBToLinear(value);
|
||
|
}else if(inputEncoding == 2){
|
||
|
return RGBEToLinear(value);
|
||
|
}else if(inputEncoding == 3){
|
||
|
return RGBMToLinear(value, 7.0);
|
||
|
}else if(inputEncoding == 4){
|
||
|
return RGBMToLinear(value, 16.0);
|
||
|
}else if(inputEncoding == 5){
|
||
|
return RGBDToLinear(value, 256.0);
|
||
|
}else{
|
||
|
return GammaToLinear(value, 2.2);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
vec4 linearToOutputTexel(vec4 value){
|
||
|
if(outputEncoding == 0){
|
||
|
return value;
|
||
|
}else if(outputEncoding == 1){
|
||
|
return LinearTosRGB(value);
|
||
|
}else if(outputEncoding == 2){
|
||
|
return LinearToRGBE(value);
|
||
|
}else if(outputEncoding == 3){
|
||
|
return LinearToRGBM(value, 7.0);
|
||
|
}else if(outputEncoding == 4){
|
||
|
return LinearToRGBM(value, 16.0);
|
||
|
}else if(outputEncoding == 5){
|
||
|
return LinearToRGBD(value, 256.0);
|
||
|
}else{
|
||
|
return LinearToGamma(value, 2.2);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
vec4 envMapTexelToLinear(vec4 color) {
|
||
|
return inputTexelToLinear(color);
|
||
|
}
|
||
|
|
||
|
#endif
|
||
|
`}mc.create=function(e,t){return console.log("v3d.Curve.create() has been deprecated"),e.prototype=Object.create(mc.prototype),(e.prototype.constructor=e).prototype.getPoint=t,e},Nd.prototype.fromPoints=function(e){return console.warn("v3d.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)},sp.prototype.setColors=function(){console.error("v3d.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},tp.prototype.update=function(){console.error("v3d.SkeletonHelper: update() no longer needs to be called.")},Sd.prototype.extractUrlBase=function(e){return console.warn("v3d.Loader: .extractUrlBase() has been deprecated. Use v3d.LoaderUtils.extractUrlBase() instead."),eh.extractUrlBase(e)},Sd.Handlers={add:function(){console.error("v3d.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("v3d.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Xh.prototype.center=function(e){return console.warn("v3d.Box2: .center() has been renamed to .getCenter()."),this.getCenter(e)},Xh.prototype.empty=function(){return console.warn("v3d.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Xh.prototype.isIntersectionBox=function(e){return console.warn("v3d.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},Xh.prototype.size=function(e){return console.warn("v3d.Box2: .size() has been renamed to .getSize()."),this.getSize(e)},g.prototype.center=function(e){return console.warn("v3d.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},g.prototype.empty=function(){return console.warn("v3d.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},g.prototype.isIntersectionBox=function(e){return console.warn("v3d.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},g.prototype.isIntersectionSphere=function(e){return console.warn("v3d.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},g.prototype.size=function(e){return console.warn("v3d.Box3: .size() has been renamed to .getSize()."),this.getSize(e)},fr.prototype.empty=function(){return console.warn("v3d.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Ma.prototype.setFromMatrix=function(e){return console.warn("v3d.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(e)},Zh.prototype.center=function(e){return console.warn("v3d.Line3: .center() has been renamed to .getCenter()."),this.getCenter(e)},Un.prototype.flattenToArrayOffset=function(e,t){return console.warn("v3d.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},Un.prototype.multiplyVector3=function(e){return console.warn("v3d.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3(matrix) instead."),e.applyMatrix3(this)},Un.prototype.multiplyVector3Array=function(){console.error("v3d.Matrix3: .multiplyVector3Array() has been removed.")},Un.prototype.applyToBufferAttribute=function(e){return console.warn("v3d.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3(matrix) instead."),e.applyMatrix3(this)},Un.prototype.applyToVector3Array=function(){console.error("v3d.Matrix3: .applyToVector3Array() has been removed.")},Un.prototype.getInverse=function(e){return console.warn("v3d.Matrix3: .getInverse() has been removed. Use matrixInv.copy(matrix).invert(); instead."),this.copy(e).invert()},gt.prototype.extractPosition=function(e){return console.warn("v3d.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},gt.prototype.flattenToArrayOffset=function(e,t){return console.warn("v3d.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},gt.prototype.getPosition=function(){return console.warn("v3d.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition(matrix) instead."),(new vt).setF
|
||
|
uniform int faceIdx;
|
||
|
|
||
|
varying vec3 vCubeDirection;
|
||
|
|
||
|
vec3 uvToCubeDirection(vec2 uv, int face) {
|
||
|
vec3 dir;
|
||
|
uv = 2.0 * uv - 1.0;
|
||
|
|
||
|
if (face == 0) {
|
||
|
dir = vec3(1.0, -uv.y, -uv.x);
|
||
|
} else if (face == 1) {
|
||
|
dir = vec3(-1.0, -uv.y, uv.x);
|
||
|
} else if (face == 2) {
|
||
|
dir = vec3(uv.x, 1.0, uv.y);
|
||
|
} else if (face == 3) {
|
||
|
dir = vec3(uv.x, -1.0, -uv.y);
|
||
|
} else if (face == 4) {
|
||
|
dir = vec3(uv.x, -uv.y, 1.0);
|
||
|
} else if (face == 5) {
|
||
|
dir = vec3(-uv.x, -uv.y, -1.0);
|
||
|
}
|
||
|
return dir;
|
||
|
}
|
||
|
|
||
|
void main() {
|
||
|
vCubeDirection = uvToCubeDirection(uv, faceIdx);
|
||
|
gl_Position = vec4(position, 1.0);
|
||
|
}
|
||
|
`,fragmentShader:`
|
||
|
uniform samplerCube cubemap;
|
||
|
|
||
|
varying vec3 vCubeDirection;
|
||
|
|
||
|
void main() {
|
||
|
gl_FragColor = mapTexelToLinear(textureCube(cubemap, vCubeDirection));
|
||
|
|
||
|
#include <tonemapping_fragment>
|
||
|
|
||
|
gl_FragColor = linearToOutputTexel(gl_FragColor);
|
||
|
}
|
||
|
`}),this.shader.map=e,this.shader.uniforms.cubemap.value=e,this.planeMesh=new ee(new Sa(2,2),this.shader),this.scene=new Js,this.scene.add(this.camera),this.scene.add(this.planeMesh)}function g1(e,t){this.sourceTexture=e,this.resolution=void 0!==t?t:256;e=this.resolution,t={format:this.sourceTexture.format,magFilter:this.sourceTexture.magFilter,minFilter:this.sourceTexture.minFilter,type:this.sourceTexture.type,generateMipmaps:this.sourceTexture.generateMipmaps,anisotropy:this.sourceTexture.anisotropy,encoding:this.sourceTexture.encoding};this.renderTarget=new fa(e,e,t),this.renderTarget.texture.name="EquiCube.cube",this.camera=new Rs(-1,1,1,-1,0,1e3),this.shader=new T(E.equicube),this.planeMesh=new ee(new Sa(2,2),this.shader),this.planeMesh.material.side=Ue,this.scene=new Js,this.scene.add(this.planeMesh),this.scene.add(this.camera),this.invertU=!1,this.offsetU=0,this.shader.uniforms.tEquirect.value=this.sourceTexture}Object.defineProperties(m1.prototype,{center:{get:function(){return console.warn("v3d.OrbitControls: .center has been deprecated, use .targetObj instead"),new vt}},target:{get:function(){return console.warn("v3d.OrbitControls: .target has been deprecated, use .targetObj instead"),new vt},set:function(){console.warn("v3d.OrbitControls: .target has been deprecated, use .targetObj instead")}},noZoom:{get:function(){return console.warn("v3d.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),!this.enableZoom},set:function(e){console.warn("v3d.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),this.enableZoom=!e}},noRotate:{get:function(){return console.warn("v3d.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),!this.enableRotate},set:function(e){console.warn("v3d.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),this.enableRotate=!e}},noPan:{get:function(){return console.warn("v3d.OrbitControls: .noPan has been deprecated. Use .enablePan instead."),!this.enablePan},set:function(e){console.warn("v3d.OrbitControls: .noPan has been deprecated. Use .enablePan instead."),this.enablePan=!e}},noKeys:{get:function(){return console.warn("v3d.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),!this.enableKeys},set:function(e){console.warn("v3d.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),this.enableKeys=!e}},staticMoving:{get:function(){return console.warn("v3d.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),!this.enableDamping},set:function(e){console.warn("v3d.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),this.enableDamping=!e}}}),v1.prototype={constructor:v1,render:function(e,t,n=1){var r=e.toneMapping,i=e.toneMappingExposure,a=e.getRenderTarget();e.toneMapping=1,e.toneMappingExposure=n;for(var o=0;o<6;o++)e.setRenderTarget(t,o),this.shader.uniforms.faceIdx.value=o,e.render(this.scene,this.camera);e.toneMapping=r,e.toneMappingExposure=i,e.setRenderTarget(a)},dispose:function(){this.planeMesh.geometry.dispose(),this.planeMesh.material.dispose()}},g1.prototype={constructor:g1,update:function(e){var t=e.gammaInput,n=e.gammaOutput,r=e.toneMapping,i=e.toneMappingExposure,a=e.getRenderTarget();e.toneMapping=1,e.toneMappingExposure=1,e.gammaInput=!1,e.gammaOutput=!1,this.renderToCubeMapTarget(e,this.renderTarget),e.setRenderTarget(a),e.toneMapping=r,e.toneMappingExposure=i,e.gammaInput=t,e.gammaOutput=n},renderToCubeMapTarget:function(e,t){this.shader.uniforms.invertU.value=this.invertU,this.shader.uniforms.offsetU.value=this.offsetU;for(var n=0;n<6;n++)this.renderToCubeMapTargetFace(e,t,n)},renderToCubeMapTargetFace:function(e,t,n){this.shader.uniforms.faceIndex.value=n,e.setRenderTarget(t,n),e.render(this.scene,this.camera)},dispose:function(){this.renderTarget.dispose(),this.planeMesh.geometry.dispose(),this.planeMesh.material.dispose()}};class _1 extends n{constructor(){super(),this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setCamera(e){}setSize(e,t){}dispose(){}render(e,t,n,r,i){console.e
|