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,31 @@
1
+ import Tool from './base'
2
+ import UERPC from './../../core/ue-rpc'
3
+ import UERPCNode from '../node/ue-node'
4
+ // 虚化
5
+ export default class Ghost extends Tool {
6
+ constructor(rpc: UERPC) {
7
+ super(rpc)
8
+ }
9
+ async ghost(node: UERPCNode) {
10
+ await this._rpc.callModule('Visual', 'Ghost', {
11
+ Ghost: true,
12
+ handle: node.key
13
+ })
14
+ return new GhostHandle(node, this._rpc)
15
+ }
16
+ }
17
+
18
+ export class GhostHandle {
19
+ private _node: UERPCNode
20
+ private _rpc: UERPC
21
+ constructor(node: UERPCNode, rpc: UERPC) {
22
+ this._node = node
23
+ this._rpc = rpc
24
+ }
25
+ async restore() {
26
+ await this._rpc.callModule('Visual', 'Ghost', {
27
+ handle: this._node.key,
28
+ Ghost: false
29
+ })
30
+ }
31
+ }
@@ -0,0 +1,95 @@
1
+ import Tool from './base'
2
+ import UERPC from '../../core/ue-rpc'
3
+ import { Vector3 } from '@math.gl/core'
4
+ import World from '../world'
5
+ import UERPCNode, { AssetType } from '../node/ue-node'
6
+ import { RPCTransform, Transform } from '../transform'
7
+
8
+ /**
9
+ * 热力图点数据类型
10
+ */
11
+ type HeatMapPoint = {
12
+ /** 点的 X 坐标 */
13
+ x: number
14
+ /** 点的 Y 坐标 */
15
+ y: number
16
+ /** 点的权重值 */
17
+ count: number
18
+ }
19
+
20
+ type HeatMapParams = {
21
+ /** 灰度图地址(提供则按图生成,不提供则按点集生成) */
22
+ url?: string
23
+ transform: Transform
24
+ /** 标记字符串(用于后续定位或分组) */
25
+ tag?: string
26
+ /** 每格网格尺寸({ X, Y },或分别提供 MeshSizeX/MeshSizeY) */
27
+ meshSize?: { X: number; Y: number } | { MeshSizeX: number; MeshSizeY: number }
28
+ /** 网格分段数({ X, Y },或分别提供 MeshSegX/MeshSegY) */
29
+ meshSegment?:
30
+ | { X: number; Y: number }
31
+ | { MeshSegX: number; MeshSegY: number }
32
+ /** 整体抬升高度(UU) */
33
+ heatmapAltitude?: number
34
+ /** 热值插值缩放(影响平滑度) */
35
+ lerpScale?: number
36
+ /** 高度映射比例(影响高度表现) */
37
+ heightScale?: number
38
+ /** 不透明度(0–1) */
39
+ opacity?: number
40
+ /** 零值处的不透明度(0–1) */
41
+ zeroValueOpacity?: number
42
+ /** 影响半径/范围(整数) */
43
+ influenceSize?: number
44
+ /** 自发光强度(影响亮度/可视效果) */
45
+ emissiveStrength?: number
46
+ /** 点集模式下的点数组(每项 { x, y, count }) */
47
+ heatMapPoints?: HeatMapPoint[]
48
+ }
49
+
50
+ /**
51
+ * 热力图工具类,用于创建热力图
52
+ */
53
+ export default class HeatMap extends Tool {
54
+ private _world: World
55
+ constructor(rpc: UERPC, world: World) {
56
+ super(rpc)
57
+ this._world = world
58
+ }
59
+ async create(params: HeatMapParams) {
60
+ let _transform = params.transform || Transform.default()
61
+ let response = await this._rpc.callModule('HeatMap', 'Create', {
62
+ url: params.url,
63
+ X: _transform.position.x,
64
+ Y: _transform.position.y,
65
+ Z: _transform.position.z,
66
+ ScaleX: _transform.scale.x,
67
+ ScaleY: _transform.scale.y,
68
+ ScaleZ: _transform.scale.z,
69
+ Pitch: _transform.rotation.pitch,
70
+ Yaw: _transform.rotation.yaw,
71
+ Roll: _transform.rotation.roll,
72
+ Tag: params.tag,
73
+ MeshSize: params.meshSize,
74
+ MeshSegment: params.meshSegment,
75
+ LerpScale: params.lerpScale,
76
+ Opacity: params.opacity,
77
+ HeightScale: params.heightScale,
78
+ ZeroValueOpacity: params.zeroValueOpacity,
79
+ InfluenceSize: params.influenceSize,
80
+ EmissiveStrength: params.emissiveStrength,
81
+ HeatMapPoints: params.heatMapPoints
82
+ })
83
+ let _node = new UERPCNode(
84
+ this._rpc,
85
+ response.Handle,
86
+ {
87
+ assetType: AssetType.Other
88
+ },
89
+ _transform,
90
+ params.tag
91
+ )
92
+ this._world.root.__dangerousRawAdd(_node)
93
+ return _node
94
+ }
95
+ }
@@ -0,0 +1,25 @@
1
+ import Tool from './base'
2
+ import MatchViewTool from './match-view'
3
+ import WeatherTool from './weather'
4
+ import PickCastTool from './pick-cast'
5
+ import HeatMapTool from './heat-map'
6
+ import ScatterTool from './scatter'
7
+ import FenceTool from './fence'
8
+ import BuildingTool from './building'
9
+ import MeasurementTool from './measurement'
10
+ import DaytimeTool from './daytime'
11
+ import GhostTool from './ghost'
12
+
13
+ export default {
14
+ Tool,
15
+ MatchViewTool,
16
+ WeatherTool,
17
+ PickCastTool,
18
+ HeatMapTool,
19
+ ScatterTool,
20
+ FenceTool,
21
+ BuildingTool,
22
+ MeasurementTool,
23
+ DaytimeTool,
24
+ GhostTool
25
+ }
@@ -0,0 +1,35 @@
1
+ import { PixelStreaming } from '@epicgames-ps/lib-pixelstreamingfrontend-ue5.5'
2
+ import UERPC from './../../core/ue-rpc'
3
+ import Tool from './base'
4
+
5
+ const maxView4K = (width: number, height: number) => {
6
+ const maxWidth = 3840
7
+ const maxHeight = 2160
8
+
9
+ // 如果宽或高任一超过4K限制
10
+ if (width > maxWidth || height > maxHeight) {
11
+ const ratio = Math.min(maxWidth / width, maxHeight / height)
12
+ return {
13
+ width: Math.ceil(width * ratio),
14
+ height: Math.ceil(height * ratio)
15
+ }
16
+ }
17
+
18
+ // 未超过限制,返回原尺寸
19
+ return { width, height }
20
+ }
21
+
22
+ export default class MatchView extends Tool {
23
+ constructor(rpc: UERPC) {
24
+ super(rpc)
25
+ }
26
+ excute() {
27
+ this._rpc.emitCommand({
28
+ Command: 'MatchView',
29
+ 'Resolution.Width': maxView4K(window.innerWidth, window.innerHeight)
30
+ .width,
31
+ 'Resolution.Height': maxView4K(window.innerWidth, window.innerHeight)
32
+ .height
33
+ })
34
+ }
35
+ }
@@ -0,0 +1,25 @@
1
+ import Tool from './base'
2
+ import UERPC from './../../core/ue-rpc'
3
+
4
+ export enum MeasurementType {
5
+ Path = 'Path',
6
+ Height = 'Height',
7
+ Area = 'Area'
8
+ }
9
+
10
+ export default class Measurement extends Tool {
11
+ constructor(rpc: UERPC) {
12
+ super(rpc)
13
+ }
14
+
15
+ draw(type: MeasurementType | string) {
16
+ return this._rpc.callModule('Measurement', 'SetDrawType', {
17
+ Type: type
18
+ })
19
+ }
20
+ clean() {
21
+ return this._rpc.callModule('Measurement', 'SetDrawType', {
22
+ Type: 'Null'
23
+ })
24
+ }
25
+ }
@@ -0,0 +1,67 @@
1
+ import Tool from './base'
2
+ import UERPC from '../../core/ue-rpc'
3
+ import { throttle } from './../../utils'
4
+
5
+ type PickCastResponse = {
6
+ Geo: {
7
+ Height: number
8
+ Latitude: number
9
+ Longitude: number
10
+ }
11
+ HitActor: string
12
+ Screen: {
13
+ X: number
14
+ Y: number
15
+ }
16
+ World: {
17
+ X: number
18
+ Y: number
19
+ Z: number
20
+ }
21
+ }
22
+
23
+ export default class PickCast extends Tool {
24
+ constructor(rpc: UERPC) {
25
+ super(rpc)
26
+ }
27
+
28
+ hover(
29
+ callback: (data: PickCastResponse) => void,
30
+ maxDistance = 1_000_000,
31
+ highlight = false
32
+ ) {
33
+ let stream = this._rpc.getStream()
34
+ let videoElementParent = stream.videoElementParent
35
+ const onMousemove = throttle(async (event: MouseEvent) => {
36
+ // console.log(event)
37
+ const offsetX = event.offsetX
38
+ const offsetY = event.offsetY
39
+ let response = await this._rpc.pickPointByScreen(
40
+ offsetX,
41
+ offsetY,
42
+ maxDistance,
43
+ highlight
44
+ )
45
+ callback && callback(response)
46
+ }, 50)
47
+ videoElementParent.addEventListener('mousemove', onMousemove)
48
+ return function finish() {
49
+ videoElementParent.removeEventListener('mousemove', onMousemove)
50
+ }
51
+ }
52
+ pick(callback: (data: PickCastResponse) => void , maxDistance= 1_000_000 , highlight = true) {
53
+ let videoElementParent = this._rpc.getStream().videoElementParent
54
+ let rpc = this._rpc
55
+ async function onPick(event: MouseEvent) {
56
+ const offsetX = event.offsetX
57
+ const offsetY = event.offsetY
58
+ let response = await rpc.pickPointByScreen(offsetX, offsetY, maxDistance , highlight)
59
+ callback && callback(response)
60
+ }
61
+
62
+ videoElementParent.addEventListener('click', onPick)
63
+ return function finish() {
64
+ videoElementParent.removeEventListener('click', onPick)
65
+ }
66
+ }
67
+ }
@@ -0,0 +1,230 @@
1
+ import Tool from './base'
2
+ import UERPC from './../../core/ue-rpc'
3
+ import { RPCTransform, Transform } from '../transform'
4
+ import { Collector, createDeepProxy } from '../proxy'
5
+
6
+ interface PointParam {
7
+ id?: string
8
+ location: RPCTransform['Location']
9
+ rotation?: RPCTransform['Rotation']
10
+ scale?: RPCTransform['Scale']
11
+ tag?: string
12
+ textContent?: string
13
+ }
14
+
15
+ type ScatterParams = {
16
+ pointParams: PointParam[]
17
+ widgetSpace?: 'Screen' | 'World'
18
+ }
19
+
20
+ export default class Scatter extends Tool {
21
+ constructor(rpc: UERPC) {
22
+ super(rpc)
23
+ }
24
+
25
+ async create(params: ScatterParams): Promise<ScatterGroupHandler> {
26
+ let response = await this._rpc.callModule('Point', 'Create', {
27
+ WidgetSpace: params.widgetSpace,
28
+ PointParams: params.pointParams.map((item) => {
29
+ return {
30
+ Id: item.id,
31
+ Location: item.location,
32
+ Rotation: item.rotation,
33
+ Scale: item.scale,
34
+ Tag: item.tag,
35
+ TextContent: item.textContent
36
+ }
37
+ })
38
+ })
39
+ let _params = [] as PointParam[]
40
+ for (let i = 0; i < response.CreatedIDs.length; i++) {
41
+ let id = response.CreatedIDs[i]
42
+ let param = params.pointParams[i]
43
+ _params.push({
44
+ ...param,
45
+ id
46
+ })
47
+ }
48
+
49
+ return createScatterGroupHandler(this._rpc, _params)
50
+ }
51
+ }
52
+
53
+ class ScatterGroupHandler {
54
+ private _rpc: UERPC
55
+ children: PointHandler[] = []
56
+ get pointsMap() {
57
+ return this.children.reduce((acc, cur) => {
58
+ acc[cur.id] = cur
59
+ return acc
60
+ }, {} as any)
61
+ }
62
+ get tagMap() {
63
+ return this.children.reduce((acc, cur) => {
64
+ if (!acc[cur.tag]) {
65
+ acc[cur.tag] = []
66
+ }
67
+ acc[cur.tag].push(cur)
68
+ return acc
69
+ }, {} as any)
70
+ }
71
+ constructor(rpc: UERPC) {
72
+ this._rpc = rpc
73
+ }
74
+
75
+ getById(id: string): PointHandler {
76
+ return this.pointsMap[id]
77
+ }
78
+
79
+ async removeById(id: string) {
80
+ let handle = this.getById(id)
81
+ if (handle) {
82
+ this.children = this.children.filter((child) => child.id !== id)
83
+ handle.group = undefined
84
+ await handle.remove()
85
+ }
86
+ }
87
+
88
+ async removeAll() {
89
+ let childrenIds = this.children.map((child) => child.id)
90
+ this.children = []
91
+ await this._rpc.callModule('Point', 'DeleteByIds', {
92
+ PointParams: childrenIds.map((item) => {
93
+ return {
94
+ Id: item
95
+ }
96
+ })
97
+ })
98
+ }
99
+ async removeByTag(tag: string) {
100
+ let childrenIds: string[] = this.tagMap[tag].map(
101
+ (child: PointHandler) => child.id
102
+ )
103
+ this.children = this.children.filter((child) => child.tag !== tag)
104
+ await this._rpc.callModule('Point', 'DeleteByIds', {
105
+ PointParams: childrenIds.map((item) => {
106
+ return {
107
+ Id: item
108
+ }
109
+ })
110
+ })
111
+ }
112
+ }
113
+
114
+ class PointHandler {
115
+ private _id: string
116
+ private _transform: Transform
117
+ private _textContent?: string
118
+ private _collector: Collector
119
+ private _tag: string
120
+ private _remoteUpdateFlag: boolean
121
+ private _rpc: UERPC
122
+ group?: ScatterGroupHandler
123
+ constructor(
124
+ id: string,
125
+ params: {
126
+ rpc: UERPC
127
+ transform?: Transform
128
+ textContent?: string
129
+ tag?: string
130
+ group?: ScatterGroupHandler
131
+ }
132
+ ) {
133
+ this._id = id
134
+ this._rpc = params.rpc
135
+ this._transform = params.transform || Transform.default()
136
+ this._textContent = params.textContent
137
+ this._tag = params.tag || ''
138
+ this._remoteUpdateFlag = false
139
+ this._collector = new Collector(this._triggerRemoteUpdate.bind(this))
140
+ this.group = params.group
141
+ }
142
+ get tag() {
143
+ return this._tag
144
+ }
145
+ get id() {
146
+ return this._id
147
+ }
148
+
149
+ get transform() {
150
+ return createDeepProxy(this._transform, {}, this._collector)
151
+ }
152
+
153
+ get textContent(): string | undefined {
154
+ return this._textContent
155
+ }
156
+
157
+ set textContent(value: string) {
158
+ this._textContent = value
159
+ this._triggerRemoteUpdate()
160
+ }
161
+
162
+ private _triggerRemoteUpdate() {
163
+ if (!this._remoteUpdateFlag) {
164
+ this._remoteUpdateFlag = true
165
+ this.remoteUpdate()
166
+ }
167
+ }
168
+
169
+ private remoteUpdate() {
170
+ let transformObj = this.transform.toRPCJSON()
171
+ this._rpc.callModule('Point', 'Update', {
172
+ PointParams: [
173
+ {
174
+ Id: this.id,
175
+ textContent: this.textContent,
176
+ Location: transformObj.Location,
177
+ Rotation: transformObj.Rotation,
178
+ Scale: transformObj.Scale
179
+ }
180
+ ]
181
+ })
182
+
183
+ this._remoteUpdateFlag = false
184
+ }
185
+
186
+ async remove() {
187
+ if (this.group) {
188
+ // this.group = undefined
189
+ return this.group.removeById(this.id)
190
+ }
191
+ await this._rpc.callModule('Point', 'DeleteByIds', {
192
+ IDs: [this.id]
193
+ })
194
+ }
195
+ }
196
+
197
+ function createScatterGroupHandler(
198
+ rpc: UERPC,
199
+ params: PointParam[]
200
+ ): ScatterGroupHandler {
201
+ let scatterhandler = new ScatterGroupHandler(rpc)
202
+ let phandler = params.map((param) =>
203
+ createPointHandler(
204
+ rpc,
205
+ {
206
+ ...param
207
+ },
208
+ scatterhandler
209
+ )
210
+ )
211
+
212
+ scatterhandler.children = phandler
213
+ return scatterhandler
214
+ }
215
+
216
+ function createPointHandler(
217
+ rpc: UERPC,
218
+ param: PointParam,
219
+ group?: ScatterGroupHandler
220
+ ): PointHandler {
221
+ // return new PointHandlerQuery()
222
+ let handler = new PointHandler(param.id!, {
223
+ rpc,
224
+ transform: Transform.fromRPCObject({}),
225
+ textContent: param.textContent,
226
+ tag: param.tag,
227
+ group: group
228
+ })
229
+ return handler
230
+ }
@@ -0,0 +1,40 @@
1
+ import UERPC from './../../core/ue-rpc'
2
+
3
+ /**
4
+ * 天气类型枚举,定义了不同的天气状态
5
+ */
6
+ export enum WeatherType {
7
+ /** 晴天 */
8
+ SUNNY = 'Sunny',
9
+ /** 雾天 */
10
+ Foggy = 'Foggy',
11
+ /** 雨天 */
12
+ RAIN = 'Rain',
13
+ /** 雪天 */
14
+ SNOW = 'Snow'
15
+ }
16
+
17
+ /**
18
+ * 天气类,用于管理和控制场景中的天气
19
+ */
20
+ class Weather {
21
+ private _rpc: UERPC
22
+
23
+ /**
24
+ * 构造函数
25
+ */
26
+ constructor(rpc: UERPC) {
27
+ this._rpc = rpc
28
+ }
29
+
30
+ /**
31
+ * 设置天气类型
32
+ * @param type 天气类型
33
+ */
34
+ async setWeather(type: WeatherType | string) {
35
+ return this._rpc.callModule('Enviorment', 'SetWeather', {
36
+ Preset: type
37
+ })
38
+ }
39
+ }
40
+ export default Weather
@@ -0,0 +1,126 @@
1
+ /**
2
+ * 变换模块,提供变换相关的类和功能
3
+ * 用于表示对象的位置、旋转和缩放信息
4
+ */
5
+ import { Euler, Vector3 } from '@math.gl/core'
6
+
7
+ export type RPCTransform = {
8
+ Location?: {
9
+ X: number
10
+ Y: number
11
+ Z: number
12
+ }
13
+ Rotation?: {
14
+ Pitch: number
15
+ Yaw: number
16
+ Roll: number
17
+ }
18
+ Scale?: {
19
+ X: number
20
+ Y: number
21
+ Z: number
22
+ }
23
+ }
24
+
25
+ /**
26
+ * 变换基类,用于表示对象的位置、旋转和缩放
27
+ */
28
+ export class OTransform {
29
+ /** 位置向量 */
30
+ position: Vector3
31
+ /** 旋转欧拉角 */
32
+ rotation: Euler
33
+ /** 缩放向量 */
34
+ scale: Vector3
35
+
36
+ /**
37
+ * 构造函数
38
+ * @param position 位置向量
39
+ * @param rotation 旋转欧拉角
40
+ * @param scale 缩放向量
41
+ */
42
+ constructor(position: Vector3, rotation: Euler, scale: Vector3) {
43
+ this.position = position
44
+ this.rotation = rotation
45
+ this.scale = scale
46
+ }
47
+
48
+ /**
49
+ * 创建默认的变换对象
50
+ * @param params 可选参数对象
51
+ * @param params.position 位置向量,默认值为新的Vector3实例
52
+ * @param params.rotation 旋转欧拉角,默认值为新的Euler实例
53
+ * @param params.scale 缩放向量,默认值为Vector3(1, 1, 1)
54
+ * @returns 默认的变换对象
55
+ */
56
+ static default(params?: {
57
+ position?: Vector3
58
+ rotation?: Euler
59
+ scale?: Vector3
60
+ }): OTransform {
61
+ return new OTransform(
62
+ params?.position || new Vector3(),
63
+ params?.rotation || new Euler(),
64
+ params?.scale || new Vector3(1, 1, 1)
65
+ )
66
+ }
67
+ }
68
+
69
+ /**
70
+ * 变换类,继承自OTransform,用于表示带有标识符的变换对象
71
+ */
72
+ export class Transform extends OTransform {
73
+ /**
74
+ * 构造函数
75
+
76
+ * @param position 位置向量
77
+ * @param rotation 旋转欧拉角
78
+ * @param scale 缩放向量
79
+ */
80
+ constructor(position: Vector3, rotation: Euler, scale: Vector3) {
81
+ super(position, rotation, scale)
82
+ }
83
+
84
+ toRPCJSON() {
85
+ return {
86
+ Location: {
87
+ X: this.position.x,
88
+ Y: this.position.y,
89
+ Z: this.position.z
90
+ },
91
+ Rotation: {
92
+ Pitch: this.rotation.pitch,
93
+ Yaw: this.rotation.yaw,
94
+ Roll: this.rotation.roll
95
+ },
96
+ Scale: {
97
+ X: this.scale.x,
98
+ Y: this.scale.y,
99
+ Z: this.scale.z
100
+ }
101
+ }
102
+ }
103
+
104
+ /**
105
+ * 创建默认的变换对象
106
+ * @param handle 变换对象的唯一标识符
107
+ * @returns 默认的变换对象
108
+ */
109
+ static default(): Transform {
110
+ return new Transform(new Vector3(), new Euler(), new Vector3(1, 1, 1))
111
+ }
112
+
113
+ static fromRPCObject(obj: RPCTransform) {
114
+ return new Transform(
115
+ obj.Location
116
+ ? new Vector3(obj.Location.X, obj.Location.Y, obj.Location.Z)
117
+ : new Vector3(),
118
+ obj.Rotation
119
+ ? new Euler(obj.Rotation.Pitch, obj.Rotation.Yaw, obj.Rotation.Roll)
120
+ : new Euler(),
121
+ obj.Scale
122
+ ? new Vector3(obj.Scale.X, obj.Scale.Y, obj.Scale.Z)
123
+ : new Vector3(1, 1, 1)
124
+ )
125
+ }
126
+ }