mirror of
https://gitee.com/ice-gl/icegl-three-vue-tres.git
synced 2025-04-05 06:22:43 +08:00
2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
import{u as t,_ as o,a as n}from"./mergeTres.fIxCvWHm1725416517797.js";import{l as r}from"./utils.CfHZ88O81725416517797.js";import{$ as e}from"./@tresjs.5lh7VmqZ1725416517797.js";import{d as a,r as i,a2 as l,o as c,E as s,F as u,W as f,L as p,m as v,e as d,j as g,g as m,f as h,al as _,am as y,an as C}from"./@vue._6MD2XyK1725416517797.js";import{_ as x}from"./@fesjs.ILazvsHx1725416517797.js";import"./@amap.LUDXTi4z1725416517797.js";import"./pinia.QjdSMCYS1725416517797.js";import"./three.VTQVqxMx1725416517797.js";import"./three-mesh-bvh.wPvA9dFk1725416517797.js";import"./tweakpane.yHWGBmom1725416517797.js";import"./@vueuse.L-salR9N1725416517797.js";import"./vue-router.oJSnFzhA1725416517797.js";import"./lodash-es.kYt-_xTG1725416517797.js";import"./@qlin.yHhFDldE1725416517797.js";import"./@floating-ui.BPbuo5Gx1725416517797.js";import"./@juggle.7yjBMqoW1725416517797.js";const w=I;!function(t,o){const n=I,r=z();for(;;)try{if(442618===parseInt(n(280))/1+-parseInt(n(229))/2+parseInt(n(238))/3+-parseInt(n(254))/4+parseInt(n(242))/5+parseInt(n(277))/6*(parseInt(n(237))/7)+-parseInt(n(270))/8*(parseInt(n(227))/9))break;r.push(r.shift())}catch(e){r.push(r.shift())}}();const b=function(){let t=!0;return function(o,n){const r=t?function(){if(n){const t=n.apply(o,arguments);return n=null,t}}:function(){};return t=!1,r}}();function I(t,o){const n=z();return(I=function(t,o){return n[t-=226]})(t,o)}!function(){b(this,(function(){const t=I,o=new RegExp("function *\\( *\\)"),n=new RegExp(t(244),"i"),r=P("init");o[t(233)](r+t(232))&&n[t(233)](r+t(231))?P():r("0")}))()}();const S=function(){let t=!0;return function(o,n){const r=t?function(){if(n){const t=n[I(235)](o,arguments);return n=null,t}}:function(){};return t=!1,r}}();S(void 0,(function(){const t=I;let o;try{o=Function(t(251)+t(275)+");")()}catch(e){o=window}const n=o.console=o[t(247)]||{},r=[t(269),"warn",t(281),"error",t(246),t(248),t(252)];for(let a=0;a<r.length;a++){const o=S.constructor[t(245)][t(263)](S),e=r[a],i=n[e]||o;o[t(259)]=S[t(263)](S),o[t(226)]=i[t(226)][t(263)](i),n[e]=o}}))();const j=["position","faceUv",w(276)];function z(){const t=["string","1783436MJDGbN","length","u_near","mapHandle","action","__proto__","counter","TresMesh","faceUv","bind","gger","https://opensource-1314935952.cos.ap-nanjing.myqcloud.com/json/AMapGIS/latlngbuildings.geojson","u_zoom","lngLatToCoord","u_far","log","488aqARsg","customCoords","debu","cameraState","TresShaderMaterial",'{}.constructor("return this")( )',"normal","542244UfDTmv","exp","push","802343TMzjMn","info","TresBufferGeometry","getZoom","toString","155853cEOgoO","near","161538kICOux","geometry","input","chain","test","TresGroup","apply","uniforms","21crLntP","2581836jPjaYm","atan","constructor","buildings","457530ryRkqJ","value","\\+\\+ *(?:[a-zA-Z_$][0-9a-zA-Z_$]*)","prototype","exception","console","table","while (true) {}","uvArray","return (function() ","trace"];return(z=function(){return t})()}const R=a({__name:"buildingModels",setup(o){const n=t(),a=t=>{const o=I;for(let r=0;r<t[o(255)];r+=3){const e=[t[r],t[r+1]],a=n[o(257)][o(271)].lngLatToCoord(e);t[r]=a[0],t[r+1]=a[1],t[r+2]=.2*t[r+2]}},d=i([]),g={uniforms:{u_opacity:{value:1},u_time:{value:.45},u_color:{value:[.02,.15,.5,1]},u_zoom:{value:1},u_brightColor:{value:[1,1,1,1]},u_windowColor:{value:[.07,.07,.03,1]},u_near:{value:1},u_far:{value:1e3}},vertexShader:"precision highp float;\n#define ambientRatio .5\n#define diffuseRatio .4\n#define specularRatio .1\n\nattribute vec2 faceUv;\nuniform vec4 u_color;\nvarying vec2 v_texCoord;\nvarying vec4 v_color;\nvarying float v_lightWeight;\n\nvoid main(){\n\t\n\tmat4 matModelViewProjection=projectionMatrix*modelViewMatrix;\n\t\n\tv_texCoord=faceUv;\n\t\n\tif(normal==vec3(0.,0.,1.)){\n\t\tv_color=u_color;\n\t\tgl_Position=matModelViewProjection*vec4(position,1.);\n\t\treturn;\n\t}\n\t\n\tvec3 worldPos=vec3(vec4(position,1.)*modelMatrix);\n\tvec3 worldNormal=vec3(vec4(normal,1.)*modelMatrix);// N\n\t// //cal light weight 光亮度的权重\n\tvec3 viewDir=normalize(cameraPosition-worldPos);// V\n\t// 光照的方向, 前上方 Ild = k*I*(N·L)\n\tvec3 lightDir=normalize(vec3(0.,-10.,1.));// L\n\tvec3 halfDir=normalize(viewDir+lightDir);\n\t// //lambert\n\tfloat lambert=dot(worldNormal,lightDir);\n\t//specular //反射\n\tfloat specular=pow(max(0.,dot(worldNormal,halfDir)),32.);\n\t//sum to light weight (lambert + 环境光) Idiff = Iad + Ild = k*Ia + k*Il*(N·L)\n\tfloat lightWeight=ambientRatio+diffuseRatio*lambert+specularRatio*specular;\n\tv_texCoord=faceUv;\n\tv_lightWeight=lightWeight;\n\t\n\t// 根据光照方向,调整光线明暗\n\t\n\t// v_lightWeight = pow( 0.0 + 1.0 * abs(dot(worldNormal, worldPos)), 2.0);\n\t\n\tv_color=vec4(u_color.rgb*v_lightWeight,u_color.w);\n\t\n\tgl_Position=matModelViewProjection*vec4(position,1.);\n}",fragmentShader:"precision highp float;\nuniform float u_opacity;\nuniform vec4 u_baseColor;\nuniform vec4 u_color;\nuniform vec4 u_brightColor;\nuniform vec4 u_windowColor;\n\nuniform float u_zoom;\nuniform float u_time;\nuniform float u_near;\nuniform float u_far;\nvarying vec2 v_texCoord;\nvarying vec4 v_color;\nvarying float v_lightWeight;\n\nvec3 getWindowColor(float n,float hot,vec3 brightColor,vec3 darkColor){\n\tfloat s=step(hot,n);\n\tvec3 color=mix(brightColor,vec3(1.,1.,1.),n);\n\treturn mix(darkColor,color,s);\n}\n\nfloat random(vec2 st){\n\treturn fract(sin(dot(st.xy,vec2(12.9898,78.233)))*43758.5453123);\n}\n\nfloat LinearizeDepth()\n{\n\tfloat z=gl_FragCoord.z*2.-1.;\n\treturn(2.*u_near*u_far)/(u_far+u_near-z*(u_far-u_near));\n}\n\nvec3 fog(vec3 color,vec3 fogColor,float depth){\n\tfloat fogFactor=clamp(depth,0.,1.);\n\tvec3 output_color=mix(fogColor,color,fogFactor);\n\treturn output_color;\n}\n\nfloat sdRect(vec2 p,vec2 sz){\n\tvec2 d=abs(p)-sz;\n\tfloat outside=length(max(d,0.));\n\tfloat inside=min(max(d.x,d.y),0.);\n\treturn outside+inside;\n}\n\nvoid main(){\n\tif(v_color.w==0.){\n\t\tdiscard;\n\t\treturn;\n\t}\n\tvec3 baseColor=u_color.xyz;\n\tvec3 brightColor=u_brightColor.xyz;\n\tvec3 windowColor=u_windowColor.xyz;\n\tfloat targetColId=5.;\n\tfloat depth=1.-LinearizeDepth()/u_far*u_zoom;// 深度,调节明暗,远的颜色暗,近的颜色亮\n\tvec3 fogColor=vec3(23./255.,31./255.,51./255.);\n\t\n\tif(v_texCoord.x<0.){//顶部颜色\n\t\tvec3 foggedColor=fog(baseColor.xyz+vec3(.12*.9,.2*.9,.3*.9),fogColor,depth);\n\t\tgl_FragColor=vec4(foggedColor,v_color.w*u_opacity);\n\t}else{// 侧面颜色\n\t\t\n\t\tif(u_zoom<14.){\n\t\t\tgl_FragColor=v_color;\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(v_texCoord.x<.01||v_texCoord.x>.99||v_texCoord.y<.01){\n\t\t\tgl_FragColor=vec4(1.,.7,.25,.5);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tvec2 st=v_texCoord;\n\t\tvec2 UvScale=v_texCoord;\n\t\tvec2 tStep=vec2(.05,.125);\n\t\tvec2 tStart=vec2(tStep.x*.25,tStep.y*.25);\n\t\tvec2 tEnd=vec2(tStep.x*.75,tStep.y*.75);\n\t\t\n\t\tfloat u=mod(UvScale.x,tStep.x);\n\t\tfloat v=mod(UvScale.y,tStep.y);\n\t\tfloat ux=floor(UvScale.x/tStep.x);\n\t\tfloat uy=floor(UvScale.y/tStep.y);\n\t\tfloat n=random(vec2(ux,uy));\n\t\tfloat lightP=u_time;\n\t\tfloat head=1.-step(.005,st.y);\n\t\t/*step3*/\n\t\t// 将窗户颜色和墙面颜色区别开来\n\t\tfloat sU=step(tStart.x,u)-step(tEnd.x,u);\n\t\tfloat sV=step(tStart.y,v)-step(tEnd.y,v);\n\t\tvec2 windowSize=vec2(abs(tEnd.x-tStart.x),abs(tEnd.y-tStart.y));\n\t\tfloat dist=sdRect(vec2(u,v),windowSize);\n\t\tfloat s=sU*sV;\n\t\t\n\t\tfloat curColId=ux;// floor(UvScale.x / tStep.x);\n\t\tfloat sCol=step(targetColId-.2,curColId)-step(targetColId+.2,curColId);\n\t\t\n\t\tfloat mLightP=mod(lightP,2.);\n\t\tfloat sRow=step(mLightP-.2,st.y)-step(mLightP,st.y);\n\t\tif(ux==targetColId){\n\t\t\tn=0.;\n\t\t}\n\t\t// float hot = min(1.0, abs (sin(u_time/6.0) ) );\n\t\t// float hot = smoothstep(1.0,0.0,timeP);\n\t\t//hot = clamp(hot,0.2,0.8);\n\t\tvec3 color=mix(baseColor,getWindowColor(n,u_time,brightColor,windowColor),s);\n\t\t\n\t\tfloat sFinal=s*sCol*sRow;\n\t\tcolor+=mix(baseColor,brightColor,sFinal*n);\n\t\t\n\t\tif(head==1.){// 顶部亮线\n\t\t\tcolor=brightColor;\n\t\t}\n\t\tcolor=color*v_lightWeight;\n\t\t\n\t\tvec3 foggedColor=fog(color,fogColor,depth);\n\t\t\n\t\tgl_FragColor=vec4(foggedColor,1.);\n\t}\n\t\n}"};l((()=>{n.cameraState&&(async()=>{const t=I,o=await r(t(265),t(241));for(let n=0;n<o.length;n++){const r=o[n];a(r[t(230)]);const e=new Float32Array(r.geometry),i=new Float32Array(r[t(262)]),l=new Float32Array(r[t(230)][t(255)]);d[t(279)]({positionArray:e,uvArray:i,normalArray:l})}})()}));const{onLoop:m}=e();return m((()=>{const t=I;n[t(273)]&&(g[t(236)][t(266)].value=n[t(257)][t(283)](),g.uniforms[t(256)][t(243)]=n[t(273)][t(228)],g.uniforms[t(268)][t(243)]=n[t(273)].far)})),(t,o)=>{const n=I;return c(),s(n(234),null,[(c(!0),s(u,null,f(d,((t,o)=>{const r=n;return c(),s(r(261),{key:""+o},[p(r(282),{ref_for:!0,ref:"tbgRef",position:[t.positionArray,3],faceUv:[t[r(250)],2],normal:[t.normalArray,3]},null,8,j),p(r(274),v({ref_for:!0},g),null,16)])})),128))])}}});function P(t){function o(t){const n=I;if(typeof t===n(253))return function(t){}.constructor(n(249)).apply(n(260));1!==(""+t/t)[n(255)]||t%20==0?function(){return!0}[n(240)]("debu"+n(264)).call(n(258)):function(){return!1}[n(240)](n(272)+"gger").apply("stateObject"),o(++t)}try{if(t)return o;o(0)}catch(n){}}const A=T;!function(t,o){const n=T,r=F();for(;;)try{if(431389===-parseInt(n(297))/1+-parseInt(n(285))/2+parseInt(n(307))/3+parseInt(n(286))/4+parseInt(n(323))/5+-parseInt(n(314))/6*(-parseInt(n(309))/7)+-parseInt(n(293))/8)break;r.push(r.shift())}catch(e){r.push(r.shift())}}();const M=function(){let t=!0;return function(o,n){const r=t?function(){if(n){const t=n[T(287)](o,arguments);return n=null,t}}:function(){};return t=!1,r}}();!function(){M(this,(function(){const t=T,o=new RegExp(t(317)),n=new RegExp(t(295),"i"),r=E("init");o[t(310)](r+"chain")&&n.test(r+t(288))?E():r("0")}))()}();const k=function(){let t=!0;return function(o,n){const r=t?function(){if(n){const t=n[T(287)](o,arguments);return n=null,t}}:function(){};return t=!1,r}}();function F(){const t=["action","14049IHYBrd","test","log","toString","tresCanvas","534EAikIY","return (function() ","trace","function *\\( *\\)",'{}.constructor("return this")( )',"string","counter","exception","prototype","4162660vMmXty","bind","905996pwgfnD","1052128xVtboM","apply","input","while (true) {}","console","warn","stateObject","6269208RNSTGK","TresCanvas","\\+\\+ *(?:[a-zA-Z_$][0-9a-zA-Z_$]*)","data-v-40288e17","331669mNVyfd","debu","buildings","constructor","info","error","tcRef","gger","length","TresAmbientLight","2176560NkRODZ"];return(F=function(){return t})()}k(void 0,(function(){const t=T;let o;try{o=Function(t(315)+t(318)+");")()}catch(e){o=window}const n=o[t(290)]=o[t(290)]||{},r=[t(311),t(291),t(301),t(302),t(321),"table",t(316)];for(let a=0;a<r[t(305)];a++){const o=k[t(300)][t(322)][t(324)](k),e=r[a],i=n[e]||o;o.__proto__=k[t(324)](k),o[t(312)]=i.toString.bind(i),n[e]=o}}))();const U=t=>(y(A(296)),t=t(),C(),t),L=U((()=>p("TresPerspectiveCamera",{fov:60,near:.1,far:2e3},null,-1))),D=U((()=>p(A(306),{intensity:.5},null,-1)));function T(t,o){const n=F();return(T=function(t,o){return n[t-=285]})(t,o)}function E(t){function o(t){const n=T;if(typeof t===n(319))return function(t){}[n(300)](n(289)).apply(n(320));1!==(""+t/t)[n(305)]||t%20==0?function(){return!0}[n(300)](n(298)+n(304)).call(n(308)):function(){return!1}[n(300)]("debu"+n(304))[n(287)](n(292)),o(++t)}try{if(t)return o;o(0)}catch(n){}}const N=x(a({__name:A(299),setup(t){const r=[121.407867,31.157717],e=i({alpha:!0,antialias:!0,autoClear:!1,disableRender:!0});return(t,a)=>{const i=T,l=d(i(294));return c(),s(u,null,[g(o,{center:r,zoom:19,pitch:65.59312320916906,mapStyle:"darkblue"}),g(l,v({id:i(313),ref:i(303)},e),{default:m((()=>[L,D,g(n,{center:r}),(c(),h(_,null,{default:m((()=>[g(R)])),_:1}))])),_:1},16)],64)}}}),[["__scopeId","data-v-40288e17"]]);export{N as default};
|