Class: BimViewer

BimViewer(containerDiv, options)

new BimViewer(containerDiv, options)

三维场景核心类,BimViewer是BIMI引擎的核心,管理所有的plugin,并提供多种事件回调。
Parameters:
Name Type Default Description
containerDiv * Div容器
options Object null 初始化参数
Example
参数定义如下:
{
    id: String/Number BimViewer对象id,唯一性,默认采用时间戳,这意味着一个web应用中可以存在多个BimViewer对象,多个对象统一使用ViewerHelper管理
    showGrid:是否显示辅助地平网格。默认false
    fps:是否显示FPS。默认false
    debug:是否控制台输出render debug日志 默认false
    loading:使用自带的加载进度控件LoadingMultiplePlugin,支持多模型加载。默认true
    streamRender:流式渲染,默认true
    loadProperty:是否需要加载构件数据数据 默认true
    loadTree:是否需要加载目录树 默认true
    loadRoom:是否需要加载房间数据 默认true
    localCache:是否启用本地缓存 默认false
    navCube:是否默认加载方向插件NavCubePlugin 默认true
    farLimit:是否限制相机的远视角距离(camera.far),默认 false 
    alwaysRefresh:是否开启自动每帧刷新,默认false
}

Methods

addPlugin(plugin)

添加插件
Parameters:
Name Type Description
plugin object 引擎提供的各个Plugin

changePickMaterial(color, opacity)

设置pick和框选后构件的颜色和透明度
Parameters:
Name Type Description
color string 颜色
opacity Number 不透明度

clearEvent(eventName)

清除某类事件回调
Parameters:
Name Type Description
eventName *

clearFog()

清除雾气

clearLocalCache()

清理浏览器中关于BIM模型数据的本地缓存

clearRooms()

在场景中清除房间

clearZoomToHightlight()

清除ZoomTo高亮构件状态,如果有的话

coordScreenToWorld(screenVector)

屏幕坐标转世界坐标,返回THREE.Vector3对象
Parameters:
Name Type Description
screenVector object 类似这样的屏幕坐标对象:{x:231,y:45}

coordWorldToScreen(worldVector)

世界坐标转屏幕坐标
Parameters:
Name Type Description
worldVector THREE.Vector3

createBasicTextureMaterial(imagePath, repeat, side, deptTest)

生成一个包含贴图的Basic材质,该材质不受光照的影响
Parameters:
Name Type Description
imagePath * 图片url
repeat * true为重复填充,false为拉伸填充,默认true
side * 默认值BIMI.THREE.FrontSide
deptTest * 深度探测,默认是true
Returns:
Promise对象

createDecal(options)

在场景中添加一个贴花
Parameters:
Name Type Description
options Object { id: 对象标识,Number或String,默认采用时间戳 url: 图片地址url side: 材质是单面还是双面,默认是单面,如果需要双面,赋值'double' position:贴花中心点位置,BIMI.THREE.Vector3类型,默认new BIMI.THREE.Vector3(0,0,0) width:贴花宽度,如果不设置,自动采用图片的宽度作为贴花宽度 height:贴花高度,如果不设置,自动采用图片的高度作为贴花高度 rotate: 贴花旋转偏移量,BIMI.THREE.Vector3类型,默认new BIMI.THREE.Vector3(0,0,0) }
Returns:
Promise ,返回贴花的mesh对象

createDom(domStr)

将html文本转为dom对象
Parameters:
Name Type Description
domStr string

createGradientMaterial(modelId, productId, color1, color2, opacity)

针对某个构件,创建符合该构件高度的渐变材质对象,返回材质对象
Parameters:
Name Type Description
modelId * 模型ID, String/Number
productId * 构件ID,Number
color1 * 颜色1, String
color2 * 颜色2, String
opacity * 透明度, Number

createLambertMaterial(color, opacity, deptTest)

创建Lambert材质(已过时),建议采用createPBRMaterial替代该函数
Parameters:
Name Type Description
color string 颜色
opacity Number 不透明度,默认1.0
deptTest Boolean 深度测试,默认true

createLevelMaps(modelId, blackAndWhite, download)

