Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
53ba0f1f
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,发现更多精彩内容 >>
提交
53ba0f1f
编写于
9月 15, 2013
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Yet more code clean up.
上级
f9cfc5f6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
26 deletion
+28
-26
examples/js/Mirror.js
examples/js/Mirror.js
+21
-11
src/core/BufferGeometry.js
src/core/BufferGeometry.js
+7
-15
未找到文件。
examples/js/Mirror.js
浏览文件 @
53ba0f1f
...
...
@@ -54,6 +54,7 @@ THREE.ShaderLib['mirror'] = {
THREE
.
Mirror
=
function
(
renderer
,
camera
,
options
)
{
THREE
.
Object3D
.
call
(
this
);
this
.
name
=
'
mirror_
'
+
this
.
id
;
function
isPowerOfTwo
(
value
)
{
...
...
@@ -82,7 +83,9 @@ THREE.Mirror = function ( renderer, camera, options ) {
// For debug only, show the normal and plane of the mirror
var
debugMode
=
options
.
debugMode
!==
undefined
?
options
.
debugMode
:
false
;
if
(
debugMode
){
if
(
debugMode
)
{
var
arrow
=
new
THREE
.
ArrowHelper
(
new
THREE
.
Vector3
(
0
,
0
,
1
),
new
THREE
.
Vector3
(
0
,
0
,
0
),
10
,
0xffff80
);
var
planeGeometry
=
new
THREE
.
Geometry
();
planeGeometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
-
10
,
-
10
,
0
)
);
...
...
@@ -94,13 +97,18 @@ THREE.Mirror = function ( renderer, camera, options ) {
this
.
add
(
arrow
);
this
.
add
(
plane
);
}
if
(
camera
instanceof
THREE
.
PerspectiveCamera
)
if
(
camera
instanceof
THREE
.
PerspectiveCamera
)
{
this
.
camera
=
camera
;
else
{
}
else
{
this
.
camera
=
new
THREE
.
PerspectiveCamera
();
console
.
log
(
this
.
name
+
'
: camera is not a Perspective Camera!
'
)
console
.
log
(
this
.
name
+
'
: camera is not a Perspective Camera!
'
);
}
this
.
textureMatrix
=
new
THREE
.
Matrix4
();
...
...
@@ -114,16 +122,18 @@ THREE.Mirror = function ( renderer, camera, options ) {
var
mirrorUniforms
=
THREE
.
UniformsUtils
.
clone
(
mirrorShader
.
uniforms
);
this
.
material
=
new
THREE
.
ShaderMaterial
(
{
fragmentShader
:
mirrorShader
.
fragmentShader
,
vertexShader
:
mirrorShader
.
vertexShader
,
uniforms
:
mirrorUniforms
}
);
this
.
material
.
uniforms
.
mirrorSampler
.
value
=
this
.
texture
;
this
.
material
.
uniforms
.
mirrorColor
.
value
=
mirrorColor
;
this
.
material
.
uniforms
.
textureMatrix
.
value
=
this
.
textureMatrix
;
if
(
!
isPowerOfTwo
(
width
)
||
!
isPowerOfTwo
(
height
)
)
{
if
(
!
isPowerOfTwo
(
width
)
||
!
isPowerOfTwo
(
height
)
)
{
this
.
texture
.
generateMipmaps
=
false
;
this
.
tempTexture
.
generateMipmaps
=
false
;
...
...
@@ -137,7 +147,7 @@ THREE.Mirror = function ( renderer, camera, options ) {
THREE
.
Mirror
.
prototype
=
Object
.
create
(
THREE
.
Object3D
.
prototype
);
THREE
.
Mirror
.
prototype
.
renderWithMirror
=
function
(
otherMirror
)
{
THREE
.
Mirror
.
prototype
.
renderWithMirror
=
function
(
otherMirror
)
{
// update the mirror matrix to mirror the current view
this
.
updateTextureMatrix
();
...
...
@@ -165,7 +175,7 @@ THREE.Mirror.prototype.renderWithMirror = function (otherMirror) {
THREE
.
Mirror
.
prototype
.
updateTextureMatrix
=
function
()
{
function
sign
(
x
)
{
return
x
?
x
<
0
?
-
1
:
1
:
0
;
}
var
sign
=
THREE
.
Math
.
sign
;
this
.
updateMatrixWorld
();
this
.
camera
.
updateMatrixWorld
();
...
...
@@ -222,10 +232,10 @@ THREE.Mirror.prototype.updateTextureMatrix = function () {
var
q
=
new
THREE
.
Vector4
();
var
projectionMatrix
=
this
.
mirrorCamera
.
projectionMatrix
;
q
.
x
=
(
sign
(
this
.
clipPlane
.
x
)
+
projectionMatrix
.
elements
[
8
]
)
/
projectionMatrix
.
elements
[
0
];
q
.
y
=
(
sign
(
this
.
clipPlane
.
y
)
+
projectionMatrix
.
elements
[
9
]
)
/
projectionMatrix
.
elements
[
5
];
q
.
z
=
-
1.0
;
q
.
w
=
(
1.0
+
projectionMatrix
.
elements
[
10
]
)
/
projectionMatrix
.
elements
[
14
];
q
.
x
=
(
sign
(
this
.
clipPlane
.
x
)
+
projectionMatrix
.
elements
[
8
]
)
/
projectionMatrix
.
elements
[
0
];
q
.
y
=
(
sign
(
this
.
clipPlane
.
y
)
+
projectionMatrix
.
elements
[
9
]
)
/
projectionMatrix
.
elements
[
5
];
q
.
z
=
-
1.0
;
q
.
w
=
(
1.0
+
projectionMatrix
.
elements
[
10
]
)
/
projectionMatrix
.
elements
[
14
];
// Calculate the scaled plane vector
var
c
=
new
THREE
.
Vector4
();
...
...
src/core/BufferGeometry.js
浏览文件 @
53ba0f1f
...
...
@@ -554,7 +554,7 @@ THREE.BufferGeometry.prototype = {
},
clone
:
function
()
{
clone
:
function
()
{
var
geometry
=
new
THREE
.
BufferGeometry
();
...
...
@@ -562,12 +562,10 @@ THREE.BufferGeometry.prototype = {
for
(
var
attr
in
this
.
attributes
)
{
var
attribute
,
sourceAttr
,
sourceArray
;
var
sourceAttr
=
this
.
attributes
[
attr
];
var
sourceArray
=
sourceAttr
.
array
;
sourceAttr
=
this
.
attributes
[
attr
];
sourceArray
=
sourceAttr
.
array
;
attribute
=
{
var
attribute
=
{
itemSize
:
sourceAttr
.
itemSize
,
numItems
:
sourceAttr
.
numItems
,
...
...
@@ -581,19 +579,13 @@ THREE.BufferGeometry.prototype = {
if
(
sourceArray
instanceof
type
)
{
attribute
s
.
array
=
new
type
(
sourceArray
.
length
);
attribute
.
array
=
new
type
(
sourceArray
);
break
;
}
}
for
(
var
i
=
0
,
il
=
sourceAttr
.
numItems
;
i
<
il
;
i
++
)
{
attribute
.
array
[
i
]
=
sourceArray
[
i
];
}
geometry
.
attributes
[
attr
]
=
attribute
;
}
...
...
@@ -602,13 +594,13 @@ THREE.BufferGeometry.prototype = {
var
offset
=
this
.
offsets
[
i
];
geometry
.
offsets
.
push
({
geometry
.
offsets
.
push
(
{
start
:
offset
.
start
,
index
:
offset
.
index
,
count
:
offset
.
count
});
}
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录