ht.Default

工具对象,包含HT默认的配置参数和一些工具函数
不要直接修改这个对象的属性值,如果需要改变HT的默认配置,需要通过全局的htconfig变量名指定,HT系统只在初始化时读取htconfig的配置信息,
因此htconfig必须在引入ht.js包之前初始化好,运行状态时修改htconfig变量不会再起作用,示例代码如下:

Example

<script>
  htconfig = {
      Color: {
          label: '#000',
          highlight: '#1ABC9C',
      },
      Default: {
          toolTipDelay: 100,
          toolTipContinual: true
      }
  };
</script>
<script src="ht.js"></script>

Members

static accordionViewCollapseIcon :string

折叠组件关闭状态图标

static accordionViewExpandIcon :string

折叠组件展开状态图标

static accordionViewLabelColor :string

折叠组件文字颜色

Default Value:
  • #FFF

static accordionViewLabelFont :string

折叠组件文字字体

Default Value:
  • 12px arial, sans-serif

static accordionViewSelectBackground :string

折叠组件选中背景

Default Value:
  • #1ABC9C

static accordionViewSelectWidth :number

折叠组件选中宽度

Default Value:
  • 3

static accordionViewSeparatorColor :string

折叠组件分隔条颜色

static accordionViewTitleBackground :string

折叠组件抬头背景

Default Value:
  • #2C3E50

static animDuration :number

默认动画周期毫秒数

Default Value:
  • 200

static animEasing :function

默认动画效果函数

Default Value:
  • function (m){return m*m}

static autoHideScrollBar :boolean

决定组件的滚动条默认是否自动隐藏,true为自动显示和隐藏,false则需要滚动时一直显示不会自动隐藏

Default Value:
  • true

static autoMakeVisible :boolean

决定Data元素被选中时,组件是否自动滚动到Data元素可见位置

Default Value:
  • true

static baseZIndex :number

指定组件基准 CSS 的 ZIndex 值,改值仅在将 HT 与其他第三方组件混合使用时根据需要设置

Default Value:
  • undefined

static blockMinSize :number

默认设置 block 组合大小的最小限制

Default Value:
  • 1

static clickDelay :number

单击延迟, onClick 事件之后,延迟时间内如果有再次点击就判定为双击

Default Value:
  • 200

static compStack :Array.<any>

矢量组件 comp 嵌套堆栈,矢量组件 comp 可嵌套定义,通过改参数能得到当前嵌套层次信息

Default Value:
  • []

static crossOrigin :string

图片请求的时候跨域标记,默认空字符串等同 anonymous

Default Value:
  • anonymous

static dashPattern :Array.<number>

连线或多边形等图形的默认虚线样式

Default Value:
  • [16, 16]

static debugTipBackground :string

默认 debugTip 背景颜色

Default Value:
  • #FFFFE0

static debugTipLabelColor :string

默认 debugTip 文字颜色

Default Value:
  • #000

static debugTipLabelFont :string

默认 debugTip 字体

Default Value:
  • '12px arial, sans-serif'

static devicePixelRatio :number

设备像素比,HT 系统自动取至 window.devicePixelRatio,某些特性情况需要为 mobile 应用牺牲精度节省内存时可以强制设置为较小值

Default Value:
  • 1.25

static disabledBackground :string

组件无效时的背景色

Default Value:
  • rgba(255,255,255,0.65)

static disabledOpacity :number

组件无效时的透明度

Default Value:
  • 0.4

static doubleClickRange :number

默认双击的两次点击间隔范围

Default Value:
  • 1

static doubleClickSpeed :number

默认两次双击之间的间隔事件

Default Value:
  • 500

static doubleTouchRange :number

默认触摸双击的两次点击间隔范围

Default Value:
  • 20

static edgeGroupAgentFunc :function

此函数返回连线组的代理连线,edges为List类型的Edge对象数组,默认返回edges.get(0),可重载自定义规则

Default Value:
  • null

static encodeStringKey :string

编码字符串键

Default Value:
  • null

static eventListenerOptionsFalse :Object

事件监听选项为 false

Default Value:
  • { passive: false, capture: false }

static eventListenerOptionsTrue :Object

事件监听选项为 true

Default Value:
  • { passive: true, capture: true }

static graph3dEnvmapCapabilityRequire :number

Vector 最大的缓存时间

Default Value:
  • 50

static graph3dMaxVectorCacheTime :number

Vector 最大的缓存时间

Default Value:
  • 50

static graph3dViewAttributes :Object

Graph3dView组件初始化WebGL上下文参数,一般无需改动

Default Value:
  • null

static graph3dViewAxisXColor :string

Graph3dView组件显示x轴线颜色

Default Value:
  • [1,0,0,1]

static graph3dViewAxisYColor :string

Graph3dView组件显示y轴线颜色

Default Value:
  • [0,1,0,1]

static graph3dViewAxisZColor :string

Graph3dView组件显示z轴线颜色

Default Value:
  • [0,0,1,1]

static graph3dViewBatchBlendDisabled :boolean

批量染色是否禁用

Default Value:
  • true

static graph3dViewBatchBrightnessDisabled :boolean

批量亮度是否启用

Default Value:
  • true

static graph3dViewBatchColorDisabled :boolean

批量颜色是否禁用

Default Value:
  • false

static graph3dViewBatchInstancedDisabled :boolean

是否禁用批量同质

Default Value:
  • false

static graph3dViewBlockSelectable :boolean

Graph3dView组件是否允许选中 block 组合

Default Value:
  • true

static graph3dViewCenter :Array.<number>

Graph3dView组件投影呈现时,眼睛最终锁定的目标中心位置

Default Value:
  • [0,0,0]

static graph3dViewCenterAxisVisible :boolean

Graph3dView组件屏幕中心点x|y|z三个轴线是否可见

Default Value:
  • false

static graph3dViewDataNumWarningLine :number

节点数量警告线,超过会有告警提示

Default Value:
  • 10000

static graph3dViewEditHelperDisabled :boolean

是否关闭 EditHelper

Default Value:
  • false

static graph3dViewEditSizeColor :string

Graph3dView组件在编辑状态图元拉伸标识颜色

Default Value:
  • [1,1,0,1]

static graph3dViewEnvmapType :string

设置环境光模式,new / legacy 两种模式

Default Value:
  • legacy

static graph3dViewEye :Array.<number>

Graph3dView组件投影呈现时,眼睛观察点所在位置

Default Value:
  • [0,300,1000]

static graph3dViewFar :number

Graph3dView组件投影呈现内容的最远距离,该值可根据场景最远范围进行调节设置

Default Value:
  • 10000

static graph3dViewFirstPersonMode :boolean

Graph3dView组件是否为第一人称交互方式

Default Value:
  • false

static graph3dViewFlowBlendMode :string

流光染色模式。模式有:叠加RGB(addRGB);叠加RGBA(addRGBA);覆盖A(overrideA);覆盖RGB(overrideRGB);覆盖RGBA(overrideRGBA);相乘RGB(multiplyRGB);相乘RGBA(multiplyRGBA) .

Default Value:
  • addRGB

static graph3dViewFogColor :string

雾颜色

Default Value:
  • white

static graph3dViewFogDensity :number

雾化强度,默认值为:0.0005

Default Value:
  • 0.0005

static graph3dViewFogDisabled :boolean

是否关闭雾化效果

Default Value:
  • true

static graph3dViewFogFar :number

代表从该距离之后物体完全看不清

Default Value:
  • 2000

static graph3dViewFogMode :string

雾化模式,可设置为线性linear、标准exp2两种模式

Default Value:
  • linear

static graph3dViewFogNear :number

代表从该距离起物体开始受雾效果影响

Default Value:
  • 1

static graph3dViewFovy :number

Graph3dView组件在透视投影方式下的y轴张角弧度(Field of view)

Default Value:
  • 0.7853981633974483

static graph3dViewGridColor :string

Graph3dView组件显示xz面的网格线颜色

Default Value:
  • [0.4,0.75,0.85,1]

static graph3dViewGridGap :number

Graph3dView组件显示xz面的网格行列间距

Default Value:
  • 50

static graph3dViewGridSize :number

Graph3dView组件显示xz面的网格行列数

Default Value:
  • 50

static graph3dViewGridVisible :boolean

Graph3dView组件是否允许显示xz面网格

Default Value:
  • false

static graph3dViewHeadlightAmbientIntensity :number

头灯环境光比例,默认为0.7,即无论灯的角度,头灯都会贡献70%的环境光,剩下30%根据灯的角度决定强弱

Default Value:
  • 0.7

static graph3dViewHeadlightColor :Array.<number>

头灯颜色

Default Value:
  • [1,1,1,1]

static graph3dViewHeadlightDirection :string|Array.<number>

头灯方向,跟随相机: camera,跟随阴影方向:shadow,任意方向:某一个点例如[0, -1, 0]。

Default Value:
  • camera

static graph3dViewHeadlightDisabled :boolean

是否关闭头灯效果

Default Value:
  • false

static graph3dViewHeadlightGroup :number

头灯所在的灯光组, 默认是0

Default Value:
  • 0

static graph3dViewHeadlightIntensity :number

头灯强度,默认为1,大于1增强,小于1减弱

Default Value:
  • 1

static graph3dViewHeadlightRange :number

头灯影响范围,默认为
0
代表可照射到无穷远处,如果设置了值则光照射效果随物体远离光影而衰减

Default Value:
  • 0

static graph3dViewHeadlightRatioForPhysicalMaterial :number

头灯材质系数,默认值为 0.5

Since:
  • 7.7.0
Default Value:
  • 0.5

static graph3dViewMouseRoamable :boolean

Graph3dView组件在第一人称交互方式时,鼠标是否能漫游

Default Value:
  • true

static graph3dViewMoveStep :number

Graph3dView组件键盘控制移动的步进

Default Value:
  • 15

static graph3dViewNear :number

Graph3dView组件投影呈现内容的最近距离,该值在可接受的范围内尽量设置较大值有利于呈现精度

Default Value:
  • 10

static graph3dViewOpaqueSortable :boolean

默认是否开启对不透明的物体也启用排序

Since:
  • 7.7.0
Default Value:
  • false

static graph3dViewOriginAxisVisible :boolean

Graph3dView组件原点x|y|z三个轴线是否可见

Default Value:
  • false

static graph3dViewOrtho :boolean

Graph3dView组件是否显示为正交投影方式

Default Value:
  • false

static graph3dViewOrthoWidth :number

Graph3dView组件正交投影方式下屏幕宽度内显示的逻辑宽度值

Default Value:
  • 2000

static graph3dViewPannable :boolean

Graph3dView组件是否允许按Shift键进行手抓图平移

Default Value:
  • true

static graph3dViewPickerResolution :number

当前 Picker 的绘制精度

