@shapediver/viewer.session-engine.session-engine 3.1.2 → 3.2.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.
- package/dist/implementation/SessionEngine.d.ts +8 -1
- package/dist/implementation/SessionEngine.d.ts.map +1 -1
- package/dist/implementation/SessionEngine.js +79 -18
- package/dist/implementation/SessionEngine.js.map +1 -1
- package/dist/implementation/dto/Parameter.d.ts +1 -0
- package/dist/implementation/dto/Parameter.d.ts.map +1 -1
- package/dist/implementation/dto/Parameter.js +8 -2
- package/dist/implementation/dto/Parameter.js.map +1 -1
- package/dist/implementation/dto/interaction/GumballParameter.d.ts +20 -0
- package/dist/implementation/dto/interaction/GumballParameter.d.ts.map +1 -0
- package/dist/implementation/dto/interaction/GumballParameter.js +70 -0
- package/dist/implementation/dto/interaction/GumballParameter.js.map +1 -0
- package/dist/implementation/dto/interaction/SelectionParameter.d.ts +17 -0
- package/dist/implementation/dto/interaction/SelectionParameter.d.ts.map +1 -0
- package/dist/implementation/dto/interaction/SelectionParameter.js +58 -0
- package/dist/implementation/dto/interaction/SelectionParameter.js.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces/dto/interaction/IGumballParameter.d.ts +6 -0
- package/dist/interfaces/dto/interaction/IGumballParameter.d.ts.map +1 -0
- package/dist/interfaces/dto/interaction/IGumballParameter.js +3 -0
- package/dist/interfaces/dto/interaction/IGumballParameter.js.map +1 -0
- package/dist/interfaces/dto/interaction/IInteractionParameter.d.ts +6 -0
- package/dist/interfaces/dto/interaction/IInteractionParameter.d.ts.map +1 -0
- package/dist/interfaces/dto/interaction/IInteractionParameter.js +3 -0
- package/dist/interfaces/dto/interaction/IInteractionParameter.js.map +1 -0
- package/dist/interfaces/dto/interaction/ISelectionParameter.d.ts +6 -0
- package/dist/interfaces/dto/interaction/ISelectionParameter.d.ts.map +1 -0
- package/dist/interfaces/dto/interaction/ISelectionParameter.js +3 -0
- package/dist/interfaces/dto/interaction/ISelectionParameter.js.map +1 -0
- package/package.json +10 -10
- package/src/implementation/SessionEngine.ts +101 -31
- package/src/implementation/dto/Parameter.ts +6 -0
- package/src/implementation/dto/interaction/GumballParameter.ts +78 -0
- package/src/implementation/dto/interaction/SelectionParameter.ts +66 -0
- package/src/index.ts +6 -1
- package/src/interfaces/dto/interaction/IGumballParameter.ts +5 -0
- package/src/interfaces/dto/interaction/IInteractionParameter.ts +10 -0
- package/src/interfaces/dto/interaction/ISelectionParameter.ts +5 -0
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
ShapeDiverResponseFileInfo,
|
|
21
21
|
ShapeDiverResponseModelComputationStatus,
|
|
22
22
|
ShapeDiverResponseOutput,
|
|
23
|
+
ShapeDiverResponseParameter,
|
|
23
24
|
ShapeDiverSdk,
|
|
24
25
|
ShapeDiverSdkConfigType
|
|
25
26
|
} from '@shapediver/sdk.geometry-api-sdk-v2';
|
|
@@ -40,16 +41,19 @@ import {
|
|
|
40
41
|
} from '@shapediver/viewer.shared.services';
|
|
41
42
|
import { Export } from './dto/Export';
|
|
42
43
|
import { FileParameter } from './dto/FileParameter';
|
|
44
|
+
import { GumballParameter } from './dto/interaction/GumballParameter';
|
|
43
45
|
import { IExport } from '../interfaces/dto/IExport';
|
|
44
46
|
import { IFileParameter } from '../interfaces/dto/IFileParameter';
|
|
45
|
-
import { IOutput } from '../interfaces/dto/IOutput';
|
|
46
47
|
import {
|
|
48
|
+
IInteractionParameterSettings,
|
|
47
49
|
IOutputEvent,
|
|
48
50
|
ISettingsSections,
|
|
49
51
|
ITaskEvent,
|
|
50
52
|
PARAMETER_TYPE,
|
|
51
|
-
TASK_TYPE
|
|
53
|
+
TASK_TYPE,
|
|
54
|
+
validateInteractionParameterSettings
|
|
52
55
|
} from '@shapediver/viewer.shared.types';
|
|
56
|
+
import { IOutput } from '../interfaces/dto/IOutput';
|
|
53
57
|
import { IParameter } from '../interfaces/dto/IParameter';
|
|
54
58
|
import { ISessionEngine } from '../interfaces/ISessionEngine';
|
|
55
59
|
import { ISessionTreeNode } from '../interfaces/ISessionTreeNode';
|
|
@@ -63,6 +67,7 @@ import { Output } from './dto/Output';
|
|
|
63
67
|
import { OutputDelayException } from './OutputDelayException';
|
|
64
68
|
import { OutputLoader, OutputLoaderTaskEventInfo } from './OutputLoader';
|
|
65
69
|
import { Parameter } from './dto/Parameter';
|
|
70
|
+
import { SelectionParameter } from './dto/interaction/SelectionParameter';
|
|
66
71
|
import { SessionData } from './SessionData';
|
|
67
72
|
import { SessionTreeNode } from './SessionTreeNode';
|
|
68
73
|
import { vec3 } from 'gl-matrix';
|
|
@@ -168,7 +173,7 @@ export class SessionEngine implements ISessionEngine {
|
|
|
168
173
|
|
|
169
174
|
// #endregion Constructors (1)
|
|
170
175
|
|
|
171
|
-
// #region Public Getters And Setters (
|
|
176
|
+
// #region Public Getters And Setters (27)
|
|
172
177
|
|
|
173
178
|
public get automaticSceneUpdate(): boolean {
|
|
174
179
|
return this._automaticSceneUpdate;
|
|
@@ -231,7 +236,7 @@ export class SessionEngine implements ISessionEngine {
|
|
|
231
236
|
|
|
232
237
|
public set loadSdtf(value: boolean) {
|
|
233
238
|
this._loadSdtf = value;
|
|
234
|
-
if(this._initialized === true && this._loadSdtf === true) {
|
|
239
|
+
if (this._initialized === true && this._loadSdtf === true) {
|
|
235
240
|
(async () => {
|
|
236
241
|
this._outputLoader.reloadSdtf = true;
|
|
237
242
|
await this.updateOutputs();
|
|
@@ -293,9 +298,9 @@ export class SessionEngine implements ISessionEngine {
|
|
|
293
298
|
return this._viewerSettings;
|
|
294
299
|
}
|
|
295
300
|
|
|
296
|
-
// #endregion Public Getters And Setters (
|
|
301
|
+
// #endregion Public Getters And Setters (27)
|
|
297
302
|
|
|
298
|
-
// #region Public Methods (
|
|
303
|
+
// #region Public Methods (29)
|
|
299
304
|
|
|
300
305
|
public applySettings(response: ShapeDiverResponseDto, sections?: ISettingsSections) {
|
|
301
306
|
sections = sections || {};
|
|
@@ -443,8 +448,8 @@ export class SessionEngine implements ISessionEngine {
|
|
|
443
448
|
|
|
444
449
|
for (const busyId of this.#customizationBusyModes) {
|
|
445
450
|
for (const r in this._stateEngine.viewportEngines) {
|
|
446
|
-
if (this._stateEngine.viewportEngines[r].busy.includes(busyId))
|
|
447
|
-
this._stateEngine.viewportEngines[r]
|
|
451
|
+
if (this._stateEngine.viewportEngines[r] && this._stateEngine.viewportEngines[r]!.busy.includes(busyId))
|
|
452
|
+
this._stateEngine.viewportEngines[r]!.busy.splice(this._stateEngine.viewportEngines[r]!.busy.indexOf(busyId), 1);
|
|
448
453
|
}
|
|
449
454
|
}
|
|
450
455
|
|
|
@@ -613,8 +618,8 @@ export class SessionEngine implements ISessionEngine {
|
|
|
613
618
|
// update the viewports
|
|
614
619
|
if (waitForViewportUpdate) {
|
|
615
620
|
for (const r in this._stateEngine.viewportEngines)
|
|
616
|
-
if (!this.excludeViewports.includes(this._stateEngine.viewportEngines[r]
|
|
617
|
-
this._stateEngine.viewportEngines[r]
|
|
621
|
+
if (this._stateEngine.viewportEngines[r] && !this.excludeViewports.includes(this._stateEngine.viewportEngines[r]!.id))
|
|
622
|
+
this._stateEngine.viewportEngines[r]!.update(`SessionEngine(${this.id}).customize`);
|
|
618
623
|
|
|
619
624
|
for (const outputId in this.outputs) {
|
|
620
625
|
if (oldOutputVersions[outputId] !== newOutputVersions[outputId]) {
|
|
@@ -637,8 +642,8 @@ export class SessionEngine implements ISessionEngine {
|
|
|
637
642
|
if (!waitForViewportUpdate) {
|
|
638
643
|
setTimeout(() => {
|
|
639
644
|
for (const r in this._stateEngine.viewportEngines)
|
|
640
|
-
if (!this.excludeViewports.includes(this._stateEngine.viewportEngines[r]
|
|
641
|
-
this._stateEngine.viewportEngines[r]
|
|
645
|
+
if (this._stateEngine.viewportEngines[r] && !this.excludeViewports.includes(this._stateEngine.viewportEngines[r]!.id))
|
|
646
|
+
this._stateEngine.viewportEngines[r]!.update(`SessionEngine(${this.id}).customize`);
|
|
642
647
|
}, 0);
|
|
643
648
|
}
|
|
644
649
|
|
|
@@ -972,7 +977,6 @@ export class SessionEngine implements ISessionEngine {
|
|
|
972
977
|
let processId;
|
|
973
978
|
this.checkAvailability('export');
|
|
974
979
|
try {
|
|
975
|
-
|
|
976
980
|
// activate the busy mode if outputs are loaded
|
|
977
981
|
if (loadOutputs === true && this._allowOutputLoading === true &&
|
|
978
982
|
body.outputs && Object.keys(body.outputs).length > 0) {
|
|
@@ -1299,8 +1303,8 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1299
1303
|
// update the viewports
|
|
1300
1304
|
if (waitForViewportUpdate) {
|
|
1301
1305
|
for (const r in this._stateEngine.viewportEngines)
|
|
1302
|
-
if (!this.excludeViewports.includes(this._stateEngine.viewportEngines[r]
|
|
1303
|
-
this._stateEngine.viewportEngines[r]
|
|
1306
|
+
if (this._stateEngine.viewportEngines[r] && !this.excludeViewports.includes(this._stateEngine.viewportEngines[r]!.id))
|
|
1307
|
+
this._stateEngine.viewportEngines[r]!.update(`SessionEngine(${this.id}).updateOutputs`);
|
|
1304
1308
|
|
|
1305
1309
|
for (const outputId in this.outputs) {
|
|
1306
1310
|
if (oldOutputVersions[outputId] !== newOutputVersions[outputId]) {
|
|
@@ -1326,15 +1330,21 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1326
1330
|
public async uploadFile(parameterId: string, data: File, type: string, retry = false): Promise<string> {
|
|
1327
1331
|
this.checkAvailability('file-upload');
|
|
1328
1332
|
try {
|
|
1329
|
-
const
|
|
1330
|
-
[parameterId]: {
|
|
1333
|
+
const result = await this._sdk.file.requestUpload(this._sessionId!, {
|
|
1334
|
+
[parameterId]: {
|
|
1335
|
+
size: data.size,
|
|
1336
|
+
format: type,
|
|
1337
|
+
filename: data.name === '' ? undefined : data.name
|
|
1338
|
+
}
|
|
1331
1339
|
});
|
|
1332
1340
|
|
|
1333
|
-
if (
|
|
1334
|
-
const fileAsset =
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1341
|
+
if (result && result.asset && result.asset.file && result.asset.file[parameterId]) {
|
|
1342
|
+
const fileAsset = result.asset.file[parameterId];
|
|
1343
|
+
await this._sdk.utils.uploadAsset(
|
|
1344
|
+
fileAsset.href,
|
|
1345
|
+
await data.arrayBuffer(),
|
|
1346
|
+
fileAsset.headers
|
|
1347
|
+
);
|
|
1338
1348
|
return fileAsset.id;
|
|
1339
1349
|
} else {
|
|
1340
1350
|
throw new ShapeDiverViewerSessionError('Session.uploadFile: Upload reply has not the required format.');
|
|
@@ -1364,9 +1374,9 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1364
1374
|
parameterValues[parameterId] = fileParameterValues[parameterId];
|
|
1365
1375
|
|
|
1366
1376
|
// 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])
|
|
1377
|
+
if (parameterValues[parameterId] === undefined && this.parameters[parameterId].value !== fileParameterValues[parameterId])
|
|
1368
1378
|
this.parameters[parameterId].value = fileParameterValues[parameterId];
|
|
1369
|
-
} else if(this.parameters[parameterId].value !== fileParameterValues[parameterId]) {
|
|
1379
|
+
} else if (this.parameters[parameterId].value !== fileParameterValues[parameterId]) {
|
|
1370
1380
|
this.parameters[parameterId].value = fileParameterValues[parameterId];
|
|
1371
1381
|
}
|
|
1372
1382
|
}
|
|
@@ -1388,9 +1398,9 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1388
1398
|
}
|
|
1389
1399
|
}
|
|
1390
1400
|
|
|
1391
|
-
// #endregion Public Methods (
|
|
1401
|
+
// #endregion Public Methods (29)
|
|
1392
1402
|
|
|
1393
|
-
// #region Private Methods (
|
|
1403
|
+
// #region Private Methods (17)
|
|
1394
1404
|
|
|
1395
1405
|
private _saveSessionSettings() {
|
|
1396
1406
|
const parameters = this.parameters;
|
|
@@ -1450,8 +1460,8 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1450
1460
|
|
|
1451
1461
|
private addBusyMode(busyId: string) {
|
|
1452
1462
|
for (const r in this._stateEngine.viewportEngines) {
|
|
1453
|
-
if (!this.excludeViewports.includes(r)) {
|
|
1454
|
-
this._stateEngine.viewportEngines[r]
|
|
1463
|
+
if (this._stateEngine.viewportEngines[r] && !this.excludeViewports.includes(r)) {
|
|
1464
|
+
this._stateEngine.viewportEngines[r]!.busy.push(busyId);
|
|
1455
1465
|
this.#customizationBusyModes.push(busyId);
|
|
1456
1466
|
}
|
|
1457
1467
|
}
|
|
@@ -1534,6 +1544,27 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1534
1544
|
return requestParameterSet;
|
|
1535
1545
|
}
|
|
1536
1546
|
|
|
1547
|
+
/**
|
|
1548
|
+
* Create an interaction parameter based on the parameter definition.
|
|
1549
|
+
*
|
|
1550
|
+
* @param parameter
|
|
1551
|
+
* @returns
|
|
1552
|
+
*/
|
|
1553
|
+
private createInteractionParameter(parameter: ShapeDiverResponseParameter): IParameter<unknown> {
|
|
1554
|
+
const result = validateInteractionParameterSettings(parameter.settings);
|
|
1555
|
+
if (result.success) {
|
|
1556
|
+
switch ((parameter.settings as IInteractionParameterSettings).type) {
|
|
1557
|
+
case 'selection':
|
|
1558
|
+
return new SelectionParameter(parameter, this);
|
|
1559
|
+
case 'gumball':
|
|
1560
|
+
return new GumballParameter(parameter, this);
|
|
1561
|
+
}
|
|
1562
|
+
} else {
|
|
1563
|
+
this._logger.warn(`SessionEngine.createInteractionParameter: The value ${parameter.settings} is not a valid InteractionParameter: ${result.error.message}`);
|
|
1564
|
+
}
|
|
1565
|
+
return new Parameter<string>(parameter, this);
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1537
1568
|
private async customizeInternal(cancelRequest: () => boolean, taskEventInfo: OutputLoaderTaskEventInfo): Promise<ISessionTreeNode> {
|
|
1538
1569
|
return this.customizeSession(this._parameterValues, cancelRequest, taskEventInfo);
|
|
1539
1570
|
}
|
|
@@ -1637,8 +1668,8 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1637
1668
|
|
|
1638
1669
|
private removeBusyMode(busyId: string) {
|
|
1639
1670
|
for (const r in this._stateEngine.viewportEngines) {
|
|
1640
|
-
if (this._stateEngine.viewportEngines[r].busy.includes(busyId))
|
|
1641
|
-
this._stateEngine.viewportEngines[r]
|
|
1671
|
+
if (this._stateEngine.viewportEngines[r] && this._stateEngine.viewportEngines[r]!.busy.includes(busyId))
|
|
1672
|
+
this._stateEngine.viewportEngines[r]!.busy.splice(this._stateEngine.viewportEngines[r]!.busy.indexOf(busyId), 1);
|
|
1642
1673
|
|
|
1643
1674
|
if (this.#customizationBusyModes.includes(busyId))
|
|
1644
1675
|
this.#customizationBusyModes.splice(this.#customizationBusyModes.indexOf(busyId), 1);
|
|
@@ -1705,6 +1736,42 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1705
1736
|
if (this.parameters[parameterId]) continue;
|
|
1706
1737
|
this._responseDto.parameters[parameterId].id = parameterId;
|
|
1707
1738
|
|
|
1739
|
+
/**
|
|
1740
|
+
*
|
|
1741
|
+
* REMOVE THIS LOGIC - START
|
|
1742
|
+
*
|
|
1743
|
+
*/
|
|
1744
|
+
const fakeSelectionParameterName = 'FAKE_SELECTION_PARAMETER';
|
|
1745
|
+
const nameStartsWithFakeSelectionParameter = this._responseDto.parameters[parameterId].name.startsWith(fakeSelectionParameterName);
|
|
1746
|
+
const displaynameStartsWithFakeSelectionParameter = this._responseDto.parameters[parameterId].displayname?.startsWith(fakeSelectionParameterName);
|
|
1747
|
+
|
|
1748
|
+
if (nameStartsWithFakeSelectionParameter || displaynameStartsWithFakeSelectionParameter) {
|
|
1749
|
+
this._responseDto.parameters[parameterId].type = PARAMETER_TYPE.INTERACTION;
|
|
1750
|
+
const name = nameStartsWithFakeSelectionParameter ? this._responseDto.parameters[parameterId].name : this._responseDto.parameters[parameterId].displayname!;
|
|
1751
|
+
const urlParams = new URLSearchParams(name.replace(fakeSelectionParameterName + '?', ''));
|
|
1752
|
+
const jsonString = urlParams.get('settings');
|
|
1753
|
+
if (jsonString)
|
|
1754
|
+
this._responseDto.parameters[parameterId].settings = JSON.parse(jsonString);
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
const fakeGumballParameterName = 'FAKE_GUMBALL_PARAMETER';
|
|
1758
|
+
const nameStartsWithFakeGumballParameter = this._responseDto.parameters[parameterId].name.startsWith(fakeGumballParameterName);
|
|
1759
|
+
const displaynameStartsWithFakeGumballParameter = this._responseDto.parameters[parameterId].displayname?.startsWith(fakeGumballParameterName);
|
|
1760
|
+
|
|
1761
|
+
if (nameStartsWithFakeGumballParameter || displaynameStartsWithFakeGumballParameter) {
|
|
1762
|
+
this._responseDto.parameters[parameterId].type = PARAMETER_TYPE.INTERACTION;
|
|
1763
|
+
const name = nameStartsWithFakeGumballParameter ? this._responseDto.parameters[parameterId].name : this._responseDto.parameters[parameterId].displayname!;
|
|
1764
|
+
const urlParams = new URLSearchParams(name.replace(fakeGumballParameterName + '?', ''));
|
|
1765
|
+
const jsonString = urlParams.get('settings');
|
|
1766
|
+
if (jsonString)
|
|
1767
|
+
this._responseDto.parameters[parameterId].settings = JSON.parse(jsonString);
|
|
1768
|
+
}
|
|
1769
|
+
/**
|
|
1770
|
+
*
|
|
1771
|
+
* REMOVE THIS LOGIC - END
|
|
1772
|
+
*
|
|
1773
|
+
*/
|
|
1774
|
+
|
|
1708
1775
|
switch (true) {
|
|
1709
1776
|
case this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.BOOL:
|
|
1710
1777
|
this.parameters[parameterId] = new Parameter<boolean>(this._responseDto.parameters[parameterId], this);
|
|
@@ -1718,6 +1785,9 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1718
1785
|
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:
|
|
1719
1786
|
this.parameters[parameterId] = new Parameter<number>(this._responseDto.parameters[parameterId], this);
|
|
1720
1787
|
break;
|
|
1788
|
+
case this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.INTERACTION:
|
|
1789
|
+
this.parameters[parameterId] = this.createInteractionParameter(this._responseDto.parameters[parameterId]);
|
|
1790
|
+
break;
|
|
1721
1791
|
default:
|
|
1722
1792
|
this.parameters[parameterId] = new Parameter<string>(this._responseDto.parameters[parameterId], this);
|
|
1723
1793
|
break;
|
|
@@ -1794,5 +1864,5 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1794
1864
|
await Promise.all(promises);
|
|
1795
1865
|
}
|
|
1796
1866
|
|
|
1797
|
-
// #endregion Private Methods (
|
|
1867
|
+
// #endregion Private Methods (17)
|
|
1798
1868
|
}
|
|
@@ -32,6 +32,7 @@ export class Parameter<T> implements IParameter<T> {
|
|
|
32
32
|
readonly #min?: number;
|
|
33
33
|
readonly #name: string;
|
|
34
34
|
readonly #sessionEngine: SessionEngine;
|
|
35
|
+
readonly #settings?: Record<string, unknown>;
|
|
35
36
|
readonly #structure?: ShapeDiverResponseParameterStructure;
|
|
36
37
|
readonly #type: PARAMETER_TYPE;
|
|
37
38
|
readonly #visualization?: PARAMETER_VISUALIZATION;
|
|
@@ -67,6 +68,7 @@ export class Parameter<T> implements IParameter<T> {
|
|
|
67
68
|
if (paramDef.visualization !== undefined) this.#visualization = <PARAMETER_VISUALIZATION>paramDef.visualization;
|
|
68
69
|
if (paramDef.structure !== undefined) this.#structure = paramDef.structure;
|
|
69
70
|
if (paramDef.group !== undefined) this.#group = paramDef.group;
|
|
71
|
+
if (paramDef.settings !== undefined) this.#settings = paramDef.settings;
|
|
70
72
|
if (paramDef.tooltip !== undefined) this.#tooltip = paramDef.tooltip;
|
|
71
73
|
|
|
72
74
|
if (paramDef.displayname !== undefined) this.#displayname = paramDef.displayname;
|
|
@@ -179,6 +181,10 @@ export class Parameter<T> implements IParameter<T> {
|
|
|
179
181
|
});
|
|
180
182
|
}
|
|
181
183
|
|
|
184
|
+
public get settings(): Record<string, unknown> | undefined {
|
|
185
|
+
return this.#settings;
|
|
186
|
+
}
|
|
187
|
+
|
|
182
188
|
public get structure(): ShapeDiverResponseParameterStructure | undefined {
|
|
183
189
|
return this.#structure;
|
|
184
190
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IInteractionParameterSettings,
|
|
3
|
+
InteractionParameterSettingsType,
|
|
4
|
+
IGumballParameterSettings,
|
|
5
|
+
validateGumballParameterSettings
|
|
6
|
+
} from '@shapediver/viewer.shared.types';
|
|
7
|
+
import { IGumballParameter } from '../../../interfaces/dto/interaction/IGumballParameter';
|
|
8
|
+
import { Parameter } from '../Parameter';
|
|
9
|
+
import { SessionEngine } from '../../SessionEngine';
|
|
10
|
+
import { ShapeDiverResponseParameter } from '@shapediver/sdk.geometry-api-sdk-v2';
|
|
11
|
+
|
|
12
|
+
export class GumballParameter extends Parameter<string> implements IGumballParameter {
|
|
13
|
+
// #region Properties (1)
|
|
14
|
+
|
|
15
|
+
readonly #sessionEngine: SessionEngine;
|
|
16
|
+
|
|
17
|
+
// #endregion Properties (1)
|
|
18
|
+
|
|
19
|
+
// #region Constructors (1)
|
|
20
|
+
|
|
21
|
+
constructor(paramDef: ShapeDiverResponseParameter, sessionEngine: SessionEngine) {
|
|
22
|
+
super(paramDef, sessionEngine);
|
|
23
|
+
this.#sessionEngine = sessionEngine;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// #endregion Constructors (1)
|
|
27
|
+
|
|
28
|
+
// #region Public Getters And Setters (9)
|
|
29
|
+
|
|
30
|
+
public get enableRotation(): boolean | undefined {
|
|
31
|
+
return this.getGumballProperties()?.enableRotation;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public get enableScaling(): boolean | undefined {
|
|
35
|
+
return this.getGumballProperties()?.enableScaling;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public get enableTranslation(): boolean | undefined {
|
|
39
|
+
return this.getGumballProperties()?.enableTranslation;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public get hover(): boolean | undefined {
|
|
43
|
+
return this.getGumballProperties()?.hover;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public get interactionType(): InteractionParameterSettingsType {
|
|
47
|
+
return 'gumball';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public get nameFilter(): string[] | undefined {
|
|
51
|
+
return this.getGumballProperties()?.nameFilter;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public get scale(): number | undefined {
|
|
55
|
+
return this.getGumballProperties()?.scale;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public get selectionColor(): string | undefined {
|
|
59
|
+
return this.getGumballProperties()?.selectionColor;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public get space(): 'local' | 'world' | undefined {
|
|
63
|
+
return this.getGumballProperties()?.space;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// #endregion Public Getters And Setters (9)
|
|
67
|
+
|
|
68
|
+
// #region Private Methods (1)
|
|
69
|
+
|
|
70
|
+
private getGumballProperties(): IGumballParameterSettings | undefined {
|
|
71
|
+
const result = validateGumballParameterSettings((this.settings as unknown as IInteractionParameterSettings));
|
|
72
|
+
if (result.success) {
|
|
73
|
+
return (this.settings as unknown as IInteractionParameterSettings).props;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// #endregion Private Methods (1)
|
|
78
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IInteractionParameterSettings,
|
|
3
|
+
InteractionParameterSettingsType,
|
|
4
|
+
ISelectionParameterSettings,
|
|
5
|
+
validateSelectionParameterSettings
|
|
6
|
+
} from '@shapediver/viewer.shared.types';
|
|
7
|
+
import { ISelectionParameter } from '../../../interfaces/dto/interaction/ISelectionParameter';
|
|
8
|
+
import { Parameter } from '../Parameter';
|
|
9
|
+
import { SessionEngine } from '../../SessionEngine';
|
|
10
|
+
import { ShapeDiverResponseParameter } from '@shapediver/sdk.geometry-api-sdk-v2';
|
|
11
|
+
|
|
12
|
+
export class SelectionParameter extends Parameter<string> implements ISelectionParameter {
|
|
13
|
+
// #region Properties (1)
|
|
14
|
+
|
|
15
|
+
readonly #sessionEngine: SessionEngine;
|
|
16
|
+
|
|
17
|
+
// #endregion Properties (1)
|
|
18
|
+
|
|
19
|
+
// #region Constructors (1)
|
|
20
|
+
|
|
21
|
+
constructor(paramDef: ShapeDiverResponseParameter, sessionEngine: SessionEngine) {
|
|
22
|
+
super(paramDef, sessionEngine);
|
|
23
|
+
this.#sessionEngine = sessionEngine;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// #endregion Constructors (1)
|
|
27
|
+
|
|
28
|
+
// #region Public Getters And Setters (6)
|
|
29
|
+
|
|
30
|
+
public get hover(): boolean | undefined {
|
|
31
|
+
return this.getSelectionProperties()?.hover;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public get interactionType(): InteractionParameterSettingsType {
|
|
35
|
+
return 'selection';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public get maximumSelection(): number | undefined {
|
|
39
|
+
return this.getSelectionProperties()?.maximumSelection;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public get minimumSelection(): number | undefined {
|
|
43
|
+
return this.getSelectionProperties()?.minimumSelection;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public get nameFilter(): string[] | undefined {
|
|
47
|
+
return this.getSelectionProperties()?.nameFilter;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public get selectionColor(): string | undefined {
|
|
51
|
+
return this.getSelectionProperties()?.selectionColor;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// #endregion Public Getters And Setters (6)
|
|
55
|
+
|
|
56
|
+
// #region Private Methods (1)
|
|
57
|
+
|
|
58
|
+
private getSelectionProperties(): ISelectionParameterSettings | undefined {
|
|
59
|
+
const result = validateSelectionParameterSettings((this.settings as unknown as IInteractionParameterSettings));
|
|
60
|
+
if (result.success) {
|
|
61
|
+
return (this.settings as unknown as IInteractionParameterSettings).props;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// #endregion Private Methods (1)
|
|
66
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { Export } from './implementation/dto/Export';
|
|
2
2
|
import { FileParameter } from './implementation/dto/FileParameter';
|
|
3
|
+
import { GumballParameter } from './implementation/dto/interaction/GumballParameter';
|
|
3
4
|
import { IExport } from './interfaces/dto/IExport';
|
|
4
5
|
import { IFileParameter } from './interfaces/dto/IFileParameter';
|
|
6
|
+
import { IGumballParameter } from './interfaces/dto/interaction/IGumballParameter';
|
|
7
|
+
import { IInteractionParameter } from './interfaces/dto/interaction/IInteractionParameter';
|
|
5
8
|
import { IOutput, ShapeDiverResponseOutputChunk, ShapeDiverResponseOutputContent } from './interfaces/dto/IOutput';
|
|
6
9
|
import { IParameter } from './interfaces/dto/IParameter';
|
|
10
|
+
import { ISelectionParameter } from './interfaces/dto/interaction/ISelectionParameter';
|
|
7
11
|
import { ISessionData } from './interfaces/ISessionData';
|
|
8
12
|
import { ISessionEngine } from './interfaces/ISessionEngine';
|
|
9
13
|
import { ISessionOutputData } from './interfaces/ISessionOutputData';
|
|
10
14
|
import { Output } from './implementation/dto/Output';
|
|
11
15
|
import { Parameter } from './implementation/dto/Parameter';
|
|
16
|
+
import { SelectionParameter } from './implementation/dto/interaction/SelectionParameter';
|
|
12
17
|
import { SessionData } from './implementation/SessionData';
|
|
13
18
|
import { SessionEngine } from './implementation/SessionEngine';
|
|
14
19
|
import { SessionOutputData } from './implementation/SessionOutputData';
|
|
@@ -18,5 +23,5 @@ export {
|
|
|
18
23
|
};
|
|
19
24
|
|
|
20
25
|
export {
|
|
21
|
-
ISessionEngine, SessionEngine, IOutput, Output, IParameter, Parameter, IFileParameter, FileParameter, IExport, Export, ShapeDiverResponseOutputContent, ShapeDiverResponseOutputChunk
|
|
26
|
+
ISessionEngine, SessionEngine, IOutput, Output, IParameter, Parameter, IFileParameter, FileParameter, IInteractionParameter, ISelectionParameter, SelectionParameter, IGumballParameter, GumballParameter, IExport, Export, ShapeDiverResponseOutputContent, ShapeDiverResponseOutputChunk
|
|
22
27
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IInteractionParameter } from './IInteractionParameter';
|
|
2
|
+
import { IParameter } from '../IParameter';
|
|
3
|
+
import { IGumballParameterSettings } from '@shapediver/viewer.shared.types';
|
|
4
|
+
|
|
5
|
+
export interface IGumballParameter extends IParameter<string>, IInteractionParameter, IGumballParameterSettings { }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InteractionParameterSettingsType } from '@shapediver/viewer.shared.types';
|
|
2
|
+
import { IParameter } from '../IParameter';
|
|
3
|
+
|
|
4
|
+
export interface IInteractionParameter extends IParameter<string> {
|
|
5
|
+
// #region Properties (1)
|
|
6
|
+
|
|
7
|
+
interactionType: InteractionParameterSettingsType;
|
|
8
|
+
|
|
9
|
+
// #endregion Properties (1)
|
|
10
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IInteractionParameter } from './IInteractionParameter';
|
|
2
|
+
import { IParameter } from '../IParameter';
|
|
3
|
+
import { ISelectionParameterSettings } from '@shapediver/viewer.shared.types';
|
|
4
|
+
|
|
5
|
+
export interface ISelectionParameter extends IParameter<string>, IInteractionParameter, ISelectionParameterSettings { }
|