Skip to content

Commit 25d2945

Browse files
sankheshfloryst
authored andcommitted
feat(camera): added a new model transform matrix to the Camera API
The new model transform matrix can be used for transformations like scale, shear, rotations and translations.
1 parent a6ffba9 commit 25d2945

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Sources/Rendering/Core/Camera/index.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,12 @@ function vtkCamera(publicAPI, model) {
498498
publicAPI.computeViewParametersFromViewMatrix(tmpMatrix);
499499
};
500500

501+
publicAPI.setModelTransformMatrix = (mat) => {
502+
model.modelTransformMatrix = mat;
503+
};
504+
505+
publicAPI.getModelTransformMatrix = () => model.modelTransformMatrix;
506+
501507
publicAPI.setViewMatrix = (mat) => {
502508
model.viewMatrix = mat;
503509
if (model.viewMatrix) {
@@ -509,6 +515,10 @@ function vtkCamera(publicAPI, model) {
509515

510516
publicAPI.getViewMatrix = () => {
511517
if (model.viewMatrix) {
518+
if (model.modelTransformMatrix) {
519+
mat4.multiply(tmpMatrix, model.viewMatrix, model.modelTransformMatrix);
520+
return tmpMatrix;
521+
}
512522
return model.viewMatrix;
513523
}
514524

@@ -522,7 +532,11 @@ function vtkCamera(publicAPI, model) {
522532
mat4.transpose(tmpMatrix, tmpMatrix);
523533

524534
const result = new Float64Array(16);
525-
mat4.copy(result, tmpMatrix);
535+
if (model.modelTransformMatrix) {
536+
mat4.multiply(result, tmpMatrix, model.modelTransformMatrix);
537+
} else {
538+
mat4.copy(result, tmpMatrix);
539+
}
526540
return result;
527541
};
528542

@@ -767,6 +781,7 @@ export const DEFAULT_VALUES = {
767781
freezeFocalPoint: false,
768782
projectionMatrix: null,
769783
viewMatrix: null,
784+
modelTransformMatrix: null,
770785
cameraLightTransform: mat4.create(),
771786

772787
// used for world to physical transformations

0 commit comments

Comments
 (0)