visionforge/demo/playground/src/jvmMain/kotlin/randomSpheres.kt

41 lines
1.3 KiB
Kotlin
Raw Normal View History

2021-03-07 16:19:43 +03:00
package space.kscience.visionforge.examples
2020-12-26 22:46:01 +03:00
import kotlinx.html.h1
2021-03-07 16:19:43 +03:00
import space.kscience.dataforge.misc.DFExperimental
import space.kscience.visionforge.VisionForge
import space.kscience.visionforge.html.ResourceLocation
import space.kscience.visionforge.html.fragment
import space.kscience.visionforge.invoke
import space.kscience.visionforge.solid.*
2020-12-26 22:46:01 +03:00
import java.nio.file.Paths
import kotlin.random.Random
@OptIn(DFExperimental::class)
2021-02-27 21:40:58 +03:00
fun main() = VisionForge(Solids) {
2020-12-28 22:39:37 +03:00
2020-12-26 22:46:01 +03:00
val random = Random(112233)
2021-02-26 13:03:40 +03:00
val fragment = fragment {
2020-12-26 22:46:01 +03:00
h1 { +"Happy new year!" }
vision {
solid {
repeat(100) {
2020-12-28 22:39:37 +03:00
sphere(5, name = "sphere[$it]") {
2020-12-26 22:46:01 +03:00
x = random.nextDouble(-300.0, 300.0)
y = random.nextDouble(-300.0, 300.0)
z = random.nextDouble(-300.0, 300.0)
material {
color(random.nextInt())
specularColor(random.nextInt())
}
detail = 16
}
}
}
}
}
2021-02-26 13:03:40 +03:00
makeVisionFile(
2020-12-28 22:39:37 +03:00
fragment,
Paths.get("randomSpheres.html"),
resourceLocation = ResourceLocation.EMBED
)
2020-12-26 22:46:01 +03:00
}