Skip to content

refact: replace decodeText with TextDecoder #264

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions src/bin/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class GLTFLoader extends THREE.Loader {
if (typeof data === 'string') {
content = data
} else {
var magic = THREE.LoaderUtils.decodeText(new Uint8Array(data, 0, 4))
var magic = new TextDecoder().decode(new Uint8Array(data, 0, 4))

if (magic === BINARY_EXTENSION_HEADER_MAGIC) {
try {
Expand All @@ -139,7 +139,7 @@ export class GLTFLoader extends THREE.Loader {

content = extensions[EXTENSIONS.KHR_BINARY_GLTF].content
} else {
content = THREE.LoaderUtils.decodeText(new Uint8Array(data))
content = new TextDecoder().decode(new Uint8Array(data))
}
}

Expand Down Expand Up @@ -630,7 +630,7 @@ function GLTFBinaryExtension(data) {
var headerView = new DataView(data, 0, BINARY_EXTENSION_HEADER_LENGTH)

this.header = {
magic: THREE.LoaderUtils.decodeText(new Uint8Array(data.slice(0, 4))),
magic: new TextDecoder().decode(new Uint8Array(data.slice(0, 4))),
version: headerView.getUint32(4, true),
length: headerView.getUint32(8, true),
}
Expand All @@ -653,7 +653,7 @@ function GLTFBinaryExtension(data) {

if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON) {
var contentArray = new Uint8Array(data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength)
this.content = THREE.LoaderUtils.decodeText(contentArray)
this.content = new TextDecoder().decode(contentArray)
} else if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN) {
var byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex
this.body = data.slice(byteOffset, byteOffset + chunkLength)
Expand Down