8000 GitHub - jonike/three.kt: Three.js port for the JVM
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jonike/three.kt

 
 

Repository files navigation

three.kt (Work in progress)

License: MIT contributions welcome

Gitter CircleCI

Kotlin/JVM port of the popular three.js 3D library (r106).

Be warned, while the basics works, such as:

  • Primitives, Points and TubeGeometry (Only BufferGeometries are supported)
  • All materials
  • OrbitControls
  • Ambient, Directional, Point and Spot lights
  • RenderTarget, 2D textures
  • Other stuff like Reflector (mirror) and water

a lot of features are still missing and the API can change rapidly.

Right now, this is mostly interesting for developers that want to contribute.

How to run the samples?

This project has been setup as a kotlin multi-platform project. Due to some issue loading files from the resources folder in this context, right click -> run will not work. As a temporary workaround, please run the associated gradle tasks instead. E.g. BasicExample.kt will have an associated runBasicExample gradle task.

API (subject to changes)

Canvas().use { canvas ->

    val scene = Scene().apply {
        setBackground(Color.aliceblue)
    }

    val camera = PerspectiveCamera(75, canvas.aspect, 0.1, 1000)
    val renderer = GLRenderer(canvas).apply {
        checkShaderErrors = true
    }

    val box = Mesh(BoxGeometry(1f), MeshBasicMaterial().apply {
        color.set(0x00ff00)
    }).also {
        scene.add(it)
    }

    camera.position.z = 5f
    
    val controls = OrbitControls(camera, canvas)

    val clock = Clock()
    while (!canvas.shouldClose()) {
        renderer.render(scene, camera)
        
        val dt = clock.getDelta()
        box.rotation.x += 1f * dt
        box.rotation.y += 1f * dt
    }
    
}

Looking for the Kotlin/JS wrapper project?

It has been renamed and moved to here.

About

Three.js port for the JVM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 84.7%
  • GLSL 15.3%
0