setup animate for client/worker merged module
This commit is contained in:
parent
d8542c24fa
commit
bd160cdd71
3 changed files with 26 additions and 9 deletions
1
app.js
1
app.js
|
|
@ -329,6 +329,7 @@ const script = {
|
||||||
"mode/cam/slice",
|
"mode/cam/slice",
|
||||||
"mode/cam/prepare",
|
"mode/cam/prepare",
|
||||||
"mode/cam/export",
|
"mode/cam/export",
|
||||||
|
"mode/cam/animate",
|
||||||
"mode/laser/driver",
|
"mode/laser/driver",
|
||||||
"kiri/widget",
|
"kiri/widget",
|
||||||
"kiri/print",
|
"kiri/print",
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ self.alert = function(o) {
|
||||||
console.log(o);
|
console.log(o);
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(`kiri | init work | ${KIRI.version}`);
|
console.log(`kiri | init work | ${KIRI.version || "rogue"}`);
|
||||||
BASE.debug.disable();
|
BASE.debug.disable();
|
||||||
|
|
||||||
// code is running in the worker / server context
|
// code is running in the worker / server context
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
(function() {
|
kiri.loader.push(function() {
|
||||||
|
|
||||||
let KIRI = self.kiri,
|
let KIRI = self.kiri,
|
||||||
BASE = self.base,
|
BASE = self.base,
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
newPolygon = BASE.newPolygon,
|
newPolygon = BASE.newPolygon,
|
||||||
newPoint = BASE.newPoint;
|
newPoint = BASE.newPoint;
|
||||||
|
|
||||||
|
if (KIRI.client)
|
||||||
CAM.animate = function(API) {
|
CAM.animate = function(API) {
|
||||||
const settings = API.conf.get();
|
const settings = API.conf.get();
|
||||||
const stock = settings.stock;
|
const stock = settings.stock;
|
||||||
|
|
@ -18,9 +19,9 @@
|
||||||
|
|
||||||
console.log("animate", settings.stock);
|
console.log("animate", settings.stock);
|
||||||
|
|
||||||
const step = 2;
|
const step = 1;
|
||||||
const stepsX = Math.floor(stock.x / step);
|
const stepsX = Math.floor(stock.x / step) + 1;
|
||||||
const stepsY = Math.floor(stock.y / step);
|
const stepsY = Math.floor(stock.y / step) + 1;
|
||||||
const gridPoints = stepsX * stepsY;
|
const gridPoints = stepsX * stepsY;
|
||||||
|
|
||||||
const mat = new THREE.LineBasicMaterial({
|
const mat = new THREE.LineBasicMaterial({
|
||||||
|
|
@ -30,9 +31,9 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
const pos = new Float32Array(gridPoints * 3);
|
const pos = new Float32Array(gridPoints * 3);
|
||||||
const ind = [];//new Array(stepsX * stepsY);
|
const ind = [];
|
||||||
const ox = (stepsX * step) / 2;
|
const ox = stock.x / 2;
|
||||||
const oy = (stepsY * step) / 2;
|
const oy = stock.y / 2;
|
||||||
|
|
||||||
// initialize grid points
|
// initialize grid points
|
||||||
for (let x=0, ai=0; x<stepsX; x++) {
|
for (let x=0, ai=0; x<stepsX; x++) {
|
||||||
|
|
@ -57,6 +58,21 @@
|
||||||
const seg = new THREE.LineSegments(geo, mat);
|
const seg = new THREE.LineSegments(geo, mat);
|
||||||
|
|
||||||
API.const.SPACE.platform.world.add(seg);
|
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});
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue