|
@@ -10040,7 +10040,7 @@ var BABYLON;
|
|
|
var minLODIndex = offset; // roughness = 0
|
|
|
var maxLODIndex = BABYLON.Scalar.Log2(width) * scale + offset; // roughness = 1
|
|
|
var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
|
|
|
- var mipmapIndex = Math.min(Math.max(Math.round(lodIndex), 0), maxLODIndex);
|
|
|
+ var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
|
|
|
var glTextureFromLod = gl.createTexture();
|
|
|
glTextureFromLod.isCube = true;
|
|
|
_this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod);
|
|
@@ -24859,23 +24859,24 @@ var BABYLON;
|
|
|
Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
|
|
|
var _this = this;
|
|
|
var subMesh = new BABYLON.BaseSubMesh();
|
|
|
- var scene = this.getScene();
|
|
|
- var engine = scene.getEngine();
|
|
|
- var beforeRenderCallback = function () {
|
|
|
+ var engine = this.getScene().getEngine();
|
|
|
+ var checkReady = function () {
|
|
|
if (subMesh._materialDefines) {
|
|
|
subMesh._materialDefines._renderId = -1;
|
|
|
}
|
|
|
var alphaTestState = engine.getAlphaTesting();
|
|
|
engine.setAlphaTesting(options ? options.alphaTest : _this.needAlphaTesting());
|
|
|
if (_this.isReadyForSubMesh(mesh, subMesh)) {
|
|
|
- scene.unregisterBeforeRender(beforeRenderCallback);
|
|
|
if (onCompiled) {
|
|
|
onCompiled(_this);
|
|
|
}
|
|
|
}
|
|
|
+ else {
|
|
|
+ setTimeout(checkReady, 16);
|
|
|
+ }
|
|
|
engine.setAlphaTesting(alphaTestState);
|
|
|
};
|
|
|
- scene.registerBeforeRender(beforeRenderCallback);
|
|
|
+ checkReady();
|
|
|
};
|
|
|
Material.prototype.markAsDirty = function (flag) {
|
|
|
if (flag & Material.TextureDirtyFlag) {
|
|
@@ -28506,9 +28507,11 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
if (parsedGeometry.matricesWeights) {
|
|
|
+ Geometry._CleanMatricesWeights(parsedGeometry.matricesWeights, parsedGeometry.numBoneInfluencers);
|
|
|
mesh.setVerticesData(BABYLON.VertexBuffer.MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
|
|
|
}
|
|
|
if (parsedGeometry.matricesWeightsExtra) {
|
|
|
+ Geometry._CleanMatricesWeights(parsedGeometry.matricesWeightsExtra, parsedGeometry.numBoneInfluencers);
|
|
|
mesh.setVerticesData(BABYLON.VertexBuffer.MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
|
|
|
}
|
|
|
mesh.setIndices(parsedGeometry.indices);
|
|
@@ -28533,6 +28536,16 @@ var BABYLON;
|
|
|
scene['_selectionOctree'].addMesh(mesh);
|
|
|
}
|
|
|
};
|
|
|
+ Geometry._CleanMatricesWeights = function (matricesWeights, influencers) {
|
|
|
+ var size = matricesWeights.length;
|
|
|
+ for (var i = 0; i < size; i += influencers) {
|
|
|
+ var weight = 0;
|
|
|
+ for (var j = 0; j < influencers - 1; j++) {
|
|
|
+ weight += matricesWeights[i + j];
|
|
|
+ }
|
|
|
+ matricesWeights[i + (influencers - 1)] = Math.max(0, 1.0 - weight);
|
|
|
+ }
|
|
|
+ };
|
|
|
Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
|
|
|
if (scene.getGeometryByID(parsedVertexData.id)) {
|
|
|
return null; // null since geometry could be something else than a box...
|
|
@@ -38102,6 +38115,7 @@ var BABYLON;
|
|
|
_this._floats = {};
|
|
|
_this._floatsArrays = {};
|
|
|
_this._colors3 = {};
|
|
|
+ _this._colors3Arrays = {};
|
|
|
_this._colors4 = {};
|
|
|
_this._vectors2 = {};
|
|
|
_this._vectors3 = {};
|
|
@@ -38166,6 +38180,14 @@ var BABYLON;
|
|
|
this._colors3[name] = value;
|
|
|
return this;
|
|
|
};
|
|
|
+ ShaderMaterial.prototype.setColor3Array = function (name, value) {
|
|
|
+ this._checkUniform(name);
|
|
|
+ this._colors3Arrays[name] = value.reduce(function (arr, color) {
|
|
|
+ color.toArray(arr, arr.length);
|
|
|
+ return arr;
|
|
|
+ }, []);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
ShaderMaterial.prototype.setColor4 = function (name, value) {
|
|
|
this._checkUniform(name);
|
|
|
this._colors4[name] = value;
|
|
@@ -38340,6 +38362,9 @@ var BABYLON;
|
|
|
for (name in this._colors3) {
|
|
|
this._effect.setColor3(name, this._colors3[name]);
|
|
|
}
|
|
|
+ for (name in this._colors3Arrays) {
|
|
|
+ this._effect.setArray3(name, this._colors3Arrays[name]);
|
|
|
+ }
|
|
|
// Color4
|
|
|
for (name in this._colors4) {
|
|
|
var color = this._colors4[name];
|
|
@@ -38463,6 +38488,11 @@ var BABYLON;
|
|
|
for (name in this._colors3) {
|
|
|
serializationObject.colors3[name] = this._colors3[name].asArray();
|
|
|
}
|
|
|
+ // Color3 array
|
|
|
+ serializationObject.colors3Arrays = {};
|
|
|
+ for (name in this._colors3Arrays) {
|
|
|
+ serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
|
|
|
+ }
|
|
|
// Color4
|
|
|
serializationObject.colors4 = {};
|
|
|
for (name in this._colors4) {
|
|
@@ -38533,6 +38563,19 @@ var BABYLON;
|
|
|
for (name in source.colors3) {
|
|
|
material.setColor3(name, BABYLON.Color3.FromArray(source.colors3[name]));
|
|
|
}
|
|
|
+ // Color3 arrays
|
|
|
+ for (name in source.colors3Arrays) {
|
|
|
+ var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
|
|
|
+ if (i % 3 === 0) {
|
|
|
+ arr.push([num]);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ arr[arr.length - 1].push(num);
|
|
|
+ }
|
|
|
+ return arr;
|
|
|
+ }, []).map(function (color) { return BABYLON.Color3.FromArray(color); });
|
|
|
+ material.setColor3Array(name, colors);
|
|
|
+ }
|
|
|
// Color4
|
|
|
for (name in source.colors4) {
|
|
|
material.setColor4(name, BABYLON.Color4.FromArray(source.colors4[name]));
|
|
@@ -52063,11 +52106,11 @@ var BABYLON;
|
|
|
}
|
|
|
else {
|
|
|
var material = _this._gltf.materials[primitive.material];
|
|
|
- _this.addPendingData(material);
|
|
|
_this.loadMaterial(material, function (babylonMaterial, isNew) {
|
|
|
if (isNew && _this._parent.onMaterialLoaded) {
|
|
|
_this._parent.onMaterialLoaded(babylonMaterial);
|
|
|
}
|
|
|
+ _this.addPendingData(material);
|
|
|
babylonMaterial.forceCompilation(babylonMesh, function (babylonMaterial) {
|
|
|
babylonMultiMaterial.subMaterials[i] = babylonMaterial;
|
|
|
_this.removePendingData(material);
|