Commit b9e43d1ba5486faaae44bbc5d69ff2ece95628a7

Authored by xp.Huang
2 parents 1bf2cee0 86297f6c

Merge branch 'fix/3d-model-thumbnail' into 'main_dev'

fix: 修复3d模型在大屏中无法保存缩略图与模型加载与上传时间调整为2min

See merge request yunteng/thingskit-view!314
1 import { UIPanel, UIRow, UIHorizontalRule } from './libs/ui.js' 1 import { UIPanel, UIRow, UIHorizontalRule } from './libs/ui.js'
2 -import useMessage from './MessageDialog.js'  
3 -import { saveOrUpdateThreeJsModel } from './libs/http/api.js'  
4 -import html2canvas from 'html2canvas'  
5 -import { fetchRouteParamsLocation } from '@/utils'  
6 -import { uploadFile } from '@/api/external/contentSave/content'  
7 -import { base64toFile } from '../utils/Base64ToFile.js'  
8 -import { useSpin } from '../js/libs/spin/useSpin.js'  
9 import arkanoid from '../examples/arkanoid.app.json?url' 2 import arkanoid from '../examples/arkanoid.app.json?url'
10 import camera from '../examples/camera.app.json?url' 3 import camera from '../examples/camera.app.json?url'
11 import particles from '../examples/particles.app.json?url' 4 import particles from '../examples/particles.app.json?url'
@@ -15,6 +15,8 @@ function Strings( config ) { @@ -15,6 +15,8 @@ function Strings( config ) {
15 'prompt/history/preserve': 'The history will be preserved across sessions.\nThis can have an impact on performance when working with textures.', 15 'prompt/history/preserve': 'The history will be preserved across sessions.\nThis can have an impact on performance when working with textures.',
16 'prompt/history/forbid': 'Undo/Redo disabled while scene is playing.', 16 'prompt/history/forbid': 'Undo/Redo disabled while scene is playing.',
17 'prompt/rendering/realistic/unsupportedMaterial': 'REALISTIC Shading: Only MeshStandardMaterial and MeshPhysicalMaterial are supported', 17 'prompt/rendering/realistic/unsupportedMaterial': 'REALISTIC Shading: Only MeshStandardMaterial and MeshPhysicalMaterial are supported',
  18 + 'prompt/save/success': "Save successfully",
  19 + 'prompt/save/faild': "Save failure",
18 20
19 'command/AddObject': 'Add Object', 21 'command/AddObject': 'Add Object',
20 'command/AddScript': 'Add Script', 22 'command/AddScript': 'Add Script',
@@ -418,6 +420,8 @@ function Strings( config ) { @@ -418,6 +420,8 @@ function Strings( config ) {
418 'prompt/history/preserve': 'L\'histoire sera conservée entre les sessions.\nCela peut avoir un impact sur les performances lors de la manipulation des textures.', 420 'prompt/history/preserve': 'L\'histoire sera conservée entre les sessions.\nCela peut avoir un impact sur les performances lors de la manipulation des textures.',
419 'prompt/history/forbid': 'Les fonctions Annuler/Rétablir sont désactivées pendant la lecture de la scène.', 421 'prompt/history/forbid': 'Les fonctions Annuler/Rétablir sont désactivées pendant la lecture de la scène.',
420 'prompt/rendering/realistic/unsupportedMaterial': 'Ombrage REALISTIC : seuls MeshStandardMaterial et MeshPhysicalMaterial sont pris en charge', 422 'prompt/rendering/realistic/unsupportedMaterial': 'Ombrage REALISTIC : seuls MeshStandardMaterial et MeshPhysicalMaterial sont pris en charge',
  423 + 'prompt/save/success': "Sauvé avec succès",
  424 + 'prompt/save/faild': "Échec de sauvegarde",
421 425
422 'command/AddObject': 'Ajouter un objet', 426 'command/AddObject': 'Ajouter un objet',
423 'command/AddScript': 'Ajouter un script', 427 'command/AddScript': 'Ajouter un script',
@@ -821,6 +825,8 @@ function Strings( config ) { @@ -821,6 +825,8 @@ function Strings( config ) {
821 'prompt/history/preserve': '历史将在会话之间保留。\n这可能会影响在处理纹理时的性能。', 825 'prompt/history/preserve': '历史将在会话之间保留。\n这可能会影响在处理纹理时的性能。',
822 'prompt/history/forbid': '在播放场景时,撤消/重做被禁用。', 826 'prompt/history/forbid': '在播放场景时,撤消/重做被禁用。',
823 'prompt/rendering/realistic/unsupportedMaterial': 'REALISTIC着色:仅支持 MeshStandardMaterial 和 MeshPhysicalMaterial', 827 'prompt/rendering/realistic/unsupportedMaterial': 'REALISTIC着色:仅支持 MeshStandardMaterial 和 MeshPhysicalMaterial',
  828 + 'prompt/save/success': "保存成功",
  829 + 'prompt/save/faild': "保存失败",
824 830
825 'command/AddObject': '添加对象', 831 'command/AddObject': '添加对象',
826 'command/AddScript': '添加脚本', 832 'command/AddScript': '添加脚本',
@@ -1224,6 +1230,8 @@ function Strings( config ) { @@ -1224,6 +1230,8 @@ function Strings( config ) {
1224 'prompt/history/preserve': '履歴はセッションをまたいで保存されます。\nこれは、テクスチャを操作する際のパフォーマンスに影響を与える可能性があります。', 1230 'prompt/history/preserve': '履歴はセッションをまたいで保存されます。\nこれは、テクスチャを操作する際のパフォーマンスに影響を与える可能性があります。',
1225 'prompt/history/forbid': 'シーンの再生中は元に戻す/やり直しは無効になります。', 1231 'prompt/history/forbid': 'シーンの再生中は元に戻す/やり直しは無効になります。',
1226 'prompt/rendering/realistic/unsupportedMaterial': 'REALISTIC シェーディング: MeshStandardmaterial と MeshPhysicalmaterial のみがサポートされています', 1232 'prompt/rendering/realistic/unsupportedMaterial': 'REALISTIC シェーディング: MeshStandardmaterial と MeshPhysicalmaterial のみがサポートされています',
  1233 + 'prompt/save/success': "保存成功です",
  1234 + 'prompt/save/faild': "保存に失敗しました",
1227 1235
1228 'command/AddObject': 'オブジェクトを追加', 1236 'command/AddObject': 'オブジェクトを追加',
1229 'command/AddScript': 'スクリプトを追加', 1237 'command/AddScript': 'スクリプトを追加',
@@ -1626,6 +1634,8 @@ function Strings( config ) { @@ -1626,6 +1634,8 @@ function Strings( config ) {
1626 'prompt/history/preserve': '기록은 세션을 통해 저장됩니다. 이는 텍스처를 조작할 때 성능에 영향을 미칠 수 있습니다.', 1634 'prompt/history/preserve': '기록은 세션을 통해 저장됩니다. 이는 텍스처를 조작할 때 성능에 영향을 미칠 수 있습니다.',
1627 'prompt/history/forbid': '씬을 재생하는 동안 되돌리기/다시하기는 비활성화됩니다.', 1635 'prompt/history/forbid': '씬을 재생하는 동안 되돌리기/다시하기는 비활성화됩니다.',
1628 'prompt/rendering/realistic/unsupportedMaterial': 'REALISTIC 셰이딩: MeshStandardmaterial 및 MeshPhysicalmaterial만 지원됩니다', 1636 'prompt/rendering/realistic/unsupportedMaterial': 'REALISTIC 셰이딩: MeshStandardmaterial 및 MeshPhysicalmaterial만 지원됩니다',
  1637 + 'prompt/save/success': "성공적으로 저장했습니다",
  1638 + 'prompt/save/faild': "저장 실패",
1629 1639
1630 'command/AddObject': '객체 추가', 1640 'command/AddObject': '객체 추가',
1631 'command/AddScript': '스크립트 추가', 1641 'command/AddScript': '스크립트 추가',
@@ -7,6 +7,7 @@ import { base64toFile } from '../../../utils/Base64ToFile.js' @@ -7,6 +7,7 @@ import { base64toFile } from '../../../utils/Base64ToFile.js'
7 import { useSpin } from '../spin/useSpin' 7 import { useSpin } from '../spin/useSpin'
8 8
9 export function useSave(editor) { 9 export function useSave(editor) {
  10 + const strings = editor.strings
10 11
11 async function save() { 12 async function save() {
12 // 获取缩略图片 13 // 获取缩略图片
@@ -38,9 +39,9 @@ export function useSave(editor) { @@ -38,9 +39,9 @@ export function useSave(editor) {
38 imageUrl: uploadRes?.fileStaticUri, 39 imageUrl: uploadRes?.fileStaticUri,
39 data: file_json 40 data: file_json
40 }) 41 })
41 - success('保存成功') 42 + success(strings.getKey('prompt/save/success'))
42 } catch (e) { 43 } catch (e) {
43 - error(e?.message || e?.msg || '网络错误') 44 + error(e?.message || e?.msg || e?.response?.statusText || strings.getKey('prompt/save/faild'))
44 } finally { 45 } finally {
45 stop() 46 stop()
46 } 47 }
@@ -12,10 +12,10 @@ export function saveOrUpdateThreeJsModel(params) { @@ -12,10 +12,10 @@ export function saveOrUpdateThreeJsModel(params) {
12 { 12 {
13 url: `${API['URL']}?id=${params['id']}&imageUrl=${params['imageUrl']}`, 13 url: `${API['URL']}?id=${params['id']}&imageUrl=${params['imageUrl']}`,
14 data: params['data'], 14 data: params['data'],
15 - timeout: 30 * 1000 15 + timeout: 60 * 1000 * 2
16 }, 16 },
17 { 17 {
18 - errorMessageMode: '' 18 + errorMessageMode: 'none'
19 } 19 }
20 ) 20 )
21 } 21 }
@@ -41,7 +41,7 @@ export function getThreeJsModelByJson(id) { @@ -41,7 +41,7 @@ export function getThreeJsModelByJson(id) {
41 return defHttp.get( 41 return defHttp.get(
42 { 42 {
43 url: API['URL'] + '/json' + '/' + id + '/root.json', 43 url: API['URL'] + '/json' + '/' + id + '/root.json',
44 - timeout: 30 * 1000 44 + timeout: 60 * 1000 * 2
45 }, 45 },
46 { 46 {
47 errorMessageMode: '' 47 errorMessageMode: ''
@@ -4,10 +4,11 @@ import { ModelComponentItemType } from './model'; @@ -4,10 +4,11 @@ import { ModelComponentItemType } from './model';
4 4
5 5
6 6
7 -export const doGet3DComponentJson = (id: string, ) => { 7 +export const doGet3DComponentJson = (id: string,) => {
8 return defHttp.get<ModelComponentItemType | null>( 8 return defHttp.get<ModelComponentItemType | null>(
9 { 9 {
10 - url: `/3d_component/json/${id}/root.json` 10 + url: `/3d_component/json/${id}/root.json`,
  11 + timeout: 1000 * 60 * 2
11 } 12 }
12 ) 13 )
13 } 14 }
@@ -24,7 +24,7 @@ export class ModelLoader { @@ -24,7 +24,7 @@ export class ModelLoader {
24 height = window.innerHeight 24 height = window.innerHeight
25 }: ModelLoaderConstructorOptions = {} 25 }: ModelLoaderConstructorOptions = {}
26 ) { 26 ) {
27 - this.renderer = new WebGLRenderer({ alpha: true, antialias: true }) 27 + this.renderer = new WebGLRenderer({ alpha: true, antialias: true, preserveDrawingBuffer: true })
28 this.scene = new Scene() 28 this.scene = new Scene()
29 this.camera = new PerspectiveCamera() 29 this.camera = new PerspectiveCamera()
30 this.objectLoader = new ObjectLoader() 30 this.objectLoader = new ObjectLoader()