新风系统是根据在密闭的室内一侧用专用设备向室内送新风,再从另一侧由专用设备向室外排出,在室内会形成“新风流动场”,从而满足室内新风换气的需要。实施方案是:采用高风压、大流量风机、依靠机械强力由一侧向室内送风,由另一侧用专门设计的排风风机向室外排出的方式强迫在系统内形成新风流动场。在送风的同时对进入室内的空气进过滤、消毒、杀菌、增氧、预热(冬天)。

接下来就用ThingJs平台来搭建一个新风系统
第一步,利用CampusBuilder搭建模拟场景。CampusBuilder的模型库有各种各样的模型,使我们搭建出的场景更逼真。

  1. 1 //加载场景代码
  2. 2 var app = new THING.App({
  3. 3 // 场景地址
  4. 4 "url": "http://www.thingjs.com/./uploads/wechat/oLX7p05lsWJZUIxnIWsNXAzJ40X8/scene/新风演示2",
  5. 5
  6. 6 });

第二步,创建三个数组来保存每个风的模型。

  1. 1 var hotWindGroup = [];
  2. 2 var coolWindGroup = [];
  3. 3 var newWindGroup = [];
  4. 4 var wind = null;

第三步,构造一个创建风的函数,为了方便创建风及其位置,我们选取排风设备为风的父物体,将创建出来的风的visiable属性设置为false(这里这个坐标问题可以看一下官网的教程中控制物体中的坐标转换)。

  1. 1 function createWind(parent, x, y, angle, localPosition, color, group) {
  2. 2 rs = app.query(parent)[0];
  3. 3 wind = app.create({
  4. 4 type: 'Thing',
  5. 5 name: 'hotWind',
  6. 6 url: 'http://model.3dmomoda.cn/models/4da706d8a37047298c0318a5b9546abd/0/gltf/',
  7. 7 localPosition: localPosition,
  8. 8 scale: [1, 2, 1],
  9. 9 angle: angle,
  10. 10 parent: rs,
  11. 11 });
  12. 12 wind.style.color = color;
  13. 13 wind.visible = false;
  14. 14 wind.rotateX(x);
  15. 15 wind.rotateY(y);
  16. 16 group.push(wind);
  17. 17 }

