Full BM@N geometry

This commit is contained in:
Alexander Nozik 2019-08-17 16:59:57 +03:00
parent b50a9c590f
commit 8d7eb2c1a9
7 changed files with 24 additions and 16 deletions

View File

@ -24,6 +24,7 @@ private fun VisualObject3D.withPosition(
this@withPosition.rotationX = rotation.x() this@withPosition.rotationX = rotation.x()
this@withPosition.rotationY = rotation.y() this@withPosition.rotationY = rotation.y()
this@withPosition.rotationZ = rotation.z() this@withPosition.rotationZ = rotation.z()
this@withPosition.rotationOrder=RotationOrder.ZXY
} }
scale?.let { scale?.let {
this@withPosition.scaleX = scale.x.toFloat() this@withPosition.scaleX = scale.x.toFloat()

View File

@ -102,7 +102,11 @@ private class GDMLDemoApp : ApplicationBase() {
} }
launch { message("Rendering") } launch { message("Rendering") }
val output = three.output(canvas) val output = three.output(canvas){
"axis" to {
"size" to 100
}
}
output.render(visual) output.render(visual)
launch { launch {
message(null) message(null)

View File

@ -33,7 +33,7 @@ class Tube(
require(radius > 0) require(radius > 0)
require(height > 0) require(height > 0)
require(innerRadius >= 0) require(innerRadius >= 0)
require(startAngle >= 0) //require(startAngle >= 0)
require(angle in (0f..(PI2))) require(angle in (0f..(PI2)))
} }

View File

@ -121,7 +121,7 @@ enum class RotationOrder {
*/ */
var VisualObject3D.rotationOrder: RotationOrder var VisualObject3D.rotationOrder: RotationOrder
get() = getProperty(VisualObject3D.rotationOrder).enum<RotationOrder>() ?: RotationOrder.XYZ get() = getProperty(VisualObject3D.rotationOrder).enum<RotationOrder>() ?: RotationOrder.XYZ
set(value) = setProperty(VisualObject3D.rotationOrder, value) set(value) = setProperty(VisualObject3D.rotationOrder, value.name)
/** /**
@ -191,7 +191,7 @@ var VisualObject3D.rotationY: Number
get() = rotation?.y ?: 0f get() = rotation?.y ?: 0f
set(value) { set(value) {
rotation().y = value.toDouble() rotation().y = value.toDouble()
propertyChanged(VisualObject3D.xRotation) propertyChanged(VisualObject3D.yRotation)
} }
var VisualObject3D.rotationZ: Number var VisualObject3D.rotationZ: Number

View File

@ -37,13 +37,12 @@ interface ThreeFactory<T : VisualObject3D> {
*/ */
internal fun Object3D.updatePosition(obj: VisualObject3D) { internal fun Object3D.updatePosition(obj: VisualObject3D) {
visible = obj.visible ?: true visible = obj.visible ?: true
// Matrix4().apply {
// makeRotationFromEuler(obj.euler)
// applyMatrix(this)
// makeTranslation(obj.x.toDouble(), obj.y.toDouble(), obj.z.toDouble())
// applyMatrix(this)
// }
position.set(obj.x, obj.y, obj.z) position.set(obj.x, obj.y, obj.z)
// obj.rotation?.let{
// rotateZ(it.z)
// rotateX(it.x)
// rotateY(it.y)
// }
setRotationFromEuler(obj.euler) setRotationFromEuler(obj.euler)
scale.set(obj.scaleX, obj.scaleY, obj.scaleZ) scale.set(obj.scaleX, obj.scaleY, obj.scaleZ)
updateMatrix() updateMatrix()

View File

@ -21,8 +21,8 @@ class ThreeOutput(val three: ThreePlugin, val meta: Meta = EmptyMeta) : Output<V
val scene: Scene = Scene().apply { val scene: Scene = Scene().apply {
add(AmbientLight()) add(AmbientLight())
if (meta["axis"] != null) { meta["axis"]?.let {
val axesHelper = AxesHelper(meta["axis.size"].int ?: 1) val axesHelper = AxesHelper(it.node["size"].int ?: 1)
add(axesHelper) add(axesHelper)
} }
} }

View File

@ -9,7 +9,9 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlin.math.* import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin
import kotlin.random.Random import kotlin.random.Random
@ -123,7 +125,9 @@ private class ThreeDemoApp : ApplicationBase() {
demo("CSG.custom", "CSG with manually created object") { demo("CSG.custom", "CSG with manually created object") {
intersect { intersect {
box(100, 100, 100) box(100, 100, 100)
tube(60,10) tube(60, 10) {
detail = 180
}
} }
} }
} }