@shapediver/viewer.session-engine.session-engine 2.9.10 → 2.10.0
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.
- package/dist/implementation/OutputDelayException.js +1 -5
- package/dist/implementation/OutputDelayException.js.map +1 -1
- package/dist/implementation/OutputLoader.js +26 -30
- package/dist/implementation/OutputLoader.js.map +1 -1
- package/dist/implementation/SessionData.js +2 -6
- package/dist/implementation/SessionData.js.map +1 -1
- package/dist/implementation/SessionEngine.d.ts +7 -4
- package/dist/implementation/SessionEngine.d.ts.map +1 -1
- package/dist/implementation/SessionEngine.js +180 -150
- package/dist/implementation/SessionEngine.js.map +1 -1
- package/dist/implementation/SessionOutputData.js +2 -6
- package/dist/implementation/SessionOutputData.js.map +1 -1
- package/dist/implementation/SessionTreeNode.js +2 -6
- package/dist/implementation/SessionTreeNode.js.map +1 -1
- package/dist/implementation/dto/Export.js +13 -17
- package/dist/implementation/dto/Export.js.map +1 -1
- package/dist/implementation/dto/FileParameter.js +7 -30
- package/dist/implementation/dto/FileParameter.js.map +1 -1
- package/dist/implementation/dto/Output.d.ts +1 -0
- package/dist/implementation/dto/Output.d.ts.map +1 -1
- package/dist/implementation/dto/Output.js +7 -9
- package/dist/implementation/dto/Output.js.map +1 -1
- package/dist/implementation/dto/Parameter.js +33 -56
- package/dist/implementation/dto/Parameter.js.map +1 -1
- package/dist/index.js +11 -20
- package/dist/index.js.map +1 -1
- package/dist/interfaces/ISessionData.js +1 -2
- package/dist/interfaces/ISessionEngine.d.ts +4 -1
- package/dist/interfaces/ISessionEngine.d.ts.map +1 -1
- package/dist/interfaces/ISessionEngine.js +4 -7
- package/dist/interfaces/ISessionEngine.js.map +1 -1
- package/dist/interfaces/ISessionOutputData.js +1 -2
- package/dist/interfaces/ISessionTreeNode.js +1 -2
- package/dist/interfaces/dto/IExport.js +1 -2
- package/dist/interfaces/dto/IFileParameter.js +1 -2
- package/dist/interfaces/dto/IOutput.d.ts +1 -0
- package/dist/interfaces/dto/IOutput.d.ts.map +1 -1
- package/dist/interfaces/dto/IOutput.js +1 -2
- package/dist/interfaces/dto/IParameter.js +1 -2
- package/package.json +10 -10
- package/src/implementation/SessionEngine.ts +63 -18
- package/src/implementation/dto/Output.ts +2 -0
- package/src/interfaces/ISessionEngine.ts +4 -1
- package/src/interfaces/dto/IOutput.ts +1 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -20,45 +19,43 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
20
19
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
21
20
|
};
|
|
22
21
|
var _SessionEngine_customizationProcess, _SessionEngine_parameterHistory, _SessionEngine_parameterHistoryCall, _SessionEngine_parameterHistoryForward;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const viewer_settings_1 = require("@shapediver/viewer.settings");
|
|
39
|
-
class SessionEngine {
|
|
22
|
+
import { HttpClient, PerformanceEvaluator, UuidGenerator, SystemInfo, Logger, ShapeDiverViewerSessionError, SettingsEngine, EVENTTYPE, EventEngine, StateEngine, ShapeDiverViewerSettingsError } from '@shapediver/viewer.shared.services';
|
|
23
|
+
import { OutputDelayException } from './OutputDelayException';
|
|
24
|
+
import { OutputLoader } from './OutputLoader';
|
|
25
|
+
import { SessionTreeNode } from './SessionTreeNode';
|
|
26
|
+
import { PARAMETER_TYPE } from '../interfaces/ISessionEngine';
|
|
27
|
+
import { SessionData } from './SessionData';
|
|
28
|
+
import { create, ShapeDiverResponseErrorType, ShapeDiverRequestGltfUploadQueryConversion, ShapeDiverResponseExportDefinitionType, ShapeDiverSdkConfigType, ShapeDiverResponseModelComputationStatus, isGBResponseError } from '@shapediver/sdk.geometry-api-sdk-v2';
|
|
29
|
+
import { Tree, TreeNode } from '@shapediver/viewer.shared.node-tree';
|
|
30
|
+
import { TASK_TYPE } from '@shapediver/viewer.shared.types';
|
|
31
|
+
import { FileParameter } from './dto/FileParameter';
|
|
32
|
+
import { Parameter } from './dto/Parameter';
|
|
33
|
+
import { Export } from './dto/Export';
|
|
34
|
+
import { Output } from './dto/Output';
|
|
35
|
+
import { convert, latestVersion, validate } from '@shapediver/viewer.settings';
|
|
36
|
+
export class SessionEngine {
|
|
40
37
|
// #endregion Properties (43)
|
|
41
38
|
// #region Constructors (1)
|
|
42
39
|
/**
|
|
43
|
-
* Can be use to initialize a session with the ticket and modelViewUrl and returns a scene graph node with the result.
|
|
40
|
+
* Can be use to initialize a session with the ticket/guid and modelViewUrl and returns a scene graph node with the result.
|
|
44
41
|
* Can be use to customize the session with updated parameters to get the updated scene graph node.
|
|
45
42
|
*/
|
|
46
43
|
constructor(properties) {
|
|
47
44
|
// #region Properties (43)
|
|
48
|
-
this._eventEngine =
|
|
45
|
+
this._eventEngine = EventEngine.instance;
|
|
49
46
|
this._exports = {};
|
|
50
|
-
this._httpClient =
|
|
51
|
-
this._logger =
|
|
47
|
+
this._httpClient = HttpClient.instance;
|
|
48
|
+
this._logger = Logger.instance;
|
|
52
49
|
this._outputs = {};
|
|
53
50
|
this._outputsFreeze = {};
|
|
54
51
|
this._parameterValues = {};
|
|
55
52
|
this._parameters = {};
|
|
56
|
-
this._performanceEvaluator =
|
|
57
|
-
this._sceneTree =
|
|
58
|
-
this._sessionEngineId = (
|
|
59
|
-
this._settingsEngine = new
|
|
60
|
-
this._stateEngine =
|
|
61
|
-
this._uuidGenerator =
|
|
53
|
+
this._performanceEvaluator = PerformanceEvaluator.instance;
|
|
54
|
+
this._sceneTree = Tree.instance;
|
|
55
|
+
this._sessionEngineId = (UuidGenerator.instance).create();
|
|
56
|
+
this._settingsEngine = new SettingsEngine();
|
|
57
|
+
this._stateEngine = StateEngine.instance;
|
|
58
|
+
this._uuidGenerator = UuidGenerator.instance;
|
|
62
59
|
_SessionEngine_customizationProcess.set(this, void 0);
|
|
63
60
|
_SessionEngine_parameterHistory.set(this, []);
|
|
64
61
|
_SessionEngine_parameterHistoryCall.set(this, false);
|
|
@@ -70,7 +67,7 @@ class SessionEngine {
|
|
|
70
67
|
this._dataCache = {};
|
|
71
68
|
this._excludeViewports = [];
|
|
72
69
|
this._headers = {
|
|
73
|
-
"X-ShapeDiver-Origin": (
|
|
70
|
+
"X-ShapeDiver-Origin": (SystemInfo.instance).origin,
|
|
74
71
|
"X-ShapeDiver-SessionEngineId": this._sessionEngineId,
|
|
75
72
|
"X-ShapeDiver-BuildVersion": '',
|
|
76
73
|
"X-ShapeDiver-BuildDate": ''
|
|
@@ -78,20 +75,21 @@ class SessionEngine {
|
|
|
78
75
|
this._initialized = false;
|
|
79
76
|
this._retryCounter = 0;
|
|
80
77
|
this._updateCallback = null;
|
|
81
|
-
this._viewerSettingsVersion =
|
|
82
|
-
this._viewerSettingsVersionBackend =
|
|
78
|
+
this._viewerSettingsVersion = latestVersion;
|
|
79
|
+
this._viewerSettingsVersionBackend = latestVersion;
|
|
83
80
|
this._id = properties.id;
|
|
84
|
-
this._node = new
|
|
81
|
+
this._node = new TreeNode(properties.id);
|
|
82
|
+
this._guid = properties.guid;
|
|
85
83
|
this._ticket = properties.ticket;
|
|
86
84
|
this._modelViewUrl = properties.modelViewUrl;
|
|
87
85
|
this._excludeViewports = properties.excludeViewports || [];
|
|
88
86
|
this._jwtToken = properties.jwtToken;
|
|
89
87
|
this._headers['X-ShapeDiver-BuildDate'] = properties.buildDate;
|
|
90
88
|
this._headers['X-ShapeDiver-BuildVersion'] = properties.buildVersion;
|
|
91
|
-
this._outputLoader = new
|
|
89
|
+
this._outputLoader = new OutputLoader(this);
|
|
92
90
|
try {
|
|
93
|
-
this._sdk =
|
|
94
|
-
this._sdk.setConfigurationValue(
|
|
91
|
+
this._sdk = create(this._modelViewUrl, this._jwtToken);
|
|
92
|
+
this._sdk.setConfigurationValue(ShapeDiverSdkConfigType.REQUEST_HEADERS, this._headers);
|
|
95
93
|
}
|
|
96
94
|
catch (e) {
|
|
97
95
|
throw this._httpClient.convertError(e);
|
|
@@ -131,6 +129,9 @@ class SessionEngine {
|
|
|
131
129
|
get exports() {
|
|
132
130
|
return this._exports;
|
|
133
131
|
}
|
|
132
|
+
get guid() {
|
|
133
|
+
return this._guid;
|
|
134
|
+
}
|
|
134
135
|
get id() {
|
|
135
136
|
return this._id;
|
|
136
137
|
}
|
|
@@ -194,21 +195,21 @@ class SessionEngine {
|
|
|
194
195
|
if (sections.session.export === undefined)
|
|
195
196
|
sections.session.export = { displayname: false, order: false, hidden: false };
|
|
196
197
|
if (sections.viewport === undefined)
|
|
197
|
-
sections.viewport = { ar: false, scene: false, camera: false, light: false, environment: false, general: false };
|
|
198
|
+
sections.viewport = { ar: false, scene: false, camera: false, light: false, environment: false, general: false, postprocessing: false };
|
|
198
199
|
let config;
|
|
199
200
|
if (response.viewer !== undefined) {
|
|
200
201
|
config = response.viewer.config;
|
|
201
202
|
}
|
|
202
203
|
else {
|
|
203
|
-
throw new
|
|
204
|
+
throw new ShapeDiverViewerSettingsError('Session.applySettings: No config object available.');
|
|
204
205
|
}
|
|
205
206
|
try {
|
|
206
|
-
|
|
207
|
+
validate(config);
|
|
207
208
|
}
|
|
208
209
|
catch (e) {
|
|
209
|
-
throw new
|
|
210
|
+
throw new ShapeDiverViewerSettingsError('Session.applySettings: Was not able to validate config object.');
|
|
210
211
|
}
|
|
211
|
-
const settings =
|
|
212
|
+
const settings = convert(config, latestVersion);
|
|
212
213
|
const exportMappingUid = {};
|
|
213
214
|
if (sections.session.export.displayname || sections.session.export.order || sections.session.export.hidden)
|
|
214
215
|
if (response.exports)
|
|
@@ -278,7 +279,7 @@ class SessionEngine {
|
|
|
278
279
|
currentSettings.environmentGeometry.groundPlaneShadowColor = settings.environmentGeometry.groundPlaneShadowColor;
|
|
279
280
|
currentSettings.environmentGeometry.groundPlaneShadowVisibility = settings.environmentGeometry.groundPlaneShadowVisibility;
|
|
280
281
|
currentSettings.rendering.shadows = settings.rendering.shadows;
|
|
281
|
-
currentSettings.rendering.
|
|
282
|
+
currentSettings.rendering.softShadows = settings.rendering.softShadows;
|
|
282
283
|
currentSettings.rendering.automaticColorAdjustment = settings.rendering.automaticColorAdjustment;
|
|
283
284
|
currentSettings.rendering.textureEncoding = settings.rendering.textureEncoding;
|
|
284
285
|
currentSettings.rendering.outputEncoding = settings.rendering.outputEncoding;
|
|
@@ -291,6 +292,9 @@ class SessionEngine {
|
|
|
291
292
|
currentSettings.general.commitParameters = settings.general.commitParameters;
|
|
292
293
|
currentSettings.general.pointSize = settings.general.pointSize;
|
|
293
294
|
}
|
|
295
|
+
// apply postprocessing settings
|
|
296
|
+
if (sections.viewport.postprocessing)
|
|
297
|
+
currentSettings.postprocessing = settings.postprocessing;
|
|
294
298
|
// apply environment settings
|
|
295
299
|
if (sections.viewport.environment) {
|
|
296
300
|
currentSettings.environment.clearAlpha = settings.environment.clearAlpha;
|
|
@@ -346,19 +350,20 @@ class SessionEngine {
|
|
|
346
350
|
if (changes === false)
|
|
347
351
|
return this.node;
|
|
348
352
|
}
|
|
349
|
-
const eventStart = { type:
|
|
350
|
-
this._eventEngine.emitEvent(
|
|
353
|
+
const eventStart = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0, data: { sessionId: this.id }, status: 'Customizing session' };
|
|
354
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_START, eventStart);
|
|
351
355
|
const oldNode = this.node.cloneInstance();
|
|
352
356
|
__classPrivateFieldSet(this, _SessionEngine_customizationProcess, customizationId, "f");
|
|
353
357
|
this._logger.debugLow(`Session(${this.id}).customize: Customizing session.`);
|
|
354
358
|
for (let r in this._stateEngine.renderingEngines)
|
|
355
|
-
this.
|
|
356
|
-
|
|
357
|
-
|
|
359
|
+
if (!this.excludeViewports.includes(r))
|
|
360
|
+
this._stateEngine.renderingEngines[r].busy.push(customizationId);
|
|
361
|
+
const eventFileUpload = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0.1, data: { sessionId: this.id }, status: 'Uploading file parameters' };
|
|
362
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_PROCESS, eventFileUpload);
|
|
358
363
|
const fileParameterIds = {};
|
|
359
364
|
// load file parameter first
|
|
360
365
|
for (const parameterId in this.parameters) {
|
|
361
|
-
if (this.parameters[parameterId] instanceof
|
|
366
|
+
if (this.parameters[parameterId] instanceof FileParameter) {
|
|
362
367
|
fileParameterIds[parameterId] = yield this.parameters[parameterId].upload();
|
|
363
368
|
// OPTION TO SKIP - PART 1a
|
|
364
369
|
if (__classPrivateFieldGet(this, _SessionEngine_customizationProcess, "f") !== customizationId) {
|
|
@@ -366,18 +371,18 @@ class SessionEngine {
|
|
|
366
371
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
367
372
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
368
373
|
this._logger.debug(`Session(${this.id}).customize: Session customization was exceeded by other customization request.`);
|
|
369
|
-
const eventCancel1a = { type:
|
|
370
|
-
this._eventEngine.emitEvent(
|
|
371
|
-
return new
|
|
374
|
+
const eventCancel1a = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customization was exceeded by other customization request' };
|
|
375
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel1a);
|
|
376
|
+
return new SessionTreeNode();
|
|
372
377
|
}
|
|
373
378
|
else if (this._closed === true) {
|
|
374
379
|
for (let r in this._stateEngine.renderingEngines)
|
|
375
380
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
376
381
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
377
382
|
this._logger.debug(`Session(${this.id}).customize: Session was closed during customization request.`);
|
|
378
|
-
const eventCancel1a = { type:
|
|
379
|
-
this._eventEngine.emitEvent(
|
|
380
|
-
return new
|
|
383
|
+
const eventCancel1a = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session was closed during customization request' };
|
|
384
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel1a);
|
|
385
|
+
return new SessionTreeNode();
|
|
381
386
|
}
|
|
382
387
|
}
|
|
383
388
|
}
|
|
@@ -386,19 +391,19 @@ class SessionEngine {
|
|
|
386
391
|
for (let r in this._stateEngine.renderingEngines)
|
|
387
392
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
388
393
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
389
|
-
const eventCancel1b = { type:
|
|
390
|
-
this._eventEngine.emitEvent(
|
|
394
|
+
const eventCancel1b = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customization was exceeded by other customization request' };
|
|
395
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel1b);
|
|
391
396
|
this._logger.debug(`Session(${this.id}).customize: Session customization was exceeded by other customization request.`);
|
|
392
|
-
return new
|
|
397
|
+
return new SessionTreeNode();
|
|
393
398
|
}
|
|
394
399
|
else if (this._closed === true) {
|
|
395
400
|
for (let r in this._stateEngine.renderingEngines)
|
|
396
401
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
397
402
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
398
403
|
this._logger.debug(`Session(${this.id}).customize: Session was closed during customization request.`);
|
|
399
|
-
const eventCancel1b = { type:
|
|
400
|
-
this._eventEngine.emitEvent(
|
|
401
|
-
return new
|
|
404
|
+
const eventCancel1b = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session was closed during customization request' };
|
|
405
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel1b);
|
|
406
|
+
return new SessionTreeNode();
|
|
402
407
|
}
|
|
403
408
|
// assign the uploaded parameters
|
|
404
409
|
for (const parameterId in fileParameterIds)
|
|
@@ -415,26 +420,26 @@ class SessionEngine {
|
|
|
415
420
|
for (const parameterId in this.parameters)
|
|
416
421
|
this.parameterValues[parameterId] = parameterSet[parameterId].valueString;
|
|
417
422
|
this._logger.info(`Session(${this.id}).customize: Customizing session with parameters ${JSON.stringify(this.parameterValues)}.`);
|
|
418
|
-
const eventRequest = { type:
|
|
419
|
-
this._eventEngine.emitEvent(
|
|
423
|
+
const eventRequest = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0.1, data: { sessionId: this.id }, status: 'Sending customization request' };
|
|
424
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_PROCESS, eventRequest);
|
|
420
425
|
const newNode = yield this.customizeInternal(() => __classPrivateFieldGet(this, _SessionEngine_customizationProcess, "f") !== customizationId, {
|
|
421
426
|
eventId,
|
|
422
|
-
type:
|
|
427
|
+
type: TASK_TYPE.SESSION_CUSTOMIZATION,
|
|
423
428
|
progressRange: {
|
|
424
429
|
min: 0.1,
|
|
425
430
|
max: 0.9
|
|
426
431
|
},
|
|
427
432
|
data: { sessionId: this.id }
|
|
428
433
|
});
|
|
429
|
-
const eventSceneUpdate = { type:
|
|
430
|
-
this._eventEngine.emitEvent(
|
|
434
|
+
const eventSceneUpdate = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0.9, data: { sessionId: this.id }, status: 'Updating scene' };
|
|
435
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_PROCESS, eventSceneUpdate);
|
|
431
436
|
// OPTION TO SKIP - PART 2
|
|
432
437
|
if (__classPrivateFieldGet(this, _SessionEngine_customizationProcess, "f") !== customizationId) {
|
|
433
438
|
for (let r in this._stateEngine.renderingEngines)
|
|
434
439
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
435
440
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
436
|
-
const eventCancel2 = { type:
|
|
437
|
-
this._eventEngine.emitEvent(
|
|
441
|
+
const eventCancel2 = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customization was exceeded by other customization request' };
|
|
442
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel2);
|
|
438
443
|
this._logger.debug(`Session(${this.id}).customize: Session customization was exceeded by other customization request.`);
|
|
439
444
|
return newNode;
|
|
440
445
|
}
|
|
@@ -443,9 +448,9 @@ class SessionEngine {
|
|
|
443
448
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
444
449
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
445
450
|
this._logger.debug(`Session(${this.id}).customize: Session was closed during customization request.`);
|
|
446
|
-
const eventCancel2 = { type:
|
|
447
|
-
this._eventEngine.emitEvent(
|
|
448
|
-
return new
|
|
451
|
+
const eventCancel2 = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session was closed during customization request' };
|
|
452
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel2);
|
|
453
|
+
return new SessionTreeNode();
|
|
449
454
|
}
|
|
450
455
|
// if this is not a call by the goBack or goForward functions, add the parameter values to the history and delete the forward history
|
|
451
456
|
if (!__classPrivateFieldGet(this, _SessionEngine_parameterHistoryCall, "f")) {
|
|
@@ -461,8 +466,6 @@ class SessionEngine {
|
|
|
461
466
|
// set the session values to the current ones in all parameters
|
|
462
467
|
for (const parameterId in this.parameters)
|
|
463
468
|
this.parameters[parameterId].sessionValue = parameterSet[parameterId].value;
|
|
464
|
-
if (this._updateCallback)
|
|
465
|
-
this._updateCallback(newNode, oldNode);
|
|
466
469
|
// set the output content to what has been updated
|
|
467
470
|
for (const outputId in this.outputs)
|
|
468
471
|
this.outputs[outputId].updateOutput(newNode.children.find(c => c.name === outputId), oldNode.children.find(c => c.name === outputId));
|
|
@@ -475,14 +478,24 @@ class SessionEngine {
|
|
|
475
478
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
476
479
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
477
480
|
this._logger.debug(`Session(${this.id}).customize: Session customized.`);
|
|
478
|
-
this._eventEngine.emitEvent(
|
|
479
|
-
const eventEnd = { type:
|
|
480
|
-
this._eventEngine.emitEvent(
|
|
481
|
+
this._eventEngine.emitEvent(EVENTTYPE.SESSION.SESSION_CUSTOMIZED, { sessionId: this.id });
|
|
482
|
+
const eventEnd = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customized' };
|
|
483
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_END, eventEnd);
|
|
484
|
+
// update the viewports
|
|
485
|
+
for (let r in this._stateEngine.renderingEngines)
|
|
486
|
+
if (!this.excludeViewports.includes(this._stateEngine.renderingEngines[r].id))
|
|
487
|
+
this._stateEngine.renderingEngines[r].update(`SessionEngine(${this.id}).customize`);
|
|
488
|
+
// call the update callback function on the session
|
|
489
|
+
if (this._updateCallback)
|
|
490
|
+
this._updateCallback(newNode, oldNode);
|
|
491
|
+
// call the update callback functions on the outputs
|
|
492
|
+
for (const outputId in this.outputs)
|
|
493
|
+
this.outputs[outputId].triggerUpdateCallback(newNode.children.find(c => c.name === outputId), oldNode.children.find(c => c.name === outputId));
|
|
481
494
|
return this.node;
|
|
482
495
|
}
|
|
483
496
|
catch (e) {
|
|
484
|
-
const eventCancel = { type:
|
|
485
|
-
this._eventEngine.emitEvent(
|
|
497
|
+
const eventCancel = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customization failed' };
|
|
498
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel);
|
|
486
499
|
for (let r in this._stateEngine.renderingEngines)
|
|
487
500
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
488
501
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
@@ -493,15 +506,15 @@ class SessionEngine {
|
|
|
493
506
|
customizeParallel(parameterValues) {
|
|
494
507
|
return __awaiter(this, void 0, void 0, function* () {
|
|
495
508
|
const eventId = this._uuidGenerator.create();
|
|
496
|
-
const eventStart = { type:
|
|
497
|
-
this._eventEngine.emitEvent(
|
|
509
|
+
const eventStart = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0, data: { sessionId: this.id }, status: 'Customizing session' };
|
|
510
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_START, eventStart);
|
|
498
511
|
const parameterSet = {};
|
|
499
512
|
// create a set of the current validated parameter values
|
|
500
513
|
for (const parameterId in this.parameters)
|
|
501
514
|
parameterSet[parameterId] = parameterValues[parameterId] !== undefined ? (' ' + parameterValues[parameterId]).slice(1) : this.parameters[parameterId].stringify();
|
|
502
515
|
const newNode = yield this.customizeSession(parameterSet, () => false, {
|
|
503
516
|
eventId,
|
|
504
|
-
type:
|
|
517
|
+
type: TASK_TYPE.SESSION_CUSTOMIZATION,
|
|
505
518
|
progressRange: {
|
|
506
519
|
min: 0.0,
|
|
507
520
|
max: 1
|
|
@@ -509,8 +522,8 @@ class SessionEngine {
|
|
|
509
522
|
data: { sessionId: this.id }
|
|
510
523
|
}, true);
|
|
511
524
|
newNode.excludeViewports = JSON.parse(JSON.stringify(this._excludeViewports));
|
|
512
|
-
const eventEnd = { type:
|
|
513
|
-
this._eventEngine.emitEvent(
|
|
525
|
+
const eventEnd = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customized' };
|
|
526
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_END, eventEnd);
|
|
514
527
|
return newNode;
|
|
515
528
|
});
|
|
516
529
|
}
|
|
@@ -518,7 +531,7 @@ class SessionEngine {
|
|
|
518
531
|
return __awaiter(this, void 0, void 0, function* () {
|
|
519
532
|
if (!this.canGoBack()) {
|
|
520
533
|
this._logger.debug(`Session(${this.id}).goBack: Cannot go further back.`);
|
|
521
|
-
return new
|
|
534
|
+
return new TreeNode();
|
|
522
535
|
}
|
|
523
536
|
// get the current parameter set and store it in the forward history later on
|
|
524
537
|
const currentParameterSet = __classPrivateFieldGet(this, _SessionEngine_parameterHistory, "f").pop();
|
|
@@ -539,7 +552,7 @@ class SessionEngine {
|
|
|
539
552
|
return __awaiter(this, void 0, void 0, function* () {
|
|
540
553
|
if (!this.canGoForward()) {
|
|
541
554
|
this._logger.debug(`Session(${this.id}).goForward: Cannot go further forward.`);
|
|
542
|
-
return new
|
|
555
|
+
return new TreeNode();
|
|
543
556
|
}
|
|
544
557
|
// get the last undone parameter set and apply the values to the parameters
|
|
545
558
|
const lastParameterSet = __classPrivateFieldGet(this, _SessionEngine_parameterHistoryForward, "f").pop();
|
|
@@ -563,17 +576,26 @@ class SessionEngine {
|
|
|
563
576
|
var _a, _b;
|
|
564
577
|
return __awaiter(this, void 0, void 0, function* () {
|
|
565
578
|
if (this._initialized === true)
|
|
566
|
-
throw new
|
|
579
|
+
throw new ShapeDiverViewerSessionError('Session.init: Session already initialized.');
|
|
567
580
|
try {
|
|
568
581
|
this._performanceEvaluator.startSection('sessionResponse');
|
|
569
582
|
const parameterSet = {};
|
|
570
583
|
// the slice here is done as a way for deep copying the string values
|
|
571
584
|
for (const parameterNameOrId in parameterValues)
|
|
572
585
|
parameterSet[parameterNameOrId] = (' ' + parameterValues[parameterNameOrId]).slice(1);
|
|
573
|
-
|
|
586
|
+
if (this._ticket) {
|
|
587
|
+
this._responseDto = yield this._sdk.session.init(this._ticket, parameterSet);
|
|
588
|
+
}
|
|
589
|
+
else if (this._guid) {
|
|
590
|
+
this._responseDto = yield this._sdk.session.initForModel(this._guid, parameterSet);
|
|
591
|
+
}
|
|
592
|
+
else {
|
|
593
|
+
// we should never get here
|
|
594
|
+
throw new ShapeDiverViewerSessionError(`Session.init: Initialization of session failed. Neither a ticket nor a guid are available.`);
|
|
595
|
+
}
|
|
574
596
|
this._performanceEvaluator.endSection('sessionResponse');
|
|
575
597
|
this._viewerSettings = (_a = this._responseDto.viewer) === null || _a === void 0 ? void 0 : _a.config;
|
|
576
|
-
this._viewerSettingsVersionBackend = this._responseDto.viewerSettingsVersion ||
|
|
598
|
+
this._viewerSettingsVersionBackend = this._responseDto.viewerSettingsVersion || latestVersion;
|
|
577
599
|
this._sessionId = this._responseDto.sessionId;
|
|
578
600
|
this._modelId = (_b = this._responseDto.model) === null || _b === void 0 ? void 0 : _b.id;
|
|
579
601
|
this._httpClient.addDataLoading(this._sessionId, {
|
|
@@ -582,9 +604,9 @@ class SessionEngine {
|
|
|
582
604
|
});
|
|
583
605
|
this._settingsEngine.loadSettings(this._viewerSettings);
|
|
584
606
|
if (!this._sessionId)
|
|
585
|
-
throw new
|
|
607
|
+
throw new ShapeDiverViewerSessionError(`Session.init: Initialization of session failed. ResponseDto did not have a sessionId.`);
|
|
586
608
|
if (!this._modelId)
|
|
587
|
-
throw new
|
|
609
|
+
throw new ShapeDiverViewerSessionError(`Session.init: Initialization of session failed. ResponseDto did not have a model.id.`);
|
|
588
610
|
this.updateResponseDto(this._responseDto, parameterSet);
|
|
589
611
|
this._initialized = true;
|
|
590
612
|
}
|
|
@@ -612,39 +634,39 @@ class SessionEngine {
|
|
|
612
634
|
responseDto.outputs[outputId].id = outputId;
|
|
613
635
|
if (this.outputsFreeze[outputId] === undefined)
|
|
614
636
|
outputsFreeze[outputId] = false;
|
|
615
|
-
outputs[outputId] = new
|
|
637
|
+
outputs[outputId] = new Output(responseDto.outputs[outputId], this);
|
|
616
638
|
}
|
|
617
639
|
try {
|
|
618
640
|
const node = yield this._outputLoader.loadOutputs(((_a = this._responseDto.model) === null || _a === void 0 ? void 0 : _a.name) || 'model', outputs, outputsFreeze, taskEventInfo);
|
|
619
|
-
node.data.push(new
|
|
641
|
+
node.data.push(new SessionData(responseDto));
|
|
620
642
|
return node;
|
|
621
643
|
}
|
|
622
644
|
catch (e) {
|
|
623
|
-
if (e instanceof
|
|
645
|
+
if (e instanceof OutputDelayException) {
|
|
624
646
|
yield this.timeout(e.delay);
|
|
625
647
|
}
|
|
626
648
|
else {
|
|
627
649
|
yield this.handleError(e, retry);
|
|
628
650
|
if (cancelRequest())
|
|
629
|
-
return new
|
|
651
|
+
return new SessionTreeNode();
|
|
630
652
|
return yield this.loadOutputsParallel(responseDto, cancelRequest, taskEventInfo, true);
|
|
631
653
|
}
|
|
632
654
|
if (cancelRequest())
|
|
633
|
-
return new
|
|
655
|
+
return new SessionTreeNode();
|
|
634
656
|
let outputMapping = {};
|
|
635
657
|
for (let output in outputs)
|
|
636
658
|
outputMapping[output] = outputs[output].version;
|
|
637
659
|
try {
|
|
638
660
|
const responseDto = yield this._sdk.output.getCache(this._sessionId, outputMapping);
|
|
639
661
|
if (cancelRequest())
|
|
640
|
-
return new
|
|
662
|
+
return new SessionTreeNode();
|
|
641
663
|
this.updateResponseDto(responseDto);
|
|
642
664
|
return yield this.loadOutputsParallel(responseDto, cancelRequest, taskEventInfo);
|
|
643
665
|
}
|
|
644
666
|
catch (e) {
|
|
645
667
|
yield this.handleError(e, retry);
|
|
646
668
|
if (cancelRequest())
|
|
647
|
-
return new
|
|
669
|
+
return new SessionTreeNode();
|
|
648
670
|
return yield this.loadOutputsParallel(responseDto, cancelRequest, taskEventInfo, true);
|
|
649
671
|
}
|
|
650
672
|
}
|
|
@@ -666,7 +688,7 @@ class SessionEngine {
|
|
|
666
688
|
const of = Object.assign({}, this._outputsFreeze);
|
|
667
689
|
try {
|
|
668
690
|
const node = yield this._outputLoader.loadOutputs(((_a = this._responseDto.model) === null || _a === void 0 ? void 0 : _a.name) || 'model', o, of, taskEventInfo);
|
|
669
|
-
node.data.push(new
|
|
691
|
+
node.data.push(new SessionData(this._responseDto));
|
|
670
692
|
if (cancelRequest())
|
|
671
693
|
return node;
|
|
672
694
|
if (this._automaticSceneUpdate)
|
|
@@ -678,31 +700,31 @@ class SessionEngine {
|
|
|
678
700
|
return node;
|
|
679
701
|
}
|
|
680
702
|
catch (e) {
|
|
681
|
-
if (e instanceof
|
|
703
|
+
if (e instanceof OutputDelayException) {
|
|
682
704
|
yield this.timeout(e.delay);
|
|
683
705
|
}
|
|
684
706
|
else {
|
|
685
707
|
yield this.handleError(e, retry);
|
|
686
708
|
if (cancelRequest())
|
|
687
|
-
return new
|
|
709
|
+
return new SessionTreeNode();
|
|
688
710
|
return yield this.loadOutputs(cancelRequest, taskEventInfo, true);
|
|
689
711
|
}
|
|
690
712
|
if (cancelRequest())
|
|
691
|
-
return new
|
|
713
|
+
return new SessionTreeNode();
|
|
692
714
|
let outputMapping = {};
|
|
693
715
|
for (let output in o)
|
|
694
716
|
outputMapping[output] = o[output].version;
|
|
695
717
|
try {
|
|
696
718
|
const responseDto = yield this._sdk.output.getCache(this._sessionId, outputMapping);
|
|
697
719
|
if (cancelRequest())
|
|
698
|
-
return new
|
|
720
|
+
return new SessionTreeNode();
|
|
699
721
|
this.updateResponseDto(responseDto);
|
|
700
722
|
return yield this.loadOutputs(cancelRequest, taskEventInfo);
|
|
701
723
|
}
|
|
702
724
|
catch (e) {
|
|
703
725
|
yield this.handleError(e, retry);
|
|
704
726
|
if (cancelRequest())
|
|
705
|
-
return new
|
|
727
|
+
return new SessionTreeNode();
|
|
706
728
|
return yield this.loadOutputs(cancelRequest, taskEventInfo, true);
|
|
707
729
|
}
|
|
708
730
|
}
|
|
@@ -745,7 +767,7 @@ class SessionEngine {
|
|
|
745
767
|
}
|
|
746
768
|
resetSettings(sections) {
|
|
747
769
|
if (!this._responseDto)
|
|
748
|
-
throw new
|
|
770
|
+
throw new ShapeDiverViewerSessionError(`Session.resetSettings: responseDto not available.`);
|
|
749
771
|
sections = sections || {};
|
|
750
772
|
if (sections.session === undefined) {
|
|
751
773
|
sections.session = {
|
|
@@ -758,7 +780,7 @@ class SessionEngine {
|
|
|
758
780
|
if (sections.session.export === undefined)
|
|
759
781
|
sections.session.export = { displayname: true, order: true, hidden: true };
|
|
760
782
|
if (sections.viewport === undefined)
|
|
761
|
-
sections.viewport = { ar: true, scene: true, camera: true, light: true, environment: true, general: true };
|
|
783
|
+
sections.viewport = { ar: true, scene: true, camera: true, light: true, environment: true, general: true, postprocessing: true };
|
|
762
784
|
return this.applySettings(this._responseDto, sections);
|
|
763
785
|
}
|
|
764
786
|
saveDefaultParameterValues() {
|
|
@@ -769,7 +791,7 @@ class SessionEngine {
|
|
|
769
791
|
this._logger.debug(`Session(${this.id}).saveDefaultParameters: Saved default parameters.`);
|
|
770
792
|
}
|
|
771
793
|
else {
|
|
772
|
-
throw new
|
|
794
|
+
throw new ShapeDiverViewerSessionError(`Session(${this.id}).saveDefaultParameters: Could not save default parameters.`);
|
|
773
795
|
}
|
|
774
796
|
return response;
|
|
775
797
|
});
|
|
@@ -848,14 +870,14 @@ class SessionEngine {
|
|
|
848
870
|
return __awaiter(this, void 0, void 0, function* () {
|
|
849
871
|
this.checkAvailability('configure', true);
|
|
850
872
|
try {
|
|
851
|
-
|
|
873
|
+
validate(json, this._viewerSettingsVersion);
|
|
852
874
|
// if viewer settings version is higher than backend settings version
|
|
853
875
|
// convert to backend settings version
|
|
854
876
|
if (+this._viewerSettingsVersion > +this._viewerSettingsVersionBackend)
|
|
855
|
-
json =
|
|
877
|
+
json = convert(json, this._viewerSettingsVersionBackend);
|
|
856
878
|
}
|
|
857
879
|
catch (e) {
|
|
858
|
-
throw new
|
|
880
|
+
throw new ShapeDiverViewerSettingsError('Session.saveSettings: Settings could not be validated. ' + e.message, e);
|
|
859
881
|
}
|
|
860
882
|
try {
|
|
861
883
|
yield this._sdk.model.updateConfig(this._modelId, json);
|
|
@@ -918,7 +940,7 @@ class SessionEngine {
|
|
|
918
940
|
this.checkAvailability();
|
|
919
941
|
this._jwtToken = value;
|
|
920
942
|
try {
|
|
921
|
-
this._sdk.setConfigurationValue(
|
|
943
|
+
this._sdk.setConfigurationValue(ShapeDiverSdkConfigType.JWT_TOKEN, value);
|
|
922
944
|
const responseDto = yield this._sdk.session.default(this._sessionId);
|
|
923
945
|
if (this._responseDto)
|
|
924
946
|
this._responseDto.actions = responseDto.actions;
|
|
@@ -931,20 +953,21 @@ class SessionEngine {
|
|
|
931
953
|
updateOutputs(taskEventInfo) {
|
|
932
954
|
return __awaiter(this, void 0, void 0, function* () {
|
|
933
955
|
const eventId = taskEventInfo ? taskEventInfo.eventId : this._uuidGenerator.create();
|
|
934
|
-
const eventType = taskEventInfo ? taskEventInfo.type :
|
|
956
|
+
const eventType = taskEventInfo ? taskEventInfo.type : TASK_TYPE.SESSION_OUTPUTS_UPDATE;
|
|
935
957
|
const eventData = taskEventInfo ? taskEventInfo.data : { sessionId: this.id };
|
|
936
958
|
if (!taskEventInfo) {
|
|
937
959
|
const eventStart = { type: eventType, id: eventId, progress: 0, data: eventData, status: 'Updating outputs' };
|
|
938
|
-
this._eventEngine.emitEvent(
|
|
960
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_START, eventStart);
|
|
939
961
|
}
|
|
940
962
|
const customizationId = this._uuidGenerator.create();
|
|
941
963
|
const oldNode = this.node.cloneInstance();
|
|
942
964
|
__classPrivateFieldSet(this, _SessionEngine_customizationProcess, customizationId, "f");
|
|
943
965
|
this._logger.debugLow(`Session(${this.id}).updateOutputs: Updating Outputs.`);
|
|
944
966
|
for (let r in this._stateEngine.renderingEngines)
|
|
945
|
-
this.
|
|
967
|
+
if (!this.excludeViewports.includes(r))
|
|
968
|
+
this._stateEngine.renderingEngines[r].busy.push(customizationId);
|
|
946
969
|
const eventRequest = { type: eventType, id: eventId, progress: taskEventInfo ? (taskEventInfo.progressRange.max - taskEventInfo.progressRange.min) * 0.1 + taskEventInfo.progressRange.min : 0.1, data: eventData, status: 'Loading outputs' };
|
|
947
|
-
this._eventEngine.emitEvent(
|
|
970
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_PROCESS, eventRequest);
|
|
948
971
|
const newNode = yield this.loadOutputs(() => __classPrivateFieldGet(this, _SessionEngine_customizationProcess, "f") !== customizationId, {
|
|
949
972
|
eventId,
|
|
950
973
|
type: eventType,
|
|
@@ -955,14 +978,14 @@ class SessionEngine {
|
|
|
955
978
|
data: eventData
|
|
956
979
|
});
|
|
957
980
|
const eventSceneUpdate = { type: eventType, id: eventId, progress: taskEventInfo ? (taskEventInfo.progressRange.max - taskEventInfo.progressRange.min) * 0.9 + taskEventInfo.progressRange.min : 0.9, data: eventData, status: 'Updating scene' };
|
|
958
|
-
this._eventEngine.emitEvent(
|
|
981
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_PROCESS, eventSceneUpdate);
|
|
959
982
|
// OPTION TO SKIP - PART 1
|
|
960
983
|
if (__classPrivateFieldGet(this, _SessionEngine_customizationProcess, "f") !== customizationId) {
|
|
961
984
|
for (let r in this._stateEngine.renderingEngines)
|
|
962
985
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
963
986
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
964
987
|
const eventCancel1 = { type: eventType, id: eventId, progress: taskEventInfo ? (taskEventInfo.progressRange.max - taskEventInfo.progressRange.min) * 1 + taskEventInfo.progressRange.min : 1, data: eventData, status: 'Output updating was exceeded by other customization request' };
|
|
965
|
-
this._eventEngine.emitEvent(
|
|
988
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel1);
|
|
966
989
|
this._logger.debug(`Session(${this.id}).updateOutputs: Output updating was exceeded by other request.`);
|
|
967
990
|
return newNode;
|
|
968
991
|
}
|
|
@@ -971,9 +994,9 @@ class SessionEngine {
|
|
|
971
994
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
972
995
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
973
996
|
this._logger.debug(`Session(${this.id}).customize: Session was closed during customization request.`);
|
|
974
|
-
const eventCancel1a = { type:
|
|
975
|
-
this._eventEngine.emitEvent(
|
|
976
|
-
return new
|
|
997
|
+
const eventCancel1a = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session was closed during customization request' };
|
|
998
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel1a);
|
|
999
|
+
return new SessionTreeNode();
|
|
977
1000
|
}
|
|
978
1001
|
if (this.automaticSceneUpdate)
|
|
979
1002
|
this.removeFromSceneTree(this.node);
|
|
@@ -981,8 +1004,6 @@ class SessionEngine {
|
|
|
981
1004
|
if (this.automaticSceneUpdate && this._closed === false)
|
|
982
1005
|
this.addToSceneTree(this.node);
|
|
983
1006
|
this._logger.debug(`Session(${this.id}).updateOutputs: Updating outputs finished, updating geometry.`);
|
|
984
|
-
if (this._updateCallback)
|
|
985
|
-
this._updateCallback(newNode, oldNode);
|
|
986
1007
|
// set the output content to what has been updated
|
|
987
1008
|
for (const outputId in this.outputs) {
|
|
988
1009
|
this.outputs[outputId].updateOutput(newNode.children.find(c => c.name === outputId), oldNode.children.find(c => c.name === outputId));
|
|
@@ -998,8 +1019,18 @@ class SessionEngine {
|
|
|
998
1019
|
this._logger.debug(`Session(${this.id}).updateOutputs: Updated outputs.`);
|
|
999
1020
|
if (!taskEventInfo) {
|
|
1000
1021
|
const eventEnd = { type: eventType, id: eventId, progress: 1, data: eventData, status: 'Outputs updated' };
|
|
1001
|
-
this._eventEngine.emitEvent(
|
|
1022
|
+
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_END, eventEnd);
|
|
1002
1023
|
}
|
|
1024
|
+
// update the viewports
|
|
1025
|
+
for (let r in this._stateEngine.renderingEngines)
|
|
1026
|
+
if (!this.excludeViewports.includes(this._stateEngine.renderingEngines[r].id))
|
|
1027
|
+
this._stateEngine.renderingEngines[r].update(`SessionEngine(${this.id}).customize`);
|
|
1028
|
+
// call the update callback function on the session
|
|
1029
|
+
if (this._updateCallback)
|
|
1030
|
+
this._updateCallback(newNode, oldNode);
|
|
1031
|
+
// call the update callback functions on the outputs
|
|
1032
|
+
for (const outputId in this.outputs)
|
|
1033
|
+
this.outputs[outputId].triggerUpdateCallback(newNode.children.find(c => c.name === outputId), oldNode.children.find(c => c.name === outputId));
|
|
1003
1034
|
return this.node;
|
|
1004
1035
|
});
|
|
1005
1036
|
}
|
|
@@ -1016,7 +1047,7 @@ class SessionEngine {
|
|
|
1016
1047
|
return fileAsset.id;
|
|
1017
1048
|
}
|
|
1018
1049
|
else {
|
|
1019
|
-
throw new
|
|
1050
|
+
throw new ShapeDiverViewerSessionError(`Session.uploadFile: Upload reply has not the required format.`);
|
|
1020
1051
|
}
|
|
1021
1052
|
}
|
|
1022
1053
|
catch (e) {
|
|
@@ -1025,13 +1056,13 @@ class SessionEngine {
|
|
|
1025
1056
|
}
|
|
1026
1057
|
});
|
|
1027
1058
|
}
|
|
1028
|
-
uploadGLTF(blob, conversion =
|
|
1059
|
+
uploadGLTF(blob, conversion = ShapeDiverRequestGltfUploadQueryConversion.NONE, retry = false) {
|
|
1029
1060
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1030
1061
|
this.checkAvailability('gltf-upload');
|
|
1031
1062
|
try {
|
|
1032
1063
|
const responseDto = yield this._sdk.gltf.upload(this._sessionId, yield blob.arrayBuffer(), 'model/gltf-binary', conversion);
|
|
1033
1064
|
if (!responseDto || !responseDto.gltf || !responseDto.gltf.href)
|
|
1034
|
-
throw new
|
|
1065
|
+
throw new ShapeDiverViewerSessionError(`Session.uploadGLTF: Upload reply has not the required format.`);
|
|
1035
1066
|
return responseDto;
|
|
1036
1067
|
}
|
|
1037
1068
|
catch (e) {
|
|
@@ -1081,9 +1112,9 @@ class SessionEngine {
|
|
|
1081
1112
|
let warning = '';
|
|
1082
1113
|
if (this.outputs[outputId].msg)
|
|
1083
1114
|
warning += `\n\t- ${this.outputs[outputId].msg}`;
|
|
1084
|
-
if (this.outputs[outputId].status_collect && this.outputs[outputId].status_collect !==
|
|
1115
|
+
if (this.outputs[outputId].status_collect && this.outputs[outputId].status_collect !== ShapeDiverResponseModelComputationStatus.SUCCESS)
|
|
1085
1116
|
warning += `\n\t- status_collect is ${this.outputs[outputId].status_collect}`;
|
|
1086
|
-
if (this.outputs[outputId].status_computation && this.outputs[outputId].status_computation !==
|
|
1117
|
+
if (this.outputs[outputId].status_computation && this.outputs[outputId].status_computation !== ShapeDiverResponseModelComputationStatus.SUCCESS)
|
|
1087
1118
|
warning += `\n\t- status_computation is ${this.outputs[outputId].status_computation}`;
|
|
1088
1119
|
if (warning)
|
|
1089
1120
|
this._logger.warn(`\nOutput(${outputId}):${warning}`);
|
|
@@ -1093,9 +1124,9 @@ class SessionEngine {
|
|
|
1093
1124
|
let warning = '';
|
|
1094
1125
|
if (this.exports[exportId].msg)
|
|
1095
1126
|
warning += `\n\t- ${this.exports[exportId].msg}`;
|
|
1096
|
-
if (this.exports[exportId].status_collect && this.exports[exportId].status_collect !==
|
|
1127
|
+
if (this.exports[exportId].status_collect && this.exports[exportId].status_collect !== ShapeDiverResponseModelComputationStatus.SUCCESS)
|
|
1097
1128
|
warning += `\n\t- status_collect is ${this.exports[exportId].status_collect}`;
|
|
1098
|
-
if (this.exports[exportId].status_computation && this.exports[exportId].status_computation !==
|
|
1129
|
+
if (this.exports[exportId].status_computation && this.exports[exportId].status_computation !== ShapeDiverResponseModelComputationStatus.SUCCESS)
|
|
1099
1130
|
warning += `\n\t- status_computation is ${this.exports[exportId].status_computation}`;
|
|
1100
1131
|
if (warning)
|
|
1101
1132
|
this._logger.warn(`\nExport(${exportId}):${warning}`);
|
|
@@ -1108,16 +1139,16 @@ class SessionEngine {
|
|
|
1108
1139
|
checkAvailability(action, checkForModelId = false) {
|
|
1109
1140
|
var _a;
|
|
1110
1141
|
if (!this._responseDto)
|
|
1111
|
-
throw new
|
|
1142
|
+
throw new ShapeDiverViewerSessionError(`Session.checkAvailability: responseDto not available.`);
|
|
1112
1143
|
if (!this._sessionId)
|
|
1113
|
-
throw new
|
|
1144
|
+
throw new ShapeDiverViewerSessionError(`Session.checkAvailability: sessionId not available.`);
|
|
1114
1145
|
if (checkForModelId && !this._modelId)
|
|
1115
|
-
throw new
|
|
1146
|
+
throw new ShapeDiverViewerSessionError(`Session.checkAvailability: modelId not available.`);
|
|
1116
1147
|
if (action && !this._responseDto.actions)
|
|
1117
|
-
throw new
|
|
1148
|
+
throw new ShapeDiverViewerSessionError(`Session.checkAvailability: actions not available.`);
|
|
1118
1149
|
const responseDtoAction = (_a = this._responseDto.actions) === null || _a === void 0 ? void 0 : _a.find(a => a.name === action);
|
|
1119
1150
|
if (action && !responseDtoAction)
|
|
1120
|
-
throw new
|
|
1151
|
+
throw new ShapeDiverViewerSessionError(`Session.checkAvailability: action ${action} not available.`);
|
|
1121
1152
|
}
|
|
1122
1153
|
customizeInternal(cancelRequest, taskEventInfo) {
|
|
1123
1154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1132,7 +1163,7 @@ class SessionEngine {
|
|
|
1132
1163
|
const responseDto = yield this._sdk.utils.submitAndWaitForCustomization(this._sdk, this._sessionId, parameters);
|
|
1133
1164
|
this._performanceEvaluator.endSection('sessionResponse');
|
|
1134
1165
|
if (cancelRequest())
|
|
1135
|
-
return new
|
|
1166
|
+
return new SessionTreeNode();
|
|
1136
1167
|
if (parallel === false)
|
|
1137
1168
|
this.updateResponseDto(responseDto);
|
|
1138
1169
|
return parallel === false ? this.loadOutputs(cancelRequest, taskEventInfo) : this.loadOutputsParallel(responseDto, cancelRequest, taskEventInfo);
|
|
@@ -1140,15 +1171,15 @@ class SessionEngine {
|
|
|
1140
1171
|
catch (e) {
|
|
1141
1172
|
yield this.handleError(e, retry);
|
|
1142
1173
|
if (cancelRequest())
|
|
1143
|
-
return new
|
|
1174
|
+
return new SessionTreeNode();
|
|
1144
1175
|
return yield this.customizeSession(parameters, cancelRequest, taskEventInfo, parallel, true);
|
|
1145
1176
|
}
|
|
1146
1177
|
});
|
|
1147
1178
|
}
|
|
1148
1179
|
handleError(e, retry = false) {
|
|
1149
1180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1150
|
-
if (e
|
|
1151
|
-
if (e.error ===
|
|
1181
|
+
if (isGBResponseError(e)) {
|
|
1182
|
+
if (e.error === ShapeDiverResponseErrorType.SESSION_GONE_ERROR) {
|
|
1152
1183
|
// case 1: the session is no longer available
|
|
1153
1184
|
// we try to re-initialize the session 3 times, if that does not work, we close it
|
|
1154
1185
|
this._logger.warn(`The session has been closed, trying to re-initialize.`);
|
|
@@ -1170,7 +1201,7 @@ class SessionEngine {
|
|
|
1170
1201
|
throw this._httpClient.convertError(e);
|
|
1171
1202
|
}
|
|
1172
1203
|
}
|
|
1173
|
-
else if (e.error ===
|
|
1204
|
+
else if (e.error === ShapeDiverResponseErrorType.JWT_VALIDATION_ERROR) {
|
|
1174
1205
|
// if any of the above errors occur, we try to get a new bearer token
|
|
1175
1206
|
// if we get a new one, we retry 3 times (by requiring new bearer tokens every time)
|
|
1176
1207
|
if (this._retryCounter < 3) {
|
|
@@ -1257,20 +1288,20 @@ class SessionEngine {
|
|
|
1257
1288
|
continue;
|
|
1258
1289
|
this._responseDto.parameters[parameterId].id = parameterId;
|
|
1259
1290
|
switch (true) {
|
|
1260
|
-
case this._responseDto.parameters[parameterId].type ===
|
|
1261
|
-
this.parameters[parameterId] = new
|
|
1291
|
+
case this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.BOOL:
|
|
1292
|
+
this.parameters[parameterId] = new Parameter(this._responseDto.parameters[parameterId], this);
|
|
1262
1293
|
break;
|
|
1263
|
-
case this._responseDto.parameters[parameterId].type ===
|
|
1264
|
-
this.parameters[parameterId] = new
|
|
1294
|
+
case this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.COLOR:
|
|
1295
|
+
this.parameters[parameterId] = new Parameter(this._responseDto.parameters[parameterId], this);
|
|
1265
1296
|
break;
|
|
1266
|
-
case this._responseDto.parameters[parameterId].type ===
|
|
1267
|
-
this.parameters[parameterId] = new
|
|
1297
|
+
case this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.FILE:
|
|
1298
|
+
this.parameters[parameterId] = new FileParameter(this._responseDto.parameters[parameterId], this);
|
|
1268
1299
|
break;
|
|
1269
|
-
case this._responseDto.parameters[parameterId].type ===
|
|
1270
|
-
this.parameters[parameterId] = new
|
|
1300
|
+
case this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.EVEN || this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.FLOAT || this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.INT || this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.ODD:
|
|
1301
|
+
this.parameters[parameterId] = new Parameter(this._responseDto.parameters[parameterId], this);
|
|
1271
1302
|
break;
|
|
1272
1303
|
default:
|
|
1273
|
-
this.parameters[parameterId] = new
|
|
1304
|
+
this.parameters[parameterId] = new Parameter(this._responseDto.parameters[parameterId], this);
|
|
1274
1305
|
break;
|
|
1275
1306
|
}
|
|
1276
1307
|
// we don't have to do larger restrictions for this as the backend would have already thrown an error if the values were not correct
|
|
@@ -1300,10 +1331,10 @@ class SessionEngine {
|
|
|
1300
1331
|
if (!this.initialized)
|
|
1301
1332
|
__classPrivateFieldGet(this, _SessionEngine_parameterHistory, "f").push(parameterSet);
|
|
1302
1333
|
for (let exportId in this._responseDto.exports) {
|
|
1303
|
-
if (this._responseDto.exports[exportId].type ===
|
|
1334
|
+
if (this._responseDto.exports[exportId].type === ShapeDiverResponseExportDefinitionType.EMAIL || this._responseDto.exports[exportId].type === ShapeDiverResponseExportDefinitionType.DOWNLOAD) {
|
|
1304
1335
|
if (!this.exports[exportId]) {
|
|
1305
1336
|
this._responseDto.exports[exportId].id = exportId;
|
|
1306
|
-
this.exports[exportId] = new
|
|
1337
|
+
this.exports[exportId] = new Export(this._responseDto.exports[exportId], this);
|
|
1307
1338
|
}
|
|
1308
1339
|
else {
|
|
1309
1340
|
this.exports[exportId].updateExportDefinition(this._responseDto.exports[exportId]);
|
|
@@ -1315,7 +1346,7 @@ class SessionEngine {
|
|
|
1315
1346
|
this._responseDto.outputs[outputId].id = outputId;
|
|
1316
1347
|
if (this.outputsFreeze[outputId] === undefined)
|
|
1317
1348
|
this.outputsFreeze[outputId] = false;
|
|
1318
|
-
this.outputs[outputId] = new
|
|
1349
|
+
this.outputs[outputId] = new Output(this._responseDto.outputs[outputId], this);
|
|
1319
1350
|
}
|
|
1320
1351
|
else {
|
|
1321
1352
|
this.outputs[outputId].updateOutputDefinition(this._responseDto.outputs[outputId]);
|
|
@@ -1323,6 +1354,5 @@ class SessionEngine {
|
|
|
1323
1354
|
}
|
|
1324
1355
|
}
|
|
1325
1356
|
}
|
|
1326
|
-
exports.SessionEngine = SessionEngine;
|
|
1327
1357
|
_SessionEngine_customizationProcess = new WeakMap(), _SessionEngine_parameterHistory = new WeakMap(), _SessionEngine_parameterHistoryCall = new WeakMap(), _SessionEngine_parameterHistoryForward = new WeakMap();
|
|
1328
1358
|
//# sourceMappingURL=SessionEngine.js.map
|