From 37f60d85f75fdf0395404ba4fa90cd0039206872 Mon Sep 17 00:00:00 2001 From: lxc <237024898@qq.com> Date: Wed, 21 Dec 2022 09:05:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E7=AD=BE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/.DS_Store | Bin 6148 -> 6148 bytes js/app.js | 107 +++++---- js/units/sprite.js | 0 lndexUASB.html | 41 ++-- lndexUASB2.html | 574 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 659 insertions(+), 63 deletions(-) create mode 100644 js/units/sprite.js create mode 100644 lndexUASB2.html diff --git a/assets/.DS_Store b/assets/.DS_Store index 170501ce12d1c152f4f7a7f6522ac59a337b2ab1..48ed76d041e6ab1f509454e9fc3681a569bcbfa6 100644 GIT binary patch delta 21 ccmZoMXffDul7++4SVuwE(AaSEMHXXW07@PPHUIzs delta 21 ccmZoMXffDul7++ER7XMA$iQIpMHXXW07?l4GXMYp diff --git a/js/app.js b/js/app.js index 08a7d12..ce52cb3 100644 --- a/js/app.js +++ b/js/app.js @@ -11,6 +11,9 @@ var APP = { var controls, camera, glScene, cssScene, glRenderer, cssRenderer; + var waters = []; + //CSS 标签列表 + var BIG_LABEL_ARR = []; camera = new THREE.PerspectiveCamera( 45, @@ -47,7 +50,7 @@ var APP = { window.camera = camera; window.scene = glScene; - var waters = []; + @@ -117,40 +120,40 @@ var APP = { } function createLights() { - var directionalLight = new THREE.DirectionalLight(0xafafaf); + var directionalLight = new THREE.DirectionalLight(0xe0ffff); directionalLight.position.set(-.5, .5, -1.5).normalize(); glScene.add(directionalLight); - const light = new THREE.AmbientLight("#ffffff"); + const light = new THREE.AmbientLight("#afafaf"); glScene.add(light); - const light1 = new THREE.PointLight(0xe0ffff, 0.1, 20) - light1.position.set(-2, 3, 2) - glScene.add(light1) + // const light1 = new THREE.PointLight(0xe0ffff, 0.1, 20) + // light1.position.set(-2, 3, 2) + // glScene.add(light1) - const light2 = new THREE.PointLight(0xe0ffff, 0.1, 20) - light2.position.set(0, 3, -6) - glScene.add(light2) + // const light2 = new THREE.PointLight(0xe0ffff, 0.1, 20) + // light2.position.set(0, 3, -6) + // glScene.add(light2) - const light3 = new THREE.PointLight(0xe0ffff, 0.1, 20) - light3.position.set(-12, 3, 6) - glScene.add(light3) + // const light3 = new THREE.PointLight(0xe0ffff, 0.1, 20) + // light3.position.set(-12, 3, 6) + // glScene.add(light3) - const light4 = new THREE.PointLight(0xe0ffff, 0.1, 20) - light4.position.set(-12, 4, -4) - glScene.add(light4) + // const light4 = new THREE.PointLight(0xe0ffff, 0.1, 20) + // light4.position.set(-12, 4, -4) + // glScene.add(light4) - const light5 = new THREE.PointLight(0xe0ffff, 0.1, 20) - light5.position.set(12, 4, -8) - glScene.add(light5) + // const light5 = new THREE.PointLight(0xe0ffff, 0.1, 20) + // light5.position.set(12, 4, -8) + // glScene.add(light5) - const light6 = new THREE.PointLight(0xe0ffff, 0.1, 20) - light6.position.set(12, 4, 0) - glScene.add(light6) + // const light6 = new THREE.PointLight(0xe0ffff, 0.1, 20) + // light6.position.set(12, 4, 0) + // glScene.add(light6) - const light7 = new THREE.PointLight(0xe0ffff, 0.1, 20) - light7.position.set(12, 4, 8) - glScene.add(light7) + // const light7 = new THREE.PointLight(0xe0ffff, 0.1, 20) + // light7.position.set(12, 4, 8) + // glScene.add(light7) } this.setClearColor = function (color) { @@ -246,29 +249,29 @@ var APP = { glRenderer.setAnimationLoop(animate); - const image = document.createElement('img'); - image.addEventListener('load', function () { + // const image = document.createElement('img'); + // image.addEventListener('load', function () { - for (let i = 0; i < 2; i++) { + // for (let i = 0; i < 2; i++) { - const object = new CSS3DSprite(image.cloneNode()); - object.position.x = Math.random() * 4 - 2, - object.position.y = Math.random() * 4 - 2, - object.position.z = Math.random() * 4 - 2; - object.scale.set(0.01, 0.01, 0.01); - glScene.add(object); + // const object = new CSS3DSprite(image.cloneNode()); + // object.position.x = Math.random() * 4 - 2, + // object.position.y = Math.random() * 4 - 2, + // object.position.z = Math.random() * 4 - 2; + // object.scale.set(0.01, 0.01, 0.01); + // glScene.add(object); - objects.push(object); + // objects.push(object); - } + // } - //transition(); + // //transition(); - }); - image.src = '/assets/textures/sprite.png'; + // }); + // image.src = '/assets/textures/sprite.png'; - cssScene.add(createSpriteShape()); - cssScene.add(createBox13DLabel()); + // cssScene.add(createSpriteShape()); + // cssScene.add(createBox13DLabel()); }; @@ -318,19 +321,23 @@ var APP = { url); cssScene.add(cssObject); } - const defaultScale=80 + const defaultScale = 80 this.create3dLabel = function (parent, text, w = 100, h = 20, position, rotation) { - - let txtlength=text.length - + + + // let sprite =createBox13DLabel() + // glScene.add(sprite) + // return ; + let txtlength = text.length + var width = defaultScale * txtlength; var height = defaultScale + 15; - + var plane = css3dlabel.createPlane( width, height, position, rotation); - + glScene.add(plane); var cssObject = css3dlabel.createCssLabel(text, @@ -339,10 +346,11 @@ var APP = { rotation); // if(parent){ // parent.add(cssObject); - + BIG_LABEL_ARR.push(cssObject); // }else{ cssScene.add(cssObject); // } + //cssObject.element.textContent = 'your data' } // this.create3dButton = function (parent, text, w = 100, h = 20, position, rotation,click) { @@ -403,6 +411,11 @@ var APP = { earthLabel.scale.set(0.01, 0.01, 0.01); return earthLabel; } + this.updateLabel = function (name, text) { + BIG_LABEL_ARR.forEach(tmplable => { + tmplable.element.textContent = text; + }) + } } diff --git a/js/units/sprite.js b/js/units/sprite.js new file mode 100644 index 0000000..e69de29 diff --git a/lndexUASB.html b/lndexUASB.html index 36591f4..dd0f2b3 100644 --- a/lndexUASB.html +++ b/lndexUASB.html @@ -90,13 +90,13 @@ window.THREE = THREE; // Used by APP Scripts. - var client = null; + var mqttclient = null; var player = new APP.Player(); //水泵列表 - var pumpModelArr = [] - var bigLabelArr = [] + var PUMP_MODEL_ARR = [] + //红色标签 // const labArr = [{ name: "水泵M_1", text: "水泵1" }, { name: "水泵M_2", text: "水泵002" } @@ -136,6 +136,7 @@ addRemarkLabels(); mqttInit(); + updateLabel(); // for (var i = 0; i < 1; i++) { // player.create3dPage( // 1020, 680, @@ -209,8 +210,8 @@ addLabel(item, 0, 0.4, 0) } else if (item.name.indexOf('水泵M_') > -1) { // 水泵 - x = x + 1; - pumpModelArr.push(item); + x = x + 1; + PUMP_MODEL_ARR.push(item); //debugger if (item.name === '水泵001') { item.material.color.set(0x00f); @@ -514,14 +515,14 @@ username: config.mqttUserName, password: config.mqttPassword, } - client = mqtt.connect('ws://127.0.0.1:8083/mqtt', options); - client.on('reconnect', function (error) { + mqttclient = mqtt.connect('ws://127.0.0.1:8083/mqtt', options); + mqttclient.on('reconnect', function (error) { console.log("reconnect"); }) - client.on('error', function (error) { + mqttclient.on('error', function (error) { console.log('连接失败:', error) }) - client.on('message', function (topic, message, s) { + mqttclient.on('message', function (topic, message, s) { console.log(topic, message.toString()); if (message.toString() == '1') { // if (that.lastTime + 2 * 1000 < new Date().getTime()) { @@ -530,14 +531,17 @@ // } } }) - client.subscribe("/scene/update/*"); - client.subscribe("scene"); - client.publish('/sys/update/scene', 'scene'); - client.subscribe("RTData", (err) => { + mqttclient.subscribe("/scene/update/*", (err) => { + if (!err) { + console.log(`订阅/scene/update/* 成功`); + } + }); + mqttclient.subscribe("RTData", (err) => { if (!err) { console.log(`订阅 RTData 成功`); } }); + mqttclient.publish('/sys/update/scene', 'scene'); } //打开对话框 function openDialog(tmpobj) { @@ -555,10 +559,15 @@ }); } - function updateLabel(event) { - - alert(event) + function updateLabel() { + return + // debugger + setTimeout(updateLabel, 1000); //5秒后执行 + let date = new Date(); + let m = date.getSeconds(); + player.updateLabel("", m); } + diff --git a/lndexUASB2.html b/lndexUASB2.html new file mode 100644 index 0000000..0688603 --- /dev/null +++ b/lndexUASB2.html @@ -0,0 +1,574 @@ + + + + + + + + + + + + + + + +
2D数据表格显示 不旋转 厌氧系统
+ + + + + + + + +