mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
fix: use new model format
This commit is contained in:
1 parent
1c3e98678f
commit
c68df74943
5 files changed
+108
-185
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { MeshProps } from '@react-three/fiber';
|
||||
import { Mesh, Object3D } from 'three';
|
||||
|
||||
export function jsxTree(node: Object3D, mesh?: MeshProps) {
|
||||
if (node instanceof Mesh) {
|
||||
return (
|
||||
<mesh
|
||||
geometry={node.geometry}
|
||||
material={node.material}
|
||||
position={node.position}
|
||||
rotation={node.rotation}
|
||||
scale={node.scale}
|
||||
{...mesh}
|
||||
/>
|
||||
);
|
||||
} else if (node instanceof Object3D) {
|
||||
return (
|
||||
<group
|
||||
position={node.position}
|
||||
rotation={node.rotation}
|
||||
scale={node.scale}
|
||||
>
|
||||
{node.children.map((child) => jsxTree(child, mesh))}
|
||||
</group>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
import { Mesh, Object3D } from 'three';
|
||||
|
||||
export function resolveJsxTree(parent: Object3D) {
|
||||
return parent.children.map((child) => {
|
||||
if (child.type === 'Mesh') {
|
||||
return (
|
||||
<mesh
|
||||
key={child.uuid}
|
||||
castShadow
|
||||
receiveShadow
|
||||
geometry={(child as Mesh).geometry}
|
||||
material={(child as Mesh).material}
|
||||
position={child.position}
|
||||
rotation={child.rotation}
|
||||
scale={child.scale}
|
||||
children={resolveJsxTree(child)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (child.type === 'Object3D') {
|
||||
return (
|
||||
<group
|
||||
key={child.uuid}
|
||||
position={child.position}
|
||||
rotation={child.rotation}
|
||||
scale={child.scale}
|
||||
children={resolveJsxTree(child)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
throw new TypeError(
|
||||
`Unhandled three jsx type ${child.type} (${child.name})`,
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user