Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rozenmad/Menori

Library for 3D rendering with LÖVE.
https://github.com/rozenmad/Menori

3d love2d lua

Last synced: 6 days ago
JSON representation

Library for 3D rendering with LÖVE.

Awesome Lists containing this project

README

        

# Menori

LÖVE library for 3D rendering based on scene graph. Support glTF 2.0 (implemented: meshes, materials, textures, skins, skeletons, animations). Assets may be provided either in JSON (.gltf) or binary (.glb) format.

Works on LÖVE 11.4 and higher.

[Web version](https://rozenmad.github.io/menori_demo1201/)
Built using [love-web-builder](https://github.com/rozenmad/love-web-builder)

[Documentation](https://rozenmad.github.io)

You can generate documentation using `ldoc -c menori/docs/config.ld -o index .`

![preview_example](preview.png)

# Usage Example

``` lua
local menori = require 'menori'

local ml = menori.ml
local vec3 = ml.vec3
local quat = ml.quat

function love.load()
local _, _, w, h = menori.app:get_viewport()
camera = menori.PerspectiveCamera(60, w/h, 0.5, 1024)
environment = menori.Environment(camera)

root_node = menori.Node()

local gltf = menori.glTFLoader.load('examples/assets/etrian_odyssey_3_monk.glb')
local scenes = menori.NodeTreeBuilder.create(gltf, function (scene, builder)
animations = menori.glTFAnimations(builder.animations)
animations:set_action(1)

scene:traverse(function (node)
if node.mesh then
node.material:set("baseColor", {0.85, 0.95, 1.0, 1})
end
end)
end)

root_node:attach(scenes[1])
end

local scene = menori.Scene()

function love.draw()
love.graphics.clear(0.3, 0.25, 0.2)
scene:render_nodes(root_node, environment, {
node_sort_comp = menori.Scene.alpha_mode_comp
})

love.graphics.print(love.timer.getFPS(), 10, 10)
end

function love.update(dt)
scene:update_nodes(root_node, environment)

local q = quat.from_euler_angles(0, math.rad(20), math.rad(10)) * vec3.unit_z * 2.0
local v = vec3(0, 0.5, 0)
camera.center = v
camera.eye = q + v
camera:update_view_matrix()

animations:update(dt)

if love.keyboard.isDown('escape') then
love.event.quit()
end
end
```

See ```main.lua``` for a more complete example.

# License
MIT