gl-draw 0.17.0-beta.4 → 0.17.0-beta.41

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 (50) hide show
  1. package/dist/cartographicToCartesian.js +1 -0
  2. package/dist/cartographicToCartesian.module.js +49 -0
  3. package/dist/constants.d.ts +0 -1
  4. package/dist/core/BaseObject/PointerEvent.d.ts +1 -0
  5. package/dist/core/BaseObject/index.d.ts +16 -4
  6. package/dist/core/CSSRenderer/CollisionManager.d.ts +98 -0
  7. package/dist/core/CSSRenderer/index.d.ts +18 -6
  8. package/dist/core/Composer.d.ts +5 -5
  9. package/dist/core/Helper.d.ts +4 -4
  10. package/dist/core/Lead/Pick.d.ts +35 -3
  11. package/dist/core/Lead/index.d.ts +5 -6
  12. package/dist/core/Pages/Pages.d.ts +1 -0
  13. package/dist/core/Pencil.d.ts +19 -5
  14. package/dist/core/pass/OutputPass.d.ts +1 -2
  15. package/dist/index.js +2 -2
  16. package/dist/index.module.js +708 -442
  17. package/dist/index.module2.js +1183 -0
  18. package/dist/index2.js +140 -0
  19. package/dist/objects/conicPolygon/geometry/index.d.ts +1 -2
  20. package/dist/objects/ellipsoid/createGeometry.d.ts +30 -0
  21. package/dist/objects/ellipsoid/index.d.ts +38 -0
  22. package/dist/objects/extrudePolygon/createGeometry.d.ts +2 -1
  23. package/dist/objects/group/index.d.ts +1 -0
  24. package/dist/objects/index.d.ts +1 -0
  25. package/dist/objects/index.js +1 -1
  26. package/dist/objects/index.module.js +691 -688
  27. package/dist/objects/node/index.d.ts +6 -2
  28. package/dist/objects/pie/index.d.ts +2 -1
  29. package/dist/plugins/Worker/getAttributes/conicLine.d.ts +1 -1
  30. package/dist/plugins/Worker/getAttributes/conicPolygon.d.ts +2 -3
  31. package/dist/plugins/Worker/getAttributes/extrudePolygon.d.ts +1 -1
  32. package/dist/plugins/Worker/getAttributes/getCoordinatesArr.d.ts +5 -1
  33. package/dist/plugins/Worker/getAttributes/line.d.ts +1 -1
  34. package/dist/plugins/Worker/getAttributes/line2.d.ts +1 -1
  35. package/dist/plugins/Worker/getAttributes/splitPolygonsByLongitudeDifference.d.ts +5 -2
  36. package/dist/plugins/Worker/index.d.ts +2 -3
  37. package/dist/plugins/index.js +1 -1
  38. package/dist/plugins/index.module.js +77 -70
  39. package/dist/utils/Sprite2Points.d.ts +1 -1
  40. package/dist/utils/cartographicToCartesian.d.ts +30 -0
  41. package/dist/utils/index.d.ts +1 -1
  42. package/dist/utils/index.js +1 -1
  43. package/dist/utils/index.module.js +15 -13
  44. package/dist/utils/proposedRaycast.d.ts +1 -0
  45. package/package.json +1 -1
  46. package/dist/WebGPULineSegments2.js +0 -140
  47. package/dist/WebGPULineSegments2.module.js +0 -1031
  48. package/dist/polar2Cartesian.js +0 -1
  49. package/dist/polar2Cartesian.module.js +0 -18
  50. package/dist/utils/polar2Cartesian.d.ts +0 -1
@@ -1,3 +1,3 @@
1
- import { Sprite, BufferGeometry, PointsMaterial, Points } from 'three';
1
+ import { BufferGeometry, Points, PointsMaterial, type Sprite } from 'three';
2
2
  declare const _default: (object3d: Sprite, count?: number) => Points<BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>, PointsMaterial, import("three").Object3DEventMap>;
3
3
  export default _default;
