Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
890a7571
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,发现更多精彩内容 >>
提交
890a7571
编写于
7月 15, 2013
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactored helpers.
上级
c1d45fdd
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
138 addition
and
107 deletion
+138
-107
editor/js/Editor.js
editor/js/Editor.js
+59
-38
editor/js/Menubar.Add.js
editor/js/Menubar.Add.js
+7
-7
editor/js/Viewport.js
editor/js/Viewport.js
+2
-2
src/extras/helpers/DirectionalLightHelper.js
src/extras/helpers/DirectionalLightHelper.js
+29
-24
src/extras/helpers/HemisphereLightHelper.js
src/extras/helpers/HemisphereLightHelper.js
+22
-13
src/extras/helpers/PointLightHelper.js
src/extras/helpers/PointLightHelper.js
+2
-1
src/extras/helpers/SpotLightHelper.js
src/extras/helpers/SpotLightHelper.js
+17
-22
未找到文件。
editor/js/Editor.js
浏览文件 @
890a7571
...
...
@@ -127,12 +127,23 @@ Editor.prototype = {
//
addHelper
:
function
(
object
)
{
addHelper
:
function
()
{
var
geometry
=
new
THREE
.
SphereGeometry
(
20
,
4
,
2
);
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
color
:
0xff0000
}
);
return
function
(
object
)
{
if
(
object
instanceof
THREE
.
PointLight
)
{
var
picker
=
new
THREE
.
Mesh
(
geometry
,
material
);
picker
.
name
=
'
picker
'
;
picker
.
userData
.
object
=
object
;
picker
.
visible
=
false
;
var
helper
=
new
THREE
.
PointLightHelper
(
object
,
10
);
helper
.
userData
.
object
=
object
;
helper
.
add
(
picker
);
this
.
sceneHelpers
.
add
(
helper
);
this
.
helpers
[
object
.
id
]
=
helper
;
...
...
@@ -140,8 +151,14 @@ Editor.prototype = {
}
else
if
(
object
instanceof
THREE
.
DirectionalLight
)
{
var
helper
=
new
THREE
.
DirectionalLightHelper
(
object
,
10
);
helper
.
userData
.
object
=
object
;
var
picker
=
new
THREE
.
Mesh
(
geometry
,
material
);
picker
.
name
=
'
picker
'
;
picker
.
userData
.
object
=
object
;
picker
.
visible
=
false
;
var
helper
=
new
THREE
.
DirectionalLightHelper
(
object
,
20
);
helper
.
add
(
picker
);
this
.
sceneHelpers
.
add
(
helper
);
this
.
helpers
[
object
.
id
]
=
helper
;
...
...
@@ -149,8 +166,14 @@ Editor.prototype = {
}
else
if
(
object
instanceof
THREE
.
SpotLight
)
{
var
picker
=
new
THREE
.
Mesh
(
geometry
,
material
);
picker
.
name
=
'
picker
'
;
picker
.
userData
.
object
=
object
;
picker
.
visible
=
false
;
var
helper
=
new
THREE
.
SpotLightHelper
(
object
,
10
);
helper
.
userData
.
object
=
object
;
helper
.
add
(
picker
);
this
.
sceneHelpers
.
add
(
helper
);
this
.
helpers
[
object
.
id
]
=
helper
;
...
...
@@ -158,8 +181,14 @@ Editor.prototype = {
}
else
if
(
object
instanceof
THREE
.
HemisphereLight
)
{
var
picker
=
new
THREE
.
Mesh
(
geometry
,
material
);
picker
.
name
=
'
picker
'
;
picker
.
userData
.
object
=
object
;
picker
.
visible
=
false
;
var
helper
=
new
THREE
.
HemisphereLightHelper
(
object
,
10
);
helper
.
userData
.
object
=
object
;
helper
.
add
(
picker
);
this
.
sceneHelpers
.
add
(
helper
);
this
.
helpers
[
object
.
id
]
=
helper
;
...
...
@@ -167,7 +196,9 @@ Editor.prototype = {
}
},
};
}(),
removeHelper
:
function
(
object
)
{
...
...
@@ -211,17 +242,7 @@ Editor.prototype = {
selectById
:
function
(
id
)
{
var
scope
=
this
;
this
.
scene
.
traverse
(
function
(
node
)
{
if
(
node
.
id
===
id
)
{
scope
.
select
(
node
);
}
}
);
this
.
select
(
this
.
scene
.
getObjectById
(
id
)
);
},
...
...
editor/js/Menubar.Add.js
浏览文件 @
890a7571
...
...
@@ -36,7 +36,7 @@ Menubar.Add = function ( editor ) {
var
heightSegments
=
1
;
var
geometry
=
new
THREE
.
PlaneGeometry
(
width
,
height
,
widthSegments
,
heightSegments
);
var
material
=
new
THREE
.
Mesh
Lambert
Material
();
var
material
=
new
THREE
.
Mesh
Phong
Material
();
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
mesh
.
name
=
'
Plane
'
+
(
++
meshCount
);
...
...
@@ -64,7 +64,7 @@ Menubar.Add = function ( editor ) {
var
depthSegments
=
1
;
var
geometry
=
new
THREE
.
CubeGeometry
(
width
,
height
,
depth
,
widthSegments
,
heightSegments
,
depthSegments
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
Mesh
Lambert
Material
()
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
Mesh
Phong
Material
()
);
mesh
.
name
=
'
Cube
'
+
(
++
meshCount
);
editor
.
addObject
(
mesh
);
...
...
@@ -88,7 +88,7 @@ Menubar.Add = function ( editor ) {
var
openEnded
=
false
;
var
geometry
=
new
THREE
.
CylinderGeometry
(
radiusTop
,
radiusBottom
,
height
,
radiusSegments
,
heightSegments
,
openEnded
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
Mesh
Lambert
Material
()
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
Mesh
Phong
Material
()
);
mesh
.
name
=
'
Cylinder
'
+
(
++
meshCount
);
editor
.
addObject
(
mesh
);
...
...
@@ -109,7 +109,7 @@ Menubar.Add = function ( editor ) {
var
heightSegments
=
16
;
var
geometry
=
new
THREE
.
SphereGeometry
(
radius
,
widthSegments
,
heightSegments
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
Mesh
Lambert
Material
()
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
Mesh
Phong
Material
()
);
mesh
.
name
=
'
Sphere
'
+
(
++
meshCount
);
editor
.
addObject
(
mesh
);
...
...
@@ -129,7 +129,7 @@ Menubar.Add = function ( editor ) {
var
detail
=
2
;
var
geometry
=
new
THREE
.
IcosahedronGeometry
(
radius
,
detail
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
Mesh
Lambert
Material
()
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
Mesh
Phong
Material
()
);
mesh
.
name
=
'
Icosahedron
'
+
(
++
meshCount
);
editor
.
addObject
(
mesh
);
...
...
@@ -152,7 +152,7 @@ Menubar.Add = function ( editor ) {
var
arc
=
Math
.
PI
*
2
;
var
geometry
=
new
THREE
.
TorusGeometry
(
radius
,
tube
,
radialSegments
,
tubularSegments
,
arc
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
Mesh
Lambert
Material
()
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
Mesh
Phong
Material
()
);
mesh
.
name
=
'
Torus
'
+
(
++
meshCount
);
editor
.
addObject
(
mesh
);
...
...
@@ -177,7 +177,7 @@ Menubar.Add = function ( editor ) {
var
heightScale
=
1
;
var
geometry
=
new
THREE
.
TorusKnotGeometry
(
radius
,
tube
,
radialSegments
,
tubularSegments
,
p
,
q
,
heightScale
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
Mesh
Lambert
Material
()
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
Mesh
Phong
Material
()
);
mesh
.
name
=
'
TorusKnot
'
+
(
++
meshCount
);
editor
.
addObject
(
mesh
);
...
...
editor/js/Viewport.js
浏览文件 @
890a7571
...
...
@@ -288,13 +288,13 @@ var Viewport = function ( editor ) {
signals
.
helperAdded
.
add
(
function
(
object
)
{
objects
.
push
(
object
);
objects
.
push
(
object
.
getObjectByName
(
'
picker
'
)
);
}
);
signals
.
helperRemoved
.
add
(
function
(
object
)
{
objects
.
splice
(
objects
.
indexOf
(
object
),
1
);
objects
.
splice
(
objects
.
indexOf
(
object
.
getObjectByName
(
'
picker
'
)
),
1
);
}
);
...
...
src/extras/helpers/DirectionalLightHelper.js
浏览文件 @
890a7571
...
...
@@ -3,51 +3,56 @@
* @author mrdoob / http://mrdoob.com/
*/
THREE
.
DirectionalLightHelper
=
function
(
light
,
s
phereS
ize
)
{
THREE
.
DirectionalLightHelper
=
function
(
light
,
size
)
{
THREE
.
Object3D
.
call
(
this
);
this
.
matrixAutoUpdate
=
false
;
this
.
light
=
light
;
this
.
light
.
updateMatrixWorld
();
var
geometry
=
new
THREE
.
SphereGeometry
(
sphereSize
,
4
,
2
);
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
fog
:
false
,
wireframe
:
true
}
);
material
.
color
.
copy
(
this
.
light
.
color
).
multiplyScalar
(
this
.
light
.
intensity
);
this
.
matrixWorld
=
light
.
matrixWorld
;
this
.
matrixAutoUpdate
=
false
;
this
.
lightSphere
=
new
THREE
.
Mesh
(
geometry
,
material
);
this
.
lightSphere
.
matrixWorld
=
this
.
light
.
matrixWorld
;
this
.
lightSphere
.
matrixAutoUpdate
=
false
;
this
.
add
(
this
.
lightSphere
);
var
geometry
=
new
THREE
.
PlaneGeometry
(
size
,
size
);
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
wireframe
:
true
,
fog
:
false
}
);
material
.
color
.
copy
(
this
.
light
.
color
).
multiplyScalar
(
this
.
light
.
intensity
);
/*
this.targetSphere = new THREE.Mesh( geometry, material );
this.targetSphere.position = this.light.target.position;
this.add( this.targetSphere );
*/
this
.
lightPlane
=
new
THREE
.
Mesh
(
geometry
,
material
);
this
.
add
(
this
.
lightPlane
);
geometry
=
new
THREE
.
Geometry
();
geometry
.
vertices
.
push
(
this
.
light
.
position
);
geometry
.
vertices
.
push
(
this
.
light
.
target
.
position
);
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
()
);
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
()
);
geometry
.
computeLineDistances
();
material
=
new
THREE
.
Line
DashedMaterial
(
{
dashSize
:
4
,
gapSize
:
4
,
opacity
:
0.75
,
transparent
:
true
,
fog
:
false
}
);
material
=
new
THREE
.
Line
BasicMaterial
(
{
fog
:
false
}
);
material
.
color
.
copy
(
this
.
light
.
color
).
multiplyScalar
(
this
.
light
.
intensity
);
this
.
targetLine
=
new
THREE
.
Line
(
geometry
,
material
);
this
.
add
(
this
.
targetLine
);
}
this
.
update
();
};
THREE
.
DirectionalLightHelper
.
prototype
=
Object
.
create
(
THREE
.
Object3D
.
prototype
);
THREE
.
DirectionalLightHelper
.
prototype
.
update
=
function
()
{
this
.
lightSphere
.
material
.
color
.
copy
(
this
.
light
.
color
).
multiplyScalar
(
this
.
light
.
intensity
);
var
vector
=
new
THREE
.
Vector3
();
return
function
()
{
vector
.
getPositionFromMatrix
(
this
.
light
.
matrixWorld
).
negate
();
this
.
targetLine
.
geometry
.
computeLineDistances
();
this
.
lightPlane
.
lookAt
(
vector
);
this
.
lightPlane
.
material
.
color
.
copy
(
this
.
light
.
color
).
multiplyScalar
(
this
.
light
.
intensity
);
this
.
targetLine
.
geometry
.
vertices
[
1
].
copy
(
vector
);
this
.
targetLine
.
geometry
.
verticesNeedUpdate
=
true
;
this
.
targetLine
.
material
.
color
.
copy
(
this
.
light
.
color
).
multiplyScalar
(
this
.
light
.
intensity
);
this
.
targetLine
.
material
.
color
.
copy
(
this
.
lightPlane
.
material
.
color
);
};
}
}();
src/extras/helpers/HemisphereLightHelper.js
浏览文件 @
890a7571
...
...
@@ -8,37 +8,46 @@ THREE.HemisphereLightHelper = function ( light, sphereSize, arrowLength, domeSiz
THREE
.
Object3D
.
call
(
this
);
this
.
light
=
light
;
this
.
light
.
updateMatrixWorld
();
this
.
matrixWorld
=
light
.
matrixWorld
;
this
.
matrixAutoUpdate
=
false
;
this
.
colors
=
[
new
THREE
.
Color
(),
new
THREE
.
Color
()
];
var
geometry
=
new
THREE
.
SphereGeometry
(
sphereSize
,
4
,
2
);
geometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeRotationX
(
-
Math
.
PI
/
2
)
);
for
(
var
i
=
0
,
il
=
8
;
i
<
il
;
i
++
)
{
geometry
.
faces
[
i
].
materialIndex
=
i
<
4
?
0
:
1
;
geometry
.
faces
[
i
].
color
=
this
.
colors
[
i
<
4
?
0
:
1
]
;
}
var
materialSky
=
new
THREE
.
MeshBasicMaterial
(
{
fog
:
false
,
wireframe
:
true
}
);
materialSky
.
color
.
copy
(
light
.
color
).
multiplyScalar
(
light
.
intensity
);
var
materialGround
=
new
THREE
.
MeshBasicMaterial
(
{
fog
:
false
,
wireframe
:
true
}
);
materialGround
.
color
.
copy
(
light
.
groundColor
).
multiplyScalar
(
light
.
intensity
);
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
vertexColors
:
THREE
.
FaceColors
,
wireframe
:
true
}
);
this
.
lightSphere
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshFaceMaterial
(
[
materialSky
,
materialGround
]
)
);
this
.
lightSphere
.
position
=
light
.
position
;
this
.
lightSphere
.
lookAt
(
new
THREE
.
Vector3
()
);
this
.
lightSphere
=
new
THREE
.
Mesh
(
geometry
,
material
);
this
.
add
(
this
.
lightSphere
);
this
.
update
();
};
THREE
.
HemisphereLightHelper
.
prototype
=
Object
.
create
(
THREE
.
Object3D
.
prototype
);
THREE
.
HemisphereLightHelper
.
prototype
.
update
=
function
()
{
this
.
lightSphere
.
lookAt
(
new
THREE
.
Vector3
()
);
var
vector
=
new
THREE
.
Vector3
(
);
this
.
lightSphere
.
material
.
materials
[
0
].
color
.
copy
(
this
.
light
.
color
).
multiplyScalar
(
this
.
light
.
intensity
);
this
.
lightSphere
.
material
.
materials
[
1
].
color
.
copy
(
this
.
light
.
groundColor
).
multiplyScalar
(
this
.
light
.
intensity
);
return
function
()
{
};
this
.
colors
[
0
].
copy
(
this
.
light
.
color
).
multiplyScalar
(
this
.
light
.
intensity
);
this
.
colors
[
1
].
copy
(
this
.
light
.
groundColor
).
multiplyScalar
(
this
.
light
.
intensity
);
this
.
lightSphere
.
lookAt
(
vector
.
getPositionFromMatrix
(
this
.
light
.
matrixWorld
).
negate
()
);
this
.
lightSphere
.
geometry
.
colorsNeedUpdate
=
true
;
}
}();
src/extras/helpers/PointLightHelper.js
浏览文件 @
890a7571
...
...
@@ -6,9 +6,10 @@
THREE
.
PointLightHelper
=
function
(
light
,
sphereSize
)
{
this
.
light
=
light
;
this
.
light
.
updateMatrixWorld
();
var
geometry
=
new
THREE
.
SphereGeometry
(
sphereSize
,
4
,
2
);
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
fog
:
false
,
wireframe
:
tru
e
}
);
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
wireframe
:
true
,
fog
:
fals
e
}
);
material
.
color
.
copy
(
this
.
light
.
color
).
multiplyScalar
(
this
.
light
.
intensity
);
THREE
.
Mesh
.
call
(
this
,
geometry
,
material
);
...
...
src/extras/helpers/SpotLightHelper.js
浏览文件 @
890a7571
...
...
@@ -6,50 +6,45 @@
THREE
.
SpotLightHelper
=
function
(
light
)
{
// spotlight helper must be a child of the scene
THREE
.
Object3D
.
call
(
this
);
this
.
light
=
light
;
this
.
light
.
updateMatrixWorld
();
this
.
matrixWorld
=
light
.
matrixWorld
;
this
.
matrixAutoUpdate
=
false
;
var
geometry
=
new
THREE
.
CylinderGeometry
(
0
,
1
,
1
,
8
,
1
,
true
);
geometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
0
,
-
0.5
,
0
)
);
geometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeRotationX
(
-
Math
.
PI
/
2
)
);
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
wireframe
:
true
,
opacity
:
0.3
,
transparent
:
tru
e
}
);
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
wireframe
:
true
,
fog
:
fals
e
}
);
THREE
.
Mesh
.
call
(
this
,
geometry
,
material
);
this
.
cone
=
new
THREE
.
Mesh
(
geometry
,
material
);
this
.
add
(
this
.
cone
);
this
.
update
();
};
THREE
.
SpotLightHelper
.
prototype
=
Object
.
create
(
THREE
.
Mesh
.
prototype
);
THREE
.
SpotLightHelper
.
prototype
=
Object
.
create
(
THREE
.
Object3D
.
prototype
);
THREE
.
SpotLightHelper
.
prototype
.
update
=
(
function
()
{
THREE
.
SpotLightHelper
.
prototype
.
update
=
function
()
{
var
targetPosition
=
new
THREE
.
Vector3
();
var
vector
=
new
THREE
.
Vector3
();
return
function
()
{
return
function
()
{
var
coneLength
=
this
.
light
.
distance
?
this
.
light
.
distance
:
10000
;
var
coneWidth
=
coneLength
*
Math
.
tan
(
this
.
light
.
angle
);
this
.
scale
.
set
(
coneWidth
,
coneWidth
,
coneLength
);
this
.
light
.
updateMatrixWorld
(
true
);
this
.
position
.
getPositionFromMatrix
(
this
.
light
.
matrixWorld
);
this
.
light
.
target
.
updateMatrixWorld
(
true
);
targetPosition
.
getPositionFromMatrix
(
this
.
light
.
target
.
matrixWorld
);
this
.
cone
.
scale
.
set
(
coneWidth
,
coneWidth
,
coneLength
);
this
.
lookAt
(
targetPosition
);
this
.
cone
.
lookAt
(
vector
.
getPositionFromMatrix
(
this
.
light
.
matrixWorld
).
negate
()
);
this
.
material
.
color
.
copy
(
this
.
light
.
color
).
multiplyScalar
(
this
.
light
.
intensity
);
this
.
cone
.
material
.
color
.
copy
(
this
.
light
.
color
).
multiplyScalar
(
this
.
light
.
intensity
);
}
}()
)
;
}();
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录