Add edges to transparent objects. remove unnecessary re-configuration

This commit is contained in:
Alexander Nozik 2020-08-26 23:00:21 +03:00
parent 998afb1ce0
commit ea82082304
4 changed files with 16 additions and 29 deletions

View File

@ -59,7 +59,7 @@ val GDMLApp = component<GDMLAppProps> { props ->
val parsedVision = when { val parsedVision = when {
name.endsWith(".gdml") || name.endsWith(".xml") -> { name.endsWith(".gdml") || name.endsWith(".xml") -> {
val gdml = GDML.parse(data) val gdml = GDML.parse(data)
gdml.toVision(gdmlConfiguration) gdml.toVision()
} }
name.endsWith(".json") -> SolidGroup.parseJson(data) name.endsWith(".json") -> SolidGroup.parseJson(data)
else -> { else -> {

View File

@ -14,18 +14,6 @@ import styled.injectGlobal
import kotlin.browser.document import kotlin.browser.document
val gdmlConfiguration: GDMLTransformer.() -> Unit = {
lUnit = LUnit.CM
solidConfiguration = { parent, _ ->
if (parent.physVolumes.isNotEmpty()) {
useStyle("opaque") {
MATERIAL_OPACITY_KEY put 0.3
}
}
}
}
private class GDMLDemoApp : Application { private class GDMLDemoApp : Application {
override fun start(state: Map<String, Any>) { override fun start(state: Map<String, Any>) {
@ -46,7 +34,7 @@ private class GDMLDemoApp : Application {
child(GDMLApp) { child(GDMLApp) {
attrs { attrs {
this.context = context this.context = context
this.rootObject = cubes().toVision(gdmlConfiguration) this.rootObject = cubes().toVision()
} }
} }
} }

View File

@ -18,18 +18,18 @@ import java.util.zip.ZipInputStream
fun SolidManager.Companion.readFile(file: File): SolidGroup = when { fun SolidManager.Companion.readFile(file: File): SolidGroup = when {
file.extension == "gdml" || file.extension == "xml" -> { file.extension == "gdml" || file.extension == "xml" -> {
GDML.readFile(file.toPath()).toVision { GDML.readFile(file.toPath()).toVision {
lUnit = LUnit.CM // lUnit = LUnit.CM
//
solidConfiguration = { parent, solid -> // solidConfiguration = { parent, solid ->
if (solid.name == "cave") { // if (solid.name == "cave") {
setItem(SolidMaterial.MATERIAL_WIREFRAME_KEY, true.asValue()) // setItem(SolidMaterial.MATERIAL_WIREFRAME_KEY, true.asValue())
} // }
if (parent.physVolumes.isNotEmpty()) { // if (parent.physVolumes.isNotEmpty()) {
useStyle("opaque") { // useStyle("opaque") {
SolidMaterial.MATERIAL_OPACITY_KEY put 0.3 // SolidMaterial.MATERIAL_OPACITY_KEY put 0.3
} // }
} // }
} // }
} }
} }
file.extension == "json" -> SolidGroup.parseJson(file.readText()) file.extension == "json" -> SolidGroup.parseJson(file.readText())

View File

@ -47,9 +47,7 @@ class GDMLTransformer(val root: GDML) {
} }
internal val volumes by lazy { internal val volumes by lazy {
proto.group(volumesName) { proto.group(volumesName)
config["edges.enabled"] = true
}
} }
private val styleCache = HashMap<Name, Meta>() private val styleCache = HashMap<Name, Meta>()
@ -58,6 +56,7 @@ class GDMLTransformer(val root: GDML) {
if (parent.physVolumes.isNotEmpty()) { if (parent.physVolumes.isNotEmpty()) {
useStyle("opaque") { useStyle("opaque") {
SolidMaterial.MATERIAL_OPACITY_KEY put 0.3 SolidMaterial.MATERIAL_OPACITY_KEY put 0.3
"edges.enabled" put true
} }
} }
} }