Migrate to DF 0.3
This commit is contained in:
parent
25a47a9719
commit
2b02f151d2
@ -52,7 +52,6 @@ class Model {
|
||||
detector(it)
|
||||
}
|
||||
}
|
||||
|
||||
tracks = group("tracks")
|
||||
}
|
||||
|
||||
|
@ -147,8 +147,7 @@ fun Page<Solid>.showcaseCSG() {
|
||||
detail = 32
|
||||
}
|
||||
material {
|
||||
color(Colors.red)
|
||||
wireframe = false
|
||||
color(Colors.pink)
|
||||
}
|
||||
}
|
||||
composite(CompositeType.UNION) {
|
||||
@ -158,8 +157,8 @@ fun Page<Solid>.showcaseCSG() {
|
||||
sphere(50){
|
||||
detail = 32
|
||||
}
|
||||
color(Colors.lightgreen)
|
||||
opacity = 0.5
|
||||
color("lightgreen")
|
||||
opacity = 0.7
|
||||
}
|
||||
composite(CompositeType.SUBTRACT) {
|
||||
y = -300
|
||||
@ -169,7 +168,7 @@ fun Page<Solid>.showcaseCSG() {
|
||||
sphere(50){
|
||||
detail = 32
|
||||
}
|
||||
color(Colors.teal)
|
||||
color("teal")
|
||||
opacity = 0.7
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.css.th
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.Transient
|
||||
@ -27,18 +28,28 @@ internal data class PropertyListener(
|
||||
)
|
||||
|
||||
|
||||
/**
|
||||
* A full base implementation for a [Vision]
|
||||
* @param properties Object own properties excluding styles and inheritance
|
||||
*/
|
||||
@Serializable
|
||||
@SerialName("vision")
|
||||
public open class VisionBase : Vision {
|
||||
public open class VisionBase(internal var properties: Config? = null) : Vision {
|
||||
|
||||
init {
|
||||
//used during deserialization only
|
||||
properties?.onChange(this) { name, oldItem, newItem ->
|
||||
if (oldItem != newItem) {
|
||||
scope.launch {
|
||||
notifyPropertyChanged(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transient
|
||||
override var parent: VisionGroup? = null
|
||||
|
||||
/**
|
||||
* Object own properties excluding styles and inheritance
|
||||
*/
|
||||
internal var properties: Config? = null
|
||||
|
||||
override val meta: Meta get() = properties ?: Meta.EMPTY
|
||||
|
||||
@Synchronized
|
||||
|
@ -101,6 +101,7 @@ internal class Prototypes(
|
||||
) : VisionGroupBase(children as? MutableMap<NameToken, Vision> ?: children.toMutableMap()), PrototypeHolder {
|
||||
|
||||
init {
|
||||
//used during deserialization only
|
||||
children.values.forEach {
|
||||
it.parent = parent
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ public class SolidMaterial : Scheme() {
|
||||
/**
|
||||
* Primary web-color for the material
|
||||
*/
|
||||
public var color: ColorAccessor = ColorAccessor(items, COLOR_KEY)
|
||||
public var color: ColorAccessor = ColorAccessor(this, COLOR_KEY)
|
||||
|
||||
/**
|
||||
* Specular color for phong material
|
||||
*/
|
||||
public var specularColor: ColorAccessor = ColorAccessor(items, SPECULAR_COLOR_KEY)
|
||||
public var specularColor: ColorAccessor = ColorAccessor(this, SPECULAR_COLOR_KEY)
|
||||
|
||||
/**
|
||||
* Opacity
|
||||
@ -104,13 +104,7 @@ public var Solid.material: SolidMaterial?
|
||||
|
||||
@VisionBuilder
|
||||
public fun Solid.material(builder: SolidMaterial.() -> Unit) {
|
||||
setProperty(MATERIAL_KEY, SolidMaterial(builder))
|
||||
// val node = getOwnProperty(MATERIAL_KEY).node
|
||||
// if (node != null) {
|
||||
// configure(SolidMaterial(builder).config)
|
||||
// } else {
|
||||
// setProperty(MATERIAL_KEY, SolidMaterial(builder))
|
||||
// }
|
||||
ownProperties.getChild(MATERIAL_KEY).update(SolidMaterial, builder)
|
||||
}
|
||||
|
||||
public var Solid.opacity: Number?
|
||||
|
@ -4,9 +4,9 @@ import hep.dataforge.meta.*
|
||||
import hep.dataforge.names.Name
|
||||
|
||||
public class Canvas3DOptions : Scheme() {
|
||||
public var axes: Axes by spec(Axes, Axes.empty())
|
||||
public var camera: Camera by spec(Camera, Camera.empty())
|
||||
public var controls: Controls by spec(Controls, Controls.empty())
|
||||
public var axes: Axes by spec(Axes)
|
||||
public var camera: Camera by spec(Camera)
|
||||
public var controls: Controls by spec(Controls)
|
||||
|
||||
public var minSize: Int by int(400)
|
||||
public var minWith: Number by number { minSize }
|
||||
|
@ -0,0 +1,29 @@
|
||||
package hep.dataforge.vision.solid
|
||||
|
||||
import hep.dataforge.vision.Colors
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class CompositeTest {
|
||||
|
||||
@Test
|
||||
fun testCompositeBuilder(){
|
||||
lateinit var composite: Composite
|
||||
SolidGroup {
|
||||
composite = composite(CompositeType.INTERSECT) {
|
||||
y = 300
|
||||
box(100, 100, 100) {
|
||||
z = 50
|
||||
}
|
||||
sphere(50) {
|
||||
detail = 32
|
||||
}
|
||||
material {
|
||||
color("pink")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals("pink", composite.color.string)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user