Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aframe-desktop-vr-controller

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aframe-desktop-vr-controller - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

2

dist/desktop-vr-controller.min.js

@@ -1,1 +0,1 @@

(()=>{var t={244:()=>{AFRAME.registerComponent("connecting-line",{schema:{start:{type:"selector"},startOffset:{type:"vec3",default:{x:0,y:0,z:0}},end:{type:"selector"},endOffset:{type:"vec3",default:{x:0,y:0,z:0}},color:{type:"color",default:"#74BEC1"},opacity:{type:"number",default:1},visible:{default:!0}},multiple:!0,init(){this.startVector=new THREE.Vector3,this.endVector=new THREE.Vector3},update(){this.el.setAttribute(`line__${this.attrName}`,{color:this.data.color,opacity:this.data.opacity,visible:this.data.visible})},remove(){this.el.removeAttribute(`line__${this.attrName}`)},tick(){const t=this.startVector,e=this.endVector;t.copy(this.data.startOffset),this.data.start.object3D.updateMatrixWorld(),this.data.start.object3D.localToWorld(t),this.el.object3D.worldToLocal(t),e.copy(this.data.endOffset),this.data.end.object3D.updateMatrixWorld(),this.data.end.object3D.localToWorld(e),this.el.object3D.worldToLocal(e),this.el.setAttribute(`line__${this.attrName}`,`start: ${t.x} ${t.y} ${t.z};\n end: ${e.x} ${e.y} ${e.z}`)}})},660:()=>{AFRAME.registerComponent("cursor-tracker",{schema:{cursor:{type:"selector",default:"#cursor"}},init(){this.cursor=this.data.cursor,this.raycaster=this.cursor.components.raycaster.raycaster,this.forward=new THREE.Vector3(0,0,-1),this.localRayVector=new THREE.Vector3},tick(){this.el.object3D.getWorldPosition(this.localRayVector),this.localRayVector.add(this.raycaster.ray.direction),this.el.object3D.parent.worldToLocal(this.localRayVector),this.localRayVector.normalize(),this.el.object3D.quaternion.setFromUnitVectors(this.forward,this.localRayVector)}})},711:()=>{AFRAME.registerComponent("label-anchor",{schema:{offsetVector:{type:"vec3"},showLine:{type:"boolean",default:!0},lineColor:{type:"color",default:"white"}},init(){this.label=this.el.querySelector("[label]"),this.cameraWorldPosition=new THREE.Vector3,this.objectWorldPosition=new THREE.Vector3},update(){this.data.showLine?this.el.setAttribute("line__label-anchor",`start: 0 0 0; end: 0 0 0; color: ${this.data.lineColor}`):this.el.removeAttribute("line__label-anchor")},tick(){const t=this.el.sceneEl.camera;var e=1;if(t.isPerspectiveCamera&&(this.cameraWorldPosition.setFromMatrixPosition(t.matrixWorld),this.el.object3D.getWorldPosition(this.objectWorldPosition),e=this.objectWorldPosition.distanceTo(this.cameraWorldPosition)),this.label.object3D.position.copy(this.data.offsetVector),this.label.object3D.position.multiplyScalar(e),this.data.showLine){const t=this.label.object3D.position,e=`${t.x} ${t.y} ${t.z}`;this.el.setAttribute("line__label-anchor",`end: ${e}`)}}}),AFRAME.registerComponent("label",{schema:{overwrite:{type:"boolean",default:!1},forceDesktopMode:{type:"boolean",default:!1}},init(){this.enterVR=this.enterVR.bind(this),this.exitVR=this.exitVR.bind(this),this.el.sceneEl.addEventListener("enter-vr",this.enterVR),this.el.sceneEl.addEventListener("exit-vr",this.exitVR)},update(){this.el.sceneEl.is("vr-mode")?this.enterVR():this.exitVR()},enterVR:function(){this.el.setAttribute("face-camera",{fixedSize:this.data.forceDesktopMode,spriteMode:this.data.forceDesktopMode,overwrite:this.data.overwrite})},exitVR:function(){this.el.setAttribute("face-camera",{fixedSize:!0,spriteMode:!0,overwrite:this.data.overwrite})}}),AFRAME.registerComponent("face-camera",{schema:{fixedSize:{type:"boolean",default:!1},spriteMode:{type:"boolean",default:!1},overwrite:{type:"boolean",default:!1}},init:function(){this.cameraWorldPosition=new THREE.Vector3,this.objectWorldPosition=new THREE.Vector3,this.cameraQuaternion=new THREE.Quaternion,this.spriteDistanceVector=new THREE.Vector3,this.cameraDirectionVector=new THREE.Vector3,this.parentInverseQuaternion=new THREE.Quaternion,this.object3DSet=this.object3DSet.bind(this),this.data.overwrite&&this.el.addEventListener("object3dset",this.object3DSet)},object3DSet(t){const e=t.target.getObject3D(t.detail.type);e.material.depthTest=!1,e.material.depthWrite=!1},tick:function(){const t=this.el.sceneEl.camera;if(this.data.spriteMode||t.isOrthographicCamera?(setWorldQuaternion=(t,e)=>{t.updateMatrixWorld(),t.parent.getWorldQuaternion(this.parentInverseQuaternion),this.parentInverseQuaternion.invert(),t.quaternion.copy(e),t.quaternion.premultiply(this.parentInverseQuaternion)},this.cameraQuaternion.setFromRotationMatrix(t.matrixWorld),setWorldQuaternion(this.el.object3D,this.cameraQuaternion)):(this.cameraWorldPosition.setFromMatrixPosition(t.matrixWorld),this.el.object3D.lookAt(this.cameraWorldPosition)),this.data.fixedSize)if(t.isPerspectiveCamera)if(this.data.spriteMode){this.cameraDirectionVector.set(0,0,-1),this.cameraDirectionVector.transformDirection(t.matrixWorld),this.cameraWorldPosition.setFromMatrixPosition(t.matrixWorld),this.el.object3D.getWorldPosition(this.objectWorldPosition),this.spriteDistanceVector.subVectors(this.objectWorldPosition,this.cameraWorldPosition),this.spriteDistanceVector.projectOnVector(this.cameraDirectionVector);const e=this.spriteDistanceVector.length();this.el.object3D.scale.set(e,e,e)}else{this.el.object3D.getWorldPosition(this.objectWorldPosition);const t=this.objectWorldPosition.distanceTo(this.cameraWorldPosition);this.el.object3D.scale.set(t,t,t)}else this.el.object3D.scale.set(1,1,1)}})},363:(t,e,i)=>{i(527),i(660),i(711),AFRAME.registerComponent("mouse-manipulation",{schema:{debug:{type:"boolean",default:!1},showHints:{type:"boolean",default:!0}},events:{mousedown:function(t){this.mouseDown(t)},mouseup:function(t){this.mouseUp(t)},mouseenter:function(t){this.mouseEnter(t)},mouseleave:function(t){this.mouseLeave(t)}},init(){console.assert(this.el.id),this.moveSpeed=3,this.grabbedEl=null,this.camera=document.querySelector("[camera]"),this.cursorTracker=document.createElement("a-entity"),this.cursorTracker.setAttribute("cursor-tracker",`cursor:#${this.el.id}`),this.camera.appendChild(this.cursorTracker),this.cursorContactPoint=document.createElement("a-entity"),this.cursorContactPoint.setAttribute("id",`${this.el.id}-cursor-contact-point`),this.data.debug&&(this.cursorContactPoint.setAttribute("geometry","primitive:box; height:0.1; width: 0.1; depth:0.1"),this.cursorContactPoint.setAttribute("material","color: blue")),this.cursorTracker.appendChild(this.cursorContactPoint),this.cameraContactPoint=document.createElement("a-entity"),this.cameraContactPoint.setAttribute("id",`${this.el.id}-camera-contact-point`),this.data.debug&&(this.cameraContactPoint.setAttribute("geometry","primitive:box; height:0.1; width: 0.1; depth:0.1"),this.cameraContactPoint.setAttribute("material","color: red")),this.camera.appendChild(this.cameraContactPoint),this.vector1=new THREE.Vector3,this.vector2=new THREE.Vector3,this.windowMouseUp=this.windowMouseUp.bind(this),this.windowMouseDown=this.windowMouseDown.bind(this),window.addEventListener("mouseup",this.windowMouseUp),window.addEventListener("mousedown",this.windowMouseDown),window.addEventListener("contextmenu",(t=>t.preventDefault())),this.lbDown=!1,this.mbDown=!1,this.rbDown=!1,this.radiansPerMousePixel=.01},update:function(){this.data.showHints?this.createHints():this.removeHints()},remove(){this.removeHints(),this.cursorTracker.parentNode.removeChild(this.cursorTracker),this.cameraContactPoint.parentNode.removeChild(this.cameraContactPoint),window.removeEventListener("mouseup",this.windowMouseUp),window.removeEventListener("mousedown",this.windowMouseDown)},windowMouseDown(t){void 0!==t.buttons&&this.grabbedEl&&(this.data.debug&&console.log("MouseDown:",t),this.recordMouseButtonsState(t),this.updateMouseControls(),this.updateHints(),this.lbDown?this.grabElToContactPoint(this.cursorContactPoint,`#${this.el.id}-cursor-contact-point`):this.grabElToContactPoint(this.cameraContactPoint,`#${this.el.id}-camera-contact-point`))},windowMouseUp(t){void 0!==t.buttons&&this.grabbedEl&&(this.data.debug&&console.log("MouseUp:",t),this.recordMouseButtonsState(t),this.updateMouseControls(),this.updateHints(),this.lbDown?this.data.debug&&console.log("Left button still down"):0===t.buttons?(this.data.debug&&console.log("No buttons down - releasing"),this.releaseEl()):0===t.button&&(this.data.debug&&console.log("Left button released, middle or right still down"),this.grabElToContactPoint(this.cameraContactPoint,`#${this.el.id}-camera-contact-point`)))},recordMouseButtonsState(t){this.lbDown=1&t.buttons,this.mbDown=4&t.buttons,this.rbDown=2&t.buttons,this.data.debug&&(console.log("this.lbDown:",this.lbDown),console.log("this.rbDown:",this.rbDown),console.log("this.mbDown:",this.mbDown))},updateMouseControls(){this.lbDown?this.cursorContactPoint.setAttribute("mouse-dolly",""):this.rbDown?(this.cursorContactPoint.removeAttribute("mouse-dolly"),this.cameraContactPoint.setAttribute("mouse-dolly","")):(this.cursorContactPoint.removeAttribute("mouse-dolly"),this.cameraContactPoint.removeAttribute("mouse-dolly")),this.rbDown?this.cameraContactPoint.setAttribute("mouse-pitch-yaw",""):this.cameraContactPoint.removeAttribute("mouse-pitch-yaw"),this.mbDown?this.cameraContactPoint.setAttribute("mouse-roll",""):this.cameraContactPoint.removeAttribute("mouse-roll")},createHints(){this.data.showHints&&(this.hints=document.createElement("a-entity"),this.hints.setAttribute("label","overwrite: true; forceDesktopMode: true"),this.hints.setAttribute("mouse-manipulation-hints",""),this.el.appendChild(this.hints),this.updateHints())},updateHints(){if(!this.data.showHints)return;const t=t=>{this.hints.setAttribute("mouse-manipulation-hints","view",t)};this.lbDown?t("left"):this.rbDown?t("right"):this.mbDown?t("middle"):this.hoverEl?t("hover"):t("none")},removeHints(){this.hints&&(this.hints.parentNode.removeChild(this.hints),this.hints=null)},mouseDown(t){const e=this.getIntersections(t.target);if(0===e.length)return;const i=e[0];var s=this.getRaycastTarget(i);this.grabbedEl&&this.grabbedEl!==s&&console.warn("Grabbed 2nd element without releasing the first:",s.id,this.grabbedEl.id),this.grabbedEl=s},assureUsableId(t){t.id?document.getElementById(t.id)!==t&&console.error(`Element ID for ${t.id} does not unambiguously identify it. Check for duplicate IDs.`):t.setAttribute("id",Math.random().toString(36).slice(2))},getParentEl(t){const e=t.object3D.parent;return"Scene"===e.type?this.el.sceneEl:e.el},grabElToContactPoint(t,e){this.originalParentEl||(this.originalParentEl=this.getParentEl(this.grabbedEl)),this.assureUsableId(this.originalParentEl);const i=t.object3D.position;this.grabbedEl.object3D.getWorldPosition(i),t.object3D.parent.worldToLocal(i),this.grabbedEl.setAttribute("object-parent","parent",e),this.hints.object3D.position.set(0,0,0),t.object3D.add(this.hints.object3D)},releaseEl(){if(this.grabbedEl.object3D.parent,this.grabbedEl.setAttribute("object-parent","parent",`#${this.originalParentEl.id}`),this.grabbedEl=null,this.originalParentEl=null,this.el.object3D.add(this.hints.object3D),this.hoverEl){const t=this.hints.object3D.position;this.hoverEl.object3D.getWorldPosition(t),this.hints.object3D.parent.worldToLocal(t)}},mouseUp(){},getRaycastTarget:t=>t.components["raycast-target"]?t.components["raycast-target"].target:t,mouseEnter(t){const e=this.getIntersections(t.target);if(0===e.length)return;const i=e[0];if(this.hoverEl=this.getRaycastTarget(i),this.data.debug&&console.log("HoverEl set:",this.hoverEl),this.grabbedEl)return;this.cursorContactPoint;const s=this.hints.object3D.position;this.hoverEl.object3D.getWorldPosition(s),this.hints.object3D.parent.worldToLocal(s),this.updateHints()},mouseLeave(t){this.hoverEl=null,this.data.debug&&console.log("HoverEl cleared"),this.updateHints()},getIntersections:t=>t.components.raycaster.intersectedEls}),AFRAME.registerComponent("mouse-manipulation-hints",{schema:{view:{type:"string",oneOf:["none","hover","left","middle","right"],default:"none"}},init(){this.views={},this.views,this.createHoverView(),this.createLeftView(),this.createRightView(),this.createMiddleView()},createHoverView(){const t=this.views;t.hover=document.createElement("a-entity"),t.hover.setAttribute("id","hint-hover"),this.el.appendChild(t.hover),this.addRowsToView(t.hover,[["left-mouse","move-arrows","left-mouse","pitch-yaw-arrow"],["mouse-wheel","in-out-arrow","middle-mouse","roll"]],[[0,0,0,0],[0,0,0,0]],[[1,1,-1,1],[1,1,1,1]],"above")},createLeftView(){const t=this.views;t.left=document.createElement("a-entity"),t.left.setAttribute("id","hint-left"),this.el.appendChild(t.left),this.addRowsToView(t.left,[["mouse-wheel","in-out-arrow"]],[[0,0]],[[1,1]],"below"),this.addRowsToView(t.left,[["left-arrow"],["left-arrow"],["left-arrow"],["left-arrow"]],[[270],[90],[0],[180]],[[1],[1],[1],[1]],"compass")},createRightView(){const t=this.views;t.right=document.createElement("a-entity"),t.right.setAttribute("id","hint-right"),this.el.appendChild(t.right),this.addRowsToView(t.right,[["mouse-wheel","in-out-arrow"]],[[0,0]],[[1,1]],"below"),this.addRowsToView(t.right,[["yaw-arrow"],["yaw-arrow"],["yaw-arrow"],["yaw-arrow"]],[[90],[90],[0],[0]],[[1],[-1],[-1],[1]],"compass")},createMiddleView(){const t=this.views;t.middle=document.createElement("a-entity"),t.middle.setAttribute("id","hint-middle"),this.el.appendChild(t.middle);const e=[["roll"]],i=[[1]];this.addRowsToView(t.middle,e,[[0]],i,"above"),this.addRowsToView(t.middle,e,[[180]],i,"below")},addRowsToView(t,e,i,s,o){const n=.15;var r,a;function h(e,o,r,a){e.forEach(((e,h)=>{!function(e,i,s,o,n){const r=document.createElement("a-image"),a=`https://cdn.jsdelivr.net/gh/diarmidmackenzie/aframe-components@latest/assets/icons/${e}.svg`;r.setAttribute("src",a),r.object3D.position.set(i,s,0),r.object3D.rotation.set(0,0,THREE.MathUtils.degToRad(o)),r.object3D.scale.set(.1*n,.1,.1),t.appendChild(r)}(e,o+h*n,r,i[a][h],s[a][h])}))}if(r=-(e[0].length-1)*n/2,a=.2+e.length*n/2,"below"===o&&(a-=.5),"above"===o||"below"===o)e.forEach(((t,e)=>{h(t,r,a-e*n,e)}));else if("compass"===o){console.assert(4==e.length);const t=.4;h(e[0],0,t,0),h(e[1],0,-t,1),h(e[2],-t,0,2),h(e[3],t,0,3)}},update(){const t=t=>{t.object3D.visible=!1},e=this.views;t(e.hover),t(e.left),t(e.right),t(e.middle);const i=e[this.data.view];i&&(i.object3D.visible=!0)}}),AFRAME.registerComponent("mouse-pitch-yaw",{schema:{singleAxis:{type:"boolean",default:!1},threshold:{type:"number",default:5}},init:function(){this.axis=null,this.cumX=0,this.cumY=0,this.xQuaternion=new THREE.Quaternion,this.yQuaternion=new THREE.Quaternion,this.yAxis=new THREE.Vector3(0,1,0),this.xAxis=new THREE.Vector3(1,0,0),this.onMouseMove=this.onMouseMove.bind(this),document.addEventListener("mousemove",this.onMouseMove)},remove(){document.removeEventListener("mousemove",this.onMouseMove)},onMouseMove:function(t){this.rotateModel(t)},rotateModel:function(t){this.xAxis.copy(this.el.object3D.position),this.xAxis.normalize(),this.xAxis.cross(this.yAxis);var e=t.movementX,i=t.movementY;this.data.singleAxis&&(this.cumX+=e,this.cumY+=i,!this.axis&&(Math.abs(this.cumX)>this.data.threshold||Math.abs(this.cumY)>this.data.threshold)&&(this.axis=Math.abs(this.cumX)>Math.abs(this.cumY)?"x":"y"),"x"===this.axis?i=0:"y"===this.axis?e=0:(e=0,i=0)),this.xQuaternion.setFromAxisAngle(this.yAxis,e/200),this.yQuaternion.setFromAxisAngle(this.xAxis,i/200),this.el.object3D.quaternion.premultiply(this.xQuaternion),this.el.object3D.quaternion.premultiply(this.yQuaternion),this.el.object3D.quaternion.normalize()}}),AFRAME.registerComponent("mouse-roll",{schema:{slowdownRadius:{type:"number",default:50}},init:function(){this.zQuaternion=new THREE.Quaternion,this.zAxis=new THREE.Vector3(0,0,1),this.onMouseMove=this.onMouseMove.bind(this),document.addEventListener("mousemove",this.onMouseMove),this.currPointer=new THREE.Vector2,this.prevPointer=new THREE.Vector2,this.el.setAttribute("entity-screen-position",""),this.modelPos=new THREE.Vector2,this.el.components["entity-screen-position"].getEntityScreenPosition(this.modelPos)},remove(){this.el.removeAttribute("entity-screen-position"),document.removeEventListener("mousemove",this.onMouseMove)},onMouseMove:function(t){this.rotateModel(t)},rotateModel:function(t){this.zAxis.copy(this.el.object3D.position),this.zAxis.multiplyScalar(-1),this.zAxis.normalize(),this.el.components["entity-screen-position"].getEntityScreenPosition(this.modelPos);const e=t.movementX,i=t.movementY;this.currPointer.set(t.clientX,t.clientY),this.currPointer.sub(this.modelPos),this.prevPointer.set(t.clientX-e,t.clientY-i),this.prevPointer.sub(this.modelPos);let s=this.prevPointer.angle()-this.currPointer.angle();s<-Math.PI&&(s+=2*Math.PI),s>Math.PI&&(s-=2*Math.PI);const o=Math.min(this.currPointer.length(),this.prevPointer.length());o<this.data.slowdownRadius&&(s*=o/this.data.slowdownRadius),this.zQuaternion.setFromAxisAngle(this.zAxis,s),this.el.object3D.quaternion.premultiply(this.zQuaternion)}}),AFRAME.registerComponent("entity-screen-position",{init:function(){this.vector=new THREE.Vector3,this.canvasBounds=document.body.getBoundingClientRect(),this.updateCanvasBounds=AFRAME.utils.debounce((()=>{this.canvasBounds=this.el.sceneEl.canvas.getBoundingClientRect()}),500),window.addEventListener("resize",this.updateCanvasBounds),window.addEventListener("scroll",this.updateCanvasBounds),this.getEntityScreenPosition=this.getEntityScreenPosition.bind(this)},remove(){window.removeEventListener("resize",this.updateCanvasBounds),window.removeEventListener("scroll",this.updateCanvasBounds)},getEntityScreenPosition(t){this.el.object3D.getWorldPosition(this.vector),this.vector.project(this.el.sceneEl.camera);const e=this.canvasBounds;return t.set((this.vector.x+1)*e.width/2,e.height-(this.vector.y+1)*e.height/2),t}}),AFRAME.registerComponent("mouse-dolly",{init:function(){this.moveSpeed=1.3,this.zQuaternion=new THREE.Quaternion,this.zAxis=new THREE.Vector3(0,0,1),this.onMouseWheel=this.onMouseWheel.bind(this),document.addEventListener("mousewheel",this.onMouseWheel)},remove(){document.removeEventListener("mousewheel",this.onMouseWheel)},onMouseWheel:function(t){this.dollyModel(t)},dollyModel:function(t){const e=t.deltaY,i=Math.pow(this.moveSpeed,-e/400);this.el.object3D.position.multiplyScalar(i)}})},527:()=>{AFRAME.registerComponent("object-parent",{schema:{parent:{type:"selector"}},update(){document.querySelectorAll(`#${parent.id}`).length>1&&console.warn(`object-parent matches duplicate entities for new parent ${parent.id}`);const t=this.data.parent.object3D;this.reparent(t)},remove(){const t=this.el.parentEl;this.reparent(t.object3D)},reparent(t){const e=this.el.object3D,i=e.parent;e.parent!==t&&(objectEl=t=>"Scene"===t.type?this.el.sceneEl:t.el,console.log(`Reparenting ${e.el.id} from ${objectEl(i).id} to ${objectEl(t).id}`),t.attach(e))}})},403:()=>{AFRAME.registerComponent("raycaster-thresholds",{dependencies:["raycaster"],schema:{line:{type:"number",default:.01},points:{type:"number",default:.01}},init(){this.oldLine=this.el.components.raycaster.raycaster.params.Line.threshold,this.oldPoints=this.el.components.raycaster.raycaster.params.Points.threshold,this.el.components.raycaster.raycaster.params.Line.threshold=this.data.line,this.el.components.raycaster.raycaster.params.Points.threshold=this.data.points},remove(){this.el.components.raycaster.raycaster.params.Line.threshold=this.oldLine,this.el.components.raycaster.raycaster.params.Points.threshold=this.oldPoints}})},81:()=>{AFRAME.registerComponent("screen-display",{schema:{position:{type:"string",default:"percent"},xpos:{type:"number",default:50},ypos:{type:"number",default:50},scale:{type:"string",default:"percent"},keepaspect:{type:"boolean",default:!0},width:{type:"number",default:10},height:{type:"number"},zscale:{type:"number"},zdist:{type:"number",default:.01}},update:function(){switch(this.screenwidth=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,this.screenheight=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,this.data.position){case"percent":this.xpospercent=this.data.xpos,this.ypospercent=this.data.ypos;break;case"pixels":this.xpospercent=100*this.data.xpos/this.screenwidth,this.ypospercent=100*this.data.ypos/this.screenheight;break;default:console.log(`Unexpected Config: ${this.data.position}`)}switch(this.data.scale){case"percent":this.xscalepercent=this.data.width,this.yscalepercent=this.data.height;break;case"pixels":this.xscalepercent=100*this.data.width/this.screenwidth,this.yscalepercent=100*this.data.height/this.screenheight;break;default:console.warn(`Unexpected Config: ${this.data.position}`)}this.data.keepaspect?(this.yscalepercent=this.xscalepercent*this.screenwidth/this.screenheight,this.data.height&&console.warn('Height being ignored, since "keepaspect" is set.')):this.data.height||console.warn('"keepaspect" is not set, so height is required, but none provided.');var t=Math.tan(59*Math.PI/180)*this.data.zdist,e=t*this.screenwidth/this.screenheight,i=(this.xpospercent/100-.5)*e,s=(.5-this.ypospercent/100)*t;this.el.object3D.position.set(i,s,-this.data.zdist);const o=e*this.xscalepercent/100,n=t*this.yscalepercent/100;var r=this.data.zscale*this.data.zdist/100;this.data.keepaspect?r=o:this.data.zscale||console.warn('"keepaspect" is not set, so zscale is required, but none provided.'),this.el.object3D.scale.set(o,n,r)},tick:function(){const t=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,e=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;this.screenwidth===t&&this.screenheight===e||this.update()}}),AFRAME.registerComponent("screendisplay",{schema:{position:{type:"string",default:"percent"},xpos:{type:"number",default:50},ypos:{type:"number",default:50},scale:{type:"string",default:"percent"},keepaspect:{type:"boolean",default:!0},width:{type:"number",default:10},height:{type:"number"},zscale:{type:"number"},zdist:{type:"number",default:.01}},update:function(){this.el.setAttribute("screen-display",{position:this.data.position,xpos:this.data.xpos,ypos:this.data.ypos,scale:this.data.scale,keepaspect:this.data.keepaspect,width:this.data.width,height:this.data.height,zscale:this.data.zscale,zdist:this.data.zdist})}})}},e={};function i(s){var o=e[s];if(void 0!==o)return o.exports;var n=e[s]={exports:{}};return t[s](n,n.exports,i),n.exports}AFRAME.components["mouse-manipulation"]||i(363),AFRAME.components["screen-display"]||i(81),AFRAME.components.label||i(711),AFRAME.components["raycaster-thresholds"]||i(403),AFRAME.components["connecting-line"]||i(244),AFRAME.registerSystem("desktop-vr-controller",{init(){this.controllers=0},registerController(){0===this.controllers&&(this.disableExistingCursors(),this.createCursor()),this.controllers++},unregisterController(){this.controllers--,this.controllers<=0&&(this.controllers=0,this.myCursor.parentNode.removeChild(this.myCursor),this.myCursor=null,this.reinstateCursors())},createCursor(){this.myCursor=document.createElement("a-entity"),this.myCursor.setAttribute("id","desktop-vr-controller-cursor"),this.myCursor.setAttribute("cursor","rayOrigin: mouse"),this.myCursor.setAttribute("raycaster","objects: [desktop-vr-controller]"),this.myCursor.setAttribute("raycaster-thresholds","line: 0"),this.myCursor.setAttribute("mouse-manipulation",""),this.el.sceneEl.appendChild(this.myCursor)},disableExistingCursors(){const t=document.querySelectorAll("[cursor]");for(this.oldCursorStates=[],ii=0;ii<t.length;ii++){const e=t[ii];this.oldCursorStates.push(e.getAttribute("raycaster","enabled")),"mouse"===e.components.cursor.data.rayOrigin&&e.setAttribute("raycaster","enabled",!1)}},reinstateCursors(){if(!this.oldCursorStates)return;const t=document.querySelectorAll("[cursor]");for(ii=0;ii<t.length;ii++)if(this.oldCursorStates[ii]){const e=t[ii];"mouse"===e.components.cursor.data.rayOrigin&&e.setAttribute("raycaster","enabled",this.oldCursorStates[ii])}}}),AFRAME.registerComponent("desktop-vr-controller",{dependencies:["oculus-touch-controls"],init(){this.simulateController=this.simulateController.bind(this),this.removeController=this.removeController.bind(this),this.keyUp=this.keyUp.bind(this),this.keyDown=this.keyDown.bind(this),this.el.sceneEl.addEventListener("enter-vr",this.simulateController),this.el.sceneEl.addEventListener("exit-vr",this.removeController),this.labels={},this.keysDown={},this.keysLocked={},this.createLockHint()},simulateController(){if(this.el.sceneEl.renderer.xr.getSession())return void console.log("desktop-vr-controller suppressed due to presence of an XR session");this.system.registerController();const t=this.el.sceneEl;if(this.trackedControlsSystem=t&&t.systems["tracked-controls-webxr"],!this.trackedControlsSystem)return console.warn("No tracked-controls-webxr system found for desktop-vr-controller"),!1;oculusData=this.el.components["oculus-touch-controls"].data,oculusData?(this.controllerData={hand:oculusData.hand,handedness:oculusData.hand,profiles:["oculus-touch-controls","oculus-touch-v3"]},this.trackedControlsSystem.controllers.push(this.controllerData),t.emit("controllersupdated"),"left"==this.controllerData.hand?(this.keyBindings={ShiftLeft:"trigger",ControlLeft:"grip",KeyX:"xbutton",KeyY:"ybutton",Digit1:"thumbstick"},this.labels.trigger=this.createLabel("L-Shift","trigger"),this.lockLabel(this.labels.trigger),this.unlockLabel(this.labels.trigger),this.labels.grip=this.createLabel("L-Ctrl","grip"),this.labels.xbutton=this.createLabel("X","xbutton"),this.labels.ybutton=this.createLabel("Y","ybutton"),this.labels.thumbstick=this.createLabel("1","thumbstick")):(this.keyBindings={ShiftRight:"trigger",ControlRight:"grip",KeyV:"abutton",KeyB:"bbutton",Digit2:"thumbstick"},this.labels.trigger=this.createLabel("R-Shift","trigger"),this.labels.grip=this.createLabel("R-Ctrl","grip"),this.labels.abutton=this.createLabel("V","abutton"),this.labels.bbutton=this.createLabel("B","bbutton"),this.labels.thumbstick=this.createLabel("2","thumbstick")),window.addEventListener("keyup",this.keyUp),window.addEventListener("keydown",this.keyDown)):console.warn("No oculus-touch-controls component found for desktop-vr-controller")},createLabel(t,e){var i,s;if("left"==this.controllerData.hand)switch(e){case"trigger":i="0.015 -0.02 0.01",s="0.1 0 -0.2";break;case"grip":i="0.015 -0.02 0.06",s="0.25 0 0";break;case"xbutton":i="0.017 0.005 0.045",s="0.0 0.1 0.1";break;case"ybutton":i="0.022 0.005 0.03",s="0.0 0.2 -0.1";break;case"thumbstick":i="0.001 0.015 0.03",s="-0.1 0.2 -0.1";break;default:console.error(`unexpected position identifier: ${e}`)}else switch(e){case"trigger":i="-0.015 -0.02 0.01",s="-0.1 0 -0.2";break;case"grip":i="-0.015 -0.02 0.06",s="-0.25 0 0";break;case"abutton":i="-0.017 0.005 0.045",s="0.0 0.1 0.1";break;case"bbutton":i="-0.022 0.005 0.03",s="0.0 0.2 -0.1";break;case"thumbstick":i="-0.001 0.015 0.03",s="0.1 0.2 -0.1";break;default:console.error(`unexpected position identifier: ${e}`)}const o=document.createElement("a-entity");o.setAttribute("position",i),o.setAttribute("label-anchor",`offsetVector: ${s}; lineColor: green`);const n=document.createElement("a-entity");n.setAttribute("label",{overwrite:!0,forceDesktopMode:!0}),o.appendChild(n),this.el.appendChild(o);const r=document.createElement("a-plane");return r.setAttribute("width",t.length>2?.2:.1),r.setAttribute("height",.1),r.setAttribute("color","black"),r.setAttribute("text",`value:${t};\n color: white;\n wrapCount: ${t.length+2};\n align: center;\n anchor: center`),"thumbstick"===e&&r.setAttribute("desktop-vr-thumbstick",""),n.appendChild(r),o},createLockHint(){const t=document.createElement("a-plane");t.setAttribute("color","black"),t.setAttribute("height",.12),t.setAttribute("screen-display","xpos: 50; ypos: 85; width: 25"),t.setAttribute("text","value: Press Enter to Lock Button Down; align: center; wrapCount: 30"),document.querySelector("[camera]").appendChild(t),this.lockHint=t,this.lockHintCounter=0,this.hideLockHint()},showLockHint(){this.lockHint.object3D.visible=!0,this.lockHintCounter++},hideLockHint(){this.lockHintCounter--,this.lockHintCounter<=0&&(this.lockHint.object3D.visible=!1,this.lockHintCounter=0)},lockLabel(t){if(t.querySelector("a-image"))return;const e=t.querySelector("a-plane"),i=document.createElement("a-image");i.setAttribute("src","https://cdn.jsdelivr.net/gh/diarmidmackenzie/aframe-components@latest/assets/icons/lock.svg");const s=.4*e.attributes.width.value;i.object3D.position.set(s,0,0),i.object3D.scale.set(.03,.03,.03),e.appendChild(i)},unlockLabel(t){const e=t.querySelector("a-image");e&&e.parentNode.removeChild(e)},removeLabels(){Object.entries(this.labels).forEach((([t,e])=>{e.parentNode.removeChild(e)})),this.labels={}},removeController(){console.log("Removing controller:",this.controllerData),console.log("Current Controllers:",this.trackedControlsSystem.controllers);const t=this.trackedControlsSystem.controllers.findIndex((t=>t===this.controllerData));console.log("Find index: ",t),t>=0&&this.trackedControlsSystem.controllers.splice(t),this.el.sceneEl.emit("controllersupdated"),window.removeEventListener("keyup",this.keyUp),window.removeEventListener("keydown",this.keyDown),this.removeLabels(),this.system.unregisterController()},keyUp(t){const e=this.keyBindings[t.code];e&&(this.keysLocked[t.code]||("thumbstick"!==e?(this.el.emit(`${e}up`),this.el.emit(`${e}changed`)):this.labels[e].querySelector("[desktop-vr-thumbstick]").setAttribute("desktop-vr-thumbstick","active: false"),this.labels[e].setAttribute("label-anchor","lineColor: green"),this.labels[e].querySelector("a-plane").setAttribute("color","black")),this.keysDown[t.code]=!1,this.hideLockHint())},keyDown(t){if(t.repeat)return;this.keysLocked[t.code]=!1;const e=this.keyBindings[t.code];e&&(this.showLockHint(),"thumbstick"!==e?(this.el.emit(`${e}down`),this.el.emit(`${e}changed`)):this.labels[e].querySelector("[desktop-vr-thumbstick]").setAttribute("desktop-vr-thumbstick",`active: true;\n controller: #${this.el.id}`),this.labels[e].setAttribute("label-anchor","lineColor: yellow"),this.labels[e].querySelector("a-plane").setAttribute("color","grey"),this.unlockLabel(this.labels[e]),this.keysDown[t.code]=!0),"Enter"===t.code&&Object.entries(this.keysDown).forEach((([t,e])=>{if(e){this.keysLocked[t]=!0;const e=this.keyBindings[t];e&&(this.lockLabel(this.labels[e]),this.hideLockHint())}}))}}),AFRAME.registerComponent("desktop-vr-thumbstick",{schema:{active:{type:"boolean",default:!1},controller:{type:"selector"}},init(){this.dimension=100,this.radius=.5;const t=this.el.sceneEl.camera;this.mouseMove=this.mouseMove.bind(this),this.mouseDown=this.mouseDown.bind(this),this.mouseUp=this.mouseUp.bind(this),this.startMouseX=void 0,this.startMouseY=void 0,this.thumbstickVector=new THREE.Vector2(0,0),this.thumbstickDown=!1,this.base=document.createElement("a-circle"),this.base.setAttribute("radius",this.radius),this.base.setAttribute("id",Math.random().toString(36).slice(2)),this.base.setAttribute("material","color:black; shader: flat"),this.base.object3D.visible=!1,t.el.appendChild(this.base),this.stick=document.createElement("a-circle"),this.stick.setAttribute("material","color:#bbb; shader: flat"),this.stick.setAttribute("radius",.6*this.radius),this.stick.object3D.position.set(0,0,1e-5),this.base.appendChild(this.stick),this.line=document.createElement("a-entity"),this.line.object3D.visible=!1,this.el.sceneEl.appendChild(this.line),window.addEventListener("mousemove",this.mouseMove),window.addEventListener("mouseup",this.mouseUp),window.addEventListener("mousedown",this.mouseDown)},update(){this.data.active?(this.base.setAttribute("screen-display",{position:"pixels",scale:"pixels",width:this.dimension,xpos:this.startMouseX,ypos:this.startMouseY}),this.base.object3D.visible=!0,this.line.setAttribute("connecting-line",`start: #${this.data.controller.id};\n startOffset: 0 0.015 0.03;\n end: #${this.base.id};\n endOffset: 0 0 0;\n color: yellow`),this.line.object3D.visible=!0):(this.base.object3D.visible=!1,this.line.removeAttribute("connecting-line"),this.line.object3D.visible=!1,this.thumbstickVector.lengthSq()>0&&(this.thumbstickVector.set(0,0),this.generateEvents()),this.thumbstickDown&&(this.data.controller.emit("thumbstickup"),this.data.controller.emit("thumbstickchanged"),this.thumbstickDown=!1))},remove(){window.removeEventListener("mousemove",this.mouseMove)},mouseMove(t){this.data.active?(this.startMouseX&&this.startMouseY||(this.startMouseX=t.clientX,this.startMouseY=t.clientY),xDiff=(t.clientX-this.startMouseX)/(.375*this.dimension),yDiff=(t.clientY-this.startMouseY)/(.375*this.dimension),this.thumbstickVector.set(xDiff,yDiff),this.thumbstickVector.clampLength(0,1),this.updateDisplay(),this.generateEvents()):(this.startMouseX=t.clientX,this.startMouseY=t.clientY)},updateDisplay(){this.stick.object3D.position.x=this.thumbstickVector.x*this.radius*.75,this.stick.object3D.position.y=-this.thumbstickVector.y*this.radius*.75},generateEvents(){this.data.controller.emit("thumbstickmoved",this.thumbstickVector)},mouseDown(){this.data.active&&(this.stick.setAttribute("material","color:#888; shader: flat"),this.data.controller.emit("thumbstickdown"),this.data.controller.emit("thumbstickchanged"),this.thumbstickDown=!0)},mouseUp(){this.data.active&&(this.stick.setAttribute("material","color:#bbb; shader: flat"),this.data.controller.emit("thumbstickup"),this.data.controller.emit("thumbstickchanged"),this.thumbstickDown=!1)}})})();
(()=>{var t={244:()=>{AFRAME.registerComponent("connecting-line",{schema:{start:{type:"selector"},startOffset:{type:"vec3",default:{x:0,y:0,z:0}},end:{type:"selector"},endOffset:{type:"vec3",default:{x:0,y:0,z:0}},color:{type:"color",default:"#74BEC1"},opacity:{type:"number",default:1},visible:{default:!0}},multiple:!0,init(){this.startVector=new THREE.Vector3,this.endVector=new THREE.Vector3},update(){this.el.setAttribute(`line__${this.attrName}`,{color:this.data.color,opacity:this.data.opacity,visible:this.data.visible})},remove(){this.el.removeAttribute(`line__${this.attrName}`)},tick(){const t=this.startVector,e=this.endVector;t.copy(this.data.startOffset),this.data.start.object3D.updateMatrixWorld(),this.data.start.object3D.localToWorld(t),this.el.object3D.worldToLocal(t),e.copy(this.data.endOffset),this.data.end.object3D.updateMatrixWorld(),this.data.end.object3D.localToWorld(e),this.el.object3D.worldToLocal(e),this.el.setAttribute(`line__${this.attrName}`,`start: ${t.x} ${t.y} ${t.z};\n end: ${e.x} ${e.y} ${e.z}`)}})},660:()=>{AFRAME.registerComponent("cursor-tracker",{schema:{cursor:{type:"selector",default:"#cursor"}},init(){this.cursor=this.data.cursor,this.raycaster=this.cursor.components.raycaster.raycaster,this.forward=new THREE.Vector3(0,0,-1),this.localRayVector=new THREE.Vector3},tick(){this.el.object3D.getWorldPosition(this.localRayVector),this.localRayVector.add(this.raycaster.ray.direction),this.el.object3D.parent.worldToLocal(this.localRayVector),this.localRayVector.normalize(),this.el.object3D.quaternion.setFromUnitVectors(this.forward,this.localRayVector)}})},711:()=>{AFRAME.registerComponent("label-anchor",{schema:{offsetVector:{type:"vec3"},showLine:{type:"boolean",default:!0},lineColor:{type:"color",default:"white"}},init(){this.label=this.el.querySelector("[label]"),this.cameraWorldPosition=new THREE.Vector3,this.objectWorldPosition=new THREE.Vector3},update(){this.data.showLine?this.el.setAttribute("line__label-anchor",`start: 0 0 0; end: 0 0 0; color: ${this.data.lineColor}`):this.el.removeAttribute("line__label-anchor")},tick(){const t=this.el.sceneEl.camera;var e=1;if(t.isPerspectiveCamera&&(this.cameraWorldPosition.setFromMatrixPosition(t.matrixWorld),this.el.object3D.getWorldPosition(this.objectWorldPosition),e=this.objectWorldPosition.distanceTo(this.cameraWorldPosition)),this.label.object3D.position.copy(this.data.offsetVector),this.label.object3D.position.multiplyScalar(e),this.data.showLine){const t=this.label.object3D.position,e=`${t.x} ${t.y} ${t.z}`;this.el.setAttribute("line__label-anchor",`end: ${e}`)}}}),AFRAME.registerComponent("label",{schema:{overwrite:{type:"boolean",default:!1},forceDesktopMode:{type:"boolean",default:!1}},init(){this.enterVR=this.enterVR.bind(this),this.exitVR=this.exitVR.bind(this),this.el.sceneEl.addEventListener("enter-vr",this.enterVR),this.el.sceneEl.addEventListener("exit-vr",this.exitVR)},update(){this.el.sceneEl.is("vr-mode")?this.enterVR():this.exitVR()},enterVR:function(){this.el.setAttribute("face-camera",{fixedSize:this.data.forceDesktopMode,spriteMode:this.data.forceDesktopMode,overwrite:this.data.overwrite})},exitVR:function(){this.el.setAttribute("face-camera",{fixedSize:!0,spriteMode:!0,overwrite:this.data.overwrite})}}),AFRAME.registerComponent("face-camera",{schema:{fixedSize:{type:"boolean",default:!1},spriteMode:{type:"boolean",default:!1},overwrite:{type:"boolean",default:!1}},init:function(){if(this.cameraWorldPosition=new THREE.Vector3,this.objectWorldPosition=new THREE.Vector3,this.cameraQuaternion=new THREE.Quaternion,this.spriteDistanceVector=new THREE.Vector3,this.cameraDirectionVector=new THREE.Vector3,this.parentInverseQuaternion=new THREE.Quaternion,this.object3DSet=this.object3DSet.bind(this),this.data.overwrite){const t=this.el.getObject3D("mesh");t&&this.bringMeshToFront(t),this.el.addEventListener("object3dset",this.object3DSet)}},bringMeshToFront(t){const e=t.material;e.depthTest=!1,e.depthWrite=!1,e.transparent=!0},object3DSet(t){const e=t.target.getObject3D(t.detail.type);this.bringMeshToFront(e)},tick:function(){const t=this.el.sceneEl.camera;if(this.data.spriteMode||t.isOrthographicCamera?(setWorldQuaternion=(t,e)=>{t.updateMatrixWorld(),t.parent.getWorldQuaternion(this.parentInverseQuaternion),this.parentInverseQuaternion.invert(),t.quaternion.copy(e),t.quaternion.premultiply(this.parentInverseQuaternion)},this.cameraQuaternion.setFromRotationMatrix(t.matrixWorld),setWorldQuaternion(this.el.object3D,this.cameraQuaternion)):(this.cameraWorldPosition.setFromMatrixPosition(t.matrixWorld),this.el.object3D.lookAt(this.cameraWorldPosition)),this.data.fixedSize)if(t.isPerspectiveCamera)if(this.data.spriteMode){this.cameraDirectionVector.set(0,0,-1),this.cameraDirectionVector.transformDirection(t.matrixWorld),this.cameraWorldPosition.setFromMatrixPosition(t.matrixWorld),this.el.object3D.getWorldPosition(this.objectWorldPosition),this.spriteDistanceVector.subVectors(this.objectWorldPosition,this.cameraWorldPosition),this.spriteDistanceVector.projectOnVector(this.cameraDirectionVector);const e=this.spriteDistanceVector.length();this.el.object3D.scale.set(e,e,e)}else{this.el.object3D.getWorldPosition(this.objectWorldPosition);const t=this.objectWorldPosition.distanceTo(this.cameraWorldPosition);this.el.object3D.scale.set(t,t,t)}else this.el.object3D.scale.set(1,1,1)}})},363:(t,e,i)=>{i(527),i(660),i(711),AFRAME.registerComponent("mouse-manipulation",{schema:{debug:{type:"boolean",default:!1},showHints:{type:"boolean",default:!0}},events:{mousedown:function(t){this.mouseDown(t)},mouseup:function(t){this.mouseUp(t)},mouseenter:function(t){this.mouseEnter(t)},mouseleave:function(t){this.mouseLeave(t)}},init(){console.assert(this.el.id),this.moveSpeed=3,this.grabbedEl=null,this.camera=document.querySelector("[camera]"),this.cursorTracker=document.createElement("a-entity"),this.cursorTracker.setAttribute("cursor-tracker",`cursor:#${this.el.id}`),this.camera.appendChild(this.cursorTracker),this.cursorContactPoint=document.createElement("a-entity"),this.cursorContactPoint.setAttribute("id",`${this.el.id}-cursor-contact-point`),this.data.debug&&(this.cursorContactPoint.setAttribute("geometry","primitive:box; height:0.1; width: 0.1; depth:0.1"),this.cursorContactPoint.setAttribute("material","color: blue")),this.cursorTracker.appendChild(this.cursorContactPoint),this.cameraContactPoint=document.createElement("a-entity"),this.cameraContactPoint.setAttribute("id",`${this.el.id}-camera-contact-point`),this.data.debug&&(this.cameraContactPoint.setAttribute("geometry","primitive:box; height:0.1; width: 0.1; depth:0.1"),this.cameraContactPoint.setAttribute("material","color: red")),this.camera.appendChild(this.cameraContactPoint),this.vector1=new THREE.Vector3,this.vector2=new THREE.Vector3,this.windowMouseUp=this.windowMouseUp.bind(this),this.windowMouseDown=this.windowMouseDown.bind(this),window.addEventListener("mouseup",this.windowMouseUp),window.addEventListener("mousedown",this.windowMouseDown),window.addEventListener("contextmenu",(t=>t.preventDefault())),this.lbDown=!1,this.mbDown=!1,this.rbDown=!1,this.radiansPerMousePixel=.01},update:function(){this.data.showHints?this.createHints():this.removeHints()},remove(){this.removeHints(),this.cursorTracker.parentNode.removeChild(this.cursorTracker),this.cameraContactPoint.parentNode.removeChild(this.cameraContactPoint),window.removeEventListener("mouseup",this.windowMouseUp),window.removeEventListener("mousedown",this.windowMouseDown)},windowMouseDown(t){void 0!==t.buttons&&this.grabbedEl&&(this.data.debug&&console.log("MouseDown:",t),this.recordMouseButtonsState(t),this.updateMouseControls(),this.updateHints(),this.lbDown?this.grabElToContactPoint(this.cursorContactPoint,`#${this.el.id}-cursor-contact-point`):this.grabElToContactPoint(this.cameraContactPoint,`#${this.el.id}-camera-contact-point`))},windowMouseUp(t){void 0!==t.buttons&&this.grabbedEl&&(this.data.debug&&console.log("MouseUp:",t),this.recordMouseButtonsState(t),this.updateMouseControls(),this.updateHints(),this.lbDown?this.data.debug&&console.log("Left button still down"):0===t.buttons?(this.data.debug&&console.log("No buttons down - releasing"),this.releaseEl()):0===t.button&&(this.data.debug&&console.log("Left button released, middle or right still down"),this.grabElToContactPoint(this.cameraContactPoint,`#${this.el.id}-camera-contact-point`)))},recordMouseButtonsState(t){this.lbDown=1&t.buttons,this.mbDown=4&t.buttons,this.rbDown=2&t.buttons,this.data.debug&&(console.log("this.lbDown:",this.lbDown),console.log("this.rbDown:",this.rbDown),console.log("this.mbDown:",this.mbDown))},updateMouseControls(){this.lbDown?this.cursorContactPoint.setAttribute("mouse-dolly",""):this.rbDown?(this.cursorContactPoint.removeAttribute("mouse-dolly"),this.cameraContactPoint.setAttribute("mouse-dolly","")):(this.cursorContactPoint.removeAttribute("mouse-dolly"),this.cameraContactPoint.removeAttribute("mouse-dolly")),this.rbDown?this.cameraContactPoint.setAttribute("mouse-pitch-yaw",""):this.cameraContactPoint.removeAttribute("mouse-pitch-yaw"),this.mbDown?this.cameraContactPoint.setAttribute("mouse-roll",""):this.cameraContactPoint.removeAttribute("mouse-roll")},createHints(){this.data.showHints&&(this.hints=document.createElement("a-entity"),this.hints.setAttribute("label","overwrite: true; forceDesktopMode: true"),this.hints.setAttribute("mouse-manipulation-hints",""),this.el.appendChild(this.hints),this.updateHints())},updateHints(){if(!this.data.showHints)return;const t=t=>{this.hints.setAttribute("mouse-manipulation-hints","view",t)};this.lbDown?t("left"):this.rbDown?t("right"):this.mbDown?t("middle"):this.hoverEl?t("hover"):t("none")},removeHints(){this.hints&&(this.hints.parentNode.removeChild(this.hints),this.hints=null)},mouseDown(t){const e=this.getIntersections(t.target);if(0===e.length)return;const i=e[0];var s=this.getRaycastTarget(i);this.grabbedEl&&this.grabbedEl!==s&&console.warn("Grabbed 2nd element without releasing the first:",s.id,this.grabbedEl.id),this.grabbedEl=s},assureUsableId(t){t.id?document.getElementById(t.id)!==t&&console.error(`Element ID for ${t.id} does not unambiguously identify it. Check for duplicate IDs.`):t.setAttribute("id",Math.random().toString(36).slice(2))},getParentEl(t){const e=t.object3D.parent;return"Scene"===e.type?this.el.sceneEl:e.el},grabElToContactPoint(t,e){this.originalParentEl||(this.originalParentEl=this.getParentEl(this.grabbedEl)),this.assureUsableId(this.originalParentEl);const i=t.object3D.position;this.grabbedEl.object3D.getWorldPosition(i),t.object3D.parent.worldToLocal(i),this.grabbedEl.setAttribute("object-parent","parent",e),this.hints.object3D.position.set(0,0,0),t.object3D.add(this.hints.object3D)},releaseEl(){if(this.grabbedEl.object3D.parent,this.grabbedEl.setAttribute("object-parent","parent",`#${this.originalParentEl.id}`),this.grabbedEl=null,this.originalParentEl=null,this.el.object3D.add(this.hints.object3D),this.hoverEl){const t=this.hints.object3D.position;this.hoverEl.object3D.getWorldPosition(t),this.hints.object3D.parent.worldToLocal(t)}},mouseUp(){},getRaycastTarget:t=>t.components["raycast-target"]?t.components["raycast-target"].target:t,mouseEnter(t){const e=this.getIntersections(t.target);if(0===e.length)return;const i=e[0];if(this.hoverEl=this.getRaycastTarget(i),this.data.debug&&console.log("HoverEl set:",this.hoverEl),this.grabbedEl)return;this.cursorContactPoint;const s=this.hints.object3D.position;this.hoverEl.object3D.getWorldPosition(s),this.hints.object3D.parent.worldToLocal(s),this.updateHints()},mouseLeave(t){this.hoverEl=null,this.data.debug&&console.log("HoverEl cleared"),this.updateHints()},getIntersections:t=>t.components.raycaster.intersectedEls}),AFRAME.registerComponent("mouse-manipulation-hints",{schema:{view:{type:"string",oneOf:["none","hover","left","middle","right"],default:"none"}},init(){this.views={},this.views,this.createHoverView(),this.createLeftView(),this.createRightView(),this.createMiddleView()},createHoverView(){const t=this.views;t.hover=document.createElement("a-entity"),t.hover.setAttribute("id","hint-hover"),this.el.appendChild(t.hover),this.addRowsToView(t.hover,[["left-mouse","move-arrows","left-mouse","pitch-yaw-arrow"],["mouse-wheel","in-out-arrow","middle-mouse","roll"]],[[0,0,0,0],[0,0,0,0]],[[1,1,-1,1],[1,1,1,1]],"above")},createLeftView(){const t=this.views;t.left=document.createElement("a-entity"),t.left.setAttribute("id","hint-left"),this.el.appendChild(t.left),this.addRowsToView(t.left,[["mouse-wheel","in-out-arrow"]],[[0,0]],[[1,1]],"below"),this.addRowsToView(t.left,[["left-arrow"],["left-arrow"],["left-arrow"],["left-arrow"]],[[270],[90],[0],[180]],[[1],[1],[1],[1]],"compass")},createRightView(){const t=this.views;t.right=document.createElement("a-entity"),t.right.setAttribute("id","hint-right"),this.el.appendChild(t.right),this.addRowsToView(t.right,[["mouse-wheel","in-out-arrow"]],[[0,0]],[[1,1]],"below"),this.addRowsToView(t.right,[["yaw-arrow"],["yaw-arrow"],["yaw-arrow"],["yaw-arrow"]],[[90],[90],[0],[0]],[[1],[-1],[-1],[1]],"compass")},createMiddleView(){const t=this.views;t.middle=document.createElement("a-entity"),t.middle.setAttribute("id","hint-middle"),this.el.appendChild(t.middle);const e=[["roll"]],i=[[1]];this.addRowsToView(t.middle,e,[[0]],i,"above"),this.addRowsToView(t.middle,e,[[180]],i,"below")},addRowsToView(t,e,i,s,o){const n=.15;var r,a;function h(e,o,r,a){e.forEach(((e,h)=>{!function(e,i,s,o,n){const r=document.createElement("a-image"),a=`https://cdn.jsdelivr.net/gh/diarmidmackenzie/aframe-components@latest/assets/icons/${e}.svg`;r.setAttribute("src",a),r.object3D.position.set(i,s,0),r.object3D.rotation.set(0,0,THREE.MathUtils.degToRad(o)),r.object3D.scale.set(.1*n,.1,.1),t.appendChild(r)}(e,o+h*n,r,i[a][h],s[a][h])}))}if(r=-(e[0].length-1)*n/2,a=.2+e.length*n/2,"below"===o&&(a-=.5),"above"===o||"below"===o)e.forEach(((t,e)=>{h(t,r,a-e*n,e)}));else if("compass"===o){console.assert(4==e.length);const t=.4;h(e[0],0,t,0),h(e[1],0,-t,1),h(e[2],-t,0,2),h(e[3],t,0,3)}},update(){const t=t=>{t.object3D.visible=!1},e=this.views;t(e.hover),t(e.left),t(e.right),t(e.middle);const i=e[this.data.view];i&&(i.object3D.visible=!0)}}),AFRAME.registerComponent("mouse-pitch-yaw",{schema:{singleAxis:{type:"boolean",default:!1},threshold:{type:"number",default:5}},init:function(){this.axis=null,this.cumX=0,this.cumY=0,this.xQuaternion=new THREE.Quaternion,this.yQuaternion=new THREE.Quaternion,this.yAxis=new THREE.Vector3(0,1,0),this.xAxis=new THREE.Vector3(1,0,0),this.onMouseMove=this.onMouseMove.bind(this),document.addEventListener("mousemove",this.onMouseMove)},remove(){document.removeEventListener("mousemove",this.onMouseMove)},onMouseMove:function(t){this.rotateModel(t)},rotateModel:function(t){this.xAxis.copy(this.el.object3D.position),this.xAxis.normalize(),this.xAxis.cross(this.yAxis);var e=t.movementX,i=t.movementY;this.data.singleAxis&&(this.cumX+=e,this.cumY+=i,!this.axis&&(Math.abs(this.cumX)>this.data.threshold||Math.abs(this.cumY)>this.data.threshold)&&(this.axis=Math.abs(this.cumX)>Math.abs(this.cumY)?"x":"y"),"x"===this.axis?i=0:"y"===this.axis?e=0:(e=0,i=0)),this.xQuaternion.setFromAxisAngle(this.yAxis,e/200),this.yQuaternion.setFromAxisAngle(this.xAxis,i/200),this.el.object3D.quaternion.premultiply(this.xQuaternion),this.el.object3D.quaternion.premultiply(this.yQuaternion),this.el.object3D.quaternion.normalize()}}),AFRAME.registerComponent("mouse-roll",{schema:{slowdownRadius:{type:"number",default:50}},init:function(){this.zQuaternion=new THREE.Quaternion,this.zAxis=new THREE.Vector3(0,0,1),this.onMouseMove=this.onMouseMove.bind(this),document.addEventListener("mousemove",this.onMouseMove),this.currPointer=new THREE.Vector2,this.prevPointer=new THREE.Vector2,this.el.setAttribute("entity-screen-position",""),this.modelPos=new THREE.Vector2,this.el.components["entity-screen-position"].getEntityScreenPosition(this.modelPos)},remove(){this.el.removeAttribute("entity-screen-position"),document.removeEventListener("mousemove",this.onMouseMove)},onMouseMove:function(t){this.rotateModel(t)},rotateModel:function(t){this.zAxis.copy(this.el.object3D.position),this.zAxis.multiplyScalar(-1),this.zAxis.normalize(),this.el.components["entity-screen-position"].getEntityScreenPosition(this.modelPos);const e=t.movementX,i=t.movementY;this.currPointer.set(t.clientX,t.clientY),this.currPointer.sub(this.modelPos),this.prevPointer.set(t.clientX-e,t.clientY-i),this.prevPointer.sub(this.modelPos);let s=this.prevPointer.angle()-this.currPointer.angle();s<-Math.PI&&(s+=2*Math.PI),s>Math.PI&&(s-=2*Math.PI);const o=Math.min(this.currPointer.length(),this.prevPointer.length());o<this.data.slowdownRadius&&(s*=o/this.data.slowdownRadius),this.zQuaternion.setFromAxisAngle(this.zAxis,s),this.el.object3D.quaternion.premultiply(this.zQuaternion)}}),AFRAME.registerComponent("entity-screen-position",{init:function(){this.vector=new THREE.Vector3,this.canvasBounds=document.body.getBoundingClientRect(),this.updateCanvasBounds=AFRAME.utils.debounce((()=>{this.canvasBounds=this.el.sceneEl.canvas.getBoundingClientRect()}),500),window.addEventListener("resize",this.updateCanvasBounds),window.addEventListener("scroll",this.updateCanvasBounds),this.getEntityScreenPosition=this.getEntityScreenPosition.bind(this)},remove(){window.removeEventListener("resize",this.updateCanvasBounds),window.removeEventListener("scroll",this.updateCanvasBounds)},getEntityScreenPosition(t){this.el.object3D.getWorldPosition(this.vector),this.vector.project(this.el.sceneEl.camera);const e=this.canvasBounds;return t.set((this.vector.x+1)*e.width/2,e.height-(this.vector.y+1)*e.height/2),t}}),AFRAME.registerComponent("mouse-dolly",{init:function(){this.moveSpeed=1.3,this.zQuaternion=new THREE.Quaternion,this.zAxis=new THREE.Vector3(0,0,1),this.onMouseWheel=this.onMouseWheel.bind(this),document.addEventListener("mousewheel",this.onMouseWheel)},remove(){document.removeEventListener("mousewheel",this.onMouseWheel)},onMouseWheel:function(t){this.dollyModel(t)},dollyModel:function(t){const e=t.deltaY,i=Math.pow(this.moveSpeed,-e/400);this.el.object3D.position.multiplyScalar(i)}})},527:()=>{AFRAME.registerComponent("object-parent",{schema:{parent:{type:"selector"}},update(){document.querySelectorAll(`#${parent.id}`).length>1&&console.warn(`object-parent matches duplicate entities for new parent ${parent.id}`);const t=this.data.parent.object3D;this.reparent(t)},remove(){const t=this.el.parentEl;this.reparent(t.object3D)},reparent(t){const e=this.el.object3D,i=e.parent;e.parent!==t&&(objectEl=t=>"Scene"===t.type?this.el.sceneEl:t.el,console.log(`Reparenting ${e.el.id} from ${objectEl(i).id} to ${objectEl(t).id}`),t.attach(e))}})},403:()=>{AFRAME.registerComponent("raycaster-thresholds",{dependencies:["raycaster"],schema:{line:{type:"number",default:.01},points:{type:"number",default:.01}},init(){this.oldLine=this.el.components.raycaster.raycaster.params.Line.threshold,this.oldPoints=this.el.components.raycaster.raycaster.params.Points.threshold,this.el.components.raycaster.raycaster.params.Line.threshold=this.data.line,this.el.components.raycaster.raycaster.params.Points.threshold=this.data.points},remove(){this.el.components.raycaster.raycaster.params.Line.threshold=this.oldLine,this.el.components.raycaster.raycaster.params.Points.threshold=this.oldPoints}})},81:()=>{AFRAME.registerComponent("screen-display",{schema:{position:{type:"string",default:"percent"},xpos:{type:"number",default:50},ypos:{type:"number",default:50},scale:{type:"string",default:"percent"},keepaspect:{type:"boolean",default:!0},width:{type:"number",default:10},height:{type:"number"},zscale:{type:"number"},zdist:{type:"number",default:.01}},update:function(){switch(this.screenwidth=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,this.screenheight=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,this.data.position){case"percent":this.xpospercent=this.data.xpos,this.ypospercent=this.data.ypos;break;case"pixels":this.xpospercent=100*this.data.xpos/this.screenwidth,this.ypospercent=100*this.data.ypos/this.screenheight;break;default:console.log(`Unexpected Config: ${this.data.position}`)}switch(this.data.scale){case"percent":this.xscalepercent=this.data.width,this.yscalepercent=this.data.height;break;case"pixels":this.xscalepercent=100*this.data.width/this.screenwidth,this.yscalepercent=100*this.data.height/this.screenheight;break;default:console.warn(`Unexpected Config: ${this.data.position}`)}this.data.keepaspect?(this.yscalepercent=this.xscalepercent*this.screenwidth/this.screenheight,this.data.height&&console.warn('Height being ignored, since "keepaspect" is set.')):this.data.height||console.warn('"keepaspect" is not set, so height is required, but none provided.');var t=Math.tan(59*Math.PI/180)*this.data.zdist,e=t*this.screenwidth/this.screenheight,i=(this.xpospercent/100-.5)*e,s=(.5-this.ypospercent/100)*t;this.el.object3D.position.set(i,s,-this.data.zdist);const o=e*this.xscalepercent/100,n=t*this.yscalepercent/100;var r=this.data.zscale*this.data.zdist/100;this.data.keepaspect?r=o:this.data.zscale||console.warn('"keepaspect" is not set, so zscale is required, but none provided.'),this.el.object3D.scale.set(o,n,r)},tick:function(){const t=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,e=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;this.screenwidth===t&&this.screenheight===e||this.update()}}),AFRAME.registerComponent("screendisplay",{schema:{position:{type:"string",default:"percent"},xpos:{type:"number",default:50},ypos:{type:"number",default:50},scale:{type:"string",default:"percent"},keepaspect:{type:"boolean",default:!0},width:{type:"number",default:10},height:{type:"number"},zscale:{type:"number"},zdist:{type:"number",default:.01}},update:function(){this.el.setAttribute("screen-display",{position:this.data.position,xpos:this.data.xpos,ypos:this.data.ypos,scale:this.data.scale,keepaspect:this.data.keepaspect,width:this.data.width,height:this.data.height,zscale:this.data.zscale,zdist:this.data.zdist})}})}},e={};function i(s){var o=e[s];if(void 0!==o)return o.exports;var n=e[s]={exports:{}};return t[s](n,n.exports,i),n.exports}AFRAME.components["mouse-manipulation"]||i(363),AFRAME.components["screen-display"]||i(81),AFRAME.components.label||i(711),AFRAME.components["raycaster-thresholds"]||i(403),AFRAME.components["connecting-line"]||i(244),AFRAME.registerSystem("desktop-vr-controller",{init(){this.controllers=0},registerController(){0===this.controllers&&(this.disableExistingCursors(),this.createCursor()),this.controllers++},unregisterController(){this.controllers--,this.controllers<=0&&(this.controllers=0,this.myCursor.parentNode.removeChild(this.myCursor),this.myCursor=null,this.reinstateCursors())},createCursor(){this.myCursor=document.createElement("a-entity"),this.myCursor.setAttribute("id","desktop-vr-controller-cursor"),this.myCursor.setAttribute("cursor","rayOrigin: mouse"),this.myCursor.setAttribute("raycaster","objects: [desktop-vr-controller]"),this.myCursor.setAttribute("raycaster-thresholds","line: 0"),this.myCursor.setAttribute("mouse-manipulation",""),this.el.sceneEl.appendChild(this.myCursor)},disableExistingCursors(){const t=document.querySelectorAll("[cursor]");for(this.oldCursorStates=[],ii=0;ii<t.length;ii++){const e=t[ii];this.oldCursorStates.push(e.getAttribute("raycaster","enabled")),"mouse"===e.components.cursor.data.rayOrigin&&e.setAttribute("raycaster","enabled",!1)}},reinstateCursors(){if(!this.oldCursorStates)return;const t=document.querySelectorAll("[cursor]");for(ii=0;ii<t.length;ii++)if(this.oldCursorStates[ii]){const e=t[ii];"mouse"===e.components.cursor.data.rayOrigin&&e.setAttribute("raycaster","enabled",this.oldCursorStates[ii])}}}),AFRAME.registerComponent("desktop-vr-controller",{dependencies:["oculus-touch-controls"],init(){this.simulateController=this.simulateController.bind(this),this.removeController=this.removeController.bind(this),this.keyUp=this.keyUp.bind(this),this.keyDown=this.keyDown.bind(this),this.el.sceneEl.addEventListener("enter-vr",this.simulateController),this.el.sceneEl.addEventListener("exit-vr",this.removeController),this.labels={},this.keysDown={},this.keysLocked={},this.createLockHint(),AFRAME.version>="1.4.0"&&this.el.object3D.rotateX(Math.PI/4)},simulateController(){if(this.el.sceneEl.renderer.xr.getSession())return void console.log("desktop-vr-controller suppressed due to presence of an XR session");this.system.registerController();const t=this.el.sceneEl;if(this.trackedControlsSystem=t&&t.systems["tracked-controls-webxr"],!this.trackedControlsSystem)return console.warn("No tracked-controls-webxr system found for desktop-vr-controller"),!1;oculusData=this.el.components["oculus-touch-controls"].data,oculusData?(this.controllerData={hand:oculusData.hand,handedness:oculusData.hand,profiles:["oculus-touch-controls","oculus-touch-v3"]},this.trackedControlsSystem.controllers.push(this.controllerData),t.emit("controllersupdated"),"left"==this.controllerData.hand?(this.keyBindings={ShiftLeft:"trigger",ControlLeft:"grip",KeyX:"xbutton",KeyY:"ybutton",Digit1:"thumbstick"},this.labels.trigger=this.createLabel("L-Shift","trigger"),this.lockLabel(this.labels.trigger),this.unlockLabel(this.labels.trigger),this.labels.grip=this.createLabel("L-Ctrl","grip"),this.labels.xbutton=this.createLabel("X","xbutton"),this.labels.ybutton=this.createLabel("Y","ybutton"),this.labels.thumbstick=this.createLabel("1","thumbstick")):(this.keyBindings={ShiftRight:"trigger",ControlRight:"grip",KeyV:"abutton",KeyB:"bbutton",Digit2:"thumbstick"},this.labels.trigger=this.createLabel("R-Shift","trigger"),this.labels.grip=this.createLabel("R-Ctrl","grip"),this.labels.abutton=this.createLabel("V","abutton"),this.labels.bbutton=this.createLabel("B","bbutton"),this.labels.thumbstick=this.createLabel("2","thumbstick")),window.addEventListener("keyup",this.keyUp),window.addEventListener("keydown",this.keyDown)):console.warn("No oculus-touch-controls component found for desktop-vr-controller")},createLabel(t,e){var i,s;if("left"==this.controllerData.hand)switch(e){case"trigger":i="0.015 -0.02 0.01",s="0.1 0 -0.2";break;case"grip":i="0.015 -0.02 0.06",s="0.25 0 0";break;case"xbutton":i="0.017 0.005 0.045",s="0.0 0.1 0.1";break;case"ybutton":i="0.022 0.005 0.03",s="0.0 0.2 -0.1";break;case"thumbstick":i="0.001 0.015 0.03",s="-0.1 0.2 -0.1";break;default:console.error(`unexpected position identifier: ${e}`)}else switch(e){case"trigger":i="-0.015 -0.02 0.01",s="-0.1 0 -0.2";break;case"grip":i="-0.015 -0.02 0.06",s="-0.25 0 0";break;case"abutton":i="-0.017 0.005 0.045",s="0.0 0.1 0.1";break;case"bbutton":i="-0.022 0.005 0.03",s="0.0 0.2 -0.1";break;case"thumbstick":i="-0.001 0.015 0.03",s="0.1 0.2 -0.1";break;default:console.error(`unexpected position identifier: ${e}`)}const o=document.createElement("a-entity");o.setAttribute("position",i),o.setAttribute("label-anchor",`offsetVector: ${s}; lineColor: green`);const n=document.createElement("a-entity");n.setAttribute("label",{overwrite:!0,forceDesktopMode:!0}),o.appendChild(n),this.el.appendChild(o);const r=document.createElement("a-plane");return r.setAttribute("width",t.length>2?.2:.1),r.setAttribute("height",.1),r.setAttribute("color","black"),r.setAttribute("text",`value:${t};\n color: white;\n wrapCount: ${t.length+2};\n align: center;\n anchor: center`),"thumbstick"===e&&r.setAttribute("desktop-vr-thumbstick",""),n.appendChild(r),o},createLockHint(){const t=document.createElement("a-plane");t.setAttribute("color","black"),t.setAttribute("height",.12),t.setAttribute("screen-display","xpos: 50; ypos: 85; width: 25"),t.setAttribute("text","value: Press Enter to Lock Button Down; align: center; wrapCount: 30"),document.querySelector("[camera]").appendChild(t),this.lockHint=t,this.lockHintCounter=0,this.hideLockHint()},showLockHint(){this.lockHint.object3D.visible=!0,this.lockHintCounter++},hideLockHint(){this.lockHintCounter--,this.lockHintCounter<=0&&(this.lockHint.object3D.visible=!1,this.lockHintCounter=0)},lockLabel(t){if(t.querySelector("a-image"))return;const e=t.querySelector("a-plane"),i=document.createElement("a-image");i.setAttribute("src","https://cdn.jsdelivr.net/gh/diarmidmackenzie/aframe-components@latest/assets/icons/lock.svg");const s=.4*e.attributes.width.value;i.object3D.position.set(s,0,0),i.object3D.scale.set(.03,.03,.03),e.appendChild(i)},unlockLabel(t){const e=t.querySelector("a-image");e&&e.parentNode.removeChild(e)},removeLabels(){Object.entries(this.labels).forEach((([t,e])=>{e.parentNode.removeChild(e)})),this.labels={}},removeController(){console.log("Removing controller:",this.controllerData),console.log("Current Controllers:",this.trackedControlsSystem.controllers);const t=this.trackedControlsSystem.controllers.findIndex((t=>t===this.controllerData));console.log("Find index: ",t),t>=0&&this.trackedControlsSystem.controllers.splice(t),this.el.sceneEl.emit("controllersupdated"),window.removeEventListener("keyup",this.keyUp),window.removeEventListener("keydown",this.keyDown),this.removeLabels(),this.system.unregisterController()},keyUp(t){const e=this.keyBindings[t.code];e&&(this.keysLocked[t.code]||("thumbstick"!==e?(this.el.emit(`${e}up`),this.el.emit(`${e}changed`)):this.labels[e].querySelector("[desktop-vr-thumbstick]").setAttribute("desktop-vr-thumbstick","active: false"),this.labels[e].setAttribute("label-anchor","lineColor: green"),this.labels[e].querySelector("a-plane").setAttribute("color","black")),this.keysDown[t.code]=!1,this.hideLockHint())},keyDown(t){if(t.repeat)return;this.keysLocked[t.code]=!1;const e=this.keyBindings[t.code];e&&(this.showLockHint(),"thumbstick"!==e?(this.el.emit(`${e}down`),this.el.emit(`${e}changed`)):this.labels[e].querySelector("[desktop-vr-thumbstick]").setAttribute("desktop-vr-thumbstick",`active: true;\n controller: #${this.el.id}`),this.labels[e].setAttribute("label-anchor","lineColor: yellow"),this.labels[e].querySelector("a-plane").setAttribute("color","grey"),this.unlockLabel(this.labels[e]),this.keysDown[t.code]=!0),"Enter"===t.code&&Object.entries(this.keysDown).forEach((([t,e])=>{if(e){this.keysLocked[t]=!0;const e=this.keyBindings[t];e&&(this.lockLabel(this.labels[e]),this.hideLockHint())}}))}}),AFRAME.registerComponent("desktop-vr-thumbstick",{schema:{active:{type:"boolean",default:!1},controller:{type:"selector"}},init(){this.dimension=100,this.radius=.5;const t=this.el.sceneEl.camera;this.mouseMove=this.mouseMove.bind(this),this.mouseDown=this.mouseDown.bind(this),this.mouseUp=this.mouseUp.bind(this),this.startMouseX=void 0,this.startMouseY=void 0,this.thumbstickVector=new THREE.Vector2(0,0),this.thumbstickDown=!1,this.base=document.createElement("a-circle"),this.base.setAttribute("radius",this.radius),this.base.setAttribute("id",Math.random().toString(36).slice(2)),this.base.setAttribute("material","color:black; shader: flat"),this.base.object3D.visible=!1,t.el.appendChild(this.base),this.stick=document.createElement("a-circle"),this.stick.setAttribute("material","color:#bbb; shader: flat"),this.stick.setAttribute("radius",.6*this.radius),this.stick.object3D.position.set(0,0,1e-5),this.base.appendChild(this.stick),this.line=document.createElement("a-entity"),this.line.object3D.visible=!1,this.el.sceneEl.appendChild(this.line),window.addEventListener("mousemove",this.mouseMove),window.addEventListener("mouseup",this.mouseUp),window.addEventListener("mousedown",this.mouseDown)},update(){this.data.active?(this.base.setAttribute("screen-display",{position:"pixels",scale:"pixels",width:this.dimension,xpos:this.startMouseX,ypos:this.startMouseY}),this.base.object3D.visible=!0,this.line.setAttribute("connecting-line",`start: #${this.data.controller.id};\n startOffset: 0 0.015 0.03;\n end: #${this.base.id};\n endOffset: 0 0 0;\n color: yellow`),this.line.object3D.visible=!0):(this.base.object3D.visible=!1,this.line.removeAttribute("connecting-line"),this.line.object3D.visible=!1,this.thumbstickVector.lengthSq()>0&&(this.thumbstickVector.set(0,0),this.generateEvents()),this.thumbstickDown&&(this.data.controller.emit("thumbstickup"),this.data.controller.emit("thumbstickchanged"),this.thumbstickDown=!1))},remove(){window.removeEventListener("mousemove",this.mouseMove)},mouseMove(t){this.data.active?(this.startMouseX&&this.startMouseY||(this.startMouseX=t.clientX,this.startMouseY=t.clientY),xDiff=(t.clientX-this.startMouseX)/(.375*this.dimension),yDiff=(t.clientY-this.startMouseY)/(.375*this.dimension),this.thumbstickVector.set(xDiff,yDiff),this.thumbstickVector.clampLength(0,1),this.updateDisplay(),this.generateEvents()):(this.startMouseX=t.clientX,this.startMouseY=t.clientY)},updateDisplay(){this.stick.object3D.position.x=this.thumbstickVector.x*this.radius*.75,this.stick.object3D.position.y=-this.thumbstickVector.y*this.radius*.75},generateEvents(){this.data.controller.emit("thumbstickmoved",this.thumbstickVector)},mouseDown(){this.data.active&&(this.stick.setAttribute("material","color:#888; shader: flat"),this.data.controller.emit("thumbstickdown"),this.data.controller.emit("thumbstickchanged"),this.thumbstickDown=!0)},mouseUp(){this.data.active&&(this.stick.setAttribute("material","color:#bbb; shader: flat"),this.data.controller.emit("thumbstickup"),this.data.controller.emit("thumbstickchanged"),this.thumbstickDown=!1)}})})();

