Reference Source
public class | source

Fresnel

Extends:

Component → Fresnel

Configures Fresnel effects for PhongMaterials.

Fresnels are attached to PhongMaterials, which are attached to Meshes.

Usage

In the example below we'll create a Mesh with a PhongMaterial that applies a Fresnel to its alpha channel to give a glasss-like effect.

[Run this example]

import {Viewer, Mesh, buildTorusGeometry,
     ReadableGeometry, PhongMaterial, Texture, Fresnel} from "xeokit-sdk.es.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];

new Mesh(viewer.scene, {
     geometry: new ReadableGeometry(viewer.scene, buildTorusGeometry({
         center: [0, 0, 0],
         radius: 1.5,
         tube: 0.5,
         radialSegments: 32,
         tubeSegments: 24,
         arc: Math.PI * 2.0
     }),
     material: new PhongMaterial(viewer.scene, {
         alpha: 0.9,
         alphaMode: "blend",
         ambient: [0.0, 0.0, 0.0],
         shininess: 30,
         diffuseMap: new Texture(viewer.scene, {
             src: "textures/diffuse/uvGrid2.jpg"
         }),
         alphaFresnel: new Fresnel(viewer.scene, {
v               edgeBias: 0.2,
             centerBias: 0.8,
             edgeColor: [1.0, 1.0, 1.0],
             centerColor: [0.0, 0.0, 0.0],
             power: 2
         })
     })
});

Constructor Summary

Public Constructor
public

constructor(owner: Component, cfg: *)

Member Summary

Public Members
public set

Sets the Fresnel's center bias.

Default value is 1.

public get

Gets the Fresnel's center bias.

Default value is 1.

public set

Sets the Fresnel's center color.

Default value is [1.0, 1.0, 1.0].

public get

Gets the Fresnel's center color.

Default value is [1.0, 1.0, 1.0].

public set

Sets the Fresnel's edge bias.

Default value is 0.

public get

Gets the Fresnel's edge bias.

Default value is 0.

public set

Sets the Fresnel's edge color.

Default value is [0.0, 0.0, 0.0].

public get

Gets the Fresnel's edge color.

Default value is [0.0, 0.0, 0.0].

public set

Sets the Fresnel's power.

Default value is 1.

public get

Gets the Fresnel's power.

Default value is 1.

public get

JavaScript class name for this Component.

Method Summary

Public Methods
public

Destroys this Fresnel.

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

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

cfg *
  • optional

Configs

cfg.id String
  • optional

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

cfg.edgeColor Number[]
  • optional
  • default: [ 0.0, 0.0, 0.0 ]

Color used on edges.

cfg.centerColor Number[]
  • optional
  • default: [ 1.0, 1.0, 1.0 ]

Color used on center.

cfg.edgeBias Number
  • optional
  • default: 0

Bias at the edge.

cfg.centerBias Number
  • optional
  • default: 1

Bias at the center.

cfg.power Number
  • optional
  • default: 0

The power.

Public Members

public set centerBias: Number source

Sets the Fresnel's center bias.

Default value is 1.

public get centerBias: Number source

Gets the Fresnel's center bias.

Default value is 1.

public set centerColor: Number[] source

Sets the Fresnel's center color.

Default value is [1.0, 1.0, 1.0].

public get centerColor: Number[] source

Gets the Fresnel's center color.

Default value is [1.0, 1.0, 1.0].

public set edgeBias: Number source

Sets the Fresnel's edge bias.

Default value is 0.

public get edgeBias: Number source

Gets the Fresnel's edge bias.

Default value is 0.

public set edgeColor: Number[] source

Sets the Fresnel's edge color.

Default value is [0.0, 0.0, 0.0].

public get edgeColor: Number[] source

Gets the Fresnel's edge color.

Default value is [0.0, 0.0, 0.0].

public set power: Number source

Sets the Fresnel's power.

Default value is 1.

public get power: Number source

Gets the Fresnel's power.

Default value is 1.

public get type: String source

JavaScript class name for this Component.

Public Methods

public destroy() source

Destroys this Fresnel.

Override:

Component#destroy