21 lines
592 B
TypeScript
21 lines
592 B
TypeScript
import * as THREE from 'three';
|
|
|
|
export default function objectLinesToArray(structuredObjects: any): any {
|
|
if (!Array.isArray(structuredObjects)) {
|
|
return [];
|
|
}
|
|
|
|
return structuredObjects.map((structuredObject) => {
|
|
if (!structuredObject || !structuredObject.line) {
|
|
return [];
|
|
}
|
|
|
|
const { layer, type, line } = structuredObject;
|
|
|
|
return line.map(({ position, uuid }: any) => {
|
|
const vector = new THREE.Vector3(position.x, position.y, position.z);
|
|
return [vector, uuid, layer, type];
|
|
});
|
|
});
|
|
}
|