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

aframe-blend-transforms

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aframe-blend-transforms

Give an A-Frame object a transform (i.e. position, rotation & scale) that is a weighted blend of two different object transforms.

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

blend-transforms

This is a companion component to screen-display, which supports giving an object a transform (i.e. position, rotation & scale) that is a weighted blend of two different object transforms (we call these "anchors")

The can be used in combination with the animation component to smoothly move objects from a position on screen to a position in the 3D world, and vice-versa.

See examples:

  • From screen to 3D world
  • From 3D world to screen

Status

This component is pretty new. It has been used in one application and performed well, but may hit problems in novel situations.

It explicitly can handle:

  • Working in combination with screen-display for AR applications.
  • Movement of the anchor objects whose transform is blended - the object that blends their transforms will dynamically update its own transform in response to these movements.

Currently, scale, position & rotation are all controlled by a single parameter - more flexibility may be desirable in future - see "Other Notes" below for an explanation why.

Installation

Via CDN

<script src="https://cdn.jsdelivr.net/npm/aframe-screen-display@0.1.1/index.min.js"></script>

Or via npm

npm install aframe-screen-display

Usage Guidelines

See the examples folder for some examples of how to use the component, including examples of how to combine it with the animation component.

Typically, you will set up two invisible anchor objects, and then refer to them from the component that you wish to position with a blend of their transforms.

Component Interface

The following attributes are supported on the blend-transforms component:

  • objectA: A selector for the first object whose transform is to be blended.
  • objectB: A selector for the second object whose transform is to be blended.
  • percentage: The percentage of the transform to be taken from object B. The remaining percentage will be taken from Object A. The default value is 0, which will lead to the object being positioned at the position of object A. When this is set to 100, the object will be positioned at the position of object B.

Other Notes

Position, scale and rotation are all weighted linearly, using the configured percentage.

This may lead to unexpected behaviour when using this component in combination with screen-display. Although the object may be moving linearly in space, if it starts far from the camera, and ends up close to it, then it may appear to be moving slowly at the start, and very fast at the end.

This effect can be compensates for by using a non-linear easing function in the animation (e.g. quadratic or cubic). However, while that might "correct"the apparent rate of positional change, it will also make the rotation speed non-linear, which may look odd.

In future, I hope to to enhance this component to allow options for independent control of each of rotation, position and scale.

Keywords

FAQs

Package last updated on 18 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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