Default Value:
  • 0.5

static graph3dViewRectSelectable :boolean

Graph3dView组件是否允许框选

Default Value:
  • true

static graph3dViewRectSelectBackground :string

Graph3dView组件框选背景

Default Value:
  • rgba(0,0,0,0.35)

static graph3dViewResettable :boolean

Graph3dView组件是否允许按空格键复位,复位调用了Graph3dView#reset()函数,该函数会重置Graph3dView的eye|center|up三个参数

Default Value:
  • true

static graph3dViewRotatable :boolean

Graph3dView组件是否允许进行旋转中心或方位操作

Default Value:
  • true

static graph3dViewRotateMaxPhi :number

Graph3dView组件最大旋转度数

Default Value:
  • 3.141592653589793

static graph3dViewRotateMinPhi :number

Graph3dView组件最小旋转度数

Default Value:
  • 0

static graph3dViewRotateStep :number

Graph3dView组件键盘控制旋转的步进

Default Value:
  • 0.05235987755982988

static graph3dViewShadowBias :number

阴影 bias 偏移

Default Value:
  • -0.005

static graph3dViewShadowDegreeX :number

阴影 X 轴角度

Default Value:
  • 30

static graph3dViewShadowDegreeZ :number

阴影 Y 轴角度

Default Value:
  • 30

static graph3dViewShadowDisabled :boolean

是否关闭阴影效果

Default Value:
  • true

static graph3dViewShadowIntensity :number

阴影强度

Default Value:
  • 0.3

static graph3dViewShadowQuality :string

阴影质量 low:低,medium:中,high:高,ultra:极高

Default Value:
  • high

static graph3dViewShadowRadius :number

阴影柔化半径

Default Value:
  • 0.1

static graph3dViewShadowType :string

阴影柔化类型 none:无,hard:硬,软:soft

Default Value:
  • hard

static graph3dViewSortable :boolean

Graph3dView组件是否允许透明排序

Default Value:
  • false

static graph3dViewTransmissionEnabled :boolean

是否允许透射材质

Since:
  • 7.7.1
Default Value:
  • true

static graph3dViewUp :Array.<number>

Graph3dView组件投影呈现时,摄像镜头垂直朝上方向

Default Value:
  • [0,1,-1e-7]

static graph3dViewUvClipEnabled :boolean

是否开启 UV 裁切使能

Default Value:
  • false

static graph3dViewWalkable :boolean

Graph3dView组件是否允许前进后退操作

Default Value:
  • true

static graph3dViewZoomable :boolean

Graph3dView组件是否允许缩放

Default Value:
  • true

static graphViewAutoScrollZone :number

GraphView组件中拖动图元到边缘时会自动滚动,该参数决定开始自动滚动的区域范围,设置为0或负数则代表关闭自动滚动功能

Default Value:
  • 16

static graphViewEditPointBackground :string

GraphView组件编辑点背景颜色

Default Value:
  • #D9D9D9

static graphViewEditPointBorderColor :string

GraphView组件编辑点边框颜色

Default Value:
  • #2C3E50

static graphViewEditPointSize :number

GraphView组件编辑点大小

Default Value:
  • 7

static graphViewPannable :boolean

决定GraphView组件是否允许手抓图操作

Default Value:
  • true

static graphViewRectSelectable :boolean

决定GraphView组件是否允许按Ctrl键进行框选操作

Default Value:
  • true

static graphViewRectSelectBackground :string

GraphView组件框选背景颜色

Default Value:
  • rgba(0,0,0,0.35)

static graphViewRectSelectBorderColor :string

GraphView组件框选边框颜色

Default Value:
  • #2C3E50

static graphViewResettable :boolean

决定GraphView组件按空格键是否允许复位,复位调用了GraphView#reset()函数,该函数默认会调用setZoom(1)和setTranslate(0, 0)

Default Value:
  • true

static graphViewScrollBarVisible :boolean

决定GraphView组件是否显示滚动条

Default Value:
  • true

static graphViewZoomable :boolean

GraphView组件是否允许缩放

Default Value:
  • true

static handleImageLoaded :function

图片在加载之后的回调函数

Example
ht.Default.handleImageLoaded = function(name, img) {

}

static handleModelLoaded :function

模型在加载之后的回调函数

Example
ht.Default.handleModelLoaded = function(name, img) {

}

static handleUnfoundImage :function

无法加载图片资源时会调用该函数,默认返回空,可自定义返回一个默认的图片

Example
ht.Default.handleUnfoundImage = function(name, url) {

}

static handleUnfoundModel :function

无法加载模型资源时会调用该函数,默认为空,可自定义返回一个默认的模型

Example
ht.Default.handleUnfoundModel = function(name, url) {
  return ht.Default.createBoxModel();
}

static hitMaxArea :number

进行框选判断时为了避免内存占用过大,HT会根据最大面积限制进行缩放判断,该参数一般无需改动

Default Value:
  • 3000

static hoverDelay :number

悬停延迟,默认 600

static imageCacheThreshold :number

图像缓存阈值

Default Value:
  • 20

static imageGradient :string

默认图片的渐进色类型

Default Value:
  • linear.northeast

static isTouchable :boolean

判断是否为触屏可 Touch 方式交互,HT系统一般会自动判断,对于极少数HT无法正确识别的系统下,可以通过配置强制指定

static labelColor :string

默认文字颜色

Default Value:
  • #000

static labelFont :string

默认文字字体

Default Value:
  • 12px arial, sans-serif

static labelSelectColor :string

选中状态下文字颜色

Default Value:
  • #fff

static lineCap :string

线条末端线帽的样式,可选值为butt|round|square

Default Value:
  • butt

static lineJoin :string

当两条线交汇时创建边角的类型,可选参数为:bevel|round|miter

Default Value:
  • round

static listViewLabelColor :string

列表组件文字颜色

Default Value:
  • #000

static listViewLabelFont :string

列表组件文字字体

Default Value:
  • 12px arial, sans-serif

static listViewLabelSelectColor :string

列表组件文字选中颜色

Default Value:
  • #FFF

static listViewRowLineColor :string

列表组件行线颜色

Default Value:
  • #D9D9D9

static listViewRowLineVisible :boolean

列表组件行线是否可见

Default Value:
  • false

static listViewSelectBackground :string

列表组件选中背景色

Default Value:
  • #1ABC9C

static mockTouch :boolean

是否开启 Touch 支持,默认为开启状态

Default Value:
  • true

static NumberDigits :number

number 序列化时,数值类型数据的最大精度值,默认是 5

Default Value:
  • 5

static numberListener :function

数字类型监听器,该监听器将使得input文本输入框只允许输入数学相关字符

Example
NumberListener: (function(){
     var map = {
         46: 1,
         8: 1,
         9: 1,
         27: 1,
         13: 1,
         109: 1,
         110: 1,
         189: 1,
         190: 1
     };
     return function(e){
         var keyCode = e.keyCode;
         if(map[keyCode] || (keyCode === 65 && ht.Default.isCtrlDown(e)) || (keyCode >= 35 && keyCode <= 39)){
             return;
         }
         if ((e.shiftKey || (keyCode < 48 || keyCode > 57)) && (keyCode < 96 || keyCode > 105)) {
             e.preventDefault();
         }
     };
 })()

static paletteContentBackground :string

指定调色板内容区域的背景色

static paletteContentLabelColor :string

指定调色板内容区域的文字颜色

static paletteContentLabelFont :string

指定调色板内容区域的文字字

static paletteItemHoverBorderColor :string

指定鼠标划过按钮元素时的边框颜色,默认为Color.highlight

static paletteItemSelectBackground :string

指定被选中的按钮元素的背景色,默认为Color.highlight

static paletteSeparatorColor :string

指定标题栏分割线的颜色,默认为undefined

static paletteSeparatorWidth :number

指定标题栏分割线的宽度,默认为1

static paletteTitleBackground :string

指定调色板标题栏的背景色,默认为Color.titleBackground

static paletteTitleHeight :number

指定调色板标题栏的高度,默认为Default.widgetTitleHeight

static paletteTitleHoverBackground :string

指定鼠标划过调色板标题栏时的背景色,默认为Color.titleBackground

static paletteTitleLabelColor :string

指定调色板标题栏的文字颜色,默认为Default.labelSelectColor

static paletteTitleLabelFont :string

指定调色板标题栏的文字字体,默认为Default.labelFont

static pinchZoomIncrement :number

默认双指触屏Touch方式缩放步进

Default Value:
  • 1.08

static pinchZoomThreshold :number

默认双指触屏Touch方式缩放阈值

Default Value:
  • 1

static propertyViewBackground :string

属性组件背景

Default Value:
  • #ECF0F1

static propertyViewCollapseIcon :string

属性组件合并图标

static propertyViewColumnLineColor :string

属性组件列线颜色

Default Value:
  • #D9D9D9

static propertyViewColumnLineVisible :boolean

属性组件列线是否可见

Default Value:
  • true

static propertyViewExpandIcon :string

属性组件展开图标

static propertyViewLabelColor :string

属性组件文字颜色

Default Value:
  • #000

static propertyViewLabelFont :string

属性组件文字字体

Default Value:
  • 12px arial, sans-serif

static propertyViewLabelSelectColor :string

属性组件文字选中颜色

Default Value:
  • #FFF

static propertyViewRowLineColor :string

属性组件行线颜色

Default Value:
  • #D9D9D9

static propertyViewRowLineVisible :boolean

属性组件行线是否可见

Default Value:
  • true

static propertyViewSelectBackground :string

属性组件选中背景色

Default Value:
  • #1ABC9C

static reinvalidateCount :number

组件初次加载时界面宽高值可能会为0,HT会自动尝试等待下次延迟刷新,该参数指定尝试次数,一般无需改动

Default Value:
  • 3

static scrollBarColor :string

滚动条默认颜色

Default Value:
  • rgba(0,0,0,0.35)

static scrollBarInteractiveSize :number

滚动条起作用区域默认大小

Default Value:
  • 16

static scrollBarMinLength :number

滚动条默认最小长度

Default Value:
  • 20

static scrollBarSize :number

滚动条默认宽度

Default Value:
  • 7

static scrollBarTimeout :number

滚动条默认的隐藏间隔毫秒数

Default Value:
  • 1000

static scrollZoomIncrement :number

默认滚轮缩放步进

Default Value:
  • 1.05

static segmentResolution :number

默认曲线分段微分数

Default Value:
  • 12

static shapeResolution :number

默认模型分段微分数

Default Value:
  • 24

static shapeSide :number

默认模型边数

Default Value:
  • 24

static sortFunc :function

默认排序函数

Example
ht.Default.sortFunc = function(v1, v2) { 

   }

static splitViewDividerBackground :string

分割组件分隔条背景

Default Value:
  • #2C3E50

