/** * vue-vrm * * @description Vrm viewer component for Vue 3 / WebComponents. * @author Logue * @license MIT * @version 0.4.0 * @see {@link https://github.com/logue/vue-vrm} */ import { type ComputedRef, type EmitFn, type ExtractPropTypes, type PropType, type Ref } from 'vue'; import type { CameraChangePayload } from '../types/VrmCameraTypes.js'; import type { VrmCanvasExposed } from '../types/VrmCanvasExposed.js'; import type { CameraInteractionOptions, CameraOptions, DirectionalLightOptions, LightOptions, Vec3 } from '../types/VrmCanvasOptions.js'; import type { VrmAutoBlinkOptions, VrmExpressions } from '../types/VrmExpressionTypes.js'; import type { AnimationData } from '../types/VrmModelTypes.js'; import type { VrmRenderFunction, VrmRenderTargets, VrmResizePayload } from '../types/VrmRenderTypes.js'; import type { VRM } from '@pixiv/three-vrm'; import type { VRMAnimation } from '@pixiv/three-vrm-animation'; import type { Vector3 } from 'three'; import type { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js'; /** `VrmCanvas` props definition (shared by the Vue component and the Web Component). */ export declare const vrmCanvasProps: { /** The VRM model data as an ArrayBuffer. */ readonly modelData: { readonly type: PropType; }; /** The VRM animation data as an ArrayBuffer or an array of ArrayBuffers. */ readonly animationData: { readonly type: PropType; }; /** The weights for each animation. */ readonly animationWeights: { readonly type: PropType; }; /** Whether the animation should loop. */ readonly loop: { readonly type: BooleanConstructor; readonly default: true; }; /** * Expression weights (0–1) keyed by preset or custom expression name, e.g. `{ happy: 1 }`. * Applied every frame after the animation; expressions not listed are left untouched. */ readonly expressions: { readonly type: PropType; }; /** * Blink automatically at random intervals. `true` uses the defaults; pass an object to tune them. * Ignored while `blink` is set through `expressions` or `setExpression()`. */ readonly autoBlink: { readonly type: PropType; readonly default: false; }; /** Whether the background should be transparent. */ readonly bgTransparent: { readonly type: BooleanConstructor; readonly default: false; }; /** The background image URL. */ readonly bgImage: { readonly type: StringConstructor; }; /** Whether to show the grid helper. */ readonly showGrid: { readonly type: BooleanConstructor; readonly default: false; }; /** * The width of the canvas: pixels as a number, or a CSS length such as `'100%'` * to follow the parent's width while keeping `aspectRatio`. */ readonly width: { readonly type: PropType; readonly default: 480; }; /** The maximum width of the canvas in pixels. */ readonly maxWidth: { readonly type: NumberConstructor; }; /** The aspect ratio (width / height) to maintain. Height is derived from width and this ratio. */ readonly aspectRatio: { readonly type: NumberConstructor; readonly default: number; }; /** Options for configuring the camera. */ readonly cameraOptions: { readonly type: PropType; readonly default: () => CameraOptions; }; /** The distance of the camera from the target. Defaults to a distance that fits the model. */ readonly cameraDistance: { readonly type: NumberConstructor; }; /** The Euler angles (X, Y, Z) for the camera rotation around the target. */ readonly cameraEuler: { readonly type: PropType; readonly default: () => Vec3; }; /** The offset of the camera from the target. */ readonly cameraOffset: { readonly type: PropType; readonly default: () => Vec3; }; /** The point the camera is looking at. */ readonly cameraLookAt: { readonly type: PropType; readonly default: () => Vec3; }; /** Options for the ambient light (color and intensity). */ readonly ambientLight: { readonly type: PropType; readonly default: () => LightOptions; }; /** Options for the directional light (color, intensity, and position). */ readonly directionalLight: { readonly type: PropType; readonly default: () => DirectionalLightOptions; }; /** An optional postprocessing shader pass to apply. */ readonly shaderPass: { readonly type: PropType; }; /** Optional camera interaction controls. */ readonly cameraInteraction: { readonly type: PropType; }; /** * Custom per-frame render function. When set, it is called instead of the default * `renderer.render(scene, camera)` (and instead of the built-in `shaderPass` composer), * after the mixer and `vrm.update()` have run for the frame. */ readonly render: { readonly type: PropType; }; }; /** Resolved prop types for {@link vrmCanvasProps}. */ export type VrmCanvasProps = ExtractPropTypes; /** `VrmCanvas` emits definition. */ export declare const vrmCanvasEmits: { /** Emitted when the model starts loading. */ 'model:loading': () => boolean; /** Emitted when the model has successfully loaded. */ 'model:loaded': (_vrm: VRM) => boolean; /** Emitted when the model is unloaded. */ 'model:unloaded': () => boolean; /** Emitted when there is an error loading the model. */ 'model:error': (_error: Error) => boolean; /** Emitted when the animation starts loading. */ 'animation:loading': () => boolean; /** Emitted when the animation has successfully loaded. */ 'animation:loaded': (_animation: VRMAnimation | VRMAnimation[]) => boolean; /** Emitted when the animation starts playing. */ 'animation:start': () => boolean; /** Emitted when the animation is paused. */ 'animation:pause': () => boolean; /** Emitted when the animation is resumed. */ 'animation:resume': () => boolean; /** Emitted when the animation is stopped. */ 'animation:stop': () => boolean; /** Emitted when a non-looping animation ends. */ 'animation:end': () => boolean; /** Emitted when there is an error loading the animation. */ 'animation:error': (_error: Error) => boolean; /** Emitted when the camera position or target changes. */ 'camera:change': (_payload: CameraChangePayload) => boolean; /** * Emitted when the camera options change (fov, near, far). * Changes to cameraDistance, cameraEuler, cameraOffset, or cameraLookAt * only trigger 'camera:change'. */ 'camera:options-change': (_payload: Required) => boolean; /** Emitted when the ambient light changes. */ 'light:ambient-change': (_payload: LightOptions) => boolean; /** Emitted when the directional light changes. */ 'light:directional-change': (_payload: LightOptions & { position: Vector3; }) => boolean; /** * Emitted once the renderer, scene, and camera exist (on mount), before the first frame. * Create custom postprocessing (e.g. an `EffectComposer`) here. */ 'renderer:ready': (_targets: VrmRenderTargets) => boolean; /** * Emitted on unmount, before the renderer is disposed. * Dispose custom postprocessing here. */ 'renderer:dispose': () => boolean; /** Emitted after the renderer and camera have been resized (also once on mount). */ resize: (_payload: VrmResizePayload) => boolean; /** Emitted on other errors (e.g. background image failed to load). */ error: (_error: Error) => boolean; }; /** Typed `emit` function matching {@link vrmCanvasEmits}. */ export type VrmCanvasEmit = EmitFn; /** * Sets up a VRM viewer bound to `props` and reports state changes through `emit`. * * Wires the scene, camera, model, sizing, and render-loop composables together and * handles the mount / unmount lifecycle, so the `VrmCanvas` component and the Web * Component only need to render the markup. * * @param props - Resolved `VrmCanvas` props. * @param emit - Typed emit function. */ export declare function useVrmCanvas(props: VrmCanvasProps, emit: VrmCanvasEmit): { /** `
` wrapper element (template ref). */ container: Ref; /** `` element (template ref). */ canvas: Ref; /** Inline size style for the container. */ containerStyle: ComputedRef>; /** Keyboard handler for the canvas (camera roll). */ handleCanvasKeydown: (event: KeyboardEvent) => void; /** Public API to expose from the component instance. */ exposed: VrmCanvasExposed; };