engine icon indicating copy to clipboard operation
engine copied to clipboard

ESM Orbit Camera

Open marklundin opened this issue 1 year ago • 13 comments

Swaps the Orbit Camera out for the ESM version. If this get's approved I can generate the equivalent for all the other scripts.

There's a bigger discussion on discovery and how we can provide these to the user, but for now, this is a simple swap

  • updating to esm attributes declarations
  • var -> let/const
  • attr:* events to getters/setters
  • callbacks to arrow functions where sensible

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

marklundin avatar Oct 07 '24 10:10 marklundin

It'd be great to update one of the examples to use this, maybe cascaded shadow maps? It'd be great to see how it gets used.

mvaligursky avatar Oct 07 '24 10:10 mvaligursky

Not sure about deleting orbit-camera.js - lots of engine examples use it?

mvaligursky avatar Oct 07 '24 11:10 mvaligursky

It'd be great to update one of the examples to use this, maybe cascaded shadow maps? It'd be great to see how it gets used.

Yeah it should just be a case of doing

import { OrbrtCamera }  from '/scripts/camera/orbit-camera.mjs'
entity.add(OrbitCamera)

unfortunately it's not easy to import things in the examples browser 😩

Not sure about deleting orbit-camera.js - lots of engine examples use it?

yeah I guess, we'd need to update everything in sync

marklundin avatar Oct 07 '24 12:10 marklundin

I'm importing the script in the examples this way (from a different folder, but that's a good start for now) https://github.com/playcanvas/engine/pull/7011

mvaligursky avatar Oct 07 '24 12:10 mvaligursky

Yeah ideally we only have scripts in one location. We don't really want to have a copy in the examples/misc

marklundin avatar Oct 07 '24 12:10 marklundin

Agreed, for me that is THE location. But we need to surface those scripts to the Editor and that will change then.

mvaligursky avatar Oct 07 '24 12:10 mvaligursky

These new scripts seem to not have name on them, will they still work when using scene loaders and referenced scripts by names (not class references)?

Please don't force people to switch by removing currently used scripts.

Maksims avatar Oct 07 '24 13:10 Maksims

Please don't force people to switch by removing currently used scripts.

We do not want to maintain each script in two forms. We're planning to convert all (maybe apart from post-effects) scripts stored in the engine to the new format. People are welcome to use old format if they already have them in their project though. Those are 1:1 replacement though, so it should be easy for people to switch to new format? Or do you see some complications with this?

mvaligursky avatar Oct 07 '24 13:10 mvaligursky

Yep creating using a name will work as long as the script is registered.

marklundin avatar Oct 07 '24 14:10 marklundin

Or do you see some complications with this?

I don't think Editor has complete feature parity and similar level of UX yet to force such a switch. Previously any new systems would be provided as a more convenient option until devs decided to switch, without forcing by force-deprecating or removing features/code.

Maksims avatar Oct 07 '24 21:10 Maksims

Curious to know what you think is missing?

At the moment the UX is to manually find a script and copy/paste it into the project. This could be much better, but for now it works and is identical workflow for both. An ESM script can be added to a project containing Classic scripts and vice-versa and it won't affect your existing scripts.

marklundin avatar Oct 08 '24 07:10 marklundin

At the moment the UX is to manually find a script and copy/paste it into the project.

I personally prefer to import the orbit script from the store, so I don't need to search/copy/paste it. Can it be added there?

LeXXik avatar Oct 08 '24 08:10 LeXXik

At the moment the UX is to manually find a script and copy/paste it into the project.

I personally prefer to import the orbit script from the store, so I don't need to search/copy/paste it. Can it be added there?

We're working on a way to surface engine provided scripts to the Editor, and the discussion is ongoing here. Stay tuned. Store is one way, but we're hoping for simply importing them from the "playcanvas" or similar.

mvaligursky avatar Oct 08 '24 08:10 mvaligursky

This version of the orbit camera will be deprecated in favor of extending of the base camera defined in GH-6642 with the multi-camera

kpal81xd avatar Oct 29 '24 10:10 kpal81xd

@marklundin This can be closed now since Orbit camera in included in GH-7111

kpal81xd avatar Nov 19 '24 12:11 kpal81xd

YES!! 🙏

marklundin avatar Nov 19 '24 13:11 marklundin