Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
8adc0489
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,发现更多精彩内容 >>
提交
8adc0489
编写于
2月 18, 2014
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Experimenting with Geometry2 being an extension of BufferGeometry.
上级
77b6890c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
59 addition
and
299 deletion
+59
-299
examples/js/loaders/OBJLoader2.js
examples/js/loaders/OBJLoader2.js
+49
-37
src/core/Geometry2.js
src/core/Geometry2.js
+5
-129
src/core/Projector.js
src/core/Projector.js
+0
-14
src/extras/geometries/BoxGeometry2.js
src/extras/geometries/BoxGeometry2.js
+4
-4
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+0
-114
utils/build/includes/common.json
utils/build/includes/common.json
+1
-1
未找到文件。
examples/js/loaders/OBJLoader2.js
浏览文件 @
8adc0489
...
...
@@ -28,27 +28,7 @@ THREE.OBJLoader.prototype = {
parse
:
function
(
text
)
{
/*
function vector( x, y, z ) {
return new THREE.Vector3( parseFloat( x ), parseFloat( y ), parseFloat( z ) );
}
function uv( u, v ) {
return new THREE.Vector2( parseFloat( u ), parseFloat( v ) );
}
function face3( a, b, c, normals ) {
return new THREE.Face3( a, b, c, normals );
}
*/
var
object
=
new
THREE
.
Object3D
();
var
object
,
objects
=
[];
var
geometry
,
material
,
mesh
;
function
parseVertexIndex
(
value
)
{
...
...
@@ -172,10 +152,23 @@ THREE.OBJLoader.prototype = {
if
(
/^o /gm
.
test
(
text
)
===
false
)
{
geometry
=
new
THREE
.
Geometry2
();
material
=
new
THREE
.
MeshLambertMaterial
();
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
object
.
add
(
mesh
);
geometry
=
{
vertices
:
[],
normals
:
[],
uvs
:
[]
};
material
=
{
name
:
''
};
object
=
{
name
:
''
,
geometry
:
geometry
,
material
:
material
};
objects
.
push
(
object
);
}
...
...
@@ -285,12 +278,22 @@ THREE.OBJLoader.prototype = {
}
else
if
(
/^o /
.
test
(
line
)
)
{
geometry
=
new
THREE
.
Geometry2
();
material
=
new
THREE
.
MeshLambertMaterial
();
geometry
=
{
vertices
:
[],
normals
:
[],
uvs
:
[]
};
material
=
{
name
:
''
};
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
mesh
.
name
=
line
.
substring
(
2
).
trim
();
object
.
add
(
mesh
);
object
=
{
name
:
line
.
substring
(
2
).
trim
(),
geometry
:
geometry
};
objects
.
push
(
object
)
}
else
if
(
/^g /
.
test
(
line
)
)
{
...
...
@@ -318,19 +321,28 @@ THREE.OBJLoader.prototype = {
}
var
children
=
object
.
children
;
var
container
=
new
THREE
.
Object3D
();
for
(
var
i
=
0
,
l
=
objects
.
length
;
i
<
l
;
i
++
)
{
var
object
=
objects
[
i
];
var
geometry
=
new
THREE
.
Geometry2
(
object
.
geometry
.
vertices
.
length
/
3
);
geometry
.
vertices
.
set
(
object
.
geometry
.
vertices
);
geometry
.
normals
.
set
(
object
.
geometry
.
normals
);
geometry
.
uvs
.
set
(
object
.
geometry
.
uvs
);
for
(
var
i
=
0
,
l
=
children
.
length
;
i
<
l
;
i
++
)
{
var
material
=
new
THREE
.
MeshLambertMaterial
();
material
.
name
=
object
.
material
.
name
;
var
geometry
=
children
[
i
].
geometry
;
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
mesh
.
name
=
object
.
name
;
geometry
.
vertices
=
new
Float32Array
(
geometry
.
vertices
);
geometry
.
normals
=
new
Float32Array
(
geometry
.
normals
);
geometry
.
uvs
=
new
Float32Array
(
geometry
.
uvs
);
container
.
add
(
mesh
);
}
return
object
;
return
container
;
}
...
...
src/core/Geometry2.js
浏览文件 @
8adc0489
...
...
@@ -4,139 +4,15 @@
THREE
.
Geometry2
=
function
(
size
)
{
this
.
id
=
THREE
.
GeometryIdCount
++
;
this
.
uuid
=
THREE
.
Math
.
generateUUID
();
THREE
.
BufferGeometry
.
call
(
this
);
this
.
name
=
''
;
this
.
vertices
=
size
!==
undefined
?
new
Float32Array
(
size
*
3
)
:
[];
this
.
normals
=
size
!==
undefined
?
new
Float32Array
(
size
*
3
)
:
[];
this
.
uvs
=
size
!==
undefined
?
new
Float32Array
(
size
*
2
)
:
[];
this
.
vertices
=
this
.
addAttribute
(
'
position
'
,
Float32Array
,
size
,
3
).
array
;
this
.
normals
=
this
.
addAttribute
(
'
normal
'
,
Float32Array
,
size
,
3
).
array
;
this
.
uvs
=
this
.
addAttribute
(
'
uv
'
,
Float32Array
,
size
,
2
).
array
;
this
.
boundingBox
=
null
;
this
.
boundingSphere
=
null
;
};
THREE
.
Geometry2
.
prototype
=
{
constructor
:
THREE
.
Geometry2
,
applyMatrix
:
function
(
matrix
)
{
matrix
.
multiplyVector3Array
(
this
.
vertices
);
},
computeBoundingBox
:
function
()
{
if
(
this
.
boundingBox
===
null
)
{
this
.
boundingBox
=
new
THREE
.
Box3
();
}
var
vertices
=
this
.
vertices
;
var
bb
=
this
.
boundingBox
;
if
(
vertices
.
length
>=
3
)
{
bb
.
min
.
x
=
bb
.
max
.
x
=
vertices
[
0
];
bb
.
min
.
y
=
bb
.
max
.
y
=
vertices
[
1
];
bb
.
min
.
z
=
bb
.
max
.
z
=
vertices
[
2
];
}
for
(
var
i
=
3
,
il
=
vertices
.
length
;
i
<
il
;
i
+=
3
)
{
var
x
=
vertices
[
i
];
var
y
=
vertices
[
i
+
1
];
var
z
=
vertices
[
i
+
2
];
// bounding box
if
(
x
<
bb
.
min
.
x
)
{
bb
.
min
.
x
=
x
;
}
else
if
(
x
>
bb
.
max
.
x
)
{
bb
.
max
.
x
=
x
;
}
if
(
y
<
bb
.
min
.
y
)
{
bb
.
min
.
y
=
y
;
}
else
if
(
y
>
bb
.
max
.
y
)
{
bb
.
max
.
y
=
y
;
}
if
(
z
<
bb
.
min
.
z
)
{
bb
.
min
.
z
=
z
;
}
else
if
(
z
>
bb
.
max
.
z
)
{
bb
.
max
.
z
=
z
;
}
}
},
computeBoundingSphere
:
function
()
{
var
box
=
new
THREE
.
Box3
();
var
vector
=
new
THREE
.
Vector3
();
return
function
()
{
if
(
this
.
boundingSphere
===
null
)
{
this
.
boundingSphere
=
new
THREE
.
Sphere
();
}
box
.
makeEmpty
();
var
vertices
=
this
.
vertices
;
var
center
=
this
.
boundingSphere
.
center
;
for
(
var
i
=
0
,
il
=
vertices
.
length
;
i
<
il
;
i
+=
3
)
{
vector
.
set
(
vertices
[
i
],
vertices
[
i
+
1
],
vertices
[
i
+
2
]
);
box
.
addPoint
(
vector
);
}
box
.
center
(
center
);
var
maxRadiusSq
=
0
;
for
(
var
i
=
0
,
il
=
vertices
.
length
;
i
<
il
;
i
+=
3
)
{
vector
.
set
(
vertices
[
i
],
vertices
[
i
+
1
],
vertices
[
i
+
2
]
);
maxRadiusSq
=
Math
.
max
(
maxRadiusSq
,
center
.
distanceToSquared
(
vector
)
);
}
this
.
boundingSphere
.
radius
=
Math
.
sqrt
(
maxRadiusSq
);
}
}(),
dispose
:
function
()
{
this
.
dispatchEvent
(
{
type
:
'
dispose
'
}
);
}
};
THREE
.
EventDispatcher
.
prototype
.
apply
(
THREE
.
Geometry2
.
prototype
);
THREE
.
Geometry2
.
prototype
=
Object
.
create
(
THREE
.
BufferGeometry
.
prototype
);
\ No newline at end of file
src/core/Projector.js
浏览文件 @
8adc0489
...
...
@@ -375,20 +375,6 @@ THREE.Projector = function () {
}
}
else
if
(
geometry
instanceof
THREE
.
Geometry2
)
{
vertices
=
geometry
.
vertices
;
for
(
var
i
=
0
,
j
=
0
,
l
=
vertices
.
length
;
i
<
l
;
i
+=
9
,
j
+=
3
)
{
renderList
.
pushVertex
(
vertices
[
i
+
0
],
vertices
[
i
+
1
],
vertices
[
i
+
2
]
);
renderList
.
pushVertex
(
vertices
[
i
+
3
],
vertices
[
i
+
4
],
vertices
[
i
+
5
]
);
renderList
.
pushVertex
(
vertices
[
i
+
6
],
vertices
[
i
+
7
],
vertices
[
i
+
8
]
);
renderList
.
pushTriangle
(
j
+
0
,
j
+
1
,
j
+
2
);
}
}
else
if
(
geometry
instanceof
THREE
.
Geometry
)
{
vertices
=
geometry
.
vertices
;
...
...
src/extras/geometries/BoxGeometry2.js
浏览文件 @
8adc0489
...
...
@@ -5,8 +5,6 @@
THREE
.
BoxGeometry2
=
function
(
width
,
height
,
depth
,
widthSegments
,
heightSegments
,
depthSegments
)
{
THREE
.
Geometry2
.
call
(
this
);
var
scope
=
this
;
this
.
width
=
width
;
...
...
@@ -24,7 +22,7 @@ THREE.BoxGeometry2 = function ( width, height, depth, widthSegments, heightSegme
var
vector
=
new
THREE
.
Vector3
();
var
vectors
=
[];
var
vertices
=
this
.
vertices
;
var
vertices
=
[]
;
var
addVertex
=
function
(
a
,
b
,
c
)
{
...
...
@@ -106,7 +104,9 @@ THREE.BoxGeometry2 = function ( width, height, depth, widthSegments, heightSegme
}
this
.
vertices
=
new
Float32Array
(
vertices
);
THREE
.
Geometry2
.
call
(
this
,
vertices
.
length
/
3
);
this
.
vertices
.
set
(
vertices
);
};
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
8adc0489
...
...
@@ -608,12 +608,6 @@ THREE.WebGLRenderer = function ( parameters ) {
_this
.
info
.
memory
.
geometries
--
;
}
if
(
geometry
instanceof
THREE
.
Geometry2
)
{
delete
_buffers
[
geometry
.
id
];
_this
.
info
.
memory
.
geometries
--
;
}
else
{
if
(
geometry
.
geometryGroups
!==
undefined
)
{
...
...
@@ -1090,27 +1084,6 @@ THREE.WebGLRenderer = function ( parameters ) {
};
function
initGeometry2Buffers
(
geometry
)
{
var
buffers
=
{};
var
attributes
=
[
'
vertices
'
,
'
normals
'
,
'
uvs
'
];
for
(
var
key
in
attributes
)
{
var
array
=
geometry
[
attributes
[
key
]
];
var
buffer
=
_gl
.
createBuffer
();
_gl
.
bindBuffer
(
_gl
.
ARRAY_BUFFER
,
buffer
);
_gl
.
bufferData
(
_gl
.
ARRAY_BUFFER
,
array
,
_gl
.
STATIC_DRAW
);
buffers
[
attributes
[
key
]
]
=
buffer
;
}
_buffers
[
geometry
.
id
]
=
buffers
;
};
// Buffer setting
function
setParticleBuffers
(
geometry
,
hint
,
object
)
{
...
...
@@ -2481,27 +2454,6 @@ THREE.WebGLRenderer = function ( parameters ) {
}
function
setGeometry2Buffers
(
geometry
,
hint
)
{
if
(
geometry
.
needsUpdate
===
false
)
return
;
var
attributes
=
[
'
vertices
'
,
'
normals
'
,
'
uvs
'
];
var
buffers
=
_buffers
[
geometry
.
id
];
for
(
var
key
in
attributes
)
{
var
array
=
geometry
[
attributes
[
key
]
];
var
buffer
=
buffers
[
attributes
[
key
]
];
_gl
.
bindBuffer
(
_gl
.
ARRAY_BUFFER
,
buffer
);
_gl
.
bufferData
(
_gl
.
ARRAY_BUFFER
,
array
,
hint
);
}
geometry
.
needsUpdate
=
false
;
};
// Buffer rendering
this
.
renderBufferImmediate
=
function
(
object
,
program
,
material
)
{
...
...
@@ -2597,56 +2549,6 @@ THREE.WebGLRenderer = function ( parameters ) {
};
this
.
renderBufferGeometry2
=
function
(
camera
,
lights
,
fog
,
material
,
geometry
,
object
)
{
var
program
=
setProgram
(
camera
,
lights
,
fog
,
material
,
object
);
var
programAttributes
=
program
.
attributes
;
var
attributes
=
{
'
position
'
:
'
vertices
'
,
'
normal
'
:
'
normals
'
,
'
uv
'
:
'
uvs
'
};
var
itemSizes
=
{
'
position
'
:
3
,
'
normal
'
:
3
,
'
uv
'
:
2
};
var
buffers
=
_buffers
[
geometry
.
id
];
disableAttributes
();
for
(
var
name
in
programAttributes
)
{
var
attributePointer
=
programAttributes
[
name
];
if
(
attributePointer
>=
0
)
{
var
array
=
geometry
[
attributes
[
name
]
];
if
(
array
!==
undefined
&&
array
.
length
>
0
)
{
_gl
.
bindBuffer
(
_gl
.
ARRAY_BUFFER
,
buffers
[
attributes
[
name
]
]
);
enableAttribute
(
attributePointer
);
_gl
.
vertexAttribPointer
(
attributePointer
,
itemSizes
[
name
],
_gl
.
FLOAT
,
false
,
0
,
0
);
}
else
{
if
(
itemSizes
[
name
]
===
3
)
{
_gl
.
vertexAttrib3fv
(
attributePointer
,
[
0
,
0
,
0
]
);
}
else
if
(
itemSizes
[
name
]
===
2
)
{
_gl
.
vertexAttrib2fv
(
attributePointer
,
[
0
,
0
]
);
}
}
}
}
_gl
.
drawArrays
(
_gl
.
TRIANGLES
,
0
,
geometry
.
vertices
.
length
/
3
);
};
this
.
renderBufferDirect
=
function
(
camera
,
lights
,
fog
,
material
,
geometry
,
object
)
{
if
(
material
.
visible
===
false
)
return
;
...
...
@@ -3611,10 +3513,6 @@ THREE.WebGLRenderer = function ( parameters ) {
_this
.
renderBufferDirect
(
camera
,
lights
,
fog
,
material
,
buffer
,
object
);
}
else
if
(
buffer
instanceof
THREE
.
Geometry2
)
{
_this
.
renderBufferGeometry2
(
camera
,
lights
,
fog
,
material
,
buffer
,
object
);
}
else
{
_this
.
renderBuffer
(
camera
,
lights
,
fog
,
material
,
buffer
,
object
);
...
...
@@ -3834,10 +3732,6 @@ THREE.WebGLRenderer = function ( parameters ) {
initDirectBuffers
(
geometry
);
}
else
if
(
geometry
instanceof
THREE
.
Geometry2
)
{
initGeometry2Buffers
(
geometry
);
}
else
if
(
object
instanceof
THREE
.
Mesh
)
{
material
=
object
.
material
;
...
...
@@ -3912,10 +3806,6 @@ THREE.WebGLRenderer = function ( parameters ) {
addBuffer
(
scene
.
__webglObjects
,
geometry
,
object
);
}
else
if
(
geometry
instanceof
THREE
.
Geometry2
)
{
addBuffer
(
scene
.
__webglObjects
,
geometry
,
object
);
}
else
if
(
geometry
instanceof
THREE
.
Geometry
)
{
for
(
g
in
geometry
.
geometryGroups
)
{
...
...
@@ -3994,10 +3884,6 @@ THREE.WebGLRenderer = function ( parameters ) {
setDirectBuffers
(
geometry
,
_gl
.
DYNAMIC_DRAW
);
}
else
if
(
geometry
instanceof
THREE
.
Geometry2
)
{
setGeometry2Buffers
(
geometry
,
_gl
.
DYNAMIC_DRAW
);
}
else
if
(
object
instanceof
THREE
.
Mesh
)
{
// check all geometry groups
...
...
utils/build/includes/common.json
浏览文件 @
8adc0489
...
...
@@ -27,9 +27,9 @@
"src/core/Projector.js"
,
"src/core/Face3.js"
,
"src/core/Face4.js"
,
"src/core/BufferGeometry.js"
,
"src/core/Geometry.js"
,
"src/core/Geometry2.js"
,
"src/core/BufferGeometry.js"
,
"src/cameras/Camera.js"
,
"src/cameras/OrthographicCamera.js"
,
"src/cameras/PerspectiveCamera.js"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录