Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds buffer normalization check #2483

Merged
1 commit merged into from
Jun 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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