How to use the Matrix3 function from three

Find comprehensive JavaScript three.Matrix3 code examples handpicked from public code repositorys.

three.Matrix3 is a class in the Three.js library used to represent a 3x3 matrix for use in 3D graphics operations such as transformation and rotation.

111
112
113
114
115
116
117
118
119
120
        _pointLights = new THREE.Color(),

        _vector3 = new THREE.Vector3(), // Needed for PointLight
        _centroid = new THREE.Vector3(),
        _normal = new THREE.Vector3(),
        _normalViewMatrix = new THREE.Matrix3();

// dash+gap fallbacks for Firefox and everything else

if ( _context.setLineDash === undefined ) {
fork icon185
star icon870
watch icon40

+ 9 other calls in file

120
121
122
123
124
125
126
127
128
129
_viewProjectionMatrix = new THREE.Matrix4(),

_modelMatrix,
_modelViewProjectionMatrix = new THREE.Matrix4(),

_normalMatrix = new THREE.Matrix3(),

_frustum = new THREE.Frustum(),

_clippedVertex1PositionScreen = new THREE.Vector4(),
fork icon185
star icon867
watch icon40

+ 21 other calls in file

How does three.Matrix3 work?

three.Matrix3 is a class in the Three.js library that represents a 3x3 matrix in a 3D space, providing methods for matrix transformations such as rotation, scaling, and translation. It contains properties for the matrix elements, and methods for matrix operations such as multiplication and inversion. The class is used to transform vectors and other 3D objects in a scene.

9
10
11
12
13
14
15
16
17
18
const __newStateQuaternion = new THREE.Quaternion();

const __tmpDir3 = new THREE.Vector3();
const __tmpQuaternion = new THREE.Vector3();
const __tmpPos3 = new THREE.Vector3();
const __tmpNormalMatrix = new THREE.Matrix3();
const __tmpRotationMatrix = new THREE.Matrix4();
const __tmpNormal = new THREE.Vector3();

const States = {
fork icon4
star icon25
watch icon2

+ 5 other calls in file

17
18
19
20
21
22
23
24
25
26

let nbVertex = 0;
let nbNormals = 0;
let nbVertexUvs = 0;
const geometry = mesh.geometry;
const normalMatrixWorld = new THREE.Matrix3(); // shortcuts

const vertices = geometry.getAttribute( 'position' );
const normals = geometry.getAttribute( 'normal' );
const uvs = geometry.getAttribute( 'uv' );
fork icon2
star icon10
watch icon0

+ 2 other calls in file

Ai Example

1
2
3
4
const matrix = new THREE.Matrix3();

// Set values of the matrix
matrix.set(1, 0, 0, 0, 1, 0, 0, 0, 1);

In this example, a new Matrix3 object is created using the constructor. The set method is then used to set the values of the matrix to the identity matrix.

15
16
17
18
19
20
21
22
23
24
function parseMesh(mesh) {
    let nbVertex = 0;
    let nbNormals = 0;
    let nbVertexUvs = 0;
    const geometry = mesh.geometry;
    const normalMatrixWorld = new three_1.Matrix3();
    if (geometry.isBufferGeometry !== true) {
        throw new Error('THREE.OBJExporter: Geometry is not of type THREE.BufferGeometry.');
    }
    // shortcuts
fork icon1
star icon3
watch icon0

29
30
31
32
33
34
35
36
37
38
var nbNormals = 0;
var nbVertexUvs = 0;

var geometry = mesh.geometry;

var normalMatrixWorld = new THREE.Matrix3();

if ( geometry instanceof THREE.Geometry ) {

	geometry = new THREE.BufferGeometry().setFromObject( mesh );
fork icon1
star icon0
watch icon2

+ 8 other calls in file

21
22
23
24
25
26
27
28
29
30
 * method that takes a JSON array of camera calibrations in and yields an array of {@link OrientedImageCamera}
 *
 * @module CameraCalibrationParser
 */
var textureLoader = new THREE.TextureLoader();
var matrix3 = new THREE.Matrix3(); // the json format encodes the following transformation:
// extrinsics: p_local = rotation * (p_world - position)
// intrinsics: p_pixel = projection * p_local
// distortion: p_raw = distortion(p_pixel)

fork icon0
star icon1
watch icon1

+ 10 other calls in file

905
906
907
908
909
910
911
912
913
  _this2.movieScreen.rotation.y = -Math.PI;
  return _this2.movieScreen;
};

if (projection === 'EAC') {
  this.scene.add(makeScreen(new THREE.Matrix3(), new THREE.Matrix3()));
} else {
  var scaleMatrix = new THREE.Matrix3().set(0, 0.5, 0, 1, 0, 0, 0, 0, 1);
  makeScreen(new THREE.Matrix3().set(0, -0.5, 0.5, 1, 0, 0, 0, 0, 1), scaleMatrix); // display in left eye only
fork icon0
star icon0
watch icon1

+ 83 other calls in file

140
141
142
143
144
145
146
147
148
149
    return geom;
}
static fromMesh(mesh, objectIndex) {
    const csg = CSG.fromGeometry(mesh.geometry, objectIndex);
    const ttvv0 = new three_1.Vector3();
    const tmpm3 = new three_1.Matrix3();
    tmpm3.getNormalMatrix(mesh.matrix);
    for (let i = 0; i < csg.polygons.length; i++) {
        const p = csg.polygons[i];
        for (let j = 0; j < p.vertices.length; j++) {
fork icon0
star icon0
watch icon1

85
86
87
88
89
90
91
92
93
94
95
  return nextStepDat;
}


function rotateTo(oldDir,newDir,rad){
  var A = new THREE.Matrix3();
  var R1 = new THREE.Matrix3();
  var R2 = new THREE.Matrix3();
  var R3 = new THREE.Matrix3();
  var R = new THREE.Matrix3();
  var x = new THREE.Vector3();
fork icon0
star icon0
watch icon0

+ 5 other calls in file

1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
  var normalAttribute = new THREE.Float32BufferAttribute(
    buffers.normal,
    3,
  );

  var normalMatrix = new THREE.Matrix3().getNormalMatrix(preTransform);
  normalMatrix.applyToBufferAttribute(normalAttribute);

  geo.addAttribute('normal', normalAttribute);
}
fork icon0
star icon0
watch icon0

Other functions in three

Sorted by popularity

function icon

three.Vector3 is the most popular function in three (22341 examples)