83d8035dc2
* root + server * frontend * frontend-2 * dui3 * dui3 * tailwind theme * ui-components * preview service * viewer * viewer-sandbox * fileimport-service * webhook service * objectloader * shared * ui-components-nuxt * WIP full config * WIP full linter * eslint projectwide util * minor fix * removing redundant ci * clean up test errors * fixed prettier formatting * CI improvements * TSC lint fix * 'buildBatch' needs to be async since some batch types (like Text) require it. Removed a disabled liniting rule from ObjLoader * removed unnecessary void --------- Co-authored-by: AlexandruPopovici <alexandrupopoviciioan@gmail.com>
16 lines
427 B
TypeScript
16 lines
427 B
TypeScript
import { round } from 'lodash-es'
|
|
import type { Vector3 } from 'three'
|
|
|
|
export function areVectorsLooselyEqual(v1: Vector3, v2: Vector3, precision = 6) {
|
|
const coords1 = v1.toArray()
|
|
const coords2 = v2.toArray()
|
|
|
|
for (let i = 0; i < coords1.length; i++) {
|
|
const rounded1 = round(coords1[i], precision)
|
|
const rounded2 = round(coords2[i], precision)
|
|
if (rounded1 !== rounded2) return false
|
|
}
|
|
|
|
return true
|
|
}
|