u-space 0.0.0-alpha.2 → 0.0.1

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.
@@ -1,48 +1,48 @@
1
- # Examples Guide
1
+ # 示例指南
2
2
 
3
- `u-space` contains an extensive `examples/` directory that demonstrates the engine's capabilities. Below are a few key examples and what they teach you about the system.
3
+ `u-space` 的 `examples/` 目录中包含了大量演示引擎功能的示例。以下是几个关键示例及其所展示的系统特性。
4
4
 
5
- ## 1. `demo01.html`: Basic Setup & Interactivity
5
+ ## 1. `demo01.html`:基础配置与交互
6
6
 
7
- This example demonstrates the absolute bare-minimum setup required to get a 3D scene rendering via WebGPU, as covered in the [Getting Started](./getting-started.md) guide.
7
+ 该示例演示了通过 WebGPU 渲染 3D 场景所需的最少配置,与 [快速上手](./getting-started.md) 指南中的内容一致。
8
8
 
9
- ### Key Takeaways:
9
+ ### 核心要点:
10
10
 
11
- - Injecting the `Viewer` into a DOM element.
12
- - Setting the scene background using WebGPU `Color`.
13
- - Adding primitive geometries (like `BoxGeometry`).
14
- - Enabling global interaction via `viewer.interactionManager.pointerMoveEventsEnabled`.
15
- - Attaching DOM-style event listeners (`click`, `pointerenter`, `pointerleave`) natively to 3D meshes.
11
+ - 将 `Viewer` 注入 DOM 元素。
12
+ - 使用 WebGPU `Color` 设置场景背景。
13
+ - 添加基础几何体(如 `BoxGeometry`)。
14
+ - 通过 `viewer.interactionManager.pointerMoveEventsEnabled` 启用全局交互。
15
+ - 像操作 DOM 元素一样,为 3D 网格原生绑定事件监听(`click`、`pointerenter`、`pointerleave`)。
16
16
 
17
- ## 2. `test_loader.html`: Model Caching Mechanics
17
+ ## 2. `test_loader.html`:模型缓存机制
18
18
 
19
- This example dives deep into the `u-space` Model Loader pipeline and explains the differences between runtime cache and browser persistent cache.
19
+ 该示例深入解析了 `u-space` 的模型加载管线,阐明运行时缓存与浏览器持久化缓存之间的区别。
20
20
 
21
- ### Key Takeaways:
21
+ ### 核心要点:
22
22
 
23
- - Utilizing the global `Model` class to load `.glb` files asynchronously via `Model.prototype.loadAsync()`.
24
- - Demystifying `cache: true` (which retains the model node in RAM for instant cloning/instantiation).
25
- - Demystifying `persistent: true` (which uses the Service Worker / Cache Storage API to cache the actual network request bytes).
26
- - Demonstrates how to register these loaded asynchronous assets into the `viewer.objectManager` securely.
27
- - Provides examples on programmatically flushing the caches using `Model.clearMemoryCache()` and `Model.clearPersistentCache()`.
23
+ - 使用全局 `Model` 类通过 `Model.prototype.loadAsync()` 异步加载 `.glb` 文件。
24
+ - 理解 `cache: true`(将模型节点保留在内存中,可实现即时克隆/实例化)。
25
+ - 理解 `persistent: true`(使用 Service Worker / Cache Storage API 对实际网络请求数据进行持久化缓存)。
26
+ - 演示如何将这些异步加载的资源安全地注册到 `viewer.objectManager`。
27
+ - 提供通过 `Model.clearMemoryCache()` 和 `Model.clearPersistentCache()` 手动清除缓存的示例。
28
28
 
29
- ## 3. `load_tiles.html`: GIS & Earth Rendering
29
+ ## 3. `load_tiles.html`:GIS 与地球渲染
30
30
 
31
- This example uses the external `3d-tiles-renderer` peer dependency securely wrapped by a `u-space` plugin to render massive level-of-detail GIS globes.
31
+ 该示例使用外部对等依赖 `3d-tiles-renderer`,通过 `u-space` 插件安全封装后,渲染大规模 LOD GIS 地球。
32
32
 
33
- ### Key Takeaways:
33
+ ### 核心要点:
34
34
 
35
- - Instantiating complex plugins (`ArcgisTilesRenderer`) dynamically passing the core viewer reference.
36
- - Using `viewer.frameloop = 'always'` since tiles stream asynchronously and continuously update the viewport.
37
- - Fetching specific Longitude and Latitude positions using the plugin's `invalidate(lon, lat, zoom)` method.
35
+ - 动态实例化复杂插件(`ArcgisTilesRenderer`),并传入核心 viewer 引用。
36
+ - 由于瓦片是异步流式加载并持续更新视口的,需使用 `viewer.frameloop = 'always'`。
37
+ - 通过插件的 `invalidate(lon, lat, zoom)` 方法定位到指定的经纬度位置。
38
38
 
