|
|
|
@ -16,6 +16,8 @@ |
|
|
|
|
/* TODO : |
|
|
|
|
- refactor to use emit('eventname', {eventdata:'data'}) for onreleased and onpicked rather than latest element |
|
|
|
|
e.g newEl.setAttribute("onreleased", 'document.querySelector("['+generatorName+']").emit("check",{color:"'+color+'"})') |
|
|
|
|
let latest = selectedElements[selectedElements.length-1].element |
|
|
|
|
check for this pattern and replace by event.detail.element instead |
|
|
|
|
- insure scene setup, e.g starting position and orientation of environment and main character (until now assumed unchanged) |
|
|
|
|
- isolate emit('eventname', {test:0}) versus same with onreleased (which does NOT work) and same without event detail (which works) |
|
|
|
|
- add audio instructions |
|
|
|
@ -52,8 +54,8 @@ AFRAME.registerComponent('startfunctions', { |
|
|
|
|
let newEl = document.createElement('a-entity') |
|
|
|
|
//let gamename = "checkers" |
|
|
|
|
//let gamename = "carcassone" |
|
|
|
|
let gamename = "simon" |
|
|
|
|
//let gamename = "voxelpaint" |
|
|
|
|
//let gamename = "simon" |
|
|
|
|
let gamename = "voxelpaint" |
|
|
|
|
newEl.id = gamename |
|
|
|
|
newEl.setAttribute(gamename, "") |
|
|
|
|
newEl.classList.add( "game" ) |
|
|
|
@ -168,8 +170,8 @@ AFRAME.registerComponent('voxelpaint', { |
|
|
|
|
let poses = [] |
|
|
|
|
Array.from( this.el.querySelectorAll(".voxel") ).map( el => { |
|
|
|
|
poses.push( { |
|
|
|
|
position: el.getAttribute("position"), |
|
|
|
|
rotation: el.getAttribute("rotation"), |
|
|
|
|
position: this.shortenVector3( el.getAttribute("position") ), |
|
|
|
|
rotation: this.shortenVector3( el.getAttribute("rotation") ), |
|
|
|
|
color: el.getAttribute("color") |
|
|
|
|
} ) |
|
|
|
|
}) |
|
|
|
@ -178,6 +180,13 @@ AFRAME.registerComponent('voxelpaint', { |
|
|
|
|
window.location.hash = JSON.stringify(data) |
|
|
|
|
// prefixed by generatorName in order to support saving/sharing of the state of other games |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
shortenVector3: function ( v ){ |
|
|
|
|
let o = new THREE.Vector3() |
|
|
|
|
o.x = v.x.toFixed(3) |
|
|
|
|
o.y = v.y.toFixed(3) |
|
|
|
|
o.z = v.z.toFixed(3) |
|
|
|
|
return o |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|