日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室(升级版)

發(fā)布時(shí)間:2023/12/13 综合教程 41 生活家
生活随笔 收集整理的這篇文章主要介紹了 如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室(升级版) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

很長一段時(shí)間沒有寫3D庫房,3D密集架相關(guān)的效果文章了,剛好最近有相關(guān)項(xiàng)目落地,索性總結(jié)一下

與之前我寫的3D庫房密集架文章《如何用webgl(three.js)搭建一個(gè)3D庫房,3D密集架,3D檔案室,-第二課》相比,本次做了一些效果上的升級(jí),以及更加貼合用戶應(yīng)用實(shí)際。

密集架庫房再檔案管理,土壤監(jiān)測,標(biāo)本存儲(chǔ)等各個(gè)行業(yè)應(yīng)用的比較多,從早期的貨架到后來的手搖式密集架再到現(xiàn)在的全自動(dòng)密集架,硬件上都做了升級(jí)改進(jìn)。

在環(huán)境、安防監(jiān)控這一塊,密集架方案提供商也配套的加上了八方感知,視頻監(jiān)控,溫濕度一體機(jī),自動(dòng)書架,智能門禁等各種設(shè)備。

這篇文章我們主要記錄講解使用webgl(three.js)實(shí)現(xiàn)3D可視化密集架方案以及實(shí)現(xiàn)代碼。

技術(shù)交流 1203193731@qq.com

交流微信:

    

如果你有什么要交流的心得 可郵件我

閑話少敘,我們進(jìn)入正題:

一、主庫房功能效果,以及其特效實(shí)現(xiàn)代碼

首先我們先看看庫房效果以及當(dāng)前實(shí)現(xiàn)的3d密集架的一些功能

1.1、主界面效果,這個(gè)庫房分了6個(gè)區(qū)域,多個(gè)房間拐角,后面我們還會(huì)展示一些拐角房間的內(nèi)部效果,那是一個(gè)虛擬展廳。效果如下:

1.2、選擇點(diǎn)擊密集架,可以看到當(dāng)前密集架的一些統(tǒng)計(jì)信息,例如面數(shù),層數(shù),節(jié)數(shù)(列),還有利用率等。

對(duì)于全自動(dòng)密集架,我們還可以通過協(xié)議對(duì)接,對(duì)密集架進(jìn)行控制,開架,打開通道,合架等。效果如下:

實(shí)現(xiàn)方式:

移動(dòng)密集架,合并密集架,重點(diǎn),難點(diǎn)在于計(jì)算密集架移動(dòng)距離,每次移動(dòng)密集架的個(gè)數(shù),以及記錄當(dāng)前密集架的位置

我才用的時(shí)分區(qū)計(jì)算,各個(gè)突破,通過配置文件的方式記錄固定架,以及每個(gè)架子的有效移動(dòng)方向

具體實(shí)現(xiàn)如下:

首先通過配置的方式,記錄每個(gè)架子的初始態(tài),對(duì)于一個(gè)庫房來說,不用寫邏輯代碼,直接配置還是比較方便的

var shelfAreas = [[11, 23, 13, 11, 23, 13, 25, 17]];
//固定列編號(hào)
var areasFixedCol = [
[[ 1], [12], [13], [1], [12], [13], [13], [9]]
];
//左移方向
var leftMoveDirect = [
[["x", -1], ["x", -1], ["x", -1],
["x", -1], ["x", -1], ["x", -1],
["x", -1], ["x", -1]]];

然后再通過寫通用方法,實(shí)現(xiàn)每個(gè)架子的移動(dòng)與合并方案