根据BIM模型层高数据,生成模型楼层平面图数据。
Parameters:
Name Type Description
modelId * 模型ID
blackAndWhite * 灰度图,默认true
download * 启用浏览器下载生成数据文件,默认true
Returns:
返回Promise对象,resolve参数为数据对象

createLine(points, color, depthTest) → {object}

创建Three的Line,线宽受限webgl永远是1
Parameters:
Name Type Description
points Array [{x:0,y:0,z:0},...]
color String 颜色
depthTest Boolean 是否需要深度探测
Returns:
shape对象
Type
object

createPBRMaterial(type, color, opacity, deptTest)

创建PBR材质
Parameters:
Name Type Description
type String 类型,如果设置为null就是哑光无反射的Lambert材质,type定义目前支持"metal"(金属),"wallpaint"(墙漆),"plasticvinyl"(塑料),"glazing"(玻璃),"concrete"(混凝土),"hardwood"(木材),"ceramic"(陶瓷)
color String 颜色
opacity Number 不透明度,默认1.0
deptTest Boolean 深度测试,默认true
Returns:
材质对象

createPoints(points, color, pointPixel) → {object}

创建包含一组坐标的Points对象,但不自动绘制
Parameters:
Name Type Description
points Array [{x:0,y:0,z:0},...]
color string 颜色
pointPixel Number 点的像素大小
Returns:
shape对象
Type
object

disabelProductsReceiveShadow(modelId, productIds)

设置某些构件不接受阴影
Parameters:
Name Type Description
modelId *
productIds *

dispose()

引擎销毁释放资源

disposeProductsEdge(modelId, productIds)

取消指定构件Edge
Parameters:
Name Type Description
modelId *
productIds *

drawAnchorMark(position, color) → {object}

绘制锚点标记(类似百度地图的锚点标记)
Parameters:
Name Type Description
position object {x:0,y:0,z:0}
color string 颜色 默认 '#00ff00'
Returns:
shape对象
Type
object

drawCurve(points, color)

通过一系列的Vector3生成圆滑曲线
Parameters:
Name Type Description
points *
color *

drawLine(points, color) → {object}

使用Three的Line绘制,线宽受限webgl永远是1
Parameters:
Name Type Description
points Array [{x:0,y:0,z:0},...]
color String 颜色
Returns:
shape对象
Type
object

drawLine2(points, color, linePixel, dash) → {object}

绘制Line2,参见webgl_lines_fat.html
Parameters:
Name Type Description
points Array [{x:0,y:0,z:0},...]
color String
linePixel Number 线宽像素大小,默认5
dash boolean 是否虚线,默认false
Returns:
shape对象
Type
object

drawPoints(points, color, pointPixel) → {object}

绘制一组Point,点的大小不随相机深度而衰减
Parameters:
Name Type Description
points Array [{x:0,y:0,z:0},...]
color string 颜色
pointPixel Number 点的像素大小
Returns:
shape对象
Type
object

enableDamping(enable)

Orbit控件是否启用阻尼效果,默认false. dampingFactor是阻尼系数,默认0.05。值越小阻尼越明显
Parameters:
Name Type Description
enable Boolean

getCamerFrustum()

获得当前camera的视锥对象

getCameraState()

获取当前相机的位置和四元数

getCameraStateForGeo()

当前相机状态数据对应的经纬度、高程、俯仰角数据
Returns:
object,相机的经纬度、高程、俯仰角数据
Example
数据格式定义
{
     camera_pitch: pitch角
     camera_yaw: yaw角
     camera_latitude: 纬度
     camera_longitude: 经度
     camera_height: 高度
}

getLevelsBbox(modelId, levelNames)

求多个层高名称下的包围盒
Parameters:
Name Type Description
modelId Number 模型id
levelNames Array 层高名称数组
Returns:
包围盒box

getMeterPrePixel(position)

计算某个位置的屏幕像素和世界单位的比例
Parameters:
Name Type Description
position THREE.Vector3

getModelBox(modelId)

获得模型的bbox,注意该API必须在加载模型完成之后调用才会生效
Parameters:
Name Type Description
modelId Number 模型id

getModelGroup(modelId)

获得模型的Group对象,这是一个模型根节点对象
Parameters:
Name Type Description
modelId *

getModels()

场景中所有模型对象

getMutilProductsBbox(modelId, productIds)

