优化代码。

This commit is contained in:
tengge1 2019-04-05 11:12:32 +08:00
parent e40469a323
commit bd3748c5a6
2 changed files with 12 additions and 5 deletions

View File

@ -128,7 +128,7 @@ TiledLayerRenderer.prototype.render = function (layer) {
this.mesh.geometry.groups.length = 0;
this.creator.get().forEach((n, i) => {
if (n.z >= z && n.material) {
if (n.material) {
n.material.group.materialIndex = i;
this.mesh.material.push(n.material);
this.mesh.geometry.groups.push(n.material.group);

View File

@ -73,16 +73,23 @@ SphereTileCreator.prototype.canFork = function () {
var xyz = new THREE.Vector3();
return function (tile) {
if (tile.z > this._centerZoom) { // this._centerZoom: { min: 0 }
if (tile.z > this._centerZoom) {
return false;
}
// 判断tile是否在视野范围内
// var intersect = false;
var intersect = false;
// debugger
for (var i = 1, l = tile._vertices.length; i < l; i++) {
if (this._frustum.containsPoint(tile._vertices[i])) {
intersect = true;
break;
}
}
// return false;
if (!intersect) {
return false;
}
return true;
};