@@ -0,0 +1,30 @@
1
+ import { Vector3 } from 'three';
2
+ /**
3
+ * 将地理坐标 (经度, 纬度, 高度) 转换为 Cartesian3 坐标
4
+ * 类似 Cesium 的 Ellipsoid.cartographicToCartesian
5
+ * @param longitude 经度(度)
6
+ * @param latitude 纬度(度)
7
+ * @param height 椭球体表面之上的高度(米),默认为 0
8
+ * @param scaleFactor 缩放因子,默认为 1/WGS84.a(将地球缩放到半径≈1)
9
+ * @param usePerfectSphere 是否使用完美球体(忽略椭球体扁率),默认 false
10
+ * @returns Vector3 笛卡尔坐标(已缩放)
11
+ */
12
+ export declare const WGS84: {
13
+ a: number;
14
+ b: number;
15
+ f: number;
16
+ };
17
+ export declare function cartographicToCartesian(longitude: number, latitude: number, height?: number, scaleFactor?: number, usePerfectSphere?: boolean): Vector3;
18
+ /**
19
+ * 将 Cartesian3 坐标转换为地理坐标 (经度, 纬度, 高度)
20
+ * 类似 Cesium 的 Ellipsoid.cartesianToCartographic
21
+ * @param cartesian Vector3 笛卡尔坐标(已缩放)
22
+ * @param scaleFactor 缩放因子,必须与 cartographicToCartesian 使用的相同
23
+ * @param usePerfectSphere 是否使用完美球体,必须与 cartographicToCartesian 使用的相同
24
+ * @returns {longitude, latitude, height} 经纬度(度)和高度(米)
25
+ */
26
+ export declare function cartesianToCartographic(cartesian: Vector3, scaleFactor?: number, usePerfectSphere?: boolean): {
27
+ longitude: number;
28
+ latitude: number;
29
+ height: number;
30
+ };
@@ -2,5 +2,5 @@ export { applyTextureColorSpace } from './applyTextureColorSpace';
2
2
  export * from './getProjection';
3
3
  export { isPlainObject } from './isPlainObject';
4
4
  export * from './parseVector';
5
- export { polar2Cartesian } from './polar2Cartesian';
5
+ export * from './cartographicToCartesian';
6
6
  export * from './uvGenerator';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../isPlainObject.js"),l=require("d3-geo"),p=require("d3-geo-projection"),o=require("../polar2Cartesian.js"),u=require("../uvGenerator.js"),g={mercator:l.geoMercator,equirectangular:l.geoEquirectangular,winkel3:p.geoWinkel3},a={},j=e=>{var c,n,i;const r=JSON.stringify(e);if(a[r])return a[r];const t=g[(c=e.projectionType)!=null?c:"mercator"]().center(e.center).scale(e.scale).translate((n=e.translate)!=null?n:[0,0]).precision((i=e.precision)!=null?i:.1);return e.rotate&&t.rotate(e.rotate),a[r]=t,t};exports.applyTextureColorSpace=s.applyTextureColorSpace;exports.isPlainObject=s.isPlainObject;exports.parseVector2=o.parseVector2;exports.parseVector3=o.parseVector3;exports.polar2Cartesian=o.polar2Cartesian;exports.claerUVGenerator=u.claerUVGenerator;exports.getUVGenerator=u.getUVGenerator;exports.getProjection=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../isPlainObject.js"),s=require("d3-geo"),p=require("d3-geo-projection"),r=require("../cartographicToCartesian.js"),g=require("../uvGenerator.js"),u={mercator:s.geoMercator,equirectangular:s.geoEquirectangular,winkel3:p.geoWinkel3},c={},j=e=>{var o,n,i;const t=JSON.stringify(e);if(c[t])return c[t];const a=u[(o=e.projectionType)!=null?o:"mercator"]().center(e.center).scale(e.scale).translate((n=e.translate)!=null?n:[0,0]).precision((i=e.precision)!=null?i:.1);return e.rotate&&a.rotate(e.rotate),c[t]=a,a};exports.applyTextureColorSpace=l.applyTextureColorSpace;exports.isPlainObject=l.isPlainObject;exports.WGS84=r.WGS84;exports.cartesianToCartographic=r.cartesianToCartographic;exports.cartographicToCartesian=r.cartographicToCartesian;exports.parseVector2=r.parseVector2;exports.parseVector3=r.parseVector3;exports.claerUVGenerator=g.claerUVGenerator;exports.getUVGenerator=g.getUVGenerator;exports.getProjection=j;
@@ -1,27 +1,29 @@
1
1
  import { a as x, i as y } from "../isPlainObject.module.js";
2
2
  import { geoMercator as i, geoEquirectangular as s } from "d3-geo";
3
3
  import { geoWinkel3 as p } from "d3-geo-projection";
4
- import { b, p as k, a as O } from "../polar2Cartesian.module.js";
5
- import { c as C, g as G } from "../uvGenerator.module.js";
4
+ import { W as V, b, c as k, a as C, p as G } from "../cartographicToCartesian.module.js";
5
+ import { c as S, g as W } from "../uvGenerator.module.js";
6
6
  const l = {
7
7
  mercator: i,
8
8
  equirectangular: s,
9
9
  winkel3: p
10
- }, a = {}, f = (e) => {
10
+ }, t = {}, f = (r) => {
11
11
  var o, c, n;
12
- const r = JSON.stringify(e);
13
- if (a[r])
14
- return a[r];
15
- const t = l[(o = e.projectionType) != null ? o : "mercator"]().center(e.center).scale(e.scale).translate((c = e.translate) != null ? c : [0, 0]).precision((n = e.precision) != null ? n : 0.1);
16
- return e.rotate && t.rotate(e.rotate), a[r] = t, t;
12
+ const e = JSON.stringify(r);
13
+ if (t[e])
14
+ return t[e];
15
+ const a = l[(o = r.projectionType) != null ? o : "mercator"]().center(r.center).scale(r.scale).translate((c = r.translate) != null ? c : [0, 0]).precision((n = r.precision) != null ? n : 0.1);
16
+ return r.rotate && a.rotate(r.rotate), t[e] = a, a;
17
17
  };
