+ 2

Is it possible to change camera view with Javascript alone, not with three.js or babylon.js. Just Javascript.?

For example, if I make a 3d cube, is it possible to change the camera angle to any position around that cube with JavaScript alone?

12th Nov 2020, 2:56 PM
Fasasi Sherif
Fasasi Sherif - avatar
4 Réponses
+ 2
If I understand you correctly, yes. The following code is pure CSS: https://code.sololearn.com/W042fu4jIrKY/#html All those properties could be controlled by JavaScript too. transform-style: preserve-3d should help you transform the whole cube by manipulating the transform on a single element in JavaScript.
14th Nov 2020, 7:10 AM
Josh Greig
Josh Greig - avatar
+ 2
Josh Greig Thank you. You're saying the transform property used on the cube will give the effect of a camera rotating around the cube? Is it possible for an actual camera to rotate around the cube?
14th Nov 2020, 8:04 AM
Fasasi Sherif
Fasasi Sherif - avatar
+ 2
Yes. If all you see in 3D is a cube, there is no difference between the cube rotating and the camera rotating around the cube. By camera, you mean the point from which you're viewing the cube, right? On a side note, I linked to another code at https://code.sololearn.com/W042fu4jIrKY/#html because the author of the previous one cleared his code. This other one has simpler code.
14th Nov 2020, 11:23 AM
Josh Greig
Josh Greig - avatar
+ 2
Josh Greig Yes. By camera, I mean the point from which I'm viewing the cube. Okay, so css transform can create that effect. Thanks very much.
14th Nov 2020, 5:01 PM
Fasasi Sherif
Fasasi Sherif - avatar