Fix light
This commit is contained in:
parent
cb25dca34c
commit
67afa4e45b
@ -1,13 +1,20 @@
|
|||||||
package space.kscience.visionforge.examples
|
package space.kscience.visionforge.examples
|
||||||
|
|
||||||
import space.kscience.gdml.GdmlShowCase
|
import space.kscience.gdml.GdmlShowCase
|
||||||
|
import space.kscience.visionforge.Colors
|
||||||
import space.kscience.visionforge.gdml.toVision
|
import space.kscience.visionforge.gdml.toVision
|
||||||
import space.kscience.visionforge.html.ResourceLocation
|
import space.kscience.visionforge.html.ResourceLocation
|
||||||
import space.kscience.visionforge.solid.Solids
|
import space.kscience.visionforge.solid.Solids
|
||||||
|
import space.kscience.visionforge.solid.ambientLight
|
||||||
|
import space.kscience.visionforge.solid.set
|
||||||
|
|
||||||
fun main() = makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) {
|
fun main() = makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) {
|
||||||
vision("canvas") {
|
vision("canvas") {
|
||||||
requirePlugin(Solids)
|
requirePlugin(Solids)
|
||||||
GdmlShowCase.cubes().toVision()
|
GdmlShowCase.cubes().toVision().also {
|
||||||
|
it.ambientLight {
|
||||||
|
color.set(Colors.white)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,6 +8,7 @@ import space.kscience.dataforge.context.Context
|
|||||||
import space.kscience.dataforge.context.fetch
|
import space.kscience.dataforge.context.fetch
|
||||||
import space.kscience.dataforge.misc.DFExperimental
|
import space.kscience.dataforge.misc.DFExperimental
|
||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.Name
|
||||||
|
import space.kscience.visionforge.Colors
|
||||||
import space.kscience.visionforge.html.Page
|
import space.kscience.visionforge.html.Page
|
||||||
import space.kscience.visionforge.html.plus
|
import space.kscience.visionforge.html.plus
|
||||||
import space.kscience.visionforge.server.close
|
import space.kscience.visionforge.server.close
|
||||||
@ -28,7 +29,11 @@ fun main() {
|
|||||||
val solids = satContext.fetch(Solids)
|
val solids = satContext.fetch(Solids)
|
||||||
|
|
||||||
//Create a geometry
|
//Create a geometry
|
||||||
val sat = solids.visionOfSatellite(ySegments = 3)
|
val sat = solids.visionOfSatellite(ySegments = 3).apply {
|
||||||
|
ambientLight {
|
||||||
|
color.set(Colors.white)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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")) {
|
||||||
|
@ -9,6 +9,7 @@ import kotlinx.serialization.Serializable
|
|||||||
import space.kscience.dataforge.meta.*
|
import space.kscience.dataforge.meta.*
|
||||||
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.isEmpty
|
||||||
import space.kscience.dataforge.names.plus
|
import space.kscience.dataforge.names.plus
|
||||||
import kotlin.jvm.Synchronized
|
import kotlin.jvm.Synchronized
|
||||||
import kotlin.time.Duration
|
import kotlin.time.Duration
|
||||||
@ -49,7 +50,7 @@ public object NullVision : Vision {
|
|||||||
public class VisionChangeBuilder(private val manager: VisionManager) : MutableVisionContainer<Vision> {
|
public class VisionChangeBuilder(private val manager: VisionManager) : MutableVisionContainer<Vision> {
|
||||||
|
|
||||||
private var vision: Vision? = null
|
private var vision: Vision? = null
|
||||||
private val propertyChange = MutableMeta()
|
private var propertyChange = MutableMeta()
|
||||||
private val children: HashMap<Name, VisionChangeBuilder> = HashMap()
|
private val children: HashMap<Name, VisionChangeBuilder> = HashMap()
|
||||||
|
|
||||||
public fun isEmpty(): Boolean = propertyChange.isEmpty() && propertyChange.isEmpty() && children.isEmpty()
|
public fun isEmpty(): Boolean = propertyChange.isEmpty() && propertyChange.isEmpty() && children.isEmpty()
|
||||||
@ -61,7 +62,11 @@ public class VisionChangeBuilder(private val manager: VisionManager) : MutableVi
|
|||||||
public fun propertyChanged(visionName: Name, propertyName: Name, item: Meta?) {
|
public fun propertyChanged(visionName: Name, propertyName: Name, item: Meta?) {
|
||||||
if (visionName == Name.EMPTY) {
|
if (visionName == Name.EMPTY) {
|
||||||
//Write property removal as [Null]
|
//Write property removal as [Null]
|
||||||
|
if (propertyName.isEmpty()) {
|
||||||
|
propertyChange = item?.toMutableMeta() ?: MutableMeta()
|
||||||
|
} else {
|
||||||
propertyChange[propertyName] = (item ?: Meta(Null))
|
propertyChange[propertyName] = (item ?: Meta(Null))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
getOrPutChild(visionName).propertyChanged(Name.EMPTY, propertyName, item)
|
getOrPutChild(visionName).propertyChanged(Name.EMPTY, propertyName, item)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user