339 lines
12 KiB
HTML
339 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en-us">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<title>Unity WebGL Player | MqttTest</title>
|
|
<link rel="shortcut icon" href="TemplateData/favicon.ico">
|
|
<link rel="stylesheet" href="TemplateData/style.css">
|
|
</head>
|
|
|
|
<body>
|
|
<div id="unity-container" style="height: 100%;" class="unity-desktop">
|
|
<canvas id="unity-canvas"></canvas>
|
|
<div id="unity-loading-bar">
|
|
<div id="unity-logo"></div>
|
|
<div id="unity-progress-bar-empty">
|
|
<div id="unity-progress-bar-full"></div>
|
|
</div>
|
|
</div>
|
|
<div id="unity-warning"> </div>
|
|
<div id="unity-footer">
|
|
<!-- <div id="unity-webgl-logo"></div>
|
|
<div id="unity-fullscreen-button"></div>
|
|
<div id="unity-build-title">MqttTest</div> -->
|
|
</div>
|
|
<div id='black'>
|
|
|
|
</div>
|
|
<div id='blackleng'>
|
|
|
|
</div>
|
|
</div>
|
|
<script>
|
|
var container = document.querySelector("#unity-container");
|
|
var canvas = document.querySelector("#unity-canvas");
|
|
var loadingBar = document.querySelector("#unity-loading-bar");
|
|
var progressBarFull = document.querySelector("#unity-progress-bar-full");
|
|
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
|
|
var warningBanner = document.querySelector("#unity-warning");
|
|
var black = document.querySelector("#black");
|
|
var blackleng = document.querySelector("#blackleng");
|
|
// 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() {
|
|
warningBanner.style.display = warningBanner.children.length ? 'block' : 'none';
|
|
}
|
|
var div = document.createElement('div');
|
|
div.innerHTML = msg;
|
|
warningBanner.appendChild(div);
|
|
if (type == 'error') div.style = 'background: red; padding: 10px;';
|
|
else {
|
|
if (type == 'warning') div.style = 'background: yellow; padding: 10px;';
|
|
setTimeout(function () {
|
|
warningBanner.removeChild(div);
|
|
updateBannerVisibility();
|
|
}, 5000);
|
|
}
|
|
updateBannerVisibility();
|
|
}
|
|
|
|
var buildUrl = "Build";
|
|
var loaderUrl = buildUrl + "/YtzeWeb.loader.js";
|
|
var config = {
|
|
dataUrl: buildUrl + "/YtzeWeb.data.unityweb",
|
|
frameworkUrl: buildUrl + "/YtzeWeb.framework.js.unityweb",
|
|
codeUrl: buildUrl + "/YtzeWeb.wasm.unityweb",
|
|
streamingAssetsUrl: "StreamingAssets",
|
|
companyName: "DefaultCompany",
|
|
productName: "MqttTest",
|
|
productVersion: "0.1",
|
|
showBanner: unityShowBanner,
|
|
};
|
|
|
|
// By default Unity keeps WebGL canvas render target size matched with
|
|
// the DOM size of the canvas element (scaled by window.devicePixelRatio)
|
|
// Set this to false if you want to decouple this synchronization from
|
|
// happening inside the engine, and you would instead like to size up
|
|
// the canvas DOM size and WebGL render target sizes yourself.
|
|
// config.matchWebGLToCanvasSize = false;
|
|
|
|
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
|
|
// Mobile device style: fill the whole browser client area with the game canvas:
|
|
|
|
var meta = document.createElement('meta');
|
|
meta.name = 'viewport';
|
|
meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes';
|
|
document.getElementsByTagName('head')[0].appendChild(meta);
|
|
container.className = "unity-mobile";
|
|
|
|
// To lower canvas resolution on mobile devices to gain some
|
|
// performance, uncomment the following line:
|
|
// config.devicePixelRatio = 1;
|
|
|
|
canvas.style.width = window.innerWidth + 'px';
|
|
canvas.style.height = window.innerHeight + 'px';
|
|
|
|
unityShowBanner('WebGL builds are not supported on mobile devices.');
|
|
} else {
|
|
// Desktop style: Render the game canvas in a window that can be maximized to fullscreen:
|
|
|
|
// canvas.style.width = "1600px";
|
|
// canvas.style.height = "900px";
|
|
canvas.style.width = window.innerWidth + 'px';
|
|
canvas.style.height = window.innerHeight + 'px';
|
|
}
|
|
|
|
loadingBar.style.display = "block";
|
|
blackleng.style.display = "none";
|
|
var script = document.createElement("script");
|
|
script.src = loaderUrl;
|
|
script.onload = () => {
|
|
createUnityInstance(canvas, config, (progress) => {
|
|
window.parent.getProgress(progress);
|
|
progressBarFull.style.width = 100 * progress + "%";
|
|
}).then((unityInstance) => {
|
|
unity = unityInstance
|
|
loadingBar.style.display = "none";
|
|
// fullscreenButton.onclick = () => {
|
|
// unityInstance.SetFullscreen(1);
|
|
// };
|
|
black.style.display = "none";
|
|
blackleng.style.display = "block";
|
|
}).catch((message) => {
|
|
alert(message);
|
|
});
|
|
};
|
|
function OnSceneLoaded() {
|
|
black.style.display = "none";
|
|
blackleng.style.display = "none";
|
|
window.parent.createMqtt();
|
|
}
|
|
function fullScreen() {
|
|
|
|
if (unity != null) {
|
|
console.log('Unity_FullScreen')
|
|
unity.SendMessage("GameManager", 'Unity_FullScreen');
|
|
}
|
|
}
|
|
function exitFullScreen() {
|
|
if (unity != null) {
|
|
console.log('Unity_ExitFullScreen')
|
|
unity.SendMessage("GameManager", 'Unity_ExitFullScreen');
|
|
}
|
|
}
|
|
function receiveMqttData(string) {
|
|
if (unity != null) {
|
|
console.log('Unity_ReceiveMqttData', string)
|
|
unity.SendMessage("GameManager", 'Unity_ReceiveMqttData', string);
|
|
}
|
|
}
|
|
//获取视频地址
|
|
function getVideoUrl(data) {
|
|
console.log('Unity_ReceiveMqttData', data)
|
|
window.parent.gantDialog();
|
|
}
|
|
function closeVideo() {
|
|
window.parent.dialogShowClose()
|
|
}
|
|
//显示隐藏bottomCharts
|
|
function changeBottomCharts(data) {
|
|
console.log("changeBottomCharts", data)
|
|
//打开底部
|
|
if (data == "1") {
|
|
window.parent.closeBottom()
|
|
|
|
} else if (data == "0") {
|
|
//隐藏底部
|
|
window.parent.openBottom()
|
|
}
|
|
}
|
|
//显示隐藏bottomCharts不控制头部
|
|
function changeBottomChartsOne(data) {
|
|
console.log("data", data)
|
|
|
|
if (data == "1") {
|
|
window.parent.openBottomOne()
|
|
// window.parent.openBottom()
|
|
} else if (data == "0") {
|
|
//隐藏底部
|
|
window.parent.closeBottomOne()
|
|
// window.parent.closeBottom()
|
|
}
|
|
}
|
|
function getMaxVideoUrl(data) {
|
|
var name = ''
|
|
var url = ''
|
|
var noticeId = ''
|
|
name = data.split(",")[0]
|
|
url = data.split(",")[1]
|
|
noticeId = data.split(",")[2]
|
|
videoStatus = data.split(",")[3]
|
|
window.parent.gantDialog1(name, url,noticeId,videoStatus);
|
|
}
|
|
function closeMaxVideo(data) {
|
|
window.parent.closeMaxVideo();
|
|
}
|
|
function getMonitoringVideoUrl(data) {
|
|
console.log('getMonitoringVideoUrl', data)
|
|
var data01 = ''
|
|
var data02 = ''
|
|
console.log("333", data.split(",")[2])
|
|
data01 = data.split(",")[0]
|
|
data02 = data.split(",")[1]
|
|
console.log("4444", data01.split("(")[1])
|
|
console.log("55555", data02.split(")")[0])
|
|
window.parent.getMonitoringVideoUrlData(data01.split("(")[1], data02.split(")")[0], data.split(",")[2]);
|
|
}
|
|
function closeMonitoringVideo() {
|
|
window.parent.closeMonitoringVideo();
|
|
}
|
|
//隐藏设置底部展示按钮
|
|
function changeBottomChartsTwo(data) {
|
|
if (data == "1") {
|
|
window.parent.btnOpen()
|
|
// window.parent.openBottom()
|
|
} else if (data == "0") {
|
|
//隐藏按钮
|
|
window.parent.btnclose()
|
|
// window.parent.closeBottom()
|
|
}
|
|
}
|
|
//隐藏底部
|
|
function changeThreeTerminalSwitch(string) {
|
|
if (unity != null) {
|
|
unity.SendMessage("GameManager", 'ThreeTerminalSwitch', string);
|
|
}
|
|
|
|
}
|
|
// 质量管控的常规巡检
|
|
function getRoutineTourLog(id) {
|
|
console.log(id, '三维传过来的id');
|
|
window.parent.openControlPage(id)
|
|
}
|
|
// 关闭质量管控的常规巡检
|
|
function closeRoutineTourLog() {
|
|
window.parent.closeRoutineTourLog()
|
|
}
|
|
//报警视频弹窗打开
|
|
function SiteSafetyAlarm(val) {
|
|
console.log(val,'报警弹窗');
|
|
var data01 = ''
|
|
var data02 = ''
|
|
data01 = val.split(",")[0]
|
|
data02 = val.split(",")[1]
|
|
window.parent.SiteSafetyAlarm(data01.split("(")[1], data02.split(")")[0], val.split(",")[2],val.split(",")[3],val.split(",")[4])
|
|
}
|
|
//报警视频弹窗关闭
|
|
function clearSecurityAlarm(params) {
|
|
console.log(params,'报警视频关闭');
|
|
if (unity != null) {
|
|
unity.SendMessage("GameManager", 'ClearSecurityAlarm', params);
|
|
}
|
|
}
|
|
//报警视频弹窗关闭
|
|
function CloseSiteSafetyAlarm() {
|
|
window.parent.CloseSiteSafetyAlarm()
|
|
}
|
|
//环境传感器环境监测数据实时推送
|
|
function webSocketEnvironmentData(val) {
|
|
// console.log(val, '环境监测数据');
|
|
if (unity != null) {
|
|
unity.SendMessage("GameManager", 'WebSocketEnvironmentData', val);
|
|
}
|
|
}
|
|
//人员定位数据实时推送
|
|
function webSocketLocationData(val) {
|
|
console.log(val, '人员定位数据');
|
|
if (unity != null) {
|
|
unity.SendMessage("GameManager", 'WebSocketLocationData', val);
|
|
}
|
|
}
|
|
//人员考勤实时推送
|
|
function webSocketAttendanceView(val) {
|
|
console.log(val, '人员考勤数据');
|
|
if (unity != null) {
|
|
unity.SendMessage("GameManager", 'WebSocketAttendanceView', val);
|
|
}
|
|
}
|
|
//安全帽定位数据实时推送
|
|
function webSocketEquipmentStatus(val) {
|
|
console.log(val, '安全帽数据');
|
|
if (unity != null) {
|
|
unity.SendMessage("GameManager", 'WebSocketEquipmentStatus', val);
|
|
}
|
|
}
|
|
//当工地安全告警事件实时推送
|
|
function webSocketMonitoringAlarm(val) {
|
|
console.log(val, '工地安全告警数据');
|
|
if (unity != null) {
|
|
unity.SendMessage("GameManager", 'WebSocketMonitoringAlarm', val);
|
|
}
|
|
}
|
|
//安全帽定位推送
|
|
function webSocketSafetyHat(val) {
|
|
console.log(val, '安全帽定位推送');
|
|
if (unity != null) {
|
|
unity.SendMessage("GameManager", 'WebSocketSafetyHat', val);
|
|
}
|
|
}
|
|
//当日环境告警事件实时推送
|
|
function webSocketEnvironmentAlarm(val) {
|
|
console.log(val, '当日环境告警数据');
|
|
if (unity != null) {
|
|
unity.SendMessage("GameManager", 'WebSocketEnvironmentAlarm', val);
|
|
}
|
|
}
|
|
//安全帽视频
|
|
function getSmartHelmetVideoUrl(val) {
|
|
var data01 = ''
|
|
var data02 = ''
|
|
data01 = val.split(",")[0]
|
|
data02 = val.split(",")[1]
|
|
window.parent.getSmartHelmetVideoUrl(data01.split("(")[1], data02.split(")")[0], val.split(",")[2], val.split(",")[3])
|
|
}
|
|
function closeSmartHelmetVideoUrl() {
|
|
window.parent.closeSmartHelmetVideoUrl()
|
|
}
|
|
function successfulBroadcast(params) {
|
|
console.log(params,'现场播报数据');
|
|
if (unity != null) {
|
|
unity.SendMessage("GameManager", 'SuccessfulBroadcast', params);
|
|
}
|
|
}
|
|
//点击点位播放对应视频进度
|
|
function getVideoProgress(params) {
|
|
window.parent.getVideoProgress(params)
|
|
}
|
|
//设备状态实时推送
|
|
document.body.appendChild(script);
|
|
</script>
|
|
</body>
|
|
|
|
</html> |