MCPcopy
hub / github.com/donmccurdy/glTF-Transform / getElement

Method getElement

packages/core/src/properties/accessor.ts:435–450  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers 15

accessor.test.tsFile · 0.80
getMeshBoundsFunction · 0.80
concatSparseAccessorsMethod · 0.80
elementPairsFunction · 0.80
scaleAccessorFunction · 0.80
getTexCoordBoundsFunction · 0.80
getTexCoordAreaFunction · 0.80
normalsFunction · 0.80
createInstanceNodesFunction · 0.80

Calls 5

getNormalizedMethod · 0.95
getElementSizeMethod · 0.95
getComponentTypeMethod · 0.95
getArrayMethod · 0.95
decodeNormalizedIntMethod · 0.80

Tested by 4

elementPairsFunction · 0.64
scaleAccessorFunction · 0.64
getTexCoordBoundsFunction · 0.64
getTexCoordAreaFunction · 0.64