Babylon.js : Problem with the latest release

Using Javascript from SpiderBasic
HPW
Posts: 35
Joined: Thu May 04, 2017 4:25 pm

Re: Babylon.js : Problem with the latest release

Post by HPW »

Hello falsam and Peter,
falsam wrote:
Unfortunately no
So I give it a try and copied Peters Header with the cdn3.2 loadr to every demo of Bjs-master.

In engine.sbi I outcomment this 4 lines:

Code: Select all

Procedure InitEngine(Callback, CanvasGadget = #PB_Ignore)    
;  !require([bjs$v_bjsenginepath + "/babylon.custom.js"], 
;  ! function(t) {
  !   if (BABYLON.Engine.isSupported()) {
  
        If CanvasGadget = #PB_Ignore    
          !$('<canvas>').attr('id', 'renderCanvas')
          ! .css({ width : '100%', height : '100%' })
          ! .appendTo('body');
        Else
          !var selector = $(spider_GadgetID(v_canvasgadget))[0].gadget
          !selector.id = "renderCanvas"
          !selector.style.width = '100%'
          !selector.style.height = '100%'
        EndIf
  
  !     v_bjscanvas = document.getElementById('renderCanvas');
  !     v_bjsengine = new BABYLON.Engine(v_bjscanvas, true, { preserveDrawingBuffer: true, stencil: true });  
  !     window.addEventListener('resize', function(){v_bjsengine.resize(); });  
  !     v_callback()
  !   } else {return false} 
;  ! }
;  !);    
EndProcedure  
Each demo compiles but a few did not Show as expected. (water,terrain etc.)
I guess incompatibiitys between last used custom-build and 3.2

So I do a find and replace on all bfs-examples sb to

Code: Select all

;!        "replace": "</title>\n\n<script src='/sbbjs/babylon.custom.js'></script>"
Now the Demos work again like last original release.

Regards
Andy
Posts: 46
Joined: Sat Feb 15, 2020 5:19 pm
Location: Larnaca, Cyprus
Contact:

Re: Babylon.js : Problem with the latest release

Post by Andy »

Works with v4 :)
Andy
Posts: 46
Joined: Sat Feb 15, 2020 5:19 pm
Location: Larnaca, Cyprus
Contact:

Re: Babylon.js : Problem with the latest release

Post by Andy »

It was working until i actually saved the code in the IDE.

If i run the code below in a new tab in the IDE without saving, it works. I'm still learning the basics. Anyone know whats going on here?

Code: Select all

Enumeration
  #mf
  #mfRender
EndEnumeration

Global BJSEngine, BJSCanvas, Scene

