XREstimatedLight.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. [page:Group] &rarr;
  11. <h1>XR估计光照([name])</h1>
  12. <p class="desc">
  13. [name] 使用 WebXR 的光照估计来创建光探针、定向光和(可选)模拟用户真实世界环境和照明的环境图。<br>
  14. 当 WebXR 更新光照和环境估计时,[name] 会自动更新光照探针、定向光和环境贴图。<br><br>
  15. 在创建 WebXR 会话时,将光照估计指定为可选或必需的功能非常重要,否则光照估计将无法工作。<br><br>
  16. 有关浏览器兼容性信息,请参阅 <a
  17. href="https://developer.mozilla.org/en-US/docs/Web/API/XRLightProbe#browser_compatibility">此处</a>,因为这仍然是 WebXR
  18. 中的一个实验功能。<br><br>
  19. 要使用它,就像 /examples 目录中的所有文件一样,您必须在HTML中单独包含该文件。
  20. </p>
  21. <h2>导入</h2>
  22. <p>
  23. [name] 是一个附加组件,必须显式导入。请参阅 [link:#manual/introduction/Installation Installation / Addons]。
  24. </p>
  25. <code>
  26. import { XREstimatedLight } from 'three/addons/webxr/XREstimatedLight.js';
  27. </code>
  28. <h2>代码示例</h2>
  29. <code>
  30. renderer.xr.enabled = true;
  31. // Don't add the XREstimatedLight to the scene initially.
  32. // It doesn't have any estimated lighting values until an AR session starts.
  33. const xrLight = new XREstimatedLight( renderer );
  34. xrLight.addEventListener( 'estimationstart' , () => {
  35. scene.add( xrLight );
  36. if ( xrLight.environment ) {
  37. scene.environment = xrLight.environment;
  38. }
  39. } );
  40. xrLight.addEventListener( 'estimationend', () => {
  41. scene.remove( xrLight );
  42. scene.environment = null;
  43. } );
  44. // In order for lighting estimation to work, 'light-estimation' must be included as either
  45. // an optional or required feature.
  46. document.body.appendChild( XRButton.createButton( renderer, {
  47. optionalFeatures: [ 'light-estimation' ]
  48. } ) );
  49. </code>
  50. <h2>例子</h2>
  51. <p>[example:webxr_ar_lighting webxr / light estimation]</p>
  52. <h2>构造函数</h2>
  53. <h3>[name]( [param:WebGLRenderer renderer], [param:Boolean environmentEstimation] )</h3>
  54. <p>
  55. [page:WebGLRenderer renderer]: (必需)用于渲染场景的渲染器。主要用于与 WebXRManager 交互。<br><br>
  56. environmentEstimation: 如果 `true`,则使用 WebXR 来估计环境地图。
  57. </p>
  58. <h2>事件</h2>
  59. <h3>estimationstart</h3>
  60. <p>
  61. 当估计的照明值开始更新时触发。
  62. </p>
  63. <h3>estimationend</h3>
  64. <p>
  65. 当估计的照明值停止更新时触发。
  66. </p>
  67. <h2>Properties</h2>
  68. <h3>[property:Texture environment]</h3>
  69. <p>
  70. WebXR 估计的环境地图。仅当 environmentEstimation 为 时,此选项才可用 `true`。<br><br>
  71. 它可以用作 [page:Scene.environment] 的 [page:MeshStandardMaterial.envMap] 或 [page:Scene.background]。
  72. </p>
  73. <h2>源代码</h2>
  74. <p>
  75. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/webxr/XREstimatedLight.js examples/jsm/webxr/XREstimatedLight.js]
  76. </p>
  77. </body>
  78. </html>