首页 > 其他分享 >vis.js动画移动点3d图形

vis.js动画移动点3d图形

时间:2024-04-24 14:23:33浏览次数:20  
标签:tdot value js vis var data sin dot 3d

  • 代码案例
<!DOCTYPE html>
<html>
  <head>
    <title>Graph 3D demo</title>
    <style>
        body {
          font: 10pt arial;
        }
    </style>
    <script
      type="text/javascript"
      src="https://unpkg.com/vis-graph3d@latest/dist/vis-graph3d.min.js"
    ></script>
    <script type="text/javascript">
        var data = null;
        var graph = null;

        // Called when the Visualization API is loaded.
        function drawVisualization() {
          // create the data table.
          data = new vis.DataSet();

          // create some shortcuts to math functions
          var sin = Math.sin;
          var cos = Math.cos;
          var pi = Math.PI;

          // create the animation data
          var tmax = 2.0 * pi;
          var tstep = tmax / 75;
          var dotCount = 1; // set this to 1, 2, 3, 4, ...
          for (var t = 0; t < tmax; t += tstep) {
            var tgroup = parseFloat(t.toFixed(2));
            var value = t;

            // a dot in the center
            data.add({ x: 0, y: 0, z: 0, filter: tgroup, style: value });

            // one or multiple dots moving around the center
            for (var dot = 0; dot < dotCount; dot++) {
              var tdot = t + (2 * pi * dot) / dotCount;
              data.add({
                x: sin(tdot),
                y: cos(tdot),
                z: sin(tdot),
                filter: tgroup,
                style: value,
              });
              data.add({
                x: sin(tdot),
                y: -cos(tdot),
                z: sin(tdot + (tmax * 1) / 2),
                filter: tgroup,
                style: value,
              });
            }
          }

          // specify options
          var options = {
            width: "600px",
            height: "600px",
            style: "dot-color",
            showPerspective: true,
            showGrid: true,
            keepAspectRatio: true,
            verticalRatio: 1.0,
            animationInterval: 35, // milliseconds
            animationPreload: false,
            animationAutoStart: true,
            legendLabel: "color value",
            cameraPosition: {
              horizontal: 2.7,
              vertical: 0.0,
              distance: 1.65,
            },
          };

          // create our graph
          var container = document.getElementById("mygraph");
          graph = new vis.Graph3d(container, data, options);
        }

        window.addEventListener("load", () => {
          drawVisualization();
        });

    </script>
  </head>
  <body onl oad="drawVisualization();">    
    <div id="mygraph"></div>

    <div id="info"></div>    
      
  </body>
</html>
  • 效果图
点击查看详情

标签:tdot,value,js,vis,var,data,sin,dot,3d
From: https://www.cnblogs.com/dogleftover/p/18155173

相关文章

  • Docker(十六)-Docker的daemon.json的作用
    docker安装后默认没有daemon.json这个配置文件,需要进行手动创建。配置文件的默认路径:/etc/docker/daemon.json一般情况,配置文件daemon.json中配置的项目参数,在启动参数中同样适用,有些可能不一样(具体可以查看官方文档),但需要注意的一点,配置文件中如果已经有某个配置项,则无法在启动......
  • Nuxtjs如果使用useHead()导入swiper,除了在onMounted调用,切换报错前面使用 await next
     注意:awaitnextTick();如果没用,vue切换的时候可能有问题<scriptlang="ts"setup>import{DArrowRight}from"@element-plus/icons-vue";useHead({script:[{src:"/script/swiper.js",},],link:[{......
  • mormot2 json 操作
    [mormot2json操作]本文非完全原创,本文部分内容来自博客园,作者:{咏南中间件}unitmormot2.json.serial;interfaceusesClasses,SysUtils,mormot.core.buffers,mormot.core.text,mormot.core.json,mormot.core.base//;type{TSerial}TSerial......
  • python包:torchvision
    torch 是一个偏向于底层的包, 做一些较为基础 矩阵运算 对于不同的样本比如图像,声音,文字, 之类,有更加针对性的包 比如,针对图片 他的矩阵处理专用包就是:torchvision 这个就需要单独安装,这个包的体积不是很大,我们可以直接尝试安装 pipinstalltorchvision......
  • FormData传输JSON同时上传单个/多个文件问题
    背景最近在开发一个功能时,涉及到向后端接口发送:JSON请求参数多个文件刚开始想通过RequestBody(application/json)形式进行传值,但是文件不好处理。有一个通过application/json传输文件数据的方法,就是将文件转成base64,然后在后端进行处理。但是这种方式涉及到大文件传输的时候,转......
  • JS之调用高德地图接口进行打卡
    调用高德地图接口进行打卡1.安装依赖"@amap/amap-jsapi-loader":"^1.0.1"2.增加代码如下:orientation.jsimportAMapLoaderfrom'@amap/amap-jsapi-loader';import{gcj02towgs84}from'./coordTransform.js';exportfunctiongetOrientati......
  • js-splice方法【插入、删除、替换】
    splice()语法:arrayObject.splice(index,howmany,item1,.....,itemX)参数说明:参数描述index必需。整数,规定添加/删除项目的位置,使用负数可从数组结尾处规定位置。howmany必需。要删除的项目数量。如果设置为0,则不会删除项目。item1,…,itemX可选。向数组添......
  • 爬虫js逆向(python调用js学习)
    首先介绍pyexecjs的使用PyExecJs是一个python库,用于在Python环境中执行javaScript代码。它实际上是对Execs库的Python封装,Execls本身是一个通用的JavaScript运行环境的抽象层。使用PyExecJs,你可以在Python中执行JavaScript代码,而无需启动一个完整的JavaScript解释器......
  • 【实用技巧】JSON格式转换方式
    1 前言对接开发中,常遇到的就是报文转换。比如从淘宝或者京东拉取订单,亦或是各个公司内部的WMS、OMS等交互,都涉及到格式转换。而大多的格式基本上都是JSON格式,当然也有一些老的SAP交互用的是XML格式的,还有一小部分webService接口也是用的XML格式。那我们这节就看看JSON......
  • Visual Studio常用快捷键
    常用快捷方式快捷键功能Ctrl+K+C注释选定内容Ctrl+K+U取消注释选定内容Ctrl+K+D代码格式整个文档内容Ctrl+K+F格式化选定内容F12转到定义Ctrl+F12转到声明Ctrl+-后退Ctrl+Shift+-前进Ctrl+M+O折叠......