Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
1d439d02
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,发现更多精彩内容 >>
提交
1d439d02
编写于
4月 08, 2014
作者:
M
Michael Guerrero
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' of
https://github.com/mrdoob/three.js
into blending-take2
上级
12edee29
b4fb0ab0
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
511 addition
and
358 deletion
+511
-358
build/three.js
build/three.js
+187
-51
build/three.min.js
build/three.min.js
+290
-287
examples/js/loaders/STLLoader.js
examples/js/loaders/STLLoader.js
+9
-11
examples/webgl_geometry_minecraft.html
examples/webgl_geometry_minecraft.html
+2
-2
src/core/Geometry2.js
src/core/Geometry2.js
+10
-6
src/core/IndexedGeometry2.js
src/core/IndexedGeometry2.js
+5
-0
src/extras/geometries/CircleGeometry.js
src/extras/geometries/CircleGeometry.js
+3
-1
src/extras/renderers/plugins/ShadowMapPlugin.js
src/extras/renderers/plugins/ShadowMapPlugin.js
+2
-0
src/renderers/webgl/WebGLShader.js
src/renderers/webgl/WebGLShader.js
+3
-0
未找到文件。
build/three.js
浏览文件 @
1d439d02
...
...
@@ -4133,23 +4133,26 @@ THREE.Matrix3.prototype = {
var v1 = new THREE.Vector3();
return function ( a ) {
return function ( a
rray, offset, length
) {
for ( var i = 0, il = a.length; i < il; i += 3 ) {
if ( offset === undefined ) offset = 0;
if ( length === undefined ) length = array.length;
v1.x = a[ i ];
v1.y = a[ i + 1 ];
v1.z = a[ i + 2 ];
for ( var i = 0, j = offset, il; i < length; i += 3, j += 3 ) {
v1.x = array[ j ];
v1.y = array[ j + 1 ];
v1.z = array[ j + 2 ];
v1.applyMatrix3( this );
a
[ i
] = v1.x;
a
[ i
+ 1 ] = v1.y;
a
[ i
+ 2 ] = v1.z;
a
rray[ j
] = v1.x;
a
rray[ j
+ 1 ] = v1.y;
a
rray[ j
+ 2 ] = v1.z;
}
return a;
return a
rray
;
};
...
...
@@ -4763,23 +4766,26 @@ THREE.Matrix4.prototype = {
var v1 = new THREE.Vector3();
return function ( a ) {
return function ( array, offset, length ) {
if ( offset === undefined ) offset = 0;
if ( length === undefined ) length = array.length;
for ( var i = 0,
il = a.length; i < il; i
+= 3 ) {
for ( var i = 0,
j = offset, il; i < length; i += 3, j
+= 3 ) {
v1.x = a
[ i
];
v1.y = a
[ i
+ 1 ];
v1.z = a
[ i
+ 2 ];
v1.x = a
rray[ j
];
v1.y = a
rray[ j
+ 1 ];
v1.z = a
rray[ j
+ 2 ];
v1.applyMatrix4( this );
a
[ i
] = v1.x;
a
[ i
+ 1 ] = v1.y;
a
[ i
+ 2 ] = v1.z;
a
rray[ j
] = v1.x;
a
rray[ j
+ 1 ] = v1.y;
a
rray[ j
+ 2 ] = v1.z;
}
return a;
return a
rray
;
};
...
...
@@ -9495,28 +9501,6 @@ THREE.BufferGeometry.prototype = {
},
normalizeNormals: function () {
var normals = this.attributes[ "normal" ].array;
var x, y, z, n;
for ( var i = 0, il = normals.length; i < il; i += 3 ) {
x = normals[ i ];
y = normals[ i + 1 ];
z = normals[ i + 2 ];
n = 1.0 / Math.sqrt( x * x + y * y + z * z );
normals[ i ] *= n;
normals[ i + 1 ] *= n;
normals[ i + 2 ] *= n;
}
},
computeTangents: function () {
// based on http://www.terathon.com/code/tangent.html
...
...
@@ -9827,6 +9811,34 @@ THREE.BufferGeometry.prototype = {
return offsets;
},
merge: function () {
console.log( 'BufferGeometry.merge(): TODO' );
},
normalizeNormals: function () {
var normals = this.attributes[ "normal" ].array;
var x, y, z, n;
for ( var i = 0, il = normals.length; i < il; i += 3 ) {
x = normals[ i ];
y = normals[ i + 1 ];
z = normals[ i + 2 ];
n = 1.0 / Math.sqrt( x * x + y * y + z * z );
normals[ i ] *= n;
normals[ i + 1 ] *= n;
normals[ i + 2 ] *= n;
}
},
/*
reoderBuffers:
Reorder attributes based on a new indexBuffer and indexMap.
...
...
@@ -9943,34 +9955,150 @@ THREE.EventDispatcher.prototype.apply( THREE.BufferGeometry.prototype );
* @author mrdoob / http://mrdoob.com/
*/
THREE.Geometry2 = function (
vertices, normals, uvs
) {
THREE.Geometry2 = function (
size
) {
THREE.BufferGeometry.call( this );
if ( size !== undefined ) {
this.vertices = new Float32Array( size * 3 * 3 );
this.normals = new Float32Array( size * 3 * 3 );
this.uvs = new Float32Array( size * 3 * 2 );
this.attributes[ 'position' ] = { array: this.vertices, itemSize: 3 };
this.attributes[ 'normal' ] = { array: this.normals, itemSize: 3 };
this.attributes[ 'uv' ] = { array: this.uvs, itemSize: 2 };
}
};
THREE.Geometry2.prototype = Object.create( THREE.BufferGeometry.prototype );
THREE.Geometry2.prototype.setArrays = function ( vertices, normals, uvs ) {
this.vertices = vertices;
this.normals = normals;
this.uvs = uvs;
this.attributes[ 'position' ] = { array: vertices, itemSize: 3 };
this.attributes[ 'normal' ] = { array: normals, itemSize: 3 };
this.attributes[ 'uv' ] = { array: uvs, itemSize: 2 };
this.attributes[ 'uv' ] = { array: uvs, itemSize: 2 };
return this;
};
THREE.Geometry2.prototype = Object.create( THREE.BufferGeometry.prototype );
THREE.Geometry2.prototype.merge = ( function () {
var offset = 0;
var normalMatrix = new THREE.Matrix3();
return function ( geometry, matrix, startOffset ) {
if ( startOffset !== undefined ) offset = startOffset;
var offset2 = offset * 2;
var offset3 = offset * 3;
var vertices = this.attributes[ 'position' ].array;
var normals = this.attributes[ 'normal' ].array;
var uvs = this.attributes[ 'uv' ].array;
if ( geometry instanceof THREE.Geometry2 ) {
var vertices2 = geometry.attributes[ 'position' ].array;
var normals2 = geometry.attributes[ 'normal' ].array;
var uvs2 = geometry.attributes[ 'uv' ].array;
for ( var i = 0, l = vertices2.length; i < l; i += 3 ) {
vertices[ i + offset3 ] = vertices2[ i ];
vertices[ i + offset3 + 1 ] = vertices2[ i + 1 ];
vertices[ i + offset3 + 2 ] = vertices2[ i + 2 ];
normals[ i + offset3 ] = normals2[ i ];
normals[ i + offset3 + 1 ] = normals2[ i + 1 ];
normals[ i + offset3 + 2 ] = normals2[ i + 2 ];
uvs[ i + offset2 ] = uvs2[ i ];
uvs[ i + offset2 + 1 ] = uvs2[ i + 1 ];
}
} else if ( geometry instanceof THREE.IndexedGeometry2 ) {
var indices2 = geometry.attributes[ 'index' ].array;
var vertices2 = geometry.attributes[ 'position' ].array;
var normals2 = geometry.attributes[ 'normal' ].array;
var uvs2 = geometry.attributes[ 'uv' ].array;
for ( var i = 0, l = indices2.length; i < l; i ++ ) {
var index = indices2[ i ];
var index3 = index * 3;
var i3 = i * 3;
vertices[ i3 + offset3 ] = vertices2[ index3 ];
vertices[ i3 + offset3 + 1 ] = vertices2[ index3 + 1 ];
vertices[ i3 + offset3 + 2 ] = vertices2[ index3 + 2 ];
normals[ i3 + offset3 ] = normals2[ index3 ];
normals[ i3 + offset3 + 1 ] = normals2[ index3 + 1 ];
normals[ i3 + offset3 + 2 ] = normals2[ index3 + 2 ];
var index2 = index * 2;
var i2 = i * 2;
uvs[ i2 + offset2 ] = uvs2[ index2 ];
uvs[ i2 + offset2 + 1 ] = uvs2[ index2 + 1 ];
}
if ( matrix !== undefined ) {
matrix.applyToVector3Array( vertices, offset3, indices2.length * 3 );
normalMatrix.getNormalMatrix( matrix );
normalMatrix.applyToVector3Array( normals, offset3, indices2.length * 3 );
}
offset += indices2.length;
}
};
} )();
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.IndexedGeometry2 = function (
indices, vertices, normals, uvs
) {
THREE.IndexedGeometry2 = function () {
THREE.BufferGeometry.call( this );
};
THREE.IndexedGeometry2.prototype = Object.create( THREE.BufferGeometry.prototype );
THREE.IndexedGeometry2.prototype.setArrays = function ( indices, vertices, normals, uvs ) {
this.indices = indices;
this.vertices = vertices;
this.normals = normals;
this.uvs = uvs;
this.attributes[ 'index' ] = { array: indices, itemSize: 1 };
this.attributes[ 'position' ] = { array: vertices, itemSize: 3 };
this.attributes[ 'normal' ] = { array: normals, itemSize: 3 };
this.attributes[ 'uv' ] = { array: uvs, itemSize: 2 };
};
THREE.IndexedGeometry2.prototype = Object.create( THREE.BufferGeometry.prototype );
return this;
};
/**
* @author mrdoob / http://mrdoob.com/
* @author kile / http://kile.stravaganza.org/
...
...
@@ -10223,8 +10351,6 @@ THREE.Geometry.prototype = {
for ( f = 0, fl = this.faces.length; f < fl; f ++ ) {
face = this.faces[ f ];
faceNormal = new THREE.Vector3();
vertexNormals = { a: new THREE.Vector3(), b: new THREE.Vector3(), c: new THREE.Vector3() };
...
...
@@ -28539,6 +28665,9 @@ THREE.WebGLShader = ( function () {
}
// --enable-privileged-webgl-extension
// console.log( type, gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );
return shader;
};
...
...
@@ -33866,7 +33995,9 @@ THREE.CircleGeometry = function ( radius, segments, thetaStart, thetaLength ) {
}
THREE.IndexedGeometry2.call( this, indices, vertices, normals, uvs );
THREE.IndexedGeometry2.call( this );
this.setArrays( indices, vertices, normals, uvs );
this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
...
...
@@ -35068,7 +35199,10 @@ THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments )
}
THREE.IndexedGeometry2.call( this, indices, vertices, normals, uvs );
THREE.IndexedGeometry2.call( this );
this.setArrays( indices, vertices, normals, uvs );
this.computeBoundingSphere();
};
...
...
@@ -38458,6 +38592,8 @@ THREE.ShadowMapPlugin = function () {
}
_renderer.setMaterialFaces( objectMaterial );
if ( buffer instanceof THREE.BufferGeometry ) {
_renderer.renderBufferDirect( shadowCamera, scene.__lights, fog, material, buffer, object );
...
...
build/three.min.js
浏览文件 @
1d439d02
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
examples/js/loaders/STLLoader.js
浏览文件 @
1d439d02
...
...
@@ -106,12 +106,10 @@ THREE.STLLoader.prototype.parseBinary = function ( data ) {
var
dataOffset
=
84
;
var
faceLength
=
12
*
4
+
2
;
var
vertices
=
new
Float32Array
(
faces
*
3
*
3
);
var
normals
=
new
Float32Array
(
faces
*
3
*
3
);
var
uvs
=
new
Float32Array
(
faces
*
3
*
2
);
var
offset
=
0
;
var
geometry
=
new
THREE
.
Geometry2
(
faces
);
for
(
var
face
=
0
;
face
<
faces
;
face
++
)
{
var
start
=
dataOffset
+
face
*
faceLength
;
...
...
@@ -120,13 +118,13 @@ THREE.STLLoader.prototype.parseBinary = function ( data ) {
var
vertexstart
=
start
+
i
*
12
;
vertices
[
offset
]
=
reader
.
getFloat32
(
vertexstart
,
true
);
vertices
[
offset
+
1
]
=
reader
.
getFloat32
(
vertexstart
+
4
,
true
);
vertices
[
offset
+
2
]
=
reader
.
getFloat32
(
vertexstart
+
8
,
true
);
geometry
.
vertices
[
offset
]
=
reader
.
getFloat32
(
vertexstart
,
true
);
geometry
.
vertices
[
offset
+
1
]
=
reader
.
getFloat32
(
vertexstart
+
4
,
true
);
geometry
.
vertices
[
offset
+
2
]
=
reader
.
getFloat32
(
vertexstart
+
8
,
true
);
normals
[
offset
]
=
reader
.
getFloat32
(
start
,
true
);
normals
[
offset
+
1
]
=
reader
.
getFloat32
(
start
+
4
,
true
);
normals
[
offset
+
2
]
=
reader
.
getFloat32
(
start
+
8
,
true
);
geometry
.
normals
[
offset
]
=
reader
.
getFloat32
(
start
,
true
);
geometry
.
normals
[
offset
+
1
]
=
reader
.
getFloat32
(
start
+
4
,
true
);
geometry
.
normals
[
offset
+
2
]
=
reader
.
getFloat32
(
start
+
8
,
true
);
offset
+=
3
;
...
...
@@ -134,7 +132,7 @@ THREE.STLLoader.prototype.parseBinary = function ( data ) {
}
return
new
THREE
.
Geometry2
(
vertices
,
normals
,
uvs
)
;
return
geometry
;
};
...
...
examples/webgl_geometry_minecraft.html
浏览文件 @
1d439d02
...
...
@@ -107,8 +107,8 @@
nxGeometry
.
applyMatrix
(
matrix
.
makeTranslation
(
-
50
,
0
,
0
)
);
var
pyGeometry
=
new
THREE
.
PlaneGeometry
(
100
,
100
);
pyGeometry
.
attributes
.
uv
.
array
[
5
]
=
0.5
;
pyGeometry
.
attributes
.
uv
.
array
[
7
]
=
0.5
;
pyGeometry
.
uvs
[
5
]
=
0.5
;
pyGeometry
.
uvs
[
7
]
=
0.5
;
// pyGeometry.faceVertexUvs[ 0 ][ 0 ][ 1 ].y = 0.5;
// pyGeometry.faceVertexUvs[ 0 ][ 1 ][ 0 ].y = 0.5;
// pyGeometry.faceVertexUvs[ 0 ][ 1 ][ 1 ].y = 0.5;
...
...
src/core/Geometry2.js
浏览文件 @
1d439d02
...
...
@@ -8,13 +8,13 @@ THREE.Geometry2 = function ( size ) {
if
(
size
!==
undefined
)
{
var
vertices
=
new
Float32Array
(
size
*
3
*
3
);
var
normals
=
new
Float32Array
(
size
*
3
*
3
);
var
uvs
=
new
Float32Array
(
size
*
3
*
2
);
this
.
vertices
=
new
Float32Array
(
size
*
3
*
3
);
this
.
normals
=
new
Float32Array
(
size
*
3
*
3
);
this
.
uvs
=
new
Float32Array
(
size
*
3
*
2
);
this
.
attributes
[
'
position
'
]
=
{
array
:
vertices
,
itemSize
:
3
};
this
.
attributes
[
'
normal
'
]
=
{
array
:
normals
,
itemSize
:
3
};
this
.
attributes
[
'
uv
'
]
=
{
array
:
uvs
,
itemSize
:
2
};
this
.
attributes
[
'
position
'
]
=
{
array
:
this
.
vertices
,
itemSize
:
3
};
this
.
attributes
[
'
normal
'
]
=
{
array
:
this
.
normals
,
itemSize
:
3
};
this
.
attributes
[
'
uv
'
]
=
{
array
:
this
.
uvs
,
itemSize
:
2
};
}
...
...
@@ -24,6 +24,10 @@ THREE.Geometry2.prototype = Object.create( THREE.BufferGeometry.prototype );
THREE
.
Geometry2
.
prototype
.
setArrays
=
function
(
vertices
,
normals
,
uvs
)
{
this
.
vertices
=
vertices
;
this
.
normals
=
normals
;
this
.
uvs
=
uvs
;
this
.
attributes
[
'
position
'
]
=
{
array
:
vertices
,
itemSize
:
3
};
this
.
attributes
[
'
normal
'
]
=
{
array
:
normals
,
itemSize
:
3
};
this
.
attributes
[
'
uv
'
]
=
{
array
:
uvs
,
itemSize
:
2
};
...
...
src/core/IndexedGeometry2.js
浏览文件 @
1d439d02
...
...
@@ -12,6 +12,11 @@ THREE.IndexedGeometry2.prototype = Object.create( THREE.BufferGeometry.prototype
THREE
.
IndexedGeometry2
.
prototype
.
setArrays
=
function
(
indices
,
vertices
,
normals
,
uvs
)
{
this
.
indices
=
indices
;
this
.
vertices
=
vertices
;
this
.
normals
=
normals
;
this
.
uvs
=
uvs
;
this
.
attributes
[
'
index
'
]
=
{
array
:
indices
,
itemSize
:
1
};
this
.
attributes
[
'
position
'
]
=
{
array
:
vertices
,
itemSize
:
3
};
this
.
attributes
[
'
normal
'
]
=
{
array
:
normals
,
itemSize
:
3
};
...
...
src/extras/geometries/CircleGeometry.js
浏览文件 @
1d439d02
...
...
@@ -64,7 +64,9 @@ THREE.CircleGeometry = function ( radius, segments, thetaStart, thetaLength ) {
}
THREE
.
IndexedGeometry2
.
call
(
this
,
indices
,
vertices
,
normals
,
uvs
);
THREE
.
IndexedGeometry2
.
call
(
this
);
this
.
setArrays
(
indices
,
vertices
,
normals
,
uvs
);
this
.
boundingSphere
=
new
THREE
.
Sphere
(
new
THREE
.
Vector3
(),
radius
);
...
...
src/extras/renderers/plugins/ShadowMapPlugin.js
浏览文件 @
1d439d02
...
...
@@ -298,6 +298,8 @@ THREE.ShadowMapPlugin = function () {
}
_renderer
.
setMaterialFaces
(
objectMaterial
);
if
(
buffer
instanceof
THREE
.
BufferGeometry
)
{
_renderer
.
renderBufferDirect
(
shadowCamera
,
scene
.
__lights
,
fog
,
material
,
buffer
,
object
);
...
...
src/renderers/webgl/WebGLShader.js
浏览文件 @
1d439d02
...
...
@@ -34,6 +34,9 @@ THREE.WebGLShader = ( function () {
}
// --enable-privileged-webgl-extension
// console.log( type, gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );
return
shader
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录