babylonjs-loaders 5.0.0-rc.9 → 5.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.
@@ -0,0 +1,4063 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory(require("babylonjs"));
4
+ else if(typeof define === 'function' && define.amd)
5
+ define("babylonjs-loaders", ["babylonjs"], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["babylonjs-loaders"] = factory(require("babylonjs"));
8
+ else
9
+ root["LOADERS"] = factory(root["BABYLON"]);
10
+ })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_core_Misc_observable__) {
11
+ return /******/ (() => { // webpackBootstrap
12
+ /******/ "use strict";
13
+ /******/ var __webpack_modules__ = ({
14
+
15
+ /***/ "../../../../node_modules/tslib/tslib.es6.js":
16
+ /*!***************************************************!*\
17
+ !*** ../../../../node_modules/tslib/tslib.es6.js ***!
18
+ \***************************************************/
19
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
20
+
21
+ __webpack_require__.r(__webpack_exports__);
22
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
23
+ /* harmony export */ "__assign": () => (/* binding */ __assign),
24
+ /* harmony export */ "__asyncDelegator": () => (/* binding */ __asyncDelegator),
25
+ /* harmony export */ "__asyncGenerator": () => (/* binding */ __asyncGenerator),
26
+ /* harmony export */ "__asyncValues": () => (/* binding */ __asyncValues),
27
+ /* harmony export */ "__await": () => (/* binding */ __await),
28
+ /* harmony export */ "__awaiter": () => (/* binding */ __awaiter),
29
+ /* harmony export */ "__classPrivateFieldGet": () => (/* binding */ __classPrivateFieldGet),
30
+ /* harmony export */ "__classPrivateFieldSet": () => (/* binding */ __classPrivateFieldSet),
31
+ /* harmony export */ "__createBinding": () => (/* binding */ __createBinding),
32
+ /* harmony export */ "__decorate": () => (/* binding */ __decorate),
33
+ /* harmony export */ "__exportStar": () => (/* binding */ __exportStar),
34
+ /* harmony export */ "__extends": () => (/* binding */ __extends),
35
+ /* harmony export */ "__generator": () => (/* binding */ __generator),
36
+ /* harmony export */ "__importDefault": () => (/* binding */ __importDefault),
37
+ /* harmony export */ "__importStar": () => (/* binding */ __importStar),
38
+ /* harmony export */ "__makeTemplateObject": () => (/* binding */ __makeTemplateObject),
39
+ /* harmony export */ "__metadata": () => (/* binding */ __metadata),
40
+ /* harmony export */ "__param": () => (/* binding */ __param),
41
+ /* harmony export */ "__read": () => (/* binding */ __read),
42
+ /* harmony export */ "__rest": () => (/* binding */ __rest),
43
+ /* harmony export */ "__spread": () => (/* binding */ __spread),
44
+ /* harmony export */ "__spreadArray": () => (/* binding */ __spreadArray),
45
+ /* harmony export */ "__spreadArrays": () => (/* binding */ __spreadArrays),
46
+ /* harmony export */ "__values": () => (/* binding */ __values)
47
+ /* harmony export */ });
48
+ /*! *****************************************************************************
49
+ Copyright (c) Microsoft Corporation.
50
+
51
+ Permission to use, copy, modify, and/or distribute this software for any
52
+ purpose with or without fee is hereby granted.
53
+
54
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
55
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
56
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
57
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
58
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
59
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
60
+ PERFORMANCE OF THIS SOFTWARE.
61
+ ***************************************************************************** */
62
+ /* global Reflect, Promise */
63
+
64
+ var extendStatics = function(d, b) {
65
+ extendStatics = Object.setPrototypeOf ||
66
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
67
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
68
+ return extendStatics(d, b);
69
+ };
70
+
71
+ function __extends(d, b) {
72
+ if (typeof b !== "function" && b !== null)
73
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
74
+ extendStatics(d, b);
75
+ function __() { this.constructor = d; }
76
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
77
+ }
78
+
79
+ var __assign = function() {
80
+ __assign = Object.assign || function __assign(t) {
81
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
82
+ s = arguments[i];
83
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
84
+ }
85
+ return t;
86
+ }
87
+ return __assign.apply(this, arguments);
88
+ }
89
+
90
+ function __rest(s, e) {
91
+ var t = {};
92
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
93
+ t[p] = s[p];
94
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
95
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
96
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
97
+ t[p[i]] = s[p[i]];
98
+ }
99
+ return t;
100
+ }
101
+
102
+ function __decorate(decorators, target, key, desc) {
103
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
104
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
105
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
106
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
107
+ }
108
+
109
+ function __param(paramIndex, decorator) {
110
+ return function (target, key) { decorator(target, key, paramIndex); }
111
+ }
112
+
113
+ function __metadata(metadataKey, metadataValue) {
114
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
115
+ }
116
+
117
+ function __awaiter(thisArg, _arguments, P, generator) {
118
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
119
+ return new (P || (P = Promise))(function (resolve, reject) {
120
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
121
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
122
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
123
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
124
+ });
125
+ }
126
+
127
+ function __generator(thisArg, body) {
128
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
129
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
130
+ function verb(n) { return function (v) { return step([n, v]); }; }
131
+ function step(op) {
132
+ if (f) throw new TypeError("Generator is already executing.");
133
+ while (_) try {
134
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
135
+ if (y = 0, t) op = [op[0] & 2, t.value];
136
+ switch (op[0]) {
137
+ case 0: case 1: t = op; break;
138
+ case 4: _.label++; return { value: op[1], done: false };
139
+ case 5: _.label++; y = op[1]; op = [0]; continue;
140
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
141
+ default:
142
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
143
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
144
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
145
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
146
+ if (t[2]) _.ops.pop();
147
+ _.trys.pop(); continue;
148
+ }
149
+ op = body.call(thisArg, _);
150
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
151
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
152
+ }
153
+ }
154
+
155
+ var __createBinding = Object.create ? (function(o, m, k, k2) {
156
+ if (k2 === undefined) k2 = k;
157
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
158
+ }) : (function(o, m, k, k2) {
159
+ if (k2 === undefined) k2 = k;
160
+ o[k2] = m[k];
161
+ });
162
+
163
+ function __exportStar(m, o) {
164
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
165
+ }
166
+
167
+ function __values(o) {
168
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
169
+ if (m) return m.call(o);
170
+ if (o && typeof o.length === "number") return {
171
+ next: function () {
172
+ if (o && i >= o.length) o = void 0;
173
+ return { value: o && o[i++], done: !o };
174
+ }
175
+ };
176
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
177
+ }
178
+
179
+ function __read(o, n) {
180
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
181
+ if (!m) return o;
182
+ var i = m.call(o), r, ar = [], e;
183
+ try {
184
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
185
+ }
186
+ catch (error) { e = { error: error }; }
187
+ finally {
188
+ try {
189
+ if (r && !r.done && (m = i["return"])) m.call(i);
190
+ }
191
+ finally { if (e) throw e.error; }
192
+ }
193
+ return ar;
194
+ }
195
+
196
+ /** @deprecated */
197
+ function __spread() {
198
+ for (var ar = [], i = 0; i < arguments.length; i++)
199
+ ar = ar.concat(__read(arguments[i]));
200
+ return ar;
201
+ }
202
+
203
+ /** @deprecated */
204
+ function __spreadArrays() {
205
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
206
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
207
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
208
+ r[k] = a[j];
209
+ return r;
210
+ }
211
+
212
+ function __spreadArray(to, from, pack) {
213
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
214
+ if (ar || !(i in from)) {
215
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
216
+ ar[i] = from[i];
217
+ }
218
+ }
219
+ return to.concat(ar || Array.prototype.slice.call(from));
220
+ }
221
+
222
+ function __await(v) {
223
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
224
+ }
225
+
226
+ function __asyncGenerator(thisArg, _arguments, generator) {
227
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
228
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
229
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
230
+ function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
231
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
232
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
233
+ function fulfill(value) { resume("next", value); }
234
+ function reject(value) { resume("throw", value); }
235
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
236
+ }
237
+
238
+ function __asyncDelegator(o) {
239
+ var i, p;
240
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
241
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
242
+ }
243
+
244
+ function __asyncValues(o) {
245
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
246
+ var m = o[Symbol.asyncIterator], i;
247
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
248
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
249
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
250
+ }
251
+
252
+ function __makeTemplateObject(cooked, raw) {
253
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
254
+ return cooked;
255
+ };
256
+
257
+ var __setModuleDefault = Object.create ? (function(o, v) {
258
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
259
+ }) : function(o, v) {
260
+ o["default"] = v;
261
+ };
262
+
263
+ function __importStar(mod) {
264
+ if (mod && mod.__esModule) return mod;
265
+ var result = {};
266
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
267
+ __setModuleDefault(result, mod);
268
+ return result;
269
+ }
270
+
271
+ function __importDefault(mod) {
272
+ return (mod && mod.__esModule) ? mod : { default: mod };
273
+ }
274
+
275
+ function __classPrivateFieldGet(receiver, state, kind, f) {
276
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
277
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
278
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
279
+ }
280
+
281
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
282
+ if (kind === "m") throw new TypeError("Private method is not writable");
283
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
284
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
285
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
286
+ }
287
+
288
+
289
+ /***/ }),
290
+
291
+ /***/ "../../../lts/loaders/dist/glTF/1.0/glTFBinaryExtension.js":
292
+ /*!*****************************************************************!*\
293
+ !*** ../../../lts/loaders/dist/glTF/1.0/glTFBinaryExtension.js ***!
294
+ \*****************************************************************/
295
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
296
+
297
+ __webpack_require__.r(__webpack_exports__);
298
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
299
+ /* harmony export */ "GLTFBinaryExtension": () => (/* binding */ GLTFBinaryExtension)
300
+ /* harmony export */ });
301
+ /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.js");
302
+ /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoader */ "../../../lts/loaders/dist/glTF/1.0/glTFLoader.js");
303
+ /* harmony import */ var _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderUtils */ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderUtils.js");
304
+ /* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderInterfaces.js");
305
+
306
+
307
+
308
+
309
+ var BinaryExtensionBufferName = "binary_glTF";
310
+ /** @hidden */
311
+ var GLTFBinaryExtension = /** @class */ (function (_super) {
312
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(GLTFBinaryExtension, _super);
313
+ function GLTFBinaryExtension() {
314
+ return _super.call(this, "KHR_binary_glTF") || this;
315
+ }
316
+ GLTFBinaryExtension.prototype.loadRuntimeAsync = function (scene, data, rootUrl, onSuccess) {
317
+ var extensionsUsed = data.json.extensionsUsed;
318
+ if (!extensionsUsed || extensionsUsed.indexOf(this.name) === -1 || !data.bin) {
319
+ return false;
320
+ }
321
+ this._bin = data.bin;
322
+ onSuccess(_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl));
323
+ return true;
324
+ };
325
+ GLTFBinaryExtension.prototype.loadBufferAsync = function (gltfRuntime, id, onSuccess, onError) {
326
+ if (gltfRuntime.extensionsUsed.indexOf(this.name) === -1) {
327
+ return false;
328
+ }
329
+ if (id !== BinaryExtensionBufferName) {
330
+ return false;
331
+ }
332
+ this._bin.readAsync(0, this._bin.byteLength).then(onSuccess, function (error) { return onError(error.message); });
333
+ return true;
334
+ };
335
+ GLTFBinaryExtension.prototype.loadTextureBufferAsync = function (gltfRuntime, id, onSuccess) {
336
+ var texture = gltfRuntime.textures[id];
337
+ var source = gltfRuntime.images[texture.source];
338
+ if (!source.extensions || !(this.name in source.extensions)) {
339
+ return false;
340
+ }
341
+ var sourceExt = source.extensions[this.name];
342
+ var bufferView = gltfRuntime.bufferViews[sourceExt.bufferView];
343
+ var buffer = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_3__.EComponentType.UNSIGNED_BYTE);
344
+ onSuccess(buffer);
345
+ return true;
346
+ };
347
+ GLTFBinaryExtension.prototype.loadShaderStringAsync = function (gltfRuntime, id, onSuccess) {
348
+ var shader = gltfRuntime.shaders[id];
349
+ if (!shader.extensions || !(this.name in shader.extensions)) {
350
+ return false;
351
+ }
352
+ var binaryExtensionShader = shader.extensions[this.name];
353
+ var bufferView = gltfRuntime.bufferViews[binaryExtensionShader.bufferView];
354
+ var shaderBytes = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_3__.EComponentType.UNSIGNED_BYTE);
355
+ setTimeout(function () {
356
+ var shaderString = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.DecodeBufferToText(shaderBytes);
357
+ onSuccess(shaderString);
358
+ });
359
+ return true;
360
+ };
361
+ return GLTFBinaryExtension;
362
+ }(_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderExtension));
363
+
364
+ _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(new GLTFBinaryExtension());
365
+
366
+
367
+ /***/ }),
368
+
369
+ /***/ "../../../lts/loaders/dist/glTF/1.0/glTFLoader.js":
370
+ /*!********************************************************!*\
371
+ !*** ../../../lts/loaders/dist/glTF/1.0/glTFLoader.js ***!
372
+ \********************************************************/
373
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
374
+
375
+ __webpack_require__.r(__webpack_exports__);
376
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
377
+ /* harmony export */ "GLTFLoader": () => (/* binding */ GLTFLoader),
378
+ /* harmony export */ "GLTFLoaderBase": () => (/* binding */ GLTFLoaderBase),
379
+ /* harmony export */ "GLTFLoaderExtension": () => (/* binding */ GLTFLoaderExtension)
380
+ /* harmony export */ });
381
+ /* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderInterfaces.js");
382
+ /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core/Engines/constants */ "core/Misc/observable");
383
+ /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
384
+ /* harmony import */ var _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderUtils */ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderUtils.js");
385
+ /* harmony import */ var _glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../glTFFileLoader */ "../../../lts/loaders/dist/glTF/glTFFileLoader.js");
386
+
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+
409
+
410
+
411
+
412
+
413
+
414
+ /**
415
+ * Tokenizer. Used for shaders compatibility
416
+ * Automatically map world, view, projection, worldViewProjection, attributes and so on
417
+ */
418
+ var ETokenType;
419
+ (function (ETokenType) {
420
+ ETokenType[ETokenType["IDENTIFIER"] = 1] = "IDENTIFIER";
421
+ ETokenType[ETokenType["UNKNOWN"] = 2] = "UNKNOWN";
422
+ ETokenType[ETokenType["END_OF_INPUT"] = 3] = "END_OF_INPUT";
423
+ })(ETokenType || (ETokenType = {}));
424
+ var Tokenizer = /** @class */ (function () {
425
+ function Tokenizer(toParse) {
426
+ this._pos = 0;
427
+ this.currentToken = ETokenType.UNKNOWN;
428
+ this.currentIdentifier = "";
429
+ this.currentString = "";
430
+ this.isLetterOrDigitPattern = /^[a-zA-Z0-9]+$/;
431
+ this._toParse = toParse;
432
+ this._maxPos = toParse.length;
433
+ }
434
+ Tokenizer.prototype.getNextToken = function () {
435
+ if (this.isEnd()) {
436
+ return ETokenType.END_OF_INPUT;
437
+ }
438
+ this.currentString = this.read();
439
+ this.currentToken = ETokenType.UNKNOWN;
440
+ if (this.currentString === "_" || this.isLetterOrDigitPattern.test(this.currentString)) {
441
+ this.currentToken = ETokenType.IDENTIFIER;
442
+ this.currentIdentifier = this.currentString;
443
+ while (!this.isEnd() && (this.isLetterOrDigitPattern.test((this.currentString = this.peek())) || this.currentString === "_")) {
444
+ this.currentIdentifier += this.currentString;
445
+ this.forward();
446
+ }
447
+ }
448
+ return this.currentToken;
449
+ };
450
+ Tokenizer.prototype.peek = function () {
451
+ return this._toParse[this._pos];
452
+ };
453
+ Tokenizer.prototype.read = function () {
454
+ return this._toParse[this._pos++];
455
+ };
456
+ Tokenizer.prototype.forward = function () {
457
+ this._pos++;
458
+ };
459
+ Tokenizer.prototype.isEnd = function () {
460
+ return this._pos >= this._maxPos;
461
+ };
462
+ return Tokenizer;
463
+ }());
464
+ /**
465
+ * Values
466
+ */
467
+ var glTFTransforms = ["MODEL", "VIEW", "PROJECTION", "MODELVIEW", "MODELVIEWPROJECTION", "JOINTMATRIX"];
468
+ var babylonTransforms = ["world", "view", "projection", "worldView", "worldViewProjection", "mBones"];
469
+ var glTFAnimationPaths = ["translation", "rotation", "scale"];
470
+ var babylonAnimationPaths = ["position", "rotationQuaternion", "scaling"];
471
+ /**
472
+ * Parse
473
+ * @param parsedBuffers
474
+ * @param gltfRuntime
475
+ */
476
+ var parseBuffers = function (parsedBuffers, gltfRuntime) {
477
+ for (var buf in parsedBuffers) {
478
+ var parsedBuffer = parsedBuffers[buf];
479
+ gltfRuntime.buffers[buf] = parsedBuffer;
480
+ gltfRuntime.buffersCount++;
481
+ }
482
+ };
483
+ var parseShaders = function (parsedShaders, gltfRuntime) {
484
+ for (var sha in parsedShaders) {
485
+ var parsedShader = parsedShaders[sha];
486
+ gltfRuntime.shaders[sha] = parsedShader;
487
+ gltfRuntime.shaderscount++;
488
+ }
489
+ };
490
+ var parseObject = function (parsedObjects, runtimeProperty, gltfRuntime) {
491
+ for (var object in parsedObjects) {
492
+ var parsedObject = parsedObjects[object];
493
+ gltfRuntime[runtimeProperty][object] = parsedObject;
494
+ }
495
+ };
496
+ /**
497
+ * Utils
498
+ * @param buffer
499
+ */
500
+ var normalizeUVs = function (buffer) {
501
+ if (!buffer) {
502
+ return;
503
+ }
504
+ for (var i = 0; i < buffer.length / 2; i++) {
505
+ buffer[i * 2 + 1] = 1.0 - buffer[i * 2 + 1];
506
+ }
507
+ };
508
+ var getAttribute = function (attributeParameter) {
509
+ if (attributeParameter.semantic === "NORMAL") {
510
+ return "normal";
511
+ }
512
+ else if (attributeParameter.semantic === "POSITION") {
513
+ return "position";
514
+ }
515
+ else if (attributeParameter.semantic === "JOINT") {
516
+ return "matricesIndices";
517
+ }
518
+ else if (attributeParameter.semantic === "WEIGHT") {
519
+ return "matricesWeights";
520
+ }
521
+ else if (attributeParameter.semantic === "COLOR") {
522
+ return "color";
523
+ }
524
+ else if (attributeParameter.semantic && attributeParameter.semantic.indexOf("TEXCOORD_") !== -1) {
525
+ var channel = Number(attributeParameter.semantic.split("_")[1]);
526
+ return "uv" + (channel === 0 ? "" : channel + 1);
527
+ }
528
+ return null;
529
+ };
530
+ /**
531
+ * Loads and creates animations
532
+ * @param gltfRuntime
533
+ */
534
+ var loadAnimations = function (gltfRuntime) {
535
+ for (var anim in gltfRuntime.animations) {
536
+ var animation = gltfRuntime.animations[anim];
537
+ if (!animation.channels || !animation.samplers) {
538
+ continue;
539
+ }
540
+ var lastAnimation = null;
541
+ for (var i = 0; i < animation.channels.length; i++) {
542
+ // Get parameters and load buffers
543
+ var channel = animation.channels[i];
544
+ var sampler = animation.samplers[channel.sampler];
545
+ if (!sampler) {
546
+ continue;
547
+ }
548
+ var inputData = null;
549
+ var outputData = null;
550
+ if (animation.parameters) {
551
+ inputData = animation.parameters[sampler.input];
552
+ outputData = animation.parameters[sampler.output];
553
+ }
554
+ else {
555
+ inputData = sampler.input;
556
+ outputData = sampler.output;
557
+ }
558
+ var bufferInput = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromAccessor(gltfRuntime, gltfRuntime.accessors[inputData]);
559
+ var bufferOutput = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromAccessor(gltfRuntime, gltfRuntime.accessors[outputData]);
560
+ var targetId = channel.target.id;
561
+ var targetNode = gltfRuntime.scene.getNodeById(targetId);
562
+ if (targetNode === null) {
563
+ targetNode = gltfRuntime.scene.getNodeByName(targetId);
564
+ }
565
+ if (targetNode === null) {
566
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Creating animation named " + anim + ". But cannot find node named " + targetId + " to attach to");
567
+ continue;
568
+ }
569
+ var isBone = targetNode instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Bone;
570
+ // Get target path (position, rotation or scaling)
571
+ var targetPath = channel.target.path;
572
+ var targetPathIndex = glTFAnimationPaths.indexOf(targetPath);
573
+ if (targetPathIndex !== -1) {
574
+ targetPath = babylonAnimationPaths[targetPathIndex];
575
+ }
576
+ // Determine animation type
577
+ var animationType = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_MATRIX;
578
+ if (!isBone) {
579
+ if (targetPath === "rotationQuaternion") {
580
+ animationType = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_QUATERNION;
581
+ targetNode.rotationQuaternion = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion();
582
+ }
583
+ else {
584
+ animationType = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_VECTOR3;
585
+ }
586
+ }
587
+ // Create animation and key frames
588
+ var babylonAnimation = null;
589
+ var keys = [];
590
+ var arrayOffset = 0;
591
+ var modifyKey = false;
592
+ if (isBone && lastAnimation && lastAnimation.getKeys().length === bufferInput.length) {
593
+ babylonAnimation = lastAnimation;
594
+ modifyKey = true;
595
+ }
596
+ if (!modifyKey) {
597
+ gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;
598
+ babylonAnimation = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation(anim, isBone ? "_matrix" : targetPath, 1, animationType, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONLOOPMODE_CYCLE);
599
+ gltfRuntime.scene._blockEntityCollection = false;
600
+ }
601
+ // For each frame
602
+ for (var j = 0; j < bufferInput.length; j++) {
603
+ var value = null;
604
+ if (targetPath === "rotationQuaternion") {
605
+ // VEC4
606
+ value = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2], bufferOutput[arrayOffset + 3]]);
607
+ arrayOffset += 4;
608
+ }
609
+ else {
610
+ // Position and scaling are VEC3
611
+ value = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2]]);
612
+ arrayOffset += 3;
613
+ }
614
+ if (isBone) {
615
+ var bone = targetNode;
616
+ var translation = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero();
617
+ var rotationQuaternion = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion();
618
+ var scaling = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero();
619
+ // Warning on decompose
620
+ var mat = bone.getBaseMatrix();
621
+ if (modifyKey && lastAnimation) {
622
+ mat = lastAnimation.getKeys()[j].value;
623
+ }
624
+ mat.decompose(scaling, rotationQuaternion, translation);
625
+ if (targetPath === "position") {
626
+ translation = value;
627
+ }
628
+ else if (targetPath === "rotationQuaternion") {
629
+ rotationQuaternion = value;
630
+ }
631
+ else {
632
+ scaling = value;
633
+ }
634
+ value = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Compose(scaling, rotationQuaternion, translation);
635
+ }
636
+ if (!modifyKey) {
637
+ keys.push({
638
+ frame: bufferInput[j],
639
+ value: value,
640
+ });
641
+ }
642
+ else if (lastAnimation) {
643
+ lastAnimation.getKeys()[j].value = value;
644
+ }
645
+ }
646
+ // Finish
647
+ if (!modifyKey && babylonAnimation) {
648
+ babylonAnimation.setKeys(keys);
649
+ targetNode.animations.push(babylonAnimation);
650
+ }
651
+ lastAnimation = babylonAnimation;
652
+ gltfRuntime.scene.stopAnimation(targetNode);
653
+ gltfRuntime.scene.beginAnimation(targetNode, 0, bufferInput[bufferInput.length - 1], true, 1.0);
654
+ }
655
+ }
656
+ };
657
+ /**
658
+ * Returns the bones transformation matrix
659
+ * @param node
660
+ */
661
+ var configureBoneTransformation = function (node) {
662
+ var mat = null;
663
+ if (node.translation || node.rotation || node.scale) {
664
+ var scale = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(node.scale || [1, 1, 1]);
665
+ var rotation = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray(node.rotation || [0, 0, 0, 1]);
666
+ var position = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(node.translation || [0, 0, 0]);
667
+ mat = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Compose(scale, rotation, position);
668
+ }
669
+ else {
670
+ mat = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.FromArray(node.matrix);
671
+ }
672
+ return mat;
673
+ };
674
+ /**
675
+ * Returns the parent bone
676
+ * @param gltfRuntime
677
+ * @param skins
678
+ * @param jointName
679
+ * @param newSkeleton
680
+ */
681
+ var getParentBone = function (gltfRuntime, skins, jointName, newSkeleton) {
682
+ // Try to find
683
+ for (var i = 0; i < newSkeleton.bones.length; i++) {
684
+ if (newSkeleton.bones[i].name === jointName) {
685
+ return newSkeleton.bones[i];
686
+ }
687
+ }
688
+ // Not found, search in gltf nodes
689
+ var nodes = gltfRuntime.nodes;
690
+ for (var nde in nodes) {
691
+ var node = nodes[nde];
692
+ if (!node.jointName) {
693
+ continue;
694
+ }
695
+ var children = node.children;
696
+ for (var i = 0; i < children.length; i++) {
697
+ var child = gltfRuntime.nodes[children[i]];
698
+ if (!child.jointName) {
699
+ continue;
700
+ }
701
+ if (child.jointName === jointName) {
702
+ var mat = configureBoneTransformation(node);
703
+ var bone = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Bone(node.name || "", newSkeleton, getParentBone(gltfRuntime, skins, node.jointName, newSkeleton), mat);
704
+ bone.id = nde;
705
+ return bone;
706
+ }
707
+ }
708
+ }
709
+ return null;
710
+ };
711
+ /**
712
+ * Returns the appropriate root node
713
+ * @param nodesToRoot
714
+ * @param id
715
+ */
716
+ var getNodeToRoot = function (nodesToRoot, id) {
717
+ for (var i = 0; i < nodesToRoot.length; i++) {
718
+ var nodeToRoot = nodesToRoot[i];
719
+ for (var j = 0; j < nodeToRoot.node.children.length; j++) {
720
+ var child = nodeToRoot.node.children[j];
721
+ if (child === id) {
722
+ return nodeToRoot.bone;
723
+ }
724
+ }
725
+ }
726
+ return null;
727
+ };
728
+ /**
729
+ * Returns the node with the joint name
730
+ * @param gltfRuntime
731
+ * @param jointName
732
+ */
733
+ var getJointNode = function (gltfRuntime, jointName) {
734
+ var nodes = gltfRuntime.nodes;
735
+ var node = nodes[jointName];
736
+ if (node) {
737
+ return {
738
+ node: node,
739
+ id: jointName,
740
+ };
741
+ }
742
+ for (var nde in nodes) {
743
+ node = nodes[nde];
744
+ if (node.jointName === jointName) {
745
+ return {
746
+ node: node,
747
+ id: nde,
748
+ };
749
+ }
750
+ }
751
+ return null;
752
+ };
753
+ /**
754
+ * Checks if a nodes is in joints
755
+ * @param skins
756
+ * @param id
757
+ */
758
+ var nodeIsInJoints = function (skins, id) {
759
+ for (var i = 0; i < skins.jointNames.length; i++) {
760
+ if (skins.jointNames[i] === id) {
761
+ return true;
762
+ }
763
+ }
764
+ return false;
765
+ };
766
+ /**
767
+ * Fills the nodes to root for bones and builds hierarchy
768
+ * @param gltfRuntime
769
+ * @param newSkeleton
770
+ * @param skins
771
+ * @param nodesToRoot
772
+ */
773
+ var getNodesToRoot = function (gltfRuntime, newSkeleton, skins, nodesToRoot) {
774
+ // Creates nodes for root
775
+ for (var nde in gltfRuntime.nodes) {
776
+ var node = gltfRuntime.nodes[nde];
777
+ var id = nde;
778
+ if (!node.jointName || nodeIsInJoints(skins, node.jointName)) {
779
+ continue;
780
+ }
781
+ // Create node to root bone
782
+ var mat = configureBoneTransformation(node);
783
+ var bone = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Bone(node.name || "", newSkeleton, null, mat);
784
+ bone.id = id;
785
+ nodesToRoot.push({ bone: bone, node: node, id: id });
786
+ }
787
+ // Parenting
788
+ for (var i = 0; i < nodesToRoot.length; i++) {
789
+ var nodeToRoot = nodesToRoot[i];
790
+ var children = nodeToRoot.node.children;
791
+ for (var j = 0; j < children.length; j++) {
792
+ var child = null;
793
+ for (var k = 0; k < nodesToRoot.length; k++) {
794
+ if (nodesToRoot[k].id === children[j]) {
795
+ child = nodesToRoot[k];
796
+ break;
797
+ }
798
+ }
799
+ if (child) {
800
+ child.bone._parent = nodeToRoot.bone;
801
+ nodeToRoot.bone.children.push(child.bone);
802
+ }
803
+ }
804
+ }
805
+ };
806
+ /**
807
+ * Imports a skeleton
808
+ * @param gltfRuntime
809
+ * @param skins
810
+ * @param mesh
811
+ * @param newSkeleton
812
+ */
813
+ var importSkeleton = function (gltfRuntime, skins, mesh, newSkeleton) {
814
+ if (!newSkeleton) {
815
+ newSkeleton = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Skeleton(skins.name || "", "", gltfRuntime.scene);
816
+ }
817
+ if (!skins.babylonSkeleton) {
818
+ return newSkeleton;
819
+ }
820
+ // Find the root bones
821
+ var nodesToRoot = [];
822
+ var nodesToRootToAdd = [];
823
+ getNodesToRoot(gltfRuntime, newSkeleton, skins, nodesToRoot);
824
+ newSkeleton.bones = [];
825
+ // Joints
826
+ for (var i = 0; i < skins.jointNames.length; i++) {
827
+ var jointNode = getJointNode(gltfRuntime, skins.jointNames[i]);
828
+ if (!jointNode) {
829
+ continue;
830
+ }
831
+ var node = jointNode.node;
832
+ if (!node) {
833
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Joint named " + skins.jointNames[i] + " does not exist");
834
+ continue;
835
+ }
836
+ var id = jointNode.id;
837
+ // Optimize, if the bone already exists...
838
+ var existingBone = gltfRuntime.scene.getBoneById(id);
839
+ if (existingBone) {
840
+ newSkeleton.bones.push(existingBone);
841
+ continue;
842
+ }
843
+ // Search for parent bone
844
+ var foundBone = false;
845
+ var parentBone = null;
846
+ for (var j = 0; j < i; j++) {
847
+ var jointNode_1 = getJointNode(gltfRuntime, skins.jointNames[j]);
848
+ if (!jointNode_1) {
849
+ continue;
850
+ }
851
+ var joint = jointNode_1.node;
852
+ if (!joint) {
853
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Joint named " + skins.jointNames[j] + " does not exist when looking for parent");
854
+ continue;
855
+ }
856
+ var children = joint.children;
857
+ if (!children) {
858
+ continue;
859
+ }
860
+ foundBone = false;
861
+ for (var k = 0; k < children.length; k++) {
862
+ if (children[k] === id) {
863
+ parentBone = getParentBone(gltfRuntime, skins, skins.jointNames[j], newSkeleton);
864
+ foundBone = true;
865
+ break;
866
+ }
867
+ }
868
+ if (foundBone) {
869
+ break;
870
+ }
871
+ }
872
+ // Create bone
873
+ var mat = configureBoneTransformation(node);
874
+ if (!parentBone && nodesToRoot.length > 0) {
875
+ parentBone = getNodeToRoot(nodesToRoot, id);
876
+ if (parentBone) {
877
+ if (nodesToRootToAdd.indexOf(parentBone) === -1) {
878
+ nodesToRootToAdd.push(parentBone);
879
+ }
880
+ }
881
+ }
882
+ var bone = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Bone(node.jointName || "", newSkeleton, parentBone, mat);
883
+ bone.id = id;
884
+ }
885
+ // Polish
886
+ var bones = newSkeleton.bones;
887
+ newSkeleton.bones = [];
888
+ for (var i = 0; i < skins.jointNames.length; i++) {
889
+ var jointNode = getJointNode(gltfRuntime, skins.jointNames[i]);
890
+ if (!jointNode) {
891
+ continue;
892
+ }
893
+ for (var j = 0; j < bones.length; j++) {
894
+ if (bones[j].id === jointNode.id) {
895
+ newSkeleton.bones.push(bones[j]);
896
+ break;
897
+ }
898
+ }
899
+ }
900
+ newSkeleton.prepare();
901
+ // Finish
902
+ for (var i = 0; i < nodesToRootToAdd.length; i++) {
903
+ newSkeleton.bones.push(nodesToRootToAdd[i]);
904
+ }
905
+ return newSkeleton;
906
+ };
907
+ /**
908
+ * Imports a mesh and its geometries
909
+ * @param gltfRuntime
910
+ * @param node
911
+ * @param meshes
912
+ * @param id
913
+ * @param newMesh
914
+ */
915
+ var importMesh = function (gltfRuntime, node, meshes, id, newMesh) {
916
+ if (!newMesh) {
917
+ gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;
918
+ newMesh = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Mesh(node.name || "", gltfRuntime.scene);
919
+ newMesh._parentContainer = gltfRuntime.assetContainer;
920
+ gltfRuntime.scene._blockEntityCollection = false;
921
+ newMesh.id = id;
922
+ }
923
+ if (!node.babylonNode) {
924
+ return newMesh;
925
+ }
926
+ var subMaterials = [];
927
+ var vertexData = null;
928
+ var verticesStarts = new Array();
929
+ var verticesCounts = new Array();
930
+ var indexStarts = new Array();
931
+ var indexCounts = new Array();
932
+ for (var meshIndex = 0; meshIndex < meshes.length; meshIndex++) {
933
+ var meshId = meshes[meshIndex];
934
+ var mesh = gltfRuntime.meshes[meshId];
935
+ if (!mesh) {
936
+ continue;
937
+ }
938
+ // Positions, normals and UVs
939
+ for (var i = 0; i < mesh.primitives.length; i++) {
940
+ // Temporary vertex data
941
+ var tempVertexData = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexData();
942
+ var primitive = mesh.primitives[i];
943
+ if (primitive.mode !== 4) {
944
+ // continue;
945
+ }
946
+ var attributes = primitive.attributes;
947
+ var accessor = null;
948
+ var buffer = null;
949
+ // Set positions, normal and uvs
950
+ for (var semantic in attributes) {
951
+ // Link accessor and buffer view
952
+ accessor = gltfRuntime.accessors[attributes[semantic]];
953
+ buffer = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromAccessor(gltfRuntime, accessor);
954
+ if (semantic === "NORMAL") {
955
+ tempVertexData.normals = new Float32Array(buffer.length);
956
+ tempVertexData.normals.set(buffer);
957
+ }
958
+ else if (semantic === "POSITION") {
959
+ if (_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.HomogeneousCoordinates) {
960
+ tempVertexData.positions = new Float32Array(buffer.length - buffer.length / 4);
961
+ for (var j = 0; j < buffer.length; j += 4) {
962
+ tempVertexData.positions[j] = buffer[j];
963
+ tempVertexData.positions[j + 1] = buffer[j + 1];
964
+ tempVertexData.positions[j + 2] = buffer[j + 2];
965
+ }
966
+ }
967
+ else {
968
+ tempVertexData.positions = new Float32Array(buffer.length);
969
+ tempVertexData.positions.set(buffer);
970
+ }
971
+ verticesCounts.push(tempVertexData.positions.length);
972
+ }
973
+ else if (semantic.indexOf("TEXCOORD_") !== -1) {
974
+ var channel = Number(semantic.split("_")[1]);
975
+ var uvKind = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexBuffer.UVKind + (channel === 0 ? "" : channel + 1);
976
+ var uvs = new Float32Array(buffer.length);
977
+ uvs.set(buffer);
978
+ normalizeUVs(uvs);
979
+ tempVertexData.set(uvs, uvKind);
980
+ }
981
+ else if (semantic === "JOINT") {
982
+ tempVertexData.matricesIndices = new Float32Array(buffer.length);
983
+ tempVertexData.matricesIndices.set(buffer);
984
+ }
985
+ else if (semantic === "WEIGHT") {
986
+ tempVertexData.matricesWeights = new Float32Array(buffer.length);
987
+ tempVertexData.matricesWeights.set(buffer);
988
+ }
989
+ else if (semantic === "COLOR") {
990
+ tempVertexData.colors = new Float32Array(buffer.length);
991
+ tempVertexData.colors.set(buffer);
992
+ }
993
+ }
994
+ // Indices
995
+ accessor = gltfRuntime.accessors[primitive.indices];
996
+ if (accessor) {
997
+ buffer = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromAccessor(gltfRuntime, accessor);
998
+ tempVertexData.indices = new Int32Array(buffer.length);
999
+ tempVertexData.indices.set(buffer);
1000
+ indexCounts.push(tempVertexData.indices.length);
1001
+ }
1002
+ else {
1003
+ // Set indices on the fly
1004
+ var indices = [];
1005
+ for (var j = 0; j < tempVertexData.positions.length / 3; j++) {
1006
+ indices.push(j);
1007
+ }
1008
+ tempVertexData.indices = new Int32Array(indices);
1009
+ indexCounts.push(tempVertexData.indices.length);
1010
+ }
1011
+ if (!vertexData) {
1012
+ vertexData = tempVertexData;
1013
+ }
1014
+ else {
1015
+ vertexData.merge(tempVertexData);
1016
+ }
1017
+ // Sub material
1018
+ var material_1 = gltfRuntime.scene.getMaterialById(primitive.material);
1019
+ subMaterials.push(material_1 === null ? _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetDefaultMaterial(gltfRuntime.scene) : material_1);
1020
+ // Update vertices start and index start
1021
+ verticesStarts.push(verticesStarts.length === 0 ? 0 : verticesStarts[verticesStarts.length - 1] + verticesCounts[verticesCounts.length - 2]);
1022
+ indexStarts.push(indexStarts.length === 0 ? 0 : indexStarts[indexStarts.length - 1] + indexCounts[indexCounts.length - 2]);
1023
+ }
1024
+ }
1025
+ var material;
1026
+ gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;
1027
+ if (subMaterials.length > 1) {
1028
+ material = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.MultiMaterial("multimat" + id, gltfRuntime.scene);
1029
+ material.subMaterials = subMaterials;
1030
+ }
1031
+ else {
1032
+ material = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.StandardMaterial("multimat" + id, gltfRuntime.scene);
1033
+ }
1034
+ if (subMaterials.length === 1) {
1035
+ material = subMaterials[0];
1036
+ }
1037
+ material._parentContainer = gltfRuntime.assetContainer;
1038
+ if (!newMesh.material) {
1039
+ newMesh.material = material;
1040
+ }
1041
+ // Apply geometry
1042
+ new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Geometry(id, gltfRuntime.scene, vertexData, false, newMesh);
1043
+ newMesh.computeWorldMatrix(true);
1044
+ gltfRuntime.scene._blockEntityCollection = false;
1045
+ // Apply submeshes
1046
+ newMesh.subMeshes = [];
1047
+ var index = 0;
1048
+ for (var meshIndex = 0; meshIndex < meshes.length; meshIndex++) {
1049
+ var meshId = meshes[meshIndex];
1050
+ var mesh = gltfRuntime.meshes[meshId];
1051
+ if (!mesh) {
1052
+ continue;
1053
+ }
1054
+ for (var i = 0; i < mesh.primitives.length; i++) {
1055
+ if (mesh.primitives[i].mode !== 4) {
1056
+ //continue;
1057
+ }
1058
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.SubMesh.AddToMesh(index, verticesStarts[index], verticesCounts[index], indexStarts[index], indexCounts[index], newMesh, newMesh, true);
1059
+ index++;
1060
+ }
1061
+ }
1062
+ // Finish
1063
+ return newMesh;
1064
+ };
1065
+ /**
1066
+ * Configure node transformation from position, rotation and scaling
1067
+ * @param newNode
1068
+ * @param position
1069
+ * @param rotation
1070
+ * @param scaling
1071
+ */
1072
+ var configureNode = function (newNode, position, rotation, scaling) {
1073
+ if (newNode.position) {
1074
+ newNode.position = position;
1075
+ }
1076
+ if (newNode.rotationQuaternion || newNode.rotation) {
1077
+ newNode.rotationQuaternion = rotation;
1078
+ }
1079
+ if (newNode.scaling) {
1080
+ newNode.scaling = scaling;
1081
+ }
1082
+ };
1083
+ /**
1084
+ * Configures node from transformation matrix
1085
+ * @param newNode
1086
+ * @param node
1087
+ */
1088
+ var configureNodeFromMatrix = function (newNode, node) {
1089
+ if (node.matrix) {
1090
+ var position = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0);
1091
+ var rotation = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion();
1092
+ var scaling = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0);
1093
+ var mat = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.FromArray(node.matrix);
1094
+ mat.decompose(scaling, rotation, position);
1095
+ configureNode(newNode, position, rotation, scaling);
1096
+ }
1097
+ else if (node.translation && node.rotation && node.scale) {
1098
+ configureNode(newNode, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(node.translation), core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray(node.rotation), core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(node.scale));
1099
+ }
1100
+ newNode.computeWorldMatrix(true);
1101
+ };
1102
+ /**
1103
+ * Imports a node
1104
+ * @param gltfRuntime
1105
+ * @param node
1106
+ * @param id
1107
+ */
1108
+ var importNode = function (gltfRuntime, node, id) {
1109
+ var lastNode = null;
1110
+ if (gltfRuntime.importOnlyMeshes && (node.skin || node.meshes)) {
1111
+ if (gltfRuntime.importMeshesNames && gltfRuntime.importMeshesNames.length > 0 && gltfRuntime.importMeshesNames.indexOf(node.name || "") === -1) {
1112
+ return null;
1113
+ }
1114
+ }
1115
+ // Meshes
1116
+ if (node.skin) {
1117
+ if (node.meshes) {
1118
+ var skin = gltfRuntime.skins[node.skin];
1119
+ var newMesh = importMesh(gltfRuntime, node, node.meshes, id, node.babylonNode);
1120
+ newMesh.skeleton = gltfRuntime.scene.getLastSkeletonById(node.skin);
1121
+ if (newMesh.skeleton === null) {
1122
+ newMesh.skeleton = importSkeleton(gltfRuntime, skin, newMesh, skin.babylonSkeleton);
1123
+ if (!skin.babylonSkeleton) {
1124
+ skin.babylonSkeleton = newMesh.skeleton;
1125
+ }
1126
+ }
1127
+ lastNode = newMesh;
1128
+ }
1129
+ }
1130
+ else if (node.meshes) {
1131
+ /**
1132
+ * Improve meshes property
1133
+ */
1134
+ var newMesh = importMesh(gltfRuntime, node, node.mesh ? [node.mesh] : node.meshes, id, node.babylonNode);
1135
+ lastNode = newMesh;
1136
+ }
1137
+ // Lights
1138
+ else if (node.light && !node.babylonNode && !gltfRuntime.importOnlyMeshes) {
1139
+ var light = gltfRuntime.lights[node.light];
1140
+ if (light) {
1141
+ if (light.type === "ambient") {
1142
+ var ambienLight = light[light.type];
1143
+ var hemiLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.HemisphericLight(node.light, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene);
1144
+ hemiLight.name = node.name || "";
1145
+ if (ambienLight.color) {
1146
+ hemiLight.diffuse = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(ambienLight.color);
1147
+ }
1148
+ lastNode = hemiLight;
1149
+ }
1150
+ else if (light.type === "directional") {
1151
+ var directionalLight = light[light.type];
1152
+ var dirLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.DirectionalLight(node.light, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene);
1153
+ dirLight.name = node.name || "";
1154
+ if (directionalLight.color) {
1155
+ dirLight.diffuse = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(directionalLight.color);
1156
+ }
1157
+ lastNode = dirLight;
1158
+ }
1159
+ else if (light.type === "point") {
1160
+ var pointLight = light[light.type];
1161
+ var ptLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.PointLight(node.light, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene);
1162
+ ptLight.name = node.name || "";
1163
+ if (pointLight.color) {
1164
+ ptLight.diffuse = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(pointLight.color);
1165
+ }
1166
+ lastNode = ptLight;
1167
+ }
1168
+ else if (light.type === "spot") {
1169
+ var spotLight = light[light.type];
1170
+ var spLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.SpotLight(node.light, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), 0, 0, gltfRuntime.scene);
1171
+ spLight.name = node.name || "";
1172
+ if (spotLight.color) {
1173
+ spLight.diffuse = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(spotLight.color);
1174
+ }
1175
+ if (spotLight.fallOfAngle) {
1176
+ spLight.angle = spotLight.fallOfAngle;
1177
+ }
1178
+ if (spotLight.fallOffExponent) {
1179
+ spLight.exponent = spotLight.fallOffExponent;
1180
+ }
1181
+ lastNode = spLight;
1182
+ }
1183
+ }
1184
+ }
1185
+ // Cameras
1186
+ else if (node.camera && !node.babylonNode && !gltfRuntime.importOnlyMeshes) {
1187
+ var camera = gltfRuntime.cameras[node.camera];
1188
+ if (camera) {
1189
+ gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;
1190
+ if (camera.type === "orthographic") {
1191
+ var orthoCamera = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.FreeCamera(node.camera, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene, false);
1192
+ orthoCamera.name = node.name || "";
1193
+ orthoCamera.mode = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Camera.ORTHOGRAPHIC_CAMERA;
1194
+ orthoCamera.attachControl();
1195
+ lastNode = orthoCamera;
1196
+ orthoCamera._parentContainer = gltfRuntime.assetContainer;
1197
+ }
1198
+ else if (camera.type === "perspective") {
1199
+ var perspectiveCamera = camera[camera.type];
1200
+ var persCamera = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.FreeCamera(node.camera, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene, false);
1201
+ persCamera.name = node.name || "";
1202
+ persCamera.attachControl();
1203
+ if (!perspectiveCamera.aspectRatio) {
1204
+ perspectiveCamera.aspectRatio = gltfRuntime.scene.getEngine().getRenderWidth() / gltfRuntime.scene.getEngine().getRenderHeight();
1205
+ }
1206
+ if (perspectiveCamera.znear && perspectiveCamera.zfar) {
1207
+ persCamera.maxZ = perspectiveCamera.zfar;
1208
+ persCamera.minZ = perspectiveCamera.znear;
1209
+ }
1210
+ lastNode = persCamera;
1211
+ persCamera._parentContainer = gltfRuntime.assetContainer;
1212
+ }
1213
+ gltfRuntime.scene._blockEntityCollection = false;
1214
+ }
1215
+ }
1216
+ // Empty node
1217
+ if (!node.jointName) {
1218
+ if (node.babylonNode) {
1219
+ return node.babylonNode;
1220
+ }
1221
+ else if (lastNode === null) {
1222
+ gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;
1223
+ var dummy = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Mesh(node.name || "", gltfRuntime.scene);
1224
+ dummy._parentContainer = gltfRuntime.assetContainer;
1225
+ gltfRuntime.scene._blockEntityCollection = false;
1226
+ node.babylonNode = dummy;
1227
+ lastNode = dummy;
1228
+ }
1229
+ }
1230
+ if (lastNode !== null) {
1231
+ if (node.matrix && lastNode instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Mesh) {
1232
+ configureNodeFromMatrix(lastNode, node);
1233
+ }
1234
+ else {
1235
+ var translation = node.translation || [0, 0, 0];
1236
+ var rotation = node.rotation || [0, 0, 0, 1];
1237
+ var scale = node.scale || [1, 1, 1];
1238
+ configureNode(lastNode, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(translation), core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray(rotation), core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(scale));
1239
+ }
1240
+ lastNode.updateCache(true);
1241
+ node.babylonNode = lastNode;
1242
+ }
1243
+ return lastNode;
1244
+ };
1245
+ /**
1246
+ * Traverses nodes and creates them
1247
+ * @param gltfRuntime
1248
+ * @param id
1249
+ * @param parent
1250
+ * @param meshIncluded
1251
+ */
1252
+ var traverseNodes = function (gltfRuntime, id, parent, meshIncluded) {
1253
+ if (meshIncluded === void 0) { meshIncluded = false; }
1254
+ var node = gltfRuntime.nodes[id];
1255
+ var newNode = null;
1256
+ if (gltfRuntime.importOnlyMeshes && !meshIncluded && gltfRuntime.importMeshesNames) {
1257
+ if (gltfRuntime.importMeshesNames.indexOf(node.name || "") !== -1 || gltfRuntime.importMeshesNames.length === 0) {
1258
+ meshIncluded = true;
1259
+ }
1260
+ else {
1261
+ meshIncluded = false;
1262
+ }
1263
+ }
1264
+ else {
1265
+ meshIncluded = true;
1266
+ }
1267
+ if (!node.jointName && meshIncluded) {
1268
+ newNode = importNode(gltfRuntime, node, id);
1269
+ if (newNode !== null) {
1270
+ newNode.id = id;
1271
+ newNode.parent = parent;
1272
+ }
1273
+ }
1274
+ if (node.children) {
1275
+ for (var i = 0; i < node.children.length; i++) {
1276
+ traverseNodes(gltfRuntime, node.children[i], newNode, meshIncluded);
1277
+ }
1278
+ }
1279
+ };
1280
+ /**
1281
+ * do stuff after buffers, shaders are loaded (e.g. hook up materials, load animations, etc.)
1282
+ * @param gltfRuntime
1283
+ */
1284
+ var postLoad = function (gltfRuntime) {
1285
+ // Nodes
1286
+ var currentScene = gltfRuntime.currentScene;
1287
+ if (currentScene) {
1288
+ for (var i = 0; i < currentScene.nodes.length; i++) {
1289
+ traverseNodes(gltfRuntime, currentScene.nodes[i], null);
1290
+ }
1291
+ }
1292
+ else {
1293
+ for (var thing in gltfRuntime.scenes) {
1294
+ currentScene = gltfRuntime.scenes[thing];
1295
+ for (var i = 0; i < currentScene.nodes.length; i++) {
1296
+ traverseNodes(gltfRuntime, currentScene.nodes[i], null);
1297
+ }
1298
+ }
1299
+ }
1300
+ // Set animations
1301
+ loadAnimations(gltfRuntime);
1302
+ for (var i = 0; i < gltfRuntime.scene.skeletons.length; i++) {
1303
+ var skeleton = gltfRuntime.scene.skeletons[i];
1304
+ gltfRuntime.scene.beginAnimation(skeleton, 0, Number.MAX_VALUE, true, 1.0);
1305
+ }
1306
+ };
1307
+ /**
1308
+ * onBind shaderrs callback to set uniforms and matrices
1309
+ * @param mesh
1310
+ * @param gltfRuntime
1311
+ * @param unTreatedUniforms
1312
+ * @param shaderMaterial
1313
+ * @param technique
1314
+ * @param material
1315
+ * @param onSuccess
1316
+ */
1317
+ var onBindShaderMaterial = function (mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess) {
1318
+ var materialValues = material.values || technique.parameters;
1319
+ for (var unif in unTreatedUniforms) {
1320
+ var uniform = unTreatedUniforms[unif];
1321
+ var type = uniform.type;
1322
+ if (type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT2 || type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT3 || type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT4) {
1323
+ if (uniform.semantic && !uniform.source && !uniform.node) {
1324
+ _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.SetMatrix(gltfRuntime.scene, mesh, uniform, unif, shaderMaterial.getEffect());
1325
+ }
1326
+ else if (uniform.semantic && (uniform.source || uniform.node)) {
1327
+ var source = gltfRuntime.scene.getNodeByName(uniform.source || uniform.node || "");
1328
+ if (source === null) {
1329
+ source = gltfRuntime.scene.getNodeById(uniform.source || uniform.node || "");
1330
+ }
1331
+ if (source === null) {
1332
+ continue;
1333
+ }
1334
+ _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.SetMatrix(gltfRuntime.scene, source, uniform, unif, shaderMaterial.getEffect());
1335
+ }
1336
+ }
1337
+ else {
1338
+ var value = materialValues[technique.uniforms[unif]];
1339
+ if (!value) {
1340
+ continue;
1341
+ }
1342
+ if (type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.SAMPLER_2D) {
1343
+ var texture = gltfRuntime.textures[material.values ? value : uniform.value].babylonTexture;
1344
+ if (texture === null || texture === undefined) {
1345
+ continue;
1346
+ }
1347
+ shaderMaterial.getEffect().setTexture(unif, texture);
1348
+ }
1349
+ else {
1350
+ _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.SetUniform(shaderMaterial.getEffect(), unif, value, type);
1351
+ }
1352
+ }
1353
+ }
1354
+ onSuccess(shaderMaterial);
1355
+ };
1356
+ /**
1357
+ * Prepare uniforms to send the only one time
1358
+ * Loads the appropriate textures
1359
+ * @param gltfRuntime
1360
+ * @param shaderMaterial
1361
+ * @param technique
1362
+ * @param material
1363
+ */
1364
+ var prepareShaderMaterialUniforms = function (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms) {
1365
+ var materialValues = material.values || technique.parameters;
1366
+ var techniqueUniforms = technique.uniforms;
1367
+ var _loop_1 = function (unif) {
1368
+ var uniform = unTreatedUniforms[unif];
1369
+ var type = uniform.type;
1370
+ var value = materialValues[techniqueUniforms[unif]];
1371
+ if (value === undefined) {
1372
+ // In case the value is the same for all materials
1373
+ value = uniform.value;
1374
+ }
1375
+ if (!value) {
1376
+ return "continue";
1377
+ }
1378
+ var onLoadTexture = function (uniformName) {
1379
+ return function (texture) {
1380
+ if (uniform.value && uniformName) {
1381
+ // Static uniform
1382
+ shaderMaterial.setTexture(uniformName, texture);
1383
+ delete unTreatedUniforms[uniformName];
1384
+ }
1385
+ };
1386
+ };
1387
+ // Texture (sampler2D)
1388
+ if (type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.SAMPLER_2D) {
1389
+ GLTFLoaderExtension.LoadTextureAsync(gltfRuntime, material.values ? value : uniform.value, onLoadTexture(unif), function () { return onLoadTexture(null); });
1390
+ }
1391
+ // Others
1392
+ else {
1393
+ if (uniform.value && _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.SetUniform(shaderMaterial, unif, material.values ? value : uniform.value, type)) {
1394
+ // Static uniform
1395
+ delete unTreatedUniforms[unif];
1396
+ }
1397
+ }
1398
+ };
1399
+ /**
1400
+ * Prepare values here (not matrices)
1401
+ */
1402
+ for (var unif in unTreatedUniforms) {
1403
+ _loop_1(unif);
1404
+ }
1405
+ };
1406
+ /**
1407
+ * Shader compilation failed
1408
+ * @param program
1409
+ * @param shaderMaterial
1410
+ * @param onError
1411
+ */
1412
+ var onShaderCompileError = function (program, shaderMaterial, onError) {
1413
+ return function (effect, error) {
1414
+ shaderMaterial.dispose(true);
1415
+ onError("Cannot compile program named " + program.name + ". Error: " + error + ". Default material will be applied");
1416
+ };
1417
+ };
1418
+ /**
1419
+ * Shader compilation success
1420
+ * @param gltfRuntime
1421
+ * @param shaderMaterial
1422
+ * @param technique
1423
+ * @param material
1424
+ * @param unTreatedUniforms
1425
+ * @param onSuccess
1426
+ */
1427
+ var onShaderCompileSuccess = function (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess) {
1428
+ return function (_) {
1429
+ prepareShaderMaterialUniforms(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms);
1430
+ shaderMaterial.onBind = function (mesh) {
1431
+ onBindShaderMaterial(mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess);
1432
+ };
1433
+ };
1434
+ };
1435
+ /**
1436
+ * Returns the appropriate uniform if already handled by babylon
1437
+ * @param tokenizer
1438
+ * @param technique
1439
+ */
1440
+ var parseShaderUniforms = function (tokenizer, technique, unTreatedUniforms) {
1441
+ for (var unif in technique.uniforms) {
1442
+ var uniform = technique.uniforms[unif];
1443
+ var uniformParameter = technique.parameters[uniform];
1444
+ if (tokenizer.currentIdentifier === unif) {
1445
+ if (uniformParameter.semantic && !uniformParameter.source && !uniformParameter.node) {
1446
+ var transformIndex = glTFTransforms.indexOf(uniformParameter.semantic);
1447
+ if (transformIndex !== -1) {
1448
+ delete unTreatedUniforms[unif];
1449
+ return babylonTransforms[transformIndex];
1450
+ }
1451
+ }
1452
+ }
1453
+ }
1454
+ return tokenizer.currentIdentifier;
1455
+ };
1456
+ /**
1457
+ * All shaders loaded. Create materials one by one
1458
+ * @param gltfRuntime
1459
+ */
1460
+ var importMaterials = function (gltfRuntime) {
1461
+ // Create materials
1462
+ for (var mat in gltfRuntime.materials) {
1463
+ GLTFLoaderExtension.LoadMaterialAsync(gltfRuntime, mat, function () { }, function () { });
1464
+ }
1465
+ };
1466
+ /**
1467
+ * Implementation of the base glTF spec
1468
+ * @hidden
1469
+ */
1470
+ var GLTFLoaderBase = /** @class */ (function () {
1471
+ function GLTFLoaderBase() {
1472
+ }
1473
+ GLTFLoaderBase.CreateRuntime = function (parsedData, scene, rootUrl) {
1474
+ var gltfRuntime = {
1475
+ extensions: {},
1476
+ accessors: {},
1477
+ buffers: {},
1478
+ bufferViews: {},
1479
+ meshes: {},
1480
+ lights: {},
1481
+ cameras: {},
1482
+ nodes: {},
1483
+ images: {},
1484
+ textures: {},
1485
+ shaders: {},
1486
+ programs: {},
1487
+ samplers: {},
1488
+ techniques: {},
1489
+ materials: {},
1490
+ animations: {},
1491
+ skins: {},
1492
+ extensionsUsed: [],
1493
+ scenes: {},
1494
+ buffersCount: 0,
1495
+ shaderscount: 0,
1496
+ scene: scene,
1497
+ rootUrl: rootUrl,
1498
+ loadedBufferCount: 0,
1499
+ loadedBufferViews: {},
1500
+ loadedShaderCount: 0,
1501
+ importOnlyMeshes: false,
1502
+ dummyNodes: [],
1503
+ assetContainer: null,
1504
+ };
1505
+ // Parse
1506
+ if (parsedData.extensions) {
1507
+ parseObject(parsedData.extensions, "extensions", gltfRuntime);
1508
+ }
1509
+ if (parsedData.extensionsUsed) {
1510
+ parseObject(parsedData.extensionsUsed, "extensionsUsed", gltfRuntime);
1511
+ }
1512
+ if (parsedData.buffers) {
1513
+ parseBuffers(parsedData.buffers, gltfRuntime);
1514
+ }
1515
+ if (parsedData.bufferViews) {
1516
+ parseObject(parsedData.bufferViews, "bufferViews", gltfRuntime);
1517
+ }
1518
+ if (parsedData.accessors) {
1519
+ parseObject(parsedData.accessors, "accessors", gltfRuntime);
1520
+ }
1521
+ if (parsedData.meshes) {
1522
+ parseObject(parsedData.meshes, "meshes", gltfRuntime);
1523
+ }
1524
+ if (parsedData.lights) {
1525
+ parseObject(parsedData.lights, "lights", gltfRuntime);
1526
+ }
1527
+ if (parsedData.cameras) {
1528
+ parseObject(parsedData.cameras, "cameras", gltfRuntime);
1529
+ }
1530
+ if (parsedData.nodes) {
1531
+ parseObject(parsedData.nodes, "nodes", gltfRuntime);
1532
+ }
1533
+ if (parsedData.images) {
1534
+ parseObject(parsedData.images, "images", gltfRuntime);
1535
+ }
1536
+ if (parsedData.textures) {
1537
+ parseObject(parsedData.textures, "textures", gltfRuntime);
1538
+ }
1539
+ if (parsedData.shaders) {
1540
+ parseShaders(parsedData.shaders, gltfRuntime);
1541
+ }
1542
+ if (parsedData.programs) {
1543
+ parseObject(parsedData.programs, "programs", gltfRuntime);
1544
+ }
1545
+ if (parsedData.samplers) {
1546
+ parseObject(parsedData.samplers, "samplers", gltfRuntime);
1547
+ }
1548
+ if (parsedData.techniques) {
1549
+ parseObject(parsedData.techniques, "techniques", gltfRuntime);
1550
+ }
1551
+ if (parsedData.materials) {
1552
+ parseObject(parsedData.materials, "materials", gltfRuntime);
1553
+ }
1554
+ if (parsedData.animations) {
1555
+ parseObject(parsedData.animations, "animations", gltfRuntime);
1556
+ }
1557
+ if (parsedData.skins) {
1558
+ parseObject(parsedData.skins, "skins", gltfRuntime);
1559
+ }
1560
+ if (parsedData.scenes) {
1561
+ gltfRuntime.scenes = parsedData.scenes;
1562
+ }
1563
+ if (parsedData.scene && parsedData.scenes) {
1564
+ gltfRuntime.currentScene = parsedData.scenes[parsedData.scene];
1565
+ }
1566
+ return gltfRuntime;
1567
+ };
1568
+ GLTFLoaderBase.LoadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) {
1569
+ var buffer = gltfRuntime.buffers[id];
1570
+ if (core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.IsBase64(buffer.uri)) {
1571
+ setTimeout(function () { return onSuccess(new Uint8Array(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.DecodeBase64(buffer.uri))); });
1572
+ }
1573
+ else {
1574
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.LoadFile(gltfRuntime.rootUrl + buffer.uri, function (data) { return onSuccess(new Uint8Array(data)); }, onProgress, undefined, true, function (request) {
1575
+ if (request) {
1576
+ onError(request.status + " " + request.statusText);
1577
+ }
1578
+ });
1579
+ }
1580
+ };
1581
+ GLTFLoaderBase.LoadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) {
1582
+ var texture = gltfRuntime.textures[id];
1583
+ if (!texture || !texture.source) {
1584
+ onError("");
1585
+ return;
1586
+ }
1587
+ if (texture.babylonTexture) {
1588
+ onSuccess(null);
1589
+ return;
1590
+ }
1591
+ var source = gltfRuntime.images[texture.source];
1592
+ if (core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.IsBase64(source.uri)) {
1593
+ setTimeout(function () { return onSuccess(new Uint8Array(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.DecodeBase64(source.uri))); });
1594
+ }
1595
+ else {
1596
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.LoadFile(gltfRuntime.rootUrl + source.uri, function (data) { return onSuccess(new Uint8Array(data)); }, undefined, undefined, true, function (request) {
1597
+ if (request) {
1598
+ onError(request.status + " " + request.statusText);
1599
+ }
1600
+ });
1601
+ }
1602
+ };
1603
+ GLTFLoaderBase.CreateTextureAsync = function (gltfRuntime, id, buffer, onSuccess) {
1604
+ var texture = gltfRuntime.textures[id];
1605
+ if (texture.babylonTexture) {
1606
+ onSuccess(texture.babylonTexture);
1607
+ return;
1608
+ }
1609
+ var sampler = gltfRuntime.samplers[texture.sampler];
1610
+ var createMipMaps = sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.NEAREST_MIPMAP_NEAREST ||
1611
+ sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.NEAREST_MIPMAP_LINEAR ||
1612
+ sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR_MIPMAP_NEAREST ||
1613
+ sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR_MIPMAP_LINEAR;
1614
+ var samplingMode = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.BILINEAR_SAMPLINGMODE;
1615
+ var blob = buffer == null ? new Blob() : new Blob([buffer]);
1616
+ var blobURL = URL.createObjectURL(blob);
1617
+ var revokeBlobURL = function () { return URL.revokeObjectURL(blobURL); };
1618
+ var newTexture = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture(blobURL, gltfRuntime.scene, !createMipMaps, true, samplingMode, revokeBlobURL, revokeBlobURL);
1619
+ if (sampler.wrapS !== undefined) {
1620
+ newTexture.wrapU = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetWrapMode(sampler.wrapS);
1621
+ }
1622
+ if (sampler.wrapT !== undefined) {
1623
+ newTexture.wrapV = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetWrapMode(sampler.wrapT);
1624
+ }
1625
+ newTexture.name = id;
1626
+ texture.babylonTexture = newTexture;
1627
+ onSuccess(newTexture);
1628
+ };
1629
+ GLTFLoaderBase.LoadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) {
1630
+ var shader = gltfRuntime.shaders[id];
1631
+ if (core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.IsBase64(shader.uri)) {
1632
+ var shaderString = atob(shader.uri.split(",")[1]);
1633
+ if (onSuccess) {
1634
+ onSuccess(shaderString);
1635
+ }
1636
+ }
1637
+ else {
1638
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.LoadFile(gltfRuntime.rootUrl + shader.uri, onSuccess, undefined, undefined, false, function (request) {
1639
+ if (request && onError) {
1640
+ onError(request.status + " " + request.statusText);
1641
+ }
1642
+ });
1643
+ }
1644
+ };
1645
+ GLTFLoaderBase.LoadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
1646
+ var material = gltfRuntime.materials[id];
1647
+ if (!material.technique) {
1648
+ if (onError) {
1649
+ onError("No technique found.");
1650
+ }
1651
+ return;
1652
+ }
1653
+ var technique = gltfRuntime.techniques[material.technique];
1654
+ if (!technique) {
1655
+ gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;
1656
+ var defaultMaterial = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.StandardMaterial(id, gltfRuntime.scene);
1657
+ defaultMaterial._parentContainer = gltfRuntime.assetContainer;
1658
+ gltfRuntime.scene._blockEntityCollection = false;
1659
+ defaultMaterial.diffuseColor = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3(0.5, 0.5, 0.5);
1660
+ defaultMaterial.sideOrientation = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Material.CounterClockWiseSideOrientation;
1661
+ onSuccess(defaultMaterial);
1662
+ return;
1663
+ }
1664
+ var program = gltfRuntime.programs[technique.program];
1665
+ var states = technique.states;
1666
+ var vertexShader = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[program.vertexShader + "VertexShader"];
1667
+ var pixelShader = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[program.fragmentShader + "PixelShader"];
1668
+ var newVertexShader = "";
1669
+ var newPixelShader = "";
1670
+ var vertexTokenizer = new Tokenizer(vertexShader);
1671
+ var pixelTokenizer = new Tokenizer(pixelShader);
1672
+ var unTreatedUniforms = {};
1673
+ var uniforms = [];
1674
+ var attributes = [];
1675
+ var samplers = [];
1676
+ // Fill uniform, sampler2D and attributes
1677
+ for (var unif in technique.uniforms) {
1678
+ var uniform = technique.uniforms[unif];
1679
+ var uniformParameter = technique.parameters[uniform];
1680
+ unTreatedUniforms[unif] = uniformParameter;
1681
+ if (uniformParameter.semantic && !uniformParameter.node && !uniformParameter.source) {
1682
+ var transformIndex = glTFTransforms.indexOf(uniformParameter.semantic);
1683
+ if (transformIndex !== -1) {
1684
+ uniforms.push(babylonTransforms[transformIndex]);
1685
+ delete unTreatedUniforms[unif];
1686
+ }
1687
+ else {
1688
+ uniforms.push(unif);
1689
+ }
1690
+ }
1691
+ else if (uniformParameter.type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.SAMPLER_2D) {
1692
+ samplers.push(unif);
1693
+ }
1694
+ else {
1695
+ uniforms.push(unif);
1696
+ }
1697
+ }
1698
+ for (var attr in technique.attributes) {
1699
+ var attribute = technique.attributes[attr];
1700
+ var attributeParameter = technique.parameters[attribute];
1701
+ if (attributeParameter.semantic) {
1702
+ var name_1 = getAttribute(attributeParameter);
1703
+ if (name_1) {
1704
+ attributes.push(name_1);
1705
+ }
1706
+ }
1707
+ }
1708
+ // Configure vertex shader
1709
+ while (!vertexTokenizer.isEnd() && vertexTokenizer.getNextToken()) {
1710
+ var tokenType = vertexTokenizer.currentToken;
1711
+ if (tokenType !== ETokenType.IDENTIFIER) {
1712
+ newVertexShader += vertexTokenizer.currentString;
1713
+ continue;
1714
+ }
1715
+ var foundAttribute = false;
1716
+ for (var attr in technique.attributes) {
1717
+ var attribute = technique.attributes[attr];
1718
+ var attributeParameter = technique.parameters[attribute];
1719
+ if (vertexTokenizer.currentIdentifier === attr && attributeParameter.semantic) {
1720
+ newVertexShader += getAttribute(attributeParameter);
1721
+ foundAttribute = true;
1722
+ break;
1723
+ }
1724
+ }
1725
+ if (foundAttribute) {
1726
+ continue;
1727
+ }
1728
+ newVertexShader += parseShaderUniforms(vertexTokenizer, technique, unTreatedUniforms);
1729
+ }
1730
+ // Configure pixel shader
1731
+ while (!pixelTokenizer.isEnd() && pixelTokenizer.getNextToken()) {
1732
+ var tokenType = pixelTokenizer.currentToken;
1733
+ if (tokenType !== ETokenType.IDENTIFIER) {
1734
+ newPixelShader += pixelTokenizer.currentString;
1735
+ continue;
1736
+ }
1737
+ newPixelShader += parseShaderUniforms(pixelTokenizer, technique, unTreatedUniforms);
1738
+ }
1739
+ // Create shader material
1740
+ var shaderPath = {
1741
+ vertex: program.vertexShader + id,
1742
+ fragment: program.fragmentShader + id,
1743
+ };
1744
+ var options = {
1745
+ attributes: attributes,
1746
+ uniforms: uniforms,
1747
+ samplers: samplers,
1748
+ needAlphaBlending: states && states.enable && states.enable.indexOf(3042) !== -1,
1749
+ };
1750
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[program.vertexShader + id + "VertexShader"] = newVertexShader;
1751
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[program.fragmentShader + id + "PixelShader"] = newPixelShader;
1752
+ var shaderMaterial = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.ShaderMaterial(id, gltfRuntime.scene, shaderPath, options);
1753
+ shaderMaterial.onError = onShaderCompileError(program, shaderMaterial, onError);
1754
+ shaderMaterial.onCompiled = onShaderCompileSuccess(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess);
1755
+ shaderMaterial.sideOrientation = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Material.CounterClockWiseSideOrientation;
1756
+ if (states && states.functions) {
1757
+ var functions = states.functions;
1758
+ if (functions.cullFace && functions.cullFace[0] !== _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ECullingType.BACK) {
1759
+ shaderMaterial.backFaceCulling = false;
1760
+ }
1761
+ var blendFunc = functions.blendFuncSeparate;
1762
+ if (blendFunc) {
1763
+ if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.SRC_ALPHA &&
1764
+ blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE_MINUS_SRC_ALPHA &&
1765
+ blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE &&
1766
+ blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) {
1767
+ shaderMaterial.alphaMode = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_COMBINE;
1768
+ }
1769
+ else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE &&
1770
+ blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE &&
1771
+ blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ZERO &&
1772
+ blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) {
1773
+ shaderMaterial.alphaMode = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_ONEONE;
1774
+ }
1775
+ else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.SRC_ALPHA &&
1776
+ blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE &&
1777
+ blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ZERO &&
1778
+ blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) {
1779
+ shaderMaterial.alphaMode = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_ADD;
1780
+ }
1781
+ else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ZERO &&
1782
+ blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE_MINUS_SRC_COLOR &&
1783
+ blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE &&
1784
+ blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) {
1785
+ shaderMaterial.alphaMode = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_SUBTRACT;
1786
+ }
1787
+ else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.DST_COLOR &&
1788
+ blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ZERO &&
1789
+ blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE &&
1790
+ blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) {
1791
+ shaderMaterial.alphaMode = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_MULTIPLY;
1792
+ }
1793
+ else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.SRC_ALPHA &&
1794
+ blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE_MINUS_SRC_COLOR &&
1795
+ blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE &&
1796
+ blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) {
1797
+ shaderMaterial.alphaMode = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_MAXIMIZED;
1798
+ }
1799
+ }
1800
+ }
1801
+ };
1802
+ return GLTFLoaderBase;
1803
+ }());
1804
+
1805
+ /**
1806
+ * glTF V1 Loader
1807
+ * @hidden
1808
+ */
1809
+ var GLTFLoader = /** @class */ (function () {
1810
+ function GLTFLoader() {
1811
+ }
1812
+ GLTFLoader.RegisterExtension = function (extension) {
1813
+ if (GLTFLoader.Extensions[extension.name]) {
1814
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error('Tool with the same name "' + extension.name + '" already exists');
1815
+ return;
1816
+ }
1817
+ GLTFLoader.Extensions[extension.name] = extension;
1818
+ };
1819
+ GLTFLoader.prototype.dispose = function () {
1820
+ // do nothing
1821
+ };
1822
+ GLTFLoader.prototype._importMeshAsync = function (meshesNames, scene, data, rootUrl, assetContainer, onSuccess, onProgress, onError) {
1823
+ var _this = this;
1824
+ scene.useRightHandedSystem = true;
1825
+ GLTFLoaderExtension.LoadRuntimeAsync(scene, data, rootUrl, function (gltfRuntime) {
1826
+ gltfRuntime.assetContainer = assetContainer;
1827
+ gltfRuntime.importOnlyMeshes = true;
1828
+ if (meshesNames === "") {
1829
+ gltfRuntime.importMeshesNames = [];
1830
+ }
1831
+ else if (typeof meshesNames === "string") {
1832
+ gltfRuntime.importMeshesNames = [meshesNames];
1833
+ }
1834
+ else if (meshesNames && !(meshesNames instanceof Array)) {
1835
+ gltfRuntime.importMeshesNames = [meshesNames];
1836
+ }
1837
+ else {
1838
+ gltfRuntime.importMeshesNames = [];
1839
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Argument meshesNames must be of type string or string[]");
1840
+ }
1841
+ // Create nodes
1842
+ _this._createNodes(gltfRuntime);
1843
+ var meshes = new Array();
1844
+ var skeletons = new Array();
1845
+ // Fill arrays of meshes and skeletons
1846
+ for (var nde in gltfRuntime.nodes) {
1847
+ var node = gltfRuntime.nodes[nde];
1848
+ if (node.babylonNode instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.AbstractMesh) {
1849
+ meshes.push(node.babylonNode);
1850
+ }
1851
+ }
1852
+ for (var skl in gltfRuntime.skins) {
1853
+ var skin = gltfRuntime.skins[skl];
1854
+ if (skin.babylonSkeleton instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Skeleton) {
1855
+ skeletons.push(skin.babylonSkeleton);
1856
+ }
1857
+ }
1858
+ // Load buffers, shaders, materials, etc.
1859
+ _this._loadBuffersAsync(gltfRuntime, function () {
1860
+ _this._loadShadersAsync(gltfRuntime, function () {
1861
+ importMaterials(gltfRuntime);
1862
+ postLoad(gltfRuntime);
1863
+ if (!_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.IncrementalLoading && onSuccess) {
1864
+ onSuccess(meshes, skeletons);
1865
+ }
1866
+ });
1867
+ });
1868
+ if (_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.IncrementalLoading && onSuccess) {
1869
+ onSuccess(meshes, skeletons);
1870
+ }
1871
+ }, onError);
1872
+ return true;
1873
+ };
1874
+ /**
1875
+ * Imports one or more meshes from a loaded gltf file and adds them to the scene
1876
+ * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
1877
+ * @param scene the scene the meshes should be added to
1878
+ * @param assetContainer defines the asset container to use (can be null)
1879
+ * @param data gltf data containing information of the meshes in a loaded file
1880
+ * @param rootUrl root url to load from
1881
+ * @param onProgress event that fires when loading progress has occured
1882
+ * @returns a promise containg the loaded meshes, particles, skeletons and animations
1883
+ */
1884
+ GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, assetContainer, data, rootUrl, onProgress) {
1885
+ var _this = this;
1886
+ return new Promise(function (resolve, reject) {
1887
+ _this._importMeshAsync(meshesNames, scene, data, rootUrl, assetContainer, function (meshes, skeletons) {
1888
+ resolve({
1889
+ meshes: meshes,
1890
+ particleSystems: [],
1891
+ skeletons: skeletons,
1892
+ animationGroups: [],
1893
+ lights: [],
1894
+ transformNodes: [],
1895
+ geometries: [],
1896
+ });
1897
+ }, onProgress, function (message) {
1898
+ reject(new Error(message));
1899
+ });
1900
+ });
1901
+ };
1902
+ GLTFLoader.prototype._loadAsync = function (scene, data, rootUrl, onSuccess, onProgress, onError) {
1903
+ var _this = this;
1904
+ scene.useRightHandedSystem = true;
1905
+ GLTFLoaderExtension.LoadRuntimeAsync(scene, data, rootUrl, function (gltfRuntime) {
1906
+ // Load runtime extensios
1907
+ GLTFLoaderExtension.LoadRuntimeExtensionsAsync(gltfRuntime, function () {
1908
+ // Create nodes
1909
+ _this._createNodes(gltfRuntime);
1910
+ // Load buffers, shaders, materials, etc.
1911
+ _this._loadBuffersAsync(gltfRuntime, function () {
1912
+ _this._loadShadersAsync(gltfRuntime, function () {
1913
+ importMaterials(gltfRuntime);
1914
+ postLoad(gltfRuntime);
1915
+ if (!_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.IncrementalLoading) {
1916
+ onSuccess();
1917
+ }
1918
+ });
1919
+ });
1920
+ if (_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.IncrementalLoading) {
1921
+ onSuccess();
1922
+ }
1923
+ }, onError);
1924
+ }, onError);
1925
+ };
1926
+ /**
1927
+ * Imports all objects from a loaded gltf file and adds them to the scene
1928
+ * @param scene the scene the objects should be added to
1929
+ * @param data gltf data containing information of the meshes in a loaded file
1930
+ * @param rootUrl root url to load from
1931
+ * @param onProgress event that fires when loading progress has occured
1932
+ * @returns a promise which completes when objects have been loaded to the scene
1933
+ */
1934
+ GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress) {
1935
+ var _this = this;
1936
+ return new Promise(function (resolve, reject) {
1937
+ _this._loadAsync(scene, data, rootUrl, function () {
1938
+ resolve();
1939
+ }, onProgress, function (message) {
1940
+ reject(new Error(message));
1941
+ });
1942
+ });
1943
+ };
1944
+ GLTFLoader.prototype._loadShadersAsync = function (gltfRuntime, onload) {
1945
+ var hasShaders = false;
1946
+ var processShader = function (sha, shader) {
1947
+ GLTFLoaderExtension.LoadShaderStringAsync(gltfRuntime, sha, function (shaderString) {
1948
+ if (shaderString instanceof ArrayBuffer) {
1949
+ return;
1950
+ }
1951
+ gltfRuntime.loadedShaderCount++;
1952
+ if (shaderString) {
1953
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[sha + (shader.type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EShaderType.VERTEX ? "VertexShader" : "PixelShader")] = shaderString;
1954
+ }
1955
+ if (gltfRuntime.loadedShaderCount === gltfRuntime.shaderscount) {
1956
+ onload();
1957
+ }
1958
+ }, function () {
1959
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("Error when loading shader program named " + sha + " located at " + shader.uri);
1960
+ });
1961
+ };
1962
+ for (var sha in gltfRuntime.shaders) {
1963
+ hasShaders = true;
1964
+ var shader = gltfRuntime.shaders[sha];
1965
+ if (shader) {
1966
+ processShader.bind(this, sha, shader)();
1967
+ }
1968
+ else {
1969
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("No shader named: " + sha);
1970
+ }
1971
+ }
1972
+ if (!hasShaders) {
1973
+ onload();
1974
+ }
1975
+ };
1976
+ GLTFLoader.prototype._loadBuffersAsync = function (gltfRuntime, onLoad) {
1977
+ var hasBuffers = false;
1978
+ var processBuffer = function (buf, buffer) {
1979
+ GLTFLoaderExtension.LoadBufferAsync(gltfRuntime, buf, function (bufferView) {
1980
+ gltfRuntime.loadedBufferCount++;
1981
+ if (bufferView) {
1982
+ if (bufferView.byteLength != gltfRuntime.buffers[buf].byteLength) {
1983
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("Buffer named " + buf + " is length " + bufferView.byteLength + ". Expected: " + buffer.byteLength); // Improve error message
1984
+ }
1985
+ gltfRuntime.loadedBufferViews[buf] = bufferView;
1986
+ }
1987
+ if (gltfRuntime.loadedBufferCount === gltfRuntime.buffersCount) {
1988
+ onLoad();
1989
+ }
1990
+ }, function () {
1991
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("Error when loading buffer named " + buf + " located at " + buffer.uri);
1992
+ });
1993
+ };
1994
+ for (var buf in gltfRuntime.buffers) {
1995
+ hasBuffers = true;
1996
+ var buffer = gltfRuntime.buffers[buf];
1997
+ if (buffer) {
1998
+ processBuffer.bind(this, buf, buffer)();
1999
+ }
2000
+ else {
2001
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("No buffer named: " + buf);
2002
+ }
2003
+ }
2004
+ if (!hasBuffers) {
2005
+ onLoad();
2006
+ }
2007
+ };
2008
+ GLTFLoader.prototype._createNodes = function (gltfRuntime) {
2009
+ var currentScene = gltfRuntime.currentScene;
2010
+ if (currentScene) {
2011
+ // Only one scene even if multiple scenes are defined
2012
+ for (var i = 0; i < currentScene.nodes.length; i++) {
2013
+ traverseNodes(gltfRuntime, currentScene.nodes[i], null);
2014
+ }
2015
+ }
2016
+ else {
2017
+ // Load all scenes
2018
+ for (var thing in gltfRuntime.scenes) {
2019
+ currentScene = gltfRuntime.scenes[thing];
2020
+ for (var i = 0; i < currentScene.nodes.length; i++) {
2021
+ traverseNodes(gltfRuntime, currentScene.nodes[i], null);
2022
+ }
2023
+ }
2024
+ }
2025
+ };
2026
+ GLTFLoader.Extensions = {};
2027
+ return GLTFLoader;
2028
+ }());
2029
+
2030
+ /** @hidden */
2031
+ var GLTFLoaderExtension = /** @class */ (function () {
2032
+ function GLTFLoaderExtension(name) {
2033
+ this._name = name;
2034
+ }
2035
+ Object.defineProperty(GLTFLoaderExtension.prototype, "name", {
2036
+ get: function () {
2037
+ return this._name;
2038
+ },
2039
+ enumerable: false,
2040
+ configurable: true
2041
+ });
2042
+ /**
2043
+ * Defines an override for loading the runtime
2044
+ * Return true to stop further extensions from loading the runtime
2045
+ * @param scene
2046
+ * @param data
2047
+ * @param rootUrl
2048
+ * @param onSuccess
2049
+ * @param onError
2050
+ */
2051
+ GLTFLoaderExtension.prototype.loadRuntimeAsync = function (scene, data, rootUrl, onSuccess, onError) {
2052
+ return false;
2053
+ };
2054
+ /**
2055
+ * Defines an onverride for creating gltf runtime
2056
+ * Return true to stop further extensions from creating the runtime
2057
+ * @param gltfRuntime
2058
+ * @param onSuccess
2059
+ * @param onError
2060
+ */
2061
+ GLTFLoaderExtension.prototype.loadRuntimeExtensionsAsync = function (gltfRuntime, onSuccess, onError) {
2062
+ return false;
2063
+ };
2064
+ /**
2065
+ * Defines an override for loading buffers
2066
+ * Return true to stop further extensions from loading this buffer
2067
+ * @param gltfRuntime
2068
+ * @param id
2069
+ * @param onSuccess
2070
+ * @param onError
2071
+ * @param onProgress
2072
+ */
2073
+ GLTFLoaderExtension.prototype.loadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) {
2074
+ return false;
2075
+ };
2076
+ /**
2077
+ * Defines an override for loading texture buffers
2078
+ * Return true to stop further extensions from loading this texture data
2079
+ * @param gltfRuntime
2080
+ * @param id
2081
+ * @param onSuccess
2082
+ * @param onError
2083
+ */
2084
+ GLTFLoaderExtension.prototype.loadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) {
2085
+ return false;
2086
+ };
2087
+ /**
2088
+ * Defines an override for creating textures
2089
+ * Return true to stop further extensions from loading this texture
2090
+ * @param gltfRuntime
2091
+ * @param id
2092
+ * @param buffer
2093
+ * @param onSuccess
2094
+ * @param onError
2095
+ */
2096
+ GLTFLoaderExtension.prototype.createTextureAsync = function (gltfRuntime, id, buffer, onSuccess, onError) {
2097
+ return false;
2098
+ };
2099
+ /**
2100
+ * Defines an override for loading shader strings
2101
+ * Return true to stop further extensions from loading this shader data
2102
+ * @param gltfRuntime
2103
+ * @param id
2104
+ * @param onSuccess
2105
+ * @param onError
2106
+ */
2107
+ GLTFLoaderExtension.prototype.loadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) {
2108
+ return false;
2109
+ };
2110
+ /**
2111
+ * Defines an override for loading materials
2112
+ * Return true to stop further extensions from loading this material
2113
+ * @param gltfRuntime
2114
+ * @param id
2115
+ * @param onSuccess
2116
+ * @param onError
2117
+ */
2118
+ GLTFLoaderExtension.prototype.loadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
2119
+ return false;
2120
+ };
2121
+ // ---------
2122
+ // Utilities
2123
+ // ---------
2124
+ GLTFLoaderExtension.LoadRuntimeAsync = function (scene, data, rootUrl, onSuccess, onError) {
2125
+ GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) {
2126
+ return loaderExtension.loadRuntimeAsync(scene, data, rootUrl, onSuccess, onError);
2127
+ }, function () {
2128
+ setTimeout(function () {
2129
+ if (!onSuccess) {
2130
+ return;
2131
+ }
2132
+ onSuccess(GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl));
2133
+ });
2134
+ });
2135
+ };
2136
+ GLTFLoaderExtension.LoadRuntimeExtensionsAsync = function (gltfRuntime, onSuccess, onError) {
2137
+ GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) {
2138
+ return loaderExtension.loadRuntimeExtensionsAsync(gltfRuntime, onSuccess, onError);
2139
+ }, function () {
2140
+ setTimeout(function () {
2141
+ onSuccess();
2142
+ });
2143
+ });
2144
+ };
2145
+ GLTFLoaderExtension.LoadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) {
2146
+ GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) {
2147
+ return loaderExtension.loadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress);
2148
+ }, function () {
2149
+ GLTFLoaderBase.LoadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress);
2150
+ });
2151
+ };
2152
+ GLTFLoaderExtension.LoadTextureAsync = function (gltfRuntime, id, onSuccess, onError) {
2153
+ GLTFLoaderExtension._LoadTextureBufferAsync(gltfRuntime, id, function (buffer) {
2154
+ if (buffer) {
2155
+ GLTFLoaderExtension._CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
2156
+ }
2157
+ }, onError);
2158
+ };
2159
+ GLTFLoaderExtension.LoadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) {
2160
+ GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) {
2161
+ return loaderExtension.loadShaderStringAsync(gltfRuntime, id, onSuccess, onError);
2162
+ }, function () {
2163
+ GLTFLoaderBase.LoadShaderStringAsync(gltfRuntime, id, onSuccess, onError);
2164
+ });
2165
+ };
2166
+ GLTFLoaderExtension.LoadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
2167
+ GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) {
2168
+ return loaderExtension.loadMaterialAsync(gltfRuntime, id, onSuccess, onError);
2169
+ }, function () {
2170
+ GLTFLoaderBase.LoadMaterialAsync(gltfRuntime, id, onSuccess, onError);
2171
+ });
2172
+ };
2173
+ GLTFLoaderExtension._LoadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) {
2174
+ GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) {
2175
+ return loaderExtension.loadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
2176
+ }, function () {
2177
+ GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
2178
+ });
2179
+ };
2180
+ GLTFLoaderExtension._CreateTextureAsync = function (gltfRuntime, id, buffer, onSuccess, onError) {
2181
+ GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) {
2182
+ return loaderExtension.createTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
2183
+ }, function () {
2184
+ GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, onSuccess);
2185
+ });
2186
+ };
2187
+ GLTFLoaderExtension._ApplyExtensions = function (func, defaultFunc) {
2188
+ for (var extensionName in GLTFLoader.Extensions) {
2189
+ var loaderExtension = GLTFLoader.Extensions[extensionName];
2190
+ if (func(loaderExtension)) {
2191
+ return;
2192
+ }
2193
+ }
2194
+ defaultFunc();
2195
+ };
2196
+ return GLTFLoaderExtension;
2197
+ }());
2198
+
2199
+ _glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader._CreateGLTF1Loader = function () { return new GLTFLoader(); };
2200
+
2201
+
2202
+ /***/ }),
2203
+
2204
+ /***/ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderInterfaces.js":
2205
+ /*!******************************************************************!*\
2206
+ !*** ../../../lts/loaders/dist/glTF/1.0/glTFLoaderInterfaces.js ***!
2207
+ \******************************************************************/
2208
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2209
+
2210
+ __webpack_require__.r(__webpack_exports__);
2211
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2212
+ /* harmony export */ "EBlendingFunction": () => (/* binding */ EBlendingFunction),
2213
+ /* harmony export */ "EComponentType": () => (/* binding */ EComponentType),
2214
+ /* harmony export */ "ECullingType": () => (/* binding */ ECullingType),
2215
+ /* harmony export */ "EParameterType": () => (/* binding */ EParameterType),
2216
+ /* harmony export */ "EShaderType": () => (/* binding */ EShaderType),
2217
+ /* harmony export */ "ETextureFilterType": () => (/* binding */ ETextureFilterType),
2218
+ /* harmony export */ "ETextureFormat": () => (/* binding */ ETextureFormat),
2219
+ /* harmony export */ "ETextureWrapMode": () => (/* binding */ ETextureWrapMode)
2220
+ /* harmony export */ });
2221
+ /**
2222
+ * Enums
2223
+ * @hidden
2224
+ */
2225
+ var EComponentType;
2226
+ (function (EComponentType) {
2227
+ EComponentType[EComponentType["BYTE"] = 5120] = "BYTE";
2228
+ EComponentType[EComponentType["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE";
2229
+ EComponentType[EComponentType["SHORT"] = 5122] = "SHORT";
2230
+ EComponentType[EComponentType["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT";
2231
+ EComponentType[EComponentType["FLOAT"] = 5126] = "FLOAT";
2232
+ })(EComponentType || (EComponentType = {}));
2233
+ /** @hidden */
2234
+ var EShaderType;
2235
+ (function (EShaderType) {
2236
+ EShaderType[EShaderType["FRAGMENT"] = 35632] = "FRAGMENT";
2237
+ EShaderType[EShaderType["VERTEX"] = 35633] = "VERTEX";
2238
+ })(EShaderType || (EShaderType = {}));
2239
+ /** @hidden */
2240
+ var EParameterType;
2241
+ (function (EParameterType) {
2242
+ EParameterType[EParameterType["BYTE"] = 5120] = "BYTE";
2243
+ EParameterType[EParameterType["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE";
2244
+ EParameterType[EParameterType["SHORT"] = 5122] = "SHORT";
2245
+ EParameterType[EParameterType["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT";
2246
+ EParameterType[EParameterType["INT"] = 5124] = "INT";
2247
+ EParameterType[EParameterType["UNSIGNED_INT"] = 5125] = "UNSIGNED_INT";
2248
+ EParameterType[EParameterType["FLOAT"] = 5126] = "FLOAT";
2249
+ EParameterType[EParameterType["FLOAT_VEC2"] = 35664] = "FLOAT_VEC2";
2250
+ EParameterType[EParameterType["FLOAT_VEC3"] = 35665] = "FLOAT_VEC3";
2251
+ EParameterType[EParameterType["FLOAT_VEC4"] = 35666] = "FLOAT_VEC4";
2252
+ EParameterType[EParameterType["INT_VEC2"] = 35667] = "INT_VEC2";
2253
+ EParameterType[EParameterType["INT_VEC3"] = 35668] = "INT_VEC3";
2254
+ EParameterType[EParameterType["INT_VEC4"] = 35669] = "INT_VEC4";
2255
+ EParameterType[EParameterType["BOOL"] = 35670] = "BOOL";
2256
+ EParameterType[EParameterType["BOOL_VEC2"] = 35671] = "BOOL_VEC2";
2257
+ EParameterType[EParameterType["BOOL_VEC3"] = 35672] = "BOOL_VEC3";
2258
+ EParameterType[EParameterType["BOOL_VEC4"] = 35673] = "BOOL_VEC4";
2259
+ EParameterType[EParameterType["FLOAT_MAT2"] = 35674] = "FLOAT_MAT2";
2260
+ EParameterType[EParameterType["FLOAT_MAT3"] = 35675] = "FLOAT_MAT3";
2261
+ EParameterType[EParameterType["FLOAT_MAT4"] = 35676] = "FLOAT_MAT4";
2262
+ EParameterType[EParameterType["SAMPLER_2D"] = 35678] = "SAMPLER_2D";
2263
+ })(EParameterType || (EParameterType = {}));
2264
+ /** @hidden */
2265
+ var ETextureWrapMode;
2266
+ (function (ETextureWrapMode) {
2267
+ ETextureWrapMode[ETextureWrapMode["CLAMP_TO_EDGE"] = 33071] = "CLAMP_TO_EDGE";
2268
+ ETextureWrapMode[ETextureWrapMode["MIRRORED_REPEAT"] = 33648] = "MIRRORED_REPEAT";
2269
+ ETextureWrapMode[ETextureWrapMode["REPEAT"] = 10497] = "REPEAT";
2270
+ })(ETextureWrapMode || (ETextureWrapMode = {}));
2271
+ /** @hidden */
2272
+ var ETextureFilterType;
2273
+ (function (ETextureFilterType) {
2274
+ ETextureFilterType[ETextureFilterType["NEAREST"] = 9728] = "NEAREST";
2275
+ ETextureFilterType[ETextureFilterType["LINEAR"] = 9728] = "LINEAR";
2276
+ ETextureFilterType[ETextureFilterType["NEAREST_MIPMAP_NEAREST"] = 9984] = "NEAREST_MIPMAP_NEAREST";
2277
+ ETextureFilterType[ETextureFilterType["LINEAR_MIPMAP_NEAREST"] = 9985] = "LINEAR_MIPMAP_NEAREST";
2278
+ ETextureFilterType[ETextureFilterType["NEAREST_MIPMAP_LINEAR"] = 9986] = "NEAREST_MIPMAP_LINEAR";
2279
+ ETextureFilterType[ETextureFilterType["LINEAR_MIPMAP_LINEAR"] = 9987] = "LINEAR_MIPMAP_LINEAR";
2280
+ })(ETextureFilterType || (ETextureFilterType = {}));
2281
+ /** @hidden */
2282
+ var ETextureFormat;
2283
+ (function (ETextureFormat) {
2284
+ ETextureFormat[ETextureFormat["ALPHA"] = 6406] = "ALPHA";
2285
+ ETextureFormat[ETextureFormat["RGB"] = 6407] = "RGB";
2286
+ ETextureFormat[ETextureFormat["RGBA"] = 6408] = "RGBA";
2287
+ ETextureFormat[ETextureFormat["LUMINANCE"] = 6409] = "LUMINANCE";
2288
+ ETextureFormat[ETextureFormat["LUMINANCE_ALPHA"] = 6410] = "LUMINANCE_ALPHA";
2289
+ })(ETextureFormat || (ETextureFormat = {}));
2290
+ /** @hidden */
2291
+ var ECullingType;
2292
+ (function (ECullingType) {
2293
+ ECullingType[ECullingType["FRONT"] = 1028] = "FRONT";
2294
+ ECullingType[ECullingType["BACK"] = 1029] = "BACK";
2295
+ ECullingType[ECullingType["FRONT_AND_BACK"] = 1032] = "FRONT_AND_BACK";
2296
+ })(ECullingType || (ECullingType = {}));
2297
+ /** @hidden */
2298
+ var EBlendingFunction;
2299
+ (function (EBlendingFunction) {
2300
+ EBlendingFunction[EBlendingFunction["ZERO"] = 0] = "ZERO";
2301
+ EBlendingFunction[EBlendingFunction["ONE"] = 1] = "ONE";
2302
+ EBlendingFunction[EBlendingFunction["SRC_COLOR"] = 768] = "SRC_COLOR";
2303
+ EBlendingFunction[EBlendingFunction["ONE_MINUS_SRC_COLOR"] = 769] = "ONE_MINUS_SRC_COLOR";
2304
+ EBlendingFunction[EBlendingFunction["DST_COLOR"] = 774] = "DST_COLOR";
2305
+ EBlendingFunction[EBlendingFunction["ONE_MINUS_DST_COLOR"] = 775] = "ONE_MINUS_DST_COLOR";
2306
+ EBlendingFunction[EBlendingFunction["SRC_ALPHA"] = 770] = "SRC_ALPHA";
2307
+ EBlendingFunction[EBlendingFunction["ONE_MINUS_SRC_ALPHA"] = 771] = "ONE_MINUS_SRC_ALPHA";
2308
+ EBlendingFunction[EBlendingFunction["DST_ALPHA"] = 772] = "DST_ALPHA";
2309
+ EBlendingFunction[EBlendingFunction["ONE_MINUS_DST_ALPHA"] = 773] = "ONE_MINUS_DST_ALPHA";
2310
+ EBlendingFunction[EBlendingFunction["CONSTANT_COLOR"] = 32769] = "CONSTANT_COLOR";
2311
+ EBlendingFunction[EBlendingFunction["ONE_MINUS_CONSTANT_COLOR"] = 32770] = "ONE_MINUS_CONSTANT_COLOR";
2312
+ EBlendingFunction[EBlendingFunction["CONSTANT_ALPHA"] = 32771] = "CONSTANT_ALPHA";
2313
+ EBlendingFunction[EBlendingFunction["ONE_MINUS_CONSTANT_ALPHA"] = 32772] = "ONE_MINUS_CONSTANT_ALPHA";
2314
+ EBlendingFunction[EBlendingFunction["SRC_ALPHA_SATURATE"] = 776] = "SRC_ALPHA_SATURATE";
2315
+ })(EBlendingFunction || (EBlendingFunction = {}));
2316
+
2317
+
2318
+ /***/ }),
2319
+
2320
+ /***/ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderUtils.js":
2321
+ /*!*************************************************************!*\
2322
+ !*** ../../../lts/loaders/dist/glTF/1.0/glTFLoaderUtils.js ***!
2323
+ \*************************************************************/
2324
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2325
+
2326
+ __webpack_require__.r(__webpack_exports__);
2327
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2328
+ /* harmony export */ "GLTFUtils": () => (/* binding */ GLTFUtils)
2329
+ /* harmony export */ });
2330
+ /* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderInterfaces.js");
2331
+ /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core/Materials/Textures/texture */ "core/Misc/observable");
2332
+ /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
2333
+
2334
+
2335
+
2336
+
2337
+
2338
+
2339
+ /**
2340
+ * Utils functions for GLTF
2341
+ * @hidden
2342
+ */
2343
+ var GLTFUtils = /** @class */ (function () {
2344
+ function GLTFUtils() {
2345
+ }
2346
+ /**
2347
+ * Sets the given "parameter" matrix
2348
+ * @param scene the Scene object
2349
+ * @param source the source node where to pick the matrix
2350
+ * @param parameter the GLTF technique parameter
2351
+ * @param uniformName the name of the shader's uniform
2352
+ * @param shaderMaterial the shader material
2353
+ */
2354
+ GLTFUtils.SetMatrix = function (scene, source, parameter, uniformName, shaderMaterial) {
2355
+ var mat = null;
2356
+ if (parameter.semantic === "MODEL") {
2357
+ mat = source.getWorldMatrix();
2358
+ }
2359
+ else if (parameter.semantic === "PROJECTION") {
2360
+ mat = scene.getProjectionMatrix();
2361
+ }
2362
+ else if (parameter.semantic === "VIEW") {
2363
+ mat = scene.getViewMatrix();
2364
+ }
2365
+ else if (parameter.semantic === "MODELVIEWINVERSETRANSPOSE") {
2366
+ mat = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Transpose(source.getWorldMatrix().multiply(scene.getViewMatrix()).invert());
2367
+ }
2368
+ else if (parameter.semantic === "MODELVIEW") {
2369
+ mat = source.getWorldMatrix().multiply(scene.getViewMatrix());
2370
+ }
2371
+ else if (parameter.semantic === "MODELVIEWPROJECTION") {
2372
+ mat = source.getWorldMatrix().multiply(scene.getTransformMatrix());
2373
+ }
2374
+ else if (parameter.semantic === "MODELINVERSE") {
2375
+ mat = source.getWorldMatrix().invert();
2376
+ }
2377
+ else if (parameter.semantic === "VIEWINVERSE") {
2378
+ mat = scene.getViewMatrix().invert();
2379
+ }
2380
+ else if (parameter.semantic === "PROJECTIONINVERSE") {
2381
+ mat = scene.getProjectionMatrix().invert();
2382
+ }
2383
+ else if (parameter.semantic === "MODELVIEWINVERSE") {
2384
+ mat = source.getWorldMatrix().multiply(scene.getViewMatrix()).invert();
2385
+ }
2386
+ else if (parameter.semantic === "MODELVIEWPROJECTIONINVERSE") {
2387
+ mat = source.getWorldMatrix().multiply(scene.getTransformMatrix()).invert();
2388
+ }
2389
+ else if (parameter.semantic === "MODELINVERSETRANSPOSE") {
2390
+ mat = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Transpose(source.getWorldMatrix().invert());
2391
+ }
2392
+ if (mat) {
2393
+ switch (parameter.type) {
2394
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT2:
2395
+ shaderMaterial.setMatrix2x2(uniformName, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.GetAsMatrix2x2(mat));
2396
+ break;
2397
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT3:
2398
+ shaderMaterial.setMatrix3x3(uniformName, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.GetAsMatrix3x3(mat));
2399
+ break;
2400
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT4:
2401
+ shaderMaterial.setMatrix(uniformName, mat);
2402
+ break;
2403
+ default:
2404
+ break;
2405
+ }
2406
+ }
2407
+ };
2408
+ /**
2409
+ * Sets the given "parameter" matrix
2410
+ * @param shaderMaterial the shader material
2411
+ * @param uniform the name of the shader's uniform
2412
+ * @param value the value of the uniform
2413
+ * @param type the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
2414
+ */
2415
+ GLTFUtils.SetUniform = function (shaderMaterial, uniform, value, type) {
2416
+ switch (type) {
2417
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT:
2418
+ shaderMaterial.setFloat(uniform, value);
2419
+ return true;
2420
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_VEC2:
2421
+ shaderMaterial.setVector2(uniform, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector2.FromArray(value));
2422
+ return true;
2423
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_VEC3:
2424
+ shaderMaterial.setVector3(uniform, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(value));
2425
+ return true;
2426
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_VEC4:
2427
+ shaderMaterial.setVector4(uniform, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector4.FromArray(value));
2428
+ return true;
2429
+ default:
2430
+ return false;
2431
+ }
2432
+ };
2433
+ /**
2434
+ * Returns the wrap mode of the texture
2435
+ * @param mode the mode value
2436
+ */
2437
+ GLTFUtils.GetWrapMode = function (mode) {
2438
+ switch (mode) {
2439
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureWrapMode.CLAMP_TO_EDGE:
2440
+ return core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.CLAMP_ADDRESSMODE;
2441
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureWrapMode.MIRRORED_REPEAT:
2442
+ return core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.MIRROR_ADDRESSMODE;
2443
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureWrapMode.REPEAT:
2444
+ return core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.WRAP_ADDRESSMODE;
2445
+ default:
2446
+ return core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.WRAP_ADDRESSMODE;
2447
+ }
2448
+ };
2449
+ /**
2450
+ * Returns the byte stride giving an accessor
2451
+ * @param accessor the GLTF accessor objet
2452
+ */
2453
+ GLTFUtils.GetByteStrideFromType = function (accessor) {
2454
+ // Needs this function since "byteStride" isn't requiered in glTF format
2455
+ var type = accessor.type;
2456
+ switch (type) {
2457
+ case "VEC2":
2458
+ return 2;
2459
+ case "VEC3":
2460
+ return 3;
2461
+ case "VEC4":
2462
+ return 4;
2463
+ case "MAT2":
2464
+ return 4;
2465
+ case "MAT3":
2466
+ return 9;
2467
+ case "MAT4":
2468
+ return 16;
2469
+ default:
2470
+ return 1;
2471
+ }
2472
+ };
2473
+ /**
2474
+ * Returns the texture filter mode giving a mode value
2475
+ * @param mode the filter mode value
2476
+ */
2477
+ GLTFUtils.GetTextureFilterMode = function (mode) {
2478
+ switch (mode) {
2479
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR:
2480
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR_MIPMAP_NEAREST:
2481
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR_MIPMAP_LINEAR:
2482
+ return core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.TRILINEAR_SAMPLINGMODE;
2483
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.NEAREST:
2484
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.NEAREST_MIPMAP_NEAREST:
2485
+ return core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_SAMPLINGMODE;
2486
+ default:
2487
+ return core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.BILINEAR_SAMPLINGMODE;
2488
+ }
2489
+ };
2490
+ GLTFUtils.GetBufferFromBufferView = function (gltfRuntime, bufferView, byteOffset, byteLength, componentType) {
2491
+ byteOffset = bufferView.byteOffset + byteOffset;
2492
+ var loadedBufferView = gltfRuntime.loadedBufferViews[bufferView.buffer];
2493
+ if (byteOffset + byteLength > loadedBufferView.byteLength) {
2494
+ throw new Error("Buffer access is out of range");
2495
+ }
2496
+ var buffer = loadedBufferView.buffer;
2497
+ byteOffset += loadedBufferView.byteOffset;
2498
+ switch (componentType) {
2499
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EComponentType.BYTE:
2500
+ return new Int8Array(buffer, byteOffset, byteLength);
2501
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EComponentType.UNSIGNED_BYTE:
2502
+ return new Uint8Array(buffer, byteOffset, byteLength);
2503
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EComponentType.SHORT:
2504
+ return new Int16Array(buffer, byteOffset, byteLength);
2505
+ case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EComponentType.UNSIGNED_SHORT:
2506
+ return new Uint16Array(buffer, byteOffset, byteLength);
2507
+ default:
2508
+ return new Float32Array(buffer, byteOffset, byteLength);
2509
+ }
2510
+ };
2511
+ /**
2512
+ * Returns a buffer from its accessor
2513
+ * @param gltfRuntime the GLTF runtime
2514
+ * @param accessor the GLTF accessor
2515
+ */
2516
+ GLTFUtils.GetBufferFromAccessor = function (gltfRuntime, accessor) {
2517
+ var bufferView = gltfRuntime.bufferViews[accessor.bufferView];
2518
+ var byteLength = accessor.count * GLTFUtils.GetByteStrideFromType(accessor);
2519
+ return GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, accessor.byteOffset, byteLength, accessor.componentType);
2520
+ };
2521
+ /**
2522
+ * Decodes a buffer view into a string
2523
+ * @param view the buffer view
2524
+ */
2525
+ GLTFUtils.DecodeBufferToText = function (view) {
2526
+ var result = "";
2527
+ var length = view.byteLength;
2528
+ for (var i = 0; i < length; ++i) {
2529
+ result += String.fromCharCode(view[i]);
2530
+ }
2531
+ return result;
2532
+ };
2533
+ /**
2534
+ * Returns the default material of gltf. Related to
2535
+ * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
2536
+ * @param scene the Babylon.js scene
2537
+ */
2538
+ GLTFUtils.GetDefaultMaterial = function (scene) {
2539
+ if (!GLTFUtils._DefaultMaterial) {
2540
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore.GLTFDefaultMaterialVertexShader = [
2541
+ "precision highp float;",
2542
+ "",
2543
+ "uniform mat4 worldView;",
2544
+ "uniform mat4 projection;",
2545
+ "",
2546
+ "attribute vec3 position;",
2547
+ "",
2548
+ "void main(void)",
2549
+ "{",
2550
+ " gl_Position = projection * worldView * vec4(position, 1.0);",
2551
+ "}",
2552
+ ].join("\n");
2553
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore.GLTFDefaultMaterialPixelShader = [
2554
+ "precision highp float;",
2555
+ "",
2556
+ "uniform vec4 u_emission;",
2557
+ "",
2558
+ "void main(void)",
2559
+ "{",
2560
+ " gl_FragColor = u_emission;",
2561
+ "}",
2562
+ ].join("\n");
2563
+ var shaderPath = {
2564
+ vertex: "GLTFDefaultMaterial",
2565
+ fragment: "GLTFDefaultMaterial",
2566
+ };
2567
+ var options = {
2568
+ attributes: ["position"],
2569
+ uniforms: ["worldView", "projection", "u_emission"],
2570
+ samplers: new Array(),
2571
+ needAlphaBlending: false,
2572
+ };
2573
+ GLTFUtils._DefaultMaterial = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.ShaderMaterial("GLTFDefaultMaterial", scene, shaderPath, options);
2574
+ GLTFUtils._DefaultMaterial.setColor4("u_emission", new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color4(0.5, 0.5, 0.5, 1.0));
2575
+ }
2576
+ return GLTFUtils._DefaultMaterial;
2577
+ };
2578
+ // The GLTF default material
2579
+ GLTFUtils._DefaultMaterial = null;
2580
+ return GLTFUtils;
2581
+ }());
2582
+
2583
+
2584
+
2585
+ /***/ }),
2586
+
2587
+ /***/ "../../../lts/loaders/dist/glTF/1.0/glTFMaterialsCommonExtension.js":
2588
+ /*!**************************************************************************!*\
2589
+ !*** ../../../lts/loaders/dist/glTF/1.0/glTFMaterialsCommonExtension.js ***!
2590
+ \**************************************************************************/
2591
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2592
+
2593
+ __webpack_require__.r(__webpack_exports__);
2594
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2595
+ /* harmony export */ "GLTFMaterialsCommonExtension": () => (/* binding */ GLTFMaterialsCommonExtension)
2596
+ /* harmony export */ });
2597
+ /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.js");
2598
+ /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoader */ "../../../lts/loaders/dist/glTF/1.0/glTFLoader.js");
2599
+ /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core/Lights/spotLight */ "core/Misc/observable");
2600
+ /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__);
2601
+
2602
+
2603
+
2604
+
2605
+
2606
+
2607
+
2608
+
2609
+
2610
+
2611
+
2612
+ /** @hidden */
2613
+ var GLTFMaterialsCommonExtension = /** @class */ (function (_super) {
2614
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(GLTFMaterialsCommonExtension, _super);
2615
+ function GLTFMaterialsCommonExtension() {
2616
+ return _super.call(this, "KHR_materials_common") || this;
2617
+ }
2618
+ GLTFMaterialsCommonExtension.prototype.loadRuntimeExtensionsAsync = function (gltfRuntime) {
2619
+ if (!gltfRuntime.extensions) {
2620
+ return false;
2621
+ }
2622
+ var extension = gltfRuntime.extensions[this.name];
2623
+ if (!extension) {
2624
+ return false;
2625
+ }
2626
+ // Create lights
2627
+ var lights = extension.lights;
2628
+ if (lights) {
2629
+ for (var thing in lights) {
2630
+ var light = lights[thing];
2631
+ switch (light.type) {
2632
+ case "ambient": {
2633
+ var ambientLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.HemisphericLight(light.name, new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Vector3(0, 1, 0), gltfRuntime.scene);
2634
+ var ambient = light.ambient;
2635
+ if (ambient) {
2636
+ ambientLight.diffuse = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Color3.FromArray(ambient.color || [1, 1, 1]);
2637
+ }
2638
+ break;
2639
+ }
2640
+ case "point": {
2641
+ var pointLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.PointLight(light.name, new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Vector3(10, 10, 10), gltfRuntime.scene);
2642
+ var point = light.point;
2643
+ if (point) {
2644
+ pointLight.diffuse = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Color3.FromArray(point.color || [1, 1, 1]);
2645
+ }
2646
+ break;
2647
+ }
2648
+ case "directional": {
2649
+ var dirLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.DirectionalLight(light.name, new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Vector3(0, -1, 0), gltfRuntime.scene);
2650
+ var directional = light.directional;
2651
+ if (directional) {
2652
+ dirLight.diffuse = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Color3.FromArray(directional.color || [1, 1, 1]);
2653
+ }
2654
+ break;
2655
+ }
2656
+ case "spot": {
2657
+ var spot = light.spot;
2658
+ if (spot) {
2659
+ var spotLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.SpotLight(light.name, new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Vector3(0, 10, 0), new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Vector3(0, -1, 0), spot.fallOffAngle || Math.PI, spot.fallOffExponent || 0.0, gltfRuntime.scene);
2660
+ spotLight.diffuse = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Color3.FromArray(spot.color || [1, 1, 1]);
2661
+ }
2662
+ break;
2663
+ }
2664
+ default:
2665
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Tools.Warn('GLTF Material Common extension: light type "' + light.type + "” not supported");
2666
+ break;
2667
+ }
2668
+ }
2669
+ }
2670
+ return false;
2671
+ };
2672
+ GLTFMaterialsCommonExtension.prototype.loadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
2673
+ var material = gltfRuntime.materials[id];
2674
+ if (!material || !material.extensions) {
2675
+ return false;
2676
+ }
2677
+ var extension = material.extensions[this.name];
2678
+ if (!extension) {
2679
+ return false;
2680
+ }
2681
+ var standardMaterial = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.StandardMaterial(id, gltfRuntime.scene);
2682
+ standardMaterial.sideOrientation = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Material.CounterClockWiseSideOrientation;
2683
+ if (extension.technique === "CONSTANT") {
2684
+ standardMaterial.disableLighting = true;
2685
+ }
2686
+ standardMaterial.backFaceCulling = extension.doubleSided === undefined ? false : !extension.doubleSided;
2687
+ standardMaterial.alpha = extension.values.transparency === undefined ? 1.0 : extension.values.transparency;
2688
+ standardMaterial.specularPower = extension.values.shininess === undefined ? 0.0 : extension.values.shininess;
2689
+ // Ambient
2690
+ if (typeof extension.values.ambient === "string") {
2691
+ this._loadTexture(gltfRuntime, extension.values.ambient, standardMaterial, "ambientTexture", onError);
2692
+ }
2693
+ else {
2694
+ standardMaterial.ambientColor = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Color3.FromArray(extension.values.ambient || [0, 0, 0]);
2695
+ }
2696
+ // Diffuse
2697
+ if (typeof extension.values.diffuse === "string") {
2698
+ this._loadTexture(gltfRuntime, extension.values.diffuse, standardMaterial, "diffuseTexture", onError);
2699
+ }
2700
+ else {
2701
+ standardMaterial.diffuseColor = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Color3.FromArray(extension.values.diffuse || [0, 0, 0]);
2702
+ }
2703
+ // Emission
2704
+ if (typeof extension.values.emission === "string") {
2705
+ this._loadTexture(gltfRuntime, extension.values.emission, standardMaterial, "emissiveTexture", onError);
2706
+ }
2707
+ else {
2708
+ standardMaterial.emissiveColor = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Color3.FromArray(extension.values.emission || [0, 0, 0]);
2709
+ }
2710
+ // Specular
2711
+ if (typeof extension.values.specular === "string") {
2712
+ this._loadTexture(gltfRuntime, extension.values.specular, standardMaterial, "specularTexture", onError);
2713
+ }
2714
+ else {
2715
+ standardMaterial.specularColor = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Color3.FromArray(extension.values.specular || [0, 0, 0]);
2716
+ }
2717
+ return true;
2718
+ };
2719
+ GLTFMaterialsCommonExtension.prototype._loadTexture = function (gltfRuntime, id, material, propertyPath, onError) {
2720
+ // Create buffer from texture url
2721
+ _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, function (buffer) {
2722
+ // Create texture from buffer
2723
+ _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, function (texture) { return (material[propertyPath] = texture); });
2724
+ }, onError);
2725
+ };
2726
+ return GLTFMaterialsCommonExtension;
2727
+ }(_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderExtension));
2728
+
2729
+ _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(new GLTFMaterialsCommonExtension());
2730
+
2731
+
2732
+ /***/ }),
2733
+
2734
+ /***/ "../../../lts/loaders/dist/glTF/1.0/index.js":
2735
+ /*!***************************************************!*\
2736
+ !*** ../../../lts/loaders/dist/glTF/1.0/index.js ***!
2737
+ \***************************************************/
2738
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2739
+
2740
+ __webpack_require__.r(__webpack_exports__);
2741
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2742
+ /* harmony export */ "EBlendingFunction": () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EBlendingFunction),
2743
+ /* harmony export */ "EComponentType": () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EComponentType),
2744
+ /* harmony export */ "ECullingType": () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.ECullingType),
2745
+ /* harmony export */ "EParameterType": () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EParameterType),
2746
+ /* harmony export */ "EShaderType": () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EShaderType),
2747
+ /* harmony export */ "ETextureFilterType": () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.ETextureFilterType),
2748
+ /* harmony export */ "ETextureFormat": () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.ETextureFormat),
2749
+ /* harmony export */ "ETextureWrapMode": () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.ETextureWrapMode),
2750
+ /* harmony export */ "GLTFBinaryExtension": () => (/* reexport safe */ _glTFBinaryExtension__WEBPACK_IMPORTED_MODULE_0__.GLTFBinaryExtension),
2751
+ /* harmony export */ "GLTFLoader": () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader),
2752
+ /* harmony export */ "GLTFLoaderBase": () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderBase),
2753
+ /* harmony export */ "GLTFLoaderExtension": () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderExtension),
2754
+ /* harmony export */ "GLTFMaterialsCommonExtension": () => (/* reexport safe */ _glTFMaterialsCommonExtension__WEBPACK_IMPORTED_MODULE_4__.GLTFMaterialsCommonExtension),
2755
+ /* harmony export */ "GLTFUtils": () => (/* reexport safe */ _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_3__.GLTFUtils)
2756
+ /* harmony export */ });
2757
+ /* harmony import */ var _glTFBinaryExtension__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFBinaryExtension */ "../../../lts/loaders/dist/glTF/1.0/glTFBinaryExtension.js");
2758
+ /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoader */ "../../../lts/loaders/dist/glTF/1.0/glTFLoader.js");
2759
+ /* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderInterfaces.js");
2760
+ /* harmony import */ var _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./glTFLoaderUtils */ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderUtils.js");
2761
+ /* harmony import */ var _glTFMaterialsCommonExtension__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./glTFMaterialsCommonExtension */ "../../../lts/loaders/dist/glTF/1.0/glTFMaterialsCommonExtension.js");
2762
+
2763
+
2764
+
2765
+
2766
+
2767
+
2768
+
2769
+ /***/ }),
2770
+
2771
+ /***/ "../../../lts/loaders/dist/glTF/glTFFileLoader.js":
2772
+ /*!********************************************************!*\
2773
+ !*** ../../../lts/loaders/dist/glTF/glTFFileLoader.js ***!
2774
+ \********************************************************/
2775
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2776
+
2777
+ __webpack_require__.r(__webpack_exports__);
2778
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2779
+ /* harmony export */ "GLTFFileLoader": () => (/* binding */ GLTFFileLoader),
2780
+ /* harmony export */ "GLTFLoaderAnimationStartMode": () => (/* binding */ GLTFLoaderAnimationStartMode),
2781
+ /* harmony export */ "GLTFLoaderCoordinateSystemMode": () => (/* binding */ GLTFLoaderCoordinateSystemMode),
2782
+ /* harmony export */ "GLTFLoaderState": () => (/* binding */ GLTFLoaderState)
2783
+ /* harmony export */ });
2784
+ /* harmony import */ var core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Misc/error */ "core/Misc/observable");
2785
+ /* harmony import */ var core_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
2786
+ /* harmony import */ var _glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFValidation */ "../../../lts/loaders/dist/glTF/glTFValidation.js");
2787
+
2788
+
2789
+
2790
+
2791
+
2792
+
2793
+
2794
+
2795
+
2796
+
2797
+ function readAsync(arrayBuffer, byteOffset, byteLength) {
2798
+ try {
2799
+ return Promise.resolve(new Uint8Array(arrayBuffer, byteOffset, byteLength));
2800
+ }
2801
+ catch (e) {
2802
+ return Promise.reject(e);
2803
+ }
2804
+ }
2805
+ /**
2806
+ * Mode that determines the coordinate system to use.
2807
+ */
2808
+ var GLTFLoaderCoordinateSystemMode;
2809
+ (function (GLTFLoaderCoordinateSystemMode) {
2810
+ /**
2811
+ * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
2812
+ */
2813
+ GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["AUTO"] = 0] = "AUTO";
2814
+ /**
2815
+ * Sets the useRightHandedSystem flag on the scene.
2816
+ */
2817
+ GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["FORCE_RIGHT_HANDED"] = 1] = "FORCE_RIGHT_HANDED";
2818
+ })(GLTFLoaderCoordinateSystemMode || (GLTFLoaderCoordinateSystemMode = {}));
2819
+ /**
2820
+ * Mode that determines what animations will start.
2821
+ */
2822
+ var GLTFLoaderAnimationStartMode;
2823
+ (function (GLTFLoaderAnimationStartMode) {
2824
+ /**
2825
+ * No animation will start.
2826
+ */
2827
+ GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["NONE"] = 0] = "NONE";
2828
+ /**
2829
+ * The first animation will start.
2830
+ */
2831
+ GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["FIRST"] = 1] = "FIRST";
2832
+ /**
2833
+ * All animations will start.
2834
+ */
2835
+ GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["ALL"] = 2] = "ALL";
2836
+ })(GLTFLoaderAnimationStartMode || (GLTFLoaderAnimationStartMode = {}));
2837
+ /**
2838
+ * Loader state.
2839
+ */
2840
+ var GLTFLoaderState;
2841
+ (function (GLTFLoaderState) {
2842
+ /**
2843
+ * The asset is loading.
2844
+ */
2845
+ GLTFLoaderState[GLTFLoaderState["LOADING"] = 0] = "LOADING";
2846
+ /**
2847
+ * The asset is ready for rendering.
2848
+ */
2849
+ GLTFLoaderState[GLTFLoaderState["READY"] = 1] = "READY";
2850
+ /**
2851
+ * The asset is completely loaded.
2852
+ */
2853
+ GLTFLoaderState[GLTFLoaderState["COMPLETE"] = 2] = "COMPLETE";
2854
+ })(GLTFLoaderState || (GLTFLoaderState = {}));
2855
+ /**
2856
+ * File loader for loading glTF files into a scene.
2857
+ */
2858
+ var GLTFFileLoader = /** @class */ (function () {
2859
+ function GLTFFileLoader() {
2860
+ // --------------
2861
+ // Common options
2862
+ // --------------
2863
+ /**
2864
+ * Raised when the asset has been parsed
2865
+ */
2866
+ this.onParsedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
2867
+ // ----------
2868
+ // V2 options
2869
+ // ----------
2870
+ /**
2871
+ * The coordinate system mode. Defaults to AUTO.
2872
+ */
2873
+ this.coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO;
2874
+ /**
2875
+ * The animation start mode. Defaults to FIRST.
2876
+ */
2877
+ this.animationStartMode = GLTFLoaderAnimationStartMode.FIRST;
2878
+ /**
2879
+ * Defines if the loader should compile materials before raising the success callback. Defaults to false.
2880
+ */
2881
+ this.compileMaterials = false;
2882
+ /**
2883
+ * Defines if the loader should also compile materials with clip planes. Defaults to false.
2884
+ */
2885
+ this.useClipPlane = false;
2886
+ /**
2887
+ * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
2888
+ */
2889
+ this.compileShadowGenerators = false;
2890
+ /**
2891
+ * Defines if the Alpha blended materials are only applied as coverage.
2892
+ * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
2893
+ * If true, no extra effects are applied to transparent pixels.
2894
+ */
2895
+ this.transparencyAsCoverage = false;
2896
+ /**
2897
+ * Defines if the loader should use range requests when load binary glTF files from HTTP.
2898
+ * Enabling will disable offline support and glTF validator.
2899
+ * Defaults to false.
2900
+ */
2901
+ this.useRangeRequests = false;
2902
+ /**
2903
+ * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
2904
+ */
2905
+ this.createInstances = true;
2906
+ /**
2907
+ * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false.
2908
+ */
2909
+ this.alwaysComputeBoundingBox = false;
2910
+ /**
2911
+ * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
2912
+ */
2913
+ this.loadAllMaterials = false;
2914
+ /**
2915
+ * If true, load only the materials defined in the file. Defaults to false.
2916
+ */
2917
+ this.loadOnlyMaterials = false;
2918
+ /**
2919
+ * If true, do not load any materials defined in the file. Defaults to false.
2920
+ */
2921
+ this.skipMaterials = false;
2922
+ /**
2923
+ * If true, load the color (gamma encoded) textures into sRGB buffers (if supported by the GPU), which will yield more accurate results when sampling the texture. Defaults to true.
2924
+ */
2925
+ this.useSRGBBuffers = true;
2926
+ /**
2927
+ * When loading glTF animations, which are defined in seconds, target them to this FPS. Defaults to 60.
2928
+ */
2929
+ this.targetFps = 60;
2930
+ /**
2931
+ * Defines if the loader should always compute the nearest common ancestor of the skeleton joints instead of using `skin.skeleton`. Defaults to false.
2932
+ * Set this to true if loading assets with invalid `skin.skeleton` values.
2933
+ */
2934
+ this.alwaysComputeSkeletonRootNode = false;
2935
+ /**
2936
+ * Function called before loading a url referenced by the asset.
2937
+ * @param url
2938
+ */
2939
+ this.preprocessUrlAsync = function (url) { return Promise.resolve(url); };
2940
+ /**
2941
+ * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
2942
+ * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
2943
+ */
2944
+ this.onMeshLoadedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
2945
+ /**
2946
+ * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
2947
+ */
2948
+ this.onTextureLoadedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
2949
+ /**
2950
+ * Observable raised when the loader creates a material after parsing the glTF properties of the material.
2951
+ */
2952
+ this.onMaterialLoadedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
2953
+ /**
2954
+ * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
2955
+ */
2956
+ this.onCameraLoadedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
2957
+ /**
2958
+ * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
2959
+ * For assets with LODs, raised when all of the LODs are complete.
2960
+ * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
2961
+ */
2962
+ this.onCompleteObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
2963
+ /**
2964
+ * Observable raised when an error occurs.
2965
+ */
2966
+ this.onErrorObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
2967
+ /**
2968
+ * Observable raised after the loader is disposed.
2969
+ */
2970
+ this.onDisposeObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
2971
+ /**
2972
+ * Observable raised after a loader extension is created.
2973
+ * Set additional options for a loader extension in this event.
2974
+ */
2975
+ this.onExtensionLoadedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
2976
+ /**
2977
+ * Defines if the loader should validate the asset.
2978
+ */
2979
+ this.validate = false;
2980
+ /**
2981
+ * Observable raised after validation when validate is set to true. The event data is the result of the validation.
2982
+ */
2983
+ this.onValidatedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
2984
+ this._loader = null;
2985
+ this._state = null;
2986
+ this._requests = new Array();
2987
+ /**
2988
+ * Name of the loader ("gltf")
2989
+ */
2990
+ this.name = "gltf";
2991
+ /** @hidden */
2992
+ this.extensions = {
2993
+ ".gltf": { isBinary: false },
2994
+ ".glb": { isBinary: true },
2995
+ };
2996
+ /**
2997
+ * Observable raised when the loader state changes.
2998
+ */
2999
+ this.onLoaderStateChangedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
3000
+ this._logIndentLevel = 0;
3001
+ this._loggingEnabled = false;
3002
+ /** @hidden */
3003
+ this._log = this._logDisabled;
3004
+ this._capturePerformanceCounters = false;
3005
+ /** @hidden */
3006
+ this._startPerformanceCounter = this._startPerformanceCounterDisabled;
3007
+ /** @hidden */
3008
+ this._endPerformanceCounter = this._endPerformanceCounterDisabled;
3009
+ }
3010
+ Object.defineProperty(GLTFFileLoader.prototype, "onParsed", {
3011
+ /**
3012
+ * Raised when the asset has been parsed
3013
+ */
3014
+ set: function (callback) {
3015
+ if (this._onParsedObserver) {
3016
+ this.onParsedObservable.remove(this._onParsedObserver);
3017
+ }
3018
+ this._onParsedObserver = this.onParsedObservable.add(callback);
3019
+ },
3020
+ enumerable: false,
3021
+ configurable: true
3022
+ });
3023
+ Object.defineProperty(GLTFFileLoader.prototype, "onMeshLoaded", {
3024
+ /**
3025
+ * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
3026
+ * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
3027
+ */
3028
+ set: function (callback) {
3029
+ if (this._onMeshLoadedObserver) {
3030
+ this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver);
3031
+ }
3032
+ this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(callback);
3033
+ },
3034
+ enumerable: false,
3035
+ configurable: true
3036
+ });
3037
+ Object.defineProperty(GLTFFileLoader.prototype, "onTextureLoaded", {
3038
+ /**
3039
+ * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
3040
+ */
3041
+ set: function (callback) {
3042
+ if (this._onTextureLoadedObserver) {
3043
+ this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver);
3044
+ }
3045
+ this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(callback);
3046
+ },
3047
+ enumerable: false,
3048
+ configurable: true
3049
+ });
3050
+ Object.defineProperty(GLTFFileLoader.prototype, "onMaterialLoaded", {
3051
+ /**
3052
+ * Callback raised when the loader creates a material after parsing the glTF properties of the material.
3053
+ */
3054
+ set: function (callback) {
3055
+ if (this._onMaterialLoadedObserver) {
3056
+ this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver);
3057
+ }
3058
+ this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(callback);
3059
+ },
3060
+ enumerable: false,
3061
+ configurable: true
3062
+ });
3063
+ Object.defineProperty(GLTFFileLoader.prototype, "onCameraLoaded", {
3064
+ /**
3065
+ * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
3066
+ */
3067
+ set: function (callback) {
3068
+ if (this._onCameraLoadedObserver) {
3069
+ this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver);
3070
+ }
3071
+ this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(callback);
3072
+ },
3073
+ enumerable: false,
3074
+ configurable: true
3075
+ });
3076
+ Object.defineProperty(GLTFFileLoader.prototype, "onComplete", {
3077
+ /**
3078
+ * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
3079
+ * For assets with LODs, raised when all of the LODs are complete.
3080
+ * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
3081
+ */
3082
+ set: function (callback) {
3083
+ if (this._onCompleteObserver) {
3084
+ this.onCompleteObservable.remove(this._onCompleteObserver);
3085
+ }
3086
+ this._onCompleteObserver = this.onCompleteObservable.add(callback);
3087
+ },
3088
+ enumerable: false,
3089
+ configurable: true
3090
+ });
3091
+ Object.defineProperty(GLTFFileLoader.prototype, "onError", {
3092
+ /**
3093
+ * Callback raised when an error occurs.
3094
+ */
3095
+ set: function (callback) {
3096
+ if (this._onErrorObserver) {
3097
+ this.onErrorObservable.remove(this._onErrorObserver);
3098
+ }
3099
+ this._onErrorObserver = this.onErrorObservable.add(callback);
3100
+ },
3101
+ enumerable: false,
3102
+ configurable: true
3103
+ });
3104
+ Object.defineProperty(GLTFFileLoader.prototype, "onDispose", {
3105
+ /**
3106
+ * Callback raised after the loader is disposed.
3107
+ */
3108
+ set: function (callback) {
3109
+ if (this._onDisposeObserver) {
3110
+ this.onDisposeObservable.remove(this._onDisposeObserver);
3111
+ }
3112
+ this._onDisposeObserver = this.onDisposeObservable.add(callback);
3113
+ },
3114
+ enumerable: false,
3115
+ configurable: true
3116
+ });
3117
+ Object.defineProperty(GLTFFileLoader.prototype, "onExtensionLoaded", {
3118
+ /**
3119
+ * Callback raised after a loader extension is created.
3120
+ */
3121
+ set: function (callback) {
3122
+ if (this._onExtensionLoadedObserver) {
3123
+ this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver);
3124
+ }
3125
+ this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(callback);
3126
+ },
3127
+ enumerable: false,
3128
+ configurable: true
3129
+ });
3130
+ Object.defineProperty(GLTFFileLoader.prototype, "loggingEnabled", {
3131
+ /**
3132
+ * Defines if the loader logging is enabled.
3133
+ */
3134
+ get: function () {
3135
+ return this._loggingEnabled;
3136
+ },
3137
+ set: function (value) {
3138
+ if (this._loggingEnabled === value) {
3139
+ return;
3140
+ }
3141
+ this._loggingEnabled = value;
3142
+ if (this._loggingEnabled) {
3143
+ this._log = this._logEnabled;
3144
+ }
3145
+ else {
3146
+ this._log = this._logDisabled;
3147
+ }
3148
+ },
3149
+ enumerable: false,
3150
+ configurable: true
3151
+ });
3152
+ Object.defineProperty(GLTFFileLoader.prototype, "capturePerformanceCounters", {
3153
+ /**
3154
+ * Defines if the loader should capture performance counters.
3155
+ */
3156
+ get: function () {
3157
+ return this._capturePerformanceCounters;
3158
+ },
3159
+ set: function (value) {
3160
+ if (this._capturePerformanceCounters === value) {
3161
+ return;
3162
+ }
3163
+ this._capturePerformanceCounters = value;
3164
+ if (this._capturePerformanceCounters) {
3165
+ this._startPerformanceCounter = this._startPerformanceCounterEnabled;
3166
+ this._endPerformanceCounter = this._endPerformanceCounterEnabled;
3167
+ }
3168
+ else {
3169
+ this._startPerformanceCounter = this._startPerformanceCounterDisabled;
3170
+ this._endPerformanceCounter = this._endPerformanceCounterDisabled;
3171
+ }
3172
+ },
3173
+ enumerable: false,
3174
+ configurable: true
3175
+ });
3176
+ Object.defineProperty(GLTFFileLoader.prototype, "onValidated", {
3177
+ /**
3178
+ * Callback raised after a loader extension is created.
3179
+ */
3180
+ set: function (callback) {
3181
+ if (this._onValidatedObserver) {
3182
+ this.onValidatedObservable.remove(this._onValidatedObserver);
3183
+ }
3184
+ this._onValidatedObserver = this.onValidatedObservable.add(callback);
3185
+ },
3186
+ enumerable: false,
3187
+ configurable: true
3188
+ });
3189
+ /**
3190
+ * Disposes the loader, releases resources during load, and cancels any outstanding requests.
3191
+ */
3192
+ GLTFFileLoader.prototype.dispose = function () {
3193
+ if (this._loader) {
3194
+ this._loader.dispose();
3195
+ this._loader = null;
3196
+ }
3197
+ for (var _i = 0, _a = this._requests; _i < _a.length; _i++) {
3198
+ var request = _a[_i];
3199
+ request.abort();
3200
+ }
3201
+ this._requests.length = 0;
3202
+ delete this._progressCallback;
3203
+ this.preprocessUrlAsync = function (url) { return Promise.resolve(url); };
3204
+ this.onMeshLoadedObservable.clear();
3205
+ this.onTextureLoadedObservable.clear();
3206
+ this.onMaterialLoadedObservable.clear();
3207
+ this.onCameraLoadedObservable.clear();
3208
+ this.onCompleteObservable.clear();
3209
+ this.onExtensionLoadedObservable.clear();
3210
+ this.onDisposeObservable.notifyObservers(undefined);
3211
+ this.onDisposeObservable.clear();
3212
+ };
3213
+ /**
3214
+ * @param scene
3215
+ * @param fileOrUrl
3216
+ * @param onSuccess
3217
+ * @param onProgress
3218
+ * @param useArrayBuffer
3219
+ * @param onError
3220
+ * @hidden
3221
+ */
3222
+ GLTFFileLoader.prototype.loadFile = function (scene, fileOrUrl, onSuccess, onProgress, useArrayBuffer, onError) {
3223
+ var _this = this;
3224
+ this._progressCallback = onProgress;
3225
+ var rootUrl = fileOrUrl.name ? "file:" : core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.GetFolderPath(fileOrUrl);
3226
+ var fileName = fileOrUrl.name || core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.GetFilename(fileOrUrl);
3227
+ if (useArrayBuffer) {
3228
+ if (this.useRangeRequests) {
3229
+ if (this.validate) {
3230
+ core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("glTF validation is not supported when range requests are enabled");
3231
+ }
3232
+ var fileRequest_1 = {
3233
+ abort: function () { },
3234
+ onCompleteObservable: new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(),
3235
+ };
3236
+ var dataBuffer = {
3237
+ readAsync: function (byteOffset, byteLength) {
3238
+ return new Promise(function (resolve, reject) {
3239
+ _this._loadFile(scene, fileOrUrl, function (data) {
3240
+ resolve(new Uint8Array(data));
3241
+ }, true, function (error) {
3242
+ reject(error);
3243
+ }, function (webRequest) {
3244
+ webRequest.setRequestHeader("Range", "bytes=".concat(byteOffset, "-").concat(byteOffset + byteLength - 1));
3245
+ });
3246
+ });
3247
+ },
3248
+ byteLength: 0,
3249
+ };
3250
+ this._unpackBinaryAsync(new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader(dataBuffer)).then(function (loaderData) {
3251
+ fileRequest_1.onCompleteObservable.notifyObservers(fileRequest_1);
3252
+ onSuccess(loaderData);
3253
+ }, onError ? function (error) { return onError(undefined, error); } : undefined);
3254
+ return fileRequest_1;
3255
+ }
3256
+ return this._loadFile(scene, fileOrUrl, function (data) {
3257
+ _this._validate(scene, data, rootUrl, fileName);
3258
+ _this._unpackBinaryAsync(new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader({
3259
+ readAsync: function (byteOffset, byteLength) { return readAsync(data, byteOffset, byteLength); },
3260
+ byteLength: data.byteLength,
3261
+ })).then(function (loaderData) {
3262
+ onSuccess(loaderData);
3263
+ }, onError ? function (error) { return onError(undefined, error); } : undefined);
3264
+ }, true, onError);
3265
+ }
3266
+ return this._loadFile(scene, fileOrUrl, function (data) {
3267
+ _this._validate(scene, data, rootUrl, fileName);
3268
+ onSuccess({ json: _this._parseJson(data) });
3269
+ }, useArrayBuffer, onError);
3270
+ };
3271
+ /**
3272
+ * @param meshesNames
3273
+ * @param scene
3274
+ * @param data
3275
+ * @param rootUrl
3276
+ * @param onProgress
3277
+ * @param fileName
3278
+ * @hidden
3279
+ */
3280
+ GLTFFileLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress, fileName) {
3281
+ var _this = this;
3282
+ return Promise.resolve().then(function () {
3283
+ _this.onParsedObservable.notifyObservers(data);
3284
+ _this.onParsedObservable.clear();
3285
+ _this._log("Loading ".concat(fileName || ""));
3286
+ _this._loader = _this._getLoader(data);
3287
+ return _this._loader.importMeshAsync(meshesNames, scene, null, data, rootUrl, onProgress, fileName);
3288
+ });
3289
+ };
3290
+ /**
3291
+ * @param scene
3292
+ * @param data
3293
+ * @param rootUrl
3294
+ * @param onProgress
3295
+ * @param fileName
3296
+ * @hidden
3297
+ */
3298
+ GLTFFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) {
3299
+ var _this = this;
3300
+ return Promise.resolve().then(function () {
3301
+ _this.onParsedObservable.notifyObservers(data);
3302
+ _this.onParsedObservable.clear();
3303
+ _this._log("Loading ".concat(fileName || ""));
3304
+ _this._loader = _this._getLoader(data);
3305
+ return _this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName);
3306
+ });
3307
+ };
3308
+ /**
3309
+ * @param scene
3310
+ * @param data
3311
+ * @param rootUrl
3312
+ * @param onProgress
3313
+ * @param fileName
3314
+ * @hidden
3315
+ */
3316
+ GLTFFileLoader.prototype.loadAssetContainerAsync = function (scene, data, rootUrl, onProgress, fileName) {
3317
+ var _this = this;
3318
+ return Promise.resolve().then(function () {
3319
+ _this.onParsedObservable.notifyObservers(data);
3320
+ _this.onParsedObservable.clear();
3321
+ _this._log("Loading ".concat(fileName || ""));
3322
+ _this._loader = _this._getLoader(data);
3323
+ // Prepare the asset container.
3324
+ var container = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.AssetContainer(scene);
3325
+ // Get materials/textures when loading to add to container
3326
+ var materials = [];
3327
+ _this.onMaterialLoadedObservable.add(function (material) {
3328
+ materials.push(material);
3329
+ });
3330
+ var textures = [];
3331
+ _this.onTextureLoadedObservable.add(function (texture) {
3332
+ textures.push(texture);
3333
+ });
3334
+ var cameras = [];
3335
+ _this.onCameraLoadedObservable.add(function (camera) {
3336
+ cameras.push(camera);
3337
+ });
3338
+ return _this._loader.importMeshAsync(null, scene, container, data, rootUrl, onProgress, fileName).then(function (result) {
3339
+ Array.prototype.push.apply(container.geometries, result.geometries);
3340
+ Array.prototype.push.apply(container.meshes, result.meshes);
3341
+ Array.prototype.push.apply(container.particleSystems, result.particleSystems);
3342
+ Array.prototype.push.apply(container.skeletons, result.skeletons);
3343
+ Array.prototype.push.apply(container.animationGroups, result.animationGroups);
3344
+ Array.prototype.push.apply(container.materials, materials);
3345
+ Array.prototype.push.apply(container.textures, textures);
3346
+ Array.prototype.push.apply(container.lights, result.lights);
3347
+ Array.prototype.push.apply(container.transformNodes, result.transformNodes);
3348
+ Array.prototype.push.apply(container.cameras, cameras);
3349
+ return container;
3350
+ });
3351
+ });
3352
+ };
3353
+ /**
3354
+ * @param data
3355
+ * @hidden
3356
+ */
3357
+ GLTFFileLoader.prototype.canDirectLoad = function (data) {
3358
+ return ((data.indexOf("asset") !== -1 && data.indexOf("version") !== -1) ||
3359
+ core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(data, "data:base64," + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.
3360
+ core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(data, "data:;base64," + GLTFFileLoader._MagicBase64Encoded) ||
3361
+ core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(data, "data:application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) ||
3362
+ core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(data, "data:model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded));
3363
+ };
3364
+ /**
3365
+ * @param scene
3366
+ * @param data
3367
+ * @hidden
3368
+ */
3369
+ GLTFFileLoader.prototype.directLoad = function (scene, data) {
3370
+ if (core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(data, "base64," + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.
3371
+ core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(data, ";base64," + GLTFFileLoader._MagicBase64Encoded) ||
3372
+ core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(data, "application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) ||
3373
+ core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(data, "model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded)) {
3374
+ var arrayBuffer_1 = (0,core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DecodeBase64UrlToBinary)(data);
3375
+ this._validate(scene, arrayBuffer_1);
3376
+ return this._unpackBinaryAsync(new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader({
3377
+ readAsync: function (byteOffset, byteLength) { return readAsync(arrayBuffer_1, byteOffset, byteLength); },
3378
+ byteLength: arrayBuffer_1.byteLength,
3379
+ }));
3380
+ }
3381
+ this._validate(scene, data);
3382
+ return Promise.resolve({ json: this._parseJson(data) });
3383
+ };
3384
+ /** @hidden */
3385
+ GLTFFileLoader.prototype.createPlugin = function () {
3386
+ return new GLTFFileLoader();
3387
+ };
3388
+ Object.defineProperty(GLTFFileLoader.prototype, "loaderState", {
3389
+ /**
3390
+ * The loader state or null if the loader is not active.
3391
+ */
3392
+ get: function () {
3393
+ return this._state;
3394
+ },
3395
+ enumerable: false,
3396
+ configurable: true
3397
+ });
3398
+ /**
3399
+ * Returns a promise that resolves when the asset is completely loaded.
3400
+ * @returns a promise that resolves when the asset is completely loaded.
3401
+ */
3402
+ GLTFFileLoader.prototype.whenCompleteAsync = function () {
3403
+ var _this = this;
3404
+ return new Promise(function (resolve, reject) {
3405
+ _this.onCompleteObservable.addOnce(function () {
3406
+ resolve();
3407
+ });
3408
+ _this.onErrorObservable.addOnce(function (reason) {
3409
+ reject(reason);
3410
+ });
3411
+ });
3412
+ };
3413
+ /**
3414
+ * @param state
3415
+ * @hidden
3416
+ */
3417
+ GLTFFileLoader.prototype._setState = function (state) {
3418
+ if (this._state === state) {
3419
+ return;
3420
+ }
3421
+ this._state = state;
3422
+ this.onLoaderStateChangedObservable.notifyObservers(this._state);
3423
+ this._log(GLTFLoaderState[this._state]);
3424
+ };
3425
+ /**
3426
+ * @param scene
3427
+ * @param fileOrUrl
3428
+ * @param onSuccess
3429
+ * @param useArrayBuffer
3430
+ * @param onError
3431
+ * @param onOpened
3432
+ * @hidden
3433
+ */
3434
+ GLTFFileLoader.prototype._loadFile = function (scene, fileOrUrl, onSuccess, useArrayBuffer, onError, onOpened) {
3435
+ var _this = this;
3436
+ var request = scene._loadFile(fileOrUrl, onSuccess, function (event) {
3437
+ _this._onProgress(event, request);
3438
+ }, true, useArrayBuffer, onError, onOpened);
3439
+ request.onCompleteObservable.add(function (request) {
3440
+ _this._requests.splice(_this._requests.indexOf(request), 1);
3441
+ });
3442
+ this._requests.push(request);
3443
+ return request;
3444
+ };
3445
+ GLTFFileLoader.prototype._onProgress = function (event, request) {
3446
+ if (!this._progressCallback) {
3447
+ return;
3448
+ }
3449
+ request._lengthComputable = event.lengthComputable;
3450
+ request._loaded = event.loaded;
3451
+ request._total = event.total;
3452
+ var lengthComputable = true;
3453
+ var loaded = 0;
3454
+ var total = 0;
3455
+ for (var _i = 0, _a = this._requests; _i < _a.length; _i++) {
3456
+ var request_1 = _a[_i];
3457
+ if (request_1._lengthComputable === undefined || request_1._loaded === undefined || request_1._total === undefined) {
3458
+ return;
3459
+ }
3460
+ lengthComputable = lengthComputable && request_1._lengthComputable;
3461
+ loaded += request_1._loaded;
3462
+ total += request_1._total;
3463
+ }
3464
+ this._progressCallback({
3465
+ lengthComputable: lengthComputable,
3466
+ loaded: loaded,
3467
+ total: lengthComputable ? total : 0,
3468
+ });
3469
+ };
3470
+ GLTFFileLoader.prototype._validate = function (scene, data, rootUrl, fileName) {
3471
+ var _this = this;
3472
+ if (rootUrl === void 0) { rootUrl = ""; }
3473
+ if (fileName === void 0) { fileName = ""; }
3474
+ if (!this.validate) {
3475
+ return;
3476
+ }
3477
+ this._startPerformanceCounter("Validate JSON");
3478
+ _glTFValidation__WEBPACK_IMPORTED_MODULE_1__.GLTFValidation.ValidateAsync(data, rootUrl, fileName, function (uri) {
3479
+ return _this.preprocessUrlAsync(rootUrl + uri).then(function (url) { return scene._loadFileAsync(url, undefined, true, true); });
3480
+ }).then(function (result) {
3481
+ _this._endPerformanceCounter("Validate JSON");
3482
+ _this.onValidatedObservable.notifyObservers(result);
3483
+ _this.onValidatedObservable.clear();
3484
+ }, function (reason) {
3485
+ _this._endPerformanceCounter("Validate JSON");
3486
+ core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Failed to validate: ".concat(reason.message));
3487
+ _this.onValidatedObservable.clear();
3488
+ });
3489
+ };
3490
+ GLTFFileLoader.prototype._getLoader = function (loaderData) {
3491
+ var asset = loaderData.json.asset || {};
3492
+ this._log("Asset version: ".concat(asset.version));
3493
+ asset.minVersion && this._log("Asset minimum version: ".concat(asset.minVersion));
3494
+ asset.generator && this._log("Asset generator: ".concat(asset.generator));
3495
+ var version = GLTFFileLoader._parseVersion(asset.version);
3496
+ if (!version) {
3497
+ throw new Error("Invalid version: " + asset.version);
3498
+ }
3499
+ if (asset.minVersion !== undefined) {
3500
+ var minVersion = GLTFFileLoader._parseVersion(asset.minVersion);
3501
+ if (!minVersion) {
3502
+ throw new Error("Invalid minimum version: " + asset.minVersion);
3503
+ }
3504
+ if (GLTFFileLoader._compareVersion(minVersion, { major: 2, minor: 0 }) > 0) {
3505
+ throw new Error("Incompatible minimum version: " + asset.minVersion);
3506
+ }
3507
+ }
3508
+ var createLoaders = {
3509
+ 1: GLTFFileLoader._CreateGLTF1Loader,
3510
+ 2: GLTFFileLoader._CreateGLTF2Loader,
3511
+ };
3512
+ var createLoader = createLoaders[version.major];
3513
+ if (!createLoader) {
3514
+ throw new Error("Unsupported version: " + asset.version);
3515
+ }
3516
+ return createLoader(this);
3517
+ };
3518
+ GLTFFileLoader.prototype._parseJson = function (json) {
3519
+ this._startPerformanceCounter("Parse JSON");
3520
+ this._log("JSON length: ".concat(json.length));
3521
+ var parsed = JSON.parse(json);
3522
+ this._endPerformanceCounter("Parse JSON");
3523
+ return parsed;
3524
+ };
3525
+ GLTFFileLoader.prototype._unpackBinaryAsync = function (dataReader) {
3526
+ var _this = this;
3527
+ this._startPerformanceCounter("Unpack Binary");
3528
+ // Read magic + version + length + json length + json format
3529
+ return dataReader.loadAsync(20).then(function () {
3530
+ var Binary = {
3531
+ Magic: 0x46546c67,
3532
+ };
3533
+ var magic = dataReader.readUint32();
3534
+ if (magic !== Binary.Magic) {
3535
+ throw new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.RuntimeError("Unexpected magic: " + magic, core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.ErrorCodes.GLTFLoaderUnexpectedMagicError);
3536
+ }
3537
+ var version = dataReader.readUint32();
3538
+ if (_this.loggingEnabled) {
3539
+ _this._log("Binary version: ".concat(version));
3540
+ }
3541
+ var length = dataReader.readUint32();
3542
+ if (dataReader.buffer.byteLength !== 0 && length !== dataReader.buffer.byteLength) {
3543
+ throw new Error("Length in header does not match actual data length: ".concat(length, " != ").concat(dataReader.buffer.byteLength));
3544
+ }
3545
+ var unpacked;
3546
+ switch (version) {
3547
+ case 1: {
3548
+ unpacked = _this._unpackBinaryV1Async(dataReader, length);
3549
+ break;
3550
+ }
3551
+ case 2: {
3552
+ unpacked = _this._unpackBinaryV2Async(dataReader, length);
3553
+ break;
3554
+ }
3555
+ default: {
3556
+ throw new Error("Unsupported version: " + version);
3557
+ }
3558
+ }
3559
+ _this._endPerformanceCounter("Unpack Binary");
3560
+ return unpacked;
3561
+ });
3562
+ };
3563
+ GLTFFileLoader.prototype._unpackBinaryV1Async = function (dataReader, length) {
3564
+ var ContentFormat = {
3565
+ JSON: 0,
3566
+ };
3567
+ var contentLength = dataReader.readUint32();
3568
+ var contentFormat = dataReader.readUint32();
3569
+ if (contentFormat !== ContentFormat.JSON) {
3570
+ throw new Error("Unexpected content format: ".concat(contentFormat));
3571
+ }
3572
+ var bodyLength = length - dataReader.byteOffset;
3573
+ var data = { json: this._parseJson(dataReader.readString(contentLength)), bin: null };
3574
+ if (bodyLength !== 0) {
3575
+ var startByteOffset_1 = dataReader.byteOffset;
3576
+ data.bin = {
3577
+ readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_1 + byteOffset, byteLength); },
3578
+ byteLength: bodyLength,
3579
+ };
3580
+ }
3581
+ return Promise.resolve(data);
3582
+ };
3583
+ GLTFFileLoader.prototype._unpackBinaryV2Async = function (dataReader, length) {
3584
+ var _this = this;
3585
+ var ChunkFormat = {
3586
+ JSON: 0x4e4f534a,
3587
+ BIN: 0x004e4942,
3588
+ };
3589
+ // Read the JSON chunk header.
3590
+ var chunkLength = dataReader.readUint32();
3591
+ var chunkFormat = dataReader.readUint32();
3592
+ if (chunkFormat !== ChunkFormat.JSON) {
3593
+ throw new Error("First chunk format is not JSON");
3594
+ }
3595
+ // Bail if there are no other chunks.
3596
+ if (dataReader.byteOffset + chunkLength === length) {
3597
+ return dataReader.loadAsync(chunkLength).then(function () {
3598
+ return { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null };
3599
+ });
3600
+ }
3601
+ // Read the JSON chunk and the length and type of the next chunk.
3602
+ return dataReader.loadAsync(chunkLength + 8).then(function () {
3603
+ var data = { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null };
3604
+ var readAsync = function () {
3605
+ var chunkLength = dataReader.readUint32();
3606
+ var chunkFormat = dataReader.readUint32();
3607
+ switch (chunkFormat) {
3608
+ case ChunkFormat.JSON: {
3609
+ throw new Error("Unexpected JSON chunk");
3610
+ }
3611
+ case ChunkFormat.BIN: {
3612
+ var startByteOffset_2 = dataReader.byteOffset;
3613
+ data.bin = {
3614
+ readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_2 + byteOffset, byteLength); },
3615
+ byteLength: chunkLength,
3616
+ };
3617
+ dataReader.skipBytes(chunkLength);
3618
+ break;
3619
+ }
3620
+ default: {
3621
+ // ignore unrecognized chunkFormat
3622
+ dataReader.skipBytes(chunkLength);
3623
+ break;
3624
+ }
3625
+ }
3626
+ if (dataReader.byteOffset !== length) {
3627
+ return dataReader.loadAsync(8).then(readAsync);
3628
+ }
3629
+ return Promise.resolve(data);
3630
+ };
3631
+ return readAsync();
3632
+ });
3633
+ };
3634
+ GLTFFileLoader._parseVersion = function (version) {
3635
+ if (version === "1.0" || version === "1.0.1") {
3636
+ return {
3637
+ major: 1,
3638
+ minor: 0,
3639
+ };
3640
+ }
3641
+ var match = (version + "").match(/^(\d+)\.(\d+)/);
3642
+ if (!match) {
3643
+ return null;
3644
+ }
3645
+ return {
3646
+ major: parseInt(match[1]),
3647
+ minor: parseInt(match[2]),
3648
+ };
3649
+ };
3650
+ GLTFFileLoader._compareVersion = function (a, b) {
3651
+ if (a.major > b.major) {
3652
+ return 1;
3653
+ }
3654
+ if (a.major < b.major) {
3655
+ return -1;
3656
+ }
3657
+ if (a.minor > b.minor) {
3658
+ return 1;
3659
+ }
3660
+ if (a.minor < b.minor) {
3661
+ return -1;
3662
+ }
3663
+ return 0;
3664
+ };
3665
+ /**
3666
+ * @param message
3667
+ * @hidden
3668
+ */
3669
+ GLTFFileLoader.prototype._logOpen = function (message) {
3670
+ this._log(message);
3671
+ this._logIndentLevel++;
3672
+ };
3673
+ /** @hidden */
3674
+ GLTFFileLoader.prototype._logClose = function () {
3675
+ --this._logIndentLevel;
3676
+ };
3677
+ GLTFFileLoader.prototype._logEnabled = function (message) {
3678
+ var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
3679
+ core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Logger.Log("".concat(spaces).concat(message));
3680
+ };
3681
+ GLTFFileLoader.prototype._logDisabled = function (message) { };
3682
+ GLTFFileLoader.prototype._startPerformanceCounterEnabled = function (counterName) {
3683
+ core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.StartPerformanceCounter(counterName);
3684
+ };
3685
+ GLTFFileLoader.prototype._startPerformanceCounterDisabled = function (counterName) { };
3686
+ GLTFFileLoader.prototype._endPerformanceCounterEnabled = function (counterName) {
3687
+ core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.EndPerformanceCounter(counterName);
3688
+ };
3689
+ GLTFFileLoader.prototype._endPerformanceCounterDisabled = function (counterName) { };
3690
+ // ----------
3691
+ // V1 options
3692
+ // ----------
3693
+ /**
3694
+ * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.
3695
+ * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
3696
+ * Defaults to true.
3697
+ * @hidden
3698
+ */
3699
+ GLTFFileLoader.IncrementalLoading = true;
3700
+ /**
3701
+ * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
3702
+ * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
3703
+ * @hidden
3704
+ */
3705
+ GLTFFileLoader.HomogeneousCoordinates = false;
3706
+ GLTFFileLoader._MagicBase64Encoded = "Z2xURg"; // "glTF" base64 encoded (without the quotes!)
3707
+ GLTFFileLoader._logSpaces = " ";
3708
+ return GLTFFileLoader;
3709
+ }());
3710
+
3711
+ if (core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.SceneLoader) {
3712
+ core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.SceneLoader.RegisterPlugin(new GLTFFileLoader());
3713
+ }
3714
+
3715
+
3716
+ /***/ }),
3717
+
3718
+ /***/ "../../../lts/loaders/dist/glTF/glTFValidation.js":
3719
+ /*!********************************************************!*\
3720
+ !*** ../../../lts/loaders/dist/glTF/glTFValidation.js ***!
3721
+ \********************************************************/
3722
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3723
+
3724
+ __webpack_require__.r(__webpack_exports__);
3725
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3726
+ /* harmony export */ "GLTFValidation": () => (/* binding */ GLTFValidation)
3727
+ /* harmony export */ });
3728
+ /* harmony import */ var core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Misc/tools */ "core/Misc/observable");
3729
+ /* harmony import */ var core_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__);
3730
+
3731
+ function validateAsync(data, rootUrl, fileName, getExternalResource) {
3732
+ var options = {
3733
+ externalResourceFunction: function (uri) { return getExternalResource(uri).then(function (value) { return new Uint8Array(value); }); },
3734
+ };
3735
+ if (fileName) {
3736
+ options.uri = rootUrl === "file:" ? fileName : rootUrl + fileName;
3737
+ }
3738
+ return data instanceof ArrayBuffer ? GLTFValidator.validateBytes(new Uint8Array(data), options) : GLTFValidator.validateString(data, options);
3739
+ }
3740
+ /**
3741
+ * The worker function that gets converted to a blob url to pass into a worker.
3742
+ */
3743
+ function workerFunc() {
3744
+ var pendingExternalResources = [];
3745
+ onmessage = function (message) {
3746
+ var data = message.data;
3747
+ switch (data.id) {
3748
+ case "init": {
3749
+ importScripts(data.url);
3750
+ break;
3751
+ }
3752
+ case "validate": {
3753
+ validateAsync(data.data, data.rootUrl, data.fileName, function (uri) {
3754
+ return new Promise(function (resolve, reject) {
3755
+ var index = pendingExternalResources.length;
3756
+ pendingExternalResources.push({ resolve: resolve, reject: reject });
3757
+ postMessage({ id: "getExternalResource", index: index, uri: uri });
3758
+ });
3759
+ }).then(function (value) {
3760
+ postMessage({ id: "validate.resolve", value: value });
3761
+ }, function (reason) {
3762
+ postMessage({ id: "validate.reject", reason: reason });
3763
+ });
3764
+ break;
3765
+ }
3766
+ case "getExternalResource.resolve": {
3767
+ pendingExternalResources[data.index].resolve(data.value);
3768
+ break;
3769
+ }
3770
+ case "getExternalResource.reject": {
3771
+ pendingExternalResources[data.index].reject(data.reason);
3772
+ break;
3773
+ }
3774
+ }
3775
+ };
3776
+ }
3777
+ /**
3778
+ * glTF validation
3779
+ */
3780
+ var GLTFValidation = /** @class */ (function () {
3781
+ function GLTFValidation() {
3782
+ }
3783
+ /**
3784
+ * Validate a glTF asset using the glTF-Validator.
3785
+ * @param data The JSON of a glTF or the array buffer of a binary glTF
3786
+ * @param rootUrl The root url for the glTF
3787
+ * @param fileName The file name for the glTF
3788
+ * @param getExternalResource The callback to get external resources for the glTF validator
3789
+ * @returns A promise that resolves with the glTF validation results once complete
3790
+ */
3791
+ GLTFValidation.ValidateAsync = function (data, rootUrl, fileName, getExternalResource) {
3792
+ var _this = this;
3793
+ if (typeof Worker === "function") {
3794
+ return new Promise(function (resolve, reject) {
3795
+ var workerContent = "".concat(validateAsync, "(").concat(workerFunc, ")()");
3796
+ var workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: "application/javascript" }));
3797
+ var worker = new Worker(workerBlobUrl);
3798
+ var onError = function (error) {
3799
+ worker.removeEventListener("error", onError);
3800
+ worker.removeEventListener("message", onMessage);
3801
+ reject(error);
3802
+ };
3803
+ var onMessage = function (message) {
3804
+ var data = message.data;
3805
+ switch (data.id) {
3806
+ case "getExternalResource": {
3807
+ getExternalResource(data.uri).then(function (value) {
3808
+ worker.postMessage({ id: "getExternalResource.resolve", index: data.index, value: value }, [value]);
3809
+ }, function (reason) {
3810
+ worker.postMessage({ id: "getExternalResource.reject", index: data.index, reason: reason });
3811
+ });
3812
+ break;
3813
+ }
3814
+ case "validate.resolve": {
3815
+ worker.removeEventListener("error", onError);
3816
+ worker.removeEventListener("message", onMessage);
3817
+ resolve(data.value);
3818
+ worker.terminate();
3819
+ break;
3820
+ }
3821
+ case "validate.reject": {
3822
+ worker.removeEventListener("error", onError);
3823
+ worker.removeEventListener("message", onMessage);
3824
+ reject(data.reason);
3825
+ worker.terminate();
3826
+ }
3827
+ }
3828
+ };
3829
+ worker.addEventListener("error", onError);
3830
+ worker.addEventListener("message", onMessage);
3831
+ worker.postMessage({ id: "init", url: _this.Configuration.url });
3832
+ worker.postMessage({ id: "validate", data: data, rootUrl: rootUrl, fileName: fileName });
3833
+ });
3834
+ }
3835
+ else {
3836
+ if (!this._LoadScriptPromise) {
3837
+ this._LoadScriptPromise = core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.LoadScriptAsync(this.Configuration.url);
3838
+ }
3839
+ return this._LoadScriptPromise.then(function () {
3840
+ return validateAsync(data, rootUrl, fileName, getExternalResource);
3841
+ });
3842
+ }
3843
+ };
3844
+ /**
3845
+ * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
3846
+ */
3847
+ GLTFValidation.Configuration = {
3848
+ url: "https://preview.babylonjs.com/gltf_validator.js",
3849
+ };
3850
+ return GLTFValidation;
3851
+ }());
3852
+
3853
+
3854
+
3855
+ /***/ }),
3856
+
3857
+ /***/ "../../../lts/loaders/dist/legacy/legacy-glTF.js":
3858
+ /*!*******************************************************!*\
3859
+ !*** ../../../lts/loaders/dist/legacy/legacy-glTF.js ***!
3860
+ \*******************************************************/
3861
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3862
+
3863
+ __webpack_require__.r(__webpack_exports__);
3864
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3865
+ /* harmony export */ "GLTFFileLoader": () => (/* reexport safe */ _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFFileLoader),
3866
+ /* harmony export */ "GLTFLoaderAnimationStartMode": () => (/* reexport safe */ _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderAnimationStartMode),
3867
+ /* harmony export */ "GLTFLoaderCoordinateSystemMode": () => (/* reexport safe */ _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderCoordinateSystemMode),
3868
+ /* harmony export */ "GLTFLoaderState": () => (/* reexport safe */ _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderState),
3869
+ /* harmony export */ "GLTFValidation": () => (/* reexport safe */ _glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__.GLTFValidation)
3870
+ /* harmony export */ });
3871
+ /* harmony import */ var _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTF/glTFFileLoader */ "../../../lts/loaders/dist/glTF/glTFFileLoader.js");
3872
+ /* harmony import */ var _glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTF/glTFValidation */ "../../../lts/loaders/dist/glTF/glTFValidation.js");
3873
+
3874
+
3875
+ /**
3876
+ * This is the entry point for the UMD module.
3877
+ * The entry point for a future ESM package should be index.ts
3878
+ */
3879
+ var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined;
3880
+ if (typeof globalObject !== "undefined") {
3881
+ globalObject.BABYLON = globalObject.BABYLON || {};
3882
+ for (var key in _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__) {
3883
+ globalObject.BABYLON[key] = _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__[key];
3884
+ }
3885
+ for (var key in _glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__) {
3886
+ globalObject.BABYLON[key] = _glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__[key];
3887
+ }
3888
+ }
3889
+
3890
+
3891
+
3892
+
3893
+ /***/ }),
3894
+
3895
+ /***/ "../../../lts/loaders/dist/legacy/legacy-glTF1.js":
3896
+ /*!********************************************************!*\
3897
+ !*** ../../../lts/loaders/dist/legacy/legacy-glTF1.js ***!
3898
+ \********************************************************/
3899
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3900
+
3901
+ __webpack_require__.r(__webpack_exports__);
3902
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3903
+ /* harmony export */ "GLTF1": () => (/* reexport module object */ _glTF_1_0_index__WEBPACK_IMPORTED_MODULE_0__)
3904
+ /* harmony export */ });
3905
+ /* harmony import */ var _glTF_1_0_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTF/1.0/index */ "../../../lts/loaders/dist/glTF/1.0/index.js");
3906
+ /* eslint-disable import/no-internal-modules */
3907
+
3908
+ /**
3909
+ * This is the entry point for the UMD module.
3910
+ * The entry point for a future ESM package should be index.ts
3911
+ */
3912
+ var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined;
3913
+ if (typeof globalObject !== "undefined") {
3914
+ globalObject.BABYLON = globalObject.BABYLON || {};
3915
+ globalObject.BABYLON.GLTF1 = globalObject.BABYLON.GLTF1 || {};
3916
+ for (var key in _glTF_1_0_index__WEBPACK_IMPORTED_MODULE_0__) {
3917
+ globalObject.BABYLON.GLTF1[key] = _glTF_1_0_index__WEBPACK_IMPORTED_MODULE_0__[key];
3918
+ }
3919
+ }
3920
+
3921
+
3922
+
3923
+ /***/ }),
3924
+
3925
+ /***/ "../../../lts/loaders/dist/legacy/legacy-glTF1FileLoader.js":
3926
+ /*!******************************************************************!*\
3927
+ !*** ../../../lts/loaders/dist/legacy/legacy-glTF1FileLoader.js ***!
3928
+ \******************************************************************/
3929
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3930
+
3931
+ __webpack_require__.r(__webpack_exports__);
3932
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3933
+ /* harmony export */ "GLTF1": () => (/* reexport safe */ _legacy_glTF1__WEBPACK_IMPORTED_MODULE_1__.GLTF1),
3934
+ /* harmony export */ "GLTFFileLoader": () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFFileLoader),
3935
+ /* harmony export */ "GLTFLoaderAnimationStartMode": () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderAnimationStartMode),
3936
+ /* harmony export */ "GLTFLoaderCoordinateSystemMode": () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderCoordinateSystemMode),
3937
+ /* harmony export */ "GLTFLoaderState": () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderState),
3938
+ /* harmony export */ "GLTFValidation": () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFValidation)
3939
+ /* harmony export */ });
3940
+ /* harmony import */ var _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./legacy-glTF */ "../../../lts/loaders/dist/legacy/legacy-glTF.js");
3941
+ /* harmony import */ var _legacy_glTF1__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./legacy-glTF1 */ "../../../lts/loaders/dist/legacy/legacy-glTF1.js");
3942
+ // eslint-disable-next-line import/export
3943
+
3944
+
3945
+
3946
+
3947
+ /***/ }),
3948
+
3949
+ /***/ "core/Misc/observable":
3950
+ /*!****************************************************************************************************!*\
3951
+ !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
3952
+ \****************************************************************************************************/
3953
+ /***/ ((module) => {
3954
+
3955
+ module.exports = __WEBPACK_EXTERNAL_MODULE_core_Misc_observable__;
3956
+
3957
+ /***/ })
3958
+
3959
+ /******/ });
3960
+ /************************************************************************/
3961
+ /******/ // The module cache
3962
+ /******/ var __webpack_module_cache__ = {};
3963
+ /******/
3964
+ /******/ // The require function
3965
+ /******/ function __webpack_require__(moduleId) {
3966
+ /******/ // Check if module is in cache
3967
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
3968
+ /******/ if (cachedModule !== undefined) {
3969
+ /******/ return cachedModule.exports;
3970
+ /******/ }
3971
+ /******/ // Create a new module (and put it into the cache)
3972
+ /******/ var module = __webpack_module_cache__[moduleId] = {
3973
+ /******/ // no module.id needed
3974
+ /******/ // no module.loaded needed
3975
+ /******/ exports: {}
3976
+ /******/ };
3977
+ /******/
3978
+ /******/ // Execute the module function
3979
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
3980
+ /******/
3981
+ /******/ // Return the exports of the module
3982
+ /******/ return module.exports;
3983
+ /******/ }
3984
+ /******/
3985
+ /************************************************************************/
3986
+ /******/ /* webpack/runtime/compat get default export */
3987
+ /******/ (() => {
3988
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
3989
+ /******/ __webpack_require__.n = (module) => {
3990
+ /******/ var getter = module && module.__esModule ?
3991
+ /******/ () => (module['default']) :
3992
+ /******/ () => (module);
3993
+ /******/ __webpack_require__.d(getter, { a: getter });
3994
+ /******/ return getter;
3995
+ /******/ };
3996
+ /******/ })();
3997
+ /******/
3998
+ /******/ /* webpack/runtime/define property getters */
3999
+ /******/ (() => {
4000
+ /******/ // define getter functions for harmony exports
4001
+ /******/ __webpack_require__.d = (exports, definition) => {
4002
+ /******/ for(var key in definition) {
4003
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
4004
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
4005
+ /******/ }
4006
+ /******/ }
4007
+ /******/ };
4008
+ /******/ })();
4009
+ /******/
4010
+ /******/ /* webpack/runtime/global */
4011
+ /******/ (() => {
4012
+ /******/ __webpack_require__.g = (function() {
4013
+ /******/ if (typeof globalThis === 'object') return globalThis;
4014
+ /******/ try {
4015
+ /******/ return this || new Function('return this')();
4016
+ /******/ } catch (e) {
4017
+ /******/ if (typeof window === 'object') return window;
4018
+ /******/ }
4019
+ /******/ })();
4020
+ /******/ })();
4021
+ /******/
4022
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
4023
+ /******/ (() => {
4024
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
4025
+ /******/ })();
4026
+ /******/
4027
+ /******/ /* webpack/runtime/make namespace object */
4028
+ /******/ (() => {
4029
+ /******/ // define __esModule on exports
4030
+ /******/ __webpack_require__.r = (exports) => {
4031
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
4032
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4033
+ /******/ }
4034
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
4035
+ /******/ };
4036
+ /******/ })();
4037
+ /******/
4038
+ /************************************************************************/
4039
+ var __webpack_exports__ = {};
4040
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
4041
+ (() => {
4042
+ /*!********************************!*\
4043
+ !*** ./src/glTF1FileLoader.ts ***!
4044
+ \********************************/
4045
+ __webpack_require__.r(__webpack_exports__);
4046
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4047
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
4048
+ /* harmony export */ "loaders": () => (/* reexport module object */ loaders_legacy_legacy_glTF1FileLoader__WEBPACK_IMPORTED_MODULE_0__)
4049
+ /* harmony export */ });
4050
+ /* harmony import */ var loaders_legacy_legacy_glTF1FileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/legacy/legacy-glTF1FileLoader */ "../../../lts/loaders/dist/legacy/legacy-glTF1FileLoader.js");
4051
+ // eslint-disable-next-line import/export
4052
+
4053
+
4054
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (loaders_legacy_legacy_glTF1FileLoader__WEBPACK_IMPORTED_MODULE_0__);
4055
+
4056
+ })();
4057
+
4058
+ __webpack_exports__ = __webpack_exports__["default"];
4059
+ /******/ return __webpack_exports__;
4060
+ /******/ })()
4061
+ ;
4062
+ });
4063
+ //# sourceMappingURL=babylon.glTF1FileLoader.js.map