UIAnchor.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. //创建面板
  2. function uiAnchor(car){
  3. panel = new THING.widget.Panel({
  4. // 设置面板宽度
  5. width: '170px',
  6. // cornerType 角标样式
  7. // 没有角标 none ,没有线的角标 noline ,折线角标 polyline
  8. cornerType: 'none'
  9. })
  10. // 绑定物体身上相应的属性数据
  11. panel.addString(car, 'name').caption('名称');
  12. panel.addString(car, 'id').caption('ID');
  13. panel.addString(car.userData, 'power').caption('设备类型');
  14. // 创建UIAnchor面板
  15. const uiAnchor = app.create({
  16. // 类型
  17. type: 'UIAnchor',
  18. // 父节点设置
  19. parent: car,
  20. // 要绑定的页面的 element 对象
  21. element: panel.domElement,
  22. // 设置 localPosition 为 [0, 0, 0]
  23. localPosition: [0, 0.5, 0],
  24. // 相对于Element左上角的偏移像素值
  25. pivotPixel: [-16, 180] // 当前用值是角标的中心点
  26. });
  27. return panel;
  28. }
  29. function init(car,data) {
  30. uis_array.push(car)
  31. var templaet =
  32. `
  33. <div id="${car.name}" style="width: 190px;font-size: 16px;text-align: center;
  34. background-color: rgba(0,190,255, .3);border: 1px solid #07befc;border-radius: 8px;
  35. color: #eee;position: absolute;top: 0;left: 0;z-index: 10;display: none;">
  36. <a href="#" class='liu'>
  37. <span></span>
  38. <span></span>
  39. <span></span>
  40. <span></span>
  41. </a>
  42. <div class="s1">
  43. <span class="span-l icon" style="float: left;width: 30px;height: 30px;
  44. background:url(${data.iconUrl}) no-repeat center;
  45. margin: 1px 1px 1px 5px;"></span>
  46. <span class="span-l font" style="float: left;margin: 0px 0px 0px 3px;">${data.devicetitle}</span>
  47. </div>
  48. </div>
  49. `
  50. //<span class="span-r point" style="float: right;width: 12px;height: 12px;background-color: #18EB20;border-radius: 50%;margin: 10px 5px 10px 0px;"></span>
  51. //<div class="point-top" style="position: absolute;top: -7px;right: -7px;background-color: #3F6781;width: 10px;height: 10px;border: 3px solid #eee;border-radius: 50%;"></div>
  52. $('#div3d').append($(templaet));
  53. var html;
  54. Object.keys(data.params).forEach(function(key){
  55. html = `
  56. <div class="s2">
  57. <span class="span-l font1" style="width: 60px;"> ${key}:</span>
  58. ${key === '实时画面' ?
  59. `<video class="${car.name}" style="width:40px;float: left;
  60. margin: 0px 10px 0px 10px;" controls preload="true" autoplay muted>
  61. </video>`
  62. : `<span class="span-l font2" style="float: left; width: 70px;
  63. background-color: ${
  64. data.params[key] === '在线' ? "#18EB20" :
  65. data.params[key] === '离线' ? "red" :
  66. data.params[key] === '异常' ? "yellow" : ""
  67. };">
  68. ${ data.params[key]}</span>`
  69. }
  70. </div>
  71. `
  72. $('#'+car.name).append($(html));
  73. })
  74. // var name = document.getElementsByClassName(car.name);
  75. // name.setAttribute("onclick", "deviceIcon_click('"+car.id+"','"+car.name+"')");
  76. $('head').append($(`
  77. <style>
  78. .s1{
  79. margin: 5px 0px 5px 0px;
  80. line-height: 32px;
  81. overflow: hidden;
  82. }
  83. .font1{
  84. float: left;
  85. margin: 0px 10px 0px 10px;
  86. }
  87. .s2{
  88. margin: 5px 0px 10px 0px;
  89. line-height: 18px;
  90. font-size: 10px;
  91. overflow: hidden;
  92. }
  93. @keyframes fade-in {
  94. 0% {opacity: 0;}/*初始状态 透明度为0*/
  95. 40% {opacity: 0;}/*过渡状态 透明度为0*/
  96. 100% {opacity: 1;}/*结束状态 透明度为1*/
  97. }
  98. @-webkit-keyframes fade-in {/*针对webkit内核*/
  99. 0% {opacity: 0;}
  100. 40% {opacity: 0;}
  101. 100% {opacity: 1;}
  102. }
  103. #board {
  104. padding-right: 10px;
  105. animation: fade-in;/*动画名称*/
  106. animation-duration: 0.5s;/*动画持续时间*/
  107. -webkit-animation:fade-in 0.5s;/*针对webkit内核*/
  108. }
  109. .liu{
  110. width: 100%;
  111. height: 100%;
  112. position: absolute;
  113. display: inline-block;
  114. // padding: 25px 30px;
  115. // margin: 40px 0;
  116. left: 0;
  117. color: #03e9f4;
  118. text-decoration: none;
  119. text-transform: uppercase;
  120. transition: 0.5s;
  121. letter-spacing: 4px;
  122. overflow: hidden;
  123. // margin-right: 50px;
  124. }
  125. .liu:nth-child(1) {
  126. filter: hue-rotate(270deg);
  127. }
  128. .liu:nth-child(2) {
  129. filter: hue-rotate(110deg);
  130. }
  131. .liu span {
  132. position: absolute;
  133. display: block;
  134. }
  135. .liu span:nth-child(1) {
  136. top: 0;
  137. left: 0;
  138. width: 100%;
  139. height: 2px;
  140. background: linear-gradient(90deg, transparent, #03e9f4);
  141. animation: animate1 1s linear infinite;
  142. }
  143. @keyframes animate1 {
  144. 0% {
  145. left: -100%;
  146. }
  147. 50%,
  148. 100% {
  149. left: 100%;
  150. }
  151. }
  152. .liu span:nth-child(2) {
  153. top: -100%;
  154. right: 0;
  155. width: 2px;
  156. height: 100%;
  157. background: linear-gradient(180deg, transparent, #03e9f4);
  158. animation: animate2 1s linear infinite;
  159. animation-delay: 0.25s;
  160. }
  161. @keyframes animate2 {
  162. 0% {
  163. top: -100%;
  164. }
  165. 50%,
  166. 100% {
  167. top: 100%;
  168. }
  169. }
  170. .liu span:nth-child(3) {
  171. bottom: 0;
  172. right: 0;
  173. width: 100%;
  174. height: 2px;
  175. background: linear-gradient(270deg, transparent, #03e9f4);
  176. animation: animate3 1s linear infinite;
  177. animation-delay: 0.5s;
  178. }
  179. @keyframes animate3 {
  180. 0% {
  181. right: -100%;
  182. }
  183. 50%,
  184. 100% {
  185. right: 100%;
  186. }
  187. }
  188. .liu span:nth-child(4) {
  189. bottom: -100%;
  190. left: 0;
  191. width: 2px;
  192. height: 100%;
  193. background: linear-gradient(360deg, transparent, #03e9f4);
  194. animation: animate4 1s linear infinite;
  195. animation-delay: 0.75s;
  196. }
  197. @keyframes animate4 {
  198. 0% {
  199. bottom: -100%;
  200. }
  201. 50%,
  202. 100% {
  203. bottom: 100%;
  204. }
  205. }
  206. </style>
  207. `));
  208. ui = app.create({
  209. type: 'UIAnchor',
  210. parent: car,
  211. element: create_element(car),
  212. localPosition: [0, 2, 0],
  213. pivot: [0.5, 1] // [0,0]即以界面左上角定位,[1,1]即以界面右下角进行定位
  214. });
  215. uis.push(ui);
  216. uis_list.push({name:car.name})
  217. if(car.userData.物体类型){
  218. uis_name[car.userData.物体类型]--
  219. // console.log(uis_name[car.userData.物体类型])
  220. if(uis_name[car.userData.物体类型] == 0){
  221. ev_name = ""
  222. dataObj.checkbox[car.userData.物体类型] = true
  223. }
  224. }
  225. }
  226. function create_element(car) {
  227. var srcElem = document.getElementById(car.name);
  228. var newElem = srcElem.cloneNode(true);
  229. newElem.style.display = "block";
  230. app.domElement.insertBefore(newElem,srcElem);
  231. return newElem;
  232. }