SceneU3D

SceneU3D

一个U3D类型场景的抽象描述,场景即渲染2D数据、3D模型的虚拟画板. 所有的需要渲染的数据、模型对象都将作为子对象存储在这个场景中

Constructor

new SceneU3D(options)

Description:
  • 创建一个U3D场景实例

Parameters:

Name Type Description
options SceneU3D.ConstructorOptions

实例化引擎的参数对象

Members

(readonly) id :string

Description:
  • 获取U3D场景的ID

获取U3D场景的ID

Type:
  • string

Methods

addGroup(models) → {Group}

Description:
  • 向场景中添加一个群组对象实例

Parameters:

Name Type Description
models Array.<Object3D>

要添加到群组的模型对象实例

Returns:
Group -

返回成功添加至场景中的群组对象实例

addShadowPlane(options)

Description:
  • 添加一个平面,用于辅助获取模型阴影

Parameters:

Name Type Description
options Object

描述数据源信息的对象,包括以下字段

Properties
Name Type Description
visible boolean

默认是否显示阴影平面

width number

阴影平面的高度

height number

阴影平面的高度

position Array

阴影平面的位置

rotation Array

阴影平面的旋转参数

scale Array

阴影平面的缩放参数

cloneSource(options) → {Object3D}

Description:
  • 克隆指定id的模型、模型组、图层

Parameters:

Name Type Description
options Object
Returns:
Object3D -

返回一个数据源所克隆的对象

getSource(options) → {Object3D}

Description:
  • 从场景中获取模型、数据、文字、标签等数据源

Parameters:

Name Type Attributes Description
options Object
object.id string <optional>

资源ID

object.groupId string <optional>

群组ID,当指定群组ID时,该API将会在群组对象中,查找指定ID的对象

Returns:
Object3D -

返回一个数据源对象

resize(width, height)

Description:
  • 重新调整场景的尺寸大小

Parameters:

Name Type Description
width number

场景的宽度

height number

场景的高度

setBackground(options)

Description:
  • 设置场景的背景色或图片,其中背景色,目前只能设置垂直渐变色

Parameters:

Name Type Description
options Object

场景背景色设置参数,包含以下字段

Properties
Name Type Attributes Description
color string <optional>

场景为纯色背景时的颜色

startColor string <optional>

场景为垂直渐变背景时的起始颜色

endColor string <optional>

场景为垂直渐变背景时的截止颜色

setClearColor(rgb)

Description:
  • 设置渲染器笔刷颜色

Parameters:

Name Type Description
rgb string

rgb颜色

setVisible(state)

Description:
  • 设置显示或隐藏当前场景

Parameters:

Name Type Description
state boolean

Type Definitions

ConstructorOptions

Description:
  • 创建并初始化U3D场景(SceneU3D)实例所需的参数

Properties:
Name Type Attributes Default Description
container string | HTMLDivElement

场景容器,必须是一个HTML DIV元素对象,或HTML DIV元素对象的ID

sceneType SceneType <optional>
SceneType.U3D

场景类型

active boolean <optional>
true

默认是否激活当前场景

renderingMode RenderingMode <optional>
RenderingMode.RenderLoop

场景渲染模式

clearColor string <optional>
'#FFFFFF'

场景渲染器的画刷颜色,即每一帧清空画布时所用的颜色

bgTransparent boolean <optional>
false

场景背景是否透明

bgColor string <optional>

场景背景色,目前仅支持纯色和垂直渐变色

envMap string <optional>

场景环境贴图,应该是一个有效的URL

camera PerspectiveCamera | OrthographicCamera <optional>

场景中的默认相机

ambientLight AmbientLight <optional>

场景环境光

directionalLight DirectionalLight <optional>

场景平行光

hemisphereLight HemisphereLight <optional>

场景半球光

创建并初始化U3D场景(SceneU3D)实例所需的参数

Type:
  • Object