Interaction

Interaction Overview

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:

Initialization

When initializing the engine, you can customize the listening sources for touch, keyboard, and wheel.

image.png
// 将触控事件的监听源设置为 document
const engine = await WebGLEngine.create({
  canvas,
  input: {
    pointerTarget: document,
  },
});

⚠️ Do not set the listening source of touch to window, because window cannot receive PointerLevel events, which will cause touch information confusion.

⚠️ If you set the listening source of the keyboard to a certain HtmlElement, you need to set its tabIndex so that it can be focused. For example, you can call canvas.tabIndex = canvas.tabIndex; once.

Framebuffer Picking

If the engine's touch callback cannot meet your needs, you can try using framebuffer picking

Was this page helpful?