2021-01-12 12:52:22 +03:00
|
|
|
package hep.dataforge.vision.examples
|
|
|
|
|
2021-02-16 14:49:15 +03:00
|
|
|
import hep.dataforge.misc.DFExperimental
|
2021-02-24 18:26:15 +03:00
|
|
|
import hep.dataforge.vision.Vision
|
2021-02-26 13:03:40 +03:00
|
|
|
import hep.dataforge.vision.VisionForge
|
2021-01-12 12:52:22 +03:00
|
|
|
import hep.dataforge.vision.html.HtmlVisionFragment
|
|
|
|
import hep.dataforge.vision.html.ResourceLocation
|
2021-02-23 21:47:18 +03:00
|
|
|
import hep.dataforge.vision.html.page
|
2021-01-12 12:52:22 +03:00
|
|
|
import hep.dataforge.vision.html.scriptHeader
|
|
|
|
import hep.dataforge.vision.makeFile
|
|
|
|
import hep.dataforge.vision.three.server.VisionServer
|
|
|
|
import hep.dataforge.vision.three.server.useScript
|
|
|
|
import java.awt.Desktop
|
|
|
|
import java.nio.file.Path
|
|
|
|
|
|
|
|
|
|
|
|
public fun VisionServer.usePlayground(): Unit {
|
|
|
|
useScript("js/visionforge-playground.js")
|
|
|
|
}
|
|
|
|
|
|
|
|
@DFExperimental
|
2021-02-26 13:03:40 +03:00
|
|
|
public fun VisionForge.makeVisionFile(
|
2021-01-12 12:52:22 +03:00
|
|
|
content: HtmlVisionFragment,
|
|
|
|
path: Path? = null,
|
|
|
|
title: String = "VisionForge page",
|
|
|
|
resourceLocation: ResourceLocation = ResourceLocation.SYSTEM,
|
|
|
|
show: Boolean = true,
|
|
|
|
): Unit {
|
|
|
|
val actualPath = page(title, content).makeFile(path) { actualPath ->
|
|
|
|
mapOf("threeJs" to scriptHeader("js/visionforge-playground.js", actualPath, resourceLocation))
|
|
|
|
}
|
|
|
|
if (show) Desktop.getDesktop().browse(actualPath.toFile().toURI())
|
|
|
|
}
|
2021-02-24 18:26:15 +03:00
|
|
|
|
|
|
|
@DFExperimental
|
2021-02-26 13:03:40 +03:00
|
|
|
public fun VisionForge.makeVisionFile(
|
2021-02-24 18:26:15 +03:00
|
|
|
vision: Vision,
|
|
|
|
path: Path? = null,
|
|
|
|
title: String = "VisionForge page",
|
|
|
|
resourceLocation: ResourceLocation = ResourceLocation.SYSTEM,
|
|
|
|
show: Boolean = true,
|
|
|
|
): Unit = makeVisionFile({ vision(vision) }, path, title, resourceLocation, show)
|