vis-core 0.12.16 → 0.12.17
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.js
CHANGED
|
@@ -4697,7 +4697,7 @@ version 0.8.2
|
|
|
4697
4697
|
gl_FragColor = vec4(ccccc, alpha * 0.65);
|
|
4698
4698
|
|
|
4699
4699
|
|
|
4700
|
-
`)},o.needsUpdate=!0,s.useMaterial(i)}})}addArea(e,i){return Gt(this,null,function*(){const{bbox:s,material:l,onTop:a,bboxOffset:o}=i,c=this.geojson2Meta(e),d=this.pencil.getPlugin("worker"),r=this.pencil.getPlugin("draw");if(i.areaGroup)return yield Promise.all(c.map(h=>Gt(this,null,function*(){const{coords:u,properties:m}=h,p=this.findGroup(m.adcode||m.DistrictID),G=yield d.geoGeometry(this.options.curvatureResolution?"conicPolygon":"extrudePolygon",{mesaage:{coordinatesArr:u,projection:this.options.projection,curvatureResolution:this.options.curvatureResolution,bbox:s,bboxOffset:o,depth:[this.options.depth],hasBottom:!1,hasSide:i.hasSide,useGroups:i.hasSide?2:0}}),b=yield r.draw(this.options.curvatureResolution?"ConicPolygon":"ExtrudePolygon",{geometry:G,material:l,onTop:a},p);return b.userData=Bt({},m),b})));{const h=yield d.geoGeometry("extrudePolygon",{mesaage:{coordinatesArr:c.map(({coords:m})=>m).flat(),projection:Bt({},this.options.projection),bbox:s,bboxOffset:o,depth:[this.options.depth],hasBottom:!1,useGroups:2}});return[yield r.draw("ExtrudePolygon",{geometry:h,material:l},this)]}})}addLine(e,i){return Gt(this,null,function*(){const{material:s,onTop:l}=i,a=this.geojson2Meta(e),o=this.pencil.getPlugin("worker"),c=this.pencil.getPlugin("draw");if(i.areaGroup)return yield Promise.all(a.map(d=>Gt(this,null,function*(){const{coords:r,properties:h}=d,u=this.findGroup(h.adcode||h.DistrictID),m=yield o.geoGeometry("line",{mesaage:{coordinatesArr:r,lineWidth:[1],projection:this.options.projection}}),p=yield c.draw("Line",{geometry:m,material:s,onTop:l},u);return p.userData=Bt({},h),p})));{const d=yield o.geoGeometry("line",{mesaage:{coordinatesArr:a.map(({coords:h})=>h).flat(),lineWidth:[1],projection:this.options.projection}});return[yield c.draw("Line",{geometry:d,material:s,onTop:l},this)]}})}geojson2Meta(e){return e.features.filter(i=>i.geometry).map(i=>{var o,c;const{type:s,coordinates:l}=i.geometry;let a=[];return s==="Polygon"?(a=l,(((o=i.properties)==null?void 0:o.NAME)==="Iceland"||((c=i.properties)==null?void 0:c.NAME)==="Greenland")&&i.geometry.coordinates[0][0][0]!==-999&&i.geometry.coordinates[0].unshift([-999,-999])):s==="MultiPolygon"&&(a=l.flat()),{coords:a,properties:i.properties}})}pickArea(e){const{pencil:i}=this,s=this.areaArr.map(a=>a.object3d),l=i.pick(e,s,!0);if(l)return this.drawController.objMap.get(l.object)}update(e,i){const{lineMat:s,extrudeLineMat:l}=this.options.materialOptions;this.isActive&&[s,l].forEach(a=>{!a||!a.uniforms.lineLightAnimation.value||(a.uniforms.time.value=i)})}findGroup(e){return this.pencil.getPlugin("draw").getObject("Group",{key:`area-group-${e}`})}setAreaMaterial(e){this.areaArr.forEach(i=>{i.setMaterialList("bg",e),i.useMaterial("bg")})}resetAreaMaterial(){this.areaArr.forEach(e=>{e.useMaterial("origin")})}setLineMaterial(e){this.lineArr.forEach(i=>{i.setMaterialList("bg",e),i.useMaterial("bg")})}resetLineMaterial(){const{lineMat:e}=this.options.materialOptions;e&&this.lineArr.forEach(i=>{i.useMaterial("origin")})}setExtrudeLineMaterial(e){var i;(i=this.extrudelineArr)==null||i.forEach(s=>{s.setMaterialList("bg",e),s.useMaterial("bg")})}resetExtrudeLineMaterial(){var i;const{extrudeLineMat:e}=this.options.materialOptions;e&&((i=this.extrudelineArr)==null||i.forEach(s=>{s.useMaterial("origin")}))}changeLineAnimateParams({speed:e=.5,extrude:i=!1}){const{lineMat:s,extrudeLineMat:l}=this.options.materialOptions,a=i?l:s;if(!a)return;a.uniforms.time.value=0,a.uniforms.speed.value=e,a.uniforms.lineLightAnimation.value=1;const{size:o,min:c,max:d}=this.getSize();a.uniforms.size.value=Math.max(o.x,o.y)/2,a.uniforms.uCenter.value=new A((c.x+d.x)/2,(c.y+d.y)/2)}deactive(){if(!this.isActive)return;const{materialOptions:e}=this.options,{bgTopMat:i,bgSideMat:s,bgLineMat:l,bgExtrudeLineMat:a,lineMat:o,extrudeLineMat:c}=e;this.isActive=!1,this.options.bloom&&this.toggleExtrudelineBloom(!1),i&&s&&this.setAreaMaterial([i,s]),l&&this.setLineMaterial(l),a&&this.setExtrudeLineMaterial(a)}render(){this.options.bloom&&this.toggleExtrudelineBloom(!0)}toggleExtrudelineBloom(e){var i;(i=this.extrudelineArr)==null||i.forEach(s=>{this.pencil.composerController.toggleBloomSelection(s.object3d,e)})}active(){this.isActive||(this.isActive=!0,this.resetAreaMaterial(),this.resetLineMaterial(),this.resetExtrudeLineMaterial(),this.options.bloom&&this.toggleExtrudelineBloom(!0))}dispose(e=!0){super.dispose(e),this.areaArr.length=0,this.lineArr&&(this.lineArr.length=0),this.extrudelineArr&&(this.extrudelineArr.length=0)}}class pX extends X0{constructor(e){super();P(this,"options");P(this,"mapArr",[]);this.options=e}create(){return Gt(this,null,function*(){const{depth:e}=this.options,i=this.pencil.installPlugins.get("materialList"),s=this.pencil.getPlugin("draw"),l=i.getMaterialObj("continents");this.createGroup(),yield Promise.all(e9.features.map(a=>Gt(this,null,function*(){a.properties.name==="大洋洲"&&(a.geometry.coordinates[4]=[],a.geometry.coordinates[21]=[]);const o=j0.centroid(a).geometry.coordinates;let c=0,d=0,r=this.options.scale;const h=30,u=25,m=a.properties.name;a.properties.name==="南美洲"?(c=-h,d=u,r=r*.2):a.properties.name==="北美洲"?(c=0,d=u,r=r*.18):a.properties.name==="大洋洲"?(c=h,d=u,r=r*.3):a.properties.name==="亚洲"?(c=-h,d=-u,r=r*.15):a.properties.name==="欧洲"?(c=0,d=-u,r=r*.3):a.properties.name==="非洲"&&(c=h,d=-u,r=r*.2);const p=yield s.draw("PlaneMap",{geojson:{type:"FeatureCollection",features:[a]},projection:{center:o,scale:r,rotate:[0,0],equirectangular:!0},areaGroup:!1,depth:e,materialOptions:Bt({},l)},this);p.userData.projection=ga({center:o,scale:r,rotate:[0,0],equirectangular:!0}),p.userData.name=m,p.position.set(c,d,0),this.mapArr.push(p)})))})}
|
|
4700
|
+
`)},o.needsUpdate=!0,s.useMaterial(i)}})}addArea(e,i){return Gt(this,null,function*(){const{bbox:s,material:l,onTop:a,bboxOffset:o}=i,c=this.geojson2Meta(e),d=this.pencil.getPlugin("worker"),r=this.pencil.getPlugin("draw");if(i.areaGroup)return yield Promise.all(c.map(h=>Gt(this,null,function*(){const{coords:u,properties:m}=h,p=this.findGroup(m.adcode||m.DistrictID),G=yield d.geoGeometry(this.options.curvatureResolution?"conicPolygon":"extrudePolygon",{mesaage:{coordinatesArr:u,projection:this.options.projection,curvatureResolution:this.options.curvatureResolution,bbox:s,bboxOffset:o,depth:[this.options.depth],hasBottom:!1,hasSide:i.hasSide,useGroups:i.hasSide?2:0}}),b=yield r.draw(this.options.curvatureResolution?"ConicPolygon":"ExtrudePolygon",{geometry:G,material:l,onTop:a},p);return b.userData=Bt({},m),b})));{const h=yield d.geoGeometry("extrudePolygon",{mesaage:{coordinatesArr:c.map(({coords:m})=>m).flat(),projection:Bt({},this.options.projection),bbox:s,bboxOffset:o,depth:[this.options.depth],hasBottom:!1,useGroups:2}});return[yield r.draw("ExtrudePolygon",{geometry:h,material:l},this)]}})}addLine(e,i){return Gt(this,null,function*(){const{material:s,onTop:l}=i,a=this.geojson2Meta(e),o=this.pencil.getPlugin("worker"),c=this.pencil.getPlugin("draw");if(i.areaGroup)return yield Promise.all(a.map(d=>Gt(this,null,function*(){const{coords:r,properties:h}=d,u=this.findGroup(h.adcode||h.DistrictID),m=yield o.geoGeometry("line",{mesaage:{coordinatesArr:r,lineWidth:[1],projection:this.options.projection}}),p=yield c.draw("Line",{geometry:m,material:s,onTop:l},u);return p.userData=Bt({},h),p})));{const d=yield o.geoGeometry("line",{mesaage:{coordinatesArr:a.map(({coords:h})=>h).flat(),lineWidth:[1],projection:this.options.projection}});return[yield c.draw("Line",{geometry:d,material:s,onTop:l},this)]}})}geojson2Meta(e){return e.features.filter(i=>i.geometry).map(i=>{var o,c;const{type:s,coordinates:l}=i.geometry;let a=[];return s==="Polygon"?(a=l,(((o=i.properties)==null?void 0:o.NAME)==="Iceland"||((c=i.properties)==null?void 0:c.NAME)==="Greenland")&&i.geometry.coordinates[0][0][0]!==-999&&i.geometry.coordinates[0].unshift([-999,-999])):s==="MultiPolygon"&&(a=l.flat()),{coords:a,properties:i.properties}})}pickArea(e){const{pencil:i}=this,s=this.areaArr.map(a=>a.object3d),l=i.pick(e,s,!0);if(l)return this.drawController.objMap.get(l.object)}update(e,i){const{lineMat:s,extrudeLineMat:l}=this.options.materialOptions;this.isActive&&[s,l].forEach(a=>{!a||!a.uniforms.lineLightAnimation.value||(a.uniforms.time.value=i)})}findGroup(e){return this.pencil.getPlugin("draw").getObject("Group",{key:`area-group-${e}`})}setAreaMaterial(e){this.areaArr.forEach(i=>{i.setMaterialList("bg",e),i.useMaterial("bg")})}resetAreaMaterial(){this.areaArr.forEach(e=>{e.useMaterial("origin")})}setLineMaterial(e){this.lineArr.forEach(i=>{i.setMaterialList("bg",e),i.useMaterial("bg")})}resetLineMaterial(){const{lineMat:e}=this.options.materialOptions;e&&this.lineArr.forEach(i=>{i.useMaterial("origin")})}setExtrudeLineMaterial(e){var i;(i=this.extrudelineArr)==null||i.forEach(s=>{s.setMaterialList("bg",e),s.useMaterial("bg")})}resetExtrudeLineMaterial(){var i;const{extrudeLineMat:e}=this.options.materialOptions;e&&((i=this.extrudelineArr)==null||i.forEach(s=>{s.useMaterial("origin")}))}changeLineAnimateParams({speed:e=.5,extrude:i=!1}){const{lineMat:s,extrudeLineMat:l}=this.options.materialOptions,a=i?l:s;if(!a)return;a.uniforms.time.value=0,a.uniforms.speed.value=e,a.uniforms.lineLightAnimation.value=1;const{size:o,min:c,max:d}=this.getSize();a.uniforms.size.value=Math.max(o.x,o.y)/2,a.uniforms.uCenter.value=new A((c.x+d.x)/2,(c.y+d.y)/2)}deactive(){if(!this.isActive)return;const{materialOptions:e}=this.options,{bgTopMat:i,bgSideMat:s,bgLineMat:l,bgExtrudeLineMat:a,lineMat:o,extrudeLineMat:c}=e;this.isActive=!1,this.options.bloom&&this.toggleExtrudelineBloom(!1),i&&s&&this.setAreaMaterial([i,s]),l&&this.setLineMaterial(l),a&&this.setExtrudeLineMaterial(a)}render(){this.options.bloom&&this.toggleExtrudelineBloom(!0)}toggleExtrudelineBloom(e){var i;(i=this.extrudelineArr)==null||i.forEach(s=>{this.pencil.composerController.toggleBloomSelection(s.object3d,e)})}active(){this.isActive||(this.isActive=!0,this.resetAreaMaterial(),this.resetLineMaterial(),this.resetExtrudeLineMaterial(),this.options.bloom&&this.toggleExtrudelineBloom(!0))}dispose(e=!0){super.dispose(e),this.areaArr.length=0,this.lineArr&&(this.lineArr.length=0),this.extrudelineArr&&(this.extrudelineArr.length=0)}}class pX extends X0{constructor(e){super();P(this,"options");P(this,"mapArr",[]);this.options=e}create(){return Gt(this,null,function*(){const{depth:e}=this.options,i=this.pencil.installPlugins.get("materialList"),s=this.pencil.getPlugin("draw"),l=i.getMaterialObj("continents");this.createGroup(),yield Promise.all(e9.features.map(a=>Gt(this,null,function*(){a.properties.name==="大洋洲"&&(a.geometry.coordinates[4]=[],a.geometry.coordinates[21]=[]);const o=j0.centroid(a).geometry.coordinates;let c=0,d=0,r=this.options.scale;const h=30,u=25,m=a.properties.name;a.properties.name==="南美洲"?(c=-h,d=u,r=r*.2):a.properties.name==="北美洲"?(c=0,d=u,r=r*.18):a.properties.name==="大洋洲"?(c=h,d=u,r=r*.3):a.properties.name==="亚洲"?(c=-h,d=-u,r=r*.15):a.properties.name==="欧洲"?(c=0,d=-u,r=r*.3):a.properties.name==="非洲"&&(c=h,d=-u,r=r*.2);const p=yield s.draw("PlaneMap",{geojson:{type:"FeatureCollection",features:[a]},projection:{center:o,scale:r,rotate:[0,0],equirectangular:!0},areaGroup:!1,depth:e,materialOptions:Bt({},l)},this);p.userData.projection=ga({center:o,scale:r,rotate:[0,0],equirectangular:!0}),p.userData.name=m,p.position.set(c,d,0),this.mapArr.push(p)})))})}getPointInContinentInfo(e){return e9.features.find(i=>i.geometry.coordinates.some(s=>s.length?j0.booleanPointInPolygon(j0.point(e),j0.polygon(s)):!1))}getPointInContinent(e){return!!this.getPointInContinentInfo(e)}getLocationPosition(e){var s;const i=(s=this.getPointInContinentInfo(e))==null?void 0:s.properties.name;if(i){const l=this.mapArr.find(a=>a.userData.name===i);if(l){const{projection:a}=l.userData,[o,c]=e,[d,r]=a([o,c]),h=l.object3d.getWorldPosition(new S),u=new S(d,-r,0).add(new S(h.x,h.y,h.z+this.options.depth));return[u.x,u.y,u.z]}}}dispose(){this.mapArr.forEach(e=>{e.dispose()}),this.mapArr.length=0}}class bX extends X0{create(){return Gt(this,null,function*(){const t=new _i(100,100,1,1),e=new d2;e.opacity=.5,this.createMesh(t,e),this.object3d.receiveShadow=!0,this.position.z=.001})}}const IM={Node:Ia,Image:Na,Line:Ma,PlaneMap:mX,ContinentsBg:pX,ExtrudePolygon:Fa,Group:bl,Light:Yc,PlaneShadow:bX},an=new Ya(IM),ls=n=>{const t=vn.makePromiseCreator(!0);return fetch(n).then(e=>{if(e.ok)return e.json();throw new Error("Network response was not ok.")}).then(e=>{t.resolve(e)}).catch(e=>{t.reject(e)}),t.promise},ZX=n=>{const t=document.createElement("div");return n.replace(/省|市|特别行政区|自治区|维吾尔自治区|回族自治区|壮族自治区/,""),t.classList.add("vis-map-label","absolute","top-1/2","left-1/2","-translate-x-1/2","-translate-y-1/2"),t.innerHTML=`
|
|
4701
4701
|
<div class="text-[#809083] text-center leading-[1] text-xs whitespace-nowrap">
|
|
4702
4702
|
${n}
|
|
4703
4703
|
</div>
|
package/dist/index.module.js
CHANGED
|
@@ -41721,23 +41721,26 @@ class VX extends X0 {
|
|
|
41721
41721
|
);
|
|
41722
41722
|
});
|
|
41723
41723
|
}
|
|
41724
|
-
|
|
41724
|
+
getPointInContinentInfo(e) {
|
|
41725
41725
|
return a9.features.find((i) => i.geometry.coordinates.some((s) => s.length ? Fm(P5(e), qo(s)) : !1));
|
|
41726
41726
|
}
|
|
41727
|
+
getPointInContinent(e) {
|
|
41728
|
+
return !!this.getPointInContinentInfo(e);
|
|
41729
|
+
}
|
|
41727
41730
|
getLocationPosition(e) {
|
|
41728
41731
|
var s;
|
|
41729
|
-
const i = (s = this.
|
|
41732
|
+
const i = (s = this.getPointInContinentInfo(e)) == null ? void 0 : s.properties.name;
|
|
41730
41733
|
if (i) {
|
|
41731
41734
|
const l = this.mapArr.find((a) => a.userData.name === i);
|
|
41732
41735
|
if (l) {
|
|
41733
|
-
const { projection: a } = l.userData, [o, c] = e, [d, r] = a([o, c]), h = new S(d, -r, 0).add(
|
|
41736
|
+
const { projection: a } = l.userData, [o, c] = e, [d, r] = a([o, c]), h = l.object3d.getWorldPosition(new S()), u = new S(d, -r, 0).add(
|
|
41734
41737
|
new S(
|
|
41735
|
-
|
|
41736
|
-
|
|
41737
|
-
|
|
41738
|
+
h.x,
|
|
41739
|
+
h.y,
|
|
41740
|
+
h.z + this.options.depth
|
|
41738
41741
|
)
|
|
41739
41742
|
);
|
|
41740
|
-
return [
|
|
41743
|
+
return [u.x, u.y, u.z];
|
|
41741
41744
|
}
|
|
41742
41745
|
}
|
|
41743
41746
|
}
|
|
@@ -10,7 +10,7 @@ export default class extends BaseObject {
|
|
|
10
10
|
mapArr: PlaneMap[];
|
|
11
11
|
constructor(options: Options);
|
|
12
12
|
create(): Promise<void>;
|
|
13
|
-
|
|
13
|
+
getPointInContinentInfo(location: [number, number]): {
|
|
14
14
|
type: string;
|
|
15
15
|
properties: {
|
|
16
16
|
name: string;
|
|
@@ -20,6 +20,7 @@ export default class extends BaseObject {
|
|
|
20
20
|
coordinates: number[][][][];
|
|
21
21
|
};
|
|
22
22
|
} | undefined;
|
|
23
|
+
getPointInContinent(location: [number, number]): boolean;
|
|
23
24
|
getLocationPosition(location: [number, number]): number[] | undefined;
|
|
24
25
|
dispose(): void;
|
|
25
26
|
}
|