add start of animation class
This commit is contained in:
parent
de2ad2a02d
commit
d8542c24fa
3 changed files with 64 additions and 1 deletions
1
app.js
1
app.js
|
|
@ -275,6 +275,7 @@ const script = {
|
||||||
"mode/cam/driver",
|
"mode/cam/driver",
|
||||||
"mode/cam/client",
|
"mode/cam/client",
|
||||||
"mode/cam/tool",
|
"mode/cam/tool",
|
||||||
|
"mode/cam/animate",
|
||||||
"mode/laser/driver",
|
"mode/laser/driver",
|
||||||
"kiri/stacks",
|
"kiri/stacks",
|
||||||
"kiri/widget",
|
"kiri/widget",
|
||||||
|
|
|
||||||
62
src/mode/cam/animate.js
Normal file
62
src/mode/cam/animate.js
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
let KIRI = self.kiri,
|
||||||
|
BASE = self.base,
|
||||||
|
CAM = KIRI.driver.CAM,
|
||||||
|
PRO = CAM.process,
|
||||||
|
newPolygon = BASE.newPolygon,
|
||||||
|
newPoint = BASE.newPoint;
|
||||||
|
|
||||||
|
CAM.animate = function(API) {
|
||||||
|
const settings = API.conf.get();
|
||||||
|
const stock = settings.stock;
|
||||||
|
const center = stock.center;
|
||||||
|
|
||||||
|
console.log("animate", settings.stock);
|
||||||
|
|
||||||
|
const step = 2;
|
||||||
|
const stepsX = Math.floor(stock.x / step);
|
||||||
|
const stepsY = Math.floor(stock.y / step);
|
||||||
|
const gridPoints = stepsX * stepsY;
|
||||||
|
|
||||||
|
const mat = new THREE.LineBasicMaterial({
|
||||||
|
transparent: true,
|
||||||
|
opacity: 0.75,
|
||||||
|
color: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
const pos = new Float32Array(gridPoints * 3);
|
||||||
|
const ind = [];//new Array(stepsX * stepsY);
|
||||||
|
const ox = (stepsX * step) / 2;
|
||||||
|
const oy = (stepsY * step) / 2;
|
||||||
|
|
||||||
|
// initialize grid points
|
||||||
|
for (let x=0, ai=0; x<stepsX; x++) {
|
||||||
|
for (let y=0; y<stepsY; y++) {
|
||||||
|
pos[ai++] = x * step - ox;
|
||||||
|
pos[ai++] = y * step - oy;
|
||||||
|
pos[ai++] = stock.z;
|
||||||
|
if (y > 0) ind.appendAll([
|
||||||
|
(stepsY * x) + (y - 1),
|
||||||
|
(stepsY * x) + (y )
|
||||||
|
]);
|
||||||
|
if (x > 0) ind.appendAll([
|
||||||
|
(stepsY * (x - 1)) + y,
|
||||||
|
(stepsY * (x )) + y
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
function animate() {
|
function animate() {
|
||||||
API.view.set(VIEWS.ARRANGE);
|
API.view.set(VIEWS.ARRANGE);
|
||||||
API.widgets.opacity(0.75);
|
API.widgets.opacity(0.75);
|
||||||
// console.log("animate", API.conf.get().stock);
|
CAM.animate(API);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateStock(args, event) {
|
function updateStock(args, event) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue