Fixed Circular Dependency.
This commit is contained in:
parent
b788b64df5
commit
a016aa749b
@ -8,7 +8,7 @@ import {
|
|||||||
WebXRDefaultExperience,
|
WebXRDefaultExperience,
|
||||||
WebXRInputSource
|
WebXRInputSource
|
||||||
} from "@babylonjs/core";
|
} from "@babylonjs/core";
|
||||||
import {DiagramEventObserverMask, DiagramManager} from "../diagram/diagramManager";
|
import {DiagramManager} from "../diagram/diagramManager";
|
||||||
import {DiagramEvent, DiagramEventType} from "../diagram/types/diagramEntity";
|
import {DiagramEvent, DiagramEventType} from "../diagram/types/diagramEntity";
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
import {ControllerEventType, Controllers} from "./controllers";
|
import {ControllerEventType, Controllers} from "./controllers";
|
||||||
@ -27,6 +27,7 @@ import {handleWasGrabbed} from "./functions/handleWasGrabbed";
|
|||||||
import {buildDrop} from "./functions/buildDrop";
|
import {buildDrop} from "./functions/buildDrop";
|
||||||
import {pointable} from "./functions/pointable";
|
import {pointable} from "./functions/pointable";
|
||||||
import {DefaultScene} from "../defaultScene";
|
import {DefaultScene} from "../defaultScene";
|
||||||
|
import {DiagramEventObserverMask} from "../diagram/types/diagramEventObserverMask";
|
||||||
|
|
||||||
const CLICK_TIME = 300;
|
const CLICK_TIME = 300;
|
||||||
|
|
||||||
|
|||||||
@ -173,7 +173,7 @@ export class Rigplatform {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LEFT:
|
case LEFT:
|
||||||
if (!this.leftController) {
|
if (this.leftController) {
|
||||||
this.leftController = new Left(source, this.xr, this.diagramManager);
|
this.leftController = new Left(source, this.xr, this.diagramManager);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -189,6 +189,9 @@ export class Rigplatform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fixRotation() {
|
private fixRotation() {
|
||||||
|
if (!this.scene) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.scene.onAfterPhysicsObservable.add(() => {
|
this.scene.onAfterPhysicsObservable.add(() => {
|
||||||
const turnSnap = this.turnSnap;
|
const turnSnap = this.turnSnap;
|
||||||
if (turnSnap && turnSnap > 0) {
|
if (turnSnap && turnSnap > 0) {
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
import {AbstractMesh, KeyboardEventTypes, MeshBuilder, Scene} from "@babylonjs/core";
|
import {AbstractMesh, KeyboardEventTypes, MeshBuilder, Scene} from "@babylonjs/core";
|
||||||
import {Rigplatform} from "./rigplatform";
|
import {Rigplatform} from "./rigplatform";
|
||||||
import {ControllerEventType, Controllers} from "./controllers";
|
import {ControllerEventType, Controllers} from "./controllers";
|
||||||
import {DiagramEventObserverMask, DiagramManager} from "../diagram/diagramManager";
|
import {DiagramManager} from "../diagram/diagramManager";
|
||||||
import {GridMaterial} from "@babylonjs/materials";
|
import {GridMaterial} from "@babylonjs/materials";
|
||||||
import {wheelHandler} from "./functions/wheelHandler";
|
import {wheelHandler} from "./functions/wheelHandler";
|
||||||
import log, {Logger} from "loglevel";
|
import log, {Logger} from "loglevel";
|
||||||
import {isDiagramEntity} from "../diagram/functions/isDiagramEntity";
|
import {isDiagramEntity} from "../diagram/functions/isDiagramEntity";
|
||||||
import {DiagramEventType} from "../diagram/types/diagramEntity";
|
import {DiagramEventType} from "../diagram/types/diagramEntity";
|
||||||
import {toDiagramEntity} from "../diagram/functions/toDiagramEntity";
|
import {toDiagramEntity} from "../diagram/functions/toDiagramEntity";
|
||||||
|
import {DiagramEventObserverMask} from "../diagram/types/diagramEventObserverMask";
|
||||||
|
|
||||||
export class WebController {
|
export class WebController {
|
||||||
private readonly scene: Scene;
|
private readonly scene: Scene;
|
||||||
|
|||||||
@ -2,10 +2,11 @@ import PouchDB from 'pouchdb';
|
|||||||
import {DiagramEntity, DiagramEventType} from "../diagram/types/diagramEntity";
|
import {DiagramEntity, DiagramEventType} from "../diagram/types/diagramEntity";
|
||||||
import {Observable} from "@babylonjs/core";
|
import {Observable} from "@babylonjs/core";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {DiagramEventObserverMask, DiagramManager} from "../diagram/diagramManager";
|
import {DiagramManager} from "../diagram/diagramManager";
|
||||||
import log, {Logger} from "loglevel";
|
import log, {Logger} from "loglevel";
|
||||||
import {ascii_to_hex} from "./functions/hexFunctions";
|
import {ascii_to_hex} from "./functions/hexFunctions";
|
||||||
import {getPath} from "../util/functions/getPath";
|
import {getPath} from "../util/functions/getPath";
|
||||||
|
import {DiagramEventObserverMask} from "../diagram/types/diagramEventObserverMask";
|
||||||
|
|
||||||
|
|
||||||
export class PouchdbPersistenceManager {
|
export class PouchdbPersistenceManager {
|
||||||
|
|||||||
@ -7,15 +7,14 @@ const uploadImage = async (evt) => {
|
|||||||
}
|
}
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
|
//formData.append('requireSignedURLs', 'false');
|
||||||
//formData.append('requireSignedURLs', 'true');
|
//formData.append('requireSignedURLs', 'true');
|
||||||
const formInitData = new FormData();
|
const formInitData = new FormData();
|
||||||
formInitData.append('requireSignedURLs', 'true');
|
formInitData.append('requireSignedURLs', 'false');
|
||||||
|
|
||||||
const initialUpload = await fetch('/api/images', {
|
const initialUpload = await fetch('/api/images', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formInitData
|
body: formInitData
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
const initialData = await initialUpload.json();
|
const initialData = await initialUpload.json();
|
||||||
|
|||||||
@ -1,68 +0,0 @@
|
|||||||
import {
|
|
||||||
AssetContainer,
|
|
||||||
Color3,
|
|
||||||
Mesh,
|
|
||||||
MeshBuilder,
|
|
||||||
Scalar,
|
|
||||||
Scene,
|
|
||||||
SceneLoader,
|
|
||||||
SpotLight,
|
|
||||||
StandardMaterial,
|
|
||||||
Vector3
|
|
||||||
} from "@babylonjs/core";
|
|
||||||
|
|
||||||
|
|
||||||
export function createCloset(scene: Scene) {
|
|
||||||
const width = 1.8;
|
|
||||||
const height = 2.4;
|
|
||||||
const material = new StandardMaterial("closet", scene);
|
|
||||||
material.maxSimultaneousLights = 10;
|
|
||||||
material.diffuseColor = Color3.FromHexString("#ffffee");
|
|
||||||
const back = MeshBuilder.CreatePlane("back", {sideOrientation: Mesh.DOUBLESIDE, width: width, height: height}, scene);
|
|
||||||
back.position.z = -.9 / 2;
|
|
||||||
back.material = material;
|
|
||||||
back.position.y = height / 2;
|
|
||||||
const left = MeshBuilder.CreatePlane("back", {sideOrientation: Mesh.DOUBLESIDE, width: .9, height: height}, scene);
|
|
||||||
const left2 = MeshBuilder.CreatePlane("back", {sideOrientation: Mesh.DOUBLESIDE, width: .15, height: height}, scene);
|
|
||||||
left2.position.z = .9 / 2;
|
|
||||||
left2.position.x = -width / 2 + .15 / 2;
|
|
||||||
left2.position.y = height / 2;
|
|
||||||
left.material = material;
|
|
||||||
left2.material = material;
|
|
||||||
const right = MeshBuilder.CreatePlane("back", {sideOrientation: Mesh.DOUBLESIDE, width: .9, height: height}, scene);
|
|
||||||
const right2 = MeshBuilder.CreatePlane("back", {sideOrientation: Mesh.DOUBLESIDE, width: .15, height: height}, scene);
|
|
||||||
right2.position.x = width / 2 - .15 / 2;
|
|
||||||
right2.position.y = height / 2;
|
|
||||||
right2.position.z = .9 / 2;
|
|
||||||
right2.material = material
|
|
||||||
right.material = material;
|
|
||||||
left.position.y = height / 2;
|
|
||||||
right.position.y = height / 2;
|
|
||||||
left.position.x = width / 2;
|
|
||||||
right.position.x = -width / 2;
|
|
||||||
left.rotation.y = Math.PI / 2;
|
|
||||||
right.rotation.y = Math.PI / 2;
|
|
||||||
const front = MeshBuilder.CreatePlane("back", {sideOrientation: Mesh.DOUBLESIDE, width: width - .3, height: .35}, scene);
|
|
||||||
front.material = material;
|
|
||||||
front.position.y = height - .35 / 2;
|
|
||||||
front.position.z = .9 / 2;
|
|
||||||
const width2 = width * .9;
|
|
||||||
for (let i = 0; i < 5; i++) {
|
|
||||||
const l = Scalar.Lerp(-width2 / 2, width2 / 2, (width / 5) * i);
|
|
||||||
const light = new SpotLight("light", new Vector3(l, 2, (.9 / 2) - .01),
|
|
||||||
new Vector3(0, 0, -1), Math.PI / 1.5, 5, scene);
|
|
||||||
light.intensity = .3;
|
|
||||||
}
|
|
||||||
|
|
||||||
SceneLoader.LoadAssetContainer("/assets/textures/washer/LG Trom Wash Tower Object Collection_2color/LG Trom Wash Tower_white/", "LG Trom Wash.gltf", scene,
|
|
||||||
(container: AssetContainer) => {
|
|
||||||
const model = container.instantiateModelsToScene(undefined, false, {doNotInstantiate: true});
|
|
||||||
const node = model.rootNodes[0];
|
|
||||||
node.scaling.scaleInPlace(.00098);
|
|
||||||
node.position.x -= .42;
|
|
||||||
const bounds = node.getHierarchyBoundingVectors(true);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
31
src/vrApp.ts
31
src/vrApp.ts
@ -1,12 +1,12 @@
|
|||||||
import {Color3, Engine, FreeCamera, Scene, Vector3, WebGPUEngine} from "@babylonjs/core";
|
import {Color3, Engine, FreeCamera, Scene, Vector3, WebGPUEngine} from "@babylonjs/core";
|
||||||
import '@babylonjs/loaders';
|
//import '@babylonjs/loaders';
|
||||||
import {DiagramManager} from "./diagram/diagramManager";
|
import {DiagramManager} from "./diagram/diagramManager";
|
||||||
import log, {Logger} from "loglevel";
|
import log, {Logger} from "loglevel";
|
||||||
import {GamepadManager} from "./controllers/gamepadManager";
|
import {GamepadManager} from "./controllers/gamepadManager";
|
||||||
import {CustomEnvironment} from "./util/customEnvironment";
|
import {CustomEnvironment} from "./util/customEnvironment";
|
||||||
import {Spinner} from "./objects/spinner";
|
import {Spinner} from "./objects/spinner";
|
||||||
import {PouchdbPersistenceManager} from "./integration/pouchdbPersistenceManager";
|
import {PouchdbPersistenceManager} from "./integration/pouchdbPersistenceManager";
|
||||||
import {addSceneInspector} from "./util/functions/sceneInspctor";
|
import {addSceneInspector} from "./util/functions/sceneInspector";
|
||||||
import {groundMeshObserver} from "./util/functions/groundMeshObserver";
|
import {groundMeshObserver} from "./util/functions/groundMeshObserver";
|
||||||
import {buildQuestLink} from "./util/functions/buildQuestLink";
|
import {buildQuestLink} from "./util/functions/buildQuestLink";
|
||||||
import {exportGltf} from "./util/functions/exportGltf";
|
import {exportGltf} from "./util/functions/exportGltf";
|
||||||
@ -23,39 +23,28 @@ export class VrApp {
|
|||||||
private logger: Logger = log.getLogger('App');
|
private logger: Logger = log.getLogger('App');
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
||||||
this.initializeEngine().then(() => {
|
this.initializeEngine().then(() => {
|
||||||
this.logger.info('Engine initialized');
|
this.logger.info('Engine initialized');
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initialize() {
|
public async initialize() {
|
||||||
const scene = DefaultScene.Scene;
|
const scene = DefaultScene.Scene;
|
||||||
|
const camera: FreeCamera = new FreeCamera("Main Camera",
|
||||||
|
new Vector3(0, 1.6, 0), scene);
|
||||||
|
scene.setActiveCameraByName("Main Camera");
|
||||||
const spinner = new Spinner();
|
const spinner = new Spinner();
|
||||||
spinner.show();
|
spinner.show();
|
||||||
|
|
||||||
const diagramManager = new DiagramManager();
|
const diagramManager = new DiagramManager();
|
||||||
const db = new PouchdbPersistenceManager();
|
const db = new PouchdbPersistenceManager();
|
||||||
db.setDiagramManager(diagramManager);
|
db.setDiagramManager(diagramManager);
|
||||||
await db.initialize();
|
await db.initialize();
|
||||||
|
|
||||||
const camera: FreeCamera = new FreeCamera("Main Camera",
|
|
||||||
new Vector3(0, 1.6, 0), scene);
|
|
||||||
//camera.setTarget(new Vector3(0, 1.6, -3));
|
|
||||||
scene.setActiveCameraByName("Main Camera");
|
|
||||||
const environment = new CustomEnvironment("default", diagramManager.config);
|
const environment = new CustomEnvironment("default", diagramManager.config);
|
||||||
environment.groundMeshObservable.add((ground) => {
|
environment.groundMeshObservable.add((ground) => {
|
||||||
groundMeshObserver(ground, diagramManager, spinner);
|
groundMeshObserver(ground, diagramManager, spinner);
|
||||||
}, -1, false, this);
|
}, -1, false, this);
|
||||||
|
|
||||||
const gamepadManager = new GamepadManager(scene);
|
const gamepadManager = new GamepadManager(scene);
|
||||||
/*
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
addSceneInspector();
|
addSceneInspector();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -92,8 +81,8 @@ export class VrApp {
|
|||||||
exportGltf();
|
exportGltf();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.logger.info('keydown event listener added, use Ctrl+Shift+Alt+I to toggle debug layer');
|
|
||||||
if (!localStorage.getItem('tutorialCompleted')) {
|
if (!localStorage.getItem('tutorialCompleted')) {
|
||||||
|
this.logger.info('Starting tutorial');
|
||||||
const intro = new Introduction();
|
const intro = new Introduction();
|
||||||
}
|
}
|
||||||
this.engine.runRenderLoop(() => {
|
this.engine.runRenderLoop(() => {
|
||||||
@ -110,27 +99,19 @@ export class VrApp {
|
|||||||
} else {
|
} else {
|
||||||
this.engine = new Engine(canvas, true);
|
this.engine = new Engine(canvas, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.engine.setHardwareScalingLevel(1 / window.devicePixelRatio);
|
this.engine.setHardwareScalingLevel(1 / window.devicePixelRatio);
|
||||||
|
|
||||||
window.onresize = () => {
|
window.onresize = () => {
|
||||||
this.engine.resize();
|
this.engine.resize();
|
||||||
}
|
}
|
||||||
const scene = new Scene(this.engine);
|
const scene = new Scene(this.engine);
|
||||||
scene.ambientColor = new Color3(.1, .1, .1);
|
scene.ambientColor = new Color3(.1, .1, .1);
|
||||||
DefaultScene.Scene = scene;
|
DefaultScene.Scene = scene;
|
||||||
|
|
||||||
//log.resetLevel();
|
//log.resetLevel();
|
||||||
//log.setDefaultLevel('error');
|
//log.setDefaultLevel('error');
|
||||||
this.logger.debug('App', 'gameCanvas created');
|
this.logger.debug('App', 'gameCanvas created');
|
||||||
await this.initialize();
|
await this.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async start() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const vrApp = new VrApp();
|
const vrApp = new VrApp();
|
||||||
buildQuestLink();
|
buildQuestLink();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user