Skip to content

Commit 2691415

Browse files
修复videolayer 范围精度判断对比
1 parent 8573a1b commit 2691415

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/mapboxgl/overlay/VideoLayer.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,13 @@
9595
this.type = 'custom';
9696
this.renderingMode = '3d';
9797
this.overlay = true;
98+
this.beginIndex = 0;
9899
if (Array.isArray(this.videoParameters)) {
99100
this.videoParameters = smartTimeProcessor(this.interval, this.videoParameters, ['yaw', 'pitch', 'roll', 'x', 'y', 'z', 'extent']);
100101
const timeArr = this.videoParameters.map((item) => {
101102
return item.time;
102103
})
104+
this.beginIndex = timeArr[0];
103105
this.finder = new FastRangeSearcher(timeArr);
104106
}
105107
}
@@ -266,10 +268,10 @@
266268
let srcTri = this.cv.matFromArray(4, 1, this.cv.CV_32FC2,
267269
srcPixelCoords
268270
);
269-
that.dsize = that.timeParams[0].dsize;
270-
let dstTri = that.timeParams[0].dstTri;
271+
that.dsize = that.timeParams[that.beginIndex].dsize;
272+
let dstTri = that.timeParams[that.beginIndex].dstTri;
271273
let canvas = document.createElement('canvas');
272-
let { clipMat, dst1 } = this._updateMask(canvas, that.timeParams[0].realHeight, that.timeParams[0].ratio);
274+
let { clipMat, dst1 } = this._updateMask(canvas, that.timeParams[that.beginIndex].realHeight, that.timeParams[that.beginIndex].ratio);
273275
let count = 0;
274276
const videoEle = this.video.tech().el();
275277
let current = 0;
@@ -319,7 +321,7 @@
319321
newFrame = new ImageData(new Uint8ClampedArray(dst.data), dst.cols, dst.rows);
320322
} else {
321323
if (that.videoParameters.length > 1) {
322-
const res = that._updateMask(canvas, that.timeParams[0].realHeight, that.timeParams[0].ratio);
324+
const res = that._updateMask(canvas, that.timeParams[that.beginIndex].realHeight, that.timeParams[that.beginIndex].ratio);
323325
clipMat = res.clipMat;
324326
dst1 = res.dst1;
325327
}
@@ -378,7 +380,7 @@
378380
}
379381

380382
_contain(coord, bounds) {
381-
return coord[0] >= bounds[0] && coord[0] <= bounds[2] && coord[1] >= bounds[1] && coord[1] <= bounds[3];
383+
return (coord[0] > bounds[0] || Math.abs(coord[0] - bounds[0]) < 0.000001 ) && (coord[0] < bounds[2] || Math.abs(coord[0] - bounds[2]) < 0.000001 ) && (coord[1] > bounds[1] || Math.abs(coord[1] - bounds[1]) < 0.000001) && (coord[1] < bounds[3] || Math.abs(coord[1] - bounds[3]) < 0.000001);
382384
}
383385

384386
/**

0 commit comments

Comments
 (0)