Reference Source
public class | source

LinesMaterial

Extends:

ComponentMaterial → LinesMaterial

Configures the shape of "lines" geometry primitives.

Usage

In the example below, we'll customize the Scene's global LinesMaterial, then use an XKTLoaderPlugin to load a model containing line segments.

[Run this example]

import {Viewer} from "../src/viewer/Viewer.js";
import {XKTLoaderPlugin} from "../src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js";

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

viewer.scene.camera.eye = [0, 0, 5];
viewer.scene.camera.look = [0, 0, 0];
viewer.scene.camera.up = [0, 1, 0];

viewer.scene.linesMaterial.lineWidth = 3;

const xktLoader = new XKTLoaderPlugin(viewer);

const model = xktLoader.load({
     id: "myModel",
     src: "./models/xkt/duplex/duplex.xkt",
     metaModelSrc: "./metaModels/duplex/metaModel.json"
});

Constructor Summary

Public Constructor
public

constructor(owner: Component, cfg: *)

Member Summary

Public Members
public set

Sets line width.

public get

Gets the line width.

public set

Selects a preset LinesMaterial configuration.

public get

The current preset LinesMaterial configuration.

public get

Gets available LinesMaterial presets.

Method Summary

Public Methods
public

Destroys this LinesMaterial.

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

warn(message: String)

Logs a warning for this component to the JavaScript console.

From class Material
public

Public Constructors

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

Override:

Material#constructor

Params:

NameTypeAttributeDescription
owner Component

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

cfg *
  • optional

The LinesMaterial configuration

cfg.id String
  • optional

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

cfg.lineWidth Number
  • optional
  • default: 1

Line width in pixels.

cfg.preset String
  • optional

Selects a preset LinesMaterial configuration - see LinesMaterial#presets.

Public Members

public set lineWidth: Number source

Sets line width.

Default value is 1 pixels.

public get lineWidth: Number source

Gets the line width.

Default value is 1 pixels.

public set preset: String source

Selects a preset LinesMaterial configuration.

Default value is "default".

public get preset: String source

The current preset LinesMaterial configuration.

Default value is "default".

public get presets: Object source

Gets available LinesMaterial presets.

Public Methods

public destroy() source

Destroys this LinesMaterial.

Override:

Material#destroy