|
@@ -3663,6 +3663,7 @@ var BABYLON;
|
|
|
this._loadedTexturesCache = new Array();
|
|
|
this._activeTexturesCache = new Array();
|
|
|
this._compiledEffects = {};
|
|
|
+ this._uintIndicesCurrentlySet = false;
|
|
|
this._renderingCanvas = canvas;
|
|
|
this._canvasClientRect = this._renderingCanvas.getBoundingClientRect();
|
|
|
|
|
@@ -3712,6 +3713,7 @@ var BABYLON;
|
|
|
this._caps.textureAnisotropicFilterExtension = this._gl.getExtension('EXT_texture_filter_anisotropic') || this._gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic') || this._gl.getExtension('MOZ_EXT_texture_filter_anisotropic');
|
|
|
this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
|
|
|
this._caps.instancedArrays = this._gl.getExtension('ANGLE_instanced_arrays');
|
|
|
+ this._caps.uintIndices = this._gl.getExtension('OES_element_index_uint') !== null;
|
|
|
|
|
|
|
|
|
this.setDepthBuffer(true);
|
|
@@ -4015,6 +4017,7 @@ var BABYLON;
|
|
|
};
|
|
|
|
|
|
Engine.prototype.restoreDefaultFramebuffer = function () {
|
|
|
+ this._currentRenderTarget = null;
|
|
|
this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, null);
|
|
|
|
|
|
this.setViewport(this._cachedViewport);
|
|
@@ -4070,9 +4073,28 @@ var BABYLON;
|
|
|
Engine.prototype.createIndexBuffer = function (indices) {
|
|
|
var vbo = this._gl.createBuffer();
|
|
|
this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, vbo);
|
|
|
- this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), this._gl.STATIC_DRAW);
|
|
|
+
|
|
|
+
|
|
|
+ var arrayBuffer;
|
|
|
+ var need32Bits = false;
|
|
|
+
|
|
|
+ if (this._caps.uintIndices) {
|
|
|
+ for (var index = 0; index < indices.length; index++) {
|
|
|
+ if (indices[index] > 65535) {
|
|
|
+ need32Bits = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
|
|
|
+ } else {
|
|
|
+ arrayBuffer = new Uint16Array(indices);
|
|
|
+ }
|
|
|
+
|
|
|
+ this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.STATIC_DRAW);
|
|
|
this._resetIndexBufferBinding();
|
|
|
vbo.references = 1;
|
|
|
+ vbo.is32Bits = need32Bits;
|
|
|
return vbo;
|
|
|
};
|
|
|
|
|
@@ -4097,6 +4119,7 @@ var BABYLON;
|
|
|
if (this._cachedIndexBuffer !== indexBuffer) {
|
|
|
this._cachedIndexBuffer = indexBuffer;
|
|
|
this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
|
|
|
+ this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -4125,6 +4148,7 @@ var BABYLON;
|
|
|
if (indexBuffer != null && this._cachedIndexBuffer !== indexBuffer) {
|
|
|
this._cachedIndexBuffer = indexBuffer;
|
|
|
this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
|
|
|
+ this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -4184,12 +4208,13 @@ var BABYLON;
|
|
|
this.applyStates();
|
|
|
|
|
|
|
|
|
+ var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
|
|
|
if (instancesCount) {
|
|
|
- this._caps.instancedArrays.drawElementsInstancedANGLE(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2, instancesCount);
|
|
|
+ this._caps.instancedArrays.drawElementsInstancedANGLE(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, indexFormat, indexStart * 2, instancesCount);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2);
|
|
|
+ this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, indexFormat, indexStart * 2);
|
|
|
};
|
|
|
|
|
|
Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
|
|
@@ -9608,7 +9633,7 @@ var BABYLON;
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
var VertexBuffer = (function () {
|
|
|
- function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation) {
|
|
|
+ function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride) {
|
|
|
if (engine instanceof BABYLON.Mesh) {
|
|
|
this._engine = engine.getScene().getEngine();
|
|
|
} else {
|
|
@@ -9625,6 +9650,11 @@ var BABYLON;
|
|
|
|
|
|
this._kind = kind;
|
|
|
|
|
|
+ if (stride) {
|
|
|
+ this._strideSize = stride;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
switch (kind) {
|
|
|
case VertexBuffer.PositionKind:
|
|
|
this._strideSize = 3;
|
|
@@ -10896,7 +10926,7 @@ var BABYLON;
|
|
|
this.synchronizeInstances();
|
|
|
};
|
|
|
|
|
|
- Mesh.prototype.setVerticesData = function (kind, data, updatable) {
|
|
|
+ Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
|
|
|
if (kind instanceof Array) {
|
|
|
var temp = data;
|
|
|
data = kind;
|
|
@@ -10913,7 +10943,7 @@ var BABYLON;
|
|
|
|
|
|
new BABYLON.Geometry(BABYLON.Geometry.RandomId(), scene, vertexData, updatable, this);
|
|
|
} else {
|
|
|
- this._geometry.setVerticesData(kind, data, updatable);
|
|
|
+ this._geometry.setVerticesData(kind, data, updatable, stride);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -25987,17 +26017,17 @@ var BABYLON;
|
|
|
vertexData.applyToGeometry(this, updatable);
|
|
|
};
|
|
|
|
|
|
- Geometry.prototype.setVerticesData = function (kind, data, updatable) {
|
|
|
+ Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
|
|
|
this._vertexBuffers = this._vertexBuffers || {};
|
|
|
|
|
|
if (this._vertexBuffers[kind]) {
|
|
|
this._vertexBuffers[kind].dispose();
|
|
|
}
|
|
|
|
|
|
- this._vertexBuffers[kind] = new BABYLON.VertexBuffer(this._engine, data, kind, updatable, this._meshes.length === 0);
|
|
|
+ this._vertexBuffers[kind] = new BABYLON.VertexBuffer(this._engine, data, kind, updatable, this._meshes.length === 0, stride);
|
|
|
|
|
|
if (kind === BABYLON.VertexBuffer.PositionKind) {
|
|
|
- var stride = this._vertexBuffers[kind].getStrideSize();
|
|
|
+ stride = this._vertexBuffers[kind].getStrideSize();
|
|
|
|
|
|
this._totalVertices = data.length / stride;
|
|
|
|