Skip to content

Commit

Permalink
adds buffer normalization check (#2483)
Browse files Browse the repository at this point in the history
  • Loading branch information
SrirachaSource authored Jun 17, 2021
1 parent 7dae842 commit 53460e6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/model-viewer/src/three-components/ModelUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ import {BufferAttribute, InterleavedBufferAttribute, Object3D, Vector3} from 'th
*/
export const getNormalizedComponentScale =
(buffer: BufferAttribute|InterleavedBufferAttribute) => {
const array: ArrayLike<number> = buffer.array;
if (!buffer.normalized) {
return 1;
}

const array: ArrayLike<number> = buffer.array;
if (array instanceof Int8Array) {
return 1 / 127;
} else if (array instanceof Uint8Array) {
Expand All @@ -36,7 +39,6 @@ export const getNormalizedComponentScale =
} else if (array instanceof Uint16Array) {
return 1 / 65535;
}

return 1;
};
/**
Expand Down

0 comments on commit 53460e6

Please sign in to comment.