<div dir="ltr"><div dir="ltr"><div>Very interesting, thanks for your careful analysis and testing Michalis.</div><div><br></div><div>Might you or someone adapt this to create a test scene for the X3D Example Archives?</div><div><br></div><div>The response to loading the scene could be Script node initialize() statements to the console describing</div><div><ul><li>expected result,</li><li>actual result,</li><li>boolean result, did they match?</li><li>also showing a change in the X3D rendering to report success/failure is useful.</li></ul><div>That test might also be integrated in X3DJSAIL and X3DPSAIL libraries.</div></div><div><br></div><div>Thanks in advance for anyone considering creation of such a test scene.</div><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div style="color:rgb(34,34,34)"><font face="monospace"><br></font></div><div style="color:rgb(34,34,34)"><font face="monospace">all the best, Don</font></div><div style="color:rgb(34,34,34)"><font face="monospace">-- </font></div><div style="color:rgb(34,34,34)"><font face="monospace">X3D Graphics, Maritime Robotics, Distributed Simulation</font></div><div style="color:rgb(34,34,34)"><font face="monospace">Relative Motion Consulting  <a href="https://RelativeMotion.info" target="_blank">https://RelativeMotion.info</a></font></div></div></div></div><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sat, Nov 22, 2025 at 4:40 PM Michalis Kamburelis via x3d-public <<a href="mailto:x3d-public@web3d.org">x3d-public@web3d.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Arial,sans-serif;font-size:14px">Short version: Let's make sure our X3D browsers honor the order of values when reading SFMatrix*, MFMatrix* fields :)</div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px"><ul style="margin-top:0px;margin-bottom:0px"><li style="list-style-type:"- ""><span><span>Classic encoding link: </span><span><a rel="noreferrer nofollow noopener" href="https://www.web3d.org/documents/specifications/19776-2/V3.3/Part02/EncodingOfFields.html#SFMatrix4f" target="_blank">https://www.web3d.org/documents/specifications/19776-2/V3.3/Part02/EncodingOfFields.html#SFMatrix4f</a></span><br></span></li></ul></div><div style="font-family:Arial,sans-serif;font-size:14px"><div><br></div><div><ul style="margin-top:0px;margin-bottom:0px"><li style="list-style-type:"- ""><span><span>XML encoding link, saying the same:</span><span><a rel="noreferrer nofollow noopener" href="https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/EncodingOfFields.html#SFMatrix4f" target="_blank">https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/EncodingOfFields.html#SFMatrix4f</a></span><br></span></li></ul></div></div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px">Longer version:</div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px">I recently found a mistake in Castle Game Engine's SFMatrix*, MFMatrix* reading/writing code. We were following VRML 1.0 order, while the X3D order (according to both classic and XML encodings specs) is different. So I fixed it, and now <span>Castle Game Engine</span> and Castle Model Viewer follow the proper X3D spec order (when reading/writing X3D).</div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px">Namely, X3D classic encoding spec <span>unambiguous</span>ly says:</div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px"><span>    """</span><div><span>    The first four single-precision floating point numbers represent the top row of the matrix.</span></div><div><span>    The second four single-precision floating point numbers represent the second row of the matrix.</span></div><div><span>    """</span></div><div><span><br></span></div><div><span>    Classic encoding link: </span><span><a rel="noreferrer nofollow noopener" href="https://www.web3d.org/documents/specifications/19776-2/V3.3/Part02/EncodingOfFields.html#SFMatrix4f" target="_blank">https://www.web3d.org/documents/specifications/19776-2/V3.3/Part02/EncodingOfFields.html#SFMatrix4f</a></span><div><br></div><div><span>    XML encoding link, saying the same:</span><span><a rel="noreferrer nofollow noopener" href="https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/EncodingOfFields.html#SFMatrix4f" target="_blank">https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/EncodingOfFields.html#SFMatrix4f</a></span></div><div><span><br></span></div><div>So this means that e.g. translation by 1 2 3 is encoded in X3D in a way that looks similar to how you would write it in math expressions:</div><div><br></div><div>1 0 0 1</div><div>0 1 0 2</div><div>0 0 1 3</div><div>0 0 0 1</div><div><br></div><div>For example, using MatrixTransform node (extension supported by at least Castle Game Engine, X3DOM, Instant Reality), to move object by 1 2 3 you would write this:</div><div><br></div><div><span>MatrixTransform {</span><div><span>  matrix</span></div><div><span>    1 0 0 1</span></div><div><span>    0 1 0 2</span></div><div><span>    0 0 1 3</span></div><div><span>    0 0 0 1</span></div><div><span>  children Shape {</span></div><div><span>    appearance Appearance {</span></div><div><span>      material Material { diffuseColor 0 1 0 }</span></div><div><span>    }</span></div><div><span>    geometry Sphere { }</span></div><div><span>  }</span></div><div><span>}</span></div><span></span></div><div><br></div><div>To complicate testing a bit, </div><div><br></div><div><ul style="margin-top:0px;margin-bottom:0px"><li style="list-style-type:"- ""><span>VRML 1.0 and X3D specifications here say the opposite things. And VRML 2.0 specification doesn't have a matrix field type. So it's probably easy to make the same mistake I did :) See my docs about it on <span><a rel="noreferrer nofollow noopener" href="https://github.com/castle-engine/castle-engine/tree/master/tests/data/matrix_vrml_x3d_format" target="_blank">https://github.com/castle-engine/castle-engine/tree/master/tests/data/matrix_vrml_x3d_format</a> .</span><br></span></li></ul></div><div><span><br></span></div><div><ul style="margin-top:0px;margin-bottom:0px"><li style="list-style-type:"- ""><span><span>Moreover, not many nodes in spec actually use the matrix field types. Again, see <span><a rel="noreferrer nofollow noopener" href="https://github.com/castle-engine/castle-engine/tree/master/tests/data/matrix_vrml_x3d_format" target="_blank">https://github.com/castle-engine/castle-engine/tree/master/tests/data/matrix_vrml_x3d_format</a></span> where I listed the ones that do. The <span>MatrixTransform</span>, shown above, is only an extension (and I do _not_ propose to make it part of spec; we should encourage authors to use cleaner Transform).</span></span></li></ul></div><div><span><br></span></div><div><span>I have been testing MatrixTransform in X3DOM, and I think X3DOM has a bug (just like CGE did, a month ago!) and it expects matrix in transposed order. See testcase on <span><a rel="noreferrer nofollow noopener" href="https://github.com/castle-engine/demo-models/blob/master/x3d/matrix_transform_x3dom.html" target="_blank">https://github.com/castle-engine/demo-models/blob/master/x3d/matrix_transform_x3dom.html</a></span> -- only by transposing a matrix I was able to get the correct result.</span></div><div><span><br></span></div><div>Regards,</div><div>Michalis</div></div></div><div style="font-family:Arial,sans-serif;font-size:14px">
    <div></div>
    
            <div>
        
            </div>
</div>
_______________________________________________<br>
x3d-public mailing list<br>
<a href="mailto:x3d-public@web3d.org" target="_blank">x3d-public@web3d.org</a><br>
<a href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org" rel="noreferrer" target="_blank">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a><br>
</blockquote></div></div>