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 {
name.endsWith(".gdml") || name.endsWith(".xml") -> {
val gdml = GDML.parse(data)
gdml.toVision(gdmlConfiguration)
gdml.toVision()
}
name.endsWith(".json") -> SolidGroup.parseJson(data)
else -> {

View File

@ -14,18 +14,6 @@ import styled.injectGlobal
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 {
override fun start(state: Map<String, Any>) {
@ -46,7 +34,7 @@ private class GDMLDemoApp : Application {
child(GDMLApp) {
attrs {
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 {
file.extension == "gdml" || file.extension == "xml" -> {
GDML.readFile(file.toPath()).toVision {
lUnit = LUnit.CM
solidConfiguration = { parent, solid ->
if (solid.name == "cave") {
setItem(SolidMaterial.MATERIAL_WIREFRAME_KEY, true.asValue())
}
if (parent.physVolumes.isNotEmpty()) {
useStyle("opaque") {
SolidMaterial.MATERIAL_OPACITY_KEY put 0.3
}
}
}
// lUnit = LUnit.CM
//
// solidConfiguration = { parent, solid ->
// if (solid.name == "cave") {
// setItem(SolidMaterial.MATERIAL_WIREFRAME_KEY, true.asValue())
// }
// if (parent.physVolumes.isNotEmpty()) {
// useStyle("opaque") {
// SolidMaterial.MATERIAL_OPACITY_KEY put 0.3
// }
// }
// }
}
}
file.extension == "json" -> SolidGroup.parseJson(file.readText())

View File

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