onStart()
onStart: ({ canvas, GLctx, computeCtx, isWebgl2, orientation, videoWidth, videoHeight, canvasWidth, canvasHeight, config })
説明
onStart()はXRの起動時に呼ばれる。
パラメータ
| パラメータ | 説明 |
|---|---|
| canvas | GPU処理とユーザー表示を支えるキャンバス。 |
| GLctx | 描画キャンバスの WebGLRenderingContext または WebGL2RenderingContext. |
| computeCtx | コンピュートキャンバスの WebGLRenderingContext または WebGL2RenderingContext. |
| isWebgl2 | GLctxがWebGL2RenderingContext であれば真。 |
| orientation | ポートレートからのUIの回転を度単位で指定する(-90, 0, 90, 180)。 |
| videoWidth | カメラフィードの高さ(ピクセル単位)。 |
| videoHeight | カメラフィードの高さ(ピクセル単位)。 |
| canvasWidth | GLctx キャンバスの幅をピクセル単位で指定する。 |
| canvasHeight | GLctx キャンバスの高さをピクセル単位で指定する。 |
| config | XR8.run() に渡された設定パラメータ。 |
例
XR8.addCameraPipelineModule({
name: 'mycamerapipelinemodule',
onStart: ({canvasWidth, canvasHeight}) => {
// three.jsのシーンを取得します。これはXR8.Threejs.pipelineModule().onStart()によって作成されました。
// 今ここでアクセスできる理由は、'mycamerapipelinemodule'が
// XR8.Threejs.pipelineModule()の後にインストールされたからです。
const {scene, camera} = XR8.Threejs.xrScene()
// いくつかのオブジェクトをシーンに追加し、開始カメラ位置を設定します。
myInitXrScene({scene, camera})
// xrコントローラの6DoF位置とカメラパラメータをシーンに同期します。
XR8.XrController.updateCameraProjectionMatrix({
origin: camera.position,
facing: camera.quaternion,
})
},
})