GistTree.Com
Entertainment at it's peak. The news is by your side.

Show HN: Three.kt – A Kotlin/JVM port of Three.js JavaScript 3D library

0

License: MIT
contributions welcome

CI
Download

Gitter

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

Be warned, whereas the basics works, akin to:

  • Primitives, Components and TubeGeometry
  • All provides and lights
  • OrbitControls
  • 2D textures
  • Raycasting against Mesh
  • OBJ, MTL and STL loaders
  • Diversified stuff bask in think, sky and water shaders

comparatively plenty of parts are serene missing and the API can commerce snappily.

Appropriate now, this is basically intriguing for builders that contain to make contributions.

API (field to changes)

Kotlin
Window(antialias = 4).employ { window ->

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

    val digicam = PerspectiveCamera(75, window.aspect, 0.1, 1000).be aware {
        space.z = 5f
    }

    val renderer = GLRenderer(window.size)

    val field = Mesh(BoxGeometry(1f), MeshBasicMaterial().be aware {
        color.space(0x00ff00)
    })
    scene.add(field)
    
    val clock = Clock()
    val controls = OrbitControls(digicam, window)
    window.animate {
     
        val dt = clock.getDelta()
        field.rotation.x += 1f * dt
        field.rotation.y += 1f * dt

        renderer.render(scene, digicam)

    }

}
Java
public class JavaExample {

    public static void main(String[] args) {

        are attempting (Window window = unique Window()) {

            Scene scene = unique Scene();
            PerspectiveCamera digicam = unique PerspectiveCamera();
            digicam.getPosition().z = 5;
            GLRenderer renderer = unique GLRenderer(window.getSize());

            BoxBufferGeometry boxBufferGeometry = unique BoxBufferGeometry();
            MeshPhongMaterial boxMaterial = unique MeshPhongMaterial();
            boxMaterial.getColor().space(Color.getRoyalblue());

            Mesh field = unique Mesh(boxBufferGeometry, boxMaterial);
            scene.add(field);

            MeshBasicMaterial wireframeMaterial = unique MeshBasicMaterial();
            wireframeMaterial.getColor().space(0x000000);
            wireframeMaterial.setWireframe(unprejudiced appropriate);
            Mesh wireframe = unique Mesh(field.getGeometry().clone(), wireframeMaterial);
            scene.add(wireframe);

            AmbientLight light = unique AmbientLight();
            scene.add(light);

            OrbitControls orbitControls = unique OrbitControls(digicam, window);

            window.animate(() -> {
                renderer.render(scene, digicam);
            });

        }

    }

}

Screenshots

seascape
points
ocean
pointlights

Procuring for the Kotlin/JS wrapper venture?

It has been renamed and moved to here.

Read More

Leave A Reply

Your email address will not be published.