ht.CSGShape()

new CSGShape()

Requires:
  • module:ht-modeling.js

Extends

Requires

  • module:ht-modeling.js

Methods

a(name, value) → {ht.Data}

设置attr属性, 有两个参数时相当于setAttr

Parameters:
Name Type Description
name string

属性名

value any

属性值

Returns:
ht.Data
Inherited From:

addChild(child, index) → {void}

添加孩子节点

Parameters:
Name Type Attributes Description
child ht.Data

子元素

index number <optional>

插入索引,为空则插入作为最后的孩子

Returns:
void
Inherited From:

addPoint(point, index) → {void}

增加点

Parameters:
Name Type Attributes Description
point Object

坐标点

index number <optional>

索引,如果不指定索引则加到最后

Returns:
void
Inherited From:

addStyleIcon(name, icon) → {void}

增加 style 中 icons 属性

Parameters:
Name Type Description
name string

名称

icon any

icon 定义

Returns:
void
Inherited From:

appendAnchorMatrix3d(matrix) → {void}

追加锚点矩阵

Parameters:
Name Type Description
matrix Array.<number>
Returns:
void
Inherited From:

backwardAnimation(shiftTime) → {boolean}

设置动画向后偏移一段时间

Parameters:
Name Type Description
shiftTime number

单位秒

Returns:
boolean
Since:
  • 7.7.0
Inherited From:

beginTransaction() → {void}

开启所在数据模型事务

Returns:
void
Inherited From:

ca(name) → {any}

自动附加当前前缀,获得对应属性

Parameters:
Name Type Description
name string
Returns:
any
Inherited From:

changeCurrentAnimationSpeed(newSpeed) → {boolean}

重置当前播放的动画的速度

Parameters:
Name Type Description
newSpeed number

浮点类型,播放动画的速度,可以是0,表示静止的动画,也可以可以是负数,表示反向播放

Returns:
boolean
Since:
  • 7.7.0
Inherited From:

clearChildren() → {void}

删除所有孩子节点,

Returns:
void
Inherited From:

clearChildrenFromDataModel() → {void}

删除所有孩子节点,并从数据模型移出

Returns:
void
Inherited From:

dm() → {ht.DataModel}

获取当前节点所在数据模型

Returns:
ht.DataModel
Inherited From:

eachChild(func, scope) → {void}

遍历所有子节点

Parameters:
Name Type Attributes Description
func Object

遍历函数 (data, index) => {}

scope any <optional>

作用域

Returns:
void
Inherited From:

endTransaction() → {void}

结束所在数据模型事务

Returns:
void
Inherited From:

firePropertyChange(property, oldValue, newValue) → {void}

派发属性变化事件,可使用fp的简写方式

Parameters:
Name Type Description
property string

属性

oldValue any

旧值

newValue any

新值

Returns:
void
Inherited From:

fireShapeChange() → {void}

更新多边形,如当 points 数组属性变化时,可以通过此方法显示更新,可用简写 fs

Returns:
void
Inherited From:

forwardAnimation(shiftTime) → {boolean}

设置动画向前偏移一段时间

Parameters:
Name Type Description
shiftTime number

单位秒

Returns:
boolean
Since:
  • 7.7.0
Inherited From:

fp(property, oldValue, newValue) → {void}

派发属性变化事件,firePropertyChange 方法的简写

Parameters:
Name Type Description
property string

属性

oldValue any

旧值

newValue any

新值

Returns:
void
Inherited From:

fs() → {void}

更新多边形,如当 points 数组属性变化时,可以通过此方法显示更新,fireShapeChange 的简写

Returns:
void
Inherited From:

get3dUIClass() → {function}

获取组件上的UI类

Returns:
function -

UI类声明(构造函数)

Inherited From:

getAgentEdges() → {ht.List}

获取当前图元代理的连线集合

Returns:
ht.List
Inherited From:

getAnchor() → {Point}

获取节点锚点属性

Returns:
Point -

节点锚点

Inherited From:
Example
//返回值示例:
{
	   x: 0,
	   y: 0
}

getAnchor3d() → {Object}

获取节点3d锚点属性

Returns:
Object
Inherited From:

getAnchorElevation() → {number}

获取三维中高度锚点

Returns:
number -

高度锚点

Inherited From:

getAnchorRect() → {Rect}

以图元左上角为原点,获取图元的矩形区域(不包括旋转)

Returns:
Rect -

矩形区域

Inherited From:
Example
//返回值示例:
{x: -15, y: -15, width: 30, height: 30}

getAnchorX() → {number}

获取横向锚点

Returns:
number -

横向锚点

Inherited From:

getAnchorY() → {number}

获取纵向锚点

Returns:
number -

纵向锚点

Inherited From:

getAnimation() → {object}

获取动画配置

Requires:
  • module:ht-animation.js
Returns:
object
Inherited From:

getAnimationNames() → {Array.<string>}

获取这个节点有效的动画名列表

Returns:
Array.<string>
Since:
  • 7.7.0
Inherited From:

getAnimations() → {Array.<Object>}

获取所有的动画的详细信息

Returns:
Array.<Object>
Since:
  • 7.7.0
Inherited From:

getAttaches() → {ht.List}

获取吸附到自身的所有图元

Returns:
ht.List
Inherited From:

getAttachPosition(anchorX, anchorY, offsetX, offsetY) → {Point}

获取吸附点位置

Parameters:
Name Type Description
anchorX number
anchorY number
offsetX number
offsetY number
Returns:
Point -

返回吸附点的坐标

Inherited From:

getAttr(name) → {any}

获取attr属性

Parameters:
Name Type Description
name string

属性名

Returns:
any
Inherited From:

getAttrObject() → {any}

