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.
- package/README.md +50 -59
- package/dev-dist/animation.esm.js +152 -0
- package/dev-dist/animation.esm.js.map +1 -0
- package/dev-dist/animation.js +154 -0
- package/dev-dist/animation.js.map +1 -0
- package/dev-dist/building.esm.js +85 -0
- package/dev-dist/building.esm.js.map +1 -0
- package/dev-dist/building.js +87 -0
- package/dev-dist/building.js.map +1 -0
- package/dev-dist/common.esm.js +16159 -0
- package/dev-dist/common.esm.js.map +1 -0
- package/dev-dist/common.js +16163 -0
- package/dev-dist/common.js.map +1 -0
- package/dev-dist/fence.esm.js +100 -0
- package/dev-dist/fence.esm.js.map +1 -0
- package/dev-dist/fence.js +102 -0
- package/dev-dist/fence.js.map +1 -0
- package/dev-dist/ghost.esm.js +53 -0
- package/dev-dist/ghost.esm.js.map +1 -0
- package/dev-dist/ghost.js +55 -0
- package/dev-dist/ghost.js.map +1 -0
- package/dev-dist/heatmap.esm.js +103 -0
- package/dev-dist/heatmap.esm.js.map +1 -0
- package/dev-dist/heatmap.js +105 -0
- package/dev-dist/heatmap.js.map +1 -0
- package/dev-dist/index.esm.js +21 -0
- package/dev-dist/index.esm.js.map +1 -0
- package/dev-dist/index.esm2.js +4272 -0
- package/dev-dist/index.esm2.js.map +1 -0
- package/dev-dist/index.js +26 -0
- package/dev-dist/index.js.map +1 -0
- package/dev-dist/index2.js +4280 -0
- package/dev-dist/index2.js.map +1 -0
- package/dev-dist/keyframe.esm.js +95 -0
- package/dev-dist/keyframe.esm.js.map +1 -0
- package/dev-dist/keyframe.js +97 -0
- package/dev-dist/keyframe.js.map +1 -0
- package/dev-dist/measurement.esm.js +57 -0
- package/dev-dist/measurement.esm.js.map +1 -0
- package/dev-dist/measurement.js +59 -0
- package/dev-dist/measurement.js.map +1 -0
- package/dev-dist/scatter.esm.js +85 -0
- package/dev-dist/scatter.esm.js.map +1 -0
- package/dev-dist/scatter.js +87 -0
- package/dev-dist/scatter.js.map +1 -0
- package/dev-dist/src.esm.js +289 -0
- package/dev-dist/src.esm.js.map +1 -0
- package/dev-dist/src.js +291 -0
- package/dev-dist/src.js.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/animation/animate-clip.d.ts +39 -0
- package/dev-dist/types/hj-gis-sdk/addons/animation/animate-clip.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/animation/animation-action.d.ts +31 -0
- package/dev-dist/types/hj-gis-sdk/addons/animation/animation-action.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/animation/animation-mixer.d.ts +18 -0
- package/dev-dist/types/hj-gis-sdk/addons/animation/animation-mixer.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/animation/index.d.ts +5 -0
- package/dev-dist/types/hj-gis-sdk/addons/animation/index.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/camera.d.ts +59 -0
- package/dev-dist/types/hj-gis-sdk/addons/camera.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/clock.d.ts +40 -0
- package/dev-dist/types/hj-gis-sdk/addons/clock.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/commander/context.d.ts +24 -0
- package/dev-dist/types/hj-gis-sdk/addons/commander/context.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/commander/dispatcher.d.ts +43 -0
- package/dev-dist/types/hj-gis-sdk/addons/commander/dispatcher.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/commander/excutor/base.d.ts +22 -0
- package/dev-dist/types/hj-gis-sdk/addons/commander/excutor/base.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/loader/index.d.ts +6 -0
- package/dev-dist/types/hj-gis-sdk/addons/loader/index.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/loader/loader.d.ts +4 -0
- package/dev-dist/types/hj-gis-sdk/addons/loader/loader.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/node/base.d.ts +63 -0
- package/dev-dist/types/hj-gis-sdk/addons/node/base.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/node/ue-node.d.ts +82 -0
- package/dev-dist/types/hj-gis-sdk/addons/node/ue-node.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/proxy.d.ts +83 -0
- package/dev-dist/types/hj-gis-sdk/addons/proxy.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/base.d.ts +7 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/base.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/building.d.ts +36 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/building.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/daytime.d.ts +7 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/daytime.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/fence.d.ts +61 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/fence.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/ghost.d.ts +14 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/ghost.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/heat-map.d.ts +65 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/heat-map.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/index.d.ts +26 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/index.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/match-view.d.ts +7 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/match-view.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/measurement.d.ts +13 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/measurement.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/pick-cast.d.ts +26 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/pick-cast.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/scatter.d.ts +57 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/scatter.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/weather.d.ts +31 -0
- package/dev-dist/types/hj-gis-sdk/addons/tools/weather.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/transform.d.ts +91 -0
- package/dev-dist/types/hj-gis-sdk/addons/transform.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/addons/world.d.ts +76 -0
- package/dev-dist/types/hj-gis-sdk/addons/world.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/core/ue-rpc.d.ts +54 -0
- package/dev-dist/types/hj-gis-sdk/core/ue-rpc.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/index.d.ts +27 -0
- package/dev-dist/types/hj-gis-sdk/index.d.ts.map +1 -0
- package/dev-dist/types/hj-gis-sdk/utils.d.ts +16 -0
- package/dev-dist/types/hj-gis-sdk/utils.d.ts.map +1 -0
- package/dev-dist/types/src/animation.d.ts +2 -0
- package/dev-dist/types/src/animation.d.ts.map +1 -0
- package/dev-dist/types/src/building.d.ts +2 -0
- package/dev-dist/types/src/building.d.ts.map +1 -0
- package/dev-dist/types/src/common.d.ts +5 -0
- package/dev-dist/types/src/common.d.ts.map +1 -0
- package/dev-dist/types/src/fence.d.ts +2 -0
- package/dev-dist/types/src/fence.d.ts.map +1 -0
- package/dev-dist/types/src/ghost.d.ts +2 -0
- package/dev-dist/types/src/ghost.d.ts.map +1 -0
- package/dev-dist/types/src/heatmap.d.ts +2 -0
- package/dev-dist/types/src/heatmap.d.ts.map +1 -0
- package/dev-dist/types/src/index.d.ts +2 -0
- package/dev-dist/types/src/index.d.ts.map +1 -0
- package/dev-dist/types/src/keyframe.d.ts +2 -0
- package/dev-dist/types/src/keyframe.d.ts.map +1 -0
- package/dev-dist/types/src/measurement.d.ts +2 -0
- package/dev-dist/types/src/measurement.d.ts.map +1 -0
- package/dev-dist/types/src/scatter.d.ts +2 -0
- package/dev-dist/types/src/scatter.d.ts.map +1 -0
- package/dev-dist/types/src/weather.d.ts +2 -0
- package/dev-dist/types/src/weather.d.ts.map +1 -0
- package/dev-dist/weather.esm.js +68 -0
- package/dev-dist/weather.esm.js.map +1 -0
- package/dev-dist/weather.js +70 -0
- package/dev-dist/weather.js.map +1 -0
- package/dist/sdk.esm.js +19 -6
- package/dist/sdk.esm.js.map +1 -1
- package/dist/sdk.js +19 -6
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.umd.js +1 -1
- package/dist/sdk.umd.js.map +1 -1
- package/dist/types/hj-gis-sdk/addons/tools/scatter.d.ts.map +1 -1
- package/dist/types/src/common.d.ts.map +1 -1
- package/hj-gis-sdk/addons/animation/animate-clip.ts +93 -0
- package/hj-gis-sdk/addons/animation/animation-action.ts +93 -0
- package/hj-gis-sdk/addons/animation/animation-mixer.ts +51 -0
- package/hj-gis-sdk/addons/animation/index.ts +17 -0
- package/hj-gis-sdk/addons/camera.ts +173 -0
- package/hj-gis-sdk/addons/clock.ts +85 -0
- package/hj-gis-sdk/addons/commander/context.ts +70 -0
- package/hj-gis-sdk/addons/commander/dispatcher.ts +68 -0
- package/hj-gis-sdk/addons/commander/excutor/base.ts +26 -0
- package/hj-gis-sdk/addons/loader/index.ts +7 -0
- package/hj-gis-sdk/addons/loader/loader.ts +3 -0
- package/hj-gis-sdk/addons/node/base.ts +131 -0
- package/hj-gis-sdk/addons/node/ue-node.ts +147 -0
- package/hj-gis-sdk/addons/proxy.ts +200 -0
- package/hj-gis-sdk/addons/tools/base.ts +11 -0
- package/hj-gis-sdk/addons/tools/building.ts +84 -0
- package/hj-gis-sdk/addons/tools/daytime.ts +14 -0
- package/hj-gis-sdk/addons/tools/fence.ts +105 -0
- package/hj-gis-sdk/addons/tools/ghost.ts +31 -0
- package/hj-gis-sdk/addons/tools/heat-map.ts +95 -0
- package/hj-gis-sdk/addons/tools/index.ts +25 -0
- package/hj-gis-sdk/addons/tools/match-view.ts +35 -0
- package/hj-gis-sdk/addons/tools/measurement.ts +25 -0
- package/hj-gis-sdk/addons/tools/pick-cast.ts +67 -0
- package/hj-gis-sdk/addons/tools/scatter.ts +230 -0
- package/hj-gis-sdk/addons/tools/weather.ts +40 -0
- package/hj-gis-sdk/addons/transform.ts +126 -0
- package/hj-gis-sdk/addons/world.ts +173 -0
- package/hj-gis-sdk/core/ue-rpc.ts +234 -0
- package/hj-gis-sdk/index.ts +26 -0
- package/hj-gis-sdk/utils.ts +52 -0
- package/index.html +48 -0
- package/package-lock.json +7368 -0
- package/package.json +17 -4
- package/rollup.config.dev.js +107 -0
- package/rollup.config.js +52 -0
- package/src/animation.ts +175 -0
- package/src/building.ts +114 -0
- package/src/common.ts +47 -0
- package/src/fence.ts +131 -0
- package/src/ghost.ts +70 -0
- package/src/heatmap.ts +125 -0
- package/src/index.ts +350 -0
- package/src/keyframe.ts +113 -0
- package/src/measurement.ts +80 -0
- package/src/scatter.ts +105 -0
- package/src/weather.ts +86 -0
- package/tsconfig.json +30 -0
- package/yarn.lock +3108 -0
package/package.json
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hj-gis-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"main": "dist/sdk.js",
|
|
5
5
|
"module": "dist/sdk.esm.js",
|
|
6
|
-
"types": "dist/types/index.d.ts",
|
|
6
|
+
"types": "dist/types/hj-gis-sdk/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
9
|
-
"
|
|
9
|
+
"dev-dist",
|
|
10
|
+
"src",
|
|
11
|
+
"hj-gis-sdk",
|
|
12
|
+
"types",
|
|
13
|
+
"rollup.config.js",
|
|
14
|
+
"rollup.config.dev.js",
|
|
15
|
+
"package.json",
|
|
16
|
+
"tsconfig.json",
|
|
17
|
+
"package-lock.json",
|
|
18
|
+
"yarn.lock",
|
|
19
|
+
"README.md",
|
|
20
|
+
"README_UERPC.md",
|
|
21
|
+
"index.html"
|
|
10
22
|
],
|
|
11
23
|
"scripts": {
|
|
12
24
|
"build": "npm run clean && rollup -c",
|
|
@@ -21,7 +33,8 @@
|
|
|
21
33
|
"keywords": [
|
|
22
34
|
"gis",
|
|
23
35
|
"typescript",
|
|
24
|
-
"sdk"
|
|
36
|
+
"sdk",
|
|
37
|
+
"hj-gis-sdk"
|
|
25
38
|
],
|
|
26
39
|
"author": "",
|
|
27
40
|
"license": "MIT",
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { defineConfig } from 'rollup'
|
|
2
|
+
import nodeResolve from '@rollup/plugin-node-resolve'
|
|
3
|
+
import commonjs from '@rollup/plugin-commonjs'
|
|
4
|
+
import typescript from '@rollup/plugin-typescript'
|
|
5
|
+
import alias from '@rollup/plugin-alias'
|
|
6
|
+
import serve from 'rollup-plugin-serve'
|
|
7
|
+
import livereload from 'rollup-plugin-livereload'
|
|
8
|
+
import { mkdirSync, rmSync } from 'fs'
|
|
9
|
+
|
|
10
|
+
// 自定义清理插件,确保在每次构建前完全清理输出目录
|
|
11
|
+
const clearDevDist = {
|
|
12
|
+
name: 'clear-dev-dist',
|
|
13
|
+
buildStart() {
|
|
14
|
+
console.log('清理旧的dev-dist目录...')
|
|
15
|
+
// 清理旧的dev-dist目录
|
|
16
|
+
rmSync('dev-dist', { recursive: true, force: true })
|
|
17
|
+
// 确保输出目录存在
|
|
18
|
+
mkdirSync('dev-dist', { recursive: true })
|
|
19
|
+
mkdirSync('dev-dist/types', { recursive: true })
|
|
20
|
+
console.log('dev-dist目录清理完成')
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default defineConfig({
|
|
25
|
+
// 输入配置 - 包含lib和src
|
|
26
|
+
input: {
|
|
27
|
+
index: 'hj-gis-sdk/index.ts',
|
|
28
|
+
src: 'src/index.ts',
|
|
29
|
+
fence: 'src/fence.ts',
|
|
30
|
+
heatmap: 'src/heatmap.ts',
|
|
31
|
+
scatter: 'src/scatter.ts',
|
|
32
|
+
building: 'src/building.ts',
|
|
33
|
+
weather: 'src/weather.ts',
|
|
34
|
+
measurement: 'src/measurement.ts',
|
|
35
|
+
ghost: 'src/ghost.ts',
|
|
36
|
+
animation: 'src/animation.ts',
|
|
37
|
+
keyframe: 'src/keyframe.ts'
|
|
38
|
+
},
|
|
39
|
+
// Watch配置 - 监视lib和src目录下的所有文件
|
|
40
|
+
watch: {
|
|
41
|
+
include: ['hj-gis-sdk/**/*.ts', 'src/**/*.ts'],
|
|
42
|
+
exclude: ['node_modules/**', 'dev-dist/**']
|
|
43
|
+
},
|
|
44
|
+
// 开发模式下启用更详细的错误信息
|
|
45
|
+
onwarn: (warning, warn) => {
|
|
46
|
+
// 忽略特定警告
|
|
47
|
+
if (warning.code === 'CIRCULAR_DEPENDENCY') return
|
|
48
|
+
warn(warning)
|
|
49
|
+
},
|
|
50
|
+
output: [
|
|
51
|
+
// CommonJS 格式
|
|
52
|
+
{
|
|
53
|
+
dir: 'dev-dist',
|
|
54
|
+
format: 'cjs',
|
|
55
|
+
sourcemap: true,
|
|
56
|
+
exports: 'named',
|
|
57
|
+
entryFileNames: '[name].js',
|
|
58
|
+
chunkFileNames: '[name].js' // 确保chunk文件名也不包含哈希值
|
|
59
|
+
},
|
|
60
|
+
// ES Module 格式
|
|
61
|
+
{
|
|
62
|
+
dir: 'dev-dist',
|
|
63
|
+
format: 'esm',
|
|
64
|
+
sourcemap: true,
|
|
65
|
+
entryFileNames: '[name].esm.js',
|
|
66
|
+
chunkFileNames: '[name].esm.js' // 确保chunk文件名也不包含哈希值
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
plugins: [
|
|
70
|
+
// 清理输出目录插件
|
|
71
|
+
clearDevDist,
|
|
72
|
+
// 别名配置
|
|
73
|
+
alias({
|
|
74
|
+
entries: [{ find: 'hj-gis-sdk', replacement: './hj-gis-sdk/index.ts' }]
|
|
75
|
+
}),
|
|
76
|
+
// Node.js模块解析
|
|
77
|
+
nodeResolve({
|
|
78
|
+
extensions: ['.ts', '.js'],
|
|
79
|
+
preferBuiltins: false
|
|
80
|
+
}),
|
|
81
|
+
// CommonJS转换
|
|
82
|
+
commonjs(),
|
|
83
|
+
// TypeScript编译
|
|
84
|
+
typescript({
|
|
85
|
+
tsconfig: './tsconfig.json',
|
|
86
|
+
declaration: true,
|
|
87
|
+
declarationDir: 'dev-dist/types',
|
|
88
|
+
sourceMap: true,
|
|
89
|
+
inlineSources: true,
|
|
90
|
+
removeComments: false
|
|
91
|
+
}),
|
|
92
|
+
// 开发服务器配置
|
|
93
|
+
serve({
|
|
94
|
+
contentBase: '.',
|
|
95
|
+
port: 3000,
|
|
96
|
+
open: true,
|
|
97
|
+
verbose: true
|
|
98
|
+
}),
|
|
99
|
+
// 热重载配置 - 监视lib、src和dist目录
|
|
100
|
+
livereload({
|
|
101
|
+
watch: ['hj-gis-sdk', 'src', 'dev-dist'],
|
|
102
|
+
delay: 300
|
|
103
|
+
})
|
|
104
|
+
],
|
|
105
|
+
external: []
|
|
106
|
+
})
|
|
107
|
+
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { defineConfig } from 'rollup'
|
|
2
|
+
import nodeResolve from '@rollup/plugin-node-resolve'
|
|
3
|
+
import commonjs from '@rollup/plugin-commonjs'
|
|
4
|
+
import typescript from '@rollup/plugin-typescript'
|
|
5
|
+
import terser from '@rollup/plugin-terser'
|
|
6
|
+
import { mkdirSync } from 'fs'
|
|
7
|
+
|
|
8
|
+
// 确保输出目录存在
|
|
9
|
+
mkdirSync('dist', { recursive: true })
|
|
10
|
+
mkdirSync('dist/types', { recursive: true })
|
|
11
|
+
|
|
12
|
+
export default defineConfig({
|
|
13
|
+
input: 'hj-gis-sdk/index.ts',
|
|
14
|
+
output: [
|
|
15
|
+
// CommonJS 格式
|
|
16
|
+
{
|
|
17
|
+
file: 'dist/sdk.js',
|
|
18
|
+
format: 'cjs',
|
|
19
|
+
sourcemap: true,
|
|
20
|
+
exports: 'named'
|
|
21
|
+
},
|
|
22
|
+
// ES Module 格式
|
|
23
|
+
{
|
|
24
|
+
file: 'dist/sdk.esm.js',
|
|
25
|
+
format: 'esm',
|
|
26
|
+
sourcemap: true
|
|
27
|
+
},
|
|
28
|
+
// UMD 格式 (适用于浏览器直接使用)
|
|
29
|
+
{
|
|
30
|
+
file: 'dist/sdk.umd.js',
|
|
31
|
+
format: 'umd',
|
|
32
|
+
name: 'HJGISSDK',
|
|
33
|
+
sourcemap: true,
|
|
34
|
+
exports: 'named',
|
|
35
|
+
plugins: [terser()]
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
plugins: [
|
|
39
|
+
nodeResolve({
|
|
40
|
+
extensions: ['.ts', '.js']
|
|
41
|
+
}),
|
|
42
|
+
commonjs(),
|
|
43
|
+
typescript({
|
|
44
|
+
tsconfig: './tsconfig.json',
|
|
45
|
+
declaration: true,
|
|
46
|
+
declarationDir: 'dist/types',
|
|
47
|
+
sourceMap: true,
|
|
48
|
+
inlineSources: true
|
|
49
|
+
})
|
|
50
|
+
],
|
|
51
|
+
external: ['@epicgames-ps/lib-pixelstreamingfrontend-ue5.5']
|
|
52
|
+
})
|
package/src/animation.ts
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { Addons } from 'hj-gis-sdk'
|
|
2
|
+
|
|
3
|
+
/// 动画效果示例
|
|
4
|
+
|
|
5
|
+
import { PerspectiveCamera } from 'hj-gis-sdk/addons/camera'
|
|
6
|
+
import { initializeApp } from './common'
|
|
7
|
+
|
|
8
|
+
import GUI from 'lil-gui'
|
|
9
|
+
import { Logger, LogLevel } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5'
|
|
10
|
+
|
|
11
|
+
Logger.InitLogging(LogLevel.Info, false)
|
|
12
|
+
const { UERPCNode, Animation } = Addons
|
|
13
|
+
|
|
14
|
+
let world: InstanceType<typeof Addons.World>
|
|
15
|
+
let camera: InstanceType<typeof PerspectiveCamera>
|
|
16
|
+
|
|
17
|
+
let skeletalNode: InstanceType<typeof UERPCNode> | null = null
|
|
18
|
+
let animationMixer: InstanceType<typeof Animation.AnimationMixer> | null = null
|
|
19
|
+
|
|
20
|
+
async function _initializeApp() {
|
|
21
|
+
// const url = `ws://120.27.198.158:9001/player`
|
|
22
|
+
const url = `wss://kdyjs-proxy.metamaker.cn/proxy_gis_sdk`
|
|
23
|
+
const AppElement = document.querySelector('#ue')! as HTMLElement
|
|
24
|
+
let result = await initializeApp(url, AppElement)
|
|
25
|
+
world = result.world
|
|
26
|
+
camera = result.camera
|
|
27
|
+
animationMixer = new Animation.AnimationMixer(world.rpc)
|
|
28
|
+
|
|
29
|
+
// 可以在此处加载动画相关的蓝图对象
|
|
30
|
+
skeletalNode = await world.spawnSkeletalMesh({
|
|
31
|
+
assetPath: '/Game/Mesh/Human/Jog_In_Circle.Jog_In_Circle'
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// 模型太大, 调整到适合的大小
|
|
35
|
+
skeletalNode.transform.scale.set(0.3, 0.3, 0.3)
|
|
36
|
+
|
|
37
|
+
camera.transform.position.x = -180
|
|
38
|
+
camera.transform.position.z = 5
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 判断 window 是否初始化完成
|
|
42
|
+
if (document.readyState === 'loading') {
|
|
43
|
+
// 文档正在加载,等待DOMContentLoaded事件
|
|
44
|
+
document.addEventListener('DOMContentLoaded', _initializeApp)
|
|
45
|
+
} else {
|
|
46
|
+
// 文档已经加载完成,直接初始化应用
|
|
47
|
+
_initializeApp()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 动画控制配置
|
|
51
|
+
const animationConfig = {
|
|
52
|
+
speed: 1.0,
|
|
53
|
+
loop: true,
|
|
54
|
+
playing: false
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 动画列表(示例)
|
|
58
|
+
const animationList = {
|
|
59
|
+
跑步动画: '/Game/Mesh/Human/Jog_In_Circle_Anim.Jog_In_Circle_Anim'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const selectedAnimation = {
|
|
63
|
+
current: ''
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 创建GUI控制面板
|
|
67
|
+
const gui = new GUI()
|
|
68
|
+
|
|
69
|
+
let animateAction: InstanceType<typeof Animation.AnimationAction> | undefined
|
|
70
|
+
let animateClip: InstanceType<typeof Animation.PresetAnimateClip>
|
|
71
|
+
// 添加动画选择下拉菜单
|
|
72
|
+
const animationFolder = gui.addFolder('动画控制')
|
|
73
|
+
animationFolder
|
|
74
|
+
.add(selectedAnimation, 'current', animationList)
|
|
75
|
+
.name('选择动画')
|
|
76
|
+
.onChange(async (value: string) => {
|
|
77
|
+
animateClip = new Animation.PresetAnimateClip(value)
|
|
78
|
+
|
|
79
|
+
animateAction = animationMixer!.clipAction(animateClip, skeletalNode!)
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
// 添加动画播放控制
|
|
83
|
+
// 保存按钮引用
|
|
84
|
+
let playButton: any, pauseButton: any
|
|
85
|
+
|
|
86
|
+
const animationControls = {
|
|
87
|
+
play: async () => {
|
|
88
|
+
if (!animateAction) {
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
if (animationConfig.loop) {
|
|
92
|
+
animateAction.type = 'loop'
|
|
93
|
+
} else {
|
|
94
|
+
animateAction.type = 'once'
|
|
95
|
+
}
|
|
96
|
+
animateAction.rate = animationConfig.speed
|
|
97
|
+
animateAction.play()
|
|
98
|
+
animationConfig.playing = true
|
|
99
|
+
// 更新按钮状态
|
|
100
|
+
updateButtonStates()
|
|
101
|
+
},
|
|
102
|
+
pause: async () => {
|
|
103
|
+
if (!animateAction) {
|
|
104
|
+
alert('动画未准备好')
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
animateAction.pause()
|
|
108
|
+
animationConfig.playing = false
|
|
109
|
+
// 更新按钮状态
|
|
110
|
+
updateButtonStates()
|
|
111
|
+
},
|
|
112
|
+
stop: async () => {
|
|
113
|
+
if (!animateAction) {
|
|
114
|
+
alert('动画未准备好')
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
// animateAction.stop()
|
|
118
|
+
animationConfig.playing = false
|
|
119
|
+
// 更新按钮状态
|
|
120
|
+
updateButtonStates()
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 创建按钮并保存引用
|
|
125
|
+
playButton = animationFolder
|
|
126
|
+
.add(animationControls, 'play')
|
|
127
|
+
.name('播放')
|
|
128
|
+
.disable(animationConfig.playing)
|
|
129
|
+
|
|
130
|
+
pauseButton = animationFolder
|
|
131
|
+
.add(animationControls, 'pause')
|
|
132
|
+
.name('暂停')
|
|
133
|
+
.enable(animationConfig.playing)
|
|
134
|
+
|
|
135
|
+
// 添加停止按钮
|
|
136
|
+
const stopButton = animationFolder
|
|
137
|
+
.add(animationControls, 'stop')
|
|
138
|
+
.name('停止')
|
|
139
|
+
|
|
140
|
+
// 更新按钮状态的函数
|
|
141
|
+
function updateButtonStates() {
|
|
142
|
+
if (playButton) {
|
|
143
|
+
if (animationConfig.playing) {
|
|
144
|
+
playButton.disable()
|
|
145
|
+
pauseButton.enable()
|
|
146
|
+
} else {
|
|
147
|
+
playButton.enable()
|
|
148
|
+
pauseButton.disable()
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// 添加动画参数控制
|
|
154
|
+
animationFolder
|
|
155
|
+
.add(animationConfig, 'speed', 0.1, 3.0, 0.1)
|
|
156
|
+
.name('动画速度')
|
|
157
|
+
.onChange(async (value: number) => {
|
|
158
|
+
console.log('设置动画速度:', value)
|
|
159
|
+
// await world.tools.animation.setSpeed(value)
|
|
160
|
+
// animateAction?.rate = value
|
|
161
|
+
if (!animateAction) {
|
|
162
|
+
alert('请先选择动画')
|
|
163
|
+
return
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
animationFolder
|
|
168
|
+
.add(animationConfig, 'loop')
|
|
169
|
+
.name('循环播放')
|
|
170
|
+
.onChange(async (value: boolean) => {
|
|
171
|
+
console.log('设置循环播放:', value)
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
// 打开默认的文件夹
|
|
175
|
+
animationFolder.open()
|
package/src/building.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Addons } from 'hj-gis-sdk'
|
|
2
|
+
|
|
3
|
+
/// 建筑示例
|
|
4
|
+
|
|
5
|
+
import { PerspectiveCamera } from 'hj-gis-sdk/addons/camera'
|
|
6
|
+
import { initializeApp } from './common'
|
|
7
|
+
|
|
8
|
+
import GUI from 'lil-gui'
|
|
9
|
+
import { Logger, LogLevel } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5'
|
|
10
|
+
|
|
11
|
+
Logger.InitLogging(LogLevel.Info, false)
|
|
12
|
+
const { UERPCNode } = Addons
|
|
13
|
+
|
|
14
|
+
let world: InstanceType<typeof Addons.World>
|
|
15
|
+
let camera: InstanceType<typeof PerspectiveCamera>
|
|
16
|
+
|
|
17
|
+
let bluePrintNode: InstanceType<typeof UERPCNode>
|
|
18
|
+
|
|
19
|
+
async function _initializeApp() {
|
|
20
|
+
// const url = `ws://120.27.198.158:9001/player`
|
|
21
|
+
const url = `wss://kdyjs-proxy.metamaker.cn/proxy_gis_sdk`
|
|
22
|
+
const AppElement = document.querySelector('#ue')! as HTMLElement
|
|
23
|
+
let result = await initializeApp(url, AppElement)
|
|
24
|
+
world = result.world
|
|
25
|
+
camera = result.camera
|
|
26
|
+
|
|
27
|
+
// 设置相机位置
|
|
28
|
+
camera!.transform.position.z = 10
|
|
29
|
+
camera!.transform.position.x = -80
|
|
30
|
+
camera!.transform.position.y = 0
|
|
31
|
+
|
|
32
|
+
// 确保加载了正确的蓝图对象
|
|
33
|
+
let louNode = await world.spawnLocalBlueprintActor({
|
|
34
|
+
assetPath: '/Game/Mesh/Lou/Lou.Lou'
|
|
35
|
+
})
|
|
36
|
+
bluePrintNode = louNode
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 判断 window 是否初始化完成
|
|
40
|
+
if (document.readyState === 'loading') {
|
|
41
|
+
// 文档正在加载,等待DOMContentLoaded事件
|
|
42
|
+
document.addEventListener('DOMContentLoaded', _initializeApp)
|
|
43
|
+
} else {
|
|
44
|
+
// 文档已经加载完成,直接初始化应用
|
|
45
|
+
_initializeApp()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 建筑处理器类型
|
|
49
|
+
let handler: Awaited<ReturnType<typeof world.tools.building.expand>>
|
|
50
|
+
const gui = new GUI()
|
|
51
|
+
|
|
52
|
+
// 生成建筑按钮
|
|
53
|
+
gui
|
|
54
|
+
.add(
|
|
55
|
+
{
|
|
56
|
+
async building() {
|
|
57
|
+
// z
|
|
58
|
+
|
|
59
|
+
handler = await world.tools.building.expand(bluePrintNode.key!, {
|
|
60
|
+
spacing: 5,
|
|
61
|
+
duration: 1
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
'building'
|
|
66
|
+
)
|
|
67
|
+
.name('查看建筑物')
|
|
68
|
+
|
|
69
|
+
gui
|
|
70
|
+
.add(
|
|
71
|
+
{
|
|
72
|
+
async expandFloor() {
|
|
73
|
+
if (!handler) {
|
|
74
|
+
alert('请先查看建筑物')
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let _dir = camera.transform.position
|
|
79
|
+
.clone()
|
|
80
|
+
.subtract(bluePrintNode.transform.position)
|
|
81
|
+
.normalize()
|
|
82
|
+
|
|
83
|
+
let distance = bluePrintNode.transform.position.distanceTo(
|
|
84
|
+
camera.transform.position
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
// 向相机的镜头靠近
|
|
88
|
+
handler.expandFloor({
|
|
89
|
+
floorIndex: 2,
|
|
90
|
+
direction: {
|
|
91
|
+
X: _dir.x,
|
|
92
|
+
Y: _dir.y,
|
|
93
|
+
Z: _dir.z
|
|
94
|
+
},
|
|
95
|
+
distance: distance / 3,
|
|
96
|
+
// expandHeight: 0,
|
|
97
|
+
duration: 1.2
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
'expandFloor'
|
|
102
|
+
)
|
|
103
|
+
.name('展开楼层')
|
|
104
|
+
|
|
105
|
+
gui
|
|
106
|
+
.add(
|
|
107
|
+
{
|
|
108
|
+
collapse: () => {
|
|
109
|
+
handler.collapse()
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
'collapse'
|
|
113
|
+
)
|
|
114
|
+
.name('折叠建筑')
|
package/src/common.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Config,
|
|
3
|
+
Flags,
|
|
4
|
+
NumericParameters,
|
|
5
|
+
PixelStreaming
|
|
6
|
+
} from '@epicgames-ps/lib-pixelstreamingfrontend-ue5.5'
|
|
7
|
+
import { Addons } from 'hj-gis-sdk'
|
|
8
|
+
const { World, PerspectiveCamera } = Addons
|
|
9
|
+
export async function initializeApp(url: string, parentElement: HTMLElement) {
|
|
10
|
+
const config = new Config({
|
|
11
|
+
initialSettings: {
|
|
12
|
+
ss: url,
|
|
13
|
+
StreamerId: '',
|
|
14
|
+
AutoPlayVideo: true,
|
|
15
|
+
StartVideoMuted: true,
|
|
16
|
+
[Flags.HoveringMouseMode]: true,
|
|
17
|
+
[Flags.TouchInput]: true,
|
|
18
|
+
[Flags.FakeMouseWithTouches]: true
|
|
19
|
+
|
|
20
|
+
/// 这是一些处理网络质量的参数 降低视频质量以减少网络带宽消耗带来的卡顿问题
|
|
21
|
+
// [NumericParameters.WebRTCFPS]: 30, // 限制帧率为30fps
|
|
22
|
+
// [NumericParameters.WebRTCMinBitrate]: 500, // 设置最小比特率为500kbps
|
|
23
|
+
// [NumericParameters.WebRTCMaxBitrate]: 1000, // 设置最大比特率为2000kbps
|
|
24
|
+
// [NumericParameters.MinQuality]: 0.3, // 设置最小质量为0.3
|
|
25
|
+
// [NumericParameters.MaxQuality]: 0.6 // 设置最大质量为0.8
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
const stream = new PixelStreaming(config, {
|
|
29
|
+
videoElementParent: parentElement
|
|
30
|
+
})
|
|
31
|
+
stream.connect()
|
|
32
|
+
let { resolve, promise } = Promise.withResolvers()
|
|
33
|
+
stream.addEventListener('playStream', () => {
|
|
34
|
+
console.log('PlayStreamEvent')
|
|
35
|
+
resolve(null)
|
|
36
|
+
})
|
|
37
|
+
await promise
|
|
38
|
+
let world = new World(stream)
|
|
39
|
+
world.tools.matchView.excute()
|
|
40
|
+
let camera = new PerspectiveCamera(world.rpc)
|
|
41
|
+
camera.transform.position.set(0, 0, 0)
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
world,
|
|
45
|
+
camera
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/fence.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/// 电子围栏
|
|
2
|
+
|
|
3
|
+
import { PerspectiveCamera } from 'hj-gis-sdk/addons/camera'
|
|
4
|
+
import { initializeApp } from './common'
|
|
5
|
+
import { Addons } from 'hj-gis-sdk'
|
|
6
|
+
import GUI from 'lil-gui'
|
|
7
|
+
import { Logger, LogLevel } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5'
|
|
8
|
+
const { World } = Addons
|
|
9
|
+
|
|
10
|
+
Logger.InitLogging(LogLevel.Info, false)
|
|
11
|
+
let world: InstanceType<typeof World>
|
|
12
|
+
let camera: InstanceType<typeof PerspectiveCamera>
|
|
13
|
+
async function _initializeApp() {
|
|
14
|
+
// const url = `ws://120.27.198.158:9001/player`
|
|
15
|
+
const url = `wss://kdyjs-proxy.metamaker.cn/proxy_gis_sdk`
|
|
16
|
+
const AppElement = document.querySelector('#ue')! as HTMLElement
|
|
17
|
+
let result = await initializeApp(url, AppElement)
|
|
18
|
+
world = result.world
|
|
19
|
+
camera = result.camera
|
|
20
|
+
|
|
21
|
+
// 加载地图 并 调整 camera 的站位
|
|
22
|
+
await world!.loadLevelByName('plgz')
|
|
23
|
+
|
|
24
|
+
camera!.transform.rotation.pitch = -24.621778868125325
|
|
25
|
+
camera!.transform.rotation.yaw = -105.8061416023954
|
|
26
|
+
camera!.transform.rotation.roll = -0.000008784850083129122
|
|
27
|
+
camera!.transform.position.set(
|
|
28
|
+
-237278.78546608693,
|
|
29
|
+
-3452.7198396154936,
|
|
30
|
+
18918.349286794506
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 判断 window 是否初始化完成
|
|
35
|
+
if (document.readyState === 'loading') {
|
|
36
|
+
// 文档正在加载,等待DOMContentLoaded事件
|
|
37
|
+
document.addEventListener('DOMContentLoaded', _initializeApp)
|
|
38
|
+
} else {
|
|
39
|
+
// 文档已经加载完成,直接初始化应用
|
|
40
|
+
_initializeApp()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let handler: Awaited<ReturnType<typeof world.tools.fence.create>> | undefined
|
|
44
|
+
const gui = new GUI()
|
|
45
|
+
|
|
46
|
+
async function createFence() {
|
|
47
|
+
if (pickPoint.length < 4) {
|
|
48
|
+
Logger.Error(`请先点选电子围栏坐标 必须大于 4 个点'`)
|
|
49
|
+
alert('请先点选电子围栏坐标 必须大于 4 个点')
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
if (handler) {
|
|
53
|
+
await handler.remove()
|
|
54
|
+
handler = undefined
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
handler = await world.tools.fence.create({
|
|
58
|
+
vectorArray: pickPoint,
|
|
59
|
+
height: fenceConfig.height,
|
|
60
|
+
color: fenceConfig.color
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// GUI 配置参数
|
|
65
|
+
const fenceConfig = {
|
|
66
|
+
height: 2000, // 默认高度
|
|
67
|
+
color: {
|
|
68
|
+
R: 0,
|
|
69
|
+
G: 0,
|
|
70
|
+
B: 255,
|
|
71
|
+
A: 255
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 默认的数据
|
|
76
|
+
let pickPoint = [
|
|
77
|
+
{ X: -246221.0796922246, Y: -32072.524457131625, Z: 1745.0013945392457 },
|
|
78
|
+
{ X: -243099.5648544035, Y: -21702.59371692306, Z: 1744.9990816078753 },
|
|
79
|
+
{ X: -239620.4587922823, Y: -23366.489133662646, Z: 1745.0001235060408 },
|
|
80
|
+
{ X: -241704.08632315777, Y: -33198.77387552471, Z: 1745.000323218097 }
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
// 添加高度控制
|
|
84
|
+
gui.add(fenceConfig, 'height', 0, 50000, 1).name('围栏高度')
|
|
85
|
+
|
|
86
|
+
// 添加颜色控制
|
|
87
|
+
const colorFolder = gui.addFolder('围栏颜色')
|
|
88
|
+
colorFolder.add(fenceConfig.color, 'R', 0, 255, 1).name('红色')
|
|
89
|
+
colorFolder.add(fenceConfig.color, 'G', 0, 255, 1).name('绿色')
|
|
90
|
+
colorFolder.add(fenceConfig.color, 'B', 0, 255, 1).name('蓝色')
|
|
91
|
+
colorFolder.add(fenceConfig.color, 'A', 0, 255, 1).name('透明度')
|
|
92
|
+
colorFolder.open()
|
|
93
|
+
|
|
94
|
+
gui
|
|
95
|
+
.add(
|
|
96
|
+
{
|
|
97
|
+
// 通过点选坐标,自定义生成围栏
|
|
98
|
+
pick: async () => {
|
|
99
|
+
pickPoint.length = 0
|
|
100
|
+
world.tools.pickCast.pick(
|
|
101
|
+
(data) => {
|
|
102
|
+
pickPoint.push(data.World)
|
|
103
|
+
},
|
|
104
|
+
1_000_000,
|
|
105
|
+
true
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
'pick'
|
|
110
|
+
)
|
|
111
|
+
.name('点选电子围栏坐标')
|
|
112
|
+
|
|
113
|
+
gui
|
|
114
|
+
.add(
|
|
115
|
+
{
|
|
116
|
+
fence: createFence
|
|
117
|
+
},
|
|
118
|
+
'fence'
|
|
119
|
+
)
|
|
120
|
+
.name('生成电子围栏')
|
|
121
|
+
|
|
122
|
+
gui
|
|
123
|
+
.add(
|
|
124
|
+
{
|
|
125
|
+
destroy() {
|
|
126
|
+
handler && handler.remove()
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
'destroy'
|
|
130
|
+
)
|
|
131
|
+
.name('销毁电子围栏')
|