Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
d30c3703
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,发现更多精彩内容 >>
提交
d30c3703
编写于
7月 15, 2013
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Code clean up and now using inv* pattern.
上级
9949be37
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
65 addition
and
50 deletion
+65
-50
src/core/Projector.js
src/core/Projector.js
+10
-6
src/math/Matrix4.js
src/math/Matrix4.js
+13
-9
src/math/Ray.js
src/math/Ray.js
+9
-10
src/math/Vector2.js
src/math/Vector2.js
+8
-5
src/math/Vector3.js
src/math/Vector3.js
+11
-9
src/math/Vector4.js
src/math/Vector4.js
+14
-11
未找到文件。
src/core/Projector.js
浏览文件 @
d30c3703
...
...
@@ -199,9 +199,11 @@ THREE.Projector = function () {
_vertex
.
positionWorld
.
copy
(
vertices
[
v
]
).
applyMatrix4
(
_modelMatrix
);
_vertex
.
positionScreen
.
copy
(
_vertex
.
positionWorld
).
applyMatrix4
(
_viewProjectionMatrix
);
_vertex
.
positionScreen
.
x
/=
_vertex
.
positionScreen
.
w
;
_vertex
.
positionScreen
.
y
/=
_vertex
.
positionScreen
.
w
;
_vertex
.
positionScreen
.
z
/=
_vertex
.
positionScreen
.
w
;
var
invW
=
1
/
_vertex
.
positionScreen
.
w
;
_vertex
.
positionScreen
.
x
*=
invW
;
_vertex
.
positionScreen
.
y
*=
invW
;
_vertex
.
positionScreen
.
z
*=
invW
;
_vertex
.
visible
=
!
(
_vertex
.
positionScreen
.
x
<
-
1
||
_vertex
.
positionScreen
.
x
>
1
||
_vertex
.
positionScreen
.
y
<
-
1
||
_vertex
.
positionScreen
.
y
>
1
||
...
...
@@ -432,14 +434,16 @@ THREE.Projector = function () {
_vector4
.
set
(
_modelMatrix
.
elements
[
12
],
_modelMatrix
.
elements
[
13
],
_modelMatrix
.
elements
[
14
],
1
);
_vector4
.
applyMatrix4
(
_viewProjectionMatrix
);
_vector4
.
z
/=
_vector4
.
w
;
var
invW
=
1
/
_vector4
.
w
;
_vector4
.
z
*=
invW
;
if
(
_vector4
.
z
>
0
&&
_vector4
.
z
<
1
)
{
_particle
=
getNextParticleInPool
();
_particle
.
id
=
object
.
id
;
_particle
.
x
=
_vector4
.
x
/
_vector4
.
w
;
_particle
.
y
=
_vector4
.
y
/
_vector4
.
w
;
_particle
.
x
=
_vector4
.
x
*
invW
;
_particle
.
y
=
_vector4
.
y
*
invW
;
_particle
.
z
=
_vector4
.
z
;
_particle
.
object
=
object
;
...
...
src/math/Matrix4.js
浏览文件 @
d30c3703
...
...
@@ -847,17 +847,21 @@ THREE.Matrix4.prototype = {
matrix
.
elements
.
set
(
this
.
elements
);
// at this point matrix is incomplete so we can't use .copy()
matrix
.
elements
[
0
]
/=
sx
;
matrix
.
elements
[
1
]
/=
sx
;
matrix
.
elements
[
2
]
/=
sx
;
var
invSX
=
1
/
sx
;
var
invSY
=
1
/
sy
;
var
invSZ
=
1
/
sz
;
matrix
.
elements
[
4
]
/=
sy
;
matrix
.
elements
[
5
]
/=
sy
;
matrix
.
elements
[
6
]
/=
sy
;
matrix
.
elements
[
0
]
*=
invSX
;
matrix
.
elements
[
1
]
*=
invSX
;
matrix
.
elements
[
2
]
*=
invSX
;
matrix
.
elements
[
8
]
/=
sz
;
matrix
.
elements
[
9
]
/=
sz
;
matrix
.
elements
[
10
]
/=
sz
;
matrix
.
elements
[
4
]
*=
invSY
;
matrix
.
elements
[
5
]
*=
invSY
;
matrix
.
elements
[
6
]
*=
invSY
;
matrix
.
elements
[
8
]
*=
invSZ
;
matrix
.
elements
[
9
]
*=
invSZ
;
matrix
.
elements
[
10
]
*=
invSZ
;
quaternion
.
setFromRotationMatrix
(
matrix
);
...
...
src/math/Ray.js
浏览文件 @
d30c3703
...
...
@@ -112,7 +112,8 @@ THREE.Ray.prototype = {
var
c
=
diff
.
lengthSq
();
var
det
=
Math
.
abs
(
1
-
a01
*
a01
);
var
s0
,
s1
,
sqrDist
,
extDet
;
if
(
det
>=
0
)
{
if
(
det
>=
0
)
{
// The ray and segment are not parallel.
...
...
@@ -120,11 +121,11 @@ THREE.Ray.prototype = {
s1
=
a01
*
b0
-
b1
;
extDet
=
segExtent
*
det
;
if
(
s0
>=
0
)
{
if
(
s0
>=
0
)
{
if
(
s1
>=
-
extDet
)
{
if
(
s1
>=
-
extDet
)
{
if
(
s1
<=
extDet
)
{
if
(
s1
<=
extDet
)
{
// region 0
// Minimum at interior points of ray and segment.
...
...
@@ -144,9 +145,7 @@ THREE.Ray.prototype = {
}
}
else
{
}
else
{
// region 5
...
...
@@ -166,7 +165,7 @@ THREE.Ray.prototype = {
s1
=
(
s0
>
0
)
?
-
segExtent
:
Math
.
min
(
Math
.
max
(
-
segExtent
,
-
b1
),
segExtent
);
sqrDist
=
-
s0
*
s0
+
s1
*
(
s1
+
2
*
b1
)
+
c
;
}
else
if
(
s1
<=
extDet
)
{
}
else
if
(
s1
<=
extDet
)
{
// region 3
...
...
@@ -174,7 +173,7 @@ THREE.Ray.prototype = {
s1
=
Math
.
min
(
Math
.
max
(
-
segExtent
,
-
b1
),
segExtent
);
sqrDist
=
s1
*
(
s1
+
2
*
b1
)
+
c
;
}
else
{
}
else
{
// region 2
...
...
@@ -186,7 +185,7 @@ THREE.Ray.prototype = {
}
}
else
{
}
else
{
// Ray and segment are parallel.
...
...
src/math/Vector2.js
浏览文件 @
d30c3703
...
...
@@ -143,16 +143,19 @@ THREE.Vector2.prototype = {
},
divideScalar
:
function
(
s
)
{
divideScalar
:
function
(
s
calar
)
{
if
(
s
!==
0
)
{
if
(
s
calar
!==
0
)
{
this
.
x
/=
s
;
this
.
y
/=
s
;
var
invScalar
=
1
/
scalar
;
this
.
x
*=
invScalar
;
this
.
y
*=
invScalar
;
}
else
{
this
.
set
(
0
,
0
);
this
.
x
=
0
;
this
.
y
=
0
;
}
...
...
src/math/Vector3.js
浏览文件 @
d30c3703
...
...
@@ -170,11 +170,11 @@ THREE.Vector3.prototype = {
},
multiplyScalar
:
function
(
s
)
{
multiplyScalar
:
function
(
s
calar
)
{
this
.
x
*=
s
;
this
.
y
*=
s
;
this
.
z
*=
s
;
this
.
x
*=
s
calar
;
this
.
y
*=
s
calar
;
this
.
z
*=
s
calar
;
return
this
;
...
...
@@ -296,13 +296,15 @@ THREE.Vector3.prototype = {
},
divideScalar
:
function
(
s
)
{
divideScalar
:
function
(
s
calar
)
{
if
(
s
!==
0
)
{
if
(
s
calar
!==
0
)
{
this
.
x
/=
s
;
this
.
y
/=
s
;
this
.
z
/=
s
;
var
invScalar
=
1
/
scalar
;
this
.
x
*=
invScalar
;
this
.
y
*=
invScalar
;
this
.
z
*=
invScalar
;
}
else
{
...
...
src/math/Vector4.js
浏览文件 @
d30c3703
...
...
@@ -170,12 +170,12 @@ THREE.Vector4.prototype = {
},
multiplyScalar
:
function
(
s
)
{
multiplyScalar
:
function
(
s
calar
)
{
this
.
x
*=
s
;
this
.
y
*=
s
;
this
.
z
*=
s
;
this
.
w
*=
s
;
this
.
x
*=
s
calar
;
this
.
y
*=
s
calar
;
this
.
z
*=
s
calar
;
this
.
w
*=
s
calar
;
return
this
;
...
...
@@ -199,14 +199,16 @@ THREE.Vector4.prototype = {
},
divideScalar
:
function
(
s
)
{
divideScalar
:
function
(
s
calar
)
{
if
(
s
!==
0
)
{
if
(
s
calar
!==
0
)
{
this
.
x
/=
s
;
this
.
y
/=
s
;
this
.
z
/=
s
;
this
.
w
/=
s
;
var
invScalar
=
1
/
scalar
;
this
.
x
*=
invScalar
;
this
.
y
*=
invScalar
;
this
.
z
*=
invScalar
;
this
.
w
*=
invScalar
;
}
else
{
...
...
@@ -524,6 +526,7 @@ THREE.Vector4.prototype = {
if
(
oldLength
!==
0
&&
l
!==
oldLength
)
{
this
.
multiplyScalar
(
l
/
oldLength
);
}
return
this
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录