Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
b11e457e
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 搜索 >>
提交
b11e457e
编写于
11月 15, 2012
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed loading of models which were using normalmap materials inside MeshFaceMaterials.
上级
bf8bc4b0
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
90 addition
and
70 deletion
+90
-70
build/three.js
build/three.js
+30
-20
build/three.min.js
build/three.min.js
+30
-30
src/loaders/BinaryLoader.js
src/loaders/BinaryLoader.js
+7
-4
src/loaders/JSONLoader.js
src/loaders/JSONLoader.js
+2
-3
src/loaders/Loader.js
src/loaders/Loader.js
+3
-5
src/loaders/SceneLoader.js
src/loaders/SceneLoader.js
+18
-8
未找到文件。
build/three.js
浏览文件 @
b11e457e
...
...
@@ -6846,13 +6846,11 @@ THREE.Loader.prototype = {
},
hasNormals: function ( scope
) {
needsTangents: function ( materials
) {
var m, i, il = scope.materials.length;
for( var i = 0, il = materials.length; i < il; i ++ ) {
for( i = 0; i < il; i ++ ) {
m = scope.materials[ i ];
var m = materials[ i ];
if ( m instanceof THREE.ShaderMaterial ) return true;
...
...
@@ -7318,7 +7316,7 @@ THREE.BinaryLoader.prototype.loadAjaxBuffers = function ( json, callback, binary
// Binary AJAX parser
THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texturePath,
m
aterials ) {
THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texturePath,
jsonM
aterials ) {
var Model = function ( texturePath ) {
...
...
@@ -7399,8 +7397,6 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
this.computeCentroids();
this.computeFaceNormals();
if ( THREE.Loader.prototype.hasNormals( this ) ) this.computeTangents();
function handlePadding( n ) {
return ( n % 4 ) ? ( 4 - n % 4 ) : 0;
...
...
@@ -7961,7 +7957,12 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
Model.prototype = Object.create( THREE.Geometry.prototype );
callback( new Model( texturePath ), this.initMaterials( materials, texturePath ) );
var geometry = new Model( texturePath );
var materials = this.initMaterials( jsonMaterials, texturePath );
if ( this.needsTangents( materials ) ) geometry.computeTangents();
callback( geometry, materials );
};
/**
...
...
@@ -8111,9 +8112,6 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texturePath
geometry.computeCentroids();
geometry.computeFaceNormals();
if ( this.hasNormals( geometry ) ) geometry.computeTangents();
function parseModel( scale ) {
function isBitSet( value, position ) {
...
...
@@ -8431,6 +8429,8 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texturePath
var materials = this.initMaterials( json.materials, texturePath );
if ( this.needsTangents( materials ) ) geometry.computeTangents();
callback( geometry, materials );
};
...
...
@@ -8706,16 +8706,10 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
if ( geometry ) {
var
hasNormal
s = false;
var
needsTangent
s = false;
material = result.materials[ o.material ];
hasNormals = material instanceof THREE.ShaderMaterial;
if ( hasNormals ) {
geometry.computeTangents();
}
needsTangents = material instanceof THREE.ShaderMaterial;
p = o.position;
r = o.rotation;
...
...
@@ -8746,6 +8740,22 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
}
if ( material instanceof THREE.MeshFaceMaterial ) {
for ( var i = 0; i < material.materials.length; i ++ ) {
needsTangents = needsTangents || ( material.materials[ i ] instanceof THREE.ShaderMaterial );
}
}
if ( needsTangents ) {
geometry.computeTangents();
}
if ( o.skin ) {
object = new THREE.SkinnedMesh( geometry, material );
...
...
build/three.min.js
浏览文件 @
b11e457e
此差异已折叠。
点击以展开。
src/loaders/BinaryLoader.js
浏览文件 @
b11e457e
...
...
@@ -116,7 +116,7 @@ THREE.BinaryLoader.prototype.loadAjaxBuffers = function ( json, callback, binary
// Binary AJAX parser
THREE
.
BinaryLoader
.
prototype
.
createBinModel
=
function
(
data
,
callback
,
texturePath
,
m
aterials
)
{
THREE
.
BinaryLoader
.
prototype
.
createBinModel
=
function
(
data
,
callback
,
texturePath
,
jsonM
aterials
)
{
var
Model
=
function
(
texturePath
)
{
...
...
@@ -197,8 +197,6 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
this
.
computeCentroids
();
this
.
computeFaceNormals
();
if
(
THREE
.
Loader
.
prototype
.
hasNormals
(
this
)
)
this
.
computeTangents
();
function
handlePadding
(
n
)
{
return
(
n
%
4
)
?
(
4
-
n
%
4
)
:
0
;
...
...
@@ -759,6 +757,11 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
Model
.
prototype
=
Object
.
create
(
THREE
.
Geometry
.
prototype
);
callback
(
new
Model
(
texturePath
),
this
.
initMaterials
(
materials
,
texturePath
)
);
var
geometry
=
new
Model
(
texturePath
);
var
materials
=
this
.
initMaterials
(
jsonMaterials
,
texturePath
);
if
(
this
.
needsTangents
(
materials
)
)
geometry
.
computeTangents
();
callback
(
geometry
,
materials
);
};
src/loaders/JSONLoader.js
浏览文件 @
b11e457e
...
...
@@ -104,9 +104,6 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texturePath
geometry
.
computeCentroids
();
geometry
.
computeFaceNormals
();
if
(
this
.
hasNormals
(
geometry
)
)
geometry
.
computeTangents
();
function
parseModel
(
scale
)
{
function
isBitSet
(
value
,
position
)
{
...
...
@@ -424,6 +421,8 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texturePath
var
materials
=
this
.
initMaterials
(
json
.
materials
,
texturePath
);
if
(
this
.
needsTangents
(
materials
)
)
geometry
.
computeTangents
();
callback
(
geometry
,
materials
);
};
src/loaders/Loader.js
浏览文件 @
b11e457e
...
...
@@ -81,13 +81,11 @@ THREE.Loader.prototype = {
},
hasNormals
:
function
(
scope
)
{
needsTangents
:
function
(
materials
)
{
var
m
,
i
,
il
=
scope
.
materials
.
length
;
for
(
var
i
=
0
,
il
=
materials
.
length
;
i
<
il
;
i
++
)
{
for
(
i
=
0
;
i
<
il
;
i
++
)
{
m
=
scope
.
materials
[
i
];
var
m
=
materials
[
i
];
if
(
m
instanceof
THREE
.
ShaderMaterial
)
return
true
;
...
...
src/loaders/SceneLoader.js
浏览文件 @
b11e457e
...
...
@@ -234,16 +234,10 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
if
(
geometry
)
{
var
hasNormal
s
=
false
;
var
needsTangent
s
=
false
;
material
=
result
.
materials
[
o
.
material
];
hasNormals
=
material
instanceof
THREE
.
ShaderMaterial
;
if
(
hasNormals
)
{
geometry
.
computeTangents
();
}
needsTangents
=
material
instanceof
THREE
.
ShaderMaterial
;
p
=
o
.
position
;
r
=
o
.
rotation
;
...
...
@@ -274,6 +268,22 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
}
if
(
material
instanceof
THREE
.
MeshFaceMaterial
)
{
for
(
var
i
=
0
;
i
<
material
.
materials
.
length
;
i
++
)
{
needsTangents
=
needsTangents
||
(
material
.
materials
[
i
]
instanceof
THREE
.
ShaderMaterial
);
}
}
if
(
needsTangents
)
{
geometry
.
computeTangents
();
}
if
(
o
.
skin
)
{
object
=
new
THREE
.
SkinnedMesh
(
geometry
,
material
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录