[x3d-public] errors in convertJsonToStl.js
John Carlson
yottzumm at gmail.com
Mon Jun 4 03:48:24 PDT 2018
Well, I “fixed” my code, but would appreciate a second pair of eyes looking at it. Essentially, I added an inverse quaternion to the transform “stack” (now not quite a stack).
https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/matrix.js
https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertJsonToStl.js
search for quaternion.
If you hook up the X3DJSONLD web server, you can search for “LightsOn” in X3DJSONLD and look at the JSON file at /c/x3d-code/www.web3d.org/x3d/content/examples/Savage/… (set up Cygwin/MingW, node.js etc, create symbolic link).
It should convert to STL automatically I think. To convert back to JSON (and display as a green surface), press the here above the STL output pane.
But really, just a review of the quaternion code should be sufficient. There’s probably an issue with the viewpoint in the example (STL doesn’t have viewpoints, and I don’t think I’ve taken the time to introduce the necessary transforms).
Thanks,
John
Sent from Mail for Windows 10
From: John Carlson
Sent: Monday, June 4, 2018 3:18 AM
To: X3D Graphics public mailing list
Subject: RE: errors in convertJsonToStl.js
I looked at my quaternion code today, and at quaternions and rotations on the web. I am not quite sure how I came up with the code I did (I saw some video). I think I watched the wrong video, or I was smoking anxiety that day. Currently, my converter converts lots of stuff to a plane, it looks like (see SuperCobra).
Can anyone point me to a reasonable open source implementation of quaternion rotations in JavaScript, Java, C or C++? X_ITE or X3DOM? Ideally, the quaternions would fit into a 4x4 matrix stack, which is how I learned how to do transforms (I am not doing a perspective transform that I know of, so perhaps 3x3 is good enough). Yes, I know that other implementations are probably more efficient. I’d like to try to get 4x4 transforms working first before optimizing. 4x4 transforms are NOT a requirement, however, just a nice to have.
John
Sent from Mail for Windows 10
From: John Carlson
Sent: Saturday, May 20, 2017 2:20 AM
To: Don Brutzman; X3D Graphics public mailing list
Subject: RE: errors in convertJsonToStl.js
New versions of X3D JSON, STL and PLY interoperability are here:
https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertJsonToStl.js
https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertPlyToJson.js
https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/convertStlToJson.js
This mostly works with Indexed geometry. I don’t handle PLY texture coordinates yet.
Contributions are welcome, particularly JSON to PLY…
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180604/606f3c80/attachment-0001.html>
More information about the x3d-public
mailing list