|
@@ -33689,12 +33689,14 @@ var BABYLON;
|
|
|
* Creates a ground mesh from a height map.
|
|
|
* tuto : http://doc.babylonjs.com/babylon101/height_map
|
|
|
* Please consider using the same method from the MeshBuilder class instead.
|
|
|
- * The parameter `url` sets the URL of the height map image resource.
|
|
|
- * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
|
|
|
- * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
|
|
|
- * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
|
|
|
- * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
|
|
|
- * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
|
|
|
+ * @param url sets the URL of the height map image resource.
|
|
|
+ * @param width (positive float, default 10) set the ground width size.
|
|
|
+ * @param height (positive float, default 10) set the ground height size.
|
|
|
+ * @param subdivisions (positive integer, default 1) sets the number of subdivision per side.
|
|
|
+ * @param minHeight (float, default 0) is the minimum altitude on the ground.
|
|
|
+ * @param maxHeight (float, default 1) is the maximum altitude on the ground.
|
|
|
+ * @param onReady is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
|
|
|
+ * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible).
|
|
|
* This function is passed the newly built mesh :
|
|
|
* ```javascript
|
|
|
* function(mesh) { // do things
|
|
@@ -33702,7 +33704,7 @@ var BABYLON;
|
|
|
* ```
|
|
|
* The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
|
|
|
*/
|
|
|
- Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady) {
|
|
|
+ Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
|
|
|
var options = {
|
|
|
width: width,
|
|
|
height: height,
|
|
@@ -33710,7 +33712,8 @@ var BABYLON;
|
|
|
minHeight: minHeight,
|
|
|
maxHeight: maxHeight,
|
|
|
updatable: updatable,
|
|
|
- onReady: onReady
|
|
|
+ onReady: onReady,
|
|
|
+ alphaFilter: alphaFilter
|
|
|
};
|
|
|
return BABYLON.MeshBuilder.CreateGroundFromHeightMap(name, url, options, scene);
|
|
|
};
|
|
@@ -37639,6 +37642,7 @@ var BABYLON;
|
|
|
* * buffer the array holding the image color data
|
|
|
* * bufferWidth the width of image
|
|
|
* * bufferHeight the height of image
|
|
|
+ * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
|
|
|
* @returns the VertexData of the Ground designed from a heightmap
|
|
|
*/
|
|
|
VertexData.CreateGroundFromHeightMap = function (options) {
|
|
@@ -37648,6 +37652,7 @@ var BABYLON;
|
|
|
var uvs = [];
|
|
|
var row, col;
|
|
|
var filter = options.colorFilter || new BABYLON.Color3(0.3, 0.59, 0.11);
|
|
|
+ var alphaFilter = options.alphaFilter || 0.0;
|
|
|
// Vertices
|
|
|
for (row = 0; row <= options.subdivisions; row++) {
|
|
|
for (col = 0; col <= options.subdivisions; col++) {
|
|
@@ -37659,8 +37664,15 @@ var BABYLON;
|
|
|
var r = options.buffer[pos] / 255.0;
|
|
|
var g = options.buffer[pos + 1] / 255.0;
|
|
|
var b = options.buffer[pos + 2] / 255.0;
|
|
|
+ var a = options.buffer[pos + 3] / 255.0;
|
|
|
var gradient = r * filter.r + g * filter.g + b * filter.b;
|
|
|
- position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
|
|
|
+ // If our alpha channel is not within our filter then we will assign a 'special' height
|
|
|
+ // Then when building the indices, we will ignore any vertex that is using the special height
|
|
|
+ if (a >= alphaFilter)
|
|
|
+ position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
|
|
|
+ else {
|
|
|
+ position.y = options.minHeight - BABYLON.Epsilon; // We can't have a height below minHeight, normally.
|
|
|
+ }
|
|
|
// Add vertex
|
|
|
positions.push(position.x, position.y, position.z);
|
|
|
normals.push(0, 0, 0);
|
|
@@ -37670,12 +37682,28 @@ var BABYLON;
|
|
|
// Indices
|
|
|
for (row = 0; row < options.subdivisions; row++) {
|
|
|
for (col = 0; col < options.subdivisions; col++) {
|
|
|
- indices.push(col + 1 + (row + 1) * (options.subdivisions + 1));
|
|
|
- indices.push(col + 1 + row * (options.subdivisions + 1));
|
|
|
- indices.push(col + row * (options.subdivisions + 1));
|
|
|
- indices.push(col + (row + 1) * (options.subdivisions + 1));
|
|
|
- indices.push(col + 1 + (row + 1) * (options.subdivisions + 1));
|
|
|
- indices.push(col + row * (options.subdivisions + 1));
|
|
|
+ // Calculate Indices
|
|
|
+ var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
|
|
|
+ var idx2 = (col + 1 + row * (options.subdivisions + 1));
|
|
|
+ var idx3 = (col + row * (options.subdivisions + 1));
|
|
|
+ var idx4 = (col + (row + 1) * (options.subdivisions + 1));
|
|
|
+ // Check that all indices are visible (based on our special height)
|
|
|
+ // Only display the vertex if all Indices are visible
|
|
|
+ // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
|
|
|
+ var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
|
|
|
+ var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
|
|
|
+ var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
|
|
|
+ if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
|
|
|
+ indices.push(idx1);
|
|
|
+ indices.push(idx2);
|
|
|
+ indices.push(idx3);
|
|
|
+ }
|
|
|
+ var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
|
|
|
+ if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
|
|
|
+ indices.push(idx4);
|
|
|
+ indices.push(idx1);
|
|
|
+ indices.push(idx3);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
// Normals
|
|
@@ -56875,9 +56903,6 @@ var BABYLON;
|
|
|
else {
|
|
|
var emitterPosition = subEmitter.particleSystem.emitter;
|
|
|
emitterPosition.copyFrom(particle.position);
|
|
|
- if (subEmitter.inheritDirection) {
|
|
|
- BABYLON.Tools.Warn("subEmitter.inheritDirection is not supported with non-mesh emitter type");
|
|
|
- }
|
|
|
}
|
|
|
// Set inheritedVelocityOffset to be used when new particles are created
|
|
|
particle.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, BABYLON.Tmp.Vector3[0]);
|
|
@@ -57413,6 +57438,11 @@ var BABYLON;
|
|
|
else if (subEmitter instanceof Array) {
|
|
|
_this._subEmitters.push(subEmitter);
|
|
|
}
|
|
|
+ _this._subEmitters[_this._subEmitters.length - 1].forEach(function (se) {
|
|
|
+ if (!(se.particleSystem.emitter instanceof BABYLON.AbstractMesh) && se.inheritDirection) {
|
|
|
+ BABYLON.Tools.Warn("subEmitter.inheritDirection is not supported with non-mesh emitter type");
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
this._started = true;
|
|
@@ -58010,8 +58040,8 @@ var BABYLON;
|
|
|
this._rampGradientsTexture = null;
|
|
|
}
|
|
|
this._removeFromRoot();
|
|
|
- if (this._disposeEmitterOnDispose && !this.emitter.isDisposed) {
|
|
|
- this.emitter.dispose();
|
|
|
+ if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
|
|
|
+ this.emitter.dispose(true);
|
|
|
}
|
|
|
// Remove from scene
|
|
|
var index = this._scene.particleSystems.indexOf(this);
|
|
@@ -61849,12 +61879,13 @@ var BABYLON;
|
|
|
this.scene._beforeEvaluateActiveMeshStage.registerStep(BABYLON.SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
|
|
|
this.scene._activeMeshStage.registerStep(BABYLON.SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
|
|
|
this.scene._evaluateSubMeshStage.registerStep(BABYLON.SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
|
|
|
- this.scene._afterCameraDrawStage.registerStep(BABYLON.SceneComponentConstants.STEP_AFTERCAMERADRAW_BOUNDINGBOXRENDERER, this, this.render);
|
|
|
+ this.scene._afterRenderingGroupDrawStage.registerStep(BABYLON.SceneComponentConstants.STEP_AFTERCAMERADRAW_BOUNDINGBOXRENDERER, this, this.render);
|
|
|
};
|
|
|
BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
|
|
|
if (mesh.showSubMeshesBoundingBox) {
|
|
|
var boundingInfo = subMesh.getBoundingInfo();
|
|
|
if (boundingInfo !== null && boundingInfo !== undefined) {
|
|
|
+ boundingInfo.boundingBox._tag = mesh.renderingGroupId;
|
|
|
this.renderList.push(boundingInfo.boundingBox);
|
|
|
}
|
|
|
}
|
|
@@ -61862,6 +61893,7 @@ var BABYLON;
|
|
|
BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
|
|
|
if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
|
|
|
var boundingInfo = sourceMesh.getBoundingInfo();
|
|
|
+ boundingInfo.boundingBox._tag = mesh.renderingGroupId;
|
|
|
this.renderList.push(boundingInfo.boundingBox);
|
|
|
}
|
|
|
};
|
|
@@ -61896,7 +61928,7 @@ var BABYLON;
|
|
|
BoundingBoxRenderer.prototype.reset = function () {
|
|
|
this.renderList.reset();
|
|
|
};
|
|
|
- BoundingBoxRenderer.prototype.render = function () {
|
|
|
+ BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
|
|
|
if (this.renderList.length === 0) {
|
|
|
return;
|
|
|
}
|
|
@@ -61909,6 +61941,9 @@ var BABYLON;
|
|
|
this._colorShader._preBind();
|
|
|
for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
|
|
|
var boundingBox = this.renderList.data[boundingBoxIndex];
|
|
|
+ if (boundingBox._tag !== renderingGroupId) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
var min = boundingBox.minimum;
|
|
|
var max = boundingBox.maximum;
|
|
|
var diff = max.subtract(min);
|
|
@@ -65316,6 +65351,7 @@ var BABYLON;
|
|
|
* * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
|
|
|
* * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
|
|
|
* * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
|
|
|
+ * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
|
|
|
* * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
|
|
|
* @param name defines the name of the mesh
|
|
|
* @param url defines the url to the height map
|
|
@@ -65332,6 +65368,7 @@ var BABYLON;
|
|
|
var minHeight = options.minHeight || 0.0;
|
|
|
var maxHeight = options.maxHeight || 1.0;
|
|
|
var filter = options.colorFilter || new BABYLON.Color3(0.3, 0.59, 0.11);
|
|
|
+ var alphaFilter = options.alphaFilter || 0.0;
|
|
|
var updatable = options.updatable;
|
|
|
var onReady = options.onReady;
|
|
|
var ground = new BABYLON.GroundMesh(name, scene);
|
|
@@ -65366,7 +65403,8 @@ var BABYLON;
|
|
|
width: width, height: height,
|
|
|
subdivisions: subdivisions,
|
|
|
minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
|
|
|
- buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight
|
|
|
+ buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
|
|
|
+ alphaFilter: alphaFilter
|
|
|
});
|
|
|
vertexData.applyToMesh(ground, updatable);
|
|
|
//execute ready callback, if set
|
|
@@ -71975,9 +72013,6 @@ var BABYLON;
|
|
|
return SceneLoader._getDefaultPlugin();
|
|
|
};
|
|
|
SceneLoader._getPluginForFilename = function (sceneFilename) {
|
|
|
- if (sceneFilename.name) {
|
|
|
- sceneFilename = sceneFilename.name;
|
|
|
- }
|
|
|
var queryStringPosition = sceneFilename.indexOf("?");
|
|
|
if (queryStringPosition !== -1) {
|
|
|
sceneFilename = sceneFilename.substring(0, queryStringPosition);
|
|
@@ -71988,14 +72023,14 @@ var BABYLON;
|
|
|
};
|
|
|
// use babylon file loader directly if sceneFilename is prefixed with "data:"
|
|
|
SceneLoader._getDirectLoad = function (sceneFilename) {
|
|
|
- if (sceneFilename.substr && sceneFilename.substr(0, 5) === "data:") {
|
|
|
+ if (sceneFilename.substr(0, 5) === "data:") {
|
|
|
return sceneFilename.substr(5);
|
|
|
}
|
|
|
return null;
|
|
|
};
|
|
|
- SceneLoader._loadData = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
|
|
|
- var directLoad = SceneLoader._getDirectLoad(sceneFilename);
|
|
|
- var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(sceneFilename) : SceneLoader._getPluginForFilename(sceneFilename));
|
|
|
+ SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
|
|
|
+ var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
|
|
|
+ var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
|
|
|
var plugin;
|
|
|
if (registeredPlugin.plugin.createPlugin) {
|
|
|
plugin = registeredPlugin.plugin.createPlugin();
|
|
@@ -72031,8 +72066,7 @@ var BABYLON;
|
|
|
if (pluginDisposed) {
|
|
|
return;
|
|
|
}
|
|
|
- var url = rootUrl + sceneFilename;
|
|
|
- request = BABYLON.Tools.LoadFile(url, dataCallback, onProgress ? function (event) {
|
|
|
+ request = BABYLON.Tools.LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
|
|
|
onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
|
|
|
} : undefined, database, useArrayBuffer, function (request, exception) {
|
|
|
onError("Failed to load scene." + (exception ? "" : " " + exception.message), exception);
|
|
@@ -72042,7 +72076,7 @@ var BABYLON;
|
|
|
dataCallback(directLoad);
|
|
|
return plugin;
|
|
|
}
|
|
|
- if (rootUrl.indexOf("file:") === -1) {
|
|
|
+ if (fileInfo.rootUrl.indexOf("file:") === -1) {
|
|
|
var engine = scene.getEngine();
|
|
|
var canUseOfflineSupport = engine.enableOfflineSupport;
|
|
|
if (canUseOfflineSupport) {
|
|
@@ -72050,7 +72084,7 @@ var BABYLON;
|
|
|
var exceptionFound = false;
|
|
|
for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
|
|
|
var regex = _a[_i];
|
|
|
- if (regex.test(rootUrl + sceneFilename)) {
|
|
|
+ if (regex.test(fileInfo.url)) {
|
|
|
exceptionFound = true;
|
|
|
break;
|
|
|
}
|
|
@@ -72059,7 +72093,7 @@ var BABYLON;
|
|
|
}
|
|
|
if (canUseOfflineSupport) {
|
|
|
// Checking if a manifest file has been set for this scene and if offline mode has been requested
|
|
|
- database = new BABYLON.Database(rootUrl + sceneFilename, manifestChecked, engine.disableManifestCheck);
|
|
|
+ database = new BABYLON.Database(fileInfo.url, manifestChecked, engine.disableManifestCheck);
|
|
|
}
|
|
|
else {
|
|
|
manifestChecked();
|
|
@@ -72067,19 +72101,39 @@ var BABYLON;
|
|
|
}
|
|
|
// Loading file from disk via input file or drag'n'drop
|
|
|
else {
|
|
|
- var fileOrString = sceneFilename;
|
|
|
- if (fileOrString.name) { // File
|
|
|
- request = BABYLON.Tools.ReadFile(fileOrString, dataCallback, onProgress, useArrayBuffer);
|
|
|
- }
|
|
|
- else if (BABYLON.FilesInput.FilesToLoad[sceneFilename]) {
|
|
|
- request = BABYLON.Tools.ReadFile(BABYLON.FilesInput.FilesToLoad[sceneFilename], dataCallback, onProgress, useArrayBuffer);
|
|
|
+ var file = BABYLON.FilesInput.FilesToLoad[fileInfo.name.toLowerCase()];
|
|
|
+ if (file) {
|
|
|
+ request = BABYLON.Tools.ReadFile(file, dataCallback, onProgress, useArrayBuffer);
|
|
|
}
|
|
|
else {
|
|
|
- onError("Unable to find file named " + sceneFilename);
|
|
|
+ onError("Unable to find file named " + fileInfo.name);
|
|
|
}
|
|
|
}
|
|
|
return plugin;
|
|
|
};
|
|
|
+ SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
|
|
|
+ var url;
|
|
|
+ var name;
|
|
|
+ if (!sceneFilename) {
|
|
|
+ url = rootUrl;
|
|
|
+ name = BABYLON.Tools.GetFilename(rootUrl);
|
|
|
+ rootUrl = BABYLON.Tools.GetFolderPath(rootUrl);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (sceneFilename.substr(0, 1) === "/") {
|
|
|
+ BABYLON.Tools.Error("Wrong sceneFilename parameter");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ url = rootUrl + sceneFilename;
|
|
|
+ name = sceneFilename;
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ return {
|
|
|
+ url: url,
|
|
|
+ rootUrl: rootUrl,
|
|
|
+ name: name
|
|
|
+ };
|
|
|
+ };
|
|
|
// Public functions
|
|
|
SceneLoader.GetPluginForExtension = function (extension) {
|
|
|
return SceneLoader._getPluginForExtension(extension).plugin;
|
|
@@ -72108,8 +72162,8 @@ var BABYLON;
|
|
|
/**
|
|
|
* Import meshes into a scene
|
|
|
* @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
|
|
|
- * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
|
|
|
- * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
|
|
|
+ * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
|
|
|
+ * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
|
|
|
* @param scene the instance of BABYLON.Scene to append to
|
|
|
* @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
|
|
|
* @param onProgress a callback with a progress event for each file being loaded
|
|
@@ -72128,12 +72182,8 @@ var BABYLON;
|
|
|
BABYLON.Tools.Error("No scene available to import mesh to");
|
|
|
return null;
|
|
|
}
|
|
|
- if (!sceneFilename) {
|
|
|
- sceneFilename = BABYLON.Tools.GetFilename(rootUrl);
|
|
|
- rootUrl = BABYLON.Tools.GetFolderPath(rootUrl);
|
|
|
- }
|
|
|
- if (sceneFilename.substr && sceneFilename.substr(0, 1) === "/") {
|
|
|
- BABYLON.Tools.Error("Wrong sceneFilename parameter");
|
|
|
+ var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
|
|
|
+ if (!fileInfo) {
|
|
|
return null;
|
|
|
}
|
|
|
var loadingToken = {};
|
|
@@ -72142,7 +72192,7 @@ var BABYLON;
|
|
|
scene._removePendingData(loadingToken);
|
|
|
};
|
|
|
var errorHandler = function (message, exception) {
|
|
|
- var errorMessage = "Unable to import meshes from " + rootUrl + sceneFilename + ": " + message;
|
|
|
+ var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
|
|
|
if (onError) {
|
|
|
onError(scene, errorMessage, exception);
|
|
|
}
|
|
@@ -72161,7 +72211,7 @@ var BABYLON;
|
|
|
}
|
|
|
} : undefined;
|
|
|
var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
|
|
|
- scene.importedMeshesFiles.push(rootUrl + sceneFilename);
|
|
|
+ scene.importedMeshesFiles.push(fileInfo.url);
|
|
|
if (onSuccess) {
|
|
|
try {
|
|
|
onSuccess(meshes, particleSystems, skeletons, animationGroups);
|
|
@@ -72172,21 +72222,16 @@ var BABYLON;
|
|
|
}
|
|
|
scene._removePendingData(loadingToken);
|
|
|
};
|
|
|
- return SceneLoader._loadData(rootUrl, sceneFilename, scene, function (plugin, data, responseURL) {
|
|
|
+ return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
|
|
|
if (plugin.rewriteRootURL) {
|
|
|
- rootUrl = plugin.rewriteRootURL(rootUrl, responseURL);
|
|
|
- }
|
|
|
- if (sceneFilename === "") {
|
|
|
- if (sceneFilename === "") {
|
|
|
- rootUrl = BABYLON.Tools.GetFolderPath(rootUrl, true);
|
|
|
- }
|
|
|
+ fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
|
|
|
}
|
|
|
if (plugin.importMesh) {
|
|
|
var syncedPlugin = plugin;
|
|
|
var meshes = new Array();
|
|
|
var particleSystems = new Array();
|
|
|
var skeletons = new Array();
|
|
|
- if (!syncedPlugin.importMesh(meshNames, scene, data, rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
|
|
|
+ if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
|
|
|
return;
|
|
|
}
|
|
|
scene.loadingPluginName = plugin.name;
|
|
@@ -72194,7 +72239,7 @@ var BABYLON;
|
|
|
}
|
|
|
else {
|
|
|
var asyncedPlugin = plugin;
|
|
|
- asyncedPlugin.importMeshAsync(meshNames, scene, data, rootUrl, progressHandler, rootUrl + sceneFilename).then(function (result) {
|
|
|
+ asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
|
|
|
scene.loadingPluginName = plugin.name;
|
|
|
successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
|
|
|
}).catch(function (error) {
|
|
@@ -72204,15 +72249,15 @@ var BABYLON;
|
|
|
}, progressHandler, errorHandler, disposeHandler, pluginExtension);
|
|
|
};
|
|
|
/**
|
|
|
- * Import meshes into a scene
|
|
|
- * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
|
|
|
- * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
|
|
|
- * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
|
|
|
- * @param scene the instance of BABYLON.Scene to append to
|
|
|
- * @param onProgress a callback with a progress event for each file being loaded
|
|
|
- * @param pluginExtension the extension used to determine the plugin
|
|
|
- * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
|
|
|
- */
|
|
|
+ * Import meshes into a scene
|
|
|
+ * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
|
|
|
+ * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
|
|
|
+ * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
|
|
|
+ * @param scene the instance of BABYLON.Scene to append to
|
|
|
+ * @param onProgress a callback with a progress event for each file being loaded
|
|
|
+ * @param pluginExtension the extension used to determine the plugin
|
|
|
+ * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
|
|
|
+ */
|
|
|
SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
|
|
|
if (sceneFilename === void 0) { sceneFilename = ""; }
|
|
|
if (scene === void 0) { scene = BABYLON.Engine.LastCreatedScene; }
|
|
@@ -72232,16 +72277,16 @@ var BABYLON;
|
|
|
});
|
|
|
};
|
|
|
/**
|
|
|
- * Load a scene
|
|
|
- * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
|
|
|
- * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
|
|
|
- * @param engine is the instance of BABYLON.Engine to use to create the scene
|
|
|
- * @param onSuccess a callback with the scene when import succeeds
|
|
|
- * @param onProgress a callback with a progress event for each file being loaded
|
|
|
- * @param onError a callback with the scene, a message, and possibly an exception when import fails
|
|
|
- * @param pluginExtension the extension used to determine the plugin
|
|
|
- * @returns The loaded plugin
|
|
|
- */
|
|
|
+ * Load a scene
|
|
|
+ * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
|
|
|
+ * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
|
|
|
+ * @param engine is the instance of BABYLON.Engine to use to create the scene
|
|
|
+ * @param onSuccess a callback with the scene when import succeeds
|
|
|
+ * @param onProgress a callback with a progress event for each file being loaded
|
|
|
+ * @param onError a callback with the scene, a message, and possibly an exception when import fails
|
|
|
+ * @param pluginExtension the extension used to determine the plugin
|
|
|
+ * @returns The loaded plugin
|
|
|
+ */
|
|
|
SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
|
|
|
if (onSuccess === void 0) { onSuccess = null; }
|
|
|
if (onProgress === void 0) { onProgress = null; }
|
|
@@ -72250,14 +72295,14 @@ var BABYLON;
|
|
|
return SceneLoader.Append(rootUrl, sceneFilename, new BABYLON.Scene(engine), onSuccess, onProgress, onError, pluginExtension);
|
|
|
};
|
|
|
/**
|
|
|
- * Load a scene
|
|
|
- * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
|
|
|
- * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
|
|
|
- * @param engine is the instance of BABYLON.Engine to use to create the scene
|
|
|
- * @param onProgress a callback with a progress event for each file being loaded
|
|
|
- * @param pluginExtension the extension used to determine the plugin
|
|
|
- * @returns The loaded scene
|
|
|
- */
|
|
|
+ * Load a scene
|
|
|
+ * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
|
|
|
+ * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
|
|
|
+ * @param engine is the instance of BABYLON.Engine to use to create the scene
|
|
|
+ * @param onProgress a callback with a progress event for each file being loaded
|
|
|
+ * @param pluginExtension the extension used to determine the plugin
|
|
|
+ * @returns The loaded scene
|
|
|
+ */
|
|
|
SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
|
|
|
if (onProgress === void 0) { onProgress = null; }
|
|
|
if (pluginExtension === void 0) { pluginExtension = null; }
|
|
@@ -72270,16 +72315,16 @@ var BABYLON;
|
|
|
});
|
|
|
};
|
|
|
/**
|
|
|
- * Append a scene
|
|
|
- * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
|
|
|
- * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
|
|
|
- * @param scene is the instance of BABYLON.Scene to append to
|
|
|
- * @param onSuccess a callback with the scene when import succeeds
|
|
|
- * @param onProgress a callback with a progress event for each file being loaded
|
|
|
- * @param onError a callback with the scene, a message, and possibly an exception when import fails
|
|
|
- * @param pluginExtension the extension used to determine the plugin
|
|
|
- * @returns The loaded plugin
|
|
|
- */
|
|
|
+ * Append a scene
|
|
|
+ * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
|
|
|
+ * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
|
|
|
+ * @param scene is the instance of BABYLON.Scene to append to
|
|
|
+ * @param onSuccess a callback with the scene when import succeeds
|
|
|
+ * @param onProgress a callback with a progress event for each file being loaded
|
|
|
+ * @param onError a callback with the scene, a message, and possibly an exception when import fails
|
|
|
+ * @param pluginExtension the extension used to determine the plugin
|
|
|
+ * @returns The loaded plugin
|
|
|
+ */
|
|
|
SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
|
|
|
if (sceneFilename === void 0) { sceneFilename = ""; }
|
|
|
if (scene === void 0) { scene = BABYLON.Engine.LastCreatedScene; }
|
|
@@ -72291,12 +72336,8 @@ var BABYLON;
|
|
|
BABYLON.Tools.Error("No scene available to append to");
|
|
|
return null;
|
|
|
}
|
|
|
- if (!sceneFilename) {
|
|
|
- sceneFilename = BABYLON.Tools.GetFilename(rootUrl);
|
|
|
- rootUrl = BABYLON.Tools.GetFolderPath(rootUrl);
|
|
|
- }
|
|
|
- if (sceneFilename.substr && sceneFilename.substr(0, 1) === "/") {
|
|
|
- BABYLON.Tools.Error("Wrong sceneFilename parameter");
|
|
|
+ var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
|
|
|
+ if (!fileInfo) {
|
|
|
return null;
|
|
|
}
|
|
|
if (SceneLoader.ShowLoadingScreen) {
|
|
@@ -72309,7 +72350,7 @@ var BABYLON;
|
|
|
scene.getEngine().hideLoadingUI();
|
|
|
};
|
|
|
var errorHandler = function (message, exception) {
|
|
|
- var errorMessage = "Unable to load from " + rootUrl + sceneFilename + (message ? ": " + message : "");
|
|
|
+ var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
|
|
|
if (onError) {
|
|
|
onError(scene, errorMessage, exception);
|
|
|
}
|
|
@@ -72338,13 +72379,10 @@ var BABYLON;
|
|
|
}
|
|
|
scene._removePendingData(loadingToken);
|
|
|
};
|
|
|
- return SceneLoader._loadData(rootUrl, sceneFilename, scene, function (plugin, data, responseURL) {
|
|
|
- if (sceneFilename === "") {
|
|
|
- rootUrl = BABYLON.Tools.GetFolderPath(rootUrl, true);
|
|
|
- }
|
|
|
+ return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
|
|
|
if (plugin.load) {
|
|
|
var syncedPlugin = plugin;
|
|
|
- if (!syncedPlugin.load(scene, data, rootUrl, errorHandler)) {
|
|
|
+ if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
|
|
|
return;
|
|
|
}
|
|
|
scene.loadingPluginName = plugin.name;
|
|
@@ -72352,7 +72390,7 @@ var BABYLON;
|
|
|
}
|
|
|
else {
|
|
|
var asyncedPlugin = plugin;
|
|
|
- asyncedPlugin.loadAsync(scene, data, rootUrl, progressHandler, rootUrl + sceneFilename).then(function () {
|
|
|
+ asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
|
|
|
scene.loadingPluginName = plugin.name;
|
|
|
successHandler();
|
|
|
}).catch(function (error) {
|
|
@@ -72367,14 +72405,14 @@ var BABYLON;
|
|
|
}, progressHandler, errorHandler, disposeHandler, pluginExtension);
|
|
|
};
|
|
|
/**
|
|
|
- * Append a scene
|
|
|
- * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
|
|
|
- * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
|
|
|
- * @param scene is the instance of BABYLON.Scene to append to
|
|
|
- * @param onProgress a callback with a progress event for each file being loaded
|
|
|
- * @param pluginExtension the extension used to determine the plugin
|
|
|
- * @returns The given scene
|
|
|
- */
|
|
|
+ * Append a scene
|
|
|
+ * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
|
|
|
+ * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
|
|
|
+ * @param scene is the instance of BABYLON.Scene to append to
|
|
|
+ * @param onProgress a callback with a progress event for each file being loaded
|
|
|
+ * @param pluginExtension the extension used to determine the plugin
|
|
|
+ * @returns The given scene
|
|
|
+ */
|
|
|
SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
|
|
|
if (sceneFilename === void 0) { sceneFilename = ""; }
|
|
|
if (scene === void 0) { scene = BABYLON.Engine.LastCreatedScene; }
|
|
@@ -72389,16 +72427,16 @@ var BABYLON;
|
|
|
});
|
|
|
};
|
|
|
/**
|
|
|
- * Load a scene into an asset container
|
|
|
- * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
|
|
|
- * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
|
|
|
- * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
|
|
|
- * @param onSuccess a callback with the scene when import succeeds
|
|
|
- * @param onProgress a callback with a progress event for each file being loaded
|
|
|
- * @param onError a callback with the scene, a message, and possibly an exception when import fails
|
|
|
- * @param pluginExtension the extension used to determine the plugin
|
|
|
- * @returns The loaded plugin
|
|
|
- */
|
|
|
+ * Load a scene into an asset container
|
|
|
+ * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
|
|
|
+ * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
|
|
|
+ * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
|
|
|
+ * @param onSuccess a callback with the scene when import succeeds
|
|
|
+ * @param onProgress a callback with a progress event for each file being loaded
|
|
|
+ * @param onError a callback with the scene, a message, and possibly an exception when import fails
|
|
|
+ * @param pluginExtension the extension used to determine the plugin
|
|
|
+ * @returns The loaded plugin
|
|
|
+ */
|
|
|
SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
|
|
|
if (sceneFilename === void 0) { sceneFilename = ""; }
|
|
|
if (scene === void 0) { scene = BABYLON.Engine.LastCreatedScene; }
|
|
@@ -72410,12 +72448,8 @@ var BABYLON;
|
|
|
BABYLON.Tools.Error("No scene available to load asset container to");
|
|
|
return null;
|
|
|
}
|
|
|
- if (!sceneFilename) {
|
|
|
- sceneFilename = BABYLON.Tools.GetFilename(rootUrl);
|
|
|
- rootUrl = BABYLON.Tools.GetFolderPath(rootUrl);
|
|
|
- }
|
|
|
- if (sceneFilename.substr && sceneFilename.substr(0, 1) === "/") {
|
|
|
- BABYLON.Tools.Error("Wrong sceneFilename parameter");
|
|
|
+ var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
|
|
|
+ if (!fileInfo) {
|
|
|
return null;
|
|
|
}
|
|
|
var loadingToken = {};
|
|
@@ -72424,7 +72458,7 @@ var BABYLON;
|
|
|
scene._removePendingData(loadingToken);
|
|
|
};
|
|
|
var errorHandler = function (message, exception) {
|
|
|
- var errorMessage = "Unable to load assets from " + rootUrl + sceneFilename + (message ? ": " + message : "");
|
|
|
+ var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
|
|
|
if (onError) {
|
|
|
onError(scene, errorMessage, exception);
|
|
|
}
|
|
@@ -72453,10 +72487,10 @@ var BABYLON;
|
|
|
}
|
|
|
scene._removePendingData(loadingToken);
|
|
|
};
|
|
|
- return SceneLoader._loadData(rootUrl, sceneFilename, scene, function (plugin, data, responseURL) {
|
|
|
+ return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
|
|
|
if (plugin.loadAssetContainer) {
|
|
|
var syncedPlugin = plugin;
|
|
|
- var assetContainer = syncedPlugin.loadAssetContainer(scene, data, rootUrl, errorHandler);
|
|
|
+ var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
|
|
|
if (!assetContainer) {
|
|
|
return;
|
|
|
}
|
|
@@ -72465,7 +72499,7 @@ var BABYLON;
|
|
|
}
|
|
|
else if (plugin.loadAssetContainerAsync) {
|
|
|
var asyncedPlugin = plugin;
|
|
|
- asyncedPlugin.loadAssetContainerAsync(scene, data, rootUrl, progressHandler, rootUrl + sceneFilename).then(function (assetContainer) {
|
|
|
+ asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
|
|
|
scene.loadingPluginName = plugin.name;
|
|
|
successHandler(assetContainer);
|
|
|
}).catch(function (error) {
|
|
@@ -72483,14 +72517,14 @@ var BABYLON;
|
|
|
}, progressHandler, errorHandler, disposeHandler, pluginExtension);
|
|
|
};
|
|
|
/**
|
|
|
- * Load a scene into an asset container
|
|
|
- * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
|
|
|
- * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
|
|
|
- * @param scene is the instance of BABYLON.Scene to append to
|
|
|
- * @param onProgress a callback with a progress event for each file being loaded
|
|
|
- * @param pluginExtension the extension used to determine the plugin
|
|
|
- * @returns The loaded asset container
|
|
|
- */
|
|
|
+ * Load a scene into an asset container
|
|
|
+ * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
|
|
|
+ * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
|
|
|
+ * @param scene is the instance of BABYLON.Scene to append to
|
|
|
+ * @param onProgress a callback with a progress event for each file being loaded
|
|
|
+ * @param pluginExtension the extension used to determine the plugin
|
|
|
+ * @returns The loaded asset container
|
|
|
+ */
|
|
|
SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
|
|
|
if (sceneFilename === void 0) { sceneFilename = ""; }
|
|
|
if (scene === void 0) { scene = BABYLON.Engine.LastCreatedScene; }
|
|
@@ -73280,9 +73314,7 @@ var BABYLON;
|
|
|
&& name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
|
|
|
this._sceneFileToLoad = files[i];
|
|
|
}
|
|
|
- else {
|
|
|
- FilesInput.FilesToLoad[name] = files[i];
|
|
|
- }
|
|
|
+ FilesInput.FilesToLoad[name] = files[i];
|
|
|
}
|
|
|
};
|
|
|
FilesInput.prototype.loadFiles = function (event) {
|
|
@@ -73367,7 +73399,7 @@ var BABYLON;
|
|
|
}
|
|
|
this._engine.stopRenderLoop();
|
|
|
}
|
|
|
- BABYLON.SceneLoader.LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
|
|
|
+ BABYLON.SceneLoader.LoadAsync("file:", this._sceneFileToLoad.name, this._engine, function (progress) {
|
|
|
if (_this._progressCallback) {
|
|
|
_this._progressCallback(progress);
|
|
|
}
|
|
@@ -107639,10 +107671,14 @@ var BABYLON;
|
|
|
this._onBeforeParticlesRenderingObserver = null;
|
|
|
this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
|
|
|
this._onAfterParticlesRenderingObserver = null;
|
|
|
- this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
|
|
|
- this._onBeforeSpritesRenderingObserver = null;
|
|
|
- this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
|
|
|
- this._onAfterSpritesRenderingObserver = null;
|
|
|
+ if (this._onBeforeSpritesRenderingObserver) {
|
|
|
+ this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
|
|
|
+ this._onBeforeSpritesRenderingObserver = null;
|
|
|
+ }
|
|
|
+ if (this._onAfterSpritesRenderingObserver) {
|
|
|
+ this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
|
|
|
+ this._onAfterSpritesRenderingObserver = null;
|
|
|
+ }
|
|
|
this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
|
|
|
this._onBeforeDrawPhaseObserver = null;
|
|
|
this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
|