In the previous section, we added functionality to animate a construction sequence. Let's add in the functionality for our last button.
Seeing as the longest member in the model might be more than one, we are going to store an array of all members that have the longest length.
Have a read through the code below and then we'll discuss it a bit further.
Well that's not too bad, we're using a few tricks we already learned.
In the first loop, we used the built-in
getLength() method to get a member's length. Then we constructed a simple
if statement to determine if the current value is equal to the max, more than the max, or less than the max. If it is longer, then we reset our array to be only this member. If it was equal to the current maximum, then we added it to our array.
We then notify the user about our findings, nothing new here.
highlightElement() method can take either an integer or an array of integers. If you need to keep adding to the selection, then you can add two more arguments,
locator() method can only be called once at a time. So we added a timeout to give the animation time to finish on each member, then we move to the next member and call it again. This was done by using our
setTimeout trick from earlier.
Good Job, we've create a simple SkyCiv App with some various functions. You can reuse parts of the logic we created in your own app now. If you have any questions or need extra functionality get in contact with us on the Slack channel (icon at the top) or via the live chat.
Next up, checkout the different S3D functions you can access.