Class: Box
立方体,通常用来创建立方体或者不规则四边形。
代码示例:
const boxGeometry - new Box(renderer);
const box = new Mesh(renderer, { geometry: boxGeometry, program });
scene.add(box);
Hierarchy
-
↳
Box
Constructors
constructor
• new Box(renderer
, «destructured»?
): Box
Parameters
Name | Type | Description |
---|---|---|
renderer | Renderer | 渲染器 |
«destructured» | Partial <BoxOptions > | - |
Returns
Overrides
Defined in
Properties
renderer
• renderer: Renderer
Inherited from
Defined in
drawRange
• drawRange: any
Inherited from
Defined in
instancedCount
• instancedCount: number
Inherited from
Defined in
isInstanced
• isInstanced: boolean
Inherited from
Defined in
drawMode
• drawMode: number
Inherited from
Defined in
Accessors
gl
• get
gl(): WebGLRenderingContext
| WebGL2RenderingContext
获取 webgl
实例
Returns
WebGLRenderingContext
| WebGL2RenderingContext
Inherited from
Geometry.gl
Defined in
rendererState
• get
rendererState(): State
获取渲染状态
Returns
Inherited from
Geometry.rendererState
Defined in
id
• get
id(): string
获取当前几何体数据的唯一标识
Returns
string
Inherited from
Geometry.id
Defined in
attributes
• get
attributes(): Map
<string
, BufferAttribute
>
获取全部的属性信息
Returns
Map
<string
, BufferAttribute
>
Inherited from
Geometry.attributes
Defined in
attributesData
• get
attributesData(): Attributes
获取属性数据
Returns
Inherited from
Geometry.attributesData
Defined in
index
• get
index(): undefined
| BufferAttribute
获取顶点索引属性
Returns
undefined
| BufferAttribute
Inherited from
Geometry.index
Defined in
bounds
• get
bounds(): any
获取当前几何体的包围盒
Returns
any
Inherited from
Geometry.bounds
Defined in
• set
bounds(bounds
): void
手动设置包围盒,一般我们只需要内部计算
Parameters
Name | Type |
---|---|
bounds | any |
Returns
void
Inherited from
Geometry.bounds
Defined in
Methods
addAttribute
▸ addAttribute(name
, attribute
): void
添加对应的属性信息(顶点数据)
Parameters
Name | Type |
---|---|
name | string |
attribute | BufferAttribute |
Returns
void
Inherited from
Defined in
getAttribute
▸ getAttribute(name
): undefined
| BufferAttribute
获取对应的属性信息(顶点数据)
Parameters
Name | Type |
---|---|
name | any |
Returns
undefined
| BufferAttribute
Inherited from
Defined in
setAttributeData
▸ setAttributeData(name
, data
): void
设置对应的属性数据
Parameters
Name | Type |
---|---|
name | any |
data | any |
Returns
void
Inherited from
Defined in
updateAttribute
▸ updateAttribute(attribute
): void
更新顶点属性数据
Parameters
Name | Type |
---|---|
attribute | any |
Returns
void
Inherited from
Defined in
removeAttribute
▸ removeAttribute(attribute
): void
移除属性信息
Parameters
Name | Type |
---|---|
attribute | any |
Returns
void
Inherited from
Defined in
setIndex
▸ setIndex(index
): void
设置顶点索引数据
Parameters
Name | Type |
---|---|
index | any |
Returns
void
Inherited from
Defined in
setVertices
▸ setVertices(data
): void
设置顶点数据
Parameters
Name | Type |
---|---|
data | any |
Returns
void
Inherited from
Defined in
setNormals
▸ setNormals(data
): void
设置顶点法向量数据
Parameters
Name | Type |
---|---|
data | any |
Returns
void
Inherited from
Defined in
setUVs
▸ setUVs(data
): void
设置纹理 UV 数据
Parameters
Name | Type |
---|---|
data | any |
Returns
void
Inherited from
Defined in
setColors
▸ setColors(colors
): void
设置顶点颜色数据
Parameters
Name | Type |
---|---|
colors | (Float32Array | Float64Array | number [] | Vector3 | Vector4 )[] |
Returns
void
Inherited from
Defined in
setDrawRange
▸ setDrawRange(start
, count
): void
设置顶点渲染的开始索引和数量
Parameters
Name | Type | Description |
---|---|---|
start | number | 开始索引 |
count | number | 数量 |
Returns
void
Inherited from
Defined in
setInstancedCount
▸ setInstancedCount(count
): void
设置实例化渲染的数量
Parameters
Name | Type | Description |
---|---|---|
count | number | 数量 |
Returns
void
Inherited from
Defined in
createVAO
▸ createVAO(program
): void
创建 Vao
Parameters
Name | Type |
---|---|
program | Program |
Returns
void
Inherited from
Defined in
bindAttributes
▸ bindAttributes(program
): void
绑定顶点属性数据 https://devdocs.io/dom/webgl2renderingcontext/vertexattribipointer
Parameters
Name | Type |
---|---|
program | Program |
Returns
void
Inherited from
Defined in
computeBoundingBox
▸ computeBoundingBox(vertices?
): any
计算当前几何体的的矩形边界(立方体包围盒)
Parameters
Name | Type | Description |
---|---|---|
vertices? | number [] | DataType | 外部传入的顶点数据 |
Returns
any
Inherited from
Defined in
computeBoundingSphere
▸ computeBoundingSphere(vertices?
): void
计算当前几何体的的球形边界(球形包围盒)
Parameters
Name | Type | Description |
---|---|---|
vertices? | number [] | DataType | 外部传入的顶点数据 |
Returns
void
Inherited from
Geometry.computeBoundingSphere
Defined in
draw
▸ draw(program
, drawMode?
): void
执行绘制
Parameters
Name | Type | Description |
---|---|---|
program | any | Program 对象 |
drawMode | number | 绘制模式 |
Returns
void
Inherited from
Defined in
copy
▸ copy(source
): Box
将传入的几何体对象的属性值拷贝到此对象
Parameters
Name | Type | Description |
---|---|---|
source | Geometry | 源几何体对象 |
Returns
Inherited from
Defined in
clone
▸ clone(): Geometry
克隆此几何体对象
Returns
Inherited from
Defined in
destroy
▸ destroy(): void
销毁几何体对象
Returns
void