Skip to main content

Getting Stared

In the following tutorials, we will create several UIs using koestlich and react-three/fiber. Install the dependencies manually via `npm i @coconut-xr/koestlich @react-three/fiber react react-dom three` or use the CodeSandbox provided for each example.

📄️ Animations

Animations are built into koestlich and work out of the box. Almost all properties can be animated. In contrast to HTML/CSS, elements can transition from one place in a layout to another, a feature often referred to as AutoTransition. To declare how UI elements relate between two different layouts, the id property is used. Placing the same id property on two UI components in different layouts will keep the underlying UI element alive and automatically transition. However, both UI components need to have the same type. Therefore, it is impossible to transition an Image to a Text component.

📄️ Custom Materials

Koestlich allows to provide custom materials for the background on the Text, Container, and Image components. Using the library @coconut-xr/xmaterials, a new material can be built based on the existing three materials. Every provided material must be at least be a border material created through makeBorderMaterial. The makeBorderMaterial allows to provide default properties to the material. In the following example, we are creating a text element with a material based on the phong material with high specular and shininess. Using the border properties, we can create a border that creates the illusion of a 3d mesh. Specifically, the borderBend property allows bending the normals on the border to create this effect efficiently. The anchorX and anchorY properties allow the button in the following example to have its origin in (0,0,0).