跳到主要内容

<pc-render>

<pc-render> 添加渲染组件,用材质绘制基本形状:盒体、球体、胶囊体、圆锥、圆柱、平面或圆环。

用法

属性​

属性类型默认值说明
cast-shadowsBoolean(布尔)"true"是否投射阴影
clip-intersectionBoolean(布尔)"false"仅裁去位于所有裁剪平面背后的交集,而非任一平面背后。两平面可切楔形,三平面可切角
clipping-planesPlanes(平面)-世界空间裁剪平面,可剖开图元而保留其他场景。原点盒体设置 "0 -1 0 0, 0 0 -1 0" 并启用 clip-intersection,可切去四分之一。背向法线的一侧不渲染、不投影且不可拾取,最多 8 个平面。摄像机整体裁剪请使用 <pc-camera> 的同名属性
enabledBoolean(布尔)"true"组件启用状态
material材质 ID-引用 <pc-material>,省略使用默认材质
receive-shadowsBoolean(布尔)"true"是否接收阴影
shadow-cascade-maskString(字符串)"0 1 2 3"参与哪些平行光阴影级联,空格分隔索引 0(最近)到 3。0 1 仅参与最近两级,空值不参与,需启用 cast-shadows
typeEnum(枚举)"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,其余功能可通过它访问。

另请参阅​

示例:基本形状、下落方块、物理关节和裁剪平面。