如何用 webgl(three.js) 搭建一个 3D 库房, 3D 密集架, 3D 档案室,- 第二课

3d 库房, 3d 档案室, 3d 密集架, webGL,threejs,3d 机房

闲话少叙,我们接着第一课继续讲(http://www.cnblogs.com/yeyunfei/p/7899613.html),很久没有做技术分享了。很多人问第二课有没有,我也是抽空写一下第二课。

第一课程提到了在库房的基础上添加上下架 消防 温湿度等等控制

刚好 最近有接到一个客户的需求 是和库房差不多的项目 只是不是库房了 是档案室 但是基本操控还是差不多的 也有文件上下架什么的

那么第二课 我们就按照客户的需求 先做一个概述性的展现

特此说明:为了减少网络传输带宽 我特意用 ScreenToGif 工具 截了一些 gif 图 压缩成低帧率

有什么需要交流的 可邮件我 1203193731@qq.com

一、需要场景进行无缝的动画切换

如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室,-第二课 - 图1

代码实现

  1. //应用切换库
  2. <script src="js/pagetransitions.js"></script>
  3. var PageTransitions = (function() {
  4. var $main = $( '#pt-main' ),
  5. $pages = $main.children( 'div.pt-page' ),
  6. $iterate = $( '.pt-touch-button' ),
  7. animcursor = 1,
  8. pagesCount = $pages.length,
  9. current = 1,
  10. precurrent=1,
  11. isAnimating = false,
  12. endCurrPage = false,
  13. endNextPage = false,
  14. animEndEventNames = {
  15. 'WebkitAnimation' : 'webkitAnimationEnd',
  16. 'OAnimation' : 'oAnimationEnd',
  17. 'msAnimation' : 'MSAnimationEnd',
  18. 'animation' : 'animationend'
  19. },
  20. // animation end event name
  21. animEndEventName = animEndEventNames[ Modernizr.prefixed( 'animation' ) ],
  22. // support css animations
  23. support = Modernizr.cssanimations;
  24. function init() {
  25. $pages.each( function() {
  26. var $page = $( this );
  27. $page.data( 'originalClassList', $page.attr( 'class' ) );
  28. } );
  29. $($(".pt-page.pt-page-1")[0]).addClass( 'pt-page-current' );
  30. precurrent = 1;
  31. $iterate.on('click', function () {
  32. var frameindex = $(this).attr("data-frameindex");
  33. current = frameindex;
  34. console.log(frameindex);
  35. var _this = this;
  36. if (isAnimating || current == precurrent ) {
  37. return false;
  38. }
  39. if( animcursor > 5 ) {
  40. animcursor = 1;
  41. }
  42. nextPage( animcursor );
  43. ++animcursor;
  44. //setTimeout(function () {
  45. // $("#frame" + $(_this).attr("data-frameindex")).attr("src", $(_this).attr("data-src"));
  46. //}, 500);
  47. } );
  48. }
  49. function nextPage( animation ) {
  50. if (isAnimating) {
  51. return false;
  52. }
  53. isAnimating = true;
  54. var $currPage = $($(".pt-page.pt-page-" + precurrent)[0]);
  55. var $nextPage = $($(".pt-page.pt-page-" + current)[0]).addClass( 'pt-page-current' ),
  56. outClass = '', inClass = '';
  57. precurrent = current;
  58. switch( animation ) {
  59. case 1:
  60. outClass = 'pt-page-rotateCubeLeftOut pt-page-ontop';
  61. inClass = 'pt-page-rotateCubeLeftIn';
  62. break;
  63. case 2:
  64. outClass = 'pt-page-rotateCubeRightOut pt-page-ontop';
  65. inClass = 'pt-page-rotateCubeRightIn';
  66. break;
  67. case 3:
  68. outClass = 'pt-page-rotateCubeTopOut pt-page-ontop';
  69. inClass = 'pt-page-rotateCubeTopIn';
  70. break;
  71. case 4:
  72. outClass = 'pt-page-rotateCubeBottomOut pt-page-ontop';
  73. inClass = 'pt-page-rotateCubeBottomIn';
  74. break;
  75. case 5:
  76. outClass = 'pt-page-rotateSlideOut';
  77. inClass = 'pt-page-rotateSlideIn';
  78. break;
  79. }
  80. $currPage.addClass( outClass ).on( animEndEventName, function() {
  81. $currPage.off( animEndEventName );
  82. endCurrPage = true;
  83. if( endNextPage ) {
  84. onEndAnimation( $currPage, $nextPage );
  85. }
  86. } );
  87. $nextPage.addClass( inClass ).on( animEndEventName, function() {
  88. $nextPage.off( animEndEventName );
  89. endNextPage = true;
  90. if( endCurrPage ) {
  91. onEndAnimation( $currPage, $nextPage );
  92. }
  93. } );
  94. if( !support ) {
  95. onEndAnimation( $currPage, $nextPage );
  96. }
  97. }
  98. function onEndAnimation( $outpage, $inpage ) {
  99. endCurrPage = false;
  100. endNextPage = false;
  101. resetPage( $outpage, $inpage );
  102. isAnimating = false;
  103. }
  104. function resetPage( $outpage, $inpage ) {
  105. $outpage.attr( 'class', $outpage.data( 'originalClassList' ) );
  106. $inpage.attr( 'class', $inpage.data( 'originalClassList' ) + ' pt-page-current' );
  107. }
  108. init();
  109. return { init : init };
  110. })();

二、打开密集架 有过度动画

如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室,-第二课 - 图2

代码实现

  1. this.loadMjjFace = function (mjjObj) {
  2. $.each(mjjObj.material.materials, function (_index, _obj) {
  3. if (_obj.opacity > 0.1) {
  4. _obj.opacity = 0.1;
  5. }
  6. });
  7. var cube = {
  8. "show": true,
  9. "uuid": "",
  10. "name": mjjObj.name + "_animationCube",
  11. "objType": "cube2",
  12. "length": 78,
  13. "width": 319,
  14. "height": 1,
  15. "x": mjjObj.position.x,
  16. "y": mjjObj.position.y - 99,
  17. "z": mjjObj.position.z,
  18. "style": {
  19. "skinColor": 16777215, "skin":
  20. {
  21. "skin_up": { "skinColor": 7219463, "opacity": 0.9, },
  22. "skin_down": { "skinColor": 7219463, "opacity": 0.9, },
  23. "skin_fore": { "skinColor": 7219463, "opacity": 0.9, },
  24. "skin_behind": { "skinColor": 7219463, "opacity": 0.9, },
  25. "skin_left": { "skinColor": 7219463, "opacity": 0.9, },
  26. "skin_right": { "skinColor": 7219463, "opacity": 0.9, }
  27. }
  28. }, "showSortNub": 11, "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null
  29. }
  30. var temObj = tl3DCoreObj.createObjByJson(cube);
  31. tl3DCoreObj.addObject(temObj);
  32. new TWEEN.Tween(temObj.position).to({
  33. y: mjjObj.position.y
  34. }, 2000).start();
  35. new TWEEN.Tween(temObj.scale).to({
  36. y: 199
  37. }, 2000).onComplete(function () {
  38. $.each(mjjObj.material.materials, function (_index, _obj) {
  39. if (_obj.opacity == 0.1) {
  40. _obj.opacity = 1;
  41. }
  42. });
  43. tl3DCoreObj.destoryObj(mjjObj.name + "_animationCube");
  44. }).start();
  45. this.createMjjDetail(mjjObj);
  46. }

三、对密集架的文件档案进行上下架操作 保留操作接口

如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室,-第二课 - 图3

代码实现

  1. //创建密集架详情
  2. this.createMjjDetail = function (mjjObj) {
  3. var _this = this;
  4. var detailGroup = null;
  5. //获取密集架序号
  6. var _groupNub = parseInt(mjjObj.name.split('_')[1]);//组序号
  7. var _colomnNub = parseInt(mjjObj.name.split('_')[2])//列序号
  8. //此处表示密集架行数 列数
  9. var mjjparam = null;
  10. var rowHeigtht = null;//每隔高度 此处200表示密集架高度
  11. var columlength = null;//此处320表示宽度
  12. if (_this.mjjDetails[_groupNub - 1] && _this.mjjDetails[_groupNub - 1][_colomnNub - 1]) {
  13. detailGroup = _this.mjjDetails[_groupNub - 1][_colomnNub - 1];
  14. } else {
  15. mjjparam = {
  16. rows: 12,
  17. colums: 4,
  18. }
  19. rowHeigtht = 200 / mjjparam.rows;//每隔高度 此处200表示密集架高度
  20. columlength = 320 / mjjparam.colums;//此处320表示宽度
  21. var mjjdetailGroup = {
  22. show: true,
  23. uuid: "",
  24. name: "mjjdetailGroup1",
  25. objType: "GroupObj",
  26. scale: { x: 1, y: 1, z: 1 },
  27. position: {
  28. x: mjjObj.position.x,
  29. y: mjjObj.position.y,
  30. z: mjjObj.position.z
  31. },
  32. rotation: [{ direction: 'x', degree: 0 }],//旋转 表示x方向0度 arb表示
  33. childrens: [
  34. ]
  35. }
  36. //创建横向隔板
  37. for (var i = 0; i < mjjparam.rows - 1; i++) {
  38. var gb1 = {
  39. "show": true,
  40. "uuid": "",
  41. "name": "mjjdetail_r" + (i + 1),
  42. "objType": "cube2",
  43. "length": 79,
  44. "width": 319,
  45. "height": 1,
  46. "x": 0,
  47. "y": 100 - (i + 1) * rowHeigtht,
  48. "z": 0,
  49. "style": { "skinColor": 16777215, "skin": { "skin_up": { "skinColor": 16777215, "imgurl": "../../img/3dImg/outside_lightmap.jpg" }, "skin_down": { "skinColor": 14540253 }, "skin_fore": { "skinColor": 14540253, "imgurl": "../../img/3dImg/card_panel.png" }, "skin_behind": { "skinColor": 14540253, "imgurl": "../../img/3dImg/card_panel.png" }, "skin_left": { "skinColor": 14540253 }, "skin_right": { "skinColor": 14540253 } } }, "showSortNub": 4, "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null
  50. };
  51. mjjdetailGroup.childrens.push(gb1);
  52. }
  53. //创建竖向隔板
  54. for (var i = 0; i < mjjparam.colums - 1; i++) {
  55. var gb2 = { "show": true, "uuid": "", "name": "mjjdetail_c" + (i + 1), "objType": "cube2", "length": 10, "width": 2, "height": 199, "x": 35, "y": 0, "z": 160 - ((i + 1) * columlength), "style": { "skinColor": 16777215, "skin": { "skin_up": { "skinColor": 14540253 }, "skin_down": { "skinColor": 14540253 }, "skin_fore": { "skinColor": 0xaaaaaa }, "skin_behind": { "skinColor": 0xaaaaaa }, "skin_left": { "skinColor": 14540253, "imgurl": "../../img/3dImg/card_panel.png" }, "skin_right": { "skinColor": 14540253, "imgurl": "../../img/3dImg/card_panel.png" } } }, "showSortNub": 4, "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null };
  56. mjjdetailGroup.childrens.push(gb2);
  57. var gb3 = ({ "show": true, "uuid": "", "name": "mjjdetail_c3" + (i + 1), "objType": "cube", "length": 10, "width": 2, "height": 199, "x": 0 - 35, "y": 0, "z": 160 - ((i + 1) * columlength), "style": { "skinColor": 16777215, "skin": { "skin_up": { "skinColor": 14540253 }, "skin_down": { "skinColor": 14540253 }, "skin_fore": { "skinColor": 0xaaaaaa }, "skin_behind": { "skinColor": 0xaaaaaa }, "skin_left": { "skinColor": 14540253, "imgurl": "../../img/3dImg/card_panel.png" }, "skin_right": { "skinColor": 14540253, "imgurl": "../../img/3dImg/card_panel.png" } } }, "showSortNub": 4, "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null });
  58. mjjdetailGroup.childrens.push(gb3);
  59. }
  60. detailGroup = tl3DCoreObj.createObjByJson(mjjdetailGroup);
  61. if (_this.mjjDetails[_groupNub - 1] == undefined) {
  62. _this.mjjDetails[_groupNub - 1] = [];
  63. }
  64. _this.mjjDetails[_groupNub - 1][_colomnNub - 1] = detailGroup;
  65. tl3DCoreObj.addObject(detailGroup);
  66. }
  67. //获取内部实时数据
  68. /*
  69. 数据格式 将有文件的格子信息 以如下形式输出
  70. [
  71. {
  72. rowNo_:1,//行数
  73. colNo_:1,//列数
  74. filesNub:5//文件个数
  75. },
  76. ]
  77. */
  78. var _files = [];
  79. {//演示数据 获取真实数据后可替换
  80. for (var i = 1; i <= mjjparam.rows;i++){
  81. for (var j= 1; j <= mjjparam.colums;j++) {
  82. _files.push({
  83. rowNo_: i,//行数
  84. colNo_: j,//列数
  85. filesNub:Math.floor(Math.random()*10)%5 //随机生成演示文件个数
  86. });
  87. }
  88. }
  89. }
  90. //刷新文件排布
  91. detailGroup.children.length = mjjparam.rows + mjjparam.colums*2-3;
  92. $.each(_files, function (_index,_obj) {
  93. if (_obj.filesNub > 0) {
  94. for (var w = 0; w < parseInt(Math.random() * parseInt((columlength - 2) / 22)) + 1 ; w++) {
  95. var _tmfile = {
  96. "show": true, "uuid": "", "name": "filebox_" + _obj.rowNo_ + "_" + _obj.colNo_ + "_w" + w, "objType": "cube", "length":70, "width": 20, "height": (rowHeigtht - 5),
  97. "x": mjjObj.position.x,
  98. "y": ( (_obj.rowNo_-1) * rowHeigtht + (rowHeigtht - 5) / 2 + 5),
  99. "z": mjjObj.position.z + (-160 + ((_obj.colNo_ - 1) * columlength) + 22* (1 + w)),
  100. "style": { "skinColor": 16777215, "skin": { "skin_up": { "skinColor": 10382134 }, "skin_down": { "skinColor": 10382134 }, "skin_fore": { "skinColor": 9525548 }, "skin_behind": { "skinColor": 9525548 }, "skin_left": { "skinColor": 13076036 }, "skin_right": { "skinColor": 13203019 } } }, "showSortNub": 11, "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null
  101. };
  102. var _tmfileObj = tl3DCoreObj.createObjByJson(_tmfile);
  103. detailGroup.children.push(_tmfileObj);
  104. }
  105. }
  106. });
  107. detailGroup.visible = false;
  108. detailGroup.position.x = mjjObj.position.x;
  109. detailGroup.position.y = mjjObj.position.y;
  110. detailGroup.position.z = mjjObj.position.z;
  111. setTimeout(function () {
  112. detailGroup.visible = true;
  113. }, 2000);
  114. }

四、快速检索文件,并定位

如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室,-第二课 - 图4

代码实现

  1. //查找文件 此处查找条件可以自定义
  2. this.searchFile = function () {
  3. var _this = this;
  4. $("#toolbar").hide();
  5. //获取到文件位置信息
  6. //返回类型 searchFileObj={fileName:'',mjjName:'',mjjGroup:'3',mjjnub:'2',face:'',row:'',color:'',nub:''}\
  7. //边缘弹出
  8. layer.open({
  9. title: "文件查找",
  10. type: 1,
  11. offset: 'lt' //具体配置参考:offset参数项
  12. , content: '<div style="padding: 10px;width:250px;min-height:150px;background-color:rgba(255,255,255,0.4);">\
  13. <table class="table">\
  14. <tr><td style="text-align:right;width:80px;">类型:</td><td><input id="fsfileType" value="" /></td></tr>\
  15. <tr><td style="text-align:right;width:80px;">关键字:</td><td><input id="fskeyWord" value="" /></td></tr>\
  16. <tr><td style="text-align:right;width:80px;">结果:</td><td colspan=2 id="searchResuleTd"></td></tr>\
  17. </table></div>'
  18. , btn: '确认查找'
  19. , btnAlign: 'c' //按钮居中
  20. , shade: 0 //不显示遮罩
  21. , yes: function () {
  22. var searchFileObj = {
  23. mjjGroup: Math.floor(Math.random() * 12) % 6 + 1,
  24. mjjnub: Math.floor(Math.random() * 14) % 7 + 1,
  25. face: Math.random()>0.5? "A":"B",
  26. row: Math.floor(Math.random() * 20) % 10+1,
  27. column: Math.floor(Math.random() * 20) % 8+1,
  28. nub: Math.floor(Math.random() * 40) % 20 + 1
  29. };
  30. $("#searchResuleTd").html("密集架组:" + searchFileObj.mjjGroup + "组</br>"
  31. + "密集架号:" + searchFileObj.mjjnub + "号</br>"
  32. + "密集架面:" + searchFileObj.face + "面</br>"
  33. + "所在行数:" + searchFileObj.row + "行</br>"
  34. + "所在列数:" + searchFileObj.column + "列</br>"
  35. + "文档序号:" + searchFileObj.nub + "</br>"
  36. );
  37. var _mjjObj = tl3DCoreObj.commonFunc.findObject("mjj_" + searchFileObj.mjjGroup + "_" + searchFileObj.mjjnub);
  38. _this.selectObj(_mjjObj);
  39. var newposition = {
  40. x: (tl3DCoreObj.camera.position.x + _mjjObj.position.x)/2,
  41. y: 600,
  42. z: (tl3DCoreObj.camera.position.z+ _mjjObj.position.z) / 2
  43. }
  44. if ((tl3DCoreObj.camera.position.x - _mjjObj.position.x) * (tl3DCoreObj.camera.position.x - _mjjObj.position.x)
  45. + (600 - _mjjObj.position.y) * (600 - _mjjObj.position.y)
  46. + (tl3DCoreObj.camera.position.z - _mjjObj.position.z) * (tl3DCoreObj.camera.position.z - _mjjObj.position.z)
  47. < 150 * 150 * 150) {
  48. newposition = {
  49. x: (tl3DCoreObj.camera.position.x),
  50. y: 600,
  51. z: (tl3DCoreObj.camera.position.z )
  52. }
  53. }
  54. _this.changeCameraPosition(newposition, _mjjObj.position, 500)
  55. },
  56. end: function () {
  57. $("#toolbar").show();
  58. _this.unselectObj();
  59. }
  60. });
  61. $("#fsfileType").click(function () {
  62. $("#fsfileType").focus();
  63. })
  64. $("#fskeyWord").click(function () {
  65. $("#fskeyWord").focus();
  66. })
  67. }
  68. this.selectedObjs = null;
  69. this.selectObj=function (_obj) {
  70. var _this = this;
  71. if (_this.selectedObjs) {
  72. _this.unselectObj();
  73. }
  74. var outlineMaterial2 = new THREE.MeshBasicMaterial({ color: 0x00ff00, side: THREE.BackSide });
  75. var outlineMesh2 = new THREE.Mesh(_obj.geometry.clone(), outlineMaterial2);
  76. outlineMesh2.scale.multiplyScalar(1.05);
  77. outlineMesh2.position.x = _obj.position.x;
  78. outlineMesh2.position.y = _obj.position.y;
  79. outlineMesh2.position.z = _obj.position.z;
  80. tl3DCoreObj.scene.add(outlineMesh2);
  81. _this.selectedObjs = outlineMesh2;
  82. _this.flashObj(_obj);
  83. }
  84. this.unselectObj=function () {
  85. var _this = this;
  86. if (_this.selectedObjs) {
  87. tl3DCoreObj.scene.remove(_this.selectedObjs);
  88. _this.selectedObjs = null;
  89. }
  90. }

五、场景内监控摄像头 调取实时视频

如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室,-第二课 - 图5

  1. /*摄像头部分*********************************************************************/
  2. this.cameraRange = [];
  3. //摄像头按钮
  4. this.showCamera = function () {
  5. var _this = this;
  6. if (_this.cameraRange.length <= 0) {
  7. var jsonobj1 = { "segmentsY": 0, "segmentsX": 6, "rotation": [{ "degree": 1.836627410320584, "direction": "x" }, { "degree": -0.01857030395023093, "direction": "y" }, { "degree": -0.10075785157596659, "direction": "z" }], "show": true, "scale": { "x": 1.1, "y": 1, "z": 0.3 }, "openEnded": false, "radiusTop": 500, "radiusBottom": 5, "showSortNub": 211, "name": "camera_range", "style": { "skinColor": 16776960, "skin": { "skin_up": { "side": 0, "skinColor": 16777215, "opacity": 0 }, "skin_side": { "imgurl": "../../img/3dImg/camarerange.png", "side": 2, "skinColor": 2746367, "opacity": 0.3 }, "skin_down": { "side": 1, "skinColor": 6881093, "opacity": 0 } } }, "position": { "x": -129.087, "y": 170.956, "z": -314.488 }, "objType": "cylinder", "height": 500 };
  8. var temObj1 = tl3DCoreObj.createObjByJson(jsonobj1);
  9. tl3DCoreObj.addObject(temObj1);
  10. _this.cameraRange.push(temObj1);
  11. var jsonobj2 = {"segmentsY": 0, "segmentsX": 6, "rotation": [{ "direction": "x", "degree":1.5415097019464317 }, { "direction": "y", "degree": -0.08611454529340022 },{ "direction": "z", "degree": -3.0382866151642487 }], "show": true, "scale": { "x": 1.1, "y": 1, "z": 0.3 }, "openEnded": false, "radiusTop": 500, "radiusBottom": 5, "showSortNub": 211,"name": "camera_range2", "style": {"skinColor": 16776960, "skin": {
  12. "skin_up": { "skinColor": 16777215, "side": 0, "opacity": 0 }, "skin_down":{ "skinColor": 6881093, "side": 1, "opacity": 0 },
  13. "skin_side": { "skinColor": 2746367, "side": 2, "opacity": 0.3, "imgurl": "../../img/3dImg/camarerange.png" }
  14. }
  15. }, "position": { "x": 45.312, "y": 247.096, "z": 534.465 }, "objType": "cylinder",
  16. "height": 500, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null
  17. };
  18. var temObj2 = tl3DCoreObj.createObjByJson(jsonobj2);
  19. tl3DCoreObj.addObject(temObj2);
  20. _this.cameraRange.push(temObj2);
  21. }
  22. if (_this.cameraRange.length > 0) {
  23. $.each(_this.cameraRange, function (_index, _obj) {
  24. _obj.visible = true;
  25. _this.flashObj(_obj, 0xb2fb07);
  26. });
  27. }
  28. _this.changeCameraPosition({ x: -1284, y: 1787, z: -378 }, { x: -237, y: 308, z: 145 }, 1000)
  29. }
  30. //隐藏摄像头范围
  31. this.hideCamera = function () {
  32. var _this = this;
  33. if (_this.cameraRange.length > 0) {
  34. $.each(_this.cameraRange, function (_index, _obj) {
  35. _obj.visible = false;
  36. });
  37. }
  38. }
  39. //打开视屏
  40. this.showVideo = function (_obj) {
  41. var _this = this;
  42. layer.closeAll();
  43. var videoUrl = "";
  44. layer.open({
  45. title: "视频",
  46. area:["555px","280px"],
  47. type: 1,
  48. content: '<video id="video" autoplay loop webkit-playsinline style="width:100%;" >\
  49. <source src="../../img/3dImg/video.mp4">\
  50. </video>'
  51. , btn: false
  52. , shade: 0 //不显示遮罩
  53. , yes: function () {
  54. },
  55. end: function () {
  56. _this.hideCamera();
  57. }
  58. });
  59. }

六、消防灭火器快速定位 查找

如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室,-第二课 - 图6

  1. /*消防按钮部分*********************************************************************/
  2. //消防按钮--灭火器定位
  3. this.FireControl = function () {
  4. var _this = this;
  5. _this.VirtualWalls();
  6. _this.hideAllMjj();
  7. _this.hideCamera();
  8. _this.removeMark();
  9. _this.addMark({ "x": 940, "y":200, "z": -660 });
  10. _this.addMark({ "x": 660, "y": 200, "z": -70 });
  11. _this.addMark({ "x": 660, "y": 200, "z": 400 });
  12. _this.addMark({ "x": -960, "y": 200, "z": -70 });
  13. _this.addMark({ "x": -960, "y": 200, "z": 400 });
  14. function markmoveUP(){
  15. new TWEEN.Tween(_this.marks[0].position).to({
  16. y:230
  17. }, 700).onUpdate(function () {
  18. var _marktPosition=this;
  19. $.each(_this.marks, function (_index, _obj) {
  20. if (_index != 0) {
  21. _obj.position.y = _marktPosition.y
  22. }
  23. });
  24. }).onComplete(function () {
  25. if (_this.marks.length > 0) {
  26. markmoveDown();
  27. }
  28. }).start();
  29. }
  30. function markmoveDown() {
  31. new TWEEN.Tween(_this.marks[0].position).to({
  32. y: 200
  33. }, 700).onUpdate(function () {
  34. var _marktPosition = this;
  35. $.each(_this.marks, function (_index, _obj) {
  36. if (_index != 0) {
  37. _obj.position.y = _marktPosition.y
  38. }
  39. });
  40. }).onComplete(function () {
  41. if (_this.marks.length > 0) {
  42. markmoveUP();
  43. }
  44. }).start();
  45. }
  46. function moveCameras() {
  47. _this.changeCameraPosition(
  48. { "x": -270, "y": 1274, "z": -714 },
  49. { "x": 209, "y": 705, "z": -750 },
  50. 1000,
  51. function () {
  52. _this.changeCameraPosition(
  53. { "x": -574, "y": 1430, "z":-161 },
  54. { "x": 486, "y": 134, "z": -90 },
  55. 2000,
  56. function () {
  57. _this.changeCameraPosition(
  58. { "x": 196, "y": 1262, "z":340},
  59. { "x": -639, "y": 277, "z":216},
  60. 4000,
  61. function () {
  62. _this.changeCameraPosition(
  63. { "x":12, "y": 1749, "z": -2468 },
  64. { "x":61, "y": 156, "z":194 }, 1000, function () { });
  65. }
  66. );
  67. }
  68. );
  69. }
  70. );
  71. }
  72. markmoveUP();
  73. moveCameras();
  74. $("#toolbar").hide();
  75. layer.open({
  76. title: "消防-灭火器定位",
  77. type: 1,
  78. offset: 'lt' //具体配置参考:offset参数项
  79. , content: '<div style="padding: 10px;width:300px;min-height:200px;background-color:rgba(255,255,255,0.4);">\
  80. <table class="table">\
  81. <tr><td style="text-align:right;width:80px;">序号</td><td>位置</td><td>定位</td></tr>\
  82. <tr><td style="text-align:center;width:80px;">1</td><td>大门口</td><td><button onclick="tl3dCoreBusiness.changeCameraPosition({ x: -270, y: 1274, z: -714 },{ x: 209, y: 705, z: -750 },1000)">定位</button></tr>\
  83. <tr><td style="text-align:center;width:80px;">2</td><td>密集架5和密集架6中间</td><td><button onclick="tl3dCoreBusiness.changeCameraPosition({ x: -574, y: 1430, z: -161 },{ x: 486, y: 134, z: -90 },1000)">定位</button></td></tr>\
  84. <tr><td style="text-align:center;width:80px;">3</td><td>密集架4和密集架5中间</td><td><button onclick="tl3dCoreBusiness.changeCameraPosition({ x: -574, y: 1430, z: -161 },{ x: 486, y: 134, z: -90 },1000)">定位</button></tr>\
  85. <tr><td style="text-align:center;width:80px;">4</td><td>密集架1和密集架2中间</td><td><button onclick="tl3dCoreBusiness.changeCameraPosition({ x: 196, y: 1262, z: 340},{ x: -639, y: 277, z: 216 },1000)">定位</button></tr>\
  86. <tr><td style="text-align:center;width:80px;">5</td><td>密集架2和密集架3中间</td><td><button onclick="tl3dCoreBusiness.changeCameraPosition({ x: 196, y: 1262, z: 340},{ x: -639, y: 277, z: 216 },1000)">定位</button></tr>\
  87. </table></div>'
  88. , btn:false
  89. , btnAlign: 'c' //按钮居中
  90. , shade: 0 //不显示遮罩
  91. , end: function () {
  92. _this.hideFireControls();
  93. }
  94. });
  95. }
  96. this.hideFireControls = function () {
  97. var _this = this;
  98. $("#toolbar").show();
  99. _this.EntityWalls();
  100. _this.showAllMjj();
  101. _this.removeMark();
  102. }

七、实时 3D 模拟消防火警 显示火灾参考情况

如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室,-第二课 - 图7

  1. /*烟感模拟部分*********************************************************************/
  2. //烟感模拟
  3. this.smokeSensors = [];//烟感
  4. this.getSmokeSensors = function () {
  5. var _this = this;
  6. if (_this.smokeSensors&&_this.smokeSensors.length == 0) {
  7. $.each(tl3DCoreObj.objects, function (_index, _obj) {
  8. if (_obj.name.indexOf("smokeSensor_") >= 0) {
  9. _this.smokeSensors.push(_obj);
  10. }
  11. });
  12. }
  13. }

八、场景内温度调节 并且有调节动画

如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室,-第二课 - 图8

  1. /*温度部分*********************************************************************/
  2. //温度调节模拟+云图
  3. this.changeTemplate = function () {
  4. var _this = this;
  5. $("#toolbar").hide();
  6. _this.hideCamera();
  7. _this.changeCameraPosition({ x: 540, y: 388, z: -524 }, { x: 0, y: 260, z: 130 }, 1000);
  8. //获取当前湿度值
  9. var hvalue = 28.5;
  10. //隐藏所有密集架
  11. this.hideAllMjj();
  12. if (this.templates.length == 0) {
  13. var tps = [300, -100, 300, 500, -500, -100, -500, 500]
  14. for (var i = 0; i < 4; i++) {
  15. var _obj1 = {
  16. show: true,
  17. name: "thermometer",
  18. objType: "Thermometer3D",
  19. position: { x: tps[2 * i], y: 400, z: tps[2 * i + 1] },
  20. rotation: [{ "direction": "x", "degree": 0 }],
  21. scale: { "x": 2, "y": 1.5, "z": 2},
  22. value: hvalue,
  23. }
  24. var temObj1 = tl3DCoreObj.createObjByJson(_obj1);
  25. tl3DCoreObj.addObject(temObj1);
  26. _this.templates.push(temObj1)
  27. }
  28. }
  29. for (var i = 0; i < _this.templates.length; i++) {
  30. _this.templates[i].position.y = 400;
  31. _this.templates[i].visible = true;
  32. }
  33. new TWEEN.Tween(_this.templates[0].position).to({
  34. y: 200
  35. }, 2000).onUpdate(function () {
  36. for (var i = 1; i < _this.templates.length; i++) {
  37. _this.templates[i].position.y = this.y;
  38. }
  39. }).easing(TWEEN.Easing.Elastic.Out).start();
  40. layer.closeAll();
  41. var videoUrl = "";
  42. layer.open({
  43. title: "调节温度",
  44. type: 1,
  45. anim: 2,
  46. content: '<div style="padding: 10px;width:240px;height:80px;background-color:rgba(255,255,255,0.71);text-align:center;">\
  47. 温度:<input type="text" style="width:100px" id="template_input" value="' + hvalue + '" />%\
  48. </div>'
  49. , btn: ["调节", "关闭"]
  50. , shade: 0 //不显示遮罩
  51. , yes: function () {
  52. var t = parseFloat($("#template_input").val());
  53. for (var i = 0; i < _this.templates.length; i++) {
  54. _this.templates[i].changeThermoneter(t);
  55. }
  56. },
  57. end: function () {
  58. _this.hideTemplate();
  59. }
  60. });
  61. var t = $("#template_input").val();
  62. $("#template_input").val("").focus().val(t)
  63. }
  64. this.hideTemplate = function () {
  65. var _this = this;
  66. $("#toolbar").show();
  67. _this.hideCamera();
  68. var _this = this;
  69. if (this.templates.length > 0) {
  70. for (var i = 0; i < _this.templates.length; i++) {
  71. _this.templates[i].position.y = 400;
  72. _this.templates[i].visible = false;
  73. }
  74. }
  75. _this.showAllMjj();
  76. }

九 、场景内湿度调节 有调节动画

如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室,-第二课 - 图9

  1. //湿度调节模拟+云图
  2. this.humiditys = [];
  3. this.changehumidity = function () {
  4. var _this = this;
  5. $("#toolbar").hide();
  6. _this.hideCamera();
  7. _this.changeCameraPosition({ x: -35, y: 647, z: -1190 }, { x: -37, y: 190, z: 95 }, 1000);
  8. //获取当前湿度值
  9. var hvalue = 28.5;
  10. //隐藏所有密集架
  11. this.hideAllMjj();
  12. if (this.humiditys.length == 0) {
  13. var humiditys = [300, -100, 300, 500, -500, -100, -500, 500]
  14. for (var i = 0; i < 4;i++){
  15. var humidity1 = {
  16. show: true,
  17. name: "humidity",
  18. objType: "Humidity",
  19. position: { x: humiditys[2 * i], y: 400, z: humiditys[2 * i+1] },
  20. rotation: [{ "direction": "x", "degree": 0 }],
  21. scale: { "x": 1, "y": 1, "z": 1 },
  22. value: hvalue,
  23. }
  24. var temObj1 = tl3DCoreObj.createObjByJson(humidity1);
  25. tl3DCoreObj.addObject(temObj1);
  26. _this.humiditys.push(temObj1)
  27. }
  28. }
  29. for (var i = 0; i < _this.humiditys.length;i++){
  30. _this.humiditys[i].position.y = 400;
  31. _this.humiditys[i].visible = true;
  32. }
  33. new TWEEN.Tween(_this.humiditys[0].position).to({
  34. y: 200
  35. }, 2000).onUpdate(function () {
  36. for (var i = 1; i < _this.humiditys.length; i++) {
  37. _this.humiditys[i].position.y = this.y;
  38. }
  39. }).easing(TWEEN.Easing.Elastic.Out).start();
  40. layer.closeAll();
  41. var videoUrl = "";
  42. layer.open({
  43. title: "调节湿度",
  44. type: 1,
  45. anim: 2,
  46. content: '<div style="padding: 10px;width:240px;height:80px;background-color:rgba(255,255,255,0.71);text-align:center;">\
  47. 湿度:<input type="text" style="width:100px" id="humidity_input" value="' + hvalue + '" />%\
  48. </div>'
  49. , btn: ["调节","关闭"]
  50. , shade: 0 //不显示遮罩
  51. , yes: function () {
  52. var t = parseFloat($("#humidity_input").val());
  53. for (var i = 0; i < _this.humiditys.length; i++) {
  54. _this.humiditys[i].changeThermoneter(t);
  55. }
  56. },
  57. end: function () {
  58. _this.hideHumidity();
  59. }
  60. });
  61. var t = $("#humidity_input").val();
  62. $("#humidity_input").val("").focus().val(t)
  63. }
  64. this.hideHumidity = function () {
  65. var _this = this;
  66. $("#toolbar").show();
  67. _this.hideCamera();
  68. var _this = this;
  69. if (this.humiditys.length > 0) {
  70. for (var i = 0; i < _this.humiditys.length;i++){
  71. _this.humiditys[i].position.y = 400;
  72. _this.humiditys[i].visible = false;
  73. }
  74. }
  75. _this.showAllMjj();
  76. }
  77. this.templates = [];

十、对场景内数据大屏 进行操控 屏幕切换

如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室,-第二课 - 图10

  1. /*大屏部分*********************************************************************/
  2. //获取大屏
  3. this.bigScreens = [];
  4. this.getScreens = function () {
  5. var _this = this;
  6. if (_this.bigScreens.length == 0) {
  7. $.each(tl3DCoreObj.objects, function (_index, _obj) {
  8. if (_obj.name.indexOf("wall_bigScreen_") >= 0) {
  9. _this.bigScreens.push(_obj);
  10. }
  11. });
  12. }
  13. return _this.bigScreens;
  14. }
  15. this.showBigScreenCtrls = function () {
  16. this.getScreens();
  17. $("#toolbar").hide();
  18. layer.open({
  19. title: "大屏定位-设置",
  20. type: 1,
  21. offset: 'lt' //具体配置参考:offset参数项
  22. , content: '<div style="padding: 10px;width:300px;min-height:200px;background-color:rgba(255,255,255,0.4);">\
  23. <table class="table">\
  24. <tr><td style="text-align:right;width:60px;">序号</td><td style="text-align:center;width:120px;">位置</td><td style="width:60px;">定位</td><td style="width:60px;">设置</td></tr>\
  25. <tr><td style="text-align:center;width:80px;">1</td><td style="text-align:center;">一号外墙大屏</td><td><button onclick="tl3dCoreBusiness.changeCameraPosition({ x:1013, y:335, z: -456 },{ x: 328, y: -37, z: -532 },1000)">定位</button></td><td><button onclick="tl3dCoreBusiness.setSreenParams(\'wall_bigScreen_1\')">设置</button></td></tr>\
  26. <tr><td style="text-align:center;width:80px;">2</td><td style="text-align:center;">二号室内大屏</td><td><button onclick="tl3dCoreBusiness.changeCameraPosition({ x: -310, y: 187, z: 452},{ x: -325, y: 147, z: 870 },1000)">定位</button></td><td><button onclick="tl3dCoreBusiness.setSreenParams(\'wall_bigScreen_2\')">设置</button></td></tr>\
  27. </table></div>'
  28. , btn: false
  29. , btnAlign: 'c' //按钮居中
  30. , shade: 0 //不显示遮罩
  31. , end: function () {
  32. $("#toolbar").show();
  33. }
  34. });
  35. }
  36. this.setSreenParams = function (sreenName) {
  37. var _screenobj = null;
  38. var _this = this;
  39. // layer.closeAll();
  40. for (var i = 0; i < _this.bigScreens.length; i++) {
  41. if (_this.bigScreens[i].name == sreenName) {
  42. _screenobj = _this.bigScreens[i];
  43. }
  44. }
  45. var screenType = "1";//1图片 2视频
  46. var screenUrl = "../../img/3dImg/tv.jpg";
  47. if (_screenobj && _screenobj.screenType) {
  48. screenType = _screenobj.screenType
  49. }
  50. if (_screenobj && _screenobj.screenUrl) {
  51. screenUrl = _screenobj.screenUrl
  52. }
  53. var layerindex=layer.open({
  54. title: "大屏定位-设置",
  55. type: 1,
  56. offset: 'lt' //具体配置参考:offset参数项
  57. , content: '<div style="padding: 10px;width:300px;min-height:100px;background-color:rgba(255,255,255,1);">\
  58. <table class="table">\
  59. <tr><td style="text-align:right;width:60px;">类型:</td><td>' + '<label><input name="screenTypeAndUrl" type="radio" ' + (screenType == "1" ? " checked='checked' " : "") + ' value="1" />图片 </label>\
  60. <label><input name="screenTypeAndUrl" type="radio" ' + (screenType == "2" ? " checked='checked' " : "") + ' value="2" />视频 </label> </td></tr>\
  61. <tr><td style="text-align:right;width:60px;">url:</td><td><input onclick="var t = $(\'#screenUrl\').val();$(\'#screenUrl\').val(\'\').focus().val(t)" id="screenUrl" value="' + screenUrl + '" /></td></tr>\
  62. </table></div>'
  63. , btn: ["确定","取消"]
  64. , btnAlign: 'c' //按钮居中
  65. , shade: 0 //不显示遮罩
  66. , yes: function () {
  67. var setScreenType = $("input:radio[name='screenTypeAndUrl']:checked").val();
  68. var setScreenUrl = $("#screenUrl").val();
  69. if (setScreenType == "1") {
  70. tl3DCoreObj.commonFunc.setObjSkinImg(_screenobj, 0, setScreenUrl);
  71. } else {
  72. tl3DCoreObj.commonFunc.setObjSkinVideo(_screenobj, 0, setScreenUrl, sreenName);
  73. }
  74. _screenobj.screenType = setScreenType;
  75. _screenobj.screenUrl = setScreenUrl;
  76. layer.close(layerindex);
  77. }
  78. , end: function () {
  79. }
  80. });
  81. $("#canvas-frame canvas").dblclick();
  82. var t = $('#screenUrl').val();$('#screenUrl').val("").focus().val(t);
  83. }

十一、对场景内通风系统进行 3D 操作 并且有过度动画

如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室,-第二课 - 图11

  1. /*风控部分***********************************************************************/
  2. //风控按钮
  3. this.showWindsCtrl = function () {
  4. var _this = this;
  5. $("#toolbar").hide();
  6. _this.changeCameraPosition({ x: 430, y: 1449, z: -2557 }, { x: 8, y: 234, z: 814 }, 1000);
  7. if (_this.windsISOPEN) {
  8. _this.openWinds();
  9. layer.confirm('当前风控开启状态,是否关闭风控按钮?', {
  10. offset: 'lt' ,
  11. btn: ['关闭', '取消'] //按钮
  12. }, function () {
  13. _this.closeWinds();
  14. layer.msg("已关闭");
  15. _this.windsISOPEN = false;
  16. $("#toolbar").show();
  17. layer.closeAll();
  18. }, function () {
  19. $("#toolbar").show();
  20. _this.hiddenIngWinds();
  21. layer.closeAll();
  22. });
  23. } else {
  24. layer.confirm('当前风控关闭状态,是否开启风控按钮?', {
  25. offset: 'lt',
  26. btn: ['开启', '取消'] //按钮
  27. }, function () {
  28. _this.openWinds();
  29. layer.msg("已开启")
  30. layer.closeAll();
  31. _this.windsISOPEN = true;
  32. setTimeout(function () {
  33. _this.hiddenIngWinds();
  34. $("#toolbar").show();
  35. }, 2000);
  36. }, function () {
  37. $("#toolbar").show();
  38. layer.closeAll();
  39. });
  40. }
  41. }
  42. this.openWinds = function () {
  43. var _this=this;
  44. var _winds = [
  45. { "name": "win_1_1","position": {"x": 0,"y": -100,"z": 640},"rotation": {x:0,y:0,z:0},},
  46. { "name": "win_1_2", "position": { "x": 0, "y": -100, "z":110 }, "rotation": { x: 0, y: 0, z: 0 }, },
  47. { "name": "win_1_3", "position": { "x": 0, "y": -100, "z": -400 }, "rotation": { x: 0, y: 0, z: 0 }, },
  48. { "name": "win_1_4", "position": { "x": -240, "y": -100, "z": -400 }, "rotation": { x: -3.141592653589793, y: 0, z: -3.141592653589793 }, },
  49. { "name": "win_1_5", "position": { "x": -240, "y": -100, "z": 110 }, "rotation": { x: -3.141592653589793, y: 0, z: -3.141592653589793 }, },
  50. { "name": "win_1_6", "position": { "x": -240, "y": -100, "z": 640 }, "rotation": { x: -3.141592653589793, y: 0, z: -3.141592653589793 }, },
  51. ];
  52. if (_this.winds.length <= 0) {
  53. $.each(_winds, function (_index,_obj) {
  54. _this.createWind(_obj.position,_obj.name,_obj.rotation);
  55. })
  56. }
  57. $.each(_this.winds, function (_index, _obj) {
  58. _obj.visible = true;
  59. });
  60. }
  61. this.closeWinds = function () {
  62. var _this = this;
  63. if (_this.winds.length > 0) {
  64. $.each(_this.winds, function (_index, _obj) {
  65. _obj.visible = false;
  66. });
  67. }
  68. }

十二、对场景内空调 中央空调进行 3D 操作 并且有过度动画

如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室,-第二课 - 图12

  1. //空调
  2. this.airConditionerCtls = function () {
  3. var _this = this;
  4. $("#toolbar").hide();
  5. //获取到文件位置信息
  6. //边缘弹出
  7. layer.open({
  8. title: "空调控制",
  9. type: 1,
  10. offset: 'lt' //具体配置参考:offset参数项
  11. , content: '<div style="padding: 10px;width:300px;min-height:120px;background-color:rgba(255,255,255,0.4);">\
  12. <table class="table">\
  13. <tr><td style="text-align:center;width:80px;">空调</td><td style="text-align:center;width:200px;">操作</td></tr>\
  14. <tr><td style="text-align:left;width:80px;">立柜空调</td><td style="text-align:center;">\
  15. <button id="LGAC_btn1" onclick="tl3dCoreBusiness.changeCameraPosition({x: -98, y: 356, z: 407},{x: -75, y: 121, z: 762},1000)">定位</button>\
  16. <button id="LGAC_btn2" onclick="tl3dCoreBusiness.openLSAirconditioner(\'aircondition_57\')">开启</button>\
  17. <button id="LGAC_btn3" onclick="tl3dCoreBusiness.closeLSAirconditioner(\'aircondition_57\')">关闭</button>\
  18. </td></tr>\
  19. <tr><td style="text-align:left;width:80px;">中央空调</td><td style="text-align:center;">\
  20. <button onclick="tl3dCoreBusiness.showCenterAirConditioner()" id="centerAC_btn1">定位</button>\
  21. <button onclick="tl3dCoreBusiness.openCenterAirConditioner()" id="centerAC_btn2">开启</button>\
  22. <button onclick="tl3dCoreBusiness.closeCenterAirConditioner()" id="centerAC_btn3">关闭</button>\
  23. </td></tr>\
  24. </table></div>'
  25. , btn: false
  26. , btnAlign: 'c' //按钮居中
  27. , shade: 0 //不显示遮罩
  28. , end: function () {
  29. $("#toolbar").show();
  30. _this.hideCenterAirConditioner();
  31. _this.hideLSAirconditioner();
  32. }
  33. });
  34. }
  35. this.LGAirConditions = [];
  36. //开启立式空调
  37. this.openLSAirconditioner = function (airConName) {
  38. var tempAirWind=null;
  39. var _this = this;
  40. var aircondition = tl3DCoreObj.commonFunc.findObject(airConName);
  41. if (this.LGAirConditions && this.LGAirConditions.length > 0) {
  42. $.each(this.LGAirConditions, function (_index, _obj) {
  43. if (_obj.name == airConName + "_wind_1") {
  44. tempAirWind = _obj;
  45. }
  46. });
  47. }
  48. //{x: -82.581, y: 92.342, z: 743.966}
  49. if (tempAirWind == null) {
  50. var lgairwin = {
  51. "show": true, "uuid": "",
  52. "name":airConName+"_wind_1",// "lgAirC_wind_1",
  53. "objType": "flowTube",
  54. "points": [{ "x": 0, "y": 200, "z": 0 }, { "x": 0, "y": 150, "z": -60 }, { "x": 0, "y": 150, "z": -200 }],
  55. "position": { "x": aircondition.position.x, "y": aircondition.position.y - 122, "z": aircondition.position.z - 13 },
  56. "scale": { "x": 1, "y": 1, "z": 1 },
  57. "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }],
  58. "style": { "skinColor": 16772846, "imgurl": "../../img/3dImg/right2wind.png", "opacity": 1, "canvasSkin": { "cwidth": 1024, "cheight": 128, "cwNub": 16, "chNub": 8, "cMarginW": 0.2, "cMarginH": 0.2, "speed": 8, "fps": 40, "direction": "w", "forward": "f", "side": 1, "run": true, "bgcolor": "rgba(255, 227, 248, 0.02)" } }, "segments": 64, "radialSegments": 2, "closed": false, "radius": 20, "showSortNub": 196, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null
  59. }
  60. var temObj1 = tl3DCoreObj.createObjByJson(lgairwin);
  61. tl3DCoreObj.addObject(temObj1);
  62. _this.LGAirConditions.push(temObj1);
  63. tempAirWind = temObj1;
  64. }
  65. if (tempAirWind) {
  66. tempAirWind.visible = true;
  67. }
  68. }
  69. //关闭立式空调
  70. this.closeLSAirconditioner = function (airConName,isCloseAll) {
  71. var _this = this;
  72. if (this.LGAirConditions && this.LGAirConditions.length > 0) {
  73. $.each(this.LGAirConditions, function (_index, _obj) {
  74. if (_obj.name == airConName + "_wind_1") {
  75. _obj.visible = false;
  76. }
  77. if (isCloseAll) {
  78. _obj.visible = false;
  79. }
  80. });
  81. }
  82. }
  83. //隐藏立式空调风口动画
  84. this.hideLSAirconditioner = function () {
  85. var _this = this;
  86. if (this.LGAirConditions && this.LGAirConditions.length > 0) {
  87. $.each(this.LGAirConditions, function (_index, _obj) {
  88. _obj.visible = false;
  89. });
  90. }
  91. }
  92. //开启中央空调
  93. this.centerAirConditionerDevs = [];
  94. //显示中央空调设备
  95. this.showCenterAirConditioner = function () {
  96. var _this = this;
  97. if (_this.centerAirConditionerDevs.length <= 0) {
  98. var centerAirCondition = [
  99. { "show": true, "uuid": "", "name": "center_air_conditioning_2_2", "objType": "cube2", "length": 78, "width": 78, "height": 40, "x": -80.785, "y": 370.664, "z": -456.654, "style": { "skinColor": 16777215, "skin": { "skin_up": { "skinColor": 16777215, "side": 1, "opacity": 0 }, "skin_down": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_fore": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_behind": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_left": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_right": { "skinColor": 16777215, "side": 1, "opacity": 0.3 } } }, "showSortNub": 7, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "center_air_conditioning_2_3", "objType": "cube2", "length": 78, "width": 78, "height": 40, "x": -80.785, "y": 370.664, "z": 518.684, "style": { "skinColor": 16777215, "skin": { "skin_up": { "skinColor": 16777215, "side": 1, "opacity": 0 }, "skin_down": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_fore": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_behind": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_left": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_right": { "skinColor": 16777215, "side": 1, "opacity": 0.3 } } }, "showSortNub": 7, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "center_air_conditioning_2_1", "objType": "cube2", "length": 78, "width": 78, "height": 40, "x": -80.785, "y": 370.664, "z": 48.478, "style": { "skinColor": 16777215, "skin": { "skin_up": { "skinColor": 16777215, "side": 1, "opacity": 0 }, "skin_down": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_fore": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_behind": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_left": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_right": { "skinColor": 16777215, "side": 1, "opacity": 0.3 } } }, "showSortNub": 7, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "center_air_conditioning_1_1", "objType": "cube2", "length": 78, "width": 78, "height": 40, "x": -605.659, "y": 370.664, "z": 48.478, "style": { "skinColor": 16777215, "skin": { "skin_up": { "skinColor": 16777215, "side": 1, "opacity": 0 }, "skin_down": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_fore": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_behind": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_left": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_right": { "skinColor": 16777215, "side": 1, "opacity": 0.3 } } }, "showSortNub": 7, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "center_air_conditioning_1_2", "objType": "cube2", "length": 78, "width": 78, "height": 40, "x": -605.659, "y": 370.664, "z": -467.654, "style": { "skinColor": 16777215, "skin": { "skin_up": { "skinColor": 16777215, "side": 1, "opacity": 0 }, "skin_down": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_fore": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_behind": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_left": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_right": { "skinColor": 16777215, "side": 1, "opacity": 0.3 } } }, "showSortNub": 7, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "center_air_conditioning_1_3", "objType": "cube2", "length": 78, "width": 78, "height": 40, "x": -605.659, "y": 370.664, "z": 553.501, "style": { "skinColor": 16777215, "skin": { "skin_up": { "skinColor": 16777215, "side": 1, "opacity": 0 }, "skin_down": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_fore": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_behind": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_left": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_right": { "skinColor": 16777215, "side": 1, "opacity": 0.3 } } }, "showSortNub": 7, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "center_air_conditioning_3_1", "objType": "cube2", "length": 78, "width": 78, "height": 40, "x": 442.379, "y": 370.664, "z": 48.478, "style": { "skinColor": 16777215, "skin": { "skin_up": { "skinColor": 16777215, "side": 1, "opacity": 0 }, "skin_down": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_fore": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_behind": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_left": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_right": { "skinColor": 16777215, "side": 1, "opacity": 0.3 } } }, "showSortNub": 7, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "center_air_conditioning_3_2", "objType": "cube2", "length": 78, "width": 78, "height": 40, "x": 442.379, "y": 370.664, "z": -461.396, "style": { "skinColor": 16777215, "skin": { "skin_up": { "skinColor": 16777215, "side": 1, "opacity": 0 }, "skin_down": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_fore": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_behind": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_left": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_right": { "skinColor": 16777215, "side": 1, "opacity": 0.3 } } }, "showSortNub": 7, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "center_air_conditioning_3_3", "objType": "cube2", "length": 78, "width": 78, "height": 40, "x": 442.379, "y": 370.664, "z": 526.744, "style": { "skinColor": 16777215, "skin": { "skin_up": { "skinColor": 16777215, "side": 1, "opacity": 0 }, "skin_down": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_fore": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_behind": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_left": { "skinColor": 16777215, "side": 1, "opacity": 0.3 }, "skin_right": { "skinColor": 16777215, "side": 1, "opacity": 0.3 } } }, "showSortNub": 7, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "cacWind_1", "objType": "flowTube", "points": [{ "x": 0, "y": 0, "z": 1500 }, { "x": 0, "y": 0, "z": 0 }], "position": { "x": -70.779, "y": 419.052, "z": -751.968 }, "scale": { "x": 1, "y": 1, "z": 1 }, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "style": { "skinColor": 16772846, "imgurl": "../../img/3dImg/right2wind.png", "opacity": 1, "canvasSkin": { "cwidth": 1024, "cheight": 128, "cwNub": 32, "chNub": 8, "cMarginW": 0.2, "cMarginH": 0.2, "speed": 3, "fps": 40, "direction": "w", "forward": "f", "side": 2, "run": true, "bgcolor": "rgba(4, 4, 4, 0.098)" } }, "segments": 4, "radialSegments": 4, "closed": false, "radius": 40, "showSortNub": 16, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "cacWind_3", "objType": "flowTube", "points": [{ "x": 0, "y": 0, "z": 1500 }, { "x": 0, "y": 0, "z": 0 }], "position": { "x": 443.302, "y": 419.052, "z": -751.968 }, "scale": { "x": 1, "y": 1, "z": 1 }, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "style": { "skinColor": 16772846, "imgurl": "../../img/3dImg/right2wind.png", "opacity": 1, "canvasSkin": { "cwidth": 1024, "cheight": 128, "cwNub": 32, "chNub": 8, "cMarginW": 0.2, "cMarginH": 0.2, "speed": 3, "fps": 40, "direction": "w", "forward": "f", "side": 2, "run": true, "bgcolor": "rgba(4, 4, 4, 0.098)" } }, "segments": 4, "radialSegments": 4, "closed": false, "radius": 40, "showSortNub": 16, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "cacWind_2", "objType": "flowTube", "points": [{ "x": 0, "y": 0, "z": 1500 }, { "x": 0, "y": 0, "z": 0 }], "position": { "x": -604.569, "y": 419.052, "z": -751.968 }, "scale": { "x": 1, "y": 1, "z": 1 }, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "style": { "skinColor": 16772846, "imgurl": "../../img/3dImg/right2wind.png", "opacity": 1, "canvasSkin": { "cwidth": 1024, "cheight": 128, "cwNub": 32, "chNub": 8, "cMarginW": 0.2, "cMarginH": 0.2, "speed": 3, "fps": 40, "direction": "w", "forward": "f", "side": 2, "run": true, "bgcolor": "rgba(4, 4, 4, 0.098)" } }, "segments": 4, "radialSegments": 4, "closed": false, "radius": 40, "showSortNub": 16, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "center_air_conditioning_1", "objType": "cube2", "length": 80, "width": 1500, "height": 80, "x": 444.17, "y": 426.022, "z": 0, "style": { "skinColor": 16777215, "skin": { "skin_up": { "skinColor": 7895160, "side": 0, "opacity": 0.4 }, "skin_down": { "skinColor": 7895160, "side": 0, "opacity": 0.3 }, "skin_fore": { "skinColor": 16777215, "side": 0, "opacity": 0.3 }, "skin_behind": { "skinColor": 16777215, "side": 0, "opacity": 0.3 }, "skin_left": { "skinColor": 16777215, "side": 0, "opacity": 0 }, "skin_right": { "skinColor": 16777215, "side": 0, "opacity": 0 } } }, "showSortNub": 196, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "center_air_conditioning_2", "objType": "cube2", "length": 80, "width": 1500, "height": 80, "x": -76.111, "y": 419.507, "z": 0, "style": { "skinColor": 16777215, "skin": { "skin_up": { "skinColor": 7895160, "side": 0, "opacity": 0.4 }, "skin_down": { "skinColor": 7895160, "side": 0, "opacity": 0.3 }, "skin_fore": { "skinColor": 16777215, "side": 0, "opacity": 0.3 }, "skin_behind": { "skinColor": 16777215, "side": 0, "opacity": 0.3 }, "skin_left": { "skinColor": 16777215, "side": 0, "opacity": 0 }, "skin_right": { "skinColor": 16777215, "side": 0, "opacity": 0 } } }, "showSortNub": 196, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "center_air_conditioning_3", "objType": "cube2", "length": 80, "width": 1500, "height": 80, "x": -604.307, "y": 426.022, "z": 0, "style": { "skinColor": 16777215, "skin": { "skin_up": { "skinColor": 7895160, "side": 0, "opacity": 0.4 }, "skin_down": { "skinColor": 7895160, "side": 0, "opacity": 0.3 }, "skin_fore": { "skinColor": 16777215, "side": 0, "opacity": 0.3 }, "skin_behind": { "skinColor": 16777215, "side": 0, "opacity": 0.3 }, "skin_left": { "skinColor": 16777215, "side": 0, "opacity": 0 }, "skin_right": { "skinColor": 16777215, "side": 0, "opacity": 0 } } }, "showSortNub": 196, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "cacWind_1_1", "objType": "flowTube", "points": [{ "x": 0, "y": 200, "z": 0 }, { "x": 50, "y": 50, "z": 0 }, { "x": 150, "y": -50, "z": null }], "position": { "x": -51.031, "y": 182.086, "z": -450.709 }, "scale": { "x": 1, "y": 1, "z": 1 }, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "style": { "skinColor": 16772846, "imgurl": "../../img/3dImg/right2wind.png", "opacity": 1, "canvasSkin": { "cwidth": 1024, "cheight": 128, "cwNub": 8, "chNub": 2, "cMarginW": 0.2, "cMarginH": 0.2, "speed": 8, "fps": 40, "direction": "w", "forward": "f", "side": 1, "run": true, "bgcolor": "rgba(4, 4, 4, 0.098)" } }, "segments": 6, "radialSegments": 2, "closed": false, "radius": 20, "showSortNub": 16, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "cacWind_1_3", "objType": "flowTube", "points": [{ "x": 0, "y": 200, "z": 0 }, { "x": 50, "y": 50, "z": 0 }, { "x": 150, "y": -50, "z": null }], "position": { "x": -51.031, "y": 182.086, "z": 518.391 }, "scale": { "x": 1, "y": 1, "z": 1 }, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "style": { "skinColor": 16772846, "imgurl": "../../img/3dImg/right2wind.png", "opacity": 1, "canvasSkin": { "cwidth": 1024, "cheight": 128, "cwNub": 8, "chNub": 2, "cMarginW": 0.2, "cMarginH": 0.2, "speed": 8, "fps": 40, "direction": "w", "forward": "f", "side": 1, "run": true, "bgcolor": "rgba(4, 4, 4, 0.098)" } }, "segments": 6, "radialSegments": 2, "closed": false, "radius": 20, "showSortNub": 16, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "cacWind_1_2", "objType": "flowTube", "points": [{ "x": 0, "y": 200, "z": 0 }, { "x": 50, "y": 50, "z": 0 }, { "x": 150, "y": -50, "z": null }], "position": { "x": -51.031, "y": 182.086, "z": 56.652 }, "scale": { "x": 1, "y": 1, "z": 1 }, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "style": { "skinColor": 16772846, "imgurl": "../../img/3dImg/right2wind.png", "opacity": 1, "canvasSkin": { "cwidth": 1024, "cheight": 128, "cwNub": 8, "chNub": 2, "cMarginW": 0.2, "cMarginH": 0.2, "speed": 8, "fps": 40, "direction": "w", "forward": "f", "side": 1, "run": true, "bgcolor": "rgba(4, 4, 4, 0.098)" } }, "segments": 6, "radialSegments": 2, "closed": false, "radius": 20, "showSortNub": 16, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "cacWind_3_1", "objType": "flowTube", "points": [{ "x": 0, "y": 200, "z": 0 }, { "x": 50, "y": 50, "z": 0 }, { "x": 150, "y": -50, "z": null }], "position": { "x": -596.596, "y": 182.086, "z": -450.709 }, "scale": { "x": 1, "y": 1, "z": 1 }, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "style": { "skinColor": 16772846, "imgurl": "../../img/3dImg/right2wind.png", "opacity": 1, "canvasSkin": { "cwidth": 1024, "cheight": 128, "cwNub": 8, "chNub": 2, "cMarginW": 0.2, "cMarginH": 0.2, "speed": 8, "fps": 40, "direction": "w", "forward": "f", "side": 1, "run": true, "bgcolor": "rgba(4, 4, 4, 0.098)" } }, "segments": 6, "radialSegments": 2, "closed": false, "radius": 20, "showSortNub": 16, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "cacWind_3_2", "objType": "flowTube", "points": [{ "x": 0, "y": 200, "z": 0 }, { "x": 50, "y": 50, "z": 0 }, { "x": 150, "y": -50, "z": null }], "position": { "x": -596.596, "y": 182.086, "z": 69.057 }, "scale": { "x": 1, "y": 1, "z": 1 }, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "style": { "skinColor": 16772846, "imgurl": "../../img/3dImg/right2wind.png", "opacity": 1, "canvasSkin": { "cwidth": 1024, "cheight": 128, "cwNub": 8, "chNub": 2, "cMarginW": 0.2, "cMarginH": 0.2, "speed": 8, "fps": 40, "direction": "w", "forward": "f", "side": 1, "run": true, "bgcolor": "rgba(4, 4, 4, 0.098)" } }, "segments": 6, "radialSegments": 2, "closed": false, "radius": 20, "showSortNub": 16, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "cacWind_3_3", "objType": "flowTube", "points": [{ "x": 0, "y": 200, "z": 0 }, { "x": 50, "y": 50, "z": 0 }, { "x": 150, "y": -50, "z": null }], "position": { "x": -596.596, "y": 182.086, "z": 571.083 }, "scale": { "x": 1, "y": 1, "z": 1 }, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "style": { "skinColor": 16772846, "imgurl": "../../img/3dImg/right2wind.png", "opacity": 1, "canvasSkin": { "cwidth": 1024, "cheight": 128, "cwNub": 8, "chNub": 2, "cMarginW": 0.2, "cMarginH": 0.2, "speed": 8, "fps": 40, "direction": "w", "forward": "f", "side": 1, "run": true, "bgcolor": "rgba(4, 4, 4, 0.098)" } }, "segments": 6, "radialSegments": 2, "closed": false, "radius": 20, "showSortNub": 16, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "cacWind_2_1", "objType": "flowTube", "points": [{ "x": 0, "y": 200, "z": 0 }, { "x": 50, "y": 50, "z": 0 }, { "x": 150, "y": -50, "z": null }], "position": { "x": 449.11, "y": 182.086, "z": -450.709 }, "scale": { "x": 1, "y": 1, "z": 1 }, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "style": { "skinColor": 16772846, "imgurl": "../../img/3dImg/right2wind.png", "opacity": 1, "canvasSkin": { "cwidth": 1024, "cheight": 128, "cwNub": 8, "chNub": 2, "cMarginW": 0.2, "cMarginH": 0.2, "speed": 8, "fps": 40, "direction": "w", "forward": "f", "side": 1, "run": true, "bgcolor": "rgba(4, 4, 4, 0.098)" } }, "segments": 6, "radialSegments": 2, "closed": false, "radius": 20, "showSortNub": 16, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "cacWind_2_2", "objType": "flowTube", "points": [{ "x": 0, "y": 200, "z": 0 }, { "x": 50, "y": 50, "z": 0 }, { "x": 150, "y": -50, "z": null }], "position": { "x": 449.11, "y": 182.086, "z": 58.707 }, "scale": { "x": 1, "y": 1, "z": 1 }, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "style": { "skinColor": 16772846, "imgurl": "../../img/3dImg/right2wind.png", "opacity": 1, "canvasSkin": { "cwidth": 1024, "cheight": 128, "cwNub": 8, "chNub": 2, "cMarginW": 0.2, "cMarginH": 0.2, "speed": 8, "fps": 40, "direction": "w", "forward": "f", "side": 1, "run": true, "bgcolor": "rgba(4, 4, 4, 0.098)" } }, "segments": 6, "radialSegments": 2, "closed": false, "radius": 20, "showSortNub": 16, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }, { "show": true, "uuid": "", "name": "cacWind_2_3", "objType": "flowTube", "points": [{ "x": 0, "y": 200, "z": 0 }, { "x": 50, "y": 50, "z": 0 }, { "x": 150, "y": -50, "z": null }], "position": { "x": 449.11, "y": 182.086, "z": 550.649 }, "scale": { "x": 1, "y": 1, "z": 1 }, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "style": { "skinColor": 16772846, "imgurl": "../../img/3dImg/right2wind.png", "opacity": 1, "canvasSkin": { "cwidth": 1024, "cheight": 128, "cwNub": 8, "chNub": 2, "cMarginW": 0.2, "cMarginH": 0.2, "speed": 8, "fps": 40, "direction": "w", "forward": "f", "side": 1, "run": true, "bgcolor": "rgba(4, 4, 4, 0.098)" } }, "segments": 6, "radialSegments": 2, "closed": false, "radius": 20, "showSortNub": 16, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }]
  100. $.each(centerAirCondition,function(_index,_obj){
  101. var temObj1 = tl3DCoreObj.createObjByJson(_obj);
  102. tl3DCoreObj.addObject(temObj1);
  103. _this.centerAirConditionerDevs.push(temObj1)
  104. })
  105. }
  106. if (_this.centerAirConditionerDevs.length > 0) {
  107. $.each(_this.centerAirConditionerDevs, function (_index, _obj) {
  108. _obj.visible = true;
  109. })
  110. }
  111. //获取中央空调开关状态
  112. var isopen = true;//此处调用函数 获取中央空调状态
  113. if (isopen) {
  114. _this.openCenterAirConditioner();
  115. } else {
  116. _this.closeCenterAirConditioner();
  117. }
  118. }
  119. //隐藏中央空调设备
  120. this.hideCenterAirConditioner = function () {
  121. var _this = this;
  122. if (_this.centerAirConditionerDevs.length > 0) {
  123. $.each(_this.centerAirConditionerDevs, function (_index, _obj) {
  124. _obj.visible = false;
  125. })
  126. }
  127. }
  128. //打开中央空调
  129. this.openCenterAirConditioner = function () {
  130. var _this = this;
  131. _this.showCenterAirConditioner();
  132. if (_this.centerAirConditionerDevs.length > 0) {
  133. $.each(_this.centerAirConditionerDevs, function (_index, _obj) {
  134. if (_obj.name.indexOf("cacWind_") >= 0) {
  135. _obj.visible = true;
  136. }
  137. })
  138. }
  139. }
  140. //关闭中央空调
  141. this.closeCenterAirConditioner = function () {
  142. var _this = this;
  143. $("#centerAC_btn1").attr("disabled", true);
  144. $("#centerAC_btn2").attr("disabled", true);
  145. $("#centerAC_btn3").attr("disabled", true);
  146. if (_this.centerAirConditionerDevs.length > 0) {
  147. $.each(_this.centerAirConditionerDevs, function (_index, _obj) {
  148. if (_obj.name.indexOf("cacWind_") >= 0) {
  149. _obj.visible = false;
  150. }
  151. })
  152. }
  153. setTimeout(function () {
  154. _this.hideCenterAirConditioner();
  155. $("#centerAC_btn1").attr("disabled", false);
  156. $("#centerAC_btn2").attr("disabled", false);
  157. $("#centerAC_btn3").attr("disabled", false);
  158. }, 2000);
  159. }

十三、打开 3D 场景内告警监控,3D 实时模拟显示告警情况

如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室,-第二课 - 图13

  1. //告警绑定
  2. this.alarmIntervals = [];
  3. //添加3D告警动画
  4. this.alarmObj = function (alarmObj, AlarmColor, alarmId) {
  5. var _this = this;
  6. var _canPush = true;
  7. if (_this.alarmIntervals.length > 0) {
  8. $.each(_this.alarmIntervals, function (_index, _obj) {
  9. if (alarmId == _obj.alarmId) {
  10. _canPush = false;
  11. }
  12. });
  13. }
  14. if (_canPush) {
  15. var interval = setInterval(function () {
  16. if (alarmObj && alarmObj.alarmColor && alarmObj.alarmColor == AlarmColor) {
  17. tl3DCoreObj.commonFunc.setSkinColorByObj(alarmObj, 0x000000);
  18. alarmObj.alarmColor = 0x000000;
  19. } else {
  20. tl3DCoreObj.commonFunc.setSkinColorByObj(alarmObj, AlarmColor);
  21. alarmObj.alarmColor = AlarmColor;
  22. }
  23. }, 400);
  24. _this.alarmIntervals.push({ alarmobjname: alarmObj.name, alarmInterval: interval, alarmId: alarmId })
  25. }
  26. }
  27. //消除3D告警动画
  28. this.cleanAlarm = function (alarmObj,alarmId) {
  29. var _this = this;
  30. var _alarmIndex = -1;
  31. if (_this.alarmIntervals.length > 0) {
  32. $.each(_this.alarmIntervals, function (_index, _obj) {
  33. if (alarmId == _obj.alarmId) {
  34. _alarmIndex = _index;
  35. tl3DCoreObj.commonFunc.setSkinColorByObj(alarmObj, 0x000000);
  36. alarmObj.alarmColor = 0x000000;
  37. clearInterval(_obj.alarmInterval);
  38. }
  39. });
  40. }
  41. if (_alarmIndex >= 0) {
  42. _this.alarmIntervals.splice(_alarmIndex, 1);
  43. }
  44. }
  45. this.alarmMonitorIntervals = null;
  46. this.alarmMonitorBackgroundColorOprity = 0;
  47. this.alarmMonitorBackgroundColorOprityOP = 1;//1是加 -1是减
  48. //点击告警监控按钮
  49. this.alarmMonitorCtrl = function () {
  50. var _this = this;
  51. _this.changeCameraPosition({ x: 430, y: 1449, z: -2557 }, { x: 8, y: 234, z: 814 }, 1000);
  52. $("#btn_alarmCtrl").css("border-radius", "25px 25px 25px 25px");
  53. if ($("#btn_alarmCtrl").attr("data_state") && $("#btn_alarmCtrl").attr("data_state") == "runing") {
  54. layer.msg("告警监控已关闭");
  55. $("#btn_alarmCtrl").attr("data_state", "close");
  56. $("#btn_alarmCtrl").css("background", "rgba(255, 255, 0, 0)");
  57. $("#btn_alarmCtrl").attr("title", "启动告警监控");
  58. if (_this.alarmMonitorIntervals) {
  59. clearInterval(_this.alarmMonitorIntervals);
  60. }
  61. _this.closeAlarmMonitor();
  62. } else {
  63. _this.startAlarmMonitor();
  64. _this.alarmMonitorBackgroundColorOprity = 0;
  65. $("#btn_alarmCtrl").attr("data_state", "runing");
  66. $("#btn_alarmCtrl").attr("title", "关闭告警监控");
  67. layer.msg("告警监控已开启");
  68. if (_this.alarmMonitorIntervals) {
  69. clearInterval(_this.alarmMonitorIntervals);
  70. }
  71. _this.alarmMonitorIntervals = setInterval(function () {
  72. if (_this.alarmMonitorBackgroundColorOprityOP == 1) {
  73. _this.alarmMonitorBackgroundColorOprity += 0.05
  74. }else {
  75. _this.alarmMonitorBackgroundColorOprity -= 0.05
  76. }
  77. if (_this.alarmMonitorBackgroundColorOprity >= 1) {
  78. _this.alarmMonitorBackgroundColorOprityOP = -1;
  79. } else if (_this.alarmMonitorBackgroundColorOprity <=0) {
  80. _this.alarmMonitorBackgroundColorOprityOP = 1;
  81. }
  82. $("#btn_alarmCtrl").css("background", "rgba(255, 255, 0, " + _this.alarmMonitorBackgroundColorOprity + ")");
  83. }, 50);
  84. }
  85. }
  86. this.alarmObjList = []; /*{alarmObjName, AlarmColor, alarmId,alarmState:"start"} alarmState:“start” "end" */
  87. //获取实时告警列表
  88. this.getAlarmObjList = function () {
  89. var result = [
  90. {
  91. alarmObjName: "mjj_3_6",
  92. AlarmColor: 0xff0000,
  93. alarmId: "mjj_3_6",
  94. alarmState: "start"
  95. },
  96. {
  97. alarmObjName: "smokeSensor_1",
  98. AlarmColor: 0xff0000,
  99. alarmId: "smokeSensor_1",
  100. alarmState: "start"
  101. },
  102. {
  103. alarmObjName: "mjj_1_1",
  104. AlarmColor: 0xff0000,
  105. alarmId: "mjj_1_1",
  106. alarmState: "start"
  107. },
  108. {
  109. alarmObjName: "mjj_5_3",
  110. AlarmColor: 0xff0000,
  111. alarmId: "mjj_5_3",
  112. alarmState: "start"
  113. }];
  114. return result;
  115. }
  116. //开启告警监控 当服务端告警有改变时 可以调用此接口
  117. this.startAlarmMonitor = function () {
  118. var _this = this;
  119. _this.closeAlarmMonitor();
  120. //获取告警列表
  121. this.alarmObjList = _this.getAlarmObjList();
  122. if (_this.alarmObjList && _this.alarmObjList.length > 0) {
  123. $.each(_this.alarmObjList, function (_index, _obj) {
  124. var tl3dObj = tl3DCoreObj.commonFunc.findObject(_obj.alarmObjName);
  125. if (tl3dObj) {
  126. _obj.tl3dObj = tl3dObj;
  127. if (_obj.alarmState == "start") {
  128. if (tl3dObj.name.indexOf("smokeSensor_") >= 0) {//如果是烟感告警 特殊处理
  129. _this.alarmSmokeSensor(tl3dObj);
  130. }else{
  131. _this.alarmObj(tl3dObj, _obj.AlarmColor, _obj.alarmId);
  132. }
  133. }
  134. }
  135. });
  136. }
  137. }
  138. //关闭告警监控
  139. this.closeAlarmMonitor = function () {
  140. var _this = this;
  141. //获取告警列表
  142. if (_this.alarmObjList && _this.alarmObjList.length > 0) {
  143. $.each(_this.alarmObjList, function (_index, _obj) {
  144. if (_obj.tl3dObj.name.indexOf("smokeSensor_") >= 0) {//如果是烟感告警 特殊处理
  145. _this.clearSmokeAlarm(_obj.tl3dObj);
  146. } else {
  147. _this.cleanAlarm(_obj.tl3dObj, _obj.alarmId);
  148. }
  149. });
  150. }
  151. }
  152. //关闭某个告警
  153. this.closeAlarm = function (alarmId) {
  154. var _this = this;
  155. //获取告警列表
  156. if (_this.alarmObjList && _this.alarmObjList.length > 0) {
  157. $.each(_this.alarmObjList, function (_index, _obj) {
  158. if (_obj.alarmId == alarmId) {
  159. _obj.alarmState = "end";
  160. if (_obj.tl3dObj.name.indexOf("smokeSensor_") >= 0) {//如果是烟感告警 特殊处理
  161. _this.clearSmokeAlarm(_obj.tl3dObj);
  162. } else {
  163. _this.cleanAlarm(_obj.tl3dObj, _obj.alarmId);
  164. }
  165. }
  166. });
  167. }
  168. }
  169. //显示告警详情
  170. this.showAlarmDetail = function (_obj) {
  171. //如果状态是开始 并且该对象存在告警 那么就显示告警
  172. if ($("#btn_alarmCtrl").attr("data_state") == "runing") {
  173. var currentAlarms = this.getAlarmObjList();
  174. var IsShowAlarmDetail = false;
  175. $.each(currentAlarms, function (_index, _alarmObj) {
  176. if (_alarmObj.alarmObjName == _obj.name) {
  177. IsShowAlarmDetail = true;
  178. }
  179. });
  180. if (IsShowAlarmDetail) {//如果存在告警 就显示告警详情
  181. var index = layer.open({
  182. type: 1,
  183. title:_obj.name + '-告警详情',
  184. area: ['500px', '500px'],
  185. maxmin: true,
  186. content:"此处自定义显示告警详情",
  187. });
  188. }
  189. }
  190. }

十四、对场景内其它设备进行 3D 操控 如窗帘 采光控制 灯光控制等等

如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室,-第二课 - 图14

  1. //窗帘
  2. this._CurtainArray = null;
  3. this._CurtainState = "";
  4. this.changeCurtainsState = function () {
  5. var _this = this;
  6. _this.changeCameraPosition({ x: -620, y: 903, z: 105 }, { x: -184, y: -67, z: -560 }, 1000,
  7. function () {
  8. if (_this._CurtainArray == null) {
  9. _this._CurtainArray = [tl3DCoreObj.commonFunc.findObject("curtains4"),
  10. tl3DCoreObj.commonFunc.findObject("curtains3"),
  11. tl3DCoreObj.commonFunc.findObject("curtains2"),
  12. tl3DCoreObj.commonFunc.findObject("curtains1")]
  13. }
  14. if (_this._CurtainState != "running") {
  15. _this._CurtainState = "running";
  16. if ($("#btn_windowsCtrl").attr("data_state")) {
  17. } else {
  18. $("#btn_windowsCtrl").attr("data_state", "close")
  19. }
  20. if ($("#btn_windowsCtrl").attr("data_state") == "close") {
  21. $.each(_this._CurtainArray, function (_index, _obj) {
  22. _this.changeCurtainState(_obj, "open");
  23. });
  24. $("#btn_windowsCtrl").attr("data_state", "open");
  25. $("#btn_windowsCtrl").attr("src", "../../img/3dImg/winOpen.png");
  26. } else {
  27. $.each(_this._CurtainArray, function (_index, _obj) {
  28. _this.changeCurtainState(_obj, "close");
  29. });
  30. $("#btn_windowsCtrl").attr("data_state", "close");
  31. $("#btn_windowsCtrl").attr("src", "../../img/3dImg/winClose.png");
  32. }
  33. setTimeout(function () {
  34. _this._CurtainState = "";
  35. }, 1500);
  36. }
  37. });
  38. }
  39. //改变窗帘状态
  40. this.changeCurtainState=function (curtain,_cmd) {
  41. var state = "close"
  42. if (curtain.curtainRunState && curtain.curtainRunState == "running") {
  43. return;
  44. } else {
  45. curtain.curtainRunState = "running";
  46. }
  47. if (curtain.curtainState) {
  48. state = curtain.curtainState;
  49. } else {
  50. curtain.curtainState = state;
  51. }
  52. if (_cmd) {
  53. if (_cmd == state) {
  54. curtain.curtainRunState = "";
  55. return;
  56. }
  57. }
  58. var curtain_0 = curtain.children[6];//滚轴
  59. var curtain_1 = curtain.children[5];//窗帘布
  60. var curtain_2 = curtain.children[7];//吊缀
  61. curtain_0.matrixAutoUpdate = true;
  62. curtain_1.matrixAutoUpdate = true;
  63. curtain_2.matrixAutoUpdate = true;
  64. new TWEEN.Tween(curtain_0.rotation).to({
  65. x: (state == "close" ? Math.PI * 10 : 0)
  66. }, 1000).onComplete(function () {
  67. }).start();
  68. new TWEEN.Tween(curtain_0.scale).to({
  69. x: state == "close" ? 2 : 1,
  70. z: state == "close" ? 2 : 1
  71. }, 1000).onComplete(function () {
  72. curtain_0.matrixAutoUpdate = false;
  73. }).start();
  74. new TWEEN.Tween(curtain_1.scale).to({
  75. y: state == "close" ? 0.1 : 1
  76. }, 1000).onComplete(function () {
  77. }).start();
  78. var yy = curtain_1.position.y;
  79. new TWEEN.Tween(curtain_1.position).to({
  80. y: state == "close" ? yy + 58.5 : yy - 58.5
  81. }, 1000).onComplete(function () {
  82. curtain_1.matrixAutoUpdate = false;
  83. }).start();
  84. var yy2 = curtain_2.position.y;
  85. new TWEEN.Tween(curtain_2.position).to({
  86. y: state == "close" ? yy2 + 117 : yy2 - 117
  87. }, 1000).onComplete(function () {
  88. curtain_2.matrixAutoUpdate = false;
  89. state == "close" ? curtain.curtainState = "open" : curtain.curtainState = "close";
  90. curtain.curtainRunState = "";
  91. }).start();
  92. }

好了 这一课基本情况就先介绍到这里

下一课我们继续讲解这一课的代码详情 以及讨论给这个场景加上一些新的功能 或者建立其他 3D 场景

用 webgl 建立 3D 机房 3D 园区 3D 智慧小区 3D 工程等等

https://www.cnblogs.com/yeyunfei/p/8811228.html