add and bind file loading + api

This commit is contained in:
Stewart Allen 2022-01-06 17:28:57 -05:00
commit 06194a2415
5 changed files with 39 additions and 12 deletions

View file

@ -211,6 +211,7 @@ let model = {
}
};
// api is augmented in mesh.build
let api = mesh.api = {
clear() {
for (let group of group.list()) {
@ -245,6 +246,11 @@ let api = mesh.api = {
model,
import() {
// binding created in mesh.build
$('import').click();
},
objects() {
// return model objects suitable for finding ray intersections
return group.list().map(o => o.models).flat().map(o => o.object);

View file

@ -18,6 +18,7 @@ broker.listeners({
ui_build
});
// add modal dialog functions to api
let modal = mesh.api.modal = {
show(title, contents) {
h.bind($('modal'), contents);
@ -81,10 +82,18 @@ function ui_build() {
// create hotkey/action menu (top/left)
h.bind(actions, [
h.div([
h.button({ _: 'import' }),
// create and bind file loading elements
h.button({ _: 'import', onclick: api.import }, [
h.input({
id: "import", type: "file", class: ["hide"], multiple: true,
onchange(evt) { broker.send.load_files(evt.target.files) }
})
]),
h.button({ _: 'export' }),
h.div({ class: "vsep" }),
h.button({ _: 'analyze' }),
h.button({ _: 'repair' }),
h.div({ class: "vsep" }),
h.button({ _: 'wireframe', onclick() { api.wireframe() } }),
]),
]);