Skip to content

hand-controls component: broken features, performance. #5087

Open
@kylebakerio

Description

@kylebakerio

The hand-controls component is a bit creaky--as it mentions in its own comments, it was originally just a proof of concept. It seems incomplete; as issue #4596 points out, the events are problematic, and the 'color' property doesn't affect the mesh. It also has a lot of room for improvement in terms of not being sufficiently dry, being written in a bit of an old fashioned style, and not being written in a way that is at all conscious of the effects on garbage collection.

When writing a version of this component for NAF, I went ahead and gave the component an overhaul, and ended up with this:

https://github.com/networked-aframe/networked-aframe/blob/master/src/components/networked-hand-controls.js

Would a pull request be welcome to add these changes over to core? Any comments on improving this code? Should I just make a pull request and we work from there?

Note: lines 20-40 are NAF-specific and can be ignored.

As you'll see, I have been working on a code style that minimizes garbage collection. You can see this in the str property and the this.Y[this.Z] pattern. (Because of other quiet object re-use patterns in A-Frame, there are very tricky pitfalls that show up when just assigning properties itself).

I know it's unorthodox; I'd love feedback on a cleaner way to write this code, if you have ideas. If it's agreed that it's a good idea, though, it would be interesting to discuss ways to support this code style in A-Frame to help component authors reduce garbage collection by default, without tripping over some of the existing optimizations under the hood in A-Frame.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions