Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
88dec694
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,发现更多精彩内容 >>
提交
88dec694
编写于
8月 19, 2012
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'remotes/mrdoob/dev' into dev
上级
13c4aa32
d8bab754
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
60 addition
and
53 deletion
+60
-53
examples/webgl_camera.html
examples/webgl_camera.html
+21
-11
examples/webgl_geometry_extrude_splines.html
examples/webgl_geometry_extrude_splines.html
+14
-15
src/extras/helpers/CameraHelper.js
src/extras/helpers/CameraHelper.js
+25
-27
未找到文件。
examples/webgl_camera.html
浏览文件 @
88dec694
...
...
@@ -67,19 +67,18 @@
camera
=
new
THREE
.
PerspectiveCamera
(
50
,
0.5
*
SCREEN_WIDTH
/
SCREEN_HEIGHT
,
1
,
10000
);
camera
.
position
.
z
=
2500
;
scene
.
add
(
camera
);
cameraPerspective
=
new
THREE
.
PerspectiveCamera
(
50
,
0.5
*
SCREEN_WIDTH
/
SCREEN_HEIGHT
,
150
,
1000
);
cameraPerspectiveHelper
=
new
THREE
.
CameraHelper
(
cameraPerspective
);
cameraPerspectiv
e
.
add
(
cameraPerspectiveHelper
);
scen
e
.
add
(
cameraPerspectiveHelper
);
//
cameraOrtho
=
new
THREE
.
OrthographicCamera
(
0.5
*
SCREEN_WIDTH
/
-
2
,
0.5
*
SCREEN_WIDTH
/
2
,
SCREEN_HEIGHT
/
2
,
SCREEN_HEIGHT
/
-
2
,
150
,
1000
);
cameraOrthoHelper
=
new
THREE
.
CameraHelper
(
cameraOrtho
);
cameraOrtho
.
add
(
cameraOrthoHelper
);
scene
.
add
(
cameraOrthoHelper
);
//
...
...
@@ -166,8 +165,19 @@
switch
(
event
.
keyCode
)
{
case
79
:
/*O*/
activeCamera
=
cameraOrtho
;
activeHelper
=
cameraOrthoHelper
;
break
;
case
80
:
/*P*/
activeCamera
=
cameraPerspective
;
activeHelper
=
cameraPerspectiveHelper
;
break
;
case
79
:
/*O*/
activeCamera
=
cameraOrtho
;
activeHelper
=
cameraOrthoHelper
;
break
;
case
80
:
/*P*/
activeCamera
=
cameraPerspective
;
activeHelper
=
cameraPerspectiveHelper
;
break
;
}
...
...
@@ -226,9 +236,9 @@
cameraPerspective
.
updateProjectionMatrix
();
cameraPerspectiveHelper
.
update
();
cameraPerspectiveHelper
.
lines
.
visible
=
true
;
cameraPerspectiveHelper
.
visible
=
true
;
cameraOrthoHelper
.
lines
.
visible
=
false
;
cameraOrthoHelper
.
visible
=
false
;
}
else
{
...
...
@@ -236,9 +246,9 @@
cameraOrtho
.
updateProjectionMatrix
();
cameraOrthoHelper
.
update
();
cameraOrthoHelper
.
lines
.
visible
=
true
;
cameraOrthoHelper
.
visible
=
true
;
cameraPerspectiveHelper
.
lines
.
visible
=
false
;
cameraPerspectiveHelper
.
visible
=
false
;
}
...
...
@@ -246,12 +256,12 @@
renderer
.
clear
();
activeHelper
.
lines
.
visible
=
false
;
activeHelper
.
visible
=
false
;
renderer
.
setViewport
(
0
,
0
,
SCREEN_WIDTH
/
2
,
SCREEN_HEIGHT
);
renderer
.
render
(
scene
,
activeCamera
);
activeHelper
.
lines
.
visible
=
true
;
activeHelper
.
visible
=
true
;
renderer
.
setViewport
(
SCREEN_WIDTH
/
2
,
0
,
SCREEN_WIDTH
/
2
,
SCREEN_HEIGHT
);
renderer
.
render
(
scene
,
camera
);
...
...
examples/webgl_geometry_extrude_splines.html
浏览文件 @
88dec694
...
...
@@ -165,7 +165,7 @@
showCameraHelper
=
document
.
getElementById
(
'
cameraHelper
'
).
checked
;
cameraHelper
.
children
[
0
].
visible
=
showCameraHelper
;
cameraHelper
.
visible
=
showCameraHelper
;
cameraEye
.
visible
=
showCameraHelper
;
}
...
...
@@ -217,23 +217,22 @@
addTube
();
// Debug point
cameraEye
=
new
THREE
.
Mesh
(
new
THREE
.
SphereGeometry
(
5
),
new
THREE
.
MeshBasicMaterial
({
color
:
0xdddddd
}));
cameraEye
=
new
THREE
.
Mesh
(
new
THREE
.
SphereGeometry
(
5
),
new
THREE
.
MeshBasicMaterial
(
{
color
:
0xdddddd
}
)
);
cameraHelper
.
children
[
0
].
visible
=
showCameraHelper
;
cameraHelper
.
visible
=
showCameraHelper
;
cameraEye
.
visible
=
showCameraHelper
;
parent
.
add
(
cameraEye
);
cameraHelper
.
scale
.
multiplyScalar
(
0.1
);
cameraHelper
.
scale
.
multiplyScalar
(
0.1
);
splineCamera
.
add
(
cameraHelper
);
parent
.
add
(
splineCamera
);
//
renderer
=
new
THREE
.
WebGLRenderer
({
antialias
:
true
});
renderer
=
new
THREE
.
WebGLRenderer
({
antialias
:
true
}
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
container
.
appendChild
(
renderer
.
domElement
);
...
...
@@ -308,10 +307,10 @@
if
(
event
.
touches
.
length
==
1
)
{
event
.
preventDefault
();
event
.
preventDefault
();
mouseXOnMouseDown
=
event
.
touches
[
0
].
pageX
-
windowHalfX
;
targetRotationOnMouseDown
=
targetRotation
;
mouseXOnMouseDown
=
event
.
touches
[
0
].
pageX
-
windowHalfX
;
targetRotationOnMouseDown
=
targetRotation
;
}
...
...
@@ -321,10 +320,10 @@
if
(
event
.
touches
.
length
==
1
)
{
event
.
preventDefault
();
event
.
preventDefault
();
mouseX
=
event
.
touches
[
0
].
pageX
-
windowHalfX
;
targetRotation
=
targetRotationOnMouseDown
+
(
mouseX
-
mouseXOnMouseDown
)
*
0.05
;
mouseX
=
event
.
touches
[
0
].
pageX
-
windowHalfX
;
targetRotation
=
targetRotationOnMouseDown
+
(
mouseX
-
mouseXOnMouseDown
)
*
0.05
;
}
...
...
src/extras/helpers/CameraHelper.js
浏览文件 @
88dec694
...
...
@@ -9,22 +9,26 @@
THREE
.
CameraHelper
=
function
(
camera
)
{
THREE
.
Object3D
.
call
(
this
);
THREE
.
Line
.
call
(
this
);
var
_this
=
this
;
var
scope
=
this
;
this
.
lineGeometry
=
new
THREE
.
Geometry
();
this
.
lineMaterial
=
new
THREE
.
LineBasicMaterial
(
{
color
:
0xffffff
,
vertexColors
:
THREE
.
FaceColors
}
);
this
.
geometry
=
new
THREE
.
Geometry
();
this
.
material
=
new
THREE
.
LineBasicMaterial
(
{
color
:
0xffffff
,
vertexColors
:
THREE
.
FaceColors
}
);
this
.
type
=
THREE
.
LinePieces
;
this
.
matrixWorld
=
camera
.
matrixWorld
;
this
.
matrixAutoUpdate
=
false
;
this
.
pointMap
=
{};
// colors
var
hexFrustum
=
0xffaa00
,
hexCone
=
0xff0000
,
hexUp
=
0x00aaff
,
hexTarget
=
0xffffff
,
hexCross
=
0x333333
;
var
hexFrustum
=
0xffaa00
;
var
hexCone
=
0xff0000
;
var
hexUp
=
0x00aaff
;
var
hexTarget
=
0xffffff
;
var
hexCross
=
0x333333
;
// near
...
...
@@ -84,36 +88,31 @@ THREE.CameraHelper = function ( camera ) {
function
addPoint
(
id
,
hex
)
{
_this
.
lineGeometry
.
vertices
.
push
(
new
THREE
.
Vector3
()
);
_this
.
lineGeometry
.
colors
.
push
(
new
THREE
.
Color
(
hex
)
);
scope
.
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
()
);
scope
.
geometry
.
colors
.
push
(
new
THREE
.
Color
(
hex
)
);
if
(
scope
.
pointMap
[
id
]
===
undefined
)
scope
.
pointMap
[
id
]
=
[];
if
(
_this
.
pointMap
[
id
]
===
undefined
)
_this
.
pointMap
[
id
]
=
[];
_this
.
pointMap
[
id
].
push
(
_this
.
lineGeometry
.
vertices
.
length
-
1
);
scope
.
pointMap
[
id
].
push
(
scope
.
geometry
.
vertices
.
length
-
1
);
}
this
.
update
(
camera
);
this
.
lines
=
new
THREE
.
Line
(
this
.
lineGeometry
,
this
.
lineMaterial
,
THREE
.
LinePieces
);
this
.
add
(
this
.
lines
);
};
THREE
.
CameraHelper
.
prototype
=
Object
.
create
(
THREE
.
Object3D
.
prototype
);
THREE
.
CameraHelper
.
prototype
=
Object
.
create
(
THREE
.
Line
.
prototype
);
THREE
.
CameraHelper
.
prototype
.
update
=
function
()
{
var
camera
=
this
.
camera
;
var
w
=
1
;
var
h
=
1
;
var
scope
=
this
;
var
_this
=
this
;
var
w
=
1
,
h
=
1
;
// we need just camera projection matrix
// world matrix must be identity
THREE
.
CameraHelper
.
__c
.
projectionMatrix
.
copy
(
camera
.
projectionMatrix
);
THREE
.
CameraHelper
.
__c
.
projectionMatrix
.
copy
(
this
.
camera
.
projectionMatrix
);
// center / target
...
...
@@ -157,14 +156,13 @@ THREE.CameraHelper.prototype.update = function () {
THREE
.
CameraHelper
.
__v
.
set
(
x
,
y
,
z
);
THREE
.
CameraHelper
.
__projector
.
unprojectVector
(
THREE
.
CameraHelper
.
__v
,
THREE
.
CameraHelper
.
__c
);
var
points
=
_this
.
pointMap
[
point
];
var
points
=
scope
.
pointMap
[
point
];
if
(
points
!==
undefined
)
{
for
(
var
i
=
0
,
il
=
points
.
length
;
i
<
il
;
i
++
)
{
var
j
=
points
[
i
];
_this
.
lineGeometry
.
vertices
[
j
].
copy
(
THREE
.
CameraHelper
.
__v
);
scope
.
geometry
.
vertices
[
points
[
i
]
].
copy
(
THREE
.
CameraHelper
.
__v
);
}
...
...
@@ -172,7 +170,7 @@ THREE.CameraHelper.prototype.update = function () {
}
this
.
lineG
eometry
.
verticesNeedUpdate
=
true
;
this
.
g
eometry
.
verticesNeedUpdate
=
true
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录