用 Three.js 画一个圆(没有阴影)

Draw a circle (not shaded) with Three.js(用 Three.js 画一个圆(没有阴影))
本文介绍了用 Three.js 画一个圆(没有阴影)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在尝试绘制一个与 this 网站上的轨道图案非常相似的圆圈.我想使用 Three.js 而不是纯 WebGL.

I am trying to draw a circle very similar to the orbital patterns on this website. I would like to use Three.js instead of pure WebGL.

推荐答案

Three.js r50 添加了CircleGeometry.在 WebGL 几何示例中可以看到它(尽管有一张脸).

Three.js r50 added CircleGeometry. It can be seen (albeit with a face) in the WebGL Geometries example.

几何中的第一个顶点创建在圆的中心(在 r84 中,请参阅 CircleGeometry.js 第 71 行,在 r65 中,请参阅 CircleGeometry.js 第 18 行),如果你想要完整的吃豆人"或无信息的饼图"外观,这很不错.哦,如果您要使用除 LineBasicMaterial/LineDashedMaterial 之外的任何材料,这似乎是必要的.

The first vertex in the geometry is created at the center of the circle (in r84, see CircleGeometry.js line 71, in r65, see CircleGeometry.js line 18), which is nifty if you are going for that "full Pac-Man" or "uninformative pie chart" look. Oh, and it appears to be necessary if you are going to use any material aside from LineBasicMaterial / LineDashedMaterial.

我已验证以下代码在 r60 和r65:

I've verified that the following code works in both r60 & r65:

var radius   = 100,
    segments = 64,
    material = new THREE.LineBasicMaterial( { color: 0x0000ff } ),
    geometry = new THREE.CircleGeometry( radius, segments );

// Remove center vertex
geometry.vertices.shift();

// Non closed circle with one open segment:
scene.add( new THREE.Line( geometry, material ) );

// To get a closed circle use LineLoop instead (see also @jackrugile his comment):
scene.add( new THREE.LineLoop( geometry, material ) );

PS:文档"现在包含一个不错的 CircleGeometry 交互式示例:https://threejs.org/docs/#api/geometries/CircleGeometry

PS: The "docs" now include a nice CircleGeometry interactive example: https://threejs.org/docs/#api/geometries/CircleGeometry

这篇关于用 Three.js 画一个圆(没有阴影)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How do I can get a text of all the cells of the table using testcafe(如何使用 testcafe 获取表格中所有单元格的文本)
node_modules is not recognized as an internal or external command(node_modules 未被识别为内部或外部命令)
How can I create conditional test cases using Protractor?(如何使用 Protractor 创建条件测试用例?)
PhantomJS and clicking a form button(PhantomJS 并单击表单按钮)
Clicking #39;OK#39; on alert or confirm dialog through jquery/javascript?(在警报上单击“确定或通过 jquery/javascript 确认对话框?)
QunitJS-Tests don#39;t start: PhantomJS timed out, possibly due to a missing QUnit start() call(QunitJS-Tests 不启动:PhantomJS 超时,可能是由于缺少 QUnit start() 调用)