简体   繁体   English

Three.js - 更新纹理

[英]Three.js - Update texture

How can i get the data that the exported json file has?如何获取导出的 json 文件中的数据? For example i have this material and I want to change the mapDiffuse value, as so the texture.例如,我有这种材质,我想更改 mapDiffuse 值,纹理也是如此。 How can i do this in a javascript function?我怎样才能在 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)

I don't quit get this reference so any help would be appreciated.我不会放弃获取此参考资料,因此将不胜感激。 Thanks!谢谢!

I found it..我找到了..

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM