Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
85d3e312
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,发现更多精彩内容 >>
提交
85d3e312
编写于
9月 07, 2012
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'alteredq/dev' into dev
上级
b5d6cd92
e482b2d5
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
435 addition
and
372 deletion
+435
-372
build/three.min.js
build/three.min.js
+337
-336
examples/js/loaders/ctm/CTMLoader.js
examples/js/loaders/ctm/CTMLoader.js
+9
-8
examples/scenes/test_scene.js
examples/scenes/test_scene.js
+36
-7
examples/webgl_loader_ctm.html
examples/webgl_loader_ctm.html
+4
-6
examples/webgl_loader_ctm_materials.html
examples/webgl_loader_ctm_materials.html
+2
-3
examples/webgl_loader_scene.html
examples/webgl_loader_scene.html
+10
-0
src/loaders/SceneLoader.js
src/loaders/SceneLoader.js
+37
-12
未找到文件。
build/three.min.js
浏览文件 @
85d3e312
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
examples/js/loaders/ctm/CTMLoader.js
浏览文件 @
85d3e312
...
...
@@ -18,13 +18,13 @@ THREE.CTMLoader.prototype = Object.create( THREE.Loader.prototype );
// Load multiple CTM parts defined in JSON
THREE
.
CTMLoader
.
prototype
.
loadParts
=
function
(
url
,
callback
,
useWorker
,
useBuffers
,
basePath
)
{
THREE
.
CTMLoader
.
prototype
.
loadParts
=
function
(
url
,
callback
,
parameters
)
{
var
scope
=
this
;
var
xhr
=
new
XMLHttpRequest
();
basePath
=
basePath
?
basePath
:
this
.
extractUrlBase
(
url
);
var
basePath
=
parameters
.
basePath
?
parameters
.
basePath
:
this
.
extractUrlBase
(
url
);
xhr
.
onreadystatechange
=
function
()
{
...
...
@@ -62,7 +62,8 @@ THREE.CTMLoader.prototype.loadParts = function( url, callback, useWorker, useBuf
// load joined CTM file
var
partUrl
=
basePath
+
jsonObject
.
data
;
scope
.
load
(
partUrl
,
callbackFinal
,
useWorker
,
useBuffers
,
jsonObject
.
offsets
);
var
parametersPart
=
{
useWorker
:
parameters
.
useWorker
,
useBuffers
:
parameters
.
useBuffers
,
offsets
:
jsonObject
.
offsets
};
scope
.
load
(
partUrl
,
callbackFinal
,
parametersPart
);
}
...
...
@@ -82,11 +83,11 @@ THREE.CTMLoader.prototype.loadParts = function( url, callback, useWorker, useBuf
// - url (required)
// - callback (required)
THREE
.
CTMLoader
.
prototype
.
load
=
function
(
url
,
callback
,
useWorker
,
useBuffers
,
offset
s
)
{
THREE
.
CTMLoader
.
prototype
.
load
=
function
(
url
,
callback
,
parameter
s
)
{
var
scope
=
this
;
offsets
=
offsets
!==
undefined
?
offsets
:
[
0
];
var
offsets
=
parameters
.
offsets
!==
undefined
?
parameters
.
offsets
:
[
0
];
var
xhr
=
new
XMLHttpRequest
(),
callbackProgress
=
null
;
...
...
@@ -103,7 +104,7 @@ THREE.CTMLoader.prototype.load = function( url, callback, useWorker, useBuffers,
//var s = Date.now();
if
(
useWorker
)
{
if
(
parameters
.
useWorker
)
{
var
worker
=
new
Worker
(
"
js/loaders/ctm/CTMWorker.js
"
);
...
...
@@ -115,7 +116,7 @@ THREE.CTMLoader.prototype.load = function( url, callback, useWorker, useBuffers,
var
ctmFile
=
files
[
i
];
if
(
useBuffers
)
{
if
(
parameters
.
useBuffers
)
{
scope
.
createModelBuffers
(
ctmFile
,
callback
);
...
...
@@ -144,7 +145,7 @@ THREE.CTMLoader.prototype.load = function( url, callback, useWorker, useBuffers,
var
ctmFile
=
new
CTM
.
File
(
stream
);
if
(
useBuffers
)
{
if
(
parameters
.
useBuffers
)
{
scope
.
createModelBuffers
(
ctmFile
,
callback
);
...
...
examples/scenes/test_scene.js
浏览文件 @
85d3e312
...
...
@@ -36,7 +36,9 @@
"
position
"
:
[
-
30
,
-
5
,
25
],
"
rotation
"
:
[
0
,
0.8
,
0
],
"
scale
"
:
[
1
,
1
,
1
],
"
visible
"
:
true
"
visible
"
:
true
,
"
children
"
:
{
}
},
"
sphere_lambert
"
:
{
...
...
@@ -145,12 +147,21 @@
"
walt
"
:
{
"
geometry
"
:
"
WaltHead
"
,
"
materials
"
:
[
"
lambert_cube
"
],
"
position
"
:
[
-
45
,
10
,
0
],
"
rotation
"
:
[
0
,
0
,
0
],
"
position
"
:
[
-
75
,
10
,
-
3
0
],
"
rotation
"
:
[
0
,
0
.5
,
0
],
"
scale
"
:
[
0.5
,
0.5
,
0.5
],
"
visible
"
:
true
},
"
ben
"
:
{
"
geometry
"
:
"
ben
"
,
"
materials
"
:
[
"
phong_ben
"
],
"
position
"
:
[
-
45
,
-
10
,
0
],
"
rotation
"
:
[
0
,
0.5
,
0
],
"
scale
"
:
[
55
,
55
,
55
],
"
visible
"
:
true
},
"
ninja
"
:
{
"
geometry
"
:
"
NinjaLo
"
,
"
materials
"
:
[
"
phong_normal
"
],
...
...
@@ -288,6 +299,13 @@
"
url
"
:
"
obj/veyron/VeyronNoUv_bin.js
"
},
"
ben
"
:
{
"
type
"
:
"
ctm_mesh
"
,
"
url
"
:
"
models/ctm/ben.ctm
"
,
"
useWorkers
"
:
true
,
"
useBuffers
"
:
true
},
"
colorcube
"
:
{
"
type
"
:
"
embedded_mesh
"
,
"
id
"
:
"
cube_fvc
"
...
...
@@ -355,9 +373,14 @@
"
parameters
"
:
{
"
color
"
:
16711680
,
"
specular
"
:
16711680
,
"
shininess
"
:
25
,
"
bumpMap
"
:
"
texture_bump
"
,
"
bumpScale
"
:
-
0.75
}
},
"
phong_ben
"
:
{
"
type
"
:
"
MeshPhongMaterial
"
,
"
parameters
"
:
{
"
color
"
:
1118481
,
"
ambient
"
:
1118481
,
"
specular
"
:
5601245
,
"
shininess
"
:
12
,
"
bumpMap
"
:
"
texture_bump_repeat
"
,
"
bumpScale
"
:
0.125
,
"
envMaps
"
:
"
cube_reflection
"
,
"
reflectivity
"
:
0.5
}
},
"
phong_normal
"
:
{
"
type
"
:
"
MeshPhongMaterial
"
,
"
parameters
"
:
{
"
color
"
:
1118481
,
"
specular
"
:
16777215
,
"
shininess
"
:
25
,
"
envMap
"
:
"
cube_reflection
"
,
"
reflectivity
"
:
0.1
,
"
lightMap
"
:
"
texture_ao
"
,
"
normalMap
"
:
"
texture_normal
"
,
"
normalScale
"
:
[
1
,
-
1
],
"
displacementMap
"
:
"
texture_displacement
"
,
"
displacementScale
"
:
2.436143
,
"
displacementBias
"
:
-
0.428408
}
"
parameters
"
:
{
"
color
"
:
0
,
"
specular
"
:
16777215
,
"
shininess
"
:
25
,
"
envMap
"
:
"
cube_reflection
"
,
"
reflectivity
"
:
0.1
,
"
lightMap
"
:
"
texture_ao
"
,
"
normalMap
"
:
"
texture_normal
"
,
"
normalScale
"
:
[
1
,
-
1
],
"
displacementMap
"
:
"
texture_displacement
"
,
"
displacementScale
"
:
2.436143
,
"
displacementBias
"
:
-
0.428408
}
},
"
lambert_green
"
:
{
...
...
@@ -465,6 +488,12 @@
"
anisotropy
"
:
4
},
"
texture_bump_repeat
"
:
{
"
url
"
:
"
textures/water.jpg
"
,
"
repeat
"
:
[
20
,
20
],
"
anisotropy
"
:
4
},
"
texture_normal
"
:
{
"
url
"
:
"
textures/normal/ninja/normal.jpg
"
,
"
anisotropy
"
:
4
...
...
@@ -518,15 +547,15 @@
"
type
"
:
"
directional
"
,
"
direction
"
:
[
0
,
1
,
1
],
"
color
"
:
16777215
,
"
intensity
"
:
0.8
"
intensity
"
:
1
},
"
light2
"
:
{
"
type
"
:
"
point
"
,
"
position
"
:
[
0
,
0
,
0
],
"
color
"
:
16777215
"
color
"
:
16777215
,
"
intensity
"
:
1.25
}
},
"
fogs
"
:
{
...
...
examples/webgl_loader_ctm.html
浏览文件 @
85d3e312
...
...
@@ -155,9 +155,7 @@
}
var
useWorker
=
true
;
var
useBuffers
=
true
;
var
parameters
=
{
useWorker
:
true
,
useBuffers
:
true
};
var
loader
=
new
THREE
.
CTMLoader
();
loader
.
load
(
"
models/ctm/ben.ctm
"
,
function
(
geometry
)
{
...
...
@@ -166,7 +164,7 @@
callbackModel
(
geometry
,
450
,
material
,
0
,
-
200
,
0
,
0
,
0
);
checkTime
();
},
useWorker
,
useBuff
ers
);
},
paramet
ers
);
loader
.
load
(
"
models/ctm/WaltHead.ctm
"
,
function
(
geometry
)
{
...
...
@@ -180,7 +178,7 @@
checkTime
();
},
useWorker
,
useBuff
ers
);
},
paramet
ers
);
loader
.
load
(
"
models/ctm/LeePerry.ctm
"
,
function
(
geometry
)
{
...
...
@@ -222,7 +220,7 @@
callbackModel
(
geometry
,
1300
,
material
,
200
,
50
,
0
,
0
,
0
);
checkTime
();
},
useWorker
,
useBuff
ers
);
},
paramet
ers
);
}
...
...
examples/webgl_loader_ctm_materials.html
浏览文件 @
85d3e312
...
...
@@ -196,8 +196,7 @@
*/
// new way via CTMLoader and separate parts
var
useWorker
=
true
,
useBuffers
=
true
;
var
parameters
=
{
useWorker
:
true
,
useBuffers
:
true
};
loaderCTM
=
new
THREE
.
CTMLoader
(
true
);
document
.
body
.
appendChild
(
loaderCTM
.
statusDomElement
);
...
...
@@ -224,7 +223,7 @@
console
.
log
(
"
load time:
"
,
end
-
start
,
"
ms
"
);
},
useWorker
,
useBuff
ers
);
},
paramet
ers
);
}
...
...
examples/webgl_loader_scene.html
浏览文件 @
85d3e312
...
...
@@ -149,6 +149,10 @@
<script
src=
"../build/three.min.js"
></script>
<script
src=
"js/loaders/ctm/lzma.js"
></script>
<script
src=
"js/loaders/ctm/ctm.js"
></script>
<script
src=
"js/loaders/ctm/CTMLoader.js"
></script>
<script
src=
"js/Detector.js"
></script>
<script
src=
"js/Stats.js"
></script>
...
...
@@ -230,6 +234,10 @@
renderer
.
domElement
.
style
.
position
=
"
relative
"
;
container
.
appendChild
(
renderer
.
domElement
);
renderer
.
gammaInput
=
true
;
renderer
.
gammaOutput
=
true
;
renderer
.
physicallyBasedShading
=
true
;
stats
=
new
Stats
();
stats
.
domElement
.
style
.
position
=
'
absolute
'
;
stats
.
domElement
.
style
.
top
=
'
0px
'
;
...
...
@@ -315,6 +323,8 @@
var
loader
=
new
THREE
.
SceneLoader
();
loader
.
addGeometryHandler
(
"
ctm_mesh
"
,
THREE
.
CTMLoader
);
loader
.
callbackSync
=
callbackSync
;
loader
.
callbackProgress
=
callbackProgress
;
...
...
src/loaders/SceneLoader.js
浏览文件 @
85d3e312
...
...
@@ -11,11 +11,16 @@ THREE.SceneLoader = function () {
this
.
callbackSync
=
function
()
{};
this
.
callbackProgress
=
function
()
{};
this
.
geometryHandlerMap
=
{};
this
.
addGeometryHandler
(
"
ascii_mesh
"
,
THREE
.
JSONLoader
);
this
.
addGeometryHandler
(
"
bin_mesh
"
,
THREE
.
BinaryLoader
);
};
THREE
.
SceneLoader
.
prototype
.
constructor
=
THREE
.
SceneLoader
;
THREE
.
SceneLoader
.
prototype
.
load
=
function
(
url
,
callbackFinished
)
{
THREE
.
SceneLoader
.
prototype
.
load
=
function
(
url
,
callbackFinished
)
{
var
scope
=
this
;
...
...
@@ -47,6 +52,12 @@ THREE.SceneLoader.prototype.load = function( url, callbackFinished ) {
};
THREE
.
SceneLoader
.
prototype
.
addGeometryHandler
=
function
(
typeID
,
loaderClass
)
{
this
.
geometryHandlerMap
[
typeID
]
=
{
"
loaderClass
"
:
loaderClass
};
};
THREE
.
SceneLoader
.
prototype
.
parse
=
function
(
json
,
callbackFinished
,
url
)
{
var
scope
=
this
;
...
...
@@ -58,15 +69,20 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
geometry
,
material
,
camera
,
fog
,
texture
,
images
,
light
,
data
,
binLoader
,
jsonLoader
,
counter_models
,
counter_textures
,
total_models
,
total_textures
,
result
;
data
=
json
;
var
data
=
json
;
// async geometry loaders
for
(
var
typeID
in
this
.
geometryHandlerMap
)
{
binLoader
=
new
THREE
.
BinaryLoader
();
jsonLoader
=
new
THREE
.
JSONLoader
();
var
loaderClass
=
this
.
geometryHandlerMap
[
typeID
][
"
loaderClass
"
];
this
.
geometryHandlerMap
[
typeID
][
"
loaderObject
"
]
=
new
loaderClass
();
}
counter_models
=
0
;
counter_textures
=
0
;
...
...
@@ -123,7 +139,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
};
// t
he t
oplevel loader function, delegates to handle_children
// toplevel loader function, delegates to handle_children
function
handle_objects
()
{
...
...
@@ -273,7 +289,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
}
if
(
o
.
properties
!==
undefined
)
{
if
(
o
.
properties
!==
undefined
)
{
for
(
var
key
in
o
.
properties
)
{
...
...
@@ -495,7 +511,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
g
=
data
.
geometries
[
dg
];
if
(
g
.
type
==
"
bin_mesh
"
||
g
.
type
==
"
ascii_mesh
"
)
{
if
(
g
.
type
in
this
.
geometryHandlerMap
)
{
counter_models
+=
1
;
...
...
@@ -541,13 +557,21 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
geometry
=
new
THREE
.
IcosahedronGeometry
(
g
.
radius
,
g
.
subdivisions
);
result
.
geometries
[
dg
]
=
geometry
;
}
else
if
(
g
.
type
===
"
bin_mesh
"
)
{
}
else
if
(
g
.
type
in
this
.
geometryHandlerMap
)
{
var
loaderParameters
=
{};
for
(
var
parType
in
g
)
{
if
(
parType
!==
"
type
"
&&
parType
!==
"
url
"
)
{
binLoader
.
load
(
get_url
(
g
.
url
,
data
.
urlBaseType
),
create_callback
(
dg
)
)
;
loaderParameters
[
parType
]
=
g
[
parType
]
;
}
else
if
(
g
.
type
===
"
ascii_mesh
"
)
{
}
}
jsonLoader
.
load
(
get_url
(
g
.
url
,
data
.
urlBaseType
),
create_callback
(
dg
)
);
var
loader
=
this
.
geometryHandlerMap
[
g
.
type
][
"
loaderObject
"
];
loader
.
load
(
get_url
(
g
.
url
,
data
.
urlBaseType
),
create_callback
(
dg
),
loaderParameters
);
}
else
if
(
g
.
type
===
"
embedded_mesh
"
)
{
...
...
@@ -560,6 +584,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
if
(
modelJson
)
{
var
jsonLoader
=
this
.
geometryHandlerMap
[
"
ascii_mesh
"
][
"
loaderObject
"
];
jsonLoader
.
createModel
(
modelJson
,
create_callback_embed
(
dg
),
texture_path
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录