线圆示例(Line Circle)

  • 示例
  • HTML
  • CSS
  • JS

更多有趣示例 尽在知屋安砖社区

示例

HTML

 <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/101/three.min.js"></script><body><canvas id="myCanvas"></canvas></body>

CSS

 *{margin: 0;}canvas {display: block;width: 100%;height: 100%;margin: auto;position: fixed;overflow: hidden;}

JS

    window.addEventListener('load', init);function init() {// レンダラーを作成const renderer = new THREE.WebGLRenderer({canvas: document.querySelector('#myCanvas'),antialias: true});renderer.setPixelRatio(window.devicePixelRatio);renderer.setSize(window.innerWidth , window.innerHeight);renderer.setClearColor(0x0000ff, 1.0);console.log(renderer);const scene = new THREE.Scene();const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight);camera.position.set(0, 0, 500);window.addEventListener( 'resize', function(){onWindowResize(camera, renderer);}, false );const circleList = [];for (var i = 0; i < 10; i++) {circleList[i] = new Circle(i*i*2);scene.add(circleList[i]);}tick();function tick() {for (var i = 0; i < circleList.length; i++) {circleList[i].update(i);}renderer.render(scene, camera);requestAnimationFrame(tick);}}class Circle extends THREE.Object3D {constructor(size) {super();this.size = size;this.material = new THREE.LineBasicMaterial({color: 0xff0000});this.geometry = new THREE.Geometry();for (var i = 0; i < 361; i++) {const radian = i/360 * Math.PI * 2;this.geometry.vertices.push(new THREE.Vector3(Math.cos(radian)*this.size,Math.sin(radian)*this.size,30));}this.line = new THREE.Line( this.geometry, this.material );this.add( this.line );}update(i) {this.line.rotation.x += 0.001+i*0.001;this.line.rotation.y += 0.001+i*0.001;this.line.rotation.z += 0.001+i*0.001;}}function onWindowResize(camera, renderer) {camera.aspect = window.innerWidth / window.innerHeight;camera.updateProjectionMatrix();renderer.setSize( window.innerWidth, window.innerHeight );}

线圆示例(Line Circle)相关推荐

  1. OpenCV示例学习(二): 基本图形绘制算子:line(),circle(),fillPoly(), ellipse()

    OpenCV示例学习(二): 基本图形绘制算子:line(),circle(),fillPoly(), ellipse() #include <opencv2/opencv.hpp>usi ...

  2. Openlayers 根据坐标点画点线圆多边形

    根据坐标点画点线圆多边形,代码如下 Geometry type   Point LineString Polygon Circle None Bezier 绘制 绘制圆形 绘制线段 绘制多边形 绘制单 ...

  3. python根据坐标点画线_Openlayers 根据坐标点画点线圆多边形

    根据坐标点画点线圆多边形,代码如下 Geometry type Point LineString Polygon Circle None Bezier 绘制 绘制圆形 绘制线段 绘制多边形 绘制单个点 ...

  4. python使用matplotlib可视化线图(line plot)、移除可视化结果的所有坐标轴信息(remove all axis in matplotlib graph)

    python使用matplotlib可视化线图(line plot).移除可视化结果的所有坐标轴信息(remove all axis in matplotlib graph) 目录

  5. python使用matplotlib可视化线图(line plot)、设置X轴坐标的下限和上限数值(setting the lower and upper bound of the x axis)

    python使用matplotlib可视化线图(line plot).设置X轴坐标的下限和上限数值(setting the lower and upper bound of the x axis) 目 ...

  6. python使用matplotlib可视化线图(line plot)、在可视化图像中的指定位置添加横线(add horizontal line in matplotlib plot)

    python使用matplotlib可视化线图(line plot).在可视化图像中的指定位置添加横线(add horizontal line in matplotlib plot) 目录

  7. python使用matplotlib可视化线图(line plot)、将可视化图像的图例(legend)放置在图像外部、底部区域

    python使用matplotlib可视化线图(line plot).将可视化图像的图例(legend)放置在图像外部.底部区域(put legend outside and in bottom re ...

  8. python使用matplotlib可视化线图(line plot)、并自定义线条的粗细(线条的宽度、 line width in Matplotlib)

    python使用matplotlib可视化线图(line plot).并自定义线条的粗细(线条的宽度. line width in Matplotlib) 目录

  9. python使用matplotlib可视化线图(line plot)、使用invert_yaxis函数将Y轴坐标反序(invert the y axis in matplotlib)

    python使用matplotlib可视化线图(line plot).使用invert_yaxis函数将Y轴坐标反序(invert the y axis in matplotlib) 目录

最新文章

  1. SSI注入(server side includes injection 服务器端包含注入)
  2. 笔记-知识产权与标准化知识-软件质量模型(重)
  3. 军转干部计算机测试题,2015福建军转干考试计算机基础知识:计算机网络
  4. python(22)--面向对象1-封装
  5. python爬虫知识大全_Python爬虫入门有哪些基础知识点
  6. JavaScript返回上一页代码区别
  7. linux 驱动线程与进程,Linux内核学习之二-进程与线程
  8. 基于JAVA+SpringBoot+Mybatis+MYSQL的疫苗接种信息管理系统
  9. IntelliJ IDEA 2018.2.2及以下版本破解方法
  10. adams怎么做往复运动_关于HiFi | 在家里听音乐看电影,喇叭应该怎么选?
  11. 省级刊物发表有什么要求?需注意什么事项?
  12. Could not load NIB in bundle: 'NSBundle /Users/wyd/Library/Application Support/iPhone Simulator/5.0
  13. 100部超级好电影,100组优秀的字体设计(不看后悔系列)
  14. 有哪些植树的优美句子 值得一起收藏的植树节手抄报or海报素材?
  15. 《全面软件质量管理》核心观点摘录
  16. ROS只使用思岚A1激光雷达进行slam建图
  17. 首届 RustCon Asia 圆满落幕——Love is electricity for RustCon Asia
  18. 学习记录 --【零基础CSS学习】03.ID选择器和类选择器
  19. HCIE(第四天总结)---iStack、 CSS 、Eth-Trunk、 M-LAG
  20. K-means与高斯混合模型

热门文章

  1. VirtualBox 删除虚拟机
  2. Kubernetes哪一点最打动你?或者,它发布过的哪一项特性让你认为最厉害?
  3. 大数据高频面试题总结
  4. 跨癌症模型模拟免疫细胞行为
  5. Unity 打包项目发红
  6. 行为识别 - TAM: Temporal Adaptive Module for Video Recognition
  7. CSS把图片设置为背景
  8. uni-app H5实现扫码登录功能
  9. 直播开发软件平台搭建需要重点解决这一技术
  10. 我是如何投资数字货币的(1.2版)