Skip to content

Geojson 地理 ​

说明

用于绘制线条,支持实线、虚线。

安装 ​

sh
npm install @poggi/three-geojson
pnpm add @poggi/three-geojson
yarn add @poggi/three-geojson

基本用法 ​

loading

侧面材质动画 ​

框架提供了两种内置侧面材质动画,可自行选择

loading

边界 ​

loading

自定义子集 ​

框架提供了addChilds方法,它会返回各个行政区域对象,你可以为它添加自定义的子集,例如行政区域名称

loading

过渡动画 ​

推荐使用gsap来做动画操作

loading

交互 ​

推荐使用three.interactive进行交互

注意:three.interactive扩展了Object3D的addEventListener方法,但是TS无法正确识别,需要我们手动扩展类型说明,详细看object-interactive.d.ts

loading

API ​

Methods ​

constructor(planeMaterial: Material, options: IGeojsonConstructorOption)

构造函数

addOutline(params: IGeojsonOutlineParams)

添加轮廓

addChilds(params: IGeojsonChildParams)

添加子集

addBoundary(params: IGeojsonBoundaryParams)

添加边界

Interfaces ​

IGeojsonConstructorOption

属性名说明类型是否必选默认值
baseRenderOrder基础面渲染层级number否0
geojsongeojson数据集FeatureCollection是-
scale缩放尺寸number否80
center计算中心[number, number]否[0,0]
depth挤出深度number否1
sideType侧面材质类型SideMaterialType否ColorSweepSideMaterial
sideOption侧面材质参数IColorSweepMaterialOption | IMapSweepMaterialOption否ColorSweepSideMaterial

IColorSweepMaterialOption

属性名说明类型是否必选默认值
color1颜色1Color否#3fdef3
color2颜色2Color否#1668c6
sweepColor扫光颜色Color否#90f2ff
sweepSpeed扫光速度number否0.01
sweepLength扫光长度number否0.5
sweepInterval扫光间隔number否1

IMapSweepMaterialOption

属性名说明类型是否必选默认值
map贴图资源Texture否-
color1颜色1Color否#3fdef3
color2颜色2Color否#3fdef3
sweepSpeed扫光速度number否0.01

IGeojsonOutlineParams

属性名说明类型是否必选默认值
geojsongeojson数据集FeatureCollection是-
drawFunc绘制回调函数drawFunc: (points: number[], pointsV: Vector3[]) => void是-

IGeojsonChildParams

属性名说明类型是否必选默认值
geojsongeojson数据集FeatureCollection是-
drawFunc绘制回调函数drawFunc: (data: IDrawChild) => void是-

IDrawChild

属性名说明类型是否必选默认值
parent父级Object3D是-
center图形中心Vector3是-
centroid省会位置Vector3是-
info更多详细信息any是-

IGeojsonBoundaryParams

属性名说明类型是否必选默认值
geojsongeojson数据集FeatureCollection是-
drawFunc绘制回调函数drawFunc: (parent: Object3D, points: number[], pointsV: Vector3[]) => void是-