# 空间场分析
空间场分析可以对三维空间中的一组离散点进行插值分析最终以热力体的方式进行展示。
# 执行分析
使用引擎(Engine)analyseManager属性的executeSpaceFieldAnalysis接口执行分析。
import { MathUtils } from 'three';
import { PointRenderable } from '@tx3d/core';
// 构建分析参数
const parameters = {
// 特征点数组
featurePoints: [],
// 最小单元格尺寸
cellSize: 10.0,
// 值颜色数组
valueColor: [
{ value: 0.0, color: '#000066' },
{ value: 0.1, color: 'blue' },
{ value: 0.2, color: 'cyan' },
{ value: 0.3, color: 'lime' },
{ value: 0.4, color: 'yellow' },
{ value: 0.5, color: 'orange' },
{ value: 0.6, color: 'red' },
{ value: 0.7, color: 'maroon' },
{ value: 0.8, color: '#660066' },
{ value: 0.9, color: '#990099' },
{ value: 1.0, color: '#ff66ff' }
],
// 插值参数('idw'或'kriging')
interpolator: {
type: 'idw'
},
// 可视化参数('point'、'voxel'、'volume')
visualization: {
type: 'point'
},
// 分析成功回调
onCompleted: ( result ) => {
// 获取分析渲染组件
const renderable = result.entity.getComponent( PointRenderable );
// 更新透明度
renderable.opacity = 0.75;
// 更新阈值区间,[ 0~1 ]区间
renderable.setThreshold( 0.5, 0.8 );
}
};
// 随机生成特征点
for ( let i = 0; i < 50; i++ ) {
const x = MathUtils.randFloat( -1000.0, 1000.0 );
const y = MathUtils.randFloat( -100.0, 100.0 );
const z = MathUtils.randFloat( -1000.0, 1000.0 );
const v = MathUtils.randFloat( 0.0, 1.0 );
parameters.featurePoints.push( {
point: [ x, y, z ],
value: v
} );
}
// 执行分析
engine.analyseManager.executeSpaceFieldAnalysis( parameters );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
注意
特征点的Value值需要归一化到[ 0~1 ]区间。
# 更新分析结果
使用分析结果实体对应的渲染组件可以更新诸如透明度、阈值区间等属性。
import { VolumeRenderable } from '@tx3d/core';
// 分析完成回调
onCompleted: ( result ) => {
// 获取体渲染组件(假定使用'volume'进行可视化展示)
const renderable = result.entity.getComponent( VolumeRenderable );
// 更新透明度
renderable.opacity = 0.8;
// 更新分析阈值区间,[ 0~1 ]区间
renderable.setThreshold( 0.15, 0.75 );
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 销毁分析结果
使用分析结果实体(Entity)的destroy接口销毁分析结果。
// 分析完成回调
onCompleted: ( result ) => {
// 销毁分析结果
result.entity.destroy();
}
1
2
3
4
5
6
7
2
3
4
5
6
7