Allow replacing root node in ThreeCanvas.kt

This commit is contained in:
Alexander Nozik 2021-01-12 13:06:13 +03:00
parent bb6c6e2175
commit 716487d70a

View File

@ -1,8 +1,10 @@
package hep.dataforge.vision.solid.three package hep.dataforge.vision.solid.three
import hep.dataforge.context.logger
import hep.dataforge.meta.get import hep.dataforge.meta.get
import hep.dataforge.meta.string import hep.dataforge.meta.string
import hep.dataforge.names.Name import hep.dataforge.names.Name
import hep.dataforge.names.asName
import hep.dataforge.names.plus import hep.dataforge.names.plus
import hep.dataforge.names.toName import hep.dataforge.names.toName
import hep.dataforge.vision.Colors import hep.dataforge.vision.Colors
@ -195,10 +197,8 @@ public class ThreeCanvas(
} }
public fun render(vision: Solid) { public fun render(vision: Solid) {
scene.children.find { it.name == "@root" }?.let { three.logger.info { "Replacing root node in $this" }
//Throw error is something is already rendered here scene.findChild("@root".asName())?.let { scene.remove(it) }
error("Root object already is present in the canvas")
}
val object3D = three.buildObject3D(vision) val object3D = three.buildObject3D(vision)
object3D.name = "@root" object3D.name = "@root"