@playcanvas/react
Version:
A React renderer for PlayCanvas – build interactive 3D applications using React's declarative paradigm.
38 lines (37 loc) • 1.26 kB
TypeScript
import { FC } from "react";
import { Asset, type RenderComponent as PcRenderComponent } from "playcanvas";
import { PublicProps } from "../utils/types-utils.ts";
/**
* A Render component allows an entity to render a 3D model. You can specify the type of model to render with the `type` prop,
* which can be a primitive shape, or a model asset.
*
* @param {RenderProps} props - The props to pass to the render component.
* @see https://api.playcanvas.com/engine/classes/RenderComponent.html
*
* @example
* const { data: asset } = useAsset('./statue.glb')
* <Entity name='Box' >
* <Render type="box" />
* </Entity>
*
* @example
* <Entity name='asset'>
* <Render type="asset" asset={asset} />
* </Entity>
*/
export declare const Render: FC<RenderProps>;
declare const primitiveTypes: readonly ["asset", "box", "capsule", "cone", "cylinder", "plane", "sphere", "torus"];
type PrimitiveType = typeof primitiveTypes[number];
interface RenderProps extends Omit<Partial<PublicProps<PcRenderComponent>>, 'asset'> {
/**
* The type of primitive shape to render.
* @default "box"
*/
type: PrimitiveType;
/**
* The asset to render.
*/
asset?: Asset;
children?: React.ReactNode;
}
export default Render;