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

Re: Babylon.js : Problem with the latest release

by HPW Sat Aug 25, 2018 7:29 am

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: 23
Joined: Sat Feb 15, 2020 5:19 pm

Re: Babylon.js : Problem with the latest release

by Andy Sun Feb 16, 2020 4:49 pm

Works with v4 :)
Andy
 
Posts: 23
Joined: Sat Feb 15, 2020 5:19 pm

Re: Babylon.js : Problem with the latest release

by Andy Sun Feb 16, 2020 4:55 pm

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: 101
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada

Re: Babylon.js : Problem with the latest release

by Paul Sun Feb 16, 2020 6:19 pm

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: 774
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080

Re: Babylon.js : Problem with the latest release

by Peter Sun Feb 16, 2020 6:29 pm

Paul wrote:Works fine here using Chrome and SB2.30 running from both IDE and exported to Web Server

same here.
Andy
 
Posts: 23
Joined: Sat Feb 15, 2020 5:19 pm

Re: Babylon.js : Problem with the latest release

by Andy Sun Feb 16, 2020 6:32 pm

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

Re: Babylon.js : Problem with the latest release

by Dirk Geppert Fri Feb 21, 2020 8:03 am

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: 183
Joined: Fri Sep 22, 2017 7:02 am

Re: Babylon.js : Problem with the latest release

by Dirk Geppert Mon Feb 24, 2020 3:19 pm

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>
Return to Javascript

Who is online

Users browsing this forum: No registered users and 1 guest