Last active
April 21, 2023 11:39
-
-
Save lanmower/a5ca8c43aab634f88dcb368b87001438 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useRef, useEffect } from 'react' | |
import { useWorld, useSyncState, randomInt } from 'hyperfy' | |
export const blenderVec3 = ([x, y, z]) => [x, z, -y] | |
const headOffset = [ | |
[0,0,0],[0,0,0],[0,0,0] | |
] | |
export default function Heads() { | |
const world = useWorld() | |
const headRef = [useRef(), useRef(), useRef()] | |
useEffect(() => { | |
return world.onUpdate(delta => { | |
if(world.isClient) { | |
headRef[0].current?.setPosition([-0.65, 0, -1]); | |
headRef[1].current?.setPosition([-0.65, -0.65, -1.3]); | |
headRef[2].current?.setPosition([-0.65, 0.65, -0.7]); | |
} | |
}) | |
}, []) | |
return ( | |
<app> | |
<model | |
key={1} | |
ref={headRef[0]} | |
src="whackhead.glb" | |
position={headOffset[0]} | |
/> | |
<model | |
key={1} | |
ref={headRef[1]} | |
src="whackhead.glb" | |
position={headOffset[1]} | |
/> | |
<model | |
key={1} | |
ref={headRef[2]} | |
src="whackhead.glb" | |
position={headOffset[2]} | |
/> | |
</app> | |
) | |
} | |
const initialState = { | |
heads: [0,0,0,0,0,0,0,0,0], | |
} | |
export function getStore(state = initialState) { | |
return { | |
state, | |
actions: { | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment