Skip to content

NgtsGradientTexture

NgtsGradientTexture is a port of Drei’s GradientTexture which is a declarative THREE.CanvasTexture that attaches to map by default. You can use this to create gradient backgrounds.

Usage

import { NgtsGradientTexture } from 'angular-three-soba/abstractions';
<ngt-mesh>
<ngt-plane-geometry />
<ngt-mesh-basic-material>
<ngts-gradient-texture
[stops]="[0, 1]"
[colors]="['turquoise', 'mediumpurple']"
[options]="{ size: 1024 }"
/>
</ngt-mesh-basic-material>
</ngt-mesh>

Radial gradient

<ngt-mesh>
<ngt-plane-geometry />
<ngt-mesh-basic-material>
<ngts-gradient-texture
[stops]="[0, 0.5, 1]"
[colors]="['aquamarine', 'hotpink', 'yellow']"
[options]="{ size: 1024, width: 1024, type: 'radial', innerCircleRadius: 0, outerCircleRadius: 'auto' }"/>
</ngt-mesh-basic-material>
</ngt-mesh>

Inputs

name type description required
stops Array<number> An array of numbers that define the position of the color stops. These values must be between 0 and 1. yes
colors Array<THREE.ColorRepresentation> An array of colors that define the color of the gradient. These colors can be in any format that is accepted by THREE.Color. yes
attach NgtAttachable The attachment point of the texture on the parent. Default: 'map' no

Options

options input accepts any properties from THREE.CanvasTexture in addition to the following:

Properties

name type description
size number The size of the canvas texture in pixels. Default: 1024
width number The width of the canvas texture in pixels. Default: 16
type 'linear' | 'radial' The type of the gradient. Default: 'linear'
innerCircleRadius number The inner radius of the gradient. Default: 0
outerCircleRadius string | number The outer radius of the gradient. Default: 'auto'