Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
0d2d02c0
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,发现更多精彩内容 >>
提交
0d2d02c0
编写于
1月 27, 2014
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated builds.
上级
e91ebe3c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
539 addition
and
447 deletion
+539
-447
build/three.js
build/three.js
+215
-124
build/three.min.js
build/three.min.js
+324
-323
未找到文件。
build/three.js
浏览文件 @
0d2d02c0
...
@@ -7961,27 +7961,6 @@ THREE.Projector = function () {
...
@@ -7961,27 +7961,6 @@ THREE.Projector = function () {
};
};
var projectVertex = function ( vertex ) {
var position = vertex.position;
var positionWorld = vertex.positionWorld;
var positionScreen = vertex.positionScreen;
positionWorld.copy( position ).applyMatrix4( _modelMatrix );
positionScreen.copy( positionWorld ).applyMatrix4( _viewProjectionMatrix );
var invW = 1 / positionScreen.w;
positionScreen.x *= invW;
positionScreen.y *= invW;
positionScreen.z *= invW;
vertex.visible = positionScreen.x >= -1 && positionScreen.x <= 1 &&
positionScreen.y >= -1 && positionScreen.y <= 1 &&
positionScreen.z >= -1 && positionScreen.z <= 1;
};
var projectObject = function ( object ) {
var projectObject = function ( object ) {
if ( object.visible === false ) return;
if ( object.visible === false ) return;
...
@@ -8030,11 +8009,105 @@ THREE.Projector = function () {
...
@@ -8030,11 +8009,105 @@ THREE.Projector = function () {
};
};
var RenderState = function () {
var object = null;
var setObject = function ( value ) {
object = value;
};
var projectVertex = function ( vertex ) {
var position = vertex.position;
var positionWorld = vertex.positionWorld;
var positionScreen = vertex.positionScreen;
positionWorld.copy( position ).applyMatrix4( _modelMatrix );
positionScreen.copy( positionWorld ).applyMatrix4( _viewProjectionMatrix );
var invW = 1 / positionScreen.w;
positionScreen.x *= invW;
positionScreen.y *= invW;
positionScreen.z *= invW;
vertex.visible = positionScreen.x >= -1 && positionScreen.x <= 1 &&
positionScreen.y >= -1 && positionScreen.y <= 1 &&
positionScreen.z >= -1 && positionScreen.z <= 1;
};
var handleVertex = function ( x, y, z ) {
_vertex = getNextVertexInPool();
_vertex.position.set( x, y, z );
projectVertex( _vertex );
};
var checkTriangleVisibility = function ( v1, v2, v3 ) {
_points3[ 0 ] = v1.positionScreen;
_points3[ 1 ] = v2.positionScreen;
_points3[ 2 ] = v3.positionScreen;
if ( v1.visible === true || v2.visible === true || v3.visible === true ||
_clipBox.isIntersectionBox( _boundingBox.setFromPoints( _points3 ) ) ) {
return ( ( v3.positionScreen.x - v1.positionScreen.x ) *
( v2.positionScreen.y - v1.positionScreen.y ) -
( v3.positionScreen.y - v1.positionScreen.y ) *
( v2.positionScreen.x - v1.positionScreen.x ) ) < 0;
}
return false;
};
var handleTriangle = function ( a, b, c ) {
var v1 = _vertexPool[ a ];
var v2 = _vertexPool[ b ];
var v3 = _vertexPool[ c ];
if ( checkTriangleVisibility( v1, v2, v3 ) === true ) {
_face = getNextFace3InPool();
_face.id = object.id;
_face.v1.copy( v1 );
_face.v2.copy( v2 );
_face.v3.copy( v3 );
_face.material = object.material;
_renderData.elements.push( _face );
}
};
return {
setObject: setObject,
projectVertex: projectVertex,
checkTriangleVisibility: checkTriangleVisibility,
handleVertex: handleVertex,
handleTriangle: handleTriangle
}
};
var renderState = new RenderState();
this.projectScene = function ( scene, camera, sortObjects, sortElements ) {
this.projectScene = function ( scene, camera, sortObjects, sortElements ) {
var visible = false,
var object, geometry, vertices, faces, face, faceVertexNormals, faceVertexUvs, uvs,
object, geometry, vertices, faces, face, faceVertexNormals, faceVertexUvs, uvs,
isFaceMaterial, objectMaterials;
v1, v2, v3, v4, isFaceMaterial, objectMaterials;
_face3Count = 0;
_face3Count = 0;
_lineCount = 0;
_lineCount = 0;
...
@@ -8058,6 +8131,8 @@ THREE.Projector = function () {
...
@@ -8058,6 +8131,8 @@ THREE.Projector = function () {
object = _renderData.objects[ o ].object;
object = _renderData.objects[ o ].object;
renderState.setObject( object );
_modelMatrix = object.matrixWorld;
_modelMatrix = object.matrixWorld;
_vertexCount = 0;
_vertexCount = 0;
...
@@ -8066,176 +8141,192 @@ THREE.Projector = function () {
...
@@ -8066,176 +8141,192 @@ THREE.Projector = function () {
geometry = object.geometry;
geometry = object.geometry;
vertices = geometry.vertices;
if ( geometry instanceof THREE.BufferGeometry ) {
faces = geometry.faces;
faceVertexUvs = geometry.faceVertexUvs;
_normalMatrix.getNormalMatrix( _modelMatrix )
;
var attributes = geometry.attributes
;
isFaceMaterial = object.material instanceof THREE.MeshFaceMaterial;
if ( attributes.position !== undefined ) {
objectMaterials = isFaceMaterial === true ? object.material : null;
for ( var v = 0, vl = vertices.length; v < vl; v ++ ) {
var positions = attributes.position.array;
_vertex = getNextVertexInPool();
for ( var i = 0, l = positions.length; i < l; i += 3 ) {
_vertex.position.copy( vertices[ v ] );
projectVertex( _vertex
);
renderState.handleVertex( positions[ i ], positions[ i + 1 ], positions[ i + 2 ]
);
}
}
for ( var f = 0, fl = faces.length; f < fl; f ++
) {
if ( attributes.index !== undefined
) {
face = faces[ f ]
;
var indices = attributes.index.array
;
var material = isFaceMaterial === true
for ( var i = 0, l = indices.length; i < l; i += 3 ) {
? objectMaterials.materials[ face.materialIndex ]
: object.material;
if ( material === undefined ) continue
;
renderState.handleTriangle( indices[ i ], indices[ i + 1 ], indices[ i + 2 ] )
;
var side = material.side;
}
v1 = _vertexPool[ face.a ];
} else {
v2 = _vertexPool[ face.b ];
v3 = _vertexPool[ face.c ];
if ( material.morphTargets === true
) {
for ( var i = 0, l = positions.length; i < l; i += 3
) {
var morphTargets = geometry.morphTargets;
renderState.handleTriangle( i, i + 1, i + 2 );
var morphInfluences = object.morphTargetInfluences;
var v1p = v1.position;
}
var v2p = v2.position;
var v3p = v3.position;
_vA.set( 0, 0, 0 );
}
_vB.set( 0, 0, 0 );
_vC.set( 0, 0, 0 );
for ( var t = 0, tl = morphTargets.length; t < tl; t ++ ) {
}
var influence = morphInfluences[ t ];
} else if ( geometry instanceof THREE.Geometry ) {
if ( influence === 0 ) continue;
vertices = geometry.vertices;
faces = geometry.faces;
faceVertexUvs = geometry.faceVertexUvs;
var targets = morphTargets[ t ].vertices
;
_normalMatrix.getNormalMatrix( _modelMatrix )
;
_vA.x += ( targets[ face.a ].x - v1p.x ) * influence;
isFaceMaterial = object.material instanceof THREE.MeshFaceMaterial;
_vA.y += ( targets[ face.a ].y - v1p.y ) * influence;
objectMaterials = isFaceMaterial === true ? object.material : null;
_vA.z += ( targets[ face.a ].z - v1p.z ) * influence;
_vB.x += ( targets[ face.b ].x - v2p.x ) * influence;
for ( var v = 0, vl = vertices.length; v < vl; v ++ ) {
_vB.y += ( targets[ face.b ].y - v2p.y ) * influence;
_vB.z += ( targets[ face.b ].z - v2p.z ) * influence;
_vC.x += ( targets[ face.c ].x - v3p.x ) * influence;
var vertex = vertices[ v ];
_vC.y += ( targets[ face.c ].y - v3p.y ) * influence;
renderState.handleVertex( vertex.x, vertex.y, vertex.z );
_vC.z += ( targets[ face.c ].z - v3p.z ) * influence;
}
}
v1.position.add( _vA );
for ( var f = 0, fl = faces.length; f < fl; f ++ ) {
v2.position.add( _vB );
v3.position.add( _vC );
projectVertex( v1 );
face = faces[ f ];
projectVertex( v2 );
projectVertex( v3 );
}
var material = isFaceMaterial === true
? objectMaterials.materials[ face.materialIndex ]
: object.material;
_points3[ 0 ] = v1.positionScreen;
if ( material === undefined ) continue;
_points3[ 1 ] = v2.positionScreen;
_points3[ 2 ] = v3.positionScreen;
if ( v1.visible === true || v2.visible === true || v3.visible === true ||
var side = material.side;
_clipBox.isIntersectionBox( _boundingBox.setFromPoints( _points3 ) ) ) {
visible = ( ( v3.positionScreen.x - v1.positionScreen.x ) *
var v1 = _vertexPool[ face.a ];
( v2.positionScreen.y - v1.positionScreen.y ) -
var v2 = _vertexPool[ face.b ];
( v3.positionScreen.y - v1.positionScreen.y ) *
var v3 = _vertexPool[ face.c ];
( v2.positionScreen.x - v1.positionScreen.x ) ) < 0;
if (
side === THREE.DoubleSide || visible === ( side === THREE.FrontSide )
) {
if (
material.morphTargets === true
) {
_face = getNextFace3InPool();
var morphTargets = geometry.morphTargets;
var morphInfluences = object.morphTargetInfluences;
_face.id = object.id;
var v1p = v1.position;
_face.v1.copy( v1 );
var v2p = v2.position;
_face.v2.copy( v2 );
var v3p = v3.position;
_face.v3.copy( v3 );
} else {
_vA.set( 0, 0, 0 );
_vB.set( 0, 0, 0 );
_vC.set( 0, 0, 0 );
continue;
for ( var t = 0, tl = morphTargets.length; t < tl; t ++ ) {
}
var influence = morphInfluences[ t ];
} else {
if ( influence === 0 ) continue;
continue
;
var targets = morphTargets[ t ].vertices
;
}
_vA.x += ( targets[ face.a ].x - v1p.x ) * influence;
_vA.y += ( targets[ face.a ].y - v1p.y ) * influence;
_vA.z += ( targets[ face.a ].z - v1p.z ) * influence;
_face.normalModel.copy( face.normal );
_vB.x += ( targets[ face.b ].x - v2p.x ) * influence;
_vB.y += ( targets[ face.b ].y - v2p.y ) * influence;
_vB.z += ( targets[ face.b ].z - v2p.z ) * influence;
if ( visible === false && ( side === THREE.BackSide || side === THREE.DoubleSide ) ) {
_vC.x += ( targets[ face.c ].x - v3p.x ) * influence;
_vC.y += ( targets[ face.c ].y - v3p.y ) * influence;
_vC.z += ( targets[ face.c ].z - v3p.z ) * influence;
_face.normalModel.negate();
}
}
v1.position.add( _vA );
v2.position.add( _vB );
v3.position.add( _vC );
_face.normalModel.applyMatrix3( _normalMatrix ).normalize();
renderState.projectVertex( v1 );
renderState.projectVertex( v2 );
renderState.projectVertex( v3 );
_face.normalModelView.copy( _face.normalModel ).applyMatrix3( _normalViewMatrix );
}
var visible = renderState.checkTriangleVisibility( v1, v2, v3 );
_face.centroidModel.copy( face.centroid ).applyMatrix4( _modelMatrix )
;
if ( visible === ( side === THREE.BackSide ) ) continue
;
faceVertexNormals = face.vertexNormals
;
_face = getNextFace3InPool()
;
for ( var n = 0, nl = Math.min( faceVertexNormals.length, 3 ); n < nl; n ++ ) {
_face.id = object.id;
_face.v1.copy( v1 );
_face.v2.copy( v2 );
_face.v3.copy( v3 );
var normalModel = _face.vertexNormalsModel[ n ];
_face.normalModel.copy( face.normal );
normalModel.copy( faceVertexNormals[ n ] );
if ( visible === false && ( side === THREE.BackSide || side === THREE.DoubleSide ) ) {
if ( visible === false && ( side === THREE.BackSide || side === THREE.DoubleSide ) ) {
normalModel.negate();
_face.
normalModel.negate();
}
}
normalModel.applyMatrix3( _normalMatrix ).normalize();
_face.
normalModel.applyMatrix3( _normalMatrix ).normalize();
var normalModelView = _face.vertexNormalsModelView[ n ];
_face.normalModelView.copy( _face.normalModel ).applyMatrix3( _normalViewMatrix );
normalModelView.copy( normalModel ).applyMatrix3( _normalViewMatrix );
}
_face.centroidModel.copy( face.centroid ).applyMatrix4( _modelMatrix );
faceVertexNormals = face.vertexNormals;
for ( var n = 0, nl = Math.min( faceVertexNormals.length, 3 ); n < nl; n ++ ) {
var normalModel = _face.vertexNormalsModel[ n ];
normalModel.copy( faceVertexNormals[ n ] );
_face.vertexNormalsLength = faceVertexNormals.length;
if ( visible === false && ( side === THREE.BackSide || side === THREE.DoubleSide ) ) {
for ( var c = 0, cl = Math.min( faceVertexUvs.length, 3 ); c < cl; c ++ ) {
normalModel.negate();
uvs = faceVertexUvs[ c ][ f ];
}
normalModel.applyMatrix3( _normalMatrix ).normalize();
var normalModelView = _face.vertexNormalsModelView[ n ];
normalModelView.copy( normalModel ).applyMatrix3( _normalViewMatrix );
}
_face.vertexNormalsLength = faceVertexNormals.length;
if ( uvs === undefined ) continue;
for ( var c = 0, cl = Math.min( faceVertexUvs.length, 3 ); c < cl; c ++ ) {
for ( var u = 0, ul = uvs.length; u < ul; u ++ ) {
uvs = faceVertexUvs[ c ][ f ];
_face.uvs[ c ][ u ] = uvs[ u ];
if ( uvs === undefined ) continue;
for ( var u = 0, ul = uvs.length; u < ul; u ++ ) {
_face.uvs[ c ][ u ] = uvs[ u ];
}
}
}
}
_face.color = face.color;
_face.material = material;
_face.color = face.color;
_centroid.copy( _face.centroidModel ).applyProjection( _viewProjectionMatrix );
_face.material = material;
_centroid.copy( _face.centroidModel ).applyProjection( _viewProjectionMatrix )
;
_face.z = _centroid.z
;
_face.z = _centroid.z
;
_renderData.elements.push( _face )
;
_renderData.elements.push( _face );
}
}
}
...
...
build/three.min.js
浏览文件 @
0d2d02c0
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录