forked from kscience/visionforge
Cleanup vision root rules
This commit is contained in:
parent
eeec89f0e6
commit
34fbb23c60
@ -6,6 +6,7 @@ import space.kscience.dataforge.meta.get
|
|||||||
import space.kscience.dataforge.meta.int
|
import space.kscience.dataforge.meta.int
|
||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.Name
|
||||||
import space.kscience.dataforge.names.plus
|
import space.kscience.dataforge.names.plus
|
||||||
|
import space.kscience.visionforge.MutableVisionContainer
|
||||||
import space.kscience.visionforge.isEmpty
|
import space.kscience.visionforge.isEmpty
|
||||||
import space.kscience.visionforge.set
|
import space.kscience.visionforge.set
|
||||||
import space.kscience.visionforge.solid.*
|
import space.kscience.visionforge.solid.*
|
||||||
@ -262,7 +263,7 @@ private fun SolidGroup.addShape(
|
|||||||
val fShape by shape.dObject(::DGeoShape)
|
val fShape by shape.dObject(::DGeoShape)
|
||||||
val fScale by shape.dObject(::DGeoScale)
|
val fScale by shape.dObject(::DGeoScale)
|
||||||
fShape?.let { scaledShape ->
|
fShape?.let { scaledShape ->
|
||||||
group(name?.let { Name.parse(it) }) {
|
solidGroup(name?.let { Name.parse(it) }) {
|
||||||
scale = Point3D(fScale?.x ?: 1.0, fScale?.y ?: 1.0, fScale?.z ?: 1.0)
|
scale = Point3D(fScale?.x ?: 1.0, fScale?.y ?: 1.0, fScale?.z ?: 1.0)
|
||||||
addShape(scaledShape, context)
|
addShape(scaledShape, context)
|
||||||
apply(block)
|
apply(block)
|
||||||
@ -294,7 +295,7 @@ private fun SolidGroup.addRootNode(obj: DGeoNode, context: RootToSolidContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun buildVolume(volume: DGeoVolume, context: RootToSolidContext): Solid? {
|
private fun buildVolume(volume: DGeoVolume, context: RootToSolidContext): Solid? {
|
||||||
val group = SolidGroup {
|
val group = SolidGroup().apply {
|
||||||
//set current layer
|
//set current layer
|
||||||
layer = context.currentLayer
|
layer = context.currentLayer
|
||||||
val nodes = volume.fNodes
|
val nodes = volume.fNodes
|
||||||
@ -372,9 +373,9 @@ private fun SolidGroup.addRootVolume(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun DGeoManager.toSolid(): SolidGroup = SolidGroup {
|
public fun MutableVisionContainer<Solid>.rootGeo(dGeoManager: DGeoManager): SolidGroup = solidGroup {
|
||||||
val context = RootToSolidContext(this)
|
val context = RootToSolidContext(this)
|
||||||
fNodes.forEach { node ->
|
dGeoManager.fNodes.forEach { node ->
|
||||||
addRootNode(node, context)
|
addRootNode(node, context)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,6 +3,7 @@ package ru.mipt.npm.root.serialization
|
|||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.Name
|
||||||
import space.kscience.dataforge.names.asName
|
import space.kscience.dataforge.names.asName
|
||||||
import space.kscience.dataforge.names.plus
|
import space.kscience.dataforge.names.plus
|
||||||
|
import space.kscience.visionforge.MutableVisionContainer
|
||||||
import space.kscience.visionforge.solid.*
|
import space.kscience.visionforge.solid.*
|
||||||
import kotlin.math.PI
|
import kotlin.math.PI
|
||||||
import kotlin.math.atan2
|
import kotlin.math.atan2
|
||||||
@ -132,7 +133,7 @@ private fun buildGroup(volume: TGeoVolume): SolidGroup {
|
|||||||
return if (volume is TGeoVolumeAssemblyRef) {
|
return if (volume is TGeoVolumeAssemblyRef) {
|
||||||
buildGroup(volume.value)
|
buildGroup(volume.value)
|
||||||
} else {
|
} else {
|
||||||
SolidGroup {
|
SolidGroup().apply {
|
||||||
volume.fShape?.let { addShape(it) }
|
volume.fShape?.let { addShape(it) }
|
||||||
volume.fNodes?.let {
|
volume.fNodes?.let {
|
||||||
it.arr.forEach { obj ->
|
it.arr.forEach { obj ->
|
||||||
@ -180,8 +181,8 @@ private fun SolidGroup.volume(volume: TGeoVolume, name: String? = null, cache: B
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
public fun TGeoManager.toSolid(): SolidGroup = SolidGroup {
|
public fun MutableVisionContainer<Solid>.rootGeo(tGeoManager: TGeoManager): SolidGroup = solidGroup {
|
||||||
fNodes.arr.forEach {
|
tGeoManager.fNodes.arr.forEach {
|
||||||
node(it)
|
node(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,10 +10,7 @@ import org.w3c.files.get
|
|||||||
import react.Props
|
import react.Props
|
||||||
import react.dom.h2
|
import react.dom.h2
|
||||||
import react.fc
|
import react.fc
|
||||||
import react.useMemo
|
|
||||||
import react.useState
|
import react.useState
|
||||||
import space.kscience.dataforge.context.Context
|
|
||||||
import space.kscience.dataforge.context.fetch
|
|
||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.Name
|
||||||
import space.kscience.gdml.Gdml
|
import space.kscience.gdml.Gdml
|
||||||
import space.kscience.gdml.decodeFromString
|
import space.kscience.gdml.decodeFromString
|
||||||
@ -31,14 +28,13 @@ import styled.css
|
|||||||
import styled.styledDiv
|
import styled.styledDiv
|
||||||
|
|
||||||
external interface GDMLAppProps : Props {
|
external interface GDMLAppProps : Props {
|
||||||
var context: Context
|
var solids: Solids
|
||||||
var vision: Solid?
|
var vision: Solid?
|
||||||
var selected: Name?
|
var selected: Name?
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsExport
|
@JsExport
|
||||||
val GDMLApp = fc<GDMLAppProps>("GDMLApp") { props ->
|
val GDMLApp = fc<GDMLAppProps>("GDMLApp") { props ->
|
||||||
val visionManager = useMemo(props.context) { props.context.fetch(Solids).visionManager }
|
|
||||||
var deferredVision: Deferred<Solid?> by useState {
|
var deferredVision: Deferred<Solid?> by useState {
|
||||||
CompletableDeferred(props.vision)
|
CompletableDeferred(props.vision)
|
||||||
}
|
}
|
||||||
@ -53,7 +49,7 @@ val GDMLApp = fc<GDMLAppProps>("GDMLApp") { props ->
|
|||||||
name.endsWith(".gdml") || name.endsWith(".xml") -> {
|
name.endsWith(".gdml") || name.endsWith(".xml") -> {
|
||||||
val gdml = Gdml.decodeFromString(data)
|
val gdml = Gdml.decodeFromString(data)
|
||||||
gdml.toVision().apply {
|
gdml.toVision().apply {
|
||||||
setAsRoot(visionManager)
|
setAsRoot(props.solids.visionManager)
|
||||||
console.info("Marking layers for file $name")
|
console.info("Marking layers for file $name")
|
||||||
markLayers()
|
markLayers()
|
||||||
ambientLight {
|
ambientLight {
|
||||||
@ -61,7 +57,7 @@ val GDMLApp = fc<GDMLAppProps>("GDMLApp") { props ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
name.endsWith(".json") -> visionManager.decodeFromString(data)
|
name.endsWith(".json") -> props.solids.visionManager.decodeFromString(data)
|
||||||
else -> {
|
else -> {
|
||||||
window.alert("File extension is not recognized: $name")
|
window.alert("File extension is not recognized: $name")
|
||||||
error("File extension is not recognized: $name")
|
error("File extension is not recognized: $name")
|
||||||
@ -82,7 +78,7 @@ val GDMLApp = fc<GDMLAppProps>("GDMLApp") { props ->
|
|||||||
}
|
}
|
||||||
child(ThreeCanvasWithControls) {
|
child(ThreeCanvasWithControls) {
|
||||||
attrs {
|
attrs {
|
||||||
this.context = props.context
|
this.solids = props.solids
|
||||||
this.builderOfSolid = deferredVision
|
this.builderOfSolid = deferredVision
|
||||||
this.selected = props.selected
|
this.selected = props.selected
|
||||||
tab("Load") {
|
tab("Load") {
|
||||||
|
@ -4,11 +4,13 @@ import kotlinx.browser.document
|
|||||||
import kotlinx.css.*
|
import kotlinx.css.*
|
||||||
import react.dom.client.createRoot
|
import react.dom.client.createRoot
|
||||||
import space.kscience.dataforge.context.Context
|
import space.kscience.dataforge.context.Context
|
||||||
|
import space.kscience.dataforge.context.fetch
|
||||||
import space.kscience.gdml.GdmlShowCase
|
import space.kscience.gdml.GdmlShowCase
|
||||||
import space.kscience.visionforge.Application
|
import space.kscience.visionforge.Application
|
||||||
import space.kscience.visionforge.Colors
|
import space.kscience.visionforge.Colors
|
||||||
import space.kscience.visionforge.gdml.toVision
|
import space.kscience.visionforge.gdml.toVision
|
||||||
import space.kscience.visionforge.react.render
|
import space.kscience.visionforge.react.render
|
||||||
|
import space.kscience.visionforge.solid.Solids
|
||||||
import space.kscience.visionforge.solid.ambientLight
|
import space.kscience.visionforge.solid.ambientLight
|
||||||
import space.kscience.visionforge.solid.set
|
import space.kscience.visionforge.solid.set
|
||||||
import space.kscience.visionforge.solid.three.ThreePlugin
|
import space.kscience.visionforge.solid.three.ThreePlugin
|
||||||
@ -52,7 +54,7 @@ private class GDMLDemoApp : Application {
|
|||||||
}
|
}
|
||||||
//println(context.plugins.fetch(VisionManager).encodeToString(vision))
|
//println(context.plugins.fetch(VisionManager).encodeToString(vision))
|
||||||
attrs {
|
attrs {
|
||||||
this.context = context
|
this.solids = context.fetch(Solids)
|
||||||
this.vision = vision
|
this.vision = vision
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import react.dom.client.createRoot
|
|||||||
import ringui.SmartTabs
|
import ringui.SmartTabs
|
||||||
import ringui.Tab
|
import ringui.Tab
|
||||||
import space.kscience.dataforge.context.Context
|
import space.kscience.dataforge.context.Context
|
||||||
|
import space.kscience.dataforge.context.fetch
|
||||||
import space.kscience.plotly.models.Trace
|
import space.kscience.plotly.models.Trace
|
||||||
import space.kscience.plotly.scatter
|
import space.kscience.plotly.scatter
|
||||||
import space.kscience.visionforge.Application
|
import space.kscience.visionforge.Application
|
||||||
@ -51,7 +52,7 @@ private class JsPlaygroundApp : Application {
|
|||||||
Tab("gravity") {
|
Tab("gravity") {
|
||||||
GravityDemo {
|
GravityDemo {
|
||||||
attrs {
|
attrs {
|
||||||
this.context = playgroundContext
|
this.solids = playgroundContext.fetch(Solids)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,7 +73,7 @@ private class JsPlaygroundApp : Application {
|
|||||||
child(ThreeCanvasWithControls) {
|
child(ThreeCanvasWithControls) {
|
||||||
val random = Random(112233)
|
val random = Random(112233)
|
||||||
attrs {
|
attrs {
|
||||||
context = playgroundContext
|
solids = playgroundContext.fetch(Solids)
|
||||||
solid {
|
solid {
|
||||||
ambientLight {
|
ambientLight {
|
||||||
color.set(Colors.white)
|
color.set(Colors.white)
|
||||||
|
@ -4,7 +4,6 @@ import kotlinx.coroutines.launch
|
|||||||
import kotlinx.css.*
|
import kotlinx.css.*
|
||||||
import react.Props
|
import react.Props
|
||||||
import react.fc
|
import react.fc
|
||||||
import space.kscience.dataforge.context.Context
|
|
||||||
import space.kscience.plotly.layout
|
import space.kscience.plotly.layout
|
||||||
import space.kscience.plotly.models.Trace
|
import space.kscience.plotly.models.Trace
|
||||||
import space.kscience.visionforge.Colors
|
import space.kscience.visionforge.Colors
|
||||||
@ -18,7 +17,7 @@ import styled.styledDiv
|
|||||||
import kotlin.math.sqrt
|
import kotlin.math.sqrt
|
||||||
|
|
||||||
external interface DemoProps : Props {
|
external interface DemoProps : Props {
|
||||||
var context: Context
|
var solids: Solids
|
||||||
}
|
}
|
||||||
|
|
||||||
val GravityDemo = fc<DemoProps> { props ->
|
val GravityDemo = fc<DemoProps> { props ->
|
||||||
@ -40,7 +39,7 @@ val GravityDemo = fc<DemoProps> { props ->
|
|||||||
}
|
}
|
||||||
child(ThreeCanvasWithControls) {
|
child(ThreeCanvasWithControls) {
|
||||||
attrs {
|
attrs {
|
||||||
context = props.context
|
solids = props.solids
|
||||||
solid {
|
solid {
|
||||||
pointLight(200, 200, 200, name = "light"){
|
pointLight(200, 200, 200, name = "light"){
|
||||||
color.set(Colors.white)
|
color.set(Colors.white)
|
||||||
@ -52,7 +51,7 @@ val GravityDemo = fc<DemoProps> { props ->
|
|||||||
color.set("red")
|
color.set("red")
|
||||||
val h = 100.0
|
val h = 100.0
|
||||||
y = h
|
y = h
|
||||||
context.launch {
|
solids.context.launch {
|
||||||
val g = 10.0
|
val g = 10.0
|
||||||
val dt = 0.1
|
val dt = 0.1
|
||||||
var time = 0.0
|
var time = 0.0
|
||||||
|
@ -15,7 +15,7 @@ class Model(val manager: VisionManager) {
|
|||||||
private val events = HashSet<Event>()
|
private val events = HashSet<Event>()
|
||||||
|
|
||||||
private fun MutableVisionContainer<Solid>.pixel(pixel: SC1) {
|
private fun MutableVisionContainer<Solid>.pixel(pixel: SC1) {
|
||||||
val group = group(pixel.name) {
|
val group = solidGroup(pixel.name) {
|
||||||
position = Point3D(pixel.center.x, pixel.center.y, pixel.center.z)
|
position = Point3D(pixel.center.x, pixel.center.y, pixel.center.z)
|
||||||
box(pixel.xSize, pixel.ySize, pixel.zSize)
|
box(pixel.xSize, pixel.ySize, pixel.zSize)
|
||||||
label(pixel.name) {
|
label(pixel.name) {
|
||||||
@ -27,7 +27,7 @@ class Model(val manager: VisionManager) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun SolidGroup.detector(detector: SC16) {
|
private fun SolidGroup.detector(detector: SC16) {
|
||||||
group(detector.name) {
|
solidGroup(detector.name) {
|
||||||
detector.pixels.forEach {
|
detector.pixels.forEach {
|
||||||
pixel(it)
|
pixel(it)
|
||||||
}
|
}
|
||||||
@ -42,24 +42,24 @@ class Model(val manager: VisionManager) {
|
|||||||
color.set("darkgreen")
|
color.set("darkgreen")
|
||||||
}
|
}
|
||||||
rotationX = PI / 2
|
rotationX = PI / 2
|
||||||
group("bottom") {
|
solidGroup("bottom") {
|
||||||
Monitor.detectors.filter { it.center.z == LOWER_LAYER_Z }.forEach {
|
Monitor.detectors.filter { it.center.z == LOWER_LAYER_Z }.forEach {
|
||||||
detector(it)
|
detector(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
group("middle") {
|
solidGroup("middle") {
|
||||||
Monitor.detectors.filter { it.center.z == CENTRAL_LAYER_Z }.forEach {
|
Monitor.detectors.filter { it.center.z == CENTRAL_LAYER_Z }.forEach {
|
||||||
detector(it)
|
detector(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
group("top") {
|
solidGroup("top") {
|
||||||
Monitor.detectors.filter { it.center.z == UPPER_LAYER_Z }.forEach {
|
Monitor.detectors.filter { it.center.z == UPPER_LAYER_Z }.forEach {
|
||||||
detector(it)
|
detector(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tracks = group("tracks")
|
tracks = solidGroup("tracks")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun highlight(pixel: String) {
|
private fun highlight(pixel: String) {
|
||||||
|
@ -49,7 +49,7 @@ fun main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vision("form") { form }
|
vision("form") { form }
|
||||||
form.onPropertyChange { _, _ ->
|
form.onPropertyChange {
|
||||||
println(this)
|
println(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package space.kscience.visionforge.examples
|
package space.kscience.visionforge.examples
|
||||||
|
|
||||||
import ru.mipt.npm.root.DGeoManager
|
import ru.mipt.npm.root.DGeoManager
|
||||||
|
import ru.mipt.npm.root.rootGeo
|
||||||
import ru.mipt.npm.root.serialization.TGeoManager
|
import ru.mipt.npm.root.serialization.TGeoManager
|
||||||
import ru.mipt.npm.root.toSolid
|
|
||||||
import space.kscience.dataforge.meta.Meta
|
import space.kscience.dataforge.meta.Meta
|
||||||
import space.kscience.dataforge.meta.get
|
import space.kscience.dataforge.meta.get
|
||||||
import space.kscience.dataforge.meta.isLeaf
|
import space.kscience.dataforge.meta.isLeaf
|
||||||
@ -34,7 +34,7 @@ fun main() {
|
|||||||
println(it)
|
println(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
val solid = geo.toSolid()
|
val solid = Solids.rootGeo(geo)
|
||||||
|
|
||||||
Paths.get("BM@N.vf.json").writeText(Solids.encodeToString(solid))
|
Paths.get("BM@N.vf.json").writeText(Solids.encodeToString(solid))
|
||||||
//println(Solids.encodeToString(solid))
|
//println(Solids.encodeToString(solid))
|
||||||
|
@ -15,7 +15,7 @@ group = "ru.mipt.npm"
|
|||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
implementation(project(":visionforge-threejs:visionforge-threejs-server"))
|
implementation(project(":visionforge-threejs:visionforge-threejs-server"))
|
||||||
implementation("ch.qos.logback:logback-classic:1.2.3")
|
implementation("ch.qos.logback:logback-classic:1.2.11")
|
||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
|
@ -6,7 +6,7 @@ import space.kscience.visionforge.style
|
|||||||
import space.kscience.visionforge.useStyle
|
import space.kscience.visionforge.useStyle
|
||||||
import kotlin.math.PI
|
import kotlin.math.PI
|
||||||
|
|
||||||
internal fun visionOfSatellite(
|
internal fun Solids.visionOfSatellite(
|
||||||
layers: Int = 10,
|
layers: Int = 10,
|
||||||
layerHeight: Number = 10,
|
layerHeight: Number = 10,
|
||||||
xSegments: Int = 3,
|
xSegments: Int = 3,
|
||||||
@ -14,7 +14,7 @@ internal fun visionOfSatellite(
|
|||||||
xSegmentSize: Number = 30,
|
xSegmentSize: Number = 30,
|
||||||
ySegmentSize: Number = xSegmentSize,
|
ySegmentSize: Number = xSegmentSize,
|
||||||
fiberDiameter: Number = 1.0,
|
fiberDiameter: Number = 1.0,
|
||||||
): SolidGroup = SolidGroup {
|
): SolidGroup = solidGroup {
|
||||||
color.set("darkgreen")
|
color.set("darkgreen")
|
||||||
val transparent by style {
|
val transparent by style {
|
||||||
this[SolidMaterial.MATERIAL_OPACITY_KEY] = 0.3
|
this[SolidMaterial.MATERIAL_OPACITY_KEY] = 0.3
|
||||||
@ -31,7 +31,7 @@ internal fun visionOfSatellite(
|
|||||||
val totalXSize = xSegments * xSegmentSize.toDouble()
|
val totalXSize = xSegments * xSegmentSize.toDouble()
|
||||||
val totalYSize = ySegments * ySegmentSize.toDouble()
|
val totalYSize = ySegments * ySegmentSize.toDouble()
|
||||||
for (layer in 1..layers) {
|
for (layer in 1..layers) {
|
||||||
group("layer[$layer]") {
|
solidGroup("layer[$layer]") {
|
||||||
for (i in 1..xSegments) {
|
for (i in 1..xSegments) {
|
||||||
for (j in 1..ySegments) {
|
for (j in 1..ySegments) {
|
||||||
box(xSegmentSize, ySegmentSize, layerHeight, name = "segment[$i,$j]") {
|
box(xSegmentSize, ySegmentSize, layerHeight, name = "segment[$i,$j]") {
|
||||||
@ -42,7 +42,7 @@ internal fun visionOfSatellite(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
group("fibers") {
|
solidGroup("fibers") {
|
||||||
for (i in 1..xSegments) {
|
for (i in 1..xSegments) {
|
||||||
cylinder(fiberDiameter, totalYSize) {
|
cylinder(fiberDiameter, totalYSize) {
|
||||||
useStyle(red)
|
useStyle(red)
|
||||||
|
@ -5,6 +5,8 @@ import kotlinx.coroutines.*
|
|||||||
import kotlinx.html.div
|
import kotlinx.html.div
|
||||||
import kotlinx.html.h1
|
import kotlinx.html.h1
|
||||||
import space.kscience.dataforge.context.Context
|
import space.kscience.dataforge.context.Context
|
||||||
|
import space.kscience.dataforge.context.fetch
|
||||||
|
import space.kscience.dataforge.misc.DFExperimental
|
||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.Name
|
||||||
import space.kscience.visionforge.html.Page
|
import space.kscience.visionforge.html.Page
|
||||||
import space.kscience.visionforge.html.plus
|
import space.kscience.visionforge.html.plus
|
||||||
@ -17,13 +19,16 @@ import space.kscience.visionforge.visionManager
|
|||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
|
|
||||||
|
@OptIn(DFExperimental::class)
|
||||||
fun main() {
|
fun main() {
|
||||||
val satContext = Context("sat") {
|
val satContext = Context("sat") {
|
||||||
plugin(Solids)
|
plugin(Solids)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val solids = satContext.fetch(Solids)
|
||||||
|
|
||||||
//Create a geometry
|
//Create a geometry
|
||||||
val sat = visionOfSatellite(ySegments = 3)
|
val sat = solids.visionOfSatellite(ySegments = 3)
|
||||||
|
|
||||||
val server = satContext.visionManager.serve {
|
val server = satContext.visionManager.serve {
|
||||||
page(header = Page.threeJsHeader + Page.styleSheetHeader("css/styles.css")) {
|
page(header = Page.threeJsHeader + Page.styleSheetHeader("css/styles.css")) {
|
||||||
|
@ -5,7 +5,6 @@ import space.kscience.dataforge.meta.Meta
|
|||||||
import space.kscience.dataforge.meta.invoke
|
import space.kscience.dataforge.meta.invoke
|
||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.Name
|
||||||
import space.kscience.visionforge.Colors
|
import space.kscience.visionforge.Colors
|
||||||
import space.kscience.visionforge.setAsRoot
|
|
||||||
import space.kscience.visionforge.solid.*
|
import space.kscience.visionforge.solid.*
|
||||||
import space.kscience.visionforge.solid.specifications.Canvas3DOptions
|
import space.kscience.visionforge.solid.specifications.Canvas3DOptions
|
||||||
import space.kscience.visionforge.visible
|
import space.kscience.visionforge.visible
|
||||||
@ -19,11 +18,11 @@ fun VisionLayout<Solid>.demo(name: String, title: String = name, block: SolidGro
|
|||||||
val meta = Meta {
|
val meta = Meta {
|
||||||
"title" put title
|
"title" put title
|
||||||
}
|
}
|
||||||
val vision = SolidGroup(block).apply {
|
val vision = solids.solidGroup {
|
||||||
|
block()
|
||||||
ambientLight{
|
ambientLight{
|
||||||
color.set(Colors.white)
|
color.set(Colors.white)
|
||||||
}
|
}
|
||||||
setAsRoot(solids.visionManager)
|
|
||||||
}
|
}
|
||||||
render(Name.parse(name), vision, meta)
|
render(Name.parse(name), vision, meta)
|
||||||
}
|
}
|
||||||
@ -69,7 +68,7 @@ fun VisionLayout<Solid>.showcase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
demo("dynamic", "Dynamic properties") {
|
demo("dynamic", "Dynamic properties") {
|
||||||
val group = group {
|
val group = solidGroup {
|
||||||
box(100, 100, 100) {
|
box(100, 100, 100) {
|
||||||
z = 110.0
|
z = 110.0
|
||||||
opacity = 0.5
|
opacity = 0.5
|
||||||
@ -101,7 +100,7 @@ fun VisionLayout<Solid>.showcase() {
|
|||||||
|
|
||||||
demo("rotation", "Rotations") {
|
demo("rotation", "Rotations") {
|
||||||
box(100, 100, 100)
|
box(100, 100, 100)
|
||||||
group {
|
solidGroup {
|
||||||
x = 200
|
x = 200
|
||||||
rotationY = PI / 4
|
rotationY = PI / 4
|
||||||
box(100, 100, 100) {
|
box(100, 100, 100) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
kotlin.mpp.stability.nowarn=true
|
kotlin.mpp.stability.nowarn=true
|
||||||
kotlin.jupyter.add.scanner=false
|
kotlin.jupyter.add.scanner=false
|
||||||
#kotlin.incremental.js.ir=true
|
kotlin.incremental.js.ir=true
|
||||||
|
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
org.gradle.jvmargs=-Xmx4G
|
org.gradle.jvmargs=-Xmx4G
|
||||||
|
@ -10,7 +10,6 @@ import react.dom.div
|
|||||||
import react.dom.p
|
import react.dom.p
|
||||||
import react.dom.span
|
import react.dom.span
|
||||||
import ringui.*
|
import ringui.*
|
||||||
import space.kscience.dataforge.context.Context
|
|
||||||
import space.kscience.dataforge.meta.get
|
import space.kscience.dataforge.meta.get
|
||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.Name
|
||||||
import space.kscience.dataforge.names.NameToken
|
import space.kscience.dataforge.names.NameToken
|
||||||
@ -20,21 +19,25 @@ import space.kscience.visionforge.*
|
|||||||
import space.kscience.visionforge.react.*
|
import space.kscience.visionforge.react.*
|
||||||
import space.kscience.visionforge.solid.Solid
|
import space.kscience.visionforge.solid.Solid
|
||||||
import space.kscience.visionforge.solid.SolidGroup
|
import space.kscience.visionforge.solid.SolidGroup
|
||||||
|
import space.kscience.visionforge.solid.Solids
|
||||||
|
import space.kscience.visionforge.solid.solidGroup
|
||||||
import space.kscience.visionforge.solid.specifications.Canvas3DOptions
|
import space.kscience.visionforge.solid.specifications.Canvas3DOptions
|
||||||
import styled.css
|
import styled.css
|
||||||
import styled.styledDiv
|
import styled.styledDiv
|
||||||
|
|
||||||
public external interface ThreeCanvasWithControlsProps : Props {
|
public external interface ThreeCanvasWithControlsProps : Props {
|
||||||
public var context: Context
|
public var solids: Solids
|
||||||
public var builderOfSolid: Deferred<Solid?>
|
public var builderOfSolid: Deferred<Solid?>
|
||||||
public var selected: Name?
|
public var selected: Name?
|
||||||
public var options: Canvas3DOptions?
|
public var options: Canvas3DOptions?
|
||||||
public var additionalTabs: Map<String, RBuilder.() -> Unit>?
|
public var additionalTabs: Map<String, RBuilder.() -> Unit>?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val ThreeCanvasWithControlsProps.context get() = solids.context
|
||||||
|
|
||||||
public fun ThreeCanvasWithControlsProps.solid(block: SolidGroup.() -> Unit) {
|
public fun ThreeCanvasWithControlsProps.solid(block: SolidGroup.() -> Unit) {
|
||||||
builderOfSolid = context.async {
|
builderOfSolid = context.async {
|
||||||
SolidGroup(block)
|
solids.solidGroup(null, block)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class ThreeWithControlsPlugin : AbstractPlugin(), ElementVisionRenderer {
|
|||||||
createRoot(element).render {
|
createRoot(element).render {
|
||||||
child(ThreeCanvasWithControls) {
|
child(ThreeCanvasWithControls) {
|
||||||
attrs {
|
attrs {
|
||||||
this.context = this@ThreeWithControlsPlugin.context
|
this.solids = three.solids
|
||||||
this.builderOfSolid = context.async { vision as Solid}
|
this.builderOfSolid = context.async { vision as Solid}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import space.kscience.dataforge.meta.descriptors.MetaDescriptor
|
|||||||
import space.kscience.dataforge.meta.descriptors.value
|
import space.kscience.dataforge.meta.descriptors.value
|
||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.Name
|
||||||
import space.kscience.dataforge.names.NameToken
|
import space.kscience.dataforge.names.NameToken
|
||||||
|
import space.kscience.dataforge.names.parseAsName
|
||||||
import space.kscience.dataforge.names.plus
|
import space.kscience.dataforge.names.plus
|
||||||
import space.kscience.visionforge.Vision.Companion.STYLE_KEY
|
import space.kscience.visionforge.Vision.Companion.STYLE_KEY
|
||||||
|
|
||||||
@ -95,19 +96,19 @@ public class SimpleVisionGroup : AbstractVisionGroup(), MutableVisionContainer<V
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisionBuilder
|
@VisionBuilder
|
||||||
public fun MutableVisionContainer<Vision>.group(
|
public inline fun MutableVisionContainer<Vision>.group(
|
||||||
name: Name? = null,
|
name: Name? = null,
|
||||||
builder: SimpleVisionGroup.() -> Unit = {},
|
builder: SimpleVisionGroup.() -> Unit = {},
|
||||||
): SimpleVisionGroup = SimpleVisionGroup().apply(builder).also { setChild(name, it) }
|
): SimpleVisionGroup = SimpleVisionGroup().also { setChild(name, it) }.apply(builder)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define a group with given [name], attach it to this parent and return it.
|
* Define a group with given [name], attach it to this parent and return it.
|
||||||
*/
|
*/
|
||||||
@VisionBuilder
|
@VisionBuilder
|
||||||
public fun MutableVisionContainer<Vision>.group(
|
public inline fun MutableVisionContainer<Vision>.group(
|
||||||
name: String,
|
name: String,
|
||||||
builder: SimpleVisionGroup.() -> Unit = {},
|
builder: SimpleVisionGroup.() -> Unit = {},
|
||||||
): SimpleVisionGroup = SimpleVisionGroup().apply(builder).also { setChild(name, it) }
|
): SimpleVisionGroup = group(name.parseAsName(), builder)
|
||||||
|
|
||||||
//fun VisualObject.findStyle(styleName: Name): Meta? {
|
//fun VisualObject.findStyle(styleName: Name): Meta? {
|
||||||
// if (this is VisualGroup) {
|
// if (this is VisualGroup) {
|
||||||
|
@ -65,6 +65,7 @@ public class VisionClient : AbstractPlugin() {
|
|||||||
|
|
||||||
private fun renderVision(name: String, element: Element, vision: Vision?, outputMeta: Meta) {
|
private fun renderVision(name: String, element: Element, vision: Vision?, outputMeta: Meta) {
|
||||||
if (vision != null) {
|
if (vision != null) {
|
||||||
|
vision.setAsRoot(visionManager)
|
||||||
val renderer = findRendererFor(vision)
|
val renderer = findRendererFor(vision)
|
||||||
?: error("Could not find renderer for ${visionManager.encodeToString(vision)}")
|
?: error("Could not find renderer for ${visionManager.encodeToString(vision)}")
|
||||||
renderer.render(element, vision, outputMeta)
|
renderer.render(element, vision, outputMeta)
|
||||||
|
@ -29,7 +29,7 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) {
|
|||||||
*/
|
*/
|
||||||
private val proto = SolidGroup()
|
private val proto = SolidGroup()
|
||||||
|
|
||||||
private val solids = proto.group(solidsName) {
|
private val solids = proto.solidGroup(solidsName) {
|
||||||
properties["edges.enabled"] = false
|
properties["edges.enabled"] = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ public inline fun MutableVisionContainer<Solid>.composite(
|
|||||||
name: String? = null,
|
name: String? = null,
|
||||||
@VisionBuilder builder: SolidGroup.() -> Unit,
|
@VisionBuilder builder: SolidGroup.() -> Unit,
|
||||||
): Composite {
|
): Composite {
|
||||||
val group = SolidGroup(builder)
|
val group = SolidGroup().apply(builder)
|
||||||
val children = group.items.values.toList()
|
val children = group.items.values.toList()
|
||||||
if (children.size != 2) {
|
if (children.size != 2) {
|
||||||
error("Composite requires exactly two children, but found ${children.size}")
|
error("Composite requires exactly two children, but found ${children.size}")
|
||||||
@ -48,7 +48,7 @@ public fun SolidGroup.smartComposite(
|
|||||||
name: String? = null,
|
name: String? = null,
|
||||||
@VisionBuilder builder: SolidGroup.() -> Unit,
|
@VisionBuilder builder: SolidGroup.() -> Unit,
|
||||||
): Solid = if (type == CompositeType.GROUP) {
|
): Solid = if (type == CompositeType.GROUP) {
|
||||||
val group = SolidGroup(builder)
|
val group = SolidGroup().apply(builder)
|
||||||
if (name == null && group.properties.own == null) {
|
if (name == null && group.properties.own == null) {
|
||||||
//append directly to group if no properties are defined
|
//append directly to group if no properties are defined
|
||||||
group.items.forEach { (_, value) ->
|
group.items.forEach { (_, value) ->
|
||||||
|
@ -5,6 +5,7 @@ import kotlinx.serialization.Serializable
|
|||||||
import space.kscience.dataforge.meta.descriptors.MetaDescriptor
|
import space.kscience.dataforge.meta.descriptors.MetaDescriptor
|
||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.Name
|
||||||
import space.kscience.dataforge.names.NameToken
|
import space.kscience.dataforge.names.NameToken
|
||||||
|
import space.kscience.dataforge.names.parseAsName
|
||||||
import space.kscience.visionforge.*
|
import space.kscience.visionforge.*
|
||||||
|
|
||||||
|
|
||||||
@ -30,7 +31,8 @@ public interface PrototypeHolder {
|
|||||||
*/
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
@SerialName("group.solid")
|
@SerialName("group.solid")
|
||||||
public class SolidGroup : AbstractVisionGroup(), Solid, PrototypeHolder, MutableVisionGroup, MutableVisionContainer<Solid> {
|
public class SolidGroup : AbstractVisionGroup(), Solid, PrototypeHolder, MutableVisionGroup,
|
||||||
|
MutableVisionContainer<Solid> {
|
||||||
|
|
||||||
public val items: Map<NameToken, Solid>
|
public val items: Map<NameToken, Solid>
|
||||||
get() = children.keys.mapNotNull {
|
get() = children.keys.mapNotNull {
|
||||||
@ -79,19 +81,18 @@ public class SolidGroup : AbstractVisionGroup(), Solid, PrototypeHolder, Mutable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public inline fun SolidGroup(block: SolidGroup.() -> Unit): SolidGroup = SolidGroup().apply(block)
|
|
||||||
|
|
||||||
@VisionBuilder
|
@VisionBuilder
|
||||||
public fun MutableVisionContainer<Solid>.group(
|
public inline fun MutableVisionContainer<Solid>.solidGroup(
|
||||||
name: Name? = null,
|
name: Name? = null,
|
||||||
builder: SolidGroup.() -> Unit = {},
|
builder: SolidGroup.() -> Unit = {},
|
||||||
): SolidGroup = SolidGroup(builder).also { setChild(name, it) }
|
): SolidGroup = SolidGroup().also { setChild(name, it) }.apply(builder)
|
||||||
|
//root first, update later
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define a group with given [name], attach it to this parent and return it.
|
* Define a group with given [name], attach it to this parent and return it.
|
||||||
*/
|
*/
|
||||||
@VisionBuilder
|
@VisionBuilder
|
||||||
public fun MutableVisionContainer<Solid>.group(
|
public inline fun MutableVisionContainer<Solid>.solidGroup(
|
||||||
name: String,
|
name: String,
|
||||||
action: SolidGroup.() -> Unit = {},
|
action: SolidGroup.() -> Unit = {},
|
||||||
): SolidGroup = SolidGroup(action).also { setChild(name, it) }
|
): SolidGroup = solidGroup(name.parseAsName(), action)
|
||||||
|
@ -71,24 +71,30 @@ public class SolidReference(
|
|||||||
}
|
}
|
||||||
}.distinct().asValue()
|
}.distinct().asValue()
|
||||||
}
|
}
|
||||||
|
//1. resolve own properties
|
||||||
properties?.getValue(name)?.let { return it }
|
properties?.getValue(name)?.let { return it }
|
||||||
|
|
||||||
val descriptor = descriptor?.get(name)
|
val descriptor = descriptor?.get(name)
|
||||||
val inheritFlag = inherit ?: descriptor?.inherited ?: false
|
val inheritFlag = inherit ?: descriptor?.inherited ?: false
|
||||||
val stylesFlag = includeStyles ?: descriptor?.usesStyles ?: true
|
val stylesFlag = includeStyles ?: descriptor?.usesStyles ?: true
|
||||||
|
|
||||||
if (stylesFlag) {
|
//2. Resolve prototype onw properties
|
||||||
getStyleProperty(name)?.value?.let { return it }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inheritFlag) {
|
|
||||||
parent?.properties?.getValue(name, inherit, includeStyles)?.let { return it }
|
|
||||||
}
|
|
||||||
|
|
||||||
prototype.properties.getValue(name, inheritFlag, stylesFlag)?.let { return it }
|
prototype.properties.getValue(name, inheritFlag, stylesFlag)?.let { return it }
|
||||||
|
|
||||||
|
if (stylesFlag) {
|
||||||
|
//3. own styles
|
||||||
|
own?.getValue(Vision.STYLE_KEY)?.list?.forEach { styleName ->
|
||||||
|
getStyle(styleName.string)?.getValue(name)?.let { return it }
|
||||||
|
}
|
||||||
|
//4. prototype styles
|
||||||
|
prototype.getStyleProperty(name)?.value?.let { return it }
|
||||||
|
}
|
||||||
|
|
||||||
if(inheritFlag){
|
if(inheritFlag){
|
||||||
|
//5. own inheritance
|
||||||
parent?.properties?.getValue(name, inheritFlag, includeStyles)?.let { return it }
|
parent?.properties?.getValue(name, inheritFlag, includeStyles)?.let { return it }
|
||||||
|
//6. prototype inheritance
|
||||||
|
prototype.parent?.properties?.getValue(name, inheritFlag, includeStyles)?.let { return it }
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
|
@ -10,22 +10,34 @@ import kotlinx.serialization.serializer
|
|||||||
import space.kscience.dataforge.context.Context
|
import space.kscience.dataforge.context.Context
|
||||||
import space.kscience.dataforge.context.PluginFactory
|
import space.kscience.dataforge.context.PluginFactory
|
||||||
import space.kscience.dataforge.context.PluginTag
|
import space.kscience.dataforge.context.PluginTag
|
||||||
|
import space.kscience.dataforge.context.fetch
|
||||||
import space.kscience.dataforge.meta.Meta
|
import space.kscience.dataforge.meta.Meta
|
||||||
import space.kscience.dataforge.misc.DFExperimental
|
import space.kscience.dataforge.misc.DFExperimental
|
||||||
|
import space.kscience.dataforge.names.Name
|
||||||
import space.kscience.visionforge.*
|
import space.kscience.visionforge.*
|
||||||
import space.kscience.visionforge.html.VisionOutput
|
import space.kscience.visionforge.html.VisionOutput
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
|
||||||
public class Solids(meta: Meta) : VisionPlugin(meta) {
|
public class Solids(meta: Meta) : VisionPlugin(meta), MutableVisionContainer<Solid> {
|
||||||
override val tag: PluginTag get() = Companion.tag
|
override val tag: PluginTag get() = Companion.tag
|
||||||
|
|
||||||
override val visionSerializersModule: SerializersModule get() = serializersModuleForSolids
|
override val visionSerializersModule: SerializersModule get() = serializersModuleForSolids
|
||||||
|
|
||||||
public companion object : PluginFactory<Solids> {
|
override fun setChild(name: Name?, child: Solid?) {
|
||||||
|
child?.setAsRoot(visionManager)
|
||||||
|
}
|
||||||
|
|
||||||
|
public companion object : PluginFactory<Solids>, MutableVisionContainer<Solid> {
|
||||||
override val tag: PluginTag = PluginTag(name = "vision.solid", group = PluginTag.DATAFORGE_GROUP)
|
override val tag: PluginTag = PluginTag(name = "vision.solid", group = PluginTag.DATAFORGE_GROUP)
|
||||||
override val type: KClass<out Solids> = Solids::class
|
override val type: KClass<out Solids> = Solids::class
|
||||||
|
|
||||||
|
public val default: Solids by lazy {
|
||||||
|
Context("@Solids"){
|
||||||
|
plugin(Solids)
|
||||||
|
}.fetch(Solids)
|
||||||
|
}
|
||||||
|
|
||||||
override fun build(context: Context, meta: Meta): Solids = Solids(meta)
|
override fun build(context: Context, meta: Meta): Solids = Solids(meta)
|
||||||
|
|
||||||
private fun PolymorphicModuleBuilder<Solid>.solids() {
|
private fun PolymorphicModuleBuilder<Solid>.solids() {
|
||||||
@ -68,6 +80,10 @@ public class Solids(meta: Meta) : VisionPlugin(meta) {
|
|||||||
|
|
||||||
public fun decodeFromString(str: String): Solid =
|
public fun decodeFromString(str: String): Solid =
|
||||||
jsonForSolids.decodeFromString(PolymorphicSerializer(Solid::class), str)
|
jsonForSolids.decodeFromString(PolymorphicSerializer(Solid::class), str)
|
||||||
|
|
||||||
|
override fun setChild(name: Name?, child: Solid?) {
|
||||||
|
default.setChild(name, child)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ class CompositeTest {
|
|||||||
@Test
|
@Test
|
||||||
fun testCompositeBuilder(){
|
fun testCompositeBuilder(){
|
||||||
lateinit var composite: Composite
|
lateinit var composite: Composite
|
||||||
SolidGroup {
|
Solids.solidGroup {
|
||||||
composite = composite(CompositeType.INTERSECT) {
|
composite = composite(CompositeType.INTERSECT) {
|
||||||
y = 300
|
y = 300
|
||||||
box(100, 100, 100) {
|
box(100, 100, 100) {
|
||||||
|
@ -11,7 +11,7 @@ class ConvexTest {
|
|||||||
@Suppress("UNUSED_VARIABLE")
|
@Suppress("UNUSED_VARIABLE")
|
||||||
@Test
|
@Test
|
||||||
fun testConvexBuilder() {
|
fun testConvexBuilder() {
|
||||||
val group = SolidGroup{
|
val group = Solids.solidGroup {
|
||||||
convex {
|
convex {
|
||||||
point(50, 50, -50)
|
point(50, 50, -50)
|
||||||
point(50, -50, -50)
|
point(50, -50, -50)
|
||||||
|
@ -9,7 +9,7 @@ import kotlin.test.assertEquals
|
|||||||
class GroupTest {
|
class GroupTest {
|
||||||
@Test
|
@Test
|
||||||
fun testGroupWithComposite() {
|
fun testGroupWithComposite() {
|
||||||
val group = SolidGroup{
|
val group = Solids.solidGroup{
|
||||||
union("union") {
|
union("union") {
|
||||||
box(100, 100, 100) {
|
box(100, 100, 100) {
|
||||||
z = 100
|
z = 100
|
||||||
|
@ -41,7 +41,7 @@ class SerializationTest {
|
|||||||
x = 100
|
x = 100
|
||||||
z = -100
|
z = -100
|
||||||
}
|
}
|
||||||
val group = SolidGroup {
|
val group = Solids.solidGroup {
|
||||||
newRef("cube", cube)
|
newRef("cube", cube)
|
||||||
refGroup("pg", Name.parse("pg.content")) {
|
refGroup("pg", Name.parse("pg.content")) {
|
||||||
sphere(50) {
|
sphere(50) {
|
||||||
@ -57,7 +57,7 @@ class SerializationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun lightSerialization(){
|
fun lightSerialization(){
|
||||||
val group = SolidGroup {
|
val group = Solids.solidGroup {
|
||||||
ambientLight {
|
ambientLight {
|
||||||
color.set(Colors.white)
|
color.set(Colors.white)
|
||||||
intensity = 100.0
|
intensity = 100.0
|
||||||
|
@ -8,7 +8,7 @@ import kotlin.test.Test
|
|||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
class SolidPluginTest {
|
class SolidPluginTest {
|
||||||
val vision = SolidGroup {
|
val vision = Solids.solidGroup {
|
||||||
box(100, 100, 100, name = "aBox")
|
box(100, 100, 100, name = "aBox")
|
||||||
|
|
||||||
sphere(100, name = "aSphere") {
|
sphere(100, name = "aSphere") {
|
||||||
|
@ -52,7 +52,7 @@ class SolidPropertyTest {
|
|||||||
var box: Box? = null
|
var box: Box? = null
|
||||||
val group = SolidGroup().apply {
|
val group = SolidGroup().apply {
|
||||||
properties["test"] = 22
|
properties["test"] = 22
|
||||||
group {
|
solidGroup {
|
||||||
box = box(100, 100, 100)
|
box = box(100, 100, 100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,13 +62,13 @@ class SolidPropertyTest {
|
|||||||
@Test
|
@Test
|
||||||
fun testStyleProperty() {
|
fun testStyleProperty() {
|
||||||
var box: Box? = null
|
var box: Box? = null
|
||||||
val group = SolidGroup {
|
val group = Solids.solidGroup {
|
||||||
styleSheet {
|
styleSheet {
|
||||||
update("testStyle") {
|
update("testStyle") {
|
||||||
"test" put 22
|
"test" put 22
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
group {
|
solidGroup {
|
||||||
box = box(100, 100, 100) {
|
box = box(100, 100, 100) {
|
||||||
useStyle("testStyle")
|
useStyle("testStyle")
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ class SolidPropertyTest {
|
|||||||
SolidMaterial.MATERIAL_COLOR_KEY put "#555555"
|
SolidMaterial.MATERIAL_COLOR_KEY put "#555555"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
group {
|
solidGroup {
|
||||||
box = box(100, 100, 100) {
|
box = box(100, 100, 100) {
|
||||||
useStyle("testStyle")
|
useStyle("testStyle")
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ class SolidPropertyTest {
|
|||||||
@Test
|
@Test
|
||||||
fun testReferenceStyleProperty() {
|
fun testReferenceStyleProperty() {
|
||||||
var box: SolidReference? = null
|
var box: SolidReference? = null
|
||||||
val group = SolidGroup {
|
val group = Solids.solidGroup {
|
||||||
styleSheet {
|
styleSheet {
|
||||||
update("testStyle") {
|
update("testStyle") {
|
||||||
SolidMaterial.MATERIAL_COLOR_KEY put "#555555"
|
SolidMaterial.MATERIAL_COLOR_KEY put "#555555"
|
||||||
@ -109,7 +109,7 @@ class SolidPropertyTest {
|
|||||||
styles = listOf("testStyle")
|
styles = listOf("testStyle")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
group {
|
solidGroup {
|
||||||
box = ref("box".asName())
|
box = ref("box".asName())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import kotlin.test.assertEquals
|
|||||||
|
|
||||||
@DFExperimental
|
@DFExperimental
|
||||||
class SolidReferenceTest {
|
class SolidReferenceTest {
|
||||||
val groupWithReference = SolidGroup {
|
val groupWithReference = Solids.solidGroup {
|
||||||
val theStyle by style {
|
val theStyle by style {
|
||||||
SolidMaterial.MATERIAL_COLOR_KEY put "red"
|
SolidMaterial.MATERIAL_COLOR_KEY put "red"
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,11 @@ internal class VisionUpdateTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testVisionUpdate(){
|
fun testVisionUpdate(){
|
||||||
val targetVision = SolidGroup {
|
val targetVision = Solids.solidGroup {
|
||||||
box(200,200,200, name = "origin")
|
box(200,200,200, name = "origin")
|
||||||
}
|
}
|
||||||
val dif = visionManager.VisionChange{
|
val dif = visionManager.VisionChange{
|
||||||
group ("top") {
|
solidGroup ("top") {
|
||||||
color.set(123)
|
color.set(123)
|
||||||
box(100,100,100)
|
box(100,100,100)
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ internal class VisionUpdateTest {
|
|||||||
@Test
|
@Test
|
||||||
fun testVisionChangeSerialization(){
|
fun testVisionChangeSerialization(){
|
||||||
val change = visionManager.VisionChange{
|
val change = visionManager.VisionChange{
|
||||||
group("top") {
|
solidGroup("top") {
|
||||||
color.set(123)
|
color.set(123)
|
||||||
box(100,100,100)
|
box(100,100,100)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user