Reference Source
public class | source

SectionPlane

Extends:

Component → SectionPlane

An arbitrarily-aligned World-space clipping plane.

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

active(value: Boolean)

Sets if this SectionPlane is active or not.

public get

Gets if this SectionPlane is active or not.

public set

dir(value: Number[])

Sets the direction of this SectionPlane's plane.

Default value is [0, 0, -1].

public get

dir: Number[]: *

Gets the direction of this SectionPlane's plane.

Default value is [0, 0, -1].

public get

dist: Number: *

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

pos(value: Number[])

Sets the World-space position of this SectionPlane's plane.

Default value is [0, 0, 0].

public get

pos: Number[]: *

Gets the World-space position of this SectionPlane's plane.

Default value is [0, 0, 0].

Method Summary

Public Methods
public
public

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

Destroys this component.

public

error(message: String)

Logs an error for this component to the JavaScript console.

public

fire(event: String, value: Object, forget: Boolean)

Fires an event on this component.

public

Returns true if there are any subscribers to the given event on this component.

public

isType(type: *): *: Boolean

Tests if this component is of the given type, or is a subclass of the given type.

public

log(message: String)

Logs a console debugging message for this component.

public

off(subId: String)

Cancels an event subscription that was previously made with Component#on or Component#once.

public

on(event: String, callback: Function, scope: Object): String

Subscribes to an event on this component.

public

once(event: String, callback: Function, scope: Object)

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

warn(message: String)

Logs a warning for this component to the JavaScript console.

Public Constructors

public constructor(owner: Component, cfg: *) source

Override:

Component#constructor

Params:

NameTypeAttributeDescription
owner Component
  • optional

Owner component. When destroyed, the owner will destroy this SectionPlane as well.

cfg *
  • optional

SectionPlane configuration

cfg.id String
  • optional

Optional ID, unique among all components in the parent Scene, generated automatically when omitted.

cfg.active Boolean
  • optional
  • default: true

Indicates whether or not this SectionPlane is active.

cfg.pos Number[]
  • optional
  • default: [0,0,0]

World-space position of the SectionPlane.

cfg.dir Number[]
  • optional
  • default: [0,0,-1]

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.

Return:

Boolean

Returns true if active.

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].

Return:

Number[]

value Current direction.

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.

Return:

Number

public set pos(value: Number[]) source

Sets the World-space position of this SectionPlane's plane.

Default value is [0, 0, 0].

public get pos: Number[]: * source

Gets the World-space position of this SectionPlane's plane.

Default value is [0, 0, 0].

Return:

Number[]

Current position.

Public Methods

public destroy() source

Destroys this component.

Override:

Component#destroy

public flipDir() source

Inverts the direction of SectionPlane#dir.