返回所有属性集合对象,当没设置过任何属性可能会返回 undefined

Returns:
any
Inherited From:

getChildAt(index) → {ht.Data}

返回指定索引位置的孩子

Parameters:
Name Type Description
index number

索引

Returns:
ht.Data -

索引对应的孩子

Inherited From:

getChildren() → {ht.List}

获取所有孩子节点

Returns:
ht.List -

孩子元素集合

Inherited From:

getClass() → {any}

获取类声明(构造函数)

Returns:
any -

类声明(构造函数)

Inherited From:

getClassName() → {string}

获取类全名,继承Data并希望序列化时应该重写此方法返回子类的类名字符串

Returns:
string -

类全名

Inherited From:

getCorners(xPadding, yPadding) → {Array.<Point>}

获取图元四个角的实时坐标(包括旋转后的坐标)

Parameters:
Name Type Description
xPadding number

水平方向padding

yPadding number

垂直方向padding

Returns:
Array.<Point> -

四个角坐标,顺序为左上,右上,右下,左下

Inherited From:
Example
//返回值示例:
[
    {x: 0, y: 0},//左上
    {x: 100, y: 0},//右上
    {x: 100, y: 100},//右下
    {x: 0, y: 100}//左下
]

getCurrentAnimationState(key) → {Object}

获取当前正在播放的动画的播放数据

Parameters:
Name Type Attributes Description
key string <optional>
Returns:
Object
Since:
  • 7.7.0
Inherited From:

getCurrentPrefix() → {string}

返回当前运行态前缀内容

Returns:
string
Inherited From:

getDataBindings() → {Object}

获取数据绑定对象

Returns:
Object -

数据绑定对象

Inherited From:

getDataModel() → {ht.DataModel}

获取所属的DataModel

Returns:
ht.DataModel -

DataModel数据模型

Inherited From:

getDefaultAnimationName() → {string}

获取默认动画名字

Returns:
string
Since:
  • 7.7.0
Inherited From:

getDisplayName() → {string}

获取显示名称,常作为Column和Property的列头和属性名称显示

Returns:
string -

显示名称

Inherited From:

getEdges() → {ht.List}

获取所有跟图元关联的连线(不包括代理的连线)

Returns:
ht.List
Inherited From:

getElevation() → {number}

获取图元中心在3D坐标系中的y坐标

Returns:
number
Inherited From:

getEuler() → {ht.Math.Euler}

获取欧拉旋转角

Returns:
ht.Math.Euler
Inherited From:

getFinalRotation3d() → {Array.<number>}

获取包括动态旋转(billboard 的 autorotate 属性作用下)在内的最终旋转

Returns:
Array.<number>
Inherited From:

getFinalScale3d() → {Array.<number>}

获取包括动态缩放(billboard 的 fixSizeOnScreen 作用下)、scale、size在内的最终缩放

Returns:
Array.<number>
Inherited From:

getHeight() → {number}

获取图元在2D拓扑中的高度,或3D拓扑中的z轴长度

Returns:
number
Inherited From:

getHost() → {ht.Data}

获取宿主图元,当图元吸附上宿主图元时,宿主移动或旋转时会带动所有吸附者

Returns:
ht.Data
Inherited From:

getIcon() → {any}

获取小图标名称,常作为TreeView和ListView等组件上的节点小图标

Returns:
any -

图标名或矢量

Inherited From:

getId() → {string|number}

获取唯一编号

Returns:
string | number -

唯一编号

Inherited From:

getImage() → {string}

Returns:
string
Inherited From:

getLayer() → {string|number}

获取数据元素在GraphView组件中的图层位置

Returns:
string | number -

图层名

Inherited From:
Default Value:
  • 0

getLength(resolution) → {number}

计算Shape的长度

Parameters:
Name Type Attributes Description
resolution number <optional>

曲线分段微分数,默认为12,数字越大计算结果越精确,同时也越耗费性能

Returns:
number
Inherited From:

getLocalEuler(k) → {ht.Math.Euler}

获取节点的局部旋转
参数为空会创建一个新的欧拉角并返回;若传入一个欧拉角,会把结果输出到这个对象并返回

Parameters:
Name Type Attributes Description
k ht.Math.Euler <optional>

欧拉角

Returns:
ht.Math.Euler
Inherited From:

getLocalQuaternion(quaternion) → {ht.Math.Quaternion}

获取全局坐标的四元素数据

Parameters:
Name Type Description
quaternion ht.Math.Quaternion
Returns:
ht.Math.Quaternion -

四元素

Inherited From:

getLoopedEdges() → {ht.List}

获取所有跟节点关联的自环连线

Returns:
ht.List
Inherited From:

getMaterial(name) → {void}

获取材质,请参考材质手册

Parameters:
Name Type Description
name string

材质名

Returns:
void -

材质信息

Since:
  • 7.7.0
Inherited From:

getMatrix() → {ht.Math.Matrix2d}

获取节点转换矩阵

Returns:
ht.Math.Matrix2d
Inherited From:

getMatrix4(mat4) → {ht.Math.Matrix4}

获取节点转换四乘四的单位矩阵

Parameters:
Name Type Description
mat4 ht.Math.Matrix4
Returns:
ht.Math.Matrix4
Inherited From:

getName() → {string}

获取数据元素名

Returns:
string -

名称

Inherited From:

getOwnStyle(name) → {any}

获取节点的样式属性值。当前节点上没有这个属性值是会返回 undefined, 而 getStyle 方法会返回默认值

Parameters:
Name Type Description
name string

样式

Returns:
any
Since:
  • 7.7.0
Inherited From:

getParent() → {ht.Data}

获取父元素

Returns:
ht.Data -

父元素

Inherited From:

getPoints() → {ht.List}

获取点集合

