在处理SVF格式时出现错误,解决方法是对模型进行3D格式转换,例如转换为OBJ格式,然后再使用Forge API将其转换为SVF格式。参考代码如下:
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
const { DerivativeApi } = require('forge-apis');
const CLIENT_ID = 'your_client_id';
const CLIENT_SECRET = 'your_client_secret';
const BUCKET_KEY = 'your_bucket_key';
const OBJECT_NAME = 'your_object_name';
const FILE_URN = 'your_file_urn';
const apiInstance = new DerivativeApi();
apiInstance.authManager.authenticate();
const job = {
input: {
urn: FILE_URN,
},
output: {
formats: [
{
type: 'obj',
advanced: {
modelGuid: '',
},
},
],
},
};
apiInstance.translate(job, {}, (err, data) => {
if (err) { console.log(err); return; }
console.log(data);
});
此代码将输入模型转换为OBJ格式,然后再使用Forge API将其转换为SVF格式,以避免在处理SVF格式时出现错误。