Scene scene.

I am currently working on a project that involves working with very large and very small distances using three.js

I have a problem on the shallower side of the stage where the "stage" starts to shake a lot.

I first assumed it was a Z-Buffer issue, so I wrote a small snippet that changes the near and far properties of the camera every time a new area is entered. This helped solve the "flickering" problems I had before, however the scene still moves sharply at short distances.

One of the conditions under which this happens is as follows

camera.near = .0133333
camera.far = 12
positionToObjects = 6

      

this should mean that the z resolution is around: .0001, which I think should be good enough, but the jitter that occurs is much larger than that.

the objects themselves are located everywhere from -200000 to 200000 in the "global" position, but the scenes themselves do not change position

The other that I thought it might be are the camera controls that I used, which are (abbrviated) as follows

if(mouseIsDown == true){
    if(this.movementSpeed < this.maxSpeed){
        this.movementSpeed += this.acceleration
    }else{
        this.movementSpeed = this.maxSpeed
    }

}else{
    if(this.movementSpeed > this.minSpeed){
        this.movementSpeed = this.movementSpeed/this.deceleration
    }else{
        this.movementSpeed = this.minSpeed  
    }

}

      

where this.minSpeed ​​= 0 and this.movementSpeed ​​is used to move the camera like this:

var actualSpeed = delta * this.movementSpeed;
this.object.translateZ( -actualSpeed * forwardOrAuto );
this.object.translateX( actualSpeed * sideSpeed );
this.object.translateY( actualSpeed * upSpeed );

      

However, even when the camera is not moving (up to 8 decimal places), the scene still shakes a lot

Are there any reasons I can't think of to make this scene?

Please let me know if there is any additional information I can / should provide and well in advance of your time.

+3


source to share


1 answer


May I suggest that you use near and far values ​​that are not so small? (In particular, for loved ones)

Near is used as a separator internally, so if you use a small number (<1), you may lose precision and stop these strong movements, since the range of values ​​you move is less than if you used closer and further values.

This is why you will find a default around 0.1: https://github.com/mrdoob/three.js/blob/r55/src/cameras/PerspectiveCamera.js#L13



... although I personally always use 1 for close.

Also, an online example is always good when asking for help on visual issues :-)

+1


source







All Articles