From 6c2231ff2a40560694ebfa29db8c94ebff6d7043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Duhen?= Date: Tue, 7 Jan 2025 15:20:26 +0100 Subject: [PATCH] fix: use setUniform for material showOutline set --- src/Converter/convertToTile.js | 2 +- src/Renderer/LayeredMaterial.ts | 2 ++ src/Renderer/Shader/TileFS.glsl | 2 +- utils/debug/TileDebug.js | 8 ++++---- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Converter/convertToTile.js b/src/Converter/convertToTile.js index 8e2180d154..5791761ca9 100644 --- a/src/Converter/convertToTile.js +++ b/src/Converter/convertToTile.js @@ -18,7 +18,7 @@ function setTileFromTiledLayer(tile, tileLayer) { } if (__DEBUG__) { - tile.material.showOutline = tileLayer.showOutline || false; + tile.material.setUniform('showOutline', tileLayer.showOutline || false); } if (tileLayer.isGlobeLayer) { diff --git a/src/Renderer/LayeredMaterial.ts b/src/Renderer/LayeredMaterial.ts index 1fcbb25df0..69092dcc61 100644 --- a/src/Renderer/LayeredMaterial.ts +++ b/src/Renderer/LayeredMaterial.ts @@ -270,6 +270,8 @@ export class LayeredMaterial extends THREE.ShaderMaterial { // @ts-expect-error: global constexpr if (__DEBUG__) { + console.log('Running in debug mode'); + const outlineColors = [new THREE.Color(1.0, 0.0, 0.0)]; if (crsCount > 1) { outlineColors.push(new THREE.Color(1.0, 0.5, 0.0)); diff --git a/src/Renderer/Shader/TileFS.glsl b/src/Renderer/Shader/TileFS.glsl index 02065f7ffc..f1939430b9 100644 --- a/src/Renderer/Shader/TileFS.glsl +++ b/src/Renderer/Shader/TileFS.glsl @@ -42,7 +42,7 @@ void main() { gl_FragColor.rgb = mix(gl_FragColor.rgb, color.rgb, color.a); } - #if defined(DEBUG) + #if DEBUG == 1 if (showOutline) { #pragma unroll_loop for ( int i = 0; i < NUM_CRS; i ++) { diff --git a/utils/debug/TileDebug.js b/utils/debug/TileDebug.js index 1866698264..dc19bbebe6 100644 --- a/utils/debug/TileDebug.js +++ b/utils/debug/TileDebug.js @@ -31,7 +31,7 @@ let selectedNode; function selectTileAt(view, mouseOrEvt, showInfo = true) { if (selectedNode) { selectedNode.material.overlayAlpha = 0; - selectedNode.material.showOutline = view.tileLayer.showOutline; + selectedNode.material.setUniform('showOutline', view.tileLayer.showOutline); view.notifyChange(selectedNode); } @@ -44,7 +44,7 @@ function selectTileAt(view, mouseOrEvt, showInfo = true) { console.info(selectedNode); } selectedNode.material.overlayAlpha = 0.5; - selectedNode.material.showOutline = true; + selectedNode.material.setUniform('showOutline', true); view.notifyChange(selectedNode); } return selectedNode; @@ -79,7 +79,7 @@ export default function createTileDebugUI(datDebugTool, view, layer, debugInstan layer.showOutline = newValue; applyToNodeFirstMaterial(view, layer.object3d, layer, (material) => { - material.showOutline = newValue; + material.setUniform('showOutline', newValue); }); }); @@ -235,7 +235,7 @@ export default function createTileDebugUI(datDebugTool, view, layer, debugInstan circle.style.width = `${object.size}px`; circle.style.height = `${object.size}px`; circle.innerHTML = `${Math.floor(object.size)} px`; - circle.style.left = `${coords.x - object.size * 0.5}px`; + circle.style.left = `${coords.x - object.size * 0.5}px`; circle.style.top = `${coords.y - object.size * 0.5}px`; }) .onComplete(removeAnimationRequester)