<t>This draft offers a specification for 4D URLs & navigation, to link 3D scenes and text together with- or without a network-connection.<br/>
The specification promotes spatial addressibility, sharing, navigation, query-ing and tagging interactive (text)objects across for (XR) Browsers.<br/>
XR Fragments allows us to enrich existing dataformats, by recursive use of existing proven technologies like <ereftarget="https://en.wikipedia.org/wiki/URI_fragment">URI Fragments</eref> and <ereftarget="https://visual-meta.info">visual-meta</eref>.<br/>
Historically, there's many attempts to create the ultimate markuplanguage or 3D fileformat.<br/>
However, thru the lens of authoring their lowest common denominator is still: plain text.<br/>
XR Fragments allows us to enrich existing dataformats, by recursive use of existing technologies:<br/>
</t>
<olspacing="compact">
<li>addressibility and navigation of 3D scenes/objects: <ereftarget="https://en.wikipedia.org/wiki/URI_fragment">URI Fragments</eref> + src/href spatial metadata</li>
<li>hasslefree tagging across text and spatial objects using BiBTeX (<ereftarget="https://visual-meta.info">visual-meta</eref> e.g.)</li>
</ol>
<blockquote><t>NOTE: The chapters in this document are ordered from highlevel to lowlevel (technical) as much as possible</t>
<td>available through custom property in 3D fileformats</td>
</tr>
</tbody>
</table><t>Popular compatible 3D fileformats: <tt>.gltf</tt>, <tt>.obj</tt>, <tt>.fbx</tt>, <tt>.usdz</tt>, <tt>.json</tt> (THREEjs), <tt>COLLADA</tt> and so on.</t>
<blockquote><t>NOTE: XR Fragments are file-agnostic, which means that the metadata exist in programmatic 3D scene(nodes) too.</t>
In case of <tt>buttonA</tt> the end-user will be teleported to another location and time in the <strong>current loaded scene</strong>, but <tt>buttonB</tt> will
<strong>replace the current scene</strong> with a new one (<tt>other.fbx</tt>).</t>
</section>
<sectionanchor="embedding-3d-content"><name>Embedding 3D content</name>
<t>Here's an ascii representation of a 3D scene-graph with 3D objects (<tt>◻</tt>) which embeds remote & local 3D objects (<tt>◻</tt>) (without) using queries:</t>
<t>An XR Fragment-compatible browser viewing this scene, lazy-loads and projects <tt>painting.png</tt> onto the (plane) object called <tt>canvas</tt> (which is copy-instanced in the bed and livingroom).<br/>
Also, after lazy-loading <tt>ocean.com/aquarium.gltf</tt>, only the queried objects <tt>bass</tt> and <tt>tuna</tt> will be instanced inside <tt>aquariumcube</tt>.<br/>
Resizing will be happen accordingly to its placeholder object (<tt>aquariumcube</tt>), see chapter Scaling.<br/>
<li>XR Fragments allows <b id="tagging-text">hasslefree XR text tagging</b>, using BibTeX metadata <strong>at the end of content</strong> (like <ereftarget="https://visual.meta.info">visual-meta</eref>).</li>
<li>XR Fragments allows hasslefree <a href="#textual-tag">textual tagging</a>, <a href="#spatial-tag">spatial tagging</a>, and <a href="#supra-tagging">supra tagging</a>, by mapping 3D/text object (class)names to BibTeX</li>
<li>inline BibTeX is the minimum required <strong>requestless metadata</strong>-layer for XR text, RDF/JSON is great but optional (and too verbose for the spec-usecases).</li>
<li>Default font (unless specified otherwise) is a modern monospace font, for maximized tabular expressiveness (see <ereftarget="#core-principle">the core principle</eref>).</li>
<li>anti-pattern: hardcoupling a mandatory <strong>obtrusive markuplanguage</strong> or framework with an XR browsers (HTML/VRML/Javascript) (see <ereftarget="#core-principle">the core principle</eref>)</li>
<li>anti-pattern: limiting human introspection, by immediately funneling human thought into typesafe, precise, pre-categorized metadata like RDF (see <ereftarget="#core-principle">the core principle</eref>)</li>
</ol>
<t>This allows recursive connections between text itself, as well as 3D objects and vice versa, using <strong>BiBTeX-tags</strong> :</t>
<li><b id="textual-tagging">textual tag</b>: text or spatial-occurences named 'houses' is now automatically tagged with 'house'</li>
<li><b id="spatial-tagging">spatial tag</b>: spatial object(s) with class:house (#.house) is now automatically tagged with 'house'</li>
<li><b id="supra-tagging">supra-tag</b>: text- or spatial-object named 'house' (spatially) elsewhere, is now automatically tagged with 'house'</li>
</ol>
<t>Spatial wires can be rendered, words can be highlighted, spatial objects can be highlighted, links can be manipulated by the user.</t>
<blockquote><t>The simplicity of appending BibTeX (humans first, machines later) is demonstrated by <ereftarget="https://visual-meta.info">visual-meta</eref> in greater detail, and makes it perfect for GUI's to generate (bib)text later. Humans can still view/edit the metadata manually, by clicking 'toggle metadata' on the 'back' (contextmenu e.g.) of any XR text, anywhere anytime.</t>
<t>This indicates that any bibtex metadata starting with <tt>@</tt> will automatically get filtered out and:</t>
<ulspacing="compact">
<li>automatically detects textual links between textual and spatial objects</li>
</ul>
<t>It's concept is similar to literate programming.
Its implications are that local/remote responses can now:</t>
<ulspacing="compact">
<li>(de)multiplex/repair human text and requestless metadata (see <ereftarget="#core-principle">the core principle</eref>)</li>
<li>no separated implementation/network-overhead for metadata (see <ereftarget="#core-principle">the core principle</eref>)</li>
<li>ensuring high FPS: HTML/RDF historically is too 'requesty' for game studios</li>
<li>rich send/receive/copy-paste everywhere by default, metadata being retained (see <ereftarget="#core-principle">the core principle</eref>)</li>
<li>less network requests, therefore less webservices, therefore less servers, and overall better FPS in XR</li>
</ul>
<blockquote><t>This significantly expands expressiveness and portability of human text, by <strong>postponing machine-concerns to the end of the human text</strong> in contrast to literal interweaving of content and markupsymbols (or extra network requests, webservices e.g.).</t>
</blockquote><t>For all other purposes, regular mimetypes can be used (but are not required by the spec).<br/>
To keep XR Fragments a lightweight spec, BiBTeX is used for text-spatial object mappings (not a scripting language or RDF e.g.).</t>
<blockquote><t>Applications are also free to attach any JSON(LD / RDF) to spatial objects using custom properties (but is not interpreted by this spec).</t>
<t>Attaching visualmeta as <tt>src</tt> metadata to the (root) scene-node hints the XR Fragment browser.
3D object names and classes map to <tt>name</tt> of visual-meta glossary-entries.
This allows rich interaction and interlinking between text and 3D objects:</t>
<olspacing="compact">
<li>When the user surfs to https://.../index.gltf#AI the XR Fragments-parser points the enduser to the AI object, and can show contextual info about it.</li>
<li>When (partial) remote content is embedded thru XR Fragment queries (see XR Fragment queries), its related visual-meta can be embedded along.</li>
<li>interlinked: Collected objects by visual-meta tag</li>
</ul>
</section>
<sectionanchor="xr-fragment-queries"><name>XR Fragment queries</name>
<t>Include, exclude, hide/shows objects using space-separated strings:</t>
<ulspacing="compact">
<li><tt>#q=cube</tt></li>
<li><tt>#q=cube -ball_inside_cube</tt></li>
<li><tt>#q=* -sky</tt></li>
<li><tt>#q=-.language .english</tt></li>
<li><tt>#q=cube&rot=0,90,0</tt></li>
<li><tt>#q=price:>2 price:<5</tt></li>
</ul>
<t>It's simple but powerful syntax which allows <b>css</b>-like class/id-selectors with a searchengine prompt-style feeling:</t>
<olspacing="compact">
<li>queries are only executed when <b>embedded</b> in the asset/scene (thru <tt>src</tt>). This is to prevent sharing of scene-tampered URL's.</li>
<li>search words are matched against 3D object names or metadata-key(values)</li>
<li><tt>#</tt> equals <tt>#q=*</tt></li>
<li>words starting with <tt>.</tt> (<tt>.language</tt>) indicate class-properties</li>
</ol>
<blockquote><t>*(*For example**: <tt>#q=.foo</tt> is a shorthand for <tt>#q=class:foo</tt>, which will select objects with custom property <tt>class</tt>:<tt>foo</tt>. Just a simple <tt>#q=cube</tt> will simply select an object named <tt>cube</tt>.</t>
</blockquote>
<ulspacing="compact">
<li>see <ereftarget="https://coderofsalvation.github.io/xrfragment.media/queries.mp4">an example video here</eref></li>
|<tt>*</tt> | select all objects (only allowed in <tt>src</tt> custom property) in the <b>current</b> scene (<b>after</b> the default [[predefined_view|predefined_view]] <tt>#</tt> was executed)|
|<tt>-</tt> | removes/hides object(s) |
|<tt>:</tt> | indicates an object-embedded custom property key/value |
|<tt>.</tt> | alias for <tt>class:</tt> (<tt>.foo</tt> equals <tt>class:foo</tt> |
|<tt>></tt><tt><</tt>| compare float or int number|
|<tt>/</tt> | reference to root-scene.<br/>
Useful in case of (preventing) showing/hiding objects in nested scenes (instanced by [[src]])<br/>
<tt>#q=-/cube</tt> hides object <tt>cube</tt> only in the root-scene (not nested <tt>cube</tt> objects)<br/>
<tt>#q=-cube</tt> hides both object <tt>cube</tt> in the root-scene <b>AND</b> nested <tt>skybox</tt> objects |</t>
<t><ereftarget="https://github.com/coderofsalvation/xrfragment/blob/main/src/3rd/js/three/xrf/q.js">» example implementation</eref>
<ereftarget="https://github.com/coderofsalvation/xrfragment/blob/main/example/assets/query.gltf#L192">» example 3D asset</eref>
<li>create an associative array/object to store query-arguments as objects</li>
<li>detect object id's & properties <tt>foo:1</tt> and <tt>foo</tt> (reference regex: <tt>/^.*:[><=!]?/</tt> )</li>
<li>detect excluders like <tt>-foo</tt>,<tt>-foo:1</tt>,<tt>-.foo</tt>,<tt>-/foo</tt> (reference regex: <tt>/^-/</tt> )</li>
<li>detect root selectors like <tt>/foo</tt> (reference regex: <tt>/^[-]?\//</tt> )</li>
<li>detect class selectors like <tt>.foo</tt> (reference regex: <tt>/^[-]?class$/</tt> )</li>
<li>detect number values like <tt>foo:1</tt> (reference regex: <tt>/^[0-9\.]+$/</tt> )</li>
<li>expand aliases like <tt>.foo</tt> into <tt>class:foo</tt></li>
<li>for every query token split string on <tt>:</tt></li>
<li>create an empty array <tt>rules</tt></li>
<li>then strip key-operator: convert "-foo" into "foo"</li>
<li>add operator and value to rule-array</li>
<li>therefore we we set <tt>id</tt> to <tt>true</tt> or <tt>false</tt> (false=excluder <tt>-</tt>)</li>
<li>and we set <tt>root</tt> to <tt>true</tt> or <tt>false</tt> (true=<tt>/</tt> root selector is present)</li>
<li>we convert key '/foo' into 'foo'</li>
<li>finally we add the key/value to the store (<tt>store.foo = {id:false,root:true}</tt> e.g.)</li>
</ol>
<blockquote><t>An example query-parser (which compiles to many languages) can be <ereftarget="https://github.com/coderofsalvation/xrfragment/blob/main/src/xrfragment/Query.hx">found here</eref></t>