Currently, I am immersed in a project that requires handling very large and very small distances utilizing three.js.
Encountering an issue on the smaller side of the scene where the 'scene' begins to shake uncontrollably.
Initially, I suspected a problem with the Z-Buffer. To address this, I created a code snippet that adjusts the near and far camera properties each time a new area is entered. While this resolved the previous 'shimmering' problems, the intense shaking persists at close ranges.
An instance triggering this effect is as follows:
camera.near = .0133333
camera.far = 12
positionToObjects = 6
This should result in a z-resolution around: .0001, which seems adequate. However, the ensuing shaking is far more severe than anticipated.
The object positions span from -200000 to 200000 globally, while the scenes themselves remain stationary.
Another potential culprit I considered is the camera controls implemented, summarized below:
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
}
}
With this.minSpeed set to 0, movement is achieved using this.movementSpeed following this pattern:
var actualSpeed = delta * this.movementSpeed;
this.object.translateZ( -actualSpeed * forwardOrAuto );
this.object.translateX( actualSpeed * sideSpeed );
this.object.translateY( actualSpeed * upSpeed );
Even when the camera remains static (up to 8 decimal places), the scene continues to shake vigorously.
Could there be factors eluding my consideration causing this behavior? Your insights would be greatly appreciated, and feel free to request additional information if needed. Thank you for your attention.