@@ -110,2 +110,8 @@ if (!AFRAME.components['mouse-manipulation']) require('aframe-mouse-manipulation')

// from 1.4.0, A-Frame no longer provides an automatic 45 degree rotation to the controllers
// SO we need to do it ourselves to get a natural default position.
// See: https://github.com/aframevr/aframe/pull/5141
if (AFRAME.version >= "1.4.0") {
this.el.object3D.rotateX(Math.PI / 4)
}
},

@@ -112,0 +118,0 @@

{
"name": "aframe-desktop-vr-controller",
"version": "0.1.0",
"version": "0.1.1",
"description": "Simulates a VR controller on the desktop, controllable using mouse & keyboard.",

@@ -36,3 +36,3 @@ "main": "index.js",

"aframe-connecting-line": "^0.1.0",
"aframe-label": "^0.1.0",
"aframe-label": "^0.1.2",
"aframe-mouse-manipulation": "^0.1.0",

@@ -39,0 +39,0 @@ "aframe-raycaster-thresholds": "^0.1.0",

@@ -57,6 +57,4 @@ ## desktop-vr-controller

```
<script src="https://cdn.jsdelivr.net/npm/aframe-mouse-manipulation@0.1.0/dist/mouse-manipulation.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/aframe-desktop-vr-controller@0.1.0/dist/desktop-vr-controller.min.js"></script>
```

@@ -72,4 +70,2 @@

```

@@ -76,0 +72,0 @@ if (!AFRAME.components['desktop-vr-controller']) require('aframe-desktop-vr-controller')

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc