hj-gis-sdk 1.0.0 → 1.0.2

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.
Files changed (194) hide show
  1. package/README.md +50 -59
  2. package/dev-dist/animation.esm.js +152 -0
  3. package/dev-dist/animation.esm.js.map +1 -0
  4. package/dev-dist/animation.js +154 -0
  5. package/dev-dist/animation.js.map +1 -0
  6. package/dev-dist/building.esm.js +85 -0
  7. package/dev-dist/building.esm.js.map +1 -0
  8. package/dev-dist/building.js +87 -0
  9. package/dev-dist/building.js.map +1 -0
  10. package/dev-dist/common.esm.js +16159 -0
  11. package/dev-dist/common.esm.js.map +1 -0
  12. package/dev-dist/common.js +16163 -0
  13. package/dev-dist/common.js.map +1 -0
  14. package/dev-dist/fence.esm.js +100 -0
  15. package/dev-dist/fence.esm.js.map +1 -0
  16. package/dev-dist/fence.js +102 -0
  17. package/dev-dist/fence.js.map +1 -0
  18. package/dev-dist/ghost.esm.js +53 -0
  19. package/dev-dist/ghost.esm.js.map +1 -0
  20. package/dev-dist/ghost.js +55 -0
  21. package/dev-dist/ghost.js.map +1 -0
  22. package/dev-dist/heatmap.esm.js +103 -0
  23. package/dev-dist/heatmap.esm.js.map +1 -0
  24. package/dev-dist/heatmap.js +105 -0
  25. package/dev-dist/heatmap.js.map +1 -0
  26. package/dev-dist/index.esm.js +21 -0
  27. package/dev-dist/index.esm.js.map +1 -0
  28. package/dev-dist/index.esm2.js +4272 -0
  29. package/dev-dist/index.esm2.js.map +1 -0
  30. package/dev-dist/index.js +26 -0
  31. package/dev-dist/index.js.map +1 -0
  32. package/dev-dist/index2.js +4280 -0
  33. package/dev-dist/index2.js.map +1 -0
  34. package/dev-dist/keyframe.esm.js +95 -0
  35. package/dev-dist/keyframe.esm.js.map +1 -0
  36. package/dev-dist/keyframe.js +97 -0
  37. package/dev-dist/keyframe.js.map +1 -0
  38. package/dev-dist/measurement.esm.js +57 -0
  39. package/dev-dist/measurement.esm.js.map +1 -0
  40. package/dev-dist/measurement.js +59 -0
  41. package/dev-dist/measurement.js.map +1 -0
  42. package/dev-dist/scatter.esm.js +85 -0
  43. package/dev-dist/scatter.esm.js.map +1 -0
  44. package/dev-dist/scatter.js +87 -0
  45. package/dev-dist/scatter.js.map +1 -0
  46. package/dev-dist/src.esm.js +289 -0
  47. package/dev-dist/src.esm.js.map +1 -0
  48. package/dev-dist/src.js +291 -0
  49. package/dev-dist/src.js.map +1 -0
  50. package/dev-dist/types/hj-gis-sdk/addons/animation/animate-clip.d.ts +39 -0
  51. package/dev-dist/types/hj-gis-sdk/addons/animation/animate-clip.d.ts.map +1 -0
  52. package/dev-dist/types/hj-gis-sdk/addons/animation/animation-action.d.ts +31 -0
  53. package/dev-dist/types/hj-gis-sdk/addons/animation/animation-action.d.ts.map +1 -0
  54. package/dev-dist/types/hj-gis-sdk/addons/animation/animation-mixer.d.ts +18 -0
  55. package/dev-dist/types/hj-gis-sdk/addons/animation/animation-mixer.d.ts.map +1 -0
  56. package/dev-dist/types/hj-gis-sdk/addons/animation/index.d.ts +5 -0
  57. package/dev-dist/types/hj-gis-sdk/addons/animation/index.d.ts.map +1 -0
  58. package/dev-dist/types/hj-gis-sdk/addons/camera.d.ts +59 -0
  59. package/dev-dist/types/hj-gis-sdk/addons/camera.d.ts.map +1 -0
  60. package/dev-dist/types/hj-gis-sdk/addons/clock.d.ts +40 -0
  61. package/dev-dist/types/hj-gis-sdk/addons/clock.d.ts.map +1 -0
  62. package/dev-dist/types/hj-gis-sdk/addons/commander/context.d.ts +24 -0
  63. package/dev-dist/types/hj-gis-sdk/addons/commander/context.d.ts.map +1 -0
  64. package/dev-dist/types/hj-gis-sdk/addons/commander/dispatcher.d.ts +43 -0
  65. package/dev-dist/types/hj-gis-sdk/addons/commander/dispatcher.d.ts.map +1 -0
  66. package/dev-dist/types/hj-gis-sdk/addons/commander/excutor/base.d.ts +22 -0
  67. package/dev-dist/types/hj-gis-sdk/addons/commander/excutor/base.d.ts.map +1 -0
  68. package/dev-dist/types/hj-gis-sdk/addons/loader/index.d.ts +6 -0
  69. package/dev-dist/types/hj-gis-sdk/addons/loader/index.d.ts.map +1 -0
  70. package/dev-dist/types/hj-gis-sdk/addons/loader/loader.d.ts +4 -0
  71. package/dev-dist/types/hj-gis-sdk/addons/loader/loader.d.ts.map +1 -0
  72. package/dev-dist/types/hj-gis-sdk/addons/node/base.d.ts +63 -0
  73. package/dev-dist/types/hj-gis-sdk/addons/node/base.d.ts.map +1 -0
  74. package/dev-dist/types/hj-gis-sdk/addons/node/ue-node.d.ts +82 -0
  75. package/dev-dist/types/hj-gis-sdk/addons/node/ue-node.d.ts.map +1 -0
  76. package/dev-dist/types/hj-gis-sdk/addons/proxy.d.ts +83 -0
  77. package/dev-dist/types/hj-gis-sdk/addons/proxy.d.ts.map +1 -0
  78. package/dev-dist/types/hj-gis-sdk/addons/tools/base.d.ts +7 -0
  79. package/dev-dist/types/hj-gis-sdk/addons/tools/base.d.ts.map +1 -0
  80. package/dev-dist/types/hj-gis-sdk/addons/tools/building.d.ts +36 -0
  81. package/dev-dist/types/hj-gis-sdk/addons/tools/building.d.ts.map +1 -0
  82. package/dev-dist/types/hj-gis-sdk/addons/tools/daytime.d.ts +7 -0
  83. package/dev-dist/types/hj-gis-sdk/addons/tools/daytime.d.ts.map +1 -0
  84. package/dev-dist/types/hj-gis-sdk/addons/tools/fence.d.ts +61 -0
  85. package/dev-dist/types/hj-gis-sdk/addons/tools/fence.d.ts.map +1 -0
  86. package/dev-dist/types/hj-gis-sdk/addons/tools/ghost.d.ts +14 -0
  87. package/dev-dist/types/hj-gis-sdk/addons/tools/ghost.d.ts.map +1 -0
  88. package/dev-dist/types/hj-gis-sdk/addons/tools/heat-map.d.ts +65 -0
  89. package/dev-dist/types/hj-gis-sdk/addons/tools/heat-map.d.ts.map +1 -0
  90. package/dev-dist/types/hj-gis-sdk/addons/tools/index.d.ts +26 -0
  91. package/dev-dist/types/hj-gis-sdk/addons/tools/index.d.ts.map +1 -0
  92. package/dev-dist/types/hj-gis-sdk/addons/tools/match-view.d.ts +7 -0
  93. package/dev-dist/types/hj-gis-sdk/addons/tools/match-view.d.ts.map +1 -0
  94. package/dev-dist/types/hj-gis-sdk/addons/tools/measurement.d.ts +13 -0
  95. package/dev-dist/types/hj-gis-sdk/addons/tools/measurement.d.ts.map +1 -0
  96. package/dev-dist/types/hj-gis-sdk/addons/tools/pick-cast.d.ts +26 -0
  97. package/dev-dist/types/hj-gis-sdk/addons/tools/pick-cast.d.ts.map +1 -0
  98. package/dev-dist/types/hj-gis-sdk/addons/tools/scatter.d.ts +57 -0
  99. package/dev-dist/types/hj-gis-sdk/addons/tools/scatter.d.ts.map +1 -0
  100. package/dev-dist/types/hj-gis-sdk/addons/tools/weather.d.ts +31 -0
  101. package/dev-dist/types/hj-gis-sdk/addons/tools/weather.d.ts.map +1 -0
  102. package/dev-dist/types/hj-gis-sdk/addons/transform.d.ts +91 -0
  103. package/dev-dist/types/hj-gis-sdk/addons/transform.d.ts.map +1 -0
  104. package/dev-dist/types/hj-gis-sdk/addons/world.d.ts +76 -0
  105. package/dev-dist/types/hj-gis-sdk/addons/world.d.ts.map +1 -0
  106. package/dev-dist/types/hj-gis-sdk/core/ue-rpc.d.ts +54 -0
  107. package/dev-dist/types/hj-gis-sdk/core/ue-rpc.d.ts.map +1 -0
  108. package/dev-dist/types/hj-gis-sdk/index.d.ts +27 -0
  109. package/dev-dist/types/hj-gis-sdk/index.d.ts.map +1 -0
  110. package/dev-dist/types/hj-gis-sdk/utils.d.ts +16 -0
  111. package/dev-dist/types/hj-gis-sdk/utils.d.ts.map +1 -0
  112. package/dev-dist/types/src/animation.d.ts +2 -0
  113. package/dev-dist/types/src/animation.d.ts.map +1 -0
  114. package/dev-dist/types/src/building.d.ts +2 -0
  115. package/dev-dist/types/src/building.d.ts.map +1 -0
  116. package/dev-dist/types/src/common.d.ts +5 -0
  117. package/dev-dist/types/src/common.d.ts.map +1 -0
  118. package/dev-dist/types/src/fence.d.ts +2 -0
  119. package/dev-dist/types/src/fence.d.ts.map +1 -0
  120. package/dev-dist/types/src/ghost.d.ts +2 -0
  121. package/dev-dist/types/src/ghost.d.ts.map +1 -0
  122. package/dev-dist/types/src/heatmap.d.ts +2 -0
  123. package/dev-dist/types/src/heatmap.d.ts.map +1 -0
  124. package/dev-dist/types/src/index.d.ts +2 -0
  125. package/dev-dist/types/src/index.d.ts.map +1 -0
  126. package/dev-dist/types/src/keyframe.d.ts +2 -0
  127. package/dev-dist/types/src/keyframe.d.ts.map +1 -0
  128. package/dev-dist/types/src/measurement.d.ts +2 -0
  129. package/dev-dist/types/src/measurement.d.ts.map +1 -0
  130. package/dev-dist/types/src/scatter.d.ts +2 -0
  131. package/dev-dist/types/src/scatter.d.ts.map +1 -0
  132. package/dev-dist/types/src/weather.d.ts +2 -0
  133. package/dev-dist/types/src/weather.d.ts.map +1 -0
  134. package/dev-dist/weather.esm.js +68 -0
  135. package/dev-dist/weather.esm.js.map +1 -0
  136. package/dev-dist/weather.js +70 -0
  137. package/dev-dist/weather.js.map +1 -0
  138. package/dist/sdk.esm.js +19 -6
  139. package/dist/sdk.esm.js.map +1 -1
  140. package/dist/sdk.js +19 -6
  141. package/dist/sdk.js.map +1 -1
  142. package/dist/sdk.umd.js +1 -1
  143. package/dist/sdk.umd.js.map +1 -1
  144. package/dist/types/hj-gis-sdk/addons/tools/scatter.d.ts.map +1 -1
  145. package/dist/types/src/common.d.ts.map +1 -1
  146. package/hj-gis-sdk/addons/animation/animate-clip.ts +93 -0
  147. package/hj-gis-sdk/addons/animation/animation-action.ts +93 -0
  148. package/hj-gis-sdk/addons/animation/animation-mixer.ts +51 -0
  149. package/hj-gis-sdk/addons/animation/index.ts +17 -0
  150. package/hj-gis-sdk/addons/camera.ts +173 -0
  151. package/hj-gis-sdk/addons/clock.ts +85 -0
  152. package/hj-gis-sdk/addons/commander/context.ts +70 -0
  153. package/hj-gis-sdk/addons/commander/dispatcher.ts +68 -0
  154. package/hj-gis-sdk/addons/commander/excutor/base.ts +26 -0
  155. package/hj-gis-sdk/addons/loader/index.ts +7 -0
  156. package/hj-gis-sdk/addons/loader/loader.ts +3 -0
  157. package/hj-gis-sdk/addons/node/base.ts +131 -0
  158. package/hj-gis-sdk/addons/node/ue-node.ts +147 -0
  159. package/hj-gis-sdk/addons/proxy.ts +200 -0
  160. package/hj-gis-sdk/addons/tools/base.ts +11 -0
  161. package/hj-gis-sdk/addons/tools/building.ts +84 -0
  162. package/hj-gis-sdk/addons/tools/daytime.ts +14 -0
  163. package/hj-gis-sdk/addons/tools/fence.ts +105 -0
  164. package/hj-gis-sdk/addons/tools/ghost.ts +31 -0
  165. package/hj-gis-sdk/addons/tools/heat-map.ts +95 -0
  166. package/hj-gis-sdk/addons/tools/index.ts +25 -0
  167. package/hj-gis-sdk/addons/tools/match-view.ts +35 -0
  168. package/hj-gis-sdk/addons/tools/measurement.ts +25 -0
  169. package/hj-gis-sdk/addons/tools/pick-cast.ts +67 -0
  170. package/hj-gis-sdk/addons/tools/scatter.ts +230 -0
  171. package/hj-gis-sdk/addons/tools/weather.ts +40 -0
  172. package/hj-gis-sdk/addons/transform.ts +126 -0
  173. package/hj-gis-sdk/addons/world.ts +173 -0
  174. package/hj-gis-sdk/core/ue-rpc.ts +234 -0
  175. package/hj-gis-sdk/index.ts +26 -0
  176. package/hj-gis-sdk/utils.ts +52 -0
  177. package/index.html +48 -0
  178. package/package-lock.json +7368 -0
  179. package/package.json +17 -4
  180. package/rollup.config.dev.js +107 -0
  181. package/rollup.config.js +52 -0
  182. package/src/animation.ts +175 -0
  183. package/src/building.ts +114 -0
  184. package/src/common.ts +47 -0
  185. package/src/fence.ts +131 -0
  186. package/src/ghost.ts +70 -0
  187. package/src/heatmap.ts +125 -0
  188. package/src/index.ts +350 -0
  189. package/src/keyframe.ts +113 -0
  190. package/src/measurement.ts +80 -0
  191. package/src/scatter.ts +105 -0
  192. package/src/weather.ts +86 -0
  193. package/tsconfig.json +30 -0
  194. package/yarn.lock +3108 -0
