add gapp dependency, start annotating files accordingly
This commit is contained in:
parent
e0c2953a2a
commit
6eb7aa3897
22 changed files with 114 additions and 39 deletions
9
app.js
9
app.js
|
|
@ -222,6 +222,7 @@ function initModule(mod, file, dir) {
|
|||
|
||||
const script = {
|
||||
kiri : [
|
||||
"main/gapp",
|
||||
"main/kiri",
|
||||
"ext/three",
|
||||
"ext/three-bgu",
|
||||
|
|
@ -291,6 +292,7 @@ const script = {
|
|||
"@icons"
|
||||
],
|
||||
kiri_work : [
|
||||
"main/gapp",
|
||||
"main/kiri",
|
||||
"ext/three",
|
||||
"ext/pngjs",
|
||||
|
|
@ -343,6 +345,7 @@ const script = {
|
|||
"kiri/worker"
|
||||
],
|
||||
kiri_pool : [
|
||||
"main/gapp",
|
||||
"main/kiri",
|
||||
"moto/license",
|
||||
"ext/clip2",
|
||||
|
|
@ -369,6 +372,7 @@ const script = {
|
|||
"kiri/minion"
|
||||
],
|
||||
engine : [
|
||||
"main/gapp",
|
||||
"main/kiri",
|
||||
"moto/license",
|
||||
"data/local",
|
||||
|
|
@ -396,13 +400,16 @@ const script = {
|
|||
"kiri/engine"
|
||||
],
|
||||
frame : [
|
||||
"main/gapp",
|
||||
"kiri/frame"
|
||||
],
|
||||
meta : [
|
||||
"main/gapp",
|
||||
"main/meta",
|
||||
"moto/license",
|
||||
],
|
||||
mesh : [
|
||||
"main/gapp",
|
||||
"moto/client",
|
||||
"moto/license",
|
||||
"moto/broker",
|
||||
|
|
@ -425,6 +432,7 @@ const script = {
|
|||
"main/mesh"
|
||||
],
|
||||
mesh_work : [
|
||||
"main/gapp",
|
||||
"moto/client",
|
||||
"moto/worker",
|
||||
"moto/license",
|
||||
|
|
@ -449,6 +457,7 @@ const script = {
|
|||
"mesh/work"
|
||||
],
|
||||
mesh_pool : [
|
||||
"main/gapp",
|
||||
"moto/worker",
|
||||
"moto/license",
|
||||
"mesh/pool"
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
(function() {
|
||||
|
||||
gapp.register('data.index');
|
||||
|
||||
let data = self.data = self.data || {};
|
||||
if (data.Index) return;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
(function() {
|
||||
|
||||
gapp.register('data.local');
|
||||
|
||||
let data = self.data = self.data || {};
|
||||
if (data.Local) return;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
SETUP = parseOpt(LOC.search.substring(1)),
|
||||
SECURE = isSecure(LOC.protocol),
|
||||
LOCAL = self.debug && !SETUP.remote,
|
||||
EVENT = KIRI.broker,
|
||||
EVENT = KIRI.broker = gapp.broker,
|
||||
SDB = DATA.Local,
|
||||
ODB = KIRI.odb = new DATA.Index(SETUP.d ? SETUP.d[0] : 'kiri'),
|
||||
// K3DB = KIRI.wdb = new DATA.Index('kiri3', { stores:["file","work"] }).init(),
|
||||
|
|
@ -56,6 +56,7 @@
|
|||
alerts = [],
|
||||
grouping = false,
|
||||
saveTimer = null,
|
||||
version = KIRI.version = gapp.version,
|
||||
noop = () => {};
|
||||
|
||||
// add show() to catalog for API
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ if (concurrent) {
|
|||
minion.onmessage = minhandler;
|
||||
minions.push(minion);
|
||||
}
|
||||
console.log(`kiri | init pool | ${KIRI.version || "rogue"} | ${concurrent + 1}`);
|
||||
console.log(`kiri | init pool | ${gapp.version || "rogue"} | ${concurrent + 1}`);
|
||||
}
|
||||
|
||||
// for concurrent operations
|
||||
|
|
@ -185,7 +185,7 @@ KIRI.minions = {
|
|||
}
|
||||
};
|
||||
|
||||
console.log(`kiri | init work | ${KIRI.version || "rogue"}`);
|
||||
console.log(`kiri | init work | ${gapp.version || "rogue"}`);
|
||||
|
||||
// code is running in the worker / server context
|
||||
const dispatch =
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
let load = self.load = self.load || {};
|
||||
if (load.TMF) return;
|
||||
|
||||
gapp.register('load.3mf');
|
||||
|
||||
load.TMF = {
|
||||
parseAsync
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
let load = self.load = self.load || {};
|
||||
if (load.File) return;
|
||||
|
||||
gapp.register('load.file');
|
||||
|
||||
load.File = {
|
||||
load_data, load_data,
|
||||
load: load_file
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
let load = self.load = self.load || {};
|
||||
if (load.OBJ) return;
|
||||
|
||||
gapp.register('load.obj');
|
||||
|
||||
load.OBJ = {
|
||||
parse,
|
||||
parseAsync
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
let load = self.load = self.load || {};
|
||||
if (load.STL) return;
|
||||
|
||||
gapp.register('load.stl');
|
||||
|
||||
const SP = STL.prototype;
|
||||
const CDH = 'Content-Disposition';
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
let load = self.load = self.load || {};
|
||||
if (load.SVG) return;
|
||||
|
||||
gapp.register('load.svg');
|
||||
|
||||
load.SVG = {
|
||||
parse,
|
||||
parseAsync
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
let load = self.load = self.load || {};
|
||||
if (load.URL) return;
|
||||
|
||||
gapp.register('load.url');
|
||||
|
||||
load.URL = {
|
||||
load: load_url
|
||||
};
|
||||
|
|
@ -84,4 +86,4 @@ function load_url(url, options = {}) {
|
|||
});
|
||||
};
|
||||
|
||||
})();
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
(function () {
|
||||
|
||||
if (!self.kiri) {
|
||||
let kiri = self.gapp = self.kiri = {
|
||||
let kiri = self.kiri = {
|
||||
beta: 3111,
|
||||
driver: {}, // driver modules
|
||||
loader: [], // module loading: array of functions
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// some ui helpers that need to go into a ui class
|
||||
function $(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
|
|
@ -21,8 +22,7 @@ function estop(evt) {
|
|||
|
||||
(function() {
|
||||
|
||||
let DOC = document,
|
||||
WIN = window;
|
||||
let broker = gapp.broker;
|
||||
|
||||
function init() {
|
||||
let moto = self.moto,
|
||||
|
|
@ -32,8 +32,7 @@ function init() {
|
|||
zoomrev = true,
|
||||
zoomspd = 1,
|
||||
space = moto.Space,
|
||||
platform = space.platform,
|
||||
platcolor = 0x00ff00;
|
||||
platform = space.platform;
|
||||
|
||||
// setup default workspace
|
||||
space.sky.set({
|
||||
|
|
@ -55,26 +54,8 @@ function init() {
|
|||
space.view.setZoom(zoomrev, zoomspd);
|
||||
space.useDefaultKeys(true);
|
||||
|
||||
// add file drop handler
|
||||
space.event.addHandlers(self, [
|
||||
'drop', (evt) => {
|
||||
estop(evt);
|
||||
platform.setColor(platcolor);
|
||||
load.File.load(evt.dataTransfer.files[0])
|
||||
.then(data => {
|
||||
console.log({data});
|
||||
})
|
||||
},
|
||||
'dragover', (evt) => {
|
||||
estop(evt);
|
||||
evt.dataTransfer.dropEffect = 'copy';
|
||||
let color = platform.setColor(0x00ff00);
|
||||
if (color !== 0x00ff00) platcolor = color;
|
||||
},
|
||||
'dragleave', (evt) => {
|
||||
platform.setColor(platcolor);
|
||||
}
|
||||
]);
|
||||
// trigger space event binding
|
||||
broker.publish('space.init', { space, platform });
|
||||
|
||||
// start worker
|
||||
moto.client.start(`/code/mesh_work?${gapp.version}`);
|
||||
|
|
@ -87,14 +68,57 @@ function init() {
|
|||
$d('curtain','none');
|
||||
}
|
||||
|
||||
// add space event bindings
|
||||
broker.subscribe('space.init', data => {
|
||||
let { space, platform } = data;
|
||||
let platcolor = 0x00ff00;
|
||||
// add file drop handler
|
||||
space.event.addHandlers(self, [
|
||||
'drop', (evt) => {
|
||||
estop(evt);
|
||||
platform.setColor(platcolor);
|
||||
load.File.load(evt.dataTransfer.files[0])
|
||||
.then(data => {
|
||||
broker.publish('space.load', data);
|
||||
})
|
||||
.catch(error => {
|
||||
dbug.error(error);
|
||||
})
|
||||
.finally(() => {
|
||||
// hide spinner
|
||||
});
|
||||
},
|
||||
'dragover', evt => {
|
||||
estop(evt);
|
||||
evt.dataTransfer.dropEffect = 'copy';
|
||||
let color = platform.setColor(0x00ff00);
|
||||
if (color !== 0x00ff00) platcolor = color;
|
||||
},
|
||||
'dragleave', evt => {
|
||||
platform.setColor(platcolor);
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
// add object loader
|
||||
broker.subscribe('space.load', data => {
|
||||
console.log({space_load: data});
|
||||
});
|
||||
|
||||
// remove version cache bust from url
|
||||
WIN.history.replaceState({},'','/mesh/');
|
||||
window.history.replaceState({},'','/mesh/');
|
||||
|
||||
// setup init() trigger when dom + scripts complete
|
||||
DOC.onreadystatechange = function() {
|
||||
if (DOC.readyState === 'complete') {
|
||||
document.onreadystatechange = function() {
|
||||
if (document.readyState === 'complete') {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
// finalize modules
|
||||
gapp.finalize("main.mesh", [
|
||||
"moto.broker",
|
||||
"moto.space"
|
||||
]);
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
(function () {
|
||||
|
||||
let meta = self.meta = self.gapp = self.gapp || {},
|
||||
let meta = self.meta = self.meta || {},
|
||||
DOC = document;
|
||||
|
||||
DOC.onreadystatechange = function() {
|
||||
|
|
|
|||
|
|
@ -4,4 +4,6 @@
|
|||
|
||||
(function() {
|
||||
|
||||
gapp.finalize("mesh.pool");
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@
|
|||
|
||||
(function() {
|
||||
|
||||
// start worker pool
|
||||
moto.client.start(`/code/mesh_pool?${gapp.version}`, moto.client.max());
|
||||
// start worker pool (disabled for now with *0)
|
||||
moto.client.start(`/code/mesh_pool?${gapp.version}`, moto.client.max() * 0);
|
||||
|
||||
gapp.finalize("mesh.work");
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
(function() {
|
||||
|
||||
gapp.register('moto.ajax');
|
||||
|
||||
let moto = self.moto = self.moto || {};
|
||||
if (moto.Ajax) return;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,15 @@
|
|||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||
|
||||
"use strict";
|
||||
|
||||
(function() {
|
||||
|
||||
if (gapp.broker) return;
|
||||
|
||||
class Broker {
|
||||
constructor() {
|
||||
this.topics = {};
|
||||
this.used = {};
|
||||
}
|
||||
|
||||
topics() {
|
||||
|
|
@ -51,6 +60,9 @@ class Broker {
|
|||
if (topic !== ".topic.publish") {
|
||||
this.publish(".topic.publish", {topic, message, options});
|
||||
}
|
||||
// store last seen message on a topic
|
||||
// acts as a tracker for all used topics
|
||||
this.used[topic] = message;
|
||||
let channel = this.topics[topic];
|
||||
if (channel && channel.length) {
|
||||
for (let listener of channel) {
|
||||
|
|
@ -61,6 +73,8 @@ class Broker {
|
|||
setTimeout(() => { throw e }, 1);
|
||||
}
|
||||
}
|
||||
} else if (topic.indexOf(".topic.") < 0) {
|
||||
dbug.debug(`undelivered '${topic}'`, message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -73,8 +87,7 @@ class Broker {
|
|||
}
|
||||
}
|
||||
|
||||
// establish default broker when GridApp container present
|
||||
let gapp = self.gapp;
|
||||
if (gapp && !gapp.broker) {
|
||||
gapp.broker = new Broker();
|
||||
}
|
||||
gapp.broker = new Broker();
|
||||
gapp.register('moto.broker');
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
|
||||
(function() {
|
||||
|
||||
let gapp = self.gapp = self.gapp || {},
|
||||
moto = self.moto = self.moto || gapp,
|
||||
let moto = self.moto = self.moto || {},
|
||||
ccvalue = self.navigator ? navigator.hardwareConcurrency || 1 : 1,
|
||||
ccmax = ccvalue > 3 ? ccvalue - 1 : 0,
|
||||
workcc = false, // concurrent or not
|
||||
|
|
@ -16,6 +15,8 @@ let gapp = self.gapp = self.gapp || {},
|
|||
|
||||
if (moto.client) return;
|
||||
|
||||
gapp.register('moto.client');
|
||||
|
||||
// code is running in the browser / client context
|
||||
let client = moto.client = {
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,12 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
(function() {
|
||||
|
||||
let MOTO = self.moto = self.moto || {};
|
||||
|
||||
gapp.register('moto.orbit');
|
||||
|
||||
/**
|
||||
* Adapted from THREE.OrbitControls
|
||||
*/
|
||||
|
|
@ -621,3 +625,5 @@ MOTO.Orbit = function (object, domElement, notify, slider) {
|
|||
};
|
||||
|
||||
MOTO.Orbit.prototype = Object.create(THREE.EventDispatcher.prototype);
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
"use strict";
|
||||
|
||||
(function() {
|
||||
gapp.register('moto.space');
|
||||
|
||||
let MOTO = self.moto = self.moto || {},
|
||||
WIN = window,
|
||||
|
|
|
|||
|
|
@ -4,13 +4,11 @@
|
|||
|
||||
(function() {
|
||||
|
||||
let gapp = self.gapp = self.gapp || {},
|
||||
moto = self.moto = self.moto || gapp;
|
||||
let moto = self.moto = self.moto || {};
|
||||
|
||||
if (moto.worker) return;
|
||||
|
||||
// allow license to inject module
|
||||
self.gapp = self.gapp || moto;
|
||||
gapp.register('moto.worker');
|
||||
|
||||
let endpoints = {};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue