The model had an outline added upon clicking, and when removing the outline, the material flickers

After adding an outline to the model upon clicking and then removing the outline using the method described in this link: PlayCanvas Examples, the material flickers. The outline was added by modifying the render.layers values, setting it to [0, 6], and removing it by setting it to [0]. After removal, the model’s material alternates between a normal appearance and an abnormal appearance. The material appears normal when the camera is on the left side but abnormal when the camera is on the right side.

Before adding the outline, there was a material replacement done, specifically for the materials that were replaced before adding the outline. There were no material operations performed after adding the outline.

The material replacement code is as follows:



If the outline is not added, it displays normally. The outline is added to the current model after clicking. Removing the outline code also results in the display being normal.


Outline code:

I cannot reproduce this. The engine-only example works fine, after changing the material of the box and toggling the layers. Could you make a minimal repro project, please?

Also, I would recommend not to access private properties, like _material or _meshInstances. There is a public API for those, e.g. model.meshInstances or meshInstance.material.

1 Like