diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfUtils.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfUtils.java index 2586a99f15..2ff42e1c52 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfUtils.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfUtils.java @@ -425,12 +425,21 @@ private static void populateByteArray(byte[] array, LittleEndien stream, int cou int stride = Math.max(dataLength, byteStride); int end = count * stride + byteOffset; stream.skipBytes(byteOffset); + + if (dataLength == stride) { + byte[] buffer = new byte[end - index]; + stream.read(buffer, 0, buffer.length); + System.arraycopy(buffer, 0, array, 0, buffer.length); + + return; + } + int arrayIndex = 0; + byte[] buffer = new byte[numComponents]; while (index < end) { - for (int i = 0; i < numComponents; i++) { - array[arrayIndex] = stream.readByte(); - arrayIndex++; - } + stream.read(buffer, 0, numComponents); + System.arraycopy(buffer, 0, array, arrayIndex, numComponents); + arrayIndex += numComponents; if (dataLength < stride) { stream.skipBytes(stride - dataLength); }