@luma.gl/shadertools
Advanced tools
Comparing version 9.0.16 to 9.0.17
@@ -1,15 +0,26 @@ | ||
/// <reference types="node" /> | ||
import { NumberArray } from '@math.gl/types'; | ||
import { UniformFormat } from "../../types.js"; | ||
import { PropType } from "../filters/prop-types.js"; | ||
import { Sampler, Texture } from '@luma.gl/core'; | ||
export type UniformValue = number | boolean | Readonly<NumberArray>; | ||
import type { UniformTypes, UniformValue } from "../utils/uniform-types.js"; | ||
type Binding = unknown; | ||
export type UniformInfo = { | ||
format?: UniformFormat; | ||
} & PropType; | ||
type BindingKeys<T> = { | ||
[K in keyof T]: T[K] extends UniformValue ? never : K; | ||
}[keyof T]; | ||
type UniformKeys<T> = { | ||
[K in keyof T]: T[K] extends UniformValue ? K : never; | ||
}[keyof T]; | ||
export type PickBindings<T> = { | ||
[K in BindingKeys<Required<T>>]: T[K]; | ||
}; | ||
export type PickUniforms<T> = { | ||
[K in UniformKeys<Required<T>>]: T[K]; | ||
}; | ||
/** | ||
* A shader module definition object | ||
* @note Can be viewed as the ShaderModuleProps for a ShaderModuleInstance | ||
* @note `UniformsT` & `BindingsT` are deduced from `PropsT` by default. If | ||
* a custom type for `UniformsT` is used, `BindingsT` should be also be provided. | ||
*/ | ||
export type ShaderModule<PropsT extends Record<string, unknown> = Record<string, unknown>, UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>, BindingsT extends Record<string, Buffer | Texture | Sampler> = {}> = { | ||
export type ShaderModule<PropsT extends Record<string, any> = Record<string, any>, UniformsT extends Record<string, UniformValue> = PickUniforms<PropsT>, BindingsT extends Record<string, Binding> = PickBindings<PropsT>> = { | ||
/** Used for type inference not for values */ | ||
@@ -19,2 +30,4 @@ props?: Required<PropsT>; | ||
uniforms?: UniformsT; | ||
/** Used for type inference, not currently used for values */ | ||
bindings?: BindingsT; | ||
name: string; | ||
@@ -24,3 +37,3 @@ fs?: string; | ||
/** Uniform shader types @note: Both order and types MUST match uniform block declarations in shader */ | ||
uniformTypes?: Record<keyof UniformsT, UniformFormat>; | ||
uniformTypes?: Required<UniformTypes<UniformsT>>; | ||
/** Uniform JS prop types */ | ||
@@ -31,8 +44,3 @@ uniformPropTypes?: Record<keyof UniformsT, UniformInfo>; | ||
/** Function that maps props to uniforms & bindings */ | ||
getUniforms?: (props?: any, oldProps?: any) => Record<string, UniformValue>; | ||
/** uniform buffers, textures, samplers, storage, ... */ | ||
bindings?: Record<keyof BindingsT, { | ||
location: number; | ||
type: 'texture' | 'sampler' | 'uniforms'; | ||
}>; | ||
getUniforms?: (props?: Partial<PropsT>, prevUniforms?: UniformsT) => Partial<UniformsT & BindingsT>; | ||
defines?: Record<string, string | number>; | ||
@@ -58,2 +66,3 @@ /** Injections */ | ||
}; | ||
export {}; | ||
//# sourceMappingURL=shader-module.d.ts.map |
@@ -1,2 +0,4 @@ | ||
import type { ShaderModule, UniformValue } from "./shader-module.js"; | ||
import type { Binding } from '@luma.gl/core'; | ||
import type { PickBindings, PickUniforms, ShaderModule } from "./shader-module.js"; | ||
import type { UniformValue } from "../utils/uniform-types.js"; | ||
/** | ||
@@ -6,3 +8,3 @@ * A shaderpass is a shader module with additional information | ||
*/ | ||
export type ShaderPass<PropsT extends Record<string, unknown> = Record<string, unknown>, UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>> = ShaderModule<PropsT, UniformsT> & { | ||
export type ShaderPass<PropsT extends Record<string, any> = Record<string, any>, UniformsT extends Record<string, UniformValue> = PickUniforms<PropsT>, BindingsT extends Record<string, Binding> = PickBindings<PropsT>> = ShaderModule<PropsT, UniformsT, BindingsT> & { | ||
passes: ShaderPassData[]; | ||
@@ -9,0 +11,0 @@ }; |
@@ -0,7 +1,9 @@ | ||
import { Vector3, Matrix4 } from '@math.gl/core'; | ||
import { ShaderModule } from "../../lib/shader-module/shader-module.js"; | ||
import type { NumberArray3, NumberArray16 } from "../../lib/utils/uniform-types.js"; | ||
type ProjectionProps = { | ||
modelMatrix?: readonly number[]; | ||
viewMatrix?: readonly number[]; | ||
projectionMatrix?: readonly number[]; | ||
cameraPositionWorld?: readonly number[]; | ||
modelMatrix?: Readonly<Matrix4 | NumberArray16>; | ||
viewMatrix?: Readonly<Matrix4 | NumberArray16>; | ||
projectionMatrix?: Readonly<Matrix4 | NumberArray16>; | ||
cameraPositionWorld?: Readonly<Vector3 | NumberArray3>; | ||
}; | ||
@@ -8,0 +10,0 @@ /** |
@@ -1,3 +0,3 @@ | ||
import { NumberArray } from "../../../types.js"; | ||
import { ShaderModule } from "../../../lib/shader-module/shader-module.js"; | ||
import type { NumberArray3, NumberArray4 } from "../../../lib/utils/uniform-types.js"; | ||
/** | ||
@@ -14,5 +14,5 @@ * Props for the picking module, which depending on mode renders picking colors or highlighted item. | ||
/** Set to a picking color to visually highlight that item, or `null` to explicitly clear **/ | ||
highlightedObjectColor?: NumberArray | null; | ||
highlightedObjectColor?: NumberArray3 | null; | ||
/** Color of visual highlight of "selected" item */ | ||
highlightColor?: NumberArray; | ||
highlightColor?: NumberArray3 | NumberArray4; | ||
/** Color range 0-1 or 0-255 */ | ||
@@ -39,5 +39,5 @@ useFloatColors?: boolean; | ||
/** Set to a picking color to visually highlight that item */ | ||
highlightedObjectColor?: NumberArray; | ||
highlightedObjectColor?: NumberArray3; | ||
/** Color of visual highlight of "selected" item */ | ||
highlightColor?: NumberArray; | ||
highlightColor?: NumberArray4; | ||
}; | ||
@@ -44,0 +44,0 @@ /** |
@@ -6,3 +6,3 @@ // luma.gl | ||
// cyan color | ||
const DEFAULT_HIGHLIGHT_COLOR = new Float32Array([0, 1, 1, 1]); | ||
const DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1]; | ||
const vs = `\ | ||
@@ -125,3 +125,3 @@ uniform pickingUniforms { | ||
useFloatColors: true, | ||
highlightedObjectColor: new Float32Array([0, 0, 0]), | ||
highlightedObjectColor: [0, 0, 0], | ||
highlightColor: DEFAULT_HIGHLIGHT_COLOR | ||
@@ -128,0 +128,0 @@ }, |
@@ -1,3 +0,4 @@ | ||
import { NumericArray as NumberArray, Matrix4, Vector3 } from '@math.gl/core'; | ||
import { Matrix4, Vector3 } from '@math.gl/core'; | ||
import { ShaderModule } from "../../../lib/shader-module/shader-module.js"; | ||
import type { NumberArray3, NumberArray16 } from "../../../lib/utils/uniform-types.js"; | ||
/** | ||
@@ -8,5 +9,5 @@ * @note Projection uniforms are normally constant across draw calls, | ||
export type ProjectionProps = { | ||
viewMatrix?: Readonly<Matrix4 | NumberArray>; | ||
projectionMatrix?: Readonly<Matrix4 | NumberArray>; | ||
cameraPositionWorld?: Readonly<Vector3 | NumberArray>; | ||
viewMatrix?: Readonly<Matrix4 | NumberArray16>; | ||
projectionMatrix?: Readonly<Matrix4 | NumberArray16>; | ||
cameraPositionWorld?: Readonly<Vector3 | NumberArray3>; | ||
}; | ||
@@ -18,6 +19,6 @@ /** | ||
export type ProjectionUniforms = { | ||
viewMatrix?: Readonly<Matrix4 | NumberArray>; | ||
projectionMatrix?: Readonly<Matrix4 | NumberArray>; | ||
viewProjectionMatrix?: Readonly<Matrix4 | NumberArray>; | ||
cameraPositionWorld?: Readonly<Vector3 | NumberArray>; | ||
viewMatrix?: Readonly<Matrix4 | NumberArray16>; | ||
projectionMatrix?: Readonly<Matrix4 | NumberArray16>; | ||
viewProjectionMatrix?: Readonly<Matrix4 | NumberArray16>; | ||
cameraPositionWorld?: Readonly<Vector3 | NumberArray3>; | ||
}; | ||
@@ -24,0 +25,0 @@ /** |
@@ -1,3 +0,3 @@ | ||
import type { NumberArray } from '@math.gl/types'; | ||
import { ShaderModule } from "../../../lib/shader-module/shader-module.js"; | ||
import type { NumberArray3 } from "../../../lib/utils/uniform-types.js"; | ||
/** Lighting helper types */ | ||
@@ -7,3 +7,3 @@ export type Light = AmbientLight | PointLight | DirectionalLight; | ||
type: 'ambient'; | ||
color?: Readonly<NumberArray>; | ||
color?: Readonly<NumberArray3>; | ||
intensity?: number; | ||
@@ -13,4 +13,4 @@ }; | ||
type: 'point'; | ||
position: Readonly<NumberArray>; | ||
color?: Readonly<NumberArray>; | ||
position: Readonly<NumberArray3>; | ||
color?: Readonly<NumberArray3>; | ||
intensity?: number; | ||
@@ -21,5 +21,5 @@ attenuation?: number; | ||
type: 'directional'; | ||
position: Readonly<NumberArray>; | ||
direction: Readonly<NumberArray>; | ||
color?: Readonly<NumberArray>; | ||
position: Readonly<NumberArray3>; | ||
direction: Readonly<NumberArray3>; | ||
color?: Readonly<NumberArray3>; | ||
intensity?: number; | ||
@@ -39,12 +39,12 @@ }; | ||
enabled: number; | ||
ambientLightColor: Readonly<NumberArray>; | ||
ambientLightColor: Readonly<NumberArray3>; | ||
numberOfLights: number; | ||
lightType: number; | ||
lightColor: Readonly<NumberArray>; | ||
lightPosition: Readonly<NumberArray>; | ||
lightDirection: Readonly<NumberArray>; | ||
lightAttenuation: Readonly<NumberArray>; | ||
lightColor: Readonly<NumberArray3>; | ||
lightPosition: Readonly<NumberArray3>; | ||
lightDirection: Readonly<NumberArray3>; | ||
lightAttenuation: Readonly<NumberArray3>; | ||
}; | ||
/** UBO ready lighting module */ | ||
export declare const lighting: ShaderModule<LightingProps, LightingUniforms>; | ||
export declare const lighting: ShaderModule<LightingProps, LightingUniforms, {}>; | ||
//# sourceMappingURL=lighting-uniforms.d.ts.map |
@@ -1,5 +0,5 @@ | ||
import type { NumberArray } from '@math.gl/types'; | ||
import type { Vector3 } from '@math.gl/core'; | ||
import { ShaderModule } from "../../../lib/shader-module/shader-module.js"; | ||
export type DirlightProps = { | ||
lightDirection?: NumberArray | [number, number, number]; | ||
lightDirection?: Vector3 | [number, number, number]; | ||
}; | ||
@@ -6,0 +6,0 @@ export type DirlightUniforms = DirlightProps; |
@@ -57,3 +57,3 @@ // luma.gl | ||
defaultUniforms: { | ||
lightDirection: new Float32Array([1, 1, 2]) | ||
lightDirection: [1, 1, 2] | ||
}, | ||
@@ -60,0 +60,0 @@ getUniforms |
@@ -1,3 +0,4 @@ | ||
import type { NumberArray, Texture } from '@luma.gl/core'; | ||
import type { Texture } from '@luma.gl/core'; | ||
import type { Vector2, Vector3, Vector4 } from '@math.gl/core'; | ||
import type { NumberArray2, NumberArray3, NumberArray4 } from "../../../lib/utils/uniform-types.js"; | ||
import { ShaderModule } from "../../../lib/shader-module/shader-module.js"; | ||
@@ -7,8 +8,8 @@ export type PBRMaterialProps = PBRMaterialBindings & { | ||
baseColorMapEnabled: boolean; | ||
baseColorFactor: Readonly<Vector4 | NumberArray>; | ||
baseColorFactor: Readonly<Vector4 | NumberArray4>; | ||
normalMapEnabled: boolean; | ||
normalScale: number; | ||
emissiveMapEnabled: boolean; | ||
emissiveFactor: Readonly<Vector3 | NumberArray>; | ||
metallicRoughnessValues: Readonly<Vector2 | NumberArray>; | ||
emissiveFactor: Readonly<Vector3 | NumberArray3>; | ||
metallicRoughnessValues: Readonly<Vector2 | NumberArray2>; | ||
metallicRoughnessMapEnabled: boolean; | ||
@@ -20,5 +21,5 @@ occlusionMapEnabled: boolean; | ||
IBLenabled: boolean; | ||
scaleIBLAmbient: Readonly<Vector2 | NumberArray>; | ||
scaleDiffBaseMR: Readonly<Vector4 | NumberArray>; | ||
scaleFGDSpec: Readonly<Vector4 | NumberArray>; | ||
scaleIBLAmbient: Readonly<Vector2 | NumberArray2>; | ||
scaleDiffBaseMR: Readonly<Vector4 | NumberArray4>; | ||
scaleFGDSpec: Readonly<Vector4 | NumberArray4>; | ||
}; | ||
@@ -39,8 +40,8 @@ /** Non-uniform block bindings for pbr module */ | ||
baseColorMapEnabled: boolean; | ||
baseColorFactor: Readonly<Vector4 | NumberArray>; | ||
baseColorFactor: Readonly<Vector4 | NumberArray4>; | ||
normalMapEnabled: boolean; | ||
normalScale: number; | ||
emissiveMapEnabled: boolean; | ||
emissiveFactor: Readonly<Vector3 | NumberArray>; | ||
metallicRoughnessValues: Readonly<Vector2 | NumberArray>; | ||
emissiveFactor: Readonly<Vector3 | NumberArray3>; | ||
metallicRoughnessValues: Readonly<Vector2 | NumberArray2>; | ||
metallicRoughnessMapEnabled: boolean; | ||
@@ -52,5 +53,5 @@ occlusionMapEnabled: boolean; | ||
IBLenabled: boolean; | ||
scaleIBLAmbient: Readonly<Vector2 | NumberArray>; | ||
scaleDiffBaseMR: Readonly<Vector4 | NumberArray>; | ||
scaleFGDSpec: Readonly<Vector4 | NumberArray>; | ||
scaleIBLAmbient: Readonly<Vector2 | NumberArray2>; | ||
scaleDiffBaseMR: Readonly<Vector4 | NumberArray4>; | ||
scaleFGDSpec: Readonly<Vector4 | NumberArray4>; | ||
}; | ||
@@ -57,0 +58,0 @@ /** |
@@ -50,14 +50,3 @@ // luma.gl | ||
}, | ||
bindings: { | ||
baseColorSampler: { type: 'texture', location: 8 }, // #ifdef HAS_BASECOLORMAP | ||
normalSampler: { type: 'texture', location: 9 }, // #ifdef HAS_NORMALMAP | ||
emissiveSampler: { type: 'texture', location: 10 }, // #ifdef HAS_EMISSIVEMAP | ||
metallicRoughnessSampler: { type: 'texture', location: 11 }, // #ifdef HAS_METALROUGHNESSMAP | ||
occlusionSampler: { type: 'texture', location: 12 }, // #ifdef HAS_OCCLUSIONMAP | ||
// IBL Samplers | ||
diffuseEnvSampler: { type: 'texture', location: 13 }, // #ifdef USE_IBL (samplerCube) | ||
specularEnvSampler: { type: 'texture', location: 14 }, // #ifdef USE_IBL (samplerCube) | ||
brdfLUT: { type: 'texture', location: 15 } // #ifdef USE_IBL | ||
}, | ||
dependencies: [lighting] | ||
}; |
@@ -8,5 +8,5 @@ import { ShaderPass } from "../../../lib/shader-module/shader-pass.js"; | ||
/** The x,y coordinate of the start of the line segment. */ | ||
start?: number[]; | ||
start?: [number, number]; | ||
/** The xm y coordinate of the end of the line segment. */ | ||
end?: number[]; | ||
end?: [number, number]; | ||
/** The maximum radius of the pyramid blur. */ | ||
@@ -13,0 +13,0 @@ blurRadius?: number; |
@@ -12,3 +12,3 @@ import { ShaderPass } from "../../../lib/shader-module/shader-pass.js"; | ||
/** @deprecated internal property */ | ||
delta?: number[]; | ||
delta?: [number, number]; | ||
}; | ||
@@ -15,0 +15,0 @@ /** |
@@ -7,3 +7,3 @@ import { ShaderPass } from "../../../lib/shader-module/shader-pass.js"; | ||
/** - The x, y coordinate of the blur origin. */ | ||
center?: number[]; | ||
center?: [number, number]; | ||
/** - The strength of the blur. Values in the range 0 to 1 are usually sufficient, where 0 doesn't change the image and 1 creates a highly blurred image. */ | ||
@@ -10,0 +10,0 @@ strength?: number; |
@@ -10,3 +10,3 @@ import { ShaderPass } from "../../../lib/shader-module/shader-pass.js"; | ||
/** The x,y coordinate of the pattern origin. */ | ||
center?: number[]; | ||
center?: [number, number]; | ||
/** The rotation of the pattern in radians. */ | ||
@@ -13,0 +13,0 @@ angle?: number; |
@@ -9,3 +9,3 @@ import { ShaderPass } from "../../../lib/shader-module/shader-pass.js"; | ||
/** The x, y coordinate of the pattern origin. */ | ||
center?: number[]; | ||
center?: [number, number]; | ||
/** The rotation of the pattern in radians. */ | ||
@@ -12,0 +12,0 @@ angle?: number; |
@@ -9,3 +9,3 @@ import { ShaderPass } from "../../../lib/shader-module/shader-pass.js"; | ||
/** The [x, y] coordinates of the pattern center. */ | ||
center?: number[]; | ||
center?: [number, number]; | ||
/** The width of an individual tile, in pixels. */ | ||
@@ -12,0 +12,0 @@ scale?: number; |
@@ -7,3 +7,3 @@ import { ShaderPass } from "../../../lib/shader-module/shader-pass.js"; | ||
/** x, y position in screen coords, both x and y is normalized and in range `[0, 1]`. `[0, 0]` is the up left corner, `[1, 1]` is the bottom right corner. Default value is `[0, 0]`. */ | ||
screenXY?: number[]; | ||
screenXY?: [number, number]; | ||
/** effect radius in pixels. Default value is `100`. */ | ||
@@ -16,3 +16,3 @@ radiusPixels?: number; | ||
/** border color of the effect circle. Default value is `[255, 255, 255, 255]`. */ | ||
borderColor?: number[]; | ||
borderColor?: [number, number, number, number]; | ||
}; | ||
@@ -19,0 +19,0 @@ /** |
@@ -5,3 +5,3 @@ import { ShaderPass } from "../../../lib/shader-module/shader-pass.js"; | ||
/** The [x, y] coordinates of the center of the circle of effect. */ | ||
center?: number[]; | ||
center?: [number, number]; | ||
/** The radius of the circle of effect. */ | ||
@@ -8,0 +8,0 @@ radius?: number; |
{ | ||
"name": "@luma.gl/shadertools", | ||
"version": "9.0.16", | ||
"version": "9.0.17", | ||
"description": "Shader module system for luma.gl", | ||
@@ -56,3 +56,3 @@ "type": "module", | ||
}, | ||
"gitHead": "b1f2597d6efc8aa223ddb3bf6b1530510f17ea40" | ||
"gitHead": "f348f3221ab2842ffa877b6c99e0e9e4df82426e" | ||
} |
@@ -5,8 +5,11 @@ // luma.gl | ||
import {NumberArray} from '@math.gl/types'; | ||
import {UniformFormat} from '../../types'; | ||
import {PropType} from '../filters/prop-types'; | ||
import {Sampler, Texture} from '@luma.gl/core'; | ||
import type {UniformTypes, UniformValue} from '../utils/uniform-types'; | ||
export type UniformValue = number | boolean | Readonly<NumberArray>; // Float32Array> | Readonly<Int32Array> | Readonly<Uint32Array> | Readonly<number[]>; | ||
// To avoid dependency on core module, do not import `Binding` type. | ||
// The ShaderModule is not concerned with the type of `Binding`, | ||
// it is the repsonsibility of `splitUniformsAndBindings` in | ||
// ShaderInputs to type the result of `getUniforms()` | ||
type Binding = unknown; // import type {Binding} from '@luma.gl/core'; | ||
@@ -17,10 +20,17 @@ export type UniformInfo = { | ||
// Helper types | ||
type BindingKeys<T> = {[K in keyof T]: T[K] extends UniformValue ? never : K}[keyof T]; | ||
type UniformKeys<T> = {[K in keyof T]: T[K] extends UniformValue ? K : never}[keyof T]; | ||
export type PickBindings<T> = {[K in BindingKeys<Required<T>>]: T[K]}; | ||
export type PickUniforms<T> = {[K in UniformKeys<Required<T>>]: T[K]}; | ||
/** | ||
* A shader module definition object | ||
* @note Can be viewed as the ShaderModuleProps for a ShaderModuleInstance | ||
* @note `UniformsT` & `BindingsT` are deduced from `PropsT` by default. If | ||
* a custom type for `UniformsT` is used, `BindingsT` should be also be provided. | ||
*/ | ||
export type ShaderModule< | ||
PropsT extends Record<string, unknown> = Record<string, unknown>, | ||
UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>, | ||
BindingsT extends Record<string, Buffer | Texture | Sampler> = {} | ||
PropsT extends Record<string, any> = Record<string, any>, | ||
UniformsT extends Record<string, UniformValue> = PickUniforms<PropsT>, | ||
BindingsT extends Record<string, Binding> = PickBindings<PropsT> | ||
> = { | ||
@@ -31,2 +41,4 @@ /** Used for type inference not for values */ | ||
uniforms?: UniformsT; | ||
/** Used for type inference, not currently used for values */ | ||
bindings?: BindingsT; | ||
@@ -38,3 +50,3 @@ name: string; | ||
/** Uniform shader types @note: Both order and types MUST match uniform block declarations in shader */ | ||
uniformTypes?: Record<keyof UniformsT, UniformFormat>; | ||
uniformTypes?: Required<UniformTypes<UniformsT>>; // Record<keyof UniformsT, UniformFormat>; | ||
/** Uniform JS prop types */ | ||
@@ -46,7 +58,7 @@ uniformPropTypes?: Record<keyof UniformsT, UniformInfo>; | ||
/** Function that maps props to uniforms & bindings */ | ||
getUniforms?: (props?: any, oldProps?: any) => Record<string, UniformValue>; | ||
getUniforms?: ( | ||
props?: Partial<PropsT>, | ||
prevUniforms?: UniformsT | ||
) => Partial<UniformsT & BindingsT>; | ||
/** uniform buffers, textures, samplers, storage, ... */ | ||
bindings?: Record<keyof BindingsT, {location: number; type: 'texture' | 'sampler' | 'uniforms'}>; | ||
defines?: Record<string, string | number>; | ||
@@ -53,0 +65,0 @@ /** Injections */ |
@@ -5,3 +5,5 @@ // luma.gl | ||
import type {ShaderModule, UniformValue} from './shader-module'; | ||
import type {Binding} from '@luma.gl/core'; | ||
import type {PickBindings, PickUniforms, ShaderModule} from './shader-module'; | ||
import type {UniformValue} from '../utils/uniform-types'; | ||
@@ -13,5 +15,6 @@ /** | ||
export type ShaderPass< | ||
PropsT extends Record<string, unknown> = Record<string, unknown>, | ||
UniformsT extends Record<string, UniformValue> = Record<string, UniformValue> | ||
> = ShaderModule<PropsT, UniformsT> & { | ||
PropsT extends Record<string, any> = Record<string, any>, | ||
UniformsT extends Record<string, UniformValue> = PickUniforms<PropsT>, | ||
BindingsT extends Record<string, Binding> = PickBindings<PropsT> | ||
> = ShaderModule<PropsT, UniformsT, BindingsT> & { | ||
passes: ShaderPassData[]; | ||
@@ -18,0 +21,0 @@ }; |
@@ -5,16 +5,17 @@ // luma.gl | ||
import {Matrix4} from '@math.gl/core'; | ||
import {Vector3, Matrix4} from '@math.gl/core'; | ||
import {glsl} from '../../lib/glsl-utils/highlight'; | ||
import {ShaderModule} from '../../lib/shader-module/shader-module'; | ||
import type {NumberArray3, NumberArray16} from '../../lib/utils/uniform-types'; | ||
type ProjectionProps = { | ||
modelMatrix?: readonly number[]; | ||
viewMatrix?: readonly number[]; | ||
projectionMatrix?: readonly number[]; | ||
cameraPositionWorld?: readonly number[]; | ||
modelMatrix?: Readonly<Matrix4 | NumberArray16>; | ||
viewMatrix?: Readonly<Matrix4 | NumberArray16>; | ||
projectionMatrix?: Readonly<Matrix4 | NumberArray16>; | ||
cameraPositionWorld?: Readonly<Vector3 | NumberArray3>; | ||
}; | ||
const IDENTITY_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; | ||
const IDENTITY_MATRIX: NumberArray16 = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; | ||
const DEFAULT_MODULE_OPTIONS = { | ||
const DEFAULT_MODULE_OPTIONS: ProjectionProps = { | ||
modelMatrix: IDENTITY_MATRIX, | ||
@@ -21,0 +22,0 @@ viewMatrix: IDENTITY_MATRIX, |
@@ -5,8 +5,8 @@ // luma.gl | ||
import {NumberArray} from '../../../types'; | ||
import {glsl} from '../../../lib/glsl-utils/highlight'; | ||
import {ShaderModule} from '../../../lib/shader-module/shader-module'; | ||
import type {NumberArray3, NumberArray4} from '../../../lib/utils/uniform-types'; | ||
// cyan color | ||
const DEFAULT_HIGHLIGHT_COLOR = new Float32Array([0, 1, 1, 1]); | ||
const DEFAULT_HIGHLIGHT_COLOR: NumberArray4 = [0, 1, 1, 1]; | ||
@@ -24,5 +24,5 @@ /** | ||
/** Set to a picking color to visually highlight that item, or `null` to explicitly clear **/ | ||
highlightedObjectColor?: NumberArray | null; | ||
highlightedObjectColor?: NumberArray3 | null; | ||
/** Color of visual highlight of "selected" item */ | ||
highlightColor?: NumberArray; | ||
highlightColor?: NumberArray3 | NumberArray4; | ||
/** Color range 0-1 or 0-255 */ | ||
@@ -50,5 +50,5 @@ useFloatColors?: boolean; | ||
/** Set to a picking color to visually highlight that item */ | ||
highlightedObjectColor?: NumberArray; | ||
highlightedObjectColor?: NumberArray3; | ||
/** Color of visual highlight of "selected" item */ | ||
highlightColor?: NumberArray; | ||
highlightColor?: NumberArray4; | ||
}; | ||
@@ -213,3 +213,3 @@ | ||
useFloatColors: true, | ||
highlightedObjectColor: new Float32Array([0, 0, 0]), | ||
highlightedObjectColor: [0, 0, 0], | ||
highlightColor: DEFAULT_HIGHLIGHT_COLOR | ||
@@ -229,3 +229,3 @@ }, | ||
uniforms.isHighlightActive = true; | ||
const highlightedObjectColor = opts.highlightedObjectColor.slice(0, 3); | ||
const highlightedObjectColor = opts.highlightedObjectColor.slice(0, 3) as NumberArray3; | ||
uniforms.highlightedObjectColor = highlightedObjectColor; | ||
@@ -239,3 +239,3 @@ } | ||
} | ||
uniforms.highlightColor = color; | ||
uniforms.highlightColor = color as NumberArray4; | ||
} | ||
@@ -242,0 +242,0 @@ |
@@ -5,7 +5,8 @@ // luma.gl | ||
import {NumericArray as NumberArray, Matrix4, Vector3} from '@math.gl/core'; | ||
import {Matrix4, Vector3} from '@math.gl/core'; | ||
import {ShaderModule} from '../../../lib/shader-module/shader-module'; | ||
import {glsl} from '../../../lib/glsl-utils/highlight'; | ||
import type {NumberArray3, NumberArray16} from '../../../lib/utils/uniform-types'; | ||
const IDENTITY_MATRIX: Readonly<NumberArray> = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; | ||
const IDENTITY_MATRIX: Readonly<NumberArray16> = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; | ||
@@ -17,5 +18,5 @@ /** | ||
export type ProjectionProps = { | ||
viewMatrix?: Readonly<Matrix4 | NumberArray>; | ||
projectionMatrix?: Readonly<Matrix4 | NumberArray>; | ||
cameraPositionWorld?: Readonly<Vector3 | NumberArray>; | ||
viewMatrix?: Readonly<Matrix4 | NumberArray16>; | ||
projectionMatrix?: Readonly<Matrix4 | NumberArray16>; | ||
cameraPositionWorld?: Readonly<Vector3 | NumberArray3>; | ||
}; | ||
@@ -28,6 +29,6 @@ | ||
export type ProjectionUniforms = { | ||
viewMatrix?: Readonly<Matrix4 | NumberArray>; | ||
projectionMatrix?: Readonly<Matrix4 | NumberArray>; | ||
viewProjectionMatrix?: Readonly<Matrix4 | NumberArray>; | ||
cameraPositionWorld?: Readonly<Vector3 | NumberArray>; | ||
viewMatrix?: Readonly<Matrix4 | NumberArray16>; | ||
projectionMatrix?: Readonly<Matrix4 | NumberArray16>; | ||
viewProjectionMatrix?: Readonly<Matrix4 | NumberArray16>; | ||
cameraPositionWorld?: Readonly<Vector3 | NumberArray3>; | ||
}; | ||
@@ -34,0 +35,0 @@ |
@@ -5,5 +5,5 @@ // luma.gl | ||
import type {NumberArray} from '@math.gl/types'; | ||
import {ShaderModule} from '../../../lib/shader-module/shader-module'; | ||
import {lightingUniforms} from './lighting-uniforms-glsl'; | ||
import type {NumberArray3} from '../../../lib/utils/uniform-types'; | ||
@@ -28,3 +28,3 @@ /** Max number of supported lights (in addition to ambient light */ | ||
type: 'ambient'; | ||
color?: Readonly<NumberArray>; | ||
color?: Readonly<NumberArray3>; | ||
intensity?: number; | ||
@@ -35,4 +35,4 @@ }; | ||
type: 'point'; | ||
position: Readonly<NumberArray>; | ||
color?: Readonly<NumberArray>; | ||
position: Readonly<NumberArray3>; | ||
color?: Readonly<NumberArray3>; | ||
intensity?: number; | ||
@@ -44,5 +44,5 @@ attenuation?: number; | ||
type: 'directional'; | ||
position: Readonly<NumberArray>; | ||
direction: Readonly<NumberArray>; | ||
color?: Readonly<NumberArray>; | ||
position: Readonly<NumberArray3>; | ||
direction: Readonly<NumberArray3>; | ||
color?: Readonly<NumberArray3>; | ||
intensity?: number; | ||
@@ -64,13 +64,13 @@ }; | ||
enabled: number; | ||
ambientLightColor: Readonly<NumberArray>; | ||
ambientLightColor: Readonly<NumberArray3>; | ||
numberOfLights: number; | ||
lightType: number; // []; | ||
lightColor: Readonly<NumberArray>; // []; | ||
lightPosition: Readonly<NumberArray>; // []; | ||
lightDirection: Readonly<NumberArray>; // []; | ||
lightAttenuation: Readonly<NumberArray>; // []; | ||
lightColor: Readonly<NumberArray3>; // []; | ||
lightPosition: Readonly<NumberArray3>; // []; | ||
lightDirection: Readonly<NumberArray3>; // []; | ||
lightAttenuation: Readonly<NumberArray3>; // []; | ||
}; | ||
/** UBO ready lighting module */ | ||
export const lighting: ShaderModule<LightingProps, LightingUniforms> = { | ||
export const lighting: ShaderModule<LightingProps, LightingUniforms, {}> = { | ||
name: 'lighting', | ||
@@ -225,6 +225,6 @@ vs: lightingUniforms, | ||
function convertColor( | ||
colorDef: {color?: Readonly<NumberArray>; intensity?: number} = {} | ||
): NumberArray { | ||
colorDef: {color?: Readonly<NumberArray3>; intensity?: number} = {} | ||
): NumberArray3 { | ||
const {color = [0, 0, 0], intensity = 1.0} = colorDef; | ||
return color.map(component => (component * intensity) / COLOR_FACTOR); | ||
return color.map(component => (component * intensity) / COLOR_FACTOR) as NumberArray3; | ||
} |
@@ -5,3 +5,3 @@ // luma.gl | ||
import type {NumberArray} from '@math.gl/types'; | ||
import type {Vector3} from '@math.gl/core'; | ||
import {glsl} from '../../../lib/glsl-utils/highlight'; | ||
@@ -11,3 +11,3 @@ import {ShaderModule} from '../../../lib/shader-module/shader-module'; | ||
export type DirlightProps = { | ||
lightDirection?: NumberArray | [number, number, number]; | ||
lightDirection?: Vector3 | [number, number, number]; | ||
}; | ||
@@ -77,3 +77,3 @@ | ||
defaultUniforms: { | ||
lightDirection: new Float32Array([1, 1, 2]) | ||
lightDirection: [1, 1, 2] | ||
}, | ||
@@ -80,0 +80,0 @@ getUniforms |
@@ -7,4 +7,5 @@ // luma.gl | ||
import type {NumberArray, Texture} from '@luma.gl/core'; | ||
import type {Texture} from '@luma.gl/core'; | ||
import type {Vector2, Vector3, Vector4} from '@math.gl/core'; | ||
import type {NumberArray2, NumberArray3, NumberArray4} from '../../../lib/utils/uniform-types'; | ||
@@ -22,3 +23,3 @@ import {ShaderModule} from '../../../lib/shader-module/shader-module'; | ||
baseColorMapEnabled: boolean; | ||
baseColorFactor: Readonly<Vector4 | NumberArray>; | ||
baseColorFactor: Readonly<Vector4 | NumberArray4>; | ||
@@ -29,5 +30,5 @@ normalMapEnabled: boolean; | ||
emissiveMapEnabled: boolean; | ||
emissiveFactor: Readonly<Vector3 | NumberArray>; // #ifdef HAS_EMISSIVEMAP | ||
emissiveFactor: Readonly<Vector3 | NumberArray3>; // #ifdef HAS_EMISSIVEMAP | ||
metallicRoughnessValues: Readonly<Vector2 | NumberArray>; | ||
metallicRoughnessValues: Readonly<Vector2 | NumberArray2>; | ||
metallicRoughnessMapEnabled: boolean; | ||
@@ -43,8 +44,8 @@ | ||
IBLenabled: boolean; | ||
scaleIBLAmbient: Readonly<Vector2 | NumberArray>; // #ifdef USE_IBL | ||
scaleIBLAmbient: Readonly<Vector2 | NumberArray2>; // #ifdef USE_IBL | ||
// debugging flags used for shader output of intermediate PBR variables | ||
// #ifdef PBR_DEBUG | ||
scaleDiffBaseMR: Readonly<Vector4 | NumberArray>; | ||
scaleFGDSpec: Readonly<Vector4 | NumberArray>; | ||
scaleDiffBaseMR: Readonly<Vector4 | NumberArray4>; | ||
scaleFGDSpec: Readonly<Vector4 | NumberArray4>; | ||
}; | ||
@@ -72,3 +73,3 @@ | ||
baseColorMapEnabled: boolean; | ||
baseColorFactor: Readonly<Vector4 | NumberArray>; | ||
baseColorFactor: Readonly<Vector4 | NumberArray4>; | ||
@@ -79,5 +80,5 @@ normalMapEnabled: boolean; | ||
emissiveMapEnabled: boolean; | ||
emissiveFactor: Readonly<Vector3 | NumberArray>; // #ifdef HAS_EMISSIVEMAP | ||
emissiveFactor: Readonly<Vector3 | NumberArray3>; // #ifdef HAS_EMISSIVEMAP | ||
metallicRoughnessValues: Readonly<Vector2 | NumberArray>; | ||
metallicRoughnessValues: Readonly<Vector2 | NumberArray2>; | ||
metallicRoughnessMapEnabled: boolean; | ||
@@ -93,8 +94,8 @@ | ||
IBLenabled: boolean; | ||
scaleIBLAmbient: Readonly<Vector2 | NumberArray>; // #ifdef USE_IBL | ||
scaleIBLAmbient: Readonly<Vector2 | NumberArray2>; // #ifdef USE_IBL | ||
// debugging flags used for shader output of intermediate PBR variables | ||
// #ifdef PBR_DEBUG | ||
scaleDiffBaseMR: Readonly<Vector4 | NumberArray>; | ||
scaleFGDSpec: Readonly<Vector4 | NumberArray>; | ||
scaleDiffBaseMR: Readonly<Vector4 | NumberArray4>; | ||
scaleFGDSpec: Readonly<Vector4 | NumberArray4>; | ||
}; | ||
@@ -153,14 +154,3 @@ | ||
}, | ||
bindings: { | ||
baseColorSampler: {type: 'texture', location: 8}, // #ifdef HAS_BASECOLORMAP | ||
normalSampler: {type: 'texture', location: 9}, // #ifdef HAS_NORMALMAP | ||
emissiveSampler: {type: 'texture', location: 10}, // #ifdef HAS_EMISSIVEMAP | ||
metallicRoughnessSampler: {type: 'texture', location: 11}, // #ifdef HAS_METALROUGHNESSMAP | ||
occlusionSampler: {type: 'texture', location: 12}, // #ifdef HAS_OCCLUSIONMAP | ||
// IBL Samplers | ||
diffuseEnvSampler: {type: 'texture', location: 13}, // #ifdef USE_IBL (samplerCube) | ||
specularEnvSampler: {type: 'texture', location: 14}, // #ifdef USE_IBL (samplerCube) | ||
brdfLUT: {type: 'texture', location: 15} // #ifdef USE_IBL | ||
}, | ||
dependencies: [lighting] | ||
}; |
@@ -61,5 +61,5 @@ // luma.gl | ||
/** The x,y coordinate of the start of the line segment. */ | ||
start?: number[]; | ||
start?: [number, number]; | ||
/** The xm y coordinate of the end of the line segment. */ | ||
end?: number[]; | ||
end?: [number, number]; | ||
/** The maximum radius of the pyramid blur. */ | ||
@@ -66,0 +66,0 @@ blurRadius?: number; |
@@ -55,3 +55,3 @@ // luma.gl | ||
/** @deprecated internal property */ | ||
delta?: number[]; | ||
delta?: [number, number]; | ||
}; | ||
@@ -58,0 +58,0 @@ |
@@ -48,3 +48,3 @@ // luma.gl | ||
/** - The x, y coordinate of the blur origin. */ | ||
center?: number[]; | ||
center?: [number, number]; | ||
/** - The strength of the blur. Values in the range 0 to 1 are usually sufficient, where 0 doesn't change the image and 1 creates a highly blurred image. */ | ||
@@ -51,0 +51,0 @@ strength?: number; |
@@ -54,3 +54,3 @@ // luma.gl | ||
/** The x,y coordinate of the pattern origin. */ | ||
center?: number[]; | ||
center?: [number, number]; | ||
/** The rotation of the pattern in radians. */ | ||
@@ -57,0 +57,0 @@ angle?: number; |
@@ -40,3 +40,3 @@ // luma.gl | ||
/** The x, y coordinate of the pattern origin. */ | ||
center?: number[]; | ||
center?: [number, number]; | ||
/** The rotation of the pattern in radians. */ | ||
@@ -43,0 +43,0 @@ angle?: number; |
@@ -60,3 +60,3 @@ // luma.gl | ||
/** The [x, y] coordinates of the pattern center. */ | ||
center?: number[]; | ||
center?: [number, number]; | ||
/** The width of an individual tile, in pixels. */ | ||
@@ -63,0 +63,0 @@ scale?: number; |
@@ -36,3 +36,3 @@ // luma.gl | ||
/** x, y position in screen coords, both x and y is normalized and in range `[0, 1]`. `[0, 0]` is the up left corner, `[1, 1]` is the bottom right corner. Default value is `[0, 0]`. */ | ||
screenXY?: number[]; | ||
screenXY?: [number, number]; | ||
/** effect radius in pixels. Default value is `100`. */ | ||
@@ -45,3 +45,3 @@ radiusPixels?: number; | ||
/** border color of the effect circle. Default value is `[255, 255, 255, 255]`. */ | ||
borderColor?: number[]; | ||
borderColor?: [number, number, number, number]; | ||
}; | ||
@@ -48,0 +48,0 @@ |
@@ -42,3 +42,3 @@ // luma.gl | ||
/** The [x, y] coordinates of the center of the circle of effect. */ | ||
center?: number[]; | ||
center?: [number, number]; | ||
/** The radius of the circle of effect. */ | ||
@@ -45,0 +45,0 @@ radius?: number; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1560203
326
33739