0
\$\begingroup\$

I have a scene where I have a terrain as a PlaneGeometry. And I'm trying to locate a building on it as Sprite. But I'm not able to put that building/sprite centered on the terrain without getting a cutoff.

enter image description here

Make sense because the terrain is cutting the half. But I'm just wondering if there is a technique to solve this problem.

I tried to rotate the sprite as a 3D object. But does not have this property. Also tried using a PlaneGeometry with a MeshBasicMaterial, but the result of the Image looks blurry and without transparency.

\$\endgroup\$
3
\$\begingroup\$

You can force the sprite to render always on top by disabling the depth testing in the sprite's material.

material = new game.THREE.SpriteMaterial({
  depthTest: false
});
\$\endgroup\$
  • 1
    \$\begingroup\$ Keep in mind that objects drawn without Depth Testing will be shown on top of everything else. If you want buildings lower on screen to obstruct view of objects higher, you will have to draw all objects in specific order - from furthest to closest. \$\endgroup\$ – crueltear Feb 6 at 9:50
0
\$\begingroup\$

The best solution I found is adding two scenes, one for the terrain and one for the sprites.

Is important to add two lines after each render()

renderer.render(sceneTerrain, camera)
renderer.clearDepth()
renderer.autoClear = false

renderer.render(sceneSprites, camera)
renderer.clearDepth()
renderer.autoClear = false

...
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.