求多个构件的包围盒
Parameters:
Name Type Description
modelId Number 模型id
productIds Array 构件id数组
Returns:
包围盒box

getOrbitMaxDistance(distance)

获得Orbit控件的最大限制距离
Parameters:
Name Type Description
distance Number

getOrbitState()

获得当前OrbitControl的状态数据

getPickPorductIds()

获得当前场景中pick的构件id
Returns:
Map对象,key是modelId,value是Array(productIds)

getPlugin(pluginName)

根据插件名称查找插件,插件名称是类名
Parameters:
Name Type Description
pluginName string

getProduct(modelId, productId)

查找构件对象
Parameters:
Name Type Description
modelId Number 模型id
productId Number 构件id

getProductBbox(modelId, productId)

求构件的包围盒
Parameters:
Name Type Description
modelId Number 模型id
productId Number 构件id

getProductIdsByLevels(modelId, levelNames)

获得指定层高下的构件ID
Parameters:
Name Type Description
modelId Number 模型id
levelNames Array 层高名称数组

getProductIdsByModel(modelId)

获得模型包含的所有构件ID,返回构件ID数组(Array),如果该模型ID没有找到对应的Model对象,那么返回null
Parameters:
Name Type Description
modelId * 模型ID
Returns:
构件ID数组,Array,如果modelId没有查询到对应的模型,返回null

getProductIdsByType(types)

根据构件类型查询场景中符合条件的构件ID,返回数据结构定义为:[{modelId:XXX,productIds:[XXX,XXX]},...]
Parameters:
Name Type Description
types * 构件类型数组 Array

getProductsByModel(modelId)

获得模型包含的所有构件对象,返回构件数组(Array),如果该模型ID没有找到对应的Model对象,那么返回null
Parameters:
Name Type Description
modelId * 模型ID
Returns:
构件数组,Array,如果modelId没有查询到对应的模型,返回null

getRayPoint(event, fliter)

鼠标射线交点
Parameters:
Name Type Description
event object 鼠标事件
fliter THREE.Object3D 过滤根节点 ,默认是整个场景

getRoomIntersectsProducts(modelId, roomId, onlyContains, roomExpand)

获得与Room空间相交(包含)的构件,目前是基于Box3判断相交的,如果Room几何是异形几何会不准确,后续版本修正
Parameters:
Name Type Description
modelId *
roomId *
onlyContains * 是否只求包含的构件,默认false(即相交和包含逻辑都要)
roomExpand * onlyContains为true时,扩展Room空间的尺寸,这是为了将一些建模时正好和Room相交的构件也纳入包含逻辑中,默认值0.01

hasFilterColor()

获得场景中是否包含过滤器着色数据

hdr(enable)

HDR效果渲染,采用ACES算法
Parameters:
Name Type Description
enable *

hdrExposure(exposure)

HDR曝光度,默认值是1
Parameters:
Name Type Description
exposure *

isBimModel(modelId)

判断模型是否是BIM模型对象
Parameters:
Name Type Description
modelId *

isDirty()

刷新场景

isolateProducts(isolateMap)

隔离构件
Parameters:
Name Type Description
isolateMap Map Map的结构{modelId:[productId]},如果传入空Map或者null,那么就取消隔离

load(url, options)

加载BIM、gltf、glb、fbx、obj模型的统一接口,返回Promise对象,该Prosmise对象提供event参数用于读取模型的一些重要属性
Parameters:
Name Type Description
url String bim模型url
options Object 加载参数,对象类型
Example
viewer.load(xxxxxx/bim.bin',{modelId:'myModel1'}).then((event)=>{ 
    console.info(event) 
 }); 
options数据定义如下:
{                                                           
     name:模型名称,在loading上会以该名称显示  
     modelId:可指定模型ID,否则引擎自动递增作为默认模型ID,建议指定ID,ID可以是文本或整数类型 
     updateRegion:是否需要重置相机视角,默认为true,如果启用地图模式(使用MapPlugin),可以设置为false,这样加载模型后不会改动相机位置和视角 
     location: 模型位置,默认BIMI.THREE.Vector3(0,0,0) 
     latitude: 模型位置纬度坐标,默认null,该值和location互斥,当设置经纬度后,引擎会自动将经纬度坐标转为世界坐标并替代location 
     longitude:模型位置经度坐标,默认null,该值和location互斥,当设置经纬度后,引擎会自动将经纬度坐标转为世界坐标并替代location 
     offset: 位置偏移量,默认BIMI.THREE.Vector3(0,0,0) 
     scale: 模型缩放量,默认BIMI.THREE.Vector3(1,1,1) 
     rotate: 模型旋转量,默认BIMI.THREE.Vector3(0,0,0) 
     toZero: 模型中心基准点是否落在location(或latitude、longitude)上,默认true。
     
}

