This repository has been archived by the owner on Jul 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Get/Set Scene transform values #621
Labels
Comments
Those helpers will be definitely helpful, isn't the Transform component a better place to add it than the Entity class? Adding those to the entity will break the ECS pattern. It is not that we cannot do it, but it will open the door to other anti patterns and in the future it will be more difficult to get rid of those anti patterns |
Yes! Please read the issue :P The proposed implementation was copy pasted from elsewhere, I didn't update the signatures but the proposed API is meant to be fully implemented in the Transform component Sorry if it is not clear enough 😓 |
Ok, it makes sense |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Currently all position/rotation/scale data for an entity's Transform is relative to that entity's parent. This will lead to several problems and hardships.
For example, making a subentity follow another entity or even the player (
Camera.instance.position
) would result in an operation between global and local transforms.As of today users need to solve this by themselves using their own implementations. It would be great to ship this as part of the Transform API.
The need for this API was made clear after the SDK game jam and is currently required to avoid repeating code inside the Builder's smart items.
Proposed API:
All the methods would live inside the Transform component
public getScenePosition(): Readonly<Vector3>
public setScenePosition(vec: Vector3): void
public getSceneRotation(): Readonly<Quaternion>
public setSceneRotation(quat: Quaternion): void
public getSceneScale(): Readonly<Vector3>
public setSceneScale(vec: Vector3): void
public getSceneUp(): Readonly<Vector3>
public getSceneDown(): Readonly<Vector3>
public getSceneForward(): Readonly<Vector3>
public getSceneBackward(): Readonly<Vector3>
public getSceneLeft(): Readonly<Vector3>
public getSceneRight(): Readonly<Vector3>
Proposed implementation:
Keep in mind they are meant to be used as an extension of the Entity class and the code submitted in a PR would be slightly different (adding new methods to the Transform component)
Further improvements:
We can further improve performance if we make the renderer supply some of the data instead of looping through the entity tree in the scene's worker.
The text was updated successfully, but these errors were encountered: