diff --git a/demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt b/demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt
index b43ce062..edf159cd 100644
--- a/demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt
+++ b/demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt
@@ -1,7 +1,6 @@
import kotlinx.browser.document
import kotlinx.css.height
-import kotlinx.css.vh
-import kotlinx.css.vw
+import kotlinx.css.pct
import kotlinx.css.width
import react.child
import react.dom.render
@@ -32,8 +31,8 @@ private class JsPlaygroundApp : Application {
render(element) {
styledDiv {
css{
- height = 100.vh
- width = 100.vw
+ height = 100.pct
+ width = 100.pct
}
child(ThreeCanvasWithControls) {
attrs {
diff --git a/demo/js-playground/src/main/resources/index.html b/demo/js-playground/src/main/resources/index.html
index 7a777ef1..83a9016e 100644
--- a/demo/js-playground/src/main/resources/index.html
+++ b/demo/js-playground/src/main/resources/index.html
@@ -2,10 +2,11 @@
+
js-playground
-
+
\ No newline at end of file
diff --git a/demo/playground/src/jvmMain/kotlin/gdmlIaxo.kt b/demo/playground/src/jvmMain/kotlin/gdmlIaxo.kt
index fc2ebce3..a9070af7 100644
--- a/demo/playground/src/jvmMain/kotlin/gdmlIaxo.kt
+++ b/demo/playground/src/jvmMain/kotlin/gdmlIaxo.kt
@@ -3,7 +3,6 @@ package space.kscience.visionforge.examples
import space.kscience.dataforge.context.Context
import space.kscience.gdml.GdmlShowCase
import space.kscience.visionforge.gdml.toVision
-import space.kscience.visionforge.html.ResourceLocation
import space.kscience.visionforge.solid.Solids
fun main() {
@@ -11,7 +10,7 @@ fun main() {
plugin(Solids)
}
- context.makeVisionFile(resourceLocation = ResourceLocation.EMBED) {
+ context.makeVisionFile {
vision("canvas") { GdmlShowCase.babyIaxo().toVision() }
}
}
\ No newline at end of file
diff --git a/visionforge-threejs/src/main/kotlin/info/laht/threekt/THREE.kt b/visionforge-threejs/src/main/kotlin/info/laht/threekt/THREE.kt
index d3844561..3f8028cb 100644
--- a/visionforge-threejs/src/main/kotlin/info/laht/threekt/THREE.kt
+++ b/visionforge-threejs/src/main/kotlin/info/laht/threekt/THREE.kt
@@ -24,6 +24,7 @@
@file:JsModule("three")
@file:JsNonModule
+@file:Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING", "unused")
package info.laht.threekt
diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeGeometryBuilder.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeGeometryBuilder.kt
index d2a79ef5..c1c5aa72 100644
--- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeGeometryBuilder.kt
+++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeGeometryBuilder.kt
@@ -11,10 +11,10 @@ import space.kscience.visionforge.solid.minus
internal fun Point3D.toVector() = Vector3(x, y, z)
-internal fun MutableList.add(f1: T, f2: T, f3: T) {
- add(f1)
- add(f2)
- add(f3)
+internal fun MutableList.add(vararg values: T) {
+ values.forEach {
+ add(it)
+ }
}
/**
@@ -25,16 +25,16 @@ public class ThreeGeometryBuilder : GeometryBuilder {
private val indices = ArrayList()
private val positions = ArrayList()
private val normals = ArrayList()
- private val colors = ArrayList()
+// private val colors = ArrayList()
private val vertexCache = HashMap()
private var counter: Short = -1
- private fun indexOf(vertex: Point3D, normal: Point3D): Short = vertexCache.getOrPut(vertex) {
+ private fun vertex(vertex: Point3D, normal: Point3D): Short = vertexCache.getOrPut(vertex) {
//add vertex and update cache if needed
positions.add(vertex.x, vertex.y, vertex.z)
normals.add(normal.x, vertex.y, vertex.z)
- colors.add(1f, 1f, 1f)
+ //colors.add(1f, 1f, 1f)
counter++
counter
}
@@ -42,19 +42,21 @@ public class ThreeGeometryBuilder : GeometryBuilder {
override fun face(vertex1: Point3D, vertex2: Point3D, vertex3: Point3D, normal: Point3D?, meta: Meta) {
val actualNormal: Point3D = normal ?: (vertex3 - vertex2) cross (vertex1 - vertex2)
indices.add(
- indexOf(vertex1, actualNormal),
- indexOf(vertex2, actualNormal),
- indexOf(vertex3, actualNormal)
+ vertex(vertex1, actualNormal),
+ vertex(vertex2, actualNormal),
+ vertex(vertex3, actualNormal)
)
}
override fun build(): BufferGeometry = BufferGeometry().apply {
- //setIndex(Int16BufferAttribute(indices.toShortArray(), 1))
setIndex(indices.toTypedArray())
setAttribute("position", Float32BufferAttribute(positions.toTypedArray(), 3))
setAttribute("normal", Float32BufferAttribute(normals.toTypedArray(), 3))
//setAttribute("color", Float32BufferAttribute(colors.toFloatArray(), 3))
+ //a temporary fix for CSG problem
+ val uvsArray = Array((counter+1)*2){0f}
+ setAttribute("uv", Float32BufferAttribute(uvsArray, 2))
computeBoundingSphere()
}