"3d objects in cocos crearoe" Code Answer's
You're definitely familiar with the best coding language TypeScript that developers use to develop their projects and they get all their queries like "3d objects in cocos crearoe" answered properly. Developers are finding an appropriate answer about 3d objects in cocos crearoe related to the TypeScript coding language. By visiting this online portal developers get answers concerning TypeScript codes question like 3d objects in cocos crearoe. Enter your desired code related query in the search bar and get every piece of information about TypeScript code related question on 3d objects in cocos crearoe.
3d objects in cocos crearoe
function createMesh (data, color) {
let gfx = cc.gfx;
let vfmt = new gfx.VertexFormat([
{ name: gfx.ATTR_POSITION, type: gfx.ATTR_TYPE_FLOAT32, num: 3 },
{ name: gfx.ATTR_NORMAL, type: gfx.ATTR_TYPE_FLOAT32, num: 3 },
{ name: gfx.ATTR_COLOR, type: gfx.ATTR_TYPE_UINT8, num: 4, normalize: true },
]);
let colors = [];
for (let i = 0; i < data.positions.length; i++) {
colors.push(color);
}
let mesh = new cc.Mesh();
mesh.init(vfmt, data.positions.length);
mesh.setVertices(gfx.ATTR_POSITION, data.positions);
mesh.setVertices(gfx.ATTR_NORMAL, data.normals);
mesh.setVertices(gfx.ATTR_COLOR, colors);
mesh.setIndices(data.indices);
mesh.setBoundingBox(data.minPos, data.maxPos);
return mesh;
}
// Create box vertex data
let data = cc.primitive.box(100, 100, 100);
// Create mesh base on vertex data
let mesh = createMesh(data, cc.color(100, 100, 100));
// Set the created mesh to the Mesh Renderer
let renderer = this.getComponent(cc.MeshRenderer);
renderer.mesh = mesh;
Source: docs.cocos.com
All those coders who are working on the TypeScript based application and are stuck on 3d objects in cocos crearoe can get a collection of related answers to their query. Programmers need to enter their query on 3d objects in cocos crearoe related to TypeScript code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about 3d objects in cocos crearoe for the programmers working on TypeScript code while coding their module. Coders are also allowed to rectify already present answers of 3d objects in cocos crearoe while working on the TypeScript language code. Developers can add up suggestions if they deem fit any other answer relating to "3d objects in cocos crearoe". Visit this developer's friendly online web community, CodeProZone, and get your queries like 3d objects in cocos crearoe resolved professionally and stay updated to the latest TypeScript updates.