fixed unwanted move

warmup
Fabien Benetou 2 years ago
parent 325f47e7fb
commit 5d17a90bd6
  1. 69
      index.html

@ -109,10 +109,10 @@ var commandhistory = []
const savedProperties = [ "src", "position", "rotation", "scale", "value", ] // add newer properties e.g visibility and generator as class
var groupSelection = []
var cabin
const url = 'https://fabien.benetou.fr/PIMVRdata/CabinData?action='
const url = "https://fabien.benetou.fr/PIMVRdata/CabinData?action="
var generators = "line-link-entities link screenstack dynamic-view selectionboxonpinches keyboard "
+ "commands-from-external-json glossary timeline issues web-url background-via-url observableui hidableenvironmentfot fot"
// could be an array proper completed on each component registration
// could be an array proper completed on each relevant component registration
// could add a dedicated MakeyMakey mode with a fixed camera, e.g bird eye view, and an action based on some physical input that others, thanks to NAF, could see or even use.
// ?inputmode=makeymakey
@ -747,12 +747,44 @@ function setHUD(txt){
document.querySelector("[hud]>a-troika-text").setAttribute("value",txt)
}
AFRAME.registerComponent('wristattachsecondary',{
schema: {
target: {type: 'selector'},
},
init: function () {
var el = this.el
this.worldPosition=new THREE.Vector3();
//var side = this.el.getAttribute("hand-tracking-controls").hand[0] // fails
// (this.el.components)
this.side = "l"
if ( this.el.getAttribute("hand-tracking-controls").indexOf("right") ) this.side = "r"
},
tick: function () {
// could check if it exists first, or isn't 0 0 0... might re-attach fine, to test
// somehow very far away... need to convert to local coordinate probably
// localToWorld?
var worldPosition=this.worldPosition;
//this.el.object3D.traverse( e => { if (e.name == "b_"+this.side+"_wrist") {
this.el.object3D.traverse( e => { if (e.name == "b_l_wrist") {
worldPosition.copy(e.position);e.parent.updateMatrixWorld();e.parent.localToWorld(worldPosition)
rotation = e.rotation.x*180/3.14 + " " + e.rotation.y*180/3.14 + " " + e.rotation.z*180/3.14
this.data.target.setAttribute("rotation", rotation)
this.data.target.setAttribute("position",
AFRAME.utils.coordinates.stringify( worldPosition ) )
// doesnt work anymore...
//this.data.target.setAttribute("rotation", AFRAME.utils.coordinates.stringify( e.getAttribute("rotation") )
}
})
}
});
AFRAME.registerComponent('pinchsecondary', {
init: function () {
this.el.addEventListener('pinchended', function (event) {
selectedElement = getClosestTargetElement( event.detail.position )
// if close enough to a target among a list of potential targets, unselect previous target then select new
if (selectedElement) interpretJXR( selectedElement.getAttribute("value") )
selectedElement = null
if (setupMode) setupBBox["B"] = event.detail.position
if ( setupBBox["A"] && setupBBox["B"] ) {
setupMode = false
@ -781,38 +813,7 @@ AFRAME.registerComponent('pinchsecondary', {
}
});
AFRAME.registerComponent('wristattachsecondary',{
schema: {
target: {type: 'selector'},
},
init: function () {
var el = this.el
this.worldPosition=new THREE.Vector3();
//var side = this.el.getAttribute("hand-tracking-controls").hand[0] // fails
// (this.el.components)
this.side = "l"
if ( this.el.getAttribute("hand-tracking-controls").indexOf("right") ) this.side = "r"
},
tick: function () {
// could check if it exists first, or isn't 0 0 0... might re-attach fine, to test
// somehow very far away... need to convert to local coordinate probably
// localToWorld?
var worldPosition=this.worldPosition;
//this.el.object3D.traverse( e => { if (e.name == "b_"+this.side+"_wrist") {
this.el.object3D.traverse( e => { if (e.name == "b_l_wrist") {
worldPosition.copy(e.position);e.parent.updateMatrixWorld();e.parent.localToWorld(worldPosition)
rotation = e.rotation.x*180/3.14 + " " + e.rotation.y*180/3.14 + " " + e.rotation.z*180/3.14
this.data.target.setAttribute("rotation", rotation)
this.data.target.setAttribute("position",
AFRAME.utils.coordinates.stringify( worldPosition ) )
// doesnt work anymore...
//this.data.target.setAttribute("rotation", AFRAME.utils.coordinates.stringify( e.getAttribute("rotation") )
}
})
}
});
AFRAME.registerComponent('pinchprimary', { // currently only 1 hand, the right one
AFRAME.registerComponent('pinchprimary', { // currently only 1 hand, the right one, should be switchable
// consider instead https://github.com/AdaRoseCannon/handy-work/blob/main/README-AFRAME.md for specific poses
// or https://aframe.io/aframe/examples/showcase/hand-tracking/pinchable.js

Loading…
Cancel
Save