scatter3D-simplex.html 2.9 KB
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Bar3D Simplex Noise - ECHARTS-GL</title>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes"> <!-- Fullscreen Landscape on iOS -->
        <link rel="stylesheet" href="./common.css">
    </head>
    <body>
        <div id="main"></div>
        <script src="../node_modules/echarts/dist/echarts.js"></script>
        <script src="../dist/echarts-gl.js"></script>
        <script src="lib/jquery.min.js"></script>
        <script src="lib/simplex.js"></script>
        <script src="js/commonUI.js"></script>
        <script>
            var chart = echarts.init(document.getElementById('main'));

            var noise = new SimplexNoise(Math.random);
            function generateData() {
                var data = [];
                for (var i = 0; i <= 40; i++) {
                    for (var j = 0; j <= 40; j++) {
                        for (var k = 0; k <= 40; k++) {
                            var value = noise.noise3D(i / 20, j / 20, k / 20);
                            valMax = Math.max(valMax, value);
                            valMin = Math.min(valMin, value);
                            data.push([i, j, k, value * 2 + 4]);
                        }
                    }
                }
                return data;
            }
            var valMin = Infinity;
            var valMax = -Infinity;
            var data = generateData();
            console.log(valMin, valMax);

            chart.setOption({
                tooltip: {},
                visualMap: {
                    show: false,
                    min: 2,
                    max: 6,
                    inRange: {
                        symbolSize: [0.5, 15],
                        color: ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026'],
                        colorAlpha: [0.2, 1]
                    }
                },
                xAxis3D: {
                    type: 'value'
                },
                yAxis3D: {
                    type: 'value'
                },
                zAxis3D: {
                    type: 'value'
                },
                grid3D: {
                    boxWidth: 150,
                    boxDepth: 150,
                    boxHeight: 150,
                    axisLine: {
                        lineStyle: { color: '#fff' }
                    },
                    axisPointer: {
                        lineStyle: { color: '#fff' }
                    },
                    viewControl: {
                        // autoRotate: true
                    }
                },
                series: [{
                    type: 'scatter3D',
                    data: data
                }]
            });

            window.onresize = chart.resize;
        </script>
    </body>
</html>