Returns:
ht.List
Inherited From:

getPointsMatrix2d() → {ht.Math.Matrix2d}

2D 点集合转换矩阵

Returns:
ht.Math.Matrix2d
Inherited From:

getPointsMatrix3d() → {ht.Math.Matrix4}

3D 点集合转换矩阵

Returns:
ht.Math.Matrix4
Inherited From:

getPosition() → {Point}

获取图元中心点坐标

Returns:
Point
Inherited From:
Example
//返回值示例:
{
	   x: 0,
	   y: 0
}

getPosition3d() → {Array.<number>}

获取图元中心点在3D拓扑中的三维坐标

Returns:
Array.<number> -

三维坐标数组,格式为[x, y, z]

Inherited From:

getQuaternion() → {ht.Math.Quaternion}

获取四元素

Inherited From:

getRect() → {Rect}

获取图元的矩形区域(包括旋转)

Returns:
Rect -

矩形区域

Inherited From:
Example
//返回值示例:
{x: 0, y: 0, width: 100, height: 100}

getRenderLayer() → {string|number}

获取三维渲染层级, 配合 ht.Default 中的 getRenderLayerInfo 和 setRenderLayerInfo 使用

Returns:
string | number
Inherited From:

getRenderLayerMask() → {string|number}

获取三维渲染层级掩码

Returns:
string | number
Since:
  • 7.7.0
Inherited From:

getRotation() → {number}

获取图元的旋转角度,围绕中心点顺时针旋转

Returns:
number -

旋转角度(弧度制)

Inherited From:

getRotation3d() → {Array.<number>}

获取图元在3D拓扑中的三维旋转角度

Returns:
Array.<number> -

三维旋转角度(弧度制),格式为[x, y, z],即[getRotationX(), -getRotation(), getRotationZ()]

Inherited From:

getRotationMode() → {string}

返回三维旋转模式

图元在3D拓扑中旋转时,先沿x轴旋转,再沿y轴旋转和先沿y轴旋转,再沿x轴旋转最后的结果是不一样的

Returns:
string -

三维旋转模式,xyz|xzy|yxz|yzx|zxy|zyx

Inherited From:

getRotationX() → {number}

获取图元在3d拓扑中沿x轴的旋转角度(弧度制)

Returns:
number
Inherited From:

getRotationY() → {number}

获取图元在3d拓扑中沿y轴的旋转角度(弧度制)

Returns:
number
Inherited From:

getRotationZ() → {number}

获取图元在3d拓扑中沿z轴的旋转角度(弧度制)

Returns:
number
Inherited From:

getScale() → {Point}

获取节点缩放属性

Returns:
Point -

节点缩放属性

Inherited From:

getScale3d() → {Array.<number>}

获取节点3d缩放属性

Returns:
Array.<number> -

3d 缩放属性

Inherited From:

getScaledSize() → {any}

获取缩放后的大小,格式如 { width, height }

Returns:
any
Inherited From:

getScaleTall() → {number}

获取三维中高度缩放

Returns:
number -

高度缩放值

Inherited From:

getScaleX() → {number}

获取横向缩放

Returns:
number -

横向缩放值

Inherited From:

getScaleY() → {number}

获取纵向缩放

Returns:
number -

纵向缩放值

Inherited From:

getSegments() → {ht.List}

获取线段类型集合

Returns:
ht.List
Inherited From:

getSerializableAttrs() → {any}

此函数返回一个map,决定序列化时哪些attr属性可被序列化,默认所有attr对象里的属性都会被序列化

Returns:
any -

需要被序列化的attr属性map

Inherited From:
Example
function(){
    var name, map = ;
    for (name in this._attrObject) {
        map[name] = 1;
    }
    returns map;
}

getSerializableProperties() → {any}

此函数返回一个map,决定序列化时哪些属性可被序列化,如果有自定义的get/set属性并且需要序列化,应该重写此方法

Returns:
any -

需要被序列化的属性map

Inherited From:
Example
function(){
    returns {
        name: 1,
        displayName: 1,
        icon: 1,
        toolTip: 1,
        parent: 1,
        layer: 1,
        tag: 1,
        adjustChildrenToTop: 1
    };
}

getSerializableStyles() → {any}

此函数返回一个map,决定序列化时哪些样式可被序列化,默认所有样式都会被序列化

Returns:
any -

需要被序列化的样式map

Inherited From:
Example
function(){
    var name, map = ;
    for (name in this._styleMap) {
        map[name] = 1;
    }
    returns map;
}

getShapeElevation() → {number}

获取 shape 在三维中的 y 坐标

Returns:
number
Inherited From:

getSize() → {Size2d}

获取图元在2D拓扑中的尺寸(宽高)

Returns:
Size2d
Inherited From:
Example
//返回值示例:
{
	   with: 100,
	   height: 100
}

getSize3d() → {Array.<number>}

获取图元在3D拓扑中的尺寸(长宽高)

Returns:
Array.<number> -

格式为[x, y, z],即[getWidth(), getTall(), getHeight()]

Inherited From:

getSourceAgentEdges() → {ht.List}

获取代理的起始于该图元的连线

Returns:
ht.List
Inherited From:

getSourceEdges() → {ht.List}

获取跟图元关联的并起始于该图元的连线(不包括代理的连线)

Returns:
ht.List
Inherited From:

getStyle(name) → {any}

获取样式属性

Parameters:
Name Type Description
name string

样式名

Returns:
any
Inherited From:

getStyleMap() → {any}

获取图元内部样式映射信息

Returns:
any -

样式映射表

Inherited From:

getSuperClass() → {function}

获取父类声明(构造函数),继承类时可以用来调用父类构造或函数

Returns:
function -

父类声明(构造函数)

