u-space 0.0.16 → 0.0.18

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.
@@ -1,9 +1,53 @@
1
+ import { type ToneMapping } from 'three/webgpu';
2
+ import { AtmosphereContext, AtmosphereLight } from '@takram/three-atmosphere/webgpu';
1
3
  import type { Viewer } from 'u-space';
4
+ export interface AtmosphereOptions {
5
+ /** Longitude in degrees. Used as the local scene origin. */
6
+ longitude?: number;
7
+ /** Latitude in degrees. Used as the local scene origin. */
8
+ latitude?: number;
9
+ /** Height above WGS84 ellipsoid in meters. */
10
+ height?: number;
11
+ /** Date used for sun and moon directions. Defaults to current local 08:00. */
12
+ date?: number | Date;
13
+ showSun?: boolean;
14
+ showMoon?: boolean;
15
+ showStars?: boolean;
16
+ showGround?: boolean;
17
+ useSkyEnvironment?: boolean;
18
+ raymarchScattering?: boolean;
19
+ lighting?: boolean;
20
+ transmittance?: boolean;
21
+ inscattering?: boolean;
22
+ moonScattering?: boolean;
23
+ lensFlare?: boolean;
24
+ temporalAntialias?: boolean;
25
+ dithering?: boolean;
26
+ toneMapping?: ToneMapping | false;
27
+ toneMappingExposure?: number;
28
+ castShadow?: boolean;
29
+ shadowMapSize?: number;
30
+ shadowCameraSize?: number;
31
+ shadowCameraNear?: number;
32
+ shadowCameraFar?: number;
33
+ shadowBias?: number;
34
+ shadowNormalBias?: number;
35
+ shadowRadius?: number;
36
+ shadowDistance?: number;
37
+ }
2
38
  declare class Atmosphere {
39
+ #private;
3
40
  viewer: Viewer;
4
41
  constructor(viewer: Viewer);
5
- enable(): void;
6
- disable(): void;
7
- dispose(): void;
42
+ get enabled(): boolean;
43
+ get context(): AtmosphereContext | null;
44
+ get light(): AtmosphereLight | null;
45
+ enable(options?: AtmosphereOptions): this;
46
+ update(options?: AtmosphereOptions): this;
47
+ setLocation(longitude: number, latitude: number, height?: number): this;
48
+ setDate(date: number | Date): this;
49
+ updateDate(date?: number | Date): this;
50
+ disable(): this;
51
+ dispose(): this;
8
52
  }
