Hello TechSoft3D,
I’ve created a polygon mesh by manually defining six individual face meshes. I’m trying to apply both face and edge (line) colors using the APIs in below code snippet. However, neither the face colors nor the line colors are getting applied.
What could be the possible reasons for the colors not being applied? Also, what is the correct way to apply face and edge colors to custom meshes in HOOPS Communicator?
export const createBoxWithParent: CreateBoxWithParent = async (
position,
width,
height,
depth,
faceColor,
hwv,
parentId,
resizedNodeId,
) => {
let parentNodeId = resizedNodeId
? hwv.model.createNode(parentId, hwv.model.getNodeName(resizedNodeId)!)
: hwv.model.createNode(parentId, box-${globalBoxCounter++}
);
for (let face = 0; face < 6; face++) {
const meshData = createBoxFaceMeshData(position, width, height, depth, face);
meshData.setBackfacesEnabled(true);
const meshId = await hwv.model.createMesh(meshData);
const meshInstanceData = new MeshInstanceData(meshId, new Matrix(), `face-${face}`, faceColor);
meshInstanceData.setFaceColor(faceColor)
meshInstanceData.setLineColor(faceColor)
meshInstanceData.setOpacity(0.4);
await hwv.model.createMeshInstance(meshInstanceData, parentNodeId);
}
return parentNodeId;
};
const boundingBoxNodeId = await createBoxWithParent(
corner,
width,
height,
depth,
Color.createFromFloat(1, 0, 0),
hwv,
folderNodeId,
);