+ 1
How can I change this from 2d to 3d
var context = canvas.getContext("2d"); var x = 0; var y = 100;
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
+ 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