Object.assign( THREE.Vector3.prototype, { xyzFixedEq: function (vector, digit) { if (this.x.toFixed(digit) - 0 == vector.x.toFixed(digit) - 0 && this.y.toFixed(digit) - 0 == vector.y.toFixed(digit) - 0 && this.z.toFixed(digit) - 0 == vector.z.toFixed(digit) - 0) { return true; } return false; }}); function tryAddDistinctVector3(array, item) { if (!vectorContains(array, item)) { array.push(item); return true; } return false; function vectorContains(array, item) { let index = array.findIndex(vector => vector.xyzFixedEq(item, 4)); if (index > -1) { return true; } return false; } }