39
- ## 4. `test_umanager.html`: Scene Compositions & Parsers
39
+ ## 4. `test_umanager.html`:场景组合与解析器
40
40
 
41
- This robust example combines multiple tools, illustrating how to build complete applications instead of just placing single models.
41
+ 该综合示例融合了多种工具,展示如何构建完整的应用程序,而不仅仅是放置单个模型。
42
42
 
43
- ### Key Takeaways:
43
+ ### 核心要点:
44
44
 
45
- - Initializing multiple Plugins concurrently (minimap, tracking, keyboard-controls) and toggling their state via `.enable()` / `.disable()`.
46
- - Streaming structured scene layouts, parsing scene descriptions (`SceneLoader`, `TopologiesLoader`).
47
- - Working with camera animations (`VisionsLoader` and `VisionsParser`) to choreograph pre-defined flight paths securely within the scene.
48
- - Retrieving complex Node materials and customizing WebGPU specific TSL (Three Shading Language) nodes like `TSLEffects.fluid()`.
45
+ - 同时初始化多个插件(minimap、tracking、keyboard-controls),并通过 `.enable()` / `.disable()` 切换其状态。
46
+ - 流式传输结构化场景布局,解析场景描述(`SceneLoader`、`TopologiesLoader`)。
47
+ - 使用相机动画(`VisionsLoader` 和 `VisionsParser`)在场景中编排预定义的飞行路径。
48
+ - 获取复杂的节点材质,并自定义 WebGPU 专属的 TSL(Three Shading Language)节点,如 `TSLEffects.fluid()`。
@@ -1,26 +1,26 @@
1
- # Getting Started with `u-space`
1
+ # 快速上手 `u-space`
2
2
 
3
- `u-space` is a WebGPU-ready 3D engine built on top of Three.js. This guide will show you how to set up a basic `u-space` application.
3
+ `u-space` 是一个基于 Three.js 的 WebGPU 3D 引擎。本指南将向你展示如何搭建一个基础的 `u-space` 应用。
4
4
 
5
- ## Installation
5
+ ## 安装
6
6
 
7
- Ensure you have `@types/three` and `three` installed as peer dependencies. If you plan to use interactions, you might also need `camera-controls`.
7
+ 确保已将 `@types/three` 和 `three` 安装为对等依赖。如果你计划使用交互功能,还需要安装 `camera-controls`。
8
8
 
9
9
  ```bash
10
10
  pnpm install three camera-controls
11
11
  ```
12
12
 
13
- ## Basic Setup
13
+ ## 基础配置
14
14
 
15
- Here is a minimal example of setting up a `u-space` `Viewer` and adding an interactive object to the scene.
15
+ 以下是一个最小示例,展示如何初始化 `u-space` 的 `Viewer` 并向场景中添加一个可交互对象。
16
16
 
17
- ### 1. HTML Structure
17
+ ### 1. HTML 结构
18
18
 
19
- Create an element to house your 3D viewer.
19
+ 创建一个容纳 3D 查看器的元素。
20
20
 
21
21
  ```html
22
22
  <!DOCTYPE html>
23
- <html lang="en">
23
+ <html lang="zh">
24
24
  <head>
25
25
  <meta charset="UTF-8" />
26
26
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
@@ -28,14 +28,14 @@ Create an element to house your 3D viewer.
28
28
  </head>
29
29
  <body style="margin: 0">
30
30
  <div id="app" style="width: 100vw; height: 100vh"></div>
31
- <!-- Script goes here -->
31
+ <!-- 脚本放这里 -->
32
32
  </body>
33
33
  </html>
34
34
  ```
35
35
 
36
36
  ### 2. Import Maps
37
37
 
38
- Since `u-space` relies on Three.js WebGPU features, it's recommended to set up an import map to resolve the WebGPU build of Three.js.
38
+ 由于 `u-space` 依赖 Three.js 的 WebGPU 特性,建议配置 Import Map 以解析 Three.js 的 WebGPU 构建版本。
39
39
 
40
40
  ```html
41
41
  <script type="importmap">
@@ -51,9 +51,9 @@ Since `u-space` relies on Three.js WebGPU features, it's recommended to set up a
51
51
  </script>
52
52
  ```
53
53
 
54
- ### 3. Initialize Viewer & Add Objects
54
+ ### 3. 初始化 Viewer 并添加对象
55
55
 
56
- Now, initialize the `Viewer` and add a basic Three.js object to the scene.
56
+ 初始化 `Viewer` 并向场景中添加一个基础 Three.js 对象。
57
57
 
