init: 路桥一把手孪生 大屏看板 项目首次入库
This commit is contained in:
54
public/webWorker/modelRotation.js
Normal file
54
public/webWorker/modelRotation.js
Normal file
@@ -0,0 +1,54 @@
|
||||
let ObjectNames
|
||||
let Values
|
||||
let Dir
|
||||
let ModelRotateWorker
|
||||
let AnimObjectArray
|
||||
let ModelMotionAttributeWorker
|
||||
let RotationValue
|
||||
let RotateSpeed
|
||||
let Direction = 1
|
||||
|
||||
onmessage = function (e) {
|
||||
ObjectNames = e.data.ObjectNames
|
||||
Values = e.data.Values
|
||||
Dir = e.data.Dir
|
||||
ModelRotateWorker = e.data.ModelRotateWorker
|
||||
RotationValue = e.data.RotationValue
|
||||
RotateSpeed = e.data.RotateSpeed
|
||||
modelRotationWorker(e.data.ObjectNames, e.data.Dir, e.data.Values, e.data.RotationValue)
|
||||
}
|
||||
|
||||
function modelRotationWorker(objectNames, Dir, Values, rotationValue) {
|
||||
|
||||
let m = ModelRotateWorker
|
||||
Dir = parseInt(Dir)
|
||||
|
||||
if (m.state === Dir) return
|
||||
if (Dir === 0) {
|
||||
m.doAnimation = false
|
||||
m.state = 0
|
||||
self.close();
|
||||
clearInterval(m.myVarSetInterval)
|
||||
} else {
|
||||
clearInterval(m.myVarSetInterval)
|
||||
m.state = Dir
|
||||
if (Dir === 1) {
|
||||
Direction = Values / Math.abs(Values)
|
||||
m.doAnimation = true
|
||||
m.myVarSetInterval = setInterval(()=> {
|
||||
if(m.state === 1){
|
||||
rotationValue += RotateSpeed * Direction
|
||||
self.postMessage({
|
||||
objectNames: objectNames,
|
||||
rotation: rotationValue
|
||||
})
|
||||
} else {
|
||||
clearInterval(m.myVarSetInterval)
|
||||
// Worker 线程结束
|
||||
self.close();
|
||||
m.doAnimation = false
|
||||
}
|
||||
},500 / (3 * Math.abs(Values)))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user