[x3d-public] Using IMPORT / EXPORT to selectively include partsof glTF file in X3D, and multiply them as much as necessary

Joseph D Williams joedwil at earthlink.net
Tue Apr 5 10:12:05 PDT 2022


➢ Shape { url='library.gltf#name }

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:

<IndexedFaceSet DEF='sternum_Geo' url='library.gltf#joe_sternum’ />

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. 
Even better, in terms of validation, by requiring the naming of the top level gltf asset schema directly. For example 

<IndexedFaceSet DEF='sternum_Geo' url='node.library.gltf#joe_sternum’ />

So in this case it could be verified that the gltf node asset contains specific data to produce the IFS. 

Is it possible to deal with how to for general use author-defined json-encoded files for any field of any node?

<IndexedFaceSet DEF='sternum_Geo' … 
   <Coordinate DEF='lfemur_Coord' point=”url-
url=’point.json’ 
,,, />

Thanks for these breakthrough implementation steps for using gltf standard stuffs in x3d.
Joe


From: GPU Group
Sent: Tuesday, April 5, 2022 7:45 AM
To: X3D Graphics public mailing list
Subject: Re: [x3d-public] Using IMPORT / EXPORT to selectively include partsof glTF file in X3D, and multiply them as much as necessary

Looks good - I like it. -Doug
(PS the ExternProto was an analogy. The syntax looks like this:
Shape { url='library.gltf#name }
)

On Mon, Apr 4, 2022 at 8:23 PM Michalis Kamburelis <michalis.kambi at gmail.com> wrote:
( No real avocados were hurt while generating screenshots for this email :) )

I started to write an answer to Doug email "Other ways to use gltf >
like ExternProto" and then I realized that I just pursue a different
approach, so I may as well create a new thread. The goal is similar:
how to get *part* of glTF scene into X3D file? But here I decided to
do it using IMPORT / EXPORT + Inline, not ExternProto.

I thought that IMPORT / EXPORT may be nice, as IMPORT / EXPORT have an
explicit purpose "make something available to the outer scene".

So I tried how far can I take it. And  implemented it in
CGE/view3dscene, and made demos :) You can now use IMPORT / EXPORT to
selectively take (and reuse as many times as you wish) parts of inner
glTF models inside outer X3D file.

1. Older demo: I have already used this approach for animations in
glTF in CGE/view3dsdcene, i.e. I export them from glTF and you can
IMPORT and control them. See
https://github.com/castle-engine/demo-models/tree/master/blender/skinned_animation
, file skinned_anim_run_animations_from_x3d.x3dv does

"""
DEF InlinedAnimations Inline {
   url "skinned_anim.glb"
}
IMPORT InlinedAnimations.jump AS jump
IMPORT InlinedAnimations.walk AS walk
"""

and then it can start  animations jump, walk. They are just TimeSensor
nodes in X3D. I can ROUTE events to them.

2. I have now extended this approach to glTF materials (X3D Appearance
nodes) and transformation groups and cameras (X3D Viewpoint /
OrthoViewpoint nodes). I can export anything named from glTF this way.

See https://github.com/michaliskambi/x3d-tests/tree/master/gltf/avocado_and_exports
and attached screenshot with scene that can reuse Avocado appearance,
or transformation, or mesh.

It looks like this:

"""
Switch {
  children DEF InlinedAvocado Inline {
    url "glTF/Avocado.gltf"
  }
}
IMPORT InlinedAvocado.Avocado_2 AS AvocadoMeshes
IMPORT InlinedAvocado.CastleEncoded_2256_Avocado_d AS AvocadoAppearance
IMPORT InlinedAvocado.Avocado AS AvocadoTransform

Shape {
  appearance USE AvocadoAppearance
  geometry IndexedFaceSet { ... }
}
...
"""

3. Why IMPORT / EXPORT? I felt this way there's less extra concepts.

  A. Do not want to see original glTF? Then place "Inline" inside "Switch".

  B. Writing "IMPORT" is simpler than ExternProto, no need to repeat
the node declaration.

4. To make this work:

  A. The browser must make sure to generate EXPORT for all named
things when importing glTF file.

  B. The browser must be more tolerant for USE clauses than spec.

    X3D spec says (
https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-CD1/Part01/components/networking.html#IMPORTStatement
) """Nodes imported into an X3D scene using the IMPORT statement may
not be instanced via the USE statement. """. I decided to ignore this
limit now in CGE/view3dscene, you can reUSE nodes you get with IMPORT.

    There seems to be no drawback from this. We only resolve USE
looking at IMPORTed names if the name cannot be found in non-imported
nodes. And it makes IMPORT / EXPORT much more powerful, also for
X3D<->X3D interaction.

5. Note: I'm not really trying to make a case that "IMPORT / EXPORT is
a better approach than ExternProto". They both seem reasonable
approaches. I just decided to test IMPORT / EXPORT approach to the
fullest, and I dabbled with it already in the demo with
skinned_anim_run_animations_from_x3d.x3dv .

Regards,
Michalis
_______________________________________________
x3d-public mailing list
x3d-public at web3d.org
http://web3d.org/mailman/listinfo/x3d-public_web3d.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20220405/516c9b2d/attachment.html>


More information about the x3d-public mailing list