253Echarts - 3D 曲面(皮革材质)

简介: 253Echarts - 3D 曲面(皮革材质)
效果图

源代码
var TILING = [4, 2];
var heightImg = new Image();
heightImg.onload = update;
heightImg.src = './data-gl/asset/leather/leather_height.jpg';
function update() {
    var canvas = document.createElement('canvas');
    var ctx = canvas.getContext('2d');
    var width = canvas.width = heightImg.width;
    var height = canvas.height = heightImg.height;
    ctx.drawImage(heightImg, 0, 0, width, height);
    var imgData = ctx.getImageData(0, 0, width, height).data;
    function getScale(u, v) {
        u = (u / Math.PI * 0.5 + 0.5) * TILING[0];
        v = v / Math.PI * TILING[1];
        u = Math.floor((u - Math.floor(u)) * (width - 1));
        v = Math.floor((1 - v + Math.floor(v)) * (height - 1));
        var idx = v * width + u;
        return 1 + imgData[idx * 4] / 255 / 20;
    }
    myChart.setOption({
        xAxis3D: {
            type: 'value',
            min: -1.5,
            max: 1.5
        },
        yAxis3D: {
            type: 'value',
            min: -1.5,
            max: 1.5
        },
        zAxis3D: {
            type: 'value',
            min: -1.5,
            max: 1.5
        },
        grid3D: {
            show: false,
            environment: 'none',
            axisPointer: {
                show: false
            },
            postEffect: {
                enable: true,
                screenSpaceAmbientOcclusion: {
                    enable: true,
                    radius: 10,
                    intensity: 2,
                    quality: 'high'
                },
                screenSpaceReflection: {
                    enable: false
                },
                depthOfField: {
                    enable: false,
                    focalRange: 10,
                    fstop: 4
                }
            },
            temporalSuperSampling: {
                enable: true
            },
            light: {
                main: {
                    intensity: 2,
                    shadow: true
                },
                ambient: {
                    intensity: 0
                },
                ambientCubemap: {
                    texture: './data-gl/asset/pisa.hdr',
                    exposure: 1,
                    diffuseIntensity: 1,
                    specularIntensity: 2
                }
            },
            viewControl: {
                distance: 80
                // projection: 'orthographic'
            }
        },
        series: [{
            type: 'surface',
            parametric: true,
            shading: 'realistic',
            silent: true,
            wireframe: {
                show: false
            },
            realisticMaterial: {
                // detailTexture: 'asset/leather/leather_albedo.jpg',
                roughness: './data-gl/asset/leather/leather_roughness.jpg',
                normalTexture: './data-gl/asset/leather/leather_normal.jpg',
                textureTiling: TILING
            },
            itemStyle: {
                color: '#300'
            },
            parametricEquation: {
                u: {
                    min: -Math.PI,
                    max: Math.PI,
                    step: Math.PI / 100
                },
                v: {
                    min: 0.4,
                    max: Math.PI - 0.4,
                    step: Math.PI / 100
                },
                x: function (u, v) {
                    return Math.sin(v) * Math.sin(u) * getScale(u, v);
                },
                y: function (u, v) {
                    return Math.sin(v) * Math.cos(u) * getScale(u, v);
                },
                z: function (u, v) {
                    return Math.cos(v) * getScale(u, v);
                }
            }
        }]
    });
}


目录
相关文章
|
6天前
|
JSON 程序员 定位技术
使用echarts+echarts-gl绘制3d地图,实现地图轮播效果
记录一下大屏开发中使用到的echarts-gl 大屏的页面根据需求前前后后改了几个版本了,地图的样式也改了又改 这里记录一下,因为echarts属性用到的比较多也比较杂,防止以后需要用到忘记了
|
7月前
262Echarts - 3D 路径图(Flights on Geo3D)
262Echarts - 3D 路径图(Flights on Geo3D)
27 0
|
7月前
261Echarts - 3D 路径图(Flights GL)
261Echarts - 3D 路径图(Flights GL)
25 0
|
7月前
260Echarts - 3D 路径图(Flights)
260Echarts - 3D 路径图(Flights)
26 0
|
7月前
252Echarts - 3D 曲面(Golden Rose)
252Echarts - 3D 曲面(Golden Rose)
44 0
|
7月前
250Echarts - 3D 曲面(Sphere Parametric Surface)
250Echarts - 3D 曲面(Sphere Parametric Surface)
14 0
|
7月前
248Echarts - 3D 曲面(Parametric Surface Rose)
248Echarts - 3D 曲面(Parametric Surface Rose)
28 0
|
7月前
240Echarts - 3D 柱状图(Transparent Bar3D)
240Echarts - 3D 柱状图(Transparent Bar3D)
21 0
|
7月前
239Echarts - 3D 柱状图(Stacked Bar3D)
239Echarts - 3D 柱状图(Stacked Bar3D)
59 0
|
7月前
238Echarts - 3D 柱状图(Metal Bar3D)
238Echarts - 3D 柱状图(Metal Bar3D)
20 0