yomotsu / camera-controls

A camera control for three.js, similar to THREE.OrbitControls yet supports smooth transitions and more features.
https://yomotsu.github.io/camera-controls/
MIT License
1.89k stars 242 forks source link

using "isSphere" requires three.js version compatibility bump to r160 #515

Open gouldingken opened 3 weeks ago

gouldingken commented 3 weeks ago

Describe the bug

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

A recent update using "isSphere" instead of instanceof to check the type of a sphere object is causing runtime errors with older three.js (because isSphere is a recent addition: https://github.com/mrdoob/three.js/pull/27395)

Using this property, CameraControls should now specify three.js >= r160 (https://github.com/mrdoob/three.js/releases/tag/r160)

This seems like a minor reason to require a big version dependency bump, so maybe an alternative would be to use a hybrid solution (instanceof if isSphere is missing?)

https://github.com/yomotsu/camera-controls/issues/510

To Reproduce

Steps to reproduce the behavior: Use fitToSphere function with three.js before r160

Code

No response

Live example

No response

Expected behavior

no errors, function runs as normal with older three.js OR version requirement bump in package.json

Screenshots or Video

No response

Device

No response

OS

No response

Browser

No response

gouldingken commented 3 weeks ago

One point of clarification: it's the peerDependency requirement (devDependency is already newer)

Dev: "three": "^0.161.0",

"peerDependencies": { "three": ">=0.126.1" <== this needs to be >= 0.160.0 },

yomotsu commented 2 weeks ago

Thank you for pointing that out. Your corrections are accurate.

~I will update the peerDeps version to r160, or should we support older version...?~

yomotsu commented 2 weeks ago

The solution is to check const isObject3D = 'isObject3D' in sphereOrMesh rather than isSphere. fixed with #517