camera.convertToUINode 我实现了2D跟随3D模型,不过我3D视角摄像机转过180度后,就是背对着这个3D模型,文字又出现了,我应该如何过滤。
转换代码如下:
private _pos: Vec3 = new Vec3();
const wpos = this.target.worldPosition;
const camera = this.camera!;
// [HACK]
// @ts-ignore
camera._camera.update();
camera.convertToUINode(wpos, this.node.parent!, this._pos);
this.node.setPosition(this._pos);
// @ts-ignore
Vec3.transformMat4(this._pos, this.target.worldPosition, camera._camera!.matView);
const ratio = 10 / Math.abs(this._pos.z);
const value = Math.floor(ratio * 100) / 100;
this.node.setScale(value, value, 1);