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:
256
docs/states_WaitStateHandler.js.html
Normal file
256
docs/states_WaitStateHandler.js.html
Normal file
@ -0,0 +1,256 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>JSDoc: Source: states/WaitStateHandler.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/WaitStateHandler.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* @fileoverview Wait state handler implementation
|
||||
* @module states
|
||||
*/
|
||||
|
||||
import { StateHandler } from './StateHandler.js'
|
||||
import { States, Emotions, Config } from '../constants.js'
|
||||
|
||||
/**
|
||||
* Handler for the Wait/Idle state
|
||||
* @class
|
||||
* @extends StateHandler
|
||||
*/
|
||||
export class WaitStateHandler extends StateHandler {
|
||||
/**
|
||||
* Create a wait state handler
|
||||
* @param {OwenAnimationContext} context - The animation context
|
||||
*/
|
||||
constructor (context) {
|
||||
super(States.WAITING, context)
|
||||
|
||||
/**
|
||||
* The main idle animation clip
|
||||
* @type {AnimationClip|null}
|
||||
*/
|
||||
this.idleClip = null
|
||||
|
||||
/**
|
||||
* Available quirk animations
|
||||
* @type {AnimationClip[]}
|
||||
*/
|
||||
this.quirks = []
|
||||
|
||||
/**
|
||||
* Timer for quirk animations
|
||||
* @type {number}
|
||||
*/
|
||||
this.quirkTimer = 0
|
||||
|
||||
/**
|
||||
* Interval between quirk attempts (ms)
|
||||
* @type {number}
|
||||
*/
|
||||
this.quirkInterval = Config.QUIRK_INTERVAL
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter the wait state
|
||||
* @param {string|null} [fromState=null] - The previous state
|
||||
* @param {string} [emotion=Emotions.NEUTRAL] - The emotion to enter with
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async enter (fromState = null, _emotion = Emotions.NEUTRAL) {
|
||||
console.log(`Entering WAITING state from ${fromState}`)
|
||||
|
||||
// Play idle loop
|
||||
this.idleClip = this.context.getClip('wait_idle_L')
|
||||
if (this.idleClip) {
|
||||
await this.idleClip.play()
|
||||
this.currentClip = this.idleClip
|
||||
}
|
||||
|
||||
// Collect available quirks
|
||||
this.quirks = this.context.getClipsByPattern('wait_*_Q')
|
||||
this.quirkTimer = 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit the wait state
|
||||
* @param {string|null} [toState=null] - The next state
|
||||
* @param {string} [emotion=Emotions.NEUTRAL] - The emotion to exit with
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async exit (toState = null, _emotion = Emotions.NEUTRAL) {
|
||||
console.log(`Exiting WAITING state to ${toState}`)
|
||||
|
||||
if (this.currentClip) {
|
||||
await this.stopCurrentClip()
|
||||
}
|
||||
|
||||
// Play transition if available
|
||||
const transitionName = `wait_2${toState}_T`
|
||||
const transition = this.context.getClip(transitionName)
|
||||
if (transition) {
|
||||
await transition.play()
|
||||
await this.waitForClipEnd(transition)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the wait state
|
||||
* @param {number} deltaTime - Time elapsed since last update (ms)
|
||||
* @returns {void}
|
||||
*/
|
||||
update (deltaTime) {
|
||||
this.quirkTimer += deltaTime
|
||||
|
||||
// Randomly play quirks
|
||||
if (this.quirkTimer > this.quirkInterval && Math.random() < Config.QUIRK_PROBABILITY) {
|
||||
this.playRandomQuirk()
|
||||
this.quirkTimer = 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Play a random quirk animation
|
||||
* @private
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async playRandomQuirk () {
|
||||
if (this.quirks.length === 0) return
|
||||
|
||||
const quirk = this.quirks[Math.floor(Math.random() * this.quirks.length)]
|
||||
|
||||
// Fade out idle
|
||||
if (this.idleClip) {
|
||||
await this.idleClip.stop(0.2)
|
||||
}
|
||||
|
||||
// Play quirk
|
||||
await quirk.play()
|
||||
await this.waitForClipEnd(quirk)
|
||||
|
||||
// Return to idle
|
||||
if (this.idleClip) {
|
||||
await this.idleClip.play()
|
||||
this.currentClip = this.idleClip
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available transitions from wait state
|
||||
* @returns {string[]} Array of available state transitions
|
||||
*/
|
||||
getAvailableTransitions () {
|
||||
return [States.REACTING, States.SLEEPING]
|
||||
}
|
||||
}
|
||||
</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