@colijnit/configurator 12.0.10 → 12.0.12

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.
@@ -5,7 +5,6 @@ import { DecoNode } from '@colijnit/configuratorapi/build/model/deco-node';
5
5
  import { BusinessObjectFactory } from '@colijnit/configuratorapi/build/service/business-object-factory';
6
6
  import { Selection } from '@colijnit/configuratorapi/build/model/selection';
7
7
  import { DecoNodeType } from '@colijnit/configuratorapi/build/enum/deco-node-type.enum';
8
- import axios from 'axios';
9
8
  import { DecoNodeKind } from '@colijnit/configuratorapi/build/enum/deco-node-kind.enum';
10
9
  import { Subject, BehaviorSubject } from 'rxjs';
11
10
  import JSZip from 'jszip';
@@ -67,146 +66,6 @@ class ObjectUtils$1 {
67
66
  }
68
67
  ObjectUtils$1.materialProps = ['map', 'lightMap', 'bumpMap', 'normalMap', 'specularMap', 'envMap', 'aoMap', 'roughnessMap', 'metalnessMap'];
69
68
 
70
- // Static utility functions holder related to files.
71
- // @dynamic
72
- class FileUtils {
73
- // Returns the given dataUri string stripped of the mimetype part.
74
- static StripMimeStringFromDataUri(dataUri) {
75
- if (!dataUri) {
76
- return '';
77
- }
78
- const mimeString = this.GetMimeStringFromDataUri(dataUri);
79
- return dataUri.substr(mimeString.length + 1);
80
- }
81
- static GetMimeStringFromDataUri(dataUri) {
82
- if (!dataUri) {
83
- return '';
84
- }
85
- return dataUri.split(',')[0];
86
- }
87
- static FileExists(url, assetPath) {
88
- return __awaiter(this, void 0, void 0, function* () {
89
- if (!assetPath.endsWith('/')) {
90
- assetPath = assetPath + '/';
91
- }
92
- const result = yield axios({
93
- method: 'get',
94
- url: `${assetPath}getFiles.php?assetUrl=${url}`,
95
- responseType: "json"
96
- });
97
- return !!result.data;
98
- });
99
- }
100
- /**
101
- * There is some discrepancy regarding locations of h3d objects
102
- * Therefor we need to (temporarily?!) fix the content url
103
- * Also we need to change some additionals
104
- */
105
- static FixUrl(assetUrl) {
106
- if (!assetUrl) {
107
- return '';
108
- }
109
- let fixedUrl = assetUrl;
110
- if (!fixedUrl.endsWith('glb') && !fixedUrl.endsWith('obj') && !fixedUrl.endsWith('glb.gz') && !fixedUrl.endsWith('obj.gz')) {
111
- fixedUrl = FileUtils.FixUnityUrl(fixedUrl);
112
- }
113
- fixedUrl = fixedUrl.replace('/content/', '/content43/');
114
- return fixedUrl;
115
- }
116
- static FixGlbUrl(assetUrl) {
117
- if (!assetUrl) {
118
- return '';
119
- }
120
- let fixedUrl = assetUrl;
121
- if (assetUrl.indexOf('_webplayer') === -1) {
122
- fixedUrl = assetUrl.concat('_webplayer');
123
- }
124
- fixedUrl = fixedUrl.replace('/content/', '/content43/');
125
- if (!fixedUrl.endsWith('.glb')) {
126
- fixedUrl = fixedUrl.concat('.glb');
127
- }
128
- return fixedUrl;
129
- }
130
- // Return the mimetype of the given filename.
131
- static MimeTypeFromFilename(fileName) {
132
- const regEx = /(?:\.([^.]+))?$/; // regex to find extension
133
- const extension = regEx.exec(fileName)[1];
134
- switch (extension) {
135
- case 'jpg':
136
- case 'jpeg':
137
- return 'image/jpeg';
138
- case 'png':
139
- return 'image/png';
140
- case 'bmp':
141
- return 'image/bmp';
142
- }
143
- }
144
- /**
145
- * Downloads the given file to the users default download location.
146
- * @param fileName With or without extension
147
- * @param content File content as a string
148
- * @param [mimeType = 'text/plain']
149
- */
150
- static DownloadFile(fileName, content, mimeType = 'text/plain') {
151
- const element = document.createElement('a');
152
- element.setAttribute('href', 'data:' + mimeType + ';charset=utf-8,' + encodeURIComponent(content));
153
- element.setAttribute('download', fileName);
154
- element.style.display = 'none';
155
- document.body.appendChild(element);
156
- element.click();
157
- document.body.removeChild(element);
158
- }
159
- // Returns the contents of given file as a text string.
160
- static ReadAsText(file) {
161
- return new Promise((resolve) => {
162
- const reader = new FileReader();
163
- reader.readAsText(file);
164
- reader.onloadend = (event) => {
165
- if (event.target.readyState === 2) {
166
- resolve(event.target.result);
167
- }
168
- };
169
- });
170
- }
171
- static GetExtensionFromDataUri(dataUri) {
172
- return dataUri.replace(/(data:image\/)(.*?)(;base64.*)/gi, '$2');
173
- }
174
- static CreateDownloadFileNameFromBase64(dataUri) {
175
- const ext = this.GetExtensionFromDataUri(dataUri);
176
- return 'preview.' + ext;
177
- }
178
- static DownloadFromDataUri(dataUri, fileName) {
179
- const link = document.createElement('a');
180
- link.download = fileName;
181
- link.href = dataUri;
182
- document.body.appendChild(link);
183
- link.click();
184
- document.body.removeChild(link);
185
- }
186
- // todo remove once Connector deals with mimetypes and this method isn't used anymore
187
- static DocumentBodyToDataUri(documentBody, mimeType) {
188
- if (!!documentBody) {
189
- return 'data:' + mimeType + ';base64,' + documentBody;
190
- }
191
- else {
192
- return '';
193
- }
194
- }
195
- static FixUnityUrl(url) {
196
- if (url.indexOf('_webplayer') === -1) {
197
- url = url.concat('_webplayer.ione3d');
198
- }
199
- else {
200
- url = url.replace('_webplayer', '_webplayer.ione3d');
201
- }
202
- if (!url.endsWith('.gz')) {
203
- url = url.concat('.gz');
204
- }
205
- return url.replace('.unity3d', '');
206
- }
207
- }
208
- FileUtils._cachedTextureUploads = new Map();
209
-
210
69
  class ThreedUtils {
211
70
  constructor() {
212
71
  this._objectCache = new Map();
@@ -224,15 +83,14 @@ class ThreedUtils {
224
83
  resolve(this._objectCache.get(lookupFileName));
225
84
  return;
226
85
  }
227
- if (yield FileUtils.FileExists(lookupFileName, assetPath)) {
228
- this.loadGlbSource(lookupFileName).then((obj) => {
229
- this._objectCache.set(lookupFileName, obj);
230
- resolve(obj);
231
- });
232
- }
233
- else {
86
+ this.loadGlbSource(lookupFileName)
87
+ .then((obj) => {
88
+ this._objectCache.set(lookupFileName, obj);
89
+ resolve(obj);
90
+ })
91
+ .catch(() => {
234
92
  reject(`GLB source not found! (${lookupFileName})`);
235
- }
93
+ });
236
94
  }));
237
95
  }
238
96
  readFileAsText(file) {
@@ -2084,7 +1942,7 @@ class Builder {
2084
1942
  deco = new DecoNode();
2085
1943
  }
2086
1944
  const variation = this._getVariations().find(v => v.parentId === this._selections[i].artNodeIdDeco);
2087
- if (variation) {
1945
+ if (variation && deco.type !== DecoNodeType.Variation) {
2088
1946
  deco.variation = variation;
2089
1947
  }
2090
1948
  this._selections[i].decoNode = deco;