Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
1fd80171
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,发现更多精彩内容 >>
提交
1fd80171
编写于
4月 05, 2011
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added option to have flat shading for renderBufferImmediate.
上级
5c943cab
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
453 addition
and
405 deletion
+453
-405
build/Three.js
build/Three.js
+231
-231
build/custom/ThreeWebGL.js
build/custom/ThreeWebGL.js
+158
-158
examples/webgl_collisions_box.html
examples/webgl_collisions_box.html
+10
-6
src/physics/Collisions.js
src/physics/Collisions.js
+7
-7
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+47
-3
未找到文件。
build/Three.js
浏览文件 @
1fd80171
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
build/custom/ThreeWebGL.js
浏览文件 @
1fd80171
此差异已折叠。
点击以展开。
examples/webgl_collisions_box.html
浏览文件 @
1fd80171
<html>
<head>
<title>
three
j.
s webgl - intersection: ray with box
</title>
<title>
three
.j
s webgl - intersection: ray with box
</title>
<meta
http-equiv=
"content-type"
content=
"text/html; charset=utf-8"
>
<style
type=
"text/css"
>
...
...
@@ -72,29 +71,34 @@ function init() {
sun
.
position
=
camera
.
position
.
clone
();
scene
.
addLight
(
sun
);
createCube
(
200
,
new
THREE
.
Vector3
(
0
,
0
,
0
)
);
createCube
(
200
,
new
THREE
.
Vector3
(
0
,
0
,
0
)
);
container
.
onmousemove
=
onDocumentMouseMove
;
animate
();
}
function
createCube
(
s
,
p
)
{
function
createCube
(
s
,
p
)
{
cube
=
new
THREE
.
Mesh
(
new
Cube
(
s
,
s
,
s
,
1
,
1
,
1
),
new
Cube
(
s
,
s
,
s
,
1
,
1
,
1
),
new
THREE
.
MeshLambertMaterial
(
{
color
:
0x003300
})
);
cube
.
position
=
p
;
scene
.
addObject
(
cube
);
THREE
.
Collisions
.
colliders
.
push
(
THREE
.
CollisionUtils
.
MeshOBB
(
cube
)
);
THREE
.
Collisions
.
colliders
.
push
(
THREE
.
CollisionUtils
.
MeshOBB
(
cube
)
);
}
function
onDocumentMouseMove
(
event
)
{
event
.
preventDefault
();
mouse2d
.
x
=
(
event
.
clientX
/
window
.
innerWidth
)
*
2
-
1
;
mouse2d
.
y
=
-
(
event
.
clientY
/
window
.
innerHeight
)
*
2
+
1
;
mouse2d
.
z
=
1
;
}
function
animate
()
{
...
...
src/physics/Collisions.js
浏览文件 @
1fd80171
...
...
@@ -2,19 +2,19 @@
* @author drojdjou / http://everyday3d.com/
*/
THREE
.
PlaneCollider
=
function
(
p
t
,
nor
)
{
THREE
.
PlaneCollider
=
function
(
p
oint
,
normal
)
{
this
.
point
=
pt
;
this
.
normal
=
nor
;
this
.
point
=
p
oin
t
;
this
.
normal
=
nor
mal
;
};
THREE
.
SphereCollider
=
function
(
cen
,
rad
)
{
THREE
.
SphereCollider
=
function
(
cen
ter
,
radius
)
{
this
.
center
=
cen
;
this
.
radius
=
rad
;
this
.
radiusSq
=
rad
*
rad
;
this
.
center
=
cen
ter
;
this
.
radius
=
rad
ius
;
this
.
radiusSq
=
rad
ius
*
radius
;
};
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
1fd80171
...
...
@@ -2606,7 +2606,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
function
renderBufferImmediate
(
object
,
program
)
{
function
renderBufferImmediate
(
object
,
program
,
shading
)
{
if
(
!
object
.
__webglVertexBuffer
)
object
.
__webglVertexBuffer
=
_gl
.
createBuffer
();
if
(
!
object
.
__webglNormalBuffer
)
object
.
__webglNormalBuffer
=
_gl
.
createBuffer
();
...
...
@@ -2623,6 +2623,50 @@ THREE.WebGLRenderer = function ( parameters ) {
if
(
object
.
hasNormal
)
{
_gl
.
bindBuffer
(
_gl
.
ARRAY_BUFFER
,
object
.
__webglNormalBuffer
);
if
(
shading
==
THREE
.
FlatShading
)
{
var
nx
,
ny
,
nz
,
nax
,
nbx
,
ncx
,
nay
,
nby
,
ncy
,
naz
,
nbz
,
ncz
,
normalArray
,
i
,
il
=
object
.
count
*
3
;
for
(
i
=
0
;
i
<
il
;
i
+=
9
)
{
normalArray
=
object
.
normalArray
;
nax
=
normalArray
[
i
];
nay
=
normalArray
[
i
+
1
];
naz
=
normalArray
[
i
+
2
];
nbx
=
normalArray
[
i
+
3
];
nby
=
normalArray
[
i
+
4
];
nbz
=
normalArray
[
i
+
5
];
ncx
=
normalArray
[
i
+
6
];
ncy
=
normalArray
[
i
+
7
];
ncz
=
normalArray
[
i
+
8
];
nx
=
(
nax
+
nbx
+
ncx
)
/
3
;
ny
=
(
nay
+
nby
+
ncy
)
/
3
;
nz
=
(
naz
+
nbz
+
ncz
)
/
3
;
normalArray
[
i
]
=
nx
;
normalArray
[
i
+
1
]
=
ny
;
normalArray
[
i
+
2
]
=
nz
;
normalArray
[
i
+
3
]
=
nx
;
normalArray
[
i
+
4
]
=
ny
;
normalArray
[
i
+
5
]
=
nz
;
normalArray
[
i
+
6
]
=
nx
;
normalArray
[
i
+
7
]
=
ny
;
normalArray
[
i
+
8
]
=
nz
;
}
}
_gl
.
bufferData
(
_gl
.
ARRAY_BUFFER
,
object
.
normalArray
,
_gl
.
DYNAMIC_DRAW
);
_gl
.
enableVertexAttribArray
(
program
.
attributes
.
normal
);
_gl
.
vertexAttribPointer
(
program
.
attributes
.
normal
,
3
,
_gl
.
FLOAT
,
false
,
0
,
0
);
...
...
@@ -2944,7 +2988,7 @@ THREE.WebGLRenderer = function ( parameters ) {
setDepthTest
(
material
.
depthTest
);
program
=
setProgram
(
camera
,
lights
,
fog
,
material
,
object
);
object
.
render
(
function
(
object
)
{
renderBufferImmediate
(
object
,
program
);
}
);
object
.
render
(
function
(
object
)
{
renderBufferImmediate
(
object
,
program
,
material
.
shading
);
}
);
}
...
...
@@ -3002,7 +3046,7 @@ THREE.WebGLRenderer = function ( parameters ) {
setDepthTest
(
material
.
depthTest
);
program
=
setProgram
(
camera
,
lights
,
fog
,
material
,
object
);
object
.
render
(
function
(
object
)
{
renderBufferImmediate
(
object
,
program
);
}
);
object
.
render
(
function
(
object
)
{
renderBufferImmediate
(
object
,
program
,
material
.
shading
);
}
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录