Skip to content

Commit

Permalink
fix 3dtiles mask specs
Browse files Browse the repository at this point in the history
fix 3dtiles specs
  • Loading branch information
fuzhenn committed Dec 24, 2024
1 parent 51c0e9c commit 472c557
Show file tree
Hide file tree
Showing 30 changed files with 34 additions and 33 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/layer-3dtiles/test/layer.identify.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const maptalks = require('maptalks');
const maptalks = require('@maptalks/map');
require('@maptalks/gl');
require('@maptalks/transcoders.draco');
require('@maptalks/transcoders.ktx2');
Expand Down
11 changes: 5 additions & 6 deletions packages/layer-3dtiles/test/layer.mask.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const maptalks = require('maptalks');
const maptalks = require('@maptalks/map');
const { GroupGLLayer, FlatInsideMask, FlatOutsideMask, ClipInsideMask, ClipOutsideMask, ColorMask, VideoMask } = require('@maptalks/gl');
require('@maptalks/transcoders.draco');
require('@maptalks/transcoders.ktx2');
Expand All @@ -12,8 +12,7 @@ const PORT = 39887;
function pickPixel(map, x, y, width, height) {
const px = x || map.width / 2, py = y || map.height / 2;
const w = width || 1, h = height || 1;
const canvas = map.getRenderer().canvas;
const ctx = canvas.getContext("2d");
const ctx = map.getRenderer().context;
const pixel = ctx.getImageData(px, py, w, h).data;
return pixel;
}
Expand Down Expand Up @@ -104,7 +103,7 @@ describe('render specs', () => {
layer.setMask(mask);
setTimeout(function() {
const pixel = pickPixel(map, 255, 497, 1, 1);
assert(pixelMatch([104, 107, 114, 255], pixel) === true);
assert(pixelMatch([125, 128, 135, 255], pixel) === true);
done();
}, 500);
});
Expand Down Expand Up @@ -192,7 +191,7 @@ describe('render specs', () => {
layer.setMask(mask);
setTimeout(function() {
const pixel = pickPixel(map, 255, 497, 1, 1);
assert(pixelMatch([53, 63, 81, 255], pixel, 50) === true);
assert(pixelMatch([107, 136, 170, 255], pixel, 50) === true);
done();
}, 1200);
});
Expand All @@ -206,7 +205,7 @@ describe('render specs', () => {
layer.setServiceOpacity(0, 0.5);
setTimeout(function() {
const pixel = pickPixel(map, 255, 497, 1, 1);
assert(pixelMatch([255, 255, 255, 127], pixel) === true);
assert(pixelMatch([172, 176, 177, 127], pixel) === true);
done();
}, 200);
});
Expand Down
20 changes: 10 additions & 10 deletions packages/layer-3dtiles/test/layer.render.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const maptalks = require('maptalks');
const maptalks = require('@maptalks/map');
const { GroupGLLayer } = require('@maptalks/gl');

const { Geo3DTilesLayer } = require('../dist/maptalks.3dtiles');
Expand Down Expand Up @@ -51,11 +51,11 @@ describe('render specs', () => {
zoom: 20,
center: center || [0, 0],
// centerCross: true
baseLayer: new maptalks.TileLayer('base', {
urlTemplate: 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
subdomains: ['a','b','c','d'],
attribution: '&copy; <a href="http://osm.org">OpenStreetMap</a> contributors, &copy; <a href="https://carto.com/">CARTO</a>'
}),
// baseLayer: new maptalks.TileLayer('base', {
// urlTemplate: 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
// subdomains: ['a','b','c','d'],
// attribution: '&copy; <a href="http://osm.org">OpenStreetMap</a> contributors, &copy; <a href="https://carto.com/">CARTO</a>'
// }),
};
map = new maptalks.Map(container, option);
}
Expand Down Expand Up @@ -426,7 +426,7 @@ describe('render specs', () => {
runner(done, layer, { path: `./integration/expected/${resPath}/expected-phong.png`, diffCount: 0, renderCount: 1, noGroup: true });
});

