节点操作管理器 NodeOperator
节点操作管理器是用于控制云渲染节点操作的工具,通过获取该管理器,用户可以方便地进行节点操作的控制和管理。 该工具的主要功能包括:
- 设置节点状态
- 获取节点状态
- 恢复节点状态为节点的初始状态
- 获取节点属性
- 设置节点轮廓线
- 获取节点Local包围盒
- 获取节点Scene包围盒
- 获取节点LocalTransform
- 设置节点LocalTransform
- 获取绕任意轴旋转的transform
我们将提供详细的使用指南和功能说明,帮助用户更好地使用该工具。
NodeOperator
用户可以调用云渲染实例 cloud
上的 getSceneManager()
方法来获取 getNodeOperator()
,从而获取节点操作接口NodeOperator
。
const sceManager = await cloud.getSceneManager()
const operator = await sceManager.getNodeOperator()
const sceManager = await cloud.getSceneManager()
const operator = await sceManager.getNodeOperator()
设置节点状态 | setState
- 说明:设置模型节点的状态,变色、透明、显示隐藏
我们可以调用 NodeOperator
上面的 setState
方法来设置节点的变色、透明、显示、隐藏。
- 参数说明
Name | Type | Description |
---|---|---|
nodes | Node [] | 节点数组 |
state | NodeState | 节点状态 |
TIP
需要注意的是,设置节点状态的参数NodeState
,需要符合数据格式要求 。
调用示例:
const sceManager = await cloud.getSceneManager()
const ope = await sceManager.getNodeOperator()
const state: NodeState = {
color: '0xFFFF0000',
opacity: 100,
show: true,
}
await ope.setState([node!], state)
const sceManager = await cloud.getSceneManager()
const ope = await sceManager.getNodeOperator()
const state: NodeState = {
color: '0xFFFF0000',
opacity: 100,
show: true,
}
await ope.setState([node!], state)
获取节点状态 | getState
- 说明:获取节点状态
我们可以调用 NodeOperator
上面的 getState
方法来获取节点状态。
- 参数说明
Name | Type | Description |
---|---|---|
node | Node | 节点 |
调用示例:
const sceManager =await cloud.getSceneManager();
const ope = await sceManager.getNodeOperator();
const node = sceManager.getRootNode3D()
const nodeState = await ope.getState(node)
const sceManager =await cloud.getSceneManager();
const ope = await sceManager.getNodeOperator();
const node = sceManager.getRootNode3D()
const nodeState = await ope.getState(node)
恢复节点状态为节点的初始状态 | unSetState
- 说明:取消节点设置,恢复节点状态为节点的初始状态
我们可以调用 NodeOperator
上面的 unSetState
方法来取消设置节点的状态。
- 参数说明
Name | Type | Description |
---|---|---|
nodes | Node [] | 节点数组 |
state | ('color' | 'opacity' |
调用示例:
const sceManager = await cloud.getSceneManager()
const ope = await sceManager.getNodeOperator()
const state = ['color', 'opacity', 'show']
await ope.unSetState([node!], state)
const sceManager = await cloud.getSceneManager()
const ope = await sceManager.getNodeOperator()
const state = ['color', 'opacity', 'show']
await ope.unSetState([node!], state)
获取节点属性 | getAttribute
- 说明:获取选中节点的属性
我们可以调用 NodeOperator
上面的 getAttribute
方法获取选中节点的属性。
- 参数说明
Name | Type | Description |
---|---|---|
node | Node | 节点 |
节点属性
在云渲染中,节点属性通常指节点的详细信息,例如节点属性名称、属性值等。
调用示例:
const sceManager = await cloud.getSceneManager()
const ope = await sceManager.getNodeOperator()
const node: Node = await sceManager.getRootNode3D()
const nodeAtt = await ope.getAttribute(node)
const sceManager = await cloud.getSceneManager()
const ope = await sceManager.getNodeOperator()
const node: Node = await sceManager.getRootNode3D()
const nodeAtt = await ope.getAttribute(node)
设置节点轮廓线 | showOutLine
- 说明:设置节点轮廓线显示、隐藏
我们可以调用 NodeOperator
上面的 showOutLine
方法来设置节点轮廓线,一般在双击回调函数时设置,可以查看当前点击的节点。
- 参数说明
Name | Type | Description |
---|---|---|
node | Node | 节点 |
isShow | boolean | 是否显示 |
节点属性
在云渲染中,设置节点轮廓线可以用于在场景中快速定位和识别节点。需要注意的是,只有在渲染场景时,节点轮廓线才会显示出来。如果希望在场景中看到节点轮廓线,需要在生成场景时设置节点的相应的参数。
调用示例:
const sceManager = await cloud.getSceneManager()
const ope = await sceManager.getNodeOperator()
const node: Node = await sceManager.getRootNode3D()
await ope.showOutLine(node!, true)
const sceManager = await cloud.getSceneManager()
const ope = await sceManager.getNodeOperator()
const node: Node = await sceManager.getRootNode3D()
await ope.showOutLine(node!, true)
获取节点Local包围盒 | getLocalBox
- 说明:获取节点Local包围盒
我们可以调用 NodeOperator
上面的 getLocalBox
方法来获取节点Local包围盒。
- 参数说明
Name | Type | Description |
---|---|---|
node | Node | 节点 |
节点属性
在云渲染中,Local 包围盒是指节点在本地坐标系中的包围盒,通常用于节点的碰撞检测、剖切等操作。需要注意的是,只有在模型节点加载完成后才能够获取到其 Local 包围盒。
调用示例:
const sceManager = await cloud.getSceneManager()
const ope = await sceManager.getNodeOperator()
const node: Node = await sceManager.getRootNode3D()
const nodeBox = await ope.getLocalBox(node!)
const sceManager = await cloud.getSceneManager()
const ope = await sceManager.getNodeOperator()
const node: Node = await sceManager.getRootNode3D()
const nodeBox = await ope.getLocalBox(node!)
获取节点Scene包围盒 | getSceneBox
- 说明:获取节点Scene包围盒
我们可以调用 NodeOperator
上面的 getSceneBox
方法来获取节点Scene包围盒。
- 参数说明
Name | Type | Description |
---|---|---|
node | Node | 节点 |
调用示例:
const sceManager =await cloud.getSceneManager();
const ope = await sceManager.getNodeOperator();
const node = await sceManager.getRootNode3D()
const nodeBox = await ope.getSceneBox(node!)
const sceManager =await cloud.getSceneManager();
const ope = await sceManager.getNodeOperator();
const node = await sceManager.getRootNode3D()
const nodeBox = await ope.getSceneBox(node!)
获取节点LocalTransform | getLocalTransform
- 说明:获取节点LocalTransform
我们可以调用 NodeOperator
上面的 getLocalTransform
方法来获取节点LocalTransform。
- 参数说明
Name | Type | Description |
---|---|---|
node | Node | 节点 |
节点属性
在云渲染中,Local Transform 是指节点在本地坐标系中的变换,包括位置、旋转和缩放。需要注意的是,只有在节点加载完成后才能够获取到其 Local Transform。
调用示例:
const sceManager = await cloud.getSceneManager()
const ope = await sceManager.getNodeOperator()
const node: Node = await sceManager.getRootNode3D()
const nodeTrans = await ope.getLocalTransform(node!)
const sceManager = await cloud.getSceneManager()
const ope = await sceManager.getNodeOperator()
const node: Node = await sceManager.getRootNode3D()
const nodeTrans = await ope.getLocalTransform(node!)
设置节点LocalTransform | setLocalTransform
- 说明:设置节点LocalTransform
我们可以调用 NodeOperator
上面的 setLocalTransform
方法来设置节点LocalTransform。
参数说明 | Name | Type | Description | | :------ | :------ | :------ | |
node
|Node
| 节点 | |trans
|Transform
| 变换信息Transform |调用示例:
tsconst sceManager = await cloud.getSceneManager() const ope = await sceManager.getNodeOperator() const node: Node = await sceManager.getRootNode3D() const nodeTrans = await ope.getLocalTransform(node!)
const sceManager = await cloud.getSceneManager() const ope = await sceManager.getNodeOperator() const node: Node = await sceManager.getRootNode3D() const nodeTrans = await ope.getLocalTransform(node!)
获取绕任意轴旋转的transform | transformRotateByAxis
- 说明:获取绕任意轴旋转的transform
我们可以调用 NodeOperator
上面的 transformRotateByAxis
方法来获取绕任意轴旋转的transform。
- 参数说明
Name | Type | Description |
---|---|---|
trans | Transform | 初始tranformTransform |
pos | Vector3 | 坐标轴位置Vector3 |
direct | Vector3 | 坐标轴方向Vector3 |
degree | number | 旋转角度 |
调用示例:
const sceManager =await cloud.getSceneManager();
const ope = await sceManager.getNodeOperator();
const translation1 = new Vector3(1, 1, 1)
const eulerAngle1 = new Euler(90, 90, 90)
const scaling1 = new Vector3(1, 1, 1)
const trans = new Transform(translation1, eulerAngle1, scaling1)
const pos = new Vector3(1, 0, 0)
const direct = new Vector3(0, 1, 0)
const degree=90
await ope.transformRotateByAxis(trans, pos, direct,degree)
const sceManager =await cloud.getSceneManager();
const ope = await sceManager.getNodeOperator();
const translation1 = new Vector3(1, 1, 1)
const eulerAngle1 = new Euler(90, 90, 90)
const scaling1 = new Vector3(1, 1, 1)
const trans = new Transform(translation1, eulerAngle1, scaling1)
const pos = new Vector3(1, 0, 0)
const direct = new Vector3(0, 1, 0)
const degree=90
await ope.transformRotateByAxis(trans, pos, direct,degree)