Default properties for JS
This commit is contained in:
parent
193fed524e
commit
c2e396328f
@ -26,7 +26,7 @@ interface VisualObject : Configurable {
|
|||||||
/**
|
/**
|
||||||
* All properties including styles and prototypes if present, but without inheritance
|
* All properties including styles and prototypes if present, but without inheritance
|
||||||
*/
|
*/
|
||||||
fun allProperties(): Meta
|
fun allProperties(): Laminate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set property for this object
|
* Set property for this object
|
||||||
|
@ -32,6 +32,10 @@ class Material3D(override val config: Config) : Specific {
|
|||||||
val MATERIAL_WIREFRAME_KEY = MATERIAL_KEY + WIREFRAME_KEY
|
val MATERIAL_WIREFRAME_KEY = MATERIAL_KEY + WIREFRAME_KEY
|
||||||
|
|
||||||
val descriptor = NodeDescriptor {
|
val descriptor = NodeDescriptor {
|
||||||
|
value(VisualObject3D.VISIBLE_KEY) {
|
||||||
|
type(ValueType.BOOLEAN)
|
||||||
|
default(true)
|
||||||
|
}
|
||||||
node(MATERIAL_KEY) {
|
node(MATERIAL_KEY) {
|
||||||
value(COLOR_KEY) {
|
value(COLOR_KEY) {
|
||||||
type(ValueType.STRING, ValueType.NUMBER)
|
type(ValueType.STRING, ValueType.NUMBER)
|
||||||
|
@ -23,6 +23,9 @@ class ThreeCanvas(val three: ThreePlugin, val meta: Meta = EmptyMeta) : Renderer
|
|||||||
|
|
||||||
override val context: Context get() = three.context
|
override val context: Context get() = three.context
|
||||||
|
|
||||||
|
var data: VisualObject3D? = null
|
||||||
|
private set
|
||||||
|
|
||||||
val axes = AxesHelper(meta["axes.size"].int ?: 50).apply { visible = false }
|
val axes = AxesHelper(meta["axes.size"].int ?: 50).apply { visible = false }
|
||||||
|
|
||||||
val scene: Scene = Scene().apply {
|
val scene: Scene = Scene().apply {
|
||||||
@ -90,6 +93,7 @@ class ThreeCanvas(val three: ThreePlugin, val meta: Meta = EmptyMeta) : Renderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun render(obj: VisualObject3D, meta: Meta) {
|
override fun render(obj: VisualObject3D, meta: Meta) {
|
||||||
|
data = obj
|
||||||
scene.add(three.buildObject3D(obj))
|
scene.add(three.buildObject3D(obj))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,49 @@ package hep.dataforge.vis.spatial.three
|
|||||||
|
|
||||||
import hep.dataforge.vis.js.editor.card
|
import hep.dataforge.vis.js.editor.card
|
||||||
import kotlinx.html.InputType
|
import kotlinx.html.InputType
|
||||||
|
import kotlinx.html.button
|
||||||
import kotlinx.html.dom.append
|
import kotlinx.html.dom.append
|
||||||
import kotlinx.html.js.div
|
import kotlinx.html.js.*
|
||||||
import kotlinx.html.js.input
|
|
||||||
import kotlinx.html.js.label
|
|
||||||
import org.w3c.dom.Element
|
import org.w3c.dom.Element
|
||||||
import kotlin.dom.clear
|
import kotlin.dom.clear
|
||||||
|
|
||||||
|
//private fun download(filename: String, text: String) {
|
||||||
|
// var element = document.createElement("a");
|
||||||
|
// element.setAttribute("href", "data:text/json;charset=utf-8," + encodeURIComponent(text));
|
||||||
|
// element.setAttribute("download", filename);
|
||||||
|
//
|
||||||
|
// element.style.display = 'none';
|
||||||
|
// document.body.appendChild(element);
|
||||||
|
//
|
||||||
|
// element.click();
|
||||||
|
//
|
||||||
|
// document.body.removeChild(element);
|
||||||
|
//}
|
||||||
|
|
||||||
fun Element.threeOutputConfig(canvas: ThreeCanvas) {
|
fun Element.threeOutputConfig(canvas: ThreeCanvas) {
|
||||||
clear()
|
clear()
|
||||||
append {
|
append {
|
||||||
|
card("Settings"){
|
||||||
|
div("row"){
|
||||||
|
div("col-1") {
|
||||||
|
label { +"Axes" }
|
||||||
|
input(type = InputType.checkBox).apply {
|
||||||
|
checked = canvas.axes.visible
|
||||||
|
onChangeFunction = {
|
||||||
|
canvas.axes.visible = checked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
div("col-1") {
|
||||||
|
button {
|
||||||
|
+"Export"
|
||||||
|
onClickFunction = {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
card("Layers"){
|
card("Layers"){
|
||||||
div("row") {
|
div("row") {
|
||||||
(0..11).forEach { layer ->
|
(0..11).forEach { layer ->
|
||||||
@ -21,7 +54,7 @@ fun Element.threeOutputConfig(canvas: ThreeCanvas) {
|
|||||||
if (layer == 0) {
|
if (layer == 0) {
|
||||||
checked = true
|
checked = true
|
||||||
}
|
}
|
||||||
onchange = {
|
onChangeFunction = {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
canvas.camera.layers.enable(layer)
|
canvas.camera.layers.enable(layer)
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,20 +4,24 @@ import hep.dataforge.context.Global
|
|||||||
import hep.dataforge.js.Application
|
import hep.dataforge.js.Application
|
||||||
import hep.dataforge.js.objectTree
|
import hep.dataforge.js.objectTree
|
||||||
import hep.dataforge.js.startApplication
|
import hep.dataforge.js.startApplication
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.buildMeta
|
||||||
import hep.dataforge.meta.builder
|
import hep.dataforge.meta.withBottom
|
||||||
import hep.dataforge.names.NameToken
|
import hep.dataforge.names.NameToken
|
||||||
import hep.dataforge.vis.spatial.*
|
import hep.dataforge.vis.js.editor.propertyEditor
|
||||||
import hep.dataforge.vis.spatial.Material3D.Companion.MATERIAL_COLOR_KEY
|
import hep.dataforge.vis.spatial.Material3D.Companion.MATERIAL_COLOR_KEY
|
||||||
import hep.dataforge.vis.spatial.Material3D.Companion.MATERIAL_OPACITY_KEY
|
import hep.dataforge.vis.spatial.Material3D.Companion.MATERIAL_OPACITY_KEY
|
||||||
|
import hep.dataforge.vis.spatial.Material3D.Companion.MATERIAL_WIREFRAME_KEY
|
||||||
|
import hep.dataforge.vis.spatial.Visual3DPlugin
|
||||||
|
import hep.dataforge.vis.spatial.VisualGroup3D
|
||||||
|
import hep.dataforge.vis.spatial.VisualObject3D
|
||||||
import hep.dataforge.vis.spatial.VisualObject3D.Companion.VISIBLE_KEY
|
import hep.dataforge.vis.spatial.VisualObject3D.Companion.VISIBLE_KEY
|
||||||
import hep.dataforge.vis.js.editor.propertyEditor
|
|
||||||
import hep.dataforge.vis.spatial.three.threeOutputConfig
|
|
||||||
import hep.dataforge.vis.spatial.gdml.GDMLTransformer
|
import hep.dataforge.vis.spatial.gdml.GDMLTransformer
|
||||||
import hep.dataforge.vis.spatial.gdml.LUnit
|
import hep.dataforge.vis.spatial.gdml.LUnit
|
||||||
import hep.dataforge.vis.spatial.gdml.toVisual
|
import hep.dataforge.vis.spatial.gdml.toVisual
|
||||||
import hep.dataforge.vis.spatial.three.ThreePlugin
|
import hep.dataforge.vis.spatial.three.ThreePlugin
|
||||||
import hep.dataforge.vis.spatial.three.output
|
import hep.dataforge.vis.spatial.three.output
|
||||||
|
import hep.dataforge.vis.spatial.three.threeOutputConfig
|
||||||
|
import hep.dataforge.vis.spatial.visible
|
||||||
import kotlinx.html.dom.append
|
import kotlinx.html.dom.append
|
||||||
import kotlinx.html.js.p
|
import kotlinx.html.js.p
|
||||||
import org.w3c.dom.DragEvent
|
import org.w3c.dom.DragEvent
|
||||||
@ -157,14 +161,18 @@ private class GDMLDemoApp : Application {
|
|||||||
//tree.visualObjectTree(visual, editor::propertyEditor)
|
//tree.visualObjectTree(visual, editor::propertyEditor)
|
||||||
treeElement.objectTree(NameToken("World"), visual) {
|
treeElement.objectTree(NameToken("World"), visual) {
|
||||||
editorElement.propertyEditor(it) { item ->
|
editorElement.propertyEditor(it) { item ->
|
||||||
val config: Meta = item.prototype.config
|
//val descriptorMeta = Material3D.descriptor
|
||||||
config.builder().apply {
|
|
||||||
VISIBLE_KEY to (item.visible ?: true)
|
val properties = item.allProperties()
|
||||||
|
val bottom = buildMeta {
|
||||||
|
VISIBLE_KEY put (item.visible ?: true)
|
||||||
if (item is VisualObject3D) {
|
if (item is VisualObject3D) {
|
||||||
MATERIAL_COLOR_KEY to (item.color ?: "#ffffff")
|
MATERIAL_COLOR_KEY put "#ffffff"
|
||||||
MATERIAL_OPACITY_KEY to (item.opacity ?: 1.0)
|
MATERIAL_OPACITY_KEY put 1.0
|
||||||
|
MATERIAL_WIREFRAME_KEY put false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
properties.withBottom(bottom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user