Node

地图中所有元素结点物体的基类

Node

Members

readonly children :Array.<Node>

此结点所有的子结点

data :object

此结点的原数据

entity :Object3D

些结点对应的3D实体

name :String

结点的名称

readonly parent :Node

此结点的父结点

position :vector3|Coord

结点的场景空间坐标

show

手动设置结点的可见性

type :String

结点的类型

Methods

add(children, keepTransform)

添加子物体
Parameters:
Name Type Description
children Node | Array.<Node> 子物体,可以为单个多个或数组
keepTransform Boolean 是否保持子物体之前的位置,旋转与缩放

clone() → {Node}

复制此结点
Returns:
Node - 复制后的结点

dispose()

销毁结点, 会同时消除data与entity

find(query, configopt) → {Node|Array.<Node>}

node子结点的查寻方法
Parameters:
Name Type Attributes Description
query objectn | function 用于查找的字段, function(item), return true or false
config object <optional>
查寻的配置
Properties
Name Type Attributes Default Description
recursive bool <optional>
true 是否递归查找
Returns:
Node | Array.<Node> - 查找到的node可以为单个或node数组
Example
omScene.find({buildingID: 'xxx'}, {recursive: false});

findData(query, config) → {Array.<object>}

从此结点向下查找结点的原数据, 推荐使用些方法, 因为场景中的结点是按需创建的 所以通过find方法直接检索结点实体的时候,可能结点的实体尚未创建
Parameters:
Name Type Description
query object | function 用于查找的字段, 或者使用检索方法, 需要返回boolean值
config object
Properties
Name Type Attributes Default Description
recursive boolean <optional>
true 是否在当前结点未检索到时,继续向下检索
multi boolean <optional>
false 是否为多选
Returns:
Array.<object> - 检索到的数据数组

getProp(prop) → {*}

得到结点data中的数据,与直接从data中得到数据是一样的,如:node.data.prop
Parameters:
Name Type Description
prop string 字段名
Returns:
* - data中对应字段的值

remove(children, clearopt)

移除子物体
Parameters:
Name Type Attributes Default Description
children Node | Array.<Node> 子物体, 可以为单个多个或数组
clear boolean <optional>
true 是否从内存中清除子物体的entity

removeEntity(entity)

销毁一个entity及其所有的子实体
Parameters:
Name Type Description
entity Object3D Node中的 entity 结点

setData(data)

设置此结点的元数据
Parameters:
Name Type Description
data object 结点的元数据

setEntity(entity)

设置此结点的3D实体
Parameters:
Name Type Description
entity Object3D 3D实体

setProp(prop, value) → {null}

设置结点data中的数据,与直接从data中得到数据是一样的,如:node.data.prop = value
Parameters:
Name Type Description
prop string 字段名
value * prop字段对应的值
Returns:
null