
info.laht.threekt.loaders.TextureLoaderExt.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.loaders
import info.laht.threekt.textures.Texture
import java.io.File
import java.net.URL
fun TextureLoader.load(url: URL, flipY: Boolean = true): Texture {
val split = url.toExternalForm().split(".")
val type = split[split.lastIndex]
val tmp = createTempFile(suffix = ".$type")
tmp.writeBytes(url.openStream().use { it.readBytes() })
return load(tmp.absolutePath, flipY).also {
tmp.delete()
}
}
fun TextureLoader.load(file: File, flipY: Boolean = true): Texture {
return load(file.absolutePath, flipY)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy