Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
peppsac committed Jun 27, 2018
1 parent 5182cd3 commit 0a7cb4d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 29 deletions.
26 changes: 13 additions & 13 deletions src/Core/MainLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ function updateElements(context, geometryLayer, elements) {
// and then update Debug.js:addGeometryLayerDebugFeatures
const newElementsToUpdate = geometryLayer.update(context, geometryLayer, element);

// update attached layers
for (const attachedLayer of geometryLayer._attachedLayers) {
if (attachedLayer.ready) {
const sub = geometryLayer.getObjectToUpdateForAttachedLayers(element);

if (sub) {
if (__DEBUG__) {
if (!(sub.element.isObject3D)) {
throw new Error(`
Invalid object for attached layer to update.
Must be a THREE.Object and have a THREE.Material`);
}
}
const sub = geometryLayer.getObjectToUpdateForAttachedLayers(element);

if (sub) {
if (__DEBUG__) {
if (!(sub.element.isObject3D)) {
throw new Error(`
Invalid object for attached layer to update.
Must be a THREE.Object and have a THREE.Material`);
}
}
// update attached layers
for (const attachedLayer of geometryLayer._attachedLayers) {
if (attachedLayer.ready) {
attachedLayer.update(context, attachedLayer, sub.element, sub.parent);
}
}
Expand Down
25 changes: 9 additions & 16 deletions src/Process/LayeredMaterialNodeProcessing.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,7 @@ function checkNodeElevationTextureValidity(texture, noDataValue) {
tData[l - Math.sqrt(l)] > noDataValue;
}

export function updateLayeredMaterialNodeImagery(context, layer, node) {
if (!node.parent) {
return;
}

export function updateLayeredMaterialNodeImagery(context, layer, node, parent) {
const material = node.material;

// Initialisation
Expand All @@ -156,10 +152,10 @@ export function updateLayeredMaterialNodeImagery(context, layer, node) {
// because even if this tile is outside of the layer, it could inherit it's
// parent texture
if (!layer.noTextureParentOutsideLimit &&
node.parent &&
node.parent.material &&
node.parent.getIndexLayerColor &&
node.parent.getIndexLayerColor(layer.id) >= 0) {
parent &&
parent.material &&
parent.getIndexLayerColor &&
parent.getIndexLayerColor(layer.id) >= 0) {
// ok, we're going to inherit our parent's texture
} else {
node.layerUpdateState[layer.id].noMoreUpdatePossible();
Expand All @@ -185,7 +181,7 @@ export function updateLayeredMaterialNodeImagery(context, layer, node) {
const sequence = ImageryLayers.getColorLayersIdOrderedBySequence(imageryLayers);
material.setSequence(sequence);

initNodeImageryTexturesFromParent(node, node.parent, layer);
initNodeImageryTexturesFromParent(node, parent, layer);
}

// Proposed new process, two separate processes:
Expand Down Expand Up @@ -303,10 +299,7 @@ export function updateLayeredMaterialNodeImagery(context, layer, node) {
});
}

export function updateLayeredMaterialNodeElevation(context, layer, node) {
if (!node.parent) {
return;
}
export function updateLayeredMaterialNodeElevation(context, layer, node, parent) {
// TODO: we need either
// - compound or exclusive layers
// - support for multiple elevation layers
Expand All @@ -320,7 +313,7 @@ export function updateLayeredMaterialNodeElevation(context, layer, node) {
// Init elevation layer, and inherit from parent if possible
if (node.layerUpdateState[layer.id] === undefined) {
node.layerUpdateState[layer.id] = new LayerUpdateState();
initNodeElevationTextureFromParent(node, node.parent, layer);
initNodeElevationTextureFromParent(node, parent, layer);
currentElevation = material.getElevationLayerLevel();
const minLevel = layer.options.zoom ? layer.options.zoom.min : 0;
if (currentElevation >= minLevel) {
Expand Down Expand Up @@ -401,7 +394,7 @@ export function updateLayeredMaterialNodeElevation(context, layer, node) {
// Quick check to avoid using elevation texture with no data value
// If we have no data values, we use value from the parent tile
// We should later implement multi elevation layer to choose the one to use at each level
insertSignificantValuesFromParent(terrain.texture, node, node.parent, layer);
insertSignificantValuesFromParent(terrain.texture, node, parent, layer);
}

node.setTextureElevation(terrain);
Expand Down

0 comments on commit 0a7cb4d

Please sign in to comment.