Add state handler implementations and documentation
Some checks failed
CI/CD Pipeline / Test & Lint (16.x) (push) Has been cancelled
CI/CD Pipeline / Test & Lint (18.x) (push) Has been cancelled
CI/CD Pipeline / Test & Lint (20.x) (push) Has been cancelled
CI/CD Pipeline / Security Audit (push) Has been cancelled
Release / Validate Version (push) Has been cancelled
CI/CD Pipeline / Release (push) Has been cancelled
Release / Build and Test (push) Has been cancelled
Release / Create Release (push) Has been cancelled
Release / Publish to NPM (push) Has been cancelled
Release / Deploy Demo (push) Has been cancelled
Multi-Scheme Testing / Validate Naming Schemes (artist) (push) Has been cancelled
Multi-Scheme Testing / Validate Naming Schemes (hierarchical) (push) Has been cancelled
Multi-Scheme Testing / Validate Naming Schemes (legacy) (push) Has been cancelled
Multi-Scheme Testing / Validate Naming Schemes (semantic) (push) Has been cancelled
Multi-Scheme Testing / Test Scheme Conversions (push) Has been cancelled
Multi-Scheme Testing / Validate Demo Functionality (push) Has been cancelled
Multi-Scheme Testing / Performance Benchmarks (push) Has been cancelled
Performance Testing / Animation Conversion Performance (100, artist) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (100, hierarchical) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (100, legacy) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (100, semantic) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (1000, artist) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (1000, hierarchical) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (1000, legacy) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (1000, semantic) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (5000, artist) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (5000, hierarchical) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (5000, legacy) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (5000, semantic) (push) Has been cancelled
Performance Testing / Memory Usage Analysis (push) Has been cancelled
Performance Testing / Demo Performance Audit (push) Has been cancelled
Performance Testing / Generate Performance Report (push) Has been cancelled
Some checks failed
CI/CD Pipeline / Test & Lint (16.x) (push) Has been cancelled
CI/CD Pipeline / Test & Lint (18.x) (push) Has been cancelled
CI/CD Pipeline / Test & Lint (20.x) (push) Has been cancelled
CI/CD Pipeline / Security Audit (push) Has been cancelled
Release / Validate Version (push) Has been cancelled
CI/CD Pipeline / Release (push) Has been cancelled
Release / Build and Test (push) Has been cancelled
Release / Create Release (push) Has been cancelled
Release / Publish to NPM (push) Has been cancelled
Release / Deploy Demo (push) Has been cancelled
Multi-Scheme Testing / Validate Naming Schemes (artist) (push) Has been cancelled
Multi-Scheme Testing / Validate Naming Schemes (hierarchical) (push) Has been cancelled
Multi-Scheme Testing / Validate Naming Schemes (legacy) (push) Has been cancelled
Multi-Scheme Testing / Validate Naming Schemes (semantic) (push) Has been cancelled
Multi-Scheme Testing / Test Scheme Conversions (push) Has been cancelled
Multi-Scheme Testing / Validate Demo Functionality (push) Has been cancelled
Multi-Scheme Testing / Performance Benchmarks (push) Has been cancelled
Performance Testing / Animation Conversion Performance (100, artist) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (100, hierarchical) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (100, legacy) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (100, semantic) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (1000, artist) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (1000, hierarchical) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (1000, legacy) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (1000, semantic) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (5000, artist) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (5000, hierarchical) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (5000, legacy) (push) Has been cancelled
Performance Testing / Animation Conversion Performance (5000, semantic) (push) Has been cancelled
Performance Testing / Memory Usage Analysis (push) Has been cancelled
Performance Testing / Demo Performance Audit (push) Has been cancelled
Performance Testing / Generate Performance Report (push) Has been cancelled
- Implemented StateHandler class with methods for entering, exiting, and updating states. - Created TypeStateHandler for handling typing state with appropriate animations and transitions. - Developed WaitStateHandler for managing idle state with quirk animations. - Added JSDoc documentation for all new classes and methods. - Included CSS styles for documentation formatting and syntax highlighting. fix: update standard configuration to include ignore for scripts directory
This commit is contained in:
244
docs/states_StateHandler.js.html
Normal file
244
docs/states_StateHandler.js.html
Normal file
@ -0,0 +1,244 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>JSDoc: Source: states/StateHandler.js</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"></script>
|
||||
<script src="scripts/prettify/lang-css.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link
|
||||
type="text/css"
|
||||
rel="stylesheet"
|
||||
href="styles/prettify-tomorrow.css"
|
||||
/>
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="main">
|
||||
<h1 class="page-title">Source: states/StateHandler.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* @fileoverview Base state handler class and utilities
|
||||
* @module StateHandler
|
||||
*/
|
||||
|
||||
import { Emotions, Config } from '../constants.js'
|
||||
|
||||
/**
|
||||
* Abstract base class for state handlers
|
||||
* @abstract
|
||||
* @class
|
||||
*/
|
||||
export class StateHandler {
|
||||
/**
|
||||
* Create a state handler
|
||||
* @param {string} stateName - The name of the state
|
||||
* @param {OwenAnimationContext} context - The animation context
|
||||
*/
|
||||
constructor (stateName, context) {
|
||||
/**
|
||||
* The name of this state
|
||||
* @type {string}
|
||||
*/
|
||||
this.stateName = stateName
|
||||
|
||||
/**
|
||||
* The animation context
|
||||
* @type {OwenAnimationContext}
|
||||
*/
|
||||
this.context = context
|
||||
|
||||
/**
|
||||
* Currently playing animation clip
|
||||
* @type {AnimationClip|null}
|
||||
*/
|
||||
this.currentClip = null
|
||||
|
||||
/**
|
||||
* Nested state information
|
||||
* @type {Object|null}
|
||||
*/
|
||||
this.nestedState = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter this state
|
||||
* @abstract
|
||||
* @param {string|null} [_fromState=null] - The previous state (unused in base class)
|
||||
* @param {string} [_emotion=Emotions.NEUTRAL] - The emotion to enter with (unused in base class)
|
||||
* @returns {Promise<void>}
|
||||
* @throws {Error} Must be implemented by subclasses
|
||||
*/
|
||||
async enter (_fromState = null, _emotion = Emotions.NEUTRAL) {
|
||||
throw new Error('enter method must be implemented by subclasses')
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit this state
|
||||
* @abstract
|
||||
* @param {string|null} [_toState=null] - The next state (unused in base class)
|
||||
* @param {string} [_emotion=Emotions.NEUTRAL] - The emotion to exit with (unused in base class)
|
||||
* @returns {Promise<void>}
|
||||
* @throws {Error} Must be implemented by subclasses
|
||||
*/
|
||||
async exit (_toState = null, _emotion = Emotions.NEUTRAL) {
|
||||
throw new Error('exit method must be implemented by subclasses')
|
||||
}
|
||||
|
||||
/**
|
||||
* Update this state (called every frame)
|
||||
* @param {number} _deltaTime - Time elapsed since last update (ms, unused in base class)
|
||||
* @returns {void}
|
||||
*/
|
||||
update (_deltaTime) {
|
||||
// Override in subclasses if needed
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a user message while in this state
|
||||
* @param {string} _message - The user message (unused in base class)
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async handleMessage (_message) {
|
||||
// Override in subclasses if needed
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available transitions from this state
|
||||
* @returns {string[]} Array of state names that can be transitioned to
|
||||
*/
|
||||
getAvailableTransitions () {
|
||||
return []
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for an animation clip to finish playing
|
||||
* @protected
|
||||
* @param {AnimationClip} clip - The animation clip to wait for
|
||||
* @returns {Promise<void>} Promise that resolves when the clip finishes
|
||||
*/
|
||||
async waitForClipEnd (clip) {
|
||||
return new Promise((resolve) => {
|
||||
const checkFinished = () => {
|
||||
if (!clip.isPlaying()) {
|
||||
resolve()
|
||||
} else {
|
||||
requestAnimationFrame(checkFinished)
|
||||
}
|
||||
}
|
||||
checkFinished()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the currently playing clip
|
||||
* @protected
|
||||
* @param {number} [fadeOutDuration] - Fade out duration
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async stopCurrentClip (fadeOutDuration = Config.DEFAULT_FADE_OUT) {
|
||||
if (this.currentClip) {
|
||||
await this.currentClip.stop(fadeOutDuration)
|
||||
this.currentClip = null
|
||||
}
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2>
|
||||
<h3>Modules</h3>
|
||||
<ul>
|
||||
<li><a href="module-StateHandler.html">StateHandler</a></li>
|
||||
<li><a href="module-animation.html">animation</a></li>
|
||||
<li>
|
||||
<a href="module-animation_AnimationConstants.html"
|
||||
>animation/AnimationConstants</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="module-animation_AnimationNameMapper.html"
|
||||
>animation/AnimationNameMapper</a
|
||||
>
|
||||
</li>
|
||||
<li><a href="module-constants.html">constants</a></li>
|
||||
<li><a href="module-core.html">core</a></li>
|
||||
<li><a href="module-factories.html">factories</a></li>
|
||||
<li><a href="module-loaders.html">loaders</a></li>
|
||||
<li><a href="module-owen.html">owen</a></li>
|
||||
<li><a href="module-states.html">states</a></li>
|
||||
</ul>
|
||||
<h3>Classes</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="module-StateHandler.StateHandler.html">StateHandler</a>
|
||||
</li>
|
||||
<li><a href="module-animation.AnimationClip.html">AnimationClip</a></li>
|
||||
<li>
|
||||
<a href="module-animation.AnimationClipFactory.html"
|
||||
>AnimationClipFactory</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="module-animation_AnimationNameMapper.AnimationNameMapper.html"
|
||||
>AnimationNameMapper</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="module-core.OwenAnimationContext.html"
|
||||
>OwenAnimationContext</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="module-factories.OwenSystemFactory.html"
|
||||
>OwenSystemFactory</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="module-loaders.AnimationLoader.html">AnimationLoader</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="module-loaders.GLTFAnimationLoader.html"
|
||||
>GLTFAnimationLoader</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="module-states.ReactStateHandler.html">ReactStateHandler</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="module-states.SleepStateHandler.html">SleepStateHandler</a>
|
||||
</li>
|
||||
<li><a href="module-states.StateFactory.html">StateFactory</a></li>
|
||||
<li>
|
||||
<a href="module-states.TypeStateHandler.html">TypeStateHandler</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="module-states.WaitStateHandler.html">WaitStateHandler</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<br class="clear" />
|
||||
|
||||
<footer>
|
||||
Documentation generated by
|
||||
<a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.4</a> on Sat May 24
|
||||
2025 12:29:38 GMT+0200 (Midden-Europese zomertijd)
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
prettyPrint();
|
||||
</script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user