@@ -6,11 +6,13 @@ var selectedID; // view-hierarchy-list active list item id
66var isClippedContentShown = true ;
77
88// constant variables
9- var MESHBORDERDEFAULTCOLOR = 0xA9A9A9 ; // mesh border default color
10- var MESHBORDERSELECTEDCOLOR = 0x457CD3 ; // mesh border selected color
11- var kSiderbarWidth = 300 ;
12- var kNavigationSidebarShownKey = 'kNavigationSidebarShownKey' ;
13- var kPropertySidebarShownKey = 'kPropertySidebarShownKey' ;
9+ const MESHBORDERDEFAULTCOLOR = 0xA9A9A9 ; // mesh border default color
10+ const MESHBORDERSELECTEDCOLOR = 0x457CD3 ; // mesh border selected color
11+ const kSiderbarWidth = 300 ;
12+ const kNavigationSidebarShownKey = 'kNavigationSidebarShownKey' ;
13+ const kPropertySidebarShownKey = 'kPropertySidebarShownKey' ;
14+ const kViewDataKeyDescription = 'description' ;
15+ const kViewDataKeyParent = 'parent' ;
1416
1517/* THREE */
1618var camera ;
@@ -110,6 +112,9 @@ function onViewHierarchyNavigationItemClick(id) {
110112 viewData . three . wireframe . material . color . setHex ( MESHBORDERSELECTEDCOLOR ) ;
111113 }
112114
115+ // update navigation toolbar
116+ generateNavigationToolbarHTML ( viewData ) ;
117+
113118 // update property list
114119 generateViewPropertyListHTML ( viewData ) ;
115120}
@@ -123,7 +128,7 @@ function generateViewHierarchyListHTML() {
123128 for ( var i = 0 ; i < allViewsData . length ; i ++ ) {
124129 // parse data
125130 var viewData = allViewsData [ i ] ;
126- var title = viewData [ 'description' ] ;
131+ var title = viewData [ kViewDataKeyDescription ] ;
127132 var depth = viewData [ 'hierarchyDepth' ] ;
128133
129134 // create li element
@@ -143,7 +148,7 @@ function generateViewHierarchyListHTML() {
143148 spanEle = tmpSpanEle ;
144149 j -- ;
145150 }
146- spanEle . innerHTML = title ;
151+ spanEle . innerHTML = i + ';' + title + ' p: ' + viewData [ 'parent' ] + '; c: ' + JSON . stringify ( viewData [ 'children' ] ) ;
147152
148153 ulEle . appendChild ( liEle ) ;
149154 }
@@ -156,6 +161,38 @@ function generateViewHierarchyListHTML() {
156161 listEle . appendChild ( ulEle ) ;
157162}
158163
164+ function generateNavigationToolbarHTML ( viewData ) {
165+ const navToolbarEle = document . querySelector ( '.navigation-toolbar' ) ;
166+ // remove all HTMLElement
167+ while ( navToolbarEle . firstChild ) {
168+ navToolbarEle . removeChild ( navToolbarEle . firstChild ) ;
169+ }
170+
171+ let guardViewData = viewData ;
172+ while ( guardViewData ) {
173+ // create HTMLElement item
174+ const itemEle = document . createElement ( 'div' ) ;
175+ itemEle . setAttribute ( 'class' , 'item' ) ;
176+ const title = guardViewData [ kViewDataKeyDescription ] ;
177+ itemEle . innerHTML = title ;
178+
179+ // add HTMLElement item
180+ if ( navToolbarEle . firstChild ) {
181+ navToolbarEle . insertBefore ( itemEle , navToolbarEle . firstChild ) ;
182+ } else {
183+ navToolbarEle . appendChild ( itemEle ) ;
184+ }
185+
186+ // prev item
187+ const parentIdx = guardViewData [ kViewDataKeyParent ] ;
188+ if ( parentIdx >= 0 ) {
189+ guardViewData = allViewsData [ parentIdx ] ;
190+ } else {
191+ guardViewData = null ;
192+ }
193+ }
194+ }
195+
159196function generateViewPropertyListHTML ( viewData ) {
160197 // parse data
161198 var memoryAddress = viewData [ 'memoryAddress' ] ;
@@ -408,41 +445,47 @@ function onShowPropertySidebarClick() {
408445}
409446
410447function showNavigationSidebar ( show ) {
411- var navSidebarEle = document . querySelector ( '.navigation-sidebar' ) ;
412- var navToolbarEle = document . querySelector ( '#canvas-toolbar button.navigator-control' ) ;
413- var toolbarEle = document . querySelector ( '#canvas-toolbar' ) ;
448+ const navSidebarEle = document . querySelector ( '.navigation-sidebar' ) ;
449+ const navToolbarEle = document . querySelector ( '.navigation-toolbar' ) ;
450+ const navCanvasToolbarEle = document . querySelector ( '#canvas-toolbar button.navigator-control' ) ;
451+ const canvasToolbarEle = document . querySelector ( '#canvas-toolbar' ) ;
414452
415453 // update view
416454 if ( show ) {
417455 // show
418456 navSidebarEle . classList . add ( 'active' ) ;
419457 navSidebarEle . style . width = kSiderbarWidth + 'px' ;
420- navToolbarEle . classList . add ( 'selected' ) ;
421- toolbarEle . style . left = kSiderbarWidth + 'px' ;
458+ navToolbarEle . style . left = kSiderbarWidth + 'px' ;
459+ navCanvasToolbarEle . classList . add ( 'selected' ) ;
460+ canvasToolbarEle . style . left = kSiderbarWidth + 'px' ;
422461 } else {
423462 // hide
424463 navSidebarEle . classList . remove ( 'active' ) ;
425- navToolbarEle . classList . remove ( 'selected' ) ;
426- toolbarEle . style . left = 0 ;
464+ navToolbarEle . style . left = 0 ;
465+ navCanvasToolbarEle . classList . remove ( 'selected' ) ;
466+ canvasToolbarEle . style . left = 0 ;
427467 }
428468}
429469
430470function showPropertySidebar ( show ) {
431- var propSidebarEle = document . querySelector ( '.property-sidebar' ) ;
432- var propToolbarEle = document . querySelector ( '#canvas-toolbar button.utilities-control' ) ;
433- var toolbarEle = document . querySelector ( '#canvas-toolbar' ) ;
471+ const propSidebarEle = document . querySelector ( '.property-sidebar' ) ;
472+ const navToolbarEle = document . querySelector ( '.navigation-toolbar' ) ;
473+ const propCanvasToolbarEle = document . querySelector ( '#canvas-toolbar button.utilities-control' ) ;
474+ const canvasToolbarEle = document . querySelector ( '#canvas-toolbar' ) ;
434475
435476 // update view
436477 if ( show ) {
437478 // show
438479 propSidebarEle . classList . add ( 'active' ) ;
439480 propSidebarEle . style . width = kSiderbarWidth + 'px' ;
440- propToolbarEle . classList . add ( 'selected' ) ;
441- toolbarEle . style . right = kSiderbarWidth + 'px' ;
481+ navToolbarEle . style . right = kSiderbarWidth + 'px' ;
482+ propCanvasToolbarEle . classList . add ( 'selected' ) ;
483+ canvasToolbarEle . style . right = kSiderbarWidth + 'px' ;
442484 } else {
443485 // hide
444486 propSidebarEle . classList . remove ( 'active' ) ;
445- propToolbarEle . classList . remove ( 'selected' ) ;
446- toolbarEle . style . right = 0 ;
487+ navToolbarEle . style . right = 0 ;
488+ propCanvasToolbarEle . classList . remove ( 'selected' ) ;
489+ canvasToolbarEle . style . right = 0 ;
447490 }
448491}
0 commit comments