Three.js - ply files - why colorless?

岁酱吖の 提交于 2019-12-10 15:19:12

问题


I am using Three.js's example in the directory:

three.js/examples/webgl_loader_ply.html

And I just swapped their .ply file with mine (made with Blender).

In Blender, I went Vertex Paint > and painted vertices. Before exporting to .ply, I made sure that all checkboxes where checked. And scale is 100.

But the .ply model renders as blue in the three.js's example. (just like the default example). And apparently it is blue because of this code in the example html file:

var geometry = event.content;
var material = new THREE.MeshPhongMaterial( { color: 0x0055ff, specular: 0x111111, shininess: 200 } );
var mesh = new THREE.Mesh( geometry, material );

I was 100% sure that ply files have color values saves as well. But, what am I supposed to do now if that code makes my model blue? Or did I do something wrong in Blender?

I am totally not familiar with Three.js and webGL because I started to learn it just yesterday. Can anyone enlighten me on what is going on and what to do next?


回答1:


i was missing this property vertexColors: THREE.VertexColors. All was fine with Blender and the code apart from the property. It works as expected now.

Here is how the line of code should look like:

var material = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shininess: 200, vertexColors: THREE.VertexColors} );


来源:https://stackoverflow.com/questions/31425761/three-js-ply-files-why-colorless

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!