From 463408c4a0d6afeec9df859c6728d5daf99f9e11 Mon Sep 17 00:00:00 2001 From: Peter Le Bek Date: Sat, 8 Dec 2018 16:04:42 -0800 Subject: [PATCH] Fix incorrect index into bufferViews array --- tiny_gltf.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index b62eb8f..d70060b 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -3488,7 +3488,8 @@ bool TinyGLTF::LoadFromString(Model *model, std::string *err, std::string *warn, { if (primitive.indices > -1) // has indices from parsing step, must be Element Array Buffer { - model->bufferViews[primitive.indices].target = TINYGLTF_TARGET_ELEMENT_ARRAY_BUFFER; + model->bufferViews[model->accessors[primitive.indices].bufferView] + .target = TINYGLTF_TARGET_ELEMENT_ARRAY_BUFFER; // we could optionally check if acessors' bufferView type is Scalar, as it should be } }