DataForge 0.7.1 and other version updates

This commit is contained in:
Alexander Nozik 2023-12-05 16:39:15 +03:00
parent fbb402de90
commit 595512959c
36 changed files with 88 additions and 88 deletions

View File

@ -7,12 +7,12 @@ plugins {
// id("org.jetbrains.kotlinx.kover") version "0.5.0"
}
val dataforgeVersion by extra("0.6.2")
val dataforgeVersion by extra("0.7.1")
val fxVersion by extra("11")
allprojects {
group = "space.kscience"
version = "0.3.0-dev-16"
version = "0.3.0-dev-17"
}
subprojects {

View File

@ -34,6 +34,6 @@ class GDMLVisionTest {
val child = cubes[Name.of("composite-000","segment-0")]
assertNotNull(child)
child.properties.setValue(SolidMaterial.MATERIAL_COLOR_KEY, "red".asValue())
assertEquals("red", child.properties.getMeta(SolidMaterial.MATERIAL_COLOR_KEY).string)
assertEquals("red", child.properties[SolidMaterial.MATERIAL_COLOR_KEY].string)
}
}

View File

@ -71,7 +71,7 @@ class Model(val manager: VisionManager) {
fun reset() {
map.values.forEach {
it.properties.setMeta(SolidMaterial.MATERIAL_COLOR_KEY, null)
it.properties[SolidMaterial.MATERIAL_COLOR_KEY] = null
}
tracks.children.clear()
}

View File

@ -8,6 +8,6 @@ org.gradle.jvmargs=-Xmx4G
org.jetbrains.compose.experimental.jscanvas.enabled=true
toolsVersion=0.15.0-kotlin-1.9.20
toolsVersion=0.15.2-kotlin-1.9.21
#kotlin.experimental.tryK2=true
#kscience.wasm.disabled=true

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -29,7 +29,7 @@ public fun RBuilder.visionPropertyEditor(
this.descriptor = descriptor
this.scope = vision.manager?.context ?: error("Orphan vision could not be observed")
this.getPropertyState = { name ->
val ownMeta = vision.properties.own?.getMeta(name)
val ownMeta = vision.properties.own?.get(name)
if (ownMeta != null && !ownMeta.isEmpty()) {
EditorPropertyState.Defined
} else if (vision.properties.root().getValue(name) != null) {

View File

@ -1,7 +1,8 @@
plugins {
id("space.kscience.gradle.mpp")
id("org.jetbrains.compose") version "1.5.10"
alias(spclibs.plugins.compose)
// id("org.jetbrains.compose") version "1.5.11"
// id("com.android.library")
}

View File

@ -17,9 +17,8 @@ import org.jetbrains.compose.web.dom.Text
import space.kscience.dataforge.meta.MutableMeta
import space.kscience.dataforge.meta.ObservableMutableMeta
import space.kscience.dataforge.meta.descriptors.MetaDescriptor
import space.kscience.dataforge.meta.descriptors.ValueRequirement
import space.kscience.dataforge.meta.descriptors.ValueRestriction
import space.kscience.dataforge.meta.descriptors.get
import space.kscience.dataforge.meta.get
import space.kscience.dataforge.meta.remove
import space.kscience.dataforge.names.*
import space.kscience.visionforge.hidden
@ -104,7 +103,7 @@ public fun PropertyEditor(
Text(token)
}
if (!name.isEmpty() && descriptor?.valueRequirement != ValueRequirement.ABSENT) {
if (!name.isEmpty() && descriptor?.valueRestriction != ValueRestriction.ABSENT) {
Div({
style {
width(160.px)

View File

@ -16,7 +16,7 @@ import org.w3c.dom.HTMLOptionElement
import org.w3c.dom.asList
import space.kscience.dataforge.meta.*
import space.kscience.dataforge.meta.descriptors.MetaDescriptor
import space.kscience.dataforge.meta.descriptors.ValueRequirement
import space.kscience.dataforge.meta.descriptors.ValueRestriction
import space.kscience.dataforge.meta.descriptors.allowedValues
import space.kscience.visionforge.Colors
import space.kscience.visionforge.widgetType
@ -199,7 +199,7 @@ public fun RangeValueChooser(
FlexRow {
if (descriptor?.valueRequirement != ValueRequirement.REQUIRED) {
if (descriptor?.valueRestriction != ValueRestriction.REQUIRED) {
Input(type = InputType.Checkbox) {
if (!rangeDisabled) defaultChecked()

View File

@ -16,9 +16,8 @@ import react.dom.attrs
import space.kscience.dataforge.meta.MutableMeta
import space.kscience.dataforge.meta.ObservableMutableMeta
import space.kscience.dataforge.meta.descriptors.MetaDescriptor
import space.kscience.dataforge.meta.descriptors.ValueRequirement
import space.kscience.dataforge.meta.descriptors.ValueRestriction
import space.kscience.dataforge.meta.descriptors.get
import space.kscience.dataforge.meta.get
import space.kscience.dataforge.meta.remove
import space.kscience.dataforge.names.*
import space.kscience.visionforge.hidden
@ -146,7 +145,7 @@ private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) {
}
+token
}
if (!props.name.isEmpty() && descriptor?.valueRequirement != ValueRequirement.ABSENT) {
if (!props.name.isEmpty() && descriptor?.valueRestriction != ValueRestriction.ABSENT) {
styledDiv {
css {
//+TreeStyles.resizeableInput
@ -185,7 +184,7 @@ private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) {
}
+"\u00D7"
attrs {
if (editorPropertyState!= EditorPropertyState.Defined) {
if (editorPropertyState != EditorPropertyState.Defined) {
disabled = true
} else {
onClickFunction = removeClick

View File

@ -12,7 +12,7 @@ import react.dom.attrs
import react.fc
import react.useState
import space.kscience.dataforge.meta.asValue
import space.kscience.dataforge.meta.descriptors.ValueRequirement
import space.kscience.dataforge.meta.descriptors.ValueRestriction
import space.kscience.dataforge.meta.double
import space.kscience.dataforge.meta.get
import space.kscience.dataforge.meta.string
@ -43,7 +43,7 @@ public val RangeValueChooser: FC<ValueChooserProps> = fc("RangeValueChooser") {
}
flexRow {
if (props.descriptor?.valueRequirement != ValueRequirement.REQUIRED) {
if (props.descriptor?.valueRestriction != ValueRestriction.REQUIRED) {
styledInput(type = InputType.checkBox) {
attrs {
defaultChecked = rangeDisabled.not()

View File

@ -13,7 +13,7 @@ import kotlin.jvm.JvmInline
@JvmInline
public value class StyleSheet(private val owner: Vision) {
private val styleNode: Meta get() = owner.properties.getMeta(STYLESHEET_KEY)
private val styleNode: Meta get() = owner.properties[STYLESHEET_KEY]
public val items: Map<NameToken, Meta> get() = styleNode.items
@ -23,7 +23,7 @@ public value class StyleSheet(private val owner: Vision) {
* Define a style without notifying owner
*/
public fun define(key: String, style: Meta?) {
owner.properties.setMeta(STYLESHEET_KEY + key, style)
owner.properties[STYLESHEET_KEY + key] = style
}
/**
@ -92,7 +92,7 @@ public fun Vision.useStyle(name: String, notify: Boolean = true) {
* Resolve a style with given name for given [Vision]. The style is not necessarily applied to this [Vision].
*/
public fun Vision.getStyle(name: String): Meta? =
properties.own?.getMeta(StyleSheet.STYLESHEET_KEY + name) ?: parent?.getStyle(name)
properties.own?.get(StyleSheet.STYLESHEET_KEY + name) ?: parent?.getStyle(name)
/**
* Resolve a property from all styles

View File

@ -10,7 +10,7 @@ import space.kscience.dataforge.meta.asValue
import space.kscience.dataforge.meta.boolean
import space.kscience.dataforge.meta.descriptors.Described
import space.kscience.dataforge.meta.descriptors.MetaDescriptor
import space.kscience.dataforge.misc.Type
import space.kscience.dataforge.misc.DfType
import space.kscience.dataforge.names.Name
import space.kscience.dataforge.names.asName
import space.kscience.visionforge.AbstractVisionGroup.Companion.updateProperties
@ -19,7 +19,7 @@ import space.kscience.visionforge.Vision.Companion.TYPE
/**
* A root type for display hierarchy
*/
@Type(TYPE)
@DfType(TYPE)
public interface Vision : Described {
/**

View File

@ -34,13 +34,13 @@ public interface VisionProperties : MetaProvider {
* @param inherit toggles parent node property lookup. Null means inference from descriptor.
* @param includeStyles toggles inclusion of properties from styles.
*/
public fun getMeta(
public fun get(
name: Name,
inherit: Boolean?,
includeStyles: Boolean? = null,
): Meta
override fun getMeta(name: Name): Meta? = getMeta(name, null, null)
override fun get(name: Name): Meta? = get(name, null, null)
public val changes: Flow<Name>
@ -54,7 +54,7 @@ public interface VisionProperties : MetaProvider {
public interface MutableVisionProperties : VisionProperties, MutableMetaProvider {
override fun getMeta(
override fun get(
name: Name,
inherit: Boolean?,
includeStyles: Boolean?,
@ -65,7 +65,7 @@ public interface MutableVisionProperties : VisionProperties, MutableMetaProvider
includeStyles,
)
public fun setMeta(
public fun set(
name: Name,
node: Meta?,
notify: Boolean,
@ -77,10 +77,10 @@ public interface MutableVisionProperties : VisionProperties, MutableMetaProvider
notify: Boolean,
)
override fun getMeta(name: Name): MutableMeta = getMeta(name, null, null)
override fun get(name: Name): MutableMeta = get(name, null, null)
override fun setMeta(name: Name, node: Meta?) {
setMeta(name, node, true)
override fun set(name: Name, node: Meta?) {
set(name, node, true)
}
override fun setValue(name: Name, value: Value?) {
@ -89,7 +89,7 @@ public interface MutableVisionProperties : VisionProperties, MutableMetaProvider
}
public fun MutableVisionProperties.remove(name: Name) {
setMeta(name, null)
set(name, null)
}
public fun MutableVisionProperties.remove(name: String) {
@ -114,7 +114,7 @@ private class VisionPropertiesItem(
override val items: Map<NameToken, MutableMeta>
get() {
val metaKeys = properties.own?.getMeta(nodeName)?.items?.keys ?: emptySet()
val metaKeys = properties.own?.get(nodeName)?.items?.keys ?: emptySet()
val descriptorKeys = descriptor?.children?.map { NameToken(it.key) } ?: emptySet()
val defaultKeys = default?.get(nodeName)?.items?.keys ?: emptySet()
val inheritFlag = descriptor?.inherited ?: inherit
@ -148,8 +148,8 @@ private class VisionPropertiesItem(
default
)
override fun setMeta(name: Name, node: Meta?) {
properties.setMeta(nodeName + name, node)
override fun set(name: Name, node: Meta?) {
properties[nodeName + name] = node
}
override fun toString(): String = Meta.toString(this)
@ -202,16 +202,16 @@ public abstract class AbstractVisionProperties(
return descriptor?.defaultValue
}
override fun setMeta(name: Name, node: Meta?, notify: Boolean) {
override fun set(name: Name, node: Meta?, notify: Boolean) {
//ignore if the value is the same as existing
if (own?.getMeta(name) == node) return
if (own?.get(name) == node) return
if (name.isEmpty()) {
properties = node?.asMutableMeta()
} else if (node == null) {
properties?.setMeta(name, node)
properties?.set(name, node)
} else {
getOrCreateProperties().setMeta(name, node)
getOrCreateProperties()[name] = node
}
if (notify) {
invalidate(name)
@ -223,7 +223,7 @@ public abstract class AbstractVisionProperties(
if (own?.getValue(name) == value) return
if (value == null) {
properties?.getMeta(name)?.value = null
properties?.get(name)?.value = null
} else {
getOrCreateProperties().setValue(name, value)
}
@ -272,11 +272,11 @@ public fun VisionProperties.getValue(
/**
* Get [Vision] property using key as a String
*/
public fun VisionProperties.getMeta(
public fun VisionProperties.get(
name: String,
inherit: Boolean? = null,
includeStyles: Boolean? = null,
): Meta = getMeta(name.parseAsName(), inherit, includeStyles)
): Meta = get(name.parseAsName(), inherit, includeStyles)
/**
* The root property node with given inheritance and style flags
@ -286,17 +286,17 @@ public fun VisionProperties.getMeta(
public fun MutableVisionProperties.root(
inherit: Boolean? = null,
includeStyles: Boolean? = null,
): MutableMeta = getMeta(Name.EMPTY, inherit, includeStyles)
): MutableMeta = get(Name.EMPTY, inherit, includeStyles)
/**
* Get [Vision] property using key as a String
*/
public fun MutableVisionProperties.getMeta(
public fun MutableVisionProperties.get(
name: String,
inherit: Boolean? = null,
includeStyles: Boolean? = null,
): MutableMeta = getMeta(name.parseAsName(), inherit, includeStyles)
): MutableMeta = get(name.parseAsName(), inherit, includeStyles)
//
//public operator fun MutableVisionProperties.set(name: Name, value: Number): Unit =

View File

@ -17,10 +17,10 @@ public fun Vision.flowProperty(
includeStyles: Boolean? = null,
): Flow<Meta> = flow {
//Pass initial value.
emit(properties.getMeta(propertyName, inherit, includeStyles))
emit(properties.get(propertyName, inherit, includeStyles))
properties.changes.collect { name ->
if (name.startsWith(propertyName)) {
emit(properties.getMeta(propertyName, inherit, includeStyles))
emit(properties.get(propertyName, inherit, includeStyles))
}
}
}

View File

@ -23,10 +23,10 @@ public fun Vision.useProperty(
callback: (Meta) -> Unit,
): Job {
//Pass initial value.
callback(properties.getMeta(propertyName, inherit, includeStyles))
callback(properties.get(propertyName, inherit, includeStyles))
return properties.changes.onEach { name ->
if (name.startsWith(propertyName)) {
callback(properties.getMeta(propertyName, inherit, includeStyles))
callback(properties.get(propertyName, inherit, includeStyles))
}
}.launchIn(scope ?: error("Orphan Vision can't observe properties"))
}

View File

@ -40,7 +40,7 @@ internal class VisionPropertyTest {
@Test
fun testPropertyEdit() {
val vision = manager.group()
vision.properties.getMeta("fff.ddd").apply {
vision.properties.get("fff.ddd").apply {
value = 2.asValue()
}
assertEquals(2, vision.properties.getValue("fff.ddd")?.int)
@ -50,7 +50,7 @@ internal class VisionPropertyTest {
@Test
fun testPropertyUpdate() {
val vision = manager.group()
vision.properties.getMeta("fff").updateWith(TestScheme) {
vision.properties.get("fff").updateWith(TestScheme) {
ddd = 2
}
assertEquals(2, vision.properties.getValue("fff.ddd")?.int)
@ -85,7 +85,7 @@ internal class VisionPropertyTest {
child.properties.remove("test")
assertEquals(11, child.properties.getMeta("test", inherit = true).int)
assertEquals(11, child.properties.get("test", inherit = true).int)
// assertEquals(11, deferred.await()?.int)
// assertEquals(2, callCounter)
subscription.cancel()

View File

@ -9,8 +9,8 @@ import kotlinx.serialization.serializerOrNull
import org.w3c.dom.Element
import org.w3c.dom.HTMLElement
import space.kscience.dataforge.meta.Meta
import space.kscience.dataforge.misc.DfType
import space.kscience.dataforge.misc.Named
import space.kscience.dataforge.misc.Type
import space.kscience.dataforge.names.Name
import space.kscience.dataforge.names.asName
import space.kscience.dataforge.names.parseAsName
@ -20,7 +20,7 @@ import kotlin.reflect.cast
/**
* A browser renderer for a [Vision].
*/
@Type(ElementVisionRenderer.TYPE)
@DfType(ElementVisionRenderer.TYPE)
public interface ElementVisionRenderer : Named {
/**

View File

@ -161,7 +161,7 @@ public class JsVisionClient : AbstractPlugin(), VisionClient {
//launch backward property propagation
vision.properties.changes.onEach { propertyName: Name ->
changeCollector.propertyChanged(visionName, propertyName, vision.properties.getMeta(propertyName))
changeCollector.propertyChanged(visionName, propertyName, vision.properties[propertyName])
}.launchIn(this)
//aggregate atomic changes

View File

@ -2,7 +2,7 @@ plugins {
id("space.kscience.gradle.mpp")
}
val plotlyVersion = "0.6.0"
val plotlyVersion = "0.6.1"
kscience {
jvm()

View File

@ -33,8 +33,8 @@ public class VisionOfPlotly private constructor(
@Transient
override val properties: MutableVisionProperties = object : MutableVisionProperties {
override fun setMeta(name: Name, node: Meta?, notify: Boolean) {
meta.setMeta(name, node)
override fun set(name: Name, node: Meta?, notify: Boolean) {
meta[name] = node
}
override fun setValue(name: Name, value: Value?, notify: Boolean) {
@ -45,11 +45,11 @@ public class VisionOfPlotly private constructor(
override val descriptor: MetaDescriptor? get() = this@VisionOfPlotly.descriptor
override fun getMeta(
override fun get(
name: Name,
inherit: Boolean?,
includeStyles: Boolean?,
): MutableMeta = meta.getMeta(name) ?: MutableMeta()
): MutableMeta = meta[name] ?: MutableMeta()
override fun getValue(
name: Name,

View File

@ -32,7 +32,7 @@ import kotlin.time.Duration.Companion.milliseconds
public class VisionRoute(
public val route: String,
public val visionManager: VisionManager,
override val meta: ObservableMutableMeta = MutableMeta(),
override val meta: ObservableMutableMeta = ObservableMutableMeta(),
) : Configurable, ContextAware {
public enum class Mode {

View File

@ -39,7 +39,7 @@ public inline fun MutableVisionContainer<Solid>.composite(
}
val res = Composite(type, children[0], children[1])
res.properties.setMeta(Name.EMPTY, group.properties.own)
res.properties[Name.EMPTY] = group.properties.own
setChild(name, res)
return res

View File

@ -92,7 +92,7 @@ public class Extruded(
}
internal fun build(): Extruded = Extruded(shape, layers).apply {
this.properties.setMeta(Name.EMPTY, this@Builder.properties)
this.properties[Name.EMPTY] = this@Builder.properties
}
}

View File

@ -190,7 +190,7 @@ internal fun float32Vector(
override fun setValue(thisRef: Solid, property: KProperty<*>, value: Float32Vector3D?) {
if (value == null) {
thisRef.properties.setMeta(name, null)
thisRef.properties[name] = null
} else {
thisRef.properties[name + X_KEY] = value.x
thisRef.properties[name + Y_KEY] = value.y

View File

@ -110,12 +110,12 @@ public val Solid.color: ColorAccessor
get() = ColorAccessor(properties.root(true), MATERIAL_COLOR_KEY)
public var Solid.material: SolidMaterial?
get() = SolidMaterial.read(properties.getMeta(MATERIAL_KEY))
set(value) = properties.setMeta(MATERIAL_KEY, value?.meta)
get() = SolidMaterial.read(properties[MATERIAL_KEY])
set(value) = properties.set(MATERIAL_KEY, value?.meta)
@VisionBuilder
public fun Solid.material(builder: SolidMaterial.() -> Unit) {
properties.getMeta(MATERIAL_KEY).updateWith(SolidMaterial, builder)
properties[MATERIAL_KEY].updateWith(SolidMaterial, builder)
}
public var Solid.opacity: Number?
@ -128,5 +128,5 @@ public var Solid.opacity: Number?
@VisionBuilder
public fun Solid.edges(enabled: Boolean = true, block: SolidMaterial.() -> Unit = {}) {
properties[SolidMaterial.EDGES_ENABLED_KEY] = enabled
SolidMaterial.write(properties.getMeta(SolidMaterial.EDGES_MATERIAL_KEY)).apply(block)
SolidMaterial.write(properties[SolidMaterial.EDGES_MATERIAL_KEY]).apply(block)
}

View File

@ -162,7 +162,7 @@ internal class SolidReferenceChild(
override val properties: MutableVisionProperties = object : MutableVisionProperties {
override val descriptor: MetaDescriptor get() = this@SolidReferenceChild.descriptor
override val own: MutableMeta by lazy { owner.properties.getMeta(childToken(childName).asName()) }
override val own: MutableMeta by lazy { owner.properties[childToken(childName).asName()] }
override fun getValue(
name: Name,
@ -170,8 +170,8 @@ internal class SolidReferenceChild(
includeStyles: Boolean?,
): Value? = own.getValue(name) ?: prototype.properties.getValue(name, inherit, includeStyles)
override fun setMeta(name: Name, node: Meta?, notify: Boolean) {
own.setMeta(name, node)
override fun set(name: Name, node: Meta?, notify: Boolean) {
own[name] = node
}
override fun setValue(name: Name, value: Value?, notify: Boolean) {

View File

@ -155,7 +155,7 @@ public class Surface(
}
internal fun build(): Surface = Surface(layers).apply {
properties.setMeta(Name.EMPTY, this@Builder.properties)
properties[Name.EMPTY] = this@Builder.properties
}
}

View File

@ -36,9 +36,9 @@ internal fun Meta.toVector2D(): Float32Vector2D =
//}
internal fun MetaProvider.point3D(default: Float = 0f) = Float32Euclidean3DSpace.vector(
getMeta(X_KEY).float ?: default,
getMeta(Y_KEY).float ?: default,
getMeta(Z_KEY).float ?: default
get(X_KEY).float ?: default,
get(Y_KEY).float ?: default,
get(Z_KEY).float ?: default
)

View File

@ -19,7 +19,7 @@ internal fun Solid.updateFrom(other: Solid): Solid {
scaleX *= other.scaleX
scaleY *= other.scaleY
scaleZ *= other.scaleZ
properties.setMeta(Name.EMPTY, other.properties.root())
properties[Name.EMPTY] = other.properties.root()
return this
}

View File

@ -2,7 +2,7 @@ plugins {
id("space.kscience.gradle.mpp")
}
val tablesVersion = "0.2.1"
val tablesVersion = "0.3.0"
kscience {
jvm()

View File

@ -6,6 +6,7 @@ import space.kscience.dataforge.meta.double
import space.kscience.dataforge.meta.int
import space.kscience.tables.ColumnHeader
import space.kscience.tables.ColumnTable
import space.kscience.tables.fill
import space.kscience.tables.get
import kotlin.math.pow
import kotlin.test.Test
@ -18,7 +19,7 @@ internal class VisionOfTableTest {
val y by ColumnHeader.typed<Value>()
val table = ColumnTable<Value>(100) {
x.fill { it.asValue() }
fill(x, null) { it.asValue() }
y.values = x.values.map { it?.double?.pow(2)?.asValue() }
}

View File

@ -1,6 +1,6 @@
package space.kscience.visionforge.solid.three
import space.kscience.dataforge.misc.Type
import space.kscience.dataforge.misc.DfType
import space.kscience.dataforge.names.Name
import space.kscience.dataforge.names.startsWith
import space.kscience.visionforge.Vision
@ -17,7 +17,7 @@ import kotlin.reflect.KClass
/**
* Builder and updater for three.js object
*/
@Type(TYPE)
@DfType(TYPE)
public interface ThreeFactory<in T : Vision> {
public val type: KClass<in T>

View File

@ -24,7 +24,7 @@ public object ThreeLineFactory : ThreeFactory<PolyLine> {
}
val material = ThreeMaterials.getLineMaterial(
vision.properties.getMeta(SolidMaterial.MATERIAL_KEY),
vision.properties[SolidMaterial.MATERIAL_KEY],
false
)

View File

@ -83,7 +83,7 @@ public object ThreeMaterials {
private val visionMaterialCache = HashMap<Vision, Material>()
internal fun cacheMaterial(vision: Vision): Material = visionMaterialCache.getOrPut(vision) {
buildMaterial(vision.properties.getMeta(SolidMaterial.MATERIAL_KEY)).apply {
buildMaterial(vision.properties[SolidMaterial.MATERIAL_KEY]).apply {
cached = true
}
}
@ -133,11 +133,11 @@ public fun Mesh.setMaterial(vision: Vision) {
} else {
material = vision.parent?.let { parent ->
//TODO cache parent material
ThreeMaterials.buildMaterial(parent.properties.getMeta(SolidMaterial.MATERIAL_KEY))
ThreeMaterials.buildMaterial(parent.properties[SolidMaterial.MATERIAL_KEY])
} ?: ThreeMaterials.cacheMaterial(vision)
}
} else {
material = ThreeMaterials.buildMaterial(vision.properties.getMeta(SolidMaterial.MATERIAL_KEY))
material = ThreeMaterials.buildMaterial(vision.properties[SolidMaterial.MATERIAL_KEY])
}
}
@ -153,18 +153,18 @@ public fun Mesh.updateMaterialProperty(vision: Vision, propertyName: Name) {
when (propertyName) {
SolidMaterial.MATERIAL_COLOR_KEY -> {
material.asDynamic().color =
vision.properties.getMeta(SolidMaterial.MATERIAL_COLOR_KEY).threeColor()
vision.properties[SolidMaterial.MATERIAL_COLOR_KEY].threeColor()
?: ThreeMaterials.DEFAULT_COLOR
}
SolidMaterial.SPECULAR_COLOR_KEY -> {
material.asDynamic().specular =
vision.properties.getMeta(SolidMaterial.SPECULAR_COLOR_KEY).threeColor()
vision.properties[SolidMaterial.SPECULAR_COLOR_KEY].threeColor()
?: ThreeMaterials.DEFAULT_COLOR
}
SolidMaterial.MATERIAL_EMISSIVE_COLOR_KEY -> {
material.asDynamic().emissive = vision.properties.getMeta(SolidMaterial.MATERIAL_EMISSIVE_COLOR_KEY)
material.asDynamic().emissive = vision.properties[SolidMaterial.MATERIAL_EMISSIVE_COLOR_KEY]
.threeColor()
?: ThreeMaterials.BLACK_COLOR
}

View File

@ -76,7 +76,7 @@ public fun Mesh.applyEdges(vision: Solid) {
val edges = children.find { it.name == EDGES_OBJECT_NAME } as? LineSegments
//inherited edges definition, enabled by default
if (vision.properties.getValue(EDGES_ENABLED_KEY, inherit = false)?.boolean != false) {
val material = ThreeMaterials.getLineMaterial(vision.properties.getMeta(EDGES_MATERIAL_KEY), true)
val material = ThreeMaterials.getLineMaterial(vision.properties[EDGES_MATERIAL_KEY], true)
if (edges == null) {
add(
LineSegments(