2
我已經創建了建築物的草圖模型並將其導出到.dae
和紋理文件。我想使用three.js在瀏覽器中顯示它,但出現錯誤THREE.MultiMaterial has been removed. Use an Array instead
。我怎麼解決這個問題?THREE.MultiMaterial已被刪除。使用數組代替
我已經創建了建築物的草圖模型並將其導出到.dae
和紋理文件。我想使用three.js在瀏覽器中顯示它,但出現錯誤THREE.MultiMaterial has been removed. Use an Array instead
。我怎麼解決這個問題?THREE.MultiMaterial已被刪除。使用數組代替
在three.js的新版本中,您必須使用簡單的數組和(項目)materilas而不是multimaterials。下面是例子:
var geometry = new THREE.BoxBufferGeometry(1, 1, 1);
var materials = [
new THREE.MeshDepthMaterial(),
new THREE.MeshNormalMaterial(),
new THREE.MeshBasicMaterial({ wireframe: true }),
new THREE.MeshLambertMaterial({ color: 0xff0000 }),
new THREE.MeshPhongMaterial({ color: 0x0000ff }),
new THREE.MeshStandardMaterial({ color: 0x00ff00 }),
];
var mesh = new THREE.Mesh(geometry, materials);
同樣重要!訪問看起來像:
if (Array.isArray(object.material)) {
for (var m = 0; m < object.material.length; m ++) {
object.material[ m ].color.set(0xffffff);
}
} else {
object.material.color.set(0xffffff);
}