@shapediver/viewer.session-engine.session-engine 2.12.8 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/implementation/OutputDelayException.js +1 -1
  2. package/dist/implementation/OutputDelayException.js.map +1 -1
  3. package/dist/implementation/OutputLoader.d.ts +9 -7
  4. package/dist/implementation/OutputLoader.d.ts.map +1 -1
  5. package/dist/implementation/OutputLoader.js +56 -41
  6. package/dist/implementation/OutputLoader.js.map +1 -1
  7. package/dist/implementation/SessionData.d.ts +1 -1
  8. package/dist/implementation/SessionData.d.ts.map +1 -1
  9. package/dist/implementation/SessionData.js +2 -2
  10. package/dist/implementation/SessionData.js.map +1 -1
  11. package/dist/implementation/SessionEngine.d.ts +30 -3
  12. package/dist/implementation/SessionEngine.d.ts.map +1 -1
  13. package/dist/implementation/SessionEngine.js +115 -48
  14. package/dist/implementation/SessionEngine.js.map +1 -1
  15. package/dist/implementation/SessionOutputData.d.ts +1 -1
  16. package/dist/implementation/SessionOutputData.d.ts.map +1 -1
  17. package/dist/implementation/SessionOutputData.js +2 -2
  18. package/dist/implementation/SessionOutputData.js.map +1 -1
  19. package/dist/implementation/SessionTreeNode.d.ts +1 -1
  20. package/dist/implementation/SessionTreeNode.d.ts.map +1 -1
  21. package/dist/implementation/SessionTreeNode.js +1 -1
  22. package/dist/implementation/SessionTreeNode.js.map +1 -1
  23. package/dist/implementation/dto/Export.d.ts +4 -4
  24. package/dist/implementation/dto/Export.d.ts.map +1 -1
  25. package/dist/implementation/dto/Export.js +2 -2
  26. package/dist/implementation/dto/Export.js.map +1 -1
  27. package/dist/implementation/dto/FileParameter.d.ts +2 -2
  28. package/dist/implementation/dto/FileParameter.d.ts.map +1 -1
  29. package/dist/implementation/dto/FileParameter.js +69 -31
  30. package/dist/implementation/dto/FileParameter.js.map +1 -1
  31. package/dist/implementation/dto/Output.js +2 -2
  32. package/dist/implementation/dto/Output.js.map +1 -1
  33. package/dist/implementation/dto/Parameter.d.ts +6 -6
  34. package/dist/implementation/dto/Parameter.d.ts.map +1 -1
  35. package/dist/implementation/dto/Parameter.js +106 -87
  36. package/dist/implementation/dto/Parameter.js.map +1 -1
  37. package/dist/index.d.ts +9 -10
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +7 -10
  40. package/dist/index.js.map +1 -1
  41. package/dist/interfaces/ISessionData.d.ts +2 -2
  42. package/dist/interfaces/ISessionData.d.ts.map +1 -1
  43. package/dist/interfaces/ISessionEngine.d.ts +11 -46
  44. package/dist/interfaces/ISessionEngine.d.ts.map +1 -1
  45. package/dist/interfaces/ISessionEngine.js +0 -4
  46. package/dist/interfaces/ISessionEngine.js.map +1 -1
  47. package/dist/interfaces/ISessionOutputData.d.ts +2 -2
  48. package/dist/interfaces/ISessionOutputData.d.ts.map +1 -1
  49. package/dist/interfaces/ISessionTreeNode.d.ts +1 -1
  50. package/dist/interfaces/dto/IExport.d.ts +2 -2
  51. package/dist/interfaces/dto/IExport.d.ts.map +1 -1
  52. package/dist/interfaces/dto/IFileParameter.d.ts +1 -1
  53. package/dist/interfaces/dto/IFileParameter.d.ts.map +1 -1
  54. package/dist/interfaces/dto/IOutput.d.ts +13 -13
  55. package/dist/interfaces/dto/IOutput.d.ts.map +1 -1
  56. package/dist/interfaces/dto/IOutput.js +1 -0
  57. package/dist/interfaces/dto/IOutput.js.map +1 -1
  58. package/dist/interfaces/dto/IParameter.d.ts +3 -3
  59. package/dist/interfaces/dto/IParameter.d.ts.map +1 -1
  60. package/package.json +9 -10
  61. package/src/implementation/OutputDelayException.ts +3 -3
  62. package/src/implementation/OutputLoader.ts +139 -104
  63. package/src/implementation/SessionData.ts +9 -9
  64. package/src/implementation/SessionEngine.ts +133 -53
  65. package/src/implementation/SessionOutputData.ts +8 -8
  66. package/src/implementation/SessionTreeNode.ts +8 -5
  67. package/src/implementation/dto/Export.ts +24 -11
  68. package/src/implementation/dto/FileParameter.ts +72 -37
  69. package/src/implementation/dto/Output.ts +2 -2
  70. package/src/implementation/dto/Parameter.ts +115 -85
  71. package/src/index.ts +17 -21
  72. package/src/interfaces/ISessionData.ts +2 -2
  73. package/src/interfaces/ISessionEngine.ts +19 -60
  74. package/src/interfaces/ISessionOutputData.ts +2 -2
  75. package/src/interfaces/ISessionTreeNode.ts +1 -1
  76. package/src/interfaces/dto/IExport.ts +4 -4
  77. package/src/interfaces/dto/IFileParameter.ts +2 -2
  78. package/src/interfaces/dto/IOutput.ts +38 -26
  79. package/src/interfaces/dto/IParameter.ts +3 -3
