flame icon indicating copy to clipboard operation
flame copied to clipboard

Add orientation property do PositionComponent

Open st-pasha opened this issue 4 years ago • 4 comments

What could be improved

New property double orientation; will keep track of where the component is "looking at": is it naturally pointing up, or down, or left, or right? It's easier (and more flexible) to have this as a double and not enum.

Maybe there is a better name for it too.

Why should this be improved

The PositionComponent currently consists of size, anchor, and transform (where transform has position, rotation, and scale). What it's missing is the notion of a natural direction.

Use cases:

  • allow PositionComponent.angleTo() method which computes the angle between this component's natural direction and another given component;
  • allow RotateEffect.towards() which can rotate the component so that it would "look at" another component.

Any risks?

No.

st-pasha avatar Nov 15 '21 23:11 st-pasha

Sounds like a very good addition! The orientation needs to be defined from some point too right, would this be up or right defined, like where is 0? Since this wouldn't be a breaking change it could be done post v1.

spydon avatar Nov 16 '21 11:11 spydon

Isn't that the same as angle?

luanpotter avatar Nov 18 '21 02:11 luanpotter

angle measures rotation from the original position. This property tells you what the original orientation is (relative to the screen).

st-pasha avatar Nov 18 '21 17:11 st-pasha

This seems like angle to me... and then both angleTo and lookAt are derivates of that plus some external input.

esDotDev avatar Feb 18 '22 17:02 esDotDev

I wonder what we could name this, I feel that orientation might be a bit confusing. Maybe one of these (not completely convinced by any of them though so please add more suggestions if you have any):

  • initialAngle
  • initialOrientation
  • startAngle ...

spydon avatar Sep 06 '22 08:09 spydon

As this new property is just going to offset the actual angle, calling it angularOffset would be appropriate. Words like initial and start make it seem like it gets applied only at the beginning and not throughout the lifetime of the component.

ufrshubham avatar Sep 06 '22 10:09 ufrshubham

  • nativeAngle
  • intrinsicAngle

I think it's best to stick to the naming pattern "*Angle", to make it clear that this property is a kind of angle and not anything else.

st-pasha avatar Sep 06 '22 17:09 st-pasha

nativeAngle is the best one so far I think.

spydon avatar Sep 08 '22 07:09 spydon