(connections)
| 2071 | }); |
| 2072 | |
| 2073 | const createMesh = (connections) => { |
| 2074 | if (!connections.length) return null; |
| 2075 | const mesh = new THREE.InstancedMesh(baseGeometry.clone(), connectionMaterial.clone(), connections.length); |
| 2076 | mesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage); |
| 2077 | const colorAttribute = new THREE.InstancedBufferAttribute(new Float32Array(connections.length * 3), 3); |
| 2078 | colorAttribute.setUsage(THREE.DynamicDrawUsage); |
| 2079 | mesh.instanceColor = colorAttribute; |
| 2080 | connections.forEach((connection, index) => { |
| 2081 | const direction = connection.targetPosition.clone().sub(connection.sourcePosition); |
| 2082 | const length = direction.length(); |
| 2083 | if (length <= 0) { |
| 2084 | return; |
| 2085 | } |
| 2086 | const midpoint = connection.sourcePosition.clone().addScaledVector(direction, 0.5); |
| 2087 | this.tempObject.position.copy(midpoint); |
| 2088 | this.tempQuaternion.setFromUnitVectors(this.upVector, direction.clone().normalize()); |
| 2089 | this.tempObject.quaternion.copy(this.tempQuaternion); |
| 2090 | this.tempObject.scale.set(1, length, 1); |
| 2091 | this.tempObject.updateMatrix(); |
| 2092 | mesh.setMatrixAt(index, this.tempObject.matrix); |
| 2093 | mesh.setColorAt(index, this.tempColor.setRGB(0.8, 0.8, 0.8)); |
| 2094 | }); |
| 2095 | mesh.instanceMatrix.needsUpdate = true; |
| 2096 | mesh.instanceColor.needsUpdate = true; |
| 2097 | return mesh; |
| 2098 | }; |
| 2099 | |
| 2100 | if (data.incoming.length) { |
| 2101 | const mesh = createMesh(data.incoming); |
nothing calls this directly
no outgoing calls
no test coverage detected