18
18
  export {
19
+ V as WGS84,
19
20
  x as applyTextureColorSpace,
20
- C as claerUVGenerator,
21
+ b as cartesianToCartographic,
22
+ k as cartographicToCartesian,
23
+ S as claerUVGenerator,
21
24
  f as getProjection,
22
- G as getUVGenerator,
25
+ W as getUVGenerator,
23
26
  y as isPlainObject,
24
- b as parseVector2,
25
- k as parseVector3,
26
- O as polar2Cartesian
27
+ C as parseVector2,
28
+ G as parseVector3
27
29
  };
@@ -0,0 +1 @@
1
+ export declare function proposedRaycast(raycaster: any, intersects: any): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gl-draw",
3
- "version": "0.17.0-beta.4",
3
+ "version": "0.17.0-beta.41",
4
4
  "author": "gitplus <hstits@gmail.com>",
5
5
  "scripts": {
6
6
  "start": "bundler-dev",
@@ -1,140 +0,0 @@
1
- "use strict";var pe=Object.defineProperty,me=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var te=Math.pow,J=(n,e,t)=>e in n?pe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,_=(n,e)=>{for(var t in e||(e={}))H.call(e,t)&&J(n,t,e[t]);if(N)for(var t of N(e))ee.call(e,t)&&J(n,t,e[t]);return n},R=(n,e)=>me(n,ve(e));var ie=(n,e)=>{var t={};for(var i in n)H.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&N)for(var i of N(n))e.indexOf(i)<0&&ee.call(n,i)&&(t[i]=n[i]);return t};var re=(n,e,t)=>new Promise((i,r)=>{var a=c=>{try{s(t.next(c))}catch(l){r(l)}},u=c=>{try{s(t.throw(c))}catch(l){r(l)}},s=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,u);s((t=t.apply(n,e)).next())});const o=require("three"),ye=require("three/examples/jsm/renderers/CSS2DRenderer"),ne=require("three/examples/jsm/renderers/CSS3DRenderer"),E=require("d3-geo");require("d3-geo-projection");const Q=require("./polar2Cartesian.js"),L=require("d3-array"),X=require("earcut"),be=require("@turf/boolean-clockwise"),ge=require("delaunator"),Me=require("@turf/boolean-point-in-polygon"),xe=require("d3-geo-voronoi"),se=require("d3-scale"),Se=require("three/examples/jsm/lines/LineSegmentsGeometry"),we=0,je=1,Ae=2,Ce=!1;class fe{constructor(){this.resources=new Set,this.disposeMaterial=!0,this.disposeVideo=!0}track(e){if(!e)return e;if(Array.isArray(e))return e.forEach(t=>this.track(t)),e;if(!this.disposeMaterial&&e instanceof o.Material)return e;if(e instanceof Y?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof o.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof Y)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof o.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof o.Material){for(const i of Object.values(e))i instanceof o.Texture&&this.track(i);const t=e;if(t.uniforms){for(const i of Object.values(t.uniforms))if(i){const r=i.value;(r instanceof o.Texture||Array.isArray(r))&&this.track(r)}}}else this.disposeVideo&&e.isVideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof o.Object3D?e.push(t):t instanceof HTMLVideoElement&&t.pause(),Reflect.has(t,"dispose")&&t.dispose();e.forEach(t=>{t.removeFromParent()}),e.length=0,this.resources.clear()}}const Be=(n,e=1)=>{const t=new o.BufferGeometry;t.setAttribute("position",new o.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new o.Float32BufferAttribute(new Array(e).fill(1),1));const i=n.material,r=new o.PointsMaterial({size:10,map:i.map,alphaMap:i.alphaMap,color:i.color,blending:i.blending,depthTest:i.depthTest,depthWrite:!1,opacity:i.opacity,transparent:!0,alphaTest:i.alphaTest,sizeAttenuation:!1});return r.onBeforeCompile=a=>{a.vertexShader=`
2
- attribute float scaleAtt;
3
- ${a.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
4
- `},new o.Points(t,r)},Ie=(n,e)=>{const t=new o.Object3D;e.forEach((i,r)=>{const a=Q.parseVector3(i.position),u=Q.parseVector3(i.scale||[1,1,1]);t.position.copy(a),t.scale.copy(u),t.updateMatrix();const s=t.matrix.clone();if(n instanceof o.InstancedMesh||n.isInstantiate)n.setMatrixAt(r,s);else if(n instanceof o.Points||n.type==="Points"){const l=n.geometry,v=l.attributes.position.array,d=l.attributes.scaleAtt.array,p=new o.Vector3,f=new o.Vector3,m=new o.Quaternion,h=r*3,y=r*1;s.decompose(p,m,f),v[h]=p.x,v[h+1]=p.y,v[h+2]=p.z,d[y]=Math.max(f.x,f.y,f.z),l.attributes.position.needsUpdate=!0,l.attributes.scaleAtt.needsUpdate=!0}})};class Pe{constructor(){this.onPointerIndex=[]}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}onClick(e){this.onPointerEvent("click",e)}onPointerEnter(e){this.onPointerEvent("enter",e)}onPointerLeave(e){this.onPointerEvent("leave",e)}onPointerMove(e){this.onPointerEvent("move",e)}onPointerDown(e){this.onPointerEvent("down",e)}dispose(){this.onPointerIndex.forEach(e=>{this.lead.removePick(e)})}}class De extends Pe{constructor(){super(...arguments),this.userData={},this.materialList={},this.useMaterialType="origin",this.disposeMaterialIfNotUsed=!0}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(i=>{const r=i.userData;i.userData={};const a=i.clone();return i.userData=r,a});{const i=t.userData;t.userData={};const r=t.clone();return t.userData=i,r}}setMaterialList(e,t){const i=this.object3d;if(!i||!i.material)return;this.materialList.origin||(this.materialList.origin=i.material);const r=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=r,r}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}useMListById(e,t){if(!this.mList)return;const i=this.mList.get(e);if(!i)return;const r=this.object3d;Array.isArray(r.material)&&t!==void 0?r.material[t]=i:r.material=i}useMListByName(e,t){if(!this.mList)return;const i=this.mList.getKeyByName(e);i&&this.useMListById(i,t)}dispose(){super.dispose(),this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed)}}class Y extends De{constructor(){super(...arguments),this.key="",this.objectType="BaseObject",this.userData={},this.isPrefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.isBaseObject=!0,this.disposeTrack=!0}get parent(){const e=this.object3d.parent;return e&&this.lead.objMap.get(e)||null}get children(){return this.object3d.children.map(e=>this.lead.objMap.get(e)).filter(e=>!!e)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}lookAt(e){const t=e instanceof o.Vector3?e:new o.Vector3(...e);this.object3d.lookAt(t)}add(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.object3d.add(t):this.lead.createBaseObject(t,{target:this})})}remove(...e){[...e].forEach(t=>{var i;this.lead.objMap.get(t)?(i=this.lead.objMap.get(t))==null||i.erase():this.object3d.remove(t)})}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let e=this.parent;for(;e;){if(!e.visible)return!1;e=e.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(e,t){}resize(e,t){}show(){return this.object3d.visible=!0,this.object3d.layers.set(we),this.isBloom&&this.enableBloom(),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Ae),this}createGroup(){return this.object3d=new o.Group,this}createMesh(...e){return this.object3d=new o.Mesh(...e),this}createPoints(...e){return this.object3d=new o.Points(...e),this}createCSS2DObject(e){return this.object3d=new ye.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new ne.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new ne.CSS3DSprite(e),this}createSprite(e){return this.object3d=new o.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new o.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new o.Vector3),center:e.getCenter(new o.Vector3)}}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}instantiate(e){return re(this,null,function*(){var l,v;const t=(l=e==null?void 0:e.recursive)!=null?l:!0,i=(v=e==null?void 0:e.cloneMaterial)!=null?v:!1,{objectType:r,objectOptions:a}=this;let u=e==null?void 0:e.create,s,c=(e==null?void 0:e.target)||this.parent;return c===this.lead.prefabGroup&&(c=this.lead.group),this.objectType==="BaseObject"?s=this.lead.createBaseObject(this.object3d.clone(!1),{target:c}):(u===void 0&&(u=d=>{var p;if(this.object3d){if((p=e==null?void 0:e.instancedAttr)!=null&&p.length){const f=e.instancedAttr.length;if(this.object3d instanceof o.Sprite)d.object3d=Be(this.object3d,f);else{const m=this.object3d,h=i?this.cloneMaterial():m.material;d.object3d=new o.InstancedMesh(m.geometry,h,f)}Ie(d.object3d,e==null?void 0:e.instancedAttr)}else d.object3d=this.object3d.clone(!1),i&&d.object3d.material&&(d.object3d.material=this.cloneMaterial());d.object3d.userData.prefab&&delete d.object3d.userData.prefab}}),s=yield this.lead.draw(r,R(_({},a||{}),{create:u,prefab:!1,keyType:this.keyType,key:(e==null?void 0:e.key)||this.keyName,uId:(e==null?void 0:e.uId)||this.keyUId,target:c}))),this.isBloom&&s.enableBloom(),t&&(yield Promise.all(this.children.map(d=>d.instantiate({key:d.keyUId?`${d.keyName}-${d.keyUId}`:d.keyName,uId:e==null?void 0:e.uId,cloneMaterial:i,target:s})))),s.isInstantiate=!0,s})}erase(){this.lead.erase(this)}handleMaterialChange(e){}enableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var e;if(super.dispose(),(e=this.pencil.composerController)==null||e.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.lead.objectWrapChindIdMap.delete(this),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack){const t=new fe;t.disposeMaterial=!1,t.track(this),t.dispose()}}}function Ve(n,e){return n.map(t=>{const i=[];let r;return t.forEach(a=>{if(r){const u=E.geoDistance(a,r)*180/Math.PI;if(u>e){const s=E.geoInterpolate(r,a),c=1/Math.ceil(u/e);let l=c;for(;l<1;)i.push(s(l)),l+=c}}i.push(r=a)}),i})}function Te(n,{minLng:e,maxLng:t,minLat:i,maxLat:r}={}){const a=Math.round(te(360/n,2)/Math.PI),u=(1+Math.sqrt(5))/2,s=f=>f/u*360%360-180,c=f=>Math.acos(2*f/a-1)/Math.PI*180-90,l=f=>a*(Math.cos((f+90)*Math.PI/180)+1)/2,v=[r!==void 0?Math.ceil(l(r)):0,i!==void 0?Math.floor(l(i)):a-1],d=e===void 0&&t===void 0?()=>!0:e===void 0?f=>f<=t:t===void 0?f=>f>=e:t>=e?f=>f>=e&&f<=t:f=>f>=e||f<=t,p=[];for(let f=v[0];f<=v[1];f++){const m=s(f);d(m)&&p.push([m,c(f)])}return p}function Z(n,e,t=!1){return t?E.geoContains(e,n):Me(n,e)}function Oe(n,e){const t={type:"Polygon",coordinates:n},[[i,r],[a,u]]=E.geoBounds(t);if(Math.min(Math.abs(a-i),Math.abs(u-r))<e)return[];const s=i>a||u>=89||r<=-89;return Te(e,{minLng:i,maxLng:a,minLat:r,maxLat:u}).filter(c=>Z(c,t,s))}function ze(n,{resolution:e=1/0,bbox:t,projection:i}={}){const r=Ve(n,e),a=L.merge(r),u=Oe(n,e),s=[...a,...u],c={type:"Polygon",coordinates:n},[[l,v],[d,p]]=E.geoBounds(c),f=l>d||p>=89||v<=-89;let m=[];if(f){const b=xe.geoVoronoi(s).triangles(),S=new Map(s.map(([C,B],O)=>[`${C}-${B}`,O]));b.features.forEach(C=>{const B=C.geometry.coordinates[0].slice(0,3).reverse(),O=[];if(B.forEach(([I,q])=>{const k=`${I}-${q}`;S.has(k)&&O.push(S.get(k))}),O.length===3){if(O.some(I=>I<a.length)){const I=C.properties.circumcenter;if(!Z(I,c,f))return}m.push(...O)}})}else if(u.length){const b=ge.from(s);for(let S=0,C=b.triangles.length;S<C;S+=3){const B=[2,1,0].map(I=>b.triangles[S+I]),O=B.map(I=>s[I]);if(B.some(I=>I<a.length)){const I=[0,1].map(q=>L.mean(O,k=>k[q]));if(!Z(I,c,f))continue}m.push(...B)}}else{const{vertices:b,holes:S=[]}=X.flatten(r);m=X(b,S,2)}let h=t?[t[0],t[2]]:L.extent(s,b=>b[0]),y=t?[t[1],t[3]]:L.extent(s,b=>b[1]);if(i){const[b,S]=i([h[0],y[0]]),[C,B]=i([h[1],y[1]]);h=[b,C],y=[-S,-B]}const w=se.scaleLinear(h,[0,1]),j=se.scaleLinear(y,[0,1]),P=s.map(([b,S])=>{if(i){const[C,B]=i([b,S]);return[w(C),j(-B)]}else return[w(b),j(S)]});return{contour:r,triangles:{points:s,indices:m,uvs:P}}}const oe=new o.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function G(n,e,t,i){const r=n.map(a=>a.map(([u,s])=>{if(i){const[c,l]=i([u,s]);return[c,-l,e]}return t?Q.polar2Cartesian(u,s,e):[u,s,e]}));return X.flatten(r)}function Le(n,e,t,i,r){const{vertices:a,holes:u}=G(n,e,i,r),{vertices:s}=G(n,t,i,r),c=L.merge([s,a]),l=Math.round(s.length/3),v=new Set(u);let d=0;const p=[];for(let m=0;m<l;m++){let h=m+1;if(h===l)h=d;else if(v.has(h)){const y=h;h=d,d=y}p.push(m,m+l,h+l),p.push(h+l,h,m)}const f=[];for(let m=1;m>=0;m--)for(let h=0;h<l;h+=1)f.push(h/(l-1),m);return{indices:p,vertices:c,uvs:f,topVerts:s}}function ae(n,e,t,i,r,a){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:G([n.points],e,r,a).vertices,uvs:t}}const he=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:r=!0,hasSide:a=!0,hasBottom:u=!1,hasTop:s=!1,projection:c,bbox:l})=>{n.forEach(w=>{be(w)||w.reverse()});const{contour:v,triangles:d}=ze(n,{resolution:i,bbox:l,projection:c});let p={},f;a&&(p=Le(v,e!=null?e:t,t!=null?t:e,r,c),f=p.topVerts);let m=[];(u||s)&&(m=L.merge(d.uvs));let h={};u&&(h=ae(d,e,m,!1,r,c));let y={};return s&&(y=ae(d,t,m,!0,r,c)),{contour:v,triangles:d,sideTorso:p,bottomCap:h,topCap:y,topVerts:f}};class _e extends o.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=_({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:i,hasTop:r,topFirst:a,hasBottom:u,hasSide:s,cartesian:c,userDataRsoOffset:l,projection:v}=this.parameters,{contour:d,sideTorso:p,topVerts:f,bottomCap:m,topCap:h}=he(_({},this.parameters));let y=[],w=[],j=[],P=0;const A=b=>{const S=Math.round(y.length/3),C=j.length;y=y.concat(b.vertices),w=w.concat(b.uvs),j=j.concat(S?b.indices.map(B=>B+S):b.indices),this.addGroup(C,j.length-C,P++)};r&&a&&A(h),s&&(A(p),this.userData.topVerts=l?G(d,i+l,c,v).vertices:f),u&&A(m),r&&!a&&A(h),this.setIndex(j),this[oe]("position",new o.Float32BufferAttribute(y,3)),this[oe]("uv",new o.Float32BufferAttribute(w,2)),this.computeVertexNormals()}}const Ee=`
5
- #include <fog_pars_fragment>
6
- #include <logdepthbuf_pars_fragment>
7
-
8
- uniform float useDash;
9
- uniform float dashArray;
10
- uniform float dashOffset;
11
- uniform float dashRatio;
12
- uniform sampler2D alphaMap;
13
- uniform float useAlphaMap;
14
-
15
- varying vec2 vUV;
16
- varying vec4 vColor;
17
- varying float vCounters;
18
-
19
- uniform sampler2D map;
20
- uniform float useMap;
21
- uniform vec2 repeat;
22
- uniform float offsetLoop;
23
- uniform float alphaTest;
24
-
25
-
26
-
27
- void main() {
28
- #include <logdepthbuf_fragment>
29
-
30
- vec4 c = vColor;
31
-
32
- if( useMap == 1. ) c *= texture2D( map, vUV * repeat );
33
- if( useAlphaMap == 1. ) c.a *= texture2D( alphaMap, vUV * repeat ).r;
34
- if(offsetLoop!=1.0){
35
- if(vUV.x>1.0 || vUV.x<0.0){
36
- c.a = 0.0;
37
- }
38
- }
39
- if (c.a < alphaTest) discard;
40
- if( useDash == 1. ){
41
- c.a *= ceil(mod(vCounters + dashOffset, dashArray) - (dashArray * dashRatio));
42
- }
43
- gl_FragColor = c;
44
- #include <fog_fragment>
45
- #include <tonemapping_fragment>
46
- #include <colorspace_fragment>
47
- }
48
- `,ke=`
49
- #include <common>
50
- #include <logdepthbuf_pars_vertex>
51
- #include <fog_pars_vertex>
52
-
53
- attribute vec3 previous;
54
- attribute vec3 next;
55
- attribute float side;
56
- attribute float width;
57
- attribute float counters;
58
-
59
- uniform vec2 resolution;
60
- uniform float lineWidth;
61
- uniform vec3 color;
62
- uniform float opacity;
63
- uniform float sizeAttenuation;
64
- uniform float scaleDown;
65
- uniform vec2 offset;
66
-
67
- varying vec2 vUV;
68
- varying vec4 vColor;
69
- varying float vCounters;
70
-
71
- vec2 intoScreen(vec4 i) {
72
- return resolution * (0.5 * i.xy / i.w + 0.5);
73
- }
74
-
75
- void main() {
76
- float aspect = resolution.y / resolution.x;
77
-
78
- mat4 m = projectionMatrix * modelViewMatrix;
79
-
80
- vec4 currentClip = m * vec4( position, 1.0 );
81
- vec4 prevClip = m * vec4( previous, 1.0 );
82
- vec4 nextClip = m * vec4( next, 1.0 );
83
-
84
- vec4 currentNormed = currentClip / currentClip.w;
85
- vec4 prevNormed = prevClip / prevClip.w;
86
- vec4 nextNormed = nextClip / nextClip.w;
87
-
88
- vec2 currentScreen = intoScreen(currentNormed);
89
- vec2 prevScreen = intoScreen(prevNormed);
90
- vec2 nextScreen = intoScreen(nextNormed);
91
-
92
- float actualWidth = lineWidth * width;
93
-
94
- vec2 dir;
95
- if(nextScreen == currentScreen) {
96
- dir = normalize( currentScreen - prevScreen );
97
- } else if(prevScreen == currentScreen) {
98
- dir = normalize( nextScreen - currentScreen );
99
- } else {
100
- vec2 inDir = currentScreen - prevScreen;
101
- vec2 outDir = nextScreen - currentScreen;
102
- vec2 fullDir = nextScreen - prevScreen;
103
-
104
- if(length(fullDir) > 0.0) {
105
- dir = normalize(fullDir);
106
- } else if(length(inDir) > 0.0){
107
- dir = normalize(inDir);
108
- } else {
109
- dir = normalize(outDir);
110
- }
111
- }
112
-
113
- vec2 normal = vec2(-dir.y, dir.x);
114
-
115
- if(sizeAttenuation != 0.0) {
116
- normal /= currentClip.w;
117
- normal *= min(resolution.x, resolution.y);
118
- }
119
-
120
- if (scaleDown > 0.0) {
121
- float dist = length(nextNormed - prevNormed);
122
- normal *= smoothstep(0.0, scaleDown, dist);
123
- }
124
-
125
- vec2 offsetInScreen = actualWidth * normal * side * 0.5;
126
-
127
- vec2 withOffsetScreen = currentScreen + offsetInScreen;
128
- vec3 withOffsetNormed = vec3((2.0 * withOffsetScreen/resolution - 1.0), currentNormed.z);
129
-
130
- vCounters = counters;
131
- vColor = vec4( color, opacity );
132
- vUV = uv;
133
- vUV=uv+offset;
134
-
135
- gl_Position = currentClip.w * vec4(withOffsetNormed, 1.0);
136
-
137
- #include <logdepthbuf_vertex>
138
- #include <fog_vertex>
139
- }
140
- `;class Ne extends o.ShaderMaterial{constructor(e={}){const j=e,{lineWidth:t=1,color:i="#ffffff",opacity:r=1,map:a=null,dashOffset:u=0,dashArray:s=0,dashRatio:c=0,sizeAttenuation:l=!0,offsetLoop:v=!0,offset:d=new o.Vector2(0,0),scaleDown:p=0,alphaMap:f=void 0,alphaTest:m=0,repeat:h=new o.Vector2(1,1),resolution:y=new o.Vector2(1,1)}=j,w=ie(j,["lineWidth","color","opacity","map","dashOffset","dashArray","dashRatio","sizeAttenuation","offsetLoop","offset","scaleDown","alphaMap","alphaTest","repeat","resolution"]);super(R(_({},w),{uniforms:{lineWidth:{value:t},color:{value:new o.Color(i)},opacity:{value:r},map:{value:a},useMap:{value:a?1:0},resolution:{value:y},sizeAttenuation:{value:l?1:0},offset:{value:d},offsetLoop:{value:v?1:0},dashArray:{value:s},dashOffset:{value:u},dashRatio:{value:c},useDash:{value:s>0?1:0},scaleDown:{value:p/10},alphaTest:{value:m},alphaMap:{value:f},useAlphaMap:{value:f?1:0},repeat:{value:h}},vertexShader:ke,fragmentShader:Ee})),this.type="MeshLineMaterial"}get color(){return this.uniforms.color.value}set color(e){this.uniforms.color.value=new o.Color(e)}get opacity(){var e;return((e=this.uniforms)==null?void 0:e.opacity.value)||1}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms&&(this.uniforms.alphaTest.value=e)}get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e,this.uniforms.useMap.value=e?1:0}get repeat(){return this.uniforms.repeat.value}set repeat(e){this.uniforms.repeat.value.copy(e)}get lineWidth(){return this.uniforms.lineWidth.value}set lineWidth(e){this.uniforms.lineWidth.value=e}get sizeAttenuation(){return this.uniforms.sizeAttenuation.value===1}set sizeAttenuation(e){this.uniforms.sizeAttenuation.value=e?1:0}}const F=new o.Vector4,ce=new o.Vector3,le=new o.Vector3,g=new o.Vector4,M=new o.Vector4,D=new o.Vector4,$=new o.Vector3,K=new o.Matrix4,x=new o.Line3,ue=new o.Vector3,U=new o.Box3,W=new o.Sphere,V=new o.Vector4;let T,z;function de(n,e,t){return V.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),V.multiplyScalar(1/V.w),V.x=z/t.width,V.y=z/t.height,V.applyMatrix4(n.projectionMatrixInverse),V.multiplyScalar(1/V.w),Math.abs(Math.max(V.x,V.y))}function Ue(n,e){const t=n.matrixWorld,i=n.geometry,r=i.attributes.instanceStart,a=i.attributes.instanceEnd,u=Math.min(i.instanceCount,r.count);for(let s=0,c=u;s<c;s++){x.start.fromBufferAttribute(r,s),x.end.fromBufferAttribute(a,s),x.applyMatrix4(t);const l=new o.Vector3,v=new o.Vector3;T.distanceSqToSegment(x.start,x.end,v,l),v.distanceTo(l)<z*.5&&e.push({point:v,pointOnLine:l,distance:T.origin.distanceTo(v),object:n,face:null,faceIndex:s,uv:null,uv1:null})}}function We(n,e,t){const i=e.projectionMatrix,a=n.material.resolution,u=n.matrixWorld,s=n.geometry,c=s.attributes.instanceStart,l=s.attributes.instanceEnd,v=Math.min(s.instanceCount,c.count),d=-e.near;T.at(1,D),D.w=1,D.applyMatrix4(e.matrixWorldInverse),D.applyMatrix4(i),D.multiplyScalar(1/D.w),D.x*=a.x/2,D.y*=a.y/2,D.z=0,$.copy(D),K.multiplyMatrices(e.matrixWorldInverse,u);for(let p=0,f=v;p<f;p++){if(g.fromBufferAttribute(c,p),M.fromBufferAttribute(l,p),g.w=1,M.w=1,g.applyMatrix4(K),M.applyMatrix4(K),g.z>d&&M.z>d)continue;if(g.z>d){const P=g.z-M.z,A=(g.z-d)/P;g.lerp(M,A)}else if(M.z>d){const P=M.z-g.z,A=(M.z-d)/P;M.lerp(g,A)}g.applyMatrix4(i),M.applyMatrix4(i),g.multiplyScalar(1/g.w),M.multiplyScalar(1/M.w),g.x*=a.x/2,g.y*=a.y/2,M.x*=a.x/2,M.y*=a.y/2,x.start.copy(g),x.start.z=0,x.end.copy(M),x.end.z=0;const h=x.closestPointToPointParameter($,!0);x.at(h,ue);const y=o.MathUtils.lerp(g.z,M.z,h),w=y>=-1&&y<=1,j=$.distanceTo(ue)<z*.5;if(w&&j){x.start.fromBufferAttribute(c,p),x.end.fromBufferAttribute(l,p),x.start.applyMatrix4(u),x.end.applyMatrix4(u);const P=new o.Vector3,A=new o.Vector3;T.distanceSqToSegment(x.start,x.end,A,P),t.push({point:A,pointOnLine:P,distance:T.origin.distanceTo(A),object:n,face:null,faceIndex:p,uv:null,uv1:null})}}}class Ge extends o.Mesh{constructor(e=new Se.LineSegmentsGeometry,t){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let u=0,s=0,c=t.count;u<c;u++,s+=2)ce.fromBufferAttribute(t,u),le.fromBufferAttribute(i,u),r[s]=s===0?0:r[s-1],r[s+1]=r[s]+ce.distanceTo(le);const a=new o.InstancedInterleavedBuffer(r,2,1);return e.setAttribute("instanceDistanceStart",new o.InterleavedBufferAttribute(a,1,0)),e.setAttribute("instanceDistanceEnd",new o.InterleavedBufferAttribute(a,1,1)),this}raycast(e,t){const i=this.material.worldUnits,r=e.camera;r===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;T=e.ray;const u=this.matrixWorld,s=this.geometry,c=this.material;z=c.linewidth+a,s.boundingSphere===null&&s.computeBoundingSphere(),W.copy(s.boundingSphere).applyMatrix4(u);let l;if(i)l=z*.5;else{const d=Math.max(r.near,W.distanceToPoint(T.origin));l=de(r,d,c.resolution)}if(W.radius+=l,T.intersectsSphere(W)===!1)return;s.boundingBox===null&&s.computeBoundingBox(),U.copy(s.boundingBox).applyMatrix4(u);let v;if(i)v=z*.5;else{const d=Math.max(r.near,U.distanceToPoint(T.origin));v=de(r,d,c.resolution)}U.expandByScalar(v),T.intersectsBox(U)!==!1&&(i?Ue(this,t):We(this,r,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(F),this.material.uniforms.resolution.value.set(F.z,F.w))}}exports.BLOOM_SCENE=je;exports.BaseObject=Y;exports.IS_DEV=Ce;exports.LineSegments2=Ge;exports.MeshLineMaterial=Ne;exports.PolygonGeometry=_e;exports.ResourceTracker=fe;exports.getMetas=he;