线圆示例(Line Circle)
线圆示例(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)相关推荐
- OpenCV示例学习(二): 基本图形绘制算子:line(),circle(),fillPoly(), ellipse()
OpenCV示例学习(二): 基本图形绘制算子:line(),circle(),fillPoly(), ellipse() #include <opencv2/opencv.hpp>usi ...
- Openlayers 根据坐标点画点线圆多边形
根据坐标点画点线圆多边形,代码如下 Geometry type Point LineString Polygon Circle None Bezier 绘制 绘制圆形 绘制线段 绘制多边形 绘制单 ...
- python根据坐标点画线_Openlayers 根据坐标点画点线圆多边形
根据坐标点画点线圆多边形,代码如下 Geometry type Point LineString Polygon Circle None Bezier 绘制 绘制圆形 绘制线段 绘制多边形 绘制单个点 ...
- python使用matplotlib可视化线图(line plot)、移除可视化结果的所有坐标轴信息(remove all axis in matplotlib graph)
python使用matplotlib可视化线图(line plot).移除可视化结果的所有坐标轴信息(remove all axis in matplotlib graph) 目录
- 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) 目 ...
- python使用matplotlib可视化线图(line plot)、在可视化图像中的指定位置添加横线(add horizontal line in matplotlib plot)
python使用matplotlib可视化线图(line plot).在可视化图像中的指定位置添加横线(add horizontal line in matplotlib plot) 目录
- python使用matplotlib可视化线图(line plot)、将可视化图像的图例(legend)放置在图像外部、底部区域
python使用matplotlib可视化线图(line plot).将可视化图像的图例(legend)放置在图像外部.底部区域(put legend outside and in bottom re ...
- python使用matplotlib可视化线图(line plot)、并自定义线条的粗细(线条的宽度、 line width in Matplotlib)
python使用matplotlib可视化线图(line plot).并自定义线条的粗细(线条的宽度. line width in Matplotlib) 目录
- 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) 目录
最新文章
- SSI注入(server side includes injection 服务器端包含注入)
- 笔记-知识产权与标准化知识-软件质量模型(重)
- 军转干部计算机测试题,2015福建军转干考试计算机基础知识:计算机网络
- python(22)--面向对象1-封装
- python爬虫知识大全_Python爬虫入门有哪些基础知识点
- JavaScript返回上一页代码区别
- linux 驱动线程与进程,Linux内核学习之二-进程与线程
- 基于JAVA+SpringBoot+Mybatis+MYSQL的疫苗接种信息管理系统
- IntelliJ IDEA 2018.2.2及以下版本破解方法
- adams怎么做往复运动_关于HiFi | 在家里听音乐看电影,喇叭应该怎么选?
- 省级刊物发表有什么要求?需注意什么事项?
- Could not load NIB in bundle: 'NSBundle /Users/wyd/Library/Application Support/iPhone Simulator/5.0
- 100部超级好电影,100组优秀的字体设计(不看后悔系列)
- 有哪些植树的优美句子 值得一起收藏的植树节手抄报or海报素材?
- 《全面软件质量管理》核心观点摘录
- ROS只使用思岚A1激光雷达进行slam建图
- 首届 RustCon Asia 圆满落幕——Love is electricity for RustCon Asia
- 学习记录 --【零基础CSS学习】03.ID选择器和类选择器
- HCIE(第四天总结)---iStack、 CSS 、Eth-Trunk、 M-LAG
- K-means与高斯混合模型