yomotsu / camera-controls

A camera control for three.js, similar to THREE.OrbitControls yet supports smooth transitions and more features.

Home Page:https://yomotsu.github.io/camera-controls/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use .isSphere instead of "instanceof Sphere"

bhouston opened this issue · comments

Describe the bug

Using instanceof can be quite problematic:

https://github.com/yomotsu/camera-controls/blob/dev/src/CameraControls.ts#L1987

If you ever have more than one Three.js included or based on how the bundler works, instanceof may not work.

Instead I recommend using .isSphere, which is provided here in the Three.js Sphere API:

https://github.com/mrdoob/three.js/blob/dev/src/math/Sphere.js#L12

To Reproduce

If you ever have more than one Three.js included or based on how the bundler works, instanceof may not work.

Code

I would recommend that we just change it to:


const isSphere = 'isSphere' in sphereOrMesh;


### Live example

_No response_

### Expected behavior

CameraControls should work whether or not instanceof works on Sphere correctly.

### Screenshots or Video

_No response_

### Device

_No response_

### OS

_No response_

### Browser

_No response_

Whoa, you are one of the contributors to three.js!
It's an honor to receive your comment.

You are absolutely right.
I've fixed it in #511. Thank you for pointing that out.

thank you!