#
luxiaotao1123
2021-12-15 1f7585d8c4cc86f0a1e6d3d62188e88698b57089
#
2个文件已修改
41 ■■■■ 已修改文件
static/js/app.js 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
static/js/object/CrnTask.js 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
static/js/app.js
@@ -42,7 +42,8 @@
            this.stats.end();
            // this.queryTask();
            this.queryCrn();
            this.modelMove();
            // this.modelMove();
            this.crnMove();
        }
        this.initScene = function () {
            this.scene = new THREE.Scene();
@@ -280,7 +281,7 @@
                for (let crnData of CrnDatas) {
                    let crnTask = getArrVal(this.crnTasks, "crnNo", crnData.crnNo);
                    if (null == crnTask) {
                        this.crnTasks.push(new CrnTask(crnData));
                        this.crnTasks.push(new CrnTask(crnData, this));
                    } else {
                        if(!crnTask.run) {
                            crnTask.modify(crnData);
@@ -400,6 +401,11 @@
                }
            }
        }
        this.crnMove = function (object) {
            for (let crnTask of this.crnTasks) {
                crnTask.move(this);
            }
        }
    },
};
static/js/object/CrnTask.js
@@ -1,5 +1,5 @@
// 堆垛机当前运行状态对象
function CrnTask(crnData) {
function CrnTask(crnData, object) {
    let that = this;
    that.crnNo = 0;
@@ -21,6 +21,10 @@
    that.position = null;
    that.forkPos = -1;
    that.crnBody = null;
    that.curve = null;
    that.progress = 0;
    let init = function () {
        that.crnNo = crnData.crnNo;
        that.bay = crnData.bay;
@@ -30,6 +34,8 @@
        that.z = crnData.position.z;
        that.position = crnData.position;
        that.forkPos = crnData.forkPos;
        that.crnBody = getArrVal(object.objects, "name", that.crnNo + "-body")
    };
    init();
@@ -57,12 +63,27 @@
            that.position = crnData.position;
            that.forkPos = crnData.forkPos;
            // create Route ------------------------------------------------
            let bodyRoute = new Route([that.prePosition, that.position]);    // body
            that.curve = new Route([that.prePosition, that.position]);    // body
            // new Route();    // load
            // console.log(bodyRoute);
            // console.log("pre" + JSON.stringify(that.prePosition));
            // console.log(JSON.stringify(that.position));
            // that.run = true;
            console.log("pre" + JSON.stringify(that.prePosition));
            console.log(JSON.stringify(that.position));
            that.run = true;
        }
    }
    that.move = function (object) {
        if (that.curve) {
            that.progress += 0.001;
            if (that.progress>1.0) {
                that.curve = null;
            } else {
                let point = that.curve.getPoint(that.progress);
                if(point && point.x){
                    that.crnBody.position.set(point.x,point.y,point.z);
                }
            }
        }
    }