Class: Mesh

Mesh

new Mesh(params)

Mesh

Name Type Description
params Object optional

初始化参数,所有params都会复制到实例上

Name Type Description
geometry Geometry optional

几何体

material Material optional

材质

[value:string] any optional

其它属性

Example
const mesh = new Hilo3d.Mesh({
    geometry: new Hilo3d.BoxGeometry(),
    material: new Hilo3d.BasicMaterial({
        diffuse: new Hilo3d.Color(0.8, 0, 0)
    }),
    x:100,
    rotationX:30
});
stage.addChild(mesh);

Extends

Members Show Inherited

Name Type Default Description
isMesh boolean true
className string Mesh
geometry Geometry
material Material
useInstanced boolean false

是否使用 Instanced

frustumTest Boolean true

是否开启视锥体裁剪

isDestroyed Boolean

是否被销毁

isNode boolean true inherited
name string inherited

Node 的名字,可以通过 getChildByName 查找

anim Animation null inherited

动画

animationId String '' inherited

animation 查找 id

jointName String '' inherited

骨骼名称

autoUpdateWorldMatrix boolean true inherited

是否自动更新世界矩阵

autoUpdateChildWorldMatrix boolean true inherited

是否自动更新子元素世界矩阵

parent Node null inherited

父节点

needCallChildUpdate boolean true inherited

每次更新的时候是否调用子节点的 onUpdate 方法

visible boolean true inherited

节点是否显示

pointerEnabled Boolean true inherited

可视对象是否接受交互事件。默认为接受交互事件,即true。

pointerChildren Boolean true inherited

子元素是否接受交互事件。

useHandCursor Boolean false inherited

是否用鼠标指针

userData any null inherited

用户数据

onUpdate function null inherited

update 回调

onlySyncQuaternion Boolean false inherited

只同步四元数,不同步欧拉角

id string inherited
up Vector3 inherited

元素的up向量

children Array.<Node> inherited

元素直接点数组

worldMatrix Matrix4 inherited

元素的世界矩阵

matrix Matrix4Notifier inherited

元素的矩阵

position Vector3Notifier inherited

位置

x number inherited

x轴坐标

y number inherited

y轴坐标

z number inherited

z轴坐标

scale Vector3Notifier inherited

缩放

scaleX number inherited

缩放比例x

scaleY number inherited

缩放比例y

scaleZ number inherited

缩放比例z

pivot Vector3Notifier inherited

中心点

pivotX Number inherited

中心点x

pivotY Number inherited

中心点y

pivotZ Number inherited

中心点z

rotation EulerNotifier inherited

欧拉角

rotationX number inherited

旋转角度 x, 角度制

rotationY number inherited

旋转角度 y, 角度制

rotationZ number inherited

旋转角度 z, 角度制

quaternion Quaternion inherited

四元数角度

matrixVersion Number 0 inherited

矩阵 version,每次改变会加一

worldMatrixVersion Number 0 inherited

世界矩阵 version,每次改变会加一

Methods Show Inherited

clone(isChild){Mesh}

clone 当前mesh

Name Type Description
isChild boolean

是否子元素

Returns:
Type Description
Mesh 返回clone的实例

raycast(ray, sort){Array.<Vector3>|null}

raycast

Name Type Default Description
ray Ray
sort Boolean true optional

是否按距离排序

Returns:
Type Description
Array.<Vector3> | null

getRenderOption(option){Object}

获取渲染选项值

Name Type Default Description
option Object {} optional

渲染选项值

Returns:
Type Description
Object 渲染选项值

destroy(renderer, destroyTextures){Mesh}

销毁 Mesh 资源

Name Type Default Description
renderer WebGLRenderer
destroyTextures Boolean false optional

是否销毁材质的贴图,默认不销毁

Returns:
Type Description
Mesh this

设置节点的动画,这个需要是模型的根节点

Name Type Description
anim Animation

动画实例

Returns:
Type Description
Node this

inherited resetSkinedMeshRootNode()

重置子孙元素中 SkinedMesh 的根节点为当前元素

inherited getChildrenNameMap(){Object}

将所以子孙元素放到一个对象中,对象key为元素的name,value为该元素

Returns:
Type Description
Object 返回获取的对象

inherited addChild(child){Node}

添加一个子元素

Name Type Description
child Node

需要添加的子元素

Returns:
Type Description
Node this

inherited removeChild(child){Node}

移除指定的子元素

Name Type Description
child Node

需要移除的元素

Returns:
Type Description
Node this

将当前元素添加到某个父元素的子元素中

Name Type Description
parent Node

需要添加到的父元素

Returns:
Type Description
Node this

inherited removeFromParent(){Node}

将当前元素从其父元素中移除

Returns:
Type Description
Node this

inherited updateMatrix(){Node}

