|
@@ -636,7 +636,6 @@ class TargetedOrbitCamera extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Comp
|
|
this.maxDistance = 50;
|
|
this.maxDistance = 50;
|
|
this.offset = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3();
|
|
this.offset = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3();
|
|
this.rotateMouseButton = 2;
|
|
this.rotateMouseButton = 2;
|
|
- this.useCameraLock = false;
|
|
|
|
this.rotateStart = new three__WEBPACK_IMPORTED_MODULE_1__.Vector2();
|
|
this.rotateStart = new three__WEBPACK_IMPORTED_MODULE_1__.Vector2();
|
|
this.rotateEnd = new three__WEBPACK_IMPORTED_MODULE_1__.Vector2();
|
|
this.rotateEnd = new three__WEBPACK_IMPORTED_MODULE_1__.Vector2();
|
|
this.rotateDelta = new three__WEBPACK_IMPORTED_MODULE_1__.Vector2();
|
|
this.rotateDelta = new three__WEBPACK_IMPORTED_MODULE_1__.Vector2();
|
|
@@ -652,11 +651,10 @@ class TargetedOrbitCamera extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Comp
|
|
this.initialOffset = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3();
|
|
this.initialOffset = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3();
|
|
}
|
|
}
|
|
awake() {
|
|
awake() {
|
|
- if (this.useCameraLock) {
|
|
|
|
- const container = document.getElementById(rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.containerId);
|
|
|
|
- container?.addEventListener("mousedown", this.lock, false);
|
|
|
|
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.onStop(this.dispose);
|
|
|
|
- }
|
|
|
|
|
|
+ const container = document.getElementById(rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.containerId);
|
|
|
|
+ container?.addEventListener("mousedown", this.lock, false);
|
|
|
|
+ container?.addEventListener("touchstart", this.lock, false);
|
|
|
|
+ rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.onStop(this.dispose);
|
|
}
|
|
}
|
|
start() {
|
|
start() {
|
|
if (!this.target) {
|
|
if (!this.target) {
|
|
@@ -675,7 +673,8 @@ class TargetedOrbitCamera extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Comp
|
|
if (!this.target) {
|
|
if (!this.target) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if (this.useCameraLock && !!document.pointerLockElement) {
|
|
|
|
|
|
+ const useCameraLock = true;
|
|
|
|
+ if (useCameraLock && !!document.pointerLockElement) {
|
|
if (this.enableRotate && rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.isMoving) {
|
|
if (this.enableRotate && rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.isMoving) {
|
|
let normalizedScreenMovement = new three__WEBPACK_IMPORTED_MODULE_1__.Vector2(0, 0);
|
|
let normalizedScreenMovement = new three__WEBPACK_IMPORTED_MODULE_1__.Vector2(0, 0);
|
|
this.normalizeScreenMovement({ x: rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.movementX, y: rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.movementY }, normalizedScreenMovement);
|
|
this.normalizeScreenMovement({ x: rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.movementX, y: rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.movementY }, normalizedScreenMovement);
|
|
@@ -703,13 +702,14 @@ class TargetedOrbitCamera extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Comp
|
|
this.dollyIn();
|
|
this.dollyIn();
|
|
}
|
|
}
|
|
this.updateCamera();
|
|
this.updateCamera();
|
|
- if (this.useCameraLock && rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("Escape")) {
|
|
|
|
|
|
+ if (useCameraLock && rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("Escape")) {
|
|
this.unlock();
|
|
this.unlock();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
dispose() {
|
|
dispose() {
|
|
const container = document.getElementById(rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.containerId);
|
|
const container = document.getElementById(rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.containerId);
|
|
container?.removeEventListener("mousedown", this.lock, false);
|
|
container?.removeEventListener("mousedown", this.lock, false);
|
|
|
|
+ container?.removeEventListener("touchstart", this.lock, false);
|
|
}
|
|
}
|
|
rotateLeft(angle) {
|
|
rotateLeft(angle) {
|
|
this.sphericalDelta.theta -= angle;
|
|
this.sphericalDelta.theta -= angle;
|
|
@@ -773,13 +773,17 @@ class TargetedOrbitCamera extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Comp
|
|
gameVector.y = -(browserVector.y / bounds.height);
|
|
gameVector.y = -(browserVector.y / bounds.height);
|
|
}
|
|
}
|
|
lock() {
|
|
lock() {
|
|
- if (!this.useCameraLock) {
|
|
|
|
|
|
+ const useCameraLock = true;
|
|
|
|
+ console.log("attempting camera lock", useCameraLock);
|
|
|
|
+ if (!useCameraLock) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ console.log("locking camera");
|
|
rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.lock();
|
|
rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.lock();
|
|
}
|
|
}
|
|
unlock() {
|
|
unlock() {
|
|
- if (!this.useCameraLock) {
|
|
|
|
|
|
+ const useCameraLock = true;
|
|
|
|
+ if (!useCameraLock) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.unlock();
|
|
rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.unlock();
|
|
@@ -825,9 +829,6 @@ __decorateClass([
|
|
__decorateClass([
|
|
__decorateClass([
|
|
rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
|
|
rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
|
|
], TargetedOrbitCamera.prototype, "rotateMouseButton", 2);
|
|
], TargetedOrbitCamera.prototype, "rotateMouseButton", 2);
|
|
-__decorateClass([
|
|
|
|
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.checkbox()
|
|
|
|
-], TargetedOrbitCamera.prototype, "useCameraLock", 2);
|
|
|
|
rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(TargetedOrbitCamera);
|
|
rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(TargetedOrbitCamera);
|
|
|
|
|
|
|
|
|