Coveralls logob
Coveralls logo
  • Home
  • Features
  • Pricing
  • Docs
  • Sign In

uber / deck.gl / 13340

10 Sep 2019 - 3:13 coverage decreased (-2.6%) to 80.892%
13340

Pull #3552

travis-ci-com

9181eb84f9c35729a3bad740fb7f9d93?size=18&default=identiconweb-flow
[#3548 - Part 4] Modify setup.py to specify that README is markdown
Pull Request #3552: [#3548 - Part 4] Update notebook documentation to include additional pydeck features

3330 of 4491 branches covered (74.15%)

Branch coverage included in aggregate %.

6860 of 8106 relevant lines covered (84.63%)

5923.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.3
/modules/mesh-layers/src/utils/matrix.js
1
import {createIterable} from '@deck.gl/core';
5×
2

3
/* eslint-disable max-statements, complexity */
4
const RADIAN_PER_DEGREE = Math.PI / 180;
1×
5
const modelMatrix = new Float32Array(16);
1×
6
const valueArray = new Float32Array(12);
1×
7

8
function calculateTransformMatrix(targetMatrix, orientation, scale) {
9
  const pitch = orientation[0] * RADIAN_PER_DEGREE;
35,289×
10
  const yaw = orientation[1] * RADIAN_PER_DEGREE;
35,289×
11
  const roll = orientation[2] * RADIAN_PER_DEGREE;
35,289×
12

13
  const sr = Math.sin(roll);
35,289×
14
  const sp = Math.sin(pitch);
35,289×
15
  const sw = Math.sin(yaw);
35,289×
16

17
  const cr = Math.cos(roll);
35,289×
18
  const cp = Math.cos(pitch);
35,289×
19
  const cw = Math.cos(yaw);
35,289×
20

21
  const scx = scale[0];
35,289×
22
  const scy = scale[1];
35,289×
23
  const scz = scale[2];
35,289×
24

25
  targetMatrix[0] = scx * cw * cp; // 0,0
35,289×
26
  targetMatrix[1] = scx * sw * cp; // 1,0
35,289×
27
  targetMatrix[2] = scx * -sp; // 2,0
35,289×
28
  targetMatrix[3] = scy * (-sw * cr + cw * sp * sr); // 0,1
35,289×
29
  targetMatrix[4] = scy * (cw * cr + sw * sp * sr); // 1,1
35,289×
30
  targetMatrix[5] = scy * cp * sr; // 2,1
35,289×
31
  targetMatrix[6] = scz * (sw * sr + cw * sp * cr); // 0,2
35,289×
32
  targetMatrix[7] = scz * (-cw * sr + sw * sp * cr); // 1,2
35,289×
33
  targetMatrix[8] = scz * cp * cr; // 2,2
35,289×
34
}
35

36
function getExtendedMat3FromMat4(mat4) {
37
  mat4[0] = mat4[0];
10,080×
38
  mat4[1] = mat4[1];
10,080×
39
  mat4[2] = mat4[2];
10,080×
40
  mat4[3] = mat4[4];
10,080×
41
  mat4[4] = mat4[5];
10,080×
42
  mat4[5] = mat4[6];
10,080×
43
  mat4[6] = mat4[8];
10,080×
44
  mat4[7] = mat4[9];
10,080×
45
  mat4[8] = mat4[10];
10,080×
46
  mat4[9] = mat4[12];
10,080×
47
  mat4[10] = mat4[13];
10,080×
48
  mat4[11] = mat4[14];
10,080×
49

50
  return mat4.subarray(0, 12);
10,080×
51
}
52

53
export const MATRIX_ATTRIBUTES = {
1×
54
  size: 12,
55
  accessor: ['getOrientation', 'getScale', 'getTranslation', 'getTransformMatrix'],
56
  shaderAttributes: {
57
    instanceModelMatrix__LOCATION_0: {
58
      size: 3,
59
      stride: 48,
60
      offset: 0
61
    },
62
    instanceModelMatrix__LOCATION_1: {
63
      size: 3,
64
      stride: 48,
65
      offset: 12
66
    },
67
    instanceModelMatrix__LOCATION_2: {
68
      size: 3,
69
      stride: 48,
70
      offset: 24
71
    },
72
    instanceTranslation: {
73
      size: 3,
74
      stride: 48,
75
      offset: 36
76
    }
77
  },
78

79
  update(attribute, {startRow, endRow}) {
80
    // NOTE(Tarek): "this" will be bound to a layer!
81
    const {data, getOrientation, getScale, getTranslation, getTransformMatrix} = this.props;
26×
82

83
    const arrayMatrix = Array.isArray(getTransformMatrix);
26×
84
    const constantMatrix = arrayMatrix && getTransformMatrix.length === 16;
26×
85
    const constantScale = Array.isArray(getScale);
26×
86
    const constantOrientation = Array.isArray(getOrientation);
26×
87
    const constantTranslation = Array.isArray(getTranslation);
26×
88

89
    const hasMatrix = constantMatrix || (!arrayMatrix && Boolean(getTransformMatrix(data[0])));
26×
90

91
    if (hasMatrix) {
26×
92
      attribute.constant = constantMatrix;
4×
93
    } else {
94
      attribute.constant = constantOrientation && constantScale && constantTranslation;
22×
95
    }
96

97
    const instanceModelMatrixData = attribute.value;
26×
98

99
    if (attribute.constant) {
26×
100
      let matrix;
101

102
      if (hasMatrix) {
Branches [[5, 0]] missed. 7×
UNCOV
103
        modelMatrix.set(getTransformMatrix);
!
UNCOV
104
        matrix = getExtendedMat3FromMat4(modelMatrix);
!
105
      } else {
106
        matrix = valueArray;
7×
107

108
        const orientation = getOrientation;
7×
109
        const scale = getScale;
7×
110

111
        calculateTransformMatrix(matrix, orientation, scale);
7×
112
        matrix.set(getTranslation, 9);
7×
113
      }
114

115
      attribute.value = new Float32Array(matrix);
7×
116
    } else {
117
      let i = startRow * attribute.size;
19×
118
      const {iterable, objectInfo} = createIterable(data, startRow, endRow);
19×
119
      for (const object of iterable) {
19×
120
        objectInfo.index++;
45,362×
121
        let matrix;
122

123
        if (hasMatrix) {
45,362×
124
          modelMatrix.set(
10,080×
125
            constantMatrix ? getTransformMatrix : getTransformMatrix(object, objectInfo)
Branches [[7, 0]] missed.
126
          );
127
          matrix = getExtendedMat3FromMat4(modelMatrix);
10,080×
128
        } else {
129
          matrix = valueArray;
35,282×
130

131
          const orientation = constantOrientation
35,282×
132
            ? getOrientation
133
            : getOrientation(object, objectInfo);
134
          const scale = constantScale ? getScale : getScale(object, objectInfo);
35,282×
135

136
          calculateTransformMatrix(matrix, orientation, scale);
35,282×
137
          matrix.set(constantTranslation ? getTranslation : getTranslation(object, objectInfo), 9);
35,282×
138
        }
139

140
        instanceModelMatrixData[i++] = matrix[0];
45,362×
141
        instanceModelMatrixData[i++] = matrix[1];
45,362×
142
        instanceModelMatrixData[i++] = matrix[2];
45,362×
143
        instanceModelMatrixData[i++] = matrix[3];
45,362×
144
        instanceModelMatrixData[i++] = matrix[4];
45,362×
145
        instanceModelMatrixData[i++] = matrix[5];
45,362×
146
        instanceModelMatrixData[i++] = matrix[6];
45,362×
147
        instanceModelMatrixData[i++] = matrix[7];
45,362×
148
        instanceModelMatrixData[i++] = matrix[8];
45,362×
149
        instanceModelMatrixData[i++] = matrix[9];
45,362×
150
        instanceModelMatrixData[i++] = matrix[10];
45,362×
151
        instanceModelMatrixData[i++] = matrix[11];
45,362×
152
      }
153
    }
154
  }
155
};
Troubleshooting · Open an Issue · Sales · Support · ENTERPRISE · CAREERS · STATUS
BLOG · TWITTER · Legal & Privacy · Supported CI Services · What's a CI service? · Automated Testing

© 2019 Coveralls, LLC