2023-03-31 14:47:54 +02:00
|
|
|
|
|
2023-03-31 16:38:11 +02:00
|
|
|
|
|
2023-03-31 17:27:40 +02:00
|
|
|
|
# `://foo.com/my3d.asset#pos=1,0,0&prio=-5`
|
2023-03-30 19:51:32 +02:00
|
|
|
|
|
2023-03-31 14:40:24 +02:00
|
|
|
|
# URI parser
|
|
|
|
|
|
2023-03-31 17:27:40 +02:00
|
|
|
|
> icanhazcode? yes, see [URI.hx](https://github.com/coderofsalvation/xrfragment/blob/main/src/xrfragment/URI.hx)
|
2023-03-31 12:58:53 +02:00
|
|
|
|
|
|
|
|
|
1. fragment URI starts with `#`
|
|
|
|
|
1. fragments are split by `&`
|
|
|
|
|
1. `=` is used to split fragment key/values
|
|
|
|
|
1. fragment-values are urlencoded (space becomes `+` using `encodeUriComponent` e.g.)
|
|
|
|
|
1. every recognized fragment key/value-pair is added to a central map/associative array/object
|
|
|
|
|
|
|
|
|
|
# XR Fragments (key/value params)
|
2023-03-30 19:51:32 +02:00
|
|
|
|
|
2023-03-31 17:27:40 +02:00
|
|
|
|
> ⛁ = supported in 3D asset-file (custom property or projection)<br>
|
|
|
|
|
> ⚂ = supported in navigator URI (`document.location.href` e.g.)<br>
|
2023-03-31 17:16:39 +02:00
|
|
|
|
|
2023-03-31 17:15:57 +02:00
|
|
|
|
| param | type | scope(s) | category | notes |
|
|
|
|
|
|---------|---------------|-------|--------------------|---------------------------------|
|
|
|
|
|
| prio | int (-10..1) | ⛁ | Asset loading / linking | \#static allow client to ignore lower-prio objects in the renderloop, to compensate frame-drop/cpu/gpu-overload scenario’soc/notes/prio.md |
|
|
|
|
|
| pos | 3D vector | ⛁ ⚂ |HREF navigation/portals | |
|
2023-03-30 19:51:32 +02:00
|
|
|
|
|
|
|
|
|
|
2023-03-31 14:40:24 +02:00
|
|
|
|
# XR Fragments parser
|
2023-03-31 16:35:54 +02:00
|
|
|
|
note: community parsers will prolly outperform this initial parser :)
|
2023-03-31 17:27:40 +02:00
|
|
|
|
> icanhazcode? yes, see [Parser.hx](https://github.com/coderofsalvation/xrfragment/blob/main/src/xrfragment/Parser.hx)
|
2023-03-30 19:51:32 +02:00
|
|
|
|
|
2023-03-31 14:40:24 +02:00
|
|
|
|
the gist of it:
|
|
|
|
|
1. each key has a regex to validate its value-type (see regexes)
|
2023-03-30 19:51:32 +02:00
|
|
|
|
1. `|` is used to split multiple/fallback values
|
|
|
|
|
1. `,` assumes 1D/2D/3D vector-values like x[,y[,z]]
|
|
|
|
|
1. parseFloat(..) and parseInt(..) is applied to vector/float and int values
|
|
|
|
|
1. anything else will be treated as string-value
|
|
|
|
|
1. incompatible value-types will be dropped / not used
|
|
|
|
|
|
|
|
|
|
> the xrfragment specification should stay simple enough
|
|
|
|
|
> for anyone to write a parser using either regexes or grammar/lexers
|
|
|
|
|
> therefore expressions/comprehensions are not supported (max wildcard/comparison operators for queries e.g.)
|
|
|
|
|
|
2023-03-31 15:57:35 +02:00
|
|
|
|
# Parser Value types
|
2023-03-30 15:44:13 +02:00
|
|
|
|
|
|
|
|
|
| type | info | format | example |
|
2023-03-30 15:57:58 +02:00
|
|
|
|
|------|------|--------|----------------------------------|
|
2023-03-30 15:44:13 +02:00
|
|
|
|
|vector| x,y,z| comma-separated | #pos=1,2,3 |
|
|
|
|
|
|string| color| FFFFFF (hex) | #fog=5m,FFAACC |
|
|
|
|
|
|string| | | #q=-sun |
|
|
|
|
|
|int | | [-]x[xxxxx] | #price:>=100 |
|
|
|
|
|
|float | | [-]x[.xxxx] (ieee)| #prio=-20
|
|
|
|
|
|array | mixed| \|-separated | #pos=0,0,0|90,0,0 |
|
|
|
|
|
|
2023-03-30 16:23:47 +02:00
|
|
|
|
> rule for thumb: type-limitations will piggyback JSON limitations (IEEE floatsize e.g.)
|
|
|
|
|
|
|
|
|
|
1. hex colors are detected using regex `/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/`
|
|
|
|
|
1. integers are detected using regex `/^[0-9]+$/`
|
|
|
|
|
1. floats are detected using regex `/^[0-9]+\.[0-9]+$/`
|
2023-03-30 19:51:32 +02:00
|
|
|
|
1. vectors are detected using regex `/[,]/` (but can also be an string referring to an entity-ID in the asset)
|
2023-03-31 12:58:53 +02:00
|
|
|
|
|
|
|
|
|
# Tests
|
|
|
|
|
|
2023-03-31 13:32:44 +02:00
|
|
|
|
the spec is tested with [JSON unittests](./../src/spec) consumed by [Test.hx](./../src/Test.hx) to cross-test all languages.
|