Removed sounds, beginning to refactor how sound interactions are handled.
This commit is contained in:
parent
8cf12bc91c
commit
d7e812d253
@ -2,7 +2,6 @@ import {AbstractMesh, ActionManager, Color3, InstancedMesh, Mesh, Observable, Sc
|
|||||||
import {DiagramEvent, DiagramEventType} from "./types/diagramEntity";
|
import {DiagramEvent, DiagramEventType} from "./types/diagramEntity";
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
import {Controllers} from "../controllers/controllers";
|
import {Controllers} from "../controllers/controllers";
|
||||||
import {DiaSounds} from "../util/diaSounds";
|
|
||||||
import {AppConfig} from "../util/appConfig";
|
import {AppConfig} from "../util/appConfig";
|
||||||
import {Toolbox} from "../toolbox/toolbox";
|
import {Toolbox} from "../toolbox/toolbox";
|
||||||
import {PresentationManager} from "./presentationManager";
|
import {PresentationManager} from "./presentationManager";
|
||||||
@ -28,7 +27,7 @@ export class DiagramManager {
|
|||||||
private readonly logger = log.getLogger('DiagramManager');
|
private readonly logger = log.getLogger('DiagramManager');
|
||||||
private readonly toolbox: Toolbox;
|
private readonly toolbox: Toolbox;
|
||||||
private readonly _scene: Scene;
|
private readonly _scene: Scene;
|
||||||
private readonly sounds: DiaSounds;
|
|
||||||
|
|
||||||
constructor(scene: Scene) {
|
constructor(scene: Scene) {
|
||||||
this._config = new AppConfig();
|
this._config = new AppConfig();
|
||||||
@ -48,11 +47,11 @@ export class DiagramManager {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.sounds = new DiaSounds(scene);
|
|
||||||
this._scene = scene;
|
this._scene = scene;
|
||||||
this.toolbox = new Toolbox(scene);
|
this.toolbox = new Toolbox(scene);
|
||||||
this.presentationManager = new PresentationManager(this._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()) {
|
if (this.onDiagramEventObservable.hasObservers()) {
|
||||||
this.logger.warn("onDiagramEventObservable already has Observers, you should be careful");
|
this.logger.warn("onDiagramEventObservable already has Observers, you should be careful");
|
||||||
@ -121,7 +120,7 @@ export class DiagramManager {
|
|||||||
newMesh.material = mesh.material;
|
newMesh.material = mesh.material;
|
||||||
newMesh.metadata = deepCopy(mesh.metadata);
|
newMesh.metadata = deepCopy(mesh.metadata);
|
||||||
if (this._config.current?.physicsEnabled) {
|
if (this._config.current?.physicsEnabled) {
|
||||||
applyPhysics(this.sounds, newMesh, this._scene);
|
applyPhysics(newMesh, this._scene);
|
||||||
}
|
}
|
||||||
return newMesh;
|
return newMesh;
|
||||||
}
|
}
|
||||||
@ -129,6 +128,6 @@ export class DiagramManager {
|
|||||||
private onDiagramEvent(event: DiagramEvent) {
|
private onDiagramEvent(event: DiagramEvent) {
|
||||||
diagramEventHandler(
|
diagramEventHandler(
|
||||||
event, this._scene, this.toolbox, this._config.current.physicsEnabled,
|
event, this._scene, this.toolbox, this._config.current.physicsEnabled,
|
||||||
this.diagramEntityActionManager, this.sounds);
|
this.diagramEntityActionManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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 {ControllerEventType, Controllers} from "../../controllers/controllers";
|
||||||
import {DiaSounds} from "../../util/diaSounds";
|
|
||||||
import log from "loglevel";
|
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 logger = log.getLogger('buildEntityActionManager');
|
||||||
const actionManager = new ActionManager(scene);
|
const actionManager = new ActionManager(scene);
|
||||||
actionManager.registerAction(
|
/*actionManager.registerAction(
|
||||||
new PlaySoundAction(ActionManager.OnPointerOverTrigger, sounds.tick));
|
new PlaySoundAction(ActionManager.OnPointerOverTrigger, sounds.tick));*/
|
||||||
actionManager.registerAction(
|
actionManager.registerAction(
|
||||||
new ExecuteCodeAction(ActionManager.OnPointerOverTrigger, (evt) => {
|
new ExecuteCodeAction(ActionManager.OnPointerOverTrigger, (evt) => {
|
||||||
controllers.controllerObserver.notifyObservers({
|
controllers.controllerObserver.notifyObservers({
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import {applyPhysics} from "./diagramShapePhysics";
|
|||||||
import {ActionManager, PhysicsMotionType, Scene} from "@babylonjs/core";
|
import {ActionManager, PhysicsMotionType, Scene} from "@babylonjs/core";
|
||||||
import {updateTextNode} from "../../util/functions/updateTextNode";
|
import {updateTextNode} from "../../util/functions/updateTextNode";
|
||||||
import {Toolbox} from "../../toolbox/toolbox";
|
import {Toolbox} from "../../toolbox/toolbox";
|
||||||
import {DiaSounds} from "../../util/diaSounds";
|
|
||||||
|
|
||||||
import {buildMeshFromDiagramEntity} from "./buildMeshFromDiagramEntity";
|
import {buildMeshFromDiagramEntity} from "./buildMeshFromDiagramEntity";
|
||||||
import {isDiagramEntity} from "./isDiagramEntity";
|
import {isDiagramEntity} from "./isDiagramEntity";
|
||||||
@ -14,8 +13,7 @@ export function diagramEventHandler(event: DiagramEvent,
|
|||||||
scene: Scene,
|
scene: Scene,
|
||||||
toolbox: Toolbox,
|
toolbox: Toolbox,
|
||||||
physicsEnabled: boolean,
|
physicsEnabled: boolean,
|
||||||
actionManager: ActionManager,
|
actionManager: ActionManager) {
|
||||||
sounds: DiaSounds) {
|
|
||||||
const entity = event.entity;
|
const entity = event.entity;
|
||||||
let mesh;
|
let mesh;
|
||||||
if (event.type == DiagramEventType.REMOVE) {
|
if (event.type == DiagramEventType.REMOVE) {
|
||||||
@ -31,7 +29,7 @@ export function diagramEventHandler(event: DiagramEvent,
|
|||||||
if (mesh) {
|
if (mesh) {
|
||||||
mesh.actionManager = actionManager;
|
mesh.actionManager = actionManager;
|
||||||
if (physicsEnabled) {
|
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;
|
mesh.actionManager = actionManager;
|
||||||
}
|
}
|
||||||
if (physicsEnabled) {
|
if (physicsEnabled) {
|
||||||
applyPhysics(sounds, mesh, scene);
|
applyPhysics(mesh, scene);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DiagramEventType.MODIFY:
|
case DiagramEventType.MODIFY:
|
||||||
if (mesh && physicsEnabled) {
|
if (mesh && physicsEnabled) {
|
||||||
applyPhysics(sounds, mesh, scene);
|
applyPhysics(mesh, scene);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DiagramEventType.REMOVE:
|
case DiagramEventType.REMOVE:
|
||||||
@ -82,7 +80,7 @@ export function diagramEventHandler(event: DiagramEvent,
|
|||||||
} else {
|
} else {
|
||||||
mesh.dispose();
|
mesh.dispose();
|
||||||
}
|
}
|
||||||
sounds.exit.play();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import {DiaSounds} from "../../util/diaSounds";
|
|
||||||
import {AbstractMesh, PhysicsAggregate, PhysicsBody, PhysicsMotionType, PhysicsShapeType, Scene} from "@babylonjs/core";
|
import {AbstractMesh, PhysicsAggregate, PhysicsBody, PhysicsMotionType, PhysicsShapeType, Scene} from "@babylonjs/core";
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
import {isDiagramEntity} from "./isDiagramEntity";
|
import {isDiagramEntity} from "./isDiagramEntity";
|
||||||
@ -6,7 +5,7 @@ import {isDiagramEntity} from "./isDiagramEntity";
|
|||||||
const logger = log.getLogger('DiagramShapePhysics');
|
const logger = log.getLogger('DiagramShapePhysics');
|
||||||
const MASS_FACTOR = 10;
|
const MASS_FACTOR = 10;
|
||||||
|
|
||||||
export function applyPhysics(sounds: DiaSounds,
|
export function applyPhysics(
|
||||||
mesh: AbstractMesh,
|
mesh: AbstractMesh,
|
||||||
scene: Scene,
|
scene: Scene,
|
||||||
motionType?: PhysicsMotionType) {
|
motionType?: PhysicsMotionType) {
|
||||||
@ -43,14 +42,14 @@ export function applyPhysics(sounds: DiaSounds,
|
|||||||
applyMotionType(motionType, body, mesh);
|
applyMotionType(motionType, body, mesh);
|
||||||
|
|
||||||
body.setCollisionCallbackEnabled(true);
|
body.setCollisionCallbackEnabled(true);
|
||||||
body.getCollisionObservable().add((event) => {
|
/*body.getCollisionObservable().add((event) => {
|
||||||
if (event.impulse < 10 && event.impulse > 1) {
|
if (event.impulse < 10 && event.impulse > 1) {
|
||||||
const sound = sounds.bounce;
|
const sound = sounds.bounce;
|
||||||
sound.setVolume(event.impulse / 10);
|
sound.setVolume(event.impulse / 10);
|
||||||
sound.attachToMesh(mesh);
|
sound.attachToMesh(mesh);
|
||||||
sound.play();
|
sound.play();
|
||||||
}
|
}
|
||||||
}, -1, false);
|
}, -1, false);*/
|
||||||
applyPhysicsDefaults(body);
|
applyPhysicsDefaults(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import {AbstractMesh, MeshBuilder, Observable, Scene, Vector3} from "@babylonjs/
|
|||||||
import log, {Logger} from "loglevel";
|
import log, {Logger} from "loglevel";
|
||||||
import {AdvancedDynamicTexture, Control, InputText, VirtualKeyboard} from "@babylonjs/gui";
|
import {AdvancedDynamicTexture, Control, InputText, VirtualKeyboard} from "@babylonjs/gui";
|
||||||
import {ControllerEventType, Controllers} from "../controllers/controllers";
|
import {ControllerEventType, Controllers} from "../controllers/controllers";
|
||||||
import {DiaSounds} from "../util/diaSounds";
|
|
||||||
import {Handle} from "../objects/handle";
|
import {Handle} from "../objects/handle";
|
||||||
|
|
||||||
export type TextEvent = {
|
export type TextEvent = {
|
||||||
@ -14,7 +13,7 @@ export class InputTextView {
|
|||||||
public readonly onTextObservable: Observable<TextEvent> = new Observable<TextEvent>();
|
public readonly onTextObservable: Observable<TextEvent> = new Observable<TextEvent>();
|
||||||
private readonly scene: Scene;
|
private readonly scene: Scene;
|
||||||
private readonly inputMesh: AbstractMesh;
|
private readonly inputMesh: AbstractMesh;
|
||||||
private sounds: DiaSounds;
|
|
||||||
private readonly controllers: Controllers;
|
private readonly controllers: Controllers;
|
||||||
|
|
||||||
private readonly handle: Handle;
|
private readonly handle: Handle;
|
||||||
@ -25,7 +24,7 @@ export class InputTextView {
|
|||||||
constructor(scene: Scene, controllers: Controllers) {
|
constructor(scene: Scene, controllers: Controllers) {
|
||||||
this.controllers = controllers;
|
this.controllers = controllers;
|
||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
this.sounds = new DiaSounds(scene);
|
|
||||||
this.inputMesh = MeshBuilder.CreatePlane("input", {width: 1, height: .5}, this.scene);
|
this.inputMesh = MeshBuilder.CreatePlane("input", {width: 1, height: .5}, this.scene);
|
||||||
this.handle = new Handle(this.inputMesh);
|
this.handle = new Handle(this.inputMesh);
|
||||||
this.createKeyboard();
|
this.createKeyboard();
|
||||||
@ -117,7 +116,7 @@ export class InputTextView {
|
|||||||
});
|
});
|
||||||
|
|
||||||
keyboard.onPointerDownObservable.add(() => {
|
keyboard.onPointerDownObservable.add(() => {
|
||||||
this.sounds.tick.play();
|
/*this.sounds.tick.play();*/
|
||||||
});
|
});
|
||||||
keyboard.onKeyPressObservable.add((key) => {
|
keyboard.onKeyPressObservable.add((key) => {
|
||||||
if (key === '↵') {
|
if (key === '↵') {
|
||||||
|
|||||||
@ -2,14 +2,12 @@ import {AdvancedDynamicTexture, CheckboxGroup, RadioGroup, SelectionPanel, Stack
|
|||||||
import {MeshBuilder, Scene, TransformNode, Vector3, WebXRDefaultExperience} from "@babylonjs/core";
|
import {MeshBuilder, Scene, TransformNode, Vector3, WebXRDefaultExperience} from "@babylonjs/core";
|
||||||
import {AppConfig} from "../util/appConfig";
|
import {AppConfig} from "../util/appConfig";
|
||||||
import {Controllers} from "../controllers/controllers";
|
import {Controllers} from "../controllers/controllers";
|
||||||
import {DiaSounds} from "../util/diaSounds";
|
|
||||||
import {AbstractMenu} from "./abstractMenu";
|
import {AbstractMenu} from "./abstractMenu";
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
|
|
||||||
const logger = log.getLogger('ConfigMenu');
|
const logger = log.getLogger('ConfigMenu');
|
||||||
|
|
||||||
export class ConfigMenu extends AbstractMenu {
|
export class ConfigMenu extends AbstractMenu {
|
||||||
private sounds: DiaSounds;
|
|
||||||
private config: AppConfig;
|
private config: AppConfig;
|
||||||
private readonly baseTransform: TransformNode;
|
private readonly baseTransform: TransformNode;
|
||||||
private gridSnaps: Array<{ label: string, value: number }> = [
|
private gridSnaps: Array<{ label: string, value: number }> = [
|
||||||
|
|||||||
@ -10,13 +10,11 @@ import {
|
|||||||
PhysicsShapeType,
|
PhysicsShapeType,
|
||||||
PointsCloudSystem,
|
PointsCloudSystem,
|
||||||
Scene,
|
Scene,
|
||||||
Sound,
|
|
||||||
Texture,
|
Texture,
|
||||||
TransformNode,
|
TransformNode,
|
||||||
Vector3
|
Vector3
|
||||||
} from "@babylonjs/core";
|
} from "@babylonjs/core";
|
||||||
import {CustomPhysics} from "./customPhysics";
|
import {CustomPhysics} from "./customPhysics";
|
||||||
import {DiaSounds} from "./diaSounds";
|
|
||||||
import {AppConfig} from "./appConfig";
|
import {AppConfig} from "./appConfig";
|
||||||
import {GridMaterial} from "@babylonjs/materials";
|
import {GridMaterial} from "@babylonjs/materials";
|
||||||
|
|
||||||
@ -48,7 +46,7 @@ export class CustomEnvironment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private initSounds() {
|
private initSounds() {
|
||||||
try {
|
/* try {
|
||||||
const sounds = new DiaSounds(this.scene);
|
const sounds = new DiaSounds(this.scene);
|
||||||
window.setTimeout((sound) => {
|
window.setTimeout((sound) => {
|
||||||
sound.play()
|
sound.play()
|
||||||
@ -78,6 +76,8 @@ export class CustomEnvironment {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
public get groundMeshObservable() {
|
public get groundMeshObservable() {
|
||||||
return this._groundMeshObservable;
|
return this._groundMeshObservable;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import {AbstractMesh, WebXRDefaultExperience, WebXRState} from "@babylonjs/core";
|
import {AbstractMesh, WebXRDefaultExperience, WebXRMotionControllerManager, WebXRState} from "@babylonjs/core";
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
import {WebController} from "../../controllers/webController";
|
import {WebController} from "../../controllers/webController";
|
||||||
import {ConfigMenu} from "../../menus/configMenu";
|
import {ConfigMenu} from "../../menus/configMenu";
|
||||||
@ -11,11 +11,14 @@ const logger = log.getLogger('groungMeshObserver');
|
|||||||
export async function groundMeshObserver(ground: AbstractMesh,
|
export async function groundMeshObserver(ground: AbstractMesh,
|
||||||
diagramManager: DiagramManager,
|
diagramManager: DiagramManager,
|
||||||
spinner: Spinner) {
|
spinner: Spinner) {
|
||||||
|
WebXRMotionControllerManager.PrioritizeOnlineRepository = false;
|
||||||
|
WebXRMotionControllerManager.UseOnlineRepository = true;
|
||||||
const xr = await WebXRDefaultExperience.CreateAsync(ground.getScene(), {
|
const xr = await WebXRDefaultExperience.CreateAsync(ground.getScene(), {
|
||||||
floorMeshes: [ground],
|
floorMeshes: [ground],
|
||||||
disableHandTracking: true,
|
disableHandTracking: true,
|
||||||
disableTeleportation: true,
|
disableTeleportation: true,
|
||||||
disableDefaultUI: true,
|
disableDefaultUI: true,
|
||||||
|
disableNearInteraction: true,
|
||||||
outputCanvasOptions: {
|
outputCanvasOptions: {
|
||||||
canvasOptions: {
|
canvasOptions: {
|
||||||
framebufferScaleFactor: 1
|
framebufferScaleFactor: 1
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user