Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
2b599e1a
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,体验更适合开发者的 AI 搜索 >>
提交
2b599e1a
编写于
6月 15, 2011
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added support for texture repeat and offset in model JSONs to Loader base class.
上级
95966678
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
163 addition
and
135 deletion
+163
-135
build/Three.js
build/Three.js
+3
-2
build/custom/ThreeExtras.js
build/custom/ThreeExtras.js
+134
-133
src/extras/io/Loader.js
src/extras/io/Loader.js
+26
-0
未找到文件。
build/Three.js
浏览文件 @
2b599e1a
...
...
@@ -469,8 +469,9 @@ this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.p
THREE
.
Loader
.
prototype
=
{
addStatusElement
:
function
(){
var
b
=
document
.
createElement
(
"
div
"
);
b
.
style
.
position
=
"
absolute
"
;
b
.
style
.
right
=
"
0px
"
;
b
.
style
.
top
=
"
0px
"
;
b
.
style
.
fontSize
=
"
0.8em
"
;
b
.
style
.
textAlign
=
"
left
"
;
b
.
style
.
background
=
"
rgba(0,0,0,0.25)
"
;
b
.
style
.
color
=
"
#fff
"
;
b
.
style
.
width
=
"
120px
"
;
b
.
style
.
padding
=
"
0.5em 0.5em 0.5em 0.5em
"
;
b
.
style
.
zIndex
=
1
E3
;
b
.
innerHTML
=
"
Loading ...
"
;
return
b
},
updateProgress
:
function
(
b
){
var
c
=
"
Loaded
"
;
c
+=
b
.
total
?(
100
*
b
.
loaded
/
b
.
total
).
toFixed
(
0
)
+
"
%
"
:(
b
.
loaded
/
1
E3
).
toFixed
(
2
)
+
"
KB
"
;
this
.
statusDomElement
.
innerHTML
=
c
},
extractUrlbase
:
function
(
b
){
b
=
b
.
split
(
"
/
"
);
b
.
pop
();
return
b
.
join
(
"
/
"
)},
init_materials
:
function
(
b
,
c
,
d
){
b
.
materials
=
[];
for
(
var
e
=
0
;
e
<
c
.
length
;
++
e
)
b
.
materials
[
e
]
=
[
THREE
.
Loader
.
prototype
.
createMaterial
(
c
[
e
],
d
)]},
createMaterial
:
function
(
b
,
c
){
function
d
(
b
){
b
=
Math
.
log
(
b
)
/
Math
.
LN2
;
return
Math
.
floor
(
b
)
==
b
}
function
e
(
b
,
c
){
var
e
=
new
Image
;
e
.
onload
=
function
(){
if
(
!
d
(
this
.
width
)
||!
d
(
this
.
height
)){
var
c
=
Math
.
pow
(
2
,
Math
.
round
(
Math
.
log
(
this
.
width
)
/
Math
.
LN2
)),
e
=
Math
.
pow
(
2
,
Math
.
round
(
Math
.
log
(
this
.
height
)
/
Math
.
LN2
));
b
.
image
.
width
=
c
;
b
.
image
.
height
=
e
;
b
.
image
.
getContext
(
"
2d
"
).
drawImage
(
this
,
0
,
0
,
c
,
e
)}
else
b
.
image
=
this
;
b
.
needsUpdate
=!
0
};
e
.
src
=
c
}
var
f
,
g
,
j
;
f
=
"
MeshLambertMaterial
"
;
g
=
{
color
:
15658734
,
opacity
:
1
,
map
:
null
,
lightMap
:
null
,
wireframe
:
b
.
wireframe
};
b
.
shading
&&
(
b
.
shading
==
"
Phong
"
?
f
=
"
MeshPhongMaterial
"
:
b
.
shading
==
"
Basic
"
&&
(
f
=
"
MeshBasicMaterial
"
));
if
(
b
.
blending
)
if
(
b
.
blending
==
"
Additive
"
)
g
.
blending
=
THREE
.
AdditiveBlending
;
else
if
(
b
.
blending
==
"
Subtractive
"
)
g
.
blending
=
THREE
.
SubtractiveBlending
;
else
if
(
b
.
blending
==
"
Multiply
"
)
g
.
blending
=
THREE
.
MultiplyBlending
;
if
(
b
.
transparent
!==
void
0
||
b
.
opacity
<
1
)
g
.
transparent
=
b
.
transparent
;
if
(
b
.
depthTest
!==
void
0
)
g
.
depthTest
=
b
.
depthTest
;
if
(
b
.
vertexColors
!==
void
0
)
if
(
b
.
vertexColors
==
"
face
"
)
g
.
vertexColors
=
THREE
.
FaceColors
;
else
if
(
b
.
vertexColors
)
g
.
vertexColors
=
THREE
.
VertexColors
;
if
(
b
.
mapDiffuse
&&
c
)
j
=
document
.
createElement
(
"
canvas
"
),
g
.
map
=
new
THREE
.
Texture
(
j
),
g
.
map
.
sourceFile
=
b
.
mapDiffuse
,
e
(
g
.
map
,
c
+
"
/
"
+
b
.
mapDiffuse
);
else
if
(
b
.
colorDiffuse
)
j
=
(
b
.
colorDiffuse
[
0
]
*
255
<<
16
)
+
(
b
.
colorDiffuse
[
1
]
*
255
<<
8
)
+
b
.
colorDiffuse
[
2
]
*
255
,
g
.
color
=
j
,
g
.
opacity
=
b
.
transparency
;
else
if
(
b
.
DbgColor
)
g
.
color
=
b
.
DbgColor
;
if
(
b
.
mapLightmap
&&
c
)
j
=
document
.
createElement
(
"
canvas
"
),
g
.
lightMap
=
new
THREE
.
Texture
(
j
),
g
.
lightMap
.
sourceFile
=
b
.
mapLightmap
,
e
(
g
.
lightMap
,
c
+
"
/
"
+
b
.
mapLightmap
);
return
new
THREE
[
f
](
g
)}};
THREE
.
JSONLoader
=
function
(
b
){
THREE
.
Loader
.
call
(
this
,
b
)};
THREE
.
JSONLoader
.
prototype
=
new
THREE
.
Loader
;
THREE
.
JSONLoader
.
prototype
.
constructor
=
THREE
.
JSONLoader
;
THREE
.
JSONLoader
.
prototype
.
supr
=
THREE
.
Loader
.
prototype
;
"
Multiply
"
)
g
.
blending
=
THREE
.
MultiplyBlending
;
if
(
b
.
transparent
!==
void
0
||
b
.
opacity
<
1
)
g
.
transparent
=
b
.
transparent
;
if
(
b
.
depthTest
!==
void
0
)
g
.
depthTest
=
b
.
depthTest
;
if
(
b
.
vertexColors
!==
void
0
)
if
(
b
.
vertexColors
==
"
face
"
)
g
.
vertexColors
=
THREE
.
FaceColors
;
else
if
(
b
.
vertexColors
)
g
.
vertexColors
=
THREE
.
VertexColors
;
if
(
b
.
mapDiffuse
&&
c
){
j
=
document
.
createElement
(
"
canvas
"
);
g
.
map
=
new
THREE
.
Texture
(
j
);
g
.
map
.
sourceFile
=
b
.
mapDiffuse
;
if
(
b
.
mapDiffuseRepeat
)
g
.
map
.
repeat
.
set
(
b
.
mapDiffuseRepeat
[
0
],
b
.
mapDiffuseRepeat
[
1
]),
g
.
map
.
wrapS
=
g
.
map
.
wrapT
=
THREE
.
RepeatWrapping
;
b
.
mapDiffuseOffset
&&
g
.
map
.
offset
.
set
(
b
.
mapDiffuseOffset
[
0
],
b
.
mapDiffuseOffset
[
1
]);
e
(
g
.
map
,
c
+
"
/
"
+
b
.
mapDiffuse
)}
else
if
(
b
.
colorDiffuse
)
j
=
(
b
.
colorDiffuse
[
0
]
*
255
<<
16
)
+
(
b
.
colorDiffuse
[
1
]
*
255
<<
8
)
+
b
.
colorDiffuse
[
2
]
*
255
,
g
.
color
=
j
,
g
.
opacity
=
b
.
transparency
;
else
if
(
b
.
DbgColor
)
g
.
color
=
b
.
DbgColor
;
if
(
b
.
mapLightmap
&&
c
){
j
=
document
.
createElement
(
"
canvas
"
);
g
.
lightMap
=
new
THREE
.
Texture
(
j
);
g
.
lightMap
.
sourceFile
=
b
.
mapLightmap
;
if
(
b
.
mapLightmapRepeat
)
g
.
lightMap
.
repeat
.
set
(
b
.
mapLightmapRepeat
[
0
],
b
.
mapLightmapRepeat
[
1
]),
g
.
lightMap
.
wrapS
=
g
.
lightMap
.
wrapT
=
THREE
.
RepeatWrapping
;
b
.
mapLightmapOffset
&&
g
.
lightMap
.
offset
.
set
(
b
.
mapLightmapOffset
[
0
],
b
.
mapLightmapOffset
[
1
]);
e
(
g
.
lightMap
,
c
+
"
/
"
+
b
.
mapLightmap
)}
return
new
THREE
[
f
](
g
)}};
THREE
.
JSONLoader
=
function
(
b
){
THREE
.
Loader
.
call
(
this
,
b
)};
THREE
.
JSONLoader
.
prototype
=
new
THREE
.
Loader
;
THREE
.
JSONLoader
.
prototype
.
constructor
=
THREE
.
JSONLoader
;
THREE
.
JSONLoader
.
prototype
.
supr
=
THREE
.
Loader
.
prototype
;
THREE
.
JSONLoader
.
prototype
.
load
=
function
(
b
){
var
c
=
this
,
d
=
b
.
model
,
e
=
b
.
callback
,
f
=
b
.
texture_path
?
b
.
texture_path
:
this
.
extractUrlbase
(
d
),
b
=
new
Worker
(
d
);
b
.
onmessage
=
function
(
b
){
c
.
createModel
(
b
.
data
,
e
,
f
);
c
.
onLoadComplete
()};
this
.
onLoadStart
();
b
.
postMessage
((
new
Date
).
getTime
())};
THREE
.
JSONLoader
.
prototype
.
createModel
=
function
(
b
,
c
,
d
){
var
e
=
new
THREE
.
Geometry
,
f
=
b
.
scale
!==
void
0
?
1
/
b
.
scale
:
1
;
this
.
init_materials
(
e
,
b
.
materials
,
d
);(
function
(
c
){
if
(
b
.
version
===
void
0
||
b
.
version
!=
2
)
console
.
error
(
"
Deprecated file format.
"
);
else
{
var
d
,
f
,
m
,
o
,
n
,
p
,
t
,
u
,
v
,
z
,
A
,
x
,
G
,
y
,
D
=
b
.
faces
;
p
=
b
.
vertices
;
var
F
=
b
.
normals
,
B
=
b
.
colors
,
P
=
0
;
for
(
d
=
0
;
d
<
b
.
uvs
.
length
;
d
++
)
b
.
uvs
[
d
].
length
&&
P
++
;
for
(
d
=
0
;
d
<
P
;
d
++
)
e
.
faceUvs
[
d
]
=
[],
e
.
faceVertexUvs
[
d
]
=
[];
o
=
0
;
for
(
n
=
p
.
length
;
o
<
n
;)
t
=
new
THREE
.
Vertex
,
t
.
position
.
x
=
p
[
o
++
]
*
c
,
t
.
position
.
y
=
p
[
o
++
]
*
c
,
t
.
position
.
z
=
p
[
o
++
]
*
c
,
e
.
vertices
.
push
(
t
);
o
=
0
;
for
(
n
=
D
.
length
;
o
<
n
;){
c
=
D
[
o
++
];
p
=
c
&
1
;
m
=
c
&
2
;
d
=
c
&
4
;
f
=
c
&
8
;
u
=
c
&
16
;
t
=
c
&
32
;
z
=
c
&
64
;
c
&=
128
;
p
?(
A
=
new
THREE
.
Face4
,
A
.
a
=
D
[
o
++
],
A
.
b
=
D
[
o
++
],
A
.
c
=
D
[
o
++
],
A
.
d
=
D
[
o
++
],
p
=
4
):(
A
=
new
THREE
.
Face3
,
A
.
a
=
D
[
o
++
],
A
.
b
=
D
[
o
++
],
A
.
c
=
D
[
o
++
],
p
=
3
);
if
(
m
)
m
=
D
[
o
++
],
A
.
materials
=
e
.
materials
[
m
];
m
=
e
.
faces
.
length
;
if
(
d
)
for
(
d
=
0
;
d
<
P
;
d
++
)
x
=
b
.
uvs
[
d
],
v
=
D
[
o
++
],
y
=
x
[
v
*
2
],
v
=
x
[
v
*
2
+
1
],
e
.
faceUvs
[
d
][
m
]
=
new
THREE
.
UV
(
y
,
v
);
if
(
f
)
for
(
d
=
0
;
d
<
P
;
d
++
){
x
=
b
.
uvs
[
d
];
G
=
[];
for
(
f
=
0
;
f
<
p
;
f
++
)
v
=
D
[
o
++
],
y
=
x
[
v
*
2
],
v
=
x
[
v
*
2
+
1
],
G
[
f
]
=
...
...
build/custom/ThreeExtras.js
浏览文件 @
2b599e1a
此差异已折叠。
点击以展开。
src/extras/io/Loader.js
浏览文件 @
2b599e1a
...
...
@@ -180,6 +180,19 @@ THREE.Loader.prototype = {
mpars
.
map
=
new
THREE
.
Texture
(
texture
);
mpars
.
map
.
sourceFile
=
m
.
mapDiffuse
;
if
(
m
.
mapDiffuseRepeat
)
{
mpars
.
map
.
repeat
.
set
(
m
.
mapDiffuseRepeat
[
0
],
m
.
mapDiffuseRepeat
[
1
]
);
mpars
.
map
.
wrapS
=
mpars
.
map
.
wrapT
=
THREE
.
RepeatWrapping
;
}
if
(
m
.
mapDiffuseOffset
)
{
mpars
.
map
.
offset
.
set
(
m
.
mapDiffuseOffset
[
0
],
m
.
mapDiffuseOffset
[
1
]
);
}
load_image
(
mpars
.
map
,
texture_path
+
"
/
"
+
m
.
mapDiffuse
);
}
else
if
(
m
.
colorDiffuse
)
{
...
...
@@ -201,6 +214,19 @@ THREE.Loader.prototype = {
mpars
.
lightMap
=
new
THREE
.
Texture
(
texture
);
mpars
.
lightMap
.
sourceFile
=
m
.
mapLightmap
;
if
(
m
.
mapLightmapRepeat
)
{
mpars
.
lightMap
.
repeat
.
set
(
m
.
mapLightmapRepeat
[
0
],
m
.
mapLightmapRepeat
[
1
]
);
mpars
.
lightMap
.
wrapS
=
mpars
.
lightMap
.
wrapT
=
THREE
.
RepeatWrapping
;
}
if
(
m
.
mapLightmapOffset
)
{
mpars
.
lightMap
.
offset
.
set
(
m
.
mapLightmapOffset
[
0
],
m
.
mapLightmapOffset
[
1
]
);
}
load_image
(
mpars
.
lightMap
,
texture_path
+
"
/
"
+
m
.
mapLightmap
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录