@@ -87,6 +87,8 @@ sap.ui.define([
8787 return canvasDOM ;
8888 } ;
8989
90+ pthis . ApplyTemporaryRCoreExtensions ( ) ;
91+
9092 pthis . bootstrap ( ) ;
9193 } ) ;
9294 } else {
@@ -203,6 +205,7 @@ sap.ui.define([
203205 this . renderer . clearColor = "#00000000" ;
204206 this . scene = new RC . Scene ( ) ;
205207 this . overlay_scene = new RC . Scene ( ) ;
208+ this . scene_bbox = new RC . Box3 ( ) ;
206209
207210 this . lights = new RC . Group ;
208211 this . lights . name = "Light container" ;
@@ -470,18 +473,23 @@ sap.ui.define([
470473 this . resetRenderer ( ) ;
471474 }
472475
473- resetRenderer ( )
476+ recalcSceneBBox ( )
474477 {
475- let sbbox = new RC . Box3 ( ) ;
476- sbbox . setFromObject ( this . scene ) ;
477- if ( sbbox . isEmpty ( ) )
478+ this . scene_bbox . setFromObject ( this . scene ) ;
479+ if ( this . scene_bbox . isEmpty ( ) )
478480 {
479- console . error ( "GlViewerRenderCore.resetRenderer scene bbox empty" , sbbox ) ;
481+ console . error ( "GlViewerRenderCore.resetRenderer scene bbox empty" , this . scene_bbox ) ;
480482 const ext = 100 ;
481- sbbox . expandByPoint ( new RC . Vector3 ( - ext , - ext , - ext ) ) ;
482- sbbox . expandByPoint ( new RC . Vector3 ( ext , ext , ext ) ) ;
483+ this . scene_bbox . expandByPoint ( new RC . Vector3 ( - ext , - ext , - ext ) ) ;
484+ this . scene_bbox . expandByPoint ( new RC . Vector3 ( ext , ext , ext ) ) ;
483485 }
486+ }
487+
488+ resetRenderer ( )
489+ {
490+ this . recalcSceneBBox ( ) ;
484491
492+ let sbbox = this . scene_bbox ;
485493 let posV = new RC . Vector3 ; posV . subVectors ( sbbox . max , this . rot_center ) ;
486494 let negV = new RC . Vector3 ; negV . subVectors ( sbbox . min , this . rot_center ) ;
487495
@@ -540,6 +548,19 @@ sap.ui.define([
540548 this . controls . update ( ) ;
541549 }
542550
551+ setupCamera ( )
552+ {
553+ // To be used with JS debugger to edit the values as needed.
554+
555+ let pos = new RC . Vector3 ;
556+ let lookat = new RC . Vector3 ;
557+ let fov = 30 ; // in degrees
558+
559+ console . log ( "A good place to set the breakpoint and edit the values" ) ;
560+
561+ // Call the controller stuff, hope it's not all local, otherwise we need to edit it there.
562+ // Sigh, should really have it (and RedeQuTor) in ROOT.
563+ }
543564
544565 updateViewerAttributes ( )
545566 {
@@ -641,20 +662,28 @@ sap.ui.define([
641662
642663 //==============================================================================
643664
644- request_render ( )
665+ request_render ( recalc_sbbox = false )
645666 {
646667 // console.log("REQUEST RENDER");
647668
669+ this . render_requested_recalc_sbbox ||= recalc_sbbox ;
648670 if ( this . render_requested ) return ;
649671 setTimeout ( this . render . bind ( this ) , 0 ) ;
650672 this . render_requested = true ;
651673 }
652674
653675 render ( )
654676 {
655- // console.log("RENDER", this.scene, this.camera, this.canvas, this.renderer);
677+ console . log ( "RENDER" , this . scene , this . camera , this . canvas , this . renderer ) ;
656678
657679 this . render_requested = false ;
680+ if ( this . render_requested_recalc_sbbox ) {
681+ this . recalcSceneBBox ( ) ;
682+ this . render_requested_recalc_sbbox = false ;
683+ }
684+ if ( this . camera . isPerspectiveCamera ) {
685+ this . camera . optimizeNearFar ( this . scene_bbox ) ;
686+ }
658687
659688 if ( this . canvas . width <= 0 || this . canvas . height <= 0 ) return ;
660689
@@ -1220,6 +1249,25 @@ sap.ui.define([
12201249 </html>` ) ;
12211250 win . document . close ( ) ;
12221251 }
1252+
1253+ //==============================================================================
1254+ // Temporary RCore additions (to avoid updating of RCore.tgz)
1255+ //==============================================================================
1256+
1257+ ApplyTemporaryRCoreExtensions ( ) {
1258+ console . log ( "GlViewerRCore.ApplyTemporaryRCoreExtensions()" ) ;
1259+
1260+ // E.g.:
1261+ // if (RC.PerspectiveCamera.prototype.optimizeNearFar === undefined) {
1262+ // RC.PerspectiveCamera.prototype.optimizeNearFar = function(scene_bbox) {
1263+ // this.matrixWorldInverse.getInverse(this.matrixWorld);
1264+ // // .....
1265+ // };
1266+ // }
1267+ }
1268+
1269+ //==============================================================================
1270+
12231271 } // class GlViewerRCore
12241272
12251273 return GlViewerRCore ;
0 commit comments