Subfile References and Scaling

Subfile References and Scaling
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: (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:

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.
Re: Subfile References and Scaling
Your current version doesn't seem to do anything for me (on SeaMonkey 2.33)

Maybe you switched the row/col order of the matrices while parsing the type 1 lines into a matrix?
Re: Subfile References and Scaling
Figured it out. My idea was correct, I was just confused by some of the implementation details of the library.
Re: Subfile References and Scaling
« Next Oldest | Next Newest »

Forum Jump:

Users browsing this thread: 1 Guest(s)