+ 1

How can I change this from 2d to 3d

var context = canvas.getContext("2d"); var x = 0; var y = 100;

1st Nov 2022, 1:58 PM
Doubra
2 Antworten
+ 5
In case you are trying to get a 3d-context (not a 3d display on a 2d context) – it is not called getContext('3d') but getContext('webgl') https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext
1st Nov 2022, 4:53 PM
Lisa
Lisa - avatar
+ 3
By deleting the 2 and typing a 3, I guess... I recommend to check a few tutorials online, about this topic. It would clear your doubt. Sololearn does not have this kind of content available. and coding for 3d transformation, with vanilla JavaScript, requires a lot of math (trigonometry) but therefore most people use libraries like three.js https://www.mamboleoo.be/articles/how-to-render-3d-in-2d-canvas
1st Nov 2022, 2:19 PM
Tibor Santa
Tibor Santa - avatar