forked from kscience/visionforge
Fix a bug with composite children. Composite is no longer a group.
This commit is contained in:
parent
1f8700efde
commit
8652b03fa5
@ -5,6 +5,8 @@ import space.kscience.gdml.*
|
|||||||
import space.kscience.visionforge.gdml.toVision
|
import space.kscience.visionforge.gdml.toVision
|
||||||
import space.kscience.visionforge.html.ResourceLocation
|
import space.kscience.visionforge.html.ResourceLocation
|
||||||
import space.kscience.visionforge.solid.Solids
|
import space.kscience.visionforge.solid.Solids
|
||||||
|
import space.kscience.visionforge.solid.color
|
||||||
|
import space.kscience.visionforge.solid.invoke
|
||||||
import space.kscience.visionforge.visible
|
import space.kscience.visionforge.visible
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
||||||
@ -229,8 +231,12 @@ fun main() {
|
|||||||
if(solid.name == "world"){
|
if(solid.name == "world"){
|
||||||
visible = false
|
visible = false
|
||||||
}
|
}
|
||||||
//make all solids semi-transparent
|
if(solid.name.startsWith("gas")){
|
||||||
transparent()
|
color("green")
|
||||||
|
} else {
|
||||||
|
//make all solids semi-transparent
|
||||||
|
transparent()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import space.kscience.visionforge.solid.three.ThreePlugin
|
|||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
public class ThreeWithControls : AbstractPlugin(), ElementVisionRenderer {
|
public class ThreeWithControls : AbstractPlugin(), ElementVisionRenderer {
|
||||||
public val three by require(ThreePlugin)
|
public val three: ThreePlugin by require(ThreePlugin)
|
||||||
|
|
||||||
override val tag: PluginTag get() = Companion.tag
|
override val tag: PluginTag get() = Companion.tag
|
||||||
|
|
||||||
|
@ -32,12 +32,10 @@ internal data class PropertyListener(
|
|||||||
@SerialName("vision")
|
@SerialName("vision")
|
||||||
public open class VisionBase(
|
public open class VisionBase(
|
||||||
internal var properties: Config? = null,
|
internal var properties: Config? = null,
|
||||||
|
@Transient override var parent: VisionGroup? = null,
|
||||||
@Transient public val coroutineScope: CoroutineScope = GlobalScope,
|
@Transient public val coroutineScope: CoroutineScope = GlobalScope,
|
||||||
) : Vision {
|
) : Vision {
|
||||||
|
|
||||||
@Transient
|
|
||||||
override var parent: VisionGroup? = null
|
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
protected fun getOrCreateConfig(): Config {
|
protected fun getOrCreateConfig(): Config {
|
||||||
if (properties == null) {
|
if (properties == null) {
|
||||||
|
@ -160,20 +160,20 @@ private class GdmlTransformerEnv(val settings: GdmlTransformer) {
|
|||||||
): T = apply {
|
): T = apply {
|
||||||
newPos?.let {
|
newPos?.let {
|
||||||
val point = Point3D(it.x(settings.lUnit), it.y(settings.lUnit), it.z(settings.lUnit))
|
val point = Point3D(it.x(settings.lUnit), it.y(settings.lUnit), it.z(settings.lUnit))
|
||||||
if (position != null || point != Point3D.ZERO) {
|
if (point != Point3D.ZERO) {
|
||||||
position = point
|
position = point
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newRotation?.let {
|
newRotation?.let {
|
||||||
val point = Point3D(it.x(settings.aUnit), it.y(settings.aUnit), it.z(settings.aUnit))
|
val point = Point3D(it.x(settings.aUnit), it.y(settings.aUnit), it.z(settings.aUnit))
|
||||||
if (rotation != null || point != Point3D.ZERO) {
|
if (point != Point3D.ZERO) {
|
||||||
rotation = point
|
rotation = point
|
||||||
}
|
}
|
||||||
//this@withPosition.rotationOrder = RotationOrder.ZXY
|
//this@withPosition.rotationOrder = RotationOrder.ZXY
|
||||||
}
|
}
|
||||||
newScale?.let {
|
newScale?.let {
|
||||||
val point = Point3D(it.x, it.y, it.z)
|
val point = Point3D(it.x, it.y, it.z)
|
||||||
if (scale != null || point != Point3D.ONE) {
|
if (point != Point3D.ONE) {
|
||||||
scale = point
|
scale = point
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package space.kscience.visionforge.solid
|
|||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import space.kscience.dataforge.meta.update
|
import space.kscience.dataforge.meta.update
|
||||||
import space.kscience.dataforge.names.NameToken
|
|
||||||
import space.kscience.visionforge.*
|
import space.kscience.visionforge.*
|
||||||
|
|
||||||
public enum class CompositeType {
|
public enum class CompositeType {
|
||||||
@ -18,15 +17,15 @@ public class Composite(
|
|||||||
public val compositeType: CompositeType,
|
public val compositeType: CompositeType,
|
||||||
public val first: Solid,
|
public val first: Solid,
|
||||||
public val second: Solid,
|
public val second: Solid,
|
||||||
) : SolidBase(), Solid, VisionGroup {
|
) : SolidBase(), Solid {
|
||||||
|
//
|
||||||
init {
|
// init {
|
||||||
first.parent = this
|
// first.parent = this
|
||||||
second.parent = this
|
// second.parent = this
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override val children: Map<NameToken, Vision>
|
// override val children: Map<NameToken, Vision>
|
||||||
get() = mapOf(NameToken("first") to first, NameToken("second") to second)
|
// get() = mapOf(NameToken("first") to first, NameToken("second") to second)
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisionBuilder
|
@VisionBuilder
|
||||||
|
@ -12,15 +12,13 @@ import space.kscience.visionforge.VisionChange
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@SerialName("solid")
|
@SerialName("solid")
|
||||||
public open class SolidBase : VisionBase(), Solid {
|
public open class SolidBase(
|
||||||
|
override var position: Point3D? = null,
|
||||||
|
override var rotation: Point3D? = null,
|
||||||
|
override var scale: Point3D? = null,
|
||||||
|
) : VisionBase(), Solid {
|
||||||
override val descriptor: NodeDescriptor get() = Solid.descriptor
|
override val descriptor: NodeDescriptor get() = Solid.descriptor
|
||||||
|
|
||||||
override var position: Point3D? = null
|
|
||||||
|
|
||||||
override var rotation: Point3D? = null
|
|
||||||
|
|
||||||
override var scale: Point3D? = null
|
|
||||||
|
|
||||||
override fun update(change: VisionChange) {
|
override fun update(change: VisionChange) {
|
||||||
updatePosition(change.properties)
|
updatePosition(change.properties)
|
||||||
super.update(change)
|
super.update(change)
|
||||||
|
@ -29,6 +29,9 @@ public interface PrototypeHolder {
|
|||||||
@SerialName("group.solid")
|
@SerialName("group.solid")
|
||||||
public class SolidGroup(
|
public class SolidGroup(
|
||||||
@Serializable(PrototypeSerializer::class) internal var prototypes: MutableVisionGroup? = null,
|
@Serializable(PrototypeSerializer::class) internal var prototypes: MutableVisionGroup? = null,
|
||||||
|
override var position: Point3D? = null,
|
||||||
|
override var rotation: Point3D? = null,
|
||||||
|
override var scale: Point3D? = null,
|
||||||
) : VisionGroupBase(), Solid, PrototypeHolder {
|
) : VisionGroupBase(), Solid, PrototypeHolder {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -53,12 +56,6 @@ public class SolidGroup(
|
|||||||
}).run(builder)
|
}).run(builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override var position: Point3D? = null
|
|
||||||
|
|
||||||
override var rotation: Point3D? = null
|
|
||||||
|
|
||||||
override var scale: Point3D? = null
|
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * TODO add special static group to hold statics without propagation
|
// * TODO add special static group to hold statics without propagation
|
||||||
// */
|
// */
|
||||||
|
@ -54,6 +54,7 @@ public class Solids(meta: Meta) : VisionPlugin(meta) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal val jsonForSolids: Json = Json(VisionManager.defaultJson) {
|
internal val jsonForSolids: Json = Json(VisionManager.defaultJson) {
|
||||||
|
encodeDefaults = false
|
||||||
serializersModule = serializersModuleForSolids
|
serializersModule = serializersModuleForSolids
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,15 @@ import space.kscience.visionforge.scheme
|
|||||||
import space.kscience.visionforge.value
|
import space.kscience.visionforge.value
|
||||||
import space.kscience.visionforge.widgetType
|
import space.kscience.visionforge.widgetType
|
||||||
|
|
||||||
|
public class ClippingPlane: Scheme(){
|
||||||
|
public var x: Double by double(0.0)
|
||||||
|
public var y: Double by double(0.0)
|
||||||
|
public var z: Double by double(0.0)
|
||||||
|
|
||||||
|
public companion object: SchemeSpec<ClippingPlane>(::ClippingPlane)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class Canvas3DOptions : Scheme() {
|
public class Canvas3DOptions : Scheme() {
|
||||||
public var axes: Axes by spec(Axes)
|
public var axes: Axes by spec(Axes)
|
||||||
public var light: Light by spec(Light)
|
public var light: Light by spec(Light)
|
||||||
@ -25,6 +34,8 @@ public class Canvas3DOptions : Scheme() {
|
|||||||
|
|
||||||
public var layers: List<Number> by numberList(0)
|
public var layers: List<Number> by numberList(0)
|
||||||
|
|
||||||
|
//public var clippingPlanes: List<ClippingPlane> by list
|
||||||
|
|
||||||
public var onSelect: ((Name?) -> Unit)? = null
|
public var onSelect: ((Name?) -> Unit)? = null
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import info.laht.threekt.geometries.EdgesGeometry
|
|||||||
import info.laht.threekt.helpers.AxesHelper
|
import info.laht.threekt.helpers.AxesHelper
|
||||||
import info.laht.threekt.lights.AmbientLight
|
import info.laht.threekt.lights.AmbientLight
|
||||||
import info.laht.threekt.materials.LineBasicMaterial
|
import info.laht.threekt.materials.LineBasicMaterial
|
||||||
|
import info.laht.threekt.math.Box3
|
||||||
import info.laht.threekt.math.Vector2
|
import info.laht.threekt.math.Vector2
|
||||||
import info.laht.threekt.objects.LineSegments
|
import info.laht.threekt.objects.LineSegments
|
||||||
import info.laht.threekt.objects.Mesh
|
import info.laht.threekt.objects.Mesh
|
||||||
@ -43,7 +44,13 @@ public class ThreeCanvas(
|
|||||||
public val three: ThreePlugin,
|
public val three: ThreePlugin,
|
||||||
public val options: Canvas3DOptions,
|
public val options: Canvas3DOptions,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
private var boundingBox: Box3? = null
|
||||||
private var root: Object3D? = null
|
private var root: Object3D? = null
|
||||||
|
set(value) {
|
||||||
|
field = value
|
||||||
|
if (value != null) boundingBox = Box3().setFromObject(value)
|
||||||
|
}
|
||||||
|
|
||||||
private val raycaster = Raycaster()
|
private val raycaster = Raycaster()
|
||||||
private val mousePosition: Vector2 = Vector2()
|
private val mousePosition: Vector2 = Vector2()
|
||||||
@ -84,7 +91,7 @@ public class ThreeCanvas(
|
|||||||
(0..31).forEach {
|
(0..31).forEach {
|
||||||
if (it in selectedLayers) {
|
if (it in selectedLayers) {
|
||||||
this@apply.layers.enable(it)
|
this@apply.layers.enable(it)
|
||||||
} else{
|
} else {
|
||||||
this@apply.layers.disable(it)
|
this@apply.layers.disable(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user