|
@@ -26402,6 +26402,8 @@ var PickingInfo = /** @class */ (function () {
|
|
this.subMeshId = 0;
|
|
this.subMeshId = 0;
|
|
/** If a sprite was picked, this will be the sprite the pick collided with */
|
|
/** If a sprite was picked, this will be the sprite the pick collided with */
|
|
this.pickedSprite = null;
|
|
this.pickedSprite = null;
|
|
|
|
+ /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
|
|
|
|
+ this.thinInstanceIndex = -1;
|
|
/**
|
|
/**
|
|
* If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
|
|
* If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
|
|
*/
|
|
*/
|
|
@@ -27899,8 +27901,8 @@ var Ray = /** @class */ (function () {
|
|
*/
|
|
*/
|
|
Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
|
|
Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
|
|
if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
|
|
if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
|
|
- var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
|
|
|
|
- var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
|
|
|
|
|
|
+ var newMinimum = Ray._TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
|
|
|
|
+ var newMaximum = Ray._TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
|
|
var d = 0.0;
|
|
var d = 0.0;
|
|
var maxValue = Number.MAX_VALUE;
|
|
var maxValue = Number.MAX_VALUE;
|
|
var inv;
|
|
var inv;
|
|
@@ -28021,11 +28023,11 @@ var Ray = /** @class */ (function () {
|
|
* @returns intersection information if hit
|
|
* @returns intersection information if hit
|
|
*/
|
|
*/
|
|
Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
|
|
Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
|
|
- var edge1 = Ray.TmpVector3[0];
|
|
|
|
- var edge2 = Ray.TmpVector3[1];
|
|
|
|
- var pvec = Ray.TmpVector3[2];
|
|
|
|
- var tvec = Ray.TmpVector3[3];
|
|
|
|
- var qvec = Ray.TmpVector3[4];
|
|
|
|
|
|
+ var edge1 = Ray._TmpVector3[0];
|
|
|
|
+ var edge2 = Ray._TmpVector3[1];
|
|
|
|
+ var pvec = Ray._TmpVector3[2];
|
|
|
|
+ var tvec = Ray._TmpVector3[3];
|
|
|
|
+ var qvec = Ray._TmpVector3[4];
|
|
vertex1.subtractToRef(vertex0, edge1);
|
|
vertex1.subtractToRef(vertex0, edge1);
|
|
vertex2.subtractToRef(vertex0, edge2);
|
|
vertex2.subtractToRef(vertex0, edge2);
|
|
_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
|
|
_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
|
|
@@ -28367,7 +28369,7 @@ var Ray = /** @class */ (function () {
|
|
farVec3.subtractToRef(nearVec3, this.direction);
|
|
farVec3.subtractToRef(nearVec3, this.direction);
|
|
this.direction.normalize();
|
|
this.direction.normalize();
|
|
};
|
|
};
|
|
- Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
|
|
|
|
|
|
+ Ray._TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
|
|
Ray.smallnum = 0.00000001;
|
|
Ray.smallnum = 0.00000001;
|
|
Ray.rayl = 10e8;
|
|
Ray.rayl = 10e8;
|
|
return Ray;
|
|
return Ray;
|
|
@@ -28421,6 +28423,17 @@ _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraS
|
|
result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
|
|
result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
|
|
return this;
|
|
return this;
|
|
};
|
|
};
|
|
|
|
+_scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPickForMesh = function (pickingInfo, rayFunction, mesh, world, fastCheck, onlyBoundingInfo, trianglePredicate) {
|
|
|
|
+ var ray = rayFunction(world);
|
|
|
|
+ var result = mesh.intersects(ray, fastCheck, trianglePredicate, onlyBoundingInfo, world);
|
|
|
|
+ if (!result || !result.hit) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+};
|
|
_scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck, onlyBoundingInfo, trianglePredicate) {
|
|
_scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck, onlyBoundingInfo, trianglePredicate) {
|
|
if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
|
|
if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
|
|
return null;
|
|
return null;
|
|
@@ -28436,18 +28449,29 @@ _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function
|
|
else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
|
|
else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- var world = mesh.skeleton && mesh.skeleton.overrideMesh ? mesh.skeleton.overrideMesh.getWorldMatrix() : mesh.getWorldMatrix();
|
|
|
|
- var ray = rayFunction(world);
|
|
|
|
- var result = mesh.intersects(ray, fastCheck, trianglePredicate, onlyBoundingInfo);
|
|
|
|
- if (!result || !result.hit) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
|
|
|
|
- continue;
|
|
|
|
|
|
+ if (mesh.hasThinInstances && mesh.thinInstanceEnablePicking) {
|
|
|
|
+ var thinMatrices = mesh.thinInstanceGetWorldMatrices();
|
|
|
|
+ for (var index = 0; index < thinMatrices.length; index++) {
|
|
|
|
+ var world = thinMatrices[index];
|
|
|
|
+ var result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, world, fastCheck, onlyBoundingInfo, trianglePredicate);
|
|
|
|
+ if (result) {
|
|
|
|
+ pickingInfo = result;
|
|
|
|
+ pickingInfo.thinInstanceIndex = index;
|
|
|
|
+ if (fastCheck) {
|
|
|
|
+ return pickingInfo;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- pickingInfo = result;
|
|
|
|
- if (fastCheck) {
|
|
|
|
- break;
|
|
|
|
|
|
+ else {
|
|
|
|
+ var world = mesh.skeleton && mesh.skeleton.overrideMesh ? mesh.skeleton.overrideMesh.getWorldMatrix() : mesh.getWorldMatrix();
|
|
|
|
+ var result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, world, fastCheck, onlyBoundingInfo, trianglePredicate);
|
|
|
|
+ if (result) {
|
|
|
|
+ pickingInfo = result;
|
|
|
|
+ if (fastCheck) {
|
|
|
|
+ return pickingInfo;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
|
|
return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
|
|
@@ -28467,13 +28491,24 @@ _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalMultiPick = func
|
|
else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
|
|
else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- var world = mesh.getWorldMatrix();
|
|
|
|
- var ray = rayFunction(world);
|
|
|
|
- var result = mesh.intersects(ray, false, trianglePredicate);
|
|
|
|
- if (!result || !result.hit) {
|
|
|
|
- continue;
|
|
|
|
|
|
+ if (mesh.hasThinInstances && mesh.thinInstanceEnablePicking) {
|
|
|
|
+ var thinMatrices = mesh.thinInstanceGetWorldMatrices();
|
|
|
|
+ for (var index = 0; index < thinMatrices.length; index++) {
|
|
|
|
+ var world = thinMatrices[index];
|
|
|
|
+ var result = this._internalPickForMesh(null, rayFunction, mesh, world, false, false, trianglePredicate);
|
|
|
|
+ if (result) {
|
|
|
|
+ result.thinInstanceIndex = index;
|
|
|
|
+ pickingInfos.push(result);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ var world = mesh.skeleton && mesh.skeleton.overrideMesh ? mesh.skeleton.overrideMesh.getWorldMatrix() : mesh.getWorldMatrix();
|
|
|
|
+ var result = this._internalPickForMesh(null, rayFunction, mesh, world, false, false, trianglePredicate);
|
|
|
|
+ if (result) {
|
|
|
|
+ pickingInfos.push(result);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- pickingInfos.push(result);
|
|
|
|
}
|
|
}
|
|
return pickingInfos;
|
|
return pickingInfos;
|
|
};
|
|
};
|
|
@@ -118858,10 +118893,11 @@ var AbstractMesh = /** @class */ (function (_super) {
|
|
* @param fastCheck defines if fast mode (but less precise) must be used (false by default)
|
|
* @param fastCheck defines if fast mode (but less precise) must be used (false by default)
|
|
* @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
|
|
* @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
|
|
* @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
|
|
* @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
|
|
|
|
+ * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
|
|
* @returns the picking info
|
|
* @returns the picking info
|
|
* @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
|
|
* @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
|
|
*/
|
|
*/
|
|
- AbstractMesh.prototype.intersects = function (ray, fastCheck, trianglePredicate, onlyBoundingInfo) {
|
|
|
|
|
|
+ AbstractMesh.prototype.intersects = function (ray, fastCheck, trianglePredicate, onlyBoundingInfo, worldToUse) {
|
|
if (onlyBoundingInfo === void 0) { onlyBoundingInfo = false; }
|
|
if (onlyBoundingInfo === void 0) { onlyBoundingInfo = false; }
|
|
var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
|
|
var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
|
|
var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
|
|
var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
|
|
@@ -118901,7 +118937,7 @@ var AbstractMesh = /** @class */ (function (_super) {
|
|
}
|
|
}
|
|
if (intersectInfo) {
|
|
if (intersectInfo) {
|
|
// Get picked point
|
|
// Get picked point
|
|
- var world = this.skeleton && this.skeleton.overrideMesh ? this.skeleton.overrideMesh.getWorldMatrix() : this.getWorldMatrix();
|
|
|
|
|
|
+ var world = worldToUse !== null && worldToUse !== void 0 ? worldToUse : (this.skeleton && this.skeleton.overrideMesh ? this.skeleton.overrideMesh.getWorldMatrix() : this.getWorldMatrix());
|
|
var worldOrigin = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[0];
|
|
var worldOrigin = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[0];
|
|
var direction = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[1];
|
|
var direction = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["TmpVectors"].Vector3[1];
|
|
_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
|
|
_Maths_math_vector__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
|
|
@@ -123610,6 +123646,7 @@ var _ThinInstanceDataStorage = /** @class */ (function () {
|
|
this.matrixBuffer = null;
|
|
this.matrixBuffer = null;
|
|
this.matrixBufferSize = 32 * 16; // let's start with a maximum of 32 thin instances
|
|
this.matrixBufferSize = 32 * 16; // let's start with a maximum of 32 thin instances
|
|
this.boundingVectors = [];
|
|
this.boundingVectors = [];
|
|
|
|
+ this.worldMatrices = null;
|
|
}
|
|
}
|
|
return _ThinInstanceDataStorage;
|
|
return _ThinInstanceDataStorage;
|
|
}());
|
|
}());
|
|
@@ -131032,6 +131069,9 @@ _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.thinInstanceSetMatri
|
|
}
|
|
}
|
|
var matrixData = this._thinInstanceDataStorage.matrixData;
|
|
var matrixData = this._thinInstanceDataStorage.matrixData;
|
|
matrix.copyToArray(matrixData, index * 16);
|
|
matrix.copyToArray(matrixData, index * 16);
|
|
|
|
+ if (this._thinInstanceDataStorage.worldMatrices) {
|
|
|
|
+ this._thinInstanceDataStorage.worldMatrices[index] = matrix;
|
|
|
|
+ }
|
|
if (refresh) {
|
|
if (refresh) {
|
|
this.thinInstanceBufferUpdated("matrix");
|
|
this.thinInstanceBufferUpdated("matrix");
|
|
if (!this.doNotSyncBoundingInfo) {
|
|
if (!this.doNotSyncBoundingInfo) {
|
|
@@ -131076,6 +131116,7 @@ _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.thinInstanceSetBuffe
|
|
this._thinInstanceDataStorage.matrixBuffer = null;
|
|
this._thinInstanceDataStorage.matrixBuffer = null;
|
|
this._thinInstanceDataStorage.matrixBufferSize = buffer ? buffer.length : 32 * stride;
|
|
this._thinInstanceDataStorage.matrixBufferSize = buffer ? buffer.length : 32 * stride;
|
|
this._thinInstanceDataStorage.matrixData = buffer;
|
|
this._thinInstanceDataStorage.matrixData = buffer;
|
|
|
|
+ this._thinInstanceDataStorage.worldMatrices = null;
|
|
if (buffer !== null) {
|
|
if (buffer !== null) {
|
|
this._thinInstanceDataStorage.instancesCount = buffer.length / stride;
|
|
this._thinInstanceDataStorage.instancesCount = buffer.length / stride;
|
|
var matrixBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"](this.getEngine(), buffer, !staticBuffer, stride, false, true);
|
|
var matrixBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"](this.getEngine(), buffer, !staticBuffer, stride, false, true);
|
|
@@ -131127,6 +131168,19 @@ _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.thinInstanceBufferUp
|
|
this._userThinInstanceBuffersStorage.vertexBuffers[kind].updateDirectly(this._userThinInstanceBuffersStorage.data[kind], 0);
|
|
this._userThinInstanceBuffersStorage.vertexBuffers[kind].updateDirectly(this._userThinInstanceBuffersStorage.data[kind], 0);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+_Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.thinInstanceGetWorldMatrices = function () {
|
|
|
|
+ if (!this._thinInstanceDataStorage.matrixData || !this._thinInstanceDataStorage.matrixBuffer) {
|
|
|
|
+ return [];
|
|
|
|
+ }
|
|
|
|
+ var matrixData = this._thinInstanceDataStorage.matrixData;
|
|
|
|
+ if (!this._thinInstanceDataStorage.worldMatrices) {
|
|
|
|
+ this._thinInstanceDataStorage.worldMatrices = new Array();
|
|
|
|
+ for (var i = 0; i < this._thinInstanceDataStorage.instancesCount; ++i) {
|
|
|
|
+ this._thinInstanceDataStorage.worldMatrices[i] = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(matrixData, i * 16);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return this._thinInstanceDataStorage.worldMatrices;
|
|
|
|
+};
|
|
_Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.thinInstanceRefreshBoundingInfo = function (forceRefreshParentInfo) {
|
|
_Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.thinInstanceRefreshBoundingInfo = function (forceRefreshParentInfo) {
|
|
if (forceRefreshParentInfo === void 0) { forceRefreshParentInfo = false; }
|
|
if (forceRefreshParentInfo === void 0) { forceRefreshParentInfo = false; }
|
|
if (!this._thinInstanceDataStorage.matrixData || !this._thinInstanceDataStorage.matrixBuffer) {
|
|
if (!this._thinInstanceDataStorage.matrixData || !this._thinInstanceDataStorage.matrixBuffer) {
|