Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
db1e452e
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,发现更多精彩内容 >>
提交
db1e452e
编写于
12月 03, 2012
作者:
B
Ben Houston
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
initial implementation of Ray3.
上级
78cf6775
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
151 addition
and
0 deletion
+151
-0
src/core/Ray3.js
src/core/Ray3.js
+150
-0
utils/includes/common.json
utils/includes/common.json
+1
-0
未找到文件。
src/core/Ray3.js
0 → 100644
浏览文件 @
db1e452e
/**
* @author bhouston / http://exocortex.com
*/
THREE
.
Ray3
=
function
(
origin
,
direction
)
{
if
(
origin
===
undefined
&&
direction
===
undefined
)
{
this
.
origin
=
new
THREE
.
Vector3
();
this
.
direction
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
}
else
{
this
.
origin
=
origin
.
clone
();
this
.
direction
=
direction
.
clone
();
}
};
THREE
.
Ray3
.
prototype
=
{
constructor
:
THREE
.
Ray3
,
set
:
function
(
origin
,
direction
)
{
this
.
origin
.
copy
(
origin
);
this
.
direction
.
copy
(
direction
);
return
this
;
},
copy
:
function
(
ray
)
{
this
.
origin
.
copy
(
ray
.
origin
);
this
.
direction
.
copy
(
ray
.
direction
);
return
this
;
},
at
:
function
(
t
)
{
return
this
.
direction
.
clone
().
multiplyScalar
(
t
).
addSelf
(
this
.
origin
);
},
recast
:
function
(
t
)
{
return
new
THREE
.
Ray3
(
this
.
at
(
t
),
this
.
direction
);
},
closestPointToPoint
:
function
(
point
)
{
var
result
=
point
.
clone
().
subSelf
(
this
.
origin
);
var
directionDistance
=
result
.
dot
(
this
.
direction
);
return
result
.
copy
(
this
.
direction
).
multiplyScalar
(
directionDistance
).
addSelf
(
this
.
origin
);
},
distanceToPoint
:
function
(
point
)
{
// NOTE: this creates a THREE.VEctor3 internally via closestPointToPoint
// that is never returned, can be further GC optimized
return
this
.
closestPointToPoint
(
point
).
distanceTo
(
point
);
},
closestPointToRay
:
function
(
ray
)
{
// Assumes the lines are normalized
// based on algorithm in ILM's Imath Plane class.
__v1
.
copy
(
this
.
origin
).
subSelf
(
ray
.
origin
);
var
c
=
this
.
direction
.
dot
(
__v1
);
var
a
=
ray
.
direction
.
dot
(
this
.
direction
);
var
f
=
ray
.
direction
.
dot
(
__v1
);
var
num
=
c
-
a
*
f
;
var
denom
=
a
*
a
-
1
;
var
absDenom
=
(
(
denom
>=
0
)
?
denom
:
-
denom
);
if
(
absDenom
<
1
)
{
var
absNum
=
(
(
num
>=
0
)
?
num
:
-
num
);
if
(
absNum
>=
absDenom
*
Number
.
MAX_VALUE
)
{
return
this
.
origin
.
clone
();
}
}
return
this
.
direction
.
clone
().
multipleScalar
(
num
/
denom
).
addSelf
(
this
.
origin
);
},
distanceToRay
:
function
(
ray
)
{
__v1
.
copy
(
this
.
direction
).
crossSelf
(
ray
.
direction
);
__v2
.
copy
(
ray
.
origin
).
subSelf
(
this
.
origin
);
var
d
=
__v1
.
dot
(
__v2
);
if
(
d
>=
0
)
{
return
d
;
}
return
-
1
;
},
isIntersectionPlane
:
function
(
plane
)
{
return
(
plane
.
normal
.
dot
(
this
.
direction
)
!=
0
);
},
intersectPlane
:
function
(
plane
)
{
var
a
=
plane
.
normal
.
dot
(
this
.
direction
);
if
(
a
==
0.0
)
{
// Unsure if this is the correct method to handle this case.
return
undefined
;
}
var
t
=
-
(
(
this
.
origin
^
plane
.
normal
)
-
plane
.
constant
)
/
a
;
return
this
.
at
(
t
);
},
equals
:
function
(
ray
)
{
return
ray
.
origin
.
equals
(
this
.
origin
)
&&
ray
.
direction
.
equals
(
this
.
direction
);
},
clone
:
function
()
{
return
new
THREE
.
Ray3
().
copy
(
this
);
}
};
THREE
.
Ray3
.
__v1
=
new
THREE
.
Vector3
();
THREE
.
Ray3
.
__v2
=
new
THREE
.
Vector3
();
\ No newline at end of file
utils/includes/common.json
浏览文件 @
db1e452e
...
...
@@ -9,6 +9,7 @@
"../src/core/Box3.js"
,
"../src/core/Matrix3.js"
,
"../src/core/Matrix4.js"
,
"../src/core/Ray3.js"
,
"../src/core/EventTarget.js"
,
"../src/core/Frustum.js"
,
"../src/core/Plane.js"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录