@shapediver/viewer.data-engine.geometry-engine 2.7.9 → 2.8.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.
Files changed (34) hide show
  1. package/dist/GeometryEngine.d.ts +6 -1
  2. package/dist/GeometryEngine.d.ts.map +1 -1
  3. package/dist/GeometryEngine.js +89 -95
  4. package/dist/GeometryEngine.js.map +1 -1
  5. package/dist/gltfv1/GLTFLoader.d.ts.map +1 -1
  6. package/dist/gltfv1/GLTFLoader.js +27 -45
  7. package/dist/gltfv1/GLTFLoader.js.map +1 -1
  8. package/dist/gltfv1/SDGTFLoader.d.ts.map +1 -1
  9. package/dist/gltfv1/SDGTFLoader.js +8 -16
  10. package/dist/gltfv1/SDGTFLoader.js.map +1 -1
  11. package/dist/gltfv2/GLTFLoader.d.ts.map +1 -1
  12. package/dist/gltfv2/GLTFLoader.js +58 -71
  13. package/dist/gltfv2/GLTFLoader.js.map +1 -1
  14. package/dist/gltfv2/loaders/AccessorLoader.d.ts.map +1 -1
  15. package/dist/gltfv2/loaders/AccessorLoader.js +2 -3
  16. package/dist/gltfv2/loaders/AccessorLoader.js.map +1 -1
  17. package/dist/gltfv2/loaders/BufferLoader.d.ts.map +1 -1
  18. package/dist/gltfv2/loaders/BufferLoader.js +1 -2
  19. package/dist/gltfv2/loaders/BufferLoader.js.map +1 -1
  20. package/dist/gltfv2/loaders/MaterialLoader.d.ts.map +1 -1
  21. package/dist/gltfv2/loaders/MaterialLoader.js +2 -3
  22. package/dist/gltfv2/loaders/MaterialLoader.js.map +1 -1
  23. package/dist/gltfv2/loaders/TextureLoader.d.ts.map +1 -1
  24. package/dist/gltfv2/loaders/TextureLoader.js +4 -4
  25. package/dist/gltfv2/loaders/TextureLoader.js.map +1 -1
  26. package/package.json +12 -13
  27. package/src/GeometryEngine.ts +108 -92
  28. package/src/gltfv1/GLTFLoader.ts +28 -42
  29. package/src/gltfv1/SDGTFLoader.ts +9 -16
  30. package/src/gltfv2/GLTFLoader.ts +72 -83
  31. package/src/gltfv2/loaders/AccessorLoader.ts +4 -10
  32. package/src/gltfv2/loaders/BufferLoader.ts +1 -2
  33. package/src/gltfv2/loaders/MaterialLoader.ts +2 -3
  34. package/src/gltfv2/loaders/TextureLoader.ts +4 -4
@@ -1,5 +1,5 @@
1
1
  import { ITreeNode, TreeNode } from '@shapediver/viewer.shared.node-tree'
