0

我最近开始使用three.js,并且我正在使用terrain.js演示作为我正在从事的设计项目的开始。

我想添加一个混合着色器“线框/兰伯特”,默认情况下仅带有线着色器。

这是演示中的代码,使用基本材料:

 var matrix = new THREE.MeshBasicMaterial({
            color:0x10ce58, 
            wireframe:true
        });

        var geometry = new THREE.PlaneGeometry(width, height, modelWidth, modelHeight); 
        mesh = new THREE.Mesh(geometry, matrix); 
        mesh.doubleSided = false;

我尝试过这样的事情,但我只得到“兰伯特”渲染,而不是兰伯特和电线的组合,有什么想法吗?

    var darkMaterial = new THREE.MeshLambertMaterial( { color: 0xffffff , shading: THREE.FlatShading, overdraw: true} );
    var wireframeMaterial = new THREE.MeshBasicMaterial( { color: 0x10ce58, wireframe: true, transparent: true } ); 
    var multiMaterial = [ darkMaterial, wireframeMaterial ]; 


        var geometry = new THREE.PlaneGeometry(width, height, modelWidth, modelHeight); 
        mesh = new THREE.Mesh(geometry, multiMaterial); 
        mesh.doubleSided = false;

感谢您的时间提前,

问候

-曼努埃尔

4

1 回答 1

1

这是我在材料的非工作示例中使用的代码(http://jsfiddle.net/xnqUb/3/

var geometry = new THREE.PlaneGeometry(width, height, model.length - 1, model.length - 1, materials);
       materials = [
                     new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, overdraw: true } ),
                     new THREE.MeshLambertMaterial({ color: 0x10ce58, wireframe: true,})
                ];

  var mesh = new THREE.Mesh(geometry); 

  object = THREE.SceneUtils.createMultiMaterialObject(geometry, materials);
于 2013-03-27T23:02:07.943 回答