@@ -410,8 +410,24 @@ AFRAME.registerComponent('metadata', {
410
410
sceneTitle : { default : '' } ,
411
411
sceneId : { default : '' }
412
412
} ,
413
+ init : function ( ) { } ,
414
+ update : function ( oldData ) {
415
+ const sceneTitle = this . data . sceneTitle ;
416
+ if ( sceneTitle !== oldData . sceneTitle ) {
417
+ this . el . emit ( 'newTitle' , { sceneTitle : sceneTitle } ) ;
418
+ }
419
+ }
420
+ } ) ;
421
+
422
+ AFRAME . registerComponent ( 'scene-title' , {
423
+ schema : {
424
+ titleText : { default : '' }
425
+ } ,
413
426
init : function ( ) {
414
427
this . titleElement = undefined ;
428
+ this . el . addEventListener ( 'newTitle' , ( evt ) => {
429
+ this . el . setAttribute ( 'scene-title' , 'titleText' , evt . detail . sceneTitle ) ;
430
+ } ) ;
415
431
} ,
416
432
createTitleElement : function ( titleText ) {
417
433
const titleDiv = this . titleElement = document . createElement ( 'div' ) ;
@@ -428,10 +444,10 @@ AFRAME.registerComponent('metadata', {
428
444
// No need to update.
429
445
if ( Object . keys ( oldData ) . length === 0 ) { return ; }
430
446
431
- const titleText = this . data . sceneTitle ;
447
+ const titleText = this . data . titleText ;
432
448
const titleElement = this . titleElement ;
433
449
434
- if ( titleText !== oldData . sceneTitle ) {
450
+ if ( titleText !== oldData . titleText ) {
435
451
if ( ! titleElement ) {
436
452
this . createTitleElement ( titleText ) ;
437
453
} else {
0 commit comments