File tree 1 file changed +7
-9
lines changed
mode/libraries/vr/src/processing/vr
1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change 23
23
package processing .vr ;
24
24
25
25
import processing .core .PApplet ;
26
+ import processing .core .PMatrix3D ;
26
27
import processing .core .PVector ;
27
28
28
29
public class VRCamera {
29
30
protected PApplet parent ;
30
31
protected VRGraphics graphics ;
31
- protected PVector pos = new PVector () ;
32
+ protected PMatrix3D eyeMat ;
32
33
33
34
public VRCamera (PApplet parent ) {
34
35
if (parent .g instanceof VRGraphics ) {
@@ -49,14 +50,11 @@ public void noSticky() {
49
50
}
50
51
51
52
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 );
60
58
}
61
59
62
60
public void setNear (float near ) {
You can’t perform that action at this time.
0 commit comments