<pc-render>
<pc-render> 添加渲染组件,用材质绘制基本形状:盒体、球体、胶囊体、圆锥、圆柱、平面或圆环。
用法
- 必须直接位于
<pc-entity>、<pc-model>或<pc-node>下。
属性
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
cast-shadows | Boolean(布尔) | "true" | 是否投射阴影 |
clip-intersection | Boolean(布尔) | "false" | 仅裁去位于所有裁剪平面背后的交集,而非任一平面背后。两平面可切楔形,三平面可切角 |
clipping-planes | Planes(平面) | - | 世界空间裁剪平面,可剖开图元而保留其他场景。原点盒体设置 "0 -1 0 0, 0 0 -1 0" 并启用 clip-intersection,可切去四分之一。背向法线的一侧不渲染、不投影且不可拾取,最多 8 个平面。摄像机整体裁剪请使用 <pc-camera> 的同名属性 |
enabled | Boolean(布尔) | "true" | 组件启用状态 |
material | 材质 ID | - | 引用 <pc-material>,省略使用默认材质 |
receive-shadows | Boolean(布尔) | "true" | 是否接收阴影 |
shadow-cascade-mask | String(字符串) | "0 1 2 3" | 参与哪些平行光阴影级联,空格分隔索引 0(最近)到 3。0 1 仅参与最近两级,空值不参与,需启用 cast-shadows |
type | Enum(枚举) | "box" | 图元:"box" | "capsule" | "cone" | "cylinder" | "plane" | "sphere" | "torus" |
提示
渲染 glTF/GLB 模型请改用 <pc-model>。
示例
全部七种形状。可修改 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创建和操作元素。
component 是底层 RenderComponent,就绪前为 null,其余功能可通过它访问。
另请参阅
<pc-material>:图元材质。<pc-model>:渲染 GLB 模型。<pc-light>:光照和阴影。<pc-collision>:匹配的物理形状。