loadMerge(models)

合模加载操作,常用于对建模时同属一个坐标系的多个分解模型文件进行合模加载,注意:这不是多个模型同时加载,而是合模加载操作,使用前请先理解BIM中合模的概念。
Parameters:
Name Type Description
models * 模型组参数对象
Returns:
Promise,确保所有模型加载完毕后的回调,但该回调then没有参数
Example
模型组参数对象举例:
//对两个模型进行合模,第一个是主模型,第二个是从模型,位置、缩放、旋转、偏移等加载参数都在主模型参数中设置,从模型统一自动采用主模型的参数,数以,从模型只要设置modelId和name
 viewer.loadMerge( 
         [
              {
                  url:'temp/柱1/bim.bin',options:{modelId:'myMaster',name:'主模型',location:new THREE.Vector3(0,10,0),scale:new THREE.Vector3(10,10,10)}
              },
              {
                  url:'temp/柱23/bim.bin',options:{modelId:'mySlave1',name:'从模型1'}
              },
          ]
      ).then(()=>{
          console.info('模型组合加载完毕')
      })

lockAxis(direction, min, max)

锁定相机旋转位置
Parameters:
Name Type Description
direction * 'horizontal'水平方向旋转角度范围,即左右旋转。如果设置,则间隔[min,max]必须是[-2 PI,2 PI]的子间隔,且(max-min <2 PI)
'vertical' 垂直方向旋转角度范围,即上下旋转。如果设置,则间隔[min,max]必须是[0 , Math.PI]的子间隔
min *
max *

lookAt(x, y, z)

设置相机的焦点坐标
Parameters:
Name Type Description
x Number
y Number
z Number

moveProducts(modelId, productIds, moveVec3, time)

移动构件,小技巧:可以通过移动构件一点点位置来处理Z-Fighting导致的构件闪烁问题
Parameters:
Name Type Description
modelId Number 模型ID
productIds Array 构件ID数组
moveVec3 Vector3 移动量
time Number 动画时间,默认0

off(eventName, callback)

取消事件回调
Parameters:
Name Type Description
eventName string 事件名称
callback function 回调

on(eventName, callback)

注册回调事件
Parameters:
Name Type Description
eventName string 事件名称
callback function 回调

onlySeeProducts(productMap)

只可见以下构件
Parameters:
Name Type Description
productMap Map Map的结构{modelId:[productId]}

onlySeeProductsByLevels(modelId, levelNames)

只可见指定层高的构件
Parameters:
Name Type Description
modelId * 模型ID
levelNames Array 层高名称数组

overrideProductsColor(modelId, productIds, color, opacity, phong)

设置构件自定义材质(替换原始材质,即永久材质),考虑到性能,在批量设置之后,需要手动调用isDirty()
Parameters:
Name Type Description
modelId Number 模型id
productIds Array 构件id数组
color string 颜色
opacity Number 不透明度
phong Boolean 是否高亮

overrideProductsColorByType(}, color, opacity, phong)

根据构件type批量设置构件自定义材质(替换原始材质,即永久材质),考虑到性能,在批量设置之后,需要手动调用isDirty()
Parameters:
Name Type Description
} Array types 类型数组
color string 颜色
opacity Number 不透明度
phong Boolean 是否高亮

overrideProductsMaterial(modelId, productIds, material)

设置构件自定义材质(替换原始材质,即永久材质),考虑到性能,在批量设置之后,需要手动调用isDirty()
Parameters:
Name Type Description
modelId Number 模型id
productIds Array 构件id数组
material THREE.Material 材质

overrideProductsMaterialByType(types, material)

按照类型,设置构件自定义材质(替换原始材质,即永久材质)考虑到性能,在批量设置之后,需要手动调用isDirty()
Parameters:
Name Type Description
types Array 构件类型数组
material * 材质