static splitViewDividerSize :number

分割组件分隔条宽度

Default Value:
  • 1

static splitViewDragOpacity :number

分割组件分隔条拖拽过程透明度

Default Value:
  • 0.5

static splitViewToggleIcon :string

分割组件展开合并图标

static tableHeaderBackground :string

表头组件背景

Default Value:
  • #ECF0F1

static tableHeaderColumnLineColor :string

表头组件列线颜色

Default Value:
  • #D9D9D9

static tableHeaderColumnLineVisible :boolean

表头组件列线是否可见

Default Value:
  • true

static tableHeaderInsertColor :string

表头组件插入状态颜色

Default Value:
  • #1ABC9C

static tableHeaderLabelColor :string

表头组件文字颜色

Default Value:
  • #000

static tableHeaderLabelFont :string

表头组件文字字体

Default Value:
  • 12px arial, sans-serif

static tableHeaderMoveBackground :string

表头组件移动状态背景

Default Value:
  • rgba(0,0,0,0.35)

static tableHeaderSortAscIcon :string

表头组件升序图标

static tableHeaderSortDescIcon :string

表头组件降序图标

static tableViewColumnLineColor :string

表格组件列线颜色

Default Value:
  • #D9D9D9

static tableViewColumnLineVisible :boolean

表格组件列线是否可见

Default Value:
  • true

static tableViewLabelColor :string

表格组件文字颜色

Default Value:
  • #000

static tableViewLabelFont :string

表格组件文字字体

Default Value:
  • 12px arial, sans-serif

static tableViewLabelSelectColor :string

表格组件文字选中颜色

Default Value:
  • #FFF

static tableViewRowLineColor :string

表格组件行线颜色

Default Value:
  • #D9D9D9

static tableViewRowLineVisible :boolean

表格组件行线是否可见

Default Value:
  • true

static tableViewSelectBackground :string

表格组件选中背景色

Default Value:
  • #1ABC9C

static tabViewInsertColor :string

页签组件插入状态颜色

Default Value:
  • #1ABC9C

static tabViewLabelColor :string

页签组件文字颜色

Default Value:
  • #FFF

static tabViewLabelFont :string

页签组件文字字体

Default Value:
  • 12px arial, sans-serif

static tabViewMoveBackground :string

页签组件移动状态背景

Default Value:
  • rgba(0,0,0,0.35)

static tabViewSelectBackground :string

页签组件选中背景

Default Value:
  • #1ABC9C

static tabViewSelectWidth :number

页签组件选中宽度

Default Value:
  • 3

static tabViewTabBackground :string

页签组件背景

Default Value:
  • #2C3E50

static tabViewTabGap :number

页签组件间距

Default Value:
  • 1

static textExtraWidth :number

默认文本节点 ht.Text 额外宽度

Default Value:
  • 4

static toolbarBackground :string

工具条组件背景

Default Value:
  • #ECF0F1

static toolbarItemGap :number

工具条组件Item的间距

Default Value:
  • 8

static toolbarLabelColor :string

工具条组件文字颜色

Default Value:
  • #000

static toolbarLabelFont :string

工具条组件文字字体

Default Value:
  • 12px arial, sans-serif

static toolbarLabelSelectColor :string

工具条组件文字选中颜色

Default Value:
  • #FFF

static toolbarSelectBackground :string

工具条组件选中背景色

Default Value:
  • #1ABC9C

static toolbarSeparatorColor :string

工具条组件的分隔条颜色

Default Value:
  • #868686

static toolTipBackground :string

ToolTip的背景颜色

Default Value:
  • #FFFFE0

static toolTipBorderRadius :string

ToolTip的边框弧度

Default Value:
  • 4px

static toolTipContinual :boolean

组件的ToolTip显示的情况下,如果鼠标移动到新的位置时,ToolTip是否实时持续跟进

Default Value:
  • false

static toolTipDelay :number

组件的ToolTip显示的延迟间隔

Default Value:
  • 800

static toolTipLabelColor :string

ToolTip的文字颜色

Default Value:
  • #000

static toolTipLabelFont :string

ToolTip的文字字体

Default Value:
  • 12px arial, sans-serif

static toolTipShadowColor :string

ToolTip的阴影颜色

Default Value:
  • rgba(0,0,0,0.35)

static touchMoveThreshold :number

默认触摸移动阈值

Default Value:
  • 20

static treeTableViewCollapseIcon :string

树表格组件关闭状态图标

static treeTableViewColumnLineColor :string

树表格组件列线颜色

Default Value:
  • #D9D9D9

static treeTableViewColumnLineVisible :boolean

树表格组件列线是否可见

Default Value:
  • true

static treeTableViewExpandIcon :string

树表格组件展开状态图标

static treeTableViewLabelColor :string

树表组件文字颜色

Default Value:
  • #000

static treeTableViewLabelFont :string

树表组件文字字体

Default Value:
  • 12px arial, sans-serif

static treeTableViewLabelSelectColor :string

树表组件文字选中颜色

Default Value:
  • #FFF

static treeTableViewRowLineColor :string

树表格组件行线颜色

Default Value:
  • #D9D9D9

static treeTableViewRowLineVisible :boolean

树表格组件行线是否可见

Default Value:
  • true

static treeTableViewSelectBackground :string

树表组件选中背景色

Default Value:
  • #1ABC9C

static treeViewCollapseIcon :string

树组件关闭状态图标

static treeViewExpandIcon :string

树组件展开状态图标

static treeViewLabelColor :string

树组件文字颜色

Default Value:
  • #000

static treeViewLabelFont :string

树组件文字字体

Default Value:
  • 12px arial, sans-serif

static treeViewLabelSelectColor :string

树组件文字选中颜色

Default Value:
  • #FFF

static treeViewRowLineColor :string

树组件行线颜色

Default Value:
  • #D9D9D9

static treeViewRowLineVisible :boolean

树组件行线是否可见

Default Value:
  • false

static treeViewSelectBackground :string

树组件选中背景色

Default Value:
  • #1ABC9C

static widgetHeaderHeight :number

通用组件抬头高度,例如TabView,TableHeader和Toolbar等的头部高度

Default Value:
  • 22

static widgetIndent :number

通用组件缩进,例如树组件每一层的缩进

Default Value:
  • 20

static widgetRowHeight :number

通用组件行高,例如表格每行行高

Default Value:
  • 20

static widgetTitleHeight :number

AccordionView和TabView等组件的Title默认高度

Default Value:
  • 24

static zoomIncrement :number

默认缩放步进

Default Value:
  • 1.3

static zoomMax :number

默认最大缩放倍数

Default Value:
  • 20

static zoomMin :number

默认最小缩放倍数

Default Value:
  • 0.01

Methods

static addFontFace(name, fontList, callback, remove) → {void}

添加附加字体

Parameters:
Name Type Attributes Description
name string

名称

fontList Array.<string>

附加字体列表

callback function <optional>

增加回调

remove boolean <optional>

是否移除同名字体

Returns:
void

static addMethod(clazz, o, keepExist) → {any}

向类中添加方法或属性值

Parameters:
Name Type Description
clazz any

o Object

要添加的属性或者方法

keepExist boolean

同名情况是否覆盖已存在

Returns:
any

static alert(content, title, buttons, contentIcon, contentInput, fixedWidth) → {ht.ui.Alert}

创建并显示 Alert

Parameters:
Name Type Attributes Description
content string | object <optional>

消息内容或是配置对象

title string <optional>

消息标题(如果不指定或为空,则图标以小图标的形式显示)

buttons Array.<object> <optional>

按钮数组,与 Dialog 的 buttons 属性格式一致

contentIcon string | object <optional>

图标名称,常用的内置图标:ui_info、ui_warn、ui_error, ui_success

contentInput ht.ui.TextField | ht.ui.MultiSelect <optional>

输入组件,比如一个文本框

fixedWidth number <optional>

消息组件的固定宽度,可以传入数字表示像素宽度,也可以传入 null 表示宽度根据内容自适应

Returns:
ht.ui.Alert -

Alert 组件实例

static animate(DOM) → {Animate}

创建动画

Parameters:
Name Type Description
DOM string | HTMLDivElement

可以是 css 选择器,也可以是 DOM 元素

Requires:
  • module:ht-cssanimation.js
Returns:
Animate

static appendChild(parent, div, position) → {void}

在父节点中追加子节点

Parameters:
Name Type Attributes Description
parent HTMLElement

父节点

div HTMLElement

子节点

position boolean <optional>

子节点的 position 是否为 absolute

Returns:
void

static appendToScreen(view) → {void}

将指定视图对象或 dom 加入到 body 下,如果全屏时,则加入到全屏节点下

Parameters:
Name Type Description
view Object | Element
Returns:
void

static beforeLoadURL(url) → {string}

加载资源地址之前会调用,在这个方法里回去调用 ht.Default.convertURL 去处理 url 地址

Parameters:
Name Type Description
url string

资源地址

Returns:
string -

返回处理过的 url 地址

static brighter(color, factor) → {string}

返回比color更亮的颜色

Parameters:
Name Type Attributes Description
color string

原始颜色

factor number <optional>

变化因子,默认为40,允许值0~100

Returns:
string -

新的颜色

Example
var newColor = brighter('#f00');

static calculateClosestPoint(points, segments, point) → {object}

获取离 point 最近的点

Parameters:
Name Type Description
points ht.List

点集合

segments ht.List

线段类型集合

point object

格式 {x: 72.5, y: 145}

Requires:
  • module:ht-flow.js
Returns:
object -

点信息

static calculateClosestPointOnLine(p1, p2, p) → {object}

Parameters:
Name Type Description
p1 object
p2 object
p object
Requires:
  • module:ht-flow.js
Returns:
object

static calculateLength(points, segments) → {number}

计算长度

Parameters:
Name Type Description
points ht.List

点集合

segments ht.List

线段类型集合

Requires:
  • module:ht-flow.js
Returns:
number -

长度

static calculatePointLength(points, segments, point, tolerance) → {number}

获取点所在长度

Parameters:
Name Type Attributes Description
points ht.List

点集合

segments ht.List

线段类型集合

point object

格式 {x: 72.5, y: 145}

tolerance number <optional>
Requires:
  • module:ht-flow.js
Returns:
number

static callLater(func, scope, args, delay) → {any}

获取全局下一个id编号

Parameters:
Name Type Attributes Description
func function

回调函数

scope any <optional>

函数域

args Array.<any> <optional>

函数参数列表

delay number <optional>

延迟时间(毫秒)

Returns:
any

static cancelLater(id, timeout) → {void}

清除动画 clearTimeout 或者 cancelAnimationFrame

Parameters:
Name Type Attributes Description
id number
timeout boolean <optional>

是否为 Timeout

Returns:
void

static clearFontFace() → {void}

