experiment with namespace loading
This commit is contained in:
parent
5601760329
commit
d4f2ac21bd
4 changed files with 40 additions and 37 deletions
|
|
@ -63,8 +63,22 @@ let mods = [];
|
|||
let modn = {};
|
||||
|
||||
// register module without a load function
|
||||
gapp.register = (name, deps) => {
|
||||
gapp.register = (name, deps, fn) => {
|
||||
gapp.load(undefined, name, deps);
|
||||
if (fn) {
|
||||
let toks = name.split('.');
|
||||
let root = self;
|
||||
let map = toks.pop();
|
||||
for (let tok of toks) {
|
||||
root = root[tok];
|
||||
if (!root) {
|
||||
console.log({missing_root: tok, at: name});
|
||||
root = root[tok] = {};
|
||||
}
|
||||
}
|
||||
map = root[map] = root[map] || {};
|
||||
fn(self, exports => Object.assign(map, exports));
|
||||
}
|
||||
};
|
||||
|
||||
// register module with a load function
|
||||
|
|
|
|||
|
|
@ -7,15 +7,13 @@
|
|||
let broker = gapp.broker;
|
||||
let call = broker.send;
|
||||
let dbindex = [ "admin", "space" ];
|
||||
let worker = moto.client.fn;
|
||||
let { Quaternion, Vector3, Mesh, MeshPhongMaterial, PlaneGeometry, DoubleSide } = THREE;
|
||||
let { Quaternion, Mesh, MeshPhongMaterial, PlaneGeometry, DoubleSide } = THREE;
|
||||
|
||||
// set below. called once the DOM readyState = complete
|
||||
// this is the main() entrypoint called after all dependents load
|
||||
function init() {
|
||||
let stores = data.open('mesh', { stores: dbindex, version: 4 }).init(),
|
||||
moto = self.moto,
|
||||
api = mesh.api,
|
||||
dark = false,
|
||||
ortho = false,
|
||||
zoomrev = true,
|
||||
|
|
@ -403,7 +401,7 @@ function space_init(data) {
|
|||
if (metaKey) {
|
||||
// set focus on intersected face
|
||||
let { x, y, z } = int.point;
|
||||
let q = new THREE.Quaternion().setFromRotationMatrix(group.object.matrix);
|
||||
let q = new Quaternion().setFromRotationMatrix(group.object.matrix);
|
||||
// rotate normal using group's matrix
|
||||
let normal = int.face.normal.applyQuaternion(q);
|
||||
// y,z swap due to world rotation for orbit controls
|
||||
|
|
|
|||
Loading…
Reference in a new issue