|
@@ -14038,7 +14038,8 @@ var BABYLON;
|
|
return effect;
|
|
return effect;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
- * Create an effect to use with particle systems
|
|
|
|
|
|
+ * Create an effect to use with particle systems.
|
|
|
|
+ * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
|
|
* @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
|
|
* @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
|
|
* @param uniformsNames defines a list of attribute names
|
|
* @param uniformsNames defines a list of attribute names
|
|
* @param samplers defines an array of string used to represent textures
|
|
* @param samplers defines an array of string used to represent textures
|
|
@@ -14052,10 +14053,13 @@ var BABYLON;
|
|
if (uniformsNames === void 0) { uniformsNames = []; }
|
|
if (uniformsNames === void 0) { uniformsNames = []; }
|
|
if (samplers === void 0) { samplers = []; }
|
|
if (samplers === void 0) { samplers = []; }
|
|
if (defines === void 0) { defines = ""; }
|
|
if (defines === void 0) { defines = ""; }
|
|
|
|
+ var attributesNamesOrOptions = BABYLON.ParticleSystem._GetAttributeNamesOrOptions();
|
|
|
|
+ var effectCreationOption = BABYLON.ParticleSystem._GetEffectCreationOptions();
|
|
|
|
+ defines += "\n#define BILLBOARD\n";
|
|
return this.createEffect({
|
|
return this.createEffect({
|
|
vertex: "particles",
|
|
vertex: "particles",
|
|
fragmentElement: fragmentName
|
|
fragmentElement: fragmentName
|
|
- }, ["position", "color", "options"], ["view", "projection"].concat(uniformsNames), ["diffuseSampler"].concat(samplers), defines, fallbacks, onCompiled, onError);
|
|
|
|
|
|
+ }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), ["diffuseSampler"].concat(samplers), defines, fallbacks, onCompiled, onError);
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
* Directly creates a webGL program
|
|
* Directly creates a webGL program
|
|
@@ -14802,19 +14806,35 @@ var BABYLON;
|
|
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
|
|
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- // Using shaders to rescale because canvas.drawImage is lossy
|
|
|
|
- var source = new BABYLON.InternalTexture(_this, BABYLON.InternalTexture.DATASOURCE_TEMP);
|
|
|
|
- _this._bindTextureDirectly(gl.TEXTURE_2D, source, true);
|
|
|
|
- gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
|
|
|
|
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
|
|
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
|
|
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
|
|
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
|
|
- _this._rescaleTexture(source, texture, scene, internalFormat, function () {
|
|
|
|
- _this._releaseTexture(source);
|
|
|
|
- _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
|
|
|
|
- continuationCallback();
|
|
|
|
- });
|
|
|
|
|
|
+ var maxTextureSize = _this._caps.maxTextureSize;
|
|
|
|
+ if (img.width > maxTextureSize || img.height > maxTextureSize) {
|
|
|
|
+ _this._prepareWorkingCanvas();
|
|
|
|
+ if (!_this._workingCanvas || !_this._workingContext) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ _this._workingCanvas.width = potWidth;
|
|
|
|
+ _this._workingCanvas.height = potHeight;
|
|
|
|
+ _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
|
|
|
|
+ gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
|
|
|
|
+ texture.width = potWidth;
|
|
|
|
+ texture.height = potHeight;
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ // Using shaders when possible to rescale because canvas.drawImage is lossy
|
|
|
|
+ var source_1 = new BABYLON.InternalTexture(_this, BABYLON.InternalTexture.DATASOURCE_TEMP);
|
|
|
|
+ _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
|
|
|
|
+ gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
|
|
|
|
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
|
|
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
|
|
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
|
|
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
|
|
+ _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
|
|
|
|
+ _this._releaseTexture(source_1);
|
|
|
|
+ _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
|
|
|
|
+ continuationCallback();
|
|
|
|
+ });
|
|
|
|
+ }
|
|
return true;
|
|
return true;
|
|
}, samplingMode);
|
|
}, samplingMode);
|
|
};
|
|
};
|
|
@@ -16287,8 +16307,9 @@ var BABYLON;
|
|
Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
|
|
Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
|
|
var _this = this;
|
|
var _this = this;
|
|
if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
|
|
if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
|
|
- var potWidth = this.needPOTTextures ? BABYLON.Tools.GetExponentOfTwo(width, this.getCaps().maxTextureSize) : width;
|
|
|
|
- var potHeight = this.needPOTTextures ? BABYLON.Tools.GetExponentOfTwo(height, this.getCaps().maxTextureSize) : height;
|
|
|
|
|
|
+ var maxTextureSize = this.getCaps().maxTextureSize;
|
|
|
|
+ var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? BABYLON.Tools.GetExponentOfTwo(width, maxTextureSize) : width);
|
|
|
|
+ var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? BABYLON.Tools.GetExponentOfTwo(height, maxTextureSize) : height);
|
|
var gl = this._gl;
|
|
var gl = this._gl;
|
|
if (!gl) {
|
|
if (!gl) {
|
|
return;
|
|
return;
|
|
@@ -55992,6 +56013,27 @@ var BABYLON;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+ /** @hidden */
|
|
|
|
+ ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased) {
|
|
|
|
+ if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
|
|
|
|
+ if (isBillboardBased === void 0) { isBillboardBased = false; }
|
|
|
|
+ var attributeNamesOrOptions = [BABYLON.VertexBuffer.PositionKind, BABYLON.VertexBuffer.ColorKind, "angle", "offset", "size"];
|
|
|
|
+ if (isAnimationSheetEnabled) {
|
|
|
|
+ attributeNamesOrOptions.push("cellIndex");
|
|
|
|
+ }
|
|
|
|
+ if (!isBillboardBased) {
|
|
|
|
+ attributeNamesOrOptions.push("direction");
|
|
|
|
+ }
|
|
|
|
+ return attributeNamesOrOptions;
|
|
|
|
+ };
|
|
|
|
+ ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
|
|
|
|
+ if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
|
|
|
|
+ var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "textureMask"];
|
|
|
|
+ if (isAnimationSheetEnabled) {
|
|
|
|
+ effectCreationOption.push("particlesInfos");
|
|
|
|
+ }
|
|
|
|
+ return effectCreationOption;
|
|
|
|
+ };
|
|
ParticleSystem.prototype._getEffect = function () {
|
|
ParticleSystem.prototype._getEffect = function () {
|
|
if (this._customEffect) {
|
|
if (this._customEffect) {
|
|
return this._customEffect;
|
|
return this._customEffect;
|
|
@@ -56011,15 +56053,8 @@ var BABYLON;
|
|
var join = defines.join("\n");
|
|
var join = defines.join("\n");
|
|
if (this._cachedDefines !== join) {
|
|
if (this._cachedDefines !== join) {
|
|
this._cachedDefines = join;
|
|
this._cachedDefines = join;
|
|
- var attributesNamesOrOptions = [BABYLON.VertexBuffer.PositionKind, BABYLON.VertexBuffer.ColorKind, "angle", "offset", "size"];
|
|
|
|
- var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "textureMask"];
|
|
|
|
- if (this._isAnimationSheetEnabled) {
|
|
|
|
- attributesNamesOrOptions.push("cellIndex");
|
|
|
|
- effectCreationOption.push("particlesInfos");
|
|
|
|
- }
|
|
|
|
- if (!this._isBillboardBased) {
|
|
|
|
- attributesNamesOrOptions.push("direction");
|
|
|
|
- }
|
|
|
|
|
|
+ var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased);
|
|
|
|
+ var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
|
|
this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, ["diffuseSampler"], join);
|
|
this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, ["diffuseSampler"], join);
|
|
}
|
|
}
|
|
return this._effect;
|
|
return this._effect;
|
|
@@ -64988,6 +65023,9 @@ var BABYLON;
|
|
};
|
|
};
|
|
VideoTexture.CreateFromWebCam = function (scene, onReady, constraints) {
|
|
VideoTexture.CreateFromWebCam = function (scene, onReady, constraints) {
|
|
var video = document.createElement("video");
|
|
var video = document.createElement("video");
|
|
|
|
+ video.setAttribute('autoplay', '');
|
|
|
|
+ video.setAttribute('muted', '');
|
|
|
|
+ video.setAttribute('playsinline', '');
|
|
var constraintsDeviceId;
|
|
var constraintsDeviceId;
|
|
if (constraints && constraints.deviceId) {
|
|
if (constraints && constraints.deviceId) {
|
|
constraintsDeviceId = {
|
|
constraintsDeviceId = {
|