From 5eb9925d35bffb3c57cc598e6db0245301e3552e Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 12 Jan 2021 13:25:43 +0300 Subject: [PATCH] Add plugin updaters to playground examples. --- playground/src/jvmMain/kotlin/randomSpheres.kt | 2 +- playground/src/jvmMain/kotlin/simpleCube.kt | 3 ++- .../commonMain/kotlin/hep/dataforge/vision/VisionManager.kt | 1 - .../src/commonMain/kotlin/hep/dataforge/vision/html/Page.kt | 2 +- .../kotlin/hep/dataforge/vision/solid/SolidManager.kt | 6 +++++- .../kotlin/hep/dataforge/vision/solid/three/ThreePlugin.kt | 4 ++++ 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/playground/src/jvmMain/kotlin/randomSpheres.kt b/playground/src/jvmMain/kotlin/randomSpheres.kt index 4d3a773b..96431234 100644 --- a/playground/src/jvmMain/kotlin/randomSpheres.kt +++ b/playground/src/jvmMain/kotlin/randomSpheres.kt @@ -34,7 +34,7 @@ fun main() { } } - VisionForge.makeVisionFile( + VisionForge.withSolids().makeVisionFile( fragment, Paths.get("randomSpheres.html"), resourceLocation = ResourceLocation.EMBED diff --git a/playground/src/jvmMain/kotlin/simpleCube.kt b/playground/src/jvmMain/kotlin/simpleCube.kt index b7ac54b9..fbcb66e1 100644 --- a/playground/src/jvmMain/kotlin/simpleCube.kt +++ b/playground/src/jvmMain/kotlin/simpleCube.kt @@ -7,6 +7,7 @@ import hep.dataforge.vision.html.ResourceLocation import hep.dataforge.vision.html.fragment import hep.dataforge.vision.solid.box import hep.dataforge.vision.solid.solid +import hep.dataforge.vision.solid.withSolids @OptIn(DFExperimental::class) fun main() { @@ -18,5 +19,5 @@ fun main() { } } - VisionForge.makeVisionFile(content, resourceLocation = ResourceLocation.SYSTEM) + VisionForge.withSolids().makeVisionFile(content, resourceLocation = ResourceLocation.SYSTEM) } \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/hep/dataforge/vision/VisionManager.kt b/visionforge-core/src/commonMain/kotlin/hep/dataforge/vision/VisionManager.kt index ea106cab..2465c662 100644 --- a/visionforge-core/src/commonMain/kotlin/hep/dataforge/vision/VisionManager.kt +++ b/visionforge-core/src/commonMain/kotlin/hep/dataforge/vision/VisionManager.kt @@ -86,7 +86,6 @@ public abstract class VisionPlugin(meta: Meta = Meta.EMPTY) : AbstractPlugin(met VisionManager.VISION_SERIALIZER_MODULE_TARGET -> mapOf(tag.toString().toName() to visionSerializersModule) else -> super.content(target) } - } /** diff --git a/visionforge-core/src/commonMain/kotlin/hep/dataforge/vision/html/Page.kt b/visionforge-core/src/commonMain/kotlin/hep/dataforge/vision/html/Page.kt index 7a12c2ac..213710cf 100644 --- a/visionforge-core/src/commonMain/kotlin/hep/dataforge/vision/html/Page.kt +++ b/visionforge-core/src/commonMain/kotlin/hep/dataforge/vision/html/Page.kt @@ -18,7 +18,7 @@ public data class Page( fragment(it) } } - title(title) + title(this@Page.title) } body { embedVisionFragment(context.visionManager, fragment = content) diff --git a/visionforge-solid/src/commonMain/kotlin/hep/dataforge/vision/solid/SolidManager.kt b/visionforge-solid/src/commonMain/kotlin/hep/dataforge/vision/solid/SolidManager.kt index c6d610cb..db68b53c 100644 --- a/visionforge-solid/src/commonMain/kotlin/hep/dataforge/vision/solid/SolidManager.kt +++ b/visionforge-solid/src/commonMain/kotlin/hep/dataforge/vision/solid/SolidManager.kt @@ -68,4 +68,8 @@ public class SolidManager(meta: Meta) : VisionPlugin(meta) { @VisionBuilder @DFExperimental -public inline fun VisionOutput.solid(block: SolidGroup.() -> Unit): SolidGroup = SolidGroup().apply(block) \ No newline at end of file +public inline fun VisionOutput.solid(block: SolidGroup.() -> Unit): SolidGroup = SolidGroup().apply(block) + +public fun Context.withSolids(): Context = apply { + plugins.fetch(SolidManager) +} \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/hep/dataforge/vision/solid/three/ThreePlugin.kt b/visionforge-threejs/src/main/kotlin/hep/dataforge/vision/solid/three/ThreePlugin.kt index 21afdedb..dc20bdce 100644 --- a/visionforge-threejs/src/main/kotlin/hep/dataforge/vision/solid/three/ThreePlugin.kt +++ b/visionforge-threejs/src/main/kotlin/hep/dataforge/vision/solid/three/ThreePlugin.kt @@ -199,4 +199,8 @@ internal fun Object3D.findChild(name: Name): Object3D? { name.length == 1 -> this.children.find { it.name == name.tokens.first().toString() } else -> findChild(name.tokens.first().asName())?.findChild(name.cutFirst()) } +} + +public fun Context.withThreeJs(): Context = apply { + plugins.fetch(ThreePlugin) } \ No newline at end of file