Reference Source
public class | source

LineSet

Extends:

Component → LineSet

A set of 3D line segments.

Usage

In the example below, we'll load the Schependomlaan model, then use a LineSet to show a grid underneath the model.

[Run this example]

import {Viewer, XKTLoaderPlugin, LineSet, buildGridGeometry} from "https://cdn.jsdelivr.net/npm/@xeokit/xeokit-sdk/dist/xeokit-sdk.es.min.js";

const viewer = new Viewer({
     canvasId: "myCanvas",
     transparent: true
 });

const camera = viewer.camera;

viewer.camera.eye = [-2.56, 8.38, 8.27];
viewer.camera.look = [13.44, 3.31, -14.83];
viewer.camera.up = [0.10, 0.98, -0.14];

const xktLoader = new XKTLoaderPlugin(viewer);

const model = xktLoader.load({
     id: "myModel",
     src: "../assets/models/xkt/v8/ifc/Schependomlaan.ifc.xkt",
     position: [0,1,0],
     edges: true,
     saoEnabled: true
 });

const geometryArrays = buildGridGeometry({
     size: 100,
     divisions: 30
 });

new LineSet(viewer.scene, {
     positions: geometryArrays.positions,
     indices: geometryArrays.indices
});

Constructor Summary

Public Constructor
public

constructor(owner: Component, cfg: *)

Creates a new LineSet.

Member Summary

Public Members
public get

indices: Number[]: *

Gets the vertex indices of the lines in this LineSet.

public get

Gets the 3D World-space vertex positions of the lines in this LineSet.

public set

visible(visible: Boolean)

Sets if this LineSet is visible.

public get

Gets if this LineSet is visible.

Method Summary

Public Methods
public

Destroys this LineSet.

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

Creates a new LineSet.

Registers the LineSet in Scene#lineSets; causes Scene to fire a "lineSetCreated" event.

Override:

Component#constructor

Params:

NameTypeAttributeDescription
owner Component
  • optional

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

cfg *
  • optional

LineSet configuration

cfg.id String
  • optional

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

cfg.positions Number[]

World-space 3D vertex positions.

cfg.indices Number[]
  • optional

Indices to connect positions into line segments. Note that these are separate line segments, not a polyline.

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

The color of this LineSet. This is both emissive and diffuse.

cfg.visible Boolean
  • optional
  • default: true

Indicates whether or not this LineSet is visible.

cfg.opacity Number
  • optional
  • default: 1.0

LineSet's initial opacity factor.

Public Members

public get indices: Number[]: * source

Gets the vertex indices of the lines in this LineSet.

Return:

Number[]

public get positions: Number[]: * source

Gets the 3D World-space vertex positions of the lines in this LineSet.

Return:

Number[]

public set visible(visible: Boolean) source

Sets if this LineSet is visible.

Default value is true.

public get visible: Boolean: * source

Gets if this LineSet is visible.

Default value is true.

Return:

Boolean

Returns true if visible.

Public Methods

public destroy() source

Destroys this LineSet.

Removes the LineSet` from Scene#lineSets; causes Scene to fire a "lineSetDestroyed" event.

Override:

Component#destroy