Skip to content

Loading problem in glTF loader #168

@liuxi150

Description

@liuxi150

Incorrect Callback Input Parameter in glTFLoader.getBufferViewData Function

In the glTFLoader.prototype._getBufferViewData function, when bufferViewData is not found (i.e., it is null or undefined) and the bufferData has already been loaded, the callback function incorrectly receives the bufferViewData. This leads to an erroneous result.

I believe the callback function should retrieve the correct bufferViewData from this._bufferViews[bufferViewID].

Here’s the relevant section of the code:

glTFLoader.prototype._getBufferViewData = function(json, bufferViewID, callback) {
var bufferViewData = this._bufferViews[bufferViewID];
if (!bufferViewData) {
var bufferView = json.bufferViews[bufferViewID];
var bufferData = this._buffers[bufferView.buffer];
if (bufferData) {
this._bufferViews[bufferViewID] = bufferData.slice(bufferView.byteOffset, bufferView.byteOffset + bufferView.byteLength);
// This callback should be updated to use the newly created this._bufferViews[bufferViewID]
callback(this._bufferViews[bufferViewID]);
}
}
};
Source:

WebGL2Samples - gltf-loader.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions