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

Exposing sky for Editor #5901

Merged
merged 7 commits into from Dec 19, 2023
Merged

Exposing sky for Editor #5901

merged 7 commits into from Dec 19, 2023

Conversation

kpal81xd
Copy link
Contributor

Implemenation of the engine side sky properties outlined in playcanvas/editor#1080

I confirm I have read the contributing guidelines and signed the Contributor License Agreement.

@kpal81xd kpal81xd self-assigned this Dec 18, 2023
@mvaligursky mvaligursky added the area: graphics Graphics related issue label Dec 18, 2023
src/scene/scene.js Outdated Show resolved Hide resolved
src/scene/scene.js Outdated Show resolved Hide resolved
@@ -59,6 +75,19 @@ class Sky {
this.projectedSkydomeCenterId = this.device.scope.resolve('projectedSkydomeCenter');
}


applySettings(render) {
if (render.skyPosition) {
Copy link
Contributor

Choose a reason for hiding this comment

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

scale and position should be set on the this.node instead of new properties, the same way the example does it:

this.node.setLocalScale(new pc.Vec3(data.get('data.skybox.scale') ?? [1, 1, 1]));
this.node.setLocalPosition(new pc.Vec3(data.get('data.skybox.position') ?? [0, 0, 0]));

and the added position and scale properties are not needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it too late to reconsider exposing the node property? Maybe scale, position and rotation properties would be kinda nice. Then we could just alias Scene#skyboxRotation to Sky#rotation. Having the node is only really handy if you want to do something hierarchical and that's not needed here.

Copy link
Contributor

Choose a reason for hiding this comment

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

we need both rotations though. The node positions / rotates / scales the mesh itself.
but scene.skyboxRotation rotates the texture.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why the texture can't also be rotated with a quaternion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe alias Scene#skyboxRotation to Scene#skyTextureRotation for more clarity then?

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe in a separate PR. I'd avoid doing it in this PR, this one should focus on the task that is needed.


applySettings(render) {
this.node.setLocalPosition(new Vec3(render.skyPosition ?? [0, 0, 0]));
this.node.setLocalScale(new Vec3(render.skyScale ?? [1, 1, 1]));
Copy link
Contributor

Choose a reason for hiding this comment

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

and for completeness, expose 'rotation' as well please - this is handy for box projection if the room geometry is not aligned with the axes.
maybe those 3 that we set on the node should be skyMeshPosition skyMeshRotation and skyMeshScale, to not confuse them with the existing skyboxRotation, that rotates the texture

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suggested in the other comment to do skyTextureRotation for the existing rotation prop but since you said it would change the existing API this seems more logical

Copy link
Contributor

@mvaligursky mvaligursky left a comment

Choose a reason for hiding this comment

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

I'm happy with this. @willeastcott ?

Copy link
Contributor

@willeastcott willeastcott left a comment

Choose a reason for hiding this comment

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

It's fine. However, One thing that comes to mind is:

  • Why does the engine have these applySettings functions? I feel like this should be Editor code. This is a general observation about loading scene settings though and not to be addressed in this PR.

@mvaligursky
Copy link
Contributor

  • Why does the engine have these applySettings functions? I feel like this should be Editor code. This is a general observation about loading scene settings though and not to be addressed in this PR.

I think Editor could set those directly, but the other use case is when the published project is loaded. Those settings are stored in data, and are applied to the scene. Similar to how components accept loaded data to initialize. So I'm not sure we can avoid this.

@kpal81xd kpal81xd merged commit 64c0fad into main Dec 19, 2023
7 checks passed
@kpal81xd kpal81xd deleted the expose-sky branch December 19, 2023 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants