# PVector orbitPosition

**URL:** https://discourse.processing.org/t/pvector-orbitposition/28542
**Category:** Gallery
**Created:** [March 15, 2021, 5:03am UTC](https://discourse.processing.org/t/pvector-orbitposition/28542 "2021-03-15T05:03:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)
#### Post date: [March 15, 2021, 5:03am UTC](https://discourse.processing.org/t/pvector-orbitposition/28542/1 "2021-03-15T05:03:39Z")

</div>

```auto
PVector orbitPosition;
 
void setup() {
  size(800, 800, P3D);
  smooth(8);
}
void draw() {
  background(0);
 
  ambientLight(128,128,128);
  directionalLight(128,128,128,1,1,0);
 
  orbitPosition = new PVector(1, -1, 1);
  orbitPosition.rotate(frameCount * 0.05);
 
  float distance = 300.0;
 
  float eye_x = orbitPosition.x * distance;
  float eye_y = 0;
  float eye_z = orbitPosition.y * distance;
 
  camera(500, -300, 1000, 0, 0, 0, 0, 1, 0);
 
  if (mousePressed) {
    camera(500, -300, 1000, eye_x, eye_y, eye_z, 0, 1, 0);
  }
 
  pushMatrix(); // the floor
    translate(0, width * 0.2, 0);
    fill(0, 255, 0);
    stroke(0);
    box(1000, 5, 1000);
  popMatrix();
 
  pushMatrix(); // the stationary object
    translate(0, 0, 0);
    fill(0, 0, 255);
    noStroke();
    sphere(width * 0.2);
  popMatrix();
 
  pushMatrix(); // the rotating object
    translate(eye_x, eye_y, eye_z);
    fill(255, 255, 255);
    noStroke();
    sphere(30.0);
  popMatrix();
}

```

 ![camera_stationary](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/5c4e4d7f80c4505042898b2c091287fe2f0dfc84.gif)
