* Returns the vector or matrix element value at the given index. For * Accessor.getNormalized normalized integer accessors, values are * decoded and returned in floating-point form. * * Example: * * ```javascript * import { add } from 'gl-matrix/add'; * * const element = []
(index: number, target: T)
| 433 | * ``` |
| 434 | */ |
| 435 | public getElement<T extends number[]>(index: number, target: T): T { |
| 436 | const normalized = this.getNormalized(); |
| 437 | const elementSize = this.getElementSize(); |
| 438 | const componentType = this.getComponentType(); |
| 439 | const array = this.getArray()!; |
| 440 | |
| 441 | for (let i = 0; i < elementSize; i++) { |
| 442 | if (normalized) { |
| 443 | target[i] = MathUtils.decodeNormalizedInt(array[index * elementSize + i], componentType); |
| 444 | } else { |
| 445 | target[i] = array[index * elementSize + i]; |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | return target; |
| 450 | } |
| 451 | |
| 452 | /** |
| 453 | * Assigns the vector or matrix element value at the given index. For |