I am trying to create line using pc.mesh but I am not able to change the color and disable the shadow of the mesh.
Test.prototype.createLine = function () {
var app = this.app;
var device = app.graphicsDevice;
// Create mesh
var mesh = new pc.Mesh(device);
var positions = new Float32Array([
-3, 0.15, -0.05, // pos 0
-3, 0.15, 0.05, // pos 1
4, 0.15, 0.05, // pos 2
4, 0.15, -0.05 // pos 3
]);
var uvs = new Float32Array([
0, 0, // uv 0
1, 0, // uv 1
1, 1, // uv 2
0, 1 // uv 3
]);
var indices = new Uint16Array([
0, 1, 2, // triangle 0
0, 2, 3 // triangle 1
]);
mesh.setPositions(positions);
mesh.setUvs(0, uvs);
mesh.setIndices(indices);
mesh.update();
// Create material
var material = new pc.StandardMaterial();
material.diffuse.set(1, 0, 0);
material.emissive.set(1, 0, 0);
material.update();
// Create node
var node = new pc.GraphNode();
// Create mesh instance
var meshInstance = new pc.MeshInstance(node, mesh, material);
meshInstance.receiveShadow = false;
// Create model
var model = new pc.Model();
model.graph = node;
model.meshInstances = [meshInstance];
// Add model to the entity
this.entity.addComponent('model', {
type: 'asset'
});
this.entity.model.model = model;
};
I am able to show the correct color by adding these line but I am not sure if this is the right way to do it.
this.entity.model.meshInstances.forEach(function(mi) {
mi.receiveShadow = false;
});