File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
mode/libraries/vr/src/processing/vr Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change 2323package processing .vr ;
2424
2525import processing .core .PApplet ;
26+ import processing .core .PMatrix3D ;
2627import processing .core .PVector ;
2728
2829public class VRCamera {
2930 protected PApplet parent ;
3031 protected VRGraphics graphics ;
31- protected PVector pos = new PVector () ;
32+ protected PMatrix3D eyeMat ;
3233
3334 public VRCamera (PApplet parent ) {
3435 if (parent .g instanceof VRGraphics ) {
@@ -49,14 +50,11 @@ public void noSticky() {
4950 }
5051
5152 public void setPosition (float x , float y , float z ) {
52- if (pos .x != x || pos .y != y || pos .z != z ) {
53- graphics .beginCamera ();
54- // Eliminate previous position from matrix stack by applying inverse transformation.
55- graphics .translate (-pos .x , -pos .y , -pos .z );
56- pos .set (-x , -y , -z );
57- graphics .translate (pos .x , pos .y , pos .z );
58- graphics .endCamera ();
59- }
53+ eyeMat = graphics .getEyeMatrix (eyeMat );
54+ float x0 = eyeMat .m03 ;
55+ float y0 = eyeMat .m13 ;
56+ float z0 = eyeMat .m23 ;
57+ graphics .translate (x0 - x , y0 - y , z0 - z );
6058 }
6159
6260 public void setNear (float near ) {
You can’t perform that action at this time.
0 commit comments