diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionContainer.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionContainer.kt index c74f027d..09edf4c1 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionContainer.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionContainer.kt @@ -10,10 +10,17 @@ import space.kscience.visionforge.VisionChildren.Companion.STATIC_TOKEN_BODY @DslMarker public annotation class VisionBuilder +/** + * A container interface with read access to its content + * using DataForge [Name] objects as keys. + */ public interface VisionContainer { public fun getChild(name: Name): V? } +/** + * A container interface with write/replace/delete access to its content. + */ public interface MutableVisionContainer { //TODO add documentation 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)!!) } } +/** + * A serializable representation of [Vision] children container + * with the ability to modify the container content. + */ public interface MutableVisionChildren : VisionChildren, MutableVisionContainer { public override val parent: MutableVisionGroup 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?) { when { name == null -> { diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreePlugin.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreePlugin.kt index f5ee8876..bb5e0c79 100644 --- a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreePlugin.kt +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/ThreePlugin.kt @@ -53,9 +53,9 @@ public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer { /** * Build an Object3D representation of the given [Solid]. * - * @param vision 3D vision to build a representation of; - * @param observe whether the constructed Object3D should be changed when its - * parent vision changes. + * @param vision [Solid] object to build a representation of; + * @param observe whether the constructed Object3D should be changed when the + * original [Vision] changes. */ public suspend fun buildObject3D(vision: Solid, observe: Boolean = true): Object3D = when (vision) { is ThreeJsVision -> vision.render(this)