From 695cdf88d86361f1ffe1f98d348bb8121af24190 Mon Sep 17 00:00:00 2001 From: Will Eastcott Date: Wed, 15 Jan 2025 13:48:24 +0000 Subject: [PATCH] API reference docs improvements --- src/components/camera-component.ts | 2 +- src/components/collision-component.ts | 2 +- src/components/element-component.ts | 82 ++++++++++++++++++++++++++- src/components/light-component.ts | 2 +- src/components/listener-component.ts | 2 +- src/components/render-component.ts | 2 +- src/components/rigidbody-component.ts | 4 +- src/components/screen-component.ts | 2 +- src/components/script-component.ts | 2 +- src/components/sound-component.ts | 2 +- src/components/sound-slot.ts | 4 +- src/components/splat-component.ts | 12 +++- src/model.ts | 6 +- src/sky.ts | 64 +++++++++++++++++++++ 14 files changed, 170 insertions(+), 18 deletions(-) diff --git a/src/components/camera-component.ts b/src/components/camera-component.ts index 89f842e..fda41e0 100644 --- a/src/components/camera-component.ts +++ b/src/components/camera-component.ts @@ -107,7 +107,7 @@ class CameraComponentElement extends ComponentElement { } /** - * Gets the camera component. + * Gets the underlying PlayCanvas camera component. * @returns The camera component. */ get component(): CameraComponent | null { diff --git a/src/components/collision-component.ts b/src/components/collision-component.ts index 40919c3..cc41729 100644 --- a/src/components/collision-component.ts +++ b/src/components/collision-component.ts @@ -46,7 +46,7 @@ class CollisionComponentElement extends ComponentElement { } /** - * Gets the collision component. + * Gets the underlying PlayCanvas collision component. * @returns The collision component. */ get component(): CollisionComponent | null { diff --git a/src/components/element-component.ts b/src/components/element-component.ts index 6f49f9b..9ba0ecf 100644 --- a/src/components/element-component.ts +++ b/src/components/element-component.ts @@ -60,13 +60,17 @@ class ElementComponentElement extends ComponentElement { } /** - * Gets the element component. + * Gets the underlying PlayCanvas element component. * @returns The element component. */ get component(): ElementComponent | null { return super.component as ElementComponent | null; } + /** + * Sets the anchor of the element component. + * @param value - The anchor. + */ set anchor(value: Vec4) { this._anchor = value; if (this.component) { @@ -74,10 +78,18 @@ class ElementComponentElement extends ComponentElement { } } + /** + * Gets the anchor of the element component. + * @returns The anchor. + */ get anchor() { return this._anchor; } + /** + * Sets the id of the `pc-asset` to use for the font. + * @param value - The asset ID. + */ set asset(value: string) { this._asset = value; const asset = AssetElement.get(value); @@ -86,10 +98,18 @@ class ElementComponentElement extends ComponentElement { } } + /** + * Gets the id of the `pc-asset` to use for the font. + * @returns The asset ID. + */ get asset() { return this._asset; } + /** + * Sets whether the element component should automatically adjust its width. + * @param value - Whether to automatically adjust the width. + */ set autoWidth(value: boolean) { this._autoWidth = value; if (this.component) { @@ -97,10 +117,18 @@ class ElementComponentElement extends ComponentElement { } } + /** + * Gets whether the element component should automatically adjust its width. + * @returns Whether to automatically adjust the width. + */ get autoWidth() { return this._autoWidth; } + /** + * Sets the color of the element component. + * @param value - The color. + */ set color(value: Color) { this._color = value; if (this.component) { @@ -108,10 +136,18 @@ class ElementComponentElement extends ComponentElement { } } + /** + * Gets the color of the element component. + * @returns The color. + */ get color() { return this._color; } + /** + * Sets the font size of the element component. + * @param value - The font size. + */ set fontSize(value: number) { this._fontSize = value; if (this.component) { @@ -119,10 +155,18 @@ class ElementComponentElement extends ComponentElement { } } + /** + * Gets the font size of the element component. + * @returns The font size. + */ get fontSize() { return this._fontSize; } + /** + * Sets the line height of the element component. + * @param value - The line height. + */ set lineHeight(value: number) { this._lineHeight = value; if (this.component) { @@ -130,10 +174,18 @@ class ElementComponentElement extends ComponentElement { } } + /** + * Gets the line height of the element component. + * @returns The line height. + */ get lineHeight() { return this._lineHeight; } + /** + * Sets the pivot of the element component. + * @param value - The pivot. + */ set pivot(value: Vec2) { this._pivot = value; if (this.component) { @@ -141,10 +193,18 @@ class ElementComponentElement extends ComponentElement { } } + /** + * Gets the pivot of the element component. + * @returns The pivot. + */ get pivot() { return this._pivot; } + /** + * Sets the text of the element component. + * @param value - The text. + */ set text(value: string) { this._text = value; if (this.component) { @@ -152,6 +212,10 @@ class ElementComponentElement extends ComponentElement { } } + /** + * Gets the text of the element component. + * @returns The text. + */ get text() { return this._text; } @@ -175,6 +239,10 @@ class ElementComponentElement extends ComponentElement { return this._type; } + /** + * Sets the width of the element component. + * @param value - The width. + */ set width(value: number) { this._width = value; if (this.component) { @@ -182,10 +250,18 @@ class ElementComponentElement extends ComponentElement { } } + /** + * Gets the width of the element component. + * @returns The width. + */ get width() { return this._width; } + /** + * Sets whether the element component should wrap lines. + * @param value - Whether to wrap lines. + */ set wrapLines(value: boolean) { this._wrapLines = value; if (this.component) { @@ -193,6 +269,10 @@ class ElementComponentElement extends ComponentElement { } } + /** + * Gets whether the element component should wrap lines. + * @returns Whether to wrap lines. + */ get wrapLines() { return this._wrapLines; } diff --git a/src/components/light-component.ts b/src/components/light-component.ts index 5eb1a20..3491497 100644 --- a/src/components/light-component.ts +++ b/src/components/light-component.ts @@ -76,7 +76,7 @@ class LightComponentElement extends ComponentElement { } /** - * Gets the light component. + * Gets the underlying PlayCanvas light component. * @returns The light component. */ get component(): LightComponent | null { diff --git a/src/components/listener-component.ts b/src/components/listener-component.ts index c3f55b3..1aab268 100644 --- a/src/components/listener-component.ts +++ b/src/components/listener-component.ts @@ -16,7 +16,7 @@ class ListenerComponentElement extends ComponentElement { } /** - * Gets the audio listener component. + * Gets the underlying PlayCanvas audio listener component. * @returns The audio listener component. */ get component(): AudioListenerComponent | null { diff --git a/src/components/render-component.ts b/src/components/render-component.ts index 491e437..12cb943 100644 --- a/src/components/render-component.ts +++ b/src/components/render-component.ts @@ -34,7 +34,7 @@ class RenderComponentElement extends ComponentElement { } /** - * Gets the render component. + * Gets the underlying PlayCanvas render component. * @returns The render component. */ get component(): RenderComponent | null { diff --git a/src/components/rigidbody-component.ts b/src/components/rigidbody-component.ts index 4385d74..8c9e6b3 100644 --- a/src/components/rigidbody-component.ts +++ b/src/components/rigidbody-component.ts @@ -76,8 +76,8 @@ class RigidBodyComponentElement extends ComponentElement { } /** - * Gets the collision component. - * @returns The collision component. + * Gets the underlying PlayCanvas rigidbody component. + * @returns The rigidbody component. */ get component(): RigidBodyComponent | null { return super.component as RigidBodyComponent | null; diff --git a/src/components/screen-component.ts b/src/components/screen-component.ts index 6e241c4..1f83aa0 100644 --- a/src/components/screen-component.ts +++ b/src/components/screen-component.ts @@ -40,7 +40,7 @@ class ScreenComponentElement extends ComponentElement { } /** - * Gets the screen component. + * Gets the underlying PlayCanvas screen component. * @returns The screen component. */ get component(): ScreenComponent | null { diff --git a/src/components/script-component.ts b/src/components/script-component.ts index ab4d06f..fa0e548 100644 --- a/src/components/script-component.ts +++ b/src/components/script-component.ts @@ -189,7 +189,7 @@ class ScriptComponentElement extends ComponentElement { } /** - * Gets the script component. + * Gets the underlying PlayCanvas script component. * @returns The script component. */ get component(): ScriptComponent | null { diff --git a/src/components/sound-component.ts b/src/components/sound-component.ts index b1e33fd..c132a2a 100644 --- a/src/components/sound-component.ts +++ b/src/components/sound-component.ts @@ -42,7 +42,7 @@ class SoundComponentElement extends ComponentElement { } /** - * Gets the sound component. + * Gets the underlying PlayCanvas sound component. * @returns The sound component. */ get component(): SoundComponent | null { diff --git a/src/components/sound-slot.ts b/src/components/sound-slot.ts index b1bbb81..8081ca8 100644 --- a/src/components/sound-slot.ts +++ b/src/components/sound-slot.ts @@ -71,7 +71,7 @@ class SoundSlotElement extends AsyncElement { } /** - * Sets the asset of the sound slot. + * Sets the id of the `pc-asset` to use for the sound slot. * @param value - The asset. */ set asset(value: string) { @@ -85,7 +85,7 @@ class SoundSlotElement extends AsyncElement { } /** - * Gets the asset of the sound slot. + * Gets the id of the `pc-asset` to use for the sound slot. * @returns The asset. */ get asset() { diff --git a/src/components/splat-component.ts b/src/components/splat-component.ts index 7a82ff8..98b672c 100644 --- a/src/components/splat-component.ts +++ b/src/components/splat-component.ts @@ -25,13 +25,17 @@ class SplatComponentElement extends ComponentElement { } /** - * Gets the gsplat component. - * @returns The gsplat component. + * Gets the underlying PlayCanvas splat component. + * @returns The splat component. */ get component(): GSplatComponent | null { return super.component as GSplatComponent | null; } + /** + * Sets id of the `pc-asset` to use for the splat. + * @param value - The asset ID. + */ set asset(value: string) { this._asset = value; const asset = AssetElement.get(value); @@ -40,6 +44,10 @@ class SplatComponentElement extends ComponentElement { } } + /** + * Gets the id of the `pc-asset` to use for the splat. + * @returns The asset ID. + */ get asset() { return this._asset; } diff --git a/src/model.ts b/src/model.ts index b5293c9..5dd4d7a 100644 --- a/src/model.ts +++ b/src/model.ts @@ -74,7 +74,7 @@ class ModelElement extends AsyncElement { } /** - * Sets the asset ID of the model. + * Sets the id of the `pc-asset` to use for the model. * @param value - The asset ID. */ set asset(value: string) { @@ -85,8 +85,8 @@ class ModelElement extends AsyncElement { } /** - * Gets the source URL of the model. - * @returns The source URL of the model. + * Gets the id of the `pc-asset` to use for the model. + * @returns The asset ID. */ get asset(): string { return this._asset; diff --git a/src/sky.ts b/src/sky.ts index 783e6e6..f7b8162 100644 --- a/src/sky.ts +++ b/src/sky.ts @@ -100,6 +100,10 @@ class SkyElement extends AsyncElement { this._scene = null; } + /** + * Sets the id of the `pc-asset` to use for the skybox. + * @param value - The asset ID. + */ set asset(value: string) { this._asset = value; if (this.isConnected) { @@ -107,10 +111,18 @@ class SkyElement extends AsyncElement { } } + /** + * Gets the id of the `pc-asset` to use for the skybox. + * @returns The asset ID. + */ get asset() { return this._asset; } + /** + * Sets the center of the skybox. + * @param value - The center. + */ set center(value: Vec3) { this._center = value; if (this._scene) { @@ -118,10 +130,18 @@ class SkyElement extends AsyncElement { } } + /** + * Gets the center of the skybox. + * @returns The center. + */ get center() { return this._center; } + /** + * Sets the intensity of the skybox. + * @param value - The intensity. + */ set intensity(value: number) { this._intensity = value; if (this._scene) { @@ -129,10 +149,18 @@ class SkyElement extends AsyncElement { } } + /** + * Gets the intensity of the skybox. + * @returns The intensity. + */ get intensity() { return this._intensity; } + /** + * Sets the mip level of the skybox. + * @param value - The mip level. + */ set level(value: number) { this._level = value; if (this._scene) { @@ -140,18 +168,34 @@ class SkyElement extends AsyncElement { } } + /** + * Gets the mip level of the skybox. + * @returns The mip level. + */ get level() { return this._level; } + /** + * Sets whether the skybox is used as a light source. + * @param value - Whether to use lighting. + */ set lighting(value: boolean) { this._lighting = value; } + /** + * Gets whether the skybox is used as a light source. + * @returns Whether to use lighting. + */ get lighting() { return this._lighting; } + /** + * Sets the Euler rotation of the skybox. + * @param value - The rotation. + */ set rotation(value: Vec3) { this._rotation = value; if (this._scene) { @@ -159,10 +203,18 @@ class SkyElement extends AsyncElement { } } + /** + * Gets the Euler rotation of the skybox. + * @returns The rotation. + */ get rotation() { return this._rotation; } + /** + * Sets the scale of the skybox. + * @param value - The scale. + */ set scale(value: Vec3) { this._scale = value; if (this._scene) { @@ -170,10 +222,18 @@ class SkyElement extends AsyncElement { } } + /** + * Gets the scale of the skybox. + * @returns The scale. + */ get scale() { return this._scale; } + /** + * Sets the type of the skybox. + * @param value - The type. + */ set type(value: 'box' | 'dome' | 'infinite' | 'none') { this._type = value; if (this._scene) { @@ -185,6 +245,10 @@ class SkyElement extends AsyncElement { } } + /** + * Gets the type of the skybox. + * @returns The type. + */ get type() { return this._type; }