0.2.0 #71

Merged
altavir merged 139 commits from dev into master 2022-01-24 09:44:18 +03:00
9 changed files with 127 additions and 97 deletions
Showing only changes of commit 9afe5da45b - Show all commits

View File

@ -1,6 +1,7 @@
plugins {
id("ru.mipt.npm.gradle.project")
// kotlin("multiplatform") version "1.5.30-RC" apply false
// kotlin("js") version "1.5.30-RC" apply false
}
val dataforgeVersion by extra("0.5.1")
@ -33,4 +34,9 @@ ksciencePublish {
apiValidation {
validationDisabled = true
ignoredPackages.add("info.laht.threekt")
}
//workaround for https://youtrack.jetbrains.com/issue/KT-48273
rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin::class.java) {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().versions.webpackDevServer.version = "4.0.0-rc.0"
}

View File

@ -20,9 +20,9 @@ kotlin{
dependencies{
implementation(project(":visionforge-gdml"))
implementation(project(":visionforge-plotly"))
implementation(projects.visionforge.visionforgeGdml)
implementation(projects.visionforge.visionforgePlotly)
implementation(projects.visionforge.visionforgeMarkdown)
implementation(project(":visionforge-threejs"))
implementation(project(":ui:ring"))
implementation(projects.visionforge.visionforgeThreejs)
implementation(projects.ui.ring)
}

View File

@ -1,7 +1,4 @@
import kotlinx.browser.document
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.css.*
import react.child
import react.dom.render
@ -12,9 +9,7 @@ import space.kscience.plotly.models.Trace
import space.kscience.plotly.scatter
import space.kscience.visionforge.Application
import space.kscience.visionforge.VisionClient
import space.kscience.visionforge.markup.VisionOfMarkup
import space.kscience.visionforge.plotly.PlotlyPlugin
import space.kscience.visionforge.react.flexRow
import space.kscience.visionforge.ring.ThreeCanvasWithControls
import space.kscience.visionforge.ring.ThreeWithControlsPlugin
import space.kscience.visionforge.ring.solid
@ -22,7 +17,6 @@ import space.kscience.visionforge.solid.*
import space.kscience.visionforge.startApplication
import styled.css
import styled.styledDiv
import kotlin.math.sqrt
import kotlin.random.Random
fun Trace.appendXYLatest(x: Number, y: Number, history: Int = 400, xErr: Number? = null, yErr: Number? = null) {
@ -44,9 +38,6 @@ private class JsPlaygroundApp : Application {
val element = document.getElementById("playground") ?: error("Element with id 'playground' not found on page")
val bouncingSphereTrace = Trace()
val bouncingSphereMarkup = VisionOfMarkup()
render(element) {
styledDiv {
css {
@ -57,72 +48,9 @@ private class JsPlaygroundApp : Application {
}
SmartTabs("gravity") {
Tab("gravity") {
styledDiv {
css {
height = 100.vh - 50.pt
}
styledDiv {
css {
height = 50.vh
}
child(ThreeCanvasWithControls) {
attrs {
context = playgroundContext
solid {
sphere(5.0, "ball") {
detail = 16
color("red")
val h = 100.0
y = h
launch {
val g = 10.0
val dt = 0.1
var time = 0.0
var velocity = 0.0
while (isActive) {
delay(20)
time += dt
velocity -= g * dt
val energy = g * y.toDouble() + velocity * velocity / 2
y = y.toDouble() + velocity * dt
bouncingSphereTrace.appendXYLatest(time, y)
if (y.toDouble() <= 2.5) {
//conservation of energy
velocity = sqrt(2 * g * h)
}
bouncingSphereMarkup.content = """
## Bouncing sphere parameters
**velocity** = $velocity
**energy** = $energy
""".trimIndent()
}
}
}
box(200, 5, 200, name = "floor") {
y = -2.5
}
}
}
}
}
flexRow {
css{
alignContent = Align.stretch
alignItems = Align.stretch
height = 50.vh - 50.pt
}
plotly {
traces(bouncingSphereTrace)
}
Markup {
attrs {
markup = bouncingSphereMarkup
}
}
GravityDemo{
attrs {
this.context = playgroundContext
}
}
}

View File

@ -0,0 +1,103 @@
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.css.*
import react.RProps
import react.child
import react.functionalComponent
import space.kscience.dataforge.context.Context
import space.kscience.plotly.models.Trace
import space.kscience.visionforge.markup.VisionOfMarkup
import space.kscience.visionforge.react.flexRow
import space.kscience.visionforge.ring.ThreeCanvasWithControls
import space.kscience.visionforge.ring.solid
import space.kscience.visionforge.solid.*
import styled.css
import styled.styledDiv
import kotlin.math.sqrt
external interface DemoProps : RProps {
var context: Context
}
val GravityDemo = functionalComponent<DemoProps> { props ->
val velocityTrace = Trace{
name = "velocity"
}
val energyTrace = Trace{
name = "energy"
}
val markup = VisionOfMarkup()
styledDiv {
css {
height = 100.vh - 50.pt
}
styledDiv {
css {
height = 50.vh
}
child(ThreeCanvasWithControls) {
attrs {
context = props.context
solid {
sphere(5.0, "ball") {
detail = 16
color("red")
val h = 100.0
y = h
context.launch {
val g = 10.0
val dt = 0.1
var time = 0.0
var velocity = 0.0
while (isActive) {
delay(20)
time += dt
velocity -= g * dt
val energy = g * y.toDouble() + velocity * velocity / 2
y = y.toDouble() + velocity * dt
velocityTrace.appendXYLatest(time, y)
energyTrace.appendXYLatest(time, energy)
if (y.toDouble() <= 2.5) {
//conservation of energy
velocity = sqrt(2 * g * h)
}
markup.content = """
## Bouncing sphere parameters
**velocity** = $velocity
**energy** = $energy
""".trimIndent()
}
}
}
box(200, 5, 200, name = "floor") {
y = -2.5
}
}
}
}
}
flexRow {
css {
alignContent = Align.stretch
alignItems = Align.stretch
height = 50.vh - 50.pt
}
plotly {
traces(velocityTrace)
}
Markup {
attrs {
this.markup = markup
}
}
}
}
}

View File

@ -46,7 +46,7 @@ val Markup = functionalComponent<MarkupProps>("Markup") { props ->
width = 100.pct
height = 100.pct
border(2.pt, BorderStyle.solid, Color.blue)
padding(8.pt)
padding(left = 8.pt)
backgroundColor = Color.white
flex(1.0)
zIndex = 10000

View File

@ -51,24 +51,24 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
api(project(":visionforge-solid"))
api(project(":visionforge-gdml"))
api(project(":visionforge-plotly"))
implementation(project(":visionforge-solid"))
implementation(project(":visionforge-gdml"))
implementation(project(":visionforge-plotly"))
implementation(projects.visionforge.visionforgeMarkdown)
}
}
val jsMain by getting{
dependencies {
implementation(project(":ui:ring"))
api(project(":visionforge-threejs"))
implementation(project(":visionforge-threejs"))
}
}
val jvmMain by getting{
dependencies {
api(project(":visionforge-server"))
api(project(":visionforge-markdown"))
api("ch.qos.logback:logback-classic:1.2.3")
implementation(project(":visionforge-server"))
implementation("ch.qos.logback:logback-classic:1.2.3")
implementation("com.github.Ricky12Awesome:json-schema-serialization:0.6.6")
}
}

View File

@ -1,10 +1,12 @@
import space.kscience.dataforge.misc.DFExperimental
import space.kscience.visionforge.markup.MarkupPlugin
import space.kscience.visionforge.plotly.PlotlyPlugin
import space.kscience.visionforge.ring.ThreeWithControlsPlugin
import space.kscience.visionforge.runVisionClient
@DFExperimental
fun main() = runVisionClient {
plugin(PlotlyPlugin)
plugin(ThreeWithControlsPlugin)
plugin(PlotlyPlugin)
plugin(MarkupPlugin)
}

View File

@ -17,13 +17,8 @@ kotlin{
dependencies{
api(project(":ui:react"))
//api("ru.mipt.npm:ring-ui:0.1.0")
api("org.jetbrains.kotlin-wrappers:kotlin-ring-ui")
implementation(npm("@jetbrains/icons", "3.14.1"))
implementation(npm("@jetbrains/ring-ui", "4.0.7"))
implementation(npm("core-js","3.12.1"))
implementation(npm("file-saver", "2.0.2"))
// compileOnly(npm("url-loader","4.1.1"))
// compileOnly(npm("postcss-loader","5.2.0"))
}

View File

@ -11,15 +11,11 @@ kscience{
dependencies {
api(project(":visionforge-solid"))
api("no.tornado:tornadofx:1.7.20")
api("org.fxyz3d:fxyz3d:0.5.4") {
exclude(module = "slf4j-simple")
}
api("org.jetbrains.kotlinx:kotlinx-coroutines-javafx:${ru.mipt.npm.gradle.KScienceVersions.coroutinesVersion}")
implementation("eu.mihosoft.vrl.jcsg:jcsg:0.5.7") {
exclude(module = "slf4j-simple")
}