cocos creater 广告版BillboardHelper

复制修改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);

    }//

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值