u-space 0.0.18 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -13,4 +13,4 @@
13
13
  border-radius: 4px;
14
14
  pointer-events: auto;
15
15
  white-space: nowrap;
16
- `,t.labelStyle)for(const[h,d]of Object.entries(t.labelStyle))d!==void 0&&(r.style[h]=d);let a=null;const o=t.labelOffset||{x:0,y:2,z:0};if(t.showLeaderLine!==!1){const{lineColor:h=16777215}=t,d=new i.BufferGeometry().setFromPoints([new i.Vector3(0,0,0),new i.Vector3(o.x,o.y,o.z)]),p=new i.LineBasicMaterial({color:h});a=new i.Line(d,p),s.add(a)}if(this._createCSSObject){const h=this._createCSSObject(r);h.position.set(o.x,o.y,o.z),s.add(h)}this.scene.add(s);const c={id:e,options:t,group:s,labelElement:r,line:a};return this.annotations.set(e,c),c}addText(e,t,s={}){const n=`annotation_${this._idCounter++}`;return this.add(n,{position:t,content:e,...s})}updateContent(e,t){const s=this.annotations.get(e);s&&(s.labelElement.innerHTML=t,s.options.content=t)}updatePosition(e,t){const s=this.annotations.get(e);s&&(s.group.position.set(t.x,t.y,t.z),s.options.position=t)}show(e){const t=this.annotations.get(e);t&&(t.group.visible=!0)}hide(e){const t=this.annotations.get(e);t&&(t.group.visible=!1)}get(e){return this.annotations.get(e)}remove(e){const t=this.annotations.get(e);if(t){const s=[...t.group.children];for(const n of s)t.group.remove(n),n.geometry?.dispose(),n.material?.dispose();this.scene.remove(t.group),this.annotations.delete(e)}}removeAll(){const e=Array.from(this.annotations.keys());for(const t of e)this.remove(t)}showAll(){for(const e of this.annotations.values())e.group.visible=!0}hideAll(){for(const e of this.annotations.values())e.group.visible=!1}keys(){return Array.from(this.annotations.keys())}get size(){return this.annotations.size}dispose(){this.removeAll()}}const Te="0.0.18";window.__USPACE__={version:Te};Object.defineProperty(exports,"CSS2DObject",{enumerable:!0,get:()=>K.CSS2DObject});Object.defineProperty(exports,"CSS3DObject",{enumerable:!0,get:()=>D.CSS3DObject});Object.defineProperty(exports,"CSS3DSprite",{enumerable:!0,get:()=>D.CSS3DSprite});exports.AnnotationManager=_t;exports.BaseGroup=Q;exports.BaseMesh=R;exports.BaseSprite=we;exports.CSSRenderer=me;exports.CameraControls=de;exports.CircleMesh=ft;exports.ClippingTool=Mt;exports.ExtrudeMesh=J;exports.InteractionEvent=oe;exports.InteractionManager=ce;exports.LightManager=Fe;exports.MaterialEffects=U;exports.MeasureTool=Ct;exports.Model=k;exports.ModelLoaderManager=O;exports.ObjectManager=he;exports.ObjectUtils=B;exports.PlaneMesh=gt;exports.Poi=mt;exports.RenderPipeline=le;exports.RoomEnvironment=pe;exports.SBMLoader=ye;exports.SBMXLoader=ge;exports.SceneManager=Ge;exports.Selection=He;exports.ShapeMesh=Y;exports.SphereMesh=ve;exports.TSLEffects=yt;exports.TextureLoaderManager=pt;exports.Topology=ut;exports.TubeMesh=X;exports.Tween=Ee;exports.Viewer=Qe;exports.reinterpretType=wt;exports.tweenAnimation=xt;exports.version=Te;
16
+ `,t.labelStyle)for(const[h,d]of Object.entries(t.labelStyle))d!==void 0&&(r.style[h]=d);let a=null;const o=t.labelOffset||{x:0,y:2,z:0};if(t.showLeaderLine!==!1){const{lineColor:h=16777215}=t,d=new i.BufferGeometry().setFromPoints([new i.Vector3(0,0,0),new i.Vector3(o.x,o.y,o.z)]),p=new i.LineBasicMaterial({color:h});a=new i.Line(d,p),s.add(a)}if(this._createCSSObject){const h=this._createCSSObject(r);h.position.set(o.x,o.y,o.z),s.add(h)}this.scene.add(s);const c={id:e,options:t,group:s,labelElement:r,line:a};return this.annotations.set(e,c),c}addText(e,t,s={}){const n=`annotation_${this._idCounter++}`;return this.add(n,{position:t,content:e,...s})}updateContent(e,t){const s=this.annotations.get(e);s&&(s.labelElement.innerHTML=t,s.options.content=t)}updatePosition(e,t){const s=this.annotations.get(e);s&&(s.group.position.set(t.x,t.y,t.z),s.options.position=t)}show(e){const t=this.annotations.get(e);t&&(t.group.visible=!0)}hide(e){const t=this.annotations.get(e);t&&(t.group.visible=!1)}get(e){return this.annotations.get(e)}remove(e){const t=this.annotations.get(e);if(t){const s=[...t.group.children];for(const n of s)t.group.remove(n),n.geometry?.dispose(),n.material?.dispose();this.scene.remove(t.group),this.annotations.delete(e)}}removeAll(){const e=Array.from(this.annotations.keys());for(const t of e)this.remove(t)}showAll(){for(const e of this.annotations.values())e.group.visible=!0}hideAll(){for(const e of this.annotations.values())e.group.visible=!1}keys(){return Array.from(this.annotations.keys())}get size(){return this.annotations.size}dispose(){this.removeAll()}}const Te="0.0.21";window.__USPACE__={version:Te};Object.defineProperty(exports,"CSS2DObject",{enumerable:!0,get:()=>K.CSS2DObject});Object.defineProperty(exports,"CSS3DObject",{enumerable:!0,get:()=>D.CSS3DObject});Object.defineProperty(exports,"CSS3DSprite",{enumerable:!0,get:()=>D.CSS3DSprite});exports.AnnotationManager=_t;exports.BaseGroup=Q;exports.BaseMesh=R;exports.BaseSprite=we;exports.CSSRenderer=me;exports.CameraControls=de;exports.CircleMesh=ft;exports.ClippingTool=Mt;exports.ExtrudeMesh=J;exports.InteractionEvent=oe;exports.InteractionManager=ce;exports.LightManager=Fe;exports.MaterialEffects=U;exports.MeasureTool=Ct;exports.Model=k;exports.ModelLoaderManager=O;exports.ObjectManager=he;exports.ObjectUtils=B;exports.PlaneMesh=gt;exports.Poi=mt;exports.RenderPipeline=le;exports.RoomEnvironment=pe;exports.SBMLoader=ye;exports.SBMXLoader=ge;exports.SceneManager=Ge;exports.Selection=He;exports.ShapeMesh=Y;exports.SphereMesh=ve;exports.TSLEffects=yt;exports.TextureLoaderManager=pt;exports.Topology=ut;exports.TubeMesh=X;exports.Tween=Ee;exports.Viewer=Qe;exports.reinterpretType=wt;exports.tweenAnimation=xt;exports.version=Te;
package/dist/index.js CHANGED
@@ -2710,7 +2710,7 @@ class In {
2710
2710
  this.removeAll();
2711
2711
  }
2712
2712
  }
2713
- const Js = "0.0.18";
2713
+ const Js = "0.0.21";
2714
2714
  window.__USPACE__ = { version: Js };
