@@ -12,8 +12,42 @@ import { Component } from '../component.js';
1212const _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 */
0 commit comments