@@ -43,10 +43,16 @@ import { FileParameter } from './dto/FileParameter';
43
43
  import { IExport } from '../interfaces/dto/IExport';
44
44
  import { IFileParameter } from '../interfaces/dto/IFileParameter';
45
45
  import { IOutput } from '../interfaces/dto/IOutput';
46
+ import {
47
+ IOutputEvent,
48
+ ISettingsSections,
49
+ ITaskEvent,
50
+ PARAMETER_TYPE,
51
+ TASK_TYPE
52
+ } from '@shapediver/viewer.shared.types';
46
53
  import { IParameter } from '../interfaces/dto/IParameter';
47
- import { ISessionEngine, ISettingsSections, PARAMETER_TYPE } from '../interfaces/ISessionEngine';
54
+ import { ISessionEngine } from '../interfaces/ISessionEngine';
48
55
  import { ISessionTreeNode } from '../interfaces/ISessionTreeNode';
49
- import { IOutputEvent, ITaskEvent, TASK_TYPE } from '@shapediver/viewer.shared.types';
50
56
  import {
51
57
  ITree,
52
58
  ITreeNode,
@@ -63,7 +69,7 @@ import { vec3 } from 'gl-matrix';
63
69
  /* eslint-disable @typescript-eslint/no-empty-function */
64
70
 
65
71
  export class SessionEngine implements ISessionEngine {
66
- // #region Properties (44)
72
+ // #region Properties (46)
67
73
 
68
74
  private readonly _eventEngine = EventEngine.instance;
69
75
  private readonly _exports: { [key: string]: IExport; } = {};
@@ -100,6 +106,7 @@ export class SessionEngine implements ISessionEngine {
100
106
  valueString: string
101
107
  }
102
108
  }[] = [];
109
+ private _allowOutputLoading: boolean = true;
103
110
  private _automaticSceneUpdate: boolean = true;
104
111
  private _closeOnFailure: () => Promise<void> = async () => { };
105
112
  private _closed: boolean = false;
@@ -116,6 +123,7 @@ export class SessionEngine implements ISessionEngine {
116
123
  };
117
124
  private _initialized: boolean = false;
118
125
  private _jwtToken?: string;
126
+ private _loadSdtf: boolean = false;
119
127
  private _modelId?: string;
120
128
  private _node: ITreeNode;
121
129
  private _refreshJwtToken?: () => Promise<string>;
@@ -128,7 +136,7 @@ export class SessionEngine implements ISessionEngine {
128
136
  private _viewerSettingsVersion: string = latestVersion;
129
137
  private _viewerSettingsVersionBackend: string = latestVersion;
130
138
 
131
- // #endregion Properties (44)
139
+ // #endregion Properties (46)
132
140
 
133
141
  // #region Constructors (1)
134
142
 
@@ -136,7 +144,7 @@ export class SessionEngine implements ISessionEngine {
136
144
  * Can be use to initialize a session with the ticket/guid and modelViewUrl and returns a scene graph node with the result.
137
145
  * Can be use to customize the session with updated parameters to get the updated scene graph node.
138
146
  */
139
- constructor(properties: { id: string, ticket?: string, guid?: string, modelViewUrl: string, buildVersion: string, buildDate: string, jwtToken?: string, excludeViewports?: string[] }) {
147
+ constructor(properties: { id: string, ticket?: string, guid?: string, modelViewUrl: string, buildVersion: string, buildDate: string, jwtToken?: string, excludeViewports?: string[], allowOutputLoading: boolean, loadSdtf: boolean }) {
140
148
  this._id = properties.id;
141
149
  this._node = new TreeNode(properties.id);
142
150
  this._guid = properties.guid;
@@ -144,6 +152,8 @@ export class SessionEngine implements ISessionEngine {
144
152
  this._modelViewUrl = properties.modelViewUrl;
145
153
  this._excludeViewports = properties.excludeViewports || [];
146
154
  this._jwtToken = properties.jwtToken;
155
+ this._allowOutputLoading = properties.allowOutputLoading;
156
+ this._loadSdtf = properties.loadSdtf;
147
157
  this._headers['X-ShapeDiver-BuildDate'] = properties.buildDate;
148
158
  this._headers['X-ShapeDiver-BuildVersion'] = properties.buildVersion;
149
159
  this._outputLoader = new OutputLoader(this);
@@ -158,7 +168,7 @@ export class SessionEngine implements ISessionEngine {
158
168
 
159
169
  // #endregion Constructors (1)
160
170
 
161
- // #region Public Accessors (25)
171
+ // #region Public Getters And Setters (26)
162
172
 
163
173
  public get automaticSceneUpdate(): boolean {
164
174
  return this._automaticSceneUpdate;
@@ -215,6 +225,22 @@ export class SessionEngine implements ISessionEngine {
215
225
  return this._jwtToken;
216
226
  }
217
227
 
228
+ public get loadSdtf(): boolean {
229
+ return this._loadSdtf;
230
+ }
231
+
232
+ public set loadSdtf(value: boolean) {
233
+ this._loadSdtf = value;
234
+ if(this._initialized === true && this._loadSdtf === true) {
235
+ (async () => {
236
+ this._outputLoader.reloadSdtf = true;
237
+ await this.updateOutputs();
238
+ this._outputLoader.reloadSdtf = false;
239
+ this._eventEngine.emitEvent(EVENTTYPE.SESSION.SESSION_SDTF_DELAYED_LOADED, { sessionId: this.id });
240
+ })();
241
+ }
242
+ }
243
+
218
244
  public get modelViewUrl(): string {
219
245
  return this._modelViewUrl;
220
246
  }
@@ -267,9 +293,9 @@ export class SessionEngine implements ISessionEngine {
267
293
  return this._viewerSettings;
268
294
  }
269
295
 
270
- // #endregion Public Accessors (25)
296
+ // #endregion Public Getters And Setters (26)
271
297
 
272
- // #region Public Methods (27)
298
+ // #region Public Methods (30)
273
299
 
274
300
  public applySettings(response: ShapeDiverResponseDto, sections?: ISettingsSections) {
275
301
  sections = sections || {};
@@ -416,9 +442,9 @@ export class SessionEngine implements ISessionEngine {
416
442
  this.removeBusyMode(this.#customizationProcess);
417
443
 
418
444
  for (const busyId of this.#customizationBusyModes) {
419
- for (const r in this._stateEngine.renderingEngines) {
420
- if (this._stateEngine.renderingEngines[r].busy.includes(busyId))
421
- this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(busyId), 1);
445
+ for (const r in this._stateEngine.viewportEngines) {
446
+ if (this._stateEngine.viewportEngines[r].busy.includes(busyId))
447
+ this._stateEngine.viewportEngines[r].busy.splice(this._stateEngine.viewportEngines[r].busy.indexOf(busyId), 1);
422
448
  }
423
449
  }
424
450
 
@@ -474,26 +500,13 @@ export class SessionEngine implements ISessionEngine {
474
500
  const eventFileUpload: ITaskEvent = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0.1, data: { sessionId: this.id }, status: 'Uploading file parameters' };
475
501
  this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_PROCESS, eventFileUpload);
476
502
 
477
- const fileParameterIds: { [key: string]: string } = {};
478
- // load file parameter first
479
- for (const parameterId in this.parameters) {
480
- if (this.parameters[parameterId] instanceof FileParameter) {
481
- fileParameterIds[parameterId] = await (<IFileParameter>this.parameters[parameterId]).upload();
482
-
483
- // OPTION TO SKIP - PART 1a
484
- const cancelResult = this.cancelProcess(customizationId, eventId, TASK_TYPE.SESSION_CUSTOMIZATION, 1, { sessionId: this.id });
485
- if (cancelResult) return cancelResult;
486
- }
487
- }
503
+ // upload file parameters
504
+ await this.uploadFileParameters();
488
505
 
489
506
  // OPTION TO SKIP - PART 1b
490
507
  const cancelResult = this.cancelProcess(customizationId, eventId, TASK_TYPE.SESSION_CUSTOMIZATION, 1, { sessionId: this.id });
491
508
  if (cancelResult) return cancelResult;
492
509
 
493
- // assign the uploaded parameters
494
- for (const parameterId in fileParameterIds)
495
- this.parameters[parameterId].value = fileParameterIds[parameterId];
496
-
497
510
  const parameterSet: {
498
511
  [key: string]: {
499
512
  value: unknown,
@@ -599,9 +612,9 @@ export class SessionEngine implements ISessionEngine {
599
612
 
600
613
  // update the viewports
601
614
  if (waitForViewportUpdate) {
602
- for (const r in this._stateEngine.renderingEngines)
603
- if (!this.excludeViewports.includes(this._stateEngine.renderingEngines[r].id))
604
- this._stateEngine.renderingEngines[r].update(`SessionEngine(${this.id}).customize`);
615
+ for (const r in this._stateEngine.viewportEngines)
616
+ if (!this.excludeViewports.includes(this._stateEngine.viewportEngines[r].id))
617
+ this._stateEngine.viewportEngines[r].update(`SessionEngine(${this.id}).customize`);
605
618
 
606
619
  for (const outputId in this.outputs) {
607
620
  if (oldOutputVersions[outputId] !== newOutputVersions[outputId]) {
@@ -623,9 +636,9 @@ export class SessionEngine implements ISessionEngine {
623
636
 
624
637
  if (!waitForViewportUpdate) {
625
638
  setTimeout(() => {
626
- for (const r in this._stateEngine.renderingEngines)
627
- if (!this.excludeViewports.includes(this._stateEngine.renderingEngines[r].id))
628
- this._stateEngine.renderingEngines[r].update(`SessionEngine(${this.id}).customize`);
639
+ for (const r in this._stateEngine.viewportEngines)
640
+ if (!this.excludeViewports.includes(this._stateEngine.viewportEngines[r].id))
641
+ this._stateEngine.viewportEngines[r].update(`SessionEngine(${this.id}).customize`);
629
642
  }, 0);
630
643
  }
631
644
 
@@ -640,19 +653,22 @@ export class SessionEngine implements ISessionEngine {
640
653
  }
641
654
  }
642
655
 
643
- public async customizeParallel(parameterValues: { [key: string]: string }, loadOutputs = true): Promise<ISessionTreeNode | ShapeDiverResponseDto> {
656
+ public async customizeParallel(parameterValues: { [key: string]: unknown }, loadOutputs = true): Promise<ISessionTreeNode | ShapeDiverResponseDto> {
644
657
  const eventId = this._uuidGenerator.create();
645
658
 
646
659
  const eventStart: ITaskEvent = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0, data: { sessionId: this.id }, status: 'Customizing session' };
647
660
  this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_START, eventStart);
648
661
 
662
+ // upload file parameters
663
+ await this.uploadFileParameters(parameterValues);
664
+
649
665
  const parameterSet: {
650
666
  [key: string]: string
651
667
  } = {};
652
668
 
653
669
  // create a set of the current validated parameter values
654
670
  for (const parameterId in this.parameters)
655
- parameterSet[parameterId] = parameterValues[parameterId] !== undefined ? (' ' + parameterValues[parameterId]).slice(1) : this.parameters[parameterId].stringify();
671
+ parameterSet[parameterId] = (' ' + this.parameters[parameterId].stringify(parameterValues[parameterId])).slice(1);
656
672
 
657
673
  const result = await this.customizeSession(parameterSet, () => false, {
658
674
  eventId,
@@ -938,9 +954,10 @@ export class SessionEngine implements ISessionEngine {
938
954
  }
939
955
  }
940
956
 
941
- public async requestExport(exportId: string, parameters: { [key: string]: string }, maxWaitTime: number, retry = false): Promise<ShapeDiverResponseExport> {
957
+ public async requestExport(exportId: string, parameters: { [key: string]: unknown }, maxWaitTime: number, retry = false): Promise<ShapeDiverResponseExport> {
942
958
  this.checkAvailability('export');
943
959
  try {
960
+ await this.uploadFileParameters(parameters);
944
961
  const requestParameterSet = this.cleanExportParameters(parameters);
945
962
  const responseDto = await this._sdk.utils.submitAndWaitForExport(this._sdk, this._sessionId!, { exports: { id: exportId }, parameters: requestParameterSet }, maxWaitTime);
946
963
  this.updateResponseDto(responseDto);
@@ -952,14 +969,28 @@ export class SessionEngine implements ISessionEngine {
952
969
  }
953
970
 
954
971
  public async requestExports(body: ShapeDiverRequestExport, loadOutputs: boolean = false, maxWaitMsec?: number, retry = false): Promise<ShapeDiverResponseDto> {
972
+ let processId;
955
973
  this.checkAvailability('export');
956
974
  try {
975
+
976
+ // activate the busy mode if outputs are loaded
977
+ if (loadOutputs === true && this._allowOutputLoading === true &&
978
+ body.outputs && Object.keys(body.outputs).length > 0) {
979
+ processId = this._uuidGenerator.create();
980
+ this.addBusyMode(processId);
981
+ }
982
+
983
+ await this.uploadFileParameters(body.parameters as { [key: string]: string | File | Blob });
957
984
  const requestParameterSet = this.cleanExportParameters(body.parameters);
985
+
958
986
  const responseDto = await this._sdk.utils.submitAndWaitForExport(this._sdk, this._sessionId!, { exports: body.exports, parameters: requestParameterSet, outputs: body.outputs, max_wait_time: body.max_wait_time }, maxWaitMsec);
959
987
  this.updateResponseDto(responseDto);
960
- if(loadOutputs === true) this.updateOutputs();
988
+ if (loadOutputs === true && this._allowOutputLoading === true) this.updateOutputs();
989
+
990
+ if (processId) this.removeBusyMode(processId);
961
991
  return responseDto;
962
992
  } catch (e) {
993
+ if (processId) this.removeBusyMode(processId);
963
994
  await this.handleError(e, retry);
964
995
  return await this.requestExports(body, loadOutputs, maxWaitMsec, true);
965
996
  }
@@ -1267,9 +1298,9 @@ export class SessionEngine implements ISessionEngine {
1267
1298
 
1268
1299
  // update the viewports
1269
1300
  if (waitForViewportUpdate) {
1270
- for (const r in this._stateEngine.renderingEngines)
1271
- if (!this.excludeViewports.includes(this._stateEngine.renderingEngines[r].id))
1272
- this._stateEngine.renderingEngines[r].update(`SessionEngine(${this.id}).updateOutputs`);
1301
+ for (const r in this._stateEngine.viewportEngines)
1302
+ if (!this.excludeViewports.includes(this._stateEngine.viewportEngines[r].id))
1303
+ this._stateEngine.viewportEngines[r].update(`SessionEngine(${this.id}).updateOutputs`);
1273
1304
 
1274
1305
  for (const outputId in this.outputs) {
1275
1306
  if (oldOutputVersions[outputId] !== newOutputVersions[outputId]) {
@@ -1314,6 +1345,36 @@ export class SessionEngine implements ISessionEngine {
1314
1345
  }
1315
1346
  }
1316
1347
 
1348
+ /**
1349
+ * Uploads all file parameters and returns the file parameter values.
1350
+ * If parameterValues is provided, the file parameter values are added to it.
1351
+ *
1352
+ * @param parameterValues
1353
+ * @returns
1354
+ */
1355
+ public async uploadFileParameters(parameterValues?: { [key: string]: unknown }): Promise<{ [key: string]: string }> {
1356
+ const parameterValueSet = parameterValues !== undefined ? this.getFileParameterSet(parameterValues) : undefined;
1357
+
1358
+ const fileParameterValues: { [key: string]: string } = {};
1359
+ // load file parameter first
1360
+ for (const parameterId in this.parameters) {
1361
+ if (this.parameters[parameterId] instanceof FileParameter) {
1362
+ fileParameterValues[parameterId] = await (<IFileParameter>this.parameters[parameterId]).upload(parameterValueSet ? parameterValueSet[parameterId] : undefined);
1363
+ if (parameterValues) {
1364
+ parameterValues[parameterId] = fileParameterValues[parameterId];
1365
+
1366
+ // if the parameter value of the file parameter was used, set the value to the parameter
1367
+ if(parameterValues[parameterId] === undefined && this.parameters[parameterId].value !== fileParameterValues[parameterId])
1368
+ this.parameters[parameterId].value = fileParameterValues[parameterId];
1369
+ } else if(this.parameters[parameterId].value !== fileParameterValues[parameterId]) {
1370
+ this.parameters[parameterId].value = fileParameterValues[parameterId];
1371
+ }
1372
+ }
1373
+ }
1374
+
1375
+ return fileParameterValues;
1376
+ }
1377
+
1317
1378
  public async uploadGLTF(blob: Blob, conversion: ShapeDiverRequestGltfUploadQueryConversion = ShapeDiverRequestGltfUploadQueryConversion.NONE, retry = false): Promise<ShapeDiverResponseDto> {
1318
1379
  this.checkAvailability('gltf-upload');
1319
1380
  try {
@@ -1327,9 +1388,9 @@ export class SessionEngine implements ISessionEngine {
1327
1388
  }
1328
1389
  }
1329
1390
 
1330
- // #endregion Public Methods (27)
1391
+ // #endregion Public Methods (30)
1331
1392
 
1332
- // #region Private Methods (15)
1393
+ // #region Private Methods (16)
1333
1394
 
1334
1395
  private _saveSessionSettings() {
1335
1396
  const parameters = this.parameters;
@@ -1388,9 +1449,9 @@ export class SessionEngine implements ISessionEngine {
1388
1449
  }
1389
1450
 
1390
1451
  private addBusyMode(busyId: string) {
1391
- for (const r in this._stateEngine.renderingEngines) {
1452
+ for (const r in this._stateEngine.viewportEngines) {
1392
1453
  if (!this.excludeViewports.includes(r)) {
1393
- this._stateEngine.renderingEngines[r].busy.push(busyId);
1454
+ this._stateEngine.viewportEngines[r].busy.push(busyId);
1394
1455
  this.#customizationBusyModes.push(busyId);
1395
1456
  }
1396
1457
  }
@@ -1444,7 +1505,7 @@ export class SessionEngine implements ISessionEngine {
1444
1505
  throw new ShapeDiverViewerSessionError(`Session.checkAvailability: action ${action} not available.`);
1445
1506
  }
1446
1507
 
1447
- private cleanExportParameters(parameters: ShapeDiverRequestCustomization): ShapeDiverRequestCustomization {
1508
+ private cleanExportParameters(parameters: { [key: string]: unknown }): ShapeDiverRequestCustomization {
1448
1509
  const requestParameterSet: ShapeDiverRequestCustomization = {};
1449
1510
 
1450
1511
  // first step, we convert all our names and displaynames to ids
@@ -1457,7 +1518,7 @@ export class SessionEngine implements ISessionEngine {
1457
1518
  if (!parameterObject) continue;
1458
1519
 
1459
1520
  // copy into new dictionary
1460
- requestParameterSet[parameterObject.id] = parameters[parameterIdOrName];
1521
+ requestParameterSet[parameterObject.id] = (' ' + parameterObject.stringify(parameters[parameterIdOrName])).slice(1);
1461
1522
  }
1462
1523
 
1463
1524
  // seconds step, fill all other parameter values that are currently not set
@@ -1474,16 +1535,16 @@ export class SessionEngine implements ISessionEngine {
1474
1535
  }
1475
1536
 
1476
1537
  private async customizeInternal(cancelRequest: () => boolean, taskEventInfo: OutputLoaderTaskEventInfo): Promise<ISessionTreeNode> {
1477
- return this.customizeSession(this._parameterValues, cancelRequest, taskEventInfo) as Promise<ISessionTreeNode>;
1538
+ return this.customizeSession(this._parameterValues, cancelRequest, taskEventInfo);
1478
1539
  }
1479
1540
 
1480
- private async customizeSession(parameters: { [key: string]: string }, cancelRequest: () => boolean, taskEventInfo: OutputLoaderTaskEventInfo, parallel = false, loadOutputs = true, retry = false): Promise<ISessionTreeNode | ShapeDiverResponseDto> {
1541
+ private async customizeSession(parameters: { [key: string]: string }, cancelRequest: () => boolean, taskEventInfo: OutputLoaderTaskEventInfo, parallel = false, loadOutputs = true, retry = false): Promise<ISessionTreeNode> {
1481
1542
  this.checkAvailability('customize');
1482
1543
  try {
1483
1544
  this._performanceEvaluator.startSection('sessionResponse');
1484
1545
  const responseDto = await this._sdk.utils.submitAndWaitForCustomization(this._sdk, this._sessionId!, parameters);
1485
1546
  this._performanceEvaluator.endSection('sessionResponse');
1486
- if (loadOutputs === true) {
1547
+ if (loadOutputs === true && this._allowOutputLoading === true) {
1487
1548
  if (cancelRequest()) return new SessionTreeNode();
1488
1549
  if (parallel === true) {
1489
1550
  // special case, we load the outputs put don't add them to the scene
@@ -1495,7 +1556,9 @@ export class SessionEngine implements ISessionEngine {
1495
1556
  }
1496
1557
  } else {
1497
1558
  // special case, we don't load the outputs and only return the responseDto
1498
- return responseDto;
1559
+ const node = new SessionTreeNode();
1560
+ node.data.push(new SessionData(responseDto));
1561
+ return node;
1499
1562
  }
1500
1563
  } catch (e) {
1501
1564
  await this.handleError(e, retry);
@@ -1504,6 +1567,23 @@ export class SessionEngine implements ISessionEngine {
1504
1567
  }
1505
1568
  }
1506
1569
 
1570
+ /**
1571
+ * Get all file parameters from the parameter set.
1572
+ * If the parameter is not set in the parameter set, the value from the parameter object is used.
1573
+ *
1574
+ * @param parameters
1575
+ * @returns
1576
+ */
1577
+ private getFileParameterSet(parameters: { [key: string]: unknown }): { [key: string]: string | File | Blob } {
1578
+ const fileParameterSet: { [key: string]: string | File | Blob } = {};
1579
+ for (const parameterId in this.parameters) {
1580
+ if (this.parameters[parameterId] instanceof FileParameter) {
1581
+ fileParameterSet[parameterId] = parameters[parameterId] !== undefined ? parameters[parameterId] as string | File | Blob : (this.parameters[parameterId] as FileParameter).value;
1582
+ }
1583
+ }
1584
+ return fileParameterSet;
1585
+ }
1586
+
1507
1587
  private async handleError(e: ShapeDiverBackendError | ShapeDiverViewerError | Error | unknown, retry = false) {
1508
1588
  if (isGBResponseError(e)) {
1509
1589
  if (e.error === ShapeDiverResponseErrorType.SESSION_GONE_ERROR) {
@@ -1556,9 +1636,9 @@ export class SessionEngine implements ISessionEngine {
1556
1636
  }
1557
1637
 
1558
1638
  private removeBusyMode(busyId: string) {
1559
- for (const r in this._stateEngine.renderingEngines) {
1560
- if (this._stateEngine.renderingEngines[r].busy.includes(busyId))
1561
- this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(busyId), 1);
1639
+ for (const r in this._stateEngine.viewportEngines) {
1640
+ if (this._stateEngine.viewportEngines[r].busy.includes(busyId))
1641
+ this._stateEngine.viewportEngines[r].busy.splice(this._stateEngine.viewportEngines[r].busy.indexOf(busyId), 1);
1562
1642
 
1563
1643
  if (this.#customizationBusyModes.includes(busyId))
1564
1644
  this.#customizationBusyModes.splice(this.#customizationBusyModes.indexOf(busyId), 1);
@@ -1714,5 +1794,5 @@ export class SessionEngine implements ISessionEngine {
1714
1794
  await Promise.all(promises);
1715
1795
  }
1716
1796
 
1717
- // #endregion Private Methods (15)
1797
+ // #endregion Private Methods (16)
1718
1798
  }
@@ -1,6 +1,6 @@
1
- import { ShapeDiverResponseOutput } from '@shapediver/sdk.geometry-api-sdk-v2';
2
- import { AbstractTreeNodeData, ITreeNodeData } from '@shapediver/viewer.shared.node-tree'
1
+ import { AbstractTreeNodeData } from '@shapediver/viewer.shared.node-tree';
3
2
  import { ISessionOutputData } from '../interfaces/ISessionOutputData';
3
+ import { ShapeDiverResponseOutput } from '@shapediver/sdk.geometry-api-sdk-v2';
4
4
 
5
5
  export class SessionOutputData extends AbstractTreeNodeData implements ISessionOutputData {
6
6
  // #region Properties (1)
@@ -22,17 +22,17 @@ export class SessionOutputData extends AbstractTreeNodeData implements ISessionO
22
22
 
23
23
  // #endregion Constructors (1)
24
24
 
25
- // #region Public Accessors (2)
25
+ // #region Public Getters And Setters (2)
26
26
 
27
27
  public get responseOutput(): ShapeDiverResponseOutput {
28
- return this.#responseOutput;
29
- }
28
+ return this.#responseOutput;
29
+ }
30
30
 
31
31
  public set responseOutput(value: ShapeDiverResponseOutput) {
32
- this.#responseOutput = value;
33
- }
32
+ this.#responseOutput = value;
33
+ }
34
34
 
35
- // #endregion Public Accessors (2)
35
+ // #endregion Public Getters And Setters (2)
36
36
 
37
37
  // #region Public Methods (1)
38
38
 
@@ -1,6 +1,10 @@
1
- import { mat4 } from 'gl-matrix'
2
- import { ITransformation, ITreeNode, ITreeNodeData, TreeNode } from '@shapediver/viewer.shared.node-tree'
3
1
  import { ISessionTreeNode } from '../interfaces/ISessionTreeNode';
2
+ import {
3
+ ITransformation,
4
+ ITreeNode,
5
+ ITreeNodeData,
6
+ TreeNode
7
+ } from '@shapediver/viewer.shared.node-tree';
4
8
 
5
9
  export class SessionTreeNode extends TreeNode implements ISessionTreeNode {
6
10
  // #region Properties (1)
@@ -30,12 +34,11 @@ export class SessionTreeNode extends TreeNode implements ISessionTreeNode {
30
34
 
31
35
  // #endregion Constructors (1)
32
36
 
33
- // #region Public Accessors (1)
37
+ // #region Public Getters And Setters (1)
34
38
 
35
39
  public get sessionNode(): boolean {
36
40
  return this.#sessionNode;
37
41
  }
38
42
 
39
- // #endregion Public Accessors (1)
40
-
43
+ // #endregion Public Getters And Setters (1)
41
44
  }
@@ -1,8 +1,21 @@
1
- import { ShapeDiverResponseExport, ShapeDiverResponseExportContent, ShapeDiverResponseExportDefinitionType, ShapeDiverResponseExportResult, ShapeDiverResponseModelComputationStatus, ShapeDiverResponseParameterGroup } from "@shapediver/sdk.geometry-api-sdk-v2";
2
- import { EventEngine, EVENTTYPE, InputValidator, Logger, UuidGenerator } from "@shapediver/viewer.shared.services";
3
- import { ITaskEvent, TASK_TYPE } from "@shapediver/viewer.shared.types";
4
- import { IExport } from "../../interfaces/dto/IExport";
5
- import { SessionEngine } from "../SessionEngine";
1
+ import {
2
+ EventEngine,
3
+ EVENTTYPE,
4
+ InputValidator,
5
+ Logger,
6
+ UuidGenerator
7
+ } from '@shapediver/viewer.shared.services';
8
+ import { IExport } from '../../interfaces/dto/IExport';
9
+ import { ITaskEvent, TASK_TYPE } from '@shapediver/viewer.shared.types';
10
+ import { SessionEngine } from '../SessionEngine';
11
+ import {
12
+ ShapeDiverResponseExport,
13
+ ShapeDiverResponseExportContent,
14
+ ShapeDiverResponseExportDefinitionType,
15
+ ShapeDiverResponseExportResult,
16
+ ShapeDiverResponseModelComputationStatus,
17
+ ShapeDiverResponseParameterGroup
18
+ } from '@shapediver/sdk.geometry-api-sdk-v2';
6
19
 
7
20
  export class Export implements IExport {
8
21
  // #region Properties (24)
@@ -24,9 +37,9 @@ export class Export implements IExport {
24
37
  #group?: ShapeDiverResponseParameterGroup;
25
38
  #hidden: boolean = false;
26
39
  #maxWaitTime: number = 300000;
27
- #msg?: string
40
+ #msg?: string;
28
41
  #order?: number;
29
- #result?: ShapeDiverResponseExportResult
42
+ #result?: ShapeDiverResponseExportResult;
30
43
  #status_collect?: ShapeDiverResponseModelComputationStatus;
31
44
  #status_computation?: ShapeDiverResponseModelComputationStatus;
32
45
  #tooltip?: string;
@@ -48,7 +61,7 @@ export class Export implements IExport {
48
61
 
49
62
  // #endregion Constructors (1)
50
63
 
51
- // #region Public Accessors (24)
64
+ // #region Public Getters And Setters (24)
52
65
 
53
66
  public get content(): ShapeDiverResponseExportContent[] | undefined {
54
67
  return this.#content;
@@ -146,17 +159,17 @@ export class Export implements IExport {
146
159
  return this.#version;
147
160
  }
148
161
 
149
- // #endregion Public Accessors (24)
162
+ // #endregion Public Getters And Setters (24)
150
163
 
151
164
  // #region Public Methods (3)
152
165
 
153
- public async request(parameterValues: { [key: string]: string } = {}): Promise<ShapeDiverResponseExport> {
166
+ public async request(parameterValues: { [key: string]: unknown } = {}): Promise<ShapeDiverResponseExport> {
154
167
  const eventId = this.#uuidGenerator.create();
155
168
  try {
156
169
  const event: ITaskEvent = { type: TASK_TYPE.EXPORT_REQUEST, id: eventId, progress: 0, status: 'Requesting export' };
157
170
  this.#eventEngine.emitEvent(EVENTTYPE.TASK.TASK_START, event);
158
171
 
159
- if(Object.keys(parameterValues).length === 0) {
172
+ if (Object.keys(parameterValues).length === 0) {
160
173
  this.#logger.info(`Export(${this.#id}).request: Sending export request with parameters ${JSON.stringify(parameterValues)}.`);
161
174
  } else {
162
175
  this.#logger.debugLow(`Export(${this.#id}).request: Sending export request.`);