wip
This commit is contained in:
parent
6b6ab870ad
commit
e98b143e7b
7 changed files with 33 additions and 17 deletions
|
|
@ -76,7 +76,7 @@ let loadAudio = (mimetype) => function(url,opts){
|
|||
|
||||
// stop playing audio when loading another scene
|
||||
xrf.addEventListener('reset', () => {
|
||||
xrf.scene.traverse( (n) => n.audio && (n.audio.playXRF({x:0})) && (n.audio.remove()) )
|
||||
xrf.scene.traverse( (n) => n.audio && (n.audio.playXRF({x:0,y:0})) && (n.audio.remove()) )
|
||||
})
|
||||
|
||||
let audioMimeTypes = [
|
||||
|
|
@ -88,14 +88,3 @@ let audioMimeTypes = [
|
|||
'application/ogg'
|
||||
]
|
||||
audioMimeTypes.map( (mimetype) => xrf.frag.src.type[ mimetype ] = loadAudio(mimetype) )
|
||||
|
||||
// listen to t XR fragment changes
|
||||
xrf.addEventListener('t', (opts) => {
|
||||
let t = opts.frag.t
|
||||
xrf.scene.traverse( (n) => {
|
||||
if( !n.audio ) return
|
||||
if( !n.audio.playXRF ){
|
||||
n.audio.autoplay = t
|
||||
}else n.audio.playXRF(t)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ let loadVideo = (mimetype) => function(url,opts){
|
|||
}
|
||||
}
|
||||
|
||||
// stop playing audio when loading another scene
|
||||
xrf.addEventListener('reset', () => {
|
||||
xrf.scene.traverse( (n) => n.video && (n.video.playXRF({x:0,y:0})) && (n.video.remove()) )
|
||||
})
|
||||
|
||||
let videoMimeTypes = [
|
||||
'video/ogg',
|
||||
'video/mp4'
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ class Test {
|
|||
test( "pos.json", Spec.load("src/spec/pos.json") );
|
||||
test( "t.json", Spec.load("src/spec/t.json") );
|
||||
test( "xywh.json", Spec.load("src/spec/xywh.json") );
|
||||
test( "speed.json", Spec.load("src/spec/speed.json") );
|
||||
test( "s.json", Spec.load("src/spec/s.json") );
|
||||
test( "sxy.json", Spec.load("src/spec/sxy.json") );
|
||||
test( "filter.selectors.json", Spec.load("src/spec/filter.selectors.json") );
|
||||
//test( Spec.load("src/spec/tmp.json") );
|
||||
if( errors > 1 ) trace("\n-----\n[ ❌] "+errors+" errors :/");
|
||||
|
|
@ -50,7 +51,8 @@ class Test {
|
|||
if( item.expect.fn == "equal.xyz" ) valid = equalXYZ(res,item);
|
||||
if( item.expect.fn == "equal.mediafragmentT" ) valid = equalMediaFragment(res,item,"t");
|
||||
if( item.expect.fn == "equal.mediafragmentXYWH") valid = equalMediaFragment(res,item,"xywh");
|
||||
if( item.expect.fn == "equal.mediafragmentSpeed") valid = equalMediaFragment(res,item,"speed");
|
||||
if( item.expect.fn == "equal.mediafragmentS") valid = equalMediaFragment(res,item,"s");
|
||||
if( item.expect.fn == "equal.mediafragmentSXY") valid = equalMediaFragment(res,item,"sxy");
|
||||
if( item.expect.fn == "testFilterRoot" ) valid = res.exists(item.expect.input[0]) && res.get(item.expect.input[0]).filter.get().root == item.expect.out;
|
||||
if( item.expect.fn == "testFilterDeep" ) valid = res.exists(item.expect.input[0]) && res.get(item.expect.input[0]).filter.get().deep == item.expect.out;
|
||||
var ok:String = valid ? "[ ✔ ] " : "[ ❌] ";
|
||||
|
|
|
|||
5
src/spec/s.json
Normal file
5
src/spec/s.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
[
|
||||
{"fn":"url","data":"http://foo.com?foo=1#s=1", "expect":{ "fn":"equal.mediafragmentSpeed", "input":"0","out":"1"},"label":"playback speed"},
|
||||
{"fn":"url","data":"http://foo.com?foo=1#s=0.5", "expect":{ "fn":"equal.mediafragmentSpeed", "input":"0","out":"0.5"},"label":"playback speed"},
|
||||
{"fn":"url","data":"http://foo.com?foo=1#s=-0.5", "expect":{ "fn":"equal.mediafragmentSpeed", "input":"0","out":"-0.5"},"label":"playback speed"}
|
||||
]
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
[
|
||||
{"fn":"url","data":"http://foo.com?foo=1#speed=0,0,1.2,1", "expect":{ "fn":"equal.mediafragmentSpeed", "input":"2","out":"1.2"},"label":"speed"}
|
||||
{"fn":"url","data":"http://foo.com?foo=1#sxy=l:0,0.1", "expect":{ "fn":"equal.mediafragmentSXY", "input":"1","out":"0.2"},"label":"sxy"},
|
||||
{"fn":"url","data":"http://foo.com?foo=1#sxy=0,0.1", "expect":{ "fn":"equal.mediafragmentSXY", "input":"1","out":"0.2"},"label":"sxy looped"}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -7,5 +7,9 @@
|
|||
{"fn":"url","data":"http://foo.com?foo=1#t=1,-2,3", "expect":{ "fn":"equal.xyz", "input":"t","out":"1,-2,3"},"label":"a equal.xyz"},
|
||||
{"fn":"url","data":"http://foo.com?foo=1#t=1,100", "expect":{ "fn":"equal.xy", "input":"t","out":"1,100"},"label":"a equal.xy"},
|
||||
{"fn":"url","data":"http://foo.com?foo=1#t=2,500", "expect":{ "fn":"testBrowserOverride", "input":"t","out":true},"label":"browser URI can override t (defined in asset)"},
|
||||
{"fn":"url","data":"http://foo.com?foo=1#t=1,100,400,500*1.2,2.3", "expect":{ "fn":"equal.mediafragmentT", "input":"3","out":"500"},"label":"a equal.mediafragment"}
|
||||
{"fn":"url","data":"http://foo.com?foo=1#t=1,100,400,500", "expect":{ "fn":"equal.mediafragmentT", "input":"3","out":"500"},"label":"a equal.mediafragment"},
|
||||
{"fn":"url","data":"http://foo.com?foo=1#t=l:1,100,400,500", "expect":{ "fn":"equal.mediafragmentT", "input":"3","out":"500"},"label":"a equal.mediafragment loop"},
|
||||
{"fn":"url","data":"http://foo.com?foo=1#t=v:l:1,100,400,500", "expect":{ "fn":"equal.mediafragmentT", "input":"3","out":"500"},"label":"a equal.mediafragment uv loop "},
|
||||
{"fn":"url","data":"http://foo.com?foo=1#t=v:1,100,400,500", "expect":{ "fn":"equal.mediafragmentT", "input":"3","out":"500"},"label":"a equal.mediafragment uv"},
|
||||
{"fn":"url","data":"http://foo.com?foo=1#t=v:1,2", "expect":{ "fn":"testParsed", "input":"mycustom","out":true},"label":"test uv is set"}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class XRF {
|
|||
public static var isExclude:EReg = ~/^-/; // 1. detect excluders like `-foo`,`-foo=1`,`-.foo`,`-/foo` (reference regex= `/^-/` )
|
||||
public static var isDeep:EReg = ~/\*/; // 1. detect deep selectors like `foo*` (reference regex= `/\*$/` )
|
||||
public static var isNumber:EReg = ~/^[0-9\.]+$/; // 1. detect number values like `foo=1` (reference regex= `/^[0-9\.]+$/` )
|
||||
public static var isMediaFrag:EReg = ~/^[0-9\.,\*]+$/; // 1. detect (extended) media fragment
|
||||
public static var isMediaFrag:EReg = ~/^(uv:)?(l:)?([0-9\.,\*]+)$/; // 1. detect (extended) media fragment
|
||||
|
||||
// value holder(s) // |------|------|--------|----------------------------------|
|
||||
public var fragment:String;
|
||||
|
|
@ -65,6 +65,8 @@ class XRF {
|
|||
public var float:Float; // |float | | [-]x[.xxxx] (ieee)| #prio=-20 |
|
||||
public var filter:Filter;
|
||||
public var noXRF:Bool;
|
||||
public var loop:Bool;
|
||||
public var uv:Bool;
|
||||
//
|
||||
public function new(_fragment:String,_flags:Int,?_index:Int){
|
||||
fragment = _fragment;
|
||||
|
|
@ -99,6 +101,14 @@ class XRF {
|
|||
v.string = str;
|
||||
if( !Std.isOfType(str,String) ) return;
|
||||
if( str.length > 0 ){
|
||||
if( str.split("l:").length > 1 ){
|
||||
str = str.split("l:")[1];
|
||||
v.loop = true;
|
||||
}
|
||||
if( str.split("uv:").length > 1 ){
|
||||
str = str.split("uv:")[1];
|
||||
v.uv = true;
|
||||
}
|
||||
if( str.split(",").length > 1){ // 1. `,` assumes 1D/2D/3D vector-values like x[,y[,z]]
|
||||
var xyzn:Array<String> = str.split(","); // 1. parseFloat(..) and parseInt(..) is applied to vector/float and int values
|
||||
if( xyzn.length > 0 ) v.x = Std.parseFloat(xyzn[0]); // 1. anything else will be treated as string-value
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue