替换三维模型
This commit is contained in:
parent
fd5ca3e6f5
commit
9806d73d5b
|
@ -15,5 +15,6 @@
|
||||||
<body>
|
<body>
|
||||||
<div id="app" v-cloak></div>
|
<div id="app" v-cloak></div>
|
||||||
<script type="module" src="/src/main.js"></script>
|
<script type="module" src="/src/main.js"></script>
|
||||||
|
<script src="./config.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
const config = {
|
||||||
|
host:'172.16.1.106',
|
||||||
|
port:'8083',
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
||||||
172.16.1.106:5005
|
10.155.161.49:5005
|
|
@ -1,89 +1,97 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en-us">
|
<html lang="en-us">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
<title>Unity WebGL Player | U3D_TobaccoWarehouseISMDTSystem</title>
|
<title>Unity WebGL Player | U3D_TobaccoWarehouseISMDTSystem</title>
|
||||||
<link rel="shortcut icon" href="TemplateData/favicon.ico">
|
<link rel="shortcut icon" href="TemplateData/favicon.ico">
|
||||||
<link rel="stylesheet" href="TemplateData/style.css">
|
<link rel="stylesheet" href="TemplateData/style.css">
|
||||||
</head>
|
</head>
|
||||||
<style>
|
<style>
|
||||||
body,html{
|
body,html{
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<body>
|
<body>
|
||||||
<div id="unity-container" class="unity-desktop" style="width: 100%;height: 100%;">
|
<div id="unity-container" class="unity-desktop" style="width: 100%;height:100%">
|
||||||
<canvas id="unity-canvas" tabindex="-1" style="width: 100%;height: 100%;"></canvas>
|
<canvas id="unity-canvas" style="width: 100%;height:100%" tabindex="-1"></canvas>
|
||||||
<div id="unity-loading-bar">
|
<div id="unity-loading-bar">
|
||||||
<div id="unity-logo"></div>
|
<div id="unity-logo"></div>
|
||||||
<div id="unity-progress-bar-empty">
|
<div id="unity-progress-bar-empty">
|
||||||
<div id="unity-progress-bar-full"></div>
|
<div id="unity-progress-bar-full"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="unity-warning"> </div>
|
<div id="unity-warning"></div>
|
||||||
<div id="unity-footer">
|
<div id="unity-footer">
|
||||||
<div id="unity-webgl-logo"></div>
|
<div id="unity-webgl-logo"></div>
|
||||||
<div id="unity-fullscreen-button"></div>
|
<div id="unity-fullscreen-button"></div>
|
||||||
<div id="unity-build-title">U3D_TobaccoWarehouseISMDTSystem</div>
|
<div id="unity-build-title">U3D_TobaccoWarehouseISMDTSystem</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<script>
|
</div>
|
||||||
|
|
||||||
var container = document.querySelector("#unity-container");
|
<button onclick="OpenHtmlMQTT()">Connect</button>
|
||||||
var canvas = document.querySelector("#unity-canvas");
|
<button onclick="publishMessage()">Publish</button>
|
||||||
var loadingBar = document.querySelector("#unity-loading-bar");
|
<button onclick="disconnectMQTT()">Disconnect</button>
|
||||||
var progressBarFull = document.querySelector("#unity-progress-bar-full");
|
<script src="./js/mqtt.min.js"></script>
|
||||||
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
|
|
||||||
var warningBanner = document.querySelector("#unity-warning");
|
|
||||||
|
|
||||||
// Shows a temporary message banner/ribbon for a few seconds, or
|
|
||||||
// a permanent error message on top of the canvas if type=='error'.
|
<script>
|
||||||
// If type=='warning', a yellow highlight color is used.
|
|
||||||
// Modify or remove this function to customize the visually presented
|
var container = document.querySelector("#unity-container");
|
||||||
// way that non-critical warnings and error messages are presented to the
|
var canvas = document.querySelector("#unity-canvas");
|
||||||
// user.
|
var loadingBar = document.querySelector("#unity-loading-bar");
|
||||||
function unityShowBanner(msg, type) {
|
var progressBarFull = document.querySelector("#unity-progress-bar-full");
|
||||||
|
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
|
||||||
|
var warningBanner = document.querySelector("#unity-warning");
|
||||||
|
|
||||||
|
// Shows a temporary message banner/ribbon for a few seconds, or
|
||||||
|
// a permanent error message on top of the canvas if type=='error'.
|
||||||
|
// If type=='warning', a yellow highlight color is used.
|
||||||
|
// Modify or remove this function to customize the visually presented
|
||||||
|
// way that non-critical warnings and error messages are presented to the
|
||||||
|
// user.
|
||||||
|
function unityShowBanner(msg, type) {
|
||||||
function updateBannerVisibility() {
|
function updateBannerVisibility() {
|
||||||
warningBanner.style.display = warningBanner.children.length ? 'block' : 'none';
|
warningBanner.style.display = warningBanner.children.length ? 'block' : 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
var div = document.createElement('div');
|
var div = document.createElement('div');
|
||||||
div.innerHTML = msg;
|
div.innerHTML = msg;
|
||||||
warningBanner.appendChild(div);
|
warningBanner.appendChild(div);
|
||||||
if (type == 'error') div.style = 'background: red; padding: 10px;';
|
if (type == 'error') div.style = 'background: red; padding: 10px;';
|
||||||
else {
|
else {
|
||||||
if (type == 'warning') div.style = 'background: yellow; padding: 10px;';
|
if (type == 'warning') div.style = 'background: yellow; padding: 10px;';
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
warningBanner.removeChild(div);
|
warningBanner.removeChild(div);
|
||||||
updateBannerVisibility();
|
updateBannerVisibility();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
updateBannerVisibility();
|
updateBannerVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
var buildUrl = "Build";
|
var buildUrl = "Build";
|
||||||
var loaderUrl = buildUrl + "/延安烟厂.loader.js";
|
var loaderUrl = buildUrl + "/webgl.loader.js";
|
||||||
var config = {
|
var config = {
|
||||||
dataUrl: buildUrl + "/延安烟厂.data.unityweb",
|
dataUrl: buildUrl + "/webgl.data.unityweb",
|
||||||
frameworkUrl: buildUrl + "/延安烟厂.framework.js.unityweb",
|
frameworkUrl: buildUrl + "/webgl.framework.js.unityweb",
|
||||||
codeUrl: buildUrl + "/延安烟厂.wasm.unityweb",
|
codeUrl: buildUrl + "/webgl.wasm.unityweb",
|
||||||
streamingAssetsUrl: "StreamingAssets",
|
streamingAssetsUrl: "StreamingAssets",
|
||||||
companyName: "DefaultCompany",
|
companyName: "DefaultCompany",
|
||||||
productName: "U3D_TobaccoWarehouseISMDTSystem",
|
productName: "U3D_TobaccoWarehouseISMDTSystem",
|
||||||
productVersion: "0.1",
|
productVersion: "0.1",
|
||||||
showBanner: unityShowBanner,
|
showBanner: unityShowBanner,
|
||||||
};
|
};
|
||||||
|
|
||||||
// By default, Unity keeps WebGL canvas render target size matched with
|
// By default, Unity keeps WebGL canvas render target size matched with
|
||||||
// the DOM size of the canvas element (scaled by window.devicePixelRatio)
|
// the DOM size of the canvas element (scaled by window.devicePixelRatio)
|
||||||
// Set this to false if you want to decouple this synchronization from
|
// Set this to false if you want to decouple this synchronization from
|
||||||
// happening inside the engine, and you would instead like to size up
|
// happening inside the engine, and you would instead like to size up
|
||||||
// the canvas DOM size and WebGL render target sizes yourself.
|
// the canvas DOM size and WebGL render target sizes yourself.
|
||||||
// config.matchWebGLToCanvasSize = false;
|
// config.matchWebGLToCanvasSize = false;
|
||||||
|
|
||||||
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
|
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
|
||||||
// Mobile device style: fill the whole browser client area with the game canvas:
|
// Mobile device style: fill the whole browser client area with the game canvas:
|
||||||
|
|
||||||
var meta = document.createElement('meta');
|
var meta = document.createElement('meta');
|
||||||
|
@ -98,32 +106,113 @@
|
||||||
// config.devicePixelRatio = 1;
|
// config.devicePixelRatio = 1;
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Desktop style: Render the game canvas in a window that can be maximized to fullscreen:
|
// Desktop style: Render the game canvas in a window that can be maximized to fullscreen:
|
||||||
|
|
||||||
// canvas.style.width = "1920px";
|
// canvas.style.width = "960px";
|
||||||
// canvas.style.height = "1080px";
|
// canvas.style.height = "600px";
|
||||||
}
|
}
|
||||||
|
|
||||||
loadingBar.style.display = "block";
|
|
||||||
|
|
||||||
var script = document.createElement("script");
|
//----------------------------------------------------------------------------------MQTT-----------------------------------------------------------------------------
|
||||||
script.src = loaderUrl;
|
let client;
|
||||||
script.onload = () => {
|
|
||||||
|
function OpenHtmlMQTT() {
|
||||||
|
client = mqtt.connect('ws://10.155.161.49:8083/mqtt');
|
||||||
|
|
||||||
|
client.on('connect', () => {
|
||||||
|
console.log('连接...');
|
||||||
|
|
||||||
|
const devices = [
|
||||||
|
"cm1",//去加盖机
|
||||||
|
Array.from({length: 7}, (_, i) => `elv${i + 1}`),//提升机
|
||||||
|
Array.from({length: 7}, (_, i) => `convoyor510${i + 1}`),//输送机
|
||||||
|
Array.from({length: 51}, (_, i) => `convoyor52${String(i + 1).padStart(2, '0')}`),//输送机
|
||||||
|
Array.from({length: 30}, (_, i) => `convoyor54${String(i + 1).padStart(2, '0')}`),//输送机
|
||||||
|
Array.from({ length: 4 }, (_, i) => `dpm${i + 1}`),//拆码垛机
|
||||||
|
Array.from({ length: 2 }, (_, i) => `fxj${i + 1}`),////机械手臂
|
||||||
|
Array.from({length: 8}, (_, i) => `car${i + 1}`),//小车
|
||||||
|
"fe1",//落地时提升机
|
||||||
|
Array.from({length: 2}, (_, i) => `qcbd${i + 1}`)//快换电池装置
|
||||||
|
];
|
||||||
|
|
||||||
|
devices.forEach(device => {
|
||||||
|
console.log(device);
|
||||||
|
client.subscribe(device, {
|
||||||
|
onSuccess: () => {
|
||||||
|
console.log(`已订阅: ${device}`);
|
||||||
|
},
|
||||||
|
onFailure: (err) => {
|
||||||
|
console.error(`订阅失败: ${device}:`, err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// client.subscribe('car1', (err) => {
|
||||||
|
// if (!err) {
|
||||||
|
// console.log('Subscribed to car1');
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('message', (topic, message) => {
|
||||||
|
|
||||||
|
const mes = JSON.stringify({device: topic, message: message.toString()});
|
||||||
|
|
||||||
|
// console.log(mes);
|
||||||
|
|
||||||
|
unityInstance.SendMessage('APP', 'Message', mes)
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('error', (err) => {
|
||||||
|
console.error('Connection error: ', err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function publishMessage() {
|
||||||
|
if (client) {
|
||||||
|
client.publish('car1', 'Hello');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function disconnectMQTT() {
|
||||||
|
if (client) {
|
||||||
|
client.end(() => {
|
||||||
|
console.log('关闭连接');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------MQTT-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
loadingBar.style.display = "block";
|
||||||
|
|
||||||
|
var script = document.createElement("script");
|
||||||
|
script.src = loaderUrl;
|
||||||
|
script.onload = () => {
|
||||||
createUnityInstance(canvas, config, (progress) => {
|
createUnityInstance(canvas, config, (progress) => {
|
||||||
progressBarFull.style.width = 100 * progress + "%";
|
progressBarFull.style.width = 100 * progress + "%";
|
||||||
}).then((unityInstance) => {
|
}).then((unityInstance) => {
|
||||||
loadingBar.style.display = "none";
|
loadingBar.style.display = "none";
|
||||||
fullscreenButton.onclick = () => {
|
|
||||||
unityInstance.SetFullscreen(1);
|
// 为window添加unityInstance对象
|
||||||
};
|
window.unityInstance = unityInstance
|
||||||
}).catch((message) => {
|
|
||||||
alert(message);
|
fullscreenButton.onclick = () => {
|
||||||
});
|
unityInstance.SetFullscreen(1);
|
||||||
};
|
};
|
||||||
|
}).catch((message) => {
|
||||||
|
alert(message);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
document.body.appendChild(script);
|
document.body.appendChild(script);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
import mqtt from "mqtt";
|
import mqtt from "mqtt";
|
||||||
class mqttHandle {
|
class mqttHandle {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -9,9 +10,9 @@ class mqttHandle {
|
||||||
cleanSession: true,
|
cleanSession: true,
|
||||||
connectTimeout: 7000, // 超时时间
|
connectTimeout: 7000, // 超时时间
|
||||||
reconnectPeriod: 7000, // 重连时间间隔
|
reconnectPeriod: 7000, // 重连时间间隔
|
||||||
host: '172.16.1.106',
|
host: config.host,
|
||||||
// host: '172.16.1.253',
|
// host: '172.16.1.253',
|
||||||
port: '8083',
|
port: config.port,
|
||||||
// 认证信息
|
// 认证信息
|
||||||
clientId: Number(new Date()).toString(),
|
clientId: Number(new Date()).toString(),
|
||||||
// clientId: 'JBFY',
|
// clientId: 'JBFY',
|
||||||
|
@ -33,7 +34,7 @@ class mqttHandle {
|
||||||
// console.log("connectUrl",connectUrl)
|
// console.log("connectUrl",connectUrl)
|
||||||
const { host, port, endpoint, ...options } = this.connect;
|
const { host, port, endpoint, ...options } = this.connect;
|
||||||
// const connectUrl = 'ws://138.227.208.100:1884/mqtt';
|
// const connectUrl = 'ws://138.227.208.100:1884/mqtt';
|
||||||
const connectUrl = 'ws://172.16.1.106:8083/mqtt';
|
const connectUrl = `ws://${config.host}:${config.port}/mqtt`;
|
||||||
// const connectUrl = 'ws://172.16.1.253:1884/mqtt';
|
// const connectUrl = 'ws://172.16.1.253:1884/mqtt';
|
||||||
if (this.mqttClient == undefined) {
|
if (this.mqttClient == undefined) {
|
||||||
this.mqttClient = mqtt.connect(connectUrl, options);
|
this.mqttClient = mqtt.connect(connectUrl, options);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<Nav />
|
<Nav />
|
||||||
<div class="unity">
|
<div class="unity">
|
||||||
<!-- <iframe src="model/index.html" frameborder="0"></iframe> -->
|
<iframe src="model/index.html" frameborder="0"></iframe>
|
||||||
</div>
|
</div>
|
||||||
<div class="home">
|
<div class="home">
|
||||||
<div class="home-left">
|
<div class="home-left">
|
||||||
|
@ -488,6 +488,7 @@ function drawInventoryNewsEcahrt(result) {
|
||||||
name: "特殊箱子",
|
name: "特殊箱子",
|
||||||
value: 0,
|
value: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
// for (let i = 0; i < scaleData.length; i++) {
|
// for (let i = 0; i < scaleData.length; i++) {
|
||||||
// if (scaleData[i].name === "特殊空箱子") {
|
// if (scaleData[i].name === "特殊空箱子") {
|
||||||
// box.value = box.value + scaleData[i].value;
|
// box.value = box.value + scaleData[i].value;
|
||||||
|
@ -906,9 +907,7 @@ function realInfo(topic, message) {
|
||||||
const u8arr = new Uint8Array(message);
|
const u8arr = new Uint8Array(message);
|
||||||
const temp = utf8decoder.decode(u8arr); // 将二进制数据转为字符串
|
const temp = utf8decoder.decode(u8arr); // 将二进制数据转为字符串
|
||||||
console.log("temp", temp)
|
console.log("temp", temp)
|
||||||
// window.parent.getMqttData(temp)
|
|
||||||
const msg = JSON.parse(temp); //这一步报错则返回的是二进制流图片,不报错则返回的是JSON的错误提示数据
|
const msg = JSON.parse(temp); //这一步报错则返回的是二进制流图片,不报错则返回的是JSON的错误提示数据
|
||||||
console.log(msg,'xxxxxxxxxx');
|
|
||||||
msg.forEach((el) => {
|
msg.forEach((el) => {
|
||||||
el.msg = "维修提醒";
|
el.msg = "维修提醒";
|
||||||
el.reminderMsg = el.facCode + " 需要维修";
|
el.reminderMsg = el.facCode + " 需要维修";
|
||||||
|
|
Loading…
Reference in New Issue