overrideProductsOpacity(modelId, productIds, opacity)

永久设置构件透明度,不改变原始材质
Parameters:
Name Type Description
modelId Number 模型id
productIds Array 构件id数组
opacity Number 不透明度

pitchYawToQuaternion(pitch, yaw)

pitch yaw转四元数对象
Parameters:
Name Type Description
pitch *
yaw *
Returns:
THREE.Quaternion对象

printScreen(callback, scale)

对BIM模型、批注、数据标签等屏幕截图(速度较慢)
Parameters:
Name Type Description
callback function 回调函数,参数是Image
scale Number 图片缩放比率,默认为null,即按照设备屏幕比率自动生成

removeMesh(mesh)

从场景中删除一个mesh对象
Parameters:
Name Type Description
mesh * 需要删除的mesh对象

removePlugin(plugin)

移除插件
Parameters:
Name Type Description
plugin object 插件对象

removePluginByName(pluginName)

移除插件,根据插件名称
Parameters:
Name Type Description
pluginName string 插件名称

removeShape(shape)

移除创建的shape
Parameters:
Name Type Description
shape object 生成的shape对象

resetFilterColor(modelId)

Revit模型真实渲染模式下,取消过滤器着色
Parameters:
Name Type Description
modelId * 模型ID

resetHomeState()

控制相机回归到Home视角

resetPick()

恢复当前被Pick的构件的高亮状态

resetProductsMaterial(modelId, productId)

恢复构件原始材质,考虑到性能,在批量设置之后,需要手动调用isDirty()
Parameters:
Name Type Description
modelId Number 模型ID
productId Number 构件ID

resetProductsMaterialByType(types, material, merge)

按构件类型reset材质
Parameters:
Name Type Description
types Array 构件类型
material THREE.Material 材质
merge Boolean 是否恢复合并 默认true

rotateProducts(modelId, productIds, rotateVec3, time)

旋转构件
Parameters:
Name Type Description
modelId * 模型ID
productIds * 构件ID数组
rotateVec3 * 旋转量,XYZ三个方向的旋转角度
time * 动画时间,默认0

scaleProducts(modelId, productIds, rotateVec3, time)

缩放构件
Parameters:
Name Type Description
modelId * 模型ID
productIds * 构件ID数组
rotateVec3 * 缩放向量
time * 动画时间,默认0

screenImage(callback)

只对BIM模型截屏
Parameters:
Name Type Description
callback function 回调参数是Image对象

screenSpacePanning(enable)

Orbit控件移动操作(Pan)时,当上下移动时,是否考虑高度移动。默认false
Parameters:
Name Type Description
enable Boolean

setBoxShadow(}, options)

场景边缘阴影渐变效果.
Parameters:
Name Type Description
} boolean enable 是否启用,默认true,如果设置为false,则是关闭该效果
options object 边框阴影参数定义
Example
参数定义
{
     shadow:阴影色,默认值'#353535'
     blur:模糊距离,默认值'300px'
     spread:阴影的大小,默认值'200px'
}

setConfig(url)

加载设置
Parameters:
Name Type Description
url string 设置文件url

setDefaultOrbitState(state)

设置相机初始化默认位置和旋转角度数据,要在load之前调用才生效
Parameters:
Name Type Description
state * 通过调用getOrbitState获得的数据对象

setFilterColor(modelId)

Revit模型真实渲染模式下,设置过滤器着色
Parameters:
Name Type Description
modelId * 模型ID

setFog(density)

设置指数雾,它可以在相机附近提供清晰的视野,且距离相机越远,雾的浓度随着指数增长越快。
Parameters:
Name Type Description
density Number 指数默认值0.0025

setMinZoomIn(scale)

Parameters:
Name Type Description
scale Number 设置最小放大比例(默认值是1),针对特别小的模型建议设置值为0.001

setModelMaterial(modelId, material)

对整个模型设置一个材质
Parameters:
Name Type Description
modelId * 模型ID
material * 材质对象

setModelPosition(modelId, options)