@@ -0,0 +1,3 @@
1
+ export interface Loader<T> {
2
+ loader: (opts: any) => Promise<T>
3
+ }
@@ -0,0 +1,131 @@
1
+ /**
2
+ * 节点基类模块,提供节点树的基础实现
3
+ * 用于表示场景中的对象,支持父子关系、变换和数据存储
4
+ */
5
+ import { Vector3, Euler } from '@math.gl/core'
6
+
7
+ import UERPC from '../../core/ue-rpc'
8
+ import { OTransform } from '../transform'
9
+
10
+ /**
11
+ * 节点基类,用于表示场景中的对象
12
+ * 支持父子关系、变换、数据存储和节点查找
13
+ * @template T 节点数据类型
14
+ */
15
+ export default class Node<T = any> {
16
+ /** 父节点 */
17
+ parent: Node | undefined
18
+ /** 根节点 */
19
+ root: Node | undefined
20
+ /** 节点唯一标识符 */
21
+ private _key: string | undefined
22
+ /** 节点变换信息 */
23
+ protected _transform: OTransform | undefined
24
+ /** 是否为根节点 */
25
+ isRoot: boolean
26
+ /** 节点附加数据 */
27
+ data?: T
28
+
29
+ /** 子节点列表 */
30
+ protected _children: Node[]
31
+
32
+ /**
33
+ * 构造函数
34
+ * @param key 节点唯一标识符
35
+ * @param data 节点附加数据
36
+ * @param transform 节点变换信息
37
+ */
38
+ constructor(key?: string, data?: T, transform?: OTransform) {
39
+ this._children = []
40
+ this._key = key
41
+ this.isRoot = true
42
+ this.data = data
43
+ if (transform) {
44
+ this._transform = new OTransform(
45
+ new Vector3(),
46
+ new Euler(),
47
+ new Vector3(1, 1, 1)
48
+ )
49
+ } else {
50
+ this._transform = OTransform.default()
51
+ }
52
+ }
53
+
54
+ /**
55
+ * 获取节点唯一标识符
56
+ */
57
+ get key() {
58
+ return this._key
59
+ }
60
+
61
+ /**
62
+ * 获取节点变换信息
63
+ */
64
+ get transform() {
65
+ return this._transform
66
+ }
67
+
68
+ /**
69
+ * 获取子节点列表
70
+ */
71
+ get children() {
72
+ return this._children
73
+ }
74
+
75
+ /**
76
+ * 添加子节点
77
+ * @param child 要添加的子节点
78
+ */
79
+ add(child: Node) {
80
+ // this.children.push(child)
81
+ child.parent = this
82
+ this._children.push(child)
83
+ child.isRoot = false
84
+ }
85
+
86
+ /**
87
+ * 脱离父节点
88
+ */
89
+ detach() {
90
+ if (this.parent) {
91
+ this.parent.removeChild(this)
92
+ }
93
+ this.isRoot = true
94
+ }
95
+
96
+ remove() {
97
+ if (this.parent) {
98
+ this.detach()
99
+ }
100
+ }
101
+
102
+ /**
103
+ * 移除子节点
104
+ * @param child 要移除的子节点
105
+ */
106
+ removeChild(child: Node) {
107
+ child.parent = undefined
108
+ let index = this._children.findIndex((c) => c !== child)
109
+ if (index > -1) {
110
+ this._children.splice(index, 1)
111
+ }
112
+ }
113
+
114
+ /**
115
+ * 根据key查找子节点
116
+ * @param key 要查找的节点key
117
+ * @returns 找到的节点或undefined
118
+ */
119
+ findChild(key: string): Node | undefined {
120
+ if (this.key === key) {
121
+ return this
122
+ }
123
+ for (let i = 0; i < this._children.length; i++) {
124
+ let child = this._children[i]
125
+ let found = child.findChild(key)
126
+ if (found) {
127
+ return found
128
+ }
129
+ }
130
+ }
131
+ }
@@ -0,0 +1,147 @@
1
+ /**
2
+ * UE RPC 节点模块,提供与 UE 通信的节点实现
3
+ * 用于表示与 Unreal Engine 通信的场景对象
4
+ */
5
+ import { Euler, Vector3 } from '@math.gl/core'
6
+ import UERPC from '../../core/ue-rpc'
7
+
8
+ import Node from './base'
9
+ import { Transform } from '../transform'
10
+ import World from '../world'
11
+ import { Collector, createDeepProxy } from '../proxy'
12
+
13
+ /**
14
+ * 资源类型枚举,用于标识不同类型的资源
15
+ */
16
+ export enum AssetType {
17
+ /** 其他类型资源 */
18
+ Other = 'other',
19
+ /** 地图资源 */
20
+ Map = 'map',
21
+ /** 蓝图资源 */
22
+ Blueprint = 'blueprint',
23
+ /** 静态网格资源 */
24
+ StaticMesh = 'static_mesh',
25
+ /** 骨骼网格资源 */
26
+ SkeletalMesh = 'skeletal_mesh'
27
+ }
28
+
29
+ /**
30
+ * 节点数据类型,包含资源类型信息
31
+ */
32
+ type Data = {
33
+ /** 资源类型 */
34
+ assetType: AssetType
35
+ }
36
+
37
+ /**
38
+ * UE RPC 节点类,继承自 Node,用于与 Unreal Engine 通信
39
+ * 支持变换同步、远程更新和子节点管理
40
+ */
41
+ export default class UERPCNode extends Node<Data> {
42
+ /** RPC 通信实例 */
43
+ protected _rpc: UERPC
44
+ /** 节点变换信息 */
45
+ protected _transform: Transform | undefined
46
+ /** 所属世界实例 */
47
+ world?: World
48
+ /** 变更收集器,用于跟踪变换属性的变化 */
49
+ protected _collector: Collector
50
+ /** 远程更新标志,用于防止循环更新 */
51
+ protected _remoteUpdateFlag: boolean
52
+
53
+ tag?: string
54
+
55
+ /**
56
+ * 构造函数
57
+ * @param rpc RPC 通信实例
58
+ * @param key 节点唯一标识符
59
+ * @param data 节点数据
60
+ * @param transform 节点变换信息
61
+ */
62
+ constructor(
63
+ rpc: UERPC,
64
+ key?: string,
65
+ data?: Data,
66
+ transform?: Transform,
67
+ tag?: string
68
+ ) {
69
+ super(key, data)
70
+ this._rpc = rpc
71
+ if (transform) {
72
+ this._transform = transform
73
+ } else {
74
+ this._transform = Transform.default()
75
+ }
76
+ this._remoteUpdateFlag = false
77
+ this._collector = new Collector(this._triggerRemoteUpdate.bind(this))
78
+ this.tag = tag
79
+ }
80
+
81
+ /**
82
+ * 获取变换信息的深度代理,用于跟踪属性变化
83
+ */
84
+ get transform() {
85
+ return createDeepProxy(this._transform!, {}, this._collector)
86
+ }
87
+
88
+ set transform(transform: Transform) {
89
+ this._transform = transform
90
+ this._triggerRemoteUpdate()
91
+ }
92
+
93
+ /**
94
+ * 添加子节点
95
+ * @param child 要添加的子节点
96
+ * @throws 非根节点添加子节点时抛出错误
97
+ */
98
+ add(child: UERPCNode) {
99
+ // throw new Error("UERPCNode can't add child")
100
+ if (this.isRoot) {
101
+ super.add(child)
102
+ child.world = this.world
103
+ } else {
104
+ throw new Error("UERPCNode can't add child , except root node")
105
+ }
106
+ }
107
+
108
+ __dangerousRawAdd(child: UERPCNode) {
109
+ super.add(child)
110
+ }
111
+
112
+ /**
113
+ * 脱离父节点
114
+ */
115
+ async detach() {
116
+ super.detach()
117
+ }
118
+
119
+ async remove() {
120
+ super.remove()
121
+ await this._rpc.destroyActorByHandle(this.key!)
122
+ }
123
+ /**
124
+ * 移除子节点
125
+ * @param child 要移除的子节点
126
+ */
127
+ async removeChild(child: Node) {
128
+ super.removeChild(child)
129
+ await this._rpc.destroyActorByHandle(this.key!)
130
+ }
131
+
132
+ protected _triggerRemoteUpdate() {
133
+ if (!this._remoteUpdateFlag) {
134
+ this._remoteUpdateFlag = true
135
+ Promise.resolve().then(() => this._remoteUpdate())
136
+ }
137
+ }
138
+
139
+ /**
140
+ * 远程更新节点变换到 UE
141
+ * 向 UE 发送变换数据,更新 Actor 的位置、旋转和缩放
142
+ */
143
+ protected _remoteUpdate() {
144
+ this._rpc.setActorTransformByHandle(this.key!, this.transform.toRPCJSON())
145
+ this._remoteUpdateFlag = false
146
+ }
147
+ }
@@ -0,0 +1,200 @@
1
+ /**
2
+ * 代理模块,提供深度代理和变动收集功能
3
+ * 用于跟踪对象的属性变化并在事件循环结束后统一处理
4
+ */
5
+
6
+ /**
7
+ * 变动接口,用于描述对象的属性变动
8
+ */
9
+ export interface Change {
10
+ /** 变动目标对象 */
11
+ target: object
12
+ /** 变动的属性名或符号 */
13
+ prop: string | symbol
14
+ /** 变动后的值 */
15
+ value: any
16
+ /** 变动类型 */
17
+ type: 'set' | 'delete'
18
+ }
19
+
20
+ // 定义自定义处理器接口
21
+ export interface DeepProxyHandler {
22
+ /**
23
+ * 拦截属性读取
24
+ */
25
+ get?: <T extends object>(
26
+ target: T,
27
+ prop: string | symbol,
28
+ receiver: any
29
+ ) => void
30
+ /**
31
+ * 拦截属性赋值
32
+ */
33
+ set?: <T extends object>(
34
+ target: T,
35
+ prop: string | symbol,
36
+ value: any,
37
+ receiver: any
38
+ ) => boolean
39
+ /**
40
+ * 拦截属性删除
41
+ */
42
+ deleteProperty?: <T extends object>(
43
+ target: T,
44
+ prop: string | symbol
45
+ ) => boolean
46
+ /**
47
+ * 拦截 in 操作符
48
+ */
49
+ has?: <T extends object>(target: T, prop: string | symbol) => boolean
50
+ /**
51
+ * 拦截 Object.getOwnPropertyNames 等方法
52
+ */
53
+ ownKeys?: <T extends object>(target: T) => (string | symbol)[]
54
+ }
55
+
56
+ /**
57
+ * 收集器类,用于收集对象变动并在事件循环结束后触发回调
58
+ */
59
+ export class Collector {
60
+ /**
61
+ * 收集到的变动列表
62
+ */
63
+ private changes: Change[] = []
64
+ /**
65
+ * 标志位,用于确保只有一个 setTimeout 在运行
66
+ */
67
+ private isTimeoutSet: boolean = false
68
+ /**
69
+ * 变动回调函数
70
+ */
71
+ private callback: (changes: Change[]) => void
72
+
73
+ /**
74
+ * 创建收集器实例
75
+ * @param callback 变动回调函数,在事件循环结束后调用
76
+ */
77
+ constructor(callback: (changes: Change[]) => void) {
78
+ this.callback = callback
79
+ }
80
+
81
+ /**
82
+ * 添加变动
83
+ * @param change 变动对象
84
+ */
85
+ addChange(change: Change): void {
86
+ this.changes.push(change)
87
+ this.scheduleCallback()
88
+ }
89
+
90
+ /**
91
+ * 调度回调函数,确保在事件循环结束后执行
92
+ */
93
+ private scheduleCallback(): void {
94
+ if (!this.isTimeoutSet) {
95
+ this.isTimeoutSet = true
96
+ // setTimeout(() => {
97
+ Promise.resolve().then(() => this.triggerCallback())
98
+ // }, 0);
99
+ }
100
+ }
101
+
102
+ /**
103
+ * 触发回调函数
104
+ */
105
+ private triggerCallback(): void {
106
+ if (this.changes.length > 0) {
107
+ this.callback([...this.changes]) // 传递变动的副本
108
+ this.changes = [] // 清空变动列表
109
+ }
110
+ this.isTimeoutSet = false
111
+ }
112
+ }
113
+
114
+ /**
115
+ * 创建深度代理,递归地为对象及其所有子对象创建 Proxy
116
+ * @param target 要代理的目标对象
117
+ * @param handler 自定义处理器
118
+ * @param collector 变动收集器,用于收集对象变动
119
+ * @returns 代理后的对象
120
+ */
121
+ export function createDeepProxy<T extends object>(
122
+ target: T,
123
+ handler: DeepProxyHandler = {},
124
+ collector?: Collector
125
+ ): T {
126
+ // 递归创建 Proxy 的核心函数
127
+ const proxyHandler: ProxyHandler<T> = {
128
+ // 拦截属性读取
129
+ get(target: T, prop: string | symbol, receiver: any): any {
130
+ // 先调用自定义 handler 的 get(如果有)
131
+ if (handler.get) {
132
+ handler.get(target, prop, receiver)
133
+ }
134
+
135
+ // 获取属性值
136
+ const result = Reflect.get(target, prop, receiver)
137
+
138
+ // 如果读取的属性是对象/数组且不是 null,递归创建 Proxy
139
+ if (
140
+ result !== null &&
141
+ (typeof result === 'object' || Array.isArray(result))
142
+ ) {
143
+ return createDeepProxy(result as object, handler, collector)
144
+ }
145
+ return result
146
+ },
147
+
148
+ // 拦截属性赋值
149
+ set(target: T, prop: string | symbol, value: any, receiver: any): boolean {
150
+ // 先调用自定义 handler 的 set(如果有)
151
+ if (handler.set) {
152
+ handler.set(target, prop, value, receiver)
153
+ }
154
+
155
+ // 赋值时,如果新值是对象/数组,也需要代理
156
+ const newValue =
157
+ value !== null && (typeof value === 'object' || Array.isArray(value))
158
+ ? createDeepProxy(value as object, handler, collector)
159
+ : value
160
+
161
+ // 如果有收集器,收集变动
162
+ if (collector) {
163
+ collector.addChange({
164
+ target,
165
+ prop,
166
+ value: newValue,
167
+ type: 'set'
168
+ })
169
+ }
170
+
171
+ return Reflect.set(target, prop, newValue, receiver)
172
+ },
173
+
174
+ // 拦截属性删除
175
+ deleteProperty(target: T, prop: string | symbol): boolean {
176
+ // 先调用自定义 handler 的 deleteProperty(如果有)
177
+ if (handler.deleteProperty) {
178
+ handler.deleteProperty(target, prop)
179
+ }
180
+
181
+ // 如果有收集器,收集变动
182
+ if (collector) {
183
+ collector.addChange({
184
+ target,
185
+ prop,
186
+ value: undefined,
187
+ type: 'delete'
188
+ })
189
+ }
190
+
191
+ return Reflect.deleteProperty(target, prop)
192
+ },
193
+
194
+ // 可选:拦截其他操作(如 has 等)
195
+ ...handler // 合并自定义 handler 的其他拦截器
196
+ }
197
+
198
+ // 为目标对象创建 Proxy
199
+ return new Proxy<T>(target, proxyHandler)
200
+ }
@@ -0,0 +1,11 @@
1
+ import UERPC from 'hj-gis-sdk/core/ue-rpc'
2
+
3
+ export default class Tool {
4
+ protected _rpc: UERPC
5
+ constructor(rpc: UERPC) {
6
+ this._rpc = rpc
7
+ }
8
+ excute(params?: any) {
9
+ throw new Error('Method not implemented.')
10
+ }
11
+ }
@@ -0,0 +1,84 @@
1
+ import Tool from './base'
2
+ import UERPC from '../../core/ue-rpc'
3
+ import { RPCTransform } from '../transform'
4
+
5
+ export default class Building extends Tool {
6
+ constructor(rpc: UERPC) {
7
+ super(rpc)
8
+ }
9
+ async expand(id: string, params: ExpandParams) {
10
+ await this._rpc.callModule('Building', 'Expand', {
11
+ BuildingId: id,
12
+ Spacing: params.spacing,
13
+ Duration: params.duration || 2000
14
+ })
15
+ let handler = new BuildingHandler(id, this._rpc)
16
+ return handler
17
+ }
18
+ }
19
+
20
+ type ExpandParams = {
21
+ spacing: number // 展开间距(UU),控制各部分分离的距离
22
+ duration: number // 动画时长(秒)
23
+ }
24
+
25
+ type ExpandFloorParams = {
26
+ floorIndex: number //楼层索引(从0起),未提供则由 UE 侧默认规则确定
27
+ direction?: RPCTransform['Location'] //展开方向向量(世界坐标系)
28
+ distance: number
29
+ expandHeight?: number //单层向外的高度/间距
30
+ duration: number //单层向外的高度/间距
31
+ }
32
+
33
+ enum Status {
34
+ Expanded = 'Expanded',
35
+ ExpandFloor = 'ExpandFloor',
36
+ Collapsed = 'Collapsed'
37
+ }
38
+
39
+ export class BuildingHandler {
40
+ private _id: string
41
+ private _rpc: UERPC
42
+ private _status: Status
43
+ constructor(id: string, rpc: UERPC, status?: Status) {
44
+ this._id = id
45
+ this._rpc = rpc
46
+ this._status = status || Status.Collapsed
47
+ }
48
+ get status() {
49
+ return this._status
50
+ }
51
+ get id() {
52
+ return this._id
53
+ }
54
+ async expand(params: ExpandParams) {
55
+ await this._rpc.callModule('Building', 'ExpandFloor', {
56
+ BuildingId: this._id,
57
+ Spacing: params.spacing,
58
+ Duration: params.duration || 2
59
+ })
60
+ }
61
+
62
+ async expandFloor(params: ExpandFloorParams) {
63
+ let _params: any = {
64
+ BuildingId: this._id,
65
+ Distance: params.distance,
66
+ ExpandHeight: params.expandHeight,
67
+ Duration: params.duration || 2
68
+ }
69
+ if (params.direction) {
70
+ _params.Direction = {
71
+ X: params.direction.X,
72
+ Y: params.direction.Y,
73
+ Z: params.direction.Z
74
+ }
75
+ }
76
+ return this._rpc.callModule('Building', 'ExpandFloor', _params)
77
+ }
78
+ async collapse(duration: number = 2) {
79
+ return this._rpc.callModule('Building', 'Collapse', {
80
+ BuildingId: this._id,
81
+ duration: duration || 2
82
+ })
83
+ }
84
+ }
@@ -0,0 +1,14 @@
1
+ import UERPC from 'hj-gis-sdk/core/ue-rpc'
2
+ import Tool from './base'
3
+
4
+ export default class Daytime extends Tool {
5
+ constructor(rpc: UERPC) {
6
+ super(rpc)
7
+ }
8
+
9
+ setDaytime(hh: string, mm: string) {
10
+ return this._rpc.callModule('Environment', 'SetDaytime', {
11
+ value: `${hh}${mm}`
12
+ })
13
+ }
14
+ }
@@ -0,0 +1,105 @@
1
+ import Tool from './base'
2
+ import UERPC from '../../core/ue-rpc'
3
+ import { RPCTransform } from '../transform'
4
+
5
+ /**
6
+ * 坐标向量接口
7
+ */
8
+ interface Vector3 {
9
+ X: number
10
+ Y: number
11
+ Z: number
12
+ }
13
+
14
+ /**
15
+ * 颜色接口
16
+ */
17
+ interface Color {
18
+ R: number
19
+ G: number
20
+ B: number
21
+ A: number
22
+ }
23
+
24
+ /**
25
+ * 材质枚举类型
26
+ */
27
+ type MaterialEnum = 'Material_A' | 'Material_B' | 'Material_C'
28
+
29
+ /**
30
+ * 围栏创建参数
31
+ */
32
+ interface FenceCreateParams {
33
+ /** 世界坐标顶点数组(至少3点,按围栏边顺序排列) */
34
+ vectorArray: Vector3[]
35
+ /** 围栏高度(UU),未提供默认 5.0 */
36
+ height?: number
37
+ /** 材质枚举(示例 A/B/C),不同值对应不同材质路径 */
38
+ materialEnum?: MaterialEnum
39
+ /** 围栏颜色(R/G/B/A),范围 0–255;内部按 0–1 归一化后应用 */
40
+ color?: Color
41
+ }
42
+
43
+ /**
44
+ * 围栏参数类型
45
+ */
46
+ type FenceParams = FenceCreateParams | {}
47
+
48
+ /**
49
+ * 围栏工具类,用于创建和删除电子围栏
50
+ */
51
+ export default class Fence extends Tool {
52
+ constructor(rpc: UERPC) {
53
+ super(rpc)
54
+ }
55
+
56
+ async create(params: FenceCreateParams): Promise<FenceHandler> {
57
+ let response = this._rpc.callModule('Box', 'Create', {
58
+ VectorArray: params.vectorArray,
59
+ Height: params.height,
60
+ MaterialEnum: params.materialEnum,
61
+ Color: params.color
62
+ })
63
+ const { FenceID } = await response
64
+ let handler = new FenceHandler(this._rpc, FenceID, FenceStatus.Created)
65
+ return handler
66
+ }
67
+ }
68
+
69
+ enum FenceStatus {
70
+ UnCreated = 'UnCreated',
71
+ /** 围栏已创建 */
72
+ Created = 'Created',
73
+ /** 围栏已删除 */
74
+ Removed = 'Removed'
75
+ }
76
+
77
+ type CreateParams = {
78
+ vectorArray: RPCTransform['Location'][] //世界坐标顶点数组(至少3点,按围栏边顺序排列)。
79
+ height?: number //围栏高度(UU),未提供默认 5.0。
80
+ materialEnum: MaterialEnum // 材质枚举(示例 A/B/C),不同值对应不同材质路径
81
+ }
82
+
83
+ class FenceHandler {
84
+ private _id: string | undefined
85
+ private _rpc: UERPC
86
+ private _status: FenceStatus | undefined
87
+ get id() {
88
+ return this._id
89
+ }
90
+ constructor(rpc: UERPC, id?: string, status?: FenceStatus) {
91
+ this._id = id
92
+ this._rpc = rpc
93
+ this._status = status || FenceStatus.UnCreated
94
+ }
95
+
96
+ get status() {
97
+ return this._status
98
+ }
99
+
100
+ async remove() {
101
+ return this._rpc.callModule('Box', 'Delete', {
102
+ FenceID: this.id
103
+ })
104
+ }
105
+ }