This repository was archived by the owner on Nov 7, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -425,10 +425,16 @@ vgl.camera = function (arg) {
425425 * it won't be recomputed unless something else changes.
426426 *
427427 * @param {mat4 } view: new view matrix.
428+ * @param {boolean } preserveType: if true, clone the input using slice. This
429+ * can be used to ensure the array is a specific precision.
428430 */
429431 ////////////////////////////////////////////////////////////////////////////
430- this . setViewMatrix = function ( view ) {
431- mat4 . copy ( m_viewMatrix , view ) ;
432+ this . setViewMatrix = function ( view , preserveType ) {
433+ if ( ! preserveType ) {
434+ mat4 . copy ( m_viewMatrix , view ) ;
435+ } else {
436+ m_viewMatrix = view . slice ( ) ;
437+ }
432438 m_computeModelViewMatrixTime . modified ( ) ;
433439 } ;
434440
Original file line number Diff line number Diff line change @@ -266,8 +266,14 @@ vgl.renderer = function (arg) {
266266 actor = sortedActors [ i ] [ 1 ] ;
267267 if ( actor . referenceFrame ( ) ===
268268 vgl . boundingObject . ReferenceFrame . Relative ) {
269- mat4 . multiply ( renSt . m_modelViewMatrix , m_this . m_camera . viewMatrix ( ) ,
270- actor . matrix ( ) ) ;
269+ var view = m_this . m_camera . viewMatrix ( ) ;
270+ /* If the view matrix is a plain array, keep it as such. This is
271+ * intended to preserve precision, and will only be the case if the
272+ * view matrix was created by delibrately setting it as an array. */
273+ if ( view instanceof Array ) {
274+ renSt . m_modelViewMatrix = new Array ( 16 ) ;
275+ }
276+ mat4 . multiply ( renSt . m_modelViewMatrix , view , actor . matrix ( ) ) ;
271277 renSt . m_projectionMatrix = m_this . m_camera . projectionMatrix ( ) ;
272278 renSt . m_modelViewAlignment = m_this . m_camera . viewAlignment ( ) ;
273279 } else {
You can’t perform that action at this time.
0 commit comments