设置模型位置(包括偏移、缩放、旋转、基点调节)
Parameters:
Name Type Description
modelId * 模型ID
options * 参数对象
Example
参数对象举例:
{
     location: 模型位置,默认BIMI.THREE.Vector3(0,0,0) 
     latitude: 模型位置纬度坐标,默认null,该值和location互斥,当设置经纬度后,引擎会自动将经纬度坐标转为世界坐标并替代location 
     longitude:模型位置经度坐标,默认null,该值和location互斥,当设置经纬度后,引擎会自动将经纬度坐标转为世界坐标并替代location 
     offset: 位置偏移量,默认BIMI.THREE.Vector3(0,0,0) 
     scale: 模型缩放量,默认BIMI.THREE.Vector3(1,1,1) 
     rotate: 模型旋转量,默认BIMI.THREE.Vector3(0,0,0) 
     toZero: 模型中心基准点是否落在location(或latitude、longitude)上,默认true。
     masterModelId:主模型ID,该参数只有在需要做BIM合模操作下才考虑,默认null。
}

setModelVisible(modelId, visible)

设置模型可见性,这只是对模型的modelGroup属性的visible进行true/false设置
Parameters:
Name Type Description
modelId Number 模型ID
visible Boolean 是否可见,默认true

setNormalModel(modelId)

设置模型正常模式展示
Parameters:
Name Type Description
modelId Number

setOrbitMaxDistance(distance)

设置Orbit控件的最大限制距离
Parameters:
Name Type Description
distance Number 最大距离

setOrbitState(json, fly, duration, callback)

设置OrbitControl的状态
Parameters:
Name Type Description
json * 状态数据对象
fly * 是否需要飞行动画
duration * 动画时长 毫秒
callback * 飞行结束回调

setPickedProducts(modelId, productIds)

通过代码,设置当前picked的构件
Parameters:
Name Type Description
modelId * 模型ID
productIds * 构件ID数组 (Array)

setProductsEdge(modelId, productId, productVisible)

设置指定构件增加Edge模式
Parameters:
Name Type Description
modelId Number 模型ID
productId Number 构件ID
productVisible Boolean 构件本身是否可见 默认false

setProductsMaterial(modelId, productIds, material)

设置构件自定义材质(临时材质,可以reset恢复),考虑到性能,在批量设置之后,需要手动调用isDirty()
Parameters:
Name Type Description
modelId Number 模型ID
productIds Array 构件ID数组
material THREE.Material 材质对象

setProductsMaterialByType(types, material)

按构件类型设置构件自定义材质(临时材质,可以reset恢复),考虑到性能,在批量设置之后,需要手动调用isDirty()
Parameters:
Name Type Description
types Array 构件类型数组
material * 材质

setProductsMaterialColor(modelId, productIds, color, opacity)

只修改构件材质的颜色,保留当前材质的贴图和属性(临时材质,可以reset恢复),考虑到性能,在批量设置之后,需要手动调用isDirty()
Parameters:
Name Type Description
modelId Number 模型ID
productIds Array 构件ID数组
color string 颜色
opacity object 不透明度,null表示不变动,默认值是null

setProductsMaterialOpacity(modelId, productIds, opacity)

只修改构件材质的透明度,保留当前材质的颜色、贴图和属性(临时材质,可以reset恢复),考虑到性能,在批量设置之后,需要手动调用isDirty()
Parameters:
Name Type Description
modelId Number 模型ID
productIds Array 构件ID数组
opacity object 不透明度,null表示不变动,默认值是0.5

setProductsTransparent(modelId, productIds)

设置构件透明,透明样式采用BimViewer的_transparentMaterial属性定义,用户可修改该属性
Parameters:
Name Type Description
modelId Number 模型ID
productIds Array 构件ID

setProductsVisible(modelId, productIds, visible)

设置构件可见性,考虑到性能,在批量设置之后,需要手动调用isDirty()
Parameters:
Name Type Description
modelId Number 模型id
productIds Array 构件id数组
visible boolean 可见性

setProductsVisibleByType(types, visible)

根据构件类别设置可见性
Parameters:
Name Type Description
types Array 构件类型数组
visible boolean 可见性

setReplaceStyle(data)

