diff --git a/config.js b/config.js index 0f612d7..fb6919f 100644 --- a/config.js +++ b/config.js @@ -44,15 +44,13 @@ export const config = { uri : `${BASE_URI}/scenes/ssgp/`, popup: theater2Popup, coords: [45.4401, 12.3408], - nodes: { - groups: [ + nodes: [ { label: 'Teatro', - layers: [ + children: [ { label: 'Struttura complessiva', model: 'models/ssgp/Teatro_SSGP_Full_ConSottrazioni.glb', - //isMain: true, }, { label: 'Involucro', @@ -64,30 +62,35 @@ export const config = { }, { label: 'Sala / Auditorium', - layers: [ + children: [ { label: 'Peplano / Platea', model: 'models/ssgp/Teatro_SSGP_Platea_peplano.glb', }, { - label: 'Ordine 1', - model: 'models/ssgp/Teatro_SSGP_Ordine1.glb', - }, - { - label: 'Ordine 2', - model: 'models/ssgp/Teatro_SSGP_Ordine2.glb', - }, - { - label: 'Ordine 3', - model: 'models/ssgp/Teatro_SSGP_Ordine3.glb', - }, - { - label: 'Ordine 4', - model: 'models/ssgp/Teatro_SSGP_Ordine4.glb', - }, - { - label: 'Ordine 5', - model: 'models/ssgp/Teatro_SSGP_Ordine5.glb', + label: 'Ordini di palchi', + children: [ + { + label: 'Ordine 1', + model: 'models/ssgp/Teatro_SSGP_Ordine1.glb', + }, + { + label: 'Ordine 2', + model: 'models/ssgp/Teatro_SSGP_Ordine2.glb', + }, + { + label: 'Ordine 3', + model: 'models/ssgp/Teatro_SSGP_Ordine3.glb', + }, + { + label: 'Ordine 4', + model: 'models/ssgp/Teatro_SSGP_Ordine4.glb', + }, + { + label: 'Ordine 5', + model: 'models/ssgp/Teatro_SSGP_Ordine5.glb', + }, + ] }, { label: 'Parapetto', @@ -101,7 +104,7 @@ export const config = { }, { label: 'Scena', - layers: [ + children: [ { label: 'Palcoscenico', model: 'models/ssgp/Teatro_SSGP_Palcoscenico.glb', @@ -122,36 +125,37 @@ export const config = { }, { label: 'Spazi tecnici', - layers: [ + children: [ { label: 'Spazio tecnico superiore', model: 'models/ssgp/Teatro_SSGP_Layer_Spazio_tecnico_sup_soffitta.glb', - }, - { - label: 'Graticcia', - model: 'models/ssgp/Teatro_SSGP_Graticcia.glb', - }, - { - label: 'Ballatoio', - model: 'models/ssgp/Teatro_SSGP_Ballatoio.glb', - }, - { - label: 'Spazio tecnico inferiore', - model: 'models/ssgp/Teatro_SSGP_Spazio_tecnico_inf.glb', + children: [ + { + label: 'Graticcia', + model: 'models/ssgp/Teatro_SSGP_Graticcia.glb', + }, + { + label: 'Ballatoio', + model: 'models/ssgp/Teatro_SSGP_Ballatoio.glb', + }, + { + label: 'Spazio tecnico inferiore', + model: 'models/ssgp/Teatro_SSGP_Spazio_tecnico_inf.glb', + }, + ] }, ] }, { label: 'Orchestra', - layers: [ + children: [ { label: 'Fossa orchestra', model: 'models/ssgp/Teatro_SSGP_Fossa_orchestra.glb', }, ] } - ], - }, + ], pano: `pano/gradient.jpg`, } ], diff --git a/js/scene.js b/js/scene.js index a36086e..bc1860b 100644 --- a/js/scene.js +++ b/js/scene.js @@ -232,18 +232,21 @@ Scene.resetClipping = function () { } /** * @param {Object} marker - The marker object from config + * @param {Object[]} nodes - The flat list of nodes for this scene */ -Scene.openScene = function(marker) { +Scene.openScene = function(marker, nodes) { Scene.init(); + // TODO: move to init logic Scene.UI.toggleClipperBar('#clipper', '#clipper-bar'); + // Filter nodes with models first + nodes = nodes.filter(n => n.model); // Load 3D models and create nodes - Scene.loadNodes(marker.nodes); + Scene.loadNodes(nodes); ATON.setMainPanorama(marker.pano); // TODO: hardcoded... AppState.initialRotation = new THREE.Vector3(0, 1.5, 0); - //Scene.showEdges(mainNode); ATON.setAutoLP(config.scene.autoLP); AppState.lightProbe = config.scene.autoLP; @@ -254,7 +257,7 @@ Scene.openScene = function(marker) { /** * - * @param {Array} nodes + * @param {Object[]} nodes */ Scene.loadNodes = function (nodes) { nodes.forEach(n => { @@ -264,7 +267,11 @@ Scene.loadNodes = function (nodes) { // Apply any transparency before attaching to scene if (n.opacity) { - node.setMaterial(new THREE.MeshPhongMaterial({transparent: true, opacity: n.opacity, color: '#fff'})); + node.setMaterial(new THREE.MeshPhongMaterial({ + transparent: true, + opacity: n.opacity, + color: '#fff' + })); } node.attachToRoot(); @@ -275,7 +282,6 @@ Scene.loadNodes = function (nodes) { AppState.clipping.boundingSphere = node.getBound(); } - AppState.nodes.push({id: n.label, active: true}); }); } diff --git a/js/state.js b/js/state.js index 5e95990..6f46dae 100644 --- a/js/state.js +++ b/js/state.js @@ -8,6 +8,7 @@ let AppState = { root: null, // {id: String, active: Boolean} nodes: [], + normalizedNodes: [], mainNodeId: null, currentScene: null, sceneHasAudio: false, diff --git a/js/ui.js b/js/ui.js index eb9dd52..7126e94 100644 --- a/js/ui.js +++ b/js/ui.js @@ -9,7 +9,7 @@ const UI = {}; UI.domParser = new DOMParser; UI.contentMenuTabs = ` - +
-