复制修改billboard.ts 修改参考白玉无冰(412条消息) Cocos Creator 3.0 教程! 标志板! Billboard !_白玉无冰 lamyoung的博客-CSDN博客
代码参考
https://zhuanlan.zhihu.com/p/335145681
引用 import { _decorator, Component, Node, Billboard, Texture2D, toDegree, toRadian, Mesh, Material, Vec4, Color, EffectAsset, builtinResMgr, utils, gfx, renderer, director } from 'cc';
const { ccclass, property } = _decorator;
private createModel () {
this._mesh = utils.createMesh({
primitiveMode: gfx.PrimitiveMode.TRIANGLE_LIST,
positions: [0, 0, 0,
0, 0, 0,
0, 0, 0,
0, 0, 0],
uvs: [0, 0,
1, 0,
0, 1,
1, 1],
colors: [
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1],
attributes: [
new gfx.Attribute(gfx.AttributeName.ATTR_POSITION, gfx.Format.RGB32F),
new gfx.Attribute(gfx.AttributeName.ATTR_TEX_COORD, gfx.Format.RG32F),
new gfx.Attribute(gfx.AttributeName.ATTR_COLOR, gfx.Format.RGBA8UI, true),
],
indices: [0, 1, 2, 1, 2, 3],
}, undefined, { calculateBounds: false });
const model = this._model = director.root.createModel(renderer.scene.Model);//, this.node);
model.node = model.transform = this.node;
if (this._material == null) {
this._material = new Material();
this._material.copy(builtinResMgr.get<Material>('default-billboard-material'));
}
model.initSubModel(0, this._mesh.renderingSubMeshes[0], this._material);
}//