//互斥移動(dòng) 一次只能移動(dòng)一個(gè)區(qū)域單邊的架子
ModelBusiness.prototype.moveMjj = function (obj, dir, moveLength) {
    var _this = this;
    if (_this.moveState == 1) {
        layer.msg("有架子移動(dòng)中,請(qǐng)稍后");
        return;
    }
    _this.moveState = 1;
    var movemjjsParam = this.getNeedMoveMjjs(obj, dir);
    /*
        needMoveNubs: needMoveNubs, 
        needMoveMjjNames:needMoveMjjNames,
        directStr: driStr,
        directValue: directValue,
        onlyCanMoveValue: onlyCanMoveValue
    */
    if(movemjjsParam.directStr=="x"){
        movemjjsParam.directStrLager="X";
    }
    if(movemjjsParam.directStr=="z"){
        movemjjsParam.directStrLager="Z";
    }
    console.log(movemjjsParam);

    var moveMjjObjs = WT3DObj.commonFunc.findObjectsByNames(movemjjsParam.needMoveMjjNames);
    var canMoveRealObjs = [];//真正能移動(dòng)的架子
    $.each(moveMjjObjs, function (_index, _obj) {
        if (!_obj.oldPositionX) { _obj.oldPositionX = _obj.position.x; }
        if (!_obj.oldPositionZ) { _obj.oldPositionZ = _obj.position.z; }
        var movevalue=0;//該架子移動(dòng)前 已經(jīng)移動(dòng)了多少
        if( Math.abs(_obj.position[movemjjsParam.directStr]-_obj["oldPosition"+movemjjsParam.directStrLager])>10){
            movevalue=_obj.position[movemjjsParam.directStr]-_obj["oldPosition"+movemjjsParam.directStrLager];
        }
        if (movevalue == 0) {//如果未移動(dòng)過
            if (movemjjsParam.directValue == movemjjsParam.onlyCanMoveValue) {
                canMoveRealObjs.push(_obj);
            }
        } else {
            if (movemjjsParam.directValue != movemjjsParam.onlyCanMoveValue) {
                canMoveRealObjs.push(_obj);
            }
        }
    });
    console.log(canMoveRealObjs);
    var moveL = { length: 0 };
    $.each(canMoveRealObjs, function (_index, _obj) {
        _obj["currentValue" + movemjjsParam.directStr] = _obj.position[movemjjsParam.directStr];
    });
    new TWEEN.Tween(moveL).to({
        length: moveLength
    }, 200).onUpdate(function (a) {
        var _this = this;
        $.each(canMoveRealObjs, function (_index, _obj) {
            _obj.position[movemjjsParam.directStr] = _obj["currentValue" + movemjjsParam.directStr] + _this.length * movemjjsParam.directValue;
        });
    }).onComplete(function () {
        _this.moveState = 0;
    }).start();
}
//非互斥移動(dòng)
ModelBusiness.prototype.moveMjjAll = function (obj, dir, moveLength) {
    var _this = this;
    var movemjjsParam = this.getNeedMoveMjjs(obj, dir);
    /*
        needMoveNubs: needMoveNubs, 
        needMoveMjjNames:needMoveMjjNames,
        directStr: driStr,
        directValue: directValue,
        onlyCanMoveValue: onlyCanMoveValue
    */
    if (movemjjsParam.directStr == "x") {
        movemjjsParam.directStrLager = "X";
    }
    if (movemjjsParam.directStr == "z") {
        movemjjsParam.directStrLager = "Z";
    }
    console.log(movemjjsParam);

    var moveMjjObjs = WT3DObj.commonFunc.findObjectsByNames(movemjjsParam.needMoveMjjNames);
    var canMoveRealObjs = [];//真正能移動(dòng)的架子
    $.each(moveMjjObjs, function (_index, _obj) {
        if (!_obj.oldPositionX) { _obj.oldPositionX = _obj.position.x; }
        if (!_obj.oldPositionZ) { _obj.oldPositionZ = _obj.position.z; }
        var movevalue = 0;//該架子移動(dòng)前 已經(jīng)移動(dòng)了多少
        if (Math.abs(_obj.position[movemjjsParam.directStr] - _obj["oldPosition" + movemjjsParam.directStrLager]) > 10) {
            movevalue = _obj.position[movemjjsParam.directStr] - _obj["oldPosition" + movemjjsParam.directStrLager];
        }
        if (movevalue == 0) {//如果未移動(dòng)過
            if (movemjjsParam.directValue == movemjjsParam.onlyCanMoveValue) {
                canMoveRealObjs.push(_obj);
            }
        } else {
            if (movemjjsParam.directValue != movemjjsParam.onlyCanMoveValue) {
                canMoveRealObjs.push(_obj);
            }
        }
    });
    console.log(canMoveRealObjs);
    $.each(canMoveRealObjs, function (_index, _obj) {
        _obj.position[movemjjsParam.directStr] = _obj.position[movemjjsParam.directStr] + moveLength * movemjjsParam.directValue;
    });

    //new TWEEN.Tween(moveL).to({
    //    length: moveLength
    //}, 200).onUpdate(function (a) {
    //    var _this = this;
    //    $.each(canMoveRealObjs, function (_index, _obj) {
    //        _obj.position[movemjjsParam.directStr] = _obj["currentValue" + movemjjsParam.directStr] + _this.length * movemjjsParam.directValue;
    //    });
    //}).onComplete(function () {
    //}).start();
}
ModelBusiness.prototype.closeMJJ = function (obj,timelong,callBack) {
    var info = modelBusiness.getMJJBindRelationByModelId(obj.name);
    var maxColNub = info.maxColNub;
    var prefixName = obj.name.split("_")[0] + "_" + obj.name.split("_")[1] + "_";//前綴
    var mjjNames = [];
    for (var i = 1; i <= maxColNub; i++) {
        mjjNames.push(prefixName+i);
    }
    var moveMjjObjs = WT3DObj.commonFunc.findObjectsByNames(mjjNames);
    $.each(moveMjjObjs, function (_index,_obj) {
        new TWEEN.Tween(_obj.position).to({
            x: _obj.oldPositionX,
            z:_obj.oldPositionZ
        }, timelong ? timelong : 200).onComplete(function () {
            if (callBack) {
                callBack();
            }
        }).start();
    });
}

1.3、密集架支持通風(fēng),鎖定、解鎖、自檢等操作,并配有相關(guān)動(dòng)畫。效果如下:

這里我們通過導(dǎo)入通風(fēng)模型的方式來實(shí)現(xiàn),當(dāng)通風(fēng)打開時(shí),我們載入通風(fēng)動(dòng)畫模型,然后定時(shí)銷毀即可