Inherited From:
Example
function MyNode() {
     this.getSuperClass().call(this);//调用父类构造函数
}
ht.Default.def(MyNode, Data, {
   setName: function(name) {
   	this.getSuperClass().prototype.setName.call(this, name);//调用父类的setName函数
   	this._username = name;
   }
});

getTag() → {string}

获取标示号,可通过getDataByTag快速查找

Returns:
string -

标示号

Inherited From:

getTall() → {number}

获取图元在3D拓扑中的y轴长度

Returns:
number
Inherited From:

getTargetAgentEdges() → {ht.List}

获取图元代理的结束于该图元的连线

Returns:
ht.List
Inherited From:

getTargetEdges() → {ht.List}

获取跟图元关联的并结束于该图元的连线(不包括代理的连线)

Returns:
ht.List
Inherited From:

getThickness() → {number}

获取3D拓扑中的线段厚度,小于0时可实现类似地板的填充效果

Returns:
number
Inherited From:

getToolTip() → {string}

获取文字提示信息

Returns:
string -

文字提示

Inherited From:

getUIClass() → {function}

获取拓扑组件上的UI类

Returns:
function -

UI类声明(构造函数)

Inherited From:

getWidth() → {number}

获取图元在2D拓扑中的宽度,或在3D拓扑中x轴的长度

Returns:
number
Inherited From:

getX() → {number}

获取节点 x 坐标

Returns:
number -

节点 x 坐标

Inherited From:

getY() → {number}

获取节点 y 坐标

Returns:
number -

节点 y 坐标

Inherited From:

handleHostPropertyChange(event) → {void}

当吸附宿主对象属性发生变化时回调该函数,可重载做后续处理

Parameters:
Name Type Description
event any

事件对象

Returns:
void
Inherited From:

hasAgentEdges() → {boolean}

判断当前图元上是否有代理连线

Returns:
boolean
Inherited From:

hasChildren() → {boolean}

判断是否有孩子

Returns:
boolean -

是否有孩子

Inherited From:

hasInheritedSize() → {boolean}

判断当前图元上是否有继承大小

Returns:
boolean
Inherited From:

invalidate() → {void}

强制触发属性变化事件通知界面更新

Returns:
void
Inherited From:

invalidateView() → {void}

无效视图

Returns:
void
Since:
  • 7.7.0
Inherited From:

isAdjustChildrenToTop() → {boolean}

GraphView点击图元会自动sendToTop,该属性决定是否对子图元也进行sendToTop操作

Returns:
boolean -

是否将children自动sendToTop

Inherited From:

isAnimationPaused() → {boolean}

是否动画正在被暂停播放中

Returns:
boolean
Since:
  • 7.7.0
Inherited From:

isAnimationPlaying() → {boolean}

是否动画正在播放中

Returns:
boolean
Since:
  • 7.7.0
Inherited From:

isClosePath() → {boolean}

是否闭合Shape

Returns:
boolean
Inherited From:

isDescendantOf(data) → {boolean}

判断自身是否为指定data的子孙

Parameters:
Name Type Description
data ht.Data

要对比的数据元素

Returns:
boolean -

自身是否为指定data的子孙

Inherited From:

isEmpty() → {boolean}

判断是否有孩子,同hasChildren

Returns:
boolean -

是否有孩子

Inherited From:

isHostOn(node) → {boolean}

判断当前图元是否吸附到指定图元对象上

Parameters:
Name Type Description
node ht.Node

指定的图元

Returns:
boolean
Inherited From:

isInRect(rect) → {boolean}

判断节点是否在矩形区域内

Parameters:
Name Type Description
rect Rect

矩形区域

Returns:
boolean
Inherited From:

isLoopedHostOn(node) → {boolean}

判断当前节点是否与传入节点互相吸附

Parameters:
Name Type Description
node ht.Node
Returns:
boolean
Inherited From:

isParentOf(data) → {boolean}

判断自身是否为指定data的父亲

Parameters:
Name Type Description
data ht.Data

要对比的数据元素

Returns:
boolean -

自身是否为指定data的父亲

Inherited From:

isRelatedTo(data) → {boolean}

判断自身与指定data是否有父子或子孙关系

Parameters:
Name Type Description
data ht.Data

要对比的数据元素

Returns:
boolean -

自身与指定data是否有父子或子孙关系

Inherited From:

iv() → {void}

强制触发属性变化事件通知界面更新,invalidate的缩写

Returns:
void
Inherited From:

layout(host) → {void}

执行布局

Parameters:
Name Type Description
host ht.Node
Returns:
void
Inherited From:

lookAt(target, face) → {void}

三维中,将节点指定面朝向目标位置旋转,可理解为节点本身看向这个位置,可以选择是哪个面看向目标

Parameters:
Name Type Attributes Description
target Array.<number>

目标位置

face string <optional>

可以是 front|back|top|bottom|right|left , 默认是 front

Returns:
void
Inherited From:

lookAtDirection(vec, face) → {void}

三维中,指定面节点看向某个方向

Parameters:
Name Type Attributes Description
vec Array.<number>

方向量,以节点自身为坐标中心,如 [0, 1, 0] 是正上方

face string <optional>

可以是 front|back|top|bottom|right|left , 默认是 front

Returns:
void
Inherited From:

lookAtX(target, face) → {void}

三维中,绕着原朝向 a 跟目标朝向 b 的法线旋转 ab 夹角

Parameters:
Name Type Attributes Description
target Array.<number>

目标位置

face string <optional>

可以是 front|back|top|bottom|right|left , 默认是 front

Returns:
void
Inherited From:

onChildAdded(child, index) → {void}

添加孩子时的回调函数,可重载做后续处理

Parameters:
Name Type Description
child ht.Data

新增加的孩子元素

