forked from kscience/visionforge
Fix polygon builders
This commit is contained in:
parent
1e29c5dbaa
commit
3529d0efc6
@ -209,9 +209,9 @@ private fun SolidGroup.addShape(
|
||||
require(fNz > 1) { "The polyhedron geometry requires at least two planes" }
|
||||
val baseRadius = fRmax[0]
|
||||
shape {
|
||||
(0..fNedges).forEach {
|
||||
val phi = deltaphi * fNedges * it + startphi
|
||||
(baseRadius * cos(phi) to baseRadius * sin(phi))
|
||||
(0..<fNedges).forEach {
|
||||
val phi = deltaphi / fNedges * it + startphi
|
||||
point(baseRadius * cos(phi), baseRadius * sin(phi))
|
||||
}
|
||||
}
|
||||
(0 until fNz).forEach { index ->
|
||||
|
21
demo/playground/src/jvmMain/kotlin/extruded.kt
Normal file
21
demo/playground/src/jvmMain/kotlin/extruded.kt
Normal file
@ -0,0 +1,21 @@
|
||||
package space.kscience.visionforge.examples
|
||||
|
||||
import space.kscience.visionforge.solid.ambientLight
|
||||
import space.kscience.visionforge.solid.extruded
|
||||
import space.kscience.visionforge.solid.polygon
|
||||
import space.kscience.visionforge.solid.solid
|
||||
|
||||
fun main() = makeVisionFile {
|
||||
vision("canvas") {
|
||||
solid {
|
||||
ambientLight()
|
||||
extruded("extruded") {
|
||||
shape{
|
||||
polygon(8, 100)
|
||||
layer(-30)
|
||||
layer(30)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ fun main() {
|
||||
ambientLight {
|
||||
color(Colors.white)
|
||||
}
|
||||
rootGeo(geo,"BM@N", maxLayer = 3, ignoreRootColors = true).also {
|
||||
rootGeo(geo,"BM@N", ignoreRootColors = true).also {
|
||||
Path("data/BM@N.vf.json").writeText(Solids.encodeToString(it))
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ public class VisionManager(meta: Meta) : AbstractPlugin(meta), MutableVisionCont
|
||||
|
||||
public val jsonFormat: Json
|
||||
get() = Json(defaultJson) {
|
||||
encodeDefaults = false
|
||||
serializersModule = this@VisionManager.serializersModule
|
||||
}
|
||||
|
||||
@ -85,7 +84,6 @@ public class VisionManager(meta: Meta) : AbstractPlugin(meta), MutableVisionCont
|
||||
serializersModule = defaultSerialModule
|
||||
prettyPrint = true
|
||||
useArrayPolymorphism = false
|
||||
encodeDefaults = false
|
||||
ignoreUnknownKeys = true
|
||||
explicitNulls = false
|
||||
}
|
||||
|
@ -207,9 +207,9 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) {
|
||||
require(solid.planes.size > 1) { "The polyhedron geometry requires at least two planes" }
|
||||
val baseRadius = solid.planes.first().rmax * lScale
|
||||
shape {
|
||||
(0..solid.numsides).forEach {
|
||||
(0..<solid.numsides).forEach {
|
||||
val phi = solid.deltaphi * aScale / solid.numsides * it + solid.startphi * aScale
|
||||
(baseRadius * cos(phi) to baseRadius * sin(phi))
|
||||
point(baseRadius * cos(phi), baseRadius * sin(phi))
|
||||
}
|
||||
}
|
||||
solid.planes.forEach { plane ->
|
||||
|
@ -23,8 +23,6 @@ public class Shape2DBuilder(private val points: ArrayList<Float32Vector2D> = Arr
|
||||
points.add(Float32Vector2D(x, y))
|
||||
}
|
||||
|
||||
public infix fun Number.to(y: Number): Unit = point(this, y)
|
||||
|
||||
public fun build(): Shape2D = points
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user