|
@@ -147,7 +147,7 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
var extendStatics = function(d, b) {
|
|
|
extendStatics = Object.setPrototypeOf ||
|
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
|
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
|
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
|
return extendStatics(d, b);
|
|
|
};
|
|
|
|
|
@@ -241,8 +241,8 @@ var __createBinding = Object.create ? (function(o, m, k, k2) {
|
|
|
o[k2] = m[k];
|
|
|
});
|
|
|
|
|
|
-function __exportStar(m, o) {
|
|
|
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
|
|
|
+function __exportStar(m, exports) {
|
|
|
+ for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
|
}
|
|
|
|
|
|
function __values(o) {
|
|
@@ -332,7 +332,7 @@ var __setModuleDefault = Object.create ? (function(o, v) {
|
|
|
function __importStar(mod) {
|
|
|
if (mod && mod.__esModule) return mod;
|
|
|
var result = {};
|
|
|
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
|
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
|
__setModuleDefault(result, mod);
|
|
|
return result;
|
|
|
}
|
|
@@ -43858,6 +43858,40 @@ var NativeEngine = /** @class */ (function (_super) {
|
|
|
var imageData = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYSURBVChTY/z//z8DPsAEpXGC4aCAgQEAGGMDDWwwgqsAAAAASUVORK5CYII=';
|
|
|
this.createTexture('data:my_image_name', true, invertY, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, undefined, undefined, imageData, texture, NativeEngine.TEXTUREFORMAT_RGBA, null, undefined);
|
|
|
};
|
|
|
+ NativeEngine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
|
|
|
+ if (compression === void 0) { compression = null; }
|
|
|
+ if (type === void 0) { type = _constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
|
|
|
+ var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTextureSource"].Raw);
|
|
|
+ texture.generateMipMaps = generateMipMaps;
|
|
|
+ texture.samplingMode = samplingMode;
|
|
|
+ texture.invertY = invertY;
|
|
|
+ texture.baseWidth = width;
|
|
|
+ texture.baseHeight = height;
|
|
|
+ texture.width = texture.baseWidth;
|
|
|
+ texture.height = texture.baseHeight;
|
|
|
+ texture._compression = compression;
|
|
|
+ texture.type = type;
|
|
|
+ this.updateRawTexture(texture, data, format, invertY, compression, type);
|
|
|
+ if (texture._hardwareTexture) {
|
|
|
+ var webGLTexture = texture._hardwareTexture.underlyingResource;
|
|
|
+ var filter = this._getNativeSamplingMode(samplingMode);
|
|
|
+ this._native.setTextureSampling(webGLTexture, filter);
|
|
|
+ }
|
|
|
+ this._internalTexturesCache.push(texture);
|
|
|
+ return texture;
|
|
|
+ };
|
|
|
+ NativeEngine.prototype.updateRawTexture = function (texture, bufferView, format, invertY, compression, type) {
|
|
|
+ if (compression === void 0) { compression = null; }
|
|
|
+ if (type === void 0) { type = _constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
|
|
|
+ if (!texture) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (bufferView && texture._hardwareTexture) {
|
|
|
+ var webGLTexture = texture._hardwareTexture.underlyingResource;
|
|
|
+ this._native.loadRawTexture(webGLTexture, bufferView, texture.width, texture.height, this._getNativeTextureFormat(format, type), texture.generateMipMaps, texture.invertY);
|
|
|
+ }
|
|
|
+ texture.isReady = true;
|
|
|
+ };
|
|
|
// TODO: Refactor to share more logic with babylon.engine.ts version.
|
|
|
/**
|
|
|
* Usually called from Texture.ts.
|
|
@@ -44387,7 +44421,10 @@ var NativeEngine = /** @class */ (function (_super) {
|
|
|
}
|
|
|
};
|
|
|
NativeEngine.prototype._getNativeTextureFormat = function (format, type) {
|
|
|
- if (format == _constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTUREFORMAT_RGBA && type == _constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
|
|
|
+ if (format == _constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTUREFORMAT_RGB && type == _constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
|
|
|
+ return this._native.TEXTURE_FORMAT_RGB8;
|
|
|
+ }
|
|
|
+ else if (format == _constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTUREFORMAT_RGBA && type == _constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
|
|
|
return this._native.TEXTURE_FORMAT_RGBA8;
|
|
|
}
|
|
|
else if (format == _constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTUREFORMAT_RGBA && type == _constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT) {
|
|
@@ -46818,7 +46855,7 @@ var ThinEngine = /** @class */ (function () {
|
|
|
this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
|
|
|
}
|
|
|
};
|
|
|
- ThinEngine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
|
|
|
+ ThinEngine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect, overrideVertexBuffers) {
|
|
|
var attributes = effect.getAttributesNames();
|
|
|
if (!this._vaoRecordInProgress) {
|
|
|
this._unbindVertexArrayObject();
|
|
@@ -46827,7 +46864,14 @@ var ThinEngine = /** @class */ (function () {
|
|
|
for (var index = 0; index < attributes.length; index++) {
|
|
|
var order = effect.getAttributeLocation(index);
|
|
|
if (order >= 0) {
|
|
|
- var vertexBuffer = vertexBuffers[attributes[index]];
|
|
|
+ var ai = attributes[index];
|
|
|
+ var vertexBuffer = null;
|
|
|
+ if (overrideVertexBuffers) {
|
|
|
+ vertexBuffer = overrideVertexBuffers[ai];
|
|
|
+ }
|
|
|
+ if (!vertexBuffer) {
|
|
|
+ vertexBuffer = vertexBuffers[ai];
|
|
|
+ }
|
|
|
if (!vertexBuffer) {
|
|
|
continue;
|
|
|
}
|
|
@@ -46855,14 +46899,15 @@ var ThinEngine = /** @class */ (function () {
|
|
|
* @param vertexBuffers defines the list of vertex buffers to store
|
|
|
* @param indexBuffer defines the index buffer to store
|
|
|
* @param effect defines the effect to store
|
|
|
+ * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
|
|
|
* @returns the new vertex array object
|
|
|
*/
|
|
|
- ThinEngine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
|
|
|
+ ThinEngine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect, overrideVertexBuffers) {
|
|
|
var vao = this._gl.createVertexArray();
|
|
|
this._vaoRecordInProgress = true;
|
|
|
this._gl.bindVertexArray(vao);
|
|
|
this._mustWipeVertexAttributes = true;
|
|
|
- this._bindVertexBuffersAttributes(vertexBuffers, effect);
|
|
|
+ this._bindVertexBuffersAttributes(vertexBuffers, effect, overrideVertexBuffers);
|
|
|
this.bindIndexBuffer(indexBuffer);
|
|
|
this._vaoRecordInProgress = false;
|
|
|
this._gl.bindVertexArray(null);
|
|
@@ -46926,12 +46971,13 @@ var ThinEngine = /** @class */ (function () {
|
|
|
* @param vertexBuffers defines the list of vertex buffers to bind
|
|
|
* @param indexBuffer defines the index buffer to bind
|
|
|
* @param effect defines the effect associated with the vertex buffers
|
|
|
+ * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
|
|
|
*/
|
|
|
- ThinEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
|
|
|
+ ThinEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect, overrideVertexBuffers) {
|
|
|
if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
|
|
|
this._cachedVertexBuffers = vertexBuffers;
|
|
|
this._cachedEffectForVertexBuffers = effect;
|
|
|
- this._bindVertexBuffersAttributes(vertexBuffers, effect);
|
|
|
+ this._bindVertexBuffersAttributes(vertexBuffers, effect, overrideVertexBuffers);
|
|
|
}
|
|
|
this._bindIndexBufferWithCache(indexBuffer);
|
|
|
};
|
|
@@ -47226,7 +47272,7 @@ var ThinEngine = /** @class */ (function () {
|
|
|
var gl = this._gl;
|
|
|
var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
|
|
|
if (!shader) {
|
|
|
- throw new Error("Something went wrong while compile the shader.");
|
|
|
+ throw new Error("Something went wrong while creating a gl " + type + " shader object. gl error=" + gl.getError());
|
|
|
}
|
|
|
gl.shaderSource(shader, source);
|
|
|
gl.compileShader(shader);
|
|
@@ -122641,12 +122687,13 @@ var Vector3 = /** @class */ (function () {
|
|
|
var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
|
|
|
var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
|
|
|
var dot = Vector3.Dot(v0, v1);
|
|
|
+ var angle = Math.acos(dot);
|
|
|
var n = MathTmp.Vector3[3];
|
|
|
Vector3.CrossToRef(v0, v1, n);
|
|
|
if (Vector3.Dot(n, normal) > 0) {
|
|
|
- return Math.acos(dot);
|
|
|
+ return isNaN(angle) ? 0 : angle;
|
|
|
}
|
|
|
- return -Math.acos(dot);
|
|
|
+ return isNaN(angle) ? -Math.PI : -Math.acos(dot);
|
|
|
};
|
|
|
/**
|
|
|
* Returns a new Vector3 set from the index "offset" of the given array
|
|
@@ -124532,6 +124579,29 @@ var Quaternion = /** @class */ (function () {
|
|
|
return result;
|
|
|
};
|
|
|
/**
|
|
|
+ * Updates a quaternion so that it rotates vector vecFrom to vector vecTo
|
|
|
+ * @param vecFrom defines the direction vector from which to rotate
|
|
|
+ * @param vecTo defines the direction vector to which to rotate
|
|
|
+ * @param result the quaternion to store the result
|
|
|
+ * @returns the updated quaternion
|
|
|
+ */
|
|
|
+ Quaternion.FromUnitVectorsToRef = function (vecFrom, vecTo, result) {
|
|
|
+ var r = Vector3.Dot(vecFrom, vecTo) + 1;
|
|
|
+ if (r < _math_constants__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]) {
|
|
|
+ if (Math.abs(vecFrom.x) > Math.abs(vecFrom.z)) {
|
|
|
+ result.set(-vecFrom.y, vecFrom.x, 0, 0);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ result.set(0, -vecFrom.z, vecFrom.y, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Vector3.CrossToRef(vecFrom, vecTo, TmpVectors.Vector3[0]);
|
|
|
+ result.set(TmpVectors.Vector3[0].x, TmpVectors.Vector3[0].y, TmpVectors.Vector3[0].z, r);
|
|
|
+ }
|
|
|
+ return result.normalize();
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Creates a new quaternion from the given Euler float angles (y, x, z)
|
|
|
* @param yaw defines the rotation around Y axis
|
|
|
* @param pitch defines the rotation around X axis
|
|
@@ -135813,6 +135883,9 @@ var Geometry = /** @class */ (function () {
|
|
|
this._vertexBuffers[kind].dispose();
|
|
|
delete this._vertexBuffers[kind];
|
|
|
}
|
|
|
+ if (this._vertexArrayObjects) {
|
|
|
+ this._disposeVertexArrayObjects();
|
|
|
+ }
|
|
|
};
|
|
|
/**
|
|
|
* Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
|
|
@@ -135826,6 +135899,8 @@ var Geometry = /** @class */ (function () {
|
|
|
this._vertexBuffers[kind].dispose();
|
|
|
}
|
|
|
this._vertexBuffers[kind] = buffer;
|
|
|
+ var meshes = this._meshes;
|
|
|
+ var numOfMeshes = meshes.length;
|
|
|
if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind) {
|
|
|
var data = buffer.getData();
|
|
|
if (totalVertices != null) {
|
|
@@ -135838,8 +135913,6 @@ var Geometry = /** @class */ (function () {
|
|
|
}
|
|
|
this._updateExtend(data);
|
|
|
this._resetPointsArrayCache();
|
|
|
- var meshes = this._meshes;
|
|
|
- var numOfMeshes = meshes.length;
|
|
|
for (var index = 0; index < numOfMeshes; index++) {
|
|
|
var mesh = meshes[index];
|
|
|
mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
|
|
@@ -135850,7 +135923,6 @@ var Geometry = /** @class */ (function () {
|
|
|
this.notifyUpdate(kind);
|
|
|
if (this._vertexArrayObjects) {
|
|
|
this._disposeVertexArrayObjects();
|
|
|
- this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
|
|
|
}
|
|
|
};
|
|
|
/**
|
|
@@ -135914,7 +135986,7 @@ var Geometry = /** @class */ (function () {
|
|
|
}
|
|
|
};
|
|
|
/** @hidden */
|
|
|
- Geometry.prototype._bind = function (effect, indexToBind) {
|
|
|
+ Geometry.prototype._bind = function (effect, indexToBind, overrideVertexBuffers, overrideVertexArrayObjects) {
|
|
|
if (!effect) {
|
|
|
return;
|
|
|
}
|
|
@@ -135925,15 +135997,16 @@ var Geometry = /** @class */ (function () {
|
|
|
if (!vbs) {
|
|
|
return;
|
|
|
}
|
|
|
- if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
|
|
|
- this._engine.bindBuffers(vbs, indexToBind, effect);
|
|
|
+ if (indexToBind != this._indexBuffer || (!this._vertexArrayObjects && !overrideVertexArrayObjects)) {
|
|
|
+ this._engine.bindBuffers(vbs, indexToBind, effect, overrideVertexBuffers);
|
|
|
return;
|
|
|
}
|
|
|
+ var vaos = overrideVertexArrayObjects ? overrideVertexArrayObjects : this._vertexArrayObjects;
|
|
|
// Using VAO
|
|
|
- if (!this._vertexArrayObjects[effect.key]) {
|
|
|
- this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
|
|
|
+ if (!vaos[effect.key]) {
|
|
|
+ vaos[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect, overrideVertexBuffers);
|
|
|
}
|
|
|
- this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
|
|
|
+ this._engine.bindVertexArrayObject(vaos[effect.key], indexToBind);
|
|
|
};
|
|
|
/**
|
|
|
* Gets total number of vertices
|
|
@@ -136103,7 +136176,6 @@ var Geometry = /** @class */ (function () {
|
|
|
if (this._indexBuffer) {
|
|
|
this._engine._releaseBuffer(this._indexBuffer);
|
|
|
}
|
|
|
- this._disposeVertexArrayObjects();
|
|
|
this._indices = indices;
|
|
|
this._indexBufferIsUpdatable = updatable;
|
|
|
if (this._meshes.length !== 0 && this._indices) {
|
|
@@ -136185,6 +136257,9 @@ var Geometry = /** @class */ (function () {
|
|
|
return;
|
|
|
}
|
|
|
meshes.splice(index, 1);
|
|
|
+ if (this._vertexArrayObjects) {
|
|
|
+ mesh._invalidateInstanceVertexArrayObject();
|
|
|
+ }
|
|
|
mesh._geometry = null;
|
|
|
if (meshes.length === 0 && shouldDispose) {
|
|
|
this.dispose();
|
|
@@ -136202,6 +136277,9 @@ var Geometry = /** @class */ (function () {
|
|
|
if (previousGeometry) {
|
|
|
previousGeometry.releaseForMesh(mesh);
|
|
|
}
|
|
|
+ if (this._vertexArrayObjects) {
|
|
|
+ mesh._invalidateInstanceVertexArrayObject();
|
|
|
+ }
|
|
|
var meshes = this._meshes;
|
|
|
// must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
|
|
|
mesh._geometry = this;
|
|
@@ -136381,7 +136459,12 @@ var Geometry = /** @class */ (function () {
|
|
|
for (var kind in this._vertexArrayObjects) {
|
|
|
this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
|
|
|
}
|
|
|
- this._vertexArrayObjects = {};
|
|
|
+ this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
|
|
|
+ var meshes = this._meshes;
|
|
|
+ var numOfMeshes = meshes.length;
|
|
|
+ for (var index = 0; index < numOfMeshes; index++) {
|
|
|
+ meshes[index]._invalidateInstanceVertexArrayObject();
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
/**
|
|
@@ -137852,8 +137935,6 @@ var InstancedMesh = /** @class */ (function (_super) {
|
|
|
|
|
|
_Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].prototype.edgesShareWithInstances = false;
|
|
|
_Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].prototype.registerInstancedBuffer = function (kind, stride) {
|
|
|
- // Remove existing one
|
|
|
- this.removeVerticesData(kind);
|
|
|
// Creates the instancedBuffer field if not present
|
|
|
if (!this.instancedBuffers) {
|
|
|
this.instancedBuffers = {};
|
|
@@ -137865,7 +137946,8 @@ _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].prototype.registerInstancedBuf
|
|
|
data: {},
|
|
|
vertexBuffers: {},
|
|
|
strides: {},
|
|
|
- sizes: {}
|
|
|
+ sizes: {},
|
|
|
+ vertexArrayObjects: (this.getEngine().getCaps().vertexArrayObject) ? {} : undefined
|
|
|
};
|
|
|
}
|
|
|
// Creates an empty property for this kind
|
|
@@ -137874,11 +137956,11 @@ _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].prototype.registerInstancedBuf
|
|
|
this._userInstancedBuffersStorage.sizes[kind] = stride * 32; // Initial size
|
|
|
this._userInstancedBuffersStorage.data[kind] = new Float32Array(this._userInstancedBuffersStorage.sizes[kind]);
|
|
|
this._userInstancedBuffersStorage.vertexBuffers[kind] = new _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"](this.getEngine(), this._userInstancedBuffersStorage.data[kind], kind, true, false, stride, true);
|
|
|
- this.setVerticesBuffer(this._userInstancedBuffersStorage.vertexBuffers[kind]);
|
|
|
for (var _b = 0, _c = this.instances; _b < _c.length; _b++) {
|
|
|
var instance = _c[_b];
|
|
|
instance.instancedBuffers[kind] = null;
|
|
|
}
|
|
|
+ this._invalidateInstanceVertexArrayObject();
|
|
|
};
|
|
|
_Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].prototype._processInstancedBuffers = function (visibleInstances, renderSelf) {
|
|
|
var instanceCount = visibleInstances.length;
|
|
@@ -137925,13 +138007,22 @@ _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].prototype._processInstancedBuf
|
|
|
// Update vertex buffer
|
|
|
if (!this._userInstancedBuffersStorage.vertexBuffers[kind]) {
|
|
|
this._userInstancedBuffersStorage.vertexBuffers[kind] = new _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"](this.getEngine(), this._userInstancedBuffersStorage.data[kind], kind, true, false, stride, true);
|
|
|
- this.setVerticesBuffer(this._userInstancedBuffersStorage.vertexBuffers[kind]);
|
|
|
+ this._invalidateInstanceVertexArrayObject();
|
|
|
}
|
|
|
else {
|
|
|
this._userInstancedBuffersStorage.vertexBuffers[kind].updateDirectly(data, 0);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+_Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].prototype._invalidateInstanceVertexArrayObject = function () {
|
|
|
+ if (!this._userInstancedBuffersStorage || this._userInstancedBuffersStorage.vertexArrayObjects === undefined) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (var kind in this._userInstancedBuffersStorage.vertexArrayObjects) {
|
|
|
+ this.getEngine().releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[kind]);
|
|
|
+ }
|
|
|
+ this._userInstancedBuffersStorage.vertexArrayObjects = {};
|
|
|
+};
|
|
|
_Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].prototype._disposeInstanceSpecificData = function () {
|
|
|
if (this._instanceDataStorage.instancesBuffer) {
|
|
|
this._instanceDataStorage.instancesBuffer.dispose();
|
|
@@ -137945,6 +138036,7 @@ _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].prototype._disposeInstanceSpec
|
|
|
this._userInstancedBuffersStorage.vertexBuffers[kind].dispose();
|
|
|
}
|
|
|
}
|
|
|
+ this._invalidateInstanceVertexArrayObject();
|
|
|
this.instancedBuffers = {};
|
|
|
};
|
|
|
|
|
@@ -139545,7 +139637,12 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
}
|
|
|
}
|
|
|
// VBOs
|
|
|
- this._geometry._bind(effect, indexToBind);
|
|
|
+ if (!this._userInstancedBuffersStorage) {
|
|
|
+ this._geometry._bind(effect, indexToBind);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this._geometry._bind(effect, indexToBind, this._userInstancedBuffersStorage.vertexBuffers, this._userInstancedBuffersStorage.vertexArrayObjects);
|
|
|
+ }
|
|
|
return this;
|
|
|
};
|
|
|
/** @hidden */
|
|
@@ -139683,10 +139780,19 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
}
|
|
|
instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_8__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
|
|
|
instanceStorage.instancesBuffer = instancesBuffer;
|
|
|
- this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
|
|
|
- this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
|
|
|
- this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
|
|
|
- this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
|
|
|
+ if (!this._userInstancedBuffersStorage) {
|
|
|
+ this._userInstancedBuffersStorage = {
|
|
|
+ data: {},
|
|
|
+ vertexBuffers: {},
|
|
|
+ strides: {},
|
|
|
+ sizes: {},
|
|
|
+ vertexArrayObjects: (this.getEngine().getCaps().vertexArrayObject) ? {} : undefined
|
|
|
+ };
|
|
|
+ }
|
|
|
+ this._userInstancedBuffersStorage.vertexBuffers["world0"] = instancesBuffer.createVertexBuffer("world0", 0, 4);
|
|
|
+ this._userInstancedBuffersStorage.vertexBuffers["world1"] = instancesBuffer.createVertexBuffer("world0", 4, 4);
|
|
|
+ this._userInstancedBuffersStorage.vertexBuffers["world2"] = instancesBuffer.createVertexBuffer("world0", 8, 4);
|
|
|
+ this._userInstancedBuffersStorage.vertexBuffers["world3"] = instancesBuffer.createVertexBuffer("world0", 12, 4);
|
|
|
}
|
|
|
else {
|
|
|
if (!this._instanceDataStorage.isFrozen) {
|
|
@@ -139766,6 +139872,19 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
this._instanceDataStorage.instancesBuffer.dispose();
|
|
|
this._instanceDataStorage.instancesBuffer = null;
|
|
|
}
|
|
|
+ if (this._userInstancedBuffersStorage) {
|
|
|
+ for (var kind in this._userInstancedBuffersStorage.vertexBuffers) {
|
|
|
+ var buffer = this._userInstancedBuffersStorage.vertexBuffers[kind];
|
|
|
+ if (buffer) {
|
|
|
+ // Dispose instance buffer to be recreated in _renderWithInstances when rendered
|
|
|
+ buffer.dispose();
|
|
|
+ this._userInstancedBuffersStorage.vertexBuffers[kind] = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (this._userInstancedBuffersStorage.vertexArrayObjects) {
|
|
|
+ this._userInstancedBuffersStorage.vertexArrayObjects = {};
|
|
|
+ }
|
|
|
+ }
|
|
|
_super.prototype._rebuild.call(this);
|
|
|
};
|
|
|
/** @hidden */
|
|
@@ -140322,6 +140441,10 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
Mesh.prototype._disposeThinInstanceSpecificData = function () {
|
|
|
// Do nothing
|
|
|
};
|
|
|
+ /** @hidden */
|
|
|
+ Mesh.prototype._invalidateInstanceVertexArrayObject = function () {
|
|
|
+ // Do nothing
|
|
|
+ };
|
|
|
/**
|
|
|
* Modifies the mesh geometry according to a displacement map.
|
|
|
* A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
|
|
@@ -140803,17 +140926,6 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
* @returns a new InstancedMesh
|
|
|
*/
|
|
|
Mesh.prototype.createInstance = function (name) {
|
|
|
- var geometry = this.geometry;
|
|
|
- if (geometry && geometry.meshes.length > 1) {
|
|
|
- var others = geometry.meshes.slice(0);
|
|
|
- for (var _i = 0, others_1 = others; _i < others_1.length; _i++) {
|
|
|
- var other = others_1[_i];
|
|
|
- if (other === this) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- other.makeGeometryUnique();
|
|
|
- }
|
|
|
- }
|
|
|
return Mesh._instancedMeshFactory(name, this);
|
|
|
};
|
|
|
/**
|
|
@@ -151966,7 +152078,7 @@ var EnvironmentTextureTools = /** @class */ (function () {
|
|
|
// Uncompress the data to a RTT
|
|
|
rgbdPostProcess.onApply = function (effect) {
|
|
|
effect._bindTexture("textureSampler", tempTexture_1);
|
|
|
- effect.setFloat2("scale", 1, 1);
|
|
|
+ effect.setFloat2("scale", 1, (image instanceof ImageBitmap) ? -1 : 1);
|
|
|
};
|
|
|
if (!engine.scenes.length) {
|
|
|
return;
|
|
@@ -152747,11 +152859,13 @@ var FilesInput = /** @class */ (function () {
|
|
|
/**
|
|
|
* Callback called when a file is processed
|
|
|
*/
|
|
|
- this.onProcessFileCallback = function () { return true; };
|
|
|
+ this.onProcessFileCallback = function () {
|
|
|
+ return true;
|
|
|
+ };
|
|
|
/**
|
|
|
* Function used when loading the scene file
|
|
|
*/
|
|
|
- this.loadAsync = function (sceneFile, onProgress) { return _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file", sceneFile, _this._engine, onProgress); };
|
|
|
+ this.loadAsync = function (sceneFile, onProgress) { return _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", sceneFile, _this._engine, onProgress); };
|
|
|
this._engine = engine;
|
|
|
this._currentScene = scene;
|
|
|
this._sceneLoadedCallback = sceneLoadedCallback;
|
|
@@ -152780,9 +152894,15 @@ var FilesInput = /** @class */ (function () {
|
|
|
var _this = this;
|
|
|
if (elementToMonitor) {
|
|
|
this._elementToMonitor = elementToMonitor;
|
|
|
- this._dragEnterHandler = function (e) { _this.drag(e); };
|
|
|
- this._dragOverHandler = function (e) { _this.drag(e); };
|
|
|
- this._dropHandler = function (e) { _this.drop(e); };
|
|
|
+ this._dragEnterHandler = function (e) {
|
|
|
+ _this.drag(e);
|
|
|
+ };
|
|
|
+ this._dragOverHandler = function (e) {
|
|
|
+ _this.drag(e);
|
|
|
+ };
|
|
|
+ this._dropHandler = function (e) {
|
|
|
+ _this.drop(e);
|
|
|
+ };
|
|
|
this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
|
|
|
this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
|
|
|
this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
|
|
@@ -152860,8 +152980,8 @@ var FilesInput = /** @class */ (function () {
|
|
|
var _this = this;
|
|
|
for (var i = 0; i < files.length; i++) {
|
|
|
var name = files[i].correctName.toLowerCase();
|
|
|
- var extension = name.split('.').pop();
|
|
|
- if (!this.onProcessFileCallback(files[i], name, extension, function (sceneFile) { return _this._sceneFileToLoad = sceneFile; })) {
|
|
|
+ var extension = name.split(".").pop();
|
|
|
+ if (!this.onProcessFileCallback(files[i], name, extension, function (sceneFile) { return (_this._sceneFileToLoad = sceneFile); })) {
|
|
|
continue;
|
|
|
}
|
|
|
if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].IsPluginForExtensionAvailable("." + extension)) {
|
|
@@ -152961,7 +153081,8 @@ var FilesInput = /** @class */ (function () {
|
|
|
}
|
|
|
_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].ShowLoadingScreen = false;
|
|
|
this._engine.displayLoadingUI();
|
|
|
- this.loadAsync(this._sceneFileToLoad, this._progressCallback).then(function (scene) {
|
|
|
+ this.loadAsync(this._sceneFileToLoad, this._progressCallback)
|
|
|
+ .then(function (scene) {
|
|
|
if (_this._currentScene) {
|
|
|
_this._currentScene.dispose();
|
|
|
}
|
|
@@ -152976,7 +153097,8 @@ var FilesInput = /** @class */ (function () {
|
|
|
_this.renderFunction();
|
|
|
});
|
|
|
});
|
|
|
- }).catch(function (error) {
|
|
|
+ })
|
|
|
+ .catch(function (error) {
|
|
|
_this._engine.hideLoadingUI();
|
|
|
if (_this._errorCallback) {
|
|
|
_this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
|