v0.2.0-dev-22 #47

Merged
altavir merged 158 commits from dev into master 2021-07-17 11:04:22 +03:00
3 changed files with 25 additions and 24 deletions
Showing only changes of commit 230cd5dc61 - Show all commits

View File

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

View File

@ -1,5 +1,6 @@
package space.kscience.visionforge.examples package space.kscience.visionforge.examples
import kotlinx.html.div
import kotlinx.html.h1 import kotlinx.html.h1
import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.Context
import space.kscience.visionforge.html.ResourceLocation import space.kscience.visionforge.html.ResourceLocation
@ -19,6 +20,7 @@ fun main() {
resourceLocation = ResourceLocation.EMBED resourceLocation = ResourceLocation.EMBED
) { ) {
h1 { +"Happy new year!" } h1 { +"Happy new year!" }
div {
vision { vision {
solid { solid {
repeat(100) { repeat(100) {
@ -28,7 +30,6 @@ fun main() {
z = random.nextDouble(-300.0, 300.0) z = random.nextDouble(-300.0, 300.0)
material { material {
color(random.nextInt()) color(random.nextInt())
specularColor(random.nextInt())
} }
detail = 16 detail = 16
} }
@ -37,3 +38,4 @@ fun main() {
} }
} }
} }
}

View File

@ -59,12 +59,12 @@ public object ThreeMaterials {
private val materialCache = HashMap<Meta, Material>() private val materialCache = HashMap<Meta, Material>()
internal fun buildMaterial(meta: Meta): Material { internal fun buildMaterial(meta: Meta): Material {
return if (meta[SolidMaterial.SPECULAR_COLOR_KEY] != null) { return meta[SolidMaterial.SPECULAR_COLOR_KEY]?.let { specularColor ->
MeshPhongMaterial().apply { MeshPhongMaterial().apply {
color = meta[SolidMaterial.COLOR_KEY]?.getColor() ?: DEFAULT_COLOR color = meta[SolidMaterial.COLOR_KEY]?.getColor() ?: DEFAULT_COLOR
specular = meta[SolidMaterial.SPECULAR_COLOR_KEY]!!.getColor() specular = specularColor.getColor()
emissive = specular emissive = specular
reflectivity = 1.0 reflectivity = 0.5
refractionRatio = 1.0 refractionRatio = 1.0
shininess = 100.0 shininess = 100.0
opacity = meta[SolidMaterial.OPACITY_KEY]?.double ?: 1.0 opacity = meta[SolidMaterial.OPACITY_KEY]?.double ?: 1.0
@ -72,15 +72,14 @@ public object ThreeMaterials {
wireframe = meta[SolidMaterial.WIREFRAME_KEY].boolean ?: false wireframe = meta[SolidMaterial.WIREFRAME_KEY].boolean ?: false
needsUpdate = true needsUpdate = true
} }
} else { } ?: MeshBasicMaterial().apply {
MeshBasicMaterial().apply {
color = meta[SolidMaterial.COLOR_KEY]?.getColor() ?: DEFAULT_COLOR color = meta[SolidMaterial.COLOR_KEY]?.getColor() ?: DEFAULT_COLOR
opacity = meta[SolidMaterial.OPACITY_KEY]?.double ?: 1.0 opacity = meta[SolidMaterial.OPACITY_KEY]?.double ?: 1.0
transparent = opacity < 1.0 transparent = opacity < 1.0
wireframe = meta[SolidMaterial.WIREFRAME_KEY].boolean ?: false wireframe = meta[SolidMaterial.WIREFRAME_KEY].boolean ?: false
needsUpdate = true needsUpdate = true
} }
}
} }
internal fun cacheMaterial(meta: Meta): Material = materialCache.getOrPut(meta) { internal fun cacheMaterial(meta: Meta): Material = materialCache.getOrPut(meta) {