public createGrid(effectName: string) {
var _maxTicks = 1;
const node = new Node(effectName);
node.parent = this.node;
node.setWorldPosition(v3(0, 0, 0));
const model = node.addComponent(ModelComponent);
const positions = [
0,0,0,
0,0,10,
10,0,10,
10,0,0
];
const uv = [
0,0,
0,1,
1,1,
1,0
]
const colors = [];
const indices = [
0,1,2,2,3,0
];
const primitiveMode = cc.gfx.PrimitiveMode.TRIANGLE_STRIP;
const attributes = [
{
name: cc.gfx.AttributeName.ATTR_POSITION,
format: cc.gfx.Format.RGB32F,
},
{
name: cc.GFXAttributeName.ATTR_TEX_COORD,
format: cc.GFXFormat.RG32F
},
];
var db:boolean = false
// const plane = primitives.box({ width: 10, length: 10, widthSegments: 50, lengthSegments: 50 });
// const mesh = utils.createMesh(plane);
const mesh = utils.createMesh({primitiveMode,positions,uv,indices, attributes,},null,{ calculateBounds: false });
const mesh = utils.createMesh({
primitiveMode: cc.GFXPrimitiveMode.TRIANGLE_LIST,
positions: positions,
uvs: uv,
colors: colors,
indices: indices,
attributes: [
{ name: cc.GFXAttributeName.ATTR_POSITION, format: cc.GFXFormat.RGB32F },
{ name: cc.GFXAttributeName.ATTR_TEX_COORD, format: cc.GFXFormat.RG32F },
{ name: cc.GFXAttributeName.ATTR_COLOR, format: cc.GFXFormat.RGBA8UI, isNormalized: true },
],
}, undefined, { calculateBounds: false });
*/
model.mesh = mesh;
var texture_:Texture2D = null
let remoteUrl = "http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.png";
assetManager.loadRemote<ImageAsset>(remoteUrl, function (err, imageAsset) {
const texture = new Texture2D();
texture.image = imageAsset;
texture_ = texture
const ma = new cc.Material();
ma.initialize({
effectName: 'builtin-standard',
defines:{
USE_ALBEDO_MAP:true,
// USE_VERTEX_COLOR:true,
}
});
const mat = new Material();
var com = node.getComponent(MeshRenderer);
com.material = ma
var m = com.material
m.setProperty('mainColor',new Color(111,1,0,1))
console.dir(node)
});
return model;
}