Skip to content

Commit

Permalink
feat(LayeredMaterial): migrate to TypeScript
Browse files Browse the repository at this point in the history
fix(tests): add new empty methods to mock Material
refactor: use interface where possible
  • Loading branch information
HoloTheDrunk committed Dec 17, 2024
1 parent fc2d3ab commit c4d4b46
Show file tree
Hide file tree
Showing 11 changed files with 559 additions and 297 deletions.
2 changes: 1 addition & 1 deletion src/Converter/convertToTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import * as THREE from 'three';
import TileMesh from 'Core/TileMesh';
import LayeredMaterial from 'Renderer/LayeredMaterial';
import { LayeredMaterial } from 'Renderer/LayeredMaterial';
import { newTileGeometry } from 'Core/Prefab/TileBuilder';
import ReferLayerProperties from 'Layer/ReferencingLayerProperties';
import { geoidLayerIsVisible } from 'Layer/GeoidLayer';
Expand Down
4 changes: 2 additions & 2 deletions src/Layer/ColorLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ class ColorLayer extends RasterLayer {
setupRasterNode(node) {
const rasterColorNode = new RasterColorTile(node.material, this);

node.material.addLayer(rasterColorNode);
node.material.addColorLayer(rasterColorNode);
// set up ColorLayer ordering.
node.material.setSequence(this.parent.colorLayersOrder);
node.material.setColorLayerIds(this.parent.colorLayersOrder);

return rasterColorNode;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Layer/ElevationLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ class ElevationLayer extends RasterLayer {
setupRasterNode(node) {
const rasterElevationNode = new RasterElevationTile(node.material, this);

node.material.addLayer(rasterElevationNode);
node.material.setSequenceElevation(this.id);
node.material.setElevationLayer(rasterElevationNode);
node.material.setElevationLayerId(this.id);
// bounding box initialisation
const updateBBox = () => node.setBBoxZ({
min: rasterElevationNode.min, max: rasterElevationNode.max, scale: this.scale,
Expand Down
2 changes: 1 addition & 1 deletion src/Layer/TiledGeometryLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class TiledGeometryLayer extends GeometryLayer {
if (layerUpdateState[c.id] && layerUpdateState[c.id].inError()) {
continue;
}
nodeLayer = node.material.getLayer(c.id);
nodeLayer = node.material.getColorLayer(c.id);
if (c.source.extentInsideLimit(node.extent, zoom) && (!nodeLayer || nodeLayer.level < 0)) {
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Process/LayeredMaterialNodeProcessing.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ export function updateLayeredMaterialNodeElevation(context, layer, node, parent)

// Possible conditions to *not* update the elevation texture
if (layer.frozen ||
!material.visible ||
!node.layerUpdateState[layer.id].canTryUpdate()) {
!material.visible ||
!node.layerUpdateState[layer.id].canTryUpdate()) {
return;
}

Expand Down Expand Up @@ -238,7 +238,7 @@ export function removeLayeredMaterialNodeLayer(layerId) {
*/
return function removeLayeredMaterialNodeLayer(node) {
if (node.material?.removeLayer) {
if (node.material.elevationLayerIds.indexOf(layerId) > -1) {
if (node.material.elevationTile !== undefined > -1) {
node.setBBoxZ({ min: 0, max: 0 });
}
node.material.removeLayer(layerId);
Expand Down
275 changes: 0 additions & 275 deletions src/Renderer/LayeredMaterial.js

This file was deleted.

Loading

0 comments on commit c4d4b46

Please sign in to comment.