Declare InitEngine(Callback, CanvasGadget = #PB_Ignore)
Declare Start()
Declare InitGame()
Declare CreateScene()

Procedure InitEngine(Callback, CanvasGadget = #PB_Ignore)   
  
  ! require(["babylonjs", "https://cdn.babylonjs.com/babylon.js"], 
  
  ! function(BJS) {
  !   if (BABYLON.Engine.isSupported()) {
  
  If CanvasGadget = #PB_Ignore   
    !$('<canvas>').attr('id', 'renderCanvas')
    ! .css({ width : '100%', height : '100%' })
    ! .appendTo('body');
  Else
    !var selector = $(spider_GadgetID(v_canvasgadget))[0].gadget
    !selector.id = "renderCanvas"
    !selector.style.width = '100%'
    !selector.style.height = '100%'
  EndIf
  
  !     v_bjscanvas = document.getElementById('renderCanvas');
  !     v_bjsengine = new BABYLON.Engine(v_bjscanvas, true, { preserveDrawingBuffer: true, stencil: true });
  !     window.addEventListener('resize', function(){v_bjsengine.resize(); }); 
  !     v_callback()
  !   } else {return false}
  ! }
  !);   
EndProcedure 

Start()

Procedure Start()
  OpenWindow(#mf, 0, 0, 800, 600, "Test", #PB_Window_ScreenCentered)
  CanvasGadget(#mfRender, 0, 0, 800, 600, #PB_Canvas_Transparent)
  InitEngine(@InitGame(), #mfRender)
EndProcedure

Procedure InitGame()
  Scene = CreateScene()
  !v_bjsengine.runRenderLoop(f_renderscene)
EndProcedure

Procedure CreateScene()
  !var scene = new BABYLON.Scene(v_bjsengine);
  
  !var camera = new BABYLON.ArcRotateCamera("Camera", 3 * Math.PI / 4, Math.PI / 4, 4, BABYLON.Vector3.Zero(), scene);
  !camera.attachControl(v_bjscanvas, true);
  
  !var light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(1, 1, 0), scene);
  
  !var box = BABYLON.MeshBuilder.CreateBox("box", {}, scene);
  !return scene
EndProcedure

Procedure RenderScene()
  !v_scene.render();
EndProcedure

User avatar
Paul
Posts: 194
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada
Contact:

Re: Babylon.js : Problem with the latest release

Post by Paul »

Andy wrote:It was working until i actually saved the code in the IDE.

If i run the code below in a new tab in the IDE without saving, it works. I'm still learning the basics. Anyone know whats going on here?
Works fine here using Chrome and SB2.30 running from both IDE and exported to Web Server
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Babylon.js : Problem with the latest release

Post by Peter »

Paul wrote:Works fine here using Chrome and SB2.30 running from both IDE and exported to Web Server
same here.
Andy
Posts: 46
Joined: Sat Feb 15, 2020 5:19 pm
Location: Larnaca, Cyprus
Contact:

Re: Babylon.js : Problem with the latest release

Post by Andy »

I closed the IDE and reopened it. All working ok now. Sorry
Dirk Geppert
Posts: 282
Joined: Fri Sep 22, 2017 7:02 am

Re: Babylon.js : Problem with the latest release

Post by Dirk Geppert »

Good to know, that SpiderBasic 2.30 runs fine now with BabylonJS 4 :D

I recently played around with glTF and GLB files and found out, that BabylonJS directly supports them. :o

-> https://sandbox.babylonjs.com

Would it be possible with SpiderBasic/BabylonJS to load and display a GLB file?
Dirk Geppert
Posts: 282
Joined: Fri Sep 22, 2017 7:02 am

Re: Babylon.js : Problem with the latest release

Post by Dirk Geppert »

That does the job for now..

Code: Select all

<html>
<head>
  <title>Babylon.js Viewer - Display a 3D model</title>
  <script src="https://preview.babylonjs.com/viewer/babylon.viewer.js"></script> 
</head>
<body>
    <babylon model="https://models.babylonjs.com/boombox.glb" templates.main.params.fill-screen="true"></babylon>
</body>
</html>
skinkairewalker
Posts: 120
Joined: Tue Jun 14, 2016 7:17 pm

Re: Babylon.js : Problem with the latest release

Post by skinkairewalker »

Andy wrote:It was working until i actually saved the code in the IDE.

If i run the code below in a new tab in the IDE without saving, it works. I'm still learning the basics. Anyone know whats going on here?

Code: Select all

Enumeration
  #mf
  #mfRender
EndEnumeration

Global BJSEngine, BJSCanvas, Scene

Declare InitEngine(Callback, CanvasGadget = #PB_Ignore)
Declare Start()
Declare InitGame()
Declare CreateScene()

Procedure InitEngine(Callback, CanvasGadget = #PB_Ignore)   
  
  ! require(["babylonjs", "https://cdn.babylonjs.com/babylon.js"], 
  
  ! function(BJS) {
  !   if (BABYLON.Engine.isSupported()) {
  
  If CanvasGadget = #PB_Ignore   
    !$('<canvas>').attr('id', 'renderCanvas')
    ! .css({ width : '100%', height : '100%' })
    ! .appendTo('body');
  Else
    !var selector = $(spider_GadgetID(v_canvasgadget))[0].gadget
    !selector.id = "renderCanvas"
    !selector.style.width = '100%'
    !selector.style.height = '100%'
  EndIf
  
  !     v_bjscanvas = document.getElementById('renderCanvas');
  !     v_bjsengine = new BABYLON.Engine(v_bjscanvas, true, { preserveDrawingBuffer: true, stencil: true });
  !     window.addEventListener('resize', function(){v_bjsengine.resize(); }); 
  !     v_callback()
  !   } else {return false}
  ! }
  !);   
EndProcedure 

Start()

Procedure Start()
  OpenWindow(#mf, 0, 0, 800, 600, "Test", #PB_Window_ScreenCentered)
  CanvasGadget(#mfRender, 0, 0, 800, 600, #PB_Canvas_Transparent)
  InitEngine(@InitGame(), #mfRender)
EndProcedure

Procedure InitGame()
  Scene = CreateScene()
  !v_bjsengine.runRenderLoop(f_renderscene)
EndProcedure

Procedure CreateScene()
  !var scene = new BABYLON.Scene(v_bjsengine);
  
  !var camera = new BABYLON.ArcRotateCamera("Camera", 3 * Math.PI / 4, Math.PI / 4, 4, BABYLON.Vector3.Zero(), scene);
  !camera.attachControl(v_bjscanvas, true);
  
  !var light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(1, 1, 0), scene);
  
  !var box = BABYLON.MeshBuilder.CreateBox("box", {}, scene);
  !return scene
EndProcedure

Procedure RenderScene()
  !v_scene.render();
EndProcedure

i get this errors : https://prnt.sc/yv73va
the.weavster
Posts: 219
Joined: Sat Mar 01, 2014 3:02 pm

Re: Babylon.js : Problem with the latest release

Post by the.weavster »

I think you guys may be interested in this, I tried it with Babylon also and it seems to work (I get BABYLON in the global namespace).
Post Reply