實(shí)現(xiàn)如下:

//打開 1 關(guān)閉 0 通風(fēng)
ModelBusiness.prototype.windFunc = function (type,position) {
    var models = [{ "show": true, "uuid": "", "name": "flowtube_7", "objType": "flowTube", "points": [{ "x": -600, "y": 0, "z": 0 }, { "x": -300, "y": -350, "z": 0 }, { "x": 300, "y": -350, "z": null }, { "x": 600, "y": 0, "z": null }], "position": position, "scale": { "x": 1, "y": 1, "z": 1 }, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": Math.PI }, { "direction": "z", "degree": 0 }], "style": { "skinColor": 16772846, "imgurl": "../img/3dImg/right1.png", "opacity": 1, "canvasSkin": { "cwidth": 1024, "cheight": 128, "cwNub": 8, "chNub": 12, "cMarginW": 0.2, "cMarginH": 0.2, "speed": 8, "fps": 20, "direction": "w", "forward": "f", "side": 2, "run": true, "bgcolor": "rgba(0, 255, 34, 0.02)" } }, "segments": 3, "radialSegments": 2, "closed": false, "radius": 200, "showSortNub": 7000, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }];
    WT3DObj.commonFunc.loadModelsByJsons(models, { x: 0, y: 0, z: 0 }, { x: 0, y: 0, z: 0 }, true);
    setTimeout(function () {
        var flowtube_7 = WT3DObj.commonFunc.findObject("flowtube_7");
        if (type == 1) {
            layer.msg("正在執(zhí)行打開通風(fēng)!");
            setTimeout(function () {
                WT3DObj.commonFunc.changeObjsOpacity([flowtube_7], 1, 0.1, 800);
                setTimeout(function () {
                    flowtube_7.visible = false;
                    WT3DObj.destoryObj(flowtube_7);
                    WT3DObj.destoryObj("flowtube_7");
                }, 500);
            }, 5000);


        } else {
            setTimeout(function () {
                layer.msg("正在執(zhí)行關(guān)閉通風(fēng)!");
                new TWEEN.Tween(flowtube_7.scale).to({
                    x: 20,
                    y: 20,
                    z: 20,
                }, 1000).onUpdate(function (a) {
                }).onComplete(function () {
                    flowtube_7.visible = false;
                    flowtube_7.scale.x = 0.001;
                    flowtube_7.scale.y = 0.001;
                    flowtube_7.scale.z = 0.001;
                    setTimeout(function () {
                        WT3DObj.destoryObj(flowtube_7);
                        WT3DObj.destoryObj("flowtube_7");
                    }, 200);
                }).start();
            }, 1000);
        }
    }, 200);
}

與通風(fēng)動(dòng)畫類似,我們通過載入鎖動(dòng)畫模型,實(shí)現(xiàn)如下:

//開鎖 1 關(guān)鎖 0特效
ModelBusiness.prototype.lockFunc = function (position,type) {
    var models = null;
    if (type == 1) {
        models = [{ "show": true, "uuid": "", "name": "lock_7", "objType": "GroupObj", "scale": { "x": 4, "y": 4, "z": 4 }, "position": { "x": 0, "y": 0, "z": 0 }, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "childrens": [{ "show": true, "uuid": "", "name": "lock_7OBJCREN0", "objType": "ExtrudeGeometry", "position": { "x": 0, "y": 0, "z": 0 }, "style": { "skinColor": 5306186, "opacity": 0.8 }, "scale": { "x": 1, "y": 1, "z": 1 }, "shapeParm": { "points": [{ "x": 100, "y": -120, "type": "nomal" }, { "x": 100, "y": 120, "type": "nomal" }, { "x": -100, "y": 120, "type": "nomal" }, { "x": -100, "y": -120, "type": "nomal" }], "holes": [] }, "extrudeSettings": { "amount": 0, "curveSegments": 1, "steps": 1, "bevelEnabled": true, "bevelThickness": 1, "bevelSize": 1, "bevelSegments": 1, "extrudePathPoints": [{ "x": 0, "y": 0, "z": -50 }, { "x": 0, "y": 0, "z": 50 }] }, "showSortNub": 6000, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "lock_7OBJCREN1", "objType": "tube", "points": [{ "x": 0, "y": 0, "z": 0 }, { "x": 0, "y": 150, "z": 0 }, { "x": -50, "y": 190, "z": 0 }, { "x": -110, "y": 190, "z": 0 }, { "x": -160, "y": 150, "z": 0 }, { "x": -170, "y": 60, "z": 0 }], "position": { "x": 84.692, "y": 33.246, "z": 0 }, "scale": { "x": 1, "y": 1, "z": 1 }, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "style": { "skinColor": 5040966, "opacity": 0.9 }, "segments": 24, "radialSegments": 8, "closed": false, "radius": 20, "showSortNub": 7000, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }], "showSortNub": 7000, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }];
    } else {
        models = [{ "show": true, "uuid": "", "name": "lock_7", "objType": "GroupObj", "scale": { "x": 4, "y": 4, "z": 4 }, "position": { "x": 0, "y": 0, "z": 0 }, "rotation": [{ "direction": "x", "degree": 0 }], "childrens": [{ "show": true, "uuid": "", "name": "lock_7OBJCREN0", "objType": "ExtrudeGeometry", "position": { "x": 0, "y": 0, "z": 0 }, "style": { "skinColor": 5306186, "opacity": 0.8 }, "scale": { "x": 1, "y": 1, "z": 1 }, "shapeParm": { "points": [{ "x": 100, "y": -120, "type": "nomal" }, { "x": 100, "y": 120, "type": "nomal" }, { "x": -100, "y": 120, "type": "nomal" }, { "x": -100, "y": -120, "type": "nomal" }], "holes": [] }, "extrudeSettings": { "amount": 0, "curveSegments": 1, "steps": 1, "bevelEnabled": true, "bevelThickness": 1, "bevelSize": 1, "bevelSegments": 1, "extrudePathPoints": [{ "x": 0, "y": 0, "z": -50 }, { "x": 0, "y": 0, "z": 50 }] }, "showSortNub": 6000, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "lock_7OBJCREN1", "objType": "tube", "points": [{ "x": 0, "y": 0, "z": 0 }, { "x": 0, "y": 150, "z": 0 }, { "x": -50, "y": 190, "z": 0 }, { "x": -110, "y": 190, "z": 0 }, { "x": -160, "y": 150, "z": 0 }, { "x": -170, "y": 60, "z": 0 }], "position": { "x": 84.692, "y": 75.037, "z": 0 }, "scale": { "x": 1, "y": 1, "z": 1 }, "rotation": [{ "direction": "x", "degree": -3.141592653589793 }, { "direction": "y", "degree": 1.2246468525851679e-16 }, { "direction": "z", "degree": -3.141592653589793 }], "style": { "skinColor": 5040966, "opacity": 0.9 }, "segments": 24, "radialSegments": 8, "closed": false, "radius": 20, "showSortNub": 7000, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }], "showSortNub": 7000 }];
    }
    WT3DObj.commonFunc.loadModelsByJsons(models, position, { x: 0, y: 0, z: 0 }, true);
    setTimeout(function () {
        var lock7 = WT3DObj.commonFunc.findObject("lock_7");
        if (type == 1) {
            var top1 = lock7.children[1];
            top1.oldpositiony = top1.position.y;

            var moveobj = { x: 0 };
            new TWEEN.Tween(moveobj).to({
                x: 25
            }, 500).onUpdate(function (a) {
                var _this = this;
                top1.position.y = top1.oldpositiony + _this.x;
                top1.matrixAutoUpdate = true;
            }).onComplete(function () {
                new TWEEN.Tween(top1.rotation).to({
                    y: Math.PI,
                }, 1000).onUpdate(function (a) {
                    top1.matrixAutoUpdate = true;
                }).onComplete(function () {

                    setTimeout(function () {
                        WT3DObj.commonFunc.changeObjsOpacity([lock7], 1, 0.1, 800);
                        new TWEEN.Tween(lock7.scale).to({
                            x: 10,
                            y: 10,
                            z: 10,
                        }, 1000).onUpdate(function (a) {
                        }).onComplete(function () {
                            lock7.visible = false;
                            lock7.scale.x = 0.001;
                            lock7.scale.y = 0.001;
                            lock7.scale.z = 0.001;
                            setTimeout(function () {
                                WT3DObj.destoryObj(lock7);
                                WT3DObj.destoryObj("lock_7");
                            }, 200);
                        }).start();

                    }, 1000);

                }).start();



            }).start();


        } else {
            var top1 = lock7.children[1];
            top1.oldpositiony = top1.position.y;
            new TWEEN.Tween(top1.rotation).to({
                y: Math.PI,
            }, 1000).onUpdate(function (a) {
                top1.matrixAutoUpdate = true;

            }).onComplete(function () {

                var moveobj = { x: 0 };
                new TWEEN.Tween(moveobj).to({
                    x: -25
                }, 500).onUpdate(function (a) {
                    var _this = this;
                    top1.position.y = top1.oldpositiony + _this.x;
                    top1.matrixAutoUpdate = true;
                }).onComplete(function () {

                    setTimeout(function () {
                        WT3DObj.commonFunc.changeObjsOpacity([lock7], 1, 0.1, 800);
                        new TWEEN.Tween(lock7.scale).to({
                            x: 10,
                            y: 10,
                            z: 10,
                        }, 1000).onUpdate(function (a) { }).onComplete(function () {
                            lock7.visible = false;
                            lock7.scale.x = 0.001;
                            lock7.scale.y = 0.001;
                            lock7.scale.z = 0.001;
                            setTimeout(function () {
                                WT3DObj.destoryObj(lock7);
                                WT3DObj.destoryObj("lock_7");
                            }, 200);
                        }).start();

                    }, 1000);

                }).start();

            }).start();



        }
    }, 200);

}

1.4、庫房內(nèi)安裝有區(qū)域控制器,八防感知系統(tǒng)等設(shè)備。點(diǎn)擊設(shè)備可以看到其實(shí)時(shí)監(jiān)控?cái)?shù)據(jù),效果如下:

