Rewrite scene switching logic (with bugs!!)
This commit is contained in:
79
js/state.js
79
js/state.js
@@ -1,10 +1,13 @@
|
||||
export const AppState = {
|
||||
/**
|
||||
* @namespace AppState
|
||||
*/
|
||||
let AppState = {
|
||||
// The root scene object
|
||||
root: null,
|
||||
mainNodeId: null,
|
||||
initialRotation: null,
|
||||
camera: ATON.Nav._camera,
|
||||
renderer: ATON._renderer,
|
||||
camera: null,
|
||||
renderer: null,
|
||||
scenes : [],
|
||||
ambientOcclusion : true,
|
||||
shadows : true,
|
||||
@@ -16,48 +19,46 @@ export const AppState = {
|
||||
controls: null,
|
||||
onDrag: null,
|
||||
helper : null,
|
||||
// Change to boundingSphere
|
||||
boundingSphere: null,
|
||||
listeners: {
|
||||
button: false,
|
||||
plane: false,
|
||||
},
|
||||
vector: null,
|
||||
},
|
||||
/**
|
||||
* Reset the overall app state
|
||||
* to default values but keep map
|
||||
*
|
||||
* @param {L.Map} map - The Leaflet map object
|
||||
*/
|
||||
resetSceneState(map) {
|
||||
AppState = {
|
||||
root: null,
|
||||
mainNodeId: null,
|
||||
initialRotation: null,
|
||||
camera: null,
|
||||
renderer: null,
|
||||
scenes : [],
|
||||
ambientOcclusion : true,
|
||||
shadows : true,
|
||||
lightProbe : false,
|
||||
map,
|
||||
clipping : {
|
||||
enabled: false,
|
||||
plane : null,
|
||||
controls: null,
|
||||
onDrag: null,
|
||||
helper : null,
|
||||
boundingSphere: null,
|
||||
listeners: {
|
||||
button: false,
|
||||
plane: false,
|
||||
},
|
||||
vector: null,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Buggyyyyy!!!!
|
||||
* @param {String} id
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
export function getSceneStatus(id) {
|
||||
return AppState.scenes.find(s => s.id === id).active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Buggyyyyy!!!!
|
||||
* @param {String} id
|
||||
* @param {Boolean} status
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
export function setSceneStatus(id, status) {
|
||||
AppState.scenes.find(s => s.id === id).active = status;
|
||||
}
|
||||
|
||||
export function getCurrentScene() {
|
||||
return AppState.scenes.find(s => s.current);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {String} id The scene's id
|
||||
* @returns
|
||||
*/
|
||||
export function setCurrentScene(id) {
|
||||
// First set the correct status for the other scenes
|
||||
let otherScenes = AppState.scenes.filter(s => s.id !== id);
|
||||
otherScenes.forEach(scene => scene.current = false)
|
||||
|
||||
AppState.scenes.find(s => s.id === id).current = true;
|
||||
}
|
||||
export default AppState;
|
||||
Reference in New Issue
Block a user