Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
b3812029
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,发现更多精彩内容 >>
提交
b3812029
编写于
7月 17, 2010
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* Using new object `UV` instead of `Vector2` where it should be used
上级
69dc5dcb
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
95 addition
and
71 deletion
+95
-71
README.md
README.md
+4
-3
build/three.js
build/three.js
+1
-1
build/three_debug.js
build/three_debug.js
+1
-1
examples/camera_free.html
examples/camera_free.html
+1
-0
examples/primitives/Plane.js
examples/primitives/Plane.js
+4
-4
examples/test.html
examples/test.html
+1
-0
src/core/UV.js
src/core/UV.js
+21
-0
src/renderers/CanvasRenderer.js
src/renderers/CanvasRenderer.js
+19
-19
utils/deployer.py
utils/deployer.py
+1
-0
utils/deployer_debug.py
utils/deployer_debug.py
+1
-0
utils/export_threejs_25a2.py
utils/export_threejs_25a2.py
+21
-22
utils/export_threejs_25b.py
utils/export_threejs_25b.py
+20
-21
未找到文件。
README.md
浏览文件 @
b3812029
...
...
@@ -35,7 +35,7 @@ Other similar projects: [pre3d](http://deanm.github.com/pre3d/), [pvjs](http://c
### Usage ###
Download the
[
compress
ed library
](
http://github.com/mrdoob/three.js/raw/master/build/three.js
)
and include it in your html.
Download the
[
minifi
ed library
](
http://github.com/mrdoob/three.js/raw/master/build/three.js
)
and include it in your html.
<script type="text/javascript" src="js/three.js"></script>
...
...
@@ -93,6 +93,7 @@ For creating a customised version of the library, including the source files in
<script type="text/javascript" src="js/three/core/Vertex.js"></script>
<script type="text/javascript" src="js/three/core/Face3.js"></script>
<script type="text/javascript" src="js/three/core/Face4.js"></script>
<script type="text/javascript" src="js/three/core/UV.js"></script>
<script type="text/javascript" src="js/three/core/Geometry.js"></script>
<script type="text/javascript" src="js/three/cameras/Camera.js"></script>
<script type="text/javascript" src="js/three/objects/Object3D.js"></script>
...
...
@@ -127,7 +128,7 @@ Thanks to the power of the internets (and github <3) these people have kindly he
### Change Log ###
2010 07 17 -
**r14**
(32.0
04
kb)
2010 07 17 -
**r14**
(32.0
93
kb)
*
Refactored
`CanvasRenderer`
(more duplicated code, but easier to handle)
*
`Face4`
now supports
`MeshBitmapUVMappingMaterial`
...
...
@@ -139,6 +140,7 @@ Thanks to the power of the internets (and github <3) these people have kindly he
*
`FaceColorStrokeMaterial`
>
`MeshFaceColorStrokeMaterial`
*
`ColorStrokeMaterial`
>
`LineColorMaterial`
*
`Rectangle.instersects`
returned false with rectangles with 0px witdh or height
*
Using new object
`UV`
instead of
`Vector2`
where it should be used
2010 07 12 -
**r13**
(29.492 kb)
...
...
@@ -162,7 +164,6 @@ Thanks to the power of the internets (and github <3) these people have kindly he
*
Blender 2.5 exporter (utils/export_threejs.py) now exports UV and normals (Thx
[
kikko
](
http://github.com/kikko
)
)
*
`Scene.add`
>
`Scene.addObject`
*
Enabled
`Scene.removeObject`
*
Removed
`computeNormals()`
from
`Geometry`
2010 06 22 -
**r10**
(23.959 kb)
...
...
build/three.js
浏览文件 @
b3812029
此差异已折叠。
点击以展开。
build/three_debug.js
浏览文件 @
b3812029
此差异已折叠。
点击以展开。
examples/camera_free.html
浏览文件 @
b3812029
...
...
@@ -27,6 +27,7 @@
<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/cameras/Camera.js"
></script>
<script
type=
"text/javascript"
src=
"../src/objects/Object3D.js"
></script>
...
...
examples/primitives/Plane.js
浏览文件 @
b3812029
...
...
@@ -42,10 +42,10 @@ var Plane = function ( width, height, segments_width, segments_height ) {
this
.
faces
.
push
(
new
THREE
.
Face4
(
a
,
b
,
c
,
d
)
);
this
.
uvs
.
push
(
[
new
THREE
.
Vector2
(
ix
/
gridX
,
iy
/
gridY
),
new
THREE
.
Vector2
(
ix
/
gridX
,
(
iy
+
1
)
/
gridY
),
new
THREE
.
Vector2
(
(
ix
+
1
)
/
gridX
,
(
iy
+
1
)
/
gridY
),
new
THREE
.
Vector2
(
(
ix
+
1
)
/
gridX
,
iy
/
gridY
)
new
THREE
.
UV
(
ix
/
gridX
,
iy
/
gridY
),
new
THREE
.
UV
(
ix
/
gridX
,
(
iy
+
1
)
/
gridY
),
new
THREE
.
UV
(
(
ix
+
1
)
/
gridX
,
(
iy
+
1
)
/
gridY
),
new
THREE
.
UV
(
(
ix
+
1
)
/
gridX
,
iy
/
gridY
)
]
);
}
...
...
examples/test.html
浏览文件 @
b3812029
...
...
@@ -25,6 +25,7 @@
<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/cameras/Camera.js"
></script>
<script
type=
"text/javascript"
src=
"../src/objects/Object3D.js"
></script>
...
...
src/core/UV.js
0 → 100644
浏览文件 @
b3812029
/**
* @author mr.doob / http://mrdoob.com/
*/
THREE
.
UV
=
function
(
u
,
v
)
{
this
.
u
=
u
||
0
;
this
.
v
=
v
||
0
;
};
THREE
.
UV
.
prototype
=
{
copy
:
function
(
uv
)
{
this
.
u
=
uv
.
u
;
this
.
v
=
uv
.
v
;
}
}
src/renderers/CanvasRenderer.js
浏览文件 @
b3812029
...
...
@@ -45,7 +45,7 @@ THREE.CanvasRenderer = function () {
var
e
,
el
,
m
,
ml
,
element
,
material
,
pi2
=
Math
.
PI
*
2
,
v1x
,
v1y
,
v2x
,
v2y
,
v3x
,
v3y
,
v4x
,
v4y
,
width
,
height
,
uv1
=
new
THREE
.
Vector2
(),
uv2
=
new
THREE
.
Vector2
(),
uv3
=
new
THREE
.
Vector2
(),
uv4
=
new
THREE
.
Vector2
(),
uv1
=
new
THREE
.
UV
(),
uv2
=
new
THREE
.
UV
(),
uv3
=
new
THREE
.
UV
(),
uv4
=
new
THREE
.
UV
(),
bitmap
,
bitmapWidth
,
bitmapHeight
;
if
(
this
.
autoClear
)
{
...
...
@@ -273,11 +273,11 @@ THREE.CanvasRenderer = function () {
uv2
.
copy
(
element
.
uvs
[
1
]
);
uv3
.
copy
(
element
.
uvs
[
2
]
);
uv1
.
x
*=
bitmapWidth
;
uv1
.
y
*=
bitmapHeight
;
uv2
.
x
*=
bitmapWidth
;
uv2
.
y
*=
bitmapHeight
;
uv3
.
x
*=
bitmapWidth
;
uv3
.
y
*=
bitmapHeight
;
uv1
.
u
*=
bitmapWidth
;
uv1
.
v
*=
bitmapHeight
;
uv2
.
u
*=
bitmapWidth
;
uv2
.
v
*=
bitmapHeight
;
uv3
.
u
*=
bitmapWidth
;
uv3
.
v
*=
bitmapHeight
;
drawTexturedTriangle
(
bitmap
,
v1x
,
v1y
,
v2x
,
v2y
,
v3x
,
v3y
,
uv1
.
x
,
uv1
.
y
,
uv2
.
x
,
uv2
.
y
,
uv3
.
x
,
uv3
.
y
);
drawTexturedTriangle
(
bitmap
,
v1x
,
v1y
,
v2x
,
v2y
,
v3x
,
v3y
,
uv1
.
u
,
uv1
.
v
,
uv2
.
u
,
uv2
.
v
,
uv3
.
u
,
uv3
.
v
);
}
...
...
@@ -395,13 +395,13 @@ THREE.CanvasRenderer = function () {
uv3
.
copy
(
element
.
uvs
[
2
]
);
uv4
.
copy
(
element
.
uvs
[
3
]
);
uv1
.
x
*=
bitmapWidth
;
uv1
.
y
*=
bitmapHeight
;
uv2
.
x
*=
bitmapWidth
;
uv2
.
y
*=
bitmapHeight
;
uv3
.
x
*=
bitmapWidth
;
uv3
.
y
*=
bitmapHeight
;
uv4
.
x
*=
bitmapWidth
;
uv4
.
y
*=
bitmapHeight
;
uv1
.
u
*=
bitmapWidth
;
uv1
.
v
*=
bitmapHeight
;
uv2
.
u
*=
bitmapWidth
;
uv2
.
v
*=
bitmapHeight
;
uv3
.
u
*=
bitmapWidth
;
uv3
.
v
*=
bitmapHeight
;
uv4
.
u
*=
bitmapWidth
;
uv4
.
v
*=
bitmapHeight
;
drawTexturedTriangle
(
bitmap
,
v1x
,
v1y
,
v2x
,
v2y
,
v4x
,
v4y
,
uv1
.
x
,
uv1
.
y
,
uv2
.
x
,
uv2
.
y
,
uv4
.
x
,
uv4
.
y
);
drawTexturedTriangle
(
bitmap
,
v2x
,
v2y
,
v3x
,
v3y
,
v4x
,
v4y
,
uv2
.
x
,
uv2
.
y
,
uv3
.
x
,
uv3
.
y
,
uv4
.
x
,
uv4
.
y
);
drawTexturedTriangle
(
bitmap
,
v1x
,
v1y
,
v2x
,
v2y
,
v4x
,
v4y
,
uv1
.
u
,
uv1
.
v
,
uv2
.
u
,
uv2
.
v
,
uv4
.
u
,
uv4
.
v
);
drawTexturedTriangle
(
bitmap
,
v2x
,
v2y
,
v3x
,
v3y
,
v4x
,
v4y
,
uv2
.
u
,
uv2
.
v
,
uv3
.
u
,
uv3
.
v
,
uv4
.
u
,
uv4
.
v
);
}
...
...
@@ -427,7 +427,7 @@ THREE.CanvasRenderer = function () {
};
function
drawTexturedTriangle
(
bitmap
,
v1x
,
v1y
,
v2x
,
v2y
,
v3x
,
v3y
,
suv1x
,
suv1y
,
suv2x
,
suv2y
,
suv3x
,
suv3y
)
{
function
drawTexturedTriangle
(
bitmap
,
v1x
,
v1y
,
v2x
,
v2y
,
v3x
,
v3y
,
uv1u
,
uv1v
,
uv2u
,
uv2v
,
uv3u
,
uv3v
)
{
// Textured triangle drawing by Thatcher Ulrich.
// http://tulrich.com/geekstuff/canvas/jsgl.js
...
...
@@ -444,14 +444,14 @@ THREE.CanvasRenderer = function () {
_context
.
save
();
_context
.
clip
();
denom
=
suv1x
*
(
suv3y
-
suv2y
)
-
suv2x
*
suv3y
+
suv3x
*
suv2y
+
(
suv2x
-
suv3x
)
*
suv1y
;
denom
=
uv1u
*
(
uv3v
-
uv2v
)
-
uv2u
*
uv3v
+
uv3u
*
uv2v
+
(
uv2u
-
uv3u
)
*
uv1v
;
m11
=
-
(
suv1y
*
(
v3x
-
v2x
)
-
suv2y
*
v3x
+
suv3y
*
v2x
+
(
suv2y
-
suv3y
)
*
v1x
)
/
denom
;
m12
=
(
suv2y
*
v3y
+
suv1y
*
(
v2y
-
v3y
)
-
suv3y
*
v2y
+
(
suv3y
-
suv2y
)
*
v1y
)
/
denom
;
m21
=
(
suv1x
*
(
v3x
-
v2x
)
-
suv2x
*
v3x
+
suv3x
*
v2x
+
(
suv2x
-
suv3x
)
*
v1x
)
/
denom
;
m22
=
-
(
suv2x
*
v3y
+
suv1x
*
(
v2y
-
v3y
)
-
suv3x
*
v2y
+
(
suv3x
-
suv2x
)
*
v1y
)
/
denom
;
dx
=
(
suv1x
*
(
suv3y
*
v2x
-
suv2y
*
v3x
)
+
suv1y
*
(
suv2x
*
v3x
-
suv3x
*
v2x
)
+
(
suv3x
*
suv2y
-
suv2x
*
suv3y
)
*
v1x
)
/
denom
;
dy
=
(
suv1x
*
(
suv3y
*
v2y
-
suv2y
*
v3y
)
+
suv1y
*
(
suv2x
*
v3y
-
suv3x
*
v2y
)
+
(
suv3x
*
suv2y
-
suv2x
*
suv3y
)
*
v1y
)
/
denom
;
m11
=
-
(
uv1v
*
(
v3x
-
v2x
)
-
uv2v
*
v3x
+
uv3v
*
v2x
+
(
uv2v
-
uv3v
)
*
v1x
)
/
denom
;
m12
=
(
uv2v
*
v3y
+
uv1v
*
(
v2y
-
v3y
)
-
uv3v
*
v2y
+
(
uv3v
-
uv2v
)
*
v1y
)
/
denom
;
m21
=
(
uv1u
*
(
v3x
-
v2x
)
-
uv2u
*
v3x
+
uv3u
*
v2x
+
(
uv2u
-
uv3u
)
*
v1x
)
/
denom
;
m22
=
-
(
uv2u
*
v3y
+
uv1u
*
(
v2y
-
v3y
)
-
uv3u
*
v2y
+
(
uv3u
-
uv2u
)
*
v1y
)
/
denom
;
dx
=
(
uv1u
*
(
uv3v
*
v2x
-
uv2v
*
v3x
)
+
uv1v
*
(
uv2u
*
v3x
-
uv3u
*
v2x
)
+
(
uv3u
*
uv2v
-
uv2u
*
uv3v
)
*
v1x
)
/
denom
;
dy
=
(
uv1u
*
(
uv3v
*
v2y
-
uv2v
*
v3y
)
+
uv1v
*
(
uv2u
*
v3y
-
uv3u
*
v2y
)
+
(
uv3u
*
uv2v
-
uv2u
*
uv3v
)
*
v1y
)
/
denom
;
_context
.
transform
(
m11
,
m12
,
m21
,
m22
,
dx
,
dy
);
...
...
utils/deployer.py
浏览文件 @
b3812029
...
...
@@ -16,6 +16,7 @@ files.append('core/Matrix4.js')
files
.
append
(
'core/Vertex.js'
)
files
.
append
(
'core/Face3.js'
)
files
.
append
(
'core/Face4.js'
)
files
.
append
(
'core/UV.js'
)
files
.
append
(
'core/Geometry.js'
)
files
.
append
(
'cameras/Camera.js'
)
files
.
append
(
'objects/Object3D.js'
)
...
...
utils/deployer_debug.py
浏览文件 @
b3812029
...
...
@@ -16,6 +16,7 @@ files.append('core/Matrix4.js')
files
.
append
(
'core/Vertex.js'
)
files
.
append
(
'core/Face3.js'
)
files
.
append
(
'core/Face4.js'
)
files
.
append
(
'core/UV.js'
)
files
.
append
(
'core/Geometry.js'
)
files
.
append
(
'cameras/Camera.js'
)
files
.
append
(
'objects/Object3D.js'
)
...
...
utils/export_threejs_25a2.py
浏览文件 @
b3812029
...
...
@@ -70,7 +70,7 @@ def write(filename, scene, ob, \
active_col_layer
=
active_col_layer
.
data
# incase
color
=
uvcoord
=
uvcoord_key
=
normal
=
normal_key
=
None
color
=
uvcoord
=
uvcoord_key
=
normal
=
normal_key
=
None
file
.
write
(
'var %s = function () {
\n\n
'
%
classname
)
...
...
@@ -82,24 +82,23 @@ def write(filename, scene, ob, \
file
.
write
(
'
\t
v( %.6f, %.6f, %.6f );
\n
'
%
(
v
.
co
.
x
,
v
.
co
.
z
,
-
v
.
co
.
y
))
# co
file
.
write
(
'
\n
'
)
if
EXPORT_NORMALS
:
for
f
in
mesh
.
faces
:
if
len
(
f
.
verts
)
==
3
:
file
.
write
(
'
\t
f3
n
( %d, %d, %d, %.6f, %.6f, %.6f );
\n
'
%
(
f
.
verts
[
0
],
f
.
verts
[
1
],
f
.
verts
[
2
],
f
.
normal
[
0
],
f
.
normal
[
1
],
f
.
normal
[
2
]))
file
.
write
(
'
\t
f3( %d, %d, %d, %.6f, %.6f, %.6f );
\n
'
%
(
f
.
verts
[
0
],
f
.
verts
[
1
],
f
.
verts
[
2
],
f
.
normal
[
0
],
f
.
normal
[
1
],
f
.
normal
[
2
]))
else
:
file
.
write
(
'
\t
f
3n( %d, %d, %d, %.6f, %.6f, %.6f );
\n
'
%
(
f
.
verts
[
3
],
f
.
verts
[
1
],
f
.
verts
[
2
],
f
.
normal
[
0
],
f
.
normal
[
1
],
f
.
normal
[
2
]))
file
.
write
(
'
\t
f3n( %d, %d, %d, %.6f, %.6f, %.6f );
\n
'
%
(
f
.
verts
[
1
],
f
.
verts
[
3
],
f
.
verts
[
0
],
f
.
normal
[
0
],
f
.
normal
[
1
],
f
.
normal
[
2
]))
file
.
write
(
'
\t
f
4( %d, %d, %d, %d, %.6f, %.6f, %.6f );
\n
'
%
(
f
.
verts
[
0
],
f
.
verts
[
1
],
f
.
verts
[
2
],
f
.
verts
[
3
],
f
.
normal
[
0
],
f
.
normal
[
1
],
f
.
normal
[
2
]))
else
:
for
f
in
mesh
.
faces
:
if
len
(
f
.
verts
)
==
3
:
file
.
write
(
'
\t
f3( %d, %d, %d );
\n
'
%
(
f
.
verts
[
0
],
f
.
verts
[
1
],
f
.
verts
[
2
]))
else
:
file
.
write
(
'
\t
f3( %d, %d, %d );
\n
'
%
(
f
.
verts
[
2
],
f
.
verts
[
1
],
f
.
verts
[
3
]))
file
.
write
(
'
\t
f3( %d, %d, %d );
\n
'
%
(
f
.
verts
[
0
],
f
.
verts
[
3
],
f
.
verts
[
1
]))
file
.
write
(
'
\t
f4( %d, %d, %d, %d );
\n
'
%
(
f
.
verts
[
0
],
f
.
verts
[
1
],
f
.
verts
[
2
],
f
.
verts
[
3
]))
face_index_pairs
=
[
(
face
,
index
)
for
index
,
face
in
enumerate
(
mesh
.
faces
)]
if
EXPORT_UV
:
file
.
write
(
'
\n
'
)
for
f
,
f_index
in
face_index_pairs
:
...
...
@@ -107,29 +106,29 @@ def write(filename, scene, ob, \
if
len
(
f
.
verts
)
==
3
:
file
.
write
(
'
\t
uv( %.6f, %.6f, %.6f, %.6f, %.6f, %.6f );
\n
'
%
(
tface
.
uv1
[
0
],
1.0
-
tface
.
uv1
[
1
],
tface
.
uv2
[
0
],
1.0
-
tface
.
uv2
[
1
],
tface
.
uv3
[
0
],
1.0
-
tface
.
uv3
[
1
]))
else
:
file
.
write
(
'
\t
uv( %.6f, %.6f, %.6f, %.6f, %.6f, %.6f );
\n
'
%
(
tface
.
uv4
[
0
],
1.0
-
tface
.
uv4
[
1
],
tface
.
uv2
[
0
],
1.0
-
tface
.
uv2
[
1
],
tface
.
uv3
[
0
],
1.0
-
tface
.
uv3
[
1
]))
file
.
write
(
'
\t
uv( %.6f, %.6f, %.6f, %.6f, %.6f, %.6f );
\n
'
%
(
tface
.
uv2
[
0
],
1.0
-
tface
.
uv2
[
1
],
tface
.
uv4
[
0
],
1.0
-
tface
.
uv4
[
1
],
tface
.
uv1
[
0
],
1.0
-
tface
.
uv1
[
1
]))
file
.
write
(
'
\t
uv( %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f );
\n
'
%
(
tface
.
uv1
[
0
],
1.0
-
tface
.
uv1
[
1
],
tface
.
uv2
[
0
],
1.0
-
tface
.
uv2
[
1
],
tface
.
uv3
[
0
],
1.0
-
tface
.
uv3
[
1
],
tface
.
uv4
[
0
],
1.0
-
tface
.
uv4
[
1
]))
file
.
write
(
'
\n
'
)
file
.
write
(
'
\t
function v( x, y, z ) {
\n\n
'
)
file
.
write
(
'
\t\t
scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
\n\n
'
)
file
.
write
(
'
\t
}
\n\n
'
)
file
.
write
(
'
\t
function f3( a, b, c ) {
\n\n
'
)
file
.
write
(
'
\t\t
scope.faces.push( new THREE.Face3( a, b, c ) );
\n\n
'
)
file
.
write
(
'
\t
function f3( a, b, c
, nx, ny, nz
) {
\n\n
'
)
file
.
write
(
'
\t\t
scope.faces.push( new THREE.Face3( a, b, c
, nx && ny && nz ? new THREE.Vector3( nx, ny, nz ) : null
) );
\n\n
'
)
file
.
write
(
'
\t
}
\n\n
'
)
file
.
write
(
'
\t
function f
3n( a, b, c
, nx, ny, nz ) {
\n\n
'
)
file
.
write
(
'
\t\t
scope.faces.push( new THREE.Face
3( a, b, c, new THREE.Vector3( nx, ny, nz )
) );
\n\n
'
)
file
.
write
(
'
\t
function f
4( a, b, c, d
, nx, ny, nz ) {
\n\n
'
)
file
.
write
(
'
\t\t
scope.faces.push( new THREE.Face
4( a, b, c, d, nx && ny && nz ? new THREE.Vector3( nx, ny, nz ) : null
) );
\n\n
'
)
file
.
write
(
'
\t
}
\n\n
'
)
file
.
write
(
'
\t
function uv( u1, v1, u2, v2, u3, v3 ) {
\n\n
'
)
file
.
write
(
'
\t\t
scope.uvs.push( [
\n\n
'
)
file
.
write
(
'
\t\t\t
new THREE.Vector2( u1, v1 ),
\n
'
)
file
.
write
(
'
\t\t\t
new THREE.Vector2( u2, v2 ),
\n
'
)
file
.
write
(
'
\t\t\t
new THREE.Vector2( u3, v3 )
\n
'
)
file
.
write
(
'
\t\t
]);
\n
'
)
file
.
write
(
'
\t
function uv( u1, v1, u2, v2, u3, v3, u4, v4 ) {
\n\n
'
)
file
.
write
(
'
\t\t
var uv = [];
\n
'
)
file
.
write
(
'
\t\t
uv.push( new THREE.UV( u1, v1 ) );
\n
'
)
file
.
write
(
'
\t\t
uv.push( new THREE.UV( u2, v2 ) );
\n
'
)
file
.
write
(
'
\t\t
uv.push( new THREE.UV( u3, v3 ) );
\n
'
)
file
.
write
(
'
\t\t
if ( u4 && v4 ) uv.push( new THREE.UV( u4, v4 ) );
\n
'
)
file
.
write
(
'
\t\t
scope.uvs.push( uv );
\n
'
)
file
.
write
(
'
\t
}
\n\n
'
)
file
.
write
(
'}
\n\n
'
)
...
...
utils/export_threejs_25b.py
浏览文件 @
b3812029
...
...
@@ -70,7 +70,7 @@ def write(filename, scene, ob, \
active_col_layer
=
active_col_layer
.
data
# incase
color
=
uvcoord
=
uvcoord_key
=
normal
=
normal_key
=
None
color
=
uvcoord
=
uvcoord_key
=
normal
=
normal_key
=
None
file
.
write
(
'var %s = function () {
\n\n
'
%
classname
)
...
...
@@ -82,24 +82,23 @@ def write(filename, scene, ob, \
file
.
write
(
'
\t
v( %.6f, %.6f, %.6f );
\n
'
%
(
v
.
co
.
x
,
v
.
co
.
z
,
-
v
.
co
.
y
))
# co
file
.
write
(
'
\n
'
)
if
EXPORT_NORMALS
:
for
f
in
mesh
.
faces
:
if
len
(
f
.
verts
)
==
3
:
file
.
write
(
'
\t
f3n( %d, %d, %d, %.6f, %.6f, %.6f );
\n
'
%
(
f
.
verts
[
0
],
f
.
verts
[
1
],
f
.
verts
[
2
],
f
.
normal
[
0
],
f
.
normal
[
1
],
f
.
normal
[
2
]))
else
:
file
.
write
(
'
\t
f
3n( %d, %d, %d, %.6f, %.6f, %.6f );
\n
'
%
(
f
.
verts
[
3
],
f
.
verts
[
1
],
f
.
verts
[
2
],
f
.
normal
[
0
],
f
.
normal
[
1
],
f
.
normal
[
2
]))
file
.
write
(
'
\t
f3n( %d, %d, %d, %.6f, %.6f, %.6f );
\n
'
%
(
f
.
verts
[
1
],
f
.
verts
[
3
],
f
.
verts
[
0
],
f
.
normal
[
0
],
f
.
normal
[
1
],
f
.
normal
[
2
]))
file
.
write
(
'
\t
f
4( %d, %d, %d, %d, %.6f, %.6f, %.6f );
\n
'
%
(
f
.
verts
[
0
],
f
.
verts
[
1
],
f
.
verts
[
2
],
f
.
verts
[
3
],
f
.
normal
[
0
],
f
.
normal
[
1
],
f
.
normal
[
2
]))
else
:
for
f
in
mesh
.
faces
:
if
len
(
f
.
verts
)
==
3
:
file
.
write
(
'
\t
f3( %d, %d, %d );
\n
'
%
(
f
.
verts
[
0
],
f
.
verts
[
1
],
f
.
verts
[
2
]))
else
:
file
.
write
(
'
\t
f3( %d, %d, %d );
\n
'
%
(
f
.
verts
[
2
],
f
.
verts
[
1
],
f
.
verts
[
3
]))
file
.
write
(
'
\t
f3( %d, %d, %d );
\n
'
%
(
f
.
verts
[
0
],
f
.
verts
[
3
],
f
.
verts
[
1
]))
file
.
write
(
'
\t
f4( %d, %d, %d, %d );
\n
'
%
(
f
.
verts
[
0
],
f
.
verts
[
1
],
f
.
verts
[
2
],
f
.
verts
[
3
]))
face_index_pairs
=
[
(
face
,
index
)
for
index
,
face
in
enumerate
(
mesh
.
faces
)]
if
EXPORT_UV
:
file
.
write
(
'
\n
'
)
for
f
,
f_index
in
face_index_pairs
:
...
...
@@ -107,29 +106,29 @@ def write(filename, scene, ob, \
if
len
(
f
.
verts
)
==
3
:
file
.
write
(
'
\t
uv( %.6f, %.6f, %.6f, %.6f, %.6f, %.6f );
\n
'
%
(
tface
.
uv1
[
0
],
1.0
-
tface
.
uv1
[
1
],
tface
.
uv2
[
0
],
1.0
-
tface
.
uv2
[
1
],
tface
.
uv3
[
0
],
1.0
-
tface
.
uv3
[
1
]))
else
:
file
.
write
(
'
\t
uv( %.6f, %.6f, %.6f, %.6f, %.6f, %.6f );
\n
'
%
(
tface
.
uv4
[
0
],
1.0
-
tface
.
uv4
[
1
],
tface
.
uv2
[
0
],
1.0
-
tface
.
uv2
[
1
],
tface
.
uv3
[
0
],
1.0
-
tface
.
uv3
[
1
]))
file
.
write
(
'
\t
uv( %.6f, %.6f, %.6f, %.6f, %.6f, %.6f );
\n
'
%
(
tface
.
uv2
[
0
],
1.0
-
tface
.
uv2
[
1
],
tface
.
uv4
[
0
],
1.0
-
tface
.
uv4
[
1
],
tface
.
uv1
[
0
],
1.0
-
tface
.
uv1
[
1
]))
file
.
write
(
'
\t
uv( %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f );
\n
'
%
(
tface
.
uv1
[
0
],
1.0
-
tface
.
uv1
[
1
],
tface
.
uv2
[
0
],
1.0
-
tface
.
uv2
[
1
],
tface
.
uv3
[
0
],
1.0
-
tface
.
uv3
[
1
],
tface
.
uv4
[
0
],
1.0
-
tface
.
uv4
[
1
]))
file
.
write
(
'
\n
'
)
file
.
write
(
'
\t
function v( x, y, z ) {
\n\n
'
)
file
.
write
(
'
\t\t
scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
\n\n
'
)
file
.
write
(
'
\t
}
\n\n
'
)
file
.
write
(
'
\t
function f3( a, b, c ) {
\n\n
'
)
file
.
write
(
'
\t\t
scope.faces.push( new THREE.Face3( a, b, c ) );
\n\n
'
)
file
.
write
(
'
\t
function f3( a, b, c
, nx, ny, nz
) {
\n\n
'
)
file
.
write
(
'
\t\t
scope.faces.push( new THREE.Face3( a, b, c
, nx && ny && nz ? new THREE.Vector3( nx, ny, nz ) : null
) );
\n\n
'
)
file
.
write
(
'
\t
}
\n\n
'
)
file
.
write
(
'
\t
function f
3n( a, b, c
, nx, ny, nz ) {
\n\n
'
)
file
.
write
(
'
\t\t
scope.faces.push( new THREE.Face
3( a, b, c, new THREE.Vector3( nx, ny, nz )
) );
\n\n
'
)
file
.
write
(
'
\t
function f
4( a, b, c, d
, nx, ny, nz ) {
\n\n
'
)
file
.
write
(
'
\t\t
scope.faces.push( new THREE.Face
4( a, b, c, d, nx && ny && nz ? new THREE.Vector3( nx, ny, nz ) : null
) );
\n\n
'
)
file
.
write
(
'
\t
}
\n\n
'
)
file
.
write
(
'
\t
function uv( u1, v1, u2, v2, u3, v3 ) {
\n\n
'
)
file
.
write
(
'
\t\t
scope.uvs.push( [
\n\n
'
)
file
.
write
(
'
\t\t\t
new THREE.Vector2( u1, v1 ),
\n
'
)
file
.
write
(
'
\t\t\t
new THREE.Vector2( u2, v2 ),
\n
'
)
file
.
write
(
'
\t\t\t
new THREE.Vector2( u3, v3 )
\n
'
)
file
.
write
(
'
\t\t
]);
\n
'
)
file
.
write
(
'
\t
function uv( u1, v1, u2, v2, u3, v3, u4, v4 ) {
\n\n
'
)
file
.
write
(
'
\t\t
var uv = [];
\n
'
)
file
.
write
(
'
\t\t
uv.push( new THREE.UV( u1, v1 ) );
\n
'
)
file
.
write
(
'
\t\t
uv.push( new THREE.UV( u2, v2 ) );
\n
'
)
file
.
write
(
'
\t\t
uv.push( new THREE.UV( u3, v3 ) );
\n
'
)
file
.
write
(
'
\t\t
if ( u4 && v4 ) uv.push( new THREE.UV( u4, v4 ) );
\n
'
)
file
.
write
(
'
\t\t
scope.uvs.push( uv );
\n
'
)
file
.
write
(
'
\t
}
\n\n
'
)
file
.
write
(
'}
\n\n
'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录