Add static glTF support (#14557)
Co-authored-by: Lars Mueller <appgurulars@gmx.de> Co-authored-by: jordan4ibanez <jordan4ibanez@users.noreply.github.com> Co-authored-by: sfan5 <sfan5@live.de> Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
This commit is contained in:
14
games/devtest/mods/gltf/LICENSE.md
Normal file
14
games/devtest/mods/gltf/LICENSE.md
Normal file
@@ -0,0 +1,14 @@
|
||||
glTF test model (and corresponding texture) licenses:
|
||||
|
||||
* Spider (`gltf_spider.gltf`, `gltf_spider.png`):
|
||||
* By [archfan7411](https://github.com/archfan7411)
|
||||
* Licensed under CC0, public domain "wherever public domain carries fewer rights or legal protections"
|
||||
* Frog (`gltf_frog.gltf`, `gltf_frog.png`):
|
||||
* By [Susybaka1234](https://sketchfab.com/3d-models/african-clawed-frog-v2-c81152c93948480c931c280d18957358)
|
||||
* Licensed under CC-BY 4.0
|
||||
* Snow Man (`gltf_snow_man.gltf`, `gltf_snow_man.png`):
|
||||
* By [jordan4ibanez](https://github.com/jordan4ibanez)
|
||||
* Licensed under CC0
|
||||
* Minimal triangle, triangle without indices (`gltf_minimal_triangle.gltf`, `gltf_triangle_without_indices.gltf`)
|
||||
* From [the glTF sample model collection](https://github.com/KhronosGroup/glTF-Sample-Models)
|
||||
* Licensed under CC0 / public domain
|
||||
51
games/devtest/mods/gltf/init.lua
Normal file
51
games/devtest/mods/gltf/init.lua
Normal file
@@ -0,0 +1,51 @@
|
||||
local function register_entity(name, textures, backface_culling)
|
||||
minetest.register_entity("gltf:" .. name, {
|
||||
initial_properties = {
|
||||
visual = "mesh",
|
||||
mesh = "gltf_" .. name .. ".gltf",
|
||||
textures = textures,
|
||||
backface_culling = backface_culling,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
-- These do not have texture coordinates; they simple render as black surfaces.
|
||||
register_entity("minimal_triangle", {}, false)
|
||||
register_entity("triangle_with_vertex_stride", {}, false)
|
||||
register_entity("triangle_without_indices", {}, false)
|
||||
do
|
||||
local cube_textures = {"gltf_cube.png"}
|
||||
register_entity("blender_cube", cube_textures)
|
||||
register_entity("blender_cube_scaled", cube_textures)
|
||||
register_entity("blender_cube_matrix_transform", cube_textures)
|
||||
end
|
||||
register_entity("snow_man", {"gltf_snow_man.png"})
|
||||
register_entity("spider", {"gltf_spider.png"})
|
||||
-- Note: Model has an animation, but we can use it as a static test nevertheless
|
||||
-- The claws rendering incorrectly from one side is expected behavior:
|
||||
-- They use an unsupported double-sided material.
|
||||
register_entity("frog", {"gltf_frog.png"}, false)
|
||||
|
||||
minetest.register_node("gltf:frog", {
|
||||
description = "glTF frog, but it's a node",
|
||||
tiles = {{name = "gltf_frog.png", backface_culling = false}},
|
||||
drawtype = "mesh",
|
||||
mesh = "gltf_frog.gltf",
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("show_model", {
|
||||
params = "<model> [textures]",
|
||||
description = "Show a model (defaults to gltf models, for example '/show_model frog').",
|
||||
func = function(name, param)
|
||||
local model, textures = param:match"^(.-)%s+(.+)$"
|
||||
if not model then
|
||||
model = "gltf_" .. param .. ".gltf"
|
||||
textures = "gltf_" .. param .. ".png"
|
||||
end
|
||||
minetest.show_formspec(name, "gltf:model", table.concat{
|
||||
"formspec_version[7]",
|
||||
"size[10,10]",
|
||||
"model[0,0;10,10;model;", model, ";", textures, ";0,0;true;true;0,0;0]",
|
||||
})
|
||||
end,
|
||||
})
|
||||
0
games/devtest/mods/gltf/invalid/empty.gltf
Normal file
0
games/devtest/mods/gltf/invalid/empty.gltf
Normal file
BIN
games/devtest/mods/gltf/invalid/invalid_bufferview_bounds.gltf
Normal file
BIN
games/devtest/mods/gltf/invalid/invalid_bufferview_bounds.gltf
Normal file
Binary file not shown.
BIN
games/devtest/mods/gltf/invalid/json_missing_brace.gltf
Normal file
BIN
games/devtest/mods/gltf/invalid/json_missing_brace.gltf
Normal file
Binary file not shown.
2
games/devtest/mods/gltf/mod.conf
Normal file
2
games/devtest/mods/gltf/mod.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
name = gltf
|
||||
description = Hosts gltf test models, both for the C++ unit tests and for in-game viewing
|
||||
BIN
games/devtest/mods/gltf/models/gltf_blender_cube.gltf
Normal file
BIN
games/devtest/mods/gltf/models/gltf_blender_cube.gltf
Normal file
Binary file not shown.
Binary file not shown.
BIN
games/devtest/mods/gltf/models/gltf_blender_cube_scaled.gltf
Normal file
BIN
games/devtest/mods/gltf/models/gltf_blender_cube_scaled.gltf
Normal file
Binary file not shown.
BIN
games/devtest/mods/gltf/models/gltf_frog.gltf
Normal file
BIN
games/devtest/mods/gltf/models/gltf_frog.gltf
Normal file
Binary file not shown.
BIN
games/devtest/mods/gltf/models/gltf_minimal_triangle.gltf
Normal file
BIN
games/devtest/mods/gltf/models/gltf_minimal_triangle.gltf
Normal file
Binary file not shown.
BIN
games/devtest/mods/gltf/models/gltf_simple_sparse_accessor.gltf
Normal file
BIN
games/devtest/mods/gltf/models/gltf_simple_sparse_accessor.gltf
Normal file
Binary file not shown.
BIN
games/devtest/mods/gltf/models/gltf_snow_man.gltf
Normal file
BIN
games/devtest/mods/gltf/models/gltf_snow_man.gltf
Normal file
Binary file not shown.
BIN
games/devtest/mods/gltf/models/gltf_spider.gltf
Normal file
BIN
games/devtest/mods/gltf/models/gltf_spider.gltf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
games/devtest/mods/gltf/textures/gltf_cube.png
Normal file
BIN
games/devtest/mods/gltf/textures/gltf_cube.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 203 B |
BIN
games/devtest/mods/gltf/textures/gltf_frog.png
Normal file
BIN
games/devtest/mods/gltf/textures/gltf_frog.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 272 B |
BIN
games/devtest/mods/gltf/textures/gltf_snow_man.png
Normal file
BIN
games/devtest/mods/gltf/textures/gltf_snow_man.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 205 B |
BIN
games/devtest/mods/gltf/textures/gltf_spider.png
Normal file
BIN
games/devtest/mods/gltf/textures/gltf_spider.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Reference in New Issue
Block a user