Files
blitzkit/src/core/blitzkrieg/jsxTree.tsx
T

31 lines
732 B
TypeScript
Raw Normal View History

2024-02-22 12:20:29 -06:00
import { MeshProps } from '@react-three/fiber';
import { Mesh, Object3D } from 'three';
2024-02-22 18:36:21 -06:00
export function jsxTree(node: Object3D, mesh?: MeshProps, key?: string) {
2024-02-22 12:20:29 -06:00
if (node instanceof Mesh) {
return (
<mesh
2024-02-22 18:36:21 -06:00
key={key}
2024-02-22 12:20:29 -06:00
geometry={node.geometry}
material={node.material}
position={node.position}
rotation={node.rotation}
scale={node.scale}
{...mesh}
/>
);
} else if (node instanceof Object3D) {
return (
<group
2024-02-22 18:36:21 -06:00
key={key}
2024-02-22 12:20:29 -06:00
position={node.position}
rotation={node.rotation}
scale={node.scale}
>
2024-02-22 18:36:21 -06:00
{node.children.map((child) => jsxTree(child, mesh, child.uuid))}
2024-02-22 12:20:29 -06:00
</group>
);
}
return null;
}