Initial Menu System Commit.

This commit is contained in:
Michael Mainguy 2023-07-08 06:21:30 -05:00
parent 06cf618203
commit 91144571c0
4 changed files with 28 additions and 57 deletions

View File

@ -1,6 +1,5 @@
import "@babylonjs/core/Debug/debugLayer"; import "@babylonjs/core/Debug/debugLayer";
import "@babylonjs/inspector"; import "@babylonjs/inspector";
import {Auth0Client, createAuth0Client} from '@auth0/auth0-spa-js';
import { import {
ArcRotateCamera, ArcRotateCamera,
@ -28,14 +27,10 @@ import {Mapt} from "./util/mapt";
class App { class App {
//preTasks = [havokModule]; //preTasks = [havokModule];
private auth0: Auth0Client;
private token: string; private token: string;
constructor(auth0: Auth0Client, token: string) { constructor() {
this.auth0 = auth0;
this.token = token;
const canvas = document.createElement("canvas"); const canvas = document.createElement("canvas");
canvas.style.width = "100%"; canvas.style.width = "100%";
canvas.style.height = "100%"; canvas.style.height = "100%";
@ -45,7 +40,7 @@ class App {
} }
async initialize(canvas) { async initialize(canvas) {
console.log(await this.auth0.getUser());
const engine = new Engine(canvas, true); const engine = new Engine(canvas, true);
const scene = new Scene(engine); const scene = new Scene(engine);
const havokInstance = await HavokPhysics(); const havokInstance = await HavokPhysics();
@ -152,41 +147,7 @@ class App {
ground.material = groundMaterial; ground.material = groundMaterial;
const groundAggregate = new PhysicsAggregate(ground, PhysicsShapeType.BOX, {mass: 0}, scene); const groundAggregate = new PhysicsAggregate(ground, PhysicsShapeType.BOX, {mass: 0}, scene);
return ground; return ground;
} }
} }
const app = new App();
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);
}
});

View File

@ -2,7 +2,7 @@ import {
Color3, Color3,
Mesh, Mesh,
MeshBuilder, MeshBuilder,
PhysicsAggregate, PhysicsBody, PhysicsAggregate, PhysicsBody, PhysicsMotionType,
PhysicsShapeType, Quaternion, PhysicsShapeType, Quaternion,
Scene, Scene,
StandardMaterial, StandardMaterial,
@ -31,7 +31,7 @@ export class Rigplatform {
PhysicsShapeType.CYLINDER, PhysicsShapeType.CYLINDER,
{ friction: 1, center: Vector3.Zero(), radius: .5, mass: .1, restitution: .1}, { friction: 1, center: Vector3.Zero(), radius: .5, mass: .1, restitution: .1},
scene); scene);
rigAggregate.body.setMotionType(PhysicsMotionType.ANIMATED);
rigAggregate.body.setGravityFactor(0); rigAggregate.body.setGravityFactor(0);
this.#fixRotation(); this.#fixRotation();
this.body = rigAggregate.body; this.body = rigAggregate.body;

View File

@ -5,14 +5,14 @@ export class Cameras {
private scene: Scene; private scene: Scene;
private token: string; private token: string;
private cameras; private cameras;
private cameratextures = new Array<Texture>();
constructor(scene: Scene, token: string) { constructor(scene: Scene, token: string) {
this.scene = scene; this.scene = scene;
this.token = token; this.token = token;
} }
public async getCameras() { public async getCameras() {
const cameras = await axios.get('https://local.immersiveidea.com/api/cameras', const cameras = await axios.get('https://local.immersiveidea.com/api/cameras');
{headers: {'Authorization': 'Bearer ' + this.token}});
this.cameras = cameras; this.cameras = cameras;
console.log(cameras); console.log(cameras);
} }
@ -25,17 +25,21 @@ export class Cameras {
this.createCamera( 55870327, 5); this.createCamera( 55870327, 5);
} }
public createCamera(id, index) { public createCamera(id, index) {
const width = 1.6;
const plane = MeshBuilder.CreatePlane("plane", {width: 1.6, height:.9}, this.scene); const height = .9
const plane = MeshBuilder.CreatePlane("plane", {width: width, height: height}, this.scene);
const materialPlane = new StandardMaterial("texturePlane", 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.diffuseTexture = new Texture("https://local.immersiveidea.com/api/cameras?id=" + id, this.scene);
materialPlane.specularColor = new Color3(0, 0, 0); materialPlane.specularColor = new Color3(0, 0, 0);
materialPlane.backFaceCulling = false;//Allways show the front and the back of an element materialPlane.backFaceCulling = false;//Allways show the front and the back of an element
plane.material = materialPlane; plane.material = materialPlane;
plane.rotation.y = Angle.FromDegrees(180).radians(); plane.rotation.y = Angle.FromDegrees(180).radians();
plane.position.y = 1.5; plane.position.y = height/2 + .2;
plane.position.z = -5; plane.position.z = -3;
plane.position.x = (1.6*3) - (index * 1.6); plane.position.x = (width*3) - (index * width);
this.cameratextures.push(imageText);
} }
} }

View File

@ -1,8 +1,14 @@
import { defineConfig } from "vite"; import { defineConfig } from "vite";
/** @type {import('vite').UserConfig} */
export default defineConfig({ export default defineConfig({
server: { server: {
port: 3001 port: 3001,
} proxy: { '/api': 'https://local.immersiveidea.com' ,
'/login': 'https://local.immersiveidea.com',
'/callback': 'https://local.immersiveidea.com'
}
},
}); base:"/cameras"
})