如何在Three.js中为金戒指添加反射率?

时间:2015-04-20 11:02:03

标签: three.js blender

我有一个从搅拌机导出的金戒指网格的stl文件。当我将它导入三个JS并添加图像纹理以获得金色金属效果时,纹理没有得到正确应用。

有什么建议吗?

这是代码,

loader.load( objaddress, stladdress, function ( object ) {

    object.traverse( function ( child ) {

            if ( child instanceof THREE.Mesh ) {                               
                    material = new THREE.MeshPhongMaterial({map: new THREE.ImageUtils.loadTexture("Gold.jpg")});
                                child.material = material;

                      }

                  } );

这是我用过的jpg文件网址: http://cdn.designbeep.com/wp-content/uploads/2012/10/7.gold-textures.jpg

1 个答案:

答案 0 :(得分:0)

从外部文件加载几何体后,使用THREE js ShaderMaterial为加载的几何体创建材质。在ShaderMaterial内部指定图像纹理以及平滑度,噪点,包裹以获得更好的外观和感觉。

供参考:http://threejs.org/docs/#Reference/Materials/ShaderMaterial

以下是为几何图形创建着色器材质的代码,

run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
相关问题