Three.js - 更新纹理

时间:2015-11-24 23:39:48

标签: javascript json three.js textures

如何获取导出的json文件所具有的数据?例如,我有这个材料,我想改变mapDiffuse值,因为纹理。我怎么能在javascript函数中做到这一点?

"materials": [{
    "transparent": false,
    "DbgIndex": 0,
    "mapDiffuseRepeat": [1,1],
    "mapDiffuseAnisotropy": 1,
    "specularCoef": 50,
    "colorEmissive": [0,0,0],
    "colorDiffuse": [0.64,0.64,0.64],
    "wireframe": false,
    "visible": true,
    "blending": "NormalBlending",
    "DbgColor": 15658734,
    "mapDiffuse": "w.jpg",
    "DbgName": "Material.005",
    "opacity": 1,
    "depthWrite": true,
    "mapDiffuseWrap": ["RepeatWrapping","RepeatWrapping"],
    "depthTest": true,
    "shading": "phong",
    "colorSpecular": [0.5,0.5,0.5],
    "colorAmbient": [0.64,0.64,0.64]}, another 4 same materials (different names)

我不会退出this reference所以任何帮助都会受到赞赏。 谢谢!

1 个答案:

答案 0 :(得分:1)

我找到了..

mesh.material.materials [4] .map = THREE.ImageUtils.loadTexture(“image.jpg”); mesh.material.materials [4] .needsUpdate = true;