清空所有附加字体

Returns:
void

static clone(obj) → {any}

传入一个对象参数,以浅拷贝的方式返回一个新的复制对象

Parameters:
Name Type Description
obj any

要复制的对象

Returns:
any -

新复制的对象

static containedInView(event, view) → {boolean}

判断交互事件所处位置是否在View组件之上,一般用于Drog And Drop的拖拽操作判断

Parameters:
Name Type Description
event Event

事件对象

view Object

视图对象

Returns:
boolean

static containsPoint(rect, point) → {boolean}

判断point是否包含在rect的矩形区域里

Parameters:
Name Type Description
rect Rect

矩形

point Point

Returns:
boolean -

矩形是否包含点

Example
containsPoint({x: 0, y: 0, width: 100, height: 100}, {x: 50, y: 50});//true

static containsRect(rect1, rect2) → {boolean}

判断矩形区域rect1是否包含矩形区域rect2

Parameters:
Name Type Description
rect1 Rect

矩形1

rect2 Rect

矩形2

Returns:
boolean -

矩形1是否包含矩形2

Example
containsRect({x: 0, y: 0, width: 100, height: 100}, {x: 0, y: 0, width: 10, height: 10});//true

static convertImageSrc(url, cb) → {void}

自定义图片加载,请求图片资源的时候,需要加请求头等可以重载该方法

Parameters:
Name Type Description
url string

图片地址

cb function
Returns:
void

static convertURL(url) → {string}

转换路径

Parameters:
Name Type Description
url string
Returns:
string

static createBoxModel() → {Object}

构建六面体模型,该模型的六个面显示的颜色和贴图都将一样

Returns:
Object -

六面体模型

static createCanvas(parent, pointerEvents) → {HTMLCanvasElement}

创建一个 Canvas 的 DOM对象

Parameters:
Name Type Attributes Description
parent HTMLElement <optional>

父节点,创建的节点 append 到这个节点下

pointerEvents boolean <optional>
Returns:
HTMLCanvasElement

static createConeModel(side, sideFrom, sideTo, from, to, bottom) → {Object}

构建圆锥体模型

Parameters:
Name Type Description
side number

总边数

sideFrom number

起始边索引

sideTo number

结束边索引

from number | boolean

是否有起始面

to number | boolean

是否有结束面

bottom number | boolean

是否有底部

Returns:
Object -

圆锥体模型

static createCylinderModel(side, sideFrom, sideTo, from, to, top, bottom) → {Object}

构建圆柱体模型

Parameters:
Name Type Description
side number

总边数

sideFrom number

起始边索引

sideTo number | boolean

结束边索引

from number | boolean

是否有起始面

to number | boolean

是否有结束面

top number | boolean

是否有顶部

bottom number | boolean

是否有底部

Returns:
Object -

圆柱体模型

static createDisabledDiv(image, bubbles) → {HTMLDivElement}

创建一个灰色背景 Div

Parameters:
Name Type Attributes Description
image URL <optional>

图片地址

bubbles boolean <optional>

是否阻止冒泡

Returns:
HTMLDivElement

static createDiv(hidden, parent) → {HTMLDivElement}

创建一个 div

Parameters:
Name Type Attributes Description
hidden boolean <optional>

超出是否隐藏,即 style.overflow 是否为 hidden

parent HTMLElement <optional>

父级 dom

Returns:
HTMLDivElement

static createElement(tagName, borderColor, font, value) → {Element}

创建DOM对象

Parameters:
Name Type Attributes Description
tagName string

DOM类型(如div、a、span等)

borderColor string <optional>

边框颜色

font string <optional>

字体

value string <optional>

内容

Returns:
Element -

DOM对象

static createExtrusionModel(array, segments, top, bottom, resolution, repeatUVLength, tall, elevation) → {Object}

根据xz平面多边形,挤压形成3D模型

Parameters:
Name Type Description
array Array.<number>

定义xz平面的所有点坐标,格式为:[x1, z1, x2, z2, ...]

segments Array.<Object>

定义点连接样式,数组元素为整型值,为空则代表所有点连成直线

top number

是否有顶部

bottom number

是否有底部

resolution number

微分段数

repeatUVLength number

默认为空,设置值后顶部和底部的贴图将根据制定长度值进行重复

tall number

模型高度,默认为 0.5

elevation number

模型中心的 y 轴位置,默认值为 0

Returns:
Object

static createFrameModel(dx, dy, dz, params) → {object}

构建框架体模型

Parameters:
Name Type Description
dx number

x轴框厚度,默认值为0.07

dy number

y轴框厚度,默认值为0.07

dz number

z轴框厚度,默认值为0.07

params FrameParams

为JSON结构对象参数

Requires:
  • module:ht-modeling.js
Returns:
object

static createGradient(g, type, background, gradientColor, x, y, w, h) → {CanvasGradient}

在指定区域,创建一个渐进色

Parameters:
Name Type Description
g CanvasRenderingContext2D

画笔对象

type string

渐进类型,可取值:'linear.southwest','linear.southeast','linear.northwest','linear.northeast', 'linear.north','linear.south','linear.west','linear.east', 'radial.center','radial.southwest','radial.southeast','radial.northwest','radial.northeast', 'radial.north','radial.south','radial.west','radial.east', 'spread.horizontal','spread.vertical','spread.diagonal','spread.antidiagonal', 'spread.north','spread.south','spread.west','spread.east'

background string

背景色

gradientColor string

渐进色

x number

绘制开始的x坐标

y number

绘制开始的y坐标

w number

绘制的宽度

h number

绘制的高度

Returns:
CanvasGradient

static createGradientImage(size, colors, colorStopList, rotation) → {HTMLCanvasElement}

创建一个渐变图像,返回 canvas

Parameters:
Name Type Attributes Description
size number

图像宽高

colors Array.<string>

颜色数组

colorStopList Array.<number>

颜色停止点,需要跟颜色数组对应

rotation number <optional>

旋转角度

Returns:
HTMLCanvasElement
Example
ht.Default.createGradientImage(100, ['#fff', '#000'],  [0, 1], 0.5)

static createMatrix(array, matrix) → {Object}

将一组JSON描述的缩放、移动和旋转等操作转换成对应的变化矩阵

Parameters:
Name Type Description
array Array.<number>
matrix Object
Returns:
Object

static createParallelogramModel(top, bottom) → {Object}

构建平行四边形体模型

Parameters:
Name Type Description
top boolean

是否有顶部

bottom boolean

是否有底部

Returns:
Object -

平行四边形体模型

static createRectModel(top, bottom) → {Object}

构建矩形体模型

Parameters:
Name Type Description
top boolean

是否有顶部

bottom boolean

是否有底部

Returns:
Object -

矩形体模型

static createRightTriangleModel(top, bottom) → {Object}

构建直角三角形体模型

Parameters:
Name Type Description
top boolean

是否有顶部

bottom boolean

是否有底部

Returns:
Object -

直角三角形体模型

static createRingModel(array, segments, resolution, top, bottom, side, sideFrom, sideTo, from, to) → {Object}

根据xy平面的曲线,环绕一周形成3D模型

Parameters:
Name Type Description
array Array.<number>

定义xy平面的所有点坐标,格式为:[x1, y1, x2, y2, ...]

segments Array.<Object>

定义点连接样式,数组元素为整型值,为空则代表所有点连成直线

resolution number

曲线微分段数

top number

是否有顶部

bottom number

是否有底部

side number

总边数

sideFrom number

起始边索引

sideTo number

结束边索引

from number

是否有起始面

to number

是否有结束面

Returns:
Object

static createRoundRectModel(top, bottom) → {Object}

构建圆角矩形体模型

Parameters:
Name Type Description
top boolean

是否有顶部

bottom boolean

是否有底部

Returns:
Object -

圆角矩形体模型

static createSmoothConeModel(bottom, resolution, start, arc, radius) → {Object}

构建光滑圆锥体模型

Parameters:
Name Type Description
bottom number

是否有底部

resolution number

微分段数

start number

起始角度,默认为 0

arc number

总弧度,默认为 Math.PI * 2

radius number

底部半径,默认为 0.5

Returns:
Object -

光滑圆锥体模型

static createSmoothCylinderModel(resolution, top, bottom, topRadius, bottomRadius, start, arc, height) → {Object}

构建光滑圆柱体模型

Parameters:
Name Type Description
resolution number

圆柱微分段数

top number

是否有顶部

bottom number

是否有底部

topRadius number

顶部半径,默认为 0.5

bottomRadius number

底部半径,默认为 0.5

start number

起始角度,默认为 0

arc number

总弧度,默认为 Math.PI * 2

height number

圆柱高度,默认为 1

Returns:
Object -

光滑圆柱体模型

static createSmoothRingModel(array, segments, vResolution, start, arc, hResolution) → {Object}

根据xy平面的曲线,环绕一周形成光滑3D模型

Parameters:
Name Type Description
array Array.<number>

定义 xy 平面的所有点坐标,格式为:[x1, y1, x2, y2, ...]

segments Array.<Object>

定义点连接样式,数组元素为整型值,为空则代表所有点连成直线

vResolution number

曲线微分段数

start number

起始角度,默认为 0

arc number

总弧度,默认为 Math.PI*2

hResolution number

水平环绕微分段数

Returns:
Object

static createSmoothSphereModel(hResolution, vResolution, hStart, hArc, vStart, vArc, radius) → {Object}

构建光滑球体模型

Parameters:
Name Type Attributes Description
hResolution number <optional>

水平方向微分段数

vResolution number <optional>

垂直方向微分段数

hStart number <optional>

水平方向起始角度,默认为 0

hArc number <optional>

水平方向总弧度,默认为 Math.PI * 2

vStart number <optional>

垂直方向起始角度,默认为 0

vArc number <optional>

垂直方向总弧度,默认为 Math.PI

radius number <optional>

球体半径,默认为 0.5

Returns:
Object -

光滑球体模型

static createSmoothTorusModel(radius, tubeRadius, hResolution, vResolution, start, arc) → {Object}

构建光滑圆环体模型

Parameters:
Name Type Description
radius number

圆环半径位置

tubeRadius number

截面圆形半径大小

hResolution number

圆环水平方向微分段数

vResolution number

截面圆形微分段数

start number

起始角度,默认为0

arc number

总弧度,默认为Math.PI*2

Returns:
Object -

光滑圆环体模型

static createSphereModel(side, sideFrom, sideTo, from, to, resolution) → {Object}

构建球体模型

Parameters:
Name Type Description
side number
sideFrom number
sideTo number
from number
to number
resolution number
Returns:
Object

static createStarModel(top, bottom) → {Object}

构建星形体模型

Parameters:
Name Type Description
top boolean

是否有顶部

bottom boolean

是否有底部

Returns:
Object -

星形体模型

