From b61f6371d0b9778f67cf683bc8e05a3972b3c76c Mon Sep 17 00:00:00 2001 From: Leon van Kammen Date: Thu, 21 Dec 2023 12:47:28 +0000 Subject: [PATCH] wip --- example/aframe/sandbox/index.html | 14 +++++--- make | 8 ++--- src/3rd/js/extra/$meeting.js | 20 +++++------ src/3rd/js/extra/$menu.js | 3 +- src/3rd/js/extra/meeting.js | 46 ++++++++++++++++-------- src/3rd/js/three/index.js | 3 -- src/3rd/js/three/xrf/dynamic/uvscroll.js | 2 +- 7 files changed, 55 insertions(+), 41 deletions(-) diff --git a/example/aframe/sandbox/index.html b/example/aframe/sandbox/index.html index 87f8526..6c1dbbd 100644 --- a/example/aframe/sandbox/index.html +++ b/example/aframe/sandbox/index.html @@ -5,15 +5,17 @@ - - + + + + - + @@ -29,8 +31,8 @@ diff --git a/make b/make index ba1b51c..51fcbb4 100755 --- a/make +++ b/make @@ -89,12 +89,12 @@ build(){ cat src/3rd/js/extra/*.js > dist/xrfragment.extras.js # fat all-in-one standalone xrf release - test -f /tmp/xrf-aframe.js || { - wget "https://aframe.io/releases/1.5.0/aframe.min.js" -O /tmp/xrf-aframe.js - wget "https://cdn.jsdelivr.net/npm/aframe-blink-controls/dist/aframe-blink-controls.min.js" -O /tmp/xrf-blink.js + test -f dist/aframe.min.js || { + wget "https://aframe.io/releases/1.5.0/aframe.min.js" -O dist/aframe.min.js + wget "https://cdn.jsdelivr.net/npm/aframe-blink-controls/dist/aframe-blink-controls.min.js" -O dist/aframe-blink-controls.min.js } - cat /tmp/xrf-*.js dist/xrfragment.aframe.js dist/xrfragment.extras.js > dist/xrfragment.aframe.all.js + cat dist/aframe.min.js dist/aframe-blink-controls.min.js dist/xrfragment.aframe.js dist/xrfragment.extras.js > dist/xrfragment.aframe.all.js # add license headers for file in dist/xrfragment.{aframe,module,three,three.module,aframe.all}.js; do diff --git a/src/3rd/js/extra/$meeting.js b/src/3rd/js/extra/$meeting.js index 473cf98..519b9f8 100644 --- a/src/3rd/js/extra/$meeting.js +++ b/src/3rd/js/extra/$meeting.js @@ -14,16 +14,15 @@ MEETING = { init: (el) => new Proxy({ - scene: null, - enabled: false, - active: false, + scene: null, + visible: false, //$overlay: $overlay = el.querySelector('#overlay'), // install(opts){ this.scene = opts.scene - window.meeting.buttons.push(`🧑‍🤝‍🧑 meeting
`) - document.body.appendChild( el ) + document.body.appendChild( el ) + document.dispatchEvent( new CustomEvent("MEETING:ready", {detail: opts}) ) }, start(){ @@ -31,11 +30,7 @@ MEETING = { this.scene.addEventListener('meeting.peer.remove', () => console.log("$meeting.peer.remove") ) }, - toggle: () => MEETING.collapsed = !MEETING.collapsed, - install: (opts) => { - document.body.appendChild(el) - document.dispatchEvent( new CustomEvent("MEETING:ready", {detail: opts}) ) - } + toggle: () => MEETING.visible = !MEETING.visible, },{ @@ -43,7 +38,7 @@ MEETING = { set(data,k,v){ data[k] = v switch( k ){ - case "css": document.head.innerHTML += v; break; + case "visible": el.style.display = data.visible ? 'block' : 'none' } }, @@ -53,6 +48,9 @@ MEETING = { // reactify component! document.addEventListener('XRFMENU:ready', (opts) => { opts = opts.detail + XRFMENU.buttons = ([`🧑‍🤝‍🧑 meeting
`]) + .concat(XRFMENU.buttons) + document.head.innerHTML += MEETING.css $meeting = document.createElement('div') $meeting.innerHTML = MEETING.html MEETING = MEETING.init($meeting) diff --git a/src/3rd/js/extra/$menu.js b/src/3rd/js/extra/$menu.js index a7c77cd..8cce61e 100644 --- a/src/3rd/js/extra/$menu.js +++ b/src/3rd/js/extra/$menu.js @@ -63,8 +63,7 @@ $xrfmenu = document.createElement('div') $xrfmenu.innerHTML = XRFMENU.html XRFMENU = XRFMENU.init($xrfmenu) - -// here come all menu functions which are less related to rendering +// attach menu functions which are less related to rendering let utils = { bindToWindow(opts){ diff --git a/src/3rd/js/extra/meeting.js b/src/3rd/js/extra/meeting.js index 1955ac8..28832d8 100644 --- a/src/3rd/js/extra/meeting.js +++ b/src/3rd/js/extra/meeting.js @@ -1,22 +1,38 @@ // this orchestrates multiplayer events from the scene graph -window.meeting = (THREE, scene) => ({ - peer:{ - peers: [], - add(peer){ - let defaults = {lastUpdated: new Date().getTime() } - peer = { ...defaults,...peer} - this.peers.push(peer) - scene.dispatchEvent({type:'meeting.peer.add', peer}) - }, - remove(peer){ - scene.dispatchEvent({type:'meeting.peer.remove', peer}) - }, - send(opts){ +window.meeting = (THREE, scene) => new Proxy({ + + status: 'offline', + peers: {}, - }, - receive(opts){ + add(peerid,data){ + data = {lastUpdated: new Date().getTime(), id: peerid, ...data } + this.peers[peerid] = data + scene.dispatchEvent({type:'meeting.peer.add', peer}) + }, + + remove(peerid,data){ + delete this.peers[peerid] + scene.dispatchEvent({type:'meeting.peer.remove', peer}) + }, + + send(opts){ + + }, + + receive(opts){ + + } +}, +{ + // auto-trigger events on changes + get(meeting,k,receiver){ return meeting[k] }, + set(meeting,k,v){ + let from = meeting[k] + meeting[k] = v + switch( k ){ + default: scene.dispatchEvent({type:`meeting.${k}.change`, from, to:v}) } } }) diff --git a/src/3rd/js/three/index.js b/src/3rd/js/three/index.js index c48f10c..9dcb685 100644 --- a/src/3rd/js/three/index.js +++ b/src/3rd/js/three/index.js @@ -15,9 +15,6 @@ xrf.init = ((init) => function(opts){ // return xrfragment lib as 'xrf' query functor (like jquery) for ( let i in xrf ) xrf.query[i] = xrf[i] - // install menu+extras if available - if( typeof XRFMENU != 'undefined' ) XRFMENU.install(xrf) - return xrf.query })(xrf.init) diff --git a/src/3rd/js/three/xrf/dynamic/uvscroll.js b/src/3rd/js/three/xrf/dynamic/uvscroll.js index 726c2c1..b435b88 100644 --- a/src/3rd/js/three/xrf/dynamic/uvscroll.js +++ b/src/3rd/js/three/xrf/dynamic/uvscroll.js @@ -2,7 +2,7 @@ xrf.addEventListener('dynamicKeyValue', (opts) => { let {scene,match,v} = opts let objname = v.fragment let autoscroll = v.z > 0 || v.w > 0 - +return // DISABLED scene.traverse( (mesh) => { if( mesh.name == objname ){ if( !mesh.geometry ) return console.warn(`mesh '${objname}' has no uvcoordinates to offset`)