Page 1 of 1

Showing 3D object with WebGL

PostPosted: Sun Jan 05, 2020 2:43 am
by jstech
I am using WebGL inside a javascript to display a 3D object. On the page you can select the object to be displayed, among several available options and when selecting one, it appears rotating in 3D.
When successively selecting the different objects available to display, they are always displayed correctly, but the problem is that each time a new object is selected, it rotates a little faster than the previous one.
I would need the initial speed, which is correct, to be maintained instead of increasing.
The code I use to display the selected object is this:

var ps;

cam = new OrbitCam({closest:5, farthest:100, distance: 20});
cam.setOrbitPoint([0,0,0]);

ps = new PointStream();
ps.setup(document.getElementById('canvas') ,{preserveDrawingBuffer:false});

ps.background([0, 0, 0, 0.8]);
ps.pointSize(3);
ps.onRender = render;
ps.onMouseScroll = zoom;
ps.onMousePressed = mousePressed;
ps.onMouseReleased = mouseReleased;


What is missing or incorrect in this code so that the speed is always the same?