Initial Menu System Commit.

This commit is contained in:
Michael Mainguy 2023-06-29 21:03:00 -05:00
parent a0aeb13fe1
commit eea59027a7
10 changed files with 122 additions and 93 deletions

View File

@ -1,6 +1,6 @@
import {RingCamera} from "../server/ring/ringCamera";
export const GET = async (req, res) => {
async (req, res) => {
const cams = new RingCamera();
const list = await cams.getCameras();
@ -14,6 +14,4 @@ export const GET = async (req, res) => {
res.contentType('application/json');
res.send(data);
}
}

78
package-lock.json generated
View File

@ -17,9 +17,11 @@
"@maptiler/client": "^1.5.0",
"axios": "^1.4.0",
"express": "^4.18.2",
"express-http-proxy": "^1.6.3",
"google-static-maps-tile": "1.0.0",
"query-string": "^8.1.0",
"ring-client-api": "^11.8.0"
"ring-client-api": "^11.8.0",
"vite-express": "^0.9.1"
},
"devDependencies": {
"typescript": "^5.0.2",
@ -147,7 +149,6 @@
"cpu": [
"arm"
],
"dev": true,
"optional": true,
"os": [
"android"
@ -163,7 +164,6 @@
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"android"
@ -179,7 +179,6 @@
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"android"
@ -195,7 +194,6 @@
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
@ -211,7 +209,6 @@
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
@ -227,7 +224,6 @@
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"freebsd"
@ -243,7 +239,6 @@
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"freebsd"
@ -259,7 +254,6 @@
"cpu": [
"arm"
],
"dev": true,
"optional": true,
"os": [
"linux"
@ -275,7 +269,6 @@
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"linux"
@ -291,7 +284,6 @@
"cpu": [
"ia32"
],
"dev": true,
"optional": true,
"os": [
"linux"
@ -307,7 +299,6 @@
"cpu": [
"loong64"
],
"dev": true,
"optional": true,
"os": [
"linux"
@ -323,7 +314,6 @@
"cpu": [
"mips64el"
],
"dev": true,
"optional": true,
"os": [
"linux"
@ -339,7 +329,6 @@
"cpu": [
"ppc64"
],
"dev": true,
"optional": true,
"os": [
"linux"
@ -355,7 +344,6 @@
"cpu": [
"riscv64"
],
"dev": true,
"optional": true,
"os": [
"linux"
@ -371,7 +359,6 @@
"cpu": [
"s390x"
],
"dev": true,
"optional": true,
"os": [
"linux"
@ -387,7 +374,6 @@
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"linux"
@ -403,7 +389,6 @@
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"netbsd"
@ -419,7 +404,6 @@
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"openbsd"
@ -435,7 +419,6 @@
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"sunos"
@ -451,7 +434,6 @@
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"win32"
@ -467,7 +449,6 @@
"cpu": [
"ia32"
],
"dev": true,
"optional": true,
"os": [
"win32"
@ -483,7 +464,6 @@
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"win32"
@ -1904,11 +1884,15 @@
"has-binary2": "~1.0.2"
}
},
"node_modules/es6-promise": {
"version": "4.2.8",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz",
"integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w=="
},
"node_modules/esbuild": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz",
"integrity": "sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==",
"dev": true,
"hasInstallScript": true,
"bin": {
"esbuild": "bin/esbuild"
@ -2041,6 +2025,32 @@
"node": ">= 0.10.0"
}
},
"node_modules/express-http-proxy": {
"version": "1.6.3",
"resolved": "https://registry.npmjs.org/express-http-proxy/-/express-http-proxy-1.6.3.tgz",
"integrity": "sha512-/l77JHcOUrDUX8V67E287VEUQT0lbm71gdGVoodnlWBziarYKgMcpqT7xvh/HM8Jv52phw8Bd8tY+a7QjOr7Yg==",
"dependencies": {
"debug": "^3.0.1",
"es6-promise": "^4.1.1",
"raw-body": "^2.3.0"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/express-http-proxy/node_modules/debug": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"dependencies": {
"ms": "^2.1.1"
}
},
"node_modules/express-http-proxy/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"node_modules/external-editor": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz",
@ -3121,7 +3131,6 @@
"version": "3.3.6",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
"integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==",
"dev": true,
"funding": [
{
"type": "github",
@ -3363,8 +3372,7 @@
"node_modules/picocolors": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
"dev": true
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ=="
},
"node_modules/picomatch": {
"version": "2.3.1",
@ -3381,7 +3389,6 @@
"version": "8.4.24",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.24.tgz",
"integrity": "sha512-M0RzbcI0sO/XJNucsGjvWU9ERWxb/ytp1w6dKtxTKgixdtQDq4rmx/g8W1hnaheq9jgwL/oyEdH5Bc4WwJKMqg==",
"dev": true,
"funding": [
{
"type": "opencollective",
@ -3725,7 +3732,6 @@
"version": "3.25.1",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-3.25.1.tgz",
"integrity": "sha512-tywOR+rwIt5m2ZAWSe5AIJcTat8vGlnPFAv15ycCrw33t6iFsXZ6mzHVFh2psSjxQPmI+xgzMZZizUAukBI4aQ==",
"dev": true,
"bin": {
"rollup": "dist/bin/rollup"
},
@ -3994,7 +4000,6 @@
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz",
"integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
@ -4294,7 +4299,6 @@
"version": "4.3.9",
"resolved": "https://registry.npmjs.org/vite/-/vite-4.3.9.tgz",
"integrity": "sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==",
"dev": true,
"dependencies": {
"esbuild": "^0.17.5",
"postcss": "^8.4.23",
@ -4338,6 +4342,18 @@
}
}
},
"node_modules/vite-express": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/vite-express/-/vite-express-0.9.1.tgz",
"integrity": "sha512-tTX9gqYxiarnhcr9o4U95p0F8LavUzfDKS+5wB7eOw09XE1HSrdOJsk6dHN5H0EmhubdH12gHOs3t0pPdPh+Ag==",
"dependencies": {
"picocolors": "^1.0.0"
},
"peerDependencies": {
"express": "^4.18.2",
"vite": "^4.0.0"
}
},
"node_modules/vite-plugin-api": {
"version": "0.1.11",
"resolved": "https://registry.npmjs.org/vite-plugin-api/-/vite-plugin-api-0.1.11.tgz",

View File

@ -8,7 +8,7 @@
"build": "tsc && vite build",
"preview": "vite preview",
"havok": "node ./copyHavok.cjs",
"serve": "",
"serve": "node server.js",
"postinstall": "cp ./node_modules/@babylonjs/havok/lib/esm/HavokPhysics.wasm ./node_modules/.vite/deps"
},
"dependencies": {
@ -22,7 +22,9 @@
"@maptiler/client": "^1.5.0",
"axios": "^1.4.0",
"google-static-maps-tile": "1.0.0",
"query-string": "^8.1.0"
"query-string": "^8.1.0",
"vite-express": "^0.9.1",
"express-http-proxy": "^1.6.3"
},
"devDependencies": {
"typescript": "^5.0.2",

15
server.js Normal file
View File

@ -0,0 +1,15 @@
import express from "express";
import ViteExpress from "vite-express";
import dotenv from "dotenv";
import expressProxy from "express-http-proxy";
dotenv.config();
const app = express();
app.use("/api", expressProxy("local.immersiveidea.com"));
ViteExpress.listen(app, process.env.PORT || 3001, () => console.log("Server is listening..."));

View File

@ -1,6 +0,0 @@
export const GET = async (req, res, next) => {
res.contentType('application/json');
res.send('{"status": "OK"}');
}

View File

@ -3,17 +3,16 @@ import "@babylonjs/inspector";
import {Auth0Client, createAuth0Client} from '@auth0/auth0-spa-js';
import {
ActionManager, Angle,
ArcRotateCamera, Color3, CubeTexture,
ArcRotateCamera,
Engine,
HavokPlugin,
HemisphericLight, InterpolateValueAction,
Mesh,
MeshBuilder, PBRMetallicRoughnessMaterial,
PhotoDome,
HemisphericLight,
MeshBuilder,
PBRMetallicRoughnessMaterial,
PhysicsAggregate,
PhysicsShapeType, Plane, Quaternion,
Scene, StandardMaterial, Texture,
PhysicsShapeType,
Scene,
Texture,
Vector3,
WebXRDefaultExperience
} from "@babylonjs/core";
@ -23,20 +22,18 @@ import {Left} from "./controllers/left";
import {Bmenu} from "./menus/bmenu";
import HavokPhysics from "@babylonjs/havok";
import {Rigplatform} from "./controllers/rigplatform";
import {ObjectEditor} from "./menus/objectEditor";
import {RingCamera} from "./server/ring/ringCamera";
import {AdvancedDynamicTexture, Image} from "@babylonjs/gui";
import {Cameras} from "./integration/ring/cameras";
import {Gmap} from "./util/gmap";
import {Mapt} from "./util/mapt";
class App {
//preTasks = [havokModule];
private auth0: Auth0Client;
constructor(auth0: Auth0Client) {
private token: string;
constructor(auth0: Auth0Client, token: string) {
this.auth0 = auth0;
this.token = token;
const canvas = document.createElement("canvas");
@ -53,7 +50,7 @@ class App {
const scene = new Scene(engine);
const havokInstance = await HavokPhysics();
const havokPlugin = new HavokPlugin(true, havokInstance);
scene.enablePhysics(new Vector3(0 , -9.8, 0), havokPlugin);
scene.enablePhysics(new Vector3(0, -9.8, 0), havokPlugin);
const camera: ArcRotateCamera = new ArcRotateCamera("Camera", Math.PI / 2, Math.PI / 2, 2,
new Vector3(0, 1.6, 0), scene);
camera.attachControl(canvas, true);
@ -67,8 +64,10 @@ class App {
'./outdoor_field.jpeg', {},
scene);
*/
const xr = await WebXRDefaultExperience.CreateAsync(scene, {floorMeshes: [this.createGround(scene)],
optionalFeatures: true});
const xr = await WebXRDefaultExperience.CreateAsync(scene, {
floorMeshes: [this.createGround(scene)],
optionalFeatures: true
});
xr.baseExperience.camera.parent = rig.rigMesh;
const b = new Bmenu(scene, rig, xr.baseExperience);
//const box = MeshBuilder.CreateBox("box", {size: 1}, scene);
@ -88,8 +87,8 @@ class App {
//const edit = new ObjectEditor(scene, box);
//const edit = new ObjectEditor(scene, box);
const ring = new Cameras(scene);
ring.getCameras().then(()=> ring.createCameras());
const ring = new Cameras(scene, this.token);
ring.getCameras().then(() => ring.createCameras());
const stickVector = Vector3.Zero();
xr.input.onControllerAddedObservable.add((source, state) => {
@ -139,14 +138,15 @@ class App {
scene.render();
});
}
createGround(scene) {
const groundMaterial = new PBRMetallicRoughnessMaterial("groundMaterial", scene);
const gText = new Texture("./grass1.jpeg", scene);
gText.uScale =40;
gText.vScale=40;
gText.uScale = 40;
gText.vScale = 40;
groundMaterial.baseTexture = gText;
groundMaterial.metallic =0;
groundMaterial.roughness=1;
groundMaterial.metallic = 0;
groundMaterial.roughness = 1;
const ground = MeshBuilder.CreateGround("ground", {width: 100, height: 100, subdivisions: 1}, scene);
ground.material = groundMaterial;
@ -162,12 +162,16 @@ createAuth0Client({
authorizationParams: {
redirect_uri: 'https://cameras.immersiveidea.com/'
}
}).then(async (auth0)=> {
}).then(async (auth0) => {
try {
const query = window.location.search;
if (query.includes("code=") && query.includes("state=")) {
await auth0.handleRedirectCallback();
window.location.href = 'https://cameras.immersiveidea.com';
console.log(query);
const token = await auth0.handleRedirectCallback();
history.pushState({token: token}, "", "/");
}
const isAuthentic = await auth0.isAuthenticated();
@ -175,7 +179,8 @@ createAuth0Client({
await auth0.loginWithRedirect();
} else {
const token = await auth0.getTokenSilently();
new App(auth0);
new App(auth0, token);
}

View File

@ -22,6 +22,7 @@ export class Right extends Base {
init.components['xr-standard-thumbstick']
.onAxisValueChangedObservable.add((value) => {
const ray = this.camera.getForwardRay();
if (Math.abs(value.x) > .1) {
this.body.setAngularVelocity(Vector3.Up().scale(value.x));
} else {

View File

@ -3,13 +3,16 @@ import axios from "axios";
export class Cameras {
private scene: Scene;
private token: string;
private cameras;
constructor(scene: Scene) {
constructor(scene: Scene, token: string) {
this.scene = scene;
this.token = token;
}
public async getCameras() {
const cameras = await axios.get('/api/cameras',{});
const cameras = await axios.get('https://local.immersiveidea.com/api/cameras',
{headers: {'Authorization': 'Bearer ' + this.token}});
this.cameras = cameras;
console.log(cameras);
}
@ -25,7 +28,7 @@ export class Cameras {
const plane = MeshBuilder.CreatePlane("plane", {width: 1.6, height:.9}, this.scene);
const materialPlane = new StandardMaterial("texturePlane", this.scene);
materialPlane.diffuseTexture = new Texture("/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;

9
src/menus/amenu.ts Normal file
View File

@ -0,0 +1,9 @@
export class Amenu {
private visible = false;
constructor() {
}
public toggle() {
this.visible = !this.visible;
}
}

View File

@ -1,22 +1,8 @@
import { defineConfig } from "vite";
import { pluginAPI } from "vite-plugin-api";
export default defineConfig({
server: {
port: 3001
},
plugins: [
pluginAPI({
// routeBase?: "api",
// dirs?: [{ dir: "src/api"; route: "", exclude?: ["*.txt", ".csv", "data/*.*"] }],
// include?: ["**/*.js", "**/*.ts"],
// exclude?: ["node_modules", ".git"],
// moduleId?: "virtual:vite-plugin-api",
// mapper?: { default: "use", GET: "get", ... },
// entry?: "[node_module:lib]/server.js",
// handler?: "[node_module:lib]/handler.js",
}),
],
}
});