|
@@ -404,11 +404,28 @@ export class SubMesh extends BaseSubMesh implements ICullable {
|
|
|
private _intersectTriangles(ray: Ray, positions: Vector3[], indices: IndicesArray,
|
|
|
fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo> {
|
|
|
var intersectInfo: Nullable<IntersectionInfo> = null;
|
|
|
+
|
|
|
+ var start = this.indexStart;
|
|
|
+ var count = this.indexCount;
|
|
|
+
|
|
|
+ if(!indices.length){
|
|
|
+ start = this.verticesStart;
|
|
|
+ count = this.verticesCount;
|
|
|
+ }
|
|
|
+
|
|
|
// Triangles test
|
|
|
- for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
|
|
|
- var p0 = positions[indices[index]];
|
|
|
- var p1 = positions[indices[index + 1]];
|
|
|
- var p2 = positions[indices[index + 2]];
|
|
|
+ var p0, p1, p2;
|
|
|
+ for (var index = start; index < start + count; index += 3) {
|
|
|
+ if(!indices.length){
|
|
|
+ p0 = positions[index];
|
|
|
+ p1 = positions[index + 1];
|
|
|
+ p2 = positions[index + 2];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ p0 = positions[indices[index]];
|
|
|
+ p1 = positions[indices[index + 1]];
|
|
|
+ p2 = positions[indices[index + 2]];
|
|
|
+ }
|
|
|
|
|
|
if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {
|
|
|
continue;
|
|
@@ -518,4 +535,4 @@ export class SubMesh extends BaseSubMesh implements ICullable {
|
|
|
|
|
|
return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
|
|
|
}
|
|
|
-}
|
|
|
+}
|