@meetkaims/npc-babylonjs
v1.0.4
Published
</br>
Downloads
17
Keywords
Readme
NPC SDK for Babylonjs
Installation
yarn add @meetkaims/npc-babylonjs
or
npm i @meetkaims/npc-babylonjs
Basic usage
create avatar
const avatar = new Avatar(scene, { assetUrl, apikey });
await avatar.create();
Add AudioContext
to babylon Engine.
- pass audioContext and use babylon engin's global audio context
const engine = new Engine(canvas, true, {
audioEngine: true,
audioEngineOptions: { audioContext: new AudioContext() },
});
- audio context can be accessed
scene.getEngine().getAudioContext();
Inference text request
- ask avatar a questio◊n by passing text
avatar.inferenceText({
npcId: 19,
endUserId: 123,
voiceId: 'Giorgio',
message: 'hello what are you doing',
});
Inference speech
- starts microphone, listens for speech. Ask quesiton by talking
await avatar.inferenceSpeech({
npcId: 19,
endUserId: 123,
voiceId: 'Giorgio',
});
Avatar positions
get avatar position & rotation
console.log(avatar.position);
console.log(avatar.rotation);
set avatar position & rotation
avatar.setPosition(new Vector3(0, 0, 0));
avatar.setRotation(new Vector3(0, 0, 0));