@deck.gl/extensions 9.4.0-beta.3 → 9.4.0-beta.4
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.cjs +142 -2732
- package/dist/index.cjs.map +3 -3
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -15,7 +14,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
14
|
}
|
|
16
15
|
return to;
|
|
17
16
|
};
|
|
18
|
-
var __toCommonJS = (
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
18
|
|
|
20
19
|
// dist/index.js
|
|
21
20
|
var index_exports = {};
|
|
@@ -33,2640 +32,11 @@ __export(index_exports, {
|
|
|
33
32
|
});
|
|
34
33
|
module.exports = __toCommonJS(index_exports);
|
|
35
34
|
|
|
36
|
-
//
|
|
37
|
-
var
|
|
38
|
-
var defaultLogger = new import_log.Log({ id: "deck" });
|
|
39
|
-
var log_default = defaultLogger;
|
|
40
|
-
|
|
41
|
-
// ../core/src/shaderlib/index.ts
|
|
42
|
-
var import_shadertools2 = require("@luma.gl/shadertools");
|
|
43
|
-
|
|
44
|
-
// ../core/src/shaderlib/misc/geometry.ts
|
|
45
|
-
var source = (
|
|
46
|
-
/* wgsl */
|
|
47
|
-
`const SMOOTH_EDGE_RADIUS: f32 = 0.5;
|
|
48
|
-
|
|
49
|
-
struct VertexGeometry {
|
|
50
|
-
position: vec4<f32>,
|
|
51
|
-
worldPosition: vec3<f32>,
|
|
52
|
-
worldPositionAlt: vec3<f32>,
|
|
53
|
-
normal: vec3<f32>,
|
|
54
|
-
uv: vec2<f32>,
|
|
55
|
-
pickingColor: vec3<f32>,
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
var<private> geometry_: VertexGeometry = VertexGeometry(
|
|
59
|
-
vec4<f32>(0.0, 0.0, 1.0, 0.0),
|
|
60
|
-
vec3<f32>(0.0, 0.0, 0.0),
|
|
61
|
-
vec3<f32>(0.0, 0.0, 0.0),
|
|
62
|
-
vec3<f32>(0.0, 0.0, 0.0),
|
|
63
|
-
vec2<f32>(0.0, 0.0),
|
|
64
|
-
vec3<f32>(0.0, 0.0, 0.0)
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
struct FragmentGeometry {
|
|
68
|
-
uv: vec2<f32>,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
var<private> fragmentGeometry: FragmentGeometry;
|
|
72
|
-
|
|
73
|
-
fn smoothedge(edge: f32, x: f32) -> f32 {
|
|
74
|
-
return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
|
|
75
|
-
}
|
|
76
|
-
`
|
|
77
|
-
);
|
|
78
|
-
var defines = "#define SMOOTH_EDGE_RADIUS 0.5";
|
|
79
|
-
var vs = (
|
|
80
|
-
/* glsl */
|
|
81
|
-
`${defines}
|
|
82
|
-
|
|
83
|
-
struct VertexGeometry {
|
|
84
|
-
vec4 position;
|
|
85
|
-
vec3 worldPosition;
|
|
86
|
-
vec3 worldPositionAlt;
|
|
87
|
-
vec3 normal;
|
|
88
|
-
vec2 uv;
|
|
89
|
-
vec3 pickingColor;
|
|
90
|
-
} geometry = VertexGeometry(
|
|
91
|
-
vec4(0.0, 0.0, 1.0, 0.0),
|
|
92
|
-
vec3(0.0),
|
|
93
|
-
vec3(0.0),
|
|
94
|
-
vec3(0.0),
|
|
95
|
-
vec2(0.0),
|
|
96
|
-
vec3(0.0)
|
|
97
|
-
);
|
|
98
|
-
`
|
|
99
|
-
);
|
|
100
|
-
var fs = (
|
|
101
|
-
/* glsl */
|
|
102
|
-
`${defines}
|
|
103
|
-
|
|
104
|
-
struct FragmentGeometry {
|
|
105
|
-
vec2 uv;
|
|
106
|
-
};
|
|
107
|
-
FragmentGeometry geometry;
|
|
108
|
-
|
|
109
|
-
float smoothedge(float edge, float x) {
|
|
110
|
-
return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
|
|
111
|
-
}
|
|
112
|
-
`
|
|
113
|
-
);
|
|
114
|
-
var geometry_default = {
|
|
115
|
-
name: "geometry",
|
|
116
|
-
source,
|
|
117
|
-
vs,
|
|
118
|
-
fs
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
// ../core/src/shaderlib/project/project.ts
|
|
122
|
-
var import_shadertools = require("@luma.gl/shadertools");
|
|
123
|
-
|
|
124
|
-
// ../core/src/shaderlib/project/viewport-uniforms.ts
|
|
125
|
-
var import_core = require("@math.gl/core");
|
|
126
|
-
|
|
127
|
-
// ../core/src/lib/constants.ts
|
|
128
|
-
var import_mjolnir = require("mjolnir.js");
|
|
129
|
-
var COORDINATE_SYSTEM = {
|
|
130
|
-
/**
|
|
131
|
-
* `LNGLAT` if rendering into a geospatial viewport, `CARTESIAN` otherwise
|
|
132
|
-
*/
|
|
133
|
-
DEFAULT: "default",
|
|
134
|
-
/**
|
|
135
|
-
* Positions are interpreted as [longitude, latitude, elevation]
|
|
136
|
-
* longitude/latitude are in degrees, elevation is in meters.
|
|
137
|
-
* Dimensions are in meters.
|
|
138
|
-
*/
|
|
139
|
-
LNGLAT: "lnglat",
|
|
140
|
-
/**
|
|
141
|
-
* Positions are interpreted as [x, y, z] in meter offsets from the coordinate origin.
|
|
142
|
-
* Dimensions are in meters.
|
|
143
|
-
*/
|
|
144
|
-
METER_OFFSETS: "meter-offsets",
|
|
145
|
-
/**
|
|
146
|
-
* Positions are interpreted as [deltaLng, deltaLat, elevation] from the coordinate origin.
|
|
147
|
-
* deltaLng/deltaLat are in degrees, elevation is in meters.
|
|
148
|
-
* Dimensions are in meters.
|
|
149
|
-
*/
|
|
150
|
-
LNGLAT_OFFSETS: "lnglat-offsets",
|
|
151
|
-
/**
|
|
152
|
-
* Positions and dimensions are in the common units of the viewport.
|
|
153
|
-
*/
|
|
154
|
-
CARTESIAN: "cartesian"
|
|
155
|
-
};
|
|
156
|
-
Object.defineProperty(COORDINATE_SYSTEM, "IDENTITY", {
|
|
157
|
-
get: () => {
|
|
158
|
-
log_default.deprecated("COORDINATE_SYSTEM.IDENTITY", "COORDINATE_SYSTEM.CARTESIAN")();
|
|
159
|
-
return COORDINATE_SYSTEM.CARTESIAN;
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
var PROJECTION_MODE = {
|
|
163
|
-
/**
|
|
164
|
-
* Render geospatial data in Web Mercator projection
|
|
165
|
-
*/
|
|
166
|
-
WEB_MERCATOR: 1,
|
|
167
|
-
/**
|
|
168
|
-
* Render geospatial data as a 3D globe
|
|
169
|
-
*/
|
|
170
|
-
GLOBE: 2,
|
|
171
|
-
/**
|
|
172
|
-
* (Internal use only) Web Mercator projection at high zoom
|
|
173
|
-
*/
|
|
174
|
-
WEB_MERCATOR_AUTO_OFFSET: 4,
|
|
175
|
-
/**
|
|
176
|
-
* No transformation
|
|
177
|
-
*/
|
|
178
|
-
IDENTITY: 0
|
|
179
|
-
};
|
|
180
|
-
var UNIT = {
|
|
181
|
-
common: 0,
|
|
182
|
-
meters: 1,
|
|
183
|
-
pixels: 2
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
// ../core/src/utils/memoize.ts
|
|
187
|
-
function isEqual(a, b) {
|
|
188
|
-
if (a === b) {
|
|
189
|
-
return true;
|
|
190
|
-
}
|
|
191
|
-
if (Array.isArray(a)) {
|
|
192
|
-
const len = a.length;
|
|
193
|
-
if (!b || b.length !== len) {
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
for (let i = 0; i < len; i++) {
|
|
197
|
-
if (a[i] !== b[i]) {
|
|
198
|
-
return false;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return true;
|
|
202
|
-
}
|
|
203
|
-
return false;
|
|
204
|
-
}
|
|
205
|
-
function memoize(compute) {
|
|
206
|
-
let cachedArgs = {};
|
|
207
|
-
let cachedResult;
|
|
208
|
-
return (args) => {
|
|
209
|
-
for (const key in args) {
|
|
210
|
-
if (!isEqual(args[key], cachedArgs[key])) {
|
|
211
|
-
cachedResult = compute(args);
|
|
212
|
-
cachedArgs = args;
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return cachedResult;
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// ../core/src/shaderlib/project/viewport-uniforms.ts
|
|
221
|
-
var ZERO_VECTOR = [0, 0, 0, 0];
|
|
222
|
-
var VECTOR_TO_POINT_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0];
|
|
223
|
-
var IDENTITY_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
224
|
-
var DEFAULT_PIXELS_PER_UNIT2 = [0, 0, 0];
|
|
225
|
-
var DEFAULT_COORDINATE_ORIGIN = [0, 0, 0];
|
|
226
|
-
var COORDINATE_SYSTEM_NUMBERS = {
|
|
227
|
-
default: -1,
|
|
228
|
-
cartesian: 0,
|
|
229
|
-
lnglat: 1,
|
|
230
|
-
"meter-offsets": 2,
|
|
231
|
-
"lnglat-offsets": 3
|
|
232
|
-
};
|
|
233
|
-
function getShaderCoordinateSystem(coordinateSystem) {
|
|
234
|
-
const shaderCoordinateSystem = COORDINATE_SYSTEM_NUMBERS[coordinateSystem];
|
|
235
|
-
if (shaderCoordinateSystem === void 0) {
|
|
236
|
-
throw new Error(`Invalid coordinateSystem: ${coordinateSystem}`);
|
|
237
|
-
}
|
|
238
|
-
return shaderCoordinateSystem;
|
|
239
|
-
}
|
|
240
|
-
var getMemoizedViewportUniforms = memoize(calculateViewportUniforms);
|
|
241
|
-
function getOffsetOrigin(viewport, coordinateSystem, coordinateOrigin = DEFAULT_COORDINATE_ORIGIN) {
|
|
242
|
-
if (coordinateOrigin.length < 3) {
|
|
243
|
-
coordinateOrigin = [coordinateOrigin[0], coordinateOrigin[1], 0];
|
|
244
|
-
}
|
|
245
|
-
let shaderCoordinateOrigin = coordinateOrigin;
|
|
246
|
-
let geospatialOrigin;
|
|
247
|
-
let offsetMode = true;
|
|
248
|
-
if (coordinateSystem === "lnglat-offsets" || coordinateSystem === "meter-offsets") {
|
|
249
|
-
geospatialOrigin = coordinateOrigin;
|
|
250
|
-
} else {
|
|
251
|
-
geospatialOrigin = viewport.isGeospatial ? (
|
|
252
|
-
// @ts-expect-error longitude and latitude are not defined on the base Viewport, but is expected on geospatial viewports
|
|
253
|
-
[Math.fround(viewport.longitude), Math.fround(viewport.latitude), 0]
|
|
254
|
-
) : null;
|
|
255
|
-
}
|
|
256
|
-
switch (viewport.projectionMode) {
|
|
257
|
-
case PROJECTION_MODE.WEB_MERCATOR:
|
|
258
|
-
if (coordinateSystem === "lnglat" || coordinateSystem === "cartesian") {
|
|
259
|
-
geospatialOrigin = [0, 0, 0];
|
|
260
|
-
offsetMode = false;
|
|
261
|
-
}
|
|
262
|
-
break;
|
|
263
|
-
case PROJECTION_MODE.WEB_MERCATOR_AUTO_OFFSET:
|
|
264
|
-
if (coordinateSystem === "lnglat") {
|
|
265
|
-
shaderCoordinateOrigin = geospatialOrigin;
|
|
266
|
-
} else if (coordinateSystem === "cartesian") {
|
|
267
|
-
shaderCoordinateOrigin = [
|
|
268
|
-
Math.fround(viewport.center[0]),
|
|
269
|
-
Math.fround(viewport.center[1]),
|
|
270
|
-
0
|
|
271
|
-
];
|
|
272
|
-
geospatialOrigin = viewport.unprojectPosition(shaderCoordinateOrigin);
|
|
273
|
-
shaderCoordinateOrigin[0] -= coordinateOrigin[0];
|
|
274
|
-
shaderCoordinateOrigin[1] -= coordinateOrigin[1];
|
|
275
|
-
shaderCoordinateOrigin[2] -= coordinateOrigin[2];
|
|
276
|
-
}
|
|
277
|
-
break;
|
|
278
|
-
case PROJECTION_MODE.IDENTITY:
|
|
279
|
-
shaderCoordinateOrigin = viewport.position.map(Math.fround);
|
|
280
|
-
shaderCoordinateOrigin[2] = shaderCoordinateOrigin[2] || 0;
|
|
281
|
-
break;
|
|
282
|
-
case PROJECTION_MODE.GLOBE:
|
|
283
|
-
offsetMode = false;
|
|
284
|
-
geospatialOrigin = null;
|
|
285
|
-
break;
|
|
286
|
-
default:
|
|
287
|
-
offsetMode = false;
|
|
288
|
-
}
|
|
289
|
-
return { geospatialOrigin, shaderCoordinateOrigin, offsetMode };
|
|
290
|
-
}
|
|
291
|
-
function calculateMatrixAndOffset(viewport, coordinateSystem, coordinateOrigin) {
|
|
292
|
-
const { viewMatrixUncentered, projectionMatrix } = viewport;
|
|
293
|
-
let { viewMatrix: viewMatrix2, viewProjectionMatrix } = viewport;
|
|
294
|
-
let projectionCenter = ZERO_VECTOR;
|
|
295
|
-
let originCommon = ZERO_VECTOR;
|
|
296
|
-
let cameraPosCommon = viewport.cameraPosition;
|
|
297
|
-
const { geospatialOrigin, shaderCoordinateOrigin, offsetMode } = getOffsetOrigin(
|
|
298
|
-
viewport,
|
|
299
|
-
coordinateSystem,
|
|
300
|
-
coordinateOrigin
|
|
301
|
-
);
|
|
302
|
-
if (offsetMode) {
|
|
303
|
-
originCommon = viewport.projectPosition(geospatialOrigin || shaderCoordinateOrigin);
|
|
304
|
-
cameraPosCommon = [
|
|
305
|
-
cameraPosCommon[0] - originCommon[0],
|
|
306
|
-
cameraPosCommon[1] - originCommon[1],
|
|
307
|
-
cameraPosCommon[2] - originCommon[2]
|
|
308
|
-
];
|
|
309
|
-
originCommon[3] = 1;
|
|
310
|
-
projectionCenter = import_core.vec4.transformMat4([], originCommon, viewProjectionMatrix);
|
|
311
|
-
viewMatrix2 = viewMatrixUncentered || viewMatrix2;
|
|
312
|
-
viewProjectionMatrix = import_core.mat4.multiply([], projectionMatrix, viewMatrix2);
|
|
313
|
-
viewProjectionMatrix = import_core.mat4.multiply([], viewProjectionMatrix, VECTOR_TO_POINT_MATRIX);
|
|
314
|
-
}
|
|
315
|
-
return {
|
|
316
|
-
viewMatrix: viewMatrix2,
|
|
317
|
-
viewProjectionMatrix,
|
|
318
|
-
projectionCenter,
|
|
319
|
-
originCommon,
|
|
320
|
-
cameraPosCommon,
|
|
321
|
-
shaderCoordinateOrigin,
|
|
322
|
-
geospatialOrigin
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
function getUniformsFromViewport({
|
|
326
|
-
viewport,
|
|
327
|
-
devicePixelRatio = 1,
|
|
328
|
-
modelMatrix = null,
|
|
329
|
-
// Match Layer.defaultProps
|
|
330
|
-
coordinateSystem = "default",
|
|
331
|
-
coordinateOrigin = DEFAULT_COORDINATE_ORIGIN,
|
|
332
|
-
autoWrapLongitude = false
|
|
333
|
-
}) {
|
|
334
|
-
if (coordinateSystem === "default") {
|
|
335
|
-
coordinateSystem = viewport.isGeospatial ? "lnglat" : "cartesian";
|
|
336
|
-
}
|
|
337
|
-
const uniforms = getMemoizedViewportUniforms({
|
|
338
|
-
viewport,
|
|
339
|
-
devicePixelRatio,
|
|
340
|
-
coordinateSystem,
|
|
341
|
-
coordinateOrigin
|
|
342
|
-
});
|
|
343
|
-
uniforms.wrapLongitude = autoWrapLongitude;
|
|
344
|
-
uniforms.modelMatrix = modelMatrix || IDENTITY_MATRIX;
|
|
345
|
-
return uniforms;
|
|
346
|
-
}
|
|
347
|
-
function calculateViewportUniforms({
|
|
348
|
-
viewport,
|
|
349
|
-
devicePixelRatio,
|
|
350
|
-
coordinateSystem,
|
|
351
|
-
coordinateOrigin
|
|
352
|
-
}) {
|
|
353
|
-
const {
|
|
354
|
-
projectionCenter,
|
|
355
|
-
viewProjectionMatrix,
|
|
356
|
-
originCommon,
|
|
357
|
-
cameraPosCommon,
|
|
358
|
-
shaderCoordinateOrigin,
|
|
359
|
-
geospatialOrigin
|
|
360
|
-
} = calculateMatrixAndOffset(viewport, coordinateSystem, coordinateOrigin);
|
|
361
|
-
const distanceScales = viewport.getDistanceScales();
|
|
362
|
-
const viewportSize = [
|
|
363
|
-
viewport.width * devicePixelRatio,
|
|
364
|
-
viewport.height * devicePixelRatio
|
|
365
|
-
];
|
|
366
|
-
const focalDistance = import_core.vec4.transformMat4([], [0, 0, -viewport.focalDistance, 1], viewport.projectionMatrix)[3] || 1;
|
|
367
|
-
const uniforms = {
|
|
368
|
-
// Projection mode values
|
|
369
|
-
coordinateSystem: getShaderCoordinateSystem(coordinateSystem),
|
|
370
|
-
projectionMode: viewport.projectionMode,
|
|
371
|
-
coordinateOrigin: shaderCoordinateOrigin,
|
|
372
|
-
commonOrigin: originCommon.slice(0, 3),
|
|
373
|
-
center: projectionCenter,
|
|
374
|
-
// Backward compatibility
|
|
375
|
-
// TODO: remove in v9
|
|
376
|
-
// @ts-expect-error _pseudoMeters is only defined on WebMercator viewport
|
|
377
|
-
pseudoMeters: Boolean(viewport._pseudoMeters),
|
|
378
|
-
// Screen size
|
|
379
|
-
viewportSize,
|
|
380
|
-
devicePixelRatio,
|
|
381
|
-
focalDistance,
|
|
382
|
-
commonUnitsPerMeter: distanceScales.unitsPerMeter,
|
|
383
|
-
commonUnitsPerWorldUnit: distanceScales.unitsPerMeter,
|
|
384
|
-
commonUnitsPerWorldUnit2: DEFAULT_PIXELS_PER_UNIT2,
|
|
385
|
-
scale: viewport.scale,
|
|
386
|
-
// This is the mercator scale (2 ** zoom)
|
|
387
|
-
wrapLongitude: false,
|
|
388
|
-
viewProjectionMatrix,
|
|
389
|
-
modelMatrix: IDENTITY_MATRIX,
|
|
390
|
-
// This is for lighting calculations
|
|
391
|
-
cameraPosition: cameraPosCommon
|
|
392
|
-
};
|
|
393
|
-
if (geospatialOrigin) {
|
|
394
|
-
const distanceScalesAtOrigin = viewport.getDistanceScales(geospatialOrigin);
|
|
395
|
-
switch (coordinateSystem) {
|
|
396
|
-
case "meter-offsets":
|
|
397
|
-
uniforms.commonUnitsPerWorldUnit = distanceScalesAtOrigin.unitsPerMeter;
|
|
398
|
-
uniforms.commonUnitsPerWorldUnit2 = distanceScalesAtOrigin.unitsPerMeter2;
|
|
399
|
-
break;
|
|
400
|
-
case "lnglat":
|
|
401
|
-
case "lnglat-offsets":
|
|
402
|
-
if (!viewport._pseudoMeters) {
|
|
403
|
-
uniforms.commonUnitsPerMeter = distanceScalesAtOrigin.unitsPerMeter;
|
|
404
|
-
}
|
|
405
|
-
uniforms.commonUnitsPerWorldUnit = distanceScalesAtOrigin.unitsPerDegree;
|
|
406
|
-
uniforms.commonUnitsPerWorldUnit2 = distanceScalesAtOrigin.unitsPerDegree2;
|
|
407
|
-
break;
|
|
408
|
-
// a.k.a "preprojected" positions
|
|
409
|
-
case "cartesian":
|
|
410
|
-
uniforms.commonUnitsPerWorldUnit = [1, 1, distanceScalesAtOrigin.unitsPerMeter[2]];
|
|
411
|
-
uniforms.commonUnitsPerWorldUnit2 = [0, 0, distanceScalesAtOrigin.unitsPerMeter2[2]];
|
|
412
|
-
break;
|
|
413
|
-
default:
|
|
414
|
-
break;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
if (viewport.projectionMode === PROJECTION_MODE.GLOBE && coordinateSystem === "meter-offsets") {
|
|
418
|
-
const EARTH_RADIUS2 = 6370972;
|
|
419
|
-
const GLOBE_RADIUS2 = 256;
|
|
420
|
-
const lambda = coordinateOrigin[0] * Math.PI / 180;
|
|
421
|
-
const phi = coordinateOrigin[1] * Math.PI / 180;
|
|
422
|
-
const cosPhi = Math.cos(phi);
|
|
423
|
-
const D = ((coordinateOrigin[2] || 0) / EARTH_RADIUS2 + 1) * GLOBE_RADIUS2;
|
|
424
|
-
uniforms.commonOrigin = [
|
|
425
|
-
Math.sin(lambda) * cosPhi * D,
|
|
426
|
-
-Math.cos(lambda) * cosPhi * D,
|
|
427
|
-
Math.sin(phi) * D
|
|
428
|
-
];
|
|
429
|
-
}
|
|
430
|
-
return uniforms;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
// ../core/src/shaderlib/project/project.wgsl.ts
|
|
434
|
-
var SHADER_COORDINATE_SYSTEMS = [
|
|
435
|
-
"default",
|
|
436
|
-
"lnglat",
|
|
437
|
-
"meter-offsets",
|
|
438
|
-
"lnglat-offsets",
|
|
439
|
-
"cartesian"
|
|
440
|
-
];
|
|
441
|
-
var COORDINATE_SYSTEM_WGSL_CONSTANTS = SHADER_COORDINATE_SYSTEMS.map(
|
|
442
|
-
(coordinateSystem) => `const COORDINATE_SYSTEM_${coordinateSystem.toUpperCase().replaceAll("-", "_")}: i32 = ${getShaderCoordinateSystem(coordinateSystem)};`
|
|
443
|
-
).join("");
|
|
444
|
-
var PROJECTION_MODE_WGSL_CONSTANTS = Object.keys(PROJECTION_MODE).map((key) => `const PROJECTION_MODE_${key}: i32 = ${PROJECTION_MODE[key]};`).join("");
|
|
445
|
-
var UNIT_WGSL_CONSTANTS = Object.keys(UNIT).map((key) => `const UNIT_${key.toUpperCase()}: i32 = ${UNIT[key]};`).join("");
|
|
446
|
-
var projectWGSLHeader = (
|
|
447
|
-
/* wgsl */
|
|
448
|
-
`${COORDINATE_SYSTEM_WGSL_CONSTANTS}
|
|
449
|
-
${PROJECTION_MODE_WGSL_CONSTANTS}
|
|
450
|
-
${UNIT_WGSL_CONSTANTS}
|
|
451
|
-
|
|
452
|
-
const TILE_SIZE: f32 = 512.0;
|
|
453
|
-
const PI: f32 = 3.1415926536;
|
|
454
|
-
const WORLD_SCALE: f32 = TILE_SIZE / (PI * 2.0);
|
|
455
|
-
const ZERO_64_LOW: vec3<f32> = vec3<f32>(0.0, 0.0, 0.0);
|
|
456
|
-
const EARTH_RADIUS: f32 = 6370972.0; // meters
|
|
457
|
-
const GLOBE_RADIUS: f32 = 256.0;
|
|
458
|
-
|
|
459
|
-
// -----------------------------------------------------------------------------
|
|
460
|
-
// Uniform block (converted from GLSL uniform block)
|
|
461
|
-
// -----------------------------------------------------------------------------
|
|
462
|
-
struct ProjectUniforms {
|
|
463
|
-
wrapLongitude: i32,
|
|
464
|
-
coordinateSystem: i32,
|
|
465
|
-
commonUnitsPerMeter: vec3<f32>,
|
|
466
|
-
projectionMode: i32,
|
|
467
|
-
scale: f32,
|
|
468
|
-
commonUnitsPerWorldUnit: vec3<f32>,
|
|
469
|
-
commonUnitsPerWorldUnit2: vec3<f32>,
|
|
470
|
-
center: vec4<f32>,
|
|
471
|
-
modelMatrix: mat4x4<f32>,
|
|
472
|
-
viewProjectionMatrix: mat4x4<f32>,
|
|
473
|
-
viewportSize: vec2<f32>,
|
|
474
|
-
devicePixelRatio: f32,
|
|
475
|
-
focalDistance: f32,
|
|
476
|
-
cameraPosition: vec3<f32>,
|
|
477
|
-
coordinateOrigin: vec3<f32>,
|
|
478
|
-
commonOrigin: vec3<f32>,
|
|
479
|
-
pseudoMeters: i32,
|
|
480
|
-
};
|
|
481
|
-
|
|
482
|
-
@group(0) @binding(auto)
|
|
483
|
-
var<uniform> project: ProjectUniforms;
|
|
484
|
-
|
|
485
|
-
// -----------------------------------------------------------------------------
|
|
486
|
-
// Geometry data shared across the project helpers.
|
|
487
|
-
// The active layer shader is responsible for populating this private module
|
|
488
|
-
// state before calling the project functions below.
|
|
489
|
-
// -----------------------------------------------------------------------------
|
|
490
|
-
|
|
491
|
-
// Structure to carry additional geometry data used by deck.gl filters.
|
|
492
|
-
struct Geometry {
|
|
493
|
-
worldPosition: vec3<f32>,
|
|
494
|
-
worldPositionAlt: vec3<f32>,
|
|
495
|
-
position: vec4<f32>,
|
|
496
|
-
normal: vec3<f32>,
|
|
497
|
-
uv: vec2<f32>,
|
|
498
|
-
pickingColor: vec3<f32>,
|
|
499
|
-
};
|
|
500
|
-
|
|
501
|
-
var<private> geometry: Geometry;
|
|
502
|
-
`
|
|
503
|
-
);
|
|
504
|
-
var projectWGSL = (
|
|
505
|
-
/* wgsl */
|
|
506
|
-
`${projectWGSLHeader}
|
|
507
|
-
|
|
508
|
-
// -----------------------------------------------------------------------------
|
|
509
|
-
// Functions
|
|
510
|
-
// -----------------------------------------------------------------------------
|
|
511
|
-
|
|
512
|
-
// Returns an adjustment factor for commonUnitsPerMeter
|
|
513
|
-
fn _project_size_at_latitude(lat: f32) -> f32 {
|
|
514
|
-
let y = clamp(lat, -89.9, 89.9);
|
|
515
|
-
return 1.0 / cos(radians(y));
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
// Overloaded version: scales a value in meters at a given latitude.
|
|
519
|
-
fn _project_size_at_latitude_m(meters: f32, lat: f32) -> f32 {
|
|
520
|
-
return meters * project.commonUnitsPerMeter.z * _project_size_at_latitude(lat);
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
// Computes a non-linear scale factor based on geometry.
|
|
524
|
-
// (Note: This function relies on "geometry" being provided.)
|
|
525
|
-
fn project_size() -> f32 {
|
|
526
|
-
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR &&
|
|
527
|
-
project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT &&
|
|
528
|
-
project.pseudoMeters == 0) {
|
|
529
|
-
if (geometry.position.w == 0.0) {
|
|
530
|
-
return _project_size_at_latitude(geometry.worldPosition.y);
|
|
531
|
-
}
|
|
532
|
-
let y: f32 = geometry.position.y / TILE_SIZE * 2.0 - 1.0;
|
|
533
|
-
let y2 = y * y;
|
|
534
|
-
let y4 = y2 * y2;
|
|
535
|
-
let y6 = y4 * y2;
|
|
536
|
-
return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;
|
|
537
|
-
}
|
|
538
|
-
return 1.0;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
// Overloads to scale offsets (meters to world units)
|
|
542
|
-
fn project_size_float(meters: f32) -> f32 {
|
|
543
|
-
return meters * project.commonUnitsPerMeter.z * project_size();
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
fn project_size_vec2(meters: vec2<f32>) -> vec2<f32> {
|
|
547
|
-
return meters * project.commonUnitsPerMeter.xy * project_size();
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
fn project_size_vec3(meters: vec3<f32>) -> vec3<f32> {
|
|
551
|
-
return meters * project.commonUnitsPerMeter * project_size();
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
fn project_size_vec4(meters: vec4<f32>) -> vec4<f32> {
|
|
555
|
-
return vec4<f32>(meters.xyz * project.commonUnitsPerMeter, meters.w);
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
// Returns a rotation matrix aligning the z\u2011axis with the given up vector.
|
|
559
|
-
fn project_get_orientation_matrix(up: vec3<f32>) -> mat3x3<f32> {
|
|
560
|
-
let uz = normalize(up);
|
|
561
|
-
let ux = select(
|
|
562
|
-
vec3<f32>(1.0, 0.0, 0.0),
|
|
563
|
-
normalize(vec3<f32>(uz.y, -uz.x, 0.0)),
|
|
564
|
-
abs(uz.z) == 1.0
|
|
565
|
-
);
|
|
566
|
-
let uy = cross(uz, ux);
|
|
567
|
-
return mat3x3<f32>(ux, uy, uz);
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
// Since WGSL does not support "out" parameters, we return a struct.
|
|
571
|
-
struct RotationResult {
|
|
572
|
-
needsRotation: bool,
|
|
573
|
-
transform: mat3x3<f32>,
|
|
574
|
-
};
|
|
575
|
-
|
|
576
|
-
fn project_needs_rotation(commonPosition: vec3<f32>) -> RotationResult {
|
|
577
|
-
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
|
|
578
|
-
return RotationResult(true, project_get_orientation_matrix(commonPosition));
|
|
579
|
-
} else {
|
|
580
|
-
return RotationResult(false, mat3x3<f32>()); // identity alternative if needed
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
// Projects a normal vector from the current coordinate system to world space.
|
|
585
|
-
fn project_normal(vector: vec3<f32>) -> vec3<f32> {
|
|
586
|
-
let normal_modelspace = project.modelMatrix * vec4<f32>(vector, 0.0);
|
|
587
|
-
var n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter);
|
|
588
|
-
let rotResult = project_needs_rotation(geometry.position.xyz);
|
|
589
|
-
if (rotResult.needsRotation) {
|
|
590
|
-
n = rotResult.transform * n;
|
|
591
|
-
}
|
|
592
|
-
return n;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
// Applies a scale offset based on y-offset (dy)
|
|
596
|
-
fn project_offset_(offset: vec4<f32>) -> vec4<f32> {
|
|
597
|
-
let dy: f32 = offset.y;
|
|
598
|
-
let commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;
|
|
599
|
-
return vec4<f32>(offset.xyz * commonUnitsPerWorldUnit, offset.w);
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
// Projects lng/lat coordinates to a unit tile [0,1]
|
|
603
|
-
fn project_mercator_(lnglat: vec2<f32>) -> vec2<f32> {
|
|
604
|
-
var x = lnglat.x;
|
|
605
|
-
if (project.wrapLongitude != 0) {
|
|
606
|
-
x = ((x + 180.0) % 360.0) - 180.0;
|
|
607
|
-
}
|
|
608
|
-
let y = clamp(lnglat.y, -89.9, 89.9);
|
|
609
|
-
return vec2<f32>(
|
|
610
|
-
radians(x) + PI,
|
|
611
|
-
PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))
|
|
612
|
-
) * WORLD_SCALE;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
// Projects lng/lat/z coordinates for a globe projection.
|
|
616
|
-
fn project_globe_(lnglatz: vec3<f32>) -> vec3<f32> {
|
|
617
|
-
let lambda = radians(lnglatz.x);
|
|
618
|
-
let phi = radians(lnglatz.y);
|
|
619
|
-
let cosPhi = cos(phi);
|
|
620
|
-
let D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;
|
|
621
|
-
return vec3<f32>(
|
|
622
|
-
sin(lambda) * cosPhi,
|
|
623
|
-
-cos(lambda) * cosPhi,
|
|
624
|
-
sin(phi)
|
|
625
|
-
) * D;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
// Projects positions (with an optional 64-bit low part) from the input
|
|
629
|
-
// coordinate system to the common space.
|
|
630
|
-
fn project_position_vec4_f64(position: vec4<f32>, position64Low: vec3<f32>) -> vec4<f32> {
|
|
631
|
-
var position_world = project.modelMatrix * position;
|
|
632
|
-
|
|
633
|
-
// Work around for a Mac+NVIDIA bug:
|
|
634
|
-
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) {
|
|
635
|
-
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
|
|
636
|
-
return vec4<f32>(
|
|
637
|
-
project_mercator_(position_world.xy),
|
|
638
|
-
_project_size_at_latitude_m(position_world.z, position_world.y),
|
|
639
|
-
position_world.w
|
|
640
|
-
);
|
|
641
|
-
}
|
|
642
|
-
if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {
|
|
643
|
-
position_world = vec4f(position_world.xyz + project.coordinateOrigin, position_world.w);
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
|
|
647
|
-
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
|
|
648
|
-
return vec4<f32>(
|
|
649
|
-
project_globe_(position_world.xyz),
|
|
650
|
-
position_world.w
|
|
651
|
-
);
|
|
652
|
-
}
|
|
653
|
-
if (project.coordinateSystem == COORDINATE_SYSTEM_METER_OFFSETS) {
|
|
654
|
-
let enuMatrix = project_get_orientation_matrix(project.commonOrigin);
|
|
655
|
-
let metersToCommon = GLOBE_RADIUS / EARTH_RADIUS;
|
|
656
|
-
let offsetCommon = (enuMatrix * vec3<f32>(-position_world.x, -position_world.y, position_world.z)) * metersToCommon;
|
|
657
|
-
return vec4<f32>(project.commonOrigin + offsetCommon, position_world.w);
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
|
|
661
|
-
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
|
|
662
|
-
if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) {
|
|
663
|
-
return vec4<f32>(
|
|
664
|
-
project_mercator_(position_world.xy) - project.commonOrigin.xy,
|
|
665
|
-
project_size_float(position_world.z),
|
|
666
|
-
position_world.w
|
|
667
|
-
);
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
if (project.projectionMode == PROJECTION_MODE_IDENTITY ||
|
|
672
|
-
(project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&
|
|
673
|
-
(project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
|
|
674
|
-
project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {
|
|
675
|
-
position_world = vec4f(position_world.xyz - project.coordinateOrigin, position_world.w);
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
return project_offset_(position_world) +
|
|
679
|
-
project_offset_(project.modelMatrix * vec4<f32>(position64Low, 0.0));
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
// Overloaded versions for different input types.
|
|
683
|
-
fn project_position_vec4_f32(position: vec4<f32>) -> vec4<f32> {
|
|
684
|
-
return project_position_vec4_f64(position, ZERO_64_LOW);
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
fn project_position_vec3_f64(position: vec3<f32>, position64Low: vec3<f32>) -> vec3<f32> {
|
|
688
|
-
let projected_position = project_position_vec4_f64(vec4<f32>(position, 1.0), position64Low);
|
|
689
|
-
return projected_position.xyz;
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
fn project_position_vec3_f32(position: vec3<f32>) -> vec3<f32> {
|
|
693
|
-
let projected_position = project_position_vec4_f64(vec4<f32>(position, 1.0), ZERO_64_LOW);
|
|
694
|
-
return projected_position.xyz;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
fn project_position_vec2_f32(position: vec2<f32>) -> vec2<f32> {
|
|
698
|
-
let projected_position = project_position_vec4_f64(vec4<f32>(position, 0.0, 1.0), ZERO_64_LOW);
|
|
699
|
-
return projected_position.xy;
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
// Transforms a common space position to clip space.
|
|
703
|
-
fn project_common_position_to_clipspace_with_projection(position: vec4<f32>, viewProjectionMatrix: mat4x4<f32>, center: vec4<f32>) -> vec4<f32> {
|
|
704
|
-
var clipPosition = viewProjectionMatrix * position + center;
|
|
705
|
-
// deck.gl projection matrices use WebGL's [-w, w] depth range; WebGPU clips z to [0, w].
|
|
706
|
-
clipPosition.z = (clipPosition.z + clipPosition.w) * 0.5;
|
|
707
|
-
return clipPosition;
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
// Uses the project viewProjectionMatrix and center.
|
|
711
|
-
fn project_common_position_to_clipspace(position: vec4<f32>) -> vec4<f32> {
|
|
712
|
-
return project_common_position_to_clipspace_with_projection(position, project.viewProjectionMatrix, project.center);
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
// Returns a clip space offset corresponding to a given number of screen pixels.
|
|
716
|
-
fn project_pixel_size_to_clipspace(pixels: vec2<f32>) -> vec2<f32> {
|
|
717
|
-
let offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0;
|
|
718
|
-
return offset * project.focalDistance;
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
fn project_meter_size_to_pixel(meters: f32) -> f32 {
|
|
722
|
-
return project_size_float(meters) * project.scale;
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
fn project_unit_size_to_pixel(size: f32, unit: i32) -> f32 {
|
|
726
|
-
if (unit == UNIT_METERS) {
|
|
727
|
-
return project_meter_size_to_pixel(size);
|
|
728
|
-
} else if (unit == UNIT_COMMON) {
|
|
729
|
-
return size * project.scale;
|
|
730
|
-
}
|
|
731
|
-
// UNIT_PIXELS: no scaling applied.
|
|
732
|
-
return size;
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
fn project_pixel_size_float(pixels: f32) -> f32 {
|
|
736
|
-
return pixels / project.scale;
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
fn project_pixel_size_vec2(pixels: vec2<f32>) -> vec2<f32> {
|
|
740
|
-
return pixels / project.scale;
|
|
741
|
-
}
|
|
742
|
-
`
|
|
743
|
-
);
|
|
744
|
-
|
|
745
|
-
// ../core/src/shaderlib/project/project.glsl.ts
|
|
746
|
-
var SHADER_COORDINATE_SYSTEMS2 = [
|
|
747
|
-
"default",
|
|
748
|
-
"lnglat",
|
|
749
|
-
"meter-offsets",
|
|
750
|
-
"lnglat-offsets",
|
|
751
|
-
"cartesian"
|
|
752
|
-
];
|
|
753
|
-
var COORDINATE_SYSTEM_GLSL_CONSTANTS = SHADER_COORDINATE_SYSTEMS2.map(
|
|
754
|
-
(coordinateSystem) => `const int COORDINATE_SYSTEM_${coordinateSystem.toUpperCase().replaceAll("-", "_")} = ${getShaderCoordinateSystem(coordinateSystem)};`
|
|
755
|
-
).join("");
|
|
756
|
-
var PROJECTION_MODE_GLSL_CONSTANTS = Object.keys(PROJECTION_MODE).map((key) => `const int PROJECTION_MODE_${key} = ${PROJECTION_MODE[key]};`).join("");
|
|
757
|
-
var UNIT_GLSL_CONSTANTS = Object.keys(UNIT).map((key) => `const int UNIT_${key.toUpperCase()} = ${UNIT[key]};`).join("");
|
|
758
|
-
var projectGLSL = (
|
|
759
|
-
/* glsl */
|
|
760
|
-
`${COORDINATE_SYSTEM_GLSL_CONSTANTS}
|
|
761
|
-
${PROJECTION_MODE_GLSL_CONSTANTS}
|
|
762
|
-
${UNIT_GLSL_CONSTANTS}
|
|
763
|
-
|
|
764
|
-
layout(std140) uniform projectUniforms {
|
|
765
|
-
bool wrapLongitude;
|
|
766
|
-
int coordinateSystem;
|
|
767
|
-
vec3 commonUnitsPerMeter;
|
|
768
|
-
int projectionMode;
|
|
769
|
-
float scale;
|
|
770
|
-
vec3 commonUnitsPerWorldUnit;
|
|
771
|
-
vec3 commonUnitsPerWorldUnit2;
|
|
772
|
-
vec4 center;
|
|
773
|
-
mat4 modelMatrix;
|
|
774
|
-
mat4 viewProjectionMatrix;
|
|
775
|
-
vec2 viewportSize;
|
|
776
|
-
float devicePixelRatio;
|
|
777
|
-
float focalDistance;
|
|
778
|
-
vec3 cameraPosition;
|
|
779
|
-
vec3 coordinateOrigin;
|
|
780
|
-
vec3 commonOrigin;
|
|
781
|
-
bool pseudoMeters;
|
|
782
|
-
} project;
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
const float TILE_SIZE = 512.0;
|
|
786
|
-
const float PI = 3.1415926536;
|
|
787
|
-
const float WORLD_SCALE = TILE_SIZE / (PI * 2.0);
|
|
788
|
-
const vec3 ZERO_64_LOW = vec3(0.0);
|
|
789
|
-
const float EARTH_RADIUS = 6370972.0; // meters
|
|
790
|
-
const float GLOBE_RADIUS = 256.0;
|
|
791
|
-
|
|
792
|
-
// returns an adjustment factor for uCommonUnitsPerMeter
|
|
793
|
-
float project_size_at_latitude(float lat) {
|
|
794
|
-
float y = clamp(lat, -89.9, 89.9);
|
|
795
|
-
return 1.0 / cos(radians(y));
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
float project_size() {
|
|
799
|
-
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR &&
|
|
800
|
-
project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT &&
|
|
801
|
-
project.pseudoMeters == false) {
|
|
802
|
-
|
|
803
|
-
// uCommonUnitsPerMeter in low-zoom Web Mercator is non-linear
|
|
804
|
-
// Adjust by 1 / cos(latitude)
|
|
805
|
-
// If geometry.position (vertex in common space) is populated, use it
|
|
806
|
-
// Otherwise use geometry.worldPosition (anchor in world space)
|
|
807
|
-
|
|
808
|
-
if (geometry.position.w == 0.0) {
|
|
809
|
-
return project_size_at_latitude(geometry.worldPosition.y);
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
// latitude from common y: 2.0 * (atan(exp(y / TILE_SIZE * 2.0 * PI - PI)) - PI / 4.0)
|
|
813
|
-
// Taylor series of 1 / cos(latitude)
|
|
814
|
-
// Max error < 0.003
|
|
815
|
-
|
|
816
|
-
float y = geometry.position.y / TILE_SIZE * 2.0 - 1.0;
|
|
817
|
-
float y2 = y * y;
|
|
818
|
-
float y4 = y2 * y2;
|
|
819
|
-
float y6 = y4 * y2;
|
|
820
|
-
return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;
|
|
821
|
-
}
|
|
822
|
-
return 1.0;
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
float project_size_at_latitude(float meters, float lat) {
|
|
826
|
-
return meters * project.commonUnitsPerMeter.z * project_size_at_latitude(lat);
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
//
|
|
830
|
-
// Scaling offsets - scales meters to "world distance"
|
|
831
|
-
// Note the scalar version of project_size is for scaling the z component only
|
|
832
|
-
//
|
|
833
|
-
float project_size(float meters) {
|
|
834
|
-
// For scatter relevant
|
|
835
|
-
return meters * project.commonUnitsPerMeter.z * project_size();
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
vec2 project_size(vec2 meters) {
|
|
839
|
-
return meters * project.commonUnitsPerMeter.xy * project_size();
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
vec3 project_size(vec3 meters) {
|
|
843
|
-
return meters * project.commonUnitsPerMeter * project_size();
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
vec4 project_size(vec4 meters) {
|
|
847
|
-
return vec4(meters.xyz * project.commonUnitsPerMeter, meters.w);
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
// Get rotation matrix that aligns the z axis with the given up vector
|
|
851
|
-
// Find 3 unit vectors ux, uy, uz that are perpendicular to each other and uz == up
|
|
852
|
-
mat3 project_get_orientation_matrix(vec3 up) {
|
|
853
|
-
vec3 uz = normalize(up);
|
|
854
|
-
// Tangent on XY plane
|
|
855
|
-
vec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0));
|
|
856
|
-
vec3 uy = cross(uz, ux);
|
|
857
|
-
return mat3(ux, uy, uz);
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
bool project_needs_rotation(vec3 commonPosition, out mat3 transform) {
|
|
861
|
-
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
|
|
862
|
-
transform = project_get_orientation_matrix(commonPosition);
|
|
863
|
-
return true;
|
|
864
|
-
}
|
|
865
|
-
return false;
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
//
|
|
869
|
-
// Projecting normal - transform deltas from current coordinate system to
|
|
870
|
-
// normals in the worldspace
|
|
871
|
-
//
|
|
872
|
-
vec3 project_normal(vec3 vector) {
|
|
873
|
-
// Apply model matrix
|
|
874
|
-
vec4 normal_modelspace = project.modelMatrix * vec4(vector, 0.0);
|
|
875
|
-
vec3 n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter);
|
|
876
|
-
mat3 rotation;
|
|
877
|
-
if (project_needs_rotation(geometry.position.xyz, rotation)) {
|
|
878
|
-
n = rotation * n;
|
|
879
|
-
}
|
|
880
|
-
return n;
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
vec4 project_offset_(vec4 offset) {
|
|
884
|
-
float dy = offset.y;
|
|
885
|
-
vec3 commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;
|
|
886
|
-
return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
//
|
|
890
|
-
// Projecting positions - non-linear projection: lnglats => unit tile [0-1, 0-1]
|
|
891
|
-
//
|
|
892
|
-
vec2 project_mercator_(vec2 lnglat) {
|
|
893
|
-
float x = lnglat.x;
|
|
894
|
-
if (project.wrapLongitude) {
|
|
895
|
-
x = mod(x + 180., 360.0) - 180.;
|
|
896
|
-
}
|
|
897
|
-
float y = clamp(lnglat.y, -89.9, 89.9);
|
|
898
|
-
return vec2(
|
|
899
|
-
radians(x) + PI,
|
|
900
|
-
PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))
|
|
901
|
-
) * WORLD_SCALE;
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
vec3 project_globe_(vec3 lnglatz) {
|
|
905
|
-
float lambda = radians(lnglatz.x);
|
|
906
|
-
float phi = radians(lnglatz.y);
|
|
907
|
-
float cosPhi = cos(phi);
|
|
908
|
-
float D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;
|
|
909
|
-
|
|
910
|
-
return vec3(
|
|
911
|
-
sin(lambda) * cosPhi,
|
|
912
|
-
-cos(lambda) * cosPhi,
|
|
913
|
-
sin(phi)
|
|
914
|
-
) * D;
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
//
|
|
918
|
-
// Projects positions (defined by project.coordinateSystem) to common space (defined by project.projectionMode)
|
|
919
|
-
//
|
|
920
|
-
vec4 project_position(vec4 position, vec3 position64Low) {
|
|
921
|
-
vec4 position_world = project.modelMatrix * position;
|
|
922
|
-
|
|
923
|
-
// Work around for a Mac+NVIDIA bug https://github.com/visgl/deck.gl/issues/4145
|
|
924
|
-
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) {
|
|
925
|
-
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
|
|
926
|
-
return vec4(
|
|
927
|
-
project_mercator_(position_world.xy),
|
|
928
|
-
project_size_at_latitude(position_world.z, position_world.y),
|
|
929
|
-
position_world.w
|
|
930
|
-
);
|
|
931
|
-
}
|
|
932
|
-
if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {
|
|
933
|
-
position_world.xyz += project.coordinateOrigin;
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
|
|
937
|
-
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
|
|
938
|
-
return vec4(
|
|
939
|
-
project_globe_(position_world.xyz),
|
|
940
|
-
position_world.w
|
|
941
|
-
);
|
|
942
|
-
}
|
|
943
|
-
if (project.coordinateSystem == COORDINATE_SYSTEM_METER_OFFSETS) {
|
|
944
|
-
mat3 enuMatrix = project_get_orientation_matrix(project.commonOrigin);
|
|
945
|
-
float metersToCommon = GLOBE_RADIUS / EARTH_RADIUS;
|
|
946
|
-
vec3 offsetCommon = (enuMatrix * vec3(-position_world.xy, position_world.z)) * metersToCommon;
|
|
947
|
-
return vec4(project.commonOrigin + offsetCommon, position_world.w);
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
|
|
951
|
-
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
|
|
952
|
-
if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) {
|
|
953
|
-
// Too far from the projection center for offset mode to be accurate
|
|
954
|
-
// Only use high parts
|
|
955
|
-
return vec4(
|
|
956
|
-
project_mercator_(position_world.xy) - project.commonOrigin.xy,
|
|
957
|
-
project_size(position_world.z),
|
|
958
|
-
position_world.w
|
|
959
|
-
);
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
if (project.projectionMode == PROJECTION_MODE_IDENTITY ||
|
|
964
|
-
(project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&
|
|
965
|
-
(project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
|
|
966
|
-
project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {
|
|
967
|
-
// Subtract high part of 64 bit value. Convert remainder to float32, preserving precision.
|
|
968
|
-
position_world.xyz -= project.coordinateOrigin;
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
// Translation is already added to the high parts
|
|
972
|
-
return project_offset_(position_world) + project_offset_(project.modelMatrix * vec4(position64Low, 0.0));
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
vec4 project_position(vec4 position) {
|
|
976
|
-
return project_position(position, ZERO_64_LOW);
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
vec3 project_position(vec3 position, vec3 position64Low) {
|
|
980
|
-
vec4 projected_position = project_position(vec4(position, 1.0), position64Low);
|
|
981
|
-
return projected_position.xyz;
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
vec3 project_position(vec3 position) {
|
|
985
|
-
vec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW);
|
|
986
|
-
return projected_position.xyz;
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
vec2 project_position(vec2 position) {
|
|
990
|
-
vec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW);
|
|
991
|
-
return projected_position.xy;
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
vec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {
|
|
995
|
-
return viewProjectionMatrix * position + center;
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
//
|
|
999
|
-
// Projects from common space coordinates to clip space.
|
|
1000
|
-
// Uses project.viewProjectionMatrix
|
|
1001
|
-
//
|
|
1002
|
-
vec4 project_common_position_to_clipspace(vec4 position) {
|
|
1003
|
-
return project_common_position_to_clipspace(position, project.viewProjectionMatrix, project.center);
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
// Returns a clip space offset that corresponds to a given number of screen pixels
|
|
1007
|
-
vec2 project_pixel_size_to_clipspace(vec2 pixels) {
|
|
1008
|
-
vec2 offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0;
|
|
1009
|
-
return offset * project.focalDistance;
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
float project_size_to_pixel(float meters) {
|
|
1013
|
-
return project_size(meters) * project.scale;
|
|
1014
|
-
}
|
|
1015
|
-
vec2 project_size_to_pixel(vec2 meters) {
|
|
1016
|
-
return project_size(meters) * project.scale;
|
|
1017
|
-
}
|
|
1018
|
-
float project_size_to_pixel(float size, int unit) {
|
|
1019
|
-
if (unit == UNIT_METERS) return project_size_to_pixel(size);
|
|
1020
|
-
if (unit == UNIT_COMMON) return size * project.scale;
|
|
1021
|
-
// UNIT_PIXELS
|
|
1022
|
-
return size;
|
|
1023
|
-
}
|
|
1024
|
-
float project_pixel_size(float pixels) {
|
|
1025
|
-
return pixels / project.scale;
|
|
1026
|
-
}
|
|
1027
|
-
vec2 project_pixel_size(vec2 pixels) {
|
|
1028
|
-
return pixels / project.scale;
|
|
1029
|
-
}
|
|
1030
|
-
`
|
|
1031
|
-
);
|
|
1032
|
-
|
|
1033
|
-
// ../core/src/shaderlib/project/project.ts
|
|
1034
|
-
var INITIAL_MODULE_OPTIONS = {};
|
|
1035
|
-
function getUniforms(opts = INITIAL_MODULE_OPTIONS) {
|
|
1036
|
-
if ("viewport" in opts) {
|
|
1037
|
-
return getUniformsFromViewport(opts);
|
|
1038
|
-
}
|
|
1039
|
-
return {};
|
|
1040
|
-
}
|
|
1041
|
-
var project_default = {
|
|
1042
|
-
name: "project",
|
|
1043
|
-
dependencies: [import_shadertools.fp32, geometry_default],
|
|
1044
|
-
source: projectWGSL,
|
|
1045
|
-
vs: projectGLSL,
|
|
1046
|
-
getUniforms,
|
|
1047
|
-
uniformTypes: {
|
|
1048
|
-
wrapLongitude: "f32",
|
|
1049
|
-
coordinateSystem: "i32",
|
|
1050
|
-
commonUnitsPerMeter: "vec3<f32>",
|
|
1051
|
-
projectionMode: "i32",
|
|
1052
|
-
scale: "f32",
|
|
1053
|
-
commonUnitsPerWorldUnit: "vec3<f32>",
|
|
1054
|
-
commonUnitsPerWorldUnit2: "vec3<f32>",
|
|
1055
|
-
center: "vec4<f32>",
|
|
1056
|
-
modelMatrix: "mat4x4<f32>",
|
|
1057
|
-
viewProjectionMatrix: "mat4x4<f32>",
|
|
1058
|
-
viewportSize: "vec2<f32>",
|
|
1059
|
-
devicePixelRatio: "f32",
|
|
1060
|
-
focalDistance: "f32",
|
|
1061
|
-
cameraPosition: "vec3<f32>",
|
|
1062
|
-
coordinateOrigin: "vec3<f32>",
|
|
1063
|
-
commonOrigin: "vec3<f32>",
|
|
1064
|
-
pseudoMeters: "f32"
|
|
1065
|
-
}
|
|
1066
|
-
// @ts-ignore TODO v9.1
|
|
1067
|
-
};
|
|
1068
|
-
|
|
1069
|
-
// ../core/src/passes/pass.ts
|
|
1070
|
-
var Pass = class {
|
|
1071
|
-
/** Create a new Pass instance */
|
|
1072
|
-
constructor(device, props = { id: "pass" }) {
|
|
1073
|
-
const { id } = props;
|
|
1074
|
-
this.id = id;
|
|
1075
|
-
this.device = device;
|
|
1076
|
-
this.props = { ...props };
|
|
1077
|
-
}
|
|
1078
|
-
setProps(props) {
|
|
1079
|
-
Object.assign(this.props, props);
|
|
1080
|
-
}
|
|
1081
|
-
render(params) {
|
|
1082
|
-
}
|
|
1083
|
-
// eslint-disable-line @typescript-eslint/no-empty-function
|
|
1084
|
-
cleanup() {
|
|
1085
|
-
}
|
|
1086
|
-
// eslint-disable-line @typescript-eslint/no-empty-function
|
|
1087
|
-
};
|
|
1088
|
-
|
|
1089
|
-
// ../core/src/passes/layers-pass.ts
|
|
1090
|
-
var WEBGPU_DEFAULT_DRAW_PARAMETERS = {
|
|
1091
|
-
depthWriteEnabled: true,
|
|
1092
|
-
depthCompare: "less-equal",
|
|
1093
|
-
blendColorOperation: "add",
|
|
1094
|
-
blendColorSrcFactor: "one",
|
|
1095
|
-
blendColorDstFactor: "one-minus-src-alpha",
|
|
1096
|
-
blendAlphaOperation: "add",
|
|
1097
|
-
blendAlphaSrcFactor: "one",
|
|
1098
|
-
blendAlphaDstFactor: "one-minus-src-alpha"
|
|
1099
|
-
};
|
|
1100
|
-
var LayersPass = class extends Pass {
|
|
1101
|
-
constructor() {
|
|
1102
|
-
super(...arguments);
|
|
1103
|
-
this._lastRenderIndex = -1;
|
|
1104
|
-
}
|
|
1105
|
-
render(options) {
|
|
1106
|
-
this._render(options);
|
|
1107
|
-
}
|
|
1108
|
-
_render(options) {
|
|
1109
|
-
const { canvasContext = this.device.canvasContext } = options;
|
|
1110
|
-
const framebuffer = options.target ?? canvasContext.getCurrentFramebuffer();
|
|
1111
|
-
const [width, height] = canvasContext.getDrawingBufferSize();
|
|
1112
|
-
const clearCanvas = options.clearCanvas ?? true;
|
|
1113
|
-
let clearColor = options.clearColor ?? (clearCanvas ? [0, 0, 0, 0] : false);
|
|
1114
|
-
let clearDepth = clearCanvas ? 1 : false;
|
|
1115
|
-
let clearStencil = clearCanvas ? 0 : false;
|
|
1116
|
-
const colorMask = options.colorMask ?? 15;
|
|
1117
|
-
const parameters2 = { viewport: [0, 0, width, height] };
|
|
1118
|
-
if (options.colorMask) {
|
|
1119
|
-
parameters2.colorMask = colorMask;
|
|
1120
|
-
}
|
|
1121
|
-
if (options.scissorRect) {
|
|
1122
|
-
parameters2.scissorRect = options.scissorRect;
|
|
1123
|
-
}
|
|
1124
|
-
const { shaderModuleProps, viewports, views, onViewportActive, clearStack = true } = options;
|
|
1125
|
-
const pass = options.pass || "unknown";
|
|
1126
|
-
const submitEachRenderPass = this.device.type === "webgpu";
|
|
1127
|
-
if (clearStack) {
|
|
1128
|
-
this._lastRenderIndex = -1;
|
|
1129
|
-
}
|
|
1130
|
-
const renderStats = [];
|
|
1131
|
-
if (!viewports.length) {
|
|
1132
|
-
const renderPass = this.device.beginRenderPass({
|
|
1133
|
-
framebuffer,
|
|
1134
|
-
parameters: parameters2,
|
|
1135
|
-
clearColor,
|
|
1136
|
-
clearDepth,
|
|
1137
|
-
clearStencil
|
|
1138
|
-
});
|
|
1139
|
-
renderPass.end();
|
|
1140
|
-
this.device.submit();
|
|
1141
|
-
return renderStats;
|
|
1142
|
-
}
|
|
1143
|
-
try {
|
|
1144
|
-
for (const viewport of viewports) {
|
|
1145
|
-
onViewportActive == null ? void 0 : onViewportActive(viewport);
|
|
1146
|
-
const drawLayerParams = this._getDrawLayerParams(viewport, options);
|
|
1147
|
-
const view = views && views[viewport.id];
|
|
1148
|
-
const subViewports = viewport.subViewports || [viewport];
|
|
1149
|
-
const renderGroups = submitEachRenderPass ? subViewports.map((subViewport) => [subViewport]) : [subViewports];
|
|
1150
|
-
for (const renderGroup of renderGroups) {
|
|
1151
|
-
const renderPass = this.device.beginRenderPass({
|
|
1152
|
-
framebuffer,
|
|
1153
|
-
parameters: parameters2,
|
|
1154
|
-
clearColor,
|
|
1155
|
-
clearDepth,
|
|
1156
|
-
clearStencil
|
|
1157
|
-
});
|
|
1158
|
-
try {
|
|
1159
|
-
for (const subViewport of renderGroup) {
|
|
1160
|
-
const stats = this._drawLayersInViewport(
|
|
1161
|
-
renderPass,
|
|
1162
|
-
{
|
|
1163
|
-
target: framebuffer,
|
|
1164
|
-
canvasContext,
|
|
1165
|
-
shaderModuleProps,
|
|
1166
|
-
viewport: subViewport,
|
|
1167
|
-
view,
|
|
1168
|
-
pass,
|
|
1169
|
-
layers: options.layers,
|
|
1170
|
-
isPicking: options.isPicking
|
|
1171
|
-
},
|
|
1172
|
-
drawLayerParams
|
|
1173
|
-
);
|
|
1174
|
-
renderStats.push(stats);
|
|
1175
|
-
}
|
|
1176
|
-
} finally {
|
|
1177
|
-
renderPass.end();
|
|
1178
|
-
if (submitEachRenderPass) {
|
|
1179
|
-
this.device.submit();
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
clearColor = false;
|
|
1183
|
-
clearDepth = false;
|
|
1184
|
-
clearStencil = false;
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
return renderStats;
|
|
1188
|
-
} finally {
|
|
1189
|
-
if (!submitEachRenderPass) {
|
|
1190
|
-
this.device.submit();
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
// When a viewport contains multiple subviewports (e.g. repeated web mercator map),
|
|
1195
|
-
// this is only done once for the parent viewport
|
|
1196
|
-
/* Resolve the parameters needed to draw each layer */
|
|
1197
|
-
_getDrawLayerParams(viewport, {
|
|
1198
|
-
layers,
|
|
1199
|
-
pass,
|
|
1200
|
-
isPicking = false,
|
|
1201
|
-
layerFilter,
|
|
1202
|
-
cullRect,
|
|
1203
|
-
views,
|
|
1204
|
-
effects,
|
|
1205
|
-
canvasContext = this.device.canvasContext,
|
|
1206
|
-
shaderModuleProps
|
|
1207
|
-
}, evaluateShouldDrawOnly = false) {
|
|
1208
|
-
var _a, _b;
|
|
1209
|
-
const drawLayerParams = [];
|
|
1210
|
-
const indexResolver = layerIndexResolver(this._lastRenderIndex + 1);
|
|
1211
|
-
const drawContext = {
|
|
1212
|
-
layer: layers[0],
|
|
1213
|
-
viewport,
|
|
1214
|
-
isPicking,
|
|
1215
|
-
renderPass: pass,
|
|
1216
|
-
cullRect
|
|
1217
|
-
};
|
|
1218
|
-
const layerFilterCache = {};
|
|
1219
|
-
for (let layerIndex = 0; layerIndex < layers.length; layerIndex++) {
|
|
1220
|
-
const layer = layers[layerIndex];
|
|
1221
|
-
const shouldDrawLayer = this._shouldDrawLayer(
|
|
1222
|
-
layer,
|
|
1223
|
-
drawContext,
|
|
1224
|
-
layerFilter,
|
|
1225
|
-
layerFilterCache
|
|
1226
|
-
);
|
|
1227
|
-
const layerParam = { shouldDrawLayer };
|
|
1228
|
-
if (shouldDrawLayer && !evaluateShouldDrawOnly) {
|
|
1229
|
-
layerParam.shouldDrawLayer = true;
|
|
1230
|
-
layerParam.layerRenderIndex = indexResolver(layer, shouldDrawLayer);
|
|
1231
|
-
layerParam.shaderModuleProps = this._getShaderModuleProps(
|
|
1232
|
-
layer,
|
|
1233
|
-
effects,
|
|
1234
|
-
pass,
|
|
1235
|
-
canvasContext,
|
|
1236
|
-
shaderModuleProps
|
|
1237
|
-
);
|
|
1238
|
-
const defaultParams = layer.context.device.type === "webgpu" ? WEBGPU_DEFAULT_DRAW_PARAMETERS : null;
|
|
1239
|
-
layerParam.layerParameters = {
|
|
1240
|
-
...defaultParams,
|
|
1241
|
-
...(_a = layer.context.deck) == null ? void 0 : _a.props.parameters,
|
|
1242
|
-
...(_b = views == null ? void 0 : views[viewport.id]) == null ? void 0 : _b.props.parameters,
|
|
1243
|
-
...this.getLayerParameters(layer, layerIndex, viewport)
|
|
1244
|
-
};
|
|
1245
|
-
}
|
|
1246
|
-
drawLayerParams[layerIndex] = layerParam;
|
|
1247
|
-
}
|
|
1248
|
-
return drawLayerParams;
|
|
1249
|
-
}
|
|
1250
|
-
// Draws a list of layers in one viewport
|
|
1251
|
-
// TODO - when picking we could completely skip rendering viewports that dont
|
|
1252
|
-
// intersect with the picking rect
|
|
1253
|
-
/* eslint-disable max-depth, max-statements, complexity */
|
|
1254
|
-
_drawLayersInViewport(renderPass, {
|
|
1255
|
-
layers,
|
|
1256
|
-
shaderModuleProps: globalModuleParameters,
|
|
1257
|
-
pass,
|
|
1258
|
-
target,
|
|
1259
|
-
canvasContext,
|
|
1260
|
-
viewport,
|
|
1261
|
-
view,
|
|
1262
|
-
isPicking
|
|
1263
|
-
}, drawLayerParams) {
|
|
1264
|
-
const glViewport = getGLViewport(this.device, {
|
|
1265
|
-
canvasContext,
|
|
1266
|
-
shaderModuleProps: globalModuleParameters,
|
|
1267
|
-
target,
|
|
1268
|
-
viewport
|
|
1269
|
-
});
|
|
1270
|
-
if (view) {
|
|
1271
|
-
const { clear, clearColor, clearDepth, clearStencil } = view.props;
|
|
1272
|
-
if (clear) {
|
|
1273
|
-
let colorToUse = [0, 0, 0, 0];
|
|
1274
|
-
let depthToUse = 1;
|
|
1275
|
-
let stencilToUse = 0;
|
|
1276
|
-
if (Array.isArray(clearColor) && !isPicking) {
|
|
1277
|
-
colorToUse = [...clearColor.slice(0, 3), clearColor[3] || 255].map(
|
|
1278
|
-
(c) => c / 255
|
|
1279
|
-
);
|
|
1280
|
-
} else if (clearColor === false) {
|
|
1281
|
-
colorToUse = false;
|
|
1282
|
-
}
|
|
1283
|
-
if (clearDepth !== void 0) {
|
|
1284
|
-
depthToUse = clearDepth;
|
|
1285
|
-
}
|
|
1286
|
-
if (clearStencil !== void 0) {
|
|
1287
|
-
stencilToUse = clearStencil;
|
|
1288
|
-
}
|
|
1289
|
-
const clearRenderPass = this.device.beginRenderPass({
|
|
1290
|
-
framebuffer: target,
|
|
1291
|
-
parameters: {
|
|
1292
|
-
viewport: glViewport,
|
|
1293
|
-
scissorRect: glViewport
|
|
1294
|
-
},
|
|
1295
|
-
clearColor: colorToUse,
|
|
1296
|
-
clearDepth: depthToUse,
|
|
1297
|
-
clearStencil: stencilToUse
|
|
1298
|
-
});
|
|
1299
|
-
clearRenderPass.end();
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
const renderStatus = {
|
|
1303
|
-
totalCount: layers.length,
|
|
1304
|
-
visibleCount: 0,
|
|
1305
|
-
compositeCount: 0,
|
|
1306
|
-
pickableCount: 0
|
|
1307
|
-
};
|
|
1308
|
-
renderPass.setParameters({ viewport: glViewport });
|
|
1309
|
-
for (let layerIndex = 0; layerIndex < layers.length; layerIndex++) {
|
|
1310
|
-
const layer = layers[layerIndex];
|
|
1311
|
-
const drawLayerParameters = drawLayerParams[layerIndex];
|
|
1312
|
-
const { shouldDrawLayer } = drawLayerParameters;
|
|
1313
|
-
if (shouldDrawLayer && layer.props.pickable) {
|
|
1314
|
-
renderStatus.pickableCount++;
|
|
1315
|
-
}
|
|
1316
|
-
if (layer.isComposite) {
|
|
1317
|
-
renderStatus.compositeCount++;
|
|
1318
|
-
}
|
|
1319
|
-
if (layer.isDrawable && drawLayerParameters.shouldDrawLayer) {
|
|
1320
|
-
const { layerRenderIndex, shaderModuleProps, layerParameters } = drawLayerParameters;
|
|
1321
|
-
renderStatus.visibleCount++;
|
|
1322
|
-
this._lastRenderIndex = Math.max(this._lastRenderIndex, layerRenderIndex);
|
|
1323
|
-
if (shaderModuleProps.project) {
|
|
1324
|
-
shaderModuleProps.project.viewport = viewport;
|
|
1325
|
-
}
|
|
1326
|
-
layer.context.renderPass = renderPass;
|
|
1327
|
-
try {
|
|
1328
|
-
layer._drawLayer({
|
|
1329
|
-
renderPass,
|
|
1330
|
-
shaderModuleProps,
|
|
1331
|
-
uniforms: { layerIndex: layerRenderIndex },
|
|
1332
|
-
parameters: layerParameters
|
|
1333
|
-
});
|
|
1334
|
-
} catch (err) {
|
|
1335
|
-
layer.raiseError(err, `drawing ${layer} to ${pass}`);
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
return renderStatus;
|
|
1340
|
-
}
|
|
1341
|
-
/* eslint-enable max-depth, max-statements */
|
|
1342
|
-
/* Methods for subclass overrides */
|
|
1343
|
-
shouldDrawLayer(layer) {
|
|
1344
|
-
return true;
|
|
1345
|
-
}
|
|
1346
|
-
getShaderModuleProps(layer, effects, otherShaderModuleProps) {
|
|
1347
|
-
return null;
|
|
1348
|
-
}
|
|
1349
|
-
getLayerParameters(layer, layerIndex, viewport) {
|
|
1350
|
-
return layer.props.parameters;
|
|
1351
|
-
}
|
|
1352
|
-
/* Private */
|
|
1353
|
-
_shouldDrawLayer(layer, drawContext, layerFilter, layerFilterCache) {
|
|
1354
|
-
const shouldDrawLayer = layer.props.visible && this.shouldDrawLayer(layer);
|
|
1355
|
-
if (!shouldDrawLayer) {
|
|
1356
|
-
return false;
|
|
1357
|
-
}
|
|
1358
|
-
drawContext.layer = layer;
|
|
1359
|
-
let parent = layer.parent;
|
|
1360
|
-
while (parent) {
|
|
1361
|
-
if (!parent.props.visible || !parent.filterSubLayer(drawContext)) {
|
|
1362
|
-
return false;
|
|
1363
|
-
}
|
|
1364
|
-
drawContext.layer = parent;
|
|
1365
|
-
parent = parent.parent;
|
|
1366
|
-
}
|
|
1367
|
-
if (layerFilter) {
|
|
1368
|
-
const rootLayerId = drawContext.layer.id;
|
|
1369
|
-
if (!(rootLayerId in layerFilterCache)) {
|
|
1370
|
-
layerFilterCache[rootLayerId] = layerFilter(drawContext);
|
|
1371
|
-
}
|
|
1372
|
-
if (!layerFilterCache[rootLayerId]) {
|
|
1373
|
-
return false;
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
layer.activateViewport(drawContext.viewport);
|
|
1377
|
-
return true;
|
|
1378
|
-
}
|
|
1379
|
-
_getShaderModuleProps(layer, effects, pass, canvasContext, overrides) {
|
|
1380
|
-
var _a, _b;
|
|
1381
|
-
const devicePixelRatio = canvasContext.cssToDeviceRatio();
|
|
1382
|
-
const layerProps = ((_a = layer.internalState) == null ? void 0 : _a.propsInTransition) || layer.props;
|
|
1383
|
-
const shaderModuleProps = {
|
|
1384
|
-
layer: layerProps,
|
|
1385
|
-
picking: {
|
|
1386
|
-
isActive: false
|
|
1387
|
-
},
|
|
1388
|
-
project: {
|
|
1389
|
-
viewport: layer.context.viewport,
|
|
1390
|
-
devicePixelRatio,
|
|
1391
|
-
modelMatrix: layerProps.modelMatrix,
|
|
1392
|
-
coordinateSystem: layerProps.coordinateSystem,
|
|
1393
|
-
coordinateOrigin: layerProps.coordinateOrigin,
|
|
1394
|
-
autoWrapLongitude: layer.wrapLongitude
|
|
1395
|
-
}
|
|
1396
|
-
};
|
|
1397
|
-
if (effects) {
|
|
1398
|
-
for (const effect of effects) {
|
|
1399
|
-
mergeModuleParameters(
|
|
1400
|
-
shaderModuleProps,
|
|
1401
|
-
(_b = effect.getShaderModuleProps) == null ? void 0 : _b.call(effect, layer, shaderModuleProps)
|
|
1402
|
-
);
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
1405
|
-
for (const module2 of layer.context.defaultShaderModules) {
|
|
1406
|
-
if (!(module2.name in shaderModuleProps)) {
|
|
1407
|
-
shaderModuleProps[module2.name] = {};
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
return mergeModuleParameters(
|
|
1411
|
-
shaderModuleProps,
|
|
1412
|
-
this.getShaderModuleProps(layer, effects, shaderModuleProps),
|
|
1413
|
-
overrides
|
|
1414
|
-
);
|
|
1415
|
-
}
|
|
1416
|
-
};
|
|
1417
|
-
function layerIndexResolver(startIndex = 0, layerIndices = {}) {
|
|
1418
|
-
const resolvers = {};
|
|
1419
|
-
const resolveLayerIndex = (layer, isDrawn) => {
|
|
1420
|
-
const indexOverride = layer.props._offset;
|
|
1421
|
-
const layerId = layer.id;
|
|
1422
|
-
const parentId = layer.parent && layer.parent.id;
|
|
1423
|
-
let index;
|
|
1424
|
-
if (parentId && !(parentId in layerIndices)) {
|
|
1425
|
-
resolveLayerIndex(layer.parent, false);
|
|
1426
|
-
}
|
|
1427
|
-
if (parentId in resolvers) {
|
|
1428
|
-
const resolver = resolvers[parentId] = resolvers[parentId] || layerIndexResolver(layerIndices[parentId], layerIndices);
|
|
1429
|
-
index = resolver(layer, isDrawn);
|
|
1430
|
-
resolvers[layerId] = resolver;
|
|
1431
|
-
} else if (Number.isFinite(indexOverride)) {
|
|
1432
|
-
index = indexOverride + (layerIndices[parentId] || 0);
|
|
1433
|
-
resolvers[layerId] = null;
|
|
1434
|
-
} else {
|
|
1435
|
-
index = startIndex;
|
|
1436
|
-
}
|
|
1437
|
-
if (isDrawn && index >= startIndex) {
|
|
1438
|
-
startIndex = index + 1;
|
|
1439
|
-
}
|
|
1440
|
-
layerIndices[layerId] = index;
|
|
1441
|
-
return index;
|
|
1442
|
-
};
|
|
1443
|
-
return resolveLayerIndex;
|
|
1444
|
-
}
|
|
1445
|
-
function getGLViewport(device, {
|
|
1446
|
-
canvasContext = device.canvasContext,
|
|
1447
|
-
shaderModuleProps,
|
|
1448
|
-
target,
|
|
1449
|
-
viewport
|
|
1450
|
-
}) {
|
|
1451
|
-
var _a;
|
|
1452
|
-
const pixelRatio = ((_a = shaderModuleProps == null ? void 0 : shaderModuleProps.project) == null ? void 0 : _a.devicePixelRatio) ?? canvasContext.cssToDeviceRatio();
|
|
1453
|
-
const [, drawingBufferHeight] = canvasContext.getDrawingBufferSize();
|
|
1454
|
-
const height = target ? target.height : drawingBufferHeight;
|
|
1455
|
-
const dimensions = viewport;
|
|
1456
|
-
return [
|
|
1457
|
-
dimensions.x * pixelRatio,
|
|
1458
|
-
height - (dimensions.y + dimensions.height) * pixelRatio,
|
|
1459
|
-
dimensions.width * pixelRatio,
|
|
1460
|
-
dimensions.height * pixelRatio
|
|
1461
|
-
];
|
|
1462
|
-
}
|
|
1463
|
-
function mergeModuleParameters(target, ...sources) {
|
|
1464
|
-
for (const source2 of sources) {
|
|
1465
|
-
if (source2) {
|
|
1466
|
-
for (const key in source2) {
|
|
1467
|
-
if (target[key]) {
|
|
1468
|
-
Object.assign(target[key], source2[key]);
|
|
1469
|
-
} else {
|
|
1470
|
-
target[key] = source2[key];
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
return target;
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
// ../core/src/utils/math-utils.ts
|
|
1479
|
-
var import_core2 = require("@math.gl/core");
|
|
1480
|
-
function createMat4() {
|
|
1481
|
-
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
1482
|
-
}
|
|
1483
|
-
function mod(value, divisor) {
|
|
1484
|
-
const modulus = value % divisor;
|
|
1485
|
-
return modulus < 0 ? divisor + modulus : modulus;
|
|
1486
|
-
}
|
|
1487
|
-
function getCameraPosition(viewMatrixInverse) {
|
|
1488
|
-
return [viewMatrixInverse[12], viewMatrixInverse[13], viewMatrixInverse[14]];
|
|
1489
|
-
}
|
|
1490
|
-
function getFrustumPlanes(viewProjectionMatrix) {
|
|
1491
|
-
return {
|
|
1492
|
-
left: getFrustumPlane(
|
|
1493
|
-
viewProjectionMatrix[3] + viewProjectionMatrix[0],
|
|
1494
|
-
viewProjectionMatrix[7] + viewProjectionMatrix[4],
|
|
1495
|
-
viewProjectionMatrix[11] + viewProjectionMatrix[8],
|
|
1496
|
-
viewProjectionMatrix[15] + viewProjectionMatrix[12]
|
|
1497
|
-
),
|
|
1498
|
-
right: getFrustumPlane(
|
|
1499
|
-
viewProjectionMatrix[3] - viewProjectionMatrix[0],
|
|
1500
|
-
viewProjectionMatrix[7] - viewProjectionMatrix[4],
|
|
1501
|
-
viewProjectionMatrix[11] - viewProjectionMatrix[8],
|
|
1502
|
-
viewProjectionMatrix[15] - viewProjectionMatrix[12]
|
|
1503
|
-
),
|
|
1504
|
-
bottom: getFrustumPlane(
|
|
1505
|
-
viewProjectionMatrix[3] + viewProjectionMatrix[1],
|
|
1506
|
-
viewProjectionMatrix[7] + viewProjectionMatrix[5],
|
|
1507
|
-
viewProjectionMatrix[11] + viewProjectionMatrix[9],
|
|
1508
|
-
viewProjectionMatrix[15] + viewProjectionMatrix[13]
|
|
1509
|
-
),
|
|
1510
|
-
top: getFrustumPlane(
|
|
1511
|
-
viewProjectionMatrix[3] - viewProjectionMatrix[1],
|
|
1512
|
-
viewProjectionMatrix[7] - viewProjectionMatrix[5],
|
|
1513
|
-
viewProjectionMatrix[11] - viewProjectionMatrix[9],
|
|
1514
|
-
viewProjectionMatrix[15] - viewProjectionMatrix[13]
|
|
1515
|
-
),
|
|
1516
|
-
near: getFrustumPlane(
|
|
1517
|
-
viewProjectionMatrix[3] + viewProjectionMatrix[2],
|
|
1518
|
-
viewProjectionMatrix[7] + viewProjectionMatrix[6],
|
|
1519
|
-
viewProjectionMatrix[11] + viewProjectionMatrix[10],
|
|
1520
|
-
viewProjectionMatrix[15] + viewProjectionMatrix[14]
|
|
1521
|
-
),
|
|
1522
|
-
far: getFrustumPlane(
|
|
1523
|
-
viewProjectionMatrix[3] - viewProjectionMatrix[2],
|
|
1524
|
-
viewProjectionMatrix[7] - viewProjectionMatrix[6],
|
|
1525
|
-
viewProjectionMatrix[11] - viewProjectionMatrix[10],
|
|
1526
|
-
viewProjectionMatrix[15] - viewProjectionMatrix[14]
|
|
1527
|
-
)
|
|
1528
|
-
};
|
|
1529
|
-
}
|
|
1530
|
-
var scratchVector = new import_core2.Vector3();
|
|
1531
|
-
function getFrustumPlane(a, b, c, d) {
|
|
1532
|
-
scratchVector.set(a, b, c);
|
|
1533
|
-
const L = scratchVector.len();
|
|
1534
|
-
return { distance: d / L, normal: new import_core2.Vector3(-a / L, -b / L, -c / L) };
|
|
1535
|
-
}
|
|
1536
|
-
function fp64LowPart(x) {
|
|
1537
|
-
return x - Math.fround(x);
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
// ../core/src/viewports/viewport.ts
|
|
1541
|
-
var import_core3 = require("@math.gl/core");
|
|
1542
|
-
var import_web_mercator = require("@math.gl/web-mercator");
|
|
1543
|
-
var DEGREES_TO_RADIANS = Math.PI / 180;
|
|
1544
|
-
var IDENTITY = createMat4();
|
|
1545
|
-
var ZERO_VECTOR2 = [0, 0, 0];
|
|
1546
|
-
var DEFAULT_DISTANCE_SCALES = {
|
|
1547
|
-
unitsPerMeter: [1, 1, 1],
|
|
1548
|
-
metersPerUnit: [1, 1, 1]
|
|
1549
|
-
};
|
|
1550
|
-
function createProjectionMatrix({
|
|
1551
|
-
width,
|
|
1552
|
-
height,
|
|
1553
|
-
orthographic,
|
|
1554
|
-
fovyRadians,
|
|
1555
|
-
focalDistance,
|
|
1556
|
-
padding,
|
|
1557
|
-
near,
|
|
1558
|
-
far
|
|
1559
|
-
}) {
|
|
1560
|
-
const aspect = width / height;
|
|
1561
|
-
const matrix = orthographic ? new import_core3.Matrix4().orthographic({ fovy: fovyRadians, aspect, focalDistance, near, far }) : new import_core3.Matrix4().perspective({ fovy: fovyRadians, aspect, near, far });
|
|
1562
|
-
if (padding) {
|
|
1563
|
-
const { left = 0, right = 0, top = 0, bottom = 0 } = padding;
|
|
1564
|
-
const offsetX = (0, import_core3.clamp)((left + width - right) / 2, 0, width) - width / 2;
|
|
1565
|
-
const offsetY = (0, import_core3.clamp)((top + height - bottom) / 2, 0, height) - height / 2;
|
|
1566
|
-
matrix[8] -= offsetX * 2 / width;
|
|
1567
|
-
matrix[9] += offsetY * 2 / height;
|
|
1568
|
-
}
|
|
1569
|
-
return matrix;
|
|
1570
|
-
}
|
|
1571
|
-
var _Viewport = class _Viewport {
|
|
1572
|
-
// eslint-disable-next-line complexity
|
|
1573
|
-
constructor(opts = {}) {
|
|
1574
|
-
this._frustumPlanes = {};
|
|
1575
|
-
this.id = opts.id || this.constructor.displayName || "viewport";
|
|
1576
|
-
this.x = opts.x || 0;
|
|
1577
|
-
this.y = opts.y || 0;
|
|
1578
|
-
this.width = opts.width || 1;
|
|
1579
|
-
this.height = opts.height || 1;
|
|
1580
|
-
this.zoom = opts.zoom || 0;
|
|
1581
|
-
this.padding = opts.padding;
|
|
1582
|
-
this.distanceScales = opts.distanceScales || DEFAULT_DISTANCE_SCALES;
|
|
1583
|
-
this.focalDistance = opts.focalDistance || 1;
|
|
1584
|
-
this.position = opts.position || ZERO_VECTOR2;
|
|
1585
|
-
this.modelMatrix = opts.modelMatrix || null;
|
|
1586
|
-
const { longitude, latitude } = opts;
|
|
1587
|
-
this.isGeospatial = Number.isFinite(latitude) && Number.isFinite(longitude);
|
|
1588
|
-
this._initProps(opts);
|
|
1589
|
-
this._initMatrices(opts);
|
|
1590
|
-
this.equals = this.equals.bind(this);
|
|
1591
|
-
this.project = this.project.bind(this);
|
|
1592
|
-
this.unproject = this.unproject.bind(this);
|
|
1593
|
-
this.projectPosition = this.projectPosition.bind(this);
|
|
1594
|
-
this.unprojectPosition = this.unprojectPosition.bind(this);
|
|
1595
|
-
this.projectFlat = this.projectFlat.bind(this);
|
|
1596
|
-
this.unprojectFlat = this.unprojectFlat.bind(this);
|
|
1597
|
-
}
|
|
1598
|
-
get subViewports() {
|
|
1599
|
-
return null;
|
|
1600
|
-
}
|
|
1601
|
-
get metersPerPixel() {
|
|
1602
|
-
return this.distanceScales.metersPerUnit[2] / this.scale;
|
|
1603
|
-
}
|
|
1604
|
-
get projectionMode() {
|
|
1605
|
-
if (this.isGeospatial) {
|
|
1606
|
-
return this.zoom < 12 ? PROJECTION_MODE.WEB_MERCATOR : PROJECTION_MODE.WEB_MERCATOR_AUTO_OFFSET;
|
|
1607
|
-
}
|
|
1608
|
-
return PROJECTION_MODE.IDENTITY;
|
|
1609
|
-
}
|
|
1610
|
-
// Two viewports are equal if their dimensions, common-space scale, and
|
|
1611
|
-
// view and projection matrices are (approximately) equal.
|
|
1612
|
-
equals(viewport) {
|
|
1613
|
-
if (!(viewport instanceof _Viewport)) {
|
|
1614
|
-
return false;
|
|
1615
|
-
}
|
|
1616
|
-
if (this === viewport) {
|
|
1617
|
-
return true;
|
|
1618
|
-
}
|
|
1619
|
-
return viewport.width === this.width && viewport.height === this.height && viewport.scale === this.scale && viewport.projectionMode === this.projectionMode && viewport.resolution === this.resolution && (0, import_core3.equals)(viewport.distanceScales.unitsPerMeter, this.distanceScales.unitsPerMeter) && (0, import_core3.equals)(viewport.projectionMatrix, this.projectionMatrix) && (0, import_core3.equals)(viewport.viewMatrix, this.viewMatrix);
|
|
1620
|
-
}
|
|
1621
|
-
/**
|
|
1622
|
-
* Projects xyz (possibly latitude and longitude) to pixel coordinates in window
|
|
1623
|
-
* using viewport projection parameters
|
|
1624
|
-
* - [longitude, latitude] to [x, y]
|
|
1625
|
-
* - [longitude, latitude, Z] => [x, y, z]
|
|
1626
|
-
* Note: By default, returns top-left coordinates for canvas/SVG type render
|
|
1627
|
-
*
|
|
1628
|
-
* @param {Array} lngLatZ - [lng, lat] or [lng, lat, Z]
|
|
1629
|
-
* @param {Object} opts - options
|
|
1630
|
-
* @param {Object} opts.topLeft=true - Whether projected coords are top left
|
|
1631
|
-
* @return {Array} - [x, y] or [x, y, z] in top left coords
|
|
1632
|
-
*/
|
|
1633
|
-
project(xyz, { topLeft = true } = {}) {
|
|
1634
|
-
const worldPosition = this.projectPosition(xyz);
|
|
1635
|
-
const coord = (0, import_web_mercator.worldToPixels)(worldPosition, this.pixelProjectionMatrix);
|
|
1636
|
-
const [x, y] = coord;
|
|
1637
|
-
const y2 = topLeft ? y : this.height - y;
|
|
1638
|
-
return xyz.length === 2 ? [x, y2] : [x, y2, coord[2]];
|
|
1639
|
-
}
|
|
1640
|
-
/**
|
|
1641
|
-
* Unproject pixel coordinates on screen onto world coordinates,
|
|
1642
|
-
* (possibly [lon, lat]) on map.
|
|
1643
|
-
* - [x, y] => [lng, lat]
|
|
1644
|
-
* - [x, y, z] => [lng, lat, Z]
|
|
1645
|
-
* @param {Array} xyz -
|
|
1646
|
-
* @param {Object} opts - options
|
|
1647
|
-
* @param {Object} opts.topLeft=true - Whether origin is top left
|
|
1648
|
-
* @return {Array|null} - [lng, lat, Z] or [X, Y, Z]
|
|
1649
|
-
*/
|
|
1650
|
-
unproject(xyz, { topLeft = true, targetZ } = {}) {
|
|
1651
|
-
const [x, y, z] = xyz;
|
|
1652
|
-
const y2 = topLeft ? y : this.height - y;
|
|
1653
|
-
const targetZWorld = targetZ && targetZ * this.distanceScales.unitsPerMeter[2];
|
|
1654
|
-
const coord = (0, import_web_mercator.pixelsToWorld)([x, y2, z], this.pixelUnprojectionMatrix, targetZWorld);
|
|
1655
|
-
const [X, Y, Z] = this.unprojectPosition(coord);
|
|
1656
|
-
if (Number.isFinite(z)) {
|
|
1657
|
-
return [X, Y, Z];
|
|
1658
|
-
}
|
|
1659
|
-
return Number.isFinite(targetZ) ? [X, Y, targetZ] : [X, Y];
|
|
1660
|
-
}
|
|
1661
|
-
// NON_LINEAR PROJECTION HOOKS
|
|
1662
|
-
// Used for web meractor projection
|
|
1663
|
-
projectPosition(xyz) {
|
|
1664
|
-
const [X, Y] = this.projectFlat(xyz);
|
|
1665
|
-
const Z = (xyz[2] || 0) * this.distanceScales.unitsPerMeter[2];
|
|
1666
|
-
return [X, Y, Z];
|
|
1667
|
-
}
|
|
1668
|
-
unprojectPosition(xyz) {
|
|
1669
|
-
const [X, Y] = this.unprojectFlat(xyz);
|
|
1670
|
-
const Z = (xyz[2] || 0) * this.distanceScales.metersPerUnit[2];
|
|
1671
|
-
return [X, Y, Z];
|
|
1672
|
-
}
|
|
1673
|
-
/**
|
|
1674
|
-
* Project [lng,lat] on sphere onto [x,y] on 512*512 Mercator Zoom 0 tile.
|
|
1675
|
-
* Performs the nonlinear part of the web mercator projection.
|
|
1676
|
-
* Remaining projection is done with 4x4 matrices which also handles
|
|
1677
|
-
* perspective.
|
|
1678
|
-
* @param {Array} lngLat - [lng, lat] coordinates
|
|
1679
|
-
* Specifies a point on the sphere to project onto the map.
|
|
1680
|
-
* @return {Array} [x,y] coordinates.
|
|
1681
|
-
*/
|
|
1682
|
-
projectFlat(xyz) {
|
|
1683
|
-
if (this.isGeospatial) {
|
|
1684
|
-
const result = (0, import_web_mercator.lngLatToWorld)(xyz);
|
|
1685
|
-
result[1] = (0, import_core3.clamp)(result[1], -318, 830);
|
|
1686
|
-
return result;
|
|
1687
|
-
}
|
|
1688
|
-
return xyz;
|
|
1689
|
-
}
|
|
1690
|
-
/**
|
|
1691
|
-
* Unproject world point [x,y] on map onto {lat, lon} on sphere
|
|
1692
|
-
* @param {object|Vector} xy - object with {x,y} members
|
|
1693
|
-
* representing point on projected map plane
|
|
1694
|
-
* @return {GeoCoordinates} - object with {lat,lon} of point on sphere.
|
|
1695
|
-
* Has toArray method if you need a GeoJSON Array.
|
|
1696
|
-
* Per cartographic tradition, lat and lon are specified as degrees.
|
|
1697
|
-
*/
|
|
1698
|
-
unprojectFlat(xyz) {
|
|
1699
|
-
if (this.isGeospatial) {
|
|
1700
|
-
return (0, import_web_mercator.worldToLngLat)(xyz);
|
|
1701
|
-
}
|
|
1702
|
-
return xyz;
|
|
1703
|
-
}
|
|
1704
|
-
/**
|
|
1705
|
-
* Get bounds of the current viewport
|
|
1706
|
-
* @return {Array} - [minX, minY, maxX, maxY]
|
|
1707
|
-
*/
|
|
1708
|
-
getBounds(options = {}) {
|
|
1709
|
-
const unprojectOption = { targetZ: options.z || 0 };
|
|
1710
|
-
const topLeft = this.unproject([0, 0], unprojectOption);
|
|
1711
|
-
const topRight = this.unproject([this.width, 0], unprojectOption);
|
|
1712
|
-
const bottomLeft = this.unproject([0, this.height], unprojectOption);
|
|
1713
|
-
const bottomRight = this.unproject([this.width, this.height], unprojectOption);
|
|
1714
|
-
return [
|
|
1715
|
-
Math.min(topLeft[0], topRight[0], bottomLeft[0], bottomRight[0]),
|
|
1716
|
-
Math.min(topLeft[1], topRight[1], bottomLeft[1], bottomRight[1]),
|
|
1717
|
-
Math.max(topLeft[0], topRight[0], bottomLeft[0], bottomRight[0]),
|
|
1718
|
-
Math.max(topLeft[1], topRight[1], bottomLeft[1], bottomRight[1])
|
|
1719
|
-
];
|
|
1720
|
-
}
|
|
1721
|
-
getDistanceScales(coordinateOrigin) {
|
|
1722
|
-
if (coordinateOrigin && this.isGeospatial) {
|
|
1723
|
-
return (0, import_web_mercator.getDistanceScales)({
|
|
1724
|
-
longitude: coordinateOrigin[0],
|
|
1725
|
-
latitude: coordinateOrigin[1],
|
|
1726
|
-
highPrecision: true
|
|
1727
|
-
});
|
|
1728
|
-
}
|
|
1729
|
-
return this.distanceScales;
|
|
1730
|
-
}
|
|
1731
|
-
containsPixel({
|
|
1732
|
-
x,
|
|
1733
|
-
y,
|
|
1734
|
-
width = 1,
|
|
1735
|
-
height = 1
|
|
1736
|
-
}) {
|
|
1737
|
-
return x < this.x + this.width && this.x < x + width && y < this.y + this.height && this.y < y + height;
|
|
1738
|
-
}
|
|
1739
|
-
// Extract frustum planes in common space
|
|
1740
|
-
getFrustumPlanes() {
|
|
1741
|
-
if (this._frustumPlanes.near) {
|
|
1742
|
-
return this._frustumPlanes;
|
|
1743
|
-
}
|
|
1744
|
-
Object.assign(this._frustumPlanes, getFrustumPlanes(this.viewProjectionMatrix));
|
|
1745
|
-
return this._frustumPlanes;
|
|
1746
|
-
}
|
|
1747
|
-
// EXPERIMENTAL METHODS
|
|
1748
|
-
/**
|
|
1749
|
-
* Needed by panning and linear transition
|
|
1750
|
-
* Pan the viewport to place a given world coordinate at screen point [x, y]
|
|
1751
|
-
*
|
|
1752
|
-
* @param {Array} coords - world coordinates
|
|
1753
|
-
* @param {Array} pixel - [x,y] coordinates on screen
|
|
1754
|
-
* @param {Array} startPixel - [x,y] screen position where pan started (optional, for delta-based panning)
|
|
1755
|
-
* @return {Object} props of the new viewport
|
|
1756
|
-
*/
|
|
1757
|
-
panByPosition(coords, pixel, startPixel) {
|
|
1758
|
-
return null;
|
|
1759
|
-
}
|
|
1760
|
-
// INTERNAL METHODS
|
|
1761
|
-
/* eslint-disable complexity, max-statements */
|
|
1762
|
-
_initProps(opts) {
|
|
1763
|
-
const longitude = opts.longitude;
|
|
1764
|
-
const latitude = opts.latitude;
|
|
1765
|
-
if (this.isGeospatial) {
|
|
1766
|
-
if (!Number.isFinite(opts.zoom)) {
|
|
1767
|
-
this.zoom = (0, import_web_mercator.getMeterZoom)({ latitude }) + Math.log2(this.focalDistance);
|
|
1768
|
-
}
|
|
1769
|
-
this.distanceScales = opts.distanceScales || (0, import_web_mercator.getDistanceScales)({ latitude, longitude });
|
|
1770
|
-
}
|
|
1771
|
-
const scale = Math.pow(2, this.zoom);
|
|
1772
|
-
this.scale = scale;
|
|
1773
|
-
const { position, modelMatrix } = opts;
|
|
1774
|
-
let meterOffset = ZERO_VECTOR2;
|
|
1775
|
-
if (position) {
|
|
1776
|
-
meterOffset = modelMatrix ? new import_core3.Matrix4(modelMatrix).transformAsVector(position, []) : position;
|
|
1777
|
-
}
|
|
1778
|
-
if (this.isGeospatial) {
|
|
1779
|
-
const center = this.projectPosition([longitude, latitude, 0]);
|
|
1780
|
-
this.center = new import_core3.Vector3(meterOffset).scale(this.distanceScales.unitsPerMeter).add(center);
|
|
1781
|
-
} else {
|
|
1782
|
-
this.center = this.projectPosition(meterOffset);
|
|
1783
|
-
}
|
|
1784
|
-
}
|
|
1785
|
-
/* eslint-enable complexity, max-statements */
|
|
1786
|
-
_initMatrices(opts) {
|
|
1787
|
-
const {
|
|
1788
|
-
// View matrix
|
|
1789
|
-
viewMatrix: viewMatrix2 = IDENTITY,
|
|
1790
|
-
// Projection matrix
|
|
1791
|
-
projectionMatrix = null,
|
|
1792
|
-
// Projection matrix parameters, used if projectionMatrix not supplied
|
|
1793
|
-
orthographic = false,
|
|
1794
|
-
fovyRadians,
|
|
1795
|
-
fovy = 75,
|
|
1796
|
-
near = 0.1,
|
|
1797
|
-
// Distance of near clipping plane
|
|
1798
|
-
far = 1e3,
|
|
1799
|
-
// Distance of far clipping plane
|
|
1800
|
-
padding = null,
|
|
1801
|
-
// Center offset in pixels
|
|
1802
|
-
focalDistance = 1
|
|
1803
|
-
} = opts;
|
|
1804
|
-
this.viewMatrixUncentered = viewMatrix2;
|
|
1805
|
-
this.viewMatrix = new import_core3.Matrix4().multiplyRight(viewMatrix2).translate(new import_core3.Vector3(this.center).negate());
|
|
1806
|
-
this.projectionMatrix = projectionMatrix || createProjectionMatrix({
|
|
1807
|
-
width: this.width,
|
|
1808
|
-
height: this.height,
|
|
1809
|
-
orthographic,
|
|
1810
|
-
fovyRadians: fovyRadians || fovy * DEGREES_TO_RADIANS,
|
|
1811
|
-
focalDistance,
|
|
1812
|
-
padding,
|
|
1813
|
-
near,
|
|
1814
|
-
far
|
|
1815
|
-
});
|
|
1816
|
-
const vpm = createMat4();
|
|
1817
|
-
import_core3.mat4.multiply(vpm, vpm, this.projectionMatrix);
|
|
1818
|
-
import_core3.mat4.multiply(vpm, vpm, this.viewMatrix);
|
|
1819
|
-
this.viewProjectionMatrix = vpm;
|
|
1820
|
-
this.viewMatrixInverse = import_core3.mat4.invert([], this.viewMatrix) || this.viewMatrix;
|
|
1821
|
-
this.cameraPosition = getCameraPosition(this.viewMatrixInverse);
|
|
1822
|
-
const viewportMatrix = createMat4();
|
|
1823
|
-
const pixelProjectionMatrix = createMat4();
|
|
1824
|
-
import_core3.mat4.scale(viewportMatrix, viewportMatrix, [this.width / 2, -this.height / 2, 1]);
|
|
1825
|
-
import_core3.mat4.translate(viewportMatrix, viewportMatrix, [1, -1, 0]);
|
|
1826
|
-
import_core3.mat4.multiply(pixelProjectionMatrix, viewportMatrix, this.viewProjectionMatrix);
|
|
1827
|
-
this.pixelProjectionMatrix = pixelProjectionMatrix;
|
|
1828
|
-
this.pixelUnprojectionMatrix = import_core3.mat4.invert(createMat4(), this.pixelProjectionMatrix);
|
|
1829
|
-
if (!this.pixelUnprojectionMatrix) {
|
|
1830
|
-
log_default.warn("Pixel project matrix not invertible")();
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
};
|
|
1834
|
-
_Viewport.displayName = "Viewport";
|
|
1835
|
-
var Viewport = _Viewport;
|
|
1836
|
-
|
|
1837
|
-
// ../core/src/viewports/web-mercator-viewport.ts
|
|
1838
|
-
var import_web_mercator2 = require("@math.gl/web-mercator");
|
|
1839
|
-
var import_core4 = require("@math.gl/core");
|
|
1840
|
-
var _WebMercatorViewport = class _WebMercatorViewport extends Viewport {
|
|
1841
|
-
/* eslint-disable complexity, max-statements */
|
|
1842
|
-
constructor(opts = {}) {
|
|
1843
|
-
const {
|
|
1844
|
-
latitude = 0,
|
|
1845
|
-
longitude = 0,
|
|
1846
|
-
zoom = 0,
|
|
1847
|
-
pitch = 0,
|
|
1848
|
-
bearing = 0,
|
|
1849
|
-
nearZMultiplier = 0.1,
|
|
1850
|
-
farZMultiplier = 1.01,
|
|
1851
|
-
nearZ,
|
|
1852
|
-
farZ,
|
|
1853
|
-
orthographic = false,
|
|
1854
|
-
projectionMatrix,
|
|
1855
|
-
repeat = false,
|
|
1856
|
-
worldOffset = 0,
|
|
1857
|
-
position,
|
|
1858
|
-
padding,
|
|
1859
|
-
// backward compatibility
|
|
1860
|
-
// TODO: remove in v9
|
|
1861
|
-
legacyMeterSizes = false
|
|
1862
|
-
} = opts;
|
|
1863
|
-
let { width, height, altitude = 1.5 } = opts;
|
|
1864
|
-
const scale = Math.pow(2, zoom);
|
|
1865
|
-
width = width || 1;
|
|
1866
|
-
height = height || 1;
|
|
1867
|
-
let fovy;
|
|
1868
|
-
let projectionParameters = null;
|
|
1869
|
-
if (projectionMatrix) {
|
|
1870
|
-
altitude = projectionMatrix[5] / 2;
|
|
1871
|
-
fovy = (0, import_web_mercator2.altitudeToFovy)(altitude);
|
|
1872
|
-
} else {
|
|
1873
|
-
if (opts.fovy) {
|
|
1874
|
-
fovy = opts.fovy;
|
|
1875
|
-
altitude = (0, import_web_mercator2.fovyToAltitude)(fovy);
|
|
1876
|
-
} else {
|
|
1877
|
-
fovy = (0, import_web_mercator2.altitudeToFovy)(altitude);
|
|
1878
|
-
}
|
|
1879
|
-
let offset;
|
|
1880
|
-
if (padding) {
|
|
1881
|
-
const { top = 0, bottom = 0 } = padding;
|
|
1882
|
-
offset = [0, (0, import_core4.clamp)((top + height - bottom) / 2, 0, height) - height / 2];
|
|
1883
|
-
}
|
|
1884
|
-
projectionParameters = (0, import_web_mercator2.getProjectionParameters)({
|
|
1885
|
-
width,
|
|
1886
|
-
height,
|
|
1887
|
-
scale,
|
|
1888
|
-
center: position && [0, 0, position[2] * (0, import_web_mercator2.unitsPerMeter)(latitude)],
|
|
1889
|
-
offset,
|
|
1890
|
-
pitch,
|
|
1891
|
-
fovy,
|
|
1892
|
-
nearZMultiplier,
|
|
1893
|
-
farZMultiplier
|
|
1894
|
-
});
|
|
1895
|
-
if (Number.isFinite(nearZ)) {
|
|
1896
|
-
projectionParameters.near = nearZ;
|
|
1897
|
-
}
|
|
1898
|
-
if (Number.isFinite(farZ)) {
|
|
1899
|
-
projectionParameters.far = farZ;
|
|
1900
|
-
}
|
|
1901
|
-
}
|
|
1902
|
-
let viewMatrixUncentered = (0, import_web_mercator2.getViewMatrix)({
|
|
1903
|
-
height,
|
|
1904
|
-
pitch,
|
|
1905
|
-
bearing,
|
|
1906
|
-
scale,
|
|
1907
|
-
altitude
|
|
1908
|
-
});
|
|
1909
|
-
if (worldOffset) {
|
|
1910
|
-
const viewOffset = new import_core4.Matrix4().translate([512 * worldOffset, 0, 0]);
|
|
1911
|
-
viewMatrixUncentered = viewOffset.multiplyLeft(viewMatrixUncentered);
|
|
1912
|
-
}
|
|
1913
|
-
super({
|
|
1914
|
-
...opts,
|
|
1915
|
-
// x, y,
|
|
1916
|
-
width,
|
|
1917
|
-
height,
|
|
1918
|
-
// view matrix
|
|
1919
|
-
viewMatrix: viewMatrixUncentered,
|
|
1920
|
-
longitude,
|
|
1921
|
-
latitude,
|
|
1922
|
-
zoom,
|
|
1923
|
-
// projection matrix parameters
|
|
1924
|
-
...projectionParameters,
|
|
1925
|
-
fovy,
|
|
1926
|
-
focalDistance: altitude
|
|
1927
|
-
});
|
|
1928
|
-
this.latitude = latitude;
|
|
1929
|
-
this.longitude = longitude;
|
|
1930
|
-
this.zoom = zoom;
|
|
1931
|
-
this.pitch = pitch;
|
|
1932
|
-
this.bearing = bearing;
|
|
1933
|
-
this.altitude = altitude;
|
|
1934
|
-
this.fovy = fovy;
|
|
1935
|
-
this.orthographic = orthographic;
|
|
1936
|
-
this._subViewports = repeat ? [] : null;
|
|
1937
|
-
this._pseudoMeters = legacyMeterSizes;
|
|
1938
|
-
Object.freeze(this);
|
|
1939
|
-
}
|
|
1940
|
-
/* eslint-enable complexity, max-statements */
|
|
1941
|
-
get subViewports() {
|
|
1942
|
-
if (this._subViewports && !this._subViewports.length) {
|
|
1943
|
-
const bounds = this.getBounds();
|
|
1944
|
-
const minOffset = Math.floor((bounds[0] + 180) / 360);
|
|
1945
|
-
const maxOffset = Math.ceil((bounds[2] - 180) / 360);
|
|
1946
|
-
for (let x = minOffset; x <= maxOffset; x++) {
|
|
1947
|
-
const offsetViewport = x ? new _WebMercatorViewport({
|
|
1948
|
-
...this,
|
|
1949
|
-
worldOffset: x
|
|
1950
|
-
}) : this;
|
|
1951
|
-
this._subViewports.push(offsetViewport);
|
|
1952
|
-
}
|
|
1953
|
-
}
|
|
1954
|
-
return this._subViewports;
|
|
1955
|
-
}
|
|
1956
|
-
/** Returns whether two Web Mercator viewports use the same projection settings. */
|
|
1957
|
-
equals(viewport) {
|
|
1958
|
-
return viewport instanceof _WebMercatorViewport && viewport._pseudoMeters === this._pseudoMeters && super.equals(viewport);
|
|
1959
|
-
}
|
|
1960
|
-
projectPosition(xyz) {
|
|
1961
|
-
if (this._pseudoMeters) {
|
|
1962
|
-
return super.projectPosition(xyz);
|
|
1963
|
-
}
|
|
1964
|
-
const [X, Y] = this.projectFlat(xyz);
|
|
1965
|
-
const Z = (xyz[2] || 0) * (0, import_web_mercator2.unitsPerMeter)(xyz[1]);
|
|
1966
|
-
return [X, Y, Z];
|
|
1967
|
-
}
|
|
1968
|
-
unprojectPosition(xyz) {
|
|
1969
|
-
if (this._pseudoMeters) {
|
|
1970
|
-
return super.unprojectPosition(xyz);
|
|
1971
|
-
}
|
|
1972
|
-
const [X, Y] = this.unprojectFlat(xyz);
|
|
1973
|
-
const Z = (xyz[2] || 0) / (0, import_web_mercator2.unitsPerMeter)(Y);
|
|
1974
|
-
return [X, Y, Z];
|
|
1975
|
-
}
|
|
1976
|
-
/**
|
|
1977
|
-
* Add a meter delta to a base lnglat coordinate, returning a new lnglat array
|
|
1978
|
-
*
|
|
1979
|
-
* Note: Uses simple linear approximation around the viewport center
|
|
1980
|
-
* Error increases with size of offset (roughly 1% per 100km)
|
|
1981
|
-
*
|
|
1982
|
-
* @param {[Number,Number]|[Number,Number,Number]) lngLatZ - base coordinate
|
|
1983
|
-
* @param {[Number,Number]|[Number,Number,Number]) xyz - array of meter deltas
|
|
1984
|
-
* @return {[Number,Number]|[Number,Number,Number]) array of [lng,lat,z] deltas
|
|
1985
|
-
*/
|
|
1986
|
-
addMetersToLngLat(lngLatZ, xyz) {
|
|
1987
|
-
return (0, import_web_mercator2.addMetersToLngLat)(lngLatZ, xyz);
|
|
1988
|
-
}
|
|
1989
|
-
panByPosition(coords, pixel, startPixel) {
|
|
1990
|
-
const fromLocation = (0, import_web_mercator2.pixelsToWorld)(pixel, this.pixelUnprojectionMatrix);
|
|
1991
|
-
const toLocation = this.projectFlat(coords);
|
|
1992
|
-
const translate = import_core4.vec2.add([], toLocation, import_core4.vec2.negate([], fromLocation));
|
|
1993
|
-
const newCenter = import_core4.vec2.add([], this.center, translate);
|
|
1994
|
-
const [longitude, latitude] = this.unprojectFlat(newCenter);
|
|
1995
|
-
return { longitude, latitude };
|
|
1996
|
-
}
|
|
1997
|
-
/**
|
|
1998
|
-
* Returns a new longitude and latitude that keeps a 3D world coordinate at a given screen pixel
|
|
1999
|
-
* This version handles the z-component (altitude) properly for cameras positioned above ground
|
|
2000
|
-
*/
|
|
2001
|
-
panByPosition3D(coords, pixel) {
|
|
2002
|
-
const targetZ = coords[2] || 0;
|
|
2003
|
-
const deltaLngLat = import_core4.vec2.sub([], coords, this.unproject(pixel, { targetZ }));
|
|
2004
|
-
return { longitude: this.longitude + deltaLngLat[0], latitude: this.latitude + deltaLngLat[1] };
|
|
2005
|
-
}
|
|
2006
|
-
getBounds(options = {}) {
|
|
2007
|
-
const corners = (0, import_web_mercator2.getBounds)(this, options.z || 0);
|
|
2008
|
-
return [
|
|
2009
|
-
Math.min(corners[0][0], corners[1][0], corners[2][0], corners[3][0]),
|
|
2010
|
-
Math.min(corners[0][1], corners[1][1], corners[2][1], corners[3][1]),
|
|
2011
|
-
Math.max(corners[0][0], corners[1][0], corners[2][0], corners[3][0]),
|
|
2012
|
-
Math.max(corners[0][1], corners[1][1], corners[2][1], corners[3][1])
|
|
2013
|
-
];
|
|
2014
|
-
}
|
|
2015
|
-
/**
|
|
2016
|
-
* Returns a new viewport that fit around the given rectangle.
|
|
2017
|
-
* Only supports non-perspective mode.
|
|
2018
|
-
*/
|
|
2019
|
-
fitBounds(bounds, options = {}) {
|
|
2020
|
-
const { width, height } = this;
|
|
2021
|
-
const { longitude, latitude, zoom } = (0, import_web_mercator2.fitBounds)({ width, height, bounds, ...options });
|
|
2022
|
-
return new _WebMercatorViewport({ width, height, longitude, latitude, zoom });
|
|
2023
|
-
}
|
|
2024
|
-
};
|
|
2025
|
-
_WebMercatorViewport.displayName = "WebMercatorViewport";
|
|
2026
|
-
var WebMercatorViewport = _WebMercatorViewport;
|
|
2027
|
-
|
|
2028
|
-
// ../core/src/passes/pick-layers-pass.ts
|
|
2029
|
-
var PICKING_BLENDING = {
|
|
2030
|
-
blendColorOperation: "add",
|
|
2031
|
-
blendColorSrcFactor: "one",
|
|
2032
|
-
blendColorDstFactor: "zero",
|
|
2033
|
-
blendAlphaOperation: "add",
|
|
2034
|
-
blendAlphaSrcFactor: "constant",
|
|
2035
|
-
blendAlphaDstFactor: "zero"
|
|
2036
|
-
};
|
|
2037
|
-
var PickLayersPass = class extends LayersPass {
|
|
2038
|
-
constructor() {
|
|
2039
|
-
super(...arguments);
|
|
2040
|
-
this._colorEncoderState = null;
|
|
2041
|
-
}
|
|
2042
|
-
render(props) {
|
|
2043
|
-
if ("pickingFBO" in props) {
|
|
2044
|
-
return this._drawPickingBuffer(props);
|
|
2045
|
-
}
|
|
2046
|
-
const stats = super._render(props);
|
|
2047
|
-
return { decodePickingColor: null, stats };
|
|
2048
|
-
}
|
|
2049
|
-
// Private
|
|
2050
|
-
// Draws list of layers and viewports into the picking buffer
|
|
2051
|
-
// Note: does not sample the buffer, that has to be done by the caller
|
|
2052
|
-
_drawPickingBuffer({
|
|
2053
|
-
layers,
|
|
2054
|
-
layerFilter,
|
|
2055
|
-
views,
|
|
2056
|
-
viewports,
|
|
2057
|
-
onViewportActive,
|
|
2058
|
-
pickingFBO,
|
|
2059
|
-
deviceRect: { x, y, width, height },
|
|
2060
|
-
cullRect,
|
|
2061
|
-
effects,
|
|
2062
|
-
pass = "picking",
|
|
2063
|
-
pickZ,
|
|
2064
|
-
canvasContext,
|
|
2065
|
-
shaderModuleProps,
|
|
2066
|
-
clearColor
|
|
2067
|
-
}) {
|
|
2068
|
-
this.pickZ = pickZ;
|
|
2069
|
-
const colorEncoderState = this._resetColorEncoder(pickZ);
|
|
2070
|
-
const scissorRect = [x, y, width, height];
|
|
2071
|
-
const renderStatus = super._render({
|
|
2072
|
-
target: pickingFBO,
|
|
2073
|
-
layers,
|
|
2074
|
-
layerFilter,
|
|
2075
|
-
views,
|
|
2076
|
-
viewports,
|
|
2077
|
-
onViewportActive,
|
|
2078
|
-
cullRect,
|
|
2079
|
-
effects: effects == null ? void 0 : effects.filter((e) => e.useInPicking),
|
|
2080
|
-
pass,
|
|
2081
|
-
canvasContext,
|
|
2082
|
-
isPicking: true,
|
|
2083
|
-
shaderModuleProps,
|
|
2084
|
-
clearColor: clearColor ?? [0, 0, 0, 0],
|
|
2085
|
-
colorMask: 15,
|
|
2086
|
-
scissorRect
|
|
2087
|
-
});
|
|
2088
|
-
this._colorEncoderState = null;
|
|
2089
|
-
const decodePickingColor = colorEncoderState && decodeColor.bind(null, colorEncoderState);
|
|
2090
|
-
return { decodePickingColor, stats: renderStatus };
|
|
2091
|
-
}
|
|
2092
|
-
shouldDrawLayer(layer) {
|
|
2093
|
-
const { pickable, operation } = layer.props;
|
|
2094
|
-
return pickable && operation.includes("draw") || operation.includes("terrain") || operation.includes("mask");
|
|
2095
|
-
}
|
|
2096
|
-
getShaderModuleProps(layer, effects, otherShaderModuleProps) {
|
|
2097
|
-
var _a;
|
|
2098
|
-
return {
|
|
2099
|
-
picking: {
|
|
2100
|
-
isActive: 1,
|
|
2101
|
-
isAttribute: this.pickZ,
|
|
2102
|
-
disabledPickingIndices: (_a = layer.internalState) == null ? void 0 : _a.disabledPickingIndices
|
|
2103
|
-
},
|
|
2104
|
-
lighting: { enabled: false }
|
|
2105
|
-
};
|
|
2106
|
-
}
|
|
2107
|
-
getLayerParameters(layer, layerIndex, viewport) {
|
|
2108
|
-
var _a;
|
|
2109
|
-
const pickParameters = {
|
|
2110
|
-
...layer.props.parameters
|
|
2111
|
-
};
|
|
2112
|
-
const { pickable, operation } = layer.props;
|
|
2113
|
-
if (!this._colorEncoderState) {
|
|
2114
|
-
pickParameters.blend = false;
|
|
2115
|
-
} else if (pickable && operation.includes("draw")) {
|
|
2116
|
-
Object.assign(pickParameters, PICKING_BLENDING);
|
|
2117
|
-
pickParameters.blend = true;
|
|
2118
|
-
if (this.device.type === "webgpu") {
|
|
2119
|
-
pickParameters.blendConstant = encodeColor(this._colorEncoderState, layer, viewport);
|
|
2120
|
-
} else {
|
|
2121
|
-
pickParameters.blendColor = encodeColor(this._colorEncoderState, layer, viewport);
|
|
2122
|
-
}
|
|
2123
|
-
if (operation.includes("terrain") && ((_a = layer.state) == null ? void 0 : _a._hasPickingCover)) {
|
|
2124
|
-
pickParameters.blendAlphaSrcFactor = "one";
|
|
2125
|
-
}
|
|
2126
|
-
} else if (operation.includes("terrain")) {
|
|
2127
|
-
pickParameters.blend = false;
|
|
2128
|
-
}
|
|
2129
|
-
return pickParameters;
|
|
2130
|
-
}
|
|
2131
|
-
_resetColorEncoder(pickZ) {
|
|
2132
|
-
this._colorEncoderState = pickZ ? null : {
|
|
2133
|
-
byLayer: /* @__PURE__ */ new Map(),
|
|
2134
|
-
byAlpha: []
|
|
2135
|
-
};
|
|
2136
|
-
return this._colorEncoderState;
|
|
2137
|
-
}
|
|
2138
|
-
};
|
|
2139
|
-
function encodeColor(encoded, layer, viewport) {
|
|
2140
|
-
const { byLayer, byAlpha } = encoded;
|
|
2141
|
-
let a;
|
|
2142
|
-
let entry = byLayer.get(layer);
|
|
2143
|
-
if (entry) {
|
|
2144
|
-
entry.viewports.push(viewport);
|
|
2145
|
-
a = entry.a;
|
|
2146
|
-
} else {
|
|
2147
|
-
a = byLayer.size + 1;
|
|
2148
|
-
if (a <= 255) {
|
|
2149
|
-
entry = { a, layer, viewports: [viewport] };
|
|
2150
|
-
byLayer.set(layer, entry);
|
|
2151
|
-
byAlpha[a] = entry;
|
|
2152
|
-
} else {
|
|
2153
|
-
log_default.warn("Too many pickable layers, only picking the first 255")();
|
|
2154
|
-
a = 0;
|
|
2155
|
-
}
|
|
2156
|
-
}
|
|
2157
|
-
return [0, 0, 0, a / 255];
|
|
2158
|
-
}
|
|
2159
|
-
function decodeColor(encoded, pickedColor) {
|
|
2160
|
-
const entry = encoded.byAlpha[pickedColor[3]];
|
|
2161
|
-
return entry && {
|
|
2162
|
-
pickedLayer: entry.layer,
|
|
2163
|
-
pickedViewports: entry.viewports,
|
|
2164
|
-
pickedObjectIndex: entry.layer.decodePickingColor(pickedColor)
|
|
2165
|
-
};
|
|
2166
|
-
}
|
|
2167
|
-
|
|
2168
|
-
// ../core/src/utils/deep-equal.ts
|
|
2169
|
-
function deepEqual(a, b, depth) {
|
|
2170
|
-
if (a === b) {
|
|
2171
|
-
return true;
|
|
2172
|
-
}
|
|
2173
|
-
if (!depth || !a || !b) {
|
|
2174
|
-
return false;
|
|
2175
|
-
}
|
|
2176
|
-
if (Array.isArray(a)) {
|
|
2177
|
-
if (!Array.isArray(b) || a.length !== b.length) {
|
|
2178
|
-
return false;
|
|
2179
|
-
}
|
|
2180
|
-
for (let i = 0; i < a.length; i++) {
|
|
2181
|
-
if (!deepEqual(a[i], b[i], depth - 1)) {
|
|
2182
|
-
return false;
|
|
2183
|
-
}
|
|
2184
|
-
}
|
|
2185
|
-
return true;
|
|
2186
|
-
}
|
|
2187
|
-
if (Array.isArray(b)) {
|
|
2188
|
-
return false;
|
|
2189
|
-
}
|
|
2190
|
-
if (typeof a === "object" && typeof b === "object") {
|
|
2191
|
-
const aKeys = Object.keys(a);
|
|
2192
|
-
const bKeys = Object.keys(b);
|
|
2193
|
-
if (aKeys.length !== bKeys.length) {
|
|
2194
|
-
return false;
|
|
2195
|
-
}
|
|
2196
|
-
for (const key of aKeys) {
|
|
2197
|
-
if (!b.hasOwnProperty(key)) {
|
|
2198
|
-
return false;
|
|
2199
|
-
}
|
|
2200
|
-
if (!deepEqual(a[key], b[key], depth - 1)) {
|
|
2201
|
-
return false;
|
|
2202
|
-
}
|
|
2203
|
-
}
|
|
2204
|
-
return true;
|
|
2205
|
-
}
|
|
2206
|
-
return false;
|
|
2207
|
-
}
|
|
2208
|
-
|
|
2209
|
-
// ../core/src/utils/shader.ts
|
|
2210
|
-
function mergeShaders(target, source2) {
|
|
2211
|
-
if (!source2) {
|
|
2212
|
-
return target;
|
|
2213
|
-
}
|
|
2214
|
-
const result = { ...target, ...source2 };
|
|
2215
|
-
if ("defines" in source2) {
|
|
2216
|
-
result.defines = { ...target.defines, ...source2.defines };
|
|
2217
|
-
}
|
|
2218
|
-
if ("modules" in source2) {
|
|
2219
|
-
result.modules = (target.modules || []).concat(source2.modules);
|
|
2220
|
-
if (source2.modules.some((module2) => module2.name === "project64")) {
|
|
2221
|
-
const index = result.modules.findIndex((module2) => module2.name === "project32");
|
|
2222
|
-
if (index >= 0) {
|
|
2223
|
-
result.modules.splice(index, 1);
|
|
2224
|
-
}
|
|
2225
|
-
}
|
|
2226
|
-
}
|
|
2227
|
-
if ("inject" in source2) {
|
|
2228
|
-
if (!target.inject) {
|
|
2229
|
-
result.inject = source2.inject;
|
|
2230
|
-
} else {
|
|
2231
|
-
const mergedInjection = { ...target.inject };
|
|
2232
|
-
for (const key in source2.inject) {
|
|
2233
|
-
mergedInjection[key] = (mergedInjection[key] || "") + source2.inject[key];
|
|
2234
|
-
}
|
|
2235
|
-
result.inject = mergedInjection;
|
|
2236
|
-
}
|
|
2237
|
-
}
|
|
2238
|
-
return result;
|
|
2239
|
-
}
|
|
2240
|
-
|
|
2241
|
-
// ../core/src/viewports/globe-viewport.ts
|
|
2242
|
-
var import_core5 = require("@math.gl/core");
|
|
2243
|
-
var import_web_mercator3 = require("@math.gl/web-mercator");
|
|
2244
|
-
var DEGREES_TO_RADIANS2 = Math.PI / 180;
|
|
2245
|
-
var RADIANS_TO_DEGREES = 180 / Math.PI;
|
|
2246
|
-
var NORTH_UP_BEARING_THRESHOLD = 1;
|
|
2247
|
-
var EARTH_RADIUS = 6370972;
|
|
2248
|
-
var GLOBE_RADIUS = 256;
|
|
2249
|
-
var GLOBE_ZOOM_ANCHOR_DAMPING_START_RATIO = 0.75;
|
|
2250
|
-
var GLOBE_ZOOM_ANCHOR_MAX_DISTANCE_RATIO = 1.15;
|
|
2251
|
-
function isGlobeNorthUp(bearing) {
|
|
2252
|
-
const normalizedBearing = mod(bearing + 180, 360) - 180;
|
|
2253
|
-
return Math.abs(normalizedBearing) < NORTH_UP_BEARING_THRESHOLD;
|
|
2254
|
-
}
|
|
2255
|
-
function getDistanceScales2() {
|
|
2256
|
-
const unitsPerMeter2 = GLOBE_RADIUS / EARTH_RADIUS;
|
|
2257
|
-
const unitsPerDegree = Math.PI / 180 * GLOBE_RADIUS;
|
|
2258
|
-
return {
|
|
2259
|
-
unitsPerMeter: [unitsPerMeter2, unitsPerMeter2, unitsPerMeter2],
|
|
2260
|
-
unitsPerMeter2: [0, 0, 0],
|
|
2261
|
-
metersPerUnit: [1 / unitsPerMeter2, 1 / unitsPerMeter2, 1 / unitsPerMeter2],
|
|
2262
|
-
unitsPerDegree: [unitsPerDegree, unitsPerDegree, unitsPerMeter2],
|
|
2263
|
-
unitsPerDegree2: [0, 0, 0],
|
|
2264
|
-
degreesPerUnit: [1 / unitsPerDegree, 1 / unitsPerDegree, 1 / unitsPerMeter2]
|
|
2265
|
-
};
|
|
2266
|
-
}
|
|
2267
|
-
var GlobeViewport = class extends Viewport {
|
|
2268
|
-
constructor(opts = {}) {
|
|
2269
|
-
const {
|
|
2270
|
-
longitude = 0,
|
|
2271
|
-
bearing = 0,
|
|
2272
|
-
pitch = 0,
|
|
2273
|
-
zoom = 0,
|
|
2274
|
-
// Matches Maplibre defaults
|
|
2275
|
-
// https://github.com/maplibre/maplibre-gl-js/blob/f8ab4b48d59ab8fe7b068b102538793bbdd4c848/src/geo/projection/globe_transform.ts#L632-L633
|
|
2276
|
-
nearZMultiplier = 0.5,
|
|
2277
|
-
farZMultiplier = 1,
|
|
2278
|
-
resolution = 10
|
|
2279
|
-
} = opts;
|
|
2280
|
-
let { latitude = 0, height, altitude = 1.5, fovy } = opts;
|
|
2281
|
-
latitude = Math.max(Math.min(latitude, 90), -90);
|
|
2282
|
-
height = height || 1;
|
|
2283
|
-
if (fovy) {
|
|
2284
|
-
altitude = (0, import_web_mercator3.fovyToAltitude)(fovy);
|
|
2285
|
-
} else {
|
|
2286
|
-
fovy = (0, import_web_mercator3.altitudeToFovy)(altitude);
|
|
2287
|
-
}
|
|
2288
|
-
const scaleLatitude = Math.max(Math.min(latitude, import_web_mercator3.MAX_LATITUDE), -import_web_mercator3.MAX_LATITUDE);
|
|
2289
|
-
const scale = Math.pow(2, zoom - zoomAdjust(scaleLatitude));
|
|
2290
|
-
const pitchRadians = pitch * DEGREES_TO_RADIANS2;
|
|
2291
|
-
const nearZ = opts.nearZ ?? nearZMultiplier;
|
|
2292
|
-
const farZ = opts.farZ ?? (altitude + GLOBE_RADIUS * 2 * scale / height / Math.max(Math.cos(pitchRadians), 0.1)) * farZMultiplier;
|
|
2293
|
-
const viewMatrix2 = new import_core5.Matrix4().lookAt({ eye: [0, -altitude, 0], up: [0, 0, 1] }).rotateX(-pitchRadians).rotateY(-bearing * DEGREES_TO_RADIANS2).rotateX(latitude * DEGREES_TO_RADIANS2).rotateZ(-longitude * DEGREES_TO_RADIANS2).scale(scale / height);
|
|
2294
|
-
super({
|
|
2295
|
-
...opts,
|
|
2296
|
-
// x, y, width,
|
|
2297
|
-
height,
|
|
2298
|
-
// view matrix
|
|
2299
|
-
viewMatrix: viewMatrix2,
|
|
2300
|
-
longitude,
|
|
2301
|
-
latitude,
|
|
2302
|
-
zoom,
|
|
2303
|
-
// projection matrix parameters
|
|
2304
|
-
distanceScales: getDistanceScales2(),
|
|
2305
|
-
fovy,
|
|
2306
|
-
focalDistance: altitude,
|
|
2307
|
-
near: nearZ,
|
|
2308
|
-
far: farZ
|
|
2309
|
-
});
|
|
2310
|
-
this.scale = scale;
|
|
2311
|
-
this.latitude = latitude;
|
|
2312
|
-
this.longitude = longitude;
|
|
2313
|
-
this.bearing = bearing;
|
|
2314
|
-
this.pitch = pitch;
|
|
2315
|
-
this.fovy = fovy;
|
|
2316
|
-
this.resolution = resolution;
|
|
2317
|
-
}
|
|
2318
|
-
get projectionMode() {
|
|
2319
|
-
return PROJECTION_MODE.GLOBE;
|
|
2320
|
-
}
|
|
2321
|
-
getDistanceScales() {
|
|
2322
|
-
return this.distanceScales;
|
|
2323
|
-
}
|
|
2324
|
-
getBounds(options = {}) {
|
|
2325
|
-
const unprojectOption = { targetZ: options.z || 0 };
|
|
2326
|
-
const left = this.unproject([0, this.height / 2], unprojectOption);
|
|
2327
|
-
const top = this.unproject([this.width / 2, 0], unprojectOption);
|
|
2328
|
-
const right = this.unproject([this.width, this.height / 2], unprojectOption);
|
|
2329
|
-
const bottom = this.unproject([this.width / 2, this.height], unprojectOption);
|
|
2330
|
-
if (right[0] < this.longitude) right[0] += 360;
|
|
2331
|
-
if (left[0] > this.longitude) left[0] -= 360;
|
|
2332
|
-
return [
|
|
2333
|
-
Math.min(left[0], right[0], top[0], bottom[0]),
|
|
2334
|
-
Math.min(left[1], right[1], top[1], bottom[1]),
|
|
2335
|
-
Math.max(left[0], right[0], top[0], bottom[0]),
|
|
2336
|
-
Math.max(left[1], right[1], top[1], bottom[1])
|
|
2337
|
-
];
|
|
2338
|
-
}
|
|
2339
|
-
/**
|
|
2340
|
-
* Builds the screen-pixel → globe-center ray and the intermediate ray/sphere
|
|
2341
|
-
* math reused by `unproject` and anchored zoom. One function so the same
|
|
2342
|
-
* pixelUnprojectionMatrix work isn't duplicated.
|
|
2343
|
-
*/
|
|
2344
|
-
_getRayToGlobe(screenPosition, { topLeft = true, targetZ } = {}) {
|
|
2345
|
-
const [screenX, screenY] = screenPosition;
|
|
2346
|
-
const adjustedScreenY = topLeft ? screenY : this.height - screenY;
|
|
2347
|
-
const { pixelUnprojectionMatrix } = this;
|
|
2348
|
-
const rayStartPosition = transformVector(pixelUnprojectionMatrix, [
|
|
2349
|
-
screenX,
|
|
2350
|
-
adjustedScreenY,
|
|
2351
|
-
-1,
|
|
2352
|
-
1
|
|
2353
|
-
]);
|
|
2354
|
-
const rayEndPosition = transformVector(pixelUnprojectionMatrix, [
|
|
2355
|
-
screenX,
|
|
2356
|
-
adjustedScreenY,
|
|
2357
|
-
1,
|
|
2358
|
-
1
|
|
2359
|
-
]);
|
|
2360
|
-
const radius = ((targetZ || 0) / EARTH_RADIUS + 1) * GLOBE_RADIUS;
|
|
2361
|
-
const rayLengthSquared = import_core5.vec3.sqrLen(import_core5.vec3.sub([], rayStartPosition, rayEndPosition));
|
|
2362
|
-
const rayStartDistanceSquared = import_core5.vec3.sqrLen(rayStartPosition);
|
|
2363
|
-
const rayEndDistanceSquared = import_core5.vec3.sqrLen(rayEndPosition);
|
|
2364
|
-
const triangleAreaSquared = (4 * rayStartDistanceSquared * rayEndDistanceSquared - (rayLengthSquared - rayStartDistanceSquared - rayEndDistanceSquared) ** 2) / 16;
|
|
2365
|
-
const distanceToCenterSquared = 4 * triangleAreaSquared / rayLengthSquared;
|
|
2366
|
-
return {
|
|
2367
|
-
rayStartPosition,
|
|
2368
|
-
rayEndPosition,
|
|
2369
|
-
radius,
|
|
2370
|
-
rayLengthSquared,
|
|
2371
|
-
rayStartDistanceSquared,
|
|
2372
|
-
distanceToCenterSquared
|
|
2373
|
-
};
|
|
2374
|
-
}
|
|
2375
|
-
_getRayDistanceToGlobeCenterRatio(screenPosition, options) {
|
|
2376
|
-
const { distanceToCenterSquared, radius } = this._getRayToGlobe(screenPosition, options);
|
|
2377
|
-
return Math.sqrt(Math.max(0, distanceToCenterSquared)) / radius;
|
|
2378
|
-
}
|
|
2379
|
-
/**
|
|
2380
|
-
* Returns how strongly a screen position should anchor zoom on the visible globe.
|
|
2381
|
-
* A value of `0` means that the controller should fall back to center zoom.
|
|
2382
|
-
* @param screenPosition - Screen position to evaluate.
|
|
2383
|
-
* @returns Anchor strength from `0` to `1`.
|
|
2384
|
-
*/
|
|
2385
|
-
getZoomAnchorStrength(screenPosition) {
|
|
2386
|
-
const distanceRatio = this._getRayDistanceToGlobeCenterRatio(screenPosition);
|
|
2387
|
-
if (distanceRatio >= GLOBE_ZOOM_ANCHOR_MAX_DISTANCE_RATIO) {
|
|
2388
|
-
return 0;
|
|
2389
|
-
}
|
|
2390
|
-
const edgeProgress = Math.max(
|
|
2391
|
-
0,
|
|
2392
|
-
Math.min(
|
|
2393
|
-
1,
|
|
2394
|
-
(distanceRatio - GLOBE_ZOOM_ANCHOR_DAMPING_START_RATIO) / (GLOBE_ZOOM_ANCHOR_MAX_DISTANCE_RATIO - GLOBE_ZOOM_ANCHOR_DAMPING_START_RATIO)
|
|
2395
|
-
)
|
|
2396
|
-
);
|
|
2397
|
-
const smoothProgress = edgeProgress * edgeProgress * (3 - 2 * edgeProgress);
|
|
2398
|
-
return 1 - smoothProgress;
|
|
2399
|
-
}
|
|
2400
|
-
unproject(xyz, { topLeft = true, targetZ } = {}) {
|
|
2401
|
-
const [x, y, z] = xyz;
|
|
2402
|
-
const y2 = topLeft ? y : this.height - y;
|
|
2403
|
-
const { pixelUnprojectionMatrix } = this;
|
|
2404
|
-
let coord;
|
|
2405
|
-
if (Number.isFinite(z)) {
|
|
2406
|
-
coord = transformVector(pixelUnprojectionMatrix, [x, y2, z, 1]);
|
|
2407
|
-
} else {
|
|
2408
|
-
const {
|
|
2409
|
-
rayStartPosition,
|
|
2410
|
-
rayEndPosition,
|
|
2411
|
-
radius,
|
|
2412
|
-
rayLengthSquared,
|
|
2413
|
-
rayStartDistanceSquared,
|
|
2414
|
-
distanceToCenterSquared
|
|
2415
|
-
} = this._getRayToGlobe(xyz, { topLeft, targetZ });
|
|
2416
|
-
const rayStartToClosestApproach = Math.sqrt(
|
|
2417
|
-
rayStartDistanceSquared - distanceToCenterSquared
|
|
2418
|
-
);
|
|
2419
|
-
const closestApproachToIntersection = Math.sqrt(
|
|
2420
|
-
Math.max(0, radius * radius - distanceToCenterSquared)
|
|
2421
|
-
);
|
|
2422
|
-
const intersectionRatio = (rayStartToClosestApproach - closestApproachToIntersection) / Math.sqrt(rayLengthSquared);
|
|
2423
|
-
coord = import_core5.vec3.lerp([], rayStartPosition, rayEndPosition, intersectionRatio);
|
|
2424
|
-
}
|
|
2425
|
-
const [X, Y, Z] = this.unprojectPosition(coord);
|
|
2426
|
-
if (Number.isFinite(z)) {
|
|
2427
|
-
return [X, Y, Z];
|
|
2428
|
-
}
|
|
2429
|
-
return Number.isFinite(targetZ) ? [X, Y, targetZ] : [X, Y];
|
|
2430
|
-
}
|
|
2431
|
-
projectPosition(xyz) {
|
|
2432
|
-
const [lng, lat, Z = 0] = xyz;
|
|
2433
|
-
const lambda = lng * DEGREES_TO_RADIANS2;
|
|
2434
|
-
const phi = lat * DEGREES_TO_RADIANS2;
|
|
2435
|
-
const cosPhi = Math.cos(phi);
|
|
2436
|
-
const D = (Z / EARTH_RADIUS + 1) * GLOBE_RADIUS;
|
|
2437
|
-
return [Math.sin(lambda) * cosPhi * D, -Math.cos(lambda) * cosPhi * D, Math.sin(phi) * D];
|
|
2438
|
-
}
|
|
2439
|
-
unprojectPosition(xyz) {
|
|
2440
|
-
const [x, y, z] = xyz;
|
|
2441
|
-
const D = import_core5.vec3.len(xyz);
|
|
2442
|
-
const phi = Math.asin(z / D);
|
|
2443
|
-
const lambda = Math.atan2(x, -y);
|
|
2444
|
-
const lng = lambda * RADIANS_TO_DEGREES;
|
|
2445
|
-
const lat = phi * RADIANS_TO_DEGREES;
|
|
2446
|
-
const Z = (D / GLOBE_RADIUS - 1) * EARTH_RADIUS;
|
|
2447
|
-
return [lng, lat, Z];
|
|
2448
|
-
}
|
|
2449
|
-
projectFlat(xyz) {
|
|
2450
|
-
return xyz;
|
|
2451
|
-
}
|
|
2452
|
-
unprojectFlat(xyz) {
|
|
2453
|
-
return xyz;
|
|
2454
|
-
}
|
|
2455
|
-
/**
|
|
2456
|
-
* Pan the globe to place geographic coordinates at a screen pixel.
|
|
2457
|
-
* When `dragStartPosition` is supplied, applies the delta-based movement used by globe dragging.
|
|
2458
|
-
* @param coordinates - Geographic anchor, or the starting longitude, latitude and zoom.
|
|
2459
|
-
* @param screenPosition - Current screen position.
|
|
2460
|
-
* @param dragStartPosition - Screen position where a drag started.
|
|
2461
|
-
* @returns Updated viewport options.
|
|
2462
|
-
*/
|
|
2463
|
-
panByPosition(coordinates, screenPosition, dragStartPosition) {
|
|
2464
|
-
if (!dragStartPosition) {
|
|
2465
|
-
let anchorStrength = this.getZoomAnchorStrength(screenPosition);
|
|
2466
|
-
if (anchorStrength === 0) {
|
|
2467
|
-
return { longitude: this.longitude, latitude: this.latitude };
|
|
2468
|
-
}
|
|
2469
|
-
const currentCoordinates = this.unproject(screenPosition);
|
|
2470
|
-
const longitudeDelta = mod(coordinates[0] - currentCoordinates[0] + 180, 360) - 180;
|
|
2471
|
-
const latitudeDelta = coordinates[1] - currentCoordinates[1];
|
|
2472
|
-
const crossesPole = Math.abs(currentCoordinates[1]) > import_web_mercator3.MAX_LATITUDE || Math.abs(longitudeDelta) > 90;
|
|
2473
|
-
if (isGlobeNorthUp(this.bearing) && crossesPole) {
|
|
2474
|
-
return { longitude: this.longitude, latitude: this.latitude };
|
|
2475
|
-
}
|
|
2476
|
-
if (isGlobeNorthUp(this.bearing) && latitudeDelta !== 0) {
|
|
2477
|
-
const latitudeLimit = latitudeDelta > 0 ? import_web_mercator3.MAX_LATITUDE : -import_web_mercator3.MAX_LATITUDE;
|
|
2478
|
-
const latitudeConstraintStrength = (latitudeLimit - this.latitude) / latitudeDelta;
|
|
2479
|
-
anchorStrength = Math.min(anchorStrength, Math.max(0, latitudeConstraintStrength));
|
|
2480
|
-
}
|
|
2481
|
-
const longitude2 = this.longitude + longitudeDelta * anchorStrength;
|
|
2482
|
-
const latitude2 = Math.max(Math.min(this.latitude + latitudeDelta * anchorStrength, 90), -90);
|
|
2483
|
-
return { longitude: longitude2, latitude: latitude2 };
|
|
2484
|
-
}
|
|
2485
|
-
const [startLongitude, startLatitude, startZoom] = coordinates;
|
|
2486
|
-
const scale = Math.pow(2, this.zoom - zoomAdjust(this.latitude));
|
|
2487
|
-
const rotationSpeed = 0.25 / scale;
|
|
2488
|
-
const longitude = startLongitude + rotationSpeed * (dragStartPosition[0] - screenPosition[0]);
|
|
2489
|
-
let latitude = startLatitude - rotationSpeed * (dragStartPosition[1] - screenPosition[1]);
|
|
2490
|
-
latitude = Math.max(Math.min(latitude, 90), -90);
|
|
2491
|
-
const nextViewState = { longitude, latitude, zoom: startZoom - zoomAdjust(startLatitude) };
|
|
2492
|
-
nextViewState.zoom += zoomAdjust(nextViewState.latitude);
|
|
2493
|
-
return nextViewState;
|
|
2494
|
-
}
|
|
2495
|
-
};
|
|
2496
|
-
GlobeViewport.displayName = "GlobeViewport";
|
|
2497
|
-
function zoomAdjust(latitude, clampToPoles) {
|
|
2498
|
-
if (clampToPoles) {
|
|
2499
|
-
latitude = Math.max(Math.min(latitude, import_web_mercator3.MAX_LATITUDE), -import_web_mercator3.MAX_LATITUDE);
|
|
2500
|
-
}
|
|
2501
|
-
const scaleAdjust = Math.PI * Math.cos(latitude * Math.PI / 180);
|
|
2502
|
-
return Math.log2(scaleAdjust);
|
|
2503
|
-
}
|
|
2504
|
-
function transformVector(matrix, vector) {
|
|
2505
|
-
const result = import_core5.vec4.transformMat4([], vector, matrix);
|
|
2506
|
-
import_core5.vec4.scale(result, result, 1 / result[3]);
|
|
2507
|
-
return result;
|
|
2508
|
-
}
|
|
2509
|
-
|
|
2510
|
-
// ../core/src/viewports/orthographic-viewport.ts
|
|
2511
|
-
var import_core6 = require("@math.gl/core");
|
|
2512
|
-
var import_web_mercator4 = require("@math.gl/web-mercator");
|
|
2513
|
-
var viewMatrix = new import_core6.Matrix4().lookAt({ eye: [0, 0, 1] });
|
|
2514
|
-
function getProjectionMatrix({
|
|
2515
|
-
width,
|
|
2516
|
-
height,
|
|
2517
|
-
near,
|
|
2518
|
-
far,
|
|
2519
|
-
padding
|
|
2520
|
-
}) {
|
|
2521
|
-
let left = -width / 2;
|
|
2522
|
-
let right = width / 2;
|
|
2523
|
-
let bottom = -height / 2;
|
|
2524
|
-
let top = height / 2;
|
|
2525
|
-
if (padding) {
|
|
2526
|
-
const { left: l = 0, right: r = 0, top: t = 0, bottom: b = 0 } = padding;
|
|
2527
|
-
const offsetX = (0, import_core6.clamp)((l + width - r) / 2, 0, width) - width / 2;
|
|
2528
|
-
const offsetY = (0, import_core6.clamp)((t + height - b) / 2, 0, height) - height / 2;
|
|
2529
|
-
left -= offsetX;
|
|
2530
|
-
right -= offsetX;
|
|
2531
|
-
bottom += offsetY;
|
|
2532
|
-
top += offsetY;
|
|
2533
|
-
}
|
|
2534
|
-
return new import_core6.Matrix4().ortho({
|
|
2535
|
-
left,
|
|
2536
|
-
right,
|
|
2537
|
-
bottom,
|
|
2538
|
-
top,
|
|
2539
|
-
near,
|
|
2540
|
-
far
|
|
2541
|
-
});
|
|
2542
|
-
}
|
|
2543
|
-
var OrthographicViewport = class extends Viewport {
|
|
2544
|
-
constructor(props) {
|
|
2545
|
-
const {
|
|
2546
|
-
width,
|
|
2547
|
-
height,
|
|
2548
|
-
near = 0.1,
|
|
2549
|
-
far = 1e3,
|
|
2550
|
-
zoom = 0,
|
|
2551
|
-
target = [0, 0, 0],
|
|
2552
|
-
padding = null,
|
|
2553
|
-
flipY = true
|
|
2554
|
-
} = props;
|
|
2555
|
-
const zoomX = props.zoomX ?? (Array.isArray(zoom) ? zoom[0] : zoom);
|
|
2556
|
-
const zoomY = props.zoomY ?? (Array.isArray(zoom) ? zoom[1] : zoom);
|
|
2557
|
-
const zoom_ = Number.isFinite(props.zoom) ? props.zoom : Math.min(zoomX, zoomY);
|
|
2558
|
-
const scale = Math.pow(2, zoom_);
|
|
2559
|
-
let distanceScales;
|
|
2560
|
-
if (zoomX !== zoom_ || zoomY !== zoom_) {
|
|
2561
|
-
const scaleX = Math.pow(2, zoomX);
|
|
2562
|
-
const scaleY = Math.pow(2, zoomY);
|
|
2563
|
-
distanceScales = {
|
|
2564
|
-
unitsPerMeter: [scaleX / scale, scaleY / scale, 1],
|
|
2565
|
-
metersPerUnit: [scale / scaleX, scale / scaleY, 1]
|
|
2566
|
-
};
|
|
2567
|
-
}
|
|
2568
|
-
super({
|
|
2569
|
-
...props,
|
|
2570
|
-
// in case viewState contains longitude/latitude values,
|
|
2571
|
-
// make sure that the base Viewport class does not treat this as a geospatial viewport
|
|
2572
|
-
longitude: void 0,
|
|
2573
|
-
position: target,
|
|
2574
|
-
viewMatrix: viewMatrix.clone().scale([scale, scale * (flipY ? -1 : 1), scale]),
|
|
2575
|
-
projectionMatrix: getProjectionMatrix({
|
|
2576
|
-
width: width || 1,
|
|
2577
|
-
height: height || 1,
|
|
2578
|
-
padding,
|
|
2579
|
-
near,
|
|
2580
|
-
far
|
|
2581
|
-
}),
|
|
2582
|
-
zoom: zoom_,
|
|
2583
|
-
distanceScales
|
|
2584
|
-
});
|
|
2585
|
-
this.target = target;
|
|
2586
|
-
this.zoomX = zoomX;
|
|
2587
|
-
this.zoomY = zoomY;
|
|
2588
|
-
this.flipY = flipY;
|
|
2589
|
-
}
|
|
2590
|
-
projectFlat([X, Y]) {
|
|
2591
|
-
const { unitsPerMeter: unitsPerMeter2 } = this.distanceScales;
|
|
2592
|
-
return [X * unitsPerMeter2[0], Y * unitsPerMeter2[1]];
|
|
2593
|
-
}
|
|
2594
|
-
unprojectFlat([x, y]) {
|
|
2595
|
-
const { metersPerUnit } = this.distanceScales;
|
|
2596
|
-
return [x * metersPerUnit[0], y * metersPerUnit[1]];
|
|
2597
|
-
}
|
|
2598
|
-
/* Needed by LinearInterpolator */
|
|
2599
|
-
panByPosition(coords, pixel, startPixel) {
|
|
2600
|
-
const fromLocation = (0, import_web_mercator4.pixelsToWorld)(pixel, this.pixelUnprojectionMatrix);
|
|
2601
|
-
const toLocation = this.projectFlat(coords);
|
|
2602
|
-
const translate = import_core6.vec2.add([], toLocation, import_core6.vec2.negate([], fromLocation));
|
|
2603
|
-
const newCenter = import_core6.vec2.add([], this.center, translate);
|
|
2604
|
-
return { target: this.unprojectFlat(newCenter) };
|
|
2605
|
-
}
|
|
2606
|
-
};
|
|
2607
|
-
OrthographicViewport.displayName = "OrthographicViewport";
|
|
2608
|
-
|
|
2609
|
-
// ../core/src/lib/layer-extension.ts
|
|
2610
|
-
var LayerExtension = class {
|
|
2611
|
-
static get componentName() {
|
|
2612
|
-
return Object.prototype.hasOwnProperty.call(this, "extensionName") ? this.extensionName : "";
|
|
2613
|
-
}
|
|
2614
|
-
constructor(opts) {
|
|
2615
|
-
if (opts) {
|
|
2616
|
-
this.opts = opts;
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
|
-
/** Returns true if two extensions are equivalent */
|
|
2620
|
-
equals(extension) {
|
|
2621
|
-
if (this === extension) {
|
|
2622
|
-
return true;
|
|
2623
|
-
}
|
|
2624
|
-
return this.constructor === extension.constructor && deepEqual(this.opts, extension.opts, 1);
|
|
2625
|
-
}
|
|
2626
|
-
/** Only called if attached to a primitive layer */
|
|
2627
|
-
getShaders(extension) {
|
|
2628
|
-
return null;
|
|
2629
|
-
}
|
|
2630
|
-
/** Only called if attached to a CompositeLayer */
|
|
2631
|
-
getSubLayerProps(extension) {
|
|
2632
|
-
const { defaultProps: defaultProps9 } = extension.constructor;
|
|
2633
|
-
const newProps = {
|
|
2634
|
-
updateTriggers: {}
|
|
2635
|
-
};
|
|
2636
|
-
for (const key in defaultProps9) {
|
|
2637
|
-
if (key in this.props) {
|
|
2638
|
-
const propDef = defaultProps9[key];
|
|
2639
|
-
const propValue = this.props[key];
|
|
2640
|
-
newProps[key] = propValue;
|
|
2641
|
-
if (propDef && propDef.type === "accessor") {
|
|
2642
|
-
newProps.updateTriggers[key] = this.props.updateTriggers[key];
|
|
2643
|
-
if (typeof propValue === "function") {
|
|
2644
|
-
newProps[key] = this.getSubLayerAccessor(propValue);
|
|
2645
|
-
}
|
|
2646
|
-
}
|
|
2647
|
-
}
|
|
2648
|
-
}
|
|
2649
|
-
return newProps;
|
|
2650
|
-
}
|
|
2651
|
-
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
2652
|
-
initializeState(context, extension) {
|
|
2653
|
-
}
|
|
2654
|
-
updateState(params, extension) {
|
|
2655
|
-
}
|
|
2656
|
-
onNeedsRedraw(extension) {
|
|
2657
|
-
}
|
|
2658
|
-
getNeedsPickingBuffer(extension) {
|
|
2659
|
-
return false;
|
|
2660
|
-
}
|
|
2661
|
-
draw(params, extension) {
|
|
2662
|
-
}
|
|
2663
|
-
finalizeState(context, extension) {
|
|
2664
|
-
}
|
|
2665
|
-
};
|
|
2666
|
-
LayerExtension.defaultProps = {};
|
|
2667
|
-
LayerExtension.extensionName = "LayerExtension";
|
|
35
|
+
// dist/brushing/brushing-extension.js
|
|
36
|
+
var import_core2 = require("@deck.gl/core");
|
|
2668
37
|
|
|
2669
38
|
// dist/brushing/shader-module.js
|
|
39
|
+
var import_core = require("@deck.gl/core");
|
|
2670
40
|
var uniformBlock = (
|
|
2671
41
|
/* glsl */
|
|
2672
42
|
`layout(std140) uniform brushingUniforms {
|
|
@@ -2704,7 +74,7 @@ var vertex = (
|
|
|
2704
74
|
}
|
|
2705
75
|
`
|
|
2706
76
|
);
|
|
2707
|
-
var
|
|
77
|
+
var vs = `
|
|
2708
78
|
${uniformBlock}
|
|
2709
79
|
${vertex}
|
|
2710
80
|
`;
|
|
@@ -2714,7 +84,7 @@ var fragment = (
|
|
|
2714
84
|
in float brushing_isVisible;
|
|
2715
85
|
`
|
|
2716
86
|
);
|
|
2717
|
-
var
|
|
87
|
+
var fs = `
|
|
2718
88
|
${uniformBlock}
|
|
2719
89
|
${fragment}
|
|
2720
90
|
`;
|
|
@@ -2757,9 +127,9 @@ var inject = {
|
|
|
2757
127
|
};
|
|
2758
128
|
var shader_module_default = {
|
|
2759
129
|
name: "brushing",
|
|
2760
|
-
dependencies: [
|
|
2761
|
-
vs
|
|
2762
|
-
fs
|
|
130
|
+
dependencies: [import_core.project],
|
|
131
|
+
vs,
|
|
132
|
+
fs,
|
|
2763
133
|
inject,
|
|
2764
134
|
getUniforms: (opts) => {
|
|
2765
135
|
if (!opts || !("viewport" in opts)) {
|
|
@@ -2788,7 +158,7 @@ var defaultProps = {
|
|
|
2788
158
|
brushingEnabled: true,
|
|
2789
159
|
brushingRadius: 1e4
|
|
2790
160
|
};
|
|
2791
|
-
var BrushingExtension = class extends LayerExtension {
|
|
161
|
+
var BrushingExtension = class extends import_core2.LayerExtension {
|
|
2792
162
|
getShaders() {
|
|
2793
163
|
return {
|
|
2794
164
|
modules: [shader_module_default]
|
|
@@ -2843,6 +213,9 @@ BrushingExtension.defaultProps = defaultProps;
|
|
|
2843
213
|
BrushingExtension.extensionName = "BrushingExtension";
|
|
2844
214
|
var brushing_extension_default = BrushingExtension;
|
|
2845
215
|
|
|
216
|
+
// dist/data-filter/data-filter-extension.js
|
|
217
|
+
var import_core3 = require("@deck.gl/core");
|
|
218
|
+
|
|
2846
219
|
// dist/data-filter/shader-module.js
|
|
2847
220
|
var uniformBlock2 = (
|
|
2848
221
|
/* glsl */
|
|
@@ -3026,7 +399,7 @@ float dataFilter_reduceValue(vec4 value) {
|
|
|
3026
399
|
#endif
|
|
3027
400
|
`
|
|
3028
401
|
);
|
|
3029
|
-
var
|
|
402
|
+
var vs2 = `
|
|
3030
403
|
${uniformBlock2}
|
|
3031
404
|
${vertex2}
|
|
3032
405
|
`;
|
|
@@ -3036,11 +409,11 @@ var fragment2 = (
|
|
|
3036
409
|
in float dataFilter_value;
|
|
3037
410
|
`
|
|
3038
411
|
);
|
|
3039
|
-
var
|
|
412
|
+
var fs2 = `
|
|
3040
413
|
${uniformBlock2}
|
|
3041
414
|
${fragment2}
|
|
3042
415
|
`;
|
|
3043
|
-
function
|
|
416
|
+
function getUniforms(opts) {
|
|
3044
417
|
if (!opts || !("extensions" in opts)) {
|
|
3045
418
|
return {};
|
|
3046
419
|
}
|
|
@@ -3075,7 +448,7 @@ function getUniforms64(opts) {
|
|
|
3075
448
|
if (!opts || !("extensions" in opts)) {
|
|
3076
449
|
return {};
|
|
3077
450
|
}
|
|
3078
|
-
const uniforms =
|
|
451
|
+
const uniforms = getUniforms(opts);
|
|
3079
452
|
const min64High = uniforms.min.map(Math.fround);
|
|
3080
453
|
uniforms.min = uniforms.min.map((x, i) => x - min64High[i]);
|
|
3081
454
|
uniforms.softMin = uniforms.softMin.map((x, i) => x - min64High[i]);
|
|
@@ -3153,16 +526,16 @@ function uniformTypesFromOptions(opts) {
|
|
|
3153
526
|
}
|
|
3154
527
|
var dataFilter = {
|
|
3155
528
|
name: "dataFilter",
|
|
3156
|
-
vs:
|
|
3157
|
-
fs:
|
|
529
|
+
vs: vs2,
|
|
530
|
+
fs: fs2,
|
|
3158
531
|
inject: inject2,
|
|
3159
|
-
getUniforms
|
|
532
|
+
getUniforms,
|
|
3160
533
|
uniformTypesFromOptions
|
|
3161
534
|
};
|
|
3162
535
|
var dataFilter64 = {
|
|
3163
536
|
name: "dataFilter",
|
|
3164
|
-
vs:
|
|
3165
|
-
fs:
|
|
537
|
+
vs: vs2,
|
|
538
|
+
fs: fs2,
|
|
3166
539
|
inject: inject2,
|
|
3167
540
|
getUniforms: getUniforms64,
|
|
3168
541
|
uniformTypesFromOptions
|
|
@@ -3307,24 +680,24 @@ var DATA_TYPE_FROM_SIZE = {
|
|
|
3307
680
|
3: "vec3",
|
|
3308
681
|
4: "vec4"
|
|
3309
682
|
};
|
|
3310
|
-
var DataFilterExtension = class extends LayerExtension {
|
|
683
|
+
var DataFilterExtension = class extends import_core3.LayerExtension {
|
|
3311
684
|
constructor(opts = {}) {
|
|
3312
685
|
super({ ...defaultOptions, ...opts });
|
|
3313
686
|
}
|
|
3314
687
|
getShaders(extension) {
|
|
3315
688
|
const { categorySize, filterSize, fp64: fp642 } = extension.opts;
|
|
3316
|
-
const
|
|
689
|
+
const defines = {};
|
|
3317
690
|
if (categorySize) {
|
|
3318
|
-
|
|
3319
|
-
|
|
691
|
+
defines.DATACATEGORY_TYPE = CATEGORY_TYPE_FROM_SIZE[categorySize];
|
|
692
|
+
defines.DATACATEGORY_CHANNELS = categorySize;
|
|
3320
693
|
}
|
|
3321
694
|
if (filterSize) {
|
|
3322
|
-
|
|
3323
|
-
|
|
695
|
+
defines.DATAFILTER_TYPE = DATA_TYPE_FROM_SIZE[filterSize];
|
|
696
|
+
defines.DATAFILTER_DOUBLE = Boolean(fp642);
|
|
3324
697
|
}
|
|
3325
698
|
const module2 = fp642 ? dataFilter64 : dataFilter;
|
|
3326
699
|
module2.uniformTypes = module2.uniformTypesFromOptions(extension.opts);
|
|
3327
|
-
return { modules: [module2], defines
|
|
700
|
+
return { modules: [module2], defines };
|
|
3328
701
|
}
|
|
3329
702
|
initializeState(context, extension) {
|
|
3330
703
|
const attributeManager = this.getAttributeManager();
|
|
@@ -3394,7 +767,7 @@ var DataFilterExtension = class extends LayerExtension {
|
|
|
3394
767
|
}
|
|
3395
768
|
}
|
|
3396
769
|
if (attributeManager == null ? void 0 : attributeManager.attributes.filterCategoryValues) {
|
|
3397
|
-
const categoryBitMaskNeedsUpdate = attributeManager.attributes.filterCategoryValues.needsUpdate() || !
|
|
770
|
+
const categoryBitMaskNeedsUpdate = attributeManager.attributes.filterCategoryValues.needsUpdate() || !(0, import_core3._deepEqual)(props.filterCategories, oldProps.filterCategories, 2);
|
|
3398
771
|
if (categoryBitMaskNeedsUpdate) {
|
|
3399
772
|
this.setState({ categoryBitMask: null });
|
|
3400
773
|
}
|
|
@@ -3488,7 +861,7 @@ var DataFilterExtension = class extends LayerExtension {
|
|
|
3488
861
|
const channel = c * (maxCategories / 32) + Math.floor(key / 32);
|
|
3489
862
|
categoryBitMask[channel] += Math.pow(2, key % 32);
|
|
3490
863
|
} else {
|
|
3491
|
-
|
|
864
|
+
import_core3.log.warn(`Exceeded maximum number of categories (${maxCategories})`)();
|
|
3492
865
|
}
|
|
3493
866
|
}
|
|
3494
867
|
}
|
|
@@ -3510,8 +883,12 @@ DataFilterExtension.defaultProps = defaultProps2;
|
|
|
3510
883
|
DataFilterExtension.extensionName = "DataFilterExtension";
|
|
3511
884
|
var data_filter_extension_default = DataFilterExtension;
|
|
3512
885
|
|
|
886
|
+
// dist/fp64/fp64-extension.js
|
|
887
|
+
var import_core5 = require("@deck.gl/core");
|
|
888
|
+
|
|
3513
889
|
// dist/fp64/project64.js
|
|
3514
|
-
var
|
|
890
|
+
var import_shadertools = require("@luma.gl/shadertools");
|
|
891
|
+
var import_core4 = require("@deck.gl/core");
|
|
3515
892
|
|
|
3516
893
|
// dist/fp64/project64.glsl.js
|
|
3517
894
|
var project64_glsl_default = `const vec2 WORLD_SCALE_FP64 = vec2(81.4873275756836, 0.0000032873668232014097);
|
|
@@ -3590,12 +967,12 @@ position, position64xyLow, offset, commonPosition
|
|
|
3590
967
|
`;
|
|
3591
968
|
|
|
3592
969
|
// dist/fp64/project64.js
|
|
3593
|
-
var { fp64ify, fp64ifyMatrix4 } =
|
|
970
|
+
var { fp64ify, fp64ifyMatrix4 } = import_shadertools.fp64;
|
|
3594
971
|
var project64_default = {
|
|
3595
972
|
name: "project64",
|
|
3596
|
-
dependencies: [
|
|
973
|
+
dependencies: [import_core4.project, import_shadertools.fp64],
|
|
3597
974
|
vs: project64_glsl_default,
|
|
3598
|
-
getUniforms:
|
|
975
|
+
getUniforms: getUniforms2,
|
|
3599
976
|
uniformTypes: {
|
|
3600
977
|
scale: "vec2<f32>",
|
|
3601
978
|
// Cannot pass as vec2[16], so instead split into 2 mat4x4
|
|
@@ -3603,8 +980,8 @@ var project64_default = {
|
|
|
3603
980
|
viewProjectionMatrix64Low: "mat4x4<f32>"
|
|
3604
981
|
}
|
|
3605
982
|
};
|
|
3606
|
-
var getMemoizedUniforms =
|
|
3607
|
-
function
|
|
983
|
+
var getMemoizedUniforms = (0, import_core4._memoize)(calculateUniforms);
|
|
984
|
+
function getUniforms2(opts) {
|
|
3608
985
|
if (opts && "viewport" in opts) {
|
|
3609
986
|
const { viewProjectionMatrix, scale } = opts.viewport;
|
|
3610
987
|
return getMemoizedUniforms({ viewProjectionMatrix, scale });
|
|
@@ -3631,7 +1008,7 @@ function calculateUniforms({ viewProjectionMatrix, scale }) {
|
|
|
3631
1008
|
}
|
|
3632
1009
|
|
|
3633
1010
|
// dist/fp64/fp64-extension.js
|
|
3634
|
-
var Fp64Extension = class extends LayerExtension {
|
|
1011
|
+
var Fp64Extension = class extends import_core5.LayerExtension {
|
|
3635
1012
|
getShaders() {
|
|
3636
1013
|
const { coordinateSystem } = this.props;
|
|
3637
1014
|
if (coordinateSystem !== "lnglat" && coordinateSystem !== "default") {
|
|
@@ -3650,7 +1027,8 @@ Fp64Extension.extensionName = "Fp64Extension";
|
|
|
3650
1027
|
var fp64_extension_default = Fp64Extension;
|
|
3651
1028
|
|
|
3652
1029
|
// dist/path-style/path-style-extension.js
|
|
3653
|
-
var
|
|
1030
|
+
var import_core6 = require("@deck.gl/core");
|
|
1031
|
+
var import_core7 = require("@math.gl/core");
|
|
3654
1032
|
|
|
3655
1033
|
// dist/path-style/shaders.glsl.js
|
|
3656
1034
|
var dashShaders = {
|
|
@@ -4060,14 +1438,14 @@ var DASH_UNITS = {
|
|
|
4060
1438
|
};
|
|
4061
1439
|
var PATH_STYLE_ATTRIBUTES = ["instanceDashArrays", "instanceDashOffsets", "instanceOffsets"];
|
|
4062
1440
|
function dashMetricsProjectionPropsChanged({ props, oldProps }) {
|
|
4063
|
-
return !
|
|
1441
|
+
return !(0, import_core6._deepEqual)(props.modelMatrix, oldProps.modelMatrix, 2) || props.coordinateSystem !== oldProps.coordinateSystem || !(0, import_core6._deepEqual)(props.coordinateOrigin, oldProps.coordinateOrigin, 1);
|
|
4064
1442
|
}
|
|
4065
1443
|
function projectRenderedPathPosition(layer, position, projectUniforms) {
|
|
4066
1444
|
const viewport = layer.context.viewport;
|
|
4067
|
-
if (!(viewport instanceof WebMercatorViewport) || viewport.zoom < 12) {
|
|
1445
|
+
if (!(viewport instanceof import_core6.WebMercatorViewport) || viewport.zoom < 12) {
|
|
4068
1446
|
return layer.projectPosition(position, { autoOffset: false });
|
|
4069
1447
|
}
|
|
4070
|
-
const positionWorld =
|
|
1448
|
+
const positionWorld = import_core7.vec4.transformMat4([], [position[0], position[1], position[2] || 0, 1], projectUniforms.modelMatrix);
|
|
4071
1449
|
const coordinateSystem = layer.props.coordinateSystem === "default" ? "lnglat" : layer.props.coordinateSystem;
|
|
4072
1450
|
if (coordinateSystem === "lnglat") {
|
|
4073
1451
|
if (Math.abs(positionWorld[1] - projectUniforms.coordinateOrigin[1]) > 0.25) {
|
|
@@ -4082,15 +1460,15 @@ function projectRenderedPathPosition(layer, position, projectUniforms) {
|
|
|
4082
1460
|
positionWorld[2] * projectUniforms.commonUnitsPerMeter[2]
|
|
4083
1461
|
];
|
|
4084
1462
|
}
|
|
4085
|
-
|
|
1463
|
+
import_core7.vec3.sub(positionWorld, positionWorld, projectUniforms.coordinateOrigin);
|
|
4086
1464
|
} else if (coordinateSystem === "cartesian") {
|
|
4087
|
-
|
|
1465
|
+
import_core7.vec3.sub(positionWorld, positionWorld, projectUniforms.coordinateOrigin);
|
|
4088
1466
|
}
|
|
4089
1467
|
const deltaLatitude = positionWorld[1];
|
|
4090
|
-
const scale =
|
|
4091
|
-
return
|
|
1468
|
+
const scale = import_core7.vec3.scaleAndAdd([], projectUniforms.commonUnitsPerWorldUnit, projectUniforms.commonUnitsPerWorldUnit2, deltaLatitude);
|
|
1469
|
+
return import_core7.vec3.multiply([], positionWorld, scale);
|
|
4092
1470
|
}
|
|
4093
|
-
var PathStyleExtension = class extends LayerExtension {
|
|
1471
|
+
var PathStyleExtension = class extends import_core6.LayerExtension {
|
|
4094
1472
|
constructor({ dash = false, offset = false, dashMode, highPrecisionDash = false } = {}) {
|
|
4095
1473
|
const resolvedDashMode = dashMode ?? (highPrecisionDash ? "path" : "segment");
|
|
4096
1474
|
super({
|
|
@@ -4189,17 +1567,17 @@ var PathStyleExtension = class extends LayerExtension {
|
|
|
4189
1567
|
return { modules: [pathStyle2] };
|
|
4190
1568
|
}
|
|
4191
1569
|
let result = {};
|
|
4192
|
-
const
|
|
1570
|
+
const defines = {};
|
|
4193
1571
|
if (extension.opts.dash) {
|
|
4194
|
-
result =
|
|
4195
|
-
|
|
1572
|
+
result = (0, import_core6._mergeShaders)(result, dashShaders);
|
|
1573
|
+
defines.DASH_ENABLED = true;
|
|
4196
1574
|
if (extension.opts.dashMode === "path") {
|
|
4197
|
-
|
|
1575
|
+
defines.HIGH_PRECISION_DASH = true;
|
|
4198
1576
|
}
|
|
4199
1577
|
}
|
|
4200
1578
|
if (extension.opts.offset) {
|
|
4201
|
-
result =
|
|
4202
|
-
|
|
1579
|
+
result = (0, import_core6._mergeShaders)(result, offsetShaders);
|
|
1580
|
+
defines.PATH_STYLE_OFFSET = true;
|
|
4203
1581
|
}
|
|
4204
1582
|
const { inject: inject6 } = result;
|
|
4205
1583
|
const pathStyle = {
|
|
@@ -4215,7 +1593,7 @@ var PathStyleExtension = class extends LayerExtension {
|
|
|
4215
1593
|
}
|
|
4216
1594
|
return {
|
|
4217
1595
|
modules: [pathStyle],
|
|
4218
|
-
defines
|
|
1596
|
+
defines
|
|
4219
1597
|
};
|
|
4220
1598
|
}
|
|
4221
1599
|
initializeState(context, extension) {
|
|
@@ -4286,7 +1664,7 @@ var PathStyleExtension = class extends LayerExtension {
|
|
|
4286
1664
|
binaryOffset = (binaryPath == null ? void 0 : binaryPath.offset) ? binaryPath.offset / bytesPerElement : 0;
|
|
4287
1665
|
}
|
|
4288
1666
|
const sourcePosition = new Array(3);
|
|
4289
|
-
const projectUniforms =
|
|
1667
|
+
const projectUniforms = import_core6.project.getUniforms({
|
|
4290
1668
|
viewport: this.context.viewport,
|
|
4291
1669
|
modelMatrix: this.props.modelMatrix,
|
|
4292
1670
|
coordinateSystem: this.props.coordinateSystem,
|
|
@@ -4321,7 +1699,7 @@ var PathStyleExtension = class extends LayerExtension {
|
|
|
4321
1699
|
output[outputIndex] = phase;
|
|
4322
1700
|
const start = segmentIndex === previousSegment + 1 && previousEnd ? previousEnd : projectRenderedPathPosition(this, readPosition(segmentIndex), projectUniforms);
|
|
4323
1701
|
const end = projectRenderedPathPosition(this, readPosition(segmentIndex + 1), projectUniforms);
|
|
4324
|
-
phase +=
|
|
1702
|
+
phase += import_core7.vec3.dist(start, end);
|
|
4325
1703
|
previousSegment = segmentIndex;
|
|
4326
1704
|
previousEnd = end;
|
|
4327
1705
|
}
|
|
@@ -4350,7 +1728,7 @@ var PathStyleExtension = class extends LayerExtension {
|
|
|
4350
1728
|
p = isNested ? path[i] : path.slice(i * positionSize, i * positionSize + positionSize);
|
|
4351
1729
|
p = this.projectPosition(p, { autoOffset: false });
|
|
4352
1730
|
if (i > 0) {
|
|
4353
|
-
result[i] = result[i - 1] +
|
|
1731
|
+
result[i] = result[i - 1] + import_core7.vec3.dist(prevP, p);
|
|
4354
1732
|
}
|
|
4355
1733
|
prevP = p;
|
|
4356
1734
|
}
|
|
@@ -4362,7 +1740,11 @@ PathStyleExtension.defaultProps = defaultProps3;
|
|
|
4362
1740
|
PathStyleExtension.extensionName = "PathStyleExtension";
|
|
4363
1741
|
var path_style_extension_default = PathStyleExtension;
|
|
4364
1742
|
|
|
1743
|
+
// dist/fill-style/fill-style-extension.js
|
|
1744
|
+
var import_core9 = require("@deck.gl/core");
|
|
1745
|
+
|
|
4365
1746
|
// dist/fill-style/shader-module.js
|
|
1747
|
+
var import_core8 = require("@deck.gl/core");
|
|
4366
1748
|
var FILL_UV_SCALE = 512 / 4e7;
|
|
4367
1749
|
function getPatternUnitScale(sizeUnits, viewport) {
|
|
4368
1750
|
switch (sizeUnits) {
|
|
@@ -4407,7 +1789,7 @@ flat out vec4 fill_patternParams0;
|
|
|
4407
1789
|
flat out vec4 fill_patternParams1;
|
|
4408
1790
|
`
|
|
4409
1791
|
);
|
|
4410
|
-
var
|
|
1792
|
+
var vs3 = `
|
|
4411
1793
|
${uniformBlock3}
|
|
4412
1794
|
${patternVs}
|
|
4413
1795
|
`;
|
|
@@ -4550,7 +1932,7 @@ vec4 fill_blendOverBackground(vec4 pattern, vec4 background) {
|
|
|
4550
1932
|
}
|
|
4551
1933
|
`
|
|
4552
1934
|
);
|
|
4553
|
-
var
|
|
1935
|
+
var fs3 = `
|
|
4554
1936
|
${uniformBlock3}
|
|
4555
1937
|
${patternFs}
|
|
4556
1938
|
`;
|
|
@@ -4627,7 +2009,7 @@ function getPatternUniforms(opts) {
|
|
|
4627
2009
|
}
|
|
4628
2010
|
if ("project" in opts) {
|
|
4629
2011
|
const { fillPatternMask = true, fillPatternEnabled = true, fillPatternSizeUnits = "meters", fillPatternCommonFrame = null, procedural = false } = opts;
|
|
4630
|
-
const projectUniforms =
|
|
2012
|
+
const projectUniforms = import_core8.project.getUniforms(opts.project);
|
|
4631
2013
|
const { commonOrigin: coordinateOriginCommon } = projectUniforms;
|
|
4632
2014
|
const unitScale = getPatternUnitScale(fillPatternSizeUnits, opts.project.viewport);
|
|
4633
2015
|
const origin = [coordinateOriginCommon[0], coordinateOriginCommon[1]];
|
|
@@ -4636,7 +2018,7 @@ function getPatternUniforms(opts) {
|
|
|
4636
2018
|
origin[1] %= unitScale * fillPatternCommonFrame[1];
|
|
4637
2019
|
}
|
|
4638
2020
|
uniforms.uvCoordinateOrigin = origin;
|
|
4639
|
-
uniforms.uvCoordinateOrigin64Low = [fp64LowPart(origin[0]), fp64LowPart(origin[1])];
|
|
2021
|
+
uniforms.uvCoordinateOrigin64Low = [(0, import_core8.fp64LowPart)(origin[0]), (0, import_core8.fp64LowPart)(origin[1])];
|
|
4640
2022
|
uniforms.patternUnitScale = unitScale;
|
|
4641
2023
|
uniforms.patternMask = fillPatternMask;
|
|
4642
2024
|
uniforms.patternEnabled = fillPatternEnabled;
|
|
@@ -4647,10 +2029,10 @@ function getPatternUniforms(opts) {
|
|
|
4647
2029
|
}
|
|
4648
2030
|
var patternShaders = {
|
|
4649
2031
|
name: "fill",
|
|
4650
|
-
vs:
|
|
4651
|
-
fs:
|
|
2032
|
+
vs: vs3,
|
|
2033
|
+
fs: fs3,
|
|
4652
2034
|
inject: inject3,
|
|
4653
|
-
dependencies: [
|
|
2035
|
+
dependencies: [import_core8.project],
|
|
4654
2036
|
getUniforms: getPatternUniforms,
|
|
4655
2037
|
uniformTypes: {
|
|
4656
2038
|
patternTextureSize: "vec2<f32>",
|
|
@@ -4685,7 +2067,7 @@ var PROCEDURAL_PATTERN_OFFSETS = {
|
|
|
4685
2067
|
elementCount: 6
|
|
4686
2068
|
};
|
|
4687
2069
|
var COMPONENTS_PER_PATTERN = PROCEDURAL_PATTERN_COMPONENTS_PER_TEXEL * PROCEDURAL_PATTERN_TEXELS_PER_PATTERN;
|
|
4688
|
-
var
|
|
2070
|
+
var DEGREES_TO_RADIANS = Math.PI / 180;
|
|
4689
2071
|
var DEFAULT_SIZE = 1;
|
|
4690
2072
|
var DEFAULT_GAP = 1;
|
|
4691
2073
|
var DEFAULT_HATCH_ANGLE = 0;
|
|
@@ -4717,7 +2099,7 @@ function packProceduralPatterns(mapping) {
|
|
|
4717
2099
|
data[offset + PROCEDURAL_PATTERN_OFFSETS.size] = strokeWidth;
|
|
4718
2100
|
data[offset + PROCEDURAL_PATTERN_OFFSETS.gap0] = gaps[0];
|
|
4719
2101
|
data[offset + PROCEDURAL_PATTERN_OFFSETS.gap1] = gaps[1];
|
|
4720
|
-
data[offset + PROCEDURAL_PATTERN_OFFSETS.angle0] = angle *
|
|
2102
|
+
data[offset + PROCEDURAL_PATTERN_OFFSETS.angle0] = angle * DEGREES_TO_RADIANS;
|
|
4721
2103
|
data[offset + PROCEDURAL_PATTERN_OFFSETS.elementCount] = Array.isArray(gap) ? 2 : 1;
|
|
4722
2104
|
break;
|
|
4723
2105
|
}
|
|
@@ -4736,8 +2118,8 @@ function packProceduralPatterns(mapping) {
|
|
|
4736
2118
|
data[offset + PROCEDURAL_PATTERN_OFFSETS.size] = strokeWidth;
|
|
4737
2119
|
data[offset + PROCEDURAL_PATTERN_OFFSETS.gap0] = gap;
|
|
4738
2120
|
data[offset + PROCEDURAL_PATTERN_OFFSETS.gap1] = gap;
|
|
4739
|
-
data[offset + PROCEDURAL_PATTERN_OFFSETS.angle0] = angles[0] *
|
|
4740
|
-
data[offset + PROCEDURAL_PATTERN_OFFSETS.angle1] = angles[1] *
|
|
2121
|
+
data[offset + PROCEDURAL_PATTERN_OFFSETS.angle0] = angles[0] * DEGREES_TO_RADIANS;
|
|
2122
|
+
data[offset + PROCEDURAL_PATTERN_OFFSETS.angle1] = angles[1] * DEGREES_TO_RADIANS;
|
|
4741
2123
|
data[offset + PROCEDURAL_PATTERN_OFFSETS.elementCount] = 2;
|
|
4742
2124
|
break;
|
|
4743
2125
|
}
|
|
@@ -4754,8 +2136,8 @@ function packProceduralPatterns(mapping) {
|
|
|
4754
2136
|
data[offset + PROCEDURAL_PATTERN_OFFSETS.size] = radius;
|
|
4755
2137
|
data[offset + PROCEDURAL_PATTERN_OFFSETS.gap0] = gap;
|
|
4756
2138
|
data[offset + PROCEDURAL_PATTERN_OFFSETS.gap1] = gap;
|
|
4757
|
-
data[offset + PROCEDURAL_PATTERN_OFFSETS.angle0] = angle *
|
|
4758
|
-
data[offset + PROCEDURAL_PATTERN_OFFSETS.angle1] = skew *
|
|
2139
|
+
data[offset + PROCEDURAL_PATTERN_OFFSETS.angle0] = angle * DEGREES_TO_RADIANS;
|
|
2140
|
+
data[offset + PROCEDURAL_PATTERN_OFFSETS.angle1] = skew * DEGREES_TO_RADIANS;
|
|
4759
2141
|
data[offset + PROCEDURAL_PATTERN_OFFSETS.elementCount] = 2;
|
|
4760
2142
|
break;
|
|
4761
2143
|
}
|
|
@@ -4817,7 +2199,7 @@ var defaultProps4 = {
|
|
|
4817
2199
|
getFillPatternOffset: { type: "accessor", value: [0, 0] },
|
|
4818
2200
|
getFillPatternBackgroundColor: { type: "accessor", value: [0, 0, 0, 0] }
|
|
4819
2201
|
};
|
|
4820
|
-
var FillStyleExtension = class extends LayerExtension {
|
|
2202
|
+
var FillStyleExtension = class extends import_core9.LayerExtension {
|
|
4821
2203
|
constructor({ pattern = false, proceduralPattern = false } = {}) {
|
|
4822
2204
|
super({ pattern: pattern || proceduralPattern, proceduralPattern });
|
|
4823
2205
|
}
|
|
@@ -4961,6 +2343,7 @@ FillStyleExtension.extensionName = "FillStyleExtension";
|
|
|
4961
2343
|
var fill_style_extension_default = FillStyleExtension;
|
|
4962
2344
|
|
|
4963
2345
|
// dist/clip/clip-extension.js
|
|
2346
|
+
var import_core10 = require("@deck.gl/core");
|
|
4964
2347
|
var defaultProps5 = {
|
|
4965
2348
|
clipBounds: [0, 0, 1, 1],
|
|
4966
2349
|
clipByInstance: void 0
|
|
@@ -5043,7 +2426,7 @@ in vec2 clip_commonPosition;
|
|
|
5043
2426
|
`
|
|
5044
2427
|
)
|
|
5045
2428
|
};
|
|
5046
|
-
var ClipExtension = class extends LayerExtension {
|
|
2429
|
+
var ClipExtension = class extends import_core10.LayerExtension {
|
|
5047
2430
|
getShaders() {
|
|
5048
2431
|
let clipByInstance = "instancePositions" in this.getAttributeManager().attributes;
|
|
5049
2432
|
if (this.props.clipByInstance !== void 0) {
|
|
@@ -5088,8 +2471,12 @@ ClipExtension.defaultProps = defaultProps5;
|
|
|
5088
2471
|
ClipExtension.extensionName = "ClipExtension";
|
|
5089
2472
|
var clip_extension_default = ClipExtension;
|
|
5090
2473
|
|
|
2474
|
+
// dist/collision-filter/collision-filter-extension.js
|
|
2475
|
+
var import_core15 = require("@deck.gl/core");
|
|
2476
|
+
|
|
5091
2477
|
// dist/collision-filter/shader-module.js
|
|
5092
|
-
var
|
|
2478
|
+
var import_core11 = require("@deck.gl/core");
|
|
2479
|
+
var vs4 = (
|
|
5093
2480
|
/* glsl */
|
|
5094
2481
|
`
|
|
5095
2482
|
in float collisionPriorities;
|
|
@@ -5187,8 +2574,8 @@ var getCollisionUniforms = (opts) => {
|
|
|
5187
2574
|
};
|
|
5188
2575
|
var shader_module_default2 = {
|
|
5189
2576
|
name: "collision",
|
|
5190
|
-
dependencies: [
|
|
5191
|
-
vs:
|
|
2577
|
+
dependencies: [import_core11.project],
|
|
2578
|
+
vs: vs4,
|
|
5192
2579
|
inject: inject4,
|
|
5193
2580
|
getUniforms: getCollisionUniforms,
|
|
5194
2581
|
uniformTypes: {
|
|
@@ -5198,10 +2585,12 @@ var shader_module_default2 = {
|
|
|
5198
2585
|
};
|
|
5199
2586
|
|
|
5200
2587
|
// dist/collision-filter/collision-filter-effect.js
|
|
5201
|
-
var
|
|
2588
|
+
var import_core13 = require("@math.gl/core");
|
|
2589
|
+
var import_core14 = require("@deck.gl/core");
|
|
5202
2590
|
|
|
5203
2591
|
// dist/collision-filter/collision-filter-pass.js
|
|
5204
|
-
var
|
|
2592
|
+
var import_core12 = require("@deck.gl/core");
|
|
2593
|
+
var CollisionFilterPass = class extends import_core12._LayersPass {
|
|
5205
2594
|
renderCollisionMap(target, options) {
|
|
5206
2595
|
const padding = 1;
|
|
5207
2596
|
const clearColor = [0, 0, 0, 0];
|
|
@@ -5292,8 +2681,8 @@ var CollisionFilterEffect = class {
|
|
|
5292
2681
|
}
|
|
5293
2682
|
const needsRender = viewportChanged || // If render info is new
|
|
5294
2683
|
renderInfo === oldRenderInfo || // If sublayers have changed
|
|
5295
|
-
!
|
|
5296
|
-
renderInfo.layerBounds.some((b, i) => !(0,
|
|
2684
|
+
!(0, import_core14._deepEqual)(oldRenderInfo.layers, renderInfo.layers, 1) || // If a sublayer's bounds have been updated
|
|
2685
|
+
renderInfo.layerBounds.some((b, i) => !(0, import_core13.equals)(b, oldRenderInfo.layerBounds[i])) || // If a sublayer's isLoaded state has been updated
|
|
5297
2686
|
renderInfo.allLayersLoaded !== oldRenderInfo.allLayersLoaded || // Some prop is in transition
|
|
5298
2687
|
renderInfo.layers.some((layer) => layer.props.transitions);
|
|
5299
2688
|
this.channels[collisionGroup] = renderInfo;
|
|
@@ -5425,7 +2814,7 @@ var defaultProps6 = {
|
|
|
5425
2814
|
collisionGroup: { type: "string", value: "default" },
|
|
5426
2815
|
collisionTestProps: {}
|
|
5427
2816
|
};
|
|
5428
|
-
var CollisionFilterExtension = class extends LayerExtension {
|
|
2817
|
+
var CollisionFilterExtension = class extends import_core15.LayerExtension {
|
|
5429
2818
|
getShaders() {
|
|
5430
2819
|
return { modules: [shader_module_default2] };
|
|
5431
2820
|
}
|
|
@@ -5459,7 +2848,11 @@ CollisionFilterExtension.defaultProps = defaultProps6;
|
|
|
5459
2848
|
CollisionFilterExtension.extensionName = "CollisionFilterExtension";
|
|
5460
2849
|
var collision_filter_extension_default = CollisionFilterExtension;
|
|
5461
2850
|
|
|
2851
|
+
// dist/mask/mask-extension.js
|
|
2852
|
+
var import_core21 = require("@deck.gl/core");
|
|
2853
|
+
|
|
5462
2854
|
// dist/mask/shader-module.js
|
|
2855
|
+
var import_core16 = require("@deck.gl/core");
|
|
5463
2856
|
var uniformBlock4 = (
|
|
5464
2857
|
/* glsl */
|
|
5465
2858
|
`layout(std140) uniform maskUniforms {
|
|
@@ -5479,7 +2872,7 @@ vec2 mask_getCoords(vec4 position) {
|
|
|
5479
2872
|
}
|
|
5480
2873
|
`
|
|
5481
2874
|
);
|
|
5482
|
-
var
|
|
2875
|
+
var vs5 = `
|
|
5483
2876
|
${uniformBlock4}
|
|
5484
2877
|
${vertex3}
|
|
5485
2878
|
`;
|
|
@@ -5512,7 +2905,7 @@ bool mask_isInBounds(vec2 texCoords) {
|
|
|
5512
2905
|
}
|
|
5513
2906
|
`
|
|
5514
2907
|
);
|
|
5515
|
-
var
|
|
2908
|
+
var fs4 = `
|
|
5516
2909
|
${uniformBlock4}
|
|
5517
2910
|
${fragment3}
|
|
5518
2911
|
`;
|
|
@@ -5566,9 +2959,9 @@ var getMaskUniforms = (opts) => {
|
|
|
5566
2959
|
};
|
|
5567
2960
|
var shader_module_default3 = {
|
|
5568
2961
|
name: "mask",
|
|
5569
|
-
dependencies: [
|
|
5570
|
-
vs:
|
|
5571
|
-
fs:
|
|
2962
|
+
dependencies: [import_core16.project],
|
|
2963
|
+
vs: vs5,
|
|
2964
|
+
fs: fs4,
|
|
5572
2965
|
inject: inject5,
|
|
5573
2966
|
getUniforms: getMaskUniforms,
|
|
5574
2967
|
uniformTypes: {
|
|
@@ -5581,9 +2974,11 @@ var shader_module_default3 = {
|
|
|
5581
2974
|
};
|
|
5582
2975
|
|
|
5583
2976
|
// dist/mask/mask-effect.js
|
|
5584
|
-
var
|
|
2977
|
+
var import_core19 = require("@deck.gl/core");
|
|
2978
|
+
var import_core20 = require("@math.gl/core");
|
|
5585
2979
|
|
|
5586
2980
|
// dist/mask/mask-pass.js
|
|
2981
|
+
var import_core17 = require("@deck.gl/core");
|
|
5587
2982
|
var MASK_BLENDING = {
|
|
5588
2983
|
blendColorOperation: "subtract",
|
|
5589
2984
|
blendColorSrcFactor: "zero",
|
|
@@ -5592,7 +2987,7 @@ var MASK_BLENDING = {
|
|
|
5592
2987
|
blendAlphaSrcFactor: "zero",
|
|
5593
2988
|
blendAlphaDstFactor: "one"
|
|
5594
2989
|
};
|
|
5595
|
-
var MaskPass = class extends
|
|
2990
|
+
var MaskPass = class extends import_core17._LayersPass {
|
|
5596
2991
|
constructor(device, props) {
|
|
5597
2992
|
super(device, props);
|
|
5598
2993
|
const { mapSize = 2048 } = props;
|
|
@@ -5637,7 +3032,8 @@ var MaskPass = class extends LayersPass {
|
|
|
5637
3032
|
};
|
|
5638
3033
|
|
|
5639
3034
|
// dist/utils/projection-utils.js
|
|
5640
|
-
var
|
|
3035
|
+
var import_core18 = require("@deck.gl/core");
|
|
3036
|
+
var MERCATOR_REFERENCE_VIEWPORT = new import_core18.WebMercatorViewport({
|
|
5641
3037
|
width: 1,
|
|
5642
3038
|
height: 1,
|
|
5643
3039
|
longitude: 0,
|
|
@@ -5699,7 +3095,7 @@ function makeViewport(opts) {
|
|
|
5699
3095
|
zoom += Math.log2(r);
|
|
5700
3096
|
}
|
|
5701
3097
|
}
|
|
5702
|
-
return isGeospatial ? new WebMercatorViewport({
|
|
3098
|
+
return isGeospatial ? new import_core18.WebMercatorViewport({
|
|
5703
3099
|
id: viewport.id,
|
|
5704
3100
|
x: border,
|
|
5705
3101
|
y: border,
|
|
@@ -5709,7 +3105,7 @@ function makeViewport(opts) {
|
|
|
5709
3105
|
latitude: centerWorld[1],
|
|
5710
3106
|
zoom,
|
|
5711
3107
|
orthographic: true
|
|
5712
|
-
}) : new OrthographicViewport({
|
|
3108
|
+
}) : new import_core18.OrthographicViewport({
|
|
5713
3109
|
id: viewport.id,
|
|
5714
3110
|
x: border,
|
|
5715
3111
|
y: border,
|
|
@@ -5802,7 +3198,7 @@ var MaskEffect = class {
|
|
|
5802
3198
|
const viewport = viewports[0];
|
|
5803
3199
|
const viewportChanged = !this.lastViewport || !this.lastViewport.equals(viewport);
|
|
5804
3200
|
if (viewport.resolution !== void 0) {
|
|
5805
|
-
|
|
3201
|
+
import_core19.log.warn("MaskExtension is not supported in GlobeView")();
|
|
5806
3202
|
return { didRender };
|
|
5807
3203
|
}
|
|
5808
3204
|
for (const maskId in channelMap) {
|
|
@@ -5845,7 +3241,7 @@ var MaskEffect = class {
|
|
|
5845
3241
|
this.lastViewport = viewport;
|
|
5846
3242
|
const layerBounds = joinLayerBounds(channelInfo.layers, viewport);
|
|
5847
3243
|
channelInfo.bounds = layerBounds && getRenderBounds(layerBounds, viewport);
|
|
5848
|
-
if (maskChanged || !(0,
|
|
3244
|
+
if (maskChanged || !(0, import_core20.equals)(channelInfo.bounds, oldChannelInfo.bounds)) {
|
|
5849
3245
|
const { maskPass, maskMap } = this;
|
|
5850
3246
|
const maskViewport = layerBounds && makeViewport({
|
|
5851
3247
|
bounds: channelInfo.bounds,
|
|
@@ -5896,7 +3292,7 @@ var MaskEffect = class {
|
|
|
5896
3292
|
let channelInfo = channelMap[id];
|
|
5897
3293
|
if (!channelInfo) {
|
|
5898
3294
|
if (++channelCount > 4) {
|
|
5899
|
-
|
|
3295
|
+
import_core19.log.warn("Too many mask layers. The max supported is 4")();
|
|
5900
3296
|
continue;
|
|
5901
3297
|
}
|
|
5902
3298
|
channelInfo = {
|
|
@@ -5957,7 +3353,7 @@ var defaultProps7 = {
|
|
|
5957
3353
|
maskByInstance: void 0,
|
|
5958
3354
|
maskInverted: false
|
|
5959
3355
|
};
|
|
5960
|
-
var MaskExtension = class extends LayerExtension {
|
|
3356
|
+
var MaskExtension = class extends import_core21.LayerExtension {
|
|
5961
3357
|
initializeState() {
|
|
5962
3358
|
var _a;
|
|
5963
3359
|
(_a = this.context.deck) == null ? void 0 : _a._addDefaultEffect(new MaskEffect());
|
|
@@ -5985,8 +3381,8 @@ var MaskExtension = class extends LayerExtension {
|
|
|
5985
3381
|
maskProps.enabled = true;
|
|
5986
3382
|
maskProps.channel = index;
|
|
5987
3383
|
maskProps.inverted = maskInverted;
|
|
5988
|
-
if (fromCoordinateSystem === COORDINATE_SYSTEM.DEFAULT) {
|
|
5989
|
-
fromCoordinateSystem = viewport.isGeospatial ? COORDINATE_SYSTEM.LNGLAT : COORDINATE_SYSTEM.CARTESIAN;
|
|
3384
|
+
if (fromCoordinateSystem === import_core21.COORDINATE_SYSTEM.DEFAULT) {
|
|
3385
|
+
fromCoordinateSystem = viewport.isGeospatial ? import_core21.COORDINATE_SYSTEM.LNGLAT : import_core21.COORDINATE_SYSTEM.CARTESIAN;
|
|
5990
3386
|
}
|
|
5991
3387
|
const opts = { modelMatrix: null, fromCoordinateOrigin, fromCoordinateSystem };
|
|
5992
3388
|
const bl = this.projectPosition([bounds[0], bounds[1], 0], opts);
|
|
@@ -5994,7 +3390,7 @@ var MaskExtension = class extends LayerExtension {
|
|
|
5994
3390
|
maskProps.bounds = [bl[0], bl[1], tr[0], tr[1]];
|
|
5995
3391
|
} else {
|
|
5996
3392
|
if (maskId) {
|
|
5997
|
-
|
|
3393
|
+
import_core21.log.warn(`Could not find a mask layer with id: ${maskId}`)();
|
|
5998
3394
|
}
|
|
5999
3395
|
maskProps.enabled = false;
|
|
6000
3396
|
}
|
|
@@ -6005,7 +3401,14 @@ MaskExtension.defaultProps = defaultProps7;
|
|
|
6005
3401
|
MaskExtension.extensionName = "MaskExtension";
|
|
6006
3402
|
var mask_extension_default = MaskExtension;
|
|
6007
3403
|
|
|
3404
|
+
// dist/terrain/terrain-extension.js
|
|
3405
|
+
var import_core28 = require("@deck.gl/core");
|
|
3406
|
+
|
|
3407
|
+
// dist/terrain/terrain-effect.js
|
|
3408
|
+
var import_core27 = require("@deck.gl/core");
|
|
3409
|
+
|
|
6008
3410
|
// dist/terrain/shader-module.js
|
|
3411
|
+
var import_core22 = require("@deck.gl/core");
|
|
6009
3412
|
var TERRAIN_MODE = {
|
|
6010
3413
|
NONE: 0,
|
|
6011
3414
|
/** A terrain layer rendering encoded ground elevation into the height map */
|
|
@@ -6034,7 +3437,7 @@ uniform sampler2D terrain_map;
|
|
|
6034
3437
|
);
|
|
6035
3438
|
var terrainModule = {
|
|
6036
3439
|
name: "terrain",
|
|
6037
|
-
dependencies: [
|
|
3440
|
+
dependencies: [import_core22.project],
|
|
6038
3441
|
vs: `${uniformBlock5}
|
|
6039
3442
|
out vec3 commonPos;
|
|
6040
3443
|
// In globe mode, absolute Mercator position for terrain FBO UV lookups
|
|
@@ -6132,7 +3535,7 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
6132
3535
|
}
|
|
6133
3536
|
if ("terrainSkipRender" in opts || "drawToTerrainHeightMap" in opts) {
|
|
6134
3537
|
const { drawToTerrainHeightMap, heightMap, heightMapBounds, dummyHeightMap, terrainCover, useTerrainHeightMap, terrainSkipRender } = opts;
|
|
6135
|
-
const projectUniforms =
|
|
3538
|
+
const projectUniforms = import_core22.project.getUniforms(opts.project);
|
|
6136
3539
|
const { commonOrigin } = projectUniforms;
|
|
6137
3540
|
let mode = terrainSkipRender ? TERRAIN_MODE.SKIP : TERRAIN_MODE.NONE;
|
|
6138
3541
|
let sampler = dummyHeightMap;
|
|
@@ -6182,7 +3585,11 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
6182
3585
|
}
|
|
6183
3586
|
};
|
|
6184
3587
|
|
|
3588
|
+
// dist/terrain/terrain-cover.js
|
|
3589
|
+
var import_core23 = require("@deck.gl/core");
|
|
3590
|
+
|
|
6185
3591
|
// dist/terrain/utils.js
|
|
3592
|
+
var import_constants = require("@luma.gl/webgl/constants");
|
|
6186
3593
|
function createRenderTarget(device, opts) {
|
|
6187
3594
|
return device.createFramebuffer({
|
|
6188
3595
|
id: opts.id,
|
|
@@ -6296,7 +3703,7 @@ var TerrainCover = class {
|
|
|
6296
3703
|
} else {
|
|
6297
3704
|
const oldZoom = (_a = this.renderViewport) == null ? void 0 : _a.zoom;
|
|
6298
3705
|
shouldRedraw = shouldRedraw || newZoom !== oldZoom;
|
|
6299
|
-
const newBounds = viewport instanceof
|
|
3706
|
+
const newBounds = viewport instanceof import_core23._GlobeViewport ? this.targetBoundsCommon : getRenderBounds(this.targetBoundsCommon, viewport);
|
|
6300
3707
|
const oldBounds = this.bounds;
|
|
6301
3708
|
shouldRedraw = shouldRedraw || !oldBounds || newBounds.some((x, i) => x !== oldBounds[i]);
|
|
6302
3709
|
this.bounds = newBounds;
|
|
@@ -6373,6 +3780,7 @@ function intersect(b1, b2) {
|
|
|
6373
3780
|
}
|
|
6374
3781
|
|
|
6375
3782
|
// dist/terrain/terrain-pass.js
|
|
3783
|
+
var import_core24 = require("@deck.gl/core");
|
|
6376
3784
|
var TERRAIN_BLENDING = {
|
|
6377
3785
|
blendColorOperation: "max",
|
|
6378
3786
|
blendColorSrcFactor: "one",
|
|
@@ -6381,7 +3789,7 @@ var TERRAIN_BLENDING = {
|
|
|
6381
3789
|
blendAlphaSrcFactor: "one",
|
|
6382
3790
|
blendAlphaDstFactor: "one"
|
|
6383
3791
|
};
|
|
6384
|
-
var TerrainPass = class extends
|
|
3792
|
+
var TerrainPass = class extends import_core24._LayersPass {
|
|
6385
3793
|
getRenderableLayers(viewport, opts) {
|
|
6386
3794
|
const { layers } = opts;
|
|
6387
3795
|
const result = [];
|
|
@@ -6446,7 +3854,8 @@ var TerrainPass = class extends LayersPass {
|
|
|
6446
3854
|
};
|
|
6447
3855
|
|
|
6448
3856
|
// dist/terrain/terrain-picking-pass.js
|
|
6449
|
-
var
|
|
3857
|
+
var import_core25 = require("@deck.gl/core");
|
|
3858
|
+
var TerrainPickingPass = class extends import_core25._PickLayersPass {
|
|
6450
3859
|
constructor() {
|
|
6451
3860
|
super(...arguments);
|
|
6452
3861
|
this.drawParameters = {};
|
|
@@ -6517,6 +3926,7 @@ var TerrainPickingPass = class extends PickLayersPass {
|
|
|
6517
3926
|
};
|
|
6518
3927
|
|
|
6519
3928
|
// dist/terrain/height-map-builder.js
|
|
3929
|
+
var import_core26 = require("@deck.gl/core");
|
|
6520
3930
|
var MAP_MAX_SIZE = 2048;
|
|
6521
3931
|
var HeightMapBuilder = class {
|
|
6522
3932
|
static isSupported(device) {
|
|
@@ -6563,7 +3973,7 @@ var HeightMapBuilder = class {
|
|
|
6563
3973
|
if (!this.layersBoundsCommon) {
|
|
6564
3974
|
this.renderViewport = null;
|
|
6565
3975
|
} else if (layersChanged || viewportChanged) {
|
|
6566
|
-
const bounds = viewport instanceof
|
|
3976
|
+
const bounds = viewport instanceof import_core26._GlobeViewport ? this.layersBoundsCommon : getRenderBounds(this.layersBoundsCommon, viewport);
|
|
6567
3977
|
if (bounds[2] <= bounds[0] || bounds[3] <= bounds[1]) {
|
|
6568
3978
|
this.renderViewport = null;
|
|
6569
3979
|
return false;
|
|
@@ -6621,7 +4031,7 @@ var TerrainEffect = class {
|
|
|
6621
4031
|
if (HeightMapBuilder.isSupported(device)) {
|
|
6622
4032
|
this.heightMap = new HeightMapBuilder(device);
|
|
6623
4033
|
} else {
|
|
6624
|
-
|
|
4034
|
+
import_core27.log.warn("Terrain offset mode is not supported by this browser")();
|
|
6625
4035
|
}
|
|
6626
4036
|
deck._addDefaultShaderModule(terrainModule);
|
|
6627
4037
|
}
|
|
@@ -6789,7 +4199,7 @@ var TerrainEffect = class {
|
|
|
6789
4199
|
var defaultProps8 = {
|
|
6790
4200
|
terrainDrawMode: void 0
|
|
6791
4201
|
};
|
|
6792
|
-
var TerrainExtension = class extends LayerExtension {
|
|
4202
|
+
var TerrainExtension = class extends import_core28.LayerExtension {
|
|
6793
4203
|
getShaders() {
|
|
6794
4204
|
return {
|
|
6795
4205
|
modules: [terrainModule]
|