這就比較簡單了,我們只需要獲取到模型的位置,再轉(zhuǎn)換成屏幕的二維位置,然后再對(duì)應(yīng)的位置上加上tips即可,這里我用的時(shí)layer.tips

實(shí)現(xiàn)如下:

ModelBusiness.prototype.showMsg = function (_obj, position, html, closeFunc) {
    //獲取位置
    var screenPostion = WT3DObj.commonFunc.transToScreenCoord({ x: _obj.position.x + position.x, y: _obj.position.y + position.y, z: _obj.position.z + position.z });
    $("#MarkMessageHelper").remove();
    $("body").append("<div id='MarkMessageHelper' style='position:absolute;left:" + (screenPostion.x - 30) + "px;top:" + screenPostion.y + "px;height:2px;2px;z-index:1000;'></div>");
    var urandom = (Math.random() * 100).toFixed(0);
    layer.closeAll();
    layer.tips(html, '#MarkMessageHelper', {
        closeBtn: 1,
        shade: false,
        shadeClose: true,
        area: ["300px", "200px"],
        maxWidth: 1000,
        maxHeight: 350,
        time: 0,//是否定時(shí)關(guān)閉,0表示不關(guān)閉
        cancel: function (index, layero) {
            if (closeFunc) {
                closeFunc();
            }
        },
        tips: [1, "rgba(0,0,0,0.8)"] //還可配置顏色
    });
}

