Updated OPTIONS method for user function
This commit is contained in:
parent
bd63083ee3
commit
900ed963c0
@ -4,6 +4,16 @@ import axios from 'axios';
|
||||
export const handler: Handler = async (event: HandlerEvent, context: HandlerContext) => {
|
||||
try {
|
||||
const origin = event.headers.origin;
|
||||
if (event.httpMethod == 'OPTIONS') {
|
||||
return {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Access-Control-Allow-Origin': origin ? origin : 'https://cameras.immersiveidea.com',
|
||||
'Access-Control-Allow-Credentials': 'true'
|
||||
},
|
||||
statusCode: 200
|
||||
};
|
||||
}
|
||||
const baseurl = 'https://syncdb-service-d3f974de56ef.herokuapp.com/';
|
||||
const params = JSON.parse(event.body);
|
||||
const dbKey = params.shareKey;
|
||||
|
||||
6
src/controllers/functions/wheelHandler.ts
Normal file
6
src/controllers/functions/wheelHandler.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export function wheelHandler() {
|
||||
this.upDownWheel = false;
|
||||
this.fowardBackWheel = false;
|
||||
this.rig.updown(0);
|
||||
this.rig.forwardback(0);
|
||||
}
|
||||
@ -4,9 +4,11 @@ import {ControllerEventType, Controllers} from "./controllers";
|
||||
import {DiagramManager} from "../diagram/diagramManager";
|
||||
import {GridMaterial} from "@babylonjs/materials";
|
||||
import {setMenuPosition} from "../util/functions/setMenuPosition";
|
||||
import {wheelHandler} from "./functions/wheelHandler";
|
||||
|
||||
export class WebController {
|
||||
private scene: Scene;
|
||||
private speed: number = 1;
|
||||
private readonly referencePlane: AbstractMesh;
|
||||
private grabbedMesh: AbstractMesh;
|
||||
private pickedMesh: AbstractMesh;
|
||||
@ -14,6 +16,8 @@ export class WebController {
|
||||
private diagramManager: DiagramManager;
|
||||
private mouseDown: boolean = false;
|
||||
private controllers: Controllers;
|
||||
private upDownWheel: boolean = false;
|
||||
private fowardBackWheel: boolean = false;
|
||||
|
||||
constructor(scene: Scene, rig: Rigplatform, diagramManager: DiagramManager, controllers: Controllers) {
|
||||
this.scene = scene;
|
||||
@ -36,16 +40,22 @@ export class WebController {
|
||||
if (kbInfo.type == 1) {
|
||||
switch (kbInfo.event.key) {
|
||||
case "ArrowUp":
|
||||
this.rig.forwardback(-1);
|
||||
this.rig.forwardback(-this.speed);
|
||||
break;
|
||||
case "ArrowDown":
|
||||
this.rig.forwardback(1);
|
||||
this.rig.forwardback(this.speed);
|
||||
break;
|
||||
case "ArrowLeft":
|
||||
this.rig.leftright(-1);
|
||||
this.rig.leftright(-this.speed);
|
||||
break;
|
||||
case "ArrowRight":
|
||||
this.rig.leftright(1);
|
||||
this.rig.leftright(this.speed);
|
||||
break;
|
||||
case "]":
|
||||
this.speed *= 1.5;
|
||||
break;
|
||||
case "[":
|
||||
this.speed *= .5;
|
||||
break;
|
||||
case " ":
|
||||
if (kbInfo.event.ctrlKey) {
|
||||
@ -81,6 +91,35 @@ export class WebController {
|
||||
this.rig.turn(0);
|
||||
};
|
||||
|
||||
|
||||
window.addEventListener('wheel', (evt) => {
|
||||
switch (evt.buttons) {
|
||||
case 0:
|
||||
if (this.fowardBackWheel == false) {
|
||||
this.fowardBackWheel = true;
|
||||
const reset = wheelHandler.bind(this);
|
||||
setTimeout(reset, 500);
|
||||
}
|
||||
if (Math.sign(evt.deltaY) != 0) {
|
||||
this.rig.forwardback(evt.deltaY / 100);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (this.upDownWheel == false) {
|
||||
this.upDownWheel = true;
|
||||
const reset = wheelHandler.bind(this);
|
||||
setTimeout(reset, 500);
|
||||
}
|
||||
if (Math.sign(evt.deltaY) != 0) {
|
||||
this.rig.updown(evt.deltaY / 100);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
this.scene.onPointerDown = (evt, state, type) => {
|
||||
if (evt.pointerType == "mouse") {
|
||||
if (evt.shiftKey) {
|
||||
|
||||
@ -115,10 +115,15 @@ export class PouchdbPersistenceManager implements IPersistenceManager {
|
||||
|
||||
}
|
||||
|
||||
public async setConfig(config: any): Promise<any> {
|
||||
public async setConfig(config: any, initial: boolean = false): Promise<any> {
|
||||
if (!initial) {
|
||||
const doc = await this.config.get('1');
|
||||
const newConf = {...config, _id: '1', _rev: doc._rev};
|
||||
return this.config.put(newConf);
|
||||
} else {
|
||||
const newConf = {...config, _id: '1'};
|
||||
return this.config.put(newConf);
|
||||
}
|
||||
}
|
||||
|
||||
public async getConfig(): Promise<any> {
|
||||
@ -150,7 +155,7 @@ export class PouchdbPersistenceManager implements IPersistenceManager {
|
||||
currentDiagramId: uuidv4()
|
||||
}
|
||||
try {
|
||||
await this.setConfig(defaultConfig);
|
||||
await this.setConfig(defaultConfig, true);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
@ -214,8 +219,13 @@ export class PouchdbPersistenceManager implements IPersistenceManager {
|
||||
const dbs = await axios.get('https://syncdb-service-d3f974de56ef.herokuapp.com/_all_dbs');
|
||||
if (dbs.data.indexOf(syncTarget) == -1) {
|
||||
console.log('sync target missing');
|
||||
const buildTarget = await axios.post('https://deepdiagram.com/.netlify/functions/users',
|
||||
{username: syncTarget, password: 'password'});
|
||||
if (buildTarget.status != 200) {
|
||||
console.log(buildTarget.statusText);
|
||||
return;
|
||||
}
|
||||
}
|
||||
console.log(dbs);
|
||||
|
||||
this.remote = new PouchDB('https://syncdb-service-d3f974de56ef.herokuapp.com/' + syncTarget,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user