Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
644d350e
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,发现更多精彩内容 >>
提交
644d350e
编写于
5月 23, 2018
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ParametricGeometry: Fix examples
上级
f36c9c59
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
31 deletion
+30
-31
examples/js/Cloth.js
examples/js/Cloth.js
+14
-10
examples/js/curves/NURBSSurface.js
examples/js/curves/NURBSSurface.js
+2
-4
examples/js/curves/NURBSUtils.js
examples/js/curves/NURBSUtils.js
+11
-14
examples/webgl_geometry_nurbs.html
examples/webgl_geometry_nurbs.html
+3
-3
未找到文件。
examples/js/Cloth.js
浏览文件 @
644d350e
...
...
@@ -46,15 +46,13 @@ var lastTime;
function
plane
(
width
,
height
)
{
return
function
(
u
,
v
,
optionalTarget
)
{
var
result
=
optionalTarget
||
new
THREE
.
Vector3
();
return
function
(
u
,
v
,
target
)
{
var
x
=
(
u
-
0.5
)
*
width
;
var
y
=
(
v
+
0.5
)
*
height
;
var
z
=
0
;
return
resul
t
.
set
(
x
,
y
,
z
);
return
targe
t
.
set
(
x
,
y
,
z
);
};
...
...
@@ -62,20 +60,26 @@ function plane( width, height ) {
function
Particle
(
x
,
y
,
z
,
mass
)
{
this
.
position
=
clothFunction
(
x
,
y
);
// position
this
.
previous
=
clothFunction
(
x
,
y
);
// previous
this
.
original
=
clothFunction
(
x
,
y
);
this
.
position
=
new
THREE
.
Vector3
();
this
.
previous
=
new
THREE
.
Vector3
();
this
.
original
=
new
THREE
.
Vector3
(
);
this
.
a
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
// acceleration
this
.
mass
=
mass
;
this
.
invMass
=
1
/
mass
;
this
.
tmp
=
new
THREE
.
Vector3
();
this
.
tmp2
=
new
THREE
.
Vector3
();
// init
clothFunction
(
x
,
y
,
this
.
position
);
// position
clothFunction
(
x
,
y
,
this
.
previous
);
// previous
clothFunction
(
x
,
y
,
this
.
original
);
}
// Force -> Acceleration
Particle
.
prototype
.
addForce
=
function
(
force
)
{
Particle
.
prototype
.
addForce
=
function
(
force
)
{
this
.
a
.
add
(
this
.
tmp2
.
copy
(
force
).
multiplyScalar
(
this
.
invMass
)
...
...
@@ -86,7 +90,7 @@ Particle.prototype.addForce = function( force ) {
// Performs Verlet integration
Particle
.
prototype
.
integrate
=
function
(
timesq
)
{
Particle
.
prototype
.
integrate
=
function
(
timesq
)
{
var
newPos
=
this
.
tmp
.
subVectors
(
this
.
position
,
this
.
previous
);
newPos
.
multiplyScalar
(
DRAG
).
add
(
this
.
position
);
...
...
@@ -280,7 +284,7 @@ function simulate( time ) {
// Ball Constraints
ballPosition
.
z
=
-
Math
.
sin
(
Date
.
now
()
/
600
)
*
90
;
//+ 40;
ballPosition
.
z
=
-
Math
.
sin
(
Date
.
now
()
/
600
)
*
90
;
//+ 40;
ballPosition
.
x
=
Math
.
cos
(
Date
.
now
()
/
400
)
*
70
;
if
(
sphere
.
visible
)
{
...
...
examples/js/curves/NURBSSurface.js
浏览文件 @
644d350e
...
...
@@ -42,14 +42,12 @@ THREE.NURBSSurface.prototype = {
constructor
:
THREE
.
NURBSSurface
,
getPoint
:
function
(
t1
,
t2
)
{
getPoint
:
function
(
t1
,
t2
,
target
)
{
var
u
=
this
.
knots1
[
0
]
+
t1
*
(
this
.
knots1
[
this
.
knots1
.
length
-
1
]
-
this
.
knots1
[
0
]
);
// linear mapping t1->u
var
v
=
this
.
knots2
[
0
]
+
t2
*
(
this
.
knots2
[
this
.
knots2
.
length
-
1
]
-
this
.
knots2
[
0
]
);
// linear mapping t2->u
return
THREE
.
NURBSUtils
.
calcSurfacePoint
(
this
.
degree1
,
this
.
degree2
,
this
.
knots1
,
this
.
knots2
,
this
.
controlPoints
,
u
,
v
);
return
THREE
.
NURBSUtils
.
calcSurfacePoint
(
this
.
degree1
,
this
.
degree2
,
this
.
knots1
,
this
.
knots2
,
this
.
controlPoints
,
u
,
v
,
target
);
}
};
examples/js/curves/NURBSUtils.js
浏览文件 @
644d350e
...
...
@@ -19,7 +19,7 @@ THREE.NURBSUtils = {
p : degree
u : parametric value
U : knot vector
returns the span
*/
findSpan
:
function
(
p
,
u
,
U
)
{
...
...
@@ -43,7 +43,7 @@ THREE.NURBSUtils = {
var
mid
=
Math
.
floor
(
(
low
+
high
)
/
2
);
while
(
u
<
U
[
mid
]
||
u
>=
U
[
mid
+
1
]
)
{
if
(
u
<
U
[
mid
]
)
{
high
=
mid
;
...
...
@@ -61,16 +61,16 @@ THREE.NURBSUtils = {
return
mid
;
},
/*
Calculate basis functions. See The NURBS Book, page 70, algorithm A2.2
span : span in which u lies
u : parametric point
p : degree
U : knot vector
returns array[p+1] with basis functions values.
*/
calcBasisFunctions
:
function
(
span
,
u
,
p
,
U
)
{
...
...
@@ -81,7 +81,7 @@ THREE.NURBSUtils = {
N
[
0
]
=
1.0
;
for
(
var
j
=
1
;
j
<=
p
;
++
j
)
{
left
[
j
]
=
u
-
U
[
span
+
1
-
j
];
right
[
j
]
=
U
[
span
+
j
]
-
u
;
...
...
@@ -108,7 +108,7 @@ THREE.NURBSUtils = {
/*
Calculate B-Spline curve points. See The NURBS Book, page 82, algorithm A3.1.
p : degree of B-Spline
U : knot vector
P : control points (x, y, z, w)
...
...
@@ -422,7 +422,7 @@ THREE.NURBSUtils = {
/*
Calculate rational B-Spline surface point. See The NURBS Book, page 134, algorithm A4.3.
p1, p2 : degrees of B-Spline surface
U1, U2 : knot vectors
P : control points (x, y, z, w)
...
...
@@ -430,7 +430,7 @@ THREE.NURBSUtils = {
returns point for given (u, v)
*/
calcSurfacePoint
:
function
(
p
,
q
,
U
,
V
,
P
,
u
,
v
)
{
calcSurfacePoint
:
function
(
p
,
q
,
U
,
V
,
P
,
u
,
v
,
target
)
{
var
uspan
=
this
.
findSpan
(
p
,
u
,
U
);
var
vspan
=
this
.
findSpan
(
q
,
v
,
V
);
...
...
@@ -462,11 +462,8 @@ THREE.NURBSUtils = {
}
Sw
.
divideScalar
(
Sw
.
w
);
return
new
THREE
.
Vector3
(
Sw
.
x
,
Sw
.
y
,
Sw
.
z
);
return
target
.
set
(
Sw
.
x
,
Sw
.
y
,
Sw
.
z
);
}
};
examples/webgl_geometry_nurbs.html
浏览文件 @
644d350e
...
...
@@ -68,7 +68,7 @@
scene
=
new
THREE
.
Scene
();
scene
.
background
=
new
THREE
.
Color
(
0xf0f0f0
);
scene
.
add
(
new
THREE
.
AmbientLight
(
0x808080
)
);
var
light
=
new
THREE
.
DirectionalLight
(
0xffffff
,
1
);
...
...
@@ -159,9 +159,9 @@
map
.
wrapS
=
map
.
wrapT
=
THREE
.
RepeatWrapping
;
map
.
anisotropy
=
16
;
function
getSurfacePoint
(
u
,
v
)
{
function
getSurfacePoint
(
u
,
v
,
target
)
{
return
nurbsSurface
.
getPoint
(
u
,
v
);
return
nurbsSurface
.
getPoint
(
u
,
v
,
target
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录