簡體   English   中英

如何從 STL 格式中讀取模型的三角形和頂點?

[英]How to read triangles and vertices of the model from the STL format?

我需要獲取有關 STL 格式模型的頂點和三角形的信息,請告訴我如何在 ThreeJS 中提取這些數據

您可以使用STLLoader類來完成此任務。 因此,您定義了一個加載器實例並使用它從特定路徑加載 STL 資產。 onLoad()回調中,您將獲得一個BufferGeometry實例,該實例表示來自 STL 文件的幾何數據。

const loader = new STLLoader();
loader.load( './models/stl/ascii/slotted_disk.stl', function ( geometry ) {

    const material = new THREE.MeshBasicMaterial();
    const mesh = new THREE.Mesh( geometry, material );

    scene.add( mesh );

} );

請記住,幾何圖形是非索引的。 因此,面/三角形由position緩沖區屬性中的三個連續頂點定義。

完整示例: https ://threejs.org/examples/webgl_loader_stl

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM