I am currently working on a complex ifc model that includes custom properties. My objective is to allow users of my application to enter a specific designator in a search field and have the corresponding element blink for easy identification on the screen.
I successfully implemented the search field and element identification functionality. Here is the key code snippet for the search function:
function performSearchIfc() {
let searchInput = document.getElementById("uuidsearchinput").value;
let expressId = designatorToExpressId.get(searchInput);
let arrayOfParts = loadedFragmentsGroup.data.get(expressId)[0];
console.log(arrayOfParts);
for (let i = 0; i < arrayOfParts.length; i++) {
let partId = arrayOfParts[i];
let children = loadedFragmentsGroup.children;
let item = children.find(item => item.id === partId);
if (!item) {
console.log("Skipping item: " + partId);
continue;
}
console.log(item);
(async () => { //There seems to be an issue with coloring as scale works fine
try {
let r = item.instanceColor.array[0] + 1 - 1;
let g = item.instanceColor.array[1] + 1 - 1;
let b = item.instanceColor.array[2] + 1 - 1;
let copyOfOrigColor = new Float32Array([r, g, b]);
let intenseGreen = new Float32Array([0, 1, 0]);
while (true) {
console.log("Setting color to " + intenseGreen);
item.instanceColor.set(intenseGreen);
item.scale.set(2.2, 2.2, 2.2);
await sleep(1000);
console.log("Setting color to " + copyOfOrigColor);
item.instanceColor.set(copyOfOrigColor);
item.scale.set(1, 1, 1);
await sleep(1000);
}
} catch (error) {
console.error(error);
}
})();
}
}
The interesting aspect lies in the blinking behavior. The mechanism functions correctly in terms of identifying the elements linked to the specified identifier. The scaling and color change to bright green work seamlessly as intended. The console outputs exhibit the expected results:
https://i.sstatic.net/6HlxNliB.png
However, there seems to be an issue with reverting the color back to its original state after the blink effect. The elements remain green without returning to their initial color.
Could anyone shed some light on this matter?
EDIT:
Shortly after posting, I observed that only certain parts are being colored at times, resulting in the following scenario:
https://i.sstatic.net/657X0i5B.png
This indicates that the coloring method may be unreliable overall.