static createTorusModel(side, sideFrom, sideTo, from, to, radius, resolution) → {Object}

构建圆环体模型

Parameters:
Name Type Description
side number

总边数

sideFrom number

起始边索引

sideTo number

结束边索引

from number

是否有起始面

to number

是否有结束面

radius number

圆环的管半径,默认值为0.17,可取值范围0~2.5

resolution number

截面圆形微分段数

Returns:
Object -

圆环体模型

static createTrapezoidModel(top, bottom) → {Object}

构建梯形体模型

Parameters:
Name Type Description
top boolean

是否有顶部

bottom boolean

是否有底部

Returns:
Object -

梯形体模型

static createTriangleModel(top, bottom) → {Object}

构建三角形体模型

Parameters:
Name Type Description
top boolean

是否有顶部

bottom boolean

是否有底部

Returns:
Object -

三角形体模型

static createView(hidden) → {HTMLDivElement}

创建一个 div

Parameters:
Name Type Attributes Description
hidden boolean <optional>

超出是否隐藏,即 style.overflow 是否为 hidden

Returns:
HTMLDivElement

static darker(color, factor) → {string}

返回比color更暗的颜色

Parameters:
Name Type Attributes Description
color string

原始颜色

factor number <optional>

变化因子,默认为40,允许值0~100

Returns:
string -

新的颜色

Example
var newColor = darker('#f00');

static decodeString(str) → {string}

字符串解码

Parameters:
Name Type Description
str string

字符串

Returns:
string

static def(className, superClass, methods) → {void}

定义类

Parameters:
Name Type Description
className string | Object

类名,如果为字符串,自动注册到HT的classMap中,一般使用函数(构造函数)即可

superClass Object

要继承的父类

methods Object

方法和变量声明

Returns:
void
Example
function MyData() {
	   MyData.superClass.constructor.call(this);
}
ht.Default.def(MyData, Data, {
	   sayHello: function() {
		    console.log('hello');
	   }
});

static doConnectAction(view, node1, node2) → {boolean}

执行连接动作操作

Parameters:
Name Type Description
view ht.graph.GraphView

view 视图

node1 ht.Node

节点

node2 ht.Node

目标节点

Returns:
boolean

static drawBorder(g, borderColor, x, y, width, height, borderWidth) → {void}

Parameters:
Name Type Description
g CanvasRenderingContext2D

画笔对象

borderColor string
x number

矩形左上角x坐标

y number

矩形左上角y坐标

width number

矩形宽度

height number

矩形高度

borderWidth number

边框宽度

Returns:
void

static drawBreakableText(g, lines, rect, font, color, align, decoration, letterGap, strokeWidth, strokeColor) → {void}

绘制文字

Parameters:
Name Type Attributes Description
g CanvasRenderingContext2D

画笔对象

lines Array.<string>

字符串数组

rect Rect

区域

font string

文字字体

color string

文字颜色

align center | left | right

文字水平对齐方式,可选值为left|center|right

decoration underline | overline | strikethrough <optional>

文字修饰方式,可选值为underline|overline|strikethrough

letterGap number <optional>

文字字符间距

strokeWidth number <optional>

文字描边宽度

strokeColor string <optional>

文字描边颜色

Returns:
void
Since:
  • 7.7.3

static drawCenterImage(g, img, x, y, data, view, color) → {void}

以x,y为中心绘制img图片

Parameters:
Name Type Attributes Description
g CanvasRenderingContext2D

画笔对象

img Object | HTMLCanvasElement | HTMLImageElement

要绘制的图片(img对象、canvas对象或矢量对象)

x number

中心点x坐标

y number

中心点y坐标

data ht.Data <optional>

要绑定的Data对象

view Object <optional>

要绑定的视图对象

color string <optional>

染色

Returns:
void

static drawImage(g, image, x, y, width, height, data, view, blendColor) → {void}

绘制图片

Parameters:
Name Type Attributes Description
g CanvasRenderingContext2D

画笔对象

image Object | HTMLCanvasElement | HTMLImageElement

要绘制的图片(img对象、canvas对象或矢量对象)

x number

绘制范围左上角x坐标

y number

绘制范围左上角y坐标

width number

绘制范围宽度

height number

绘制范围高度

data ht.Data <optional>

要绑定的Data对象

view Object <optional>

要绑定的视图对象

blendColor string <optional>

染色

Returns:
void

static drawPoints(g, points, segments, closePath) → {void}

Parameters:
Name Type Attributes Description
g CanvasRenderingContext2D

画笔

points Array.<Point>

顶点信息

segments Array.<number> <optional>

线段信息

closePath boolean <optional>

是否闭合

Returns:
void

static drawRoundRect(g, x, y, width, height, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius) → {void}

Parameters:
Name Type Attributes Description
g CanvasRenderingContext2D

画笔对象

x number

绘制开始的x坐标

y number

绘制开始的y坐标

width number

绘制的宽度

height number

绘制的高度

topLeftRadius number <optional>

左上角圆角半径,如果后面三个参数为空,表示4个圆角的半径

topRightRadius number <optional>

右上角圆角半径

bottomLeftRadius number <optional>

左下角圆角半径

bottomRightRadius number <optional>

右下角圆角半径

Returns:
void

static drawStretchImage(g, img, stretch, x, y, w, h, data, view, color, clip, blendMode) → {void}

在矩形位置内绘制图片

Parameters:
Name Type Attributes Description
g CanvasRenderingContext2D

画笔对象

img object | HTMLCanvasElement | HTMLImageElement

要绘制的图片(img对象、canvas对象或矢量对象)

stretch string

拉伸类型(uniform/centerUniform/fill),7.7.0 后增加(cover/center)

x number

矩形左上角x坐标

y number

矩形左上角y坐标

w number

矩形宽度

h number

矩形高度

data ht.Data <optional>

要绑定的Data对象

view ht.graph3d.Graph3dView | ht.graph.GraphView <optional>

要绑定的视图对象

color string <optional>

染色

clip boolean <optional>

是否裁切

blendMode multiply | override | override_rgb | override_a <optional>

染色模式

Returns:
void

static drawText(g, value, font, color, x, y, width, height, align, vAlign, decoration) → {void}

绘制文字

Parameters:
Name Type Attributes Description
g CanvasRenderingContext2D

画笔对象

value string

文字内容

font string

文字字体

color string

文字颜色

x number

绘制开始的x坐标

y number

绘制开始的y坐标

width number

绘制的宽度

height number

绘制的高度

align center | left | right <optional>

文字水平对齐方式,可选值为left|center|right

vAlign top | bottom | middle <optional>

文字垂直对齐方式,可选值为top|middle|bottom

decoration underline | overline | strikethrough <optional>

文字修饰方式,可选值为underline|overline|strikethrough

Returns:
void
Example
function drawText(g, 'Hello, HT', '12px Arial', 'red', 0, 0, 200, 100, 'center', 'middle');

static encodeString(str) → {string}

字符串编码

Parameters:
Name Type Description
str string

字符串

Returns:
string

static endsWith(string, ends) → {boolean}

判断一个字符串是否以指定字符串结尾,如果是则返回 true,否则返回 false

Parameters:
Name Type Description
string string

字符串

ends string

结尾字符串

Returns:
boolean
Since:
  • 7.7.3

static errorMessage(content, title, region, fixedWidth, duration) → {ht.ui.Message}

显示错误消息 showMessage 快捷方式,省略了 icon 参数

Parameters:
Name Type Attributes Description
content string <optional>
title string <optional>
region string <optional>
fixedWidth number <optional>
duration number <optional>
Returns:
ht.ui.Message

static extendClass(clazz, obj) → {void}

类继承

Parameters:
Name Type Description
clazz any

obj Object

被继承对象

Returns:
void
Example
class a { }
ht.Default.extendClass(a, {b: '1'})

static fetch(xhr, options) → {void}

发起获取资源的请求方法

Parameters:
Name Type Description
xhr any
options Object
Returns:
void

static findView(str) → {any}

获取当前视图

Parameters:
Name Type Attributes Description
str string <optional>

all:获取所有视图,2d: 获取2d视图,3d:获取3d视图

Returns:
any

static getBatchInfo(name) → {Object}

获取已注册的批量信息

Parameters:
Name Type Description
name string

批量名

Returns:
Object -

批量信息

static getBatchInfoMap() → {Object}

获取批量信息对象

Returns:
Object

static getClass(name) → {function}

传入全路径类字符串名称,返回类定义(构造函数)

Parameters:
Name Type Description
name string

类名

Returns:
function -

类定义(构造函数)

static getClassMap() → {Object}

返回所有HT预定义类的json结构信息,key为类全路径名,value为类声明(构造函数)

Returns:
Object -

类结构信息

static getClientPoint(e) → {Point}

返回client属性坐标

Parameters:
Name Type Description
e Event

事件对象

Returns:
Point -

client坐标对象

Example
//返回值示例:
{
   x: 100,
   y: 100
}

static getCommonEasing(easingName) → {function}

根据缓动名称获取缓动函数

Parameters:
Name Type Description
easingName string

缓动名称。格式如 'Linear'

Requires:
  • module:ht-animation.js
Returns:
function

static getCompType(type) → {function|Object}

获得注册的矢量组件类型

Parameters:
Name Type Description
type string

类型名称

Returns:
function | Object

static getCompTypeMap() → {Object}

获取所有已注册的组件

Returns:
Object

static getConnectAction(gv, actionType) → {any}

获取连接类型信息,若无 actionType 则返回 gv 正使用的连接动作

Parameters:
Name Type Attributes Description
gv ht.graph.GraphView
actionType string <optional>
Returns:
any

static getCurrentComp() → {Object}

返回当前矢量组件comp,即function compStack[0],一般用于矢量值绑定func动态调用时使用

Returns:
Object -

矢量组件comp

static getCurrentKeyCodeMap() → {Object}

返回当前键盘按键信息,key为键的keyCode,如果按下则值为true

Returns:
Object -

键盘按键信息

static getDistance(p1, p2) → {number}

获取两点之间距离,或向量长度

Parameters:
Name Type Description
p1 Object | Array.<number>

第一个点的坐标(格式:{x: x, y: y})或第一个向量(格式:[x, y, z])

p2 Object | Array.<number>

第二个点的坐标(格式:{x: x, y: y})或第二个向量(格式:[x, y, z])

Returns:
number -

距离

Example
//二维两点距离
var distance = getDistance({x: 0, y: 0}, {x: 10, y: 0});// distance equals 10
//三维两点距离
var distance3d = getDistance([0, 0, 0], [0, 10, 0]);// distance3d equals 10

static getEdgeType(type) → {function}

获取连线类型函数

Parameters:
Name Type Description
type string

连线类型名

Returns:
function -

连线类型函数

static getFontFaceMap() → {Object}

