Skip to content

Commit 7a0fb0a

Browse files
Improve ScreenComponent API docs (#7622)
* Improve ScreenComponent API docs * Comma * Update src/framework/components/screen/component.js Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 99effc6 commit 7a0fb0a

File tree

11 files changed

+74
-26
lines changed

11 files changed

+74
-26
lines changed

src/framework/components/camera/component.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ import { PostEffectQueue } from './post-effect-queue.js';
5151
* });
5252
* ```
5353
*
54-
* Once the CameraComponent is added to the entity, you can access it via the `camera` property:
54+
* Once the CameraComponent is added to the entity, you can access it via the {@link Entity#camera}
55+
* property:
5556
*
5657
* ```javascript
5758
* entity.camera.nearClip = 2; // Set the near clip of the camera

src/framework/components/collision/component.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ const _quat = new Quat();
4242
* });
4343
* ```
4444
*
45-
* Once the CollisionComponent is added to the entity, you can access it via the `collision` property:
45+
* Once the CollisionComponent is added to the entity, you can access it via the
46+
* {@link Entity#collision} property:
4647
*
4748
* ```javascript
4849
* entity.collision.type = 'cylinder'; // Set the collision volume to a cylinder

src/framework/components/element/component.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ const matD = new Mat4();
6666
* });
6767
* ```
6868
*
69-
* Once the ElementComponent is added to the entity, you can access it via the `element` property:
69+
* Once the ElementComponent is added to the entity, you can access it via the
70+
* {@link Entity#element} property:
7071
*
7172
* ```javascript
7273
* entity.element.color = pc.Color.RED; // Set the element's color to red

src/framework/components/gsplat/component.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import { Component } from '../component.js';
2828
* });
2929
* ```
3030
*
31-
* Once the GSplatComponent is added to the entity, you can access it via the `gsplat` property:
31+
* Once the GSplatComponent is added to the entity, you can access it via the {@link Entity#gsplat}
32+
* property:
3233
*
3334
* ```javascript
3435
* entity.gsplat.customAabb = new pc.BoundingBox(new pc.Vec3(), new pc.Vec3(10, 10, 10));

src/framework/components/light/component.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ import { properties } from './data.js';
3737
* });
3838
* ```
3939
*
40-
* Once the LightComponent is added to the entity, you can access it via the `light` property:
40+
* Once the LightComponent is added to the entity, you can access it via the {@link Entity#light}
41+
* property:
4142
*
4243
* ```javascript
4344
* entity.light.intensity = 3; // Set the intensity of the light

src/framework/components/model/component.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ import { Component } from '../component.js';
3939
* });
4040
* ```
4141
*
42-
* Once the ModelComponent is added to the entity, you can access it via the `model` property:
42+
* Once the ModelComponent is added to the entity, you can access it via the {@link Entity#model}
43+
* property:
4344
*
4445
* ```javascript
4546
* entity.model.type = 'capsule'; // Set the model component's type

src/framework/components/render/component.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ import { Component } from '../component.js';
4040
* });
4141
* ```
4242
*
43-
* Once the RenderComponent is added to the entity, you can access it via the `render` property:
43+
* Once the RenderComponent is added to the entity, you can access it via the {@link Entity#render}
44+
* property:
4445
*
4546
* ```javascript
4647
* entity.render.type = 'capsule'; // Set the render component's type

src/framework/components/rigid-body/component.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ const _vec3 = new Vec3();
4949
* });
5050
* ```
5151
*
52-
* Once the RigidBodyComponent is added to the entity, you can access it via the `rigidbody` property:
52+
* Once the RigidBodyComponent is added to the entity, you can access it via the
53+
* {@link Entity#rigidbody} property:
5354
*
5455
* ```javascript
5556
* entity.rigidbody.mass = 10;

src/framework/components/screen/component.js

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,42 @@ import { Component } from '../component.js';
1212
const _transform = new Mat4();
1313