index number

索引

Returns:
void
Inherited From:

onChildRemoved(child, index) → {void}

删除孩子时的回调函数,可重载做后续处理

Parameters:
Name Type Description
child ht.Data

被删除的孩子元素

index number

索引

Returns:
void
Inherited From:

onHostChanged(oldHost, newHost) → {void}

当吸附的宿主对象发生变化时回调该函数,可重载做后续处理

Parameters:
Name Type Description
oldHost ht.Node

旧的宿主

newHost ht.Node

新的宿主

Returns:
void
Inherited From:

onParentChanged(oldParent, parent) → {void}

改变父亲元素时的回调函数,可重载做后续处理

Parameters:
Name Type Description
oldParent ht.Data

旧的父元素

parent ht.Data

新的父元素

Returns:
void
Inherited From:

onPropertyChanged(event) → {void}

属性变化回调函数,可重载做后续处理

Parameters:
Name Type Description
event any

属性变化事件

Returns:
void
Inherited From:
Example
//event格式:
{
	   property: 'name',//发生变化的属性
	   oldValue: 'oldValue',//旧值
	   newValue: 'newValue',''新值
	   data: data//发生变化的data
}

onStyleChanged(name, oldValue, newValue) → {void}

样式属性变化时会回调该函数,可重载做后续处理

Parameters:
Name Type Description
name string

样式名

oldValue any

旧的样式值

newValue any

新的样式值

Returns:
void
Inherited From:

p(x, y) → {Object}

获取或设置图元锚点位置所在坐标,有两个参数时相当于setPosition,没有参数时相当于getPosition

Parameters:
Name Type Attributes Description
x number | Point

x坐标

y number <optional>

y坐标

Returns:
Object -

坐标值,格式为: {x: x, y: y }

Inherited From:

p3(x, y, z) → {void}

获取或设置图元锚点位置在3D拓扑中的三维坐标,相当于setPosition3d

Parameters:
Name Type Attributes Description
x number | Array.<number>

x坐标

y number <optional>

y坐标

z number <optional>

z坐标

Returns:
void -

三维坐标数组,格式为[x, y, z]

Inherited From:

pauseAnimation() → {void}

暂停当前正在播放的动画

Returns:
void
Since:
  • 7.7.0
Inherited From:

playAnimation(animationName, speed, start, loop) → {boolean}

播放一个动画

Parameters:
Name Type Description
animationName string

动画名称

speed number

浮点类型,播放动画的速度,可以是0,表示静止的动画,也可以可以是负数,表示反向播放

start number

浮点类型,默认 0,动画的起始位置,可以是从中间开始播放动画

loop string

循环模式,可以是 once / repeat / pingpong,默认 repeat

Returns:
boolean
Inherited From:

r3(rotationX, rotationY, rotationZ) → {void}

获取或设置图元在3D拓扑中的三维旋转角度,相当于setRotation3d

Parameters:
Name Type Attributes Description
rotationX number | Array.<number>

沿x轴的旋转角度(弧度制)

rotationY number <optional>

沿y轴的旋转角度(弧度制)

rotationZ number <optional>

沿z轴的旋转角度(弧度制)

Returns:
void
Inherited From:

removeChild(child) → {void}

删除指定孩子元素,内部会自动调用孩子元素的setParent

Parameters:
Name Type Description
child ht.Data

要删除的孩子元素

Returns:
void
Inherited From:

removeFromDataModel() → {void}

从数据模型中移出

Returns:
void
Inherited From:

removePointAt(index) → {void}

根据索引删除点

Parameters:
Name Type Description
index number

索引

Returns:
void
Inherited From:

removeStyleIcon(name) → {void}

删除icon

Parameters:
Name Type Description
name string

要删除的icon名

Returns:
void
Inherited From:

resumeAnimation() → {void}

继续播放被暂停的动画

Returns:
void
Since:
  • 7.7.0
Inherited From:

rotateAroundAxis(axis, radian) → {void}

相对 node 自身的坐标轴,以一个归一化的向量为轴,进行旋转

Parameters:
Name Type Description
axis ht.Math.Vector3

旋转轴

radian number

旋转弧度

Returns:
void
Since:
  • 7.2.5
Inherited From:
Example
axis = new ht.Math.Vector3(1, 0, 1).normalize();
node.rotateAroundAxis( axis, radian )

rotateAroundWorldAxis(axis, radian) → {void}

相对世界的坐标轴,以一个归一化的向量为轴,进行旋转

Parameters:
Name Type Description
axis ht.Math.Vector3

旋转轴

radian number

旋转弧度

Returns:
void
Since:
  • 7.2.5
Inherited From:
Example
axis = new ht.Math.Vector3(1, 0, 1).normalize();
node.rotateAroundWorldAxis( axis, radian )

rotateAt(x, y, angle) → {void}

以指定的坐标为中心旋转图元

Parameters:
Name Type Description
x number

指定x坐标

y number

指定y坐标

angle number

旋转角度(弧度制)

Returns:
void
Inherited From:

s(name, value) → {ht.Data}

获取或设置样式,仅有一个参数时相当于getStyle,有两个参数时相当于setStyle

Parameters:
Name Type Description
name string

样式名

value any

样式值

Returns:
ht.Data
Inherited From:

s3(width, tall, height) → {void}

获取或设置图元在3D拓扑中的尺寸,相当于setSize3d

Parameters:
Name Type Attributes Description
width number | Array.<number>

x轴方向的长度

tall number <optional>

y轴方向的长度

height number <optional>

z轴方向的长度

Returns:
void
Inherited From:

setAdjustChildrenToTop(adjustToTop) → {void}

GraphView点击图元会自动sendToTop,该属性决定是否对子图元也进行sendToTop操作