获取添加的所有附加字体

Returns:
Object

static getId() → {number}

获取全局下一个id编号

Returns:
number -

id

static getImage(name, color) → {HTMLImageElement|HTMLCanvasElement|Object}

获得已注册的图片

Parameters:
Name Type Attributes Description
name string

图片名

color string <optional>

染色

Returns:
HTMLImageElement | HTMLCanvasElement | Object -

返回已经注册的图片

static getImageMap() → {Object}

获得所有注册图片的信息对象

Returns:
Object -

已注册图片的映射表

static getInternal() → {Object}

获取内部所有方法

Returns:
Object

static getLineCacheInfo(points, segments, resolution) → {Array.<Object>}

获取管线信息缓存

Parameters:
Name Type Attributes Description
points Array.<any> | ht.List

点坐标数组

segments Array.<any> | ht.List

定义点连接样式,数组元素为整型值,为空则代表所有点连成直线

resolution number <optional>

曲线微分数,默认12

Returns:
Array.<Object>

static getLineLength(cache) → {number}

获取管线的长度

Parameters:
Name Type Description
cache any

线段信息,由 ht.Default.getLineCacheInfo 获取

Returns:
number

static getLineOffset(cache, offset) → {Object}

获取管线相对偏移的位置及朝向

Parameters:
Name Type Description
cache any

线段信息,由 ht.Default.getLineCacheInfo 获取

offset number

偏移,总长需通过 ht.Default.getLineLength 计算

Returns:
Object

static getLogicalPoint(e, view, translateX, translateY, zoomX, zoomY) → {Point}

获取交互点的逻辑坐标,使用视图对象上的此方法更为便捷

Parameters:
Name Type Description
e MouseEvent

事件对象

view Object

视图对象

translateX number

水平偏移

translateY number

垂直偏移

zoomX number

水平缩放

zoomY number

垂直缩放

Returns:
Point -

逻辑点坐标

static getMaterial(name) → {Object}

根据传入的名称获取 Material

Parameters:
Name Type Description
name string
Returns:
Object
Since:
  • 7.7.0

static getMaterialDefaultStyle() → {Object}

获得材质默认支持类型

Returns:
Object
Since:
  • 7.7.0

static getMaterialMap() → {Object}

获取所有已注册的 Material

Returns:
Object
Since:
  • 7.7.0

static getMesh(name) → {Object}

根据传入的名称获取 Mesh

Parameters:
Name Type Description
name string
Returns:
Object
Since:
  • 7.7.0

static getMeshMap() → {Object}

获取所有已注册的 Mesh

Returns:
Object
Since:
  • 7.7.0

static getModel(name) → {Object}

根据传入的名称获取 model

Parameters:
Name Type Description
name string

名称

Returns:
Object
Since:
  • 7.7.0

static getModelMap() → {Object}

获取所有已注册的 model

Returns:
Object
Since:
  • 7.7.0

static getMSMap() → {any}

Returns:
any

static getNodeRect() → {Object}

获取连线类型映射表

Returns:
Object

static getPagePoint(e) → {Point}

返回page属性坐标

Parameters:
Name Type Description
e Event

事件对象

Returns:
Point -

page坐标对象

Example
//返回值示例:
{
   x: 100,
   y: 100
}

static getParentComp() → {Object}

返回当前矢量组件上一层comp,即function compStack[1],一般用于矢量值绑定func动态调用时使用

Returns:
Object -

矢量组件comp

static getPercentAngle(points, segments, percent) → {object}

获取百分比位置的弧度

Parameters:
Name Type Description
points ht.List

点集合

segments ht.List

线段类型集合

percent number

百分比,取值 0~1

Requires:
  • module:ht-flow.js
Returns:
object

static getPercentPositionOnPoints(points, segments, percent) → {object}

获取直线百分比上位置的点信息

Parameters:
Name Type Description
points ht.List

点集合

segments ht.List

线段类型集合

percent number

百分比,取值 0~1

Requires:
  • module:ht-flow.js
Returns:
object -

点信息

static getPosition(position, rect) → {Point}

获取相对位置的坐标

Parameters:
Name Type Description
position number

相对位置: 1-55

rect Rect

矩形区域

Returns:
Point

static getPosition3dGap() → {number}

3d label 偏移距离, 可以重载控制 label 的偏移

Returns:
number

static getPropertyValue(data, type, name) → {any}

获取属性

Parameters:
Name Type Description
data ht.DataModel | ht.Data

节点或 dataModel

type style | attr | field

属性类型,dataModel 不支持 style 类型

name string

属性名称

Returns:
any

static getRenderLayerInfo(layerName) → {Object}

获取渲染层级,HT内部预定义了两个layer信息,分别是main和top,两个层级对应的priority分别是:main:10000,top:10000000

Parameters:
Name Type Description
layerName string

层级名

Returns:
Object

static getShader(name) → {string}

根据传入的名称获取 shader

Parameters:
Name Type Description
name string

名称

Returns:
string
Since:
  • 7.7.0

static getShaderMap() → {Object}

获取所有已注册的 shader

Returns:
Object
Since:
  • 7.7.0

static getShape3dModel(name) → {Object}

返回所注册的3D模型

Parameters:
Name Type Description
name string

模型名

Returns:
Object -

模型

static getShape3dModelMap() → {Object}

获得所有注册模型的信息对象

Returns:
Object -

已注册模型的映射表

static getShapeModelAnimation(model, name) → {modelAnimations}

根据名称获取模型上的动画数据

Parameters:
Name Type Description
model string

模型

name string
Returns:
modelAnimations
Since:
  • 7.7.0

static getShapeModelAnimationNameList(model) → {Array.<string>}

获取模型上所有动画名称集合

Parameters:
Name Type Description
model string

模型

Returns:
Array.<string>
Since:
  • 7.7.0

static getShapeModelAnimations(model) → {Array.<modelAnimations>}

获取模型上的动画数据

Parameters:
Name Type Description
model string

图标

Returns:
Array.<modelAnimations>
Since:
  • 7.7.0

static getShapeModelDefaultAnimationName(model) → {string}

获取模型上默认动画的名称

Parameters:
Name Type Description
model string

模型

Returns:
string
Since:
  • 7.7.0

static getTarget(e) → {HTMLElement}

根据事件对象获取 dom 节点

Parameters:
Name Type Description
e MouseEvent

鼠标事件

Returns:
HTMLElement

static getter(name) → {string}

根据传入名称 property 返回一个 getProperty 方法名

Parameters:
Name Type Description
name string
Returns:
string

static getTextSize(font, text) → {Size2d}

计算文字的尺寸

Parameters:
Name Type Description
font string

文字字体,如:12px Arial

text string

文字内容

Returns:
Size2d -

文字尺寸

Example
//返回值示例:
{
	   width: 100,
	   height: 100
}

static getToolTipDiv() → {HTMLElement}

返回ToolTip的相应div对象,可获取进行风格自定义

Returns:
HTMLElement -

ToolTip相应的div对象

static getTouchCount(e) → {number}

获取当前Touch手指个数

Parameters:
Name Type Description
e Event

事件对象

Returns:
number -

Touch手指个数

static getVersion() → {string}

获得HT的版本号

Returns:
string -

版本号

static getWindowInfo() → {Object}

获取窗口信息

Returns:
Object
Example
返回对象示例
{
       "target": {},
       "left": 0,
       "top": 0,
       "width": 1234,
       "height": 1034
   }

static grow(rect, extendX, extendY) → {void}

改变rect大小,上下左右分别扩展extend的大小

Parameters:
Name Type Attributes Description
rect Rect

原始矩形

extendX number
extendY number <optional>
Returns:
void
Example
var rect = {x: 0, y: 0, width: 100, height: 100};
grow(rect, 2);
//rect结果:
{
	   x: -2,
	   y: -2,
	   width: 104,
	   height: 104
}

static handleCompTypeLoaded(url, json) → {void}

组件在加载之后的回调,可重载

Parameters:
Name Type Description
url string

组件地址

json Object

组件json

Returns:
void

static handleFontFacesLoaded() → {void}

处理附加字体加载完成,可重载

Returns:
void

static handleMaterialLoaded() → {void}

处理 Material 加载完成,可重载

Returns:
void
Since:
  • 7.7.0

static handleMeshLoaded() → {void}

处理 Mesh 加载完成,可重载

Returns:
void
Since:
  • 7.7.0

static handleRefGraphLoaded(refgraph, list, json) → {void}

RefGraph 在加载之后的回调函数,可重载

Parameters:
Name Type Description
refgraph ht.RefGraph
list ht.List

节点集合

json Object
Returns:
void

static handleShaderLoaded(name, resource) → {void}

处理 shader 加载完成,可重载

Parameters:
Name Type Description
name string
resource any
Returns:
void
Since:
  • 7.7.0

static handleUnfoundMaterial() → {void}

处理 Material 加载失败,可重载

Returns:
void
Since:
  • 7.7.0

static handleUnfoundMesh() → {void}

处理 Mesh 加载失败,可重载

Returns:
void
Since:
  • 7.7.0

static handleUnfoundShader() → {void}

处理 shader 加载失败,可重载

Returns:
void
Since:
  • 7.7.0

static hideToolTip() → {boolean}

隐藏正在显示的ToolTip

Returns:
boolean

static infoMessage(content, title, region, fixedWidth, duration) → {ht.ui.Message}

显示提示消息 showMessage 快捷方式,省略了 icon 参数

Parameters:
Name Type Attributes Description
content string <optional>
title string <optional>
region string <optional>
fixedWidth number <optional>
duration number <optional>
Returns:
ht.ui.Message

static intersection(rect1, rect2) → {Rect}

获得两个矩形的相交区域

Parameters:
Name Type Description
rect1 Rect

矩形1

rect2 Rect

矩形2

Returns:
Rect -

相交的矩形区域,如果没有相交,返回null

Example
var rect intersection({x: 0, y: 0, width: 100, height: 100}, {x: 50, y: 50, width: 200, height: 200})
//rect结果:
{
	   x: 50,
	   y: 50,
	   width: 50,
	   height: 50
}

static intersectionLineLine(a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y, segment) → {Point}

获取 2D 上两条线之间的交点

Parameters:
Name Type Attributes Description
a1x number

第一条线,点1 x 轴位置

a1y number

第一条线,点1 y 轴位置

a2x number

第一条线,点2 x 轴位置

a2y number

第一条线,点2 y 轴位置

b1x number

第二条线,点1 x 轴位置

b1y number

第二条线,点1 y 轴位置

b2x number

第二条线,点2 x 轴位置

b2y number

第二条线,点2 y 轴位置

segment Array.<number> <optional>

主要用于设置曲线,为直线时无需设置

Returns:
Point
Example
ht.Default.intersectionLineLine(0, 0, 0, 10, -5, 5, 5, 5, [1])