替换构件原始材质,在load之前调用该函数,可以实现在渐进性加载过程中使用指定的替换材质效果
Parameters:
Name Type Description
data Object 指定样式,参数类型Object,样式可byModel、byType、byProduct自由组合。
Example
参数举例:
 {
            //根据模型设置,指定modelId的模型整体都采用style样式 
            byModel:[ 
                { 
                    modelId:1, 
                    //style的属性包含颜色、不透明度、材质类型三个定义,其中颜色和材质类型是可选参数,其组合说明如下:
                    //不设置color,那么就针对构件的原始材质做透明化处理,该功能只对byModel起效 
                    //不设置type,那么为默认亚光材质,type目前支持"metal"(金属),"wallpaint"(墙漆),"plasticvinyl"(塑料),"glazing"(玻璃),"concrete"(混凝土),"hardwood"(木材),"ceramic"(陶瓷)
                    style:{color:'#ffffff',opacity:1.0,type:'metal'}
                },
                ......
            ], 
            //根据构件类型设置,场景中所有构件的类型符合指定类型,都采用style样式
            byType:[ 
                { 
                    types:['IfcBuildingElementProxy'], 
                    style:{color:'#0b4161',opacity:0.2}  
                }, 
                { 
                    types:['IfcRoof','IfcBeam','IfcColumn','IfcWallStandardCase','IfcWindow','IfcSlab','IfcDoor'],
                    style:{color:'#0f628c', opacity:0.5} 
                }, 
                ......
            ],
            //根据构件ID设置,场景中的所有构件的构造ID符合指定构件ID,都采用style样式
            byProduct:[ 
                { 
                    modelId:1, 
                    productIds:[1165376,921443,921468,921393,921418], 
                    style:{color:'#341132',opacity:1} 
                }, 
                ......
            ] 
 } 

setRoomVisible(modelId, roomId)

设置Room Mesh可见性,Room定义需要rvt建模支持,如果rvt具备Room数据,那么到处空间结构数据的时候,会生成room.json文件
Parameters:
Name Type Description
modelId Number 模型ID
roomId Number room ID

setSceneBackground(background)

若不为null,在渲染场景的时候将设置背景,且背景总是首先被渲染的。 可以设置String/Three.Color(颜色) 一个覆盖canvas的Texture(纹理) 或是CubeTexture。默认值为null。
Parameters:
Name Type Description
background * 场景背景色,如果不设置,那么场景背景透明,可设置颜色、纹理。

setScenePanoramic(imageUrl, enablePanoramicDoubleClick)

使用一张图片生成全景图
Parameters:
Name Type Description
imageUrl * 全景图的图片url
enablePanoramicDoubleClick Boolean 全景图时候支持鼠标左键双击获得坐标,默认false

setTransparentModel(modelId, color, opacity)

设置模型半透明展示
Parameters:
Name Type Description
modelId Number 模型ID
color String 颜色,可选参数,默认为#ffffff
opacity Number 不透明度,可选参数,默认为0.3

setTransparentModelSaveOriginalMaterial(modelId, opacity)

设置模型半透明展示(保持原始材质的样式)
Parameters:
Name Type Description
modelId Number 模型ID
opacity Number 不透明度,默认0.5

skewOrbitState(state, pitch, yaw)

对orbit state做pitch和yaw的偏移计算,返回一个偏移计算后的四元数,该计算不影响传入的orbit state对象
Parameters:
Name Type Description
state Object orbit state对象
pitch Number 绕X轴角度
yaw Number 绕Y轴角度
Returns:
orbit state对象

skewQuaternion(quaternion, pitch, yaw)

对四元数做pitch和yaw的偏移计算,返回一个偏移计算后的四元数,该计算不影响传入的quaternion对象
Parameters:
Name Type Description
quaternion THREE.Quaternion 原始四元数对象
pitch Number 绕X轴角度
yaw Number 绕Y轴角度
Returns:
THREE.Quaternion 偏移后的四元数对象

unload(modelId)

从场景中移除模型
Parameters:
Name Type Description
modelId Number 模型id

worldToRevit(worldVector)

世界坐标转模型原始坐标(如果是revit,注意revit是Z朝上)(返回数据的单位是米,注意revit的单位可能是英尺,需要自行从米转换到英尺)
Parameters:
Name Type Description
worldVector THREE.Vector3
Returns:
Vector3,模型原始坐标

zoomToBox(box, fitOffset, fly, callback, duration, customAngle)

