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