Skip to content

Commit e3c0de9

Browse files
committed
fix: fix 3dtiles with jpeg texture, close #2699
1 parent db9bc24 commit e3c0de9

File tree

6 files changed

+70
-3
lines changed

6 files changed

+70
-3
lines changed

packages/gltf-loader/src/adapters/GLTFV2.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,14 @@ export default class V2 extends GLTFAdapter {
112112
}
113113
}
114114
if (response.format) {
115-
out.format = response.format;
115+
out.format = response.format; // convert RGB to RGBA
116+
}
117+
if (out.format === 0x1907) {
118+
const length = out.image.array && out.image.array.length;
119+
if (length && length === out.image.width * out.image.height * 4) {
120+
// rgb images is transformed to rgba by requestImageOffscreen
121+
out.format = 0x1908;
122+
}
116123
}
117124
return out;
118125
});
11.4 KB
Loading
Binary file not shown.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"asset": {
3+
"gltfUpAxis": "Y",
4+
"statistics": {
5+
"components": 28663,
6+
"fileSize": 0,
7+
"triangles": 10626384,
8+
"vertices": 12077589
9+
},
10+
"tilesetVersion": "1.2.3",
11+
"version": "0.0"
12+
},
13+
"geometricError": 43434.8125,
14+
"root": {
15+
"boundingVolume": {
16+
"box": [
17+
-683.38633454023477, 405.70397591051386, 367.8682640287052,
18+
1600.7544626284032, -3595.3534387959871, 8157.6143269658005,
19+
-6313.1237763461277, 13624.119538930374, 7243.4517892868507,
20+
-5866.1563517411269, -2698.0384732275647, -38.016745063797316
21+
]
22+
},
23+
"children": [
24+
{
25+
"boundingVolume": {
26+
"box": [
27+
-9783.038148201289, 10788.11830869575, 10336.869082268435,
28+
727.08843140882584, -1633.0674219457408, 3700.4787737632464,
29+
30.192449936670826, -65.041713887260102, -34.63608168499227,
30+
2008.9362642280066, 925.29805026051156, 13.619800948419343
31+
]
32+
},
33+
"content": { "uri": "./F_Tile_+0_2_4+R6_0.b3dm" },
34+
"geometricError": 64.149318695068359,
35+
"refine": "REPLACE"
36+
}
37+
],
38+
"geometricError": 36195.67578125,
39+
"refine": "REPLACE",
40+
"transform": [
41+
1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -2410000.0,
42+
5202000.0, 2747000.0, 1.0
43+
]
44+
}
45+
}

packages/layer-3dtiles/test/layer.render.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,6 +2177,21 @@ describe('render specs', () => {
21772177
}, layer, { path: `./integration/expected/${resPath}/expected.png`, zoomOffset: 1, diffCount: 5, renderCount: 1, noGroup: true });
21782178
});
21792179

2180+
it('maptalks/maptalks.js#2699, fix incorrect image format with jpeg texture', done => {
2181+
const resPath = 'BatchedDraco/issue-2699';
2182+
const layer = new Geo3DTilesLayer('3d-tiles', {
2183+
services : [
2184+
{
2185+
url : `http://localhost:${PORT}/integration/fixtures/${resPath}/tileset.json`,
2186+
heightOffset: 0
2187+
}
2188+
]
2189+
});
2190+
runner(() => {
2191+
done();
2192+
}, layer, { path: `./integration/expected/${resPath}/expected.png`, zoomOffset: 1, diffCount: 5, renderCount: 1, noGroup: true });
2193+
});
2194+
21802195
it('3dtiles under hdr, maptalks/issues#755', done => {
21812196
const resPath = 'BatchedDraco/issue-755';
21822197
map.setLights({

packages/vt/test/specs/update.vector.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,7 +2209,7 @@ describe('vector layers update style specs', () => {
22092209
polygonFill: '#0f0'
22102210
},
22112211
properties: {
2212-
height: 80000
2212+
height_0: 80000
22132213
}
22142214
});
22152215

@@ -2223,7 +2223,7 @@ describe('vector layers update style specs', () => {
22232223
const pixel = readPixel(canvas, canvas.width / 2 + 20, canvas.height / 2 - 30);
22242224
assert(pixel[3] === 0);
22252225
layer.updateDataConfig({
2226-
altitudeProperty: 'height'
2226+
altitudeProperty: 'height_0'
22272227
});
22282228
} else if (count === 4) {
22292229
const canvas = group.getRenderer().canvas;

0 commit comments

Comments
 (0)