@takram/three-geospatial 0.0.1-alpha.1

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.
Files changed (53) hide show
  1. package/README.md +15 -0
  2. package/build/index.cjs +43 -0
  3. package/build/index.js +932 -0
  4. package/build/r3f.cjs +1 -0
  5. package/build/r3f.js +38 -0
  6. package/build/shared.cjs +1 -0
  7. package/build/shared.js +198 -0
  8. package/package.json +42 -0
  9. package/src/ArrayBufferLoader.ts +35 -0
  10. package/src/DataLoader.ts +114 -0
  11. package/src/Ellipsoid.ts +128 -0
  12. package/src/EllipsoidGeometry.ts +107 -0
  13. package/src/Geodetic.ts +160 -0
  14. package/src/PointOfView.ts +169 -0
  15. package/src/Rectangle.ts +97 -0
  16. package/src/TileCoordinate.test.ts +38 -0
  17. package/src/TileCoordinate.ts +112 -0
  18. package/src/TilingScheme.test.ts +63 -0
  19. package/src/TilingScheme.ts +76 -0
  20. package/src/TypedArrayLoader.ts +53 -0
  21. package/src/assertions.ts +13 -0
  22. package/src/bufferGeometry.ts +62 -0
  23. package/src/helpers/projectOnEllipsoidSurface.ts +72 -0
  24. package/src/index.ts +25 -0
  25. package/src/math.ts +41 -0
  26. package/src/r3f/EastNorthUpFrame.tsx +52 -0
  27. package/src/r3f/EllipsoidMesh.tsx +36 -0
  28. package/src/r3f/index.ts +2 -0
  29. package/src/shaders/depth.glsl +15 -0
  30. package/src/shaders/packing.glsl +20 -0
  31. package/src/shaders/transform.glsl +12 -0
  32. package/src/typedArray.ts +76 -0
  33. package/src/types.ts +54 -0
  34. package/types/ArrayBufferLoader.d.ts +5 -0
  35. package/types/DataLoader.d.ts +67 -0
  36. package/types/Ellipsoid.d.ts +18 -0
  37. package/types/EllipsoidGeometry.d.ts +13 -0
  38. package/types/Geodetic.d.ts +37 -0
  39. package/types/PointOfView.d.ts +20 -0
  40. package/types/Rectangle.d.ts +27 -0
  41. package/types/TileCoordinate.d.ts +21 -0
  42. package/types/TilingScheme.d.ts +21 -0
  43. package/types/TypedArrayLoader.d.ts +16 -0
  44. package/types/assertions.d.ts +4 -0
  45. package/types/bufferGeometry.d.ts +5 -0
  46. package/types/helpers/projectOnEllipsoidSurface.d.ts +6 -0
  47. package/types/index.d.ts +18 -0
  48. package/types/math.d.ts +13 -0
  49. package/types/r3f/EastNorthUpFrame.d.ts +15 -0
  50. package/types/r3f/EllipsoidMesh.d.ts +13 -0
  51. package/types/r3f/index.d.ts +2 -0
  52. package/types/typedArray.d.ts +10 -0
  53. package/types/types.d.ts +22 -0
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @takram/three-geospatial
2
+
3
+ Provides fundamental functions for rendering GIS data in Three.js and R3F (React Three Fiber).
4
+
5
+ This library is currently under active development, and its API may change without maintaining backward compatibility.
6
+
7
+ It is part of a project to prototype the rendering aspect of a Web GIS engine. For more details on the background and current status of this project, please refer to the [main README](/README.md).
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ npm install @takram/three-geospatial
13
+ pnpm add @takram/three-geospatial
14
+ yarn add @takram/three-geospatial
15
+ ```
@@ -0,0 +1,43 @@
1
+ "use strict";var _t=Object.defineProperty;var Tt=(e,t,r)=>t in e?_t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var h=(e,t,r)=>Tt(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("three"),d=require("./shared.cjs");var St=`float reverseLogDepth(const float depth, const float near, const float far) {
2
+ #ifdef USE_LOGDEPTHBUF
3
+ float d = pow(2.0, depth * log2(far + 1.0)) - 1.0;
4
+ float a = far / (far - near);
5
+ float b = far * near / (near - far);
6
+ return a + b / d;
7
+ #else
8
+ return depth;
9
+ #endif
10
+ }
11
+
12
+ float linearizeDepth(const float depth, const float near, const float far) {
13
+ float ndc = depth * 2.0 - 1.0;
14
+ return 2.0 * near * far / (far + near - ndc * (far - near));
15
+ }`,Mt=`vec2 signNotZero(vec2 v) {
16
+ return vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0);
17
+ }
18
+
19
+ vec2 packNormalToVec2(vec3 v) {
20
+ vec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z)));
21
+ return v.z <= 0.0
22
+ ? (1.0 - abs(p.yx)) * signNotZero(p)
23
+ : p;
24
+ }
25
+
26
+ vec3 unpackVec2ToNormal(vec2 e) {
27
+ vec3 v = vec3(e.xy, 1.0 - abs(e.x) - abs(e.y));
28
+ if (v.z < 0.0) {
29
+ v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);
30
+ }
31
+ return normalize(v);
32
+ }`,Pt=`vec3 screenToView(
33
+ const vec2 uv,
34
+ const float depth,
35
+ const float viewZ,
36
+ const mat4 projectionMatrix,
37
+ const mat4 inverseProjectionMatrix
38
+ ) {
39
+ vec4 clip = vec4(vec3(uv, depth) * 2.0 - 1.0, 1.0);
40
+ float clipW = projectionMatrix[2][3] * viewZ + projectionMatrix[3][3];
41
+ clip *= clipW;
42
+ return (inverseProjectionMatrix * clip).xyz;
43
+ }`,At=process.env.NODE_ENV==="production",Q="Invariant failed";function Ot(e,t){if(!e){if(At)throw new Error(Q);var r=Q;throw new Error(r)}}class st extends o.Loader{load(t,r,n,i){const a=new o.FileLoader(this.manager);a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(this.withCredentials),a.load(t,s=>{Ot(s instanceof ArrayBuffer);try{r(s)}catch(c){i!=null?i(c):console.error(c),this.manager.itemError(t)}},n,i)}}function zt(e){}function ot(e){return e!=null}function Et(e){return e!==void 0}function Lt(e){return e!==!1}var It=typeof global=="object"&&global&&global.Object===Object&&global,Dt=typeof self=="object"&&self&&self.Object===Object&&self,R=It||Dt||Function("return this")(),p=R.Symbol,ct=Object.prototype,Ft=ct.hasOwnProperty,Nt=ct.toString,x=p?p.toStringTag:void 0;function Ct(e){var t=Ft.call(e,x),r=e[x];try{e[x]=void 0;var n=!0}catch{}var i=Nt.call(e);return n&&(t?e[x]=r:delete e[x]),i}var Ut=Object.prototype,Gt=Ut.toString;function $t(e){return Gt.call(e)}var jt="[object Null]",Rt="[object Undefined]",J=p?p.toStringTag:void 0;function B(e){return e==null?e===void 0?Rt:jt:J&&J in Object(e)?Ct(e):$t(e)}function H(e){return e!=null&&typeof e=="object"}var Bt="[object Symbol]";function V(e){return typeof e=="symbol"||H(e)&&B(e)==Bt}function Ht(e,t){for(var r=-1,n=e==null?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}var M=Array.isArray,Vt=1/0,k=p?p.prototype:void 0,tt=k?k.toString:void 0;function ht(e){if(typeof e=="string")return e;if(M(e))return Ht(e,ht)+"";if(V(e))return tt?tt.call(e):"";var t=e+"";return t=="0"&&1/e==-Vt?"-0":t}function z(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function qt(e){return e}var Wt="[object AsyncFunction]",Xt="[object Function]",Zt="[object GeneratorFunction]",Yt="[object Proxy]";function Kt(e){if(!z(e))return!1;var t=B(e);return t==Xt||t==Zt||t==Wt||t==Yt}var G=R["__core-js_shared__"],et=function(){var e=/[^.]+$/.exec(G&&G.keys&&G.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Qt(e){return!!et&&et in e}var Jt=Function.prototype,kt=Jt.toString;function te(e){if(e!=null){try{return kt.call(e)}catch{}try{return e+""}catch{}}return""}var ee=/[\\^$.*+?()[\]{}|]/g,re=/^\[object .+?Constructor\]$/,ne=Function.prototype,ie=Object.prototype,ae=ne.toString,se=ie.hasOwnProperty,oe=RegExp("^"+ae.call(se).replace(ee,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ce(e){if(!z(e)||Qt(e))return!1;var t=Kt(e)?oe:re;return t.test(te(e))}function he(e,t){return e==null?void 0:e[t]}function q(e,t){var r=he(e,t);return ce(r)?r:void 0}function le(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var ue=800,de=16,fe=Date.now;function pe(e){var t=0,r=0;return function(){var n=fe(),i=de-(n-r);if(r=n,i>0){if(++t>=ue)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function ye(e){return function(){return e}}var E=function(){try{var e=q(Object,"defineProperty");return e({},"",{}),e}catch{}}(),ge=E?function(e,t){return E(e,"toString",{configurable:!0,enumerable:!1,value:ye(t),writable:!0})}:qt,we=pe(ge),me=9007199254740991,ve=/^(?:0|[1-9]\d*)$/;function lt(e,t){var r=typeof e;return t=t??me,!!t&&(r=="number"||r!="symbol"&&ve.test(e))&&e>-1&&e%1==0&&e<t}function xe(e,t,r){t=="__proto__"&&E?E(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function ut(e,t){return e===t||e!==e&&t!==t}var be=Object.prototype,_e=be.hasOwnProperty;function Te(e,t,r){var n=e[t];(!(_e.call(e,t)&&ut(n,r))||r===void 0&&!(t in e))&&xe(e,t,r)}var rt=Math.max;function Se(e,t,r){return t=rt(t===void 0?e.length-1:t,0),function(){for(var n=arguments,i=-1,a=rt(n.length-t,0),s=Array(a);++i<a;)s[i]=n[t+i];i=-1;for(var c=Array(t+1);++i<t;)c[i]=n[i];return c[t]=r(s),le(e,this,c)}}var Me=9007199254740991;function Pe(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Me}var Ae="[object Arguments]";function nt(e){return H(e)&&B(e)==Ae}var dt=Object.prototype,Oe=dt.hasOwnProperty,ze=dt.propertyIsEnumerable,ft=nt(function(){return arguments}())?nt:function(e){return H(e)&&Oe.call(e,"callee")&&!ze.call(e,"callee")},Ee=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Le=/^\w*$/;function Ie(e,t){if(M(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||V(e)?!0:Le.test(e)||!Ee.test(e)||t!=null&&e in Object(t)}var T=q(Object,"create");function De(){this.__data__=T?T(null):{},this.size=0}function Fe(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ne="__lodash_hash_undefined__",Ce=Object.prototype,Ue=Ce.hasOwnProperty;function Ge(e){var t=this.__data__;if(T){var r=t[e];return r===Ne?void 0:r}return Ue.call(t,e)?t[e]:void 0}var $e=Object.prototype,je=$e.hasOwnProperty;function Re(e){var t=this.__data__;return T?t[e]!==void 0:je.call(t,e)}var Be="__lodash_hash_undefined__";function He(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=T&&t===void 0?Be:t,this}function g(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}g.prototype.clear=De;g.prototype.delete=Fe;g.prototype.get=Ge;g.prototype.has=Re;g.prototype.set=He;function Ve(){this.__data__=[],this.size=0}function L(e,t){for(var r=e.length;r--;)if(ut(e[r][0],t))return r;return-1}var qe=Array.prototype,We=qe.splice;function Xe(e){var t=this.__data__,r=L(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():We.call(t,r,1),--this.size,!0}function Ze(e){var t=this.__data__,r=L(t,e);return r<0?void 0:t[r][1]}function Ye(e){return L(this.__data__,e)>-1}function Ke(e,t){var r=this.__data__,n=L(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}function v(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}v.prototype.clear=Ve;v.prototype.delete=Xe;v.prototype.get=Ze;v.prototype.has=Ye;v.prototype.set=Ke;var Qe=q(R,"Map");function Je(){this.size=0,this.__data__={hash:new g,map:new(Qe||v),string:new g}}function ke(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function I(e,t){var r=e.__data__;return ke(t)?r[typeof t=="string"?"string":"hash"]:r.map}function tr(e){var t=I(this,e).delete(e);return this.size-=t?1:0,t}function er(e){return I(this,e).get(e)}function rr(e){return I(this,e).has(e)}function nr(e,t){var r=I(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}function w(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}w.prototype.clear=Je;w.prototype.delete=tr;w.prototype.get=er;w.prototype.has=rr;w.prototype.set=nr;var ir="Expected a function";function W(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(ir);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],a=r.cache;if(a.has(i))return a.get(i);var s=e.apply(this,n);return r.cache=a.set(i,s)||a,s};return r.cache=new(W.Cache||w),r}W.Cache=w;var ar=500;function sr(e){var t=W(e,function(n){return r.size===ar&&r.clear(),n}),r=t.cache;return t}var or=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,cr=/\\(\\)?/g,hr=sr(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(or,function(r,n,i,a){t.push(i?a.replace(cr,"$1"):n||r)}),t});function lr(e){return e==null?"":ht(e)}function D(e,t){return M(e)?e:Ie(e,t)?[e]:hr(lr(e))}var ur=1/0;function X(e){if(typeof e=="string"||V(e))return e;var t=e+"";return t=="0"&&1/e==-ur?"-0":t}function dr(e,t){t=D(t,e);for(var r=0,n=t.length;e!=null&&r<n;)e=e[X(t[r++])];return r&&r==n?e:void 0}function fr(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}var it=p?p.isConcatSpreadable:void 0;function pr(e){return M(e)||ft(e)||!!(it&&e&&e[it])}function yr(e,t,r,n,i){var a=-1,s=e.length;for(r||(r=pr),i||(i=[]);++a<s;){var c=e[a];r(c)?fr(i,c):i[i.length]=c}return i}function gr(e){var t=e==null?0:e.length;return t?yr(e):[]}function wr(e){return we(Se(e,void 0,gr),e+"")}function mr(e,t){return e!=null&&t in Object(e)}function vr(e,t,r){t=D(t,e);for(var n=-1,i=t.length,a=!1;++n<i;){var s=X(t[n]);if(!(a=e!=null&&r(e,s)))break;e=e[s]}return a||++n!=i?a:(i=e==null?0:e.length,!!i&&Pe(i)&&lt(s,i)&&(M(e)||ft(e)))}function xr(e,t){return e!=null&&vr(e,t,mr)}function br(e,t,r,n){if(!z(e))return e;t=D(t,e);for(var i=-1,a=t.length,s=a-1,c=e;c!=null&&++i<a;){var l=X(t[i]),u=r;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(i!=s){var y=c[l];u=void 0,u===void 0&&(u=z(y)?y:lt(t[i+1])?[]:{})}Te(c,l,u),c=c[l]}return e}function _r(e,t,r){for(var n=-1,i=t.length,a={};++n<i;){var s=t[n],c=dr(e,s);r(c,s)&&br(a,D(s,e),c)}return a}function Tr(e,t){return _r(e,t,function(r,n){return xr(e,n)})}var Sr=wr(function(e,t){return e==null?{}:Tr(e,t)});function Mr(e){var t;return[Sr(e,["attributes","index","boundingBox","boundingSphere"]),[...Object.values(e.attributes).map(r=>r.array.buffer),(t=e.index)==null?void 0:t.array.buffer].filter(ot)]}function Pr(e,t=new o.BufferGeometry){for(const[r,n]of Object.entries(e.attributes))t.setAttribute(r,new o.BufferAttribute(n.array,n.itemSize,n.normalized));if(t.index=e.index!=null?new o.BufferAttribute(e.index.array,e.index.itemSize,e.index.normalized):null,e.boundingBox!=null){const{min:r,max:n}=e.boundingBox;t.boundingBox=new o.Box3(new o.Vector3(r.x,r.y,r.z),new o.Vector3(n.x,n.y,n.z))}if(e.boundingSphere!=null){const{center:r,radius:n}=e.boundingSphere;t.boundingSphere=new o.Sphere(new o.Vector3(r.x,r.y,r.z),n)}return t}function F(e,t,r,n=!0){const i=new DataView(e),a=new t(i.byteLength/t.BYTES_PER_ELEMENT);for(let s=0,c=0;s<a.length;++s,c+=t.BYTES_PER_ELEMENT)a[s]=i[r](c,n);return a}function pt(e,t){return F(e,Int16Array,"getInt16",t)}function yt(e,t){return F(e,Uint16Array,"getUint16",t)}function gt(e,t){return F(e,Float32Array,"getFloat32",t)}class N extends o.Loader{load(t,r,n,i){const a=new st(this.manager);a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(this.withCredentials),a.load(t,s=>{try{r(this.parseTypedArray(s))}catch(c){i!=null?i(c):console.error(c),this.manager.itemError(t)}},n,i)}}class wt extends N{constructor(){super(...arguments);h(this,"parseTypedArray",pt)}}class mt extends N{constructor(){super(...arguments);h(this,"parseTypedArray",yt)}}class Z extends N{constructor(){super(...arguments);h(this,"parseTypedArray",gt)}}const C={format:o.RGBAFormat,wrapS:o.ClampToEdgeWrapping,wrapT:o.ClampToEdgeWrapping,minFilter:o.LinearFilter,magFilter:o.LinearFilter};class P extends o.Loader{constructor(){super(...arguments);h(this,"parameters")}load(r,n,i,a){const s=new this.Texture,c=new this.TypedArrayLoader(this.manager);c.setRequestHeader(this.requestHeader),c.setPath(this.path),c.setWithCredentials(this.withCredentials),c.load(r,l=>{s.image.data=l,Object.assign(s,this.parameters),s.needsUpdate=!0,n(s)},i,a)}}class Ar extends P{constructor(){super(...arguments);h(this,"Texture",o.DataTexture);h(this,"TypedArrayLoader",wt);h(this,"parameters",{...C,type:o.FloatType})}}class Or extends P{constructor(){super(...arguments);h(this,"Texture",o.DataTexture);h(this,"TypedArrayLoader",mt);h(this,"parameters",{...C,type:o.FloatType})}}class zr extends P{constructor(){super(...arguments);h(this,"Texture",o.DataTexture);h(this,"TypedArrayLoader",Z);h(this,"parameters",{...C,type:o.FloatType})}}class Er extends P{constructor(){super(...arguments);h(this,"Texture",o.Data3DTexture);h(this,"TypedArrayLoader",Z);h(this,"parameters",{...C,type:o.FloatType})}}const vt=o.MathUtils.clamp,Lr=o.MathUtils.euclideanModulo,Ir=o.MathUtils.inverseLerp,Dr=o.MathUtils.lerp,Fr=o.MathUtils.degToRad,Nr=o.MathUtils.radToDeg,Cr=o.MathUtils.isPowerOfTwo,Ur=o.MathUtils.ceilPowerOfTwo,Gr=o.MathUtils.floorPowerOfTwo,$r=o.MathUtils.normalize;function jr(e,t,r){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function Rr(e){return Math.min(Math.max(e,0),1)}function Br(e,t,r,n=r){const i=Math.abs(e-t);return i<=n||i<=r*Math.max(Math.abs(e),Math.abs(t))}const $=1e-6,A=new o.Vector3,O=new o.Vector3,f=new o.Vector3,b=new o.Vector3,j=new o.Vector3,Hr=new o.Vector3,Vr=new o.Matrix4,qr=new o.Quaternion,Wr=new o.Ray;class Y{constructor(t=0,r=0,n=0,i=0){h(this,"_distance");h(this,"heading");h(this,"_pitch");h(this,"roll");this.distance=t,this.heading=r,this.pitch=n,this.roll=i}get distance(){return this._distance}set distance(t){this._distance=Math.max(t,$)}get pitch(){return this._pitch}set pitch(t){this._pitch=vt(t,-Math.PI/2+$,Math.PI/2-$)}set(t,r,n,i){return this.distance=t,this.heading=r,this.pitch=n,i!=null&&(this.roll=i),this}clone(){return new Y(this.distance,this.heading,this.pitch,this.roll)}copy(t){return this.distance=t.distance,this.heading=t.heading,this.pitch=t.pitch,this.roll=t.roll,this}equals(t){return t.distance===this.distance&&t.heading===this.heading&&t.pitch===this.pitch&&t.roll===this.roll}decompose(t,r,n,i,a=d.Ellipsoid.WGS84){a.getEastNorthUpVectors(t,A,O,f),i==null||i.copy(f);const s=b.copy(A).multiplyScalar(Math.cos(this.heading)).add(j.copy(O).multiplyScalar(Math.sin(this.heading))).multiplyScalar(Math.cos(this.pitch)).add(j.copy(f).multiplyScalar(Math.sin(this.pitch))).normalize().multiplyScalar(this.distance);if(r.copy(t).sub(s),this.roll!==0){const c=b.copy(t).sub(r).normalize();f.applyQuaternion(qr.setFromAxisAngle(c,this.roll))}n.setFromRotationMatrix(Vr.lookAt(r,t,f))}setFromCamera(t,r=d.Ellipsoid.WGS84){const n=b.setFromMatrixPosition(t.matrixWorld),i=j.set(0,0,.5).unproject(t).sub(n).normalize(),a=r.getIntersection(Wr.set(n,i));if(a==null)return;this.distance=n.distanceTo(a),r.getEastNorthUpVectors(a,A,O,f),this.heading=Math.atan2(O.dot(i),A.dot(i)),this.pitch=Math.asin(f.dot(i));const s=b.copy(t.up).applyQuaternion(t.quaternion),c=Hr.copy(i).multiplyScalar(-s.dot(i)).add(s).normalize(),l=b.copy(i).multiplyScalar(-f.dot(i)).add(f).normalize(),u=l.dot(c),y=i.dot(l.cross(c));return this.roll=Math.atan2(y,u),this}}const _=class _{constructor(t=0,r=0,n=0,i=0){this.west=t,this.south=r,this.east=n,this.north=i}get width(){let t=this.east;return t<this.west&&(t+=Math.PI*2),t-this.west}get height(){return this.north-this.south}set(t,r,n,i){return this.west=t,this.south=r,this.east=n,this.north=i,this}clone(){return new _(this.west,this.south,this.east,this.north)}copy(t){return this.west=t.west,this.south=t.south,this.east=t.east,this.north=t.north,this}equals(t){return t.west===this.west&&t.south===this.south&&t.east===this.east&&t.north===this.north}at(t,r,n=new d.Geodetic){return n.set(this.west+(this.east-this.west)*t,this.north+(this.south-this.north)*r)}fromArray(t,r=0){return this.west=t[r],this.south=t[r+1],this.east=t[r+2],this.north=t[r+3],this}toArray(t=[],r=0){return t[r]=this.west,t[r+1]=this.south,t[r+2]=this.east,t[r+3]=this.north,t}*[Symbol.iterator](){yield this.west,yield this.south,yield this.east,yield this.north}};h(_,"MAX",new _(d.Geodetic.MIN_LONGITUDE,d.Geodetic.MIN_LATITUDE,d.Geodetic.MAX_LONGITUDE,d.Geodetic.MAX_LATITUDE));let S=_;function*xt(e,t,r,n,i){if(r>=n)return;const a=2**r,s=r+1,c=2**s,l=Math.floor(e/a*c),u=Math.floor(t/a*c),y=[[l,u,s],[l+1,u,s],[l,u+1,s],[l+1,u+1,s]];if(s<n)for(const U of y)for(const bt of xt(...U,n,i))yield bt;else for(const U of y)yield(i??new m).set(...U)}class m{constructor(t=0,r=0,n=0){this.x=t,this.y=r,this.z=n}set(t,r,n){return this.x=t,this.y=r,n!=null&&(this.z=n),this}clone(){return new m(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}getParent(t=new m){const r=2**this.z,n=this.x/r,i=this.y/r,a=this.z-1,s=2**a;return t.set(Math.floor(n*s),Math.floor(i*s),a)}*traverseChildren(t,r){const{x:n,y:i,z:a}=this;for(const s of xt(n,i,a,a+t,r))yield s}fromArray(t,r=0){return this.x=t[r],this.y=t[r+1],this.z=t[r+2],this}toArray(t=[],r=0){return t[r]=this.x,t[r+1]=this.y,t[r+2]=this.z,t}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const at=new o.Vector2;class K{constructor(t=2,r=1,n=S.MAX){this.width=t,this.height=r,this.rectangle=n}clone(){return new K(this.width,this.height,this.rectangle.clone())}copy(t){return this.width=t.width,this.height=t.height,this.rectangle.copy(t.rectangle),this}getSize(t,r=new o.Vector2){return r.set(this.width<<t,this.height<<t)}getTile(t,r,n=new m){const i=this.getSize(r,at),a=this.rectangle.width/i.x,s=this.rectangle.height/i.y;let c=t.longitude;this.rectangle.east<this.rectangle.west&&(c+=Math.PI*2);let l=Math.floor((c-this.rectangle.west)/a);l>=i.x&&(l=i.x-1);let u=Math.floor((t.latitude-this.rectangle.south)/s);return u>=i.y&&(u=i.y-1),n.x=l,n.y=u,n.z=r,n}getRectangle(t,r=new S){const n=this.getSize(t.z,at),i=this.rectangle.width/n.x,a=this.rectangle.height/n.y;return r.west=t.x*i+this.rectangle.west,r.east=(t.x+1)*i+this.rectangle.west,r.north=this.rectangle.north-(n.y-t.y-1)*a,r.south=this.rectangle.north-(n.y-t.y)*a,r}}const Xr=St,Zr=Mt,Yr=Pt;exports.Ellipsoid=d.Ellipsoid;exports.EllipsoidGeometry=d.EllipsoidGeometry;exports.Geodetic=d.Geodetic;exports.ArrayBufferLoader=st;exports.DataLoader=P;exports.Float32ArrayLoader=Z;exports.Float32Data2DLoader=zr;exports.Float32Data3DLoader=Er;exports.Int16ArrayLoader=wt;exports.Int16Data2DLoader=Ar;exports.PointOfView=Y;exports.Rectangle=S;exports.TileCoordinate=m;exports.TilingScheme=K;exports.TypedArrayLoader=N;exports.Uint16ArrayLoader=mt;exports.Uint16Data2DLoader=Or;exports.assertType=zt;exports.ceilPowerOfTwo=Ur;exports.clamp=vt;exports.closeTo=Br;exports.degrees=Nr;exports.depthShader=Xr;exports.euclideanModulo=Lr;exports.floorPowerOfTwo=Gr;exports.fromBufferGeometryLike=Pr;exports.inverseLerp=Ir;exports.isNotFalse=Lt;exports.isNotNullish=ot;exports.isNotUndefined=Et;exports.isPowerOfTwo=Cr;exports.lerp=Dr;exports.normalize=$r;exports.packingShader=Zr;exports.parseFloat32Array=gt;exports.parseInt16Array=pt;exports.parseTypedArray=F;exports.parseUint16Array=yt;exports.radians=Fr;exports.saturate=Rr;exports.smoothstep=jr;exports.toBufferGeometryLike=Mr;exports.transformShader=Yr;