All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.earth.worldwind.frame.Frame.kt Maven / Gradle / Ivy

Go to download

The WorldWind Kotlin SDK (WWK) includes the library, examples and tutorials for building multiplatform 3D virtual globe applications for Android, Web and Java.

The newest version!
package earth.worldwind.frame

import earth.worldwind.PickedObjectList
import earth.worldwind.draw.DrawableQueue
import earth.worldwind.geom.Line
import earth.worldwind.geom.Matrix4
import earth.worldwind.geom.Vec2
import earth.worldwind.geom.Viewport
import earth.worldwind.util.Pool
import kotlinx.coroutines.CompletableDeferred
import kotlin.jvm.JvmStatic

open class Frame {
    val viewport = Viewport()
    val projection = Matrix4()
    val modelview = Matrix4()
//    val infiniteProjection = Matrix4()
    val drawableQueue = DrawableQueue()
    val drawableTerrain = DrawableQueue()
    var pickedObjects: PickedObjectList? = null
    var pickDeferred: CompletableDeferred? = null
    var pickViewport: Viewport? = null
    var pickPoint: Vec2? = null
    var pickRay: Line? = null
    var isPickMode = false
    private var pool: Pool? = null

    companion object {
        @JvmStatic
        fun obtain(pool: Pool): Frame {
            val instance = pool.acquire() ?: Frame()  // get an instance from the pool
            instance.pool = pool
            return instance
        }
    }

    open fun recycle() {
        viewport.setEmpty()
        projection.setToIdentity()
        modelview.setToIdentity()
//        infiniteProjection.setToIdentity()
        drawableQueue.clearDrawables()
        drawableTerrain.clearDrawables()
        pickedObjects?.let { pickDeferred?.complete(it) } // Complete deferred pick if available
        pickedObjects = null
        pickDeferred = null
        pickViewport = null
        pickPoint = null
        pickRay = null
        isPickMode = false
        pool?.release(this) // return this instance to the pool
        pool = null
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy