@shapediver/viewer.session-engine.session-engine 3.3.4 → 3.3.7
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.map +1 -1
- package/dist/implementation/SessionEngine.js +18 -3
- package/dist/implementation/SessionEngine.js.map +1 -1
- package/dist/implementation/dto/DrawingParameter.d.ts +13 -0
- package/dist/implementation/dto/DrawingParameter.d.ts.map +1 -0
- package/dist/implementation/dto/DrawingParameter.js +43 -0
- package/dist/implementation/dto/DrawingParameter.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces/dto/IDrawingParameter.d.ts +5 -0
- package/dist/interfaces/dto/IDrawingParameter.d.ts.map +1 -0
- package/dist/interfaces/dto/IDrawingParameter.js +3 -0
- package/dist/interfaces/dto/IDrawingParameter.js.map +1 -0
- package/dist/interfaces/dto/IDrawingToolsParameter.d.ts +5 -0
- package/dist/interfaces/dto/IDrawingToolsParameter.d.ts.map +1 -0
- package/dist/interfaces/dto/IDrawingToolsParameter.js +3 -0
- package/dist/interfaces/dto/IDrawingToolsParameter.js.map +1 -0
- package/package.json +10 -11
- package/src/implementation/OutputDelayException.ts +0 -22
- package/src/implementation/OutputLoader.ts +0 -378
- package/src/implementation/SessionData.ts +0 -44
- package/src/implementation/SessionEngine.ts +0 -2006
- package/src/implementation/SessionOutputData.ts +0 -44
- package/src/implementation/SessionTreeNode.ts +0 -44
- package/src/implementation/dto/Export.ts +0 -231
- package/src/implementation/dto/FileParameter.ts +0 -117
- package/src/implementation/dto/Output.ts +0 -223
- package/src/implementation/dto/Parameter.ts +0 -370
- package/src/implementation/dto/interaction/GumballParameter.ts +0 -78
- package/src/implementation/dto/interaction/SelectionParameter.ts +0 -66
- package/src/index.ts +0 -27
- package/src/interfaces/ISessionData.ts +0 -16
- package/src/interfaces/ISessionEngine.ts +0 -69
- package/src/interfaces/ISessionOutputData.ts +0 -16
- package/src/interfaces/ISessionTreeNode.ts +0 -9
- package/src/interfaces/dto/IExport.ts +0 -17
- package/src/interfaces/dto/IFileParameter.ts +0 -10
- package/src/interfaces/dto/IOutput.ts +0 -58
- package/src/interfaces/dto/IParameter.ts +0 -19
- package/src/interfaces/dto/interaction/IGumballParameter.ts +0 -5
- package/src/interfaces/dto/interaction/IInteractionParameter.ts +0 -10
- package/src/interfaces/dto/interaction/ISelectionParameter.ts +0 -5
- package/tsconfig.json +0 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapediver/viewer.session-engine.session-engine",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Michael Oppitz <michael@shapediver.com>",
|
|
@@ -10,11 +10,10 @@
|
|
|
10
10
|
"test": "__tests__"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
|
-
"dist",
|
|
14
|
-
"src",
|
|
15
13
|
"package.json",
|
|
14
|
+
"dist/",
|
|
16
15
|
"README.md",
|
|
17
|
-
"
|
|
16
|
+
"LICENSE"
|
|
18
17
|
],
|
|
19
18
|
"publishConfig": {
|
|
20
19
|
"access": "public"
|
|
@@ -40,16 +39,16 @@
|
|
|
40
39
|
},
|
|
41
40
|
"dependencies": {
|
|
42
41
|
"@shapediver/sdk.geometry-api-sdk-v2": "1.11.0",
|
|
43
|
-
"@shapediver/viewer.data-engine.shared-types": "3.3.
|
|
42
|
+
"@shapediver/viewer.data-engine.shared-types": "3.3.7",
|
|
44
43
|
"@shapediver/viewer.settings": "1.0.2",
|
|
45
|
-
"@shapediver/viewer.shared.build-data": "3.3.
|
|
46
|
-
"@shapediver/viewer.shared.global-access-objects": "3.3.
|
|
47
|
-
"@shapediver/viewer.shared.node-tree": "3.3.
|
|
48
|
-
"@shapediver/viewer.shared.services": "3.3.
|
|
49
|
-
"@shapediver/viewer.shared.types": "3.3.
|
|
44
|
+
"@shapediver/viewer.shared.build-data": "3.3.7",
|
|
45
|
+
"@shapediver/viewer.shared.global-access-objects": "3.3.7",
|
|
46
|
+
"@shapediver/viewer.shared.node-tree": "3.3.7",
|
|
47
|
+
"@shapediver/viewer.shared.services": "3.3.7",
|
|
48
|
+
"@shapediver/viewer.shared.types": "3.3.7",
|
|
50
49
|
"@shapediver/viewer.utils.mime-type": "1.1.0",
|
|
51
50
|
"axios": "^1.2.6",
|
|
52
51
|
"gl-matrix": "3.3.0"
|
|
53
52
|
},
|
|
54
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "112787d5c5226cca5e89d08102d0b1a3dd4a1d71"
|
|
55
54
|
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export class OutputDelayException extends Error {
|
|
2
|
-
// #region Constructors (1)
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Exception that is thrown when there is an output with a delay property.
|
|
6
|
-
*
|
|
7
|
-
* @param _delay the milliseconds to wait
|
|
8
|
-
*/
|
|
9
|
-
constructor(private readonly _delay: number) {
|
|
10
|
-
super();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// #endregion Constructors (1)
|
|
14
|
-
|
|
15
|
-
// #region Public Getters And Setters (1)
|
|
16
|
-
|
|
17
|
-
public get delay(): number {
|
|
18
|
-
return this._delay;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// #endregion Public Getters And Setters (1)
|
|
22
|
-
}
|
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AbstractMaterialData,
|
|
3
|
-
GeometryData,
|
|
4
|
-
IMaterialAbstractData,
|
|
5
|
-
ITaskEvent,
|
|
6
|
-
TASK_TYPE
|
|
7
|
-
} from '@shapediver/viewer.shared.types';
|
|
8
|
-
import {
|
|
9
|
-
EventEngine,
|
|
10
|
-
EVENTTYPE,
|
|
11
|
-
IEvent,
|
|
12
|
-
PerformanceEvaluator
|
|
13
|
-
} from '@shapediver/viewer.shared.services';
|
|
14
|
-
import { GlobalAccessObjects } from '@shapediver/viewer.shared.global-access-objects';
|
|
15
|
-
import { ISessionEngine } from '../interfaces/ISessionEngine';
|
|
16
|
-
import { ISessionTreeNode } from '../interfaces/ISessionTreeNode';
|
|
17
|
-
import { ITreeNode, TreeNode } from '@shapediver/viewer.shared.node-tree';
|
|
18
|
-
import { OutputDelayException } from './OutputDelayException';
|
|
19
|
-
import { SessionOutputData } from './SessionOutputData';
|
|
20
|
-
import { SessionTreeNode } from './SessionTreeNode';
|
|
21
|
-
import { ShapeDiverResponseOutput } from '@shapediver/sdk.geometry-api-sdk-v2';
|
|
22
|
-
|
|
23
|
-
// #region Type aliases (1)
|
|
24
|
-
|
|
25
|
-
export type OutputLoaderTaskEventInfo = {
|
|
26
|
-
eventId: string,
|
|
27
|
-
type: TASK_TYPE,
|
|
28
|
-
progressRange: {
|
|
29
|
-
min: number,
|
|
30
|
-
max: number
|
|
31
|
-
},
|
|
32
|
-
data: unknown
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// #endregion Type aliases (1)
|
|
36
|
-
|
|
37
|
-
// #region Classes (1)
|
|
38
|
-
|
|
39
|
-
export class OutputLoader {
|
|
40
|
-
// #region Properties (6)
|
|
41
|
-
|
|
42
|
-
private readonly _eventEngine: EventEngine = EventEngine.instance;
|
|
43
|
-
private readonly _globalAccessObjects: GlobalAccessObjects = GlobalAccessObjects.instance;
|
|
44
|
-
private readonly _lastOutputNodes: {
|
|
45
|
-
[key: string]: {
|
|
46
|
-
[key: string]: ISessionTreeNode
|
|
47
|
-
};
|
|
48
|
-
} = {};
|
|
49
|
-
private readonly _loadedOutputNodes: {
|
|
50
|
-
[key: string]: {
|
|
51
|
-
[key: string]: ISessionTreeNode
|
|
52
|
-
};
|
|
53
|
-
} = {};
|
|
54
|
-
private readonly _performanceEvaluator: PerformanceEvaluator = PerformanceEvaluator.instance;
|
|
55
|
-
|
|
56
|
-
private _reloadSdtf = false;
|
|
57
|
-
|
|
58
|
-
// #endregion Properties (6)
|
|
59
|
-
|
|
60
|
-
// #region Constructors (1)
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The output loader takes care of loading the outputs of a session, storing them and returning stored or newly loaded nodes.
|
|
64
|
-
*
|
|
65
|
-
* @param _session the session for this output loader
|
|
66
|
-
*/
|
|
67
|
-
constructor(private readonly _sessionEngine: ISessionEngine) { }
|
|
68
|
-
|
|
69
|
-
// #endregion Constructors (1)
|
|
70
|
-
|
|
71
|
-
// #region Public Getters And Setters (1)
|
|
72
|
-
|
|
73
|
-
public set reloadSdtf(value: boolean) {
|
|
74
|
-
this._reloadSdtf = value;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// #endregion Public Getters And Setters (1)
|
|
78
|
-
|
|
79
|
-
// #region Public Methods (2)
|
|
80
|
-
|
|
81
|
-
public getCurrentOutputVersions(): { [key: string]: string } {
|
|
82
|
-
const versions: { [key: string]: string } = {};
|
|
83
|
-
for (const o in this._lastOutputNodes)
|
|
84
|
-
versions[o] = Object.keys(this._lastOutputNodes[o])[0];
|
|
85
|
-
|
|
86
|
-
return versions;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Load the outputs and return the scene graph node of the result.
|
|
91
|
-
* In case the outputs have a delay property, it throws an OutputDelayException.
|
|
92
|
-
*
|
|
93
|
-
* @param outputs the outputs to load
|
|
94
|
-
* @returns promise with a scene graph node
|
|
95
|
-
*/
|
|
96
|
-
public async loadOutputs(nodeName: string, outputs: { [key: string]: ShapeDiverResponseOutput; }, outputsFreeze: { [key: string]: boolean; }, taskEventInfo: OutputLoaderTaskEventInfo, throwDelay = true): Promise<SessionTreeNode> {
|
|
97
|
-
this._performanceEvaluator.startSection('outputLoading');
|
|
98
|
-
const node = new SessionTreeNode(nodeName);
|
|
99
|
-
const currentNodes: {
|
|
100
|
-
[key: string]: {
|
|
101
|
-
[key: string]: ISessionTreeNode
|
|
102
|
-
};
|
|
103
|
-
} = {};
|
|
104
|
-
const outputInfo: {
|
|
105
|
-
[key: string]: {
|
|
106
|
-
version: string,
|
|
107
|
-
contentFormat: string[],
|
|
108
|
-
}
|
|
109
|
-
} = {};
|
|
110
|
-
const promises: Promise<ITreeNode>[] = [];
|
|
111
|
-
const promisesNodes: ISessionTreeNode[] = [];
|
|
112
|
-
let maxDelay = 0;
|
|
113
|
-
|
|
114
|
-
const progress: {
|
|
115
|
-
[key: string]: number
|
|
116
|
-
} = {};
|
|
117
|
-
|
|
118
|
-
const outputIDs = Object.keys(outputs);
|
|
119
|
-
|
|
120
|
-
const cb = (e: IEvent) => {
|
|
121
|
-
const taskEvent = e as ITaskEvent;
|
|
122
|
-
if (outputIDs.find(oId => taskEvent.id.startsWith(oId))) {
|
|
123
|
-
progress[taskEvent.id] = taskEvent.progress;
|
|
124
|
-
|
|
125
|
-
let sum = 0;
|
|
126
|
-
Object.values(progress).forEach(p => { sum += p; });
|
|
127
|
-
|
|
128
|
-
const outputLoadingProgress = (taskEventInfo.progressRange.max - taskEventInfo.progressRange.min) * (sum / outputIDs.length) + taskEventInfo.progressRange.min;
|
|
129
|
-
const eventProgressUpdate: ITaskEvent = { type: taskEventInfo.type, id: taskEventInfo.eventId, progress: outputLoadingProgress, data: taskEventInfo.data, status: 'Output content loading progress.' };
|
|
130
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_PROCESS, eventProgressUpdate);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
const listenerTokens = [];
|
|
135
|
-
listenerTokens.push(this._eventEngine.addListener(EVENTTYPE.TASK.TASK_START, cb));
|
|
136
|
-
listenerTokens.push(this._eventEngine.addListener(EVENTTYPE.TASK.TASK_PROCESS, cb));
|
|
137
|
-
listenerTokens.push(this._eventEngine.addListener(EVENTTYPE.TASK.TASK_CANCEL, cb));
|
|
138
|
-
listenerTokens.push(this._eventEngine.addListener(EVENTTYPE.TASK.TASK_END, cb));
|
|
139
|
-
|
|
140
|
-
for (const outputID in outputs) {
|
|
141
|
-
// we store some necessary information as this data may have been changed after the await (see warning below)
|
|
142
|
-
outputInfo[outputID] = {
|
|
143
|
-
version: outputs[outputID].version,
|
|
144
|
-
contentFormat: outputs[outputID].content ? outputs[outputID].content!.map(c => c.format) : []
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
currentNodes[outputID] = {};
|
|
148
|
-
if (!this._loadedOutputNodes[outputID])
|
|
149
|
-
this._loadedOutputNodes[outputID] = {};
|
|
150
|
-
|
|
151
|
-
if (this._reloadSdtf && outputs[outputID].content) {
|
|
152
|
-
const sdtfContents = outputs[outputID].content?.filter(c => c.format === 'sdtf');
|
|
153
|
-
if (sdtfContents && sdtfContents.length > 0)
|
|
154
|
-
delete this._loadedOutputNodes[outputID][outputInfo[outputID].version];
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (outputsFreeze[outputID]) {
|
|
158
|
-
currentNodes[outputID][outputInfo[outputID].version] = this._lastOutputNodes[outputID][outputInfo[outputID].version];
|
|
159
|
-
// no loading necessary, progress done
|
|
160
|
-
progress[outputID] = 1;
|
|
161
|
-
} else if (outputs[outputID].delay) {
|
|
162
|
-
maxDelay = Math.max(maxDelay, outputs[outputID].delay!);
|
|
163
|
-
} else if (!this._loadedOutputNodes[outputID][outputInfo[outputID].version]) {
|
|
164
|
-
currentNodes[outputID][outputInfo[outputID].version] = new SessionTreeNode(outputID);
|
|
165
|
-
currentNodes[outputID][outputInfo[outputID].version].data.push(new SessionOutputData(outputs[outputID]));
|
|
166
|
-
if (outputs[outputID].content) {
|
|
167
|
-
for (let i = 0, len = outputs[outputID].content!.length; i < len; i++) {
|
|
168
|
-
if (outputs[outputID].content![i].format === 'sdtf' && !this._sessionEngine.loadSdtf) continue;
|
|
169
|
-
if (this._globalAccessObjects.loadContent)
|
|
170
|
-
promises.push(this._globalAccessObjects.loadContent(outputs[outputID].content![i], this._sessionEngine.jwtToken, outputID + '_' + outputInfo[outputID].version + '_' + i));
|
|
171
|
-
promisesNodes.push(currentNodes[outputID][outputInfo[outputID].version]);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
} else {
|
|
175
|
-
currentNodes[outputID][outputInfo[outputID].version] = this._loadedOutputNodes[outputID][outputInfo[outputID].version];
|
|
176
|
-
// no loading necessary, progress done
|
|
177
|
-
progress[outputID] = 1;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (maxDelay && throwDelay)
|
|
182
|
-
throw new OutputDelayException(maxDelay);
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* WARNING: After this point outputs object cannot be used anymore.
|
|
186
|
-
* This can happen when fast consecutive scene updates are done.
|
|
187
|
-
* Therefore, we stored the data in the outputInfo.
|
|
188
|
-
*/
|
|
189
|
-
|
|
190
|
-
await Promise.all(promises);
|
|
191
|
-
|
|
192
|
-
listenerTokens.forEach(t => this._eventEngine.removeListener(t));
|
|
193
|
-
|
|
194
|
-
// all promises are resolved, await in the next lines is just for structural purposes
|
|
195
|
-
for (let i = 0; i < promises.length; i++)
|
|
196
|
-
promisesNodes[i].addChild(await promises[i]);
|
|
197
|
-
|
|
198
|
-
// here we assign all outputs just to the node and return it
|
|
199
|
-
for (const outputID in outputInfo)
|
|
200
|
-
if (currentNodes[outputID][outputInfo[outputID].version])
|
|
201
|
-
node.addChild(currentNodes[outputID][outputInfo[outputID].version]);
|
|
202
|
-
|
|
203
|
-
// save the nodes as the last available version
|
|
204
|
-
for (const outputID in outputInfo) {
|
|
205
|
-
if (!currentNodes[outputID][outputInfo[outputID].version]) continue;
|
|
206
|
-
this._loadedOutputNodes[outputID] = {};
|
|
207
|
-
this._loadedOutputNodes[outputID][outputInfo[outputID].version] = currentNodes[outputID][outputInfo[outputID].version];
|
|
208
|
-
this._lastOutputNodes[outputID] = {};
|
|
209
|
-
this._lastOutputNodes[outputID][outputInfo[outputID].version] = currentNodes[outputID][outputInfo[outputID].version];
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
for (const outputID in outputInfo) {
|
|
213
|
-
if (!currentNodes[outputID][outputInfo[outputID].version]) continue;
|
|
214
|
-
if (currentNodes[outputID][outputInfo[outputID].version].children.length > 1) {
|
|
215
|
-
for (let i = 0, len = outputInfo[outputID].contentFormat!.length; i < len; i++) {
|
|
216
|
-
if (outputInfo[outputID].contentFormat[i] === 'sdtf' && this._sessionEngine.loadSdtf === true) {
|
|
217
|
-
this.mergeContentNodes(currentNodes[outputID][outputInfo[outputID].version]);
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
this.assignMaterials(node);
|
|
225
|
-
this._performanceEvaluator.endSection('outputLoading');
|
|
226
|
-
return node;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// #endregion Public Methods (2)
|
|
230
|
-
|
|
231
|
-
// #region Private Methods (2)
|
|
232
|
-
|
|
233
|
-
private assignMaterials(node: ITreeNode) {
|
|
234
|
-
const addMaterialToGeometry = (node: ITreeNode, material: IMaterialAbstractData) => {
|
|
235
|
-
for (let i = 0; i < node.data.length; i++) {
|
|
236
|
-
if (node.data[i] instanceof GeometryData) {
|
|
237
|
-
const geometry = <GeometryData>node.data[i];
|
|
238
|
-
const currentMaterial = geometry.material;
|
|
239
|
-
if (currentMaterial === null || currentMaterial.materialOutput === true) {
|
|
240
|
-
geometry.material = material;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
for (let i = 0; i < node.children.length; i++) {
|
|
246
|
-
const child = node.children[i];
|
|
247
|
-
if (child) addMaterialToGeometry(child, material);
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
const getMaterialData = (node: ITreeNode, materials: IMaterialAbstractData[] = []): IMaterialAbstractData[] => {
|
|
252
|
-
for (let k = 0; k < node.data.length; k++) {
|
|
253
|
-
if (node.data[k] instanceof AbstractMaterialData) {
|
|
254
|
-
const material = <IMaterialAbstractData>node.data[k];
|
|
255
|
-
material.materialOutput = true;
|
|
256
|
-
materials.push(material);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
for (let k = 0; k < node.children.length; k++) {
|
|
261
|
-
const child = node.children[k];
|
|
262
|
-
if (!child) continue;
|
|
263
|
-
materials.push(...getMaterialData(child));
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
return materials;
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
for (let m = 0; m < node.children.length; m++) {
|
|
270
|
-
// per output node, we go through the material assignment process
|
|
271
|
-
const outputNode = node.children[m];
|
|
272
|
-
if (!outputNode) continue;
|
|
273
|
-
|
|
274
|
-
// we go through all data properties, normally, there should ony one, but we just make sure
|
|
275
|
-
for (let i = 0; i < outputNode.data.length; i++) {
|
|
276
|
-
if (!(outputNode.data[i] instanceof SessionOutputData)) continue;
|
|
277
|
-
|
|
278
|
-
// the session output data contains information about this Output
|
|
279
|
-
// most importantly the SessionOutput property with the material and content in it
|
|
280
|
-
const sessionOutputData = <SessionOutputData>outputNode.data[i];
|
|
281
|
-
|
|
282
|
-
// case 1: we have a specific material id defined, let's use that
|
|
283
|
-
if (sessionOutputData.responseOutput.material) {
|
|
284
|
-
let materialNodes: ITreeNode[] = [];
|
|
285
|
-
// now we have id
|
|
286
|
-
// get material with it
|
|
287
|
-
for (let n = 0; n < node.children.length; n++) {
|
|
288
|
-
const materialNode = node.children[n];
|
|
289
|
-
if (!materialNode) continue;
|
|
290
|
-
if (materialNode.name === sessionOutputData.responseOutput.material)
|
|
291
|
-
materialNodes = materialNode.children;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
const geometryNodes = outputNode.children;
|
|
295
|
-
|
|
296
|
-
if (materialNodes.length >= geometryNodes.length) {
|
|
297
|
-
for (let n = 0; n < geometryNodes.length; n++) {
|
|
298
|
-
addMaterialToGeometry(geometryNodes[n], getMaterialData(materialNodes[n])[0]);
|
|
299
|
-
}
|
|
300
|
-
} else {
|
|
301
|
-
if (materialNodes.length >= 1)
|
|
302
|
-
for (let n = 0; n < geometryNodes.length; n++) {
|
|
303
|
-
addMaterialToGeometry(geometryNodes[n], getMaterialData(materialNodes[0])[0]);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
// case 2: there is no specific material id defined, maybe in the content we can match geometries to ids
|
|
308
|
-
else {
|
|
309
|
-
// now we hope that in our content, there are exactly the amount of geometries and material, this will be interesting :)
|
|
310
|
-
|
|
311
|
-
const sessionOutputContent = sessionOutputData.responseOutput.content;
|
|
312
|
-
if (sessionOutputContent === undefined) continue;
|
|
313
|
-
|
|
314
|
-
const materialNodes = [];
|
|
315
|
-
const geometryNodes = [];
|
|
316
|
-
for (let i = 0; i < sessionOutputContent.length; i++) {
|
|
317
|
-
if (sessionOutputContent[i].format === 'material') {
|
|
318
|
-
if (outputNode.children[i]) materialNodes.push(outputNode.children[i]);
|
|
319
|
-
} else {
|
|
320
|
-
if (outputNode.children[i]) geometryNodes.push(outputNode.children[i]);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
if (materialNodes.length >= geometryNodes.length) {
|
|
325
|
-
for (let n = 0; n < geometryNodes.length; n++) {
|
|
326
|
-
addMaterialToGeometry(geometryNodes[n], getMaterialData(materialNodes[n])[0]);
|
|
327
|
-
}
|
|
328
|
-
} else {
|
|
329
|
-
if (materialNodes.length >= 1)
|
|
330
|
-
for (let n = 0; n < geometryNodes.length; n++) {
|
|
331
|
-
addMaterialToGeometry(geometryNodes[n], getMaterialData(materialNodes[0])[0]);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
private mergeContentNodes(node: ISessionTreeNode) {
|
|
340
|
-
if (!(node.children.length > 1)) return;
|
|
341
|
-
|
|
342
|
-
const children = [];
|
|
343
|
-
while (node.children.length > 0) {
|
|
344
|
-
children.push(...node.children[0].children);
|
|
345
|
-
node.removeChild(node.children[0]);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
const mergeNodes = (node1: ITreeNode, node2: ITreeNode) => {
|
|
349
|
-
for (let i = 0; i < node1.data.length; i++)
|
|
350
|
-
node2.data.push(node1.data[i]);
|
|
351
|
-
|
|
352
|
-
for (let i = 0; i < node1.children.length; i++) {
|
|
353
|
-
let childNode;
|
|
354
|
-
for (let j = 0; j < node2.children.length; j++) {
|
|
355
|
-
if (node1.children[i].name === node2.children[j].name) {
|
|
356
|
-
childNode = node2.children[j];
|
|
357
|
-
break;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
if (!childNode) {
|
|
361
|
-
childNode = new TreeNode(node1.children[i].name);
|
|
362
|
-
node2.addChild(childNode);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
mergeNodes(node1.children[i], childNode);
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
const newChild = new TreeNode('content_array');
|
|
370
|
-
node.addChild(newChild);
|
|
371
|
-
for (let i = 0; i < children.length; i++)
|
|
372
|
-
mergeNodes(children[i], newChild);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
// #endregion Private Methods (2)
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
// #endregion Classes (1)
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { AbstractTreeNodeData } from '@shapediver/viewer.shared.node-tree';
|
|
2
|
-
import { ISessionData } from '../interfaces/ISessionData';
|
|
3
|
-
import { ShapeDiverResponseDto } from '@shapediver/sdk.geometry-api-sdk-v2';
|
|
4
|
-
|
|
5
|
-
export class SessionData extends AbstractTreeNodeData implements ISessionData {
|
|
6
|
-
// #region Properties (1)
|
|
7
|
-
|
|
8
|
-
#responseDto: ShapeDiverResponseDto;
|
|
9
|
-
|
|
10
|
-
// #endregion Properties (1)
|
|
11
|
-
|
|
12
|
-
// #region Constructors (1)
|
|
13
|
-
|
|
14
|
-
constructor(
|
|
15
|
-
responseDto: ShapeDiverResponseDto,
|
|
16
|
-
id?: string,
|
|
17
|
-
version?: string
|
|
18
|
-
) {
|
|
19
|
-
super(id, version);
|
|
20
|
-
this.#responseDto = responseDto;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// #endregion Constructors (1)
|
|
24
|
-
|
|
25
|
-
// #region Public Getters And Setters (2)
|
|
26
|
-
|
|
27
|
-
public get responseDto(): ShapeDiverResponseDto {
|
|
28
|
-
return this.#responseDto;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public set responseDto(value: ShapeDiverResponseDto) {
|
|
32
|
-
this.#responseDto = value;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// #endregion Public Getters And Setters (2)
|
|
36
|
-
|
|
37
|
-
// #region Public Methods (1)
|
|
38
|
-
|
|
39
|
-
public clone(): ISessionData {
|
|
40
|
-
return new SessionData(this.responseDto, this.id, this.version);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// #endregion Public Methods (1)
|
|
44
|
-
}
|