@@ -397,18 +397,6 @@ function vtkCamera(publicAPI, model) {
397
397
398
398
mat4 . scale ( result , result , tmpvec1 ) ;
399
399
mat4 . translate ( result , result , model . physicalTranslation ) ;
400
-
401
- // let rot = mat4.identity(new Float64Array(16));
402
- //mat4.fromRotation(rot, model.physicalYawAngle / 180 * 3.14, model.physicalViewUp);
403
- //// mat4.invert(rot, rot);
404
- //mat4.mul(result, rot, result);
405
-
406
- //let tmpRot = mat4.identity(new Float64Array(16));
407
- //let matInv = mat4.identity(new Float64Array(16));
408
- //mat4.rotateY(tmpRot, tmpRot, model.physicalYawAngle / 180 * 3.14);
409
- //mat4.transpose(tmpRot, tmpRot);
410
- //mat4.invert(matInv, )
411
- // mat4.mul(result, tmpRot, result);
412
400
} ;
413
401
414
402
publicAPI . applyPhysicalYaw = ( angle ) => {
@@ -422,48 +410,18 @@ function vtkCamera(publicAPI, model) {
422
410
423
411
publicAPI . computeViewParametersFromViewMatrix = ( vmat ) => {
424
412
// invert to get view to world
425
- let worldToViewPos = new Float64Array ( 4 ) ;
426
413
let viewToWorldPos = new Float64Array ( 4 ) ;
427
414
let v2wMatrix = new Float64Array ( 16 ) ;
428
- worldToViewPos [ 0 ] = vmat [ 12 ] ;
429
- worldToViewPos [ 1 ] = vmat [ 13 ] ;
430
- worldToViewPos [ 2 ] = vmat [ 14 ] ;
431
- worldToViewPos [ 3 ] = 1 ;
432
415
mat4 . invert ( v2wMatrix , vmat ) ;
416
+
433
417
viewToWorldPos [ 0 ] = v2wMatrix [ 12 ] ;
434
418
viewToWorldPos [ 1 ] = v2wMatrix [ 13 ] ;
435
419
viewToWorldPos [ 2 ] = v2wMatrix [ 14 ] ;
436
420
viewToWorldPos [ 3 ] = 1 ;
421
+
437
422
mat4 . copy ( tmpMatrix , v2wMatrix ) ;
438
- //console.log('View -> World');
439
- //console.log(v2wMatrix);
440
- //mat4.copy(tmpMatrix, vmat);
441
- //v[0] = tmpMatrix[12]; //tmpMatrix[12] = 0;
442
- //tmpMatrix[13] = 0;
443
- //tmpMatrix[14] = 0;
444
- //mat4.invert(tmpMatrix, tmpMatrix);
445
-
446
- ////
447
- ////
448
- //// mat4.invert(tmpMatrix, tmpMatrix);
449
- //// mat4.rotateY(tmpMatrix, tmpMatrix, model.physicalYawAngle / 180 * 3.14);
450
- //// mat4.translate(tmpMatrix, tmpMatrix, [-v[0], -v[1], -v[2]]);
451
-
452
- ////// Correct center of rotation, incorrect view translation
453
- ////mat4.invert(tmpMatrix, tmpMatrix);
454
- ////mat4.rotateY(tmpMatrix, tmpMatrix, model.physicalYawAngle / 180 * 3.14);
455
-
456
- //// Correct view translation, incorrect center of rotation
457
- //// mat4.invert(tmpMatrix, tmpMatrix););
458
- ////let tmp = mat4.identity(new Float64Array(16));
459
- ////tmpMatrix[12] = 0;
460
- ////tmpMatrix[14] = 0;
461
- //mat4.invert(tmpMatrix, tmpMatrix);
462
-
463
- let w2vTranslate = mat4 . identity ( new Float64Array ( 16 ) ) ;
423
+
464
424
let rotate = mat4 . identity ( new Float64Array ( 16 ) ) ;
465
- let rotateRev = mat4 . identity ( new Float64Array ( 16 ) ) ;
466
- let w2vTranslateReverse = mat4 . identity ( new Float64Array ( 16 ) ) ;
467
425
let v2wTranslate = mat4 . identity ( new Float64Array ( 16 ) ) ;
468
426
let v2wTranslateReverse = mat4 . identity ( new Float64Array ( 16 ) ) ;
469
427
@@ -473,48 +431,11 @@ function vtkCamera(publicAPI, model) {
473
431
- viewToWorldPos [ 2 ] ,
474
432
] ) ;
475
433
mat4 . rotateY ( rotate , rotate , ( model . physicalYawAngle / 180 ) * 3.14 ) ;
476
- mat4 . rotateY (
477
- rotateRev ,
478
- rotateRev ,
479
- ( ( - 1 * model . physicalYawAngle ) / 180 ) * 3.14
480
- ) ;
481
434
mat4 . translate ( v2wTranslateReverse , v2wTranslateReverse , viewToWorldPos ) ;
482
- mat4 . translate ( w2vTranslate , w2vTranslate , [
483
- - worldToViewPos [ 0 ] ,
484
- - worldToViewPos [ 1 ] ,
485
- - worldToViewPos [ 2 ] ,
486
- ] ) ;
487
- mat4 . translate ( w2vTranslateReverse , w2vTranslateReverse , worldToViewPos ) ;
488
-
489
- //mat4.mul(tmpMatrix, w2vTranslate, vmat);
490
- //mat4.mul(tmpMatrix, rotate, tmpMatrix);
491
- //mat4.mul(tmpMatrix, w2vTranslateReverse, tmpMatrix);
492
- //mat4.invert(tmpMatrix, tmpMatrix);
493
-
494
- // FIXME works post-snap? mat4.mul(v2wTranslateReverse, v2wTranslate, rotate);
495
- // mat4.mul(v2wTranslate, v2wTranslate, rotate);
496
- //mat4.mul(v2wTranslateReverse, v2wTranslateReverse, rotate);
497
- mat4 . mul ( v2wTranslateReverse , v2wTranslate , rotate ) ;
498
- mat4 . mul ( tmpMatrix , v2wTranslateReverse , v2wMatrix ) ;
499
- mat4 . mul ( tmpMatrix , tmpMatrix , rotate ) ;
500
- mat4 . mul ( tmpMatrix , v2wTranslate , tmpMatrix ) ;
501
435
502
- //mat4.rotateY(tmpMatrix, tmpMatrix, -1 * model.physicalYawAngle / 180 * 3.14);
503
- //mat4.translate(tmpMatrix, tmpMatrix, [0, 0, 0.01 * model.physicalYawAngle]);
504
- //mat4.translate(tmpMatrix, tmpMatrix, v);
505
- //mat4.invert(tmpMatrix, tmpMatrix);
506
- ////
507
- //mat4.invert(tmpMatrix, tmpMatrix);
508
- //tmpMatrix[12] = v[0];
509
- //tmpMatrix[13] = v[1];
510
- //tmpMatrix[14] = v[2];
511
-
512
- // FIXME try pushing through the cone position at <0,0,-1>
513
- //v[0] = 0;
514
- //v[1] = 0;
515
- //v[1] = -1;
516
- //vec3.transformMat4(tmpvec1, v, tmpMatrix);
517
- // console.log(v);
436
+ mat4 . mul ( tmpMatrix , v2wTranslate , v2wMatrix ) ;
437
+ mat4 . mul ( tmpMatrix , tmpMatrix , rotate ) ;
438
+ mat4 . mul ( tmpMatrix , v2wTranslateReverse , tmpMatrix ) ;
518
439
519
440
// note with glmatrix operations happen in
520
441
// the reverse order
0 commit comments