Parameters:
Name Type Description
adjustToTop boolean

是否将children自动sendToTop

Returns:
void
Inherited From:

setAnchor(x, y, rectStable) → {void}

设置节点锚点

Parameters:
Name Type Attributes Description
x number | Array.<number> | Point

只传一个参数时,可以使用 { x: 1, y: 1 } 或 [1,1] 的格式

y number | boolean <optional>

纵锚点,当第一个对象为对象或者数组时,这个参数当作 rectStable

rectStable boolean <optional>

是否保持保持包围盒位置不变

Returns:
void
Inherited From:

setAnchor3d(x, y, z, rectStable) → {boolean}

设置节点3d锚点属性

Parameters:
Name Type Attributes Description
x number
y number
z number
rectStable boolean <optional>

是否保持包围盒区域不变

Returns:
boolean -

是否有更新

Inherited From:

setAnchorElevation(anchorElevation) → {void}

设置三维中高度锚点

Parameters:
Name Type Description
anchorElevation number
Returns:
void
Inherited From:

setAnchorX(anchorX) → {void}

设置横向锚点a

Parameters:
Name Type Description
anchorX number
Returns:
void
Inherited From:

setAnchorY(anchorY) → {void}

设置纵向锚点

Parameters:
Name Type Description
anchorY number
Returns:
void
Inherited From:

setAnimation(config) → {void}

设置节点动画属性,当属性为 null 时为清除动画

Parameters:
Name Type Description
config object

动画配置

Requires:
  • module:ht-animation.js
Returns:
void
Inherited From:

setAttr(name, value) → {void}

设置attr属性

Parameters:
Name Type Description
name string

属性名

value any

属性值

Returns:
void
Inherited From:

setAttrObject(attrObject) → {void}

设置attr属性对象,该属性默认为空,用于存储用户业务信息

Parameters:
Name Type Description
attrObject any

attr属性对象

Returns:
void
Inherited From:

setClosePath(v) → {void}

设置是否闭合Shape

Parameters:
Name Type Description
v boolean
Returns:
void
Inherited From:

setDataBindings(dataBindings) → {void}

设置数据绑定

Parameters:
Name Type Description
dataBindings Object

数据绑定对象

Returns:
void
Inherited From:

setDisplayName(displayName) → {void}

设置显示名称,常作为Column和Property的列头和属性名称显示

Parameters:
Name Type Description
displayName string

显示名称

Returns:
void
Inherited From:

setElevation(elevation) → {void}

设置图元中心在3D坐标系中的y坐标

Parameters:
Name Type Description
elevation number

y轴方向的坐标值

Returns:
void
Inherited From:

setEuler(euler) → {void}

设置欧拉旋转角

Parameters:
Name Type Description
euler ht.Math.Euler
Returns:
void
Inherited From:

setHeight(height) → {void}

设置图元在2D拓扑中的高度,或3D拓扑中的z轴长度

Parameters:
Name Type Description
height number

2D拓扑中的高度,或3D拓扑中的z轴长度

Returns:
void
Inherited From:

setHeightForce(height) → {void}

设置图元在2D拓扑中的高度,或3D拓扑中的z轴长度, 当值小于 0.00001 时用到

Parameters:
Name Type Description
height number
Returns:
void
Inherited From:

setHost(data) → {void}

设置宿主图元,当图元吸附上宿主图元时,宿主移动或旋转时会带动所有吸附者

Parameters:
Name Type Description
data ht.Data

宿主图元

Returns:
void
Inherited From:

setIcon(icon) → {void}

设置小图标名称,常作为TreeView和ListView等组件上的节点小图标

Parameters:
Name Type Description
icon any

图标名或矢量

Returns:
void
Inherited From:

setId(id) → {void}

设置唯一编号,如果手工设置,一定要确保在data加入到DataModel之前设置并且唯一不重复

Parameters:
Name Type Description
id string | number

唯一编号

Returns:
void
Inherited From:

setImage(image) → {void}

设置拓扑上展现的图片信息,在GraphView拓扑图中图片一般以position为中心绘制

Parameters:
Name Type Description
image string | Object

注册的图片名或url或矢量对象

Returns:
void
Inherited From:

setLayer(layer) → {void}

设置数据元素在GraphView组件中的图层位置

Parameters:
Name Type Attributes Description
layer string | number <optional>

图层名

Returns:
void
Inherited From:

setLocalEuler(k) → {void}

设置节点的局部旋转

Parameters:
Name Type Description
k ht.Math.Euler

欧拉角

Returns:
void
Inherited From:

setLocalQuaternion(quaternion) → {void}

设置全局坐标的四元素数据

Parameters:
Name Type Description
quaternion ht.Math.Quaternion
Returns:
void
Inherited From:

setMaterial(name, material) → {void}

注册材质,请参考材质手册

Parameters:
Name Type Description
name string

材质名

material Object
Returns:
void -

material 材质信息

Since:
  • 7.7.0
Inherited From:

setName(name) → {void}

设置数据元素名称

Parameters:
Name Type Description
name string

数据元素名称

Returns:
void
Inherited From:

setParent(parent) → {void}

设置父元素

Parameters:
Name Type Description
parent ht.Data

父元素

Returns:
void
Inherited From:

setPoint(index, point) → {void}

修改索引指向的点坐标

Parameters:
Name Type Description
index number

索引

point Point

新坐标点

Returns:
void
Inherited From:

setPoints(points) → {void}

设置Shape的点

Parameters:
Name Type Description
points Array.<Point> | ht.List
Returns:
void
Inherited From:

setPoints3d(points) → {void}

3D 上设置Shape的点

Parameters:
Name Type Description
points Array.<any> | ht.List
Returns:
void
Inherited From:

setPosition(x, y) → {void}

