<div dir="auto">How is shared buffer different from DEF/USE?</div><div dir="auto"><br></div><div dir="auto">John</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 5, 2022 at 12:42 PM GPU Group <<a href="mailto:gpugroup@gmail.com">gpugroup@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div dir="ltr">Good questions Joe. I struggled recently to refactor old (freewrl) browser code to better parse and use glTF more efficiently A  strange thing: glTF likes everything in one giant scene buffer blob, with nodes sharing the same blob buffer, and there being offset, stride, datatype, number of components) for each array (aka vertex attribute / index). <div>- so I refactored a bit of old code to use that technique - sharable buffer (although going through x3d nodes they aren't shared, just one buffer per node), and accessor/bufferView</div><div>- then re-did gltf parsing code so it used those accessor/bufferView and blob buffer techniques.</div><div>- What I found: the specific geometry node types we have like IFS aren't necessary. You can skip those and do a new node type that has _no_ fields. Just the (hidden/internal) accessor/bufferviews and buffer. (Could/should there be a <a href="http://web3d.org" target="_blank">web3d.org</a> official name? I think someone said x3dom uses Buffer. I'm using BufferGeometry.)</div><div>Could it be done through IFS? Yes but that was the long inefficient way I was trying to fix.</div><div>Ideally I'd finish fixing old code so all x3d geometry nodes resolve (after parsing, initializing/compiling) to some internal code and structure that looks like what I'm doing with BufferGeometry.</div><div>Back to the question Shape url='' and defining it carefully. I parse the whole gltf scene to web3d nodes, except for the geometry going to BufferGeometry which I pretend is a web3d node. So there are shapes, materials, punctual lights that map well. For geometry - no. You'd need to instance it at the Shape level in the main scene, to avoid having to say an illegal node type BufferGeometry {url='library.gltf#name'}. A true gotcha.</div><div>-Doug</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 5, 2022 at 11:12 AM Joseph D Williams <<a href="mailto:joedwil@earthlink.net" target="_blank">joedwil@earthlink.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div lang="EN-US"><div><ul style="margin-top:0in" type="disc"><li style="margin-left:0in">Shape { url='library.gltf#name }</li></ul><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Great, just so amazing that it looks so direct to import, a set of data. The critical part is that this needs to be carefully defined. This can be used only where it can be shown that the gltf file contains only data exactly equivalent to the content defined by the x3d standard for some Shape. Why not more like:</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><IndexedFaceSet DEF='sternum_Geo' url='library.gltf#joe_sternum’ /></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">That would be easier to map the named fields from the gltf file to the equivalent fields of an x3d node in x3d user code. In the end the standard will (I think) have to state that x3d can use certain ‘standard’ json-encoded gltf files that conform to Standard gltf JSON-Schema documentation. And, importantly, defining which of the gltf named fields are used directly, or converted, to construct the equivalent x3d nodes and fields. </p><p class="MsoNormal">Even better, in terms of validation, by requiring the naming of the top level gltf asset schema directly. For example </p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><IndexedFaceSet DEF='sternum_Geo' url='node.library.gltf#joe_sternum’ /></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">So in this case it could be verified that the gltf node asset contains specific data to produce the IFS. </p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Is it possible to deal with how to for general use author-defined json-encoded files for any field of any node?</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><IndexedFaceSet DEF='sternum_Geo' … <u></u><u></u></p><p class="MsoNormal">   <Coordinate DEF='lfemur_Coord' point=”url-<u></u><u></u></p><p class="MsoNormal">url=’point.json’ <u></u><u></u></p><p class="MsoNormal">,,, /><u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Thanks for these breakthrough implementation steps for using gltf standard stuffs in x3d.</p><p class="MsoNormal">Joe</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><u></u> <u></u></p><div style="border-style:solid none none;border-top-width:1pt;padding:3pt 0in 0in;border-top-color:rgb(225,225,225)"><p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:gpugroup@gmail.com" target="_blank">GPU Group</a><br><b>Sent: </b>Tuesday, April 5, 2022 7:45 AM<br><b>To: </b><a href="mailto:x3d-public@web3d.org" target="_blank">X3D Graphics public mailing list</a><br><b>Subject: </b>Re: [x3d-public] Using IMPORT / EXPORT to selectively include partsof glTF file in X3D, and multiply them as much as necessary</p></div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">Looks good - I like it. -Doug</p></div></div></div></blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div lang="EN-US"><div><div><div><p class="MsoNormal">(PS the ExternProto was an analogy. The syntax looks like this:</p></div><div><p class="MsoNormal">Shape { url='library.gltf#name }</p></div><div><p class="MsoNormal">)</p></div></div><p class="MsoNormal"><u></u> <u></u></p><div><div><p class="MsoNormal">On Mon, Apr 4, 2022 at 8:23 PM Michalis Kamburelis <<a href="mailto:michalis.kambi@gmail.com" target="_blank">michalis.kambi@gmail.com</a>> wrote:</p></div></div><p class="MsoNormal" style="margin-left:4.8pt">( No real avocados were hurt while generating screenshots for this email :) )<br><br>I started to write an answer to Doug email "Other ways to use gltf ><br>like ExternProto" and then I realized that I just pursue a different<br>approach, so I may as well create a new thread. The goal is similar:<br>how to get *part* of glTF scene into X3D file? But here I decided to<br>do it using IMPORT / EXPORT + Inline, not ExternProto.<br><br>I thought that IMPORT / EXPORT may be nice, as IMPORT / EXPORT have an<br>explicit purpose "make something available to the outer scene".<br><br>So I tried how far can I take it. And  implemented it in<br>CGE/view3dscene, and made demos :) You can now use IMPORT / EXPORT to<br>selectively take (and reuse as many times as you wish) parts of inner<br>glTF models inside outer X3D file.<br><br>1. Older demo: I have already used this approach for animations in<br>glTF in CGE/view3dsdcene, i.e. I export them from glTF and you can<br>IMPORT and control them. See<br><a href="https://github.com/castle-engine/demo-models/tree/master/blender/skinned_animation" target="_blank">https://github.com/castle-engine/demo-models/tree/master/blender/skinned_animation</a><br>, file skinned_anim_run_animations_from_x3d.x3dv does<br><br>"""<br>DEF InlinedAnimations Inline {<br>   url "skinned_anim.glb"<br>}<br>IMPORT InlinedAnimations.jump AS jump<br>IMPORT InlinedAnimations.walk AS walk<br>"""<br><br>and then it can start  animations jump, walk. They are just TimeSensor<br>nodes in X3D. I can ROUTE events to them.<br><br>2. I have now extended this approach to glTF materials (X3D Appearance<br>nodes) and transformation groups and cameras (X3D Viewpoint /<br>OrthoViewpoint nodes). I can export anything named from glTF this way.<br><br>See <a href="https://github.com/michaliskambi/x3d-tests/tree/master/gltf/avocado_and_exports" target="_blank">https://github.com/michaliskambi/x3d-tests/tree/master/gltf/avocado_and_exports</a><br>and attached screenshot with scene that can reuse Avocado appearance,<br>or transformation, or mesh.<br><br>It looks like this:<br><br>"""<br>Switch {<br>  children DEF InlinedAvocado Inline {<br>    url "glTF/Avocado.gltf"<br>  }<br>}<br>IMPORT InlinedAvocado.Avocado_2 AS AvocadoMeshes<br>IMPORT InlinedAvocado.CastleEncoded_2256_Avocado_d AS AvocadoAppearance<br>IMPORT InlinedAvocado.Avocado AS AvocadoTransform<br><br>Shape {<br>  appearance USE AvocadoAppearance<br>  geometry IndexedFaceSet { ... }<br>}<br>...<br>"""<br><br>3. Why IMPORT / EXPORT? I felt this way there's less extra concepts.<br><br>  A. Do not want to see original glTF? Then place "Inline" inside "Switch".<br><br>  B. Writing "IMPORT" is simpler than ExternProto, no need to repeat<br>the node declaration.<br><br>4. To make this work:<br><br>  A. The browser must make sure to generate EXPORT for all named<br>things when importing glTF file.<br><br>  B. The browser must be more tolerant for USE clauses than spec.<br><br>    X3D spec says (<br><a href="https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-CD1/Part01/components/networking.html#IMPORTStatement" target="_blank">https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-CD1/Part01/components/networking.html#IMPORTStatement</a><br>) """Nodes imported into an X3D scene using the IMPORT statement may<br>not be instanced via the USE statement. """. I decided to ignore this<br>limit now in CGE/view3dscene, you can reUSE nodes you get with IMPORT.<br><br>    There seems to be no drawback from this. We only resolve USE<br>looking at IMPORTed names if the name cannot be found in non-imported<br>nodes. And it makes IMPORT / EXPORT much more powerful, also for<br>X3D<->X3D interaction.<br><br>5. Note: I'm not really trying to make a case that "IMPORT / EXPORT is<br>a better approach than ExternProto". They both seem reasonable<br>approaches. I just decided to test IMPORT / EXPORT approach to the<br>fullest, and I dabbled with it already in the demo with<br>skinned_anim_run_animations_from_x3d.x3dv .<br><br>Regards,<br>Michalis<br>_______________________________________________<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" target="_blank">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a></p><p class="MsoNormal"><u></u> <u></u></p></div></div></blockquote></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>