2
- import { Logger, LOGGING_TOPIC, ShapeDiverViewerDataProcessingError } from '@shapediver/viewer.shared.services'
2
+ import { Logger, ShapeDiverViewerDataProcessingError } from '@shapediver/viewer.shared.services'
3
3
  import {
4
4
  ACCESSORCOMPONENTTYPE_V1 as ACCESSOR_COMPONENTTYPE,
5
5
  ACCESSORTYPE_V1 as ACCESSORTYPE,
@@ -12,14 +12,13 @@ import {
12
12
  PRIMITIVE_MODE,
13
13
  PrimitiveData,
14
14
  } from '@shapediver/viewer.shared.types'
15
- import { container } from 'tsyringe'
16
15
  import { mat4, vec3, vec4 } from 'gl-matrix'
17
16
 
18
17
  export class SDGTFLoader {
19
18
  // #region Properties (5)
20
19
 
21
20
  private readonly BINARY_EXTENSION_HEADER_LENGTH = 20;
22
- private readonly _logger: Logger = <Logger>container.resolve(Logger);
21
+ private readonly _logger: Logger = Logger.instance;
23
22
 
24
23
  private _body!: ArrayBuffer;
25
24
  private _content!: ISDGTF_v1;
@@ -38,10 +37,8 @@ export class SDGTFLoader {
38
37
  contentLength: headerDataView.getUint32(13, true),
39
38
  contentFormat: headerDataView.getUint32(17, true)
40
39
  }
41
- if (header.magic != 'sdgTF') {
42
- const error = new ShapeDiverViewerDataProcessingError('SDGTFLoader.load: Invalid data: sdgTF magic wrong.');
43
- throw this._logger.handleError(LOGGING_TOPIC.DATA_PROCESSING, `SDGTFLoader.load`, error);
44
- }
40
+ if (header.magic != 'sdgTF')
41
+ throw new ShapeDiverViewerDataProcessingError('SDGTFLoader.load: Invalid data: sdgTF magic wrong.');
45
42
 
46
43
  // create content
47
44
  const contentDataView = new DataView(binaryGeometry, gltfLength + this.BINARY_EXTENSION_HEADER_LENGTH + 1, header.contentLength);
@@ -52,11 +49,7 @@ export class SDGTFLoader {
52
49
  return new TreeNode();
53
50
  }
54
51
 
55
- try {
56
- return await this.loadScene();
57
- } catch (e) {
58
- throw this._logger.handleError(LOGGING_TOPIC.DATA_PROCESSING, `SDGTFLoader.load`, e);
59
- }
52
+ return await this.loadScene();
60
53
  }
61
54
 
62
55
  // #endregion Public Methods (1)
@@ -115,7 +108,7 @@ export class SDGTFLoader {
115
108
  const arcZAxis = vec3.cross(vec3.create(), arcXAxis, arcYAxis)
116
109
 
117
110
  if (arcRadius <= 0) {
118
- this._logger.warn(LOGGING_TOPIC.DATA_PROCESSING, 'SDGTFLoader.loadArcs: Arc radius is <= 0.');
111
+ this._logger.warn('SDGTFLoader.loadArcs: Arc radius is <= 0.');
119
112
  continue;
120
113
  }
121
114
  const points: number[] = [];
@@ -295,7 +288,7 @@ export class SDGTFLoader {
295
288
  const circleZAxis = vec3.cross(vec3.create(), circleXAxis, circleYAxis)
296
289
 
297
290
  if (circleRadius <= 0) {
298
- this._logger.warn(LOGGING_TOPIC.DATA_PROCESSING, 'SDGTFLoader.loadCircles: Circle radius is <= 0.');
291
+ this._logger.warn('SDGTFLoader.loadCircles: Circle radius is <= 0.');
299
292
  continue;
300
293
  }
301
294
 
@@ -382,7 +375,7 @@ export class SDGTFLoader {
382
375
  vec3.normalize(cylinderYAxis, cylinderYAxis);
383
376
 
384
377
  if (cylinderRadius <= 0) {
385
- this._logger.warn(LOGGING_TOPIC.DATA_PROCESSING, 'SDGTFLoader.loadCylinders: Cylinder radius is <= 0.');
378
+ this._logger.warn('SDGTFLoader.loadCylinders: Cylinder radius is <= 0.');
386
379
  continue;
387
380
  }
388
381
 
@@ -505,7 +498,7 @@ export class SDGTFLoader {
505
498
  const sphereTranslation = vec3.fromValues(data.array[index + 0], data.array[index + 1], data.array[index + 2]);
506
499
  const sphereRadius = data.array[index + 3];
507
500
  if (sphereRadius <= 0) {
508
- this._logger.warn(LOGGING_TOPIC.DATA_PROCESSING, 'SDGTFLoader.loadSpheres: Sphere radius is <= 0.');
501
+ this._logger.warn('SDGTFLoader.loadSpheres: Sphere radius is <= 0.');
509
502
  continue;
510
503
  }
511
504
 
@@ -3,12 +3,10 @@ import {
3
3
  Converter,
4
4
  HttpClient,
5
5
  Logger,
6
- LOGGING_TOPIC,
7
6
  PerformanceEvaluator,
8
7
  ShapeDiverViewerDataProcessingError,
9
8
  UuidGenerator,
10
9
  } from '@shapediver/viewer.shared.services'
11
- import { container } from 'tsyringe'
12
10
  import { IGLTF_v2 } from '@shapediver/viewer.data-engine.shared-types'
13
11
  import { mat4, vec3, vec4 } from 'gl-matrix'
14
12
  import {
@@ -58,12 +56,12 @@ export class GLTFLoader {
58
56
  // #region Properties (17)
59
57
 
60
58
  private readonly BINARY_EXTENSION_HEADER_LENGTH = 20;
61
- private readonly _converter: Converter = <Converter>container.resolve(Converter);
59
+ private readonly _converter: Converter = Converter.instance;
62
60
  private readonly _globalTransformation = mat4.fromValues(1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1);
63
- private readonly _httpClient: HttpClient = <HttpClient>container.resolve(HttpClient);
64
- private readonly _logger: Logger = <Logger>container.resolve(Logger);
65
- private readonly _performanceEvaluator = <PerformanceEvaluator>container.resolve(PerformanceEvaluator);
66
- private readonly _uuidGenerator: UuidGenerator = <UuidGenerator>container.resolve(UuidGenerator);
61
+ private readonly _httpClient: HttpClient = HttpClient.instance;
62
+ private readonly _logger: Logger = Logger.instance;
63
+ private readonly _performanceEvaluator = PerformanceEvaluator.instance;
64
+ private readonly _uuidGenerator: UuidGenerator = UuidGenerator.instance;
67
65
 
68
66
  private _accessorLoader!: AccessorLoader;
69
67
  private _baseUri: string | undefined;
@@ -88,89 +86,81 @@ export class GLTFLoader {
88
86
  this._body = gltfBinary.slice(this.BINARY_EXTENSION_HEADER_LENGTH + gltfHeader.contentLength + 8, gltfHeader.length);
89
87
  this._content = content;
90
88
 
91
- try {
92
- this.validateVersionAndExtensions();
93
-
94
- const dracoModule = await new DRACO();
95
-
96
- this._bufferLoader = new BufferLoader(this._content, this._body, this._baseUri);
97
- await this._bufferLoader.load();
98
- this._bufferViewLoader = new BufferViewLoader(this._content, this._bufferLoader);
99
- this._bufferViewLoader.load();
100
- this._accessorLoader = new AccessorLoader(this._content, this._bufferViewLoader);
101
- this._accessorLoader.load();
102
- this._textureLoader = new TextureLoader(this._content, this._bufferViewLoader, this._baseUri);
103
- await this._textureLoader.load();
104
- this._materialLoader = new MaterialLoader(this._content, this._textureLoader);
105
- await this._materialLoader.load();
106
- this._geometryLoader = new GeometryLoader(this._content, this._accessorLoader, this._bufferViewLoader, this._materialLoader, dracoModule);
107
-
108
- const node = this.loadScene();
109
-
110
- if (this._content.extensions && this._content.extensions[GLTF_EXTENSIONS.KHR_MATERIALS_VARIANTS]) {
111
- const variants = this._content.extensions[GLTF_EXTENSIONS.KHR_MATERIALS_VARIANTS].variants;
112
- for (let i = 0; i < variants.length; i++)
113
- this._geometryLoader.materialVariantsData.variants.push(variants[i].name);
114
- this._geometryLoader.materialVariantsData.variantIndex = 0;
115
- node.data.push(this._geometryLoader.materialVariantsData)
116
- }
89
+ this.validateVersionAndExtensions();
90
+
91
+ const dracoModule = await new DRACO();
92
+
93
+ this._bufferLoader = new BufferLoader(this._content, this._body, this._baseUri);
94
+ await this._bufferLoader.load();
95
+ this._bufferViewLoader = new BufferViewLoader(this._content, this._bufferLoader);
96
+ this._bufferViewLoader.load();
97
+ this._accessorLoader = new AccessorLoader(this._content, this._bufferViewLoader);
98
+ this._accessorLoader.load();
99
+ this._textureLoader = new TextureLoader(this._content, this._bufferViewLoader, this._baseUri);
100
+ await this._textureLoader.load();
101
+ this._materialLoader = new MaterialLoader(this._content, this._textureLoader);
102
+ await this._materialLoader.load();
103
+ this._geometryLoader = new GeometryLoader(this._content, this._accessorLoader, this._bufferViewLoader, this._materialLoader, dracoModule);
104
+
105
+ const node = this.loadScene();
106
+
107
+ if (this._content.extensions && this._content.extensions[GLTF_EXTENSIONS.KHR_MATERIALS_VARIANTS]) {
108
+ const variants = this._content.extensions[GLTF_EXTENSIONS.KHR_MATERIALS_VARIANTS].variants;
109
+ for (let i = 0; i < variants.length; i++)
110
+ this._geometryLoader.materialVariantsData.variants.push(variants[i].name);
111
+ this._geometryLoader.materialVariantsData.variantIndex = 0;
112
+ node.data.push(this._geometryLoader.materialVariantsData)
113
+ }
117
114
 
118
- if (this._content.skins !== undefined && this._content.nodes !== undefined) {
119
- for (let i = 0; i < this._content.nodes?.length; i++) {
120
- if (this._content.nodes[i].skin !== undefined) {
121
- const skinDef = this.loadSkin(this._content.nodes[i].skin!);
122
-
123
- const skinNode = this._nodes[i];
124
-
125
- const bones: ITreeNode[] = [];
126
- const boneInverses: mat4[] = [];
127
-
128
- for (let j = 0; j < skinDef.joints.length; j++) {
129
- this._nodes[skinDef.joints[j]].data.push(new BoneData())
130
- bones.push(this._nodes[skinDef.joints[j]]);
131
-
132
- let mat = mat4.create();
133
- if (skinDef.inverseBindMatrices !== undefined) {
134
- const matricesArray = skinDef.inverseBindMatrices!.array;
135
- mat = mat4.fromValues(matricesArray[j * 16 + 0], matricesArray[j * 16 + 1], matricesArray[j * 16 + 2], matricesArray[j * 16 + 3],
136
- matricesArray[j * 16 + 4], matricesArray[j * 16 + 5], matricesArray[j * 16 + 6], matricesArray[j * 16 + 7],
137
- matricesArray[j * 16 + 8], matricesArray[j * 16 + 9], matricesArray[j * 16 + 10], matricesArray[j * 16 + 11],
138
- matricesArray[j * 16 + 12], matricesArray[j * 16 + 13], matricesArray[j * 16 + 14], matricesArray[j * 16 + 15]);
139
- }
140
- boneInverses.push(mat);
141
- }
115
+ if (this._content.skins !== undefined && this._content.nodes !== undefined) {
116
+ for (let i = 0; i < this._content.nodes?.length; i++) {
117
+ if (this._content.nodes[i].skin !== undefined) {
118
+ const skinDef = this.loadSkin(this._content.nodes[i].skin!);
119
+
120
+ const skinNode = this._nodes[i];
142
121
 
143
- skinNode.skinNode = true;
144
- skinNode.bones = bones;
145
- skinNode.boneInverses = boneInverses;
122
+ const bones: ITreeNode[] = [];
123
+ const boneInverses: mat4[] = [];
146
124
 
147
- NodeTreeUtils.addBones(skinNode, skinNode);
125
+ for (let j = 0; j < skinDef.joints.length; j++) {
126
+ this._nodes[skinDef.joints[j]].data.push(new BoneData())
127
+ bones.push(this._nodes[skinDef.joints[j]]);
128
+
129
+ let mat = mat4.create();
130
+ if (skinDef.inverseBindMatrices !== undefined) {
131
+ const matricesArray = skinDef.inverseBindMatrices!.array;
132
+ mat = mat4.fromValues(matricesArray[j * 16 + 0], matricesArray[j * 16 + 1], matricesArray[j * 16 + 2], matricesArray[j * 16 + 3],
133
+ matricesArray[j * 16 + 4], matricesArray[j * 16 + 5], matricesArray[j * 16 + 6], matricesArray[j * 16 + 7],
134
+ matricesArray[j * 16 + 8], matricesArray[j * 16 + 9], matricesArray[j * 16 + 10], matricesArray[j * 16 + 11],
135
+ matricesArray[j * 16 + 12], matricesArray[j * 16 + 13], matricesArray[j * 16 + 14], matricesArray[j * 16 + 15]);
136
+ }
137
+ boneInverses.push(mat);
148
138
  }
139
+
140
+ skinNode.skinNode = true;
141
+ skinNode.bones = bones;
142
+ skinNode.boneInverses = boneInverses;
143
+
144
+ NodeTreeUtils.addBones(skinNode, skinNode);
149
145
  }
150
146
  }
151
-
152
- if (this._content.animations)
153
- for (let i = 0; i < this._content.animations?.length; i++)
154
- node.data.push(this.loadAnimation(i));
155
- return node;
156
- } catch (e) {
157
- throw this._logger.handleError(LOGGING_TOPIC.DATA_PROCESSING, `GLTFLoader.load`, e);
158
147
  }
148
+
149
+ if (this._content.animations)
150
+ for (let i = 0; i < this._content.animations?.length; i++)
151
+ node.data.push(this.loadAnimation(i));
152
+ return node;
159
153
  }
160
154
 
161
155
  public async loadWithUrl(url?: string | undefined): Promise<ITreeNode> {
162
156
  this._performanceEvaluator.startSection('gltfProcessing.' + url);
163
157
  let axiosResponse;
164
158
 
165
- try {
166
- this._performanceEvaluator.startSection('loadGltf.' + url);
167
- axiosResponse = await this._httpClient.get(url!, {
168
- responseType: 'arraybuffer'
169
- });
170
- this._performanceEvaluator.endSection('loadGltf.' + url);
171
- } catch (e) {
172
- throw this._logger.handleError(LOGGING_TOPIC.DATA_PROCESSING, `GLTFLoader.load`, e);
173
- }
159
+ this._performanceEvaluator.startSection('loadGltf.' + url);
160
+ axiosResponse = await this._httpClient.get(url!, {
161
+ responseType: 'arraybuffer'
162
+ });
163
+ this._performanceEvaluator.endSection('loadGltf.' + url);
174
164
 
175
165
  let gltfContent, gltfBinary, gltfBaseUrl, gltfHeader;
176
166
 
@@ -191,10 +181,9 @@ export class GLTFLoader {
191
181
  contentLength: headerDataView.getUint32(12, true),
192
182
  contentFormat: headerDataView.getUint32(16, true)
193
183
  }
194
- if (gltfHeader.magic != 'glTF') {
195
- const error = new ShapeDiverViewerDataProcessingError('GLTFLoader.load: Invalid data: sdgTF magic wrong.');
196
- throw this._logger.handleError(LOGGING_TOPIC.DATA_PROCESSING, `GLTFLoader.load`, error);
197
- }
184
+ if (gltfHeader.magic != 'glTF')
185
+ throw new ShapeDiverViewerDataProcessingError('GLTFLoader.load: Invalid data: sdgTF magic wrong.');
186
+
198
187
  // create content
199
188
  const contentDataView = new DataView(gltfBinary, this.BINARY_EXTENSION_HEADER_LENGTH, gltfHeader.contentLength);
200
189
  const contentDecoded = new TextDecoder().decode(contentDataView);
@@ -251,7 +240,7 @@ export class GLTFLoader {
251
240
  const output = this._accessorLoader.getAccessor(sampler.output);
252
241
  let interpolation = sampler.interpolation;
253
242
  if (interpolation === 'CUBICSPLINE') {
254
- this._logger.warn(LOGGING_TOPIC.DATA_PROCESSING, 'Animation with CUBICSPLINE interpolation is currently not supported. Assigning linear interpolation instead.')
243
+ this._logger.warn('Animation with CUBICSPLINE interpolation is currently not supported. Assigning linear interpolation instead.')
255
244
  interpolation = 'linear';
256
245
  }
257
246
 
@@ -481,7 +470,7 @@ export class GLTFLoader {
481
470
  message += '"' + element + '"' + (index === notSupported.length - 1 ? '' : index === notSupported.length - 2 ? ' and ' : ', ');
482
471
  });
483
472
  message += (notSupported.length === 1 ? ' is' : ' are') + ' not supported, but used. Loading glTF regardless.';
484
- this._logger.info(LOGGING_TOPIC.DATA_PROCESSING, 'GLTFLoader.validateVersionAndExtensions: ' + message);
473
+ this._logger.info('GLTFLoader.validateVersionAndExtensions: ' + message);
485
474
  }
486
475
  }
487
476
 
@@ -2,22 +2,16 @@ import { AttributeData } from '@shapediver/viewer.shared.types'
2
2
  import {
3
3
  ACCESSORCOMPONENTTYPE_V2 as ACCESSOR_COMPONENTTYPE,
4
4
  ACCESSORTYPE_V2 as ACCESSORTYPE,
5
- IGLTF_v2,
6
- IGLTF_v2_Material,
7
- IGLTF_v2_Material_KHR_materials_pbrSpecularGlossiness,
8
- IGLTF_v2_Primitive,
9
- ISHAPEDIVER_materials_preset,
5
+ IGLTF_v2
10
6
  } from '@shapediver/viewer.data-engine.shared-types'
11
- import { Logger, LOGGING_TOPIC } from '@shapediver/viewer.shared.services'
12
- import { container } from 'tsyringe'
7
+ import { Logger } from '@shapediver/viewer.shared.services'
13
8
 
14
- import { BufferLoader } from './BufferLoader'
15
9
  import { BufferViewLoader } from './BufferViewLoader'
16
10
 
17
11
  export class AccessorLoader {
18
12
  // #region Properties (2)
19
13
 
20
- private readonly _logger: Logger = <Logger>container.resolve(Logger);
14
+ private readonly _logger: Logger = Logger.instance;
21
15
 
22
16
  private _loaded: {
23
17
  [key: string]: AttributeData | null
@@ -58,7 +52,7 @@ export class AccessorLoader {
58
52
  const arrayBuffer = this._bufferViewLoader.getBufferView(accessor.bufferView!);
59
53
 
60
54
  const itemSize = ACCESSORTYPE[<keyof typeof ACCESSORTYPE>accessor.type];
61
- if (accessor.componentType === 5124) this._logger.warn(LOGGING_TOPIC.DATA_PROCESSING, 'GLTFLoader.loadAccessor: The componentType for this accessor is 5124, which is not allowed. Trying to load it anyway.');
55
+ if (accessor.componentType === 5124) this._logger.warn('GLTFLoader.loadAccessor: The componentType for this accessor is 5124, which is not allowed. Trying to load it anyway.');
62
56
  const ArrayType = ACCESSOR_COMPONENTTYPE[<keyof typeof ACCESSOR_COMPONENTTYPE>accessor.componentType];
63
57
 
64
58
  const elementBytes = ArrayType.BYTES_PER_ELEMENT;
@@ -1,11 +1,10 @@
1
- import { container } from 'tsyringe'
2
1
  import { IGLTF_v2 } from '@shapediver/viewer.data-engine.shared-types'
3
2
  import { HttpClient } from '@shapediver/viewer.shared.services'
4
3
 
5
4
  export class BufferLoader {
6
5
  // #region Properties (2)
7
6
 
8
- private readonly _httpClient: HttpClient = <HttpClient>container.resolve(HttpClient);
7
+ private readonly _httpClient: HttpClient = HttpClient.instance;
9
8
 
10
9
  private _loaded: {
11
10
  [key: string]: ArrayBuffer
@@ -1,5 +1,4 @@
1
1
  import { Converter, HttpClient } from '@shapediver/viewer.shared.services'
2
- import { container } from 'tsyringe'
3
2
  import {
4
3
  IGLTF_v2,
5
4
  IGLTF_v2_Material,
@@ -29,8 +28,8 @@ import { TextureLoader } from './TextureLoader'
29
28
  export class MaterialLoader {
30
29
  // #region Properties (4)
31
30
 
32
- private readonly _converter: Converter = <Converter>container.resolve(Converter);
33
- private readonly _materialEngine: MaterialEngine = <MaterialEngine>container.resolve(MaterialEngine);
31
+ private readonly _converter: Converter = Converter.instance;
32
+ private readonly _materialEngine: MaterialEngine = MaterialEngine.instance;
34
33
 
35
34
  private _loaded: { [key: string]: IMaterialAbstractData } = {};
36
35
 
@@ -1,14 +1,13 @@
1
1
  import { IGLTF_v2 } from '@shapediver/viewer.data-engine.shared-types'
2
2
  import { Converter, HttpClient, HttpResponse } from '@shapediver/viewer.shared.services'
3
- import { container } from 'tsyringe'
4
3
 
5
4
  import { BufferViewLoader } from './BufferViewLoader'
6
5
 
7
6
  export class TextureLoader {
8
7
  // #region Properties (4)
9
8
 
10
- private readonly _converter: Converter = <Converter>container.resolve(Converter);
11
- private readonly _httpClient: HttpClient = <HttpClient>container.resolve(HttpClient);
9
+ private readonly _converter: Converter = Converter.instance;
10
+ private readonly _httpClient: HttpClient = HttpClient.instance;
12
11
 
13
12
  private _loaded: {
14
13
  [key: string]: HTMLImageElement
@@ -52,7 +51,7 @@ export class TextureLoader {
52
51
  array[i] = dataView.getUint8(i);
53
52
 
54
53
  const blob = new Blob([new Uint8Array(array)], { type: image.mimeType });
55
- const dataUri = window.URL.createObjectURL(blob);
54
+ const dataUri = URL.createObjectURL(blob);
56
55
 
57
56
  promises.push(
58
57
  new Promise<void>(resolve => {
@@ -60,6 +59,7 @@ export class TextureLoader {
60
59
  .then(response => {
61
60
  this._converter.responseToImage(response).then(img => {
62
61
  this._loaded[textureId] = img;
62
+ URL.revokeObjectURL(dataUri)
63
63
  resolve()
64
64
  });
65
65
  })