mesh.Flatten
by MaxenceBrasselet
HTML
<script src="https://rawgit.com/MaxenceBrasselet/Babylon.js/master/babylon.1.11.js"></script>
<div id="rootDiv">
<canvas id="renderCanvas"></canvas>
</div>
CSS
html, body, div, canvas {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
overflow: hidden;
}
JavaScript
BABYLON.Tools.Log = {};
BABYLON.Tools.Log.Level = {
LOG: 1, // Do a console.log.
WARN: 2, // Do a console.warn.
ERROR: 4, // Do a console.error.
};
BABYLON.Tools.Log.enableFor = BABYLON.Tools.Log.Level.LOG | BABYLON.Tools.Log.Level.WARN | BABYLON.Tools.Log.Level.ERROR;
BABYLON.Tools.Log.log = function(level, message) {
var levelActive = (level & BABYLON.Tools.Log.enableFor);
// LevelActive === 0 mean the level was not activated.
if (!message || levelActive === 0) {
return;
}
switch (levelActive) {
case BABYLON.Tools.Log.Level.WARN:
console.warn(message);
break;
case BABYLON.Tools.Log.Level.ERROR:
console.error(message);
break;
case BABYLON.Tools.Log.Level.LOG:
console.log(message);
break;
}
};
// If we have more than 65535 vertices (WebGL limitation) we should cut our mesh.
BABYLON.Mesh.VERTICESLIMITATION = 65535;
BABYLON.Mesh.prototype.isSynchronized = function() {
if (this.billboardMode !== BABYLON.Mesh.BILLBOARDMODE_NONE)
return false;
if (this._cache.pivotMatrixUpdated) {
return false;
}
if (this.infiniteDistance) {
return false;
}
if (!this._cache.position.equals(this.position))
return false;
if (this.rotationQuaternion) {
if (!this._cache.rotationQuaternion.equals(this.rotationQuaternion))
return false;
} else {
if (!this._cache.rotation.equals(this.rotation))
return false;
}
if (!this._cache.scaling.equals(this.scaling))
return false;
// if (this.parent)
// return !this.parent._needToSynchonizeChildren();
return true;
};
BABYLON.Mesh.prototype.computeWorldMatrix = function (force) {
if (!force && this.isSynchronized() && this._currentRenderId == this._scene.getRenderId()) {
this._childrenFlag = false;
return this._worldMatrix;
...