2715
2715
  export {
2716
2716
  In as AnnotationManager,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("three/webgpu"),i=require("three/tsl"),h=require("@takram/three-geospatial/webgpu"),m=require("@takram/three-atmosphere"),o=require("@takram/three-atmosphere/webgpu"),p=require("@takram/three-geospatial"),x=i.mat3(i.vec3(1.6605,-.1246,-.0182),i.vec3(-.5876,1.1329,-.1006),i.vec3(-.0728,-.0083,1.1187)),y=i.mat3(i.vec3(.6274,.0691,.0164),i.vec3(.3293,.9195,.088),i.vec3(.0433,.0113,.8956)),C=h.FnVar(s=>{const e=s.pow2().toConst(),t=e.pow2().toConst();return i.add(t.mul(e).mul(15.5),t.mul(s).mul(-40.14),t.mul(31.96),e.mul(s).mul(-6.868),e.mul(.4298),s.mul(.1191),-.00232)}),M=i.mat3(i.vec3(.856627153315983,.137318972929847,.11189821299995),i.vec3(.0951212405381588,.761241990602591,.0767994186031903),i.vec3(.0482516061458583,.101439036467562,.811302368396859)),S=i.mat3(i.vec3(1.1271005818144368,-.1413297634984383,-.14132976349843826),i.vec3(-.11060664309660323,1.157823702216272,-.11060664309660294),i.vec3(-.016493938717834573,-.016493938717834257,1.2519364065950405)),v=-12.47393,T=4.026069,b=h.FnLayout({name:"agx",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]})(([s,e])=>{const t=s.toVar(),n=e;return t.mulAssign(n),t.assign(y.mul(t)),t.assign(M.mul(t)),t.assign(i.log2(t.max(1e-10))),t.assign(t.sub(v).div(i.float(T).sub(v))),t.assign(t.saturate()),t.assign(C(t)),t}),F=h.FnLayout({name:"agxEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]})(([s])=>{const e=s.toVar();return e.assign(S.mul(e)),e.assign(i.pow(e.max(0),i.float(2.2))),e.assign(x.mul(e)),e.assign(e.saturate()),e}),P=h.FnLayout({name:"agxPunchyToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]})(([s,e])=>{const t=s.toVar(),n=e;return t.assign(b(t,n.mul(1.5))),t.assign(i.cdl(t,i.vec3(1),i.vec3(0),i.vec3(1.35),i.float(1.2))),t.assign(F(t)),t}),w=100;function g(){const s=new Date;return s.setHours(8,0,0,0),s}const A={longitude:0,latitude:0,height:0,date:0,showSun:!0,showMoon:!0,showStars:!0,showGround:!1,useSkyEnvironment:!0,raymarchScattering:!0,lighting:!0,transmittance:!0,inscattering:!0,moonScattering:!0,lensFlare:!0,temporalAntialias:!0,dithering:!0,toneMapping:w,toneMappingExposure:3,castShadow:!0,shadowMapSize:4096,shadowCameraSize:180,shadowCameraNear:10,shadowCameraFar:6e3,shadowBias:-2e-5,shadowNormalBias:.001,shadowRadius:1.5,shadowDistance:3e3};class R{viewer;#a=!1;#e={...A,date:g()};#p=null;#i=null;#t=null;#r=null;#o=null;#s=null;#u=null;#d=null;#n=[];#c=null;#v;#m;#w=!1;#l=!1;#f=new d.Matrix4;#g=new d.Vector3;constructor(e){this.viewer=e}get enabled(){return this.#a}get context(){return this.#i}get light(){return this.#t}enable(e={}){return this.#a?this.update(e):(this.#e=this.#E(e),this.#p=new o.AtmosphereParameters,this.#i=new o.AtmosphereContext(this.#p),this.#i.camera=this.viewer.camera,this.#N(),this.#L(),this.#D(),this.#O(),this.#k(),this.#V(),this.#I(),this.#G(),this.updateDate(this.#e.date),this.#a=!0,this.viewer.render(),this)}update(e={}){return this.#e=this.#E(e),this.#i?(this.#N(),this.#C(),this.#M(),this.#x(),this.#F(),this.#S(),this.#B(),this.updateDate(this.#e.date),this.viewer.render(),this):this}setLocation(e,t,n=this.#e.height){return this.update({longitude:e,latitude:t,height:n})}setDate(e){return this.updateDate(e)}updateDate(e=g()){return this.#e.date=e,this.#P(),this.viewer.render(),this}disable(){return this.#a?(this.#_(),this.#U(),this.viewer.renderPipeline.removeOutputEffect(this.#h),this.#T(),this.#h.includesTemporalAntialias=!1,this.viewer.renderPipeline.needsUpdate=!0,this.#b(),this.#t&&(this.#t.target.removeFromParent(),this.#t.removeFromParent(),this.#t.dispose(),this.#t=null),this.viewer.scene.backgroundNode=this.#v,this.viewer.scene.environmentNode=this.#m,this.#c&&(this.viewer.renderer.contextNode=this.#c,this.#c=null),this.viewer.renderer.highPrecision=this.#w,this.#i?.dispose(),this.#i=null,this.#p=null,this.#r=null,this.#o=null,this.#a=!1,this.viewer.render(),this):this}dispose(){return this.disable()}#E(e){return{...this.#e,...e,date:e.date??(this.#a?this.#e.date:g())}}#N(){if(!this.#i)return;const t=new p.Geodetic(p.radians(this.#e.longitude),p.radians(this.#e.latitude),this.#e.height).toECEF(new d.Vector3);p.Ellipsoid.WGS84.getNorthUpEastFrame(t,this.#f),this.#i.camera=this.viewer.camera,this.#i.showGround=this.#e.showGround,this.#i.raymarchScattering=this.#e.raymarchScattering,this.#i.matrixWorldToECEF.value.copy(this.#f)}#L(){if(!this.#i)return;const e=this.viewer.renderer;this.#c=e.contextNode,this.#w=e.highPrecision,e.highPrecision=!0,e.contextNode=i.context({...e.contextNode.value,getAtmosphere:()=>this.#i})}#D(){const e=this.viewer.renderer;e.library.addLight(o.AtmosphereLightNode,o.AtmosphereLight),e.shadowMap.enabled=!0,this.#t=new o.AtmosphereLight,this.#x(),this.viewer.scene.add(this.#t.target),this.#y(),this.viewer.scene.add(this.#t)}#x(){if(!this.#t)return;const{castShadow:e,shadowMapSize:t,shadowCameraSize:n,shadowCameraNear:r,shadowCameraFar:c,shadowBias:a,shadowNormalBias:f,shadowRadius:E,shadowDistance:N}=this.#e,l=n/2,u=this.#t.shadow.camera;this.#t.castShadow=e,this.#t.distance=N,this.#t.shadow.mapSize.setScalar(t),this.#t.shadow.bias=a,this.#t.shadow.normalBias=f,this.#t.shadow.radius=E,u.left=-l,u.right=l,u.top=l,u.bottom=-l,u.near=r,u.far=c,u.updateProjectionMatrix(),this.#t.shadow.needsUpdate=!0}#y(){this.#t&&(this.viewer.controls.getTarget(this.#t.target.position),this.#t.target.updateMatrixWorld())}#O(){this.#v=this.viewer.scene.backgroundNode,this.#m=this.viewer.scene.environmentNode,this.#r=o.skyBackground(),this.#C(),this.viewer.scene.backgroundNode=this.#r,this.#M()}#C(){this.#r&&(this.#r.showSun=this.#e.showSun,this.#r.showMoon=this.#e.showMoon,this.#r.showStars=this.#e.showStars,this.#r.moonScattering=this.#e.moonScattering)}#M(){if(!this.#e.useSkyEnvironment){this.#o&&this.viewer.scene.environmentNode===this.#o&&(this.viewer.scene.environmentNode=this.#m),this.#o=null;return}this.#o??=o.skyEnvironment(),this.viewer.scene.environmentNode=this.#o}#k(){this.viewer.renderer.library.addToneMapping(P,w)}#V(){this.#h.includesOutputTransform=!0,this.#S(),this.viewer.renderPipeline.addOutputEffect(this.#h)}#S(){if(this.#h.includesTemporalAntialias=this.#e.temporalAntialias,this.#e.temporalAntialias){this.#l||(this.viewer.renderPipeline.addMRTChannel("atmosphereVelocity",h.highpVelocity),this.#l=!0);return}this.#T()}#T(){this.#l&&(this.viewer.renderPipeline.removeMRTChannel("atmosphereVelocity"),this.#l=!1)}#B(){this.#a&&(this.viewer.renderPipeline.needsUpdateOutputNode=!0)}#b(){for(const e of this.#n)e.dispose();this.#n=[],this.#s=null,this.#u=null,this.#d=null}#F(){this.#s&&(this.#s.lighting=this.#e.lighting,this.#s.transmittance=this.#e.transmittance,this.#s.inscattering=this.#e.inscattering,this.#s.moonScattering=this.#e.moonScattering)}#h=(e,t)=>{const n=e.getTextureNode("depth");this.#b(),this.#s=o.aerialPerspective(t,n),this.#n.push(this.#s),this.#F();let r=this.#s;if(this.#e.lensFlare&&(this.#u=h.lensFlare(r),this.#n.push(this.#u),r=this.#u),this.#e.toneMapping!==!1&&this.#e.toneMapping!==d.NoToneMapping){const a=i.toneMapping(this.#e.toneMapping,this.#e.toneMappingExposure,r);this.#n.push(a),r=a}if(this.#e.temporalAntialias){const a=e.getTextureNode("atmosphereVelocity");this.#d=h.temporalAntialias(r,n,a,this.viewer.camera),this.#n.push(this.#d),r=this.#d}if(this.#e.dithering){const a=i.add(r,h.dithering);this.#n.push(a),r=a}const c=i.renderOutput(r,d.NoToneMapping);return this.#n.push(c),c};#P(){if(!this.#i)return;this.viewer.camera.updateMatrixWorld(),this.#g.setFromMatrixPosition(this.viewer.camera.matrixWorld).applyMatrix4(this.#i.matrixWorldToECEF.value);const e=this.#i.matrixECIToECEF.value;m.getECIToECEFRotationMatrix(this.#e.date,e),m.getSunDirectionECI(this.#e.date,this.#i.sunDirectionECEF.value,this.#g).applyMatrix4(e),m.getMoonDirectionECI(this.#e.date,this.#i.moonDirectionECEF.value,this.#g).applyMatrix4(e)}#I(){this.viewer.addEventListener("cameraChange",this.#A)}#_(){this.viewer.removeEventListener("cameraChange",this.#A)}#G(){this.viewer.addEventListener("beforeRender",this.#R)}#U(){this.viewer.removeEventListener("beforeRender",this.#R)}#A=({camera:e})=>{this.#i&&(this.#i.camera=e,this.updateDate(this.#e.date))};#R=()=>{this.#y(),this.#P()}}exports.Atmosphere=R;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("three/webgpu"),i=require("three/tsl"),o=require("@takram/three-geospatial/webgpu"),m=require("@takram/three-atmosphere"),d=require("@takram/three-atmosphere/webgpu"),p=require("@takram/three-geospatial"),x=i.mat3(i.vec3(1.6605,-.1246,-.0182),i.vec3(-.5876,1.1329,-.1006),i.vec3(-.0728,-.0083,1.1187)),y=i.mat3(i.vec3(.6274,.0691,.0164),i.vec3(.3293,.9195,.088),i.vec3(.0433,.0113,.8956)),C=o.FnVar(s=>{const e=s.pow2().toConst(),t=e.pow2().toConst();return i.add(t.mul(e).mul(15.5),t.mul(s).mul(-40.14),t.mul(31.96),e.mul(s).mul(-6.868),e.mul(.4298),s.mul(.1191),-.00232)}),M=i.mat3(i.vec3(.856627153315983,.137318972929847,.11189821299995),i.vec3(.0951212405381588,.761241990602591,.0767994186031903),i.vec3(.0482516061458583,.101439036467562,.811302368396859)),S=i.mat3(i.vec3(1.1271005818144368,-.1413297634984383,-.14132976349843826),i.vec3(-.11060664309660323,1.157823702216272,-.11060664309660294),i.vec3(-.016493938717834573,-.016493938717834257,1.2519364065950405)),v=-12.47393,T=4.026069,b=o.FnLayout({name:"agx",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]})(([s,e])=>{const t=s.toVar(),n=e;return t.mulAssign(n),t.assign(y.mul(t)),t.assign(M.mul(t)),t.assign(i.log2(t.max(1e-10))),t.assign(t.sub(v).div(i.float(T).sub(v))),t.assign(t.saturate()),t.assign(C(t)),t}),F=o.FnLayout({name:"agxEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]})(([s])=>{const e=s.toVar();return e.assign(S.mul(e)),e.assign(i.pow(e.max(0),i.float(2.2))),e.assign(x.mul(e)),e.assign(e.saturate()),e}),A=o.FnLayout({name:"agxPunchyToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]})(([s,e])=>{const t=s.toVar(),n=e;return t.assign(b(t,n.mul(1.5))),t.assign(i.cdl(t,i.vec3(1),i.vec3(0),i.vec3(1.35),i.float(1.2))),t.assign(F(t)),t}),w=100;function g(){const s=new Date;return s.setHours(8,0,0,0),s}const P={longitude:0,latitude:0,height:0,date:0,showSun:!0,showMoon:!0,showStars:!0,showGround:!1,useSkyEnvironment:!0,raymarchScattering:!0,lighting:!0,transmittance:!0,inscattering:!0,moonScattering:!0,lensFlare:!0,temporalAntialias:!0,dithering:!0,toneMapping:w,toneMappingExposure:3,castShadow:!0,shadowMapSize:4096,shadowCameraSize:180,shadowCameraNear:10,shadowCameraFar:6e3,shadowBias:-2e-5,shadowNormalBias:.001,shadowRadius:1.5,shadowDistance:3e3};class R{viewer;#r=!1;#e={...P,date:g()};#l=null;#i=null;#t=null;#s=null;#n=null;#h=null;#d=null;#a=[];#u=null;#g;#p;#v=!1;#c=!1;#w=new u.Matrix4;#m=new u.Vector3;constructor(e){this.viewer=e}get enabled(){return this.#r}get context(){return this.#i}get light(){return this.#t}enable(e={}){return this.#r?this.update(e):(this.#e=this.#f(e),this.#l=new d.AtmosphereParameters,this.#i=new d.AtmosphereContext(this.#l),this.#i.camera=this.viewer.camera,this.#E(),this.#R(),this.#L(),this.#D(),this.#k(),this.#O(),this.#V(),this.#I(),this.updateDate(this.#e.date),this.#M(),this.#r=!0,this.viewer.render(),this)}update(e={}){return this.#e=this.#f(e),this.#i?(this.#E(),this.#y(),this.#C(),this.#N(),this.#S(),this.#U(),this.updateDate(this.#e.date),this.#M(),this.viewer.render(),this):this}setLocation(e,t,n=this.#e.height){return this.update({longitude:e,latitude:t,height:n})}setDate(e){return this.updateDate(e)}updateDate(e=g()){return this.#e.date=e,this.#F(),this.viewer.render(),this}disable(){return this.#r?(this.#B(),this.#_(),this.viewer.renderPipeline.removeOutputEffect(this.#o),this.#T(),this.#o.includesTemporalAntialias=!1,this.viewer.renderPipeline.needsUpdate=!0,this.#b(),this.#t&&(this.#t.target.removeFromParent(),this.#t.removeFromParent(),this.#t.dispose(),this.#t=null),this.viewer.scene.backgroundNode=this.#g,this.viewer.scene.environmentNode=this.#p,this.#u&&(this.viewer.renderer.contextNode=this.#u,this.#u=null),this.viewer.renderer.highPrecision=this.#v,this.#i?.dispose(),this.#i=null,this.#l=null,this.#s=null,this.#n=null,this.#r=!1,this.viewer.render(),this):this}dispose(){return this.disable()}#f(e){return{...this.#e,...e,date:e.date??(this.#r?this.#e.date:g())}}#E(){if(!this.#i)return;const t=new p.Geodetic(p.radians(this.#e.longitude),p.radians(this.#e.latitude),this.#e.height).toECEF(new u.Vector3);p.Ellipsoid.WGS84.getNorthUpEastFrame(t,this.#w),this.#i.camera=this.viewer.camera,this.#i.showGround=this.#e.showGround,this.#i.raymarchScattering=this.#e.raymarchScattering,this.#i.matrixWorldToECEF.value.copy(this.#w)}#R(){if(!this.#i)return;const e=this.viewer.renderer;this.#u=e.contextNode,this.#v=e.highPrecision,e.highPrecision=!0,e.contextNode=i.context({...e.contextNode.value,getAtmosphere:()=>this.#i})}#L(){const e=this.viewer.renderer;e.library.addLight(d.AtmosphereLightNode,d.AtmosphereLight),e.shadowMap.enabled=!0,this.#t=new d.AtmosphereLight,this.#N(),this.viewer.scene.add(this.#t.target),this.#x(),this.viewer.scene.add(this.#t)}#N(){if(!this.#t)return;const{castShadow:e,shadowMapSize:t,shadowCameraSize:n,shadowCameraNear:r,shadowCameraFar:c,shadowBias:a,shadowNormalBias:f,shadowRadius:E,shadowDistance:N}=this.#e,l=n/2,h=this.#t.shadow.camera;this.#t.castShadow=e,this.#t.distance=N,this.#t.shadow.mapSize.setScalar(t),this.#t.shadow.bias=a,this.#t.shadow.normalBias=f,this.#t.shadow.radius=E,h.left=-l,h.right=l,h.top=l,h.bottom=-l,h.near=r,h.far=c,h.updateProjectionMatrix(),this.#t.shadow.needsUpdate=!0}#x(){this.#t&&(this.viewer.controls.getTarget(this.#t.target.position),this.#t.target.updateMatrixWorld())}#D(){this.#g=this.viewer.scene.backgroundNode,this.#p=this.viewer.scene.environmentNode,this.#s=d.skyBackground(),this.#C(),this.#y(),this.viewer.scene.backgroundNode=this.#s}#y(){this.#s&&(this.#s.showSun=this.#e.showSun,this.#s.showMoon=this.#e.showMoon,this.#s.showStars=this.#e.showStars,this.#s.moonScattering=this.#e.moonScattering)}#C(){if(!this.#e.useSkyEnvironment){this.#n&&this.viewer.scene.environmentNode===this.#n&&(this.viewer.scene.environmentNode=this.#p),this.#n=null;return}this.#n??=d.skyEnvironment(),this.viewer.scene.environmentNode=this.#n}#M(){for(const e of[this.#s,this.#n])e&&(e.needsUpdate=!0);this.viewer.renderPipeline.needsUpdateOutputNode=!0}#k(){this.viewer.renderer.library.addToneMapping(A,w)}#O(){this.#o.includesOutputTransform=!0,this.#S(),this.viewer.renderPipeline.addOutputEffect(this.#o)}#S(){if(this.#o.includesTemporalAntialias=this.#e.temporalAntialias,this.#e.temporalAntialias){this.#c||(this.viewer.renderPipeline.addMRTChannel("atmosphereVelocity",o.highpVelocity),this.#c=!0);return}this.#T()}#T(){this.#c&&(this.viewer.renderPipeline.removeMRTChannel("atmosphereVelocity"),this.#c=!1)}#U(){this.#r&&(this.viewer.renderPipeline.needsUpdateOutputNode=!0)}#b(){for(const e of this.#a)e.dispose();this.#a=[],this.#h=null,this.#d=null}#o=(e,t)=>{const n=e.getTextureNode("depth");this.#b();let r=t;if(this.#e.lensFlare&&(this.#h=o.lensFlare(r),this.#a.push(this.#h),r=this.#h),this.#e.toneMapping!==!1&&this.#e.toneMapping!==u.NoToneMapping){const a=i.toneMapping(this.#e.toneMapping,this.#e.toneMappingExposure,r);this.#a.push(a),r=a}if(this.#e.temporalAntialias){const a=e.getTextureNode("atmosphereVelocity");this.#d=o.temporalAntialias(r,n,a,this.viewer.camera),this.#a.push(this.#d),r=this.#d}if(this.#e.dithering){const a=i.add(r,o.dithering);this.#a.push(a),r=a}const c=i.renderOutput(r,u.NoToneMapping);return this.#a.push(c),c};#F(){if(!this.#i)return;this.viewer.camera.updateMatrixWorld(),this.#m.setFromMatrixPosition(this.viewer.camera.matrixWorld).applyMatrix4(this.#i.matrixWorldToECEF.value);const e=this.#i.matrixECIToECEF.value;m.getECIToECEFRotationMatrix(this.#e.date,e),m.getSunDirectionECI(this.#e.date,this.#i.sunDirectionECEF.value,this.#m).applyMatrix4(e),m.getMoonDirectionECI(this.#e.date,this.#i.moonDirectionECEF.value,this.#m).applyMatrix4(e)}#V(){this.viewer.addEventListener("cameraChange",this.#A)}#B(){this.viewer.removeEventListener("cameraChange",this.#A)}#I(){this.viewer.addEventListener("beforeRender",this.#P)}#_(){this.viewer.removeEventListener("beforeRender",this.#P)}#A=({camera:e})=>{this.#i&&(this.#i.camera=e,this.updateDate(this.#e.date))};#P=()=>{this.#x(),this.#F()}}exports.Atmosphere=R;
@@ -1,18 +1,18 @@
1
1
  import { Matrix4 as M, Vector3 as m, NoToneMapping as g } from "three/webgpu";
2
- import { mat3 as u, vec3 as i, add as E, log2 as S, float as c, pow as T, cdl as F, context as P, toneMapping as b, renderOutput as A } from "three/tsl";
3
- import { FnVar as R, FnLayout as p, highpVelocity as D, lensFlare as L, temporalAntialias as O, dithering as k } from "@takram/three-geospatial/webgpu";
4
- import { getECIToECEFRotationMatrix as B, getSunDirectionECI as I, getMoonDirectionECI as V } from "@takram/three-atmosphere";
5
- import { AtmosphereParameters as _, AtmosphereContext as U, AtmosphereLightNode as G, AtmosphereLight as v, skyBackground as z, skyEnvironment as W, aerialPerspective as H } from "@takram/three-atmosphere/webgpu";
6
- import { Geodetic as j, radians as w, Ellipsoid as q } from "@takram/three-geospatial";
7
- const X = u(
2
+ import { mat3 as u, vec3 as i, add as E, log2 as S, float as c, pow as T, cdl as F, context as b, toneMapping as P, renderOutput as A } from "three/tsl";
3
+ import { FnVar as R, FnLayout as p, highpVelocity as D, lensFlare as L, temporalAntialias as k, dithering as O } from "@takram/three-geospatial/webgpu";
4
+ import { getECIToECEFRotationMatrix as U, getSunDirectionECI as B, getMoonDirectionECI as I } from "@takram/three-atmosphere";
5
+ import { AtmosphereParameters as V, AtmosphereContext as _, AtmosphereLightNode as G, AtmosphereLight as v, skyBackground as z, skyEnvironment as W } from "@takram/three-atmosphere/webgpu";
6
+ import { Geodetic as H, radians as w, Ellipsoid as j } from "@takram/three-geospatial";
7
+ const q = u(
8
8
  i(1.6605, -0.1246, -0.0182),
9
9
  i(-0.5876, 1.1329, -0.1006),
10
10
  i(-0.0728, -83e-4, 1.1187)
11
- ), J = u(
11
+ ), X = u(
12
12
  i(0.6274, 0.0691, 0.0164),
13
13
  i(0.3293, 0.9195, 0.088),
14
14
  i(0.0433, 0.0113, 0.8956)
15
- ), K = R((s) => {
15
+ ), J = R((s) => {
16
16
  const e = s.pow2().toConst(), t = e.pow2().toConst();
17
17
  return E(
18
18
  t.mul(e).mul(15.5),
@@ -23,15 +23,15 @@ const X = u(
23
23
  s.mul(0.1191),
24
24
  -232e-5
25
25
  );
26
- }), Q = u(
26
+ }), K = u(
27
27
  i(0.856627153315983, 0.137318972929847, 0.11189821299995),
28
28
  i(0.0951212405381588, 0.761241990602591, 0.0767994186031903),
29
29
  i(0.0482516061458583, 0.101439036467562, 0.811302368396859)
30
- ), Y = u(
30
+ ), Q = u(
31
31
  i(1.1271005818144368, -0.1413297634984383, -0.14132976349843826),
32
32
  i(-0.11060664309660323, 1.157823702216272, -0.11060664309660294),
33
33
  i(-0.016493938717834573, -0.016493938717834257, 1.2519364065950405)
34
- ), f = -12.47393, Z = 4.026069, $ = p({
34
+ ), f = -12.47393, Y = 4.026069, Z = p({
35
35
  name: "agx",
36
36
  type: "vec3",
37
37
  inputs: [
@@ -40,15 +40,15 @@ const X = u(
40
40
  ]
41
41
  })(([s, e]) => {
42
42
  const t = s.toVar(), n = e;
43
- return t.mulAssign(n), t.assign(J.mul(t)), t.assign(Q.mul(t)), t.assign(S(t.max(1e-10))), t.assign(t.sub(f).div(c(Z).sub(f))), t.assign(t.saturate()), t.assign(K(t)), t;
44
- }), ee = p({
43
+ return t.mulAssign(n), t.assign(X.mul(t)), t.assign(K.mul(t)), t.assign(S(t.max(1e-10))), t.assign(t.sub(f).div(c(Y).sub(f))), t.assign(t.saturate()), t.assign(J(t)), t;
44
+ }), $ = p({
45
45
  name: "agxEOTF",
46
46
  type: "vec3",
47
47
  inputs: [{ name: "color", type: "vec3" }]
48
48
  })(([s]) => {
49
49
  const e = s.toVar();
50
- return e.assign(Y.mul(e)), e.assign(T(e.max(0), c(2.2))), e.assign(X.mul(e)), e.assign(e.saturate()), e;
51
- }), te = p({
50
+ return e.assign(Q.mul(e)), e.assign(T(e.max(0), c(2.2))), e.assign(q.mul(e)), e.assign(e.saturate()), e;
51
+ }), ee = p({
52
52
  name: "agxPunchyToneMapping",
53
53
  type: "vec3",
54
54
  inputs: [
@@ -57,13 +57,13 @@ const X = u(
57
57
  ]
58
58
  })(([s, e]) => {
59
59
  const t = s.toVar(), n = e;
60
- return t.assign($(t, n.mul(1.5))), t.assign(F(t, i(1), i(0), i(1.35), c(1.2))), t.assign(ee(t)), t;
61
- }), x = 100;
60
+ return t.assign(Z(t, n.mul(1.5))), t.assign(F(t, i(1), i(0), i(1.35), c(1.2))), t.assign($(t)), t;
61
+ }), N = 100;
62
62
  function l() {
63
63
  const s = /* @__PURE__ */ new Date();
64
64
  return s.setHours(8, 0, 0, 0), s;
65
65
  }
66
- const ie = {
66
+ const te = {
67
67
  longitude: 0,
68
68
  latitude: 0,
69
69
  height: 0,
@@ -81,7 +81,7 @@ const ie = {
81
81
  lensFlare: !0,
82
82
  temporalAntialias: !0,
83
83
  dithering: !0,
84
- toneMapping: x,
84
+ toneMapping: N,
85
85
  toneMappingExposure: 3,
86
86
  castShadow: !0,
87
87
  shadowMapSize: 4096,
@@ -93,34 +93,33 @@ const ie = {
93
93
  shadowRadius: 1.5,
94
94
  shadowDistance: 3e3
95
95
  };
96
- class de {
96
+ class he {
97
97
  viewer;
98
- #a = !1;
98
+ #r = !1;
99
99
  #e = {
100
- ...ie,
100
+ ...te,
101
101
  date: l()
102
102
  };
103
- #p = null;
103
+ #c = null;
104
104
  #i = null;
105
105
  #t = null;
106
- #r = null;
107
- #o = null;
108
106
  #s = null;
107
+ #n = null;
108
+ #h = null;
109
109
  #d = null;
110
+ #a = [];
110
111
  #u = null;
111
- #n = [];
112
- #l = null;
113
- #v;
114
- #m;
115
- #w = !1;
116
- #c = !1;
117
- #f = new M();
118
- #g = new m();
112
+ #g;
113
+ #p;
114
+ #v = !1;
115
+ #l = !1;
116
+ #w = new M();
117
+ #m = new m();
119
118
  constructor(e) {
120
119
  this.viewer = e;
121
120
  }
122
121
  get enabled() {
123
- return this.#a;
122
+ return this.#r;
124
123
  }
125
124
  get context() {
126
125
  return this.#i;
@@ -129,10 +128,10 @@ class de {
129
128
  return this.#t;
130
129
  }
131
130
  enable(e = {}) {
132
- return this.#a ? this.update(e) : (this.#e = this.#E(e), this.#p = new _(), this.#i = new U(this.#p), this.#i.camera = this.viewer.camera, this.#x(), this.#D(), this.#L(), this.#O(), this.#k(), this.#B(), this.#V(), this.#U(), this.updateDate(this.#e.date), this.#a = !0, this.viewer.render(), this);
131
+ return this.#r ? this.update(e) : (this.#e = this.#f(e), this.#c = new V(), this.#i = new _(this.#c), this.#i.camera = this.viewer.camera, this.#E(), this.#R(), this.#D(), this.#L(), this.#k(), this.#O(), this.#B(), this.#V(), this.updateDate(this.#e.date), this.#M(), this.#r = !0, this.viewer.render(), this);
133
132
  }
134
133
  update(e = {}) {
135
- return this.#e = this.#E(e), this.#i ? (this.#x(), this.#y(), this.#M(), this.#N(), this.#P(), this.#S(), this.#I(), this.updateDate(this.#e.date), this.viewer.render(), this) : this;
134
+ return this.#e = this.#f(e), this.#i ? (this.#E(), this.#C(), this.#y(), this.#N(), this.#S(), this.#U(), this.updateDate(this.#e.date), this.#M(), this.viewer.render(), this) : this;
136
135
  }
137
136
  setLocation(e, t, n = this.#e.height) {
138
137
  return this.update({ longitude: e, latitude: t, height: n });
@@ -144,40 +143,40 @@ class de {
144
143
  return this.#e.date = e, this.#b(), this.viewer.render(), this;
145
144
  }
146
145
  disable() {
147
- return this.#a ? (this.#_(), this.#G(), this.viewer.renderPipeline.removeOutputEffect(this.#h), this.#T(), this.#h.includesTemporalAntialias = !1, this.viewer.renderPipeline.needsUpdate = !0, this.#F(), this.#t && (this.#t.target.removeFromParent(), this.#t.removeFromParent(), this.#t.dispose(), this.#t = null), this.viewer.scene.backgroundNode = this.#v, this.viewer.scene.environmentNode = this.#m, this.#l && (this.viewer.renderer.contextNode = this.#l, this.#l = null), this.viewer.renderer.highPrecision = this.#w, this.#i?.dispose(), this.#i = null, this.#p = null, this.#r = null, this.#o = null, this.#a = !1, this.viewer.render(), this) : this;
146
+ return this.#r ? (this.#I(), this.#_(), this.viewer.renderPipeline.removeOutputEffect(this.#o), this.#T(), this.#o.includesTemporalAntialias = !1, this.viewer.renderPipeline.needsUpdate = !0, this.#F(), this.#t && (this.#t.target.removeFromParent(), this.#t.removeFromParent(), this.#t.dispose(), this.#t = null), this.viewer.scene.backgroundNode = this.#g, this.viewer.scene.environmentNode = this.#p, this.#u && (this.viewer.renderer.contextNode = this.#u, this.#u = null), this.viewer.renderer.highPrecision = this.#v, this.#i?.dispose(), this.#i = null, this.#c = null, this.#s = null, this.#n = null, this.#r = !1, this.viewer.render(), this) : this;
148
147
  }
149
148
  dispose() {
150
149
  return this.disable();
151
150
  }
152
- #E(e) {
151
+ #f(e) {
153
152
  return {
154
153
  ...this.#e,
155
154
  ...e,
156
- date: e.date ?? (this.#a ? this.#e.date : l())
155
+ date: e.date ?? (this.#r ? this.#e.date : l())
157
156
  };
158
157
  }
159
- #x() {
158
+ #E() {
160
159
  if (!this.#i)
161
160
  return;
162
- const t = new j(
161
+ const t = new H(
163
162
  w(this.#e.longitude),
164
163
  w(this.#e.latitude),
165
164
  this.#e.height
166
165
  ).toECEF(new m());
167
- q.WGS84.getNorthUpEastFrame(t, this.#f), this.#i.camera = this.viewer.camera, this.#i.showGround = this.#e.showGround, this.#i.raymarchScattering = this.#e.raymarchScattering, this.#i.matrixWorldToECEF.value.copy(this.#f);
166
+ j.WGS84.getNorthUpEastFrame(t, this.#w), this.#i.camera = this.viewer.camera, this.#i.showGround = this.#e.showGround, this.#i.raymarchScattering = this.#e.raymarchScattering, this.#i.matrixWorldToECEF.value.copy(this.#w);
168
167
  }
169
- #D() {
168
+ #R() {
170
169
  if (!this.#i)
171
170
  return;
172
171
  const e = this.viewer.renderer;
173
- this.#l = e.contextNode, this.#w = e.highPrecision, e.highPrecision = !0, e.contextNode = P({
172
+ this.#u = e.contextNode, this.#v = e.highPrecision, e.highPrecision = !0, e.contextNode = b({
174
173
  ...e.contextNode.value,
175
174
  getAtmosphere: () => this.#i
176
175
  });
177
176
  }
178
- #L() {
177
+ #D() {
179
178
  const e = this.viewer.renderer;
180
- e.library.addLight(G, v), e.shadowMap.enabled = !0, this.#t = new v(), this.#N(), this.viewer.scene.add(this.#t.target), this.#C(), this.viewer.scene.add(this.#t);
179
+ e.library.addLight(G, v), e.shadowMap.enabled = !0, this.#t = new v(), this.#N(), this.viewer.scene.add(this.#t.target), this.#x(), this.viewer.scene.add(this.#t);
181
180
  }
182
181
  #N() {
183
182
  if (!this.#t)
@@ -189,123 +188,113 @@ class de {
189
188
  shadowCameraNear: r,
190
189
  shadowCameraFar: h,
191
190
  shadowBias: a,
192
- shadowNormalBias: N,
191
+ shadowNormalBias: x,
193
192
  shadowRadius: C,
194
193
  shadowDistance: y
195
194
  } = this.#e, d = n / 2, o = this.#t.shadow.camera;
196
- this.#t.castShadow = e, this.#t.distance = y, this.#t.shadow.mapSize.setScalar(t), this.#t.shadow.bias = a, this.#t.shadow.normalBias = N, this.#t.shadow.radius = C, o.left = -d, o.right = d, o.top = d, o.bottom = -d, o.near = r, o.far = h, o.updateProjectionMatrix(), this.#t.shadow.needsUpdate = !0;
195
+ this.#t.castShadow = e, this.#t.distance = y, this.#t.shadow.mapSize.setScalar(t), this.#t.shadow.bias = a, this.#t.shadow.normalBias = x, this.#t.shadow.radius = C, o.left = -d, o.right = d, o.top = d, o.bottom = -d, o.near = r, o.far = h, o.updateProjectionMatrix(), this.#t.shadow.needsUpdate = !0;
197
196
  }
198
- #C() {
197
+ #x() {
199
198
  this.#t && (this.viewer.controls.getTarget(this.#t.target.position), this.#t.target.updateMatrixWorld());
200
199
  }
201
- #O() {
202
- this.#v = this.viewer.scene.backgroundNode, this.#m = this.viewer.scene.environmentNode, this.#r = z(), this.#y(), this.viewer.scene.backgroundNode = this.#r, this.#M();
200
+ #L() {
201
+ this.#g = this.viewer.scene.backgroundNode, this.#p = this.viewer.scene.environmentNode, this.#s = z(), this.#y(), this.#C(), this.viewer.scene.backgroundNode = this.#s;
203
202
  }
204
- #y() {
205
- this.#r && (this.#r.showSun = this.#e.showSun, this.#r.showMoon = this.#e.showMoon, this.#r.showStars = this.#e.showStars, this.#r.moonScattering = this.#e.moonScattering);
203
+ #C() {
204
+ this.#s && (this.#s.showSun = this.#e.showSun, this.#s.showMoon = this.#e.showMoon, this.#s.showStars = this.#e.showStars, this.#s.moonScattering = this.#e.moonScattering);
206
205
  }
207
- #M() {
206
+ #y() {
208
207
  if (!this.#e.useSkyEnvironment) {
209
- this.#o && this.viewer.scene.environmentNode === this.#o && (this.viewer.scene.environmentNode = this.#m), this.#o = null;
208
+ this.#n && this.viewer.scene.environmentNode === this.#n && (this.viewer.scene.environmentNode = this.#p), this.#n = null;
210
209
  return;
211
210
  }
212
- this.#o ??= W(), this.viewer.scene.environmentNode = this.#o;
211
+ this.#n ??= W(), this.viewer.scene.environmentNode = this.#n;
212
+ }
213
+ #M() {
214
+ for (const e of [this.#s, this.#n])
215
+ e && (e.needsUpdate = !0);
216
+ this.viewer.renderPipeline.needsUpdateOutputNode = !0;
213
217
  }
214
218
  #k() {
215
- this.viewer.renderer.library.addToneMapping(te, x);
219
+ this.viewer.renderer.library.addToneMapping(ee, N);
216
220
  }
217
- #B() {
218
- this.#h.includesOutputTransform = !0, this.#S(), this.viewer.renderPipeline.addOutputEffect(this.#h);
221
+ #O() {
222
+ this.#o.includesOutputTransform = !0, this.#S(), this.viewer.renderPipeline.addOutputEffect(this.#o);
219
223
  }
220
224
  #S() {
221
- if (this.#h.includesTemporalAntialias = this.#e.temporalAntialias, this.#e.temporalAntialias) {
222
- this.#c || (this.viewer.renderPipeline.addMRTChannel(
223
- "atmosphereVelocity",
224
- D
225
- ), this.#c = !0);
225
+ if (this.#o.includesTemporalAntialias = this.#e.temporalAntialias, this.#e.temporalAntialias) {
226
+ this.#l || (this.viewer.renderPipeline.addMRTChannel("atmosphereVelocity", D), this.#l = !0);
226
227
  return;
227
228
  }
228
229
  this.#T();
229
230
  }
230
231
  #T() {
231
- this.#c && (this.viewer.renderPipeline.removeMRTChannel("atmosphereVelocity"), this.#c = !1);
232
+ this.#l && (this.viewer.renderPipeline.removeMRTChannel("atmosphereVelocity"), this.#l = !1);
232
233
  }
233
- #I() {
234
- this.#a && (this.viewer.renderPipeline.needsUpdateOutputNode = !0);
234
+ #U() {
235
+ this.#r && (this.viewer.renderPipeline.needsUpdateOutputNode = !0);
235
236
  }
236
237
  #F() {
237
- for (const e of this.#n)
238
+ for (const e of this.#a)
238
239
  e.dispose();
239
- this.#n = [], this.#s = null, this.#d = null, this.#u = null;
240
- }
241
- #P() {
242
- this.#s && (this.#s.lighting = this.#e.lighting, this.#s.transmittance = this.#e.transmittance, this.#s.inscattering = this.#e.inscattering, this.#s.moonScattering = this.#e.moonScattering);
240
+ this.#a = [], this.#h = null, this.#d = null;
243
241
  }
244
- #h = (e, t) => {
242
+ #o = (e, t) => {
245
243
  const n = e.getTextureNode("depth");
246
- this.#F(), this.#s = H(
247
- t,
248
- n
249
- ), this.#n.push(this.#s), this.#P();
250
- let r = this.#s;
251
- if (this.#e.lensFlare && (this.#d = L(r), this.#n.push(this.#d), r = this.#d), this.#e.toneMapping !== !1 && this.#e.toneMapping !== g) {
252
- const a = b(
253
- this.#e.toneMapping,
254
- this.#e.toneMappingExposure,
255
- r
256
- );
257
- this.#n.push(a), r = a;
244
+ this.#F();
245
+ let r = t;
246
+ if (this.#e.lensFlare && (this.#h = L(r), this.#a.push(this.#h), r = this.#h), this.#e.toneMapping !== !1 && this.#e.toneMapping !== g) {
247
+ const a = P(this.#e.toneMapping, this.#e.toneMappingExposure, r);
248
+ this.#a.push(a), r = a;
258
249
  }
259
250
  if (this.#e.temporalAntialias) {
260
251
  const a = e.getTextureNode("atmosphereVelocity");
261
- this.#u = O(
252
+ this.#d = k(
262
253
  r,
263
254
  n,
264
255
  a,
265
256
  this.viewer.camera
266
- ), this.#n.push(this.#u), r = this.#u;
257
+ ), this.#a.push(this.#d), r = this.#d;
267
258
  }
268
259
  if (this.#e.dithering) {
269
- const a = E(r, k);
270
- this.#n.push(a), r = a;
260
+ const a = E(r, O);
261
+ this.#a.push(a), r = a;
271
262
  }
272
263
  const h = A(r, g);
273
- return this.#n.push(h), h;
264
+ return this.#a.push(h), h;
274
265
  };
275
266
  #b() {
276
267
  if (!this.#i)
277
268
  return;
278
- this.viewer.camera.updateMatrixWorld(), this.#g.setFromMatrixPosition(this.viewer.camera.matrixWorld).applyMatrix4(this.#i.matrixWorldToECEF.value);
269
+ this.viewer.camera.updateMatrixWorld(), this.#m.setFromMatrixPosition(this.viewer.camera.matrixWorld).applyMatrix4(this.#i.matrixWorldToECEF.value);
279
270
  const e = this.#i.matrixECIToECEF.value;
280
- B(this.#e.date, e), I(
281
- this.#e.date,
282
- this.#i.sunDirectionECEF.value,
283
- this.#g
284
- ).applyMatrix4(e), V(
271
+ U(this.#e.date, e), B(this.#e.date, this.#i.sunDirectionECEF.value, this.#m).applyMatrix4(
272
+ e
273
+ ), I(
285
274
  this.#e.date,
286
275
  this.#i.moonDirectionECEF.value,
287
- this.#g
276
+ this.#m
288
277
  ).applyMatrix4(e);
289
278
  }
290
- #V() {
291
- this.viewer.addEventListener("cameraChange", this.#A);
279
+ #B() {
280
+ this.viewer.addEventListener("cameraChange", this.#P);
292
281
  }
293
- #_() {
294
- this.viewer.removeEventListener("cameraChange", this.#A);
282
+ #I() {
283
+ this.viewer.removeEventListener("cameraChange", this.#P);
295
284
  }
296
- #U() {
297
- this.viewer.addEventListener("beforeRender", this.#R);
285
+ #V() {
286
+ this.viewer.addEventListener("beforeRender", this.#A);
298
287
  }
299
- #G() {
300
- this.viewer.removeEventListener("beforeRender", this.#R);
288
+ #_() {
289
+ this.viewer.removeEventListener("beforeRender", this.#A);
301
290
  }
302
- #A = ({ camera: e }) => {
291
+ #P = ({ camera: e }) => {
303
292
  this.#i && (this.#i.camera = e, this.updateDate(this.#e.date));
304
293
  };
305
- #R = () => {
306
- this.#C(), this.#b();
294
+ #A = () => {
295
+ this.#x(), this.#b();
307
296
  };
308
297
  }
309
298
  export {
310
- de as Atmosphere
299
+ he as Atmosphere
311
300
  };
@@ -1,14 +1,25 @@
1
+ import { Vector3 } from 'three/webgpu';
1
2
  import type { Viewer } from 'u-space';
2
3
  import { Globe } from './Globe';
4
+ type LonLatHeight = {
5
+ lon: number;
6
+ lat: number;
7
+ height: number;
8
+ };
3
9
  declare class ArcgisTilesRenderer extends Globe {
4
10
  viewer: Viewer;
5
11
  loedTilesSets: Set<() => void>;
12
+ gisOrigin: LonLatHeight | null;
13
+ private _worldToEllipsoidMatrix;
14
+ private _ellipsoidPosition;
6
15
  constructor(viewer: Viewer);
7
16
  render: () => void;
8
17
  beforeRenderHandler: () => void;
9
18
  enable(): this;
10
19
  disable(): this;
11
20
  invalidate(lon: number, lat: number, alt: number): () => void;
21
+ lonLatHeightToPosition(lon: number, lat: number, height?: number, target?: Vector3): Vector3;
22
+ positionToLonLatHeight(position: Vector3, target?: LonLatHeight): LonLatHeight;
12
23
  dispose(): void;
13
24
  }
14
25
  export { ArcgisTilesRenderer };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("three/webgpu"),v=require("3d-tiles-renderer"),l=require("3d-tiles-renderer/plugins"),f=require("3d-tiles-renderer/src/three/plugins/fade/FadeMaterialManager.js"),M=require("3d-tiles-renderer/src/three/plugins/fade/wrapFadeMaterial.js"),s=require("three/tsl"),o=require("@takram/three-geospatial"),c=require("@takram/three-geospatial/webgpu"),u=Symbol("FADE_PARAMS"),h=c.FnLayout({name:"bayerDither2x2",type:"float",inputs:[{name:"v",type:"vec2"}]})(([t])=>(o.reinterpretType(t),t.y.mul(3).add(t.x.mul(2)).mod(4))),T=c.FnLayout({name:"bayerDither4x4",type:"float",inputs:[{name:"v",type:"vec2"}]})(([t])=>{o.reinterpretType(t);const e=t.mod(2),i=t.mod(4).mul(.5).floor();return h(e).mul(4).add(h(i))}),y=s.uniform(0).onObjectUpdate(({material:t})=>t!=null?t?.params?.fadeIn.value??0:0),R=s.uniform(0).onObjectUpdate(({material:t})=>t!=null?t?.params?.fadeOut.value??0:0),w=s.Fn(()=>{const i=T(s.screenCoordinate.xy.mod(4).floor()).add(.5).div(16);return s.If(i.greaterThanEqual(y),()=>{s.Discard()}),s.If(i.lessThan(R),()=>{s.Discard()}),s.output})();function E(t){if(o.reinterpretType(t),t[u]!=null)return t[u];const e={fadeIn:{value:0},fadeOut:{value:0},fadeTexture:{value:null}};let i=0;return t.params=e,t.defines={get FEATURE_FADE(){return i},set FEATURE_FADE(r){r!==i&&(i=r,t.outputNode=r===1?w:null)}},e}class F extends f.FadeMaterialManager{prepareMaterial(e){const i=this._fadeParams;if(i.has(e))return;let r;e instanceof n.NodeMaterial?r=E(e):r=M.wrapFadeMaterial(e,e.onBeforeCompile),i.set(e,r)}}class _ extends l.TilesFadePlugin{constructor(...e){super(...e),this._fadeMaterialManager=new F}}function p(t,e){const i=t.material;if(Array.isArray(i))throw new Error("Multiple materials are not supported yet.");const r=new e;"map"in i&&i.map!=null&&"map"in r&&(o.reinterpretType(i.map),o.reinterpretType(r.map),i.map.flipY=!1,r.map=i.map.clone()),t.material=r,i.dispose()}class b{tiles;overrideMaterial;constructor(e=n.MeshBasicNodeMaterial){this.overrideMaterial=e}init(e){this.tiles=e,e.group.traverse(i=>{i instanceof n.Mesh&&p(i,this.overrideMaterial)}),e.addEventListener("load-model",this.handleLoadModel),e.addEventListener("dispose-model",this.handleDisposeModel)}handleLoadModel=({scene:e})=>{e.traverse(i=>{i instanceof n.Mesh&&p(i,this.overrideMaterial)})};handleDisposeModel=({scene:e})=>{e.traverse(i=>{i instanceof n.Mesh&&i.material.dispose()})};dispose(){this.tiles?.removeEventListener("load-model",this.handleLoadModel),this.tiles?.removeEventListener("dispose-model",this.handleDisposeModel)}}class g{tiles;tileCompressionPlugin;updateOnChangePlugin;reorientationPlugin;xyzTilesPlugin;tilesFadePlugin;tileMaterialReplacementPlugin;constructor(){this.tiles=this._initTilesRenderer(),this.tileCompressionPlugin=this._initTileCompressionPlugin(),this.updateOnChangePlugin=this._initUpdateOnChangePlugin(),this.reorientationPlugin=this._initReorientationPlugin(),this.xyzTilesPlugin=this._initXYZTilesPlugin(),this.tilesFadePlugin=this._initTilesFadePlugin(),this.tileMaterialReplacementPlugin=this._initTileMaterialReplacementPlugin()}_initTilesRenderer(){const e=new v.TilesRenderer;return e.maxDepth=20,e.errorTarget=1,e}_initTileCompressionPlugin(){const e=new l.TileCompressionPlugin;return this.tiles.registerPlugin(e),e}_initUpdateOnChangePlugin(){const e=new l.UpdateOnChangePlugin;return this.tiles.registerPlugin(e),e}_initReorientationPlugin(){const e=new l.ReorientationPlugin;return this.tiles.registerPlugin(e),e}_initXYZTilesPlugin(){const e=new l.XYZTilesPlugin({center:!0,shape:"ellipsoid",url:"https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"});return this.tiles.registerPlugin(e),e}_initTilesFadePlugin(){const e=new _;return this.tiles.registerPlugin(e),e}_initTileMaterialReplacementPlugin(){const e=new b(n.MeshBasicNodeMaterial);return this.tiles.registerPlugin(e),e}}class L extends g{viewer;loedTilesSets=new Set;constructor(e){super(),this.viewer=e,this.tiles.addEventListener("needs-render",this.render),this.tiles.addEventListener("needs-update",this.render)}render=()=>{this.viewer.render()};beforeRenderHandler=()=>{this.viewer.camera.updateMatrixWorld(),this.tiles.setCamera(this.viewer.camera),this.tiles.setResolutionFromRenderer(this.viewer.camera,this.viewer.renderer),this.tiles.update()};enable(){return this.viewer.scene.add(this.tiles.group),this.viewer.addEventListener("beforeRender",this.beforeRenderHandler),this}disable(){return this.viewer.scene.remove(this.tiles.group),this.viewer.removeEventListener("beforeRender",this.beforeRenderHandler),this}invalidate(e,i,r){const a=()=>{const m=n.MathUtils.degToRad(i),P=n.MathUtils.degToRad(e);this.reorientationPlugin.transformLatLonHeightToOrigin(m,P,r),this.render(),d()},d=()=>{this.tiles.removeEventListener("load-root-tileset",a),this.loedTilesSets.delete(a)};return this.tiles.addEventListener("load-root-tileset",a),this.loedTilesSets.add(a),this.tiles.root&&a(),d}dispose(){this.disable(),this.loedTilesSets.forEach(e=>this.tiles.removeEventListener("load-root-tileset",e)),this.loedTilesSets.clear(),this.tiles.removeEventListener("needs-render",this.render),this.tiles.removeEventListener("needs-update",this.render),this.tiles.dispose()}}exports.ArcgisTilesRenderer=L;exports.Globe=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("three/webgpu"),P=require("3d-tiles-renderer"),a=require("3d-tiles-renderer/plugins"),T=require("3d-tiles-renderer/src/three/plugins/fade/FadeMaterialManager.js"),v=require("3d-tiles-renderer/src/three/plugins/fade/wrapFadeMaterial.js"),n=require("three/tsl"),o=require("@takram/three-geospatial"),c=require("@takram/three-geospatial/webgpu"),h=Symbol("FADE_PARAMS"),p=c.FnLayout({name:"bayerDither2x2",type:"float",inputs:[{name:"v",type:"vec2"}]})(([t])=>(o.reinterpretType(t),t.y.mul(3).add(t.x.mul(2)).mod(4))),f=c.FnLayout({name:"bayerDither4x4",type:"float",inputs:[{name:"v",type:"vec2"}]})(([t])=>{o.reinterpretType(t);const e=t.mod(2),i=t.mod(4).mul(.5).floor();return p(e).mul(4).add(p(i))}),y=n.uniform(0).onObjectUpdate(({material:t})=>t!=null?t?.params?.fadeIn.value??0:0),R=n.uniform(0).onObjectUpdate(({material:t})=>t!=null?t?.params?.fadeOut.value??0:0),w=n.Fn(()=>{const i=f(n.screenCoordinate.xy.mod(4).floor()).add(.5).div(16);return n.If(i.greaterThanEqual(y),()=>{n.Discard()}),n.If(i.lessThan(R),()=>{n.Discard()}),n.output})();function _(t){if(o.reinterpretType(t),t[h]!=null)return t[h];const e={fadeIn:{value:0},fadeOut:{value:0},fadeTexture:{value:null}};let i=0;return t.params=e,t.defines={get FEATURE_FADE(){return i},set FEATURE_FADE(s){s!==i&&(i=s,t.outputNode=s===1?w:null)}},e}class E extends T.FadeMaterialManager{prepareMaterial(e){const i=this._fadeParams;if(i.has(e))return;let s;e instanceof r.NodeMaterial?s=_(e):s=v.wrapFadeMaterial(e,e.onBeforeCompile),i.set(e,s)}}class x extends a.TilesFadePlugin{constructor(...e){super(...e),this._fadeMaterialManager=new E}}function g(t,e){const i=t.material;if(Array.isArray(i))throw new Error("Multiple materials are not supported yet.");const s=new e;"map"in i&&i.map!=null&&"map"in s&&(o.reinterpretType(i.map),o.reinterpretType(s.map),i.map.flipY=!1,s.map=i.map.clone()),t.material=s,i.dispose()}class F{tiles;overrideMaterial;constructor(e=r.MeshBasicNodeMaterial){this.overrideMaterial=e}init(e){this.tiles=e,e.group.traverse(i=>{i instanceof r.Mesh&&g(i,this.overrideMaterial)}),e.addEventListener("load-model",this.handleLoadModel),e.addEventListener("dispose-model",this.handleDisposeModel)}handleLoadModel=({scene:e})=>{e.traverse(i=>{i instanceof r.Mesh&&g(i,this.overrideMaterial)})};handleDisposeModel=({scene:e})=>{e.traverse(i=>{i instanceof r.Mesh&&i.material.dispose()})};dispose(){this.tiles?.removeEventListener("load-model",this.handleLoadModel),this.tiles?.removeEventListener("dispose-model",this.handleDisposeModel)}}class m{tiles;tileCompressionPlugin;updateOnChangePlugin;reorientationPlugin;xyzTilesPlugin;tilesFadePlugin;tileMaterialReplacementPlugin;constructor(){this.tiles=this._initTilesRenderer(),this.tileCompressionPlugin=this._initTileCompressionPlugin(),this.updateOnChangePlugin=this._initUpdateOnChangePlugin(),this.reorientationPlugin=this._initReorientationPlugin(),this.xyzTilesPlugin=this._initXYZTilesPlugin(),this.tilesFadePlugin=this._initTilesFadePlugin(),this.tileMaterialReplacementPlugin=this._initTileMaterialReplacementPlugin()}_initTilesRenderer(){const e=new P.TilesRenderer;return e.maxDepth=20,e.errorTarget=1,e}_initTileCompressionPlugin(){const e=new a.TileCompressionPlugin;return this.tiles.registerPlugin(e),e}_initUpdateOnChangePlugin(){const e=new a.UpdateOnChangePlugin;return this.tiles.registerPlugin(e),e}_initReorientationPlugin(){const e=new a.ReorientationPlugin;return this.tiles.registerPlugin(e),e}_initXYZTilesPlugin(){const e=new a.XYZTilesPlugin({center:!0,shape:"ellipsoid",url:"https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"});return this.tiles.registerPlugin(e),e}_initTilesFadePlugin(){const e=new x;return this.tiles.registerPlugin(e),e}_initTileMaterialReplacementPlugin(){const e=new F(r.MeshBasicNodeMaterial);return this.tiles.registerPlugin(e),e}}class b extends m{viewer;loedTilesSets=new Set;gisOrigin=null;_worldToEllipsoidMatrix=new r.Matrix4;_ellipsoidPosition=new r.Vector3;constructor(e){super(),this.viewer=e,this.tiles.addEventListener("needs-render",this.render),this.tiles.addEventListener("needs-update",this.render)}render=()=>{this.viewer.render()};beforeRenderHandler=()=>{this.viewer.camera.updateMatrixWorld(),this.tiles.setCamera(this.viewer.camera),this.tiles.setResolutionFromRenderer(this.viewer.camera,this.viewer.renderer),this.tiles.update()};enable(){return this.viewer.scene.add(this.tiles.group),this.viewer.addEventListener("beforeRender",this.beforeRenderHandler),this}disable(){return this.viewer.scene.remove(this.tiles.group),this.viewer.removeEventListener("beforeRender",this.beforeRenderHandler),this}invalidate(e,i,s){const l=()=>{const u=r.MathUtils.degToRad(i),M=r.MathUtils.degToRad(e);this.reorientationPlugin.transformLatLonHeightToOrigin(u,M,s),this.gisOrigin={lon:e,lat:i,height:s},this.render(),d()},d=()=>{this.tiles.removeEventListener("load-root-tileset",l),this.loedTilesSets.delete(l)};return this.tiles.addEventListener("load-root-tileset",l),this.loedTilesSets.add(l),this.tiles.root&&l(),d}lonLatHeightToPosition(e,i,s=0,l=new r.Vector3){const d=r.MathUtils.degToRad(i),u=r.MathUtils.degToRad(e);return this.tiles.ellipsoid.getCartographicToPosition(d,u,s,l),this.tiles.group.updateWorldMatrix(!0,!1),l.applyMatrix4(this.tiles.group.matrixWorld)}positionToLonLatHeight(e,i={lon:0,lat:0,height:0}){return this.tiles.group.updateWorldMatrix(!0,!1),this._worldToEllipsoidMatrix.copy(this.tiles.group.matrixWorld).invert(),this._ellipsoidPosition.copy(e).applyMatrix4(this._worldToEllipsoidMatrix),this.tiles.ellipsoid.getPositionToCartographic(this._ellipsoidPosition,i),i.lon=r.MathUtils.radToDeg(i.lon),i.lat=r.MathUtils.radToDeg(i.lat),i}dispose(){this.disable(),this.loedTilesSets.forEach(e=>this.tiles.removeEventListener("load-root-tileset",e)),this.loedTilesSets.clear(),this.tiles.removeEventListener("needs-render",this.render),this.tiles.removeEventListener("needs-update",this.render),this.tiles.dispose()}}exports.ArcgisTilesRenderer=b;exports.Globe=m;