Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
aimoonchen committed Jan 17, 2024
1 parent c7bf9ac commit 532d228
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 44 deletions.
4 changes: 1 addition & 3 deletions pkg/ant.modifier/modifier.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ function imodifier.set_target(m, target)
if not filename then
return
end
if string.find(filename, ".glb|") then
filename = filename .. "/source.ant"
end
filename = filename .. "/source.ant"
local mtl = serialize.parse(filename, aio.readall(filename))
if not mtl.properties[mf.property] then
return
Expand Down
37 changes: 2 additions & 35 deletions tools/editor/pkg/tools.editor/gui_system.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ local hierarchy_event = world:sub {"HierarchyEvent"}
local entity_event = world:sub {"EntityEvent"}
local event_keyboard = world:sub {"keyboard"}
local event_open_file = world:sub {"OpenFile"}
local event_open_proj = world:sub {"OpenProject"}
local event_add_prefab = world:sub {"AddPrefabOrEffect"}
local event_resource_browser= world:sub {"ResourceBrowser"}
local event_window_title = world:sub {"WindowTitle"}
Expand Down Expand Up @@ -158,10 +157,7 @@ end
local function on_update(eid)
world:pub {"UpdateAABB", eid}
if not eid then return end
local e <close> = world:entity(eid, "camera?in light?in")
-- if e.camera then
-- camera_mgr.update_frustrum(eid)
-- else
local e <close> = world:entity(eid, "light?in")
if e and e.light then
light_gizmo.update()
end
Expand Down Expand Up @@ -224,7 +220,7 @@ local function update_visible(node, visible)
end
return rv
end
local test_prefab

function m:handle_event()
for _, e in event_update_aabb:unpack() do
update_highlight_aabb(e)
Expand Down Expand Up @@ -308,10 +304,6 @@ function m:handle_event()
end
end

-- for _ in event_open_proj:unpack() do
-- on_open_proj()
-- end

for _, filename, isprefab in event_open_file:unpack() do
if isprefab then
prefab_mgr:open(filename)
Expand Down Expand Up @@ -349,33 +341,8 @@ function m:handle_event()
if gizmo.target_eid then
world:pub { "HierarchyEvent", "delete", gizmo.target_eid }
end
-- elseif state.CTRL and key == "O" and press == 1 then
-- on_open_proj()
elseif state.CTRL and key == "S" and press == 1 then
prefab_mgr:save()
elseif state.CTRL and key == "T" and press == 1 then
if not test_prefab then
test_prefab = world:create_instance {
prefab = "/pkg/vaststars.resources/glbs/chemical-plant-1.glb|work_start.prefab",
-- prefab = "/pkg/vaststars.resources/glbs/chimney-1.glb|work.prefab",
on_ready = function (instance)
for _, eid in ipairs(instance.tag["*"]) do
local e <close> = world:entity(eid, "timeline?in")
if e.timeline then
e.timeline.eid_map = instance.tag
end
end
end
}
else
for _, eid in ipairs(test_prefab.tag["*"]) do
local e <close> = world:entity(eid, "timeline?in")
if e.timeline then
w:extend(e, "start_timeline?out")
e.start_timeline = true
end
end
end
end
end
for _, what, type in event_create:unpack() do
Expand Down
20 changes: 14 additions & 6 deletions tools/editor/pkg/tools.editor/widget/keyframe_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ local imodifier = ecs.require "ant.modifier|modifier"
local ika = ecs.require "ant.anim_ctrl|keyframe"
local faicons = require "common.fa_icons"
local prefab_mgr = ecs.require "prefab_manager"
local gd = require "common.global_data"
local m = {}
local current_mtl
local current_target
Expand Down Expand Up @@ -1174,7 +1175,8 @@ function m.show()
end
imgui.windows.End()
end

local memfs = import_package "ant.vfs".memory
local lfs = require "bee.filesystem"
function m.save(path)
if not next(allanims) then
return
Expand Down Expand Up @@ -1216,15 +1218,23 @@ function m.save(path)
end
utils.write_file(filename, stringify(animdata))
if isSke then
local bin_file = filename:sub(1, -5) .. "bin"
local mount = false
local lpath = lfs.path(bin_file)
if not lfs.exists(lpath) then
mount = true
end
local e <close> = world:entity(anim_eid, "animation:in")
ozz.save(e.animation.status[current_anim.name].handle, filename:sub(1, -5) .. "bin")
ozz.save(e.animation.status[current_anim.name].handle, bin_file)
if mount then
memfs.update("/" .. lfs.relative(lpath, gd.project_root):string(), lpath:string())
end
end
if file_path ~= filename then
file_path = filename
end
end

local lfs = require "bee.filesystem"
local datalist = require "datalist"
local serialize = import_package "ant.serialize"
function m.load(path)
Expand Down Expand Up @@ -1296,9 +1306,7 @@ function m.create_target_animation(at, target)
elseif at == "mtl" then
local mtlpath = e.material
if mtlpath then
if string.find(e.material, ".glb|") then
mtlpath = mtlpath .. "/source.ant"
end
mtlpath = mtlpath .. "/source.ant"
local desc = {}
local mtl = serialize.parse(mtlpath, aio.readall(mtlpath))
local keys = {}
Expand Down

0 comments on commit 532d228

Please sign in to comment.