当前位置: 首页 > news >正文

Vue中实现3D得球自动旋转

1e7c9687bff03f95ad2f6a86a7429d5d.png

具体实现

安装echarts

在终端下安装echarts

npm install -D echarts

安装echarts-gl

在终端下安装echarts-gl

npm install -D echarts-gl

earth3D组件

earth3D.vue

<template><div class="globe3d-earth-container" ><div class="globe3d-earth"  ref="Globe3d"></div></div>
</template><script>import Vue from "vue";import echarts from "echarts";import "echarts-gl";import option from './Globe3d.js'import { debounce } from "./debounce.js";Vue.prototype.echarts = echarts;export default {name: "earth3D",data() {return {myChart: null,resizeHandler: null}},mounted() {// 基于准备好的dom,初始化echarts实例this.myChart = echarts.init(this.$refs.Globe3d);// 使用刚指定的配置项和数据显示图表。可视化3Dthis.myChart.setOption(option);this.resizeHandler = debounce(() => {if (this.myChart) {this.myChart.resize();}}, 100);this.initResizeEvent();},methods: {//监听resizeinitResizeEvent() {window.addEventListener("resize", this.resizeHandler);},//移除resizedestroyResizeEvent() {window.removeEventListener("resize", this.resizeHandler);}},beforeDestroy() {this.destroyResizeEvent();if (!this.myChart) {return;}this.myChart.dispose();this.myChart = null;},activated() {this.initResizeEvent();if (this.myChart) {this.myChart.resize();}},deactivated() {this.destroyResizeEvent();}} 
</script>
<style lang="scss" scoped>
.globe3d-earth-container {width: 100%;height: 100%;background:#2d3a4b;.globe3d-earth {width: 100%;height: 702px;}
}
</style>

debounce.js

export function debounce(func, wait, immediate) {let timeout, args, context, timestamp, result;const later = function() {// 据上一次触发时间间隔const last = +new Date() - timestamp;// 上次被包装函数被调用时间间隔 last 小于设定时间间隔 waitif (last < wait && last > 0) {timeout = setTimeout(later, wait - last);} else {timeout = null;// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用if (!immediate) {result = func.apply(context, args);if (!timeout) context = args = null;}}};return function(...args) {context = this;timestamp = +new Date();const callNow = immediate && !timeout;// 如果延时不存在,重新设定延时if (!timeout) timeout = setTimeout(later, wait);if (callNow) {result = func.apply(context, args);context = args = null;}return result;};}

Globe3d.js

import baseTextureImg from "./worldbathy.jpg";
import heightTextImg from "./worldbathy.jpg";
import environmentImg from "./starfield.jpg";
// import textureImg from "@/assets/images/pisa.jpg";export default {backgroundColor: "#2d3a4b",globe: {baseTexture: baseTextureImg,heightTexture: heightTextImg,displacementScale: 0.04,shading: "realistic",environment: environmentImg,realisticMaterial: {roughness: 0.9},postEffect: {enable: true},light: {main: {intensity: 5,shadow: true},ambientCubemap: {// texture: textureImg,diffuseIntensity: 0.2}}}
};

视频号如何做视频任务进行变现

2023-09-05

fccfbfd47ab651bbc04554ca78952540.jpeg

视频号如何插入带货商品链接进行变现

2023-09-04

d5696fcf56dcad58a40956a526eaf161.jpeg

36岁男子自称被裁,曾是前500强公司市场总监,最后接受做外买

2023-09-03

3bc15ec7c487d96bf9b1c798e86e672f.jpeg

聊一下互联网红利并牢牢抓住

2023-09-02

afa03c6e84f28940d147e9fde2e5503c.jpeg

关于大学考研与不考研自己一点看法

2023-09-01

8644fb3e9e5d93efc57888e107f176a8.jpeg

css中文本阴影特效

2023-08-30

99a9db363ea5b65d5e46dfda29839a2b.jpeg

css实现手风琴效果

2023-08-29

845f86d6751a90190ba8859732dab512.jpeg

如何成为一个有格局的人

2023-08-28

f5fb2b5dba7ba0ac816181036560f8dd.jpeg

49a700201d1cbedc8316a0a6e920763c.png

(能问答,能绘画)

511241ac59580afbbf7497dfe12e25cf.jpeg

http://www.lryc.cn/news/160243.html

相关文章:

  • 使用wkhtmltoimage实现生成长图分享
  • 新风机未来什么样?
  • python的几种数据类型的花样玩法(一)
  • python回调函数之获取jenkins构建结果
  • Docker底层实现
  • PY32F003F18之RS485通讯
  • 概率论与数理统计学习笔记(7)——全概率公式与贝叶斯公式
  • 深入了解 Axios 的 put 请求:使用技巧与最佳实践
  • 浅谈Http协议、TCP协议(转载)
  • flatten-maven-plugin使用
  • Vue3中快速简单使用CKEditor 5富文本编辑器
  • qt简易网络聊天室 数据库的练习
  • Navicat连接mysql8.0:提示无法加载身份验证插件“caching_sha2_password”
  • 手写签名到背景上合为1张图
  • 华为认证系统学习大纲及课程
  • 某米ax3000路由器组网解析
  • 【leetcode 力扣刷题】数学题之除法:哈希表解决商的循环节➕快速乘求解商
  • Union类型和集合的union()方法-set.union()
  • 简明SQL别名指南:掌握AS实现列名更名
  • 基于量子密钥分发和区块链技术的新一代加密通信系统
  • 网络安全-子域名收集
  • go-zero jwt 鉴权快速实战
  • 9.8day58 单调栈
  • 快速完成工信部APP备案流程_以阿里云APP备案为例
  • uniapp中UView中 u-form表单在v-for循环下如何进行表单校验
  • 工作新时代,腾讯轻联塑造高效办公未来
  • JavaScript实现广告倒计时和跳过广告
  • 蚂蚁发布金融大模型:两大应用产品支小宝2.0、支小助将在完成备案后
  • Jenkins 持续集成:Linux 系统 两台机器互相免密登录
  • Golang-GJSON 快速而简单的方法来从 json 文档获取值