facefound
facecontroller.facefound
Description
This event is emitted by Face Effects when a face is first found.
Event Properties
facecontroller.facefound.data : { id, transform, vertices, normals, attachmentPoints }
Property | Type | Description |
---|---|---|
id | Number | A numerical id of the located face |
transform | TransformObject | Transform information of the located face. |
vertices | [{x, y, z}] | Position of face points, relative to transform. |
normals | [{x, y, z}] | Normal direction of vertices, relative to transform. |
attachmentPoints | { name, position: {x,y,z} } | See XR8.FaceController.AttachmentPoints for list of available attachment points. position is relative to the transform. |
uvsInCameraFrame | [{u, v}] | The list of uv positions in the camera frame corresponding to the returned vertex points. |
TransformObject
TransformObject
is an object with the following properties: {position, rotation, scale, scaledWidth, scaledHeight, scaledDepth}
Property | Type | Description |
---|---|---|
position | {x, y, z} | The 3d position of the located face. |
rotation | {w, x, y, z} | The 3d local orientation of the located face. |
scale | Number | A scale factor that should be applied to objects attached to this face. |
scaledWidth | Number | Approximate width of the head in the scene when multiplied by scale. |
scaledHeight | Number | Approximate height of the head in the scene when multiplied by scale. |
scaledDepth | Number | Approximate depth of the head in the scene when multiplied by scale. |
Example
ecs.registerComponent({
name: 'facefound',
add: (world, component) => {
const found = ({data}) => {
const {id, transform, vertices, normals, attachmentPoints, uvsInCameraFrame} = data
doSomething(id, transform, vertices, normals, attachmentPoints, uvsInCameraFrame)
}
world.events.addListener(world.events.globalId, 'facecontroller.facefound', found)
},
})