<Entity/>
<Entity/> コンポーネントは React アプリケーションの基本的な構成要素です。シーングラフ階層のノードを表し、子として他の Entity を含めることができ、動作や外観を定義する Component も持つことができます。
import { Entity } from '@playcanvas/react'
export default function Scene() {
return (
<Entity>
<Entity name="child" />
<Entity name="other-child">
<Entity name="nested-child" />
</Entity>
</Entity>
)
}
<Entity/> はトランスフォームノードであり、位置、回転、スケールを持ちます。単体では動作を持ちません。レンダリングや物理への反応、カメラとしての動作を行うには、Component を使用して動作を追加する必要があります。
ヒント
<Entity/> 単体では動作を持ちません。<Entity/> に Component を追加することで動作を付与できます。Component は PlayCanvas における動作の構成要素です。
プロパティ
| Name | Type | Default |
|---|---|---|
name? | stringThe name of the entity | "Untitled" |
position? | [number, number, number]The local position of the entity relative to its parent.
You can use the `position` prop to set the position of the entity. | [0, 0, 0] |
scale? | [number, number, number]The local scale of the entity relative to its parent.
You can use the `scale` prop to set the scale of the entity. | [1, 1, 1] |
rotation? | [number, number, number]The local rotation of the entity relative to its parent.
The rotation is specified as euler angles in degrees. | [0, 0, 0] |
onPointerUp? | PointerEventCallbackThe callback for the pointer up event | null |
onPointerDown? | PointerEventCallbackThe callback for the pointer down event | null |
onPointerOver? | PointerEventCallbackThe callback for the pointer over event | null |
onPointerOut? | PointerEventCallbackThe callback for the pointer out event | null |
onClick? | MouseEventCallbackThe callback for the click event | null |
children? | ReactNode | - |
tags? | TagsInterface for tagging graph nodes. Tag based searches can be performed using the
findByTag function. | - |
enabled? | booleanSets the enabled state of the GraphNode. If one of the GraphNode's parents is disabled there
will be no other side effects. If all the parents are enabled then the new value will
activate or deactivate all the enabled children of the GraphNode.
Gets the enabled state of the GraphNode. | - |
ref? | Ref<Entity> | undefinedAllows getting a ref to the component instance.
Once the component unmounts, React will set `ref.current` to `null`
(or call the ref with `null` if you passed a callback ref). | - |
key? | Key | null | undefined | - |