const addTextF = (srcText, sizef, heightn, num,objMain) => { const loader = new FontLoader(manager); loader.load('./mapData/FZXiYuan-M01S_Regular.json', (font) => { let geometryText = [] let mesh = { obj: [], gropzhou:[] } const color = 0xffffff; const matLite = new THREE.MeshStandardMaterial({ color: color, emissive: color, emissiveIntensity: 15, transparent: true, opacity: 1, side: THREE.DoubleSide }); geometryText[num] = new TextGeometry(srcText, { font: font, size: sizef, height: heightn, curveSegments: 12, bevelEnabled: false, bevelThickness: 10, bevelSize: 16, bevelOffset: 0, bevelSegments: 5 }); mesh.obj[num] = new THREE.Mesh(geometryText[num], matLite) mesh.obj[num].name = '分支文字' mesh.obj[num].material.name = '分支文字材质' const box = new THREE.BoxHelper(mesh.obj[num], 0xffff00); let TextLength = (box.geometry.attributes.position.array[9] - box.geometry.attributes.position.array[6]) / 2//通过边界框计算出了生成数据长度 mesh.obj[num].position.x -= TextLength mesh.obj[num].position.z=0.4 mesh.obj[num].rotation.x=-90/180 *Math.PI mesh.gropzhou[num]=new THREE.Group() const formatter = new Intl.NumberFormat('en-US'); mesh.gropzhou[num].name='文字轴心'+formatter.format(num); mesh.gropzhou[num].add( mesh.obj[num]) objMain.add( mesh.gropzhou[num] ) } ) }如何把mesh.obj[num]导出
时间: 2023-06-18 14:05:48 浏览: 138
你可以使用 `THREE.OBJExporter` 将 `mesh.obj[num]` 导出为 OBJ 格式的文件。以下是一个示例代码:
```javascript
const exporter = new THREE.OBJExporter();
const result = exporter.parse(mesh.obj[num]);
console.log(result); // 输出导出的 OBJ 文件内容
```
你也可以将导出的内容保存为文件,可以使用 `FileSaver.js` 库实现。示例代码如下:
```javascript
const exporter = new THREE.OBJExporter();
const result = exporter.parse(mesh.obj[num]);
const blob = new Blob([result], { type: 'text/plain;charset=utf-8' });
saveAs(blob, 'mesh.obj'); // 保存为文件
```
阅读全文