info.laht.threekt.objects.Sprite.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
Port of the three.js 3D javascript library for Kotlin/JVM
The newest version!
package info.laht.threekt.objects
import info.laht.threekt.core.*
import info.laht.threekt.materials.SpriteMaterial
import info.laht.threekt.math.Frustum
import info.laht.threekt.math.Sphere
import info.laht.threekt.math.Vector2
class Sprite(
override var material: SpriteMaterial = SpriteMaterial()
) : Object3DImpl(), GeometryObject, MaterialObject {
override var geometry = BufferGeometry()
val center = Vector2(0.5f, 0.5f)
init {
val float32Array = floatArrayOf(
-0.5f, -0.5f, 0f, 0f, 0f,
0.5f, -0.5f, 0f, 1f, 0f,
0.5f, 0.5f, 0f, 1f, 1f,
-0.5f, 0.5f, 0f, 0f, 1f
)
geometry.setIndex(IntBufferAttribute(intArrayOf(0, 1, 2, 0, 2, 3), 1))
TODO("Sprite not implemented yet")
// geometry.addAttribute( "position", InterleavedBufferAttribute( interleavedBuffer, 3, 0, false ) );
// geometry.addAttribute( "uv", InterleavedBufferAttribute( interleavedBuffer, 2, 3, false ) );
}
override fun raycast(raycaster: Raycaster, intersects: MutableList) {
TODO()
}
}
fun Frustum.intersectsSprite(sprite: Sprite): Boolean {
val sphere = Sphere()
sphere.center.set(0f, 0f, 0f)
sphere.radius = 0.7071067811865476f
sphere.applyMatrix4(sprite.matrixWorld)
return this.intersectsSphere(sphere)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy