Skip to content

Commit 936110a

Browse files
stephanheiglgithub-actions[bot]
authored andcommitted
Fix mercator to globe transformation matrix used in model layer.
GitOrigin-RevId: cd4a198aa4a2daebc72c9750d88c0dc88ee6f005
1 parent ef58896 commit 936110a

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

3d-style/util/model_util.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ export function mercatorToGlobeMatrix(matrix: mat4, transform: Transform): mat4
176176
mat4.translate(m, m, [0, 0, GLOBE_RADIUS]);
177177
mat4.scale(m, m, [pixelsToEcef, pixelsToEcef, pixelsToEcef * pixelsPerMeter]);
178178

179-
mat4.translate(m, m, [transform.point.x - 0.5 * worldSize, transform.point.y - 0.5 * worldSize, 0.0]);
179+
const transformPoint = transform.point;
180+
mat4.translate(m, m, [-transformPoint.x, -transformPoint.y, 0.0]);
180181
mat4.multiply(m, m, matrix);
181182
return mat4.multiply(m, transform.globeMatrix, m);
182183
}
68.8 KB
Loading
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"version": 8,
3+
"metadata": {
4+
"test": {
5+
"width": 1024,
6+
"height": 1024,
7+
"operations": [
8+
["setProjection", "globe"],
9+
["wait"]
10+
]
11+
}
12+
},
13+
"center": [ 0, 0 ],
14+
"zoom": 5.40,
15+
"pitch": 60,
16+
"fog": {
17+
"star-intensity": 0.0
18+
},
19+
"sources": {
20+
"model": {
21+
"type": "model",
22+
"models": {
23+
"model-1" : {
24+
"uri": "local://models/low-poly-car.gltf",
25+
"position": [0, 0],
26+
"orientation": [0, 0, 45]
27+
},
28+
"model-2" : {
29+
"uri": "local://models/low-poly-car.gltf",
30+
"position": [0.00000, 20],
31+
"orientation": [0, 45, 45]
32+
},
33+
"model-3" : {
34+
"uri": "local://models/low-poly-car.gltf",
35+
"position": [-5, 5],
36+
"orientation": [0, 0, 145]
37+
},
38+
"model-4" : {
39+
"uri": "local://models/low-poly-car.gltf",
40+
"position": [5, 5],
41+
"orientation": [0, 45, -45]
42+
}
43+
}
44+
}
45+
},
46+
"layers": [
47+
{
48+
"id": "background",
49+
"type": "background",
50+
"paint": {
51+
"background-color": "white"
52+
}
53+
},
54+
{
55+
"id": "model",
56+
"type": "model",
57+
"source": "model",
58+
"paint": {
59+
"model-scale" : [100000, 100000, 100000]
60+
}
61+
}
62+
]
63+
}

0 commit comments

Comments
 (0)