@kitware/vtk.js 20.1.2 → 20.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/Core/Base64.d.ts +14 -2
- package/Common/Core/Base64.js +31 -2
- package/Common/Core/Math/index.js +3 -3
- package/Common/Core/Math.d.ts +128 -128
- package/Common/Core/Math.js +1 -1
- package/Common/Core/MatrixBuilder.js +39 -41
- package/Common/DataModel/ImageData.js +12 -14
- package/Common/Transform/LandmarkTransform.js +6 -7
- package/Filters/General/PaintFilter/PaintFilter.worker.js +8 -8
- package/Filters/General/PaintFilter.js +11 -11
- package/Filters/Sources/PlaneSource.js +12 -13
- package/IO/Core/BinaryHelper.js +2 -4
- package/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js +1 -1
- package/IO/Core/DataAccessHelper/HttpDataAccessHelper.js +1 -1
- package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +2 -2
- package/IO/Core/ZipMultiDataSetReader.js +1 -1
- package/IO/Core/ZipMultiDataSetWriter.js +1 -1
- package/IO/Geometry/STLWriter.js +4 -4
- package/IO/Misc/SkyboxReader.js +1 -1
- package/IO/XML/XMLReader.js +3 -4
- package/IO/XML/XMLWriter.js +5 -6
- package/Imaging/Core/ImageReslice.js +18 -19
- package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +27 -28
- package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +8 -9
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +14 -15
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +12 -13
- package/Interaction/Widgets/ImageCroppingRegionsWidget.js +5 -6
- package/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +1 -1
- package/Interaction/Widgets/PiecewiseGaussianWidget.js +2 -2
- package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +8 -9
- package/Rendering/Core/Actor.js +3 -4
- package/Rendering/Core/Camera.js +81 -84
- package/Rendering/Core/CellPicker.js +2 -2
- package/Rendering/Core/CubeAxesActor.js +32 -33
- package/Rendering/Core/Follower.js +20 -21
- package/Rendering/Core/Glyph3DMapper.js +30 -32
- package/Rendering/Core/ImageMapper.js +2 -2
- package/Rendering/Core/ImageSlice.js +5 -6
- package/Rendering/Core/Picker.js +5 -6
- package/Rendering/Core/PixelSpaceCallbackMapper.js +3 -4
- package/Rendering/Core/Prop3D.js +24 -25
- package/Rendering/Core/Renderer.js +11 -12
- package/Rendering/Core/ScalarBarActor.js +32 -33
- package/Rendering/Core/Volume.js +3 -4
- package/Rendering/OpenGL/Actor.js +9 -10
- package/Rendering/OpenGL/Camera.js +8 -9
- package/Rendering/OpenGL/CellArrayBufferObject.js +6 -8
- package/Rendering/OpenGL/Glyph3DMapper.js +8 -9
- package/Rendering/OpenGL/ImageMapper.js +7 -7
- package/Rendering/OpenGL/ImageSlice.js +4 -4
- package/Rendering/OpenGL/PolyDataMapper.js +11 -13
- package/Rendering/OpenGL/RenderWindow.d.ts +37 -1
- package/Rendering/OpenGL/ShaderCache.js +1 -1
- package/Rendering/OpenGL/Skybox.js +4 -5
- package/Rendering/OpenGL/SphereMapper.js +2 -2
- package/Rendering/OpenGL/StickMapper.js +3 -4
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +1 -1
- package/Rendering/OpenGL/Volume.js +6 -7
- package/Rendering/OpenGL/VolumeMapper.js +47 -49
- package/Rendering/OpenGL/glsl/vtkPolyDataFS.glsl.js +1 -1
- package/Rendering/WebGPU/Actor.js +8 -8
- package/Rendering/WebGPU/Camera.js +8 -8
- package/Rendering/WebGPU/ImageMapper.js +18 -19
- package/Rendering/WebGPU/ImageSlice.js +9 -9
- package/Rendering/WebGPU/PolyDataMapper.js +3 -4
- package/Rendering/WebGPU/Renderer.js +6 -7
- package/Rendering/WebGPU/Texture.js +10 -9
- package/Rendering/WebGPU/Volume.js +3 -3
- package/Rendering/WebGPU/VolumePassFSQ.js +10 -10
- package/ThirdParty/index.js +2 -2
- package/Widgets/Manipulators/TrackballManipulator.js +5 -6
- package/Widgets/Representations/ArrowHandleRepresentation.js +10 -12
- package/Widgets/Representations/CircleContextRepresentation.js +4 -5
- package/Widgets/Representations/RectangleContextRepresentation.js +3 -3
- package/Widgets/Widgets3D/EllipseWidget/behavior.js +5 -5
- package/Widgets/Widgets3D/ImageCroppingWidget/helpers.js +6 -8
- package/Widgets/Widgets3D/PaintWidget/behavior.js +2 -2
- package/Widgets/Widgets3D/ResliceCursorWidget.js +6 -7
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +10 -10
- package/Widgets/Widgets3D/SplineWidget/behavior.js +5 -5
- package/_virtual/rollup-plugin-worker-loader__module_Sources/Filters/General/PaintFilter/PaintFilter.worker.js +1 -1
- package/_virtual/rollup-plugin-worker-loader__module_Sources/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +1 -1
- package/package.json +2 -2
- package/vtk.js +2 -2
- package/_vendor/base64-js/index.js_commonjs-exports.js +0 -1
- package/_vendor/blueimp-md5/js/md5.js_commonjs-module.js +0 -3
- package/_vendor/define-properties/index.js_commonjs-proxy.js +0 -1
- package/_vendor/globalthis/implementation.browser.js_commonjs-module.js +0 -3
- package/_vendor/globalthis/implementation.browser.js_commonjs-proxy.js +0 -1
- package/_vendor/globalthis/polyfill.js_commonjs-proxy.js +0 -1
- package/_vendor/globalthis/shim.js_commonjs-proxy.js +0 -2
- package/_vendor/jszip/dist/jszip.min.js_commonjs-module.js +0 -3
- package/_vendor/object-keys/implementation.js_commonjs-proxy.js +0 -1
- package/_vendor/object-keys/index.js_commonjs-proxy.js +0 -1
- package/_vendor/object-keys/isArguments.js_commonjs-proxy.js +0 -1
- package/_vendor/seedrandom/lib/alea.js_commonjs-module.js +0 -3
- package/_vendor/seedrandom/lib/alea.js_commonjs-proxy.js +0 -1
- package/_vendor/seedrandom/lib/tychei.js_commonjs-module.js +0 -3
- package/_vendor/seedrandom/lib/tychei.js_commonjs-proxy.js +0 -1
- package/_vendor/seedrandom/lib/xor128.js_commonjs-module.js +0 -3
- package/_vendor/seedrandom/lib/xor128.js_commonjs-proxy.js +0 -1
- package/_vendor/seedrandom/lib/xor4096.js_commonjs-module.js +0 -3
- package/_vendor/seedrandom/lib/xor4096.js_commonjs-proxy.js +0 -1
- package/_vendor/seedrandom/lib/xorshift7.js_commonjs-module.js +0 -3
- package/_vendor/seedrandom/lib/xorshift7.js_commonjs-proxy.js +0 -1
- package/_vendor/seedrandom/lib/xorwow.js_commonjs-module.js +0 -3
- package/_vendor/seedrandom/lib/xorwow.js_commonjs-proxy.js +0 -1
- package/_vendor/seedrandom/seedrandom.js_commonjs-module.js +0 -3
- package/_vendor/seedrandom/seedrandom.js_commonjs-proxy.js +0 -1
- package/_vendor/webworker-promise/lib/register.js_commonjs-module.js +0 -3
- package/_vendor/webworker-promise/lib/tiny-emitter.js_commonjs-proxy.js +0 -1
- package/_vendor/webworker-promise/src/tiny-emitter.js_commonjs-proxy.js +0 -1
- package/_vendor/xmlbuilder2/lib/xmlbuilder2.min.js_commonjs-module.js +0 -3
- package/_virtual/_rollup_plugin_ignore_empty_module_placeholder_commonjs-proxy.js +0 -6
- package/_virtual/commonjsHelpers.js +0 -22
- package/_virtual/polyfill-node.buffer.js +0 -1971
- package/_virtual/polyfill-node.global.js +0 -5
- package/_virtual/rollup_plugin_ignore_empty_module_placeholder.js +0 -8
- package/vendor/base64-js/index.js +0 -72
- package/vendor/blueimp-md5/js/md5.js +0 -402
- package/vendor/d3-array/src/array.js +0 -1
- package/vendor/d3-array/src/ascending.js +0 -5
- package/vendor/d3-array/src/bin.js +0 -1
- package/vendor/d3-array/src/bisect.js +0 -10
- package/vendor/d3-array/src/bisector.js +0 -46
- package/vendor/d3-array/src/constant.js +0 -1
- package/vendor/d3-array/src/count.js +0 -1
- package/vendor/d3-array/src/cross.js +0 -1
- package/vendor/d3-array/src/cumsum.js +0 -1
- package/vendor/d3-array/src/descending.js +0 -1
- package/vendor/d3-array/src/deviation.js +0 -1
- package/vendor/d3-array/src/difference.js +0 -1
- package/vendor/d3-array/src/disjoint.js +0 -1
- package/vendor/d3-array/src/every.js +0 -1
- package/vendor/d3-array/src/extent.js +0 -1
- package/vendor/d3-array/src/filter.js +0 -1
- package/vendor/d3-array/src/fsum.js +0 -1
- package/vendor/d3-array/src/greatest.js +0 -1
- package/vendor/d3-array/src/greatestIndex.js +0 -1
- package/vendor/d3-array/src/group.js +0 -1
- package/vendor/d3-array/src/groupSort.js +0 -1
- package/vendor/d3-array/src/identity.js +0 -1
- package/vendor/d3-array/src/index.js +0 -1
- package/vendor/d3-array/src/intersection.js +0 -1
- package/vendor/d3-array/src/least.js +0 -1
- package/vendor/d3-array/src/leastIndex.js +0 -1
- package/vendor/d3-array/src/map.js +0 -1
- package/vendor/d3-array/src/max.js +0 -1
- package/vendor/d3-array/src/maxIndex.js +0 -1
- package/vendor/d3-array/src/mean.js +0 -1
- package/vendor/d3-array/src/median.js +0 -1
- package/vendor/d3-array/src/merge.js +0 -1
- package/vendor/d3-array/src/min.js +0 -1
- package/vendor/d3-array/src/minIndex.js +0 -1
- package/vendor/d3-array/src/mode.js +0 -1
- package/vendor/d3-array/src/nice.js +0 -1
- package/vendor/d3-array/src/number.js +0 -5
- package/vendor/d3-array/src/pairs.js +0 -1
- package/vendor/d3-array/src/permute.js +0 -1
- package/vendor/d3-array/src/quantile.js +0 -1
- package/vendor/d3-array/src/quickselect.js +0 -1
- package/vendor/d3-array/src/range.js +0 -1
- package/vendor/d3-array/src/reduce.js +0 -1
- package/vendor/d3-array/src/reverse.js +0 -1
- package/vendor/d3-array/src/scan.js +0 -1
- package/vendor/d3-array/src/set.js +0 -1
- package/vendor/d3-array/src/shuffle.js +0 -1
- package/vendor/d3-array/src/some.js +0 -1
- package/vendor/d3-array/src/sort.js +0 -1
- package/vendor/d3-array/src/subset.js +0 -1
- package/vendor/d3-array/src/sum.js +0 -1
- package/vendor/d3-array/src/superset.js +0 -1
- package/vendor/d3-array/src/threshold/freedmanDiaconis.js +0 -1
- package/vendor/d3-array/src/threshold/scott.js +0 -1
- package/vendor/d3-array/src/threshold/sturges.js +0 -1
- package/vendor/d3-array/src/ticks.js +0 -56
- package/vendor/d3-array/src/transpose.js +0 -1
- package/vendor/d3-array/src/union.js +0 -1
- package/vendor/d3-array/src/variance.js +0 -1
- package/vendor/d3-array/src/zip.js +0 -1
- package/vendor/d3-color/src/color.js +0 -373
- package/vendor/d3-color/src/cubehelix.js +0 -1
- package/vendor/d3-color/src/define.js +0 -12
- package/vendor/d3-color/src/index.js +0 -1
- package/vendor/d3-color/src/lab.js +0 -1
- package/vendor/d3-color/src/math.js +0 -1
- package/vendor/d3-format/src/defaultLocale.js +0 -20
- package/vendor/d3-format/src/exponent.js +0 -7
- package/vendor/d3-format/src/formatDecimal.js +0 -22
- package/vendor/d3-format/src/formatGroup.js +0 -20
- package/vendor/d3-format/src/formatNumerals.js +0 -9
- package/vendor/d3-format/src/formatPrefixAuto.js +0 -18
- package/vendor/d3-format/src/formatRounded.js +0 -13
- package/vendor/d3-format/src/formatSpecifier.js +0 -49
- package/vendor/d3-format/src/formatTrim.js +0 -13
- package/vendor/d3-format/src/formatTypes.js +0 -21
- package/vendor/d3-format/src/identity.js +0 -5
- package/vendor/d3-format/src/index.js +0 -1
- package/vendor/d3-format/src/locale.js +0 -150
- package/vendor/d3-format/src/precisionFixed.js +0 -7
- package/vendor/d3-format/src/precisionPrefix.js +0 -7
- package/vendor/d3-format/src/precisionRound.js +0 -8
- package/vendor/d3-interpolate/src/array.js +0 -19
- package/vendor/d3-interpolate/src/basis.js +0 -1
- package/vendor/d3-interpolate/src/basisClosed.js +0 -1
- package/vendor/d3-interpolate/src/color.js +0 -26
- package/vendor/d3-interpolate/src/constant.js +0 -3
- package/vendor/d3-interpolate/src/cubehelix.js +0 -1
- package/vendor/d3-interpolate/src/date.js +0 -8
- package/vendor/d3-interpolate/src/discrete.js +0 -1
- package/vendor/d3-interpolate/src/hcl.js +0 -1
- package/vendor/d3-interpolate/src/hsl.js +0 -1
- package/vendor/d3-interpolate/src/hue.js +0 -1
- package/vendor/d3-interpolate/src/index.js +0 -1
- package/vendor/d3-interpolate/src/lab.js +0 -1
- package/vendor/d3-interpolate/src/number.js +0 -7
- package/vendor/d3-interpolate/src/numberArray.js +0 -16
- package/vendor/d3-interpolate/src/object.js +0 -25
- package/vendor/d3-interpolate/src/piecewise.js +0 -1
- package/vendor/d3-interpolate/src/quantize.js +0 -1
- package/vendor/d3-interpolate/src/rgb.js +0 -26
- package/vendor/d3-interpolate/src/round.js +0 -7
- package/vendor/d3-interpolate/src/string.js +0 -66
- package/vendor/d3-interpolate/src/transform/decompose.js +0 -1
- package/vendor/d3-interpolate/src/transform/index.js +0 -1
- package/vendor/d3-interpolate/src/transform/parse.js +0 -1
- package/vendor/d3-interpolate/src/value.js +0 -24
- package/vendor/d3-interpolate/src/zoom.js +0 -1
- package/vendor/d3-scale/src/band.js +0 -1
- package/vendor/d3-scale/src/constant.js +0 -7
- package/vendor/d3-scale/src/continuous.js +0 -129
- package/vendor/d3-scale/src/diverging.js +0 -1
- package/vendor/d3-scale/src/identity.js +0 -1
- package/vendor/d3-scale/src/index.js +0 -1
- package/vendor/d3-scale/src/init.js +0 -10
- package/vendor/d3-scale/src/linear.js +0 -72
- package/vendor/d3-scale/src/log.js +0 -1
- package/vendor/d3-scale/src/nice.js +0 -1
- package/vendor/d3-scale/src/number.js +0 -5
- package/vendor/d3-scale/src/ordinal.js +0 -1
- package/vendor/d3-scale/src/pow.js +0 -1
- package/vendor/d3-scale/src/quantile.js +0 -1
- package/vendor/d3-scale/src/quantize.js +0 -1
- package/vendor/d3-scale/src/radial.js +0 -1
- package/vendor/d3-scale/src/sequential.js +0 -1
- package/vendor/d3-scale/src/sequentialQuantile.js +0 -1
- package/vendor/d3-scale/src/symlog.js +0 -1
- package/vendor/d3-scale/src/threshold.js +0 -1
- package/vendor/d3-scale/src/tickFormat.js +0 -35
- package/vendor/d3-scale/src/time.js +0 -1
- package/vendor/d3-scale/src/utcTime.js +0 -1
- package/vendor/d3-time/src/day.js +0 -1
- package/vendor/d3-time/src/duration.js +0 -1
- package/vendor/d3-time/src/hour.js +0 -1
- package/vendor/d3-time/src/index.js +0 -1
- package/vendor/d3-time/src/interval.js +0 -1
- package/vendor/d3-time/src/millisecond.js +0 -1
- package/vendor/d3-time/src/minute.js +0 -1
- package/vendor/d3-time/src/month.js +0 -1
- package/vendor/d3-time/src/second.js +0 -1
- package/vendor/d3-time/src/ticks.js +0 -1
- package/vendor/d3-time/src/utcDay.js +0 -1
- package/vendor/d3-time/src/utcHour.js +0 -1
- package/vendor/d3-time/src/utcMinute.js +0 -1
- package/vendor/d3-time/src/utcMonth.js +0 -1
- package/vendor/d3-time/src/utcWeek.js +0 -1
- package/vendor/d3-time/src/utcYear.js +0 -1
- package/vendor/d3-time/src/week.js +0 -1
- package/vendor/d3-time/src/year.js +0 -1
- package/vendor/d3-time-format/src/defaultLocale.js +0 -1
- package/vendor/d3-time-format/src/index.js +0 -1
- package/vendor/d3-time-format/src/isoFormat.js +0 -1
- package/vendor/d3-time-format/src/isoParse.js +0 -1
- package/vendor/d3-time-format/src/locale.js +0 -1
- package/vendor/define-properties/index.js +0 -60
- package/vendor/gl-matrix/esm/common.js +0 -30
- package/vendor/gl-matrix/esm/index.js +0 -1
- package/vendor/gl-matrix/esm/mat2.js +0 -1
- package/vendor/gl-matrix/esm/mat2d.js +0 -1
- package/vendor/gl-matrix/esm/mat3.js +0 -817
- package/vendor/gl-matrix/esm/mat4.js +0 -1868
- package/vendor/gl-matrix/esm/quat.js +0 -330
- package/vendor/gl-matrix/esm/quat2.js +0 -1
- package/vendor/gl-matrix/esm/vec2.js +0 -1
- package/vendor/gl-matrix/esm/vec3.js +0 -842
- package/vendor/gl-matrix/esm/vec4.js +0 -153
- package/vendor/globalthis/implementation.browser.js +0 -11
- package/vendor/globalthis/index.js +0 -25
- package/vendor/globalthis/polyfill.js +0 -14
- package/vendor/globalthis/shim.js +0 -25
- package/vendor/internmap/src/index.js +0 -1
- package/vendor/jszip/dist/jszip.min.js +0 -11
- package/vendor/object-keys/implementation.js +0 -124
- package/vendor/object-keys/index.js +0 -35
- package/vendor/object-keys/isArguments.js +0 -17
- package/vendor/pako/dist/pako.esm.mjs.js +0 -6707
- package/vendor/seedrandom/index.js +0 -77
- package/vendor/seedrandom/lib/alea.js +0 -117
- package/vendor/seedrandom/lib/tychei.js +0 -105
- package/vendor/seedrandom/lib/xor128.js +0 -84
- package/vendor/seedrandom/lib/xor4096.js +0 -150
- package/vendor/seedrandom/lib/xorshift7.js +0 -101
- package/vendor/seedrandom/lib/xorwow.js +0 -89
- package/vendor/seedrandom/seedrandom.js +0 -256
- package/vendor/webworker-promise/lib/register.js +0 -158
- package/vendor/webworker-promise/lib/tiny-emitter.js +0 -89
- package/vendor/webworker-promise/src/index.js +0 -110
- package/vendor/webworker-promise/src/tiny-emitter.js +0 -51
- package/vendor/xmlbuilder2/lib/xmlbuilder2.min.js +0 -13
|
@@ -1,817 +0,0 @@
|
|
|
1
|
-
import { A as ARRAY_TYPE, E as EPSILON } from './common.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 3x3 Matrix
|
|
5
|
-
* @module mat3
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Creates a new identity mat3
|
|
10
|
-
*
|
|
11
|
-
* @returns {mat3} a new 3x3 matrix
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
function create() {
|
|
15
|
-
var out = new ARRAY_TYPE(9);
|
|
16
|
-
|
|
17
|
-
if (ARRAY_TYPE != Float32Array) {
|
|
18
|
-
out[1] = 0;
|
|
19
|
-
out[2] = 0;
|
|
20
|
-
out[3] = 0;
|
|
21
|
-
out[5] = 0;
|
|
22
|
-
out[6] = 0;
|
|
23
|
-
out[7] = 0;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
out[0] = 1;
|
|
27
|
-
out[4] = 1;
|
|
28
|
-
out[8] = 1;
|
|
29
|
-
return out;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Copies the upper-left 3x3 values into the given mat3.
|
|
33
|
-
*
|
|
34
|
-
* @param {mat3} out the receiving 3x3 matrix
|
|
35
|
-
* @param {ReadonlyMat4} a the source 4x4 matrix
|
|
36
|
-
* @returns {mat3} out
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
function fromMat4(out, a) {
|
|
40
|
-
out[0] = a[0];
|
|
41
|
-
out[1] = a[1];
|
|
42
|
-
out[2] = a[2];
|
|
43
|
-
out[3] = a[4];
|
|
44
|
-
out[4] = a[5];
|
|
45
|
-
out[5] = a[6];
|
|
46
|
-
out[6] = a[8];
|
|
47
|
-
out[7] = a[9];
|
|
48
|
-
out[8] = a[10];
|
|
49
|
-
return out;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Creates a new mat3 initialized with values from an existing matrix
|
|
53
|
-
*
|
|
54
|
-
* @param {ReadonlyMat3} a matrix to clone
|
|
55
|
-
* @returns {mat3} a new 3x3 matrix
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
function clone(a) {
|
|
59
|
-
var out = new ARRAY_TYPE(9);
|
|
60
|
-
out[0] = a[0];
|
|
61
|
-
out[1] = a[1];
|
|
62
|
-
out[2] = a[2];
|
|
63
|
-
out[3] = a[3];
|
|
64
|
-
out[4] = a[4];
|
|
65
|
-
out[5] = a[5];
|
|
66
|
-
out[6] = a[6];
|
|
67
|
-
out[7] = a[7];
|
|
68
|
-
out[8] = a[8];
|
|
69
|
-
return out;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Copy the values from one mat3 to another
|
|
73
|
-
*
|
|
74
|
-
* @param {mat3} out the receiving matrix
|
|
75
|
-
* @param {ReadonlyMat3} a the source matrix
|
|
76
|
-
* @returns {mat3} out
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
function copy(out, a) {
|
|
80
|
-
out[0] = a[0];
|
|
81
|
-
out[1] = a[1];
|
|
82
|
-
out[2] = a[2];
|
|
83
|
-
out[3] = a[3];
|
|
84
|
-
out[4] = a[4];
|
|
85
|
-
out[5] = a[5];
|
|
86
|
-
out[6] = a[6];
|
|
87
|
-
out[7] = a[7];
|
|
88
|
-
out[8] = a[8];
|
|
89
|
-
return out;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Create a new mat3 with the given values
|
|
93
|
-
*
|
|
94
|
-
* @param {Number} m00 Component in column 0, row 0 position (index 0)
|
|
95
|
-
* @param {Number} m01 Component in column 0, row 1 position (index 1)
|
|
96
|
-
* @param {Number} m02 Component in column 0, row 2 position (index 2)
|
|
97
|
-
* @param {Number} m10 Component in column 1, row 0 position (index 3)
|
|
98
|
-
* @param {Number} m11 Component in column 1, row 1 position (index 4)
|
|
99
|
-
* @param {Number} m12 Component in column 1, row 2 position (index 5)
|
|
100
|
-
* @param {Number} m20 Component in column 2, row 0 position (index 6)
|
|
101
|
-
* @param {Number} m21 Component in column 2, row 1 position (index 7)
|
|
102
|
-
* @param {Number} m22 Component in column 2, row 2 position (index 8)
|
|
103
|
-
* @returns {mat3} A new mat3
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
|
|
107
|
-
var out = new ARRAY_TYPE(9);
|
|
108
|
-
out[0] = m00;
|
|
109
|
-
out[1] = m01;
|
|
110
|
-
out[2] = m02;
|
|
111
|
-
out[3] = m10;
|
|
112
|
-
out[4] = m11;
|
|
113
|
-
out[5] = m12;
|
|
114
|
-
out[6] = m20;
|
|
115
|
-
out[7] = m21;
|
|
116
|
-
out[8] = m22;
|
|
117
|
-
return out;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Set the components of a mat3 to the given values
|
|
121
|
-
*
|
|
122
|
-
* @param {mat3} out the receiving matrix
|
|
123
|
-
* @param {Number} m00 Component in column 0, row 0 position (index 0)
|
|
124
|
-
* @param {Number} m01 Component in column 0, row 1 position (index 1)
|
|
125
|
-
* @param {Number} m02 Component in column 0, row 2 position (index 2)
|
|
126
|
-
* @param {Number} m10 Component in column 1, row 0 position (index 3)
|
|
127
|
-
* @param {Number} m11 Component in column 1, row 1 position (index 4)
|
|
128
|
-
* @param {Number} m12 Component in column 1, row 2 position (index 5)
|
|
129
|
-
* @param {Number} m20 Component in column 2, row 0 position (index 6)
|
|
130
|
-
* @param {Number} m21 Component in column 2, row 1 position (index 7)
|
|
131
|
-
* @param {Number} m22 Component in column 2, row 2 position (index 8)
|
|
132
|
-
* @returns {mat3} out
|
|
133
|
-
*/
|
|
134
|
-
|
|
135
|
-
function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {
|
|
136
|
-
out[0] = m00;
|
|
137
|
-
out[1] = m01;
|
|
138
|
-
out[2] = m02;
|
|
139
|
-
out[3] = m10;
|
|
140
|
-
out[4] = m11;
|
|
141
|
-
out[5] = m12;
|
|
142
|
-
out[6] = m20;
|
|
143
|
-
out[7] = m21;
|
|
144
|
-
out[8] = m22;
|
|
145
|
-
return out;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Set a mat3 to the identity matrix
|
|
149
|
-
*
|
|
150
|
-
* @param {mat3} out the receiving matrix
|
|
151
|
-
* @returns {mat3} out
|
|
152
|
-
*/
|
|
153
|
-
|
|
154
|
-
function identity(out) {
|
|
155
|
-
out[0] = 1;
|
|
156
|
-
out[1] = 0;
|
|
157
|
-
out[2] = 0;
|
|
158
|
-
out[3] = 0;
|
|
159
|
-
out[4] = 1;
|
|
160
|
-
out[5] = 0;
|
|
161
|
-
out[6] = 0;
|
|
162
|
-
out[7] = 0;
|
|
163
|
-
out[8] = 1;
|
|
164
|
-
return out;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Transpose the values of a mat3
|
|
168
|
-
*
|
|
169
|
-
* @param {mat3} out the receiving matrix
|
|
170
|
-
* @param {ReadonlyMat3} a the source matrix
|
|
171
|
-
* @returns {mat3} out
|
|
172
|
-
*/
|
|
173
|
-
|
|
174
|
-
function transpose(out, a) {
|
|
175
|
-
// If we are transposing ourselves we can skip a few steps but have to cache some values
|
|
176
|
-
if (out === a) {
|
|
177
|
-
var a01 = a[1],
|
|
178
|
-
a02 = a[2],
|
|
179
|
-
a12 = a[5];
|
|
180
|
-
out[1] = a[3];
|
|
181
|
-
out[2] = a[6];
|
|
182
|
-
out[3] = a01;
|
|
183
|
-
out[5] = a[7];
|
|
184
|
-
out[6] = a02;
|
|
185
|
-
out[7] = a12;
|
|
186
|
-
} else {
|
|
187
|
-
out[0] = a[0];
|
|
188
|
-
out[1] = a[3];
|
|
189
|
-
out[2] = a[6];
|
|
190
|
-
out[3] = a[1];
|
|
191
|
-
out[4] = a[4];
|
|
192
|
-
out[5] = a[7];
|
|
193
|
-
out[6] = a[2];
|
|
194
|
-
out[7] = a[5];
|
|
195
|
-
out[8] = a[8];
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return out;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Inverts a mat3
|
|
202
|
-
*
|
|
203
|
-
* @param {mat3} out the receiving matrix
|
|
204
|
-
* @param {ReadonlyMat3} a the source matrix
|
|
205
|
-
* @returns {mat3} out
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
function invert(out, a) {
|
|
209
|
-
var a00 = a[0],
|
|
210
|
-
a01 = a[1],
|
|
211
|
-
a02 = a[2];
|
|
212
|
-
var a10 = a[3],
|
|
213
|
-
a11 = a[4],
|
|
214
|
-
a12 = a[5];
|
|
215
|
-
var a20 = a[6],
|
|
216
|
-
a21 = a[7],
|
|
217
|
-
a22 = a[8];
|
|
218
|
-
var b01 = a22 * a11 - a12 * a21;
|
|
219
|
-
var b11 = -a22 * a10 + a12 * a20;
|
|
220
|
-
var b21 = a21 * a10 - a11 * a20; // Calculate the determinant
|
|
221
|
-
|
|
222
|
-
var det = a00 * b01 + a01 * b11 + a02 * b21;
|
|
223
|
-
|
|
224
|
-
if (!det) {
|
|
225
|
-
return null;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
det = 1.0 / det;
|
|
229
|
-
out[0] = b01 * det;
|
|
230
|
-
out[1] = (-a22 * a01 + a02 * a21) * det;
|
|
231
|
-
out[2] = (a12 * a01 - a02 * a11) * det;
|
|
232
|
-
out[3] = b11 * det;
|
|
233
|
-
out[4] = (a22 * a00 - a02 * a20) * det;
|
|
234
|
-
out[5] = (-a12 * a00 + a02 * a10) * det;
|
|
235
|
-
out[6] = b21 * det;
|
|
236
|
-
out[7] = (-a21 * a00 + a01 * a20) * det;
|
|
237
|
-
out[8] = (a11 * a00 - a01 * a10) * det;
|
|
238
|
-
return out;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Calculates the adjugate of a mat3
|
|
242
|
-
*
|
|
243
|
-
* @param {mat3} out the receiving matrix
|
|
244
|
-
* @param {ReadonlyMat3} a the source matrix
|
|
245
|
-
* @returns {mat3} out
|
|
246
|
-
*/
|
|
247
|
-
|
|
248
|
-
function adjoint(out, a) {
|
|
249
|
-
var a00 = a[0],
|
|
250
|
-
a01 = a[1],
|
|
251
|
-
a02 = a[2];
|
|
252
|
-
var a10 = a[3],
|
|
253
|
-
a11 = a[4],
|
|
254
|
-
a12 = a[5];
|
|
255
|
-
var a20 = a[6],
|
|
256
|
-
a21 = a[7],
|
|
257
|
-
a22 = a[8];
|
|
258
|
-
out[0] = a11 * a22 - a12 * a21;
|
|
259
|
-
out[1] = a02 * a21 - a01 * a22;
|
|
260
|
-
out[2] = a01 * a12 - a02 * a11;
|
|
261
|
-
out[3] = a12 * a20 - a10 * a22;
|
|
262
|
-
out[4] = a00 * a22 - a02 * a20;
|
|
263
|
-
out[5] = a02 * a10 - a00 * a12;
|
|
264
|
-
out[6] = a10 * a21 - a11 * a20;
|
|
265
|
-
out[7] = a01 * a20 - a00 * a21;
|
|
266
|
-
out[8] = a00 * a11 - a01 * a10;
|
|
267
|
-
return out;
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Calculates the determinant of a mat3
|
|
271
|
-
*
|
|
272
|
-
* @param {ReadonlyMat3} a the source matrix
|
|
273
|
-
* @returns {Number} determinant of a
|
|
274
|
-
*/
|
|
275
|
-
|
|
276
|
-
function determinant(a) {
|
|
277
|
-
var a00 = a[0],
|
|
278
|
-
a01 = a[1],
|
|
279
|
-
a02 = a[2];
|
|
280
|
-
var a10 = a[3],
|
|
281
|
-
a11 = a[4],
|
|
282
|
-
a12 = a[5];
|
|
283
|
-
var a20 = a[6],
|
|
284
|
-
a21 = a[7],
|
|
285
|
-
a22 = a[8];
|
|
286
|
-
return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Multiplies two mat3's
|
|
290
|
-
*
|
|
291
|
-
* @param {mat3} out the receiving matrix
|
|
292
|
-
* @param {ReadonlyMat3} a the first operand
|
|
293
|
-
* @param {ReadonlyMat3} b the second operand
|
|
294
|
-
* @returns {mat3} out
|
|
295
|
-
*/
|
|
296
|
-
|
|
297
|
-
function multiply(out, a, b) {
|
|
298
|
-
var a00 = a[0],
|
|
299
|
-
a01 = a[1],
|
|
300
|
-
a02 = a[2];
|
|
301
|
-
var a10 = a[3],
|
|
302
|
-
a11 = a[4],
|
|
303
|
-
a12 = a[5];
|
|
304
|
-
var a20 = a[6],
|
|
305
|
-
a21 = a[7],
|
|
306
|
-
a22 = a[8];
|
|
307
|
-
var b00 = b[0],
|
|
308
|
-
b01 = b[1],
|
|
309
|
-
b02 = b[2];
|
|
310
|
-
var b10 = b[3],
|
|
311
|
-
b11 = b[4],
|
|
312
|
-
b12 = b[5];
|
|
313
|
-
var b20 = b[6],
|
|
314
|
-
b21 = b[7],
|
|
315
|
-
b22 = b[8];
|
|
316
|
-
out[0] = b00 * a00 + b01 * a10 + b02 * a20;
|
|
317
|
-
out[1] = b00 * a01 + b01 * a11 + b02 * a21;
|
|
318
|
-
out[2] = b00 * a02 + b01 * a12 + b02 * a22;
|
|
319
|
-
out[3] = b10 * a00 + b11 * a10 + b12 * a20;
|
|
320
|
-
out[4] = b10 * a01 + b11 * a11 + b12 * a21;
|
|
321
|
-
out[5] = b10 * a02 + b11 * a12 + b12 * a22;
|
|
322
|
-
out[6] = b20 * a00 + b21 * a10 + b22 * a20;
|
|
323
|
-
out[7] = b20 * a01 + b21 * a11 + b22 * a21;
|
|
324
|
-
out[8] = b20 * a02 + b21 * a12 + b22 * a22;
|
|
325
|
-
return out;
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Translate a mat3 by the given vector
|
|
329
|
-
*
|
|
330
|
-
* @param {mat3} out the receiving matrix
|
|
331
|
-
* @param {ReadonlyMat3} a the matrix to translate
|
|
332
|
-
* @param {ReadonlyVec2} v vector to translate by
|
|
333
|
-
* @returns {mat3} out
|
|
334
|
-
*/
|
|
335
|
-
|
|
336
|
-
function translate(out, a, v) {
|
|
337
|
-
var a00 = a[0],
|
|
338
|
-
a01 = a[1],
|
|
339
|
-
a02 = a[2],
|
|
340
|
-
a10 = a[3],
|
|
341
|
-
a11 = a[4],
|
|
342
|
-
a12 = a[5],
|
|
343
|
-
a20 = a[6],
|
|
344
|
-
a21 = a[7],
|
|
345
|
-
a22 = a[8],
|
|
346
|
-
x = v[0],
|
|
347
|
-
y = v[1];
|
|
348
|
-
out[0] = a00;
|
|
349
|
-
out[1] = a01;
|
|
350
|
-
out[2] = a02;
|
|
351
|
-
out[3] = a10;
|
|
352
|
-
out[4] = a11;
|
|
353
|
-
out[5] = a12;
|
|
354
|
-
out[6] = x * a00 + y * a10 + a20;
|
|
355
|
-
out[7] = x * a01 + y * a11 + a21;
|
|
356
|
-
out[8] = x * a02 + y * a12 + a22;
|
|
357
|
-
return out;
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Rotates a mat3 by the given angle
|
|
361
|
-
*
|
|
362
|
-
* @param {mat3} out the receiving matrix
|
|
363
|
-
* @param {ReadonlyMat3} a the matrix to rotate
|
|
364
|
-
* @param {Number} rad the angle to rotate the matrix by
|
|
365
|
-
* @returns {mat3} out
|
|
366
|
-
*/
|
|
367
|
-
|
|
368
|
-
function rotate(out, a, rad) {
|
|
369
|
-
var a00 = a[0],
|
|
370
|
-
a01 = a[1],
|
|
371
|
-
a02 = a[2],
|
|
372
|
-
a10 = a[3],
|
|
373
|
-
a11 = a[4],
|
|
374
|
-
a12 = a[5],
|
|
375
|
-
a20 = a[6],
|
|
376
|
-
a21 = a[7],
|
|
377
|
-
a22 = a[8],
|
|
378
|
-
s = Math.sin(rad),
|
|
379
|
-
c = Math.cos(rad);
|
|
380
|
-
out[0] = c * a00 + s * a10;
|
|
381
|
-
out[1] = c * a01 + s * a11;
|
|
382
|
-
out[2] = c * a02 + s * a12;
|
|
383
|
-
out[3] = c * a10 - s * a00;
|
|
384
|
-
out[4] = c * a11 - s * a01;
|
|
385
|
-
out[5] = c * a12 - s * a02;
|
|
386
|
-
out[6] = a20;
|
|
387
|
-
out[7] = a21;
|
|
388
|
-
out[8] = a22;
|
|
389
|
-
return out;
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* Scales the mat3 by the dimensions in the given vec2
|
|
393
|
-
*
|
|
394
|
-
* @param {mat3} out the receiving matrix
|
|
395
|
-
* @param {ReadonlyMat3} a the matrix to rotate
|
|
396
|
-
* @param {ReadonlyVec2} v the vec2 to scale the matrix by
|
|
397
|
-
* @returns {mat3} out
|
|
398
|
-
**/
|
|
399
|
-
|
|
400
|
-
function scale(out, a, v) {
|
|
401
|
-
var x = v[0],
|
|
402
|
-
y = v[1];
|
|
403
|
-
out[0] = x * a[0];
|
|
404
|
-
out[1] = x * a[1];
|
|
405
|
-
out[2] = x * a[2];
|
|
406
|
-
out[3] = y * a[3];
|
|
407
|
-
out[4] = y * a[4];
|
|
408
|
-
out[5] = y * a[5];
|
|
409
|
-
out[6] = a[6];
|
|
410
|
-
out[7] = a[7];
|
|
411
|
-
out[8] = a[8];
|
|
412
|
-
return out;
|
|
413
|
-
}
|
|
414
|
-
/**
|
|
415
|
-
* Creates a matrix from a vector translation
|
|
416
|
-
* This is equivalent to (but much faster than):
|
|
417
|
-
*
|
|
418
|
-
* mat3.identity(dest);
|
|
419
|
-
* mat3.translate(dest, dest, vec);
|
|
420
|
-
*
|
|
421
|
-
* @param {mat3} out mat3 receiving operation result
|
|
422
|
-
* @param {ReadonlyVec2} v Translation vector
|
|
423
|
-
* @returns {mat3} out
|
|
424
|
-
*/
|
|
425
|
-
|
|
426
|
-
function fromTranslation(out, v) {
|
|
427
|
-
out[0] = 1;
|
|
428
|
-
out[1] = 0;
|
|
429
|
-
out[2] = 0;
|
|
430
|
-
out[3] = 0;
|
|
431
|
-
out[4] = 1;
|
|
432
|
-
out[5] = 0;
|
|
433
|
-
out[6] = v[0];
|
|
434
|
-
out[7] = v[1];
|
|
435
|
-
out[8] = 1;
|
|
436
|
-
return out;
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Creates a matrix from a given angle
|
|
440
|
-
* This is equivalent to (but much faster than):
|
|
441
|
-
*
|
|
442
|
-
* mat3.identity(dest);
|
|
443
|
-
* mat3.rotate(dest, dest, rad);
|
|
444
|
-
*
|
|
445
|
-
* @param {mat3} out mat3 receiving operation result
|
|
446
|
-
* @param {Number} rad the angle to rotate the matrix by
|
|
447
|
-
* @returns {mat3} out
|
|
448
|
-
*/
|
|
449
|
-
|
|
450
|
-
function fromRotation(out, rad) {
|
|
451
|
-
var s = Math.sin(rad),
|
|
452
|
-
c = Math.cos(rad);
|
|
453
|
-
out[0] = c;
|
|
454
|
-
out[1] = s;
|
|
455
|
-
out[2] = 0;
|
|
456
|
-
out[3] = -s;
|
|
457
|
-
out[4] = c;
|
|
458
|
-
out[5] = 0;
|
|
459
|
-
out[6] = 0;
|
|
460
|
-
out[7] = 0;
|
|
461
|
-
out[8] = 1;
|
|
462
|
-
return out;
|
|
463
|
-
}
|
|
464
|
-
/**
|
|
465
|
-
* Creates a matrix from a vector scaling
|
|
466
|
-
* This is equivalent to (but much faster than):
|
|
467
|
-
*
|
|
468
|
-
* mat3.identity(dest);
|
|
469
|
-
* mat3.scale(dest, dest, vec);
|
|
470
|
-
*
|
|
471
|
-
* @param {mat3} out mat3 receiving operation result
|
|
472
|
-
* @param {ReadonlyVec2} v Scaling vector
|
|
473
|
-
* @returns {mat3} out
|
|
474
|
-
*/
|
|
475
|
-
|
|
476
|
-
function fromScaling(out, v) {
|
|
477
|
-
out[0] = v[0];
|
|
478
|
-
out[1] = 0;
|
|
479
|
-
out[2] = 0;
|
|
480
|
-
out[3] = 0;
|
|
481
|
-
out[4] = v[1];
|
|
482
|
-
out[5] = 0;
|
|
483
|
-
out[6] = 0;
|
|
484
|
-
out[7] = 0;
|
|
485
|
-
out[8] = 1;
|
|
486
|
-
return out;
|
|
487
|
-
}
|
|
488
|
-
/**
|
|
489
|
-
* Copies the values from a mat2d into a mat3
|
|
490
|
-
*
|
|
491
|
-
* @param {mat3} out the receiving matrix
|
|
492
|
-
* @param {ReadonlyMat2d} a the matrix to copy
|
|
493
|
-
* @returns {mat3} out
|
|
494
|
-
**/
|
|
495
|
-
|
|
496
|
-
function fromMat2d(out, a) {
|
|
497
|
-
out[0] = a[0];
|
|
498
|
-
out[1] = a[1];
|
|
499
|
-
out[2] = 0;
|
|
500
|
-
out[3] = a[2];
|
|
501
|
-
out[4] = a[3];
|
|
502
|
-
out[5] = 0;
|
|
503
|
-
out[6] = a[4];
|
|
504
|
-
out[7] = a[5];
|
|
505
|
-
out[8] = 1;
|
|
506
|
-
return out;
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* Calculates a 3x3 matrix from the given quaternion
|
|
510
|
-
*
|
|
511
|
-
* @param {mat3} out mat3 receiving operation result
|
|
512
|
-
* @param {ReadonlyQuat} q Quaternion to create matrix from
|
|
513
|
-
*
|
|
514
|
-
* @returns {mat3} out
|
|
515
|
-
*/
|
|
516
|
-
|
|
517
|
-
function fromQuat(out, q) {
|
|
518
|
-
var x = q[0],
|
|
519
|
-
y = q[1],
|
|
520
|
-
z = q[2],
|
|
521
|
-
w = q[3];
|
|
522
|
-
var x2 = x + x;
|
|
523
|
-
var y2 = y + y;
|
|
524
|
-
var z2 = z + z;
|
|
525
|
-
var xx = x * x2;
|
|
526
|
-
var yx = y * x2;
|
|
527
|
-
var yy = y * y2;
|
|
528
|
-
var zx = z * x2;
|
|
529
|
-
var zy = z * y2;
|
|
530
|
-
var zz = z * z2;
|
|
531
|
-
var wx = w * x2;
|
|
532
|
-
var wy = w * y2;
|
|
533
|
-
var wz = w * z2;
|
|
534
|
-
out[0] = 1 - yy - zz;
|
|
535
|
-
out[3] = yx - wz;
|
|
536
|
-
out[6] = zx + wy;
|
|
537
|
-
out[1] = yx + wz;
|
|
538
|
-
out[4] = 1 - xx - zz;
|
|
539
|
-
out[7] = zy - wx;
|
|
540
|
-
out[2] = zx - wy;
|
|
541
|
-
out[5] = zy + wx;
|
|
542
|
-
out[8] = 1 - xx - yy;
|
|
543
|
-
return out;
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
* Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
|
|
547
|
-
*
|
|
548
|
-
* @param {mat3} out mat3 receiving operation result
|
|
549
|
-
* @param {ReadonlyMat4} a Mat4 to derive the normal matrix from
|
|
550
|
-
*
|
|
551
|
-
* @returns {mat3} out
|
|
552
|
-
*/
|
|
553
|
-
|
|
554
|
-
function normalFromMat4(out, a) {
|
|
555
|
-
var a00 = a[0],
|
|
556
|
-
a01 = a[1],
|
|
557
|
-
a02 = a[2],
|
|
558
|
-
a03 = a[3];
|
|
559
|
-
var a10 = a[4],
|
|
560
|
-
a11 = a[5],
|
|
561
|
-
a12 = a[6],
|
|
562
|
-
a13 = a[7];
|
|
563
|
-
var a20 = a[8],
|
|
564
|
-
a21 = a[9],
|
|
565
|
-
a22 = a[10],
|
|
566
|
-
a23 = a[11];
|
|
567
|
-
var a30 = a[12],
|
|
568
|
-
a31 = a[13],
|
|
569
|
-
a32 = a[14],
|
|
570
|
-
a33 = a[15];
|
|
571
|
-
var b00 = a00 * a11 - a01 * a10;
|
|
572
|
-
var b01 = a00 * a12 - a02 * a10;
|
|
573
|
-
var b02 = a00 * a13 - a03 * a10;
|
|
574
|
-
var b03 = a01 * a12 - a02 * a11;
|
|
575
|
-
var b04 = a01 * a13 - a03 * a11;
|
|
576
|
-
var b05 = a02 * a13 - a03 * a12;
|
|
577
|
-
var b06 = a20 * a31 - a21 * a30;
|
|
578
|
-
var b07 = a20 * a32 - a22 * a30;
|
|
579
|
-
var b08 = a20 * a33 - a23 * a30;
|
|
580
|
-
var b09 = a21 * a32 - a22 * a31;
|
|
581
|
-
var b10 = a21 * a33 - a23 * a31;
|
|
582
|
-
var b11 = a22 * a33 - a23 * a32; // Calculate the determinant
|
|
583
|
-
|
|
584
|
-
var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
|
585
|
-
|
|
586
|
-
if (!det) {
|
|
587
|
-
return null;
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
det = 1.0 / det;
|
|
591
|
-
out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
|
|
592
|
-
out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
|
|
593
|
-
out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
|
|
594
|
-
out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
|
|
595
|
-
out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
|
|
596
|
-
out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
|
|
597
|
-
out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
|
|
598
|
-
out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
|
|
599
|
-
out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
|
|
600
|
-
return out;
|
|
601
|
-
}
|
|
602
|
-
/**
|
|
603
|
-
* Generates a 2D projection matrix with the given bounds
|
|
604
|
-
*
|
|
605
|
-
* @param {mat3} out mat3 frustum matrix will be written into
|
|
606
|
-
* @param {number} width Width of your gl context
|
|
607
|
-
* @param {number} height Height of gl context
|
|
608
|
-
* @returns {mat3} out
|
|
609
|
-
*/
|
|
610
|
-
|
|
611
|
-
function projection(out, width, height) {
|
|
612
|
-
out[0] = 2 / width;
|
|
613
|
-
out[1] = 0;
|
|
614
|
-
out[2] = 0;
|
|
615
|
-
out[3] = 0;
|
|
616
|
-
out[4] = -2 / height;
|
|
617
|
-
out[5] = 0;
|
|
618
|
-
out[6] = -1;
|
|
619
|
-
out[7] = 1;
|
|
620
|
-
out[8] = 1;
|
|
621
|
-
return out;
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* Returns a string representation of a mat3
|
|
625
|
-
*
|
|
626
|
-
* @param {ReadonlyMat3} a matrix to represent as a string
|
|
627
|
-
* @returns {String} string representation of the matrix
|
|
628
|
-
*/
|
|
629
|
-
|
|
630
|
-
function str(a) {
|
|
631
|
-
return "mat3(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ", " + a[8] + ")";
|
|
632
|
-
}
|
|
633
|
-
/**
|
|
634
|
-
* Returns Frobenius norm of a mat3
|
|
635
|
-
*
|
|
636
|
-
* @param {ReadonlyMat3} a the matrix to calculate Frobenius norm of
|
|
637
|
-
* @returns {Number} Frobenius norm
|
|
638
|
-
*/
|
|
639
|
-
|
|
640
|
-
function frob(a) {
|
|
641
|
-
return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);
|
|
642
|
-
}
|
|
643
|
-
/**
|
|
644
|
-
* Adds two mat3's
|
|
645
|
-
*
|
|
646
|
-
* @param {mat3} out the receiving matrix
|
|
647
|
-
* @param {ReadonlyMat3} a the first operand
|
|
648
|
-
* @param {ReadonlyMat3} b the second operand
|
|
649
|
-
* @returns {mat3} out
|
|
650
|
-
*/
|
|
651
|
-
|
|
652
|
-
function add(out, a, b) {
|
|
653
|
-
out[0] = a[0] + b[0];
|
|
654
|
-
out[1] = a[1] + b[1];
|
|
655
|
-
out[2] = a[2] + b[2];
|
|
656
|
-
out[3] = a[3] + b[3];
|
|
657
|
-
out[4] = a[4] + b[4];
|
|
658
|
-
out[5] = a[5] + b[5];
|
|
659
|
-
out[6] = a[6] + b[6];
|
|
660
|
-
out[7] = a[7] + b[7];
|
|
661
|
-
out[8] = a[8] + b[8];
|
|
662
|
-
return out;
|
|
663
|
-
}
|
|
664
|
-
/**
|
|
665
|
-
* Subtracts matrix b from matrix a
|
|
666
|
-
*
|
|
667
|
-
* @param {mat3} out the receiving matrix
|
|
668
|
-
* @param {ReadonlyMat3} a the first operand
|
|
669
|
-
* @param {ReadonlyMat3} b the second operand
|
|
670
|
-
* @returns {mat3} out
|
|
671
|
-
*/
|
|
672
|
-
|
|
673
|
-
function subtract(out, a, b) {
|
|
674
|
-
out[0] = a[0] - b[0];
|
|
675
|
-
out[1] = a[1] - b[1];
|
|
676
|
-
out[2] = a[2] - b[2];
|
|
677
|
-
out[3] = a[3] - b[3];
|
|
678
|
-
out[4] = a[4] - b[4];
|
|
679
|
-
out[5] = a[5] - b[5];
|
|
680
|
-
out[6] = a[6] - b[6];
|
|
681
|
-
out[7] = a[7] - b[7];
|
|
682
|
-
out[8] = a[8] - b[8];
|
|
683
|
-
return out;
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* Multiply each element of the matrix by a scalar.
|
|
687
|
-
*
|
|
688
|
-
* @param {mat3} out the receiving matrix
|
|
689
|
-
* @param {ReadonlyMat3} a the matrix to scale
|
|
690
|
-
* @param {Number} b amount to scale the matrix's elements by
|
|
691
|
-
* @returns {mat3} out
|
|
692
|
-
*/
|
|
693
|
-
|
|
694
|
-
function multiplyScalar(out, a, b) {
|
|
695
|
-
out[0] = a[0] * b;
|
|
696
|
-
out[1] = a[1] * b;
|
|
697
|
-
out[2] = a[2] * b;
|
|
698
|
-
out[3] = a[3] * b;
|
|
699
|
-
out[4] = a[4] * b;
|
|
700
|
-
out[5] = a[5] * b;
|
|
701
|
-
out[6] = a[6] * b;
|
|
702
|
-
out[7] = a[7] * b;
|
|
703
|
-
out[8] = a[8] * b;
|
|
704
|
-
return out;
|
|
705
|
-
}
|
|
706
|
-
/**
|
|
707
|
-
* Adds two mat3's after multiplying each element of the second operand by a scalar value.
|
|
708
|
-
*
|
|
709
|
-
* @param {mat3} out the receiving vector
|
|
710
|
-
* @param {ReadonlyMat3} a the first operand
|
|
711
|
-
* @param {ReadonlyMat3} b the second operand
|
|
712
|
-
* @param {Number} scale the amount to scale b's elements by before adding
|
|
713
|
-
* @returns {mat3} out
|
|
714
|
-
*/
|
|
715
|
-
|
|
716
|
-
function multiplyScalarAndAdd(out, a, b, scale) {
|
|
717
|
-
out[0] = a[0] + b[0] * scale;
|
|
718
|
-
out[1] = a[1] + b[1] * scale;
|
|
719
|
-
out[2] = a[2] + b[2] * scale;
|
|
720
|
-
out[3] = a[3] + b[3] * scale;
|
|
721
|
-
out[4] = a[4] + b[4] * scale;
|
|
722
|
-
out[5] = a[5] + b[5] * scale;
|
|
723
|
-
out[6] = a[6] + b[6] * scale;
|
|
724
|
-
out[7] = a[7] + b[7] * scale;
|
|
725
|
-
out[8] = a[8] + b[8] * scale;
|
|
726
|
-
return out;
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
|
|
730
|
-
*
|
|
731
|
-
* @param {ReadonlyMat3} a The first matrix.
|
|
732
|
-
* @param {ReadonlyMat3} b The second matrix.
|
|
733
|
-
* @returns {Boolean} True if the matrices are equal, false otherwise.
|
|
734
|
-
*/
|
|
735
|
-
|
|
736
|
-
function exactEquals(a, b) {
|
|
737
|
-
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8];
|
|
738
|
-
}
|
|
739
|
-
/**
|
|
740
|
-
* Returns whether or not the matrices have approximately the same elements in the same position.
|
|
741
|
-
*
|
|
742
|
-
* @param {ReadonlyMat3} a The first matrix.
|
|
743
|
-
* @param {ReadonlyMat3} b The second matrix.
|
|
744
|
-
* @returns {Boolean} True if the matrices are equal, false otherwise.
|
|
745
|
-
*/
|
|
746
|
-
|
|
747
|
-
function equals(a, b) {
|
|
748
|
-
var a0 = a[0],
|
|
749
|
-
a1 = a[1],
|
|
750
|
-
a2 = a[2],
|
|
751
|
-
a3 = a[3],
|
|
752
|
-
a4 = a[4],
|
|
753
|
-
a5 = a[5],
|
|
754
|
-
a6 = a[6],
|
|
755
|
-
a7 = a[7],
|
|
756
|
-
a8 = a[8];
|
|
757
|
-
var b0 = b[0],
|
|
758
|
-
b1 = b[1],
|
|
759
|
-
b2 = b[2],
|
|
760
|
-
b3 = b[3],
|
|
761
|
-
b4 = b[4],
|
|
762
|
-
b5 = b[5],
|
|
763
|
-
b6 = b[6],
|
|
764
|
-
b7 = b[7],
|
|
765
|
-
b8 = b[8];
|
|
766
|
-
return Math.abs(a0 - b0) <= EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8));
|
|
767
|
-
}
|
|
768
|
-
/**
|
|
769
|
-
* Alias for {@link mat3.multiply}
|
|
770
|
-
* @function
|
|
771
|
-
*/
|
|
772
|
-
|
|
773
|
-
var mul = multiply;
|
|
774
|
-
/**
|
|
775
|
-
* Alias for {@link mat3.subtract}
|
|
776
|
-
* @function
|
|
777
|
-
*/
|
|
778
|
-
|
|
779
|
-
var sub = subtract;
|
|
780
|
-
|
|
781
|
-
var mat3 = /*#__PURE__*/Object.freeze({
|
|
782
|
-
__proto__: null,
|
|
783
|
-
create: create,
|
|
784
|
-
fromMat4: fromMat4,
|
|
785
|
-
clone: clone,
|
|
786
|
-
copy: copy,
|
|
787
|
-
fromValues: fromValues,
|
|
788
|
-
set: set,
|
|
789
|
-
identity: identity,
|
|
790
|
-
transpose: transpose,
|
|
791
|
-
invert: invert,
|
|
792
|
-
adjoint: adjoint,
|
|
793
|
-
determinant: determinant,
|
|
794
|
-
multiply: multiply,
|
|
795
|
-
translate: translate,
|
|
796
|
-
rotate: rotate,
|
|
797
|
-
scale: scale,
|
|
798
|
-
fromTranslation: fromTranslation,
|
|
799
|
-
fromRotation: fromRotation,
|
|
800
|
-
fromScaling: fromScaling,
|
|
801
|
-
fromMat2d: fromMat2d,
|
|
802
|
-
fromQuat: fromQuat,
|
|
803
|
-
normalFromMat4: normalFromMat4,
|
|
804
|
-
projection: projection,
|
|
805
|
-
str: str,
|
|
806
|
-
frob: frob,
|
|
807
|
-
add: add,
|
|
808
|
-
subtract: subtract,
|
|
809
|
-
multiplyScalar: multiplyScalar,
|
|
810
|
-
multiplyScalarAndAdd: multiplyScalarAndAdd,
|
|
811
|
-
exactEquals: exactEquals,
|
|
812
|
-
equals: equals,
|
|
813
|
-
mul: mul,
|
|
814
|
-
sub: sub
|
|
815
|
-
});
|
|
816
|
-
|
|
817
|
-
export { invert as a, mat3 as b, create as c, fromMat4 as f, identity as i, multiply as m, transpose as t };
|