聚焦定位包围盒
Parameters:
Name Type Description
box THREE.Box3 包围盒
fitOffset Number 和距离有关 默认1.2 建议不要改动
fly Boolean 是否飞行动画
callback function 飞行结束后的回调
duration Number 飞行时间,默认1500毫秒
customAngle Object 自定义固化视角,包括俯仰角和倾斜角,用x和y来表示,例如:{x:45,y:45},该对象表示相机视角固定为 俯仰角(绕X轴)45°+倾斜角(绕Y轴)45°,默认是null

zoomToLevels(modelId, levelNames, fly, callback, customAngle)

聚焦层高
Parameters:
Name Type Description
modelId Number 模型ID
levelNames Array 层高名称数组
fly Boolean 是否飞行动画,默认true
callback function 飞行动画结束后的回调函数,默认null
customAngle Object 自定义固化视角,包括俯仰角和倾斜角,用x和y来表示,例如:{x:45,y:45},该对象表示相机视角固定为 俯仰角(绕X轴)45°+倾斜角(绕Y轴)45°,默认是null

zoomToModel(modelId, fitOffset, fly, callback, duration, customAngle)

聚焦模型
Parameters:
Name Type Description
modelId Number/String 模型ID
fitOffset Number 和距离有关 默认1.2 建议不要改动
fly Boolean 是否飞行动画,默认false
callback function 飞行结束后的回调,默认null
duration Number 飞行时间,默认1500毫秒
customAngle Object 自定义固化视角,包括俯仰角和倾斜角,用x和y来表示,例如:{x:45,y:45},该对象表示相机视角固定为 俯仰角(绕X轴)45°+倾斜角(绕Y轴)45°,默认是null

zoomToProduct(modelId, productId, fly, callback, customAngle)

聚焦构件
Parameters:
Name Type Description
modelId * 模型ID
productId * 构件ID
fly * 是否飞行动画,默认true
callback * 飞行结束回调
customAngle Object 自定义固化视角,包括俯仰角和倾斜角,用x和y来表示,例如:{x:45,y:45},该对象表示相机视角固定为 俯仰角(绕X轴)45°+倾斜角(绕Y轴)45°,默认是null

zoomToProductAndHightlight(modelId, productId, zoomMaterial, callback, customAngle)

聚焦构件并且高亮,该高亮状态会在下一个zoomToProductAndHightlight后清除,也可以手动调用clearZoomToHightlight()清除当前的高亮状态
Parameters:
Name Type Description
modelId * 模型ID
productId * 构件ID
zoomMaterial * 高亮材质,可以创建一个可复用的材质对象
callback * 飞行结束回调,默认值null
customAngle Object 自定义固化视角,包括俯仰角和倾斜角,用x和y来表示,例如:{x:45,y:45},该对象表示相机视角固定为 俯仰角(绕X轴)45°+倾斜角(绕Y轴)45°,默认是null

zoomToProductAndPick(modelId, productId, callback, customAngle)

聚焦构件并且Pick状态
Parameters:
Name Type Description
modelId *
productId *
callback * 飞行结束回调,默认值null
customAngle Object 自定义固化视角,包括俯仰角和倾斜角,用x和y来表示,例如:{x:45,y:45},该对象表示相机视角固定为 俯仰角(绕X轴)45°+倾斜角(绕Y轴)45°,默认是null

zoomToProductAndPosition(position, modelId, productId, time)

飞行到某个位置,中心点设置为某个构件bbox中心
Parameters:
Name Type Description
position * 相机的最终位置
modelId * 模型id
productId * 构件id
time * 飞行时长 毫秒 默认1500

zoomToProducts(modelId, productIds, fly, callback, customAngle)

聚焦多个构件的bbox
Parameters:
Name Type Description
modelId Number 模型ID
productIds Array 构件ID数组
fly Boolean 是否飞行动画,默认true
callback function 飞行动画结束后的回调函数,默认null
customAngle Object 自定义固化视角,包括俯仰角和倾斜角,用x和y来表示,例如:{x:45,y:45},该对象表示相机视角固定为 俯仰角(绕X轴)45°+倾斜角(绕Y轴)45°,默认是null

zoomToRoom(modelId, roomId)

聚焦定位至房间
Parameters:
Name Type Description
modelId Number
roomId Number