fixed custom physics and simplified diasounds.ts
This commit is contained in:
parent
23bce14635
commit
26c8fb664f
@ -23,7 +23,6 @@ import {IndexdbPersistenceManager} from "./integration/indexdbPersistenceManager
|
||||
export class App {
|
||||
//preTasks = [havokModule];
|
||||
constructor() {
|
||||
|
||||
const logger = log.getLogger('App');
|
||||
log.setDefaultLevel('warn');
|
||||
const canvas = document.createElement("canvas");
|
||||
@ -49,6 +48,7 @@ export class App {
|
||||
const persistenceManager = new IndexdbPersistenceManager("diagram");
|
||||
const controllers = new Controllers();
|
||||
const toolbox = new Toolbox(scene, controllers);
|
||||
|
||||
const diagramManager = new DiagramManager(scene, controllers, toolbox);
|
||||
diagramManager.setPersistenceManager(persistenceManager);
|
||||
const config = new AppConfig(persistenceManager);
|
||||
@ -60,7 +60,6 @@ export class App {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const camera: ArcRotateCamera = new ArcRotateCamera("Camera", -Math.PI / 2, Math.PI / 2, 4,
|
||||
new Vector3(0, 1.6, 0), scene);
|
||||
|
||||
@ -104,7 +103,6 @@ export class App {
|
||||
|
||||
});
|
||||
|
||||
|
||||
const gamepadManager = new GamepadManager(scene);
|
||||
/*
|
||||
const voiceManager = new VoiceManager();
|
||||
|
||||
@ -14,43 +14,38 @@ export class CustomPhysics {
|
||||
public async initializeAsync() {
|
||||
const havok = await HavokPhysics();
|
||||
const havokPlugin = new HavokPlugin(true, havok);
|
||||
this.scene.enablePhysics(new Vector3(0, -9.8, 0), havokPlugin);
|
||||
this.scene.collisionsEnabled = true;
|
||||
this.scene.onAfterPhysicsObservable.add(() => {
|
||||
this.scene.meshes.forEach((mesh) => {
|
||||
const scene = this.scene;
|
||||
scene.enablePhysics(new Vector3(0, -9.8, 0), havokPlugin);
|
||||
scene.collisionsEnabled = true;
|
||||
scene.onAfterPhysicsObservable.add(() => {
|
||||
scene.meshes.forEach((mesh) => {
|
||||
if (mesh?.metadata?.template && mesh.physicsBody) {
|
||||
const body = mesh.physicsBody;
|
||||
const linearVelocity = new Vector3();
|
||||
body.getLinearVelocityToRef(linearVelocity);
|
||||
if (linearVelocity.length() < .1) {
|
||||
if (true) {
|
||||
|
||||
body.disablePreStep = false;
|
||||
const pos: Vector3 = body.getObjectCenterWorld();
|
||||
const val: Vector3 = this.config.snapGridVal(pos);
|
||||
const val: Vector3 = this.config.snapGridVal(pos,
|
||||
this.config.current.gridSnap);
|
||||
body.transformNode.position.set(val.x, val.y, val.z);
|
||||
const rot: Quaternion =
|
||||
Quaternion.FromEulerVector(this.config.snapRotateVal(body.transformNode.rotationQuaternion.toEulerAngles()))
|
||||
Quaternion.FromEulerVector(
|
||||
this.config.snapRotateVal(body.transformNode.rotationQuaternion.toEulerAngles(),
|
||||
this.config.current.rotateSnap))
|
||||
|
||||
body.transformNode.rotationQuaternion.set(
|
||||
rot.x, rot.y, rot.z, rot.w
|
||||
);
|
||||
|
||||
//mesh.metadata.snapped=true;
|
||||
//(this.scene.getPhysicsEngine().getPhysicsPlugin() as IPhysicsEnginePluginV2).syncTransform(body, body.transformNode);
|
||||
this.scene.onAfterRenderObservable.addOnce(() => {
|
||||
scene.onAfterRenderObservable.addOnce(() => {
|
||||
body.disablePreStep = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
} else {
|
||||
//mesh.metadata.snapped = false;
|
||||
}
|
||||
//mesh.position = mesh.physicsImpostor.physicsBody.position;
|
||||
//mesh.rotationQuaternion = mesh.physicsImpostor.physicsBody.quaternion;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -20,36 +20,22 @@ export class DiaSounds {
|
||||
|
||||
constructor(scene: Scene) {
|
||||
this.scene = scene;
|
||||
this._enter = new Sound("enter", "/assets/sounds/sounds.mp3", this.scene, null, {
|
||||
autoplay: false,
|
||||
loop: false,
|
||||
volume: this.volume,
|
||||
offset: 0,
|
||||
length: 1.0
|
||||
});
|
||||
this._exit = new Sound("exit", "/assets/sounds/sounds.mp3", this.scene, null, {
|
||||
autoplay: false,
|
||||
loop: false,
|
||||
offset: 1,
|
||||
volume: this.volume,
|
||||
length: 1.0
|
||||
});
|
||||
this._high = new Sound("high", "/assets/sounds/sounds.mp3", this.scene, null, {
|
||||
autoplay: false,
|
||||
loop: false,
|
||||
offset: 2,
|
||||
volume: this.volume,
|
||||
length: 1.0
|
||||
});
|
||||
this._low = new Sound("low", "/assets/sounds/sounds.mp3", this.scene, null, {
|
||||
autoplay: false,
|
||||
loop: false,
|
||||
offset: 3,
|
||||
volume: this.volume,
|
||||
length: 1.0
|
||||
});
|
||||
|
||||
const soundSprite = [
|
||||
{obj: "_enter", name: "enter", url: "/assets/sounds/sounds.mp3"},
|
||||
{obj: "_exit", name: "exit", url: "/assets/sounds/sounds.mp3"},
|
||||
{obj: "_high", name: "high", url: "/assets/sounds/sounds.mp3"},
|
||||
{obj: "_low", name: "low", url: "/assets/sounds/sounds.mp3"},
|
||||
];
|
||||
|
||||
soundSprite.forEach((item: { obj: any, name: string, url: string }, idx) => {
|
||||
this[item.obj] = new Sound(item.name, item.url, this.scene, null, {
|
||||
autoplay: false,
|
||||
loop: false,
|
||||
volume: this.volume,
|
||||
offset: idx,
|
||||
length: 1.0
|
||||
});
|
||||
});
|
||||
this._bounce = new Sound("bounce", "/assets/sounds/drumsprite.mp3", this.scene, null, {
|
||||
autoplay: false,
|
||||
loop: false,
|
||||
@ -61,24 +47,27 @@ export class DiaSounds {
|
||||
volume: 1,
|
||||
loop: true
|
||||
});
|
||||
this._birds = new Sound("warbler", "/assets/sounds/warbler.mp3", this.scene, null, {
|
||||
const spatialOptions = {
|
||||
spatialSound: true,
|
||||
autoplay: false,
|
||||
volume: .5,
|
||||
loop: false
|
||||
});
|
||||
this.birds.switchPanningModelToHRTF();
|
||||
this.birds.maxDistance = 40;
|
||||
this._dove = new Sound("dove", "/assets/sounds/dove.mp3", this.scene, null, {
|
||||
spatialSound: true,
|
||||
autoplay: false,
|
||||
volume: .5,
|
||||
loop: false
|
||||
});
|
||||
this._dove.switchPanningModelToHRTF();
|
||||
this._dove.maxDistance = 40;
|
||||
}
|
||||
this._birds = this.buildSpatialSound("warbler", "/assets/sounds/warbler.mp3");
|
||||
this._dove = this.buildSpatialSound("dove", "/assets/sounds/dove.mp3");
|
||||
}
|
||||
|
||||
//this._enter.autoplay = true;
|
||||
private buildSpatialSound(name: string, url: string) {
|
||||
const spatialOptions = {
|
||||
spatialSound: true,
|
||||
autoplay: false,
|
||||
volume: .5,
|
||||
loop: false
|
||||
}
|
||||
const sound = new Sound(name, url, this.scene, null, spatialOptions);
|
||||
sound.switchPanningModelToHRTF();
|
||||
sound.maxDistance = 40;
|
||||
return sound;
|
||||
}
|
||||
|
||||
public get background(): Sound {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user