work in progress [might break]

This commit is contained in:
Leon van Kammen 2024-02-15 11:43:15 +00:00
parent 786173a9e0
commit a539559ae9
4 changed files with 18 additions and 6 deletions

Binary file not shown.

View file

@ -21,10 +21,19 @@ xrf.addEventListener('parseModel', (opts) => {
})
model.scene.traverse( (n) => {
const variables = /{([a-zA-Z0-9-]+)}/g
if( n.userData ){
for( let i in n.userData ){
if( i[0] == '#' || i.match(/^(href|src|tag)$/) ) continue // ignore XR Fragment aliases
xrf.URI.vars[i] = () => n.userData[i]
if( i[0] == '#' || i.match(/^(href|tag)$/) ) continue // ignore XR Fragment aliases
if( i == 'src' ){
// lets declare empty variables found in src-values ('https://foo.com/video.mp4#{somevar}') e.g.
if( n.userData[i].match(variables) ){
let vars = [].concat( n.userData[i].match(variables) )
const strip = (v) => v.replace(/[{}]/g,'')
vars.map( (v) => xrf.URI.vars[ strip(v) ] = () => '' )
}
}else xrf.URI.vars[i] = () => n.userData[i] // declare variables with values
}
}
})
@ -38,13 +47,13 @@ xrf.addEventListener('dynamicKeyValue', (opts) => {
if( !v.is( xrf.XRF.CUSTOMFRAG) ) return // only process custom frags from here
if( v.string.match(/(<|>)/) ) return // ignore filter values
if( match.length > 0 ){
xrf.frag.dynamic.material(v,opts) // check if fragment is an objectname
}
if( !xrf.URI.vars[ v.string ] ) return console.error(`'${v.string}' metadata-key not found in scene`)
if( xrf.URI.vars[ id ] && !match.length ) return console.error(`'${id}' object/tag/metadata-key not found in scene`)
//if( xrf.URI.vars[ id ] && !match.length ) return console.error(`'${id}' object/tag/metadata-key not found in scene`)
if( xrf.debug ) console.log(`URI.vars[${id}]='${v.string}'`)

View file

@ -9,7 +9,10 @@ const doFilter = (opts) => {
}
xrf.addEventListener('dynamicKey', doFilter )
xrf.addEventListener('dynamicKeyValue', doFilter )
xrf.addEventListener('dynamicKeyValue', (opts) => {
console.log("*TODO* filter integers only")
// doFilter(opts)
})
// spec: https://xrfragment.org/#filters
xrf.filter = function(query, cb){

View file

@ -36,7 +36,7 @@ xrf.frag.uv.scroll = function(){
if( this.uv.uspeed == 1.0 ) uv.setX(i, this.uv.ushift ? uv.getX(i) + this.uv.u : uv.old.getX(i) + this.uv.u )
if( this.uv.vspeed == 1.0 ) uv.setY(i, this.uv.vshift ? uv.getY(i) + this.uv.v : uv.old.getY(i) + this.uv.v )
if( this.uv.uloop || this.uv.vloop ){
if( this.uv.uspeed != 1.0 || this.uv.vspeed != 1.0 ){
let u = uv.getX(i)
let v = uv.getY(i)
let uTarget = this.uv.ushift ? uv.getX(i) + this.uv.u : uv.old.getX(i) + this.uv.u