@poggi/three-geojson 0.0.1-alpha.1 → 0.0.1-alpha.2
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/index.js +1 -342
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,342 +1 @@
|
|
|
1
|
-
var
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
var __accessCheck = (obj, member, msg) => {
|
|
8
|
-
if (!member.has(obj))
|
|
9
|
-
throw TypeError("Cannot " + msg);
|
|
10
|
-
};
|
|
11
|
-
var __privateGet = (obj, member, getter) => {
|
|
12
|
-
__accessCheck(obj, member, "read from private field");
|
|
13
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
14
|
-
};
|
|
15
|
-
var __privateAdd = (obj, member, value) => {
|
|
16
|
-
if (member.has(obj))
|
|
17
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
18
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
19
|
-
};
|
|
20
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
21
|
-
__accessCheck(obj, member, "write to private field");
|
|
22
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
23
|
-
return value;
|
|
24
|
-
};
|
|
25
|
-
var __privateMethod = (obj, member, method) => {
|
|
26
|
-
__accessCheck(obj, member, "access private method");
|
|
27
|
-
return method;
|
|
28
|
-
};
|
|
29
|
-
var _projection, _depth, _baseRenderOrder, _getLinePoints, getLinePoints_fn, _createExtrudeMesh, createExtrudeMesh_fn;
|
|
30
|
-
import { Color, ShaderMaterial, FrontSide, MeshBasicMaterial, Object3D, Vector3, Shape, ExtrudeGeometry, Mesh } from "three";
|
|
31
|
-
import * as d3 from "d3";
|
|
32
|
-
const ColorSweepSideMaterial = 0;
|
|
33
|
-
const MapSweepSideMaterial = 1;
|
|
34
|
-
function useColorSweepSideMaterial(depth, options = {}) {
|
|
35
|
-
if (!options.sweepSpeed)
|
|
36
|
-
options.sweepSpeed = 0.01;
|
|
37
|
-
if (!options.sweepLength)
|
|
38
|
-
options.sweepLength = 0.5;
|
|
39
|
-
if (!options.sweepInterval)
|
|
40
|
-
options.sweepInterval = 1;
|
|
41
|
-
const max = depth + options.sweepInterval + options.sweepLength;
|
|
42
|
-
const uniforms = {
|
|
43
|
-
color1: {
|
|
44
|
-
value: options.color1 || new Color("#3fdef3")
|
|
45
|
-
},
|
|
46
|
-
color2: {
|
|
47
|
-
value: options.color2 || new Color("#1668c6")
|
|
48
|
-
},
|
|
49
|
-
//光带当前的位置
|
|
50
|
-
height: {
|
|
51
|
-
value: -1
|
|
52
|
-
},
|
|
53
|
-
//光带颜色
|
|
54
|
-
glowColor: {
|
|
55
|
-
value: options.sweepColor || new Color("#90f2ff")
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const material = new ShaderMaterial({
|
|
59
|
-
side: FrontSide,
|
|
60
|
-
uniforms,
|
|
61
|
-
vertexShader: `
|
|
62
|
-
varying vec2 vUv;
|
|
63
|
-
varying float v_pz;
|
|
64
|
-
void main() {
|
|
65
|
-
vUv = uv;
|
|
66
|
-
v_pz = position.z;
|
|
67
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);
|
|
68
|
-
}
|
|
69
|
-
`,
|
|
70
|
-
fragmentShader: `
|
|
71
|
-
uniform vec3 color1;
|
|
72
|
-
uniform vec3 color2;
|
|
73
|
-
varying vec2 vUv;
|
|
74
|
-
uniform float height;
|
|
75
|
-
uniform vec3 glowColor;
|
|
76
|
-
varying float v_pz;
|
|
77
|
-
float plot(float pct){
|
|
78
|
-
return smoothstep(pct - ${options.sweepLength}, pct, v_pz) - smoothstep(pct, pct + 0.02, v_pz);
|
|
79
|
-
}
|
|
80
|
-
void main() {
|
|
81
|
-
gl_FragColor = vec4(mix(color1, color2, vUv.y), 1.0);
|
|
82
|
-
|
|
83
|
-
float f1 = plot(height);
|
|
84
|
-
gl_FragColor = mix(gl_FragColor,vec4(glowColor,1),f1);
|
|
85
|
-
}
|
|
86
|
-
`
|
|
87
|
-
});
|
|
88
|
-
const render = function() {
|
|
89
|
-
uniforms.height.value += options.sweepSpeed;
|
|
90
|
-
if (uniforms.height.value > max) {
|
|
91
|
-
uniforms.height.value = -1;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
return {
|
|
95
|
-
material,
|
|
96
|
-
render
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
function useMapSweepSideMaterial(options = {}) {
|
|
100
|
-
if (!options.sweepSpeed)
|
|
101
|
-
options.sweepSpeed = 0.01;
|
|
102
|
-
const material = new MeshBasicMaterial({
|
|
103
|
-
color: 16777215,
|
|
104
|
-
map: options.map,
|
|
105
|
-
side: FrontSide
|
|
106
|
-
});
|
|
107
|
-
material.onBeforeCompile = function(shader) {
|
|
108
|
-
shader.uniforms = {
|
|
109
|
-
...shader.uniforms,
|
|
110
|
-
color1: {
|
|
111
|
-
value: options.color1 || new Color("#3fdef3")
|
|
112
|
-
},
|
|
113
|
-
color2: {
|
|
114
|
-
value: options.color2 || new Color("#3fdef3")
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
shader.vertexShader = shader.vertexShader.replace(
|
|
118
|
-
"void main() {",
|
|
119
|
-
`
|
|
120
|
-
attribute float alpha;
|
|
121
|
-
varying vec3 vPosition;
|
|
122
|
-
varying float vAlpha;
|
|
123
|
-
void main() {
|
|
124
|
-
vAlpha = alpha;
|
|
125
|
-
vPosition = position;
|
|
126
|
-
`
|
|
127
|
-
);
|
|
128
|
-
shader.fragmentShader = shader.fragmentShader.replace(
|
|
129
|
-
"void main() {",
|
|
130
|
-
`
|
|
131
|
-
varying vec3 vPosition;
|
|
132
|
-
varying float vAlpha;
|
|
133
|
-
uniform vec3 color1;
|
|
134
|
-
uniform vec3 color2;
|
|
135
|
-
void main() {
|
|
136
|
-
`
|
|
137
|
-
);
|
|
138
|
-
shader.fragmentShader = shader.fragmentShader.replace(
|
|
139
|
-
"#include <opaque_fragment>",
|
|
140
|
-
`
|
|
141
|
-
#ifdef OPAQUE
|
|
142
|
-
diffuseColor.a = 1.0;
|
|
143
|
-
#endif
|
|
144
|
-
#ifdef USE_TRANSMISSION
|
|
145
|
-
diffuseColor.a *= transmissionAlpha + 0.1;
|
|
146
|
-
#endif
|
|
147
|
-
vec3 gradient = mix(color2, color1, vPosition.z / 1.2);
|
|
148
|
-
outgoingLight = outgoingLight * gradient;
|
|
149
|
-
gl_FragColor = vec4(outgoingLight, diffuseColor.a);
|
|
150
|
-
`
|
|
151
|
-
);
|
|
152
|
-
};
|
|
153
|
-
const render = function() {
|
|
154
|
-
if (options.map) {
|
|
155
|
-
options.map.offset.y += options.sweepSpeed;
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
return {
|
|
159
|
-
material,
|
|
160
|
-
render
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
const generateUVs = function(geometry, minX, minY, dx, dy) {
|
|
164
|
-
const position = geometry.attributes.position.array;
|
|
165
|
-
const uv = geometry.attributes.uv.array;
|
|
166
|
-
const index = geometry.index;
|
|
167
|
-
const shapeGroup = geometry.groups[0];
|
|
168
|
-
const start = shapeGroup.start;
|
|
169
|
-
const count = shapeGroup.count;
|
|
170
|
-
for (let i = start; i < start + count; i++) {
|
|
171
|
-
const vertexIndex = index ? index.getX(i) : i;
|
|
172
|
-
const x = position[vertexIndex * 3];
|
|
173
|
-
const y = position[vertexIndex * 3 + 1];
|
|
174
|
-
uv[vertexIndex * 2] = (x - minX) / dx;
|
|
175
|
-
uv[vertexIndex * 2 + 1] = (y - minY) / dy;
|
|
176
|
-
}
|
|
177
|
-
geometry.attributes.uv.needsUpdate = true;
|
|
178
|
-
};
|
|
179
|
-
class Geojson extends Object3D {
|
|
180
|
-
constructor(planeMaterial, options) {
|
|
181
|
-
var _a;
|
|
182
|
-
super();
|
|
183
|
-
__privateAdd(this, _getLinePoints);
|
|
184
|
-
__privateAdd(this, _createExtrudeMesh);
|
|
185
|
-
__publicField(this, "type", "Geojson");
|
|
186
|
-
__privateAdd(this, _projection, void 0);
|
|
187
|
-
__privateAdd(this, _depth, void 0);
|
|
188
|
-
__privateAdd(this, _baseRenderOrder, void 0);
|
|
189
|
-
__publicField(this, "sideMaterialRender");
|
|
190
|
-
if (!options.center)
|
|
191
|
-
options.center = ((_a = options.geojson.features[0].properties) == null ? void 0 : _a.centroid) || [
|
|
192
|
-
0,
|
|
193
|
-
0
|
|
194
|
-
];
|
|
195
|
-
if (!options.scale)
|
|
196
|
-
options.scale = 80;
|
|
197
|
-
if (!options.depth)
|
|
198
|
-
options.depth = 1;
|
|
199
|
-
if (!options.sideType)
|
|
200
|
-
options.sideType = ColorSweepSideMaterial;
|
|
201
|
-
__privateSet(this, _baseRenderOrder, options.baseRenderOrder || 0);
|
|
202
|
-
__privateSet(this, _depth, options.depth);
|
|
203
|
-
__privateSet(this, _projection, d3.geoMercator().center(options.center).scale(options.scale).translate([0, 0]));
|
|
204
|
-
let fillMaterial;
|
|
205
|
-
if (options.sideType === ColorSweepSideMaterial) {
|
|
206
|
-
const data = useColorSweepSideMaterial(__privateGet(this, _depth), options.sideOption);
|
|
207
|
-
fillMaterial = data.material;
|
|
208
|
-
this.sideMaterialRender = data.render;
|
|
209
|
-
} else {
|
|
210
|
-
const data = useMapSweepSideMaterial(options.sideOption);
|
|
211
|
-
fillMaterial = data.material;
|
|
212
|
-
this.sideMaterialRender = data.render;
|
|
213
|
-
}
|
|
214
|
-
let globalMinX = Infinity, globalMinY = Infinity;
|
|
215
|
-
let globalMaxX = -Infinity, globalMaxY = -Infinity;
|
|
216
|
-
options.geojson.features.forEach((feature) => {
|
|
217
|
-
const coords = feature.geometry.type === "MultiPolygon" ? feature.geometry.coordinates.flat(2) : feature.geometry.coordinates.flat(1);
|
|
218
|
-
coords.forEach((p) => {
|
|
219
|
-
const [x, y] = __privateGet(this, _projection).call(this, p);
|
|
220
|
-
globalMinX = Math.min(globalMinX, x);
|
|
221
|
-
globalMinY = Math.min(globalMinY, -y);
|
|
222
|
-
globalMaxX = Math.max(globalMaxX, x);
|
|
223
|
-
globalMaxY = Math.max(globalMaxY, -y);
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
const globalDX = globalMaxX - globalMinX;
|
|
227
|
-
const globalDY = globalMaxY - globalMinY;
|
|
228
|
-
options.geojson.features.forEach((feature, idx) => {
|
|
229
|
-
var _a2, _b, _c;
|
|
230
|
-
const child = new Object3D();
|
|
231
|
-
child.name = "feature" + (((_a2 = feature.properties) == null ? void 0 : _a2.adcode) || idx);
|
|
232
|
-
child.userData.properties = feature.properties;
|
|
233
|
-
if ((_b = feature.properties) == null ? void 0 : _b.center) {
|
|
234
|
-
feature.properties.centerT = __privateGet(this, _projection).call(this, feature.properties.center);
|
|
235
|
-
}
|
|
236
|
-
if ((_c = feature.properties) == null ? void 0 : _c.centroid) {
|
|
237
|
-
feature.properties.centroidT = __privateGet(this, _projection).call(this, feature.properties.centroid);
|
|
238
|
-
}
|
|
239
|
-
if (feature.geometry.type === "MultiPolygon") {
|
|
240
|
-
feature.geometry.coordinates.forEach((coordinate) => {
|
|
241
|
-
const { mesh } = __privateMethod(this, _createExtrudeMesh, createExtrudeMesh_fn).call(this, options.depth, coordinate[0], [planeMaterial, fillMaterial], globalMinX, globalMinY, globalDX, globalDY);
|
|
242
|
-
mesh.name = "polygon";
|
|
243
|
-
child.add(mesh);
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
this.add(child);
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
// 添加轮廓
|
|
250
|
-
addOutline(params) {
|
|
251
|
-
params.geojson.features.forEach((feature) => {
|
|
252
|
-
if (feature.geometry.type === "MultiPolygon") {
|
|
253
|
-
feature.geometry.coordinates.forEach((coordinate) => {
|
|
254
|
-
const { points, pointsV } = __privateMethod(this, _getLinePoints, getLinePoints_fn).call(this, coordinate[0]);
|
|
255
|
-
params.drawFunc(points, pointsV);
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
// 添加子集
|
|
261
|
-
addChilds(params) {
|
|
262
|
-
params.geojson.features.forEach((feature, idx) => {
|
|
263
|
-
var _a, _b, _c;
|
|
264
|
-
const parent = this.getObjectByName(
|
|
265
|
-
"feature" + (((_a = feature.properties) == null ? void 0 : _a.adcode) || idx)
|
|
266
|
-
);
|
|
267
|
-
const center = ((_b = feature.properties) == null ? void 0 : _b.centerT) || [0, 0];
|
|
268
|
-
const worldCenter = new Vector3(center[0], __privateGet(this, _depth), center[1]);
|
|
269
|
-
const localCenter = parent.worldToLocal(worldCenter);
|
|
270
|
-
const centroid = ((_c = feature.properties) == null ? void 0 : _c.centroidT) || [0, 0];
|
|
271
|
-
const worldCentroid = new Vector3(centroid[0], __privateGet(this, _depth), centroid[1]);
|
|
272
|
-
const localCentroid = parent.worldToLocal(worldCentroid);
|
|
273
|
-
params.drawFunc({
|
|
274
|
-
parent,
|
|
275
|
-
center: localCenter,
|
|
276
|
-
centroid: localCentroid,
|
|
277
|
-
info: feature.properties
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
// 添加边界
|
|
282
|
-
addBoundary(params) {
|
|
283
|
-
params.geojson.features.forEach((feature, idx) => {
|
|
284
|
-
var _a;
|
|
285
|
-
const parent = this.getObjectByName(
|
|
286
|
-
"feature" + (((_a = feature.properties) == null ? void 0 : _a.adcode) || idx)
|
|
287
|
-
);
|
|
288
|
-
if (feature.geometry.type === "MultiPolygon") {
|
|
289
|
-
feature.geometry.coordinates.forEach((coordinate) => {
|
|
290
|
-
coordinate.forEach((polygon) => {
|
|
291
|
-
const { points, pointsV } = __privateMethod(this, _getLinePoints, getLinePoints_fn).call(this, polygon);
|
|
292
|
-
params.drawFunc(parent, points, pointsV);
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
_projection = new WeakMap();
|
|
300
|
-
_depth = new WeakMap();
|
|
301
|
-
_baseRenderOrder = new WeakMap();
|
|
302
|
-
_getLinePoints = new WeakSet();
|
|
303
|
-
getLinePoints_fn = function(point) {
|
|
304
|
-
const points = [], pointsV = [];
|
|
305
|
-
for (let i = 0; i < point.length; i++) {
|
|
306
|
-
const [x, y] = __privateGet(this, _projection).call(this, point[i]);
|
|
307
|
-
if (!isNaN(x) && !isNaN(y)) {
|
|
308
|
-
points.push(x, -y, __privateGet(this, _depth));
|
|
309
|
-
pointsV.push(new Vector3(x, -y, __privateGet(this, _depth)));
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return { points, pointsV };
|
|
313
|
-
};
|
|
314
|
-
_createExtrudeMesh = new WeakSet();
|
|
315
|
-
createExtrudeMesh_fn = function(depth, point, materials, minX, minY, dx, dy) {
|
|
316
|
-
const shape = new Shape();
|
|
317
|
-
const points = [];
|
|
318
|
-
for (let i = 0; i < point.length; i++) {
|
|
319
|
-
const [x, y] = __privateGet(this, _projection).call(this, point[i]);
|
|
320
|
-
if (!isNaN(x) && !isNaN(y)) {
|
|
321
|
-
if (i === 0) {
|
|
322
|
-
shape.moveTo(x, -y);
|
|
323
|
-
}
|
|
324
|
-
shape.lineTo(x, -y);
|
|
325
|
-
points.push(x, -y, depth);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
const geometry = new ExtrudeGeometry(shape, {
|
|
329
|
-
depth,
|
|
330
|
-
bevelEnabled: false
|
|
331
|
-
// 对挤出的形状应用是否斜角
|
|
332
|
-
});
|
|
333
|
-
generateUVs(geometry, minX, minY, dx, dy);
|
|
334
|
-
const mesh = new Mesh(geometry, materials);
|
|
335
|
-
mesh.renderOrder = __privateGet(this, _baseRenderOrder) + 1;
|
|
336
|
-
return { mesh, points };
|
|
337
|
-
};
|
|
338
|
-
export {
|
|
339
|
-
ColorSweepSideMaterial,
|
|
340
|
-
Geojson,
|
|
341
|
-
MapSweepSideMaterial
|
|
342
|
-
};
|
|
1
|
+
var o=Object.defineProperty,n=(n,t,i)=>(((n,t,i)=>{t in n?o(n,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[t]=i})(n,"symbol"!=typeof t?t+"":t,i),i),t=(o,n,t)=>{if(!n.has(o))throw TypeError("Cannot "+t)},i=(o,n,i)=>(t(o,n,"read from private field"),i?i.call(o):n.get(o)),e=(o,n,t)=>{if(n.has(o))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(o):n.set(o,t)},a=(o,n,i,e)=>(t(o,n,"write to private field"),e?e.call(o,i):n.set(o,i),i),r=(o,n,i)=>(t(o,n,"access private method"),i);import{Color as s,ShaderMaterial as l,FrontSide as c,MeshBasicMaterial as v,Object3D as h,Vector3 as f,Shape as d,ExtrudeGeometry as u,Mesh as p}from"three";import*as g from"d3";const m=0,w=1;var M,y,S,C,_,b,N;class P extends h{constructor(o,t){var f;let d;if(super(),e(this,C),e(this,b),n(this,"type","Geojson"),e(this,M,void 0),e(this,y,void 0),e(this,S,void 0),n(this,"sideMaterialRender"),t.center||(t.center=(null==(f=t.geojson.features[0].properties)?void 0:f.centroid)||[0,0]),t.scale||(t.scale=80),t.depth||(t.depth=1),t.sideType||(t.sideType=0),a(this,S,t.baseRenderOrder||0),a(this,y,t.depth),a(this,M,g.geoMercator().center(t.center).scale(t.scale).translate([0,0])),0===t.sideType){const o=function(o,n={}){n.sweepSpeed||(n.sweepSpeed=.01),n.sweepLength||(n.sweepLength=.5),n.sweepInterval||(n.sweepInterval=1);const t=o+n.sweepInterval+n.sweepLength,i={color1:{value:n.color1||new s("#3fdef3")},color2:{value:n.color2||new s("#1668c6")},height:{value:-1},glowColor:{value:n.sweepColor||new s("#90f2ff")}};return{material:new l({side:c,uniforms:i,vertexShader:"\n varying vec2 vUv;\n varying float v_pz;\n void main() {\n vUv = uv;\n v_pz = position.z;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);\n }\n ",fragmentShader:`\n uniform vec3 color1;\n uniform vec3 color2;\n varying vec2 vUv;\n uniform float height;\n uniform vec3 glowColor;\n varying float v_pz;\n float plot(float pct){\n return smoothstep(pct - ${n.sweepLength}, pct, v_pz) - smoothstep(pct, pct + 0.02, v_pz);\n }\n void main() {\n gl_FragColor = vec4(mix(color1, color2, vUv.y), 1.0);\n\n float f1 = plot(height);\n gl_FragColor = mix(gl_FragColor,vec4(glowColor,1),f1);\n }\n `}),render:function(){i.height.value+=n.sweepSpeed,i.height.value>t&&(i.height.value=-1)}}}(i(this,y),t.sideOption);d=o.material,this.sideMaterialRender=o.render}else{const o=function(o={}){o.sweepSpeed||(o.sweepSpeed=.01);const n=new v({color:16777215,map:o.map,side:c});return n.onBeforeCompile=function(n){n.uniforms={...n.uniforms,color1:{value:o.color1||new s("#3fdef3")},color2:{value:o.color2||new s("#3fdef3")}},n.vertexShader=n.vertexShader.replace("void main() {","\n attribute float alpha;\n varying vec3 vPosition;\n varying float vAlpha;\n void main() {\n vAlpha = alpha;\n vPosition = position;\n "),n.fragmentShader=n.fragmentShader.replace("void main() {","\n varying vec3 vPosition;\n varying float vAlpha;\n uniform vec3 color1;\n uniform vec3 color2;\n void main() {\n "),n.fragmentShader=n.fragmentShader.replace("#include <opaque_fragment>","\n #ifdef OPAQUE\n diffuseColor.a = 1.0;\n #endif\n #ifdef USE_TRANSMISSION\n diffuseColor.a *= transmissionAlpha + 0.1;\n #endif\n vec3 gradient = mix(color2, color1, vPosition.z / 1.2);\n outgoingLight = outgoingLight * gradient;\n gl_FragColor = vec4(outgoingLight, diffuseColor.a);\n ")},{material:n,render:function(){o.map&&(o.map.offset.y+=o.sweepSpeed)}}}(t.sideOption);d=o.material,this.sideMaterialRender=o.render}let u=1/0,p=1/0,m=-1/0,w=-1/0;t.geojson.features.forEach(o=>{("MultiPolygon"===o.geometry.type?o.geometry.coordinates.flat(2):o.geometry.coordinates.flat(1)).forEach(o=>{const[n,t]=i(this,M).call(this,o);u=Math.min(u,n),p=Math.min(p,-t),m=Math.max(m,n),w=Math.max(w,-t)})});const _=m-u,P=w-p;t.geojson.features.forEach((n,e)=>{var a,s,l;const c=new h;c.name="feature"+((null==(a=n.properties)?void 0:a.adcode)||e),c.userData.properties=n.properties,null!=(s=n.properties)&&s.center&&(n.properties.centerT=i(this,M).call(this,n.properties.center)),null!=(l=n.properties)&&l.centroid&&(n.properties.centroidT=i(this,M).call(this,n.properties.centroid)),"MultiPolygon"===n.geometry.type&&n.geometry.coordinates.forEach(n=>{const{mesh:i}=r(this,b,N).call(this,t.depth,n[0],[o,d],u,p,_,P);i.name="polygon",c.add(i)}),this.add(c)})}addOutline(o){o.geojson.features.forEach(n=>{"MultiPolygon"===n.geometry.type&&n.geometry.coordinates.forEach(n=>{const{points:t,pointsV:i}=r(this,C,_).call(this,n[0]);o.drawFunc(t,i)})})}addChilds(o){o.geojson.features.forEach((n,t)=>{var e,a,r;const s=this.getObjectByName("feature"+((null==(e=n.properties)?void 0:e.adcode)||t)),l=(null==(a=n.properties)?void 0:a.centerT)||[0,0],c=new f(l[0],i(this,y),l[1]),v=s.worldToLocal(c),h=(null==(r=n.properties)?void 0:r.centroidT)||[0,0],d=new f(h[0],i(this,y),h[1]),u=s.worldToLocal(d);o.drawFunc({parent:s,center:v,centroid:u,info:n.properties})})}addBoundary(o){o.geojson.features.forEach((n,t)=>{var i;const e=this.getObjectByName("feature"+((null==(i=n.properties)?void 0:i.adcode)||t));"MultiPolygon"===n.geometry.type&&n.geometry.coordinates.forEach(n=>{n.forEach(n=>{const{points:t,pointsV:i}=r(this,C,_).call(this,n);o.drawFunc(e,t,i)})})})}}M=new WeakMap,y=new WeakMap,S=new WeakMap,C=new WeakSet,_=function(o){const n=[],t=[];for(let e=0;e<o.length;e++){const[a,r]=i(this,M).call(this,o[e]);!isNaN(a)&&!isNaN(r)&&(n.push(a,-r,i(this,y)),t.push(new f(a,-r,i(this,y))))}return{points:n,pointsV:t}},b=new WeakSet,N=function(o,n,t,e,a,r,s){const l=new d,c=[];for(let t=0;t<n.length;t++){const[e,a]=i(this,M).call(this,n[t]);!isNaN(e)&&!isNaN(a)&&(0===t&&l.moveTo(e,-a),l.lineTo(e,-a),c.push(e,-a,o))}const v=new u(l,{depth:o,bevelEnabled:!1});!function(o,n,t,i,e){const a=o.attributes.position.array,r=o.attributes.uv.array,s=o.index,l=o.groups[0],c=l.start,v=l.count;for(let o=c;o<c+v;o++){const l=s?s.getX(o):o,c=a[3*l],v=a[3*l+1];r[2*l]=(c-n)/i,r[2*l+1]=(v-t)/e}o.attributes.uv.needsUpdate=!0}(v,e,a,r,s);const h=new p(v,t);return h.renderOrder=i(this,S)+1,{mesh:h,points:c}};export{m as ColorSweepSideMaterial,P as Geojson,w as MapSweepSideMaterial};
|