Hi. I write opengl Kotlin code almost daily but I’m completely new to Kotlin/JS.
- I created a Kotlin/JS project in Idea without React. The hello world works fine.
- I added
implementation(npm("pixi.js", "5.3.3", generateExternals = true))
tobuild.gradle.kts
; pixi.js is a webgl library developed in TypeScript. - I ran
dukat > generateExternals
in gradle - I wrote some simple Kotlin code:
import kotlinx.browser.document
import kotlinx.browser.window
import kotlinx.html.dom.append
import org.w3c.dom.Node
fun main() {
window.onload = { document.body?.addPixi() }
}
fun Node.addPixi() {
val app = PIXI.Application()
val graphic = PIXI.Graphics()
app.stage.addChild(arrayOf(graphic))
graphic.lineStyle(3, 0xFF00FF)
graphic.beginFill(0x00FFFF)
graphic.drawCircle(0, 0, 100)
graphic.endFill()
append {
app.view
}
}
I get hundreds of errors in lib.dom.kt
, most of them are of the type 'addEventListener' overrides nothing
.
I don’t find in this forum mentions to either three.js
or pixi.js
, probably the most popular webgl libraries. Has anyone worked with them succesfully in Kotlin/JS?
Any tips on how to get it working? Or should I stick to JavaScript for now? Thank you