@galacean/engine-ui 1.4.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2020 - present Ant Group
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # @galacean/engine-ui
2
+
3
+ `@galacean/engine-ui` is a UI library designed for the `@galacean/engine`, this library enables developers to create and manage user interfaces efficiently within their **Galacean-based** applications. It is important to note that it is currently in an **experimental version**.
4
+
5
+ ## Features
6
+
7
+ - **Rendering components**: Includes `Image` and `Text`.
8
+ - **Interactive Components**: Include `Button`, as well as other planned basic rendering components to be added in the future.
9
+ - **Event Handling**: Supports the dispatch and bubbling of events such as `onPointerEnter`, `onPointerExit`,`onPointerDown`, `onPointerUp`, `onPointerClick`, `onPointerDrag` and `onPointerDrop`.
10
+ - **Optimized Performance**: Designed to run smoothly with the Galacean engine.
11
+
12
+ ## Installation
13
+
14
+ To use `@galacean/engine-ui` in your project, install it via npm:
15
+
16
+ ```bash
17
+ npm install @galacean/engine-ui
18
+ ```
19
+
20
+ ## Getting Started
21
+
22
+ Here is a simple example to help you get started:
23
+
24
+ ```typescript
25
+ import { AssetType, Camera, Sprite, Texture2D, Vector3, WebGLEngine } from "@galacean/engine";
26
+ import { CanvasRenderMode, Image, ResolutionAdaptationMode, UICanvas } from "@galacean/engine-ui";
27
+
28
+ // Initialize engine and scene
29
+ const engine = await WebGLEngine.create({ canvas: "canvas" });
30
+ const scene = engine.sceneManager.activeScene;
31
+ const rootEntity = scene.createRootEntity();
32
+
33
+ // Create camera
34
+ const cameraEntity = rootEntity.createChild("Camera");
35
+ cameraEntity.transform.position = new Vector3(0, 0, 10);
36
+ const camera = cameraEntity.addComponent(Camera);
37
+ camera.farClipPlane = 200;
38
+ camera.nearClipPlane = 0.3;
39
+
40
+ // Create canvas
41
+ const canvasEntity = rootEntity.createChild("canvas");
42
+ const canvas = canvasEntity.addComponent(UICanvas);
43
+ canvas.renderMode = CanvasRenderMode.ScreenSpaceCamera;
44
+ canvas.resolutionAdaptationMode = ResolutionAdaptationMode.HeightAdaptation;
45
+ canvas.distance = 100;
46
+ canvas.renderCamera = camera;
47
+
48
+ // Create Image
49
+ const imageEntity = canvasEntity.createChild("image");
50
+ const image = imageEntity.addComponent(Image);
51
+ engine.resourceManager
52
+ .load({
53
+ url: "https://xxx.png",
54
+ type: AssetType.Texture2D
55
+ })
56
+ .then((texture) => {
57
+ image.sprite = new Sprite(engine, <Texture2D>texture);
58
+ });
59
+
60
+ // Run the engine
61
+ engine.run();
62
+ ```
63
+ Easier operations in the [Editor](https://galacean.antgroup.com/editor/).
64
+
65
+ ## Documentation
66
+
67
+ For detailed documentation, visit [the official documentation site](https://galacean.antgroup.com/engine).