mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 11:17:05 +02:00
32 lines
732 B
TypeScript
32 lines
732 B
TypeScript
import { MeshProps } from '@react-three/fiber';
|
|
import { Mesh, Object3D } from 'three';
|
|
|
|
export function jsxTree(node: Object3D, mesh?: MeshProps, key?: string) {
|
|
if (node instanceof Mesh) {
|
|
return (
|
|
<mesh
|
|
key={key}
|
|
geometry={node.geometry}
|
|
material={node.material}
|
|
position={node.position}
|
|
rotation={node.rotation}
|
|
scale={node.scale}
|
|
{...mesh}
|
|
/>
|
|
);
|
|
} else if (node instanceof Object3D) {
|
|
return (
|
|
<group
|
|
key={key}
|
|
position={node.position}
|
|
rotation={node.rotation}
|
|
scale={node.scale}
|
|
>
|
|
{node.children.map((child) => jsxTree(child, mesh, child.uuid))}
|
|
</group>
|
|
);
|
|
}
|
|
|
|
return null;
|
|
}
|