|
@@ -15211,6 +15211,7 @@ var BABYLON;
|
|
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
|
gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
|
|
|
// Create the framebuffer
|
|
|
+ var currentFrameBuffer = this._currentFramebuffer;
|
|
|
var framebuffer = gl.createFramebuffer();
|
|
|
this.bindUnboundFramebuffer(framebuffer);
|
|
|
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
|
|
@@ -15221,7 +15222,7 @@ var BABYLON;
|
|
|
// Unbind
|
|
|
this._bindTextureDirectly(gl.TEXTURE_2D, null);
|
|
|
gl.bindRenderbuffer(gl.RENDERBUFFER, null);
|
|
|
- this.bindUnboundFramebuffer(null);
|
|
|
+ this.bindUnboundFramebuffer(currentFrameBuffer);
|
|
|
texture._framebuffer = framebuffer;
|
|
|
texture.baseWidth = width;
|
|
|
texture.baseHeight = height;
|
|
@@ -26249,8 +26250,11 @@ var BABYLON;
|
|
|
/**
|
|
|
* Add a mesh to the list of scene's meshes
|
|
|
* @param newMesh defines the mesh to add
|
|
|
+ * @param recursive if all child meshes should also be added to the scene
|
|
|
*/
|
|
|
- Scene.prototype.addMesh = function (newMesh) {
|
|
|
+ Scene.prototype.addMesh = function (newMesh, recursive) {
|
|
|
+ var _this = this;
|
|
|
+ if (recursive === void 0) { recursive = false; }
|
|
|
this.meshes.push(newMesh);
|
|
|
//notify the collision coordinator
|
|
|
if (this.collisionCoordinator) {
|
|
@@ -26258,6 +26262,11 @@ var BABYLON;
|
|
|
}
|
|
|
newMesh._resyncLightSources();
|
|
|
this.onNewMeshAddedObservable.notifyObservers(newMesh);
|
|
|
+ if (recursive) {
|
|
|
+ newMesh.getChildMeshes().forEach(function (m) {
|
|
|
+ _this.addMesh(m);
|
|
|
+ });
|
|
|
+ }
|
|
|
};
|
|
|
/**
|
|
|
* Remove a mesh for the list of scene's meshes
|
|
@@ -27824,7 +27833,7 @@ var BABYLON;
|
|
|
for (var lightIndex = 0; lightIndex < this.lights.length; lightIndex++) {
|
|
|
var light = this.lights[lightIndex];
|
|
|
var shadowGenerator = light.getShadowGenerator();
|
|
|
- if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
|
|
|
+ if (light.isEnabled() && light.shadowEnabled && shadowGenerator && shadowGenerator.arePostProcessesReady()) {
|
|
|
var shadowMap = (shadowGenerator.getShadowMap());
|
|
|
if (this.textures.indexOf(shadowMap) !== -1) {
|
|
|
this._renderTargets.push(shadowMap);
|
|
@@ -29337,6 +29346,20 @@ var BABYLON;
|
|
|
this._moveAssets(this.scene.effectLayers, this.effectLayers, keepAssets.effectLayers);
|
|
|
this.removeAllFromScene();
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
|
|
|
+ * @returns the root mesh
|
|
|
+ */
|
|
|
+ AssetContainer.prototype.createRootMesh = function () {
|
|
|
+ var rootMesh = new BABYLON.Mesh("assetContainerRootMesh", this.scene);
|
|
|
+ this.meshes.forEach(function (m) {
|
|
|
+ if (!m.parent) {
|
|
|
+ rootMesh.addChild(m);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.meshes.unshift(rootMesh);
|
|
|
+ return rootMesh;
|
|
|
+ };
|
|
|
return AssetContainer;
|
|
|
}());
|
|
|
BABYLON.AssetContainer = AssetContainer;
|
|
@@ -50940,7 +50963,7 @@ var BABYLON;
|
|
|
return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
|
|
|
};
|
|
|
/**
|
|
|
- * Transition property of the Camera to the target Value
|
|
|
+ * Transition property of an host to the target Value
|
|
|
* @param property The property to transition
|
|
|
* @param targetValue The target Value of the property
|
|
|
* @param host The object where the property to animate belongs
|
|
@@ -62321,6 +62344,41 @@ var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
/**
|
|
|
* Draco compression (https://google.github.io/draco/)
|
|
|
+ *
|
|
|
+ * This class wraps the Draco module.
|
|
|
+ *
|
|
|
+ * **Encoder**
|
|
|
+ *
|
|
|
+ * The encoder is not currently implemented.
|
|
|
+ *
|
|
|
+ * **Decoder**
|
|
|
+ *
|
|
|
+ * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
|
|
|
+ *
|
|
|
+ * To update the configuration, use the following code:
|
|
|
+ * ```javascript
|
|
|
+ * BABYLON.DracoCompression.Configuration = {
|
|
|
+ * decoder: {
|
|
|
+ * wasmUrl: "<url to the WebAssembly library>",
|
|
|
+ * wasmBinaryUrl: "<url to the WebAssembly binary>",
|
|
|
+ * fallbackUrl: "<url to the fallback JavaScript library>",
|
|
|
+ * }
|
|
|
+ * };
|
|
|
+ * ```
|
|
|
+ *
|
|
|
+ * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
|
|
|
+ * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
|
|
|
+ * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
|
|
|
+ *
|
|
|
+ * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
|
|
|
+ * ```javascript
|
|
|
+ * var dracoCompression = new BABYLON.DracoCompression();
|
|
|
+ * var vertexData = await dracoCompression.decodeMeshAsync(data, {
|
|
|
+ * [BABYLON.VertexBuffer.PositionKind]: 0
|
|
|
+ * });
|
|
|
+ * ```
|
|
|
+ *
|
|
|
+ * @see https://www.babylonjs-playground.com/#N3EK4B#0
|
|
|
*/
|
|
|
var DracoCompression = /** @class */ (function () {
|
|
|
/**
|
|
@@ -62357,16 +62415,17 @@ var BABYLON;
|
|
|
};
|
|
|
/**
|
|
|
* Decode Draco compressed mesh data to vertex data.
|
|
|
- * @param data The array buffer view for the Draco compression data
|
|
|
+ * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
|
|
|
* @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
|
|
|
* @returns A promise that resolves with the decoded vertex data
|
|
|
*/
|
|
|
DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
|
|
|
+ var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
|
|
|
return DracoCompression._GetDecoderModule().then(function (wrappedModule) {
|
|
|
var module = wrappedModule.module;
|
|
|
var vertexData = new BABYLON.VertexData();
|
|
|
var buffer = new module.DecoderBuffer();
|
|
|
- buffer.Init(data, data.byteLength);
|
|
|
+ buffer.Init(dataView, dataView.byteLength);
|
|
|
var decoder = new module.Decoder();
|
|
|
var geometry;
|
|
|
var status;
|
|
@@ -62490,7 +62549,10 @@ var BABYLON;
|
|
|
});
|
|
|
};
|
|
|
/**
|
|
|
- * The configuration.
|
|
|
+ * The configuration. Defaults to the following urls:
|
|
|
+ * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
|
|
|
+ * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
|
|
|
+ * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
|
|
|
*/
|
|
|
DracoCompression.Configuration = {
|
|
|
decoder: {
|
|
@@ -66917,6 +66979,13 @@ var BABYLON;
|
|
|
this._initializeBlurRTTAndPostProcesses();
|
|
|
}
|
|
|
}
|
|
|
+ return this.arePostProcessesReady();
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Returns true if all post processes required to render the shadow map are ready
|
|
|
+ * @returns true if the shadow map can be rendered with all post-processes
|
|
|
+ */
|
|
|
+ ShadowGenerator.prototype.arePostProcessesReady = function () {
|
|
|
if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
|
|
|
return false;
|
|
|
}
|
|
@@ -67525,7 +67594,7 @@ var BABYLON;
|
|
|
if (registeredPlugin) {
|
|
|
return registeredPlugin;
|
|
|
}
|
|
|
- BABYLON.Tools.Warn("Unable to find a plugin to load " + extension + " files. Trying to use .babylon default plugin.");
|
|
|
+ BABYLON.Tools.Warn("Unable to find a plugin to load " + extension + " files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: http://doc.babylonjs.com/how_to/load_from_any_file_type");
|
|
|
return SceneLoader._getDefaultPlugin();
|
|
|
};
|
|
|
SceneLoader._getPluginForDirectLoad = function (data) {
|
|
@@ -67671,8 +67740,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
|
|
|
- * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the 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 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
|
|
@@ -67681,10 +67750,20 @@ var BABYLON;
|
|
|
* @returns The loaded plugin
|
|
|
*/
|
|
|
SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
|
|
|
+ if (sceneFilename === void 0) { sceneFilename = ""; }
|
|
|
+ if (scene === void 0) { scene = BABYLON.Engine.LastCreatedScene; }
|
|
|
if (onSuccess === void 0) { onSuccess = null; }
|
|
|
if (onProgress === void 0) { onProgress = null; }
|
|
|
if (onError === void 0) { onError = null; }
|
|
|
if (pluginExtension === void 0) { pluginExtension = null; }
|
|
|
+ if (!scene) {
|
|
|
+ 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");
|
|
|
return null;
|
|
@@ -67759,14 +67838,16 @@ 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
|
|
|
- * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the 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 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; }
|
|
|
if (onProgress === void 0) { onProgress = null; }
|
|
|
if (pluginExtension === void 0) { pluginExtension = null; }
|
|
|
return new Promise(function (resolve, reject) {
|
|
@@ -67784,8 +67865,8 @@ var BABYLON;
|
|
|
};
|
|
|
/**
|
|
|
* Load a scene
|
|
|
- * @param rootUrl a string that defines the root url for scene and resources
|
|
|
- * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the 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
|
|
@@ -67802,8 +67883,8 @@ var BABYLON;
|
|
|
};
|
|
|
/**
|
|
|
* Load a scene
|
|
|
- * @param rootUrl a string that defines the root url for scene and resources
|
|
|
- * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the 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
|
|
@@ -67822,8 +67903,8 @@ var BABYLON;
|
|
|
};
|
|
|
/**
|
|
|
* Append a scene
|
|
|
- * @param rootUrl a string that defines the root url for scene and resources
|
|
|
- * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the 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
|
|
@@ -67832,10 +67913,20 @@ var BABYLON;
|
|
|
* @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; }
|
|
|
if (onSuccess === void 0) { onSuccess = null; }
|
|
|
if (onProgress === void 0) { onProgress = null; }
|
|
|
if (onError === void 0) { onError = null; }
|
|
|
if (pluginExtension === void 0) { pluginExtension = null; }
|
|
|
+ if (!scene) {
|
|
|
+ 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");
|
|
|
return null;
|
|
@@ -67909,14 +68000,16 @@ var BABYLON;
|
|
|
};
|
|
|
/**
|
|
|
* Append a scene
|
|
|
- * @param rootUrl a string that defines the root url for scene and resources
|
|
|
- * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the 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
|
|
|
*/
|
|
|
SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
|
|
|
+ if (sceneFilename === void 0) { sceneFilename = ""; }
|
|
|
+ if (scene === void 0) { scene = BABYLON.Engine.LastCreatedScene; }
|
|
|
if (onProgress === void 0) { onProgress = null; }
|
|
|
if (pluginExtension === void 0) { pluginExtension = null; }
|
|
|
return new Promise(function (resolve, reject) {
|
|
@@ -67929,9 +68022,9 @@ var BABYLON;
|
|
|
};
|
|
|
/**
|
|
|
* Load a scene into an asset container
|
|
|
- * @param rootUrl a string that defines the root url for scene and resources
|
|
|
- * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
|
|
|
- * @param scene is the instance of BABYLON.Scene to append to
|
|
|
+ * @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
|
|
@@ -67939,10 +68032,20 @@ var BABYLON;
|
|
|
* @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; }
|
|
|
if (onSuccess === void 0) { onSuccess = null; }
|
|
|
if (onProgress === void 0) { onProgress = null; }
|
|
|
if (onError === void 0) { onError = null; }
|
|
|
if (pluginExtension === void 0) { pluginExtension = null; }
|
|
|
+ if (!scene) {
|
|
|
+ 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");
|
|
|
return null;
|
|
@@ -68013,14 +68116,16 @@ var BABYLON;
|
|
|
};
|
|
|
/**
|
|
|
* Load a scene into an asset container
|
|
|
- * @param rootUrl a string that defines the root url for scene and resources
|
|
|
- * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the 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 loaded asset container
|
|
|
*/
|
|
|
SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
|
|
|
+ if (sceneFilename === void 0) { sceneFilename = ""; }
|
|
|
+ if (scene === void 0) { scene = BABYLON.Engine.LastCreatedScene; }
|
|
|
if (onProgress === void 0) { onProgress = null; }
|
|
|
if (pluginExtension === void 0) { pluginExtension = null; }
|
|
|
return new Promise(function (resolve, reject) {
|
|
@@ -98641,6 +98746,113 @@ var BABYLON;
|
|
|
|
|
|
//# sourceMappingURL=babylon.environmentHelper.js.map
|
|
|
|
|
|
+var BABYLON;
|
|
|
+(function (BABYLON) {
|
|
|
+ /**
|
|
|
+ * This class is made for on one-liner static method to help creating particle systems.
|
|
|
+ */
|
|
|
+ var ParticleHelper = /** @class */ (function () {
|
|
|
+ function ParticleHelper() {
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * This is the main static method (one-liner) of this helper to create different particle systems.
|
|
|
+ * @param type This string represents the type to the particle system to create
|
|
|
+ * @param emitter The object where the particle system will start to emit from.
|
|
|
+ * @param scene The scene where the particle system should live.
|
|
|
+ * @param gpu If the system will use gpu.
|
|
|
+ * @returns the ParticleSystem created.
|
|
|
+ */
|
|
|
+ ParticleHelper.CreateAsync = function (type, emitter, scene, gpu) {
|
|
|
+ var _this = this;
|
|
|
+ if (scene === void 0) { scene = BABYLON.Engine.LastCreatedScene; }
|
|
|
+ if (gpu === void 0) { gpu = false; }
|
|
|
+ return new Promise(function (resolve, reject) {
|
|
|
+ if (scene) {
|
|
|
+ _this._scene = scene;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return reject("A particle system need a scene.");
|
|
|
+ }
|
|
|
+ if (gpu && !BABYLON.GPUParticleSystem.IsSupported) {
|
|
|
+ return reject("Particle system with GPU is not supported.");
|
|
|
+ }
|
|
|
+ _this._emitter = emitter;
|
|
|
+ BABYLON.Tools.LoadFile(_this._baseAssetsUrl + "/systems/" + type + ".json", function (data, response) {
|
|
|
+ var newData = JSON.parse(data.toString());
|
|
|
+ return resolve(_this._createSystem(newData));
|
|
|
+ }, undefined, undefined, undefined, function (req, exception) {
|
|
|
+ return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
|
|
|
+ });
|
|
|
+ });
|
|
|
+ };
|
|
|
+ ParticleHelper._createSystem = function (data) {
|
|
|
+ // Create a particle system
|
|
|
+ var system = new BABYLON.ParticleSystem(data.type, data.capacity, this._scene);
|
|
|
+ // Texture of each particle
|
|
|
+ system.particleTexture = new BABYLON.Texture(this._baseAssetsUrl + "/textures/" + data.textureFile, this._scene);
|
|
|
+ // Where the particles come from
|
|
|
+ system.emitter = this._emitter; // the starting object, the emitter
|
|
|
+ // Colors of all particles
|
|
|
+ system.color1 = new BABYLON.Color4(data.color1.r, data.color1.g, data.color1.b, data.color1.a);
|
|
|
+ system.color2 = new BABYLON.Color4(data.color2.r, data.color2.g, data.color2.b, data.color2.a);
|
|
|
+ system.colorDead = new BABYLON.Color4(data.colorDead.r, data.colorDead.g, data.colorDead.b, data.colorDead.a);
|
|
|
+ // Size of each particle (random between...
|
|
|
+ system.minSize = data.minSize;
|
|
|
+ system.maxSize = data.maxSize;
|
|
|
+ // Life time of each particle (random between...
|
|
|
+ system.minLifeTime = data.minLifeTime;
|
|
|
+ system.maxLifeTime = data.maxLifeTime;
|
|
|
+ // Emission rate
|
|
|
+ system.emitRate = data.emitRate;
|
|
|
+ // Blend mode : BLENDMODE_ONEONE, or BLENDMODE_STANDARD
|
|
|
+ system.blendMode = data.blendMode;
|
|
|
+ // Set the gravity of all particles
|
|
|
+ system.gravity = new BABYLON.Vector3(data.gravity.x, data.gravity.y, data.gravity.z);
|
|
|
+ // Angular speed, in radians
|
|
|
+ system.minAngularSpeed = data.minAngularSpeed;
|
|
|
+ system.maxAngularSpeed = data.maxAngularSpeed;
|
|
|
+ // Speed
|
|
|
+ system.minEmitPower = data.minEmitPower;
|
|
|
+ system.maxEmitPower = data.maxEmitPower;
|
|
|
+ system.updateSpeed = data.updateSpeed;
|
|
|
+ switch (data.emitterType) {
|
|
|
+ case "box":
|
|
|
+ if (!data.direction1 || !data.direction2) {
|
|
|
+ throw new Error("Directions are missing in this particle system.");
|
|
|
+ }
|
|
|
+ if (!data.minEmitBox || !data.maxEmitBox) {
|
|
|
+ throw new Error("EmitBox is missing in this particle system.");
|
|
|
+ }
|
|
|
+ system.createBoxEmitter(new BABYLON.Vector3(data.direction1.x, data.direction1.y, data.direction1.z), new BABYLON.Vector3(data.direction2.x, data.direction2.y, data.direction2.z), new BABYLON.Vector3(data.minEmitBox.x, data.minEmitBox.y, data.minEmitBox.z), new BABYLON.Vector3(data.maxEmitBox.x, data.maxEmitBox.y, data.maxEmitBox.z));
|
|
|
+ break;
|
|
|
+ case "sphere":
|
|
|
+ system.createSphereEmitter(data.radius);
|
|
|
+ break;
|
|
|
+ case "directed_sphere":
|
|
|
+ if (!data.direction1 || !data.direction2) {
|
|
|
+ throw new Error("Directions are missing in this particle system.");
|
|
|
+ }
|
|
|
+ system.createDirectedSphereEmitter(data.radius, new BABYLON.Vector3(data.direction1.x, data.direction1.y, data.direction1.z), new BABYLON.Vector3(data.direction2.x, data.direction2.y, data.direction2.z));
|
|
|
+ break;
|
|
|
+ case "cone":
|
|
|
+ system.createConeEmitter(data.radius, data.angle);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return system;
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Base Assets URL.
|
|
|
+ */
|
|
|
+ ParticleHelper._baseAssetsUrl = "https://assets.babylonjs.com/particles";
|
|
|
+ return ParticleHelper;
|
|
|
+ }());
|
|
|
+ BABYLON.ParticleHelper = ParticleHelper;
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
+
|
|
|
+//# sourceMappingURL=babylon.particleHelper.js.map
|
|
|
+
|
|
|
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|