Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
9ad6e544
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,发现更多精彩内容 >>
提交
9ad6e544
编写于
6月 08, 2012
作者:
Z
zz85
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixes for dot operations in SimplexNoise. #1993
上级
0832354c
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
17 addition
and
9 deletion
+17
-9
examples/js/SimplexNoise.js
examples/js/SimplexNoise.js
+17
-9
未找到文件。
examples/js/SimplexNoise.js
浏览文件 @
9ad6e544
...
...
@@ -53,6 +53,14 @@ SimplexNoise.prototype.dot = function(g, x, y) {
return
g
[
0
]
*
x
+
g
[
1
]
*
y
;
};
SimplexNoise
.
prototype
.
dot3
=
function
(
g
,
x
,
y
,
z
)
{
return
g
[
0
]
*
x
+
g
[
1
]
*
y
+
g
[
2
]
*
z
;
}
SimplexNoise
.
prototype
.
dot4
=
function
(
g
,
x
,
y
,
z
,
w
)
{
return
g
[
0
]
*
x
+
g
[
1
]
*
y
+
g
[
2
]
*
z
+
g
[
3
]
*
w
;
};
SimplexNoise
.
prototype
.
noise
=
function
(
xin
,
yin
)
{
var
n0
,
n1
,
n2
;
// Noise contributions from the three corners
// Skew the input space to determine which simplex cell we're in
...
...
@@ -166,25 +174,25 @@ SimplexNoise.prototype.noise3d = function(xin, yin, zin) {
if
(
t0
<
0
)
n0
=
0.0
;
else
{
t0
*=
t0
;
n0
=
t0
*
t0
*
this
.
dot
(
this
.
grad3
[
gi0
],
x0
,
y0
,
z0
);
n0
=
t0
*
t0
*
this
.
dot
3
(
this
.
grad3
[
gi0
],
x0
,
y0
,
z0
);
}
var
t1
=
0.6
-
x1
*
x1
-
y1
*
y1
-
z1
*
z1
;
if
(
t1
<
0
)
n1
=
0.0
;
else
{
t1
*=
t1
;
n1
=
t1
*
t1
*
this
.
dot
(
this
.
grad3
[
gi1
],
x1
,
y1
,
z1
);
n1
=
t1
*
t1
*
this
.
dot
3
(
this
.
grad3
[
gi1
],
x1
,
y1
,
z1
);
}
var
t2
=
0.6
-
x2
*
x2
-
y2
*
y2
-
z2
*
z2
;
if
(
t2
<
0
)
n2
=
0.0
;
else
{
t2
*=
t2
;
n2
=
t2
*
t2
*
this
.
dot
(
this
.
grad3
[
gi2
],
x2
,
y2
,
z2
);
n2
=
t2
*
t2
*
this
.
dot
3
(
this
.
grad3
[
gi2
],
x2
,
y2
,
z2
);
}
var
t3
=
0.6
-
x3
*
x3
-
y3
*
y3
-
z3
*
z3
;
if
(
t3
<
0
)
n3
=
0.0
;
else
{
t3
*=
t3
;
n3
=
t3
*
t3
*
this
.
dot
(
this
.
grad3
[
gi3
],
x3
,
y3
,
z3
);
n3
=
t3
*
t3
*
this
.
dot
3
(
this
.
grad3
[
gi3
],
x3
,
y3
,
z3
);
}
// Add contributions from each corner to get the final noise value.
// The result is scaled to stay just inside [-1,1]
...
...
@@ -286,30 +294,30 @@ SimplexNoise.prototype.noise4d = function( x, y, z, w ) {
if
(
t0
<
0
)
n0
=
0.0
;
else
{
t0
*=
t0
;
n0
=
t0
*
t0
*
this
.
dot
(
grad4
[
gi0
],
x0
,
y0
,
z0
,
w0
);
n0
=
t0
*
t0
*
this
.
dot
4
(
grad4
[
gi0
],
x0
,
y0
,
z0
,
w0
);
}
var
t1
=
0.6
-
x1
*
x1
-
y1
*
y1
-
z1
*
z1
-
w1
*
w1
;
if
(
t1
<
0
)
n1
=
0.0
;
else
{
t1
*=
t1
;
n1
=
t1
*
t1
*
this
.
dot
(
grad4
[
gi1
],
x1
,
y1
,
z1
,
w1
);
n1
=
t1
*
t1
*
this
.
dot
4
(
grad4
[
gi1
],
x1
,
y1
,
z1
,
w1
);
}
var
t2
=
0.6
-
x2
*
x2
-
y2
*
y2
-
z2
*
z2
-
w2
*
w2
;
if
(
t2
<
0
)
n2
=
0.0
;
else
{
t2
*=
t2
;
n2
=
t2
*
t2
*
this
.
dot
(
grad4
[
gi2
],
x2
,
y2
,
z2
,
w2
);
n2
=
t2
*
t2
*
this
.
dot
4
(
grad4
[
gi2
],
x2
,
y2
,
z2
,
w2
);
}
var
t3
=
0.6
-
x3
*
x3
-
y3
*
y3
-
z3
*
z3
-
w3
*
w3
;
if
(
t3
<
0
)
n3
=
0.0
;
else
{
t3
*=
t3
;
n3
=
t3
*
t3
*
this
.
dot
(
grad4
[
gi3
],
x3
,
y3
,
z3
,
w3
);
n3
=
t3
*
t3
*
this
.
dot
4
(
grad4
[
gi3
],
x3
,
y3
,
z3
,
w3
);
}
var
t4
=
0.6
-
x4
*
x4
-
y4
*
y4
-
z4
*
z4
-
w4
*
w4
;
if
(
t4
<
0
)
n4
=
0.0
;
else
{
t4
*=
t4
;
n4
=
t4
*
t4
*
this
.
dot
(
grad4
[
gi4
],
x4
,
y4
,
z4
,
w4
);
n4
=
t4
*
t4
*
this
.
dot
4
(
grad4
[
gi4
],
x4
,
y4
,
z4
,
w4
);
}
// Sum up and scale the result to cover the range [-1,1]
return
27.0
*
(
n0
+
n1
+
n2
+
n3
+
n4
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录