1414
/**
15-
* A ScreenComponent enables the Entity to render child {@link ElementComponent}s using anchors and
16-
* positions in the ScreenComponent's space.
15+
* A ScreenComponent defines a rectangular area where user interfaces can be constructed. Screens
16+
* can either be 2D (screen space) or 3D (world space) - see {@link screenSpace}. It is possible to
17+
* create an {@link Entity} hierarchy underneath an Entity with a ScreenComponent to create complex
18+
* user interfaces using the following components:
19+
*
20+
* - {@link ButtonComponent}
21+
* - {@link ElementComponent}
22+
* - {@link LayoutChildComponent}
23+
* - {@link LayoutGroupComponent}
24+
* - {@link ScrollbarComponent}
25+
* - {@link ScrollViewComponent}
26+
*
27+
* You should never need to use the ScreenComponent constructor directly. To add a ScreenComponent
28+
* to an {@link Entity}, use {@link Entity#addComponent}:
29+
*
30+
* ```javascript
31+
* const entity = new pc.Entity();
32+
* entity.addComponent('screen', {
33+
* referenceResolution: new pc.Vec2(1280, 720),
34+
* screenSpace: false
35+
* });
36+
* ```
37+
*
38+
* Once the ScreenComponent is added to the entity, you can access it via the {@link Entity#screen}
39+
* property:
40+
*
41+
* ```javascript
42+
* entity.screen.scaleBlend = 0.6; // Set the screen's scale blend to 0.6
43+
*
44+
* console.log(entity.screen.scaleBlend); // Get the screen's scale blend and print it
45+
* ```
46+
*
47+
* Relevant Engine API examples:
48+
*
49+
* - [Screen Space Screen](https://playcanvas.github.io/#/user-interface/text)
50+
* - [World Space Screen](https://playcanvas.github.io/#/user-interface/world-ui)
1751
*
1852
* @hideconstructor
1953
* @category User Interface
@@ -157,8 +191,9 @@ class ScreenComponent extends Component {
157191
}
158192

159193
/**
160-
* Sets the width and height of the ScreenComponent. When screenSpace is true the resolution will
161-
* always be equal to {@link GraphicsDevice#width} x {@link GraphicsDevice#height}.
194+
* Sets the width and height of the ScreenComponent. When {@link screenSpace} is true, the
195+
* resolution will always be equal to {@link GraphicsDevice#width} by
196+
* {@link GraphicsDevice#height}.
162197
*
163198
* @type {Vec2}
164199
*/
@@ -193,9 +228,9 @@ class ScreenComponent extends Component {
193228

194229
/**
195230
* Sets the resolution that the ScreenComponent is designed for. This is only taken into
196-
* account when screenSpace is true and scaleMode is {@link SCALEMODE_BLEND}. If the actual
197-
* resolution is different then the ScreenComponent will be scaled according to the scaleBlend
198-
* value.
231+
* account when {@link screenSpace} is true and {@link scaleMode} is {@link SCALEMODE_BLEND}.
232+
* If the actual resolution is different, then the ScreenComponent will be scaled according to
233+
* the {@link scaleBlend} value.
199234
*
200235
* @type {Vec2}
201236
*/
@@ -226,7 +261,7 @@ class ScreenComponent extends Component {
226261

227262
/**
228263
* Sets whether the ScreenComponent will render its child {@link ElementComponent}s in screen
229-
* space instead of world space. Enable this to create 2D user interfaces.
264+
* space instead of world space. Enable this to create 2D user interfaces. Defaults to false.
230265
*
231266
* @type {boolean}
232267
*/
@@ -258,7 +293,8 @@ class ScreenComponent extends Component {
258293

259294
/**
260295
* Sets the scale mode. Can either be {@link SCALEMODE_NONE} or {@link SCALEMODE_BLEND}. See
261-
* the description of referenceResolution for more information.
296+
* the description of {@link referenceResolution} for more information. Defaults to
297+
* {@link SCALEMODE_NONE}.
262298
*
263299
* @type {string}
264300
*/
@@ -287,9 +323,10 @@ class ScreenComponent extends Component {
287323
}
288324

289325
/**
290-
* Sets the scale blend. This is a value between 0 and 1 that is used when scaleMode is equal
291-
* to {@link SCALEMODE_BLEND}. Scales the ScreenComponent with width as a reference (when value
292-
* is 0), the height as a reference (when value is 1) or anything in between.
326+
* Sets the scale blend. This is a value between 0 and 1 that is used when {@link scaleMode} is
327+
* equal to {@link SCALEMODE_BLEND}. Scales the ScreenComponent with width as a reference (when
328+
* value is 0), the height as a reference (when value is 1) or anything in between. Defaults to
329+
* 0.5.
293330
*
294331
* @type {number}
295332
*/
@@ -317,9 +354,9 @@ class ScreenComponent extends Component {
317354
}
318355

319356
/**
320-
* Sets the priority. Priority determines the order in which Screen components in the same
321-
* layer are rendered. Number must be an integer between 0 and 255. Priority is set into the
322-
* top 8 bits of the drawOrder property in an element.
357+
* Sets the screen's render priority. Priority determines the order in which ScreenComponents
358+
* in the same layer are rendered. Number must be an integer between 0 and 255. Priority is set
359+
* into the top 8 bits of the {@link ElementComponent#drawOrder} property. Defaults to 0.
323360
*
324361
* @type {number}
325362
*/
@@ -337,7 +374,7 @@ class ScreenComponent extends Component {
337374
}
338375

339376
/**
340-
* Gets the priority.
377+
* Gets the screen's render priority.
341378
*
342379
* @type {number}
343380
*/

src/framework/components/script/component.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ const toLowerCamelCase = str => str[0].toLowerCase() + str.substring(1);
2929
* entity.addComponent('script');
3030
* ```
3131
*
32-
* Once the ScriptComponent is added to the entity, you can access it via the `script` property.
32+
* Once the ScriptComponent is added to the entity, you can access it via the {@link Entity#script}
33+
* property.
34+
*
3335
* Add scripts to the entity by calling the `create` method:
3436
*
3537
* ```javascript

0 commit comments

Comments
 (0)