@@ -25,12 +25,59 @@ import {
2525 prevEvent ,
2626 prevSelectedEvent ,
2727 showWebFiles ,
28+ loadWebFiles ,
2829} from "./files-load.js" ;
2930import { toggleAnimation } from "./animate.js" ;
3031import { resetView , showView , setXY , setYZ , setZX , setPerspective , setOrthographic } from "./display.js" ;
31- import { setDisplayVerticalHeight , setFramerate } from "./setup.js" ;
32+ import { setDisplayVerticalHeight , setFramerate , init , initLight , initControlPanel , run } from "./setup.js" ;
3233import { buildFileSummary , createCSV } from "./analysis.js" ;
3334import { startTutorial } from "./tutorial.js" ;
35+ import { addGroups } from "./tree-view.js" ;
36+
37+ // Initialization of display
38+ function setupKeyboardListeners ( ) {
39+ // Add keyboard listeners for shortcuts
40+ document . addEventListener ( "keydown" , ( e : KeyboardEvent ) => {
41+ // Instead of a button, make output of 3D to JSON a "secret" key binding
42+ if ( e . key === "E" ) {
43+ exportScene ( ) ;
44+ }
45+ if ( e . key === "ArrowUp" && e . shiftKey ) {
46+ zoomIn ( ) ;
47+ }
48+ if ( e . key === "ArrowDown" && e . shiftKey ) {
49+ zoomOut ( ) ;
50+ }
51+ if ( e . key === "ArrowRight" ) {
52+ nextEvent ( ) ;
53+ }
54+ if ( e . key === "ArrowLeft" ) {
55+ prevEvent ( ) ;
56+ }
57+ if ( e . key === "A" ) {
58+ toggleAnimation ( ) ;
59+ }
60+ if ( e . key === "m" ) {
61+ showMass ( ) ;
62+ }
63+ } ) ;
64+ }
65+
66+ function initEventDisplay ( ) {
67+ if ( ispy . initialized ) {
68+ return ;
69+ }
70+ setupKeyboardListeners ( ) ;
71+ init ( ) ;
72+ addGroups ( ) ;
73+ initLight ( ) ;
74+ initControlPanel ( ) ;
75+ loadWebFiles ( ) ;
76+ setLanguage ( ispy . lang ) ;
77+ console . log ( "Initialization complete." ) ;
78+ run ( ) ;
79+ ispy . initialized = true ;
80+ }
3481
3582// Display Controls
3683/**
@@ -123,16 +170,10 @@ function reload() {
123170 */
124171function invertColors ( ) {
125172 const htmlEl = document . documentElement ;
126- assertDefined ( ispy . renderer , "Renderer is not defined" ) ;
127173 ispy . inverted_colors = ! ispy . inverted_colors ;
128-
129- if ( ! ispy . inverted_colors ) {
130- ispy . renderer . setClearColor ( new Color ( 0x232323 ) , 1 ) ;
131- htmlEl . setAttribute ( "data-bs-theme" , "dark" ) ;
132- } else {
133- ispy . renderer . setClearColor ( new Color ( 0xefefef ) , 1 ) ;
134- htmlEl . setAttribute ( "data-bs-theme" , "light" ) ;
135- }
174+ htmlEl . setAttribute ( "data-bs-theme" , ispy . inverted_colors ? "light" : "dark" ) ;
175+ if ( ! ispy . renderer ) return ;
176+ ispy . renderer . setClearColor ( ispy . inverted_colors ? new Color ( 0xefefef ) : new Color ( 0x232323 ) , 1 ) ;
136177}
137178
138179/**
@@ -405,6 +446,7 @@ function switchMain(view: "about" | "display" | "help") {
405446 } ) ;
406447 if ( view === "display" ) {
407448 showToolbarButtons ( ) ;
449+ initEventDisplay ( ) ;
408450 showEventName ( ) ;
409451 } else {
410452 hideToolbarButtons ( ) ;
@@ -463,7 +505,8 @@ export function setupControls() {
463505 const jsBasicsTutorialBtn = getHTMLObject ( "js-basics-tutorial-btn" ) ;
464506 const jsControlsTutorialBtn = getHTMLObject ( "js-controls-tutorial-btn" ) ;
465507 const jsAnalysisTutorialBtn = getHTMLObject ( "js-analysis-tutorial-btn" ) ;
466-
508+ const jsStartBtn = getHTMLObject ( "js-start-event" ) ;
509+
467510 // Tutorial button
468511 jsBasicsTutorialBtn . addEventListener ( "click" , ( ) => {
469512 switchMain ( "display" ) ;
@@ -477,8 +520,9 @@ export function setupControls() {
477520 switchMain ( "display" ) ;
478521 startTutorial ( "analysis" ) ;
479522 } ) ;
480-
523+
481524 // connect functions to the buttons
525+ jsStartBtn . addEventListener ( "click" , ( ) => switchMain ( "display" ) ) ;
482526 jsAboutBtn . addEventListener ( "click" , ( ) => switchMain ( "about" ) ) ;
483527 jsHelpBtn . addEventListener ( "click" , ( ) => switchMain ( "help" ) ) ;
484528 jsDisplayBtn . addEventListener ( "click" , ( ) => switchMain ( "display" ) ) ;
@@ -560,31 +604,3 @@ export function setupControls() {
560604 } ) ;
561605 }
562606}
563-
564- export function setupKeyboardListeners ( ) {
565- // Add keyboard listeners for shortcuts
566- document . addEventListener ( "keydown" , ( e : KeyboardEvent ) => {
567- // Instead of a button, make output of 3D to JSON a "secret" key binding
568- if ( e . key === "E" ) {
569- exportScene ( ) ;
570- }
571- if ( e . key === "ArrowUp" && e . shiftKey ) {
572- zoomIn ( ) ;
573- }
574- if ( e . key === "ArrowDown" && e . shiftKey ) {
575- zoomOut ( ) ;
576- }
577- if ( e . key === "ArrowRight" ) {
578- nextEvent ( ) ;
579- }
580- if ( e . key === "ArrowLeft" ) {
581- prevEvent ( ) ;
582- }
583- if ( e . key === "A" ) {
584- toggleAnimation ( ) ;
585- }
586- if ( e . key === "m" ) {
587- showMass ( ) ;
588- }
589- } ) ;
590- }
0 commit comments