更新本地矩阵

Returns:
Type Description
Node this

inherited updateQuaternion(){Node}

更新四元数

Returns:
Type Description
Node this

inherited updateTransform(){Node}

更新transform属性

Returns:
Type Description
Node this

inherited updateMatrixWorld(force){Node}

更新世界矩阵

Name Type Default Description
force Boolean true optional

是否强制更新

Returns:
Type Description
Node this

inherited getConcatenatedMatrix(ancestor){Matrix4}

获取当前元素相对于指定元素的矩阵

Name Type Description
ancestor Node optional

相对于的元素,需要是当前元素的祖先元素,不传表示获取世界矩阵

Returns:
Type Description
Matrix4 返回获取的矩阵

inherited traverse(callback, onlyChild){Node}

遍历当前元素的子孙元素

Name Type Default Description
callback NodeTraverseCallback

每个元素都会调用这个函数处理

onlyChild Boolean false optional

是否只遍历子元素

Returns:
Type Description
Node this

inherited traverseBFS(callback, onlyChild){Node}

遍历当前元素的子孙元素(广度优先)

Name Type Default Description
callback NodeTraverseCallback

每个元素都会调用这个函数处理

onlyChild Boolean false optional

是否只遍历子元素

Returns:
Type Description
Node this

inherited getChildByFnBFS(fn){Node|null}

根据函数来获取一个子孙元素(广度优先)

Name Type Description
fn NodeGetChildByCallback

判读函数

Returns:
Type Description
Node | null 返回获取到的子孙元素

inherited getChildByNamePath(path){Node|null}

根据 name path 来获取子孙元素

Name Type Description
path Array.<String>

名字数组, e.g., getChildByNamePath(['a', 'b', 'c'])

Returns:
Type Description
Node | null 返回获取到的子孙元素

inherited traverseUpdate(dt){Node}

遍历调用子孙元素onUpdate方法

Name Type Description
dt Number
Returns:
Type Description
Node this

inherited getChildByFn(fn){Node|null}

根据函数来获取一个子孙元素

Name Type Description
fn NodeGetChildByCallback

判读函数

Returns:
Type Description
Node | null 返回获取到的子孙元素

inherited getChildrenByFn(fn){Array.<Node>}

根据函数来获取匹配的所有子孙元素

Name Type Description
fn NodeGetChildByCallback

判读函数

Returns:
Type Description
Array.<Node> 返回获取到的子孙元素

inherited getChildByName(name){Node|null}

获取指定name的首个子孙元素

Name Type Description
name string

元素name

Returns:
Type Description
Node | null 获取的元素

inherited getChildrenByName(name){Array.<Node>}

获取指定name的所有子孙元素

Name Type Description
name string

元素name

Returns:
Type Description
Array.<Node> 获取的元素数组

inherited getChildById(id){Node|null}

获取指定id的子孙元素

Name Type Description
id string

元素id

Returns:
Type Description
Node | null 获取的元素

inherited getChildrenByClassName(className){Array.<Node>}

获取指定类名的所有子孙元素

Name Type Description
className string

类名

Returns:
Type Description
Array.<Node> 获取的元素数组

inherited getChildrenByBaseClassName(className){Array.<Node>}

获取指定基类名的所有子孙元素

Name Type Description
className string

类名

Returns:
Type Description
Array.<Node> 获取的元素数组

inherited setScale(x, y, z){Node}

设置元素的缩放比例,如果只有一个参数三个轴等比缩放

Name Type Description
x number

X缩放比例

y number optional

Y缩放比例

z number optional

Z缩放比例

Returns:
Type Description
Node this

inherited setPosition(x, y, z){Node}

设置元素的位置

Name Type Description
x number

X方向位置

y number

Y方向位置

z number

Z方向位置

Returns:
Type Description
Node this

inherited setRotation(x, y, z){Node}

设置元素的旋转

Name Type Description
x number

X轴旋转角度, 角度制

y number

Y轴旋转角度, 角度制

z number

Z轴旋转角度, 角度制

Returns:
Type Description
Node this

inherited setPivot(x, y, z){Node}

设置中心点

Name Type Description
x Number

中心点x

y Number

中心点y

z Number

中心点z

Returns:
Type Description
Node this

改变元素的朝向

Name Type Description
node Node | Object | Vector3

需要朝向的元素,或者坐标

Returns:
Type Description
Node this

inherited getBounds(parent, currentMatrix, bounds){Bounds}

获取元素的包围盒信息

Name Type Description
parent Node optional

元素相对于哪个祖先元素的包围盒,不传表示世界

currentMatrix Matrix4 optional

当前计算的矩阵

bounds Bounds optional

当前计算的包围盒信息

Returns:
Type Description
Bounds 返回计算的包围盒信息