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} from "../src/viewer/Viewer.js";
import {GLTFLoaderPlugin} from "../src/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.js";
import {SectionPlane} from "../src/sectionPlane/SectionPlane.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 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

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

viewer: *

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

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