Hi Community,
So, I’m trying to create an InstancedMesh by giving array of materials. Size of array is same as size of InstancedMesh. There is no texture visible on canvas it is just transparent with no errors.
The agenda behind this to keep these instanced solar panels in a way that I can turn off shadow properties for some when sun is below them to stop casting shadow (They cast on themselves).
let maxPossiblePanels = 100; // Count of panels
let materialArray = [];
for (let i = 0; i < maxPossiblePanels; i++) {
let m = new MeshStandardMaterial({
map: this.panelTexture.clone(),
side: DoubleSide,
transparent: false,
});
m.color = new Color(0xffff00);
materialArray.push(m);
}
let panelInstanceMesh = new InstancedMesh(panelGeom, materialArray, maxPossiblePanels); //Making count sufficiently large to accommodate single panels
InstancedMeshUtil.init(panelInstanceMesh);
InstancedMeshUtil.setPanelShader(panelInstanceMesh);
panelInstanceMesh.name = meshTypeEnum.panelArray;
(panelInstanceMesh.userData as MeshUserData).meshtype = meshTypeEnum.instancedMesh;
(panelInstanceMesh.userData as MeshUserData).maxInstanceCount = panelInstanceMesh.count;
panelsUserdataArray.forEach((p,i)=>{
panelInstanceMesh.setMatrixAt( i, p.matrix as Matrix4);
// panelInstanceMesh.setColorAt( i, new Color(0xffffff));
p.instanceId = i;
});
What am I doing wrong. Is even my approach correct or it’s not doable. We tried writing dynamic shader but that didn’t work and more complicated.