设置图元锚点位置所在坐标

Parameters:
Name Type Attributes Description
x number | Point <optional>

x坐标

y number <optional>

y坐标

Returns:
void
Inherited From:

setPosition3d(x, y, z) → {void}

设置图元锚点位置在3D拓扑中的三维坐标

Parameters:
Name Type Description
x number

x坐标

y number

y坐标

z number

z坐标

Returns:
void
Inherited From:

setQuaternion(quaternion) → {ht.Node}

设置四元素

Parameters:
Name Type Description
quaternion ht.Math.Quaternion
Returns:
ht.Node
Inherited From:

setRect(x, y, width, height) → {void}

设置图元矩形区域

Parameters:
Name Type Attributes Description
x number | Rect

x坐标

y number <optional>

y坐标

width number <optional>

宽度

height number <optional>

高度

Returns:
void
Inherited From:

setRenderLayer(layerName) → {void}

设置节点的三维渲染层级,配合 ht.Default 中的 getRenderLayerInfo 和 setRenderLayerInfo 使用

Parameters:
Name Type Description
layerName string | number
Returns:
void
Inherited From:

setRotation(rotation) → {void}

设置图元的旋转角度,围绕中心点顺时针旋转

Parameters:
Name Type Description
rotation number

旋转角度(弧度制)

Returns:
void
Inherited From:

setRotation3d(rotationX, rotationY, rotationZ) → {void}

设置图元在3D拓扑中的三维旋转角度

Parameters:
Name Type Attributes Description
rotationX number | Array.<number>

沿x轴的旋转角度(弧度制)

rotationY number <optional>

沿y轴的旋转角度(弧度制)

rotationZ number <optional>

沿z轴的旋转角度(弧度制)

Returns:
void
Inherited From:

setRotationMode(rotationMode) → {void}

设置三维旋转模式

图元在3D拓扑中旋转时,先沿x轴旋转,再沿y轴旋转和先沿y轴旋转,再沿x轴旋转最后的结果是不一样的

Parameters:
Name Type Description
rotationMode string

旋转模式,可选值如下:

  • xyz:先进行x轴旋转,再进行y轴旋转,最后进行z轴旋转
  • xzy:先进行x轴旋转,再进行z轴旋转,最后进行y轴旋转
  • yxz:先进行y轴旋转,再进行x轴旋转,最后进行z轴旋转
  • yzx:先进行y轴旋转,再进行z轴旋转,最后进行x轴旋转
  • zxy:先进行z轴旋转,再进行x轴旋转,最后进行y轴旋转
  • zyx:先进行z轴旋转,再进行y轴旋转,最后进行x轴旋转
Returns:
void
Inherited From:

setRotationX(rotationX) → {void}

设置图元在3D拓扑中沿x轴的旋转角度(弧度制)

Parameters:
Name Type Description
rotationX number

旋转角度(弧度制)

Returns:
void
Inherited From:

setRotationY(rotationY) → {void}

设置图元在3D拓扑中沿y轴的旋转角度(弧度制)

Parameters:
Name Type Description
rotationY number

旋转角度(弧度制)

Returns:
void
Inherited From:

setRotationZ(rotationZ) → {void}

设置图元在3D拓扑中沿z轴的旋转角度(弧度制)

Parameters:
Name Type Description
rotationZ number

旋转角度(弧度制)

Returns:
void
Inherited From:

setScale(x, y) → {void}

设置节点缩放属性

Parameters:
Name Type Attributes Description
x number | Point

只传一个参数时,可以使用 { x: 1, y: 1 } 的格式

y number <optional>

纵缩放

Returns:
void
Inherited From:

setScale3d(x, y, z) → {void}

设置节点3d缩放属性

Parameters:
Name Type Attributes Description
x number | Array.<number>

只传一个参数时,可以使用 [1, 1, 1] 的格式

y number <optional>

纵缩放

z number <optional>
Returns:
void
Inherited From:

setScaleTall(scaleTall) → {void}

设置三维中高度缩放

Parameters:
Name Type Description
scaleTall number
Returns:
void
Inherited From:

setScaleX(scaleX) → {void}

设置横向缩放

Parameters:
Name Type Description
scaleX number
Returns:
void
Inherited From:

setScaleY(scaleY) → {void}

设置纵向缩放

Parameters:
Name Type Description
scaleY number

纵向缩放值

Returns:
void
Inherited From:

setSegments(segments) → {void}

设置Shape的线段类型

Parameters:
Name Type Description
segments Array.<number> | ht.List
Returns:
void
Inherited From:

setSize(width, height) → {void}

设置图元在2D拓扑中的尺寸(宽高)

Parameters:
Name Type Description
width number

宽度

height number

高度

Returns:
void
Inherited From:

setSize3d(width, tall, height) → {void}

设置图元在3D拓扑中的尺寸

Parameters:
Name Type Description
width number

x轴方向的长度

tall number

y轴方向的长度

height number

z轴方向的长度

Returns:
void
Inherited From:

setStyle(name, value) → {void}

设置样式

Parameters:
Name Type Description
name string

样式名

value any

样式值

Returns:
void
Inherited From:

setStyleMap(styleMap) → {void}

设置节点样式对象

Parameters:
Name Type Description
styleMap any
Returns:
void
Inherited From:

setTag(tag) → {void}

设置标示号,可通过getDataByTag快速查找

Parameters:
Name Type Description
tag string

标示号

Returns:
void
Inherited From:

setTall(tall) → {void}

设置图元在3D拓扑中的y轴方向的长度

Parameters:
Name Type Description
tall number

y轴方向的长度

Returns:
void
Inherited From:

setThickness(thickness) → {void}

设置3D拓扑中的线段厚度,小于0时可实现类似地板的填充效果

