0.2.0 #71

Merged
altavir merged 139 commits from dev into master 2022-01-24 09:44:18 +03:00
2 changed files with 41 additions and 23 deletions
Showing only changes of commit 95459422d6 - Show all commits

View File

@ -9,11 +9,11 @@ import react.dom.render
import ringui.SmartTabs import ringui.SmartTabs
import ringui.Tab import ringui.Tab
import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.Context
import space.kscience.gdml.GdmlShowCase import space.kscience.plotly.models.Trace
import space.kscience.plotly.models.appendXY
import space.kscience.plotly.scatter import space.kscience.plotly.scatter
import space.kscience.visionforge.Application import space.kscience.visionforge.Application
import space.kscience.visionforge.VisionClient import space.kscience.visionforge.VisionClient
import space.kscience.visionforge.gdml.toVision
import space.kscience.visionforge.plotly.PlotlyPlugin import space.kscience.visionforge.plotly.PlotlyPlugin
import space.kscience.visionforge.ring.ThreeCanvasWithControls import space.kscience.visionforge.ring.ThreeCanvasWithControls
import space.kscience.visionforge.ring.ThreeWithControlsPlugin import space.kscience.visionforge.ring.ThreeWithControlsPlugin
@ -36,6 +36,8 @@ private class JsPlaygroundApp : Application {
val element = document.getElementById("playground") ?: error("Element with id 'playground' not found on page") val element = document.getElementById("playground") ?: error("Element with id 'playground' not found on page")
val bouncingSphereTrace = Trace()
val bouncingSphere = SolidGroup { val bouncingSphere = SolidGroup {
sphere(5.0, "ball") { sphere(5.0, "ball") {
detail = 16 detail = 16
@ -52,20 +54,19 @@ private class JsPlaygroundApp : Application {
time += dt time += dt
velocity -= g * dt velocity -= g * dt
y = y.toDouble() + velocity * dt y = y.toDouble() + velocity * dt
if (y.toDouble() <= 2.5){ bouncingSphereTrace.appendXY(time, y)
velocity = sqrt(2*g*h) if (y.toDouble() <= 2.5) {
//conservation of energy
velocity = sqrt(2 * g * h)
} }
} }
} }
} }
box(200, 5, 200, name = "floor"){ box(200, 5, 200, name = "floor") {
y = -2.5 y = -2.5
} }
} }
val visionOfD0 = GdmlShowCase.babyIaxo().toVision()
val random = Random(112233) val random = Random(112233)
val visionOfSpheres = SolidGroup { val visionOfSpheres = SolidGroup {
@ -92,6 +93,10 @@ private class JsPlaygroundApp : Application {
} }
SmartTabs("gravity") { SmartTabs("gravity") {
Tab("gravity") { Tab("gravity") {
styledDiv {
css{
height = 50.vh
}
child(ThreeCanvasWithControls) { child(ThreeCanvasWithControls) {
attrs { attrs {
context = playgroundContext context = playgroundContext
@ -99,15 +104,30 @@ private class JsPlaygroundApp : Application {
} }
} }
} }
styledDiv {
css{
height = 40.vh
}
Tab("D0") { Plotly {
child(ThreeCanvasWithControls) {
attrs { attrs {
context = playgroundContext context = playgroundContext
solid = visionOfD0 plot = space.kscience.plotly.Plotly.plot {
traces(bouncingSphereTrace)
} }
} }
} }
}
}
// Tab("D0") {
// child(ThreeCanvasWithControls) {
// attrs {
// context = playgroundContext
// solid = GdmlShowCase.babyIaxo().toVision()
// }
// }
// }
Tab("spheres") { Tab("spheres") {
child(ThreeCanvasWithControls) { child(ThreeCanvasWithControls) {
attrs { attrs {

View File

@ -1,4 +1,4 @@
import kotlinx.css.* import kotlinx.css.flex
import org.w3c.dom.Element import org.w3c.dom.Element
import org.w3c.dom.HTMLElement import org.w3c.dom.HTMLElement
import react.RProps import react.RProps
@ -27,8 +27,6 @@ val Plotly = functionalComponent<PlotlyProps>("Plotly"){props ->
styledDiv { styledDiv {
css { css {
maxWidth = 100.vw
maxHeight = 100.vh
flex(1.0) flex(1.0)
} }
ref = elementRef ref = elementRef