From 8932c8dfd142b6f2111e494f53fa5e36a43a9f20 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Thu, 26 Dec 2019 11:46:44 +0300 Subject: [PATCH] Fix Three color change problem --- .../kotlin/hep/dataforge/vis/common/AbstractVisualObject.kt | 6 ++++-- .../hep/dataforge/vis/spatial/three/ThreeMaterials.kt | 2 +- demo/gdml/build.gradle.kts | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualObject.kt b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualObject.kt index 7d75df0a..7701eb1c 100644 --- a/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualObject.kt +++ b/dataforge-vis-common/src/commonMain/kotlin/hep/dataforge/vis/common/AbstractVisualObject.kt @@ -48,8 +48,10 @@ abstract class AbstractVisualObject : VisualObject { private val listeners = HashSet() override fun propertyChanged(name: Name, before: MetaItem<*>?, after: MetaItem<*>?) { - for (l in listeners) { - l.action(name, before, after) + if (before != after) { + for (l in listeners) { + l.action(name, before, after) + } } } diff --git a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeMaterials.kt b/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeMaterials.kt index edc760c7..a1e9495e 100644 --- a/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeMaterials.kt +++ b/dataforge-vis-spatial/src/jsMain/kotlin/hep/dataforge/vis/spatial/three/ThreeMaterials.kt @@ -93,7 +93,7 @@ fun MetaItem<*>.color(): Color { fun Mesh.updateMaterial(obj: VisualObject) { val meta = obj.getProperty(Material3D.MATERIAL_KEY).node?:EmptyMeta - material = (material as? MeshBasicMaterial ?: MeshBasicMaterial()).apply { + material = MeshBasicMaterial().apply { color = meta[Material3D.COLOR_KEY]?.color() ?: ThreeMaterials.DEFAULT_COLOR opacity = meta[Material3D.OPACITY_KEY]?.double ?: 1.0 transparent = opacity < 1.0 diff --git a/demo/gdml/build.gradle.kts b/demo/gdml/build.gradle.kts index 8ba1dcfc..67570e1d 100644 --- a/demo/gdml/build.gradle.kts +++ b/demo/gdml/build.gradle.kts @@ -15,7 +15,7 @@ kotlin { js { browser { webpackTask { - sourceMaps = false + //sourceMaps = false } } }