aframe-xr icon indicating copy to clipboard operation
aframe-xr copied to clipboard

Avoid creating objects in reticle and xranchor components

Open vincentfretin opened this issue 6 years ago • 3 comments

I optimized the reticle and xranchor components to not create objects on each frame. I tested the reticle component. I did not test xranchor component, so be sure to test it before merge.

vincentfretin avatar May 12 '18 15:05 vincentfretin

There used to be a difference between changing these with "setAttribute" (which would update the component values AND set the object3D properties) and just setting the properties directly. Setting the object3D directly wouldn't update the component values.

For example, if a different component wants to look at the rotation or position of an aframe entity, and it get's the property of the corresponding component, in this changed version, it wouldn't see the new values since you are just setting them directly and not calling setAttribute.

Do newer versions of AFrame fix this? (I admit I haven't been paying too close attention to AFrame internals in months).

blairmacintyre avatar May 13 '18 11:05 blairmacintyre

This has indeed changed in aframe 0.8.2. setAttribute or getAttribute set or retrieve position, rotation or visible directly on object3D now.

vincentfretin avatar May 13 '18 11:05 vincentfretin

The behavior you described was indeed an issue on aframe 0.7.1. This is not the case on aframe 0.8.2.

vincentfretin avatar May 13 '18 11:05 vincentfretin