import {Fresnel} from '@xeokit/xeokit-sdk/src/viewer/scene/materials/Fresnel.js'
Fresnel
Extends:
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.
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 |
|
public get |
Gets the Fresnel's center bias. Default value is |
|
public set |
Sets the Fresnel's center color. Default value is |
|
public get |
Gets the Fresnel's center color. Default value is |
|
public set |
Sets the Fresnel's edge bias. Default value is |
|
public get |
Gets the Fresnel's edge bias. Default value is |
|
public set |
Sets the Fresnel's edge color. Default value is |
|
public get |
Gets the Fresnel's edge color. Default value is |
|
public set |
Sets the Fresnel's power. Default value is |
|
public get |
Gets the Fresnel's power. Default value is |
|
public get |
JavaScript class name for this Component. |
Method Summary
Public Methods | ||
public |
destroy() 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 |
destroy() Destroys this component. |
|
public |
Logs an error for this component to the JavaScript console. |
|
public |
Fires an event on this component. |
|
public |
Returns true if there are any subscribers to the given event on this component. |
|
public |
Tests if this component is of the given type, or is a subclass of the given type. |
|
public |
Logs a console debugging message for this component. |
|
public |
Cancels an event subscription that was previously made with Component#on or Component#once. |
|
public |
Subscribes to an event on this component. |
|
public |
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 |
Logs a warning for this component to the JavaScript console. |
Public Constructors
public constructor(owner: Component, cfg: *) source
Override:
Component#constructorParams:
Name | Type | Attribute | Description |
owner | Component | Owner component. When destroyed, the owner will destroy this Fresnel as well. |
|
cfg | * |
|
Configs |
cfg.id | String |
|
Optional ID, unique among all components in the parent scene, generated automatically when omitted. |
cfg.edgeColor | Number[] |
|
Color used on edges. |
cfg.centerColor | Number[] |
|
Color used on center. |
cfg.edgeBias | Number |
|
Bias at the edge. |
cfg.centerBias | Number |
|
Bias at the center. |
cfg.power | Number |
|
The power. |
Public Members
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 edgeColor: Number[] source
Sets the Fresnel's edge color.
Default value is [0.0, 0.0, 0.0]
.