Hello Everyone,
I am looking for some suggestions and advise. I am currently using EdgesGeometry as a way to render the contours of some geometries in my scene. It works flawlessly to begin with. However, the application is dynamic that involves updating the geometry based on user controlled parameters. Also, there are multiple instances of such geometries(mostly extrudegeometries) that are controlled based on multiple variables created dynamically (width, height, depth, holes etc). As of result of this there is a need to update the edgesgeometry.
Now the problem is that reconstruction of edgesgeometry really is processing intensive. Since it involves a good amount of dot product computations to filter linesegments to be used I understand this is not an easy task. However, I also believe my knowledge might be limited and perhaps someone has solved this problem with a different strategy. Can you please share if you can?
One strategy I tried was to just update the vertex positions using the bufferattribute of edgesgeometry and the dynamic geometries when the topology does not change. I update the edges geometry only when the topology changes and it is okay to tradeoff performance at this point. But even with changes in width, height, and depth the count of edgesgoemetry differs from the regular geometry I am regenerating using extrudegeometry. Is there something I am doing fundamentally wrong?
To better explain below is an example code
let dynamicGeometry: ExtrudeGeometry = construct geometry created with different variable controls
let edgesGeometry: EdgesGeometry = new EdgesGeometry(dynamicGeometry);
/**
Performance intensive way
**/
function widthHeightDepthChanges(){
dynamicGeometry = reconstruct extrudegeometry based on different variable controls
edgesGeometry.dispose();
edgesGeometry = new EdgesGeometry(dynamicGeometry);
}
/**
Hacky way I tried
**/
let dynamicAttrib: BufferAttribute = dyanmicGeometry.getAttribute('position') as BufferAttribute;
let edgesAttrib: BufferAttribute = edgesGeometry.getAttribute('position') as BufferAttribute;
if(dynamicAttrib.count === edgesAttrib.count){
for(let i:number=0; i < edgesAttrib.count;i++){
let cX: number = dynamicAttrib.getX(i);
let cY: number = dynamicAttrib.getY(i);
let cZ: number = dynamicAttrib.getZ(i);
edgesAttrib.setXYZ(i, cX, cY, cZ);
}
}
else{
// Inherent differences in geometry perhaps some has changed in the topology
edgesGeometry.dispose();
edgesGeometry = new EdgesGeometry(dynamicGeometry);
}
But the else condition is the one that is triggered everytime? Does the extrudegeometry keep changing the topology every time even when using the same shape (albeit the size difference)?
Apologies in advance if my question is not clear. I will be more than happy to explain more.
So my post is essentially about looking for an advise and a question. Thank you everyone for reading through my woes
Regards,
#0K