Commit ccc4783e authored by lixiaoyi's avatar lixiaoyi

fix 模型重叠

parent 04bf9251
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="./css/index.css">
<link rel="stylesheet" href="./layui-v2.6.8/layui/css/layui.css">
<link rel="stylesheet" href="./css/index.css" />
<link rel="stylesheet" href="./layui-v2.6.8/layui/css/layui.css" />
</head>
<style>
#webgl-output{
#webgl-output {
position: absolute;
top: 0px;
height: 100%;
......@@ -17,48 +18,54 @@
/* width: 1100px; */
}
.dg{
.dg {
display: none;
}
body{
body {
position: relative;
}
.fileDragArea1{
.fileDragArea1 {
top: 0;
bottom: 0;
right: 0;
left: 0;
margin: auto;
color: #5BFCF4;
color: #5bfcf4;
width: 150px;
height: 40px;
}
.cyxPopup{
.cyxPopup {
z-index: 300;
position: fixed;
display: none;
width: 1280px;
height: 710px;
background: #191A1A;
background: #191a1a;
border-radius: 3px;
top: calc(50% - 350px);
left: calc(50% - 640px);
}
.cyxPopup_head{
.cyxPopup_head {
width: calc(100% - 20px);
padding-left: 20px;
line-height: 36px;
height: 36px;
background: #292A2A;
background: #292a2a;
color: #c9c9c9;
}
.Popupbody{
.Popupbody {
width: 600px;
padding: 0px 0;
height: calc(100% - 86px);
float: left;
}
.Popupbodyright{
.Popupbodyright {
float: left;
height: calc(100% - 76px);
width: calc(100% - 610px);
......@@ -67,36 +74,44 @@
position: relative;
top: 35px;
}
.toptable{
.toptable {
padding: 0 10px;
}
.th{
.th {
border: none !important;
background: #383a3a !important;
color: #D7DDE0 !important;
border-bottom:1px solid #000 !important;
color: #d7dde0 !important;
border-bottom: 1px solid #000 !important;
}
table{
table {
background: #252727 !important;
color: #949494 !important;
}
tbody{
tbody {
background: #252727 !important;
color: #949494 !important;
overflow: auto;
}
.select_tr{
.select_tr {
background: #3c3529;
color: #fff;
border-bottom: 1px solid rgb(183, 157, 113);
}
.layui-select-title>input{
.layui-select-title>input {
background-color: #343434 !important;
}
.select_tr>td>input{
.select_tr>td>input {
background-color: #000000;
}
input{
input {
width: 160px !important;
height: 25px !important;
background-color: #343434;
......@@ -104,30 +119,39 @@
border: 1px solid #343434 !important;
text-indent: 0.5em;
}
.select_tr>input{
.select_tr>input {
background-color: #000 !important;
}
.layui-unselect,.layui-select-title{
.layui-unselect,
.layui-select-title {
width: 160px !important;
}
.bottomtable{
.bottomtable {
padding: 0 10px;
}
.layui-anim{
.layui-anim {
background-color: #343434 !important;
border: 1px solid #343434 !important;
color: #fff;
}
.b{
.b {
position: absolute;
z-index: 99;
width: 90px;
height: 30px;
color: #8FE4E9;
color: #8fe4e9;
border-radius: 5px;
background-color: #0C1C38;
background-color: #0c1c38;
background: #007eaf;
background: linear-gradient(-45deg, #2284fb 50%, #0a0e92 60%, #2e59d4 70%);
background: linear-gradient(-45deg,
#2284fb 50%,
#0a0e92 60%,
#2e59d4 70%);
background-size: 600% 100%;
-webkit-animation: shine 20s infinite;
animation: shine 20s infinite;
......@@ -138,13 +162,16 @@
border: none;
cursor: pointer;
}
@-webkit-keyframes shine {
0% {
background-position-x: 400%;
}
50% {
background-position-x: 0%;
}
100% {
background-position-x: -400%;
}
......@@ -154,101 +181,117 @@
0% {
background-position-x: 400%;
}
50% {
background-position-x: 0%;
}
100% {
background-position-x: -400%;
}
}
.b1{
.b1 {
right: 10px;
top:10px;
top: 10px;
position: absolute !important;
}
.b2{
.b2 {
right: 120px;
top:10px;
top: 10px;
position: absolute !important;
}
.rad1{
.rad1 {
width: 50px !important;
height: 15px !important;
position: relative;
top: 3px;
}
.b3{
.b3 {
/* width: 50px !important;
height: 15px !important; */
position: absolute !important;
top: 10px;
right: 230px;
}
#canvas{
#canvas {
position: absolute;
z-index:999999;
top:180px;
z-index: 999999;
top: 180px;
left: 0;
/* display: none; */
}
#cover{
#cover {
position: fixed;
width: 100%;
height: 100%;
top: 0;
display: none;
background-color: rgba(0,0,0,0.3);
background-color: rgba(0, 0, 0, 0.3);
/* opacity: 0.3; */
z-index:99999999999999999999999999999999999999999;
z-index: 99999999999999999999999999999999999999999;
}
td{
padding: 9px 15px;
td {
padding: 9px 15px;
}
tr{
tr {
border-bottom: 1px solid #000;
}
.select_td{
border-bottom: 1px solid rgba(255,165,0,0.1);
background: rgba(255,165,0,0.1);
.select_td {
border-bottom: 1px solid rgba(255, 165, 0, 0.1);
background: rgba(255, 165, 0, 0.1);
}
/*滚动条整体样式*/
::-webkit-scrollbar {
/*高宽分别对应横竖滚动条的尺寸*/
width: 16px;
background-color: rgba(255, 255, 255, 0.1);
}
/*滚动条里面滑块*/
::-webkit-scrollbar-thumb {
background: #465880;
}
// 上箭头
/* // 上箭头 */
::-webkit-scrollbar-button:vertical:single-button:start {
background-image: url("~@/static/images/AllData/up.png");
background-size: 100%;
cursor: pointer;
}
// 下箭头
/* // 下箭头 */
::-webkit-scrollbar-button:vertical:single-button:end {
background-image: url("~@/static/images/AllData/down.png");
background-size: 100%;
cursor: pointer;
}
#radio1,#radio2,.w,.w1{
#radio1,
#radio2,
.w,
.w1 {
display: none;
}
dd:hover{
background:rgb(183, 157, 113) !important;
}
.layui-this{
background:rgb(183, 157, 113) !important;
dd:hover {
background: rgb(183, 157, 113) !important;
}
#i1{
.layui-this {
background: rgb(183, 157, 113) !important;
}
</style>
<body>
<!-- <input type="" name="" id="i1" value="123213213" />
<input type="" name="" id="i2" value="123213213" /> -->
......@@ -257,20 +300,22 @@
<button class="b b1" data-ripple="ripple">变量运行</button>
<button class="b b3" data-ripple="ripple">清空模型</button>
<div class="cyxPopup">
<div class="cyxPopup_head">
模型配置
</div>
<div class="Popupcontent" style="position: relative;width: 100%;height: 670px">
<div class="cyxPopup_head">模型配置</div>
<div class="Popupcontent" style="position: relative; width: 100%; height: 670px">
<div class="Popupbodyright"></div>
<div class="Popupbody">
<div style="padding-top:5px !important;color: white;padding:0 10px">模型组:<input checked="" value='rad1' name="sex1" id='radio1' class="rad1" type="radio"/><span class="w">打簧机</span><input value="rad2" name="sex1" id='radio2' class="rad1" type="radio" checked=""/><span class="w1">绕线机</span></div>
<div style="padding-top: 5px !important; color: white; padding: 0 10px">
模型组:<input checked="" value="rad1" name="sex1" id="radio1" class="rad1" type="radio" /><span
class="w">打簧机</span><input value="rad2" name="sex1" id="radio2" class="rad1" type="radio" checked="" /><span
class="w1">绕线机</span>
</div>
<div class="toptable">
<table class="layui-table" style="height: 300px;margin: 0;height: 30px;margin-top:10px;">
<table class="layui-table" style="height: 300px; margin: 0; height: 30px; margin-top: 10px">
<colgroup>
<col style="width: 100px;">
<col style="width: 130px;">
<col style="width: 150px;">
<col>
<col style="width: 100px" />
<col style="width: 130px" />
<col style="width: 150px" />
<col />
</colgroup>
<thead>
<tr>
......@@ -281,33 +326,35 @@
</tr>
</thead>
</table>
<div style="height: 270px;overflow: auto;">
<div style="height: 270px; overflow: auto">
<table>
<colgroup>
<col style="width: 110px;">
<col style="width: 150px;">
<col style="width: 170px;">
<col>
<col style="width: 110px" />
<col style="width: 150px" />
<col style="width: 170px" />
<col />
</colgroup>
<tbody class="ontablebody">
</tbody>
<tbody class="ontablebody"></tbody>
</table>
</div>
</div>
<div class="searchlist" style="padding: 10px;height: 25px;line-height: 25px;">
<span style="float: left;color: #fff;margin-right:10px ;">变量类型</span>
<div class="variabletype" style="width: 100px;float: left;height: 25px;margin-right: 70px;">
<div class='layui-form'>
<select name="city" lay-verify="" lay-filrer="test" id='select' value="">
<div class="searchlist" style="padding: 10px; height: 25px; line-height: 25px">
<span style="float: left; color: #fff; margin-right: 10px">变量类型</span>
<div class="variabletype" style="
width: 100px;
float: left;
height: 25px;
margin-right: 70px;
">
<div class="layui-form">
<select name="city" lay-verify="" lay-filrer="test" id="select" value="">
<option value="不限" selected>不限</option>
<option value="二进制变量">二进制变量</option>
<option value="有符号8位整型" >有符号8位整型</option>
<option value="有符号8位整型">有符号8位整型</option>
<option value="无符号8位整型">无符号8位整型</option>
<option value="有符号16位整型" >有符号16位整型</option>
<option value="有符号16位整型">有符号16位整型</option>
<option value="无符号16位整型">无符号16位整型</option>
<option value="有符号32位整型" >有符号32位整型</option>
<option value="有符号32位整型">有符号32位整型</option>
<option value="无符号32位整型">无符号32位整型</option>
<option value="有符号64位整型">有符号64位整型</option>
<option value="无符号64位整型">无符号64位整型</option>
......@@ -319,19 +366,29 @@
</select>
</div>
</div>
<span style="color: #fff;float: left;margin-right: 10px;">变量名称</span>
<div class="variable" style="width: 100px;float: left;">
<div class='layui-form'>
<input class="searchinput" value='' placeholder="请输入变量名" style="text-indent: 0.5em;"/>
<span style="color: #fff; float: left; margin-right: 10px">变量名称</span>
<div class="variable" style="width: 100px; float: left">
<div class="layui-form">
<input class="searchinput" value="" placeholder="请输入变量名" style="text-indent: 0.5em" />
</div>
</div>
<button class="search" style="cursor: pointer;border: 1px solid #3c3529;background-color: #3c3529;width:60px;color: rgb(183, 157, 113);float: right;height: 25px;">查询</button>
<button class="search" style="
cursor: pointer;
border: 1px solid #3c3529;
background-color: #3c3529;
width: 60px;
color: rgb(183, 157, 113);
float: right;
height: 25px;
">
查询
</button>
</div>
<div class="bottomtable">
<table class="layui-table" style="height: 300px;margin: 0;height: 30px;margin-top:10px;">
<table class="layui-table" style="height: 300px; margin: 0; height: 30px; margin-top: 10px">
<colgroup>
<col style="width: 300px;">
<col style="width: 300px;">
<col style="width: 300px" />
<col style="width: 300px" />
</colgroup>
<thead>
<tr>
......@@ -340,36 +397,58 @@
</tr>
</thead>
</table>
<div style="height: 190px;overflow: auto;">
<table style="">
<div style="height: 190px; overflow: auto">
<table>
<colgroup>
<col style="width: 340px;">
<col style="width: 310px;">
<col style="width: 340px" />
<col style="width: 310px" />
</colgroup>
<tbody class="twotablebody">
</tbody>
<tbody class="twotablebody"></tbody>
</table>
</div>
</div>
<button class="cancel" style="cursor: pointer;position: absolute;bottom: 10px;border-radius: 5px;right: 130px;width:100px;height:26px;background-color: #2c2d2d;border: 1px solid rgb(86,87,87);color:#fff">取消</button>
<button class="confim" style="cursor: pointer;position: absolute;bottom: 10px;border-radius: 5px;right: 20px;width:100px;height:26px;background-color: #3c3529;color:rgb(183,157,113);border: 1px solid rgb(183,157,113);">确定</button>
<button class="cancel" style="
cursor: pointer;
position: absolute;
bottom: 10px;
border-radius: 5px;
right: 130px;
width: 100px;
height: 26px;
background-color: #2c2d2d;
border: 1px solid rgb(86, 87, 87);
color: #fff;
">
取消
</button>
<button class="confim" style="
cursor: pointer;
position: absolute;
bottom: 10px;
border-radius: 5px;
right: 20px;
width: 100px;
height: 26px;
background-color: #3c3529;
color: rgb(183, 157, 113);
border: 1px solid rgb(183, 157, 113);
">
确定
</button>
</div>
<canvas id="canvas" width="700px" height="300px">浏览器不支持canvas</canvas>
<canvas id="canvas" width="700px" height="300px" style="display: none">浏览器不支持canvas</canvas>
</div>
</div>
<div id="fileDragArea" class="fileDragArea1" style="position: absolute;z-index: 1000;" class="upload-default">拖拽文件夹导入模型</div>
<div id="fileDragArea" class="fileDragArea1" style="position: absolute; z-index: 1000" class="upload-default">
拖拽文件夹导入模型
</div>
<div class="container">
<!-- <div class="header" >
<div>header 部分</div>
</div> -->
<div class="main" >
<div class="main_header" >实时生产预警和安全预警</div>
<div class="main">
<div class="main_header">实时生产预警和安全预警</div>
<div id="webgl-output"></div>
<!-- 左右两侧内容 -->
<div class="view-btn view-btn_left btn-active">
......@@ -377,9 +456,9 @@
</div>
<div class="view view_left">
<div class="item">
<div class="item_header" >
<img class="item_img" src="./imgs/title@2x.png" alt="">
<span class="item_title" >数值显示</span>
<div class="item_header">
<img class="item_img" src="./imgs/title@2x.png" alt="" />
<span class="item_title">数值显示</span>
</div>
<div class="item_wrap item_val_wrap">
<div class="item_wrap_content">
......@@ -403,17 +482,17 @@
</div>
</div>
<div class="item">
<div class="item_header" >
<img class="item_img" src="./imgs/title@2x.png" alt="">
<span class="item_title" >电机功率值</span>
<div class="item_header">
<img class="item_img" src="./imgs/title@2x.png" alt="" />
<span class="item_title">电机功率值</span>
</div>
<div class="item_wrap" id="act_torque"></div>
</div>
<div class="item">
<div class="item_header" >
<img class="item_img" src="./imgs/title@2x.png" alt="">
<span class="item_title" >功率趋势</span>
<div class="item_header">
<img class="item_img" src="./imgs/title@2x.png" alt="" />
<span class="item_title">功率趋势</span>
</div>
<div class="item_wrap" id="torque"></div>
</div>
......@@ -423,27 +502,29 @@
</div>
<div class="view view_right">
<div class="item">
<div class="item_header" >
<img class="item_img" src="./imgs/title@2x.png" alt="">
<span class="item_title" >转矩趋势</span>
<div class="item_header">
<img class="item_img" src="./imgs/title@2x.png" alt="" />
<span class="item_title">转矩趋势</span>
</div>
<div class="item_wrap" id="right1"></div>
</div>
<div class="item">
<div class="item_header" >
<img class="item_img" src="./imgs/title@2x.png" alt="">
<span class="item_title" >电机转矩值</span>
<div class="item_header">
<img class="item_img" src="./imgs/title@2x.png" alt="" />
<span class="item_title">电机转矩值</span>
</div>
<div class="item_wrap" id="right2"></div>
</div>
<div class="item">
<div class="item_header item_alarm" >
<div class="item_title_alarm" >报警信息</div>
<div class="item_subTitle" >当前报警数:<span class="red" id="alarmData" ></span></div>
<div class="item_header item_alarm">
<div class="item_title_alarm">报警信息</div>
<div class="item_subTitle">
当前报警数:<span class="red" id="alarmData"></span>
</div>
<div class="item_wrap item_alarm_wrap" id="alarm" >
</div>
<div class="item_wrap item_alarm_wrap" id="alarm">
<!-- 渲染报警信息 -->
<!-- <div class="list">
<span>2021-11-11 12:36:30 越限报警越限报警...</span>
......@@ -455,7 +536,6 @@
<div class="list list_red">
<span>2021-11-11 12:36:30 越限报警越限报警...</span>
</div> -->
</div>
</div>
</div>
......@@ -468,46 +548,48 @@
<script src="./js/layerjs/layer.js"></script>
<script src="./layui-v2.6.8/layui/layui.js"></script>
<script src="./ripple.js"></script>
<script >
layui.use('form', function(){
<script>
layui.use("form", function () {
var form = layui.form;
//监听提交
form.on('submit(formDemo)', function(data){
form.on("submit(formDemo)", function (data) {
layer.msg(JSON.stringify(data.field));
return false;
});
});
var onetable = [{
clipAction:'',
variable:'配置变量',
value:'',
oldvalue:'',
animation:'图片数量',
name:'图片'
}]
var twotable = []
var oldvararr = []
$(".view-btn_left").click(function(){
let viewDis = $(".view_left").css('display')
$(".view_left").css('display', viewDis === 'none' ? 'flex' : 'none')
$(".view-btn_left").toggleClass('btn-active')
})
$(".view-btn_right").click(function(){
let viewDis = $(".view_right").css('display')
$(".view_right").css('display', viewDis === 'none' ? 'flex' : 'none')
$(".view-btn_right").toggleClass('btn-active')
})
</script>
var onetable = [
{
clipAction: "",
variable: "配置变量",
value: "",
oldvalue: "",
animation: "图片数量",
name: "图片",
},
];
var twotable = [];
var oldvararr = [];
$(".view-btn_left").click(function () {
let viewDis = $(".view_left").css("display");
$(".view_left").css("display", viewDis === "none" ? "flex" : "none");
$(".view-btn_left").toggleClass("btn-active");
});
$(".view-btn_right").click(function () {
let viewDis = $(".view_right").css("display");
$(".view_right").css("display", viewDis === "none" ? "flex" : "none");
$(".view-btn_right").toggleClass("btn-active");
});
</script>
<script src="./new_file.js"></script>
<script> new Ripple({
opacity : 0.6, //水波纹透明度
speed : 1, //水波纹扩散速度
bgColor : "#fff", //水波纹颜色
cursor : true //是否显示手型指针
})</script>
<script>
new Ripple({
opacity: 0.6, //水波纹透明度
speed: 1, //水波纹扩散速度
bgColor: "#fff", //水波纹颜色
cursor: true, //是否显示手型指针
});
</script>
<script src="./js/index.js"></script>
<script type="module" src="./main.js"></script>
<script type="module" src="./main.js">
</script>
</html>
\ No newline at end of file
......@@ -32,6 +32,7 @@ renderer.outputEncoding = THREE.sRGBEncoding;
container.appendChild(renderer.domElement);
const pmremGenerator = new THREE.PMREMGenerator(renderer);
const scene = new THREE.Scene();
window.scene = scene
scene.background = new THREE.Color(0x0C1C38);
scene.environment = pmremGenerator.fromScene(new RoomEnvironment(), 0.04).texture;
var select = '没有选中' //判断table有没有选中变量
......@@ -47,12 +48,13 @@ const controls = new OrbitControls(camera, renderer.domElement);
controls.target.set(0, 0.5, 0);
controls.update();
controls.enablePan = true;
controls.enableDamping = true;
// controls.enableDamping = true;
const dracoLoader = new DRACOLoader();
var mixerarr = []
dracoLoader.setDecoderPath('js/libs/draco/gltf/');
var variablearr = [] //选中变量的组合
var oldvariablearr = [] //变量旧值的组合
let needUpdateModel = false; // 是否需要更新模型
// 打簧机动画下标
var numarr = {
num0: 0,
......@@ -94,10 +96,7 @@ function updateEnvironment() {
scene.environment = envMap;
});
}
if (localStorage.getItem('moxi1') || localStorage.getItem('moxi2')) {
document.getElementById('fileDragArea').innerText = '模型载入中。。。'
}
if ($('.b1')[0].innerText == '变量运行') {
if (localStorage.getItem('moxi1') || localStorage.getItem('moxi2') || $('.b1')[0].innerText == '变量运行') {
document.getElementById('fileDragArea').innerText = '模型载入中。。。'
}
//清空模型
......@@ -130,7 +129,6 @@ $('.b1')[0].onclick = function() {
group3.visible = false
group2.visible = false
$('.b1')[0].innerText = '整体运行'
}
if (localStorage.getItem('moxi2')) {
group1.visible = true
......@@ -138,6 +136,7 @@ $('.b1')[0].onclick = function() {
if (localStorage.getItem('moxi1')) {
group.visible = true
}
}
if (group1.visible !== true && group.visible !== true) {
document.getElementById('fileDragArea').innerText == '拖拽文件夹导入模型'
document.getElementById('fileDragArea').style.display = 'block'
......@@ -154,7 +153,6 @@ $('.b1')[0].onclick = function() {
group.visible = false
} else {
console.log("asdsadas")
group3.visible = false
group2.visible = false
$('.b1')[0].innerText = '整体运行'
......@@ -170,24 +168,24 @@ $('.b1')[0].onclick = function() {
}
//模型配置
$('.b2')[0].onclick = function() {
needUpdateModel = true
scene1.clear()
$('.twotablebody').empty()
$.ajax({
type: "POST",
url: baseUrl + "/Base/GetSCMSTags",
dataType: "json",
contentType: "application/json",
success: function(res) {
console.log(res.data)
threetable = res.data
threetable.forEach((item) => {
let tr = `<tr TagName='${item.TagName}'><td>${item.TagName}</td><td>${item.TagType}</td></tr>`
$('.twotablebody').append(tr)
})
$('.twotablebody tr').click(async function() {
console.log("select", select)
$('.twotablebody tr').click(async function() {
if (select !== '没有选中') {
if ($('#radio2').prop('checked')) {
console.log("asdasdasdsadsadasdsadsad")
twotable[select].variable = $(this).attr('TagName')
$($('.ontablebody').find('tr')[select]).find('td')[2].innerText = $(this).attr('TagName')
} else {
......@@ -201,7 +199,7 @@ $('.b2')[0].onclick = function() {
},
})
if (localStorage.getItem('moxi1') || localStorage.getItem('moxi2')) {
console.log("开始时零零商量商量商量商量")
if (document.getElementById('fileDragArea').innerText == '模型载入中。。。') {
alert('请导入模型')
$('.w1').hide()
......@@ -211,6 +209,7 @@ $('.b2')[0].onclick = function() {
return
}
$('.cyxPopup')[0].style.display = 'block'
scene1.clear()
clearInterval(mxtime1)
scene1.traverse((child) => {
if (child.material) {
......@@ -248,13 +247,15 @@ $('.b2')[0].onclick = function() {
onetable[$(this).attr('index')].value = $(this).val()
})
$('.ontablebody tr').click(async function() {
if($(this).hasClass('select_tr')){
return
}
select = $(this).attr('index')
$(this).parent().children().removeClass("select_tr")
$(this).addClass('select_tr')
// console.log($(this).children())
let that = this
initvalue = 0
$('#canvas').show()
// $('#canvas').show()
for (let i1 in arr) {
await promise1(arr[i1], $(this).attr('key'), $(this).attr('index'), i1)
}
......@@ -282,13 +283,16 @@ $('.b2')[0].onclick = function() {
onetable[$(this).attr('index')].value = $(this).val()
})
$('.ontablebody tr').click(async function() {
if($(this).hasClass('select_tr')){
return
}
select = $(this).attr('index')
$(this).parent().children().removeClass("select_tr")
$(this).addClass('select_tr')
// console.log($(this).children())
let that = this
initvalue = 0
$('#canvas').show()
// $('#canvas').show()
for (let i1 in arr) {
await promise1(arr[i1], $(this).attr('key'), $(this).attr('index'), i1)
}
......@@ -314,13 +318,16 @@ $('.b2')[0].onclick = function() {
twotable[$(this).attr('index')].value = $(this).val()
})
$('.ontablebody tr').click(async function() {
if($(this).hasClass('select_tr')){
return
}
select = $(this).attr('index')
$(this).parent().children().removeClass("select_tr")
$(this).addClass('select_tr')
// console.log($(this).children())
let that = this
initvalue = 0
$('#canvas').show()
// $('#canvas').show()
for (let i1 in arr1) {
await promise3(arr1[i1], $(this).attr('key'), $(this).attr('index'), i1)
......@@ -542,6 +549,7 @@ function animate() {
})
} else {
console.log("111")
mixerarr.forEach((item) => {
item.mixer1.update(delta)
})
......@@ -573,7 +581,6 @@ function mxtime() {
contentType: "application/json",
data: JSON.stringify(variablearr),
success: function(res) {
console.log(oldvariablearr)
if (res.data.length !== 0) {
res.data.forEach((item) => {
onetable.forEach((item1) => {
......@@ -643,6 +650,9 @@ dragDrop.addEventListener("drop", function(e) {
e.stopPropagation();
e.preventDefault();
//取消鼠标经过样式
if($('.b1')[0].innerText === '变量运行'){
return
}
$(this).removeClass("upload_drag_hover");
//获取文件列表对象和文件相对路径
var files = e.target.files || e.dataTransfer.files;
......@@ -713,6 +723,7 @@ function animate1() {
function promise1(a, b, c, d) {
return new Promise((resolve, reject) => {
loader.load('models/gltf/打簧机/打簧机分模型/' + a + '.glb', function(gltf) {
if(scene1.children.length !== arr.length){
if (a == 'a') {
scene1.traverse((child) => {
if (child.material) {
......@@ -730,8 +741,13 @@ function promise1(a, b, c, d) {
const model1 = gltf.scene
model1.scale.set(2.6, 1.3, 2.6)
scene1.add(model1)
}
// const model1 = gltf.scene
// model1.scale.set(2.6, 1.3, 2.6)
// scene1.add(model1)
if (a == onetable[c].name) {
mixer1 = new THREE.AnimationMixer(model1);
mixer1 = new THREE.AnimationMixer(scene1.children[d]);
// mixer1 = new THREE.AnimationMixer(model1);
mixer1.clipAction(gltf.animations[b]).play()
animate1()
}
......@@ -739,7 +755,7 @@ function promise1(a, b, c, d) {
}, async (xhr) => {
if ((xhr.loaded / xhr.total * 100) * (d / (arr.length - 1)) > initvalue) {
initvalue = (xhr.loaded / xhr.total * 100) * (d / (arr.length - 1))
await init(initvalue)
await init(initvalue, scene1.children.length !== arr.length)
}
})
})
......@@ -748,6 +764,7 @@ function promise1(a, b, c, d) {
function promise3(a, b, c, d) {
return new Promise((resolve, reject) => {
loader.load('models/gltf/绕线机/绕线机分模型/' + a + '.glb', function(gltf) {
if(scene1.children.length !== arr1.length){
if (a == 'aa') {
scene1.traverse((child) => {
if (child.material) {
......@@ -763,8 +780,9 @@ function promise3(a, b, c, d) {
const model1 = gltf.scene
model1.scale.set(2.6, 1.3, 2.6)
scene1.add(model1)
}
if (a == twotable[c].name) {
mixer1 = new THREE.AnimationMixer(model1);
mixer1 = new THREE.AnimationMixer(scene1.children[d]);
mixer1.clipAction(gltf.animations[b]).play()
animate1()
}
......@@ -772,7 +790,7 @@ function promise3(a, b, c, d) {
}, async (xhr) => {
if ((xhr.loaded / xhr.total * 100) * (d / (arr1.length - 1)) > initvalue) {
initvalue = (xhr.loaded / xhr.total * 100) * (d / (arr1.length - 1))
await init(initvalue)
await init(initvalue, scene1.children.length !== arr1.length)
}
})
})
......@@ -799,7 +817,7 @@ function allpromise(a, c) {
animations
})
group2.add(model)
if (localStorage.getItem('moxi1')) {
if (localStorage.getItem('moxi1') && localStorage.getItem('b1') == '整体运行') {
group2.visible = false
} else if ($('.b1')[0].innerText == '变量运行') {
group2.visible = true
......@@ -921,7 +939,7 @@ function promise(a, c) {
})
}
group.add(model)
if (localStorage.getItem('moxi1')) {
if (localStorage.getItem('moxi1') && localStorage.getItem('b1') === '整体运行') {
group.visible = true
} else {
group.visible = false
......@@ -1008,12 +1026,15 @@ function promise2(a, c) {
twotable[$(this).attr('index')].value = $(this).val()
})
$('.ontablebody tr').click(async function() {
if($(this).hasClass('select_tr')){
return
}
select = $(this).attr('index')
$(this).parent().children().removeClass("select_tr")
$(this).addClass('select_tr')
let that = this
initvalue = 0
$('#canvas').show()
// $('#canvas').show()
})
group1.add(model)
if (localStorage.getItem('moxi2')) {
......@@ -1052,12 +1073,15 @@ $('input[type=radio][name=sex1]').change(function() {
onetable[$(this).attr('index')].value = $(this).val()
})
$('.ontablebody tr').click(async function() {
if($(this).hasClass('select_tr')){
return
}
select = $(this).attr('index')
$(this).parent().children().removeClass("select_tr")
$(this).addClass('select_tr')
let that = this
initvalue = 0
$('#canvas').show()
// $('#canvas').show()
for (let i1 in arr) {
await promise1(arr[i1], $(this).attr('key'), $(this).attr('index'), i1)
}
......@@ -1078,12 +1102,15 @@ $('input[type=radio][name=sex1]').change(function() {
twotable[$(this).attr('index')].value = $(this).val()
})
$('.ontablebody tr').click(async function() {
if($(this).hasClass('select_tr')){
return
}
select = $(this).attr('index')
$(this).parent().children().removeClass("select_tr")
$(this).addClass('select_tr')
let that = this
initvalue = 0
$('#canvas').show()
// $('#canvas').show()
for (let i1 in arr1) {
await promise3(arr1[i1], $(this).attr('key'), $(this).attr('index'), i1)
......@@ -1103,6 +1130,7 @@ renderer1.outputEncoding = THREE.sRGBEncoding;
container1.appendChild(renderer1.domElement);
const pmremGenerator1 = new THREE.PMREMGenerator(renderer1);
const scene1 = new THREE.Scene();
window.scenen1 = scene1
scene1.background = new THREE.Color(0x0C1C38);
scene1.environment = pmremGenerator1.fromScene(new RoomEnvironment(), 0.04).texture;
const camera1 = new THREE.PerspectiveCamera(40, window.innerWidth / window.innerHeight, 1, 100);
......@@ -1111,7 +1139,7 @@ const controls1 = new OrbitControls(camera1, renderer1.domElement);
controls1.target.set(0, 0.5, 0);
controls1.update();
controls1.enablePan = true;
controls1.enableDamping = true;
// controls1.enableDamping = true;
$('.cancel')[0].onclick = function() {
$('.cyxPopup').hide()
mxtime()
......@@ -1163,6 +1191,7 @@ $('.search')[0].onclick = function() {
})
console.log(select)
$('.twotablebody tr').click(async function() {
if (select !== '没有选中') {
if ($('#radio2').prop('checked')) {
......@@ -1223,6 +1252,7 @@ function getold() {
}
function tb(a, b) {
console.log(a, b)
a.forEach((item) => {
if (item.name == '图片' && item.variable !== '配置变量') {
variablearr.push(item.variable)
......
//判断是否支持canvaas
function isSupportCanvas(canvas) {
//判断是否支持canvaas
function isSupportCanvas(canvas) {
return !!(canvas.getContext && canvas.getContext("2d"));
}
}
//requestAnimationFrame会自动使用最优的帧率进行渲染
function setupRAF() {
//requestAnimationFrame会自动使用最优的帧率进行渲染
function setupRAF() {
window.lastTime = 0;
//兼容各个浏览器,Internet Explorer11、Google Chrome(Microsoft Edge)、Mozilla Firefox、Opera
var vendors = ["ms", "moz", "webkit", "o"];
for(var i=0; i<vendors.length; i++) {
for (var i = 0; i < vendors.length; i++) {
window.requestAnimationFrame = window[vendors[i] + "RequestAnimationFrame"];
window.cancelAnimationFrame = window[vendors[i] + "CancelAnimationFrame"] || window[vendors[i] + "CancelRequestAnimationFrame"];
window.cancelAnimationFrame =
window[vendors[i] + "CancelAnimationFrame"] ||
window[vendors[i] + "CancelRequestAnimationFrame"];
//测试浏览器支持哪一张
if(window.requestAnimationFrame) {
if (window.requestAnimationFrame) {
console.log(vendors[i] + "requestAnimationFrame");
}
if(window[vendors[i] + "CancelAnimationFrame"]) {
if (window[vendors[i] + "CancelAnimationFrame"]) {
console.log(vendors[i] + "CancelAnimationFrame");
}
if(window[vendors[i] + "CancelRequestAnimationFrame"]) {
if (window[vendors[i] + "CancelRequestAnimationFrame"]) {
console.log(vendors[i] + "CancelRequestAnimationFrame");
}
}
//回退机制
if(!window.requestAnimationFrame) {
window.requestAnimationFrame = function(callback, element) {
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = function (callback, element) {
var currentTime = new Date().getTime();
var timeToCall = Math.max(0, 16-(currentTime-window.lastTime));
var timeToCall = Math.max(0, 16 - (currentTime - window.lastTime));
var callTime = currentTime + timeToCall;
var id = window.setTimeout(function() {
var id = window.setTimeout(function () {
callback(callTime);
}, timeToCall);
window.lastTime = callTime;
......@@ -41,42 +42,42 @@
}
//回退机制
if(!window.cancelAnimationFrame) {
window.cancelAnimationFrame = function(id) {
if (!window.cancelAnimationFrame) {
window.cancelAnimationFrame = function (id) {
clearTimeout(id);
};
}
}
}
}
//在[min, max]中随机取一个数
function rand(min, max) {
//在[min, max]中随机取一个数
function rand(min, max) {
return Math.random() * (max - min + 1) + min;
}
}
//判断两碰撞盒是否相交
function isHit(x1, y1, w1, h1, x2, y2, w2, h2) {
return !( x1 + w1 < x2 || x2 + w2 < x1 || y1 + h1 < h2 || y2 + h2 < h1);
}
//判断两碰撞盒是否相交
function isHit(x1, y1, w1, h1, x2, y2, w2, h2) {
return !(x1 + w1 < x2 || x2 + w2 < x1 || y1 + h1 < h2 || y2 + h2 < h1);
}
//判断点是否在指定区域内
function isInRect(x, y, rx, ry, rw, rh) {
//判断点是否在指定区域内
function isInRect(x, y, rx, ry, rw, rh) {
return !(x < rx || x > rx + rw || y < ry || y > ry + rh);
}
}
//将数限制在某个范围之内
function limit(value, min, max) {
if(value < min) {
//将数限制在某个范围之内
function limit(value, min, max) {
if (value < min) {
return min;
} else if(value > max) {
} else if (value > max) {
return max;
}
return value;
}
}
var CanvasController = function(canvas) {
var CanvasController = function (canvas) {
var ctx = canvas.getContext("2d");
//进度条对象
var Loader = function(data=0,max=30) {
var Loader = function (data = 0, max = 30) {
//进度条宽度
this.width = canvas.width - 80;
//进度条高度
......@@ -86,7 +87,11 @@
//进度条Y坐标
this.y = (canvas.height - this.height) / 2;
//进度条当前值
this.value = Number(localStorage.getItem("value"))>Number(localStorage.getItem("value1"))?Number(localStorage.getItem("value")):Number(localStorage.getItem("value1"));
this.value =
Number(localStorage.getItem("value")) >
Number(localStorage.getItem("value1"))
? Number(localStorage.getItem("value"))
: Number(localStorage.getItem("value1"));
//进度条最大值
this.maxValue = max;
//进度条更新速度
......@@ -100,117 +105,132 @@
this.hueEnd = 360;
//获取当前值对应的X坐标
this.currentPosX = function() {
return this.x + this.width * this.value / 100;
}
console.log('asdsad')
this.currentPosX = function () {
return this.x + (this.width * this.value) / 100;
};
console.log("asdsad");
//更新进度条
this.update = function(a,b,c) {
$('#canvas').show()
$('#cover').show()
this.update = function (a, b, c) {
$("#canvas").show();
$("#cover").show();
this.value += this.speed;
localStorage.setItem('value1',this.value)
if(this.value >= 100){
this.value = 100
c()
$('#canvas').hide()
$('#cover').hide()
localStorage.setItem('value',0)
localStorage.setItem('value1',0)
}else if(this.value > this.maxValue) {
localStorage.setItem("value1", this.value);
if (this.value >= 100) {
this.value = 100;
c();
$("#canvas").hide();
$("#cover").hide();
localStorage.setItem("value", 0);
localStorage.setItem("value1", 0);
} else if (this.value > this.maxValue) {
this.value = this.maxValue;
localStorage.setItem('value',this.maxValue)
c()
}
localStorage.setItem("value", this.maxValue);
c();
}
};
//渲染进度条
this.render = function() {
this.render = function () {
ctx.globalCompositeOperation = "source-over";
var currentWidth = this.width * this.value / 100;
this.hue = this.hueStart + (this.hueEnd - this.hueStart) * this.value / 100;
var currentWidth = (this.width * this.value) / 100;
this.hue =
this.hueStart + ((this.hueEnd - this.hueStart) * this.value) / 100;
//ctx.fillStyle = "hsl(" + this.hue + ", 100%, 40%)";
var linearGradient = ctx.createLinearGradient(this.x, this.y, this.x + currentWidth, this.y);
var linearGradient = ctx.createLinearGradient(
this.x,
this.y,
this.x + currentWidth,
this.y
);
linearGradient.addColorStop(0, "hsl(" + this.hueStart + ", 100%, 40%)");
linearGradient.addColorStop(1, "hsl(" + this.hue + ", 100%, 40%)");
ctx.fillStyle = linearGradient;
ctx.fillRect(this.x, this.y, currentWidth, this.height);
ctx.fillStyle = this.lighterColor;
ctx.globalCompositeOperation = "lighter";
ctx.fillRect(this.x, this.y, currentWidth, this.height/2);
}
}
ctx.fillRect(this.x, this.y, currentWidth, this.height / 2);
};
};
//单个粒子对象
var Particle = function(x, y, hue, minX, maxX) {
var Particle = function (x, y, hue, minX, maxX) {
//粒子的X坐标
this.x = x;
//粒子的Y坐标
this.y = y;
//粒子的宽度
this.width = rand(1,3);
this.width = rand(1, 3);
//粒子的高度
this.height = rand(1,2);
this.height = rand(1, 2);
//粒子的HSL颜色的hue分量
this.hue = limit(hue + rand(-15,15), 0, 360);
this.hue = limit(hue + rand(-15, 15), 0, 360);
//粒子在X方向上的速度
this.velocityX = rand(-1,1);
this.velocityX = rand(-1, 1);
//粒子在Y方向上的速度
this.velocityY = rand(-30,-20);
this.velocityY = rand(-30, -20);
//粒子在X方向上的加速度
this.accelerationX = -.5;
this.accelerationX = -0.5;
//粒子在Y方向上的加速度
this.accelerationY = 4;
//单位时间
this.unitTime = .2;
this.unitTime = 0.2;
//更新粒子位置
this.update = function() {
this.x += (this.velocityX * this.unitTime);
this.y += (this.velocityY * this.unitTime);
this.velocityX += (this.accelerationX * this.unitTime * rand(-1,1));
this.velocityY += (this.accelerationY * this.unitTime);
}
this.update = function () {
this.x += this.velocityX * this.unitTime;
this.y += this.velocityY * this.unitTime;
this.velocityX += this.accelerationX * this.unitTime * rand(-1, 1);
this.velocityY += this.accelerationY * this.unitTime;
};
//渲染粒子
this.render = function() {
ctx.fillStyle = "hsl(" + this.hue + ", 100%, 40%)"
this.render = function () {
ctx.fillStyle = "hsl(" + this.hue + ", 100%, 40%)";
ctx.globalCompositeOperation = "source-over";
ctx.fillRect(this.x, this.y, this.width, this.height);
}
}
};
};
//所有粒子效果的对象
var Particles = function(minX, maxX) {
var Particles = function (minX, maxX) {
//存放生成的所有粒子对象
this.values = [];
//粒子生成速率
this.rate = 3;
//生成粒子
this.generate = function(x, y, hue) {
for(var i=0; i<this.rate; i++) {
this.generate = function (x, y, hue) {
for (var i = 0; i < this.rate; i++) {
this.values.push(new Particle(x, y, hue, minX, maxX));
}
}
};
//更新进度值
this.update = function() {
for(var i = this.values.length-1; i >= 0; i--) {
// 更新进度值
this.update = function () {
for (var i = this.values.length - 1; i >= 0; i--) {
this.values[i].update();
if(!isInRect(this.values[i].x, this.values[i].y, 0, 0, canvas.width, canvas.height)) {
if (
!isInRect(
this.values[i].x,
this.values[i].y,
0,
0,
canvas.width,
canvas.height
)
) {
this.values.splice(i, 1);
}
}
}
};
//渲染进度条
this.render = function() {
for(var i =0; i<this.values.length; i++) {
this.render = function () {
for (var i = 0; i < this.values.length; i++) {
this.values[i].render();
}
}
}
};
};
//清空画布
function clearCanvas() {
......@@ -220,32 +240,40 @@
}
//初始化函数
this.init = function(data=0,max,resolve) {
this.init = function (data = 0, needLoad, max, resolve) {
console.log("----------------------------------------",data, needLoad, max)
var loader = new Loader();
console.log(loader.x)
console.log(loader.currentPosX()-3, loader.y + loader.height/2, loader.hue)
console.log(loader.x);
console.log(
loader.currentPosX() - 3,
loader.y + loader.height / 2,
loader.hue
);
var particles = new Particles(loader.x, loader.x + loader.width);
loader.maxValue = data
var loop = function(data,max) {
loader.maxValue = data;
var loop = function (data, max) {
requestAnimationFrame(loop, canvas);
clearCanvas();
loader.update(data,max,resolve);
if(needLoad){
loader.update(data, max, resolve);
loader.render();
particles.generate(loader.currentPosX()-3, loader.y + loader.height/2, loader.hue);
particles.generate(
loader.currentPosX() - 3,
loader.y + loader.height / 2,
loader.hue
);
particles.update();
particles.render();
}
};
loop();
}
}
var canvas = document.getElementById("canvas");
var canvasController = new CanvasController(canvas);
localStorage.setItem("value",0)
function init(data,max) {
};
};
var canvas = document.getElementById("canvas");
var canvasController = new CanvasController(canvas);
localStorage.setItem("value", 0);
function init(data, needLoad, max) {
return new Promise((resolve, reject) => {
canvasController.init(data,max,resolve);
})
}
\ No newline at end of file
canvasController.init(data, needLoad, max, resolve);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment