8 Star 0 Fork 0

zzh-clown/hj-2021-7

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
bar3d-noise-modified-from-marpi-demo.html 7.21 KB
一键复制 编辑 原始数据 按行查看 历史
wenyue 提交于 2021-07-13 11:41 . 文阅
<!--
THIS EXAMPLE WAS DOWNLOADED FROM https://echarts.apache.org/examples/zh/editor.html?c=bar3d-noise-modified-from-marpi-demo&gl=1
-->
<!DOCTYPE html>
<html style="height: 100%">
<head>
<meta charset="utf-8">
</head>
<body style="height: 100%; margin: 0">
<div id="container" style="height: 100%"></div>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js"></script>
Uncomment this line if you want to dataTool extension
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5/dist/extension/dataTool.min.js"></script>
Uncomment this line if you want to use gl extension
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-gl@2/dist/echarts-gl.min.js"></script>
Uncomment this line if you want to echarts-stat extension
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-stat@latest/dist/ecStat.min.js"></script>
Uncomment this line if you want to use map
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5/map/js/china.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5/map/js/world.js"></script>
Uncomment these two lines if you want to use bmap extension
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=ETTpSkbYjpYN7It5IKr2RySGv33SdDnm"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5/dist/extension/bmap.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script type="text/javascript">
var dom = document.getElementById("container");
var myChart = echarts.init(dom);
var app = {};
var option;
let ROOT_PATH = 'https://cdn.jsdelivr.net/gh/apache/echarts-website@asf-site/examples';
$.getScript('https://cdn.jsdelivr.net/npm/simplex-noise@2.4.0/simplex-noise.js').done(function () {
var simplex = new SimplexNoise();
window.onresize = myChart.resize;
var UPDATE_DURATION = 1000;
function initVisualizer() {
var config = {
numWaves: 2,
randomize: randomize,
color1: '#000',
color2: "#300",
color3: "#fff",
size: 150,
roughness: 0.5,
metalness: 0.
};
//gui.add(config, "numWaves", 1, 3).name("Waves number").onChange(update).listen();
for (var i = 0; i < 2; i++) {
config["wave" + i + "axis" + "x"] = Math.random();
config["wave" + i + "axis" + "y"] = Math.random();
config["wave" + i + "rounding"] = Math.random();
config["wave" + i + "square"] = Math.random();
}
function randomize() {
//config.numWaves = Math.floor(Math.random() * 3) + 1;
for (var i = 0; i < 2; i++) {
config["wave" + i + "axis" + "x"] = Math.random();
config["wave" + i + "axis" + "y"] = Math.random();
config["wave" + i + "rounding"] = Math.random();
config["wave" + i + "square"] = Math.random();
}
// Iterate over all controllers
for (var i in gui.__controllers) {
gui.__controllers[i].updateDisplay();
}
update();
}
function update() {
var item = [];
var dataProvider = [];
var mod = .1
//config.numWaves = Math.round(config.numWaves)
//var occurenceR = Math.random() * .02
//var r = 0//Math.random()
for (var s = 0; s < config.size * config.size; s++) {
var x = s % config.size;
var y = Math.floor(s / config.size);
//if (Math.random() < occurenceR)
// r = Math.random()
var output = 0;
for (var i = 0; i < config.numWaves; i++) {
var n = simplex.noise2D(i * 213 + (-50 + x) * mod * (1 - config["wave" + i + "axis" + "x"]) * .5, i * 3124 + (-50 + y) * mod * (1 - config["wave" + i + "axis" + "y"]) * .5)
n = Math.pow(n, 1.95 - 1.9 * config["wave" + i + "rounding"])
var square = Math.floor((1.1 - config["wave" + i + "square"]) * 100)
n = Math.round(n * square) / square;
//output*=n
if (output < n)
output = n;
}
dataProvider.push([x, y, (output + 0.1) * 2]);
}
myChart.setOption({
visualMap: {
inRange: {
barSize: 100 / config.size,
color: [config.color1, config.color2, config.color3],
}
},
series: [{
data: dataProvider,
realisticMaterial: {
roughness: config.roughness,
metalness: config.metalness
}
}]
});
//setTimeout(update, UPDATE_DURATION);
}
update();
}
var focalRange = 40
var blurRadius = 4
myChart.setOption(option = {
toolbox: {
left: 20,
iconStyle: {
normal: {
borderColor: '#fff'
}
}
},
tooltip: {},
visualMap: {
show: false,
min: 0.1,
max: 2.5,
inRange: {
color: ['#000', '#300', '#fff']
}
},
xAxis3D: {
type: 'value'
},
yAxis3D: {
type: 'value'
},
zAxis3D: {
type: 'value',
min: -6,
max: 6
},
grid3D: {
show: false,
environment: '#000',
viewControl: {
distance: 100,
maxDistance: 150,
minDistance: 50,
alpha: 38,
beta: 220,
minAlpha: 10,
//maxBeta: 360,
},
postEffect: {
enable: true,
SSAO: {
enable: true,
intensity: 1.3,
radius: 5
},
screenSpaceReflection: {
enable: false
},
depthOfField: {
enable: true,
blurRadius: blurRadius,
focalRange: focalRange,
focalDistance: 70
}
},
light: {
main: {
intensity: 1,
shadow: true,
shadowQuality: 'high',
alpha: 30
},
ambient: {
intensity: 0
},
ambientCubemap: {
texture: ROOT_PATH + '/data-gl/asset/pisa.hdr',
exposure: 2,
diffuseIntensity: 1,
specularIntensity: 1
}
}
},
series: [{
type: 'bar3D',
silent: true,
shading: 'realistic',
realisticMaterial: {
roughness: 0.5,
metalness: 0
},
instancing: true,
barSize: 0.6,
data: [],
lineStyle: {
width: 4
},
itemStyle: {
color: "#fff"
},
animation: false,
animationDurationUpdate: UPDATE_DURATION
}]
});
setTimeout(function() {
initVisualizer();
});
});
if (option && typeof option === 'object') {
myChart.setOption(option);
}
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zzh-clown/hj-2021-7.git
git@gitee.com:zzh-clown/hj-2021-7.git
zzh-clown
hj-2021-7
hj-2021-7
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385