Skip to content

XRManager: Improve docs. #31101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions src/renderers/common/XRManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,22 @@ class XRManager extends EventDispatcher {

}

createQuadLayer( width, height, translation, quaternion, pixelwidth, pixelheight, rendercall, attributes = [] ) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at how attributes is used in the code, the parameter should be an object, not an array.

/**
* This method can be used in XR applications to create a quadratic layer that presents a separate
* rendered scene.
*
* @param {number} width - The width of the layer plane in world units.
* @param {number} height - The height of the layer plane in world units.
* @param {Vector3} translation - The position/translation of the layer plane in world units.
* @param {Quaternion} quaternion - The orientation of the layer plane expressed as a quaternion.
* @param {number} pixelwidth - The width of the layer's render target in pixels.
* @param {number} pixelheight - The height of the layer's render target in pixels.
* @param {Function} rendercall - A callback function that renders the layer. Similar to code in
* the default animation loop, this method can be used to update/transform 3D object in the layer's scene.
* @param {Object} [attributes={}] - Allows to configure the layer's render target.
* @return {Mesh} A mesh representing the quadratic XR layer. This mesh should be added to the XR scene.
*/
createQuadLayer( width, height, translation, quaternion, pixelwidth, pixelheight, rendercall, attributes = {} ) {

const geometry = new PlaneGeometry( width, height );
const renderTarget = new XRRenderTarget(
Expand Down Expand Up @@ -669,7 +684,23 @@ class XRManager extends EventDispatcher {

}

createCylinderLayer( radius, centralAngle, aspectratio, translation, quaternion, pixelwidth, pixelheight, rendercall, attributes = [] ) {
/**
* This method can be used in XR applications to create a cylindrical layer that presents a separate
* rendered scene.
*
* @param {number} radius - The radius of the cylinder in world units.
* @param {number} centralAngle - The central angle of the cylinder in radians.
* @param {number} aspectratio - The aspect ratio.
* @param {Vector3} translation - The position/translation of the layer plane in world units.
* @param {Quaternion} quaternion - The orientation of the layer plane expressed as a quaternion.
* @param {number} pixelwidth - The width of the layer's render target in pixels.
* @param {number} pixelheight - The height of the layer's render target in pixels.
* @param {Function} rendercall - A callback function that renders the layer. Similar to code in
* the default animation loop, this method can be used to update/transform 3D object in the layer's scene.
* @param {Object} [attributes={}] - Allows to configure the layer's render target.
* @return {Mesh} A mesh representing the cylindrical XR layer. This mesh should be added to the XR scene.
*/
createCylinderLayer( radius, centralAngle, aspectratio, translation, quaternion, pixelwidth, pixelheight, rendercall, attributes = {} ) {

const geometry = new CylinderGeometry( radius, radius, radius * centralAngle / aspectratio, 64, 64, true, Math.PI - centralAngle / 2, centralAngle );
const renderTarget = new XRRenderTarget(
Expand Down Expand Up @@ -743,6 +774,12 @@ class XRManager extends EventDispatcher {

}

/**
* Renders the XR layers that have been previously added to the scene.
*
* This method is usually called in your animation loop before rendering
* the actual scene via `renderer.render( scene, camera );`.
*/
renderLayers( ) {

const translationObject = new Vector3();
Expand Down