1
  1. I'm interested in drawing a stardome in THREE.js using either mesh points or a particle system.

  2. I don't want the camera to be able to move any closer to any part of the stardome, since the stars are effectively at infinite distance.

I can think of a couple of ways to do this:

  1. A very large mesh (or very large point/particle distances)

  2. Camera and stardome have their movement exactly linked.

Is there any way to specify a mesh, point, or particle system is automaticaly rendered at infinite distance so it is always drawn behind any foreground objects?

WestLangley
  • 102,557
  • 10
  • 276
  • 276

2 Answers2

0

I haven't used three.js, but my guess is no. OpenGL camera's need a "near clipping plane" and "far clipping plane", which effectively denote the minimum and maximum distance that it'll render things in. If you've played video games where you move too close to a wall and start to see through it, or see things in the distance suddenly vanish as you move away, those were probably the clipping planes at work.

The workaround is usually one of 2 ways: 1) Set the far clipping plane distance as high as it'll let you go. I don't know what data type three.js would use for this, but my guess is a 32-bit float. 2) Render it in "layers". Render all the stars first before anything else in the scene.

Cody
  • 2,643
  • 2
  • 10
  • 24
0

Option 2 is the one I usually use.

Even if you used option 1, you would still synchronize the position of the camera and skybox.

If you do not depth cull, draw the skybox first and match its position, but not rotation, to the camera.

Also disable lighting on the skybox. Instead, bake an ambience directly into its texture.

You're don't want things infinitely away, you just want them not to move with respect to the viewer and to not appear in front of things. The best way to do that is to prevent the viewer from getting closer to them which produces the illusion of the object being far away. The second thing is to modify your depth culling function so that the skybox is always considered further away than whatever you are currently drawing.

If you create a very large mesh object, you'll have to set your camera's far plane large enough to include the mesh which means you'll end up drawing things that you really do want to cull.

zero298
  • 25,467
  • 10
  • 75
  • 100