setup animate for client/worker merged module

This commit is contained in:
Stewart Allen 2020-11-24 00:37:44 -05:00
commit bd160cdd71
3 changed files with 26 additions and 9 deletions

1
app.js
View file

@ -329,6 +329,7 @@ const script = {
"mode/cam/slice",
"mode/cam/prepare",
"mode/cam/export",
"mode/cam/animate",
"mode/laser/driver",
"kiri/widget",
"kiri/print",

View file

@ -17,7 +17,7 @@ self.alert = function(o) {
console.log(o);
};
console.log(`kiri | init work | ${KIRI.version}`);
console.log(`kiri | init work | ${KIRI.version || "rogue"}`);
BASE.debug.disable();
// code is running in the worker / server context

View file

@ -2,7 +2,7 @@
"use strict";
(function() {
kiri.loader.push(function() {
let KIRI = self.kiri,
BASE = self.base,
@ -11,6 +11,7 @@
newPolygon = BASE.newPolygon,
newPoint = BASE.newPoint;
if (KIRI.client)
CAM.animate = function(API) {
const settings = API.conf.get();
const stock = settings.stock;
@ -18,9 +19,9 @@
console.log("animate", settings.stock);
const step = 2;
const stepsX = Math.floor(stock.x / step);
const stepsY = Math.floor(stock.y / step);
const step = 1;
const stepsX = Math.floor(stock.x / step) + 1;
const stepsY = Math.floor(stock.y / step) + 1;
const gridPoints = stepsX * stepsY;
const mat = new THREE.LineBasicMaterial({
@ -30,9 +31,9 @@
});
const pos = new Float32Array(gridPoints * 3);
const ind = [];//new Array(stepsX * stepsY);
const ox = (stepsX * step) / 2;
const oy = (stepsY * step) / 2;
const ind = [];
const ox = stock.x / 2;
const oy = stock.y / 2;
// initialize grid points
for (let x=0, ai=0; x<stepsX; x++) {
@ -57,6 +58,21 @@
const seg = new THREE.LineSegments(geo, mat);
API.const.SPACE.platform.world.add(seg);
KIRI.client.animate(123);
};
})();
if (KIRI.client)
KIRI.client.animate = function(abc) {
send("animate", {abc}, reply => {
console.log('client.animate.results', reply);
});
};
if (KIRI.worker)
KIRI.worker.animate = function(data, send) {
console.log('worker.animate', data);
send.done({def:456});
};
});