二、虛擬小庫房的效果與實(shí)現(xiàn)方式

項(xiàng)目中除了大庫房的實(shí)際應(yīng)用,還涉及到一個(gè)小庫房展廳的各種設(shè)備接入與實(shí)現(xiàn)。

2.1、庫房中,接入了軌道攝像機(jī),普通攝像機(jī),溫濕度一體機(jī),聲光報(bào)警燈,燈控開關(guān),門禁,rfid門卡,八防感知,區(qū)域控制器等等。小庫房主界面效果如下:

2.2、由于小庫房展廳的密集架沒那么多,這里的打開密集架通道,我們可以動(dòng)過強(qiáng)耦合的方式,將移動(dòng)位置直接寫死再代碼里

代碼如下:

//密集架控制
ModelBusiness.prototype.mjjCtrlSystem = function () {
    showposition = { x: 200, y: 700, z: 0 };
    showhtml = "";
    var html = ' <div class="ctrbtn" id="btn_o1"> <img src="../img/pageimg2/l1.png" title="打開1通道" /><br/>打開1通道</div>\
           <div class="ctrbtn" id="btn_o2"><img src="../img/pageimg2/l2.png" title="打開2通道" /><br/>打開2通道</div>\
           <div class="ctrbtn" id="btn_o3"><img src="../img/pageimg2/together.png" title="關(guān)閉" /><br/>關(guān)閉</div>\
         ';
    //獲取位置

    this.showMsg2(null, null,300, html, function () {
        $(".ctrbtn").click(function () {
            {
                var id = $(this).attr("id");
                var state = -1;
                switch (id) {
                    case "btn_o1":
                        {
                            state = "1";
                            WT3DObj.commonFunc.findObject("mjj_1_2").position.x = 2300;
                            WT3DObj.commonFunc.findObject("mjj_1_3").position.x = 1900;
                        
                        }
                        break;
                    case "btn_o2":
                        {
                            state = "2";
                            WT3DObj.commonFunc.findObject("mjj_1_2").position.x = 2879;
                            WT3DObj.commonFunc.findObject("mjj_1_3").position.x = 1500;
                        }
                        break;
                    case "btn_o3":
                        {  
                            WT3DObj.commonFunc.findObject("mjj_1_2").position.x = 2879;
                            WT3DObj.commonFunc.findObject("mjj_1_3").position.x = 2428;
                        }
                        break;
                }
                layer.msg("控制命令已發(fā)送!");
                webapi.controlDev("Sandtable/shelf", state, function (response) {
                    if (response) {
                        if (response.code == "1") response.msg = "控制成功";
                        layer.msg(response.msg);
                    }
                }, function (error) {
                    layer.msg("控制失敗!");
                    console.log(error);
                });
            }


        });
    });
    return;
}

2.3、所有密集架都可以打開,查看內(nèi)部詳情,雙擊密集架,鏡頭定位推進(jìn),然后打開密集架的內(nèi)部結(jié)構(gòu),效果如下:

2.4、當(dāng)密集架中有檔案數(shù)據(jù)時(shí),3d架子內(nèi)會(huì)自動(dòng)在對(duì)應(yīng)的位置顯示檔案盒,雙擊檔案盒對(duì)應(yīng)的格子,為了便于操控,我通過div彈窗的方式,將檔案盒詳細(xì)脊背展現(xiàn)出來,

點(diǎn)擊脊背,還詳細(xì)展示出檔案盒內(nèi)的文件鏈接列表,這就看具體數(shù)據(jù)了,可能時(shí)pdf world excel 亦或者時(shí)拍照存留的圖片

