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/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();

View File

@ -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;

View File

@ -5,14 +5,14 @@ export class Cameras {
private scene: Scene;
private token: string;
private cameras;
private cameratextures = new Array<Texture>();
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);
}
}

View File

@ -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'
}
},
});
base:"/cameras"
})