There are only three modes of movement in the 3D World: move, rotate, zoom out.
The use of the settimeout function can be used to achieve repeated cyclic processing, then what is the specific approach?
The first argument to the SetTimeout function is the function that is called, and the second parameter is how long it takes (milliseconds) to call this function. If the first parameter is specified as the function that is currently running, then a continuous loop can be implemented.
? function A is called
? In function A, use settimeout and pass in function A as a parameter
After the specified time, function A is called
By following the steps above, the drawing portion of WebGL is written as a recursive function, which can be continuously cycled.
The function's internal invocation of the function itself, can be directly written to the name of the function, but if it is an anonymous function, this approach will not work.
The solution is to use the arguments and Callee attributes to invoke the function itself. The arguments object is generated automatically when a function is called, and the callee property is a reference to the function itself, and even an anonymous function can be recursive if used in this way.
This recursion is done using the Settimeout+arguments.callee combination described here.
WebGL recursive processing and moving? rotation? zoom