You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3396 lines
1.5 MiB
3396 lines
1.5 MiB
4 weeks ago
|
var Si=(w,r,o)=>new Promise((a,v)=>{var h=U=>{try{D(o.next(U))}catch(V){v(V)}},b=U=>{try{D(o.throw(U))}catch(V){v(V)}},D=U=>U.done?a(U.value):Promise.resolve(U.value).then(h,b);D((o=o.apply(w,r)).next())});class PubSub{constructor(){this.events={}}on(r,o){let a=this;a.events||(a.events={}),a.events.hasOwnProperty(r)||(a.events[r]=[]),a.events[r].push(o)}emit(r,...o){let a=this;a.events||(a.events={}),a.events.hasOwnProperty(r)&&a.events[r].map(v=>v(...o))}off(r,o){if(this.events[r])if(o===void 0)this.events[r]=[];else{const a=this.events[r].indexOf(o);this.events[r].splice(a,1)}}}class Store{constructor(r){let o=this;o.actions={},o.mutations={},o.state=r.state,o.status="resting",o.events=new PubSub,r.hasOwnProperty("actions")&&(o.actions=r.actions),r.hasOwnProperty("mutations")&&(o.mutations=r.mutations)}dispatch(r,o){let a=this;return typeof a.actions[r]=="function"&&(console.groupCollapsed(`ACTION: ${r}`),a.status="action",a.actions[r](a,o),console.groupEnd(),!0)}commit(r,o){let a=this;if(typeof a.mutations[r]!="function")return console.log(`Mutation "${r}" doesn't exist`),!1;a.status="mutation";let v=a.mutations[r](a.state,o);return a.state=Object.assign(a.state,v),!0}}const options={state:{MxFun:null,Mxassembly:null,isCreateDrawObj:!1},actions:{},mutations:{}};for(let w in options.state){const r=w.charAt(0).toUpperCase()+w.slice(1);options.mutations["set"+r]=(o,a)=>{o[w]=a}}const store=new Store(options);function mxfun(){(function w(r,o,a){function v(D,U){if(!o[D]){if(!r[D]){var V=typeof require=="function"&&require;if(!U&&V)return V(D,!0);if(h)return h(D,!0);var I=new Error("Cannot find module '"+D+"'");throw I.code="MODULE_NOT_FOUND",I}var g=o[D]={exports:{}};r[D][0].call(g.exports,function(A){return v(r[D][1][A]||A)},g,g.exports,w,r,o,a)}return o[D].exports}for(var h=typeof require=="function"&&require,b=0;b<a.length;b++)v(a[b]);return v})({1:[function(w,r,o){var a={};(0,w("./lib/utils/common").assign)(a,w("./lib/deflate"),w("./lib/inflate"),w("./lib/zlib/constants")),r.exports=a},{"./lib/deflate":2,"./lib/inflate":3,"./lib/utils/common":4,"./lib/zlib/constants":7}],2:[function(w,r,o){var a=w("./zlib/deflate"),v=w("./utils/common"),h=w("./utils/strings"),b=w("./zlib/messages"),D=w("./zlib/zstream"),U=Object.prototype.toString,V=0,I=-1,g=0,A=8;function M(F){if(!(this instanceof M))return new M(F);this.options=v.assign({level:I,method:A,chunkSize:16384,windowBits:15,memLevel:8,strategy:g,to:""},F||{});var T=this.options;T.raw&&0<T.windowBits?T.windowBits=-T.windowBits:T.gzip&&0<T.windowBits&&T.windowBits<16&&(T.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new D,this.strm.avail_out=0;var _=a.deflateInit2(this.strm,T.level,T.method,T.windowBits,T.memLevel,T.strategy);if(_!==V)throw new Error(b[_]);if(T.header&&a.deflateSetHeader(this.strm,T.header),T.dictionary){var Y;if(Y=typeof T.dictionary=="string"?h.string2buf(T.dictionary):U.call(T.dictionary)==="[object ArrayBuffer]"?new Uint8Array(T.dictionary):T.dictionary,(_=a.deflateSetDictionary(this.strm,Y))!==V)throw new Error(b[_]);this._dict_set=!0}}function N(F,T){var _=new M(T);if(_.push(F,!0),_.err)throw _.msg||b[_.err];return _.result}M.prototype.push=function(F,T){var _,Y,k=this.strm,S=this.options.chunkSize;if(this.ended)return!1;Y=T===~~T?T:T===!0?4:0,typeof F=="string"?k.input=h.string2buf(F):U.call(F)==="[object ArrayBuffer]"?k.input=new Uint8Array(F):k.input=F,k.next_in=0,k.avail_in=k.input.length;do{if(k.avail_out===0&&(k.output=new v.Buf8(S),k.next_out=0,k.avail_out=S),(_=a.deflate(k,Y))!==1&&_!==V)return this.onEnd(_),!(this.ended=!0);k.avail_out!==0&&(k.avail_in!==0||Y!==4&&Y!==2)||(this.options.to==="string"?this.onData(h.buf2binstring(v.shrinkBuf(k.output,k.next_out))):this.onData(v.shrinkBuf(k.output,k.next_out)))}while((0<k.avail_in||k.avail_out===0)&&_!==1);return Y===4?(_=a.deflateEnd(this.strm),this.onEnd(_),this.ended=!0,_===V):Y!==2||(this.onEnd(V),!(k.avail_out=0))},M.prototype.onData=function(F){this.chunks.push(F)},M.prototype.onEnd=function(F){F===V&&(this.options.to==="string"?this.result=this.chunks.join(""
|
||
|
`),D.ShaderChunk.meshline_frag=["",D.ShaderChunk.fog_pars_fragment,D.ShaderChunk.logdepthbuf_pars_fragment,"","uniform sampler2D map;","uniform sampler2D alphaMap;","uniform float useMap;","uniform float useAlphaMap;","uniform float useDash;","uniform float dashArray;","uniform float dashOffset;","uniform float dashRatio;","uniform float visibility;","uniform float alphaTest;","uniform vec2 repeat;","","varying vec2 vUV;","varying vec4 vColor;","varying float vCounters;","","void main() {","",D.ShaderChunk.logdepthbuf_fragment,""," vec4 c = vColor;"," if( useMap == 1. ) c *= texture2D( map, vUV * repeat );"," if( useAlphaMap == 1. ) c.a *= texture2D( alphaMap, vUV * repeat ).a;"," if( c.a < alphaTest ) discard;"," if( useDash == 1. ){"," c.a *= ceil(mod(vCounters + dashOffset, dashArray) - (dashArray * dashRatio));"," }"," gl_FragColor = c;"," gl_FragColor.a *= step(vCounters, visibility);","",D.ShaderChunk.fog_fragment,"}"].join(`
|
||
|
`),((I.prototype=Object.create(D.ShaderMaterial.prototype)).constructor=I).prototype.isMeshLineMaterial=!0,I.prototype.copy=function(g){return D.ShaderMaterial.prototype.copy.call(this,g),this.lineWidth=g.lineWidth,this.map=g.map,this.useMap=g.useMap,this.alphaMap=g.alphaMap,this.useAlphaMap=g.useAlphaMap,this.color.copy(g.color),this.opacity=g.opacity,this.resolution.copy(g.resolution),this.sizeAttenuation=g.sizeAttenuation,this.near=g.near,this.far=g.far,this.dashArray.copy(g.dashArray),this.dashOffset.copy(g.dashOffset),this.dashRatio.copy(g.dashRatio),this.useDash=g.useDash,this.visibility=g.visibility,this.alphaTest=g.alphaTest,this.repeat.copy(g.repeat),this},o!==void 0?(r!==void 0&&r.exports&&(o=r.exports={MeshLine:U,MeshLineMaterial:I}),o.MeshLine=U,o.MeshLineMaterial=I):(this.MeshLine=U,this.MeshLineMaterial=I)}).call(this)},{three:19}],19:[function(w,r,o){var a,v;a=this,v=function(h){Number.EPSILON===void 0&&(Number.EPSILON=Math.pow(2,-52)),Number.isInteger===void 0&&(Number.isInteger=function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e}),Math.sign===void 0&&(Math.sign=function(e){return e<0?-1:0<e?1:+e}),"name"in Function.prototype==0&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),Object.assign===void 0&&(Object.assign=function(e){if(e==null)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=1;n<arguments.length;n++){var i=arguments[n];if(i!=null)for(var l in i)Object.prototype.hasOwnProperty.call(i,l)&&(t[l]=i[l])}return t});var b=0,D=1,U=2,V=1,I=2,g=3,A=0,M=1,N=2,F=0,T=0,_=1,Y=2,k=3,S=4,G=5,C=100,B=101,R=102,u=103,c=104,f=200,O=201,W=202,X=203,J=204,te=205,ne=206,ue=207,be=208,je=209,ve=210,Be=0,q=1,ge=2,oe=3,le=4,Pe=5,Ye=6,ze=7,se=0,xe=1,De=2,tt=0,st=1,mt=2,Rt=3,Ot=4,He=5,Vt=301,jt=302,Ln=303,nn=304,er=305,yt=306,Ue=307,Zt=1e3,On=1001,Xn=1002,dt=1003,lt=1004,Xt=1005,xn=1006,$t=1007,Yn=1008,kr=1009,Br=1010,$e=1011,We=1012,ut=1013,Ie=1014,Mt=1015,rn=1016,tn=1017,En=1018,br=1019,Mr=1020,Tr=1021,ti=1022,Gr=1023,ba=1024,Di=1025,wi=Gr,or=1026,ni=1027,H=1028,Nr=1029,Ri=1030,Zn=1031,Xi=1032,xo=1033,Bs=33776,ts=33777,ms=33778,no=33779,ns=35840,la=35841,Fo=35842,Aa=35843,gs=36196,Gs=37808,ro=37809,ys=37810,Oa=37811,vs=37812,io=37813,ao=37814,qr=37815,Dr=37816,rs=37817,xs=37818,is=37819,Bo=37820,Yi=37821,jr=2300,Q=2301,Ce=2400,ce=2401,Te=2402,Ke=3e3,vt=3001,Ft=3007,Jt=3002,In=3003,Gn=3004,sr=3005,hi=3006,oo=3200,Ei=3201,wo=0,Do=1,so=7680,zs=519,Wr=35044,Ma=35048;function ka(){}Object.assign(ka.prototype,{addEventListener:function(e,t){this._listeners===void 0&&(this._listeners={});var n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)},hasEventListener:function(e,t){if(this._listeners===void 0)return!1;var n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1},removeEventListener:function(e,t){if(this._listeners!==void 0){var n=this._listeners[e];if(n!==void 0){var i=n.indexOf(t);i!==-1&&n.splice(i,1)}}},dispatchEvent:function(e){if(this._listeners!==void 0){var t=this._listeners[e.type];if(t!==void 0){e.target=this;for(var n=t.slice(0),i=0,l=n.length;i<l;i++)n[i].call(this,e)}}}});for(var na=[],Go=0;Go<256;Go++)na[Go]=(Go<16?"0":"")+Go.toString(16);var ws,yr={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(na[255&e]+na[e>>8&255]+na[e>>16&255]+na[e>>24&255]+"-"+na[255&t]+na[t>>8&255]+"-"+na[t>>16&15|64]+na[t>>24&255]+"-"+na[63&n|128]+na[n>>8&255]+"-"+na[n>>16&255]+na[n>>24&255]+na[255&i]+na[i>>8&255]+na[i>>16&255]+na[i>>24&255]).toUpperCase()},clamp:function(e,t,n){return Math.max(t,Math.min(n,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,n,i,l){return i+(e-t)*(l-i)/(n-t)},lerp:function(e,t,n){return(1-n)*e+n*t},smoothstep:function(e,t,n){return e<=t?0:n<=e?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:n<=e?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:fu
|
||
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
|
}`,ch=`void main() {
|
||
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
||
|
}`;function Ya(e){It.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=uc,this.fragmentShader=ch,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,e!==void 0&&(e.attributes!==void 0&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}function Lo(){Pt.call(this),this.type="Camera",this.matrixWorldInverse=new fr,this.projectionMatrix=new fr,this.projectionMatrixInverse=new fr}function Ni(e,t,n,i){Lo.call(this),this.type="PerspectiveCamera",this.fov=e!==void 0?e:50,this.zoom=1,this.near=n!==void 0?n:.1,this.far=i!==void 0?i:2e3,this.focus=10,this.aspect=t!==void 0?t:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function Ys(e,t,n,i){Pt.call(this),this.type="CubeCamera";var l=new Ni(90,1,e,t);l.up.set(0,-1,0),l.lookAt(new Re(1,0,0)),this.add(l);var d=new Ni(90,1,e,t);d.up.set(0,-1,0),d.lookAt(new Re(-1,0,0)),this.add(d);var m=new Ni(90,1,e,t);m.up.set(0,0,1),m.lookAt(new Re(0,1,0)),this.add(m);var x=new Ni(90,1,e,t);x.up.set(0,0,-1),x.lookAt(new Re(0,-1,0)),this.add(x);var L=new Ni(90,1,e,t);L.up.set(0,-1,0),L.lookAt(new Re(0,0,1)),this.add(L);var j=new Ni(90,1,e,t);j.up.set(0,-1,0),j.lookAt(new Re(0,0,-1)),this.add(j),i=i||{format:ti,magFilter:xn,minFilter:xn},this.renderTarget=new Zs(n,i),this.renderTarget.texture.name="CubeCamera",this.update=function(Z,ee){this.parent===null&&this.updateMatrixWorld();var ie=Z.getRenderTarget(),z=this.renderTarget,he=z.texture.generateMipmaps;z.texture.generateMipmaps=!1,Z.setRenderTarget(z,0),Z.render(ee,l),Z.setRenderTarget(z,1),Z.render(ee,d),Z.setRenderTarget(z,2),Z.render(ee,m),Z.setRenderTarget(z,3),Z.render(ee,x),Z.setRenderTarget(z,4),Z.render(ee,L),z.texture.generateMipmaps=he,Z.setRenderTarget(z,5),Z.render(ee,j),Z.setRenderTarget(ie)},this.clear=function(Z,ee,ie,z){for(var he=Z.getRenderTarget(),me=this.renderTarget,ye=0;ye<6;ye++)Z.setRenderTarget(me,ye),Z.clear(ee,ie,z);Z.setRenderTarget(he)}}function Zs(e,t,n){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=n),Zi.call(this,e,e,t)}function Rl(e,t,n,i,l,d,m,x,L,j,Z,ee){Xr.call(this,null,d,m,x,L,j,i,l,Z,ee),this.image={data:e||null,width:t||1,height:n||1},this.magFilter=L!==void 0?L:dt,this.minFilter=j!==void 0?j:dt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}((Ya.prototype=Object.create(It.prototype)).constructor=Ya).prototype.isShaderMaterial=!0,Ya.prototype.copy=function(e){return It.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ss(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=e.extensions,this},Ya.prototype.toJSON=function(e){var t=It.prototype.toJSON.call(this,e);for(var n in t.uniforms={},this.uniforms){var i=this.uniforms[n].value;i&&i.isTexture?t.uniforms[n]={type:"t",value:i.toJSON(e).uuid}:i&&i.isColor?t.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?t.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?t.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?t.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?t.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?t.uniforms[n]={type:"m4",value:i.toArray()}:t.uniforms[n]={value:i}}0<Object.keys(this.defines).length&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;var l={};for(var d in this.extensions)this.extensions[d]===!0
|
||
|
`),fragmentShader:["uniform sampler2D tEquirect;","varying vec3 vWorldDirection;","#define RECIPROCAL_PI 0.31830988618","#define RECIPROCAL_PI2 0.15915494","void main() {"," vec3 direction = normalize( vWorldDirection );"," vec2 sampleUV;"," sampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;"," sampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;"," gl_FragColor = texture2D( tEquirect, sampleUV );","}"].join(`
|
||
|
`)},l=new Ya({type:"CubemapFromEquirect",uniforms:Ss(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:M,blending:T});l.uniforms.tEquirect.value=t;var d=new Ti(new cc(5,5,5),l);n.add(d);var m=new Ys(1,10,1);return m.renderTarget=this,m.renderTarget.texture.name="CubeCameraTexture",m.update(e,n),d.geometry.dispose(),d.material.dispose(),this},((Rl.prototype=Object.create(Xr.prototype)).constructor=Rl).prototype.isDataTexture=!0;var Ks=new Zr,$s=new Re;function Qs(e,t,n,i,l,d){this.planes=[e!==void 0?e:new ia,t!==void 0?t:new ia,n!==void 0?n:new ia,i!==void 0?i:new ia,l!==void 0?l:new ia,d!==void 0?d:new ia]}Object.assign(Qs.prototype,{set:function(e,t,n,i,l,d){var m=this.planes;return m[0].copy(e),m[1].copy(t),m[2].copy(n),m[3].copy(i),m[4].copy(l),m[5].copy(d),this},clone:function(){return new this.constructor().copy(this)},copy:function(e){for(var t=this.planes,n=0;n<6;n++)t[n].copy(e.planes[n]);return this},setFromProjectionMatrix:function(e){var t=this.planes,n=e.elements,i=n[0],l=n[1],d=n[2],m=n[3],x=n[4],L=n[5],j=n[6],Z=n[7],ee=n[8],ie=n[9],z=n[10],he=n[11],me=n[12],ye=n[13],Ae=n[14],Le=n[15];return t[0].setComponents(m-i,Z-x,he-ee,Le-me).normalize(),t[1].setComponents(m+i,Z+x,he+ee,Le+me).normalize(),t[2].setComponents(m+l,Z+L,he+ie,Le+ye).normalize(),t[3].setComponents(m-l,Z-L,he-ie,Le-ye).normalize(),t[4].setComponents(m-d,Z-j,he-z,Le-Ae).normalize(),t[5].setComponents(m+d,Z+j,he+z,Le+Ae).normalize(),this},intersectsObject:function(e){var t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),Ks.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Ks)},intersectsSprite:function(e){return Ks.center.set(0,0,0),Ks.radius=.7071067811865476,Ks.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ks)},intersectsSphere:function(e){for(var t=this.planes,n=e.center,i=-e.radius,l=0;l<6;l++)if(t[l].distanceToPoint(n)<i)return!1;return!0},intersectsBox:function(e){for(var t=this.planes,n=0;n<6;n++){var i=t[n];if($s.x=0<i.normal.x?e.max.x:e.min.x,$s.y=0<i.normal.y?e.max.y:e.min.y,$s.z=0<i.normal.z?e.max.z:e.min.z,i.distanceToPoint($s)<0)return!1}return!0},containsPoint:function(e){for(var t=this.planes,n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}});var wn={common:{diffuse:{value:new Qe(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Ai},uv2Transform:{value:new Ai},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new zt(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new Qe(15658734)},opacity:{value
|
||
|
diffuseColor.a *= texture2D( alphaMap, vUv ).g;
|
||
|
#endif`,alphamap_pars_fragment:`#ifdef USE_ALPHAMAP
|
||
|
uniform sampler2D alphaMap;
|
||
|
#endif`,alphatest_fragment:`#ifdef ALPHATEST
|
||
|
if ( diffuseColor.a < ALPHATEST ) discard;
|
||
|
#endif`,aomap_fragment:`#ifdef USE_AOMAP
|
||
|
float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
|
||
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
||
|
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
||
|
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
|
||
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );
|
||
|
#endif
|
||
|
#endif`,aomap_pars_fragment:`#ifdef USE_AOMAP
|
||
|
uniform sampler2D aoMap;
|
||
|
uniform float aoMapIntensity;
|
||
|
#endif`,begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:`vec3 objectNormal = vec3( normal );
|
||
|
#ifdef USE_TANGENT
|
||
|
vec3 objectTangent = vec3( tangent.xyz );
|
||
|
#endif`,bsdfs:`vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {
|
||
|
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
|
||
|
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
|
||
|
vec4 r = roughness * c0 + c1;
|
||
|
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
|
||
|
return vec2( -1.04, 1.04 ) * a004 + r.zw;
|
||
|
}
|
||
|
float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
|
||
|
#if defined ( PHYSICALLY_CORRECT_LIGHTS )
|
||
|
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
|
||
|
if( cutoffDistance > 0.0 ) {
|
||
|
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
|
||
|
}
|
||
|
return distanceFalloff;
|
||
|
#else
|
||
|
if( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
|
||
|
return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );
|
||
|
}
|
||
|
return 1.0;
|
||
|
#endif
|
||
|
}
|
||
|
vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {
|
||
|
return RECIPROCAL_PI * diffuseColor;
|
||
|
}
|
||
|
vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {
|
||
|
float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );
|
||
|
return ( 1.0 - specularColor ) * fresnel + specularColor;
|
||
|
}
|
||
|
vec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {
|
||
|
float fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );
|
||
|
vec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;
|
||
|
return Fr * fresnel + F0;
|
||
|
}
|
||
|
float G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {
|
||
|
float a2 = pow2( alpha );
|
||
|
float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
||
|
float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
||
|
return 1.0 / ( gl * gv );
|
||
|
}
|
||
|
float G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
||
|
float a2 = pow2( alpha );
|
||
|
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
||
|
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
||
|
return 0.5 / max( gv + gl, EPSILON );
|
||
|
}
|
||
|
float D_GGX( const in float alpha, const in float dotNH ) {
|
||
|
float a2 = pow2( alpha );
|
||
|
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
||
|
return RECIPROCAL_PI * a2 / pow2( denom );
|
||
|
}
|
||
|
vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {
|
||
|
float alpha = pow2( roughness );
|
||
|
vec3 halfDir = normalize( incidentLight.direction + viewDir );
|
||
|
float dotNL = saturate( dot( normal, incidentLight.direction ) );
|
||
|
float dotNV = saturate( dot( normal, viewDir ) );
|
||
|
float dotNH = saturate( dot( normal, halfDir ) );
|
||
|
float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
|
||
|
vec3 F = F_Schlick( specularColor, dotLH );
|
||
|
float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
||
|
float D = D_GGX( alpha, dotNH );
|
||
|
return F * ( G * D );
|
||
|
}
|
||
|
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
||
|
const float LUT_SIZE = 64.0;
|
||
|
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
||
|
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
||
|
float dotNV = saturate( dot( N, V ) );
|
||
|
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
||
|
uv = uv * LUT_SCALE + LUT_BIAS;
|
||
|
return uv;
|
||
|
}
|
||
|
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
||
|
float l = length( f );
|
||
|
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
||
|
}
|
||
|
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
||
|
float x = dot( v1, v2 );
|
||
|
float y = abs( x );
|
||
|
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
||
|
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
||
|
float v = a / b;
|
||
|
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
||
|
return cross( v1, v2 ) * theta_sintheta;
|
||
|
}
|
||
|
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
||
|
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
||
|
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
||
|
vec3 lightNormal = cross( v1, v2 );
|
||
|
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
||
|
vec3 T1, T2;
|
||
|
T1 = normalize( V - N * dot( V, N ) );
|
||
|
T2 = - cross( N, T1 );
|
||
|
mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
|
||
|
vec3 coords[ 4 ];
|
||
|
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
||
|
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
||
|
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
||
|
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
||
|
coords[ 0 ] = normalize( coords[ 0 ] );
|
||
|
coords[ 1 ] = normalize( coords[ 1 ] );
|
||
|
coords[ 2 ] = normalize( coords[ 2 ] );
|
||
|
coords[ 3 ] = normalize( coords[ 3 ] );
|
||
|
vec3 vectorFormFactor = vec3( 0.0 );
|
||
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
||
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
||
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
||
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
||
|
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
||
|
return vec3( result );
|
||
|
}
|
||
|
vec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {
|
||
|
float dotNV = saturate( dot( normal, viewDir ) );
|
||
|
vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
|
||
|
return specularColor * brdf.x + brdf.y;
|
||
|
}
|
||
|
void BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
||
|
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
|
||
|
vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );
|
||
|
vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
|
||
|
vec3 FssEss = F * brdf.x + brdf.y;
|
||
|
float Ess = brdf.x + brdf.y;
|
||
|
float Ems = 1.0 - Ess;
|
||
|
vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
||
|
singleScatter += FssEss;
|
||
|
multiScatter += Fms * Ems;
|
||
|
}
|
||
|
float G_BlinnPhong_Implicit( ) {
|
||
|
return 0.25;
|
||
|
}
|
||
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
||
|
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
|
||
|
}
|
||
|
vec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {
|
||
|
vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );
|
||
|
float dotNH = saturate( dot( geometry.normal, halfDir ) );
|
||
|
float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
|
||
|
vec3 F = F_Schlick( specularColor, dotLH );
|
||
|
float G = G_BlinnPhong_Implicit( );
|
||
|
float D = D_BlinnPhong( shininess, dotNH );
|
||
|
return F * ( G * D );
|
||
|
}
|
||
|
float GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {
|
||
|
return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );
|
||
|
}
|
||
|
float BlinnExponentToGGXRoughness( const in float blinnExponent ) {
|
||
|
return sqrt( 2.0 / ( blinnExponent + 2.0 ) );
|
||
|
}
|
||
|
#if defined( USE_SHEEN )
|
||
|
float D_Charlie(float roughness, float NoH) {
|
||
|
float invAlpha = 1.0 / roughness;
|
||
|
float cos2h = NoH * NoH;
|
||
|
float sin2h = max(1.0 - cos2h, 0.0078125); return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);
|
||
|
}
|
||
|
float V_Neubelt(float NoV, float NoL) {
|
||
|
return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));
|
||
|
}
|
||
|
vec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {
|
||
|
vec3 N = geometry.normal;
|
||
|
vec3 V = geometry.viewDir;
|
||
|
vec3 H = normalize( V + L );
|
||
|
float dotNH = saturate( dot( N, H ) );
|
||
|
return specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );
|
||
|
}
|
||
|
#endif`,bumpmap_pars_fragment:`#ifdef USE_BUMPMAP
|
||
|
uniform sampler2D bumpMap;
|
||
|
uniform float bumpScale;
|
||
|
vec2 dHdxy_fwd() {
|
||
|
vec2 dSTdx = dFdx( vUv );
|
||
|
vec2 dSTdy = dFdy( vUv );
|
||
|
float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
|
||
|
float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
|
||
|
float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
|
||
|
return vec2( dBx, dBy );
|
||
|
}
|
||
|
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {
|
||
|
vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );
|
||
|
vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );
|
||
|
vec3 vN = surf_norm;
|
||
|
vec3 R1 = cross( vSigmaY, vN );
|
||
|
vec3 R2 = cross( vN, vSigmaX );
|
||
|
float fDet = dot( vSigmaX, R1 );
|
||
|
fDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
|
||
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
||
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
||
|
}
|
||
|
#endif`,clipping_planes_fragment:`#if NUM_CLIPPING_PLANES > 0
|
||
|
vec4 plane;
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
||
|
plane = clippingPlanes[ i ];
|
||
|
if ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;
|
||
|
}
|
||
|
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
||
|
bool clipped = true;
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
||
|
plane = clippingPlanes[ i ];
|
||
|
clipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;
|
||
|
}
|
||
|
if ( clipped ) discard;
|
||
|
#endif
|
||
|
#endif`,clipping_planes_pars_fragment:`#if NUM_CLIPPING_PLANES > 0
|
||
|
#if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )
|
||
|
varying vec3 vViewPosition;
|
||
|
#endif
|
||
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
||
|
#endif`,clipping_planes_pars_vertex:`#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )
|
||
|
varying vec3 vViewPosition;
|
||
|
#endif`,clipping_planes_vertex:`#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )
|
||
|
vViewPosition = - mvPosition.xyz;
|
||
|
#endif`,color_fragment:`#ifdef USE_COLOR
|
||
|
diffuseColor.rgb *= vColor;
|
||
|
#endif`,color_pars_fragment:`#ifdef USE_COLOR
|
||
|
varying vec3 vColor;
|
||
|
#endif`,color_pars_vertex:`#ifdef USE_COLOR
|
||
|
varying vec3 vColor;
|
||
|
#endif`,color_vertex:`#ifdef USE_COLOR
|
||
|
vColor.xyz = color.xyz;
|
||
|
#endif`,common:`#define PI 3.14159265359
|
||
|
#define PI2 6.28318530718
|
||
|
#define PI_HALF 1.5707963267949
|
||
|
#define RECIPROCAL_PI 0.31830988618
|
||
|
#define RECIPROCAL_PI2 0.15915494
|
||
|
#define LOG2 1.442695
|
||
|
#define EPSILON 1e-6
|
||
|
#ifndef saturate
|
||
|
#define saturate(a) clamp( a, 0.0, 1.0 )
|
||
|
#endif
|
||
|
#define whiteComplement(a) ( 1.0 - saturate( a ) )
|
||
|
float pow2( const in float x ) { return x*x; }
|
||
|
float pow3( const in float x ) { return x*x*x; }
|
||
|
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
||
|
float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
|
||
|
highp float rand( const in vec2 uv ) {
|
||
|
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
||
|
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
||
|
return fract(sin(sn) * c);
|
||
|
}
|
||
|
#ifdef HIGH_PRECISION
|
||
|
float precisionSafeLength( vec3 v ) { return length( v ); }
|
||
|
#else
|
||
|
float max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
||
|
float precisionSafeLength( vec3 v ) {
|
||
|
float maxComponent = max3( abs( v ) );
|
||
|
return length( v / maxComponent ) * maxComponent;
|
||
|
}
|
||
|
#endif
|
||
|
struct IncidentLight {
|
||
|
vec3 color;
|
||
|
vec3 direction;
|
||
|
bool visible;
|
||
|
};
|
||
|
struct ReflectedLight {
|
||
|
vec3 directDiffuse;
|
||
|
vec3 directSpecular;
|
||
|
vec3 indirectDiffuse;
|
||
|
vec3 indirectSpecular;
|
||
|
};
|
||
|
struct GeometricContext {
|
||
|
vec3 position;
|
||
|
vec3 normal;
|
||
|
vec3 viewDir;
|
||
|
#ifdef CLEARCOAT
|
||
|
vec3 clearcoatNormal;
|
||
|
#endif
|
||
|
};
|
||
|
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
||
|
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
||
|
}
|
||
|
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
||
|
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
||
|
}
|
||
|
vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
|
||
|
float distance = dot( planeNormal, point - pointOnPlane );
|
||
|
return - distance * planeNormal + point;
|
||
|
}
|
||
|
float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
|
||
|
return sign( dot( point - pointOnPlane, planeNormal ) );
|
||
|
}
|
||
|
vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {
|
||
|
return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;
|
||
|
}
|
||
|
mat3 transposeMat3( const in mat3 m ) {
|
||
|
mat3 tmp;
|
||
|
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
|
||
|
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
|
||
|
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
|
||
|
return tmp;
|
||
|
}
|
||
|
float linearToRelativeLuminance( const in vec3 color ) {
|
||
|
vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );
|
||
|
return dot( weights, color.rgb );
|
||
|
}
|
||
|
bool isPerspectiveMatrix( mat4 m ) {
|
||
|
return m[ 2 ][ 3 ] == - 1.0;
|
||
|
}`,cube_uv_reflection_fragment:`#ifdef ENVMAP_TYPE_CUBE_UV
|
||
|
#define cubeUV_maxMipLevel 8.0
|
||
|
#define cubeUV_minMipLevel 4.0
|
||
|
#define cubeUV_maxTileSize 256.0
|
||
|
#define cubeUV_minTileSize 16.0
|
||
|
float getFace(vec3 direction) {
|
||
|
vec3 absDirection = abs(direction);
|
||
|
float face = -1.0;
|
||
|
if (absDirection.x > absDirection.z) {
|
||
|
if (absDirection.x > absDirection.y)
|
||
|
face = direction.x > 0.0 ? 0.0 : 3.0;
|
||
|
else
|
||
|
face = direction.y > 0.0 ? 1.0 : 4.0;
|
||
|
} else {
|
||
|
if (absDirection.z > absDirection.y)
|
||
|
face = direction.z > 0.0 ? 2.0 : 5.0;
|
||
|
else
|
||
|
face = direction.y > 0.0 ? 1.0 : 4.0;
|
||
|
}
|
||
|
return face;
|
||
|
}
|
||
|
vec2 getUV(vec3 direction, float face) {
|
||
|
vec2 uv;
|
||
|
if (face == 0.0) {
|
||
|
uv = vec2(-direction.z, direction.y) / abs(direction.x);
|
||
|
} else if (face == 1.0) {
|
||
|
uv = vec2(direction.x, -direction.z) / abs(direction.y);
|
||
|
} else if (face == 2.0) {
|
||
|
uv = direction.xy / abs(direction.z);
|
||
|
} else if (face == 3.0) {
|
||
|
uv = vec2(direction.z, direction.y) / abs(direction.x);
|
||
|
} else if (face == 4.0) {
|
||
|
uv = direction.xz / abs(direction.y);
|
||
|
} else {
|
||
|
uv = vec2(-direction.x, direction.y) / abs(direction.z);
|
||
|
}
|
||
|
return 0.5 * (uv + 1.0);
|
||
|
}
|
||
|
vec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
|
||
|
float face = getFace(direction);
|
||
|
float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
|
||
|
mipInt = max(mipInt, cubeUV_minMipLevel);
|
||
|
float faceSize = exp2(mipInt);
|
||
|
float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);
|
||
|
vec2 uv = getUV(direction, face) * (faceSize - 1.0);
|
||
|
vec2 f = fract(uv);
|
||
|
uv += 0.5 - f;
|
||
|
if (face > 2.0) {
|
||
|
uv.y += faceSize;
|
||
|
face -= 3.0;
|
||
|
}
|
||
|
uv.x += face * faceSize;
|
||
|
if(mipInt < cubeUV_maxMipLevel){
|
||
|
uv.y += 2.0 * cubeUV_maxTileSize;
|
||
|
}
|
||
|
uv.y += filterInt * 2.0 * cubeUV_minTileSize;
|
||
|
uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);
|
||
|
uv *= texelSize;
|
||
|
vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
|
||
|
uv.x += texelSize;
|
||
|
vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
|
||
|
uv.y += texelSize;
|
||
|
vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
|
||
|
uv.x -= texelSize;
|
||
|
vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;
|
||
|
vec3 tm = mix(tl, tr, f.x);
|
||
|
vec3 bm = mix(bl, br, f.x);
|
||
|
return mix(tm, bm, f.y);
|
||
|
}
|
||
|
#define r0 1.0
|
||
|
#define v0 0.339
|
||
|
#define m0 -2.0
|
||
|
#define r1 0.8
|
||
|
#define v1 0.276
|
||
|
#define m1 -1.0
|
||
|
#define r4 0.4
|
||
|
#define v4 0.046
|
||
|
#define m4 2.0
|
||
|
#define r5 0.305
|
||
|
#define v5 0.016
|
||
|
#define m5 3.0
|
||
|
#define r6 0.21
|
||
|
#define v6 0.0038
|
||
|
#define m6 4.0
|
||
|
float roughnessToMip(float roughness) {
|
||
|
float mip = 0.0;
|
||
|
if (roughness >= r1) {
|
||
|
mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
|
||
|
} else if (roughness >= r4) {
|
||
|
mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;
|
||
|
} else if (roughness >= r5) {
|
||
|
mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;
|
||
|
} else if (roughness >= r6) {
|
||
|
mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;
|
||
|
} else {
|
||
|
mip = -2.0 * log2(1.16 * roughness); }
|
||
|
return mip;
|
||
|
}
|
||
|
vec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {
|
||
|
float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);
|
||
|
float mipF = fract(mip);
|
||
|
float mipInt = floor(mip);
|
||
|
vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);
|
||
|
if (mipF == 0.0) {
|
||
|
return vec4(color0, 1.0);
|
||
|
} else {
|
||
|
vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);
|
||
|
return vec4(mix(color0, color1, mipF), 1.0);
|
||
|
}
|
||
|
}
|
||
|
#endif`,defaultnormal_vertex:`vec3 transformedNormal = objectNormal;
|
||
|
#ifdef USE_INSTANCING
|
||
|
transformedNormal = mat3( instanceMatrix ) * transformedNormal;
|
||
|
#endif
|
||
|
transformedNormal = normalMatrix * transformedNormal;
|
||
|
#ifdef FLIP_SIDED
|
||
|
transformedNormal = - transformedNormal;
|
||
|
#endif
|
||
|
#ifdef USE_TANGENT
|
||
|
vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
||
|
#ifdef FLIP_SIDED
|
||
|
transformedTangent = - transformedTangent;
|
||
|
#endif
|
||
|
#endif`,displacementmap_pars_vertex:`#ifdef USE_DISPLACEMENTMAP
|
||
|
uniform sampler2D displacementMap;
|
||
|
uniform float displacementScale;
|
||
|
uniform float displacementBias;
|
||
|
#endif`,displacementmap_vertex:`#ifdef USE_DISPLACEMENTMAP
|
||
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
|
||
|
#endif`,emissivemap_fragment:`#ifdef USE_EMISSIVEMAP
|
||
|
vec4 emissiveColor = texture2D( emissiveMap, vUv );
|
||
|
emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;
|
||
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
||
|
#endif`,emissivemap_pars_fragment:`#ifdef USE_EMISSIVEMAP
|
||
|
uniform sampler2D emissiveMap;
|
||
|
#endif`,encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:`
|
||
|
vec4 LinearToLinear( in vec4 value ) {
|
||
|
return value;
|
||
|
}
|
||
|
vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {
|
||
|
return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );
|
||
|
}
|
||
|
vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {
|
||
|
return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );
|
||
|
}
|
||
|
vec4 sRGBToLinear( in vec4 value ) {
|
||
|
return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
|
||
|
}
|
||
|
vec4 LinearTosRGB( in vec4 value ) {
|
||
|
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
|
||
|
}
|
||
|
vec4 RGBEToLinear( in vec4 value ) {
|
||
|
return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );
|
||
|
}
|
||
|
vec4 LinearToRGBE( in vec4 value ) {
|
||
|
float maxComponent = max( max( value.r, value.g ), value.b );
|
||
|
float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );
|
||
|
return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );
|
||
|
}
|
||
|
vec4 RGBMToLinear( in vec4 value, in float maxRange ) {
|
||
|
return vec4( value.rgb * value.a * maxRange, 1.0 );
|
||
|
}
|
||
|
vec4 LinearToRGBM( in vec4 value, in float maxRange ) {
|
||
|
float maxRGB = max( value.r, max( value.g, value.b ) );
|
||
|
float M = clamp( maxRGB / maxRange, 0.0, 1.0 );
|
||
|
M = ceil( M * 255.0 ) / 255.0;
|
||
|
return vec4( value.rgb / ( M * maxRange ), M );
|
||
|
}
|
||
|
vec4 RGBDToLinear( in vec4 value, in float maxRange ) {
|
||
|
return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );
|
||
|
}
|
||
|
vec4 LinearToRGBD( in vec4 value, in float maxRange ) {
|
||
|
float maxRGB = max( value.r, max( value.g, value.b ) );
|
||
|
float D = max( maxRange / maxRGB, 1.0 );
|
||
|
D = clamp( floor( D ) / 255.0, 0.0, 1.0 );
|
||
|
return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );
|
||
|
}
|
||
|
const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );
|
||
|
vec4 LinearToLogLuv( in vec4 value ) {
|
||
|
vec3 Xp_Y_XYZp = cLogLuvM * value.rgb;
|
||
|
Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );
|
||
|
vec4 vResult;
|
||
|
vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;
|
||
|
float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;
|
||
|
vResult.w = fract( Le );
|
||
|
vResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;
|
||
|
return vResult;
|
||
|
}
|
||
|
const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );
|
||
|
vec4 LogLuvToLinear( in vec4 value ) {
|
||
|
float Le = value.z * 255.0 + value.w;
|
||
|
vec3 Xp_Y_XYZp;
|
||
|
Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );
|
||
|
Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;
|
||
|
Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;
|
||
|
vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;
|
||
|
return vec4( max( vRGB, 0.0 ), 1.0 );
|
||
|
}`,envmap_fragment:`#ifdef USE_ENVMAP
|
||
|
#ifdef ENV_WORLDPOS
|
||
|
vec3 cameraToFrag;
|
||
|
|
||
|
if ( isOrthographic ) {
|
||
|
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
||
|
} else {
|
||
|
cameraToFrag = normalize( vWorldPosition - cameraPosition );
|
||
|
}
|
||
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
||
|
#ifdef ENVMAP_MODE_REFLECTION
|
||
|
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
|
||
|
#else
|
||
|
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
|
||
|
#endif
|
||
|
#else
|
||
|
vec3 reflectVec = vReflect;
|
||
|
#endif
|
||
|
#ifdef ENVMAP_TYPE_CUBE
|
||
|
vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
|
||
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
||
|
vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );
|
||
|
#elif defined( ENVMAP_TYPE_EQUIREC )
|
||
|
vec2 sampleUV;
|
||
|
reflectVec = normalize( reflectVec );
|
||
|
sampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
||
|
sampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;
|
||
|
vec4 envColor = texture2D( envMap, sampleUV );
|
||
|
#elif defined( ENVMAP_TYPE_SPHERE )
|
||
|
reflectVec = normalize( reflectVec );
|
||
|
vec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );
|
||
|
vec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );
|
||
|
#else
|
||
|
vec4 envColor = vec4( 0.0 );
|
||
|
#endif
|
||
|
#ifndef ENVMAP_TYPE_CUBE_UV
|
||
|
envColor = envMapTexelToLinear( envColor );
|
||
|
#endif
|
||
|
#ifdef ENVMAP_BLENDING_MULTIPLY
|
||
|
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
|
||
|
#elif defined( ENVMAP_BLENDING_MIX )
|
||
|
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
|
||
|
#elif defined( ENVMAP_BLENDING_ADD )
|
||
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
||
|
#endif
|
||
|
#endif`,envmap_common_pars_fragment:`#ifdef USE_ENVMAP
|
||
|
uniform float envMapIntensity;
|
||
|
uniform float flipEnvMap;
|
||
|
uniform int maxMipLevel;
|
||
|
#ifdef ENVMAP_TYPE_CUBE
|
||
|
uniform samplerCube envMap;
|
||
|
#else
|
||
|
uniform sampler2D envMap;
|
||
|
#endif
|
||
|
|
||
|
#endif`,envmap_pars_fragment:`#ifdef USE_ENVMAP
|
||
|
uniform float reflectivity;
|
||
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
|
||
|
#define ENV_WORLDPOS
|
||
|
#endif
|
||
|
#ifdef ENV_WORLDPOS
|
||
|
varying vec3 vWorldPosition;
|
||
|
uniform float refractionRatio;
|
||
|
#else
|
||
|
varying vec3 vReflect;
|
||
|
#endif
|
||
|
#endif`,envmap_pars_vertex:`#ifdef USE_ENVMAP
|
||
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )
|
||
|
#define ENV_WORLDPOS
|
||
|
#endif
|
||
|
#ifdef ENV_WORLDPOS
|
||
|
|
||
|
varying vec3 vWorldPosition;
|
||
|
#else
|
||
|
varying vec3 vReflect;
|
||
|
uniform float refractionRatio;
|
||
|
#endif
|
||
|
#endif`,envmap_physical_pars_fragment:`#if defined( USE_ENVMAP )
|
||
|
#ifdef ENVMAP_MODE_REFRACTION
|
||
|
uniform float refractionRatio;
|
||
|
#endif
|
||
|
vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {
|
||
|
vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
|
||
|
#ifdef ENVMAP_TYPE_CUBE
|
||
|
vec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );
|
||
|
#ifdef TEXTURE_LOD_EXT
|
||
|
vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );
|
||
|
#else
|
||
|
vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );
|
||
|
#endif
|
||
|
envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
|
||
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
||
|
vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
|
||
|
#else
|
||
|
vec4 envMapColor = vec4( 0.0 );
|
||
|
#endif
|
||
|
return PI * envMapColor.rgb * envMapIntensity;
|
||
|
}
|
||
|
float getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {
|
||
|
float maxMIPLevelScalar = float( maxMIPLevel );
|
||
|
float sigma = PI * roughness * roughness / ( 1.0 + roughness );
|
||
|
float desiredMIPLevel = maxMIPLevelScalar + log2( sigma );
|
||
|
return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );
|
||
|
}
|
||
|
vec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {
|
||
|
#ifdef ENVMAP_MODE_REFLECTION
|
||
|
vec3 reflectVec = reflect( -viewDir, normal );
|
||
|
reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
|
||
|
#else
|
||
|
vec3 reflectVec = refract( -viewDir, normal, refractionRatio );
|
||
|
#endif
|
||
|
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
||
|
float specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );
|
||
|
#ifdef ENVMAP_TYPE_CUBE
|
||
|
vec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );
|
||
|
#ifdef TEXTURE_LOD_EXT
|
||
|
vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );
|
||
|
#else
|
||
|
vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );
|
||
|
#endif
|
||
|
envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
|
||
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
||
|
vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
|
||
|
#elif defined( ENVMAP_TYPE_EQUIREC )
|
||
|
vec2 sampleUV;
|
||
|
sampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
||
|
sampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;
|
||
|
#ifdef TEXTURE_LOD_EXT
|
||
|
vec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );
|
||
|
#else
|
||
|
vec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );
|
||
|
#endif
|
||
|
envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
|
||
|
#elif defined( ENVMAP_TYPE_SPHERE )
|
||
|
vec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );
|
||
|
#ifdef TEXTURE_LOD_EXT
|
||
|
vec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );
|
||
|
#else
|
||
|
vec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );
|
||
|
#endif
|
||
|
envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
|
||
|
#endif
|
||
|
return envMapColor.rgb * envMapIntensity;
|
||
|
}
|
||
|
#endif`,envmap_vertex:`#ifdef USE_ENVMAP
|
||
|
#ifdef ENV_WORLDPOS
|
||
|
vWorldPosition = worldPosition.xyz;
|
||
|
#else
|
||
|
vec3 cameraToVertex;
|
||
|
if ( isOrthographic ) {
|
||
|
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
||
|
} else {
|
||
|
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
|
||
|
}
|
||
|
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
||
|
#ifdef ENVMAP_MODE_REFLECTION
|
||
|
vReflect = reflect( cameraToVertex, worldNormal );
|
||
|
#else
|
||
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
||
|
#endif
|
||
|
#endif
|
||
|
#endif`,fog_vertex:`#ifdef USE_FOG
|
||
|
fogDepth = -mvPosition.z;
|
||
|
#endif`,fog_pars_vertex:`#ifdef USE_FOG
|
||
|
varying float fogDepth;
|
||
|
#endif`,fog_fragment:`#ifdef USE_FOG
|
||
|
#ifdef FOG_EXP2
|
||
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );
|
||
|
#else
|
||
|
float fogFactor = smoothstep( fogNear, fogFar, fogDepth );
|
||
|
#endif
|
||
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
||
|
#endif`,fog_pars_fragment:`#ifdef USE_FOG
|
||
|
uniform vec3 fogColor;
|
||
|
varying float fogDepth;
|
||
|
#ifdef FOG_EXP2
|
||
|
uniform float fogDensity;
|
||
|
#else
|
||
|
uniform float fogNear;
|
||
|
uniform float fogFar;
|
||
|
#endif
|
||
|
#endif`,gradientmap_pars_fragment:`#ifdef USE_GRADIENTMAP
|
||
|
uniform sampler2D gradientMap;
|
||
|
#endif
|
||
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
||
|
float dotNL = dot( normal, lightDirection );
|
||
|
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
|
||
|
#ifdef USE_GRADIENTMAP
|
||
|
return texture2D( gradientMap, coord ).rgb;
|
||
|
#else
|
||
|
return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );
|
||
|
#endif
|
||
|
}`,lightmap_fragment:`#ifdef USE_LIGHTMAP
|
||
|
vec4 lightMapTexel= texture2D( lightMap, vUv2 );
|
||
|
reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
|
||
|
#endif`,lightmap_pars_fragment:`#ifdef USE_LIGHTMAP
|
||
|
uniform sampler2D lightMap;
|
||
|
uniform float lightMapIntensity;
|
||
|
#endif`,lights_lambert_vertex:`vec3 diffuse = vec3( 1.0 );
|
||
|
GeometricContext geometry;
|
||
|
geometry.position = mvPosition.xyz;
|
||
|
geometry.normal = normalize( transformedNormal );
|
||
|
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
|
||
|
GeometricContext backGeometry;
|
||
|
backGeometry.position = geometry.position;
|
||
|
backGeometry.normal = -geometry.normal;
|
||
|
backGeometry.viewDir = geometry.viewDir;
|
||
|
vLightFront = vec3( 0.0 );
|
||
|
vIndirectFront = vec3( 0.0 );
|
||
|
#ifdef DOUBLE_SIDED
|
||
|
vLightBack = vec3( 0.0 );
|
||
|
vIndirectBack = vec3( 0.0 );
|
||
|
#endif
|
||
|
IncidentLight directLight;
|
||
|
float dotNL;
|
||
|
vec3 directLightColor_Diffuse;
|
||
|
#if NUM_POINT_LIGHTS > 0
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
||
|
getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );
|
||
|
dotNL = dot( geometry.normal, directLight.direction );
|
||
|
directLightColor_Diffuse = PI * directLight.color;
|
||
|
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
||
|
#ifdef DOUBLE_SIDED
|
||
|
vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
|
||
|
#endif
|
||
|
}
|
||
|
#endif
|
||
|
#if NUM_SPOT_LIGHTS > 0
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
||
|
getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );
|
||
|
dotNL = dot( geometry.normal, directLight.direction );
|
||
|
directLightColor_Diffuse = PI * directLight.color;
|
||
|
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
||
|
#ifdef DOUBLE_SIDED
|
||
|
vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
|
||
|
#endif
|
||
|
}
|
||
|
#endif
|
||
|
#if NUM_DIR_LIGHTS > 0
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
||
|
getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );
|
||
|
dotNL = dot( geometry.normal, directLight.direction );
|
||
|
directLightColor_Diffuse = PI * directLight.color;
|
||
|
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
||
|
#ifdef DOUBLE_SIDED
|
||
|
vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
|
||
|
#endif
|
||
|
}
|
||
|
#endif
|
||
|
#if NUM_HEMI_LIGHTS > 0
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
||
|
vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
|
||
|
#ifdef DOUBLE_SIDED
|
||
|
vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );
|
||
|
#endif
|
||
|
}
|
||
|
#endif`,lights_pars_begin:`uniform bool receiveShadow;
|
||
|
uniform vec3 ambientLightColor;
|
||
|
uniform vec3 lightProbe[ 9 ];
|
||
|
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
|
||
|
float x = normal.x, y = normal.y, z = normal.z;
|
||
|
vec3 result = shCoefficients[ 0 ] * 0.886227;
|
||
|
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
|
||
|
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
|
||
|
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
|
||
|
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
|
||
|
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
|
||
|
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
|
||
|
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
|
||
|
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
|
||
|
return result;
|
||
|
}
|
||
|
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {
|
||
|
vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
|
||
|
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
|
||
|
return irradiance;
|
||
|
}
|
||
|
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
|
||
|
vec3 irradiance = ambientLightColor;
|
||
|
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
||
|
irradiance *= PI;
|
||
|
#endif
|
||
|
return irradiance;
|
||
|
}
|
||
|
#if NUM_DIR_LIGHTS > 0
|
||
|
struct DirectionalLight {
|
||
|
vec3 direction;
|
||
|
vec3 color;
|
||
|
int shadow;
|
||
|
float shadowBias;
|
||
|
float shadowRadius;
|
||
|
vec2 shadowMapSize;
|
||
|
};
|
||
|
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
|
||
|
void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {
|
||
|
directLight.color = directionalLight.color;
|
||
|
directLight.direction = directionalLight.direction;
|
||
|
directLight.visible = true;
|
||
|
}
|
||
|
#endif
|
||
|
#if NUM_POINT_LIGHTS > 0
|
||
|
struct PointLight {
|
||
|
vec3 position;
|
||
|
vec3 color;
|
||
|
float distance;
|
||
|
float decay;
|
||
|
int shadow;
|
||
|
float shadowBias;
|
||
|
float shadowRadius;
|
||
|
vec2 shadowMapSize;
|
||
|
float shadowCameraNear;
|
||
|
float shadowCameraFar;
|
||
|
};
|
||
|
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
|
||
|
void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {
|
||
|
vec3 lVector = pointLight.position - geometry.position;
|
||
|
directLight.direction = normalize( lVector );
|
||
|
float lightDistance = length( lVector );
|
||
|
directLight.color = pointLight.color;
|
||
|
directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
|
||
|
directLight.visible = ( directLight.color != vec3( 0.0 ) );
|
||
|
}
|
||
|
#endif
|
||
|
#if NUM_SPOT_LIGHTS > 0
|
||
|
struct SpotLight {
|
||
|
vec3 position;
|
||
|
vec3 direction;
|
||
|
vec3 color;
|
||
|
float distance;
|
||
|
float decay;
|
||
|
float coneCos;
|
||
|
float penumbraCos;
|
||
|
int shadow;
|
||
|
float shadowBias;
|
||
|
float shadowRadius;
|
||
|
vec2 shadowMapSize;
|
||
|
};
|
||
|
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
|
||
|
void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {
|
||
|
vec3 lVector = spotLight.position - geometry.position;
|
||
|
directLight.direction = normalize( lVector );
|
||
|
float lightDistance = length( lVector );
|
||
|
float angleCos = dot( directLight.direction, spotLight.direction );
|
||
|
if ( angleCos > spotLight.coneCos ) {
|
||
|
float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );
|
||
|
directLight.color = spotLight.color;
|
||
|
directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );
|
||
|
directLight.visible = true;
|
||
|
} else {
|
||
|
directLight.color = vec3( 0.0 );
|
||
|
directLight.visible = false;
|
||
|
}
|
||
|
}
|
||
|
#endif
|
||
|
#if NUM_RECT_AREA_LIGHTS > 0
|
||
|
struct RectAreaLight {
|
||
|
vec3 color;
|
||
|
vec3 position;
|
||
|
vec3 halfWidth;
|
||
|
vec3 halfHeight;
|
||
|
};
|
||
|
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
|
||
|
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
|
||
|
#endif
|
||
|
#if NUM_HEMI_LIGHTS > 0
|
||
|
struct HemisphereLight {
|
||
|
vec3 direction;
|
||
|
vec3 skyColor;
|
||
|
vec3 groundColor;
|
||
|
};
|
||
|
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
|
||
|
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {
|
||
|
float dotNL = dot( geometry.normal, hemiLight.direction );
|
||
|
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
|
||
|
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
|
||
|
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
||
|
irradiance *= PI;
|
||
|
#endif
|
||
|
return irradiance;
|
||
|
}
|
||
|
#endif`,lights_toon_fragment:`ToonMaterial material;
|
||
|
material.diffuseColor = diffuseColor.rgb;
|
||
|
material.specularColor = specular;
|
||
|
material.specularShininess = shininess;
|
||
|
material.specularStrength = specularStrength;`,lights_toon_pars_fragment:`varying vec3 vViewPosition;
|
||
|
#ifndef FLAT_SHADED
|
||
|
varying vec3 vNormal;
|
||
|
#endif
|
||
|
struct ToonMaterial {
|
||
|
vec3 diffuseColor;
|
||
|
vec3 specularColor;
|
||
|
float specularShininess;
|
||
|
float specularStrength;
|
||
|
};
|
||
|
void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
||
|
vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
|
||
|
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
||
|
irradiance *= PI;
|
||
|
#endif
|
||
|
reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
|
||
|
reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;
|
||
|
}
|
||
|
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
||
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
|
||
|
}
|
||
|
#define RE_Direct RE_Direct_Toon
|
||
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
|
||
|
#define Material_LightProbeLOD( material ) (0)`,lights_phong_fragment:`BlinnPhongMaterial material;
|
||
|
material.diffuseColor = diffuseColor.rgb;
|
||
|
material.specularColor = specular;
|
||
|
material.specularShininess = shininess;
|
||
|
material.specularStrength = specularStrength;`,lights_phong_pars_fragment:`varying vec3 vViewPosition;
|
||
|
#ifndef FLAT_SHADED
|
||
|
varying vec3 vNormal;
|
||
|
#endif
|
||
|
struct BlinnPhongMaterial {
|
||
|
vec3 diffuseColor;
|
||
|
vec3 specularColor;
|
||
|
float specularShininess;
|
||
|
float specularStrength;
|
||
|
};
|
||
|
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
||
|
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
||
|
vec3 irradiance = dotNL * directLight.color;
|
||
|
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
||
|
irradiance *= PI;
|
||
|
#endif
|
||
|
reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
|
||
|
reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;
|
||
|
}
|
||
|
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
||
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
|
||
|
}
|
||
|
#define RE_Direct RE_Direct_BlinnPhong
|
||
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong
|
||
|
#define Material_LightProbeLOD( material ) (0)`,lights_physical_fragment:`PhysicalMaterial material;
|
||
|
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
||
|
vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
|
||
|
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
||
|
material.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;
|
||
|
material.specularRoughness = min( material.specularRoughness, 1.0 );
|
||
|
#ifdef REFLECTIVITY
|
||
|
material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );
|
||
|
#else
|
||
|
material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );
|
||
|
#endif
|
||
|
#ifdef CLEARCOAT
|
||
|
material.clearcoat = saturate( clearcoat ); material.clearcoatRoughness = max( clearcoatRoughness, 0.0525 );
|
||
|
material.clearcoatRoughness += geometryRoughness;
|
||
|
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
||
|
#endif
|
||
|
#ifdef USE_SHEEN
|
||
|
material.sheenColor = sheen;
|
||
|
#endif`,lights_physical_pars_fragment:`struct PhysicalMaterial {
|
||
|
vec3 diffuseColor;
|
||
|
float specularRoughness;
|
||
|
vec3 specularColor;
|
||
|
#ifdef CLEARCOAT
|
||
|
float clearcoat;
|
||
|
float clearcoatRoughness;
|
||
|
#endif
|
||
|
#ifdef USE_SHEEN
|
||
|
vec3 sheenColor;
|
||
|
#endif
|
||
|
};
|
||
|
#define MAXIMUM_SPECULAR_COEFFICIENT 0.16
|
||
|
#define DEFAULT_SPECULAR_COEFFICIENT 0.04
|
||
|
float clearcoatDHRApprox( const in float roughness, const in float dotNL ) {
|
||
|
return DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );
|
||
|
}
|
||
|
#if NUM_RECT_AREA_LIGHTS > 0
|
||
|
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
|
vec3 normal = geometry.normal;
|
||
|
vec3 viewDir = geometry.viewDir;
|
||
|
vec3 position = geometry.position;
|
||
|
vec3 lightPos = rectAreaLight.position;
|
||
|
vec3 halfWidth = rectAreaLight.halfWidth;
|
||
|
vec3 halfHeight = rectAreaLight.halfHeight;
|
||
|
vec3 lightColor = rectAreaLight.color;
|
||
|
float roughness = material.specularRoughness;
|
||
|
vec3 rectCoords[ 4 ];
|
||
|
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
||
|
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
||
|
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
||
|
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
||
|
vec4 t1 = texture2D( ltc_1, uv );
|
||
|
vec4 t2 = texture2D( ltc_2, uv );
|
||
|
mat3 mInv = mat3(
|
||
|
vec3( t1.x, 0, t1.y ),
|
||
|
vec3( 0, 1, 0 ),
|
||
|
vec3( t1.z, 0, t1.w )
|
||
|
);
|
||
|
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
|
||
|
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
||
|
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
||
|
}
|
||
|
#endif
|
||
|
void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
|
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
||
|
vec3 irradiance = dotNL * directLight.color;
|
||
|
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
||
|
irradiance *= PI;
|
||
|
#endif
|
||
|
#ifdef CLEARCOAT
|
||
|
float ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
|
||
|
vec3 ccIrradiance = ccDotNL * directLight.color;
|
||
|
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
||
|
ccIrradiance *= PI;
|
||
|
#endif
|
||
|
float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );
|
||
|
reflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );
|
||
|
#else
|
||
|
float clearcoatDHR = 0.0;
|
||
|
#endif
|
||
|
#ifdef USE_SHEEN
|
||
|
reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(
|
||
|
material.specularRoughness,
|
||
|
directLight.direction,
|
||
|
geometry,
|
||
|
material.sheenColor
|
||
|
);
|
||
|
#else
|
||
|
reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);
|
||
|
#endif
|
||
|
reflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
|
||
|
}
|
||
|
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
|
||
|
}
|
||
|
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
|
||
|
#ifdef CLEARCOAT
|
||
|
float ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
|
||
|
reflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );
|
||
|
float ccDotNL = ccDotNV;
|
||
|
float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );
|
||
|
#else
|
||
|
float clearcoatDHR = 0.0;
|
||
|
#endif
|
||
|
float clearcoatInv = 1.0 - clearcoatDHR;
|
||
|
vec3 singleScattering = vec3( 0.0 );
|
||
|
vec3 multiScattering = vec3( 0.0 );
|
||
|
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
||
|
BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );
|
||
|
vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );
|
||
|
reflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;
|
||
|
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
||
|
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
|
||
|
}
|
||
|
#define RE_Direct RE_Direct_Physical
|
||
|
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
||
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
||
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
||
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
||
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
||
|
}`,lights_fragment_begin:`
|
||
|
GeometricContext geometry;
|
||
|
geometry.position = - vViewPosition;
|
||
|
geometry.normal = normal;
|
||
|
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
||
|
#ifdef CLEARCOAT
|
||
|
geometry.clearcoatNormal = clearcoatNormal;
|
||
|
#endif
|
||
|
IncidentLight directLight;
|
||
|
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
||
|
PointLight pointLight;
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
||
|
pointLight = pointLights[ i ];
|
||
|
getPointDirectLightIrradiance( pointLight, geometry, directLight );
|
||
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
|
||
|
directLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
||
|
#endif
|
||
|
RE_Direct( directLight, geometry, material, reflectedLight );
|
||
|
}
|
||
|
#endif
|
||
|
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
||
|
SpotLight spotLight;
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
||
|
spotLight = spotLights[ i ];
|
||
|
getSpotDirectLightIrradiance( spotLight, geometry, directLight );
|
||
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
||
|
directLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
|
||
|
#endif
|
||
|
RE_Direct( directLight, geometry, material, reflectedLight );
|
||
|
}
|
||
|
#endif
|
||
|
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
||
|
DirectionalLight directionalLight;
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
||
|
directionalLight = directionalLights[ i ];
|
||
|
getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );
|
||
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
||
|
directLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
||
|
#endif
|
||
|
RE_Direct( directLight, geometry, material, reflectedLight );
|
||
|
}
|
||
|
#endif
|
||
|
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
||
|
RectAreaLight rectAreaLight;
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
||
|
rectAreaLight = rectAreaLights[ i ];
|
||
|
RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
|
||
|
}
|
||
|
#endif
|
||
|
#if defined( RE_IndirectDiffuse )
|
||
|
vec3 iblIrradiance = vec3( 0.0 );
|
||
|
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
||
|
irradiance += getLightProbeIrradiance( lightProbe, geometry );
|
||
|
#if ( NUM_HEMI_LIGHTS > 0 )
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
||
|
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
|
||
|
}
|
||
|
#endif
|
||
|
#endif
|
||
|
#if defined( RE_IndirectSpecular )
|
||
|
vec3 radiance = vec3( 0.0 );
|
||
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
||
|
#endif`,lights_fragment_maps:`#if defined( RE_IndirectDiffuse )
|
||
|
#ifdef USE_LIGHTMAP
|
||
|
vec4 lightMapTexel= texture2D( lightMap, vUv2 );
|
||
|
vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
|
||
|
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
||
|
lightMapIrradiance *= PI;
|
||
|
#endif
|
||
|
irradiance += lightMapIrradiance;
|
||
|
#endif
|
||
|
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
|
||
|
iblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );
|
||
|
#endif
|
||
|
#endif
|
||
|
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
||
|
radiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );
|
||
|
#ifdef CLEARCOAT
|
||
|
clearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );
|
||
|
#endif
|
||
|
#endif`,lights_fragment_end:`#if defined( RE_IndirectDiffuse )
|
||
|
RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
|
||
|
#endif
|
||
|
#if defined( RE_IndirectSpecular )
|
||
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
|
||
|
#endif`,logdepthbuf_fragment:`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
|
||
|
gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
||
|
#endif`,logdepthbuf_pars_fragment:`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
|
||
|
uniform float logDepthBufFC;
|
||
|
varying float vFragDepth;
|
||
|
varying float vIsPerspective;
|
||
|
#endif`,logdepthbuf_pars_vertex:`#ifdef USE_LOGDEPTHBUF
|
||
|
#ifdef USE_LOGDEPTHBUF_EXT
|
||
|
varying float vFragDepth;
|
||
|
varying float vIsPerspective;
|
||
|
#else
|
||
|
uniform float logDepthBufFC;
|
||
|
#endif
|
||
|
#endif`,logdepthbuf_vertex:`#ifdef USE_LOGDEPTHBUF
|
||
|
#ifdef USE_LOGDEPTHBUF_EXT
|
||
|
vFragDepth = 1.0 + gl_Position.w;
|
||
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
||
|
#else
|
||
|
if ( isPerspectiveMatrix( projectionMatrix ) ) {
|
||
|
gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
|
||
|
gl_Position.z *= gl_Position.w;
|
||
|
}
|
||
|
#endif
|
||
|
#endif`,map_fragment:`#ifdef USE_MAP
|
||
|
vec4 texelColor = texture2D( map, vUv );
|
||
|
texelColor = mapTexelToLinear( texelColor );
|
||
|
diffuseColor *= texelColor;
|
||
|
#endif`,map_pars_fragment:`#ifdef USE_MAP
|
||
|
uniform sampler2D map;
|
||
|
#endif`,map_particle_fragment:`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
||
|
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
|
||
|
#endif
|
||
|
#ifdef USE_MAP
|
||
|
vec4 mapTexel = texture2D( map, uv );
|
||
|
diffuseColor *= mapTexelToLinear( mapTexel );
|
||
|
#endif
|
||
|
#ifdef USE_ALPHAMAP
|
||
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
||
|
#endif`,map_particle_pars_fragment:`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
||
|
uniform mat3 uvTransform;
|
||
|
#endif
|
||
|
#ifdef USE_MAP
|
||
|
uniform sampler2D map;
|
||
|
#endif
|
||
|
#ifdef USE_ALPHAMAP
|
||
|
uniform sampler2D alphaMap;
|
||
|
#endif`,metalnessmap_fragment:`float metalnessFactor = metalness;
|
||
|
#ifdef USE_METALNESSMAP
|
||
|
vec4 texelMetalness = texture2D( metalnessMap, vUv );
|
||
|
metalnessFactor *= texelMetalness.b;
|
||
|
#endif`,metalnessmap_pars_fragment:`#ifdef USE_METALNESSMAP
|
||
|
uniform sampler2D metalnessMap;
|
||
|
#endif`,morphnormal_vertex:`#ifdef USE_MORPHNORMALS
|
||
|
objectNormal *= morphTargetBaseInfluence;
|
||
|
objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
|
||
|
objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
|
||
|
objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
|
||
|
objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
|
||
|
#endif`,morphtarget_pars_vertex:`#ifdef USE_MORPHTARGETS
|
||
|
uniform float morphTargetBaseInfluence;
|
||
|
#ifndef USE_MORPHNORMALS
|
||
|
uniform float morphTargetInfluences[ 8 ];
|
||
|
#else
|
||
|
uniform float morphTargetInfluences[ 4 ];
|
||
|
#endif
|
||
|
#endif`,morphtarget_vertex:`#ifdef USE_MORPHTARGETS
|
||
|
transformed *= morphTargetBaseInfluence;
|
||
|
transformed += morphTarget0 * morphTargetInfluences[ 0 ];
|
||
|
transformed += morphTarget1 * morphTargetInfluences[ 1 ];
|
||
|
transformed += morphTarget2 * morphTargetInfluences[ 2 ];
|
||
|
transformed += morphTarget3 * morphTargetInfluences[ 3 ];
|
||
|
#ifndef USE_MORPHNORMALS
|
||
|
transformed += morphTarget4 * morphTargetInfluences[ 4 ];
|
||
|
transformed += morphTarget5 * morphTargetInfluences[ 5 ];
|
||
|
transformed += morphTarget6 * morphTargetInfluences[ 6 ];
|
||
|
transformed += morphTarget7 * morphTargetInfluences[ 7 ];
|
||
|
#endif
|
||
|
#endif`,normal_fragment_begin:`#ifdef FLAT_SHADED
|
||
|
vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );
|
||
|
vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
|
||
|
vec3 normal = normalize( cross( fdx, fdy ) );
|
||
|
#else
|
||
|
vec3 normal = normalize( vNormal );
|
||
|
#ifdef DOUBLE_SIDED
|
||
|
normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
|
||
|
#endif
|
||
|
#ifdef USE_TANGENT
|
||
|
vec3 tangent = normalize( vTangent );
|
||
|
vec3 bitangent = normalize( vBitangent );
|
||
|
#ifdef DOUBLE_SIDED
|
||
|
tangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
|
||
|
bitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
|
||
|
#endif
|
||
|
#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
|
||
|
mat3 vTBN = mat3( tangent, bitangent, normal );
|
||
|
#endif
|
||
|
#endif
|
||
|
#endif
|
||
|
vec3 geometryNormal = normal;`,normal_fragment_maps:`#ifdef OBJECTSPACE_NORMALMAP
|
||
|
normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
|
||
|
#ifdef FLIP_SIDED
|
||
|
normal = - normal;
|
||
|
#endif
|
||
|
#ifdef DOUBLE_SIDED
|
||
|
normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
|
||
|
#endif
|
||
|
normal = normalize( normalMatrix * normal );
|
||
|
#elif defined( TANGENTSPACE_NORMALMAP )
|
||
|
vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
|
||
|
mapN.xy *= normalScale;
|
||
|
#ifdef USE_TANGENT
|
||
|
normal = normalize( vTBN * mapN );
|
||
|
#else
|
||
|
normal = perturbNormal2Arb( -vViewPosition, normal, mapN );
|
||
|
#endif
|
||
|
#elif defined( USE_BUMPMAP )
|
||
|
normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );
|
||
|
#endif`,normalmap_pars_fragment:`#ifdef USE_NORMALMAP
|
||
|
uniform sampler2D normalMap;
|
||
|
uniform vec2 normalScale;
|
||
|
#endif
|
||
|
#ifdef OBJECTSPACE_NORMALMAP
|
||
|
uniform mat3 normalMatrix;
|
||
|
#endif
|
||
|
#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
|
||
|
vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {
|
||
|
vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
|
||
|
vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
|
||
|
vec2 st0 = dFdx( vUv.st );
|
||
|
vec2 st1 = dFdy( vUv.st );
|
||
|
float scale = sign( st1.t * st0.s - st0.t * st1.s );
|
||
|
vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );
|
||
|
vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );
|
||
|
vec3 N = normalize( surf_norm );
|
||
|
mat3 tsn = mat3( S, T, N );
|
||
|
mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
|
||
|
return normalize( tsn * mapN );
|
||
|
}
|
||
|
#endif`,clearcoat_normal_fragment_begin:`#ifdef CLEARCOAT
|
||
|
vec3 clearcoatNormal = geometryNormal;
|
||
|
#endif`,clearcoat_normal_fragment_maps:`#ifdef USE_CLEARCOAT_NORMALMAP
|
||
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
|
||
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
||
|
#ifdef USE_TANGENT
|
||
|
clearcoatNormal = normalize( vTBN * clearcoatMapN );
|
||
|
#else
|
||
|
clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );
|
||
|
#endif
|
||
|
#endif`,clearcoat_normalmap_pars_fragment:`#ifdef USE_CLEARCOAT_NORMALMAP
|
||
|
uniform sampler2D clearcoatNormalMap;
|
||
|
uniform vec2 clearcoatNormalScale;
|
||
|
#endif`,packing:`vec3 packNormalToRGB( const in vec3 normal ) {
|
||
|
return normalize( normal ) * 0.5 + 0.5;
|
||
|
}
|
||
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
||
|
return 2.0 * rgb.xyz - 1.0;
|
||
|
}
|
||
|
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
|
||
|
const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
|
||
|
const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
|
||
|
const float ShiftRight8 = 1. / 256.;
|
||
|
vec4 packDepthToRGBA( const in float v ) {
|
||
|
vec4 r = vec4( fract( v * PackFactors ), v );
|
||
|
r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
|
||
|
}
|
||
|
float unpackRGBAToDepth( const in vec4 v ) {
|
||
|
return dot( v, UnpackFactors );
|
||
|
}
|
||
|
vec4 pack2HalfToRGBA( vec2 v ) {
|
||
|
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));
|
||
|
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);
|
||
|
}
|
||
|
vec2 unpackRGBATo2Half( vec4 v ) {
|
||
|
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
|
||
|
}
|
||
|
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
|
||
|
return ( viewZ + near ) / ( near - far );
|
||
|
}
|
||
|
float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
|
||
|
return linearClipZ * ( near - far ) - near;
|
||
|
}
|
||
|
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
|
||
|
return (( near + viewZ ) * far ) / (( far - near ) * viewZ );
|
||
|
}
|
||
|
float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {
|
||
|
return ( near * far ) / ( ( far - near ) * invClipZ - far );
|
||
|
}`,premultiplied_alpha_fragment:`#ifdef PREMULTIPLIED_ALPHA
|
||
|
gl_FragColor.rgb *= gl_FragColor.a;
|
||
|
#endif`,project_vertex:`vec4 mvPosition = vec4( transformed, 1.0 );
|
||
|
#ifdef USE_INSTANCING
|
||
|
mvPosition = instanceMatrix * mvPosition;
|
||
|
#endif
|
||
|
mvPosition = modelViewMatrix * mvPosition;
|
||
|
gl_Position = projectionMatrix * mvPosition;`,dithering_fragment:`#ifdef DITHERING
|
||
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
||
|
#endif`,dithering_pars_fragment:`#ifdef DITHERING
|
||
|
vec3 dithering( vec3 color ) {
|
||
|
float grid_position = rand( gl_FragCoord.xy );
|
||
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
||
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
||
|
return color + dither_shift_RGB;
|
||
|
}
|
||
|
#endif`,roughnessmap_fragment:`float roughnessFactor = roughness;
|
||
|
#ifdef USE_ROUGHNESSMAP
|
||
|
vec4 texelRoughness = texture2D( roughnessMap, vUv );
|
||
|
roughnessFactor *= texelRoughness.g;
|
||
|
#endif`,roughnessmap_pars_fragment:`#ifdef USE_ROUGHNESSMAP
|
||
|
uniform sampler2D roughnessMap;
|
||
|
#endif`,shadowmap_pars_fragment:`#ifdef USE_SHADOWMAP
|
||
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
|
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
||
|
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
||
|
#endif
|
||
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||
|
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
|
varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
|
#endif
|
||
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
|
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
||
|
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
||
|
#endif
|
||
|
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
||
|
return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
|
||
|
}
|
||
|
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
|
||
|
return unpackRGBATo2Half( texture2D( shadow, uv ) );
|
||
|
}
|
||
|
float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
|
||
|
float occlusion = 1.0;
|
||
|
vec2 distribution = texture2DDistribution( shadow, uv );
|
||
|
float hard_shadow = step( compare , distribution.x );
|
||
|
if (hard_shadow != 1.0 ) {
|
||
|
float distance = compare - distribution.x ;
|
||
|
float variance = max( 0.00000, distribution.y * distribution.y );
|
||
|
float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
|
||
|
}
|
||
|
return occlusion;
|
||
|
}
|
||
|
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
||
|
float shadow = 1.0;
|
||
|
shadowCoord.xyz /= shadowCoord.w;
|
||
|
shadowCoord.z += shadowBias;
|
||
|
bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
|
||
|
bool inFrustum = all( inFrustumVec );
|
||
|
bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
|
||
|
bool frustumTest = all( frustumTestVec );
|
||
|
if ( frustumTest ) {
|
||
|
#if defined( SHADOWMAP_TYPE_PCF )
|
||
|
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
||
|
float dx0 = - texelSize.x * shadowRadius;
|
||
|
float dy0 = - texelSize.y * shadowRadius;
|
||
|
float dx1 = + texelSize.x * shadowRadius;
|
||
|
float dy1 = + texelSize.y * shadowRadius;
|
||
|
float dx2 = dx0 / 2.0;
|
||
|
float dy2 = dy0 / 2.0;
|
||
|
float dx3 = dx1 / 2.0;
|
||
|
float dy3 = dy1 / 2.0;
|
||
|
shadow = (
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
|
||
|
) * ( 1.0 / 17.0 );
|
||
|
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
||
|
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
||
|
float dx = texelSize.x;
|
||
|
float dy = texelSize.y;
|
||
|
vec2 uv = shadowCoord.xy;
|
||
|
vec2 f = fract( uv * shadowMapSize + 0.5 );
|
||
|
uv -= f * texelSize;
|
||
|
shadow = (
|
||
|
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
||
|
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
||
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
||
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
||
|
f.x ) +
|
||
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
||
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
||
|
f.x ) +
|
||
|
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
||
|
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
||
|
f.y ) +
|
||
|
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
||
|
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
||
|
f.y ) +
|
||
|
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
||
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
||
|
f.x ),
|
||
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
||
|
texture2DCompare( shadowMap, uv + + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
||
|
f.x ),
|
||
|
f.y )
|
||
|
) * ( 1.0 / 9.0 );
|
||
|
#elif defined( SHADOWMAP_TYPE_VSM )
|
||
|
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
||
|
#else
|
||
|
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
||
|
#endif
|
||
|
}
|
||
|
return shadow;
|
||
|
}
|
||
|
vec2 cubeToUV( vec3 v, float texelSizeY ) {
|
||
|
vec3 absV = abs( v );
|
||
|
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
|
||
|
absV *= scaleToCube;
|
||
|
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
|
||
|
vec2 planar = v.xy;
|
||
|
float almostATexel = 1.5 * texelSizeY;
|
||
|
float almostOne = 1.0 - almostATexel;
|
||
|
if ( absV.z >= almostOne ) {
|
||
|
if ( v.z > 0.0 )
|
||
|
planar.x = 4.0 - v.x;
|
||
|
} else if ( absV.x >= almostOne ) {
|
||
|
float signX = sign( v.x );
|
||
|
planar.x = v.z * signX + 2.0 * signX;
|
||
|
} else if ( absV.y >= almostOne ) {
|
||
|
float signY = sign( v.y );
|
||
|
planar.x = v.x + 2.0 * signY + 2.0;
|
||
|
planar.y = v.z * signY - 2.0;
|
||
|
}
|
||
|
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
||
|
}
|
||
|
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
||
|
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
||
|
vec3 lightToPosition = shadowCoord.xyz;
|
||
|
float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
|
||
|
vec3 bd3D = normalize( lightToPosition );
|
||
|
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
||
|
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
||
|
return (
|
||
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
||
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
||
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
||
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
||
|
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
||
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
||
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
||
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
||
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
||
|
) * ( 1.0 / 9.0 );
|
||
|
#else
|
||
|
return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
||
|
#endif
|
||
|
}
|
||
|
#endif`,shadowmap_pars_vertex:`#ifdef USE_SHADOWMAP
|
||
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
|
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
|
||
|
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
||
|
#endif
|
||
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||
|
uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
|
varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
|
||
|
#endif
|
||
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
|
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
|
||
|
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
||
|
#endif
|
||
|
#endif`,shadowmap_vertex:`#ifdef USE_SHADOWMAP
|
||
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
||
|
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;
|
||
|
}
|
||
|
#endif
|
||
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
||
|
vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;
|
||
|
}
|
||
|
#endif
|
||
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
||
|
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;
|
||
|
}
|
||
|
#endif
|
||
|
#endif`,shadowmask_pars_fragment:`float getShadowMask() {
|
||
|
float shadow = 1.0;
|
||
|
#ifdef USE_SHADOWMAP
|
||
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||
|
DirectionalLight directionalLight;
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
||
|
directionalLight = directionalLights[ i ];
|
||
|
shadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
||
|
}
|
||
|
#endif
|
||
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||
|
SpotLight spotLight;
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
||
|
spotLight = spotLights[ i ];
|
||
|
shadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
|
||
|
}
|
||
|
#endif
|
||
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||
|
PointLight pointLight;
|
||
|
#pragma unroll_loop
|
||
|
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
||
|
pointLight = pointLights[ i ];
|
||
|
shadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
||
|
}
|
||
|
#endif
|
||
|
#endif
|
||
|
return shadow;
|
||
|
}`,skinbase_vertex:`#ifdef USE_SKINNING
|
||
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
||
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
||
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
||
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
||
|
#endif`,skinning_pars_vertex:`#ifdef USE_SKINNING
|
||
|
uniform mat4 bindMatrix;
|
||
|
uniform mat4 bindMatrixInverse;
|
||
|
#ifdef BONE_TEXTURE
|
||
|
uniform highp sampler2D boneTexture;
|
||
|
uniform int boneTextureSize;
|
||
|
mat4 getBoneMatrix( const in float i ) {
|
||
|
float j = i * 4.0;
|
||
|
float x = mod( j, float( boneTextureSize ) );
|
||
|
float y = floor( j / float( boneTextureSize ) );
|
||
|
float dx = 1.0 / float( boneTextureSize );
|
||
|
float dy = 1.0 / float( boneTextureSize );
|
||
|
y = dy * ( y + 0.5 );
|
||
|
vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
|
||
|
vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
|
||
|
vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
|
||
|
vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
|
||
|
mat4 bone = mat4( v1, v2, v3, v4 );
|
||
|
return bone;
|
||
|
}
|
||
|
#else
|
||
|
uniform mat4 boneMatrices[ MAX_BONES ];
|
||
|
mat4 getBoneMatrix( const in float i ) {
|
||
|
mat4 bone = boneMatrices[ int(i) ];
|
||
|
return bone;
|
||
|
}
|
||
|
#endif
|
||
|
#endif`,skinning_vertex:`#ifdef USE_SKINNING
|
||
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
||
|
vec4 skinned = vec4( 0.0 );
|
||
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
||
|
skinned += boneMatY * skinVertex * skinWeight.y;
|
||
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
||
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
||
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
||
|
#endif`,skinnormal_vertex:`#ifdef USE_SKINNING
|
||
|
mat4 skinMatrix = mat4( 0.0 );
|
||
|
skinMatrix += skinWeight.x * boneMatX;
|
||
|
skinMatrix += skinWeight.y * boneMatY;
|
||
|
skinMatrix += skinWeight.z * boneMatZ;
|
||
|
skinMatrix += skinWeight.w * boneMatW;
|
||
|
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
|
||
|
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
|
||
|
#ifdef USE_TANGENT
|
||
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
||
|
#endif
|
||
|
#endif`,specularmap_fragment:`float specularStrength;
|
||
|
#ifdef USE_SPECULARMAP
|
||
|
vec4 texelSpecular = texture2D( specularMap, vUv );
|
||
|
specularStrength = texelSpecular.r;
|
||
|
#else
|
||
|
specularStrength = 1.0;
|
||
|
#endif`,specularmap_pars_fragment:`#ifdef USE_SPECULARMAP
|
||
|
uniform sampler2D specularMap;
|
||
|
#endif`,tonemapping_fragment:`#if defined( TONE_MAPPING )
|
||
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
||
|
#endif`,tonemapping_pars_fragment:`#ifndef saturate
|
||
|
#define saturate(a) clamp( a, 0.0, 1.0 )
|
||
|
#endif
|
||
|
uniform float toneMappingExposure;
|
||
|
uniform float toneMappingWhitePoint;
|
||
|
vec3 LinearToneMapping( vec3 color ) {
|
||
|
return toneMappingExposure * color;
|
||
|
}
|
||
|
vec3 ReinhardToneMapping( vec3 color ) {
|
||
|
color *= toneMappingExposure;
|
||
|
return saturate( color / ( vec3( 1.0 ) + color ) );
|
||
|
}
|
||
|
#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )
|
||
|
vec3 Uncharted2ToneMapping( vec3 color ) {
|
||
|
color *= toneMappingExposure;
|
||
|
return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );
|
||
|
}
|
||
|
vec3 OptimizedCineonToneMapping( vec3 color ) {
|
||
|
color *= toneMappingExposure;
|
||
|
color = max( vec3( 0.0 ), color - 0.004 );
|
||
|
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
|
||
|
}
|
||
|
vec3 ACESFilmicToneMapping( vec3 color ) {
|
||
|
color *= toneMappingExposure;
|
||
|
return saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );
|
||
|
}`,uv_pars_fragment:`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
|
||
|
varying vec2 vUv;
|
||
|
#endif`,uv_pars_vertex:`#ifdef USE_UV
|
||
|
#ifdef UVS_VERTEX_ONLY
|
||
|
vec2 vUv;
|
||
|
#else
|
||
|
varying vec2 vUv;
|
||
|
#endif
|
||
|
uniform mat3 uvTransform;
|
||
|
#endif`,uv_vertex:`#ifdef USE_UV
|
||
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
||
|
#endif`,uv2_pars_fragment:`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
|
||
|
varying vec2 vUv2;
|
||
|
#endif`,uv2_pars_vertex:`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
|
||
|
attribute vec2 uv2;
|
||
|
varying vec2 vUv2;
|
||
|
uniform mat3 uv2Transform;
|
||
|
#endif`,uv2_vertex:`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
|
||
|
vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
|
||
|
#endif`,worldpos_vertex:`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )
|
||
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
||
|
#ifdef USE_INSTANCING
|
||
|
worldPosition = instanceMatrix * worldPosition;
|
||
|
#endif
|
||
|
worldPosition = modelMatrix * worldPosition;
|
||
|
#endif`,background_frag:`uniform sampler2D t2D;
|
||
|
varying vec2 vUv;
|
||
|
void main() {
|
||
|
vec4 texColor = texture2D( t2D, vUv );
|
||
|
gl_FragColor = mapTexelToLinear( texColor );
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <encodings_fragment>
|
||
|
}`,background_vert:`varying vec2 vUv;
|
||
|
uniform mat3 uvTransform;
|
||
|
void main() {
|
||
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
||
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
||
|
}`,cube_frag:`#include <envmap_common_pars_fragment>
|
||
|
uniform float opacity;
|
||
|
varying vec3 vWorldDirection;
|
||
|
#include <cube_uv_reflection_fragment>
|
||
|
void main() {
|
||
|
vec3 vReflect = vWorldDirection;
|
||
|
#include <envmap_fragment>
|
||
|
gl_FragColor = envColor;
|
||
|
gl_FragColor.a *= opacity;
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <encodings_fragment>
|
||
|
}`,cube_vert:`varying vec3 vWorldDirection;
|
||
|
#include <common>
|
||
|
void main() {
|
||
|
vWorldDirection = transformDirection( position, modelMatrix );
|
||
|
#include <begin_vertex>
|
||
|
#include <project_vertex>
|
||
|
gl_Position.z = gl_Position.w;
|
||
|
}`,depth_frag:`#if DEPTH_PACKING == 3200
|
||
|
uniform float opacity;
|
||
|
#endif
|
||
|
#include <common>
|
||
|
#include <packing>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main() {
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec4 diffuseColor = vec4( 1.0 );
|
||
|
#if DEPTH_PACKING == 3200
|
||
|
diffuseColor.a = opacity;
|
||
|
#endif
|
||
|
#include <map_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#if DEPTH_PACKING == 3200
|
||
|
gl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );
|
||
|
#elif DEPTH_PACKING == 3201
|
||
|
gl_FragColor = packDepthToRGBA( gl_FragCoord.z );
|
||
|
#endif
|
||
|
}`,depth_vert:`#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <displacementmap_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main() {
|
||
|
#include <uv_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#ifdef USE_DISPLACEMENTMAP
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#endif
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <displacementmap_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
}`,distanceRGBA_frag:`#define DISTANCE
|
||
|
uniform vec3 referencePosition;
|
||
|
uniform float nearDistance;
|
||
|
uniform float farDistance;
|
||
|
varying vec3 vWorldPosition;
|
||
|
#include <common>
|
||
|
#include <packing>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main () {
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec4 diffuseColor = vec4( 1.0 );
|
||
|
#include <map_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
float dist = length( vWorldPosition - referencePosition );
|
||
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
||
|
dist = saturate( dist );
|
||
|
gl_FragColor = packDepthToRGBA( dist );
|
||
|
}`,distanceRGBA_vert:`#define DISTANCE
|
||
|
varying vec3 vWorldPosition;
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <displacementmap_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main() {
|
||
|
#include <uv_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#ifdef USE_DISPLACEMENTMAP
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#endif
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <displacementmap_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <worldpos_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
vWorldPosition = worldPosition.xyz;
|
||
|
}`,equirect_frag:`uniform sampler2D tEquirect;
|
||
|
varying vec3 vWorldDirection;
|
||
|
#include <common>
|
||
|
void main() {
|
||
|
vec3 direction = normalize( vWorldDirection );
|
||
|
vec2 sampleUV;
|
||
|
sampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
||
|
sampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;
|
||
|
vec4 texColor = texture2D( tEquirect, sampleUV );
|
||
|
gl_FragColor = mapTexelToLinear( texColor );
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <encodings_fragment>
|
||
|
}`,equirect_vert:`varying vec3 vWorldDirection;
|
||
|
#include <common>
|
||
|
void main() {
|
||
|
vWorldDirection = transformDirection( position, modelMatrix );
|
||
|
#include <begin_vertex>
|
||
|
#include <project_vertex>
|
||
|
}`,linedashed_frag:`uniform vec3 diffuse;
|
||
|
uniform float opacity;
|
||
|
uniform float dashSize;
|
||
|
uniform float totalSize;
|
||
|
varying float vLineDistance;
|
||
|
#include <common>
|
||
|
#include <color_pars_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main() {
|
||
|
#include <clipping_planes_fragment>
|
||
|
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
||
|
discard;
|
||
|
}
|
||
|
vec3 outgoingLight = vec3( 0.0 );
|
||
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <color_fragment>
|
||
|
outgoingLight = diffuseColor.rgb;
|
||
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <encodings_fragment>
|
||
|
#include <fog_fragment>
|
||
|
#include <premultiplied_alpha_fragment>
|
||
|
}`,linedashed_vert:`uniform float scale;
|
||
|
attribute float lineDistance;
|
||
|
varying float vLineDistance;
|
||
|
#include <common>
|
||
|
#include <color_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main() {
|
||
|
#include <color_vertex>
|
||
|
vLineDistance = scale * lineDistance;
|
||
|
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
||
|
gl_Position = projectionMatrix * mvPosition;
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`,meshbasic_frag:`uniform vec3 diffuse;
|
||
|
uniform float opacity;
|
||
|
#ifndef FLAT_SHADED
|
||
|
varying vec3 vNormal;
|
||
|
#endif
|
||
|
#include <common>
|
||
|
#include <color_pars_fragment>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <uv2_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <aomap_pars_fragment>
|
||
|
#include <lightmap_pars_fragment>
|
||
|
#include <envmap_common_pars_fragment>
|
||
|
#include <envmap_pars_fragment>
|
||
|
#include <cube_uv_reflection_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <specularmap_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main() {
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_fragment>
|
||
|
#include <color_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <specularmap_fragment>
|
||
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
|
#ifdef USE_LIGHTMAP
|
||
|
|
||
|
vec4 lightMapTexel= texture2D( lightMap, vUv2 );
|
||
|
reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
|
||
|
#else
|
||
|
reflectedLight.indirectDiffuse += vec3( 1.0 );
|
||
|
#endif
|
||
|
#include <aomap_fragment>
|
||
|
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
||
|
vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
||
|
#include <envmap_fragment>
|
||
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <encodings_fragment>
|
||
|
#include <fog_fragment>
|
||
|
#include <premultiplied_alpha_fragment>
|
||
|
}`,meshbasic_vert:`#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <uv2_pars_vertex>
|
||
|
#include <envmap_pars_vertex>
|
||
|
#include <color_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main() {
|
||
|
#include <uv_vertex>
|
||
|
#include <uv2_vertex>
|
||
|
#include <color_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#ifdef USE_ENVMAP
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#include <defaultnormal_vertex>
|
||
|
#endif
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <worldpos_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
#include <envmap_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`,meshlambert_frag:`uniform vec3 diffuse;
|
||
|
uniform vec3 emissive;
|
||
|
uniform float opacity;
|
||
|
varying vec3 vLightFront;
|
||
|
varying vec3 vIndirectFront;
|
||
|
#ifdef DOUBLE_SIDED
|
||
|
varying vec3 vLightBack;
|
||
|
varying vec3 vIndirectBack;
|
||
|
#endif
|
||
|
#include <common>
|
||
|
#include <packing>
|
||
|
#include <dithering_pars_fragment>
|
||
|
#include <color_pars_fragment>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <uv2_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <aomap_pars_fragment>
|
||
|
#include <lightmap_pars_fragment>
|
||
|
#include <emissivemap_pars_fragment>
|
||
|
#include <envmap_common_pars_fragment>
|
||
|
#include <envmap_pars_fragment>
|
||
|
#include <cube_uv_reflection_fragment>
|
||
|
#include <bsdfs>
|
||
|
#include <lights_pars_begin>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <shadowmap_pars_fragment>
|
||
|
#include <shadowmask_pars_fragment>
|
||
|
#include <specularmap_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main() {
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
|
vec3 totalEmissiveRadiance = emissive;
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_fragment>
|
||
|
#include <color_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <specularmap_fragment>
|
||
|
#include <emissivemap_fragment>
|
||
|
reflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );
|
||
|
#ifdef DOUBLE_SIDED
|
||
|
reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;
|
||
|
#else
|
||
|
reflectedLight.indirectDiffuse += vIndirectFront;
|
||
|
#endif
|
||
|
#include <lightmap_fragment>
|
||
|
reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );
|
||
|
#ifdef DOUBLE_SIDED
|
||
|
reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;
|
||
|
#else
|
||
|
reflectedLight.directDiffuse = vLightFront;
|
||
|
#endif
|
||
|
reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();
|
||
|
#include <aomap_fragment>
|
||
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
||
|
#include <envmap_fragment>
|
||
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <encodings_fragment>
|
||
|
#include <fog_fragment>
|
||
|
#include <premultiplied_alpha_fragment>
|
||
|
#include <dithering_fragment>
|
||
|
}`,meshlambert_vert:`#define LAMBERT
|
||
|
varying vec3 vLightFront;
|
||
|
varying vec3 vIndirectFront;
|
||
|
#ifdef DOUBLE_SIDED
|
||
|
varying vec3 vLightBack;
|
||
|
varying vec3 vIndirectBack;
|
||
|
#endif
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <uv2_pars_vertex>
|
||
|
#include <envmap_pars_vertex>
|
||
|
#include <bsdfs>
|
||
|
#include <lights_pars_begin>
|
||
|
#include <color_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <shadowmap_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main() {
|
||
|
#include <uv_vertex>
|
||
|
#include <uv2_vertex>
|
||
|
#include <color_vertex>
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#include <defaultnormal_vertex>
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
#include <worldpos_vertex>
|
||
|
#include <envmap_vertex>
|
||
|
#include <lights_lambert_vertex>
|
||
|
#include <shadowmap_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`,meshmatcap_frag:`#define MATCAP
|
||
|
uniform vec3 diffuse;
|
||
|
uniform float opacity;
|
||
|
uniform sampler2D matcap;
|
||
|
varying vec3 vViewPosition;
|
||
|
#ifndef FLAT_SHADED
|
||
|
varying vec3 vNormal;
|
||
|
#endif
|
||
|
#include <common>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <bumpmap_pars_fragment>
|
||
|
#include <normalmap_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main() {
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <normal_fragment_begin>
|
||
|
#include <normal_fragment_maps>
|
||
|
vec3 viewDir = normalize( vViewPosition );
|
||
|
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
||
|
vec3 y = cross( viewDir, x );
|
||
|
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
|
||
|
#ifdef USE_MATCAP
|
||
|
vec4 matcapColor = texture2D( matcap, uv );
|
||
|
matcapColor = matcapTexelToLinear( matcapColor );
|
||
|
#else
|
||
|
vec4 matcapColor = vec4( 1.0 );
|
||
|
#endif
|
||
|
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
|
||
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <encodings_fragment>
|
||
|
#include <fog_fragment>
|
||
|
#include <premultiplied_alpha_fragment>
|
||
|
}`,meshmatcap_vert:`#define MATCAP
|
||
|
varying vec3 vViewPosition;
|
||
|
#ifndef FLAT_SHADED
|
||
|
varying vec3 vNormal;
|
||
|
#endif
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <displacementmap_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main() {
|
||
|
#include <uv_vertex>
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#include <defaultnormal_vertex>
|
||
|
#ifndef FLAT_SHADED
|
||
|
vNormal = normalize( transformedNormal );
|
||
|
#endif
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <displacementmap_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
#include <fog_vertex>
|
||
|
vViewPosition = - mvPosition.xyz;
|
||
|
}`,meshtoon_frag:`#define TOON
|
||
|
uniform vec3 diffuse;
|
||
|
uniform vec3 emissive;
|
||
|
uniform vec3 specular;
|
||
|
uniform float shininess;
|
||
|
uniform float opacity;
|
||
|
#include <common>
|
||
|
#include <packing>
|
||
|
#include <dithering_pars_fragment>
|
||
|
#include <color_pars_fragment>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <uv2_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <aomap_pars_fragment>
|
||
|
#include <lightmap_pars_fragment>
|
||
|
#include <emissivemap_pars_fragment>
|
||
|
#include <gradientmap_pars_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <bsdfs>
|
||
|
#include <lights_pars_begin>
|
||
|
#include <lights_toon_pars_fragment>
|
||
|
#include <shadowmap_pars_fragment>
|
||
|
#include <bumpmap_pars_fragment>
|
||
|
#include <normalmap_pars_fragment>
|
||
|
#include <specularmap_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main() {
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
|
vec3 totalEmissiveRadiance = emissive;
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_fragment>
|
||
|
#include <color_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <specularmap_fragment>
|
||
|
#include <normal_fragment_begin>
|
||
|
#include <normal_fragment_maps>
|
||
|
#include <emissivemap_fragment>
|
||
|
#include <lights_toon_fragment>
|
||
|
#include <lights_fragment_begin>
|
||
|
#include <lights_fragment_maps>
|
||
|
#include <lights_fragment_end>
|
||
|
#include <aomap_fragment>
|
||
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
||
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <encodings_fragment>
|
||
|
#include <fog_fragment>
|
||
|
#include <premultiplied_alpha_fragment>
|
||
|
#include <dithering_fragment>
|
||
|
}`,meshtoon_vert:`#define TOON
|
||
|
varying vec3 vViewPosition;
|
||
|
#ifndef FLAT_SHADED
|
||
|
varying vec3 vNormal;
|
||
|
#endif
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <uv2_pars_vertex>
|
||
|
#include <displacementmap_pars_vertex>
|
||
|
#include <color_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <shadowmap_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main() {
|
||
|
#include <uv_vertex>
|
||
|
#include <uv2_vertex>
|
||
|
#include <color_vertex>
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#include <defaultnormal_vertex>
|
||
|
#ifndef FLAT_SHADED
|
||
|
vNormal = normalize( transformedNormal );
|
||
|
#endif
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <displacementmap_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
vViewPosition = - mvPosition.xyz;
|
||
|
#include <worldpos_vertex>
|
||
|
#include <shadowmap_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`,meshphong_frag:`#define PHONG
|
||
|
uniform vec3 diffuse;
|
||
|
uniform vec3 emissive;
|
||
|
uniform vec3 specular;
|
||
|
uniform float shininess;
|
||
|
uniform float opacity;
|
||
|
#include <common>
|
||
|
#include <packing>
|
||
|
#include <dithering_pars_fragment>
|
||
|
#include <color_pars_fragment>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <uv2_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <aomap_pars_fragment>
|
||
|
#include <lightmap_pars_fragment>
|
||
|
#include <emissivemap_pars_fragment>
|
||
|
#include <envmap_common_pars_fragment>
|
||
|
#include <envmap_pars_fragment>
|
||
|
#include <cube_uv_reflection_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <bsdfs>
|
||
|
#include <lights_pars_begin>
|
||
|
#include <lights_phong_pars_fragment>
|
||
|
#include <shadowmap_pars_fragment>
|
||
|
#include <bumpmap_pars_fragment>
|
||
|
#include <normalmap_pars_fragment>
|
||
|
#include <specularmap_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main() {
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
|
vec3 totalEmissiveRadiance = emissive;
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_fragment>
|
||
|
#include <color_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <specularmap_fragment>
|
||
|
#include <normal_fragment_begin>
|
||
|
#include <normal_fragment_maps>
|
||
|
#include <emissivemap_fragment>
|
||
|
#include <lights_phong_fragment>
|
||
|
#include <lights_fragment_begin>
|
||
|
#include <lights_fragment_maps>
|
||
|
#include <lights_fragment_end>
|
||
|
#include <aomap_fragment>
|
||
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
||
|
#include <envmap_fragment>
|
||
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <encodings_fragment>
|
||
|
#include <fog_fragment>
|
||
|
#include <premultiplied_alpha_fragment>
|
||
|
#include <dithering_fragment>
|
||
|
}`,meshphong_vert:`#define PHONG
|
||
|
varying vec3 vViewPosition;
|
||
|
#ifndef FLAT_SHADED
|
||
|
varying vec3 vNormal;
|
||
|
#endif
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <uv2_pars_vertex>
|
||
|
#include <displacementmap_pars_vertex>
|
||
|
#include <envmap_pars_vertex>
|
||
|
#include <color_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <shadowmap_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main() {
|
||
|
#include <uv_vertex>
|
||
|
#include <uv2_vertex>
|
||
|
#include <color_vertex>
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#include <defaultnormal_vertex>
|
||
|
#ifndef FLAT_SHADED
|
||
|
vNormal = normalize( transformedNormal );
|
||
|
#endif
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <displacementmap_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
vViewPosition = - mvPosition.xyz;
|
||
|
#include <worldpos_vertex>
|
||
|
#include <envmap_vertex>
|
||
|
#include <shadowmap_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`,meshphysical_frag:`#define STANDARD
|
||
|
#ifdef PHYSICAL
|
||
|
#define REFLECTIVITY
|
||
|
#define CLEARCOAT
|
||
|
#define TRANSPARENCY
|
||
|
#endif
|
||
|
uniform vec3 diffuse;
|
||
|
uniform vec3 emissive;
|
||
|
uniform float roughness;
|
||
|
uniform float metalness;
|
||
|
uniform float opacity;
|
||
|
#ifdef TRANSPARENCY
|
||
|
uniform float transparency;
|
||
|
#endif
|
||
|
#ifdef REFLECTIVITY
|
||
|
uniform float reflectivity;
|
||
|
#endif
|
||
|
#ifdef CLEARCOAT
|
||
|
uniform float clearcoat;
|
||
|
uniform float clearcoatRoughness;
|
||
|
#endif
|
||
|
#ifdef USE_SHEEN
|
||
|
uniform vec3 sheen;
|
||
|
#endif
|
||
|
varying vec3 vViewPosition;
|
||
|
#ifndef FLAT_SHADED
|
||
|
varying vec3 vNormal;
|
||
|
#ifdef USE_TANGENT
|
||
|
varying vec3 vTangent;
|
||
|
varying vec3 vBitangent;
|
||
|
#endif
|
||
|
#endif
|
||
|
#include <common>
|
||
|
#include <packing>
|
||
|
#include <dithering_pars_fragment>
|
||
|
#include <color_pars_fragment>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <uv2_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <aomap_pars_fragment>
|
||
|
#include <lightmap_pars_fragment>
|
||
|
#include <emissivemap_pars_fragment>
|
||
|
#include <bsdfs>
|
||
|
#include <cube_uv_reflection_fragment>
|
||
|
#include <envmap_common_pars_fragment>
|
||
|
#include <envmap_physical_pars_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <lights_pars_begin>
|
||
|
#include <lights_physical_pars_fragment>
|
||
|
#include <shadowmap_pars_fragment>
|
||
|
#include <bumpmap_pars_fragment>
|
||
|
#include <normalmap_pars_fragment>
|
||
|
#include <clearcoat_normalmap_pars_fragment>
|
||
|
#include <roughnessmap_pars_fragment>
|
||
|
#include <metalnessmap_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main() {
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
||
|
vec3 totalEmissiveRadiance = emissive;
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_fragment>
|
||
|
#include <color_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <roughnessmap_fragment>
|
||
|
#include <metalnessmap_fragment>
|
||
|
#include <normal_fragment_begin>
|
||
|
#include <normal_fragment_maps>
|
||
|
#include <clearcoat_normal_fragment_begin>
|
||
|
#include <clearcoat_normal_fragment_maps>
|
||
|
#include <emissivemap_fragment>
|
||
|
#include <lights_physical_fragment>
|
||
|
#include <lights_fragment_begin>
|
||
|
#include <lights_fragment_maps>
|
||
|
#include <lights_fragment_end>
|
||
|
#include <aomap_fragment>
|
||
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
||
|
#ifdef TRANSPARENCY
|
||
|
diffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );
|
||
|
#endif
|
||
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <encodings_fragment>
|
||
|
#include <fog_fragment>
|
||
|
#include <premultiplied_alpha_fragment>
|
||
|
#include <dithering_fragment>
|
||
|
}`,meshphysical_vert:`#define STANDARD
|
||
|
varying vec3 vViewPosition;
|
||
|
#ifndef FLAT_SHADED
|
||
|
varying vec3 vNormal;
|
||
|
#ifdef USE_TANGENT
|
||
|
varying vec3 vTangent;
|
||
|
varying vec3 vBitangent;
|
||
|
#endif
|
||
|
#endif
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <uv2_pars_vertex>
|
||
|
#include <displacementmap_pars_vertex>
|
||
|
#include <color_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <shadowmap_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main() {
|
||
|
#include <uv_vertex>
|
||
|
#include <uv2_vertex>
|
||
|
#include <color_vertex>
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#include <defaultnormal_vertex>
|
||
|
#ifndef FLAT_SHADED
|
||
|
vNormal = normalize( transformedNormal );
|
||
|
#ifdef USE_TANGENT
|
||
|
vTangent = normalize( transformedTangent );
|
||
|
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
||
|
#endif
|
||
|
#endif
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <displacementmap_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
vViewPosition = - mvPosition.xyz;
|
||
|
#include <worldpos_vertex>
|
||
|
#include <shadowmap_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`,normal_frag:`#define NORMAL
|
||
|
uniform float opacity;
|
||
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
|
||
|
varying vec3 vViewPosition;
|
||
|
#endif
|
||
|
#ifndef FLAT_SHADED
|
||
|
varying vec3 vNormal;
|
||
|
#ifdef USE_TANGENT
|
||
|
varying vec3 vTangent;
|
||
|
varying vec3 vBitangent;
|
||
|
#endif
|
||
|
#endif
|
||
|
#include <packing>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <bumpmap_pars_fragment>
|
||
|
#include <normalmap_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main() {
|
||
|
#include <clipping_planes_fragment>
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <normal_fragment_begin>
|
||
|
#include <normal_fragment_maps>
|
||
|
gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
|
||
|
}`,normal_vert:`#define NORMAL
|
||
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
|
||
|
varying vec3 vViewPosition;
|
||
|
#endif
|
||
|
#ifndef FLAT_SHADED
|
||
|
varying vec3 vNormal;
|
||
|
#ifdef USE_TANGENT
|
||
|
varying vec3 vTangent;
|
||
|
varying vec3 vBitangent;
|
||
|
#endif
|
||
|
#endif
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <displacementmap_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main() {
|
||
|
#include <uv_vertex>
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#include <defaultnormal_vertex>
|
||
|
#ifndef FLAT_SHADED
|
||
|
vNormal = normalize( transformedNormal );
|
||
|
#ifdef USE_TANGENT
|
||
|
vTangent = normalize( transformedTangent );
|
||
|
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
||
|
#endif
|
||
|
#endif
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <displacementmap_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
|
||
|
vViewPosition = - mvPosition.xyz;
|
||
|
#endif
|
||
|
}`,points_frag:`uniform vec3 diffuse;
|
||
|
uniform float opacity;
|
||
|
#include <common>
|
||
|
#include <color_pars_fragment>
|
||
|
#include <map_particle_pars_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main() {
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec3 outgoingLight = vec3( 0.0 );
|
||
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_particle_fragment>
|
||
|
#include <color_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
outgoingLight = diffuseColor.rgb;
|
||
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <encodings_fragment>
|
||
|
#include <fog_fragment>
|
||
|
#include <premultiplied_alpha_fragment>
|
||
|
}`,points_vert:`uniform float size;
|
||
|
uniform float scale;
|
||
|
#include <common>
|
||
|
#include <color_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main() {
|
||
|
#include <color_vertex>
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <project_vertex>
|
||
|
gl_PointSize = size;
|
||
|
#ifdef USE_SIZEATTENUATION
|
||
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
||
|
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
|
||
|
#endif
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
#include <worldpos_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`,shadow_frag:`uniform vec3 color;
|
||
|
uniform float opacity;
|
||
|
#include <common>
|
||
|
#include <packing>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <bsdfs>
|
||
|
#include <lights_pars_begin>
|
||
|
#include <shadowmap_pars_fragment>
|
||
|
#include <shadowmask_pars_fragment>
|
||
|
void main() {
|
||
|
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <encodings_fragment>
|
||
|
#include <fog_fragment>
|
||
|
}`,shadow_vert:`#include <fog_pars_vertex>
|
||
|
#include <shadowmap_pars_vertex>
|
||
|
void main() {
|
||
|
#include <begin_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <worldpos_vertex>
|
||
|
#include <shadowmap_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`,sprite_frag:`uniform vec3 diffuse;
|
||
|
uniform float opacity;
|
||
|
#include <common>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main() {
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec3 outgoingLight = vec3( 0.0 );
|
||
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
outgoingLight = diffuseColor.rgb;
|
||
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <encodings_fragment>
|
||
|
#include <fog_fragment>
|
||
|
}`,sprite_vert:`uniform float rotation;
|
||
|
uniform vec2 center;
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main() {
|
||
|
#include <uv_vertex>
|
||
|
vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
|
||
|
vec2 scale;
|
||
|
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
|
||
|
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
|
||
|
#ifndef USE_SIZEATTENUATION
|
||
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
||
|
if ( isPerspective ) scale *= - mvPosition.z;
|
||
|
#endif
|
||
|
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
|
||
|
vec2 rotatedPosition;
|
||
|
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
||
|
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
||
|
mvPosition.xy += rotatedPosition;
|
||
|
gl_Position = projectionMatrix * mvPosition;
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`},_o={basic:{uniforms:Qi([wn.common,wn.specularmap,wn.envmap,wn.aomap,wn.lightmap,wn.fog]),vertexShader:Er.meshbasic_vert,fragmentShader:Er.meshbasic_frag},lambert:{uniforms:Qi([wn.common,wn.specularmap,wn.envmap,wn.aomap,wn.lightmap,wn.emissivemap,wn.fog,wn.lights,{emissive:{value:new Qe(0)}}]),vertexShader:Er.meshlambert_vert,fragmentShader:Er.meshlambert_frag},phong:{uniforms:Qi([wn.common,wn.specularmap,wn.envmap,wn.aomap,wn.lightmap,wn.emissivemap,wn.bumpmap,wn.normalmap,wn.displacementmap,wn.fog,wn.lights,{emissive:{value:new Qe(0)},specular:{value:new Qe(1118481)},shininess:{value:30}}]),vertexShader:Er.meshphong_vert,fragmentShader:Er.meshphong_frag},standard:{uniforms:Qi([wn.common,wn.envmap,wn.aomap,wn.lightmap,wn.emissivemap,wn.bumpmap,wn.normalmap,wn.displacementmap,wn.roughnessmap,wn.metalnessmap,wn.fog,wn.lights,{emissive:{value:new Qe(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Er.meshphysical_vert,fragmentShader:Er.meshphysical_frag},toon:{uniforms:Qi([wn.common,wn.specularmap,wn.aomap,wn.lightmap,wn.emissivemap,wn.bumpmap,wn.normalmap,wn.displacementmap,wn.gradientmap,wn.fog,wn.lights,{emissive:{value:new Qe(0)},specular:{value:new Qe(1118481)},shininess:{value:30}}]),vertexShader:Er.meshtoon_vert,fragmentShader:Er.meshtoon_frag},matcap:{uniforms:Qi([wn.common,wn.bumpmap,wn.normalmap,wn.displacementmap,wn.fog,{matcap:{value:null}}]),vertexShader:Er.meshmatcap_vert,fragmentShader:Er.meshmatcap_frag},points:{uniforms:Qi([wn.points,wn.fog]),vertexShader:Er.points_vert,fragmentShader:Er.points_frag},dashed:{uniforms:Qi([wn.common,wn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Er.linedashed_vert,fragmentShader:Er.linedashed_frag},depth:{uniforms:Qi([wn.common,wn.displacementmap]),vertexShader:Er.depth_vert,fragmentShader:Er.depth_frag},normal:{uniforms:Qi([wn.common,wn.bumpmap,wn.normalmap,wn.displacementmap,{opacity:{value:1}}]),vertexShader:Er.normal_vert,fragmentShader:Er.normal_frag},sprite:{uniforms:Qi([wn.sprite,wn.fog]),vertexShader:Er.sprite_vert,fragmentShader:Er.sprite_frag},background:{uniforms:{uvTransform:{value:new Ai},t2D:{value:null}},vertexShader:Er.background_vert,fragmentShader:Er.background_frag},cube:{uniforms:Qi([wn.envmap,{opacity:{value:1}}]),vertexShader:Er.cube_vert,fragmentShader:Er.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Er.equirect_vert,fragmentShader:Er.equirect_frag},distanceRGBA:{uniforms:Qi([wn.common,wn.displacementmap,{referencePosition:{value:new Re},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Er.distanceRGBA_vert,fragmentShader:Er.distanceRGBA_frag},shadow:{uniforms:Qi([wn.lights,wn.fog,{color:{value:new Qe(0)},opacity:{value:1}}]),vertexShader:Er.shadow_vert,fragmentShader:Er.shadow_frag}};function Lr(e,t,n,i){var l,d,m=new Qe(0),x=0,L=null,j=0,Z=null;function ee(ie,z){t.buffers.color.setClear(ie.r,ie.g,ie.b,z,i)}return{getClearColor:function(){return m},setClearColor:function(ie,z){m.set(ie),ee(m,x=z!==void 0?z:1)},getClearAlpha:function(){return x},setClearAlpha:function(ie){ee(m,x=ie)},render:function(ie,z,he,me){var ye=z.background,Ae=e.xr,Le=Ae.getSession&&Ae.getSession();if(Le&&Le.environmentBlendMode==="additive"&&(ye=null),ye===null?ee(m,x):ye&&ye.isColor&&(ee(ye,1),me=!0),(e.autoClear||me)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),ye&&(ye.isCubeTexture||ye.isWebGLCubeRenderTarget||ye.mapping===yt)){d===void 0&&((d=new Ti(new cc(1,1,1),new Ya({type:"BackgroundCubeMaterial",uniforms:Ss(_o.cube.uniforms),vertexShader:_o.cube.vertexShader,fragmentShader:_o.cube.fragmentShader,side:M,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(et,Fe,at){this.matrixWorld.copyPosition(at.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(d));var Ge=ye.isWebGLCubeRenderTarget?ye.texture:ye;d.material.uniforms.envMap.value=Ge,d.material.uniforms.flipEnvMap.value=Ge.isCubeTexture?-1:1,L===ye&&
|
||
|
`+l+function(d){for(var m=d.split(`
|
||
|
`),x=0;x<m.length;x++)m[x]=x+1+": "+m[x];return m.join(`
|
||
|
`)}(e.getShaderSource(t))}function tl(e,t){var n=Th(t);return"vec4 "+e+"( vec4 value ) { return "+n[0]+"ToLinear"+n[1]+"; }"}function nl(e){return e!==""}function Cu(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function pc(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var jl=/^[ \t]*#include +<([\w\d./]+)>/gm;function nr(e){return e.replace(jl,Su)}function Su(e,t){var n=Er[t];if(n===void 0)throw new Error("Can not resolve #include <"+t+">");return nr(n)}var Ch=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;function Os(e){return e.replace(Ch,Sh)}function Sh(e,t,n,i){for(var l="",d=parseInt(t);d<parseInt(n);d++)l+=i.replace(/\[ i \]/g,"[ "+d+" ]").replace(/UNROLLED_LOOP_INDEX/g,d);return l}function Dh(e){var t="precision "+e.precision+` float;
|
||
|
precision `+e.precision+" int;";return e.precision==="highp"?t+=`
|
||
|
#define HIGH_PRECISION`:e.precision==="mediump"?t+=`
|
||
|
#define MEDIUM_PRECISION`:e.precision==="lowp"&&(t+=`
|
||
|
#define LOW_PRECISION`),t}function Ra(e,t,n){var i,l,d,m,x,L,j,Z=e.getContext(),ee=n.defines,ie=n.vertexShader,z=n.fragmentShader,he=(l="SHADOWMAP_TYPE_BASIC",(i=n).shadowMapType===V?l="SHADOWMAP_TYPE_PCF":i.shadowMapType===I?l="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===g&&(l="SHADOWMAP_TYPE_VSM"),l),me=function(ur){var Sn="ENVMAP_TYPE_CUBE";if(ur.envMap)switch(ur.envMapMode){case Vt:case jt:Sn="ENVMAP_TYPE_CUBE";break;case yt:case Ue:Sn="ENVMAP_TYPE_CUBE_UV";break;case Ln:case nn:Sn="ENVMAP_TYPE_EQUIREC";break;case er:Sn="ENVMAP_TYPE_SPHERE"}return Sn}(n),ye=function(ur){var Sn="ENVMAP_MODE_REFLECTION";if(ur.envMap)switch(ur.envMapMode){case jt:case nn:Sn="ENVMAP_MODE_REFRACTION"}return Sn}(n),Ae=function(ur){var Sn="ENVMAP_BLENDING_NONE";if(ur.envMap)switch(ur.combine){case se:Sn="ENVMAP_BLENDING_MULTIPLY";break;case xe:Sn="ENVMAP_BLENDING_MIX";break;case De:Sn="ENVMAP_BLENDING_ADD"}return Sn}(n),Le=0<e.gammaFactor?e.gammaFactor:1,Ge=n.isWebGL2?"":[(d=n).extensionDerivatives||d.envMapCubeUV||d.bumpMap||d.tangentSpaceNormalMap||d.clearcoatNormalMap||d.flatShading||d.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(d.extensionFragDepth||d.logarithmicDepthBuffer)&&d.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",d.extensionDrawBuffers&&d.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(d.extensionShaderTextureLOD||d.envMap)&&d.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(nl).join(`
|
||
|
`),et=function(ur){var Sn=[];for(var Ne in ur){var nt=ur[Ne];nt!==!1&&Sn.push("#define "+Ne+" "+nt)}return Sn.join(`
|
||
|
`)}(ee),Fe=Z.createProgram(),at=n.numMultiviewViews;if(n.isRawShaderMaterial?(0<(m=[et].filter(nl).join(`
|
||
|
`)).length&&(m+=`
|
||
|
`),0<(x=[Ge,et].filter(nl).join(`
|
||
|
`)).length&&(x+=`
|
||
|
`)):(m=[Dh(n),"#define SHADER_NAME "+n.shaderName,et,n.instancing?"#define USE_INSTANCING":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+Le,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+ye:"",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.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+he:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","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","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#ifdef USE_COLOR"," attribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
||
|
`].filter(nl).join(`
|
||
|
`),x=[Ge,Dh(n),"#define SHADER_NAME "+n.shaderName,et,n.alphaTest?"#define ALPHATEST "+n.alphaTest+(n.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+Le,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 "+me:"",n.envMap?"#define "+ye:"",n.envMap?"#define "+Ae:"",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.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.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",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 "+he:"",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":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==tt?"#define TONE_MAPPING":"",n.toneMapping!==tt?Er.tonemapping_pars_fragment:"",n.toneMapping!==tt?function(ur,Sn){var Ne;switch(Sn){case st:Ne="Linear";break;case mt:Ne="Reinhard";break;case Rt:Ne="Uncharted2";break;case Ot:Ne="OptimizedCineon";break;case He:Ne="ACESFilmic";break;default:throw new Error("unsupported toneMapping: "+Sn)}return"vec3 toneMapping( vec3 color ) { return "+Ne+"ToneMapping( color ); }"}(0,n.toneMapping):"",n.dithering?"#define DITHERING":"",n.outputEncoding||n.mapEncoding||n.matcapEncoding||n.envMapEncoding||n.emissiveMapEncoding||n.lightMapEncoding?Er.encodings_pars_fragment:"",n.mapEncoding?tl("mapTexelToLinear",n.mapEncoding):"",n.matcapEncoding?tl("matcapTexelToLinear",n.matcapEncoding):"",n.envMapEncoding?tl("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMapEncoding?tl("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.lightMapEncoding?tl("lightMapTexelToLinear",n.lightMapEncoding):"",n.outputEncoding?(L=n.outputEncoding,j=Th(L),"vec4 linearToOutputTexel( vec4 value ) { return LinearTo"+j[0]+j[1]+"; }"):"",n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
|
||
|
`].filter(nl).join(`
|
||
|
`)),ie=pc(ie=Cu(ie=nr(ie),n),n),z=pc(z=Cu(z=nr(z),n),n),ie=Os(ie),z=Os(z),n.isWebGL2&&!n.isRawShaderMaterial){var Je=!1,xt=/^\s*#version\s+300\s+es\s*\n/;n.isShaderMaterial&&ie.match(xt)!==null&&z.match(xt)!==null&&(Je=!0,ie=ie.replace(xt,""),z=z.replace(xt,"")),m=[`#version 300 es
|
||
|
`,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
||
|
`)+`
|
||
|
`+m,x=[`#version 300 es
|
||
|
`,"#define varying in",Je?"":"out highp vec4 pc_fragColor;",Je?"":"#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(`
|
||
|
`)+`
|
||
|
`+x,0<at&&(m=(m=m.replace(`#version 300 es
|
||
|
`,[`#version 300 es
|
||
|
`,"#extension GL_OVR_multiview2 : require","layout(num_views = "+at+") in;","#define VIEW_ID gl_ViewID_OVR"].join(`
|
||
|
`))).replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join(`
|
||
|
`),["uniform mat4 modelViewMatrices["+at+"];","uniform mat4 projectionMatrices["+at+"];","uniform mat4 viewMatrices["+at+"];","uniform mat3 normalMatrices["+at+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join(`
|
||
|
`)),x=(x=x.replace(`#version 300 es
|
||
|
`,[`#version 300 es
|
||
|
`,"#extension GL_OVR_multiview2 : require","#define VIEW_ID gl_ViewID_OVR"].join(`
|
||
|
`))).replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+at+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join(`
|
||
|
`)))}var Tt,Et,At=x+z,Gt=_h(Z,35633,m+ie),Yt=_h(Z,35632,At);if(Z.attachShader(Fe,Gt),Z.attachShader(Fe,Yt),n.index0AttributeName!==void 0?Z.bindAttribLocation(Fe,0,n.index0AttributeName):n.morphTargets===!0&&Z.bindAttribLocation(Fe,0,"position"),Z.linkProgram(Fe),e.debug.checkShaderErrors){var St=Z.getProgramInfoLog(Fe).trim(),_t=Z.getShaderInfoLog(Gt).trim(),hn=Z.getShaderInfoLog(Yt).trim(),bn=!0,Kn=!0;if(Z.getProgramParameter(Fe,35714)===!1){bn=!1;var qn=Jo(Z,Gt,"vertex"),Bn=Jo(Z,Yt,"fragment");console.error("THREE.WebGLProgram: shader error: ",Z.getError(),"35715",Z.getProgramParameter(Fe,35715),"gl.getProgramInfoLog",St,qn,Bn)}else St!==""?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",St):_t!==""&&hn!==""||(Kn=!1);Kn&&(this.diagnostics={runnable:bn,programLog:St,vertexShader:{log:_t,prefix:m},fragmentShader:{log:hn,prefix:x}})}return Z.deleteShader(Gt),Z.deleteShader(Yt),this.getUniforms=function(){return Tt===void 0&&(Tt=new us(Z,Fe)),Tt},this.getAttributes=function(){return Et===void 0&&(Et=function(ur,Sn){for(var Ne={},nt=ur.getProgramParameter(Sn,35721),qt=0;qt<nt;qt++){var Ht=ur.getActiveAttrib(Sn,qt).name;Ne[Ht]=ur.getAttribLocation(Sn,Ht)}return Ne}(Z,Fe)),Et},this.destroy=function(){Z.deleteProgram(Fe),this.program=void 0},this.name=n.shaderName,this.id=qd++,this.cacheKey=t,this.usedTimes=1,this.program=Fe,this.vertexShader=Gt,this.fragmentShader=Yt,this.numMultiviewViews=at,this}function nd(e,t,n){var i=[],l=n.isWebGL2,d=n.logarithmicDepthBuffer,m=n.floatVertexTextures,x=n.precision,L=n.maxVertexUniforms,j=n.vertexTextures,Z={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},ee=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","numMultiviewViews","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen"];function ie(z){var he;return z?z.isTexture?he=z.encoding:z.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),he=z.texture.encoding):he=Ke,he}this.getParameters=function(z,he,me,ye,Ae,Le,Ge){var et=ye.fog,Fe=z.isMeshStandardMaterial?ye.environment:null,at=z.envMap||Fe,Je=Z[z.type],xt=Ge.isSkinnedMesh?function(Gt){var Yt=Ge.skeleton.bones;if(m)return 1024;var St=L,_t=Math.floor((St-20)/4),hn=Math.min(_t,Yt.length);return hn<Yt.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+Yt.length+" bones. This GPU supports "+hn+"."),0):hn}():0;z.precision!==null&&(x=n.getMaxPrecision(z.precision))!==z.precision&&console.warn("THREE.WebGLProgram.getParameters:",z.precision,"not supported, using",x,"instead.");var Tt=function(Gt,Yt){var St;if(Je){var _t=_o[Je];St={name:Gt.type,uniforms:lh.clone(_t.uniforms),vertexShader:_t.vertexShader,fragmentShader:_t.fragmentShader}}else St={name:Gt.type,uniforms:Gt.uniforms,v
|
||
|
uniform vec2 resolution;
|
||
|
uniform float radius;
|
||
|
#include <packing>
|
||
|
void main() {
|
||
|
float mean = 0.0;
|
||
|
float squared_mean = 0.0;
|
||
|
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );
|
||
|
for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {
|
||
|
#ifdef HORIZONAL_PASS
|
||
|
vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );
|
||
|
mean += distribution.x;
|
||
|
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
|
||
|
#else
|
||
|
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );
|
||
|
mean += depth;
|
||
|
squared_mean += depth * depth;
|
||
|
#endif
|
||
|
}
|
||
|
mean = mean * HALF_SAMPLE_RATE;
|
||
|
squared_mean = squared_mean * HALF_SAMPLE_RATE;
|
||
|
float std_dev = sqrt( squared_mean - mean * mean );
|
||
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
||
|
}`,od=`void main() {
|
||
|
gl_Position = vec4( position, 1.0 );
|
||
|
}`;function Oh(e,t,n){var i=new Qs,l=new zt,d=new zt,m=new Jr,x=[],L=[],j={},Z={0:M,1:A,2:N},ee=new Ya({defines:{SAMPLE_RATE:.25,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new zt},radius:{value:4}},vertexShader:od,fragmentShader:ad}),ie=ee.clone();ie.defines.HORIZONAL_PASS=1;var z=new Cn;z.setAttribute("position",new Qt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var he=new Ti(z,ee),me=this;function ye(Fe,at){var Je=t.update(he);ee.uniforms.shadow_pass.value=Fe.map.texture,ee.uniforms.resolution.value=Fe.mapSize,ee.uniforms.radius.value=Fe.radius,e.setRenderTarget(Fe.mapPass),e.clear(),e.renderBufferDirect(at,null,Je,ee,he,null),ie.uniforms.shadow_pass.value=Fe.mapPass.texture,ie.uniforms.resolution.value=Fe.mapSize,ie.uniforms.radius.value=Fe.radius,e.setRenderTarget(Fe.map),e.clear(),e.renderBufferDirect(at,null,Je,ie,he,null)}function Ae(Fe,at,Je){var xt=Fe<<0|at<<1|Je<<2,Tt=x[xt];return Tt===void 0&&(Tt=new Xo({depthPacking:Ei,morphTargets:Fe,skinning:at}),x[xt]=Tt),Tt}function Le(Fe,at,Je){var xt=Fe<<0|at<<1|Je<<2,Tt=L[xt];return Tt===void 0&&(Tt=new rl({morphTargets:Fe,skinning:at}),L[xt]=Tt),Tt}function Ge(Fe,at,Je,xt,Tt,Et){var At=Fe.geometry,Gt=null,Yt=Ae,St=Fe.customDepthMaterial;if(Je.isPointLight===!0&&(Yt=Le,St=Fe.customDistanceMaterial),St===void 0){var _t=!1;at.morphTargets===!0&&(At.isBufferGeometry===!0?_t=At.morphAttributes&&At.morphAttributes.position&&0<At.morphAttributes.position.length:At.isGeometry===!0&&(_t=At.morphTargets&&0<At.morphTargets.length));var hn=!1;Fe.isSkinnedMesh===!0&&(at.skinning===!0?hn=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",Fe)),Gt=Yt(_t,hn,Fe.isInstancedMesh===!0)}else Gt=St;if(e.localClippingEnabled&&at.clipShadows===!0&&at.clippingPlanes.length!==0){var bn=Gt.uuid,Kn=at.uuid,qn=j[bn];qn===void 0&&(qn={},j[bn]=qn);var Bn=qn[Kn];Bn===void 0&&(Bn=Gt.clone(),qn[Kn]=Bn),Gt=Bn}return Gt.visible=at.visible,Gt.wireframe=at.wireframe,Gt.side=Et===g?at.shadowSide!==null?at.shadowSide:at.side:at.shadowSide!==null?at.shadowSide:Z[at.side],Gt.clipShadows=at.clipShadows,Gt.clippingPlanes=at.clippingPlanes,Gt.clipIntersection=at.clipIntersection,Gt.wireframeLinewidth=at.wireframeLinewidth,Gt.linewidth=at.linewidth,Je.isPointLight===!0&&Gt.isMeshDistanceMaterial===!0&&(Gt.referencePosition.setFromMatrixPosition(Je.matrixWorld),Gt.nearDistance=xt,Gt.farDistance=Tt),Gt}function et(Fe,at,Je,xt,Tt){if(Fe.visible!==!1){if(Fe.layers.test(at.layers)&&(Fe.isMesh||Fe.isLine||Fe.isPoints)&&(Fe.castShadow||Fe.receiveShadow&&Tt===g)&&(!Fe.frustumCulled||i.intersectsObject(Fe))){Fe.modelViewMatrix.multiplyMatrices(Je.matrixWorldInverse,Fe.matrixWorld);var Et=t.update(Fe),At=Fe.material;if(Array.isArray(At))for(var Gt=Et.groups,Yt=0,St=Gt.length;Yt<St;Yt++){var _t=Gt[Yt],hn=At[_t.materialIndex];if(hn&&hn.visible){var bn=Ge(Fe,hn,xt,Je.near,Je.far,Tt);e.renderBufferDirect(Je,null,Et,bn,Fe,_t)}}else At.visible&&(bn=Ge(Fe,At,xt,Je.near,Je.far,Tt),e.renderBufferDirect(Je,null,Et,bn,Fe,null))}for(var Kn=Fe.children,qn=0,Bn=Kn.length;qn<Bn;qn++)et(Kn[qn],at,Je,xt,Tt)}}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=V,this.render=function(Fe,at,Je){if(me.enabled!==!1&&(me.autoUpdate!==!1||me.needsUpdate!==!1)&&Fe.length!==0){var xt=e.getRenderTarget(),Tt=e.getActiveCubeFace(),Et=e.getActiveMipmapLevel(),At=e.state;At.setBlending(T),At.buffers.color.setClear(1,1,1,1),At.buffers.depth.setTest(!0),At.setScissorTest(!1);for(var Gt=0,Yt=Fe.length;Gt<Yt;Gt++){var St=Fe[Gt],_t=St.shadow;if(_t!==void 0){l.copy(_t.mapSize);var hn=_t.getFrameExtents();if(l.multiply(hn),d.copy(_t.mapSize),(l.x>n||l.y>n)&&(console.warn("THREE.WebGLShadowMap:",St,"has shadow exceeding max texture size, reducing"),l.x>n&&(d.x=Math.floor(n/hn.x),l.x=d.x*hn.x,_t.mapSize.x=d.x),l.y>n&&(d.y=Math.floor(n/hn.y),l.y=d.y*hn.y,_t.mapSize.y=d.y)),_t.map===null&&!_t.isPointLightShadow&&this.type===g){var bn={minFilter:xn,magFilter:xn,format:Gr};_t.map=new Zi(l.x,l.y,bn),_t.map.texture.name=St.name+".shadowMap",_t.mapPass=new Zi(l.x,l.y,bn),_t.ca
|
||
|
`)z=0,he-=ee;else{var Ae=Sf(ye,Z,z,he,L);z+=Ae.offsetX,ie.push(Ae.path)}}return ie}(e,t,this.data),l=0,d=i.length;l<d;l++)Array.prototype.push.apply(n,i[l].toShapes());return n}}),op.prototype=Object.assign(Object.create(s.prototype),{constructor:op,load:function(e,t,n,i){var l=this,d=new P(this.manager);d.setPath(this.path),d.load(e,function(m){var x;try{x=JSON.parse(m)}catch(j){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),x=JSON.parse(m.substring(65,m.length-2))}var L=l.parse(x);t&&t(L)},n,i)},parse:function(e){return new ap(e)}});var sp={getContext:function(){return Cd===void 0&&(Cd=new(window.AudioContext||window.webkitAudioContext)),Cd},setContext:function(e){Cd=e}};function Sd(e){s.call(this,e)}function Dd(){this.coefficients=[];for(var e=0;e<9;e++)this.coefficients.push(new Re)}function ps(e,t){Ur.call(this,void 0,t),this.sh=e!==void 0?e:new Dd}function lp(e,t,n){ps.call(this,void 0,n);var i=new Qe().set(e),l=new Qe().set(t),d=new Re(i.r,i.g,i.b),m=new Re(l.r,l.g,l.b),x=Math.sqrt(Math.PI),L=x*Math.sqrt(.75);this.sh.coefficients[0].copy(d).add(m).multiplyScalar(x),this.sh.coefficients[1].copy(d).sub(m).multiplyScalar(L)}function cp(e,t){ps.call(this,void 0,t);var n=new Qe().set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}Sd.prototype=Object.assign(Object.create(s.prototype),{constructor:Sd,load:function(e,t,n,i){var l=new P(this.manager);l.setResponseType("arraybuffer"),l.setPath(this.path),l.load(e,function(d){var m=d.slice(0);sp.getContext().decodeAudioData(m,function(x){t(x)})},n,i)}}),Object.assign(Dd.prototype,{isSphericalHarmonics3:!0,set:function(e){for(var t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this},zero:function(){for(var e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this},getAt:function(e,t){var n=e.x,i=e.y,l=e.z,d=this.coefficients;return t.copy(d[0]).multiplyScalar(.282095),t.addScale(d[1],.488603*i),t.addScale(d[2],.488603*l),t.addScale(d[3],.488603*n),t.addScale(d[4],n*i*1.092548),t.addScale(d[5],i*l*1.092548),t.addScale(d[6],.315392*(3*l*l-1)),t.addScale(d[7],n*l*1.092548),t.addScale(d[8],.546274*(n*n-i*i)),t},getIrradianceAt:function(e,t){var n=e.x,i=e.y,l=e.z,d=this.coefficients;return t.copy(d[0]).multiplyScalar(.886227),t.addScale(d[1],1.023328*i),t.addScale(d[2],1.023328*l),t.addScale(d[3],1.023328*n),t.addScale(d[4],.858086*n*i),t.addScale(d[5],.858086*i*l),t.addScale(d[6],.743125*l*l-.247708),t.addScale(d[7],.858086*n*l),t.addScale(d[8],.429043*(n*n-i*i)),t},add:function(e){for(var t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this},scale:function(e){for(var t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this},lerp:function(e,t){for(var n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this},equals:function(e){for(var t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0},copy:function(e){return this.set(e.coefficients)},clone:function(){return new this.constructor().copy(this)},fromArray:function(e,t){t===void 0&&(t=0);for(var n=this.coefficients,i=0;i<9;i++)n[i].fromArray(e,t+3*i);return this},toArray:function(e,t){e===void 0&&(e=[]),t===void 0&&(t=0);for(var n=this.coefficients,i=0;i<9;i++)n[i].toArray(e,t+3*i);return e}}),Object.assign(Dd,{getBasisAt:function(e,t){var n=e.x,i=e.y,l=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*l,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*l,t[6]=.315392*(3*l*l-1),t[7]=1.092548*n*l,t[8]=.546274*(n*n-i*i)}}),ps.prototype=Object.assign(Object.create(Ur.prototype),{constructor:ps,isLightProbe:!0,copy:function(e){return Ur.prototype.copy.call(this,e),this.sh.copy(e.sh),this.intensity=e.intensity,this},toJSON:function(e){return Ur.prototype.toJSON.call(this,e)}}),lp.prototype=Object.assign(Object.create(ps.prototype),{constructor:lp,isHemisphereLightProbe:!0,copy:function(e){return ps.prototype.copy.call(this,e),this},toJSON:function(e){return ps.prototype.toJSON.call(this,e)}}),cp.prototype=Object.assign(Object.create(ps.prototype),{constructor:cp,isAmbientLightProbe:!0,copy:f
|
||
|
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 );
|
||
|
}
|
||
|
`,fragmentShader:`
|
||
|
precision mediump float;
|
||
|
precision mediump int;
|
||
|
varying vec3 vOutputDirection;
|
||
|
uniform sampler2D envMap;
|
||
|
uniform int samples;
|
||
|
uniform float weights[n];
|
||
|
uniform bool latitudinal;
|
||
|
uniform float dTheta;
|
||
|
uniform float mipInt;
|
||
|
uniform vec3 poleAxis;
|
||
|
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
|
||
|
#define ENVMAP_TYPE_CUBE_UV
|
||
|
#include <cube_uv_reflection_fragment>
|
||
|
|
||
|
void main() {
|
||
|
gl_FragColor = vec4(0.0);
|
||
|
for (int i = 0; i < n; i++) {
|
||
|
if (i >= samples)
|
||
|
break;
|
||
|
for (int dir = -1; dir < 2; dir += 2) {
|
||
|
if (i == 0 && dir == 1)
|
||
|
continue;
|
||
|
vec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);
|
||
|
if (all(equal(axis, vec3(0.0))))
|
||
|
axis = cross(vec3(0.0, 1.0, 0.0), vOutputDirection);
|
||
|
axis = normalize(axis);
|
||
|
float theta = dTheta * float(dir * i);
|
||
|
float cosTheta = cos(theta);
|
||
|
// Rodrigues' axis-angle rotation
|
||
|
vec3 sampleDirection = vOutputDirection * cosTheta
|
||
|
+ cross(axis, vOutputDirection) * sin(theta)
|
||
|
+ axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);
|
||
|
gl_FragColor.rgb +=
|
||
|
weights[i] * bilinearCubeUV(envMap, sampleDirection, mipInt);
|
||
|
}
|
||
|
}
|
||
|
gl_FragColor = linearToOutputTexel(gl_FragColor);
|
||
|
}
|
||
|
`,blending:T,depthTest:!1,depthWrite:!1})).type="SphericalGaussianBlur",uf),eu=null,tu=null,Op=function(){for(var e=[],t=[],n=[],i=ac,l=0;l<lf;l++){var d=Math.pow(2,i);t.push(d);var m=1/d;ac-eh<l?m=sf[l-ac+eh-1]:l==0&&(m=0),n.push(m);for(var x=1/(d-1),L=-x/2,j=1+x/2,Z=[L,L,j,L,j,j,L,L,j,j,L,j],ee=new Float32Array(108),ie=new Float32Array(72),z=new Float32Array(36),he=0;he<6;he++){var me=he%3*2/3-1,ye=2<he?0:-1,Ae=[me,ye,0,me+2/3,ye,0,me+2/3,1+ye,0,me,ye,0,me+2/3,1+ye,0,me,1+ye,0];ee.set(Ae,18*he),ie.set(Z,12*he);var Le=[he,he,he,he,he,he];z.set(Le,6*he)}var Ge=new Cn;Ge.setAttribute("position",new Qt(ee,3)),Ge.setAttribute("uv",new Qt(ie,2)),Ge.setAttribute("faceIndex",new Qt(z,1)),e.push(Ge),eh<i&&i--}return{_lodPlanes:e,_sizeLods:t,_sigmas:n}}(),Bh=Op._lodPlanes,hf=Op._sizeLods,zd=Op._sigmas,Ud=null,Ci=null,Pp=null,nu=(1+Math.sqrt(5))/2,nh=1/nu,df=[new Re(1,1,1),new Re(-1,1,1),new Re(1,1,-1),new Re(-1,1,-1),new Re(0,nu,nh),new Re(0,nu,-nh),new Re(nh,0,nu),new Re(-nh,0,nu),new Re(nu,nh,0),new Re(-nu,nh,0)];function Rp(e){Ci=e,Lp(Gd)}function pf(e){var t={magFilter:dt,minFilter:dt,generateMipmaps:!1,type:e?e.type:kr,format:e?e.format:wi,encoding:e?e.encoding:Jt,depthBuffer:!1,stencilBuffer:!1},n=mf(t);return n.depthBuffer=!e,Ud=mf(t),n}function ff(e){Ud.dispose(),Ci.setRenderTarget(Pp),e.scissorTest=!1,e.setSize(e.width,e.height)}function Lp(e){var t=new Hn;t.add(new Ti(Bh[0],e)),Ci.compile(t,Ap)}function mf(e){var t=new Zi(3*Vs,3*Vs,e);return t.texture.mapping=yt,t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}function Ip(e,t,n,i,l){e.viewport.set(t,n,i,l),e.scissor.set(t,n,i,l)}function gf(e){var t=Ci.autoClear;Ci.autoClear=!1;for(var n=1;n<lf;n++)yf(e,n-1,n,Math.sqrt(zd[n]*zd[n]-zd[n-1]*zd[n-1]),df[(n-1)%df.length]);Ci.autoClear=t}function yf(e,t,n,i,l){vf(e,Ud,t,n,i,"latitudinal",l),vf(Ud,e,n,n,i,"longitudinal",l)}function vf(e,t,n,i,l,d,m){d!=="latitudinal"&&d!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");var x=new Hn;x.add(new Ti(Bh[i],Gd));var L=Gd.uniforms,j=hf[n]-1,Z=isFinite(l)?Math.PI/(2*j):2*Math.PI/(2*th-1),ee=l/Z,ie=isFinite(l)?1+Math.floor(3*ee):th;th<ie&&console.warn("sigmaRadians, "+l+", is too large and will clip, as it requested "+ie+" samples when the maximum is set to "+th);for(var z=[],he=0,me=0;me<th;++me){var ye=me/ee,Ae=Math.exp(-ye*ye/2);z.push(Ae),me==0?he+=Ae:me<ie&&(he+=2*Ae)}for(me=0;me<z.length;me++)z[me]=z[me]/he;L.envMap.value=e.texture,L.samples.value=ie,L.weights.value=z,L.latitudinal.value=d==="latitudinal",m&&(L.poleAxis.value=m),L.dTheta.value=Z,L.mipInt.value=ac-n,L.inputEncoding.value=Ua[e.texture.encoding],L.outputEncoding.value=Ua[e.texture.encoding];var Le=hf[i];Ip(t,ye=3*Math.max(0,Vs-2*Le),(i===0?0:2*Vs)+2*Le*(ac-eh<i?i-ac+eh:0),3*Le,2*Le),Ci.setRenderTarget(t),Ci.render(x,Ap)}function xf(){var e=new ks({uniforms:{envMap:{value:null},texelSize:{value:new zt(1,1)},inputEncoding:{value:Ua[Ke]},outputEncoding:{value:Ua[Ke]}},vertexShader:`
|
||
|
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 );
|
||
|
}
|
||
|
`,fragmentShader:`
|
||
|
precision mediump float;
|
||
|
precision mediump int;
|
||
|
varying vec3 vOutputDirection;
|
||
|
uniform sampler2D envMap;
|
||
|
uniform vec2 texelSize;
|
||
|
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
|
||
|
#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:T,depthTest:!1,depthWrite:!1});return e.type="EquirectangularToCubeUV",e}function wf(){var e=new ks({uniforms:{envMap:{value:null},inputEncoding:{value:Ua[Ke]},outputEncoding:{value:Ua[Ke]}},vertexShader:`
|
||
|
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 );
|
||
|
}
|
||
|
`,fragmentShader:`
|
||
|
precision mediump float;
|
||
|
precision mediump int;
|
||
|
varying vec3 vOutputDirection;
|
||
|
uniform samplerCube envMap;
|
||
|
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
|
||
|
void main() {
|
||
|
gl_FragColor = vec4(0.0);
|
||
|
gl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ))).rgb;
|
||
|
gl_FragColor = linearToOutputTexel(gl_FragColor);
|
||
|
}
|
||
|
`,blending:T,depthTest:!1,depthWrite:!1});return e.type="CubemapToCubeUV",e}function bf(e){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Nn.call(this,e),this.type="catmullrom",this.closed=!0}function Mf(e){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Nn.call(this,e),this.type="catmullrom"}function kp(e){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),Nn.call(this,e),this.type="catmullrom"}Rp.prototype={constructor:Rp,fromScene:function(e,t,n,i){t===void 0&&(t=0),n===void 0&&(n=.1),i===void 0&&(i=100),Pp=Ci.getRenderTarget();var l=pf();return function(d,m,x,L){var j=new Ni(90,1,m,x),Z=[1,1,1,1,-1,1],ee=[1,1,-1,-1,-1,1],ie=Ci.outputEncoding,z=Ci.toneMapping,he=Ci.toneMappingExposure,me=Ci.getClearColor(),ye=Ci.getClearAlpha();Ci.toneMapping=st,Ci.toneMappingExposure=1,Ci.outputEncoding=Ke,d.scale.z*=-1;var Ae=d.background;if(Ae&&Ae.isColor){Ae.convertSRGBToLinear();var Le=Math.max(Ae.r,Ae.g,Ae.b),Ge=Math.min(Math.max(Math.ceil(Math.log2(Le)),-128),127);Ae=Ae.multiplyScalar(Math.pow(2,-Ge));var et=(Ge+128)/255;Ci.setClearColor(Ae,et),d.background=null}for(var Fe=0;Fe<6;Fe++){var at=Fe%3;at==0?(j.up.set(0,Z[Fe],0),j.lookAt(ee[Fe],0,0)):at==1?(j.up.set(0,0,Z[Fe]),j.lookAt(0,ee[Fe],0)):(j.up.set(0,Z[Fe],0),j.lookAt(0,0,ee[Fe])),Ip(L,at*Vs,2<Fe?Vs:0,Vs,Vs),Ci.setRenderTarget(L),Ci.render(d,j)}Ci.toneMapping=z,Ci.toneMappingExposure=he,Ci.outputEncoding=ie,Ci.setClearColor(me,ye),d.scale.z*=-1}(e,n,i,l),0<t&&yf(l,0,0,t),gf(l),ff(l),l},fromEquirectangular:function(e){return e.magFilter=dt,e.minFilter=dt,e.generateMipmaps=!1,this.fromCubemap(e)},fromCubemap:function(e){Pp=Ci.getRenderTarget();var t=pf(e);return function(n,i){var l=new Hn;n.isCubeTexture?tu==null&&(tu=wf()):eu==null&&(eu=xf());var d=n.isCubeTexture?tu:eu;l.add(new Ti(Bh[0],d));var m=d.uniforms;(m.envMap.value=n).isCubeTexture||m.texelSize.value.set(1/n.image.width,1/n.image.height),m.inputEncoding.value=Ua[n.encoding],m.outputEncoding.value=Ua[n.encoding],Ip(i,0,0,3*Vs,2*Vs),Ci.setRenderTarget(i),Ci.render(l,Ap)}(e,t),gf(t),ff(t),t},compileCubemapShader:function(){tu==null&&Lp(tu=wf())},compileEquirectangularShader:function(){eu==null&&Lp(eu=xf())},dispose:function(){Gd.dispose(),tu!=null&&tu.dispose(),eu!=null&&eu.dispose();for(var e=0;e<Bh.length;e++)Bh[e].dispose()}},gt.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(gt.prototype),(e.prototype.constructor=e).prototype.getPoint=t,e},Object.assign(va.prototype,{createPointsGeometry:function(e){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var t=this.getPoints(e);return this.createGeometry(t)},createSpacedPointsGeometry:function(e){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var t=this.getSpacedPoints(e);return this.createGeometry(t)},createGeometry:function(e){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var t=new lr,n=0,i=e.length;n<i;n++){var l=e[n];t.vertices.push(new Re(l.x,l.y,l.z||0))}return t}}),Object.assign(xa.prototype,{fromPoints:function(e){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)}}),bf.prototype=Object.create(Nn.prototype),Mf.prototype=Object.create(Nn.prototype),kp.prototype=Object.create(Nn.prototype),Object.assign(kp.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}),kd.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead."
|
||
|
uniform mat4 modelViewMatrix;
|
||
|
uniform mat4 projectionMatrix;
|
||
|
attribute vec2 position;
|
||
|
attribute vec3 color;
|
||
|
attribute vec4 tran1;
|
||
|
attribute vec4 tran2;
|
||
|
attribute vec4 tran3;
|
||
|
attribute vec4 tran4;
|
||
|
attribute float ishide;
|
||
|
varying vec4 vColor;
|
||
|
void main(){
|
||
|
mat4 tran;
|
||
|
tran[0][0] = tran1.x;tran[0][1] = tran1.y;tran[0][2] = tran1.z;tran[0][3] = tran1.w;
|
||
|
tran[1][0] = tran2.x;tran[1][1] = tran2.y;tran[1][2] = tran2.z;tran[1][3] = tran2.w;
|
||
|
tran[2][0] = tran3.x;tran[2][1] = tran3.y;tran[2][2] = tran3.z;tran[2][3] = tran3.w;
|
||
|
tran[3][0] = tran4.x;tran[3][1] = tran4.y;tran[3][2] = tran4.z;tran[3][3] = tran4.w;
|
||
|
if(ishide > 0.1)
|
||
|
vColor = vec4(color,0.0);
|
||
|
else
|
||
|
vColor = vec4(color,1.0);
|
||
|
gl_Position = projectionMatrix * modelViewMatrix * tran * vec4( position.x,position.y,0.0, 1.0 );
|
||
|
}
|
||
|
`,a.VSHADER_COLOR_POINT_BYLAYER=` precision highp float;
|
||
|
uniform mat4 modelViewMatrix;
|
||
|
uniform mat4 projectionMatrix;
|
||
|
uniform vec3 color;
|
||
|
attribute vec2 position;
|
||
|
attribute vec4 tran1;
|
||
|
attribute vec4 tran2;
|
||
|
attribute vec4 tran3;
|
||
|
attribute vec4 tran4;
|
||
|
attribute float ishide;
|
||
|
varying vec4 vColor;
|
||
|
void main(){
|
||
|
mat4 tran;
|
||
|
tran[0][0] = tran1.x;tran[0][1] = tran1.y;tran[0][2] = tran1.z;tran[0][3] = tran1.w;
|
||
|
tran[1][0] = tran2.x;tran[1][1] = tran2.y;tran[1][2] = tran2.z;tran[1][3] = tran2.w;
|
||
|
tran[2][0] = tran3.x;tran[2][1] = tran3.y;tran[2][2] = tran3.z;tran[2][3] = tran3.w;
|
||
|
tran[3][0] = tran4.x;tran[3][1] = tran4.y;tran[3][2] = tran4.z;tran[3][3] = tran4.w;
|
||
|
if(ishide > 0.1)
|
||
|
vColor = vec4(color,0.0);
|
||
|
else
|
||
|
vColor = vec4(color,1.0);
|
||
|
gl_Position = projectionMatrix * modelViewMatrix * tran * vec4( position.x,position.y,0.0, 1.0 );
|
||
|
}
|
||
|
`,a.FSHADER_COLOR_POINT=` precision highp float;
|
||
|
varying vec4 vColor;
|
||
|
void main() {
|
||
|
gl_FragColor = vColor;
|
||
|
}
|
||
|
`,a.VSHADER_COLOR_POINT_TEXTURE=` precision highp float;
|
||
|
uniform mat4 modelViewMatrix;
|
||
|
uniform mat4 projectionMatrix;
|
||
|
attribute vec2 position;
|
||
|
attribute vec2 uv;
|
||
|
attribute vec4 tran1;
|
||
|
attribute vec4 tran2;
|
||
|
attribute vec4 tran3;
|
||
|
attribute vec4 tran4;
|
||
|
varying vec2 vUv;
|
||
|
void main(){
|
||
|
vUv = uv;
|
||
|
mat4 tran;
|
||
|
tran[0][0] = tran1.x;tran[0][1] = tran1.y;tran[0][2] = tran1.z;tran[0][3] = tran1.w;
|
||
|
tran[1][0] = tran2.x;tran[1][1] = tran2.y;tran[1][2] = tran2.z;tran[1][3] = tran2.w;
|
||
|
tran[2][0] = tran3.x;tran[2][1] = tran3.y;tran[2][2] = tran3.z;tran[2][3] = tran3.w;
|
||
|
tran[3][0] = tran4.x;tran[3][1] = tran4.y;tran[3][2] = tran4.z;tran[3][3] = tran4.w;
|
||
|
gl_Position = projectionMatrix * modelViewMatrix * tran * vec4( position.x,position.y,0.0, 1.0 );
|
||
|
}
|
||
|
`,a.FSHADER_COLOR_POINT_TEXTURE=` precision highp float;
|
||
|
varying vec2 vUv;
|
||
|
uniform sampler2D texture;
|
||
|
void main() {
|
||
|
gl_FragColor = texture2D( texture, vUv );
|
||
|
}
|
||
|
`,a.VSHADER_COLOR_POINT_CLIP=` precision highp float;
|
||
|
uniform mat4 modelViewMatrix;
|
||
|
uniform mat4 projectionMatrix;
|
||
|
uniform vec2 clippt1;
|
||
|
uniform vec2 clippt2;
|
||
|
uniform float vieww;
|
||
|
uniform float viewh;
|
||
|
attribute vec2 position;
|
||
|
attribute vec3 color;
|
||
|
attribute vec4 tran1;
|
||
|
attribute vec4 tran2;
|
||
|
attribute vec4 tran3;
|
||
|
attribute vec4 tran4;
|
||
|
attribute float ishide;
|
||
|
varying vec4 vColor;
|
||
|
varying vec2 vCp1;
|
||
|
varying vec2 vCp2;
|
||
|
void main(){
|
||
|
mat4 tran;
|
||
|
tran[0][0] = tran1.x;tran[0][1] = tran1.y;tran[0][2] = tran1.z;tran[0][3] = tran1.w;
|
||
|
tran[1][0] = tran2.x;tran[1][1] = tran2.y;tran[1][2] = tran2.z;tran[1][3] = tran2.w;
|
||
|
tran[2][0] = tran3.x;tran[2][1] = tran3.y;tran[2][2] = tran3.z;tran[2][3] = tran3.w;
|
||
|
tran[3][0] = tran4.x;tran[3][1] = tran4.y;tran[3][2] = tran4.z;tran[3][3] = tran4.w;
|
||
|
vec4 pt1 = projectionMatrix * modelViewMatrix * vec4( clippt1.x,clippt1.y,0.0, 1.0 );
|
||
|
vec4 pt2 = projectionMatrix * modelViewMatrix * vec4( clippt2.x,clippt2.y,0.0, 1.0 );
|
||
|
vCp1 = vec2(pt1.x * vieww + vieww,pt1.y * viewh + viewh);
|
||
|
vCp2 = vec2(pt2.x * vieww + vieww,pt2.y * viewh + viewh);
|
||
|
if(ishide > 0.1)
|
||
|
vColor = vec4(color,0.0);
|
||
|
else
|
||
|
vColor = vec4(color,1.0);
|
||
|
gl_Position = projectionMatrix * modelViewMatrix * tran * vec4( position.x,position.y,0.0, 1.0 );
|
||
|
}
|
||
|
`,a.VSHADER_COLOR_POINT_BYLAYER_CLIP=` precision highp float;
|
||
|
uniform mat4 modelViewMatrix;
|
||
|
uniform mat4 projectionMatrix;
|
||
|
uniform vec3 color;
|
||
|
uniform vec2 clippt1;
|
||
|
uniform vec2 clippt2;
|
||
|
uniform float vieww;
|
||
|
uniform float viewh;
|
||
|
attribute vec2 position;
|
||
|
attribute vec4 tran1;
|
||
|
attribute vec4 tran2;
|
||
|
attribute vec4 tran3;
|
||
|
attribute vec4 tran4;
|
||
|
attribute float ishide;
|
||
|
varying vec4 vColor;
|
||
|
varying vec2 vCp1;
|
||
|
varying vec2 vCp2;
|
||
|
void main(){
|
||
|
mat4 tran;
|
||
|
tran[0][0] = tran1.x;tran[0][1] = tran1.y;tran[0][2] = tran1.z;tran[0][3] = tran1.w;
|
||
|
tran[1][0] = tran2.x;tran[1][1] = tran2.y;tran[1][2] = tran2.z;tran[1][3] = tran2.w;
|
||
|
tran[2][0] = tran3.x;tran[2][1] = tran3.y;tran[2][2] = tran3.z;tran[2][3] = tran3.w;
|
||
|
tran[3][0] = tran4.x;tran[3][1] = tran4.y;tran[3][2] = tran4.z;tran[3][3] = tran4.w;
|
||
|
vec4 pt1 = projectionMatrix * modelViewMatrix * vec4( clippt1.x,clippt1.y,0.0, 1.0 );
|
||
|
vec4 pt2 = projectionMatrix * modelViewMatrix * vec4( clippt2.x,clippt2.y,0.0, 1.0 );
|
||
|
vCp1 = vec2(pt1.x * vieww + vieww,pt1.y * viewh + viewh);
|
||
|
vCp2 = vec2(pt2.x * vieww + vieww,pt2.y * viewh + viewh);
|
||
|
if(ishide > 0.1)
|
||
|
vColor = vec4(color,0.0);
|
||
|
else
|
||
|
vColor = vec4(color,1.0);
|
||
|
gl_Position = projectionMatrix * modelViewMatrix * tran * vec4( position.x,position.y,0.0, 1.0 );
|
||
|
}
|
||
|
`,a.FSHADER_COLOR_POINT_CLIP=`precision highp float;
|
||
|
varying vec4 vColor;
|
||
|
varying vec2 vCp1;
|
||
|
varying vec2 vCp2;
|
||
|
void main() {
|
||
|
if(gl_FragCoord.x > vCp1.x && gl_FragCoord.x < vCp2.x && gl_FragCoord.y > vCp1.y && gl_FragCoord.y < vCp2.y)
|
||
|
gl_FragColor = vColor;
|
||
|
else
|
||
|
discard;
|
||
|
}
|
||
|
`,a.VSHADER_COLOR_POINT_FORMXCAD=` precision highp float;
|
||
|
uniform mat4 modelViewMatrix;
|
||
|
uniform mat4 projectionMatrix;
|
||
|
uniform vec3 color;
|
||
|
attribute vec2 position;
|
||
|
attribute vec4 tran1;
|
||
|
attribute vec4 tran2;
|
||
|
attribute vec4 tran3;
|
||
|
attribute vec4 tran4;
|
||
|
attribute float ishide;
|
||
|
varying vec4 vColor;
|
||
|
void main(){
|
||
|
mat4 tran;
|
||
|
tran[0][0] = tran1.x;tran[0][1] = tran1.y;tran[0][2] = tran1.z;tran[0][3] = tran1.w;
|
||
|
tran[1][0] = tran2.x;tran[1][1] = tran2.y;tran[1][2] = tran2.z;tran[1][3] = tran2.w;
|
||
|
tran[2][0] = tran3.x;tran[2][1] = tran3.y;tran[2][2] = tran3.z;tran[2][3] = tran3.w;
|
||
|
tran[3][0] = tran4.x;tran[3][1] = tran4.y;tran[3][2] = tran4.z;tran[3][3] = tran4.w;
|
||
|
gl_PointSize = 1.0;
|
||
|
if(ishide > 0.1)
|
||
|
vColor = vec4(color,0.0);
|
||
|
else
|
||
|
vColor = vec4(color,1.0);
|
||
|
gl_Position = projectionMatrix * modelViewMatrix * tran * vec4( position.x,position.y,0.0, 1.0 );
|
||
|
}
|
||
|
`,a.FSHADER_COLOR_POINT_FORMXCAD=` precision highp float;
|
||
|
varying vec4 vColor;
|
||
|
void main() {
|
||
|
gl_FragColor = vColor;
|
||
|
}
|
||
|
`,a.VSHADER_COLOR_POINT_CLIP_FORMXCAD=` precision highp float;
|
||
|
uniform mat4 modelViewMatrix;
|
||
|
uniform mat4 projectionMatrix;
|
||
|
uniform vec3 color;
|
||
|
uniform vec2 clippt1;
|
||
|
uniform vec2 clippt2;
|
||
|
uniform float vieww;
|
||
|
uniform float viewh;
|
||
|
attribute vec2 position;
|
||
|
attribute vec4 tran1;
|
||
|
attribute vec4 tran2;
|
||
|
attribute vec4 tran3;
|
||
|
attribute vec4 tran4;
|
||
|
attribute float ishide;
|
||
|
varying vec4 vColor;
|
||
|
varying vec2 vCp1;
|
||
|
varying vec2 vCp2;
|
||
|
void main(){
|
||
|
mat4 tran;
|
||
|
tran[0][0] = tran1.x;tran[0][1] = tran1.y;tran[0][2] = tran1.z;tran[0][3] = tran1.w;
|
||
|
tran[1][0] = tran2.x;tran[1][1] = tran2.y;tran[1][2] = tran2.z;tran[1][3] = tran2.w;
|
||
|
tran[2][0] = tran3.x;tran[2][1] = tran3.y;tran[2][2] = tran3.z;tran[2][3] = tran3.w;
|
||
|
tran[3][0] = tran4.x;tran[3][1] = tran4.y;tran[3][2] = tran4.z;tran[3][3] = tran4.w;
|
||
|
vec4 pt1 = projectionMatrix * modelViewMatrix * vec4( clippt1.x,clippt1.y,0.0, 1.0 );
|
||
|
vec4 pt2 = projectionMatrix * modelViewMatrix * vec4( clippt2.x,clippt2.y,0.0, 1.0 );
|
||
|
vCp1 = vec2(pt1.x * vieww + vieww,pt1.y * viewh + viewh);
|
||
|
vCp2 = vec2(pt2.x * vieww + vieww,pt2.y * viewh + viewh);
|
||
|
if(ishide > 0.1)
|
||
|
vColor = vec4(color,0.0);
|
||
|
else
|
||
|
vColor = vec4(color,1.0);
|
||
|
gl_Position = projectionMatrix * modelViewMatrix * tran * vec4( position.x,position.y,0.0, 1.0 );
|
||
|
}
|
||
|
`,a.FSHADER_COLOR_POINT_CLIP_FORMXCAD=`precision highp float;
|
||
|
varying vec4 vColor;
|
||
|
varying vec2 vCp1;
|
||
|
varying vec2 vCp2;
|
||
|
void main() {
|
||
|
if(gl_FragCoord.x > vCp1.x && gl_FragCoord.x < vCp2.x && gl_FragCoord.y > vCp1.y && gl_FragCoord.y < vCp2.y)
|
||
|
gl_FragColor = vColor;
|
||
|
else
|
||
|
discard;
|
||
|
}
|
||
|
`},{}],33:[function(w,r,o){Object.defineProperty(o,"__esModule",{value:!0}),o.MxStencilObject=void 0;var a=w("three"),v=w("./MxMaterial"),h=(b.prototype.object_onAfterRender=function(D){var U=this.aryMeshStencil;if(U&&0<U.length){D.getContext();var V=D.state.buffers;V.stencil.setLocked(!1),V.depth.setTest(!0),V.stencil.setTest(!1)}},b.prototype.object_onBeforeRender=function(D,U,V){var I=this.aryMeshStencil;if(I&&0<I.length){var g=D.getContext(),A=D.state.buffers;A.color.setMask(!1),A.color.setLocked(!0),A.depth.setTest(!1),A.stencil.setTest(!0),A.stencil.setMask(255),A.stencil.setClear(0),D.clearStencil(),A.stencil.setLocked(!0);var M=1,N=!0;I.forEach(function(F){N?(N=!1,A.stencil.setFunc(g.ALWAYS,M,255),A.stencil.setOp(g.KEEP,g.KEEP,g.REPLACE)):(A.stencil.setFunc(g.EQUAL,M,255),A.stencil.setOp(g.KEEP,g.KEEP,g.INCR),M++),D.mxRenderObject(F,U,V,F.material,null)}),A.color.setLocked(!1),A.color.setMask(!0),A.stencil.setMask(0),A.stencil.setFunc(g.EQUAL,M,255)}},b.prototype.associateObject=function(D,U){var V=this;U.forEach(function(g){if(3<=g.length){var A=new a.Shape(g),M=new a.ShapeGeometry(A),N=new a.Mesh(M,v.MxMaterial.getStencilMaterial());V.aryMeshStencil.push(N)}});var I=this;D.onBeforeRender=function(g,A,M){I.object_onBeforeRender(g,A,M)},D.onAfterRender=function(g){I.object_onAfterRender(g)}},b);function b(){this.aryMeshStencil=[]}o.MxStencilObject=h},{"./MxMaterial":30,three:19}],34:[function(w,r,o){Object.defineProperty(o,"__esModule",{value:!0}),o.MxString=void 0;var a=(v.prototype.Find=function(h){return this.m_val.indexOf(h)},v.prototype.Left=function(h){return this.m_val.substring(0,h)},v.prototype.Right=function(h){return this.m_val.substring(this.m_val.length-h,this.m_val.length)},v.prototype.TrimLeft=function(h){for(;0<this.m_val.length&&this.m_val[0]==h;)this.m_val=this.m_val.slice(1)},v.prototype.TrimRight=function(h){for(;0<this.m_val.length&&this.m_val[this.m_val.length-1]==h;)this.m_val=this.m_val.slice(0,-1)},v.prototype.AnalyzeString=function(h){return this.m_val.split(h)},v.prototype.IsEmpty=function(){return this.m_val.length==0},v.prototype.MakeUpper=function(){this.m_val=this.m_val.toUpperCase()},v.prototype.MakeLower=function(){this.m_val=this.m_val.toLowerCase()},v.prototype.GetLength=function(){return this.m_val.length},v);function v(h){this.m_val="",h!=null&&(this.m_val=h)}o.MxString=a},{}],35:[function(w,r,o){Object.defineProperty(o,"__esModule",{value:!0}),o.MxSystemVariable=void 0;var a=w("three"),v=w("./Operate/McEdJigOsnap"),h=(b.prototype.init=function(D){this.m_mxObj=D},b.prototype.getAllLinetypeName=function(){return this.m_vecLinetype},b.prototype.getSysVarBool=function(D){return this.m_data[D]!=null&&this.m_data[D]},b.prototype.setSysVarBool=function(D,U){this.m_data[D]=U},b.prototype.setSysVarPoint=function(D,U){this.m_data[D]=U},b.prototype.OnMessageMxCADSystemVariable=function(D){this.m_vecLinetype=[];var U=JSON.parse(D);if(U!=null){var V=U.vecLinetypeName;for(var I in V)this.m_vecLinetype.push(V[I]);this.m_data.CELTYPE=U.curLinetypeName,this.m_data.CLAYER=U.clayer,this.m_data.CECOLOR=U.cecolor,this.m_data.CECOLORINDEX=U.cecolorindex}this.m_mxObj.callEvent("loadSystmeVariableComplete")},b.prototype.getSysVarPoint=function(D){return this.m_data[D]==null?new a.Vector3(0,0,0):this.m_data[D]},b.prototype.setSysVarNumber=function(D,U){this.m_data[D]=U},b.prototype.getSysVarNumber=function(D){return this.m_data[D]==null?0:this.m_data[D]},b.prototype.getSysVar=function(D){return this.m_data[D]},b.prototype.setSysVar=function(D,U){this.m_data[D]=U},b);function b(){this.m_data={},this.m_mxObj=null,this.m_vecLinetype=[],this.m_data.GETPOINTSTATUS=0,this.m_data.LASTPOINT=void 0,this.m_data.LASTMOVEPOINT=void 0,this.m_data.CELTYPE="Continuous",this.m_data.CLAYER="0",this.m_data.CECOLOR=67108863,this.m_data.CECOLORINDEX=7,this.m_data.OSMODE=v.MxOsnapDefine.OsModeAll}o.MxSystemVariable=h},{"./Operate/McEdJigOsnap":43,three:19}],36:[function(w,r,o){Object.defineProperty(o,"__esModule",{value:!0}),o.MxTempMarkDraw=void 0;var a=w("three"),v=w("./MxFun"),h=w("./MxThreeJS"),b=(D.prototype.init=f
|
||
|
命令:`)}}}a=o.MxWindowsEvent||(o.MxWindowsEvent={}),v=!1,h=new Array,a.addEvent=function(T){h.push(T)},a.registEvent=function(){v||(v=!0,b.MxFun.isPC()&&(document.addEventListener("mousemove",g,!1),document.addEventListener("mouseup",A,!1),document.addEventListener("mousedown",N,!1),document.addEventListener("dblclick",M,!1),document.onkeydown=F))}},{"./MxDrawData":22,"./MxFun":27,"./Operate/MxJigCmdManager":54,"./UI/MxUiVue":65}],42:[function(w,r,o){Object.defineProperty(o,"__esModule",{value:!0}),o.McEdJigDynamicTrace=void 0;var a=w("three"),v=w("./MxJigCmdManager"),h=w("../MxFun"),b=w("../MxDrawData"),D=w("../MxTools"),U=w("../MxManager"),V=w("../MxThreeJS"),I=w("./McEdJigOsnap"),g=(A.prototype.IsEqual=function(_){return this.m_snapObjectId==_.m_snapObjectId&&this.m_pt.distanceTo(_.m_pt)<1e-6},A.prototype.drawLine=function(_,Y,k){var S=V.MxThreeJS.createLine(new a.Vector3(_.x,_.y,_.z),new a.Vector3(Y.x,Y.y,Y.z),this.m_iColor);k.add(S),this.m_aryDynDrawObject.push(S)},A.prototype.clearDraw=function(_){for(var Y=this.m_aryDynDrawObject.length,k=0;k<Y;k++)h.MxFun.removeThreejsObject(this.m_aryDynDrawObject[k],_);this.m_aryDynDrawObject=[]},A.prototype.draw=function(_,Y){var k=_.toSmallcoord(this.m_pt),S=new a.Vector3(k.x,k.y+this.m_iGripWidth,0),G=new a.Vector3(k.x,k.y-this.m_iGripWidth,0);this.drawLine(S,G,Y);var C=new a.Vector3(k.x+this.m_iGripWidth,k.y,0),B=new a.Vector3(k.x-this.m_iGripWidth,k.y,0);this.drawLine(C,B,Y)},A);function A(){this.m_snapObjectId=0,this.m_pt=new a.Vector3,this.m_osmode=0,this.m_iColor=16760703,this.m_iGripWidth=10,this.m_aryDynDrawObject=new Array}var M=(N.prototype.clearDraw=function(_){for(var Y=this.m_aryDynDrawObject.length,k=0;k<Y;k++)h.MxFun.removeThreejsObject(this.m_aryDynDrawObject[k],_);this.m_aryDynDrawObject=[]},N.prototype.draw=function(_,Y){this.m_draw.setWidth(this.m_iGripWidth),this.m_draw.draw(_.toSmallcoord(this.m_pt),this.m_ostype,Y)},N);function N(_,Y){var k=this;this.m_aryDynDrawObject=new Array,this.m_iGripWidth=10,this.m_draw=new I.McEdJigOsnapDraw,this.m_pt=_,this.m_ostype=Y,this.m_draw.setAddDynDrawObject_call(function(S){k.m_aryDynDrawObject.push(S)})}var F=(T.prototype.DynamicTraceTimeCall=function(_){if(!this.m_mxJig.isExit()&&this.m_iTimeCallId==_&&this.m_isDynTrace&&this.m_snapObjectId!=0){var Y=new g;Y.m_osmode=this.m_osmode,Y.m_snapObjectId=this.m_snapObjectId,Y.m_pt=this.m_ptSnapPoint,Y.m_iGripWidth=.5*this.m_mxJig.getMxObject().screenCoordLong2Doc(b.MxDrawData.m_dInputRectWidth);for(var k=this.m_aryTraceObject.length,S=this.m_mxJig.getMxObject().getTheTempDrawContainer_SmallCoord(),G=0;G<k;G++)if(this.m_aryTraceObject[G].IsEqual(Y))return this.m_aryTraceObject[G].clearDraw(S),void this.m_aryTraceObject.splice(G,1);this.m_aryTraceObject.push(Y),Y.draw(this.m_mxJig.getMxObject(),S),this.m_mxJig.getMxObject().updateDisplay()}},T.prototype.OnDynamicTrace=function(_,Y,k){if(this.m_isDynTrace)if(_==0)this.m_iTimeCallId++,this.m_snapObjectId=0;else{if(k==v.MxJigCmdManager.OsnapMode.kOsModeNear)return;var S=.5*this.m_mxJig.getMxObject().screenCoordLong2Doc(b.MxDrawData.m_dInputRectWidth);if(this.m_snapObjectId!=0&&this.m_ptSnapPoint.distanceTo(Y)<S)return;var G=this.m_iTimeCallId,C=this;setTimeout(function(){C.DynamicTraceTimeCall(G)},400),this.m_snapObjectId=_,this.m_ptSnapPoint=Y,this.m_osmode=k}},T.prototype.ClearOsmodeObjectDisplay=function(){for(var _=this.m_mxJig.getMxObject().getTheTempDrawContainer_SmallCoord(),Y=this.m_aryTraceOsmodeObject.length,k=0;k<Y;k++)this.m_aryTraceOsmodeObject[k].clearDraw(_);this.m_aryTraceOsmodeObject=[]},T.prototype.ClearTraceObject=function(){for(var _=this.m_mxJig.getMxObject().getTheTempDrawContainer_SmallCoord(),Y=this.m_aryTraceObject.length,k=0;k<Y;k++)this.m_aryTraceObject[k].clearDraw(_);this.m_aryTraceObject=[]},T.prototype.ClearDisplay=function(){this.ClearTraceObject(),this.ClearOsmodeObjectDisplay(),this.ClearDynDrawEntity()},T.prototype.GetTraceLine=function(_,Y,k,S){var G=Y.m_pt;if(G.distanceTo(_)<2*k)return[];var C={pt1:new a.Vector3(G.x-S,G.y),pt2:new a.Vector3(G.x+S,G.y)},B={pt1:new a.Vector3(G.x,G.y-S),pt2:n
|
||
|
`)==-1?V.MxUiVue.acutPrintf(`
|
||
|
`+B.m_val+" 或"+this.m_keyWords+":"):V.MxUiVue.acutPrintf(B.m_val+" 或"+this.m_keyWords+":"):B.m_val.indexOf(`
|
||
|
`)==-1?V.MxUiVue.acutPrintf(`
|
||
|
`+B.m_val+":"):V.MxUiVue.acutPrintf(B.m_val+":")},C);function C(){var B=S!==null&&S.apply(this,arguments)||this;return B.m_keyWords="",B.m_message="",B.m_keyWordPicked="",B.m_pWorldDraw=null,B.m_toucheType=D.MxJigCmdManager.InType.kGetBegan,B.m_cursorType=V.MxUiVue.CursorType.kNormal,B}o.MrxDbgUiPrBase=G},{"../MxManager":29,"../MxString":34,"../MxThreeJS":37,"../UI/MxUiVue":65,"./McGiWorldDraw":44,"./MxJig":53,"./MxJigCmdManager":54,three:19}],46:[function(w,r,o){var a,v=this&&this.__extends||(a=function(f,O){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(W,X){W.__proto__=X}||function(W,X){for(var J in X)Object.prototype.hasOwnProperty.call(X,J)&&(W[J]=X[J])})(f,O)},function(f,O){function W(){this.constructor=f}a(f,O),f.prototype=O===null?Object.create(O):(W.prototype=O.prototype,new W)});Object.defineProperty(o,"__esModule",{value:!0}),o.MrxDbgUiPrAngle=o.MrxDbgUiPrKeyWord=o.MrxDbgUiPrString=o.MrxDbgUiPrInt=o.MrxDbgUiPrDist=void 0;var h,b=w("three"),D=w("./MxJigCmdManager"),U=w("../MxFun"),V=w("./MrxDbgUiPrBase"),I=w("../UI/MxUiVue"),g=w("../MxThreeJS"),A=w("../MxString"),M=(v(N,h=V.MrxDbgUiPrBase),N.prototype.value=function(){return this.m_value},N.prototype.basePt=function(){return new b.Vector3(this.m_basePt.x,this.m_basePt.y,0)},N.prototype.setBasePt=function(f){this.m_basePt==null?this.m_basePt=new b.Vector3(f.x,f.y,0):(this.m_basePt.x=f.x,this.m_basePt.y=f.y),this.m_useBasePt=!0},N.prototype.setUseBasePt=function(f){this.m_useBasePt=f},N.prototype.initGo=function(){this.m_keyWordPicked="",this.m_retcall=null,this.clearLastInputPoint(),this.getDynImput().setGetNumber(!0),this.m_useBasePt&&this.SetLASTPOINT(this.m_basePt)},N.prototype.go=function(f){this.initGo(),this.m_retcall=f,this.m_previousInPoint=null,this.m_currentInPoint=null,this.m_value=0,D.MxJigCmdManager.runCmd(this)},N.prototype.onExitCommand=function(){var f=this;I.MxUiVue.setCursorType(I.MxUiVue.CursorType.kNormal);var O=!1;this.m_retcall!=null&&(D.MxJigCmdManager.setRunCmdEvent(function(){h.prototype.onExitCommand.call(f,!1),O=!0}),this.m_retcall(this.getReturnStatus(this.m_resultDragStatus)),D.MxJigCmdManager.setRunCmdEvent(void 0)),!O&&D.MxJigCmdManager.isWaitCmdNull()&&I.MxUiVue.restoreCmdStatus(),O||h.prototype.onExitCommand.call(this,!0)},N.prototype.onStartCommand=function(){I.MxUiVue.setCursorType(this.m_cursorType),this.printMessage(),D.MxJigCmdManager.setKeywordList(this.keyWords()),h.prototype.onStartCommand.call(this)},N.prototype.sampler=function(){var f,O=D.MxJigCmdManager.acquirePoint(this.m_toucheType,!1);return O.status==D.MxJigCmdManager.DragStatus.kNormal&&(this.m_currSamplerPoint==null?this.m_currSamplerPoint=new b.Vector3(O.pt.x,O.pt.y,0):(this.m_currSamplerPoint.x=O.pt.x,this.m_currSamplerPoint.y=O.pt.y)),f=this.m_useBasePt?this.acquireDist(this.m_toucheType,this.m_basePt):this.acquireDist(this.m_toucheType,this.m_currentInPoint),this.procInKeyword(f),f.status==D.MxJigCmdManager.DragStatus.kNormal?(this.m_value=f.dist,f.status):f.status==D.MxJigCmdManager.DragStatus.kKW1?f.status:this.m_useBasePt||this.m_currentInPoint?O.status:((f=this.acquirePoint(this.m_toucheType,!1)).status==D.MxJigCmdManager.DragStatus.kNormal&&f.exit&&(this.m_previousInPoint==null?this.m_previousInPoint=new b.Vector3(f.pt.x,f.pt.y,0):(this.m_previousInPoint.x=f.pt.x,this.m_previousInPoint.y=f.pt.y)),f.status)},N.prototype.done=function(f){if(this.m_retcall!=null)return this.m_resultDragStatus=f,this.m_useBasePt||f!=D.MxJigCmdManager.DragStatus.kNormal||!this.m_previousInPoint||this.m_currentInPoint?D.MxJigCmdManager.DoneStatius.kExitCommand:(this.m_currentInPoint=this.m_previousInPoint,this.m_previousInPoint=null,D.MxJigCmdManager.DoneStatius.kContinueCommand);U.MxFun.Assert(0)},N.prototype.upDisplay=function(){this.m_currSamplerPoint&&(this.m_pWorldDraw&&(this._mxObject.getMcObject().onReadyJigUpdateDispla(),this.m_pWorldDraw.worldDraw(this.m_currSamplerPoint)),this.m_useBasePt&&this.m_basePt?this.drawEntity(g.MxThreeJS.createLine(this.m_currSamplerPoint,this.m_basePt,16777215)):this.m_currentInPoint&&this.drawEntity(g.MxThreeJS
|
||
|
`)==-1?I.MxUiVue.acutPrintf(`
|
||
|
`+f.m_val+" "+this.m_keyWords+":"):I.MxUiVue.acutPrintf(f.m_val+" "+this.m_keyWords+":"):f.m_val.indexOf(`
|
||
|
`)==-1?I.MxUiVue.acutPrintf(`
|
||
|
`+f.m_val+":"):I.MxUiVue.acutPrintf(f.m_val+":")},B.prototype.go=function(f){this.initGo(),this.m_retcall=f,this.m_currSamplerPoint=null,D.MxJigCmdManager.runCmd(this)},B.prototype.onExitCommand=function(){var f=this;I.MxUiVue.setCursorType(I.MxUiVue.CursorType.kNormal);var O=!1;this.m_retcall!=null&&(D.MxJigCmdManager.setRunCmdEvent(function(){G.prototype.onExitCommand.call(f,!1),O=!0}),this.m_retcall(this.getReturnStatus(this.m_resultDragStatus)),D.MxJigCmdManager.setRunCmdEvent(void 0)),!O&&D.MxJigCmdManager.isWaitCmdNull()&&I.MxUiVue.restoreCmdStatus(),O||G.prototype.onExitCommand.call(this,!0)},B.prototype.onStartCommand=function(){I.MxUiVue.setCursorType(this.m_cursorType),this.printMessage(),D.MxJigCmdManager.setKeywordList(this.keyWords()),G.prototype.onStartCommand.call(this)},B.prototype.sampler=function(){var f=D.MxJigCmdManager.acquirePoint(this.m_toucheType,!1);f.status==D.MxJigCmdManager.DragStatus.kNormal&&(this.m_currSamplerPoint==null?this.m_currSamplerPoint=new b.Vector3(f.pt.x,f.pt.y,0):(this.m_currSamplerPoint.x=f.pt.x,this.m_currSamplerPoint.y=f.pt.y));var O=this.acquireKeyword();return this.procInKeyword(O),O.status,D.MxJigCmdManager.DragStatus.kKW1,O.status},B.prototype.done=function(f){if(this.m_retcall!=null)return f>=D.MxJigCmdManager.DragStatus.kKW1&&(f=D.MxJigCmdManager.DragStatus.kNormal),this.m_resultDragStatus=f,D.MxJigCmdManager.DoneStatius.kExitCommand;U.MxFun.Assert(0)},B.prototype.upDisplay=function(){this.m_currSamplerPoint&&this.m_pWorldDraw&&(this._mxObject.getMcObject().onReadyJigUpdateDispla(),this.m_pWorldDraw.worldDraw(this.m_currSamplerPoint))},B);function B(){var f=G.call(this)||this;return f.m_currSamplerPoint=null,f.m_retcall=null,f.m_resultDragStatus=D.MxJigCmdManager.DragStatus.kCancel,f.m_cursorType=I.MxUiVue.CursorType.kCross,f.setUserInputControls(0),f.setDisableDynInput(!0),f}o.MrxDbgUiPrKeyWord=C;var R,u=(v(c,R=V.MrxDbgUiPrBase),c.prototype.value=function(){return this.m_value},c.prototype.basePt=function(){return new b.Vector3(this.m_basePt.x,this.m_basePt.y,0)},c.prototype.setBasePt=function(f){this.m_basePt==null?this.m_basePt=new b.Vector3(f.x,f.y,0):(this.m_basePt.x=f.x,this.m_basePt.y=f.y),this.m_useBasePt=!0},c.prototype.setUseBasePt=function(f){this.m_useBasePt=f},c.prototype.initGo=function(){this.m_keyWordPicked="",this.m_retcall=null,this.getDynImput().setGetNumber(!0),this.clearLastInputPoint(),this.m_useBasePt&&this.SetLASTPOINT(this.m_basePt)},c.prototype.go=function(f){this.initGo(),this.m_retcall=f,this.m_previousInPoint=null,this.m_currentInPoint=null,this.m_value=0,D.MxJigCmdManager.runCmd(this)},c.prototype.onExitCommand=function(){var f=this;I.MxUiVue.setCursorType(I.MxUiVue.CursorType.kNormal);var O=!1;this.m_retcall!=null&&(D.MxJigCmdManager.setRunCmdEvent(function(){R.prototype.onExitCommand.call(f,!1),O=!0}),this.m_retcall(this.getReturnStatus(this.m_resultDragStatus)),D.MxJigCmdManager.setRunCmdEvent(void 0)),!O&&D.MxJigCmdManager.isWaitCmdNull()&&I.MxUiVue.restoreCmdStatus(),O||R.prototype.onExitCommand.call(this,!0)},c.prototype.onStartCommand=function(){I.MxUiVue.setCursorType(this.m_cursorType),this.printMessage(),D.MxJigCmdManager.setKeywordList(this.keyWords()),R.prototype.onStartCommand.call(this)},c.prototype.sampler=function(){var f,O=D.MxJigCmdManager.acquirePoint(this.m_toucheType,!1);return O.status==D.MxJigCmdManager.DragStatus.kNormal&&(this.m_currSamplerPoint==null?this.m_currSamplerPoint=new b.Vector3(O.pt.x,O.pt.y,0):(this.m_currSamplerPoint.x=O.pt.x,this.m_currSamplerPoint.y=O.pt.y)),f=this.m_useBasePt?this.acquireAngle(this.m_toucheType,this.m_basePt):this.acquireAngle(this.m_toucheType,this.m_currentInPoint),this.procInKeyword(f),f.status==D.MxJigCmdManager.DragStatus.kNormal?(this.m_value=f.ang,f.status):f.status==D.MxJigCmdManager.DragStatus.kKW1?f.status:this.m_useBasePt||this.m_currentInPoint?O.status:((f=this.acquirePoint(this.m_toucheType,!1)).status==D.MxJigCmdManager.DragStatus.kNormal&&f.exit&&(this.m_previousInPoint==null?this.m_previousInPoint=new b.Vector3(f.pt.x,f.pt.y,0):(this.m_previousInPoint.x=f.pt.x,this.m
|
||
|
命令:`,_),!1}if(!S)return!1;T.endPanCommand(),T.getTempMarkDraw().clear(!1);var C=h.indexOf(S.cmd);-1<C&&h.splice(C,1),D=!(b=0),h.push(S.cmd),!(S.flag&A.MxType.MxCommandFlag.MCRX_CMD_NO_RECORD_PRVCMD)&&(U=S.cmd);var B=S.fun;T&&!(S.flag&A.MxType.MxCommandFlag.MCRX_CMD_TRANSPARENT)&&N.MxUiVue.acutPrintf(`{0}
|
||
|
`,S.cmd),M.MxJigCmdManager.stopCmd(M.MxJigCmdManager.DetailedResult.kNewCommadIn),T.callEvent("commandWillStart",{cmd:S.cmd}),T.getMcObject().fireStartRunCommand(S.cmd,S.flag);var R=T.sysVariable().getSysVarNumber("GETPOINTSTATUS");if(R&=~M.MxJigCmdManager.GETPOINTSTATUS.OsModeSValidLastPoint,R&=~M.MxJigCmdManager.GETPOINTSTATUS.OsModeSValidLastMovePoint,T.sysVariable().setSysVarNumber("GETPOINTSTATUS",R),T&&(S.flag&A.MxType.MxCommandFlag.MCRX_CMD_NO_CLEAR_SELECT)==0){var u=!1,c=T.getMxAllSelect();if(T.getMxDatabase().getGripManager().removeAllGrips()&&(u=!0),T.getMxDatabase().getSelectManager().removeAllEntity()&&(u=!0),T.isValidMcObject()){var f=T.getMcObject().getGripManager().getAllSelect();T.getMcObject().getGripManager().setPrvCommandSelect(f),T.getMcObject().getGripManager().clearAll()&&(u=!0)}T.getMxDatabase().getSelectManager().setPrvCommandSelect(c),u&&(T.getMxDatabase().getGripManager().fireMxEntitySelectChange(),T.updateDisplay())}try{B(Y)}catch(O){console.log("mx: run cmd error"),console.log(O)}return T.getMcObject().fireEndRunCommand(S.cmd,S.flag),T&&(M.MxJigCmdManager.isRunning()||N.MxUiVue.restoreCmdStatus(),T.updateDisplay(),F.MxDrawData.m_isAutoResetRenderer||T.resetRenderer()),!0},a.addCommand=function(T,_,Y){Y==null&&(Y=A.MxType.MxCommandFlag.MCRX_CMD_MODAL);var k=T.toUpperCase();v[k]={fun:_,cmd:T,flag:Y}}},{"../MxDrawData":22,"../MxFun":27,"../MxType":39,"../UI/MxUiVue":65,"./MxJigCmdManager":54}],49:[function(w,r,o){var a,v=this&&this.__extends||(a=function(C,B){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(R,u){R.__proto__=u}||function(R,u){for(var c in u)Object.prototype.hasOwnProperty.call(u,c)&&(R[c]=u[c])})(C,B)},function(C,B){function R(){this.constructor=C}a(C,B),C.prototype=B===null?Object.create(B):(R.prototype=B.prototype,new R)});Object.defineProperty(o,"__esModule",{value:!0}),o.MxDrawObjectOsnap=o.McDbLine=o.McDbCurve=o.McDbEntity=o.McDbType=void 0;var h,b,D=w("three"),U=w("../MxThreeJS"),V=w("../MxDrawData"),I=w("./MxJigCmdManager"),g=w("./McEdJigOsnap");(b=h=o.McDbType||(o.McDbType={}))[b.kInValid=0]="kInValid",b[b.kLine=1]="kLine";var A=(M.prototype.getType=function(){return this.m_type},M);function M(){this.m_type=h.kInValid}o.McDbEntity=A;var N,F=(v(T,N=A),T);function T(){return N!==null&&N.apply(this,arguments)||this}o.McDbCurve=F;var _,Y=(v(k,_=F),k);function k(){var C=_.call(this)||this;return C.m_type=h.kLine,C}o.McDbLine=Y;var S=(G.prototype.getBlobHead=function(C,B){var R={};return R.type=C.getInt32(B,!0),B+=4,R.ver=C.getInt32(B,!0),B+=4,R.databaseIndex=C.getInt32(B,!0),B+=4,R.nOffset=B,R},G.prototype.clearData=function(){this.threejsObjects=new D.Object3D},G.prototype.calculateDistance=function(C,B,R){var u=new D.Vector3().subVectors(B,C),c=new D.Vector3().subVectors(R,C),f=u.clone().normalize(),O=c.clone().normalize(),W=f.dot(O),X=new D.Vector3().subVectors(R,B),J=new D.Vector3().subVectors(C,B),te=X.clone().normalize(),ne=J.clone().normalize();if(0<te.dot(ne)&&0<W){var ue=Math.sqrt(1-W*W),be=C.distanceTo(R),je=be*ue,ve=be*W,Be=u.clone().normalize().multiplyScalar(ve),q=C.clone().add(Be),ge=u.clone().normalize().multiplyScalar(200+ve);return{pt1:C,pt2:B,pt:R,distance:je,targetPt:q,warningPt:C.clone().add(ge)}}return null},G.prototype.getOsnapData=function(C,B){if(this.threejsObjects){var R=new D.Raycaster,u=V.MxDrawData.m_dInputRectWidth;R.linePrecision=this.mxObj.screenCoordLong2World(u);var c=this.mxObj.getCanvas(),f=c.clientWidth,O=c.clientHeight,W=this.mxObj.screenCoord2World(C.x,C.y);W.z=0,C=new D.Vector2(C.x/f*2-1,-C.y/O*2+1),R.setFromCamera(C,this.mxObj.getCamera());var X=R.intersectObjects(this.threejsObjects.children,!0),J=this.mxObj.getSysVarLong("OSMODE"),te=new Map;if(X.length)for(var ne=0;ne<X.length;ne++){var ue=X[ne];if(ue.object.userData&&ue.object.userData.obj.getType()==h.kLine){var be=ue.object.userData.obj;if(J&g.MxOsnapDefine.OsModeEnd){var je=W.distanceTo(be.pt1);be.pt1.type=I.MxJigCmdManager.OsnapMode.kOsModeEnd,te.set(je,be.pt1);var ve=W.distanceTo(be.pt2);be.pt2.type=I.MxJigCmdManager.OsnapMode.kOsModeEnd,te.set(ve,be.pt2
|
||
|
值必须为正 且非零。
|
||
|
`):xn(`
|
||
|
值必不能为零。
|
||
|
`),xn(ut),C.kOther):$e!=J.COMMAND_IN_INVALID_NEG?C.kNoChange:(ut=I.MxUiVue.getCmdTip(),q.userInputControls()&Y.kNoZeroResponseAccepted?xn(`
|
||
|
值必须为正 且非零。
|
||
|
`):xn(`
|
||
|
值必不能为负。
|
||
|
`),xn(ut),C.kOther)}function Yn($e){var We={iRet:J.COMMAND_IN_NO_ENTITY,sValue:"",iKey:C.kNull,dDist:0,iVal:0,pt:null,cmdText:""};if(!xe)return We;var ut=q.userInputControls(),Ie=I.MxUiVue.getCmdText();if((We.cmdText=Ie).length==0)return ut&Y.kNullResponseAccepted?We.iRet=J.COMMAND_IN_EMTPY:We.iRet=J.COMMAND_IN_INVALID,We;if($e&ne.COMMAND_GET_KEY&&0<tt.size){var Mt=new A.MxString(Ie);Mt.MakeUpper(),Mt.TrimLeft(" "),Mt.TrimRight(" ");var rn=tt.get(Mt.m_val);if(rn!=null)return We.iRet=J.COMMAND_IN_KEY,We.iKey=rn,We.sValue=Mt.m_val,We}if($e&ne.COMMAND_GET_DIST&&g.MxTools.IsNumerical(Ie))return We.dDist=g.MxTools._tstof(Ie),ut&Y.kNoZeroResponseAccepted&&g.MxTools.IsZero(We.dDist)?We.iRet=J.COMMAND_IN_INVALID_ZERO:ut&Y.kNoNegativeResponseAccepted&&We.dDist<0?We.iRet=J.COMMAND_IN_INVALID_NEG:(We.sValue=Ie,We.iRet=J.COMMAND_IN_DIST),We;if($e&ne.COMMAND_GET_INT&&g.MxTools.IsNumerical(Ie))return We.iVal=g.MxTools._tstoi(Ie),ut&Y.kNoZeroResponseAccepted&&We.iVal==0?We.iRet=J.COMMAND_IN_INVALID_ZERO:ut&Y.kNoNegativeResponseAccepted&&We.iVal<0?We.iRet=J.COMMAND_IN_INVALID_NEG:(We.sValue=Ie,We.iRet=J.COMMAND_IN_INT),We;if($e&ne.COMMAND_GET_COORD){var tn=Xt(Ie);if(tn!=null)return We.sValue=Ie,We.iRet=J.COMMAND_IN_COORD,We.pt=tn,We}return $e&ne.COMMAND_GET_STRING?(We.sValue=Ie,We.iRet=J.COMMAND_IN_STRING):We.iRet=J.COMMAND_IN_INVALID,We}function kr($e){var We=q.getMxObject();if(We.sysVariable().setSysVarPoint("LASTPOINT",$e),$e){var ut=We.sysVariable().getSysVarNumber("GETPOINTSTATUS");ut|=_.GETPOINTSTATUS.OsModeSValidLastPoint,We.sysVariable().setSysVarNumber("GETPOINTSTATUS",ut)}else ut=We.sysVariable().getSysVarNumber("GETPOINTSTATUS"),ut&=~_.GETPOINTSTATUS.OsModeSValidLastPoint,We.sysVariable().setSysVarNumber("GETPOINTSTATUS",ut)}function Br($e){var We=new T;return oe==S.kMove?(We.status=C.kNormal,We.pt=Be,We.exit=!1):oe==S.kEnd?$e&f.kGetEnd?(We.status=C.kNormal,We.pt=Be,We.exit=!0,We.DetailedResult=R.kTouchUpIn,kr(We.pt)):(We.status=C.kNormal,We.pt=Be,We.exit=!1):oe==S.kCancle?(We.status=C.kCancel,We.pt=Be,We.exit=!0):oe==S.kBegan?$e&f.kGetBegan?(We.status=C.kNormal,We.pt=Be,We.exit=!0,We.DetailedResult=R.kTouchDownIn,kr(We.pt)):(We.status=C.kNormal,We.pt=Be,We.exit=!1):oe==S.kMouseDown?(We.status=C.kNormal,We.pt=Be,We.exit=!0,We.DetailedResult=R.kMouseLeftIn,kr(We.pt)):(We.status=C.kNoChange,We.pt=void 0,We.exit=!1),We}_.getInputKeyword=function($e){if($e<1)return"";for(var We,ut=tt.entries();!(We=ut.next()).done;)if(We.value==$e)return We.key;return""},_.GetKeyWordToString=function(){return st},_.keywordList=function(){return mt.m_val},_.setKeywordList=function($e){if(mt.m_val=$e,tt.clear(),st.length=0,!mt.IsEmpty())if(mt.TrimLeft(" "),mt.TrimRight(" "),mt.m_val[0]=="["&&mt.m_val[mt.m_val.length-1]=="]"){mt.TrimLeft("["),mt.TrimRight("]");for(var We=mt.AnalyzeString("/"),ut=1,Ie=0;Ie<We.length;Ie++){var Mt=(En=new A.MxString(We[Ie])).Find("(");if(Mt!=-1){var rn=new A.MxString(En.Left(Mt)),tn=new A.MxString(En.Right(En.GetLength()-Mt-1));tn.TrimRight(")"),rn.IsEmpty()||tn.IsEmpty()||(tn.MakeUpper(),tt.set(tn.m_val,ut),ut++,st.push(new g.MxPair(tn.m_val,rn.m_val)))}}}else for(We=mt.AnalyzeString(" "),ut=1,Ie=0;Ie<We.length;Ie++){var En;(En=new A.MxString(We[Ie])).IsEmpty()||(En.MakeUpper(),tt.set(En.m_val,ut),ut++)}},_.getAcquirePoint=function(){return Be},_.getAcquireStatus=function(){return oe},_.doMouseMoveImp=On,_.OnThreeControlsChage=function(){if(q!=null)return q.getOsnap().reComputeOffset(),void(Ye.x!=Pe&&Ye.y!=Pe&&On(Ye))},_.OnEnter=function($e){De=$e,xe=!0,oe=S.kNoChange,He(),xe=!1},_.Test=function(){xe=!0},_.registEvent=Xn,_.unRegistEvent=dt,_.getCurrentMouseButton=function(){return le},_.isRunning=function(){return q!=null},_.getCurCmd=function(){return q},_.commandRunComplete=function($e){q!=$e&&console.log("aseert:_curCmd == cmd");var We,ut,Ie=D.MxManager.currentMx();q!=null&&(Ie=q.getMxObject()),ge!=null?(q=ge,ge=void 0,le=W.kInvalid,Xn(),q.onStartCommand(),lt(Ie)):(dt(),q=void 0,ut=(We=Ie).getOrbitControls(),h.MxFun.isPC()?Ot!=-2&&(ut.mouseButtons.LEFT=Ot,Ot=-2,ut.resetStatusValue()):(N.MxDrawData.m_isMobileComman
|
||
|
需要输入关键字。
|
||
|
`),$e.exit=!1),$e},_.acquireString=function(){var $e=new T;if(q==null)return $e.status=C.kCancel,$e.exit=!0,$e;var We=Yn(ne.COMMAND_GET_STRING|ne.COMMAND_GET_KEY);return We.iRet==J.COMMAND_IN_EMTPY?($e.status=C.kNull,$e.exit=!0,De==13?$e.DetailedResult=R.kNullEnterIn:De==32?$e.DetailedResult=R.kNullSpaceIn:De==-1&&($e.DetailedResult=R.kMouseRightIn)):We.iRet==J.COMMAND_IN_KEY?($e.status=We.iKey,$e.exit=!0,$e.sKeyValue=We.sValue,$e.DetailedResult=R.kKeyIn):We.iRet==J.COMMAND_IN_STRING?($e.status=C.kNormal,$e.sValue=We.sValue,$e.exit=!0,$e.DetailedResult=R.kKeyIn):($e.status=$t(We.iRet,`
|
||
|
需要输入非空字符串。
|
||
|
`),$e.exit=!1),$e},_.acquireInt=function(){var $e=new T;if(q==null)return $e.status=C.kCancel,$e.exit=!0,$e;var We=Yn(ne.COMMAND_GET_INT|ne.COMMAND_GET_KEY);return We.iRet==J.COMMAND_IN_EMTPY?($e.status=C.kNull,$e.exit=!0,De==13?$e.DetailedResult=R.kNullEnterIn:De==32?$e.DetailedResult=R.kNullSpaceIn:De==-1&&($e.DetailedResult=R.kMouseRightIn)):We.iRet==J.COMMAND_IN_KEY?($e.status=We.iKey,$e.exit=!0,$e.sKeyValue=We.sValue,$e.DetailedResult=R.kKeyIn):We.iRet==J.COMMAND_IN_INT?($e.status=C.kNormal,$e.iVal=We.iVal,$e.exit=!0,$e.DetailedResult=R.kKeyIn):($e.status=$t(We.iRet,`
|
||
|
需要整数或选项关键字。
|
||
|
`),$e.exit=!1),$e},_.acquireDist=function($e,We){var ut=new T;if(q==null)return ut.status=C.kCancel,ut.exit=!0,ut;var Ie=Yn(ne.COMMAND_GET_DIST|ne.COMMAND_GET_KEY);if(Ie.iRet==J.COMMAND_IN_EMTPY)return ut.status=C.kNull,ut.exit=!0,De==13?ut.DetailedResult=R.kNullEnterIn:De==32?ut.DetailedResult=R.kNullSpaceIn:De==-1&&(ut.DetailedResult=R.kMouseRightIn),ut;if(Ie.iRet==J.COMMAND_IN_KEY)return ut.status=Ie.iKey,ut.exit=!0,ut.sKeyValue=Ie.sValue,ut.DetailedResult=R.kKeyIn,ut;if(Ie.iRet==J.COMMAND_IN_DIST)return ut.status=C.kNormal,ut.dist=Ie.dDist,ut.exit=!0,ut.DetailedResult=R.kCoordIn,ut;if(ut.status=$t(Ie.iRet,`
|
||
|
需要点或选项关键字。
|
||
|
`),!We||Ie.iRet==J.COMMAND_IN_INVALID_ZERO||Ie.iRet==J.COMMAND_IN_INVALID_NEG)return ut.exit=!1,ut;var Mt=Br($e);if(Mt.status==C.kNormal&&Mt.exit){var rn=Mt.pt.clone(),tn=We.clone();rn.z=tn.z=0;var En=rn.distanceTo(tn);return q.userInputControls()&Y.kNoZeroResponseAccepted&&g.MxTools.IsZero(En)?($t(J.COMMAND_IN_INVALID_ZERO,`
|
||
|
需要点或选项关键字。
|
||
|
`),ut.status=C.kOther,ut.exit=!1,ut):(ut.status=C.kNormal,ut.dist=En,ut.exit=!0,ut.DetailedResult=Mt.DetailedResult,ut)}return ut.exit=!1,ut.status=C.kNoChange,ut},_.acquirePoint=function($e,We){We===void 0&&(We=!0);var ut=new T;if(q==null)return ut.status=C.kCancel,ut;var Ie=Yn(ne.COMMAND_GET_COORD|ne.COMMAND_GET_KEY);return Ie.iRet==J.COMMAND_IN_EMTPY?(ut.status=C.kNull,ut.exit=!0,De==13?ut.DetailedResult=R.kNullEnterIn:De==32?ut.DetailedResult=R.kNullSpaceIn:De==-1&&(ut.DetailedResult=R.kMouseRightIn),ut):Ie.iRet==J.COMMAND_IN_KEY?(ut.status=Ie.iKey,ut.exit=!0,ut.sKeyValue=Ie.sValue,ut.DetailedResult=R.kKeyIn,ut):Ie.iRet==J.COMMAND_IN_COORD?(ut.status=C.kNormal,ut.pt=new v.Vector3(Ie.pt.x,Ie.pt.y,Ie.pt.z),ut.exit=!0,ut.DetailedResult=R.kCoordIn,ut):(We&&$t(Ie.iRet,`
|
||
|
需要点或选项关键字。
|
||
|
`),Br($e))},_.acquireAngle=function($e,We){var ut=new T;if(q==null)return ut.status=C.kCancel,ut.exit=!0,ut;var Ie=Yn(ne.COMMAND_GET_DIST|ne.COMMAND_GET_KEY);if(Ie.iRet==J.COMMAND_IN_EMTPY)return ut.status=C.kNull,ut.exit=!0,De==13?ut.DetailedResult=R.kNullEnterIn:De==32?ut.DetailedResult=R.kNullSpaceIn:De==-1&&(ut.DetailedResult=R.kMouseRightIn),ut;if(Ie.iRet==J.COMMAND_IN_KEY)return ut.status=Ie.iKey,ut.exit=!0,ut.sKeyValue=Ie.sValue,ut.DetailedResult=R.kKeyIn,ut;if(Ie.iRet==J.COMMAND_IN_DIST)return ut.status=C.kNormal,ut.ang=3.14159265*Ie.dDist/180,ut.exit=!0,ut.DetailedResult=R.kCoordIn,ut;if(ut.status=$t(Ie.iRet,`
|
||
|
需要点或选项关键字。
|
||
|
`),!We||Ie.iRet==J.COMMAND_IN_INVALID_ZERO||Ie.iRet==J.COMMAND_IN_INVALID_NEG)return ut.exit=!1,ut;var Mt=Br($e);if(Mt.status==C.kNormal&&Mt.exit){var rn=new v.Vector3(Mt.pt.x-We.x,Mt.pt.y-We.y,0),tn=rn.angleTo(new v.Vector3(1,0,0));rn.dot(new v.Vector3(0,1,0))<-1e-11&&(tn=2*Math.PI-tn);var En=q.userInputControls();return En&Y.kNoZeroResponseAccepted&&g.MxTools.IsZero(tn)?($t(J.COMMAND_IN_INVALID_ZERO,`
|
||
|
需要点或选项关键字。
|
||
|
`),ut.status=C.kOther,ut.exit=!1,ut):(En&Y.kNoNegativeResponseAccepted&&tn<0?($t(J.COMMAND_IN_INVALID_NEG,`
|
||
|
需要点或选项关键字。
|
||
|
`),ut.status=C.kOther,ut.exit=!1):(ut.status=C.kNormal,ut.ang=tn,ut.exit=!0,ut.DetailedResult=Mt.DetailedResult),ut)}return ut.exit=!1,ut.status=C.kNoChange,ut},_.getMcEdJigCommandClass=function(){return b.McEdJigCommand},_.getMrxDbgUiPrPointClass=function(){return U.MrxDbgUiPrPoint},_.getMrxDbgUiPrDistClass=function(){return F.MrxDbgUiPrDist},_.getMrxDbgUiPrIntClass=function(){return F.MrxDbgUiPrInt},_.getMrxDbgUiPrStringClass=function(){return F.MrxDbgUiPrString},_.getMrxDbgUiPrKeyWordClass=function(){return F.MrxDbgUiPrKeyWord},_.getMrxDbgUiPrAngleClass=function(){return F.MrxDbgUiPrAngle},_.getMcEdGetPointWorldDrawClass=function(){return V.McEdGetPointWorldDraw},_.McEdGetPointWorldDrawObjectClass=function(){return V.McEdGetPointWorldDrawObject},_.init=function(){this._curCmd=void 0}}(a=o.MxJigCmdManager||(o.MxJigCmdManager={}))},{"../MxDrawData":22,"../MxFun":27,"../MxManager":29,"../MxString":34,"../MxTools":38,"../UI/MxUiVue":65,"./McEdJigOsnap":43,"./MrxDbgUiPrBase":45,"./MrxDbgUiPrDist":46,"./MrxDbgUiPrPoint":47,"./MxJig":53,three:19}],55:[function(w,r,o){var a,v=this&&this.__extends||(a=function(I,g){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(A,M){A.__proto__=M}||function(A,M){for(var N in M)Object.prototype.hasOwnProperty.call(M,N)&&(A[N]=M[N])})(I,g)},function(I,g){function A(){this.constructor=I}a(I,g),I.prototype=g===null?Object.create(g):(A.prototype=g.prototype,new A)});Object.defineProperty(o,"__esModule",{value:!0}),o.MxJigGetLine=void 0;var h,b=w("./MxJig"),D=w("./MxJigCmdManager"),U=(v(V,h=b.McEdJigCommand),V.prototype.sampler=function(){var I=D.MxJigCmdManager.InType.kGetBegan;this._isGetPt1||(I=D.MxJigCmdManager.InType.kGetEnd);var g=this.acquirePoint(I);return g.status==D.MxJigCmdManager.DragStatus.kNormal&&(this._isGetPt1?this._pt1=g.pt:this._pt2=g.pt),g.status},V.prototype.setRetCall=function(I){this._retCall=I},V.prototype.done=function(I){if(this._isGetPt1)return this._isGetPt1=!1,D.MxJigCmdManager.DoneStatius.kContinueCommand;var g={};return g.pt1=this.getMxObject().worldCoord2Currnet(this._pt1.x,this._pt1.y,this._pt1.z),g.pt2=this.getMxObject().worldCoord2Currnet(this._pt2.x,this._pt2.y,this._pt2.z),this._retCall(g),D.MxJigCmdManager.DoneStatius.kExitCommand},V.prototype.upDisplay=function(){this._isGetPt1||this._pt1==null||this._pt2==null||this.drawLine(this._pt1,this._pt2)},V);function V(){var I=h!==null&&h.apply(this,arguments)||this;return I._isGetPt1=!0,I}o.MxJigGetLine=U},{"./MxJig":53,"./MxJigCmdManager":54}],56:[function(w,r,o){Object.defineProperty(o,"__esModule",{value:!0}),o.MxOffsetArrow=void 0;var a=w("three"),v=w("../MxFun"),h=w("../MxThreeJS"),b=w("../MxTools"),D=(U.prototype.ClearDynDrawEntity=function(){var V=this.m_vecDynDrawEntity.length;if(V!=0){for(var I=this.m_mxJig.getMxObject().getTheTempDrawContainer_SmallCoord(),g=0;g<V;g++)v.MxFun.removeThreejsObject(this.m_vecDynDrawEntity[g],I);this.m_vecDynDrawEntity=[]}},U.prototype.MouseMove=function(V){var I=this.m_mxJig.getMxObject();if(I.getMcObject().isValid()&&(this.ClearDynDrawEntity(),this.m_mxJig.isOffsetInputPostion())){var g=V.clone(),A=this.m_mxJig.getOsnap().reCompteCurrentPoint(g.clone()),M=h.MxThreeJS.createLine(I.toSmallcoord(g),I.toSmallcoord(A),16777215),N=I.getTheTempDrawContainer_SmallCoord();N.add(M),this.m_vecDynDrawEntity.push(M);var F=b.MxTools.MillimeterToPixels(2.9);F=I.screenCoordLong2Doc(F);var T=h.MxThreeJS.createSolidCircle(I.toSmallcoord(g),.85*F,16777215);N.add(T),this.m_vecDynDrawEntity.push(T);var _=h.MxThreeJS.createCircle(I.toSmallcoord(g),F,16777215);N.add(_),this.m_vecDynDrawEntity.push(_);var Y=g.sub(A);Y.normalize().multiplyScalar(.8*F);var k=Y.clone().applyAxisAngle(new a.Vector3(0,0,1),15*Math.PI/180),S=Y.clone().applyAxisAngle(new a.Vector3(0,0,1),15*-Math.PI/180),G=A.clone().add(k),C=A.clone().add(S),B=h.MxThreeJS.createLine(I.toSmallcoord(G),I.toSmallcoord(A),16777215);I.getTheTempDrawContainer_SmallCoord().add(B),this.m_vecDynDrawEntity.push(B);var R=h.MxThreeJS.createLine(I.toSmallcoord(C),I.toSmallcoord(A),16777215);I.getTheTempDrawContainer_SmallCoord
|
||
|
指定第一点:`),u.go(function(c){if(c==0){var f=u.value(),O=new I.Vector3;O.x=f.x,O.y=f.y;var W=new D.McEdGetPointWorldDrawObject;W.setDraw(function(X,J){J.setColor(255),J.drawLine(X,O)}),u.setUserDraw(W),u.setMessage(`
|
||
|
指定下一点:`),u.go(function(X){if(X==0){var J=u.value(),te=g.MxFun.getCurrentDraw(),ne=V.MxThreeJS.createLine(f,J,16777215);te.addObject(ne)}})}})}function Y(){var R=new U.MrxDbgUiPrPoint;R.setMessage(`
|
||
|
指定第一点:`),R.go(function(u){if(u==0){var c=g.MxFun.getCurrentDraw(),f=new F;f.setColor(16711680),f.setPoint(R.value()),f.setR(c.viewCoordLong2Cad(100)),c.addMxEntity(f),c.addMxCurrentSelect(f.objectId())}})}function k(){M.MrxDbgUtils.selectEnt("Test").then(function(R){console.log(R)})}function S(){var R=g.MxFun.getCurrentDraw();b?(R.eraseAllMxEntity(),R.loadMxEntityFromJson(b)):(b=R.saveMxEntityToJson(),console.log(b))}function G(){g.MxFun.openFile("demo/buf/hhhh.dwg?token=123456")}function C(){var R=new U.MrxDbgUiPrPoint;R.setMessage(`
|
||
|
指定第一点:`),R.go(function(u){if(u==0){var c=R.value();M.MrxDbgUtils.getCorner(c,"Test",!0).then(function(f){console.log("xxxdddd"),console.log(f)})}})}function B(){var R=new N.MrxDbgUiPrDist;R.setMessage(`
|
||
|
输入距离:`),R.go(function(u){if(u==0){var c=R.value();console.log(c)}})}(o.MxTest||(o.MxTest={})).registerCommand=function(){console.log("regist mx test"),new F().init(),g.MxFun.addCommand("MxTest_GetPoint",_),g.MxFun.addCommand("MxTest_GetDist",B),g.MxFun.addCommand("MxTest_DrawCustomEntity",Y),g.MxFun.addCommand("MxTest_EntSel",k),g.MxFun.addCommand("MxTest_SaveMxDbEntityToJson",S),g.MxFun.addCommand("MxTest_OpenFile",G),g.MxFun.addCommand("MxTest_GetCorner",C),g.MxFun.addWindowsEvent(function(R,u){if(R=="mouseup"){if(g.MxFun.isRunningCommand()||u.button!=0)return 0;var c=u.srcElement;if(c&&c.tagName=="CANVAS"){var f=g.MxFun.getCurrentDraw(),O=new I.Vector3(u.offsetX,u.offsetY,0);f.findMxEntityAtPoint(O,!1).length&&u.preventDefault()}return 0}})}},{"../MrxDbgUtils":20,"../MxFun":27,"../MxString":34,"../MxThreeJS":37,"../Operate/MrxDbgUiPrBase":45,"../Operate/MrxDbgUiPrDist":46,"../Operate/MrxDbgUiPrPoint":47,"../View/MxDbEntity":69,three:19}],62:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.MxUiObject=exports.MxToolBarItem=exports.MxMenuItem=void 0;var MxFun_1=require("../MxFun"),MxMenuItem=function(){this.id=-1,this.text="",this.evalString="",this.parentId=-1};exports.MxMenuItem=MxMenuItem;var MxToolBarItem=function(){this.isMxCommand=!1,this.itemid=""};exports.MxToolBarItem=MxToolBarItem;var MxUiObject=function(){function MxUiObject(){this.vecMenuItem=new Array,this.vecToolBarItem=new Array,this.uiPath="./ui",this.idMenuItemCount=100,this.isShowTitle=!1,this.isShowStructTree=!1,this.isEnableLoading=!0,this.isShowLayer=!1,this.isShowTakeColor=!1,this.isShowLayout=!1,this.isEnableObjectProperty=!1,this.isShowToolbar=!1,this.isShowMainMenu=!1,this.sTitle="",this.sLanguageTable={layout:"布局",layer:"图层",visible:"可见",color:"颜色",name:"名字",status:"状态",openComplete:"提示:打开图纸完成"}}return MxUiObject.prototype.SetLayoutData=function(w){this.vecLayoutData=w},MxUiObject.prototype.CallMxCommand=function(w){MxFun_1.MxFun.callCommand(w,"")},MxUiObject.prototype.EvalJs=function(value){eval(value)},MxUiObject.prototype.SetLayerData=function(w){this.vecLayerData=w},MxUiObject.prototype.SetSketchLayerData=function(w){this.vecSketchLayerData=w},MxUiObject.prototype.init=function(){this.onInit()},MxUiObject.prototype.addMenuItem=function(w,r,o,a){r===void 0&&(r=""),o===void 0&&(o=-1),a===void 0&&(a=-1);var v=new MxMenuItem;v.text=w,v.evalString=r,a==-1&&(a=this.idMenuItemCount,this.idMenuItemCount++),v.id=a,v.parentId=o,this.vecMenuItem.push(v)},MxUiObject.prototype.addToolBarItem=function(w,r,o,a,v){r===void 0&&(r=""),o===void 0&&(o=""),a===void 0&&(a=!1),v===void 0&&(v="");var h=new MxToolBarItem;h.image=w,h.evalString=o,h.text=r,h.isMxCommand=a,h.itemid=v,this.vecToolBarItem.push(h)},MxUiObject.prototype.setPath=function(w){this.uiPath=w},MxUiObject.prototype.getPath=function(){return this.uiPath},MxUiObject.prototype.create=function(){this.onCreate()},MxUiObject.prototype.writeUICSS=function(){var w=this.uiPath;MxFun_1.MxFun.isPC()?(document.write("<link rel='stylesheet' href='"+w+"/css/mxbimpcm.css'>"),this.isShowMainMenu&&(document.write("<link rel='stylesheet' href='"+w+"/css/rightfacefonts2.css'>"),document.write("<link rel='stylesheet' href='"+w+"/css/rightmnu.css'>"),document.write("<script type='text/javascript' src='"+w+"/hc-mobile-nav.js'><\/script>"))):(document.write("<link rel='stylesheet' href='"+w+"/css/mxmobile.css'>"),this.isShowMainMenu&&(document.write("<link href='"+w+"/css/font-awesome.min.css' rel='stylesheet'>"),document.write("<link rel='stylesheet' href='"+w+"/css/rightfacefonts1.css'>"),document.write("<link rel='stylesheet' href='"+w+"/css/rightfacefonts2.css'>"),document.write("<link rel='stylesheet' href='"+w+"/css/rightmnu.css'>"),document.write("<script type='text/javascript' src='"+w+"/hc-mobile-nav.js'><\/script>")))},MxUiObject}();exports.MxUiObject=MxUiObject},{"../MxFun":27}],63:[function(w,r,o){var a,v=this&&this.__extends||(a=function(I,g){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&fun
|
||
|
`),f=0,O=!0;c!=-1&&(O?(B.addCmdDisplay(`
|
||
|
`+R+u+S.substring(f,c-f)),u=R="",O=!1):B.addCmdDisplay(`
|
||
|
`+S.substring(f,c-f)),(f=c+1)<C);)c=S.indexOf(`
|
||
|
`,f);if(O){var W=S.substring(f,C-f),X=W.indexOf("\r"),J=W.length;R=X==-1?R+u+W:X+1<J?W.substring(X+1,J-X-1):""}else f<C&&(R=S.substring(f,C));u="",G&&(R+=" "),B.setCmdTip(R),B.setCmdText(u),B.upDisplay()}}function F(S){for(var G=[],C=1;C<arguments.length;C++)G[C-1]=arguments[C];if(h!=null){for(var B=arguments,R=B[0],u=0;u<B.length-1;u++){var c=new RegExp("\\{"+u+"\\}","gm");R=R.replace(c,B[u+1])}N(R,!0)}}function T(){h!=null&&h.getCmdLine().upDisplay()}function _(){if(h==null)return"";var S=h.getCmdLine();return I.MxTools.stringTrimLeftRightSpace(S.getCmdText())}function Y(S){if(h!=null)return h.getCmdLine().setCmdText(S)}function k(S){var G=V.MxJigCmdManager.getCurCmd();return G==null?0:G.getDynImput().onKeyDonw(S)?1:M(S)}o.MxUiOperations={kOkCommand:1,kCancaleCommand:2},a=o.MxUiVue||(o.MxUiVue={}),h=void 0,b=new D.Vector3,a.SetLasetPoint=function(S){b=S},a.GetLasetPoint=function(){return b},(v=a.CursorType||(a.CursorType={}))[v.kNormal=0]="kNormal",v[v.kRect=1]="kRect",v[v.kCross=2]="kCross",v[v.kPan=3]="kPan",a.isNull=function(){return h==null},a.init=function(S){(h=S).mountKeydownEvent(M),h.getDynamicInput().mountKeydownEvent(k),h.mountsetRightMenuSnapTypeFun&&h.mountsetRightMenuSnapTypeFun(A),h.mountTsWeb_MxUiVue&&h.mountTsWeb_MxUiVue(this)},a.executeOperations=function(S){S==o.MxUiOperations.kOkCommand?V.MxJigCmdManager.getCurCmd()&&V.MxJigCmdManager.OnEnter(-1):S==o.MxUiOperations.kCancaleCommand&&V.MxJigCmdManager.getCurCmd()&&V.MxJigCmdManager.stopCmd(V.MxJigCmdManager.DetailedResult.kEcsIn)},a.setTipCoord=function(S){h!=null&&h.setTipCoord(S)},a.setCursorType=function(S){h!=null&&h.setCursorType(S)},a.AcutPrintfNoFormat=N,a.acutPrintf=F,a.cmdLineUpDisplay=T,a.getCmdText=_,a.setCmdText=Y,a.getCmdDisplay=function(){return h==null?"":h.getCmdLine().getCmdDisplay()},a.setCmdDisplay=function(S){if(h!=null)return h.getCmdLine().setCmdDisplay(S)},a.getCmdTip=function(){return h==null?"":h.getCmdLine().getCmdTip()},a.setCmdTip=function(S){if(h!=null)return h.getCmdLine().setCmdTip(S)},a.restoreCmdStatus=function(){if(h!=null){var S=h.getCmdLine();S.getCmdTip()==" "&&S.getCmdText().length==0?(S.setCmdTip(""),F("{0}:","命令")):F(`
|
||
|
{0}:`,"命令")}},a.DynamicInput_upDisplay=function(){h!=null&&a.OnMxEvent({name:"dynInputUpDisplay"})},a.DynamicInput_setType=function(S){h!=null&&h.getDynamicInput().setType(S)},a.DynamicInput_getType=function(){return h==null?V.MxJigCmdManager.DynamicInputType.kNoInput:h.getDynamicInput().getType()},a.DynamicInput_setPos=function(S){h!=null&&h.getDynamicInput().setPos([S.x,S.y])},a.DynamicInput_setTip=function(S){h!=null&&h.getDynamicInput().setTip(S)},a.DynamicInput_setValue1=function(S){h!=null&&h.getDynamicInput().setValue1(S)},a.DynamicInput_getValue1=function(){return h==null?"":h.getDynamicInput().getValue1()},a.DynamicInput_setValue1Pos=function(S){h!=null&&h.getDynamicInput().setValue1Pos([S.x,S.y])},a.DynamicInput_setValue2=function(S){h!=null&&h.getDynamicInput().setValue2(S)},a.DynamicInput_getValue2=function(){return h==null?"":h.getDynamicInput().getValue2()},a.DynamicInput_getFocusValue=function(){return h==null?"":h.getDynamicInput().getFocusValue()},a.DynamicInput_getFocusIndex=function(){return h==null?0:h.getDynamicInput().getFocusIndex()},a.DynamicInput_setValue2Pos=function(S){h!=null&&h.getDynamicInput().setValue2Pos([S.x,S.y])},a.DynamicInput_setShow=function(S){h!=null&&h.getDynamicInput().setShow(S)},a.DynamicInput_isShow=function(){return h!=null&&h.getDynamicInput().isShow()},a.OnMxEvent=function(S){if(h==null)return!1;h.OnMxEvent(S)},a.DynamicInput_getLockValuesMap=function(){return h==null?new Map:h.getDynamicInput().getLockValuesMap()},a.DynamicInput_clearLockValuesMap=function(){h!=null&&h.getDynamicInput().clearLockValuesMap()}},{"../MxFun":27,"../MxTools":38,"../Operate/MxCmdRunManager":48,"../Operate/MxJigCmdManager":54,three:19}],66:[function(w,r,o){Object.defineProperty(o,"__esModule",{value:!0}),o.ExternalReferenceManager=o.ExternalReferenceDatabase=o.Blocks=o.Block=o.Layer=o.MxNewDisplayMemorySection=o.MxNewDisplayMemorySectionType=o.TextureData=o.BlockInstance=o.BlockRef=o.ClipPlans=o.ClipPlan=void 0;var a=w("three"),v=w("../MxShader"),h=w("./MxBrowseLayerData"),b=w("../MxManager"),D=w("../MxNetData"),U=w("../MxStencilObject"),V=w("../MxFun"),I=function(){this.x1=0,this.y1=0,this.x2=0,this.y2=0};o.ClipPlan=I;var g=function(){this.ver=4,this.id=1,this.clipPlanArray=new Array,this.clipPoints=[],this.instansClipePoints=[]};o.ClipPlans=g;var A=function(){this.ver=4,this.mat=new a.Matrix4,this.blkRecId=-1,this.blkOwnerId=0,this.layerId=-1,this.color=16777215,this.clipPlans=new g};o.BlockRef=A;var M=function(){this.mat=new a.Matrix4,this.color=new Array,this.topLayerColor=new Array,this.clipPlans=new g,this.clipMat=new a.Matrix4};o.BlockInstance=M;var N,F,T=function(){};o.TextureData=T,(F=N=o.MxNewDisplayMemorySectionType||(o.MxNewDisplayMemorySectionType={}))[F.kLinesType=1]="kLinesType",F[F.kTriangleType=2]="kTriangleType",F[F.kLinesType_Float=3]="kLinesType_Float",F[F.kTriangleType_Float=4]="kTriangleType_Float",F[F.kPointType_Float=5]="kPointType_Float",F[F.kPointType=6]="kPointType",o.MxNewDisplayMemorySection=function(){this.id=0,this.type=N.kLinesType,this.blockId=0,this.layerId=0,this.color=0,this.points=[]};var _=(Y.prototype.Show=function(c){for(var f=0,O=this._entitys.length;f<O;f++)this._entitys[f].visible=c},Y.prototype.updataClipMaterial=function(c){for(var f=this._material_clip.length,O=.5*c.width,W=.5*c.height,X=0;X<f;X++)this._material_clip[X].uniforms.vieww.value=O,this._material_clip[X].uniforms.viewh.value=W},Y.prototype.createThreejsObjForMesh_Clip=function(c,f,O){c.size!=0&&c.forEach(function(W){var X=W;if(X.length!=0){var J=[],te=[],ne=X[0].clipPlans;ne.ver<=3&&(J.push(ne.clipPlanArray[0].x1,ne.clipPlanArray[0].y1),te.push(ne.clipPlanArray[0].x2,ne.clipPlanArray[0].y2));for(var ue=[],be=[],je=[],ve=[],Be=[],q=[],ge=[],oe=0;oe<X.length;oe++){var le=X[oe];ue=ue.concat(le.mat.elements.slice(0,4)),be=be.concat(le.mat.elements.slice(4,8)),je=je.concat(le.mat.elements.slice(8,12)),ve=ve.concat(le.mat.elements.slice(12,16)),Be.push(0),q=q.concat(X[oe].color)}if(0<this._geometryMeshPositionsByBlock.length)for(oe=0;oe<X.length;oe++)q=q.concat(X[oe].color);if(0<this._geome
|
||
|
`):y)),E};var Ma=/^(?:focusinfocus|focusoutblur)$/,ka=function(y){y.stopPropagation()};u.extend(u.event,{trigger:function(y,E,K,re){var de,fe,_e,Me,Se,Ve,rt,ft,ct=[K||k],Lt=M.call(y,"type")?y.type:y,kn=M.call(y,"namespace")?y.namespace.split("."):[];if(fe=ft=_e=K=K||k,K.nodeType!==3&&K.nodeType!==8&&!Ma.test(Lt+u.event.triggered)&&(Lt.indexOf(".")>-1&&(Lt=(kn=Lt.split(".")).shift(),kn.sort()),Se=Lt.indexOf(":")<0&&"on"+Lt,(y=y[u.expando]?y:new u.Event(Lt,typeof y=="object"&&y)).isTrigger=re?2:3,y.namespace=kn.join("."),y.rnamespace=y.namespace?new RegExp("(^|\\.)"+kn.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,y.result=void 0,y.target||(y.target=K),E=E==null?[y]:u.makeArray(E,[y]),rt=u.event.special[Lt]||{},re||!rt.trigger||rt.trigger.apply(K,E)!==!1)){if(!re&&!rt.noBubble&&!Y(K)){for(Me=rt.delegateType||Lt,Ma.test(Me+Lt)||(fe=fe.parentNode);fe;fe=fe.parentNode)ct.push(fe),_e=fe;_e===(K.ownerDocument||k)&&ct.push(_e.defaultView||_e.parentWindow||a)}for(de=0;(fe=ct[de++])&&!y.isPropagationStopped();)ft=fe,y.type=de>1?Me:rt.bindType||Lt,(Ve=(Ue.get(fe,"events")||Object.create(null))[y.type]&&Ue.get(fe,"handle"))&&Ve.apply(fe,E),(Ve=Se&&fe[Se])&&Ve.apply&&er(fe)&&(y.result=Ve.apply(fe,E),y.result===!1&&y.preventDefault());return y.type=Lt,re||y.isDefaultPrevented()||rt._default&&rt._default.apply(ct.pop(),E)!==!1||!er(K)||Se&&_(K[Lt])&&!Y(K)&&((_e=K[Se])&&(K[Se]=null),u.event.triggered=Lt,y.isPropagationStopped()&&ft.addEventListener(Lt,ka),K[Lt](),y.isPropagationStopped()&&ft.removeEventListener(Lt,ka),u.event.triggered=void 0,_e&&(K[Se]=_e)),y.result}},simulate:function(y,E,K){var re=u.extend(new u.Event,K,{type:y,isSimulated:!0});u.event.trigger(re,null,E)}}),u.fn.extend({trigger:function(y,E){return this.each(function(){u.event.trigger(y,E,this)})},triggerHandler:function(y,E){var K=this[0];if(K)return u.event.trigger(y,E,K,!0)}});var na=/\[\]$/,Go=/\r?\n/g,ws=/^(?:submit|button|image|reset|file)$/i,yr=/^(?:input|select|textarea|keygen)/i;function zt(y,E,K,re){var de;if(Array.isArray(E))u.each(E,function(fe,_e){K||na.test(y)?re(y,_e):zt(y+"["+(typeof _e=="object"&&_e!=null?fe:"")+"]",_e,K,re)});else if(K||C(E)!=="object")re(y,E);else for(de in E)zt(y+"["+de+"]",E[de],K,re)}u.param=function(y,E){var K,re=[],de=function(fe,_e){var Me=_(_e)?_e():_e;re[re.length]=encodeURIComponent(fe)+"="+encodeURIComponent(Me==null?"":Me)};if(y==null)return"";if(Array.isArray(y)||y.jquery&&!u.isPlainObject(y))u.each(y,function(){de(this.name,this.value)});else for(K in y)zt(K,y[K],E,de);return re.join("&")},u.fn.extend({serialize:function(){return u.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var y=u.prop(this,"elements");return y?u.makeArray(y):this}).filter(function(){var y=this.type;return this.name&&!u(this).is(":disabled")&&yr.test(this.nodeName)&&!ws.test(y)&&(this.checked||!tn.test(y))}).map(function(y,E){var K=u(this).val();return K==null?null:Array.isArray(K)?u.map(K,function(re){return{name:E.name,value:re.replace(Go,`\r
|
||
|
`)}}):{name:E.name,value:K.replace(Go,`\r
|
||
|
`)}}).get()}});var Ai=/%20/g,zo=/#.*$/,cu=/([?&])_=[^&]*/,Xr=/^(.*?):[ \t]*([^\r\n]*)$/gm,Jr=/^(?:GET|HEAD)$/,Zi=/^\/\//,Us={},Gi={},bs="*/".concat("*"),Hs=k.createElement("a");function Re(y){return function(E,K){typeof E!="string"&&(K=E,E="*");var re,de=0,fe=E.toLowerCase().match(xe)||[];if(_(K))for(;re=fe[de++];)re[0]==="+"?(re=re.slice(1)||"*",(y[re]=y[re]||[]).unshift(K)):(y[re]=y[re]||[]).push(K)}}function Eo(y,E,K,re){var de={},fe=y===Gi;function _e(Me){var Se;return de[Me]=!0,u.each(y[Me]||[],function(Ve,rt){var ft=rt(E,K,re);return typeof ft!="string"||fe||de[ft]?fe?!(Se=ft):void 0:(E.dataTypes.unshift(ft),_e(ft),!1)}),Se}return _e(E.dataTypes[0])||!de["*"]&&_e("*")}function ra(y,E){var K,re,de=u.ajaxSettings.flatOptions||{};for(K in E)E[K]!==void 0&&((de[K]?y:re||(re={}))[K]=E[K]);return re&&u.extend(!0,y,re),y}Hs.href=so.href,u.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:so.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(so.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":bs,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":u.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(y,E){return E?ra(ra(y,u.ajaxSettings),E):ra(u.ajaxSettings,y)},ajaxPrefilter:Re(Us),ajaxTransport:Re(Gi),ajax:function(y,E){typeof y=="object"&&(E=y,y=void 0),E=E||{};var K,re,de,fe,_e,Me,Se,Ve,rt,ft,ct=u.ajaxSetup({},E),Lt=ct.context||ct,kn=ct.context&&(Lt.nodeType||Lt.jquery)?u(Lt):u.event,Pt=u.Deferred(),Hn=u.Callbacks("once memory"),Yr=ct.statusCode||{},zr={},ca={},Ta="canceled",dr={readyState:0,getResponseHeader:function(vr){var Wn;if(Se){if(!fe)for(fe={};Wn=Xr.exec(de);)fe[Wn[1].toLowerCase()+" "]=(fe[Wn[1].toLowerCase()+" "]||[]).concat(Wn[2]);Wn=fe[vr.toLowerCase()+" "]}return Wn==null?null:Wn.join(", ")},getAllResponseHeaders:function(){return Se?de:null},setRequestHeader:function(vr,Wn){return Se==null&&(vr=ca[vr.toLowerCase()]=ca[vr.toLowerCase()]||vr,zr[vr]=Wn),this},overrideMimeType:function(vr){return Se==null&&(ct.mimeType=vr),this},statusCode:function(vr){var Wn;if(vr)if(Se)dr.always(vr[dr.status]);else for(Wn in vr)Yr[Wn]=[Yr[Wn],vr[Wn]];return this},abort:function(vr){var Wn=vr||Ta;return K&&K.abort(Wn),Ca(0,Wn),this}};if(Pt.promise(dr),ct.url=((y||ct.url||so.href)+"").replace(Zi,so.protocol+"//"),ct.type=E.method||E.type||ct.method||ct.type,ct.dataTypes=(ct.dataType||"*").toLowerCase().match(xe)||[""],ct.crossDomain==null){Me=k.createElement("a");try{Me.href=ct.url,Me.href=Me.href,ct.crossDomain=Hs.protocol+"//"+Hs.host!=Me.protocol+"//"+Me.host}catch(vr){ct.crossDomain=!0}}if(ct.data&&ct.processData&&typeof ct.data!="string"&&(ct.data=u.param(ct.data,ct.traditional)),Eo(Us,ct,E,dr),Se)return dr;for(rt in(Ve=u.event&&ct.global)&&u.active++==0&&u.event.trigger("ajaxStart"),ct.type=ct.type.toUpperCase(),ct.hasContent=!Jr.test(ct.type),re=ct.url.replace(zo,""),ct.hasContent?ct.data&&ct.processData&&(ct.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&(ct.data=ct.data.replace(Ai,"+")):(ft=ct.url.slice(re.length),ct.data&&(ct.processData||typeof ct.data=="string")&&(re+=(Wr.test(re)?"&":"?")+ct.data,delete ct.data),ct.cache===!1&&(re=re.replace(cu,"$1"),ft=(Wr.test(re)?"&":"?")+"_="+zs.guid+++ft),ct.url=re+ft),ct.ifModified&&(u.lastModified[re]&&dr.setRequestHeader("If-Modified-Since",u.lastModified[re]),u.etag[re]&&dr.setRequestHeader("If-None-Match",u.etag[re])),(ct.data&&ct.hasContent&&ct.contentType!==!1||E.contentType)&&dr.setRequestHeader("Content-Type",ct.contentType),dr.setRequestHeader("Accept",ct.dataTypes[0]&&ct.accepts[ct.dataTypes[0]]?ct.accepts[ct.dataTypes[0]]+(ct.dataTypes[0]!=="*"?", "+bs+"; q=0.01":""):ct.accepts["*"]),ct.headers)dr.setRequestHeader(rt,ct.headers[rt]);if(ct.beforeSend&&(ct.bef
|
||
|
/* [wrapped with `+Oe+`] */
|
||
|
`)}(ae,function(pe,Oe){return Ei(F,function(Xe){var it="_."+Xe[0];Oe&Xe[1]&&!so(pe,it)&&pe.push(it)}),pe.sort()}(function(pe){var Oe=ae.match(Ue);return Oe?Oe[1].split(Zt):[]}(),P)))}function il(s){var p=0,P=0;return function(){var ae=Js(),pe=16-(ae-P);if(P=ae,pe>0){if(++p>=800)return arguments[0]}else p=0;return s.apply(o,arguments)}}function gc(s,p){var P=-1,ae=s.length,pe=ae-1;for(p=p===o?ae:p;++P<p;){var Oe=Er(P,pe),Xe=s[Oe];s[Oe]=s[P],s[P]=Xe}return s.length=p,s}var Du=function(s){var p=Hl(function(ae){var pe=[];return ae.charCodeAt(0)===46&&pe.push(""),ae.replace(Vt,function(Oe,Xe,it,wt){pe.push(it?wt.replace(dt,"$1"):Xe||Oe)}),pe},function(ae){return P.size===500&&P.clear(),ae}),P=p.cache;return p}();function po(s){if(typeof s=="string"||mo(s))return s;var p=s+"";return p=="0"&&1/s==-1/0?"-0":p}function Yo(s){if(s!=null){try{return vr.call(s)}catch(p){}try{return s+""}catch(p){}}return""}function Zo(s){if(s instanceof xr)return s.clone();var p=new Cr(s.__wrapped__,s.__chain__);return p.__actions__=Ka(s.__actions__),p.__index__=s.__index__,p.__values__=s.__values__,p}var Vl=Lr(function(s,p){return mi(s)?Cs(s,Wi(p,1,mi,!0)):[]}),al=Lr(function(s,p){var P=Ba(p);return mi(P)&&(P=o),mi(s)?Cs(s,Wi(p,1,mi,!0),nr(P,2)):[]}),yc=Lr(function(s,p){var P=Ba(p);return mi(P)&&(P=o),mi(s)?Cs(s,Wi(p,1,mi,!0),o,P):[]});function ol(s,p,P){var ae=s==null?0:s.length;if(!ae)return-1;var pe=P==null?0:Sr(P);return pe<0&&(pe=di(ae+pe,0)),zt(s,nr(p,3),pe)}function Fl(s,p,P){var ae=s==null?0:s.length;if(!ae)return-1;var pe=ae-1;return P!==o&&(pe=Sr(P),pe=P<0?di(ae+pe,0):Ii(pe,ae-1)),zt(s,nr(p,3),pe,!0)}function sl(s){return s!=null&&s.length?Wi(s,1):[]}function ll(s){return s&&s.length?s[0]:o}var Bl=Lr(function(s){var p=Wr(s,gh);return p.length&&p[0]===s[0]?Ss(p):[]}),vc=Lr(function(s){var p=Ba(s),P=Wr(s,gh);return p===Ba(P)?p=o:P.pop(),P.length&&P[0]===s[0]?Ss(P,nr(p,2)):[]}),ld=Lr(function(s){var p=Ba(s),P=Wr(s,gh);return(p=typeof p=="function"?p:o)&&P.pop(),P.length&&P[0]===s[0]?Ss(P,o,p):[]});function Ba(s){var p=s==null?0:s.length;return p?s[p-1]:o}var xc=Lr(wc);function wc(s,p){return s&&s.length&&p&&p.length?Ll(s,p):s}var cd=Jo(function(s,p){var P=s==null?0:s.length,ae=as(s,p);return el(s,Wr(p,function(pe){return qo(pe,P)?+pe:pe}).sort(Jh)),ae});function bc(s){return s==null?s:ke.call(s)}var ud=Lr(function(s){return ss(Wi(s,1,mi,!0))}),Mc=Lr(function(s){var p=Ba(s);return mi(p)&&(p=o),ss(Wi(s,1,mi,!0),nr(p,2))}),Eu=Lr(function(s){var p=Ba(s);return p=typeof p=="function"?p:o,ss(Wi(s,1,mi,!0),o,p)});function Gl(s){if(!s||!s.length)return[];var p=0;return s=Do(s,function(P){if(mi(P))return p=di(P.length,p),!0}),bs(p,function(P){return Wr(s,Jr(P))})}function Rh(s,p){if(!s||!s.length)return[];var P=Gl(s);return p==null?P:Wr(P,function(ae){return hi(p,o,ae)})}var _c=Lr(function(s,p){return mi(s)?Cs(s,p):[]}),Tc=Lr(function(s){return Va(Do(s,mi))}),hd=Lr(function(s){var p=Ba(s);return mi(p)&&(p=o),Va(Do(s,mi),nr(p,2))}),Yd=Lr(function(s){var p=Ba(s);return p=typeof p=="function"?p:o,Va(Do(s,mi),o,p)}),Au=Lr(Gl),Lh=Lr(function(s){var p=s.length,P=p>1?s[p-1]:o;return Rh(s,P=typeof P=="function"?(s.pop(),P):o)});function Ih(s){var p=we(s);return p.__chain__=!0,p}function Cc(s,p){return p(s)}var zl=Jo(function(s){var p=s.length,P=p?s[0]:0,ae=this.__wrapped__,pe=function(Oe){return as(Oe,s)};return!(p>1||this.__actions__.length)&&ae instanceof xr&&qo(P)?((ae=ae.slice(P,+P+(p?1:0))).__actions__.push({func:Cc,args:[pe],thisArg:o}),new Cr(ae,this.__chain__).thru(function(Oe){return p&&!Oe.length&&Oe.push(o),Oe})):this.thru(pe)}),Sc=xu(function(s,p,P){Wn.call(s,P)?++s[P]:ja(s,P,1)}),Ou=$h(ol),Vi=$h(Fl);function kh(s,p){return(gr(s)?Ei:Po)(s,nr(p,3))}function jh(s,p){return(gr(s)?function(P,ae){for(var pe=P==null?0:P.length;pe--&&ae(P[pe],pe,P)!==!1;);return P}:lc)(s,nr(p,3))}var dd=xu(function(s,p,P){Wn.call(s,P)?s[P].push(p):ja(s,P,[p])}),Pu=Lr(function(s,p,P){var ae=-1,pe=typeof p=="function",Oe=Ea(s)?rt(s.length):[];return Po(s,function(Xe){Oe[++ae]=pe?hi(p,Xe,P):Qi(Xe,p,P)}),Oe}),Ru=xu(function(s,p,P){ja(s,P,p)});function La(s,p){return(gr(s)?
|
||
|
`;s.replace(Pn,function(on,Nn,vn,pr,cr,Ar){return vn||(vn=pr),Kt+=s.slice(gt,Ar).replace(ut,_a),Nn&&(pe=!0,Kt+=`' +
|
||
|
__e(`+Nn+`) +
|
||
|
'`),cr&&(Oe=!0,Kt+=`';
|
||
|
`+cr+`;
|
||
|
__p += '`),vn&&(Kt+=`' +
|
||
|
((__t = (`+vn+`)) == null ? '' : __t) +
|
||
|
'`),gt=Ar+on.length,on}),Kt+=`';
|
||
|
`;var Qn=Wn.call(p,"variable")&&p.variable;if(Qn){if(Xn.test(Qn))throw new ct("Invalid `variable` option passed into `_.template`")}else Kt=`with (obj) {
|
||
|
`+Kt+`
|
||
|
}
|
||
|
`;Kt=(Oe?Kt.replace(Pe,""):Kt).replace(Ye,"$1").replace(ze,"$1;"),Kt="function("+(Qn||"obj")+`) {
|
||
|
`+(Qn?"":`obj || (obj = {});
|
||
|
`)+"var __t, __p = ''"+(pe?", __e = _.escape":"")+(Oe?`, __j = Array.prototype.join;
|
||
|
function print() { __p += __j.call(arguments, '') }
|
||
|
`:`;
|
||
|
`)+Kt+`return __p
|
||
|
}`;var Ut=ds(function(){return Lt(it,jn+"return "+Kt).apply(o,wt)});if(Ut.source=Kt,Jl(Ut))throw Ut;return Ut},we.times=function(s,p){if((s=Sr(s))<1||s>A)return[];var P=N,ae=Ii(s,N);p=nr(p),s-=N;for(var pe=bs(ae,p);++P<s;)p(P);return pe},we.toFinite=ko,we.toInteger=Sr,we.toLength=ul,we.toLower=function(s){return $r(s).toLowerCase()},we.toNumber=oi,we.toSafeInteger=function(s){return s?uo(Sr(s),-9007199254740991,A):s===0?s:0},we.toString=$r,we.toUpper=function(s){return $r(s).toUpperCase()},we.trim=function(s,p,P){if((s=$r(s))&&(P||p===o))return Hs(s);if(!s||!(p=Za(p)))return s;var ae=re(s),pe=re(p);return As(ae,uu(ae,pe),Ms(ae,pe)+1).join("")},we.trimEnd=function(s,p,P){if((s=$r(s))&&(P||p===o))return s.slice(0,de(s)+1);if(!s||!(p=Za(p)))return s;var ae=re(s);return As(ae,0,Ms(ae,re(p))+1).join("")},we.trimStart=function(s,p,P){if((s=$r(s))&&(P||p===o))return s.replace(nn,"");if(!s||!(p=Za(p)))return s;var ae=re(s);return As(ae,uu(ae,re(p))).join("")},we.truncate=function(s,p){var P=30,ae="...";if(gi(p)){var pe="separator"in p?p.separator:pe;P="length"in p?Sr(p.length):P,ae="omission"in p?Za(p.omission):ae}var Oe=(s=$r(s)).length;if(fr(s)){var Xe=re(s);Oe=Xe.length}if(P>=Oe)return s;var it=P-K(ae);if(it<1)return ae;var wt=Xe?As(Xe,0,it).join(""):s.slice(0,it);if(pe===o)return wt+ae;if(Xe&&(it+=wt.length-it),cl(pe)){if(s.slice(it).search(pe)){var gt,Nt=wt;for(pe.global||(pe=Hn(pe.source,$r(Xt.exec(pe))+"g")),pe.lastIndex=0;gt=pe.exec(Nt);)var Kt=gt.index;wt=wt.slice(0,Kt===o?it:Kt)}}else if(s.indexOf(Za(pe),it)!=it){var Pn=wt.lastIndexOf(pe);Pn>-1&&(wt=wt.slice(0,Pn))}return wt+ae},we.unescape=function(s){return(s=$r(s))&&De.test(s)?s.replace(se,fe):s},we.uniqueId=function(s){var p=++lo;return $r(s)+p},we.upperCase=Ga,we.upperFirst=fl,we.each=kh,we.eachRight=jh,we.first=ll,Oi(we,(gl={},Ro(we,function(s,p){Wn.call(we.prototype,p)||(gl[p]=s)}),gl),{chain:!1}),we.VERSION="4.17.21",Ei(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){we[s].placeholder=we}),Ei(["drop","take"],function(s,p){xr.prototype[s]=function(P){P=P===o?1:di(Sr(P),0);var ae=this.__filtered__&&!p?new xr(this):this.clone();return ae.__filtered__?ae.__takeCount__=Ii(P,ae.__takeCount__):ae.__views__.push({size:Ii(P,N),type:s+(ae.__dir__<0?"Right":"")}),ae},xr.prototype[s+"Right"]=function(P){return this.reverse()[s](P).reverse()}}),Ei(["filter","map","takeWhile"],function(s,p){var P=p+1,ae=P==1||P==3;xr.prototype[s]=function(pe){var Oe=this.clone();return Oe.__iteratees__.push({iteratee:nr(pe,3),type:P}),Oe.__filtered__=Oe.__filtered__||ae,Oe}}),Ei(["head","last"],function(s,p){var P="take"+(p?"Right":"");xr.prototype[s]=function(){return this[P](1).value()[0]}}),Ei(["initial","tail"],function(s,p){var P="drop"+(p?"":"Right");xr.prototype[s]=function(){return this.__filtered__?new xr(this):this[P](1)}}),xr.prototype.compact=function(){return this.filter(ma)},xr.prototype.find=function(s){return this.filter(s).head()},xr.prototype.findLast=function(s){return this.reverse().find(s)},xr.prototype.invokeMap=Lr(function(s,p){return typeof s=="function"?new xr(this):this.map(function(P){return Qi(P,s,p)})}),xr.prototype.reject=function(s){return this.filter(Wl(nr(s)))},xr.prototype.slice=function(s,p){s=Sr(s);var P=this;return P.__filtered__&&(s>0||p<0)?new xr(P):(s<0?P=P.takeRight(-s):s&&(P=P.drop(s)),p!==o&&(P=(p=Sr(p))<0?P.dropRight(-p):P.take(p-s)),P)},xr.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},xr.prototype.toArray=function(){return this.take(N)},Ro(xr.prototype,function(s,p){var P=/^(?:filter|find|map|reject)|While$/.test(p),ae=/^(?:head|last)$/.test(p),pe=we[ae?"take"+(p=="last"?"Right":""):p],Oe=ae||/^find/.test(p);pe&&(we.prototype[p]=function(){var Xe=this.__wrapped__,it=ae?[1]:arguments,wt=Xe instanceof xr,gt=it[0],Nt=wt||gr(Xe),Kt=function(Nn){var vn=pe.apply(we,Ma([Nn],it));return ae&&Pn?vn[0]:vn};Nt&&P&&typeof gt=="function"&>.length!=1&&(wt=Nt=!1);var Pn=this.__chain__,jn=!!this.__actions__.length,Qn=Oe&&!Pn,Ut=wt&&!jn;if(!Oe&&Nt){Xe=Ut?Xe:new xr(this);var on=s.apply(Xe,it);retur
|
||
|
指定插入点:`);let r=MxFun.getCurrentDraw();w.go(o=>{if(o!=0)return;let a=MxFun.screenCoordLong2Doc(300),v=MxFun.screenCoordLong2Doc(200);const h=w.value();let b=MxFun.screenCoord2Doc(10,10);h.z=b.z;let D=new MxDbImage;D.setRenderOrder(MxType.MxDefaultRenderOrder.kCADMeshRenderOrder-1),D.setPoint1(h);let U=new THREE.Vector3(h.x+a,h.y+v,h.z);D.setPoint2(U);let V=prompt("请填写图片网络地址","https://cdn.pixabay.com/photo/2022/11/15/12/23/winter-7593872_960_720.jpg");V&&(D.setImagePath(V),r.addMxEntity(D),D.addEvent("onStartGripEidt",()=>(D.visible=!1,D.setNeedUpdateDisplay(),{renderOrder:MxType.MxDefaultRenderOrder.kCADMeshRenderOrder-1})),D.addEvent("onEndGripEidt",()=>{D.visible=!0,D.setNeedUpdateDisplay()}))})}MxDbEntity.isRegister=!1;class MxDbImage extends MxDbEntity{constructor(){super(...arguments),this.pt1=new THREE.Vector3,this.pt2=new THREE.Vector3,this.imagePath="",this.isLoadMaterialFromPath=!0,this.material=null,this.angle=0}getTypeName(){return"MxDbImage"}getAngle(){return this.angle}setAngle(r){this.angle=r}worldDraw(r){let o=new THREE.Vector3(this.pt1.x,this.pt2.y),a=new THREE.Vector3(this.pt2.x,this.pt1.y);if(Math.abs(this.angle)>1e-5){let v=new THREE.Vector3(.5*(this.pt1.x-this.pt2.x)+this.pt2.x,.5*(this.pt1.y-this.pt2.y)+this.pt2.y),h=new THREE.Matrix4;h.makeRotationZ(this.angle);let b=new THREE.Matrix4().makeTranslation(v.x,v.y,v.z).multiply(h).multiply(new THREE.Matrix4().makeTranslation(-v.x,-v.y,-v.z));r.setMatrix(b)}if(r.getType()==1){if(r.drawSelectLine(this.pt1,o),r.drawSelectLine(o,this.pt2),r.drawSelectLine(this.pt2,a),r.drawSelectLine(a,this.pt1),this.material){let v=Math.abs(this.pt1.x-this.pt2.x),h=Math.abs(this.pt1.y-this.pt2.y),b=new THREE.PlaneGeometry(v,h),D=Math.min(this.pt1.x,this.pt2.x),U=Math.min(this.pt1.y,this.pt2.y);for(let I=0;I<b.vertices.length;I++)b.vertices[I].x+=D+.5*v,b.vertices[I].y+=U+.5*h,b.vertices[I].z=0;let V=new THREE.Mesh(b,this.material);V.material.depthTest=!1,r.drawEntity(V)}else if(this.imagePath.length>0&&this.isLoadMaterialFromPath){let v=this,h=r.getMxObject();const b=D=>{this.isLoadMaterialFromPath=!1,D&&(v.setMaterial(D),v.setNeedUpdateDisplay(),h.updateDisplay())};MxFun.loadImageMaterial(this.imagePath,D=>{b(D)})}}else if(this.material){let v=Math.abs(this.pt1.x-this.pt2.x),h=Math.abs(this.pt1.y-this.pt2.y),b=new THREE.PlaneGeometry(v,h),D=Math.min(this.pt1.x,this.pt2.x),U=Math.min(this.pt1.y,this.pt2.y);for(let I=0;I<b.vertices.length;I++)b.vertices[I].x+=D+.5*v,b.vertices[I].y+=U+.5*h,b.vertices[I].z=0;let V=new THREE.Mesh(b,this.material);V.material.depthTest=!1,r.drawEntity(V)}else r.drawLine(this.pt1,o),r.drawLine(o,this.pt2),r.drawLine(this.pt2,a),r.drawLine(a,this.pt1);r.setMatrix(null)}setImagePath(r){this.imagePath=r,this.isLoadMaterialFromPath=!0,this.material=null}getImagePath(){return this.imagePath}setMaterial(r){this.material=r}loadMaterial(r){r&&(this.imagePath=r),this.isLoadMaterialFromPath=!1,this.material=null;let o=this;MxFun.loadImageMaterial(this.imagePath,a=>{this.isLoadMaterialFromPath=!1,o.setMaterial(a)})}setPoint1(r){this.pt1=r}getPoint1(){return this.pt1}setPoint2(r){this.pt2=r}getPoint2(){return this.pt2}getGripPoints(){let r=[];r.push(this.pt1),r.push(this.pt2);let o=new THREE.Vector3(this.pt1.x+.5*(this.pt2.x-this.pt1.x),this.pt1.y+.5*(this.pt2.y-this.pt1.y));return r.push(o),r}moveGripPointsAt(r,o){return r==0?this.pt1.add(o):r==1?this.pt2.add(o):r==2&&(this.pt1.add(o),this.pt2.add(o)),!0}dwgIn(r){return this.onDwgIn(r),this.pt1.copy(r.pt1),this.pt2.copy(r.pt2),this.imagePath=r.imagePath.substr(0),this.isLoadMaterialFromPath=!0,r.angle&&(this.angle=r.angle),r.material&&(this.material=r.material),!0}dwgOut(r){return this.onDwgOut(r),r.pt1=this.pt1,r.pt2=this.pt2,r.imagePath=this.imagePath,r.angle=this.angle,r.type==MxType.MxCloneType.kDragClone&&(r.material=this.material),r}create(){return new MxDbImage}}var McGiWorldDrawType;MxDbImage.cmd="Mx_DrawImage",MxDbImage.draw=drawMxDbImage,addRegisterMxDbEntity(MxDbImage),function(w){w[w.kWorldDraw=1]="kWorldDraw",w[w.kDynDragDraw=2]="kDynDragDraw",w[w.kSelectDraw=3]="kS
|
||
|
指定一点:`);let r=yield w.go();if(!r)return;let o=new MxDbSVG,a=prompt("请输入svg图片网络或本地地址","https://img.alicdn.com/imgextra/i2/O1CN01FF1t1g1Q3PDWpSm4b_!!6000000001920-55-tps-508-135.svg");if(!a)return;o.setSvgPath(a),o.setSvgPostion(r),o.svgReverse=!0,o.svgMargin.x=.2,o.setSvgAlignmentRatio(new THREE.Vector2(.5,-1)),o.setRenderOrder(100),o.setSvgSize(new THREE.Vector2(50,0));let v=new MxDbSVGText;v.txt="A1",v.txtPos=new THREE.Vector3(0,-30,0),v.txtHeight=30,o.addText(v),o.fixedSize=!0,o.color=65297,MxFun.addToCurrentSpace(o)})}class MxDbSVG extends MxDbEntity{constructor(){super(...arguments),this.svgPos=new THREE.Vector3,this.svg=null,this.svgPath="",this.svgSize=new THREE.Vector2(50,50),this.svgAlignmentRatio=new THREE.Vector2(0,0),this.imagePath="",this.isLoadMaterialFromPath=!0,this.material=null,this.svgRotate=0,this.svgReverse=!1,this.svgMirror=!1,this.svgChildColor=[],this.svgMargin=new THREE.Vector2(0,0),this.isSvgDirtyLocation=!1,this.isLoadFromPath=!0,this.aryText=[],this.svgBoxSize=null,this.fixedSize=!1,this.useSvgColor=!1}setSvgChildColor(r){if(this.svgChildColor=r,!this.useSvgColor&&this.svg){let o=new THREE.Color(this.getColor()),a=0,v=this;this.svg.traverse(function(h){h.material&&(a<v.svgChildColor.length?h.material.color=new THREE.Color(v.svgChildColor[a]):h.material.color=o,a++)}),this.setNeedUpdateDisplay(!0)}}getSvgChildColor(){return this.svgChildColor}calcVewSize(r){let o=this.svgSize.x,a=this.svgSize.y;return a<=0&&(a=this.svgBoxSize?this.svgBoxSize.y/this.svgBoxSize.x*o:o),this.fixedSize&&(o=r.screenCoordLong2Doc(o),a=r.screenCoordLong2Doc(a)),[o,a]}calcSvgDrawRect(r){if(!r)return;this.calcSvgPosition(r);let[o,a]=this.calcVewSize(r),v=new THREE.Matrix4;v.makeScale(this.svgMirror?-1:1,this.svgReverse?-1:1,1);let h=new THREE.Matrix4;h.makeRotationZ(this.svgRotate);let b=new THREE.Matrix4,D=new THREE.Vector3(this.svgPos.x-o*this.svgAlignmentRatio.x,this.svgPos.y-a*this.svgAlignmentRatio.y,0);b.makeTranslation(D.x,D.y,D.z),h.multiply(v),h.premultiply(b);let U=new THREE.Vector3(0,0,0),V=new THREE.Vector3(o,0,0),I=new THREE.Vector3(o,a,0),g=new THREE.Vector3(0,a,0);return U.applyMatrix4(h),V.applyMatrix4(h),I.applyMatrix4(h),g.applyMatrix4(h),{pt1:U,pt2:I,pt3:V,pt4:g,cenpt:I.clone().add(U.clone().sub(I).multiplyScalar(.5)),sizew:o,sizeh:a}}calcImageDrawRect(r){if(!r)return;this.calcSvgPosition(r);let[o,a]=this.calcVewSize(r),v=new THREE.Matrix4;v.makeScale(this.svgMirror?-1:1,this.svgReverse?-1:1,1);let h=new THREE.Matrix4,b=new THREE.Matrix4,D=new THREE.Vector3(this.svgPos.x-o*this.svgAlignmentRatio.x,this.svgPos.y-a*this.svgAlignmentRatio.y,0);b.makeTranslation(D.x,D.y,D.z),h.multiply(v),h.premultiply(b);let U=new THREE.Vector3(0,0,0),V=new THREE.Vector3(o,0,0),I=new THREE.Vector3(o,a,0),g=new THREE.Vector3(0,a,0);return U.applyMatrix4(h),V.applyMatrix4(h),I.applyMatrix4(h),g.applyMatrix4(h),{pt1:U,pt2:I,pt3:V,pt4:g,cenpt:I.clone().add(U.clone().sub(I).multiplyScalar(.5)),sizew:o,sizeh:a}}worldDraw(r){let o,a=r.getMxObject();if(this.imagePath.length>0){if(o=this.calcImageDrawRect(a),Math.abs(this.svgRotate)>1e-5){let g=new THREE.Vector3(.5*(o.pt1.x-o.pt2.x)+o.pt2.x,.5*(o.pt1.y-o.pt2.y)+o.pt2.y),A=new THREE.Matrix4;A.makeRotationZ(this.svgRotate);let M=new THREE.Matrix4().makeTranslation(g.x,g.y,g.z).multiply(A).multiply(new THREE.Matrix4().makeTranslation(-g.x,-g.y,-g.z));r.setMatrix(M)}}else o=this.calcSvgDrawRect(a);let v=o.pt1,h=o.pt2,b=o.pt3,D=o.pt4,U=o.cenpt,V=o.sizew,I=this;if(r.getType()!=McGiWorldDrawType$1.kSelectDraw&&this.aryText.forEach((g,A)=>{if(g.txt.length>0){let F,T=new THREE.Vector3(g.txtPos.x,g.txtPos.y,0);this.fixedSize&&(g.txtPos.x>0?T.x=this.svgPos.x+a.screenCoordLong2Doc(g.txtPos.x):T.x=this.svgPos.x-a.screenCoordLong2Doc(g.txtPos.x),g.txtPos.y>0?T.y=this.svgPos.y+a.screenCoordLong2Doc(g.txtPos.y):T.y=this.svgPos.y-a.screenCoordLong2Doc(g.txtPos.y)),g.color&&(F=r.getColor(),r.setColor(g.color));let _=g.txtHeight;I.fixedSize&&(_=a.screenCoordLong2Doc(g.txtHeight)),r.setXData({type:"text",txt:g.txt,index:A});let Y=r.drawText(g.txt,_,0,T,void 0,k=>g.font
|
||
|
指定第一点:`);let r,o=new MxDbPolyline;w.go(a=>{if(a!=0)return;let v=w.value();r||(r=v.clone());let h=v;const b=new McEdGetPointWorldDrawObject;b.setDraw((U,V)=>{V.setColor(16711680),V.drawLine(h,U),V.drawCustomEntity(o)}),w.setUserDraw(b),w.setMessage(`
|
||
|
指定下一点:`);let D=0;o.addVertexAt(v),w.goWhile(U=>{if(U==0)h=w.value(),o.addVertexAt(h),++D>=2?(w.setMessage(`
|
||
|
指定下一点:`),w.setKeyWords("[闭合(C)/放弃(U)]")):D>0?(w.setMessage(`
|
||
|
指定下一点:`),w.setKeyWords("[放弃(U)]")):(w.setMessage(`
|
||
|
指定第一点:`),w.setKeyWords(""));else if(U==1){if(w.isKeyWordPicked("C"))return{exit:!0};w.isKeyWordPicked("U")&&console.log("Mx_Line undo....")}},()=>{MxFun.getCurrentDraw().addMxEntity(o)})})}MxDbSVG.cmd="Mx_ModelFixedSvg",MxDbSVG.draw=drawMxDbSVG,addRegisterMxDbEntity(MxDbSVG);class MxDbPolyline extends MxDbEntity{constructor(){super(...arguments),this.points=[]}getTypeName(){return"MxDbPolyline"}worldDraw(r){this.points.length<2||r.drawLines(this.points)}getGripPoints(){return this.points}moveGripPointsAt(r,o){return!(r>=this.points.length||(this.points[r].add(o),0))}create(){return new MxDbPolyline}dwgIn(r){this.onDwgIn(r);let o=r.points;return this.points=[],o.forEach(a=>{this.points.push(new THREE.Vector3(a.x,a.y,a.z))}),!0}dwgOut(r){return this.onDwgOut(r),r.points=this.points,r}addVertexAt(r){this.points.push(r)}numVerts(){return this.points.length}getPointAt(r){return r<this.points.length?this.points[r]:null}setPointAt(r,o){return r<this.points.length&&(this.points[r]=o,!0)}}function drawMxDb2LineAngularDimension(){const w=new MrxDbgUiPrPoint,r=MxFun.getCurrentDraw(),o=new MxDb2LineAngularDimension,a=new McEdGetPointWorldDrawObject;return w.setMessage(`
|
||
|
指定第一点:`),w.go(v=>{v===0&&(w.setMessage(`
|
||
|
指定第二个角度点:`),o.point1=w.value(),a.setDraw((h,b)=>{o.point2=h,a.drawLine(o.point1,h)}),w.setUserDraw(a),w.go(h=>{w.setMessage(`
|
||
|
指定最后一个点:`),h===0&&(o.point2=w.value(),a.setDraw((b,D)=>{o.point3=b,a.drawCustomEntity(o)}),w.go(b=>{b===0&&r.addMxEntity(o)}))}))}),o}MxDbPolyline.cmd="Mx_Lines",MxDbPolyline.draw=drawMxDbPolyline,addRegisterMxDbEntity(MxDbPolyline);const propertyDbKeys$6=["colors","point1","point2","point3"];class MxDb2LineAngularDimension extends MxDbEntity{constructor(r){if(super(),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3,this.point3=new THREE.Vector3,this.colors=[],r){const{points:o,colors:a}=r;o&&this.setPoints(o),a&&this.setColor(a)}}calculateLineAngle(r,o,a){const v=2*Math.PI/360;return{startAngle:180*Math.atan2(o.y-r.y,o.x-r.x)/Math.PI*v,endAngle:180*Math.atan2(a.y-r.y,a.x-r.x)/Math.PI*v}}setPoints(r){const[o,a,v]=r;return o&&(this.point1=o),a&&(this.point2=a),v&&(this.point3=v),this}setColor(r){return lodash.isArray(r)?this.colors=r:this.color=r,this}worldDraw(r){if(r.getType()==McGiWorldDrawType$1.kWorldDraw||r.getType()==McGiWorldDrawType$1.kDynDragDraw){const[o,a,v,h]=this.colors||[],b=this.getColor(),D=r.getMxObject();r.setOpacity(this.opacity),r.setColor(o||b),r.drawLine(this.point1,this.point2),r.setColor(a||b),r.drawLine(this.point2,this.point3);const{startAngle:U,endAngle:V}=this.calculateLineAngle(this.point2,this.point1,this.point3),I=this.point2.distanceTo(this.point1),g=this.point2.distanceTo(this.point3),A=Math.min(I,g)/4;let M=THREE.MathUtils.radToDeg(U-V);M<0&&(M+=360);let N=D.screenCoordLong2Doc(50);const F=new THREE.ArcCurve(this.point2.x,this.point2.y,A,U,V,!0),T=new THREE.Geometry().setFromPoints(F.getPoints(50));r.setColor(v||b),r.drawGeometryLines(T);const _=F.getPoint(.5);let Y=new THREE.Vector3(_.x,_.y,0);const k=Y.sub(this.point2),S=k.length()+.5*N;k.normalize().multiplyScalar(S),Y=this.point2.clone().add(k),r.setColor(h||b),r.drawText(M.toFixed(3)+"°",.5*N,0,Y)}else r.drawLine(this.point1,this.point2),r.drawLine(this.point3,this.point2)}getGripPoints(){return[this.point1,this.point2,this.point3]}moveGripPointsAt(r,o){return r===0?this.point1.add(o):r===1?this.point2.add(o):r===2&&this.point3.add(o),!0}dwgIn(r){return this.onDwgIn(r),this.dwgInHelp(r,propertyDbKeys$6),!0}dwgOut(r){return this.onDwgOut(r),this.dwgOutHelp(r,propertyDbKeys$6),r}create(){return new MxDb2LineAngularDimension}transformBy(r){this.point1.applyMatrix4(r),this.point2.applyMatrix4(r)}getTypeName(){return"MxDb2LineAngularDimension"}}MxDb2LineAngularDimension.cmd="Mx_AngleSurveying",MxDb2LineAngularDimension.draw=drawMxDb2LineAngularDimension,addRegisterMxDbEntity(MxDb2LineAngularDimension);class MxFilters{constructor(){this.uniformObj={},this.filtersStr="",this.filtersTypes="",this.VSHADER_SOURCE=`
|
||
|
varying vec2 v_Uv;
|
||
|
void main () {
|
||
|
v_Uv = uv;
|
||
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
|
}
|
||
|
`,this.FSHADER_SOURCE=`
|
||
|
varying vec2 v_Uv;
|
||
|
uniform sampler2D e_Texture;
|
||
|
uniform mat4 colorMatrix;
|
||
|
${this.filtersStr}
|
||
|
void main () {
|
||
|
vec4 color = texture2D( e_Texture, v_Uv );
|
||
|
color = color * colorMatrix;
|
||
|
${this.filtersTypes}
|
||
|
gl_FragColor = color;
|
||
|
}`,this._matrix=new THREE.Matrix4}channel({r=1,g:o=1,b:a=1}){return this._matrix=new THREE.Matrix4().set(r,0,0,0,0,o,0,0,0,0,a,0,0,0,0,1).multiply(this._matrix),this}brightness(r){return this._matrix=new THREE.Matrix4().set(r,0,0,0,0,r,0,0,0,0,r,0,0,0,0,1).multiply(this._matrix),this}saturate(r){const o=.2126*(1-r),a=.7152*(1-r),v=.0722*(1-r);return this._matrix=new THREE.Matrix4().set(o+r,a,v,0,o,a+r,v,0,o,a,v+r,0,0,0,0,1).multiply(this._matrix),this}contrast(r){const o=.5*(1-r);return this._matrix=new THREE.Matrix4().set(r,0,0,0,0,r,0,0,0,0,r,0,o,o,o,1).multiply(this._matrix),this}opacity(r){return this._matrix=new THREE.Matrix4().set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,r).multiply(this._matrix),this}invert(r){const o=1-2*r;return this._matrix=new THREE.Matrix4().set(o,0,0,0,0,o,0,0,0,0,o,0,r,r,r,1).multiply(this._matrix),this}grayscale(r=1){const o=.2126*r,a=.7152*r,v=.0722*r;return this._matrix=new THREE.Matrix4().set(o+1-r,a,v,0,o,a+1-r,v,0,o,a,v+1-r,0,0,0,0,1).multiply(this._matrix),this}sepia(r=1){return this._matrix=new THREE.Matrix4().set(1-.607*r,.769*r,.189*r,0,.349*r,1-.314*r,.168*r,0,.272*r,.534*r,1-.869*r,0,0,0,0,1).multiply(this._matrix),this}hueRotate(r){const o=r/180*Math.PI,a=Math.cos(o),v=Math.sin(o),h=.2126,b=.7152,D=.0722;return this._matrix=new THREE.Matrix4().set(h+.7874*a+v*-h,b+a*-b+v*-b,D+a*-D+.9278*v,0,h+a*-h+.143*v,b+a*(1-b)+.14*v,D+a*-D+-.283*v,0,h+a*-h+-.7874*v,b+a*-b+v*b,D+.9278*a+v*D,0,0,0,0,1).multiply(this._matrix),this}convolution(r,o=1/9,a=521){return this.uniformObj=Object.assign(Object.assign({},this.uniformObj),{cKernel:{value:r.toArray()},stStep:{value:o},scaleFactor:{value:a}}),this.filtersTypes.indexOf("convolutionTextureColor")<0&&(this.filtersStr+=`
|
||
|
uniform float cKernel[9];
|
||
|
uniform float stStep;
|
||
|
uniform float scaleFactor;
|
||
|
vec4 convolutionTextureColor(vec4 color) {
|
||
|
vec2 offsets[9];
|
||
|
offsets[0] = vec2(-1.0,-1.0);
|
||
|
offsets[1] = vec2(0.0,-1.0);
|
||
|
offsets[2] = vec2(1.0,-1.0);
|
||
|
offsets[3] = vec2(-1.0,0.0);
|
||
|
offsets[4] = vec2(0.0,0.0);
|
||
|
offsets[5] = vec2(1.0,0.0);
|
||
|
offsets[6] = vec2(-1.0,1.0);
|
||
|
offsets[7] = vec2(0.0,1.0);
|
||
|
offsets[8] = vec2(1.0,1.0);
|
||
|
|
||
|
vec4 sum = color;
|
||
|
for(int i = 0; i < 9; i++) {
|
||
|
sum = sum + cKernel[i] * scaleFactor * texture2D(e_Texture, v_Uv + offsets[i] / stStep);
|
||
|
};
|
||
|
return sum;
|
||
|
}`,this.filtersTypes+=`color = convolutionTextureColor(color);
|
||
|
`),this}reset(){return this.uniformObj={},this.filtersStr="",this.filtersTypes="",this._matrix=new THREE.Matrix4,this}_getFilterShaderData(r){return{uniforms:Object.assign({e_Texture:{value:r},colorMatrix:{value:this._matrix}},this.uniformObj),vertexShader:this.VSHADER_SOURCE,fragmentShader:this.FSHADER_SOURCE}}_getFilterColor(r="#000000",o=1){r=new THREE.Color(r);let{r:a,g:v,b:h}=r;const b=this._matrix.toArray();b[12],b[13],b[14],b[15];const D=b[0]*a+b[1]*a+b[2]*a+b[3]*o,U=b[4]*v+b[5]*v+b[6]*v+b[7]*o,V=b[8]*h+b[9]*h+b[10]*h+b[11]*o;return r.setRGB(D,U,V),r}toJSON(){return JSON.stringify({matrix:this._matrix.toArray(),uniformObj:this.uniformObj,filtersStr:this.filtersStr,filtersTypes:this.filtersTypes})}static fromJSON(r){const{matrix:o,uniformObj:a,filtersStr:v,filtersTypes:h}=JSON.parse(r),b=new MxFilters;return b._matrix=new THREE.Matrix4().fromArray(o),b.uniformObj=a,b.filtersStr=v,b.filtersTypes=h,b}}class MxDbShape extends MxDbEntity{constructor(){super(...arguments),this.isLoadMaterialFromPath=!0,this.stroke="#fff",this.strokeLineWidth=2,this.isStrokeDashLine=!1,this.isFill=!1,this._fillImageSrc=null,this.curveSegments=50,this.closed=!0,this.filter=null,this._cornerRadius=[],this._propertyDbKeys=["isFill","stroke","strokeLineWidth","isStrokeDashLine","closed","cornerRadius","fillImageSrc","fillImageParam","curveSegments"]}setStroke(r){return this.stroke=r,this}setStrokeLineWidth(r){return this.strokeLineWidth=r,this}setIsStrokeDashLine(r){return this.isStrokeDashLine=r,this}setIsFill(r){return this.isFill=r,this}get fillImageSrc(){return this._fillImageSrc}set fillImageSrc(r){this._fillImageSrc=r,this.isLoadMaterialFromPath=!0,this.material=null,this.fillImageSrc&&(this.isFill=!0),r!==!1&&r!==null||(this.setNeedUpdateDisplay(),MxFun.updateDisplay())}setFillImageSrc(r){return this.fillImageSrc=r,this}setFillImageParam(r){this.fillImageParam=r===void 0?r:Object.assign(this.fillImageParam,r)}setCurveSegments(r){return this.curveSegments=r,this}setClosed(r){return this.closed=r,this}getFilter(){return this.filter}setFilter(r){this.filter=r,this.isLoadMaterialFromPath=!0,this.material=null}get cornerRadius(){return this._cornerRadius}set cornerRadius(r){this.setCornerRadius(r)}setCornerRadius(r,o=!0){this._cornerRadius=r instanceof Array?r.map(a=>o?MxFun.screenCoordLong2Doc(a):a):o?MxFun.screenCoordLong2Doc(r):r}getTypeName(){return"MxDbShape"}getShapePoints(r){const{curveSegments:o}=this;return this.points=r.getPoints(o).map(a=>a instanceof THREE.Vector2?new THREE.Vector3(a.x,a.y,0):a),this.points}createPaths(r){return this._paths=new THREE.CurvePath,Array.isArray(r)?r.forEach(o=>this._paths.add(o)):this._paths.add(r),this._paths}_draw(r,o){let{isFill:a,closed:v,opacity:h,dLineWidth:b,lineWidthByPixels:D}=this;r.setOpacity(h),r.setLineWidthByPixels(D),r.setLineWidth(b);const U=r.getColor();r.setColor(this.filter?this.filter._getFilterColor(this.color,this.opacity):this.color);const V=this.getCornerRadiusPoints(v||a?this.getClosedPoints(o):o);a?!this.fillImageSrc&&r.drawSolid(V):r.drawLines(V),this._fillImg(r,V),r.setColor(U)}getCornerRadiusPoints(r){const{cornerRadius:o}=this;if(!o)return r;const a=typeof o=="number"?r.map(()=>o):o;return a.length>0?getToGenerateRoundedCorners(r,a):r}_drawStoreLine(r,o,a){const{isFill:v,stroke:h,strokeLineWidth:b}=this,D=r.getLineWidth(),U=r.getColor(),V=r.isDashLineDisplay();h&&v&&(r.setDashLineDisplay(this.isStrokeDashLine),r.setColor(h),r.setLineWidth(b),a?a(r):r.drawLines(this.getCornerRadiusPoints(this.getClosedPoints(o))),r.setColor(U),r.setLineWidth(D),r.setDashLineDisplay(V))}getClosedPoints(r){return[...r,r[0]]}getTotalLength(){if(this.points){let r=0;return this.points.reduce((o,a)=>(r+=o.distanceTo(a),a)),r}if(this._paths)return this._paths.getLength()+(this.closedLine?this.closedLine.getLength():0)}getGetLength(){return this._paths.getLength()}getArea(){return this.points?McGeTool.calcArea(this.closed?this.getClosedPoints(this.points):this.points):0}worldDraw(r){const o=this.createPaths(new THREE.Curve),a=this.getShapePoints(o);this._draw(r,a),this._drawStoreLine(r,a)}_fi
|
||
|
确定圆弧开始点:`),w.go(a=>{a===MrxDbgUiPrBaseReturn$1.kOk&&(o.point1=w.value(),r.setDraw(v=>{r.drawLine(o.point1,v)})),w.setMessage(`
|
||
|
确定圆弧结束点:`),w.go(v=>{v===MrxDbgUiPrBaseReturn$1.kOk&&(o.point2=w.value(),r.setDraw(h=>{o.point3=h,r.drawCustomEntity(o)})),w.setMessage(`
|
||
|
确定圆弧上任意一点:`),w.go(h=>{if(h===MrxDbgUiPrBaseReturn$1.kOk){MxFun.getCurrentDraw().addMxEntity(o);const{radius:b,angle:D,arcLength:U}=createThreePointArc(o.point1,o.point2,o.point3,!0);console.log("半径:",b),console.log("圆弧弧长:",U,o.getTotalLength())}})})})}addRegisterMxDbEntity(MxDbCircleShape);class Mx3PointArc extends MxDbCircleShape{constructor(){super(),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3,this.point3=new THREE.Vector3,this.autoClockwise=!0,this.closed=!1,this.centralAngle=0,this._propertyDbKeys=[...this._propertyDbKeys,"point1","point2","point3","autoClockwise"]}getTypeName(){return"Mx3PointArc"}create(){return new Mx3PointArc}worldDraw(r){this.updateDataInfo();const{centralAngle:o}=this.drawEllipseShape(r);this.centralAngle=o}getGripPoints(){return[this.point1,this.point2,this.point3,this.center]}compute3PointAngle(r=this.point1,o=this.point2,a=this.point3){const v=calculateArcAngle(r,this.center,this.radius),h=calculateArcAngle(o,this.center,this.radius),b=calculateArcAngle(a,this.center,this.radius);return[v.angle,h.angle,b.angle]}upDateCenter(r=this.point1,o=this.point2,a=this.point3){return this.center=calculateArcOrigin(r,o,a),this.center}upDateRadius(r=this.point1){return this.radius=calculateRadiusArc(r,this.center),this.radius}upDataClockwise(r,o,a){const{autoClockwise:v}=this;v&&(this.clockwise=judgementArcRenderDirection(o,r,a))}updateDataInfo(){this.upDateCenter(this.point1,this.point2,this.point3),this.upDateRadius(this.point1);const[r,o,a]=this.compute3PointAngle();this.startAngle=THREE.MathUtils.degToRad(r),this.endAngle=THREE.MathUtils.degToRad(o),this.upDataClockwise(r,o,a)}getArcMidPoint(){const r=MxFun.getMxFunTHREE();this.updateDataInfo();let{startAngle:o,endAngle:a,center:v,radius:h,clockwise:b}=this;b?o<a&&(o+=2*Math.PI):o>a&&(a+=2*Math.PI);const D=(o+a)/2,U=v.x+h*Math.cos(D),V=v.y+h*Math.sin(D);return new r.Vector3(U,V,0)}moveGripPointsAt(r,o){return r===0?this.point1.add(o):r===1?this.point2.add(o):r===2?this.point3.add(o):r===3&&(this.point1.add(o),this.point2.add(o),this.point3.add(o)),this.upDateCenter(),!0}}Mx3PointArc.cmd="Mx_3PointArc",Mx3PointArc.draw=drawMx3PointArc,Mx3PointArc.isRegister=!1,addRegisterMxDbEntity(Mx3PointArc);const drawMx2PointArc=()=>Si(void 0,null,function*(){const w=new MrxDbgUiPrPoint,r=new Mx2PointArc,o=yield w.go();if(!o)return;r.startPoint=o,w.setUserDraw((v,h)=>{r.endPoint=v,h.drawCustomEntity(r)});const a=yield w.go();a&&(r.endPoint=a,MxFun.getCurrentDraw().addMxEntity(r))});class Mx2PointArc extends Mx3PointArc{getTypeName(){return"Mx2PointArc"}create(){return new Mx2PointArc}get startPoint(){return this.point1}set startPoint(r){this.point1=r,this.point3.x,this.point1.x,this.point3.y,this.point2.y}get endPoint(){return this.point2}set endPoint(r){this.point2=r,this.point3=this.getArcMidPoint()}}function drawMxDbCoord(){const w=new MrxDbgUiPrPoint;w.setMessage(`
|
||
|
指定坐标点:`),w.go(r=>{if(r!=0)return;const o=w.value();let a=new MxDbCoord;a.point1=o,a.point2=o.clone(),w.setBasePt(o),w.setUseBasePt(!0),w.setUserDraw((v,h)=>{a.point2=v,h.drawCustomEntity(a)}),w.setMessage(`
|
||
|
指定标注点:`),w.go(v=>{v==0?(a.point2=w.value(),MxFun.addToCurrentSpace(a)):console.log(v)})})}Mx2PointArc.cmd="Mx_2PointArc",Mx2PointArc.draw=drawMx2PointArc,Mx2PointArc.isRegister=!1,addRegisterMxDbEntity(Mx2PointArc);class MxDbCoord extends MxDbEntity{constructor(){super(...arguments),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3}worldDraw(r){let o=r.getMxObject();r.drawLine(this.point1,this.point2);let a=this.point2.clone();var v=o.screenCoordLong2Doc(20),h=6*v;a.x=a.x+h,r.drawLine(this.point2,a);var b=new THREE.Vector3,D=new THREE.Vector3;let U=o.docCoord2Cad(this.point1.x,this.point1.y,this.point1.z),V=U.x.toFixed(3),I=U.y.toFixed(3);b.x=this.point2.x+.3*v+.5*h,b.y=this.point2.y+.1*v+.5*v,r.drawText(V,v,0,b),D.x=this.point2.x+.3*v+.5*h,D.y=this.point2.y-.1*v-.5*v,r.drawText(I,v,0,D)}getGripPoints(){let r=[];return r.push(this.point1),r.push(this.point2),r}moveGripPointsAt(r,o){return r==0?this.point1.add(o):r==1&&this.point2.add(o),!0}dwgIn(r){return this.onDwgIn(r),this.point1.copy(r.point1),this.point2.copy(r.point2),!0}dwgOut(r){return this.onDwgOut(r),r.point1=this.point1,r.point2=this.point2,r}create(){return new MxDbCoord}transformBy(r){this.point1.applyMatrix4(r),this.point2.applyMatrix4(r)}getTypeName(){return"MxDbCoord"}}function drawMxDbLine(){return Si(this,null,function*(){const w=new MrxDbgUiPrPoint;w.setMessage(`
|
||
|
指定第一点:`);let r=yield w.go();if(r==null)return;w.setBasePt(r.clone()),w.setUseBasePt(!0),w.setMessage(`
|
||
|
指定第二点:`);let o=yield w.go();if(o==null)return;let a=new MxDbLine;a.pt1=r,a.pt2=o,MxFun.addToCurrentSpace(a)})}MxDbCoord.cmd="Mx_Coord",MxDbCoord.draw=drawMxDbCoord,addRegisterMxDbEntity(MxDbCoord);class MxDbLine extends MxDbEntity{constructor(){super(...arguments),this.pt1=new THREE.Vector3,this.pt2=new THREE.Vector3}getTypeName(){return"MxDbLine"}worldDraw(r){r.drawLine(this.pt1,this.pt2)}setPoint1(r){this.pt1=r}getPoint1(){return this.pt1}setPoint2(r){this.pt2=r}getPoint2(){return this.pt2}getGripPoints(){let r=[];r.push(this.pt1),r.push(this.pt2);let o=new THREE.Vector3(this.pt1.x+.5*(this.pt2.x-this.pt1.x),this.pt1.y+.5*(this.pt2.y-this.pt1.y),0);return r.push(o),r}moveGripPointsAt(r,o){return r==0?this.pt1.add(o):r==1?this.pt2.add(o):r==2&&(this.pt1.add(o),this.pt2.add(o)),!0}dwgIn(r){return this.onDwgIn(r),this.pt1.copy(r.pt1),this.pt2.copy(r.pt2),!0}dwgOut(r){return this.onDwgOut(r),r.pt1=this.pt1,r.pt2=this.pt2,r}create(){return new MxDbLine}getGeomExtents(){return new THREE.Box3(this.pt1,this.pt2)}getGetLength(){return this.pt1.distanceTo(this.pt2)}}function drawMxDbRect(){return Si(this,null,function*(){const w=new MrxDbgUiPrPoint;w.setMessage(`
|
||
|
指定第一点:`);let r=yield w.go();if(!r)return;let o=new MxDbRect;o.pt1=r;const a=new McEdGetPointWorldDrawObject;a.setDraw(v=>{o.pt2=v,a.drawCustomEntity(o)}),w.setBasePt(r),w.setUseBasePt(!0),w.setUserDraw(a),w.setMessage(`
|
||
|
指定第二点:`),(yield w.go())&&(o.pt2=w.value(),MxFun.getCurrentDraw().addMxEntity(o))})}MxDbLine.cmd="Mx_Line",MxDbLine.draw=drawMxDbLine,addRegisterMxDbEntity(MxDbLine);class MxDbRect extends MxDbEntity{constructor(){super(...arguments),this.cornerRadius=[],this.pt1=new THREE.Vector3,this.pt2=new THREE.Vector3,this.isSolidColorFill=!1,this.isLoadMaterialFromPath=!0,this.material=null}worldDraw(r){let o=computeRectPoints(this.pt1,this.pt2);if(this.cornerRadius.length>0&&(o=getToGenerateRoundedCorners(o,this.cornerRadius)),r.getType()!=McGiWorldDrawType$1.kWorldDraw)return o.push(o[0]),void r.drawLines(o);const a={transparent:!0,depthTest:!1,opacity:this.opacity,visible:this.visible};if(this.isSolidColorFill){let v;o=o.map(({x:D,y:U})=>new THREE.Vector2(D,U)),v=new THREE.ShapeGeometry(new THREE.Shape(o));let h=new THREE.MeshBasicMaterial(Object.assign({color:this.filter?this.filter._getFilterColor(this.color,this.opacity):new THREE.Color(this.color)},a)),b=new THREE.Mesh(v,h);r.drawEntity(b)}else if(this.fillImageSrc){if(this.material){o=o.map(({x:D,y:U})=>new THREE.Vector2(D,U));let v=this.material,h=new THREE.ShapeGeometry(new THREE.Shape(o));if(h=repairGeometryFaceVertexUvs(h),this.filter){const D=v.map;this.fillImageParam&&(this.fillImageParam.center&&(D.center=this.fillImageParam.center),this.fillImageParam.offset&&(D.offset=this.fillImageParam.offset),this.fillImageParam.repeat&&(D.repeat=this.fillImageParam.repeat),this.fillImageParam.rotation&&(D.rotation=this.fillImageParam.rotation));const U=this.filter._getFilterShaderData(D);v=new THREE.ShaderMaterial(Object.assign(Object.assign({},U),a))}v.depthTest=!1,v.transparent=!0,v.opacity=this.opacity,v.visible=this.visible;let b=new THREE.Mesh(h,v);r.drawEntity(b)}else if(this.fillImageSrc.length>0&&this.isLoadMaterialFromPath){let v=this;MxFun.loadImageMaterial(this.fillImageSrc,h=>{this.isLoadMaterialFromPath=!1,h&&(v.material=h,v.setNeedUpdateDisplay(),MxFun.updateDisplay())})}}else r.drawLines([...o,o[0]])}getGripPoints(){let r=[];r.push(this.pt1);const o=new THREE.Line3(this.pt1,this.pt2);let a=new THREE.Vector3;return o.getCenter(a),r.push(a),r.push(this.pt2),r}moveGripPointsAt(r,o){return r==0?this.pt1.add(o):r==1?(this.pt1.add(o),this.pt2.add(o)):r==2&&this.pt2.add(o),!0}dwgIn(r){return this.onDwgIn(r),this.pt1.copy(r.pt1),this.pt2.copy(r.pt2),this.isSolidColorFill=r.isSolidColorFill,this.fillImageSrc=r.fillImageSrc,this.fillImageParam=r.fillImageParam,this.cornerRadius=r.cornerRadius,this.filter=r.filter,this.isLoadMaterialFromPath=!0,this.material=null,!0}dwgOut(r){return this.onDwgOut(r),r.pt1=this.pt1,r.pt2=this.pt2,r.isSolidColorFill=this.isSolidColorFill,r.fillImageSrc=this.fillImageSrc,r.fillImageParam=this.fillImageParam,r.cornerRadius=this.cornerRadius,r.filter=this.filter,r}create(){return new MxDbRect}transformBy(r){this.pt1.applyMatrix4(r),this.pt2.applyMatrix4(r)}setRadius(r,o=!0){this.cornerRadius=r instanceof Array?r.map(a=>o?MxFun.screenCoordLong2Doc(a):a):r>0?o?[MxFun.screenCoordLong2Doc(r),MxFun.screenCoordLong2Doc(r),MxFun.screenCoordLong2Doc(r),MxFun.screenCoordLong2Doc(r)]:[r,r,r,r]:[]}getTypeName(){return"MxDbRect"}getFilter(){return this.filter}setFilter(r){this.filter=r,this.isLoadMaterialFromPath=!0,this.material=null}setFillImagePath(r){this.fillImageSrc=r,this.isLoadMaterialFromPath=!0,this.material=null,this.fillImageSrc&&(this.isSolidColorFill=!1)}getFillImagePath(){return this.fillImageSrc}}function drawMxDbAlignedDimension(){let w=new MxDbAlignedDimension;const r=new MrxDbgUiPrPoint;return r.setMessage(`
|
||
|
指定第一点:`),r.go(o=>{if(o!=0)return;const a=r.value();w.setPoint1(a),w.setColor(65314);const v=new McEdGetPointWorldDrawObject;v.setDraw(h=>{w.setPoint2(h),v.drawCustomEntity(w)}),r.setBasePt(a),r.setUseBasePt(!0),r.setUserDraw(v),r.setMessage(`
|
||
|
指定第二点:`),r.setInputToucheType(MxType.InputToucheType.kGetEnd),r.go(h=>{if(h!=0)return void console.log(h);const b=r.value();w.setPoint2(b),MxFun.getCurrentDraw().addMxEntity(w)})}),w}MxDbRect.cmd="Mx_DrawRect",MxDbRect.draw=drawMxDbRect,addRegisterMxDbEntity(MxDbRect);const propertyDbKeys$5=["point1","point2","fontColor"];class MxDbAlignedDimension extends MxDbEntity{constructor(r){if(super(),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3,r){const{points:o,fontColor:a}=r;o&&this.setPoints(o),a&&(this.fontColor=a)}}setPoints(r){const[o,a]=r;o&&(this.point1=o),a&&(this.point2=a)}getTypeName(){return"MxDbAlignedDimension"}getDirection(r,o,a){const v=new THREE.Vector3(r.x,r.y,0),h=new THREE.Vector3(1,0,0),b=r.angleTo(h);let D=-1;(b<7*Math.PI/18||b>10*Math.PI/18)&&o.x>a.x&&(D=1);const U=new THREE.Matrix4;return U.makeRotationZ(Math.PI/2*D),v.applyMatrix4(U),v}getDimText(){return new THREE.Vector3(this.point1.x-this.point2.x,this.point1.y-this.point2.y,0).length().toFixed(3)}worldDraw(r){if(r.setOpacity(this.opacity),r.getType()==McGiWorldDrawType$1.kWorldDraw||r.getType()==McGiWorldDrawType$1.kDynDragDraw){let S=function(G,C){Array.isArray(G)?G.forEach(B=>{S(B,C)}):G.opacity=C};const o=this.point1,a=this.point2;let v,h,b,D,U,V,I;const g=new THREE.Vector3(o.x-a.x,o.y-a.y,0),A=this.getDirection(g,o,a),M=new THREE.Matrix4;M.makeScale(.01,.01,.01);const N=new THREE.Vector3(A.x,A.y,0);N.applyMatrix4(M);const F=new THREE.Vector3(o.x+N.x,o.y+N.y,0),T=new THREE.Vector3(a.x+N.x,a.y+N.y,0),_=this.getColor();V=MxThreeJS.createPoint(o,_),I=MxThreeJS.createPoint(a,_);const Y=new THREE.Vector3(A.x,A.y,0),k=new THREE.Vector3(A.x,A.y,0);M.identity(),M.makeScale(.2,.2,0),Y.applyMatrix4(M),M.identity(),M.makeScale(.02,.02,0),k.applyMatrix4(M),r.drawLine(F.x+2*k.x,F.y+2*k.y,T.x+2*k.x,T.y+2*k.y),v=MxThreeJS.createLine(new THREE.Vector3(F.x+3*k.x,F.y+3*k.y,0),new THREE.Vector3(o.x+.5*k.x,o.y+.5*k.y,0),_),h=MxThreeJS.createLine(new THREE.Vector3(T.x+3*k.x,T.y+3*k.y,0),new THREE.Vector3(a.x+.5*k.x,a.y+.5*k.y,0),_);{const G=new THREE.Vector3(1,0,0);let C=g.angleTo(G);const B=new THREE.Vector3(A.x,A.y,0);B.normalize();const R=o.distanceTo(a);g.y<0?C=C<Math.PI/2?2*Math.PI-C:Math.PI-C:C>Math.PI/2&&(C=Math.PI+C);const u=r.getMxObject();u&&(C-=u.getViewAngle());const c=this.getDimText();(b=MxThreeJS.creatTextSprite(c,new THREE.Vector3(T.x+g.x/2+B.x*R/15,T.y+g.y/2+B.y*R/15,0),.07*R,C,this.fontColor||_))!=null&&(b.material.opacity=this.opacity,r.drawEntity(b))}{M.identity(),M.makeScale(.08,.08,.08);const G=new THREE.Matrix4;G.makeRotationZ(17*Math.PI/18);let C=new THREE.Vector3(g.x,g.y,0);C.applyMatrix4(M),C.applyMatrix4(G),G.identity(),G.makeRotationZ(17*-Math.PI/18);let B=new THREE.Vector3(g.x,g.y,0);B.applyMatrix4(M),B.applyMatrix4(G);const R=new Array;R.push(new THREE.Vector3(F.x+2*k.x,F.y+2*k.y,0),new THREE.Vector3(F.x+2*k.x+C.x,F.y+C.y+2*k.y,0),new THREE.Vector3(F.x+2*k.x+B.x,F.y+B.y+2*k.y,0)),D=MxThreeJS.createTriangle(R,_),G.identity(),G.makeRotationZ(Math.PI/18),(C=new THREE.Vector3(g.x,g.y,0)).applyMatrix4(M),C.applyMatrix4(G),G.identity(),G.makeRotationZ(-Math.PI/18),(B=new THREE.Vector3(g.x,g.y,0)).applyMatrix4(M),B.applyMatrix4(G);const u=new Array;u.push(new THREE.Vector3(T.x+2*k.x,T.y+2*k.y,0),new THREE.Vector3(T.x+C.x+2*k.x,T.y+C.y+2*k.y,0),new THREE.Vector3(T.x+B.x+2*k.x,T.y+B.y+2*k.y,0)),U=MxThreeJS.createTriangle(u,_)}r.drawEntity(v),r.drawEntity(h),D&&(S(D.material,this.opacity),r.drawEntity(D)),U&&(S(U.material,this.opacity),r.drawEntity(U)),r.drawEntity(V),r.drawEntity(I)}else r.drawLine(this.point1,this.point2)}setPoint1(r){this.point1=r}setPoint2(r){this.point2=r}setColor(r){return lodash.isArray(r)?([this.color=this.color,this.fontColor=this.fontColor||this.color]=r,console.log("this.fontColor : ",this.fontColor)):this.color=r,this}getGripPoints(){let r=[];return r.push(this.point1),r.push(this.point2),r}moveGripPointsAt(r,o){return r==0?this.point1.add(o):(r=1)&&this.point2.add(o),!0}dwgIn(r){return this.onDwgIn(r),this.dwgInHelp(r,propertyDbKeys$5),!0}dwgOut(r){return this.onDwgOut(r),this.dwgOutHelp(r,pro
|
||
|
指定第一点:`),w.go(r=>{if(r!=0)return;const o=w.value();let a=new MxDbArea;a.addPoint(o);const v=new McEdGetPointWorldDrawObject;v.setDraw((h,b)=>{let D=a.clone();D.addPoint(h),v.drawCustomEntity(D)}),w.setUserDraw(v),w.setMessage(`
|
||
|
指定下一点:`),w.goWhile(h=>{if(h==0){const b=w.value();a.addPoint(b)}},h=>{a.isFill=!0,a.fillOpacity=.7,a.fillColor=6697540,MxFun.getCurrentDraw().addMxEntity(a)})})}addRegisterMxDbEntity(MxDbHatch);class MxDbArea extends MxDbEntity{constructor(){super(...arguments),this.points=[],this.isFill=!1,this.fillColor=6697540,this.fillOpacity=.7}getTypeName(){return"MxDbArea"}create(){return new MxDbArea}getDimText(){return McGeTool.calcArea(this.points).toFixed(2)}worldDraw(r){if(this.points.length<3)return void(this.points.length==2&&r.drawLine(this.points[0],this.points[1]));let o=this.points[0],a=o.clone(),v=o.clone(),h=this.points.length;for(let I=1;I<h;I++){let g=this.points[I];a.x>g.x&&(a.x=g.x),a.y>g.y&&(a.y=g.y),v.x<g.x&&(v.x=g.x),v.y<g.y&&(v.y=g.y),r.drawLine(o,g),o=g}r.drawLine(o,this.points[0]);let b=new THREE.Vector3(a.x+.5*(v.x-a.x),a.y+.5*(v.y-a.y));const D=r.getColor();let U=MxFun.screenCoordLong2Doc(20),V=MxThreeJS.creatTextSprite(this.getDimText(),b,U,0,D);if(V!=null&&r.drawEntity(V),r.getType()==McGiWorldDrawType$1.kWorldDraw&&this.isFill){r.setColor(this.fillColor),r.setOpacity(this.fillOpacity),r.setRenderOrder(r.getRenderOrder()-1);const I=new MxDbHatch;I.points=this.points,I.worldDraw(r)}}getGripPoints(){return this.points}moveGripPointsAt(r,o){return!(r>=this.points.length||(this.points[r].add(o),0))}dwgIn(r){this.onDwgIn(r);let o=r.points;return this.points=[],o.forEach(a=>{this.points.push(new THREE.Vector3(a.x,a.y,a.z))}),this.dwgInHelp(r,["isFill","fillColor","fillOpacity"]),!0}dwgOut(r){return this.onDwgOut(r),r.points=this.points,this.dwgOutHelp(r,["isFill","fillColor","fillOpacity"]),r}addPoint(r){this.points.push(r.clone())}getPoints(){return this.points}clearPoint(){this.points=[]}}function drawMxDbLeadTag(){return Si(this,null,function*(){let r=yield new MrxDbgUiPrPoint().go();if(!r)return;let o=prompt("请输入文字批注","批注");if(!o)return;const a=new MxDbLeadTag;a.point=r,a.text=o,MxFun.addToCurrentSpace(a)})}MxDbArea.cmd="Mx_Area",MxDbArea.draw=drawMxDbArea,addRegisterMxDbEntity(MxDbArea);class MxDbLeadTag extends MxDbEntity{constructor(){super(...arguments),this.point=new THREE.Vector3,this.leadLen=88,this.text="",this.textHeight=24}getTypeName(){return"MxDbLeadTag"}createDots(r,o){const{x:a,y:v,z:h}=r,b=new THREE.Shape;b.arc(a,v,o.screenCoordLong2Doc(6),0,2*Math.PI,!0);const D=new THREE.Path;D.arc(a,v,o.screenCoordLong2Doc(3),0,2*Math.PI,!0),b.holes.push(D);const U=new THREE.ShapeGeometry(b),V=new THREE.MeshPhongMaterial({color:"#ff0000",transparent:!0}),I=new THREE.Shape;I.arc(a,v,o.screenCoordLong2Doc(3),0,2*Math.PI,!0);const g=new THREE.ShapeGeometry(I),A=new THREE.MeshPhongMaterial({color:"#e2da8f",transparent:!0}),M=new THREE.Mesh(U,V),N=new THREE.Mesh(g,A);return M.add(N),M}worldDraw(r){let o=r.getMxObject();const a=this.createDots(this.point,o);if(r.drawEntity(a),a.geometry.computeBoundingBox(),r.drawSelectLine(a.geometry.boundingBox.max,a.geometry.boundingBox.min),r.getType()===2)return;let v=r.getMxObject().screenCoordLong2Doc(this.leadLen),h=new THREE.Vector3(this.point.x+2*v,this.point.y+v,0);const b=h.x-v,D=new THREE.Vector3(b,h.y,h.z);r.setLineWidth(4),r.setColor(16770565),r.drawLines([this.point,D,h]);const U=r.getMxObject().screenCoordLong2Doc(this.textHeight),V=h.clone().setX(h.x);r.setColor(16744448);const I=MxThreeJS.creatTextSprite(this.text,V,U,0,r.getColor());if(I){const g=new THREE.Box3,A=new THREE.Vector3;g.expandByObject(I),g.getSize(A),I.position.setX(I.position.x+A.x/2);const M=r.getMxObject().screenCoordLong2Doc(5),N=g.min.clone().setX(g.min.x+A.x/2).setY(g.min.y-M),F=g.max.clone().setX(g.max.x+A.x/2).setY(g.min.y+M);F.setY(g.max.y+M);const T=new THREE.Vector3(N.x,F.y),_=new THREE.Vector3(F.x,N.y);r.setColor(16777215),r.setLineWidth(0),r.drawLine(N,T),r.drawLine(F,_),r.drawLine(N,_),r.drawLine(T,F);const Y=M/2,k=[],S=[];k.push(new THREE.Vector3(T.x+Y,T.y-M,T.z),new THREE.Vector3(T.x+Y,T.y-Y,T.z),new THREE.Vector3(T.x+M,T.y-Y,T.z)),S.push(new THREE.Vector3(_.x-Y,_.y+M,_.z),new THREE.Vector3(_.x-Y,_.y+Y,_.z),new THREE.Vector3(_.x-M,_.y+Y,_.z)),r.drawLi
|
||
|
点击开始画线:`),w.go(v=>{v===MrxDbgUiPrBaseReturn$1.kOk&&(a.points.push(w.value()),o.setDraw(h=>{a.points.push(h.clone()),o.drawCustomEntity(a)})),w.setMessage(`
|
||
|
再次点击结束画线:`),w.go(h=>{h===MrxDbgUiPrBaseReturn$1.kOk&&r.addMxEntity(a)})})}MxDbLeadTag.cmd="Mx_LeadTag",MxDbLeadTag.draw=drawMxDbLeadTag,addRegisterMxDbEntity(MxDbLeadTag);const propertyDbKeys$4=["points"];class MxDbAnyLine extends MxDbEntity{constructor(){super(...arguments),this.points=[]}getTypeName(){return"MxDbAnyLine"}create(){return new MxDbAnyLine}worldDraw(r){let o=r.getMxObject();const a=new THREE.Box3().setFromPoints(this.points);let v=new THREE.Vector3;if(a.getCenter(v),r.drawLines(this.points),r.getType()===McGiWorldDrawType$1.kSelectDraw){const h=new THREE.Vector3;a.getSize(h),h.addScalar(o.screenCoordLong2Doc(20));const b=h.x/2,D=h.y/2,U={x:v.x-b,y:v.y-D},V={x:v.x+b,y:v.y-D},I={x:v.x+b,y:v.y+D},g={x:v.x-b,y:v.y+D};r.drawLine(V.x,V.y,I.x,I.y),r.drawLine(U.x,U.y,V.x,V.y),r.drawLine(I.x,I.y,g.x,g.y),r.drawLine(g.x,g.y,U.x,U.y)}}setPoints(r){return this.points=r,this}getCenter(){const r=new THREE.Geometry;r.vertices=this.points;const o=new THREE.Vector3;return r.computeBoundingBox(),r.boundingBox.getCenter(o),o}getGripPoints(){return[this.getCenter()]}moveGripPointsAt(r,o){return r===0&&this.points.forEach(a=>{a.add(o)}),!0}dwgIn(r){return this.onDwgIn(r),this.dwgInHelp(r,propertyDbKeys$4),!0}dwgOut(r){return this.onDwgOut(r),this.dwgOutHelp(r,propertyDbKeys$4),r}}function drawMxDbCloudLine(){const w=new MrxDbgUiPrPoint,r=MxFun.getCurrentDraw(),o=new McEdGetPointWorldDrawObject;w.setMessage(`
|
||
|
点击开启绘制云线:`),w.go(()=>{const a=MxFun.screenCoordLong2Doc(16);let v=w.value();const h=new MxDbCloudLine;h.setRadius(a),h.addPoint(v),o.setDraw(b=>{v.distanceTo(b)>a&&(v=b.clone(),h.addPoint(b,!0)),o.drawCustomEntity(h)}),w.setUserDraw(o),w.setMessage(`
|
||
|
再次点击结束绘制云线:`),w.go(()=>{r.addMxEntity(h)})})}MxDbAnyLine.cmd="Mx_AnyLine",MxDbAnyLine.draw=drawMxDbAnyLine,addRegisterMxDbEntity(MxDbAnyLine);const propertyDbKeys$3=["points","radius"];class MxDbCloudLine extends MxDbEntity{constructor(){super(),this.points=[],this.radius=16,this.cachePoint=null,this.use_smallcoord_display=!0}getTypeName(){return"MxDbCloudLine"}create(){return new MxDbCloudLine}setRadius(r){this.radius=r}getRadius(){return this.radius}getCachePoint(){return this.cachePoint}clacNewArcDiameterPoint(r){if(this.points.length==0)return r;let o=this.points[this.points.length-1];const a=2*this.radius,v=o.distanceTo(r);if(v<a)return null;const h=a*(r.x-o.x)/v+o.x,b=a*(r.y-o.y)/v+o.y;return new THREE.Vector3(h,b,o.z)}createCloudArcCurvePoints(r,o,a){const v=new THREE.Vector3((r.x+o.x)/2,(r.y+o.y)/2,0);a||(a=v.distanceTo(r));const{startAngle:h,endAngle:b}=function(D,U,V){const I=2*Math.PI/360;return{startAngle:180*Math.atan2(U.y-D.y,U.x-D.x)/Math.PI*I,endAngle:180*Math.atan2(V.y-D.y,V.x-D.x)/Math.PI*I}}(v,r,o);return new THREE.ArcCurve(v.x,v.y,a,h,b,!0).getPoints(10)}addPoint(r,o){let a=this.clacNewArcDiameterPoint(r);a&&(this.points.push(a),this.cachePoint=null,o&&(this.cachePoint=this.reCalculateDrawGeometryPoint()))}addLine(r,o){this.addPoint(r);const a=2*this.radius;let v=this.points[this.points.length-1],h=v.distanceTo(o);const b=Math.round(h/a);for(let D=0;D<b;D++){h=v.distanceTo(o);const U=a*(o.x-v.x)/h+v.x,V=a*(o.y-v.y)/h+v.y;let I=new THREE.Vector3(U,V,o.z);this.addPoint(I),v=I}return this.addPoint(o),this.points[this.points.length-1]}reCalculateDrawGeometryPoint(){if(this.points.length<2)return null;let r=this.points[0],o=this.points.length,a=[];for(let v=1;v<o;v++){let h=this.points[v];this.createCloudArcCurvePoints(r,h).forEach(b=>{a.push(new THREE.Vector3(b.x,b.y,0))}),r=h}return a}worldDraw(r){if(this.cachePoint||(this.cachePoint=this.reCalculateDrawGeometryPoint()),!this.cachePoint)return;let o=r.getMxObject();if(r.getType()===McGiWorldDrawType$1.kSelectDraw){let a=new THREE.Geometry;this.cachePoint.forEach(A=>{a.vertices.push(new THREE.Vector3(A.x,A.y,0))}),a.computeBoundingBox();const v=new THREE.Vector3;a.boundingBox.getSize(v);let h=new THREE.Vector3;a.boundingBox.getCenter(h);const b=v.x/2,D=v.y/2,U={x:h.x-b,y:h.y-D},V={x:h.x+b,y:h.y-D},I={x:h.x+b,y:h.y+D},g={x:h.x-b,y:h.y+D};r.drawLine(this.toSmallcoord2(o,U.x,U.y),this.toSmallcoord2(o,V.x,V.y)),r.drawLine(this.toSmallcoord2(o,V.x,V.y),this.toSmallcoord2(o,I.x,I.y)),r.drawLine(this.toSmallcoord2(o,I.x,I.y),this.toSmallcoord2(o,g.x,g.y)),r.drawLine(this.toSmallcoord2(o,g.x,g.y),this.toSmallcoord2(o,U.x,U.y))}else{let a=[];this.cachePoint.forEach(v=>{a.push(this.toSmallcoord(o,v))}),r.drawLines(a)}}getCenter(){const r=new THREE.Geometry;r.vertices=this.points;let o=new THREE.Vector3;return r.computeBoundingBox(),r.boundingBox.getCenter(o),o}getGripPoints(){return[this.getCenter()]}moveGripPointsAt(r,o){return this.points.forEach(a=>{a.add(o)}),this.cachePoint=null,!0}dwgIn(r){return this.onDwgIn(r),this.dwgInHelp(r,propertyDbKeys$3),this.cachePoint=null,!0}dwgOut(r){return this.onDwgOut(r),this.dwgOutHelp(r,propertyDbKeys$3),r.type===MxType.MxCloneType.kSaveDwgClone&&this.dwgOutHelp(r,["cachePoint"]),r}}function drawMxDbRegularPolygon(){const w=new MrxDbgUiPrPoint,r=MxFun.getCurrentDraw(),o=new McEdGetPointWorldDrawObject,a=new MxDbRegularPolygon;w.setMessage(`
|
||
|
点击开始绘制多边形:`),w.go(()=>{let v=prompt("请输入多边形的边数","8");v&&(a.sidesNumber=Number(v),a.centerPoint=w.value(),w.setUserDraw(o),o.setDraw(h=>{a.otherPoint=h,o.drawCustomEntity(a)}),w.setMessage(`
|
||
|
再次点击结束绘制多边形:`),w.go(()=>{r.addMxEntity(a)}))})}MxDbCloudLine.isRegister=!1,MxDbCloudLine.cmd="Mx_CloudLine",MxDbCloudLine.draw=drawMxDbCloudLine,addRegisterMxDbEntity(MxDbCloudLine);class MxDbRegularPolygon extends MxDbShape{getTypeName(){return"MxDbRegularPolygon"}constructor(){super(),this.centerPoint=new THREE.Vector3,this.otherPoint=new THREE.Vector3,this.sidesNumber=5,this._propertyDbKeys=[...this._propertyDbKeys,"centerPoint","otherPoint","sidesNumber"]}worldDraw(r){const o=computeRegularPolygonVertices(this.centerPoint,this.otherPoint,this.sidesNumber);this.closed=!1,o.push(o[0]),this._draw(r,o),this._drawStoreLine(r,o)}getGripPoints(){return[this.centerPoint,this.otherPoint]}moveGripPointsAt(r,o){return r===0?(this.centerPoint.add(o),this.otherPoint.add(o)):r===1&&this.otherPoint.add(o),!0}}function drawMxDbLeadComment(){const w=new MrxDbgUiPrPoint;w.setMessage(`
|
||
|
指定第一点:`),w.go(r=>{if(r!=0)return;const o=w.value();let a=new MxDbLeadComment;a.point1=o.clone(),a.textHeight=MxFun.screenCoordLong2Doc(50);let v=prompt("请输入文字批注","批注");if(!v)return;a.text=v,a.textWidth=MxFun.screenCoordLong2Doc(10*v.length),a.fixedSize=!0,a.fixedSize&&(a.textHeight=50,a.textWidth=50*v.length);const h=new McEdGetPointWorldDrawObject;h.setDraw((b,D)=>{a.point2=b,D.drawCustomEntity(a)}),w.setBasePt(o),w.setUseBasePt(!0),w.setUserDraw(h),w.setMessage(`
|
||
|
指定第二点:`),w.go(b=>{if(b!=0)return void console.log(b);const D=w.value();a.point2=D,MxFun.addToCurrentSpace(a)})})}MxDbRegularPolygon.cmd="Mx_RegularPolygon",MxDbRegularPolygon.draw=drawMxDbRegularPolygon,addRegisterMxDbEntity(MxDbRegularPolygon);class MxDbLeadComment extends MxDbEntity{constructor(){super(),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3,this.text="",this.textHeight=20,this.textWidth=0,this.fixedSize=!1,this.use_smallcoord_display=!0}getTypeName(){return"MxDbLeadComment"}create(){return new MxDbLeadComment}worldDraw(r){let o=r.getMxObject(),a=this.toSmallcoord(o,this.point1),v=this.toSmallcoord(o,this.point2);if(r.drawLine(a,v),this.text.length>0){const h=new THREE.Vector3;let b=this.textHeight,D=this.textWidth;this.fixedSize&&(b=o.screenCoordLong2Doc(b),D=o.screenCoordLong2Doc(D));let U=MxThreeJS.clacTextSpriteSize(this.text,b,D);h.x=v.x+.5*U.textwidth,h.y=v.y+.5*U.allTextHeight,r.drawText(this.text,b,0,h,D);const V=new THREE.Vector3;V.x=v.x+U.textwidth,V.y=v.y,r.drawLine(V,v)}}getGripPoints(){let r=[];return r.push(this.point1),r.push(this.point2),r}moveGripPointsAt(r,o){return r==0?this.point1.add(o):r==1&&this.point2.add(o),!0}dwgIn(r){return this.onDwgIn(r),this.point1.copy(r.point1),this.point2.copy(r.point2),this.text=r.text.substr(0),this.textHeight=r.textHeight,r.textWidth&&(this.textWidth=r.textWidth),this.fixedSize=r.fixedSize,!0}dwgOut(r){return this.onDwgOut(r),r.point1=this.point1,r.point2=this.point2,r.textHeight=this.textHeight,r.text=this.text,r.textWidth=this.textWidth,r.fixedSize=this.fixedSize,r}onViewChange(){return!!this.fixedSize&&(this.setNeedUpdateDisplay(!1),!0)}}function drawMxDbRectBoxLeadComment(){const w=new MrxDbgUiPrPoint,r=MxFun.getCurrentDraw(),o=new McEdGetPointWorldDrawObject,a=new MxDbRectBoxLeadComment;a.setLineWidth(3),a.setLineWidthByPixels(!0),w.setMessage(`
|
||
|
云线框起始点:`),w.go(v=>{a.radius=MxFun.screenCoordLong2Doc(8),v==MrxDbgUiPrBaseReturn$1.kOk&&(a.point1=w.value(),o.setDraw(h=>{a.point2=h,o.drawCustomEntity(a)}),w.setUserDraw(o),w.setMessage(`
|
||
|
云线框结束点:`),w.go(h=>{if(h!=MrxDbgUiPrBaseReturn$1.kOk)return;a.point2=w.value(),o.setDraw(D=>{a.point3=D,o.drawCustomEntity(a)});let b=prompt("请输入文字批注","批注");b||(b="默认批注文字"),a.text=b,a.textWidth=MxFun.screenCoordLong2Doc(10*b.length),a.textHeight=MxFun.screenCoordLong2Doc(5*b.length),a.fixedSize=!0,a.fixedSize&&(a.textHeight=20,a.textWidth=20*b.length),w.setMessage(`
|
||
|
审图标注点:`),w.go(D=>{D==MrxDbgUiPrBaseReturn$1.kOk&&(a.point3=w.value(),r.addMxEntity(a))})}))})}MxDbLeadComment.cmd="Mx_Comment",MxDbLeadComment.draw=drawMxDbLeadComment,addRegisterMxDbEntity(MxDbLeadComment);class MxDbRectBoxLeadComment extends MxDbEntity{constructor(){super(),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3,this.point3=new THREE.Vector3,this.text="",this.textHeight=20,this.radius=16,this.textWidth=0,this.fixedSize=!1,this.use_smallcoord_display=!0}getTypeName(){return"MxDbRectBoxLeadComment"}create(){return new MxDbRectBoxLeadComment}getCloudLine(){let r=new MxDbCloudLine;r.setRadius(this.radius);let o=this.point1.clone(),a=this.point2.clone();if(o.x>a.x){let U=o.x;o.x=a.x,a.x=U}if(o.y>a.y){let U=o.y;o.y=a.y,a.y=U}let v=new THREE.Vector3(o.x,a.y,o.z);v=r.addLine(o,v),a=new THREE.Vector3(a.x,v.y,a.z),a=r.addLine(v,a);let h=new THREE.Vector3(a.x,o.y,o.z);h=r.addLine(a,h);let b=o=r.addLine(h,o),D=o.distanceTo(this.point3);return D>v.distanceTo(this.point3)&&(b=v,D=v.distanceTo(this.point3)),D>a.distanceTo(this.point3)&&(b=a,D=a.distanceTo(this.point3)),D>h.distanceTo(this.point3)&&(b=h,D=h.distanceTo(this.point3)),{cloudLine:r,pt1:o,pt2:v,pt3:a,pt4:h,leadPt:b}}worldDraw(r){let o=this.getCloudLine(),a=o.cloudLine;if(a.setUseSmallcoordDisplay(this.use_smallcoord_display),a.worldDraw(r),this.text.length>0){let v=o.leadPt,h=new MxDbLeadComment;h.setUseSmallcoordDisplay(this.use_smallcoord_display),h.point1=v,h.point2=this.point3,h.text=this.text,h.textHeight=this.textHeight,h.textWidth=this.textWidth,h.fixedSize=this.fixedSize,h.worldDraw(r)}}getGripPoints(){let r=[];return r.push(this.point1),r.push(this.point2),r.push(this.point3),r}moveGripPointsAt(r,o){return r==0?this.point1.add(o):r==1?this.point2.add(o):r==2&&this.point3.add(o),!0}dwgIn(r){return this.onDwgIn(r),this.point1.copy(r.point1),this.point2.copy(r.point2),this.point3.copy(r.point3),this.text=r.text.substr(0),this.textHeight=r.textHeight,this.radius=r.radius,r.textWidth&&(this.textWidth=r.textWidth),this.fixedSize=r.fixedSize,!0}dwgOut(r){if(this.onDwgOut(r),r.point1=this.point1,r.point2=this.point2,r.point3=this.point3,r.textHeight=this.textHeight,r.text=this.text,r.radius=this.radius,r.textWidth=this.textWidth,r.fixedSize=this.fixedSize,r.type===MxType.MxCloneType.kSaveDwgClone){let o=this.getCloudLine(),a=o.cloudLine.reCalculateDrawGeometryPoint();r.cachePoint=a||[],r.leadPt=o.leadPt}return r}onViewChange(){return!!this.fixedSize&&(this.setNeedUpdateDisplay(!1),!0)}}function drawMxDbEllipse(){const w=new MrxDbgUiPrPoint,r=MxFun.getCurrentDraw(),o=new McEdGetPointWorldDrawObject,a=new MxDbEllipse;w.setMessage(`
|
||
|
点击开始绘制椭圆:`),w.go(()=>{a.point1=w.value(),o.setDraw(v=>{a.point2=v,o.drawCustomEntity(a)}),w.setUserDraw(o),w.setMessage(`
|
||
|
再次点击结束绘制椭圆:`),w.go(()=>{r.addMxEntity(a)})})}MxDbRectBoxLeadComment.cmd="Mx_CheckDraw",MxDbRectBoxLeadComment.draw=drawMxDbRectBoxLeadComment,addRegisterMxDbEntity(MxDbRectBoxLeadComment);class MxDbEllipse extends MxDbEllipseShape{constructor(){super(),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3,this.isClosedToCenter=!1,this.closed=!1,this._propertyDbKeys=[...this._propertyDbKeys,"point1","point2"]}getTypeName(){return"MxDbEllipse"}create(){return new MxDbEllipse}setPoint1(r){return this.point1=r,this}setPoint2(r){return this.point2=r,this}worldDraw(r){const{point1:o,point2:a}=this,v=o.clone().set(a.x,o.y,a.z),h=a.clone().set(o.x,a.y,o.z);this.xRadius=o.distanceTo(v)/2,this.yRadius=o.distanceTo(h)/2;const b=o.x>a.x,D=o.y>a.y,U=b?o.x-this.xRadius:o.x+this.xRadius,V=D?o.y-this.yRadius:o.y+this.yRadius;this.center=new THREE.Vector3(U,V,0),this.drawEllipseShape(r),r.getType()===McGiWorldDrawType$1.kSelectDraw&&r.drawLines([o,new THREE.Vector3(o.x,a.y),a,new THREE.Vector3(a.x,o.y),o])}getGripPoints(){let r=new THREE.Vector3(.5*(this.point2.x+this.point1.x),.5*(this.point2.y+this.point1.y),0);return[this.point1,this.point2,r]}moveGripPointsAt(r,o){return r===0?this.point1.add(o):r===1?this.point2.add(o):r===2&&(this.point1.add(o),this.point2.add(o)),!0}}function drawMxDbText(){return Si(this,null,function*(){const w=new MrxDbgUiPrPoint;w.setMessage(`
|
||
|
点取文字插入点:`);let r=yield w.go();if(r==null)return;let o=prompt("请输入文字");if(!o)return;let a=new MxDbText;a.position=r,a.height=MxFun.screenCoordLong2Doc(50),a.text=o,MxFun.addToCurrentSpace(a)})}let _SpriteText;function getSpriteTextColor(w){return w?w instanceof THREE.Color?w.getStyle():typeof w=="number"?new THREE.Color(w).getStyle():w:"#fff"}function toCSSFont(w,r,o,a,v){let h=document.createElement("span");return h.style.font="1px serif",h.style.fontFamily=w,h.style.fontSize=`${r}px`,h.style.fontStyle=o,h.style.fontVariant=a,h.style.fontWeight=v,h.style.font}function getSpriteTextClass(){if(!_SpriteText){class w extends THREE.Sprite{constructor(o){super(new THREE.SpriteMaterial);const{text:a,textHeight:v,color:h,backgroundColor:b,padding:D,borderWidth:U,borderRadius:V,borderColor:I,strokeWidth:g,strokeColor:A,fontFace:M,fontSize:N,fontWeight:F,textAlign:T,textShadowBlur:_,textShadowColor:Y,textShadowOffsetX:k,textShadowOffsetY:S,angle:G,scale:C,underline:B,fontStyle:R,fontVariant:u}=o||{};this._text=`${a}`,this._textHeight=v||10,this._color=h,this._backgroundColor=b,this._padding=D||0,this._borderWidth=U||0,this._borderRadius=V||0,this._borderColor=I||"white",this._strokeWidth=g||0,this._strokeColor=A||"white",this._fontFace=M||"Arial",this._fontSize=N||90,this._fontWeight=(F==null?void 0:F.toString())||"normal",this._textAlign=T||"start",this._fontStyle=R||"normal",this._fontVariant=u||"normal",this._textShadowBlur=_||0,this._textShadowColor=Y,this._textShadowOffsetX=k||0,this._textShadowOffsetY=S||0,this._angle=G||0,this._textScale=C||1,this._underline=B||!1,this._canvas=document.createElement("canvas"),this._genCanvas()}get text(){return this._text}set text(o){this._text=o,this._genCanvas()}get textHeight(){return this._textHeight}set textHeight(o){this._textHeight=o,this._genCanvas()}get color(){return this._color}set color(o){this._color=o,this._genCanvas()}get backgroundColor(){return this._backgroundColor}set backgroundColor(o){this._backgroundColor=o,this._genCanvas()}get padding(){return this._padding}set padding(o){this._padding=o,this._genCanvas()}get borderWidth(){return this._borderWidth}set borderWidth(o){this._borderWidth=o,this._genCanvas()}get borderRadius(){return this._borderRadius}set borderRadius(o){this._borderRadius=o,this._genCanvas()}get borderColor(){return this._borderColor}set borderColor(o){this._borderColor=o,this._genCanvas()}get fontFace(){return this._fontFace}set fontFace(o){this._fontFace=o,this._genCanvas()}get fontSize(){return this._fontSize}set fontSize(o){this._fontSize=o,this._genCanvas()}get fontWeight(){return this._fontWeight}set fontWeight(o){this._fontWeight=o,this._genCanvas()}get strokeWidth(){return this._strokeWidth}set strokeWidth(o){this._strokeWidth=o,this._genCanvas()}get strokeColor(){return this._strokeColor}set strokeColor(o){this._strokeColor=o,this._genCanvas()}get textAlign(){return this._textAlign}set textAlign(o){this._textAlign=o,this._genCanvas()}get textShadowBlur(){return this._textShadowBlur}set textShadowBlur(o){this._textShadowBlur=o,this._genCanvas()}get textShadowColor(){return this._textShadowColor}set textShadowColor(o){this._textShadowColor=o,this._genCanvas()}get textShadowOffsetX(){return this._textShadowOffsetX}set textShadowOffsetX(o){this._textShadowOffsetX=o,this._genCanvas()}get textShadowOffsetY(){return this._textShadowOffsetY}set textShadowOffsetY(o){this._textShadowOffsetY=o,this._genCanvas()}get angle(){return this._angle}set angle(o){this._angle=o,this._genCanvas()}get textScale(){return this._textScale}set textScale(o){this._textScale=o,this._genCanvas()}get underline(){return this._underline}set underline(o){this._underline=o,this._genCanvas()}get fontStyle(){return this._fontStyle}set fontStyle(o){this._fontStyle=o,this._genCanvas()}get fontVariant(){return this._fontVariant}set fontVariant(o){this._fontVariant=o,this._genCanvas()}_genCanvas(){const o=this._canvas,a=o.getContext("2d"),v=Array.isArray(this.borderWidth)?this.borderWidth:[this.borderWidth,this.borderWidth],h=v.map(S=>S*this.fontSize*.1),b=(Ar
|
||
|
`),I=this.font;a.font=I;const g=Math.max(...V.map(S=>a.measureText(S).width)),A=4*this.strokeWidth+(this.underline?this.fontSize/15*4:this.fontSize/15),M=(this.fontSize+A)*V.length;if(o.width=g+2*h[0]+2*U[0],o.height=M+2*h[1]+2*U[1],this.borderWidth){if(a.strokeStyle=getSpriteTextColor(this.borderColor),h[0]){const S=h[0]/2;a.lineWidth=h[0],a.beginPath(),a.moveTo(S,b[0]),a.lineTo(S,o.height-b[3]),a.moveTo(o.width-S,b[1]),a.lineTo(o.width-S,o.height-b[2]),a.stroke()}if(h[1]){const S=h[1]/2;a.lineWidth=h[1],a.beginPath(),a.moveTo(Math.max(h[0],b[0]),S),a.lineTo(o.width-Math.max(h[0],b[1]),S),a.moveTo(Math.max(h[0],b[3]),o.height-S),a.lineTo(o.width-Math.max(h[0],b[2]),o.height-S),a.stroke()}if(this.borderRadius){const S=Math.max(...h),G=S/2;a.lineWidth=S,a.beginPath(),[!!b[0]&&[b[0],G,G,b[0]],!!b[1]&&[o.width-b[1],o.width-G,G,b[1]],!!b[2]&&[o.width-b[2],o.width-G,o.height-G,o.height-b[2]],!!b[3]&&[b[3],G,o.height-G,o.height-b[3]]].filter(C=>C).forEach(C=>{const[B,R,u,c]=C;a.moveTo(B,u),a.quadraticCurveTo(R,u,R,c)}),a.stroke()}}this.backgroundColor&&(a.fillStyle=getSpriteTextColor(this.backgroundColor),this.borderRadius?(a.beginPath(),a.moveTo(h[0],b[0]),[[h[0],b[0],o.width-b[1],h[1],h[1],h[1]],[o.width-h[0],o.width-h[0],o.width-h[0],h[1],b[1],o.height-b[2]],[o.width-h[0],o.width-b[2],b[3],o.height-h[1],o.height-h[1],o.height-h[1]],[h[0],h[0],h[0],o.height-h[1],o.height-b[3],b[0]]].forEach(([S,G,C,B,R,u])=>{a.quadraticCurveTo(S,B,G,R),a.lineTo(C,u)}),a.closePath(),a.fill()):a.fillRect(h[0],h[1],o.width-2*h[0],o.height-2*h[1])),a.translate(h[0],h[1]),a.translate(U[0],U[1]),a.font=I,a.fillStyle=getSpriteTextColor(this.color),a.textBaseline="bottom",a.shadowBlur=this.textShadowBlur,a.shadowColor=new THREE.Color(this.textShadowColor).getStyle(),a.shadowOffsetX=this.textShadowOffsetX,a.shadowOffsetY=this.textShadowOffsetY;const N=this.strokeWidth>0;N&&(a.lineWidth=this.strokeWidth*this.fontSize/10,a.strokeStyle=getSpriteTextColor(this.strokeColor));const F=this.textAlign==="center",T=this.textAlign==="start"||this.textAlign==="left";V.forEach((S,G)=>Si(this,null,function*(){let C=F?2:1;const B=a.measureText(S).width,R=T?0:(g-B)/C,u=(G+1)*(this.fontSize+A);N&&a.strokeText(S,R,u),a.fillText(S,R,u),this.underline&&a.fillRect(R,o.height-this.fontSize/25,B,this.fontSize/25)})),this.material.map&&this.material.map.dispose();const _=this.material.map=new THREE.Texture(o);_.minFilter=THREE.LinearFilter,_.needsUpdate=!0;const Y=this.textHeight*V.length+2*v[1]+2*D[1],k=Y*o.width/o.height;this.scale.set(k,Y,this.scale.z),this.material.rotation=this.angle,this.scale.applyMatrix4(new THREE.Matrix4().makeScale(this.textScale,this.textScale,1))}clone(){return new this.constructor(this.text,this.textHeight,this.color).copy(THREE.Sprite.prototype.clone.call(this))}copy(o){return THREE.Sprite.prototype.copy.call(this,o),this.color=o.color,this.backgroundColor=o.backgroundColor,this.padding=o.padding,this.borderWidth=o.borderWidth,this.borderColor=o.borderColor,this.fontFace=o.fontFace,this.fontSize=o.fontSize,this.fontWeight=o.fontWeight,this.strokeWidth=o.strokeWidth,this.strokeColor=o.strokeColor,this.textAlign=o.textAlign,this.textShadowBlur=o.textShadowBlur,this.textShadowColor=o.textShadowColor,this.textShadowOffsetX=o.textShadowOffsetX,this.textShadowOffsetY=o.textShadowOffsetY,this.angle=o.angle,this.textScale=o.textScale,this}get font(){return toCSSFont(this.fontFace,this.fontSize,this.fontStyle,this.fontVariant,this.fontWeight)}checkFontFace(){try{const{fontFace:o}=this;return document.fonts.check(o)}catch(o){}return!0}loadFontFace(){return Si(this,null,function*(){try{const{fontFace:o}=this;yield document.fonts.load(o)}catch(o){}})}dispose(){var o;(o=this.material.map)===null||o===void 0||o.dispose(),this.material.dispose(),this.geometry.dispose(),this.dispatchEvent({type:"dispose"})}}_SpriteText=w}return _SpriteText}MxDbEllipse.cmd="Mx_Ellipse",MxDbEllipse.draw=drawMxDbEllipse,addRegisterMxDbEntity(MxDbEllipse);const propertyDbKeys$2=["text","position","height","backgroundColor","padding","borderWidth","borderRadius","borderColor","fo
|
||
|
确定圆弧中点:`),w.go(()=>Si(this,null,function*(){a.center=w.value(),o.setDraw(v=>{o.drawLine(a.center,v)}),w.setMessage(`
|
||
|
确定圆弧开始点:`),a.startPoint=(yield w.go())||new THREE.Vector3,o.setDraw(v=>{a.endPoint=v,o.drawCustomEntity(a)}),w.setMessage(`
|
||
|
确定圆弧结束点:`),a.endPoint=(yield w.go())||new THREE.Vector3,o.setDraw(()=>{}),r.addMxEntity(a)}))}MxDbEllipseArc.cmd="Mx_MxDbEllipseArc",MxDbEllipseArc.draw=drawMxDbEllipseArc,addRegisterMxDbEntity(MxDbEllipseArc);class MxDbCircleArc extends MxDbCircleShape{constructor(){super(),this._propertyDbKeys=[...this._propertyDbKeys,"startPoint","endPoint"]}getTypeName(){return"MxDbCircleArc"}setStartPoint(r){return this.startPoint=r,this}setEndPoint(r){return this.endPoint=r,this}worldDraw(r){console.log(1111);let{startPoint:o,endPoint:a}=this;if(o&&(this.startAngle=this.computePointAngle(o)),a&&(this.endAngle=this.computePointAngle(a)),o&&a){const{points:v}=this.drawEllipseShape(r);this.startPoint=v[0]}}computePointAngle(r){return this.radius=this.center.distanceTo(r),THREE.MathUtils.degToRad(calculateArcAngle(r,this.center,this.radius).angle)}getGripPoints(){return[this.center,this.startPoint,this.endPoint]}moveGripPointsAt(r,o){return r===0?(this.center.add(o),this.startPoint.add(o),this.endPoint.add(o)):r===1?this.startPoint.add(o):r===2&&this.endPoint.add(o),!0}}MxDbCircleArc.cmd="Mx_MxDbCircleArc",MxDbCircleArc.draw=drawMxDbCircleArc,addRegisterMxDbEntity(MxDbCircleArc);class MxDbArcShape extends MxDbCircleArc{constructor(){super(),this.center=new THREE.Vector3,this.innerRadius=10,this.outerRadius=20,this._propertyDbKeys=[...this._propertyDbKeys,"center","innerRadius","outerRadius"]}getTypeName(){return"MxDbArcShape"}worldDraw(r){r.getType()===McGiWorldDrawType$1.kDynDragDraw?(r.drawCircle(this.center,this.innerRadius),r.drawCircle(this.center,this.outerRadius)):this.drawArcShape(r)}drawArcShape(r){const{center:o,startAngle:a,endAngle:v,clockwise:h}=this,{x:b,y:D}=o;this.isClosedToCenter=!1;const U=this.createEllipseCurve(b,D,this.innerRadius,this.innerRadius,a,v,h),V=this.createEllipseCurve(b,D,this.outerRadius,this.outerRadius,v,a,!h),I=this.createPaths([U,V]);let g=this.getShapePoints(I);this._draw(r,g),this._drawStoreLine(r,g)}getGripPoints(){return[this.center]}moveGripPointsAt(r,o){return r===0&&this.center.add(o),!0}}function drawMxDbArcShape(){const w=new MrxDbgUiPrPoint,r=MxFun.getCurrentDraw(),o=new McEdGetPointWorldDrawObject;let a=new MxDbArcShapeDraw;w.setMessage(`
|
||
|
确定圆弧中点:`),w.setUserDraw(o),w.go(()=>Si(this,null,function*(){w.setMessage(`
|
||
|
确定圆弧开始点:`),a.center=w.value(),o.setDraw(v=>{a.interRadiusPoint=v,o.drawCircle(a.center,v.distanceTo(a.center))}),a.interRadiusPoint=(yield w.go())||new THREE.Vector3,o.setDraw(v=>{a.outerRadiusPoint=v,o.drawCustomEntity(a)}),a.outerRadiusPoint=(yield w.go())||new THREE.Vector3,r.addMxEntity(a)}))}class MxDbArcShapeDraw extends MxDbArcShape{getTypeName(){return"MxDbArcShapeDraw"}constructor(){super(),this.outerRadiusPoint=new THREE.Vector3,this.interRadiusPoint=new THREE.Vector3,this._propertyDbKeys=[...this._propertyDbKeys,"interRadiusPoint","outerRadiusPoint"]}worldDraw(r){this.innerRadius=this.center.distanceTo(this.interRadiusPoint),this.outerRadius=this.center.distanceTo(this.outerRadiusPoint),this.startAngle=THREE.MathUtils.degToRad(calculateArcAngle(this.interRadiusPoint,this.center,this.innerRadius).angle),this.endAngle=THREE.MathUtils.degToRad(calculateArcAngle(this.outerRadiusPoint,this.center,this.outerRadius).angle),this.drawArcShape(r)}getGripPoints(){return[this.center,this.interRadiusPoint,this.outerRadiusPoint]}moveGripPointsAt(r,o){return r===0&&(this.center.add(o),this.interRadiusPoint.add(o),this.outerRadiusPoint.add(o)),r===1&&this.interRadiusPoint.add(o),r===2&&this.outerRadiusPoint.add(o),!0}}function drawMxDbRingShape(){const w=new MrxDbgUiPrPoint,r=MxFun.getCurrentDraw(),o=new McEdGetPointWorldDrawObject;w.setUserDraw(o);const a=new McEdGetPointWorldDrawObject,v=new MxDbRingShapeDraw;w.setUserDraw(a),w.setMessage(`
|
||
|
确定圆弧开始点:`),w.go(h=>Si(this,null,function*(){console.log(123),v.center=w.value(),a.setDraw(b=>{a.drawCircle(v.center,v.center.distanceTo(b))}),v.innerPoint=(yield w.go())||new THREE.Vector3,a.setDraw(b=>{v.outerPoint=b,a.drawCustomEntity(v)}),v.outerPoint=(yield w.go())||new THREE.Vector3,r.addMxEntity(v)}))}MxDbArcShapeDraw.isRegister=!1,MxDbArcShapeDraw.cmd="Mx_MxDbArcShape",MxDbArcShapeDraw.draw=drawMxDbArcShape,addRegisterMxDbEntity(MxDbArcShapeDraw);class MxDbRingShape extends MxDbArcShape{getTypeName(){return"MxDbRingShape"}worldDraw(r){const{center:o,startAngle:a,endAngle:v,clockwise:h}=this,{x:b,y:D}=o;this.isClosedToCenter=!1;const U=this.createEllipseCurve(b,D,this.innerRadius,this.innerRadius,a,v,h),V=this.createEllipseCurve(b,D,this.outerRadius,this.outerRadius,a,v,!h),I=this.createPaths([U,V]);let g=this.getShapePoints(I);const A=this.createPaths(U);let M=this.getShapePoints(A);const N=this.createPaths(V);let F=this.getShapePoints(N);this.isFill?(this._draw(r,g),this._drawStoreLine(r,M),this._drawStoreLine(r,F)):(this._draw(r,M),this._drawStoreLine(r,M),this._draw(r,F),this._drawStoreLine(r,F))}}MxDbRingShape.isRegister=!1,MxDbRingShape.cmd="Mx_MxDbRingShape",MxDbRingShape.draw=drawMxDbRingShape;class MxDbRingShapeDraw extends MxDbRingShape{constructor(){super(),this.innerPoint=new THREE.Vector3,this.outerPoint=new THREE.Vector3,this._propertyDbKeys=[...this._propertyDbKeys,"innerPoint","outerPoint"]}getGripPoints(){return[this.center,this.innerPoint,this.outerPoint]}moveGripPointsAt(r,o){return r===0&&(this.center.add(o),this.innerPoint.add(o),this.outerPoint.add(o)),r===1&&this.innerPoint.add(o),r===2&&this.outerPoint.add(o),!0}worldDraw(r){this.innerPoint&&(this.innerRadius=this.center.distanceTo(this.innerPoint)),this.outerPoint&&(this.outerRadius=this.center.distanceTo(this.outerPoint)),super.worldDraw(r)}}function drawMxDbStarShape(){const w=new MrxDbgUiPrPoint,r=MxFun.getCurrentDraw(),o=new McEdGetPointWorldDrawObject;w.setUserDraw(o);const a=new McEdGetPointWorldDrawObject,v=new MxDbStarShapeDraw;w.setUserDraw(a),w.setMessage(`
|
||
|
确定圆弧开始点:`),w.go(h=>Si(this,null,function*(){v.center=w.value(),a.setDraw(b=>{v.innerPoint=b,a.drawCircle(v.center,v.center.distanceTo(b))}),v.innerPoint=(yield w.go())||new THREE.Vector3,a.setDraw(b=>{v.outerPoint=b,a.drawCustomEntity(v)}),v.outerPoint=(yield w.go())||new THREE.Vector3,r.addMxEntity(v)}))}addRegisterMxDbEntity(MxDbRingShape);class MxDbStarShape extends MxDbShape{getTypeName(){return"MxDbStarShape"}constructor(){super(),this.center=new THREE.Vector3,this.numPoints=10,this.innerRadius=10,this.outerRadius=10,this._propertyDbKeys=[...this._propertyDbKeys,"center","numPoints","innerRadius","outerRadius"]}worldDraw(r){const{x:o,y:a}=this.center,v=new THREE.Path;v.moveTo(o,a-this.outerRadius);for(let D=1;D<2*this.numPoints;D++){const U=D%2==0?this.outerRadius:this.innerRadius,V=U*Math.sin(D*Math.PI/this.numPoints)+o,I=-1*U*Math.cos(D*Math.PI/this.numPoints)+a;v.lineTo(V,I)}v.closePath();const h=this.createPaths(v),b=this.getShapePoints(h);this._draw(r,b),this._drawStoreLine(r,b)}getGripPoints(){return[this.center]}moveGripPointsAt(r,o){return r===0&&this.center.add(o),!0}}MxDbStarShape.cmd="Mx_MxDbStarShape",MxDbStarShape.draw=drawMxDbStarShape;class MxDbStarShapeDraw extends MxDbStarShape{constructor(){super(),this.innerPoint=new THREE.Vector3,this.outerPoint=new THREE.Vector3,this._propertyDbKeys=[...this._propertyDbKeys,"innerPoint","outerPoint"]}getGripPoints(){return[this.center,this.innerPoint,this.outerPoint]}moveGripPointsAt(r,o){return r===0&&(this.center.add(o),this.innerPoint.add(o),this.outerPoint.add(o)),r===1&&this.innerPoint.add(o),r===2&&this.outerPoint.add(o),!0}worldDraw(r){this.innerPoint&&(this.innerRadius=this.center.distanceTo(this.innerPoint)),this.outerPoint&&(this.outerRadius=this.center.distanceTo(this.outerPoint)),super.worldDraw(r)}}addRegisterMxDbEntity(MxDbStarShape);class MxDbRegularPolygonShape extends MxDbShape{getTypeName(){return"MxDbRegularPolygonShape"}constructor(){super(),this.center=new THREE.Vector3,this.sidesNumber=6,this.radius=70,this._propertyDbKeys=[...this._propertyDbKeys,"center","sidesNumber","radius"]}worldDraw(r){this._drawPolygonShape(r)}_drawPolygonShape(r){const o=this._getPoints(),a=new THREE.Path;a.moveTo(o[0].x,o[0].y);for(let b=0;b<o.length;b++)a.lineTo(o[b].x,o[b].y);a.closePath();const v=this.createPaths(a),h=this.getShapePoints(v);this._draw(r,h),this._drawStoreLine(r,h)}_getPoints(){const{sidesNumber:r,radius:o}=this,{x:a,y:v}=this.center,h=[];for(let b=0;b<r;b++)h.push({x:o*Math.sin(2*b*Math.PI/r)+a,y:-1*o*Math.cos(2*b*Math.PI/r)+v});return h}getGripPoints(){return[this.center]}moveGripPointsAt(r,o){return r===0&&this.center.add(o),!0}}function getScreenPixel(w,r){let o=MxFun.screenCoordLong2World(r?w:w-w/3);return o=MxFun.worldCoordLong2Doc(o)}function drawMxDbArrow(){const w=new McEdGetPointWorldDrawObject,r=new MxDbArrow,o=MxFun.getCurrentDraw(),a=new MrxDbgUiPrPoint;a.setUserDraw(w),r.setLineWidth(10),a.go(()=>{r.innerOffset=getScreenPixel(10),r.outerOffset=getScreenPixel(22),r.topOffset=getScreenPixel(36),r.startPoint=a.value(),w.setDraw(v=>{r.endPoint=v,w.drawCustomEntity(r)}),a.go(v=>Si(this,null,function*(){r.endPoint=a.value(),o.addMxEntity(r)}))})}addRegisterMxDbEntity(MxDbRegularPolygonShape);class MxDbArrow extends MxDbShape{constructor(){super(),this.isSharpCorner=!1,this.innerOffset=10,this.outerOffset=22,this.topOffset=36,this.startPoint=new THREE.Vector3,this.endPoint=new THREE.Vector3,this._propertyDbKeys=[...this._propertyDbKeys,"outerOffset","topOffset","innerOffset","isSharpCorner","startPoint","endPoint"]}worldDraw(r){const o=this.getArrowVertex(this.startPoint,this.endPoint);o&&(this._draw(r,o),this._drawStoreLine(r,o))}getArrowVertex(r,o,a=this.isSharpCorner){let{innerOffset:v,topOffset:h,outerOffset:b}=this;const D=[];D[3]=o;const U=Math.sqrt((r.x-o.x)*(r.x-o.x)+(r.y-o.y)*(r.y-o.y));if(U===0)return;const V=-(o.x-r.x)/U,I=(o.y-r.y)/U,g=r.x+v,A=r.y+U-h,M=r.x+b,N=r.y+U-h,F=r.x-v,T=r.y+U-h,_=r.x-b,Y=r.y+U-h;return a?(D[0]=r,D[6]=D[0]):(D[0]=new THREE.Vector3(r.x-(F-r.x)*I,r.y-(F-r.x)*V),D[6]=new THREE.Vector3(r.x+(
|
||
|
指定第一个点:`),w.goWhile(o=>Si(this,null,function*(){if(o===MrxDbgUiPrBaseReturn$1.kOk)r.points.push(w.value()),w.setUserDraw((a,v)=>{const h=r.clone();h.points.push(a),v.drawCustomEntity(h),r.points.length===0?w.setMessage(`
|
||
|
指定第一个点:`):(w.setMessage(`
|
||
|
指定下一个点:`),w.setKeyWords("[闭合(C)/ 放弃(U)]"))});else if(o===MrxDbgUiPrBaseReturn$1.kKeyWord){if(w.isKeyWordPicked("C"))return r.closed=!0,{exit:!0};w.isKeyWordPicked("U")&&r.points.pop()}}),()=>{MxFun.getCurrentDraw().addMxEntity(r)})})}addRegisterMxDbEntity(MxDbLineShape);const propertyDbKeys=["points","closed","tension","curveType"];class MxDbSplineCurve extends MxDbEntity{constructor(){super(...arguments),this.points=[],this.closed=!1,this.tension=.5,this.curveType="centripetal"}worldDraw(r){const o=new THREE.CatmullRomCurve3(this.points,this.closed,"catmullrom",this.tension).getPoints(15*this.points.length),a=new THREE.Geometry().setFromPoints(o),v=new THREE.LineBasicMaterial({color:this.color}),h=new THREE.Line(a,v);r.drawEntity(h)}getGripPoints(){return this.points}moveGripPointsAt(r,o){return this.points[r].add(o),!0}create(){return new MxDbSplineCurve}dwgIn(r){return this.onDwgIn(r),this.dwgInHelp(r,propertyDbKeys),!0}dwgOut(r){return this.onDwgOut(r),this.dwgOutHelp(r,propertyDbKeys),r}getTypeName(){return"MxDbSplineCurve"}}MxDbSplineCurve.draw=drawMxDbSplineCurve,MxDbSplineCurve.cmd="Mx_Spline",addRegisterMxDbEntity(MxDbSplineCurve);class MrxDbgUiPrDist extends MrxDbgUiPrBase{constructor(){var r;super(new((r=store.state.MxFun)===null||r===void 0?void 0:r.getMxJigCmdManager().getMrxDbgUiPrDistClass()))}value(){return this.imp.value()}basePt(){return this.imp.basePt()}setBasePt(r){return this.imp.setBasePt(r)}setUseBasePt(r){return this.imp.setUseBasePt(r)}go(r){let o=this;return r?(o.imp.go(a=>{o.status=a,r(a)}),new Promise((a,v)=>{a(null)})):new Promise((a,v)=>{o.imp.go(h=>{o.status=h,a(h!=0?null:o.imp.value())})})}}class MrxDbgUiPrInt extends MrxDbgUiPrBase{constructor(){var r;super(new((r=store.state.MxFun)===null||r===void 0?void 0:r.getMxJigCmdManager().getMrxDbgUiPrIntClass()))}value(){return this.imp.value()}go(r){let o=this;return r?(o.imp.go(a=>{o.status=a,r(a)}),new Promise((a,v)=>{a(null)})):new Promise((a,v)=>{o.imp.go(h=>{o.status=h,a(h!=0?null:o.imp.value())})})}}class MrxDbgUiPrString extends MrxDbgUiPrBase{constructor(){var r;super(new((r=store.state.MxFun)===null||r===void 0?void 0:r.getMxJigCmdManager().getMrxDbgUiPrStringClass()))}value(){return this.imp.value()}go(r){let o=this;return r?(o.imp.go(a=>{o.status=a,r(a)}),new Promise((a,v)=>{a(null)})):new Promise((a,v)=>{o.imp.go(h=>{o.status=h,a(h!=0?null:o.imp.value())})})}}class MrxDbgUiPrKeyWord extends MrxDbgUiPrBase{constructor(){var r;super(new((r=store.state.MxFun)===null||r===void 0?void 0:r.getMxJigCmdManager().getMrxDbgUiPrKeyWordClass()))}go(r){let o=this;return r?(o.imp.go(a=>{o.status=a,r(a)}),new Promise((a,v)=>{a(null)})):new Promise((a,v)=>{o.imp.go(h=>{o.status=h,a(h!=0?null:o.keyWordPicked())})})}}class MrxDbgUiPrAngle extends MrxDbgUiPrBase{constructor(){var r;super(new((r=store.state.MxFun)===null||r===void 0?void 0:r.getMxJigCmdManager().getMrxDbgUiPrAngleClass()))}value(){return this.imp.value()}basePt(){return this.imp.basePt()}setBasePt(r){return this.imp.setBasePt(r)}setUseBasePt(r){return this.imp.setUseBasePt(r)}go(r){let o=this;return r?(o.imp.go(a=>{o.status=a,r(a)}),new Promise((a,v)=>{a(null)})):new Promise((a,v)=>{o.imp.go(h=>{o.status=h,a(h!=0?null:o.imp.value())})})}}var elementResizeEventPolyfill_umd_min=createCommonjsModule(function(w,r){w.exports=function(o){var a={};function v(h){if(a[h])return a[h].exports;var b=a[h]={i:h,l:!1,exports:{}};return o[h].call(b.exports,b,b.exports,v),b.l=!0,b.exports}return v.m=o,v.c=a,v.d=function(h,b,D){v.o(h,b)||Object.defineProperty(h,b,{enumerable:!0,get:D})},v.r=function(h){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(h,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(h,"__esModule",{value:!0})},v.t=function(h,b){if(1&b&&(h=v(h)),8&b||4&b&&typeof h=="object"&&h&&h.__esModule)return h;var D=Object.create(null);if(v.r(D),Object.defineProperty(D,"default",{enumerable:!0,value:h}),2&b&&typeof h!="string")for(var U in h)v.d(D,U,function(V){return h[V]}.bind(null,U));return D},v.n=function(h){var b=h&&h.__esModule?function()
|