From 513127a92bcb459909ad518f58f65a5560c6c614 Mon Sep 17 00:00:00 2001 From: Leon van Kammen Date: Mon, 18 Dec 2023 09:55:20 +0100 Subject: [PATCH] work in progress [might break] --- com/helloworld.js | 30 ++++++++++++++++++++++++++++++ com/require.js | 16 +++++++++------- com/xrsh.js | 2 +- 3 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 com/helloworld.js diff --git a/com/helloworld.js b/com/helloworld.js new file mode 100644 index 0000000..e854784 --- /dev/null +++ b/com/helloworld.js @@ -0,0 +1,30 @@ +AFRAME.registerComponent('helloworld', { + schema:{ + things: {type:'array'}, + $: {default: document.createElement('div') } + }, + init: function() { + + this.data = new Proxy( this.data, { + html(data){ + return ` + + + ` + }, + render(data ){ return `
  • ${data.things.join("
  • ")}
  • `}, + set(data,k,v){ (data[k] = v) && (data.$.innerHTML = this.html(data)) }, + get(data,k ){ return data[k] != undefined ? data[k] : data } + }) + + document.body.appendChild(this.data.$) + + setInterval( () => { + // update js --> HTML+AFRAME + this.data.things = [ ...this.data.things, Math.random() ].slice(-3) + + },500) + + }, + +}) diff --git a/com/require.js b/com/require.js index 8c7aa88..6a01ad1 100644 --- a/com/require.js +++ b/com/require.js @@ -3,10 +3,12 @@ AFRAME.registerComponent('require', { }, }) - // -const updateComponents = AFRAME.AEntity.prototype.updateComponents -AFRAME.AEntity.prototype.updateComponents = function(updateComponents){ - return function(){ - return updateComponents.apply(this,args) - } -}(updateComponents) +// work in progress +// +// // +//const updateComponents = AFRAME.AEntity.prototype.updateComponents +//AFRAME.AEntity.prototype.updateComponents = function(updateComponents){ +// return function(){ +// return updateComponents.apply(this,args) +// } +//}(updateComponents) diff --git a/com/xrsh.js b/com/xrsh.js index 90ea98e..384b407 100644 --- a/com/xrsh.js +++ b/com/xrsh.js @@ -1,4 +1,4 @@ -AFRAME.registerComponent('xrshell', { +AFRAME.registerComponent('xrsh', { init: function ( ) { console.log("this is the boot component which initializes other components")