Gathering detailed insights and metrics for axis3d-inputs
Gathering detailed insights and metrics for axis3d-inputs
Gathering detailed insights and metrics for axis3d-inputs
Gathering detailed insights and metrics for axis3d-inputs
npm install axis3d-inputs
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
3 Commits
9 Watchers
1 Branches
2 Contributors
Updated on Aug 17, 2017
Latest Version
2.0.0
Package Id
axis3d-inputs@2.0.0
Size
7.32 kB
NPM Version
5.3.0
Node Version
7.10.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Axis3D commands that provide state for user inputs.
1$ npm install axis3d-inputs
1const KeyboardInput = require('axis3d-inputs/keyboard') 2const MouseInput = require('axis3d-inputs/keyboard') 3const TouchInput = require('axis3d-inputs/keyboard') 4const quat = require('gl-quat') 5const vec3 = require('gl-vec3') 6 7const keyboard = new KeyboardInput(ctx) 8const mouse = new MouseInput(ctx) 9const touch = new TouchInput(ctx) 10 11const rotation = quat.identity([]) 12const position = [0, 0, 0] 13 14frame(() => { 15 keyboard(({keys}) => { 16 if (keys.left) { 17 vec3.add(position, position, [-1, 0, 0]) 18 } else if (keys.right) { 19 vec3.add(position, position, [+1, 0, 0]) 20 } 21 22 if (keys.up) { 23 vec3.add(position, position, [0, 0, +1]) 24 } else if (keys.down) { 25 vec3.add(position, position, [0, 0, -1]) 26 } 27 }) 28 29 mouse(({mouse, wheel}) => { 30 if (mouse.buttons > 0) { 31 quat.rotateY(rotation, rotation, mouse.deltaX) 32 quat.rotateX(rotation, rotation, mouse.deltaY) 33 } 34 35 if (wheel.deltaY) { 36 vec3.add(position, position, [0, 0, 0.5*wheel.deltaY]) 37 } 38 }) 39 40 touch(({touches}) => { 41 if (touches) { 42 switch (touches.length) { 43 case 1: 44 quat.rotateY(rotation, rotation, touches[0].deltaX) 45 quat.rotateX(rotation, rotation, touches[0].deltaY) 46 break; 47 48 case 2: break; 49 default: 50 } 51 } 52 }) 53})
This module exposes constructors for commands compatible with Axis3D. Commands are just functions that accept arguments and a callback. The callback function exposes context variables associated with the command. Context variables can hold information about the current state of the input in use.
The KeyboardInput
command provides keyboard context variables that
expose which keys are currently pressed (or not).
1keyboard(({keys, keycodes}) => { 2 if (keys.h) left() 3 if (keys.l) right() 4 if (keys.k) up() 5 if (keys.j) down() 6})
keys
- An object containing a map of key names and a boolean value
indicating that the key is currently pressedkeycodes
- An object containing a map of key codes and a boolean
value indicating that the key is currently pressedThe MouseInput
command provides mouse context variables that
expose the current mouse state including the wheel and currently pressed
buttons count. The current, delta, and previous [x, y]
coordinates of
the mouse cursor position and wheel are exposed.
1mouse(({mouse, wheel}) => { 2 quat.setAxisAngle(xRotation, [1, 0, 0], 0.5*mouse.deltaY) 3 quat.setAxisAngle(yRotation, [0, 1, 0], 0.5*mouse.deltaX) 4}) 5 fieldOfView += 0.5*wheel.deltaY
mouse
- The current mouse state
buttons
- Number of mouse buttons currently pressedcurrentX
- The current x
coordinate of the mouse cursorcurrentY
- The current y
coordinate of the mouse cursordeltaX
- The differnence between the previous and current x
coordinate of the mouse cursordeltaY
- The differnence between the previous and current y
coordinate of the mouse cursorprevX
- The previous x
coordinate of the mouse cursorprevY
- The previous y
coordinate of the mouse cursorThe TouchInput
command provides touch context variables that
expose the current touch state including the wheel and currently pressed
buttons count. The current, delta, and previous [x, y]
coordinates of
the touch position and wheel are exposed.
1touch(({touches, wheel}) => { 2 if (1 == touches.length) { 3 quat.setAxisAngle(xRotation, [1, 0, 0], 0.5*touches[0].deltaY) 4 quat.setAxisAngle(yRotation, [0, 1, 0], 0.5*touches[0].deltaX) 5 } 6})
touches
- Currently active touches where touches[i]
is:
currentX
- The current x
coordinate of the touchcurrentY
- The current y
coordinate of the touchoffsetX
- The current x
coordinate offset of the touch positionoffsetY
- The current y
coordinate offset of the touch positionstartX
- The start x
coordinate offset of the touchstartY
- The start y
coordinate offset of the touchdeltaX
- The differnence between the previous and current x
coordinate of the touch positiondeltaY
- The differnence between the previous and current y
coordinate of the touch positionprevX
- The previous x
coordinate of the touchprevY
- The previous y
coordinate of the touchMIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/3 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
90 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More