58
58
  ```html
59
59
  <script type="module">
@@ -62,48 +62,48 @@ Now, initialize the `Viewer` and add a basic Three.js object to the scene.
62
62
 
63
63
  const app = document.getElementById('app');
64
64
 
65
- // Initialize the viewer
65
+ // 初始化查看器
66
66
  const viewer = new Viewer({
67
67
  el: app,
68
- rendererOptions: { forceWebGL: false }, // Prefer WebGPU
68
+ rendererOptions: { forceWebGL: false }, // 优先使用 WebGPU
69
69
  });
70
70
 
71
- // Set background color
71
+ // 设置背景颜色
72
72
  viewer.scene.background = new Color(0x666666);
73
73
 
74
- // Add a grid
74
+ // 添加网格辅助线
75
75
  const gridHelper = new GridHelper(10, 10);
76
76
  viewer.scene.add(gridHelper);
77
77
 
78
- // Add a Box
78
+ // 添加一个立方体
79
79
  const geometry = new BoxGeometry(1, 1, 1);
80
80
  const material = new MeshBasicMaterial({ color: 0xff0000 });
81
81
  const box = new Mesh(geometry, material);
82
82
  box.position.set(0, 0.5, 0);
83
83
  viewer.scene.add(box);
84
84
 
85
- // Render the scene
85
+ // 渲染场景
86
86
  viewer.render();
87
87
  </script>
88
88
  ```
89
89
 
90
- ### 4. Enable Interactions
90
+ ### 4. 启用交互
91
91
 
92
- `u-space` has a built-in `InteractionManager`. You can easily add event listeners to your 3D objects.
92
+ `u-space` 内置了 `InteractionManager`,可以轻松为 3D 对象添加事件监听。
93
93
 
94
94
  ```javascript
95
- // Enable pointer move events
95
+ // 启用指针移动事件
96
96
  viewer.interactionManager.targetObjects = [];
97
97
  viewer.interactionManager.pointerMoveEventsEnabled = true;
98
98
 
99
- // Add click event
99
+ // 添加点击事件
100
100
  box.addEventListener('click', (e) => {
101
- console.log('Clicked at:', e.event.intersect.point);
101
+ console.log('点击位置:', e.event.intersect.point);
102
102
  material.color.set(Math.random() * 0xffffff);
103
- viewer.render(); // Request a new frame
103
+ viewer.render(); // 请求新一帧渲染
104
104
  });
105
105
 
106
- // Add hover events
106
+ // 添加悬停事件
107
107
  box.addEventListener('pointerenter', (e) => {
108
108
  document.body.style.cursor = 'pointer';
109
109
  material.color.set(0x00ff00);
@@ -117,15 +117,15 @@ box.addEventListener('pointerleave', (e) => {
117
117
  });
118
118
  ```
119
119
 
120
- And that's it! You now have a basic `u-space` application up and running.
120
+ 这样就完成了!你现在拥有一个基础的 `u-space` 应用。
121
121
 
122
- ## Next Steps
122
+ ## 下一步
123
123
 
124
- - Learn more about the [Viewer API](./api-viewer.md)
125
- - Explore how to [load Models and work with Objects](./api-objects.md)
126
- - Understand the [Interaction System](./api-interactions.md)
127
- - Register and retrieve objects with the [Managers API](./api-managers.md)
128
- - Add tile maps, minimap, keyboard controls and more with the [Plugins API](./api-plugins.md)
129
- - Animate properties with the [Animations API](./api-animations.md)
130
- - Apply visual effects with the [Effects API](./api-effects.md)
131
- - Browse the [Examples Guide](./examples-guide.md)
124
+ - 深入了解 [Viewer API](./api-viewer.md)
125
+ - 探索如何 [加载模型与使用对象](./api-objects.md)
126
+ - 理解 [交互系统](./api-interactions.md)
127
+ - 使用 [Managers API](./api-managers.md) 注册和检索对象
128
+ - 通过 [Plugins API](./api-plugins.md) 添加瓦片地图、小地图、键盘控制等功能
129
+ - 使用 [Animations API](./api-animations.md) 为属性添加动画
130
+ - 使用 [Effects API](./api-effects.md) 应用视觉特效
131
+ - 浏览 [示例指南](./examples-guide.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "u-space",
3
- "version": "0.0.0-alpha.2",
3
+ "version": "0.0.1",
4
4
  "type": "module",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "module": "dist/index.js",
@@ -28,7 +28,8 @@
28
28
  "docs:dev": "vitepress dev docs",
29
29
  "docs:build": "vitepress build docs",
30
30
  "docs:preview": "vitepress preview docs",
31
- "docs:deploy": "pnpm docs:build && vercel --prod"
31
+ "docs:deploy": "pnpm docs:build && vercel --prod",
32
+ "release": "npm version patch && npm publish --access public"
32
33
  },
33
34
  "files": [
34
35
  "dist",
@@ -63,4 +64,4 @@
63
64
  "camera-controls": "^3.1.2",
64
65
  "three": "^0.183.1"
65
66
  }
66
- }
67
+ }