zyy-engine

图形引擎API


点光源

<h1>点光源</h1> <h2>点光源配置对象 - BCore.Viewer.Light.PointLightConfig</h2> <h3>构造函数</h3> <pre><code class="language-javascript">new BCore.Viewer.Light.PointLightConfig()</code></pre> <h3>属性</h3> <table> <thead> <tr> <th>参数名</th> <th>类型</th> <th>默认值</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td>color</td> <td>string</td> <td>&quot;#FFFFFF&quot;</td> <td>光源颜色</td> </tr> <tr> <td>intensity</td> <td>number</td> <td>1</td> <td>光源强度</td> </tr> <tr> <td>distance</td> <td>number</td> <td>100</td> <td>光源范围</td> </tr> <tr> <td>decay</td> <td>number</td> <td>2</td> <td>衰减</td> </tr> <tr> <td>position</td> <td>{ x: number, y: number, z: number }</td> <td>{ x: 0, y: 0, z: 20 }</td> <td>光源位置</td> </tr> <tr> <td>castShadow</td> <td>boolean</td> <td>false</td> <td>是否投射阴影</td> </tr> <tr> <td>mapSize</td> <td>number</td> <td>2048</td> <td>不宜过大</td> </tr> <tr> <td>radius</td> <td>number</td> <td>1.5</td> <td>光源半径</td> </tr> <tr> <td>bias</td> <td>number</td> <td>0.0001</td> <td>偏移量</td> </tr> <tr> <td>normalBias</td> <td>number</td> <td>2</td> <td>法线偏移</td> </tr> </tbody> </table> <ul> <li>详细说明请参考 <a href="https://threejs.org/docs/index.html?q=shad#api/en/lights/shadows/LightShadow">LightShadow API</a></li> </ul> <hr /> <h2>方法总览</h2> <ul> <li><code>addPointLight(id: string, lightConfig: PointLightConfig)</code> 添加点光源</li> <li><code>deletePointLight(id: string)</code> 删除点光源</li> <li><code>getPointLightConfig(id: string)</code> 获取点光源参数</li> <li><code>setPointLightConfig(id: string, config: PointLightConfig)</code> 设置点光源参数</li> <li><code>clearPointLights()</code> 清空所有点光源</li> </ul> <h2>方法示例</h2> <h3>1. 添加点光源</h3> <pre><code class="language-javascript">addPointLight(id: string, lightConfig: PointLightConfig)</code></pre> <h4>参数</h4> <table> <thead> <tr> <th>参数名</th> <th>必选</th> <th>类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td>id</td> <td>是</td> <td>string</td> <td>光源Id</td> </tr> <tr> <td>lightConfig</td> <td>是</td> <td>BCore.Viewer.Light.PointLightConfig</td> <td>光源参数</td> </tr> </tbody> </table> <h4>示例</h4> <pre><code class="language-javascript">let mPointLightConfig = new BCore.Viewer.Light.PointLightConfig(); mViewer3D.addPointLight('name', mPointLightConfig);</code></pre> <p>&lt;br&gt;</p> <h3>2. 删除点光源</h3> <pre><code class="language-javascript">deletePointLight(id: string)</code></pre> <h4>参数</h4> <table> <thead> <tr> <th>参数名</th> <th>必选</th> <th>类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td>id</td> <td>是</td> <td>string</td> <td>光源Id</td> </tr> </tbody> </table> <h4>示例</h4> <pre><code class="language-javascript">let mPointLightConfig = new BCore.Viewer.Light.PointLightConfig(); mViewer3D.addPointLight('name', mPointLightConfig); mViewer3D.deletePointLight('name');</code></pre> <p>&lt;br&gt;</p> <h3>3. 获取点光源参数</h3> <h4>简要描述</h4> <p>获取点光源参数</p> <h4>接口</h4> <pre><code class="language-javascript">getPointLightConfig(id: string)</code></pre> <h4>参数</h4> <table> <thead> <tr> <th>参数名</th> <th>必选</th> <th>类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td>id</td> <td>是</td> <td>string</td> <td>光源Id</td> </tr> </tbody> </table> <h4>示例</h4> <pre><code class="language-javascript">let mPointLightConfig = new BCore.Viewer.Light.PointLightConfig(); mViewer3D.addPointLight('name', mPointLightConfig); let config = mViewer3D.getPointLightConfig('name');</code></pre> <p>&lt;br&gt;</p> <h3>4. 设置点光源参数</h3> <pre><code class="language-javascript">setPointLightConfig(id: string, config: PointLightConfig)</code></pre> <h4>参数</h4> <table> <thead> <tr> <th>参数名</th> <th>必选</th> <th>类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td>id</td> <td>是</td> <td>string</td> <td>光源Id</td> </tr> <tr> <td>config</td> <td>是</td> <td>PointLightConfig</td> <td>光源配置</td> </tr> </tbody> </table> <h4>示例</h4> <pre><code class="language-javascript">let mPointLightConfig = new BCore.Viewer.Light.PointLightConfig(); mViewer3D.addPointLight('name', mPointLightConfig); mPointLightConfig.castShadow = true; m3D.setPointLightConfig('name', mPointLightConfig);</code></pre> <p>&lt;br&gt;</p> <h3>5. 清空所有点光源</h3> <pre><code class="language-javascript">clearPointLights()</code></pre> <h4>示例</h4> <pre><code class="language-javascript">let mPointLightConfig = new BCore.Viewer.Light.PointLightConfig(); mViewer3D.addPointLight('name', mPointLightConfig); mViewer3D.clearPointLights();</code></pre> <hr /> <p>以上是 '点光源' 的说明文档,包含构造函数、参数、方法以及示例代码。</p>

页面列表

ITEM_HTML