xrfragment/dist/aframe-hand-tracking-contro...

2 lines
7.2 KiB
JavaScript
Raw Permalink Normal View History

2024-04-25 17:57:06 +02:00
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.JointObject=void 0;class JointObject{constructor(id,num,parent){this.id=id;this.num=num;this.parent=parent}getId(){return this.id}getPosition(_vector){return this.parent.getPosition(this.num,_vector)}getDirection(_vector){return this.parent.getDirection(this.num,_vector)}getNormal(_vector){return this.parent.getNormal(this.num,_vector)}getQuaternion(_quaternion){return this.parent.getQuaternion(this.num,_quaternion)}getRadius(){return this.parent.getRadius(this.num)}isValid(){return this.parent.getValidity(this.num)}isCloserThan(other,distance){}isTouchingJoint(other){}isNearJoint(other){}isSameDirection(other){}isOppositeDirection(other){}isHorizontal(){}isVertical(){}isUp(){}isDown(){}}exports.JointObject=JointObject},{}],2:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _handdata=require("./handdata");var _default=AFRAME.registerComponent("hand-tracking-extras",{init:function(){this.el.addEventListener("enter-vr",this.play);this.el.addEventListener("exit-vr",this.pause)},tick:function(){return function(){if(this.isPaused)return;var controller=this.el.components["tracked-controls"]&&this.el.components["tracked-controls"].controller;var trackedControlsWebXR=this.el.components["tracked-controls-webxr"];if(!trackedControlsWebXR)return;var referenceSpace=trackedControlsWebXR.system.referenceSpace;var frame=this.el.sceneEl.frame;if(!controller||!frame||!referenceSpace){return}if(!this.HandData){this.HandData=new _handdata.HandData;this.el.emit("hand-tracking-extras-ready",{data:this.HandData})}this.HandData.updateData(controller,frame,referenceSpace)}}(),play:function(){this.isPaused=false},pause:function(){this.isPaused=true},remove:function(){this.el.removeEventListener("enter-vr",this.play);this.el.removeEventListener("exit-vr",this.pause)},getRawJoints(){if(this.HandData)return this.HandData.joints;return null},getJoints(){if(this.HandData)return this.HandData.jointAPI;return null}});exports.default=_default},{"./handdata":3}],3:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.HandData=HandData;var _JointObject=require("./JointObject");function HandData(){const Joint_Count=25;const rotMtx={elements:new Float32Array(16)};const radii=new Float32Array(Joint_Count);const transforms=new Float32Array(4*4*Joint_Count);var validPoses=false;var tmpVector=new THREE.Vector3;var tmpQuaternion=new THREE.Quaternion;var tmpDummy=new THREE.Object3D;let num=0;const joints={Wrist:new _JointObject.JointObject("wrist",num++,this),T_Metacarpal:new _JointObject.JointObject("thumb-metacarpal",num++,this),T_Proximal:new _JointObject.JointObject("thumb-phalanx-proximal",num++,this),T_Distal:new _JointObject.JointObject("thumb-phalanx-distal",num++,this),T_Tip:new _JointObject.JointObject("thumb-tip",num++,this),I_Metacarpal:new _JointObject.JointObject("index-finger-metacarpal",num++,this),I_Proximal:new _JointObject.JointObject("index-finger-phalanx-proximal",num++,this),I_Intermediate:new _JointObject.JointObject("index-finger-phalanx-intermediate",num++,this),I_Distal:new _JointObject.JointObject("index-finger-phalanx-distal",num++,this),I_Tip:new _JointObject.JointObject("index-finger-tip",num++,this),M_Metacarpal:new _JointObject.JointObject("middle-finger-metacarpal",num++,this),M_Proximal:new _JointObject.JointObject("middle-finger-phalanx-proximal",num++,this),M_Intermediate:new _JointObject.JointObject("middle-finger-phalanx-in