Experience-Monks / orbit-controls

generic controls for orbiting a target in 3D
http://jam3.github.io/orbit-controls/
MIT License
110 stars 17 forks source link

Add UMD dist version for usage with CDN #16

Open rreusser opened 4 years ago

rreusser commented 4 years ago

What kind of change does this PR introduce? (check at least one)

Does this PR introduce a breaking change? (check one)

Did you test your solution?

I've confirmed it loads in Safari, Firefox, and Chrome. You may find a live example of inclusion in a notebook here: https://observablehq.com/d/90b90e6e86f901d3

Problem Description

I wanted to use orbit-controls in an observable notebook and used https://bundle.run. I decided to give it a try again, but I'm really rather opposed to its usage any any sort of non-private notebook for two reasons:

  1. Downtime is not unusual
  2. Caching in your personal browser prevents you from realizing when it's broken for everyone else

It was working a day or two ago, I think, but I'm now observing this this issue when trying to load orbit-controls@1.2.4 via this URL: https://bundle.run/orbit-controls@1.2.4 This means my notebooks are probably broken for anyone without a working version of these scripts cached.

Solution Description

My solution is to submit a PR adding a dist bundle. This makes the bundle loadable via unpkg.com which, in my experience, is significantly more reliable than bundling js servers. The cost, of course, is duplicated dependencies, though that's a price I'm more than willing to pay since this module gzipped is 14kb.

You may find an example here: https://raw.githack.com/rreusser/orbit-controls/add-dist/dist/orbit-controls.js

I'm not 100% certain about the best style, but UMD seems to work acceptably. I'm open to suggestions about other ways to accomplish the same.

I committed it to the git repo so that I could test this process, but my preference would be to omit dist from the git repo and move bundling to a prepublish hook instead so that dist is present only in the npm disribution.

Side Effects, Risks, Impact

None.

Additional comments:

Thanks for your time and consideration. If this change is not welcome, no hurt feelings, though I'd still love to find a way to use this in environments like observable.

One additional note is that I was unable to find contributing guidelines as requested in the PR template. This link appears broken: https://github.com/Jam3/.github/CONTRIBUTING.md

paulmelnikow commented 4 years ago

Hey, thought I'd mention that I switched from this project to https://github.com/yomotsu/camera-controls which is actively maintained 👍

rreusser commented 4 years ago

Thanks, @paulmelnikow! If I understand its usage correctly, that's not ideal for me since I'd rather not create a camera API and conform it to that of three.js (it's probably a simple API and may not be an actual problem; I haven't checked exactly what that API would look like), but I appreciate the suggestion. For now, I think the best option is to use rawgit, sit on this PR for a bit, and if it's not maintained, I'll probably just fork it to @rreusser/orbit-controls and start adding features :)

paulmelnikow commented 4 years ago

Makes sense. I was using this but needed the things it didn't have, like pan.