Comments (4)
I had this problem at first... Use this to go forward:
+ VR.camera.moveZ(-(Math.PI * delta * 2));
And this to go backwards (away from where ur looking at):
+ VR.camera.moveZ(-(Math.PI * delta * 2));
from webvr-starter-kit.
Ignore the pluses
from webvr-starter-kit.
Darn!... This to go back: VR.camera.moveZ(Math.PI * delta * 2);
from webvr-starter-kit.
Hey guys,
First of all, never move the camera, because it will conflict with the headset. Move the body instead. And, of course, be careful about doing so because this is a great way to cause simulator sickness.
Multiplying delta by 2 PI doesn't change anything except to speed up the movement by a factor of a little more than 6.
This solution seems to work. See step-by-step explanation in comments.
VR.floor();
var camera = VR.camera.object;
// create a single scratch vector to re-use so we don't have to allocate
// one on every frame. Garbage collection can cause barf-inducing judder.
var lookDirection = new THREE.Vector3();
VR.animate(function(delta){
// get direction camera is looking relative to the world
camera.getWorldDirection(lookDirection);
// set y to zero so we only move on the horizontal plane, not up or down
lookDirection.y = 0;
// don't move or try to normalize if length is very small,
// because it can cause a divide-by-zero error
// or otherwise create a weird/terrible experience
if (lookDirection.lengthSq() > 0.01) {
// normalize so we can get a constant speed
lookDirection.normalize();
lookDirection.multiplyScalar(delta);
// move body, not the camera
VR.body.position.add(lookDirection);
}
});
from webvr-starter-kit.
Related Issues (20)
- Text rendered center aligned if text width is shorter than the 'wrap' HOT 1
- Installing the starter kit for development
- How to check current rotation of an object HOT 8
- Transparent images HOT 2
- Add a link to an object in the scene HOT 2
- Closed
- Using Images
- Audio does not play on iOS device
- text renders a black box background
- Can not disable all movements
- 180 degree mode? HOT 2
- CVE-2018-16487 High Severity Vulnerability detected by WhiteSource
- CVE-2018-3721 Medium Severity Vulnerability detected by WhiteSource
- WS-2018-0210 Low Severity Vulnerability detected by WhiteSource
- WS-2019-0032 Medium Severity Vulnerability detected by WhiteSource
- WS-2019-0019 Medium Severity Vulnerability detected by WhiteSource
- CVE-2016-10540 High Severity Vulnerability detected by WhiteSource
- CVE-2017-16138 High Severity Vulnerability detected by WhiteSource
- WS-2017-0330 Medium Severity Vulnerability detected by WhiteSource
- WS-2018-0107 High Severity Vulnerability detected by WhiteSource
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webvr-starter-kit.