最終效果:
將其他1/8圓補全即可。
export
default
class
spheregeometry
extends
three.buffergeometry
this
.indices =
this
.rs1 =
this
.parameters.radiussegments +
1this
.cornervertnumber =
this
.rs1 *
this
.parameters.radiussegments +
1this
.lastvertex =
this
.rs1 *
this
.parameters.radiussegments
this
.totalvertexcount =
(this
.rs1 *
this
.parameters.radiussegments +1)
<<3;
let positions =
newthree.bufferattribute
(new
float32array
(this
.totalvertexcount *3)
,3);
this
.vertexpool =
// [0~-90],[90~180],[180~270],[270~360]
this
.getver()
this
.docorners(0
)this
.getver()
this
.docorners(1
)this
.getver()
this
.docorners(2
)this
.getver()
this
.docorners(3
)this
.getver()
this
.docorners(4
)this
.getver()
this
.docorners(5
)this
.getver()
this
.docorners(6
)this
.getver()
this
.docorners(7
)// this.vertexpool = vertexpool
for(
var i =
0; i <
this
.vertexpool.length; i++
)this
.setindex
(new
three.bufferattribute
(new
uint16array
(this
.indices),1
));this
.setattribute
('position'
, positions);}
docorners
(i)=
this
.parameters
const
=this
var corneroffset =
this
.cornervertnumber * i;
var lastrowoffset = rs1 *
( radiussegments -1)
;// 每次迴圈產生一行的頂點索引
for(
var v =
0; v < radiussegments -
1; v++)}
// 最後最上面一行的三角形
for(
var u =
0; u < radiussegments; u++)}
getver()
=this
.parameters
var pihalf = math.pi/
2;let=
this
// 每次迴圈產生一行的頂點
for(
var y =
0; y <= radiussegments; y++
)// 每次迴圈產生乙個頂點
for(
var x =
0; x <= radiussegments; x++)}
return vertexpool
}}
PyQGisCookbook 幾何體處理 八
如果您在pyqgis控制台之外,則此以下 段需要以下匯入 from qgis.core import qgsgeometry,qgspoint,qgspointxy,qgswkbtypes,qgsproject,qgsfeaturerequest,qgsdistancearea 表示空間要素的點,線...
osg中幾何體繪製筆記(一)
1 複雜的場景都是由少數的基本圖元構成。我們可以通過構建簡單的圖元來實現複雜場景。2 osg中定義了純基類drawable作為幾何圖元的基類。從drawable派生出9個類,其中比較重要的為geometry和shapedrawable。geometry用來繪製幾何體,使用比較靈活,而shapedra...
three幾何體旋轉 平移 縮放變換
建立網格模型 var geometry new three.boxgeometry 100,100,100 建立乙個立方體幾何物件geometry 幾何體xyz三個方向都放大2倍 geometry.scale 2,2,2 幾何體沿著x軸平移50 geometry.translate 50,0,0 幾...