init: 广西机电数字孪生看板项目首次入库
This commit is contained in:
58
src/components/DMT/libs/DmtControl.js
Normal file
58
src/components/DMT/libs/DmtControl.js
Normal file
@@ -0,0 +1,58 @@
|
||||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'
|
||||
const _changeEvent = { type: 'change' }
|
||||
class DmtControl extends OrbitControls {
|
||||
constructor(object, domElement) {
|
||||
super(object, domElement)
|
||||
const scope = this
|
||||
const STATE = {
|
||||
NONE: -1,
|
||||
ROTATE: 0,
|
||||
DOLLY: 1,
|
||||
PAN: 2,
|
||||
TOUCH_ROTATE: 3,
|
||||
TOUCH_PAN: 4,
|
||||
TOUCH_DOLLY_PAN: 5,
|
||||
TOUCH_DOLLY_ROTATE: 6
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
let state = STATE.NONE
|
||||
this.resetState = function(target0, position0, zoom0) {
|
||||
scope.target.copy(target0)
|
||||
scope.object.position.copy(position0)
|
||||
scope.object.zoom = zoom0
|
||||
|
||||
scope.object.updateProjectionMatrix()
|
||||
scope.dispatchEvent(_changeEvent)
|
||||
|
||||
scope.update()
|
||||
|
||||
state = STATE.NONE
|
||||
}
|
||||
this.setLookAt = function(position0, target0, zoom0) {
|
||||
scope.target.copy(target0)
|
||||
scope.object.position.copy(position0)
|
||||
scope.object.zoom = zoom0
|
||||
|
||||
scope.object.updateProjectionMatrix()
|
||||
scope.dispatchEvent(_changeEvent)
|
||||
|
||||
scope.update()
|
||||
|
||||
state = STATE.NONE
|
||||
}
|
||||
this.moveTo = function(x, y, z) {
|
||||
// scope.target.set(x, y, z)
|
||||
}
|
||||
this.getState = function() {
|
||||
return {
|
||||
target: scope.target.clone(),
|
||||
position: scope.object.position.clone(),
|
||||
zoom: parseFloat(scope.object.zoom.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
export {
|
||||
DmtControl
|
||||
}
|
||||
Reference in New Issue
Block a user