# 巷道热力分析

巷道热力分析可以对巷道内部的某些属性(例如,浓度、密度)进行插值分析最终将热力颜色附着到巷道外壁。

提示

当前巷道热力分析支持'idw'(距离反比)和'kriging'(克里金)两种插值方式。

# 执行分析

使用引擎(Engine)analyseManager属性的executeLanewayHeatAnalysis接口执行分析。

import { MathUtils } from 'three';

// 加载巷道
engine.loadLaneways( 'assets/jsons/laneways(3.0).json', {

    useLOD: true,
    lodDistance: 2000.0,
    arrowMap: 'assets/textures/laneway/arrow.png',
    leftMap: 'assets/textures/laneway/left.jpg',
    rightMap: 'assets/textures/laneway/right.jpg',
    topMap: 'assets/textures/laneway/top.jpg',
    bottomMap: 'assets/textures/laneway/bottom.jpg'

} ).then( ( entities ) => {

    // 获取巷道外包盒
    const bounds = entities.bounds;

    // 构建巷道热力分析参数
    const parameters = {

        // 特征点数组
        featurePoints: [],

        // 最新单元格尺寸
        cellSize: 20.0,

        // 外包范围
        bounds: {

            min: bounds.min,
            max: bounds.max

        },

        // 值颜色
        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: 'kriging' // 使用克里金插值 

        },

        // 分析完成回调
        onCompleted: ( result ) => {

            // TODO:处理分析结果

        }

    };

    // 生成随机特征点
    for ( let i = 0; i < 200; i++ ) {

        const x = MathUtils.randFloat( bounds.min.x, bounds.max.x );
        const y = MathUtils.randFloat( bounds.min.y, bounds.max.y );
        const z = MathUtils.randFloat( bounds.min.z, bounds.max.z );
        const v = MathUtils.randFloat( 0.0, 1.0 ); 

        parameters.featurePoints.push( {

            point: [ x, y, z ],
            value: v

        } );        

    }

    // 执行分析
    engine.analyseManager.executeLanewayHeatAnalysis( 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
79
80
81
82
83
84
85
86
87
88
89

注意

特征点的Value值需要归一化到[ 0~1 ]区间。

# 取消分析

使用引擎(Engine)analyseManager属性的cancelLanewayHeatAnalysis接口取消分析。

// 取消巷道热力分析
engine.analyseManager.cancelLanewayHeatAnalysis();
1
2
Last Updated: 8/30/2023, 9:51:49 AM