Jump to content

Why Canvas2D Causes Babylon.js Stop Working on Website?


Borislav
 Share

Recommended Posts

11 hours ago, Deltakosh said:

Hello I suggest using GUI instead of canvas2d. But in the meantime you need to reference the canvas2d.js which you can find here: https://github.com/BabylonJS/Extensions/tree/master/canvas2D/dist/preview release

Ugh, I did this

 

<script src="https://www.github.com/BabylonJS/Extensions/blob/master/canvas2D/dist/preview release/babylon.canvas2d.min.js"></script>
<script src="https://www.github.com/BabylonJS/Extensions/blob/master/canvas2D/dist/preview release/babylon.canvas2d.js"></script>
<script src="https://www.github.com/BabylonJS/Extensions/blob/master/canvas2D/dist/preview release/babylon.canvas2d.d.ts"></script>

Doesn't work :(

Link to comment
Share on other sites

What can you see when you click on the link you set in your <script> tag : https://github.com/BabylonJS/Extensions/blob/master/canvas2D/dist/preview release/babylon.canvas2d.min.js  ?

You can see that Github doesn't serve a js file but a web page. Github doesn't allow to download directly js files (or any other files) from its site like a CDN would do.

You have to download the wanted js file and then to host it on your own web server.

Link to comment
Share on other sites

5 minutes ago, jerome said:

What can you see when you click on the link you set in your <script> tag : https://github.com/BabylonJS/Extensions/blob/master/canvas2D/dist/preview release/babylon.canvas2d.min.js  ?

You can see that Github doesn't serve a js file but a web page. Github doesn't allow to download directly js files (or any other files) from its site like a CDN would do.

You have to download the wanted js file and then to host it on your own web server.

Ok, but what about raw ones?

<script src="https://raw.githubusercontent.com/BabylonJS/Extensions/master/canvas2D/dist/preview%20release/babylon.canvas2d.min.js"></script>
<script src="https://raw.githubusercontent.com/BabylonJS/Extensions/master/canvas2D/dist/preview%20release/babylon.canvas2d.js"></script>
<script src="https://raw.githubusercontent.com/BabylonJS/Extensions/master/canvas2D/dist/preview%20release/babylon.canvas2d.d.ts"></script>

These are not web pages. it is just the plain raw text.

Link to comment
Share on other sites

4 hours ago, jerome said:

What can you see when you click on the link you set in your <script> tag : https://github.com/BabylonJS/Extensions/blob/master/canvas2D/dist/preview release/babylon.canvas2d.min.js  ?

You can see that Github doesn't serve a js file but a web page. Github doesn't allow to download directly js files (or any other files) from its site like a CDN would do.

You have to download the wanted js file and then to host it on your own web server.

Is it possible without node.js and npm?

Otherwise, it is impossible since node.js can't install due to an error in my pc(Nearly all programs glitch).

Link to comment
Share on other sites

yep, just download the file here : https://raw.githubusercontent.com/BabylonJS/Extensions/master/canvas2D/dist/preview release/babylon.canvas2d.min.js

Save it on your web server with the name canvasd.min.js in the same folder where you already put your html main page.

and just add the script tag <script src="canvas2d.min.js></script> in this html page. This should be enough.

 

Link to comment
Share on other sites

2 hours ago, jerome said:

yep, just download the file here : https://raw.githubusercontent.com/BabylonJS/Extensions/master/canvas2D/dist/preview release/babylon.canvas2d.min.js

Save it on your web server with the name canvasd.min.js in the same folder where you already put your html main page.

and just add the script tag <script src="canvas2d.min.js></script> in this html page. This should be enough.

 

Okay, i'll try

 

Link to comment
Share on other sites

1 hour ago, Borislav said:

Okay, i'll try

 

Doesn't work.

  <script src="https://www.babylonjs.com/hand.minified-1.2.js"></script>
        <script src="https://preview.babylonjs.com/cannon.js"></script>
        <script src="https://preview.babylonjs.com/oimo.js"></script>
        <script src="https://preview.babylonjs.com/babylon.js"></script>
       <script src="babylon.canvas2d.min.js"> </script>
        <script src="babylon.canvas2d.d.ts"> </script>
        <script src="babylon.canvas2d.js"> </script>

I downloaded the files to the page.

Still, doesn't work.

Link to comment
Share on other sites

15 hours ago, Borislav said:

Doesn't work.


  <script src="https://www.babylonjs.com/hand.minified-1.2.js"></script>
        <script src="https://preview.babylonjs.com/cannon.js"></script>
        <script src="https://preview.babylonjs.com/oimo.js"></script>
        <script src="https://preview.babylonjs.com/babylon.js"></script>
       <script src="babylon.canvas2d.min.js"> </script>
        <script src="babylon.canvas2d.d.ts"> </script>
        <script src="babylon.canvas2d.js"> </script>

I downloaded the files to the page.

Still, doesn't work.

Please help.

Link to comment
Share on other sites

20 minutes ago, jerome said:

Please open your browser console (F12) and check in the network tab what is downloaded and what is not.

Uncaught TypeError: Cannot read property 'getEngine' of undefined
    at ScreenSpaceCanvas2D.Canvas2D [as constructor] (babylon.canvas2d.js:17000)
    at new ScreenSpaceCanvas2D (babylon.canvas2d.js:18776)
    at create (preview.html:41)
    at createScene (preview.html:134)
    at preview.html:370

ppdETLOkSEyHPtr3wgKbWg.png

 

Link to comment
Share on other sites

8 minutes ago, jerome said:

1) did you check that they were all rightly downloaded (status code 200) ?

2) Is your own code starting well after all these downloaded scripts ?

 

@jerome

1. Yes, status code 200, and 304.

2.  It DID work in playground, so that means everything is correct right?

Everything is correct!

 

7UFqU1LyT6W63THzT2y2GQ.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...