第四步,开始创建风模型,并调整一下摄像机的角度及位置。

  1. 1 app.on('load', function () {
  2. 2 //摄像机角度
  3. 3 app.camera.position = [-22.91452445633646, 30.46296743148116, -23.83548169673341];
  4. 4 app.camera.target = [-13.532807014407252, 5.6565539015865856, -3.3431546399681276];
  5. 5 //hotWind
  6. 6 createWind('空调1', 0, 0, 0, [0, -2, 0], '#FF0000', hotWindGroup);
  7. 7 createWind('空调1', 0, 0, 0, [0, -2, 0.5], '#FF0000', hotWindGroup);
  8. 8 createWind('空调1', 0, 0, 0, [0, -2, 1], '#FF0000', hotWindGroup);
  9. 9 createWind('空调2', 0, 0, 0, [0, -2, 0], '#FF0000', hotWindGroup);
  10. 10 createWind('空调2', 0, 0, 0, [0, -2, 0.5], '#FF0000', hotWindGroup);
  11. 11 createWind('空调2', 0, 0, 0, [0, -2, 1], '#FF0000', hotWindGroup);
  12. 12 //coolWind
  13. 13 createWind('空调1', 0, 0, 0, [0, -2, 0], '#0000FF', coolWindGroup);
  14. 14 createWind('空调1', 0, 0, 0, [0, -2, 0.5], '#0000FF', coolWindGroup);
  15. 15 createWind('空调1', 0, 0, 0, [0, -2, 1], '#0000FF', coolWindGroup);
  16. 16 createWind('空调2', 0, 0, 0, [0, -2, 0], '#0000FF', coolWindGroup);
  17. 17 createWind('空调2', 0, 0, 0, [0, -2, 0.5], '#0000FF', coolWindGroup);
  18. 18 createWind('空调2', 0, 0, 0, [0, -2, 1], '#0000FF', coolWindGroup);
  19. 19 //newWind
  20. 20 createWind('排风1', -50, 0, 0, [0, -0.5, 2], '#00FF00', newWindGroup);
  21. 21 createWind('排风1', -50, 0, 0, [0, -0.5, 4], '#00FF00', newWindGroup);
  22. 22 createWind('排风1', -50, 0, 0, [0, -0.5, 6], '#00FF00', newWindGroup);
  23. 23 createWind('排风1', -50, 50, 50, [2, -0.5, 7], '#00FF00', newWindGroup);
  24. 24 createWind('排风1', -50, 50, 50, [4, -0.5, 8], '#00FF00', newWindGroup);
  25. 25 createWind('排风1', -50, 50, 50, [6, -0.5, 9], '#00FF00', newWindGroup);
  26. 26 createWind('排风1', -50, 50, 50, [8, -0.5, 12], '#00FF00', newWindGroup);
  27. 27 createWind('排风1', -50, 50, 50, [10, -0.5, 15], '#00FF00', newWindGroup);
  28. 28 createWind('排风1', -50, 50, 50, [12, -0.5, 18], '#00FF00', newWindGroup);
  29. 29 createWind('排风1', -50, 50, 50, [10, -0.5, 9], '#00FF00', newWindGroup);
  30. 30 createWind('排风1', -50, 50, 50, [14, -0.5, 9], '#00FF00', newWindGroup);
  31. 31 createWind('排风1', -50, 50, 50, [18, -0.5, 9], '#00FF00', newWindGroup);
  32. 32 createWind('排风1', -50, 50, 50, [22, -0.5, 9], '#00FF00', newWindGroup);
  33. 33 createWind('排风1', -50, 50, 50, [26, -0.5, 9], '#00FF00', newWindGroup);
  34. 34 createWind('排风2', -50, 0, 0, [0, -0.5, 2], '#00FF00', newWindGroup);
  35. 35 createWind('排风3', -50, 0, 0, [0, -0.5, 2], '#00FF00', newWindGroup);
  36. 36 createWind('排风4', -50, 0, 0, [0, -0.5, 2], '#00FF00', newWindGroup);
  37. 37 createWind('排风4', -50, 0, 0, [0, -0.5, 4], '#00FF00', newWindGroup);
  38. 38 createWind('排风4', -50, 0, 0, [0, -0.5, 6], '#00FF00', newWindGroup);
  39. 39 createWind('排风4', -50, 0, 0, [0, -0.5, 8], '#00FF00', newWindGroup);
  40. 40 createWind('排风4', -50, 0, 0, [0, -0.5, 10], '#00FF00', newWindGroup);
  41. 41 createWind('排风4', -50, 0, 0, [0, -0.5, 12], '#00FF00', newWindGroup);
  42. 42 createWind('排风4', -90, 50, 50, [2, -0.6, 12], '#00FF00', newWindGroup);
  43. 43 createWind('排风4', -90, 50, 50, [4, -0.7, 12], '#00FF00', newWindGroup);
  44. 44 createWind('排风4', -90, 50, 50, [6, -0.8, 13], '#00FF00', newWindGroup);
  45. 45 createWind('排风4', -90, 50, 90, [8, -0.8, 11], '#00FF00', newWindGroup);
  46. 46 createWind('排风4', -90, 50, 90, [12, -0.8, 9], '#00FF00', newWindGroup);
  47. 47 createWind('排风4', -90, 50, 90, [16, -0.8, 7], '#00FF00', newWindGroup);
  48. 48 createWind('排风4', -90, 50, 90, [20, -0.8, 5], '#00FF00', newWindGroup);
  49. 49 createWind('排风4', -90, 50, 90, [24, -0.8, 3], '#00FF00', newWindGroup);
  50. 50 createWind('排风4', -90, 0, 90, [8, -0.8, 13], '#00FF00', newWindGroup);
  51. 51 createWind('排风4', -90, 0, 90, [12, -0.8, 13], '#00FF00', newWindGroup);
  52. 52 createWind('排风4', -90, 0, 90, [16, -0.7, 13], '#00FF00', newWindGroup);
  53. 53 createWind('排风4', -90, 0, 90, [20, -0.6, 13], '#00FF00', newWindGroup);
  54. 54 //createWind('排风4', -90, 0, 90, [24, -0.5, 13], '#00FF00', newWindGroup);
  55. 55
  56. 56 //热风演示
  57. 57 new THING.widget.Button('热风演示', function () {
  58. 58 for (let i of coolWindGroup) {
  59. 59 i.visible = false;
  60. 60 };
  61. 61 for (let i of hotWindGroup) {
  62. 62 i.visible = true;
  63. 63 };
  64. 64
  65. 65 });
  66. 66
  67. 67 //冷风演示
  68. 68 new THING.widget.Button('冷风演示', function () {
  69. 69 for (let i of coolWindGroup) {
  70. 70 i.visible = true;
  71. 71 };
  72. 72 for (let i of hotWindGroup) {
  73. 73 i.visible = false;
  74. 74 };
  75. 75 });
  76. 76
  77. 77 //新风演示
  78. 78 new THING.widget.Button('新风演示', function () {
  79. 79 playNewWind();
  80. 80 });
  81. 81
  82. 82 function playNewWind() {
  83. 83 for (var i = 0; i < newWindGroup.length; i++) {
  84. 84 if(i==newWindGroup.length-1)
  85. 85 return;
  86. 86 newWindGroup[i].visible = true;
  87. 87 newWindGroup[i].moveTo({
  88. 88 "time": 4000,
  89. 89 "position": newWindGroup[i+1].position,
  90. 90 });
  91. 91 }
  92. 92 });

第五步,运行项目。演示地址

思考与总结:
首先就是空间坐标系下转父物体坐标真是弄晕了,看了官网的教程多少理解了一点。刚开始的时候我一直认为我的子物体以父物体坐标下放置的时候,子物体坐标轴的问题指向的问题。看了教程发现自己的担心多余了,就好像是人戴鸭舌帽帽子不管戴在谁的头上都一样。
其次就是让风动起来,最初是想让一个模型在空间中运动,发现效果不好用。最后就创建了多个模型他们对应着有各自的点,让每一个模型向他下一个模型的位置移动实现运动。

完整代码

  1. //加载场景代码
  2. var app = new THING.App({
  3. // 场景地址
  4. "url": "http://www.thingjs.com/./uploads/wechat/oLX7p05lsWJZUIxnIWsNXAzJ40X8/scene/新风演示2",
  5. });
  6. var hotWindGroup = [];
  7. var coolWindGroup = [];
  8. var newWindGroup = [];
  9. var wind = null;
  10. function createWind(parent, x, y, angle, localPosition, color, group) {
  11. rs = app.query(parent)[0];
  12. wind = app.create({
  13. type: 'Thing',
  14. name: 'hotWind',
  15. url: 'http://model.3dmomoda.cn/models/4da706d8a37047298c0318a5b9546abd/0/gltf/',
  16. localPosition: localPosition,
  17. scale: [1, 2, 1],
  18. angle: angle,
  19. parent: rs,
  20. });
  21. wind.style.color = color;
  22. wind.visible = false;
  23. wind.rotateX(x);
  24. wind.rotateY(y);
  25. group.push(wind);
  26. }
  27. app.on('load', function () {
  28. //摄像机角度
  29. app.camera.position = [-22.91452445633646, 30.46296743148116, -23.83548169673341];
  30. app.camera.target = [-13.532807014407252, 5.6565539015865856, -3.3431546399681276];
  31. //hotWind
  32. createWind('空调1', 0, 0, 0, [0, -2, 0], '#FF0000', hotWindGroup);
  33. createWind('空调1', 0, 0, 0, [0, -2, 0.5], '#FF0000', hotWindGroup);
  34. createWind('空调1', 0, 0, 0, [0, -2, 1], '#FF0000', hotWindGroup);
  35. createWind('空调2', 0, 0, 0, [0, -2, 0], '#FF0000', hotWindGroup);
  36. createWind('空调2', 0, 0, 0, [0, -2, 0.5], '#FF0000', hotWindGroup);
  37. createWind('空调2', 0, 0, 0, [0, -2, 1], '#FF0000', hotWindGroup);
  38. //coolWind
  39. createWind('空调1', 0, 0, 0, [0, -2, 0], '#0000FF', coolWindGroup);
  40. createWind('空调1', 0, 0, 0, [0, -2, 0.5], '#0000FF', coolWindGroup);
  41. createWind('空调1', 0, 0, 0, [0, -2, 1], '#0000FF', coolWindGroup);
  42. createWind('空调2', 0, 0, 0, [0, -2, 0], '#0000FF', coolWindGroup);
  43. createWind('空调2', 0, 0, 0, [0, -2, 0.5], '#0000FF', coolWindGroup);
  44. createWind('空调2', 0, 0, 0, [0, -2, 1], '#0000FF', coolWindGroup);
  45. //newWind
  46. createWind('排风1', -50, 0, 0, [0, -0.5, 2], '#00FF00', newWindGroup);
  47. createWind('排风1', -50, 0, 0, [0, -0.5, 4], '#00FF00', newWindGroup);
  48. createWind('排风1', -50, 0, 0, [0, -0.5, 6], '#00FF00', newWindGroup);
  49. createWind('排风1', -50, 50, 50, [2, -0.5, 7], '#00FF00', newWindGroup);
  50. createWind('排风1', -50, 50, 50, [4, -0.5, 8], '#00FF00', newWindGroup);
  51. createWind('排风1', -50, 50, 50, [6, -0.5, 9], '#00FF00', newWindGroup);
  52. createWind('排风1', -50, 50, 50, [8, -0.5, 12], '#00FF00', newWindGroup);
  53. createWind('排风1', -50, 50, 50, [10, -0.5, 15], '#00FF00', newWindGroup);
  54. createWind('排风1', -50, 50, 50, [12, -0.5, 18], '#00FF00', newWindGroup);
  55. createWind('排风1', -50, 50, 50, [10, -0.5, 9], '#00FF00', newWindGroup);
  56. createWind('排风1', -50, 50, 50, [14, -0.5, 9], '#00FF00', newWindGroup);
  57. createWind('排风1', -50, 50, 50, [18, -0.5, 9], '#00FF00', newWindGroup);
  58. createWind('排风1', -50, 50, 50, [22, -0.5, 9], '#00FF00', newWindGroup);
  59. createWind('排风1', -50, 50, 50, [26, -0.5, 9], '#00FF00', newWindGroup);
  60. createWind('排风2', -50, 0, 0, [0, -0.5, 2], '#00FF00', newWindGroup);
  61. createWind('排风3', -50, 0, 0, [0, -0.5, 2], '#00FF00', newWindGroup);
  62. createWind('排风4', -50, 0, 0, [0, -0.5, 2], '#00FF00', newWindGroup);
  63. createWind('排风4', -50, 0, 0, [0, -0.5, 4], '#00FF00', newWindGroup);
  64. createWind('排风4', -50, 0, 0, [0, -0.5, 6], '#00FF00', newWindGroup);
  65. createWind('排风4', -50, 0, 0, [0, -0.5, 8], '#00FF00', newWindGroup);
  66. createWind('排风4', -50, 0, 0, [0, -0.5, 10], '#00FF00', newWindGroup);
  67. createWind('排风4', -50, 0, 0, [0, -0.5, 12], '#00FF00', newWindGroup);
  68. createWind('排风4', -90, 50, 50, [2, -0.6, 12], '#00FF00', newWindGroup);
  69. createWind('排风4', -90, 50, 50, [4, -0.7, 12], '#00FF00', newWindGroup);
  70. createWind('排风4', -90, 50, 50, [6, -0.8, 13], '#00FF00', newWindGroup);
  71. createWind('排风4', -90, 50, 90, [8, -0.8, 11], '#00FF00', newWindGroup);
  72. createWind('排风4', -90, 50, 90, [12, -0.8, 9], '#00FF00', newWindGroup);
  73. createWind('排风4', -90, 50, 90, [16, -0.8, 7], '#00FF00', newWindGroup);
  74. createWind('排风4', -90, 50, 90, [20, -0.8, 5], '#00FF00', newWindGroup);
  75. createWind('排风4', -90, 50, 90, [24, -0.8, 3], '#00FF00', newWindGroup);
  76. createWind('排风4', -90, 0, 90, [8, -0.8, 13], '#00FF00', newWindGroup);
  77. createWind('排风4', -90, 0, 90, [12, -0.8, 13], '#00FF00', newWindGroup);
  78. createWind('排风4', -90, 0, 90, [16, -0.7, 13], '#00FF00', newWindGroup);
  79. createWind('排风4', -90, 0, 90, [20, -0.6, 13], '#00FF00', newWindGroup);
  80. //createWind('排风4', -90, 0, 90, [24, -0.5, 13], '#00FF00', newWindGroup);
  81.  
  82. //热风演示
  83. new THING.widget.Button('热风演示', function () {
  84. for (let i of coolWindGroup) {
  85. i.visible = false;
  86. };
  87. for (let i of hotWindGroup) {
  88. i.visible = true;
  89. //playWind(i,[0,-0.6499999999999999,0],[0,-0.7234152255572697,0.46352549156242107],[0,-1.2683221215612903,1.2135254915624212],[0,-2.15,1.5])
  90. };
  91. });
  92. //冷风演示
  93. new THING.widget.Button('冷风演示', function () {
  94. for (let i of coolWindGroup) {
  95. i.visible = true;
  96. };
  97. for (let i of hotWindGroup) {
  98. i.visible = false;
  99. };
  100. });
  101. //新风演示
  102. new THING.widget.Button('新风演示', function () {
  103. playNewWind();
  104. });
  105. function playNewWind() {
  106. for (var i = 0; i < newWindGroup.length; i++) {
  107. if(i==newWindGroup.length-1)
  108. return;
  109. newWindGroup[i].visible = true;
  110. newWindGroup[i].moveTo({
  111. "time": 4000,
  112. "position": newWindGroup[i+1].position,
  113. });
  114. }
  115. }
  116. });

 

版权声明:本文为thingjs原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/thingjs/p/10088471.html