Skip to content

Commit

Permalink
Hide component constructors (#7203)
Browse files Browse the repository at this point in the history
* Hide component constructors

* Delete unused import
  • Loading branch information
willeastcott authored Dec 17, 2024
1 parent c58fe2f commit 4dc7939
Show file tree
Hide file tree
Showing 22 changed files with 173 additions and 173 deletions.
65 changes: 38 additions & 27 deletions src/framework/components/anim/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,51 @@ import {
} from '../../anim/controller/constants.js';
import { AnimTrack } from '../../anim/evaluator/anim-track.js';

/**
* @import { AnimComponentSystem } from './system.js'
*/

/**
* The Anim Component allows an Entity to playback animations on models and entity properties.
*
* @hideconstructor
* @category Animation
*/
class AnimComponent extends Component {
/**
* Create a new AnimComponent instance.
*
* @param {AnimComponentSystem} system - The {@link ComponentSystem} that created this Component.
* @param {Entity} entity - The Entity that this Component is attached to.
*/
constructor(system, entity) {
super(system, entity);
/** @private */
_stateGraphAsset = null;

this._stateGraphAsset = null;
this._animationAssets = {};
this._speed = 1.0;
this._activate = true;
this._playing = false;
this._rootBone = null;
this._stateGraph = null;
this._layers = [];
this._layerIndices = {};
this._parameters = {};
// a collection of animated property targets
this._targets = {};
this._consumedTriggers = new Set();
this._normalizeWeights = false;
}
/** @private */
_animationAssets = {};

/** @private */
_speed = 1;

/** @private */
_activate = true;

/** @private */
_playing = false;

/** @private */
_rootBone = null;

/** @private */
_stateGraph = null;

/** @private */
_layers = [];

/** @private */
_layerIndices = {};

/** @private */
_parameters = {};

/** @private */
_targets = {};

/** @private */
_consumedTriggers = new Set();

/** @private */
_normalizeWeights = false;

set stateGraphAsset(value) {
if (value === null) {
Expand Down
14 changes: 1 addition & 13 deletions src/framework/components/animation/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import { Component } from '../component.js';

/**
* @import { Animation } from '../../../scene/animation/animation.js'
* @import { AnimationComponentSystem } from './system.js'
* @import { Entity } from '../../entity.js'
* @import { Model } from '../../../scene/model.js'
*/

/**
* The Animation Component allows an Entity to playback animations on models.
*
* @hideconstructor
* @category Animation
*/
class AnimationComponent extends Component {
Expand Down Expand Up @@ -109,17 +108,6 @@ class AnimationComponent extends Component {
*/
speed = 1;

/**
* Create a new AnimationComponent instance.
*
* @param {AnimationComponentSystem} system - The {@link ComponentSystem} that created this
* component.
* @param {Entity} entity - The Entity that this component is attached to.
*/
constructor(system, entity) { // eslint-disable-line no-useless-constructor
super(system, entity);
}

/**
* Sets the dictionary of animations by name.
*
Expand Down
16 changes: 1 addition & 15 deletions src/framework/components/audio-listener/component.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
import { Component } from '../component.js';

/**
* @import { AudioListenerComponentSystem } from './system.js'
* @import { Entity } from '../../entity.js'
*/

/**
* Represents the audio listener in the 3D world, so that 3D positioned audio sources are heard
* correctly.
*
* @hideconstructor
* @category Sound
*/
class AudioListenerComponent extends Component {
/**
* Create a new AudioListenerComponent instance.
*
* @param {AudioListenerComponentSystem} system - The ComponentSystem that created this component.
* @param {Entity} entity - The Entity that this component is attached to.
*/
constructor(system, entity) { // eslint-disable-line no-useless-constructor
super(system, entity);
}

setCurrentListener() {
if (this.enabled && this.entity.audiolistener && this.entity.enabled) {
this.system.current = this.entity;
Expand Down
31 changes: 22 additions & 9 deletions src/framework/components/button/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ STATES_TO_SPRITE_FRAME_NAMES[VisualState.INACTIVE] = 'inactiveSpriteFrame';
* A ButtonComponent enables a group of entities to behave like a button, with different visual
* states for hover and press interactions.
*
* @hideconstructor
* @category User Interface
*/
class ButtonComponent extends Component {
Expand Down Expand Up @@ -243,6 +244,27 @@ class ButtonComponent extends Component {
*/
static EVENT_PRESSEDEND = 'pressedend';

/** @private */
_visualState = VisualState.DEFAULT;

/** @private */
_isHovering = false;

/** @private */
_hoveringCounter = 0;

/** @private */
_isPressed = false;

/** @private */
_defaultTint = new Color(1, 1, 1, 1);

/** @private */
_defaultSpriteAsset = null;

/** @private */
_defaultSpriteFrame = 0;

/**
* Create a new ButtonComponent instance.
*
Expand All @@ -252,15 +274,6 @@ class ButtonComponent extends Component {
constructor(system, entity) {
super(system, entity);

this._visualState = VisualState.DEFAULT;
this._isHovering = false;
this._hoveringCounter = 0;
this._isPressed = false;

this._defaultTint = new Color(1, 1, 1, 1);
this._defaultSpriteAsset = null;
this._defaultSpriteFrame = 0;

this._imageReference = new EntityReference(this, 'imageEntity', {
'element#gain': this._onImageElementGain,
'element#lose': this._onImageElementLose,
Expand Down
1 change: 1 addition & 0 deletions src/framework/components/camera/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { PostEffectQueue } from './post-effect-queue.js';
* entity.camera.nearClip = 2;
* ```
*
* @hideconstructor
* @category Graphics
*/
class CameraComponent extends Component {
Expand Down
11 changes: 7 additions & 4 deletions src/framework/components/collision/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const _quat = new Quat();
* | **Rigid Body (Dynamic or Kinematic)** | <ul><li>contact</li><li>collisionstart</li><li>collisionend</li></ul> | <ul><li>contact</li><li>collisionstart</li><li>collisionend</li></ul> | <ul><li>triggerenter</li><li>triggerleave</li></ul> |
* | **Trigger Volume** | | <ul><li>triggerenter</li><li>triggerleave</li></ul> | |
*
* @hideconstructor
* @category Physics
*/
class CollisionComponent extends Component {
Expand Down Expand Up @@ -94,6 +95,12 @@ class CollisionComponent extends Component {
*/
static EVENT_TRIGGERLEAVE = 'triggerleave';

/** @private */
_compoundParent = null;

/** @private */
_hasOffset = false;

/**
* Create a new CollisionComponent.
*
Expand All @@ -103,10 +110,6 @@ class CollisionComponent extends Component {
constructor(system, entity) {
super(system, entity);

/** @private */
this._compoundParent = null;
this._hasOffset = false;

this.entity.on('insert', this._onInsert, this);

this.on('set_type', this.onSetType, this);
Expand Down
2 changes: 2 additions & 0 deletions src/framework/components/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { EventHandler } from '../../core/event-handler.js';
/**
* Components are used to attach functionality on a {@link Entity}. Components can receive update
* events each frame, and expose properties to the PlayCanvas Editor.
*
* @hideconstructor
*/
class Component extends EventHandler {
/**
Expand Down
1 change: 1 addition & 0 deletions src/framework/components/element/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const matD = new Mat4();
* - [Text localization](https://playcanvas.github.io/#/user-interface/text-localization)
* - [Typewriter text](https://playcanvas.github.io/#/user-interface/text-typewriter)
*
* @hideconstructor
* @category User Interface
*/
class ElementComponent extends Component {
Expand Down
1 change: 1 addition & 0 deletions src/framework/components/gsplat/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { Component } from '../component.js';
* - [Loading a Splat](https://playcanvas.github.io/#/loaders/gsplat)
* - [Custom Splat Shaders](https://playcanvas.github.io/#/loaders/gsplat-many)
*
* @hideconstructor
* @category Graphics
*/
class GSplatComponent extends Component {
Expand Down
50 changes: 21 additions & 29 deletions src/framework/components/layout-child/component.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,33 @@
import { Component } from '../component.js';

/**
* @import { Entity } from '../../entity.js'
* @import { LayoutChildComponentSystem } from './system.js'
*/

/**
* A LayoutChildComponent enables the Entity to control the sizing applied to it by its parent
* {@link LayoutGroupComponent}.
*
* @hideconstructor
* @category User Interface
*/
class LayoutChildComponent extends Component {
/**
* Create a new LayoutChildComponent.
*
* @param {LayoutChildComponentSystem} system - The ComponentSystem that created this Component.
* @param {Entity} entity - The Entity that this Component is attached to.
*/
constructor(system, entity) {
super(system, entity);

/** @private */
this._minWidth = 0;
/** @private */
this._minHeight = 0;
/** @private */
this._maxWidth = null;
/** @private */
this._maxHeight = null;
/** @private */
this._fitWidthProportion = 0;
/** @private */
this._fitHeightProportion = 0;
/** @private */
this._excludeFromLayout = false;
}
/** @private */
_minWidth = 0;

/** @private */
_minHeight = 0;

/** @private */
_maxWidth = null;

/** @private */
_maxHeight = null;

/** @private */
_fitWidthProportion = 0;

/** @private */
_fitHeightProportion = 0;

/** @private */
_excludeFromLayout = false;

/**
* Sets the minimum width the element should be rendered at.
Expand Down
52 changes: 31 additions & 21 deletions src/framework/components/layout-group/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,40 @@ function isEnabledAndHasEnabledElement(entity) {
* A LayoutGroupComponent enables the Entity to position and scale child {@link ElementComponent}s
* according to configurable layout rules.
*
* @hideconstructor
* @category User Interface
*/
class LayoutGroupComponent extends Component {
/** @private */
_orientation = ORIENTATION_HORIZONTAL;

/** @private */
_reverseX = false;

/** @private */
_reverseY = true;

/** @private */
_alignment = new Vec2(0, 1);

/** @private */
_padding = new Vec4();

/** @private */
_spacing = new Vec2();

/** @private */
_widthFitting = FITTING_NONE;

/** @private */
_heightFitting = FITTING_NONE;

/** @private */
_wrap = false;

/** @private */
_layoutCalculator = new LayoutCalculator();

/**
* Create a new LayoutGroupComponent instance.
*
Expand All @@ -35,27 +66,6 @@ class LayoutGroupComponent extends Component {
constructor(system, entity) {
super(system, entity);

/** @private */
this._orientation = ORIENTATION_HORIZONTAL;
/** @private */
this._reverseX = false;
/** @private */
this._reverseY = true;
/** @private */
this._alignment = new Vec2(0, 1);
/** @private */
this._padding = new Vec4();
/** @private */
this._spacing = new Vec2();
/** @private */
this._widthFitting = FITTING_NONE;
/** @private */
this._heightFitting = FITTING_NONE;
/** @private */
this._wrap = false;
/** @private */
this._layoutCalculator = new LayoutCalculator();

// Listen for the group container being resized
this._listenForReflowEvents(this.entity, 'on');

Expand Down
Loading

0 comments on commit 4dc7939

Please sign in to comment.