@shapediver/viewer.session-engine.session-engine 3.1.2 → 3.2.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/SessionEngine.d.ts +8 -1
- package/dist/implementation/SessionEngine.d.ts.map +1 -1
- package/dist/implementation/SessionEngine.js +70 -11
- 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 +88 -24
- 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]) {
|
|
@@ -1364,9 +1368,9 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1364
1368
|
parameterValues[parameterId] = fileParameterValues[parameterId];
|
|
1365
1369
|
|
|
1366
1370
|
// 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])
|
|
1371
|
+
if (parameterValues[parameterId] === undefined && this.parameters[parameterId].value !== fileParameterValues[parameterId])
|
|
1368
1372
|
this.parameters[parameterId].value = fileParameterValues[parameterId];
|
|
1369
|
-
} else if(this.parameters[parameterId].value !== fileParameterValues[parameterId]) {
|
|
1373
|
+
} else if (this.parameters[parameterId].value !== fileParameterValues[parameterId]) {
|
|
1370
1374
|
this.parameters[parameterId].value = fileParameterValues[parameterId];
|
|
1371
1375
|
}
|
|
1372
1376
|
}
|
|
@@ -1388,9 +1392,9 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1388
1392
|
}
|
|
1389
1393
|
}
|
|
1390
1394
|
|
|
1391
|
-
// #endregion Public Methods (
|
|
1395
|
+
// #endregion Public Methods (29)
|
|
1392
1396
|
|
|
1393
|
-
// #region Private Methods (
|
|
1397
|
+
// #region Private Methods (17)
|
|
1394
1398
|
|
|
1395
1399
|
private _saveSessionSettings() {
|
|
1396
1400
|
const parameters = this.parameters;
|
|
@@ -1450,8 +1454,8 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1450
1454
|
|
|
1451
1455
|
private addBusyMode(busyId: string) {
|
|
1452
1456
|
for (const r in this._stateEngine.viewportEngines) {
|
|
1453
|
-
if (!this.excludeViewports.includes(r)) {
|
|
1454
|
-
this._stateEngine.viewportEngines[r]
|
|
1457
|
+
if (this._stateEngine.viewportEngines[r] && !this.excludeViewports.includes(r)) {
|
|
1458
|
+
this._stateEngine.viewportEngines[r]!.busy.push(busyId);
|
|
1455
1459
|
this.#customizationBusyModes.push(busyId);
|
|
1456
1460
|
}
|
|
1457
1461
|
}
|
|
@@ -1534,6 +1538,27 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1534
1538
|
return requestParameterSet;
|
|
1535
1539
|
}
|
|
1536
1540
|
|
|
1541
|
+
/**
|
|
1542
|
+
* Create an interaction parameter based on the parameter definition.
|
|
1543
|
+
*
|
|
1544
|
+
* @param parameter
|
|
1545
|
+
* @returns
|
|
1546
|
+
*/
|
|
1547
|
+
private createInteractionParameter(parameter: ShapeDiverResponseParameter): IParameter<unknown> {
|
|
1548
|
+
const result = validateInteractionParameterSettings(parameter.settings);
|
|
1549
|
+
if (result.success) {
|
|
1550
|
+
switch ((parameter.settings as IInteractionParameterSettings).type) {
|
|
1551
|
+
case 'selection':
|
|
1552
|
+
return new SelectionParameter(parameter, this);
|
|
1553
|
+
case 'gumball':
|
|
1554
|
+
return new GumballParameter(parameter, this);
|
|
1555
|
+
}
|
|
1556
|
+
} else {
|
|
1557
|
+
this._logger.warn(`SessionEngine.createInteractionParameter: The value ${parameter.settings} is not a valid InteractionParameter: ${result.error.message}`);
|
|
1558
|
+
}
|
|
1559
|
+
return new Parameter<string>(parameter, this);
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1537
1562
|
private async customizeInternal(cancelRequest: () => boolean, taskEventInfo: OutputLoaderTaskEventInfo): Promise<ISessionTreeNode> {
|
|
1538
1563
|
return this.customizeSession(this._parameterValues, cancelRequest, taskEventInfo);
|
|
1539
1564
|
}
|
|
@@ -1637,8 +1662,8 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1637
1662
|
|
|
1638
1663
|
private removeBusyMode(busyId: string) {
|
|
1639
1664
|
for (const r in this._stateEngine.viewportEngines) {
|
|
1640
|
-
if (this._stateEngine.viewportEngines[r].busy.includes(busyId))
|
|
1641
|
-
this._stateEngine.viewportEngines[r]
|
|
1665
|
+
if (this._stateEngine.viewportEngines[r] && this._stateEngine.viewportEngines[r]!.busy.includes(busyId))
|
|
1666
|
+
this._stateEngine.viewportEngines[r]!.busy.splice(this._stateEngine.viewportEngines[r]!.busy.indexOf(busyId), 1);
|
|
1642
1667
|
|
|
1643
1668
|
if (this.#customizationBusyModes.includes(busyId))
|
|
1644
1669
|
this.#customizationBusyModes.splice(this.#customizationBusyModes.indexOf(busyId), 1);
|
|
@@ -1705,6 +1730,42 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1705
1730
|
if (this.parameters[parameterId]) continue;
|
|
1706
1731
|
this._responseDto.parameters[parameterId].id = parameterId;
|
|
1707
1732
|
|
|
1733
|
+
/**
|
|
1734
|
+
*
|
|
1735
|
+
* REMOVE THIS LOGIC - START
|
|
1736
|
+
*
|
|
1737
|
+
*/
|
|
1738
|
+
const fakeSelectionParameterName = 'FAKE_SELECTION_PARAMETER';
|
|
1739
|
+
const nameStartsWithFakeSelectionParameter = this._responseDto.parameters[parameterId].name.startsWith(fakeSelectionParameterName);
|
|
1740
|
+
const displaynameStartsWithFakeSelectionParameter = this._responseDto.parameters[parameterId].displayname?.startsWith(fakeSelectionParameterName);
|
|
1741
|
+
|
|
1742
|
+
if (nameStartsWithFakeSelectionParameter || displaynameStartsWithFakeSelectionParameter) {
|
|
1743
|
+
this._responseDto.parameters[parameterId].type = PARAMETER_TYPE.INTERACTION;
|
|
1744
|
+
const name = nameStartsWithFakeSelectionParameter ? this._responseDto.parameters[parameterId].name : this._responseDto.parameters[parameterId].displayname!;
|
|
1745
|
+
const urlParams = new URLSearchParams(name.replace(fakeSelectionParameterName + '?', ''));
|
|
1746
|
+
const jsonString = urlParams.get('settings');
|
|
1747
|
+
if (jsonString)
|
|
1748
|
+
this._responseDto.parameters[parameterId].settings = JSON.parse(jsonString);
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
const fakeGumballParameterName = 'FAKE_GUMBALL_PARAMETER';
|
|
1752
|
+
const nameStartsWithFakeGumballParameter = this._responseDto.parameters[parameterId].name.startsWith(fakeGumballParameterName);
|
|
1753
|
+
const displaynameStartsWithFakeGumballParameter = this._responseDto.parameters[parameterId].displayname?.startsWith(fakeGumballParameterName);
|
|
1754
|
+
|
|
1755
|
+
if (nameStartsWithFakeGumballParameter || displaynameStartsWithFakeGumballParameter) {
|
|
1756
|
+
this._responseDto.parameters[parameterId].type = PARAMETER_TYPE.INTERACTION;
|
|
1757
|
+
const name = nameStartsWithFakeGumballParameter ? this._responseDto.parameters[parameterId].name : this._responseDto.parameters[parameterId].displayname!;
|
|
1758
|
+
const urlParams = new URLSearchParams(name.replace(fakeGumballParameterName + '?', ''));
|
|
1759
|
+
const jsonString = urlParams.get('settings');
|
|
1760
|
+
if (jsonString)
|
|
1761
|
+
this._responseDto.parameters[parameterId].settings = JSON.parse(jsonString);
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
*
|
|
1765
|
+
* REMOVE THIS LOGIC - END
|
|
1766
|
+
*
|
|
1767
|
+
*/
|
|
1768
|
+
|
|
1708
1769
|
switch (true) {
|
|
1709
1770
|
case this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.BOOL:
|
|
1710
1771
|
this.parameters[parameterId] = new Parameter<boolean>(this._responseDto.parameters[parameterId], this);
|
|
@@ -1718,6 +1779,9 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1718
1779
|
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
1780
|
this.parameters[parameterId] = new Parameter<number>(this._responseDto.parameters[parameterId], this);
|
|
1720
1781
|
break;
|
|
1782
|
+
case this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.INTERACTION:
|
|
1783
|
+
this.parameters[parameterId] = this.createInteractionParameter(this._responseDto.parameters[parameterId]);
|
|
1784
|
+
break;
|
|
1721
1785
|
default:
|
|
1722
1786
|
this.parameters[parameterId] = new Parameter<string>(this._responseDto.parameters[parameterId], this);
|
|
1723
1787
|
break;
|
|
@@ -1794,5 +1858,5 @@ export class SessionEngine implements ISessionEngine {
|
|
|
1794
1858
|
await Promise.all(promises);
|
|
1795
1859
|
}
|
|
1796
1860
|
|
|
1797
|
-
// #endregion Private Methods (
|
|
1861
|
+
// #endregion Private Methods (17)
|
|
1798
1862
|
}
|
|
@@ -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 { }
|