Iraklis Bekiaris
Iraklis Bekiaris

Reputation: 1221

Three.js - Update texture

How can i get the data that the exported json file has? For example i have this material and I want to change the mapDiffuse value, as so the texture. How can i do this in a javascript function?

"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!

Upvotes: 2

Views: 333

Answers (1)

Iraklis Bekiaris
Iraklis Bekiaris

Reputation: 1221

I found it..

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

Upvotes: 1

Related Questions