(nodes: ReadonlyArray<SceneNode>)
| 38 | const MAX_NODE_COUNT_PREVIEW = 1200; |
| 39 | const MAX_NODE_COUNT_HARD = 4000; |
| 40 | const countNodes = (nodes: ReadonlyArray<SceneNode>) => { |
| 41 | let count = 0; |
| 42 | const stack = [...nodes]; |
| 43 | while (stack.length > 0) { |
| 44 | const node = stack.pop()!; |
| 45 | count += 1; |
| 46 | if ("children" in node && Array.isArray(node.children)) { |
| 47 | for (const child of node.children) { |
| 48 | stack.push(child); |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | return count; |
| 53 | }; |
| 54 | |
| 55 | const nodeCount = countNodes(selection); |
| 56 | if (nodeCount > MAX_NODE_COUNT_HARD) { |