0.4.3 • Published 1 year ago

aframe-blink-controls v0.4.3

Weekly downloads
9
License
MIT
Repository
github
Last release
1 year ago

aframe-blink-controls

Live examples

Video demo

This component adds teleport with rotation to A-Frame applications! It's a modified version of the aframe-teleport-controls component by @fernandojsg, and the main changes are:

  • added support for rotation,
  • removed line teleport option,
  • added support for thumbsticks,
  • added snap turn support,
  • calculation of parabolic roots for accurate longer teleport rays.

This is a work in progress to support an experimental project and currently only tested on: Oculus Quest, Oculus Quest 2. Support for HTC Vive/Valve Index/HP Reverb G2 etc. controllers is only theoretical/untested, as I don't have a way of testing on these devices yet. PRs welcome!

Properties

PropertyDescriptionDefault Value
cameraRigSelector of the camera Rig to teleport
teleportOriginSelector of the child of cameraRig to use as the center point for teleporting, typically the camera. If set, teleporting will position the cameraRig such that this element ends up above the teleport location (rather than the center of the cameraRig)
collisionEntitiesSelector of the meshes used to check the collisions. If no value provided a plane y = 0 is used
startEventsAlternative to button, list of events to start teleporting.[]
endEventsPaired with startEvents, list of events to end teleporting.[]
cancelEventsEvents to cancel teleporting.[]
buttonButton used to launch the teleport: trackpad, trigger, grip, menu, thumbstick
hitEntityEntity used to show at the hitting position. If no value provided a cylinder will be used as default.
hitCylinderColorColor used for the default hitEntity primitives#4d93fd
hitCylinderRadiusRadius used for the default hitEntity primitives0.25
hitCylinderHeightHeight used for the default hitEntity primitives0.3
curveHitColorColor used for the curve when hit the mesh#4d93fd
curveMissColorColor used for the curve when it doesn't hit anything#ff0000
curveNumberPointsNumber of points used in the curve50
curveLineWidthLine width of the curve0.025
curveShootingSpeedCurve shooting speed, as bigger value, farther distance.8
intervalNumber of milliseconds to wait in between each intersection test. Lower number is better for faster updates. Higher number is better for performance.0
defaultPlaneSizeDefault plane size100
landingNormalNormal vector to detect collisions with the collisionEntity(0, 1, 0)
landingMaxAngleAngle threshold (in degrees) used together with landingNormal to detect if the mesh is too steep to jump to it.45
drawIncrementallyIf the ray should be drawn as an animationtrue
incrementalDrawMsHow long the ray animation should be500
snapTurnIf left/right thumbstick axis performs a 45 deg rotationtrue
rotateOnTeleportWill rotate player on teleport, facing the direction where the arrow is pointingtrue

Usage

Directly in the browser

Use the script files directly, for example:

<head>
  <title>My A-Frame Scene</title>
  <script src="https://aframe.io/releases/1.3.0/aframe.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/aframe-blink-controls/dist/aframe-blink-controls.min.js"></script>
</head>

<body>
  <a-scene>
    <!-- camera rig -->
    <a-entity id="player">
      <!-- camera -->
      <a-entity id="camera" camera wasd-controls look-controls></a-entity>
      <!-- hand controls -->
      <a-entity id="left-hand" oculus-touch-controls="hand: left" blink-controls></a-entity>
      <a-entity id="right-hand" oculus-touch-controls="hand: right"></a-entity>
    </a-entity>
  </a-scene>
</body>

By default, this uses the forward thumbstick axis to activate the teleport, as that seems to be a familiar way across different applications and platforms, in addition to being pratical (as it does not require pressing buttons while also e.g. moving axes). When the teleport is active, you can also choose the direction you want to be facing (rotation) after teleporting, by using the thumbstick.

You can also use e.g. the trigger button instead of the thumbstick by adding button: trigger (or trackpad, trigger, grip, menu, thumbstick). Or specify startEvents and endEvents for specific use cases, though give the default bindings a try first!

For collisionEntities, you specify a selector for the objects that you want to calculate collisions with. By default this is a 100x100 plane at y = 0.

Installing via npm

Install via npm:

npm install aframe-blink-controls

Then require it: this will register the component globally.

require('aframe-blink-controls');

Development

Use npm run dev to run a development build with a number of provided examples on https://localhost:8080 (or alternatively your computer's IP on your network, e.g. for testing on standalone devices).

Events

EventProperties of event.detailDescription
teleportedoldPosition, newPosition, hitPoint, rotationQuaternionFires when teleportation begins.
0.4.1

2 years ago

0.4.0

2 years ago

0.4.3

1 year ago

0.4.2

1 year ago

0.3.0

2 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.0.1

3 years ago