added support for embedded textures defined with buffer views.

pull/1811/head
Marco Di Benedetto 2018-02-24 17:44:40 +01:00
parent b0ac2d9daf
commit 4b7cd97fea
1 changed files with 13 additions and 1 deletions

View File

@ -669,7 +669,7 @@ inline Image::Image()
}
inline void Image::Read(Value& obj, Asset& /*r*/)
inline void Image::Read(Value& obj, Asset& r)
{
if (!mDataLength) {
if (Value* uri = FindString(obj, "uri")) {
@ -686,6 +686,18 @@ inline void Image::Read(Value& obj, Asset& /*r*/)
this->uri = uristr;
}
}
else if (Value* bufferViewVal = FindUInt(obj, "bufferView")) {
this->bufferView = r.bufferViews.Retrieve(bufferViewVal->GetUint());
Ref<Buffer> buffer = this->bufferView->buffer;
this->mDataLength = this->bufferView->byteLength;
this->mData = new uint8_t [this->mDataLength];
memcpy(this->mData, buffer->GetPointer(), this->mDataLength);
if (Value* mtype = FindString(obj, "mimeType")) {
this->mimeType = mtype->GetString();
}
}
}
}