import {SectionPlane} from '@xeokit/xeokit-sdk/src/viewer/scene/sectionPlane/SectionPlane.js'
SectionPlane
Extends:
An arbitrarily-aligned World-space clipping plane.
- Slices portions off objects to create cross-section views or reveal interiors.
- Registered by SectionPlane#id in Scene#sectionPlanes.
- Indicates World-space position in SectionPlane#pos and orientation in SectionPlane#dir.
- Discards elements from the half-space in the direction of SectionPlane#dir.
- Can be be enabled or disabled via SectionPlane#active.
Usage
In the example below, we'll create two SectionPlanes to slice a model loaded from glTF. Note that we could also create them using a SectionPlanesPlugin.
import {Viewer, GLTFLoaderPlugin, SectionPlane} from "xeokit-sdk.es.js";
const viewer = new Viewer({
canvasId: "myCanvas"
});
const gltfLoaderPlugin = new GLTFModelsPlugin(viewer, {
id: "GLTFModels"
});
const model = gltfLoaderPlugin.load({
id: "myModel",
src: "./models/gltf/mygltfmodel.gltf"
});
// Create a SectionPlane on negative diagonal
const sectionPlane1 = new SectionPlane(viewer.scene, {
pos: [1.0, 1.0, 1.0],
dir: [-1.0, -1.0, -1.0],
active: true
}),
// Create a SectionPlane on positive diagonal
const sectionPlane2 = new SectionPlane(viewer.scene, {
pos: [-1.0, -1.0, -1.0],
dir: [1.0, 1.0, 1.0],
active: true
});
Constructor Summary
Public Constructor | ||
public |
constructor(owner: Component, cfg: *) |
Member Summary
Public Members | ||
public set |
Sets if this SectionPlane is active or not. |
|
public get |
Gets if this SectionPlane is active or not. |
|
public set |
Sets the direction of this SectionPlane's plane. Default value is |
|
public get |
Gets the direction of this SectionPlane's plane. Default value is |
|
public get |
Gets this SectionPlane's distance to the origin of the World-space coordinate system. This is the dot product of SectionPlane#pos and SectionPlane#dir and is automatically re-calculated each time either of two properties are updated. |
|
public set |
Sets the World-space position of this SectionPlane's plane. Default value is |
|
public get |
Gets the World-space position of this SectionPlane's plane. Default value is |
Method Summary
Public Methods | ||
public |
destroy() |
|
public |
flipDir() Inverts the direction of SectionPlane#dir. |
Inherited Summary
From class Component | ||
public get |
The Component that owns the lifecycle of this Component, if any. |
|
public |
True as soon as this Component has been destroyed |
|
public |
ID of this Component, unique within the Scene. |
|
public |
meta: * Arbitrary, user-defined metadata on this component. |
|
public |
The parent Scene that contains this Component. |
|
public |
The viewer that contains this Scene. |
|
public |
clear() Destroys all Components that are owned by this. |
|
public |
destroy() Destroys this component. |
|
public |
Logs an error for this component to the JavaScript console. |
|
public |
Fires an event on this component. |
|
public |
Returns true if there are any subscribers to the given event on this component. |
|
public |
Tests if this component is of the given type, or is a subclass of the given type. |
|
public |
Logs a console debugging message for this component. |
|
public |
Cancels an event subscription that was previously made with Component#on or Component#once. |
|
public |
Subscribes to an event on this component. |
|
public |
Subscribes to the next occurrence of the given event, then un-subscribes as soon as the event is subIdd. |
|
public |
scheduleTask(task: *) Schedule a task to perform on the next browser interval |
|
public |
Logs a warning for this component to the JavaScript console. |
Public Constructors
public constructor(owner: Component, cfg: *) source
Override:
Component#constructorParams:
Name | Type | Attribute | Description |
owner | Component |
|
Owner component. When destroyed, the owner will destroy this SectionPlane as well. |
cfg | * |
|
SectionPlane configuration |
cfg.id | String |
|
Optional ID, unique among all components in the parent Scene, generated automatically when omitted. |
cfg.active | Boolean |
|
Indicates whether or not this SectionPlane is active. |
cfg.pos | Number[] |
|
World-space position of the SectionPlane. |
cfg.dir | Number[] |
|
Vector perpendicular to the plane surface, indicating the SectionPlane plane orientation. |
Public Members
public set active(value: Boolean) source
Sets if this SectionPlane is active or not.
Default value is true
.
public get active: Boolean: * source
Gets if this SectionPlane is active or not.
Default value is true
.
public set dir(value: Number[]) source
Sets the direction of this SectionPlane's plane.
Default value is [0, 0, -1]
.
public get dir: Number[]: * source
Gets the direction of this SectionPlane's plane.
Default value is [0, 0, -1]
.
public get dist: Number: * source
Gets this SectionPlane's distance to the origin of the World-space coordinate system.
This is the dot product of SectionPlane#pos and SectionPlane#dir and is automatically re-calculated each time either of two properties are updated.