Parameters:
Name Type Description
thickness number
Returns:
void
Inherited From:

setToolTip(toolTip) → {void}

设置文字提示信息

Parameters:
Name Type Description
toolTip string

文字提示

Returns:
void
Inherited From:

setWidth(width) → {void}

设置图元在3D拓扑中的x轴方向的长度

Parameters:
Name Type Description
width number

x轴方向的长度

Returns:
void
Inherited From:

setWidthForce(width) → {void}

设置图元2D拓扑中的宽度,或3D拓扑中的z轴长度, 当值小于 0.00001 时用到

Parameters:
Name Type Description
width number
Returns:
void
Inherited From:

setX(x) → {void}

设置节点 x 坐标

Parameters:
Name Type Description
x number

节点的 x 坐标

Returns:
void
Inherited From:

setY(y) → {void}

设置节点 y 坐标

Parameters:
Name Type Description
y number

节点的 y 坐标

Returns:
void
Inherited From:

shiftPoints(x, y, e) → {void}

偏移所有点

Parameters:
Name Type Attributes Description
x number <optional>

x 轴,

y number <optional>

y 轴,三维中对应 z 轴

e number <optional>

高度,三维中对应 y 轴

Returns:
void
Inherited From:

shiftPointsElevation(e) → {void}

Parameters:
Name Type Description
e number

高度,三维中对应 y 轴

Returns:
void
Inherited From:

size() → {number}

获取孩子元素总数

Returns:
number -

孩子元素总数

Inherited From:

stopAnimation() → {void}

停止当前正在播放的动画

Returns:
void
Since:
  • 7.7.0
Inherited From:

t3(tx, ty, tz) → {void}

在当前坐标的基础上增加x、y、z三个方向的平移值,translate3d的缩写

Parameters:
Name Type Description
tx number

x轴方向的平移值

ty number

y轴方向的平移值

tz number

z轴方向的平移值

Returns:
void
Inherited From:

testRenderLayer(layerName) → {boolean}

测试对应的渲染层级名是否被注册

Parameters:
Name Type Description
layerName string

渲染层级

Returns:
boolean
Since:
  • 7.7.0
Inherited From:

toChildren(matchFunc, scope) → {ht.List}

以matchFunc为过滤函数构建新的孩子元素集合

Parameters:
Name Type Attributes Description
matchFunc function <optional>

过滤函数

scope any <optional>

函数域

Returns:
ht.List -

孩子元素集合

Inherited From:
Example
var list = data.toChildren(function(child) {
    if (child.a('visible')) {
   	   returns true;
    }
});

toGlobal(point) → {Point}

将矢量本地坐标转换为图纸全局坐标

Parameters:
Name Type Description
point Point
Returns:
Point
Inherited From:

toLabel() → {string}

返回值作为TreeView和GraphView等组件上的图元文字标签,默认返回displayName||name信息

Returns:
string -

文字标签

Inherited From:

toLocal(point) → {Point}

将全局坐标转换为本地矢量坐标,得到结果需再加上 anchor * size

Parameters:
Name Type Description
point Point
Returns:
Point
Inherited From:

toPoints() → {ht.List}

构建一个新的Shape点集合并返回

Returns:
ht.List
Inherited From:

toSegments() → {ht.List}

构建一个新的线段类型集合并返回

Returns:
ht.List
Inherited From:

toString() → {string}

重写 js 默认的 toString, 优先返回 displayName|name,再者是 tag,如果displayName|name|tag都没有值,则返回 ID

Returns:
string -

数据名称/标签/ID

Inherited From:

translate(tx, ty) → {void}

在当前坐标的基础上增加x、y两个方向的平移值

Parameters:
Name Type Description
tx number

x轴方向的平移值

ty number

y轴方向的平移值

Returns:
void
Inherited From:

translate3d(tx, ty, tz) → {void}

在当前坐标的基础上增加x、y、z三个方向的平移值,t3的缩写

Parameters:
Name Type Description
tx number

x轴方向的平移值

ty number

y轴方向的平移值

tz number

z轴方向的平移值

Returns:
void
Inherited From:

translate3dBy(direction, distance) → {void}

相对 node 自身的坐标轴,以一个归一化的向量为方向,进行平移

Parameters:
Name Type Description
direction Array.<number>

方向向量

distance number

平移距离

Returns:
void
Inherited From:
Example
axis = new ht.Math.Vector3(0, 1, 0).normalize().toArray();
node.translate3dBy( axis, 10 );

translateBack(distance) → {void}

沿向量[0, 0, -1]平移

Parameters:
Name Type Description
distance number

平移距离

Returns:
void
Inherited From:

translateBottom(distance) → {void}

沿向量[0, -1, 0]平移

Parameters:
Name Type Description
distance number

平移距离

Returns:
void
Inherited From:

translateFront(distance) → {void}

沿向量[0, 0, 1]平移

Parameters:
Name Type Description
distance number

平移距离

Returns:
void
Inherited From:

translateLeft(distance) → {void}

沿向量[-1, 0, 0]平移

Parameters:
Name Type Description
distance number

平移距离

Returns:
void
Inherited From:

translateRight(distance) → {void}

沿向量[1, 0, 0]平移

Parameters:
Name Type Description
distance number

平移距离

Returns:
void
Inherited From:

translateTop(distance) → {void}

沿向量[0, 1, 0]平移

Parameters:
Name Type Description
distance number

平移距离

Returns:
void
Inherited From:

updateAttach() → {void}

更新吸附于此节点的节点

Returns:
void
Inherited From:

updateLayoutParameters(host, params) → {void}

更新布局参数

Parameters:
Name Type Description
host ht.Node

宿主图元

params any
Returns:
void
Inherited From: