Code Monkey home page Code Monkey logo

Comments (4)

vedhant avatar vedhant commented on August 23, 2024

The starting position of the viewer is the same as a typical webgl default camera position.

  • The viewer is placed at the origin of the world.
  • the zx plane of world is the physical horizontal plane (perpendicular to gravity) of the viewer.
  • y axis of the world is opposite to gravity. (towards sky)
  • -z axis is the component of starting forward vector of viewer onto the zx plane.
  • x axis is the starting right vector of viewer.
let vrGlobals = {
  counter: 0
};

function preload() {
  createVRCanvas();
}

function setup() {
  setVRBackgroundColor(200, 0, 150);
}

function draw() {
  fill(0, 255, 0);
  checkSync();
  vrGlobals.counter++;
  
  translate(0, 0, -10);
  strokeWeight(0.1);
  
  box(5);
}

function checkSync() {
  if(vrGlobals.counter === 0) {return;}

  if(vrGlobals.counter !== frameCount) {
    console.error('Out of sync!');
  }
}

This example places a box on the negative z axis. So when the user first goes to VR mode, the cube will be directly visible to the front just by moving the head up and down (the head should be facing front perpendicular to gravity). The movement of head up and down from starting position will allow aligning the viewer's forward vector along the -z axis.

from p5.xr.

stalgiag avatar stalgiag commented on August 23, 2024

Right I understand. My main concern is whether every frame the camera should be shifted in the z-vector. If I draw a sphere at 0,0 then where do I expect that to be in relation to my body to most effectively match the experience of WebGL mode on the screen. This isn't a technical question as much as a question of design and achieve a good 'feeling' out of the box for the user.

from p5.xr.

vedhant avatar vedhant commented on August 23, 2024

As we discussed, how do you feel about giving user the capability to specify starting position or interestingly, let the user decide the viewers position at any point? The api for this could be very similar to p5 camera or maybe we can attach a viewer to a perspective camera?

from p5.xr.

stalgiag avatar stalgiag commented on August 23, 2024

Definitely! Do you want to propose one or two methods?

from p5.xr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.