具體實(shí)現(xiàn)如下:

function openW(a) {
    window.parent.$(".layui-layer-setwin").hide();
    $("#fzbtn").hide();
    window.parent.$("iframe").height($(window.parent).height() - 50);
    
    console.log(a);
    var title = "";
    var face = 0;
    var quno = getQueryString("quno");
    var colnub = getQueryString("colnub");
    var row = a.name.split("_")[1];
    var jie = a.name.split("_")[2];
    if (a.name.indexOf("lattice1") >= 0) {
        title = "左面,第" + row + "行,第" + jie+ "節(jié)";
    } else {
        title = "右面,第" + row + "行,第" + jie + "列";
        face =1;
    }
    var detail = LatCache["r" + (face) + "_" + row + "_c_" + jie];
    if (detail && detail.desc) {
        title +="<font style='font-size:16px;margin-left:20px;'>("+ replaceNull(detail.desc)+")</font>";
    } 
    layer.open({
        type: 1, title: title,
        skin: "layui-layer-rim",
        shade: 0.8,
        shadeClose: false,
        area: [($(window).width() - 10) + "px", ($(window).height() -10) + "px"],
        content: '<div id="boxsDivFather"><div id="boxsDiv"></div></div>',
        cancel: function () {
            $("#fzbtn").show();
            window.parent.$(".layui-layer-setwin").show();
            window.parent.$("iframe").height($(window.parent).height() - 100);

            if (boxLayerIndex) {
                layer.close(boxLayerIndex);
            }
        }, success: function () {
            scale15 = false;
            $(".layui-layer-content").after("<button id='fdbtn' style=' text-align:center;position:absolute; top: 8px;font-size: 16px;left: 500px; 80px;height: 28px; background: #288fd8;color: white;border: 0px;margin-left:20px;cursor:pointer;' onclick='fdFunc()'><i class='ace-icon fa fa-search-plus'  style='font-size:18px;'></i>&nbsp;放大</button>");
            setTimeout(function () {
                webapi.deviceInfo(room, dataId, face, row, jie, function (books) {
                    
                    var allhtml = "";
                    
                    books=books.sort(function(a,b){return a.sortNub-b.sortNub});
                    $.each(books,function(_bindex,_bobj){
                        boxcacheData["b_"+_bobj.id]=_bobj;
                         
                        var ftype = 0;
                        if (mjjparam.fileType && mjjparam.fileType != 0) {
                            ftype = mjjparam.fileType;
                        } else if (_bobj.boxType) {
                            ftype = _bobj.boxType;
                        }
                        allhtml += getBoxFaceByType(ftype, _bindex, _bobj)

                        });
                    $("#boxsDiv").html(allhtml);


                    console.log(a.name);
                    $(".boxSelectCSS").click(function () {
                        var id = $(this).attr("data-id");
                        webapi.boxDetailInfo(id, function (files) {
                          

                            var showhtml = ' <div class="row">'
                                + '<div class="col-sm-12">';
                            showhtml += '<div class="input-group">'
                         + '<span class="input-group-addon">文件列表:</span>'
                         + '</div>'
                            $.each(files, function (_findex,_fobj) {
                            
                                showhtml += '<div class="input-group">'
                         + '<font  onclick="window.open(\'' + _fobj.fileSrc + '\');">' + _fobj.name + '</font>'
                         + '</div>';
                            });
                            showhtml += '</div></div>';
                            boxLayerIndex = layer.tips(showhtml, "#b_archiveno_" + id, {
                                closeBtn: 1,
                                tips:2,
                                shade: false,
                                shadeClose: true,
                                area: ["280px", "auto"],
                                maxWidth: 1000,
                                maxHeight: 750,
                                time: 0,//是否定時(shí)關(guān)閉,0表示不關(guān)閉
                                cancel: function (index, layero) {
                                    boxLayerIndex = null;
                                },
                                tips: [1, "rgba(0,0,0,0.8)"] //還可配置顏色
                            });

                        }, function (err) {
                        }, false);
                 
                    });
                    $(".boxSelectCSS").dblclick(function () {
                        var id = $(this).attr("data-id");
                        webapi.boxDetailInfo(id, function (files) {
                            if (files.length > 0) {
                                window.open( files[0].fileSrc);
                             }
                            
                        }, function (err) {
                        }, false);

                    });

                    var scaleheigt = ($(window).height() - 70) / $("#boxsDiv").height();
                    if (scaleheigt < 1) {
                        ScaleSize = scaleheigt;
                        $("#boxsDiv").width(1 / scaleheigt * 100 + "%");
                        $("#boxsDiv").css("transform", "scale(" + scaleheigt + ")");
                    } else {
                        ScaleSize = 1;
                    }
                }, function () { });
            }, 200);
        }
    });

}

2.5、控制軌道相機(jī)的位置,通過選擇通道,改變軌道相機(jī)的位置

這個(gè)實(shí)現(xiàn)比較簡單,我們只需要修改它的position屬性即可,

//軌道攝像機(jī)

