Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
d330d5b6
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,发现更多精彩内容 >>
提交
d330d5b6
编写于
5月 08, 2016
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
*Camera: Implemented Object.assign(). See #8838.
上级
1c20a696
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
182 addition
and
182 deletion
+182
-182
src/cameras/OrthographicCamera.js
src/cameras/OrthographicCamera.js
+34
-31
src/cameras/PerspectiveCamera.js
src/cameras/PerspectiveCamera.js
+146
-147
src/cameras/StereoCamera.js
src/cameras/StereoCamera.js
+2
-4
未找到文件。
src/cameras/OrthographicCamera.js
浏览文件 @
d330d5b6
...
...
@@ -22,49 +22,52 @@ THREE.OrthographicCamera = function ( left, right, top, bottom, near, far ) {
};
THREE
.
OrthographicCamera
.
prototype
=
Object
.
create
(
THREE
.
Camera
.
prototype
);
THREE
.
OrthographicCamera
.
prototype
.
constructor
=
THREE
.
OrthographicCamera
;
THREE
.
OrthographicCamera
.
prototype
=
Object
.
assign
(
Object
.
create
(
THREE
.
Camera
.
prototype
),
{
THREE
.
OrthographicCamera
.
prototype
.
updateProjectionMatrix
=
function
()
{
constructor
:
THREE
.
OrthographicCamera
,
var
dx
=
(
this
.
right
-
this
.
left
)
/
(
2
*
this
.
zoom
);
var
dy
=
(
this
.
top
-
this
.
bottom
)
/
(
2
*
this
.
zoom
);
var
cx
=
(
this
.
right
+
this
.
left
)
/
2
;
var
cy
=
(
this
.
top
+
this
.
bottom
)
/
2
;
copy
:
function
(
source
)
{
this
.
projectionMatrix
.
makeOrthographic
(
cx
-
dx
,
cx
+
dx
,
cy
+
dy
,
cy
-
dy
,
this
.
near
,
this
.
far
);
THREE
.
Camera
.
prototype
.
copy
.
call
(
this
,
source
);
};
this
.
left
=
source
.
left
;
this
.
right
=
source
.
right
;
this
.
top
=
source
.
top
;
this
.
bottom
=
source
.
bottom
;
this
.
near
=
source
.
near
;
this
.
far
=
source
.
far
;
THREE
.
OrthographicCamera
.
prototype
.
copy
=
function
(
source
)
{
this
.
zoom
=
source
.
zoom
;
THREE
.
Camera
.
prototype
.
copy
.
call
(
this
,
source
)
;
return
this
;
this
.
left
=
source
.
left
;
this
.
right
=
source
.
right
;
this
.
top
=
source
.
top
;
this
.
bottom
=
source
.
bottom
;
this
.
near
=
source
.
near
;
this
.
far
=
source
.
far
;
},
this
.
zoom
=
source
.
zoom
;
updateProjectionMatrix
:
function
()
{
return
this
;
var
dx
=
(
this
.
right
-
this
.
left
)
/
(
2
*
this
.
zoom
);
var
dy
=
(
this
.
top
-
this
.
bottom
)
/
(
2
*
this
.
zoom
);
var
cx
=
(
this
.
right
+
this
.
left
)
/
2
;
var
cy
=
(
this
.
top
+
this
.
bottom
)
/
2
;
}
;
this
.
projectionMatrix
.
makeOrthographic
(
cx
-
dx
,
cx
+
dx
,
cy
+
dy
,
cy
-
dy
,
this
.
near
,
this
.
far
)
;
THREE
.
OrthographicCamera
.
prototype
.
toJSON
=
function
(
meta
)
{
},
var
data
=
THREE
.
Object3D
.
prototype
.
toJSON
.
call
(
this
,
meta
);
toJSON
:
function
(
meta
)
{
data
.
object
.
zoom
=
this
.
zoom
;
data
.
object
.
left
=
this
.
left
;
data
.
object
.
right
=
this
.
right
;
data
.
object
.
top
=
this
.
top
;
data
.
object
.
bottom
=
this
.
bottom
;
data
.
object
.
near
=
this
.
near
;
data
.
object
.
far
=
this
.
far
;
var
data
=
THREE
.
Object3D
.
prototype
.
toJSON
.
call
(
this
,
meta
);
return
data
;
data
.
object
.
zoom
=
this
.
zoom
;
data
.
object
.
left
=
this
.
left
;
data
.
object
.
right
=
this
.
right
;
data
.
object
.
top
=
this
.
top
;
data
.
object
.
bottom
=
this
.
bottom
;
data
.
object
.
near
=
this
.
near
;
data
.
object
.
far
=
this
.
far
;
};
return
data
;
}
}
);
src/cameras/PerspectiveCamera.js
浏览文件 @
d330d5b6
...
...
@@ -28,199 +28,198 @@ THREE.PerspectiveCamera = function( fov, aspect, near, far ) {
};
THREE
.
PerspectiveCamera
.
prototype
=
Object
.
create
(
THREE
.
Camera
.
prototype
);
THREE
.
PerspectiveCamera
.
prototype
.
constructor
=
THREE
.
PerspectiveCamera
;
THREE
.
PerspectiveCamera
.
prototype
=
Object
.
assign
(
Object
.
create
(
THREE
.
Camera
.
prototype
),
{
constructor
:
THREE
.
PerspectiveCamera
,
/**
* Sets the FOV by focal length (DEPRECATED).
*
* Optionally also sets .filmGauge, otherwise uses it. See .setFocalLength.
*/
THREE
.
PerspectiveCamera
.
prototype
.
setLens
=
function
(
focalLength
,
filmGauge
)
{
copy
:
function
(
source
)
{
console
.
warn
(
"
THREE.PerspectiveCamera.setLens is deprecated.
"
+
"
Use .setFocalLength and .filmGauge for a photographic setup.
"
);
THREE
.
Camera
.
prototype
.
copy
.
call
(
this
,
source
);
if
(
filmGauge
!==
undefined
)
this
.
filmGauge
=
filmGauge
;
this
.
setFocalLength
(
focalLength
)
;
this
.
fov
=
source
.
fov
;
this
.
zoom
=
source
.
zoom
;
};
this
.
near
=
source
.
near
;
this
.
far
=
source
.
far
;
this
.
focus
=
source
.
focus
;
/**
* Sets the FOV by focal length in respect to the current .filmGauge.
*
* The default film gauge is 35, so that the focal length can be specified for
* a 35mm (full frame) camera.
*
* Values for focal length and film gauge must have the same unit.
*/
THREE
.
PerspectiveCamera
.
prototype
.
setFocalLength
=
function
(
focalLength
)
{
this
.
aspect
=
source
.
aspect
;
this
.
view
=
source
.
view
===
null
?
null
:
Object
.
assign
(
{},
source
.
view
);
// see http://www.bobatkins.com/photography/technical/field_of_view.html
var
vExtentSlope
=
0.5
*
this
.
getFilmHeight
()
/
focalLength
;
this
.
filmGauge
=
source
.
filmGauge
;
this
.
filmOffset
=
source
.
filmOffset
;
this
.
fov
=
THREE
.
Math
.
RAD2DEG
*
2
*
Math
.
atan
(
vExtentSlope
);
this
.
updateProjectionMatrix
();
return
this
;
};
},
/**
* Sets the FOV by focal length (DEPRECATED).
*
* Optionally also sets .filmGauge, otherwise uses it. See .setFocalLength.
*/
setLens
:
function
(
focalLength
,
filmGauge
)
{
/**
* Calculates the focal length from the current .fov and .filmGauge.
*/
THREE
.
PerspectiveCamera
.
prototype
.
getFocalLength
=
function
()
{
console
.
warn
(
"
THREE.PerspectiveCamera.setLens is deprecated.
"
+
"
Use .setFocalLength and .filmGauge for a photographic setup.
"
);
var
vExtentSlope
=
Math
.
tan
(
THREE
.
Math
.
DEG2RAD
*
0.5
*
this
.
fov
);
if
(
filmGauge
!==
undefined
)
this
.
filmGauge
=
filmGauge
;
this
.
setFocalLength
(
focalLength
);
return
0.5
*
this
.
getFilmHeight
()
/
vExtentSlope
;
},
};
/**
* Sets the FOV by focal length in respect to the current .filmGauge.
*
* The default film gauge is 35, so that the focal length can be specified for
* a 35mm (full frame) camera.
*
* Values for focal length and film gauge must have the same unit.
*/
setFocalLength
:
function
(
focalLength
)
{
THREE
.
PerspectiveCamera
.
prototype
.
getEffectiveFOV
=
function
()
{
// see http://www.bobatkins.com/photography/technical/field_of_view.html
var
vExtentSlope
=
0.5
*
this
.
getFilmHeight
()
/
focalLength
;
return
THREE
.
Math
.
RAD2DEG
*
2
*
Math
.
atan
(
Math
.
tan
(
THREE
.
Math
.
DEG2RAD
*
0.5
*
this
.
fov
)
/
this
.
zoom
);
this
.
fov
=
THREE
.
Math
.
RAD2DEG
*
2
*
Math
.
atan
(
vExtentSlope
);
this
.
updateProjectionMatrix
(
);
};
},
THREE
.
PerspectiveCamera
.
prototype
.
getFilmWidth
=
function
()
{
/**
* Calculates the focal length from the current .fov and .filmGauge.
*/
getFocalLength
:
function
()
{
// film not completely covered in portrait format (aspect < 1)
return
this
.
filmGauge
*
Math
.
min
(
this
.
aspect
,
1
);
var
vExtentSlope
=
Math
.
tan
(
THREE
.
Math
.
DEG2RAD
*
0.5
*
this
.
fov
);
}
;
return
0.5
*
this
.
getFilmHeight
()
/
vExtentSlope
;
THREE
.
PerspectiveCamera
.
prototype
.
getFilmHeight
=
function
()
{
},
// film not completely covered in landscape format (aspect > 1)
return
this
.
filmGauge
/
Math
.
max
(
this
.
aspect
,
1
);
getEffectiveFOV
:
function
()
{
};
return
THREE
.
Math
.
RAD2DEG
*
2
*
Math
.
atan
(
Math
.
tan
(
THREE
.
Math
.
DEG2RAD
*
0.5
*
this
.
fov
)
/
this
.
zoom
);
},
getFilmWidth
:
function
()
{
/**
* Sets an offset in a larger frustum. This is useful for multi-window or
* multi-monitor/multi-machine setups.
*
* For example, if you have 3x2 monitors and each monitor is 1920x1080 and
* the monitors are in grid like this
*
* +---+---+---+
* | A | B | C |
* +---+---+---+
* | D | E | F |
* +---+---+---+
*
* then for each monitor you would call it like this
*
* var w = 1920;
* var h = 1080;
* var fullWidth = w * 3;
* var fullHeight = h * 2;
*
* --A--
* camera.setOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
* --B--
* camera.setOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
* --C--
* camera.setOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
* --D--
* camera.setOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
* --E--
* camera.setOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
* --F--
* camera.setOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
*
* Note there is no reason monitors have to be the same size or in a grid.
*/
THREE
.
PerspectiveCamera
.
prototype
.
setViewOffset
=
function
(
fullWidth
,
fullHeight
,
x
,
y
,
width
,
height
)
{
// film not completely covered in portrait format (aspect < 1)
return
this
.
filmGauge
*
Math
.
min
(
this
.
aspect
,
1
);
this
.
aspect
=
fullWidth
/
fullHeight
;
},
this
.
view
=
{
fullWidth
:
fullWidth
,
fullHeight
:
fullHeight
,
offsetX
:
x
,
offsetY
:
y
,
width
:
width
,
height
:
height
};
getFilmHeight
:
function
()
{
this
.
updateProjectionMatrix
();
};
THREE
.
PerspectiveCamera
.
prototype
.
updateProjectionMatrix
=
function
()
{
var
near
=
this
.
near
,
top
=
near
*
Math
.
tan
(
THREE
.
Math
.
DEG2RAD
*
0.5
*
this
.
fov
)
/
this
.
zoom
,
height
=
2
*
top
,
width
=
this
.
aspect
*
height
,
left
=
-
0.5
*
width
,
view
=
this
.
view
;
if
(
view
!==
null
)
{
var
fullWidth
=
view
.
fullWidth
,
fullHeight
=
view
.
fullHeight
;
// film not completely covered in landscape format (aspect > 1)
return
this
.
filmGauge
/
Math
.
max
(
this
.
aspect
,
1
);
left
+=
view
.
offsetX
*
width
/
fullWidth
;
top
-=
view
.
offsetY
*
height
/
fullHeight
;
width
*=
view
.
width
/
fullWidth
;
height
*=
view
.
height
/
fullHeight
;
},
}
var
skew
=
this
.
filmOffset
;
if
(
skew
!==
0
)
left
+=
near
*
skew
/
this
.
getFilmWidth
();
/**
* Sets an offset in a larger frustum. This is useful for multi-window or
* multi-monitor/multi-machine setups.
*
* For example, if you have 3x2 monitors and each monitor is 1920x1080 and
* the monitors are in grid like this
*
* +---+---+---+
* | A | B | C |
* +---+---+---+
* | D | E | F |
* +---+---+---+
*
* then for each monitor you would call it like this
*
* var w = 1920;
* var h = 1080;
* var fullWidth = w * 3;
* var fullHeight = h * 2;
*
* --A--
* camera.setOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
* --B--
* camera.setOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
* --C--
* camera.setOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
* --D--
* camera.setOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
* --E--
* camera.setOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
* --F--
* camera.setOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
*
* Note there is no reason monitors have to be the same size or in a grid.
*/
setViewOffset
:
function
(
fullWidth
,
fullHeight
,
x
,
y
,
width
,
height
)
{
this
.
projectionMatrix
.
makeFrustum
(
left
,
left
+
width
,
top
-
height
,
top
,
near
,
this
.
far
);
this
.
aspect
=
fullWidth
/
fullHeight
;
};
this
.
view
=
{
fullWidth
:
fullWidth
,
fullHeight
:
fullHeight
,
offsetX
:
x
,
offsetY
:
y
,
width
:
width
,
height
:
height
};
THREE
.
PerspectiveCamera
.
prototype
.
copy
=
function
(
source
)
{
this
.
updateProjectionMatrix
();
THREE
.
Camera
.
prototype
.
copy
.
call
(
this
,
source
);
},
this
.
fov
=
source
.
fov
;
this
.
zoom
=
source
.
zoom
;
updateProjectionMatrix
:
function
()
{
this
.
near
=
source
.
near
;
this
.
far
=
source
.
far
;
this
.
focus
=
source
.
focus
;
var
near
=
this
.
near
,
top
=
near
*
Math
.
tan
(
THREE
.
Math
.
DEG2RAD
*
0.5
*
this
.
fov
)
/
this
.
zoom
,
height
=
2
*
top
,
width
=
this
.
aspect
*
height
,
left
=
-
0.5
*
width
,
view
=
this
.
view
;
this
.
aspect
=
source
.
aspect
;
this
.
view
=
source
.
view
===
null
?
null
:
Object
.
assign
(
{},
source
.
view
);
if
(
view
!==
null
)
{
this
.
filmGauge
=
source
.
filmGauge
;
this
.
filmOffset
=
source
.
filmOffse
t
;
var
fullWidth
=
view
.
fullWidth
,
fullHeight
=
view
.
fullHeigh
t
;
return
this
;
left
+=
view
.
offsetX
*
width
/
fullWidth
;
top
-=
view
.
offsetY
*
height
/
fullHeight
;
width
*=
view
.
width
/
fullWidth
;
height
*=
view
.
height
/
fullHeight
;
};
}
THREE
.
PerspectiveCamera
.
prototype
.
toJSON
=
function
(
meta
)
{
var
skew
=
this
.
filmOffset
;
if
(
skew
!==
0
)
left
+=
near
*
skew
/
this
.
getFilmWidth
();
var
data
=
THREE
.
Object3D
.
prototype
.
toJSON
.
call
(
this
,
meta
);
this
.
projectionMatrix
.
makeFrustum
(
left
,
left
+
width
,
top
-
height
,
top
,
near
,
this
.
far
);
data
.
object
.
fov
=
this
.
fov
;
data
.
object
.
zoom
=
this
.
zoom
;
},
data
.
object
.
near
=
this
.
near
;
data
.
object
.
far
=
this
.
far
;
data
.
object
.
focus
=
this
.
focus
;
toJSON
:
function
(
meta
)
{
data
.
object
.
aspect
=
this
.
aspect
;
var
data
=
THREE
.
Object3D
.
prototype
.
toJSON
.
call
(
this
,
meta
)
;
if
(
this
.
view
!==
null
)
data
.
object
.
view
=
Object
.
assign
(
{},
this
.
view
);
data
.
object
.
fov
=
this
.
fov
;
data
.
object
.
zoom
=
this
.
zoom
;
data
.
object
.
near
=
this
.
near
;
data
.
object
.
far
=
this
.
far
;
data
.
object
.
focus
=
this
.
focus
;
data
.
object
.
aspect
=
this
.
aspect
;
if
(
this
.
view
!==
null
)
data
.
object
.
view
=
Object
.
assign
(
{},
this
.
view
);
data
.
object
.
filmGauge
=
this
.
filmGauge
;
data
.
object
.
filmOffset
=
this
.
filmOffset
;
return
data
;
data
.
object
.
filmGauge
=
this
.
filmGauge
;
data
.
object
.
filmOffset
=
this
.
filmOffset
;
return
data
;
}
};
}
)
;
src/cameras/StereoCamera.js
浏览文件 @
d330d5b6
...
...
@@ -18,9 +18,7 @@ THREE.StereoCamera = function () {
};
THREE
.
StereoCamera
.
prototype
=
{
constructor
:
THREE
.
StereoCamera
,
Object
.
assign
(
THREE
.
StereoCamera
.
prototype
,
{
update
:
(
function
()
{
...
...
@@ -86,4 +84,4 @@ THREE.StereoCamera.prototype = {
}
)()
};
}
)
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录