Webgl json对象在渲染时显示奇怪的纹理

时间:2014-03-06 15:06:33

标签: json textures webgl

我用紫外线坐标在搅拌机中模拟了一块冰壶石。在混合器中它看起来像这样,使用3D视图和UV /图像编辑器:

http://imgur.com/2q8YfvI&B26eaHG&V3NaMNQ#2

然后我将其导出为waveFront(.obj)格式,并使用semisignal.com的c ++脚本将其转换为json格式

当将json对象加载到我的webGL项目时,它会显示一个毁坏的纹理,我想知道这是否是常见问题,有人可以指出问题所在(在blender /转换为json /或webGL代码? ),或者也许这是不可能的?

http://imgur.com/2q8YfvI&B26eaHG&V3NaMNQ#0

这是我正在使用的loadtexture函数,如果它是相关的:

function handleLoadedTexture(texture) {
    gl.bindTexture(gl.TEXTURE_2D, texture);
    gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.image);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
    gl.bindTexture(gl.TEXTURE_2D, null);
}

var stone_texture;

function initTextures() {
    neheTexture = gl.createTexture();
    neheTexture.image = new Image();
    neheTexture.image.onload = function () {
        handleLoadedTexture(stone_texture)
    }

    neheTexture.image.src = "stone_texture.png";
}

0 个答案:

没有答案
相关问题