lctools.min.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. var CGQValue = [];
  2. var high;
  3. var whign;
  4. var low;
  5. var wlow;
  6. var LCcs = [];//用于接收地址参数
  7. var SensorID = -1;
  8. var AAA = -1;
  9. var BBB = 0;
  10. var CCC;
  11. var CGQcase;//根据接口返回规定不同的测温渲染状态0,1,2
  12. $.each(location.href.split("?")[1].split("&"),function(i,n){
  13. LCcs.push(n.split("=")[1]);
  14. })
  15. $.ajax({
  16. type: "get",
  17. url: location.protocol+"//"+location.host+"/depot-intelligent/intelligents/wareHouseBasicInfo/getStorehouse?orgId=" + LCcs[0] + "&cfCode=" + LCcs[1] + "&libraryType=" + LCcs[3],
  18. data: {},
  19. async:true,
  20. dataType: "json",
  21. success: function(e) {
  22. console.log(e);
  23. if (e.data.keeperName == null) {
  24. e.data.keeperName = "";
  25. }
  26. if (e.data.dj == null) {
  27. e.data.dj = "";
  28. }
  29. if (e.data.pz == null) {
  30. e.data.pz = "";
  31. }
  32. if (e.data.lkmc == null) {
  33. e.data.lkmc = "";
  34. }
  35. $("#LSDJ").text(e.data.dj);
  36. $("#LKMC").text(e.data.lkmc);
  37. $("#LKBGY").text(e.data.keeperName);
  38. $("#LSPZ").text(e.data.pz)
  39. }
  40. });
  41. $.ajax({
  42. type: "get",
  43. url: location.protocol+"//"+location.host+"/depot-intelligent/intelligents/WarningThreshold/getByOrgIdAndCfCode?orgId=" + LCcs[0] + "&vCfCode=" + LCcs[1],
  44. data: {},
  45. dataType: "json",
  46. async:true,
  47. success: function(e) {
  48. high = e.data.high;
  49. whign = e.data.whigh;
  50. low = e.data.low;
  51. wlow = e.data.wlow
  52. if(high == undefined && whign == undefined && low == undefined && wlow == undefined){
  53. CGQcase = 0;
  54. }
  55. else if(high != undefined && whign == undefined && low == undefined && wlow == undefined){
  56. CGQcase = 1;
  57. }
  58. else if(high != undefined && whign != undefined && low != undefined && wlow != undefined){
  59. CGQcase = 2;
  60. }
  61. }
  62. });
  63. $.ajax({
  64. type: "get",
  65. url: location.protocol+"//"+location.host+"/depot-intelligent/intelligents/temperatureRecord/findById?id=" + LCcs[2],
  66. data: {},
  67. async:true,
  68. dataType: "json",
  69. success: function(e) {
  70. console.log(e);
  71. if (e.data.inh == null) {
  72. e.data.inh = "";
  73. }
  74. if (e.data.intemp == null) {
  75. e.data.intemp = "";
  76. }
  77. if (e.data.outtemp == null) {
  78. e.data.outtemp = "";
  79. }
  80. if (e.data.outh == null) {
  81. e.data.outh = "";
  82. }
  83. $("#CNSD").text(e.data.inh);
  84. $("#CNWD").text(e.data.intemp);
  85. $("#CWWD").text(e.data.outtemp);
  86. $("#CWSD").text(e.data.outh)
  87. }
  88. });
  89. var scene = new THREE.Scene;
  90. scene.background = (new THREE.CubeTextureLoader).setPath("pic/")
  91. .load(['px.jpg', 'nx.jpg', 'py.jpg', 'ny.jpg', 'pz.jpg', 'nz.jpg',]);
  92. var axes = new THREE.AxesHelper(1e3);
  93. // scene.add(axes);
  94. var point = new THREE.PointLight(16777215);
  95. point.position.set(400, 200, 300);
  96. scene.add(point);
  97. var ambient = new THREE.AmbientLight(4473924);
  98. scene.add(ambient);
  99. var width = window.innerWidth;
  100. var height = window.innerHeight;
  101. var k = width / height;
  102. var s = 200;
  103. var camera = new THREE.PerspectiveCamera(100, width / height, 1, 1e3);
  104. camera.position.set(700, 100, 100);
  105. camera.lookAt(scene.position);
  106. THREE.onEvent(scene, camera);
  107. var p1 = {x: 550,y:80,z:200};
  108. var position = camera.position;
  109. var tween1 = new TWEEN.Tween(position);
  110. tween1.to(p1, 5000);
  111. var update = function () {
  112. // camera.position.set(p1.x,p1.y,p1.z);
  113. camera.lookAt(300,80,200);
  114. controls.target = new THREE.Vector3(300,80,200);
  115. // $("body").mLoading("hide"); //取消loading
  116. };
  117. tween1.onUpdate(update);
  118. tween1.easing(TWEEN.Easing.Back.InOut);
  119. $.ajax({
  120. type: "get",
  121. url: location.protocol+"//"+location.host+"/depot-intelligent/intelligents/temperatureRecord/findByHouseAndTimes?lqId=" + LCcs[2],
  122. data: {},
  123. async:true,
  124. dataType: "json",
  125. success: function(e) {
  126. console.log(e.data);
  127. //取第一个数
  128. for (let i in e.data[0]){
  129. AAA++
  130. }
  131. console.log(AAA)
  132. //取第二个数
  133. var BBBArray = [];
  134. var arr = []
  135. $.each(e.data,function(i,n){
  136. BBBArray.push(n[1]);
  137. })
  138. console.log(BBBArray);
  139. $.each(BBBArray,function(i,n){
  140. if(i+1 == n.split("-")[1]){
  141. BBB++
  142. }
  143. })
  144. console.log(BBB);
  145. //取第三个数
  146. CCC = BBBArray.length/BBB
  147. console.log(CCC);
  148. var geometry = new THREE.CylinderGeometry(.3, .3, 140);
  149. var material = new THREE.MeshLambertMaterial({
  150. color: 0
  151. });
  152. for (var x = 0; x < AAA; x++) {
  153. for (var z = 0; z < BBB; z++) {
  154. var mesh = new THREE.Mesh(geometry, material);
  155. mesh.position.set(x * 50, 0, z * 70);
  156. mesh.translateY(70);
  157. scene.add(mesh)
  158. }
  159. }
  160. var ckfloor = new THREE.BoxGeometry((AAA+1)*50, (BBB)*70, 3);
  161. var textureckfloor = (new THREE.TextureLoader).load("img/lss.jpg");
  162. textureckfloor.wrapS = textureckfloor.wrapT = THREE.RepeatWrapping;
  163. textureckfloor.repeat.set(8, 8);
  164. var ckfloormaterial = new THREE.MeshBasicMaterial({
  165. color: 16121850,
  166. map: textureckfloor
  167. });
  168. var ckfloormesh = new THREE.Mesh(ckfloor, ckfloormaterial);
  169. ckfloormesh.rotateX(Math.PI / 2);
  170. // ckfloormesh.position.set((AAA+1)*25, 3, (BBB+1)*35);
  171. ckfloormesh.position.set(AAA*25, 3, (BBB-1)*35);
  172. scene.add(ckfloormesh);
  173. var cubeleft = new THREE.CubeGeometry((AAA+1)*50, 140, 10, (AAA+1)*50);
  174. var textureleft = (new THREE.TextureLoader).load("img/qiang.jpg");
  175. textureleft.wrapS = textureleft.wrapT = THREE.RepeatWrapping;
  176. textureleft.repeat.set(3, 3);
  177. var materialleft = new THREE.MeshBasicMaterial({
  178. color: 15000001,
  179. map: textureleft,
  180. transparent: true,
  181. // opacity: 0.5,
  182. });
  183. var meshleft = new THREE.Mesh(cubeleft, materialleft);
  184. // meshleft.translateY(70);
  185. // meshleft.translateZ(590);
  186. meshleft.position.set((AAA)*25,70,(BBB)*70-35)
  187. scene.add(meshleft);
  188. var cuberight = new THREE.CubeGeometry((AAA+1)*50, 140, 10, (AAA+1)*50);
  189. var textureright = (new THREE.TextureLoader).load("img/qiang.jpg");
  190. textureright.wrapS = textureright.wrapT = THREE.RepeatWrapping;
  191. textureright.repeat.set(3, 3);
  192. var materialright = new THREE.MeshBasicMaterial({
  193. color: 15000001,
  194. map: textureright,
  195. });
  196. var meshright = new THREE.Mesh(cuberight, materialright);
  197. meshright.translateY(70);
  198. // meshright.translateZ(-250);
  199. meshright.position.set((AAA)*25,70,-35)
  200. scene.add(meshright);
  201. var cubeback = new THREE.CubeGeometry(10, 140, (BBB)*70, 140);
  202. var textureback = (new THREE.TextureLoader).load("img/qiang.jpg");
  203. textureback.wrapS = textureback.wrapT = THREE.RepeatWrapping;
  204. textureback.repeat.set(3, 3);
  205. var materialback = new THREE.MeshBasicMaterial({
  206. color: 15000001,
  207. map: textureback
  208. });
  209. var meshback = new THREE.Mesh(cubeback, materialback);
  210. meshback.translateY(70);
  211. // meshback.translateZ(170);
  212. // meshback.translateX(-200);
  213. meshback.position.set(-25,70,(BBB-1)*35)
  214. scene.add(meshback);
  215. var texturetop = (new THREE.TextureLoader).load("img/1111.jpg");
  216. texturetop.wrapS = texturetop.wrapT = THREE.RepeatWrapping;
  217. texturetop.repeat.set(10, 10);
  218. var materialtop = new THREE.MeshBasicMaterial({
  219. color: 1869550,
  220. map: texturetop
  221. });
  222. var cubetop1 = new THREE.CubeGeometry((AAA+2)*25, 10, (BBB)*70);
  223. var meshtop1 = new THREE.Mesh(cubetop1, materialtop);
  224. meshtop1.translateY(170);
  225. meshtop1.position.set(0,170,(BBB-1)*35)
  226. meshtop1.translateX((1/AAA)*70+50);
  227. // meshtop1.translateZ(170);
  228. meshtop1.rotateZ(Math.PI / 12);
  229. scene.add(meshtop1);
  230. var cubetop2 = new THREE.CubeGeometry((AAA+2)*25, 10, (BBB)*70);
  231. var meshtop2 = new THREE.Mesh(cubetop2, materialtop);
  232. meshtop2.position.set(0,170,(BBB-1)*35)
  233. meshtop2.translateX((AAA-1/AAA)*50-50);
  234. // meshtop2.translateZ(170);
  235. meshtop2.rotateZ(-Math.PI / 12);
  236. scene.add(meshtop2);
  237. var tubeMaterial = new THREE.MeshPhongMaterial({
  238. // map: texture,
  239. color:0x000000,
  240. transparent: true,
  241. });
  242. for(var x = 0; x<AAA;x++){
  243. var curve = new THREE.CatmullRomCurve3([
  244. new THREE.Vector3(x*50, 140, 0),
  245. new THREE.Vector3(x*50, 140, (BBB-1)*70),
  246. ],false/*是否闭合*/);
  247. var tubeGeometry = new THREE.TubeGeometry(curve, 2, 0.5, 5, false);
  248. var tube = new THREE.Mesh(tubeGeometry, tubeMaterial);
  249. scene.add(tube);
  250. }
  251. // 通过Path类的线条绘制方法方法定义轮廓
  252. var shape = new THREE.Shape();
  253. //shape.absarc(50,50,40,0,2*Math.PI);//圆弧
  254. shape.moveTo(0, 0, 0); //起点
  255. shape.lineTo(((AAA+1)/2)*50, 0, 0); //第2点
  256. shape.lineTo(0, 50, 0); //第3点
  257. shape.lineTo(-((AAA+1)/2)*50, 0, 0); //第4点
  258. shape.lineTo(0, 0, 0); //第5点
  259. var geometry = new THREE.ExtrudeGeometry( //拉伸造型
  260. shape, //二维轮廓
  261. //拉伸参数
  262. {
  263. amount: BBB*70, //拉伸长度
  264. }
  265. );
  266. var trianglematerial = new THREE.MeshPhongMaterial({
  267. // color: 0xC7C7C7,
  268. color:0x27408B,
  269. side: THREE.DoubleSide, //两面可见,
  270. //wireframe: true,
  271. }); //材质对象
  272. var meshwuzi = new THREE.Mesh(geometry, trianglematerial); //网格模型对象
  273. // meshwuzi.translateZ(-433)
  274. // meshwuzi.translateY(140)
  275. meshwuzi.position.set(((AAA+3)*35)/2,140,-35);
  276. scene.add(meshwuzi); //网格模型添加到场景中
  277. $.ajax({
  278. type: "get",
  279. url: location.protocol+"//"+location.host+"/depot-intelligent/intelligents/temperatureRecord/findByHouseAndTimes?lqId=" + LCcs[2],
  280. data: {},
  281. async:true,
  282. dataType: "json",
  283. success: function(e) {
  284. console.log(e);
  285. $.each(e.data, function(e, a) {
  286. for (var t = 2; t < AAA+2; t++) {
  287. CGQValue.push(a[t])
  288. }
  289. });
  290. // console.log(CGQValue);
  291. for (var a = CCC; a > 0; a--) {
  292. for (var t = 0; t < BBB; t++) {
  293. for (var r = 0; r < AAA; r++) {
  294. SensorID = SensorID + 1;
  295. var o = CGQValue[SensorID];
  296. switch (CGQcase){
  297. case 0:
  298. if(o == 250){
  299. var n = new THREE.MeshLambertMaterial({
  300. color: "#636363",
  301. wireframe: false,
  302. transparent: true,
  303. opacity: .9
  304. })
  305. }
  306. else{
  307. var n = new THREE.MeshLambertMaterial({
  308. color: 8190976,
  309. wireframe: false,
  310. transparent: true,
  311. opacity: .7
  312. })
  313. }
  314. break;
  315. case 1:
  316. if (o >= high) {
  317. var n = new THREE.MeshLambertMaterial({
  318. color: 16711680,
  319. wireframe: false,
  320. transparent: true,
  321. opacity: .9
  322. })
  323. }
  324. else{
  325. var n = new THREE.MeshLambertMaterial({
  326. color: 8190976,
  327. wireframe: false,
  328. transparent: true,
  329. opacity: .7
  330. })
  331. }
  332. break;
  333. case 2:
  334. if (o >= high && o != 250) {
  335. var n = new THREE.MeshLambertMaterial({
  336. color: 16711680,
  337. wireframe: false,
  338. transparent: true,
  339. opacity: .9
  340. })
  341. }
  342. else if(o == 250){
  343. var n = new THREE.MeshLambertMaterial({
  344. color: "#636363",
  345. wireframe: false,
  346. transparent: true,
  347. opacity: .9
  348. })
  349. }
  350. else if(o <= low){
  351. var n = new THREE.MeshLambertMaterial({
  352. color: "#00F5FF",
  353. wireframe: false,
  354. transparent: true,
  355. opacity: .7
  356. })
  357. }
  358. else if (o >= whign && o < high) {
  359. var n = new THREE.MeshLambertMaterial({
  360. color: 15658496,
  361. wireframe: false,
  362. transparent: true,
  363. opacity: .7
  364. })
  365. } else if (o >= low && o < wlow) {
  366. var n = new THREE.MeshLambertMaterial({
  367. color: "#00F5FF",
  368. wireframe: false,
  369. transparent: true,
  370. opacity: .7
  371. })
  372. } else if (o < whign && o > wlow) {
  373. var n = new THREE.MeshLambertMaterial({
  374. color: 8190976,
  375. wireframe: false,
  376. transparent: true,
  377. opacity: .7
  378. })
  379. }
  380. break;
  381. }
  382. var s = new THREE.Mesh(sphere, n);
  383. s.position.set(r * 50, a * 25, t * 70);
  384. s.rotateX(Math.PI / 2);
  385. s.name = "传感器" + SensorID.toString();
  386. var d = document.createElement("div");
  387. d.className = "label";
  388. d.textContent = CGQValue[SensorID] + "℃";
  389. d.style.marginTop = "-1em";
  390. var c = new THREE.CSS2DObject(d);
  391. // c.position.set(r, a, t);
  392. s.add(c);
  393. scene.add(s)
  394. // console.log(SensorID);
  395. s.add(c);
  396. // scene.add(newsphereMesh);
  397. // s.on('click', function(m) {
  398. // console.log(m);
  399. // if (m.children.length > 1) {
  400. // alert(m.children[1].element.innerText);
  401. // } else{
  402. // alert(m.children[0].element.innerText);
  403. // }
  404. // });
  405. }
  406. }
  407. }
  408. }
  409. });
  410. }
  411. });
  412. var tubeMaterial = new THREE.MeshPhongMaterial({
  413. color: 0,
  414. transparent: true
  415. });
  416. var dianban = new THREE.BoxGeometry(3e3, 3e3, 5);
  417. var texturefloor = (new THREE.TextureLoader).load("img/cizhuan.jpg");
  418. texturefloor.wrapS = texturefloor.wrapT = THREE.RepeatWrapping;
  419. texturefloor.repeat.set(80, 80);
  420. var dianbanmaterial = new THREE.MeshBasicMaterial({
  421. color: 16121850,
  422. map: texturefloor
  423. });
  424. var real_dianban = new THREE.Mesh(dianban, dianbanmaterial);
  425. real_dianban.rotateX(Math.PI / 2);
  426. scene.add(real_dianban);
  427. var sphere = new THREE.SphereGeometry(4, 20, 20);
  428. labelRenderer = new THREE.CSS2DRenderer;
  429. labelRenderer.setSize(window.innerWidth, window.innerHeight);
  430. labelRenderer.domElement.style.position = "absolute";
  431. labelRenderer.domElement.style.top = 0;
  432. document.body.appendChild(labelRenderer.domElement);
  433. function animate() {
  434. requestAnimationFrame(animate)
  435. }
  436. function draw() {
  437. animate()
  438. }
  439. var renderer = new THREE.WebGLRenderer;
  440. renderer.setSize(width, height);
  441. renderer.setClearColor(12178431, 1);
  442. document.body.appendChild(renderer.domElement);
  443. function render() {
  444. renderer.render(scene, camera);
  445. labelRenderer.render(scene, camera);
  446. requestAnimationFrame(render)
  447. TWEEN.update();
  448. }
  449. render();
  450. var controls = new THREE.OrbitControls(camera);
  451. controls.maxPolarAngle = 1.5;
  452. controls.minPolarAngle = 1.3;
  453. controls.minDistance = 50;
  454. controls.maxDistance = 800;
  455. function CWXQ() {
  456. // camera.position.set(80, 50, 80);
  457. controls.maxDistance = 200;
  458. console.log($(".label"));
  459. tween1.start();
  460. $("body").mLoading({
  461. text: "切换摄像头视角...", //加载文字,默认值:加载中...
  462. // mask:false//是否显示遮罩效果,默认显示
  463. });
  464. setTimeout(function() {
  465. $("body").mLoading("hide");
  466. $(".label").addClass("active")
  467. }, 5000)
  468. }
  469. function HFQJ() {
  470. controls.maxDistance = 800;
  471. controls.reset();
  472. $(".label").removeClass("active")
  473. }