Subfile References and Scaling
2015-06-22, 23:48 (This post was last modified: 2015-06-28, 16:06 by Steffen.)
2015-06-22, 23:48 (This post was last modified: 2015-06-28, 16:06 by Steffen.)
I'm writing an online LDraw viewer using three.js and am getting some strange results when I try and render subfile references.
Here's what I have currently - this should be a basic 2 x 4 brick: http://nathanfriend.io/ldraw-visualizer (Note that I'm randomizing the color of all surfaces so I can clearly see how each is being rendered.)
As you can see, all subfile references are being translated too much, especially along the X and Z axes.
Here's a pseudo-code representation of how I'm calculating the positions of subfile parts:
You can see the relevant portion of this calculation here.
Any ideas as to what I'm doing wrong?
My current theory is that some part in the subfile chain is being scaled (for example, '4-4edge.dat' is non-uniformly scaled by a factor of 6 inside of 'stud4.dat'), and the assumption is that this scaling should not be applied to its own subfile references. This scaling would then causes exaggerations in the position of all descendent subfiles. If this is correct, I'm not sure how to go about counteracting the scaling.
Any hints would be much appreciated.
Here's what I have currently - this should be a basic 2 x 4 brick: http://nathanfriend.io/ldraw-visualizer (Note that I'm randomizing the color of all surfaces so I can clearly see how each is being rendered.)
As you can see, all subfile references are being translated too much, especially along the X and Z axes.
Here's a pseudo-code representation of how I'm calculating the positions of subfile parts:
Code:
subfileGeometry.applyMatrix(matrixFromSubfileReference * matrixThatRepresentsAllParentTransforms);
You can see the relevant portion of this calculation here.
Any ideas as to what I'm doing wrong?
My current theory is that some part in the subfile chain is being scaled (for example, '4-4edge.dat' is non-uniformly scaled by a factor of 6 inside of 'stud4.dat'), and the assumption is that this scaling should not be applied to its own subfile references. This scaling would then causes exaggerations in the position of all descendent subfiles. If this is correct, I'm not sure how to go about counteracting the scaling.
Any hints would be much appreciated.