Skip to content

Commit

Permalink
Use Matrix4Like
Browse files Browse the repository at this point in the history
  • Loading branch information
felixpalmer committed Sep 26, 2024
1 parent 0af3044 commit 884c9db
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion modules/core/src/lib/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ export default abstract class Layer<PropsT extends {} = {}> extends Component<
lighting: lightSources,
phongMaterial: material,
gouraudMaterial: material,
picking: {isActive, isAttribute} as PickingProps,
picking: {isActive, isAttribute} as const satisfies PickingProps,
project: projectProps
});
}
Expand Down
21 changes: 10 additions & 11 deletions modules/core/src/shaderlib/project/viewport-uniforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
// THE SOFTWARE.
/* eslint-disable complexity, camelcase */

import {mat4, vec4} from '@math.gl/core';
import type {NumberArray16} from '@math.gl/types';
import {mat4, Matrix4Like, vec4} from '@math.gl/core';

import {COORDINATE_SYSTEM, PROJECTION_MODE} from '../../lib/constants';

Expand All @@ -35,8 +34,8 @@ type Vec4 = [number, number, number, number];
// To quickly set a vector to zero
const ZERO_VECTOR: Vec4 = [0, 0, 0, 0];
// 4x4 matrix that drops 4th component of vector
const VECTOR_TO_POINT_MATRIX: NumberArray16 = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0];
const IDENTITY_MATRIX: NumberArray16 = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
const VECTOR_TO_POINT_MATRIX: Matrix4Like = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0];
const IDENTITY_MATRIX: Matrix4Like = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
const DEFAULT_PIXELS_PER_UNIT2: Vec3 = [0, 0, 0];
const DEFAULT_COORDINATE_ORIGIN: Vec3 = [0, 0, 0];

Expand Down Expand Up @@ -127,8 +126,8 @@ function calculateMatrixAndOffset(
coordinateSystem: CoordinateSystem,
coordinateOrigin: Vec3
): {
viewMatrix: NumberArray16;
viewProjectionMatrix: NumberArray16;
viewMatrix: Matrix4Like;
viewProjectionMatrix: Matrix4Like;
projectionCenter: Vec4;
originCommon: Vec4;
cameraPosCommon: Vec3;
Expand Down Expand Up @@ -177,8 +176,8 @@ function calculateMatrixAndOffset(
}

return {
viewMatrix: viewMatrix as NumberArray16,
viewProjectionMatrix: viewProjectionMatrix as NumberArray16,
viewMatrix: viewMatrix as Matrix4Like,
viewProjectionMatrix: viewProjectionMatrix as Matrix4Like,
projectionCenter,
originCommon,
cameraPosCommon,
Expand Down Expand Up @@ -209,8 +208,8 @@ export type ProjectUniforms = {
scale: number;
wrapLongitude: boolean;

viewProjectionMatrix: NumberArray16;
modelMatrix: NumberArray16;
viewProjectionMatrix: Matrix4Like;
modelMatrix: Matrix4Like;

// This is for lighting calculations
cameraPosition: Vec3;
Expand All @@ -219,7 +218,7 @@ export type ProjectUniforms = {
export type ProjectProps = {
viewport: Viewport;
devicePixelRatio?: number;
modelMatrix?: NumberArray16 | null;
modelMatrix?: Matrix4Like | null;
coordinateSystem?: CoordinateSystem;
coordinateOrigin?: Vec3;
autoWrapLongitude?: boolean;
Expand Down
3 changes: 2 additions & 1 deletion modules/core/src/types/layer-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {Texture, TextureProps} from '@luma.gl/core';
import type {Buffer, Parameters} from '@luma.gl/core';
import type {Loader} from '@loaders.gl/loader-utils';
import type {LightingModuleSettings} from '../shaderlib/index';
import type {Matrix4Like} from '@math.gl/core';

export type LayerData<T> =
| Iterable<T>
Expand Down Expand Up @@ -169,7 +170,7 @@ export type LayerProps = {
/**
* A 4x4 matrix to transform local coordianates to the world space.
*/
modelMatrix?: NumericArray | null;
modelMatrix?: Matrix4Like | null;
/**
* (Geospatial only) normalize geometries that cross the 180th meridian. Default false.
*/
Expand Down

0 comments on commit 884c9db

Please sign in to comment.