How to draw a point inside a mesh?

十年热恋 提交于 2019-12-13 08:46:22

问题


I have multiple meshes, and want to add a point in a random part contained within hexagon[0]. how can I do it?

var Hexagon=new Array();
Hexagon[0] = new THREE.Mesh( HexagonExtrude[0],material[0] );
Hexagon[1] = new THREE.Mesh( HexagonExtrude[1],material[1]  );
Hexagon[2] = new THREE.Mesh( HexagonExtrude[2],material[2]  );
Hexagon[3] = new THREE.Mesh( HexagonExtrude[3],material[3]  );
Hexagon[4] = new THREE.Mesh( HexagonExtrude[4],material[4]  );
Hexagon[5] = new THREE.Mesh( HexagonExtrude[5],material[5]  );
Hexagon[6] = new THREE.Mesh( HexagonExtrude[6],material[6]  );

http://jsfiddle.net/fznore2c/


回答1:


If the mesh is of unknown shape (is it even closed?) then you either have to do something fancy like use signed distance fields, voxelization, or pick a point based on the bounding box as @gaitat has suggested. The reason samples use boxes and spheres is because those shapes have very well-behaved, simple-arithmetic properties. If you want to do fancier things like pick random points inside a random shape, well... that's much tougher!

Another approach you might consider is having invisible particle emitter zones that are part of your object. Your object might be shaped, say, like a monster in a game, but the particles inside it only come from a few spherical regions within the complex, deforming mesh. Not directly from the mesh itself.



来源:https://stackoverflow.com/questions/32407179/how-to-draw-a-point-inside-a-mesh

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