Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
e7e3eaf7
T
three.js
项目概览
车家大少爷
/
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,发现更多精彩内容 >>
提交
e7e3eaf7
编写于
5月 27, 2019
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
JSM: Added module and TS file for ParametricGeometries.
上级
ac1321d0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
303 addition
and
0 deletion
+303
-0
docs/manual/en/introduction/Import-via-modules.html
docs/manual/en/introduction/Import-via-modules.html
+1
-0
examples/jsm/geometries/ParametricGeometries.d.ts
examples/jsm/geometries/ParametricGeometries.d.ts
+27
-0
examples/jsm/geometries/ParametricGeometries.js
examples/jsm/geometries/ParametricGeometries.js
+274
-0
utils/modularize.js
utils/modularize.js
+1
-0
未找到文件。
docs/manual/en/introduction/Import-via-modules.html
浏览文件 @
e7e3eaf7
...
...
@@ -127,6 +127,7 @@
<li>
geometries
<ul>
<li>
BoxLineGeometry
</li>
<li>
ParametricGeometries
</li>
</ul>
</li>
<li>
loaders
...
...
examples/jsm/geometries/ParametricGeometries.d.ts
0 → 100644
浏览文件 @
e7e3eaf7
import
{
Curve
,
Vector3
}
from
'
../../../src/Three
'
;
export
namespace
ParametricGeometries
{
export
function
klein
(
v
:
number
,
u
:
number
,
target
:
Vector3
):
Vector3
;
export
function
plane
(
width
:
number
,
height
:
number
,
target
:
Vector3
):
Vector3
;
export
function
mobius
(
u
:
number
,
t
:
number
,
target
:
Vector3
):
Vector3
;
export
function
mobius3d
(
u
:
number
,
t
:
number
,
target
:
Vector3
):
Vector3
;
export
class
TubeGeometry
{
constructor
(
path
:
Curve
<
Vector3
>
,
segments
?:
number
,
radius
?:
number
,
segmentsRadius
?:
number
,
closed
?:
boolean
,
debug
?:
boolean
);
}
export
class
TorusKnotGeometry
{
constructor
(
radius
?:
number
,
tube
?:
number
,
segmentsT
?:
number
,
segmentsR
?:
number
,
p
?:
number
,
q
?:
number
);
}
export
class
SphereGeometry
{
constructor
(
size
:
number
,
u
:
number
,
v
):
number
;
}
export
class
PlaneGeometry
{
constructor
(
width
:
number
,
depth
:
number
,
segmentsWidth
:
number
,
segmentsDepth
:
number
);
}
}
examples/jsm/geometries/ParametricGeometries.js
0 → 100644
浏览文件 @
e7e3eaf7
/*
* @author zz85
*
* Experimenting of primitive geometry creation using Surface Parametric equations
*
*/
import
{
ArrowHelper
,
Curve
,
Geometry
,
Object3D
,
ParametricGeometry
,
Vector3
}
from
"
../../../build/three.module.js
"
;
var
ParametricGeometries
=
{
klein
:
function
(
v
,
u
,
target
)
{
u
*=
Math
.
PI
;
v
*=
2
*
Math
.
PI
;
u
=
u
*
2
;
var
x
,
y
,
z
;
if
(
u
<
Math
.
PI
)
{
x
=
3
*
Math
.
cos
(
u
)
*
(
1
+
Math
.
sin
(
u
)
)
+
(
2
*
(
1
-
Math
.
cos
(
u
)
/
2
)
)
*
Math
.
cos
(
u
)
*
Math
.
cos
(
v
);
z
=
-
8
*
Math
.
sin
(
u
)
-
2
*
(
1
-
Math
.
cos
(
u
)
/
2
)
*
Math
.
sin
(
u
)
*
Math
.
cos
(
v
);
}
else
{
x
=
3
*
Math
.
cos
(
u
)
*
(
1
+
Math
.
sin
(
u
)
)
+
(
2
*
(
1
-
Math
.
cos
(
u
)
/
2
)
)
*
Math
.
cos
(
v
+
Math
.
PI
);
z
=
-
8
*
Math
.
sin
(
u
);
}
y
=
-
2
*
(
1
-
Math
.
cos
(
u
)
/
2
)
*
Math
.
sin
(
v
);
target
.
set
(
x
,
y
,
z
);
},
plane
:
function
(
width
,
height
)
{
return
function
(
u
,
v
,
target
)
{
var
x
=
u
*
width
;
var
y
=
0
;
var
z
=
v
*
height
;
target
.
set
(
x
,
y
,
z
);
};
},
mobius
:
function
(
u
,
t
,
target
)
{
// flat mobius strip
// http://www.wolframalpha.com/input/?i=M%C3%B6bius+strip+parametric+equations&lk=1&a=ClashPrefs_*Surface.MoebiusStrip.SurfaceProperty.ParametricEquations-
u
=
u
-
0.5
;
var
v
=
2
*
Math
.
PI
*
t
;
var
x
,
y
,
z
;
var
a
=
2
;
x
=
Math
.
cos
(
v
)
*
(
a
+
u
*
Math
.
cos
(
v
/
2
)
);
y
=
Math
.
sin
(
v
)
*
(
a
+
u
*
Math
.
cos
(
v
/
2
)
);
z
=
u
*
Math
.
sin
(
v
/
2
);
target
.
set
(
x
,
y
,
z
);
},
mobius3d
:
function
(
u
,
t
,
target
)
{
// volumetric mobius strip
u
*=
Math
.
PI
;
t
*=
2
*
Math
.
PI
;
u
=
u
*
2
;
var
phi
=
u
/
2
;
var
major
=
2.25
,
a
=
0.125
,
b
=
0.65
;
var
x
,
y
,
z
;
x
=
a
*
Math
.
cos
(
t
)
*
Math
.
cos
(
phi
)
-
b
*
Math
.
sin
(
t
)
*
Math
.
sin
(
phi
);
z
=
a
*
Math
.
cos
(
t
)
*
Math
.
sin
(
phi
)
+
b
*
Math
.
sin
(
t
)
*
Math
.
cos
(
phi
);
y
=
(
major
+
x
)
*
Math
.
sin
(
u
);
x
=
(
major
+
x
)
*
Math
.
cos
(
u
);
target
.
set
(
x
,
y
,
z
);
}
};
/*********************************************
*
* Parametric Replacement for TubeGeometry
*
*********************************************/
ParametricGeometries
.
TubeGeometry
=
function
(
path
,
segments
,
radius
,
segmentsRadius
,
closed
,
debug
)
{
this
.
path
=
path
;
this
.
segments
=
segments
||
64
;
this
.
radius
=
radius
||
1
;
this
.
segmentsRadius
=
segmentsRadius
||
8
;
this
.
closed
=
closed
||
false
;
if
(
debug
)
this
.
debug
=
new
Object3D
();
var
scope
=
this
,
numpoints
=
this
.
segments
+
1
;
var
frames
=
path
.
computeFrenetFrames
(
segments
,
closed
),
tangents
=
frames
.
tangents
,
normals
=
frames
.
normals
,
binormals
=
frames
.
binormals
;
// proxy internals
this
.
tangents
=
tangents
;
this
.
normals
=
normals
;
this
.
binormals
=
binormals
;
var
ParametricTube
=
function
(
u
,
v
,
target
)
{
v
*=
2
*
Math
.
PI
;
var
i
=
u
*
(
numpoints
-
1
);
i
=
Math
.
floor
(
i
);
var
pos
=
path
.
getPointAt
(
u
);
var
tangent
=
tangents
[
i
];
var
normal
=
normals
[
i
];
var
binormal
=
binormals
[
i
];
if
(
scope
.
debug
)
{
scope
.
debug
.
add
(
new
ArrowHelper
(
tangent
,
pos
,
radius
,
0x0000ff
)
);
scope
.
debug
.
add
(
new
ArrowHelper
(
normal
,
pos
,
radius
,
0xff0000
)
);
scope
.
debug
.
add
(
new
ArrowHelper
(
binormal
,
pos
,
radius
,
0x00ff00
)
);
}
var
cx
=
-
scope
.
radius
*
Math
.
cos
(
v
);
// TODO: Hack: Negating it so it faces outside.
var
cy
=
scope
.
radius
*
Math
.
sin
(
v
);
pos
.
x
+=
cx
*
normal
.
x
+
cy
*
binormal
.
x
;
pos
.
y
+=
cx
*
normal
.
y
+
cy
*
binormal
.
y
;
pos
.
z
+=
cx
*
normal
.
z
+
cy
*
binormal
.
z
;
target
.
copy
(
pos
);
};
ParametricGeometry
.
call
(
this
,
ParametricTube
,
segments
,
segmentsRadius
);
};
ParametricGeometries
.
TubeGeometry
.
prototype
=
Object
.
create
(
Geometry
.
prototype
);
ParametricGeometries
.
TubeGeometry
.
prototype
.
constructor
=
ParametricGeometries
.
TubeGeometry
;
/*********************************************
*
* Parametric Replacement for TorusKnotGeometry
*
*********************************************/
ParametricGeometries
.
TorusKnotGeometry
=
function
(
radius
,
tube
,
segmentsT
,
segmentsR
,
p
,
q
)
{
this
.
radius
=
radius
||
200
;
this
.
tube
=
tube
||
40
;
this
.
segmentsT
=
segmentsT
||
64
;
this
.
segmentsR
=
segmentsR
||
8
;
this
.
p
=
p
||
2
;
this
.
q
=
q
||
3
;
function
TorusKnotCurve
()
{
Curve
.
call
(
this
);
}
TorusKnotCurve
.
prototype
=
Object
.
create
(
Curve
.
prototype
);
TorusKnotCurve
.
prototype
.
constructor
=
TorusKnotCurve
;
TorusKnotCurve
.
prototype
.
getPoint
=
function
(
t
,
optionalTarget
)
{
var
point
=
optionalTarget
||
new
Vector3
();
t
*=
Math
.
PI
*
2
;
var
r
=
0.5
;
var
x
=
(
1
+
r
*
Math
.
cos
(
q
*
t
)
)
*
Math
.
cos
(
p
*
t
);
var
y
=
(
1
+
r
*
Math
.
cos
(
q
*
t
)
)
*
Math
.
sin
(
p
*
t
);
var
z
=
r
*
Math
.
sin
(
q
*
t
);
return
point
.
set
(
x
,
y
,
z
).
multiplyScalar
(
radius
);
};
var
segments
=
segmentsT
;
var
radiusSegments
=
segmentsR
;
var
extrudePath
=
new
TorusKnotCurve
();
ParametricGeometries
.
TubeGeometry
.
call
(
this
,
extrudePath
,
segments
,
tube
,
radiusSegments
,
true
,
false
);
};
ParametricGeometries
.
TorusKnotGeometry
.
prototype
=
Object
.
create
(
Geometry
.
prototype
);
ParametricGeometries
.
TorusKnotGeometry
.
prototype
.
constructor
=
ParametricGeometries
.
TorusKnotGeometry
;
/*********************************************
*
* Parametric Replacement for SphereGeometry
*
*********************************************/
ParametricGeometries
.
SphereGeometry
=
function
(
size
,
u
,
v
)
{
function
sphere
(
u
,
v
,
target
)
{
u
*=
Math
.
PI
;
v
*=
2
*
Math
.
PI
;
var
x
=
size
*
Math
.
sin
(
u
)
*
Math
.
cos
(
v
);
var
y
=
size
*
Math
.
sin
(
u
)
*
Math
.
sin
(
v
);
var
z
=
size
*
Math
.
cos
(
u
);
target
.
set
(
x
,
y
,
z
);
}
ParametricGeometry
.
call
(
this
,
sphere
,
u
,
v
);
};
ParametricGeometries
.
SphereGeometry
.
prototype
=
Object
.
create
(
Geometry
.
prototype
);
ParametricGeometries
.
SphereGeometry
.
prototype
.
constructor
=
ParametricGeometries
.
SphereGeometry
;
/*********************************************
*
* Parametric Replacement for PlaneGeometry
*
*********************************************/
ParametricGeometries
.
PlaneGeometry
=
function
(
width
,
depth
,
segmentsWidth
,
segmentsDepth
)
{
function
plane
(
u
,
v
,
target
)
{
var
x
=
u
*
width
;
var
y
=
0
;
var
z
=
v
*
depth
;
target
.
set
(
x
,
y
,
z
);
}
ParametricGeometry
.
call
(
this
,
plane
,
segmentsWidth
,
segmentsDepth
);
};
ParametricGeometries
.
PlaneGeometry
.
prototype
=
Object
.
create
(
Geometry
.
prototype
);
ParametricGeometries
.
PlaneGeometry
.
prototype
.
constructor
=
ParametricGeometries
.
PlaneGeometry
;
export
{
ParametricGeometries
};
utils/modularize.js
浏览文件 @
e7e3eaf7
...
...
@@ -43,6 +43,7 @@ var files = [
{
path
:
'
exporters/TypedGeometryExporter.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
{
path
:
'
geometries/BoxLineGeometry.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
{
path
:
'
geometries/ParametricGeometries.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
{
path
:
'
loaders/3MFLoader.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
{
path
:
'
loaders/AMFLoader.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录