More docs for ThreePlugin and VisionContainer
This commit is contained in:
parent
7b9fe54363
commit
71f7f59cb3
@ -10,10 +10,17 @@ import space.kscience.visionforge.VisionChildren.Companion.STATIC_TOKEN_BODY
|
|||||||
@DslMarker
|
@DslMarker
|
||||||
public annotation class VisionBuilder
|
public annotation class VisionBuilder
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A container interface with read access to its content
|
||||||
|
* using DataForge [Name] objects as keys.
|
||||||
|
*/
|
||||||
public interface VisionContainer<out V : Vision> {
|
public interface VisionContainer<out V : Vision> {
|
||||||
public fun getChild(name: Name): V?
|
public fun getChild(name: Name): V?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A container interface with write/replace/delete access to its content.
|
||||||
|
*/
|
||||||
public interface MutableVisionContainer<in V : Vision> {
|
public interface MutableVisionContainer<in V : Vision> {
|
||||||
//TODO add documentation
|
//TODO add documentation
|
||||||
public fun setChild(name: Name?, child: V?)
|
public fun setChild(name: Name?, child: V?)
|
||||||
@ -61,12 +68,22 @@ public inline fun VisionChildren.forEach(block: (NameToken, Vision) -> Unit) {
|
|||||||
keys.forEach { block(it, get(it)!!) }
|
keys.forEach { block(it, get(it)!!) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A serializable representation of [Vision] children container
|
||||||
|
* with the ability to modify the container content.
|
||||||
|
*/
|
||||||
public interface MutableVisionChildren : VisionChildren, MutableVisionContainer<Vision> {
|
public interface MutableVisionChildren : VisionChildren, MutableVisionContainer<Vision> {
|
||||||
|
|
||||||
public override val parent: MutableVisionGroup
|
public override val parent: MutableVisionGroup
|
||||||
|
|
||||||
public operator fun set(token: NameToken, value: Vision?)
|
public operator fun set(token: NameToken, value: Vision?)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set child [Vision] by name.
|
||||||
|
* @param name child name. Pass null to add a static child. Note that static children cannot
|
||||||
|
* be removed, replaced or accessed by name by other means.
|
||||||
|
* @param child new child value. Pass null to delete the child.
|
||||||
|
*/
|
||||||
override fun setChild(name: Name?, child: Vision?) {
|
override fun setChild(name: Name?, child: Vision?) {
|
||||||
when {
|
when {
|
||||||
name == null -> {
|
name == null -> {
|
||||||
|
@ -53,9 +53,9 @@ public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer {
|
|||||||
/**
|
/**
|
||||||
* Build an Object3D representation of the given [Solid].
|
* Build an Object3D representation of the given [Solid].
|
||||||
*
|
*
|
||||||
* @param vision 3D vision to build a representation of;
|
* @param vision [Solid] object to build a representation of;
|
||||||
* @param observe whether the constructed Object3D should be changed when its
|
* @param observe whether the constructed Object3D should be changed when the
|
||||||
* parent vision changes.
|
* original [Vision] changes.
|
||||||
*/
|
*/
|
||||||
public suspend fun buildObject3D(vision: Solid, observe: Boolean = true): Object3D = when (vision) {
|
public suspend fun buildObject3D(vision: Solid, observe: Boolean = true): Object3D = when (vision) {
|
||||||
is ThreeJsVision -> vision.render(this)
|
is ThreeJsVision -> vision.render(this)
|
||||||
|
Loading…
Reference in New Issue
Block a user