At the present moment, I am writing code that cues off of the coordinates of furniture items in a 3d scene.
From what I gather, each furniture piece possesses its own coordinates which are based off of the furniture pieces parent. Whether the parent be the level or a group etc...
If the parent happens to be the "level" the furniture pieces' coordinates directly entail where the furniture piece resides in the 3d scene.
However, if a furniture piece happens to have a non-level parent, the coordinates of the furniture piece are based off of the parent(s).
Basically, in my code I am writing a recursive function that takes in a furniture node and grabs its coordinates.
As the recursive function iterates it climbs the levels of the parents and increments the original coordinates in accordance with the coordinates of the node that is currently in the function.
If the class of node currently in the function is that of "io3d-level" the recursive function will stop and return the incremented coordinates. This is because a node with a class of "io3d-level" must possess a coordinate object of {0, 0, 0}.
Again, the recursive function will iterate from the level of a furniture node and climb the structure of the parents grabbing and adding their coordinates onto the original coordinates of the furniture node until the current class of the node within the function is the level, at which point the function stops and returns the coordinates.
This recursive function appears to produce pristine results in almost all cases.
However, this function does not return pristinely accurate coordinates for a minority of furniture nodes sent through it.
The assumption behind this recursive function is that a furniture nodes' true coordinates, relative to the level, can be obtained via grabbing the coordinates of all of the furniture nodes' parents and summing them. Obviously taking into account that x coordinates are summed with x coordinates and z coordinates are summed with z coordinates.
Is this assumption false?
Am I perhaps misinterpreting the coordinate system that belies the 3d.io scenes?
This can be done directly without inaccuracies using the three.js handle.
let worldCoordinates = obj.data3dView.threeParent.getWorldPosition();