@@ -187,14 +187,6 @@ this.onRender = function() {
187187 const meshInstance3D = WGE . parseObj ( "torus.obj" , true , ( meshInstance3D ) => {
188188 scene . addNode ( meshInstance3D , - 1 ) ;
189189 window . torus = meshInstance3D ; // Store the torus mesh instance globally for debugging
190-
191- // const torusMaterial = meshInstance3D.getSurfaceMaterial();
192- // // torusMaterial.cullType = WGE.CullType.CULL_NONE;
193- // torusMaterial.color = new WGE.vec4(1, 0, 1, 1);
194- // torusMaterial.setShader( WGE.RendererStorage.getShaderFromName( "mesh_forward", torusMaterial ) );
195-
196- // const torusSurface = meshInstance3D.getSurface( 0 );
197- // meshInstance3D.setSurfaceMaterialOverride( torusSurface, torusMaterial );
198190 } ) ;
199191 }
200192
@@ -241,7 +233,8 @@ this.onRender = function() {
241233 { name : "Sphere" , callback : this . onAddMesh . bind ( this ) } ,
242234 { name : "Capsule" , callback : this . onAddMesh . bind ( this ) } ,
243235 { name : "Cylinder" , callback : this . onAddMesh . bind ( this ) } ,
244- { name : "Torus" , callback : this . onAddMesh . bind ( this ) }
236+ { name : "Torus" , callback : this . onAddMesh . bind ( this ) } ,
237+ { name : "Text" , callback : this . onAddMesh . bind ( this ) } ,
245238 ] } ,
246239 { name : "Light" , submenu : [
247240 { name : "Directional" , callback : this . onAddLight . bind ( this ) } ,
@@ -298,19 +291,20 @@ this.onRender = function() {
298291 {
299292 name : "Translate" ,
300293 icon : "Move" ,
301- callback : ( value , event ) => console . log ( value ) ,
302- selectable : true
294+ callback : this . onGizmoMode . bind ( this ) ,
295+ selectable : true ,
296+ selected : true ,
303297 } ,
304298 {
305299 name : "Rotate" ,
306300 icon : "RotateRight" ,
307- callback : ( value , event ) => console . log ( value ) ,
301+ callback : this . onGizmoMode . bind ( this ) ,
308302 selectable : true
309303 } ,
310304 {
311305 name : "Scale" ,
312306 icon : "Scale3d" ,
313- callback : ( value , event ) => console . log ( value ) ,
307+ callback : this . onGizmoMode . bind ( this ) ,
314308 selectable : true
315309 }
316310 ] ,
@@ -531,7 +525,46 @@ this.onRender = function() {
531525 } ,
532526
533527 onNewScene ( ) {
534- LX . prompt ( "Are you sure you want to create a new scene? This will discard the current scene." , "New Scene" , ( ok ) => { } , { input : false } ) ;
528+ LX . prompt ( "Are you sure you want to create a new scene? This will discard the current scene." , "New Scene" , ( ) => {
529+
530+ this . scene . deleteAll ( ) ;
531+
532+ // Add new environment
533+ {
534+ this . environment = new WGE . Environment3D ( ) ;
535+ this . environment . setTexture ( "test.hdr" ) ;
536+ this . scene . addNode ( this . environment , - 1 ) ;
537+ }
538+
539+ this . sceneTreePanel . refresh ( ) ;
540+ this . selectedNode = null ;
541+
542+ this . objectPanel . clear ( ) ;
543+ this . geometryPanel . clear ( ) ;
544+ this . materialPanel . clear ( ) ;
545+ this . scriptPanel . clear ( ) ;
546+
547+ this . nodePanelTabs . tabDOMs [ "Object" ] . classList . toggle ( "hidden" , true ) ;
548+ this . nodePanelTabs . tabDOMs [ "Geometry" ] . classList . toggle ( "hidden" , true ) ;
549+ this . nodePanelTabs . tabDOMs [ "Material" ] . classList . toggle ( "hidden" , true ) ;
550+ this . nodePanelTabs . tabDOMs [ "Script" ] . classList . toggle ( "hidden" , true ) ;
551+
552+ } , { input : false } ) ;
553+ } ,
554+
555+ onGizmoMode ( mode ) {
556+ switch ( mode )
557+ {
558+ case "Translate" :
559+ this . gizmo . operation = WGE . GizmoOp . TRANSLATE ;
560+ break ;
561+ case "Rotate" :
562+ this . gizmo . operation = WGE . GizmoOp . ROTATE ;
563+ break ;
564+ case "Scale" :
565+ this . gizmo . operation = WGE . GizmoOp . SCALE ;
566+ break ;
567+ }
535568 } ,
536569
537570 onDeleteNode ( ) {
@@ -564,6 +597,12 @@ this.onRender = function() {
564597
565598 const meshInstance = new WGE . MeshInstance3D ( ) ;
566599
600+ if ( geometryType === "Text" )
601+ {
602+ this . addTextMesh ( ) ;
603+ return ;
604+ }
605+
567606 // Create a mesh instance
568607 const geometryClass = WGE [ `${ geometryType } Mesh` ] ;
569608
@@ -622,6 +661,17 @@ this.onRender = function() {
622661 }
623662 } ,
624663
664+ addTextMesh ( ) {
665+
666+ const textInstance = new WGE . Text3D ( "Empty Text" ) ;
667+ textInstance . name = `${ textInstance . mesh . type } _${ LX . guidGenerator ( ) } ` ;
668+ textInstance . generateMesh ( ) ;
669+
670+ this . scene . addNode ( textInstance , - 1 ) ;
671+
672+ this . sceneTreePanel . refresh ( ) ;
673+ } ,
674+
625675 addLight ( ) {
626676 const light = new WGE . DirectionalLight3D ( ) ;
627677 light . setPosition ( new WGE . vec3 ( 0.0 , 5.0 , 0.0 ) ) ;
@@ -646,11 +696,6 @@ this.onRender = function() {
646696
647697 const surfaces = node . mesh . surfaces ;
648698
649- if ( surfaces . size ( ) > 0 )
650- {
651- this . geometryPanel . addSeparator ( ) ;
652- }
653-
654699 for ( let i = 0 ; i < surfaces . size ( ) ; i ++ )
655700 {
656701 const surface = surfaces . get ( i ) ;
@@ -702,7 +747,10 @@ this.onRender = function() {
702747
703748 if ( obj . constructor . properties ?. length )
704749 {
705- panel . branch ( options . propertiesTitle ?? "Properties" , { icon : options . propertiesIcon } ) ;
750+ if ( options . branch ?? true )
751+ {
752+ panel . branch ( options . propertiesTitle ?? "Properties" , { icon : options . propertiesIcon } ) ;
753+ }
706754
707755 for ( let p of obj . constructor . properties )
708756 {
@@ -741,6 +789,23 @@ this.onRender = function() {
741789 case Boolean :
742790 panel . addCheckbox ( widgetName , defaultValue , defaultCallback , { disabled : p . disabled } ) ;
743791 break ;
792+ case WGE . vec2 :
793+ {
794+ const value = obj [ p . name ] ?? new WGE . vec2 ( 0.0 , 0.0 ) ;
795+ panel . addVector2 ( widgetName , [ value . x , value . y ] , value => {
796+ const vec2 = new WGE . vec2 ( value [ 0 ] , value [ 1 ] ) ;
797+ if ( p . setter )
798+ {
799+ p . setter . call ( obj , vec2 ) ;
800+ }
801+ else
802+ {
803+ obj [ p . name ] = vec2 ;
804+ }
805+ LX . emit ( `@on_${ p . name } _changed` , { obj, value } ) ;
806+ } , { min : p . min , max : p . max , step : p . step , disabled : p . disabled } ) ;
807+ break ;
808+ }
744809 case WGE . vec3 :
745810 {
746811 const value = obj [ p . name ] ?? new WGE . vec3 ( 0.0 , 0.0 , 0.0 ) ;
@@ -873,6 +938,32 @@ this.onRender = function() {
873938
874939 break ;
875940 }
941+ case WGE . Skeleton :
942+ {
943+ const skeleton = defaultValue ;
944+
945+ if ( ! panel . addSkeleton )
946+ {
947+ LX . ADD_CUSTOM_WIDGET ( "Skeleton" , {
948+ icon,
949+ default : { } ,
950+ onCreate : ( panel , skeleton , node ) => {
951+ if ( ! skeleton )
952+ {
953+ skeleton = node . skeleton = new WGE . Skeleton ( ) ;
954+ }
955+
956+ this . inspectPropertiesAndMethods ( node , skeleton , panel , false , { branch : false } ) ;
957+ }
958+ } ) ;
959+ }
960+
961+ panel . addSkeleton ( widgetName , skeleton , ( value ) => {
962+ LX . emit ( `@on_${ p . name } _changed` , { obj, value } ) ;
963+ } , skeleton , node ) ;
964+
965+ break ;
966+ }
876967 case WGE . AABB :
877968 {
878969 const aabb = defaultValue ;
0 commit comments