-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.equals
in class Spherical
#28191
Comments
Can you please explain your use case? |
Yeah you are right. Those classes shouldn't have |
Do you mind explaining this in more detail? Why can we compare euclidian coordinates but not spherical ones? The following does work as expected: const v1 = new THREE.Vector3( 1, 0, 0 );
const v2 = new THREE.Vector3( 1, 0, 0 );
console.log( v1.equals( v2 ) ); // true
const s1 = new THREE.Spherical().setFromVector3( v1 );
const s2 = new THREE.Spherical().setFromVector3( v2 );
console.log( equals( s1, s2 ) ); // true
function equals( s1, s2 ) {
return ( ( s1.radius === s2.radius ) && ( s1.phi === s2.phi ) && ( s1.theta === s2.theta ) );
} |
... because const s1 = new THREE.Spherical( 1, 0, 0 );
const s2 = new THREE.Spherical( 1, 0, 2 * Math.PI ); Likewise, // As a side note, I am not in favor of methods that compare floating point values using equality. I would have preferred
|
Instead of adding |
@chenxinhang12345 Do this: const v1 = new THREE.Vector3().setFromSpherical( s1 ); |
Description
We have
.equals
inVector
classes for all dimensions. Why cant we have.equals
inSpherical
?Solution
Add comparison method for class
Spherical
just like otherVectorN
classes, should be pretty simple I guess?Alternatives
Do nothing but we would definitely want to use something like
JSON.stringify()
or some other workaround to compare twoSpherical
?Additional context
No response
The text was updated successfully, but these errors were encountered: