Galacean provides a basic input system. Based on cross-end and cross-platform features, the interaction system is well compatible with both PC and mobile ends. The current interaction system can accept the following inputs:
When initializing the engine, you can customize the listening sources for touch, keyboard, and wheel.
// 将触控事件的监听源设置为 document
const engine = await WebGLEngine.create({
canvas,
input: {
pointerTarget: document,
},
});
⚠️ Do not set the listening source of touch to
window
, becausewindow
cannot receivePointerLevel
events, which will cause touch information confusion.
⚠️ If you set the listening source of the keyboard to a certain
HtmlElement
, you need to set itstabIndex
so that it can be focused. For example, you can callcanvas.tabIndex = canvas.tabIndex;
once.
If the engine's touch callback cannot meet your needs, you can try using framebuffer picking