| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501 |
- var CGQValue = [];
- var high;
- var whign;
- var low;
- var wlow;
- var LCcs = [];//用于接收地址参数
- var SensorID = -1;
- var AAA = -1;
- var BBB = 0;
- var CCC;
- var CGQcase;//根据接口返回规定不同的测温渲染状态0,1,2
- $.each(location.href.split("?")[1].split("&"),function(i,n){
- LCcs.push(n.split("=")[1]);
- })
- $.ajax({
- type: "get",
- url: location.protocol+"//"+location.host+"/depot-intelligent/intelligents/wareHouseBasicInfo/getStorehouse?orgId=" + LCcs[0] + "&cfCode=" + LCcs[1] + "&libraryType=" + LCcs[3],
- data: {},
- async:true,
- dataType: "json",
- success: function(e) {
- console.log(e);
- if (e.data.keeperName == null) {
- e.data.keeperName = "";
- }
- if (e.data.dj == null) {
- e.data.dj = "";
- }
- if (e.data.pz == null) {
- e.data.pz = "";
- }
- if (e.data.lkmc == null) {
- e.data.lkmc = "";
- }
- $("#LSDJ").text(e.data.dj);
- $("#LKMC").text(e.data.lkmc);
- $("#LKBGY").text(e.data.keeperName);
- $("#LSPZ").text(e.data.pz)
- }
- });
- $.ajax({
- type: "get",
- url: location.protocol+"//"+location.host+"/depot-intelligent/intelligents/WarningThreshold/getByOrgIdAndCfCode?orgId=" + LCcs[0] + "&vCfCode=" + LCcs[1],
- data: {},
- dataType: "json",
- async:true,
- success: function(e) {
- high = e.data.high;
- whign = e.data.whigh;
- low = e.data.low;
- wlow = e.data.wlow
- if(high == undefined && whign == undefined && low == undefined && wlow == undefined){
- CGQcase = 0;
- }
- else if(high != undefined && whign == undefined && low == undefined && wlow == undefined){
- CGQcase = 1;
- }
- else if(high != undefined && whign != undefined && low != undefined && wlow != undefined){
- CGQcase = 2;
- }
- }
- });
- $.ajax({
- type: "get",
- url: location.protocol+"//"+location.host+"/depot-intelligent/intelligents/temperatureRecord/findById?id=" + LCcs[2],
- data: {},
- async:true,
- dataType: "json",
- success: function(e) {
- console.log(e);
- if (e.data.inh == null) {
- e.data.inh = "";
- }
- if (e.data.intemp == null) {
- e.data.intemp = "";
- }
- if (e.data.outtemp == null) {
- e.data.outtemp = "";
- }
- if (e.data.outh == null) {
- e.data.outh = "";
- }
- $("#CNSD").text(e.data.inh);
- $("#CNWD").text(e.data.intemp);
- $("#CWWD").text(e.data.outtemp);
- $("#CWSD").text(e.data.outh)
- }
- });
- var scene = new THREE.Scene;
- scene.background = (new THREE.CubeTextureLoader).setPath("pic/")
- .load(['px.jpg', 'nx.jpg', 'py.jpg', 'ny.jpg', 'pz.jpg', 'nz.jpg',]);
- var axes = new THREE.AxesHelper(1e3);
- // scene.add(axes);
- var point = new THREE.PointLight(16777215);
- point.position.set(400, 200, 300);
- scene.add(point);
- var ambient = new THREE.AmbientLight(4473924);
- scene.add(ambient);
- var width = window.innerWidth;
- var height = window.innerHeight;
- var k = width / height;
- var s = 200;
- var camera = new THREE.PerspectiveCamera(100, width / height, 1, 1e3);
- camera.position.set(700, 100, 100);
- camera.lookAt(scene.position);
- THREE.onEvent(scene, camera);
- var p1 = {x: 550,y:80,z:200};
- var position = camera.position;
- var tween1 = new TWEEN.Tween(position);
- tween1.to(p1, 5000);
- var update = function () {
- // camera.position.set(p1.x,p1.y,p1.z);
- camera.lookAt(300,80,200);
- controls.target = new THREE.Vector3(300,80,200);
- // $("body").mLoading("hide"); //取消loading
- };
- tween1.onUpdate(update);
- tween1.easing(TWEEN.Easing.Back.InOut);
- $.ajax({
- type: "get",
- url: location.protocol+"//"+location.host+"/depot-intelligent/intelligents/temperatureRecord/findByHouseAndTimes?lqId=" + LCcs[2],
- data: {},
- async:true,
- dataType: "json",
- success: function(e) {
- console.log(e.data);
- //取第一个数
- for (let i in e.data[0]){
- AAA++
- }
- console.log(AAA)
- //取第二个数
- var BBBArray = [];
- var arr = []
- $.each(e.data,function(i,n){
- BBBArray.push(n[1]);
- })
- console.log(BBBArray);
- $.each(BBBArray,function(i,n){
- if(i+1 == n.split("-")[1]){
- BBB++
- }
- })
- console.log(BBB);
- //取第三个数
- CCC = BBBArray.length/BBB
- console.log(CCC);
-
- var geometry = new THREE.CylinderGeometry(.3, .3, 140);
- var material = new THREE.MeshLambertMaterial({
- color: 0
- });
- for (var x = 0; x < AAA; x++) {
- for (var z = 0; z < BBB; z++) {
- var mesh = new THREE.Mesh(geometry, material);
- mesh.position.set(x * 50, 0, z * 70);
- mesh.translateY(70);
- scene.add(mesh)
- }
- }
- var ckfloor = new THREE.BoxGeometry((AAA+1)*50, (BBB)*70, 3);
- var textureckfloor = (new THREE.TextureLoader).load("img/lss.jpg");
- textureckfloor.wrapS = textureckfloor.wrapT = THREE.RepeatWrapping;
- textureckfloor.repeat.set(8, 8);
- var ckfloormaterial = new THREE.MeshBasicMaterial({
- color: 16121850,
- map: textureckfloor
- });
- var ckfloormesh = new THREE.Mesh(ckfloor, ckfloormaterial);
- ckfloormesh.rotateX(Math.PI / 2);
- // ckfloormesh.position.set((AAA+1)*25, 3, (BBB+1)*35);
- ckfloormesh.position.set(AAA*25, 3, (BBB-1)*35);
- scene.add(ckfloormesh);
-
- var cubeleft = new THREE.CubeGeometry((AAA+1)*50, 140, 10, (AAA+1)*50);
- var textureleft = (new THREE.TextureLoader).load("img/qiang.jpg");
- textureleft.wrapS = textureleft.wrapT = THREE.RepeatWrapping;
- textureleft.repeat.set(3, 3);
- var materialleft = new THREE.MeshBasicMaterial({
- color: 15000001,
- map: textureleft,
- transparent: true,
- // opacity: 0.5,
- });
- var meshleft = new THREE.Mesh(cubeleft, materialleft);
- // meshleft.translateY(70);
- // meshleft.translateZ(590);
- meshleft.position.set((AAA)*25,70,(BBB)*70-35)
- scene.add(meshleft);
-
- var cuberight = new THREE.CubeGeometry((AAA+1)*50, 140, 10, (AAA+1)*50);
- var textureright = (new THREE.TextureLoader).load("img/qiang.jpg");
- textureright.wrapS = textureright.wrapT = THREE.RepeatWrapping;
- textureright.repeat.set(3, 3);
- var materialright = new THREE.MeshBasicMaterial({
- color: 15000001,
- map: textureright,
- });
- var meshright = new THREE.Mesh(cuberight, materialright);
- meshright.translateY(70);
- // meshright.translateZ(-250);
- meshright.position.set((AAA)*25,70,-35)
- scene.add(meshright);
-
- var cubeback = new THREE.CubeGeometry(10, 140, (BBB)*70, 140);
- var textureback = (new THREE.TextureLoader).load("img/qiang.jpg");
- textureback.wrapS = textureback.wrapT = THREE.RepeatWrapping;
- textureback.repeat.set(3, 3);
- var materialback = new THREE.MeshBasicMaterial({
- color: 15000001,
- map: textureback
- });
- var meshback = new THREE.Mesh(cubeback, materialback);
- meshback.translateY(70);
- // meshback.translateZ(170);
- // meshback.translateX(-200);
- meshback.position.set(-25,70,(BBB-1)*35)
- scene.add(meshback);
-
- var texturetop = (new THREE.TextureLoader).load("img/1111.jpg");
- texturetop.wrapS = texturetop.wrapT = THREE.RepeatWrapping;
- texturetop.repeat.set(10, 10);
- var materialtop = new THREE.MeshBasicMaterial({
- color: 1869550,
- map: texturetop
- });
- var cubetop1 = new THREE.CubeGeometry((AAA+2)*25, 10, (BBB)*70);
- var meshtop1 = new THREE.Mesh(cubetop1, materialtop);
- meshtop1.translateY(170);
- meshtop1.position.set(0,170,(BBB-1)*35)
- meshtop1.translateX((1/AAA)*70+50);
- // meshtop1.translateZ(170);
- meshtop1.rotateZ(Math.PI / 12);
- scene.add(meshtop1);
- var cubetop2 = new THREE.CubeGeometry((AAA+2)*25, 10, (BBB)*70);
- var meshtop2 = new THREE.Mesh(cubetop2, materialtop);
- meshtop2.position.set(0,170,(BBB-1)*35)
- meshtop2.translateX((AAA-1/AAA)*50-50);
- // meshtop2.translateZ(170);
- meshtop2.rotateZ(-Math.PI / 12);
- scene.add(meshtop2);
-
- var tubeMaterial = new THREE.MeshPhongMaterial({
- // map: texture,
- color:0x000000,
- transparent: true,
- });
- for(var x = 0; x<AAA;x++){
- var curve = new THREE.CatmullRomCurve3([
- new THREE.Vector3(x*50, 140, 0),
- new THREE.Vector3(x*50, 140, (BBB-1)*70),
- ],false/*是否闭合*/);
- var tubeGeometry = new THREE.TubeGeometry(curve, 2, 0.5, 5, false);
- var tube = new THREE.Mesh(tubeGeometry, tubeMaterial);
- scene.add(tube);
- }
-
-
- // 通过Path类的线条绘制方法方法定义轮廓
- var shape = new THREE.Shape();
- //shape.absarc(50,50,40,0,2*Math.PI);//圆弧
- shape.moveTo(0, 0, 0); //起点
- shape.lineTo(((AAA+1)/2)*50, 0, 0); //第2点
- shape.lineTo(0, 50, 0); //第3点
- shape.lineTo(-((AAA+1)/2)*50, 0, 0); //第4点
- shape.lineTo(0, 0, 0); //第5点
- var geometry = new THREE.ExtrudeGeometry( //拉伸造型
- shape, //二维轮廓
- //拉伸参数
- {
- amount: BBB*70, //拉伸长度
- }
- );
- var trianglematerial = new THREE.MeshPhongMaterial({
- // color: 0xC7C7C7,
- color:0x27408B,
- side: THREE.DoubleSide, //两面可见,
- //wireframe: true,
- }); //材质对象
- var meshwuzi = new THREE.Mesh(geometry, trianglematerial); //网格模型对象
- // meshwuzi.translateZ(-433)
- // meshwuzi.translateY(140)
- meshwuzi.position.set(((AAA+3)*35)/2,140,-35);
-
- scene.add(meshwuzi); //网格模型添加到场景中
- $.ajax({
- type: "get",
- url: location.protocol+"//"+location.host+"/depot-intelligent/intelligents/temperatureRecord/findByHouseAndTimes?lqId=" + LCcs[2],
- data: {},
- async:true,
- dataType: "json",
- success: function(e) {
- console.log(e);
- $.each(e.data, function(e, a) {
- for (var t = 2; t < AAA+2; t++) {
- CGQValue.push(a[t])
- }
- });
- // console.log(CGQValue);
- for (var a = CCC; a > 0; a--) {
- for (var t = 0; t < BBB; t++) {
- for (var r = 0; r < AAA; r++) {
- SensorID = SensorID + 1;
- var o = CGQValue[SensorID];
- switch (CGQcase){
- case 0:
- if(o == 250){
- var n = new THREE.MeshLambertMaterial({
- color: "#636363",
- wireframe: false,
- transparent: true,
- opacity: .9
- })
- }
- else{
- var n = new THREE.MeshLambertMaterial({
- color: 8190976,
- wireframe: false,
- transparent: true,
- opacity: .7
- })
- }
- break;
- case 1:
- if (o >= high) {
- var n = new THREE.MeshLambertMaterial({
- color: 16711680,
- wireframe: false,
- transparent: true,
- opacity: .9
- })
- }
- else{
- var n = new THREE.MeshLambertMaterial({
- color: 8190976,
- wireframe: false,
- transparent: true,
- opacity: .7
- })
- }
- break;
- case 2:
- if (o >= high && o != 250) {
- var n = new THREE.MeshLambertMaterial({
- color: 16711680,
- wireframe: false,
- transparent: true,
- opacity: .9
- })
- }
- else if(o == 250){
- var n = new THREE.MeshLambertMaterial({
- color: "#636363",
- wireframe: false,
- transparent: true,
- opacity: .9
- })
- }
- else if(o <= low){
- var n = new THREE.MeshLambertMaterial({
- color: "#00F5FF",
- wireframe: false,
- transparent: true,
- opacity: .7
- })
- }
- else if (o >= whign && o < high) {
- var n = new THREE.MeshLambertMaterial({
- color: 15658496,
- wireframe: false,
- transparent: true,
- opacity: .7
- })
- } else if (o >= low && o < wlow) {
- var n = new THREE.MeshLambertMaterial({
- color: "#00F5FF",
- wireframe: false,
- transparent: true,
- opacity: .7
- })
- } else if (o < whign && o > wlow) {
- var n = new THREE.MeshLambertMaterial({
- color: 8190976,
- wireframe: false,
- transparent: true,
- opacity: .7
- })
- }
- break;
- }
-
- var s = new THREE.Mesh(sphere, n);
- s.position.set(r * 50, a * 25, t * 70);
- s.rotateX(Math.PI / 2);
- s.name = "传感器" + SensorID.toString();
-
- var d = document.createElement("div");
- d.className = "label";
- d.textContent = CGQValue[SensorID] + "℃";
- d.style.marginTop = "-1em";
- var c = new THREE.CSS2DObject(d);
- // c.position.set(r, a, t);
- s.add(c);
- scene.add(s)
- // console.log(SensorID);
-
- s.add(c);
- // scene.add(newsphereMesh);
- // s.on('click', function(m) {
- // console.log(m);
- // if (m.children.length > 1) {
- // alert(m.children[1].element.innerText);
- // } else{
- // alert(m.children[0].element.innerText);
- // }
- // });
- }
- }
-
- }
- }
- });
-
- }
- });
- var tubeMaterial = new THREE.MeshPhongMaterial({
- color: 0,
- transparent: true
- });
- var dianban = new THREE.BoxGeometry(3e3, 3e3, 5);
- var texturefloor = (new THREE.TextureLoader).load("img/cizhuan.jpg");
- texturefloor.wrapS = texturefloor.wrapT = THREE.RepeatWrapping;
- texturefloor.repeat.set(80, 80);
- var dianbanmaterial = new THREE.MeshBasicMaterial({
- color: 16121850,
- map: texturefloor
- });
- var real_dianban = new THREE.Mesh(dianban, dianbanmaterial);
- real_dianban.rotateX(Math.PI / 2);
- scene.add(real_dianban);
- var sphere = new THREE.SphereGeometry(4, 20, 20);
- labelRenderer = new THREE.CSS2DRenderer;
- labelRenderer.setSize(window.innerWidth, window.innerHeight);
- labelRenderer.domElement.style.position = "absolute";
- labelRenderer.domElement.style.top = 0;
- document.body.appendChild(labelRenderer.domElement);
- function animate() {
- requestAnimationFrame(animate)
- }
- function draw() {
- animate()
- }
- var renderer = new THREE.WebGLRenderer;
- renderer.setSize(width, height);
- renderer.setClearColor(12178431, 1);
- document.body.appendChild(renderer.domElement);
- function render() {
- renderer.render(scene, camera);
- labelRenderer.render(scene, camera);
- requestAnimationFrame(render)
- TWEEN.update();
- }
- render();
- var controls = new THREE.OrbitControls(camera);
- controls.maxPolarAngle = 1.5;
- controls.minPolarAngle = 1.3;
- controls.minDistance = 50;
- controls.maxDistance = 800;
- function CWXQ() {
- // camera.position.set(80, 50, 80);
- controls.maxDistance = 200;
- console.log($(".label"));
- tween1.start();
- $("body").mLoading({
- text: "切换摄像头视角...", //加载文字,默认值:加载中...
- // mask:false//是否显示遮罩效果,默认显示
- });
- setTimeout(function() {
- $("body").mLoading("hide");
- $(".label").addClass("active")
- }, 5000)
-
- }
- function HFQJ() {
- controls.maxDistance = 800;
- controls.reset();
- $(".label").removeClass("active")
- }
|