Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
85c835de
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,发现更多精彩内容 >>
提交
85c835de
编写于
7月 17, 2015
作者:
R
Ricardo Cabello
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6868 from dubejf/noproxy
Remove wip / TypedGeometry
上级
48ca3777
5456e02a
变更
32
显示空白变更内容
内联
并排
Showing
32 changed file
with
34 addition
and
2752 deletion
+34
-2752
examples/js/wip/CircleTypedGeometry.js
examples/js/wip/CircleTypedGeometry.js
+0
-76
examples/js/wip/GeometryEditor.js
examples/js/wip/GeometryEditor.js
+0
-75
examples/js/wip/IndexedTypedGeometry.js
examples/js/wip/IndexedTypedGeometry.js
+0
-28
examples/js/wip/PlaneTypedGeometry.js
examples/js/wip/PlaneTypedGeometry.js
+0
-92
examples/js/wip/ProxyGeometry.js
examples/js/wip/ProxyGeometry.js
+0
-755
examples/js/wip/TypedGeometry.js
examples/js/wip/TypedGeometry.js
+0
-120
examples/js/wip/benchmark/BoxGeometry2.js
examples/js/wip/benchmark/BoxGeometry2.js
+0
-114
examples/js/wip/benchmark/Geometry2.js
examples/js/wip/benchmark/Geometry2.js
+0
-20
examples/js/wip/benchmark/Geometry2Loader.js
examples/js/wip/benchmark/Geometry2Loader.js
+0
-67
examples/js/wip/benchmark/Geometry3.js
examples/js/wip/benchmark/Geometry3.js
+0
-32
examples/js/wip/benchmark/Geometry4.js
examples/js/wip/benchmark/Geometry4.js
+0
-85
examples/js/wip/benchmark/Geometry5.js
examples/js/wip/benchmark/Geometry5.js
+0
-78
examples/js/wip/benchmark/Geometry5b.js
examples/js/wip/benchmark/Geometry5b.js
+0
-76
examples/js/wip/benchmark/IndexedGeometry3.js
examples/js/wip/benchmark/IndexedGeometry3.js
+0
-34
examples/js/wip/benchmark/IndexedGeometry5.js
examples/js/wip/benchmark/IndexedGeometry5.js
+0
-80
examples/js/wip/benchmark/IndexedPlaneGeometry5.js
examples/js/wip/benchmark/IndexedPlaneGeometry5.js
+0
-83
examples/js/wip/benchmark/PlaneGeometry.js
examples/js/wip/benchmark/PlaneGeometry.js
+0
-79
examples/js/wip/benchmark/PlaneGeometry2.js
examples/js/wip/benchmark/PlaneGeometry2.js
+0
-76
examples/js/wip/benchmark/PlaneGeometry2b.js
examples/js/wip/benchmark/PlaneGeometry2b.js
+0
-66
examples/js/wip/benchmark/PlaneGeometry3.js
examples/js/wip/benchmark/PlaneGeometry3.js
+0
-76
examples/js/wip/benchmark/PlaneGeometry5.js
examples/js/wip/benchmark/PlaneGeometry5.js
+0
-66
examples/js/wip/benchmark/PlaneGeometry6.js
examples/js/wip/benchmark/PlaneGeometry6.js
+0
-30
examples/js/wip/benchmark/PlaneGeometry99.js
examples/js/wip/benchmark/PlaneGeometry99.js
+0
-93
examples/js/wip/benchmark/TypedGeometry.js
examples/js/wip/benchmark/TypedGeometry.js
+0
-178
examples/js/wip/proxies/MultiColor.js
examples/js/wip/proxies/MultiColor.js
+0
-39
examples/js/wip/proxies/MultiVector3.js
examples/js/wip/proxies/MultiVector3.js
+0
-40
examples/js/wip/proxies/ProxyColor.js
examples/js/wip/proxies/ProxyColor.js
+0
-33
examples/js/wip/proxies/ProxyFace3.js
examples/js/wip/proxies/ProxyFace3.js
+0
-40
examples/js/wip/proxies/ProxyVector2.js
examples/js/wip/proxies/ProxyVector2.js
+0
-26
examples/js/wip/proxies/ProxyVector3.js
examples/js/wip/proxies/ProxyVector3.js
+0
-30
examples/js/wip/proxies/ProxyVector4.js
examples/js/wip/proxies/ProxyVector4.js
+0
-34
examples/webgl_geometry_minecraft.html
examples/webgl_geometry_minecraft.html
+34
-31
未找到文件。
examples/js/wip/CircleTypedGeometry.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author hughes
* @author mrdoob / http://mrdoob.com/
*/
THREE
.
CircleTypedGeometry
=
function
(
radius
,
segments
,
thetaStart
,
thetaLength
)
{
this
.
parameters
=
{
radius
:
radius
,
segments
:
segments
,
thetaStart
:
thetaStart
,
thetaLength
:
thetaLength
};
radius
=
radius
||
50
;
segments
=
segments
!==
undefined
?
Math
.
max
(
3
,
segments
)
:
8
;
thetaStart
=
thetaStart
!==
undefined
?
thetaStart
:
0
;
thetaLength
=
thetaLength
!==
undefined
?
thetaLength
:
Math
.
PI
*
2
;
//
var
elements
=
segments
+
2
;
var
indices
=
new
Uint16Array
(
segments
*
3
);
var
vertices
=
new
Float32Array
(
elements
*
3
);
var
normals
=
new
Float32Array
(
elements
*
3
);
var
uvs
=
new
Float32Array
(
elements
*
2
);
// center
normals
[
2
]
=
1
;
uvs
[
0
]
=
0.5
;
uvs
[
1
]
=
0.5
;
var
offset
=
0
,
offset2
=
2
,
offset3
=
3
;
for
(
var
i
=
0
;
i
<=
segments
;
i
++
)
{
var
segment
=
thetaStart
+
i
/
segments
*
thetaLength
;
var
x
=
radius
*
Math
.
cos
(
segment
);
var
y
=
radius
*
Math
.
sin
(
segment
);
vertices
[
offset3
]
=
x
;
vertices
[
offset3
+
1
]
=
y
;
normals
[
offset3
+
2
]
=
1
;
uvs
[
offset2
]
=
(
x
/
radius
+
1
)
/
2
;
uvs
[
offset2
+
1
]
=
(
y
/
radius
+
1
)
/
2
;
offset2
+=
2
;
offset3
+=
3
;
//
indices
[
offset
]
=
0
;
indices
[
offset
+
1
]
=
i
+
1
;
indices
[
offset
+
2
]
=
i
+
2
;
offset
+=
3
;
}
THREE
.
IndexedTypedGeometry
.
call
(
this
);
this
.
setArrays
(
indices
,
vertices
,
normals
,
uvs
);
this
.
boundingSphere
=
new
THREE
.
Sphere
(
new
THREE
.
Vector3
(),
radius
);
};
THREE
.
CircleTypedGeometry
.
prototype
=
Object
.
create
(
THREE
.
IndexedTypedGeometry
.
prototype
);
THREE
.
CircleTypedGeometry
.
prototype
.
constructor
=
THREE
.
CircleTypedGeometry
;
examples/js/wip/GeometryEditor.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE
.
GeometryEditor
=
function
(
geometry
)
{
this
.
geometry
=
geometry
;
};
Object
.
defineProperties
(
THREE
.
GeometryEditor
.
prototype
,
{
vertices
:
{
enumerable
:
true
,
get
:
function
()
{
return
this
.
createVertexProxies
();
}
},
normals
:
{
enumerable
:
true
,
get
:
function
()
{
return
this
.
createNormalProxies
();
}
},
uvs
:
{
enumerable
:
true
,
get
:
function
()
{
return
this
.
createUVProxies
();
}
}
}
);
THREE
.
GeometryEditor
.
prototype
.
createVertexProxies
=
function
()
{
Object
.
defineProperty
(
this
,
'
vertices
'
,
{
value
:
[],
writable
:
true
}
);
var
attributes
=
this
.
geometry
.
attributes
;
var
length
=
attributes
.
position
.
array
.
length
/
3
;
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
this
.
vertices
.
push
(
new
THREE
.
ProxyVector3
(
attributes
.
position
.
array
,
i
*
3
)
);
}
return
this
.
vertices
;
};
THREE
.
GeometryEditor
.
prototype
.
createNormalProxies
=
function
()
{
Object
.
defineProperty
(
this
,
'
normals
'
,
{
value
:
[],
writable
:
true
}
);
var
attributes
=
this
.
geometry
.
attributes
;
var
length
=
attributes
.
position
.
array
.
length
/
3
;
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
this
.
normals
.
push
(
new
THREE
.
ProxyVector3
(
attributes
.
normal
.
array
,
i
*
3
)
);
}
return
this
.
normals
;
};
THREE
.
GeometryEditor
.
prototype
.
createUVProxies
=
function
()
{
Object
.
defineProperty
(
this
,
'
uvs
'
,
{
value
:
[],
writable
:
true
}
);
var
attributes
=
this
.
geometry
.
attributes
;
var
length
=
attributes
.
position
.
array
.
length
/
3
;
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
this
.
uvs
.
push
(
new
THREE
.
ProxyVector2
(
attributes
.
uv
.
array
,
i
*
2
)
);
}
return
this
.
uvs
;
};
\ No newline at end of file
examples/js/wip/IndexedTypedGeometry.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE
.
IndexedTypedGeometry
=
function
()
{
THREE
.
BufferGeometry
.
call
(
this
);
};
THREE
.
IndexedTypedGeometry
.
prototype
=
Object
.
create
(
THREE
.
BufferGeometry
.
prototype
);
THREE
.
IndexedTypedGeometry
.
prototype
.
constructor
=
THREE
.
IndexedTypedGeometry
;
THREE
.
IndexedTypedGeometry
.
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
};
return
this
;
};
examples/js/wip/PlaneTypedGeometry.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
* based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
*/
THREE
.
PlaneTypedGeometry
=
function
(
width
,
height
,
widthSegments
,
heightSegments
)
{
this
.
parameters
=
{
width
:
width
,
height
:
height
,
widthSegments
:
widthSegments
,
heightSegments
:
heightSegments
};
var
width_half
=
width
/
2
;
var
height_half
=
height
/
2
;
var
gridX
=
widthSegments
||
1
;
var
gridY
=
heightSegments
||
1
;
var
gridX1
=
gridX
+
1
;
var
gridY1
=
gridY
+
1
;
var
segment_width
=
width
/
gridX
;
var
segment_height
=
height
/
gridY
;
var
vertices
=
new
Float32Array
(
gridX1
*
gridY1
*
3
);
var
normals
=
new
Float32Array
(
gridX1
*
gridY1
*
3
);
var
uvs
=
new
Float32Array
(
gridX1
*
gridY1
*
2
);
var
offset
=
0
;
var
offset2
=
0
;
for
(
var
iy
=
0
;
iy
<
gridY1
;
iy
++
)
{
var
y
=
iy
*
segment_height
-
height_half
;
for
(
var
ix
=
0
;
ix
<
gridX1
;
ix
++
)
{
var
x
=
ix
*
segment_width
-
width_half
;
vertices
[
offset
]
=
x
;
vertices
[
offset
+
1
]
=
-
y
;
normals
[
offset
+
2
]
=
1
;
uvs
[
offset2
]
=
ix
/
gridX
;
uvs
[
offset2
+
1
]
=
1
-
(
iy
/
gridY
);
offset
+=
3
;
offset2
+=
2
;
}
}
offset
=
0
;
var
indices
=
new
(
(
vertices
.
length
/
3
)
>
65535
?
Uint32Array
:
Uint16Array
)(
gridX
*
gridY
*
6
);
for
(
var
iy
=
0
;
iy
<
gridY
;
iy
++
)
{
for
(
var
ix
=
0
;
ix
<
gridX
;
ix
++
)
{
var
a
=
ix
+
gridX1
*
iy
;
var
b
=
ix
+
gridX1
*
(
iy
+
1
);
var
c
=
(
ix
+
1
)
+
gridX1
*
(
iy
+
1
);
var
d
=
(
ix
+
1
)
+
gridX1
*
iy
;
indices
[
offset
]
=
a
;
indices
[
offset
+
1
]
=
b
;
indices
[
offset
+
2
]
=
d
;
indices
[
offset
+
3
]
=
b
;
indices
[
offset
+
4
]
=
c
;
indices
[
offset
+
5
]
=
d
;
offset
+=
6
;
}
}
THREE
.
IndexedTypedGeometry
.
call
(
this
);
this
.
setArrays
(
indices
,
vertices
,
normals
,
uvs
);
this
.
computeBoundingSphere
();
};
THREE
.
PlaneTypedGeometry
.
prototype
=
Object
.
create
(
THREE
.
IndexedTypedGeometry
.
prototype
);
THREE
.
PlaneTypedGeometry
.
prototype
.
constructor
=
THREE
.
PlaneTypedGeometry
;
examples/js/wip/ProxyGeometry.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
* @author kile / http://kile.stravaganza.org/
* @author alteredq / http://alteredqualia.com/
* @author mikael emtinger / http://gomo.se/
* @author zz85 / http://www.lab4games.net/zz85/blog
* @author bhouston / http://exocortex.com
* @author jbaicoianu / http://baicoianu.com
*/
THREE
.
ProxyGeometry
=
function
(
)
{
THREE
.
BufferGeometry
.
call
(
this
);
this
.
addEventListener
(
'
allocate
'
,
this
.
onGeometryAllocate
);
// TODO - implement as BufferGeometry attributes
this
.
morphTargets
=
[];
this
.
morphColors
=
[];
};
THREE
.
ProxyGeometry
.
prototype
=
Object
.
create
(
THREE
.
IndexedGeometry2
.
prototype
);
THREE
.
ProxyGeometry
.
prototype
.
constructor
=
THREE
.
ProxyGeometry
;
Object
.
defineProperties
(
THREE
.
ProxyGeometry
.
prototype
,
{
vertices
:
{
enumerable
:
true
,
configurable
:
true
,
get
:
function
()
{
return
this
.
createVertexProxies
();
}
},
faces
:
{
enumerable
:
true
,
get
:
function
()
{
return
this
.
createFaceProxies
()
}
},
faceVertexUvs
:
{
enumerable
:
true
,
get
:
function
()
{
return
this
.
createUvProxies
()
}
},
colors
:
{
enumerable
:
true
,
get
:
function
()
{
return
this
.
createColorProxies
()
}
},
skinIndices
:
{
enumerable
:
true
,
get
:
function
()
{
return
this
.
createSkinIndexProxies
()
}
},
skinWeights
:
{
enumerable
:
true
,
get
:
function
()
{
return
this
.
createSkinWeightProxies
()
}
},
// TODO - fill in additional proxies:
// - morphColors
// - morphNormals
// - morphTargets
verticesNeedUpdate
:
{
enumerable
:
true
,
get
:
function
()
{
if
(
this
.
attributes
[
'
position
'
])
return
this
.
attributes
[
'
position
'
].
needsUpdate
;
},
set
:
function
(
v
)
{
if
(
this
.
attributes
[
'
position
'
])
this
.
attributes
[
'
position
'
].
needsUpdate
=
v
;
}
},
colorsNeedUpdate
:
{
enumerable
:
true
,
get
:
function
()
{
if
(
this
.
attributes
[
'
color
'
])
return
this
.
attributes
[
'
color
'
].
needsUpdate
;
},
set
:
function
(
v
)
{
if
(
this
.
attributes
[
'
color
'
])
this
.
attributes
[
'
color
'
].
needsUpdate
=
v
;
}
},
normalsNeedUpdate
:
{
enumerable
:
true
,
get
:
function
()
{
if
(
this
.
attributes
[
'
normal
'
])
return
this
.
attributes
[
'
normal
'
].
needsUpdate
;
},
set
:
function
(
v
)
{
if
(
this
.
attributes
[
'
normal
'
])
this
.
attributes
[
'
normal
'
].
needsUpdate
=
v
;
}
},
});
THREE
.
ProxyGeometry
.
prototype
.
createVertexProxies
=
function
(
values
)
{
if
(
!
this
.
hasOwnProperty
(
'
vertices
'
))
{
// Replace the prototype getter with a local array property
Object
.
defineProperty
(
this
,
"
vertices
"
,
{
value
:
[],
writable
:
true
}
);
}
else
{
// Start with a new, empty array
this
.
vertices
=
[];
}
// If the attribute buffer has already been populated, set up proxy objects
this
.
populateProxyFromBuffer
(
this
.
vertices
,
"
position
"
,
THREE
.
ProxyVector3
,
3
);
// If values were passed in, store them in the buffer via the proxy objects
if
(
values
)
{
for
(
var
i
=
0
;
i
<
values
.
length
;
i
++
)
{
this
.
vertices
[
i
].
copy
(
values
[
i
]);
}
}
// Return a reference to the newly-created array
return
this
.
vertices
;
};
THREE
.
ProxyGeometry
.
prototype
.
createFaceProxies
=
function
(
values
)
{
if
(
!
this
.
hasOwnProperty
(
"
faces
"
))
{
// Replace the prototype getter with a local array property
Object
.
defineProperty
(
this
,
"
faces
"
,
{
value
:
[],
writable
:
true
}
);
}
else
{
// Start with a new, empty array
this
.
faces
=
[];
}
// If the attribute buffer has already been populated, set up proxy objects
var
faces
=
this
.
faces
,
indexarray
=
false
,
positionarray
=
false
,
normalarray
=
false
,
colorarray
=
false
,
tangentarray
=
false
;
if
(
this
.
attributes
[
'
index
'
]
)
{
indexarray
=
this
.
attributes
[
'
index
'
].
array
;
}
if
(
this
.
attributes
[
'
position
'
]
)
{
positionarray
=
this
.
attributes
[
'
position
'
].
array
;
}
if
(
this
.
attributes
[
'
normal
'
])
{
normalarray
=
this
.
attributes
[
'
normal
'
].
array
;
}
if
(
this
.
attributes
[
'
color
'
])
{
colorarray
=
this
.
attributes
[
'
color
'
].
array
;
}
if
(
this
.
attributes
[
'
tangent
'
])
{
tangentarray
=
this
.
attributes
[
'
tangent
'
].
array
;
}
// TODO - this should be accomplished using "virtual" functions on various classes (IndexedGeometry, SmoothGeometry, etc)
if
(
indexarray
)
{
for
(
var
i
=
0
,
l
=
indexarray
.
length
/
3
;
i
<
l
;
i
++
)
{
var
o
=
i
*
3
;
var
face
=
new
THREE
.
ProxyFace3
(
indexarray
,
i
*
3
);
faces
.
push
(
face
);
}
}
else
if
(
positionarray
)
{
for
(
var
i
=
0
,
l
=
positionarray
.
length
/
3
;
i
<
l
;
i
+=
3
)
{
var
o
=
i
*
3
;
var
v1
=
i
,
v2
=
i
+
1
,
v3
=
i
+
2
;
var
face
=
new
THREE
.
ProxyFace3
(
v1
,
v2
,
v3
);
faces
.
push
(
face
);
}
}
// If values were passed in, store them in the buffer via the proxy objects
if
(
values
)
{
for
(
var
i
=
0
,
l
=
values
.
length
;
i
<
l
;
i
++
)
{
var
f
=
faces
[
i
],
v
=
values
[
i
];
f
.
a
=
v
.
a
;
f
.
b
=
v
.
b
;
f
.
c
=
v
.
c
;
}
}
if
(
normalarray
)
{
this
.
createFaceVertexNormalProxies
(
values
);
}
if
(
colorarray
)
{
this
.
createFaceVertexColorProxies
(
values
);
}
if
(
tangentarray
)
{
this
.
createFaceVertexTangentProxies
(
values
);
}
// Return a reference to the newly-created array
return
this
.
faces
;
};
THREE
.
ProxyGeometry
.
prototype
.
createFaceVertexNormalProxies
=
function
(
values
)
{
if
(
this
.
attributes
[
'
normal
'
]
&&
this
.
attributes
[
'
normal
'
].
array
)
{
var
normalarray
=
this
.
attributes
[
'
normal
'
].
array
;
for
(
var
i
=
0
,
l
=
this
.
faces
.
length
;
i
<
l
;
i
++
)
{
var
f
=
this
.
faces
[
i
];
f
.
vertexNormals
=
[
new
THREE
.
ProxyVector3
(
normalarray
,
f
.
a
*
3
),
new
THREE
.
ProxyVector3
(
normalarray
,
f
.
b
*
3
),
new
THREE
.
ProxyVector3
(
normalarray
,
f
.
c
*
3
),
];
f
.
normal
=
new
THREE
.
MultiVector3
(
f
.
vertexNormals
);
}
}
// If values were passed in, store them in the buffer via the proxy objects
if
(
values
)
{
for
(
var
i
=
0
,
l
=
values
.
length
;
i
<
l
;
i
++
)
{
var
f
=
this
.
faces
[
i
],
v
=
values
[
i
];
if
(
v
.
vertexNormals
.
length
>
0
)
{
for
(
var
j
=
0
,
l2
=
f
.
vertexNormals
.
length
;
j
<
l2
;
j
++
)
{
f
.
vertexNormals
[
j
].
copy
(
v
.
vertexNormals
[
j
]);
}
}
else
if
(
v
.
normal
)
{
f
.
normal
.
copy
(
v
.
normal
);
}
}
}
};
THREE
.
ProxyGeometry
.
prototype
.
createFaceVertexColorProxies
=
function
(
values
)
{
if
(
this
.
attributes
[
'
color
'
]
&&
this
.
attributes
[
'
color
'
].
array
)
{
var
colorarray
=
this
.
attributes
[
'
color
'
].
array
;
for
(
var
i
=
0
,
l
=
this
.
faces
.
length
;
i
<
l
;
i
++
)
{
var
f
=
this
.
faces
[
i
];
if
(
this
.
attributes
[
'
index
'
]
)
{
f
.
vertexColors
=
[
new
THREE
.
ProxyColor
(
colorarray
,
f
.
a
*
3
),
new
THREE
.
ProxyColor
(
colorarray
,
f
.
b
*
3
),
new
THREE
.
ProxyColor
(
colorarray
,
f
.
c
*
3
),
];
}
else
{
var
o
=
i
*
9
;
f
.
vertexColors
=
[
new
THREE
.
ProxyColor
(
colorarray
,
o
),
new
THREE
.
ProxyColor
(
colorarray
,
o
+
3
),
new
THREE
.
ProxyColor
(
colorarray
,
o
+
6
),
];
}
f
.
color
=
new
THREE
.
MultiColor
(
f
.
vertexColors
);
}
}
// If values were passed in, store them in the buffer via the proxy objects
if
(
values
)
{
for
(
var
i
=
0
,
l
=
values
.
length
;
i
<
l
;
i
++
)
{
var
f
=
this
.
faces
[
i
],
v
=
values
[
i
];
for
(
var
j
=
0
,
l2
=
f
.
vertexColors
.
length
;
j
<
l2
;
j
++
)
{
if
(
v
.
vertexColors
.
length
>
0
)
{
f
.
vertexColors
[
j
].
copy
(
v
.
vertexColors
[
j
]);
}
else
if
(
v
.
color
)
{
f
.
color
.
copy
(
v
.
color
);
}
}
}
}
};
THREE
.
ProxyGeometry
.
prototype
.
createFaceVertexTangentProxies
=
function
(
values
)
{
if
(
this
.
attributes
[
'
tangent
'
]
&&
this
.
attributes
[
'
tangent
'
].
array
)
{
var
tangentarray
=
this
.
attributes
[
'
tangent
'
].
array
;
for
(
var
i
=
0
,
l
=
this
.
faces
.
length
;
i
<
l
;
i
++
)
{
var
f
=
this
.
faces
[
i
];
f
.
vertexTangents
=
[
new
THREE
.
ProxyVector3
(
tangentarray
,
f
.
a
*
3
),
new
THREE
.
ProxyVector3
(
tangentarray
,
f
.
b
*
3
),
new
THREE
.
ProxyVector3
(
tangentarray
,
f
.
c
*
3
),
];
}
}
// If values were passed in, store them in the buffer via the proxy objects
if
(
values
)
{
for
(
var
i
=
0
,
l
=
values
.
length
;
i
<
l
;
i
++
)
{
var
f
=
this
.
faces
[
i
],
v
=
values
[
i
];
if
(
v
.
vertexTangents
.
length
>
0
)
{
for
(
var
j
=
0
,
l2
=
f
.
vertexTangents
.
length
;
j
<
l2
;
j
++
)
{
f
.
vertexTangents
[
j
].
copy
(
v
.
vertexTangents
[
j
]);
}
}
}
}
};
THREE
.
ProxyGeometry
.
prototype
.
createUvProxies
=
function
(
values
)
{
// Replace the prototype getter with a local array property
if
(
!
this
.
hasOwnProperty
(
"
faceVertexUvs
"
))
{
Object
.
defineProperty
(
this
,
"
faceVertexUvs
"
,
{
value
:
[[]],
writable
:
true
}
);
}
else
{
this
.
faceVertexUvs
=
[[]];
}
// If the attribute buffer has already been populated, set up proxy objects
if
(
this
.
attributes
[
'
uv
'
]
&&
this
.
attributes
[
'
uv
'
].
array
)
{
var
faces
=
this
.
faces
;
var
uvarray
=
this
.
attributes
[
'
uv
'
].
array
;
for
(
var
i
=
0
,
l
=
faces
.
length
;
i
<
l
;
i
++
)
{
var
f
=
faces
[
i
];
this
.
faceVertexUvs
[
0
][
i
]
=
[];
if
(
this
.
attributes
[
'
index
'
]
)
{
this
.
faceVertexUvs
[
0
][
i
][
0
]
=
new
THREE
.
ProxyVector2
(
uvarray
,
f
.
a
*
2
);
this
.
faceVertexUvs
[
0
][
i
][
1
]
=
new
THREE
.
ProxyVector2
(
uvarray
,
f
.
b
*
2
);
this
.
faceVertexUvs
[
0
][
i
][
2
]
=
new
THREE
.
ProxyVector2
(
uvarray
,
f
.
c
*
2
);
}
else
{
var
o
=
i
*
6
;
this
.
faceVertexUvs
[
0
][
i
][
0
]
=
new
THREE
.
ProxyVector2
(
uvarray
,
o
);
this
.
faceVertexUvs
[
0
][
i
][
1
]
=
new
THREE
.
ProxyVector2
(
uvarray
,
o
+
2
);
this
.
faceVertexUvs
[
0
][
i
][
2
]
=
new
THREE
.
ProxyVector2
(
uvarray
,
o
+
4
);
}
}
}
// If values were passed in, store them in the buffer via the proxy objects
if
(
values
)
{
for
(
var
i
=
0
,
l
=
values
.
length
;
i
<
l
;
i
++
)
{
for
(
var
j
=
0
,
l2
=
values
[
i
].
length
;
j
<
l2
;
j
++
)
{
var
uv
=
values
[
i
][
j
];
this
.
faceVertexUvs
[
0
][
i
][
j
].
copy
(
uv
);
}
}
}
// Return a reference to the newly-created array
return
this
.
faceVertexUvs
;
};
THREE
.
ProxyGeometry
.
prototype
.
createSkinIndexProxies
=
function
(
values
)
{
// Replace the prototype getter with a local array property
if
(
!
this
.
hasOwnProperty
(
'
skinIndices
'
))
{
Object
.
defineProperty
(
this
,
"
skinIndices
"
,
{
value
:
[],
writable
:
true
}
);
}
else
{
this
.
skinIndices
=
[];
}
// If the attribute buffer has already been populated, set up proxy objects
this
.
populateProxyFromBuffer
(
this
.
skinIndices
,
"
skinIndex
"
,
THREE
.
ProxyVector4
,
4
);
// If values were passed in, store them in the buffer via the proxy objects
if
(
values
)
{
for
(
var
i
=
0
;
i
<
values
.
length
;
i
++
)
{
this
.
skinIndices
[
i
].
copy
(
values
[
i
]);
}
}
// Return a reference to the newly-created array
return
this
.
skinIndices
;
};
THREE
.
ProxyGeometry
.
prototype
.
createSkinWeightProxies
=
function
(
values
)
{
// Replace the prototype getter with a local array property
if
(
!
this
.
hasOwnProperty
(
'
skinWeights
'
))
{
Object
.
defineProperty
(
this
,
"
skinWeights
"
,
{
value
:
[],
writable
:
true
}
);
}
else
{
this
.
skinWeights
=
[];
}
// If the attribute buffer has already been populated, set up proxy objects
this
.
populateProxyFromBuffer
(
this
.
skinWeights
,
"
skinWeight
"
,
THREE
.
ProxyVector4
,
4
);
// If values were passed in, store them in the buffer via the proxy objects
if
(
values
)
{
for
(
var
i
=
0
;
i
<
values
.
length
;
i
++
)
{
this
.
skinWeights
[
i
].
copy
(
values
[
i
]);
}
}
// Return a reference to the newly-created array
return
this
.
skinWeights
;
};
THREE
.
ProxyGeometry
.
prototype
.
createColorProxies
=
function
(
values
)
{
// Replace the prototype getter with a local array property
if
(
!
this
.
hasOwnProperty
(
'
colors
'
))
{
Object
.
defineProperty
(
this
,
"
colors
"
,
{
value
:
[],
writable
:
true
}
);
}
else
{
this
.
colors
=
[];
}
// If the attribute buffer has already been populated, set up proxy objects
this
.
populateProxyFromBuffer
(
this
.
colors
,
"
color
"
,
THREE
.
ProxyColor
,
3
);
// If values were passed in, store them in the buffer via the proxy objects
if
(
values
)
{
for
(
var
i
=
0
;
i
<
values
.
length
;
i
++
)
{
this
.
colors
[
i
].
copy
(
values
[
i
]);
}
}
// Return a reference to the newly-created array
return
this
.
colors
;
};
THREE
.
ProxyGeometry
.
prototype
.
populateProxyFromBuffer
=
function
(
attr
,
buffername
,
proxytype
,
itemsize
,
offset
,
count
)
{
if
(
this
.
attributes
[
buffername
]
&&
this
.
attributes
[
buffername
].
array
)
{
var
array
=
this
.
attributes
[
buffername
].
array
;
var
size
=
itemsize
||
this
.
attributes
[
buffername
].
itemSize
;
var
start
=
offset
||
0
;
count
=
count
||
(
array
.
length
/
size
-
start
);
for
(
var
i
=
start
,
l
=
start
+
count
;
i
<
l
;
i
++
)
{
attr
.
push
(
new
proxytype
(
array
,
i
*
size
)
);
}
}
};
/*
* Checks for duplicate vertices with hashmap.
* Duplicated vertices are removed
* and faces' vertices are updated.
*/
THREE
.
ProxyGeometry
.
prototype
.
mergeVertices
=
function
()
{
var
verticesMap
=
{};
// Hashmap for looking up vertice by position coordinates (and making sure they are unique)
var
unique
=
[],
changes
=
[];
var
v
,
key
;
var
precisionPoints
=
4
;
// number of decimal points, eg. 4 for epsilon of 0.0001
var
precision
=
Math
.
pow
(
10
,
precisionPoints
);
var
i
,
il
,
face
;
var
indices
,
k
,
j
,
jl
,
u
;
for
(
i
=
0
,
il
=
this
.
vertices
.
length
;
i
<
il
;
i
++
)
{
v
=
this
.
vertices
[
i
];
key
=
Math
.
round
(
v
.
x
*
precision
)
+
'
_
'
+
Math
.
round
(
v
.
y
*
precision
)
+
'
_
'
+
Math
.
round
(
v
.
z
*
precision
);
if
(
verticesMap
[
key
]
===
undefined
)
{
verticesMap
[
key
]
=
i
;
unique
.
push
(
this
.
vertices
[
i
]
);
changes
[
i
]
=
unique
.
length
-
1
;
}
else
{
//console.log('Duplicate vertex found. ', i, ' could be using ', verticesMap[key]);
changes
[
i
]
=
changes
[
verticesMap
[
key
]
];
}
}
// if faces are completely degenerate after merging vertices, we
// have to remove them from the geometry.
var
faceIndicesToRemove
=
[];
for
(
i
=
0
,
il
=
this
.
faces
.
length
;
i
<
il
;
i
++
)
{
face
=
this
.
faces
[
i
];
face
.
a
=
changes
[
face
.
a
];
face
.
b
=
changes
[
face
.
b
];
face
.
c
=
changes
[
face
.
c
];
indices
=
[
face
.
a
,
face
.
b
,
face
.
c
];
var
dupIndex
=
-
1
;
// if any duplicate vertices are found in a Face3
// we have to remove the face as nothing can be saved
for
(
var
n
=
0
;
n
<
3
;
n
++
)
{
if
(
indices
[
n
]
==
indices
[
(
n
+
1
)
%
3
]
)
{
dupIndex
=
n
;
faceIndicesToRemove
.
push
(
i
);
break
;
}
}
}
for
(
i
=
faceIndicesToRemove
.
length
-
1
;
i
>=
0
;
i
--
)
{
var
idx
=
faceIndicesToRemove
[
i
];
this
.
faces
.
splice
(
idx
,
1
);
for
(
j
=
0
,
jl
=
this
.
faceVertexUvs
.
length
;
j
<
jl
;
j
++
)
{
this
.
faceVertexUvs
[
j
].
splice
(
idx
,
1
);
}
}
// Use unique set of vertices
var
diff
=
this
.
vertices
.
length
-
unique
.
length
;
this
.
vertices
=
unique
;
return
diff
;
};
THREE
.
ProxyGeometry
.
prototype
.
onGeometryAllocate
=
function
(
ev
)
{
// Prevent allocate event listener from firing multiple times
this
.
removeEventListener
(
'
allocate
'
,
this
.
onGeometryAllocate
);
if
(
this
.
hasOwnProperty
(
'
vertices
'
))
{
var
attr
=
new
THREE
.
Float32Attribute
(
this
.
vertices
.
length
,
3
);
this
.
addAttribute
(
'
position
'
,
attr
);
this
.
createVertexProxies
(
this
.
vertices
);
}
if
(
this
.
hasOwnProperty
(
'
faces
'
))
{
var
idxattr
=
new
THREE
.
Uint16Attribute
(
this
.
faces
.
length
,
3
);
this
.
addAttribute
(
'
index
'
,
idxattr
);
if
(
this
.
faces
.
length
>
0
)
{
var
hasnormals
=
(
this
.
hasOwnProperty
(
'
normals
'
)
||
this
.
faces
[
0
].
normal
||
this
.
faces
[
0
].
vertexNormals
.
length
>
0
);
var
hascolors
=
(
this
.
hasOwnProperty
(
'
colors
'
)
||
this
.
faces
[
0
].
color
||
this
.
faces
[
0
].
vertexColors
.
length
>
0
);
var
hastangents
=
(
this
.
faces
[
0
].
vertexTangents
.
length
>
0
);
if
(
hasnormals
)
{
var
normalattr
=
new
THREE
.
Float32Attribute
(
this
.
vertices
.
length
,
3
);
this
.
addAttribute
(
'
normal
'
,
normalattr
);
}
if
(
hascolors
)
{
var
colorattr
=
new
THREE
.
Float32Attribute
(
this
.
faces
.
length
*
3
,
3
);
this
.
addAttribute
(
'
color
'
,
colorattr
);
}
if
(
hastangents
)
{
var
tangentattr
=
new
THREE
.
Float32Attribute
(
this
.
faces
.
length
*
3
,
3
);
this
.
addAttribute
(
'
tangent
'
,
tangentattr
);
}
}
this
.
createFaceProxies
(
this
.
faces
);
}
if
(
this
.
hasOwnProperty
(
'
faceVertexUvs
'
))
{
var
uvattr
=
new
THREE
.
Float32Attribute
(
this
.
faces
.
length
*
3
,
2
);
this
.
addAttribute
(
'
uv
'
,
uvattr
);
this
.
createUvProxies
(
this
.
faceVertexUvs
[
0
]);
}
if
(
this
.
hasOwnProperty
(
'
skinIndices
'
))
{
var
skinidxattr
=
new
THREE
.
Float32Attribute
(
this
.
skinIndices
.
length
,
4
);
this
.
addAttribute
(
'
skinIndex
'
,
skinidxattr
);
this
.
createSkinIndexProxies
(
this
.
skinIndices
);
}
if
(
this
.
hasOwnProperty
(
'
skinWeights
'
))
{
var
skinweightattr
=
new
THREE
.
Float32Attribute
(
this
.
skinWeights
.
length
,
4
);
this
.
addAttribute
(
'
skinWeight
'
,
skinweightattr
);
this
.
createSkinWeightProxies
(
this
.
skinWeights
);
}
};
THREE
.
ProxyGeometry
.
prototype
.
computeFaceNormals
=
function
()
{
this
.
dispatchEvent
(
{
type
:
'
allocate
'
}
);
return
THREE
.
BufferGeometry
.
prototype
.
computeFaceNormals
.
call
(
this
);
};
THREE
.
ProxyGeometry
.
prototype
.
computeVertexNormals
=
function
()
{
this
.
dispatchEvent
(
{
type
:
'
allocate
'
}
);
return
THREE
.
BufferGeometry
.
prototype
.
computeVertexNormals
.
call
(
this
);
};
THREE
.
ProxyGeometry
.
prototype
.
computeTangents
=
function
()
{
this
.
dispatchEvent
(
{
type
:
'
allocate
'
}
);
var
ret
=
THREE
.
BufferGeometry
.
prototype
.
computeTangents
.
call
(
this
);
// FIXME - this doesn't work yet
//this.createFaceVertexTangentProxies();
return
ret
;
};
THREE
.
ProxyGeometry
.
prototype
.
computeBoundingSphere
=
function
()
{
this
.
dispatchEvent
(
{
type
:
'
allocate
'
}
);
return
THREE
.
BufferGeometry
.
prototype
.
computeBoundingSphere
.
call
(
this
);
};
THREE
.
ProxyGeometry
.
prototype
.
computeBoundingBox
=
function
()
{
this
.
dispatchEvent
(
{
type
:
'
allocate
'
}
);
return
THREE
.
BufferGeometry
.
prototype
.
computeBoundingBox
.
call
(
this
);
};
THREE
.
ProxyGeometry
.
prototype
.
clone
=
function
()
{
var
buff
=
THREE
.
BufferGeometry
.
prototype
.
clone
.
call
(
this
);
var
geo
=
new
THREE
.
ProxyGeometry
();
geo
.
attributes
=
buff
.
attributes
;
geo
.
offsets
=
buff
.
drawcalls
;
return
geo
;
};
THREE
.
EventDispatcher
.
prototype
.
apply
(
THREE
.
ProxyGeometry
.
prototype
);
THREE
.
ProxyGeometryIdCount
=
0
;
examples/js/wip/TypedGeometry.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE
.
TypedGeometry
=
function
(
size
)
{
THREE
.
BufferGeometry
.
call
(
this
);
if
(
size
!==
undefined
)
{
this
.
setArrays
(
new
Float32Array
(
size
*
3
*
3
),
new
Float32Array
(
size
*
3
*
3
),
new
Float32Array
(
size
*
3
*
2
)
);
}
};
THREE
.
TypedGeometry
.
prototype
=
Object
.
create
(
THREE
.
BufferGeometry
.
prototype
);
THREE
.
TypedGeometry
.
prototype
.
constructor
=
THREE
.
TypedGeometry
;
THREE
.
TypedGeometry
.
prototype
.
setArrays
=
function
(
vertices
,
normals
,
uvs
)
{
this
.
vertices
=
vertices
;
this
.
normals
=
normals
;
this
.
uvs
=
uvs
;
this
.
addAttribute
(
'
position
'
,
new
THREE
.
BufferAttribute
(
vertices
,
3
)
);
this
.
addAttribute
(
'
normal
'
,
new
THREE
.
BufferAttribute
(
normals
,
3
)
);
this
.
addAttribute
(
'
uv
'
,
new
THREE
.
BufferAttribute
(
uvs
,
2
)
);
return
this
;
};
THREE
.
TypedGeometry
.
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
.
TypedGeometry
)
{
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
.
IndexedTypedGeometry
)
{
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
;
}
};
}
)();
\ No newline at end of file
examples/js/wip/benchmark/BoxGeometry2.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
* based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Cube.as
*/
THREE
.
BoxGeometry2
=
function
(
width
,
height
,
depth
,
widthSegments
,
heightSegments
,
depthSegments
)
{
var
scope
=
this
;
this
.
width
=
width
;
this
.
height
=
height
;
this
.
depth
=
depth
;
this
.
widthSegments
=
widthSegments
||
1
;
this
.
heightSegments
=
heightSegments
||
1
;
this
.
depthSegments
=
depthSegments
||
1
;
var
width_half
=
this
.
width
/
2
;
var
height_half
=
this
.
height
/
2
;
var
depth_half
=
this
.
depth
/
2
;
var
vector
=
new
THREE
.
Vector3
();
var
vectors
=
[];
var
vertices
=
[];
var
addVertex
=
function
(
a
,
b
,
c
)
{
vertices
.
push
(
vectors
[
a
],
vectors
[
a
+
1
],
vectors
[
a
+
2
]
);
vertices
.
push
(
vectors
[
b
],
vectors
[
b
+
1
],
vectors
[
b
+
2
]
);
vertices
.
push
(
vectors
[
c
],
vectors
[
c
+
1
],
vectors
[
c
+
2
]
);
};
buildPlane
(
'
z
'
,
'
y
'
,
-
1
,
-
1
,
this
.
depth
,
this
.
height
,
width_half
,
0
);
// px
buildPlane
(
'
z
'
,
'
y
'
,
1
,
-
1
,
this
.
depth
,
this
.
height
,
-
width_half
,
1
);
// nx
buildPlane
(
'
x
'
,
'
z
'
,
1
,
1
,
this
.
width
,
this
.
depth
,
height_half
,
2
);
// py
buildPlane
(
'
x
'
,
'
z
'
,
1
,
-
1
,
this
.
width
,
this
.
depth
,
-
height_half
,
3
);
// ny
buildPlane
(
'
x
'
,
'
y
'
,
1
,
-
1
,
this
.
width
,
this
.
height
,
depth_half
,
4
);
// pz
buildPlane
(
'
x
'
,
'
y
'
,
-
1
,
-
1
,
this
.
width
,
this
.
height
,
-
depth_half
,
5
);
// nz
function
buildPlane
(
u
,
v
,
udir
,
vdir
,
width
,
height
,
depth
,
materialIndex
)
{
var
w
,
ix
,
iy
,
gridX
=
scope
.
widthSegments
,
gridY
=
scope
.
heightSegments
,
width_half
=
width
/
2
,
height_half
=
height
/
2
,
offset
=
vectors
.
length
;
if
(
(
u
===
'
x
'
&&
v
===
'
y
'
)
||
(
u
===
'
y
'
&&
v
===
'
x
'
)
)
{
w
=
'
z
'
;
}
else
if
(
(
u
===
'
x
'
&&
v
===
'
z
'
)
||
(
u
===
'
z
'
&&
v
===
'
x
'
)
)
{
w
=
'
y
'
;
gridY
=
scope
.
depthSegments
;
}
else
if
(
(
u
===
'
z
'
&&
v
===
'
y
'
)
||
(
u
===
'
y
'
&&
v
===
'
z
'
)
)
{
w
=
'
x
'
;
gridX
=
scope
.
depthSegments
;
}
var
gridX1
=
gridX
+
1
,
gridY1
=
gridY
+
1
,
segment_width
=
width
/
gridX
,
segment_height
=
height
/
gridY
,
normal
=
new
THREE
.
Vector3
();
normal
[
w
]
=
depth
>
0
?
1
:
-
1
;
for
(
iy
=
0
;
iy
<
gridY1
;
iy
++
)
{
for
(
ix
=
0
;
ix
<
gridX1
;
ix
++
)
{
vector
[
u
]
=
(
ix
*
segment_width
-
width_half
)
*
udir
;
vector
[
v
]
=
(
iy
*
segment_height
-
height_half
)
*
vdir
;
vector
[
w
]
=
depth
;
vectors
.
push
(
vector
.
x
,
vector
.
y
,
vector
.
z
);
}
}
for
(
iy
=
0
;
iy
<
gridY
;
iy
++
)
{
for
(
ix
=
0
;
ix
<
gridX
;
ix
++
)
{
var
a
=
ix
+
gridX1
*
iy
;
var
b
=
ix
+
gridX1
*
(
iy
+
1
);
var
c
=
(
ix
+
1
)
+
gridX1
*
(
iy
+
1
);
var
d
=
(
ix
+
1
)
+
gridX1
*
iy
;
addVertex
(
a
*
3
+
offset
,
b
*
3
+
offset
,
d
*
3
+
offset
);
addVertex
(
b
*
3
+
offset
,
c
*
3
+
offset
,
d
*
3
+
offset
);
}
}
}
THREE
.
Geometry2
.
call
(
this
,
vertices
.
length
/
3
);
this
.
vertices
.
set
(
vertices
);
};
THREE
.
BoxGeometry2
.
prototype
=
Object
.
create
(
THREE
.
Geometry2
.
prototype
);
THREE
.
BoxGeometry2
.
prototype
.
constructor
=
THREE
.
BoxGeometry2
;
examples/js/wip/benchmark/Geometry2.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE
.
Geometry2
=
function
(
size
)
{
THREE
.
BufferGeometry
.
call
(
this
);
this
.
vertices
=
new
THREE
.
Float32Attribute
(
size
,
3
);
this
.
normals
=
new
THREE
.
Float32Attribute
(
size
,
3
);
this
.
uvs
=
new
THREE
.
Float32Attribute
(
size
,
2
);
this
.
addAttribute
(
'
position
'
,
this
.
vertices
);
this
.
addAttribute
(
'
normal
'
,
this
.
normals
);
this
.
addAttribute
(
'
uv
'
,
this
.
uvs
);
};
THREE
.
Geometry2
.
prototype
=
Object
.
create
(
THREE
.
BufferGeometry
.
prototype
);
THREE
.
Geometry2
.
prototype
.
constructor
=
THREE
.
Geometry2
;
\ No newline at end of file
examples/js/wip/benchmark/Geometry2Loader.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE
.
Geometry2Loader
=
function
(
manager
)
{
this
.
manager
=
(
manager
!==
undefined
)
?
manager
:
THREE
.
DefaultLoadingManager
;
};
THREE
.
Geometry2Loader
.
prototype
=
{
constructor
:
THREE
.
Geometry2Loader
,
load
:
function
(
url
,
onLoad
,
onProgress
,
onError
)
{
var
scope
=
this
;
var
loader
=
new
THREE
.
XHRLoader
();
loader
.
setCrossOrigin
(
this
.
crossOrigin
);
loader
.
load
(
url
,
function
(
text
)
{
onLoad
(
scope
.
parse
(
JSON
.
parse
(
text
)
)
);
}
);
},
setCrossOrigin
:
function
(
value
)
{
this
.
crossOrigin
=
value
;
},
parse
:
function
(
json
)
{
var
geometry
=
new
THREE
.
Geometry2
(
json
.
vertices
.
length
/
3
);
var
attributes
=
[
'
vertices
'
,
'
normals
'
,
'
uvs
'
];
var
boundingSphere
=
json
.
boundingSphere
;
for
(
var
key
in
attributes
)
{
var
attribute
=
attributes
[
key
];
geometry
[
attribute
].
set
(
json
[
attribute
]
);
}
if
(
boundingSphere
!==
undefined
)
{
var
center
=
new
THREE
.
Vector3
();
if
(
boundingSphere
.
center
!==
undefined
)
{
center
.
fromArray
(
boundingSphere
.
center
);
}
geometry
.
boundingSphere
=
new
THREE
.
Sphere
(
center
,
boundingSphere
.
radius
);
}
return
geometry
;
}
};
examples/js/wip/benchmark/Geometry3.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE
.
Geometry3
=
function
(
size
)
{
THREE
.
BufferGeometry
.
call
(
this
);
var
verticesBuffer
=
new
ArrayBuffer
(
size
*
3
*
4
);
var
normalsBuffer
=
new
ArrayBuffer
(
size
*
3
*
4
);
var
uvsBuffer
=
new
ArrayBuffer
(
size
*
2
*
4
);
this
.
vertices
=
[];
this
.
normals
=
[];
this
.
uvs
=
[];
for
(
var
i
=
0
;
i
<
size
;
i
++
)
{
this
.
vertices
.
push
(
new
Float32Array
(
verticesBuffer
,
i
*
3
*
4
,
3
)
);
this
.
normals
.
push
(
new
Float32Array
(
normalsBuffer
,
i
*
3
*
4
,
3
)
);
this
.
uvs
.
push
(
new
Float32Array
(
uvsBuffer
,
i
*
2
*
4
,
2
)
);
}
this
.
attributes
[
'
position
'
]
=
{
array
:
new
Float32Array
(
verticesBuffer
,
0
,
size
*
3
),
itemSize
:
3
};
this
.
attributes
[
'
normal
'
]
=
{
array
:
new
Float32Array
(
normalsBuffer
,
0
,
size
*
3
),
itemSize
:
3
};
this
.
attributes
[
'
uv
'
]
=
{
array
:
new
Float32Array
(
uvsBuffer
,
0
,
size
*
2
),
itemSize
:
2
};
};
THREE
.
Geometry3
.
prototype
=
Object
.
create
(
THREE
.
BufferGeometry
.
prototype
);
THREE
.
Geometry3
.
prototype
.
constructor
=
THREE
.
Geometry3
;
\ No newline at end of file
examples/js/wip/benchmark/Geometry4.js
已删除
100644 → 0
浏览文件 @
48ca3777
THREE
.
Geometry4
=
function
(
size
)
{
THREE
.
BufferGeometry
.
call
(
this
);
var
verticesBuffer
=
new
ArrayBuffer
(
size
*
3
*
4
);
var
normalsBuffer
=
new
ArrayBuffer
(
size
*
3
*
4
);
var
uvsBuffer
=
new
ArrayBuffer
(
size
*
2
*
4
);
this
.
attributes
[
'
position
'
]
=
{
array
:
new
Float32Array
(
verticesBuffer
,
0
,
size
*
3
),
itemSize
:
3
};
this
.
attributes
[
'
normal
'
]
=
{
array
:
new
Float32Array
(
normalsBuffer
,
0
,
size
*
3
),
itemSize
:
3
};
this
.
attributes
[
'
uv
'
]
=
{
array
:
new
Float32Array
(
uvsBuffer
,
0
,
size
*
2
),
itemSize
:
2
};
this
.
vertices
=
new
THREE
.
VectorArrayProxy
(
this
.
attributes
[
'
position
'
]
);
this
.
normals
=
new
THREE
.
VectorArrayProxy
(
this
.
attributes
[
'
normal
'
]
);
this
.
uvs
=
new
THREE
.
VectorArrayProxy
(
this
.
attributes
[
'
uv
'
]
);
};
THREE
.
Geometry4
.
prototype
=
Object
.
create
(
THREE
.
BufferGeometry
.
prototype
);
THREE
.
Geometry4
.
prototype
.
constructor
=
THREE
.
Geometry4
;
THREE
.
VectorArrayProxy
=
function
(
attribute
)
{
// Acts as a proxy for an array of vectors, by setting up accessors which return THREE.Vector*Proxy objects
this
.
attribute
=
attribute
;
for
(
var
i
=
0
,
l
=
this
.
attribute
.
array
.
length
/
this
.
attribute
.
itemSize
;
i
<
l
;
i
++
)
{
Object
.
defineProperty
(
this
,
i
,
{
get
:
(
function
(
i
)
{
return
function
()
{
return
this
.
getValue
(
i
);
}})(
i
),
set
:
(
function
(
i
)
{
return
function
(
v
)
{
return
this
.
setValue
(
i
,
v
);
}})(
i
),
});
}
};
THREE
.
VectorArrayProxy
.
prototype
.
getValue
=
function
(
i
)
{
// Allocates a new THREE.Vector2Proxy or THREE.Vector3Proxy depending on the itemSize of our attribute
var
subarray
=
this
.
attribute
.
array
.
subarray
(
i
*
this
.
attribute
.
itemSize
,
(
i
+
1
)
*
this
.
attribute
.
itemSize
);
switch
(
this
.
attribute
.
itemSize
)
{
case
2
:
return
new
THREE
.
Vector2Proxy
(
subarray
);
case
3
:
return
new
THREE
.
Vector3Proxy
(
subarray
);
}
};
THREE
.
VectorArrayProxy
.
prototype
.
setValue
=
function
(
i
,
v
)
{
var
vec
=
this
[
i
];
vec
.
copy
(
v
);
};
// Vector Proxy Objects
THREE
.
Vector2Proxy
=
function
(
subarray
)
{
this
.
subarray
=
subarray
;
};
THREE
.
Vector2Proxy
.
prototype
=
Object
.
create
(
THREE
.
Vector2
.
prototype
);
THREE
.
Vector2Proxy
.
prototype
.
constructor
=
THREE
.
Vector2Proxy
;
Object
.
defineProperty
(
THREE
.
Vector2Proxy
.
prototype
,
'
x
'
,
{
get
:
function
()
{
return
this
.
subarray
[
0
];
},
set
:
function
(
v
)
{
this
.
subarray
[
0
]
=
v
;
}
});
Object
.
defineProperty
(
THREE
.
Vector2Proxy
.
prototype
,
'
y
'
,
{
get
:
function
()
{
return
this
.
subarray
[
1
];
},
set
:
function
(
v
)
{
this
.
subarray
[
1
]
=
v
;
}
});
THREE
.
Vector3Proxy
=
function
(
subarray
)
{
this
.
subarray
=
subarray
;
};
THREE
.
Vector3Proxy
.
prototype
=
Object
.
create
(
THREE
.
Vector3
.
prototype
);
THREE
.
Vector3Proxy
.
prototype
.
constructor
=
THREE
.
Vector3Proxy
;
Object
.
defineProperty
(
THREE
.
Vector3Proxy
.
prototype
,
'
x
'
,
{
get
:
function
()
{
return
this
.
subarray
[
0
];
},
set
:
function
(
v
)
{
this
.
subarray
[
0
]
=
v
;
}
});
Object
.
defineProperty
(
THREE
.
Vector3Proxy
.
prototype
,
'
y
'
,
{
get
:
function
()
{
return
this
.
subarray
[
1
];
},
set
:
function
(
v
)
{
this
.
subarray
[
1
]
=
v
;
}
});
Object
.
defineProperty
(
THREE
.
Vector3Proxy
.
prototype
,
'
z
'
,
{
get
:
function
()
{
return
this
.
subarray
[
2
];
},
set
:
function
(
v
)
{
this
.
subarray
[
2
]
=
v
;
}
});
\ No newline at end of file
examples/js/wip/benchmark/Geometry5.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE
.
Geometry5
=
function
(
size
)
{
THREE
.
BufferGeometry
.
call
(
this
);
var
verticesBuffer
=
new
Float32Array
(
size
*
3
);
var
normalsBuffer
=
new
Float32Array
(
size
*
3
);
var
uvsBuffer
=
new
Float32Array
(
size
*
2
);
this
.
vertices
=
[];
this
.
normals
=
[];
this
.
uvs
=
[];
for
(
var
i
=
0
;
i
<
size
;
i
++
)
{
this
.
vertices
.
push
(
new
THREE
.
TypedVector3
(
verticesBuffer
,
i
*
3
)
);
this
.
normals
.
push
(
new
THREE
.
TypedVector3
(
normalsBuffer
,
i
*
3
)
);
this
.
uvs
.
push
(
new
THREE
.
TypedVector2
(
uvsBuffer
,
i
*
2
)
);
}
this
.
attributes
[
'
position
'
]
=
{
array
:
verticesBuffer
,
itemSize
:
3
};
this
.
attributes
[
'
normal
'
]
=
{
array
:
normalsBuffer
,
itemSize
:
3
};
this
.
attributes
[
'
uv
'
]
=
{
array
:
uvsBuffer
,
itemSize
:
2
};
};
THREE
.
Geometry5
.
prototype
=
Object
.
create
(
THREE
.
BufferGeometry
.
prototype
);
THREE
.
Geometry5
.
prototype
.
constructor
=
THREE
.
Geometry5
;
THREE
.
TypedVector2
=
function
(
array
,
offset
)
{
this
.
array
=
array
;
this
.
offset
=
offset
;
};
THREE
.
TypedVector2
.
prototype
=
Object
.
create
(
THREE
.
Vector2
.
prototype
);
THREE
.
TypedVector2
.
prototype
.
constructor
=
THREE
.
TypedVector2
;
Object
.
defineProperties
(
THREE
.
TypedVector2
.
prototype
,
{
'
x
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
]
=
v
;
}
},
'
y
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
1
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
1
]
=
v
;
}
}
}
);
THREE
.
TypedVector3
=
function
(
array
,
offset
)
{
this
.
array
=
array
;
this
.
offset
=
offset
;
};
THREE
.
TypedVector3
.
prototype
=
Object
.
create
(
THREE
.
Vector3
.
prototype
);
THREE
.
TypedVector3
.
prototype
.
constructor
=
THREE
.
TypedVector3
;
Object
.
defineProperties
(
THREE
.
TypedVector3
.
prototype
,
{
'
x
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
]
=
v
;
}
},
'
y
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
1
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
1
]
=
v
;
}
},
'
z
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
2
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
2
]
=
v
;
}
}
}
);
\ No newline at end of file
examples/js/wip/benchmark/Geometry5b.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE
.
Geometry5b
=
function
(
bufferGeometry
)
{
THREE
.
BufferGeometry
.
call
(
this
);
this
.
attributes
=
bufferGeometry
.
attributes
;
var
verticesBuffer
=
this
.
attributes
.
position
.
array
;
var
normalsBuffer
=
this
.
attributes
.
normal
.
array
;
var
uvsBuffer
=
this
.
attributes
.
uv
.
array
;
this
.
vertices
=
[];
this
.
normals
=
[];
this
.
uvs
=
[];
for
(
var
i
=
0
,
l
=
verticesBuffer
.
length
/
3
;
i
<
l
;
i
++
)
{
this
.
vertices
.
push
(
new
THREE
.
TypedVector3
(
verticesBuffer
,
i
*
3
)
);
this
.
normals
.
push
(
new
THREE
.
TypedVector3
(
normalsBuffer
,
i
*
3
)
);
this
.
uvs
.
push
(
new
THREE
.
TypedVector2
(
uvsBuffer
,
i
*
2
)
);
}
};
THREE
.
Geometry5b
.
prototype
=
Object
.
create
(
THREE
.
BufferGeometry
.
prototype
);
THREE
.
Geometry5b
.
prototype
.
constructor
=
THREE
.
Geometry5b
;
THREE
.
TypedVector2
=
function
(
array
,
offset
)
{
this
.
array
=
array
;
this
.
offset
=
offset
;
};
THREE
.
TypedVector2
.
prototype
=
Object
.
create
(
THREE
.
Vector2
.
prototype
);
THREE
.
TypedVector2
.
prototype
.
constructor
=
THREE
.
TypedVector2
;
Object
.
defineProperties
(
THREE
.
TypedVector2
.
prototype
,
{
'
x
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
]
=
v
;
}
},
'
y
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
1
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
1
]
=
v
;
}
}
}
);
THREE
.
TypedVector3
=
function
(
array
,
offset
)
{
this
.
array
=
array
;
this
.
offset
=
offset
;
};
THREE
.
TypedVector3
.
prototype
=
Object
.
create
(
THREE
.
Vector3
.
prototype
);
THREE
.
TypedVector3
.
prototype
.
constructor
=
THREE
.
TypedVector3
;
Object
.
defineProperties
(
THREE
.
TypedVector3
.
prototype
,
{
'
x
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
]
=
v
;
}
},
'
y
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
1
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
1
]
=
v
;
}
},
'
z
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
2
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
2
]
=
v
;
}
}
}
);
\ No newline at end of file
examples/js/wip/benchmark/IndexedGeometry3.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE
.
IndexedGeometry3
=
function
(
indices
,
size
)
{
THREE
.
BufferGeometry
.
call
(
this
);
var
verticesBuffer
=
new
ArrayBuffer
(
size
*
3
*
4
);
var
normalsBuffer
=
new
ArrayBuffer
(
size
*
3
*
4
);
var
uvsBuffer
=
new
ArrayBuffer
(
size
*
2
*
4
);
this
.
indices
=
new
Uint16Array
(
indices
);
this
.
vertices
=
[];
this
.
normals
=
[];
this
.
uvs
=
[];
for
(
var
i
=
0
;
i
<
size
;
i
++
)
{
this
.
vertices
.
push
(
new
Float32Array
(
verticesBuffer
,
i
*
3
*
4
,
3
)
);
this
.
normals
.
push
(
new
Float32Array
(
normalsBuffer
,
i
*
3
*
4
,
3
)
);
this
.
uvs
.
push
(
new
Float32Array
(
uvsBuffer
,
i
*
2
*
4
,
2
)
);
}
this
.
attributes
[
'
index
'
]
=
{
array
:
this
.
indices
,
itemSize
:
1
};
this
.
attributes
[
'
position
'
]
=
{
array
:
new
Float32Array
(
verticesBuffer
,
0
,
size
*
3
),
itemSize
:
3
};
this
.
attributes
[
'
normal
'
]
=
{
array
:
new
Float32Array
(
normalsBuffer
,
0
,
size
*
3
),
itemSize
:
3
};
this
.
attributes
[
'
uv
'
]
=
{
array
:
new
Float32Array
(
uvsBuffer
,
0
,
size
*
2
),
itemSize
:
2
};
};
THREE
.
Geometry3
.
prototype
=
Object
.
create
(
THREE
.
BufferGeometry
.
prototype
);
THREE
.
Geometry3
.
prototype
.
constructor
=
THREE
.
Geometry3
;
\ No newline at end of file
examples/js/wip/benchmark/IndexedGeometry5.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE
.
IndexedGeometry5
=
function
(
indices
,
size
)
{
THREE
.
BufferGeometry
.
call
(
this
);
var
verticesBuffer
=
new
Float32Array
(
size
*
3
);
var
normalsBuffer
=
new
Float32Array
(
size
*
3
);
var
uvsBuffer
=
new
Float32Array
(
size
*
2
);
this
.
indices
=
new
Uint16Array
(
indices
);
this
.
vertices
=
[];
this
.
normals
=
[];
this
.
uvs
=
[];
for
(
var
i
=
0
;
i
<
size
;
i
++
)
{
this
.
vertices
.
push
(
new
THREE
.
TypedVector3
(
verticesBuffer
,
i
*
3
)
);
this
.
normals
.
push
(
new
THREE
.
TypedVector3
(
normalsBuffer
,
i
*
3
)
);
this
.
uvs
.
push
(
new
THREE
.
TypedVector2
(
uvsBuffer
,
i
*
2
)
);
}
this
.
attributes
[
'
index
'
]
=
{
array
:
this
.
indices
,
itemSize
:
1
};
this
.
attributes
[
'
position
'
]
=
{
array
:
verticesBuffer
,
itemSize
:
3
};
this
.
attributes
[
'
normal
'
]
=
{
array
:
normalsBuffer
,
itemSize
:
3
};
this
.
attributes
[
'
uv
'
]
=
{
array
:
uvsBuffer
,
itemSize
:
2
};
};
THREE
.
IndexedGeometry5
.
prototype
=
Object
.
create
(
THREE
.
BufferGeometry
.
prototype
);
THREE
.
IndexedGeometry5
.
prototype
.
constructor
=
THREE
.
IndexedGeometry5
;
THREE
.
TypedVector2
=
function
(
array
,
offset
)
{
this
.
array
=
array
;
this
.
offset
=
offset
;
};
THREE
.
TypedVector2
.
prototype
=
Object
.
create
(
THREE
.
Vector2
.
prototype
);
THREE
.
TypedVector2
.
prototype
.
constructor
=
THREE
.
TypedVector2
;
Object
.
defineProperties
(
THREE
.
TypedVector2
.
prototype
,
{
'
x
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
]
=
v
;
}
},
'
y
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
1
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
1
]
=
v
;
}
}
}
);
THREE
.
TypedVector3
=
function
(
array
,
offset
)
{
this
.
array
=
array
;
this
.
offset
=
offset
;
};
THREE
.
TypedVector3
.
prototype
=
Object
.
create
(
THREE
.
Vector3
.
prototype
);
THREE
.
TypedVector3
.
prototype
.
constructor
=
THREE
.
TypedVector3
;
Object
.
defineProperties
(
THREE
.
TypedVector3
.
prototype
,
{
'
x
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
]
=
v
;
}
},
'
y
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
1
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
1
]
=
v
;
}
},
'
z
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
2
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
2
]
=
v
;
}
}
}
);
\ No newline at end of file
examples/js/wip/benchmark/IndexedPlaneGeometry5.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
* based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
*/
THREE
.
IndexedPlaneGeometry5
=
function
(
width
,
height
,
widthSegments
,
heightSegments
)
{
this
.
width
=
width
;
this
.
height
=
height
;
this
.
widthSegments
=
widthSegments
||
1
;
this
.
heightSegments
=
heightSegments
||
1
;
var
width_half
=
width
/
2
;
var
height_half
=
height
/
2
;
var
gridX
=
this
.
widthSegments
;
var
gridY
=
this
.
heightSegments
;
var
gridX1
=
gridX
+
1
;
var
gridY1
=
gridY
+
1
;
var
segment_width
=
this
.
width
/
gridX
;
var
segment_height
=
this
.
height
/
gridY
;
var
indices
=
gridX
*
gridY
*
6
;
var
vertices
=
gridX1
*
gridY1
;
THREE
.
IndexedGeometry5
.
call
(
this
,
indices
,
vertices
);
var
offset
=
0
;
for
(
var
iy
=
0
;
iy
<
gridY1
;
iy
++
)
{
var
y
=
iy
*
segment_height
-
height_half
;
for
(
var
ix
=
0
;
ix
<
gridX1
;
ix
++
)
{
var
x
=
ix
*
segment_width
-
width_half
;
this
.
vertices
[
offset
].
x
=
x
;
this
.
vertices
[
offset
].
y
=
-
y
;
this
.
normals
[
offset
].
z
=
1
;
this
.
uvs
[
offset
].
x
=
ix
/
gridX
;
this
.
uvs
[
offset
].
y
=
iy
/
gridY
;
offset
++
;
}
}
var
offset
=
0
;
for
(
var
iy
=
0
;
iy
<
gridY
;
iy
++
)
{
for
(
var
ix
=
0
;
ix
<
gridX
;
ix
++
)
{
var
a
=
ix
+
gridX1
*
iy
;
var
b
=
ix
+
gridX1
*
(
iy
+
1
);
var
c
=
(
ix
+
1
)
+
gridX1
*
(
iy
+
1
);
var
d
=
(
ix
+
1
)
+
gridX1
*
iy
;
this
.
indices
[
offset
]
=
a
;
this
.
indices
[
offset
+
1
]
=
b
;
this
.
indices
[
offset
+
2
]
=
d
;
this
.
indices
[
offset
+
3
]
=
b
;
this
.
indices
[
offset
+
4
]
=
c
;
this
.
indices
[
offset
+
5
]
=
d
;
offset
+=
6
;
}
}
};
THREE
.
IndexedPlaneGeometry5
.
prototype
=
Object
.
create
(
THREE
.
IndexedGeometry5
.
prototype
);
THREE
.
IndexedPlaneGeometry5
.
prototype
.
constructor
=
THREE
.
IndexedPlaneGeometry5
;
examples/js/wip/benchmark/PlaneGeometry.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
* based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
*/
THREE
.
PlaneGeometry
=
function
(
width
,
height
,
widthSegments
,
heightSegments
)
{
THREE
.
Geometry
.
call
(
this
);
this
.
width
=
width
;
this
.
height
=
height
;
this
.
widthSegments
=
widthSegments
||
1
;
this
.
heightSegments
=
heightSegments
||
1
;
var
ix
,
iz
;
var
width_half
=
width
/
2
;
var
height_half
=
height
/
2
;
var
gridX
=
this
.
widthSegments
;
var
gridZ
=
this
.
heightSegments
;
var
gridX1
=
gridX
+
1
;
var
gridZ1
=
gridZ
+
1
;
var
segment_width
=
this
.
width
/
gridX
;
var
segment_height
=
this
.
height
/
gridZ
;
var
normal
=
new
THREE
.
Vector3
(
0
,
0
,
1
);
for
(
iz
=
0
;
iz
<
gridZ1
;
iz
++
)
{
for
(
ix
=
0
;
ix
<
gridX1
;
ix
++
)
{
var
x
=
ix
*
segment_width
-
width_half
;
var
y
=
iz
*
segment_height
-
height_half
;
this
.
vertices
.
push
(
new
THREE
.
Vector3
(
x
,
-
y
,
0
)
);
}
}
for
(
iz
=
0
;
iz
<
gridZ
;
iz
++
)
{
for
(
ix
=
0
;
ix
<
gridX
;
ix
++
)
{
var
a
=
ix
+
gridX1
*
iz
;
var
b
=
ix
+
gridX1
*
(
iz
+
1
);
var
c
=
(
ix
+
1
)
+
gridX1
*
(
iz
+
1
);
var
d
=
(
ix
+
1
)
+
gridX1
*
iz
;
var
uva
=
new
THREE
.
Vector2
(
ix
/
gridX
,
1
-
iz
/
gridZ
);
var
uvb
=
new
THREE
.
Vector2
(
ix
/
gridX
,
1
-
(
iz
+
1
)
/
gridZ
);
var
uvc
=
new
THREE
.
Vector2
(
(
ix
+
1
)
/
gridX
,
1
-
(
iz
+
1
)
/
gridZ
);
var
uvd
=
new
THREE
.
Vector2
(
(
ix
+
1
)
/
gridX
,
1
-
iz
/
gridZ
);
var
face
=
new
THREE
.
Face3
(
a
,
b
,
d
);
face
.
normal
.
copy
(
normal
);
face
.
vertexNormals
.
push
(
normal
.
clone
(),
normal
.
clone
(),
normal
.
clone
()
);
this
.
faces
.
push
(
face
);
this
.
faceVertexUvs
[
0
].
push
(
[
uva
,
uvb
,
uvd
]
);
face
=
new
THREE
.
Face3
(
b
,
c
,
d
);
face
.
normal
.
copy
(
normal
);
face
.
vertexNormals
.
push
(
normal
.
clone
(),
normal
.
clone
(),
normal
.
clone
()
);
this
.
faces
.
push
(
face
);
this
.
faceVertexUvs
[
0
].
push
(
[
uvb
.
clone
(),
uvc
,
uvd
.
clone
()
]
);
}
}
};
THREE
.
PlaneGeometry
.
prototype
=
Object
.
create
(
THREE
.
Geometry
.
prototype
);
THREE
.
PlaneGeometry
.
prototype
.
constructor
=
THREE
.
PlaneGeometry
;
examples/js/wip/benchmark/PlaneGeometry2.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
* based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
*/
THREE
.
PlaneGeometry2
=
function
(
width
,
height
,
widthSegments
,
heightSegments
)
{
THREE
.
Geometry2
.
call
(
this
,
(
widthSegments
*
heightSegments
)
*
2
*
3
);
var
vertices
=
this
.
vertices
.
array
;
var
normals
=
this
.
normals
.
array
;
var
uvs
=
this
.
uvs
.
array
;
this
.
width
=
width
;
this
.
height
=
height
;
this
.
widthSegments
=
widthSegments
||
1
;
this
.
heightSegments
=
heightSegments
||
1
;
var
widthHalf
=
width
/
2
;
var
heightHalf
=
height
/
2
;
var
gridX
=
this
.
widthSegments
;
var
gridY
=
this
.
heightSegments
;
var
segmentWidth
=
this
.
width
/
gridX
;
var
segmentHeight
=
this
.
height
/
gridY
;
var
offset
=
0
;
for
(
var
iy
=
0
;
iy
<
gridY
;
iy
++
)
{
var
y1
=
iy
*
segmentHeight
-
heightHalf
;
var
y2
=
(
iy
+
1
)
*
segmentHeight
-
heightHalf
;
for
(
var
ix
=
0
;
ix
<
gridX
;
ix
++
)
{
var
x1
=
ix
*
segmentWidth
-
widthHalf
;
var
x2
=
(
ix
+
1
)
*
segmentWidth
-
widthHalf
;
vertices
[
offset
+
0
]
=
x1
;
vertices
[
offset
+
1
]
=
y1
;
vertices
[
offset
+
3
]
=
x2
;
vertices
[
offset
+
4
]
=
y1
;
vertices
[
offset
+
6
]
=
x1
;
vertices
[
offset
+
7
]
=
y2
;
normals
[
offset
+
2
]
=
1
;
normals
[
offset
+
5
]
=
1
;
normals
[
offset
+
8
]
=
1
;
vertices
[
offset
+
9
]
=
x2
;
vertices
[
offset
+
10
]
=
y1
;
vertices
[
offset
+
12
]
=
x2
;
vertices
[
offset
+
13
]
=
y2
;
vertices
[
offset
+
15
]
=
x1
;
vertices
[
offset
+
16
]
=
y2
;
normals
[
offset
+
11
]
=
1
;
normals
[
offset
+
13
]
=
1
;
normals
[
offset
+
17
]
=
1
;
offset
+=
18
;
}
}
};
THREE
.
PlaneGeometry2
.
prototype
=
Object
.
create
(
THREE
.
Geometry2
.
prototype
);
THREE
.
PlaneGeometry2
.
prototype
.
constructor
=
THREE
.
PlaneGeometry2
;
examples/js/wip/benchmark/PlaneGeometry2b.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
* based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
*/
THREE
.
PlaneGeometry2b
=
function
(
width
,
height
,
widthSegments
,
heightSegments
)
{
THREE
.
Geometry2
.
call
(
this
,
(
widthSegments
*
heightSegments
)
*
2
*
3
);
var
vertices
=
this
.
vertices
;
var
normals
=
this
.
normals
;
var
uvs
=
this
.
uvs
;
this
.
width
=
width
;
this
.
height
=
height
;
this
.
widthSegments
=
widthSegments
||
1
;
this
.
heightSegments
=
heightSegments
||
1
;
var
widthHalf
=
width
/
2
;
var
heightHalf
=
height
/
2
;
var
gridX
=
this
.
widthSegments
;
var
gridY
=
this
.
heightSegments
;
var
segmentWidth
=
this
.
width
/
gridX
;
var
segmentHeight
=
this
.
height
/
gridY
;
var
index
=
0
;
for
(
var
iy
=
0
;
iy
<
gridY
;
iy
++
)
{
var
y1
=
iy
*
segmentHeight
-
heightHalf
;
var
y2
=
(
iy
+
1
)
*
segmentHeight
-
heightHalf
;
for
(
var
ix
=
0
;
ix
<
gridX
;
ix
++
)
{
var
x1
=
ix
*
segmentWidth
-
widthHalf
;
var
x2
=
(
ix
+
1
)
*
segmentWidth
-
widthHalf
;
this
.
vertices
.
setXY
(
index
+
0
,
x1
,
y1
);
this
.
vertices
.
setXY
(
index
+
1
,
x2
,
y1
);
this
.
vertices
.
setXY
(
index
+
2
,
x1
,
y2
);
this
.
vertices
.
setXY
(
index
+
3
,
x2
,
y1
);
this
.
vertices
.
setXY
(
index
+
4
,
x2
,
y2
);
this
.
vertices
.
setXY
(
index
+
5
,
x1
,
y2
);
this
.
normals
.
setZ
(
index
+
0
,
1
);
this
.
normals
.
setZ
(
index
+
1
,
1
);
this
.
normals
.
setZ
(
index
+
2
,
1
);
this
.
normals
.
setZ
(
index
+
3
,
1
);
this
.
normals
.
setZ
(
index
+
4
,
1
);
this
.
normals
.
setZ
(
index
+
5
,
1
);
index
+=
6
;
}
}
};
THREE
.
PlaneGeometry2b
.
prototype
=
Object
.
create
(
THREE
.
Geometry2
.
prototype
);
THREE
.
PlaneGeometry2b
.
prototype
.
constructor
=
THREE
.
PlaneGeometry2b
;
examples/js/wip/benchmark/PlaneGeometry3.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
* based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
*/
THREE
.
PlaneGeometry3
=
function
(
width
,
height
,
widthSegments
,
heightSegments
)
{
THREE
.
Geometry3
.
call
(
this
,
(
widthSegments
*
heightSegments
)
*
2
*
3
);
var
vertices
=
this
.
vertices
;
var
normals
=
this
.
normals
;
var
uvs
=
this
.
uvs
;
this
.
width
=
width
;
this
.
height
=
height
;
this
.
widthSegments
=
widthSegments
||
1
;
this
.
heightSegments
=
heightSegments
||
1
;
var
widthHalf
=
width
/
2
;
var
heightHalf
=
height
/
2
;
var
gridX
=
this
.
widthSegments
;
var
gridY
=
this
.
heightSegments
;
var
segmentWidth
=
this
.
width
/
gridX
;
var
segmentHeight
=
this
.
height
/
gridY
;
var
offset
=
0
;
for
(
var
iy
=
0
;
iy
<
gridY
;
iy
++
)
{
var
y1
=
iy
*
segmentHeight
-
heightHalf
;
var
y2
=
(
iy
+
1
)
*
segmentHeight
-
heightHalf
;
for
(
var
ix
=
0
;
ix
<
gridX
;
ix
++
)
{
var
x1
=
ix
*
segmentWidth
-
widthHalf
;
var
x2
=
(
ix
+
1
)
*
segmentWidth
-
widthHalf
;
vertices
[
offset
+
0
][
0
]
=
x1
;
vertices
[
offset
+
0
][
1
]
=
y1
;
vertices
[
offset
+
1
][
0
]
=
x2
;
vertices
[
offset
+
1
][
1
]
=
y1
;
vertices
[
offset
+
2
][
0
]
=
x1
;
vertices
[
offset
+
2
][
1
]
=
y2
;
normals
[
offset
+
0
][
2
]
=
1
;
normals
[
offset
+
1
][
2
]
=
1
;
normals
[
offset
+
2
][
2
]
=
1
;
vertices
[
offset
+
3
][
0
]
=
x2
;
vertices
[
offset
+
3
][
1
]
=
y1
;
vertices
[
offset
+
4
][
0
]
=
x2
;
vertices
[
offset
+
4
][
1
]
=
y2
;
vertices
[
offset
+
5
][
0
]
=
x1
;
vertices
[
offset
+
5
][
1
]
=
y2
;
normals
[
offset
+
3
][
2
]
=
1
;
normals
[
offset
+
4
][
2
]
=
1
;
normals
[
offset
+
5
][
2
]
=
1
;
offset
+=
6
;
}
}
};
THREE
.
PlaneGeometry3
.
prototype
=
Object
.
create
(
THREE
.
Geometry3
.
prototype
);
THREE
.
PlaneGeometry3
.
prototype
.
constructor
=
THREE
.
PlaneGeometry3
;
examples/js/wip/benchmark/PlaneGeometry5.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
* based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
*/
THREE
.
PlaneGeometry5
=
function
(
width
,
height
,
widthSegments
,
heightSegments
)
{
THREE
.
Geometry5
.
call
(
this
,
(
widthSegments
*
heightSegments
)
*
2
*
3
);
var
vertices
=
this
.
vertices
;
var
normals
=
this
.
normals
;
var
uvs
=
this
.
uvs
;
this
.
width
=
width
;
this
.
height
=
height
;
this
.
widthSegments
=
widthSegments
||
1
;
this
.
heightSegments
=
heightSegments
||
1
;
var
widthHalf
=
width
/
2
;
var
heightHalf
=
height
/
2
;
var
gridX
=
this
.
widthSegments
;
var
gridY
=
this
.
heightSegments
;
var
segmentWidth
=
this
.
width
/
gridX
;
var
segmentHeight
=
this
.
height
/
gridY
;
var
offset
=
0
;
for
(
var
iy
=
0
;
iy
<
gridY
;
iy
++
)
{
var
y1
=
iy
*
segmentHeight
-
heightHalf
;
var
y2
=
(
iy
+
1
)
*
segmentHeight
-
heightHalf
;
for
(
var
ix
=
0
;
ix
<
gridX
;
ix
++
)
{
var
x1
=
ix
*
segmentWidth
-
widthHalf
;
var
x2
=
(
ix
+
1
)
*
segmentWidth
-
widthHalf
;
vertices
[
offset
+
0
].
set
(
x1
,
y1
,
0
);
vertices
[
offset
+
1
].
set
(
x2
,
y1
,
0
);
vertices
[
offset
+
2
].
set
(
x1
,
y2
,
0
);
normals
[
offset
+
0
].
z
=
1
;
normals
[
offset
+
1
].
z
=
1
;
normals
[
offset
+
2
].
z
=
1
;
vertices
[
offset
+
3
].
set
(
x2
,
y1
,
0
);
vertices
[
offset
+
4
].
set
(
x2
,
y2
,
0
);
vertices
[
offset
+
5
].
set
(
x1
,
y2
,
0
);
normals
[
offset
+
3
].
z
=
1
;
normals
[
offset
+
4
].
z
=
1
;
normals
[
offset
+
5
].
z
=
1
;
offset
+=
6
;
}
}
};
THREE
.
PlaneGeometry5
.
prototype
=
Object
.
create
(
THREE
.
Geometry5
.
prototype
);
THREE
.
PlaneGeometry5
.
prototype
.
constructor
=
THREE
.
PlaneGeometry5
;
examples/js/wip/benchmark/PlaneGeometry6.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE
.
PlaneGeometry6
=
function
(
width
,
height
,
widthSegments
,
heightSegments
)
{
THREE
.
PlaneBufferGeometry
.
call
(
this
,
width
,
height
,
widthSegments
,
heightSegments
);
var
indices
=
this
.
attributes
.
index
.
array
;
var
vertices
=
this
.
attributes
.
position
.
array
;
var
normals
=
this
.
attributes
.
normal
.
array
;
var
uvs
=
this
.
attributes
.
uv
.
array
;
this
.
indices
=
indices
;
this
.
vertices
=
[];
this
.
normals
=
[];
this
.
uvs
=
[];
for
(
var
i
=
0
,
l
=
vertices
.
length
/
3
;
i
<
l
;
i
++
)
{
this
.
vertices
.
push
(
new
THREE
.
TypedVector3
(
vertices
,
i
*
3
)
);
this
.
normals
.
push
(
new
THREE
.
TypedVector3
(
normals
,
i
*
3
)
);
this
.
uvs
.
push
(
new
THREE
.
TypedVector2
(
uvs
,
i
*
2
)
);
}
};
THREE
.
PlaneGeometry6
.
prototype
=
Object
.
create
(
THREE
.
PlaneBufferGeometry
.
prototype
);
THREE
.
PlaneGeometry6
.
prototype
.
constructor
=
THREE
.
PlaneGeometry6
;
\ No newline at end of file
examples/js/wip/benchmark/PlaneGeometry99.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE
.
PlaneGeometry99
=
function
(
width
,
height
,
widthSegments
,
heightSegments
)
{
THREE
.
Geometry99
.
call
(
this
);
this
.
parameters
=
{
width
:
width
,
height
:
height
,
widthSegments
:
widthSegments
,
heightSegments
:
heightSegments
};
var
width_half
=
width
/
2
;
var
height_half
=
height
/
2
;
var
gridX
=
widthSegments
||
1
;
var
gridY
=
heightSegments
||
1
;
var
gridX1
=
gridX
+
1
;
var
gridY1
=
gridY
+
1
;
var
segment_width
=
width
/
gridX
;
var
segment_height
=
height
/
gridY
;
var
vertices
=
new
Float32Array
(
gridX1
*
gridY1
*
3
);
var
normals
=
new
Float32Array
(
gridX1
*
gridY1
*
3
);
var
uvs
=
new
Float32Array
(
gridX1
*
gridY1
*
2
);
var
offset
=
0
;
var
offset2
=
0
;
for
(
var
iy
=
0
;
iy
<
gridY1
;
iy
++
)
{
var
y
=
iy
*
segment_height
-
height_half
;
for
(
var
ix
=
0
;
ix
<
gridX1
;
ix
++
)
{
var
x
=
ix
*
segment_width
-
width_half
;
vertices
[
offset
]
=
x
;
vertices
[
offset
+
1
]
=
-
y
;
normals
[
offset
+
2
]
=
1
;
uvs
[
offset2
]
=
ix
/
gridX
;
uvs
[
offset2
+
1
]
=
1
-
(
iy
/
gridY
);
offset
+=
3
;
offset2
+=
2
;
}
}
offset
=
0
;
var
indices
=
new
Uint16Array
(
gridX
*
gridY
*
6
);
for
(
var
iy
=
0
;
iy
<
gridY
;
iy
++
)
{
for
(
var
ix
=
0
;
ix
<
gridX
;
ix
++
)
{
var
a
=
ix
+
gridX1
*
iy
;
var
b
=
ix
+
gridX1
*
(
iy
+
1
);
var
c
=
(
ix
+
1
)
+
gridX1
*
(
iy
+
1
);
var
d
=
(
ix
+
1
)
+
gridX1
*
iy
;
indices
[
offset
]
=
a
;
indices
[
offset
+
1
]
=
b
;
indices
[
offset
+
2
]
=
d
;
indices
[
offset
+
3
]
=
b
;
indices
[
offset
+
4
]
=
c
;
indices
[
offset
+
5
]
=
d
;
offset
+=
6
;
}
}
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
.
PlaneGeometry99
.
prototype
=
Object
.
create
(
THREE
.
Geometry99
.
prototype
);
THREE
.
PlaneGeometry99
.
prototype
.
constructor
=
THREE
.
PlaneGeometry99
;
\ No newline at end of file
examples/js/wip/benchmark/TypedGeometry.js
已删除
100644 → 0
浏览文件 @
48ca3777
THREE
.
TypedVector2
=
function
(
array
,
offset
)
{
this
.
array
=
array
;
this
.
offset
=
offset
*
2
;
};
THREE
.
TypedVector2
.
prototype
=
{
constructor
:
THREE
.
TypedVector2
,
get
x
()
{
return
this
.
array
[
this
.
offset
];
},
set
x
(
value
)
{
this
.
array
[
this
.
offset
]
=
value
;
},
get
y
()
{
return
this
.
array
[
this
.
offset
+
1
];
},
set
y
(
value
)
{
this
.
array
[
this
.
offset
+
1
]
=
value
;
},
set
:
function
(
x
,
y
)
{
this
.
array
[
this
.
offset
]
=
x
;
this
.
array
[
this
.
offset
+
1
]
=
y
;
return
this
;
}
};
THREE
.
TypedVector3
=
function
(
array
,
offset
)
{
this
.
array
=
array
;
this
.
offset
=
offset
*
3
;
};
THREE
.
TypedVector3
.
prototype
=
{
constructor
:
THREE
.
TypedVector3
,
get
x
()
{
return
this
.
array
[
this
.
offset
];
},
set
x
(
value
)
{
this
.
array
[
this
.
offset
]
=
value
;
},
get
y
()
{
return
this
.
array
[
this
.
offset
+
1
];
},
set
y
(
value
)
{
this
.
array
[
this
.
offset
+
1
]
=
value
;
},
get
z
()
{
return
this
.
array
[
this
.
offset
+
2
];
},
set
z
(
value
)
{
this
.
array
[
this
.
offset
+
2
]
=
value
;
},
set
:
function
(
x
,
y
,
z
)
{
this
.
array
[
this
.
offset
]
=
x
;
this
.
array
[
this
.
offset
+
1
]
=
y
;
this
.
array
[
this
.
offset
+
2
]
=
z
;
return
this
;
},
toString
:
function
()
{
return
'
[
'
+
this
.
array
[
this
.
offset
]
+
'
,
'
+
this
.
array
[
this
.
offset
+
1
]
+
'
,
'
+
this
.
array
[
this
.
offset
+
2
]
+
'
]
'
;
}
};
THREE
.
TypedFace
=
function
(
positions
,
normals
,
uvs
,
offset
)
{
this
.
positions
=
positions
;
this
.
normals
=
normals
;
this
.
uvs
=
uvs
;
this
.
offset
=
offset
*
3
;
};
THREE
.
TypedFace
.
prototype
=
{
constructor
:
THREE
.
TypedFace
,
vertex
:
function
(
index
)
{
return
new
THREE
.
TypedVector3
(
this
.
positions
,
this
.
offset
+
index
);
},
normal
:
function
(
index
)
{
return
new
THREE
.
TypedVector3
(
this
.
normals
,
this
.
offset
+
index
);
},
uv
:
function
(
index
)
{
return
new
THREE
.
TypedVector2
(
this
.
uvs
,
this
.
offset
+
index
);
}
};
THREE
.
TypedGeometry
=
function
(
size
)
{
this
.
id
=
THREE
.
GeometryIdCount
++
;
this
.
uuid
=
THREE
.
Math
.
generateUUID
();
this
.
name
=
''
;
this
.
positions
=
new
Float32Array
(
size
*
3
*
3
);
this
.
normals
=
new
Float32Array
(
size
*
3
*
3
);
this
.
uvs
=
new
Float32Array
(
size
*
3
*
2
);
this
.
boundingBox
=
null
;
this
.
boundingSphere
=
null
;
};
THREE
.
TypedGeometry
.
prototype
=
{
constructor
:
THREE
.
TypedGeometry
,
face
:
function
(
index
)
{
return
new
THREE
.
TypedFace
(
this
.
positions
,
this
.
normals
,
this
.
uvs
,
index
);
},
dispose
:
function
()
{
this
.
dispatchEvent
(
{
type
:
'
dispose
'
}
);
}
};
THREE
.
EventDispatcher
.
prototype
.
apply
(
THREE
.
TypedGeometry
.
prototype
);
examples/js/wip/proxies/MultiColor.js
已删除
100644 → 0
浏览文件 @
48ca3777
// Allows updating of multiple THREE.Color objects with the same value
// Used for face.color -> face.vertexColor[] compatibility layer for non-indexed geometry
THREE
.
MultiColor
=
function
(
links
)
{
this
.
links
=
links
;
};
THREE
.
MultiColor
.
prototype
=
Object
.
create
(
THREE
.
Color
.
prototype
);
THREE
.
MultiColor
.
prototype
.
constructor
=
THREE
.
MultiColor
;
THREE
.
MultiColor
.
prototype
.
setAll
=
function
(
axis
,
value
)
{
for
(
var
i
=
0
,
l
=
this
.
links
.
length
;
i
<
l
;
i
++
)
{
this
.
links
[
i
][
axis
]
=
value
;
}
};
// Getters return value from the first linked color
// Setters set the same value for all linked colors
Object
.
defineProperties
(
THREE
.
MultiColor
.
prototype
,
{
'
r
'
:
{
get
:
function
()
{
return
(
this
.
links
[
0
]
?
this
.
links
[
0
].
r
:
0
);
},
set
:
function
(
v
)
{
this
.
setAll
(
'
r
'
,
v
);
}
},
'
g
'
:
{
get
:
function
()
{
return
(
this
.
links
[
0
]
?
this
.
links
[
0
].
g
:
0
);
},
set
:
function
(
v
)
{
this
.
setAll
(
'
g
'
,
v
);
}
},
'
b
'
:
{
get
:
function
()
{
return
(
this
.
links
[
0
]
?
this
.
links
[
0
].
b
:
0
);
},
set
:
function
(
v
)
{
this
.
setAll
(
'
b
'
,
v
);
}
}
}
);
examples/js/wip/proxies/MultiVector3.js
已删除
100644 → 0
浏览文件 @
48ca3777
// Allows updating of multiple THREE.Vector3 objects with the same value
// Used for face.normal -> face.vertexNormal[] compatibility layer for FlatShading
THREE
.
MultiVector3
=
function
(
links
)
{
this
.
links
=
links
;
};
THREE
.
MultiVector3
.
prototype
=
Object
.
create
(
THREE
.
Vector3
.
prototype
);
THREE
.
MultiVector3
.
prototype
.
constructor
=
THREE
.
MultiVector3
;
THREE
.
MultiVector3
.
prototype
.
setAll
=
function
(
axis
,
value
)
{
for
(
var
i
=
0
,
l
=
this
.
links
.
length
;
i
<
l
;
i
++
)
{
this
.
links
[
i
][
axis
]
=
value
;
}
};
// Getters return value from the first linked vector
// Setters set the same value for all linked vectors
Object
.
defineProperties
(
THREE
.
MultiVector3
.
prototype
,
{
'
x
'
:
{
get
:
function
()
{
return
(
this
.
links
[
0
]
?
this
.
links
[
0
].
x
:
0
);
},
set
:
function
(
v
)
{
this
.
setAll
(
'
x
'
,
v
);
}
},
'
y
'
:
{
get
:
function
()
{
return
(
this
.
links
[
0
]
?
this
.
links
[
0
].
y
:
0
);
},
set
:
function
(
v
)
{
this
.
setAll
(
'
y
'
,
v
);
}
},
'
z
'
:
{
get
:
function
()
{
return
(
this
.
links
[
0
]
?
this
.
links
[
0
].
z
:
0
);
},
set
:
function
(
v
)
{
this
.
setAll
(
'
z
'
,
v
);
}
}
}
);
examples/js/wip/proxies/ProxyColor.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
* @author jbaicoianu / http://baicoianu.com/
*/
THREE
.
ProxyColor
=
function
(
array
,
offset
)
{
this
.
array
=
array
;
this
.
offset
=
offset
;
};
THREE
.
ProxyColor
.
prototype
=
Object
.
create
(
THREE
.
Color
.
prototype
);
THREE
.
ProxyColor
.
prototype
.
constructor
=
THREE
.
ProxyColor
;
Object
.
defineProperties
(
THREE
.
ProxyColor
.
prototype
,
{
'
r
'
:
{
enumerable
:
true
,
get
:
function
()
{
return
this
.
array
[
this
.
offset
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
]
=
v
;
}
},
'
g
'
:
{
enumerable
:
true
,
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
1
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
1
]
=
v
;
}
},
'
b
'
:
{
enumerable
:
true
,
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
2
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
2
]
=
v
;
}
}
}
);
examples/js/wip/proxies/ProxyFace3.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author jbaicoianu / http://baicoianu.com/
*/
THREE
.
ProxyFace3
=
function
(
array
,
offset
,
vertexNormals
,
vertexColors
,
vertexTangents
)
{
this
.
array
=
array
;
this
.
offset
=
offset
;
this
.
vertexNormals
=
vertexNormals
||
[];
this
.
vertexColors
=
vertexColors
||
[];
this
.
vertexTangents
=
vertexTangents
||
[];
this
.
normal
=
new
THREE
.
MultiVector3
(
this
.
vertexNormals
);
this
.
color
=
new
THREE
.
MultiColor
(
this
.
vertexColors
);
//THREE.Face3.call( this, array[offset], array[offset+1], array[offset+2] /*, normal, color, materialIndex */);
};
THREE
.
ProxyFace3
.
prototype
=
Object
.
create
(
THREE
.
Face3
.
prototype
);
THREE
.
ProxyFace3
.
prototype
.
constructor
=
THREE
.
ProxyFace3
;
Object
.
defineProperties
(
THREE
.
ProxyFace3
.
prototype
,
{
'
a
'
:
{
enumerable
:
true
,
get
:
function
()
{
return
this
.
array
[
this
.
offset
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
]
=
v
;
}
},
'
b
'
:
{
enumerable
:
true
,
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
1
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
1
]
=
v
;
}
},
'
c
'
:
{
enumerable
:
true
,
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
2
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
2
]
=
v
;
}
},
}
);
examples/js/wip/proxies/ProxyVector2.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
* @author jbaicoianu / http://baicoianu.com/
*/
THREE
.
ProxyVector2
=
function
(
array
,
offset
)
{
this
.
array
=
array
;
this
.
offset
=
offset
;
};
THREE
.
ProxyVector2
.
prototype
=
Object
.
create
(
THREE
.
Vector2
.
prototype
);
THREE
.
ProxyVector2
.
prototype
.
constructor
=
THREE
.
ProxyVector2
;
Object
.
defineProperties
(
THREE
.
ProxyVector2
.
prototype
,
{
'
x
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
]
=
v
;
}
},
'
y
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
1
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
1
]
=
v
;
}
}
}
);
examples/js/wip/proxies/ProxyVector3.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
* @author jbaicoianu / http://baicoianu.com/
*/
THREE
.
ProxyVector3
=
function
(
array
,
offset
)
{
this
.
array
=
array
;
this
.
offset
=
offset
;
};
THREE
.
ProxyVector3
.
prototype
=
Object
.
create
(
THREE
.
Vector3
.
prototype
);
THREE
.
ProxyVector3
.
prototype
.
constructor
=
THREE
.
ProxyVector3
;
Object
.
defineProperties
(
THREE
.
ProxyVector3
.
prototype
,
{
'
x
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
]
=
v
;
}
},
'
y
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
1
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
1
]
=
v
;
}
},
'
z
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
2
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
2
]
=
v
;
}
}
}
);
examples/js/wip/proxies/ProxyVector4.js
已删除
100644 → 0
浏览文件 @
48ca3777
/**
* @author mrdoob / http://mrdoob.com/
* @author jbaicoianu / http://baicoianu.com/
*/
THREE
.
ProxyVector4
=
function
(
array
,
offset
)
{
this
.
array
=
array
;
this
.
offset
=
offset
;
};
THREE
.
ProxyVector4
.
prototype
=
Object
.
create
(
THREE
.
Vector4
.
prototype
);
THREE
.
ProxyVector4
.
prototype
.
constructor
=
THREE
.
ProxyVector4
;
Object
.
defineProperties
(
THREE
.
ProxyVector4
.
prototype
,
{
'
x
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
]
=
v
;
}
},
'
y
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
1
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
1
]
=
v
;
}
},
'
z
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
2
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
2
]
=
v
;
}
},
'
w
'
:
{
get
:
function
()
{
return
this
.
array
[
this
.
offset
+
3
];
},
set
:
function
(
v
)
{
this
.
array
[
this
.
offset
+
3
]
=
v
;
}
}
}
);
examples/webgl_geometry_minecraft.html
浏览文件 @
85c835de
...
...
@@ -49,10 +49,6 @@
<script
src=
"js/Detector.js"
></script>
<script
src=
"js/libs/stats.min.js"
></script>
<script
src=
"js/wip/TypedGeometry.js"
></script>
<script
src=
"js/wip/IndexedTypedGeometry.js"
></script>
<script
src=
"js/wip/PlaneTypedGeometry.js"
></script>
<script>
if
(
!
Detector
.
webgl
)
{
...
...
@@ -96,38 +92,44 @@
var
matrix
=
new
THREE
.
Matrix4
();
var
pxGeometry
=
new
THREE
.
Plane
Typed
Geometry
(
100
,
100
);
pxGeometry
.
uvs
[
1
]
=
0.5
;
pxGeometry
.
uvs
[
3
]
=
0.5
;
var
pxGeometry
=
new
THREE
.
Plane
Buffer
Geometry
(
100
,
100
);
pxGeometry
.
attributes
.
uv
.
array
[
1
]
=
0.5
;
pxGeometry
.
attributes
.
uv
.
array
[
3
]
=
0.5
;
pxGeometry
.
applyMatrix
(
matrix
.
makeRotationY
(
Math
.
PI
/
2
)
);
pxGeometry
.
applyMatrix
(
matrix
.
makeTranslation
(
50
,
0
,
0
)
);
var
nxGeometry
=
new
THREE
.
Plane
Typed
Geometry
(
100
,
100
);
nxGeometry
.
uvs
[
1
]
=
0.5
;
nxGeometry
.
uvs
[
3
]
=
0.5
;
var
nxGeometry
=
new
THREE
.
Plane
Buffer
Geometry
(
100
,
100
);
nxGeometry
.
attributes
.
uv
.
array
[
1
]
=
0.5
;
nxGeometry
.
attributes
.
uv
.
array
[
3
]
=
0.5
;
nxGeometry
.
applyMatrix
(
matrix
.
makeRotationY
(
-
Math
.
PI
/
2
)
);
nxGeometry
.
applyMatrix
(
matrix
.
makeTranslation
(
-
50
,
0
,
0
)
);
var
pyGeometry
=
new
THREE
.
Plane
Typed
Geometry
(
100
,
100
);
pyGeometry
.
uvs
[
5
]
=
0.5
;
pyGeometry
.
uvs
[
7
]
=
0.5
;
var
pyGeometry
=
new
THREE
.
Plane
Buffer
Geometry
(
100
,
100
);
pyGeometry
.
attributes
.
uv
.
array
[
5
]
=
0.5
;
pyGeometry
.
attributes
.
uv
.
array
[
7
]
=
0.5
;
pyGeometry
.
applyMatrix
(
matrix
.
makeRotationX
(
-
Math
.
PI
/
2
)
);
pyGeometry
.
applyMatrix
(
matrix
.
makeTranslation
(
0
,
50
,
0
)
);
var
pzGeometry
=
new
THREE
.
Plane
Typed
Geometry
(
100
,
100
);
pzGeometry
.
uvs
[
1
]
=
0.5
;
pzGeometry
.
uvs
[
3
]
=
0.5
;
var
pzGeometry
=
new
THREE
.
Plane
Buffer
Geometry
(
100
,
100
);
pzGeometry
.
attributes
.
uv
.
array
[
1
]
=
0.5
;
pzGeometry
.
attributes
.
uv
.
array
[
3
]
=
0.5
;
pzGeometry
.
applyMatrix
(
matrix
.
makeTranslation
(
0
,
0
,
50
)
);
var
nzGeometry
=
new
THREE
.
Plane
Typed
Geometry
(
100
,
100
);
nzGeometry
.
uvs
[
1
]
=
0.5
;
nzGeometry
.
uvs
[
3
]
=
0.5
;
var
nzGeometry
=
new
THREE
.
Plane
Buffer
Geometry
(
100
,
100
);
nzGeometry
.
attributes
.
uv
.
array
[
1
]
=
0.5
;
nzGeometry
.
attributes
.
uv
.
array
[
3
]
=
0.5
;
nzGeometry
.
applyMatrix
(
matrix
.
makeRotationY
(
Math
.
PI
)
);
nzGeometry
.
applyMatrix
(
matrix
.
makeTranslation
(
0
,
0
,
-
50
)
);
//
var
geometry
=
new
THREE
.
TypedGeometry
(
worldWidth
*
worldDepth
*
2
*
5
);
// 2 triangles, 5 possible sides
// BufferGeometry cannot be merged yet.
var
tmpGeometry
=
new
THREE
.
Geometry
();
var
pxTmpGeometry
=
new
THREE
.
Geometry
().
fromBufferGeometry
(
pxGeometry
);
var
nxTmpGeometry
=
new
THREE
.
Geometry
().
fromBufferGeometry
(
nxGeometry
);
var
pyTmpGeometry
=
new
THREE
.
Geometry
().
fromBufferGeometry
(
pyGeometry
);
var
pzTmpGeometry
=
new
THREE
.
Geometry
().
fromBufferGeometry
(
pzGeometry
);
var
nzTmpGeometry
=
new
THREE
.
Geometry
().
fromBufferGeometry
(
nzGeometry
);
for
(
var
z
=
0
;
z
<
worldDepth
;
z
++
)
{
...
...
@@ -146,29 +148,29 @@
var
pz
=
getY
(
x
,
z
+
1
);
var
nz
=
getY
(
x
,
z
-
1
);
geometry
.
merge
(
py
Geometry
,
matrix
);
tmpGeometry
.
merge
(
pyTmp
Geometry
,
matrix
);
if
(
(
px
!=
h
&&
px
!=
h
+
1
)
||
x
==
0
)
{
if
(
(
px
!=
=
h
&&
px
!==
h
+
1
)
||
x
=
==
0
)
{
geometry
.
merge
(
px
Geometry
,
matrix
);
tmpGeometry
.
merge
(
pxTmp
Geometry
,
matrix
);
}
if
(
(
nx
!=
h
&&
nx
!=
h
+
1
)
||
x
==
worldWidth
-
1
)
{
if
(
(
nx
!=
=
h
&&
nx
!==
h
+
1
)
||
x
=
==
worldWidth
-
1
)
{
geometry
.
merge
(
nx
Geometry
,
matrix
);
tmpGeometry
.
merge
(
nxTmp
Geometry
,
matrix
);
}
if
(
(
pz
!=
h
&&
pz
!=
h
+
1
)
||
z
==
worldDepth
-
1
)
{
if
(
(
pz
!=
=
h
&&
pz
!==
h
+
1
)
||
z
=
==
worldDepth
-
1
)
{
geometry
.
merge
(
pz
Geometry
,
matrix
);
tmpGeometry
.
merge
(
pzTmp
Geometry
,
matrix
);
}
if
(
(
nz
!=
h
&&
nz
!=
h
+
1
)
||
z
==
0
)
{
if
(
(
nz
!=
=
h
&&
nz
!==
h
+
1
)
||
z
=
==
0
)
{
geometry
.
merge
(
nz
Geometry
,
matrix
);
tmpGeometry
.
merge
(
nzTmp
Geometry
,
matrix
);
}
...
...
@@ -176,6 +178,7 @@
}
var
geometry
=
new
THREE
.
BufferGeometry
().
fromGeometry
(
tmpGeometry
);
geometry
.
computeBoundingSphere
();
var
texture
=
THREE
.
ImageUtils
.
loadTexture
(
'
textures/minecraft/atlas.png
'
);
...
...
@@ -230,7 +233,7 @@
for
(
var
j
=
0
;
j
<
4
;
j
++
)
{
if
(
j
==
0
)
for
(
var
i
=
0
;
i
<
size
;
i
++
)
data
[
i
]
=
0
;
if
(
j
==
=
0
)
for
(
var
i
=
0
;
i
<
size
;
i
++
)
data
[
i
]
=
0
;
for
(
var
i
=
0
;
i
<
size
;
i
++
)
{
...
...
@@ -240,7 +243,7 @@
}
quality
*=
4
quality
*=
4
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录