Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to set Z offset when creating instances from external layout #5704

Merged
merged 3 commits into from
Oct 10, 2023

Conversation

AlexandreSi
Copy link
Collaborator

@AlexandreSi AlexandreSi commented Oct 2, 2023

Fixes #5694

@AlexandreSi AlexandreSi requested a review from 4ian as a code owner October 2, 2023 13:33
@@ -281,7 +281,8 @@ namespace gdjs {
scene: gdjs.RuntimeInstanceContainer,
externalLayout: string,
xPos: float,
yPos: float
yPos: float,
zPos: float,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like I should either set 0 as default value here or deprecate the method to have createObjectsFromExternalLayout2 because this method is exposed to JS events through gdjs.evtTools.runtimeScene.createObjectsFromExternalLayout.
Some JS events might use it and it would create bugs.

Copy link
Owner

@4ian 4ian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative to createObjectsFrom2:

  • At least, make the existing createObjectsFrom to call the new version (passing z = 0).
  • Alternatively, do some "dynamic magic" by checking the value of arguments.length. If it's <= 4, treat zPos as trackByPersistentUuid with some ts-ignore.

So officially we support only the new version, but we have compatibility code to make existing calls still work

@AlexandreSi
Copy link
Collaborator Author

First time I use arguments! This is practical in that overloading case. I tried to see if I could declare the overloading with Typescript but I couldn't find a way.
After a bit of thinking, I think it's better not overloading the signature.

Copy link
Owner

@4ian 4ian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@AlexandreSi AlexandreSi merged commit 9298026 into master Oct 10, 2023
7 checks passed
@AlexandreSi AlexandreSi deleted the create-external-layout-at-z branch October 10, 2023 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Objects from external layout should have offset for Z point as well instead of only X and Y that it has now.
2 participants