move animation setup into worker
This commit is contained in:
parent
bd160cdd71
commit
eaf2cdb668
3 changed files with 34 additions and 36 deletions
|
|
@ -251,7 +251,8 @@
|
|||
},
|
||||
hide: {
|
||||
alert: function(rec) { alert2cancel(rec) },
|
||||
import: function() { }
|
||||
import: function() { },
|
||||
slider: hideSlider
|
||||
},
|
||||
language: KIRI.lang,
|
||||
lists,
|
||||
|
|
@ -672,13 +673,12 @@
|
|||
function showSlider() {
|
||||
UI.layers.style.display = 'flex';
|
||||
UI.slider.style.display = 'flex';
|
||||
// UI.setMenu.style.display = 'none';
|
||||
}
|
||||
|
||||
function hideSlider(andmenu) {
|
||||
UI.layers.style.display = 'none';
|
||||
UI.slider.style.display = 'none';
|
||||
// UI.setMenu.style.display = andmenu ? 'none' : 'flex';
|
||||
UI.speeds.style.display = 'none';
|
||||
}
|
||||
|
||||
function updateSpeeds(maxSpeed) {
|
||||
|
|
|
|||
|
|
@ -13,23 +13,40 @@ kiri.loader.push(function() {
|
|||
|
||||
if (KIRI.client)
|
||||
CAM.animate = function(API) {
|
||||
const settings = API.conf.get();
|
||||
const stock = settings.stock;
|
||||
const center = stock.center;
|
||||
|
||||
console.log("animate", settings.stock);
|
||||
|
||||
const step = 1;
|
||||
const stepsX = Math.floor(stock.x / step) + 1;
|
||||
const stepsY = Math.floor(stock.y / step) + 1;
|
||||
const gridPoints = stepsX * stepsY;
|
||||
KIRI.client.animate(API.conf.get(), data => {
|
||||
const { ind, pos } = data;
|
||||
|
||||
const geo = new THREE.BufferGeometry();
|
||||
geo.setAttribute('position', new THREE.BufferAttribute(pos, 3));
|
||||
geo.setIndex(new THREE.BufferAttribute(new Uint16Array(ind), 1));
|
||||
const mat = new THREE.LineBasicMaterial({
|
||||
transparent: true,
|
||||
opacity: 0.75,
|
||||
color: 0
|
||||
});
|
||||
const seg = new THREE.LineSegments(geo, mat);
|
||||
|
||||
API.const.SPACE.platform.world.add(seg);
|
||||
});
|
||||
};
|
||||
|
||||
if (KIRI.client)
|
||||
KIRI.client.animate = function(settings, ondone) {
|
||||
send("animate", {settings}, reply => {
|
||||
ondone(reply);
|
||||
});
|
||||
};
|
||||
|
||||
if (KIRI.worker)
|
||||
KIRI.worker.animate = function(data, send) {
|
||||
console.log({current});
|
||||
const { settings } = data;
|
||||
const stock = settings.stock;
|
||||
const center = stock.center;
|
||||
const step = 1;
|
||||
const stepsX = Math.floor(stock.x / step) + 1;
|
||||
const stepsY = Math.floor(stock.y / step) + 1;
|
||||
const gridPoints = stepsX * stepsY;
|
||||
const pos = new Float32Array(gridPoints * 3);
|
||||
const ind = [];
|
||||
const ox = stock.x / 2;
|
||||
|
|
@ -52,27 +69,7 @@ kiri.loader.push(function() {
|
|||
}
|
||||
}
|
||||
|
||||
const geo = new THREE.BufferGeometry();
|
||||
geo.setAttribute('position', new THREE.BufferAttribute(pos, 3));
|
||||
geo.setIndex(new THREE.BufferAttribute(new Uint16Array(ind), 1));
|
||||
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});
|
||||
send.done({ pos, ind });
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -72,8 +72,9 @@
|
|||
};
|
||||
|
||||
function animate() {
|
||||
API.view.set(VIEWS.ARRANGE);
|
||||
API.widgets.opacity(0.75);
|
||||
API.hide.slider();
|
||||
STACKS.clear();
|
||||
CAM.animate(API);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue