メインコンテンツまでスキップ

<pc-render>

<pc-render>タグは、プリミティブ形状 — ボックス、球、カプセル、円錐、円柱、平面、トーラス — をマテリアルで描画するレンダーコンポーネントを追加します。

使用法

属性​

属性タイプデフォルト説明
cast-shadowsBoolean"true"コンポーネントが影を落とすかどうか
enabledBoolean"true"コンポーネントの有効状態
materialMaterial ID-プリミティブのレンダリングに使用する <pc-material> の id。省略した場合はデフォルトのマテリアルが使用されます
receive-shadowsBoolean"true"コンポーネントが影を受け取るかどうか
shadow-cascade-maskString"0 1 2 3"コンポーネントがディレクショナルライトのどのシャドウカスケードに影を落とすか。0(カメラに最も近い)から3までのカスケード番号をスペース区切りで指定します。"0 1"は近い2つのカスケードにのみ影を落とし、空の値はどのカスケードにも落としません。cast-shadowsが必要です
typeEnum"box"レンダリングするプリミティブの形状: "box" | "capsule" | "cone" | "cylinder" | "plane" | "sphere" | "torus"
ヒント

glTF/GLBファイルから3Dモデルをレンダリングするには、代わりに <pc-model> を使用してください。

例​

7種類のプリミティブ形状すべてです。任意の type を変更してみましょう。<pc-material> を定義すれば material も追加できます:

ライブサンプル
<pc-app>
<pc-scene>
<pc-entity name="camera" position="0 1.5 7" rotation="-10 0 0">
<pc-camera clear-color="#2a2d36"></pc-camera>
</pc-entity>
<pc-entity name="light" rotation="45 30 0">
<pc-light cast-shadows normal-offset-bias="0.05" shadow-bias="0.2" intensity="1.5"></pc-light>
</pc-entity>
<pc-entity name="box" position="-3.5 0.5 0">
<pc-render type="box"></pc-render>
</pc-entity>
<pc-entity name="sphere" position="-2.1 0.5 0">
<pc-render type="sphere"></pc-render>
</pc-entity>
<pc-entity name="capsule" position="-0.7 1 0">
<pc-render type="capsule"></pc-render>
</pc-entity>
<pc-entity name="cone" position="0.7 0.5 0">
<pc-render type="cone"></pc-render>
</pc-entity>
<pc-entity name="cylinder" position="2.1 0.5 0">
<pc-render type="cylinder"></pc-render>
</pc-entity>
<pc-entity name="torus" position="3.5 0.5 0" rotation="90 0 0">
<pc-render type="torus"></pc-render>
</pc-entity>
<pc-entity name="ground" scale="10 10 10">
<pc-render type="plane"></pc-render>
</pc-entity>
</pc-scene>
</pc-app>

JavaScriptインターフェース​

RenderComponentElement APIを使用して、<pc-render>要素をプログラムで作成および操作できます。

componentプロパティは、この要素が追加するエンジンのRenderComponentです。要素の準備が完了するまではnullで、属性が公開していないものはすべてここから利用できます。

関連項目​

  • <pc-material> — プリミティブを描くマテリアル
  • <pc-model> — プリミティブの代わりにGLBをレンダリングします
  • <pc-light> — プリミティブに光と影を当てます
  • <pc-collision> — 対応する物理形状

サンプル: Basic Shapes、Falling Blocks、Physics Joints