import { observer } from "mobx-react-lite"; import type { ObjectType, RuntimeObjectInstance } from "../types"; import { forwardRef, useMemo } from "react"; import type { Group } from "three"; import { Instance, Instances } from "@react-three/drei"; import type { ThreeEvent } from "@react-three/fiber"; import { state } from "../state"; import { TrimeshCollider } from "@react-three/rapier"; import { SyncRigidBody } from "./SyncRigidBody"; import { runInAction } from "mobx"; import { buildObjectTrimesh } from "../utils/graphics/mesh"; type ObjectViewInternalProps = { object: Omit; objectType: ObjectType; onClick?: (e: ThreeEvent) => void; } export const ObjectViewInternal = observer(forwardRef( function ({ object, objectType, onClick }, ref) { const trimeshArgs = useMemo( () => buildObjectTrimesh(objectType, state.world.data.voxelTypes), // eslint-disable-next-line react-hooks/exhaustive-deps [objectType.id] ); return ( { runInAction(() => { const obj = state.game?.scene.objects[object.id]; if (obj) { obj.position = data.position; obj.rotation = data.rotation; obj.linearVelocity = data.linearVelocity; obj.radialVelocity = data.radialVelocity; } }); }} > { object.cache.voxelGroups.map((vg) => {vg.positions.map((pos, i) => )} ) } {trimeshArgs && } ); } ));