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

aframe-input-mapping-component

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-input-mapping-component - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

.npmignore

3

dist/aframe-input-mapping-component.js

@@ -196,3 +196,2 @@ /******/ (function(modules) { // webpackBootstrap

// Merge mappings
var mappings = data.mappings;
for (var mappingName in data.mappings) {

@@ -219,2 +218,4 @@ var mapping = data.mappings[mappingName];

if (!AFRAME.scenes) { return; }
for (var i = 0; i < AFRAME.scenes.length; i++) {

@@ -221,0 +222,0 @@ AFRAME.scenes[i].emit('inputmappingregistered');

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

!function(e){function n(t){if(r[t])return r[t].exports;var i=r[t]={exports:{},id:t,loaded:!1};return e[t].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var r={};return n.m=e,n.c=r,n.p="",n(0)}([function(e,n){if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");AFRAME.currentInputMapping="default",AFRAME.inputMappings={},AFRAME.registerSystem("input-mapping",{mappings:{},mappingsPerControllers:{},loadedControllers:[],init:function(){var e=this;this.keyboardHandler=this.keyboardHandler.bind(this),this.sceneEl.addEventListener("inputmappingregistered",function(){e.removeControllersListeners();for(var n=0;n<e.loadedControllers.length;n++){var r=e.loadedControllers[n];e.updateControllersListeners(r)}}),this.sceneEl.addEventListener("controllerconnected",function(n){var r={name:n.detail.name,hand:n.detail.component.data.hand,element:n.detail.target,handlers:{}};e.loadedControllers.push(r),e.updateControllersListeners(r)}),this.addKeyboardListeners()},addKeyboardListeners:function(){document.addEventListener("keyup",this.keyboardHandler),document.addEventListener("keydown",this.keyboardHandler),document.addEventListener("keypress",this.keyboardHandler)},removeKeyboardListeners:function(){document.removeEventListener("keyup",this.keyboardHandler),document.removeEventListener("keydown",this.keyboardHandler),document.removeEventListener("keypress",this.keyboardHandler)},removeControllerListeners:function(e){for(var n in e.handlers){var r=e.handlers[n];e.element.removeEventListener(n,r)}e.handlers={}},updateControllersListeners:function(e){if(this.removeControllerListeners(e),!AFRAME.inputMappings.mappings)return void console.warn("controller-mapping: No mappings defined");var n=this.mappingsPerControllers[e.name]={};for(var r in AFRAME.inputMappings.mappings){var t=AFRAME.inputMappings.mappings[r],i=t.common;i&&this.updateMappingsPerController(i,n,r);var a=t[e.name];a?this.updateMappingsPerController(a,n,r):console.warn("controller-mapping: No mappings defined for controller type: ",e.name)}for(var o in n){var s=function(e){var r=n[e.type],t=r[AFRAME.currentInputMapping]?r[AFRAME.currentInputMapping]:r.default;t&&e.detail.target.emit(t,e.detail)};e.element.addEventListener(o,s),e.handlers[o]=s}},keyboardHandler:function(e){var n=AFRAME.inputMappings.mappings[AFRAME.currentInputMapping];if(n&&n.keyboard){n=n.keyboard;var r=32===e.keyCode?"Space":e.key,t=(r+"_"+e.type.substr(3)).toLowerCase(),i=n[t];i&&this.sceneEl.emit(i)}},updateMappingsPerController:function(e,n,r){for(var t in e){var i=e[t];n[t]||(n[t]={}),n[t][r]=i}},removeControllersListeners:function(){for(var e=0;e<this.loadedControllers.length;e++){var n=this.loadedControllers[e];this.removeControllerListeners(n)}this.mappingsPerControllers={}}}),AFRAME.registerInputMappings=function(e,n){if(n||0===Object.keys(AFRAME.inputMappings).length)AFRAME.inputMappings=e;else{e.actions&&(AFRAME.inputMappings.actions=e.actions);e.mappings;for(var r in e.mappings){var t=e.mappings[r];if(AFRAME.inputMappings.mappings[r])for(var i in t){var a=t[i];if(AFRAME.inputMappings.mappings[r][i])for(var o in a)AFRAME.inputMappings.mappings[r][i][o]=a[o];else AFRAME.inputMappings.mappings[r][i]=a}else AFRAME.inputMappings.mappings[r]=t}}for(var s=0;s<AFRAME.scenes.length;s++)AFRAME.scenes[s].emit("inputmappingregistered")}}]);
!function(e){function n(t){if(r[t])return r[t].exports;var i=r[t]={exports:{},id:t,loaded:!1};return e[t].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var r={};return n.m=e,n.c=r,n.p="",n(0)}([function(e,n){if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");AFRAME.currentInputMapping="default",AFRAME.inputMappings={},AFRAME.registerSystem("input-mapping",{mappings:{},mappingsPerControllers:{},loadedControllers:[],init:function(){var e=this;this.keyboardHandler=this.keyboardHandler.bind(this),this.sceneEl.addEventListener("inputmappingregistered",function(){e.removeControllersListeners();for(var n=0;n<e.loadedControllers.length;n++){var r=e.loadedControllers[n];e.updateControllersListeners(r)}}),this.sceneEl.addEventListener("controllerconnected",function(n){var r={name:n.detail.name,hand:n.detail.component.data.hand,element:n.detail.target,handlers:{}};e.loadedControllers.push(r),e.updateControllersListeners(r)}),this.addKeyboardListeners()},addKeyboardListeners:function(){document.addEventListener("keyup",this.keyboardHandler),document.addEventListener("keydown",this.keyboardHandler),document.addEventListener("keypress",this.keyboardHandler)},removeKeyboardListeners:function(){document.removeEventListener("keyup",this.keyboardHandler),document.removeEventListener("keydown",this.keyboardHandler),document.removeEventListener("keypress",this.keyboardHandler)},removeControllerListeners:function(e){for(var n in e.handlers){var r=e.handlers[n];e.element.removeEventListener(n,r)}e.handlers={}},updateControllersListeners:function(e){if(this.removeControllerListeners(e),!AFRAME.inputMappings.mappings)return void console.warn("controller-mapping: No mappings defined");var n=this.mappingsPerControllers[e.name]={};for(var r in AFRAME.inputMappings.mappings){var t=AFRAME.inputMappings.mappings[r],i=t.common;i&&this.updateMappingsPerController(i,n,r);var a=t[e.name];a?this.updateMappingsPerController(a,n,r):console.warn("controller-mapping: No mappings defined for controller type: ",e.name)}for(var s in n){var o=function(e){var r=n[e.type],t=r[AFRAME.currentInputMapping]?r[AFRAME.currentInputMapping]:r.default;t&&e.detail.target.emit(t,e.detail)};e.element.addEventListener(s,o),e.handlers[s]=o}},keyboardHandler:function(e){var n=AFRAME.inputMappings.mappings[AFRAME.currentInputMapping];if(n&&n.keyboard){n=n.keyboard;var r=32===e.keyCode?"Space":e.key,t=(r+"_"+e.type.substr(3)).toLowerCase(),i=n[t];i&&this.sceneEl.emit(i)}},updateMappingsPerController:function(e,n,r){for(var t in e){var i=e[t];n[t]||(n[t]={}),n[t][r]=i}},removeControllersListeners:function(){for(var e=0;e<this.loadedControllers.length;e++){var n=this.loadedControllers[e];this.removeControllerListeners(n)}this.mappingsPerControllers={}}}),AFRAME.registerInputMappings=function(e,n){if(n||0===Object.keys(AFRAME.inputMappings).length)AFRAME.inputMappings=e;else{e.actions&&(AFRAME.inputMappings.actions=e.actions);for(var r in e.mappings){var t=e.mappings[r];if(AFRAME.inputMappings.mappings[r])for(var i in t){var a=t[i];if(AFRAME.inputMappings.mappings[r][i])for(var s in a)AFRAME.inputMappings.mappings[r][i][s]=a[s];else AFRAME.inputMappings.mappings[r][i]=a}else AFRAME.inputMappings.mappings[r]=t}}if(AFRAME.scenes)for(var o=0;o<AFRAME.scenes.length;o++)AFRAME.scenes[o].emit("inputmappingregistered")}}]);

@@ -150,3 +150,2 @@ /* global AFRAME */

// Merge mappings
var mappings = data.mappings;
for (var mappingName in data.mappings) {

@@ -173,2 +172,4 @@ var mapping = data.mappings[mappingName];

if (!AFRAME.scenes) { return; }
for (var i = 0; i < AFRAME.scenes.length; i++) {

@@ -175,0 +176,0 @@ AFRAME.scenes[i].emit('inputmappingregistered');

{
"name": "aframe-input-mapping-component",
"version": "0.1.0",
"version": "0.1.1",
"description": "A Input Mapping component for A-Frame.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -0,0 +0,0 @@ ## aframe-input-mapping-component

Sorry, the diff of this file is not supported yet

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