arcade icon indicating copy to clipboard operation
arcade copied to clipboard

Expose Camera2D in arcade's top level namespace

Open pushfoo opened this issue 1 year ago • 9 comments

Changes

TL;DR: Enable arcade.Camera2D and from arcade import Camera2D

  • Import Camera2D + supporting classes to arcade/__init__.py
  • Add Camera2D + supporting classes to arcade.__all__

Why

  1. Good DX
  2. Make subsequent examples + porting guide PRs easier to read

pushfoo avatar Apr 08 '24 05:04 pushfoo

Good idea. We have other "core" objects exposed (Text, Window, View, Sprite) and this makes sense to have. You want more complex cameras, dig into arcade.camera.

DigiDuncan avatar Apr 08 '24 07:04 DigiDuncan

It does make sense historically, but I'm a little bit conflicted here. Should we not try to slim down the arcade module when possible? It already contains so much.

einarf avatar Apr 10 '24 22:04 einarf

It does make sense historically, but I'm a little bit conflicted here. Should we not try to slim down the arcade module when possible? It already contains so much.

I would say our most important objects (and most accessible ones) should be top-level. Camera2D, Text, Window, View, Sprite, Sound, etc. The more advanced or specialized versions (PerspectiveProjector, or BasicSprite, etc.) can be accessed in their sub-modules.

DigiDuncan avatar Apr 11 '24 03:04 DigiDuncan

@einarf TL;DR: We should fix Camera2D.__init__'s arguments + improve underlying camera behavior.

Should we not try to slim down the arcade module when possible?

The current custom viewport options for Camera2D are somewhat ugly. We have a choice of telling beginners to:

  • use Camera2D.from_raw_data to create cameras
  • set camera2d_instance.projection_viewport after creation
  • use the camera.*Data classes with Camera2D.__init__

I think we should flip Camera2D's __init__ and from_raw_data arguments:

  • It eliminates requiring a top-level exposure for the arcade.camera.*Data classes
  • Beginners will be confused by the extra classes anyway
  • Sharing CameraData between cameras is an advanced technique

pushfoo avatar Apr 15 '24 15:04 pushfoo

The recent commits pushed:

  1. Rebase onto development to get #2062's fixes
  2. Remove the *Data classes from arcade.__all__

pushfoo avatar Apr 16 '24 00:04 pushfoo

Might also be a good idea to update imports in examples here?

einarf avatar Apr 16 '24 02:04 einarf

Might also be a good idea to update imports in examples here?

Yep. I think this might wait till after the following:

  • #2065
  • #2061
  • The camera __init__ and from_raw_data swap

From what I remember of trying to test something like this locally, it also caused some havoc when trying to build doc in certain cases. That may have been due to trying to squeeze cameras into the current doc build system clumsily and in a rush. I'll revisit this PR in the coming days after the above.

pushfoo avatar Apr 18 '24 12:04 pushfoo

Maybe we should just merge this quick to at least get the Camera2D doc generated? It's better than having no docs on it right now.

einarf avatar Apr 23 '24 21:04 einarf

TL;DR: It might actually be very broken despite tests seeming to pass.

I haven't it recently and so I don't remember the details, but there was at some point a wall of red in build output related to this. From what I remember:

  • They weren't the PDF build
  • They were related to class detection
  • I think replacing the quick index tooling as you suggested would've solved them

I was going to wait until the following are in place:

  • [ ] #2057 (may be merged already from earlier in today, need to double check)
  • [ ] Fix up vector / rotation handling of Camera2D (currently breaks other properites)
  • [ ] Vec fixes for 3.0-mandatory #2021
  • [ ] Rectangle abstraction to make camera code debuggable / fixable (@DigiDuncan and @DragonMoffon have been working on this)

pushfoo avatar Apr 23 '24 22:04 pushfoo

This is redundant and additional work needs to be done before we're able to get the doc generating. That's WIP, so closing this.

pushfoo avatar Jun 03 '24 22:06 pushfoo