static intersectionLineRect(p1, p2, r) → {Point}

获取 2D 上线和面的交点信息

Parameters:
Name Type Description
p1 Point

p2 Point

r Rect

Returns:
Point -

Point

Example
ht.Default.intersectionLineRect({x: 0, y: 0}, {x: 0, y : 10}, {x: 0, y: 0, width: 100, height: 100})

static intersectsRect(rect1, rect2) → {boolean}

判断矩形区域rect1和矩形区域rect2是否相交

Parameters:
Name Type Description
rect1 Rect

矩形1

rect2 Rect

矩形2

Returns:
boolean -

两个矩形是否相交

Example
function intersectsRect({x: 0, y: 0, width: 100, height: 100}, {x: 0, y: 0, width: 200, height: 200})//true

static isArray(obj) → {obj}

判断是否为数组

Parameters:
Name Type Description
obj any

判断对象

Returns:
obj

static isBoolean(obj) → {boolean}

判断对象是否为 boolean 类型

Parameters:
Name Type Description
obj any

对象

Returns:
boolean

static isCtrlDown(e) → {boolean}

判断Ctrl键是否被按下

Parameters:
Name Type Attributes Description
e Event <optional>

事件对象

Returns:
boolean -

Ctrl键是否被按下

static isDelete(e) → {boolean}

判断键盘是否按下 Delete 键

Parameters:
Name Type Attributes Description
e Event <optional>

事件对象

Returns:
boolean -

Delete键是否被按下

static isDoubleClick(e) → {boolean}

判断是否为双击事件

Parameters:
Name Type Description
e Event

事件对象

Returns:
boolean -

是否是双击

static isDown(e) → {boolean}

判断键盘是否按下方向下键

Parameters:
Name Type Attributes Description
e Event <optional>

事件对象

Returns:
boolean -

方向下键是否被按下

static isDragging() → {boolean}

判断目前是否处于拖拽状态

Returns:
boolean -

是否处于拖拽状态

static isEmptyObject(obj) → {boolean}

判断对象是否为空

Parameters:
Name Type Description
obj Object
Returns:
boolean

static isEnter(e) → {boolean}

判断键盘是否按下 Enter 键

Parameters:
Name Type Attributes Description
e Event <optional>

事件对象

Returns:
boolean -

Enter键是否被按下

static isEsc(e) → {boolean}

判断键盘四否按下 Esc 键

Parameters:
Name Type Attributes Description
e Event <optional>

事件对象

Returns:
boolean -

Esc键是否被按下

static isFunction(obj) → {boolean}

判断是否为函数

Parameters:
Name Type Description
obj any

判断对象

Returns:
boolean

static isImageComplete(image, node, view) → {boolean}

判断图片有没有加载

Parameters:
Name Type Attributes Description
image string

图片

node ht.Node <optional>
view ht.graph.GraphView <optional>
Returns:
boolean

static isInput(e) → {boolean}

判断对象是否为 INPUT / TEXTAREA / SELECT 节点

Parameters:
Name Type Attributes Description
e any <optional>

对象

Returns:
boolean

static isIsolating() → {boolean}

判断目前系统是否处于隔离状态,处于隔离状态时host吸附和Group组等图元间的联动关系将会被停止

Returns:
boolean -

是否处于隔离状态

static isLeft(e) → {boolean}

判断键盘是否按下方向左键

Parameters:
Name Type Attributes Description
e Event <optional>

事件对象

Returns:
boolean -

方向左键是否被按下

static isLeftButton(e) → {boolean}

判断是否鼠标左键被按下

Parameters:
Name Type Description
e Event

事件对象

Returns:
boolean -

鼠标左键是否被按下

static isMouseEvent(e) → {boolean}

判断是否是鼠标事件

Parameters:
Name Type Attributes Description
e any <optional>

事件对象

Returns:
boolean -

是否是鼠标事件

static isNumber(o) → {o}

传入参数是否是数值

Parameters:
Name Type Description
o any
Returns:
o

static isObject(obj) → {boolean}

传入参数是否是对象

Parameters:
Name Type Description
obj any
Returns:
boolean

static isRight(e) → {boolean}

判断键盘是否按下方向右键

Parameters:
Name Type Attributes Description
e Event <optional>

事件对象

Returns:
boolean -

方向右键是否被按下

static isRightButton(e) → {boolean}

判断是否鼠标右键被按下

Parameters:
Name Type Description
e Event

事件对象

Returns:
boolean -

鼠标右键是否被按下

static isSelectAll(e) → {boolean}

判断键盘是否按下 ctrl + A

Parameters:
Name Type Attributes Description
e Event <optional>

事件对象

Returns:
boolean -

ctrl + A 是否被按下

static isShiftDown(e) → {boolean}

判断Shift键是否被按下

Parameters:
Name Type Attributes Description
e Event <optional>

事件对象

Returns:
boolean -

Shift键是否被按下

static isSpace(e) → {boolean}

判断键盘是否按下空格键

Parameters:
Name Type Attributes Description
e Event <optional>

事件对象

Returns:
boolean -

空格键是否被按下

static isString(obj) → {obj}

多段传入参数是否是字符串

Parameters:
Name Type Description
obj any
Returns:
obj

static isToolTipShowing() → {boolean}

判断ToolTip是否正在显示状态

Returns:
boolean -

ToolTip是否显示

static isTouchEvent(e) → {boolean}

判断是否是 touch 事件

Parameters:
Name Type Description
e UIEvent

事件对象

Returns:
boolean

static isUp(e) → {boolean}

判断键盘是否按下方向上键

Parameters:
Name Type Attributes Description
e Event <optional>

事件对象

Returns:
boolean -

方向上键是否被按下

static layout(dom, rect) → {void}

Parameters:
Name Type Description
dom HTMLElement
rect Rect
Returns:
void

static loadFbx(fbxUrl, params) → {void}

根据 url 加载 fbx 模型

Parameters:
Name Type Description
fbxUrl string

fbx模型路径

params LoadFbxParams

解析模型参数

Requires:
  • module:ht-fbx.js
Returns:
void
Since:
  • 7.0.0

static loadFontFace(url, callback) → {void}

加载字体

Parameters:
Name Type Attributes Description
url string

为json格式的typeface字体的地址

callback function <optional>

如果不带callback则为同步加载,带callback则异步加载字体,参数为加载成功的字体名

Returns:
void

static loadGltf(gltfUrl, params) → {void}

根据 url 加载 gltf 模型

Parameters:
Name Type Description
gltfUrl string

gltf 模型路径

params LoadGltfParams

解析模型参数

Requires:
  • module:ht-gltf.js
Returns:
void
Since:
  • 7.0.1

static loadJS(urls, callback) → {void}

加载 js 文件

Parameters:
Name Type Description
urls Array.<string>
callback function

回调

Returns:
void

static loadObj(objUrl, mtlUrl, params) → {boolean}

用于加载模型

Parameters:
Name Type Description
objUrl string

obj文件路径

mtlUrl string

mtl文件路径

params LoadObjParams

JSON 结构参数

Requires:
  • module:ht-obj.js
Returns:
boolean

static moveDatas(nodeList, x, y) → {void}

移动节点

Parameters:
Name Type Description
nodeList Array.<ht.Node>

节点数字

x number

x轴移动距离

y number

y轴移动距离

Returns:
void

static parse(str) → {Object}

解析 json 数据

Parameters:
Name Type Description
str string

json

Returns:
Object

static parseFbx(fbxContent, params) → {object}

解析出 fbx 模型信息

Parameters:
Name Type Description
fbxContent ArrayBuffer

fbx 模型

params ParseFbxParams
Requires:
  • module:ht-fbx.js
Returns:
object
Since:
  • 7.0.0

static parseGltf(gltfContent, params, callback) → {object}

  • 解析出 gltf 模型信息
Parameters:
Name Type Attributes Description
gltfContent ArrayBuffer

gltf 模型

params ParseGltfParams
callback function <optional>

解析后的回调

Requires:
  • module:ht-gltf.js
Returns:
object
Since:
  • 7.0.1

static parseObj(objStr, mtlStr, params) → {any}

解析 obj 和 mtl 文件loadObjParams

Parameters:
Name Type Description
objStr string

obj文件路径

mtlStr string

mtl文件路径

params ParseObjParams

JSON 结构参数

Requires:
  • module:ht-obj.js
Returns:
any

static preventDefault(e) → {void}

阻止事件的默认行为,常用于屏蔽触屏上默认DoubleTap缩放等行为

Parameters:
Name Type Description
e Event

事件对象

Returns:
void

static removeFontFace(font, del) → {void}

移除附加字体

Parameters:
Name Type Description
font any

字体

del boolean

是否 delete

Returns:
void
Example
ht.Default.removeFontFace(ht.Default.getFontFaceMap()['字体'], true)

static removeHTML(domElement) → {boolean}

删除指定的DOM对象

Parameters:
Name Type Description
domElement HTMLElement

DOM对象

Returns:
boolean -

操作是否成功

static setBatchInfo(name, batchInfo) → {void}

注册3d图元的批量信息,用于优化大数据量图元绘制性能,详细用法请参考批量手册

Parameters:
Name Type Description
name string

批量名

batchInfo Object

批量信息

Returns:
void

static setBatchInfoMap(name, info) → {void}

根据批量名称设置批量数据信息

Parameters:
Name Type Description
name string

批量名称

info Object

批量信息

Returns:
void
Example
ht.Default.setBatchInfo('firstBatch', {
       color: 'red',
       brightness: true,
       blend: true,
       alphaTest: 0.4,
   });

static setCanvas(canvas, width, height, ratio) → {void}

初始化一个 canvas 的尺寸

Parameters:
Name Type Attributes Description
canvas HTMLCanvasElement
width number

height number

ratio number <optional>

像素比,默认使用 devicePixcelRatio

Returns:
void

static setCompType(type, func) → {void}

注册矢量组件类型

Parameters:
Name Type Description
type string

类型名称

func any

绘制函数,例:function(g, rect, comp, data, view)();

Returns:
void

static setConnectAction(actionType, action, extraInfo) → {void}

注册连接动作

Parameters:
Name Type Attributes Description
actionType string

动作名

action ConnectActionFunc

动作函数

extraInfo ConnectActionExtraInfo <optional>

额外信息,可以定义可见,删除(垃圾桶)的可见与否,处理逻辑函数

Returns:
void

static setDevicePixelRatio(ratio) → {void}

设置分辨率

Parameters:
Name Type Description
ratio number
Returns:
void

static setEdgeType(type, func) → {void}

注册连线类型

Parameters:
Name Type Description
type string

连线类型名

func function

决定连线走向的函数

Returns:
void
Example
function setEdgeType('customEdge', function(edge, gap, graphView) {
    return {
        points: points;
        segments: segments;
    }
})

