Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
234 views
in Technique[技术] by (71.8m points)

javascript - How to draw a point inside a mesh?

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/

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...