9
53
  export { Atmosphere };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class s{viewer;constructor(e){this.viewer=e}enable(){}disable(){}dispose(){}}exports.Atmosphere=s;
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,15 +1,311 @@
1
- class r {
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(
8
+ i(1.6605, -0.1246, -0.0182),
9
+ i(-0.5876, 1.1329, -0.1006),
10
+ i(-0.0728, -83e-4, 1.1187)
11
+ ), J = u(
12
+ i(0.6274, 0.0691, 0.0164),
13
+ i(0.3293, 0.9195, 0.088),
14
+ i(0.0433, 0.0113, 0.8956)
15
+ ), K = R((s) => {
16
+ const e = s.pow2().toConst(), t = e.pow2().toConst();
17
+ return E(
18
+ t.mul(e).mul(15.5),
19
+ t.mul(s).mul(-40.14),
20
+ t.mul(31.96),
21
+ e.mul(s).mul(-6.868),
22
+ e.mul(0.4298),
23
+ s.mul(0.1191),
24
+ -232e-5
25
+ );
26
+ }), Q = u(
27
+ i(0.856627153315983, 0.137318972929847, 0.11189821299995),
28
+ i(0.0951212405381588, 0.761241990602591, 0.0767994186031903),
29
+ i(0.0482516061458583, 0.101439036467562, 0.811302368396859)
30
+ ), Y = u(
31
+ i(1.1271005818144368, -0.1413297634984383, -0.14132976349843826),
32
+ i(-0.11060664309660323, 1.157823702216272, -0.11060664309660294),
33
+ i(-0.016493938717834573, -0.016493938717834257, 1.2519364065950405)
34
+ ), f = -12.47393, Z = 4.026069, $ = p({
35
+ name: "agx",
36
+ type: "vec3",
37
+ inputs: [
38
+ { name: "color", type: "vec3" },
39
+ { name: "exposure", type: "float" }
40
+ ]
41
+ })(([s, e]) => {
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({
45
+ name: "agxEOTF",
46
+ type: "vec3",
47
+ inputs: [{ name: "color", type: "vec3" }]
48
+ })(([s]) => {
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({
52
+ name: "agxPunchyToneMapping",
53
+ type: "vec3",
54
+ inputs: [
55
+ { name: "color", type: "vec3" },
56
+ { name: "exposure", type: "float" }
57
+ ]
58
+ })(([s, e]) => {
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;
62
+ function l() {
63
+ const s = /* @__PURE__ */ new Date();
64
+ return s.setHours(8, 0, 0, 0), s;
65
+ }
66
+ const ie = {
67
+ longitude: 0,
68
+ latitude: 0,
69
+ height: 0,
70
+ date: 0,
71
+ showSun: !0,
72
+ showMoon: !0,
73
+ showStars: !0,
74
+ showGround: !1,
75
+ useSkyEnvironment: !0,
76
+ raymarchScattering: !0,
77
+ lighting: !0,
78
+ transmittance: !0,
79
+ inscattering: !0,
80
+ moonScattering: !0,
81
+ lensFlare: !0,
82
+ temporalAntialias: !0,
83
+ dithering: !0,
84
+ toneMapping: x,
85
+ toneMappingExposure: 3,
86
+ castShadow: !0,
87
+ shadowMapSize: 4096,
88
+ shadowCameraSize: 180,
89
+ shadowCameraNear: 10,
90
+ shadowCameraFar: 6e3,
91
+ shadowBias: -2e-5,
92
+ shadowNormalBias: 1e-3,
93
+ shadowRadius: 1.5,
94
+ shadowDistance: 3e3
95
+ };
96
+ class de {
2
97
  viewer;
98
+ #a = !1;
99
+ #e = {
100
+ ...ie,
101
+ date: l()
102
+ };
103
+ #p = null;
104
+ #i = null;
105
+ #t = null;
106
+ #r = null;
107
+ #o = null;
108
+ #s = null;
109
+ #d = null;
110
+ #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();
3
119
  constructor(e) {
4
120
  this.viewer = e;
5
121
  }
6
- enable() {
122
+ get enabled() {
123
+ return this.#a;
124
+ }
125
+ get context() {
126
+ return this.#i;
127
+ }
128
+ get light() {
129
+ return this.#t;
130
+ }
131
+ 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);
133
+ }
134
+ 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;
136
+ }
137
+ setLocation(e, t, n = this.#e.height) {
138
+ return this.update({ longitude: e, latitude: t, height: n });
139
+ }
140
+ setDate(e) {
141
+ return this.updateDate(e);
142
+ }
143
+ updateDate(e = l()) {
144
+ return this.#e.date = e, this.#b(), this.viewer.render(), this;
7
145
  }
8
146
  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;
9
148
  }
10
149
  dispose() {
150
+ return this.disable();
151
+ }
152
+ #E(e) {
153
+ return {
154
+ ...this.#e,
155
+ ...e,
156
+ date: e.date ?? (this.#a ? this.#e.date : l())
157
+ };
158
+ }
159
+ #x() {
160
+ if (!this.#i)
161
+ return;
162
+ const t = new j(
163
+ w(this.#e.longitude),
164
+ w(this.#e.latitude),
165
+ this.#e.height
166
+ ).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);
168
+ }
169
+ #D() {
170
+ if (!this.#i)
171
+ return;
172
+ const e = this.viewer.renderer;
173
+ this.#l = e.contextNode, this.#w = e.highPrecision, e.highPrecision = !0, e.contextNode = P({
174
+ ...e.contextNode.value,
175
+ getAtmosphere: () => this.#i
176
+ });
177
+ }
178
+ #L() {
179
+ 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);
181
+ }
182
+ #N() {
183
+ if (!this.#t)
184
+ return;
185
+ const {
186
+ castShadow: e,
187
+ shadowMapSize: t,
188
+ shadowCameraSize: n,
189
+ shadowCameraNear: r,
190
+ shadowCameraFar: h,
191
+ shadowBias: a,
192
+ shadowNormalBias: N,
193
+ shadowRadius: C,
194
+ shadowDistance: y
195
+ } = 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;
197
+ }
198
+ #C() {
199
+ this.#t && (this.viewer.controls.getTarget(this.#t.target.position), this.#t.target.updateMatrixWorld());
200
+ }
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();
203
+ }
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);
206
+ }
207
+ #M() {
208
+ if (!this.#e.useSkyEnvironment) {
209
+ this.#o && this.viewer.scene.environmentNode === this.#o && (this.viewer.scene.environmentNode = this.#m), this.#o = null;
210
+ return;
211
+ }
212
+ this.#o ??= W(), this.viewer.scene.environmentNode = this.#o;
213
+ }
214
+ #k() {
215
+ this.viewer.renderer.library.addToneMapping(te, x);
216
+ }
217
+ #B() {
218
+ this.#h.includesOutputTransform = !0, this.#S(), this.viewer.renderPipeline.addOutputEffect(this.#h);
219
+ }
220
+ #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);
226
+ return;
227
+ }
228
+ this.#T();
229
+ }
230
+ #T() {
231
+ this.#c && (this.viewer.renderPipeline.removeMRTChannel("atmosphereVelocity"), this.#c = !1);
232
+ }
233
+ #I() {
234
+ this.#a && (this.viewer.renderPipeline.needsUpdateOutputNode = !0);
235
+ }
236
+ #F() {
237
+ for (const e of this.#n)
238
+ 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);
243
+ }
244
+ #h = (e, t) => {
245
+ 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;
258
+ }
259
+ if (this.#e.temporalAntialias) {
260
+ const a = e.getTextureNode("atmosphereVelocity");
261
+ this.#u = O(
262
+ r,
263
+ n,
264
+ a,
265
+ this.viewer.camera
266
+ ), this.#n.push(this.#u), r = this.#u;
267
+ }
268
+ if (this.#e.dithering) {
269
+ const a = E(r, k);
270
+ this.#n.push(a), r = a;
271
+ }
272
+ const h = A(r, g);
273
+ return this.#n.push(h), h;
274
+ };
275
+ #b() {
276
+ if (!this.#i)
277
+ return;
278
+ this.viewer.camera.updateMatrixWorld(), this.#g.setFromMatrixPosition(this.viewer.camera.matrixWorld).applyMatrix4(this.#i.matrixWorldToECEF.value);
279
+ 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(
285
+ this.#e.date,
286
+ this.#i.moonDirectionECEF.value,
287
+ this.#g
288
+ ).applyMatrix4(e);
289
+ }
290
+ #V() {
291
+ this.viewer.addEventListener("cameraChange", this.#A);
292
+ }
293
+ #_() {
294
+ this.viewer.removeEventListener("cameraChange", this.#A);
295
+ }
296
+ #U() {
297
+ this.viewer.addEventListener("beforeRender", this.#R);
298
+ }
299
+ #G() {
300
+ this.viewer.removeEventListener("beforeRender", this.#R);
11
301
  }
302
+ #A = ({ camera: e }) => {
303
+ this.#i && (this.#i.camera = e, this.updateDate(this.#e.date));
304
+ };
305
+ #R = () => {
306
+ this.#C(), this.#b();
307
+ };
12
308
  }
13
309
  export {
14
- r as Atmosphere
310
+ de as Atmosphere
15
311
  };