diff --git a/demo/solid-showcase/src/commonMain/kotlin/space/kscience/visionforge/solid/demo/demo.kt b/demo/solid-showcase/src/commonMain/kotlin/space/kscience/visionforge/solid/demo/demo.kt index 6f2cb61f..baee4c71 100644 --- a/demo/solid-showcase/src/commonMain/kotlin/space/kscience/visionforge/solid/demo/demo.kt +++ b/demo/solid-showcase/src/commonMain/kotlin/space/kscience/visionforge/solid/demo/demo.kt @@ -4,6 +4,8 @@ import kotlinx.coroutines.* import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.invoke import space.kscience.dataforge.names.Name +import space.kscience.kmath.geometry.Euclidean3DSpace +import space.kscience.kmath.geometry.radians import space.kscience.visionforge.Colors import space.kscience.visionforge.solid.* import space.kscience.visionforge.solid.specifications.Canvas3DOptions @@ -103,8 +105,15 @@ fun VisionLayout.showcase() { solidGroup { x = 200 rotationY = PI / 4 + axes(200) box(100, 100, 100) { - rotationZ = PI / 4 + rotate((PI / 4).radians, Euclidean3DSpace.zAxis) + GlobalScope.launch(Dispatchers.Main) { + while (isActive) { + delay(100) + rotate((PI/20).radians,Euclidean3DSpace.yAxis) + } + } color.set(Colors.red) } } @@ -151,7 +160,7 @@ fun VisionLayout.showcase() { } } - demo("STL", "STL loaded from URL"){ + demo("STL", "STL loaded from URL") { stl("https://ozeki.hu/attachments/116/Menger_sponge_sample.stl") } } diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt index a24192a8..c58b849d 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt @@ -9,6 +9,7 @@ import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.plus import space.kscience.kmath.complex.Quaternion +import space.kscience.kmath.complex.QuaternionField import space.kscience.kmath.geometry.* import space.kscience.visionforge.* import space.kscience.visionforge.Vision.Companion.VISIBLE_KEY @@ -245,6 +246,6 @@ public var Solid.scaleZ: Number by float(Z_SCALE_KEY, 1f) /** * Add rotation with given [angle] relative to given [axis] */ -public fun Solid.rotate(angle: Angle, axis: DoubleVector3D) { - quaternion = Quaternion.fromRotation(angle, axis) +public fun Solid.rotate(angle: Angle, axis: DoubleVector3D) = with(QuaternionField) { + quaternion = Quaternion.fromRotation(angle, axis)*quaternion } \ No newline at end of file