|
@@ -1,3 +1,5 @@
|
|
|
+import util from "./util.js"
|
|
|
+
|
|
|
export default class XCameraComponent {
|
|
|
constructor(e, t, r) {
|
|
|
E(this, "maincameraRotLimitObserver", null);
|
|
@@ -60,9 +62,9 @@ export default class XCameraComponent {
|
|
|
);
|
|
|
E(this, "setCameraPose", e=>{
|
|
|
var n;
|
|
|
- const t = ue4Position2Xverse(e.position);
|
|
|
+ const t = util.ue4Position2Xverse(e.position);
|
|
|
let r = null;
|
|
|
- e.rotation != null && (r = ue4Rotation2Xverse(e.rotation)),
|
|
|
+ e.rotation != null && (r = util.ue4Rotation2Xverse(e.rotation)),
|
|
|
this._cameraPose = {
|
|
|
position: t
|
|
|
},
|
|
@@ -183,11 +185,11 @@ export default class XCameraComponent {
|
|
|
, h = [n - s, n + s]
|
|
|
, f = [a - u, a + u];
|
|
|
this.maincameraRotLimitObserver = r.onAfterCheckInputsObservable.add(()=>{
|
|
|
- let {pitch: d, yaw: _, roll: g} = xverseRotation2Ue4(r.rotation);
|
|
|
+ let {pitch: d, yaw: _, roll: g} = util.xverseRotation2Ue4(r.rotation);
|
|
|
d = this._limitAngle(d, c),
|
|
|
_ = this._limitAngle(_, h),
|
|
|
g = this._limitAngle(g, f),
|
|
|
- r.rotation = ue4Rotation2Xverse({
|
|
|
+ r.rotation = util.ue4Rotation2Xverse({
|
|
|
pitch: d,
|
|
|
yaw: _,
|
|
|
roll: g
|
|
@@ -198,8 +200,8 @@ export default class XCameraComponent {
|
|
|
setMainCameraRotationLimitByAnchor(e, t, r) {
|
|
|
this.maincameraRotLimitObserver != null && this.removeMainCameraRotationLimit();
|
|
|
const n = this.mainCamera
|
|
|
- , o = ue4Rotation2Xverse_mesh(t)
|
|
|
- , a = ue4Rotation2Xverse_mesh(r);
|
|
|
+ , o = util.ue4Rotation2Xverse_mesh(t)
|
|
|
+ , a = util.ue4Rotation2Xverse_mesh(r);
|
|
|
a != null && o != null && e.mesh != null && (this.maincameraRotLimitObserver = n.onAfterCheckInputsObservable.add(()=>{
|
|
|
const s = e.mesh.rotation;
|
|
|
r.yaw > 0 && (n.rotation.y <= s.y - a.y + o.y ? n.rotation.y = s.y - a.y + o.y : n.rotation.y >= s.y + a.y + o.y && (n.rotation.y = s.y + a.y + o.y)),
|
|
@@ -209,12 +211,12 @@ export default class XCameraComponent {
|
|
|
))
|
|
|
}
|
|
|
getCameraPose() {
|
|
|
- const e = xversePosition2Ue4({
|
|
|
+ const e = util.xversePosition2Ue4({
|
|
|
x: this.mainCamera.position.x,
|
|
|
y: this.mainCamera.position.y,
|
|
|
z: this.mainCamera.position.z
|
|
|
})
|
|
|
- , t = xverseRotation2Ue4({
|
|
|
+ , t = util.xverseRotation2Ue4({
|
|
|
x: this.mainCamera.rotation.x,
|
|
|
y: this.mainCamera.rotation.y,
|
|
|
z: this.mainCamera.rotation.z
|
|
@@ -238,7 +240,7 @@ export default class XCameraComponent {
|
|
|
}
|
|
|
addRot(e) {
|
|
|
const t = this.mainCamera
|
|
|
- , r = ue4Rotation2Xverse_mesh(e);
|
|
|
+ , r = util.ue4Rotation2Xverse_mesh(e);
|
|
|
r != null && t.rotation.addInPlace(r)
|
|
|
}
|
|
|
getCameraFov() {
|
|
@@ -251,8 +253,8 @@ export default class XCameraComponent {
|
|
|
this.mainCamera.detachControl(this.canvas)
|
|
|
}
|
|
|
forceChangeSavedCameraPose(e) {
|
|
|
- this.saveCameraPose != null && (e.position != null && (this.saveCameraPose.position = ue4Position2Xverse(e.position)),
|
|
|
- e.rotation != null && (this.saveCameraPose.rotation = ue4Rotation2Xverse(e.rotation)))
|
|
|
+ this.saveCameraPose != null && (e.position != null && (this.saveCameraPose.position = util.ue4Position2Xverse(e.position)),
|
|
|
+ e.rotation != null && (this.saveCameraPose.rotation = util.ue4Rotation2Xverse(e.rotation)))
|
|
|
}
|
|
|
changeToFirstPersonView(e) {
|
|
|
this.saveCameraPose = {
|
|
@@ -260,8 +262,8 @@ export default class XCameraComponent {
|
|
|
rotation: this.mainCamera.rotation.clone()
|
|
|
},
|
|
|
this.mainCamera.attachControl(this.canvas, !0),
|
|
|
- e.position != null && (this.mainCamera.position = ue4Position2Xverse(e.position)),
|
|
|
- e.rotation != null && (this.mainCamera.rotation = ue4Rotation2Xverse(e.rotation))
|
|
|
+ e.position != null && (this.mainCamera.position = util.ue4Position2Xverse(e.position)),
|
|
|
+ e.rotation != null && (this.mainCamera.rotation = util.ue4Rotation2Xverse(e.rotation))
|
|
|
}
|
|
|
changeToThirdPersonView() {
|
|
|
this.saveCameraPose != null && this.mainCamera != null && (this.mainCamera.position = this.saveCameraPose.position.clone(),
|