[SOLVED] How to compare two vector3s

I’m trying to compare two vector3’s. I know that at some point the vectors are equal as they each print to the console as:

this.vertex_local_positions[k] = [-0.5, -0.5, 0.5]
this.tmpLocalPos = [-0.5, -0.5, 0.5]

…but they never return equal or run the code when compared. For example…

if(this.vertex_local_positions[k]==this.tmpLocalPos)
{
//never runs
}

Any idea what’s going on and how to resolve? I tried using if(this.vertex_local_positions[k].equals(this.tmpLocalPos))
but that just threw the error: Cannot read properties of undefined (reading ‘equals’)

SOLVED:
if(this.vertex_local_positions[k].equals(this.tmpLocalPos))

is the correct solution!! I was doing something else wrong. My bad.

1 Like