如何更改三个js中的墙壁颜色或图像?

时间:2016-09-06 07:53:32

标签: three.js

我用三个js的路径创建了墙。我想更改颜色选项按钮自动需要更改颜色onclick事件。

在我的颜色之下,任何人都会帮助我。

// wall 1 inside
 item_count = 1;
 var wall_x1                =   69;
 var wall_y1                =   55;
 var wall_x2                =   366;
 var wall_y2                =   52;
 var wall_z                 =   0;
 var wall_width             =   5;
 var wall_height            =   default_height;
 var wall_wall_width        =   5;

 if(!wall_wall_width) { wall_wall_width = 5; }

 var wall_wall_elevation    =   planner_default_height;

 if(!wall_wall_elevation) { wall_wall_elevation = default_height; }

 var wall_top_filltype      =   'texture';
 var wall_top_fill          =   'default_wall.jpg';
 var wall_side_filltype     =   'texture';
 var wall_side_fill         =   'wall5.jpg';

 if ( item_count    == 0  )
 {
    starting_x_value    =   wall_x1;
    starting_y_value    =   wall_y1;
 }

 path   = generate_path_byline(wall_x1,wall_y1,wall_x2,wall_y2,default_depth);
 path_type  ="wall"; 
 x=starting_x_value-wall_x1;    y=starting_y_value-wall_y1;
 // z=default_height/2;
 path_transform =   transformSVGPath(path); 
 create_surface(1,1,path_type,path_transform,starting_x_value,starting_y_value,x,y,z,default_height,wall_wall_elevation,wall_top_filltype,wall_top_fill,wall_side_filltype,wall_side_fill);

1 个答案:

答案 0 :(得分:0)

我认为没有明确的方法来定义示例代码中的材料,或至少three.js的方式:

var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );

如果您使用带有图像的纹理作为材质,您可以通过多种方式更改其颜色......一个简单的技巧可能是更改淡化场景或此对象的灯光颜色。