Class: SectioningManager
剖切管理类 @主要功能 添加剖切面或剖切盒,移除剖切等。
Examples
typescript
this.sectioningManager = cloud.getSectioningManager(); 在CreateApp时调用
this.sectioningManager = cloud.getSectioningManager(); 在CreateApp时调用
Hierarchy
Callable
↳
SectioningManager
Methods
setChangedCallback
▸ setChangedCallback(fn
): void
Details
设置操作剖切轴鼠标左键弹起的回调函数
Examples
调用示例:
ts
function changeFinished(re: Transform) {
console.log(re)
}
cloud.sectioningManager.setChangedCallback(changeFinished)
function changeFinished(re: Transform) {
console.log(re)
}
cloud.sectioningManager.setChangedCallback(changeFinished)
Parameters
Name | Type | Description |
---|---|---|
fn | (SectionInfo : Transform ) => void | 回调函数,SectionInfo指剖切面或盒的Transform |
Returns
void
addPlaneSection
▸ addPlaneSection(sectionPos
, operationNode
, dir
, state
): Promise
<SectionObject
>
Details
添加剖切面
Examples
js
//六个标准方向(写的方向就是对应要剖切的方向,保留的是相反的方向,如Vector3(0, -1, 0)剖切方向为上)
//Vector3(0, -1, 0))//上
//Vector3(0, 1, 0))//下
//Vector3(1, 0, 0)//西
//Vector3(-1, 0, 0))//东
//Vector3(0, 0, 1)//北
//Vector3(0, 0, -1)//南
let sceManager =await cloud.getSceneManager();
var rootNode = await sceManager.getRootNode3D();//获取根节点
await cloud.getSectioningManager()
const dir=new Vector3(1,0,0);
const pos=new Vector3(1,0,1);
const state: NodeState = {
color: '0xFF0000',
opacity: 100,
show: true,
}
let obj= await cloud.sectioningManager.addPlaneSection(pos,rootNode!,dir,state)
//六个标准方向(写的方向就是对应要剖切的方向,保留的是相反的方向,如Vector3(0, -1, 0)剖切方向为上)
//Vector3(0, -1, 0))//上
//Vector3(0, 1, 0))//下
//Vector3(1, 0, 0)//西
//Vector3(-1, 0, 0))//东
//Vector3(0, 0, 1)//北
//Vector3(0, 0, -1)//南
let sceManager =await cloud.getSceneManager();
var rootNode = await sceManager.getRootNode3D();//获取根节点
await cloud.getSectioningManager()
const dir=new Vector3(1,0,0);
const pos=new Vector3(1,0,1);
const state: NodeState = {
color: '0xFF0000',
opacity: 100,
show: true,
}
let obj= await cloud.sectioningManager.addPlaneSection(pos,rootNode!,dir,state)
Parameters
Name | Type | Description |
---|---|---|
sectionPos | Vector3 | 剖切面的位置 |
operationNode | Node | 被剖切的节点对象,为空时对根节点进行剖切 |
dir | Vector3 | 剖切面的方向 |
state | NodeState | 剖切面的颜色(ARGB),显隐 |
Returns
Promise
<SectionObject
>
剖切操作对象
addBoxSection
▸ addBoxSection(transform
, operationNode
, state
): Promise
<SectionObject
>
Details
添加剖切盒
Examples
js
await cloud.getSectioningManager()
let sceManager =await cloud.getSceneManager();
var rootNode = await sceManager.getRootNode3D();//获取根节点
const ope = await sceManager.getNodeOperator()
const box = await ope.getLocalBox(rootNode!)
box.expandByScalar(1.125) //推荐参数 1.125(对剖切盒放大)
const trans: Transform = box.boxToTransform()
const state: NodeState = {
color: '0xFF0000',
opacity: 100,
show: true,
}
let obj= await cloud.sectioningManager.addBoxSection(trans,rootNode!,state);
await cloud.getSectioningManager()
let sceManager =await cloud.getSceneManager();
var rootNode = await sceManager.getRootNode3D();//获取根节点
const ope = await sceManager.getNodeOperator()
const box = await ope.getLocalBox(rootNode!)
box.expandByScalar(1.125) //推荐参数 1.125(对剖切盒放大)
const trans: Transform = box.boxToTransform()
const state: NodeState = {
color: '0xFF0000',
opacity: 100,
show: true,
}
let obj= await cloud.sectioningManager.addBoxSection(trans,rootNode!,state);
Parameters
Name | Type | Description |
---|---|---|
transform | Transform | 剖切盒的位置姿态 |
operationNode | Node | 被剖切的节点对象,为空时对根节点进行剖切 |
state | NodeState | 剖切盒的颜色(ARGB),显隐 |
Returns
Promise
<SectionObject
>
剖切操作对象
remove
▸ remove(sectionObj
): Promise
<any
>
Details
移除此剖切操作
Examples
js
await cloud.getSectioningManager()
let sceManager =await cloud.getSceneManager();
var rootNode = await sceManager.getRootNode3D();//获取根节点
const translation1 = new Vector3(10, 0, 0)
const eulerAngle1 = new Euler(0, 0, 0)
const scaling1 = new Vector3(1, 1, 1)
const trans = new Transform(translation1, eulerAngle1, scaling1)
const state: NodeState = {
color: '0xFF0000',
opacity: undefined,
show: true,
}
let obj= await cloud.sectioningManager.addBoxSection(trans,rootNode!,state);
await cloud.sectioningManager.remove(obj)
await cloud.getSectioningManager()
let sceManager =await cloud.getSceneManager();
var rootNode = await sceManager.getRootNode3D();//获取根节点
const translation1 = new Vector3(10, 0, 0)
const eulerAngle1 = new Euler(0, 0, 0)
const scaling1 = new Vector3(1, 1, 1)
const trans = new Transform(translation1, eulerAngle1, scaling1)
const state: NodeState = {
color: '0xFF0000',
opacity: undefined,
show: true,
}
let obj= await cloud.sectioningManager.addBoxSection(trans,rootNode!,state);
await cloud.sectioningManager.remove(obj)
Parameters
Name | Type | Description |
---|---|---|
sectionObj | SectionObject | 剖切操作对象 |
Returns
Promise
<any
>