(obj: unknown, key: string)
| 339 | container.removeChild(canvas); |
| 340 | } |
| 341 | const callIfFn = (obj: unknown, key: string) => { |
| 342 | const fn = obj && (obj as Record<string, unknown>)[key]; |
| 343 | if (typeof fn === 'function') { |
| 344 | (fn as () => void).call(obj); |
| 345 | } |
| 346 | }; |
| 347 | callIfFn(programRef.current, 'remove'); |
| 348 | callIfFn(geometryRef.current, 'remove'); |
| 349 | callIfFn(meshRef.current, 'remove'); |