|
@@ -450,7 +450,17 @@ var BABYLON;
|
|
|
// Loads through the babylon tools to allow fileInput search.
|
|
|
BABYLON.Tools.LoadFile(pathOfFile, onSuccess, undefined, undefined, false, function () { console.warn("Error - Unable to load " + pathOfFile); });
|
|
|
};
|
|
|
- OBJFileLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress) {
|
|
|
+ /**
|
|
|
+ * Imports one or more meshes from the loaded glTF data and adds them to the scene
|
|
|
+ * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
|
|
|
+ * @param scene the scene the meshes should be added to
|
|
|
+ * @param data the glTF data to load
|
|
|
+ * @param rootUrl root url to load from
|
|
|
+ * @param onProgress event that fires when loading progress has occured
|
|
|
+ * @param fullName Defines the FQDN of the file to load
|
|
|
+ * @returns a promise containg the loaded meshes, particles, skeletons and animations
|
|
|
+ */
|
|
|
+ OBJFileLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress, fullName) {
|
|
|
//get the meshes from OBJ file
|
|
|
return this._parseSolid(meshesNames, scene, data, rootUrl).then(function (meshes) {
|
|
|
return {
|
|
@@ -461,13 +471,31 @@ var BABYLON;
|
|
|
};
|
|
|
});
|
|
|
};
|
|
|
- OBJFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress) {
|
|
|
+ /**
|
|
|
+ * Imports all objects from the loaded glTF data and adds them to the scene
|
|
|
+ * @param scene the scene the objects should be added to
|
|
|
+ * @param data the glTF data to load
|
|
|
+ * @param rootUrl root url to load from
|
|
|
+ * @param onProgress event that fires when loading progress has occured
|
|
|
+ * @param fullName Defines the FQDN of the file to load
|
|
|
+ * @returns a promise which completes when objects have been loaded to the scene
|
|
|
+ */
|
|
|
+ OBJFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fullName) {
|
|
|
//Get the 3D model
|
|
|
return this.importMeshAsync(null, scene, data, rootUrl, onProgress).then(function () {
|
|
|
// return void
|
|
|
});
|
|
|
};
|
|
|
- OBJFileLoader.prototype.loadAssetContainerAsync = function (scene, data, rootUrl, onProgress) {
|
|
|
+ /**
|
|
|
+ * Load into an asset container.
|
|
|
+ * @param scene The scene to load into
|
|
|
+ * @param data The data to import
|
|
|
+ * @param rootUrl The root url for scene and resources
|
|
|
+ * @param onProgress The callback when the load progresses
|
|
|
+ * @param fullName Defines the FQDN of the file to load
|
|
|
+ * @returns The loaded asset container
|
|
|
+ */
|
|
|
+ OBJFileLoader.prototype.loadAssetContainerAsync = function (scene, data, rootUrl, onProgress, fullName) {
|
|
|
return this.importMeshAsync(null, scene, data, rootUrl).then(function (result) {
|
|
|
var container = new BABYLON.AssetContainer(scene);
|
|
|
result.meshes.forEach(function (mesh) { return container.meshes.push(mesh); });
|
|
@@ -1427,14 +1455,15 @@ var BABYLON;
|
|
|
* @param data the glTF data to load
|
|
|
* @param rootUrl root url to load from
|
|
|
* @param onProgress event that fires when loading progress has occured
|
|
|
+ * @param fullName Defines the FQDN of the file to load
|
|
|
* @returns a promise containg the loaded meshes, particles, skeletons and animations
|
|
|
*/
|
|
|
- GLTFFileLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress) {
|
|
|
+ GLTFFileLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress, fullName) {
|
|
|
var _this = this;
|
|
|
return Promise.resolve().then(function () {
|
|
|
var loaderData = _this._parse(data);
|
|
|
_this._loader = _this._getLoader(loaderData);
|
|
|
- return _this._loader.importMeshAsync(meshesNames, scene, loaderData, rootUrl, onProgress);
|
|
|
+ return _this._loader.importMeshAsync(meshesNames, scene, loaderData, rootUrl, onProgress, fullName);
|
|
|
});
|
|
|
};
|
|
|
/**
|
|
@@ -1443,14 +1472,15 @@ var BABYLON;
|
|
|
* @param data the glTF data to load
|
|
|
* @param rootUrl root url to load from
|
|
|
* @param onProgress event that fires when loading progress has occured
|
|
|
+ * @param fullName Defines the FQDN of the file to load
|
|
|
* @returns a promise which completes when objects have been loaded to the scene
|
|
|
*/
|
|
|
- GLTFFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress) {
|
|
|
+ GLTFFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fullName) {
|
|
|
var _this = this;
|
|
|
return Promise.resolve().then(function () {
|
|
|
var loaderData = _this._parse(data);
|
|
|
_this._loader = _this._getLoader(loaderData);
|
|
|
- return _this._loader.loadAsync(scene, loaderData, rootUrl, onProgress);
|
|
|
+ return _this._loader.loadAsync(scene, loaderData, rootUrl, onProgress, fullName);
|
|
|
});
|
|
|
};
|
|
|
/**
|
|
@@ -1459,14 +1489,15 @@ var BABYLON;
|
|
|
* @param data The data to import
|
|
|
* @param rootUrl The root url for scene and resources
|
|
|
* @param onProgress The callback when the load progresses
|
|
|
+ * @param fullName Defines the FQDN of the file to load
|
|
|
* @returns The loaded asset container
|
|
|
*/
|
|
|
- GLTFFileLoader.prototype.loadAssetContainerAsync = function (scene, data, rootUrl, onProgress) {
|
|
|
+ GLTFFileLoader.prototype.loadAssetContainerAsync = function (scene, data, rootUrl, onProgress, fullName) {
|
|
|
var _this = this;
|
|
|
return Promise.resolve().then(function () {
|
|
|
var loaderData = _this._parse(data);
|
|
|
_this._loader = _this._getLoader(loaderData);
|
|
|
- return _this._loader.importMeshAsync(null, scene, loaderData, rootUrl, onProgress).then(function (result) {
|
|
|
+ return _this._loader.importMeshAsync(null, scene, loaderData, rootUrl, onProgress, fullName).then(function (result) {
|
|
|
var container = new BABYLON.AssetContainer(scene);
|
|
|
Array.prototype.push.apply(container.meshes, result.meshes);
|
|
|
Array.prototype.push.apply(container.particleSystems, result.particleSystems);
|
|
@@ -4050,11 +4081,12 @@ var BABYLON;
|
|
|
this._parent._clear();
|
|
|
};
|
|
|
/** @hidden */
|
|
|
- GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress) {
|
|
|
+ GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress, fullName) {
|
|
|
var _this = this;
|
|
|
return Promise.resolve().then(function () {
|
|
|
_this.babylonScene = scene;
|
|
|
_this._rootUrl = rootUrl;
|
|
|
+ _this._fullName = fullName || "" + Date.now();
|
|
|
_this._progressCallback = onProgress;
|
|
|
_this._loadData(data);
|
|
|
var nodes = null;
|
|
@@ -4088,11 +4120,12 @@ var BABYLON;
|
|
|
});
|
|
|
};
|
|
|
/** @hidden */
|
|
|
- GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress) {
|
|
|
+ GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fullName) {
|
|
|
var _this = this;
|
|
|
return Promise.resolve().then(function () {
|
|
|
_this.babylonScene = scene;
|
|
|
_this._rootUrl = rootUrl;
|
|
|
+ _this._fullName = fullName || "" + Date.now();
|
|
|
_this._progressCallback = onProgress;
|
|
|
_this._loadData(data);
|
|
|
return _this._loadAsync(null, function () { return undefined; });
|
|
@@ -5344,7 +5377,7 @@ var BABYLON;
|
|
|
babylonTexture.wrapV = samplerData.wrapV;
|
|
|
var image = ArrayItem.Get(context + "/source", this.gltf.images, texture.source);
|
|
|
promises.push(this.loadImageAsync("#/images/" + image.index, image).then(function (data) {
|
|
|
- var dataUrl = "data:" + _this._rootUrl + (image.uri || "image" + image.index);
|
|
|
+ var dataUrl = "data:" + _this._fullName + (image.uri || "image" + image.index);
|
|
|
babylonTexture.updateURL(dataUrl, new Blob([data], { type: image.mimeType }));
|
|
|
}));
|
|
|
assign(babylonTexture);
|