static setImage(name, img) → {void}

注册图片

Parameters:
Name Type Attributes Description
name string

图片名

img string | Object | HTMLCanvasElement | HTMLImageElement <optional>

img、canvas对象或图片url或base64字符串或矢量对象

Returns:
void

static setImageCacheRule(url, cache) → {void}

全局注册缓存的逻辑,这个方法更适用于项目已经完成要做后期优化,这样可以不用再去修改矢量内容,复杂的图纸运用,而不会因为定义在矢量上全局受影响

Parameters:
Name Type Description
url string
cache boolean | function

是否开启缓存

Returns:
void

static setIsolating(isolating) → {void}

设置系统的隔离状态,处于隔离状态时host吸附和Group组等图元间的联动关系将会被停止

Parameters:
Name Type Description
isolating boolean

新的状态

Returns:
void

static setMaterial(name, material) → {void}

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

Parameters:
Name Type Description
name string

材质名

material Object
Returns:
void
Since:
  • 7.7.0

static setMesh(name, Obj) → {void}

注册 Mesh

Parameters:
Name Type Description
name string

名称

Obj Object
Returns:
void
Since:
  • 7.7.0
Example
// 注册 mesh 示例
ht.Default.setMesh('test', {
       // vs -> aPosition
       // ns -> aNormal
       // uv -> aUv
       // 并非一定要 vs 、 ns,也可以自己定义任何名不需要 vs,取决于 shader
       // 比如 myvs, myns,myOtherPointAttr ...
       vs : [ 0, 0, 0, 1, 1, 1, 0.5, 0.5, 0.5 ],   
       ns : [ 0, 0, 0, 0, 0, 1 ... ], 
       uv : [ ... ],

       is : [ 0, 1,2,3 ... ],   // 非必须,固定名,作为indices顶点序
   })

static setModel(name, Obj) → {void}

注册 Model

Parameters:
Name Type Description
name string
Obj Object
Returns:
void
Since:
  • 7.7.0
Example
// 注册示例
ht.Default.getModel('test', {
   model3d : true,    // 必须指定,以区分旧有 shape3d
   position : [ 0, 0, 0 ],
   scale : [1 , 1 ,1], 
   quaternion : [ 0, 0, 0, 1], // 旋转优先查找 quaternion 是否存在,不存在则使用 euler
   euler: [ 0, 0, 0, 'XYZ' ], // 优先级低于 quaternion,不存在 quaternion 时尝试查找 euler 作为旋转
   visible : true,
   // 也可以 mesh : 'assets/mesh/myMesh1.json',
   mesh : { ... },
   drawRange: [ 0, 100 ],   // 非必须,固定名,默认 [ 0, 顶点长度 ],如果长度超过 2,则每 2 个数为一段 range 会直接进行多次绘制
   // 也可以 mat : 'assets/material/myMaterial.json'
   mat : { ... },
   // 指定 Mesh 不同部位使用不同的 mat,
   // 其中 start & count 代表了 drawRange,materialIndex 代表使用 prefab.mat[materialIndex] 材质
   // 注意此时 mat 必定为 Array 列表形态
   subMeshes : [ ... ],  
   instances : { ... },
   matDef : { ... }, // 非必要,缺省为空;该模型的材质的定义;上述的 mat 如果是非完整的 json 材质定义而是字符串,则会优先使用查找本 material 的 matDef,无法找到则尝试去公共库(包括加载)查找
   comps : [ ... ] // 孩子
})

static setPropertyValue(data, type, name, value) → {void}

设置属性

Parameters:
Name Type Description
data ht.DataModel | ht.Data

节点或 dataModel

type style | attr | field

属性类型,dataModel 不支持 style 类型

name string

属性名称

value any

属性值

Returns:
void

static setRenderLayerInfo(layerName, info) → {void}

注册|修改渲染层级,HT内部预定义了两个layer信息,分别是main和top,两个层级对应的priority分别是:main:10000,top:10000000

Parameters:
Name Type Description
layerName string
info Object

info 可定义属性有:priority优先等级,数值类型,值越大表示越上层;ignore是否忽略该层级的渲染,布尔类型;

Returns:
void

static setShader(name, url, fs) → {void}

注册 shader

Parameters:
Name Type Attributes Description
name string

名称

url string

shaderPath Or ShaderContent

fs any <optional>
Returns:
void

static setShape3dModel(name, model) → {void}

注册3D模型,请参考modeling建模手册

Parameters:
Name Type Description
name string

模型名

model Object

模型内容

Returns:
void

static setter(name) → {string}

根据传入名称 property 返回一个 setProperty 方法名

Parameters:
Name Type Description
name string
Returns:
string

static showMessage(content, title, icon, region, fixedWidth, duration) → {ht.ui.Message}

显示消息提醒

Parameters:
Name Type Attributes Description
content string <optional>

消息内容或是配置对象

title string <optional>

消息标题(如果不指定或为空,则图标以小图标的形式显示)

icon string | object <optional>

图标,可以使用四个内置图标:success、info、warn、error,也可以使用自定义图标

region string <optional>

显示区域,支持:top、center、topRight、topLeft、bottomRight、bottomLeft

fixedWidth number <optional>

消息组件的固定宽度,可以传入数字表示像素宽度,也可以传入 null 表示宽度根据内容自适应

duration number <optional>

消息组件停留多长事件以后自动隐藏,单位为毫秒;传入 null 可关闭自动隐藏

Returns:
ht.ui.Message -

Message 组件实例

static showToolTip(eventOrPoint, innerHTML) → {void}

显示ToolTip

Parameters:
Name Type Description
eventOrPoint Object | Event

鼠标事件对象或点坐标

innerHTML string

ToolTip的内容

Returns:
void

static startAnim(paramObj) → {AnimInstance}

启动动画

Parameters:
Name Type Description
paramObj AnimOption

动画配置对象,请参考入门手册中的动画属性

Returns:
AnimInstance
Example
ht.Default.startAnim({
	   frames: 60,
	   interval: 16,
	   finishFunc: function() {
		   console.log('finish');
	   },
	   action: function(t) {
		   console.log(t);
	   }
});

static startDragging(interactor, e) → {void}

启动拖拽,自定义交互时可能用到

Parameters:
Name Type Description
interactor Object

交互器

e Event

事件对象

Returns:
void

static stringify(json, space, encode) → {string}

将对象序列化为字符串

Parameters:
Name Type Attributes Description
json any

要序列化的对象

space string | number <optional>

指定缩进用的空白字符串

encode boolean <optional>

是否加密

Returns:
string

static successMessage(content, title, region, fixedWidth, duration) → {ht.ui.Message}

显示成功消息 showMessage 快捷方式,省略了 icon 参数

Parameters:
Name Type Attributes Description
content string <optional>
title string <optional>
region string <optional>
fixedWidth number <optional>
duration number <optional>
Returns:
ht.ui.Message

static toBoundaries(points, segments, resolution) → {Array.<number>}

将不连续曲线转化成Graph3dView#setBoundaries(bs)需要的参数格式

Parameters:
Name Type Description
points Array.<Object>

曲线上的点坐标数组

segments Array.<Object>
resolution number

曲线微分数

Returns:
Array.<number> -

适合Graph3dView#setBoundaries(bs)需要的参数格式

static toCanvas(image, width, height, stretch, data, view, color) → {HTMLCanvasElement}

将图片转换成Canvas对象

Parameters:
Name Type Attributes Description
image Object | HTMLImageElement

要转换的图片(img对象或矢量对象)

width number

新canvas的宽度

height number

新canvas的高度

stretch string

拉伸类型(uniform/centerUniform/fill)

data ht.Data <optional>

要绑定的Data对象

view Object <optional>

要绑定的视图对象

color string <optional>

染色

Returns:
HTMLCanvasElement -

canvas对象

static toColorData(color) → {Array.<number>}

将颜色转换为rgba格式

Parameters:
Name Type Description
color string

旧格式的颜色

Returns:
Array.<number> -

rgba格式的颜色

static toggleFullscreen(view) → {void}

切换 HT 视图组件的全屏显示状态

Parameters:
Name Type Description
view any

HT 视图组件,比如 ht.graph.GraphView, ht.widget.TreeView, ht.widget.BorderPane 等

Returns:
void

static toGrayColor(color) → {string}

传入一个颜色,获取灰化后的颜色

Parameters:
Name Type Description
color string

颜色

Returns:
string

static toRoundedCorner(listOrNode, radius) → {any}

将一组折线曲线化

Parameters:
Name Type Description
listOrNode Array.<any> | ht.List | ht.Shape

节点或者点数组

radius number

拐角弧度,

Returns:
any

static transformVec(vec, matrix) → {Object}

将指定矢量或顶点,通过矩阵转换运算出变化后的新矢量或顶点位置

Parameters:
Name Type Description
vec Object
matrix Object
Returns:
Object

static unionPoint(p1, p2) → {Rect}

将点组合成矩形

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

第一个点或点数组

p2 Point <optional>

第二个点

Returns:
Rect -

组合的矩形

Example
//组合两点:
var rect = unionPoint({x: 0, y: 0}, {x: 100, y: 100});
//rect结果:
{
	   x: 0,
	   y: 0,
	   width: 100,
	   height: 100
}
组合多点:
var rect unionPoint([{x: 0, y: 0}, {x: 50, y: 50}, {x: 100, y: 100}]);
//rect结果:
{
	   x: 0,
	   y: 0,
	   width: 100,
	   height: 100
}

static unionRect(rect1, rect2) → {Rect}

将两个矩形区域union融合成新的矩形区域

Parameters:
Name Type Description
rect1 Rect

第一个矩形区域

rect2 Rect

第二个矩形区域

Returns:
Rect -

新的矩形区域

Example
var rect = unionRect( {x: 0, y: 0, width: 100, height: 100}, {x: 0, y: 0, width: 200, height: 200});
//rect结果:
{
	   x: 0,
	   y: 0,
	   width: 200,
	   height: 200
}

static updateToolTipContent(content) → {void}

更新 tooltip 的内容

Parameters:
Name Type Description
content string

内容

Returns:
void

static warnMessage(content, title, region, fixedWidth, duration) → {ht.ui.Message}

显示警告消息 showMessage 快捷方式,省略了 icon 参数

Parameters:
Name Type Attributes Description
content string <optional>
title string <optional>
region string <optional>
fixedWidth number <optional>
duration number <optional>
Returns:
ht.ui.Message

static xhrLoad(urls, callback, option) → {void}

异步加载文件

Parameters:
Name Type Attributes Description
urls string | Array.<string>

url 字符串或者多个url,为字符串数据

callback function

回调函数,仅有一个参数,为请求结果

option Object <optional>

选项,可以设置 method,responseType

Returns:
void