diff --git a/src/diagram/diagramManager.ts b/src/diagram/diagramManager.ts index b493488..de77e3e 100644 --- a/src/diagram/diagramManager.ts +++ b/src/diagram/diagramManager.ts @@ -2,7 +2,6 @@ import {AbstractMesh, ActionManager, Color3, InstancedMesh, Mesh, Observable, Sc import {DiagramEvent, DiagramEventType} from "./types/diagramEntity"; import log from "loglevel"; import {Controllers} from "../controllers/controllers"; -import {DiaSounds} from "../util/diaSounds"; import {AppConfig} from "../util/appConfig"; import {Toolbox} from "../toolbox/toolbox"; import {PresentationManager} from "./presentationManager"; @@ -28,7 +27,7 @@ export class DiagramManager { private readonly logger = log.getLogger('DiagramManager'); private readonly toolbox: Toolbox; private readonly _scene: Scene; - private readonly sounds: DiaSounds; + constructor(scene: Scene) { this._config = new AppConfig(); @@ -48,11 +47,11 @@ export class DiagramManager { } }); - this.sounds = new DiaSounds(scene); + this._scene = scene; this.toolbox = new Toolbox(scene); this.presentationManager = new PresentationManager(this._scene); - this.diagramEntityActionManager = buildEntityActionManager(this._scene, this.sounds, this._controllers); + this.diagramEntityActionManager = buildEntityActionManager(this._scene, this._controllers); if (this.onDiagramEventObservable.hasObservers()) { this.logger.warn("onDiagramEventObservable already has Observers, you should be careful"); @@ -121,7 +120,7 @@ export class DiagramManager { newMesh.material = mesh.material; newMesh.metadata = deepCopy(mesh.metadata); if (this._config.current?.physicsEnabled) { - applyPhysics(this.sounds, newMesh, this._scene); + applyPhysics(newMesh, this._scene); } return newMesh; } @@ -129,6 +128,6 @@ export class DiagramManager { private onDiagramEvent(event: DiagramEvent) { diagramEventHandler( event, this._scene, this.toolbox, this._config.current.physicsEnabled, - this.diagramEntityActionManager, this.sounds); + this.diagramEntityActionManager); } } \ No newline at end of file diff --git a/src/diagram/functions/buildEntityActionManager.ts b/src/diagram/functions/buildEntityActionManager.ts index f86e1a3..75e74dd 100644 --- a/src/diagram/functions/buildEntityActionManager.ts +++ b/src/diagram/functions/buildEntityActionManager.ts @@ -1,13 +1,12 @@ -import {ActionManager, ExecuteCodeAction, PlaySoundAction, Scene} from "@babylonjs/core"; +import {ActionManager, ExecuteCodeAction, Scene} from "@babylonjs/core"; import {ControllerEventType, Controllers} from "../../controllers/controllers"; -import {DiaSounds} from "../../util/diaSounds"; import log from "loglevel"; -export function buildEntityActionManager(scene: Scene, sounds: DiaSounds, controllers: Controllers) { +export function buildEntityActionManager(scene: Scene, controllers: Controllers) { const logger = log.getLogger('buildEntityActionManager'); const actionManager = new ActionManager(scene); - actionManager.registerAction( - new PlaySoundAction(ActionManager.OnPointerOverTrigger, sounds.tick)); + /*actionManager.registerAction( + new PlaySoundAction(ActionManager.OnPointerOverTrigger, sounds.tick));*/ actionManager.registerAction( new ExecuteCodeAction(ActionManager.OnPointerOverTrigger, (evt) => { controllers.controllerObserver.notifyObservers({ diff --git a/src/diagram/functions/diagramEventHandler.ts b/src/diagram/functions/diagramEventHandler.ts index 432e1b1..0d9c8d5 100644 --- a/src/diagram/functions/diagramEventHandler.ts +++ b/src/diagram/functions/diagramEventHandler.ts @@ -4,7 +4,6 @@ import {applyPhysics} from "./diagramShapePhysics"; import {ActionManager, PhysicsMotionType, Scene} from "@babylonjs/core"; import {updateTextNode} from "../../util/functions/updateTextNode"; import {Toolbox} from "../../toolbox/toolbox"; -import {DiaSounds} from "../../util/diaSounds"; import {buildMeshFromDiagramEntity} from "./buildMeshFromDiagramEntity"; import {isDiagramEntity} from "./isDiagramEntity"; @@ -14,8 +13,7 @@ export function diagramEventHandler(event: DiagramEvent, scene: Scene, toolbox: Toolbox, physicsEnabled: boolean, - actionManager: ActionManager, - sounds: DiaSounds) { + actionManager: ActionManager) { const entity = event.entity; let mesh; if (event.type == DiagramEventType.REMOVE) { @@ -31,7 +29,7 @@ export function diagramEventHandler(event: DiagramEvent, if (mesh) { mesh.actionManager = actionManager; if (physicsEnabled) { - applyPhysics(sounds, mesh, scene, PhysicsMotionType.DYNAMIC); + applyPhysics(mesh, scene, PhysicsMotionType.DYNAMIC); } } } @@ -62,12 +60,12 @@ export function diagramEventHandler(event: DiagramEvent, mesh.actionManager = actionManager; } if (physicsEnabled) { - applyPhysics(sounds, mesh, scene); + applyPhysics(mesh, scene); } break; case DiagramEventType.MODIFY: if (mesh && physicsEnabled) { - applyPhysics(sounds, mesh, scene); + applyPhysics(mesh, scene); } break; case DiagramEventType.REMOVE: @@ -82,7 +80,7 @@ export function diagramEventHandler(event: DiagramEvent, } else { mesh.dispose(); } - sounds.exit.play(); + } break; } diff --git a/src/diagram/functions/diagramShapePhysics.ts b/src/diagram/functions/diagramShapePhysics.ts index 0c142ea..6739a0b 100644 --- a/src/diagram/functions/diagramShapePhysics.ts +++ b/src/diagram/functions/diagramShapePhysics.ts @@ -1,4 +1,3 @@ -import {DiaSounds} from "../../util/diaSounds"; import {AbstractMesh, PhysicsAggregate, PhysicsBody, PhysicsMotionType, PhysicsShapeType, Scene} from "@babylonjs/core"; import log from "loglevel"; import {isDiagramEntity} from "./isDiagramEntity"; @@ -6,7 +5,7 @@ import {isDiagramEntity} from "./isDiagramEntity"; const logger = log.getLogger('DiagramShapePhysics'); const MASS_FACTOR = 10; -export function applyPhysics(sounds: DiaSounds, +export function applyPhysics( mesh: AbstractMesh, scene: Scene, motionType?: PhysicsMotionType) { @@ -43,14 +42,14 @@ export function applyPhysics(sounds: DiaSounds, applyMotionType(motionType, body, mesh); body.setCollisionCallbackEnabled(true); - body.getCollisionObservable().add((event) => { + /*body.getCollisionObservable().add((event) => { if (event.impulse < 10 && event.impulse > 1) { const sound = sounds.bounce; sound.setVolume(event.impulse / 10); sound.attachToMesh(mesh); sound.play(); } - }, -1, false); + }, -1, false);*/ applyPhysicsDefaults(body); } diff --git a/src/information/inputTextView.ts b/src/information/inputTextView.ts index e165343..5afc6cb 100644 --- a/src/information/inputTextView.ts +++ b/src/information/inputTextView.ts @@ -2,7 +2,6 @@ import {AbstractMesh, MeshBuilder, Observable, Scene, Vector3} from "@babylonjs/ import log, {Logger} from "loglevel"; import {AdvancedDynamicTexture, Control, InputText, VirtualKeyboard} from "@babylonjs/gui"; import {ControllerEventType, Controllers} from "../controllers/controllers"; -import {DiaSounds} from "../util/diaSounds"; import {Handle} from "../objects/handle"; export type TextEvent = { @@ -14,7 +13,7 @@ export class InputTextView { public readonly onTextObservable: Observable = new Observable(); private readonly scene: Scene; private readonly inputMesh: AbstractMesh; - private sounds: DiaSounds; + private readonly controllers: Controllers; private readonly handle: Handle; @@ -25,7 +24,7 @@ export class InputTextView { constructor(scene: Scene, controllers: Controllers) { this.controllers = controllers; this.scene = scene; - this.sounds = new DiaSounds(scene); + this.inputMesh = MeshBuilder.CreatePlane("input", {width: 1, height: .5}, this.scene); this.handle = new Handle(this.inputMesh); this.createKeyboard(); @@ -117,7 +116,7 @@ export class InputTextView { }); keyboard.onPointerDownObservable.add(() => { - this.sounds.tick.play(); + /*this.sounds.tick.play();*/ }); keyboard.onKeyPressObservable.add((key) => { if (key === '↵') { diff --git a/src/menus/configMenu.ts b/src/menus/configMenu.ts index 53ad94f..1a99392 100644 --- a/src/menus/configMenu.ts +++ b/src/menus/configMenu.ts @@ -2,14 +2,12 @@ import {AdvancedDynamicTexture, CheckboxGroup, RadioGroup, SelectionPanel, Stack import {MeshBuilder, Scene, TransformNode, Vector3, WebXRDefaultExperience} from "@babylonjs/core"; import {AppConfig} from "../util/appConfig"; import {Controllers} from "../controllers/controllers"; -import {DiaSounds} from "../util/diaSounds"; import {AbstractMenu} from "./abstractMenu"; import log from "loglevel"; const logger = log.getLogger('ConfigMenu'); export class ConfigMenu extends AbstractMenu { - private sounds: DiaSounds; private config: AppConfig; private readonly baseTransform: TransformNode; private gridSnaps: Array<{ label: string, value: number }> = [ diff --git a/src/util/customEnvironment.ts b/src/util/customEnvironment.ts index 451b468..3690392 100644 --- a/src/util/customEnvironment.ts +++ b/src/util/customEnvironment.ts @@ -10,13 +10,11 @@ import { PhysicsShapeType, PointsCloudSystem, Scene, - Sound, Texture, TransformNode, Vector3 } from "@babylonjs/core"; import {CustomPhysics} from "./customPhysics"; -import {DiaSounds} from "./diaSounds"; import {AppConfig} from "./appConfig"; import {GridMaterial} from "@babylonjs/materials"; @@ -48,7 +46,7 @@ export class CustomEnvironment { } private initSounds() { - try { + /* try { const sounds = new DiaSounds(this.scene); window.setTimeout((sound) => { sound.play() @@ -78,6 +76,8 @@ export class CustomEnvironment { } catch (error) { } + + */ } public get groundMeshObservable() { return this._groundMeshObservable; diff --git a/src/util/functions/groundMeshObserver.ts b/src/util/functions/groundMeshObserver.ts index c05dd02..7c9d569 100644 --- a/src/util/functions/groundMeshObserver.ts +++ b/src/util/functions/groundMeshObserver.ts @@ -1,4 +1,4 @@ -import {AbstractMesh, WebXRDefaultExperience, WebXRState} from "@babylonjs/core"; +import {AbstractMesh, WebXRDefaultExperience, WebXRMotionControllerManager, WebXRState} from "@babylonjs/core"; import log from "loglevel"; import {WebController} from "../../controllers/webController"; import {ConfigMenu} from "../../menus/configMenu"; @@ -11,11 +11,14 @@ const logger = log.getLogger('groungMeshObserver'); export async function groundMeshObserver(ground: AbstractMesh, diagramManager: DiagramManager, spinner: Spinner) { + WebXRMotionControllerManager.PrioritizeOnlineRepository = false; + WebXRMotionControllerManager.UseOnlineRepository = true; const xr = await WebXRDefaultExperience.CreateAsync(ground.getScene(), { floorMeshes: [ground], disableHandTracking: true, disableTeleportation: true, disableDefaultUI: true, + disableNearInteraction: true, outputCanvasOptions: { canvasOptions: { framebufferScaleFactor: 1