diff --git a/visualization/app/codeCharta/services/3DExports/serialize3mf.service.spec.ts b/visualization/app/codeCharta/services/3DExports/serialize3mf.service.spec.ts
index fd66cc1728..d47b22c198 100644
--- a/visualization/app/codeCharta/services/3DExports/serialize3mf.service.spec.ts
+++ b/visualization/app/codeCharta/services/3DExports/serialize3mf.service.spec.ts
@@ -62,7 +62,8 @@ describe("serialize3mf service", () => {
vertexIndexToNewVertexIndex = new Map()
vertexIndexes = [0, 1, 2]
testMesh = new Mesh()
- testMesh.geometry.attributes["position"] = new BufferAttribute(new Float32Array(testVertexPositions), 3, false)
+ testMesh.geometry.attributes["position"] = new BufferAttribute(new Float32Array(testVertexPositions), 3)
+ testMesh.matrix.makeScale(2, 2, 2)
})
it("should create correct vertex entries", () => {
@@ -72,6 +73,56 @@ describe("serialize3mf service", () => {
expect(vertexIndexToNewVertexIndex.size).toBe(3)
expect(vertexToNewVertexIndex.size).toBe(3)
expect([...vertexToNewVertexIndex.keys()].toString()).toBe(vertices.toString())
+ const expectedPositions = [
+ [0, 0, 0],
+ [4, 0, 0],
+ [0, 4, 0]
+ ]
+ for (const xyzPos of expectedPositions) {
+ expect(vertices).toContain(``)
+ }
+ })
+
+ it("should apply parent matrix if present", () => {
+ parentMatrix = new Matrix4()
+ parentMatrix.setPosition(1, 1, 1)
+
+ constructVertices(vertices, vertexToNewVertexIndex, vertexIndexToNewVertexIndex, vertexIndexes, testMesh, parentMatrix)
+
+ expect(vertices).toHaveLength(3)
+ expect(vertexIndexToNewVertexIndex.size).toBe(3)
+ expect(vertexToNewVertexIndex.size).toBe(3)
+ expect([...vertexToNewVertexIndex.keys()].toString()).toBe(vertices.toString())
+ const expectedPositions = [
+ [1, 1, 1],
+ [5, 1, 1],
+ [1, 5, 1]
+ ]
+ for (const xyzPos of expectedPositions) {
+ expect(vertices).toContain(``)
+ }
+ })
+
+ it("should not add new entries to indexLookup but vertexLookup if repeated information", () => {
+ const testDoubleVertexPositions = [...testVertexPositions, ...testVertexPositions]
+ const doubleMesh = new Mesh()
+ doubleMesh.geometry.attributes["position"] = new BufferAttribute(new Float32Array(testDoubleVertexPositions), 3)
+ const longerIndex = [1, 2, 3, 4, 5, 6]
+
+ constructVertices(vertices, vertexToNewVertexIndex, vertexIndexToNewVertexIndex, longerIndex, doubleMesh, parentMatrix)
+
+ expect(vertices).toHaveLength(3)
+ expect(vertexIndexToNewVertexIndex.size).toBe(6)
+ expect(vertexToNewVertexIndex.size).toBe(3)
+ expect([...vertexToNewVertexIndex.keys()].toString()).toBe(vertices.toString())
+ const expectedPositions = [
+ [0, 0, 0],
+ [2, 0, 0],
+ [0, 2, 0]
+ ]
+ for (const xyzPos of expectedPositions) {
+ expect(vertices).toContain(``)
+ }
})
})