Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
562864d3
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,发现更多精彩内容 >>
提交
562864d3
编写于
3月 21, 2011
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge remote branch 'alteredq/experimental' into experimental
上级
27dbb644
8f8c6047
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
607 addition
and
677 deletion
+607
-677
build/Three.js
build/Three.js
+235
-233
build/custom/ThreeCanvas.js
build/custom/ThreeCanvas.js
+100
-101
build/custom/ThreeDOM.js
build/custom/ThreeDOM.js
+3
-2
build/custom/ThreeSVG.js
build/custom/ThreeSVG.js
+51
-52
build/custom/ThreeWebGL.js
build/custom/ThreeWebGL.js
+152
-152
examples/obj/leeperrysmith/LeePerrySmith.js
examples/obj/leeperrysmith/LeePerrySmith.js
+5
-3
examples/webgl_materials_normalmap.html
examples/webgl_materials_normalmap.html
+3
-3
examples/webgl_materials_normalmap2.html
examples/webgl_materials_normalmap2.html
+1
-86
src/core/Face3.js
src/core/Face3.js
+2
-0
src/core/Face4.js
src/core/Face4.js
+2
-0
src/core/Geometry.js
src/core/Geometry.js
+27
-25
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+11
-8
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
...blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
+6
-4
utils/exporters/convert_obj_three.py
utils/exporters/convert_obj_three.py
+9
-8
未找到文件。
build/Three.js
浏览文件 @
562864d3
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
build/custom/ThreeCanvas.js
浏览文件 @
562864d3
此差异已折叠。
点击以展开。
build/custom/ThreeDOM.js
浏览文件 @
562864d3
...
...
@@ -49,8 +49,9 @@ THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;thi
-
1
;
this
.
z
*=-
1
;
return
this
},
length
:
function
(){
return
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
+
this
.
w
*
this
.
w
)},
normalize
:
function
(){
var
a
=
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
+
this
.
w
*
this
.
w
);
if
(
a
==
0
)
this
.
w
=
this
.
z
=
this
.
y
=
this
.
x
=
0
;
else
{
a
=
1
/
a
;
this
.
x
*=
a
;
this
.
y
*=
a
;
this
.
z
*=
a
;
this
.
w
*=
a
}
return
this
},
multiplySelf
:
function
(
a
){
var
b
=
this
.
x
,
c
=
this
.
y
,
e
=
this
.
z
,
d
=
this
.
w
,
g
=
a
.
x
,
f
=
a
.
y
,
i
=
a
.
z
;
a
=
a
.
w
;
this
.
x
=
b
*
a
+
d
*
g
+
c
*
i
-
e
*
f
;
this
.
y
=
c
*
a
+
d
*
f
+
e
*
g
-
b
*
i
;
this
.
z
=
e
*
a
+
d
*
i
+
b
*
f
-
c
*
g
;
this
.
w
=
d
*
a
-
b
*
g
-
c
*
f
-
e
*
i
;
return
this
},
multiplyVector3
:
function
(
a
,
b
){
b
||
(
b
=
a
);
var
c
=
a
.
x
,
e
=
a
.
y
,
d
=
a
.
z
,
g
=
this
.
x
,
f
=
this
.
y
,
i
=
this
.
z
,
h
=
this
.
w
,
j
=
h
*
c
+
f
*
d
-
i
*
e
,
m
=
h
*
e
+
i
*
c
-
g
*
d
,
l
=
h
*
d
+
g
*
e
-
f
*
c
;
c
=-
g
*
c
-
f
*
e
-
i
*
d
;
b
.
x
=
j
*
h
+
c
*-
g
+
m
*-
i
-
l
*-
f
;
b
.
y
=
m
*
h
+
c
*-
f
+
l
*-
g
-
j
*-
i
;
b
.
z
=
l
*
h
+
c
*-
i
+
j
*-
f
-
m
*-
g
;
return
b
}};
THREE
.
Quaternion
.
slerp
=
function
(
a
,
b
,
c
,
e
){
var
d
=
a
.
w
*
b
.
w
+
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
+
a
.
z
*
b
.
z
;
if
(
Math
.
abs
(
d
)
>=
1
){
c
.
w
=
a
.
w
;
c
.
x
=
a
.
x
;
c
.
y
=
a
.
y
;
c
.
z
=
a
.
z
;
return
c
}
var
g
=
Math
.
acos
(
d
),
f
=
Math
.
sqrt
(
1
-
d
*
d
);
if
(
Math
.
abs
(
f
)
<
0.0010
){
c
.
w
=
0.5
*
(
a
.
w
+
b
.
w
);
c
.
x
=
0.5
*
(
a
.
x
+
b
.
x
);
c
.
y
=
0.5
*
(
a
.
y
+
b
.
y
);
c
.
z
=
0.5
*
(
a
.
z
+
b
.
z
);
return
c
}
d
=
Math
.
sin
((
1
-
e
)
*
g
)
/
f
;
e
=
Math
.
sin
(
e
*
g
)
/
f
;
c
.
w
=
a
.
w
*
d
+
b
.
w
*
e
;
c
.
x
=
a
.
x
*
d
+
b
.
x
*
e
;
c
.
y
=
a
.
y
*
d
+
b
.
y
*
e
;
c
.
z
=
a
.
z
*
d
+
b
.
z
*
e
;
return
c
};
THREE
.
Vertex
=
function
(
a
){
this
.
position
=
a
||
new
THREE
.
Vector3
};
THREE
.
Face3
=
function
(
a
,
b
,
c
,
e
,
d
,
g
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
normal
=
e
instanceof
THREE
.
Vector3
?
e
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
e
instanceof
Array
?
e
:[];
this
.
color
=
d
instanceof
THREE
.
Color
?
d
:
new
THREE
.
Color
;
this
.
vertexColors
=
d
instanceof
Array
?
d
:[];
this
.
materials
=
g
instanceof
Array
?
g
:[
g
];
this
.
centroid
=
new
THREE
.
Vector3
};
THREE
.
Face4
=
function
(
a
,
b
,
c
,
e
,
d
,
g
,
f
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
d
=
e
;
this
.
normal
=
d
instanceof
THREE
.
Vector3
?
d
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
d
instanceof
Array
?
d
:[];
this
.
color
=
g
instanceof
THREE
.
Color
?
g
:
new
THREE
.
Color
;
this
.
vertexColors
=
g
instanceof
Array
?
g
:[];
this
.
materials
=
f
instanceof
Array
?
f
:[
f
];
this
.
centroid
=
new
THREE
.
Vector3
};
THREE
.
UV
=
function
(
a
,
b
){
this
.
set
(
a
||
0
,
b
||
0
)};
THREE
.
UV
.
prototype
=
{
set
:
function
(
a
,
b
){
this
.
u
=
a
;
this
.
v
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
set
(
a
.
u
,
a
.
v
);
return
this
}};
THREE
.
Face3
=
function
(
a
,
b
,
c
,
e
,
d
,
g
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
normal
=
e
instanceof
THREE
.
Vector3
?
e
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
e
instanceof
Array
?
e
:[];
this
.
color
=
d
instanceof
THREE
.
Color
?
d
:
new
THREE
.
Color
;
this
.
vertexColors
=
d
instanceof
Array
?
d
:[];
this
.
vertexTangents
=
[];
this
.
materials
=
g
instanceof
Array
?
g
:[
g
];
this
.
centroid
=
new
THREE
.
Vector3
};
THREE
.
Face4
=
function
(
a
,
b
,
c
,
e
,
d
,
g
,
f
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
d
=
e
;
this
.
normal
=
d
instanceof
THREE
.
Vector3
?
d
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
d
instanceof
Array
?
d
:[];
this
.
color
=
g
instanceof
THREE
.
Color
?
g
:
new
THREE
.
Color
;
this
.
vertexColors
=
g
instanceof
Array
?
g
:[];
this
.
vertexTangents
=
[];
this
.
materials
=
f
instanceof
Array
?
f
:[
f
];
this
.
centroid
=
new
THREE
.
Vector3
};
THREE
.
UV
=
function
(
a
,
b
){
this
.
set
(
a
||
0
,
b
||
0
)};
THREE
.
UV
.
prototype
=
{
set
:
function
(
a
,
b
){
this
.
u
=
a
;
this
.
v
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
set
(
a
.
u
,
a
.
v
);
return
this
}};
THREE
.
AnimationHandler
=
function
(){
var
a
=
[],
b
=
{},
c
=
{};
c
.
update
=
function
(
d
){
for
(
var
g
=
0
;
g
<
a
.
length
;
g
++
)
a
[
g
].
update
(
d
)};
c
.
addToUpdate
=
function
(
d
){
a
.
indexOf
(
d
)
===-
1
&&
a
.
push
(
d
)};
c
.
removeFromUpdate
=
function
(
d
){
d
=
a
.
indexOf
(
d
);
d
!==-
1
&&
a
.
splice
(
d
,
1
)};
c
.
add
=
function
(
d
){
b
[
d
.
name
]
!==
undefined
&&
console
.
log
(
"
THREE.AnimationHandler.add: Warning!
"
+
d
.
name
+
"
already exists in library. Overwriting.
"
);
b
[
d
.
name
]
=
d
;
if
(
d
.
initialized
!==!
0
){
for
(
var
g
=
0
;
g
<
d
.
hierarchy
.
length
;
g
++
){
for
(
var
f
=
0
;
f
<
d
.
hierarchy
[
g
].
keys
.
length
;
f
++
){
if
(
d
.
hierarchy
[
g
].
keys
[
f
].
time
<
0
)
d
.
hierarchy
[
g
].
keys
[
f
].
time
=
0
;
if
(
d
.
hierarchy
[
g
].
keys
[
f
].
rot
!==
undefined
&&!
(
d
.
hierarchy
[
g
].
keys
[
f
].
rot
instanceof
THREE
.
Quaternion
)){
var
i
=
d
.
hierarchy
[
g
].
keys
[
f
].
rot
;
d
.
hierarchy
[
g
].
keys
[
f
].
rot
=
new
THREE
.
Quaternion
(
i
[
0
],
i
[
1
],
i
[
2
],
i
[
3
])}}
if
(
d
.
hierarchy
[
g
].
keys
[
0
].
morphTargets
!==
undefined
){
i
=
{};
for
(
f
=
0
;
f
<
d
.
hierarchy
[
g
].
keys
.
length
;
f
++
)
for
(
var
h
=
0
;
h
<
d
.
hierarchy
[
g
].
keys
[
f
].
morphTargets
.
length
;
h
++
){
var
j
=
d
.
hierarchy
[
g
].
keys
[
f
].
morphTargets
[
h
];
i
[
j
]
=-
1
}
d
.
hierarchy
[
g
].
usedMorphTargets
=
i
;
for
(
f
=
0
;
f
<
d
.
hierarchy
[
g
].
keys
.
length
;
f
++
){
var
m
=
{};
for
(
j
in
i
){
for
(
h
=
0
;
h
<
d
.
hierarchy
[
g
].
keys
[
f
].
morphTargets
.
length
;
h
++
)
if
(
d
.
hierarchy
[
g
].
keys
[
f
].
morphTargets
[
h
]
===
j
){
m
[
j
]
=
d
.
hierarchy
[
g
].
keys
[
f
].
morphTargetsInfluences
[
h
];
break
}
h
===
d
.
hierarchy
[
g
].
keys
[
f
].
morphTargets
.
length
&&
(
m
[
j
]
=
0
)}
d
.
hierarchy
[
g
].
keys
[
f
].
morphTargetsInfluences
=
m
}}
for
(
f
=
1
;
f
<
d
.
hierarchy
[
g
].
keys
.
length
;
f
++
)
if
(
d
.
hierarchy
[
g
].
keys
[
f
].
time
===
d
.
hierarchy
[
g
].
keys
[
f
-
1
].
time
){
d
.
hierarchy
[
g
].
keys
.
splice
(
f
,
1
);
f
--
}
for
(
f
=
1
;
f
<
d
.
hierarchy
[
g
].
keys
.
length
;
f
++
)
d
.
hierarchy
[
g
].
keys
[
f
].
index
=
f
}
f
=
parseInt
(
d
.
length
*
...
...
build/custom/ThreeSVG.js
浏览文件 @
562864d3
此差异已折叠。
点击以展开。
build/custom/ThreeWebGL.js
浏览文件 @
562864d3
此差异已折叠。
点击以展开。
examples/obj/leeperrysmith/LeePerrySmith.js
浏览文件 @
562864d3
此差异已折叠。
点击以展开。
examples/webgl_materials_normalmap.html
浏览文件 @
562864d3
...
...
@@ -54,7 +54,7 @@
</div>
<script
type=
"text/javascript"
src=
"../build/Three.js"
></script>
<script
type=
"text/javascript"
src=
"js/Detector.js"
></script>
<script
type=
"text/javascript"
src=
"js/RequestAnimationFrame.js"
></script>
<script
type=
"text/javascript"
src=
"js/Stats.js"
></script>
...
...
@@ -188,8 +188,8 @@
function
createScene
(
geometry
,
scale
,
material1
,
material2
)
{
geometry
.
computeTangents
();
//
mesh1 = SceneUtils.addMesh( scene, geometry, scale, -scale * 12, 0, 0, 0,0,0, material1 );
mesh1
=
SceneUtils
.
addMesh
(
scene
,
geometry
,
scale
,
-
scale
*
12
,
0
,
0
,
0
,
0
,
0
,
material1
);
mesh2
=
SceneUtils
.
addMesh
(
scene
,
geometry
,
scale
,
scale
*
12
,
0
,
0
,
0
,
0
,
0
,
material2
);
loader
.
statusDomElement
.
style
.
display
=
"
none
"
;
...
...
examples/webgl_materials_normalmap2.html
浏览文件 @
562864d3
...
...
@@ -52,92 +52,8 @@
</div>
</div>
<!--
<script
type=
"text/javascript"
src=
"../build/Three.js"
></script>
-->
<script
type=
"text/javascript"
src=
"../src/Three.js"
></script>
<script
type=
"text/javascript"
src=
"../src/core/Color.js"
></script>
<script
type=
"text/javascript"
src=
"../src/core/Vector2.js"
></script>
<script
type=
"text/javascript"
src=
"../src/core/Vector3.js"
></script>
<script
type=
"text/javascript"
src=
"../src/core/Vector4.js"
></script>
<script
type=
"text/javascript"
src=
"../src/core/Ray.js"
></script>
<script
type=
"text/javascript"
src=
"../src/core/Rectangle.js"
></script>
<script
type=
"text/javascript"
src=
"../src/core/Matrix3.js"
></script>
<script
type=
"text/javascript"
src=
"../src/core/Matrix4.js"
></script>
<script
type=
"text/javascript"
src=
"../src/core/Object3D.js"
></script>
<script
type=
"text/javascript"
src=
"../src/core/Quaternion.js"
></script>
<script
type=
"text/javascript"
src=
"../src/core/Vertex.js"
></script>
<script
type=
"text/javascript"
src=
"../src/core/Face3.js"
></script>
<script
type=
"text/javascript"
src=
"../src/core/Face4.js"
></script>
<script
type=
"text/javascript"
src=
"../src/core/UV.js"
></script>
<script
type=
"text/javascript"
src=
"../src/core/Geometry.js"
></script>
<script
type=
"text/javascript"
src=
"../src/core/Spline.js"
></script>
<script
type=
"text/javascript"
src=
"../src/animation/AnimationHandler.js"
></script>
<script
type=
"text/javascript"
src=
"../src/animation/Animation.js"
></script>
<script
type=
"text/javascript"
src=
"../src/cameras/Camera.js"
></script>
<script
type=
"text/javascript"
src=
"../src/lights/Light.js"
></script>
<script
type=
"text/javascript"
src=
"../src/lights/AmbientLight.js"
></script>
<script
type=
"text/javascript"
src=
"../src/lights/DirectionalLight.js"
></script>
<script
type=
"text/javascript"
src=
"../src/lights/PointLight.js"
></script>
<script
type=
"text/javascript"
src=
"../src/materials/Material.js"
></script>
<script
type=
"text/javascript"
src=
"../src/materials/Mappings.js"
></script>
<script
type=
"text/javascript"
src=
"../src/materials/LineBasicMaterial.js"
></script>
<script
type=
"text/javascript"
src=
"../src/materials/MeshBasicMaterial.js"
></script>
<script
type=
"text/javascript"
src=
"../src/materials/MeshLambertMaterial.js"
></script>
<script
type=
"text/javascript"
src=
"../src/materials/MeshPhongMaterial.js"
></script>
<script
type=
"text/javascript"
src=
"../src/materials/MeshDepthMaterial.js"
></script>
<script
type=
"text/javascript"
src=
"../src/materials/MeshNormalMaterial.js"
></script>
<script
type=
"text/javascript"
src=
"../src/materials/MeshFaceMaterial.js"
></script>
<script
type=
"text/javascript"
src=
"../src/materials/MeshShaderMaterial.js"
></script>
<script
type=
"text/javascript"
src=
"../src/materials/ParticleBasicMaterial.js"
></script>
<script
type=
"text/javascript"
src=
"../src/materials/ParticleCanvasMaterial.js"
></script>
<script
type=
"text/javascript"
src=
"../src/materials/ParticleDOMMaterial.js"
></script>
<script
type=
"text/javascript"
src=
"../src/materials/Texture.js"
></script>
<script
type=
"text/javascript"
src=
"../src/materials/RenderTarget.js"
></script>
<script
type=
"text/javascript"
src=
"../src/materials/Uniforms.js"
></script>
<script
type=
"text/javascript"
src=
"../src/objects/Particle.js"
></script>
<script
type=
"text/javascript"
src=
"../src/objects/ParticleSystem.js"
></script>
<script
type=
"text/javascript"
src=
"../src/objects/Line.js"
></script>
<script
type=
"text/javascript"
src=
"../src/objects/Mesh.js"
></script>
<script
type=
"text/javascript"
src=
"../src/objects/Bone.js"
></script>
<script
type=
"text/javascript"
src=
"../src/objects/SkinnedMesh.js"
></script>
<script
type=
"text/javascript"
src=
"../src/objects/Ribbon.js"
></script>
<script
type=
"text/javascript"
src=
"../src/objects/Sound.js"
></script>
<script
type=
"text/javascript"
src=
"../src/objects/LOD.js"
></script>
<script
type=
"text/javascript"
src=
"../src/scenes/Scene.js"
></script>
<script
type=
"text/javascript"
src=
"../src/scenes/Fog.js"
></script>
<script
type=
"text/javascript"
src=
"../src/scenes/FogExp2.js"
></script>
<script
type=
"text/javascript"
src=
"../src/renderers/Projector.js"
></script>
<script
type=
"text/javascript"
src=
"../src/renderers/DOMRenderer.js"
></script>
<script
type=
"text/javascript"
src=
"../src/renderers/CanvasRenderer.js"
></script>
<script
type=
"text/javascript"
src=
"../src/renderers/SVGRenderer.js"
></script>
<script
type=
"text/javascript"
src=
"../src/renderers/WebGLShaders.js"
></script>
<script
type=
"text/javascript"
src=
"../src/renderers/WebGLRenderer.js"
></script>
<script
type=
"text/javascript"
src=
"../src/renderers/SoundRenderer.js"
></script>
<script
type=
"text/javascript"
src=
"../src/renderers/renderables/RenderableVertex.js"
></script>
<script
type=
"text/javascript"
src=
"../src/renderers/renderables/RenderableFace3.js"
></script>
<script
type=
"text/javascript"
src=
"../src/renderers/renderables/RenderableObject.js"
></script>
<script
type=
"text/javascript"
src=
"../src/renderers/renderables/RenderableParticle.js"
></script>
<script
type=
"text/javascript"
src=
"../src/renderers/renderables/RenderableLine.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/GeometryUtils.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/ImageUtils.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/SceneUtils.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/ShaderUtils.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/cameras/QuakeCamera.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/cameras/PathCamera.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/geometries/Cube.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/geometries/Cylinder.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/geometries/Icosahedron.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/geometries/Lathe.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/geometries/Plane.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/geometries/Sphere.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/geometries/Torus.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/geometries/TorusKnot.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/io/Loader.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/io/JSONLoader.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/io/BinaryLoader.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/objects/MarchingCubes.js"
></script>
<script
type=
"text/javascript"
src=
"js/Detector.js"
></script>
<script
type=
"text/javascript"
src=
"js/RequestAnimationFrame.js"
></script>
<script
type=
"text/javascript"
src=
"js/Stats.js"
></script>
...
...
@@ -252,7 +168,6 @@
geometry
.
computeTangents
();
material
=
new
THREE
.
MeshFaceMaterial
();
mesh1
=
SceneUtils
.
addMesh
(
scene
,
geometry
,
scale
,
0
,
-
50
,
0
,
0
,
0
,
0
,
material
);
loader
.
statusDomElement
.
style
.
display
=
"
none
"
;
...
...
src/core/Face3.js
浏览文件 @
562864d3
...
...
@@ -15,6 +15,8 @@ THREE.Face3 = function ( a, b, c, normal, color, materials ) {
this
.
color
=
color
instanceof
THREE
.
Color
?
color
:
new
THREE
.
Color
();
this
.
vertexColors
=
color
instanceof
Array
?
color
:
[];
this
.
vertexTangents
=
[];
this
.
materials
=
materials
instanceof
Array
?
materials
:
[
materials
];
this
.
centroid
=
new
THREE
.
Vector3
();
...
...
src/core/Face4.js
浏览文件 @
562864d3
...
...
@@ -16,6 +16,8 @@ THREE.Face4 = function ( a, b, c, d, normal, color, materials ) {
this
.
color
=
color
instanceof
THREE
.
Color
?
color
:
new
THREE
.
Color
();
this
.
vertexColors
=
color
instanceof
Array
?
color
:
[];
this
.
vertexTangents
=
[];
this
.
materials
=
materials
instanceof
Array
?
materials
:
[
materials
];
this
.
centroid
=
new
THREE
.
Vector3
();
...
...
src/core/Geometry.js
浏览文件 @
562864d3
...
...
@@ -224,7 +224,8 @@ THREE.Geometry.prototype = {
// based on http://www.terathon.com/code/tangent.html
// tangents go to vertices
var
f
,
fl
,
v
,
vl
,
face
,
uv
,
vA
,
vB
,
vC
,
uvA
,
uvB
,
uvC
,
var
f
,
fl
,
v
,
vl
,
i
,
il
,
vertexIndex
,
face
,
uv
,
vA
,
vB
,
vC
,
uvA
,
uvB
,
uvC
,
x1
,
x2
,
y1
,
y2
,
z1
,
z2
,
s1
,
s2
,
t1
,
t2
,
r
,
t
,
test
,
tan1
=
[],
tan2
=
[],
...
...
@@ -282,49 +283,50 @@ THREE.Geometry.prototype = {
for
(
f
=
0
,
fl
=
this
.
faces
.
length
;
f
<
fl
;
f
++
)
{
face
=
this
.
faces
[
f
];
uv
=
this
.
faceVertexUvs
[
f
][
0
];
// use UV layer 0 for tangents
uv
=
this
.
faceVertexUvs
[
0
][
f
];
// use UV layer 0 for tangents
if
(
face
instanceof
THREE
.
Face3
)
{
handleTriangle
(
this
,
face
.
a
,
face
.
b
,
face
.
c
,
0
,
1
,
2
);
this
.
vertices
[
face
.
a
].
normal
.
copy
(
face
.
vertexNormals
[
0
]
);
this
.
vertices
[
face
.
b
].
normal
.
copy
(
face
.
vertexNormals
[
1
]
);
this
.
vertices
[
face
.
c
].
normal
.
copy
(
face
.
vertexNormals
[
2
]
);
}
else
if
(
face
instanceof
THREE
.
Face4
)
{
handleTriangle
(
this
,
face
.
a
,
face
.
b
,
face
.
c
,
0
,
1
,
2
);
handleTriangle
(
this
,
face
.
a
,
face
.
b
,
face
.
d
,
0
,
1
,
3
);
this
.
vertices
[
face
.
a
].
normal
.
copy
(
face
.
vertexNormals
[
0
]
);
this
.
vertices
[
face
.
b
].
normal
.
copy
(
face
.
vertexNormals
[
1
]
);
this
.
vertices
[
face
.
c
].
normal
.
copy
(
face
.
vertexNormals
[
2
]
);
this
.
vertices
[
face
.
d
].
normal
.
copy
(
face
.
vertexNormals
[
3
]
);
}
}
for
(
v
=
0
,
vl
=
this
.
vertices
.
length
;
v
<
vl
;
v
++
)
{
n
.
copy
(
this
.
vertices
[
v
].
normal
);
t
=
tan1
[
v
];
// Gram-Schmidt orthogonalize
var
faceIndex
=
[
'
a
'
,
'
b
'
,
'
c
'
,
'
d
'
];
for
(
f
=
0
,
fl
=
this
.
faces
.
length
;
f
<
fl
;
f
++
)
{
face
=
this
.
faces
[
f
];
for
(
i
=
0
;
i
<
face
.
vertexNormals
.
length
;
i
++
)
{
n
.
copy
(
face
.
vertexNormals
[
i
]
);
vertexIndex
=
face
[
faceIndex
[
i
]
];
t
=
tan1
[
vertexIndex
];
tmp
.
copy
(
t
);
tmp
.
subSelf
(
n
.
multiplyScalar
(
n
.
dot
(
t
)
)
).
normalize
();
// Gram-Schmidt orthogonalize
// Calculate handedness
tmp
.
copy
(
t
);
tmp
.
subSelf
(
n
.
multiplyScalar
(
n
.
dot
(
t
)
)
).
normalize
();
tmp2
.
cross
(
this
.
vertices
[
v
].
normal
,
t
);
test
=
tmp2
.
dot
(
tan2
[
v
]
);
w
=
(
test
<
0.0
)
?
-
1.0
:
1.0
;
// Calculate handedness
this
.
vertices
[
v
].
tangent
.
set
(
tmp
.
x
,
tmp
.
y
,
tmp
.
z
,
w
);
tmp2
.
cross
(
face
.
vertexNormals
[
i
],
t
);
test
=
tmp2
.
dot
(
tan2
[
vertexIndex
]
);
w
=
(
test
<
0.0
)
?
-
1.0
:
1.0
;
face
.
vertexTangents
[
i
]
=
new
THREE
.
Vector4
(
tmp
.
x
,
tmp
.
y
,
tmp
.
z
,
w
);
}
}
this
.
hasTangents
=
true
;
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
562864d3
...
...
@@ -361,7 +361,7 @@ THREE.WebGLRenderer = function ( parameters ) {
normalType
=
bufferGuessNormalType
(
materials
,
geometryGroup
,
object
);
vertexColorType
=
bufferGuessVertexColorType
(
materials
,
geometryGroup
,
object
);
//console.log(
uvType, normalType,
vertexColorType, object, geometryGroup, materials );
//console.log(
"uvType",uvType, "normalType",normalType, "vertexColorType",
vertexColorType, object, geometryGroup, materials );
geometryGroup
.
__vertexArray
=
new
Float32Array
(
nvertices
*
3
);
...
...
@@ -439,6 +439,7 @@ THREE.WebGLRenderer = function ( parameters ) {
var
f
,
fl
,
fi
,
face
,
vertexNormals
,
faceNormal
,
normal
,
vertexColors
,
faceColor
,
vertexTangents
,
uvType
,
vertexColorType
,
normalType
,
uv
,
uv2
,
v1
,
v2
,
v3
,
v4
,
t1
,
t2
,
t3
,
t4
,
c1
,
c2
,
c3
,
c4
,
...
...
@@ -535,6 +536,8 @@ THREE.WebGLRenderer = function ( parameters ) {
vertexColors
=
face
.
vertexColors
;
faceColor
=
face
.
color
;
vertexTangents
=
face
.
vertexTangents
;
if
(
face
instanceof
THREE
.
Face3
)
{
...
...
@@ -711,9 +714,9 @@ THREE.WebGLRenderer = function ( parameters ) {
if
(
dirtyTangents
&&
geometry
.
hasTangents
)
{
t1
=
vert
ices
[
face
.
a
].
tangent
;
t2
=
vert
ices
[
face
.
b
].
tangent
;
t3
=
vert
ices
[
face
.
c
].
tangent
;
t1
=
vert
exTangents
[
0
]
;
t2
=
vert
exTangents
[
1
]
;
t3
=
vert
exTangents
[
2
]
;
tangentArray
[
offset_tangent
]
=
t1
.
x
;
tangentArray
[
offset_tangent
+
1
]
=
t1
.
y
;
...
...
@@ -1035,10 +1038,10 @@ THREE.WebGLRenderer = function ( parameters ) {
if
(
dirtyTangents
&&
geometry
.
hasTangents
)
{
t1
=
vert
ices
[
face
.
a
].
tangent
;
t2
=
vert
ices
[
face
.
b
].
tangent
;
t3
=
vert
ices
[
face
.
c
].
tangent
;
t4
=
vert
ices
[
face
.
d
].
tangent
;
t1
=
vert
exTangents
[
0
]
;
t2
=
vert
exTangents
[
1
]
;
t3
=
vert
exTangents
[
2
]
;
t4
=
vert
exTangents
[
3
]
;
tangentArray
[
offset_tangent
]
=
t1
.
x
;
tangentArray
[
offset_tangent
+
1
]
=
t1
.
y
;
...
...
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
浏览文件 @
562864d3
...
...
@@ -70,10 +70,12 @@ var model = {
'materials': [%(materials)s],
'normals': [%(normals)s],
'vertices': [%(vertices)s],
'morphTargets': [],
'normals': [%(normals)s],
'colors': [%(colors)s],
'uvs': [[%(uvs)s]],
...
...
@@ -226,7 +228,7 @@ def setBit(value, position, on):
mask
=
~
(
1
<<
position
)
return
(
value
&
mask
)
def
generate_face
(
f
,
i
,
normals
,
uvs
,
colors
,
mesh
,
use_normals
,
use_colors
,
use_uv_coords
):
def
generate_face
(
f
,
faceIndex
,
normals
,
uvs
,
colors
,
mesh
,
use_normals
,
use_colors
,
use_uv_coords
):
isTriangle
=
(
len
(
f
.
vertices
)
==
3
)
if
isTriangle
:
...
...
@@ -278,7 +280,7 @@ def generate_face(f, i, normals, uvs, colors, mesh, use_normals, use_colors, use
faceData
.
append
(
f
.
material_index
)
if
hasFaceVertexUvs
:
uv
=
get_uv_indices
(
i
,
uvs
,
mesh
)
uv
=
get_uv_indices
(
faceIndex
,
uvs
,
mesh
)
for
i
in
range
(
nVertices
):
index
=
uv
[
i
]
faceData
.
append
(
index
)
...
...
utils/exporters/convert_obj_three.py
浏览文件 @
562864d3
...
...
@@ -4,7 +4,7 @@
How to use this converter
-------------------------
python convert_obj_three.py -i infile.obj -o outfile.js [-m morphfiles*.obj] [-a center|top|bottom] [-s smooth|flat] [-t ascii|binary] [-d invert|normal]
python convert_obj_three.py -i infile.obj -o outfile.js [-m morphfiles*.obj] [-a center|top|bottom
|none
] [-s smooth|flat] [-t ascii|binary] [-d invert|normal]
Notes:
...
...
@@ -29,18 +29,19 @@ How to use generated JS file in your HTML document
<script type="text/javascript">
...
var loader = new THREE.Loader();
// load ascii model
loader.loadAscii( "Model_ascii.js", function( geometry ) { createScene( geometry) }, path_to_textures );
var jsonLoader = new THREE.JSONLoader();
jsonLoader.load( { model: "Model_ascii.js", callback: function( geometry ) { createScene( geometry) } } );
// load binary model
loader.loadBinary( "Model_bin.js", function( geometry ) { createScene( geometry) }, path_to_textures );
var binLoader = new THREE.BinaryLoader();
binLoader.load( { model: "Model_bin.js", callback: function( geometry ) { createScene( geometry) } } );
function createScene( geometry ) {
var normalizeUVsFlag = 1; // set to 1 if canvas render has missing materials
var mesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial(), normalizeUVsFlag );
var mesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial() );
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录