it('deyihu-khr_techniques_webgl', done => {
it('deyihu-taoyuan-khr_techniques_webgl', done => {
const resPath = 'BatchedDraco/deyihu/taoyuan/';
const layer = new Geo3DTilesLayer('3d-tiles', {
services : [
Expand Down Expand Up @@ -2014,7 +2014,7 @@ describe('render specs', () => {
runner(() => {
assert(map.getCenter().x.toFixed(3) === '108.959');
done();
}, layer, { path: `./integration/expected/${resPath}/4490/expected.png`, diffCount: 0, renderCount: 1, noGroup: true });
}, layer, { path: `./integration/expected/${resPath}/4490/expected.png`, diffCount: 100, renderCount: 1, noGroup: true });
});
});

Expand All @@ -2035,7 +2035,7 @@ describe('render specs', () => {
runner(() => {
assert(map.getCenter().x.toFixed(3) === '108.959');
done();
}, layer, { path: `./integration/expected/${resPath}/trs/expected.png`, diffCount: 0, renderCount: 1, noGroup: true, zoomOffset: -2 });
}, layer, { path: `./integration/expected/${resPath}/trs/expected.png`, diffCount: 100, renderCount: 1, noGroup: true, zoomOffset: -2 });
});

it('set transform', done => {
Expand Down Expand Up @@ -2075,7 +2075,7 @@ describe('render specs', () => {
runner(() => {
assert(map.getCenter().x.toFixed(3) === '108.959');
done();
}, layer, { path: `./integration/expected/${resPath}/rotation/expected.png`, diffCount: 0, renderCount: 1, noGroup: true, zoomOffset: -2 });
}, layer, { path: `./integration/expected/${resPath}/rotation/expected.png`, diffCount: 100, renderCount: 1, noGroup: true, zoomOffset: -2 });
});

it('show debug boundingVolume', done => {
Expand Down
28 changes: 13 additions & 15 deletions packages/layer-3dtiles/test/layer.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const maptalks = require('maptalks');
const maptalks = require('@maptalks/map');
require('@maptalks/gl');
require('@maptalks/transcoders.draco');
require('@maptalks/transcoders.ktx2');
Expand Down Expand Up @@ -306,7 +306,7 @@ describe('3dtiles layer', () => {
count++;
if (count === 2) {
const canvas = map.getRenderer().canvas;
const ctx = canvas.getContext('2d');
const ctx = map.getRenderer().context;
const color = ctx.getImageData(canvas.width / 2 - 43, canvas.height / 2 + 70, 1, 1);
assert(color.data[3] > 0);
done();
Expand Down Expand Up @@ -337,7 +337,7 @@ describe('3dtiles layer', () => {
count++;
if (count === 2) {
const canvas = map.getRenderer().canvas;
const ctx = canvas.getContext('2d');
const ctx = map.getRenderer().context;
const color = ctx.getImageData(canvas.width / 2 - 43, canvas.height / 2 + 70, 1, 1);
assert(color.data[3] > 0);
done();
Expand All @@ -364,7 +364,7 @@ describe('3dtiles layer', () => {
layer.addService(service);
setTimeout(() => {
const canvas = map.getRenderer().canvas;
const ctx = canvas.getContext('2d');
const ctx = map.getRenderer().context;
const color = ctx.getImageData(canvas.width / 2 - 43, canvas.height / 2 + 70, 1, 1);
assert(color.data[3] > 0);
done();
Expand Down Expand Up @@ -394,7 +394,7 @@ describe('3dtiles layer', () => {
} else if (count === 3) {
setTimeout(() => {
const canvas = map.getRenderer().canvas;
const ctx = canvas.getContext('2d');
const ctx = map.getRenderer().context;
const color = ctx.getImageData(canvas.width / 2 - 43, canvas.height / 2 + 70, 1, 1);
assert(color.data[3] === 0);
done();
Expand Down Expand Up @@ -453,7 +453,7 @@ describe('3dtiles layer', () => {
} else if (count === 3) {
setTimeout(() => {
const canvas = map.getRenderer().canvas;
const ctx = canvas.getContext('2d');
const ctx = map.getRenderer().context;
const color = ctx.getImageData(canvas.width / 2 - 53, canvas.height / 2 + 100, 1, 1);
assert(color.data[3] === 255);
done();
Expand Down Expand Up @@ -489,13 +489,13 @@ describe('3dtiles layer', () => {
layer.removeService(0);
layer.addService(service);
const canvas = map.getRenderer().canvas;
const ctx = canvas.getContext('2d');
const ctx = map.getRenderer().context;
const color = ctx.getImageData(canvas.width / 2 - 43, canvas.height / 2 + 70, 1, 1);
assert(color.data[3] === 255);
layer.hideService(0);
setTimeout(() => {
const canvas = map.getRenderer().canvas;
const ctx = canvas.getContext('2d');
const ctx = map.getRenderer().context;
const color = ctx.getImageData(canvas.width / 2 - 43, canvas.height / 2 + 70, 1, 1);
assert(color.data[3] === 0);
done();
Expand Down Expand Up @@ -529,7 +529,7 @@ describe('3dtiles layer', () => {
} else if (count === 3) {
setTimeout(() => {
const canvas = map.getRenderer().canvas;
const ctx = canvas.getContext('2d');
const ctx = map.getRenderer().context;
const color = ctx.getImageData(canvas.width / 2 + 56, canvas.height / 2 + 70, 1, 1);
assert(color.data[3] === 255);
done();
Expand Down Expand Up @@ -563,7 +563,7 @@ describe('3dtiles layer', () => {
} else if (count === 3) {
setTimeout(() => {
const canvas = map.getRenderer().canvas;
const ctx = canvas.getContext('2d');
const ctx = map.getRenderer().context;
const color = ctx.getImageData(canvas.width / 2 - 43, canvas.height / 2 + 70, 1, 1);
assert(color.data[3] === 255);
done();
Expand Down Expand Up @@ -593,7 +593,7 @@ describe('3dtiles layer', () => {
layer.updateService(0, { heightOffset: 0 });
setTimeout(() => {
const canvas = map.getRenderer().canvas;
const ctx = canvas.getContext('2d');
const ctx = map.getRenderer().context;
const color = ctx.getImageData(canvas.width / 2 - 43, canvas.height / 2 + 70, 1, 1);
assert(color.data[3] === 255);
done();
Expand Down Expand Up @@ -621,16 +621,14 @@ describe('3dtiles layer', () => {
if (count === 1) {
layer.removeService(0);
setTimeout(() => {
const canvas = map.getRenderer().canvas;
const ctx = canvas.getContext('2d');
const ctx = map.getRenderer().context;
const color = ctx.getImageData(258, 525, 1, 1);
assert(color.data[3] === 0);
layer.addService(service);
}, 20);
} else if (count === 2) {
setTimeout(() => {
const canvas = map.getRenderer().canvas;
const ctx = canvas.getContext('2d');
const ctx = map.getRenderer().context;
const color = ctx.getImageData(258, 525, 1, 1);
assert(color.data[3] === 255);
done();
Expand Down
6 changes: 5 additions & 1 deletion packages/reshader.gl/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ export { Constants };

export { default as KHRTechniquesWebglManager } from './extensions/KHRTechniquesWebglManager';

export { default as earcut } from 'earcut';
import { default as earcutFn, flatten } from 'earcut';

const earcut = earcutFn;
earcut.flatten = flatten;
export { earcut };

export {
glMatrix,
Expand Down

0 comments on commit 472c557

Please sign in to comment.