Fixed bug with turn snap
This commit is contained in:
parent
559108281f
commit
425a9e99e6
@ -1,6 +1,5 @@
|
|||||||
import {AdvancedDynamicTexture, RadioGroup, SelectionPanel} from "@babylonjs/gui";
|
import {AdvancedDynamicTexture, RadioGroup, SelectionPanel} from "@babylonjs/gui";
|
||||||
import {AbstractMesh, MeshBuilder, Scene, WebXRDefaultExperience} from "@babylonjs/core";
|
import {AbstractMesh, MeshBuilder, Scene, WebXRDefaultExperience} from "@babylonjs/core";
|
||||||
import log from "loglevel";
|
|
||||||
import {AppConfig} from "../util/appConfig";
|
import {AppConfig} from "../util/appConfig";
|
||||||
import {ControllerEventType, Controllers} from "../controllers/controllers";
|
import {ControllerEventType, Controllers} from "../controllers/controllers";
|
||||||
import {DiaSounds} from "../util/diaSounds";
|
import {DiaSounds} from "../util/diaSounds";
|
||||||
@ -78,7 +77,7 @@ export class ConfigMenu extends AbstractMenu {
|
|||||||
selectionPanel.addGroup(radio);
|
selectionPanel.addGroup(radio);
|
||||||
|
|
||||||
for (const [index, snap] of this.gridSnaps.entries()) {
|
for (const [index, snap] of this.gridSnaps.entries()) {
|
||||||
const selected = this.config.current.createSnap == snap.value
|
const selected = (this.config.current.createSnap == snap.value);
|
||||||
radio.addRadio(snap.label, this.createVal.bind(this), selected);
|
radio.addRadio(snap.label, this.createVal.bind(this), selected);
|
||||||
}
|
}
|
||||||
return radio;
|
return radio;
|
||||||
@ -88,7 +87,7 @@ export class ConfigMenu extends AbstractMenu {
|
|||||||
const radio = new RadioGroup("Rotation Snap");
|
const radio = new RadioGroup("Rotation Snap");
|
||||||
selectionPanel.addGroup(radio);
|
selectionPanel.addGroup(radio);
|
||||||
for (const [index, snap] of this.rotationSnaps.entries()) {
|
for (const [index, snap] of this.rotationSnaps.entries()) {
|
||||||
const selected = this.config.current.rotateSnap == snap.value
|
const selected = (this.config.current.rotateSnap == snap.value);
|
||||||
radio.addRadio(snap.label, this.rotateVal.bind(this), selected);
|
radio.addRadio(snap.label, this.rotateVal.bind(this), selected);
|
||||||
}
|
}
|
||||||
return radio;
|
return radio;
|
||||||
@ -100,7 +99,7 @@ export class ConfigMenu extends AbstractMenu {
|
|||||||
selectionPanel.addGroup(radio);
|
selectionPanel.addGroup(radio);
|
||||||
|
|
||||||
for (const [index, snap] of this.gridSnaps.entries()) {
|
for (const [index, snap] of this.gridSnaps.entries()) {
|
||||||
const selected = this.config.current.gridSnap == snap.value;
|
const selected = (this.config.current.gridSnap == snap.value);
|
||||||
|
|
||||||
radio.addRadio(snap.label, this.gridVal.bind(this), selected);
|
radio.addRadio(snap.label, this.gridVal.bind(this), selected);
|
||||||
}
|
}
|
||||||
@ -111,46 +110,26 @@ export class ConfigMenu extends AbstractMenu {
|
|||||||
const radio = new RadioGroup("Turn Snap");
|
const radio = new RadioGroup("Turn Snap");
|
||||||
selectionPanel.addGroup(radio);
|
selectionPanel.addGroup(radio);
|
||||||
for (const [index, snap] of this.rotationSnaps.entries()) {
|
for (const [index, snap] of this.rotationSnaps.entries()) {
|
||||||
const selected = this.config.current.rotateSnap == snap.value;
|
const selected = (this.config.current.turnSnap == snap.value);
|
||||||
radio.addRadio(snap.label, this.turnVal.bind(this), selected);
|
radio.addRadio(snap.label, this.turnVal.bind(this), selected);
|
||||||
}
|
}
|
||||||
return radio;
|
return radio;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createVal(value) {
|
private createVal(value) {
|
||||||
const config = this.config.current;
|
this.config.setCreateSnap(this.gridSnaps[value].value);
|
||||||
if (config.createSnap != this.gridSnaps[value].value) {
|
|
||||||
config.createSnap = this.gridSnaps[value].value;
|
|
||||||
this.config.current = config;
|
|
||||||
|
|
||||||
log.debug("configMenu", "create Snap", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private rotateVal(value) {
|
private rotateVal(value) {
|
||||||
const config = this.config.current;
|
this.config.setRotateSnap(this.rotationSnaps[value].value);
|
||||||
if (config.rotateSnap != this.rotationSnaps[value].value) {
|
|
||||||
config.rotateSnap = this.rotationSnaps[value].value;
|
|
||||||
this.config.current = config;
|
|
||||||
log.debug("configMenu", "rotate Snap", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private turnVal(value) {
|
private turnVal(value) {
|
||||||
const config = this.config.current;
|
this.config.setTurnSnap(this.rotationSnaps[value].value);
|
||||||
config.turnSnap = this.rotationSnaps[value].value;
|
|
||||||
this.config.current = config;
|
|
||||||
log.debug("configMenu", "turn Snap", value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private gridVal(value) {
|
private gridVal(value) {
|
||||||
const config = this.config.current;
|
this.config.setGridSnap(this.gridSnaps[value].value);
|
||||||
config.gridSnap = this.gridSnaps[value].value;
|
|
||||||
this.config.current = config;
|
|
||||||
log.debug("configMenu", "grid Snap", value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -6,6 +6,17 @@ export class AppConfig {
|
|||||||
private _currentConfig: AppConfigType;
|
private _currentConfig: AppConfigType;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
this._currentConfig = {
|
||||||
|
id: 1,
|
||||||
|
gridSnap: .1,
|
||||||
|
rotateSnap: 45,
|
||||||
|
createSnap: .1,
|
||||||
|
turnSnap: 22.5,
|
||||||
|
newRelicKey: null,
|
||||||
|
newRelicAccount: null,
|
||||||
|
physicsEnabled: false,
|
||||||
|
demoCompleted: false,
|
||||||
|
};
|
||||||
this.onConfigChangedObservable.add((config, state) => {
|
this.onConfigChangedObservable.add((config, state) => {
|
||||||
console.log(state);
|
console.log(state);
|
||||||
this._currentConfig = config;
|
this._currentConfig = config;
|
||||||
@ -13,24 +24,29 @@ export class AppConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get current(): AppConfigType {
|
public get current(): AppConfigType {
|
||||||
if (!this._currentConfig) {
|
|
||||||
|
|
||||||
this._currentConfig = {
|
|
||||||
id: 1,
|
|
||||||
gridSnap: .1,
|
|
||||||
rotateSnap: 45,
|
|
||||||
createSnap: .1,
|
|
||||||
turnSnap: 22.5,
|
|
||||||
newRelicKey: null,
|
|
||||||
newRelicAccount: null,
|
|
||||||
physicsEnabled: false,
|
|
||||||
demoCompleted: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return this._currentConfig;
|
return this._currentConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setRotateSnap(value: number) {
|
||||||
|
this._currentConfig.rotateSnap = value;
|
||||||
|
this.onConfigChangedObservable.notifyObservers(this._currentConfig, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public setCreateSnap(value: number) {
|
||||||
|
this._currentConfig.createSnap = value;
|
||||||
|
this.onConfigChangedObservable.notifyObservers(this._currentConfig, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public setTurnSnap(value: number) {
|
||||||
|
this._currentConfig.turnSnap = value;
|
||||||
|
this.onConfigChangedObservable.notifyObservers(this._currentConfig, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public setGridSnap(value: number) {
|
||||||
|
this._currentConfig.gridSnap = value;
|
||||||
|
this.onConfigChangedObservable.notifyObservers(this._currentConfig, 2);
|
||||||
|
}
|
||||||
|
|
||||||
public set current(config: AppConfigType) {
|
public set current(config: AppConfigType) {
|
||||||
this._currentConfig = config;
|
this._currentConfig = config;
|
||||||
this.onConfigChangedObservable.notifyObservers(config, 2);
|
this.onConfigChangedObservable.notifyObservers(config, 2);
|
||||||
|
|||||||
@ -37,6 +37,8 @@ ctx.onmessage = (event) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.data.config) {
|
if (event.data.config) {
|
||||||
|
console.log('updateing config');
|
||||||
|
console.log(event.data.config);
|
||||||
persistenceManager.setConfig(event.data.config);
|
persistenceManager.setConfig(event.data.config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user