2.9 KiB
2.9 KiB
://foo.com/my3d.asset#pos=1,0,0&prio=-5
URI parser
icanhazcode? yes, see URI.hx
- fragment URI starts with
#
- fragments are split by
&
=
is used to split fragment key/values- fragment-values are urlencoded (space becomes
+
usingencodeUriComponent
e.g.) - every recognized fragment key/value-pair is added to a central map/associative array/object
XR Fragments (key/value params)
⛁ = supported in 3D asset-file (custom property or projection)
⚂ = supported in navigator URI (document.location.href
e.g.)
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 |
XR Fragments parser
note: community parsers will prolly outperform this initial parser :)
icanhazcode? yes, see Parser.hx
the gist of it:
- each key has a regex to validate its value-type (see regexes)
|
is used to split multiple/fallback values,
assumes 1D/2D/3D vector-values like x[,y[,z]]- parseFloat(..) and parseInt(..) is applied to vector/float and int values
- anything else will be treated as string-value
- 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.)
Parser Value types
type | info | format | example |
---|---|---|---|
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 |
rule for thumb: type-limitations will piggyback JSON limitations (IEEE floatsize e.g.)
- hex colors are detected using regex
/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/
- integers are detected using regex
/^[0-9]+$/
- floats are detected using regex
/^[0-9]+\.[0-9]+$/
- vectors are detected using regex
/[,]/
(but can also be an string referring to an entity-ID in the asset)
Tests
the spec is tested with JSON unittests consumed by Test.hx to cross-test all languages.