forked from kscience/visionforge
Fix color resolution
This commit is contained in:
parent
a33d9d1946
commit
f99a359e24
@ -1,9 +1,9 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.gradle.project")
|
id("ru.mipt.npm.gradle.project")
|
||||||
kotlin("multiplatform") version "1.5.30-RC" apply false
|
// kotlin("multiplatform") version "1.5.30-RC" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
val dataforgeVersion by extra("0.5.0")
|
val dataforgeVersion by extra("0.5.1")
|
||||||
val fxVersion by extra("11")
|
val fxVersion by extra("11")
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
@ -20,7 +20,7 @@ kotlin {
|
|||||||
this.outputFileName = "js/visionforge-playground.js"
|
this.outputFileName = "js/visionforge-playground.js"
|
||||||
}
|
}
|
||||||
commonWebpackConfig {
|
commonWebpackConfig {
|
||||||
sourceMaps = false
|
sourceMaps = true
|
||||||
cssSupport.enabled = false
|
cssSupport.enabled = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ kotlin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
val jsBrowserDistribution by tasks.getting
|
val jsBrowserDistribution = tasks.getByName("jsBrowserDevelopmentExecutableDistribution")
|
||||||
|
|
||||||
tasks.getByName<ProcessResources>("jvmProcessResources") {
|
tasks.getByName<ProcessResources>("jvmProcessResources") {
|
||||||
dependsOn(jsBrowserDistribution)
|
dependsOn(jsBrowserDistribution)
|
||||||
|
@ -17,7 +17,7 @@ fun main() {
|
|||||||
|
|
||||||
context.makeVisionFile(
|
context.makeVisionFile(
|
||||||
Paths.get("randomSpheres.html"),
|
Paths.get("randomSpheres.html"),
|
||||||
resourceLocation = ResourceLocation.EMBED
|
resourceLocation = ResourceLocation.SYSTEM
|
||||||
) {
|
) {
|
||||||
h1 { +"Happy new year!" }
|
h1 { +"Happy new year!" }
|
||||||
div {
|
div {
|
||||||
|
@ -2,16 +2,15 @@ package space.kscience.visionforge.solid
|
|||||||
|
|
||||||
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.dataforge.values.MutableValueProvider
|
import space.kscience.dataforge.values.*
|
||||||
import space.kscience.dataforge.values.Value
|
|
||||||
import space.kscience.dataforge.values.asValue
|
|
||||||
import space.kscience.dataforge.values.string
|
|
||||||
import space.kscience.visionforge.Colors
|
import space.kscience.visionforge.Colors
|
||||||
import space.kscience.visionforge.VisionBuilder
|
import space.kscience.visionforge.VisionBuilder
|
||||||
|
|
||||||
@VisionBuilder
|
@VisionBuilder
|
||||||
public class ColorAccessor(private val provider: MutableValueProvider, private val colorKey: Name) :
|
public class ColorAccessor(
|
||||||
MutableValueProvider {
|
private val provider: MutableValueProvider,
|
||||||
|
private val colorKey: Name
|
||||||
|
) : MutableValueProvider {
|
||||||
public var value: Value?
|
public var value: Value?
|
||||||
get() = provider.getValue(colorKey)
|
get() = provider.getValue(colorKey)
|
||||||
set(value) {
|
set(value) {
|
||||||
@ -26,7 +25,7 @@ public class ColorAccessor(private val provider: MutableValueProvider, private v
|
|||||||
}
|
}
|
||||||
|
|
||||||
public var ColorAccessor?.string: String?
|
public var ColorAccessor?.string: String?
|
||||||
get() = this?.value?.string
|
get() = this?.value?.let { if(it == Null) null else it.string }
|
||||||
set(value) {
|
set(value) {
|
||||||
this?.value = value?.asValue()
|
this?.value = value?.asValue()
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import kotlinx.serialization.Serializable
|
|||||||
import space.kscience.dataforge.meta.MutableMeta
|
import space.kscience.dataforge.meta.MutableMeta
|
||||||
import space.kscience.dataforge.meta.descriptors.MetaDescriptor
|
import space.kscience.dataforge.meta.descriptors.MetaDescriptor
|
||||||
import space.kscience.visionforge.VisionBase
|
import space.kscience.visionforge.VisionBase
|
||||||
import space.kscience.visionforge.VisionChange
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@SerialName("solid")
|
@SerialName("solid")
|
||||||
@ -14,9 +13,4 @@ public open class SolidBase : VisionBase(), Solid {
|
|||||||
override var properties: MutableMeta? = null
|
override var properties: MutableMeta? = null
|
||||||
|
|
||||||
override val descriptor: MetaDescriptor get() = Solid.descriptor
|
override val descriptor: MetaDescriptor get() = Solid.descriptor
|
||||||
|
|
||||||
override fun update(change: VisionChange) {
|
|
||||||
updatePosition(change.properties)
|
|
||||||
super.update(change)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,7 @@ import info.laht.threekt.materials.Material
|
|||||||
import info.laht.threekt.materials.MeshBasicMaterial
|
import info.laht.threekt.materials.MeshBasicMaterial
|
||||||
import info.laht.threekt.math.Color
|
import info.laht.threekt.math.Color
|
||||||
import info.laht.threekt.objects.Mesh
|
import info.laht.threekt.objects.Mesh
|
||||||
import space.kscience.dataforge.meta.Meta
|
import space.kscience.dataforge.meta.*
|
||||||
import space.kscience.dataforge.meta.boolean
|
|
||||||
import space.kscience.dataforge.meta.double
|
|
||||||
import space.kscience.dataforge.meta.get
|
|
||||||
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.values.*
|
import space.kscience.dataforge.values.*
|
||||||
@ -100,18 +97,23 @@ public object ThreeMaterials {
|
|||||||
/**
|
/**
|
||||||
* Compute color
|
* Compute color
|
||||||
*/
|
*/
|
||||||
public fun Meta.threeColor(): Color = getValue(Name.EMPTY)?.let { value ->
|
public fun Meta.threeColor(): Color? {
|
||||||
if (value.type == ValueType.NUMBER) {
|
val value = getValue(Name.EMPTY)
|
||||||
val int = value.int
|
return if (isLeaf) {
|
||||||
Color(int)
|
when {
|
||||||
} else {
|
value == null -> null
|
||||||
Color(value.string)
|
value === Null -> null
|
||||||
|
value.type == ValueType.NUMBER -> Color(value.int)
|
||||||
|
else -> Color(value.string)
|
||||||
}
|
}
|
||||||
} ?: Color(
|
} else {
|
||||||
|
Color(
|
||||||
getValue(Colors.RED_KEY.asName())?.int ?: 0,
|
getValue(Colors.RED_KEY.asName())?.int ?: 0,
|
||||||
getValue(Colors.GREEN_KEY.asName())?.int ?: 0,
|
getValue(Colors.GREEN_KEY.asName())?.int ?: 0,
|
||||||
getValue(Colors.BLUE_KEY.asName())?.int ?: 0
|
getValue(Colors.BLUE_KEY.asName())?.int ?: 0
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var Material.cached: Boolean
|
private var Material.cached: Boolean
|
||||||
get() = userData["cached"] == true
|
get() = userData["cached"] == true
|
||||||
|
Loading…
Reference in New Issue
Block a user