Reputation: 52
Q.) I have canvas element and i'm drawing with 2D javascript(papaer js) and 3D javascript(babylon js) on canvas. Now, i want to add/draw image on that canvas in 2D and 3D. I can draw image on canvas using 2D JS(Paper js).
like this,
var canvas = document.getElementById('canvsID');
var context = canvas.getContext('2d');
and i get the result with that.
i want to do same thing with 3D JS. But it wont, work with 3D JS. it is just because my 3D js is continuously rendering.
So, is there any way for that.
I read that you can use getContext() with 3D like this..
var context = canvas.getContext('webgl');
But, still it wont work..! It says "WebGL not supported"
Upvotes: 1
Views: 1746
Reputation: 39926
maybe try
var context = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
Upvotes: 1
Reputation: 1767
a good option would be to use Babylon.js dynamic texture to render your 2d content in a texture and apply it on a background (or foreground) layer:
http://doc.babylonjs.com/classes/2.2/DynamicTexture
http://doc.babylonjs.com/classes/2.2/Layer
Upvotes: 0