work in progress [might break]

This commit is contained in:
Leon van Kammen 2023-03-31 15:57:35 +02:00
parent 785516f975
commit 6bc1e9bbe5
8 changed files with 29 additions and 21 deletions

6
dist/xrfragment.js vendored
View file

@ -113,8 +113,8 @@ haxe_iterators_ArrayIterator.prototype = {
var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
xrfragment_Parser.parse = function(key,value,resultMap) {
var Frag_h = Object.create(null);
Frag_h["pos"] = xrfragment_Type.isVector;
Frag_h["prio"] = xrfragment_Type.isInt;
Frag_h["pos"] = xrfragment_Type.isVector;
if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
if(Frag_h[key].match(value)) {
var v = new xrfragment_Value();
@ -133,11 +133,11 @@ xrfragment_Parser.parse = function(key,value,resultMap) {
}
resultMap[key] = v;
} else {
console.log("src/xrfragment/Parser.hx:32:","[ i ] fragment '" + key + "' has incompatible value (" + value + ")");
console.log("src/xrfragment/Parser.hx:33:","[ i ] fragment '" + key + "' has incompatible value (" + value + ")");
return false;
}
} else {
console.log("src/xrfragment/Parser.hx:33:","[ i ] fragment '" + key + "' does not exist or has no type defined (yet)");
console.log("src/xrfragment/Parser.hx:34:","[ i ] fragment '" + key + "' does not exist or has no type defined (yet)");
return false;
}
return true;

View file

@ -1,8 +1,9 @@
> version 1.0.0
date: 2023-03-31T14:48:17+0200 (generated by `./make doc`)
date: 2023-03-31T15:57:18+0200 (generated by `./make doc`)
example URI: `://domain.com/some3d.asset#pos=1,0,0&prio=-5`
##
# example URI: `://domain.com/some3d.asset#pos=1,0,0&prio=-5`
# URI parser
@ -16,10 +17,10 @@ example URI: `://domain.com/some3d.asset#pos=1,0,0&prio=-5`
# XR Fragments (key/value params)
| param | type | category | example |
|---------|---------------|-------------------------|------------------|
| pos | 3D vector | HREF navigation/portals | `#pos=1,0,1` or `#pos=foo` |
| prio | int (-10..1) | Asset linking | `#prio=-5` |
| param | type | 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 scenariosoc/notes/prio.md |
| pos | 3D vector | HREF navigation/portals | |
# XR Fragments parser
@ -38,7 +39,7 @@ the gist of it:
> 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.)
# Value types
# Parser Value types
| type | info | format | example |
|------|------|--------|----------------------------------|

1
doc/notes/prio.md Normal file
View file

@ -0,0 +1 @@
\#static allow client to ignore lower-prio objects in the renderloop, to compensate frame-drop/cpu/gpu-overload scenarios

7
make
View file

@ -36,9 +36,14 @@ doc(){
cat $1 | awk '/\/\/ / {
gsub(".*// ","",$0);
gsub("# ","\n# ",$0);
if( match($0,/^#include /) ){ system("cat "$2); next; }
if( match($0,/^#code /) ){ print "```\n"; system("cat "$2); print "```\n"; next; }
if( match($0,/^#sh /) ){ $1=""; system($0); next; }
if( match($0,/#include /) ) {
o=$0; gsub(/.*#include/,"#include",$0); f=$2; $0=o;
cmd="cat "f
cmd | getline text; close(cmd)
gsub(/#include \w/, text)
}
print $0;
}'
}

View file

@ -8,10 +8,11 @@ class Parser { // #
@:keep
public static function parse(key:String,value:String,resultMap:haxe.DynamicAccess<Dynamic>):Bool {
// | param | type | category | example |
var Frag:Map<String, EReg> = new Map<String, EReg>(); // |---------|---------------|-------------------------|------------------|
Frag.set("pos", Type.isVector); // | pos | 3D vector | HREF navigation/portals | `#pos=1,0,1` or `#pos=foo` |
Frag.set("prio", Type.isInt); // | prio | int (-10..1) | Asset linking | `#prio=-5` |
var Frag:Map<String, EReg> = new Map<String, EReg>(); // | param | type | category | notes |
// |---------|---------------|-------------------------|-------------------------|
Frag.set("prio", Type.isInt); // | prio | int (-10..1) | Asset loading / linking | #include doc/notes/prio.md |
Frag.set("pos", Type.isVector); // | pos | 3D vector | HREF navigation/portals | |
//
// # XR Fragments parser
if( Frag.exists(key) ){ //
@ -51,7 +52,7 @@ class Parser { // #
}
}
// # Value types
// # Parser Value types
//
// | type | info | format | example |
class Value { // |------|------|--------|----------------------------------|

View file

@ -5,7 +5,7 @@ import xrfragment.Parser;
@:expose // <- makes the class reachable from plain JavaScript
@:keep // <- avoids accidental removal by dead code elimination
//
// example URI: `://domain.com/some3d.asset#pos=1,0,0&prio=-5`
// ### example URI: `://domain.com/some3d.asset#pos=1,0,0&prio=-5`
class URI {
@:keep // # URI parser
public static function parse(qs:String):haxe.DynamicAccess<Dynamic> { //

View file

@ -283,8 +283,8 @@ var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
xrfragment_Parser.__name__ = true;
xrfragment_Parser.parse = function(key,value,resultMap) {
var Frag_h = Object.create(null);
Frag_h["pos"] = xrfragment_Type.isVector;
Frag_h["prio"] = xrfragment_Type.isInt;
Frag_h["pos"] = xrfragment_Type.isVector;
if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
if(Frag_h[key].match(value)) {
var v = new xrfragment_Value();
@ -303,11 +303,11 @@ xrfragment_Parser.parse = function(key,value,resultMap) {
}
resultMap[key] = v;
} else {
console.log("src/xrfragment/Parser.hx:32:","[ i ] fragment '" + key + "' has incompatible value (" + value + ")");
console.log("src/xrfragment/Parser.hx:33:","[ i ] fragment '" + key + "' has incompatible value (" + value + ")");
return false;
}
} else {
console.log("src/xrfragment/Parser.hx:33:","[ i ] fragment '" + key + "' does not exist or has no type defined (yet)");
console.log("src/xrfragment/Parser.hx:34:","[ i ] fragment '" + key + "' does not exist or has no type defined (yet)");
return false;
}
return true;

View file

@ -1368,8 +1368,8 @@ class xrfragment_Parser:
@staticmethod
def parse(key,value,resultMap):
Frag = haxe_ds_StringMap()
Frag.h["pos"] = xrfragment_Type.isVector
Frag.h["prio"] = xrfragment_Type.isInt
Frag.h["pos"] = xrfragment_Type.isVector
if (key in Frag.h):
_this = Frag.h.get(key,None)
_this.matchObj = python_lib_Re.search(_this.pattern,value)