mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-16 14:16:00 +01:00
feat: i tried my best to implement dynamic armor :(
This commit is contained in:
1 parent
952523d3f9
commit
46f1461de6
9 files changed
+182
-92
No files matched your search
@@ -1,7 +1,14 @@
|
||||
import { MeshProps } from '@react-three/fiber';
|
||||
import { GroupProps, MeshProps } from '@react-three/fiber';
|
||||
import { Mesh, Object3D } from 'three';
|
||||
|
||||
export function jsxTree(node: Object3D, mesh?: MeshProps, key?: string) {
|
||||
export function jsxTree(
|
||||
node: Object3D,
|
||||
mergers?: {
|
||||
mesh?: MeshProps | ((mesh: Mesh) => MeshProps);
|
||||
group?: GroupProps | ((object3d: Object3D) => GroupProps);
|
||||
},
|
||||
key?: string,
|
||||
) {
|
||||
if (node instanceof Mesh) {
|
||||
return (
|
||||
<mesh
|
||||
@@ -11,7 +18,10 @@ export function jsxTree(node: Object3D, mesh?: MeshProps, key?: string) {
|
||||
position={node.position}
|
||||
rotation={node.rotation}
|
||||
scale={node.scale}
|
||||
{...mesh}
|
||||
{...(mergers?.mesh &&
|
||||
(typeof mergers.mesh === 'function'
|
||||
? mergers.mesh(node)
|
||||
: mergers.mesh))}
|
||||
/>
|
||||
);
|
||||
} else if (node instanceof Object3D) {
|
||||
@@ -21,8 +31,12 @@ export function jsxTree(node: Object3D, mesh?: MeshProps, key?: string) {
|
||||
position={node.position}
|
||||
rotation={node.rotation}
|
||||
scale={node.scale}
|
||||
{...(mergers?.group &&
|
||||
(typeof mergers.group === 'function'
|
||||
? mergers.group(node)
|
||||
: mergers.group))}
|
||||
>
|
||||
{node.children.map((child) => jsxTree(child, mesh, child.uuid))}
|
||||
{node.children.map((child) => jsxTree(child, mergers, child.uuid))}
|
||||
</group>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user