ModelBusiness.prototype.gdsxjCtrlSystem = function () {
    showposition = { x: 200, y: 700, z: 0 };
    showhtml = "";
    var html = ' <div class="ctrbtn" id="btn_o1"> <img src="../img/pageimg2/l1.png" title="1通道" /><br/>1通道</div>\
           <div class="ctrbtn" id="btn_o2"><img src="../img/pageimg2/l2.png" title="2通道" /><br/>2通道</div>\
           <div class="ctrbtn" id="btn_o3"><img src="../img/pageimg2/l3.png" title="原點(diǎn)" /><br/>原點(diǎn)</div>\
         ';
    //獲取位置

    this.showMsg2(null, null, 300, html, function () {
        $(".ctrbtn").click(function () {
            {
                var id = $(this).attr("id");
                var state = -1;
                switch (id) {
                    case "btn_o1":
                        {
                            state = "1";
                                WT3DObj.commonFunc.findObject("xxj_2_263").position.x = 3200;
                        }
                        break;
                    case "btn_o2":
                        {
                            state = "2";
                            WT3DObj.commonFunc.findObject("xxj_2_263").position.x = 2300;
                        }
                        break;
                    case "btn_o3":
                        {
                            WT3DObj.commonFunc.findObject("xxj_2_263").position.x = 1400;
                        }
                        break;
                }
                layer.msg("控制命令已發(fā)送!");
                webapi.controlDev("Sandtable/cam", state, function (response) {
                    if (response) {
                        if (response.code == "1") response.msg = "控制成功";
                        layer.msg(response.msg);
                    }
                }, function (error) {
                    layer.msg("控制失敗!");
                    console.log(error);
                });
            }


        });
    });
    return;
}

2.6、控制門禁,實(shí)現(xiàn)遠(yuǎn)程開門,在三維里面反饋展示

具體實(shí)現(xiàn):

//門禁
ModelBusiness.prototype.doorCtrlSystem = function () {
    showposition = { x: 200, y: 700, z: 0 };
    showhtml = "";
    var html = ' <div class="ctrbtn" id="btn_closedoor"> <img src="../img/pageimg2/lock.png" title="關(guān)燈" /><br/>關(guān)門</div>\
           <div class="ctrbtn" id="btn_opendoor"><img src="../img/pageimg2/unlock.png" title="開門" /><br/>開門</div>\
         ';
    //獲取位置

    this.showMsg2(null, null, 200, html, function () {
        $(".ctrbtn").click(function () {
            {
                var id = $(this).attr("id");
                var state = -1;
                switch (id) {
                    case "btn_closedoor":
                        {
                            state = "2";

                            WT3DObj.commonFunc.findObject("door_1").position.x = -163.322
                            WT3DObj.commonFunc.findObject("door_1").position.z = 2680.743
                            WT3DObj.commonFunc.findObject("door_1").rotation.y = 0;
                            WT3DObj.commonFunc.findObject("door_2").position.x = -163.322
                            WT3DObj.commonFunc.findObject("door_2").position.z = 3081.653
                            WT3DObj.commonFunc.findObject("door_2").rotation.y = 0
                        }
                        break;
                    case "btn_opendoor":
                        {
                            state = "1";

                            WT3DObj.commonFunc.findObject("door_1").position.x = 74
                            WT3DObj.commonFunc.findObject("door_1").position.z = 2500
                            WT3DObj.commonFunc.findObject("door_1").rotation.y = Math.PI / 2;
                            WT3DObj.commonFunc.findObject("door_2").position.x = 74
                            WT3DObj.commonFunc.findObject("door_2").position.z = 3250
                            WT3DObj.commonFunc.findObject("door_2").rotation.y = -Math.PI / 2
                            state = "1";
                        }
                        break;
                    
                }
                layer.msg("控制命令已發(fā)送!");
                webapi.controlDev("Sadntable/door", state, function (response) {
                    if (response) {
                        if (response.code == "1") response.msg = "控制成功";
                        layer.msg(response.msg);
                    }
                }, function (error) {
                    layer.msg("控制失敗!");
                    console.log(error);
                });
            }


        });
    });
    return;
}

2.7、控制溫濕度一體機(jī)

這里實(shí)現(xiàn),也是通過載入開關(guān)動(dòng)畫的方式

具體實(shí)現(xiàn):

//一體機(jī)    16
ModelBusiness.prototype.ctrlYITIJI = function (model, action) {
   {
        var cresultState = true;
        switch (action) {
            case "1":
                cresultState = modelBusiness.ctrlJSAnimation(model);
                break;
            case "2":
                cresultState = modelBusiness.closeDev(model);
                break;
        }
        //發(fā)送控制命令
        if (cresultState) {
      

            webapi.controlDev("Sandtable/aiodevice", action, function (response) {
                if (response) {
                    if (response.msg == "") response.msg = "控制成功"; layer.msg(response.msg);
                }
            }, function (error) {
                layer.msg("控制失敗!");
                console.log(error);
            });
        }
    }
}

2.8、控制燈控系統(tǒng)

