From 15ac3545b56a0cc06f3b68965a07fdf643b1767b Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 31 Dec 2023 20:12:40 +0300 Subject: [PATCH] Fix clipping controls for ThreeCanvas --- .../space/kscience/visionforge/compose/PropertyEditor.kt | 4 ++-- .../kscience/visionforge/solid/three/ThreeCanvas.kt | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt index 81d0b944..68899508 100644 --- a/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt +++ b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt @@ -116,7 +116,7 @@ public fun PropertyEditor( } } - CloseButton(editorPropertyState != EditorPropertyState.Defined){ + CloseButton(editorPropertyState != EditorPropertyState.Defined) { rootMeta.remove(name) update() } @@ -163,7 +163,7 @@ public fun PropertyEditor( } } - awaitClose { properties.removeListener(scope) } + awaitClose { properties.removeListener(scope) } }, name = Name.EMPTY, rootDescriptor = descriptor, diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeCanvas.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeCanvas.kt index 5723626a..dac32e08 100644 --- a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeCanvas.kt +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreeCanvas.kt @@ -155,9 +155,10 @@ public class ThreeCanvas( } //Clipping planes - options.useProperty(Canvas3DOptions::clipping) { clipping -> - if (!clipping.meta.isEmpty()) { - renderer.localClippingEnabled = true + options.useProperty(Canvas3DOptions::clipping) { clipping: PointScheme -> + if (clipping.meta.isEmpty()) { + renderer.clippingPlanes = emptyArray() + } else { boundingBox?.let { boundingBox -> val xClippingPlane = clipping.x?.let { val absoluteValue = boundingBox.min.x + (boundingBox.max.x - boundingBox.min.x) * it @@ -175,8 +176,6 @@ public class ThreeCanvas( renderer.clippingPlanes = listOfNotNull(xClippingPlane, yClippingPlane, zClippingPlane).toTypedArray() } - } else { - renderer.localClippingEnabled = false } }