[]如何在3d场景中添加文字

我在搞一个3d的rpg的demo,需要给人物模型头顶加个名字跟着模型移动动。
已邀请:

ltmking

赞同来自:

//设置其他玩家角色名称跟随角色模型
这后边的代码放到针刷新事件里

ltmking

赞同来自:

/**玩家名称 */
private txtName:Laya.Text;
//场景的相机
public otherGameScene:Laya.Camera;

private _outPos:Laya.Vector3 = new Laya.Vector3();


this.txtName = new Laya.Text();
this.txtName.color = "#FFFFFF";
this.txtName.text = this.playerName;
this.txtName.fontSize = 18;
this.txtName.font = "Arial";
this.txtName.bold = true;
this.txtName.align = "left";
Laya.stage.addChild(this.txtName);

//设置其他玩家角色名称跟随角色模型
var currPosition2:Laya.Vector3 = new Laya.Vector3(this._position.x, 5, this._position.z);
this.otherGameScene.viewport.project(currPosition2,this.otherGameScene.projectionViewMatrix,this._outPos);
this.txtName.pos(this._outPos.x / Laya.stage.clientScaleX - this.txtName.width/2, this._outPos.y / Laya.stage.clientScaleY);
 

要回复问题请先

商务合作
商务合作