這里我們通過加上光照效果,實(shí)現(xiàn)方式是修改環(huán)境光顯示隱藏的屬性,即可達(dá)到燈光效果,由于全程可見,我們通過地面的陰影來體現(xiàn)燈光的開關(guān)。

具體實(shí)現(xiàn):

//燈控
ModelBusiness.prototype.lightCtrlSystem = function () {
    showposition = { x: 200, y: 700, z: 0 };
    showhtml = "";
    var html = ' <div class="ctrbtn" id="btn_closelight"> <img src="../img/pageimg2/closeLight.png" title="關(guān)燈" /><br/>關(guān)燈</div>\
           <div class="ctrbtn" id="btn_l3"><img src="../img/pageimg2/l3.png" title="開燈" /><br/>開燈</div>\
         ';
    //獲取位置

    this.showMsg2(null, null, 200, html, function () {
        $(".ctrbtn").click(function () {
            {
                var id = $(this).attr("id");
                var state = -1;
                switch (id) {
                    case "btn_closelight":
                        {
                            state = "2";
                            
                            WT3DObj.commonFunc.findObject("DirectionalLight_429").visible=false;
                        }
                        break;
                    case "btn_l1":
                        {
                            state = 1;
                        }
                        break;
                    case "btn_l2":
                        {
                            state = 2;
                        }
                        break;
                    case "btn_l3":
                        {
                            WT3DObj.commonFunc.findObject("DirectionalLight_429").visible = true;
                            state = "1";
                        }
                        break;
                }
                layer.msg("控制命令已發(fā)送!");
                webapi.controlDev("Sandtable/light", state, function (response) {
                    if (response) {
                        if (response.code == "1") response.msg = "控制成功";
                        layer.msg(response.msg);
                    }
                }, function (error) {
                    layer.msg("控制失敗!");
                    console.log(error);
                });
            }


        });
    });
    return;
}

2.9、聲光報(bào)警器觸發(fā)。

通過修改聲光效果的屬性來實(shí)現(xiàn)。

實(shí)現(xiàn)代碼如下:

//報(bào)警器
ModelBusiness.prototype.alarmCtrlSystem = function () {
    return;
    showposition = { x: 200, y: 700, z: 0 };
    showhtml = "";

    var html = ' <div class="ctrbtn" id="btn_openlight"> <img src="../img/pageimg2/bf.png" title="布防" /><br/>布防</div>\
         <div class="ctrbtn" id="btn_l1"> <img src="../img/pageimg2/cf.png" title="撤防" /><br/>撤防</div>\
         ';
    //獲取位置

    this.showMsg2(null, null, 200, html, function () {
        $(".ctrbtn").click(function () {
            var _id = $(this).attr("id");
            switch (_id) {
                case "btn_openlight":
                    { }
                    break;
                case "btn_l1":
                    { }
                    break;
                case "btn_l2":
                    { }
                    break;
                case "btn_l3":
                    { }
                    break;
                case "ptdBtn":
                    { }
                    break;
            }
        });
    });
}

2.10、庫房內(nèi)搜索功能,可以通過關(guān)鍵之搜索,快速定位檔案位置。

三、該篇總結(jié)

本篇文章主要介紹了3D密集架的功能與效果。并且對(duì)主要實(shí)現(xiàn)邏輯代碼進(jìn)行了講解

后面的文章會(huì)對(duì)具體模型的實(shí)現(xiàn)方式進(jìn)行講解,由于篇幅原因,先講到這里,后面持續(xù)更新。

亦或者通過下列方式交流:

郵箱交流 1203193731@qq.com

微信交流:

    

如果你有什么要交流的心得 可郵件我

其它相關(guān)文章:

使用webgl(three.js)創(chuàng)建3D機(jī)房,3D機(jī)房微模塊詳細(xì)介紹(升級(jí)版二)

如何用webgl(three.js)搭建一個(gè)3D庫房-第一課

如何用webgl(three.js)搭建一個(gè)3D庫房,3D密集架,3D檔案室,-第二課

使用webgl(three.js)搭建一個(gè)3D建筑,3D消防模擬——第三課

使用webgl(three.js)搭建一個(gè)3D智慧園區(qū)、3D建筑,3D消防模擬,web版3D,bim管理系統(tǒng)——第四課

如何用webgl(three.js)搭建不規(guī)則建筑模型,客流量熱力圖模擬

使用webgl(three.js)搭建一個(gè)3D智慧園區(qū)、3D建筑,3D消防模擬,web版3D,bim管理系統(tǒng)——第四課(炫酷版一)

使用webgl(three.js)搭建3D智慧園區(qū)、3D大屏,3D樓宇,智慧燈桿三維展示,3D燈桿,web版3D,bim管理系統(tǒng)——第六課

物聯(lián)網(wǎng)3D,物業(yè)基礎(chǔ)設(shè)施3D運(yùn)維,使用webgl(three.js)與物聯(lián)網(wǎng)設(shè)備結(jié)合案例。搭建智慧樓宇,智慧園區(qū),3D園區(qū)、3D物業(yè)設(shè)施,3D樓宇管理系統(tǒng)——第八課

總結(jié)

以上是生活随笔為你收集整理的如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室(升级版)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。