Hello, all. I am wondering if its possible to make text be able to be seen through objects. I would like this for only some text, for quest NPC names. Is this possible? Thanks.
I’m not sure you can do this with the official API. But this is how I hacked it to work.
-
Create a new Layer called
Labels
. -
Assign this script to your scene’s root:
var ClearDepth = pc.createScript('clearDepth'); // initialize code called once per entity ClearDepth.prototype.initialize = function() { const layer = this.app.scene.layers.getLayerByName('Labels'); layer.clearDepthBuffer = true; };
-
Create a text element entity.
-
Set the text element to render to the
Labels
layer. -
Assign this script to your text element that appears above your NPC:
var DepthTest = pc.createScript('depthTest'); // initialize code called once per entity DepthTest.prototype.initialize = function() { // Warning: this is not public API this.entity.element._text._material.depthTest = false; };
1 Like
Thanks a lot for clearing that up. It works great now! Is there a way to add and take off entities from layers in code?
Yes, you can search the forum, there are a few topics about it. For example
1 Like