Skip to content

Commit

Permalink
refactor(core): add zoom to each extent of tile
Browse files Browse the repository at this point in the history
to follow issue visiting: #1069
  • Loading branch information
gchoqueux committed Mar 13, 2019
1 parent 2bdc27d commit 7475a3f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
8 changes: 8 additions & 0 deletions src/Core/TileMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ class TileMesh extends THREE.Mesh {
this.layer = layer;
this.extent = extent;
this.level = level;
// Set equivalent tiled extent zoom
// Is used to set zoom for each texture fetched with no tiled extent
// It's more simple to set zoom here instead of reverse ingeneer
// Removable with a table pixel/extent.size
if (!this.extent.zoom) {
this.extent.zoom = level;
}

this.material.objectId = this.id;

this.obb = this.geometry.OBB.clone();
Expand Down
9 changes: 1 addition & 8 deletions src/Process/LayeredMaterialNodeProcessing.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@ function getSourceExtent(node, extent, targetLevel) {
if (extent.isTiledCrs()) {
return extent.extentParent(targetLevel);
} else {
const parent = node.findAncestorFromLevel(targetLevel);
if (parent.extent) {
// Needed to initNodeElevationTextureFromParent, insertSignificantValuesFromParent,
// isColorLayerDownscaled
// Must be removed
parent.extent.zoom = parent.level;
}
return parent.extent;
return node.findAncestorFromLevel(targetLevel).extent;
}
}

Expand Down
9 changes: 4 additions & 5 deletions test/unit/dataSourceProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import ColorLayer from 'Layer/ColorLayer';
import GeometryLayer from 'Layer/GeometryLayer';
import GlobeLayer from 'Core/Prefab/Globe/GlobeLayer';
import Feature2Mesh from 'Converter/Feature2Mesh';
import MaterialLayer from 'Renderer/MaterialLayer';

const holes = require('../data/geojson/holes.geojson.json');

Expand All @@ -28,11 +29,7 @@ describe('Provide in Sources', function () {
geom.OBB = new OBB(new THREE.Vector3(), new THREE.Vector3(1, 1, 1));
const extent = new Extent('EPSG:4326', 0, 10, 0, 10);
const zoom = 4;

const nodeLayer = { };
const material = {
getLayer: () => nodeLayer,
};
const material = { };

// Mock scheduler
const context = {
Expand All @@ -49,6 +46,8 @@ describe('Provide in Sources', function () {
};

const colorlayer = new ColorLayer();
const nodeLayer = new MaterialLayer(material, colorlayer);
material.getLayer = () => nodeLayer;
const globelayer = new GlobeLayer('globe', new THREE.Group());
const featureLayer = new GeometryLayer('geom', new THREE.Group());
featureLayer.update = FeatureProcessing.update;
Expand Down
10 changes: 5 additions & 5 deletions test/unit/layeredmaterialnodeprocessing.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ import OBB from 'Renderer/OBB';
import Layer from 'Layer/Layer';
import Source from 'Source/Source';
import { STRATEGY_MIN_NETWORK_TRAFFIC } from 'Layer/LayerUpdateStrategy';
import MaterialLayer from 'Renderer/MaterialLayer';

describe('updateLayeredMaterialNodeImagery', function () {
// Misc var to initialize a TileMesh instance
const geom = new THREE.Geometry();
geom.OBB = new OBB(new THREE.Vector3(), new THREE.Vector3(1, 1, 1));
const extent = new Extent('EPSG:4326', 0, 0, 0, 0);

const nodeLayer = { };
const material = {
getLayer: () => nodeLayer,
};
const material = {};

// Mock scheduler
const context = {
Expand All @@ -43,6 +40,9 @@ describe('updateLayeredMaterialNodeImagery', function () {
info: { update: () => {} },
});

const nodeLayer = new MaterialLayer(material, layer);
material.getLayer = () => nodeLayer;

beforeEach('reset state', function () {
// clear commands array
context.scheduler.commands = [];
Expand Down

0 comments on commit 7475a3f

Please sign in to comment.