// 异步加载
const LoadObj = async (key?: string) => {
LoadState.value = true
var objStr, mtlStr
var imgStrObj = {}
let len = 0 const zp: any = (await getoBJList({ key })).data JSZip.loadAsync(zp).then(function (zip) {
zip.forEach((relativePath: string, file: JSZip.JSZipObject) => {
try {
len++
let blobs = false
if (file.name.indexOf('.obj') > 0 || file.name.indexOf('.mtl') > 0)
blobs = true zip
.file(file.name)
.async(blobs ? 'text' : 'base64')
.then(
function success(text) {
len-- if (file.name.indexOf('.obj') > 0) objStr = text
else if (file.name.indexOf('.mtl') > 0) mtlStr = text
else
ht.Default.setImage(
file.name,
(imgStrObj[file.name] = 'data:image/png;base64,' + text)
)
if (len <= 0) {
try {
dataModel.clear() var rawS3 = parseObj('2121', objStr, mtlStr, imgStrObj) var node = new ht.Node()
node.s({
shape3d: '2121',
'3d.selectable': false
})
node.s3(rawS3)
node.p3(0, rawS3[1] / 2, 0)
dataModel.add(node)
var sz = node.getSize3d()
var sa = node.getScale3d()
graphView.setNear(
Math.floor(
Math.min(sz[0] * sa[0], sz[1] * sa[1], sz[2] * sa[2])
)
)
graphView.setFar(
Math.floor(
Math.max(sz[0] * sa[0], sz[1] * sa[1], sz[2] * sa[2])
) * 10
)
graphView.flyTo(node, true)
LoadState.value = true
} catch {
ElMessage.error(i18n.global.t('message.Objerr'))
LoadState.value = false
}
}
},
function error(e) {
len--
console.log(e)
}
)
} catch {
ElMessage.error(i18n.global.t('message.Objerr'))
LoadState.value = false
}
})
})
}

import { DownGet } from '/@/type/config/down'
const api = {
getoBJList: '/admin/down/obj', // 获取模型 }
// 下载模型文件
export function getoBJList(param: DownGet): Promise<AxiosResponse<IResponse>> {
return request({
url: api.getoBJList,
method: 'post',
data: param,
responseType: 'blob'
})
}
// 下载请求
export interface DownGet {
key: string
}
   /// <summary>
/// 读取文件
/// </summary>
/// <param name="Name"></param>
/// <param name="path"></param>
/// <returns></returns>
private FileStreamResult DownloadFile(string Name, string key, string path = null)
{
if (string.IsNullOrEmpty(path))
path = $"{Directory.GetCurrentDirectory()}/wwwroot"; //Determine the Content Type of the File.
string contentType = "";
new FileExtensionContentTypeProvider().TryGetContentType(Name, out contentType); //Build the File Path.
path = Path.Combine(path, Name); //Read the File data into FileStream.
FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read); //Send the File to Download.
return new FileStreamResult(fileStream, contentType) { FileDownloadName = key };
} /// <summary>
/// 下载obj模型
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
[HttpPost("obj"), Authorize] public IActionResult DownoBJ(XJDataDll.DataHttp.Admin.Down.Select obj)
{ try
{
var model = (from v in _dbcontext.company_models.Where(o => obj.key.Equals(o.key)).OrderBy(v => v.index) select v).FirstOrDefault(); FileStreamResult files = DownloadFile(model.path,model.key); return files;
}
catch
{
return NotFound();
} }

最新文章

  1. PHP下使用强大的imagick轻松生成组合缩略图
  2. 流量咪教你挖到5G免费流量
  3. awk实现按照某个字段排序
  4. SecureCRT rz和sz命令不可用,安装lrzsz
  5. VS2013配置WTL90_4140_Final
  6. 【转】linux之fsck命令
  7. Window 2008 R2 + IIS7.5 + VS2013 错误代码 0x80070002
  8. Fedora 下 安装 chrome
  9. C#中登录验证FormsAuthentication
  10. mysql数据库容量查询
  11. 图解 Monad
  12. 干货 | 云智慧透视宝Java代码性能监控实现原理
  13. Python之可变类型与不可变类型
  14. 【Qt编程】Qt学习笔记&lt;三&gt;
  15. vue-all
  16. Codeforces 109D String Transformation 字符串 哈希 KMP
  17. golang-grpc-Unimplemented-desc
  18. All about the “paper”
  19. 一劳永逸:域名支持通配符,ASP.NET Core中配置CORS
  20. java XML(可扩展标记语言)

热门文章

  1. SQLSERVER自动备份数据库
  2. Linux&amp;Android相关常用命令汇总记录
  3. PGI 用户手册之 Site-Specific Customization of the Compilers
  4. Spring Boot Actuator未授权漏洞
  5. WSL2 网络异常排查 [ping 不通、网络地址异常、缺少默认路由、被宿主机防火墙拦截]
  6. BeanUtils.copyProperties null覆盖问题
  7. 时间函数strtotime的强大
  8. redis获取图形验证码
  9. gauva cache
  10. 易语言json