Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
00f2725c
T
three.js
项目概览
Ablesons
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
00f2725c
编写于
11月 22, 2020
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Geometries: Implemented es6 default parameters.
上级
94db93d9
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
33 addition
and
92 deletion
+33
-92
src/geometries/CircleBufferGeometry.js
src/geometries/CircleBufferGeometry.js
+2
-6
src/geometries/ConeBufferGeometry.js
src/geometries/ConeBufferGeometry.js
+2
-1
src/geometries/CylinderBufferGeometry.js
src/geometries/CylinderBufferGeometry.js
+3
-11
src/geometries/DodecahedronBufferGeometry.js
src/geometries/DodecahedronBufferGeometry.js
+1
-1
src/geometries/IcosahedronBufferGeometry.js
src/geometries/IcosahedronBufferGeometry.js
+1
-1
src/geometries/LatheBufferGeometry.js
src/geometries/LatheBufferGeometry.js
+2
-5
src/geometries/OctahedronBufferGeometry.js
src/geometries/OctahedronBufferGeometry.js
+1
-1
src/geometries/PlaneBufferGeometry.js
src/geometries/PlaneBufferGeometry.js
+4
-16
src/geometries/PolyhedronBufferGeometry.js
src/geometries/PolyhedronBufferGeometry.js
+1
-4
src/geometries/RingBufferGeometry.js
src/geometries/RingBufferGeometry.js
+3
-9
src/geometries/ShapeBufferGeometry.js
src/geometries/ShapeBufferGeometry.js
+1
-3
src/geometries/SphereBufferGeometry.js
src/geometries/SphereBufferGeometry.js
+3
-11
src/geometries/TetrahedronBufferGeometry.js
src/geometries/TetrahedronBufferGeometry.js
+1
-1
src/geometries/TextBufferGeometry.js
src/geometries/TextBufferGeometry.js
+1
-3
src/geometries/TorusBufferGeometry.js
src/geometries/TorusBufferGeometry.js
+3
-6
src/geometries/TorusKnotBufferGeometry.js
src/geometries/TorusKnotBufferGeometry.js
+3
-7
src/geometries/TubeBufferGeometry.js
src/geometries/TubeBufferGeometry.js
+1
-6
未找到文件。
src/geometries/CircleBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -5,7 +5,7 @@ import { Vector2 } from '../math/Vector2.js';
class
CircleBufferGeometry
extends
BufferGeometry
{
constructor
(
radius
,
segments
,
thetaStart
,
thetaLength
)
{
constructor
(
radius
=
1
,
segments
=
8
,
thetaStart
=
0
,
thetaLength
=
Math
.
PI
*
2
)
{
super
();
...
...
@@ -18,11 +18,7 @@ class CircleBufferGeometry extends BufferGeometry {
thetaLength
:
thetaLength
};
radius
=
radius
||
1
;
segments
=
segments
!==
undefined
?
Math
.
max
(
3
,
segments
)
:
8
;
thetaStart
=
thetaStart
!==
undefined
?
thetaStart
:
0
;
thetaLength
=
thetaLength
!==
undefined
?
thetaLength
:
Math
.
PI
*
2
;
segments
=
Math
.
max
(
3
,
segments
);
// buffers
...
...
src/geometries/ConeBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -2,9 +2,10 @@ import { CylinderBufferGeometry } from './CylinderBufferGeometry.js';
class
ConeBufferGeometry
extends
CylinderBufferGeometry
{
constructor
(
radius
,
height
,
radialSegments
,
heightSegments
,
openEnded
,
thetaStart
,
thetaLength
)
{
constructor
(
radius
=
1
,
height
=
1
,
radialSegments
=
8
,
heightSegments
=
1
,
openEnded
=
false
,
thetaStart
=
0
,
thetaLength
=
Math
.
PI
*
2
)
{
super
(
0
,
radius
,
height
,
radialSegments
,
heightSegments
,
openEnded
,
thetaStart
,
thetaLength
);
this
.
type
=
'
ConeBufferGeometry
'
;
this
.
parameters
=
{
...
...
src/geometries/CylinderBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -5,7 +5,7 @@ import { Vector2 } from '../math/Vector2.js';
class
CylinderBufferGeometry
extends
BufferGeometry
{
constructor
(
radiusTop
,
radiusBottom
,
height
,
radialSegments
,
heightSegments
,
openEnded
,
thetaStart
,
thetaLength
)
{
constructor
(
radiusTop
=
1
,
radiusBottom
=
1
,
height
=
1
,
radialSegments
=
8
,
heightSegments
=
1
,
openEnded
=
false
,
thetaStart
=
0
,
thetaLength
=
Math
.
PI
*
2
)
{
super
();
this
.
type
=
'
CylinderBufferGeometry
'
;
...
...
@@ -23,16 +23,8 @@ class CylinderBufferGeometry extends BufferGeometry {
const
scope
=
this
;
radiusTop
=
radiusTop
!==
undefined
?
radiusTop
:
1
;
radiusBottom
=
radiusBottom
!==
undefined
?
radiusBottom
:
1
;
height
=
height
||
1
;
radialSegments
=
Math
.
floor
(
radialSegments
)
||
8
;
heightSegments
=
Math
.
floor
(
heightSegments
)
||
1
;
openEnded
=
openEnded
!==
undefined
?
openEnded
:
false
;
thetaStart
=
thetaStart
!==
undefined
?
thetaStart
:
0.0
;
thetaLength
=
thetaLength
!==
undefined
?
thetaLength
:
Math
.
PI
*
2
;
radialSegments
=
Math
.
floor
(
radialSegments
);
heightSegments
=
Math
.
floor
(
heightSegments
);
// buffers
...
...
src/geometries/DodecahedronBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -2,7 +2,7 @@ import { PolyhedronBufferGeometry } from './PolyhedronBufferGeometry.js';
class
DodecahedronBufferGeometry
extends
PolyhedronBufferGeometry
{
constructor
(
radius
,
detail
)
{
constructor
(
radius
=
1
,
detail
=
0
)
{
const
t
=
(
1
+
Math
.
sqrt
(
5
)
)
/
2
;
const
r
=
1
/
t
;
...
...
src/geometries/IcosahedronBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -2,7 +2,7 @@ import { PolyhedronBufferGeometry } from './PolyhedronBufferGeometry.js';
class
IcosahedronBufferGeometry
extends
PolyhedronBufferGeometry
{
constructor
(
radius
,
detail
)
{
constructor
(
radius
=
1
,
detail
=
0
)
{
const
t
=
(
1
+
Math
.
sqrt
(
5
)
)
/
2
;
...
...
src/geometries/LatheBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -6,7 +6,7 @@ import { MathUtils } from '../math/MathUtils.js';
class
LatheBufferGeometry
extends
BufferGeometry
{
constructor
(
points
,
segments
,
phiStart
,
phiLength
)
{
constructor
(
points
,
segments
=
12
,
phiStart
=
0
,
phiLength
=
Math
.
PI
*
2
)
{
super
();
...
...
@@ -19,15 +19,12 @@ class LatheBufferGeometry extends BufferGeometry {
phiLength
:
phiLength
};
segments
=
Math
.
floor
(
segments
)
||
12
;
phiStart
=
phiStart
||
0
;
phiLength
=
phiLength
||
Math
.
PI
*
2
;
segments
=
Math
.
floor
(
segments
);
// clamp phiLength so it's in range of [ 0, 2PI ]
phiLength
=
MathUtils
.
clamp
(
phiLength
,
0
,
Math
.
PI
*
2
);
// buffers
const
indices
=
[];
...
...
src/geometries/OctahedronBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -2,7 +2,7 @@ import { PolyhedronBufferGeometry } from './PolyhedronBufferGeometry.js';
class
OctahedronBufferGeometry
extends
PolyhedronBufferGeometry
{
constructor
(
radius
,
detail
)
{
constructor
(
radius
=
1
,
detail
=
0
)
{
const
vertices
=
[
1
,
0
,
0
,
-
1
,
0
,
0
,
0
,
1
,
0
,
...
...
src/geometries/PlaneBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -3,7 +3,7 @@ import { Float32BufferAttribute } from '../core/BufferAttribute.js';
class
PlaneBufferGeometry
extends
BufferGeometry
{
constructor
(
width
,
height
,
widthSegments
,
heightSegments
)
{
constructor
(
width
=
1
,
height
=
1
,
widthSegments
=
1
,
heightSegments
=
1
)
{
super
();
this
.
type
=
'
PlaneBufferGeometry
'
;
...
...
@@ -15,14 +15,11 @@ class PlaneBufferGeometry extends BufferGeometry {
heightSegments
:
heightSegments
};
width
=
width
||
1
;
height
=
height
||
1
;
const
width_half
=
width
/
2
;
const
height_half
=
height
/
2
;
const
gridX
=
Math
.
floor
(
widthSegments
)
||
1
;
const
gridY
=
Math
.
floor
(
heightSegments
)
||
1
;
const
gridX
=
Math
.
floor
(
widthSegments
);
const
gridY
=
Math
.
floor
(
heightSegments
);
const
gridX1
=
gridX
+
1
;
const
gridY1
=
gridY
+
1
;
...
...
@@ -30,15 +27,13 @@ class PlaneBufferGeometry extends BufferGeometry {
const
segment_width
=
width
/
gridX
;
const
segment_height
=
height
/
gridY
;
//
buffers
//
const
indices
=
[];
const
vertices
=
[];
const
normals
=
[];
const
uvs
=
[];
// generate vertices, normals and uvs
for
(
let
iy
=
0
;
iy
<
gridY1
;
iy
++
)
{
const
y
=
iy
*
segment_height
-
height_half
;
...
...
@@ -58,8 +53,6 @@ class PlaneBufferGeometry extends BufferGeometry {
}
// indices
for
(
let
iy
=
0
;
iy
<
gridY
;
iy
++
)
{
for
(
let
ix
=
0
;
ix
<
gridX
;
ix
++
)
{
...
...
@@ -69,8 +62,6 @@ class PlaneBufferGeometry extends BufferGeometry {
const
c
=
(
ix
+
1
)
+
gridX1
*
(
iy
+
1
);
const
d
=
(
ix
+
1
)
+
gridX1
*
iy
;
// faces
indices
.
push
(
a
,
b
,
d
);
indices
.
push
(
b
,
c
,
d
);
...
...
@@ -78,8 +69,6 @@ class PlaneBufferGeometry extends BufferGeometry {
}
// build geometry
this
.
setIndex
(
indices
);
this
.
setAttribute
(
'
position
'
,
new
Float32BufferAttribute
(
vertices
,
3
)
);
this
.
setAttribute
(
'
normal
'
,
new
Float32BufferAttribute
(
normals
,
3
)
);
...
...
@@ -89,5 +78,4 @@ class PlaneBufferGeometry extends BufferGeometry {
}
export
{
PlaneBufferGeometry
};
src/geometries/PolyhedronBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -5,7 +5,7 @@ import { Vector2 } from '../math/Vector2.js';
class
PolyhedronBufferGeometry
extends
BufferGeometry
{
constructor
(
vertices
,
indices
,
radius
,
detail
)
{
constructor
(
vertices
,
indices
,
radius
=
1
,
detail
=
0
)
{
super
();
...
...
@@ -18,9 +18,6 @@ class PolyhedronBufferGeometry extends BufferGeometry {
detail
:
detail
};
radius
=
radius
||
1
;
detail
=
detail
||
0
;
// default buffer data
const
vertexBuffer
=
[];
...
...
src/geometries/RingBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -5,7 +5,7 @@ import { Vector3 } from '../math/Vector3.js';
class
RingBufferGeometry
extends
BufferGeometry
{
constructor
(
innerRadius
,
outerRadius
,
thetaSegments
,
phiSegments
,
thetaStart
,
thetaLength
)
{
constructor
(
innerRadius
=
0.5
,
outerRadius
=
1
,
thetaSegments
=
8
,
phiSegments
=
1
,
thetaStart
=
0
,
thetaLength
=
Math
.
PI
*
2
)
{
super
();
...
...
@@ -20,14 +20,8 @@ class RingBufferGeometry extends BufferGeometry {
thetaLength
:
thetaLength
};
innerRadius
=
innerRadius
||
0.5
;
outerRadius
=
outerRadius
||
1
;
thetaStart
=
thetaStart
!==
undefined
?
thetaStart
:
0
;
thetaLength
=
thetaLength
!==
undefined
?
thetaLength
:
Math
.
PI
*
2
;
thetaSegments
=
thetaSegments
!==
undefined
?
Math
.
max
(
3
,
thetaSegments
)
:
8
;
phiSegments
=
phiSegments
!==
undefined
?
Math
.
max
(
1
,
phiSegments
)
:
1
;
thetaSegments
=
Math
.
max
(
3
,
thetaSegments
);
phiSegments
=
Math
.
max
(
1
,
phiSegments
);
// buffers
...
...
src/geometries/ShapeBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -4,7 +4,7 @@ import { ShapeUtils } from '../extras/ShapeUtils.js';
class
ShapeBufferGeometry
extends
BufferGeometry
{
constructor
(
shapes
,
curveSegments
)
{
constructor
(
shapes
,
curveSegments
=
12
)
{
super
();
this
.
type
=
'
ShapeBufferGeometry
'
;
...
...
@@ -14,8 +14,6 @@ class ShapeBufferGeometry extends BufferGeometry {
curveSegments
:
curveSegments
};
curveSegments
=
curveSegments
||
12
;
// buffers
const
indices
=
[];
...
...
src/geometries/SphereBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -4,7 +4,7 @@ import { Vector3 } from '../math/Vector3.js';
class
SphereBufferGeometry
extends
BufferGeometry
{
constructor
(
radius
,
widthSegments
,
heightSegments
,
phiStart
,
phiLength
,
thetaStart
,
thetaLength
)
{
constructor
(
radius
=
1
,
widthSegments
=
8
,
heightSegments
=
6
,
phiStart
=
0
,
phiLength
=
Math
.
PI
*
2
,
thetaStart
=
0
,
thetaLength
=
Math
.
PI
)
{
super
();
this
.
type
=
'
SphereBufferGeometry
'
;
...
...
@@ -19,16 +19,8 @@ class SphereBufferGeometry extends BufferGeometry {
thetaLength
:
thetaLength
};
radius
=
radius
||
1
;
widthSegments
=
Math
.
max
(
3
,
Math
.
floor
(
widthSegments
)
||
8
);
heightSegments
=
Math
.
max
(
2
,
Math
.
floor
(
heightSegments
)
||
6
);
phiStart
=
phiStart
!==
undefined
?
phiStart
:
0
;
phiLength
=
phiLength
!==
undefined
?
phiLength
:
Math
.
PI
*
2
;
thetaStart
=
thetaStart
!==
undefined
?
thetaStart
:
0
;
thetaLength
=
thetaLength
!==
undefined
?
thetaLength
:
Math
.
PI
;
widthSegments
=
Math
.
max
(
3
,
Math
.
floor
(
widthSegments
)
);
heightSegments
=
Math
.
max
(
2
,
Math
.
floor
(
heightSegments
)
);
const
thetaEnd
=
Math
.
min
(
thetaStart
+
thetaLength
,
Math
.
PI
);
...
...
src/geometries/TetrahedronBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -2,7 +2,7 @@ import { PolyhedronBufferGeometry } from './PolyhedronBufferGeometry.js';
class
TetrahedronBufferGeometry
extends
PolyhedronBufferGeometry
{
constructor
(
radius
,
detail
)
{
constructor
(
radius
=
1
,
detail
=
0
)
{
const
vertices
=
[
1
,
1
,
1
,
-
1
,
-
1
,
1
,
-
1
,
1
,
-
1
,
1
,
-
1
,
-
1
...
...
src/geometries/TextBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -20,9 +20,7 @@ import { ExtrudeBufferGeometry } from './ExtrudeBufferGeometry.js';
class
TextBufferGeometry
extends
ExtrudeBufferGeometry
{
constructor
(
text
,
parameters
)
{
parameters
=
parameters
||
{};
constructor
(
text
,
parameters
=
{}
)
{
const
font
=
parameters
.
font
;
...
...
src/geometries/TorusBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -4,7 +4,7 @@ import { Vector3 } from '../math/Vector3.js';
class
TorusBufferGeometry
extends
BufferGeometry
{
constructor
(
radius
,
tube
,
radialSegments
,
tubularSegments
,
arc
)
{
constructor
(
radius
=
1
,
tube
=
0.4
,
radialSegments
=
8
,
tubularSegments
=
6
,
arc
=
Math
.
PI
*
2
)
{
super
();
this
.
type
=
'
TorusBufferGeometry
'
;
...
...
@@ -17,11 +17,8 @@ class TorusBufferGeometry extends BufferGeometry {
arc
:
arc
};
radius
=
radius
||
1
;
tube
=
tube
||
0.4
;
radialSegments
=
Math
.
floor
(
radialSegments
)
||
8
;
tubularSegments
=
Math
.
floor
(
tubularSegments
)
||
6
;
arc
=
arc
||
Math
.
PI
*
2
;
radialSegments
=
Math
.
floor
(
radialSegments
);
tubularSegments
=
Math
.
floor
(
tubularSegments
);
// buffers
...
...
src/geometries/TorusKnotBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -4,7 +4,7 @@ import { Vector3 } from '../math/Vector3.js';
class
TorusKnotBufferGeometry
extends
BufferGeometry
{
constructor
(
radius
,
tube
,
tubularSegments
,
radialSegments
,
p
,
q
)
{
constructor
(
radius
=
1
,
tube
=
0.4
,
tubularSegments
=
64
,
radialSegments
=
8
,
p
=
2
,
q
=
3
)
{
super
();
this
.
type
=
'
TorusKnotBufferGeometry
'
;
...
...
@@ -18,12 +18,8 @@ class TorusKnotBufferGeometry extends BufferGeometry {
q
:
q
};
radius
=
radius
||
1
;
tube
=
tube
||
0.4
;
tubularSegments
=
Math
.
floor
(
tubularSegments
)
||
64
;
radialSegments
=
Math
.
floor
(
radialSegments
)
||
8
;
p
=
p
||
2
;
q
=
q
||
3
;
tubularSegments
=
Math
.
floor
(
tubularSegments
);
radialSegments
=
Math
.
floor
(
radialSegments
);
// buffers
...
...
src/geometries/TubeBufferGeometry.js
浏览文件 @
00f2725c
...
...
@@ -5,7 +5,7 @@ import { Vector3 } from '../math/Vector3.js';
class
TubeBufferGeometry
extends
BufferGeometry
{
constructor
(
path
,
tubularSegments
,
radius
,
radialSegments
,
closed
)
{
constructor
(
path
,
tubularSegments
=
64
,
radius
=
1
,
radialSegments
=
8
,
closed
=
false
)
{
super
();
this
.
type
=
'
TubeBufferGeometry
'
;
...
...
@@ -18,11 +18,6 @@ class TubeBufferGeometry extends BufferGeometry {
closed
:
closed
};
tubularSegments
=
tubularSegments
||
64
;
radius
=
radius
||
1
;
radialSegments
=
radialSegments
||
8
;
closed
=
closed
||
false
;
const
frames
=
path
.
computeFrenetFrames
(
tubularSegments
,
closed
);
// expose internals
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录