Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

1.5 KB
Raw Blame
import { UIElement } from './libs/ui.js';

function AnimationResizer( editor ) {

	const signals = editor.signals;

	const dom = document.createElement( 'div' );
	dom.id = 'animation-resizer';

	let panelHeight = 36;
	let startY = 0;
	let startHeight = 0;

	function onPointerDown( event ) {

		if ( event.isPrimary === false ) return;

		startY = event.clientY;
		startHeight = panelHeight;

		dom.ownerDocument.addEventListener( 'pointermove', onPointerMove );
		dom.ownerDocument.addEventListener( 'pointerup', onPointerUp );

	}

	function onPointerUp( event ) {

		if ( event.isPrimary === false ) return;

		dom.ownerDocument.removeEventListener( 'pointermove', onPointerMove );
		dom.ownerDocument.removeEventListener( 'pointerup', onPointerUp );

	}

	function onPointerMove( event ) {

		if ( event.isPrimary === false ) return;

		const deltaY = startY - event.clientY;
		const newHeight = startHeight + deltaY;
		const maxHeight = window.innerHeight / 2;

		// Clamp between 36px (top bar only) and half the window height
		panelHeight = Math.max( 36, Math.min( maxHeight, newHeight ) );

		signals.animationPanelResized.dispatch( panelHeight );

	}

	dom.addEventListener( 'pointerdown', onPointerDown );

	// Show/hide based on animation panel visibility
	signals.animationPanelChanged.add( function ( height ) {

		if ( height === false ) {

			dom.style.display = 'none';

		} else {

			dom.style.display = 'block';
			dom.style.bottom = height + 'px';
			panelHeight = height;

		}

	} );

	return new UIElement( dom );

}

export { AnimationResizer };