94 lines
2.9 KiB
JavaScript
Executable File
94 lines
2.9 KiB
JavaScript
Executable File
export default function i(scope) {
|
|
|
|
"use strict";
|
|
|
|
let downX = 0;
|
|
let downY = 0;
|
|
|
|
scope.domElement.addEventListener("touchmove", function (ev) {
|
|
|
|
if (this.type !== "anim") {
|
|
|
|
nm[0] = ev.touches[0].clientX / w * 2 - 1;
|
|
nm[1] = ev.touches[0].clientY / h * -2 + 1;
|
|
|
|
}
|
|
}.bind(scope), false);
|
|
|
|
scope.domElement.addEventListener("touchstart", function (ev) {
|
|
|
|
downX = ev.touches[0].clientX / w * 2 - 1;
|
|
downY = ev.touches[0].clientY / h * -2 + 1;
|
|
|
|
scope.mouseArray = [
|
|
[downX, downY],
|
|
[downX, downY],
|
|
[downX, downY],
|
|
[downX, downY],
|
|
[downX, downY],
|
|
[downX, downY],
|
|
[downX, downY],
|
|
[downX, downY],
|
|
[downX, downY],
|
|
[downX, downY]
|
|
]
|
|
|
|
this.dragMultiplier = 1;
|
|
this.pressed = true;
|
|
|
|
}.bind(scope), false);
|
|
|
|
scope.domElement.addEventListener("touchend", function (ev) {
|
|
|
|
this.pressed = false;
|
|
|
|
if (Math.abs(downX - nm[0]) + Math.abs(downY - nm[1]) < 0.05) {
|
|
|
|
//If we have an intersect object
|
|
if (this.intersects) {
|
|
|
|
//If the name of the object under the cursor === floor then set controls to FP, translate to Cursor pos
|
|
if (this.intersects.object.name === "floor") {
|
|
this.setFP(this.intersects);
|
|
this.activeObject.uuid = undefined;
|
|
}
|
|
|
|
//If the object under the cursor is clickable &
|
|
//not the activeObject & the camera is not animating translate the Camera to it
|
|
else if (
|
|
this.intersects.object.userData.clickable === true &&
|
|
this.intersects.object.uuid !== this.activeObject.uuid &&
|
|
this.type !== "anim") {
|
|
this.setOrbit(this.intersects.object);
|
|
this.outlineObject.visible = false;
|
|
this.activeObject.uuid = this.intersects.object.uuid;
|
|
this.activeObject.name = this.intersects.object.name;
|
|
this.activeObject.text = this.intersects.object.userData.text;
|
|
overlayInfo.animIn(this.activeObject.name, this.activeObject.text);
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.dragMultiplier = 1.1;
|
|
|
|
this.dragVector.x = (mouseArray[9][1] - mouseArray[7][1]) * -1;
|
|
this.dragVector.y = mouseArray[9][0] - mouseArray[7][0];
|
|
|
|
}
|
|
|
|
if (this.saveCamTransform) {
|
|
localStorage.camTransform = [
|
|
this.target.position.x,
|
|
this.target.position.y,
|
|
this.target.position.z,
|
|
this.target.rotation.x,
|
|
this.target.rotation.y,
|
|
this.target.rotation.z
|
|
];
|
|
}
|
|
|
|
}.bind(scope), false);
|
|
|
|
} |