From 91144571c0e61b4e3fc817f4d9f654a6f9dc82b3 Mon Sep 17 00:00:00 2001 From: Michael Mainguy Date: Sat, 8 Jul 2023 06:21:30 -0500 Subject: [PATCH] Initial Menu System Commit. --- src/app.ts | 47 +++------------------------------ src/controllers/rigplatform.ts | 4 +-- src/integration/ring/cameras.ts | 20 ++++++++------ vite.config.ts | 14 +++++++--- 4 files changed, 28 insertions(+), 57 deletions(-) diff --git a/src/app.ts b/src/app.ts index f5b1257..a723f30 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,6 +1,5 @@ import "@babylonjs/core/Debug/debugLayer"; import "@babylonjs/inspector"; -import {Auth0Client, createAuth0Client} from '@auth0/auth0-spa-js'; import { ArcRotateCamera, @@ -28,14 +27,10 @@ import {Mapt} from "./util/mapt"; class App { //preTasks = [havokModule]; - private auth0: Auth0Client; + private token: string; - constructor(auth0: Auth0Client, token: string) { - this.auth0 = auth0; - this.token = token; - - + constructor() { const canvas = document.createElement("canvas"); canvas.style.width = "100%"; canvas.style.height = "100%"; @@ -45,7 +40,7 @@ class App { } async initialize(canvas) { - console.log(await this.auth0.getUser()); + const engine = new Engine(canvas, true); const scene = new Scene(engine); const havokInstance = await HavokPhysics(); @@ -152,41 +147,7 @@ class App { ground.material = groundMaterial; const groundAggregate = new PhysicsAggregate(ground, PhysicsShapeType.BOX, {mass: 0}, scene); return ground; - } } - -createAuth0Client({ - domain: import.meta.env.VITE_AUTH0_DOMAIN, - clientId: import.meta.env.VITE_AUTH0_CLIENTID, - authorizationParams: { - redirect_uri: 'https://cameras.immersiveidea.com/' - } -}).then(async (auth0) => { - try { - const query = window.location.search; - if (query.includes("code=") && query.includes("state=")) { - console.log(query); - const token = await auth0.handleRedirectCallback(); - - - history.pushState({token: token}, "", "/"); - - } - - const isAuthentic = await auth0.isAuthenticated(); - if (!isAuthentic) { - await auth0.loginWithRedirect(); - } else { - const token = await auth0.getTokenSilently(); - - new App(auth0, token); - } - - - } catch (error) { - console.log(error); - } -}); - +const app = new App(); diff --git a/src/controllers/rigplatform.ts b/src/controllers/rigplatform.ts index f3aabe5..06388a3 100644 --- a/src/controllers/rigplatform.ts +++ b/src/controllers/rigplatform.ts @@ -2,7 +2,7 @@ import { Color3, Mesh, MeshBuilder, - PhysicsAggregate, PhysicsBody, + PhysicsAggregate, PhysicsBody, PhysicsMotionType, PhysicsShapeType, Quaternion, Scene, StandardMaterial, @@ -31,7 +31,7 @@ export class Rigplatform { PhysicsShapeType.CYLINDER, { friction: 1, center: Vector3.Zero(), radius: .5, mass: .1, restitution: .1}, scene); - + rigAggregate.body.setMotionType(PhysicsMotionType.ANIMATED); rigAggregate.body.setGravityFactor(0); this.#fixRotation(); this.body = rigAggregate.body; diff --git a/src/integration/ring/cameras.ts b/src/integration/ring/cameras.ts index 8d51010..313cde3 100644 --- a/src/integration/ring/cameras.ts +++ b/src/integration/ring/cameras.ts @@ -5,14 +5,14 @@ export class Cameras { private scene: Scene; private token: string; private cameras; + private cameratextures = new Array(); constructor(scene: Scene, token: string) { this.scene = scene; this.token = token; } public async getCameras() { - const cameras = await axios.get('https://local.immersiveidea.com/api/cameras', - {headers: {'Authorization': 'Bearer ' + this.token}}); + const cameras = await axios.get('https://local.immersiveidea.com/api/cameras'); this.cameras = cameras; console.log(cameras); } @@ -25,17 +25,21 @@ export class Cameras { this.createCamera( 55870327, 5); } public createCamera(id, index) { - - const plane = MeshBuilder.CreatePlane("plane", {width: 1.6, height:.9}, this.scene); + const width = 1.6; + const height = .9 + const plane = MeshBuilder.CreatePlane("plane", {width: width, height: height}, this.scene); const materialPlane = new StandardMaterial("texturePlane", this.scene); + const imageText = new Texture("https://local.immersiveidea.com/api/cameras?id=" + id, this.scene); + materialPlane.diffuseTexture = new Texture("https://local.immersiveidea.com/api/cameras?id=" + id, this.scene); materialPlane.specularColor = new Color3(0, 0, 0); materialPlane.backFaceCulling = false;//Allways show the front and the back of an element plane.material = materialPlane; plane.rotation.y = Angle.FromDegrees(180).radians(); - plane.position.y = 1.5; - plane.position.z = -5; - plane.position.x = (1.6*3) - (index * 1.6); + plane.position.y = height/2 + .2; + plane.position.z = -3; + plane.position.x = (width*3) - (index * width); + this.cameratextures.push(imageText); } -} \ No newline at end of file +} diff --git a/vite.config.ts b/vite.config.ts index d57ed23..e7d38ce 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,8 +1,14 @@ import { defineConfig } from "vite"; - +/** @type {import('vite').UserConfig} */ export default defineConfig({ server: { - port: 3001 - } + port: 3001, + proxy: { '/api': 'https://local.immersiveidea.com' , + '/login': 'https://local.immersiveidea.com', + '/callback': 'https://local.immersiveidea.com' + } + }, -}); \ No newline at end of file + base:"/cameras" + +}) \ No newline at end of file