|
@@ -20,15 +20,10 @@ const positionVector = Vec3.zero()
|
|
|
const normalVector = Vec3.zero()
|
|
|
const torsionVector = Vec3.zero()
|
|
|
|
|
|
-const arrowVerticalVector = Vec3.zero()
|
|
|
const p1 = Vec3.zero()
|
|
|
const p2 = Vec3.zero()
|
|
|
const p3 = Vec3.zero()
|
|
|
const p4 = Vec3.zero()
|
|
|
-const p5 = Vec3.zero()
|
|
|
-const p6 = Vec3.zero()
|
|
|
-const p7 = Vec3.zero()
|
|
|
-const p8 = Vec3.zero()
|
|
|
|
|
|
export function addSheet(controlPoints: ArrayLike<number>, normalVectors: ArrayLike<number>, binormalVectors: ArrayLike<number>, linearSegments: number, width: number, height: number, arrowHeight: number, startCap: boolean, endCap: boolean, state: MeshBuilderState) {
|
|
|
const { vertices, normals, indices } = state
|
|
@@ -121,7 +116,7 @@ export function addSheet(controlPoints: ArrayLike<number>, normalVectors: ArrayL
|
|
|
vertexCount = vertices.elementCount
|
|
|
|
|
|
Vec3.fromArray(verticalVector, normalVectors, offset)
|
|
|
- Vec3.scale(verticalVector, verticalVector, height);
|
|
|
+ Vec3.scale(verticalVector, verticalVector, arrowHeight === 0 ? height : arrowHeight);
|
|
|
|
|
|
Vec3.fromArray(horizontalVector, binormalVectors, offset)
|
|
|
Vec3.scale(horizontalVector, horizontalVector, width);
|
|
@@ -140,36 +135,11 @@ export function addSheet(controlPoints: ArrayLike<number>, normalVectors: ArrayL
|
|
|
|
|
|
Vec3.cross(normalVector, horizontalVector, verticalVector)
|
|
|
|
|
|
- if (arrowHeight === 0) {
|
|
|
- for (let i = 0; i < 4; ++i) {
|
|
|
- ChunkedArray.add3(normals, normalVector[0], normalVector[1], normalVector[2])
|
|
|
- }
|
|
|
-
|
|
|
- ChunkedArray.add3(indices, vertexCount + 2, vertexCount + 1, vertexCount);
|
|
|
- ChunkedArray.add3(indices, vertexCount, vertexCount + 3, vertexCount + 2);
|
|
|
- } else {
|
|
|
- Vec3.fromArray(arrowVerticalVector, normalVectors, offset)
|
|
|
- Vec3.scale(arrowVerticalVector, verticalVector, arrowHeight);
|
|
|
-
|
|
|
- Vec3.add(p5, Vec3.add(p5, positionVector, horizontalVector), arrowVerticalVector)
|
|
|
- Vec3.sub(p6, Vec3.add(p6, positionVector, horizontalVector), arrowVerticalVector)
|
|
|
- Vec3.sub(p7, Vec3.sub(p7, positionVector, horizontalVector), arrowVerticalVector)
|
|
|
- Vec3.add(p8, Vec3.sub(p8, positionVector, horizontalVector), arrowVerticalVector)
|
|
|
-
|
|
|
- ChunkedArray.add3(vertices, p5[0], p5[1], p5[2])
|
|
|
- ChunkedArray.add3(vertices, p6[0], p6[1], p6[2])
|
|
|
- ChunkedArray.add3(vertices, p7[0], p7[1], p7[2])
|
|
|
- ChunkedArray.add3(vertices, p8[0], p8[1], p8[2])
|
|
|
-
|
|
|
- for (let i = 0; i < 8; ++i) {
|
|
|
- ChunkedArray.add3(normals, normalVector[0], normalVector[1], normalVector[2])
|
|
|
- }
|
|
|
-
|
|
|
- ChunkedArray.add3(indices, vertexCount + 7, vertexCount, vertexCount + 4);
|
|
|
- ChunkedArray.add3(indices, vertexCount + 7, vertexCount + 3, vertexCount);
|
|
|
- ChunkedArray.add3(indices, vertexCount + 5, vertexCount + 1, vertexCount + 6);
|
|
|
- ChunkedArray.add3(indices, vertexCount + 1, vertexCount + 2, vertexCount + 6);
|
|
|
+ for (let i = 0; i < 4; ++i) {
|
|
|
+ ChunkedArray.add3(normals, normalVector[0], normalVector[1], normalVector[2])
|
|
|
}
|
|
|
+ ChunkedArray.add3(indices, vertexCount + 2, vertexCount + 1, vertexCount);
|
|
|
+ ChunkedArray.add3(indices, vertexCount, vertexCount + 3, vertexCount + 2);
|
|
|
}
|
|
|
|
|
|
if (endCap && arrowHeight === 0) {
|
|
@@ -199,10 +169,9 @@ export function addSheet(controlPoints: ArrayLike<number>, normalVectors: ArrayL
|
|
|
for (let i = 0; i < 4; ++i) {
|
|
|
ChunkedArray.add3(normals, normalVector[0], normalVector[1], normalVector[2])
|
|
|
}
|
|
|
-
|
|
|
ChunkedArray.add3(indices, vertexCount + 2, vertexCount + 1, vertexCount);
|
|
|
ChunkedArray.add3(indices, vertexCount, vertexCount + 3, vertexCount + 2);
|
|
|
}
|
|
|
|
|
|
- return (linearSegments + 1) * 8 + (startCap ? (arrowHeight === 0 ? 4 : 8) : 0) + (endCap && arrowHeight === 0 ? 4 : 0)
|
|
|
+ return (linearSegments + 1) * 8 + (startCap ? 4 : 0) + (endCap && arrowHeight === 0 ? 4 : 0)
|
|
|
}
|