@shapediver/viewer.data-engine.sdtf-engine 1.15.7 → 2.0.2
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/SDTFEngine.d.ts +2 -2
- package/dist/SDTFEngine.d.ts.map +1 -1
- package/dist/SDTFEngine.js +7 -7
- package/dist/SDTFEngine.js.map +1 -1
- package/package.json +15 -12
- package/src/SDTFEngine.ts +285 -0
- package/src/index.ts +5 -0
- package/tsconfig.json +17 -0
package/dist/SDTFEngine.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ITreeNode } from '@shapediver/viewer.shared.node-tree';
|
|
2
2
|
import { ShapeDiverResponseOutputContent } from '@shapediver/sdk.geometry-api-sdk-v2';
|
|
3
3
|
export declare class SDTFEngine {
|
|
4
4
|
private readonly _logger;
|
|
@@ -10,7 +10,7 @@ export declare class SDTFEngine {
|
|
|
10
10
|
* @param content the geometry content
|
|
11
11
|
* @returns the scene graph node
|
|
12
12
|
*/
|
|
13
|
-
loadContent(content: ShapeDiverResponseOutputContent): Promise<
|
|
13
|
+
loadContent(content: ShapeDiverResponseOutputContent): Promise<ITreeNode>;
|
|
14
14
|
/**
|
|
15
15
|
* Create an overview of the SDTF file.
|
|
16
16
|
* This overview is used for the data visualization.
|
package/dist/SDTFEngine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SDTFEngine.d.ts","sourceRoot":"","sources":["../src/SDTFEngine.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SDTFEngine.d.ts","sourceRoot":"","sources":["../src/SDTFEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAY,MAAM,qCAAqC,CAAA;AAIzE,OAAO,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAA;AAIrF,qBACa,UAAU;IAGnB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6C;IAErE,OAAO,CAAC,WAAW,CAAsB;;IAYzC;;;;;OAKG;IACU,WAAW,CAAC,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC,SAAS,CAAC;IAkCtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;YACW,kBAAkB;IA2EhC;;;;;OAKG;YACW,cAAc;IAa5B;;;;;;OAMG;YACW,SAAS;IA2BvB;;;;;;OAMG;YACW,QAAQ;IAkBtB;;;;;;OAMG;YACW,QAAQ;CA4BzB"}
|
package/dist/SDTFEngine.js
CHANGED
|
@@ -19,12 +19,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.SDTFEngine = void 0;
|
|
22
|
-
const sdk_sdtf_v1_1 = require("@shapediver/sdk.sdtf-v1");
|
|
23
|
-
const sdk_sdtf_primitives_1 = require("@shapediver/sdk.sdtf-primitives");
|
|
24
22
|
const viewer_shared_node_tree_1 = require("@shapediver/viewer.shared.node-tree");
|
|
25
23
|
const tsyringe_1 = require("tsyringe");
|
|
26
24
|
const viewer_shared_services_1 = require("@shapediver/viewer.shared.services");
|
|
27
25
|
const viewer_shared_types_1 = require("@shapediver/viewer.shared.types");
|
|
26
|
+
const sdk_sdtf_v1_1 = require("@shapediver/sdk.sdtf-v1");
|
|
27
|
+
const sdk_sdtf_primitives_1 = require("@shapediver/sdk.sdtf-primitives");
|
|
28
28
|
let SDTFEngine = class SDTFEngine {
|
|
29
29
|
// #endregion Properties (2)
|
|
30
30
|
// #region Constructors (1)
|
|
@@ -46,10 +46,10 @@ let SDTFEngine = class SDTFEngine {
|
|
|
46
46
|
// We have to be safe and check if the content is a valid SDTF file
|
|
47
47
|
if (!content || (content && !content.href)) {
|
|
48
48
|
const error = new viewer_shared_services_1.ShapeDiverViewerDataProcessingError('SDTFEngine.loadContent: Invalid content was provided to geometry engine.');
|
|
49
|
-
throw this._logger.handleError(viewer_shared_services_1.
|
|
49
|
+
throw this._logger.handleError(viewer_shared_services_1.LOGGING_TOPIC.DATA_PROCESSING, `SDTFEngine.loadContent`, error);
|
|
50
50
|
}
|
|
51
51
|
// create the sdtf sdk
|
|
52
|
-
const sdk = yield sdk_sdtf_v1_1.create();
|
|
52
|
+
const sdk = yield (0, sdk_sdtf_v1_1.create)();
|
|
53
53
|
// crete the sdtf parser
|
|
54
54
|
const parser = sdk.createParser();
|
|
55
55
|
// parse the file
|
|
@@ -63,7 +63,7 @@ let SDTFEngine = class SDTFEngine {
|
|
|
63
63
|
return node;
|
|
64
64
|
}
|
|
65
65
|
catch (e) {
|
|
66
|
-
throw this._logger.handleError(viewer_shared_services_1.
|
|
66
|
+
throw this._logger.handleError(viewer_shared_services_1.LOGGING_TOPIC.DATA_PROCESSING, `SDTFEngine.load`, e);
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
}
|
|
@@ -157,7 +157,7 @@ let SDTFEngine = class SDTFEngine {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
return new viewer_shared_types_1.
|
|
160
|
+
return new viewer_shared_types_1.SDTFOverviewData(overview);
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
@@ -267,7 +267,7 @@ let SDTFEngine = class SDTFEngine {
|
|
|
267
267
|
}
|
|
268
268
|
};
|
|
269
269
|
SDTFEngine = __decorate([
|
|
270
|
-
tsyringe_1.singleton(),
|
|
270
|
+
(0, tsyringe_1.singleton)(),
|
|
271
271
|
__metadata("design:paramtypes", [])
|
|
272
272
|
], SDTFEngine);
|
|
273
273
|
exports.SDTFEngine = SDTFEngine;
|
package/dist/SDTFEngine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SDTFEngine.js","sourceRoot":"","sources":["../src/SDTFEngine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"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CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;aACjE;YAED,uDAAuD;YACvD,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBACnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;oBACnD,wBAAwB;oBACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;iBAC3D;aACJ;YAED,uDAAuD;YACvD,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBACnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;oBACnD,2BAA2B;oBAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;iBAC3D;aACJ;YAED,OAAO,OAAO,CAAC;QACnB,CAAC;KAAA;CAGJ,CAAA;AAnRY,UAAU;IADtB,IAAA,oBAAS,GAAE;;GACC,UAAU,CAmRtB;AAnRY,gCAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapediver/viewer.data-engine.sdtf-engine",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Michael Oppitz <michael@shapediver.com>",
|
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
"test": "__tests__"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
|
-
"dist"
|
|
13
|
+
"dist",
|
|
14
|
+
"src",
|
|
15
|
+
"package.json",
|
|
16
|
+
"README.md",
|
|
17
|
+
"tsconfig.json"
|
|
14
18
|
],
|
|
15
19
|
"publishConfig": {
|
|
16
20
|
"access": "public"
|
|
@@ -20,11 +24,10 @@
|
|
|
20
24
|
"url": "git+https://github.com/shapediver/Viewer.git"
|
|
21
25
|
},
|
|
22
26
|
"scripts": {
|
|
23
|
-
"test": "bash ../../scripts/test.sh",
|
|
24
27
|
"check": "tsc --noEmit",
|
|
25
|
-
"build": "bash ../../scripts/build.sh",
|
|
26
|
-
"build-watch": "bash ../../scripts/build-watch.sh",
|
|
27
|
-
"build-dep": "bash ../../scripts/build-dep.sh"
|
|
28
|
+
"build": "bash ../../scripts/building/build.sh",
|
|
29
|
+
"build-watch": "bash ../../scripts/building/build-watch.sh",
|
|
30
|
+
"build-dep": "bash ../../scripts/building/build-dep.sh"
|
|
28
31
|
},
|
|
29
32
|
"bugs": {
|
|
30
33
|
"url": "https://github.com/shapediver/Viewer/issues"
|
|
@@ -38,14 +41,14 @@
|
|
|
38
41
|
"dependencies": {
|
|
39
42
|
"@shapediver/sdk.geometry-api-sdk-v2": "^1.0.24",
|
|
40
43
|
"@shapediver/sdk.sdtf-v1": "1.0.0",
|
|
41
|
-
"@shapediver/viewer.data-engine.shared-types": "
|
|
42
|
-
"@shapediver/viewer.shared.build-data": "
|
|
43
|
-
"@shapediver/viewer.shared.node-tree": "
|
|
44
|
-
"@shapediver/viewer.shared.services": "
|
|
45
|
-
"@shapediver/viewer.shared.types": "
|
|
44
|
+
"@shapediver/viewer.data-engine.shared-types": "2.0.2",
|
|
45
|
+
"@shapediver/viewer.shared.build-data": "2.0.2",
|
|
46
|
+
"@shapediver/viewer.shared.node-tree": "2.0.2",
|
|
47
|
+
"@shapediver/viewer.shared.services": "2.0.2",
|
|
48
|
+
"@shapediver/viewer.shared.types": "2.0.2",
|
|
46
49
|
"axios": "^0.21.1",
|
|
47
50
|
"gl-matrix": "3.3.0",
|
|
48
51
|
"tsyringe": "^4.5.0"
|
|
49
52
|
},
|
|
50
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "1655aca09350a0a27686512bcac140df47c8a0ec"
|
|
51
54
|
}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { ITreeNode, TreeNode } from '@shapediver/viewer.shared.node-tree'
|
|
2
|
+
import { container, singleton } from 'tsyringe'
|
|
3
|
+
import { Logger, LOGGING_TOPIC, ShapeDiverViewerDataProcessingError } from '@shapediver/viewer.shared.services'
|
|
4
|
+
import { SDTFAttributesData, SDTFAttributeData, SDTFItemData, SDTFOverviewData } from '@shapediver/viewer.shared.types'
|
|
5
|
+
import { ShapeDiverResponseOutputContent } from '@shapediver/sdk.geometry-api-sdk-v2'
|
|
6
|
+
import { create, ISdtfReadableAsset, ISdtfReadableAttributes, ISdtfReadableChunk, ISdtfReadableDataItem, ISdtfReadableNode, SdtfTypeHintName } from '@shapediver/sdk.sdtf-v1'
|
|
7
|
+
import { SdtfPrimitiveTypeGuard } from '@shapediver/sdk.sdtf-primitives'
|
|
8
|
+
|
|
9
|
+
@singleton()
|
|
10
|
+
export class SDTFEngine {
|
|
11
|
+
// #region Properties (2)
|
|
12
|
+
|
|
13
|
+
private readonly _logger: Logger = <Logger>container.resolve(Logger);
|
|
14
|
+
|
|
15
|
+
private _parsedFile!: ISdtfReadableAsset;
|
|
16
|
+
|
|
17
|
+
// #endregion Properties (2)
|
|
18
|
+
|
|
19
|
+
// #region Constructors (1)
|
|
20
|
+
|
|
21
|
+
constructor() { }
|
|
22
|
+
|
|
23
|
+
// #endregion Constructors (1)
|
|
24
|
+
|
|
25
|
+
// #region Public Methods (1)
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Load the sdtf content into a scene graph node.
|
|
29
|
+
*
|
|
30
|
+
* @param content the geometry content
|
|
31
|
+
* @returns the scene graph node
|
|
32
|
+
*/
|
|
33
|
+
public async loadContent(content: ShapeDiverResponseOutputContent): Promise<ITreeNode> {
|
|
34
|
+
const node = new TreeNode('sdtf');
|
|
35
|
+
|
|
36
|
+
// We have to be safe and check if the content is a valid SDTF file
|
|
37
|
+
if (!content || (content && !content.href)) {
|
|
38
|
+
const error = new ShapeDiverViewerDataProcessingError('SDTFEngine.loadContent: Invalid content was provided to geometry engine.');
|
|
39
|
+
throw this._logger.handleError(LOGGING_TOPIC.DATA_PROCESSING, `SDTFEngine.loadContent`, error);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// create the sdtf sdk
|
|
43
|
+
const sdk = await create();
|
|
44
|
+
// crete the sdtf parser
|
|
45
|
+
const parser = sdk.createParser();
|
|
46
|
+
// parse the file
|
|
47
|
+
this._parsedFile = await parser.readFromUrl(content.href!);
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
// crete the overview and save it in the node data
|
|
51
|
+
node.data.push(await this.createSDTFOverview());
|
|
52
|
+
|
|
53
|
+
// add the loaded chunks to the node
|
|
54
|
+
for (let i = 0; i < this._parsedFile.chunks.length; i++)
|
|
55
|
+
node.children.push(await this.loadChunk(this._parsedFile.chunks[i], i));
|
|
56
|
+
|
|
57
|
+
return node;
|
|
58
|
+
} catch (e) {
|
|
59
|
+
throw this._logger.handleError(LOGGING_TOPIC.DATA_PROCESSING, `SDTFEngine.load`, e);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// #endregion Public Methods (1)
|
|
64
|
+
|
|
65
|
+
// #region Private Methods (5)
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Create an overview of the SDTF file.
|
|
69
|
+
* This overview is used for the data visualization.
|
|
70
|
+
* It is structured as a dictionary with the name as the key and an array of Objects as the value.
|
|
71
|
+
* The array of objects contains the different types that can be found in the SDTF file under the same name.
|
|
72
|
+
*
|
|
73
|
+
* Example:
|
|
74
|
+
* {
|
|
75
|
+
* "color": [
|
|
76
|
+
* {
|
|
77
|
+
* typeHint: 'string',
|
|
78
|
+
* count: 2,
|
|
79
|
+
* values: ["red", "blue"]
|
|
80
|
+
* },
|
|
81
|
+
* {
|
|
82
|
+
* typeHint: 'numberArray',
|
|
83
|
+
* count: 2,
|
|
84
|
+
* values: [[1,0,0,1], [0,0,1,1]]
|
|
85
|
+
* },
|
|
86
|
+
* ]
|
|
87
|
+
* }
|
|
88
|
+
*
|
|
89
|
+
* The overview contains the following information:
|
|
90
|
+
* - name of the attribute + type of the attribute
|
|
91
|
+
* - the count
|
|
92
|
+
* - for numerical attributes, the min and max values
|
|
93
|
+
* - for string attributes, the unique values
|
|
94
|
+
*
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
private async createSDTFOverview(): Promise<SDTFOverviewData> {
|
|
98
|
+
const overview: {
|
|
99
|
+
[key: string]: {
|
|
100
|
+
typeHint: SdtfTypeHintName | string;
|
|
101
|
+
count: number;
|
|
102
|
+
values?: string[];
|
|
103
|
+
min?: number;
|
|
104
|
+
max?: number;
|
|
105
|
+
}[];
|
|
106
|
+
} = {};
|
|
107
|
+
|
|
108
|
+
// go through all attributes
|
|
109
|
+
for (let i = 0; i < this._parsedFile.attributes.length; i++) {
|
|
110
|
+
const attributes = this._parsedFile.attributes[i];
|
|
111
|
+
|
|
112
|
+
// go through all entries
|
|
113
|
+
for (let key in attributes.entries) {
|
|
114
|
+
const dataToCopy = attributes.entries[key];
|
|
115
|
+
const value = await dataToCopy.getContent();
|
|
116
|
+
|
|
117
|
+
// create the type hint to use
|
|
118
|
+
const dataTypehint = dataToCopy.typeHint === undefined ? 'undefined' : dataToCopy.typeHint.name;
|
|
119
|
+
|
|
120
|
+
// check if the attribute is already in the overview
|
|
121
|
+
const existingEntries = overview[key] ? overview[key].filter(o => o.typeHint === dataTypehint) : [];
|
|
122
|
+
|
|
123
|
+
if (overview[key] && existingEntries.length > 0) {
|
|
124
|
+
// update the existing entry
|
|
125
|
+
const entry = existingEntries[0];
|
|
126
|
+
// update the count
|
|
127
|
+
entry.count++;
|
|
128
|
+
|
|
129
|
+
// update the values
|
|
130
|
+
if (SdtfPrimitiveTypeGuard.isStringType(dataTypehint)) {
|
|
131
|
+
if (!entry.values?.includes(<string>value))
|
|
132
|
+
entry.values?.push(<string>value)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// update the min and max
|
|
136
|
+
if (SdtfPrimitiveTypeGuard.isNumberType(dataTypehint)) {
|
|
137
|
+
entry.min = Math.min(<number>value, entry.min!);
|
|
138
|
+
entry.max = Math.max(<number>value, entry.max!);
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
// create a new entry, if the name already exists, but the type does not
|
|
142
|
+
if (overview[key]) {
|
|
143
|
+
overview[key].push({
|
|
144
|
+
typeHint: dataTypehint,
|
|
145
|
+
count: 1,
|
|
146
|
+
})
|
|
147
|
+
}
|
|
148
|
+
// create completely new entry
|
|
149
|
+
else {
|
|
150
|
+
overview[key] = [{
|
|
151
|
+
typeHint: dataTypehint,
|
|
152
|
+
count: 1,
|
|
153
|
+
}]
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// update the values
|
|
157
|
+
if (SdtfPrimitiveTypeGuard.isStringType(dataTypehint)) {
|
|
158
|
+
overview[key][overview[key].length - 1].values = [<string>value];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// update the min and max
|
|
162
|
+
if (SdtfPrimitiveTypeGuard.isNumberType(dataTypehint)) {
|
|
163
|
+
overview[key][overview[key].length - 1].min = <number>value;
|
|
164
|
+
overview[key][overview[key].length - 1].max = <number>value;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return new SDTFOverviewData(overview);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Load the attributes into a SDTFAttributesData data item.
|
|
174
|
+
*
|
|
175
|
+
* @param attributes
|
|
176
|
+
* @returns
|
|
177
|
+
*/
|
|
178
|
+
private async loadAttributes(attributes: ISdtfReadableAttributes): Promise<SDTFAttributesData> {
|
|
179
|
+
const data = new SDTFAttributesData();
|
|
180
|
+
// go through all attributes entries and save them in data items
|
|
181
|
+
for (let key in attributes.entries) {
|
|
182
|
+
if (SdtfPrimitiveTypeGuard.isBooleanType(attributes.entries[key].typeHint?.name) || SdtfPrimitiveTypeGuard.isColorType(attributes.entries[key].typeHint?.name) || SdtfPrimitiveTypeGuard.isNumberType(attributes.entries[key].typeHint?.name) || SdtfPrimitiveTypeGuard.isStringType(attributes.entries[key].typeHint?.name)) {
|
|
183
|
+
// create the data item and save it in the dictionary
|
|
184
|
+
const typeHint = attributes.entries[key].typeHint === undefined ? 'undefined' : attributes.entries[key].typeHint!.name;
|
|
185
|
+
data.attributes[key] = new SDTFAttributeData(typeHint, await attributes.entries[key].getContent());
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return data;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Load the chunk into a scene graph node.
|
|
193
|
+
*
|
|
194
|
+
* @param chunk
|
|
195
|
+
* @param chunkId
|
|
196
|
+
* @returns
|
|
197
|
+
*/
|
|
198
|
+
private async loadChunk(chunk: ISdtfReadableChunk, chunkId: number): Promise<TreeNode> {
|
|
199
|
+
const chunkDef = new TreeNode(chunk.name || 'chunk_' + chunkId);
|
|
200
|
+
|
|
201
|
+
// if there are attributes, add them to the chunk as data
|
|
202
|
+
if (chunk.attributes !== undefined) {
|
|
203
|
+
chunkDef.data.push(await this.loadAttributes(chunk.attributes));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// if there are items, add them to the chunk as children
|
|
207
|
+
if (chunk.items !== undefined && chunk.items.length > 0) {
|
|
208
|
+
for (let i = 0, len = chunk.items.length; i < len; i++) {
|
|
209
|
+
// got through all items
|
|
210
|
+
chunkDef.addChild(await this.loadItem(chunk.items[i], i));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// if there are nodes, add them to the chunk as children
|
|
215
|
+
if (chunk.nodes !== undefined && chunk.nodes.length > 0) {
|
|
216
|
+
for (let i = 0, len = chunk.nodes.length; i < len; i++) {
|
|
217
|
+
// got through all children
|
|
218
|
+
chunkDef.addChild(await this.loadNode(chunk.nodes[i], i));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return chunkDef;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Load the item into a scene graph node.
|
|
227
|
+
*
|
|
228
|
+
* @param item
|
|
229
|
+
* @param itemId
|
|
230
|
+
* @returns
|
|
231
|
+
*/
|
|
232
|
+
private async loadItem(item: ISdtfReadableDataItem, itemId: number): Promise<TreeNode> {
|
|
233
|
+
const itemDef = new TreeNode(itemId + '');
|
|
234
|
+
|
|
235
|
+
// if there are attributes, add them to the item
|
|
236
|
+
let attributes;
|
|
237
|
+
if (item.attributes !== undefined)
|
|
238
|
+
attributes = await this.loadAttributes(item.attributes);
|
|
239
|
+
|
|
240
|
+
// create the typehint
|
|
241
|
+
const typeHint = item.typeHint === undefined ? 'undefined' : item.typeHint!.name;
|
|
242
|
+
|
|
243
|
+
// create the data and save it in the item node
|
|
244
|
+
const itemData = new SDTFItemData(typeHint, await item.getContent(), attributes?.attributes!)
|
|
245
|
+
itemDef.data.push(itemData)
|
|
246
|
+
|
|
247
|
+
return itemDef;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Load the node into a scene graph node.
|
|
252
|
+
*
|
|
253
|
+
* @param node
|
|
254
|
+
* @param nodeId
|
|
255
|
+
* @returns
|
|
256
|
+
*/
|
|
257
|
+
private async loadNode(node: ISdtfReadableNode, nodeId: number): Promise<TreeNode> {
|
|
258
|
+
const nodeDef = new TreeNode(node.name || 'node_' + nodeId);
|
|
259
|
+
|
|
260
|
+
// if there are attributes, add them to the node as data
|
|
261
|
+
if (node.attributes !== undefined) {
|
|
262
|
+
nodeDef.data.push(await this.loadAttributes(node.attributes));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// if there are items, add them to the node as children
|
|
266
|
+
if (node.items !== undefined && node.items.length > 0) {
|
|
267
|
+
for (let i = 0, len = node.items.length; i < len; i++) {
|
|
268
|
+
// got through all items
|
|
269
|
+
nodeDef.addChild(await this.loadItem(node.items[i], i));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// if there are nodes, add them to the node as children
|
|
274
|
+
if (node.nodes !== undefined && node.nodes.length > 0) {
|
|
275
|
+
for (let i = 0, len = node.nodes.length; i < len; i++) {
|
|
276
|
+
// got through all children
|
|
277
|
+
nodeDef.addChild(await this.loadNode(node.nodes[i], i));
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return nodeDef;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// #endregion Private Methods (5)
|
|
285
|
+
}
|
package/src/index.ts
ADDED
package/tsconfig.json
ADDED