26 lines
736 B
Lua
26 lines
736 B
Lua
local api = ...
|
|
local ecs = api.ecs
|
|
|
|
return {
|
|
name = "3DFile",
|
|
enabled = true,
|
|
|
|
onURI = function(obj)
|
|
if( obj.URL ~= nil and obj.URLResponse ~= nil and
|
|
(obj.URL.extension == 'GLB' or
|
|
obj.URL.extension == 'GLTF' or
|
|
obj.URL.extension == 'OBJ')) then
|
|
if obj.URLResponse.ok then
|
|
obj.model = api.graphics.newModel( api.data.newBlob( obj.URLResponse.data) )
|
|
obj.root = (obj.URI.target == '_top')
|
|
if obj.x == nil then obj.x = 0 end
|
|
if obj.y == nil then obj.y = 0 end
|
|
if obj.z == nil then obj.z = 0 end
|
|
obj.commit('on3DFile') -- notify systems
|
|
else
|
|
print("[3DFile] error: could not load " .. obj.URL.string )
|
|
end
|
|
end
|
|
end
|
|
|
|
}
|