Browse Source

echart

master
lxc 2 years ago
parent
commit
4b8012cdc6
  1. BIN
      .DS_Store
  2. BIN
      assets/.DS_Store
  3. BIN
      assets/video/.DS_Store
  4. 4
      js/app.js
  5. 3742
      lib/ColladaLoader.js
  6. 6
      libs/Modules.js
  7. 45
      libs/echarts.min.js
  8. BIN
      libs/three/js/.DS_Store
  9. BIN
      libs/three/jsm/.DS_Store
  10. 133
      lndexUASB2.html
  11. 133
      lndexUASBUpdate.html
  12. 150
      temp copy 3.html

BIN
.DS_Store

Binary file not shown.

BIN
assets/.DS_Store

Binary file not shown.

BIN
assets/video/.DS_Store

Binary file not shown.

4
js/app.js

@ -122,8 +122,8 @@ var APP = {
} }
function createLights() { function createLights() {
var directionalLight = new THREE.DirectionalLight(0xe0ffff); var directionalLight = new THREE.DirectionalLight(0xaeaeae);
directionalLight.position.set(-.5, .5, 15).normalize(); directionalLight.position.set(-15.5, .5, -15).normalize();
glScene.add(directionalLight); glScene.add(directionalLight);
const light = new THREE.AmbientLight("#aaaaaa"); const light = new THREE.AmbientLight("#aaaaaa");

3742
lib/ColladaLoader.js

File diff suppressed because it is too large

6
libs/Modules.js

@ -245,11 +245,7 @@ function addVideoPlane(x, y, z, width, length, videoId) {
return (mesh); return (mesh);
} }
var iframe = document.createElement('iframe')
iframe.src = url;
iframe.style.width = w + 'px';
iframe.style.height = h + 'px';
iframe.style.border = '0px';
//endregion //endregion
//region 矩形区域 //region 矩形区域

45
libs/echarts.min.js

File diff suppressed because one or more lines are too long

BIN
libs/three/js/.DS_Store

Binary file not shown.

BIN
libs/three/jsm/.DS_Store

Binary file not shown.

133
lndexUASB2.html

@ -67,6 +67,9 @@
<script async src="./libs/layui/layui.js"></script> <script async src="./libs/layui/layui.js"></script>
<script async src="./libs/mqtt/mqtt.min.js"></script> <script async src="./libs/mqtt/mqtt.min.js"></script>
<script src="./libs/Modules.js" charset="UTF-8"></script> <script src="./libs/Modules.js" charset="UTF-8"></script>
<script src="./lib/Tween.js"></script>
<script src="./lib/jquery-1.11.0.min.js"></script>
<script src="./libs/echarts.min.js"></script>
</head> </head>
<body ontouchstart=""> <body ontouchstart="">
@ -142,10 +145,7 @@
addRemarkLabels(); addRemarkLabels();
mqttInit(); mqttInit();
updateLabel(); updateLabel();
addLEDScreen();
let video = addVideoPlane(0, 8, 6, 200, 100, 'video');
video.scale.set(0.1, 0.1, 0.1);
scene.add(video);
// for (var i = 0; i < 1; i++) { // for (var i = 0; i < 1; i++) {
// player.create3dPage( // player.create3dPage(
// 1020, 680, // 1020, 680,
@ -153,6 +153,14 @@
// new THREE.Vector3(0, Math.PI, 0), // new THREE.Vector3(0, Math.PI, 0),
// 'https://zuoben.blog.csdn.net/'); // 'https://zuoben.blog.csdn.net/');
// } // }
addLEDScreen();
// let video = addVideoPlane(0, 8, 6, 200, 100, 'video');
// video.scale.set(0.1, 0.1, 0.1);
// scene.add(video);
initEcharts()
} }
// document.body.appendChild(player.dom); // document.body.appendChild(player.dom);
@ -167,12 +175,127 @@
player.addModels(scene1);//.children[3]); player.addModels(scene1);//.children[3]);
setModel(scene1, player); setModel(scene1, player);
// AddWaters(player); AddWaters(player);
// addRemarkLabels(); // addRemarkLabels();
}); });
} }
var pieChart, pieChart1, pieChart2, option, option2
function initEcharts() {
pieChart = echarts.init($("<canvas width='512' height='512'></canvas>")[0]);
option = {
color: ['#3398DB'],
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
axisTick: {
alignWithLabel: true
}
}
],
yAxis: [
{
type: 'value'
}
],
series: [
{
name: '直接访问',
type: 'bar',
barWidth: '60%',
data: [10, 52, 200, 334, 390, 330, 220]
}
]
};
pieChart.setOption(option);
pieChart.on('finished', function () {
var infoEchart = new THREE.TextureLoader().load(pieChart.getDataURL());
var infoEchartMaterial = new THREE.MeshBasicMaterial({
transparent: true,
map: infoEchart,
side: THREE.DoubleSide
});
var echartPlane = new THREE.Mesh(new THREE.PlaneGeometry(100, 100), infoEchartMaterial);
echartPlane.position.set(10, 8, 10);
echartPlane.scale.set(0.1, 0.1, 0.1);
scene.add(echartPlane);
});
pieChart2 = echarts.init($("<canvas width='512' height='512'></canvas>")[0]);
option2 = {
title: {
text: '某站点用户访问来源',
subtext: '纯属虚构',
x: 'center'
},
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
legend: {
orient: 'vertical',
left: 'left',
data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎']
},
series: [
{
name: '访问来源',
type: 'pie',
radius: '55%',
center: ['50%', '60%'],
data: [
{ value: 335, name: '直接访问' },
{ value: 310, name: '邮件营销' },
{ value: 234, name: '联盟广告' },
{ value: 135, name: '视频广告' },
{ value: 1548, name: '搜索引擎' }
],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
pieChart2.setOption(option2);
pieChart2.on('finished', function () {
var spriteMap = new THREE.TextureLoader().load(pieChart2.getDataURL());
var spriteMaterial = new THREE.SpriteMaterial({
transparent: true,
map: spriteMap,
side: THREE.DoubleSide
});
var sprite = new THREE.Sprite(spriteMaterial);
sprite.scale.set(15, 15, 1)
sprite.position.set(-10, 8, 0);
scene.add(sprite);
});
}
function initModel1() { function initModel1() {
var loader = new GLTFLoader(); var loader = new GLTFLoader();
loader.load('assets/models/uasb2.glb', function (gltf) { loader.load('assets/models/uasb2.glb', function (gltf) {

133
lndexUASBUpdate.html

@ -67,6 +67,9 @@
<script async src="./libs/layui/layui.js"></script> <script async src="./libs/layui/layui.js"></script>
<script async src="./libs/mqtt/mqtt.min.js"></script> <script async src="./libs/mqtt/mqtt.min.js"></script>
<script src="./libs/Modules.js" charset="UTF-8"></script> <script src="./libs/Modules.js" charset="UTF-8"></script>
<script src="./lib/Tween.js"></script>
<script src="./lib/jquery-1.11.0.min.js"></script>
<script src="./libs/echarts.min.js"></script>
</head> </head>
<body ontouchstart=""> <body ontouchstart="">
@ -142,10 +145,7 @@
addRemarkLabels(); addRemarkLabels();
mqttInit(); mqttInit();
updateLabel(); updateLabel();
addLEDScreen();
let video = addVideoPlane(0, 8, 6, 200, 100, 'video');
video.scale.set(0.1, 0.1, 0.1);
scene.add(video);
// for (var i = 0; i < 1; i++) { // for (var i = 0; i < 1; i++) {
// player.create3dPage( // player.create3dPage(
// 1020, 680, // 1020, 680,
@ -153,6 +153,14 @@
// new THREE.Vector3(0, Math.PI, 0), // new THREE.Vector3(0, Math.PI, 0),
// 'https://zuoben.blog.csdn.net/'); // 'https://zuoben.blog.csdn.net/');
// } // }
addLEDScreen();
// let video = addVideoPlane(0, 8, 6, 200, 100, 'video');
// video.scale.set(0.1, 0.1, 0.1);
// scene.add(video);
initEcharts()
} }
// document.body.appendChild(player.dom); // document.body.appendChild(player.dom);
@ -167,12 +175,127 @@
player.addModels(scene1);//.children[3]); player.addModels(scene1);//.children[3]);
setModel(scene1, player); setModel(scene1, player);
// AddWaters(player); AddWaters(player);
// addRemarkLabels(); // addRemarkLabels();
}); });
} }
var pieChart, pieChart1, pieChart2, option, option2
function initEcharts() {
pieChart = echarts.init($("<canvas width='512' height='512'></canvas>")[0]);
option = {
color: ['#3398DB'],
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
axisTick: {
alignWithLabel: true
}
}
],
yAxis: [
{
type: 'value'
}
],
series: [
{
name: '直接访问',
type: 'bar',
barWidth: '60%',
data: [10, 52, 200, 334, 390, 330, 220]
}
]
};
pieChart.setOption(option);
pieChart.on('finished', function () {
var infoEchart = new THREE.TextureLoader().load(pieChart.getDataURL());
var infoEchartMaterial = new THREE.MeshBasicMaterial({
transparent: true,
map: infoEchart,
side: THREE.DoubleSide
});
var echartPlane = new THREE.Mesh(new THREE.PlaneGeometry(100, 100), infoEchartMaterial);
echartPlane.position.set(10, 8, 10);
echartPlane.scale.set(0.1, 0.1, 0.1);
scene.add(echartPlane);
});
pieChart2 = echarts.init($("<canvas width='512' height='512'></canvas>")[0]);
option2 = {
title: {
text: '某站点用户访问来源',
subtext: '纯属虚构',
x: 'center'
},
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
legend: {
orient: 'vertical',
left: 'left',
data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎']
},
series: [
{
name: '访问来源',
type: 'pie',
radius: '55%',
center: ['50%', '60%'],
data: [
{ value: 335, name: '直接访问' },
{ value: 310, name: '邮件营销' },
{ value: 234, name: '联盟广告' },
{ value: 135, name: '视频广告' },
{ value: 1548, name: '搜索引擎' }
],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
pieChart2.setOption(option2);
pieChart2.on('finished', function () {
var spriteMap = new THREE.TextureLoader().load(pieChart2.getDataURL());
var spriteMaterial = new THREE.SpriteMaterial({
transparent: true,
map: spriteMap,
side: THREE.DoubleSide
});
var sprite = new THREE.Sprite(spriteMaterial);
sprite.scale.set(15, 15, 1)
sprite.position.set(-10, 8, 0);
scene.add(sprite);
});
}
function initModel1() { function initModel1() {
var loader = new GLTFLoader(); var loader = new GLTFLoader();
loader.load('assets/models/uasb2.glb', function (gltf) { loader.load('assets/models/uasb2.glb', function (gltf) {

150
temp copy 3.html

@ -0,0 +1,150 @@
<!DOCTYPE html>
<html>
<head>
<title>Threejs实现机械臂运动,机械臂dae格式模型</title>
<meta charset="UTF-8">
<script type="text/javascript" src="lib/statistics.js"></script>
<!-- <script type="text/javascript" src="lib/steak.js"></script> -->
<script type="text/javascript" src="lib/three.js"></script>
<script type="text/javascript" src="lib/OrbitControls.js"></script>
<script type="text/javascript" src="lib/ColladaLoader.js"></script>
<script type="text/javascript" src="lib/dat.gui.js"></script>
<script type="text/javascript" charset="UTF-8" src="lib/Tween.min.js"></script>
<style>
body {
margin: 0;
overflow: hidden;
}
</style>
</head>
<body>
<div id="dom"></div>
<script type="text/javascript">
var camera;
var renderer;
let dae;
let kinematics;
let kinematicsTween;
const tweenParameters = {};
function init() {
var urls = [
'assets/bgImage/skyBox6/posx.jpg',
'assets/bgImage/skyBox6/negx.jpg',
'assets/bgImage/skyBox6/posy.jpg',
'assets/bgImage/skyBox6/negy.jpg',
'assets/bgImage/skyBox6/posz.jpg',
'assets/bgImage/skyBox6/negz.jpg'
];
// 创建一个场景,它将包含我们所有的元素,如物体,相机和灯光。
var scene = new THREE.Scene();
var cubeLoader = new THREE.CubeTextureLoader();
// scene.background = cubeLoader.load(urls);
scene.opacity = 0;
// 创建一个摄像机,它定义了我们正在看的地方
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 100000);
// 将摄像机对准场景的中心
camera.position.z = 5;
camera.lookAt(scene.position);
var orbit = new THREE.OrbitControls(camera);
// 创建一个渲染器并设置大小,WebGLRenderer将会使用电脑显卡来渲染场景
renderer = new THREE.WebGLRenderer({
antialias: true,
logarithmicDepthBuffer: true,
});
renderer.setSize(window.innerWidth, window.innerHeight);
var ambientLight = new THREE.AmbientLight("#ffffff", 1);
scene.add(ambientLight);
const light = new THREE.HemisphereLight(0xffeeee, 0x111122);
scene.add(light);
// 将呈现器的输出添加到HTML元素
document.getElementById("dom").appendChild(renderer.domElement);
// 启动动画
renderScene();
initFang();
// 添加坊的模型
function initFang() {
var loader = new THREE.ColladaLoader();
loader.load('assets/models/abb_irb52_7_120.dae', function (collada) {
dae = collada.scene;
dae.traverse(function (child) {
if (child.isMesh) {
// model does not have normals
child.material.flatShading = true;
}
});
// dae.scale = 1000;
dae.updateMatrix();
kinematics = collada.kinematics;
console.log(kinematics)
scene.add(dae);
setupTween();
});
}
function setupTween() {
const duration = THREE.Math.randInt(1000, 2000);
const target = {};
for (const prop in kinematics.joints) {
if (kinematics.joints.hasOwnProperty(prop)) {
if (!kinematics.joints[prop].static) {
const joint = kinematics.joints[prop];
const old = tweenParameters[prop];
const position = old ? old : joint.zeroPosition;
tweenParameters[prop] = position;
target[prop] = THREE.Math.randInt(joint.limits.min, joint.limits.max);
}
}
}
kinematicsTween = new TWEEN.Tween(tweenParameters).to(target, duration).easing(TWEEN.Easing.Quadratic.Out);
kinematicsTween.onUpdate(function (object) {
for (const prop in kinematics.joints) {
if (kinematics.joints.hasOwnProperty(prop)) {
if (!kinematics.joints[prop].static) {
kinematics.setJointValue(prop, this[prop]);
}
}
}
});
kinematicsTween.start();
setTimeout(setupTween, duration);
}
var clock = new THREE.Clock(); //声明一个时钟对象
function renderScene() {
TWEEN.update();
orbit.update();
// 使用requestAnimationFrame函数进行渲染
requestAnimationFrame(renderScene);
renderer.render(scene, camera);
}
// 渲染的场景
renderer.render(scene, camera);
}
window.onload = init;
// 随着窗体的变化修改场景
function onResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
// 监听窗体调整大小事件
window.addEventListener('resize', onResize, false);
</script>
</body>
</html>
Loading…
Cancel
Save