forked from kscience/visionforge
Minor FX fixes
This commit is contained in:
parent
493c527743
commit
c1627b4504
@ -65,6 +65,7 @@ class FX3DPlugin : AbstractPlugin() {
|
|||||||
}
|
}
|
||||||
is SolidLabel -> Text(obj.text).apply {
|
is SolidLabel -> Text(obj.text).apply {
|
||||||
font = Font.font(obj.fontFamily, obj.fontSize)
|
font = Font.font(obj.fontFamily, obj.fontSize)
|
||||||
|
|
||||||
x = -layoutBounds.width / 2
|
x = -layoutBounds.width / 2
|
||||||
y = layoutBounds.height / 2
|
y = layoutBounds.height / 2
|
||||||
}
|
}
|
||||||
@ -129,10 +130,10 @@ class FX3DPlugin : AbstractPlugin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object : PluginFactory<FX3DPlugin> {
|
public companion object : PluginFactory<FX3DPlugin> {
|
||||||
override val tag = PluginTag("vision.fx3D", PluginTag.DATAFORGE_GROUP)
|
override val tag: PluginTag = PluginTag("vision.fx3D", PluginTag.DATAFORGE_GROUP)
|
||||||
override val type = FX3DPlugin::class
|
override val type: KClass<FX3DPlugin> = FX3DPlugin::class
|
||||||
override fun invoke(meta: Meta, context: Context) = FX3DPlugin()
|
override fun invoke(meta: Meta, context: Context): FX3DPlugin = FX3DPlugin()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,14 +141,14 @@ class FX3DPlugin : AbstractPlugin() {
|
|||||||
* Builder and updater for three.js object
|
* Builder and updater for three.js object
|
||||||
*/
|
*/
|
||||||
@Type(TYPE)
|
@Type(TYPE)
|
||||||
interface FX3DFactory<in T : Solid> {
|
public interface FX3DFactory<in T : Solid> {
|
||||||
|
|
||||||
val type: KClass<in T>
|
public val type: KClass<in T>
|
||||||
|
|
||||||
operator fun invoke(obj: T, binding: VisualObjectFXBinding): Node
|
public operator fun invoke(obj: T, binding: VisualObjectFXBinding): Node
|
||||||
|
|
||||||
companion object {
|
public companion object {
|
||||||
const val TYPE = "fx3DFactory"
|
public const val TYPE = "fx3DFactory"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ private fun MeshView.toCSG(): CSG {
|
|||||||
return CSG.fromPolygons(polygons)
|
return CSG.fromPolygons(polygons)
|
||||||
}
|
}
|
||||||
|
|
||||||
class FXCompositeFactory(val plugin: FX3DPlugin) : FX3DFactory<Composite> {
|
public class FXCompositeFactory(public val plugin: FX3DPlugin) : FX3DFactory<Composite> {
|
||||||
override val type: KClass<in Composite>
|
override val type: KClass<in Composite>
|
||||||
get() = Composite::class
|
get() = Composite::class
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import javafx.scene.Node
|
|||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
|
||||||
object FXConvexFactory : FX3DFactory<Convex> {
|
public object FXConvexFactory : FX3DFactory<Convex> {
|
||||||
override val type: KClass<in Convex> get() = Convex::class
|
override val type: KClass<in Convex> get() = Convex::class
|
||||||
|
|
||||||
override fun invoke(obj: Convex, binding: VisualObjectFXBinding): Node {
|
override fun invoke(obj: Convex, binding: VisualObjectFXBinding): Node {
|
||||||
|
@ -8,7 +8,7 @@ import org.fxyz3d.geometry.Face3
|
|||||||
import space.kscience.dataforge.meta.Meta
|
import space.kscience.dataforge.meta.Meta
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
object FXShapeFactory : FX3DFactory<GeometrySolid> {
|
public object FXShapeFactory : FX3DFactory<GeometrySolid> {
|
||||||
override val type: KClass<in GeometrySolid> get() = GeometrySolid::class
|
override val type: KClass<in GeometrySolid> get() = GeometrySolid::class
|
||||||
|
|
||||||
override fun invoke(obj: GeometrySolid, binding: VisualObjectFXBinding): MeshView {
|
override fun invoke(obj: GeometrySolid, binding: VisualObjectFXBinding): MeshView {
|
||||||
|
@ -21,10 +21,25 @@ import space.kscience.visionforge.solid.specifications.Camera as CameraSpec
|
|||||||
|
|
||||||
public class OrbitControls internal constructor(camera: Camera, canvas: SubScene, spec: CameraSpec) {
|
public class OrbitControls internal constructor(camera: Camera, canvas: SubScene, spec: CameraSpec) {
|
||||||
|
|
||||||
public val azimuthProperty: SimpleDoubleProperty = SimpleDoubleProperty(spec.azimuth)
|
/**
|
||||||
|
* Azimuth angle in radians
|
||||||
|
*/
|
||||||
|
public val azimuthProperty: SimpleDoubleProperty = SimpleDoubleProperty().apply {
|
||||||
|
spec.useProperty(CameraSpec::azimuth){
|
||||||
|
set(spec.azimuth)
|
||||||
|
}
|
||||||
|
}
|
||||||
public var azimuth: Double by azimuthProperty
|
public var azimuth: Double by azimuthProperty
|
||||||
|
|
||||||
public val zenithProperty: SimpleDoubleProperty = SimpleDoubleProperty(PI / 2 - spec.latitude)
|
/**
|
||||||
|
* Zenith angle in radians
|
||||||
|
*/
|
||||||
|
public val zenithProperty: SimpleDoubleProperty = SimpleDoubleProperty().apply {
|
||||||
|
spec.useProperty(CameraSpec::latitude){
|
||||||
|
set(PI / 2 - spec.latitude)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public var zenith: Double by zenithProperty
|
public var zenith: Double by zenithProperty
|
||||||
|
|
||||||
|
|
||||||
@ -123,7 +138,7 @@ public class OrbitControls internal constructor(camera: Camera, canvas: SubScene
|
|||||||
|
|
||||||
if (me.isPrimaryButtonDown) {
|
if (me.isPrimaryButtonDown) {
|
||||||
azimuth = (azimuth - mouseDeltaX * MOUSE_SPEED * modifier * ROTATION_SPEED)
|
azimuth = (azimuth - mouseDeltaX * MOUSE_SPEED * modifier * ROTATION_SPEED)
|
||||||
zenith = (zenith - mouseDeltaY * MOUSE_SPEED * modifier * ROTATION_SPEED).coerceIn(-PI, PI)
|
zenith = (zenith - mouseDeltaY * MOUSE_SPEED * modifier * ROTATION_SPEED).coerceIn(-PI/2, PI/2)
|
||||||
} else if (me.isSecondaryButtonDown) {
|
} else if (me.isSecondaryButtonDown) {
|
||||||
x += MOUSE_SPEED * modifier * TRACK_SPEED * (mouseDeltaX * cos(azimuth) - mouseDeltaY * sin(azimuth))
|
x += MOUSE_SPEED * modifier * TRACK_SPEED * (mouseDeltaX * cos(azimuth) - mouseDeltaY * sin(azimuth))
|
||||||
z += MOUSE_SPEED * modifier * TRACK_SPEED * ( mouseDeltaX * sin(azimuth) + mouseDeltaY * cos(azimuth))
|
z += MOUSE_SPEED * modifier * TRACK_SPEED * ( mouseDeltaX * sin(azimuth) + mouseDeltaY * cos(azimuth))
|
||||||
|
@ -18,7 +18,6 @@ public class Camera : Scheme() {
|
|||||||
public var distance: Double by double(INITIAL_DISTANCE)
|
public var distance: Double by double(INITIAL_DISTANCE)
|
||||||
public var azimuth: Double by double(INITIAL_AZIMUTH)
|
public var azimuth: Double by double(INITIAL_AZIMUTH)
|
||||||
public var latitude: Double by double(INITIAL_LATITUDE)
|
public var latitude: Double by double(INITIAL_LATITUDE)
|
||||||
public val zenith: Double get() = PI / 2 - latitude
|
|
||||||
|
|
||||||
public companion object : SchemeSpec<Camera>(::Camera) {
|
public companion object : SchemeSpec<Camera>(::Camera) {
|
||||||
public const val INITIAL_DISTANCE: Double = 300.0
|
public const val INITIAL_DISTANCE: Double = 300.0
|
||||||
@ -52,3 +51,5 @@ public class Camera : Scheme() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public val Camera.zenith: Double get() = PI / 2 - latitude
|
Loading…
Reference in New Issue
Block a user