diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index d1a24d79d95..00000000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -**/webpack.config.js diff --git a/.eslintrc.js b/.eslintrc.js index 6b854e808dd..5741c28fa8d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,48 +1,35 @@ +var prettierConf = require('./prettier.config.js'); + module.exports = { - extends: ['airbnb'], // , 'prettier' + extends: ['airbnb', 'prettier'], rules: { - 'max-len': ["warn", 160, 4, {"ignoreUrls": true}], 'no-multi-spaces': ["error", { exceptions: { "ImportDeclaration": true } }], 'no-param-reassign': ["error", { props: false }], 'no-unused-vars': ["error", { args: 'none' }], - 'react/jsx-filename-extension': ["error", { "extensions": [".js"] }], - 'no-mixed-operators': ["error", {"allowSamePrecedence": true}], + // 'no-mixed-operators': 'error', - // Should fix that at some point but too much work... - 'react/no-is-mounted': "warn", - 'no-var': 0, - 'one-var': 0, - 'react/prefer-es6-class': 0, + // Should fix that at some point 'no-nested-ternary': 0, - - // Not for us ;-) - 'jsx-a11y/label-has-for': 0, - 'no-console': 0, - 'no-plusplus': 0, - 'linebreak-style': 0, - - // Not for vtk.js - // 'import/no-extraneous-dependencies': ["error", { "devDependencies": true }], - 'import/no-extraneous-dependencies': 0, - 'import/no-unresolved': 0, - 'import/extensions': 0, + 'prefer-destructuring': 0, 'import/no-named-as-default': 0, 'import/no-named-as-default-member': 0, - - // May want to remove at some point 'no-restricted-properties': 0, - 'function-paren-newline': 0, - 'indent': 0, 'no-multi-spaces': 0, - 'object-curly-newline': 0, - 'prefer-destructuring': 0, 'prefer-promise-reject-errors': 0, - 'switch-colon-spacing': 0, 'spaced-comment': 0, + 'no-var': 0, + 'import/extensions': 0, + + // Not for us ;-) + 'jsx-a11y/label-has-for': 0, + 'no-console': 0, + 'no-plusplus': 0, + + 'prettier/prettier': ['error', prettierConf], }, - // plugins: [ - // 'prettier' - // ], + plugins: [ + 'prettier' + ], globals: { __BASE_PATH__: false, VRFrameData: true, @@ -51,15 +38,7 @@ module.exports = { 'import/resolver': 'webpack' }, env: { + es6: true, browser: true, }, - // rules: { - // 'prettier/prettier': [ - // 'error', { - // printWidth: 100, - // singleQuote: true, - // trailingComma: "es5" - // } - // ], - // } }; diff --git a/.travis.yml b/.travis.yml index 1f629bbdf40..178af556b34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,7 @@ cache: script: - npm install - npm run build:release + - npm run validate - npm run test:travis - git config --global user.name "Travis CI" - git config --global user.email "sebastien.jourdain@kitware.com" diff --git a/Sources/Common/Core/CellArray/index.js b/Sources/Common/Core/CellArray/index.js index e947f369bd4..fa9a3cb2353 100644 --- a/Sources/Common/Core/CellArray/index.js +++ b/Sources/Common/Core/CellArray/index.js @@ -1,5 +1,5 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import macro from 'vtk.js/Sources/macro'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; import { VtkDataTypes } from 'vtk.js/Sources/Common/Core/DataArray/Constants'; // ---------------------------------------------------------------------------- diff --git a/Sources/Common/Core/DataArray/Constants.js b/Sources/Common/Core/DataArray/Constants.js index d2e69b17fc5..4f8cce3ec56 100644 --- a/Sources/Common/Core/DataArray/Constants.js +++ b/Sources/Common/Core/DataArray/Constants.js @@ -1,4 +1,4 @@ -export const DataTypeByteSize = { +const DataTypeByteSize = { Int8Array: 1, Uint8Array: 1, Uint8ClampedArray: 1, @@ -10,7 +10,7 @@ export const DataTypeByteSize = { Float64Array: 8, }; -export const VtkDataTypes = { +const VtkDataTypes = { VOID: '', // FIXME not sure to know what that shoud be CHAR: 'Int8Array', SIGNED_CHAR: 'Int8Array', @@ -23,7 +23,7 @@ export const VtkDataTypes = { DOUBLE: 'Float64Array', }; -export const DefaultDataType = VtkDataTypes.FLOAT; +const DefaultDataType = VtkDataTypes.FLOAT; export default { DefaultDataType, diff --git a/Sources/Common/Core/DataArray/index.js b/Sources/Common/Core/DataArray/index.js index 714eb471463..27280ab7dee 100644 --- a/Sources/Common/Core/DataArray/index.js +++ b/Sources/Common/Core/DataArray/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import Constants from 'vtk.js/Sources/Common/Core/DataArray/Constants'; const { DefaultDataType } = Constants; @@ -42,7 +42,10 @@ function ensureRangeSize(rangeArray, size = 0) { } function getDataType(typedArray) { - return Object.prototype.toString.call(typedArray).split(' ')[1].slice(0, -1); + return Object.prototype.toString + .call(typedArray) + .split(' ')[1] + .slice(0, -1); } // ---------------------------------------------------------------------------- @@ -73,7 +76,7 @@ function vtkDataArray(publicAPI, model) { // Return the data component at the location specified by tupleIdx and // compIdx. publicAPI.getComponent = (tupleIdx, compIdx = 0) => - model.values[(tupleIdx * model.numberOfComponents) + compIdx]; + model.values[tupleIdx * model.numberOfComponents + compIdx]; // Description: // Set the data component at the location specified by tupleIdx and compIdx @@ -82,8 +85,8 @@ function vtkDataArray(publicAPI, model) { // NumberOfComponents. Make sure enough memory has been allocated // (use SetNumberOfTuples() and SetNumberOfComponents()). publicAPI.setComponent = (tupleIdx, compIdx, value) => { - if (value !== model.values[(tupleIdx * model.numberOfComponents) + compIdx]) { - model.values[(tupleIdx * model.numberOfComponents) + compIdx] = value; + if (value !== model.values[tupleIdx * model.numberOfComponents + compIdx]) { + model.values[tupleIdx * model.numberOfComponents + compIdx] = value; dataChange(); } }; @@ -91,7 +94,8 @@ function vtkDataArray(publicAPI, model) { publicAPI.getData = () => model.values; publicAPI.getRange = (componentIndex = 0) => { - const rangeIdx = componentIndex < 0 ? model.numberOfComponents : componentIndex; + const rangeIdx = + componentIndex < 0 ? model.numberOfComponents : componentIndex; let range = null; if (!model.ranges) { @@ -106,7 +110,11 @@ function vtkDataArray(publicAPI, model) { } // Need to compute ranges... - range = computeRange(model.values, componentIndex, model.numberOfComponents); + range = computeRange( + model.values, + componentIndex, + model.numberOfComponents + ); model.ranges[rangeIdx] = range; model.rangeTuple[0] = range.min; model.rangeTuple[1] = range.max; @@ -135,15 +143,17 @@ function vtkDataArray(publicAPI, model) { publicAPI.getTupleLocation = (idx = 1) => idx * model.numberOfComponents; publicAPI.getNumberOfComponents = () => model.numberOfComponents; publicAPI.getNumberOfValues = () => model.values.length; - publicAPI.getNumberOfTuples = () => model.values.length / model.numberOfComponents; + publicAPI.getNumberOfTuples = () => + model.values.length / model.numberOfComponents; publicAPI.getDataType = () => model.dataType; /* eslint-disable no-use-before-define */ - publicAPI.newClone = () => newInstance({ - empty: true, - name: model.name, - dataType: model.dataType, - numberOfComponents: model.numberOfComponents, - }); + publicAPI.newClone = () => + newInstance({ + empty: true, + name: model.name, + dataType: model.dataType, + numberOfComponents: model.numberOfComponents, + }); /* eslint-enable no-use-before-define */ publicAPI.getName = () => { @@ -173,7 +183,9 @@ function vtkDataArray(publicAPI, model) { // Override serialization support publicAPI.getState = () => { - const jsonArchive = Object.assign({}, model, { vtkClass: publicAPI.getClassName() }); + const jsonArchive = Object.assign({}, model, { + vtkClass: publicAPI.getClassName(), + }); // Convert typed array to regular array jsonArchive.values = Array.from(jsonArchive.values); @@ -188,9 +200,11 @@ function vtkDataArray(publicAPI, model) { // Sort resulting object by key name const sortedObj = {}; - Object.keys(jsonArchive).sort().forEach((name) => { - sortedObj[name] = jsonArchive[name]; - }); + Object.keys(jsonArchive) + .sort() + .forEach((name) => { + sortedObj[name] = jsonArchive[name]; + }); // Remove mtime if (sortedObj.mtime) { @@ -220,8 +234,10 @@ const DEFAULT_VALUES = { export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); - if ((!model.empty && !model.values && !model.size)) { - throw new TypeError('Cannot create vtkDataArray object without: size > 0, values'); + if (!model.empty && !model.values && !model.size) { + throw new TypeError( + 'Cannot create vtkDataArray object without: size > 0, values' + ); } if (!model.values) { diff --git a/Sources/Common/Core/ImageHelper/index.js b/Sources/Common/Core/ImageHelper/index.js index c1536f55487..b51c99da224 100644 --- a/Sources/Common/Core/ImageHelper/index.js +++ b/Sources/Common/Core/ImageHelper/index.js @@ -12,14 +12,22 @@ import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; function canvasToImageData(canvas, boundingBox = [0, 0, 0, 0]) { const [top, left, width, height] = boundingBox; const ctxt = canvas.getContext('2d'); - const idata = ctxt.getImageData(top, left, width || canvas.width, height || canvas.height); + const idata = ctxt.getImageData( + top, + left, + width || canvas.width, + height || canvas.height + ); const imageData = vtkImageData.newInstance({ type: 'vtkImageData' }); imageData.setOrigin(0, 0, 0); imageData.setSpacing(1, 1, 1); imageData.setExtent(0, canvas.width - 1, 0, canvas.height - 1, 0, 0); - const scalars = vtkDataArray.newInstance({ numberOfComponents: 4, values: idata.data }); + const scalars = vtkDataArray.newInstance({ + numberOfComponents: 4, + values: idata.data, + }); scalars.setName('scalars'); imageData.getPointData().setScalars(scalars); diff --git a/Sources/Common/Core/LookupTable/index.js b/Sources/Common/Core/LookupTable/index.js index 8520ce3f002..13ce2f25098 100644 --- a/Sources/Common/Core/LookupTable/index.js +++ b/Sources/Common/Core/LookupTable/index.js @@ -1,7 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; -import vtkScalarsToColors from 'vtk.js/Sources/Common/Core/ScalarsToColors'; -import { ScalarMappingTarget } from 'vtk.js/Sources/Common/Core/ScalarsToColors/Constants'; +import macro from 'vtk.js/Sources/macro'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkScalarsToColors from 'vtk.js/Sources/Common/Core/ScalarsToColors'; +import { ScalarMappingTarget } from 'vtk.js/Sources/Common/Core/ScalarsToColors/Constants'; // ---------------------------------------------------------------------------- // Global methods @@ -33,9 +33,15 @@ function vtkLookupTable(publicAPI, model) { publicAPI.isOpaque = () => { if (model.opaqueFlagBuildTime.getMTime() < publicAPI.getMTime()) { let opaque = true; - if (model.nanColor[3] < 1.0) { opaque = 0; } - if (model.useBelowRangeColor && model.belowRangeColor[3] < 1.0) { opaque = 0; } - if (model.useAboveRangeColor && model.aboveRangeColor[3] < 1.0) { opaque = 0; } + if (model.nanColor[3] < 1.0) { + opaque = 0; + } + if (model.useBelowRangeColor && model.belowRangeColor[3] < 1.0) { + opaque = 0; + } + if (model.useAboveRangeColor && model.aboveRangeColor[3] < 1.0) { + opaque = 0; + } for (let i = 3; i < model.table.length && opaque; i += 4) { if (model.table[i] < 255) { opaque = false; @@ -68,7 +74,7 @@ function vtkLookupTable(publicAPI, model) { // This conditional is needed because when v is very close to // p.Range[1], it may map above p.MaxIndex in the linear mapping // above. - dIndex = (dIndex < p.maxIndex ? dIndex : p.maxIndex); + dIndex = dIndex < p.maxIndex ? dIndex : p.maxIndex; } return Math.floor(dIndex); @@ -81,12 +87,22 @@ function vtkLookupTable(publicAPI, model) { } else { index = publicAPI.linearIndexLookup(v, p); } - return [table[4 * index], table[(4 * index) + 1], table[(4 * index) + 2], table[(4 * index) + 3]]; + return [ + table[4 * index], + table[4 * index + 1], + table[4 * index + 2], + table[4 * index + 3], + ]; }; publicAPI.indexedLookupFunction = (v, table, p) => { const index = publicAPI.getAnnotatedValueIndexInternal(v); - return [table[4 * index], table[(4 * index) + 1], table[(4 * index) + 2], table[(4 * index) + 3]]; + return [ + table[4 * index], + table[4 * index + 1], + table[4 * index + 2], + table[4 * index + 3], + ]; }; //---------------------------------------------------------------------------- @@ -99,7 +115,12 @@ function vtkLookupTable(publicAPI, model) { }; // Public API methods - publicAPI.mapScalarsThroughTable = (input, output, outFormat, inputOffset) => { + publicAPI.mapScalarsThroughTable = ( + input, + output, + outFormat, + inputOffset + ) => { let lookupFunc = publicAPI.linearLookup; if (model.indexedLookup) { lookupFunc = publicAPI.indexedLookupFunction; @@ -125,25 +146,30 @@ function vtkLookupTable(publicAPI, model) { if (alpha >= 1.0) { if (outFormat === ScalarMappingTarget.RGBA) { for (let i = 0; i < length; i++) { - const cptr = - lookupFunc(inputV[(i * inIncr) + inputOffset], - model.table, p); - outputV[(i * 4)] = cptr[0]; - outputV[(i * 4) + 1] = cptr[1]; - outputV[(i * 4) + 2] = cptr[2]; - outputV[(i * 4) + 3] = cptr[3]; + const cptr = lookupFunc( + inputV[i * inIncr + inputOffset], + model.table, + p + ); + outputV[i * 4] = cptr[0]; + outputV[i * 4 + 1] = cptr[1]; + outputV[i * 4 + 2] = cptr[2]; + outputV[i * 4 + 3] = cptr[3]; } } } else { /* eslint-disable no-lonely-if */ if (outFormat === ScalarMappingTarget.RGBA) { for (let i = 0; i < length; i++) { - const cptr = - lookupFunc(inputV[(i * inIncr) + inputOffset], model.table, p); - outputV[(i * 4)] = cptr[0]; - outputV[(i * 4) + 1] = cptr[1]; - outputV[(i * 4) + 2] = cptr[2]; - outputV[(i * 4) + 3] = Math.floor((cptr[3] * alpha) + 0.5); + const cptr = lookupFunc( + inputV[i * inIncr + inputOffset], + model.table, + p + ); + outputV[i * 4] = cptr[0]; + outputV[i * 4 + 1] = cptr[1]; + outputV[i * 4 + 2] = cptr[2]; + outputV[i * 4 + 3] = Math.floor(cptr[3] * alpha + 0.5); } } } // alpha blending @@ -167,18 +193,18 @@ function vtkLookupTable(publicAPI, model) { const hsv = []; const rgba = []; for (let i = 0; i <= maxIndex; i++) { - hsv[0] = model.hueRange[0] + (i * hinc); - hsv[1] = model.saturationRange[0] + (i * sinc); - hsv[2] = model.valueRange[0] + (i * vinc); + hsv[0] = model.hueRange[0] + i * hinc; + hsv[1] = model.saturationRange[0] + i * sinc; + hsv[2] = model.valueRange[0] + i * vinc; vtkMath.hsv2rgb(hsv, rgba); - rgba[3] = model.alphaRange[0] + (i * ainc); + rgba[3] = model.alphaRange[0] + i * ainc; // case VTK_RAMP_LINEAR: - model.table[(i * 4)] = (rgba[0] * 255.0) + 0.5; - model.table[(i * 4) + 1] = (rgba[1] * 255.0) + 0.5; - model.table[(i * 4) + 2] = (rgba[2] * 255.0) + 0.5; - model.table[(i * 4) + 3] = (rgba[3] * 255.0) + 0.5; + model.table[i * 4] = rgba[0] * 255.0 + 0.5; + model.table[i * 4 + 1] = rgba[1] * 255.0 + 0.5; + model.table[i * 4 + 2] = rgba[2] * 255.0 + 0.5; + model.table[i * 4 + 3] = rgba[3] * 255.0 + 0.5; } publicAPI.buildSpecialColors(); @@ -195,10 +221,10 @@ function vtkLookupTable(publicAPI, model) { // Below range color if (model.useBelowRangeColor || numberOfColors === 0) { - tptr[base] = (model.belowRangeColor[0] * 255.0) + 0.5; - tptr[base + 1] = (model.belowRangeColor[1] * 255.0) + 0.5; - tptr[base + 2] = (model.belowRangeColor[2] * 255.0) + 0.5; - tptr[base + 3] = (model.belowRangeColor[3] * 255.0) + 0.5; + tptr[base] = model.belowRangeColor[0] * 255.0 + 0.5; + tptr[base + 1] = model.belowRangeColor[1] * 255.0 + 0.5; + tptr[base + 2] = model.belowRangeColor[2] * 255.0 + 0.5; + tptr[base + 3] = model.belowRangeColor[3] * 255.0 + 0.5; } else { // Duplicate the first color in the table. tptr[base] = tptr[0]; @@ -210,29 +236,31 @@ function vtkLookupTable(publicAPI, model) { // Above range color base = (model.numberOfColors + ABOVE_RANGE_COLOR_INDEX) * 4; if (model.useAboveRangeColor || numberOfColors === 0) { - tptr[base] = (model.aboveRangeColor[0] * 255.0) + 0.5; - tptr[base + 1] = (model.aboveRangeColor[1] * 255.0) + 0.5; - tptr[base + 2] = (model.aboveRangeColor[2] * 255.0) + 0.5; - tptr[base + 3] = (model.aboveRangeColor[3] * 255.0) + 0.5; + tptr[base] = model.aboveRangeColor[0] * 255.0 + 0.5; + tptr[base + 1] = model.aboveRangeColor[1] * 255.0 + 0.5; + tptr[base + 2] = model.aboveRangeColor[2] * 255.0 + 0.5; + tptr[base + 3] = model.aboveRangeColor[3] * 255.0 + 0.5; } else { // Duplicate the last color in the table. - tptr[base] = tptr[(4 * (numberOfColors - 1)) + 0]; - tptr[base + 1] = tptr[(4 * (numberOfColors - 1)) + 1]; - tptr[base + 2] = tptr[(4 * (numberOfColors - 1)) + 2]; - tptr[base + 3] = tptr[(4 * (numberOfColors - 1)) + 3]; + tptr[base] = tptr[4 * (numberOfColors - 1) + 0]; + tptr[base + 1] = tptr[4 * (numberOfColors - 1) + 1]; + tptr[base + 2] = tptr[4 * (numberOfColors - 1) + 2]; + tptr[base + 3] = tptr[4 * (numberOfColors - 1) + 3]; } // Always use NanColor base = (model.numberOfColors + NAN_COLOR_INDEX) * 4; - tptr[base] = (model.nanColor[0] * 255.0) + 0.5; - tptr[base + 1] = (model.nanColor[1] * 255.0) + 0.5; - tptr[base + 2] = (model.nanColor[2] * 255.0) + 0.5; - tptr[base + 3] = (model.nanColor[3] * 255.0) + 0.5; + tptr[base] = model.nanColor[0] * 255.0 + 0.5; + tptr[base + 1] = model.nanColor[1] * 255.0 + 0.5; + tptr[base + 2] = model.nanColor[2] * 255.0 + 0.5; + tptr[base + 3] = model.nanColor[3] * 255.0 + 0.5; }; publicAPI.build = () => { - if (model.table.length < 1 || - publicAPI.getMTime() > model.buildTime.getMTime()) { + if ( + model.table.length < 1 || + publicAPI.getMTime() > model.buildTime.getMTime() + ) { publicAPI.forceBuild(); } }; @@ -267,7 +295,6 @@ const DEFAULT_VALUES = { export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); - // Inheritance vtkScalarsToColors.extend(publicAPI, model, initialValues); @@ -276,7 +303,6 @@ export function extend(publicAPI, model, initialValues = {}) { model.table = []; } - model.buildTime = {}; macro.obj(model.buildTime); @@ -284,9 +310,7 @@ export function extend(publicAPI, model, initialValues = {}) { macro.obj(model.opaqueFlagBuildTime, { mtime: 0 }); // Create get-only macros - macro.get(publicAPI, model, [ - 'buildTime', - ]); + macro.get(publicAPI, model, ['buildTime']); // Create get-set macros macro.setGet(publicAPI, model, [ @@ -296,18 +320,19 @@ export function extend(publicAPI, model, initialValues = {}) { ]); // Create set macros for array (needs to know size) - macro.setArray(publicAPI, model, [ - 'alphaRange', - 'hueRange', - 'saturationRange', - 'valueRange', - ], 2); - - macro.setArray(publicAPI, model, [ - 'nanColor', - 'belowRangeColor', - 'aboveRangeColor', - ], 4); + macro.setArray( + publicAPI, + model, + ['alphaRange', 'hueRange', 'saturationRange', 'valueRange'], + 2 + ); + + macro.setArray( + publicAPI, + model, + ['nanColor', 'belowRangeColor', 'aboveRangeColor'], + 4 + ); // Create get macros for array macro.getArray(publicAPI, model, [ diff --git a/Sources/Common/Core/LookupTable/test/testCategoricalColors.js b/Sources/Common/Core/LookupTable/test/testCategoricalColors.js index f3471e693d0..777c84a2deb 100644 --- a/Sources/Common/Core/LookupTable/test/testCategoricalColors.js +++ b/Sources/Common/Core/LookupTable/test/testCategoricalColors.js @@ -1,14 +1,14 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkLookupTable from 'vtk.js/Sources/Common/Core/LookupTable'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkLookupTable from 'vtk.js/Sources/Common/Core/LookupTable'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; import baseline from './testCategoricalColors.png'; @@ -19,7 +19,9 @@ test.onlyIfWebGL('Test Categorical Colors', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -66,10 +68,10 @@ test.onlyIfWebGL('Test Categorical Colors', (t) => { for (let i = 0; i < res; i++) { for (let j = 0; j < res; j++) { - const idx = (i * res) + j; + const idx = i * res + j; points[idx * 3] = j; - points[(idx * 3) + 1] = i; - points[(idx * 3) + 2] = 0.0; + points[idx * 3 + 1] = i; + points[idx * 3 + 2] = 0.0; scalars[idx] = Math.pow(10.0, Math.floor(j / 2)); // also add nan for some data if (i === 4) { @@ -78,9 +80,9 @@ test.onlyIfWebGL('Test Categorical Colors', (t) => { } } - for (let i = 0; i < (res - 1); i++) { - for (let j = 0; j < (res - 1); j++) { - const idx = ((i * res) + j); + for (let i = 0; i < res - 1; i++) { + for (let j = 0; j < res - 1; j++) { + const idx = i * res + j; polys[cellLocation++] = 3; polys[cellLocation++] = idx; polys[cellLocation++] = idx + 1; @@ -92,7 +94,9 @@ test.onlyIfWebGL('Test Categorical Colors', (t) => { } } - const da = gc.registerResource(vtkDataArray.newInstance({ numberOfComponents: 1, values: scalars })); + const da = gc.registerResource( + vtkDataArray.newInstance({ numberOfComponents: 1, values: scalars }) + ); pd.getPointData().setScalars(da); mapper.setInputData(pd); @@ -106,5 +110,12 @@ test.onlyIfWebGL('Test Categorical Colors', (t) => { const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Common/Core/LookupTable/testCategoricalColors', t, 2, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Common/Core/LookupTable/testCategoricalColors', + t, + 2, + gc.releaseResources + ); }); diff --git a/Sources/Common/Core/Math/index.js b/Sources/Common/Core/Math/index.js index 56189b3021d..af02c11952a 100644 --- a/Sources/Common/Core/Math/index.js +++ b/Sources/Common/Core/Math/index.js @@ -1,5 +1,5 @@ import seedrandom from 'seedrandom'; -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; const { vtkErrorMacro, vtkWarningMacro } = macro; @@ -38,8 +38,8 @@ function createArray(size = 3) { // ---------------------------------------------------------------------------- const Pi = () => Math.PI; -const radiansFromDegrees = deg => deg / 180 * Math.PI; -const degreesFromRadians = rad => rad * 180 / Math.PI; +const radiansFromDegrees = (deg) => deg / 180 * Math.PI; +const degreesFromRadians = (rad) => rad * 180 / Math.PI; const round = Math.round; const floor = Math.floor; const ceil = Math.ceil; @@ -57,7 +57,7 @@ function nearestPowerOfTwo(xi) { } function isPowerOfTwo(x) { - return (x === nearestPowerOfTwo(x)); + return x === nearestPowerOfTwo(x); } function binomial(m, n) { @@ -104,7 +104,7 @@ const getSeed = () => randomSeedValue; function random(minValue = 0, maxValue = 1) { const delta = maxValue - minValue; - return minValue + (delta * Math.random()); + return minValue + delta * Math.random(); } const gaussian = notImplemented('gaussian'); @@ -134,9 +134,7 @@ function multiplyScalar2D(vec, scalar) { } function dot(x, y) { - return (x[0] * y[0]) - + (x[1] * y[1]) - + (x[2] * y[2]); + return x[0] * y[0] + x[1] * y[1] + x[2] * y[2]; } function outer(x, y, out_3x3) { @@ -148,9 +146,9 @@ function outer(x, y, out_3x3) { } function cross(x, y, out) { - const Zx = (x[1] * y[2]) - (x[2] * y[1]); - const Zy = (x[2] * y[0]) - (x[0] * y[2]); - const Zz = (x[0] * y[1]) - (x[1] * y[0]); + const Zx = x[1] * y[2] - x[2] * y[1]; + const Zy = x[2] * y[0] - x[0] * y[2]; + const Zz = x[0] * y[1] - x[1] * y[0]; out[0] = Zx; out[1] = Zy; out[2] = Zz; @@ -161,17 +159,16 @@ function norm(x, n = 3) { case 1: return Math.abs(x); case 2: - return Math.sqrt((x[0] * x[0]) + (x[1] * x[1])); + return Math.sqrt(x[0] * x[0] + x[1] * x[1]); case 3: - return Math.sqrt((x[0] * x[0]) + (x[1] * x[1]) + (x[2] * x[2])); - default: - { - let sum = 0; - for (let i = 0; i < n; i++) { - sum += x[i] * x[i]; - } - return Math.sqrt(sum); + return Math.sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]); + default: { + let sum = 0; + for (let i = 0; i < n; i++) { + sum += x[i] * x[i]; } + return Math.sqrt(sum); + } } } @@ -213,22 +210,22 @@ function perpendiculars(x, y, z, theta) { const a = x[dx] / r; const b = x[dy] / r; const c = x[dz] / r; - const tmp = Math.sqrt((a * a) + (c * c)); + const tmp = Math.sqrt(a * a + c * c); if (theta !== 0) { const sintheta = Math.sin(theta); const costheta = Math.cos(theta); if (y) { - y[dx] = ((c * costheta) - (a * b * sintheta)) / tmp; + y[dx] = (c * costheta - a * b * sintheta) / tmp; y[dy] = sintheta * tmp; - y[dz] = (-(a * costheta) - (b * c * sintheta)) / tmp; + y[dz] = (-(a * costheta) - b * c * sintheta) / tmp; } if (z) { - z[dx] = (-(c * sintheta) - (a * b * costheta)) / tmp; + z[dx] = (-(c * sintheta) - a * b * costheta) / tmp; z[dy] = costheta * tmp; - z[dz] = ((a * sintheta) - (b * c * costheta)) / tmp; + z[dz] = (a * sintheta - b * c * costheta) / tmp; } } else { if (y) { @@ -266,7 +263,7 @@ function projectVector(a, b, projection) { } function dot2D(x, y) { - return (x[0] * y[0]) + (x[1] * y[1]); + return x[0] * y[0] + x[1] * y[1]; } function projectVector2D(a, b, projection) { @@ -289,9 +286,11 @@ function projectVector2D(a, b, projection) { } function distance2BetweenPoints(x, y) { - return ((x[0] - y[0]) * (x[0] - y[0])) - + ((x[1] - y[1]) * (x[1] - y[1])) - + ((x[2] - y[2]) * (x[2] - y[2])); + return ( + (x[0] - y[0]) * (x[0] - y[0]) + + (x[1] - y[1]) * (x[1] - y[1]) + + (x[2] - y[2]) * (x[2] - y[2]) + ); } function angleBetweenVectors(v1, v2) { @@ -302,12 +301,16 @@ function angleBetweenVectors(v1, v2) { function gaussianAmplitude(mean, variance, position) { const distanceFromMean = Math.abs(mean - position); - return 1 / (Math.sqrt(2 * Math.PI * variance)) * Math.exp(-(Math.pow(distanceFromMean, 2)) / (2 * variance)); + return ( + 1 / + Math.sqrt(2 * Math.PI * variance) * + Math.exp(-Math.pow(distanceFromMean, 2) / (2 * variance)) + ); } function gaussianWeight(mean, variance, position) { const distanceFromMean = Math.abs(mean - position); - return Math.exp(-(Math.pow(distanceFromMean, 2)) / (2 * variance)); + return Math.exp(-Math.pow(distanceFromMean, 2) / (2 * variance)); } function outer2D(x, y, out_2x2) { @@ -319,7 +322,7 @@ function outer2D(x, y, out_2x2) { } function norm2D(x2D) { - return Math.sqrt((x2D[0] * x2D[0]) + (x2D[1] * x2D[1])); + return Math.sqrt(x2D[0] * x2D[0] + x2D[1] * x2D[1]); } function normalize2D(x) { @@ -333,10 +336,10 @@ function normalize2D(x) { function determinant2x2(...args) { if (args.length === 2) { - return ((args[0][0] * args[1][1]) - (args[1][0] * args[0][1])); + return args[0][0] * args[1][1] - args[1][0] * args[0][1]; } if (args.length === 4) { - return (args[0] * args[3]) - (args[1] * args[2]); + return args[0] * args[3] - args[1] * args[2]; } return Number.NaN; } @@ -395,7 +398,8 @@ function LUFactor3x3(mat_3x3, index_3) { // third column mat_3x3[1][2] -= mat_3x3[1][0] * mat_3x3[0][2]; - mat_3x3[2][2] -= (mat_3x3[2][0] * mat_3x3[0][2]) + (mat_3x3[2][1] * mat_3x3[1][2]); + mat_3x3[2][2] -= + mat_3x3[2][0] * mat_3x3[0][2] + mat_3x3[2][1] * mat_3x3[1][2]; index_3[2] = 2; } @@ -407,16 +411,17 @@ function LUSolve3x3(mat_3x3, index_3, x_3) { sum = x_3[index_3[1]]; x_3[index_3[1]] = x_3[1]; - x_3[1] = sum - (mat_3x3[1][0] * x_3[0]); + x_3[1] = sum - mat_3x3[1][0] * x_3[0]; sum = x_3[index_3[2]]; x_3[index_3[2]] = x_3[2]; - x_3[2] = sum - (mat_3x3[2][0] * x_3[0]) - (mat_3x3[2][1] * x_3[1]); + x_3[2] = sum - mat_3x3[2][0] * x_3[0] - mat_3x3[2][1] * x_3[1]; // back substitution x_3[2] /= mat_3x3[2][2]; - x_3[1] = (x_3[1] - (mat_3x3[1][2] * x_3[2])) / mat_3x3[1][1]; - x_3[0] = (x_3[0] - (mat_3x3[0][1] * x_3[1]) - (mat_3x3[0][2] * x_3[2])) / mat_3x3[0][0]; + x_3[1] = (x_3[1] - mat_3x3[1][2] * x_3[2]) / mat_3x3[1][1]; + x_3[0] = + (x_3[0] - mat_3x3[0][1] * x_3[1] - mat_3x3[0][2] * x_3[2]) / mat_3x3[0][0]; } function linearSolve3x3(mat_3x3, x_3, y_3) { @@ -444,12 +449,12 @@ function linearSolve3x3(mat_3x3, x_3, y_3) { const f3 = +determinant2x2(a1, a2, b1, b2); // Compute the determinant - const det = (a1 * d1) + (b1 * d2) + (c1 * d3); + const det = a1 * d1 + b1 * d2 + c1 * d3; // Multiply by the adjoint - const v1 = (d1 * x_3[0]) + (e1 * x_3[1]) + (f1 * x_3[2]); - const v2 = (d2 * x_3[0]) + (e2 * x_3[1]) + (f2 * x_3[2]); - const v3 = (d3 * x_3[0]) + (e3 * x_3[1]) + (f3 * x_3[2]); + const v1 = d1 * x_3[0] + e1 * x_3[1] + f1 * x_3[2]; + const v2 = d2 * x_3[0] + e2 * x_3[1] + f2 * x_3[2]; + const v3 = d3 * x_3[0] + e3 * x_3[1] + f3 * x_3[2]; // Divide by the determinant y_3[0] = v1 / det; @@ -458,9 +463,12 @@ function linearSolve3x3(mat_3x3, x_3, y_3) { } function multiply3x3_vect3(mat_3x3, in_3, out_3) { - const x = (mat_3x3[0][0] * in_3[0]) + (mat_3x3[0][1] * in_3[1]) + (mat_3x3[0][2] * in_3[2]); - const y = (mat_3x3[1][0] * in_3[0]) + (mat_3x3[1][1] * in_3[1]) + (mat_3x3[1][2] * in_3[2]); - const z = (mat_3x3[2][0] * in_3[0]) + (mat_3x3[2][1] * in_3[1]) + (mat_3x3[2][2] * in_3[2]); + const x = + mat_3x3[0][0] * in_3[0] + mat_3x3[0][1] * in_3[1] + mat_3x3[0][2] * in_3[2]; + const y = + mat_3x3[1][0] * in_3[0] + mat_3x3[1][1] * in_3[1] + mat_3x3[1][2] * in_3[2]; + const z = + mat_3x3[2][0] * in_3[0] + mat_3x3[2][1] * in_3[1] + mat_3x3[2][2] * in_3[2]; out_3[0] = x; out_3[1] = y; @@ -468,16 +476,21 @@ function multiply3x3_vect3(mat_3x3, in_3, out_3) { } function multiply3x3_mat3(a_3x3, b_3x3, out_3x3) { - const tmp = [ - [0, 0, 0], - [0, 0, 0], - [0, 0, 0], - ]; + const tmp = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]; for (let i = 0; i < 3; i++) { - tmp[0][i] = (a_3x3[0][0] * b_3x3[0][i]) + (a_3x3[0][1] * b_3x3[1][i]) + (a_3x3[0][2] * b_3x3[2][i]); - tmp[1][i] = (a_3x3[1][0] * b_3x3[0][i]) + (a_3x3[1][1] * b_3x3[1][i]) + (a_3x3[1][2] * b_3x3[2][i]); - tmp[2][i] = (a_3x3[2][0] * b_3x3[0][i]) + (a_3x3[2][1] * b_3x3[1][i]) + (a_3x3[2][2] * b_3x3[2][i]); + tmp[0][i] = + a_3x3[0][0] * b_3x3[0][i] + + a_3x3[0][1] * b_3x3[1][i] + + a_3x3[0][2] * b_3x3[2][i]; + tmp[1][i] = + a_3x3[1][0] * b_3x3[0][i] + + a_3x3[1][1] * b_3x3[1][i] + + a_3x3[1][2] * b_3x3[2][i]; + tmp[2][i] = + a_3x3[2][0] * b_3x3[0][i] + + a_3x3[2][1] * b_3x3[1][i] + + a_3x3[2][2] * b_3x3[2][i]; } for (let j = 0; j < 3; j++) { @@ -549,7 +562,7 @@ function invert3x3(in_3x3, outI_3x3) { const f3 = +determinant2x2(a1, a2, b1, b2); // Divide by the determinant - const det = (a1 * d1) + (b1 * d2) + (c1 * d3); + const det = a1 * d1 + b1 * d2 + c1 * d3; outI_3x3[0][0] = d1 / det; outI_3x3[1][0] = d2 / det; @@ -572,12 +585,14 @@ function identity3x3(mat_3x3) { } function determinant3x3(mat_3x3) { - return (mat_3x3[0][0] * mat_3x3[1][1] * mat_3x3[2][2]) - + (mat_3x3[1][0] * mat_3x3[2][1] * mat_3x3[0][2]) - + (mat_3x3[2][0] * mat_3x3[0][1] * mat_3x3[1][2]) - - (mat_3x3[0][0] * mat_3x3[2][1] * mat_3x3[1][2]) - - (mat_3x3[1][0] * mat_3x3[0][1] * mat_3x3[2][2]) - - (mat_3x3[2][0] * mat_3x3[1][1] * mat_3x3[0][2]); + return ( + mat_3x3[0][0] * mat_3x3[1][1] * mat_3x3[2][2] + + mat_3x3[1][0] * mat_3x3[2][1] * mat_3x3[0][2] + + mat_3x3[2][0] * mat_3x3[0][1] * mat_3x3[1][2] - + mat_3x3[0][0] * mat_3x3[2][1] * mat_3x3[1][2] - + mat_3x3[1][0] * mat_3x3[0][1] * mat_3x3[2][2] - + mat_3x3[2][0] * mat_3x3[1][1] * mat_3x3[0][2] + ); } function quaternionToMatrix3x3(quat_4, mat_3x3) { @@ -600,17 +615,17 @@ function quaternionToMatrix3x3(quat_4, mat_3x3) { const s = (ww - rr) * f; f *= 2; - mat_3x3[0][0] = (xx * f) + s; + mat_3x3[0][0] = xx * f + s; mat_3x3[1][0] = (xy + wz) * f; mat_3x3[2][0] = (xz - wy) * f; mat_3x3[0][1] = (xy - wz) * f; - mat_3x3[1][1] = (yy * f) + s; + mat_3x3[1][1] = yy * f + s; mat_3x3[2][1] = (yz + wx) * f; mat_3x3[0][2] = (xz + wy) * f; mat_3x3[1][2] = (yz - wx) * f; - mat_3x3[2][2] = (zz * f) + s; + mat_3x3[2][2] = zz * f + s; } function areMatricesEqual(matA, matB) { @@ -647,8 +662,8 @@ function jacobiN(a, n, w, v) { const vtkROTATE = (aa, ii, jj, kk, ll) => { g = aa[ii][jj]; h = aa[kk][ll]; - aa[ii][jj] = g - (s * (h + (g * tau))); - aa[kk][ll] = h + (s * (g - (h * tau))); + aa[ii][jj] = g - s * (h + g * tau); + aa[kk][ll] = h + s * (g - h * tau); }; // initialize @@ -687,20 +702,24 @@ function jacobiN(a, n, w, v) { g = 100.0 * Math.abs(a[ip][iq]); // after 4 sweeps - if (i > 3 && (Math.abs(w[ip]) + g) === Math.abs(w[ip]) && (Math.abs(w[iq]) + g) === Math.abs(w[iq])) { + if ( + i > 3 && + Math.abs(w[ip]) + g === Math.abs(w[ip]) && + Math.abs(w[iq]) + g === Math.abs(w[iq]) + ) { a[ip][iq] = 0.0; } else if (Math.abs(a[ip][iq]) > tresh) { h = w[iq] - w[ip]; - if ((Math.abs(h) + g) === Math.abs(h)) { - t = (a[ip][iq]) / h; + if (Math.abs(h) + g === Math.abs(h)) { + t = a[ip][iq] / h; } else { - theta = 0.5 * h / (a[ip][iq]); - t = 1.0 / (Math.abs(theta) + Math.sqrt(1.0 + (theta * theta))); + theta = 0.5 * h / a[ip][iq]; + t = 1.0 / (Math.abs(theta) + Math.sqrt(1.0 + theta * theta)); if (theta < 0.0) { t = -t; } } - c = 1.0 / Math.sqrt(1 + (t * t)); + c = 1.0 / Math.sqrt(1 + t * t); s = t * c; tau = s / (1.0 + c); h = t * a[ip][iq]; @@ -787,12 +806,7 @@ function jacobiN(a, n, w, v) { } function matrix3x3ToQuaternion(mat_3x3, quat_4) { - const tmp = [ - [0, 0, 0, 0], - [0, 0, 0, 0], - [0, 0, 0, 0], - [0, 0, 0, 0], - ]; + const tmp = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]; // on-diagonal elements tmp[0][0] = mat_3x3[0][0] + mat_3x3[1][1] + mat_3x3[2][2]; @@ -809,12 +823,7 @@ function matrix3x3ToQuaternion(mat_3x3, quat_4) { tmp[1][3] = tmp[3][1] = mat_3x3[0][2] + mat_3x3[2][0]; tmp[2][3] = tmp[3][2] = mat_3x3[2][1] + mat_3x3[1][2]; - const eigenvectors = [ - [0, 0, 0, 0], - [0, 0, 0, 0], - [0, 0, 0, 0], - [0, 0, 0, 0], - ]; + const eigenvectors = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]; const eigenvalues = [0, 0, 0, 0]; // convert into format that JacobiN can use, @@ -879,8 +888,8 @@ function orthogonalize3x3(a_3x3, out_3x3) { const x1 = Math.abs(out_3x3[i][0]); const x2 = Math.abs(out_3x3[i][1]); const x3 = Math.abs(out_3x3[i][2]); - largest = (x2 > x1 ? x2 : x1); - largest = (x3 > largest ? x3 : largest); + largest = x2 > x1 ? x2 : x1; + largest = x3 > largest ? x3 : largest; scale[i] = 1; if (largest !== 0) { scale[i] /= largest; @@ -966,11 +975,7 @@ function diagonalize3x3(a_3x3, w_3, v_3x3) { let maxVal; // do the matrix[3][3] to **matrix conversion for Jacobi - const C = [ - createArray(3), - createArray(3), - createArray(3), - ]; + const C = [createArray(3), createArray(3), createArray(3)]; const ATemp = createArray(3); const VTemp = createArray(3); for (i = 0; i < 3; i++) { @@ -1197,7 +1202,7 @@ function luFactorLinearSystem(A, index, size) { return 0; } - if (j !== (size - 1)) { + if (j !== size - 1) { temp1 = 1.0 / A[j][j]; for (i = j + 1; i < size; i++) { A[i][j] *= temp1; @@ -1223,7 +1228,7 @@ function luSolveLinearSystem(A, index, x, size) { x[idx] = x[i]; if (ii >= 0) { - for (j = ii; j <= (i - 1); j++) { + for (j = ii; j <= i - 1; j++) { sum -= A[i][j] * x[j]; } } else if (sum !== 0.0) { @@ -1255,8 +1260,8 @@ function solveLinearSystem(A, x, size) { return 0; } - y[0] = ((A[1][1] * x[0]) - (A[0][1] * x[1])) / det; - y[1] = (-(A[1][0] * x[0]) + (A[0][0] * x[1])) / det; + y[0] = (A[1][1] * x[0] - A[0][1] * x[1]) / det; + y[1] = (-(A[1][0] * x[0]) + A[0][0] * x[1]) / det; x[0] = y[0]; x[1] = y[1]; @@ -1337,7 +1342,7 @@ function estimateMatrixCondition(A, size) { if (minValue === 0.0) { return Number.MAX_VALUE; } - return (maxValue / minValue); + return maxValue / minValue; } function jacobi(a_3x3, w, v) { @@ -1399,9 +1404,17 @@ function solveHomogeneousLeastSquares(numberOfSamples, xt, xOrder, mt) { return 1; } -function solveLeastSquares(numberOfSamples, xt, xOrder, yt, yOrder, mt, checkHomogeneous = true) { +function solveLeastSquares( + numberOfSamples, + xt, + xOrder, + yt, + yOrder, + mt, + checkHomogeneous = true +) { // check dimensional consistency - if ((numberOfSamples < xOrder) || (numberOfSamples < yOrder)) { + if (numberOfSamples < xOrder || numberOfSamples < yOrder) { vtkWarningMacro('Insufficient number of samples. Underdetermined.'); return 0; } @@ -1424,7 +1437,6 @@ function solveLeastSquares(numberOfSamples, xt, xOrder, yt, yOrder, mt, checkHom // since that's just yOrder occurrences of a 0 vector on the RHS, but // we allow it anyway. N - // Initialize homogeneous flags on a per-right-hand-side basis for (j = 0; j < yOrder; j++) { homogenFlags[j] = 1; @@ -1440,11 +1452,12 @@ function solveLeastSquares(numberOfSamples, xt, xOrder, yt, yOrder, mt, checkHom // If we've got one system, and it's homogeneous, do it and bail out quickly. if (allHomogeneous && yOrder === 1) { - vtkWarningMacro('Detected homogeneous system (Y=0), calling SolveHomogeneousLeastSquares()'); + vtkWarningMacro( + 'Detected homogeneous system (Y=0), calling SolveHomogeneousLeastSquares()' + ); return solveHomogeneousLeastSquares(numberOfSamples, xt, xOrder, mt); } - // Ok, we've got more than one system of equations. // Figure out if we need to calculate the homogeneous equation solution for // any of them. @@ -1473,7 +1486,6 @@ function solveLeastSquares(numberOfSamples, xt, xOrder, yt, yOrder, mt, checkHom homogRC = solveHomogeneousLeastSquares(numberOfSamples, xt, xOrder, hmt); } - // set up intermediate variables const XXt = createArray(xOrder); // size x by x const XXtI = createArray(xOrder); // size x by x @@ -1581,9 +1593,9 @@ function rgb2hsv(rgb, hsv) { if (r === cmax) { h = onesixth * (g - b) / (cmax - cmin); } else if (g === cmax) { - h = onethird + ((onesixth * (b - r)) / (cmax - cmin)); + h = onethird + onesixth * (b - r) / (cmax - cmin); } else { - h = twothird + ((onesixth * (r - g)) / (cmax - cmin)); + h = twothird + onesixth * (r - g) / (cmax - cmin); } if (h < 0.0) { h += 1.0; @@ -1624,24 +1636,27 @@ function hsv2rgb(hsv, rgb) { b = 1.0; g = (twothird - h) / onesixth; r = 0.0; - } else if (h > twothird && h <= fivesixth) { // blue/red + } else if (h > twothird && h <= fivesixth) { + // blue/red b = 1.0; r = (h - twothird) / onesixth; g = 0.0; - } else if (h > fivesixth && h <= 1.0) { // red/blue + } else if (h > fivesixth && h <= 1.0) { + // red/blue r = 1.0; b = (1.0 - h) / onesixth; g = 0.0; - } else { // red/green + } else { + // red/green r = 1.0; g = h / onesixth; b = 0.0; } // add Saturation to the equation. - r = ((s * r) + (1.0 - s)); - g = ((s * g) + (1.0 - s)); - b = ((s * b) + (1.0 - s)); + r = s * r + (1.0 - s); + g = s * g + (1.0 - s); + b = s * b + (1.0 - s); r *= v; g *= v; @@ -1657,28 +1672,28 @@ function lab2xyz(lab, xyz) { // LAB to XYZ const [L, a, b] = lab; let var_Y = (L + 16) / 116; - let var_X = (a / 500) + var_Y; - let var_Z = var_Y - (b / 200); + let var_X = a / 500 + var_Y; + let var_Z = var_Y - b / 200; if (Math.pow(var_Y, 3) > 0.008856) { var_Y = Math.pow(var_Y, 3); } else { - var_Y = (var_Y - (16.0 / 116.0)) / 7.787; + var_Y = (var_Y - 16.0 / 116.0) / 7.787; } if (Math.pow(var_X, 3) > 0.008856) { var_X = Math.pow(var_X, 3); } else { - var_X = (var_X - (16.0 / 116.0)) / 7.787; + var_X = (var_X - 16.0 / 116.0) / 7.787; } if (Math.pow(var_Z, 3) > 0.008856) { var_Z = Math.pow(var_Z, 3); } else { - var_Z = (var_Z - (16.0 / 116.0)) / 7.787; + var_Z = (var_Z - 16.0 / 116.0) / 7.787; } const ref_X = 0.9505; - const ref_Y = 1.000; + const ref_Y = 1.0; const ref_Z = 1.089; xyz[0] = ref_X * var_X; // ref_X = 0.9505 Observer= 2 deg Illuminant= D65 xyz[1] = ref_Y * var_Y; // ref_Y = 1.000 @@ -1688,29 +1703,29 @@ function lab2xyz(lab, xyz) { function xyz2lab(xyz, lab) { const [x, y, z] = xyz; const ref_X = 0.9505; - const ref_Y = 1.000; + const ref_Y = 1.0; const ref_Z = 1.089; - let var_X = x / ref_X; // ref_X = 0.9505 Observer= 2 deg, Illuminant= D65 - let var_Y = y / ref_Y; // ref_Y = 1.000 - let var_Z = z / ref_Z; // ref_Z = 1.089 + let var_X = x / ref_X; // ref_X = 0.9505 Observer= 2 deg, Illuminant= D65 + let var_Y = y / ref_Y; // ref_Y = 1.000 + let var_Z = z / ref_Z; // ref_Z = 1.089 if (var_X > 0.008856) var_X = Math.pow(var_X, 1.0 / 3.0); - else var_X = (7.787 * var_X) + (16.0 / 116.0); + else var_X = 7.787 * var_X + 16.0 / 116.0; if (var_Y > 0.008856) var_Y = Math.pow(var_Y, 1.0 / 3.0); - else var_Y = (7.787 * var_Y) + (16.0 / 116.0); + else var_Y = 7.787 * var_Y + 16.0 / 116.0; if (var_Z > 0.008856) var_Z = Math.pow(var_Z, 1.0 / 3.0); - else var_Z = (7.787 * var_Z) + (16.0 / 116.0); + else var_Z = 7.787 * var_Z + 16.0 / 116.0; - lab[0] = (116 * var_Y) - 16; + lab[0] = 116 * var_Y - 16; lab[1] = 500 * (var_X - var_Y); lab[2] = 200 * (var_Y - var_Z); } function xyz2rgb(xyz, rgb) { const [x, y, z] = xyz; - let r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986); - let g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415); - let b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570); + let r = x * 3.2406 + y * -1.5372 + z * -0.4986; + let g = x * -0.9689 + y * 1.8758 + z * 0.0415; + let b = x * 0.0557 + y * -0.204 + z * 1.057; // The following performs a "gamma correction" specified by the sRGB color // space. sRGB is defined by a canonical definition of a display monitor and @@ -1720,11 +1735,11 @@ function xyz2rgb(xyz, rgb) { // several applications including Adobe Photoshop and Microsoft Windows color // management. OpenGL is agnostic on its RGB color space, but it is reasonable // to assume it is close to this one. - if (r > 0.0031308) r = (1.055 * Math.pow(r, (1 / 2.4))) - 0.055; + if (r > 0.0031308) r = 1.055 * Math.pow(r, 1 / 2.4) - 0.055; else r *= 12.92; - if (g > 0.0031308) g = (1.055 * Math.pow(g, (1 / 2.4))) - 0.055; + if (g > 0.0031308) g = 1.055 * Math.pow(g, 1 / 2.4) - 0.055; else g *= 12.92; - if (b > 0.0031308) b = (1.055 * Math.pow(b, (1 / 2.4))) - 0.055; + if (b > 0.0031308) b = 1.055 * Math.pow(b, 1 / 2.4) - 0.055; else b *= 12.92; // Clip colors. ideally we would do something that is perceptually closest @@ -1766,9 +1781,9 @@ function rgb2xyz(rgb, xyz) { else b /= 12.92; // Observer. = 2 deg, Illuminant = D65 - xyz[0] = (r * 0.4124) + (g * 0.3576) + (b * 0.1805); - xyz[1] = (r * 0.2126) + (g * 0.7152) + (b * 0.0722); - xyz[2] = (r * 0.0193) + (g * 0.1192) + (b * 0.9505); + xyz[0] = r * 0.4124 + g * 0.3576 + b * 0.1805; + xyz[1] = r * 0.2126 + g * 0.7152 + b * 0.0722; + xyz[2] = r * 0.0193 + g * 0.1192 + b * 0.9505; } function rgb2lab(rgb, lab) { @@ -1833,8 +1848,12 @@ function extentIsWithinOtherExtent(extent1, extent2) { } for (let i = 0; i < 6; i += 2) { - if (extent1[i] < extent2[i] || extent1[i] > extent2[i + 1] || - extent1[i + 1] < extent2[i] || extent1[i + 1] > extent2[i + 1]) { + if ( + extent1[i] < extent2[i] || + extent1[i] > extent2[i + 1] || + extent1[i + 1] < extent2[i] || + extent1[i + 1] > extent2[i + 1] + ) { return 0; } } @@ -1847,10 +1866,12 @@ function boundsIsWithinOtherBounds(bounds1_6, bounds2_6, delta_3) { return 0; } for (let i = 0; i < 6; i += 2) { - if (bounds1_6[i] + delta_3[i / 2] < bounds2_6[i] - || bounds1_6[i] - delta_3[i / 2] > bounds2_6[i + 1] - || bounds1_6[i + 1] + delta_3[i / 2] < bounds2_6[i] - || bounds1_6[i + 1] - delta_3[i / 2] > bounds2_6[i + 1]) { + if ( + bounds1_6[i] + delta_3[i / 2] < bounds2_6[i] || + bounds1_6[i] - delta_3[i / 2] > bounds2_6[i + 1] || + bounds1_6[i + 1] + delta_3[i / 2] < bounds2_6[i] || + bounds1_6[i + 1] - delta_3[i / 2] > bounds2_6[i + 1] + ) { return 0; } } @@ -1862,7 +1883,10 @@ function pointIsWithinBounds(point_3, bounds_6, delta_3) { return 0; } for (let i = 0; i < 3; i++) { - if (point_3[i] + delta_3[i] < bounds_6[2 * i] || point_3[i] - delta_3[i] > bounds_6[(2 * i) + 1]) { + if ( + point_3[i] + delta_3[i] < bounds_6[2 * i] || + point_3[i] - delta_3[i] > bounds_6[2 * i + 1] + ) { return 0; } } @@ -1894,15 +1918,15 @@ function solve3PointCircle(p1, p2, p3, center) { cross(v21, v32, crossv21v32); const normCross = norm(crossv21v32); - const radius = (norm12 * norm23 * norm13) / (2 * normCross); + const radius = norm12 * norm23 * norm13 / (2 * normCross); const normCross22 = 2 * normCross * normCross; - const alpha = ((norm23 * norm23) * dot(v21, v31)) / normCross22; - const beta = ((norm13 * norm13) * dot(v12, v32)) / normCross22; - const gamma = ((norm12 * norm12) * dot(v13, v23)) / normCross22; + const alpha = norm23 * norm23 * dot(v21, v31) / normCross22; + const beta = norm13 * norm13 * dot(v12, v32) / normCross22; + const gamma = norm12 * norm12 * dot(v13, v23) / normCross22; for (let i = 0; i < 3; ++i) { - center[i] = (alpha * p1[i]) + (beta * p2[i]) + (gamma * p3[i]); + center[i] = alpha * p1[i] + beta * p2[i] + gamma * p3[i]; } return radius; } @@ -1910,7 +1934,7 @@ function solve3PointCircle(p1, p2, p3, center) { const inf = Infinity; const negInf = -Infinity; -const isInf = value => !Number.isFinite(value); +const isInf = (value) => !Number.isFinite(value); const isNan = Number.isNaN; const isFinite = Number.isFinite; @@ -1918,9 +1942,12 @@ const isFinite = Number.isFinite; function createUninitializedBounds() { return [].concat([ - Number.MAX_VALUE, -Number.MAX_VALUE, // X - Number.MAX_VALUE, -Number.MAX_VALUE, // Y - Number.MAX_VALUE, -Number.MAX_VALUE, // Z + Number.MAX_VALUE, + -Number.MAX_VALUE, // X + Number.MAX_VALUE, + -Number.MAX_VALUE, // Y + Number.MAX_VALUE, + -Number.MAX_VALUE, // Z ]); } diff --git a/Sources/Common/Core/MatrixBuilder/index.js b/Sources/Common/Core/MatrixBuilder/index.js index 3cad16dce6a..a062a2f46bc 100644 --- a/Sources/Common/Core/MatrixBuilder/index.js +++ b/Sources/Common/Core/MatrixBuilder/index.js @@ -1,6 +1,6 @@ import { vec3, mat4, glMatrix } from 'gl-matrix'; -const NoOp = v => v; +const NoOp = (v) => v; const IDENTITY = mat4.create(); @@ -67,27 +67,30 @@ class Transform { } apply(typedArray, offset = 0, nbIterations = -1) { - if (IDENTITY[0] === this.matrix[0] - && IDENTITY[1] === this.matrix[1] - && IDENTITY[2] === this.matrix[2] - && IDENTITY[3] === this.matrix[3] - && IDENTITY[4] === this.matrix[4] - && IDENTITY[5] === this.matrix[5] - && IDENTITY[6] === this.matrix[6] - && IDENTITY[7] === this.matrix[7] - && IDENTITY[8] === this.matrix[8] - && IDENTITY[9] === this.matrix[9] - && IDENTITY[10] === this.matrix[10] - && IDENTITY[11] === this.matrix[11] - && IDENTITY[12] === this.matrix[12] - && IDENTITY[13] === this.matrix[13] - && IDENTITY[14] === this.matrix[14] - && IDENTITY[15] === this.matrix[15]) { + if ( + IDENTITY[0] === this.matrix[0] && + IDENTITY[1] === this.matrix[1] && + IDENTITY[2] === this.matrix[2] && + IDENTITY[3] === this.matrix[3] && + IDENTITY[4] === this.matrix[4] && + IDENTITY[5] === this.matrix[5] && + IDENTITY[6] === this.matrix[6] && + IDENTITY[7] === this.matrix[7] && + IDENTITY[8] === this.matrix[8] && + IDENTITY[9] === this.matrix[9] && + IDENTITY[10] === this.matrix[10] && + IDENTITY[11] === this.matrix[11] && + IDENTITY[12] === this.matrix[12] && + IDENTITY[13] === this.matrix[13] && + IDENTITY[14] === this.matrix[14] && + IDENTITY[15] === this.matrix[15] + ) { // Make sure we can chain apply... return this; } - const size = (nbIterations === -1) ? typedArray.length : offset + (nbIterations * 3); + const size = + nbIterations === -1 ? typedArray.length : offset + nbIterations * 3; for (let i = offset; i < size; i += 3) { vec3.set(this.tmp, typedArray[i], typedArray[i + 1], typedArray[i + 2]); vec3.transformMat4(this.tmp, this.tmp, this.matrix); @@ -105,7 +108,6 @@ class Transform { } } - function buildFromDegree() { return new Transform(true); } diff --git a/Sources/Common/Core/Points/index.js b/Sources/Common/Core/Points/index.js index 059cfe07b2e..6b295805c1c 100644 --- a/Sources/Common/Core/Points/index.js +++ b/Sources/Common/Core/Points/index.js @@ -1,5 +1,5 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import macro from 'vtk.js/Sources/macro'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; import { VtkDataTypes } from 'vtk.js/Sources/Common/Core/DataArray/Constants'; const { vtkErrorMacro } = macro; diff --git a/Sources/Common/Core/ProgressHandler/index.js b/Sources/Common/Core/ProgressHandler/index.js index 95be367ad89..1d373ba68b9 100644 --- a/Sources/Common/Core/ProgressHandler/index.js +++ b/Sources/Common/Core/ProgressHandler/index.js @@ -35,11 +35,13 @@ function vtkProgressHandler(publicAPI, model) { (...rejectArgs) => { publicAPI.stopWork(); reject(...rejectArgs); - }); + } + ); }); }; - publicAPI.wrapPromiseFunction = fn => ((...args) => publicAPI.wrapPromise(fn(...args))); + publicAPI.wrapPromiseFunction = (fn) => (...args) => + publicAPI.wrapPromise(fn(...args)); } // ---------------------------------------------------------------------------- diff --git a/Sources/Common/Core/ScalarsToColors/index.js b/Sources/Common/Core/ScalarsToColors/index.js index 4237db57ac3..29e25cbaef2 100644 --- a/Sources/Common/Core/ScalarsToColors/index.js +++ b/Sources/Common/Core/ScalarsToColors/index.js @@ -1,7 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import Constants from 'vtk.js/Sources/Common/Core/ScalarsToColors/Constants'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper/Constants'; // Need to go inside Constants otherwise dependency loop +import Constants from 'vtk.js/Sources/Common/Core/ScalarsToColors/Constants'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper/Constants'; // Need to go inside Constants otherwise dependency loop const { ScalarMappingTarget, VectorMode } = Constants; const { VtkDataTypes } = vtkDataArray; @@ -19,8 +19,12 @@ const { vtkErrorMacro } = macro; // Static API // ---------------------------------------------------------------------------- -function intColorToUChar(c) { return c; } -function floatColorToUChar(c) { return Math.floor((c * 255.0) + 0.5); } +function intColorToUChar(c) { + return c; +} +function floatColorToUChar(c) { + return Math.floor(c * 255.0 + 0.5); +} // ---------------------------------------------------------------------------- // vtkScalarsToColors methods @@ -30,9 +34,12 @@ function vtkScalarsToColors(publicAPI, model) { // Set our className model.classHierarchy.push('vtkScalarsToColors'); - publicAPI.setVectorModeToMagnitude = () => publicAPI.setVectorMode(VectorMode.MAGNITUDE); - publicAPI.setVectorModeToComponent = () => publicAPI.setVectorMode(VectorMode.COMPONENT); - publicAPI.setVectorModeToRGBColors = () => publicAPI.setVectorMode(VectorMode.RGBCOLORS); + publicAPI.setVectorModeToMagnitude = () => + publicAPI.setVectorMode(VectorMode.MAGNITUDE); + publicAPI.setVectorModeToComponent = () => + publicAPI.setVectorMode(VectorMode.COMPONENT); + publicAPI.setVectorModeToRGBColors = () => + publicAPI.setVectorMode(VectorMode.RGBCOLORS); publicAPI.build = () => {}; @@ -40,15 +47,18 @@ function vtkScalarsToColors(publicAPI, model) { //---------------------------------------------------------------------------- publicAPI.setAnnotations = (values, annotations) => { - if ((values && !annotations) || - (!values && annotations)) { + if ((values && !annotations) || (!values && annotations)) { return; } - if (values && annotations && - values.getNumberOfTuples() !== annotations.getNumberOfTuples()) { + if ( + values && + annotations && + values.getNumberOfTuples() !== annotations.getNumberOfTuples() + ) { vtkErrorMacro( - 'Values and annotations do not have the same number of tuples so ignoring'); + 'Values and annotations do not have the same number of tuples so ignoring' + ); return; } @@ -57,7 +67,10 @@ function vtkScalarsToColors(publicAPI, model) { if (annotations && values) { const num = annotations.getNumberOfTuples(); for (let i = 0; i < num; i++) { - model.annotationArray.push({ value: values[i], annotation: annotations[i] }); + model.annotationArray.push({ + value: values[i], + annotation: annotations[i], + }); } } @@ -106,13 +119,13 @@ function vtkScalarsToColors(publicAPI, model) { }; //---------------------------------------------------------------------------- - publicAPI.getAnnotatedValueIndex = val => - (model.annotationArray.length ? publicAPI.checkForAnnotatedValue(val) : -1); + publicAPI.getAnnotatedValueIndex = (val) => + model.annotationArray.length ? publicAPI.checkForAnnotatedValue(val) : -1; //---------------------------------------------------------------------------- publicAPI.removeAnnotation = (value) => { const i = publicAPI.checkForAnnotatedValue(value); - const needToRemove = (i >= 0); + const needToRemove = i >= 0; if (needToRemove) { model.annotationArray.splice(i, 1); publicAPI.updateAnnotatedValueMap(); @@ -140,7 +153,7 @@ function vtkScalarsToColors(publicAPI, model) { }; //---------------------------------------------------------------------------- - publicAPI.checkForAnnotatedValue = value => + publicAPI.checkForAnnotatedValue = (value) => publicAPI.getAnnotatedValueIndexInternal(value); //---------------------------------------------------------------------------- @@ -194,11 +207,16 @@ function vtkScalarsToColors(publicAPI, model) { let newColors = null; // map scalars through lookup table only if needed - if ((colorMode === ColorMode.DEFAULT && - scalars.getDataType() === VtkDataTypes.UNSIGNED_CHAR) || - (colorMode === ColorMode.DIRECT_SCALARS && scalars)) { - newColors = publicAPI.convertToRGBA(scalars, numberOfComponents, - scalars.getNumberOfTuples()); + if ( + (colorMode === ColorMode.DEFAULT && + scalars.getDataType() === VtkDataTypes.UNSIGNED_CHAR) || + (colorMode === ColorMode.DIRECT_SCALARS && scalars) + ) { + newColors = publicAPI.convertToRGBA( + scalars, + numberOfComponents, + scalars.getNumberOfTuples() + ); } else { const newscalars = { type: 'vtkDataArray', @@ -207,7 +225,9 @@ function vtkScalarsToColors(publicAPI, model) { dataType: VtkDataTypes.UNSIGNED_CHAR, }; - const s = new window[newscalars.dataType](4 * scalars.getNumberOfTuples()); + const s = new window[newscalars.dataType]( + 4 * scalars.getNumberOfTuples() + ); newscalars.values = s; newscalars.size = s.length; newColors = vtkDataArray.newInstance(newscalars); @@ -216,7 +236,13 @@ function vtkScalarsToColors(publicAPI, model) { // If mapper did not specify a component, use the VectorMode if (component < 0 && numberOfComponents > 1) { - publicAPI.mapVectorsThroughTable(scalars, newColors, ScalarMappingTarget.RGBA, -1, -1); + publicAPI.mapVectorsThroughTable( + scalars, + newColors, + ScalarMappingTarget.RGBA, + -1, + -1 + ); } else { if (component < 0) { component = 0; @@ -226,7 +252,12 @@ function vtkScalarsToColors(publicAPI, model) { } // Map the scalars to colors - publicAPI.mapScalarsThroughTable(scalars, newColors, ScalarMappingTarget.RGBA, component); + publicAPI.mapScalarsThroughTable( + scalars, + newColors, + ScalarMappingTarget.RGBA, + component + ); } } @@ -243,7 +274,7 @@ function vtkScalarsToColors(publicAPI, model) { for (let i = 0; i < length; i++) { let sum = 0.0; for (let j = 0; j < compsToUse; j++) { - sum += inputV[(i * inIncr) + j]; + sum += inputV[i * inIncr + j]; } outputV[i] = Math.sqrt(sum); } @@ -252,10 +283,12 @@ function vtkScalarsToColors(publicAPI, model) { //---------------------------------------------------------------------------- // Map a set of vector values through the table publicAPI.mapVectorsThroughTable = ( - input, output, + input, + output, outputFormat, vectorComponentIn, - vectorSizeIn) => { + vectorSizeIn + ) => { let vectorMode = publicAPI.getVectorMode(); let vectorSize = vectorSizeIn; let vectorComponent = vectorComponentIn; @@ -294,8 +327,10 @@ function vtkScalarsToColors(publicAPI, model) { } } - if (vectorMode === VectorMode.MAGNITUDE && - (inComponents === 1 || vectorSize === 1)) { + if ( + vectorMode === VectorMode.MAGNITUDE && + (inComponents === 1 || vectorSize === 1) + ) { vectorMode = VectorMode.COMPONENT; } } @@ -310,18 +345,23 @@ function vtkScalarsToColors(publicAPI, model) { switch (vectorMode) { case VectorMode.COMPONENT: { publicAPI.mapScalarsThroughTable( - input, output, outputFormat, inputOffset); + input, + output, + outputFormat, + inputOffset + ); break; } default: case VectorMode.MAGNITUDE: { - const magValues = - vtkDataArray.newInstance({ numberOfComponents: 1, values: new Float32Array(input.getNumberOfTuples()) }); + const magValues = vtkDataArray.newInstance({ + numberOfComponents: 1, + values: new Float32Array(input.getNumberOfTuples()), + }); publicAPI.mapVectorsToMagnitude(input, magValues, vectorSize); - publicAPI.mapScalarsThroughTable( - magValues, output, outputFormat, 0); + publicAPI.mapScalarsThroughTable(magValues, output, outputFormat, 0); break; } @@ -346,10 +386,10 @@ function vtkScalarsToColors(publicAPI, model) { let count = 0; for (let i = component; i < size; i += tuple) { const l = convtFun(values[i]); - newValues[(count * 4)] = l; - newValues[(count * 4) + 1] = l; - newValues[(count * 4) + 2] = l; - newValues[(count * 4) + 3] = a; + newValues[count * 4] = l; + newValues[count * 4 + 1] = l; + newValues[count * 4 + 2] = l; + newValues[count * 4 + 3] = a; count++; } }; @@ -383,10 +423,10 @@ function vtkScalarsToColors(publicAPI, model) { let count = 0; for (let i = component; i < size; i += tuple) { - newValues[(count * 4)] = convtFun(values[i]); - newValues[(count * 4) + 1] = convtFun(values[i + 1]); - newValues[(count * 4) + 2] = convtFun(values[i + 2]); - newValues[(count * 4) + 3] = a; + newValues[count * 4] = convtFun(values[i]); + newValues[count * 4 + 1] = convtFun(values[i + 1]); + newValues[count * 4 + 2] = convtFun(values[i + 2]); + newValues[count * 4 + 3] = a; count++; } }; @@ -400,18 +440,21 @@ function vtkScalarsToColors(publicAPI, model) { let count = 0; for (let i = component; i < size; i += tuple) { - newValues[(count * 4)] = convtFun(values[i]); - newValues[(count * 4) + 1] = convtFun(values[i + 1]); - newValues[(count * 4) + 2] = convtFun(values[i + 2]); - newColors[(count * 4) + 3] = convtFun(values[i + 3]) * alpha; + newValues[count * 4] = convtFun(values[i]); + newValues[count * 4 + 1] = convtFun(values[i + 1]); + newValues[count * 4 + 2] = convtFun(values[i + 2]); + newColors[count * 4 + 3] = convtFun(values[i + 3]) * alpha; count++; } }; //---------------------------------------------------------------------------- publicAPI.convertToRGBA = (colors, numComp, numTuples) => { - if (numComp === 4 && model.alpha >= 1.0 && - colors.getDataType() === VtkDataTypes.UNSIGNED_CHAR) { + if ( + numComp === 4 && + model.alpha >= 1.0 && + colors.getDataType() === VtkDataTypes.UNSIGNED_CHAR + ) { return colors; } @@ -427,12 +470,14 @@ function vtkScalarsToColors(publicAPI, model) { } let alpha = model.alpha; - alpha = (alpha > 0 ? alpha : 0); - alpha = (alpha < 1 ? alpha : 1); + alpha = alpha > 0 ? alpha : 0; + alpha = alpha < 1 ? alpha : 1; let convtFun = intColorToUChar; - if ((colors.getDataType() === VtkDataTypes.FLOAT) || - colors.getDataType() === VtkDataTypes.DOUBLE) { + if ( + colors.getDataType() === VtkDataTypes.FLOAT || + colors.getDataType() === VtkDataTypes.DOUBLE + ) { convtFun = floatColorToUChar; } @@ -506,14 +551,10 @@ export function extend(publicAPI, model, initialValues = {}) { ]); // Create set macros for array (needs to know size) - macro.setArray(publicAPI, model, [ - 'mappingRange', - ], 2); + macro.setArray(publicAPI, model, ['mappingRange'], 2); // Create get macros for array - macro.getArray(publicAPI, model, [ - 'mappingRange', - ]); + macro.getArray(publicAPI, model, ['mappingRange']); // For more macro methods, see "Sources/macro.js" diff --git a/Sources/Common/Core/StringArray/index.js b/Sources/Common/Core/StringArray/index.js index f12fb119af6..17fe1cc52f8 100644 --- a/Sources/Common/Core/StringArray/index.js +++ b/Sources/Common/Core/StringArray/index.js @@ -14,7 +14,7 @@ function vtkStringArray(publicAPI, model) { // Return the data component at the location specified by tupleIdx and // compIdx. publicAPI.getComponent = (tupleIdx, compIdx = 0) => - model.values[(tupleIdx * model.numberOfComponents) + compIdx]; + model.values[tupleIdx * model.numberOfComponents + compIdx]; // Description: // Set the data component at the location specified by tupleIdx and compIdx @@ -23,8 +23,8 @@ function vtkStringArray(publicAPI, model) { // NumberOfComponents. Make sure enough memory has been allocated // (use SetNumberOfTuples() and SetNumberOfComponents()). publicAPI.setComponent = (tupleIdx, compIdx, value) => { - if (value !== model.values[(tupleIdx * model.numberOfComponents) + compIdx]) { - model.values[(tupleIdx * model.numberOfComponents) + compIdx] = value; + if (value !== model.values[tupleIdx * model.numberOfComponents + compIdx]) { + model.values[tupleIdx * model.numberOfComponents + compIdx] = value; publicAPI.modified(); } }; @@ -46,13 +46,15 @@ function vtkStringArray(publicAPI, model) { publicAPI.getTupleLocation = (idx = 1) => idx * model.numberOfComponents; publicAPI.getNumberOfComponents = () => model.numberOfComponents; publicAPI.getNumberOfValues = () => model.values.length; - publicAPI.getNumberOfTuples = () => model.values.length / model.numberOfComponents; + publicAPI.getNumberOfTuples = () => + model.values.length / model.numberOfComponents; publicAPI.getDataType = () => model.dataType; /* eslint-disable no-use-before-define */ - publicAPI.newClone = () => newInstance({ - name: model.name, - numberOfComponents: model.numberOfComponents, - }); + publicAPI.newClone = () => + newInstance({ + name: model.name, + numberOfComponents: model.numberOfComponents, + }); /* eslint-enable no-use-before-define */ publicAPI.getName = () => { @@ -93,8 +95,10 @@ const DEFAULT_VALUES = { export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); - if ((!model.empty && !model.values && !model.size)) { - throw new TypeError('Cannot create vtkStringArray object without: size > 0, values'); + if (!model.empty && !model.values && !model.size) { + throw new TypeError( + 'Cannot create vtkStringArray object without: size > 0, values' + ); } if (!model.values) { diff --git a/Sources/Common/Core/URLExtract/index.js b/Sources/Common/Core/URLExtract/index.js index c9da1eb1b91..da370390c05 100644 --- a/Sources/Common/Core/URLExtract/index.js +++ b/Sources/Common/Core/URLExtract/index.js @@ -17,7 +17,10 @@ function toNativeType(str) { return parseFloat(str); } -function extractURLParameters(castToNativeType = true, query = window.location.search) { +function extractURLParameters( + castToNativeType = true, + query = window.location.search +) { const summary = {}; const convert = castToNativeType ? toNativeType : identity; const queryTokens = (query || '') @@ -26,7 +29,7 @@ function extractURLParameters(castToNativeType = true, query = window.location.s .split('&'); // extract token pair queryTokens.forEach((token) => { - const [key, value] = token.split('=').map(s => decodeURIComponent(s)); + const [key, value] = token.split('=').map((s) => decodeURIComponent(s)); if (key) { summary[key] = value ? convert(value) : true; } diff --git a/Sources/Common/Core/VariantArray/index.js b/Sources/Common/Core/VariantArray/index.js index a51639c2eee..b6be60c7d31 100644 --- a/Sources/Common/Core/VariantArray/index.js +++ b/Sources/Common/Core/VariantArray/index.js @@ -14,7 +14,7 @@ function vtkVariantArray(publicAPI, model) { // Return the data component at the location specified by tupleIdx and // compIdx. publicAPI.getComponent = (tupleIdx, compIdx = 0) => - model.values[(tupleIdx * model.numberOfComponents) + compIdx]; + model.values[tupleIdx * model.numberOfComponents + compIdx]; // Description: // Set the data component at the location specified by tupleIdx and compIdx @@ -23,8 +23,8 @@ function vtkVariantArray(publicAPI, model) { // NumberOfComponents. Make sure enough memory has been allocated // (use SetNumberOfTuples() and SetNumberOfComponents()). publicAPI.setComponent = (tupleIdx, compIdx, value) => { - if (value !== model.values[(tupleIdx * model.numberOfComponents) + compIdx]) { - model.values[(tupleIdx * model.numberOfComponents) + compIdx] = value; + if (value !== model.values[tupleIdx * model.numberOfComponents + compIdx]) { + model.values[tupleIdx * model.numberOfComponents + compIdx] = value; publicAPI.modified(); } }; @@ -46,13 +46,15 @@ function vtkVariantArray(publicAPI, model) { publicAPI.getTupleLocation = (idx = 1) => idx * model.numberOfComponents; publicAPI.getNumberOfComponents = () => model.numberOfComponents; publicAPI.getNumberOfValues = () => model.values.length; - publicAPI.getNumberOfTuples = () => model.values.length / model.numberOfComponents; + publicAPI.getNumberOfTuples = () => + model.values.length / model.numberOfComponents; publicAPI.getDataType = () => model.dataType; /* eslint-disable no-use-before-define */ - publicAPI.newClone = () => newInstance({ - name: model.name, - numberOfComponents: model.numberOfComponents, - }); + publicAPI.newClone = () => + newInstance({ + name: model.name, + numberOfComponents: model.numberOfComponents, + }); /* eslint-enable no-use-before-define */ publicAPI.getName = () => { @@ -93,8 +95,10 @@ const DEFAULT_VALUES = { export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); - if ((!model.empty && !model.values && !model.size)) { - throw new TypeError('Cannot create vtkVariantArray object without: size > 0, values'); + if (!model.empty && !model.values && !model.size) { + throw new TypeError( + 'Cannot create vtkVariantArray object without: size > 0, values' + ); } if (!model.values) { diff --git a/Sources/Common/Core/index.js b/Sources/Common/Core/index.js index f7428b8c6f2..3235a9d4070 100644 --- a/Sources/Common/Core/index.js +++ b/Sources/Common/Core/index.js @@ -1,13 +1,13 @@ -import vtkCellArray from './CellArray'; -import vtkDataArray from './DataArray'; -import vtkEndian from './Endian'; -import vtkLookupTable from './LookupTable'; -import vtkMath from './Math'; -import vtkPoints from './Points'; +import vtkCellArray from './CellArray'; +import vtkDataArray from './DataArray'; +import vtkEndian from './Endian'; +import vtkLookupTable from './LookupTable'; +import vtkMath from './Math'; +import vtkPoints from './Points'; import vtkScalarsToColors from './ScalarsToColors'; -import vtkStringArray from './StringArray'; -import vtkURLExtract from './URLExtract'; -import vtkVariantArray from './VariantArray'; +import vtkStringArray from './StringArray'; +import vtkURLExtract from './URLExtract'; +import vtkVariantArray from './VariantArray'; export default { vtkCellArray, diff --git a/Sources/Common/DataModel/BoundingBox/index.js b/Sources/Common/DataModel/BoundingBox/index.js index 8144a2d031a..589e7518db0 100644 --- a/Sources/Common/DataModel/BoundingBox/index.js +++ b/Sources/Common/DataModel/BoundingBox/index.js @@ -1,10 +1,13 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkPlane from 'vtk.js/Sources/Common/DataModel/Plane'; const INIT_BOUNDS = [ - Number.MAX_VALUE, -Number.MAX_VALUE, // X - Number.MAX_VALUE, -Number.MAX_VALUE, // Y - Number.MAX_VALUE, -Number.MAX_VALUE, // Z + Number.MAX_VALUE, + -Number.MAX_VALUE, // X + Number.MAX_VALUE, + -Number.MAX_VALUE, // Y + Number.MAX_VALUE, + -Number.MAX_VALUE, // Z ]; // ---------------------------------------------------------------------------- @@ -12,9 +15,9 @@ const INIT_BOUNDS = [ // ---------------------------------------------------------------------------- function isValid(bounds) { - return bounds[0] <= bounds[1] - && bounds[2] <= bounds[3] - && bounds[4] <= bounds[5]; + return ( + bounds[0] <= bounds[1] && bounds[2] <= bounds[3] && bounds[4] <= bounds[5] + ); } function getCenter(bounds) { @@ -26,15 +29,11 @@ function getCenter(bounds) { } function getLength(bounds, index) { - return bounds[(index * 2) + 1] - bounds[index * 2]; + return bounds[index * 2 + 1] - bounds[index * 2]; } function getLengths(bounds) { - return [ - getLength(bounds, 0), - getLength(bounds, 1), - getLength(bounds, 2), - ]; + return [getLength(bounds, 0), getLength(bounds, 1), getLength(bounds, 2)]; } function getXRange(bounds) { @@ -65,7 +64,7 @@ function getMaxLength(bounds) { function getDiagonalLength(bounds) { if (isValid(bounds)) { const l = getLengths(bounds); - return Math.sqrt((l[0] * l[0]) + (l[1] * l[1]) + (l[2] * l[2])); + return Math.sqrt(l[0] * l[0] + l[1] * l[1] + l[2] * l[2]); } return null; } @@ -122,12 +121,14 @@ function vtkBoundingBox(publicAPI, model) { publicAPI.equals = (other) => { const a = model.bounds; const b = other.getBounds(); - 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]; + 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] + ); }; publicAPI.setMinPoint = (x, y, z) => { @@ -172,9 +173,12 @@ function vtkBoundingBox(publicAPI, model) { publicAPI.addBounds = (xMin, xMax, yMin, yMax, zMin, zMax) => { const [_xMin, _xMax, _yMin, _yMax, _zMin, _zMax] = model.bounds; model.bounds = [ - Math.min(xMin, _xMin), Math.max(xMax, _xMax), - Math.min(yMin, _yMin), Math.max(yMax, _yMax), - Math.min(zMin, _zMin), Math.max(zMax, _zMax), + Math.min(xMin, _xMin), + Math.max(xMax, _xMax), + Math.min(yMin, _yMin), + Math.max(yMax, _yMax), + Math.min(zMin, _zMin), + Math.max(zMax, _zMax), ]; }; @@ -194,24 +198,32 @@ function vtkBoundingBox(publicAPI, model) { let intersects; for (let i = 0; i < 3; i++) { intersects = false; - if ((bBounds[i * 2] >= model.bounds[i * 2]) && - (bBounds[i * 2] <= model.bounds[(i * 2) + 1])) { + if ( + bBounds[i * 2] >= model.bounds[i * 2] && + bBounds[i * 2] <= model.bounds[i * 2 + 1] + ) { intersects = true; newBounds[i * 2] = bBounds[i * 2]; - } else if ((model.bounds[i * 2] >= bBounds[i * 2]) && - (model.bounds[i * 2] <= bBounds[(i * 2) + 1])) { + } else if ( + model.bounds[i * 2] >= bBounds[i * 2] && + model.bounds[i * 2] <= bBounds[i * 2 + 1] + ) { intersects = true; newBounds[i * 2] = model.bounds[i * 2]; } - if ((bBounds[(i * 2) + 1] >= model.bounds[i * 2]) && - (bBounds[(i * 2) + 1] <= model.bounds[(i * 2) + 1])) { + if ( + bBounds[i * 2 + 1] >= model.bounds[i * 2] && + bBounds[i * 2 + 1] <= model.bounds[i * 2 + 1] + ) { intersects = true; - newBounds[(i * 2) + 1] = bbox.MaxPnt[i]; - } else if ((model.bounds[(i * 2) + 1] >= bbox.MinPnt[i * 2]) && - (model.bounds[(i * 2) + 1] <= bbox.MaxPnt[(i * 2) + 1])) { + newBounds[i * 2 + 1] = bbox.MaxPnt[i]; + } else if ( + model.bounds[i * 2 + 1] >= bbox.MinPnt[i * 2] && + model.bounds[i * 2 + 1] <= bbox.MaxPnt[i * 2 + 1] + ) { intersects = true; - newBounds[(i * 2) + 1] = model.bounds[(i * 2) + 1]; + newBounds[i * 2 + 1] = model.bounds[i * 2 + 1]; } if (!intersects) { @@ -231,19 +243,27 @@ function vtkBoundingBox(publicAPI, model) { const bBounds = bbox.getBounds(); /* eslint-disable no-continue */ for (let i = 0; i < 3; i++) { - if ((bBounds[i * 2] >= model.bounds[i * 2]) && - (bBounds[i * 2] <= model.bounds[(i * 2) + 1])) { + if ( + bBounds[i * 2] >= model.bounds[i * 2] && + bBounds[i * 2] <= model.bounds[i * 2 + 1] + ) { continue; - } else if ((model.bounds[i * 2] >= bBounds[i * 2]) && - (model.bounds[i * 2] <= bBounds[(i * 2) + 1])) { + } else if ( + model.bounds[i * 2] >= bBounds[i * 2] && + model.bounds[i * 2] <= bBounds[i * 2 + 1] + ) { continue; } - if ((bBounds[(i * 2) + 1] >= model.bounds[i * 2]) && - (bBounds[(i * 2) + 1] <= model.bounds[(i * 2) + 1])) { + if ( + bBounds[i * 2 + 1] >= model.bounds[i * 2] && + bBounds[i * 2 + 1] <= model.bounds[i * 2 + 1] + ) { continue; - } else if ((model.bounds[(i * 2) + 1] >= bbox.MinPnt[i * 2]) && - (model.bounds[(i * 2) + 1] <= bbox.MaxPnt[(i * 2) + 1])) { + } else if ( + model.bounds[i * 2 + 1] >= bbox.MinPnt[i * 2] && + model.bounds[i * 2 + 1] <= bbox.MaxPnt[i * 2 + 1] + ) { continue; } return false; @@ -274,15 +294,16 @@ function vtkBoundingBox(publicAPI, model) { } } - let dir = 2; while (dir--) { // in each direction, we test if the vertices of two orthogonal faces // are on either side of the plane - if (oppositeSign(d[index[dir][0]], d[index[dir][4]]) && - oppositeSign(d[index[dir][1]], d[index[dir][5]]) && - oppositeSign(d[index[dir][2]], d[index[dir][6]]) && - oppositeSign(d[index[dir][3]], d[index[dir][7]])) { + if ( + oppositeSign(d[index[dir][0]], d[index[dir][4]]) && + oppositeSign(d[index[dir][1]], d[index[dir][5]]) && + oppositeSign(d[index[dir][2]], d[index[dir][6]]) && + oppositeSign(d[index[dir][3]], d[index[dir][7]]) + ) { break; } } @@ -292,7 +313,9 @@ function vtkBoundingBox(publicAPI, model) { } const sign = Math.sign(normal[dir]); - const size = Math.abs((model.bounds[(dir * 2) + 1] - model.bounds[dir * 2]) * normal[dir]); + const size = Math.abs( + (model.bounds[dir * 2 + 1] - model.bounds[dir * 2]) * normal[dir] + ); let t = sign > 0 ? 1 : 0; /* eslint-disable no-continue */ for (let i = 0; i < 4; i++) { @@ -309,36 +332,45 @@ function vtkBoundingBox(publicAPI, model) { } } /* eslint-enable no-continue */ - const bound = ((1.0 - t) * model.bounds[dir * 2]) + (t * model.bounds[(dir * 2) + 1]); + const bound = + (1.0 - t) * model.bounds[dir * 2] + t * model.bounds[dir * 2 + 1]; if (sign > 0) { model.bounds[dir * 2] = bound; } else { - model.bounds[(dir * 2) + 1] = bound; + model.bounds[dir * 2 + 1] = bound; } return true; }; publicAPI.containsPoint = (x, y, z) => { - if ((x < model.bounds[0]) || (x > model.bounds[1])) { + if (x < model.bounds[0] || x > model.bounds[1]) { return false; } - if ((y < model.bounds[2]) || (y > model.bounds[3])) { + if (y < model.bounds[2] || y > model.bounds[3]) { return false; } - if ((z < model.bounds[4]) || (z > model.bounds[5])) { + if (z < model.bounds[4] || z > model.bounds[5]) { return false; } return true; }; - publicAPI.getMinPoint = () => [model.bounds[0], model.bounds[2], model.bounds[4]]; - publicAPI.getMaxPoint = () => [model.bounds[1], model.bounds[3], model.bounds[5]]; - publicAPI.getBound = index => model.bound[index]; + publicAPI.getMinPoint = () => [ + model.bounds[0], + model.bounds[2], + model.bounds[4], + ]; + publicAPI.getMaxPoint = () => [ + model.bounds[1], + model.bounds[3], + model.bounds[5], + ]; + publicAPI.getBound = (index) => model.bound[index]; publicAPI.contains = (bbox) => { // if either box is not valid or they don't intersect @@ -358,7 +390,7 @@ function vtkBoundingBox(publicAPI, model) { }; publicAPI.getCenter = () => getCenter(model.bounds); - publicAPI.getLength = index => getLength(model.bounds, index); + publicAPI.getLength = (index) => getLength(model.bounds, index); publicAPI.getLengths = () => getLengths(model.bounds); publicAPI.getMaxLength = () => getMaxLength(model.bounds); publicAPI.getDiagonalLength = () => getDiagonalLength(model.bounds); diff --git a/Sources/Common/DataModel/Box/index.js b/Sources/Common/DataModel/Box/index.js index f01690d8b18..dbb6e88e658 100644 --- a/Sources/Common/DataModel/Box/index.js +++ b/Sources/Common/DataModel/Box/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkBoundingBox from 'vtk.js/Sources/Common/DataModel/BoundingBox'; // ---------------------------------------------------------------------------- @@ -26,9 +26,9 @@ function intersectBox(bounds, origin, dir, coord, tolerance) { quadrant[i] = LEFT; candidatePlane[i] = bounds[2 * i]; inside = false; - } else if (origin[i] > bounds[(2 * i) + 1]) { + } else if (origin[i] > bounds[2 * i + 1]) { quadrant[i] = RIGHT; - candidatePlane[i] = bounds[(2 * i) + 1]; + candidatePlane[i] = bounds[2 * i + 1]; inside = false; } else { quadrant[i] = MIDDLE; @@ -70,8 +70,8 @@ function intersectBox(bounds, origin, dir, coord, tolerance) { // Intersection point along line is okay. Check bbox. for (let i = 0; i < 3; i++) { if (whichPlane !== i) { - coord[i] = origin[i] + (maxT[whichPlane] * dir[i]); - if (coord[i] < bounds[2 * i] || coord[i] > bounds[(2 * i) + 1]) { + coord[i] = origin[i] + maxT[whichPlane] * dir[i]; + if (coord[i] < bounds[2 * i] || coord[i] > bounds[2 * i + 1]) { return 0; } } else { @@ -146,13 +146,15 @@ function vtkBox(publicAPI, model) { } else if (t > 1.0) { inside = 0; dist = point[i] - maxPoint[i]; - } else { // want negative distance, we are inside + } else { + // want negative distance, we are inside if (t <= 0.5) { dist = minPoint[i] - point[i]; } else { dist = point[i] - maxPoint[i]; } - if (dist > minDistance) { // remember, it's engative + if (dist > minDistance) { + // remember, it's engative minDistance = dist; } } // end if inside @@ -197,8 +199,7 @@ function vtkBox(publicAPI, model) { // Object factory // ---------------------------------------------------------------------------- -const DEFAULT_VALUES = { -}; +const DEFAULT_VALUES = {}; // ---------------------------------------------------------------------------- diff --git a/Sources/Common/DataModel/Box/test/testBox.js b/Sources/Common/DataModel/Box/test/testBox.js index e279743a4f5..87db1d87d57 100644 --- a/Sources/Common/DataModel/Box/test/testBox.js +++ b/Sources/Common/DataModel/Box/test/testBox.js @@ -1,4 +1,4 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import vtkBox from 'vtk.js/Sources/Common/DataModel/Box'; test('Test vtkBox instance', (t) => { @@ -77,4 +77,3 @@ test('Test vtkBox evaluateFunction', (t) => { t.end(); }); - diff --git a/Sources/Common/DataModel/Cell/index.js b/Sources/Common/DataModel/Cell/index.js index eccc002697f..429e6d2d044 100644 --- a/Sources/Common/DataModel/Cell/index.js +++ b/Sources/Common/DataModel/Cell/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkMath from 'vtk.js/Sources/Common/Core/Math'; import vtkPoints from 'vtk.js/Sources/Common/Core/Points'; @@ -30,12 +30,12 @@ function vtkCell(publicAPI, model) { for (let i = 1; i < nbPoints; i++) { model.points.getPoint(i, x); - model.bounds[0] = (x[0] < model.bounds[0] ? x[0] : model.bounds[0]); - model.bounds[1] = (x[0] > model.bounds[1] ? x[0] : model.bounds[1]); - model.bounds[2] = (x[1] < model.bounds[2] ? x[1] : model.bounds[2]); - model.bounds[3] = (x[1] > model.bounds[3] ? x[1] : model.bounds[3]); - model.bounds[4] = (x[2] < model.bounds[4] ? x[2] : model.bounds[4]); - model.bounds[5] = (x[2] > model.bounds[5] ? x[2] : model.bounds[5]); + model.bounds[0] = x[0] < model.bounds[0] ? x[0] : model.bounds[0]; + model.bounds[1] = x[0] > model.bounds[1] ? x[0] : model.bounds[1]; + model.bounds[2] = x[1] < model.bounds[2] ? x[1] : model.bounds[2]; + model.bounds[3] = x[1] > model.bounds[3] ? x[1] : model.bounds[3]; + model.bounds[4] = x[2] < model.bounds[4] ? x[2] : model.bounds[4]; + model.bounds[5] = x[2] > model.bounds[5] ? x[2] : model.bounds[5]; } } else { vtkMath.uninitializeBounds(model.bounds); @@ -48,7 +48,7 @@ function vtkCell(publicAPI, model) { let length = 0.0; let diff = 0; for (let i = 0; i < 3; i++) { - diff = model.bounds[(2 * i) + 1] - model.bounds[2 * i]; + diff = model.bounds[2 * i + 1] - model.bounds[2 * i]; length += diff * diff; } return length; @@ -63,7 +63,8 @@ function vtkCell(publicAPI, model) { pDist = -pcoords[i]; } else if (pcoords[i] > 1.0) { pDist = pcoords[i] - 1.0; - } else { // inside the cell in the parametric direction + } else { + // inside the cell in the parametric direction pDist = 0.0; } if (pDist > pDistMax) { @@ -76,12 +77,23 @@ function vtkCell(publicAPI, model) { publicAPI.getNumberOfPoints = () => model.points.getNumberOfPoints(); publicAPI.deepCopy = (cell) => { - cell.initialize(model.points.getNumberOfPoints(), model.pointsIds, model.points); + cell.initialize( + model.points.getNumberOfPoints(), + model.pointsIds, + model.points + ); }; publicAPI.getCellDimension = () => {}; // virtual publicAPI.intersectWithLine = (p1, p2, tol, t, x, pcoords, subId) => {}; // virtual - publicAPI.evaluatePosition = (x, closestPoint, subId, pcoords, dist2, weights) => {}; // virtual + publicAPI.evaluatePosition = ( + x, + closestPoint, + subId, + pcoords, + dist2, + weights + ) => {}; // virtual } // ---------------------------------------------------------------------------- diff --git a/Sources/Common/DataModel/Cone/index.js b/Sources/Common/DataModel/Cone/index.js index 1f4e19dffad..852a11213a1 100644 --- a/Sources/Common/DataModel/Cone/index.js +++ b/Sources/Common/DataModel/Cone/index.js @@ -1,16 +1,14 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import macro from 'vtk.js/Sources/macro'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; // ---------------------------------------------------------------------------- // Global methods // ---------------------------------------------------------------------------- - // ---------------------------------------------------------------------------- // Static API // ---------------------------------------------------------------------------- - // ---------------------------------------------------------------------------- // vtkCone methods // ---------------------------------------------------------------------------- @@ -21,18 +19,15 @@ function vtkCone(publicAPI, model) { publicAPI.evaluateFunction = (x) => { const tanTheta = Math.tan(vtkMath.radiansFromDegrees(model.angle)); - const retVal = (x[1] * x[1]) + (x[2] * x[2]) - (x[0] * x[0] * tanTheta * tanTheta); + const retVal = + x[1] * x[1] + x[2] * x[2] - x[0] * x[0] * tanTheta * tanTheta; return retVal; }; publicAPI.evaluateGradient = (x) => { const tanTheta = Math.tan(vtkMath.radiansFromDegrees(model.angle)); - const retVal = [ - -2.0 * x[0] * tanTheta * tanTheta, - 2.0 * x[1], - 2.0 * x[2], - ]; + const retVal = [-2.0 * x[0] * tanTheta * tanTheta, 2.0 * x[1], 2.0 * x[2]]; return retVal; }; } @@ -51,9 +46,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Object methods macro.obj(publicAPI, model); - macro.setGet(publicAPI, model, [ - 'angle', - ]); + macro.setGet(publicAPI, model, ['angle']); vtkCone(publicAPI, model); } diff --git a/Sources/Common/DataModel/Cone/test/testConeImplicitFunction.js b/Sources/Common/DataModel/Cone/test/testConeImplicitFunction.js index 05bb0907378..1689c4ff34d 100644 --- a/Sources/Common/DataModel/Cone/test/testConeImplicitFunction.js +++ b/Sources/Common/DataModel/Cone/test/testConeImplicitFunction.js @@ -1,14 +1,14 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkCone from 'vtk.js/Sources/Common/DataModel/Cone'; -import vtkSampleFunction from 'vtk.js/Sources/Imaging/Hybrid/SampleFunction'; -import vtkImageMarchingCubes from 'vtk.js/Sources/Filters/General/ImageMarchingCubes'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkCone from 'vtk.js/Sources/Common/DataModel/Cone'; +import vtkSampleFunction from 'vtk.js/Sources/Imaging/Hybrid/SampleFunction'; +import vtkImageMarchingCubes from 'vtk.js/Sources/Filters/General/ImageMarchingCubes'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; import baseline from './testConeImplicitFunction.png'; @@ -18,7 +18,9 @@ test.onlyIfWebGL('Test Cone Implicit Function', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // Rendering stuff @@ -29,9 +31,16 @@ test.onlyIfWebGL('Test Cone Implicit Function', (t) => { // Pipeline const cone = gc.registerResource(vtkCone.newInstance({ angle: 12.0 })); - const sample = gc.registerResource(vtkSampleFunction.newInstance({ - implicitFunction: cone, sampleDimensions: [50, 50, 50], modelBounds: [-1, 1, -1, 1, -1, 1] })); - const mCubes = gc.registerResource(vtkImageMarchingCubes.newInstance({ contourValue: 0.0 })); + const sample = gc.registerResource( + vtkSampleFunction.newInstance({ + implicitFunction: cone, + sampleDimensions: [50, 50, 50], + modelBounds: [-1, 1, -1, 1, -1, 1], + }) + ); + const mCubes = gc.registerResource( + vtkImageMarchingCubes.newInstance({ contourValue: 0.0 }) + ); mCubes.setInputConnection(sample.getOutputPort()); const mapper = gc.registerResource(vtkMapper.newInstance()); @@ -51,5 +60,12 @@ test.onlyIfWebGL('Test Cone Implicit Function', (t) => { renderWindow.render(); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Common/DataModel/Cone/testConeImplicitFunction', t, 1.0, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Common/DataModel/Cone/testConeImplicitFunction', + t, + 1.0, + gc.releaseResources + ); }); diff --git a/Sources/Common/DataModel/Cylinder/index.js b/Sources/Common/DataModel/Cylinder/index.js index 9fd7d41d90f..e49bba64332 100644 --- a/Sources/Common/DataModel/Cylinder/index.js +++ b/Sources/Common/DataModel/Cylinder/index.js @@ -1,5 +1,5 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import macro from 'vtk.js/Sources/macro'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; // ---------------------------------------------------------------------------- // Global methods @@ -13,7 +13,7 @@ function evaluate(radius, center, axis, x) { const proj = vtkMath.dot(axis, x2C); - const retVal = ((vtkMath.dot(x2C, x2C) - (proj * proj)) - (radius * radius)); + const retVal = vtkMath.dot(x2C, x2C) - proj * proj - radius * radius; return retVal; } @@ -26,7 +26,6 @@ export const STATIC = { evaluate, }; - // ---------------------------------------------------------------------------- // vtkCylinder methods // ---------------------------------------------------------------------------- @@ -44,26 +43,28 @@ function vtkCylinder(publicAPI, model) { const proj = vtkMath.dot(model.axis, x2C); - const retVal = ((vtkMath.dot(x2C, x2C) - (proj * proj)) - (model.radius * model.radius)); + const retVal = + vtkMath.dot(x2C, x2C) - proj * proj - model.radius * model.radius; return retVal; }; publicAPI.evaluateGradient = (xyz) => { - const t = (model.axis[0] * (xyz[0] - model.center[0])) + - (model.axis[1] * (xyz[1] - model.center[1])) + - (model.axis[2] * (xyz[2] - model.center[2])); + const t = + model.axis[0] * (xyz[0] - model.center[0]) + + model.axis[1] * (xyz[1] - model.center[1]) + + model.axis[2] * (xyz[2] - model.center[2]); const cp = [ - model.center[0] + (t * model.axis[0]), - model.center[1] + (t * model.axis[1]), - model.center[2] + (t * model.axis[2]), + model.center[0] + t * model.axis[0], + model.center[1] + t * model.axis[1], + model.center[2] + t * model.axis[2], ]; const retVal = [ - (2.0 * (xyz[0] - cp[0])), - (2.0 * (xyz[1] - cp[1])), - (2.0 * (xyz[2] - cp[2])), + 2.0 * (xyz[0] - cp[0]), + 2.0 * (xyz[1] - cp[1]), + 2.0 * (xyz[2] - cp[2]), ]; return retVal; }; @@ -85,13 +86,8 @@ export function extend(publicAPI, model, initialValues = {}) { // Object methods macro.obj(publicAPI, model); - macro.setGet(publicAPI, model, [ - 'radius', - ]); - macro.setGetArray(publicAPI, model, [ - 'center', - 'axis', - ], 3); + macro.setGet(publicAPI, model, ['radius']); + macro.setGetArray(publicAPI, model, ['center', 'axis'], 3); vtkCylinder(publicAPI, model); } diff --git a/Sources/Common/DataModel/DataSet/Constants.js b/Sources/Common/DataModel/DataSet/Constants.js index f2f77287c05..b50e5a1385b 100644 --- a/Sources/Common/DataModel/DataSet/Constants.js +++ b/Sources/Common/DataModel/DataSet/Constants.js @@ -1,25 +1,25 @@ // Specify how data arrays can be used by data objects export const FieldDataTypes = { - UNIFORM: 0, // data that does not vary over points/cells/etc. - DATA_OBJECT_FIELD: 0, // to match VTK + UNIFORM: 0, // data that does not vary over points/cells/etc. + DATA_OBJECT_FIELD: 0, // to match VTK - COORDINATE: 1, // data that specifies the location of each point - POINT_DATA: 1, // to match VTK + COORDINATE: 1, // data that specifies the location of each point + POINT_DATA: 1, // to match VTK - POINT: 2, // data defined at each point, but that does not specify the point location - POINT_FIELD_DATA: 2, // to match VTK + POINT: 2, // data defined at each point, but that does not specify the point location + POINT_FIELD_DATA: 2, // to match VTK - CELL: 3, // data defined at each cell, but that does not specify the cell - CELL_FIELD_DATA: 3, // to match VTK + CELL: 3, // data defined at each cell, but that does not specify the cell + CELL_FIELD_DATA: 3, // to match VTK - VERTEX: 4, // data defined at each graph vertex, but that does not specify the graph vertex - VERTEX_FIELD_DATA: 4, // to match VTK + VERTEX: 4, // data defined at each graph vertex, but that does not specify the graph vertex + VERTEX_FIELD_DATA: 4, // to match VTK - EDGE: 5, // data defined at each graph edge, but that does not specify the graph edge - EDGE_FIELD_DATA: 5, // to match VTK + EDGE: 5, // data defined at each graph edge, but that does not specify the graph edge + EDGE_FIELD_DATA: 5, // to match VTK - ROW: 6, // data specifying a table row - ROW_DATA: 6, // to match VTK + ROW: 6, // data specifying a table row + ROW_DATA: 6, // to match VTK }; export const FieldAssociations = { diff --git a/Sources/Common/DataModel/DataSet/index.js b/Sources/Common/DataModel/DataSet/index.js index dab6fd7d952..863d04c5cfa 100644 --- a/Sources/Common/DataModel/DataSet/index.js +++ b/Sources/Common/DataModel/DataSet/index.js @@ -1,7 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; -import vtk from 'vtk.js/Sources/vtk'; +import macro from 'vtk.js/Sources/macro'; +import vtk from 'vtk.js/Sources/vtk'; import vtkDataSetAttributes from 'vtk.js/Sources/Common/DataModel/DataSetAttributes'; -import Constants from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; +import Constants from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; // import vtkBoundingBox from '../BoundingBox'; // import vtkMath from '../../Core/Math'; diff --git a/Sources/Common/DataModel/DataSetAttributes/Constants.js b/Sources/Common/DataModel/DataSetAttributes/Constants.js index ee0a16bbbfc..88d98e122d3 100644 --- a/Sources/Common/DataModel/DataSetAttributes/Constants.js +++ b/Sources/Common/DataModel/DataSetAttributes/Constants.js @@ -17,24 +17,24 @@ export const AttributeLimitTypes = { }; export const CellGhostTypes = { - DUPLICATECELL: 1, // the cell is present on multiple processors + DUPLICATECELL: 1, // the cell is present on multiple processors HIGHCONNECTIVITYCELL: 2, // the cell has more neighbors than in a regular mesh - LOWCONNECTIVITYCELL: 4, // the cell has less neighbors than in a regular mesh - REFINEDCELL: 8, // other cells are present that refines it. - EXTERIORCELL: 16, // the cell is on the exterior of the data set - HIDDENCELL: 32, // the cell is needed to maintain connectivity, but the data values should be ignored. + LOWCONNECTIVITYCELL: 4, // the cell has less neighbors than in a regular mesh + REFINEDCELL: 8, // other cells are present that refines it. + EXTERIORCELL: 16, // the cell is on the exterior of the data set + HIDDENCELL: 32, // the cell is needed to maintain connectivity, but the data values should be ignored. }; export const PointGhostTypes = { DUPLICATEPOINT: 1, // the cell is present on multiple processors - HIDDENPOINT: 2, // the point is needed to maintain connectivity, but the data values should be ignored. + HIDDENPOINT: 2, // the point is needed to maintain connectivity, but the data values should be ignored. }; export const AttributeCopyOperations = { COPYTUPLE: 0, INTERPOLATE: 1, PASSDATA: 2, - ALLCOPY: 3, //all of the above + ALLCOPY: 3, //all of the above }; export const ghostArrayName = 'vtkGhostType'; diff --git a/Sources/Common/DataModel/DataSetAttributes/FieldData.js b/Sources/Common/DataModel/DataSetAttributes/FieldData.js index 943c66724d6..56f04cd1c6c 100644 --- a/Sources/Common/DataModel/DataSetAttributes/FieldData.js +++ b/Sources/Common/DataModel/DataSetAttributes/FieldData.js @@ -1,4 +1,4 @@ -import vtk from 'vtk.js/Sources/vtk'; +import vtk from 'vtk.js/Sources/vtk'; import macro from 'vtk.js/Sources/macro'; // ---------------------------------------------------------------------------- @@ -11,7 +11,7 @@ function vtkFieldData(publicAPI, model) { // Decode serialized data if any if (model.arrays) { - model.arrays = model.arrays.map(item => ({ data: vtk(item.data) })); + model.arrays = model.arrays.map((item) => ({ data: vtk(item.data) })); } publicAPI.initialize = () => { @@ -28,47 +28,74 @@ function vtkFieldData(publicAPI, model) { publicAPI.copyStructure = (other) => { publicAPI.initializeFields(); - model.copyFieldFlags = other.getCopyFieldFlags().map(x => x); // Deep-copy - model.arrays = other.arrays().map(x => ({ array: x })); // Deep-copy + model.copyFieldFlags = other.getCopyFieldFlags().map((x) => x); // Deep-copy + model.arrays = other.arrays().map((x) => ({ array: x })); // Deep-copy // TODO: Copy array information objects (once we support information objects) }; publicAPI.getNumberOfArrays = () => model.arrays.length; publicAPI.getNumberOfActiveArrays = () => model.arrays.length; - publicAPI.addArray = (arr) => { model.arrays = [].concat(model.arrays, { data: arr }); return model.arrays.length - 1; }; - publicAPI.removeAllArrays = () => { (model.arrays = []); }; + publicAPI.addArray = (arr) => { + model.arrays = [].concat(model.arrays, { data: arr }); + return model.arrays.length - 1; + }; + publicAPI.removeAllArrays = () => { + model.arrays = []; + }; publicAPI.removeArray = (arrayName) => { - model.arrays = model.arrays.filter(entry => arrayName !== entry.data.getName()); + model.arrays = model.arrays.filter( + (entry) => arrayName !== entry.data.getName() + ); }; publicAPI.removeArrayByIndex = (arrayIdx) => { model.arrays = model.arrays.filter((entry, idx) => idx !== arrayIdx); }; - publicAPI.getArrays = () => model.arrays.map(entry => entry.data); - publicAPI.getArray = arraySpec => - (typeof arraySpec === 'number' ? - publicAPI.getArrayByIndex(arraySpec) : - publicAPI.getArrayByName(arraySpec)); - publicAPI.getArrayByName = arrayName => model.arrays.reduce((a, b, i) => (b.data.getName() === arrayName ? b.data : a), null); - publicAPI.getArrayWithIndex = arrayName => model.arrays.reduce( - (a, b, i) => (b.data && b.data.getName() === arrayName ? { array: b.data, index: i } : a), { array: null, index: -1 }); - publicAPI.getArrayByIndex = idx => (idx >= 0 && idx < model.arrays.length ? model.arrays[idx].data : null); - publicAPI.hasArray = arrayName => publicAPI.getArrayWithIndex(arrayName).index >= 0; + publicAPI.getArrays = () => model.arrays.map((entry) => entry.data); + publicAPI.getArray = (arraySpec) => + typeof arraySpec === 'number' + ? publicAPI.getArrayByIndex(arraySpec) + : publicAPI.getArrayByName(arraySpec); + publicAPI.getArrayByName = (arrayName) => + model.arrays.reduce( + (a, b, i) => (b.data.getName() === arrayName ? b.data : a), + null + ); + publicAPI.getArrayWithIndex = (arrayName) => + model.arrays.reduce( + (a, b, i) => + b.data && b.data.getName() === arrayName + ? { array: b.data, index: i } + : a, + { array: null, index: -1 } + ); + publicAPI.getArrayByIndex = (idx) => + idx >= 0 && idx < model.arrays.length ? model.arrays[idx].data : null; + publicAPI.hasArray = (arrayName) => + publicAPI.getArrayWithIndex(arrayName).index >= 0; publicAPI.getArrayName = (idx) => { const arr = model.arrays[idx]; return arr ? arr.data.getName() : ''; }; publicAPI.getCopyFieldFlags = () => model.copyFieldFlags; - publicAPI.getFlag = arrayName => model.copyFieldFlags[arrayName]; + publicAPI.getFlag = (arrayName) => model.copyFieldFlags[arrayName]; publicAPI.passData = (other) => { other.getArrays().forEach((arr, idx) => { const copyFlag = publicAPI.getFlag(arr.getName()); - if (copyFlag !== false && !(model.doCopyAllOff && copyFlag !== true) && arr) { + if ( + copyFlag !== false && + !(model.doCopyAllOff && copyFlag !== true) && + arr + ) { publicAPI.addArray(arr); } }); }; - publicAPI.copyFieldOn = (arrayName) => { model.copyFieldFlags[arrayName] = true; }; - publicAPI.copyFieldOff = (arrayName) => { model.copyFieldFlags[arrayName] = false; }; + publicAPI.copyFieldOn = (arrayName) => { + model.copyFieldFlags[arrayName] = true; + }; + publicAPI.copyFieldOff = (arrayName) => { + model.copyFieldFlags[arrayName] = false; + }; publicAPI.copyAllOn = () => { if (!model.doCopyAllOn || model.doCopyAllOff) { model.doCopyAllOn = true; @@ -93,19 +120,27 @@ function vtkFieldData(publicAPI, model) { return { data: arrNew }; }); }; - publicAPI.copyFlags = other => other.getCopyFieldFlags().map(x => x); + publicAPI.copyFlags = (other) => other.getCopyFieldFlags().map((x) => x); // TODO: publicAPI.squeeze = () => model.arrays.forEach(entry => entry.data.squeeze()); - publicAPI.reset = () => model.arrays.forEach(entry => entry.data.reset()); + publicAPI.reset = () => model.arrays.forEach((entry) => entry.data.reset()); // TODO: getActualMemorySize - publicAPI.getMTime = () => model.arrays.reduce((a, b) => (b.data.getMTime() > a ? b.data.getMTime() : a), model.mtime); + publicAPI.getMTime = () => + model.arrays.reduce( + (a, b) => (b.data.getMTime() > a ? b.data.getMTime() : a), + model.mtime + ); // TODO: publicAPI.getField = (ids, other) => { copy ids from other into this model's arrays } // TODO: publicAPI.getArrayContainingComponent = (component) => ... - publicAPI.getNumberOfComponents = () => model.arrays.reduce((a, b) => a + b.data.getNumberOfComponents(), 0); - publicAPI.getNumberOfTuples = () => (model.arrays.length > 0 ? model.arrays[0].getNumberOfTuples() : 0); + publicAPI.getNumberOfComponents = () => + model.arrays.reduce((a, b) => a + b.data.getNumberOfComponents(), 0); + publicAPI.getNumberOfTuples = () => + model.arrays.length > 0 ? model.arrays[0].getNumberOfTuples() : 0; publicAPI.getState = () => { const result = superGetState(); - result.arrays = model.arrays.map(item => ({ data: item.data.getState() })); + result.arrays = model.arrays.map((item) => ({ + data: item.data.getState(), + })); return result; }; } @@ -117,7 +152,6 @@ const DEFAULT_VALUES = { doCopyAllOff: false, }; - export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); diff --git a/Sources/Common/DataModel/DataSetAttributes/index.js b/Sources/Common/DataModel/DataSetAttributes/index.js index a986edd2517..bfe0a4fdfee 100644 --- a/Sources/Common/DataModel/DataSetAttributes/index.js +++ b/Sources/Common/DataModel/DataSetAttributes/index.js @@ -1,6 +1,6 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkFieldData from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/FieldData'; -import Constants from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; +import Constants from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; const { AttributeTypes, AttributeCopyOperations } = Constants; @@ -11,17 +11,26 @@ const { vtkWarningMacro } = macro; // ---------------------------------------------------------------------------- function vtkDataSetAttributes(publicAPI, model) { - const attrTypes = ['Scalars', 'Vectors', 'Normals', - 'TCoords', 'Tensors', 'GlobalIds', 'PedigreeIds']; + const attrTypes = [ + 'Scalars', + 'Vectors', + 'Normals', + 'TCoords', + 'Tensors', + 'GlobalIds', + 'PedigreeIds', + ]; function cleanAttributeType(attType) { // Given an integer or string, convert the result to one of the // strings in the "attrTypes" array above or null (if // no match is found) let cleanAttType = attrTypes.find( - ee => ( + (ee) => AttributeTypes[ee.toUpperCase()] === attType || - (typeof attType !== 'number' && ee.toLowerCase() === attType.toLowerCase()))); + (typeof attType !== 'number' && + ee.toLowerCase() === attType.toLowerCase()) + ); if (typeof cleanAttType === 'undefined') { cleanAttType = null; } @@ -31,20 +40,28 @@ function vtkDataSetAttributes(publicAPI, model) { // Set our className model.classHierarchy.push('vtkDataSetAttributes'); - publicAPI.checkNumberOfComponents = x => true; // TODO + publicAPI.checkNumberOfComponents = (x) => true; // TODO publicAPI.setAttribute = (arr, uncleanAttType) => { const attType = cleanAttributeType(uncleanAttType); - if (arr && attType.toUpperCase() === 'PEDIGREEIDS' && !arr.isA('vtkDataArray')) { - vtkWarningMacro(`Cannot set attribute ${attType}. The attribute must be a vtkDataArray.`); + if ( + arr && + attType.toUpperCase() === 'PEDIGREEIDS' && + !arr.isA('vtkDataArray') + ) { + vtkWarningMacro( + `Cannot set attribute ${attType}. The attribute must be a vtkDataArray.` + ); return -1; } if (arr && !publicAPI.checkNumberOfComponents(arr, attType)) { - vtkWarningMacro(`Cannot set attribute ${attType}. Incorrect number of components.`); + vtkWarningMacro( + `Cannot set attribute ${attType}. Incorrect number of components.` + ); return -1; } let currentAttribute = model[`active${attType}`]; - if ((currentAttribute >= 0) && (currentAttribute < model.arrays.length)) { + if (currentAttribute >= 0 && currentAttribute < model.arrays.length) { if (model.arrays[currentAttribute] === arr) { return currentAttribute; } @@ -63,7 +80,9 @@ function vtkDataSetAttributes(publicAPI, model) { publicAPI.setActiveAttributeByName = (arrayName, attType) => publicAPI.setActiveAttributeByIndex( - publicAPI.getArrayWithIndex(arrayName).index, attType); + publicAPI.getArrayWithIndex(arrayName).index, + attType + ); publicAPI.setActiveAttributeByIndex = (arrayIdx, uncleanAttType) => { const attType = cleanAttributeType(uncleanAttType); @@ -71,11 +90,15 @@ function vtkDataSetAttributes(publicAPI, model) { if (attType.toUpperCase() !== 'PEDIGREEIDS') { const arr = publicAPI.getArrayByIndex(arrayIdx); if (!arr.isA('vtkDataArray')) { - vtkWarningMacro(`Cannot set attribute ${attType}. Only vtkDataArray subclasses can be set as active attributes.`); + vtkWarningMacro( + `Cannot set attribute ${attType}. Only vtkDataArray subclasses can be set as active attributes.` + ); return -1; } if (!publicAPI.checkNumberOfComponents(arr, attType)) { - vtkWarningMacro(`Cannot set attribute ${attType}. Incorrect number of components.`); + vtkWarningMacro( + `Cannot set attribute ${attType}. Incorrect number of components.` + ); return -1; } } @@ -132,32 +155,50 @@ function vtkDataSetAttributes(publicAPI, model) { attrTypes.forEach((value) => { const activeVal = `active${value}`; - publicAPI[`get${value}`] = () => publicAPI.getArrayByIndex(model[activeVal]); - publicAPI[`set${value}`] = da => publicAPI.setAttribute(da, value); - publicAPI[`setActive${value}`] = - arrayName => publicAPI.setActiveAttributeByIndex( - publicAPI.getArrayWithIndex(arrayName).index, value); + publicAPI[`get${value}`] = () => + publicAPI.getArrayByIndex(model[activeVal]); + publicAPI[`set${value}`] = (da) => publicAPI.setAttribute(da, value); + publicAPI[`setActive${value}`] = (arrayName) => + publicAPI.setActiveAttributeByIndex( + publicAPI.getArrayWithIndex(arrayName).index, + value + ); }); publicAPI.initialize = macro.chain(publicAPI.initialize, () => { // Default to copying all attributes in every circumstance: model.copyAttributeFlags = []; Object.keys(AttributeCopyOperations) - .filter(op => op !== 'ALLCOPY').forEach((attCopyOp) => { - model.copyAttributeFlags[AttributeCopyOperations[attCopyOp]] = - Object.keys(AttributeTypes).filter(ty => ty !== 'NUM_ATTRIBUTES').reduce( - (a, b) => { a[AttributeTypes[b]] = true; return a; }, []); + .filter((op) => op !== 'ALLCOPY') + .forEach((attCopyOp) => { + model.copyAttributeFlags[ + AttributeCopyOperations[attCopyOp] + ] = Object.keys(AttributeTypes) + .filter((ty) => ty !== 'NUM_ATTRIBUTES') + .reduce((a, b) => { + a[AttributeTypes[b]] = true; + return a; + }, []); }); // Override some operations where we don't want to copy: - model.copyAttributeFlags[AttributeCopyOperations.COPYTUPLE][AttributeTypes.GLOBALIDS] = false; - model.copyAttributeFlags[AttributeCopyOperations.INTERPOLATE][AttributeTypes.GLOBALIDS] = false; - model.copyAttributeFlags[AttributeCopyOperations.COPYTUPLE][AttributeTypes.PEDIGREEIDS] = false; + model.copyAttributeFlags[AttributeCopyOperations.COPYTUPLE][ + AttributeTypes.GLOBALIDS + ] = false; + model.copyAttributeFlags[AttributeCopyOperations.INTERPOLATE][ + AttributeTypes.GLOBALIDS + ] = false; + model.copyAttributeFlags[AttributeCopyOperations.COPYTUPLE][ + AttributeTypes.PEDIGREEIDS + ] = false; }); // Process dataArrays if any if (model.dataArrays && Object.keys(model.dataArrays).length) { Object.keys(model.dataArrays).forEach((name) => { - if (!model.dataArrays[name].ref && model.dataArrays[name].type === 'vtkDataArray') { + if ( + !model.dataArrays[name].ref && + model.dataArrays[name].type === 'vtkDataArray' + ) { publicAPI.addArray(vtkDataArray.newInstance(model.dataArrays[name])); } }); diff --git a/Sources/Common/DataModel/DataSetAttributes/test/testDataSetAttributes.js b/Sources/Common/DataModel/DataSetAttributes/test/testDataSetAttributes.js index 12f5314df6e..f78f23922d6 100644 --- a/Sources/Common/DataModel/DataSetAttributes/test/testDataSetAttributes.js +++ b/Sources/Common/DataModel/DataSetAttributes/test/testDataSetAttributes.js @@ -1,27 +1,62 @@ import test from 'tape-catch'; import vtkDataSetAttributes from 'vtk.js/Sources/Common/DataModel/DataSetAttributes'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -const attrTypes = ['Scalars', 'Vectors', 'Normals', - 'TCoords', 'Tensors', 'GlobalIds', 'PedigreeIds']; +const attrTypes = [ + 'Scalars', + 'Vectors', + 'Normals', + 'TCoords', + 'Tensors', + 'GlobalIds', + 'PedigreeIds', +]; test('Test vtkDataSetAttributes instance', (t) => { t.ok(vtkDataSetAttributes, 'Make sure the class definition exists'); const instance = vtkDataSetAttributes.newInstance(); t.ok(instance, 'Make sure the newInstance method exists.'); - t.equal(instance.getNumberOfArrays(), 0, 'Default number of arrays should be 0'); + t.equal( + instance.getNumberOfArrays(), + 0, + 'Default number of arrays should be 0' + ); // Test that all the default active attributes are null (with -1 index) const ntuples = 10; let numArrs = 0; attrTypes.forEach((attType) => { - t.equal(instance[`get${attType}`](), null, `Default ${attType} should be null`); - const testArray = vtkDataArray.newInstance({ name: `Foo${attType}`, numberOfComponents: 1, values: new Float32Array(ntuples) }); - t.equal(instance.addArray(testArray), numArrs, `Adding ${attType.toLowerCase()} empty DSA should return index of ${numArrs}`); - t.equal(instance[`setActive${attType}`](`Foo${attType}`), numArrs, `Setting ${attType.toLowerCase()} should return ${numArrs} (the index of the array).`); - t.equal(instance[`setActive${attType}`]('xxx'), -1, `Setting ${attType.toLowerCase()} with an invalid name should return -1.`); - t.equal(instance[`get${attType}`](), null, `Setting ${attType.toLowerCase()} with an invalid name should reset the attribute.`); + t.equal( + instance[`get${attType}`](), + null, + `Default ${attType} should be null` + ); + const testArray = vtkDataArray.newInstance({ + name: `Foo${attType}`, + numberOfComponents: 1, + values: new Float32Array(ntuples), + }); + t.equal( + instance.addArray(testArray), + numArrs, + `Adding ${attType.toLowerCase()} empty DSA should return index of ${numArrs}` + ); + t.equal( + instance[`setActive${attType}`](`Foo${attType}`), + numArrs, + `Setting ${attType.toLowerCase()} should return ${numArrs} (the index of the array).` + ); + t.equal( + instance[`setActive${attType}`]('xxx'), + -1, + `Setting ${attType.toLowerCase()} with an invalid name should return -1.` + ); + t.equal( + instance[`get${attType}`](), + null, + `Setting ${attType.toLowerCase()} with an invalid name should reset the attribute.` + ); ++numArrs; }); diff --git a/Sources/Common/DataModel/ImageData/index.js b/Sources/Common/DataModel/ImageData/index.js index b51808c20b3..a6cb8722585 100644 --- a/Sources/Common/DataModel/ImageData/index.js +++ b/Sources/Common/DataModel/ImageData/index.js @@ -1,6 +1,6 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkDataSet from 'vtk.js/Sources/Common/DataModel/DataSet'; -import vtkStructuredData from 'vtk.js/Sources/Common/DataModel/StructuredData'; +import macro from 'vtk.js/Sources/macro'; +import vtkDataSet from 'vtk.js/Sources/Common/DataModel/DataSet'; +import vtkStructuredData from 'vtk.js/Sources/Common/DataModel/StructuredData'; import { StructuredType } from 'vtk.js/Sources/Common/DataModel/StructuredData/Constants'; import { quat, vec3, mat3, mat4 } from 'gl-matrix'; @@ -36,7 +36,9 @@ function vtkImageData(publicAPI, model) { if (changeDetected) { model.extent = [].concat(inExtent); - model.dataDescription = vtkStructuredData.getDataDescriptionFromExtent(model.extent); + model.dataDescription = vtkStructuredData.getDataDescriptionFromExtent( + model.extent + ); publicAPI.modified(); } }; @@ -69,9 +71,9 @@ function vtkImageData(publicAPI, model) { }; publicAPI.getDimensions = () => [ - (model.extent[1] - model.extent[0]) + 1, - (model.extent[3] - model.extent[2]) + 1, - (model.extent[5] - model.extent[4]) + 1, + model.extent[1] - model.extent[0] + 1, + model.extent[3] - model.extent[2] + 1, + model.extent[5] - model.extent[4] + 1, ]; publicAPI.getNumberOfCells = () => { @@ -83,7 +85,7 @@ function vtkImageData(publicAPI, model) { return 0; } if (dims[i] > 1) { - nCells *= (dims[i] - 1); + nCells *= dims[i] - 1; } } @@ -186,6 +188,7 @@ function vtkImageData(publicAPI, model) { publicAPI.getBounds = () => publicAPI.extentToBounds(model.extent); publicAPI.extentToBounds = (ex) => { + // prettier-ignore const corners = [ ex[0], ex[2], ex[4], ex[1], ex[2], ex[4], @@ -203,12 +206,24 @@ function vtkImageData(publicAPI, model) { for (let i = 3; i < 24; i += 3) { vec3.set(idx, corners[i], corners[i + 1], corners[i + 2]); publicAPI.indexToWorldVec3(idx, vout); - if (vout[0] < bounds[0]) { bounds[0] = vout[0]; } - if (vout[1] < bounds[2]) { bounds[2] = vout[1]; } - if (vout[2] < bounds[4]) { bounds[4] = vout[2]; } - if (vout[0] > bounds[1]) { bounds[1] = vout[0]; } - if (vout[1] > bounds[3]) { bounds[3] = vout[1]; } - if (vout[2] > bounds[5]) { bounds[5] = vout[2]; } + if (vout[0] < bounds[0]) { + bounds[0] = vout[0]; + } + if (vout[1] < bounds[2]) { + bounds[2] = vout[1]; + } + if (vout[2] < bounds[4]) { + bounds[4] = vout[2]; + } + if (vout[0] > bounds[1]) { + bounds[1] = vout[0]; + } + if (vout[1] > bounds[3]) { + bounds[3] = vout[1]; + } + if (vout[2] > bounds[5]) { + bounds[5] = vout[2]; + } } return bounds; @@ -218,9 +233,15 @@ function vtkImageData(publicAPI, model) { const rotq = quat.create(); quat.fromMat3(rotq, model.direction); const trans = vec3.fromValues( - model.origin[0], model.origin[1], model.origin[2]); + model.origin[0], + model.origin[1], + model.origin[2] + ); const scale = vec3.fromValues( - model.spacing[0], model.spacing[1], model.spacing[2]); + model.spacing[0], + model.spacing[1], + model.spacing[2] + ); mat4.fromRotationTranslationScale(model.indexToWorld, rotq, trans, scale); mat4.invert(model.worldToIndex, model.indexToWorld); }; @@ -302,7 +323,7 @@ function vtkImageData(publicAPI, model) { // ---------------------------------------------------------------------------- const DEFAULT_VALUES = { - direction: null, // a mat3 + direction: null, // a mat3 indexToWorld: null, // a mat4 worldToIndex: null, // a mat4 spacing: [1.0, 1.0, 1.0], @@ -333,11 +354,7 @@ export function extend(publicAPI, model, initialValues = {}) { model.worldToIndex = mat4.create(); // Set/Get methods - macro.get(publicAPI, model, [ - 'direction', - 'indexToWorld', - 'worldToIndex', - ]); + macro.get(publicAPI, model, ['direction', 'indexToWorld', 'worldToIndex']); macro.setGetArray(publicAPI, model, ['origin', 'spacing'], 3); macro.getArray(publicAPI, model, ['extent'], 6); diff --git a/Sources/Common/DataModel/ImplicitBoolean/example/index.js b/Sources/Common/DataModel/ImplicitBoolean/example/index.js index 7e1308fb496..fb13370147e 100644 --- a/Sources/Common/DataModel/ImplicitBoolean/example/index.js +++ b/Sources/Common/DataModel/ImplicitBoolean/example/index.js @@ -1,13 +1,13 @@ import 'vtk.js/Sources/favicon'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkImageMarchingCubes from 'vtk.js/Sources/Filters/General/ImageMarchingCubes'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkSampleFunction from 'vtk.js/Sources/Imaging/Hybrid/SampleFunction'; -import vtkPlane from 'vtk.js/Sources/Common/DataModel/Plane'; -import vtkCylinder from 'vtk.js/Sources/Common/DataModel/Cylinder'; -import vtkImplicitBoolean from 'vtk.js/Sources/Common/DataModel/ImplicitBoolean'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkImageMarchingCubes from 'vtk.js/Sources/Filters/General/ImageMarchingCubes'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkSampleFunction from 'vtk.js/Sources/Imaging/Hybrid/SampleFunction'; +import vtkPlane from 'vtk.js/Sources/Common/DataModel/Plane'; +import vtkCylinder from 'vtk.js/Sources/Common/DataModel/Cylinder'; +import vtkImplicitBoolean from 'vtk.js/Sources/Common/DataModel/ImplicitBoolean'; import controlPanel from './controller.html'; @@ -33,13 +33,26 @@ actor.setMapper(mapper); // Build pipeline. Boolean together some implicit functions and then sample, isosurface them const pLeft = vtkPlane.newInstance({ normal: [-1, 0, 0], origin: [-5, 0, 0] }); const pRight = vtkPlane.newInstance({ normal: [1, 0, 0], origin: [5, 0, 0] }); -const cyl = vtkCylinder.newInstance({ radius: 0.5, center: [0, 0, 0], axis: [1, 0, 0] }); -const lCylCut = vtkImplicitBoolean.newInstance({ operation: Operation.INTERSECTION, functions: [cyl, pLeft] }); -const rCylCut = vtkImplicitBoolean.newInstance({ operation: Operation.INTERSECTION }); +const cyl = vtkCylinder.newInstance({ + radius: 0.5, + center: [0, 0, 0], + axis: [1, 0, 0], +}); +const lCylCut = vtkImplicitBoolean.newInstance({ + operation: Operation.INTERSECTION, + functions: [cyl, pLeft], +}); +const rCylCut = vtkImplicitBoolean.newInstance({ + operation: Operation.INTERSECTION, +}); rCylCut.addFunction(lCylCut); rCylCut.addFunction(pRight); -const sample = vtkSampleFunction.newInstance({ implicitFunction: rCylCut, sampleDimensions: [50, 50, 50], modelBounds: [-7.5, 7.5, -1, 1, -1, 1] }); +const sample = vtkSampleFunction.newInstance({ + implicitFunction: rCylCut, + sampleDimensions: [50, 50, 50], + modelBounds: [-7.5, 7.5, -1, 1, -1, 1], +}); const mCubes = vtkImageMarchingCubes.newInstance({ contourValue: 0.0 }); // Connect the pipeline proper diff --git a/Sources/Common/DataModel/ImplicitBoolean/index.js b/Sources/Common/DataModel/ImplicitBoolean/index.js index 9604f1aaf61..a46c36c5982 100644 --- a/Sources/Common/DataModel/ImplicitBoolean/index.js +++ b/Sources/Common/DataModel/ImplicitBoolean/index.js @@ -34,14 +34,16 @@ function vtkImplicitBoolean(publicAPI, model) { return mTime; }; - publicAPI.getOperationAsString = () => macro.enumToString(Operation, model.operation); + publicAPI.getOperationAsString = () => + macro.enumToString(Operation, model.operation); publicAPI.setOperationToUnion = () => publicAPI.setOperation(0); publicAPI.setOperationToIntersection = () => publicAPI.setOperation(1); publicAPI.setOperationToDifference = () => publicAPI.setOperation(2); publicAPI.getFunctions = () => model.functions; - publicAPI.hasFunction = f => !!model.functions.filter(item => item === f).length; + publicAPI.hasFunction = (f) => + !!model.functions.filter((item) => item === f).length; publicAPI.addFunction = (f) => { if (f && !publicAPI.hasFunction(f)) { model.functions = model.functions.concat(f); @@ -49,7 +51,7 @@ function vtkImplicitBoolean(publicAPI, model) { }; publicAPI.removeFunction = (f) => { - const newFunctionList = model.functions.filter(item => item !== f); + const newFunctionList = model.functions.filter((item) => item !== f); if (model.functions.length !== newFunctionList.length) { model.functions = newFunctionList; } @@ -88,7 +90,7 @@ function vtkImplicitBoolean(publicAPI, model) { value = firstF.evaluateFunction(xyz); for (let i = 1; i < model.functions.length; ++i) { const f = model.functions[i]; - const v = (-1.0) * f.evaluateFunction(xyz); + const v = -1.0 * f.evaluateFunction(xyz); if (v > value) { value = v; } @@ -98,19 +100,20 @@ function vtkImplicitBoolean(publicAPI, model) { }; publicAPI.evaluateGradient = (xyz) => { - const t = (model.axis[0] * (xyz[0] - model.center[0])) + - (model.axis[1] * (xyz[1] - model.center[1])) + - (model.axis[2] * (xyz[2] - model.center[2])); + const t = + model.axis[0] * (xyz[0] - model.center[0]) + + model.axis[1] * (xyz[1] - model.center[1]) + + model.axis[2] * (xyz[2] - model.center[2]); const cp = new Float32Array(3); - cp[0] = model.center[0] + (t * model.axis[0]); - cp[1] = model.center[1] + (t * model.axis[1]); - cp[2] = model.center[2] + (t * model.axis[2]); + cp[0] = model.center[0] + t * model.axis[0]; + cp[1] = model.center[1] + t * model.axis[1]; + cp[2] = model.center[2] + t * model.axis[2]; const retVal = [ - (2.0 * (xyz[0] - cp[0])), - (2.0 * (xyz[1] - cp[1])), - (2.0 * (xyz[2] - cp[2])), + 2.0 * (xyz[0] - cp[0]), + 2.0 * (xyz[1] - cp[1]), + 2.0 * (xyz[2] - cp[2]), ]; return retVal; }; @@ -132,9 +135,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Object methods macro.obj(publicAPI, model); - macro.setGet(publicAPI, model, [ - 'operation', - ]); + macro.setGet(publicAPI, model, ['operation']); vtkImplicitBoolean(publicAPI, model); } diff --git a/Sources/Common/DataModel/Line/index.js b/Sources/Common/DataModel/Line/index.js index a49b8eeb041..aac75804b3a 100644 --- a/Sources/Common/DataModel/Line/index.js +++ b/Sources/Common/DataModel/Line/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import Constants from 'vtk.js/Sources/Common/DataModel/Line/Constants'; import vtkCell from 'vtk.js/Sources/Common/DataModel/Cell'; import vtkMath from 'vtk.js/Sources/Common/Core/Math'; @@ -18,11 +18,12 @@ function distanceToLine(x, p1, p2, closestPoint = null) { p21[2] = p2[2] - p1[2]; // Get parametric location - const num = (p21[0] * (x[0] - p1[0])) + (p21[1] * (x[1] - p1[1])) + (p21[2] * (x[2] - p1[2])); + const num = + p21[0] * (x[0] - p1[0]) + p21[1] * (x[1] - p1[1]) + p21[2] * (x[2] - p1[2]); const denom = vtkMath.dot(p21, p21); // trying to avoid an expensive fabs - let tolerance = 1.e-05 * num; + let tolerance = 1e-5 * num; if (denom !== 0.0) { outObj.t = num / denom; } @@ -39,9 +40,9 @@ function distanceToLine(x, p1, p2, closestPoint = null) { closest = p2; } else { closest = p21; - p21[0] = p1[0] + (outObj.t * p21[0]); - p21[1] = p1[1] + (outObj.t * p21[1]); - p21[2] = p1[2] + (outObj.t * p21[2]); + p21[0] = p1[0] + outObj.t * p21[0]; + p21[1] = p1[1] + outObj.t * p21[1]; + p21[2] = p1[2] + outObj.t * p21[2]; } if (closestPoint) { @@ -107,7 +108,7 @@ function intersection(a1, a2, b1, b2, u, v) { v[0] = c[1]; // Check parametric coordinates for intersection. - if ((u[0] >= 0.0) && (u[0] <= 1.0) && (v[0] >= 0.0) && (v[0] <= 1.0)) { + if (u[0] >= 0.0 && u[0] <= 1.0 && v[0] >= 0.0 && v[0] <= 1.0) { return IntersectionState.YES_INTERSECTION; } @@ -152,10 +153,10 @@ function vtkLine(publicAPI, model) { if (intersect === IntersectionState.YES_INTERSECTION) { // make sure we are within tolerance for (let i = 0; i < 3; i++) { - x[i] = a1[i] + (pcoords[0] * (a2[i] - a1[i])); - projXYZ[i] = p1[i] + (outObj.t * (p2[i] - p1[i])); + x[i] = a1[i] + pcoords[0] * (a2[i] - a1[i]); + projXYZ[i] = p1[i] + outObj.t * (p2[i] - p1[i]); } - if (vtkMath.distance2BetweenPoints(x, projXYZ) <= (tol * tol)) { + if (vtkMath.distance2BetweenPoints(x, projXYZ) <= tol * tol) { outObj.intersect = 1; return outObj; } @@ -167,7 +168,7 @@ function vtkLine(publicAPI, model) { outObj.t = 0.0; outDistance = distanceToLine(p1, a1, a2, x); pcoords[0] = outDistance.t; - if (outDistance.distance <= (tol * tol)) { + if (outDistance.distance <= tol * tol) { outObj.intersect = 1; return outObj; } @@ -177,7 +178,7 @@ function vtkLine(publicAPI, model) { outObj.t = 1.0; outDistance = distanceToLine(p2, a1, a2, x); pcoords[0] = outDistance.t; - if (outDistance.distance <= (tol * tol)) { + if (outDistance.distance <= tol * tol) { outObj.intersect = 1; return outObj; } @@ -187,7 +188,7 @@ function vtkLine(publicAPI, model) { pcoords[0] = 0.0; outDistance = distanceToLine(a1, p1, p2, x); outObj.t = outDistance.t; - if (outDistance.distance <= (tol * tol)) { + if (outDistance.distance <= tol * tol) { outObj.intersect = 1; return outObj; } @@ -197,7 +198,7 @@ function vtkLine(publicAPI, model) { pcoords[1] = 1.0; outDistance = distanceToLine(a2, p1, p2, x); outObj.t = outDistance.t; - if (outDistance.distance <= (tol * tol)) { + if (outDistance.distance <= tol * tol) { outObj.intersect = 1; return outObj; } @@ -206,15 +207,21 @@ function vtkLine(publicAPI, model) { } return outObj; }; - publicAPI.evaluatePosition = (x, closestPoint, subId, pcoords, dist2, weights) => {}; // virtual + publicAPI.evaluatePosition = ( + x, + closestPoint, + subId, + pcoords, + dist2, + weights + ) => {}; // virtual } // ---------------------------------------------------------------------------- // Object factory // ---------------------------------------------------------------------------- -const DEFAULT_VALUES = { -}; +const DEFAULT_VALUES = {}; // ---------------------------------------------------------------------------- diff --git a/Sources/Common/DataModel/Line/test/testLine.js b/Sources/Common/DataModel/Line/test/testLine.js index e04fc8998f8..4ce13e15dfb 100644 --- a/Sources/Common/DataModel/Line/test/testLine.js +++ b/Sources/Common/DataModel/Line/test/testLine.js @@ -1,4 +1,4 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import vtkLine from 'vtk.js/Sources/Common/DataModel/Line'; import vtkPoints from 'vtk.js/Sources/Common/Core/Points'; @@ -141,4 +141,3 @@ test('Test vtkLine intersectWithLine', (t) => { // t and pcoords do not matter t.end(); }); - diff --git a/Sources/Common/DataModel/Molecule/index.js b/Sources/Common/DataModel/Molecule/index.js index 200a311a519..519acc5ce7a 100644 --- a/Sources/Common/DataModel/Molecule/index.js +++ b/Sources/Common/DataModel/Molecule/index.js @@ -2,7 +2,15 @@ import macro from 'vtk.js/Sources/macro'; // ---------------------------------------------------------------------------- -const MOLECULE_FIELDS = ['chemical json', 'name', 'inchi', 'formula', 'atoms', 'bonds', 'properties']; +const MOLECULE_FIELDS = [ + 'chemical json', + 'name', + 'inchi', + 'formula', + 'atoms', + 'bonds', + 'properties', +]; // ---------------------------------------------------------------------------- // vtkMolecule methods diff --git a/Sources/Common/DataModel/PiecewiseFunction/index.js b/Sources/Common/DataModel/PiecewiseFunction/index.js index 41c708d51c4..152dd719688 100644 --- a/Sources/Common/DataModel/PiecewiseFunction/index.js +++ b/Sources/Common/DataModel/PiecewiseFunction/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; const { vtkErrorMacro } = macro; @@ -51,22 +51,23 @@ function vtkPiecewiseFunction(publicAPI, model) { switch (functionType) { case 0: case 1: - functionType = 1; // NonDecreasing + functionType = 1; // NonDecreasing break; default: case 2: - functionType = 3; // Varied + functionType = 3; // Varied break; } - } else { // value < prev_value + } else { + // value < prev_value switch (functionType) { case 0: case 2: - functionType = 2; // NonIncreasing + functionType = 2; // NonIncreasing break; default: case 1: - functionType = 3; // Varied + functionType = 3; // Varied break; } } @@ -105,7 +106,7 @@ function vtkPiecewiseFunction(publicAPI, model) { model.function = []; for (let i = 0; i < size; i++) { model.function[2 * i] = model.nodes[i].x; - model.function[(2 * i) + 1] = model.nodes[i].y; + model.function[2 * i + 1] = model.nodes[i].y; } } return model.function; @@ -133,8 +134,9 @@ function vtkPiecewiseFunction(publicAPI, model) { // a large value if (allZero) { x = Number.MAX_VALUE; - } else if (i > 0) { // A point was found with a non-zero value - // Return the value of the point that precedes this one + } else if (i > 0) { + // A point was found with a non-zero value + // Return the value of the point that precedes this one x = model.nodes[i - 1].x; } else if (model.clamping) { // If this is the first point in the function, return its @@ -317,7 +319,7 @@ function vtkPiecewiseFunction(publicAPI, model) { publicAPI.addSegment = (x1, y1, x2, y2) => { // First, find all points in this range and remove them publicAPI.sortAndUpdateRange(); - for (let i = 0; i < model.nodes.length;) { + for (let i = 0; i < model.nodes.length; ) { if (model.nodes[i].x >= x1 && model.nodes[i].x <= x2) { model.nodes.splice(i, 1); } else { @@ -362,7 +364,7 @@ function vtkPiecewiseFunction(publicAPI, model) { // Remove all points out-of-range publicAPI.sortAndUpdateRange(); - for (let i = 0; i < model.nodes.length;) { + for (let i = 0; i < model.nodes.length; ) { if (model.nodes[i].x >= range[0] && model.nodes[i].x <= range[1]) { model.nodes.splice(i, 1); } else { @@ -429,14 +431,13 @@ function vtkPiecewiseFunction(publicAPI, model) { // it halfway between start and end (usually start and end will // be the same in this case) if (size > 1) { - x = xStart + ((i / (size - 1.0)) * (xEnd - xStart)); + x = xStart + i / (size - 1.0) * (xEnd - xStart); } else { x = 0.5 * (xStart + xEnd); } // Do we need to move to the next node? - while (idx < numNodes && - x > model.nodes[idx].x) { + while (idx < numNodes && x > model.nodes[idx].x) { idx++; // If we are at a valid point index, fill in // the value at this node, and the one before (the @@ -470,10 +471,10 @@ function vtkPiecewiseFunction(publicAPI, model) { if (idx >= numNodes) { table[tidx] = model.clamping ? lastValue : 0.0; } else if (idx === 0) { - // Are we before the first node? If so, duplicate this nodes values + // Are we before the first node? If so, duplicate this nodes values table[tidx] = model.clamping ? model.nodes[0].y : 0.0; } else { - // Otherwise, we are between two nodes - interpolate + // Otherwise, we are between two nodes - interpolate // Our first attempt at a normalized location [0,1] - // we will be modifying this based on midpoint and // sharpness to get the curve shape we want and to have @@ -484,7 +485,7 @@ function vtkPiecewiseFunction(publicAPI, model) { if (s < midpoint) { s = 0.5 * s / midpoint; } else { - s = 0.5 + (0.5 * (s - midpoint) / (1.0 - midpoint)); + s = 0.5 + 0.5 * (s - midpoint) / (1.0 - midpoint); } // override for sharpness > 0.99 @@ -495,7 +496,7 @@ function vtkPiecewiseFunction(publicAPI, model) { table[tidx] = y1; continue; } else { - // Use the second value at or above the midpoint + // Use the second value at or above the midpoint table[tidx] = y2; continue; } @@ -505,7 +506,7 @@ function vtkPiecewiseFunction(publicAPI, model) { // In this case we want piecewise linear if (sharpness < 0.01) { // Simple linear interpolation - table[tidx] = ((1 - s) * y1) + (s * y2); + table[tidx] = (1 - s) * y1 + s * y2; continue; } @@ -517,18 +518,18 @@ function vtkPiecewiseFunction(publicAPI, model) { // First, we will adjust our position based on sharpness in // order to make the curve sharper (closer to piecewise constant) if (s < 0.5) { - s = 0.5 * Math.pow(s * 2, 1.0 + (10 * sharpness)); + s = 0.5 * Math.pow(s * 2, 1.0 + 10 * sharpness); } else if (s > 0.5) { - s = 1.0 - (0.5 * Math.pow((1.0 - s) * 2, 1 + (10 * sharpness))); + s = 1.0 - 0.5 * Math.pow((1.0 - s) * 2, 1 + 10 * sharpness); } // Compute some coefficients we will need for the hermite curve const ss = s * s; const sss = ss * s; - const h1 = (2 * sss) - (3 * ss) + 1; - const h2 = (-2 * sss) + (3 * ss); - const h3 = sss - (2 * ss) + s; + const h1 = 2 * sss - 3 * ss + 1; + const h2 = -2 * sss + 3 * ss; + const h3 = sss - 2 * ss + s; const h4 = sss - ss; // Use one slope for both end points @@ -536,15 +537,15 @@ function vtkPiecewiseFunction(publicAPI, model) { const t = (1.0 - sharpness) * slope; // Compute the value - table[tidx] = (h1 * y1) + (h2 * y2) + (h3 * t) + (h4 * t); + table[tidx] = h1 * y1 + h2 * y2 + h3 * t + h4 * t; // Final error check to make sure we don't go outside // the Y range - const min = (y1 < y2) ? y1 : y2; - const max = (y1 > y2) ? y1 : y2; + const min = y1 < y2 ? y1 : y2; + const max = y1 > y2 ? y1 : y2; - table[tidx] = (table[tidx] < min) ? min : table[tidx]; - table[tidx] = (table[tidx] > max) ? max : table[tidx]; + table[tidx] = table[tidx] < min ? min : table[tidx]; + table[tidx] = table[tidx] > max ? max : table[tidx]; } } }; @@ -573,19 +574,12 @@ export function extend(publicAPI, model, initialValues = {}) { model.nodes = []; // Create get-set macros - macro.setGet(publicAPI, model, [ - 'allowDuplicateScalars', - 'clamping', - ]); + macro.setGet(publicAPI, model, ['allowDuplicateScalars', 'clamping']); - macro.setArray(publicAPI, model, [ - 'range', - ], 2); + macro.setArray(publicAPI, model, ['range'], 2); // Create get macros for array - macro.getArray(publicAPI, model, [ - 'range', - ]); + macro.getArray(publicAPI, model, ['range']); // For more macro methods, see "Sources/macro.js" diff --git a/Sources/Common/DataModel/Plane/index.js b/Sources/Common/DataModel/Plane/index.js index 8f6977e287d..b848aa544af 100644 --- a/Sources/Common/DataModel/Plane/index.js +++ b/Sources/Common/DataModel/Plane/index.js @@ -1,5 +1,5 @@ import vtkMath from 'vtk.js/Sources/Common/Core/Math'; -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; const PLANE_TOLERANCE = 1.0e-6; @@ -8,15 +8,18 @@ const PLANE_TOLERANCE = 1.0e-6; // ---------------------------------------------------------------------------- function evaluate(normal, origin, x) { - return (normal[0] * (x[0] - origin[0])) - + (normal[1] * (x[1] - origin[1])) - + (normal[2] * (x[2] - origin[2])); + return ( + normal[0] * (x[0] - origin[0]) + + normal[1] * (x[1] - origin[1]) + + normal[2] * (x[2] - origin[2]) + ); } function distanceToPlane(x, origin, normal) { - const distance = (normal[0] * (x[0] - origin[0])) - + (normal[1] * (x[1] - origin[1])) - + (normal[2] * (x[2] - origin[2])); + const distance = + normal[0] * (x[0] - origin[0]) + + normal[1] * (x[1] - origin[1]) + + normal[2] * (x[2] - origin[2]); return Math.abs(distance); } @@ -27,9 +30,9 @@ function projectPoint(x, origin, normal, xproj) { const t = vtkMath.dot(normal, xo); - xproj[0] = x[0] - (t * normal[0]); - xproj[1] = x[1] - (t * normal[1]); - xproj[2] = x[2] - (t * normal[2]); + xproj[0] = x[0] - t * normal[0]; + xproj[1] = x[1] - t * normal[1]; + xproj[2] = x[2] - t * normal[2]; } function projectVector(v, normal, vproj) { @@ -40,9 +43,9 @@ function projectVector(v, normal, vproj) { n2 = 1.0; } - vproj[0] = v[0] - ((t * normal[0]) / n2); - vproj[1] = v[1] - ((t * normal[1]) / n2); - vproj[2] = v[2] - ((t * normal[2]) / n2); + vproj[0] = v[0] - t * normal[0] / n2; + vproj[1] = v[1] - t * normal[1] / n2; + vproj[2] = v[2] - t * normal[2] / n2; } function generalizedProjectPoint(x, origin, normal, xproj) { @@ -53,9 +56,9 @@ function generalizedProjectPoint(x, origin, normal, xproj) { const n2 = vtkMath.dot(normal, normal); if (n2 !== 0) { - xproj[0] = x[0] - ((t * normal[0]) / n2); - xproj[1] = x[1] - ((t * normal[1]) / n2); - xproj[2] = x[2] - ((t * normal[2]) / n2); + xproj[0] = x[0] - t * normal[0] / n2; + xproj[1] = x[1] - t * normal[1] / n2; + xproj[2] = x[2] - t * normal[2] / n2; } else { xproj[0] = x[0]; xproj[1] = x[1]; @@ -97,9 +100,9 @@ function intersectWithLine(p1, p2, origin, normal) { // Valid intersection outObj.t = num / den; - outObj.x[0] = p1[0] + (outObj.t * p21[0]); - outObj.x[1] = p1[1] + (outObj.t * p21[1]); - outObj.x[2] = p1[2] + (outObj.t * p21[2]); + outObj.x[0] = p1[0] + outObj.t * p21[0]; + outObj.x[1] = p1[1] + outObj.t * p21[1]; + outObj.x[2] = p1[2] + outObj.t * p21[2]; outObj.intersection = outObj.t >= 0.0 && outObj.t <= 1.0; return outObj; @@ -118,7 +121,6 @@ export const STATIC = { intersectWithLine, }; - // ---------------------------------------------------------------------------- // vtkPlane methods // ---------------------------------------------------------------------------- @@ -127,7 +129,8 @@ export function vtkPlane(publicAPI, model) { // Set our className model.classHierarchy.push('vtkPlane'); - publicAPI.distanceToPlane = x => distanceToPlane(x, model.origin, model.normal); + publicAPI.distanceToPlane = (x) => + distanceToPlane(x, model.origin, model.normal); publicAPI.projectPoint = (x, xproj) => { projectPoint(x, model.origin, model.normal, xproj); @@ -161,22 +164,19 @@ export function vtkPlane(publicAPI, model) { } return ( - (model.normal[0] * (point[0] - model.origin[0])) + - (model.normal[1] * (point[1] - model.origin[1])) + - (model.normal[2] * (point[2] - model.origin[2])) + model.normal[0] * (point[0] - model.origin[0]) + + model.normal[1] * (point[1] - model.origin[1]) + + model.normal[2] * (point[2] - model.origin[2]) ); }; publicAPI.evaluateGradient = (xyz) => { - const retVal = [ - model.normal[0], - model.normal[1], - model.normal[2], - ]; + const retVal = [model.normal[0], model.normal[1], model.normal[2]]; return retVal; }; - publicAPI.intersectWithLine = (p1, p2) => intersectWithLine(p1, p2, model.origin, model.normal); + publicAPI.intersectWithLine = (p1, p2) => + intersectWithLine(p1, p2, model.origin, model.normal); } // ---------------------------------------------------------------------------- @@ -196,10 +196,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Object methods macro.obj(publicAPI, model); - macro.setGetArray(publicAPI, model, [ - 'normal', - 'origin', - ], 3); + macro.setGetArray(publicAPI, model, ['normal', 'origin'], 3); vtkPlane(publicAPI, model); } diff --git a/Sources/Common/DataModel/Plane/test/testPlane.js b/Sources/Common/DataModel/Plane/test/testPlane.js index 61aa3f43647..8e11dd659d4 100644 --- a/Sources/Common/DataModel/Plane/test/testPlane.js +++ b/Sources/Common/DataModel/Plane/test/testPlane.js @@ -1,4 +1,4 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import vtkPlane from 'vtk.js/Sources/Common/DataModel/Plane'; test('Test vtkPlane instance', (t) => { @@ -96,7 +96,6 @@ test('Test vtkPlane Push', (t) => { t.end(); }); - test('Test vtkPlane intersectWithLine', (t) => { const plane = vtkPlane.newInstance(); plane.setOrigin(0.0, 0.0, 0.0); diff --git a/Sources/Common/DataModel/PointSet/index.js b/Sources/Common/DataModel/PointSet/index.js index ac385716616..cf765a8be43 100644 --- a/Sources/Common/DataModel/PointSet/index.js +++ b/Sources/Common/DataModel/PointSet/index.js @@ -1,7 +1,7 @@ -import vtk from 'vtk.js/Sources/vtk'; -import macro from 'vtk.js/Sources/macro'; +import vtk from 'vtk.js/Sources/vtk'; +import macro from 'vtk.js/Sources/macro'; import vtkDataSet from 'vtk.js/Sources/Common/DataModel/DataSet'; -import vtkPoints from 'vtk.js/Sources/Common/Core/Points'; +import vtkPoints from 'vtk.js/Sources/Common/Core/Points'; // ---------------------------------------------------------------------------- // Global methods diff --git a/Sources/Common/DataModel/PolyData/index.js b/Sources/Common/DataModel/PolyData/index.js index 04ca4d5a1d4..ccc9efa1921 100644 --- a/Sources/Common/DataModel/PolyData/index.js +++ b/Sources/Common/DataModel/PolyData/index.js @@ -1,8 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; -import vtk from 'vtk.js/Sources/vtk'; +import macro from 'vtk.js/Sources/macro'; +import vtk from 'vtk.js/Sources/vtk'; import vtkCellArray from 'vtk.js/Sources/Common/Core/CellArray'; -import vtkPointSet from 'vtk.js/Sources/Common/DataModel/PointSet'; - +import vtkPointSet from 'vtk.js/Sources/Common/DataModel/PointSet'; const POLYDATA_FIELDS = ['verts', 'lines', 'polys', 'strips']; @@ -15,13 +14,19 @@ function vtkPolyData(publicAPI, model) { model.classHierarchy.push('vtkPolyData'); function camelize(str) { - return str.replace(/(?:^\w|[A-Z]|\b\w)/g, (letter, index) => - (index === 0 ? letter.toLowerCase() : letter.toUpperCase())).replace(/\s+/g, ''); + return str + .replace( + /(?:^\w|[A-Z]|\b\w)/g, + (letter, index) => + index === 0 ? letter.toLowerCase() : letter.toUpperCase() + ) + .replace(/\s+/g, ''); } // build empty cell arrays and set methods POLYDATA_FIELDS.forEach((type) => { - publicAPI[`getNumberOf${camelize(type)}`] = () => model[type].getNumberOfCells(); + publicAPI[`getNumberOf${camelize(type)}`] = () => + model[type].getNumberOfCells(); if (!model[type]) { model[type] = vtkCellArray.newInstance(); } else { @@ -29,8 +34,11 @@ function vtkPolyData(publicAPI, model) { } }); - publicAPI.getNumberOfCells = () => POLYDATA_FIELDS.reduce( - (num, cellType) => num + model[cellType].getNumberOfCells(), 0); + publicAPI.getNumberOfCells = () => + POLYDATA_FIELDS.reduce( + (num, cellType) => num + model[cellType].getNumberOfCells(), + 0 + ); } // ---------------------------------------------------------------------------- diff --git a/Sources/Common/DataModel/Sphere/index.js b/Sources/Common/DataModel/Sphere/index.js index 9c99e0d3a2c..73a0b76d7b8 100644 --- a/Sources/Common/DataModel/Sphere/index.js +++ b/Sources/Common/DataModel/Sphere/index.js @@ -5,10 +5,12 @@ import macro from 'vtk.js/Sources/macro'; // ---------------------------------------------------------------------------- function evaluate(radius, center, x) { - return (((x[0] - center[0]) * (x[0] - center[0])) + - ((x[1] - center[1]) * (x[1] - center[1])) + - ((x[2] - center[2]) * (x[2] - center[2]))) - - (radius * radius); + return ( + (x[0] - center[0]) * (x[0] - center[0]) + + (x[1] - center[1]) * (x[1] - center[1]) + + (x[2] - center[2]) * (x[2] - center[2]) - + radius * radius + ); } // ---------------------------------------------------------------------------- @@ -19,7 +21,6 @@ export const STATIC = { evaluate, }; - // ---------------------------------------------------------------------------- // vtkSphere methods // ---------------------------------------------------------------------------- @@ -29,19 +30,20 @@ function vtkSphere(publicAPI, model) { model.classHierarchy.push('vtkSphere'); publicAPI.evaluateFunction = (xyz) => { - const retVal = ((xyz[0] - model.center[0]) * (xyz[0] - model.center[0])) + - ((xyz[1] - model.center[1]) * (xyz[1] - model.center[1])) + - ((xyz[2] - model.center[2]) * (xyz[2] - model.center[2])) - - (model.radius * model.radius); + const retVal = + (xyz[0] - model.center[0]) * (xyz[0] - model.center[0]) + + (xyz[1] - model.center[1]) * (xyz[1] - model.center[1]) + + (xyz[2] - model.center[2]) * (xyz[2] - model.center[2]) - + model.radius * model.radius; return retVal; }; publicAPI.evaluateGradient = (xyz) => { const retVal = [ - (2.0 - (xyz[0] - model.center[0])), - (2.0 - (xyz[1] - model.center[1])), - (2.0 - (xyz[2] - model.center[2])), + 2.0 - (xyz[0] - model.center[0]), + 2.0 - (xyz[1] - model.center[1]), + 2.0 - (xyz[2] - model.center[2]), ]; return retVal; }; @@ -63,13 +65,8 @@ export function extend(publicAPI, model, initialValues = {}) { // Object methods macro.obj(publicAPI, model); - macro.setGet(publicAPI, model, [ - 'radius', - ]); - macro.setGetArray(publicAPI, model, [ - 'center', - ], 3); - + macro.setGet(publicAPI, model, ['radius']); + macro.setGetArray(publicAPI, model, ['center'], 3); vtkSphere(publicAPI, model); } diff --git a/Sources/Common/DataModel/StructuredData/index.js b/Sources/Common/DataModel/StructuredData/index.js index ada90b98d6f..2ad7a367d8a 100644 --- a/Sources/Common/DataModel/StructuredData/index.js +++ b/Sources/Common/DataModel/StructuredData/index.js @@ -5,7 +5,7 @@ const { StructuredType } = Constants; export function getDataDescriptionFromExtent(inExt) { let dataDim = 0; for (let i = 0; i < 3; ++i) { - if (inExt[i * 2] < inExt[(i * 2) + 1]) { + if (inExt[i * 2] < inExt[i * 2 + 1]) { dataDim++; } } diff --git a/Sources/Common/DataModel/Triangle/index.js b/Sources/Common/DataModel/Triangle/index.js index 4059e3d3e63..1406a31564f 100644 --- a/Sources/Common/DataModel/Triangle/index.js +++ b/Sources/Common/DataModel/Triangle/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkCell from 'vtk.js/Sources/Common/DataModel/Cell'; import vtkMath from 'vtk.js/Sources/Common/Core/Math'; import vtkLine from 'vtk.js/Sources/Common/DataModel/Line'; @@ -17,14 +17,14 @@ function computeNormalDirection(v1, v2, v3, n) { const by = v1[1] - v2[1]; const bz = v1[2] - v2[2]; - n[0] = (ay * bz) - (az * by); - n[1] = (az * bx) - (ax * bz); - n[2] = (ax * by) - (ay * bx); + n[0] = ay * bz - az * by; + n[1] = az * bx - ax * bz; + n[2] = ax * by - ay * bx; } function computeNormal(v1, v2, v3, n) { computeNormalDirection(v1, v2, v3, n); - const length = Math.sqrt(((n[0] * n[0]) + (n[1] * n[1]) + (n[2] * n[2]))); + const length = Math.sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]); if (length !== 0.0) { n[0] /= length; n[1] /= length; @@ -32,7 +32,6 @@ function computeNormal(v1, v2, v3, n) { } } - // ---------------------------------------------------------------------------- // Static API // ---------------------------------------------------------------------------- @@ -82,7 +81,12 @@ function vtkTriangle(publicAPI, model) { } // Evaluate position - const inside = publicAPI.evaluatePosition(x, closestPoint, pcoords, weights); + const inside = publicAPI.evaluatePosition( + x, + closestPoint, + pcoords, + weights + ); if (inside.evaluation >= 0) { if (inside.dist2 <= tol2) { outObj.intersect = 1; @@ -216,9 +220,14 @@ function vtkTriangle(publicAPI, model) { weights[1] = pcoords[0]; weights[2] = pcoords[1]; - if (weights[0] >= 0.0 && weights[0] <= 1.0 && - weights[1] >= 0.0 && weights[1] <= 1.0 && - weights[2] >= 0.0 && weights[2] <= 1.0) { + if ( + weights[0] >= 0.0 && + weights[0] <= 1.0 && + weights[1] >= 0.0 && + weights[1] <= 1.0 && + weights[2] >= 0.0 && + weights[2] <= 1.0 + ) { // projection distance if (closestPoint) { outObj.dist2 = vtkMath.distance2BetweenPoints(cp, x); @@ -285,13 +294,28 @@ function vtkTriangle(publicAPI, model) { closestPoint[i] = closest[i]; } } else if (weights[0] < 0.0) { - const lineDistance = vtkLine.distanceToLine(x, pt1, pt2, closestPoint); + const lineDistance = vtkLine.distanceToLine( + x, + pt1, + pt2, + closestPoint + ); outObj.dist2 = lineDistance.distance; } else if (weights[1] < 0.0) { - const lineDistance = vtkLine.distanceToLine(x, pt2, pt3, closestPoint); + const lineDistance = vtkLine.distanceToLine( + x, + pt2, + pt3, + closestPoint + ); outObj.dist2 = lineDistance.distance; } else if (weights[2] < 0.0) { - const lineDistance = vtkLine.distanceToLine(x, pt1, pt3, closestPoint); + const lineDistance = vtkLine.distanceToLine( + x, + pt1, + pt3, + closestPoint + ); outObj.dist2 = lineDistance.distance; } } @@ -311,7 +335,7 @@ function vtkTriangle(publicAPI, model) { const u3 = 1.0 - pcoords[0] - pcoords[1]; for (let i = 0; i < 3; i++) { - x[i] = (p0[i] * u3) + (p1[i] * pcoords[0]) + (p2[i] * pcoords[1]); + x[i] = p0[i] * u3 + p1[i] * pcoords[0] + p2[i] * pcoords[1]; } weights[0] = u3; @@ -332,7 +356,8 @@ function vtkTriangle(publicAPI, model) { pDist = -pc[i]; } else if (pc[i] > 1.0) { pDist = pc[i] - 1.0; - } else { // inside the cell in the parametric direction + } else { + // inside the cell in the parametric direction pDist = 0.0; } if (pDist > pDistMax) { @@ -347,8 +372,7 @@ function vtkTriangle(publicAPI, model) { // Object factory // ---------------------------------------------------------------------------- -const DEFAULT_VALUES = { -}; +const DEFAULT_VALUES = {}; // ---------------------------------------------------------------------------- diff --git a/Sources/Common/DataModel/Triangle/test/testTriangle.js b/Sources/Common/DataModel/Triangle/test/testTriangle.js index 37dd27abd5f..e7624c351c8 100644 --- a/Sources/Common/DataModel/Triangle/test/testTriangle.js +++ b/Sources/Common/DataModel/Triangle/test/testTriangle.js @@ -1,4 +1,4 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import vtkPoints from 'vtk.js/Sources/Common/Core/Points'; import vtkTriangle from 'vtk.js/Sources/Common/DataModel/Triangle'; @@ -144,7 +144,11 @@ test('Test vtkTriangle evaluatePosition', (t) => { // subId does not matter t.equal(result.dist2, 0.0); t.deepEqual(pcoords, [Math.sqrt(2) - 1, (2 - Math.sqrt(2)) / 2, 0]); - t.deepEqual(weights, [(2 - Math.sqrt(2)) / 2, Math.sqrt(2) - 1, (2 - Math.sqrt(2)) / 2]); + t.deepEqual(weights, [ + (2 - Math.sqrt(2)) / 2, + Math.sqrt(2) - 1, + (2 - Math.sqrt(2)) / 2, + ]); // Outside x = [0, 2, 0]; diff --git a/Sources/Common/DataModel/index.js b/Sources/Common/DataModel/index.js index 988941219d9..756e215aefa 100644 --- a/Sources/Common/DataModel/index.js +++ b/Sources/Common/DataModel/index.js @@ -1,21 +1,21 @@ -import vtkBoundingBox from './BoundingBox'; -import vtkBox from './Box'; -import vtkCell from './Cell'; -import vtkCone from './Cone'; -import vtkCylinder from './Cylinder'; -import vtkDataSet from './DataSet'; +import vtkBoundingBox from './BoundingBox'; +import vtkBox from './Box'; +import vtkCell from './Cell'; +import vtkCone from './Cone'; +import vtkCylinder from './Cylinder'; +import vtkDataSet from './DataSet'; import vtkDataSetAttributes from './DataSetAttributes'; -import vtkImageData from './ImageData'; -import vtkImplicitBoolean from './ImplicitBoolean'; -import vtkLine from './Line'; -import vtkMolecule from './Molecule'; +import vtkImageData from './ImageData'; +import vtkImplicitBoolean from './ImplicitBoolean'; +import vtkLine from './Line'; +import vtkMolecule from './Molecule'; import vtkPiecewiseFunction from './PiecewiseFunction'; -import vtkPlane from './Plane'; -import vtkPointSet from './PointSet'; -import vtkPolyData from './PolyData'; -import vtkSphere from './Sphere'; -import vtkStructuredData from './StructuredData'; -import vtkTriangle from './Triangle'; +import vtkPlane from './Plane'; +import vtkPointSet from './PointSet'; +import vtkPolyData from './PolyData'; +import vtkSphere from './Sphere'; +import vtkStructuredData from './StructuredData'; +import vtkTriangle from './Triangle'; export default { vtkBoundingBox, diff --git a/Sources/Common/Transform/LandmarkTransform/index.js b/Sources/Common/Transform/LandmarkTransform/index.js index a2d7ee8d091..bc7226f66e4 100644 --- a/Sources/Common/Transform/LandmarkTransform/index.js +++ b/Sources/Common/Transform/LandmarkTransform/index.js @@ -1,7 +1,7 @@ import { mat3, mat4 } from 'gl-matrix'; -import Constants from 'vtk.js/Sources/Common/Transform/LandmarkTransform/Constants'; -import macro from 'vtk.js/Sources/macro'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import Constants from 'vtk.js/Sources/Common/Transform/LandmarkTransform/Constants'; +import macro from 'vtk.js/Sources/macro'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; const { Mode } = Constants; @@ -33,8 +33,12 @@ function vtkLandmarkTransform(publicAPI, model) { function update() { mat4.identity(model.matrix); const N_PTS = model.sourceLandmark.getNumberOfPoints(); - if (model.targetLandmark.getNumberOfPoints() !== N_PTS - || model.sourceLandmark === null || model.targetLandmark === null || N_PTS === 0) { + if ( + model.targetLandmark.getNumberOfPoints() !== N_PTS || + model.sourceLandmark === null || + model.targetLandmark === null || + N_PTS === 0 + ) { console.error('Error : Bad inputs of vtkLandmarkTransform'); return model.matrix; } @@ -101,21 +105,21 @@ function vtkLandmarkTransform(publicAPI, model) { // accumulate the products a*T(b) into the matrix M for (let i = 0; i < 3; i++) { - M[(3 * 0) + i] += a[i] * b[0]; - M[(3 * 1) + i] += a[i] * b[1]; - M[(3 * 2) + i] += a[i] * b[2]; + M[3 * 0 + i] += a[i] * b[0]; + M[3 * 1 + i] += a[i] * b[1]; + M[3 * 2 + i] += a[i] * b[2]; // for the affine transform, compute ((a.a^t)^-1 . a.b^t)^t. // a.b^t is already in M. here we put a.a^t in AAT. if (model.mode === Mode.AFFINE) { - AAT[(3 * 0) + i] += a[i] * a[0]; - AAT[(3 * 1) + i] += a[i] * a[1]; - AAT[(3 * 2) + i] += a[i] * a[2]; + AAT[3 * 0 + i] += a[i] * a[0]; + AAT[3 * 1 + i] += a[i] * a[1]; + AAT[3 * 2 + i] += a[i] * a[2]; } } // accumulate scale factors (if desired) - sa += (a[0] * a[0]) + (a[1] * a[1]) + (a[2] * a[2]); - sb += (b[0] * b[0]) + (b[1] * b[1]) + (b[2] * b[2]); + sa += a[0] * a[0] + a[1] * a[1] + a[2] * a[2]; + sb += b[0] * b[0] + b[1] * b[1] + b[2] * b[2]; } if (model.mode === Mode.AFFINE) { @@ -128,7 +132,7 @@ function vtkLandmarkTransform(publicAPI, model) { // this->Matrix = M^t for (let i = 0; i < 3; ++i) { for (let j = 0; j < 3; ++j) { - model.matrix[(4 * j) + i] = M[(4 * i) + j]; + model.matrix[4 * j + i] = M[4 * i + j]; } } } else { @@ -149,21 +153,23 @@ function vtkLandmarkTransform(publicAPI, model) { N[15] = -M[0] - M[4] + M[8]; // off-diagonal elements /* eslint-disable no-multi-assign */ - N[4] = N[1] = (M[7] - M[5]); - N[8] = N[2] = (M[2] - M[6]); - N[12] = N[3] = (M[3] - M[1]); + N[4] = N[1] = M[7] - M[5]; + N[8] = N[2] = M[2] - M[6]; + N[12] = N[3] = M[3] - M[1]; - N[9] = N[6] = (M[3] + M[1]); - N[13] = N[7] = (M[2] + M[6]); - N[14] = N[11] = (M[7] + M[5]); + N[9] = N[6] = M[3] + M[1]; + N[13] = N[7] = M[2] + M[6]; + N[14] = N[11] = M[7] + M[5]; /* eslint-enable no-multi-assign */ // -- eigen-decompose N (is symmetric) -- - const eigenVectors = [[0.0, 0.0, 0.0, 0.0], - [0.0, 0.0, 0.0, 0.0], - [0.0, 0.0, 0.0, 0.0], - [0.0, 0.0, 0.0, 0.0]]; + const eigenVectors = [ + [0.0, 0.0, 0.0, 0.0], + [0.0, 0.0, 0.0, 0.0], + [0.0, 0.0, 0.0, 0.0], + [0.0, 0.0, 0.0, 0.0], + ]; const eigenValues = [0.0, 0.0, 0.0, 0.0]; const NMatrix = mat4To2DArray(N); @@ -194,9 +200,9 @@ function vtkLandmarkTransform(publicAPI, model) { let rt = 0; for (let i = 0; i < 3; i++) { ds[i] = s1[i] - s0[i]; // vector between points - rs = (ds[i] * ds[i]) + rs; + rs = ds[i] * ds[i] + rs; dt[i] = t1[i] - t0[i]; - rt = (dt[i] * dt[i]) + rt; + rt = dt[i] * dt[i] + rt; } // normalize the two vectors @@ -210,12 +216,12 @@ function vtkLandmarkTransform(publicAPI, model) { dt[2] /= rt; // take dot & cross product - w = (ds[0] * dt[0]) + (ds[1] * dt[1]) + (ds[2] * dt[2]); - x = (ds[1] * dt[2]) - (ds[2] * dt[1]); - y = (ds[2] * dt[0]) - (ds[0] * dt[2]); - z = (ds[0] * dt[1]) - (ds[1] * dt[0]); + w = ds[0] * dt[0] + ds[1] * dt[1] + ds[2] * dt[2]; + x = ds[1] * dt[2] - ds[2] * dt[1]; + y = ds[2] * dt[0] - ds[0] * dt[2]; + z = ds[0] * dt[1] - ds[1] * dt[0]; - let r = Math.sqrt((x * x) + (y * y) + (z * z)); + let r = Math.sqrt(x * x + y * y + z * z); const theta = Math.atan2(r, w); // construct quaternion @@ -225,7 +231,8 @@ function vtkLandmarkTransform(publicAPI, model) { x *= r; y *= r; z *= r; - } else { // rotation by 180 degrees : special case + } else { + // rotation by 180 degrees : special case // Rotate around a vector perpendicular to ds vtkMath.perpendiculars(ds, dt, 0, 0); r = Math.sin(theta / 2); @@ -233,7 +240,8 @@ function vtkLandmarkTransform(publicAPI, model) { y = dt[1] * r; z = dt[2] * r; } - } else { // points are not collinear + } else { + // points are not collinear w = eigenVectors[0][0]; x = eigenVectors[1][0]; y = eigenVectors[2][0]; @@ -270,24 +278,27 @@ function vtkLandmarkTransform(publicAPI, model) { // add in the scale factor (if desired) if (model.mode !== Mode.RIGID_BODY) { for (let i = 0; i < 3; i++) { - model.matrix[(4 * 0) + i] = model.matrix[(4 * 0) + i] * scale; - model.matrix[(4 * 1) + i] = model.matrix[(4 * 1) + i] * scale; - model.matrix[(4 * 2) + i] = model.matrix[(4 * 2) + i] * scale; + model.matrix[4 * 0 + i] = model.matrix[4 * 0 + i] * scale; + model.matrix[4 * 1 + i] = model.matrix[4 * 1 + i] * scale; + model.matrix[4 * 2 + i] = model.matrix[4 * 2 + i] * scale; } } } // the translation is given by the difference in the transformed source // centroid and the target centroid - const sx = (model.matrix[0] * sourceCentroid[0]) + - (model.matrix[4] * sourceCentroid[1]) + - (model.matrix[8] * sourceCentroid[2]); - const sy = (model.matrix[1] * sourceCentroid[0]) + - (model.matrix[5] * sourceCentroid[1]) + - (model.matrix[9] * sourceCentroid[2]); - const sz = (model.matrix[2] * sourceCentroid[0]) + - (model.matrix[6] * sourceCentroid[1]) + - (model.matrix[10] * sourceCentroid[2]); + const sx = + model.matrix[0] * sourceCentroid[0] + + model.matrix[4] * sourceCentroid[1] + + model.matrix[8] * sourceCentroid[2]; + const sy = + model.matrix[1] * sourceCentroid[0] + + model.matrix[5] * sourceCentroid[1] + + model.matrix[9] * sourceCentroid[2]; + const sz = + model.matrix[2] * sourceCentroid[0] + + model.matrix[6] * sourceCentroid[1] + + model.matrix[10] * sourceCentroid[2]; model.matrix[12] = targetCentroid[0] - sx; model.matrix[13] = targetCentroid[1] - sy; diff --git a/Sources/Common/index.js b/Sources/Common/index.js index 94e6e3e37c8..47a74f74244 100644 --- a/Sources/Common/index.js +++ b/Sources/Common/index.js @@ -1,7 +1,7 @@ -import Core from './Core'; -import DataModel from './DataModel'; -import Transform from './Transform'; -import System from './System'; +import Core from './Core'; +import DataModel from './DataModel'; +import Transform from './Transform'; +import System from './System'; export default { Core, diff --git a/Sources/Filters/General/AppendPolyData/Constants.js b/Sources/Filters/General/AppendPolyData/Constants.js index a168404c1e5..c25650cd2dc 100644 --- a/Sources/Filters/General/AppendPolyData/Constants.js +++ b/Sources/Filters/General/AppendPolyData/Constants.js @@ -1,7 +1,7 @@ export const PointPrecision = { DEFAULT: 0, // use the point type that does not truncate any data - SINGLE: 1, // use Float32Array - DOUBLE: 2, // use Float64Array + SINGLE: 1, // use Float32Array + DOUBLE: 2, // use Float64Array }; export default { diff --git a/Sources/Filters/General/AppendPolyData/index.js b/Sources/Filters/General/AppendPolyData/index.js index 24a4b87743e..02bf5bf80b2 100644 --- a/Sources/Filters/General/AppendPolyData/index.js +++ b/Sources/Filters/General/AppendPolyData/index.js @@ -1,10 +1,10 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkPoints from 'vtk.js/Sources/Common/Core/Points'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import macro from 'vtk.js/Sources/macro'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkPoints from 'vtk.js/Sources/Common/Core/Points'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; import { VtkDataTypes } from 'vtk.js/Sources/Common/Core/DataArray/Constants'; -import Constants from 'vtk.js/Sources/Filters/General/AppendPolyData/Constants'; +import Constants from 'vtk.js/Sources/Filters/General/AppendPolyData/Constants'; const { PointPrecision } = Constants; const { vtkErrorMacro } = macro; @@ -32,7 +32,8 @@ function vtkAppendPolyData(publicAPI, model) { // Set our classname model.classHierarchy.push('vtkAppendPolyData'); - publicAPI.requestData = (inData, outData) => { // implement requestData + publicAPI.requestData = (inData, outData) => { + // implement requestData const numberOfInputs = publicAPI.getNumberOfInputPorts(); if (!numberOfInputs) { vtkErrorMacro('No input specified.'); @@ -86,9 +87,9 @@ function vtkAppendPolyData(publicAPI, model) { const ptD = ds.getPointData(); if (ptD) { - hasPtNormals = hasPtNormals && (ptD.getNormals() !== null); - hasPtTCoords = hasPtTCoords && (ptD.getTCoords() !== null); - hasPtScalars = hasPtScalars && (ptD.getScalars() !== null); + hasPtNormals = hasPtNormals && ptD.getNormals() !== null; + hasPtTCoords = hasPtTCoords && ptD.getTCoords() !== null; + hasPtScalars = hasPtScalars && ptD.getScalars() !== null; } else { hasPtNormals = false; hasPtTCoords = false; @@ -123,7 +124,8 @@ function vtkAppendPolyData(publicAPI, model) { numberOfTuples: numPts, size: 3 * numPts, dataType: dsNormals.getDataType(), - name: dsNormals.getName() }); + name: dsNormals.getName(), + }); } if (hasPtTCoords) { const dsTCoords = lds.getPointData().getTCoords(); @@ -132,7 +134,8 @@ function vtkAppendPolyData(publicAPI, model) { numberOfTuples: numPts, size: 2 * numPts, dataType: dsTCoords.getDataType(), - name: dsTCoords.getName() }); + name: dsTCoords.getName(), + }); } if (hasPtScalars) { const dsScalars = lds.getPointData().getScalars(); @@ -141,7 +144,8 @@ function vtkAppendPolyData(publicAPI, model) { numberOfTuples: numPts, size: numPts * dsScalars.getNumberOfComponents(), dataType: dsScalars.getDataType(), - name: dsScalars.getName() }); + name: dsScalars.getName(), + }); } numPts = 0; @@ -172,8 +176,12 @@ function vtkAppendPolyData(publicAPI, model) { } if (hasPtScalars) { const ptScalars = dsPD.getScalars(); - newPtScalars.getData().set(ptScalars.getData(), - numPts * newPtScalars.getNumberOfComponents()); + newPtScalars + .getData() + .set( + ptScalars.getData(), + numPts * newPtScalars.getNumberOfComponents() + ); } numPts += ds.getPoints().getNumberOfPoints(); @@ -210,11 +218,8 @@ const DEFAULT_VALUES = { export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); - // Build VTK API - macro.setGet(publicAPI, model, [ - 'outputPointsPrecision', - ]); + macro.setGet(publicAPI, model, ['outputPointsPrecision']); // Make this a VTK object macro.obj(publicAPI, model); diff --git a/Sources/Filters/General/AppendPolyData/test/testAppendPolyData.js b/Sources/Filters/General/AppendPolyData/test/testAppendPolyData.js index c853974769b..641cb2e114a 100644 --- a/Sources/Filters/General/AppendPolyData/test/testAppendPolyData.js +++ b/Sources/Filters/General/AppendPolyData/test/testAppendPolyData.js @@ -1,21 +1,21 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkAppendPolyData from 'vtk.js/Sources/Filters/General/AppendPolyData'; -import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; -import vtkCylinderSource from 'vtk.js/Sources/Filters/Sources/CylinderSource'; -import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; -import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; +import vtkAppendPolyData from 'vtk.js/Sources/Filters/General/AppendPolyData'; +import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; +import vtkCylinderSource from 'vtk.js/Sources/Filters/Sources/CylinderSource'; +import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; +import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import { VtkDataTypes } from 'vtk.js/Sources/Common/Core/DataArray/Constants'; -import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; -import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; +import { VtkDataTypes } from 'vtk.js/Sources/Common/Core/DataArray/Constants'; +import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; +import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; import baseline from './testAppendPolyData.png'; @@ -31,7 +31,10 @@ test('Test vtkAppendPolyData instance', (t) => { test('Test vtkAppendPolyData execution', (t) => { const cone = vtkConeSource.newInstance({ resolution: 6, capping: true }); - const cylinder = vtkCylinderSource.newInstance({ resolution: 6, capping: true }); + const cylinder = vtkCylinderSource.newInstance({ + resolution: 6, + capping: true, + }); const filter = vtkAppendPolyData.newInstance(); filter.setInputConnection(cone.getOutputPort(), 0); filter.addInputConnection(cylinder.getOutputPort()); @@ -39,16 +42,28 @@ test('Test vtkAppendPolyData execution', (t) => { const outPD = filter.getOutputData(); - t.ok((outPD.getPoints().getNumberOfPoints() === 31), - 'Make sure the number of points is correct.'); - t.ok((outPD.getPoints().getDataType() === VtkDataTypes.FLOAT), - 'Make sure the output data type is correct.'); + t.ok( + outPD.getPoints().getNumberOfPoints() === 31, + 'Make sure the number of points is correct.' + ); + t.ok( + outPD.getPoints().getDataType() === VtkDataTypes.FLOAT, + 'Make sure the output data type is correct.' + ); const expNumPolys = [cone, cylinder].reduce( - (count, c) => count + c.getOutputData().getPolys().getNumberOfCells(), 0, + (count, c) => + count + + c + .getOutputData() + .getPolys() + .getNumberOfCells(), + 0 ); const outNumPolys = outPD.getPolys().getNumberOfCells(); - t.ok((outNumPolys === expNumPolys), - 'Make sure the number of polys is correct.'); + t.ok( + outNumPolys === expNumPolys, + 'Make sure the number of polys is correct.' + ); t.end(); }); @@ -59,7 +74,9 @@ test.onlyIfWebGL('Test vtkAppendPolyData rendering', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -76,17 +93,19 @@ test.onlyIfWebGL('Test vtkAppendPolyData rendering', (t) => { const calc = vtkCalculator.newInstance(); calc.setFormula({ - getArrays: inputDataSets => ({ + getArrays: (inputDataSets) => ({ input: [], output: [ - { location: FieldDataTypes.POINT, + { + location: FieldDataTypes.POINT, name: 'Scalars', dataType: 'Float32Array', - attribute: AttributeTypes.SCALARS }, + attribute: AttributeTypes.SCALARS, + }, ], }), evaluate: (arraysIn, arraysOut) => { - const [scalars] = arraysOut.map(d => d.getData()); + const [scalars] = arraysOut.map((d) => d.getData()); for (let i = 0; i < scalars.length; i++) { scalars[i] = i * 0.01; } @@ -96,7 +115,10 @@ test.onlyIfWebGL('Test vtkAppendPolyData rendering', (t) => { const plane = vtkPlaneSource.newInstance({ xResolution: 5, yResolution: 10 }); calc.setInputConnection(plane.getOutputPort()); const planeData = calc.getOutputData(); - const plane2 = vtkPlaneSource.newInstance({ xResolution: 10, yResolution: 5 }); + const plane2 = vtkPlaneSource.newInstance({ + xResolution: 10, + yResolution: 5, + }); plane2.setOrigin(0.5, 0, -0.5); plane2.setPoint1(0.5, 0, 0.5); plane2.setPoint2(0.5, 1, -0.5); @@ -120,5 +142,12 @@ test.onlyIfWebGL('Test vtkAppendPolyData rendering', (t) => { renderer.resetCamera(); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Filters/General/AppendPolyData/testAppendPolyData', t, 2.5, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Filters/General/AppendPolyData/testAppendPolyData', + t, + 2.5, + gc.releaseResources + ); }); diff --git a/Sources/Filters/General/Calculator/example/index.js b/Sources/Filters/General/Calculator/example/index.js index 870b8190f23..dac5630757c 100644 --- a/Sources/Filters/General/Calculator/example/index.js +++ b/Sources/Filters/General/Calculator/example/index.js @@ -1,17 +1,17 @@ import 'vtk.js/Sources/favicon'; -import macro from 'vtk.js/Sources/macro'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import macro from 'vtk.js/Sources/macro'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; -import vtkDataSet from 'vtk.js/Sources/Common/DataModel/DataSet'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; +import vtkDataSet from 'vtk.js/Sources/Common/DataModel/DataSet'; import vtkLookupTable from 'vtk.js/Sources/Common/Core/LookupTable'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; -import vtkPoints from 'vtk.js/Sources/Common/Core/Points'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; -import vtkWarpScalar from 'vtk.js/Sources/Filters/General/WarpScalar'; +import vtkPoints from 'vtk.js/Sources/Common/Core/Points'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import vtkWarpScalar from 'vtk.js/Sources/Filters/General/WarpScalar'; import controlPanel from './controlPanel.html'; @@ -29,7 +29,9 @@ const FORMULA = [ // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0.9, 0.9, 0.9] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0.9, 0.9, 0.9], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -39,7 +41,10 @@ const renderWindow = fullScreenRenderer.getRenderWindow(); const lookupTable = vtkLookupTable.newInstance({ hueRange: [0.666, 0] }); -const planeSource = vtkPlaneSource.newInstance({ xResolution: 25, yResolution: 25 }); +const planeSource = vtkPlaneSource.newInstance({ + xResolution: 25, + yResolution: 25, +}); const planeMapper = vtkMapper.newInstance({ interpolateScalarsBeforeMapping: true, colorMode: ColorMode.DEFAULT, @@ -53,9 +58,9 @@ planeActor.getProperty().setEdgeVisibility(true); const simpleFilter = vtkCalculator.newInstance(); simpleFilter.setFormulaSimple( FieldDataTypes.POINT, // Generate an output array defined over points. - [], // We don't request any point-data arrays because point coordinates are made available by default. + [], // We don't request any point-data arrays because point coordinates are made available by default. 'z', // Name the output array "z" - x => ((x[0] - 0.5) * (x[0] - 0.5)) + ((x[1] - 0.5) * (x[1] - 0.5)) + 0.125, + (x) => (x[0] - 0.5) * (x[0] - 0.5) + (x[1] - 0.5) * (x[1] - 0.5) + 0.125 ); // Our formula for z const warpScalar = vtkWarpScalar.newInstance(); @@ -117,14 +122,23 @@ function applyFormula() { if (fn) { el.style.background = '#fff'; const formulaObj = simpleFilter.createSimpleFormulaObject( - FieldDataTypes.POINT, [], 'z', fn); + FieldDataTypes.POINT, + [], + 'z', + fn + ); // See if the formula is actually valid by invoking "formulaObj" on // a dataset containing a single point. planeSource.update(); const arraySpec = formulaObj.getArrays(planeSource.getOutputData()); const testData = vtkPolyData.newInstance(); - const testPts = vtkPoints.newInstance({ name: 'coords', numberOfComponents: 3, size: 3, values: [0, 0, 0] }); + const testPts = vtkPoints.newInstance({ + name: 'coords', + numberOfComponents: 3, + size: 3, + values: [0, 0, 0], + }); testData.setPoints(testPts); const testOut = vtkPolyData.newInstance(); testOut.shallowCopy(testData); @@ -139,7 +153,11 @@ function applyFormula() { simpleFilter.update(); // Update UI with new range - const [min, max] = simpleFilter.getOutputData().getPointData().getScalars().getRange(); + const [min, max] = simpleFilter + .getOutputData() + .getPointData() + .getScalars() + .getRange(); document.querySelector('.min').value = min; document.querySelector('.max').value = max; lookupTable.setMappingRange(min, max); @@ -178,7 +196,9 @@ document.querySelector('.visibility').addEventListener('change', (e) => { document.querySelector('.formula').addEventListener('input', applyFormula); ['min', 'max'].forEach((selector) => { - document.querySelector(`.${selector}`).addEventListener('input', updateScalarRange); + document + .querySelector(`.${selector}`) + .addEventListener('input', updateScalarRange); }); document.querySelector('.next').addEventListener('click', (e) => { @@ -188,7 +208,6 @@ document.querySelector('.next').addEventListener('click', (e) => { renderWindow.render(); }); - // Eecompute scalar range applyFormula(); diff --git a/Sources/Filters/General/Calculator/index.js b/Sources/Filters/General/Calculator/index.js index 2a94f86bb77..083c09d4fb4 100644 --- a/Sources/Filters/General/Calculator/index.js +++ b/Sources/Filters/General/Calculator/index.js @@ -1,7 +1,7 @@ -import vtk from 'vtk.js/Sources/vtk'; -import macro from 'vtk.js/Sources/macro'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkPoints from 'vtk.js/Sources/Common/Core/Points'; +import vtk from 'vtk.js/Sources/vtk'; +import macro from 'vtk.js/Sources/macro'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkPoints from 'vtk.js/Sources/Common/Core/Points'; import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; @@ -38,25 +38,41 @@ function vtkCalculator(publicAPI, model) { return arraysOut; }; - publicAPI.createSimpleFormulaObject = (locn, arrNames, resultName, singleValueFormula, options = {}) => ({ + publicAPI.createSimpleFormulaObject = ( + locn, + arrNames, + resultName, + singleValueFormula, + options = {} + ) => ({ getArrays: () => ({ input: publicAPI.augmentInputArrays( - locn, arrNames.map(x => ({ location: locn, name: x }))), - output: [{ - location: locn, - name: resultName, - attribute: ('outputAttributeType' in options ? options.outputAttributeType : AttributeTypes.SCALARS), - numberOfComponents: ('numberOfOutputComponents' in options ? options.numberOfOutputComponents : 1), - }], + locn, + arrNames.map((x) => ({ location: locn, name: x })) + ), + output: [ + { + location: locn, + name: resultName, + attribute: + 'outputAttributeType' in options + ? options.outputAttributeType + : AttributeTypes.SCALARS, + numberOfComponents: + 'numberOfOutputComponents' in options + ? options.numberOfOutputComponents + : 1, + }, + ], }), evaluate: (arraysIn, arraysOut) => { const tuples = new Array(arraysIn.length); const arrayInAccessors = arraysIn.map((x, jj) => { const nc = x.getNumberOfComponents(); const rawData = x.getData(); - return (nc === 1 ? - (ii => rawData[ii]) : - (ii => x.getTuple(ii, tuples[jj]))); + return nc === 1 + ? (ii) => rawData[ii] + : (ii) => x.getTuple(ii, tuples[jj]); }); const arrayOut = arraysOut[0]; const arrayOutRaw = arrayOut.getData(); @@ -64,22 +80,42 @@ function vtkCalculator(publicAPI, model) { let tupleOut = new Array(nc); if (nc === 1) { arrayOutRaw.forEach((xxx, ii) => { - arrayOutRaw[ii] = singleValueFormula(...arrayInAccessors.map(x => x(ii)), ii, tupleOut); + arrayOutRaw[ii] = singleValueFormula( + ...arrayInAccessors.map((x) => x(ii)), + ii, + tupleOut + ); }); } else { const nt = arrayOut.getNumberOfTuples(); for (let ii = 0; ii < nt; ++ii) { - tupleOut = singleValueFormula(...arrayInAccessors.map(x => x(ii)), ii, tupleOut); + tupleOut = singleValueFormula( + ...arrayInAccessors.map((x) => x(ii)), + ii, + tupleOut + ); arrayOut.setTuple(ii, tupleOut); } } }, }); - publicAPI.setFormulaSimple = (locn, arrNames, resultName, formula, options = {}) => + publicAPI.setFormulaSimple = ( + locn, + arrNames, + resultName, + formula, + options = {} + ) => publicAPI.setFormula( publicAPI.createSimpleFormulaObject( - locn, arrNames, resultName, formula, options)); + locn, + arrNames, + resultName, + formula, + options + ) + ); publicAPI.prepareArrays = (arraySpec, inData, outData) => { const arraysIn = []; @@ -89,53 +125,98 @@ function vtkCalculator(publicAPI, model) { arraysIn.push(inData.getPoints()); } else { const fetchArrayContainer = [ - [FieldDataTypes.UNIFORM, x => x.getFieldData()], - [FieldDataTypes.POINT, x => x.getPointData()], - [FieldDataTypes.CELL, x => x.getCellData()], - [FieldDataTypes.VERTEX, x => x.getVertexData()], - [FieldDataTypes.EDGE, x => x.getEdgeData()], - [FieldDataTypes.ROW, x => x.getRowData()], - ].reduce((result, value) => { result[value[0]] = value[1]; return result; }, {}); - const dsa = ('location' in spec && spec.location in fetchArrayContainer ? - fetchArrayContainer[spec.location](inData) : null); + [FieldDataTypes.UNIFORM, (x) => x.getFieldData()], + [FieldDataTypes.POINT, (x) => x.getPointData()], + [FieldDataTypes.CELL, (x) => x.getCellData()], + [FieldDataTypes.VERTEX, (x) => x.getVertexData()], + [FieldDataTypes.EDGE, (x) => x.getEdgeData()], + [FieldDataTypes.ROW, (x) => x.getRowData()], + ].reduce((result, value) => { + result[value[0]] = value[1]; + return result; + }, {}); + const dsa = + 'location' in spec && spec.location in fetchArrayContainer + ? fetchArrayContainer[spec.location](inData) + : null; if (dsa) { if (spec.name) { arraysIn.push(dsa.getArrayByName(spec.name)); } else if ('index' in spec) { arraysIn.push(dsa.getArrayByIndex(spec.index)); - } else if ('attribute' in spec && spec.location !== FieldDataTypes.UNIFORM) { + } else if ( + 'attribute' in spec && + spec.location !== FieldDataTypes.UNIFORM + ) { arraysIn.push(dsa.getActiveAttribute(spec.attribute)); } else { - vtkWarningMacro(`No matching array for specifier "${JSON.stringify(spec)}".`); + vtkWarningMacro( + `No matching array for specifier "${JSON.stringify(spec)}".` + ); arraysIn.push(null); } } else { - vtkWarningMacro(`Specifier "${JSON.stringify(spec)}" did not provide a usable location.`); + vtkWarningMacro( + `Specifier "${JSON.stringify( + spec + )}" did not provide a usable location.` + ); arraysIn.push(null); } } }); arraySpec.output.forEach((spec) => { const fullSpec = Object.assign({}, spec); - const ncomp = ('numberOfComponents' in fullSpec ? fullSpec.numberOfComponents : 1); + const ncomp = + 'numberOfComponents' in fullSpec ? fullSpec.numberOfComponents : 1; if (spec.location === FieldDataTypes.UNIFORM && 'tuples' in fullSpec) { fullSpec.size = ncomp * fullSpec.tuples; } if (spec.location === FieldDataTypes.COORDINATE) { const inPts = inData.getPoints(); const pts = vtkPoints.newInstance({ dataType: inPts.getDataType() }); - pts.setNumberOfPoints(inPts.getNumberOfPoints(), inPts.getNumberOfComponents()); + pts.setNumberOfPoints( + inPts.getNumberOfPoints(), + inPts.getNumberOfComponents() + ); outData.setPoints(pts); arraysOut.push(pts); } else { const fetchArrayContainer = [ - [FieldDataTypes.UNIFORM, x => x.getFieldData(), (x, y) => ('tuples' in y ? y.tuples : 0)], - [FieldDataTypes.POINT, x => x.getPointData(), x => x.getPoints().getNumberOfPoints()], - [FieldDataTypes.CELL, x => x.getCellData(), x => x.getNumberOfCells()], - [FieldDataTypes.VERTEX, x => x.getVertexData(), x => x.getNumberOfVertices()], - [FieldDataTypes.EDGE, x => x.getEdgeData(), x => x.getNumberOfEdges()], - [FieldDataTypes.ROW, x => x.getRowData(), x => x.getNumberOfRows()], - ].reduce((result, value) => { result[value[0]] = { getData: value[1], getSize: value[2] }; return result; }, {}); + [ + FieldDataTypes.UNIFORM, + (x) => x.getFieldData(), + (x, y) => ('tuples' in y ? y.tuples : 0), + ], + [ + FieldDataTypes.POINT, + (x) => x.getPointData(), + (x) => x.getPoints().getNumberOfPoints(), + ], + [ + FieldDataTypes.CELL, + (x) => x.getCellData(), + (x) => x.getNumberOfCells(), + ], + [ + FieldDataTypes.VERTEX, + (x) => x.getVertexData(), + (x) => x.getNumberOfVertices(), + ], + [ + FieldDataTypes.EDGE, + (x) => x.getEdgeData(), + (x) => x.getNumberOfEdges(), + ], + [ + FieldDataTypes.ROW, + (x) => x.getRowData(), + (x) => x.getNumberOfRows(), + ], + ].reduce((result, value) => { + result[value[0]] = { getData: value[1], getSize: value[2] }; + return result; + }, {}); let dsa = null; let tuples = 0; if ('location' in spec && spec.location in fetchArrayContainer) { @@ -143,18 +224,29 @@ function vtkCalculator(publicAPI, model) { tuples = fetchArrayContainer[spec.location].getSize(inData, fullSpec); } if (tuples <= 0) { - vtkWarningMacro(`Output array size could not be determined for ${JSON.stringify(spec)}.`); + vtkWarningMacro( + `Output array size could not be determined for ${JSON.stringify( + spec + )}.` + ); arraysOut.push(null); } else if (dsa) { fullSpec.size = ncomp * tuples; const arrOut = vtkDataArray.newInstance(fullSpec); const arrIdx = dsa.addArray(arrOut); - if ('attribute' in fullSpec && spec.location !== FieldDataTypes.UNIFORM) { + if ( + 'attribute' in fullSpec && + spec.location !== FieldDataTypes.UNIFORM + ) { dsa.setActiveAttributeByIndex(arrIdx, fullSpec.attribute); } arraysOut.push(arrOut); } else { - vtkWarningMacro(`Specifier "${JSON.stringify(spec)}" did not provide a usable location.`); + vtkWarningMacro( + `Specifier "${JSON.stringify( + spec + )}" did not provide a usable location.` + ); arraysOut.push(null); } } diff --git a/Sources/Filters/General/Calculator/test/testCalculator.js b/Sources/Filters/General/Calculator/test/testCalculator.js index 692adf22357..84d0cd3dd58 100644 --- a/Sources/Filters/General/Calculator/test/testCalculator.js +++ b/Sources/Filters/General/Calculator/test/testCalculator.js @@ -1,7 +1,7 @@ import test from 'tape-catch'; -import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; -import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; +import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; +import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; @@ -14,30 +14,41 @@ test('Test vtkCalculator instance', (t) => { }); test('Test vtkCalculator execution', (t) => { - const source = vtkPlaneSource.newInstance({ xResolution: 5, yResolution: 10 }); + const source = vtkPlaneSource.newInstance({ + xResolution: 5, + yResolution: 10, + }); const filter = vtkCalculator.newInstance(); filter.setInputConnection(source.getOutputPort()); filter.setFormula({ - getArrays: inputDataSets => ({ - input: [ - { location: FieldDataTypes.COORDINATE }, - ], + getArrays: (inputDataSets) => ({ + input: [{ location: FieldDataTypes.COORDINATE }], output: [ - { location: FieldDataTypes.POINT, name: 'sine wave', dataType: 'Float64Array', attribute: AttributeTypes.SCALARS }, - { location: FieldDataTypes.UNIFORM, name: 'global', dataType: 'Float32Array', tuples: 1 }, + { + location: FieldDataTypes.POINT, + name: 'sine wave', + dataType: 'Float64Array', + attribute: AttributeTypes.SCALARS, + }, + { + location: FieldDataTypes.UNIFORM, + name: 'global', + dataType: 'Float32Array', + tuples: 1, + }, ], }), evaluate: (arraysIn, arraysOut) => { - const [coords] = arraysIn.map(d => d.getData()); - const [sine, glob] = arraysOut.map(d => d.getData()); + const [coords] = arraysIn.map((d) => d.getData()); + const [sine, glob] = arraysOut.map((d) => d.getData()); for (let i = 0, sz = coords.length / 3; i < sz; ++i) { - const dx = (coords[3 * i] - 0.5); - const dy = (coords[(3 * i) + 1] - 0.5); - sine[i] = (dx * dx) + (dy * dy) + 0.125; + const dx = coords[3 * i] - 0.5; + const dy = coords[3 * i + 1] - 0.5; + sine[i] = dx * dx + dy * dy + 0.125; } glob[0] = sine.reduce((result, value) => result + value, 0); - arraysOut.forEach(arr => arr.modified()); + arraysOut.forEach((arr) => arr.modified()); }, }); @@ -47,18 +58,44 @@ test('Test vtkCalculator execution', (t) => { const output = filter.getOutputData(); t.ok(output, 'Output dataset exists'); - t.equal(output.isA('vtkPolyData'), true, 'The output dataset should be a vtkPolydata'); + t.equal( + output.isA('vtkPolyData'), + true, + 'The output dataset should be a vtkPolydata' + ); t.equal( input.getPoints().getNumberOfPoints(), output.getPoints().getNumberOfPoints(), - `The number of points did not change between input ${ - input.getPoints().getNumberOfPoints()} and output ${ - output.getPoints().getNumberOfPoints()}`); - t.ok(output.getPointData().getScalars(), 'Output point-scalars array exists.'); - t.equal(output.getPointData().getScalars().getName(), 'sine wave', 'Output point-scalars is "sine wave".'); - t.ok(output.getFieldData().getArray('global'), 'Output field-data array exists.'); - const uniform = output.getFieldData().getArray('global').getData(); - t.ok(Math.abs(uniform[0] - 22.55) < 1e-6, `The uniform result variable should be 22.55; got ${uniform[0]}.`); + `The number of points did not change between input ${input + .getPoints() + .getNumberOfPoints()} and output ${output + .getPoints() + .getNumberOfPoints()}` + ); + t.ok( + output.getPointData().getScalars(), + 'Output point-scalars array exists.' + ); + t.equal( + output + .getPointData() + .getScalars() + .getName(), + 'sine wave', + 'Output point-scalars is "sine wave".' + ); + t.ok( + output.getFieldData().getArray('global'), + 'Output field-data array exists.' + ); + const uniform = output + .getFieldData() + .getArray('global') + .getData(); + t.ok( + Math.abs(uniform[0] - 22.55) < 1e-6, + `The uniform result variable should be 22.55; got ${uniform[0]}.` + ); t.end(); }); diff --git a/Sources/Filters/General/ImageMarchingCubes/caseTable.js b/Sources/Filters/General/ImageMarchingCubes/caseTable.js index b579b7d9da7..dbad1dae399 100644 --- a/Sources/Filters/General/ImageMarchingCubes/caseTable.js +++ b/Sources/Filters/General/ImageMarchingCubes/caseTable.js @@ -5,262 +5,262 @@ // triangle points. // ---------------------------------------------------------------------------- const MARCHING_CUBE_CASES = [ - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 0 0 */ - [0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 1 1 */ - [0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 2 1 */ - [1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 3 2 */ - [1, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 4 1 */ - [0, 3, 8, 1, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 5 3 */ - [9, 11, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 6 2 */ - [2, 3, 8, 2, 8, 11, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1], /* 7 5 */ - [3, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 8 1 */ - [0, 2, 10, 8, 0, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 9 2 */ - [1, 0, 9, 2, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 10 3 */ - [1, 2, 10, 1, 10, 9, 9, 10, 8, -1, -1, -1, -1, -1, -1, -1], /* 11 5 */ - [3, 1, 11, 10, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 12 2 */ - [0, 1, 11, 0, 11, 8, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1], /* 13 5 */ - [3, 0, 9, 3, 9, 10, 10, 9, 11, -1, -1, -1, -1, -1, -1, -1], /* 14 5 */ - [9, 11, 8, 11, 10, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 15 8 */ - [4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 16 1 */ - [4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 17 2 */ - [0, 9, 1, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 18 3 */ - [4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1], /* 19 5 */ - [1, 11, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 20 4 */ - [3, 7, 4, 3, 4, 0, 1, 11, 2, -1, -1, -1, -1, -1, -1, -1], /* 21 7 */ - [9, 11, 2, 9, 2, 0, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1], /* 22 7 */ - [2, 9, 11, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1], /* 23 14 */ - [8, 7, 4, 3, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 24 3 */ - [10, 7, 4, 10, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1], /* 25 5 */ - [9, 1, 0, 8, 7, 4, 2, 10, 3, -1, -1, -1, -1, -1, -1, -1], /* 26 6 */ - [4, 10, 7, 9, 10, 4, 9, 2, 10, 9, 1, 2, -1, -1, -1, -1], /* 27 9 */ - [3, 1, 11, 3, 11, 10, 7, 4, 8, -1, -1, -1, -1, -1, -1, -1], /* 28 7 */ - [1, 11, 10, 1, 10, 4, 1, 4, 0, 7, 4, 10, -1, -1, -1, -1], /* 29 11 */ - [4, 8, 7, 9, 10, 0, 9, 11, 10, 10, 3, 0, -1, -1, -1, -1], /* 30 12 */ - [4, 10, 7, 4, 9, 10, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1], /* 31 5 */ - [9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 32 1 */ - [9, 4, 5, 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 33 3 */ - [0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 34 2 */ - [8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1], /* 35 5 */ - [1, 11, 2, 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 36 3 */ - [3, 8, 0, 1, 11, 2, 4, 5, 9, -1, -1, -1, -1, -1, -1, -1], /* 37 6 */ - [5, 11, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1], /* 38 5 */ - [2, 5, 11, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1], /* 39 9 */ - [9, 4, 5, 2, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 40 4 */ - [0, 2, 10, 0, 10, 8, 4, 5, 9, -1, -1, -1, -1, -1, -1, -1], /* 41 7 */ - [0, 4, 5, 0, 5, 1, 2, 10, 3, -1, -1, -1, -1, -1, -1, -1], /* 42 7 */ - [2, 5, 1, 2, 8, 5, 2, 10, 8, 4, 5, 8, -1, -1, -1, -1], /* 43 11 */ - [11, 10, 3, 11, 3, 1, 9, 4, 5, -1, -1, -1, -1, -1, -1, -1], /* 44 7 */ - [4, 5, 9, 0, 1, 8, 8, 1, 11, 8, 11, 10, -1, -1, -1, -1], /* 45 12 */ - [5, 0, 4, 5, 10, 0, 5, 11, 10, 10, 3, 0, -1, -1, -1, -1], /* 46 14 */ - [5, 8, 4, 5, 11, 8, 11, 10, 8, -1, -1, -1, -1, -1, -1, -1], /* 47 5 */ - [9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 48 2 */ - [9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1], /* 49 5 */ - [0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1], /* 50 5 */ - [1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 51 8 */ - [9, 8, 7, 9, 7, 5, 11, 2, 1, -1, -1, -1, -1, -1, -1, -1], /* 52 7 */ - [11, 2, 1, 9, 0, 5, 5, 0, 3, 5, 3, 7, -1, -1, -1, -1], /* 53 12 */ - [8, 2, 0, 8, 5, 2, 8, 7, 5, 11, 2, 5, -1, -1, -1, -1], /* 54 11 */ - [2, 5, 11, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1], /* 55 5 */ - [7, 5, 9, 7, 9, 8, 3, 2, 10, -1, -1, -1, -1, -1, -1, -1], /* 56 7 */ - [9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 10, 7, -1, -1, -1, -1], /* 57 14 */ - [2, 10, 3, 0, 8, 1, 1, 8, 7, 1, 7, 5, -1, -1, -1, -1], /* 58 12 */ - [10, 1, 2, 10, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1], /* 59 5 */ - [9, 8, 5, 8, 7, 5, 11, 3, 1, 11, 10, 3, -1, -1, -1, -1], /* 60 10 */ - [5, 0, 7, 5, 9, 0, 7, 0, 10, 1, 11, 0, 10, 0, 11, -1], /* 61 7 */ - [10, 0, 11, 10, 3, 0, 11, 0, 5, 8, 7, 0, 5, 0, 7, -1], /* 62 7 */ - [10, 5, 11, 7, 5, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 63 2 */ - [11, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 64 1 */ - [0, 3, 8, 5, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 65 4 */ - [9, 1, 0, 5, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 66 3 */ - [1, 3, 8, 1, 8, 9, 5, 6, 11, -1, -1, -1, -1, -1, -1, -1], /* 67 7 */ - [1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 68 2 */ - [1, 5, 6, 1, 6, 2, 3, 8, 0, -1, -1, -1, -1, -1, -1, -1], /* 69 7 */ - [9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1], /* 70 5 */ - [5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1], /* 71 11 */ - [2, 10, 3, 11, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 72 3 */ - [10, 8, 0, 10, 0, 2, 11, 5, 6, -1, -1, -1, -1, -1, -1, -1], /* 73 7 */ - [0, 9, 1, 2, 10, 3, 5, 6, 11, -1, -1, -1, -1, -1, -1, -1], /* 74 6 */ - [5, 6, 11, 1, 2, 9, 9, 2, 10, 9, 10, 8, -1, -1, -1, -1], /* 75 12 */ - [6, 10, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1], /* 76 5 */ - [0, 10, 8, 0, 5, 10, 0, 1, 5, 5, 6, 10, -1, -1, -1, -1], /* 77 14 */ - [3, 6, 10, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1], /* 78 9 */ - [6, 9, 5, 6, 10, 9, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1], /* 79 5 */ - [5, 6, 11, 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 80 3 */ - [4, 0, 3, 4, 3, 7, 6, 11, 5, -1, -1, -1, -1, -1, -1, -1], /* 81 7 */ - [1, 0, 9, 5, 6, 11, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1], /* 82 6 */ - [11, 5, 6, 1, 7, 9, 1, 3, 7, 7, 4, 9, -1, -1, -1, -1], /* 83 12 */ - [6, 2, 1, 6, 1, 5, 4, 8, 7, -1, -1, -1, -1, -1, -1, -1], /* 84 7 */ - [1, 5, 2, 5, 6, 2, 3, 4, 0, 3, 7, 4, -1, -1, -1, -1], /* 85 10 */ - [8, 7, 4, 9, 5, 0, 0, 5, 6, 0, 6, 2, -1, -1, -1, -1], /* 86 12 */ - [7, 9, 3, 7, 4, 9, 3, 9, 2, 5, 6, 9, 2, 9, 6, -1], /* 87 7 */ - [3, 2, 10, 7, 4, 8, 11, 5, 6, -1, -1, -1, -1, -1, -1, -1], /* 88 6 */ - [5, 6, 11, 4, 2, 7, 4, 0, 2, 2, 10, 7, -1, -1, -1, -1], /* 89 12 */ - [0, 9, 1, 4, 8, 7, 2, 10, 3, 5, 6, 11, -1, -1, -1, -1], /* 90 13 */ - [9, 1, 2, 9, 2, 10, 9, 10, 4, 7, 4, 10, 5, 6, 11, -1], /* 91 6 */ - [8, 7, 4, 3, 5, 10, 3, 1, 5, 5, 6, 10, -1, -1, -1, -1], /* 92 12 */ - [5, 10, 1, 5, 6, 10, 1, 10, 0, 7, 4, 10, 0, 10, 4, -1], /* 93 7 */ - [0, 9, 5, 0, 5, 6, 0, 6, 3, 10, 3, 6, 8, 7, 4, -1], /* 94 6 */ - [6, 9, 5, 6, 10, 9, 4, 9, 7, 7, 9, 10, -1, -1, -1, -1], /* 95 3 */ - [11, 9, 4, 6, 11, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 96 2 */ - [4, 6, 11, 4, 11, 9, 0, 3, 8, -1, -1, -1, -1, -1, -1, -1], /* 97 7 */ - [11, 1, 0, 11, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1], /* 98 5 */ - [8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 11, 1, -1, -1, -1, -1], /* 99 14 */ - [1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1], /* 100 5 */ - [3, 8, 0, 1, 9, 2, 2, 9, 4, 2, 4, 6, -1, -1, -1, -1], /* 101 12 */ - [0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 102 8 */ - [8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1], /* 103 5 */ - [11, 9, 4, 11, 4, 6, 10, 3, 2, -1, -1, -1, -1, -1, -1, -1], /* 104 7 */ - [0, 2, 8, 2, 10, 8, 4, 11, 9, 4, 6, 11, -1, -1, -1, -1], /* 105 10 */ - [3, 2, 10, 0, 6, 1, 0, 4, 6, 6, 11, 1, -1, -1, -1, -1], /* 106 12 */ - [6, 1, 4, 6, 11, 1, 4, 1, 8, 2, 10, 1, 8, 1, 10, -1], /* 107 7 */ - [9, 4, 6, 9, 6, 3, 9, 3, 1, 10, 3, 6, -1, -1, -1, -1], /* 108 11 */ - [8, 1, 10, 8, 0, 1, 10, 1, 6, 9, 4, 1, 6, 1, 4, -1], /* 109 7 */ - [3, 6, 10, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1], /* 110 5 */ - [6, 8, 4, 10, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 111 2 */ - [7, 6, 11, 7, 11, 8, 8, 11, 9, -1, -1, -1, -1, -1, -1, -1], /* 112 5 */ - [0, 3, 7, 0, 7, 11, 0, 11, 9, 6, 11, 7, -1, -1, -1, -1], /* 113 11 */ - [11, 7, 6, 1, 7, 11, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1], /* 114 9 */ - [11, 7, 6, 11, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1], /* 115 5 */ - [1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1], /* 116 14 */ - [2, 9, 6, 2, 1, 9, 6, 9, 7, 0, 3, 9, 7, 9, 3, -1], /* 117 7 */ - [7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1], /* 118 5 */ - [7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 119 2 */ - [2, 10, 3, 11, 8, 6, 11, 9, 8, 8, 7, 6, -1, -1, -1, -1], /* 120 12 */ - [2, 7, 0, 2, 10, 7, 0, 7, 9, 6, 11, 7, 9, 7, 11, -1], /* 121 7 */ - [1, 0, 8, 1, 8, 7, 1, 7, 11, 6, 11, 7, 2, 10, 3, -1], /* 122 6 */ - [10, 1, 2, 10, 7, 1, 11, 1, 6, 6, 1, 7, -1, -1, -1, -1], /* 123 3 */ - [8, 6, 9, 8, 7, 6, 9, 6, 1, 10, 3, 6, 1, 6, 3, -1], /* 124 7 */ - [0, 1, 9, 10, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 125 4 */ - [7, 0, 8, 7, 6, 0, 3, 0, 10, 10, 0, 6, -1, -1, -1, -1], /* 126 3 */ - [7, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 127 1 */ - [7, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 128 1 */ - [3, 8, 0, 10, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 129 3 */ - [0, 9, 1, 10, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 130 4 */ - [8, 9, 1, 8, 1, 3, 10, 6, 7, -1, -1, -1, -1, -1, -1, -1], /* 131 7 */ - [11, 2, 1, 6, 7, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 132 3 */ - [1, 11, 2, 3, 8, 0, 6, 7, 10, -1, -1, -1, -1, -1, -1, -1], /* 133 6 */ - [2, 0, 9, 2, 9, 11, 6, 7, 10, -1, -1, -1, -1, -1, -1, -1], /* 134 7 */ - [6, 7, 10, 2, 3, 11, 11, 3, 8, 11, 8, 9, -1, -1, -1, -1], /* 135 12 */ - [7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 136 2 */ - [7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1], /* 137 5 */ - [2, 6, 7, 2, 7, 3, 0, 9, 1, -1, -1, -1, -1, -1, -1, -1], /* 138 7 */ - [1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1], /* 139 14 */ - [11, 6, 7, 11, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1], /* 140 5 */ - [11, 6, 7, 1, 11, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1], /* 141 9 */ - [0, 7, 3, 0, 11, 7, 0, 9, 11, 6, 7, 11, -1, -1, -1, -1], /* 142 11 */ - [7, 11, 6, 7, 8, 11, 8, 9, 11, -1, -1, -1, -1, -1, -1, -1], /* 143 5 */ - [6, 4, 8, 10, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 144 2 */ - [3, 10, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1], /* 145 5 */ - [8, 10, 6, 8, 6, 4, 9, 1, 0, -1, -1, -1, -1, -1, -1, -1], /* 146 7 */ - [9, 6, 4, 9, 3, 6, 9, 1, 3, 10, 6, 3, -1, -1, -1, -1], /* 147 11 */ - [6, 4, 8, 6, 8, 10, 2, 1, 11, -1, -1, -1, -1, -1, -1, -1], /* 148 7 */ - [1, 11, 2, 3, 10, 0, 0, 10, 6, 0, 6, 4, -1, -1, -1, -1], /* 149 12 */ - [4, 8, 10, 4, 10, 6, 0, 9, 2, 2, 9, 11, -1, -1, -1, -1], /* 150 10 */ - [11, 3, 9, 11, 2, 3, 9, 3, 4, 10, 6, 3, 4, 3, 6, -1], /* 151 7 */ - [8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1], /* 152 5 */ - [0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 153 8 */ - [1, 0, 9, 2, 4, 3, 2, 6, 4, 4, 8, 3, -1, -1, -1, -1], /* 154 12 */ - [1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1], /* 155 5 */ - [8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 11, -1, -1, -1, -1], /* 156 14 */ - [11, 0, 1, 11, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1], /* 157 5 */ - [4, 3, 6, 4, 8, 3, 6, 3, 11, 0, 9, 3, 11, 3, 9, -1], /* 158 7 */ - [11, 4, 9, 6, 4, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 159 2 */ - [4, 5, 9, 7, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 160 3 */ - [0, 3, 8, 4, 5, 9, 10, 6, 7, -1, -1, -1, -1, -1, -1, -1], /* 161 6 */ - [5, 1, 0, 5, 0, 4, 7, 10, 6, -1, -1, -1, -1, -1, -1, -1], /* 162 7 */ - [10, 6, 7, 8, 4, 3, 3, 4, 5, 3, 5, 1, -1, -1, -1, -1], /* 163 12 */ - [9, 4, 5, 11, 2, 1, 7, 10, 6, -1, -1, -1, -1, -1, -1, -1], /* 164 6 */ - [6, 7, 10, 1, 11, 2, 0, 3, 8, 4, 5, 9, -1, -1, -1, -1], /* 165 13 */ - [7, 10, 6, 5, 11, 4, 4, 11, 2, 4, 2, 0, -1, -1, -1, -1], /* 166 12 */ - [3, 8, 4, 3, 4, 5, 3, 5, 2, 11, 2, 5, 10, 6, 7, -1], /* 167 6 */ - [7, 3, 2, 7, 2, 6, 5, 9, 4, -1, -1, -1, -1, -1, -1, -1], /* 168 7 */ - [9, 4, 5, 0, 6, 8, 0, 2, 6, 6, 7, 8, -1, -1, -1, -1], /* 169 12 */ - [3, 2, 6, 3, 6, 7, 1, 0, 5, 5, 0, 4, -1, -1, -1, -1], /* 170 10 */ - [6, 8, 2, 6, 7, 8, 2, 8, 1, 4, 5, 8, 1, 8, 5, -1], /* 171 7 */ - [9, 4, 5, 11, 6, 1, 1, 6, 7, 1, 7, 3, -1, -1, -1, -1], /* 172 12 */ - [1, 11, 6, 1, 6, 7, 1, 7, 0, 8, 0, 7, 9, 4, 5, -1], /* 173 6 */ - [4, 11, 0, 4, 5, 11, 0, 11, 3, 6, 7, 11, 3, 11, 7, -1], /* 174 7 */ - [7, 11, 6, 7, 8, 11, 5, 11, 4, 4, 11, 8, -1, -1, -1, -1], /* 175 3 */ - [6, 5, 9, 6, 9, 10, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1], /* 176 5 */ - [3, 10, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1], /* 177 9 */ - [0, 8, 10, 0, 10, 5, 0, 5, 1, 5, 10, 6, -1, -1, -1, -1], /* 178 14 */ - [6, 3, 10, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1], /* 179 5 */ - [1, 11, 2, 9, 10, 5, 9, 8, 10, 10, 6, 5, -1, -1, -1, -1], /* 180 12 */ - [0, 3, 10, 0, 10, 6, 0, 6, 9, 5, 9, 6, 1, 11, 2, -1], /* 181 6 */ - [10, 5, 8, 10, 6, 5, 8, 5, 0, 11, 2, 5, 0, 5, 2, -1], /* 182 7 */ - [6, 3, 10, 6, 5, 3, 2, 3, 11, 11, 3, 5, -1, -1, -1, -1], /* 183 3 */ - [5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1], /* 184 11 */ - [9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1], /* 185 5 */ - [1, 8, 5, 1, 0, 8, 5, 8, 6, 3, 2, 8, 6, 8, 2, -1], /* 186 7 */ - [1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 187 2 */ - [1, 6, 3, 1, 11, 6, 3, 6, 8, 5, 9, 6, 8, 6, 9, -1], /* 188 7 */ - [11, 0, 1, 11, 6, 0, 9, 0, 5, 5, 0, 6, -1, -1, -1, -1], /* 189 3 */ - [0, 8, 3, 5, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 190 4 */ - [11, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 191 1 */ - [10, 11, 5, 7, 10, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 192 2 */ - [10, 11, 5, 10, 5, 7, 8, 0, 3, -1, -1, -1, -1, -1, -1, -1], /* 193 7 */ - [5, 7, 10, 5, 10, 11, 1, 0, 9, -1, -1, -1, -1, -1, -1, -1], /* 194 7 */ - [11, 5, 7, 11, 7, 10, 9, 1, 8, 8, 1, 3, -1, -1, -1, -1], /* 195 10 */ - [10, 2, 1, 10, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1], /* 196 5 */ - [0, 3, 8, 1, 7, 2, 1, 5, 7, 7, 10, 2, -1, -1, -1, -1], /* 197 12 */ - [9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 10, -1, -1, -1, -1], /* 198 14 */ - [7, 2, 5, 7, 10, 2, 5, 2, 9, 3, 8, 2, 9, 2, 8, -1], /* 199 7 */ - [2, 11, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1], /* 200 5 */ - [8, 0, 2, 8, 2, 5, 8, 5, 7, 11, 5, 2, -1, -1, -1, -1], /* 201 11 */ - [9, 1, 0, 5, 3, 11, 5, 7, 3, 3, 2, 11, -1, -1, -1, -1], /* 202 12 */ - [9, 2, 8, 9, 1, 2, 8, 2, 7, 11, 5, 2, 7, 2, 5, -1], /* 203 7 */ - [1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 204 8 */ - [0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1], /* 205 5 */ - [9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1], /* 206 5 */ - [9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 207 2 */ - [5, 4, 8, 5, 8, 11, 11, 8, 10, -1, -1, -1, -1, -1, -1, -1], /* 208 5 */ - [5, 4, 0, 5, 0, 10, 5, 10, 11, 10, 0, 3, -1, -1, -1, -1], /* 209 14 */ - [0, 9, 1, 8, 11, 4, 8, 10, 11, 11, 5, 4, -1, -1, -1, -1], /* 210 12 */ - [11, 4, 10, 11, 5, 4, 10, 4, 3, 9, 1, 4, 3, 4, 1, -1], /* 211 7 */ - [2, 1, 5, 2, 5, 8, 2, 8, 10, 4, 8, 5, -1, -1, -1, -1], /* 212 11 */ - [0, 10, 4, 0, 3, 10, 4, 10, 5, 2, 1, 10, 5, 10, 1, -1], /* 213 7 */ - [0, 5, 2, 0, 9, 5, 2, 5, 10, 4, 8, 5, 10, 5, 8, -1], /* 214 7 */ - [9, 5, 4, 2, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 215 4 */ - [2, 11, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1], /* 216 9 */ - [5, 2, 11, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1], /* 217 5 */ - [3, 2, 11, 3, 11, 5, 3, 5, 8, 4, 8, 5, 0, 9, 1, -1], /* 218 6 */ - [5, 2, 11, 5, 4, 2, 1, 2, 9, 9, 2, 4, -1, -1, -1, -1], /* 219 3 */ - [8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1], /* 220 5 */ - [0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 221 2 */ - [8, 5, 4, 8, 3, 5, 9, 5, 0, 0, 5, 3, -1, -1, -1, -1], /* 222 3 */ - [9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 223 1 */ - [4, 7, 10, 4, 10, 9, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1], /* 224 5 */ - [0, 3, 8, 4, 7, 9, 9, 7, 10, 9, 10, 11, -1, -1, -1, -1], /* 225 12 */ - [1, 10, 11, 1, 4, 10, 1, 0, 4, 7, 10, 4, -1, -1, -1, -1], /* 226 11 */ - [3, 4, 1, 3, 8, 4, 1, 4, 11, 7, 10, 4, 11, 4, 10, -1], /* 227 7 */ - [4, 7, 10, 9, 4, 10, 9, 10, 2, 9, 2, 1, -1, -1, -1, -1], /* 228 9 */ - [9, 4, 7, 9, 7, 10, 9, 10, 1, 2, 1, 10, 0, 3, 8, -1], /* 229 6 */ - [10, 4, 7, 10, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1], /* 230 5 */ - [10, 4, 7, 10, 2, 4, 8, 4, 3, 3, 4, 2, -1, -1, -1, -1], /* 231 3 */ - [2, 11, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1], /* 232 14 */ - [9, 7, 11, 9, 4, 7, 11, 7, 2, 8, 0, 7, 2, 7, 0, -1], /* 233 7 */ - [3, 11, 7, 3, 2, 11, 7, 11, 4, 1, 0, 11, 4, 11, 0, -1], /* 234 7 */ - [1, 2, 11, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 235 4 */ - [4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1], /* 236 5 */ - [4, 1, 9, 4, 7, 1, 0, 1, 8, 8, 1, 7, -1, -1, -1, -1], /* 237 3 */ - [4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 238 2 */ - [4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 239 1 */ - [9, 8, 11, 11, 8, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 240 8 */ - [3, 9, 0, 3, 10, 9, 10, 11, 9, -1, -1, -1, -1, -1, -1, -1], /* 241 5 */ - [0, 11, 1, 0, 8, 11, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1], /* 242 5 */ - [3, 11, 1, 10, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 243 2 */ - [1, 10, 2, 1, 9, 10, 9, 8, 10, -1, -1, -1, -1, -1, -1, -1], /* 244 5 */ - [3, 9, 0, 3, 10, 9, 1, 9, 2, 2, 9, 10, -1, -1, -1, -1], /* 245 3 */ - [0, 10, 2, 8, 10, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 246 2 */ - [3, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 247 1 */ - [2, 8, 3, 2, 11, 8, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1], /* 248 5 */ - [9, 2, 11, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 249 2 */ - [2, 8, 3, 2, 11, 8, 0, 8, 1, 1, 8, 11, -1, -1, -1, -1], /* 250 3 */ - [1, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 251 1 */ - [1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 252 2 */ - [0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 253 1 */ - [0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 254 1 */ - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], /* 255 0 */ + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 0 0 */, + [0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 1 1 */, + [0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 2 1 */, + [1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 3 2 */, + [1, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 4 1 */, + [0, 3, 8, 1, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 5 3 */, + [9, 11, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 6 2 */, + [2, 3, 8, 2, 8, 11, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1] /* 7 5 */, + [3, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 8 1 */, + [0, 2, 10, 8, 0, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 9 2 */, + [1, 0, 9, 2, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 10 3 */, + [1, 2, 10, 1, 10, 9, 9, 10, 8, -1, -1, -1, -1, -1, -1, -1] /* 11 5 */, + [3, 1, 11, 10, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 12 2 */, + [0, 1, 11, 0, 11, 8, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1] /* 13 5 */, + [3, 0, 9, 3, 9, 10, 10, 9, 11, -1, -1, -1, -1, -1, -1, -1] /* 14 5 */, + [9, 11, 8, 11, 10, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 15 8 */, + [4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 16 1 */, + [4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 17 2 */, + [0, 9, 1, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 18 3 */, + [4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1] /* 19 5 */, + [1, 11, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 20 4 */, + [3, 7, 4, 3, 4, 0, 1, 11, 2, -1, -1, -1, -1, -1, -1, -1] /* 21 7 */, + [9, 11, 2, 9, 2, 0, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1] /* 22 7 */, + [2, 9, 11, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1] /* 23 14 */, + [8, 7, 4, 3, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 24 3 */, + [10, 7, 4, 10, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1] /* 25 5 */, + [9, 1, 0, 8, 7, 4, 2, 10, 3, -1, -1, -1, -1, -1, -1, -1] /* 26 6 */, + [4, 10, 7, 9, 10, 4, 9, 2, 10, 9, 1, 2, -1, -1, -1, -1] /* 27 9 */, + [3, 1, 11, 3, 11, 10, 7, 4, 8, -1, -1, -1, -1, -1, -1, -1] /* 28 7 */, + [1, 11, 10, 1, 10, 4, 1, 4, 0, 7, 4, 10, -1, -1, -1, -1] /* 29 11 */, + [4, 8, 7, 9, 10, 0, 9, 11, 10, 10, 3, 0, -1, -1, -1, -1] /* 30 12 */, + [4, 10, 7, 4, 9, 10, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1] /* 31 5 */, + [9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 32 1 */, + [9, 4, 5, 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 33 3 */, + [0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 34 2 */, + [8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1] /* 35 5 */, + [1, 11, 2, 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 36 3 */, + [3, 8, 0, 1, 11, 2, 4, 5, 9, -1, -1, -1, -1, -1, -1, -1] /* 37 6 */, + [5, 11, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1] /* 38 5 */, + [2, 5, 11, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1] /* 39 9 */, + [9, 4, 5, 2, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 40 4 */, + [0, 2, 10, 0, 10, 8, 4, 5, 9, -1, -1, -1, -1, -1, -1, -1] /* 41 7 */, + [0, 4, 5, 0, 5, 1, 2, 10, 3, -1, -1, -1, -1, -1, -1, -1] /* 42 7 */, + [2, 5, 1, 2, 8, 5, 2, 10, 8, 4, 5, 8, -1, -1, -1, -1] /* 43 11 */, + [11, 10, 3, 11, 3, 1, 9, 4, 5, -1, -1, -1, -1, -1, -1, -1] /* 44 7 */, + [4, 5, 9, 0, 1, 8, 8, 1, 11, 8, 11, 10, -1, -1, -1, -1] /* 45 12 */, + [5, 0, 4, 5, 10, 0, 5, 11, 10, 10, 3, 0, -1, -1, -1, -1] /* 46 14 */, + [5, 8, 4, 5, 11, 8, 11, 10, 8, -1, -1, -1, -1, -1, -1, -1] /* 47 5 */, + [9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 48 2 */, + [9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1] /* 49 5 */, + [0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1] /* 50 5 */, + [1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 51 8 */, + [9, 8, 7, 9, 7, 5, 11, 2, 1, -1, -1, -1, -1, -1, -1, -1] /* 52 7 */, + [11, 2, 1, 9, 0, 5, 5, 0, 3, 5, 3, 7, -1, -1, -1, -1] /* 53 12 */, + [8, 2, 0, 8, 5, 2, 8, 7, 5, 11, 2, 5, -1, -1, -1, -1] /* 54 11 */, + [2, 5, 11, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1] /* 55 5 */, + [7, 5, 9, 7, 9, 8, 3, 2, 10, -1, -1, -1, -1, -1, -1, -1] /* 56 7 */, + [9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 10, 7, -1, -1, -1, -1] /* 57 14 */, + [2, 10, 3, 0, 8, 1, 1, 8, 7, 1, 7, 5, -1, -1, -1, -1] /* 58 12 */, + [10, 1, 2, 10, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1] /* 59 5 */, + [9, 8, 5, 8, 7, 5, 11, 3, 1, 11, 10, 3, -1, -1, -1, -1] /* 60 10 */, + [5, 0, 7, 5, 9, 0, 7, 0, 10, 1, 11, 0, 10, 0, 11, -1] /* 61 7 */, + [10, 0, 11, 10, 3, 0, 11, 0, 5, 8, 7, 0, 5, 0, 7, -1] /* 62 7 */, + [10, 5, 11, 7, 5, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 63 2 */, + [11, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 64 1 */, + [0, 3, 8, 5, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 65 4 */, + [9, 1, 0, 5, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 66 3 */, + [1, 3, 8, 1, 8, 9, 5, 6, 11, -1, -1, -1, -1, -1, -1, -1] /* 67 7 */, + [1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 68 2 */, + [1, 5, 6, 1, 6, 2, 3, 8, 0, -1, -1, -1, -1, -1, -1, -1] /* 69 7 */, + [9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1] /* 70 5 */, + [5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1] /* 71 11 */, + [2, 10, 3, 11, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 72 3 */, + [10, 8, 0, 10, 0, 2, 11, 5, 6, -1, -1, -1, -1, -1, -1, -1] /* 73 7 */, + [0, 9, 1, 2, 10, 3, 5, 6, 11, -1, -1, -1, -1, -1, -1, -1] /* 74 6 */, + [5, 6, 11, 1, 2, 9, 9, 2, 10, 9, 10, 8, -1, -1, -1, -1] /* 75 12 */, + [6, 10, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1] /* 76 5 */, + [0, 10, 8, 0, 5, 10, 0, 1, 5, 5, 6, 10, -1, -1, -1, -1] /* 77 14 */, + [3, 6, 10, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1] /* 78 9 */, + [6, 9, 5, 6, 10, 9, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1] /* 79 5 */, + [5, 6, 11, 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 80 3 */, + [4, 0, 3, 4, 3, 7, 6, 11, 5, -1, -1, -1, -1, -1, -1, -1] /* 81 7 */, + [1, 0, 9, 5, 6, 11, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1] /* 82 6 */, + [11, 5, 6, 1, 7, 9, 1, 3, 7, 7, 4, 9, -1, -1, -1, -1] /* 83 12 */, + [6, 2, 1, 6, 1, 5, 4, 8, 7, -1, -1, -1, -1, -1, -1, -1] /* 84 7 */, + [1, 5, 2, 5, 6, 2, 3, 4, 0, 3, 7, 4, -1, -1, -1, -1] /* 85 10 */, + [8, 7, 4, 9, 5, 0, 0, 5, 6, 0, 6, 2, -1, -1, -1, -1] /* 86 12 */, + [7, 9, 3, 7, 4, 9, 3, 9, 2, 5, 6, 9, 2, 9, 6, -1] /* 87 7 */, + [3, 2, 10, 7, 4, 8, 11, 5, 6, -1, -1, -1, -1, -1, -1, -1] /* 88 6 */, + [5, 6, 11, 4, 2, 7, 4, 0, 2, 2, 10, 7, -1, -1, -1, -1] /* 89 12 */, + [0, 9, 1, 4, 8, 7, 2, 10, 3, 5, 6, 11, -1, -1, -1, -1] /* 90 13 */, + [9, 1, 2, 9, 2, 10, 9, 10, 4, 7, 4, 10, 5, 6, 11, -1] /* 91 6 */, + [8, 7, 4, 3, 5, 10, 3, 1, 5, 5, 6, 10, -1, -1, -1, -1] /* 92 12 */, + [5, 10, 1, 5, 6, 10, 1, 10, 0, 7, 4, 10, 0, 10, 4, -1] /* 93 7 */, + [0, 9, 5, 0, 5, 6, 0, 6, 3, 10, 3, 6, 8, 7, 4, -1] /* 94 6 */, + [6, 9, 5, 6, 10, 9, 4, 9, 7, 7, 9, 10, -1, -1, -1, -1] /* 95 3 */, + [11, 9, 4, 6, 11, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 96 2 */, + [4, 6, 11, 4, 11, 9, 0, 3, 8, -1, -1, -1, -1, -1, -1, -1] /* 97 7 */, + [11, 1, 0, 11, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1] /* 98 5 */, + [8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 11, 1, -1, -1, -1, -1] /* 99 14 */, + [1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1] /* 100 5 */, + [3, 8, 0, 1, 9, 2, 2, 9, 4, 2, 4, 6, -1, -1, -1, -1] /* 101 12 */, + [0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 102 8 */, + [8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1] /* 103 5 */, + [11, 9, 4, 11, 4, 6, 10, 3, 2, -1, -1, -1, -1, -1, -1, -1] /* 104 7 */, + [0, 2, 8, 2, 10, 8, 4, 11, 9, 4, 6, 11, -1, -1, -1, -1] /* 105 10 */, + [3, 2, 10, 0, 6, 1, 0, 4, 6, 6, 11, 1, -1, -1, -1, -1] /* 106 12 */, + [6, 1, 4, 6, 11, 1, 4, 1, 8, 2, 10, 1, 8, 1, 10, -1] /* 107 7 */, + [9, 4, 6, 9, 6, 3, 9, 3, 1, 10, 3, 6, -1, -1, -1, -1] /* 108 11 */, + [8, 1, 10, 8, 0, 1, 10, 1, 6, 9, 4, 1, 6, 1, 4, -1] /* 109 7 */, + [3, 6, 10, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1] /* 110 5 */, + [6, 8, 4, 10, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 111 2 */, + [7, 6, 11, 7, 11, 8, 8, 11, 9, -1, -1, -1, -1, -1, -1, -1] /* 112 5 */, + [0, 3, 7, 0, 7, 11, 0, 11, 9, 6, 11, 7, -1, -1, -1, -1] /* 113 11 */, + [11, 7, 6, 1, 7, 11, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1] /* 114 9 */, + [11, 7, 6, 11, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1] /* 115 5 */, + [1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1] /* 116 14 */, + [2, 9, 6, 2, 1, 9, 6, 9, 7, 0, 3, 9, 7, 9, 3, -1] /* 117 7 */, + [7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1] /* 118 5 */, + [7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 119 2 */, + [2, 10, 3, 11, 8, 6, 11, 9, 8, 8, 7, 6, -1, -1, -1, -1] /* 120 12 */, + [2, 7, 0, 2, 10, 7, 0, 7, 9, 6, 11, 7, 9, 7, 11, -1] /* 121 7 */, + [1, 0, 8, 1, 8, 7, 1, 7, 11, 6, 11, 7, 2, 10, 3, -1] /* 122 6 */, + [10, 1, 2, 10, 7, 1, 11, 1, 6, 6, 1, 7, -1, -1, -1, -1] /* 123 3 */, + [8, 6, 9, 8, 7, 6, 9, 6, 1, 10, 3, 6, 1, 6, 3, -1] /* 124 7 */, + [0, 1, 9, 10, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 125 4 */, + [7, 0, 8, 7, 6, 0, 3, 0, 10, 10, 0, 6, -1, -1, -1, -1] /* 126 3 */, + [7, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 127 1 */, + [7, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 128 1 */, + [3, 8, 0, 10, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 129 3 */, + [0, 9, 1, 10, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 130 4 */, + [8, 9, 1, 8, 1, 3, 10, 6, 7, -1, -1, -1, -1, -1, -1, -1] /* 131 7 */, + [11, 2, 1, 6, 7, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 132 3 */, + [1, 11, 2, 3, 8, 0, 6, 7, 10, -1, -1, -1, -1, -1, -1, -1] /* 133 6 */, + [2, 0, 9, 2, 9, 11, 6, 7, 10, -1, -1, -1, -1, -1, -1, -1] /* 134 7 */, + [6, 7, 10, 2, 3, 11, 11, 3, 8, 11, 8, 9, -1, -1, -1, -1] /* 135 12 */, + [7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 136 2 */, + [7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1] /* 137 5 */, + [2, 6, 7, 2, 7, 3, 0, 9, 1, -1, -1, -1, -1, -1, -1, -1] /* 138 7 */, + [1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1] /* 139 14 */, + [11, 6, 7, 11, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1] /* 140 5 */, + [11, 6, 7, 1, 11, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1] /* 141 9 */, + [0, 7, 3, 0, 11, 7, 0, 9, 11, 6, 7, 11, -1, -1, -1, -1] /* 142 11 */, + [7, 11, 6, 7, 8, 11, 8, 9, 11, -1, -1, -1, -1, -1, -1, -1] /* 143 5 */, + [6, 4, 8, 10, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 144 2 */, + [3, 10, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1] /* 145 5 */, + [8, 10, 6, 8, 6, 4, 9, 1, 0, -1, -1, -1, -1, -1, -1, -1] /* 146 7 */, + [9, 6, 4, 9, 3, 6, 9, 1, 3, 10, 6, 3, -1, -1, -1, -1] /* 147 11 */, + [6, 4, 8, 6, 8, 10, 2, 1, 11, -1, -1, -1, -1, -1, -1, -1] /* 148 7 */, + [1, 11, 2, 3, 10, 0, 0, 10, 6, 0, 6, 4, -1, -1, -1, -1] /* 149 12 */, + [4, 8, 10, 4, 10, 6, 0, 9, 2, 2, 9, 11, -1, -1, -1, -1] /* 150 10 */, + [11, 3, 9, 11, 2, 3, 9, 3, 4, 10, 6, 3, 4, 3, 6, -1] /* 151 7 */, + [8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1] /* 152 5 */, + [0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 153 8 */, + [1, 0, 9, 2, 4, 3, 2, 6, 4, 4, 8, 3, -1, -1, -1, -1] /* 154 12 */, + [1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1] /* 155 5 */, + [8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 11, -1, -1, -1, -1] /* 156 14 */, + [11, 0, 1, 11, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1] /* 157 5 */, + [4, 3, 6, 4, 8, 3, 6, 3, 11, 0, 9, 3, 11, 3, 9, -1] /* 158 7 */, + [11, 4, 9, 6, 4, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 159 2 */, + [4, 5, 9, 7, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 160 3 */, + [0, 3, 8, 4, 5, 9, 10, 6, 7, -1, -1, -1, -1, -1, -1, -1] /* 161 6 */, + [5, 1, 0, 5, 0, 4, 7, 10, 6, -1, -1, -1, -1, -1, -1, -1] /* 162 7 */, + [10, 6, 7, 8, 4, 3, 3, 4, 5, 3, 5, 1, -1, -1, -1, -1] /* 163 12 */, + [9, 4, 5, 11, 2, 1, 7, 10, 6, -1, -1, -1, -1, -1, -1, -1] /* 164 6 */, + [6, 7, 10, 1, 11, 2, 0, 3, 8, 4, 5, 9, -1, -1, -1, -1] /* 165 13 */, + [7, 10, 6, 5, 11, 4, 4, 11, 2, 4, 2, 0, -1, -1, -1, -1] /* 166 12 */, + [3, 8, 4, 3, 4, 5, 3, 5, 2, 11, 2, 5, 10, 6, 7, -1] /* 167 6 */, + [7, 3, 2, 7, 2, 6, 5, 9, 4, -1, -1, -1, -1, -1, -1, -1] /* 168 7 */, + [9, 4, 5, 0, 6, 8, 0, 2, 6, 6, 7, 8, -1, -1, -1, -1] /* 169 12 */, + [3, 2, 6, 3, 6, 7, 1, 0, 5, 5, 0, 4, -1, -1, -1, -1] /* 170 10 */, + [6, 8, 2, 6, 7, 8, 2, 8, 1, 4, 5, 8, 1, 8, 5, -1] /* 171 7 */, + [9, 4, 5, 11, 6, 1, 1, 6, 7, 1, 7, 3, -1, -1, -1, -1] /* 172 12 */, + [1, 11, 6, 1, 6, 7, 1, 7, 0, 8, 0, 7, 9, 4, 5, -1] /* 173 6 */, + [4, 11, 0, 4, 5, 11, 0, 11, 3, 6, 7, 11, 3, 11, 7, -1] /* 174 7 */, + [7, 11, 6, 7, 8, 11, 5, 11, 4, 4, 11, 8, -1, -1, -1, -1] /* 175 3 */, + [6, 5, 9, 6, 9, 10, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1] /* 176 5 */, + [3, 10, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1] /* 177 9 */, + [0, 8, 10, 0, 10, 5, 0, 5, 1, 5, 10, 6, -1, -1, -1, -1] /* 178 14 */, + [6, 3, 10, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1] /* 179 5 */, + [1, 11, 2, 9, 10, 5, 9, 8, 10, 10, 6, 5, -1, -1, -1, -1] /* 180 12 */, + [0, 3, 10, 0, 10, 6, 0, 6, 9, 5, 9, 6, 1, 11, 2, -1] /* 181 6 */, + [10, 5, 8, 10, 6, 5, 8, 5, 0, 11, 2, 5, 0, 5, 2, -1] /* 182 7 */, + [6, 3, 10, 6, 5, 3, 2, 3, 11, 11, 3, 5, -1, -1, -1, -1] /* 183 3 */, + [5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1] /* 184 11 */, + [9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1] /* 185 5 */, + [1, 8, 5, 1, 0, 8, 5, 8, 6, 3, 2, 8, 6, 8, 2, -1] /* 186 7 */, + [1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 187 2 */, + [1, 6, 3, 1, 11, 6, 3, 6, 8, 5, 9, 6, 8, 6, 9, -1] /* 188 7 */, + [11, 0, 1, 11, 6, 0, 9, 0, 5, 5, 0, 6, -1, -1, -1, -1] /* 189 3 */, + [0, 8, 3, 5, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 190 4 */, + [11, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 191 1 */, + [10, 11, 5, 7, 10, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 192 2 */, + [10, 11, 5, 10, 5, 7, 8, 0, 3, -1, -1, -1, -1, -1, -1, -1] /* 193 7 */, + [5, 7, 10, 5, 10, 11, 1, 0, 9, -1, -1, -1, -1, -1, -1, -1] /* 194 7 */, + [11, 5, 7, 11, 7, 10, 9, 1, 8, 8, 1, 3, -1, -1, -1, -1] /* 195 10 */, + [10, 2, 1, 10, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1] /* 196 5 */, + [0, 3, 8, 1, 7, 2, 1, 5, 7, 7, 10, 2, -1, -1, -1, -1] /* 197 12 */, + [9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 10, -1, -1, -1, -1] /* 198 14 */, + [7, 2, 5, 7, 10, 2, 5, 2, 9, 3, 8, 2, 9, 2, 8, -1] /* 199 7 */, + [2, 11, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1] /* 200 5 */, + [8, 0, 2, 8, 2, 5, 8, 5, 7, 11, 5, 2, -1, -1, -1, -1] /* 201 11 */, + [9, 1, 0, 5, 3, 11, 5, 7, 3, 3, 2, 11, -1, -1, -1, -1] /* 202 12 */, + [9, 2, 8, 9, 1, 2, 8, 2, 7, 11, 5, 2, 7, 2, 5, -1] /* 203 7 */, + [1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 204 8 */, + [0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1] /* 205 5 */, + [9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1] /* 206 5 */, + [9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 207 2 */, + [5, 4, 8, 5, 8, 11, 11, 8, 10, -1, -1, -1, -1, -1, -1, -1] /* 208 5 */, + [5, 4, 0, 5, 0, 10, 5, 10, 11, 10, 0, 3, -1, -1, -1, -1] /* 209 14 */, + [0, 9, 1, 8, 11, 4, 8, 10, 11, 11, 5, 4, -1, -1, -1, -1] /* 210 12 */, + [11, 4, 10, 11, 5, 4, 10, 4, 3, 9, 1, 4, 3, 4, 1, -1] /* 211 7 */, + [2, 1, 5, 2, 5, 8, 2, 8, 10, 4, 8, 5, -1, -1, -1, -1] /* 212 11 */, + [0, 10, 4, 0, 3, 10, 4, 10, 5, 2, 1, 10, 5, 10, 1, -1] /* 213 7 */, + [0, 5, 2, 0, 9, 5, 2, 5, 10, 4, 8, 5, 10, 5, 8, -1] /* 214 7 */, + [9, 5, 4, 2, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 215 4 */, + [2, 11, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1] /* 216 9 */, + [5, 2, 11, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1] /* 217 5 */, + [3, 2, 11, 3, 11, 5, 3, 5, 8, 4, 8, 5, 0, 9, 1, -1] /* 218 6 */, + [5, 2, 11, 5, 4, 2, 1, 2, 9, 9, 2, 4, -1, -1, -1, -1] /* 219 3 */, + [8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1] /* 220 5 */, + [0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 221 2 */, + [8, 5, 4, 8, 3, 5, 9, 5, 0, 0, 5, 3, -1, -1, -1, -1] /* 222 3 */, + [9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 223 1 */, + [4, 7, 10, 4, 10, 9, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1] /* 224 5 */, + [0, 3, 8, 4, 7, 9, 9, 7, 10, 9, 10, 11, -1, -1, -1, -1] /* 225 12 */, + [1, 10, 11, 1, 4, 10, 1, 0, 4, 7, 10, 4, -1, -1, -1, -1] /* 226 11 */, + [3, 4, 1, 3, 8, 4, 1, 4, 11, 7, 10, 4, 11, 4, 10, -1] /* 227 7 */, + [4, 7, 10, 9, 4, 10, 9, 10, 2, 9, 2, 1, -1, -1, -1, -1] /* 228 9 */, + [9, 4, 7, 9, 7, 10, 9, 10, 1, 2, 1, 10, 0, 3, 8, -1] /* 229 6 */, + [10, 4, 7, 10, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1] /* 230 5 */, + [10, 4, 7, 10, 2, 4, 8, 4, 3, 3, 4, 2, -1, -1, -1, -1] /* 231 3 */, + [2, 11, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1] /* 232 14 */, + [9, 7, 11, 9, 4, 7, 11, 7, 2, 8, 0, 7, 2, 7, 0, -1] /* 233 7 */, + [3, 11, 7, 3, 2, 11, 7, 11, 4, 1, 0, 11, 4, 11, 0, -1] /* 234 7 */, + [1, 2, 11, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 235 4 */, + [4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1] /* 236 5 */, + [4, 1, 9, 4, 7, 1, 0, 1, 8, 8, 1, 7, -1, -1, -1, -1] /* 237 3 */, + [4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 238 2 */, + [4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 239 1 */, + [9, 8, 11, 11, 8, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 240 8 */, + [3, 9, 0, 3, 10, 9, 10, 11, 9, -1, -1, -1, -1, -1, -1, -1] /* 241 5 */, + [0, 11, 1, 0, 8, 11, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1] /* 242 5 */, + [3, 11, 1, 10, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 243 2 */, + [1, 10, 2, 1, 9, 10, 9, 8, 10, -1, -1, -1, -1, -1, -1, -1] /* 244 5 */, + [3, 9, 0, 3, 10, 9, 1, 9, 2, 2, 9, 10, -1, -1, -1, -1] /* 245 3 */, + [0, 10, 2, 8, 10, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 246 2 */, + [3, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 247 1 */, + [2, 8, 3, 2, 11, 8, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1] /* 248 5 */, + [9, 2, 11, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 249 2 */, + [2, 8, 3, 2, 11, 8, 0, 8, 1, 1, 8, 11, -1, -1, -1, -1] /* 250 3 */, + [1, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 251 1 */, + [1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 252 2 */, + [0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 253 1 */, + [0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 254 1 */, + [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] /* 255 0 */, ]; const EDGES = [ diff --git a/Sources/Filters/General/ImageMarchingCubes/example/index.js b/Sources/Filters/General/ImageMarchingCubes/example/index.js index 11eb4787e9b..f5a1faf94e4 100644 --- a/Sources/Filters/General/ImageMarchingCubes/example/index.js +++ b/Sources/Filters/General/ImageMarchingCubes/example/index.js @@ -1,11 +1,11 @@ import 'vtk.js/Sources/favicon'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkImageMarchingCubes from 'vtk.js/Sources/Filters/General/ImageMarchingCubes'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkSampleFunction from 'vtk.js/Sources/Imaging/Hybrid/SampleFunction'; -import vtkSphere from 'vtk.js/Sources/Common/DataModel/Sphere'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkImageMarchingCubes from 'vtk.js/Sources/Filters/General/ImageMarchingCubes'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkSampleFunction from 'vtk.js/Sources/Imaging/Hybrid/SampleFunction'; +import vtkSphere from 'vtk.js/Sources/Common/DataModel/Sphere'; import controlPanel from './controller.html'; @@ -28,7 +28,11 @@ actor.setMapper(mapper); // Build pipeline const sphere = vtkSphere.newInstance({ center: [0.0, 0.0, 0.0], radius: 0.5 }); -const sample = vtkSampleFunction.newInstance({ implicitFunction: sphere, sampleDimensions: [50, 50, 50], modelBounds: [-0.5, 0.5, -0.5, 0.5, -0.5, 0.5] }); +const sample = vtkSampleFunction.newInstance({ + implicitFunction: sphere, + sampleDimensions: [50, 50, 50], + modelBounds: [-0.5, 0.5, -0.5, 0.5, -0.5, 0.5], +}); const mCubes = vtkImageMarchingCubes.newInstance({ contourValue: 0.0 }); // Connect the pipeline proper @@ -73,7 +77,6 @@ document.querySelector('.mergePoints').addEventListener('change', (e) => { renderWindow.render(); }); - // ----------------------------------------------------------- renderer.resetCamera(); diff --git a/Sources/Filters/General/ImageMarchingCubes/index.js b/Sources/Filters/General/ImageMarchingCubes/index.js index 0ace5ed5d93..c8125a84e9b 100644 --- a/Sources/Filters/General/ImageMarchingCubes/index.js +++ b/Sources/Filters/General/ImageMarchingCubes/index.js @@ -1,7 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; import vtkCaseTable from './caseTable'; @@ -24,7 +24,7 @@ function vtkImageMarchingCubes(publicAPI, model) { // Retrieve scalars and voxel coordinates. i-j-k is origin of voxel. publicAPI.getVoxelScalars = (i, j, k, slice, dims, origin, spacing, s) => { // First get the indices for the voxel - ids[0] = (k * slice) + (j * dims[0]) + i; // i, j, k + ids[0] = k * slice + j * dims[0] + i; // i, j, k ids[1] = ids[0] + 1; // i+1, j, k ids[2] = ids[0] + dims[0]; // i, j+1, k ids[3] = ids[2] + 1; // i+1, j+1, k @@ -42,10 +42,10 @@ function vtkImageMarchingCubes(publicAPI, model) { // Retrieve voxel coordinates. i-j-k is origin of voxel. publicAPI.getVoxelPoints = (i, j, k, dims, origin, spacing) => { // (i,i+1),(j,j+1),(k,k+1) - i varies fastest; then j; then k - voxelPts[0] = origin[0] + (i * spacing[0]); // 0 - voxelPts[1] = origin[1] + (j * spacing[1]); - voxelPts[2] = origin[2] + (k * spacing[2]); - voxelPts[3] = voxelPts[0] + spacing[0];// 1 + voxelPts[0] = origin[0] + i * spacing[0]; // 0 + voxelPts[1] = origin[1] + j * spacing[1]; + voxelPts[2] = origin[2] + k * spacing[2]; + voxelPts[3] = voxelPts[0] + spacing[0]; // 1 voxelPts[4] = voxelPts[1]; voxelPts[5] = voxelPts[2]; voxelPts[6] = voxelPts[0]; // 2 @@ -75,46 +75,46 @@ function vtkImageMarchingCubes(publicAPI, model) { // x-direction if (i === 0) { - sp = s[(i + 1) + (j * dims[0]) + (k * slice)]; - sm = s[i + (j * dims[0]) + (k * slice)]; + sp = s[i + 1 + j * dims[0] + k * slice]; + sm = s[i + j * dims[0] + k * slice]; g[0] = (sm - sp) / spacing[0]; - } else if (i === (dims[0] - 1)) { - sp = s[i + (j * dims[0]) + (k * slice)]; - sm = s[(i - 1) + (j * dims[0]) + (k * slice)]; + } else if (i === dims[0] - 1) { + sp = s[i + j * dims[0] + k * slice]; + sm = s[i - 1 + j * dims[0] + k * slice]; g[0] = (sm - sp) / spacing[0]; } else { - sp = s[(i + 1) + (j * dims[0]) + (k * slice)]; - sm = s[(i - 1) + (j * dims[0]) + (k * slice)]; + sp = s[i + 1 + j * dims[0] + k * slice]; + sm = s[i - 1 + j * dims[0] + k * slice]; g[0] = 0.5 * (sm - sp) / spacing[0]; } // y-direction if (j === 0) { - sp = s[i + ((j + 1) * dims[0]) + (k * slice)]; - sm = s[i + (j * dims[0]) + (k * slice)]; + sp = s[i + (j + 1) * dims[0] + k * slice]; + sm = s[i + j * dims[0] + k * slice]; g[1] = (sm - sp) / spacing[1]; - } else if (j === (dims[1] - 1)) { - sp = s[i + (j * dims[0]) + (k * slice)]; - sm = s[i + ((j - 1) * dims[0]) + (k * slice)]; + } else if (j === dims[1] - 1) { + sp = s[i + j * dims[0] + k * slice]; + sm = s[i + (j - 1) * dims[0] + k * slice]; g[1] = (sm - sp) / spacing[1]; } else { - sp = s[i + ((j + 1) * dims[0]) + (k * slice)]; - sm = s[i + ((j - 1) * dims[0]) + (k * slice)]; + sp = s[i + (j + 1) * dims[0] + k * slice]; + sm = s[i + (j - 1) * dims[0] + k * slice]; g[1] = 0.5 * (sm - sp) / spacing[1]; } // z-direction if (k === 0) { - sp = s[i + (j * dims[0]) + ((k + 1) * slice)]; - sm = s[i + (j * dims[0]) + (k * slice)]; + sp = s[i + j * dims[0] + (k + 1) * slice]; + sm = s[i + j * dims[0] + k * slice]; g[2] = (sm - sp) / spacing[2]; - } else if (k === (dims[2] - 1)) { - sp = s[i + (j * dims[0]) + (k * slice)]; - sm = s[i + (j * dims[0]) + ((k - 1) * slice)]; + } else if (k === dims[2] - 1) { + sp = s[i + j * dims[0] + k * slice]; + sm = s[i + j * dims[0] + (k - 1) * slice]; g[2] = (sm - sp) / spacing[2]; } else { - sp = s[i + (j * dims[0]) + ((k + 1) * slice)]; - sm = s[i + (j * dims[0]) + ((k - 1) * slice)]; + sp = s[i + j * dims[0] + (k + 1) * slice]; + sm = s[i + j * dims[0] + (k - 1) * slice]; g[2] = 0.5 * (sm - sp) / spacing[2]; } }; @@ -135,7 +135,16 @@ function vtkImageMarchingCubes(publicAPI, model) { voxelGradients[6] = g[0]; voxelGradients[7] = g[1]; voxelGradients[8] = g[2]; - publicAPI.getPointGradient(i + 1, j + 1, k, dims, slice, spacing, scalars, g); + publicAPI.getPointGradient( + i + 1, + j + 1, + k, + dims, + slice, + spacing, + scalars, + g + ); voxelGradients[9] = g[0]; voxelGradients[10] = g[1]; voxelGradients[11] = g[2]; @@ -143,21 +152,61 @@ function vtkImageMarchingCubes(publicAPI, model) { voxelGradients[12] = g[0]; voxelGradients[13] = g[1]; voxelGradients[14] = g[2]; - publicAPI.getPointGradient(i + 1, j, k + 1, dims, slice, spacing, scalars, g); + publicAPI.getPointGradient( + i + 1, + j, + k + 1, + dims, + slice, + spacing, + scalars, + g + ); voxelGradients[15] = g[0]; voxelGradients[16] = g[1]; voxelGradients[17] = g[2]; - publicAPI.getPointGradient(i, j + 1, k + 1, dims, slice, spacing, scalars, g); + publicAPI.getPointGradient( + i, + j + 1, + k + 1, + dims, + slice, + spacing, + scalars, + g + ); voxelGradients[18] = g[0]; voxelGradients[19] = g[1]; voxelGradients[20] = g[2]; - publicAPI.getPointGradient(i + 1, j + 1, k + 1, dims, slice, spacing, scalars, g); + publicAPI.getPointGradient( + i + 1, + j + 1, + k + 1, + dims, + slice, + spacing, + scalars, + g + ); voxelGradients[21] = g[0]; voxelGradients[22] = g[1]; voxelGradients[23] = g[2]; }; - publicAPI.produceTriangles = (cVal, i, j, k, slice, dims, origin, spacing, scalars, points, tris, normals) => { + publicAPI.produceTriangles = ( + cVal, + i, + j, + k, + slice, + dims, + origin, + spacing, + scalars, + points, + tris, + normals + ) => { const CASE_MASK = [1, 2, 4, 8, 16, 32, 64, 128]; const VERT_MAP = [0, 1, 3, 2, 4, 5, 7, 6]; const xyz = []; @@ -201,22 +250,29 @@ function vtkImageMarchingCubes(publicAPI, model) { pId = edgeMap.get(edge); } if (pId === undefined) { - const t = (cVal - voxelScalars[edgeVerts[0]]) / + const t = + (cVal - voxelScalars[edgeVerts[0]]) / (voxelScalars[edgeVerts[1]] - voxelScalars[edgeVerts[0]]); const x0 = voxelPts.slice(edgeVerts[0] * 3, (edgeVerts[0] + 1) * 3); const x1 = voxelPts.slice(edgeVerts[1] * 3, (edgeVerts[1] + 1) * 3); - xyz[0] = x0[0] + (t * (x1[0] - x0[0])); - xyz[1] = x0[1] + (t * (x1[1] - x0[1])); - xyz[2] = x0[2] + (t * (x1[2] - x0[2])); + xyz[0] = x0[0] + t * (x1[0] - x0[0]); + xyz[1] = x0[1] + t * (x1[1] - x0[1]); + xyz[2] = x0[2] + t * (x1[2] - x0[2]); pId = points.length / 3; points.push(xyz[0], xyz[1], xyz[2]); if (model.computeNormals) { - const n0 = voxelGradients.slice(edgeVerts[0] * 3, (edgeVerts[0] + 1) * 3); - const n1 = voxelGradients.slice(edgeVerts[1] * 3, (edgeVerts[1] + 1) * 3); - n[0] = n0[0] + (t * (n1[0] - n0[0])); - n[1] = n0[1] + (t * (n1[1] - n0[1])); - n[2] = n0[2] + (t * (n1[2] - n0[2])); + const n0 = voxelGradients.slice( + edgeVerts[0] * 3, + (edgeVerts[0] + 1) * 3 + ); + const n1 = voxelGradients.slice( + edgeVerts[1] * 3, + (edgeVerts[1] + 1) * 3 + ); + n[0] = n0[0] + t * (n1[0] - n0[0]); + n[1] = n0[1] + t * (n1[1] - n0[1]); + n[2] = n0[2] + t * (n1[2] - n0[2]); vtkMath.normalize(n); normals.push(n[0], n[1], n[2]); } @@ -237,7 +293,8 @@ function vtkImageMarchingCubes(publicAPI, model) { } }; - publicAPI.requestData = (inData, outData) => { // implement requestData + publicAPI.requestData = (inData, outData) => { + // implement requestData const input = inData[0]; if (!input) { @@ -251,7 +308,10 @@ function vtkImageMarchingCubes(publicAPI, model) { const origin = input.getOrigin(); const spacing = input.getSpacing(); const dims = input.getDimensions(); - const s = input.getPointData().getScalars().getData(); + const s = input + .getPointData() + .getScalars() + .getData(); // Points - dynamic array const pBuffer = []; @@ -264,10 +324,23 @@ function vtkImageMarchingCubes(publicAPI, model) { // Loop over all voxels, determine case and process const slice = dims[0] * dims[1]; - for (let k = 0; k < (dims[2] - 1); ++k) { - for (let j = 0; j < (dims[1] - 1); ++j) { - for (let i = 0; i < (dims[0] - 1); ++i) { - publicAPI.produceTriangles(model.contourValue, i, j, k, slice, dims, origin, spacing, s, pBuffer, tBuffer, nBuffer); + for (let k = 0; k < dims[2] - 1; ++k) { + for (let j = 0; j < dims[1] - 1; ++j) { + for (let i = 0; i < dims[0] - 1; ++i) { + publicAPI.produceTriangles( + model.contourValue, + i, + j, + k, + slice, + dims, + origin, + spacing, + s, + pBuffer, + tBuffer, + nBuffer + ); } } } @@ -278,7 +351,11 @@ function vtkImageMarchingCubes(publicAPI, model) { polydata.getPolys().setData(new Uint32Array(tBuffer)); if (model.computeNormals) { const nData = new Float32Array(nBuffer); - const normals = vtkDataArray.newInstance({ numberOfComponents: 3, values: nData, name: 'Normals' }); + const normals = vtkDataArray.newInstance({ + numberOfComponents: 3, + values: nData, + name: 'Normals', + }); polydata.getPointData().setNormals(normals); } outData[0] = polydata; diff --git a/Sources/Filters/General/ImageMarchingSquares/caseTable.js b/Sources/Filters/General/ImageMarchingSquares/caseTable.js index f39efc95416..b3603f4e591 100644 --- a/Sources/Filters/General/ImageMarchingSquares/caseTable.js +++ b/Sources/Filters/General/ImageMarchingSquares/caseTable.js @@ -5,30 +5,25 @@ // triangle points. // ---------------------------------------------------------------------------- const MARCHING_SQUARES_CASES = [ - [-1, -1, -1, -1, -1], /* 0 */ - [0, 3, -1, -1, -1], /* 1 */ - [1, 0, -1, -1, -1], /* 2 */ - [1, 3, -1, -1, -1], /* 3 */ - [2, 1, -1, -1, -1], /* 4 */ - [0, 3, 2, 1, -1], /* 5 */ - [2, 0, -1, -1, -1], /* 6 */ - [2, 3, -1, -1, -1], /* 7 */ - [3, 2, -1, -1, -1], /* 8 */ - [0, 2, -1, -1, -1], /* 9 */ - [1, 0, 3, 2, -1], /* 10 */ - [1, 2, -1, -1, -1], /* 11 */ - [3, 1, -1, -1, -1], /* 12 */ - [0, 1, -1, -1, -1], /* 13 */ - [3, 0, -1, -1, -1], /* 14 */ - [-1, -1, -1, -1, -1], /* 15 */ + [-1, -1, -1, -1, -1] /* 0 */, + [0, 3, -1, -1, -1] /* 1 */, + [1, 0, -1, -1, -1] /* 2 */, + [1, 3, -1, -1, -1] /* 3 */, + [2, 1, -1, -1, -1] /* 4 */, + [0, 3, 2, 1, -1] /* 5 */, + [2, 0, -1, -1, -1] /* 6 */, + [2, 3, -1, -1, -1] /* 7 */, + [3, 2, -1, -1, -1] /* 8 */, + [0, 2, -1, -1, -1] /* 9 */, + [1, 0, 3, 2, -1] /* 10 */, + [1, 2, -1, -1, -1] /* 11 */, + [3, 1, -1, -1, -1] /* 12 */, + [0, 1, -1, -1, -1] /* 13 */, + [3, 0, -1, -1, -1] /* 14 */, + [-1, -1, -1, -1, -1] /* 15 */, ]; -const EDGES = [ - [0, 1], - [1, 3], - [2, 3], - [0, 2], -]; +const EDGES = [[0, 1], [1, 3], [2, 3], [0, 2]]; function getCase(index) { return MARCHING_SQUARES_CASES[index]; diff --git a/Sources/Filters/General/ImageMarchingSquares/example/index.js b/Sources/Filters/General/ImageMarchingSquares/example/index.js index f5ba68b074d..724518345a0 100644 --- a/Sources/Filters/General/ImageMarchingSquares/example/index.js +++ b/Sources/Filters/General/ImageMarchingSquares/example/index.js @@ -1,14 +1,14 @@ import 'vtk.js/Sources/favicon'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkImageMarchingSquares from 'vtk.js/Sources/Filters/General/ImageMarchingSquares'; -import vtkOutlineFilter from 'vtk.js/Sources/Filters/General/OutlineFilter'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkSampleFunction from 'vtk.js/Sources/Imaging/Hybrid/SampleFunction'; -import vtkSphere from 'vtk.js/Sources/Common/DataModel/Sphere'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkImageMarchingSquares from 'vtk.js/Sources/Filters/General/ImageMarchingSquares'; +import vtkOutlineFilter from 'vtk.js/Sources/Filters/General/OutlineFilter'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkSampleFunction from 'vtk.js/Sources/Imaging/Hybrid/SampleFunction'; +import vtkSphere from 'vtk.js/Sources/Common/DataModel/Sphere'; // import vtkPlane from 'vtk.js/Sources/Common/DataModel/Plane'; -import vtkImplicitBoolean from 'vtk.js/Sources/Common/DataModel/ImplicitBoolean'; +import vtkImplicitBoolean from 'vtk.js/Sources/Common/DataModel/ImplicitBoolean'; import controlPanel from './controller.html'; @@ -35,8 +35,15 @@ actor.setMapper(mapper); const sphere = vtkSphere.newInstance({ center: [-2.5, 0.0, 0.0], radius: 0.5 }); const sphere2 = vtkSphere.newInstance({ center: [2.5, 0.0, 0.0], radius: 0.5 }); // const plane = vtkPlane.newInstance({ origin: [0, 0, 0], normal: [0, 1, 0] }); -const impBool = vtkImplicitBoolean.newInstance({ operation: Operation.UNION, functions: [sphere, sphere2] }); -const sample = vtkSampleFunction.newInstance({ implicitFunction: impBool, sampleDimensions: [5, 3, 3], modelBounds: [-5.0, 5.0, -1.0, 1.0, -1.0, 1.0] }); +const impBool = vtkImplicitBoolean.newInstance({ + operation: Operation.UNION, + functions: [sphere, sphere2], +}); +const sample = vtkSampleFunction.newInstance({ + implicitFunction: impBool, + sampleDimensions: [5, 3, 3], + modelBounds: [-5.0, 5.0, -1.0, 1.0, -1.0, 1.0], +}); // Isocontour const mSquares = vtkImageMarchingSquares.newInstance({ slice: 1 }); @@ -48,9 +55,13 @@ mapper.setInputConnection(mSquares.getOutputPort()); // Update the pipeline to obtain metadata (range) about scalars sample.update(); const cValues = []; -const [min, max] = sample.getOutputData().getPointData().getScalars().getRange(); +const [min, max] = sample + .getOutputData() + .getPointData() + .getScalars() + .getRange(); for (let i = 0; i < 20; ++i) { - cValues[i] = min + ((i / 19) * (max - min)); + cValues[i] = min + i / 19 * (max - min); } mSquares.setContourValues(cValues); @@ -72,7 +83,7 @@ fullScreenRenderer.addController(controlPanel); document.querySelector('.volumeResolution').addEventListener('input', (e) => { const value = Number(e.target.value); sample.setSampleDimensions(value, value, value); - mSquares.setSlice((value / 2.0)); + mSquares.setSlice(value / 2.0); renderWindow.render(); }); @@ -91,7 +102,6 @@ document.querySelector('.mergePoints').addEventListener('change', (e) => { renderWindow.render(); }); - // ----------------------------------------------------------- const cam = renderer.getActiveCamera(); cam.setFocalPoint(0, 0, 0); diff --git a/Sources/Filters/General/ImageMarchingSquares/index.js b/Sources/Filters/General/ImageMarchingSquares/index.js index 2d8f5a4cedb..cba0a8f96f2 100644 --- a/Sources/Filters/General/ImageMarchingSquares/index.js +++ b/Sources/Filters/General/ImageMarchingSquares/index.js @@ -1,5 +1,5 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import macro from 'vtk.js/Sources/macro'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; import vtkCaseTable from './caseTable'; @@ -27,7 +27,7 @@ function vtkImageMarchingSquares(publicAPI, model) { // Retrieve scalars and pixel coordinates. i-j-k is origin of pixel. publicAPI.getPixelScalars = (i, j, k, slice, dims, origin, spacing, s) => { // First get the indices for the pixel - ids[0] = (k * slice) + (j * dims[0]) + i; // i, j, k + ids[0] = k * slice + j * dims[0] + i; // i, j, k ids[1] = ids[0] + 1; // i+1, j, k ids[2] = ids[0] + dims[0]; // i, j+1, k ids[3] = ids[2] + 1; // i+1, j+1, k @@ -41,8 +41,8 @@ function vtkImageMarchingSquares(publicAPI, model) { // Retrieve pixel coordinates. i-j-k is origin of pixel. publicAPI.getPixelPoints = (i, j, k, dims, origin, spacing) => { // (i,i+1),(j,j+1),(k,k+1) - i varies fastest; then j; then k - pixelPts[0] = origin[0] + (i * spacing[0]); // 0 - pixelPts[1] = origin[1] + (j * spacing[1]); + pixelPts[0] = origin[0] + i * spacing[0]; // 0 + pixelPts[1] = origin[1] + j * spacing[1]; pixelPts[2] = pixelPts[0] + spacing[0]; // 1 pixelPts[3] = pixelPts[1]; @@ -54,8 +54,19 @@ function vtkImageMarchingSquares(publicAPI, model) { pixelPts[7] = pixelPts[5]; }; - - publicAPI.produceLines = (cVal, i, j, k, slice, dims, origin, spacing, scalars, points, lines) => { + publicAPI.produceLines = ( + cVal, + i, + j, + k, + slice, + dims, + origin, + spacing, + scalars, + points, + lines + ) => { const CASE_MASK = [1, 2, 8, 4]; // case table is actually for quad const xyz = []; let pId; @@ -78,7 +89,7 @@ function vtkImageMarchingSquares(publicAPI, model) { publicAPI.getPixelPoints(i, j, k, dims, origin, spacing); - const z = origin[2] + (k * spacing[2]); + const z = origin[2] + k * spacing[2]; for (let idx = 0; pixelLines[idx] >= 0; idx += 3) { lines.push(2); for (let eid = 0; eid < 2; eid++) { @@ -95,16 +106,16 @@ function vtkImageMarchingSquares(publicAPI, model) { pId = edgeMap.get(edge); } if (pId === undefined) { - const t = (cVal - pixelScalars[edgeVerts[0]]) / + const t = + (cVal - pixelScalars[edgeVerts[0]]) / (pixelScalars[edgeVerts[1]] - pixelScalars[edgeVerts[0]]); const x0 = pixelPts.slice(edgeVerts[0] * 2, (edgeVerts[0] + 1) * 2); const x1 = pixelPts.slice(edgeVerts[1] * 2, (edgeVerts[1] + 1) * 2); - xyz[0] = x0[0] + (t * (x1[0] - x0[0])); - xyz[1] = x0[1] + (t * (x1[1] - x0[1])); + xyz[0] = x0[0] + t * (x1[0] - x0[0]); + xyz[1] = x0[1] + t * (x1[1] - x0[1]); pId = points.length / 3; points.push(xyz[0], xyz[1], z); - if (model.mergePoints) { edge[0] = ids[edgeVerts[0]]; edge[1] = ids[edgeVerts[1]]; @@ -121,7 +132,8 @@ function vtkImageMarchingSquares(publicAPI, model) { } }; - publicAPI.requestData = (inData, outData) => { // implement requestData + publicAPI.requestData = (inData, outData) => { + // implement requestData const input = inData[0]; if (!input) { @@ -135,7 +147,10 @@ function vtkImageMarchingSquares(publicAPI, model) { const origin = input.getOrigin(); const spacing = input.getSpacing(); const dims = input.getDimensions(); - const s = input.getPointData().getScalars().getData(); + const s = input + .getPointData() + .getScalars() + .getData(); // Points - dynamic array const pBuffer = []; @@ -152,9 +167,21 @@ function vtkImageMarchingSquares(publicAPI, model) { // Loop over all contour values, and then pixels, determine case and process for (let cv = 0; cv < model.contourValues.length; ++cv) { - for (let j = 0; j < (dims[1] - 1); ++j) { - for (let i = 0; i < (dims[0] - 1); ++i) { - publicAPI.produceLines(model.contourValues[cv], i, j, k, slice, dims, origin, spacing, s, pBuffer, lBuffer); + for (let j = 0; j < dims[1] - 1; ++j) { + for (let i = 0; i < dims[0] - 1; ++i) { + publicAPI.produceLines( + model.contourValues[cv], + i, + j, + k, + slice, + dims, + origin, + spacing, + s, + pBuffer, + lBuffer + ); } } edgeMap.clear(); @@ -192,10 +219,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Also make it an algorithm with one input and one output macro.algo(publicAPI, model, 1, 1); - macro.setGet(publicAPI, model, [ - 'slice', - 'mergePoints', - ]); + macro.setGet(publicAPI, model, ['slice', 'mergePoints']); // Object specific methods macro.algo(publicAPI, model, 1, 1); diff --git a/Sources/Filters/General/ImageStreamline/example/index.js b/Sources/Filters/General/ImageStreamline/example/index.js index cd9416387d9..af91f0671b5 100644 --- a/Sources/Filters/General/ImageStreamline/example/index.js +++ b/Sources/Filters/General/ImageStreamline/example/index.js @@ -1,15 +1,15 @@ import 'vtk.js/Sources/favicon'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkOutlineFilter from 'vtk.js/Sources/Filters/General/OutlineFilter'; -import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; -import vtkImageStreamline from 'vtk.js/Sources/Filters/General/ImageStreamline'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkImageData from 'vtk.js/Sources/Common/DataModel/ImageData'; -import macro from 'vtk.js/Sources/macro'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkOutlineFilter from 'vtk.js/Sources/Filters/General/OutlineFilter'; +import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; +import vtkImageStreamline from 'vtk.js/Sources/Filters/General/ImageStreamline'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkImageData from 'vtk.js/Sources/Common/DataModel/ImageData'; +import macro from 'vtk.js/Sources/macro'; import controlPanel from './controller.html'; @@ -17,7 +17,9 @@ import controlPanel from './controller.html'; // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -43,7 +45,8 @@ function addRepresentation(name, filter, props = {}) { const vecSource = macro.newInstance((publicAPI, model) => { macro.obj(publicAPI, model); // make it an object macro.algo(publicAPI, model, 0, 1); // mixin algorithm code 1 in, 1 out - publicAPI.requestData = (inData, outData) => { // implement requestData + publicAPI.requestData = (inData, outData) => { + // implement requestData if (!outData[0]) { const id = vtkImageData.newInstance(); id.setSpacing(0.1, 0.1, 0.1); @@ -58,13 +61,16 @@ const vecSource = macro.newInstance((publicAPI, model) => { for (let x = 0; x <= 9; x++) { newArray[i++] = 0.1 * x; const v = 0.1 * y; - newArray[i++] = (v * v); + newArray[i++] = v * v; newArray[i++] = 0; } } } - const da = vtkDataArray.newInstance({ numberOfComponents: 3, values: newArray }); + const da = vtkDataArray.newInstance({ + numberOfComponents: 3, + values: newArray, + }); da.setName('vectors'); const cpd = id.getPointData(); @@ -89,9 +95,18 @@ sline.setInputConnection(planeSource.getOutputPort(), 1); const outlineFilter = vtkOutlineFilter.newInstance(); outlineFilter.setInputConnection(vecSource.getOutputPort()); -addRepresentation('streamLine', sline, { diffuseColor: [0, 1, 1], lineWidth: 5 }); -addRepresentation('outline', outlineFilter, { diffuseColor: [1, 0, 0], lineWidth: 3 }); -addRepresentation('seed', planeSource, { representation: Representation.POINTS, pointSize: 10 }); +addRepresentation('streamLine', sline, { + diffuseColor: [0, 1, 1], + lineWidth: 5, +}); +addRepresentation('outline', outlineFilter, { + diffuseColor: [1, 0, 0], + lineWidth: 3, +}); +addRepresentation('seed', planeSource, { + representation: Representation.POINTS, + pointSize: 10, +}); // ----------------------------------------------------------- diff --git a/Sources/Filters/General/ImageStreamline/index.js b/Sources/Filters/General/ImageStreamline/index.js index c21198d8edb..cbd573f542b 100644 --- a/Sources/Filters/General/ImageStreamline/index.js +++ b/Sources/Filters/General/ImageStreamline/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; const { vtkErrorMacro } = macro; @@ -38,11 +38,15 @@ function vtkImageStreamline(publicAPI, model) { sf[7] = r * s * t; }; - publicAPI.computeStructuredCoordinates = (x, ijk, pcoords, - extent, - spacing, - origin, - bounds) => { + publicAPI.computeStructuredCoordinates = ( + x, + ijk, + pcoords, + extent, + spacing, + origin, + bounds + ) => { // tolerance is needed for 2D data (this is squared tolerance) const tol2 = 1e-12; // @@ -58,7 +62,7 @@ function vtkImageStreamline(publicAPI, model) { let tmpInBounds = false; const minExt = extent[i * 2]; - const maxExt = extent[(i * 2) + 1]; + const maxExt = extent[i * 2 + 1]; // check if data is one pixel thick if (minExt === maxExt) { @@ -69,15 +73,19 @@ function vtkImageStreamline(publicAPI, model) { tmpInBounds = true; } } else if (ijk[i] < minExt) { - if ((spacing[i] >= 0 && x[i] >= bounds[i * 2]) || - (spacing[i] < 0 && x[i] <= bounds[(i * 2) + 1])) { + if ( + (spacing[i] >= 0 && x[i] >= bounds[i * 2]) || + (spacing[i] < 0 && x[i] <= bounds[i * 2 + 1]) + ) { pcoords[i] = 0.0; ijk[i] = minExt; tmpInBounds = true; } } else if (ijk[i] >= maxExt) { - if ((spacing[i] >= 0 && x[i] <= bounds[(i * 2) + 1]) || - (spacing[i] < 0 && x[i] >= bounds[(i * 2)])) { + if ( + (spacing[i] >= 0 && x[i] <= bounds[i * 2 + 1]) || + (spacing[i] < 0 && x[i] >= bounds[i * 2]) + ) { // make sure index is within the allowed cell index range pcoords[i] = 1.0; ijk[i] = maxExt - 1; @@ -95,20 +103,28 @@ function vtkImageStreamline(publicAPI, model) { }; publicAPI.getVoxelIndices = (ijk, dims, ids) => { - ids[0] = (ijk[2] * dims[0] * dims[1]) + (ijk[1] * dims[0]) + ijk[0]; + ids[0] = ijk[2] * dims[0] * dims[1] + ijk[1] * dims[0] + ijk[0]; ids[1] = ids[0] + 1; // i+1, j, k ids[2] = ids[0] + dims[0]; // i, j+1, k ids[3] = ids[2] + 1; // i+1, j+1, k - ids[4] = ids[0] + (dims[0] * dims[1]); // i, j, k+1 + ids[4] = ids[0] + dims[0] * dims[1]; // i, j, k+1 ids[5] = ids[4] + 1; // i+1, j, k+1 ids[6] = ids[4] + dims[0]; // i, j+1, k+1 ids[7] = ids[6] + 1; // i+1, j+1, k+1 }; publicAPI.vectorAt = (xyz, velArray, image, velAtArg) => { - if (!publicAPI.computeStructuredCoordinates(xyz, indices, paramCoords, - image.getExtent(), image.getSpacing(), - image.getOrigin(), image.getBounds())) { + if ( + !publicAPI.computeStructuredCoordinates( + xyz, + indices, + paramCoords, + image.getExtent(), + image.getSpacing(), + image.getOrigin(), + image.getBounds() + ) + ) { return false; } @@ -140,7 +156,7 @@ function vtkImageStreamline(publicAPI, model) { } // Now find the mid point for (let i = 0; i < 3; i++) { - xtmp[i] = xyz[i] + ((delT / 2.0) * velAt[i]); + xtmp[i] = xyz[i] + delT / 2.0 * velAt[i]; } // Use the velocity @ that point to project if (!publicAPI.vectorAt(xtmp, velArray, image, velAt)) { @@ -175,7 +191,7 @@ function vtkImageStreamline(publicAPI, model) { break; } for (let i = 0; i < 3; i++) { - pointsBuffer[(3 * step) + i] = xyz[i]; + pointsBuffer[3 * step + i] = xyz[i]; } } @@ -199,7 +215,8 @@ function vtkImageStreamline(publicAPI, model) { return retVal; }; - publicAPI.requestData = (inData, outData) => { // implement requestData + publicAPI.requestData = (inData, outData) => { + // implement requestData const input = inData[0]; const seeds = inData[1]; @@ -220,7 +237,12 @@ function vtkImageStreamline(publicAPI, model) { const datas = []; const vectors = input.getPointData().getVectors(); for (let i = 0; i < nSeeds; i++) { - const retVal = publicAPI.streamIntegrate(vectors, input, seedPts.getTuple(i), offset); + const retVal = publicAPI.streamIntegrate( + vectors, + input, + seedPts.getTuple(i), + offset + ); offset += retVal[0].length / 3; datas.push(retVal); } @@ -271,10 +293,7 @@ export function extend(publicAPI, model, initialValues = {}) { macro.algo(publicAPI, model, 2, 1); // Generate macros for properties - macro.setGet(publicAPI, model, [ - 'integrationStep', - 'maximumNumberOfSteps', - ]); + macro.setGet(publicAPI, model, ['integrationStep', 'maximumNumberOfSteps']); // Object specific methods vtkImageStreamline(publicAPI, model); diff --git a/Sources/Filters/General/ImageStreamline/test/testStreamline.js b/Sources/Filters/General/ImageStreamline/test/testStreamline.js index e138d42235e..12c684f6256 100644 --- a/Sources/Filters/General/ImageStreamline/test/testStreamline.js +++ b/Sources/Filters/General/ImageStreamline/test/testStreamline.js @@ -1,15 +1,16 @@ import test from 'tape-catch'; -import macro from 'vtk.js/Sources/macro'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkImageData from 'vtk.js/Sources/Common/DataModel/ImageData'; +import macro from 'vtk.js/Sources/macro'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkImageData from 'vtk.js/Sources/Common/DataModel/ImageData'; import vtkImageStreamline from 'vtk.js/Sources/Filters/General/ImageStreamline'; -import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; +import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; const vecSource = macro.newInstance((publicAPI, model) => { macro.obj(publicAPI, model); // make it an object macro.algo(publicAPI, model, 0, 1); // mixin algorithm code 1 in, 1 out - publicAPI.requestData = (inData, outData) => { // implement requestData + publicAPI.requestData = (inData, outData) => { + // implement requestData if (!outData[0]) { const id = vtkImageData.newInstance(); id.setSpacing(0.1, 0.1, 0.1); @@ -24,13 +25,16 @@ const vecSource = macro.newInstance((publicAPI, model) => { for (let x = 0; x <= 9; x++) { newArray[i++] = 0.1 * x; const v = 0.1 * y; - newArray[i++] = (v * v); + newArray[i++] = v * v; newArray[i++] = 0; } } } - const da = vtkDataArray.newInstance({ numberOfComponents: 3, values: newArray }); + const da = vtkDataArray.newInstance({ + numberOfComponents: 3, + values: newArray, + }); da.setName('vectors'); const cpd = id.getPointData(); @@ -47,16 +51,27 @@ test('Test vtkImageStreamline instance', (t) => { const instance = vtkImageStreamline.newInstance(); t.ok(instance, 'Make sure the instance exist'); - t.equal(instance.getIntegrationStep(), 1, 'Default integrationStep should be 1'); - t.equal(instance.getMaximumNumberOfSteps(), 1000, 'Default MaximumNumberOfSteps should be 1000'); + t.equal( + instance.getIntegrationStep(), + 1, + 'Default integrationStep should be 1' + ); + t.equal( + instance.getMaximumNumberOfSteps(), + 1000, + 'Default MaximumNumberOfSteps should be 1000' + ); instance.setIntegrationStep(0.1); - t.equal(instance.getIntegrationStep(), 0.1, 'Updated value of integrationStep should be 0.1'); + t.equal( + instance.getIntegrationStep(), + 0.1, + 'Updated value of integrationStep should be 0.1' + ); t.end(); }); - test('Test vtkImageStreamline execution', (t) => { const planeSource = vtkPlaneSource.newInstance(); planeSource.setOrigin(0.05, 0.05, 0.05); @@ -75,11 +90,16 @@ test('Test vtkImageStreamline execution', (t) => { const output = filter.getOutputData(); t.ok(output, 'Output dataset exist'); - t.equal(output.isA('vtkPolyData'), true, 'The output dataset should be a vtkPolydata'); + t.equal( + output.isA('vtkPolyData'), + true, + 'The output dataset should be a vtkPolydata' + ); t.equal( output.getPoints().getNumberOfPoints(), 2228, - 'The number of points should be 2228'); + 'The number of points should be 2228' + ); t.end(); }); diff --git a/Sources/Filters/General/MoleculeToRepresentation/index.js b/Sources/Filters/General/MoleculeToRepresentation/index.js index a07f6c9ed8b..70a89c7ccce 100644 --- a/Sources/Filters/General/MoleculeToRepresentation/index.js +++ b/Sources/Filters/General/MoleculeToRepresentation/index.js @@ -1,9 +1,9 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import macro from 'vtk.js/Sources/macro'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; -import atomElem from 'vtk.js/Utilities/XMLConverter/chemistry/elements.json'; +import atomElem from 'vtk.js/Utilities/XMLConverter/chemistry/elements.json'; const { vtkErrorMacro, vtkDebugMacro } = macro; @@ -12,7 +12,9 @@ const { vtkErrorMacro, vtkDebugMacro } = macro; // ---------------------------------------------------------------------------- const ATOMS = {}; -atomElem.atoms.forEach((a) => { ATOMS[a.atomicNumber] = a; }); +atomElem.atoms.forEach((a) => { + ATOMS[a.atomicNumber] = a; +}); // ---------------------------------------------------------------------------- // vtkMoleculeToRepresentation methods @@ -146,22 +148,27 @@ function vtkMoleculeToRepresentation(publicAPI, model) { const cutoff = covalentArray[i] + covalentArray[j] + model.tolerance; const jPtsIdx = j * 3; const iPtsIdx = i * 3; - const diff = [pointsArray[jPtsIdx], + const diff = [ + pointsArray[jPtsIdx], pointsArray[jPtsIdx + 1], - pointsArray[jPtsIdx + 2]]; + pointsArray[jPtsIdx + 2], + ]; diff[0] -= pointsArray[iPtsIdx]; diff[1] -= pointsArray[iPtsIdx + 1]; diff[2] -= pointsArray[iPtsIdx + 2]; - if (Math.abs(diff[0]) > cutoff || - Math.abs(diff[1]) > cutoff || - Math.abs(diff[2]) > cutoff) { + if ( + Math.abs(diff[0]) > cutoff || + Math.abs(diff[1]) > cutoff || + Math.abs(diff[2]) > cutoff + ) { continue; } // Check radius and add bond if needed const cutoffSq = cutoff * cutoff; - const diffsq = (diff[0] * diff[0]) + (diff[1] * diff[1]) + (diff[2] * diff[2]); + const diffsq = + diff[0] * diff[0] + diff[1] * diff[1] + diff[2] * diff[2]; if (diffsq < cutoffSq && diffsq > 0.1) { // appendBond between i and j bondIndex.push(i); @@ -177,33 +184,48 @@ function vtkMoleculeToRepresentation(publicAPI, model) { for (let index = 0; index < numBonds; index++) { // appendBond between i and j const i = bondIndex[index * 2]; - const j = bondIndex[(index * 2) + 1]; + const j = bondIndex[index * 2 + 1]; // Do not append if i or j belong to element to not display - if (model.hideElements.includes(ATOMS[atomicNumber[i]].id) || - model.hideElements.includes(ATOMS[atomicNumber[j]].id)) { + if ( + model.hideElements.includes(ATOMS[atomicNumber[i]].id) || + model.hideElements.includes(ATOMS[atomicNumber[j]].id) + ) { continue; } const jPtsIdx = j * 3; const iPtsIdx = i * 3; - const diff = [pointsArray[jPtsIdx], + const diff = [ + pointsArray[jPtsIdx], pointsArray[jPtsIdx + 1], - pointsArray[jPtsIdx + 2]]; + pointsArray[jPtsIdx + 2], + ]; diff[0] -= pointsArray[iPtsIdx]; diff[1] -= pointsArray[iPtsIdx + 1]; diff[2] -= pointsArray[iPtsIdx + 2]; - const diffsq = (diff[0] * diff[0]) + (diff[1] * diff[1]) + (diff[2] * diff[2]); - - const radiusJsq = radiusArray[j] * model.atomicRadiusScaleFactor * radiusArray[j] * model.atomicRadiusScaleFactor; - const radiusIsq = radiusArray[i] * model.atomicRadiusScaleFactor * radiusArray[i] * model.atomicRadiusScaleFactor; + const diffsq = diff[0] * diff[0] + diff[1] * diff[1] + diff[2] * diff[2]; + + const radiusJsq = + radiusArray[j] * + model.atomicRadiusScaleFactor * + radiusArray[j] * + model.atomicRadiusScaleFactor; + const radiusIsq = + radiusArray[i] * + model.atomicRadiusScaleFactor * + radiusArray[i] * + model.atomicRadiusScaleFactor; let bondDelta = (2 + model.deltaBondFactor) * model.bondRadius; // distance between 2 bonds // scale bonds if total distance from bonds is bigger than 2r*factor with r = min(r_i, r_j) - const r = Math.min(radiusArray[i] * model.atomicRadiusScaleFactor, radiusArray[j] * model.atomicRadiusScaleFactor); - const t = ((bondOrder[index] - 1) * bondDelta) + (2 * model.bondRadius); + const r = Math.min( + radiusArray[i] * model.atomicRadiusScaleFactor, + radiusArray[j] * model.atomicRadiusScaleFactor + ); + const t = (bondOrder[index] - 1) * bondDelta + 2 * model.bondRadius; if (t > 2 * r * 0.6) { - model.bondRadius *= ((2 * r * 0.6) / t); + model.bondRadius *= 2 * r * 0.6 / t; // recompute bondDelta bondDelta = (2 + model.deltaBondFactor) * model.bondRadius; // distance between 2 bonds } @@ -219,37 +241,55 @@ function vtkMoleculeToRepresentation(publicAPI, model) { // - odd order: x * 2 <=> x * 2 + 1 - 1 // - even order: x * 2 + 1 // (with x the loop <=> floor(k/2)) - const oddOrEven = ((bondOrder[index]) % 2); // zero if even order / one if odd order + const oddOrEven = bondOrder[index] % 2; // zero if even order / one if odd order for (let k = oddOrEven; k < bondOrder[index] + oddOrEven; k++) { // dist from center to bond depending of number of bond - let offset = ((((Math.floor(k / 2) * 2) + 1) - oddOrEven) * bondDelta) / 2; + let offset = (Math.floor(k / 2) * 2 + 1 - oddOrEven) * bondDelta / 2; // offset between center of SphereJ (resp. SphereI) and the start of the bond - const offsetJ = Math.sqrt(radiusJsq - Math.pow(model.bondRadius + offset, 2)); - const offsetI = Math.sqrt(radiusIsq - Math.pow(model.bondRadius + offset, 2)); + const offsetJ = Math.sqrt( + radiusJsq - Math.pow(model.bondRadius + offset, 2) + ); + const offsetI = Math.sqrt( + radiusIsq - Math.pow(model.bondRadius + offset, 2) + ); const vectUnitJI = [ diff[0] / Math.sqrt(diffsq), diff[1] / Math.sqrt(diffsq), - diff[2] / Math.sqrt(diffsq)]; + diff[2] / Math.sqrt(diffsq), + ]; const vectUnitJIperp = [0, 0, 0]; // Search perp to vectUnitJI: find axis != 0 to create vectUnitJIperp such as dot(vectUnitJIperp,vectUnitJI) = 0 for (let coord = 0; coord < 3; coord++) { if (Math.abs(vectUnitJI[coord]) < 0.000001) { continue; } - vectUnitJIperp[coord] = (-((vectUnitJI[(coord + 2) % 3] * vectUnitJI[(coord + 2) % 3]) + - (vectUnitJI[(coord + 1) % 3] * vectUnitJI[(coord + 1) % 3])) / vectUnitJI[coord]); - vectUnitJIperp[(coord + 1) % 3] = (vectUnitJI[(coord + 1) % 3]); - vectUnitJIperp[(coord + 2) % 3] = (vectUnitJI[(coord + 2) % 3]); + vectUnitJIperp[coord] = + -( + vectUnitJI[(coord + 2) % 3] * vectUnitJI[(coord + 2) % 3] + + vectUnitJI[(coord + 1) % 3] * vectUnitJI[(coord + 1) % 3] + ) / vectUnitJI[coord]; + vectUnitJIperp[(coord + 1) % 3] = vectUnitJI[(coord + 1) % 3]; + vectUnitJIperp[(coord + 2) % 3] = vectUnitJI[(coord + 2) % 3]; vtkMath.normalize(vectUnitJIperp); break; } offset *= Math.pow(-1, k % 2); const bondPos = [ - pointsArray[jPtsIdx] - (((offsetJ - offsetI) * vectUnitJI[0]) / 2.0) - (diff[0] / 2.0) + (offset * vectUnitJIperp[0]), - pointsArray[jPtsIdx + 1] - (((offsetJ - offsetI) * vectUnitJI[1]) / 2.0) - (diff[1] / 2.0) + (offset * vectUnitJIperp[1]), - pointsArray[jPtsIdx + 2] - (((offsetJ - offsetI) * vectUnitJI[2]) / 2.0) - (diff[2] / 2.0) + (offset * vectUnitJIperp[2])]; + pointsArray[jPtsIdx] - + (offsetJ - offsetI) * vectUnitJI[0] / 2.0 - + diff[0] / 2.0 + + offset * vectUnitJIperp[0], + pointsArray[jPtsIdx + 1] - + (offsetJ - offsetI) * vectUnitJI[1] / 2.0 - + diff[1] / 2.0 + + offset * vectUnitJIperp[1], + pointsArray[jPtsIdx + 2] - + (offsetJ - offsetI) * vectUnitJI[2] / 2.0 - + diff[2] / 2.0 + + offset * vectUnitJIperp[2], + ]; const bondLenght = Math.sqrt(diffsq) - offsetJ - offsetI; addBond(bondPos, vectUnitJI, bondLenght); @@ -259,22 +299,37 @@ function vtkMoleculeToRepresentation(publicAPI, model) { SphereData.getPoints().setData(pointsData, 3); if (radiusArray) { - const scales = vtkDataArray.newInstance({ numberOfComponents: 1, values: scaleData, name: publicAPI.getSphereScaleArrayName() }); + const scales = vtkDataArray.newInstance({ + numberOfComponents: 1, + values: scaleData, + name: publicAPI.getSphereScaleArrayName(), + }); SphereData.getPointData().addArray(scales); } if (colorArray) { - const colors = vtkDataArray.newInstance({ numberOfComponents: 3, values: Uint8Array.from(colorData), name: 'colors' }); + const colors = vtkDataArray.newInstance({ + numberOfComponents: 3, + values: Uint8Array.from(colorData), + name: 'colors', + }); SphereData.getPointData().setScalars(colors); } - StickData.getPoints().setData(bondPositionData, 3); - const stickScales = vtkDataArray.newInstance({ numberOfComponents: 2, values: bondScaleData, name: 'stickScales' }); + const stickScales = vtkDataArray.newInstance({ + numberOfComponents: 2, + values: bondScaleData, + name: 'stickScales', + }); StickData.getPointData().addArray(stickScales); - const orientation = vtkDataArray.newInstance({ numberOfComponents: 3, values: bondOrientationData, name: 'orientation' }); + const orientation = vtkDataArray.newInstance({ + numberOfComponents: 3, + values: bondOrientationData, + name: 'orientation', + }); StickData.getPointData().addArray(orientation); // Update output @@ -317,7 +372,10 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkMoleculeToRepresentation'); +export const newInstance = macro.newInstance( + extend, + 'vtkMoleculeToRepresentation' +); // ---------------------------------------------------------------------------- diff --git a/Sources/Filters/General/MoleculeToRepresentation/test/testMultipleBonds.js b/Sources/Filters/General/MoleculeToRepresentation/test/testMultipleBonds.js index d3690e63da4..a7323e8e0d9 100644 --- a/Sources/Filters/General/MoleculeToRepresentation/test/testMultipleBonds.js +++ b/Sources/Filters/General/MoleculeToRepresentation/test/testMultipleBonds.js @@ -1,18 +1,17 @@ -import test from 'tape-catch'; -import testUtils from 'vtk.js/Sources/Testing/testUtils'; +import test from 'tape-catch'; +import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMolecule from 'vtk.js/Sources/Common/DataModel/Molecule'; -import vtkMoleculeToRepresentation from 'vtk.js/Sources/Filters/General/MoleculeToRepresentation'; -import vtkSphereMapper from 'vtk.js/Sources/Rendering/Core/SphereMapper'; -import vtkStickMapper from 'vtk.js/Sources/Rendering/Core/StickMapper'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; - -import testMolecule from 'vtk.js/Data/molecule/test-multiple-bonds.cjson'; -import baseline from './testMolecule_multiple_bonds.png'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMolecule from 'vtk.js/Sources/Common/DataModel/Molecule'; +import vtkMoleculeToRepresentation from 'vtk.js/Sources/Filters/General/MoleculeToRepresentation'; +import vtkSphereMapper from 'vtk.js/Sources/Rendering/Core/SphereMapper'; +import vtkStickMapper from 'vtk.js/Sources/Rendering/Core/StickMapper'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import testMolecule from 'vtk.js/Data/molecule/test-multiple-bonds.cjson'; +import baseline from './testMolecule_multiple_bonds.png'; test.onlyIfWebGL('Test MultipleBonds', (t) => { const gc = testUtils.createGarbageCollector(t); @@ -20,7 +19,9 @@ test.onlyIfWebGL('Test MultipleBonds', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -72,5 +73,12 @@ test.onlyIfWebGL('Test MultipleBonds', (t) => { // capturing and comparing the images const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Filters/General/MoleculeToRepresentation/testMultipleBonds', t, 1, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Filters/General/MoleculeToRepresentation/testMultipleBonds', + t, + 1, + gc.releaseResources + ); }); diff --git a/Sources/Filters/General/OutlineFilter/example/index.js b/Sources/Filters/General/OutlineFilter/example/index.js index 38495355d55..4fcb1155d3b 100644 --- a/Sources/Filters/General/OutlineFilter/example/index.js +++ b/Sources/Filters/General/OutlineFilter/example/index.js @@ -1,11 +1,11 @@ import 'vtk.js/Sources/favicon'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkPointSource from 'vtk.js/Sources/Filters/Sources/PointSource'; -import vtkOutlineFilter from 'vtk.js/Sources/Filters/General/OutlineFilter'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkPointSource from 'vtk.js/Sources/Filters/Sources/PointSource'; +import vtkOutlineFilter from 'vtk.js/Sources/Filters/General/OutlineFilter'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; import controlPanel from './controlPanel.html'; @@ -13,7 +13,9 @@ import controlPanel from './controlPanel.html'; // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -38,7 +40,10 @@ function addRepresentation(name, filter, props = {}) { vtkMath.randomSeed(141592); -const pointSource = vtkPointSource.newInstance({ numberOfPoints: 25, radius: 0.25 }); +const pointSource = vtkPointSource.newInstance({ + numberOfPoints: 25, + radius: 0.25, +}); const outline = vtkOutlineFilter.newInstance(); outline.setInputConnection(pointSource.getOutputPort()); diff --git a/Sources/Filters/General/OutlineFilter/index.js b/Sources/Filters/General/OutlineFilter/index.js index 5dbb739181a..430bb070ab6 100644 --- a/Sources/Filters/General/OutlineFilter/index.js +++ b/Sources/Filters/General/OutlineFilter/index.js @@ -1,8 +1,9 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; const { vtkErrorMacro } = macro; +// prettier-ignore const BOUNDS_MAP = [ 0, 2, 4, // pt 0 1, 2, 4, // pt 1 @@ -14,6 +15,7 @@ const BOUNDS_MAP = [ 1, 3, 5, // pt 7 ]; +// prettier-ignore const LINE_ARRAY = [ 2, 0, 1, 2, 2, 3, @@ -37,7 +39,8 @@ function vtkOutlineFilter(publicAPI, model) { // Set our className model.classHierarchy.push('vtkOutlineFilter'); - publicAPI.requestData = (inData, outData) => { // implement requestData + publicAPI.requestData = (inData, outData) => { + // implement requestData const input = inData[0]; if (!input) { @@ -48,7 +51,9 @@ function vtkOutlineFilter(publicAPI, model) { const bounds = input.getBounds(); const output = vtkPolyData.newInstance(); - output.getPoints().setData(Float32Array.from(BOUNDS_MAP.map(idx => bounds[idx])), 3); + output + .getPoints() + .setData(Float32Array.from(BOUNDS_MAP.map((idx) => bounds[idx])), 3); output.getLines().setData(Uint16Array.from(LINE_ARRAY)); outData[0] = output; @@ -59,8 +64,7 @@ function vtkOutlineFilter(publicAPI, model) { // Object factory // ---------------------------------------------------------------------------- -const DEFAULT_VALUES = { -}; +const DEFAULT_VALUES = {}; // ---------------------------------------------------------------------------- diff --git a/Sources/Filters/General/WarpScalar/example/index.js b/Sources/Filters/General/WarpScalar/example/index.js index d1e22152771..6fc0d33c080 100644 --- a/Sources/Filters/General/WarpScalar/example/index.js +++ b/Sources/Filters/General/WarpScalar/example/index.js @@ -1,14 +1,14 @@ import 'vtk.js/Sources/favicon'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import macro from 'vtk.js/Sources/macro'; -import vtk from 'vtk.js/Sources/vtk'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkCamera from 'vtk.js/Sources/Rendering/Core/Camera'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; -import vtkWarpScalar from 'vtk.js/Sources/Filters/General/WarpScalar'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import macro from 'vtk.js/Sources/macro'; +import vtk from 'vtk.js/Sources/vtk'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkCamera from 'vtk.js/Sources/Rendering/Core/Camera'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; +import vtkWarpScalar from 'vtk.js/Sources/Filters/General/WarpScalar'; import controlPanel from './controller.html'; @@ -16,7 +16,9 @@ import controlPanel from './controller.html'; // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -37,7 +39,10 @@ cam.setPosition(0, 0, 10); cam.setClippingRange(0.1, 50.0); // Build pipeline -const sphereSource = vtkSphereSource.newInstance({ thetaResolution: 40, phiResolution: 41 }); +const sphereSource = vtkSphereSource.newInstance({ + thetaResolution: 40, + phiResolution: 41, +}); const filter = vtkWarpScalar.newInstance({ scaleFactor: 0, useNormal: false }); // create a filter on the fly, sort of cool, this is a random scalars @@ -46,9 +51,12 @@ const filter = vtkWarpScalar.newInstance({ scaleFactor: 0, useNormal: false }); const randFilter = macro.newInstance((publicAPI, model) => { macro.obj(publicAPI, model); // make it an object macro.algo(publicAPI, model, 1, 1); // mixin algorithm code 1 in, 1 out - publicAPI.requestData = (inData, outData) => { // implement requestData + publicAPI.requestData = (inData, outData) => { + // implement requestData if (!outData[0] || inData[0].getMTime() > outData[0].getMTime()) { - const newArray = new Float32Array(inData[0].getPoints().getNumberOfPoints()); + const newArray = new Float32Array( + inData[0].getPoints().getNumberOfPoints() + ); for (let i = 0; i < newArray.length; i++) { newArray[i] = i % 2 ? 1 : 0; } @@ -86,7 +94,7 @@ fullScreenRenderer.addController(controlPanel); // Checkbox document.querySelector('.useNormal').addEventListener('change', (e) => { - const useNormal = !!(e.target.checked); + const useNormal = !!e.target.checked; filter.set({ useNormal }); renderWindow.render(); }); diff --git a/Sources/Filters/General/WarpScalar/index.js b/Sources/Filters/General/WarpScalar/index.js index 1a4a7ca03f1..834687e0619 100644 --- a/Sources/Filters/General/WarpScalar/index.js +++ b/Sources/Filters/General/WarpScalar/index.js @@ -1,5 +1,5 @@ -import vtk from 'vtk.js/Sources/vtk'; -import macro from 'vtk.js/Sources/macro'; +import vtk from 'vtk.js/Sources/vtk'; +import macro from 'vtk.js/Sources/macro'; import vtkPoints from 'vtk.js/Sources/Common/Core/Points'; const { vtkDebugMacro, vtkErrorMacro } = macro; @@ -12,7 +12,8 @@ function vtkWarpScalar(publicAPI, model) { // Set our className model.classHierarchy.push('vtkWarpScalar'); - publicAPI.requestData = (inData, outData) => { // implement requestData + publicAPI.requestData = (inData, outData) => { + // implement requestData const input = inData[0]; if (!input) { @@ -41,9 +42,9 @@ function vtkWarpScalar(publicAPI, model) { const normal = [0, 0, 1]; if (inNormals && !model.useNormal) { pointNormal = (id, array) => [ - array.getData()[(id * 3)], - array.getData()[(id * 3) + 1], - array.getData()[(id * 3) + 2], + array.getData()[id * 3], + array.getData()[id * 3 + 1], + array.getData()[id * 3 + 2], ]; vtkDebugMacro('Using data normals'); } else if (publicAPI.getXyPlane()) { @@ -74,9 +75,11 @@ function vtkWarpScalar(publicAPI, model) { s = scalarDataArray[ptId * nc]; } - newPtsData[ptOffset] = inPoints[ptOffset] + (model.scaleFactor * s * n[0]); - newPtsData[ptOffset + 1] = inPoints[ptOffset + 1] + (model.scaleFactor * s * n[1]); - newPtsData[ptOffset + 2] = inPoints[ptOffset + 2] + (model.scaleFactor * s * n[2]); + newPtsData[ptOffset] = inPoints[ptOffset] + model.scaleFactor * s * n[0]; + newPtsData[ptOffset + 1] = + inPoints[ptOffset + 1] + model.scaleFactor * s * n[1]; + newPtsData[ptOffset + 2] = + inPoints[ptOffset + 2] + model.scaleFactor * s * n[2]; } const newDataSet = vtk({ vtkClass: input.getClassName() }); @@ -113,15 +116,9 @@ export function extend(publicAPI, model, initialValues = {}) { macro.algo(publicAPI, model, 1, 1); // Generate macros for properties - macro.setGet(publicAPI, model, [ - 'scaleFactor', - 'useNormal', - 'xyPlane', - ]); - - macro.setGetArray(publicAPI, model, [ - 'normal', - ], 3); + macro.setGet(publicAPI, model, ['scaleFactor', 'useNormal', 'xyPlane']); + + macro.setGetArray(publicAPI, model, ['normal'], 3); // Object specific methods vtkWarpScalar(publicAPI, model); diff --git a/Sources/Filters/General/WarpScalar/test/testWarp.js b/Sources/Filters/General/WarpScalar/test/testWarp.js index e5bf90e7436..eaf3ba3310e 100644 --- a/Sources/Filters/General/WarpScalar/test/testWarp.js +++ b/Sources/Filters/General/WarpScalar/test/testWarp.js @@ -1,6 +1,6 @@ import test from 'tape-catch'; -import vtkWarpScalar from 'vtk.js/Sources/Filters/General/WarpScalar'; +import vtkWarpScalar from 'vtk.js/Sources/Filters/General/WarpScalar'; import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; test('Test vtkWarpScalar instance', (t) => { @@ -11,15 +11,22 @@ test('Test vtkWarpScalar instance', (t) => { t.equal(instance.getScaleFactor(), 1, 'Default ScaleFactor should be 1'); t.equal(instance.getUseNormal(), false, 'Default UseNormal should be false'); t.equal(instance.getXyPlane(), false, 'Default xyPlane should be false'); - t.deepEqual(instance.getNormal(), [0, 0, 1], 'Default normal should be [0, 0, 1]'); + t.deepEqual( + instance.getNormal(), + [0, 0, 1], + 'Default normal should be [0, 0, 1]' + ); instance.setScaleFactor(2.5); - t.equal(instance.getScaleFactor(), 2.5, 'Updated value of ScaleFactor should be 2.5'); + t.equal( + instance.getScaleFactor(), + 2.5, + 'Updated value of ScaleFactor should be 2.5' + ); t.end(); }); - test('Test vtkWarpScalar execution', (t) => { const source = vtkSphereSource.newInstance(); const filter = vtkWarpScalar.newInstance(); @@ -30,11 +37,20 @@ test('Test vtkWarpScalar execution', (t) => { const output = filter.getOutputData(); t.ok(output, 'Output dataset exist'); - t.equal(output.isA('vtkPolyData'), true, 'The output dataset should be a vtkPolydata'); + t.equal( + output.isA('vtkPolyData'), + true, + 'The output dataset should be a vtkPolydata' + ); t.equal( input.getPoints().getNumberOfPoints(), output.getPoints().getNumberOfPoints(), - `The number of points do not change between input ${input.getPoints().getNumberOfPoints()} and output ${output.getPoints().getNumberOfPoints()}`); + `The number of points do not change between input ${input + .getPoints() + .getNumberOfPoints()} and output ${output + .getPoints() + .getNumberOfPoints()}` + ); t.end(); }); diff --git a/Sources/Filters/General/index.js b/Sources/Filters/General/index.js index ee63c57e7a8..b125f61517d 100644 --- a/Sources/Filters/General/index.js +++ b/Sources/Filters/General/index.js @@ -1,11 +1,11 @@ -import vtkAppendPolyData from './AppendPolyData'; -import vtkCalculator from './Calculator'; -import vtkImageMarchingCubes from './ImageMarchingCubes'; -import vtkImageMarchingSquares from './ImageMarchingSquares'; -import vtkImageStreamline from './ImageStreamline'; +import vtkAppendPolyData from './AppendPolyData'; +import vtkCalculator from './Calculator'; +import vtkImageMarchingCubes from './ImageMarchingCubes'; +import vtkImageMarchingSquares from './ImageMarchingSquares'; +import vtkImageStreamline from './ImageStreamline'; import vtkMoleculeToRepresentation from './MoleculeToRepresentation'; -import vtkOutlineFilter from './OutlineFilter'; -import vtkWarpScalar from './WarpScalar'; +import vtkOutlineFilter from './OutlineFilter'; +import vtkWarpScalar from './WarpScalar'; export default { vtkAppendPolyData, diff --git a/Sources/Filters/Sources/ArrowSource/example/index.js b/Sources/Filters/Sources/ArrowSource/example/index.js index 91b0798c374..267dcd45576 100644 --- a/Sources/Filters/Sources/ArrowSource/example/index.js +++ b/Sources/Filters/Sources/ArrowSource/example/index.js @@ -1,9 +1,9 @@ import 'vtk.js/Sources/favicon'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkArrowSource from 'vtk.js/Sources/Filters/Sources/ArrowSource'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkArrowSource from 'vtk.js/Sources/Filters/Sources/ArrowSource'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import controlPanel from './controlPanel.html'; @@ -11,7 +11,9 @@ import controlPanel from './controlPanel.html'; // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -45,7 +47,13 @@ renderWindow.render(); fullScreenRenderer.addController(controlPanel); -['tipResolution', 'tipRadius', 'tipLength', 'shaftResolution', 'shaftRadius'].forEach((propertyName) => { +[ + 'tipResolution', + 'tipRadius', + 'tipLength', + 'shaftResolution', + 'shaftRadius', +].forEach((propertyName) => { document.querySelector(`.${propertyName}`).addEventListener('input', (e) => { const value = Number(e.target.value); pipelines[0].arrowSource.set({ [propertyName]: value }); @@ -54,7 +62,7 @@ fullScreenRenderer.addController(controlPanel); }); document.querySelector('.invert').addEventListener('change', (e) => { - const invert = !!(e.target.checked); + const invert = !!e.target.checked; pipelines[0].arrowSource.set({ invert }); renderWindow.render(); }); diff --git a/Sources/Filters/Sources/ArrowSource/index.js b/Sources/Filters/Sources/ArrowSource/index.js index 0719391a3e5..40c8f66a561 100644 --- a/Sources/Filters/Sources/ArrowSource/index.js +++ b/Sources/Filters/Sources/ArrowSource/index.js @@ -1,8 +1,8 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkAppendPolyData from 'vtk.js/Sources/Filters/General/AppendPolyData'; -import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; -import vtkCylinderSource from 'vtk.js/Sources/Filters/Sources/CylinderSource'; -import vtkMatrixBuilder from 'vtk.js/Sources/Common/Core/MatrixBuilder'; +import macro from 'vtk.js/Sources/macro'; +import vtkAppendPolyData from 'vtk.js/Sources/Filters/General/AppendPolyData'; +import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; +import vtkCylinderSource from 'vtk.js/Sources/Filters/Sources/CylinderSource'; +import vtkMatrixBuilder from 'vtk.js/Sources/Common/Core/MatrixBuilder'; // ---------------------------------------------------------------------------- // vtkArrowSource methods @@ -25,7 +25,10 @@ function vtkArrowSource(publicAPI, model) { const cylinderPD = cylinder.getOutputData(); const cylinderPts = cylinderPD.getPoints().getData(); - const cylinderNormals = cylinderPD.getPointData().getNormals().getData(); + const cylinderNormals = cylinderPD + .getPointData() + .getNormals() + .getData(); // Apply transformation to the cylinder vtkMatrixBuilder @@ -45,7 +48,7 @@ function vtkArrowSource(publicAPI, model) { // Apply transformation to the cone vtkMatrixBuilder .buildFromRadian() - .translate(1.0 - (model.tipLength * 0.5), 0.0, 0.0) + .translate(1.0 - model.tipLength * 0.5, 0.0, 0.0) .apply(conePts); const append = vtkAppendPolyData.newInstance(); diff --git a/Sources/Filters/Sources/ConcentricCylinderSource/example/index.js b/Sources/Filters/Sources/ConcentricCylinderSource/example/index.js index b242ffabae0..08d261cbaec 100644 --- a/Sources/Filters/Sources/ConcentricCylinderSource/example/index.js +++ b/Sources/Filters/Sources/ConcentricCylinderSource/example/index.js @@ -1,9 +1,9 @@ import 'vtk.js/Sources/favicon'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkConcentricCylinderSource from 'vtk.js/Sources/Filters/Sources/ConcentricCylinderSource'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkConcentricCylinderSource from 'vtk.js/Sources/Filters/Sources/ConcentricCylinderSource'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; // import { ColorMode, ScalarMode } from 'vtk.js/Sources/Rendering/Core/Mapper/Constants'; @@ -13,7 +13,9 @@ import controlPanel from './controlPanel.html'; // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0.5, 0.5, 0.5] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0.5, 0.5, 0.5], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -49,7 +51,7 @@ renderWindow.render(); fullScreenRenderer.addController(controlPanel); document.querySelector('.skipInnerFaces').addEventListener('change', (e) => { - const skipInnerFaces = !!(e.target.checked); + const skipInnerFaces = !!e.target.checked; cylinder.setSkipInnerFaces(skipInnerFaces); renderWindow.render(); }); @@ -58,7 +60,7 @@ const masksButtons = document.querySelectorAll('.mask'); let count = masksButtons.length; while (count--) { masksButtons[count].addEventListener('change', (e) => { - const mask = !!(e.target.checked); + const mask = !!e.target.checked; const index = Number(e.target.dataset.layer); cylinder.setMaskLayer(index, mask); renderWindow.render(); diff --git a/Sources/Filters/Sources/ConcentricCylinderSource/index.js b/Sources/Filters/Sources/ConcentricCylinderSource/index.js index 150e927f1f3..0d0d5d0d2e4 100644 --- a/Sources/Filters/Sources/ConcentricCylinderSource/index.js +++ b/Sources/Filters/Sources/ConcentricCylinderSource/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; import vtkMatrixBuilder from 'vtk.js/Sources/Common/Core/MatrixBuilder'; import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; @@ -35,9 +35,14 @@ function vtkConcentricCylinderSource(publicAPI, model) { publicAPI.getNumberOfRadius = () => model.radius.length; publicAPI.getRadius = (index = 0) => model.radius[index]; - publicAPI.setRadius = (index, radius) => { model.radius[index] = radius; publicAPI.modified(); }; - publicAPI.setCellField = (index, field) => { model.cellFields[index] = field; publicAPI.modified(); }; - + publicAPI.setRadius = (index, radius) => { + model.radius[index] = radius; + publicAPI.modified(); + }; + publicAPI.setCellField = (index, field) => { + model.cellFields[index] = field; + publicAPI.modified(); + }; publicAPI.removeMask = () => { model.mask = null; @@ -64,7 +69,8 @@ function vtkConcentricCylinderSource(publicAPI, model) { } }; - publicAPI.getMaskLayer = index => ((index === undefined) ? model.mask : model.mask[index]); + publicAPI.getMaskLayer = (index) => + index === undefined ? model.mask : model.mask[index]; function requestData(inData, outData) { if (model.deleted || !model.radius.length) { @@ -87,13 +93,16 @@ function vtkConcentricCylinderSource(publicAPI, model) { if (!model.skipInnerFaces && !model.mask) { // We keep everything - cellArraySize = (2 * (model.resolution + 1)) + (5 * model.resolution) + ((nbLayers - 1) * model.resolution * 20); - nbCells = 2 + model.resolution + ((nbLayers - 1) * 4 * model.resolution); + cellArraySize = + 2 * (model.resolution + 1) + + 5 * model.resolution + + (nbLayers - 1) * model.resolution * 20; + nbCells = 2 + model.resolution + (nbLayers - 1) * 4 * model.resolution; } else if (!model.skipInnerFaces && model.mask) { // We skip some cylinders // Handle core if (!model.mask[0]) { - cellArraySize += (2 * (model.resolution + 1)) + (5 * model.resolution); + cellArraySize += 2 * (model.resolution + 1) + 5 * model.resolution; nbCells += 2 + model.resolution; } // Handle inside cylinders @@ -108,9 +117,13 @@ function vtkConcentricCylinderSource(publicAPI, model) { // We skip cylinders and internal faces if (!model.skipInnerFaces || !model.mask || !model.mask[0]) { // core handling - cellArraySize += (2 * (model.resolution + 1)); + cellArraySize += 2 * (model.resolution + 1); nbCells += 2; - if (model.radius.length === 1 || !model.skipInnerFaces || (model.mask && model.mask[1])) { + if ( + model.radius.length === 1 || + !model.skipInnerFaces || + (model.mask && model.mask[1]) + ) { // add side faces cellArraySize += 5 * model.resolution; nbCells += model.resolution; @@ -120,7 +133,7 @@ function vtkConcentricCylinderSource(publicAPI, model) { // Handle inside cylinders for (let layer = 1; layer < nbLayers; layer++) { if (!model.skipInnerFaces || !model.mask || !model.mask[layer]) { - const lastLayer = (nbLayers - 1 === layer); + const lastLayer = nbLayers - 1 === layer; // Add inside cylinder cellArraySize += model.resolution * 10; @@ -133,7 +146,11 @@ function vtkConcentricCylinderSource(publicAPI, model) { } // Do we add outterFaces - if (lastLayer || !model.skipInnerFaces || (model.mask && model.mask[layer + 1])) { + if ( + lastLayer || + !model.skipInnerFaces || + (model.mask && model.mask[layer + 1]) + ) { cellArraySize += model.resolution * 5; nbCells += model.resolution; } @@ -158,17 +175,17 @@ function vtkConcentricCylinderSource(publicAPI, model) { const radius = model.radius[layer]; // Create top for (let i = 0; i < model.resolution; i++) { - points[(pointIdx * 3) + 0] = radius * Math.cos(i * angle); - points[(pointIdx * 3) + 1] = radius * Math.sin(i * angle); - points[(pointIdx * 3) + 2] = zRef; + points[pointIdx * 3 + 0] = radius * Math.cos(i * angle); + points[pointIdx * 3 + 1] = radius * Math.sin(i * angle); + points[pointIdx * 3 + 2] = zRef; pointIdx++; } // Create bottom for (let i = 0; i < model.resolution; i++) { - points[(pointIdx * 3) + 0] = radius * Math.cos(i * angle); - points[(pointIdx * 3) + 1] = radius * Math.sin(i * angle); - points[(pointIdx * 3) + 2] = -zRef; + points[pointIdx * 3 + 0] = radius * Math.cos(i * angle); + points[pointIdx * 3 + 1] = radius * Math.sin(i * angle); + points[pointIdx * 3 + 2] = -zRef; pointIdx++; } } @@ -189,17 +206,21 @@ function vtkConcentricCylinderSource(publicAPI, model) { field[fieldLocation++] = currentField; polys[cellLocation++] = model.resolution; for (let i = 0; i < model.resolution; i++) { - polys[cellLocation++] = (2 * model.resolution) - i - 1; + polys[cellLocation++] = 2 * model.resolution - i - 1; } // Core: sides - if (!model.skipInnerFaces || (model.mask && model.mask[1]) || nbLayers === 1) { + if ( + !model.skipInnerFaces || + (model.mask && model.mask[1]) || + nbLayers === 1 + ) { for (let i = 0; i < model.resolution; i++) { polys[cellLocation++] = 4; polys[cellLocation++] = (i + 1) % model.resolution; polys[cellLocation++] = i; polys[cellLocation++] = i + model.resolution; - polys[cellLocation++] = ((i + 1) % model.resolution) + model.resolution; + polys[cellLocation++] = (i + 1) % model.resolution + model.resolution; field[fieldLocation++] = currentField; } @@ -216,16 +237,17 @@ function vtkConcentricCylinderSource(publicAPI, model) { } const offset = model.resolution * 2 * (layer - 1); - const lastLayer = (nbLayers - 1 === layer); + const lastLayer = nbLayers - 1 === layer; currentField = model.cellFields[layer]; // Create top for (let i = 0; i < model.resolution; i++) { polys[cellLocation++] = 4; polys[cellLocation++] = i + offset; - polys[cellLocation++] = ((i + 1) % model.resolution) + offset; - polys[cellLocation++] = ((i + 1) % model.resolution) + (2 * model.resolution) + offset; - polys[cellLocation++] = i + (2 * model.resolution) + offset; + polys[cellLocation++] = (i + 1) % model.resolution + offset; + polys[cellLocation++] = + (i + 1) % model.resolution + 2 * model.resolution + offset; + polys[cellLocation++] = i + 2 * model.resolution + offset; field[fieldLocation++] = currentField; } @@ -233,10 +255,16 @@ function vtkConcentricCylinderSource(publicAPI, model) { // Create bottom for (let i = 0; i < model.resolution; i++) { polys[cellLocation++] = 4; - polys[cellLocation++] = ((i + 1) % model.resolution) + offset + model.resolution; + polys[cellLocation++] = + (i + 1) % model.resolution + offset + model.resolution; polys[cellLocation++] = i + offset + model.resolution; - polys[cellLocation++] = i + (2 * model.resolution) + offset + model.resolution; - polys[cellLocation++] = ((i + 1) % model.resolution) + (2 * model.resolution) + offset + model.resolution; + polys[cellLocation++] = + i + 2 * model.resolution + offset + model.resolution; + polys[cellLocation++] = + (i + 1) % model.resolution + + 2 * model.resolution + + offset + + model.resolution; field[fieldLocation++] = currentField; } @@ -246,8 +274,9 @@ function vtkConcentricCylinderSource(publicAPI, model) { for (let i = 0; i < model.resolution; i++) { polys[cellLocation++] = 4; polys[cellLocation++] = i + offset; - polys[cellLocation++] = ((i + 1) % model.resolution) + offset; - polys[cellLocation++] = ((i + 1) % model.resolution) + model.resolution + offset; + polys[cellLocation++] = (i + 1) % model.resolution + offset; + polys[cellLocation++] = + (i + 1) % model.resolution + model.resolution + offset; polys[cellLocation++] = i + model.resolution + offset; field[fieldLocation++] = currentField; @@ -255,13 +284,23 @@ function vtkConcentricCylinderSource(publicAPI, model) { } // Create outter - if (!model.skipInnerFaces || lastLayer || (model.mask && (model.mask[layer + 1] || lastLayer))) { + if ( + !model.skipInnerFaces || + lastLayer || + (model.mask && (model.mask[layer + 1] || lastLayer)) + ) { for (let i = 0; i < model.resolution; i++) { polys[cellLocation++] = 4; - polys[cellLocation++] = ((i + 1) % model.resolution) + offset + (2 * model.resolution); - polys[cellLocation++] = i + offset + (2 * model.resolution); - polys[cellLocation++] = i + model.resolution + offset + (2 * model.resolution); - polys[cellLocation++] = ((i + 1) % model.resolution) + model.resolution + offset + (2 * model.resolution); + polys[cellLocation++] = + (i + 1) % model.resolution + offset + 2 * model.resolution; + polys[cellLocation++] = i + offset + 2 * model.resolution; + polys[cellLocation++] = + i + model.resolution + offset + 2 * model.resolution; + polys[cellLocation++] = + (i + 1) % model.resolution + + model.resolution + + offset + + 2 * model.resolution; field[fieldLocation++] = currentField; } @@ -278,7 +317,9 @@ function vtkConcentricCylinderSource(publicAPI, model) { dataset = vtkPolyData.newInstance(); dataset.getPoints().setData(points, 3); dataset.getPolys().setData(polys, 1); - dataset.getCellData().setScalars(vtkDataArray.newInstance({ name: 'layer', values: field })); + dataset + .getCellData() + .setScalars(vtkDataArray.newInstance({ name: 'layer', values: field })); // Update output outData[0] = dataset; @@ -311,15 +352,8 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.obj(publicAPI, model); - macro.setGet(publicAPI, model, [ - 'height', - 'resolution', - 'skipInnerFaces', - ]); - macro.setGetArray(publicAPI, model, [ - 'center', - 'direction', - ], 3); + macro.setGet(publicAPI, model, ['height', 'resolution', 'skipInnerFaces']); + macro.setGetArray(publicAPI, model, ['center', 'direction'], 3); macro.getArray(publicAPI, model, ['cellFields']); macro.algo(publicAPI, model, 0, 1); vtkConcentricCylinderSource(publicAPI, model); @@ -327,7 +361,10 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkConcentricCylinderSource'); +export const newInstance = macro.newInstance( + extend, + 'vtkConcentricCylinderSource' +); // ---------------------------------------------------------------------------- diff --git a/Sources/Filters/Sources/ConeSource/example/index.js b/Sources/Filters/Sources/ConeSource/example/index.js index 24cfef63af1..6ab050f3bac 100644 --- a/Sources/Filters/Sources/ConeSource/example/index.js +++ b/Sources/Filters/Sources/ConeSource/example/index.js @@ -1,9 +1,9 @@ import 'vtk.js/Sources/favicon'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import controlPanel from './controlPanel.html'; @@ -11,7 +11,9 @@ import controlPanel from './controlPanel.html'; // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -56,7 +58,7 @@ fullScreenRenderer.addController(controlPanel); }); document.querySelector('.capping').addEventListener('change', (e) => { - const capping = !!(e.target.checked); + const capping = !!e.target.checked; pipelines[0].coneSource.set({ capping }); pipelines[1].coneSource.set({ capping }); renderWindow.render(); @@ -70,7 +72,9 @@ function updateTransformedCone() { const direction = [1, 0, 0]; for (let i = 0; i < 3; i++) { center[Number(centerElems[i].dataset.index)] = Number(centerElems[i].value); - direction[Number(directionElems[i].dataset.index)] = Number(directionElems[i].value); + direction[Number(directionElems[i].dataset.index)] = Number( + directionElems[i].value + ); } console.log('updateTransformedCone', center, direction); pipelines[1].coneSource.set({ center, direction }); diff --git a/Sources/Filters/Sources/ConeSource/index.js b/Sources/Filters/Sources/ConeSource/index.js index 7e6d90e23e4..8588f25ac68 100644 --- a/Sources/Filters/Sources/ConeSource/index.js +++ b/Sources/Filters/Sources/ConeSource/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; import vtkMatrixBuilder from 'vtk.js/Sources/Common/Core/MatrixBuilder'; @@ -20,7 +20,7 @@ function vtkConeSource(publicAPI, model) { const angle = 2 * Math.PI / model.resolution; const xbot = -model.height / 2.0; const numberOfPoints = model.resolution + 1; - const cellArraySize = (4 * model.resolution) + 1 + model.resolution; + const cellArraySize = 4 * model.resolution + 1 + model.resolution; // Points let pointIdx = 0; @@ -43,9 +43,9 @@ function vtkConeSource(publicAPI, model) { // Add all points for (let i = 0; i < model.resolution; i++) { pointIdx++; - points[(pointIdx * 3) + 0] = xbot; - points[(pointIdx * 3) + 1] = model.radius * Math.cos(i * angle); - points[(pointIdx * 3) + 2] = model.radius * Math.sin(i * angle); + points[pointIdx * 3 + 0] = xbot; + points[pointIdx * 3 + 1] = model.radius * Math.cos(i * angle); + points[pointIdx * 3 + 2] = model.radius * Math.sin(i * angle); // Add points to bottom cell in reverse order if (model.capping) { @@ -101,16 +101,8 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.obj(publicAPI, model); - macro.setGet(publicAPI, model, [ - 'height', - 'radius', - 'resolution', - 'capping', - ]); - macro.setGetArray(publicAPI, model, [ - 'center', - 'direction', - ], 3); + macro.setGet(publicAPI, model, ['height', 'radius', 'resolution', 'capping']); + macro.setGetArray(publicAPI, model, ['center', 'direction'], 3); macro.algo(publicAPI, model, 0, 1); vtkConeSource(publicAPI, model); } diff --git a/Sources/Filters/Sources/ConeSource/test/testCone.js b/Sources/Filters/Sources/ConeSource/test/testCone.js index 7d521b74e4a..bc365073a69 100644 --- a/Sources/Filters/Sources/ConeSource/test/testCone.js +++ b/Sources/Filters/Sources/ConeSource/test/testCone.js @@ -1,13 +1,13 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkLight from 'vtk.js/Sources/Rendering/Core/Light'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkLight from 'vtk.js/Sources/Rendering/Core/Light'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import baseline from './testCone.png'; @@ -17,7 +17,9 @@ test.onlyIfWebGL('Test vtkConeSource Rendering', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -41,7 +43,9 @@ test.onlyIfWebGL('Test vtkConeSource Rendering', (t) => { const mapper = gc.registerResource(vtkMapper.newInstance()); actor.setMapper(mapper); - const coneSource = gc.registerResource(vtkConeSource.newInstance({ height: 1.0 })); + const coneSource = gc.registerResource( + vtkConeSource.newInstance({ height: 1.0 }) + ); coneSource.setResolution(40); mapper.setInputConnection(coneSource.getOutputPort()); @@ -52,5 +56,12 @@ test.onlyIfWebGL('Test vtkConeSource Rendering', (t) => { glwindow.setSize(400, 400); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Filters/Sources/ConeSource/testCone', t, 2.5, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Filters/Sources/ConeSource/testCone', + t, + 2.5, + gc.releaseResources + ); }); diff --git a/Sources/Filters/Sources/CubeSource/index.js b/Sources/Filters/Sources/CubeSource/index.js index fadb26ccc7e..f46f768c6b2 100644 --- a/Sources/Filters/Sources/CubeSource/index.js +++ b/Sources/Filters/Sources/CubeSource/index.js @@ -1,6 +1,6 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; // ---------------------------------------------------------------------------- // vtkConeSource methods @@ -26,7 +26,11 @@ function vtkCubeSource(publicAPI, model) { polyData.getPoints().setData(points, 3); const normals = new window[model.pointType](numberOfPoints * 3); - const normalArray = vtkDataArray.newInstance({ name: 'Normals', values: normals, numberOfComponents: 3 }); + const normalArray = vtkDataArray.newInstance({ + name: 'Normals', + values: normals, + numberOfComponents: 3, + }); polyData.getPointData().setNormals(normalArray); let tcdim = 2; @@ -35,7 +39,11 @@ function vtkCubeSource(publicAPI, model) { } const textureCoords = new window[model.pointType](numberOfPoints * tcdim); - const tcoords = vtkDataArray.newInstance({ name: 'TextureCoordinates', values: textureCoords, numberOfComponents: tcdim }); + const tcoords = vtkDataArray.newInstance({ + name: 'TextureCoordinates', + values: textureCoords, + numberOfComponents: tcdim, + }); polyData.getPointData().setTCoords(tcoords); const x = [0.0, 0.0, 0.0]; @@ -44,34 +52,34 @@ function vtkCubeSource(publicAPI, model) { let pointIndex = 0; - x[0] = model.center[0] - (model.xLength / 2.0); - n[0] = (-1.0); + x[0] = model.center[0] - model.xLength / 2.0; + n[0] = -1.0; n[1] = 0.0; n[2] = 0.0; for (let i = 0; i < 2; i++) { - x[1] = model.center[1] - (model.yLength / 2.0); + x[1] = model.center[1] - model.yLength / 2.0; for (let j = 0; j < 2; j++) { tc[1] = x[1] + 0.5; - x[2] = model.center[2] - (model.zLength / 2.0); + x[2] = model.center[2] - model.zLength / 2.0; for (let k = 0; k < 2; k++) { - tc[0] = (x[2] + 0.5) * (1 - (2 * i)); - points[(pointIndex * 3)] = x[0]; - points[(pointIndex * 3) + 1] = x[1]; - points[(pointIndex * 3) + 2] = x[2]; + tc[0] = (x[2] + 0.5) * (1 - 2 * i); + points[pointIndex * 3] = x[0]; + points[pointIndex * 3 + 1] = x[1]; + points[pointIndex * 3 + 2] = x[2]; - normals[(pointIndex * 3)] = n[0]; - normals[(pointIndex * 3) + 1] = n[1]; - normals[(pointIndex * 3) + 2] = n[2]; + normals[pointIndex * 3] = n[0]; + normals[pointIndex * 3 + 1] = n[1]; + normals[pointIndex * 3 + 2] = n[2]; if (tcdim === 2) { - textureCoords[(pointIndex * tcdim)] = tc[0]; - textureCoords[(pointIndex * tcdim) + 1] = tc[1]; + textureCoords[pointIndex * tcdim] = tc[0]; + textureCoords[pointIndex * tcdim + 1] = tc[1]; } else { - textureCoords[(pointIndex * tcdim)] = (2 * i) - 1; - textureCoords[(pointIndex * tcdim) + 1] = (2 * j) - 1; - textureCoords[(pointIndex * tcdim) + 2] = (2 * k) - 1; + textureCoords[pointIndex * tcdim] = 2 * i - 1; + textureCoords[pointIndex * tcdim + 1] = 2 * j - 1; + textureCoords[pointIndex * tcdim + 2] = 2 * k - 1; } pointIndex++; @@ -84,35 +92,35 @@ function vtkCubeSource(publicAPI, model) { n[0] += 2.0; } - x[1] = model.center[1] - (model.yLength / 2.0); - n[1] = (-1.0); + x[1] = model.center[1] - model.yLength / 2.0; + n[1] = -1.0; n[0] = 0.0; n[2] = 0.0; for (let i = 0; i < 2; i++) { - x[0] = model.center[0] - (model.xLength / 2.0); + x[0] = model.center[0] - model.xLength / 2.0; for (let j = 0; j < 2; j++) { - tc[0] = (x[0] + 0.5) * ((2 * i) - 1); - x[2] = model.center[2] - (model.zLength / 2.0); + tc[0] = (x[0] + 0.5) * (2 * i - 1); + x[2] = model.center[2] - model.zLength / 2.0; for (let k = 0; k < 2; k++) { - tc[1] = (x[2] + 0.5) * (-1); + tc[1] = (x[2] + 0.5) * -1; - points[(pointIndex * 3)] = x[0]; - points[(pointIndex * 3) + 1] = x[1]; - points[(pointIndex * 3) + 2] = x[2]; + points[pointIndex * 3] = x[0]; + points[pointIndex * 3 + 1] = x[1]; + points[pointIndex * 3 + 2] = x[2]; - normals[(pointIndex * 3)] = n[0]; - normals[(pointIndex * 3) + 1] = n[1]; - normals[(pointIndex * 3) + 2] = n[2]; + normals[pointIndex * 3] = n[0]; + normals[pointIndex * 3 + 1] = n[1]; + normals[pointIndex * 3 + 2] = n[2]; if (tcdim === 2) { - textureCoords[(pointIndex * tcdim)] = tc[0]; - textureCoords[(pointIndex * tcdim) + 1] = tc[1]; + textureCoords[pointIndex * tcdim] = tc[0]; + textureCoords[pointIndex * tcdim + 1] = tc[1]; } else { - textureCoords[(pointIndex * tcdim)] = (2 * j) - 1; - textureCoords[(pointIndex * tcdim) + 1] = (2 * i) - 1; - textureCoords[(pointIndex * tcdim) + 2] = (2 * k) - 1; + textureCoords[pointIndex * tcdim] = 2 * j - 1; + textureCoords[pointIndex * tcdim + 1] = 2 * i - 1; + textureCoords[pointIndex * tcdim + 2] = 2 * k - 1; } pointIndex++; @@ -124,35 +132,35 @@ function vtkCubeSource(publicAPI, model) { n[1] += 2.0; } - x[2] = model.center[2] - (model.zLength / 2.0); - n[2] = (-1.0); + x[2] = model.center[2] - model.zLength / 2.0; + n[2] = -1.0; n[0] = 0.0; n[1] = 0.0; for (let i = 0; i < 2; i++) { - x[1] = model.center[1] - (model.yLength / 2.0); + x[1] = model.center[1] - model.yLength / 2.0; for (let j = 0; j < 2; j++) { tc[1] = x[1] + 0.5; - x[0] = model.center[0] - (model.xLength / 2.0); + x[0] = model.center[0] - model.xLength / 2.0; for (let k = 0; k < 2; k++) { - tc[0] = (x[0] + 0.5) * ((2 * i) - 1); + tc[0] = (x[0] + 0.5) * (2 * i - 1); - points[(pointIndex * 3)] = x[0]; - points[(pointIndex * 3) + 1] = x[1]; - points[(pointIndex * 3) + 2] = x[2]; + points[pointIndex * 3] = x[0]; + points[pointIndex * 3 + 1] = x[1]; + points[pointIndex * 3 + 2] = x[2]; - normals[(pointIndex * 3)] = n[0]; - normals[(pointIndex * 3) + 1] = n[1]; - normals[(pointIndex * 3) + 2] = n[2]; + normals[pointIndex * 3] = n[0]; + normals[pointIndex * 3 + 1] = n[1]; + normals[pointIndex * 3 + 2] = n[2]; if (tcdim === 2) { - textureCoords[(pointIndex * tcdim)] = tc[0]; - textureCoords[(pointIndex * tcdim) + 1] = tc[1]; + textureCoords[pointIndex * tcdim] = tc[0]; + textureCoords[pointIndex * tcdim + 1] = tc[1]; } else { - textureCoords[(pointIndex * tcdim)] = (2 * k) - 1; - textureCoords[(pointIndex * tcdim) + 1] = (2 * j) - 1; - textureCoords[(pointIndex * tcdim) + 2] = (2 * i) - 1; + textureCoords[pointIndex * tcdim] = 2 * k - 1; + textureCoords[pointIndex * tcdim + 1] = 2 * j - 1; + textureCoords[pointIndex * tcdim + 2] = 2 * i - 1; } pointIndex++; @@ -262,9 +270,7 @@ export function extend(publicAPI, model, initialValues = {}) { 'zLength', 'generate3DTextureCoordinates', ]); - macro.setGetArray(publicAPI, model, [ - 'center', - ], 3); + macro.setGetArray(publicAPI, model, ['center'], 3); macro.algo(publicAPI, model, 0, 1); vtkCubeSource(publicAPI, model); diff --git a/Sources/Filters/Sources/CubeSource/test/testCube.js b/Sources/Filters/Sources/CubeSource/test/testCube.js index 270d52b4a79..f6448994f65 100644 --- a/Sources/Filters/Sources/CubeSource/test/testCube.js +++ b/Sources/Filters/Sources/CubeSource/test/testCube.js @@ -1,12 +1,12 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; import baseline from './testCube.png'; @@ -16,7 +16,9 @@ test.onlyIfWebGL('Test vtkCubeSource Rendering', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -25,7 +27,6 @@ test.onlyIfWebGL('Test vtkCubeSource Rendering', (t) => { renderWindow.addRenderer(renderer); renderer.setBackground(0.32, 0.34, 0.43); - const cube0 = gc.registerResource(vtkCubeSource.newInstance()); const mapperCube0 = gc.registerResource(vtkMapper.newInstance()); mapperCube0.setInputConnection(cube0.getOutputPort()); @@ -33,12 +34,14 @@ test.onlyIfWebGL('Test vtkCubeSource Rendering', (t) => { actorCube0.setMapper(mapperCube0); renderer.addActor(actorCube0); - const cube1 = gc.registerResource(vtkCubeSource.newInstance({ - xLength: 2.0, - yLength: 2.0, - zLength: 2.0, - center: [3.0, 0.0, 0.0], - })); + const cube1 = gc.registerResource( + vtkCubeSource.newInstance({ + xLength: 2.0, + yLength: 2.0, + zLength: 2.0, + center: [3.0, 0.0, 0.0], + }) + ); const mapperCube1 = gc.registerResource(vtkMapper.newInstance()); mapperCube1.setInputConnection(cube1.getOutputPort()); const actorCube1 = gc.registerResource(vtkActor.newInstance()); @@ -70,5 +73,12 @@ test.onlyIfWebGL('Test vtkCubeSource Rendering', (t) => { glwindow.setSize(400, 400); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Filters/Sources/CubeSource/testCube', t, 2.5, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Filters/Sources/CubeSource/testCube', + t, + 2.5, + gc.releaseResources + ); }); diff --git a/Sources/Filters/Sources/CylinderSource/example/index.js b/Sources/Filters/Sources/CylinderSource/example/index.js index e8c4300e1f0..b1448f1b3fd 100644 --- a/Sources/Filters/Sources/CylinderSource/example/index.js +++ b/Sources/Filters/Sources/CylinderSource/example/index.js @@ -1,9 +1,9 @@ import 'vtk.js/Sources/favicon'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkCylinderSource from 'vtk.js/Sources/Filters/Sources/CylinderSource'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkCylinderSource from 'vtk.js/Sources/Filters/Sources/CylinderSource'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import controlPanel from './controlPanel.html'; @@ -11,7 +11,9 @@ import controlPanel from './controlPanel.html'; // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -56,7 +58,7 @@ fullScreenRenderer.addController(controlPanel); }); document.querySelector('.capping').addEventListener('change', (e) => { - const capping = !!(e.target.checked); + const capping = !!e.target.checked; pipelines[0].cylinderSource.set({ capping }); pipelines[1].cylinderSource.set({ capping }); renderWindow.render(); diff --git a/Sources/Filters/Sources/CylinderSource/index.js b/Sources/Filters/Sources/CylinderSource/index.js index 9dd46f2bb5d..afd0d39657a 100644 --- a/Sources/Filters/Sources/CylinderSource/index.js +++ b/Sources/Filters/Sources/CylinderSource/index.js @@ -1,6 +1,6 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import macro from 'vtk.js/Sources/macro'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; // ---------------------------------------------------------------------------- // vtkCylinderSource methods @@ -23,7 +23,7 @@ function vtkCylinderSource(publicAPI, model) { if (model.capping) { numberOfPoints = 4 * model.resolution; - numberOfPolys = (7 * model.resolution) + 2; + numberOfPolys = 7 * model.resolution + 2; } // Points @@ -35,13 +35,19 @@ function vtkCylinderSource(publicAPI, model) { // Normals const normalsData = new Float32Array(numberOfPoints * 3); - const normals = vtkDataArray.newInstance( - { numberOfComponents: 3, values: normalsData, name: 'Normals' }); + const normals = vtkDataArray.newInstance({ + numberOfComponents: 3, + values: normalsData, + name: 'Normals', + }); // Texture coords const tcData = new Float32Array(numberOfPoints * 2); - const tcoords = vtkDataArray.newInstance( - { numberOfComponents: 2, values: tcData, name: 'TCoords' }); + const tcoords = vtkDataArray.newInstance({ + numberOfComponents: 2, + values: tcData, + name: 'TCoords', + }); // Generate points for all sides const nbot = [0.0, 0.0, 0.0]; @@ -54,32 +60,32 @@ function vtkCylinderSource(publicAPI, model) { // x coordinate nbot[0] = Math.cos(i * angle); ntop[0] = nbot[0]; - xbot[0] = (model.radius * nbot[0]) + model.center[0]; + xbot[0] = model.radius * nbot[0] + model.center[0]; xtop[0] = xbot[0]; - tcbot[0] = Math.abs((2.0 * i / model.resolution) - 1.0); + tcbot[0] = Math.abs(2.0 * i / model.resolution - 1.0); tctop[0] = tcbot[0]; // y coordinate - xbot[1] = (0.5 * model.height) + model.center[1]; - xtop[1] = (-0.5 * model.height) + model.center[1]; + xbot[1] = 0.5 * model.height + model.center[1]; + xtop[1] = -0.5 * model.height + model.center[1]; tcbot[1] = 0.0; tctop[1] = 1.0; // z coordinate - nbot[2] = -(Math.sin(i * angle)); + nbot[2] = -Math.sin(i * angle); ntop[2] = nbot[2]; - xbot[2] = (model.radius * nbot[2]) + model.center[2]; + xbot[2] = model.radius * nbot[2] + model.center[2]; xtop[2] = xbot[2]; const pointIdx = 2 * i; for (let j = 0; j < 3; j++) { - normalsData[(pointIdx * 3) + j] = nbot[j]; - normalsData[((pointIdx + 1) * 3) + j] = ntop[j]; - points[(pointIdx * 3) + j] = xbot[j]; - points[((pointIdx + 1) * 3) + j] = xtop[j]; + normalsData[pointIdx * 3 + j] = nbot[j]; + normalsData[(pointIdx + 1) * 3 + j] = ntop[j]; + points[pointIdx * 3 + j] = xbot[j]; + points[(pointIdx + 1) * 3 + j] = xtop[j]; if (j < 2) { - tcData[(pointIdx * 2) + j] = tcbot[j]; - tcData[((pointIdx + 1) * 2) + j] = tctop[j]; + tcData[pointIdx * 2 + j] = tcbot[j]; + tcData[(pointIdx + 1) * 2 + j] = tctop[j]; } } } @@ -88,8 +94,8 @@ function vtkCylinderSource(publicAPI, model) { for (let i = 0; i < model.resolution; i++) { polys[cellLocation++] = 4; polys[cellLocation++] = 2 * i; - polys[cellLocation++] = (2 * i) + 1; - const pt = ((2 * i) + 3) % (2 * model.resolution); + polys[cellLocation++] = 2 * i + 1; + const pt = (2 * i + 3) % (2 * model.resolution); polys[cellLocation++] = pt; polys[cellLocation++] = pt - 1; } @@ -108,8 +114,8 @@ function vtkCylinderSource(publicAPI, model) { // y coordinate nbot[1] = 1.0; ntop[1] = -1.0; - xbot[1] = (0.5 * model.height) + model.center[1]; - xtop[1] = (-0.5 * model.height) + model.center[1]; + xbot[1] = 0.5 * model.height + model.center[1]; + xtop[1] = -0.5 * model.height + model.center[1]; // z coordinate xbot[2] = -model.radius * Math.sin(i * angle); @@ -118,16 +124,16 @@ function vtkCylinderSource(publicAPI, model) { tctop[1] = xbot[2]; xbot[2] += model.center[2]; xtop[2] += model.center[2]; - const botIdx = (2 * model.resolution) + i; - const topIdx = (3 * model.resolution) + model.resolution - i - 1; + const botIdx = 2 * model.resolution + i; + const topIdx = 3 * model.resolution + model.resolution - i - 1; for (let j = 0; j < 3; j++) { - normalsData[(3 * botIdx) + j] = nbot[j]; - normalsData[(3 * topIdx) + j] = ntop[j]; - points[(3 * botIdx) + j] = xbot[j]; - points[(3 * topIdx) + j] = xtop[j]; + normalsData[3 * botIdx + j] = nbot[j]; + normalsData[3 * topIdx + j] = ntop[j]; + points[3 * botIdx + j] = xbot[j]; + points[3 * topIdx + j] = xtop[j]; if (j < 2) { - tcData[(2 * botIdx) + j] = tcbot[j]; - tcData[(2 * topIdx) + j] = tctop[j]; + tcData[2 * botIdx + j] = tcbot[j]; + tcData[2 * topIdx + j] = tctop[j]; } } } @@ -135,11 +141,11 @@ function vtkCylinderSource(publicAPI, model) { // Generate polygons for top/bottom polys[cellLocation++] = model.resolution; for (let i = 0; i < model.resolution; i++) { - polys[cellLocation++] = (2 * model.resolution) + i; + polys[cellLocation++] = 2 * model.resolution + i; } polys[cellLocation++] = model.resolution; for (let i = 0; i < model.resolution; i++) { - polys[cellLocation++] = (3 * model.resolution) + i; + polys[cellLocation++] = 3 * model.resolution + i; } } @@ -177,15 +183,8 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.obj(publicAPI, model); - macro.setGet(publicAPI, model, [ - 'height', - 'radius', - 'resolution', - 'capping', - ]); - macro.setGetArray(publicAPI, model, [ - 'center', - ], 3); + macro.setGet(publicAPI, model, ['height', 'radius', 'resolution', 'capping']); + macro.setGetArray(publicAPI, model, ['center'], 3); macro.algo(publicAPI, model, 0, 1); vtkCylinderSource(publicAPI, model); } diff --git a/Sources/Filters/Sources/CylinderSource/test/testCylinder.js b/Sources/Filters/Sources/CylinderSource/test/testCylinder.js index 7eaf11364e2..dfa956ec009 100644 --- a/Sources/Filters/Sources/CylinderSource/test/testCylinder.js +++ b/Sources/Filters/Sources/CylinderSource/test/testCylinder.js @@ -1,13 +1,13 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkCylinderSource from 'vtk.js/Sources/Filters/Sources/CylinderSource'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkLight from 'vtk.js/Sources/Rendering/Core/Light'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkCylinderSource from 'vtk.js/Sources/Filters/Sources/CylinderSource'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkLight from 'vtk.js/Sources/Rendering/Core/Light'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import baseline from './testCylinder.png'; @@ -17,7 +17,9 @@ test.onlyIfWebGL('Test vtkCylinderSource Rendering', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -41,7 +43,9 @@ test.onlyIfWebGL('Test vtkCylinderSource Rendering', (t) => { const mapper = gc.registerResource(vtkMapper.newInstance()); actor.setMapper(mapper); - const cylinderSource = gc.registerResource(vtkCylinderSource.newInstance({ height: 1.0 })); + const cylinderSource = gc.registerResource( + vtkCylinderSource.newInstance({ height: 1.0 }) + ); cylinderSource.setResolution(40); mapper.setInputConnection(cylinderSource.getOutputPort()); @@ -52,5 +56,12 @@ test.onlyIfWebGL('Test vtkCylinderSource Rendering', (t) => { glwindow.setSize(400, 400); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Filters/Sources/CylinderSource/testCylinder', t, 2.5, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Filters/Sources/CylinderSource/testCylinder', + t, + 2.5, + gc.releaseResources + ); }); diff --git a/Sources/Filters/Sources/ImageGridSource/index.js b/Sources/Filters/Sources/ImageGridSource/index.js index e48c8f478d2..23a897c1803 100644 --- a/Sources/Filters/Sources/ImageGridSource/index.js +++ b/Sources/Filters/Sources/ImageGridSource/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkImageData from 'vtk.js/Sources/Common/DataModel/ImageData'; import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; @@ -26,18 +26,26 @@ function vtkImageGridSource(publicAPI, model) { }; // Add parameter used to create dataset as metadata.state[*] - ['gridSpacing', 'gridOrigin', 'dataSpacing', 'dataOrigin'].forEach((field) => { - state[field] = [].concat(model[field]); - }); + ['gridSpacing', 'gridOrigin', 'dataSpacing', 'dataOrigin'].forEach( + (field) => { + state[field] = [].concat(model[field]); + } + ); const id = vtkImageData.newInstance(dataset); id.setOrigin(model.dataOrigin[0], model.dataOrigin[1], model.dataOrigin[2]); - id.setSpacing(model.dataSpacing[0], model.dataSpacing[1], model.dataSpacing[2]); + id.setSpacing( + model.dataSpacing[0], + model.dataSpacing[1], + model.dataSpacing[2] + ); id.setExtent.apply(this, model.dataExtent); id.setDirection(model.dataDirection); let dims = [0, 0, 0]; - dims = dims.map((_, i) => model.dataExtent[(i * 2) + 1] - model.dataExtent[i * 2] + 1); + dims = dims.map( + (_, i) => model.dataExtent[i * 2 + 1] - model.dataExtent[i * 2] + 1 + ); const newArray = new Uint8Array(dims[0] * dims[1] * dims[2]); @@ -47,29 +55,33 @@ function vtkImageGridSource(publicAPI, model) { let i = 0; for (let z = model.dataExtent[4]; z <= model.dataExtent[5]; z++) { if (model.gridSpacing[2]) { - zval = (z % model.gridSpacing[2] === model.gridOrigin[2]); + zval = z % model.gridSpacing[2] === model.gridOrigin[2]; } else { zval = 0; } for (let y = model.dataExtent[2]; y <= model.dataExtent[3]; y++) { if (model.gridSpacing[1]) { - yval = (y % model.gridSpacing[1] === model.gridOrigin[1]); + yval = y % model.gridSpacing[1] === model.gridOrigin[1]; } else { yval = 0; } for (let x = model.dataExtent[0]; x <= model.dataExtent[1]; x++) { if (model.gridSpacing[0]) { - xval = (x % model.gridSpacing[0] === model.gridOrigin[0]); + xval = x % model.gridSpacing[0] === model.gridOrigin[0]; } else { xval = 0; } - newArray[i] = ((zval || yval || xval) ? model.lineValue : model.fillValue); + newArray[i] = + zval || yval || xval ? model.lineValue : model.fillValue; i++; } } } - const da = vtkDataArray.newInstance({ numberOfComponents: 1, values: newArray }); + const da = vtkDataArray.newInstance({ + numberOfComponents: 1, + values: newArray, + }); da.setName('scalars'); const cpd = id.getPointData(); @@ -103,25 +115,18 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.obj(publicAPI, model); - macro.setGet(publicAPI, model, [ - 'lineValue', - 'fillValue', - ]); - - macro.setGetArray(publicAPI, model, [ - 'gridOrigin', - 'gridSpacing', - 'dataOrigin', - 'dataSpacing', - ], 3); - - macro.setGetArray(publicAPI, model, [ - 'dataExtent', - ], 6); - - macro.setGetArray(publicAPI, model, [ - 'dataDirection', - ], 9); + macro.setGet(publicAPI, model, ['lineValue', 'fillValue']); + + macro.setGetArray( + publicAPI, + model, + ['gridOrigin', 'gridSpacing', 'dataOrigin', 'dataSpacing'], + 3 + ); + + macro.setGetArray(publicAPI, model, ['dataExtent'], 6); + + macro.setGetArray(publicAPI, model, ['dataDirection'], 9); macro.algo(publicAPI, model, 0, 1); vtkImageGridSource(publicAPI, model); diff --git a/Sources/Filters/Sources/LineSource/example/index.js b/Sources/Filters/Sources/LineSource/example/index.js index ff72c0a1d6b..a93afda8607 100644 --- a/Sources/Filters/Sources/LineSource/example/index.js +++ b/Sources/Filters/Sources/LineSource/example/index.js @@ -1,10 +1,10 @@ import 'vtk.js/Sources/favicon'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkLineSource from 'vtk.js/Sources/Filters/Sources/LineSource'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkLineSource from 'vtk.js/Sources/Filters/Sources/LineSource'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants'; import controlPanel from './controlPanel.html'; @@ -12,7 +12,9 @@ import controlPanel from './controlPanel.html'; // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); diff --git a/Sources/Filters/Sources/LineSource/index.js b/Sources/Filters/Sources/LineSource/index.js index f974360ad3b..dde30b5cb3e 100644 --- a/Sources/Filters/Sources/LineSource/index.js +++ b/Sources/Filters/Sources/LineSource/index.js @@ -1,6 +1,6 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; const { vtkWarningMacro } = macro; @@ -20,7 +20,9 @@ function vtkLineSource(publicAPI, model) { const dataset = outData[0]; // Check input - const pointDataType = dataset ? dataset.getPoints().getDataType() : 'Float32Array'; + const pointDataType = dataset + ? dataset.getPoints().getDataType() + : 'Float32Array'; const pd = vtkPolyData.newInstance(); const v21 = new Float32Array(3); vtkMath.subtract(model.point2, model.point1, v21); @@ -41,15 +43,14 @@ function vtkLineSource(publicAPI, model) { const lines = new Uint32Array(numPts + 1); pd.getLines().setData(lines, 1); - let idx = 0; let t = 0.0; - for (let i = 0; i < (xres + 1); i++) { + for (let i = 0; i < xres + 1; i++) { t = i / xres; - points[(idx * 3)] = model.point1[0] + (t * v21[0]); - points[(idx * 3) + 1] = model.point1[1] + (t * v21[1]); - points[(idx * 3) + 2] = model.point1[2] + (t * v21[2]); + points[idx * 3] = model.point1[0] + t * v21[0]; + points[idx * 3 + 1] = model.point1[1] + t * v21[1]; + points[idx * 3 + 2] = model.point1[2] + t * v21[2]; idx++; } @@ -85,13 +86,8 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.obj(publicAPI, model); - macro.setGet(publicAPI, model, [ - 'resolution', - ]); - macro.setGetArray(publicAPI, model, [ - 'point1', - 'point2', - ], 3); + macro.setGet(publicAPI, model, ['resolution']); + macro.setGetArray(publicAPI, model, ['point1', 'point2'], 3); macro.algo(publicAPI, model, 0, 1); vtkLineSource(publicAPI, model); } diff --git a/Sources/Filters/Sources/LineSource/test/testLine.js b/Sources/Filters/Sources/LineSource/test/testLine.js index a1d46661762..9c40ce68265 100644 --- a/Sources/Filters/Sources/LineSource/test/testLine.js +++ b/Sources/Filters/Sources/LineSource/test/testLine.js @@ -1,12 +1,12 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkLineSource from 'vtk.js/Sources/Filters/Sources/LineSource'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkLineSource from 'vtk.js/Sources/Filters/Sources/LineSource'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import baseline from './baseline.png'; @@ -16,7 +16,9 @@ test.onlyIfWebGL('Test vtkLineSource Rendering', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -31,7 +33,9 @@ test.onlyIfWebGL('Test vtkLineSource Rendering', (t) => { const mapper = gc.registerResource(vtkMapper.newInstance()); actor.setMapper(mapper); - const lineSource = gc.registerResource(vtkLineSource.newInstance({ resolution: 10 })); + const lineSource = gc.registerResource( + vtkLineSource.newInstance({ resolution: 10 }) + ); mapper.setInputConnection(lineSource.getOutputPort()); // now create something to view it, in this case webgl @@ -41,5 +45,12 @@ test.onlyIfWebGL('Test vtkLineSource Rendering', (t) => { glwindow.setSize(400, 400); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Filters/Sources/LineSource/testLine', t, 1, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Filters/Sources/LineSource/testLine', + t, + 1, + gc.releaseResources + ); }); diff --git a/Sources/Filters/Sources/PlaneSource/example/index.js b/Sources/Filters/Sources/PlaneSource/example/index.js index 5f2c025d84d..44326207120 100644 --- a/Sources/Filters/Sources/PlaneSource/example/index.js +++ b/Sources/Filters/Sources/PlaneSource/example/index.js @@ -1,10 +1,10 @@ import 'vtk.js/Sources/favicon'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants'; import controlPanel from './controlPanel.html'; @@ -12,7 +12,9 @@ import controlPanel from './controlPanel.html'; // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); diff --git a/Sources/Filters/Sources/PlaneSource/index.js b/Sources/Filters/Sources/PlaneSource/index.js index ca8d7706793..cdf95548a85 100644 --- a/Sources/Filters/Sources/PlaneSource/index.js +++ b/Sources/Filters/Sources/PlaneSource/index.js @@ -1,7 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import macro from 'vtk.js/Sources/macro'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; const { vtkWarningMacro } = macro; @@ -21,7 +21,9 @@ function vtkPlaneSource(publicAPI, model) { const dataset = outData[0]; // Check input - const pointDataType = dataset ? dataset.getPoints().getDataType() : 'Float32Array'; + const pointDataType = dataset + ? dataset.getPoints().getDataType() + : 'Float32Array'; const pd = vtkPolyData.newInstance(); const v10 = new Float32Array(3); const v20 = new Float32Array(3); @@ -50,23 +52,26 @@ function vtkPlaneSource(publicAPI, model) { // Texture coords const tcData = new Float32Array(numPts * 2); - const tcoords = vtkDataArray.newInstance({ numberOfComponents: 2, values: tcData, name: 'TextureCoordinates' }); + const tcoords = vtkDataArray.newInstance({ + numberOfComponents: 2, + values: tcData, + name: 'TextureCoordinates', + }); pd.getPointData().setTCoords(tcoords); - const tc = new Float32Array(2); let idx = 0; - for (let j = 0; j < (yres + 1); j++) { + for (let j = 0; j < yres + 1; j++) { tc[1] = j / yres; - for (let i = 0; i < (xres + 1); i++) { + for (let i = 0; i < xres + 1; i++) { tc[0] = i / xres; - points[(idx * 3)] = model.origin[0] + (tc[0] * v10[0]) + (tc[1] * v20[0]); - points[(idx * 3) + 1] = model.origin[1] + (tc[0] * v10[1]) + (tc[1] * v20[1]); - points[(idx * 3) + 2] = model.origin[2] + (tc[0] * v10[2]) + (tc[1] * v20[2]); + points[idx * 3] = model.origin[0] + tc[0] * v10[0] + tc[1] * v20[0]; + points[idx * 3 + 1] = model.origin[1] + tc[0] * v10[1] + tc[1] * v20[1]; + points[idx * 3 + 2] = model.origin[2] + tc[0] * v10[2] + tc[1] * v20[2]; - tcData[(idx * 2)] = tc[0]; - tcData[(idx * 2) + 1] = tc[1]; + tcData[idx * 2] = tc[0]; + tcData[idx * 2 + 1] = tc[1]; idx++; } @@ -77,11 +82,11 @@ function vtkPlaneSource(publicAPI, model) { idx = 0; for (let j = 0; j < yres; j++) { for (let i = 0; i < xres; i++) { - polys[(idx * 5) + 0] = 4; - polys[(idx * 5) + 1] = i + (j * (xres + 1)); - polys[(idx * 5) + 2] = polys[(idx * 5) + 1] + 1; - polys[(idx * 5) + 3] = polys[(idx * 5) + 1] + xres + 2; - polys[(idx * 5) + 4] = polys[(idx * 5) + 1] + xres + 1; + polys[idx * 5 + 0] = 4; + polys[idx * 5 + 1] = i + j * (xres + 1); + polys[idx * 5 + 2] = polys[idx * 5 + 1] + 1; + polys[idx * 5 + 3] = polys[idx * 5 + 1] + xres + 2; + polys[idx * 5 + 4] = polys[idx * 5 + 1] + xres + 1; idx++; } @@ -112,15 +117,8 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.obj(publicAPI, model); - macro.setGet(publicAPI, model, [ - 'xResolution', - 'yResolution', - ]); - macro.setGetArray(publicAPI, model, [ - 'origin', - 'point1', - 'point2', - ], 3); + macro.setGet(publicAPI, model, ['xResolution', 'yResolution']); + macro.setGetArray(publicAPI, model, ['origin', 'point1', 'point2'], 3); macro.algo(publicAPI, model, 0, 1); vtkPlaneSource(publicAPI, model); } diff --git a/Sources/Filters/Sources/PlaneSource/test/testPlane.js b/Sources/Filters/Sources/PlaneSource/test/testPlane.js index c83b3538ebf..5e3338dae34 100644 --- a/Sources/Filters/Sources/PlaneSource/test/testPlane.js +++ b/Sources/Filters/Sources/PlaneSource/test/testPlane.js @@ -1,13 +1,13 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkLight from 'vtk.js/Sources/Rendering/Core/Light'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkLight from 'vtk.js/Sources/Rendering/Core/Light'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import baseline from './testPlane.png'; @@ -17,7 +17,9 @@ test.onlyIfWebGL('Test vtkPlaneSource Rendering', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -46,7 +48,9 @@ test.onlyIfWebGL('Test vtkPlaneSource Rendering', (t) => { const mapper = gc.registerResource(vtkMapper.newInstance()); actor.setMapper(mapper); - const PlaneSource = gc.registerResource(vtkPlaneSource.newInstance({ xResolution: 5, yResolution: 10 })); + const PlaneSource = gc.registerResource( + vtkPlaneSource.newInstance({ xResolution: 5, yResolution: 10 }) + ); mapper.setInputConnection(PlaneSource.getOutputPort()); // now create something to view it, in this case webgl @@ -56,5 +60,12 @@ test.onlyIfWebGL('Test vtkPlaneSource Rendering', (t) => { glwindow.setSize(400, 400); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Filters/Sources/PlaneSource/testPlane', t, 1, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Filters/Sources/PlaneSource/testPlane', + t, + 1, + gc.releaseResources + ); }); diff --git a/Sources/Filters/Sources/PointSource/example/index.js b/Sources/Filters/Sources/PointSource/example/index.js index 1a2c16fbbc8..181876d1bf0 100644 --- a/Sources/Filters/Sources/PointSource/example/index.js +++ b/Sources/Filters/Sources/PointSource/example/index.js @@ -1,10 +1,10 @@ import 'vtk.js/Sources/favicon'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkPointSource from 'vtk.js/Sources/Filters/Sources/PointSource'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkPointSource from 'vtk.js/Sources/Filters/Sources/PointSource'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; import controlPanel from './controlPanel.html'; @@ -12,7 +12,9 @@ import controlPanel from './controlPanel.html'; // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -22,7 +24,10 @@ const renderWindow = fullScreenRenderer.getRenderWindow(); vtkMath.randomSeed(141592); -const pointSource = vtkPointSource.newInstance({ numberOfPoints: 25, radius: 0.25 }); +const pointSource = vtkPointSource.newInstance({ + numberOfPoints: 25, + radius: 0.25, +}); // pointSource.setNumberOfPoints(25); // pointSource.setRadius(0.25); diff --git a/Sources/Filters/Sources/PointSource/index.js b/Sources/Filters/Sources/PointSource/index.js index 74ba319f048..8f667cec4d5 100644 --- a/Sources/Filters/Sources/PointSource/index.js +++ b/Sources/Filters/Sources/PointSource/index.js @@ -1,5 +1,5 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import macro from 'vtk.js/Sources/macro'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; // ---------------------------------------------------------------------------- @@ -18,7 +18,9 @@ function vtkPointSource(publicAPI, model) { const dataset = outData[0]; // Check input - const pointDataType = dataset ? dataset.getPoints().getDataType() : 'Float32Array'; + const pointDataType = dataset + ? dataset.getPoints().getDataType() + : 'Float32Array'; const pd = vtkPolyData.newInstance(); // hand create a point cloud @@ -38,14 +40,14 @@ function vtkPointSource(publicAPI, model) { let radius; let theta; for (let i = 0; i < numPts; i++) { - cosphi = 1 - (2.0 * vtkMath.random()); - sinphi = Math.sqrt(1 - (cosphi * cosphi)); + cosphi = 1 - 2.0 * vtkMath.random(); + sinphi = Math.sqrt(1 - cosphi * cosphi); rho = model.radius * Math.pow(vtkMath.random(), 0.33333333); radius = rho * sinphi; theta = 2.0 * Math.PI * vtkMath.random(); - points[(i * 3)] = model.center[0] + (radius * Math.cos(theta)); - points[(i * 3) + 1] = model.center[1] + (radius * Math.sin(theta)); - points[(i * 3) + 2] = model.center[2] + (rho * cosphi); + points[i * 3] = model.center[0] + radius * Math.cos(theta); + points[i * 3 + 1] = model.center[1] + radius * Math.sin(theta); + points[i * 3 + 2] = model.center[2] + rho * cosphi; } // Generate point connectivity @@ -78,13 +80,8 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.obj(publicAPI, model); - macro.setGet(publicAPI, model, [ - 'numberOfPoints', - 'radius', - ]); - macro.setGetArray(publicAPI, model, [ - 'center', - ], 3); + macro.setGet(publicAPI, model, ['numberOfPoints', 'radius']); + macro.setGetArray(publicAPI, model, ['center'], 3); macro.algo(publicAPI, model, 0, 1); vtkPointSource(publicAPI, model); } diff --git a/Sources/Filters/Sources/PointSource/test/testPointSource.js b/Sources/Filters/Sources/PointSource/test/testPointSource.js index 2cd94cc6ded..98a73521341 100644 --- a/Sources/Filters/Sources/PointSource/test/testPointSource.js +++ b/Sources/Filters/Sources/PointSource/test/testPointSource.js @@ -1,13 +1,13 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkPointSource from 'vtk.js/Sources/Filters/Sources/PointSource'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkPointSource from 'vtk.js/Sources/Filters/Sources/PointSource'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; import basepoint from './testPointSource.png'; @@ -17,7 +17,9 @@ test.onlyIfWebGL('Test vtkPointSource Rendering', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -33,7 +35,9 @@ test.onlyIfWebGL('Test vtkPointSource Rendering', (t) => { const mapper = gc.registerResource(vtkMapper.newInstance()); actor.setMapper(mapper); - const PointSource = gc.registerResource(vtkPointSource.newInstance({ numberOfPoints: 125, radius: 0.75 })); + const PointSource = gc.registerResource( + vtkPointSource.newInstance({ numberOfPoints: 125, radius: 0.75 }) + ); vtkMath.randomSeed(141592); PointSource.update(); mapper.setInputConnection(PointSource.getOutputPort()); @@ -45,5 +49,12 @@ test.onlyIfWebGL('Test vtkPointSource Rendering', (t) => { glwindow.setSize(400, 400); const image = glwindow.captureImage(); - testUtils.compareImages(image, [basepoint], 'Filters/Sources/PointSource/testPointSource', t, 1.0, gc.releaseResources); + testUtils.compareImages( + image, + [basepoint], + 'Filters/Sources/PointSource/testPointSource', + t, + 1.0, + gc.releaseResources + ); }); diff --git a/Sources/Filters/Sources/RTAnalyticSource/index.js b/Sources/Filters/Sources/RTAnalyticSource/index.js index 2e6058dc96c..1f10f607bb0 100644 --- a/Sources/Filters/Sources/RTAnalyticSource/index.js +++ b/Sources/Filters/Sources/RTAnalyticSource/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkImageData from 'vtk.js/Sources/Common/DataModel/ImageData'; import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; @@ -24,7 +24,13 @@ function vtkRTAnalyticSource(publicAPI, model) { }; // Add parameter used to create dataset as metadata.state[*] - ['standardDeviation', 'center', 'frequency', 'magnitude', 'maximum'].forEach((field) => { + [ + 'standardDeviation', + 'center', + 'frequency', + 'magnitude', + 'maximum', + ].forEach((field) => { state[field] = [].concat(model[field]); }); @@ -36,10 +42,13 @@ function vtkRTAnalyticSource(publicAPI, model) { id.setDirection(model.dataDirection); let dims = [0, 0, 0]; - dims = dims.map((_, i) => model.wholeExtent[(i * 2) + 1] - model.wholeExtent[i * 2] + 1); + dims = dims.map( + (_, i) => model.wholeExtent[i * 2 + 1] - model.wholeExtent[i * 2] + 1 + ); const newArray = new Uint8Array(dims[0] * dims[1] * dims[2]); - const temp2 = 1.0 / (2.0 * model.standardDeviation * model.standardDeviation); + const temp2 = + 1.0 / (2.0 * model.standardDeviation * model.standardDeviation); let xval = 0; let yval = 0; @@ -57,20 +66,29 @@ function vtkRTAnalyticSource(publicAPI, model) { zval *= zval; for (let y = model.wholeExtent[2]; y <= model.wholeExtent[3]; y++) { yval = (model.center[1] - y) * scale[1]; - const yfactor = model.magnitude[1] * Math.sin(model.frequency[1] * yval); + const yfactor = + model.magnitude[1] * Math.sin(model.frequency[1] * yval); yval *= yval; for (let x = model.wholeExtent[0]; x <= model.wholeExtent[1]; x++) { xval = (model.center[0] - x) * scale[0]; - const sum = zval + yval + (xval * xval); - const xfactor = model.magnitude[0] * Math.sin(model.frequency[0] * xval); - newArray[i] = (model.maximum * Math.exp(-sum * temp2)) - + xfactor + yfactor + zfactor + model.offset; + const sum = zval + yval + xval * xval; + const xfactor = + model.magnitude[0] * Math.sin(model.frequency[0] * xval); + newArray[i] = + model.maximum * Math.exp(-sum * temp2) + + xfactor + + yfactor + + zfactor + + model.offset; i++; } } } - const da = vtkDataArray.newInstance({ numberOfComponents: 1, values: newArray }); + const da = vtkDataArray.newInstance({ + numberOfComponents: 1, + values: newArray, + }); da.setName('scalars'); const cpd = id.getPointData(); @@ -104,25 +122,13 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.obj(publicAPI, model); - macro.setGet(publicAPI, model, [ - 'offset', - 'maximum', - 'standardDeviation', - ]); - - macro.setGetArray(publicAPI, model, [ - 'center', - 'frequency', - 'magnitude', - ], 3); - - macro.setGetArray(publicAPI, model, [ - 'wholeExtent', - ], 6); - - macro.setGetArray(publicAPI, model, [ - 'dataDirection', - ], 9); + macro.setGet(publicAPI, model, ['offset', 'maximum', 'standardDeviation']); + + macro.setGetArray(publicAPI, model, ['center', 'frequency', 'magnitude'], 3); + + macro.setGetArray(publicAPI, model, ['wholeExtent'], 6); + + macro.setGetArray(publicAPI, model, ['dataDirection'], 9); macro.algo(publicAPI, model, 0, 1); vtkRTAnalyticSource(publicAPI, model); diff --git a/Sources/Filters/Sources/SLICSource/example/index.js b/Sources/Filters/Sources/SLICSource/example/index.js index 8297a9621eb..4dcd428f03e 100644 --- a/Sources/Filters/Sources/SLICSource/example/index.js +++ b/Sources/Filters/Sources/SLICSource/example/index.js @@ -1,17 +1,19 @@ import 'vtk.js/Sources/favicon'; -import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkSLICSource from 'vtk.js/Sources/Filters/Sources/SLICSource'; -import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction'; -import vtkVolume from 'vtk.js/Sources/Rendering/Core/Volume'; -import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper'; +import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkSLICSource from 'vtk.js/Sources/Filters/Sources/SLICSource'; +import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction'; +import vtkVolume from 'vtk.js/Sources/Rendering/Core/Volume'; +import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper'; // ---------------------------------------------------------------------------- // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -32,9 +34,9 @@ for (let i = 0; i < NB_CLUSTERS; i++) { const y = Math.random() * GRID_SIZE[1]; const z = Math.random() * GRID_SIZE[2]; const fnConst = Math.random() * NB_CLUSTERS; - const sx = (Math.random() * 2) - 1; - const sy = (Math.random() * 2) - 1; - const sz = (Math.random() * 2) - 1; + const sx = Math.random() * 2 - 1; + const sy = Math.random() * 2 - 1; + const sz = Math.random() * 2 - 1; source.addCluster(x, y, z, fnConst, sx, sy, sz); } diff --git a/Sources/Filters/Sources/SLICSource/index.js b/Sources/Filters/Sources/SLICSource/index.js index dbf3c3ff317..68e5f3de3ab 100644 --- a/Sources/Filters/Sources/SLICSource/index.js +++ b/Sources/Filters/Sources/SLICSource/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkImageData from 'vtk.js/Sources/Common/DataModel/ImageData'; import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; @@ -7,14 +7,16 @@ import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; // ---------------------------------------------------------------------------- function generateCoordinates(origin, dimensions, spacing) { - const coordinates = new Float32Array(dimensions[0] * dimensions[1] * dimensions[2] * 3); + const coordinates = new Float32Array( + dimensions[0] * dimensions[1] * dimensions[2] * 3 + ); let offset = 0; for (let k = 0; k < dimensions[2]; k++) { - const z = origin[2] + (spacing[2] * k); + const z = origin[2] + spacing[2] * k; for (let j = 0; j < dimensions[1]; j++) { - const y = origin[1] + (spacing[1] * j); + const y = origin[1] + spacing[1] * j; for (let i = 0; i < dimensions[0]; i++) { - const x = origin[0] + (spacing[0] * i); + const x = origin[0] + spacing[0] * i; coordinates[offset++] = x; coordinates[offset++] = y; coordinates[offset++] = z; @@ -32,9 +34,27 @@ function vtkSLICSource(publicAPI, model) { // Set our className model.classHierarchy.push('vtkSLICSource'); - publicAPI.addCluster = (centerX, centerY, centerZ, fnConst, fnDfDx, fnDfDy, fnDfDz) => { + publicAPI.addCluster = ( + centerX, + centerY, + centerZ, + fnConst, + fnDfDx, + fnDfDy, + fnDfDz + ) => { const id = model.clusters.length; - model.clusters.push(new Float32Array([centerX, centerY, centerZ, fnConst, fnDfDx, fnDfDy, fnDfDz])); + model.clusters.push( + new Float32Array([ + centerX, + centerY, + centerZ, + fnConst, + fnDfDx, + fnDfDy, + fnDfDz, + ]) + ); publicAPI.modified(); return id; }; @@ -49,7 +69,16 @@ function vtkSLICSource(publicAPI, model) { publicAPI.modified(); }; - publicAPI.updateCluster = (id, centerX, centerY, centerZ, fnConst, fnDfDx, fnDfDy, fnDfDz) => { + publicAPI.updateCluster = ( + id, + centerX, + centerY, + centerZ, + fnConst, + fnDfDx, + fnDfDy, + fnDfDz + ) => { if (!model.clusters[id]) { model.clusters[id] = new Float32Array(7); } @@ -70,44 +99,68 @@ function vtkSLICSource(publicAPI, model) { return; } - const dataSize = model.dimensions[0] * model.dimensions[1] * model.dimensions[2]; + const dataSize = + model.dimensions[0] * model.dimensions[1] * model.dimensions[2]; const imageData = vtkImageData.newInstance(); imageData.setSpacing(...model.spacing); - imageData.setExtent(0, model.dimensions[0] - 1, 0, model.dimensions[1] - 1, 0, model.dimensions[2] - 1); + imageData.setExtent( + 0, + model.dimensions[0] - 1, + 0, + model.dimensions[1] - 1, + 0, + model.dimensions[2] - 1 + ); imageData.setOrigin(...model.origin); // Pixel centers - const centers = generateCoordinates(model.origin, model.dimensions, model.spacing); + const centers = generateCoordinates( + model.origin, + model.dimensions, + model.spacing + ); // Fill clusterIdxValues - const nbBytes = (model.clusters.length < 256) ? 8 : ((model.clusters.length < 65536) ? 16 : 32); + const nbBytes = + model.clusters.length < 256 ? 8 : model.clusters.length < 65536 ? 16 : 32; const clusterIdxValues = new window[`Uint${nbBytes}Array`](dataSize); for (let i = 0; i < dataSize; i++) { let clusterDistance = Number.MAX_VALUE; model.clusters.forEach((cluster, idx) => { - const dist = ((cluster[0] - centers[i * 3]) * (cluster[0] - centers[i * 3])) - + ((cluster[1] - centers[(i * 3) + 1]) * (cluster[1] - centers[(i * 3) + 1])) - + ((cluster[2] - centers[(i * 3) + 2]) * (cluster[2] - centers[(i * 3) + 2])); + const dist = + (cluster[0] - centers[i * 3]) * (cluster[0] - centers[i * 3]) + + (cluster[1] - centers[i * 3 + 1]) * + (cluster[1] - centers[i * 3 + 1]) + + (cluster[2] - centers[i * 3 + 2]) * (cluster[2] - centers[i * 3 + 2]); if (dist < clusterDistance) { clusterDistance = dist; clusterIdxValues[i] = idx; } }); } - const clusters = vtkDataArray.newInstance({ name: model.clusterArrayName, numberOfComponents: 1, values: clusterIdxValues }); + const clusters = vtkDataArray.newInstance({ + name: model.clusterArrayName, + numberOfComponents: 1, + values: clusterIdxValues, + }); imageData.getPointData().addArray(clusters); // Fill scalarValues const scalarValues = new Float32Array(dataSize); for (let i = 0; i < dataSize; i++) { const cluster = model.clusters[clusterIdxValues[i]]; - scalarValues[i] = cluster[3] - + (cluster[4] * (centers[(i * 3) + 0] - cluster[0])) - + (cluster[5] * (centers[(i * 3) + 1] - cluster[1])) - + (cluster[6] * (centers[(i * 3) + 2] - cluster[2])); + scalarValues[i] = + cluster[3] + + cluster[4] * (centers[i * 3 + 0] - cluster[0]) + + cluster[5] * (centers[i * 3 + 1] - cluster[1]) + + cluster[6] * (centers[i * 3 + 2] - cluster[2]); } - const scalars = vtkDataArray.newInstance({ name: model.scalarArrayName, numberOfComponents: 1, values: scalarValues }); + const scalars = vtkDataArray.newInstance({ + name: model.scalarArrayName, + numberOfComponents: 1, + values: scalarValues, + }); imageData.getPointData().addArray(scalars); // Update output diff --git a/Sources/Filters/Sources/SphereSource/example/index.js b/Sources/Filters/Sources/SphereSource/example/index.js index 19824c413a5..650faa3c74b 100644 --- a/Sources/Filters/Sources/SphereSource/example/index.js +++ b/Sources/Filters/Sources/SphereSource/example/index.js @@ -1,9 +1,9 @@ import 'vtk.js/Sources/favicon'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import controlPanel from './controlPanel.html'; @@ -11,7 +11,9 @@ import controlPanel from './controlPanel.html'; // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -38,7 +40,15 @@ renderWindow.render(); fullScreenRenderer.addController(controlPanel); -['radius', 'thetaResolution', 'startTheta', 'endTheta', 'phiResolution', 'startPhi', 'endPhi'].forEach((propertyName) => { +[ + 'radius', + 'thetaResolution', + 'startTheta', + 'endTheta', + 'phiResolution', + 'startPhi', + 'endPhi', +].forEach((propertyName) => { document.querySelector(`.${propertyName}`).addEventListener('input', (e) => { const value = Number(e.target.value); sphereSource.set({ [propertyName]: value }); @@ -47,7 +57,7 @@ fullScreenRenderer.addController(controlPanel); }); document.querySelector('.edgeVisibility').addEventListener('change', (e) => { - const edgeVisibility = !!(e.target.checked); + const edgeVisibility = !!e.target.checked; actor.getProperty().setEdgeVisibility(edgeVisibility); renderWindow.render(); }); diff --git a/Sources/Filters/Sources/SphereSource/index.js b/Sources/Filters/Sources/SphereSource/index.js index 40fad765fc1..ebf48163aa7 100644 --- a/Sources/Filters/Sources/SphereSource/index.js +++ b/Sources/Filters/Sources/SphereSource/index.js @@ -1,5 +1,5 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import macro from 'vtk.js/Sources/macro'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; // ---------------------------------------------------------------------------- @@ -16,7 +16,9 @@ function vtkSphereSource(publicAPI, model) { } let dataset = outData[0]; - const pointDataType = dataset ? dataset.getPoints().getDataType() : 'Float32Array'; + const pointDataType = dataset + ? dataset.getPoints().getDataType() + : 'Float32Array'; dataset = vtkPolyData.newInstance(); // ---------------------------------------------------------------------- @@ -24,14 +26,17 @@ function vtkSphereSource(publicAPI, model) { // Check data, determine increments, and convert to radians let thetaResolution = model.thetaResolution; - let startTheta = (model.startTheta < model.endTheta ? model.startTheta : model.endTheta); + let startTheta = + model.startTheta < model.endTheta ? model.startTheta : model.endTheta; startTheta *= Math.PI / 180.0; - let endTheta = (model.endTheta > model.startTheta ? model.endTheta : model.startTheta); + let endTheta = + model.endTheta > model.startTheta ? model.endTheta : model.startTheta; endTheta *= Math.PI / 180.0; - let startPhi = (model.startPhi < model.endPhi ? model.startPhi : model.endPhi); + let startPhi = + model.startPhi < model.endPhi ? model.startPhi : model.endPhi; startPhi *= Math.PI / 180.0; - let endPhi = (model.endPhi > model.startPhi ? model.endPhi : model.startPhi); + let endPhi = model.endPhi > model.startPhi ? model.endPhi : model.startPhi; endPhi *= Math.PI / 180.0; if (Math.abs(startTheta - endTheta) < 2.0 * Math.PI) { @@ -39,10 +44,10 @@ function vtkSphereSource(publicAPI, model) { } const deltaTheta = (endTheta - startTheta) / model.thetaResolution; - const jStart = (model.startPhi <= 0.0 ? 1 : 0); + const jStart = model.startPhi <= 0.0 ? 1 : 0; const jEnd = model.phiResolution + (model.endPhi >= 180.0 ? -1 : 0); - const numPts = (model.phiResolution * thetaResolution) + 2; + const numPts = model.phiResolution * thetaResolution + 2; const numPolys = model.phiResolution * 2 * model.thetaResolution; // Points @@ -58,13 +63,13 @@ function vtkSphereSource(publicAPI, model) { // Create north pole if needed if (model.startPhi <= 0.0) { - points[(pointIdx * 3) + 0] = model.center[0]; - points[(pointIdx * 3) + 1] = model.center[1]; - points[(pointIdx * 3) + 2] = model.center[2] + model.radius; + points[pointIdx * 3 + 0] = model.center[0]; + points[pointIdx * 3 + 1] = model.center[1]; + points[pointIdx * 3 + 2] = model.center[2] + model.radius; - normals[(pointIdx * 3) + 0] = 0; - normals[(pointIdx * 3) + 1] = 0; - normals[(pointIdx * 3) + 2] = 1; + normals[pointIdx * 3 + 0] = 0; + normals[pointIdx * 3 + 1] = 0; + normals[pointIdx * 3 + 2] = 1; pointIdx++; numPoles++; @@ -72,13 +77,13 @@ function vtkSphereSource(publicAPI, model) { // Create south pole if needed if (model.endPhi >= 180.0) { - points[(pointIdx * 3) + 0] = model.center[0]; - points[(pointIdx * 3) + 1] = model.center[1]; - points[(pointIdx * 3) + 2] = model.center[2] - model.radius; + points[pointIdx * 3 + 0] = model.center[0]; + points[pointIdx * 3 + 1] = model.center[1]; + points[pointIdx * 3 + 2] = model.center[2] - model.radius; - normals[(pointIdx * 3) + 0] = 0; - normals[(pointIdx * 3) + 1] = 0; - normals[(pointIdx * 3) + 2] = -1; + normals[pointIdx * 3 + 0] = 0; + normals[pointIdx * 3 + 1] = 0; + normals[pointIdx * 3 + 2] = -1; pointIdx++; numPoles++; @@ -89,28 +94,29 @@ function vtkSphereSource(publicAPI, model) { // Create intermediate points for (let i = 0; i < thetaResolution; i++) { - const theta = startTheta + (i * deltaTheta); + const theta = startTheta + i * deltaTheta; for (let j = jStart; j < jEnd; j++) { - const phi = startPhi + (j * deltaPhi); + const phi = startPhi + j * deltaPhi; const radius = model.radius * Math.sin(phi); - normals[(pointIdx * 3) + 0] = radius * Math.cos(theta); - normals[(pointIdx * 3) + 1] = radius * Math.sin(theta); - normals[(pointIdx * 3) + 2] = model.radius * Math.cos(phi); + normals[pointIdx * 3 + 0] = radius * Math.cos(theta); + normals[pointIdx * 3 + 1] = radius * Math.sin(theta); + normals[pointIdx * 3 + 2] = model.radius * Math.cos(phi); - points[(pointIdx * 3) + 0] = normals[(pointIdx * 3) + 0] + model.center[0]; - points[(pointIdx * 3) + 1] = normals[(pointIdx * 3) + 1] + model.center[1]; - points[(pointIdx * 3) + 2] = normals[(pointIdx * 3) + 2] + model.center[2]; + points[pointIdx * 3 + 0] = normals[pointIdx * 3 + 0] + model.center[0]; + points[pointIdx * 3 + 1] = normals[pointIdx * 3 + 1] + model.center[1]; + points[pointIdx * 3 + 2] = normals[pointIdx * 3 + 2] + model.center[2]; let norm = Math.sqrt( - (normals[(pointIdx * 3) + 0] * normals[(pointIdx * 3) + 0]) + - (normals[(pointIdx * 3) + 1] * normals[(pointIdx * 3) + 1]) + - (normals[(pointIdx * 3) + 2] * normals[(pointIdx * 3) + 2])); + normals[pointIdx * 3 + 0] * normals[pointIdx * 3 + 0] + + normals[pointIdx * 3 + 1] * normals[pointIdx * 3 + 1] + + normals[pointIdx * 3 + 2] * normals[pointIdx * 3 + 2] + ); - norm = (norm === 0) ? 1 : norm; - normals[(pointIdx * 3) + 0] /= norm; - normals[(pointIdx * 3) + 1] /= norm; - normals[(pointIdx * 3) + 2] /= norm; + norm = norm === 0 ? 1 : norm; + normals[pointIdx * 3 + 0] /= norm; + normals[pointIdx * 3 + 1] /= norm; + normals[pointIdx * 3 + 2] /= norm; pointIdx++; } @@ -127,8 +133,8 @@ function vtkSphereSource(publicAPI, model) { if (model.startPhi <= 0.0) { for (let i = 0; i < thetaResolution; i++) { polys[cellLocation++] = 3; - polys[cellLocation++] = (phiResolution * i) + numPoles; - polys[cellLocation++] = (phiResolution * (i + 1) % base) + numPoles; + polys[cellLocation++] = phiResolution * i + numPoles; + polys[cellLocation++] = (phiResolution * (i + 1)) % base + numPoles; polys[cellLocation++] = 0; } } @@ -139,18 +145,18 @@ function vtkSphereSource(publicAPI, model) { for (let i = 0; i < thetaResolution; i++) { polys[cellLocation++] = 3; - polys[cellLocation++] = (phiResolution * i) + numOffset; + polys[cellLocation++] = phiResolution * i + numOffset; polys[cellLocation++] = numPoles - 1; - polys[cellLocation++] = ((phiResolution * (i + 1)) % base) + numOffset; + polys[cellLocation++] = (phiResolution * (i + 1)) % base + numOffset; } } // bands in-between poles for (let i = 0; i < thetaResolution; i++) { - for (let j = 0; j < (phiResolution - 1); j++) { - const a = (phiResolution * i) + j + numPoles; + for (let j = 0; j < phiResolution - 1; j++) { + const a = phiResolution * i + j + numPoles; const b = a + 1; - const c = (((phiResolution * (i + 1)) + j) % base) + numPoles + 1; + const c = (phiResolution * (i + 1) + j) % base + numPoles + 1; if (!model.latLongTessellation) { polys[cellLocation++] = 3; @@ -176,7 +182,11 @@ function vtkSphereSource(publicAPI, model) { dataset.getPoints().setData(points, 3); normals = normals.subarray(0, pointIdx * 3); - const normalArray = vtkDataArray.newInstance({ name: 'Normals', values: normals, numberOfComponents: 3 }); + const normalArray = vtkDataArray.newInstance({ + name: 'Normals', + values: normals, + numberOfComponents: 3, + }); dataset.getPointData().setNormals(normalArray); polys = polys.subarray(0, cellLocation); diff --git a/Sources/Filters/Sources/index.js b/Sources/Filters/Sources/index.js index 96447a496ef..e1da9e4a6cd 100644 --- a/Sources/Filters/Sources/index.js +++ b/Sources/Filters/Sources/index.js @@ -1,13 +1,13 @@ -import vtkConcentricCylinderSource from './ConcentricCylinderSource'; -import vtkConeSource from './ConeSource'; -import vtkCubeSource from './CubeSource'; -import vtkImageGridSource from './ImageGridSource'; -import vtkLineSource from './LineSource'; -import vtkPlaneSource from './PlaneSource'; -import vtkPointSource from './PointSource'; -import vtkRTAnalyticSource from './RTAnalyticSource'; -import vtkSLICSource from './SLICSource'; -import vtkSphereSource from './SphereSource'; +import vtkConcentricCylinderSource from './ConcentricCylinderSource'; +import vtkConeSource from './ConeSource'; +import vtkCubeSource from './CubeSource'; +import vtkImageGridSource from './ImageGridSource'; +import vtkLineSource from './LineSource'; +import vtkPlaneSource from './PlaneSource'; +import vtkPointSource from './PointSource'; +import vtkRTAnalyticSource from './RTAnalyticSource'; +import vtkSLICSource from './SLICSource'; +import vtkSphereSource from './SphereSource'; export default { vtkConcentricCylinderSource, diff --git a/Sources/Filters/Texture/TextureMapToSphere/index.js b/Sources/Filters/Texture/TextureMapToSphere/index.js index 15b15675e83..00aad1195cf 100644 --- a/Sources/Filters/Texture/TextureMapToSphere/index.js +++ b/Sources/Filters/Texture/TextureMapToSphere/index.js @@ -143,13 +143,8 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.obj(publicAPI, model); - macro.setGetArray(publicAPI, model, [ - 'center', - ]); - macro.setGet(publicAPI, model, [ - 'automaticSphereGeneration', - 'preventSeam', - ]); + macro.setGetArray(publicAPI, model, ['center']); + macro.setGet(publicAPI, model, ['automaticSphereGeneration', 'preventSeam']); macro.algo(publicAPI, model, 1, 1); vtkTextureMapToSphere(publicAPI, model); diff --git a/Sources/Filters/Texture/TextureMapToSphere/test/testTextureMapToSphere.js b/Sources/Filters/Texture/TextureMapToSphere/test/testTextureMapToSphere.js index bd350e5a3cf..480733cf20b 100644 --- a/Sources/Filters/Texture/TextureMapToSphere/test/testTextureMapToSphere.js +++ b/Sources/Filters/Texture/TextureMapToSphere/test/testTextureMapToSphere.js @@ -1,4 +1,4 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; import vtkTextureMapToSphere from 'vtk.js/Sources/Filters/Texture/TextureMapToSphere'; @@ -17,7 +17,13 @@ test('Test vtkTextureMapToSphere TCoords generation', (t) => { sphereTextureFilter.setInputData(cube); sphereTextureFilter.update(); - const generatedTCoords = sphereTextureFilter.getOutputData().getPointData().getTCoords().getData(); + const generatedTCoords = sphereTextureFilter + .getOutputData() + .getPointData() + .getTCoords() + .getData(); + + // prettier-ignore const expectedData = [ 0.75, 0.695913, 0.75, 0.304087, diff --git a/Sources/Filters/Texture/index.js b/Sources/Filters/Texture/index.js index a5f7634bee3..a8616b7bd79 100644 --- a/Sources/Filters/Texture/index.js +++ b/Sources/Filters/Texture/index.js @@ -1,4 +1,4 @@ -import vtkTextureMapToSphere from './TextureMapToSphere'; +import vtkTextureMapToSphere from './TextureMapToSphere'; export default { vtkTextureMapToSphere, diff --git a/Sources/IO/Core/BinaryHelper/index.js b/Sources/IO/Core/BinaryHelper/index.js index 83fac42d675..df9839dee22 100644 --- a/Sources/IO/Core/BinaryHelper/index.js +++ b/Sources/IO/Core/BinaryHelper/index.js @@ -50,5 +50,6 @@ function extractBinary(arrayBuffer, prefixRegex, suffixRegex = null) { } export default { - arrayBufferToString, extractBinary, + arrayBufferToString, + extractBinary, }; diff --git a/Sources/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js b/Sources/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js index fdd5b939d5b..84daf81add3 100644 --- a/Sources/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js +++ b/Sources/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js @@ -1,8 +1,8 @@ import { toByteArray } from 'base64-js'; -import pako from 'pako'; +import pako from 'pako'; -import macro from 'vtk.js/Sources/macro'; -import Endian from 'vtk.js/Sources/Common/Core/Endian'; +import macro from 'vtk.js/Sources/macro'; +import Endian from 'vtk.js/Sources/Common/Core/Endian'; import { DataTypeByteSize } from 'vtk.js/Sources/Common/Core/DataArray/Constants'; const { vtkErrorMacro, vtkDebugMacro } = macro; @@ -14,12 +14,10 @@ function getContent(url) { return el ? el.innerHTML : null; } - function removeLeadingSlash(str) { - return (str[0] === '/') ? str.substr(1) : str; + return str[0] === '/' ? str.substr(1) : str; } - function fetchText(instance = {}, url, options = {}) { return new Promise((resolve, reject) => { const txt = getContent(url); @@ -31,7 +29,6 @@ function fetchText(instance = {}, url, options = {}) { }); } - function fetchJSON(instance = {}, url, options = {}) { return new Promise((resolve, reject) => { const txt = getContent(removeLeadingSlash(url)); @@ -43,10 +40,15 @@ function fetchJSON(instance = {}, url, options = {}) { }); } - function fetchArray(instance = {}, baseURL, array, options = {}) { return new Promise((resolve, reject) => { - const url = removeLeadingSlash([baseURL, array.ref.basepath, options.compression ? `${array.ref.id}.gz` : array.ref.id].join('/')); + const url = removeLeadingSlash( + [ + baseURL, + array.ref.basepath, + options.compression ? `${array.ref.id}.gz` : array.ref.id, + ].join('/') + ); const txt = getContent(url); if (txt === null) { @@ -69,7 +71,9 @@ function fetchArray(instance = {}, baseURL, array, options = {}) { if (options.compression) { if (array.dataType === 'string' || array.dataType === 'JSON') { - array.buffer = pako.inflate(new Uint8Array(array.buffer), { to: 'string' }); + array.buffer = pako.inflate(new Uint8Array(array.buffer), { + to: 'string', + }); } else { array.buffer = pako.inflate(new Uint8Array(array.buffer)).buffer; } @@ -88,7 +92,13 @@ function fetchArray(instance = {}, baseURL, array, options = {}) { } if (array.values.length !== array.size) { - vtkErrorMacro(`Error in FetchArray: ${array.name} does not have the proper array size. Got ${array.values.length}, instead of ${array.size}`); + vtkErrorMacro( + `Error in FetchArray: ${ + array.name + } does not have the proper array size. Got ${ + array.values.length + }, instead of ${array.size}` + ); } } diff --git a/Sources/IO/Core/DataAccessHelper/HttpDataAccessHelper.js b/Sources/IO/Core/DataAccessHelper/HttpDataAccessHelper.js index 2dad398fe50..a0b8e272933 100644 --- a/Sources/IO/Core/DataAccessHelper/HttpDataAccessHelper.js +++ b/Sources/IO/Core/DataAccessHelper/HttpDataAccessHelper.js @@ -1,7 +1,7 @@ import pako from 'pako'; -import macro from 'vtk.js/Sources/macro'; -import Endian from 'vtk.js/Sources/Common/Core/Endian'; +import macro from 'vtk.js/Sources/macro'; +import Endian from 'vtk.js/Sources/Common/Core/Endian'; import { DataTypeByteSize } from 'vtk.js/Sources/Common/Core/DataArray/Constants'; const { vtkErrorMacro, vtkDebugMacro } = macro; @@ -37,7 +37,11 @@ function fetchArray(instance = {}, baseURL, array, options = {}) { if (array.ref && !array.ref.pending) { return new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); - const url = [baseURL, array.ref.basepath, options.compression ? `${array.ref.id}.gz` : array.ref.id].join('/'); + const url = [ + baseURL, + array.ref.basepath, + options.compression ? `${array.ref.id}.gz` : array.ref.id, + ].join('/'); xhr.onreadystatechange = (e) => { if (xhr.readyState === 1) { @@ -53,9 +57,13 @@ function fetchArray(instance = {}, baseURL, array, options = {}) { if (options.compression) { if (array.dataType === 'string' || array.dataType === 'JSON') { - array.buffer = pako.inflate(new Uint8Array(array.buffer), { to: 'string' }); + array.buffer = pako.inflate(new Uint8Array(array.buffer), { + to: 'string', + }); } else { - array.buffer = pako.inflate(new Uint8Array(array.buffer)).buffer; + array.buffer = pako.inflate( + new Uint8Array(array.buffer) + ).buffer; } } @@ -65,14 +73,23 @@ function fetchArray(instance = {}, baseURL, array, options = {}) { if (Endian.ENDIANNESS !== array.ref.encode && Endian.ENDIANNESS) { // Need to swap bytes vtkDebugMacro(`Swap bytes of ${array.name}`); - Endian.swapBytes(array.buffer, DataTypeByteSize[array.dataType]); + Endian.swapBytes( + array.buffer, + DataTypeByteSize[array.dataType] + ); } array.values = new window[array.dataType](array.buffer); } if (array.values.length !== array.size) { - vtkErrorMacro(`Error in FetchArray: ${array.name}, does not have the proper array size. Got ${array.values.length}, instead of ${array.size}`); + vtkErrorMacro( + `Error in FetchArray: ${ + array.name + }, does not have the proper array size. Got ${ + array.values.length + }, instead of ${array.size}` + ); } // Done with the ref and work @@ -96,7 +113,10 @@ function fetchArray(instance = {}, baseURL, array, options = {}) { // Make request xhr.open('GET', url, true); - xhr.responseType = (options.compression || array.dataType !== 'string') ? 'arraybuffer' : 'text'; + xhr.responseType = + options.compression || array.dataType !== 'string' + ? 'arraybuffer' + : 'text'; xhr.send(); }); } @@ -124,7 +144,11 @@ function fetchJSON(instance = {}, url, options = {}) { } if (xhr.status === 200 || xhr.status === 0) { if (options.compression) { - resolve(JSON.parse(pako.inflate(new Uint8Array(xhr.response), { to: 'string' }))); + resolve( + JSON.parse( + pako.inflate(new Uint8Array(xhr.response), { to: 'string' }) + ) + ); } else { resolve(JSON.parse(xhr.responseText)); } @@ -168,7 +192,9 @@ function fetchText(instance = {}, url, options = {}) { } if (xhr.status === 200 || xhr.status === 0) { if (options.compression) { - resolve(pako.inflate(new Uint8Array(xhr.response), { to: 'string' })); + resolve( + pako.inflate(new Uint8Array(xhr.response), { to: 'string' }) + ); } else { resolve(xhr.responseText); } @@ -189,7 +215,6 @@ function fetchText(instance = {}, url, options = {}) { }); } - // ---------------------------------------------------------------------------- export default { diff --git a/Sources/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js b/Sources/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js index b05983657da..0b6d3a4801d 100644 --- a/Sources/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +++ b/Sources/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js @@ -1,8 +1,8 @@ -import JSZip from 'jszip'; -import pako from 'pako'; +import JSZip from 'jszip'; +import pako from 'pako'; -import macro from 'vtk.js/Sources/macro'; -import Endian from 'vtk.js/Sources/Common/Core/Endian'; +import macro from 'vtk.js/Sources/macro'; +import Endian from 'vtk.js/Sources/Common/Core/Endian'; import { DataTypeByteSize } from 'vtk.js/Sources/Common/Core/DataArray/Constants'; const { vtkErrorMacro, vtkDebugMacro } = macro; @@ -17,7 +17,9 @@ function handleUint8Array(array, compression, done) { if (compression) { if (array.dataType === 'string' || array.dataType === 'JSON') { - array.buffer = pako.inflate(new Uint8Array(array.buffer), { to: 'string' }); + array.buffer = pako.inflate(new Uint8Array(array.buffer), { + to: 'string', + }); } else { array.buffer = pako.inflate(new Uint8Array(array.buffer)).buffer; } @@ -36,7 +38,13 @@ function handleUint8Array(array, compression, done) { } if (array.values.length !== array.size) { - vtkErrorMacro(`Error in FetchArray: ${array.name} does not have the proper array size. Got ${array.values.length}, instead of ${array.size}`); + vtkErrorMacro( + `Error in FetchArray: ${ + array.name + } does not have the proper array size. Got ${ + array.values.length + }, instead of ${array.size}` + ); } done(); @@ -60,7 +68,7 @@ const handlers = { }; function removeLeadingSlash(str) { - return (str[0] === '/') ? str.substr(1) : str; + return str[0] === '/' ? str.substr(1) : str; } function create(createOptions) { @@ -68,35 +76,40 @@ function create(createOptions) { let requestCount = 0; const zip = new JSZip(); let zipRoot = zip; - zip.loadAsync(createOptions.zipContent) - .then(() => { - ready = true; - - // Find root index.json - const metaFiles = []; - zip.forEach((relativePath, zipEntry) => { - if (relativePath.indexOf('index.json') !== -1) { - metaFiles.push(relativePath); - } - }); - metaFiles.sort((a, b) => a.length - b.length); - const fullRootPath = metaFiles[0].split('/'); - while (fullRootPath.length > 1) { - const dirName = fullRootPath.shift(); - zipRoot = zipRoot.folder(dirName); - } - - if (createOptions.callback) { - createOptions.callback(zip); + zip.loadAsync(createOptions.zipContent).then(() => { + ready = true; + + // Find root index.json + const metaFiles = []; + zip.forEach((relativePath, zipEntry) => { + if (relativePath.indexOf('index.json') !== -1) { + metaFiles.push(relativePath); } }); + metaFiles.sort((a, b) => a.length - b.length); + const fullRootPath = metaFiles[0].split('/'); + while (fullRootPath.length > 1) { + const dirName = fullRootPath.shift(); + zipRoot = zipRoot.folder(dirName); + } + + if (createOptions.callback) { + createOptions.callback(zip); + } + }); return { fetchArray(instance = {}, baseURL, array, options = {}) { return new Promise((resolve, reject) => { if (!ready) { vtkErrorMacro('ERROR!!! zip not ready...'); } - const url = removeLeadingSlash([baseURL, array.ref.basepath, options.compression ? `${array.ref.id}.gz` : array.ref.id].join('/')); + const url = removeLeadingSlash( + [ + baseURL, + array.ref.basepath, + options.compression ? `${array.ref.id}.gz` : array.ref.id, + ].join('/') + ); if (++requestCount === 1 && instance.invokeBusy) { instance.invokeBusy(true); @@ -114,10 +127,18 @@ function create(createOptions) { resolve(array); } - const asyncType = array.dataType === 'string' && !options.compression ? 'string' : 'uint8array'; - const asyncCallback = handlers[asyncType](array, options.compression, doneCleanUp); - - zipRoot.file(url) + const asyncType = + array.dataType === 'string' && !options.compression + ? 'string' + : 'uint8array'; + const asyncCallback = handlers[asyncType]( + array, + options.compression, + doneCleanUp + ); + + zipRoot + .file(url) .async(asyncType) .then(asyncCallback); }); @@ -131,15 +152,21 @@ function create(createOptions) { if (options.compression) { if (options.compression === 'gz') { - return zipRoot.file(path).async('uint8array').then((uint8array) => { - const str = pako.inflate(uint8array, { to: 'string' }); - return new Promise(ok => ok(JSON.parse(str))); - }); + return zipRoot + .file(path) + .async('uint8array') + .then((uint8array) => { + const str = pako.inflate(uint8array, { to: 'string' }); + return new Promise((ok) => ok(JSON.parse(str))); + }); } return new Promise((a, r) => r('Invalid compression')); } - return zipRoot.file(path).async('string').then(str => new Promise(ok => ok(JSON.parse(str)))); + return zipRoot + .file(path) + .async('string') + .then((str) => new Promise((ok) => ok(JSON.parse(str)))); }, fetchText(instance = {}, url, options = {}) { @@ -150,15 +177,21 @@ function create(createOptions) { if (options.compression) { if (options.compression === 'gz') { - return zipRoot.file(path).async('uint8array').then((uint8array) => { - const str = pako.inflate(uint8array, { to: 'string' }); - return new Promise(ok => ok(str)); - }); + return zipRoot + .file(path) + .async('uint8array') + .then((uint8array) => { + const str = pako.inflate(uint8array, { to: 'string' }); + return new Promise((ok) => ok(str)); + }); } return new Promise((a, r) => r('Invalid compression')); } - return zipRoot.file(path).async('string').then(str => new Promise(ok => ok(str))); + return zipRoot + .file(path) + .async('string') + .then((str) => new Promise((ok) => ok(str))); }, }; } diff --git a/Sources/IO/Core/DataAccessHelper/index.js b/Sources/IO/Core/DataAccessHelper/index.js index 28287488c2b..c0c488bff76 100644 --- a/Sources/IO/Core/DataAccessHelper/index.js +++ b/Sources/IO/Core/DataAccessHelper/index.js @@ -1,11 +1,11 @@ -import HtmlDataAccessHelper from './HtmlDataAccessHelper'; -import HttpDataAccessHelper from './HttpDataAccessHelper'; -import JSZipDataAccessHelper from './JSZipDataAccessHelper'; +import HtmlDataAccessHelper from './HtmlDataAccessHelper'; +import HttpDataAccessHelper from './HttpDataAccessHelper'; +import JSZipDataAccessHelper from './JSZipDataAccessHelper'; const TYPE_MAPPING = { - http: options => HttpDataAccessHelper, - zip: options => JSZipDataAccessHelper.create(options), - html: options => HtmlDataAccessHelper, + http: (options) => HttpDataAccessHelper, + zip: (options) => JSZipDataAccessHelper.create(options), + html: (options) => HtmlDataAccessHelper, }; function get(type = 'http', options = {}) { diff --git a/Sources/IO/Core/HttpDataSetReader/example/index.js b/Sources/IO/Core/HttpDataSetReader/example/index.js index d3a24b65906..7ce67e6c6a4 100644 --- a/Sources/IO/Core/HttpDataSetReader/example/index.js +++ b/Sources/IO/Core/HttpDataSetReader/example/index.js @@ -1,9 +1,9 @@ import 'vtk.js/Sources/favicon'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; // ---------------------------------------------------------------------------- // Standard rendering code setup diff --git a/Sources/IO/Core/HttpDataSetReader/index.js b/Sources/IO/Core/HttpDataSetReader/index.js index ca4e9c2be46..f2ffeb7a857 100644 --- a/Sources/IO/Core/HttpDataSetReader/index.js +++ b/Sources/IO/Core/HttpDataSetReader/index.js @@ -2,11 +2,11 @@ import 'vtk.js/Sources/Common/DataModel/ImageData'; import 'vtk.js/Sources/Common/DataModel/PolyData'; -import vtk from 'vtk.js/Sources/vtk'; -import macro from 'vtk.js/Sources/macro'; +import vtk from 'vtk.js/Sources/vtk'; +import macro from 'vtk.js/Sources/macro'; import DataAccessHelper from 'vtk.js/Sources/IO/Core/DataAccessHelper'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkStringArray from 'vtk.js/Sources/Common/Core/StringArray'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkStringArray from 'vtk.js/Sources/Common/Core/StringArray'; const fieldDataLocations = ['pointData', 'cellData', 'fieldData']; const HTTP_DATA_ACCESS = DataAccessHelper.get('http'); @@ -55,7 +55,15 @@ const GEOMETRY_ARRAYS = { }, }; -function processDataSet(publicAPI, model, dataset, fetchArray, resolve, reject, loadData) { +function processDataSet( + publicAPI, + model, + dataset, + fetchArray, + resolve, + reject, + loadData +) { const enable = model.enableArray; // Generate array list @@ -63,8 +71,14 @@ function processDataSet(publicAPI, model, dataset, fetchArray, resolve, reject, fieldDataLocations.forEach((location) => { if (dataset[location]) { - dataset[location].arrays.map(i => i.data).forEach((array) => { - model.arrays.push({ name: array.name, enable, location, array, registration: array.ref.registration || 'addArray' }); + dataset[location].arrays.map((i) => i.data).forEach((array) => { + model.arrays.push({ + name: array.name, + enable, + location, + array, + registration: array.ref.registration || 'addArray', + }); }); // Reset data arrays @@ -86,29 +100,23 @@ function processDataSet(publicAPI, model, dataset, fetchArray, resolve, reject, model.output[0] = model.dataset; resolve(publicAPI, model.output[0]); } else { - publicAPI.loadData().then( - () => { - model.output[0] = model.dataset; - resolve(publicAPI, model.output[0]); - }); + publicAPI.loadData().then(() => { + model.output[0] = model.dataset; + resolve(publicAPI, model.output[0]); + }); } } // Wait for all geometry array to be fetched if (pendingPromises.length) { - Promise.all(pendingPromises) - .then( - success, - (err) => { - reject(err); - }, - ); + Promise.all(pendingPromises).then(success, (err) => { + reject(err); + }); } else { success(); } } - // ---------------------------------------------------------------------------- // vtkHttpDataSetReader methods // ---------------------------------------------------------------------------- @@ -127,7 +135,12 @@ function vtkHttpDataSetReader(publicAPI, model) { // Internal method to fetch Array function fetchArray(array, options = {}) { - return model.dataAccessHelper.fetchArray(publicAPI, model.baseURL, array, options); + return model.dataAccessHelper.fetchArray( + publicAPI, + model.baseURL, + array, + options + ); } // Fetch dataset (metadata) @@ -136,44 +149,53 @@ function vtkHttpDataSetReader(publicAPI, model) { return new Promise((resolve, reject) => { HTTP_DATA_ACCESS.fetchBinary(model.url).then( (zipContent) => { - model.dataAccessHelper = DataAccessHelper.get( - 'zip', - { - zipContent, - callback: (zip) => { - model.baseURL = ''; - model.dataAccessHelper - .fetchJSON(publicAPI, 'index.json') - .then( - (dataset) => { - processDataSet(publicAPI, model, dataset, fetchArray, resolve, reject, loadData); - }, - (xhr, e) => { - reject(xhr, e); - }, + model.dataAccessHelper = DataAccessHelper.get('zip', { + zipContent, + callback: (zip) => { + model.baseURL = ''; + model.dataAccessHelper.fetchJSON(publicAPI, 'index.json').then( + (dataset) => { + processDataSet( + publicAPI, + model, + dataset, + fetchArray, + resolve, + reject, + loadData ); - }, + }, + (xhr, e) => { + reject(xhr, e); + } + ); }, - ); + }); }, (xhr, e) => { reject(xhr, e); - }, + } ); }); } return new Promise((resolve, reject) => { - model.dataAccessHelper - .fetchJSON(publicAPI, model.url) - .then( - (dataset) => { - processDataSet(publicAPI, model, dataset, fetchArray, resolve, reject, loadData); - }, - (xhr, e) => { - reject(xhr, e); - }, - ); + model.dataAccessHelper.fetchJSON(publicAPI, model.url).then( + (dataset) => { + processDataSet( + publicAPI, + model, + dataset, + fetchArray, + resolve, + reject, + loadData + ); + }, + (xhr, e) => { + reject(xhr, e); + } + ); }); }; @@ -201,9 +223,9 @@ function vtkHttpDataSetReader(publicAPI, model) { publicAPI.loadData = () => { const datasetObj = model.dataset; const arrayToFecth = model.arrays - .filter(array => array.enable) - .filter(array => array.array.ref) - .map(array => array.array); + .filter((array) => array.enable) + .filter((array) => array.array.ref) + .map((array) => array.array); return new Promise((resolve, reject) => { const error = (xhr, e) => { @@ -214,14 +236,21 @@ function vtkHttpDataSetReader(publicAPI, model) { if (arrayToFecth.length) { const progressCallback = model.progressCallback; const compression = model.fetchGzip ? 'gz' : null; - fetchArray(arrayToFecth.pop(), { compression, progressCallback }).then(processNext, error); + fetchArray(arrayToFecth.pop(), { + compression, + progressCallback, + }).then(processNext, error); } else if (datasetObj) { // Perform array registration model.arrays - .filter(array => array.registration) + .filter((array) => array.registration) .forEach((metaArray) => { - const newArray = ARRAY_BUILDERS[metaArray.array.vtkClass].newInstance(metaArray.array); - datasetObj[`get${macro.capitalize(metaArray.location)}`]()[metaArray.registration](newArray); + const newArray = ARRAY_BUILDERS[ + metaArray.array.vtkClass + ].newInstance(metaArray.array); + datasetObj[`get${macro.capitalize(metaArray.location)}`]()[ + metaArray.registration + ](newArray); delete metaArray.registration; }); datasetObj.modified(); @@ -234,14 +263,15 @@ function vtkHttpDataSetReader(publicAPI, model) { }); }; - publicAPI.requestData = (inData, outData) => { // do nothing loadData will eventually load up the data }; // Toggle arrays to load publicAPI.enableArray = (location, name, enable = true) => { - const activeArray = model.arrays.filter(array => array.name === name && array.location === location); + const activeArray = model.arrays.filter( + (array) => array.name === name && array.location === location + ); if (activeArray.length === 1) { activeArray[0].enable = enable; } @@ -267,7 +297,6 @@ const DEFAULT_VALUES = { // ---------------------------------------------------------------------------- - export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); diff --git a/Sources/IO/Core/HttpSceneLoader/example/index.js b/Sources/IO/Core/HttpSceneLoader/example/index.js index 3b3b93cff17..d0ff6840e16 100644 --- a/Sources/IO/Core/HttpSceneLoader/example/index.js +++ b/Sources/IO/Core/HttpSceneLoader/example/index.js @@ -1,7 +1,7 @@ import 'vtk.js/Sources/favicon'; import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkHttpSceneLoader from 'vtk.js/Sources/IO/Core/HttpSceneLoader'; +import vtkHttpSceneLoader from 'vtk.js/Sources/IO/Core/HttpSceneLoader'; // ---------------------------------------------------------------------------- // Standard rendering code setup @@ -15,9 +15,11 @@ const renderWindow = fullScreenRenderer.getRenderWindow(); // Example code // ---------------------------------------------------------------------------- -const sceneImporter = vtkHttpSceneLoader.newInstance({ renderer, fetchGzip: true }); +const sceneImporter = vtkHttpSceneLoader.newInstance({ + renderer, + fetchGzip: true, +}); sceneImporter.setUrl(`${__BASE_PATH__}/data/scene`); sceneImporter.onReady(() => { renderWindow.render(); }); - diff --git a/Sources/IO/Core/HttpSceneLoader/index.js b/Sources/IO/Core/HttpSceneLoader/index.js index 3508d7ab29e..ad087d9a08c 100644 --- a/Sources/IO/Core/HttpSceneLoader/index.js +++ b/Sources/IO/Core/HttpSceneLoader/index.js @@ -1,10 +1,10 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import macro from 'vtk.js/Sources/macro'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkTexture from 'vtk.js/Sources/Rendering/Core/Texture'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkTexture from 'vtk.js/Sources/Rendering/Core/Texture'; -import DataAccessHelper from 'vtk.js/Sources/IO/Core/DataAccessHelper'; +import DataAccessHelper from 'vtk.js/Sources/IO/Core/DataAccessHelper'; const { vtkWarningMacro, vtkErrorMacro } = macro; @@ -20,7 +20,8 @@ function applySettings(sceneItem, settings) { settings.actorRotation[0], settings.actorRotation[1], settings.actorRotation[2], - settings.actorRotation[3]); + settings.actorRotation[3] + ); } if (settings.property) { @@ -29,7 +30,10 @@ function applySettings(sceneItem, settings) { if (settings.mapper) { if (settings.mapper.colorByArrayName) { - sceneItem.source.enableArray(settings.mapper.colorByArrayName, settings.mapper.colorByArrayName); + sceneItem.source.enableArray( + settings.mapper.colorByArrayName, + settings.mapper.colorByArrayName + ); sceneItem.source.loadData(); } @@ -47,7 +51,10 @@ function applySettings(sceneItem, settings) { // ---------------------------------------------------------------------------- function loadHttpDataSetReader(item, model, publicAPI) { - const source = vtkHttpDataSetReader.newInstance({ fetchGzip: model.fetchGzip, dataAccessHelper: model.dataAccessHelper }); + const source = vtkHttpDataSetReader.newInstance({ + fetchGzip: model.fetchGzip, + dataAccessHelper: model.dataAccessHelper, + }); const actor = vtkActor.newInstance(); const mapper = vtkMapper.newInstance(); const sceneItem = { @@ -58,7 +65,10 @@ function loadHttpDataSetReader(item, model, publicAPI) { defaultSettings: item, }; if (item.texture) { - const textureSource = vtkHttpDataSetReader.newInstance({ fetchGzip: model.fetchGzip, dataAccessHelper: model.dataAccessHelper }); + const textureSource = vtkHttpDataSetReader.newInstance({ + fetchGzip: model.fetchGzip, + dataAccessHelper: model.dataAccessHelper, + }); textureSource .setUrl([model.baseURL, item.texture].join('/'), { loadData: true }) .then(() => { @@ -132,32 +142,32 @@ function vtkHttpSceneLoader(publicAPI, model) { return; } - model.dataAccessHelper.fetchJSON(publicAPI, model.url) - .then( - (data) => { - if (data.fetchGzip !== undefined) { - model.fetchGzip = data.fetchGzip; - } - if (data.background) { - model.renderer.setBackground(...data.background); - } - if (data.camera) { - originalSceneParameters.camera = data.camera; - setCameraParameters(data.camera); - } - if (data.scene) { - data.scene.forEach((item) => { - const builder = TYPE_MAPPING[item.type]; - if (builder) { - builder(item, model, publicAPI); - } - }); - global.scene = model.scene; - } - }, - (error) => { - vtkErrorMacro(`Error fetching scene ${error}`); - }); + model.dataAccessHelper.fetchJSON(publicAPI, model.url).then( + (data) => { + if (data.fetchGzip !== undefined) { + model.fetchGzip = data.fetchGzip; + } + if (data.background) { + model.renderer.setBackground(...data.background); + } + if (data.camera) { + originalSceneParameters.camera = data.camera; + setCameraParameters(data.camera); + } + if (data.scene) { + data.scene.forEach((item) => { + const builder = TYPE_MAPPING[item.type]; + if (builder) { + builder(item, model, publicAPI); + } + }); + global.scene = model.scene; + } + }, + (error) => { + vtkErrorMacro(`Error fetching scene ${error}`); + } + ); }; publicAPI.resetScene = () => { @@ -197,21 +207,13 @@ const DEFAULT_VALUES = { // ---------------------------------------------------------------------------- - export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API macro.obj(publicAPI, model); - macro.get(publicAPI, model, [ - 'fetchGzip', - 'url', - 'baseURL', - 'scene', - ]); - macro.setGet(publicAPI, model, [ - 'renderer', - ]); + macro.get(publicAPI, model, ['fetchGzip', 'url', 'baseURL', 'scene']); + macro.setGet(publicAPI, model, ['renderer']); macro.event(publicAPI, model, 'ready'); // Object methods diff --git a/Sources/IO/Core/index.js b/Sources/IO/Core/index.js index e7cb046370c..4b58eaafe56 100644 --- a/Sources/IO/Core/index.js +++ b/Sources/IO/Core/index.js @@ -1,7 +1,7 @@ -import BinaryHelper from './BinaryHelper'; -import DataAccessHelper from './DataAccessHelper'; +import BinaryHelper from './BinaryHelper'; +import DataAccessHelper from './DataAccessHelper'; import vtkHttpDataSetReader from './HttpDataSetReader'; -import vtkHttpSceneLoader from './HttpSceneLoader'; +import vtkHttpSceneLoader from './HttpSceneLoader'; export default { BinaryHelper, diff --git a/Sources/IO/Geometry/STLReader/example/index.js b/Sources/IO/Geometry/STLReader/example/index.js index 2fdcff42c28..6810c46cebb 100644 --- a/Sources/IO/Geometry/STLReader/example/index.js +++ b/Sources/IO/Geometry/STLReader/example/index.js @@ -1,9 +1,9 @@ import 'vtk.js/Sources/favicon'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkSTLReader from 'vtk.js/Sources/IO/Geometry/STLReader'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkSTLReader from 'vtk.js/Sources/IO/Geometry/STLReader'; // ---------------------------------------------------------------------------- // Example code @@ -64,4 +64,3 @@ fileInput.addEventListener('change', handleFile); // ---------------------------------------------------------------------------- // reader.setUrl(`${__BASE_PATH__}/data/stl/segmentation.stl`, { binary: true }).then(update); - diff --git a/Sources/IO/Geometry/STLReader/index.js b/Sources/IO/Geometry/STLReader/index.js index 00a8ae20bff..3c4c738b567 100644 --- a/Sources/IO/Geometry/STLReader/index.js +++ b/Sources/IO/Geometry/STLReader/index.js @@ -1,7 +1,7 @@ import DataAccessHelper from 'vtk.js/Sources/IO/Core/DataAccessHelper'; -import macro from 'vtk.js/Sources/macro'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import macro from 'vtk.js/Sources/macro'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; // ---------------------------------------------------------------------------- // vtkSTLReader methods @@ -21,9 +21,15 @@ function vtkSTLReader(publicAPI, model) { const compression = model.compression; const progressCallback = model.progressCallback; if (option.binary) { - return model.dataAccessHelper.fetchBinary(url, { compression, progressCallback }); + return model.dataAccessHelper.fetchBinary(url, { + compression, + progressCallback, + }); } - return model.dataAccessHelper.fetchText(publicAPI, url, { compression, progressCallback }); + return model.dataAccessHelper.fetchText(publicAPI, url, { + compression, + progressCallback, + }); } // Set DataSet url @@ -38,7 +44,10 @@ function vtkSTLReader(publicAPI, model) { model.compression = option.compression; // Fetch metadata - return publicAPI.loadData({ progressCallback: option.progressCallback, binary: !!option.binary }); + return publicAPI.loadData({ + progressCallback: option.progressCallback, + binary: !!option.binary, + }); }; // Fetch the actual data arrays @@ -86,25 +95,25 @@ function vtkSTLReader(publicAPI, model) { let cellOffset = 0; for (let faceIdx = 0; faceIdx < nbFaces; faceIdx++) { - const offset = (faceIdx * 50); - normalValues[(faceIdx * 3) + 0] = dataView.getFloat32(offset + 0, true); - normalValues[(faceIdx * 3) + 1] = dataView.getFloat32(offset + 4, true); - normalValues[(faceIdx * 3) + 2] = dataView.getFloat32(offset + 8, true); - - pointValues[(faceIdx * 9) + 0] = dataView.getFloat32(offset + 12, true); - pointValues[(faceIdx * 9) + 1] = dataView.getFloat32(offset + 16, true); - pointValues[(faceIdx * 9) + 2] = dataView.getFloat32(offset + 20, true); - pointValues[(faceIdx * 9) + 3] = dataView.getFloat32(offset + 24, true); - pointValues[(faceIdx * 9) + 4] = dataView.getFloat32(offset + 28, true); - pointValues[(faceIdx * 9) + 5] = dataView.getFloat32(offset + 32, true); - pointValues[(faceIdx * 9) + 6] = dataView.getFloat32(offset + 36, true); - pointValues[(faceIdx * 9) + 7] = dataView.getFloat32(offset + 40, true); - pointValues[(faceIdx * 9) + 8] = dataView.getFloat32(offset + 44, true); + const offset = faceIdx * 50; + normalValues[faceIdx * 3 + 0] = dataView.getFloat32(offset + 0, true); + normalValues[faceIdx * 3 + 1] = dataView.getFloat32(offset + 4, true); + normalValues[faceIdx * 3 + 2] = dataView.getFloat32(offset + 8, true); + + pointValues[faceIdx * 9 + 0] = dataView.getFloat32(offset + 12, true); + pointValues[faceIdx * 9 + 1] = dataView.getFloat32(offset + 16, true); + pointValues[faceIdx * 9 + 2] = dataView.getFloat32(offset + 20, true); + pointValues[faceIdx * 9 + 3] = dataView.getFloat32(offset + 24, true); + pointValues[faceIdx * 9 + 4] = dataView.getFloat32(offset + 28, true); + pointValues[faceIdx * 9 + 5] = dataView.getFloat32(offset + 32, true); + pointValues[faceIdx * 9 + 6] = dataView.getFloat32(offset + 36, true); + pointValues[faceIdx * 9 + 7] = dataView.getFloat32(offset + 40, true); + pointValues[faceIdx * 9 + 8] = dataView.getFloat32(offset + 44, true); cellValues[cellOffset++] = 3; - cellValues[cellOffset++] = (faceIdx * 3) + 0; - cellValues[cellOffset++] = (faceIdx * 3) + 1; - cellValues[cellOffset++] = (faceIdx * 3) + 2; + cellValues[cellOffset++] = faceIdx * 3 + 0; + cellValues[cellOffset++] = faceIdx * 3 + 1; + cellValues[cellOffset++] = faceIdx * 3 + 2; cellDataValues[faceIdx] = dataView.getUint16(offset + 48, true); } @@ -112,9 +121,18 @@ function vtkSTLReader(publicAPI, model) { const polydata = vtkPolyData.newInstance(); polydata.getPoints().setData(pointValues, 3); polydata.getPolys().setData(cellValues); - polydata.getCellData().setScalars(vtkDataArray.newInstance({ name: 'Attribute', values: cellDataValues })); - polydata.getCellData().setNormals(vtkDataArray.newInstance({ name: 'Normals', values: normalValues, numberOfComponents: 3 })); - + polydata + .getCellData() + .setScalars( + vtkDataArray.newInstance({ name: 'Attribute', values: cellDataValues }) + ); + polydata.getCellData().setNormals( + vtkDataArray.newInstance({ + name: 'Normals', + values: normalValues, + numberOfComponents: 3, + }) + ); // Add new output model.output[0] = polydata; @@ -153,19 +171,13 @@ const DEFAULT_VALUES = { // ---------------------------------------------------------------------------- - export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API macro.obj(publicAPI, model); - macro.get(publicAPI, model, [ - 'url', - 'baseURL', - ]); - macro.setGet(publicAPI, model, [ - 'dataAccessHelper', - ]); + macro.get(publicAPI, model, ['url', 'baseURL']); + macro.setGet(publicAPI, model, ['dataAccessHelper']); macro.algo(publicAPI, model, 0, 1); // vtkSTLReader methods diff --git a/Sources/IO/Legacy/LegacyAsciiParser/index.js b/Sources/IO/Legacy/LegacyAsciiParser/index.js index f9e6f06eb95..52a2204c6c4 100644 --- a/Sources/IO/Legacy/LegacyAsciiParser/index.js +++ b/Sources/IO/Legacy/LegacyAsciiParser/index.js @@ -1,5 +1,5 @@ import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; const METHOD_MAPPING = { POINTS: 'getPoints', @@ -60,7 +60,11 @@ const GENERIC_CELL_HANDLER = { const [name, nbCells, nbValues] = line.split(' '); const cellArray = dataModel.dataset[METHOD_MAPPING[name]](); cellArray.set({ numberOfCells: Number(nbCells) }, true); // Force numberOfCells update - dataModel.arrayHandler = createArrayHandler(new Uint32Array(Number(nbValues)), cellArray.setData, 1); + dataModel.arrayHandler = createArrayHandler( + new Uint32Array(Number(nbValues)), + cellArray.setData, + 1 + ); return true; }, parse(line, dataModel) { @@ -88,7 +92,10 @@ const TYPE_PARSER = { POINTS: { init(line, dataModel) { const [name, size, type] = line.split(' '); - const array = (type === 'float') ? new Float32Array(3 * Number(size)) : new Float64Array(3 * Number(size)); + const array = + type === 'float' + ? new Float32Array(3 * Number(size)) + : new Float64Array(3 * Number(size)); const dataArray = dataModel.dataset.getPoints(); dataArray.setName(name); dataModel.arrayHandler = createArrayHandler(array, dataArray.setData, 3); @@ -99,7 +106,9 @@ const TYPE_PARSER = { }, }, METADATA: { - init(line, dataModel) { return true; }, + init(line, dataModel) { + return true; + }, parse(line, dataModel) { return !!line.length; }, @@ -134,8 +143,14 @@ const TYPE_PARSER = { const size = dataModel[dataModel.activeFieldLocation] * Number(numComp); const array = new DATATYPES[dataType](size); const dataArray = vtkDataArray.newInstance({ name, empty: true }); - dataModel.dataset[METHOD_MAPPING[dataModel.activeFieldLocation]]()[REGISTER_MAPPING[type]](dataArray); - dataModel.arrayHandler = createArrayHandler(array, dataArray.setData, Number(numComp)); + dataModel.dataset[METHOD_MAPPING[dataModel.activeFieldLocation]]()[ + REGISTER_MAPPING[type] + ](dataArray); + dataModel.arrayHandler = createArrayHandler( + array, + dataArray.setData, + Number(numComp) + ); return true; }, parse(line, dataModel) { @@ -151,8 +166,14 @@ const TYPE_PARSER = { const size = dataModel[dataModel.activeFieldLocation] * Number(numComp); const array = new Uint8Array(size); const dataArray = vtkDataArray.newInstance({ name, empty: true }); - dataModel.dataset[METHOD_MAPPING[dataModel.activeFieldLocation]]()[REGISTER_MAPPING[type]](dataArray); - dataModel.arrayHandler = createArrayHandler(array, dataArray.setData, Number(numComp)); + dataModel.dataset[METHOD_MAPPING[dataModel.activeFieldLocation]]()[ + REGISTER_MAPPING[type] + ](dataArray); + dataModel.arrayHandler = createArrayHandler( + array, + dataArray.setData, + Number(numComp) + ); return true; }, parse(line, dataModel) { @@ -168,7 +189,9 @@ const TYPE_PARSER = { const size = dataModel[dataModel.activeFieldLocation] * 3; const array = new DATATYPES[dataType](size); const dataArray = vtkDataArray.newInstance({ name, empty: true }); - dataModel.dataset[METHOD_MAPPING[dataModel.activeFieldLocation]]()[REGISTER_MAPPING[type]](dataArray); + dataModel.dataset[METHOD_MAPPING[dataModel.activeFieldLocation]]()[ + REGISTER_MAPPING[type] + ](dataArray); dataModel.arrayHandler = createArrayHandler(array, dataArray.setData, 3); return true; }, @@ -182,7 +205,9 @@ const TYPE_PARSER = { const size = dataModel[dataModel.activeFieldLocation] * 3; const array = new Float32Array(size); const dataArray = vtkDataArray.newInstance({ name, empty: true }); - dataModel.dataset[METHOD_MAPPING[dataModel.activeFieldLocation]]()[REGISTER_MAPPING[type]](dataArray); + dataModel.dataset[METHOD_MAPPING[dataModel.activeFieldLocation]]()[ + REGISTER_MAPPING[type] + ](dataArray); dataModel.arrayHandler = createArrayHandler(array, dataArray.setData, 3); return true; }, @@ -193,10 +218,13 @@ const TYPE_PARSER = { TEXTURE_COORDINATES: { init(line, dataModel) { const [type, name, numberOfComponents, dataType] = line.split(' '); - const size = dataModel[dataModel.activeFieldLocation] * Number(numberOfComponents); + const size = + dataModel[dataModel.activeFieldLocation] * Number(numberOfComponents); const array = new DATATYPES[dataType](size); const dataArray = vtkDataArray.newInstance({ name, empty: true }); - dataModel.dataset[METHOD_MAPPING[dataModel.activeFieldLocation]]()[REGISTER_MAPPING[type]](dataArray); + dataModel.dataset[METHOD_MAPPING[dataModel.activeFieldLocation]]()[ + REGISTER_MAPPING[type] + ](dataArray); dataModel.arrayHandler = createArrayHandler(array, dataArray.setData, 3); return true; }, @@ -210,7 +238,9 @@ const TYPE_PARSER = { const size = dataModel[dataModel.activeFieldLocation] * 9; const array = new DATATYPES[dataType](size); const dataArray = vtkDataArray.newInstance({ name, empty: true }); - dataModel.dataset[METHOD_MAPPING[dataModel.activeFieldLocation]]()[REGISTER_MAPPING[type]](dataArray); + dataModel.dataset[METHOD_MAPPING[dataModel.activeFieldLocation]]()[ + REGISTER_MAPPING[type] + ](dataArray); dataModel.arrayHandler = createArrayHandler(array, dataArray.setData, 9); return true; }, @@ -250,4 +280,3 @@ function parseLegacyASCII(content, dataModel = {}) { export default { parseLegacyASCII, }; - diff --git a/Sources/IO/Legacy/PolyDataReader/example/index.js b/Sources/IO/Legacy/PolyDataReader/example/index.js index 36b0728be49..10a5d0395bb 100644 --- a/Sources/IO/Legacy/PolyDataReader/example/index.js +++ b/Sources/IO/Legacy/PolyDataReader/example/index.js @@ -1,9 +1,9 @@ import 'vtk.js/Sources/favicon'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkPolyDataReader from 'vtk.js/Sources/IO/Legacy/PolyDataReader'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkPolyDataReader from 'vtk.js/Sources/IO/Legacy/PolyDataReader'; const fileName = 'sphere.vtk'; // 'uh60.vtk'; // 'luggaBody.vtk'; diff --git a/Sources/IO/Legacy/PolyDataReader/index.js b/Sources/IO/Legacy/PolyDataReader/index.js index 4240bcfa635..8ac5ac90e71 100644 --- a/Sources/IO/Legacy/PolyDataReader/index.js +++ b/Sources/IO/Legacy/PolyDataReader/index.js @@ -1,5 +1,5 @@ -import macro from 'vtk.js/Sources/macro'; -import DataAccessHelper from 'vtk.js/Sources/IO/Core/DataAccessHelper'; +import macro from 'vtk.js/Sources/macro'; +import DataAccessHelper from 'vtk.js/Sources/IO/Core/DataAccessHelper'; import vtkLegacyAsciiParser from 'vtk.js/Sources/IO/Legacy/LegacyAsciiParser'; // ---------------------------------------------------------------------------- @@ -19,7 +19,10 @@ function vtkPolyDataReader(publicAPI, model) { function fetchData(url, option = {}) { const compression = model.compression; const progressCallback = model.progressCallback; - return model.dataAccessHelper.fetchText(publicAPI, url, { compression, progressCallback }); + return model.dataAccessHelper.fetchText(publicAPI, url, { + compression, + progressCallback, + }); } // Set DataSet url @@ -55,7 +58,9 @@ function vtkPolyDataReader(publicAPI, model) { } model.parseData = content; - model.output[0] = vtkLegacyAsciiParser.parseLegacyASCII(model.parseData).dataset; + model.output[0] = vtkLegacyAsciiParser.parseLegacyASCII( + model.parseData + ).dataset; }; publicAPI.requestData = (inData, outData) => { @@ -75,19 +80,13 @@ const DEFAULT_VALUES = { // ---------------------------------------------------------------------------- - export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API macro.obj(publicAPI, model); - macro.get(publicAPI, model, [ - 'url', - 'baseURL', - ]); - macro.setGet(publicAPI, model, [ - 'dataAccessHelper', - ]); + macro.get(publicAPI, model, ['url', 'baseURL']); + macro.setGet(publicAPI, model, ['dataAccessHelper']); macro.algo(publicAPI, model, 0, 1); // vtkPolyDataReader methods diff --git a/Sources/IO/Misc/ElevationReader/example/index.js b/Sources/IO/Misc/ElevationReader/example/index.js index 796921c92bc..6f03b161d60 100644 --- a/Sources/IO/Misc/ElevationReader/example/index.js +++ b/Sources/IO/Misc/ElevationReader/example/index.js @@ -1,16 +1,18 @@ import 'vtk.js/Sources/favicon'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkElevationReader from 'vtk.js/Sources/IO/Misc/ElevationReader'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkTexture from 'vtk.js/Sources/Rendering/Core/Texture'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkElevationReader from 'vtk.js/Sources/IO/Misc/ElevationReader'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkTexture from 'vtk.js/Sources/Rendering/Core/Texture'; // ---------------------------------------------------------------------------- // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -18,7 +20,11 @@ const renderWindow = fullScreenRenderer.getRenderWindow(); // Example code // ---------------------------------------------------------------------------- -const reader = vtkElevationReader.newInstance({ xSpacing: 0.01568, ySpacing: 0.01568, zScaling: 0.06666 }); +const reader = vtkElevationReader.newInstance({ + xSpacing: 0.01568, + ySpacing: 0.01568, + zScaling: 0.06666, +}); const mapper = vtkMapper.newInstance(); const actor = vtkActor.newInstance(); diff --git a/Sources/IO/Misc/ElevationReader/index.js b/Sources/IO/Misc/ElevationReader/index.js index ca8056b28f5..32acee06339 100644 --- a/Sources/IO/Misc/ElevationReader/index.js +++ b/Sources/IO/Misc/ElevationReader/index.js @@ -1,7 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; -import vtkCellArray from 'vtk.js/Sources/Common/Core/CellArray'; +import macro from 'vtk.js/Sources/macro'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import vtkCellArray from 'vtk.js/Sources/Common/Core/CellArray'; import DataAccessHelper from 'vtk.js/Sources/IO/Core/DataAccessHelper'; // ---------------------------------------------------------------------------- @@ -44,23 +44,21 @@ function vtkElevationReader(publicAPI, model) { publicAPI.loadData = () => { const promise = fetchCSV(model.url); - promise.then( - (csv) => { - model.csv = csv; - model.elevation = []; - - // Parse data - const lines = model.csv.split('\n'); - lines.forEach((line, lineIdx) => { - model.elevation.push(line.split(',').map(str => Number(str))); - }); - publicAPI.modified(); + promise.then((csv) => { + model.csv = csv; + model.elevation = []; + + // Parse data + const lines = model.csv.split('\n'); + lines.forEach((line, lineIdx) => { + model.elevation.push(line.split(',').map((str) => Number(str))); }); + publicAPI.modified(); + }); return promise; }; - publicAPI.requestData = (inData, outData) => { const polydata = vtkPolyData.newInstance(); @@ -73,29 +71,38 @@ function vtkElevationReader(publicAPI, model) { points.setNumberOfPoints(iSize * jSize, 3); const pointValues = points.getData(); - const polys = vtkCellArray.newInstance({ size: (5 * (iSize - 1) * (jSize - 1)) }); + const polys = vtkCellArray.newInstance({ + size: 5 * (iSize - 1) * (jSize - 1), + }); polydata.setPolys(polys); const polysValues = polys.getData(); let cellOffset = 0; // Texture coords const tcData = new Float32Array(iSize * jSize * 2); - const tcoords = vtkDataArray.newInstance({ numberOfComponents: 2, values: tcData, name: 'TextureCoordinates' }); + const tcoords = vtkDataArray.newInstance({ + numberOfComponents: 2, + values: tcData, + name: 'TextureCoordinates', + }); polydata.getPointData().setTCoords(tcoords); for (let j = 0; j < jSize; j++) { for (let i = 0; i < iSize; i++) { - const offsetIdx = ((j * iSize) + i); + const offsetIdx = j * iSize + i; const offsetPt = 3 * offsetIdx; // Fill points coordinates - pointValues[offsetPt + 0] = model.origin[0] + (i * model.xSpacing * model.xDirection); - pointValues[offsetPt + 1] = model.origin[1] + (j * model.ySpacing * model.yDirection); - pointValues[offsetPt + 2] = model.origin[2] + (model.elevation[j][i] * model.zScaling); + pointValues[offsetPt + 0] = + model.origin[0] + i * model.xSpacing * model.xDirection; + pointValues[offsetPt + 1] = + model.origin[1] + j * model.ySpacing * model.yDirection; + pointValues[offsetPt + 2] = + model.origin[2] + model.elevation[j][i] * model.zScaling; // fill in tcoords - tcData[(offsetIdx * 2)] = i / (iSize - 1.0); - tcData[(offsetIdx * 2) + 1] = 1.0 - (j / (jSize - 1.0)); + tcData[offsetIdx * 2] = i / (iSize - 1.0); + tcData[offsetIdx * 2 + 1] = 1.0 - j / (jSize - 1.0); // Fill polys if (i > 0 && j > 0) { @@ -135,16 +142,12 @@ const DEFAULT_VALUES = { // ---------------------------------------------------------------------------- - export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API macro.obj(publicAPI, model); - macro.get(publicAPI, model, [ - 'url', - 'baseURL', - ]); + macro.get(publicAPI, model, ['url', 'baseURL']); macro.setGet(publicAPI, model, [ 'dataAccessHelper', 'xSpacing', diff --git a/Sources/IO/Misc/MTLReader/index.js b/Sources/IO/Misc/MTLReader/index.js index 11db3e977b4..331d291a57e 100644 --- a/Sources/IO/Misc/MTLReader/index.js +++ b/Sources/IO/Misc/MTLReader/index.js @@ -1,6 +1,6 @@ import * as macro from '../../../macro'; import DataAccessHelper from '../../Core/DataAccessHelper'; -import vtkTexture from '../../../Rendering/Core/Texture'; +import vtkTexture from '../../../Rendering/Core/Texture'; // ---------------------------------------------------------------------------- // vtkMTLReader methods @@ -22,7 +22,10 @@ function vtkMTLReader(publicAPI, model) { return; } - const tokens = line.split(/[ \t]+/).map(s => s.trim()).filter(s => s.length); + const tokens = line + .split(/[ \t]+/) + .map((s) => s.trim()) + .filter((s) => s.length); if (tokens[0] === 'newmtl') { tokens.shift(); model.currentMaterial = tokens.join(' ').trim(); @@ -53,7 +56,10 @@ function vtkMTLReader(publicAPI, model) { function fetchData(url) { const compression = model.compression; const progressCallback = model.progressCallback; - return model.dataAccessHelper.fetchText(publicAPI, url, { compression, progressCallback }); + return model.dataAccessHelper.fetchText(publicAPI, url, { + compression, + progressCallback, + }); } // Set DataSet url @@ -79,15 +85,15 @@ function vtkMTLReader(publicAPI, model) { // Fetch the actual data arrays publicAPI.loadData = () => new Promise((resolve, reject) => { - fetchData(model.url) - .then( - (content) => { - publicAPI.parse(content); - resolve(); - }, - (err) => { - reject(); - }); + fetchData(model.url).then( + (content) => { + publicAPI.parse(content); + resolve(); + }, + (err) => { + reject(); + } + ); }); publicAPI.parse = (content) => { @@ -100,19 +106,20 @@ function vtkMTLReader(publicAPI, model) { publicAPI.isBusy = () => !!model.requestCount; publicAPI.getMaterialNames = () => Object.keys(model.materials); - publicAPI.getMaterial = name => model.materials[name]; + publicAPI.getMaterial = (name) => model.materials[name]; publicAPI.listImages = () => Object.keys(model.materials) - .map(name => model.materials[name].map_Kd) - .filter(fileName => !!fileName) - .map(s => s[0].trim()); + .map((name) => model.materials[name].map_Kd) + .filter((fileName) => !!fileName) + .map((s) => s[0].trim()); publicAPI.setImageSrc = (imagePath, src) => { - const selectedName = Object.keys(model.materials) - .find(name => - (model.materials[name].map_Kd - && model.materials[name].map_Kd[0].trim() === imagePath.trim())); + const selectedName = Object.keys(model.materials).find( + (name) => + model.materials[name].map_Kd && + model.materials[name].map_Kd[0].trim() === imagePath.trim() + ); const material = model.materials[selectedName]; if (material && material.image) { material.image.src = src; @@ -124,15 +131,15 @@ function vtkMTLReader(publicAPI, model) { if (material && actor) { const white = [1, 1, 1]; const actorProp = { - ambientColor: material.Ka ? material.Ka.map(i => Number(i)) : white, - specularColor: material.Ks ? material.Ks.map(i => Number(i)) : white, - diffuseColor: material.Kd ? material.Kd.map(i => Number(i)) : white, + ambientColor: material.Ka ? material.Ka.map((i) => Number(i)) : white, + specularColor: material.Ks ? material.Ks.map((i) => Number(i)) : white, + diffuseColor: material.Kd ? material.Kd.map((i) => Number(i)) : white, opacity: material.d ? Number(material.d) : 1, specularPower: material.Ns ? Number(material.Ns) : 1, }; const illum = Number(material.illum || 2); ['ambient', 'diffuse', 'specular'].forEach((k, idx) => { - actorProp[k] = (idx <= illum) ? 1.0 : 0.0; + actorProp[k] = idx <= illum ? 1.0 : 0.0; }); if (material.image) { const texture = vtkTexture.newInstance({ interpolate: true }); @@ -159,20 +166,13 @@ const DEFAULT_VALUES = { // ---------------------------------------------------------------------------- - export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API macro.obj(publicAPI, model); - macro.get(publicAPI, model, [ - 'url', - 'baseURL', - ]); - macro.setGet(publicAPI, model, [ - 'dataAccessHelper', - 'splitGroup', - ]); + macro.get(publicAPI, model, ['url', 'baseURL']); + macro.setGet(publicAPI, model, ['dataAccessHelper', 'splitGroup']); macro.event(publicAPI, model, 'busy'); // Object methods diff --git a/Sources/IO/Misc/OBJReader/example/index.js b/Sources/IO/Misc/OBJReader/example/index.js index 7c34479c93a..934ea727f7e 100644 --- a/Sources/IO/Misc/OBJReader/example/index.js +++ b/Sources/IO/Misc/OBJReader/example/index.js @@ -1,10 +1,10 @@ import 'vtk.js/Sources/favicon'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkMTLReader from 'vtk.js/Sources/IO/Misc/MTLReader'; -import vtkOBJReader from 'vtk.js/Sources/IO/Misc/OBJReader'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkMTLReader from 'vtk.js/Sources/IO/Misc/MTLReader'; +import vtkOBJReader from 'vtk.js/Sources/IO/Misc/OBJReader'; // const objs = ['ferrari-f1-race-car', 'mini-cooper', 'space-shuttle-orbiter', 'blskes-plane']; const fileName = 'space-shuttle-orbiter'; @@ -13,7 +13,9 @@ const fileName = 'space-shuttle-orbiter'; // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0.5, 0.5, 0.5] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0.5, 0.5, 0.5], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -43,40 +45,48 @@ function onClick(event) { render(); } -materialsReader.setUrl(`${__BASE_PATH__}/data/obj/${fileName}/${fileName}.mtl`).then(() => { - reader.setUrl(`${__BASE_PATH__}/data/obj/${fileName}/${fileName}.obj`).then(() => { - const size = reader.getNumberOfOutputPorts(); - for (let i = 0; i < size; i++) { - const polydata = reader.getOutputData(i); - const name = polydata.get('name').name; - const mapper = vtkMapper.newInstance(); - const actor = vtkActor.newInstance(); - - actor.setMapper(mapper); - mapper.setInputData(polydata); - - materialsReader.applyMaterialToActor(name, actor); - renderer.addActor(actor); - - scene.push({ name, polydata, mapper, actor }); - } - resetCamera(); - render(); - - // Build control ui - const htmlBuffer = ['']; - scene.forEach((item, idx) => { - htmlBuffer.push(`
${item.name}
`); - }); - - fullScreenRenderer.addController(htmlBuffer.join('\n')); - const nodes = document.querySelectorAll('.click'); - for (let i = 0; i < nodes.length; i++) { - const el = nodes[i]; - el.onclick = onClick; - } +materialsReader + .setUrl(`${__BASE_PATH__}/data/obj/${fileName}/${fileName}.mtl`) + .then(() => { + reader + .setUrl(`${__BASE_PATH__}/data/obj/${fileName}/${fileName}.obj`) + .then(() => { + const size = reader.getNumberOfOutputPorts(); + for (let i = 0; i < size; i++) { + const polydata = reader.getOutputData(i); + const name = polydata.get('name').name; + const mapper = vtkMapper.newInstance(); + const actor = vtkActor.newInstance(); + + actor.setMapper(mapper); + mapper.setInputData(polydata); + + materialsReader.applyMaterialToActor(name, actor); + renderer.addActor(actor); + + scene.push({ name, polydata, mapper, actor }); + } + resetCamera(); + render(); + + // Build control ui + const htmlBuffer = [ + '', + ]; + scene.forEach((item, idx) => { + htmlBuffer.push( + `
${item.name}
` + ); + }); + + fullScreenRenderer.addController(htmlBuffer.join('\n')); + const nodes = document.querySelectorAll('.click'); + for (let i = 0; i < nodes.length; i++) { + const el = nodes[i]; + el.onclick = onClick; + } + }); }); -}); // ----------------------------------------------------------- // Make some variables global so that you can inspect and diff --git a/Sources/IO/Misc/OBJReader/index.js b/Sources/IO/Misc/OBJReader/index.js index 864b0bf397e..f96aaee1408 100644 --- a/Sources/IO/Misc/OBJReader/index.js +++ b/Sources/IO/Misc/OBJReader/index.js @@ -1,7 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import DataAccessHelper from 'vtk.js/Sources/IO/Core/DataAccessHelper'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; // ---------------------------------------------------------------------------- @@ -30,10 +30,10 @@ function begin(splitMode) { // ---------------------------------------------------------------------------- function faceMap(str) { - const idxs = str.split('/').map(i => Number(i)); + const idxs = str.split('/').map((i) => Number(i)); const vertexIdx = idxs[0] - 1; - const textCoordIdx = idxs[1] ? (idxs[1] - 1) : vertexIdx; - const vertexNormal = idxs[2] ? (idxs[2] - 1) : vertexIdx; + const textCoordIdx = idxs[1] ? idxs[1] - 1 : vertexIdx; + const vertexNormal = idxs[2] ? idxs[2] - 1 : vertexIdx; return [vertexIdx, textCoordIdx, vertexNormal]; } @@ -67,7 +67,7 @@ function parseLine(line) { } const cells = data.f[data.size - 1]; tokens.shift(); - const faces = tokens.filter(s => s.length); + const faces = tokens.filter((s) => s.length); const size = faces.length; cells.push(size); for (let i = 0; i < size; i++) { @@ -79,8 +79,8 @@ function parseLine(line) { // ---------------------------------------------------------------------------- function end(model) { - const hasTcoords = !!(data.vt.length); - const hasNormals = !!(data.vn.length); + const hasTcoords = !!data.vt.length; + const hasNormals = !!data.vn.length; if (model.splitMode) { model.numberOfOutputs = data.size; for (let idx = 0; idx < data.size; idx++) { @@ -119,12 +119,20 @@ function end(model) { polydata.getPolys().setData(Uint32Array.from(polys)); if (hasTcoords) { - const tcoords = vtkDataArray.newInstance({ numberOfComponents: 2, values: Float32Array.from(tc), name: 'TextureCoordinates' }); + const tcoords = vtkDataArray.newInstance({ + numberOfComponents: 2, + values: Float32Array.from(tc), + name: 'TextureCoordinates', + }); polydata.getPointData().setTCoords(tcoords); } if (hasNormals) { - const normalsArray = vtkDataArray.newInstance({ numberOfComponents: 3, values: Float32Array.from(normals), name: 'Normals' }); + const normalsArray = vtkDataArray.newInstance({ + numberOfComponents: 3, + values: Float32Array.from(normals), + name: 'Normals', + }); polydata.getPointData().setNormals(normalsArray); } @@ -135,12 +143,20 @@ function end(model) { model.numberOfOutputs = 1; const polydata = vtkPolyData.newInstance(); polydata.getPoints().setData(Float32Array.from(data.v), 3); - if (hasTcoords && (data.v.length / 3) === (data.vt.length / 2)) { - const tcoords = vtkDataArray.newInstance({ numberOfComponents: 2, values: Float32Array.from(data.vt), name: 'TextureCoordinates' }); + if (hasTcoords && data.v.length / 3 === data.vt.length / 2) { + const tcoords = vtkDataArray.newInstance({ + numberOfComponents: 2, + values: Float32Array.from(data.vt), + name: 'TextureCoordinates', + }); polydata.getPointData().setTCoords(tcoords); } - if (hasNormals && (data.v.length === data.vn.length)) { - const normalsArray = vtkDataArray.newInstance({ numberOfComponents: 3, values: Float32Array.from(data.vn), name: 'Normals' }); + if (hasNormals && data.v.length === data.vn.length) { + const normalsArray = vtkDataArray.newInstance({ + numberOfComponents: 3, + values: Float32Array.from(data.vn), + name: 'Normals', + }); polydata.getPointData().setNormals(normalsArray); } @@ -179,7 +195,10 @@ function vtkOBJReader(publicAPI, model) { function fetchData(url, option = {}) { const compression = model.compression; const progressCallback = model.progressCallback; - return model.dataAccessHelper.fetchText(publicAPI, url, { compression, progressCallback }); + return model.dataAccessHelper.fetchText(publicAPI, url, { + compression, + progressCallback, + }); } // Set DataSet url @@ -248,20 +267,13 @@ const DEFAULT_VALUES = { // ---------------------------------------------------------------------------- - export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API macro.obj(publicAPI, model); - macro.get(publicAPI, model, [ - 'url', - 'baseURL', - ]); - macro.setGet(publicAPI, model, [ - 'dataAccessHelper', - 'splitMode', - ]); + macro.get(publicAPI, model, ['url', 'baseURL']); + macro.setGet(publicAPI, model, ['dataAccessHelper', 'splitMode']); macro.algo(publicAPI, model, 0, 1); macro.event(publicAPI, model, 'busy'); diff --git a/Sources/IO/Misc/PDBReader/example/index.js b/Sources/IO/Misc/PDBReader/example/index.js index 8682e21bec4..025e04ef602 100644 --- a/Sources/IO/Misc/PDBReader/example/index.js +++ b/Sources/IO/Misc/PDBReader/example/index.js @@ -1,17 +1,19 @@ import 'vtk.js/Sources/favicon'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkPDBReader from 'vtk.js/Sources/IO/Misc/PDBReader'; -import vtkSphereMapper from 'vtk.js/Sources/Rendering/Core/SphereMapper'; -import vtkStickMapper from 'vtk.js/Sources/Rendering/Core/StickMapper'; -import vtkMoleculeToRepresentation from 'vtk.js/Sources/Filters/General/MoleculeToRepresentation'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkPDBReader from 'vtk.js/Sources/IO/Misc/PDBReader'; +import vtkSphereMapper from 'vtk.js/Sources/Rendering/Core/SphereMapper'; +import vtkStickMapper from 'vtk.js/Sources/Rendering/Core/StickMapper'; +import vtkMoleculeToRepresentation from 'vtk.js/Sources/Filters/General/MoleculeToRepresentation'; // ---------------------------------------------------------------------------- // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -51,7 +53,6 @@ renderer.addActor(stickActor); renderer.resetCamera(); renderWindow.render(); - // ----------------------------------------------------------- // Make some variables global so that you can inspect and // modify objects in your browser's developer console: diff --git a/Sources/IO/Misc/PDBReader/index.js b/Sources/IO/Misc/PDBReader/index.js index 0b9401453e1..5ca7bee1ed8 100644 --- a/Sources/IO/Misc/PDBReader/index.js +++ b/Sources/IO/Misc/PDBReader/index.js @@ -1,8 +1,8 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkMolecule from 'vtk.js/Sources/Common/DataModel/Molecule'; +import macro from 'vtk.js/Sources/macro'; +import vtkMolecule from 'vtk.js/Sources/Common/DataModel/Molecule'; import DataAccessHelper from 'vtk.js/Sources/IO/Core/DataAccessHelper'; -import ATOMS from 'vtk.js/Utilities/XMLConverter/chemistry-mapper/elements.json'; +import ATOMS from 'vtk.js/Utilities/XMLConverter/chemistry-mapper/elements.json'; // ---------------------------------------------------------------------------- // vtkPDBReader methods @@ -21,7 +21,10 @@ function vtkPDBReader(publicAPI, model) { function fetchPDB(url) { const compression = model.compression; const progressCallback = model.progressCallback; - return model.dataAccessHelper.fetchText(publicAPI, url, { compression, progressCallback }); + return model.dataAccessHelper.fetchText(publicAPI, url, { + compression, + progressCallback, + }); } // Set DataSet url @@ -46,16 +49,15 @@ function vtkPDBReader(publicAPI, model) { publicAPI.loadData = () => { const promise = fetchPDB(model.url); - promise.then( - (pdb) => { - model.pdb = pdb; - model.molecule = []; + promise.then((pdb) => { + model.pdb = pdb; + model.molecule = []; - // Parse data - model.molecule = model.pdb.split('\n'); + // Parse data + model.molecule = model.pdb.split('\n'); - publicAPI.modified(); - }); + publicAPI.modified(); + }); return promise; }; @@ -79,26 +81,26 @@ function vtkPDBReader(publicAPI, model) { const iSize = model.molecule[j].length; const linebuf = model.molecule[j]; - const command = (linebuf.substr(0, 6)).replace(/\s+/g, ''); + const command = linebuf.substr(0, 6).replace(/\s+/g, ''); command.toUpperCase(); // Parse lines if (command === 'ATOM' || command === 'HETATM') { - const dum1 = (linebuf.substr(12, 4)).replace(/\s+/g, ''); + const dum1 = linebuf.substr(12, 4).replace(/\s+/g, ''); // const dum2 = (linebuf.substr(17, 3)).replace(/\s+/g, ''); // const chain = (linebuf.substr(21, 1)).replace(/\s+/g, ''); // const resi = ((linebuf.substr(22, 8)).replace(/\s+/g, '')).replace(/\D/g, ''); - const x = (linebuf.substr(30, 8)).replace(/\s+/g, ''); - const y = (linebuf.substr(38, 8)).replace(/\s+/g, ''); - const z = (linebuf.substr(46, 8)).replace(/\s+/g, ''); + const x = linebuf.substr(30, 8).replace(/\s+/g, ''); + const y = linebuf.substr(38, 8).replace(/\s+/g, ''); + const z = linebuf.substr(46, 8).replace(/\s+/g, ''); let elem = ''; if (iSize >= 78) { - elem = (linebuf.substr(76, 2)).replace(/\s+/g, ''); + elem = linebuf.substr(76, 2).replace(/\s+/g, ''); } if (elem === '') { // if element symbol was not specified, just use the "Atom name". - elem = (dum1.substr(0, 2)).replace(/\d/g, ''); + elem = dum1.substr(0, 2).replace(/\d/g, ''); } // fill polydata @@ -182,9 +184,7 @@ export function extend(publicAPI, model, initialValues = {}) { 'numberOfAtoms', 'requestCount', ]); - macro.setGet(publicAPI, model, [ - 'dataAccessHelper', - ]); + macro.setGet(publicAPI, model, ['dataAccessHelper']); macro.algo(publicAPI, model, 0, 1); macro.event(publicAPI, model, 'busy'); diff --git a/Sources/IO/Misc/PDBReader/test/testMolecule.js b/Sources/IO/Misc/PDBReader/test/testMolecule.js index aba13782b58..43a43afe1b3 100644 --- a/Sources/IO/Misc/PDBReader/test/testMolecule.js +++ b/Sources/IO/Misc/PDBReader/test/testMolecule.js @@ -1,14 +1,14 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; import vtkMoleculeToRepresentation from 'vtk.js/Sources/Filters/General/MoleculeToRepresentation'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkPDBReader from 'vtk.js/Sources/IO/Misc/PDBReader'; -import vtkSphereMapper from 'vtk.js/Sources/Rendering/Core/SphereMapper'; -import vtkStickMapper from 'vtk.js/Sources/Rendering/Core/StickMapper'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkPDBReader from 'vtk.js/Sources/IO/Misc/PDBReader'; +import vtkSphereMapper from 'vtk.js/Sources/Rendering/Core/SphereMapper'; +import vtkStickMapper from 'vtk.js/Sources/Rendering/Core/StickMapper'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; import baseline from './testMolecule_with_bonds.png'; @@ -18,7 +18,9 @@ test.onlyIfWebGL('Test MoleculeMapper', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -80,6 +82,13 @@ test.onlyIfWebGL('Test MoleculeMapper', (t) => { // the data have to be uploaded before capturing and comparing the images const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'IO/Misc/PDBReader', t, 1, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'IO/Misc/PDBReader', + t, + 1, + gc.releaseResources + ); }); }); diff --git a/Sources/IO/Misc/index.js b/Sources/IO/Misc/index.js index 270d29ce4f1..b0ca0a2773b 100644 --- a/Sources/IO/Misc/index.js +++ b/Sources/IO/Misc/index.js @@ -1,7 +1,7 @@ -import vtkElevationReader from './ElevationReader'; -import vtkMTLReader from './MTLReader'; -import vtkOBJReader from './OBJReader'; -import vtkPDBReader from './PDBReader'; +import vtkElevationReader from './ElevationReader'; +import vtkMTLReader from './MTLReader'; +import vtkOBJReader from './OBJReader'; +import vtkPDBReader from './PDBReader'; export default { vtkElevationReader, diff --git a/Sources/IO/XML/XMLImageDataReader/index.js b/Sources/IO/XML/XMLImageDataReader/index.js index 9c53457e7c6..098245138d7 100644 --- a/Sources/IO/XML/XMLImageDataReader/index.js +++ b/Sources/IO/XML/XMLImageDataReader/index.js @@ -1,6 +1,6 @@ -import vtkXMLReader from 'vtk.js/Sources/IO/XML/XMLReader'; -import macro from 'vtk.js/Sources/macro'; -import vtkImageData from 'vtk.js/Sources/Common/DataModel/ImageData'; +import vtkXMLReader from 'vtk.js/Sources/IO/XML/XMLReader'; +import macro from 'vtk.js/Sources/macro'; +import vtkImageData from 'vtk.js/Sources/Common/DataModel/ImageData'; // ---------------------------------------------------------------------------- // vtkXMLImageDataReader methods @@ -12,15 +12,24 @@ function vtkXMLImageDataReader(publicAPI, model) { publicAPI.parseXML = (rootElem, type, compressor, byteOrder, headerType) => { const imageDataElem = rootElem.getElementsByTagName(model.dataType)[0]; - const origin = imageDataElem.getAttribute('Origin').split(' ').map(t => Number(t)); - const spacing = imageDataElem.getAttribute('Spacing').split(' ').map(t => Number(t)); + const origin = imageDataElem + .getAttribute('Origin') + .split(' ') + .map((t) => Number(t)); + const spacing = imageDataElem + .getAttribute('Spacing') + .split(' ') + .map((t) => Number(t)); const pieces = imageDataElem.getElementsByTagName('Piece'); const nbPieces = pieces.length; for (let outputIndex = 0; outputIndex < nbPieces; outputIndex++) { // Create image data const piece = pieces[outputIndex]; - const extent = piece.getAttribute('Extent').split(' ').map(t => Number(t)); + const extent = piece + .getAttribute('Extent') + .split(' ') + .map((t) => Number(t)); const imageData = vtkImageData.newInstance({ origin, spacing, extent }); // Fill data @@ -28,15 +37,21 @@ function vtkXMLImageDataReader(publicAPI, model) { imageData.getNumberOfPoints(), piece.getElementsByTagName('PointData')[0], imageData.getPointData(), - compressor, byteOrder, headerType, - model.binaryBuffer); + compressor, + byteOrder, + headerType, + model.binaryBuffer + ); vtkXMLReader.processFieldData( imageData.getNumberOfCells(), piece.getElementsByTagName('CellData')[0], imageData.getCellData(), - compressor, byteOrder, headerType, - model.binaryBuffer); + compressor, + byteOrder, + headerType, + model.binaryBuffer + ); // Add new output model.output[outputIndex++] = imageData; @@ -58,7 +73,6 @@ const DEFAULT_VALUES = { // ---------------------------------------------------------------------------- - export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); vtkXMLReader.extend(publicAPI, model, initialValues); diff --git a/Sources/IO/XML/XMLPolyDataReader/index.js b/Sources/IO/XML/XMLPolyDataReader/index.js index b3e20329837..26226254761 100644 --- a/Sources/IO/XML/XMLPolyDataReader/index.js +++ b/Sources/IO/XML/XMLPolyDataReader/index.js @@ -1,16 +1,33 @@ import vtkXMLReader from 'vtk.js/Sources/IO/XML/XMLReader'; -import macro from 'vtk.js/Sources/macro'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import macro from 'vtk.js/Sources/macro'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; // ---------------------------------------------------------------------------- // Global method // ---------------------------------------------------------------------------- -function handleArray(polydata, cellType, piece, compressor, byteOrder, headerType, binaryBuffer) { +function handleArray( + polydata, + cellType, + piece, + compressor, + byteOrder, + headerType, + binaryBuffer +) { const size = Number(piece.getAttribute(`NumberOf${cellType}`)); if (size > 0) { - const dataArrayElem = piece.getElementsByTagName(cellType)[0].getElementsByTagName('DataArray')[0]; - const { values, numberOfComponents } = vtkXMLReader.processDataArray(size, dataArrayElem, compressor, byteOrder, headerType, binaryBuffer); + const dataArrayElem = piece + .getElementsByTagName(cellType)[0] + .getElementsByTagName('DataArray')[0]; + const { values, numberOfComponents } = vtkXMLReader.processDataArray( + size, + dataArrayElem, + compressor, + byteOrder, + headerType, + binaryBuffer + ); polydata[`get${cellType}`]().setData(values, numberOfComponents); } return size; @@ -18,10 +35,25 @@ function handleArray(polydata, cellType, piece, compressor, byteOrder, headerTyp // ---------------------------------------------------------------------------- -function handleCells(polydata, cellType, piece, compressor, byteOrder, headerType, binaryBuffer) { +function handleCells( + polydata, + cellType, + piece, + compressor, + byteOrder, + headerType, + binaryBuffer +) { const size = Number(piece.getAttribute(`NumberOf${cellType}`)); if (size > 0) { - const values = vtkXMLReader.processCells(size, piece.getElementsByTagName(cellType)[0], compressor, byteOrder, headerType, binaryBuffer); + const values = vtkXMLReader.processCells( + size, + piece.getElementsByTagName(cellType)[0], + compressor, + byteOrder, + headerType, + binaryBuffer + ); polydata[`get${cellType}`]().setData(values); } return size; @@ -46,19 +78,49 @@ function vtkXMLPolyDataReader(publicAPI, model) { const piece = pieces[outputIndex]; // Points - const nbPoints = handleArray(polydata, 'Points', piece, compressor, byteOrder, headerType, model.binaryBuffer); + const nbPoints = handleArray( + polydata, + 'Points', + piece, + compressor, + byteOrder, + headerType, + model.binaryBuffer + ); // Cells let nbCells = 0; ['Verts', 'Lines', 'Strips', 'Polys'].forEach((cellType) => { - nbCells += handleCells(polydata, cellType, piece, compressor, byteOrder, headerType, model.binaryBuffer); + nbCells += handleCells( + polydata, + cellType, + piece, + compressor, + byteOrder, + headerType, + model.binaryBuffer + ); }); // Fill data - vtkXMLReader.processFieldData(nbPoints, piece.getElementsByTagName('PointData')[0], polydata.getPointData(), - compressor, byteOrder, headerType, model.binaryBuffer); - vtkXMLReader.processFieldData(nbCells, piece.getElementsByTagName('CellData')[0], polydata.getCellData(), - compressor, byteOrder, headerType, model.binaryBuffer); + vtkXMLReader.processFieldData( + nbPoints, + piece.getElementsByTagName('PointData')[0], + polydata.getPointData(), + compressor, + byteOrder, + headerType, + model.binaryBuffer + ); + vtkXMLReader.processFieldData( + nbCells, + piece.getElementsByTagName('CellData')[0], + polydata.getCellData(), + compressor, + byteOrder, + headerType, + model.binaryBuffer + ); // Add new output model.output[outputIndex++] = polydata; @@ -80,7 +142,6 @@ const DEFAULT_VALUES = { // ---------------------------------------------------------------------------- - export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); vtkXMLReader.extend(publicAPI, model, initialValues); diff --git a/Sources/IO/XML/XMLReader/index.js b/Sources/IO/XML/XMLReader/index.js index 7ad4a6ad22c..b46bdd3dec5 100644 --- a/Sources/IO/XML/XMLReader/index.js +++ b/Sources/IO/XML/XMLReader/index.js @@ -2,9 +2,9 @@ import pako from 'pako'; import { toByteArray } from 'base64-js'; import DataAccessHelper from 'vtk.js/Sources/IO/Core/DataAccessHelper'; -import macro from 'vtk.js/Sources/macro'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import BinaryHelper from 'vtk.js/Sources/IO/Core/BinaryHelper'; +import macro from 'vtk.js/Sources/macro'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import BinaryHelper from 'vtk.js/Sources/IO/Core/BinaryHelper'; // ---------------------------------------------------------------------------- // Global methods @@ -16,7 +16,7 @@ function stringToXML(xmlStr) { oXML.loadXML(xmlStr); return oXML; } - return (new DOMParser()).parseFromString(xmlStr, 'application/xml'); + return new DOMParser().parseFromString(xmlStr, 'application/xml'); } function extractAppendedData(buffer) { @@ -60,7 +60,7 @@ const TYPED_ARRAY_BYTES = { function integer64to32(array) { const maxIdx = array.length - 1; // Skip last - return array.filter((v, i) => (i < maxIdx) && (i % 2) === 0); + return array.filter((v, i) => i < maxIdx && i % 2 === 0); } // ---------------------------------------------------------------------------- @@ -104,11 +104,20 @@ function uncompressBlock(compressedUint8, output) { // ---------------------------------------------------------------------------- -function processDataArray(size, dataArrayElem, compressor, byteOrder, headerType, binaryBuffer) { +function processDataArray( + size, + dataArrayElem, + compressor, + byteOrder, + headerType, + binaryBuffer +) { const dataType = dataArrayElem.getAttribute('type'); const name = dataArrayElem.getAttribute('Name'); const format = dataArrayElem.getAttribute('format'); // binary, ascii, appended - const numberOfComponents = Number(dataArrayElem.getAttribute('NumberOfComponents') || '1'); + const numberOfComponents = Number( + dataArrayElem.getAttribute('NumberOfComponents') || '1' + ); let values = null; if (format === 'ascii') { @@ -122,7 +131,9 @@ function processDataArray(size, dataArrayElem, compressor, byteOrder, headerType } else if (format === 'binary') { const uint8 = toByteArray(dataArrayElem.firstChild.nodeValue.trim()); if (compressor === 'vtkZLibDataCompressor') { - const buffer = new ArrayBuffer(TYPED_ARRAY_BYTES[dataType] * size * numberOfComponents); + const buffer = new ArrayBuffer( + TYPED_ARRAY_BYTES[dataType] * size * numberOfComponents + ); values = new TYPED_ARRAY[dataType](buffer); const output = { offset: 0, @@ -139,7 +150,10 @@ function processDataArray(size, dataArrayElem, compressor, byteOrder, headerType // Header reading const header = readerHeader(uint8, headerType); const nbBlocks = header[1]; - let offset = uint8.length - (header.reduce((a, b) => a + b, 0) - (header[0] + header[1] + header[2] + header[3])); + let offset = + uint8.length - + (header.reduce((a, b) => a + b, 0) - + (header[0] + header[1] + header[2] + header[3])); for (let i = 0; i < nbBlocks; i++) { const blockSize = header[4 + i]; const compressedBlock = new Uint8Array(uint8.buffer, offset, blockSize); @@ -152,7 +166,10 @@ function processDataArray(size, dataArrayElem, compressor, byteOrder, headerType values = integer64to32(values); } } else { - values = new TYPED_ARRAY[dataType](uint8.buffer, TYPED_ARRAY_BYTES[headerType]); // Skip the count + values = new TYPED_ARRAY[dataType]( + uint8.buffer, + TYPED_ARRAY_BYTES[headerType] + ); // Skip the count // Handle (u)int64 hoping no overflow... if (dataType.indexOf('Int64') !== -1) { @@ -180,7 +197,9 @@ function processDataArray(size, dataArrayElem, compressor, byteOrder, headerType if (offset % TYPED_ARRAY_BYTES[dataType] === 0) { values = new TYPED_ARRAY[dataType](binaryBuffer, offset, arraySize); } else { - values = new TYPED_ARRAY[dataType](binaryBuffer.slice(offset, offset + header[0])); + values = new TYPED_ARRAY[dataType]( + binaryBuffer.slice(offset, offset + header[0]) + ); } // remove higher order 32 bits assuming they're not used. if (dataType.indexOf('Int64') !== -1) { @@ -195,7 +214,14 @@ function processDataArray(size, dataArrayElem, compressor, byteOrder, headerType // ---------------------------------------------------------------------------- -function processCells(size, containerElem, compressor, byteOrder, headerType, binaryBuffer) { +function processCells( + size, + containerElem, + compressor, + byteOrder, + headerType, + binaryBuffer +) { const arrayElems = {}; const dataArrayElems = containerElem.getElementsByTagName('DataArray'); for (let elIdx = 0; elIdx < dataArrayElems.length; elIdx++) { @@ -203,9 +229,23 @@ function processCells(size, containerElem, compressor, byteOrder, headerType, bi arrayElems[el.getAttribute('Name')] = el; } - const offsets = processDataArray(size, arrayElems.offsets, compressor, byteOrder, headerType, binaryBuffer).values; + const offsets = processDataArray( + size, + arrayElems.offsets, + compressor, + byteOrder, + headerType, + binaryBuffer + ).values; const connectivitySize = offsets[offsets.length - 1]; - const connectivity = processDataArray(connectivitySize, arrayElems.connectivity, compressor, byteOrder, headerType, binaryBuffer).values; + const connectivity = processDataArray( + connectivitySize, + arrayElems.connectivity, + compressor, + byteOrder, + headerType, + binaryBuffer + ).values; const values = new Uint32Array(size + connectivitySize); let writeOffset = 0; let previousOffset = 0; @@ -226,7 +266,15 @@ function processCells(size, containerElem, compressor, byteOrder, headerType, bi // ---------------------------------------------------------------------------- -function processFieldData(size, fieldElem, fieldContainer, compressor, byteOrder, headerType, binaryBuffer) { +function processFieldData( + size, + fieldElem, + fieldContainer, + compressor, + byteOrder, + headerType, + binaryBuffer +) { if (fieldElem) { const attributes = ['Scalars', 'Vectors', 'Normals', 'Tensors', 'TCoords']; const nameBinding = {}; @@ -241,7 +289,16 @@ function processFieldData(size, fieldElem, fieldContainer, compressor, byteOrder const nbArrays = arrays.length; for (let idx = 0; idx < nbArrays; idx++) { const array = arrays[idx]; - const dataArray = vtkDataArray.newInstance(processDataArray(size, array, compressor, byteOrder, headerType, binaryBuffer)); + const dataArray = vtkDataArray.newInstance( + processDataArray( + size, + array, + compressor, + byteOrder, + headerType, + binaryBuffer + ) + ); const name = dataArray.getName(); (nameBinding[name] || fieldContainer.addArray)(dataArray); } @@ -265,7 +322,10 @@ function vtkXMLReader(publicAPI, model) { function fetchData(url, option = {}) { const compression = model.compression; const progressCallback = model.progressCallback; - return model.dataAccessHelper.fetchText(publicAPI, url, { compression, progressCallback }); + return model.dataAccessHelper.fetchText(publicAPI, url, { + compression, + progressCallback, + }); } // Set DataSet url @@ -355,10 +415,15 @@ function vtkXMLReader(publicAPI, model) { } if (encoding === 'base64') { - dataArrays.push(toByteArray(appendedBuffer.substring(offset, nextOffset))); - } else { // encoding === 'raw' + dataArrays.push( + toByteArray(appendedBuffer.substring(offset, nextOffset)) + ); + } else { + // encoding === 'raw' // Need to slice the ArrayBuffer so readerHeader() works properly - dataArrays.push(new Uint8Array(appendedBuffer.slice(offset, nextOffset))); + dataArrays.push( + new Uint8Array(appendedBuffer.slice(offset, nextOffset)) + ); } } @@ -372,11 +437,12 @@ function vtkXMLReader(publicAPI, model) { const nbBlocks = header[1]; let compressedOffset = dataArray.length - - (header.reduce((a, b) => a + b, 0) - (header[0] + header[1] + header[2] + header[3])); + (header.reduce((a, b) => a + b, 0) - + (header[0] + header[1] + header[2] + header[3])); let buffer = null; if (nbBlocks > 0) { - buffer = new ArrayBuffer((header[2] * (nbBlocks - 1)) + header[3]); + buffer = new ArrayBuffer(header[2] * (nbBlocks - 1) + header[3]); } else { // if there is no blocks, then default to a zero array of size 0. buffer = new ArrayBuffer(0); @@ -389,18 +455,23 @@ function vtkXMLReader(publicAPI, model) { uint8: uncompressed, }; - for (let i = 0; i < nbBlocks; i++) { const blockSize = header[4 + i]; - const compressedBlock = new Uint8Array(dataArray.buffer, compressedOffset, blockSize); + const compressedBlock = new Uint8Array( + dataArray.buffer, + compressedOffset, + blockSize + ); uncompressBlock(compressedBlock, output); compressedOffset += blockSize; } - const data = new Uint8Array(uncompressed.length + TYPED_ARRAY_BYTES[headerType]); + const data = new Uint8Array( + uncompressed.length + TYPED_ARRAY_BYTES[headerType] + ); // set length header // TODO this does not work for lengths that are greater than the max Uint32 value. - (new TYPED_ARRAY[headerType](data.buffer))[0] = uncompressed.length; + new TYPED_ARRAY[headerType](data.buffer)[0] = uncompressed.length; data.set(uncompressed, TYPED_ARRAY_BYTES[headerType]); dataArrays[arrayidx] = data; @@ -422,7 +493,9 @@ function vtkXMLReader(publicAPI, model) { model.binaryBuffer = buffer; if (!model.binaryBuffer) { - console.error('Processing appended data format: requires binaryBuffer to parse'); + console.error( + 'Processing appended data format: requires binaryBuffer to parse' + ); return; } } @@ -447,19 +520,13 @@ const DEFAULT_VALUES = { // ---------------------------------------------------------------------------- - export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API macro.obj(publicAPI, model); - macro.get(publicAPI, model, [ - 'url', - 'baseURL', - ]); - macro.setGet(publicAPI, model, [ - 'dataAccessHelper', - ]); + macro.get(publicAPI, model, ['url', 'baseURL']); + macro.setGet(publicAPI, model, ['dataAccessHelper']); macro.algo(publicAPI, model, 0, 1); // vtkXMLReader methods diff --git a/Sources/Imaging/Hybrid/SampleFunction/index.js b/Sources/Imaging/Hybrid/SampleFunction/index.js index a20f6f0e879..3335fed4829 100644 --- a/Sources/Imaging/Hybrid/SampleFunction/index.js +++ b/Sources/Imaging/Hybrid/SampleFunction/index.js @@ -1,5 +1,4 @@ - -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; import vtkImageData from 'vtk.js/Sources/Common/DataModel/ImageData'; @@ -23,7 +22,8 @@ function vtkSampleFunction(publicAPI, model) { return Math.max(superClass.getMTime(), model.implicitFunction.getMTime()); }; - publicAPI.requestData = (inData, outData) => { // implement requestData + publicAPI.requestData = (inData, outData) => { + // implement requestData const imp = model.implicitFunction; if (!imp) { vtkErrorMacro('An implicit function must be defined'); @@ -31,14 +31,22 @@ function vtkSampleFunction(publicAPI, model) { } // Create a volume - const dims = [model.sampleDimensions[0], model.sampleDimensions[1], model.sampleDimensions[2]]; + const dims = [ + model.sampleDimensions[0], + model.sampleDimensions[1], + model.sampleDimensions[2], + ]; const numScalars = dims[0] * dims[1] * dims[2]; if (numScalars < 1 || dims[1] < 2 || dims[1] < 2 || dims[2] < 2) { vtkErrorMacro('Bad volume dimensions'); return; } const volume = vtkImageData.newInstance(); - const origin = [model.modelBounds[0], model.modelBounds[2], model.modelBounds[4]]; + const origin = [ + model.modelBounds[0], + model.modelBounds[2], + model.modelBounds[4], + ]; const spacing = [ (model.modelBounds[1] - model.modelBounds[0]) / (dims[0] - 1), (model.modelBounds[3] - model.modelBounds[2]) / (dims[1] - 1), @@ -51,20 +59,24 @@ function vtkSampleFunction(publicAPI, model) { // Create scalars array const s = new window[model.pointType](numScalars); - const scalars = vtkDataArray.newInstance({ name: 'Scalars', values: s, numberOfComponents: 1 }); + const scalars = vtkDataArray.newInstance({ + name: 'Scalars', + values: s, + numberOfComponents: 1, + }); volume.getPointData().setScalars(scalars); // Now loop over volume dimensions and generate scalar values let sValue = 0.0; const xyz = [0.0, 0.0, 0.0]; for (let k = 0; k < dims[2]; k++) { - xyz[2] = origin[2] + (k * spacing[2]); + xyz[2] = origin[2] + k * spacing[2]; for (let j = 0; j < dims[1]; j++) { - xyz[1] = origin[1] + (j * spacing[1]); + xyz[1] = origin[1] + j * spacing[1]; for (let i = 0; i < dims[0]; i++) { - xyz[0] = origin[0] + (i * spacing[0]); + xyz[0] = origin[0] + i * spacing[0]; sValue = imp.evaluateFunction(xyz); - s[i + (j * dims[0]) + (k * sliceSize)] = sValue; + s[i + j * dims[0] + k * sliceSize] = sValue; } } } @@ -97,12 +109,8 @@ export function extend(publicAPI, model, initialValues = {}) { macro.algo(publicAPI, model, 1, 1); // Generate macros for properties - macro.setGetArray(publicAPI, model, [ - 'sampleDimensions', - ], 3); - macro.setGetArray(publicAPI, model, [ - 'modelBounds', - ], 6); + macro.setGetArray(publicAPI, model, ['sampleDimensions'], 3); + macro.setGetArray(publicAPI, model, ['modelBounds'], 6); // Object specific methods vtkSampleFunction(publicAPI, model); diff --git a/Sources/Interaction/Manipulators/Button3DPan/index.js b/Sources/Interaction/Manipulators/Button3DPan/index.js index 9a47f78b7c4..2f2f302145e 100644 --- a/Sources/Interaction/Manipulators/Button3DPan/index.js +++ b/Sources/Interaction/Manipulators/Button3DPan/index.js @@ -1,6 +1,9 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkCamera3DManipulator from 'vtk.js/Sources/Interaction/Manipulators/Camera3DManipulator'; -import { Device, Input } from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor/Constants'; +import { + Device, + Input, +} from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor/Constants'; import { States } from 'vtk.js/Sources/Rendering/Core/InteractorStyle/Constants'; // ---------------------------------------------------------------------------- @@ -11,7 +14,14 @@ function vtkButton3DPan(publicAPI, model) { // Set our className model.classHierarchy.push('vtkButton3DPan'); - publicAPI.onButton3D = (interactorStyle, renderer, state, device, input, pressed) => { + publicAPI.onButton3D = ( + interactorStyle, + renderer, + state, + device, + input, + pressed + ) => { if (pressed) { interactorStyle.startCameraPose(); interactorStyle.setAnimationStateOn(); @@ -41,9 +51,10 @@ function vtkButton3DPan(publicAPI, model) { const dir = camera.physicalOrientationToWorldDirection(data.orientation); camera.setPhysicalTranslation( - oldTrans[0] + (dir[0] * pscale), - oldTrans[1] + (dir[1] * pscale), - oldTrans[2] + (dir[2] * pscale)); + oldTrans[0] + dir[0] * pscale, + oldTrans[1] + dir[1] * pscale, + oldTrans[2] + dir[2] * pscale + ); }; } diff --git a/Sources/Interaction/Manipulators/Camera3DManipulator/index.js b/Sources/Interaction/Manipulators/Camera3DManipulator/index.js index d2a106e819d..9f79f9bf330 100644 --- a/Sources/Interaction/Manipulators/Camera3DManipulator/index.js +++ b/Sources/Interaction/Manipulators/Camera3DManipulator/index.js @@ -1,5 +1,8 @@ import macro from 'vtk.js/Sources/macro'; -import { Device, Input } from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor/Constants'; +import { + Device, + Input, +} from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor/Constants'; // ---------------------------------------------------------------------------- // vtkCameraManipulator methods @@ -9,8 +12,22 @@ function vtkCamera3DManipulator(publicAPI, model) { // Set our className model.classHierarchy.push('vtkCamera3DManipulator'); - publicAPI.onButton3D = (interactor, renderer, state, device, input, pressed) => {}; - publicAPI.onMove3D = (interactor, renderer, state, device, input, pressed) => {}; + publicAPI.onButton3D = ( + interactor, + renderer, + state, + device, + input, + pressed + ) => {}; + publicAPI.onMove3D = ( + interactor, + renderer, + state, + device, + input, + pressed + ) => {}; } // ---------------------------------------------------------------------------- @@ -32,10 +49,7 @@ export function extend(publicAPI, model, initialValues = {}) { macro.obj(publicAPI, model); // Create get-set macros - macro.setGet(publicAPI, model, [ - 'device', - 'input', - ]); + macro.setGet(publicAPI, model, ['device', 'input']); // Object specific methods vtkCamera3DManipulator(publicAPI, model); diff --git a/Sources/Interaction/Manipulators/CameraManipulator/example/index.js b/Sources/Interaction/Manipulators/CameraManipulator/example/index.js index e8b2a0b9389..7116d955058 100644 --- a/Sources/Interaction/Manipulators/CameraManipulator/example/index.js +++ b/Sources/Interaction/Manipulators/CameraManipulator/example/index.js @@ -1,20 +1,20 @@ import 'vtk.js/Sources/favicon'; -import macro from 'vtk.js/Sources/macro'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import macro from 'vtk.js/Sources/macro'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import vtkInteractorStyleManipulator from 'vtk.js/Sources/Interaction/Style/InteractorStyleManipulator'; -import vtkCameraManipulator from 'vtk.js/Sources/Interaction/Manipulators/CameraManipulator'; -import vtkTrackballMultiRotate from 'vtk.js/Sources/Interaction/Manipulators/TrackballMultiRotate'; -import vtkTrackballPan from 'vtk.js/Sources/Interaction/Manipulators/TrackballPan'; -import vtkTrackballRoll from 'vtk.js/Sources/Interaction/Manipulators/TrackballRoll'; -import vtkTrackballRotate from 'vtk.js/Sources/Interaction/Manipulators/TrackballRotate'; -import vtkTrackballZoom from 'vtk.js/Sources/Interaction/Manipulators/TrackballZoom'; -import vtkTrackballZoomToMouse from 'vtk.js/Sources/Interaction/Manipulators/TrackballZoomToMouse'; +import vtkCameraManipulator from 'vtk.js/Sources/Interaction/Manipulators/CameraManipulator'; +import vtkTrackballMultiRotate from 'vtk.js/Sources/Interaction/Manipulators/TrackballMultiRotate'; +import vtkTrackballPan from 'vtk.js/Sources/Interaction/Manipulators/TrackballPan'; +import vtkTrackballRoll from 'vtk.js/Sources/Interaction/Manipulators/TrackballRoll'; +import vtkTrackballRotate from 'vtk.js/Sources/Interaction/Manipulators/TrackballRotate'; +import vtkTrackballZoom from 'vtk.js/Sources/Interaction/Manipulators/TrackballZoom'; +import vtkTrackballZoomToMouse from 'vtk.js/Sources/Interaction/Manipulators/TrackballZoomToMouse'; import controlPanel from './controller.html'; @@ -82,7 +82,9 @@ const manipulatorFactory = { function reassignManipulators() { interactorStyle.removeAllManipulators(); Object.keys(uiComponents).forEach((keyName) => { - const manipulator = manipulatorFactory[uiComponents[keyName].manipName].newInstance(); + const manipulator = manipulatorFactory[ + uiComponents[keyName].manipName + ].newInstance(); manipulator.setButton(selectMap[keyName].button); manipulator.setShift(selectMap[keyName].shift); manipulator.setControl(selectMap[keyName].control); diff --git a/Sources/Interaction/Manipulators/CameraManipulator/index.js b/Sources/Interaction/Manipulators/CameraManipulator/index.js index 6573946ff59..844aa90c8b5 100644 --- a/Sources/Interaction/Manipulators/CameraManipulator/index.js +++ b/Sources/Interaction/Manipulators/CameraManipulator/index.js @@ -18,7 +18,11 @@ function vtkCameraManipulator(publicAPI, model) { //------------------------------------------------------------------------- publicAPI.computeDisplayCenter = (iObserver) => { - const pt = iObserver.computeWorldToDisplay(model.center[0], model.center[1], model.center[2]); + const pt = iObserver.computeWorldToDisplay( + model.center[0], + model.center[1], + model.center[2] + ); model.displayCenter[0] = pt[0]; model.displayCenter[1] = pt[1]; }; @@ -59,13 +63,9 @@ export function extend(publicAPI, model, initialValues = {}) { 'rotationFactor', ]); - macro.setGetArray(publicAPI, model, [ - 'displayCenter', - ], 2); + macro.setGetArray(publicAPI, model, ['displayCenter'], 2); - macro.setGetArray(publicAPI, model, [ - 'center', - ], 3); + macro.setGetArray(publicAPI, model, ['center'], 3); // Object specific methods vtkCameraManipulator(publicAPI, model); diff --git a/Sources/Interaction/Manipulators/TrackballMultiRotate/index.js b/Sources/Interaction/Manipulators/TrackballMultiRotate/index.js index b394738adaa..73a7c2f4635 100644 --- a/Sources/Interaction/Manipulators/TrackballMultiRotate/index.js +++ b/Sources/Interaction/Manipulators/TrackballMultiRotate/index.js @@ -1,7 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkCameraManipulator from 'vtk.js/Sources/Interaction/Manipulators/CameraManipulator'; -import vtkTrackballRotate from 'vtk.js/Sources/Interaction/Manipulators/TrackballRotate'; -import vtkTrackballRoll from 'vtk.js/Sources/Interaction/Manipulators/TrackballRoll'; +import vtkTrackballRotate from 'vtk.js/Sources/Interaction/Manipulators/TrackballRotate'; +import vtkTrackballRoll from 'vtk.js/Sources/Interaction/Manipulators/TrackballRoll'; function max(x, y) { return x < y ? y : x; @@ -36,7 +36,7 @@ function vtkTrackballMultiRotate(publicAPI, model) { const rotateRadius = 0.9 * max(viewCenter[0], viewCenter[1]); const dist2 = sqr(viewCenter[0] - pos.x) + sqr(viewCenter[1] - pos.y); - if ((rotateRadius * rotateRadius) > dist2) { + if (rotateRadius * rotateRadius > dist2) { currentManipulator = rotateManipulator; } else { currentManipulator = rollManipulator; diff --git a/Sources/Interaction/Manipulators/TrackballPan/index.js b/Sources/Interaction/Manipulators/TrackballPan/index.js index 099c02d3074..1eb7bfa7012 100644 --- a/Sources/Interaction/Manipulators/TrackballPan/index.js +++ b/Sources/Interaction/Manipulators/TrackballPan/index.js @@ -1,6 +1,6 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkCameraManipulator from 'vtk.js/Sources/Interaction/Manipulators/CameraManipulator'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; // ---------------------------------------------------------------------------- // vtkTrackballPan methods @@ -42,13 +42,13 @@ function vtkTrackballPan(publicAPI, model) { dx *= scale * 2.0; dy *= scale * 2.0; - let tmp = (right[0] * dx) + (up[0] * dy); + let tmp = right[0] * dx + up[0] * dy; camPos[0] += tmp; fp[0] += tmp; - tmp = (right[1] * dx) + (up[1] * dy); + tmp = right[1] * dx + up[1] * dy; camPos[1] += tmp; fp[1] += tmp; - tmp = (right[2] * dx) + (up[2] * dy); + tmp = right[2] * dx + up[2] * dy; camPos[2] += tmp; fp[2] += tmp; camera.setPosition(camPos[0], camPos[1], camPos[2]); @@ -56,9 +56,17 @@ function vtkTrackballPan(publicAPI, model) { } else { const center = model.center; const style = interactor.getInteractorStyle(); - const focalDepth = style.computeWorldToDisplay(center[0], center[1], center[2])[2]; + const focalDepth = style.computeWorldToDisplay( + center[0], + center[1], + center[2] + )[2]; const worldPoint = style.computeDisplayToWorld(pos.x, pos.y, focalDepth); - const lastWorldPoint = style.computeDisplayToWorld(lastPos.x, lastPos.y, focalDepth); + const lastWorldPoint = style.computeDisplayToWorld( + lastPos.x, + lastPos.y, + focalDepth + ); const newCamPos = [ camPos[0] + (lastWorldPoint[0] - worldPoint[0]), diff --git a/Sources/Interaction/Manipulators/TrackballRoll/index.js b/Sources/Interaction/Manipulators/TrackballRoll/index.js index 8478e489edb..0d84d6e54f9 100644 --- a/Sources/Interaction/Manipulators/TrackballRoll/index.js +++ b/Sources/Interaction/Manipulators/TrackballRoll/index.js @@ -1,7 +1,7 @@ -import { vec3, mat4 } from 'gl-matrix'; -import macro from 'vtk.js/Sources/macro'; +import { vec3, mat4 } from 'gl-matrix'; +import macro from 'vtk.js/Sources/macro'; import vtkCameraManipulator from 'vtk.js/Sources/Interaction/Manipulators/CameraManipulator'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; // ---------------------------------------------------------------------------- // vtkTrackballRoll methods @@ -27,7 +27,11 @@ function vtkTrackballRoll(publicAPI, model) { const cameraFp = camera.getFocalPoint(); const viewUp = camera.getViewUp(); - const axis = [cameraFp[0] - cameraPos[0], cameraFp[1] - cameraPos[1], cameraFp[2] - cameraPos[2]]; + const axis = [ + cameraFp[0] - cameraPos[0], + cameraFp[1] - cameraPos[1], + cameraFp[2] - cameraPos[2], + ]; // compute the angle of rotation // - first compute the two vectors (center to mouse) @@ -43,34 +47,69 @@ function vtkTrackballRoll(publicAPI, model) { } // - divide by magnitudes to get angle - const angle = vtkMath.degreesFromRadians(((x1 * y2) - (y1 * x2)) / - (Math.sqrt((x1 * x1) + (y1 * y1)) * Math.sqrt((x2 * x2) + (y2 * y2)))); + const angle = vtkMath.degreesFromRadians( + (x1 * y2 - y1 * x2) / + (Math.sqrt(x1 * x1 + y1 * y1) * Math.sqrt(x2 * x2 + y2 * y2)) + ); const center = model.center; const transform = mat4.create(); mat4.identity(transform); // Translate to center - mat4.translate(transform, transform, vec3.fromValues(center[0], center[1], center[2])); + mat4.translate( + transform, + transform, + vec3.fromValues(center[0], center[1], center[2]) + ); // roll - mat4.rotate(transform, transform, vtkMath.radiansFromDegrees(angle), vec3.fromValues(axis[0], axis[1], axis[2])); + mat4.rotate( + transform, + transform, + vtkMath.radiansFromDegrees(angle), + vec3.fromValues(axis[0], axis[1], axis[2]) + ); // Translate back - mat4.translate(transform, transform, vec3.fromValues(-center[0], -center[1], -center[2])); + mat4.translate( + transform, + transform, + vec3.fromValues(-center[0], -center[1], -center[2]) + ); const newCamPos = vec3.create(); const newFp = vec3.create(); const newViewUp = vec3.create(); // Apply transformation to camera position, focal point, and view up - vec3.transformMat4(newCamPos, vec3.fromValues(cameraPos[0], cameraPos[1], cameraPos[2]), transform); - vec3.transformMat4(newFp, vec3.fromValues(cameraFp[0], cameraFp[1], cameraFp[2]), transform); - vec3.transformMat4(newViewUp, vec3.fromValues(viewUp[0] + cameraPos[0], viewUp[1] + cameraPos[1], viewUp[2] + cameraPos[2]), transform); + vec3.transformMat4( + newCamPos, + vec3.fromValues(cameraPos[0], cameraPos[1], cameraPos[2]), + transform + ); + vec3.transformMat4( + newFp, + vec3.fromValues(cameraFp[0], cameraFp[1], cameraFp[2]), + transform + ); + vec3.transformMat4( + newViewUp, + vec3.fromValues( + viewUp[0] + cameraPos[0], + viewUp[1] + cameraPos[1], + viewUp[2] + cameraPos[2] + ), + transform + ); camera.setPosition(newCamPos[0], newCamPos[1], newCamPos[2]); camera.setFocalPoint(newFp[0], newFp[1], newFp[2]); - camera.setViewUp(newViewUp[0] - newCamPos[0], newViewUp[1] - newCamPos[1], newViewUp[2] - newCamPos[2]); + camera.setViewUp( + newViewUp[0] - newCamPos[0], + newViewUp[1] - newCamPos[1], + newViewUp[2] - newCamPos[2] + ); camera.orthogonalizeViewUp(); renderer.resetCameraClippingRange(); diff --git a/Sources/Interaction/Manipulators/TrackballRotate/index.js b/Sources/Interaction/Manipulators/TrackballRotate/index.js index 15b461d8df5..32d8d53c2fe 100644 --- a/Sources/Interaction/Manipulators/TrackballRotate/index.js +++ b/Sources/Interaction/Manipulators/TrackballRotate/index.js @@ -1,7 +1,7 @@ -import { vec3, mat4 } from 'gl-matrix'; -import macro from 'vtk.js/Sources/macro'; +import { vec3, mat4 } from 'gl-matrix'; +import macro from 'vtk.js/Sources/macro'; import vtkCameraManipulator from 'vtk.js/Sources/Interaction/Manipulators/CameraManipulator'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; // ---------------------------------------------------------------------------- // vtkTrackballRotate methods @@ -31,7 +31,11 @@ function vtkTrackballRotate(publicAPI, model) { const rotationFactor = model.rotationFactor; // Translate to center - mat4.translate(trans, trans, vec3.fromValues(center[0], center[1], center[2])); + mat4.translate( + trans, + trans, + vec3.fromValues(center[0], center[1], center[2]) + ); const dx = lastPos.x - pos.x; const dy = lastPos.y - pos.y; @@ -40,28 +44,62 @@ function vtkTrackballRotate(publicAPI, model) { // Azimuth const viewUp = camera.getViewUp(); - mat4.rotate(trans, trans, vtkMath.radiansFromDegrees(((360.0 * dx) / size[0]) * rotationFactor), vec3.fromValues(viewUp[0], viewUp[1], viewUp[2])); + mat4.rotate( + trans, + trans, + vtkMath.radiansFromDegrees(360.0 * dx / size[0] * rotationFactor), + vec3.fromValues(viewUp[0], viewUp[1], viewUp[2]) + ); // Elevation const v2 = [0, 0, 0]; vtkMath.cross(camera.getDirectionOfProjection(), viewUp, v2); - mat4.rotate(trans, trans, vtkMath.radiansFromDegrees(((-360.0 * dy) / size[1]) * rotationFactor), vec3.fromValues(v2[0], v2[1], v2[2])); + mat4.rotate( + trans, + trans, + vtkMath.radiansFromDegrees(-360.0 * dy / size[1] * rotationFactor), + vec3.fromValues(v2[0], v2[1], v2[2]) + ); // Translate back - mat4.translate(trans, trans, vec3.fromValues(-center[0], -center[1], -center[2])); + mat4.translate( + trans, + trans, + vec3.fromValues(-center[0], -center[1], -center[2]) + ); const newCamPos = vec3.create(); const newFp = vec3.create(); const newViewUp = vec3.create(); // Apply transformation to camera position, focal point, and view up - vec3.transformMat4(newCamPos, vec3.fromValues(cameraPos[0], cameraPos[1], cameraPos[2]), trans); - vec3.transformMat4(newFp, vec3.fromValues(cameraFp[0], cameraFp[1], cameraFp[2]), trans); - vec3.transformMat4(newViewUp, vec3.fromValues(viewUp[0] + cameraPos[0], viewUp[1] + cameraPos[1], viewUp[2] + cameraPos[2]), trans); + vec3.transformMat4( + newCamPos, + vec3.fromValues(cameraPos[0], cameraPos[1], cameraPos[2]), + trans + ); + vec3.transformMat4( + newFp, + vec3.fromValues(cameraFp[0], cameraFp[1], cameraFp[2]), + trans + ); + vec3.transformMat4( + newViewUp, + vec3.fromValues( + viewUp[0] + cameraPos[0], + viewUp[1] + cameraPos[1], + viewUp[2] + cameraPos[2] + ), + trans + ); camera.setPosition(newCamPos[0], newCamPos[1], newCamPos[2]); camera.setFocalPoint(newFp[0], newFp[1], newFp[2]); - camera.setViewUp(newViewUp[0] - newCamPos[0], newViewUp[1] - newCamPos[1], newViewUp[2] - newCamPos[2]); + camera.setViewUp( + newViewUp[0] - newCamPos[0], + newViewUp[1] - newCamPos[1], + newViewUp[2] - newCamPos[2] + ); camera.orthogonalizeViewUp(); renderer.resetCameraClippingRange(); diff --git a/Sources/Interaction/Manipulators/TrackballZoom/index.js b/Sources/Interaction/Manipulators/TrackballZoom/index.js index e207d77b595..858ae732c1b 100644 --- a/Sources/Interaction/Manipulators/TrackballZoom/index.js +++ b/Sources/Interaction/Manipulators/TrackballZoom/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkCameraManipulator from 'vtk.js/Sources/Interaction/Manipulators/CameraManipulator'; const { vtkWarningMacro } = macro; @@ -16,9 +16,13 @@ function vtkTrackballZoom(publicAPI, model) { const size = interactor.getView().getSize(); try { - const { x, y } = interactor.getAnimationEventPosition(interactor.getPointerIndex()) || DEFAULT_POSITION; + const { x, y } = + interactor.getAnimationEventPosition(interactor.getPointerIndex()) || + DEFAULT_POSITION; const interactorStyle = interactor.getInteractorStyle(); - const renderer = interactorStyle.getCurrentRenderer() || interactor.findPokedRenderer(x, y); + const renderer = + interactorStyle.getCurrentRenderer() || + interactor.findPokedRenderer(x, y); const camera = renderer.getActiveCamera(); if (camera.getParallelProjection()) { model.zoomScale = 1.5 / size[1]; diff --git a/Sources/Interaction/Manipulators/TrackballZoomToMouse/index.js b/Sources/Interaction/Manipulators/TrackballZoomToMouse/index.js index aa2aa7cb75f..6eaf4b415c3 100644 --- a/Sources/Interaction/Manipulators/TrackballZoomToMouse/index.js +++ b/Sources/Interaction/Manipulators/TrackballZoomToMouse/index.js @@ -1,6 +1,6 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkInteractorStyleManipulator from 'vtk.js/Sources/Interaction/Style/InteractorStyleManipulator'; -import vtkTrackballZoom from 'vtk.js/Sources/Interaction/Manipulators/TrackballZoom'; +import vtkTrackballZoom from 'vtk.js/Sources/Interaction/Manipulators/TrackballZoom'; // ---------------------------------------------------------------------------- // vtkTrackballZoomToMouse methods @@ -14,7 +14,9 @@ function vtkTrackballZoomToMouse(publicAPI, model) { publicAPI.onButtonDown = (interactor) => { superOnButtonDown(interactor); - model.zoomPosition = interactor.getEventPosition(interactor.getPointerIndex()); + model.zoomPosition = interactor.getEventPosition( + interactor.getPointerIndex() + ); }; publicAPI.onAnimation = (interactor, renderer) => { @@ -28,7 +30,12 @@ function vtkTrackballZoomToMouse(publicAPI, model) { const dy = lastPos.y - pos.y; const k = dy * model.zoomScale; - vtkInteractorStyleManipulator.dollyToPosition((1.0 - k), model.zoomPosition, renderer, interactor); + vtkInteractorStyleManipulator.dollyToPosition( + 1.0 - k, + model.zoomPosition, + renderer, + interactor + ); }; } diff --git a/Sources/Interaction/Manipulators/index.js b/Sources/Interaction/Manipulators/index.js index c46dda0f1d3..c190ee038bf 100644 --- a/Sources/Interaction/Manipulators/index.js +++ b/Sources/Interaction/Manipulators/index.js @@ -1,10 +1,10 @@ -import vtkCameraManipulator from './CameraManipulator'; -import vtkTrackballMultiRotate from './TrackballMultiRotate'; -import vtkTrackballPan from './TrackballPan'; -import vtkTrackballRoll from './TrackballRoll'; -import vtkTrackballRotate from './TrackballRotate'; -import vtkTrackballZoom from './TrackballZoom'; -import vtkTrackballZoomToMouse from './TrackballZoomToMouse'; +import vtkCameraManipulator from './CameraManipulator'; +import vtkTrackballMultiRotate from './TrackballMultiRotate'; +import vtkTrackballPan from './TrackballPan'; +import vtkTrackballRoll from './TrackballRoll'; +import vtkTrackballRotate from './TrackballRotate'; +import vtkTrackballZoom from './TrackballZoom'; +import vtkTrackballZoomToMouse from './TrackballZoomToMouse'; export default { vtkCameraManipulator, diff --git a/Sources/Interaction/Misc/DeviceOrientationToCamera/example/index.js b/Sources/Interaction/Misc/DeviceOrientationToCamera/example/index.js index 8bc0d20fbb8..9a8137844bb 100644 --- a/Sources/Interaction/Misc/DeviceOrientationToCamera/example/index.js +++ b/Sources/Interaction/Misc/DeviceOrientationToCamera/example/index.js @@ -1,18 +1,20 @@ import 'vtk.js/Sources/favicon'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; -import vtkTexture from 'vtk.js/Sources/Rendering/Core/Texture'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; +import vtkTexture from 'vtk.js/Sources/Rendering/Core/Texture'; import vtkDeviceOrientationToCamera from 'vtk.js/Sources/Interaction/Misc/DeviceOrientationToCamera'; // ---------------------------------------------------------------------------- // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); const interactor = fullScreenRenderer.getInteractor(); @@ -54,8 +56,14 @@ function render() { function dataReady() { const bounds = renderer.computeVisiblePropBounds(); const scale = 500; - cube.setBounds(bounds[0] * scale, bounds[1] * scale, bounds[2] * scale, - bounds[3] * scale, bounds[4] * scale, bounds[5] * scale); + cube.setBounds( + bounds[0] * scale, + bounds[1] * scale, + bounds[2] * scale, + bounds[3] * scale, + bounds[4] * scale, + bounds[5] * scale + ); renderer.addActor(actor); renderer.getActiveCamera().setPhysicalViewUp(0, -1, 0); @@ -71,7 +79,10 @@ function loadTexture(url, index) { const reader = vtkHttpDataSetReader.newInstance({ fetchGzip: true }); reader.setUrl(url, { loadData: true }).then(() => { const dataset = reader.getOutputData(); - const scalarName = dataset.getPointData().getArrayByIndex(0).getName(); + const scalarName = dataset + .getPointData() + .getArrayByIndex(0) + .getName(); dataset.getPointData().setActiveScalars(scalarName); texture.setInputData(dataset, index); nbTextureLoaded += 1; @@ -95,10 +106,15 @@ texturePathList.forEach(loadTexture); // If device support motion bind it to the camera if (vtkDeviceOrientationToCamera.isDeviceOrientationSupported()) { vtkDeviceOrientationToCamera.addWindowListeners(); - cameraListenerId = vtkDeviceOrientationToCamera.addCameraToSynchronize(interactor, renderer.getActiveCamera(), renderer.resetCameraClippingRange); + cameraListenerId = vtkDeviceOrientationToCamera.addCameraToSynchronize( + interactor, + renderer.getActiveCamera(), + renderer.resetCameraClippingRange + ); } else { - alert('Your device does not support motion detection so regular interaction will be available'); + alert( + 'Your device does not support motion detection so regular interaction will be available' + ); } setTimeout(validateMotionDetectionAgain, 100); - diff --git a/Sources/Interaction/Misc/DeviceOrientationToCamera/index.js b/Sources/Interaction/Misc/DeviceOrientationToCamera/index.js index 0d2a33379ee..1d3def0853f 100644 --- a/Sources/Interaction/Misc/DeviceOrientationToCamera/index.js +++ b/Sources/Interaction/Misc/DeviceOrientationToCamera/index.js @@ -21,24 +21,53 @@ function onDeviceOrientationChangeEvent(evt) { } function onScreenOrientationChangeEvent() { - orientation.screen = SCREEN_ORIENTATION_MAP[window.screen.orientation || window.screen.mozOrientation] || window.orientation || 0; + orientation.screen = + SCREEN_ORIENTATION_MAP[ + window.screen.orientation || window.screen.mozOrientation + ] || + window.orientation || + 0; } function addWindowListeners() { - window.addEventListener('orientationchange', onScreenOrientationChangeEvent, false); - window.addEventListener('deviceorientation', onDeviceOrientationChangeEvent, false); + window.addEventListener( + 'orientationchange', + onScreenOrientationChangeEvent, + false + ); + window.addEventListener( + 'deviceorientation', + onDeviceOrientationChangeEvent, + false + ); orientation.update = true; - listeners.filter(i => !!i).forEach(i => i.renderWindowInteractor.requestAnimation()); + listeners + .filter((i) => !!i) + .forEach((i) => i.renderWindowInteractor.requestAnimation()); } function removeWindowListeners() { - window.removeEventListener('orientationchange', onScreenOrientationChangeEvent, false); - window.removeEventListener('deviceorientation', onDeviceOrientationChangeEvent, false); + window.removeEventListener( + 'orientationchange', + onScreenOrientationChangeEvent, + false + ); + window.removeEventListener( + 'deviceorientation', + onDeviceOrientationChangeEvent, + false + ); orientation.update = false; - listeners.filter(i => !!i).forEach(i => i.renderWindowInteractor.cancelAnimation()); + listeners + .filter((i) => !!i) + .forEach((i) => i.renderWindowInteractor.cancelAnimation()); } -function addCameraToSynchronize(renderWindowInteractor, camera, onCameraUpdate) { +function addCameraToSynchronize( + renderWindowInteractor, + camera, + onCameraUpdate +) { function onAnimation() { if (orientation.update) { const { alpha, beta, gamma } = orientation.device; diff --git a/Sources/Interaction/Style/InteractorStyleImage/index.js b/Sources/Interaction/Style/InteractorStyleImage/index.js index 031e67e33ef..a91b4d54674 100644 --- a/Sources/Interaction/Style/InteractorStyleImage/index.js +++ b/Sources/Interaction/Style/InteractorStyleImage/index.js @@ -1,7 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkInteractorStyleTrackballCamera from 'vtk.js/Sources/Interaction/Style/InteractorStyleTrackballCamera'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; -import { States } from 'vtk.js/Sources/Rendering/Core/InteractorStyle/Constants'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import { States } from 'vtk.js/Sources/Rendering/Core/InteractorStyle/Constants'; // ---------------------------------------------------------------------------- // vtkInteractorStyleImage methods @@ -21,9 +21,14 @@ function vtkInteractorStyleImage(publicAPI, model) { // Get the last (the topmost) image publicAPI.setCurrentImageNumber(model.currentImageNumber); - if (model.handleObservers && - typeof publicAPI.invokeStartWindowLevelEvent === 'function') { - publicAPI.invokeStartWindowLevelEvent({ type: 'StartWindowLevelEvent', style: publicAPI }); + if ( + model.handleObservers && + typeof publicAPI.invokeStartWindowLevelEvent === 'function' + ) { + publicAPI.invokeStartWindowLevelEvent({ + type: 'StartWindowLevelEvent', + style: publicAPI, + }); } else if (model.currentImageProperty) { const property = model.currentImageProperty; model.windowLevelInitial[0] = property.getColorWindow(); @@ -36,9 +41,14 @@ function vtkInteractorStyleImage(publicAPI, model) { if (model.state !== States.IS_WINDOW_LEVEL) { return; } - if (model.handleObservers && - typeof publicAPI.invokeEndWindowLevelEvent === 'function') { - publicAPI.invokeEndWindowLevelEvent({ type: 'EndWindowLevelEvent', style: publicAPI }); + if ( + model.handleObservers && + typeof publicAPI.invokeEndWindowLevelEvent === 'function' + ) { + publicAPI.invokeEndWindowLevelEvent({ + type: 'EndWindowLevelEvent', + style: publicAPI, + }); } publicAPI.stopState(); }; @@ -62,7 +72,9 @@ function vtkInteractorStyleImage(publicAPI, model) { // Public API methods publicAPI.superHandleAnimation = publicAPI.handleAnimation; publicAPI.handleAnimation = () => { - const pos = model.interactor.getEventPosition(model.interactor.getPointerIndex()); + const pos = model.interactor.getEventPosition( + model.interactor.getPointerIndex() + ); switch (model.state) { case States.IS_WINDOW_LEVEL: @@ -86,7 +98,9 @@ function vtkInteractorStyleImage(publicAPI, model) { //---------------------------------------------------------------------------- publicAPI.superHandleLeftButtonPress = publicAPI.handleLeftButtonPress; publicAPI.handleLeftButtonPress = () => { - const pos = model.interactor.getEventPosition(model.interactor.getPointerIndex()); + const pos = model.interactor.getEventPosition( + model.interactor.getPointerIndex() + ); publicAPI.findPokedRenderer(pos.x, pos.y); if (model.currentRenderer === null) { return; @@ -98,13 +112,17 @@ function vtkInteractorStyleImage(publicAPI, model) { model.windowLevelStartPosition[1] = pos.y; publicAPI.startWindowLevel(); publicAPI.setAnimationStateOn(); - } else if (model.interactionMode === 'IMAGE3D' && - model.interactor.getShiftKey()) { + } else if ( + model.interactionMode === 'IMAGE3D' && + model.interactor.getShiftKey() + ) { // If shift is held down, do a rotation publicAPI.startRotate(); publicAPI.setAnimationStateOn(); - } else if (model.interactionMode === 'IMAGE_SLICING' && - model.interactor.getControlKey()) { + } else if ( + model.interactionMode === 'IMAGE_SLICING' && + model.interactor.getControlKey() + ) { // If ctrl is held down in slicing mode, slice the image model.lastSlicePosition = pos.y; publicAPI.startSlice(); @@ -143,15 +161,22 @@ function vtkInteractorStyleImage(publicAPI, model) { //---------------------------------------------------------------------------- publicAPI.windowLevel = () => { - const pos = model.interactor.getEventPosition(model.interactor.getPointerIndex()); + const pos = model.interactor.getEventPosition( + model.interactor.getPointerIndex() + ); model.windowLevelCurrentPosition[0] = pos.x; model.windowLevelCurrentPosition[1] = pos.y; const rwi = model.interactor; - if (model.handleObservers && - typeof publicAPI.invokeWindowLevelEvent === 'function') { - publicAPI.invokeWindowLevelEvent({ type: 'WindowLevelEvent', style: publicAPI }); + if ( + model.handleObservers && + typeof publicAPI.invokeWindowLevelEvent === 'function' + ) { + publicAPI.invokeWindowLevelEvent({ + type: 'WindowLevelEvent', + style: publicAPI, + }); } else if (model.currentImageProperty) { const size = rwi.getView().getViewportSize(model.currentRenderer); @@ -159,21 +184,27 @@ function vtkInteractorStyleImage(publicAPI, model) { const level = model.windowLevelInitial[1]; // Compute normalized delta - let dx = (model.windowLevelCurrentPosition[0] - - model.windowLevelStartPosition[0]) * 4.0 / size[0]; - let dy = (model.windowLevelStartPosition[1] - - model.windowLevelCurrentPosition[1]) * 4.0 / size[1]; + let dx = + (model.windowLevelCurrentPosition[0] - + model.windowLevelStartPosition[0]) * + 4.0 / + size[0]; + let dy = + (model.windowLevelStartPosition[1] - + model.windowLevelCurrentPosition[1]) * + 4.0 / + size[1]; // Scale by current values if (Math.abs(mWindow) > 0.01) { dx *= mWindow; } else { - dx *= (mWindow < 0 ? -0.01 : 0.01); + dx *= mWindow < 0 ? -0.01 : 0.01; } if (Math.abs(level) > 0.01) { dy *= level; } else { - dy *= (level < 0 ? -0.01 : 0.01); + dy *= level < 0 ? -0.01 : 0.01; } // Abs so that direction does not flip @@ -229,17 +260,16 @@ function vtkInteractorStyleImage(publicAPI, model) { // clamp the distance to the clipping range if (distance < range[0]) { - distance = range[0] + (viewportHeight * 1e-3); + distance = range[0] + viewportHeight * 1e-3; } if (distance > range[1]) { - distance = range[1] - (viewportHeight * 1e-3); + distance = range[1] - viewportHeight * 1e-3; } camera.setDistance(distance); model.lastSlicePosition = pos.y; }; - //---------------------------------------------------------------------------- // This is a way of dealing with images as if they were layers. // It looks through the renderer's list of props and sets the @@ -254,8 +284,11 @@ function vtkInteractorStyleImage(publicAPI, model) { } function propMatch(j, prop, targetIndex) { - if (prop.isA('vtkImageSlice') && - j === targetIndex && prop.getPickable()) { + if ( + prop.isA('vtkImageSlice') && + j === targetIndex && + prop.getPickable() + ) { return true; } return false; @@ -311,10 +344,7 @@ export function extend(publicAPI, model, initialValues = {}) { vtkInteractorStyleTrackballCamera.extend(publicAPI, model, initialValues); // Create get-set macros - macro.setGet(publicAPI, model, [ - 'motionFactor', - 'interactionMode', - ]); + macro.setGet(publicAPI, model, ['motionFactor', 'interactionMode']); // For more macro methods, see "Sources/macro.js" diff --git a/Sources/Interaction/Style/InteractorStyleManipulator/index.js b/Sources/Interaction/Style/InteractorStyleManipulator/index.js index 328b376781b..54eb2de9b18 100644 --- a/Sources/Interaction/Style/InteractorStyleManipulator/index.js +++ b/Sources/Interaction/Style/InteractorStyleManipulator/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkInteractorStyle from 'vtk.js/Sources/Rendering/Core/InteractorStyle'; const { vtkDebugMacro } = macro; @@ -13,11 +13,17 @@ function translateCamera(renderer, rwi, toX, toY, fromX, fromY) { const cam = renderer.getActiveCamera(); let viewFocus = cam.getFocalPoint(); - viewFocus = rwi.getInteractorStyle().computeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2]); + viewFocus = rwi + .getInteractorStyle() + .computeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2]); const focalDepth = viewFocus[2]; - const newPickPoint = rwi.getInteractorStyle().computeDisplayToWorld(toX, toY, focalDepth); - const oldPickPoint = rwi.getInteractorStyle().computeDisplayToWorld(fromX, fromY, focalDepth); + const newPickPoint = rwi + .getInteractorStyle() + .computeDisplayToWorld(toX, toY, focalDepth); + const oldPickPoint = rwi + .getInteractorStyle() + .computeDisplayToWorld(fromX, fromY, focalDepth); // camera motion is reversed const motionVector = [ @@ -29,8 +35,16 @@ function translateCamera(renderer, rwi, toX, toY, fromX, fromY) { viewFocus = cam.getFocalPoint(); const viewPoint = cam.getPosition(); - cam.setFocalPoint(motionVector[0] + viewFocus[0], motionVector[1] + viewFocus[1], motionVector[2] + viewFocus[2]); - cam.setPosition(motionVector[0] + viewPoint[0], motionVector[1] + viewPoint[1], motionVector[2] + viewPoint[2]); + cam.setFocalPoint( + motionVector[0] + viewFocus[0], + motionVector[1] + viewFocus[1], + motionVector[2] + viewFocus[2] + ); + cam.setPosition( + motionVector[0] + viewPoint[0], + motionVector[1] + viewPoint[1], + motionVector[2] + viewPoint[2] + ); } function dollyToPosition(fact, position, renderer, rwi) { @@ -55,8 +69,12 @@ function dollyToPosition(fact, position, renderer, rwi) { let viewFocus = cam.getFocalPoint(); const norm = cam.getViewPlaneNormal(); - viewFocus = rwi.getInteractorStyle().computeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2]); - const newFp = rwi.getInteractorStyle().computeDisplayToWorld(position.x, position.y, viewFocus[2]); + viewFocus = rwi + .getInteractorStyle() + .computeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2]); + const newFp = rwi + .getInteractorStyle() + .computeDisplayToWorld(position.x, position.y, viewFocus[2]); cam.setFocalPoint(newFp[0], newFp[1], newFp[2]); @@ -68,13 +86,14 @@ function dollyToPosition(fact, position, renderer, rwi) { const newCameraPos = cam.getPosition(); viewFocus = cam.getFocalPoint(); const newPoint = [0, 0, 0]; - let t = (norm[0] * (viewFocus[0] - newCameraPos[0])) + - (norm[1] * (viewFocus[1] - newCameraPos[1])) + - (norm[2] * (viewFocus[2] - newCameraPos[2])); - t /= (Math.pow(norm[0], 2) + Math.pow(norm[1], 2) + Math.pow(norm[2], 2)); - newPoint[0] = newCameraPos[0] + (norm[0] * t); - newPoint[1] = newCameraPos[1] + (norm[1] * t); - newPoint[2] = newCameraPos[2] + (norm[2] * t); + let t = + norm[0] * (viewFocus[0] - newCameraPos[0]) + + norm[1] * (viewFocus[1] - newCameraPos[1]) + + norm[2] * (viewFocus[2] - newCameraPos[2]); + t /= Math.pow(norm[0], 2) + Math.pow(norm[1], 2) + Math.pow(norm[2], 2); + newPoint[0] = newCameraPos[0] + norm[0] * t; + newPoint[1] = newCameraPos[1] + norm[1] * t; + newPoint[2] = newCameraPos[2] + norm[2] * t; cam.setFocalPoint(newPoint[0], newPoint[1], newPoint[2]); renderer.resetCameraClippingRange(); @@ -105,7 +124,9 @@ function vtkInteractorStyleManipulator(publicAPI, model) { model.rotationFactor = 1; function updateCurrentRenderer() { - const pos = model.interactor.getEventPosition(model.interactor.getPointerIndex()) || DEFAULT_EVENT_POSITION; + const pos = + model.interactor.getEventPosition(model.interactor.getPointerIndex()) || + DEFAULT_EVENT_POSITION; publicAPI.findPokedRenderer(pos.x, pos.y); return model.currentRenderer; } @@ -174,17 +195,32 @@ function vtkInteractorStyleManipulator(publicAPI, model) { //------------------------------------------------------------------------- publicAPI.handleLeftButtonPress = () => { - publicAPI.onButtonDown(1, model.interactor.getShiftKey(), model.interactor.getControlKey(), model.interactor.getAltKey()); + publicAPI.onButtonDown( + 1, + model.interactor.getShiftKey(), + model.interactor.getControlKey(), + model.interactor.getAltKey() + ); }; //------------------------------------------------------------------------- publicAPI.handleMiddleButtonPress = () => { - publicAPI.onButtonDown(2, model.interactor.getShiftKey(), model.interactor.getControlKey(), model.interactor.getAltKey()); + publicAPI.onButtonDown( + 2, + model.interactor.getShiftKey(), + model.interactor.getControlKey(), + model.interactor.getAltKey() + ); }; //------------------------------------------------------------------------- publicAPI.handleRightButtonPress = () => { - publicAPI.onButtonDown(3, model.interactor.getShiftKey(), model.interactor.getControlKey(), model.interactor.getAltKey()); + publicAPI.onButtonDown( + 3, + model.interactor.getShiftKey(), + model.interactor.getControlKey(), + model.interactor.getAltKey() + ); }; //------------------------------------------------------------------------- @@ -202,10 +238,21 @@ function vtkInteractorStyleManipulator(publicAPI, model) { } // Look for a matching 3D camera interactor. - model.currentManipulator = publicAPI.find3DManipulator(ed.device, ed.input, ed.pressed); + model.currentManipulator = publicAPI.find3DManipulator( + ed.device, + ed.input, + ed.pressed + ); if (model.currentManipulator) { publicAPI.invokeStartInteractionEvent({ type: 'StartInteractionEvent' }); - model.currentManipulator.onButton3D(publicAPI, model.currentRenderer, model.state, ed.device, ed.input, ed.pressed); + model.currentManipulator.onButton3D( + publicAPI, + model.currentRenderer, + model.state, + ed.device, + ed.input, + ed.pressed + ); publicAPI.setAnimationStateOn(); } else { vtkDebugMacro('No manipulator found'); @@ -216,7 +263,12 @@ function vtkInteractorStyleManipulator(publicAPI, model) { publicAPI.handleMove3D = (arg) => { const ed = arg.calldata; if (model.currentManipulator) { - model.currentManipulator.onMove3D(publicAPI, model.currentRenderer, model.state, ed); + model.currentManipulator.onMove3D( + publicAPI, + model.currentRenderer, + model.state, + ed + ); } }; @@ -228,7 +280,12 @@ function vtkInteractorStyleManipulator(publicAPI, model) { } // Look for a matching camera interactor. - model.currentManipulator = publicAPI.findManipulator(button, shift, control, alt); + model.currentManipulator = publicAPI.findManipulator( + button, + shift, + control, + alt + ); if (model.currentManipulator) { publicAPI.invokeStartInteractionEvent({ type: 'StartInteractionEvent' }); model.currentManipulator.setCenter(model.centerOfRotation); @@ -246,11 +303,13 @@ function vtkInteractorStyleManipulator(publicAPI, model) { // Look for a matching camera manipulator let manipulator = null; model.cameraManipulators.forEach((manip) => { - if (manip - && manip.getButton() === button - && manip.getShift() === shift - && manip.getControl() === control - && manip.getAlt() === alt) { + if ( + manip && + manip.getButton() === button && + manip.getShift() === shift && + manip.getControl() === control && + manip.getAlt() === alt + ) { manipulator = manip; } }); @@ -261,9 +320,7 @@ function vtkInteractorStyleManipulator(publicAPI, model) { // Look for a matching camera manipulator let manipulator = null; model.camera3DManipulators.forEach((manip) => { - if (manip - && manip.getDevice() === device - && manip.getInput() === input) { + if (manip && manip.getDevice() === device && manip.getInput() === input) { manipulator = manip; } }); @@ -300,7 +357,7 @@ function vtkInteractorStyleManipulator(publicAPI, model) { }; publicAPI.handlePinch = () => { - model.cameraManipulators.filter(m => m.onPinch).forEach((manipulator) => { + model.cameraManipulators.filter((m) => m.onPinch).forEach((manipulator) => { manipulator.onPinch(model.interactor); }); publicAPI.invokeInteractionEvent({ type: 'InteractionEvent' }); @@ -308,15 +365,21 @@ function vtkInteractorStyleManipulator(publicAPI, model) { //------------------------------------------------------------------------- publicAPI.handleAnimation = () => { - if (model.currentManipulator && (model.currentRenderer || updateCurrentRenderer())) { - model.currentManipulator.onAnimation(model.interactor, model.currentRenderer); + if ( + model.currentManipulator && + (model.currentRenderer || updateCurrentRenderer()) + ) { + model.currentManipulator.onAnimation( + model.interactor, + model.currentRenderer + ); publicAPI.invokeInteractionEvent({ type: 'InteractionEvent' }); } }; //------------------------------------------------------------------------- publicAPI.handleChar = () => { - model.cameraManipulators.filter(m => m.onChar).forEach((manipulator) => { + model.cameraManipulators.filter((m) => m.onChar).forEach((manipulator) => { manipulator.onChar(model.interactor); }); publicAPI.invokeInteractionEvent({ type: 'InteractionEvent' }); @@ -333,14 +396,16 @@ function vtkInteractorStyleManipulator(publicAPI, model) { //------------------------------------------------------------------------- publicAPI.handleKeyPress = () => { - model.cameraManipulators.filter(m => m.onKeyDown).forEach((manipulator) => { - manipulator.onKeyDown(model.interactor); - }); + model.cameraManipulators + .filter((m) => m.onKeyDown) + .forEach((manipulator) => { + manipulator.onKeyDown(model.interactor); + }); }; //------------------------------------------------------------------------- publicAPI.handleKeyUp = () => { - model.cameraManipulators.filter(m => m.onKeyUp).forEach((manipulator) => { + model.cameraManipulators.filter((m) => m.onKeyUp).forEach((manipulator) => { manipulator.onKeyUp(model.interactor); }); }; @@ -369,9 +434,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Create get-set macros macro.setGet(publicAPI, model, ['rotationFactor']); - macro.setGetArray(publicAPI, model, [ - 'centerOfRotation', - ], 3); + macro.setGetArray(publicAPI, model, ['centerOfRotation'], 3); // Object specific methods vtkInteractorStyleManipulator(publicAPI, model); @@ -379,7 +442,10 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkInteractorStyleManipulator'); +export const newInstance = macro.newInstance( + extend, + 'vtkInteractorStyleManipulator' +); // ---------------------------------------------------------------------------- diff --git a/Sources/Interaction/Style/InteractorStyleTrackballCamera/index.js b/Sources/Interaction/Style/InteractorStyleTrackballCamera/index.js index de3d36ccec7..b38a9e9f59b 100644 --- a/Sources/Interaction/Style/InteractorStyleTrackballCamera/index.js +++ b/Sources/Interaction/Style/InteractorStyleTrackballCamera/index.js @@ -1,7 +1,10 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkInteractorStyle from 'vtk.js/Sources/Rendering/Core/InteractorStyle'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; -import { Device, Input } from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor/Constants'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import { + Device, + Input, +} from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor/Constants'; const { States } = vtkInteractorStyle; @@ -17,7 +20,9 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) { // Public API methods publicAPI.handleAnimation = () => { - const pos = model.interactor.getAnimationEventPosition(model.interactor.getPointerIndex()); + const pos = model.interactor.getAnimationEventPosition( + model.interactor.getPointerIndex() + ); switch (model.state) { case States.IS_ROTATE: @@ -56,17 +61,23 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) { return; } - if (ed && ed.pressed && - ed.device === Device.RightController && - ed.input === Input.TrackPad) { + if ( + ed && + ed.pressed && + ed.device === Device.RightController && + ed.input === Input.TrackPad + ) { publicAPI.startCameraPose(); publicAPI.setAnimationStateOn(); return; } - if (ed && !ed.pressed && - ed.device === Device.RightController && - ed.input === Input.TrackPad && - model.state === States.IS_CAMERA_POSE) { + if ( + ed && + !ed.pressed && + ed.device === Device.RightController && + ed.input === Input.TrackPad && + model.state === States.IS_CAMERA_POSE + ) { publicAPI.endCameraPose(); publicAPI.setAnimationStateOff(); // return; @@ -99,14 +110,17 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) { const dir = camera.physicalOrientationToWorldDirection(ed.orientation); camera.setPhysicalTranslation( - oldTrans[0] + (dir[0] * pscale), - oldTrans[1] + (dir[1] * pscale), - oldTrans[2] + (dir[2] * pscale)); + oldTrans[0] + dir[0] * pscale, + oldTrans[1] + dir[1] * pscale, + oldTrans[2] + dir[2] * pscale + ); }; //---------------------------------------------------------------------------- publicAPI.handleLeftButtonPress = () => { - const pos = model.interactor.getEventPosition(model.interactor.getPointerIndex()); + const pos = model.interactor.getEventPosition( + model.interactor.getPointerIndex() + ); publicAPI.findPokedRenderer(pos.x, pos.y); if (model.currentRenderer === null) { return; @@ -166,7 +180,9 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) { //---------------------------------------------------------------------------- publicAPI.handlePinch = () => { - const pos = model.interactor.getEventPosition(model.interactor.getPointerIndex()); + const pos = model.interactor.getEventPosition( + model.interactor.getPointerIndex() + ); publicAPI.findPokedRenderer(pos.x, pos.y); if (model.currentRenderer === null) { return; @@ -191,7 +207,9 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) { //---------------------------------------------------------------------------- publicAPI.handlePan = () => { - const pos = model.interactor.getEventPosition(model.interactor.getPointerIndex()); + const pos = model.interactor.getEventPosition( + model.interactor.getPointerIndex() + ); publicAPI.findPokedRenderer(pos.x, pos.y); if (model.currentRenderer === null) { return; @@ -204,23 +222,34 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) { // Calculate the focal depth since we'll be using it a lot let viewFocus = camera.getFocalPoint(); - viewFocus = publicAPI.computeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2]); + viewFocus = publicAPI.computeWorldToDisplay( + viewFocus[0], + viewFocus[1], + viewFocus[2] + ); const focalDepth = viewFocus[2]; - let newPickPoint = publicAPI.computeDisplayToWorld(pos.x, pos.y, - focalDepth); + let newPickPoint = publicAPI.computeDisplayToWorld( + pos.x, + pos.y, + focalDepth + ); const trans = rwi.getTranslation(); const lastTrans = rwi.getLastTranslation(); - newPickPoint = publicAPI.computeDisplayToWorld(viewFocus[0] + trans[0] - lastTrans[0], - viewFocus[1] + trans[1] - lastTrans[1], - focalDepth); + newPickPoint = publicAPI.computeDisplayToWorld( + viewFocus[0] + trans[0] - lastTrans[0], + viewFocus[1] + trans[1] - lastTrans[1], + focalDepth + ); // Has to recalc old mouse point since the viewport has moved, // so can't move it outside the loop - const oldPickPoint = publicAPI.computeDisplayToWorld(viewFocus[0], - viewFocus[1], - focalDepth); + const oldPickPoint = publicAPI.computeDisplayToWorld( + viewFocus[0], + viewFocus[1], + focalDepth + ); // Camera motion is reversed const motionVector = []; @@ -230,13 +259,17 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) { viewFocus = camera.getFocalPoint(); const viewPoint = camera.getPosition(); - camera.setFocalPoint(motionVector[0] + viewFocus[0], - motionVector[1] + viewFocus[1], - motionVector[2] + viewFocus[2]); - - camera.setPosition(motionVector[0] + viewPoint[0], - motionVector[1] + viewPoint[1], - motionVector[2] + viewPoint[2]); + camera.setFocalPoint( + motionVector[0] + viewFocus[0], + motionVector[1] + viewFocus[1], + motionVector[2] + viewFocus[2] + ); + + camera.setPosition( + motionVector[0] + viewPoint[0], + motionVector[1] + viewPoint[1], + motionVector[2] + viewPoint[2] + ); if (model.interactor.getLightFollowCamera()) { model.currentRenderer.updateLightsGeometryToFollowCamera(); @@ -246,7 +279,9 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) { }; publicAPI.handleRotate = () => { - const pos = model.interactor.getEventPosition(model.interactor.getPointerIndex()); + const pos = model.interactor.getEventPosition( + model.interactor.getPointerIndex() + ); publicAPI.findPokedRenderer(pos.x, pos.y); if (model.currentRenderer === null) { return; @@ -254,13 +289,13 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) { const camera = model.currentRenderer.getActiveCamera(); - - camera.roll(model.interactor.getRotation() - model.interactor.getLastRotation()); + camera.roll( + model.interactor.getRotation() - model.interactor.getLastRotation() + ); camera.orthogonalizeViewUp(); }; - //-------------------------------------------------------------------------- publicAPI.rotate = () => { if (model.currentRenderer === null) { @@ -319,12 +354,13 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) { const camera = model.currentRenderer.getActiveCamera(); const center = rwi.getView().getViewportCenter(model.currentRenderer); - const oldAngle = - vtkMath.degreesFromRadians(Math.atan2(lastPos.y - center[1], - lastPos.x - center[0])); + const oldAngle = vtkMath.degreesFromRadians( + Math.atan2(lastPos.y - center[1], lastPos.x - center[0]) + ); const newAngle = - vtkMath.degreesFromRadians(Math.atan2(pos.y - center[1], - pos.x - center[0])) - oldAngle; + vtkMath.degreesFromRadians( + Math.atan2(pos.y - center[1], pos.x - center[0]) + ) - oldAngle; if (!Number.isNaN(newAngle)) { camera.roll(newAngle); @@ -347,17 +383,26 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) { // Calculate the focal depth since we'll be using it a lot let viewFocus = camera.getFocalPoint(); - viewFocus = publicAPI.computeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2]); + viewFocus = publicAPI.computeWorldToDisplay( + viewFocus[0], + viewFocus[1], + viewFocus[2] + ); const focalDepth = viewFocus[2]; - const newPickPoint = publicAPI.computeDisplayToWorld(pos.x, pos.y, - focalDepth); + const newPickPoint = publicAPI.computeDisplayToWorld( + pos.x, + pos.y, + focalDepth + ); // Has to recalc old mouse point since the viewport has moved, // so can't move it outside the loop - const oldPickPoint = publicAPI.computeDisplayToWorld(lastPos.x, - lastPos.y, - focalDepth); + const oldPickPoint = publicAPI.computeDisplayToWorld( + lastPos.x, + lastPos.y, + focalDepth + ); // Camera motion is reversed const motionVector = []; @@ -367,13 +412,17 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) { viewFocus = camera.getFocalPoint(); const viewPoint = camera.getPosition(); - camera.setFocalPoint(motionVector[0] + viewFocus[0], - motionVector[1] + viewFocus[1], - motionVector[2] + viewFocus[2]); - - camera.setPosition(motionVector[0] + viewPoint[0], - motionVector[1] + viewPoint[1], - motionVector[2] + viewPoint[2]); + camera.setFocalPoint( + motionVector[0] + viewFocus[0], + motionVector[1] + viewFocus[1], + motionVector[2] + viewFocus[2] + ); + + camera.setPosition( + motionVector[0] + viewPoint[0], + motionVector[1] + viewPoint[1], + motionVector[2] + viewPoint[2] + ); if (rwi.getLightFollowCamera()) { model.currentRenderer.updateLightsGeometryToFollowCamera(); @@ -449,7 +498,10 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkInteractorStyleTrackballCamera'); +export const newInstance = macro.newInstance( + extend, + 'vtkInteractorStyleTrackballCamera' +); // ---------------------------------------------------------------------------- diff --git a/Sources/Interaction/Style/index.js b/Sources/Interaction/Style/index.js index b526f9326b9..051fb9ed78f 100644 --- a/Sources/Interaction/Style/index.js +++ b/Sources/Interaction/Style/index.js @@ -1,6 +1,6 @@ -import vtkInteractorStyleImage from './InteractorStyleImage'; -import vtkInteractorStyleManipulator from './InteractorStyleManipulator'; -import vtkInteractorStyleTrackballCamera from './InteractorStyleTrackballCamera'; +import vtkInteractorStyleImage from './InteractorStyleImage'; +import vtkInteractorStyleManipulator from './InteractorStyleManipulator'; +import vtkInteractorStyleTrackballCamera from './InteractorStyleTrackballCamera'; export default { vtkInteractorStyleImage, diff --git a/Sources/Interaction/UI/Icons/index.js b/Sources/Interaction/UI/Icons/index.js index f1e78c7564f..2921f40ad68 100644 --- a/Sources/Interaction/UI/Icons/index.js +++ b/Sources/Interaction/UI/Icons/index.js @@ -1,7 +1,7 @@ import Contrast from './Contrast.svg'; -import Logo from './Logo.svg'; -import Spacing from './Spacing.svg'; -import Tint from './Tint.svg'; +import Logo from './Logo.svg'; +import Spacing from './Spacing.svg'; +import Tint from './Tint.svg'; export default { Contrast, diff --git a/Sources/Interaction/UI/Slider/index.js b/Sources/Interaction/UI/Slider/index.js index 8cd84197943..c38ab7d9b35 100644 --- a/Sources/Interaction/UI/Slider/index.js +++ b/Sources/Interaction/UI/Slider/index.js @@ -1,6 +1,6 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import Constants from 'vtk.js/Sources/Interaction/UI/Slider/Constants'; -import style from 'vtk.js/Sources/Interaction/UI/Slider/Slider.mcss'; +import style from 'vtk.js/Sources/Interaction/UI/Slider/Slider.mcss'; // ---------------------------------------------------------------------------- // Helper methods @@ -17,7 +17,7 @@ function findClosestValue(value, values) { index = count; } } - return (index !== -1) ? values[index] : undefined; + return index !== -1 ? values[index] : undefined; } // ---------------------------------------------------------------------------- @@ -36,8 +36,11 @@ function vtkSlider(publicAPI, model) { // -------------------------------------------------------------------------- function getDisplacementRatio() { - return ((model.containerSizes[1] - model.containerSizes[0]) - * (model.value - model.values[0]) / (model.values[model.values.length - 1] - model.values[0])); + return ( + (model.containerSizes[1] - model.containerSizes[0]) * + (model.value - model.values[0]) / + (model.values[model.values.length - 1] - model.values[0]) + ); } function updateCursorPosition() { @@ -80,8 +83,11 @@ function vtkSlider(publicAPI, model) { function onMouseMove(e) { e.preventDefault(); if (isDragging) { - const newRatio = ratio + (((model.orientation ? e.clientX : e.clientY) - offset) / (model.containerSizes[1] - model.containerSizes[0])); - const value = (newRatio * model.range) + model.values[0]; + const newRatio = + ratio + + ((model.orientation ? e.clientX : e.clientY) - offset) / + (model.containerSizes[1] - model.containerSizes[0]); + const value = newRatio * model.range + model.values[0]; const newValue = findClosestValue(value, model.values); if (newValue !== undefined) { publicAPI.setValue(newValue); @@ -93,9 +99,15 @@ function vtkSlider(publicAPI, model) { if (!isDragging) { const isClick = !((model.orientation ? e.clientX : e.clientY) - offset); if (isClick) { - const absValue = model.values[0] + (model.range * - (offset - model.container.getBoundingClientRect()[model.orientation ? 'left' : 'top'] - (0.5 * model.containerSizes[0])) / - (model.containerSizes[1] - model.containerSizes[0])); + const absValue = + model.values[0] + + model.range * + (offset - + model.container.getBoundingClientRect()[ + model.orientation ? 'left' : 'top' + ] - + 0.5 * model.containerSizes[0]) / + (model.containerSizes[1] - model.containerSizes[0]); const newValue = findClosestValue(absValue, model.values); if (newValue !== undefined) { publicAPI.setValue(newValue); @@ -148,7 +160,11 @@ function vtkSlider(publicAPI, model) { const height = Math.floor(dims.height); const min = Math.min(width, height); const max = Math.max(width, height); - publicAPI.setOrientation(height === max ? Constants.SliderOrientation.VERTICAL : Constants.SliderOrientation.HORIZONTAL); + publicAPI.setOrientation( + height === max + ? Constants.SliderOrientation.VERTICAL + : Constants.SliderOrientation.HORIZONTAL + ); model.containerSizes = [min, max]; updateCursorPosition(); } @@ -176,7 +192,7 @@ function vtkSlider(publicAPI, model) { const step = (max - min) / (nbSteps - 1); model.values = []; for (let i = 0; i < nbSteps; i++) { - model.values.push(min + (i * step)); + model.values.push(min + i * step); } model.range = max - min; updateCursorPosition(); diff --git a/Sources/Interaction/UI/VolumeController/index.js b/Sources/Interaction/UI/VolumeController/index.js index 7ae78d759d6..c47d4637719 100644 --- a/Sources/Interaction/UI/VolumeController/index.js +++ b/Sources/Interaction/UI/VolumeController/index.js @@ -12,7 +12,9 @@ import style from 'vtk.js/Sources/Interaction/UI/VolumeController/VolumeControll // Global structures // ---------------------------------------------------------------------------- -const PRESETS_OPTIONS = vtkColorMaps.rgbPresetNames.map(name => ``); +const PRESETS_OPTIONS = vtkColorMaps.rgbPresetNames.map( + (name) => `` +); // ---------------------------------------------------------------------------- // vtkVolumeController methods @@ -25,7 +27,10 @@ function vtkVolumeController(publicAPI, model) { model.el = document.createElement('div'); model.el.setAttribute('class', style.container); - model.widget = vtkPiecewiseGaussianWidget.newInstance({ numberOfBins: 256, size: model.size }); + model.widget = vtkPiecewiseGaussianWidget.newInstance({ + numberOfBins: 256, + size: model.size, + }); function toggleVisibility() { const elements = model.el.querySelectorAll('.js-toggle'); @@ -50,9 +55,13 @@ function vtkVolumeController(publicAPI, model) { function updateColorMapPreset() { const sourceDS = model.actor.getMapper().getInputData(); - const dataArray = sourceDS.getPointData().getScalars() || sourceDS.getPointData().getArrays()[0]; + const dataArray = + sourceDS.getPointData().getScalars() || + sourceDS.getPointData().getArrays()[0]; const dataRange = dataArray.getRange(); - const preset = vtkColorMaps.getPresetByName(model.el.querySelector('.js-color-preset').value); + const preset = vtkColorMaps.getPresetByName( + model.el.querySelector('.js-color-preset').value + ); const lookupTable = model.actor.getProperty().getRGBTransferFunction(0); lookupTable.applyColorMap(preset); lookupTable.setMappingRange(...dataRange); @@ -63,8 +72,17 @@ function vtkVolumeController(publicAPI, model) { function updateSpacing() { const value = Number(model.el.querySelector('.js-spacing').value); const sourceDS = model.actor.getMapper().getInputData(); - const sampleDistance = 0.7 * Math.sqrt(sourceDS.getSpacing().map(v => v * v).reduce((a, b) => a + b, 0)); - model.actor.getMapper().setSampleDistance(sampleDistance * Math.pow(2, (value * 3.0) - 1.5)); + const sampleDistance = + 0.7 * + Math.sqrt( + sourceDS + .getSpacing() + .map((v) => v * v) + .reduce((a, b) => a + b, 0) + ); + model.actor + .getMapper() + .setSampleDistance(sampleDistance * Math.pow(2, value * 3.0 - 1.5)); model.renderWindow.render(); } @@ -74,24 +92,42 @@ function vtkVolumeController(publicAPI, model) { model.actor.getProperty().setUseGradientOpacity(0, false); } else { const sourceDS = model.actor.getMapper().getInputData(); - const dataArray = sourceDS.getPointData().getScalars() || sourceDS.getPointData().getArrays()[0]; + const dataArray = + sourceDS.getPointData().getScalars() || + sourceDS.getPointData().getArrays()[0]; const dataRange = dataArray.getRange(); model.actor.getProperty().setUseGradientOpacity(0, true); const minV = Math.max(0.0, value - 0.3) / 0.7; - model.actor.getProperty().setGradientOpacityMinimumValue(0, - (dataRange[1] - dataRange[0]) * 0.2 * minV * minV); - model.actor.getProperty().setGradientOpacityMaximumValue(0, - (dataRange[1] - dataRange[0]) * 1.0 * value * value); + model.actor + .getProperty() + .setGradientOpacityMinimumValue( + 0, + (dataRange[1] - dataRange[0]) * 0.2 * minV * minV + ); + model.actor + .getProperty() + .setGradientOpacityMaximumValue( + 0, + (dataRange[1] - dataRange[0]) * 1.0 * value * value + ); } model.renderWindow.render(); } - publicAPI.setupContent = (renderWindow, actor, isBackgroundDark, useShadow = '1', presetName = 'erdc_rainbow_bright') => { + publicAPI.setupContent = ( + renderWindow, + actor, + isBackgroundDark, + useShadow = '1', + presetName = 'erdc_rainbow_bright' + ) => { publicAPI.setActor(actor); publicAPI.setRenderWindow(renderWindow); const sourceDS = model.actor.getMapper().getInputData(); - const dataArray = sourceDS.getPointData().getScalars() || sourceDS.getPointData().getArrays()[0]; + const dataArray = + sourceDS.getPointData().getScalars() || + sourceDS.getPointData().getArrays()[0]; const lookupTable = model.actor.getProperty().getRGBTransferFunction(0); const piecewiseFunction = model.actor.getProperty().getScalarOpacity(0); @@ -114,11 +150,15 @@ function vtkVolumeController(publicAPI, model) {
${svgSpacing}
- +
${svgEdge}
- +
@@ -198,7 +238,6 @@ function vtkVolumeController(publicAPI, model) { updateEdgeGradient(); }; - publicAPI.setContainer = (el) => { if (model.container && model.container !== el) { model.container.removeChild(model.el); diff --git a/Sources/Interaction/Widgets/AbstractWidget/index.js b/Sources/Interaction/Widgets/AbstractWidget/index.js index a6b07b81056..3aa1e264374 100644 --- a/Sources/Interaction/Widgets/AbstractWidget/index.js +++ b/Sources/Interaction/Widgets/AbstractWidget/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkInteractorObserver from 'vtk.js/Sources/Rendering/Core/InteractorObserver'; const { vtkErrorMacro } = macro; @@ -12,12 +12,10 @@ function vtkAbstractWidget(publicAPI, model) { model.classHierarchy.push('vtkAbstractWidget'); // Virtual method - publicAPI.createDefaultRepresentation = () => { - }; + publicAPI.createDefaultRepresentation = () => {}; // Virtual method - publicAPI.listenEvents = () => { - }; + publicAPI.listenEvents = () => {}; publicAPI.render = () => { if (!model.parent && model.interactor) { @@ -27,11 +25,14 @@ function vtkAbstractWidget(publicAPI, model) { publicAPI.setEnable = (enable) => { if (enable) { - if (model.enabled) { // widget already enabled + if (model.enabled) { + // widget already enabled return; } if (!model.interactor) { - vtkErrorMacro('The interactor must be set prior to enabling the widget'); + vtkErrorMacro( + 'The interactor must be set prior to enabling the widget' + ); return; } @@ -60,7 +61,8 @@ function vtkAbstractWidget(publicAPI, model) { model.widgetRep.buildRepresentation(); model.currentRenderer.addViewProp(model.widgetRep); } else { - if (!model.enabled) { // already + if (!model.enabled) { + // already return; } model.enabled = 0; @@ -78,9 +80,16 @@ function vtkAbstractWidget(publicAPI, model) { }; publicAPI.get2DPointerPosition = () => { - const pos = model.interactor.getEventPosition(model.interactor.getPointerIndex()); - const boundingContainer = model.interactor.getCanvas().getBoundingClientRect(); - const position = [pos.x - boundingContainer.left, pos.y + boundingContainer.top]; + const pos = model.interactor.getEventPosition( + model.interactor.getPointerIndex() + ); + const boundingContainer = model.interactor + .getCanvas() + .getBoundingClientRect(); + const position = [ + pos.x - boundingContainer.left, + pos.y + boundingContainer.top, + ]; return position; }; } @@ -103,10 +112,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Inheritance vtkInteractorObserver.extend(publicAPI, model, initialValues); - macro.setGet(publicAPI, model, [ - 'widgetRep', - 'parent', - ]); + macro.setGet(publicAPI, model, ['widgetRep', 'parent']); model.unsubscribes = []; diff --git a/Sources/Interaction/Widgets/HandleRepresentation/index.js b/Sources/Interaction/Widgets/HandleRepresentation/index.js index d0f8bb91940..be5798b9cdb 100644 --- a/Sources/Interaction/Widgets/HandleRepresentation/index.js +++ b/Sources/Interaction/Widgets/HandleRepresentation/index.js @@ -1,7 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; -import Constants from 'vtk.js/Sources/Interaction/Widgets/HandleRepresentation/Constants'; -import vtkCoordinate from 'vtk.js/Sources/Rendering/Core/Coordinate'; -import vtkPointPlacer from 'vtk.js/Sources/Interaction/Widgets/PointPlacer'; +import macro from 'vtk.js/Sources/macro'; +import Constants from 'vtk.js/Sources/Interaction/Widgets/HandleRepresentation/Constants'; +import vtkCoordinate from 'vtk.js/Sources/Rendering/Core/Coordinate'; +import vtkPointPlacer from 'vtk.js/Sources/Interaction/Widgets/PointPlacer'; import vtkWidgetRepresentation from 'vtk.js/Sources/Interaction/Widgets/WidgetRepresentation'; const { InteractionState } = Constants; @@ -17,7 +17,13 @@ function vtkHandleRepresentation(publicAPI, model) { publicAPI.setDisplayPosition = (displayPos) => { if (model.renderer && model.pointPlacer) { const worldPos = []; - if (model.pointPlacer.computeWorldPosition(model.renderer, displayPos, worldPos)) { + if ( + model.pointPlacer.computeWorldPosition( + model.renderer, + displayPos, + worldPos + ) + ) { model.displayPosition.setValue(displayPos); model.worldPosition.setValue(worldPos); } diff --git a/Sources/Interaction/Widgets/HandleWidget/example/index.js b/Sources/Interaction/Widgets/HandleWidget/example/index.js index def2f8e80b6..baa89fae437 100644 --- a/Sources/Interaction/Widgets/HandleWidget/example/index.js +++ b/Sources/Interaction/Widgets/HandleWidget/example/index.js @@ -1,7 +1,7 @@ import 'vtk.js/Sources/favicon'; import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkHandleWidget from 'vtk.js/Sources/Interaction/Widgets/HandleWidget'; +import vtkHandleWidget from 'vtk.js/Sources/Interaction/Widgets/HandleWidget'; // ---------------------------------------------------------------------------- // USER AVAILABLE INTERACTIONS diff --git a/Sources/Interaction/Widgets/HandleWidget/index.js b/Sources/Interaction/Widgets/HandleWidget/index.js index 40f8707c560..52233425127 100644 --- a/Sources/Interaction/Widgets/HandleWidget/index.js +++ b/Sources/Interaction/Widgets/HandleWidget/index.js @@ -1,8 +1,8 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkAbstractWidget from 'vtk.js/Sources/Interaction/Widgets/AbstractWidget'; +import macro from 'vtk.js/Sources/macro'; +import vtkAbstractWidget from 'vtk.js/Sources/Interaction/Widgets/AbstractWidget'; import vtkSphereHandleRepresentation from 'vtk.js/Sources/Interaction/Widgets/SphereHandleRepresentation'; -import vtkHandleRepresentation from 'vtk.js/Sources/Interaction/Widgets/HandleRepresentation'; -import Constants from 'vtk.js/Sources/Interaction/Widgets/HandleWidget/Constants'; +import vtkHandleRepresentation from 'vtk.js/Sources/Interaction/Widgets/HandleRepresentation'; +import Constants from 'vtk.js/Sources/Interaction/Widgets/HandleWidget/Constants'; const { InteractionState } = vtkHandleRepresentation; const { WidgetState } = Constants; @@ -61,11 +61,12 @@ function vtkHandleWidget(publicAPI, model) { } events.forEach((eventName) => { model.unsubscribes.push( - model.interactor[`on${eventName}`](() => { - if (publicAPI[`handle${eventName}`]) { - publicAPI[`handle${eventName}`](); - } - })); + model.interactor[`on${eventName}`](() => { + if (publicAPI[`handle${eventName}`]) { + publicAPI[`handle${eventName}`](); + } + }) + ); }); }; @@ -117,9 +118,16 @@ function vtkHandleWidget(publicAPI, model) { }; publicAPI.selectAction = () => { - const pos = model.interactor.getEventPosition(model.interactor.getPointerIndex()); - const boundingContainer = model.interactor.getCanvas().getBoundingClientRect(); - const position = [pos.x - boundingContainer.left, pos.y + boundingContainer.top]; + const pos = model.interactor.getEventPosition( + model.interactor.getPointerIndex() + ); + const boundingContainer = model.interactor + .getCanvas() + .getBoundingClientRect(); + const position = [ + pos.x - boundingContainer.left, + pos.y + boundingContainer.top, + ]; model.widgetRep.computeInteractionState(position); if (model.widgetRep.getInteractionState() === InteractionState.OUTSIDE) { return; @@ -132,9 +140,16 @@ function vtkHandleWidget(publicAPI, model) { }; publicAPI.translateAction = () => { - const pos = model.interactor.getEventPosition(model.interactor.getPointerIndex()); - const boundingContainer = model.interactor.getCanvas().getBoundingClientRect(); - const position = [pos.x - boundingContainer.left, pos.y + boundingContainer.top]; + const pos = model.interactor.getEventPosition( + model.interactor.getPointerIndex() + ); + const boundingContainer = model.interactor + .getCanvas() + .getBoundingClientRect(); + const position = [ + pos.x - boundingContainer.left, + pos.y + boundingContainer.top, + ]; model.widgetRep.startComplexWidgetInteraction(position); if (model.widgetRep.getInteractionState() === InteractionState.OUTSIDE) { return; @@ -146,9 +161,16 @@ function vtkHandleWidget(publicAPI, model) { publicAPI.scaleAction = () => { if (model.allowHandleResize) { - const pos = model.interactor.getEventPosition(model.interactor.getPointerIndex()); - const boundingContainer = model.interactor.getCanvas().getBoundingClientRect(); - const position = [pos.x - boundingContainer.left, pos.y + boundingContainer.top]; + const pos = model.interactor.getEventPosition( + model.interactor.getPointerIndex() + ); + const boundingContainer = model.interactor + .getCanvas() + .getBoundingClientRect(); + const position = [ + pos.x - boundingContainer.left, + pos.y + boundingContainer.top, + ]; model.widgetRep.startComplexWidgetInteraction(position); if (model.widgetRep.getInteractionState() === InteractionState.OUTSIDE) { return; @@ -170,14 +192,24 @@ function vtkHandleWidget(publicAPI, model) { }; publicAPI.moveAction = () => { - const pos = model.interactor.getEventPosition(model.interactor.getPointerIndex()); - const boundingContainer = model.interactor.getCanvas().getBoundingClientRect(); - const position = [pos.x - boundingContainer.left, pos.y + boundingContainer.top]; + const pos = model.interactor.getEventPosition( + model.interactor.getPointerIndex() + ); + const boundingContainer = model.interactor + .getCanvas() + .getBoundingClientRect(); + const position = [ + pos.x - boundingContainer.left, + pos.y + boundingContainer.top, + ]; if (model.widgetState === WidgetState.START) { const state = model.widgetRep.getInteractionState(); model.widgetRep.computeInteractionState(position); setCursor(model.widgetRep.getInteractionState()); - if (model.widgetRep.getActiveRepresentation() && state !== model.widgetRep.getInteractionState()) { + if ( + model.widgetRep.getActiveRepresentation() && + state !== model.widgetRep.getInteractionState() + ) { publicAPI.render(); } return; diff --git a/Sources/Interaction/Widgets/LineRepresentation/index.js b/Sources/Interaction/Widgets/LineRepresentation/index.js index 0ad2fa33c78..4289957722e 100644 --- a/Sources/Interaction/Widgets/LineRepresentation/index.js +++ b/Sources/Interaction/Widgets/LineRepresentation/index.js @@ -10,7 +10,6 @@ import vtkSphereHandleRepresentation from 'vtk.js/Sources/Interaction/Widgets/Sp import vtkWidgetRepresentation from 'vtk.js/Sources/Interaction/Widgets/WidgetRepresentation'; import { InteractionState } from '../HandleRepresentation/Constants'; - const { State, Restrict } = Constants; // ---------------------------------------------------------------------------- @@ -40,10 +39,14 @@ function vtkLineRepresentation(publicAPI, model) { }; publicAPI.getResolution = () => model.lineSource.getResolution(); - publicAPI.getPoint1WorldPosition = () => model.point1Representation.getWorldPosition(); - publicAPI.getPoint2WorldPosition = () => model.point2Representation.getWorldPosition(); - publicAPI.getPoint1DisplayPosition = () => model.point1Representation.getDisplayPosition(); - publicAPI.getPoint2DisplayPosition = () => model.point2Representation.getDisplayPosition(); + publicAPI.getPoint1WorldPosition = () => + model.point1Representation.getWorldPosition(); + publicAPI.getPoint2WorldPosition = () => + model.point2Representation.getWorldPosition(); + publicAPI.getPoint1DisplayPosition = () => + model.point1Representation.getDisplayPosition(); + publicAPI.getPoint2DisplayPosition = () => + model.point2Representation.getDisplayPosition(); publicAPI.setPoint1WorldPosition = (pos) => { model.point1Representation.setWorldPosition(pos); model.lineSource.setPoint1(...pos); @@ -85,7 +88,10 @@ function vtkLineRepresentation(publicAPI, model) { if (model.interactionState === State.SCALING) { const dp1 = model.point1Representation.getDisplayPosition(); const dp2 = model.point2Representation.getDisplayPosition(); - model.length = Math.sqrt(((dp1[0] - dp2[0]) * (dp1[0] - dp2[0])) + ((dp1[1] - dp2[1]) * (dp1[1] - dp2[1]))); + model.length = Math.sqrt( + (dp1[0] - dp2[0]) * (dp1[0] - dp2[0]) + + (dp1[1] - dp2[1]) * (dp1[1] - dp2[1]) + ); } }; @@ -94,7 +100,7 @@ function vtkLineRepresentation(publicAPI, model) { if (model.restrictFlag !== 0) { const x = model.point1Representation.getWorldPosition(); for (let i = 0; i < 3; i++) { - x[i] = (model.restrictFlag === (i + 1)) ? x[i] : model.startP1[i]; + x[i] = model.restrictFlag === i + 1 ? x[i] : model.startP1[i]; } model.point1Representation.setWorldPosition(x); } @@ -102,7 +108,7 @@ function vtkLineRepresentation(publicAPI, model) { if (model.restrictFlag !== 0) { const x = model.point2Representation.getWorldPosition(); for (let i = 0; i < 3; i++) { - x[i] = (model.restrictFlag === (i + 1)) ? x[i] : model.startP2[i]; + x[i] = model.restrictFlag === i + 1 ? x[i] : model.startP2[i]; } model.point2Representation.setWorldPosition(x); } @@ -158,9 +164,10 @@ function vtkLineRepresentation(publicAPI, model) { model.initialBounds[i] = newBounds[i]; } model.initialLength = Math.sqrt( - ((newBounds[1] - newBounds[0]) * (newBounds[1] - newBounds[0])) + - ((newBounds[3] - newBounds[2]) * (newBounds[3] - newBounds[2])) + - ((newBounds[5] - newBounds[4]) * (newBounds[5] - newBounds[4]))); + (newBounds[1] - newBounds[0]) * (newBounds[1] - newBounds[0]) + + (newBounds[3] - newBounds[2]) * (newBounds[3] - newBounds[2]) + + (newBounds[5] - newBounds[4]) * (newBounds[5] - newBounds[4]) + ); // When PlaceWidget() is invoked, the widget orientation is preserved, but it // is allowed to translate and scale. This means it is centered in the @@ -175,11 +182,7 @@ function vtkLineRepresentation(publicAPI, model) { model.initialLength * (p1[1] - p2[1]), model.initialLength * (p1[2] - p2[2]), ]; - const o = [ - center[0] - r[0], - center[1] - r[1], - center[2] - r[2], - ]; + const o = [center[0] - r[0], center[1] - r[1], center[2] - r[2]]; const placedP1 = []; const t = []; @@ -363,8 +366,8 @@ function vtkLineRepresentation(publicAPI, model) { if (x[i] < model.initialBounds[2 * i]) { x[i] = model.initialBounds[2 * i]; } - if (x[i] > model.initialBounds[(2 * i) + 1]) { - x[i] = model.initialBounds[(2 * i) + 1]; + if (x[i] > model.initialBounds[2 * i + 1]) { + x[i] = model.initialBounds[2 * i + 1]; } } }; diff --git a/Sources/Interaction/Widgets/LineWidget/index.js b/Sources/Interaction/Widgets/LineWidget/index.js index d6ba719b2c9..c7a6be45de9 100644 --- a/Sources/Interaction/Widgets/LineWidget/index.js +++ b/Sources/Interaction/Widgets/LineWidget/index.js @@ -10,7 +10,6 @@ const { vtkErrorMacro } = macro; const { WidgetState } = Constants; const { InteractionState } = HandleRepConstants; - // ---------------------------------------------------------------------------- // vtkHandleWidget methods // ---------------------------------------------------------------------------- @@ -55,7 +54,8 @@ function vtkLineWidget(publicAPI, model) { if (publicAPI[`handle${eventName}`]) { publicAPI[`handle${eventName}`](); } - })); + }) + ); }); }; @@ -113,8 +113,12 @@ function vtkLineWidget(publicAPI, model) { } if (enabling && !enable) { - model.point1Widget.setWidgetRep(model.widgetRep.getPoint1Representation()); - model.point2Widget.setWidgetRep(model.widgetRep.getPoint2Representation()); + model.point1Widget.setWidgetRep( + model.widgetRep.getPoint1Representation() + ); + model.point2Widget.setWidgetRep( + model.widgetRep.getPoint2Representation() + ); model.point1Widget.getWidgetRep().setRenderer(model.currentRenderer); model.point2Widget.getWidgetRep().setRenderer(model.currentRenderer); } else if (!enabling && enable) { @@ -172,7 +176,9 @@ function vtkLineWidget(publicAPI, model) { const position = publicAPI.get2DPointerPosition(); if (model.widgetState === WidgetState.START) { - const pos3D = model.point1Widget.getWidgetRep().displayToWorld(position, 0); + const pos3D = model.point1Widget + .getWidgetRep() + .displayToWorld(position, 0); // The first time we click, the method is called twice if (model.currentHandle <= 1) { model.point1Widget.setEnable(0); @@ -268,14 +274,20 @@ function vtkLineWidget(publicAPI, model) { } else if (model.widgetState === WidgetState.START) { model.widgetRep.setPoint1Visibility(1); model.widgetRep.complexWidgetInteraction(position); - const pos3D = model.point1Widget.getWidgetRep().displayToWorld(position, 0); + const pos3D = model.point1Widget + .getWidgetRep() + .displayToWorld(position, 0); if (model.currentHandle === 0) { model.widgetRep.setPoint1WorldPosition(pos3D); } model.widgetRep.setPoint2WorldPosition(pos3D); } else if (model.widgetState === WidgetState.ACTIVE) { - model.widgetRep.setPoint1WorldPosition(model.point1Widget.getWidgetRep().getWorldPosition()); - model.widgetRep.setPoint2WorldPosition(model.point2Widget.getWidgetRep().getWorldPosition()); + model.widgetRep.setPoint1WorldPosition( + model.point1Widget.getWidgetRep().getWorldPosition() + ); + model.widgetRep.setPoint2WorldPosition( + model.point2Widget.getWidgetRep().getWorldPosition() + ); } publicAPI.invokeInteractionEvent(); @@ -288,8 +300,12 @@ function vtkLineWidget(publicAPI, model) { } const position = publicAPI.get2DPointerPosition(); model.widgetRep.complexWidgetInteraction(position); - model.widgetRep.setPoint1WorldPosition(model.point1Widget.getWidgetRep().getWorldPosition()); - model.widgetRep.setPoint2WorldPosition(model.point2Widget.getWidgetRep().getWorldPosition()); + model.widgetRep.setPoint1WorldPosition( + model.point1Widget.getWidgetRep().getWorldPosition() + ); + model.widgetRep.setPoint2WorldPosition( + model.point2Widget.getWidgetRep().getWorldPosition() + ); model.widgetState = WidgetState.MANIPULATE; publicAPI.invokeEndInteractionEvent(); diff --git a/Sources/Interaction/Widgets/OrientationMarkerWidget/Constants.js b/Sources/Interaction/Widgets/OrientationMarkerWidget/Constants.js index a2b82b8fb0f..75fe538e6c1 100644 --- a/Sources/Interaction/Widgets/OrientationMarkerWidget/Constants.js +++ b/Sources/Interaction/Widgets/OrientationMarkerWidget/Constants.js @@ -5,5 +5,4 @@ const Corners = { BOTTOM_RIGHT: 'BOTTOM_RIGHT', }; - export default { Corners }; diff --git a/Sources/Interaction/Widgets/OrientationMarkerWidget/example/index.js b/Sources/Interaction/Widgets/OrientationMarkerWidget/example/index.js index b365a961832..d285a75aad3 100644 --- a/Sources/Interaction/Widgets/OrientationMarkerWidget/example/index.js +++ b/Sources/Interaction/Widgets/OrientationMarkerWidget/example/index.js @@ -1,17 +1,19 @@ import 'vtk.js/Sources/favicon'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import vtkOrientationMarkerWidget from 'vtk.js/Sources/Interaction/Widgets/OrientationMarkerWidget'; -import vtkAnnotatedCubeActor from 'vtk.js/Sources/Rendering/Core/AnnotatedCubeActor/index.js'; +import vtkAnnotatedCubeActor from 'vtk.js/Sources/Rendering/Core/AnnotatedCubeActor/index.js'; // ---------------------------------------------------------------------------- // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0.2, 0.2, 0.2] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0.2, 0.2, 0.2], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -36,16 +38,28 @@ axes.setDefaultStyle({ fontStyle: 'bold', fontFamily: 'Arial', fontColor: 'black', - fontSizeScale: res => res / 2, + fontSizeScale: (res) => res / 2, faceColor: '#0000ff', edgeThickness: 0.1, edgeColor: 'black', resolution: 400, }); // axes.setXPlusFaceProperty({ text: '+X' }); -axes.setXMinusFaceProperty({ text: '-X', faceColor: '#ffff00', fontStyle: 'italic' }); -axes.setYPlusFaceProperty({ text: '+Y', faceColor: '#00ff00', fontSizeScale: res => res / 4 }); -axes.setYMinusFaceProperty({ text: '-Y', faceColor: '#00ffff', fontColor: 'white' }); +axes.setXMinusFaceProperty({ + text: '-X', + faceColor: '#ffff00', + fontStyle: 'italic', +}); +axes.setYPlusFaceProperty({ + text: '+Y', + faceColor: '#00ff00', + fontSizeScale: (res) => res / 4, +}); +axes.setYMinusFaceProperty({ + text: '-Y', + faceColor: '#00ffff', + fontColor: 'white', +}); axes.setZPlusFaceProperty({ text: '+Z', edgeColor: 'yellow' }); axes.setZMinusFaceProperty({ text: '-Z', edgeThickness: 0 }); @@ -55,7 +69,9 @@ const orientationWidget = vtkOrientationMarkerWidget.newInstance({ interactor: renderWindow.getInteractor(), }); orientationWidget.setEnabled(true); -orientationWidget.setViewportCorner(vtkOrientationMarkerWidget.Corners.BOTTOM_RIGHT); +orientationWidget.setViewportCorner( + vtkOrientationMarkerWidget.Corners.BOTTOM_RIGHT +); orientationWidget.setViewportSize(0.15); renderer.resetCamera(); diff --git a/Sources/Interaction/Widgets/OrientationMarkerWidget/index.js b/Sources/Interaction/Widgets/OrientationMarkerWidget/index.js index d68e8e55590..17391a435db 100644 --- a/Sources/Interaction/Widgets/OrientationMarkerWidget/index.js +++ b/Sources/Interaction/Widgets/OrientationMarkerWidget/index.js @@ -1,6 +1,6 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import Constants from 'vtk.js/Sources/Interaction/Widgets/OrientationMarkerWidget/Constants'; +import Constants from 'vtk.js/Sources/Interaction/Widgets/OrientationMarkerWidget/Constants'; // ---------------------------------------------------------------------------- // vtkOrientationMarkerWidget @@ -8,10 +8,10 @@ import Constants from 'vtk.js/Sources/Interaction/Widgets/OrientationMarkerWid // depends on Constants.Corners const VIEWPORTS = { - TOP_LEFT: size => [0, (1 - size), size, 1], - TOP_RIGHT: size => [(1 - size), (1 - size), 1, 1], - BOTTOM_LEFT: size => [0, 0, size, size], - BOTTOM_RIGHT: size => [(1 - size), 0, 1, size], + TOP_LEFT: (size) => [0, 1 - size, size, 1], + TOP_RIGHT: (size) => [1 - size, 1 - size, 1, 1], + BOTTOM_LEFT: (size) => [0, 0, size, size], + BOTTOM_RIGHT: (size) => [1 - size, 0, 1, size], }; function vtkOrientationMarkerWidget(publicAPI, model) { @@ -26,7 +26,9 @@ function vtkOrientationMarkerWidget(publicAPI, model) { // private methods function updateMarkerOrientation() { - const currentCamera = model.interactor.findPokedRenderer().getActiveCamera(); + const currentCamera = model.interactor + .findPokedRenderer() + .getActiveCamera(); if (!currentCamera) { return; @@ -59,11 +61,15 @@ function vtkOrientationMarkerWidget(publicAPI, model) { } if (!model.interactor) { - console.error('Must set interactor before enabling orientation marker.'); + console.error( + 'Must set interactor before enabling orientation marker.' + ); return; } - const renderWindow = model.interactor.findPokedRenderer().getRenderWindow(); + const renderWindow = model.interactor + .findPokedRenderer() + .getRenderWindow(); renderWindow.addRenderer(selfRenderer); if (renderWindow.getNumberOfLayers() < 2) { renderWindow.setNumberOfLayers(2); @@ -77,7 +83,9 @@ function vtkOrientationMarkerWidget(publicAPI, model) { selfRenderer.setViewport(...getViewport()); - const { unsubscribe } = model.interactor.onAnimation(updateMarkerOrientation); + const { unsubscribe } = model.interactor.onAnimation( + updateMarkerOrientation + ); interactorUnsubscribe = unsubscribe; model.enabled = true; @@ -93,7 +101,9 @@ function vtkOrientationMarkerWidget(publicAPI, model) { model.actor.setVisibility(false); selfRenderer.removeViewProp(model.actor); - const renderWindow = model.interactor.findPokedRenderer().getRenderWindow(); + const renderWindow = model.interactor + .findPokedRenderer() + .getRenderWindow(); if (renderWindow) { renderWindow.removeRenderer(selfRenderer); } @@ -140,18 +150,11 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.obj(publicAPI, model); - macro.get(publicAPI, model, [ - 'enabled', - 'viewportCorner', - 'viewportSize', - ]); + macro.get(publicAPI, model, ['enabled', 'viewportCorner', 'viewportSize']); // NOTE: setting these while the widget is enabled will // not update the widget. - macro.setGet(publicAPI, model, [ - 'actor', - 'interactor', - ]); + macro.setGet(publicAPI, model, ['actor', 'interactor']); // Object methods vtkOrientationMarkerWidget(publicAPI, model); @@ -159,7 +162,10 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkOrientationMarkerWidget'); +export const newInstance = macro.newInstance( + extend, + 'vtkOrientationMarkerWidget' +); // ---------------------------------------------------------------------------- diff --git a/Sources/Interaction/Widgets/PiecewiseGaussianWidget/example/index.js b/Sources/Interaction/Widgets/PiecewiseGaussianWidget/example/index.js index a7b6bcecf6e..6f5d1379e45 100644 --- a/Sources/Interaction/Widgets/PiecewiseGaussianWidget/example/index.js +++ b/Sources/Interaction/Widgets/PiecewiseGaussianWidget/example/index.js @@ -1,12 +1,12 @@ import 'vtk.js/Sources/favicon'; -import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; -import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction'; +import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; +import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction'; import vtkPiecewiseGaussianWidget from 'vtk.js/Sources/Interaction/Widgets/PiecewiseGaussianWidget'; -import vtkVolume from 'vtk.js/Sources/Rendering/Core/Volume'; -import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper'; +import vtkVolume from 'vtk.js/Sources/Rendering/Core/Volume'; +import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper'; import vtkColorMaps from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction/ColorMaps'; @@ -14,11 +14,20 @@ import vtkColorMaps from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction/Co // Standard rendering code setup // ---------------------------------------------------------------------------- -const rootContainer = document.querySelector('.vtk-js-example-piecewise-gaussian-widget'); +const rootContainer = document.querySelector( + '.vtk-js-example-piecewise-gaussian-widget' +); const containerStyle = rootContainer ? { height: '100%' } : null; -const urlToLoad = rootContainer ? rootContainer.dataset.url || 'https://kitware.github.io/vtk-js/data/volume/LIDC2.vti' : `${__BASE_PATH__}/data/volume/LIDC2.vti`; - -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0], rootContainer, containerStyle }); +const urlToLoad = rootContainer + ? rootContainer.dataset.url || + 'https://kitware.github.io/vtk-js/data/volume/LIDC2.vti' + : `${__BASE_PATH__}/data/volume/LIDC2.vti`; + +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], + rootContainer, + containerStyle, +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -55,8 +64,12 @@ const globalDataRange = [0, 255]; const lookupTable = vtkColorTransferFunction.newInstance(); function changePreset(delta = 1) { - presetIndex = (presetIndex + delta + vtkColorMaps.rgbPresetNames.length) % vtkColorMaps.rgbPresetNames.length; - lookupTable.applyColorMap(vtkColorMaps.getPresetByName(vtkColorMaps.rgbPresetNames[presetIndex])); + presetIndex = + (presetIndex + delta + vtkColorMaps.rgbPresetNames.length) % + vtkColorMaps.rgbPresetNames.length; + lookupTable.applyColorMap( + vtkColorMaps.getPresetByName(vtkColorMaps.rgbPresetNames[presetIndex]) + ); lookupTable.setMappingRange(...globalDataRange); lookupTable.updateRange(); labelContainer.innerHTML = vtkColorMaps.rgbPresetNames[presetIndex]; @@ -84,8 +97,10 @@ labelContainer.addEventListener('click', (event) => { // Example code // ---------------------------------------------------------------------------- - -const widget = vtkPiecewiseGaussianWidget.newInstance({ numberOfBins: 256, size: [400, 150] }); +const widget = vtkPiecewiseGaussianWidget.newInstance({ + numberOfBins: 256, + size: [400, 150], +}); widget.updateStyle({ backgroundColor: 'rgba(255, 255, 255, 0.6)', histogramColor: 'rgba(100, 100, 100, 0.5)', diff --git a/Sources/Interaction/Widgets/PiecewiseGaussianWidget/index.js b/Sources/Interaction/Widgets/PiecewiseGaussianWidget/index.js index b0c325cb132..1f13da564b5 100644 --- a/Sources/Interaction/Widgets/PiecewiseGaussianWidget/index.js +++ b/Sources/Interaction/Widgets/PiecewiseGaussianWidget/index.js @@ -27,18 +27,23 @@ const ACTIONS = { gaussian.position = x + xOffset; }, adjustHeight(x, y, originalXY, gaussian, originalGaussian) { - gaussian.height = (1 - y); + gaussian.height = 1 - y; gaussian.height = Math.min(1, Math.max(0, gaussian.height)); }, adjustBias(x, y, originalXY, gaussian, originalGaussian) { - gaussian.xBias = originalGaussian.xBias - ((originalXY[0] - x) / gaussian.height); - gaussian.yBias = originalGaussian.yBias + (4 * (originalXY[1] - y) / gaussian.height); + gaussian.xBias = + originalGaussian.xBias - (originalXY[0] - x) / gaussian.height; + gaussian.yBias = + originalGaussian.yBias + 4 * (originalXY[1] - y) / gaussian.height; // Clamps gaussian.xBias = Math.max(-1, Math.min(1, gaussian.xBias)); gaussian.yBias = Math.max(0, Math.min(2, gaussian.yBias)); }, adjustWidth(x, y, originalXY, gaussian, originalGaussian, side) { - gaussian.width = (side < 0) ? originalGaussian.width - (originalXY[0] - x) : originalGaussian.width + (originalXY[0] - x); + gaussian.width = + side < 0 + ? originalGaussian.width - (originalXY[0] - x) + : originalGaussian.width + (originalXY[0] - x); if (gaussian.width < MIN_GAUSSIAN_WIDTH) { gaussian.width = MIN_GAUSSIAN_WIDTH; } @@ -60,7 +65,7 @@ function computeOpacities(gaussians, sampling = 256) { const x = i / (sampling - 1); // clamp non-zero values to pos +/- width - if (x > (position + width) || x < (position - width)) { + if (x > position + width || x < position - width) { if (opacities[i] < 0.0) { opacities[i] = 0.0; } @@ -68,22 +73,29 @@ function computeOpacities(gaussians, sampling = 256) { } // non-zero width - const correctedWidth = (width < MIN_GAUSSIAN_WIDTH) ? MIN_GAUSSIAN_WIDTH : width; + const correctedWidth = + width < MIN_GAUSSIAN_WIDTH ? MIN_GAUSSIAN_WIDTH : width; // translate the original x to a new x based on the xbias let x0 = 0; - if (xBias === 0 || x === (position + xBias)) { + if (xBias === 0 || x === position + xBias) { x0 = x; - } else if (x > (position + xBias)) { + } else if (x > position + xBias) { if (correctedWidth === xBias) { x0 = position; } else { - x0 = position + ((x - position - xBias) * (correctedWidth / (correctedWidth - xBias))); + x0 = + position + + (x - position - xBias) * + (correctedWidth / (correctedWidth - xBias)); } - } else if (-correctedWidth === xBias) { // (x < pos+xBias) + } else if (-correctedWidth === xBias) { + // (x < pos+xBias) x0 = position; } else { - x0 = position - ((x - position - xBias) * (correctedWidth / (correctedWidth + xBias))); + x0 = + position - + (x - position - xBias) * (correctedWidth / (correctedWidth + xBias)); } // center around 0 and normalize to -1,1 @@ -93,13 +105,13 @@ function computeOpacities(gaussians, sampling = 256) { // a gaussian and a parabola if 0 < yBias <1 // a parabola and a step function if 1 < yBias <2 const h0a = Math.exp(-(4 * x1 * x1)); - const h0b = 1.0 - (x1 * x1); + const h0b = 1.0 - x1 * x1; const h0c = 1.0; let h1; if (yBias < 1) { - h1 = (yBias * h0b) + ((1 - yBias) * h0a); + h1 = yBias * h0b + (1 - yBias) * h0a; } else { - h1 = ((2 - yBias) * h0b) + ((yBias - 1) * h0c); + h1 = (2 - yBias) * h0b + (yBias - 1) * h0c; } const h2 = height * h1; @@ -115,7 +127,12 @@ function computeOpacities(gaussians, sampling = 256) { // ---------------------------------------------------------------------------- -function drawChart(ctx, area, values, style = { lineWidth: 1, strokeStyle: '#000' }) { +function drawChart( + ctx, + area, + values, + style = { lineWidth: 1, strokeStyle: '#000' } +) { const verticalScale = area[3]; const horizontalScale = area[2] / (values.length - 1); const height = ctx.canvas.height; @@ -128,7 +145,10 @@ function drawChart(ctx, area, values, style = { lineWidth: 1, strokeStyle: '#000 ctx.moveTo(area[0], height - area[1]); for (let index = 0; index < values.length; index++) { - ctx.lineTo(area[0] + (index * horizontalScale), Math.max(area[1], height - (area[1] + (values[index] * verticalScale)))); + ctx.lineTo( + area[0] + index * horizontalScale, + Math.max(area[1], height - (area[1] + values[index] * verticalScale)) + ); } if (fill) { @@ -153,7 +173,12 @@ function updateColorCanvas(colorTransferFunction, width, rangeToUse, canvas) { workCanvas.setAttribute('height', 256); const ctx = workCanvas.getContext('2d'); - const rgba = colorTransferFunction.getUint8Table(rangeToUse[0], rangeToUse[1], width, 4); + const rgba = colorTransferFunction.getUint8Table( + rangeToUse[0], + rangeToUse[1], + width, + 4 + ); const pixelsArea = ctx.getImageData(0, 0, width, 256); for (let lineIdx = 0; lineIdx < 256; lineIdx++) { pixelsArea.data.set(rgba, lineIdx * 4 * width); @@ -192,7 +217,7 @@ function normalizeCoordinates(x, y, subRectangeArea) { // ---------------------------------------------------------------------------- function findGaussian(x, gaussians) { - const distances = gaussians.map(g => Math.abs(g.position - x)); + const distances = gaussians.map((g) => Math.abs(g.position - x)); const min = Math.min(...distances); return distances.indexOf(min); } @@ -213,16 +238,25 @@ function createListener(callback, preventDefault = true) { function createTouchClickListener(...callbacks) { const id = TOUCH_CLICK.length; - TOUCH_CLICK.push({ callbacks, timeout: 0, deltaT: 200, count: 0, ready: false }); + TOUCH_CLICK.push({ + callbacks, + timeout: 0, + deltaT: 200, + count: 0, + ready: false, + }); return id; } // ---------------------------------------------------------------------------- function processTouchClicks() { - TOUCH_CLICK.filter(t => t.ready).forEach((touchHandle) => { + TOUCH_CLICK.filter((t) => t.ready).forEach((touchHandle) => { touchHandle.callbacks.forEach((callback) => { - if (callback.touches === touchHandle.touches && callback.clicks === touchHandle.count) { + if ( + callback.touches === touchHandle.touches && + callback.clicks === touchHandle.count + ) { callback.action(...touchHandle.singleTouche); } }); @@ -237,11 +271,21 @@ function processTouchClicks() { // ---------------------------------------------------------------------------- -function createTouchListener(id, callback, nbTouches = 1, preventDefault = true) { +function createTouchListener( + id, + callback, + nbTouches = 1, + preventDefault = true +) { return (e) => { const targetBounds = e.target.getBoundingClientRect(); - const relativeTouches = Array.prototype.map.call(e.touches, t => [t.pageX - targetBounds.left, t.pageY - targetBounds.top]); - const singleTouche = relativeTouches.reduce((a, b) => [a[0] + b[0], a[1] + b[1]], [0, 0]).map(v => v / e.touches.length); + const relativeTouches = Array.prototype.map.call(e.touches, (t) => [ + t.pageX - targetBounds.left, + t.pageY - targetBounds.top, + ]); + const singleTouche = relativeTouches + .reduce((a, b) => [a[0] + b[0], a[1] + b[1]], [0, 0]) + .map((v) => v / e.touches.length); if (e.type === 'touchstart') { clearTimeout(TOUCH_CLICK[id].timeout); @@ -259,7 +303,10 @@ function createTouchListener(id, callback, nbTouches = 1, preventDefault = true) if (preventDefault) { e.preventDefault(); } - TOUCH_CLICK[id].timeout = setTimeout(processTouchClicks, TOUCH_CLICK[id].deltaT); + TOUCH_CLICK[id].timeout = setTimeout( + processTouchClicks, + TOUCH_CLICK[id].deltaT + ); } else { TOUCH_CLICK[id].ready = false; } @@ -277,7 +324,7 @@ function createTouchListener(id, callback, nbTouches = 1, preventDefault = true) // ---------------------------------------------------------------------------- function listenerSelector(condition, ok, ko) { - return e => (condition() ? ok(e) : ko(e)); + return (e) => (condition() ? ok(e) : ko(e)); } // ---------------------------------------------------------------------------- @@ -360,7 +407,11 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) { publicAPI.modified(); }; - publicAPI.setDataArray = (array, numberOfBinToConsider = 1, numberOfBinsToSkip = 1) => { + publicAPI.setDataArray = ( + array, + numberOfBinToConsider = 1, + numberOfBinsToSkip = 1 + ) => { model.histogramArray = array; const size = array.length; let max = array[0]; @@ -370,21 +421,26 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) { min = Math.min(min, array[i]); } - const delta = (max - min); + const delta = max - min; model.dataRange = [min, max]; model.histogram = []; while (model.histogram.length < model.numberOfBins) { model.histogram.push(0); } array.forEach((value) => { - const idx = Math.floor((model.numberOfBins - 1) * (Number(value) - min) / delta); + const idx = Math.floor( + (model.numberOfBins - 1) * (Number(value) - min) / delta + ); model.histogram[idx] += 1; }); // Smart Rescale Histogram - const sampleSize = Math.min(numberOfBinToConsider, model.histogram.length - numberOfBinsToSkip); + const sampleSize = Math.min( + numberOfBinToConsider, + model.histogram.length - numberOfBinsToSkip + ); const sortedArray = [].concat(model.histogram); - sortedArray.sort((a, b) => (Number(a) - Number(b))); + sortedArray.sort((a, b) => Number(a) - Number(b)); for (let i = 0; i < numberOfBinsToSkip; i++) { sortedArray.pop(); } @@ -393,12 +449,16 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) { } const mean = sortedArray.reduce((a, b) => a + b, 0) / sampleSize; - model.histogram = model.histogram.map(v => v / mean); + model.histogram = model.histogram.map((v) => v / mean); publicAPI.modified(); }; publicAPI.onClick = (x, y) => { - const [xNormalized, yNormalized] = normalizeCoordinates(x, y, model.graphArea); + const [xNormalized, yNormalized] = normalizeCoordinates( + x, + y, + model.graphArea + ); if (xNormalized < 0 && model.style.iconSize > 1) { // Control buttons const delta = model.style.iconSize + model.style.padding; @@ -420,7 +480,12 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) { // Fake active action setImmediate(() => { publicAPI.onDown(x, y); - model.dragAction = { position: [0, 0], action, gaussian, originalGaussian }; + model.dragAction = { + position: [0, 0], + action, + gaussian, + originalGaussian, + }; }); break; } @@ -435,7 +500,12 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) { model.dragAction = null; } } - } else if (xNormalized < 0 || xNormalized > 1 || yNormalized < 0 || yNormalized > 1) { + } else if ( + xNormalized < 0 || + xNormalized > 1 || + yNormalized < 0 || + yNormalized > 1 + ) { model.selectedGaussian = -1; model.dragAction = null; } else { @@ -449,8 +519,15 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) { }; publicAPI.onHover = (x, y) => { - const [xNormalized, yNormalized] = normalizeCoordinates(x, y, model.graphArea); - const newActive = (xNormalized < 0) ? model.selectedGaussian : findGaussian(xNormalized, model.gaussians); + const [xNormalized, yNormalized] = normalizeCoordinates( + x, + y, + model.graphArea + ); + const newActive = + xNormalized < 0 + ? model.selectedGaussian + : findGaussian(xNormalized, model.gaussians); model.canvas.style.cursor = 'default'; const gaussian = model.gaussians[newActive]; if (gaussian && xNormalized >= 0) { @@ -465,9 +542,9 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) { } else { actionName = 'adjustPosition'; } - } else if (invY > (gaussian.height * 0.5) + tolerance) { + } else if (invY > gaussian.height * 0.5 + tolerance) { actionName = 'adjustPosition'; - } else if (invY > (gaussian.height * 0.5) - tolerance) { + } else if (invY > gaussian.height * 0.5 - tolerance) { if (Math.abs(xNormalized - gaussian.position) < tolerance) { actionName = 'adjustBias'; } else { @@ -481,7 +558,12 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) { model.canvas.style.cursor = ACTION_TO_CURSOR[actionName]; const action = ACTIONS[actionName]; const originalGaussian = Object.assign({}, gaussian); - model.dragAction = { position: [xNormalized, yNormalized], action, gaussian, originalGaussian }; + model.dragAction = { + position: [xNormalized, yNormalized], + action, + gaussian, + originalGaussian, + }; } if (newActive !== model.activeGaussian) { @@ -513,9 +595,20 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) { publicAPI.onDrag = (x, y) => { if (model.dragAction) { - const [xNormalized, yNormalized] = normalizeCoordinates(x, y, model.graphArea); + const [xNormalized, yNormalized] = normalizeCoordinates( + x, + y, + model.graphArea + ); const { position, gaussian, originalGaussian, action } = model.dragAction; - action(xNormalized, yNormalized, position, gaussian, originalGaussian, model.gaussianSide); + action( + xNormalized, + yNormalized, + position, + gaussian, + originalGaussian, + model.gaussianSide + ); model.opacities = computeOpacities(model.gaussians, model.piecewiseSize); publicAPI.invokeOpacityChange(publicAPI, true); publicAPI.modified(); @@ -540,7 +633,11 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) { }; publicAPI.onAddGaussian = (x, y) => { - const [xNormalized, yNormalized] = normalizeCoordinates(x, y, model.graphArea); + const [xNormalized, yNormalized] = normalizeCoordinates( + x, + y, + model.graphArea + ); if (xNormalized >= 0) { publicAPI.addGaussian(xNormalized, 1 - yNormalized, 0.1, 0, 0); } @@ -564,18 +661,25 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) { clicks: 1, touches: 1, action: publicAPI.onClick, - }, { + }, + { clicks: 2, touches: 1, action: publicAPI.onAddGaussian, - }, { + }, + { clicks: 2, touches: 2, action: publicAPI.onRemoveGaussian, - }); + } + ); model.listeners = { - mousemove: listenerSelector(isDown, createListener(publicAPI.onDrag), createListener(publicAPI.onHover)), + mousemove: listenerSelector( + isDown, + createListener(publicAPI.onDrag), + createListener(publicAPI.onHover) + ), dblclick: createListener(publicAPI.onAddGaussian), contextmenu: createListener(publicAPI.onRemoveGaussian), click: createListener(publicAPI.onClick), @@ -583,12 +687,23 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) { mousedown: createListener(publicAPI.onDown), mouseout: createListener(publicAPI.onLeave), - touchstart: createTouchListener(touchId, macro.chain(publicAPI.onHover, publicAPI.onDown)), - touchmove: listenerSelector(isDown, createTouchListener(touchId, publicAPI.onDrag), createTouchListener(touchId, publicAPI.onHover)), + touchstart: createTouchListener( + touchId, + macro.chain(publicAPI.onHover, publicAPI.onDown) + ), + touchmove: listenerSelector( + isDown, + createTouchListener(touchId, publicAPI.onDrag), + createTouchListener(touchId, publicAPI.onHover) + ), touchend: createTouchListener(touchId, publicAPI.onUp, 0), // touchend have 0 touch event... }; Object.keys(model.listeners).forEach((eventType) => { - model.canvas.addEventListener(eventType, model.listeners[eventType], false); + model.canvas.addEventListener( + eventType, + model.listeners[eventType], + false + ); }); } }; @@ -611,8 +726,8 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) { const graphArea = [ Math.floor(model.style.iconSize + offset), Math.floor(offset), - Math.ceil(width - (2 * offset) - model.style.iconSize), - Math.ceil(height - (2 * offset)), + Math.ceil(width - 2 * offset - model.style.iconSize), + Math.ceil(height - 2 * offset), ]; model.graphArea = graphArea; @@ -625,20 +740,34 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) { if (model.style.iconSize > 1) { // Draw icons // + - const halfSize = Math.round((model.style.iconSize / 2) - model.style.strokeWidth); + const halfSize = Math.round( + model.style.iconSize / 2 - model.style.strokeWidth + ); const center = Math.round(halfSize + offset + model.style.strokeWidth); ctx.beginPath(); ctx.lineWidth = model.style.buttonStrokeWidth; ctx.strokeStyle = model.style.buttonStrokeColor; - ctx.arc(center - (offset / 2), center, halfSize, 0, 2 * Math.PI, false); + ctx.arc(center - offset / 2, center, halfSize, 0, 2 * Math.PI, false); ctx.fillStyle = model.style.buttonFillColor; ctx.fill(); ctx.stroke(); - ctx.moveTo(center - halfSize + model.style.strokeWidth + 2 - (offset / 2), center); - ctx.lineTo(center + halfSize - model.style.strokeWidth - 2 - (offset / 2), center); + ctx.moveTo( + center - halfSize + model.style.strokeWidth + 2 - offset / 2, + center + ); + ctx.lineTo( + center + halfSize - model.style.strokeWidth - 2 - offset / 2, + center + ); ctx.stroke(); - ctx.moveTo(center - (offset / 2), center - halfSize + model.style.strokeWidth + 2); - ctx.lineTo(center - (offset / 2), center + halfSize - model.style.strokeWidth - 2); + ctx.moveTo( + center - offset / 2, + center - halfSize + model.style.strokeWidth + 2 + ); + ctx.lineTo( + center - offset / 2, + center + halfSize - model.style.strokeWidth - 2 + ); ctx.stroke(); // - @@ -652,67 +781,119 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) { ctx.strokeStyle = model.style.buttonStrokeColor; } ctx.beginPath(); - ctx.arc(center - (offset / 2), center + (offset / 2) + model.style.iconSize, halfSize, 0, 2 * Math.PI, false); + ctx.arc( + center - offset / 2, + center + offset / 2 + model.style.iconSize, + halfSize, + 0, + 2 * Math.PI, + false + ); ctx.fill(); ctx.stroke(); - ctx.moveTo(center - halfSize + model.style.strokeWidth + 2 - (offset / 2), center + (offset / 2) + model.style.iconSize); - ctx.lineTo(center + halfSize - model.style.strokeWidth - 2 - (offset / 2), center + (offset / 2) + model.style.iconSize); + ctx.moveTo( + center - halfSize + model.style.strokeWidth + 2 - offset / 2, + center + offset / 2 + model.style.iconSize + ); + ctx.lineTo( + center + halfSize - model.style.strokeWidth - 2 - offset / 2, + center + offset / 2 + model.style.iconSize + ); ctx.stroke(); } // Draw histogram - drawChart(ctx, graphArea, model.histogram, { lineWidth: 1, strokeStyle: model.style.histogramColor, fillStyle: model.style.histogramColor }); + drawChart(ctx, graphArea, model.histogram, { + lineWidth: 1, + strokeStyle: model.style.histogramColor, + fillStyle: model.style.histogramColor, + }); // Draw gaussians - drawChart(ctx, graphArea, model.opacities, { lineWidth: model.style.strokeWidth, strokeStyle: model.style.strokeColor }); + drawChart(ctx, graphArea, model.opacities, { + lineWidth: model.style.strokeWidth, + strokeStyle: model.style.strokeColor, + }); // Draw color function if any if (model.colorTransferFunction) { - const rangeToUse = model.dataRange || model.colorTransferFunction.getMappingRange(); - if (!model.colorCanvas || model.colorCanvasMTime < model.colorTransferFunction.getMTime()) { + const rangeToUse = + model.dataRange || model.colorTransferFunction.getMappingRange(); + if ( + !model.colorCanvas || + model.colorCanvasMTime < model.colorTransferFunction.getMTime() + ) { model.colorCanvasMTime = model.colorTransferFunction.getMTime(); - model.colorCanvas = updateColorCanvas(model.colorTransferFunction, graphArea[2], rangeToUse, model.colorCanvas); + model.colorCanvas = updateColorCanvas( + model.colorTransferFunction, + graphArea[2], + rangeToUse, + model.colorCanvas + ); } ctx.save(); - drawChart(ctx, graphArea, model.opacities, { lineWidth: 1, strokeStyle: 'rgba(0,0,0,0)', fillStyle: 'rgba(0,0,0,1)', clip: true }); + drawChart(ctx, graphArea, model.opacities, { + lineWidth: 1, + strokeStyle: 'rgba(0,0,0,0)', + fillStyle: 'rgba(0,0,0,1)', + clip: true, + }); ctx.drawImage(model.colorCanvas, graphArea[0], graphArea[1]); ctx.restore(); } else if (model.backgroundImage) { - model.colorCanvas = updateColorCanvasFromImage(model.backgroundImage, graphArea[2], model.colorCanvas); + model.colorCanvas = updateColorCanvasFromImage( + model.backgroundImage, + graphArea[2], + model.colorCanvas + ); ctx.save(); - drawChart(ctx, graphArea, model.opacities, { lineWidth: 1, strokeStyle: 'rgba(0,0,0,0)', fillStyle: 'rgba(0,0,0,1)', clip: true }); + drawChart(ctx, graphArea, model.opacities, { + lineWidth: 1, + strokeStyle: 'rgba(0,0,0,0)', + fillStyle: 'rgba(0,0,0,1)', + clip: true, + }); ctx.drawImage(model.colorCanvas, graphArea[0], graphArea[1]); ctx.restore(); } // Draw active guassian - const activeGaussian = model.gaussians[model.activeGaussian] || model.gaussians[model.selectedGaussian]; + const activeGaussian = + model.gaussians[model.activeGaussian] || + model.gaussians[model.selectedGaussian]; if (activeGaussian) { const activeOpacities = computeOpacities([activeGaussian], graphArea[2]); - drawChart(ctx, graphArea, activeOpacities, { lineWidth: model.style.activeStrokeWidth, strokeStyle: model.style.activeColor }); + drawChart(ctx, graphArea, activeOpacities, { + lineWidth: model.style.activeStrokeWidth, + strokeStyle: model.style.activeColor, + }); // Draw controls - const xCenter = graphArea[0] + (activeGaussian.position * graphArea[2]); - const yTop = graphArea[1] + ((1 - activeGaussian.height) * graphArea[3]); - const yMiddle = graphArea[1] + ((1 - (0.5 * activeGaussian.height)) * graphArea[3]); + const xCenter = graphArea[0] + activeGaussian.position * graphArea[2]; + const yTop = graphArea[1] + (1 - activeGaussian.height) * graphArea[3]; + const yMiddle = + graphArea[1] + (1 - 0.5 * activeGaussian.height) * graphArea[3]; const yBottom = graphArea[1] + graphArea[3]; const widthInPixel = activeGaussian.width * graphArea[2]; ctx.lineWidth = model.style.handleWidth; ctx.strokeStyle = model.style.handleColor; ctx.fillStyle = model.style.backgroundColor; ctx.beginPath(); - ctx.moveTo(xCenter, graphArea[1] + ((1 - activeGaussian.height) * graphArea[3])); + ctx.moveTo( + xCenter, + graphArea[1] + (1 - activeGaussian.height) * graphArea[3] + ); ctx.lineTo(xCenter, graphArea[1] + graphArea[3]); ctx.stroke(); // Height ctx.beginPath(); - ctx.arc( - xCenter, - yTop, - 6, 0, 2 * Math.PI); + ctx.arc(xCenter, yTop, 6, 0, 2 * Math.PI); ctx.fill(); ctx.stroke(); // Bias - const radius = Math.min(widthInPixel * 0.1, activeGaussian.height * graphArea[3] * 0.2); + const radius = Math.min( + widthInPixel * 0.1, + activeGaussian.height * graphArea[3] * 0.2 + ); ctx.beginPath(); ctx.rect(xCenter - radius, yMiddle - radius, radius * 2, radius * 2); ctx.fill(); @@ -728,12 +909,13 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) { publicAPI.getOpacityNodes = (dataRange) => { const rangeToUse = dataRange || model.dataRange; - const delta = (rangeToUse[1] - rangeToUse[0]) / (model.opacities.length - 1); + const delta = + (rangeToUse[1] - rangeToUse[0]) / (model.opacities.length - 1); const nodes = []; const midpoint = 0.5; const sharpness = 0; for (let index = 0; index < model.opacities.length; index++) { - const x = rangeToUse[0] + (delta * index); + const x = rangeToUse[0] + delta * index; const y = model.opacities[index]; nodes.push({ x, y, midpoint, sharpness }); } @@ -794,7 +976,12 @@ export function extend(publicAPI, model, initialValues = {}) { // Object methods macro.obj(publicAPI, model); - macro.setGet(publicAPI, model, ['piecewiseSize', 'numberOfBins', 'colorTransferFunction', 'backgroundImage']); + macro.setGet(publicAPI, model, [ + 'piecewiseSize', + 'numberOfBins', + 'colorTransferFunction', + 'backgroundImage', + ]); macro.get(publicAPI, model, ['size', 'canvas']); macro.event(publicAPI, model, 'opacityChange'); macro.event(publicAPI, model, 'animation'); @@ -805,7 +992,10 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkPiecewiseGaussianWidget'); +export const newInstance = macro.newInstance( + extend, + 'vtkPiecewiseGaussianWidget' +); // ---------------------------------------------------------------------------- diff --git a/Sources/Interaction/Widgets/PointPlacer/index.js b/Sources/Interaction/Widgets/PointPlacer/index.js index 4156939a6b9..ab0afbe352e 100644 --- a/Sources/Interaction/Widgets/PointPlacer/index.js +++ b/Sources/Interaction/Widgets/PointPlacer/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkCoordinate from 'vtk.js/Sources/Rendering/Core/Coordinate'; // ---------------------------------------------------------------------------- diff --git a/Sources/Interaction/Widgets/SphereHandleRepresentation/index.js b/Sources/Interaction/Widgets/SphereHandleRepresentation/index.js index 4e8e21ac3cd..4098b1d3668 100644 --- a/Sources/Interaction/Widgets/SphereHandleRepresentation/index.js +++ b/Sources/Interaction/Widgets/SphereHandleRepresentation/index.js @@ -1,13 +1,13 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkCellPicker from 'vtk.js/Sources/Rendering/Core/CellPicker'; +import macro from 'vtk.js/Sources/macro'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkCellPicker from 'vtk.js/Sources/Rendering/Core/CellPicker'; import vtkHandleRepresentation from 'vtk.js/Sources/Interaction/Widgets/HandleRepresentation'; -import vtkInteractorObserver from 'vtk.js/Sources/Rendering/Core/InteractorObserver'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; -import vtkProperty from 'vtk.js/Sources/Rendering/Core/Property'; -import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; -import { InteractionState } from '../HandleRepresentation/Constants'; +import vtkInteractorObserver from 'vtk.js/Sources/Rendering/Core/InteractorObserver'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkProperty from 'vtk.js/Sources/Rendering/Core/Property'; +import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; +import { InteractionState } from '../HandleRepresentation/Constants'; // ---------------------------------------------------------------------------- // vtkSphereHandleRepresentation methods @@ -45,9 +45,10 @@ function vtkSphereHandleRepresentation(publicAPI, model) { model.initialBounds[i] = newBounds[i]; } model.initialLength = Math.sqrt( - ((newBounds[1] - newBounds[0]) * (newBounds[1] - newBounds[0])) + - ((newBounds[3] - newBounds[2]) * (newBounds[3] - newBounds[2])) + - ((newBounds[5] - newBounds[4]) * (newBounds[5] - newBounds[4]))); + (newBounds[1] - newBounds[0]) * (newBounds[1] - newBounds[0]) + + (newBounds[3] - newBounds[2]) * (newBounds[3] - newBounds[2]) + + (newBounds[5] - newBounds[4]) * (newBounds[5] - newBounds[4]) + ); }; publicAPI.setSphereRadius = (radius) => { @@ -112,9 +113,12 @@ function vtkSphereHandleRepresentation(publicAPI, model) { // outside the hot spot if (!model.waitingForMotion) { const pickedPosition = model.cursorPicker.getPickPosition(); - const d2 = vtkMath.distance2BetweenPoints(pickedPosition, model.startEventPosition); + const d2 = vtkMath.distance2BetweenPoints( + pickedPosition, + model.startEventPosition + ); const tol = model.hotSpotSize * model.initialLength; - if (d2 > (tol * tol)) { + if (d2 > tol * tol) { model.waitingForMotion = 0; return model.cursorPicker.getCellId(); } @@ -127,7 +131,7 @@ function vtkSphereHandleRepresentation(publicAPI, model) { v[0] = Math.abs(x[0] - model.startEventPosition[0]); v[1] = Math.abs(x[1] - model.startEventPosition[1]); v[2] = Math.abs(x[2] - model.startEventPosition[2]); - return (v[0] > v[1] ? (v[0] > v[2] ? 0 : 2) : (v[1] > v[2] ? 1 : 2)); + return v[0] > v[1] ? (v[0] > v[2] ? 0 : 2) : v[1] > v[2] ? 1 : 2; } return -1; }; @@ -154,22 +158,43 @@ function vtkSphereHandleRepresentation(publicAPI, model) { } }; - publicAPI.displayToWorld = (eventPos, z) => vtkInteractorObserver.computeDisplayToWorld(model.renderer, - eventPos[0], eventPos[1], z); + publicAPI.displayToWorld = (eventPos, z) => + vtkInteractorObserver.computeDisplayToWorld( + model.renderer, + eventPos[0], + eventPos[1], + z + ); publicAPI.complexWidgetInteraction = (eventPos) => { - const focalPoint = vtkInteractorObserver.computeDisplayToWorld(model.renderer, - model.lastPickPosition[0], model.lastPickPosition[1], model.lastPickPosition[2]); + const focalPoint = vtkInteractorObserver.computeDisplayToWorld( + model.renderer, + model.lastPickPosition[0], + model.lastPickPosition[1], + model.lastPickPosition[2] + ); const z = focalPoint[2]; - const prevPickPoint = vtkInteractorObserver.computeDisplayToWorld(model.renderer, - model.lastEventPosition[0], model.lastEventPosition[1], z); + const prevPickPoint = vtkInteractorObserver.computeDisplayToWorld( + model.renderer, + model.lastEventPosition[0], + model.lastEventPosition[1], + z + ); const pickPoint = publicAPI.displayToWorld(eventPos, z); - if (model.interactionState === InteractionState.SELECTING || - model.interactionState === InteractionState.TRANSLATING) { + if ( + model.interactionState === InteractionState.SELECTING || + model.interactionState === InteractionState.TRANSLATING + ) { if (!model.waitingForMotion || model.waitCount++ > 3) { - model.constraintAxis = publicAPI.determineConstraintAxis(model.constraintAxis, pickPoint); - if (model.interactionState === InteractionState.SELECTING && !model.translationMode) { + model.constraintAxis = publicAPI.determineConstraintAxis( + model.constraintAxis, + pickPoint + ); + if ( + model.interactionState === InteractionState.SELECTING && + !model.translationMode + ) { publicAPI.moveFocus(prevPickPoint, pickPoint); } else { publicAPI.translate(prevPickPoint, pickPoint); @@ -248,10 +273,13 @@ function vtkSphereHandleRepresentation(publicAPI, model) { const bounds = publicAPI.getBounds(); // Compute the scale factor - let sf = vtkMath.norm(v) / - Math.sqrt(((bounds[1] - bounds[0]) * (bounds[1] - bounds[0])) + - ((bounds[3] - bounds[2]) * (bounds[3] - bounds[2])) + - ((bounds[5] - bounds[4]) * (bounds[5] - bounds[4]))); + let sf = + vtkMath.norm(v) / + Math.sqrt( + (bounds[1] - bounds[0]) * (bounds[1] - bounds[0]) + + (bounds[3] - bounds[2]) * (bounds[3] - bounds[2]) + + (bounds[5] - bounds[4]) * (bounds[5] - bounds[4]) + ); if (eventPos[1] > model.lastEventPosition[1]) { sf += 1.0; @@ -260,7 +288,8 @@ function vtkSphereHandleRepresentation(publicAPI, model) { } model.currentHandleSize *= sf; - model.currentHandleSize = (model.currentHandleSize < 0.001 ? 0.001 : model.currentHandleSize); + model.currentHandleSize = + model.currentHandleSize < 0.001 ? 0.001 : model.currentHandleSize; publicAPI.sizeBounds(); }; @@ -349,7 +378,10 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkSphereHandleRepresentation'); +export const newInstance = macro.newInstance( + extend, + 'vtkSphereHandleRepresentation' +); // ---------------------------------------------------------------------------- diff --git a/Sources/Interaction/Widgets/WidgetRepresentation/index.js b/Sources/Interaction/Widgets/WidgetRepresentation/index.js index 6ebf71b74a0..c1823a0fd4b 100644 --- a/Sources/Interaction/Widgets/WidgetRepresentation/index.js +++ b/Sources/Interaction/Widgets/WidgetRepresentation/index.js @@ -1,6 +1,6 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkInteractorObserver from 'vtk.js/Sources/Rendering/Core/InteractorObserver'; -import vtkProp from 'vtk.js/Sources/Rendering/Core/Prop'; +import vtkProp from 'vtk.js/Sources/Rendering/Core/Prop'; const { vtkErrorMacro } = macro; @@ -19,7 +19,9 @@ function vtkWidgetRepresentation(publicAPI, model) { publicAPI.adjustBounds = (bounds, newBounds, center) => { if (bounds.length !== 6) { - vtkErrorMacro("vtkWidgetRepresentation::adjustBounds Can't process bounds, not enough values..."); + vtkErrorMacro( + "vtkWidgetRepresentation::adjustBounds Can't process bounds, not enough values..." + ); return; } @@ -27,64 +29,96 @@ function vtkWidgetRepresentation(publicAPI, model) { center[1] = (bounds[2] + bounds[3]) / 2.0; center[2] = (bounds[4] + bounds[5]) / 2.0; - newBounds[0] = center[0] + (model.placeFactor * (bounds[0] - center[0])); - newBounds[1] = center[0] + (model.placeFactor * (bounds[1] - center[0])); - newBounds[2] = center[1] + (model.placeFactor * (bounds[2] - center[1])); - newBounds[3] = center[1] + (model.placeFactor * (bounds[3] - center[1])); - newBounds[4] = center[2] + (model.placeFactor * (bounds[4] - center[2])); - newBounds[5] = center[2] + (model.placeFactor * (bounds[5] - center[2])); + newBounds[0] = center[0] + model.placeFactor * (bounds[0] - center[0]); + newBounds[1] = center[0] + model.placeFactor * (bounds[1] - center[0]); + newBounds[2] = center[1] + model.placeFactor * (bounds[2] - center[1]); + newBounds[3] = center[1] + model.placeFactor * (bounds[3] - center[1]); + newBounds[4] = center[2] + model.placeFactor * (bounds[4] - center[2]); + newBounds[5] = center[2] + model.placeFactor * (bounds[5] - center[2]); }; publicAPI.sizeHandlesInPixels = (factor, pos) => { const renderer = model.renderer; if (!model.validPick || !renderer || !renderer.getActiveCamera()) { - return (model.handleSize * factor * model.initialLength); + return model.handleSize * factor * model.initialLength; } - const focalPoint = vtkInteractorObserver.computeWorldToDisplay(renderer, pos[0], pos[1], pos[2]); + const focalPoint = vtkInteractorObserver.computeWorldToDisplay( + renderer, + pos[0], + pos[1], + pos[2] + ); const z = focalPoint[2]; - let x = focalPoint[0] - (model.handleSize / 2.0); - let y = focalPoint[1] - (model.handleSize / 2.0); - const lowerLeft = vtkInteractorObserver.computeDisplayToWorld(renderer, x, y, z); - - x = focalPoint[0] + (model.handleSize / 2.0); - y = focalPoint[1] + (model.handleSize / 2.0); - const upperRight = vtkInteractorObserver.computeDisplayToWorld(renderer, x, y, z); + let x = focalPoint[0] - model.handleSize / 2.0; + let y = focalPoint[1] - model.handleSize / 2.0; + const lowerLeft = vtkInteractorObserver.computeDisplayToWorld( + renderer, + x, + y, + z + ); + + x = focalPoint[0] + model.handleSize / 2.0; + y = focalPoint[1] + model.handleSize / 2.0; + const upperRight = vtkInteractorObserver.computeDisplayToWorld( + renderer, + x, + y, + z + ); let radius = 0.0; for (let i = 0; i < 3; i++) { radius += (upperRight[i] - lowerLeft[i]) * (upperRight[i] - lowerLeft[i]); } - return (factor * (Math.sqrt(radius) / 2.0)); + return factor * (Math.sqrt(radius) / 2.0); }; publicAPI.sizeHandlesRelativeToViewport = (factor, pos) => { const renderer = model.renderer; if (!model.validPick || !renderer || !renderer.getActiveCamera()) { - return (model.handleSize * factor * model.initialLength); + return model.handleSize * factor * model.initialLength; } const viewport = renderer.getViewport(); const view = renderer.getRenderWindow().getViews()[0]; const winSize = view.getViewportSize(renderer); - const focalPoint = vtkInteractorObserver.computeWorldToDisplay(renderer, pos[0], pos[1], pos[2]); + const focalPoint = vtkInteractorObserver.computeWorldToDisplay( + renderer, + pos[0], + pos[1], + pos[2] + ); const z = focalPoint[2]; let x = winSize[0] * viewport[0]; let y = winSize[1] * viewport[1]; - const windowLowerLeft = vtkInteractorObserver.computeDisplayToWorld(renderer, x, y, z); + const windowLowerLeft = vtkInteractorObserver.computeDisplayToWorld( + renderer, + x, + y, + z + ); x = winSize[0] * viewport[2]; y = winSize[1] * viewport[3]; - const windowUpperRight = vtkInteractorObserver.computeDisplayToWorld(renderer, x, y, z); + const windowUpperRight = vtkInteractorObserver.computeDisplayToWorld( + renderer, + x, + y, + z + ); let radius = 0.0; for (let i = 0; i < 3; i++) { - radius += (windowUpperRight[i] - windowLowerLeft[i]) * (windowUpperRight[i] - windowLowerLeft[i]); + radius += + (windowUpperRight[i] - windowLowerLeft[i]) * + (windowUpperRight[i] - windowLowerLeft[i]); } - return (factor * (Math.sqrt(radius) / 2.0)); + return factor * (Math.sqrt(radius) / 2.0); }; } diff --git a/Sources/Interaction/index.js b/Sources/Interaction/index.js index b52b4db2bf3..09db4280a08 100644 --- a/Sources/Interaction/index.js +++ b/Sources/Interaction/index.js @@ -1,8 +1,8 @@ import Manipulators from './Manipulators'; -import Misc from './Misc'; -import Style from './Style'; -import UI from './UI'; -import Widgets from './Widgets'; +import Misc from './Misc'; +import Style from './Style'; +import UI from './UI'; +import Widgets from './Widgets'; export default { Manipulators, diff --git a/Sources/Rendering/Core/AbstractMapper/index.js b/Sources/Rendering/Core/AbstractMapper/index.js index 47eafe4641b..a33c9c6e850 100644 --- a/Sources/Rendering/Core/AbstractMapper/index.js +++ b/Sources/Rendering/Core/AbstractMapper/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; // ---------------------------------------------------------------------------- // vtkAbstractMapper methods diff --git a/Sources/Rendering/Core/AbstractMapper/test/testAbstractMapper.js b/Sources/Rendering/Core/AbstractMapper/test/testAbstractMapper.js index 4ec42039114..5647b70accf 100644 --- a/Sources/Rendering/Core/AbstractMapper/test/testAbstractMapper.js +++ b/Sources/Rendering/Core/AbstractMapper/test/testAbstractMapper.js @@ -1,7 +1,7 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkPlane from 'vtk.js/Sources/Common/DataModel/Plane'; +import vtkPlane from 'vtk.js/Sources/Common/DataModel/Plane'; test('Test vtkAbstractMapper publicAPI', (t) => { const mapper = vtkMapper.newInstance(); diff --git a/Sources/Rendering/Core/AbstractMapper3D/index.js b/Sources/Rendering/Core/AbstractMapper3D/index.js index b5ae7912be6..44105a2600d 100644 --- a/Sources/Rendering/Core/AbstractMapper3D/index.js +++ b/Sources/Rendering/Core/AbstractMapper3D/index.js @@ -1,7 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkAbstractMapper from 'vtk.js/Sources/Rendering/Core/AbstractMapper'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; // ---------------------------------------------------------------------------- // vtkAbstractMapper methods // ---------------------------------------------------------------------------- @@ -19,7 +19,7 @@ function vtkAbstractMapper3D(publicAPI, model) { publicAPI.getCenter = (...center) => { publicAPI.getBounds(); for (let i = 0; i < 3; i++) { - model.center[i] = (model.bounds[(2 * i) + 1] + model.bounds[2 * i]) / 2.0; + model.center[i] = (model.bounds[2 * i + 1] + model.bounds[2 * i]) / 2.0; } if (Array.isArray(center[0])) { center[0] = model.center.splice(0); @@ -32,7 +32,7 @@ function vtkAbstractMapper3D(publicAPI, model) { let l = 0.0; publicAPI.getBounds(); for (let i = 0; i < 3; i++) { - diff = model.bounds[(2 * i) + 1] - model.bounds[2 * i]; + diff = model.bounds[2 * i + 1] - model.bounds[2 * i]; l += diff * diff; } @@ -55,13 +55,13 @@ function vtkAbstractMapper3D(publicAPI, model) { const v1 = normal[0]; const v2 = normal[1]; const v3 = normal[2]; - const v4 = -((v1 * origin[0]) + (v2 * origin[1]) + (v3 * origin[2])); + const v4 = -(v1 * origin[0] + v2 * origin[1] + v3 * origin[2]); // Transform normal from world to data coords - hnormal[0] = (v1 * mat[0]) + (v2 * mat[4]) + (v3 * mat[8]) + (v4 * mat[12]); - hnormal[1] = (v1 * mat[1]) + (v2 * mat[5]) + (v3 * mat[9]) + (v4 * mat[13]); - hnormal[2] = (v1 * mat[2]) + (v2 * mat[6]) + (v3 * mat[10]) + (v4 * mat[14]); - hnormal[3] = (v1 * mat[3]) + (v2 * mat[7]) + (v3 * mat[11]) + (v4 * mat[15]); + hnormal[0] = v1 * mat[0] + v2 * mat[4] + v3 * mat[8] + v4 * mat[12]; + hnormal[1] = v1 * mat[1] + v2 * mat[5] + v3 * mat[9] + v4 * mat[13]; + hnormal[2] = v1 * mat[2] + v2 * mat[6] + v3 * mat[10] + v4 * mat[14]; + hnormal[3] = v1 * mat[3] + v2 * mat[7] + v3 * mat[11] + v4 * mat[15]; return; } diff --git a/Sources/Rendering/Core/AbstractPicker/index.js b/Sources/Rendering/Core/AbstractPicker/index.js index e37c5312570..4013ce61c5b 100644 --- a/Sources/Rendering/Core/AbstractPicker/index.js +++ b/Sources/Rendering/Core/AbstractPicker/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; // ---------------------------------------------------------------------------- // vtkAbstractPicker methods diff --git a/Sources/Rendering/Core/Actor/example_/index.js b/Sources/Rendering/Core/Actor/example_/index.js index fa20030e7cf..066d65a0b55 100644 --- a/Sources/Rendering/Core/Actor/example_/index.js +++ b/Sources/Rendering/Core/Actor/example_/index.js @@ -7,10 +7,10 @@ const test = (condition, message) => { vtkErrorMacro(`ERROR: ${message}`); } }; -const zip = rows => rows[0].map((_, c) => rows.map(row => row[c])); +const zip = (rows) => rows[0].map((_, c) => rows.map((row) => row[c])); const arraysEqual = (aa, bb) => aa.length === bb.length && - zip([aa, bb]).reduce((a, b) => (a && b[0] === b[1]), true); + zip([aa, bb]).reduce((a, b) => a && b[0] === b[1], true); // Create actor instance const actor = Actor.newInstance(); @@ -24,7 +24,8 @@ test(actor.getMapper() === null, 'Actor should not have a default mapper.'); test(actor.getVisibility(), 'Actor should be visible by default.'); test( arraysEqual(actor.getBounds(), [1, -1, 1, -1, 1, -1]), - 'Actor bounds should be invalid when there is no mapper.'); + 'Actor bounds should be invalid when there is no mapper.' +); actor.setVisibility(!actor.getVisibility()); vtkDebugMacro(`visibility ${actor.getVisibility()}`); diff --git a/Sources/Rendering/Core/Actor/index.js b/Sources/Rendering/Core/Actor/index.js index 568f0c42141..cf4a8c709fc 100644 --- a/Sources/Rendering/Core/Actor/index.js +++ b/Sources/Rendering/Core/Actor/index.js @@ -1,7 +1,7 @@ import { vec3, mat4 } from 'gl-matrix'; -import macro from 'vtk.js/Sources/macro'; -import vtkProp3D from 'vtk.js/Sources/Rendering/Core/Prop3D'; -import vtkProperty from 'vtk.js/Sources/Rendering/Core/Property'; +import macro from 'vtk.js/Sources/macro'; +import vtkProp3D from 'vtk.js/Sources/Rendering/Core/Prop3D'; +import vtkProperty from 'vtk.js/Sources/Rendering/Core/Property'; const { vtkDebugMacro } = macro; @@ -31,7 +31,7 @@ function vtkActor(publicAPI, model) { publicAPI.getProperty(); } - let isOpaque = (model.property.getOpacity() >= 1.0); + let isOpaque = model.property.getOpacity() >= 1.0; // are we using an opaque texture, if any? isOpaque = isOpaque && (!model.texture || !model.texture.isTranslucent()); @@ -89,14 +89,16 @@ function vtkActor(publicAPI, model) { // of caching. If the values returned this time are different, or // the modified time of this class is newer than the cached time, // then we need to rebuild. - if (!model.mapperBounds - || bds[0] !== model.mapperBounds[0] - || bds[1] !== model.mapperBounds[1] - || bds[2] !== model.mapperBounds[2] - || bds[3] !== model.mapperBounds[3] - || bds[4] !== model.mapperBounds[4] - || bds[5] !== model.mapperBounds[5] - || publicAPI.getMTime() > model.boundsMTime.getMTime()) { + if ( + !model.mapperBounds || + bds[0] !== model.mapperBounds[0] || + bds[1] !== model.mapperBounds[1] || + bds[2] !== model.mapperBounds[2] || + bds[3] !== model.mapperBounds[3] || + bds[4] !== model.mapperBounds[4] || + bds[5] !== model.mapperBounds[5] || + publicAPI.getMTime() > model.boundsMTime.getMTime() + ) { vtkDebugMacro('Recomputing bounds...'); model.mapperBounds = bds.concat(); // copy the mapper's bounds const bbox = [ @@ -113,16 +115,22 @@ function vtkActor(publicAPI, model) { publicAPI.computeMatrix(); const tmp4 = mat4.create(); mat4.transpose(tmp4, model.matrix); - bbox.forEach(pt => vec3.transformMat4(pt, pt, tmp4)); + bbox.forEach((pt) => vec3.transformMat4(pt, pt, tmp4)); /* eslint-disable no-multi-assign */ model.bounds[0] = model.bounds[2] = model.bounds[4] = Number.MAX_VALUE; model.bounds[1] = model.bounds[3] = model.bounds[5] = -Number.MAX_VALUE; /* eslint-enable no-multi-assign */ - model.bounds = model.bounds.map((d, i) => ((i % 2 === 0) ? - bbox.reduce((a, b) => (a > b[i / 2] ? b[i / 2] : a), d) : - bbox.reduce((a, b) => (a < b[(i - 1) / 2] ? b[(i - 1) / 2] : a), d))); + model.bounds = model.bounds.map( + (d, i) => + i % 2 === 0 + ? bbox.reduce((a, b) => (a > b[i / 2] ? b[i / 2] : a), d) + : bbox.reduce( + (a, b) => (a < b[(i - 1) / 2] ? b[(i - 1) / 2] : a), + d + ) + ); model.boundsMTime.modified(); } @@ -133,12 +141,12 @@ function vtkActor(publicAPI, model) { let mt = superClass.getMTime(); if (model.property !== null) { const time = model.property.getMTime(); - mt = (time > mt ? time : mt); + mt = time > mt ? time : mt; } if (model.backfaceProperty !== null) { const time = model.backfaceProperty.getMTime(); - mt = (time > mt ? time : mt); + mt = time > mt ? time : mt; } return mt; @@ -148,18 +156,19 @@ function vtkActor(publicAPI, model) { let mt = model.mtime; if (model.mapper !== null) { let time = model.mapper.getMTime(); - mt = (time > mt ? time : mt); + mt = time > mt ? time : mt; if (model.mapper.getInput() !== null) { // FIXME !!! getInputAlgorithm / getInput model.mapper.getInputAlgorithm().update(); time = model.mapper.getInput().getMTime(); - mt = (time > mt ? time : mt); + mt = time > mt ? time : mt; } } return mt; }; - publicAPI.getSupportsSelection = () => (model.mapper ? model.mapper.getSupportsSelection() : false); + publicAPI.getSupportsSelection = () => + model.mapper ? model.mapper.getSupportsSelection() : false; } // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/Core/Actor2D/index.js b/Sources/Rendering/Core/Actor2D/index.js index 567b55a831a..607fb32980b 100644 --- a/Sources/Rendering/Core/Actor2D/index.js +++ b/Sources/Rendering/Core/Actor2D/index.js @@ -1,7 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkCoordinate from 'vtk.js/Sources/Rendering/Core/Coordinate'; -import vtkProp from 'vtk.js/Sources/Rendering/Core/Prop'; -import vtkProperty2D from 'vtk.js/Sources/Rendering/Core/Property2D'; +import macro from 'vtk.js/Sources/macro'; +import vtkCoordinate from 'vtk.js/Sources/Rendering/Core/Coordinate'; +import vtkProp from 'vtk.js/Sources/Rendering/Core/Prop'; +import vtkProperty2D from 'vtk.js/Sources/Rendering/Core/Property2D'; import { Coordinate } from 'vtk.js/Sources/Rendering/Core/Coordinate/Constants'; // ---------------------------------------------------------------------------- @@ -21,7 +21,7 @@ function vtkActor2D(publicAPI, model) { publicAPI.getProperty(); } - let isOpaque = (model.property.getOpacity() >= 1.0); + let isOpaque = model.property.getOpacity() >= 1.0; // are we using an opaque texture, if any? isOpaque = isOpaque && (!model.texture || !model.texture.isTranslucent()); @@ -86,13 +86,17 @@ function vtkActor2D(publicAPI, model) { let mt = model.mtime; if (model.property !== null) { const time = model.property.getMTime(); - mt = (time > mt ? time : mt); + mt = time > mt ? time : mt; } - mt = (model.positionCoordinate.getMTime() > mt ? - model.positionCoordinate.getMTime() : mt); - mt = (model.positionCoordinate2.getMTime() > mt ? - model.positionCoordinate2.getMTime() : mt); + mt = + model.positionCoordinate.getMTime() > mt + ? model.positionCoordinate.getMTime() + : mt; + mt = + model.positionCoordinate2.getMTime() > mt + ? model.positionCoordinate2.getMTime() + : mt; // TBD: Handle array of textures here. @@ -103,12 +107,12 @@ function vtkActor2D(publicAPI, model) { let mt = model.mtime; if (model.mapper !== null) { let time = model.mapper.getMTime(); - mt = (time > mt ? time : mt); + mt = time > mt ? time : mt; if (model.mapper.getInput() !== null) { // FIXME !!! getInputAlgorithm / getInput model.mapper.getInputAlgorithm().update(); time = model.mapper.getInput().getMTime(); - mt = (time > mt ? time : mt); + mt = time > mt ? time : mt; } } return mt; @@ -161,9 +165,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.set(publicAPI, model, ['property']); - macro.setGet(publicAPI, model, [ - 'mapper', - ]); + macro.setGet(publicAPI, model, ['mapper']); // Object methods vtkActor2D(publicAPI, model); diff --git a/Sources/Rendering/Core/AnnotatedCubeActor/index.js b/Sources/Rendering/Core/AnnotatedCubeActor/index.js index 763684e3648..63f51d345bb 100644 --- a/Sources/Rendering/Core/AnnotatedCubeActor/index.js +++ b/Sources/Rendering/Core/AnnotatedCubeActor/index.js @@ -1,9 +1,9 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkTexture from 'vtk.js/Sources/Rendering/Core/Texture'; -import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; -import ImageHelper from 'vtk.js/Sources/Common/Core/ImageHelper'; +import macro from 'vtk.js/Sources/macro'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkTexture from 'vtk.js/Sources/Rendering/Core/Texture'; +import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; +import ImageHelper from 'vtk.js/Sources/Common/Core/ImageHelper'; const FACE_TO_INDEX = { xPlus: 0, @@ -46,7 +46,11 @@ function vtkAnnotatedCubeActor(publicAPI, model) { Object.assign(model[`${faceName}FaceProperty`], newProp); } - const prop = Object.assign({}, model.defaultStyle, model[`${faceName}FaceProperty`]); + const prop = Object.assign( + {}, + model.defaultStyle, + model[`${faceName}FaceProperty`] + ); // set canvas resolution canvas.width = prop.resolution; @@ -99,12 +103,12 @@ function vtkAnnotatedCubeActor(publicAPI, model) { updateAllFaceTextures(); }; - publicAPI.setXPlusFaceProperty = prop => updateFaceTexture('xPlus', prop); - publicAPI.setXMinusFaceProperty = prop => updateFaceTexture('xMinus', prop); - publicAPI.setYPlusFaceProperty = prop => updateFaceTexture('yPlus', prop); - publicAPI.setYMinusFaceProperty = prop => updateFaceTexture('yMinus', prop); - publicAPI.setZPlusFaceProperty = prop => updateFaceTexture('zPlus', prop); - publicAPI.setZMinusFaceProperty = prop => updateFaceTexture('zMinus', prop); + publicAPI.setXPlusFaceProperty = (prop) => updateFaceTexture('xPlus', prop); + publicAPI.setXMinusFaceProperty = (prop) => updateFaceTexture('xMinus', prop); + publicAPI.setYPlusFaceProperty = (prop) => updateFaceTexture('yPlus', prop); + publicAPI.setYMinusFaceProperty = (prop) => updateFaceTexture('yMinus', prop); + publicAPI.setZPlusFaceProperty = (prop) => updateFaceTexture('zPlus', prop); + publicAPI.setZMinusFaceProperty = (prop) => updateFaceTexture('zMinus', prop); // constructor @@ -129,7 +133,7 @@ export const DEFAULT_VALUES = { fontFamily: 'Arial', fontColor: 'black', fontStyle: 'normal', - fontSizeScale: resolution => resolution / 1.8, + fontSizeScale: (resolution) => resolution / 1.8, edgeThickness: 0.1, edgeColor: 'black', resolution: 200, diff --git a/Sources/Rendering/Core/Camera/index.js b/Sources/Rendering/Core/Camera/index.js index 5181289e569..45e196648a2 100644 --- a/Sources/Rendering/Core/Camera/index.js +++ b/Sources/Rendering/Core/Camera/index.js @@ -1,6 +1,6 @@ import { quat, vec3, vec4, mat3, mat4 } from 'gl-matrix'; -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkMath from 'vtk.js/Sources/Common/Core/Math'; const { vtkDebugMacro } = macro; @@ -46,9 +46,11 @@ function vtkCamera(publicAPI, model) { }; publicAPI.setPosition = (x, y, z) => { - if (x === model.position[0] && - y === model.position[1] && - z === model.position[2]) { + if ( + x === model.position[0] && + y === model.position[1] && + z === model.position[2] + ) { return; } @@ -63,9 +65,11 @@ function vtkCamera(publicAPI, model) { }; publicAPI.setFocalPoint = (x, y, z) => { - if (x === model.focalPoint[0] && - y === model.focalPoint[1] && - z === model.focalPoint[2]) { + if ( + x === model.focalPoint[0] && + y === model.focalPoint[1] && + z === model.focalPoint[2] + ) { return; } @@ -95,9 +99,9 @@ function vtkCamera(publicAPI, model) { const vec = model.directionOfProjection; // recalculate FocalPoint - model.focalPoint[0] = model.position[0] + (vec[0] * model.distance); - model.focalPoint[1] = model.position[1] + (vec[1] * model.distance); - model.focalPoint[2] = model.position[2] + (vec[2] * model.distance); + model.focalPoint[0] = model.position[0] + vec[0] * model.distance; + model.focalPoint[1] = model.position[1] + vec[1] * model.distance; + model.focalPoint[2] = model.position[2] + vec[2] * model.distance; publicAPI.modified(); }; @@ -109,7 +113,7 @@ function vtkCamera(publicAPI, model) { const dy = model.focalPoint[1] - model.position[1]; const dz = model.focalPoint[2] - model.position[2]; - model.distance = Math.sqrt((dx * dx) + (dy * dy) + (dz * dz)); + model.distance = Math.sqrt(dx * dx + dy * dy + dz * dz); if (model.distance < 1e-20) { model.distance = 1e-20; @@ -118,9 +122,9 @@ function vtkCamera(publicAPI, model) { const vec = model.directionOfProjection; // recalculate FocalPoint - model.focalPoint[0] = model.position[0] + (vec[0] * model.distance); - model.focalPoint[1] = model.position[1] + (vec[1] * model.distance); - model.focalPoint[2] = model.position[2] + (vec[2] * model.distance); + model.focalPoint[0] = model.position[0] + vec[0] * model.distance; + model.focalPoint[1] = model.position[1] + vec[1] * model.distance; + model.focalPoint[2] = model.position[2] + vec[2] * model.distance; } model.directionOfProjection[0] = dx / model.distance; @@ -151,18 +155,15 @@ function vtkCamera(publicAPI, model) { const d = model.distance / amount; publicAPI.setPosition( - model.focalPoint[0] - (d * model.directionOfProjection[0]), - model.focalPoint[1] - (d * model.directionOfProjection[1]), - model.focalPoint[2] - (d * model.directionOfProjection[2])); + model.focalPoint[0] - d * model.directionOfProjection[0], + model.focalPoint[1] - d * model.directionOfProjection[1], + model.focalPoint[2] - d * model.directionOfProjection[2] + ); }; - publicAPI.setRoll = (roll) => { + publicAPI.setRoll = (roll) => {}; - }; - - publicAPI.getRoll = () => { - - }; + publicAPI.getRoll = () => {}; publicAPI.roll = (angle) => { const eye = model.position; @@ -170,9 +171,18 @@ function vtkCamera(publicAPI, model) { const up = model.viewUp; const viewUpVec4 = vec4.fromValues(up[0], up[1], up[2], 0.0); - const rotateMatrix = mat4.create(); // FIXME: don't create a new one each time? - const viewDir = vec3.fromValues((at[0] - eye[0]), (at[1] - eye[1]), (at[2] - eye[2])); - mat4.rotate(rotateMatrix, rotateMatrix, vtkMath.radiansFromDegrees(angle), viewDir); + const rotateMatrix = mat4.create(); // FIXME: don't create a new one each time? + const viewDir = vec3.fromValues( + at[0] - eye[0], + at[1] - eye[1], + at[2] - eye[2] + ); + mat4.rotate( + rotateMatrix, + rotateMatrix, + vtkMath.radiansFromDegrees(angle), + viewDir + ); vec4.transformMat4(viewUpVec4, viewUpVec4, rotateMatrix); model.viewUp[0] = viewUpVec4[0]; @@ -193,11 +203,20 @@ function vtkCamera(publicAPI, model) { // rotate about view up, // translate back again mat4.translate(trans, trans, vec3.fromValues(fp[0], fp[1], fp[2])); - mat4.rotate(trans, trans, vtkMath.radiansFromDegrees(angle), vec3.fromValues(model.viewUp[0], model.viewUp[1], model.viewUp[2])); + mat4.rotate( + trans, + trans, + vtkMath.radiansFromDegrees(angle), + vec3.fromValues(model.viewUp[0], model.viewUp[1], model.viewUp[2]) + ); mat4.translate(trans, trans, vec3.fromValues(-fp[0], -fp[1], -fp[2])); // apply the transform to the position - vec3.transformMat4(newPosition, vec3.fromValues(model.position[0], model.position[1], model.position[2]), trans); + vec3.transformMat4( + newPosition, + vec3.fromValues(model.position[0], model.position[1], model.position[2]), + trans + ); publicAPI.setPosition(newPosition[0], newPosition[1], newPosition[2]); }; @@ -211,13 +230,38 @@ function vtkCamera(publicAPI, model) { // translate the camera to the origin, // rotate about axis, // translate back again - mat4.translate(trans, trans, vec3.fromValues(position[0], position[1], position[2])); - mat4.rotate(trans, trans, vtkMath.radiansFromDegrees(angle), vec3.fromValues(model.viewUp[0], model.viewUp[1], model.viewUp[2])); - mat4.translate(trans, trans, vec3.fromValues(-position[0], -position[1], -position[2])); + mat4.translate( + trans, + trans, + vec3.fromValues(position[0], position[1], position[2]) + ); + mat4.rotate( + trans, + trans, + vtkMath.radiansFromDegrees(angle), + vec3.fromValues(model.viewUp[0], model.viewUp[1], model.viewUp[2]) + ); + mat4.translate( + trans, + trans, + vec3.fromValues(-position[0], -position[1], -position[2]) + ); // apply the transform to the position - vec3.transformMat4(newFocalPoint, vec3.fromValues(model.focalPoint[0], model.focalPoint[1], model.focalPoint[2]), trans); - publicAPI.setFocalPoint(newFocalPoint[0], newFocalPoint[1], newFocalPoint[2]); + vec3.transformMat4( + newFocalPoint, + vec3.fromValues( + model.focalPoint[0], + model.focalPoint[1], + model.focalPoint[2] + ), + trans + ); + publicAPI.setFocalPoint( + newFocalPoint[0], + newFocalPoint[1], + newFocalPoint[2] + ); }; publicAPI.elevation = (angle) => { @@ -234,11 +278,20 @@ function vtkCamera(publicAPI, model) { // rotate about view up, // translate back again mat4.translate(trans, trans, vec3.fromValues(fp[0], fp[1], fp[2])); - mat4.rotate(trans, trans, vtkMath.radiansFromDegrees(angle), vec3.fromValues(axis[0], axis[1], axis[2])); + mat4.rotate( + trans, + trans, + vtkMath.radiansFromDegrees(angle), + vec3.fromValues(axis[0], axis[1], axis[2]) + ); mat4.translate(trans, trans, vec3.fromValues(-fp[0], -fp[1], -fp[2])); // apply the transform to the position - vec3.transformMat4(newPosition, vec3.fromValues(model.position[0], model.position[1], model.position[2]), trans); + vec3.transformMat4( + newPosition, + vec3.fromValues(model.position[0], model.position[1], model.position[2]), + trans + ); publicAPI.setPosition(newPosition[0], newPosition[1], newPosition[2]); }; @@ -255,13 +308,38 @@ function vtkCamera(publicAPI, model) { // translate the camera to the origin, // rotate about axis, // translate back again - mat4.translate(trans, trans, vec3.fromValues(position[0], position[1], position[2])); - mat4.rotate(trans, trans, vtkMath.radiansFromDegrees(angle), vec3.fromValues(axis[0], axis[1], axis[2])); - mat4.translate(trans, trans, vec3.fromValues(-position[0], -position[1], -position[2])); + mat4.translate( + trans, + trans, + vec3.fromValues(position[0], position[1], position[2]) + ); + mat4.rotate( + trans, + trans, + vtkMath.radiansFromDegrees(angle), + vec3.fromValues(axis[0], axis[1], axis[2]) + ); + mat4.translate( + trans, + trans, + vec3.fromValues(-position[0], -position[1], -position[2]) + ); // apply the transform to the position - vec3.transformMat4(newFocalPoint, vec3.fromValues(model.focalPoint[0], model.focalPoint[1], model.focalPoint[2]), trans); - publicAPI.setFocalPoint(newFocalPoint[0], newFocalPoint[1], newFocalPoint[2]); + vec3.transformMat4( + newFocalPoint, + vec3.fromValues( + model.focalPoint[0], + model.focalPoint[1], + model.focalPoint[2] + ), + trans + ); + publicAPI.setFocalPoint( + newFocalPoint[0], + newFocalPoint[1], + newFocalPoint[2] + ); }; publicAPI.zoom = (factor) => { @@ -276,13 +354,9 @@ function vtkCamera(publicAPI, model) { publicAPI.modified(); }; - publicAPI.setThickness = (thickness) => { - - }; - - publicAPI.setObliqueAngles = (alpha, beta) => { + publicAPI.setThickness = (thickness) => {}; - }; + publicAPI.setObliqueAngles = (alpha, beta) => {}; publicAPI.physicalOrientationToWorldDirection = (ori) => { // get the PhysicalToWorldMatrix @@ -309,8 +383,12 @@ function vtkCamera(publicAPI, model) { publicAPI.getWorldToPhysicalMatrix = (result) => { mat4.identity(w2pMatrix); - vec3.set(tmpvec1, - model.physicalScale, model.physicalScale, model.physicalScale); + vec3.set( + tmpvec1, + model.physicalScale, + model.physicalScale, + model.physicalScale + ); mat4.scale(w2pMatrix, w2pMatrix, tmpvec1); mat4.translate(w2pMatrix, w2pMatrix, model.physicalTranslation); @@ -367,10 +445,12 @@ function vtkCamera(publicAPI, model) { const up = model.viewUp; const result = mat4.create(); - mat4.lookAt(viewMatrix, - vec3.fromValues(eye[0], eye[1], eye[2]), // eye - vec3.fromValues(at[0], at[1], at[2]), // at - vec3.fromValues(up[0], up[1], up[2])); // up + mat4.lookAt( + viewMatrix, + vec3.fromValues(eye[0], eye[1], eye[2]), // eye + vec3.fromValues(at[0], at[1], at[2]), // at + vec3.fromValues(up[0], up[1], up[2]) + ); // up mat4.transpose(viewMatrix, viewMatrix); @@ -386,9 +466,12 @@ function vtkCamera(publicAPI, model) { const result = mat4.create(); if (model.projectionMatrix) { - vec3.set(tmpvec1, - model.physicalScale, model.physicalScale, model.physicalScale); - + vec3.set( + tmpvec1, + model.physicalScale, + model.physicalScale, + model.physicalScale + ); mat4.copy(result, model.projectionMatrix); mat4.scale(result, result, tmpvec1); @@ -403,8 +486,9 @@ function vtkCamera(publicAPI, model) { // this->ProjectionTransform->AdjustZBuffer( -1, +1, nearz, farz ); const cWidth = model.clippingRange[1] - model.clippingRange[0]; const cRange = [ - model.clippingRange[0] + (((nearz + 1) * cWidth) / 2.0), - model.clippingRange[0] + (((farz + 1) * cWidth) / 2.0)]; + model.clippingRange[0] + (nearz + 1) * cWidth / 2.0, + model.clippingRange[0] + (farz + 1) * cWidth / 2.0, + ]; if (model.parallelProjection) { // set up a rectangular parallelipiped @@ -416,7 +500,15 @@ function vtkCamera(publicAPI, model) { const ymin = (model.windowCenter[1] - 1.0) * height; const ymax = (model.windowCenter[1] + 1.0) * height; - mat4.ortho(projectionMatrix, xmin, xmax, ymin, ymax, cRange[0], cRange[1]); + mat4.ortho( + projectionMatrix, + xmin, + xmax, + ymin, + ymax, + cRange[0], + cRange[1] + ); mat4.transpose(projectionMatrix, projectionMatrix); } else if (model.useOffAxisProjection) { throw new Error('Off-Axis projection is not supported at this time'); @@ -466,18 +558,16 @@ function vtkCamera(publicAPI, model) { // Return array of 24 params (4 params for each of 6 plane equations) }; - publicAPI.getOrientation = () => { - - }; + publicAPI.getOrientation = () => {}; - publicAPI.getOrientationWXYZ = () => { - - }; + publicAPI.getOrientationWXYZ = () => {}; publicAPI.setDirectionOfProjection = (x, y, z) => { - if (model.directionOfProjection[0] === x && - model.directionOfProjection[1] === y && - model.directionOfProjection[2] === z) { + if ( + model.directionOfProjection[0] === x && + model.directionOfProjection[1] === y && + model.directionOfProjection[2] === z + ) { return; } @@ -488,9 +578,9 @@ function vtkCamera(publicAPI, model) { const vec = model.directionOfProjection; // recalculate FocalPoint - model.focalPoint[0] = model.position[0] + (vec[0] * model.distance); - model.focalPoint[1] = model.position[1] + (vec[1] * model.distance); - model.focalPoint[2] = model.position[2] + (vec[2] * model.distance); + model.focalPoint[0] = model.position[0] + vec[0] * model.distance; + model.focalPoint[1] = model.position[1] + vec[1] * model.distance; + model.focalPoint[2] = model.position[2] + vec[2] * model.distance; publicAPI.computeViewPlaneNormal(); }; @@ -600,11 +690,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.obj(publicAPI, model); - model.viewMatrix = - macro.get(publicAPI, model, [ - 'distance', - 'thickness', - ]); + model.viewMatrix = macro.get(publicAPI, model, ['distance', 'thickness']); macro.setGet(publicAPI, model, [ 'parallelProjection', @@ -624,20 +710,22 @@ export function extend(publicAPI, model, initialValues = {}) { 'focalPoint', ]); - macro.setGetArray(publicAPI, model, [ - 'clippingRange', - 'windowCenter', - ], 2); - - macro.setGetArray(publicAPI, model, [ - 'viewUp', - 'screenBottomLeft', - 'screenBottomRight', - 'screenTopRight', - 'physicalTranslation', - 'physicalViewUp', - 'physicalViewNorth', - ], 3); + macro.setGetArray(publicAPI, model, ['clippingRange', 'windowCenter'], 2); + + macro.setGetArray( + publicAPI, + model, + [ + 'viewUp', + 'screenBottomLeft', + 'screenBottomRight', + 'screenTopRight', + 'physicalTranslation', + 'physicalViewUp', + 'physicalViewNorth', + ], + 3 + ); // Object methods vtkCamera(publicAPI, model); diff --git a/Sources/Rendering/Core/CellPicker/example/PickerInteractorStyle.js b/Sources/Rendering/Core/CellPicker/example/PickerInteractorStyle.js index f42a1c6b0fb..9d30c7c678c 100644 --- a/Sources/Rendering/Core/CellPicker/example/PickerInteractorStyle.js +++ b/Sources/Rendering/Core/CellPicker/example/PickerInteractorStyle.js @@ -1,9 +1,9 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkInteractorStyleTrackballCamera from 'vtk.js/Sources/Interaction/Style/InteractorStyleTrackballCamera'; -import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; // ---------------------------------------------------------------------------- // vtkInteractorStyleTrackballCamera2 methods @@ -16,7 +16,9 @@ function vtkPickerInteractorStyle(publicAPI, model) { const superClass = Object.assign({}, publicAPI); publicAPI.handleLeftButtonPress = () => { - const pos = model.interactor.getEventPosition(model.interactor.getPointerIndex()); + const pos = model.interactor.getEventPosition( + model.interactor.getPointerIndex() + ); publicAPI.findPokedRenderer(pos.x, pos.y); if (model.currentRenderer === null) { return; @@ -26,17 +28,25 @@ function vtkPickerInteractorStyle(publicAPI, model) { const renderer = model.currentRenderer; const interactor = model.interactor; const boundingContainer = model.container.getBoundingClientRect(); - const point = [pos.x - boundingContainer.left, pos.y + boundingContainer.top, 0.0]; + const point = [ + pos.x - boundingContainer.left, + pos.y + boundingContainer.top, + 0.0, + ]; interactor.getPicker().pick(point, renderer); const pickedPoints = interactor.getPicker().getPickedPositions(); const pickedCellId = interactor.getPicker().getCellId(); console.log('cell id : ', pickedCellId); - const cameraCenter = model.currentRenderer.getActiveCamera().getPosition(); + const cameraCenter = model.currentRenderer + .getActiveCamera() + .getPosition(); let minDistance = Number.MAX_VALUE; for (let i = 0; i < pickedPoints.length; i++) { - const dist = Math.sqrt(vtkMath.distance2BetweenPoints(cameraCenter, pickedPoints[i])); + const dist = Math.sqrt( + vtkMath.distance2BetweenPoints(cameraCenter, pickedPoints[i]) + ); if (dist < minDistance) { minDistance = dist; } @@ -77,7 +87,10 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkPickerInteractorStyle'); +export const newInstance = macro.newInstance( + extend, + 'vtkPickerInteractorStyle' +); // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/Core/CellPicker/example/index.js b/Sources/Rendering/Core/CellPicker/example/index.js index 7688e4ae4e2..1fe47d0fb71 100644 --- a/Sources/Rendering/Core/CellPicker/example/index.js +++ b/Sources/Rendering/Core/CellPicker/example/index.js @@ -1,11 +1,11 @@ import 'vtk.js/Sources/favicon'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkPickerInteractorStyle from 'vtk.js/Sources/Rendering/Core/CellPicker/example/PickerInteractorStyle'; -import vtkCellPicker from 'vtk.js/Sources/Rendering/Core/CellPicker'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkPickerInteractorStyle from 'vtk.js/Sources/Rendering/Core/CellPicker/example/PickerInteractorStyle'; +import vtkCellPicker from 'vtk.js/Sources/Rendering/Core/CellPicker'; // ---------------------------------------------------------------------------- // Standard rendering code setup diff --git a/Sources/Rendering/Core/CellPicker/index.js b/Sources/Rendering/Core/CellPicker/index.js index 185fbdaf2d9..025acc41778 100644 --- a/Sources/Rendering/Core/CellPicker/index.js +++ b/Sources/Rendering/Core/CellPicker/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkMath from 'vtk.js/Sources/Common/Core/Math'; import vtkPicker from 'vtk.js/Sources/Rendering/Core/Picker'; import vtkPoints from 'vtk.js/Sources/Common/Core/Points'; @@ -17,13 +17,16 @@ function clipLineWithPlane(mapper, matrix, p1, p2) { for (let i = 0; i < nbClippingPlanes; i++) { mapper.getClippingPlaneInDataCoords(matrix, i, plane); - const d1 = (plane[0] * p1[0]) + (plane[1] * p1[1]) + (plane[2] * p1[2]) + plane[3]; - const d2 = (plane[0] * p2[0]) + (plane[1] * p2[1]) + (plane[2] * p2[2]) + plane[3]; + const d1 = + plane[0] * p1[0] + plane[1] * p1[1] + plane[2] * p1[2] + plane[3]; + const d2 = + plane[0] * p2[0] + plane[1] * p2[1] + plane[2] * p2[2] + plane[3]; // If both distances are negative, both points are outside if (d1 < 0 && d2 < 0) { return 0; - } else if (d1 < 0 || d2 < 0) { // If only one of the distances is negative, the line crosses the plane + } else if (d1 < 0 || d2 < 0) { + // If only one of the distances is negative, the line crosses the plane // Compute fractional distance "t" of the crossing between p1 & p2 let t = 0.0; @@ -39,7 +42,8 @@ function clipLineWithPlane(mapper, matrix, p1, p2) { outObj.t1 = t; outObj.planeId = i; } - } else if (t <= outObj.t2) { // else point p2 was clipped, so adjust t2 + } else if (t <= outObj.t2) { + // else point p2 was clipped, so adjust t2 outObj.t2 = t; } // If this happens, there's no line left @@ -118,9 +122,9 @@ function vtkCellPicker(publicAPI, model) { const pointNormal = []; for (let i = 0; i < 3; i++) { normals.getTuple(cell.getPointsIds()[i], pointNormal); - normal[0] += (pointNormal[0] * weights[i]); - normal[1] += (pointNormal[1] * weights[i]); - normal[2] += (pointNormal[2] * weights[i]); + normal[0] += pointNormal[0] * weights[i]; + normal[1] += pointNormal[1] * weights[i]; + normal[2] += pointNormal[2] * weights[i]; } vtkMath.normalize(normal); } else if (cellDimension === 2) { @@ -163,7 +167,14 @@ function vtkCellPicker(publicAPI, model) { const vtkCellPickerPlaneTol = 1e-14; - const clipLine = clipLineWithPlane(mapper, model.transformMatrix, p1, p2, t1, t2); + const clipLine = clipLineWithPlane( + mapper, + model.transformMatrix, + p1, + p2, + t1, + t2 + ); if (mapper && !clipLine.intersect) { return Number.MAX_VALUE; } @@ -181,24 +192,44 @@ function vtkCellPicker(publicAPI, model) { if (tMin < model.globalTMin) { model.globalTMin = tMin; - if (Math.abs(tMin - t1) < vtkCellPickerPlaneTol && clipLine.clippingPlaneId >= 0) { - model.mapperPosition[0] = (p1[0] * (1 - t1)) + (p2[0] * t1); - model.mapperPosition[1] = (p1[1] * (1 - t1)) + (p2[1] * t1); - model.mapperPosition[2] = (p1[2] * (1 - t1)) + (p2[2] * t1); + if ( + Math.abs(tMin - t1) < vtkCellPickerPlaneTol && + clipLine.clippingPlaneId >= 0 + ) { + model.mapperPosition[0] = p1[0] * (1 - t1) + p2[0] * t1; + model.mapperPosition[1] = p1[1] * (1 - t1) + p2[1] * t1; + model.mapperPosition[2] = p1[2] * (1 - t1) + p2[2] * t1; const plane = []; - mapper.getClippingPlaneInDataCoords(model.transformMatrix, clipLine.clippingPlaneId, plane); + mapper.getClippingPlaneInDataCoords( + model.transformMatrix, + clipLine.clippingPlaneId, + plane + ); vtkMath.normalize(plane); // Want normal outward from the planes, not inward model.mapperNormal[0] = -plane[0]; model.mapperNormal[1] = -plane[1]; model.mapperNormal[2] = -plane[2]; } - vec3.transformMat4(model.pickPosition, model.mapperPosition, model.transformMatrix); + vec3.transformMat4( + model.pickPosition, + model.mapperPosition, + model.transformMatrix + ); // Transform vector const mat = model.transformMatrix; - model.mapperNormal[0] = (mat[0] * model.pickNormal[0]) + (mat[4] * model.pickNormal[1]) + (mat[8] * model.pickNormal[2]); - model.mapperNormal[1] = (mat[1] * model.pickNormal[0]) + (mat[5] * model.pickNormal[1]) + (mat[9] * model.pickNormal[2]); - model.mapperNormal[2] = (mat[2] * model.pickNormal[0]) + (mat[6] * model.pickNormal[1]) + (mat[10] * model.pickNormal[2]); + model.mapperNormal[0] = + mat[0] * model.pickNormal[0] + + mat[4] * model.pickNormal[1] + + mat[8] * model.pickNormal[2]; + model.mapperNormal[1] = + mat[1] * model.pickNormal[0] + + mat[5] * model.pickNormal[1] + + mat[9] * model.pickNormal[2]; + model.mapperNormal[2] = + mat[2] * model.pickNormal[0] + + mat[6] * model.pickNormal[1] + + mat[10] * model.pickNormal[2]; } return tMin; @@ -226,8 +257,8 @@ function vtkCellPicker(publicAPI, model) { q2[2] = p2[2]; if (t1 !== 0.0 || t2 !== 1.0) { for (let j = 0; j < 3; j++) { - q1[j] = (p1[j] * (1.0 - t1)) + (p2[j] * t1); - q2[j] = (p1[j] * (1.0 - t2)) + (p2[j] * t2); + q1[j] = p1[j] * (1.0 - t1) + p2[j] * t1; + q2[j] = p1[j] * (1.0 - t2) + p2[j] * t2; } } @@ -256,13 +287,17 @@ function vtkCellPicker(publicAPI, model) { for (let j = 0; j < nbPointsInCell; j++) { pointsIdList[j] = cellData[i++]; cellPointsData[cpt++] = pointsData[pointsIdList[j] * 3]; - cellPointsData[cpt++] = pointsData[(pointsIdList[j] * 3) + 1]; - cellPointsData[cpt++] = pointsData[(pointsIdList[j] * 3) + 2]; + cellPointsData[cpt++] = pointsData[pointsIdList[j] * 3 + 1]; + cellPointsData[cpt++] = pointsData[pointsIdList[j] * 3 + 2]; } cellPoints.setData(cellPointsData); // Create cell from points - cell.initialize(cellPoints.getNumberOfPoints(), pointsIdList, cellPoints); + cell.initialize( + cellPoints.getNumberOfPoints(), + pointsIdList, + cellPoints + ); let cellPicked; if (isPolyData) { @@ -270,12 +305,16 @@ function vtkCellPicker(publicAPI, model) { } else { cellPicked = cell.intersectWithLine(q1, q2, tol, x, pCoords); if (t1 !== 0.0 || t2 !== 1.0) { - cellPicked.t = (t1 * (1.0 - cellPicked.t)) + (t2 * cellPicked.t); + cellPicked.t = t1 * (1.0 - cellPicked.t) + t2 * cellPicked.t; } } - if (cellPicked.intersect === 1 && cellPicked.t <= (tMin + model.tolerance) && - cellPicked.t >= t1 && cellPicked.t <= t2) { + if ( + cellPicked.intersect === 1 && + cellPicked.t <= tMin + model.tolerance && + cellPicked.t >= t1 && + cellPicked.t <= t2 + ) { const pDist = cell.getParametricDistance(pCoords); if (pDist < pDistMin || (pDist === pDistMin && cellPicked.t < tMin)) { tMin = cellPicked.t; @@ -329,7 +368,14 @@ function vtkCellPicker(publicAPI, model) { model.mapperPosition[2] = minXYZ[2]; // COmpute the normal - if (!publicAPI.computeSurfaceNormal(data, minCell, weights, model.mapperNormal)) { + if ( + !publicAPI.computeSurfaceNormal( + data, + minCell, + weights, + model.mapperNormal + ) + ) { // By default, the normal points back along view ray model.mapperNormal[0] = p1[0] - p2[0]; model.mapperNormal[1] = p1[1] - p2[1]; diff --git a/Sources/Rendering/Core/ColorTransferFunction/ColorMaps.js b/Sources/Rendering/Core/ColorTransferFunction/ColorMaps.js index 0c77ff4b40a..50c58a8b406 100644 --- a/Sources/Rendering/Core/ColorTransferFunction/ColorMaps.js +++ b/Sources/Rendering/Core/ColorTransferFunction/ColorMaps.js @@ -3,9 +3,9 @@ import vtkColorMaps from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction/Co const uniqueNames = {}; vtkColorMaps - .filter(p => p.RGBPoints) - .filter(p => p.ColorSpace !== 'CIELAB') - .map(p => p.Name) + .filter((p) => p.RGBPoints) + .filter((p) => p.ColorSpace !== 'CIELAB') + .map((p) => p.Name) .forEach((name) => { uniqueNames[name] = true; }); @@ -18,7 +18,7 @@ rgbPresetNames.sort(); // ---------------------------------------------------------------------------- function getPresetByName(name) { - return vtkColorMaps.find(p => p.Name === name); + return vtkColorMaps.find((p) => p.Name === name); } // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/Core/ColorTransferFunction/index.js b/Sources/Rendering/Core/ColorTransferFunction/index.js index 76adfc632ae..4ee07b8173f 100644 --- a/Sources/Rendering/Core/ColorTransferFunction/index.js +++ b/Sources/Rendering/Core/ColorTransferFunction/index.js @@ -1,7 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; -import vtkScalarsToColors from 'vtk.js/Sources/Common/Core/ScalarsToColors'; -import Constants from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction/Constants'; +import macro from 'vtk.js/Sources/macro'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkScalarsToColors from 'vtk.js/Sources/Common/Core/ScalarsToColors'; +import Constants from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction/Constants'; const { ColorSpace, Scale } = Constants; const { ScalarMappingTarget } = vtkScalarsToColors; @@ -18,9 +18,9 @@ function vtkColorTransferFunctionLabToMsh(lab, msh) { const L = lab[0]; const a = lab[1]; const b = lab[2]; - const M = Math.sqrt((L * L) + (a * a) + (b * b)); - const s = (M > 0.001) ? Math.acos(L / M) : 0.0; - const h = (s > 0.001) ? Math.atan2(b, a) : 0.0; + const M = Math.sqrt(L * L + a * a + b * b); + const s = M > 0.001 ? Math.acos(L / M) : 0.0; + const h = s > 0.001 ? Math.atan2(b, a) : 0.0; msh[0] = M; msh[1] = s; msh[2] = h; @@ -46,7 +46,10 @@ function vtkColorTransferFunctionAdjustHue(msh, unsatM) { // This equation is designed to make the perceptual change of the // interpolation to be close to constant. - const hueSpin = (msh[1] * Math.sqrt((unsatM * unsatM) - (msh[0] * msh[0])) / (msh[0] * Math.sin(msh[1]))); + const hueSpin = + msh[1] * + Math.sqrt(unsatM * unsatM - msh[0] * msh[0]) / + (msh[0] * Math.sin(msh[1])); // Spin hue away from 0 except in purple hues. if (msh[2] > -0.3 * Math.PI) { return msh[2] + hueSpin; @@ -61,10 +64,10 @@ function vtkColorTransferFunctionAngleDiff(a1, a2) { adiff = -adiff; } while (adiff >= 2.0 * Math.PI) { - adiff -= (2.0 * Math.PI); + adiff -= 2.0 * Math.PI; } if (adiff > Math.PI) { - adiff = (2.0 * Math.PI) - adiff; + adiff = 2.0 * Math.PI - adiff; } return adiff; } @@ -84,8 +87,11 @@ function vtkColorTransferFunctionInterpolateDiverging(s, rgb1, rgb2, result) { // If the endpoints are distinct saturated colors, then place white in between // them. let localS = s; - if ((msh1[1] > 0.05) && (msh2[1] > 0.05) - && (vtkColorTransferFunctionAngleDiff(msh1[2], msh2[2]) > 0.33 * Math.PI)) { + if ( + msh1[1] > 0.05 && + msh2[1] > 0.05 && + vtkColorTransferFunctionAngleDiff(msh1[2], msh2[2]) > 0.33 * Math.PI + ) { // Insert the white midpoint by setting one end to white and adjusting the // scalar value. let Mmid = Math.max(msh1[0], msh2[0]); @@ -99,23 +105,23 @@ function vtkColorTransferFunctionInterpolateDiverging(s, rgb1, rgb2, result) { msh1[0] = Mmid; msh1[1] = 0.0; msh1[2] = 0.0; - localS = (2.0 * localS) - 1.0; + localS = 2.0 * localS - 1.0; } } // If one color has no saturation, then its hue value is invalid. In this // case, we want to set it to something logical so that the interpolation of // hue makes sense. - if ((msh1[1] < 0.05) && (msh2[1] > 0.05)) { + if (msh1[1] < 0.05 && msh2[1] > 0.05) { msh1[2] = vtkColorTransferFunctionAdjustHue(msh2, msh1[0]); - } else if ((msh2[1] < 0.05) && (msh1[1] > 0.05)) { + } else if (msh2[1] < 0.05 && msh1[1] > 0.05) { msh2[2] = vtkColorTransferFunctionAdjustHue(msh1, msh2[0]); } const mshTmp = []; - mshTmp[0] = ((1 - localS) * msh1[0]) + (localS * msh2[0]); - mshTmp[1] = ((1 - localS) * msh1[1]) + (localS * msh2[1]); - mshTmp[2] = ((1 - localS) * msh1[2]) + (localS * msh2[2]); + mshTmp[0] = (1 - localS) * msh1[0] + localS * msh2[0]; + mshTmp[1] = (1 - localS) * msh1[1] + localS * msh2[1]; + mshTmp[2] = (1 - localS) * msh1[2] + localS * msh2[2]; // Now convert back to RGB const labTmp = []; @@ -131,7 +137,6 @@ function vtkColorTransferFunction(publicAPI, model) { // Set our className model.classHierarchy.push('vtkColorTransferFunction'); - // Return the number of points which specify this function publicAPI.getSize = () => model.nodes.length; @@ -196,7 +201,14 @@ function vtkColorTransferFunction(publicAPI, model) { const hsv = [h, s, v]; vtkMath.hsv2rgb(hsv, rgb); - return publicAPI.addRGBPoint(x, rgb[0], rgb[1], rgb[2], midpoint, sharpness); + return publicAPI.addRGBPoint( + x, + rgb[0], + rgb[1], + rgb[2], + midpoint, + sharpness + ); }; //---------------------------------------------------------------------------- @@ -228,7 +240,10 @@ function vtkColorTransferFunction(publicAPI, model) { } // If the range is the same, then no need to call Modified() - if (oldRange[0] === model.mappingRange[0] && oldRange[1] === model.mappingRange[1]) { + if ( + oldRange[0] === model.mappingRange[0] && + oldRange[1] === model.mappingRange[1] + ) { return false; } @@ -298,7 +313,7 @@ function vtkColorTransferFunction(publicAPI, model) { publicAPI.addRGBSegment = (x1, r1, g1, b1, x2, r2, g2, b2) => { // First, find all points in this range and remove them publicAPI.sortAndUpdateRange(); - for (let i = 0; i < model.nodes.length;) { + for (let i = 0; i < model.nodes.length; ) { if (model.nodes[i].x >= x1 && model.nodes[i].x <= x2) { model.nodes.splice(i, 1); } else { @@ -322,7 +337,16 @@ function vtkColorTransferFunction(publicAPI, model) { vtkMath.hsv2rgb(hsv1, rgb1); vtkMath.hsv2rgb(hsv2, rgb2); - publicAPI.addRGBSegment(x1, rgb1[0], rgb1[1], rgb1[2], x2, rgb2[0], rgb2[1], rgb2[2]); + publicAPI.addRGBSegment( + x1, + rgb1[0], + rgb1[1], + rgb1[2], + x2, + rgb2[0], + rgb2[1], + rgb2[2] + ); }; //---------------------------------------------------------------------------- @@ -332,10 +356,11 @@ function vtkColorTransferFunction(publicAPI, model) { publicAPI.getColor(x, rgb); return [ - Math.floor((255.0 * rgb[0]) + 0.5), - Math.floor((255.0 * rgb[1]) + 0.5), - Math.floor((255.0 * rgb[2]) + 0.5), - 255]; + Math.floor(255.0 * rgb[0] + 0.5), + Math.floor(255.0 * rgb[1] + 0.5), + Math.floor(255.0 * rgb[2] + 0.5), + 255, + ]; }; //---------------------------------------------------------------------------- @@ -391,9 +416,9 @@ function vtkColorTransferFunction(publicAPI, model) { // the NaN color. if (vtkMath.isNan(xStart) || vtkMath.isNan(xEnd)) { for (let i = 0; i < size; i++) { - table[(i * 3) + 0] = model.nanColor[0]; - table[(i * 3) + 1] = model.nanColor[1]; - table[(i * 3) + 2] = model.nanColor[2]; + table[i * 3 + 0] = model.nanColor[0]; + table[i * 3 + 1] = model.nanColor[1]; + table[i * 3 + 2] = model.nanColor[2]; } return; } @@ -424,10 +449,10 @@ function vtkColorTransferFunction(publicAPI, model) { const tmpVec = []; // If the scale is logarithmic, make sure the range is valid. - let usingLogScale = (model.scale === Scale.LOG10); + let usingLogScale = model.scale === Scale.LOG10; if (usingLogScale) { // Note: This requires range[0] <= range[1]. - usingLogScale = (model.mappingRange[0] > 0.0); + usingLogScale = model.mappingRange[0] > 0.0; } let logStart = 0.0; @@ -448,12 +473,10 @@ function vtkColorTransferFunction(publicAPI, model) { // be the same in this case) if (size > 1) { if (usingLogScale) { - logX = logStart + - ((i / (size - 1.0)) - * (logEnd - logStart)); + logX = logStart + i / (size - 1.0) * (logEnd - logStart); x = Math.pow(10.0, logX); } else { - x = xStart + ((i / (size - 1.0)) * (xEnd - xStart)); + x = xStart + i / (size - 1.0) * (xEnd - xStart); } } else if (usingLogScale) { logX = 0.5 * (logStart + logEnd); @@ -463,8 +486,7 @@ function vtkColorTransferFunction(publicAPI, model) { } // Do we need to move to the next node? - while (idx < numNodes && - x > model.nodes[idx].x) { + while (idx < numNodes && x > model.nodes[idx].x) { idx++; // If we are at a valid point index, fill in // the value at this node, and the one before (the @@ -564,7 +586,7 @@ function vtkColorTransferFunction(publicAPI, model) { if (s < midpoint) { s = 0.5 * s / midpoint; } else { - s = 0.5 + (0.5 * (s - midpoint) / (1.0 - midpoint)); + s = 0.5 + 0.5 * (s - midpoint) / (1.0 - midpoint); } // override for sharpness > 0.99 @@ -590,18 +612,19 @@ function vtkColorTransferFunction(publicAPI, model) { if (sharpness < 0.01) { // Simple linear interpolation if (model.colorSpace === ColorSpace.RGB) { - table[tidx] = ((1 - s) * rgb1[0]) + (s * rgb2[0]); - table[tidx + 1] = ((1 - s) * rgb1[1]) + (s * rgb2[1]); - table[tidx + 2] = ((1 - s) * rgb1[2]) + (s * rgb2[2]); + table[tidx] = (1 - s) * rgb1[0] + s * rgb2[0]; + table[tidx + 1] = (1 - s) * rgb1[1] + s * rgb2[1]; + table[tidx + 2] = (1 - s) * rgb1[2] + s * rgb2[2]; } else if (model.colorSpace === ColorSpace.HSV) { const hsv1 = []; const hsv2 = []; vtkMath.rgb2hsv(rgb1, hsv1); vtkMath.rgb2hsv(rgb2, hsv2); - if (model.hSVWrap && - (hsv1[0] - hsv2[0] > 0.5 || - hsv2[0] - hsv1[0] > 0.5)) { + if ( + model.hSVWrap && + (hsv1[0] - hsv2[0] > 0.5 || hsv2[0] - hsv1[0] > 0.5) + ) { if (hsv1[0] > hsv2[0]) { hsv1[0] -= 1.0; } else { @@ -610,12 +633,12 @@ function vtkColorTransferFunction(publicAPI, model) { } const hsvTmp = []; - hsvTmp[0] = ((1.0 - s) * hsv1[0]) + (s * hsv2[0]); + hsvTmp[0] = (1.0 - s) * hsv1[0] + s * hsv2[0]; if (hsvTmp[0] < 0.0) { hsvTmp[0] += 1.0; } - hsvTmp[1] = ((1.0 - s) * hsv1[1]) + (s * hsv2[1]); - hsvTmp[2] = ((1.0 - s) * hsv1[2]) + (s * hsv2[2]); + hsvTmp[1] = (1.0 - s) * hsv1[1] + s * hsv2[1]; + hsvTmp[2] = (1.0 - s) * hsv1[2] + s * hsv2[2]; // Now convert this back to RGB vtkMath.hsv2rgb(hsvTmp, tmpVec); @@ -629,9 +652,9 @@ function vtkColorTransferFunction(publicAPI, model) { vtkMath.rgb2lab(rgb2, lab2); const labTmp = []; - labTmp[0] = ((1 - s) * lab1[0]) + (s * lab2[0]); - labTmp[1] = ((1 - s) * lab1[1]) + (s * lab2[1]); - labTmp[2] = ((1 - s) * lab1[2]) + (s * lab2[2]); + labTmp[0] = (1 - s) * lab1[0] + s * lab2[0]; + labTmp[1] = (1 - s) * lab1[1] + s * lab2[1]; + labTmp[2] = (1 - s) * lab1[2] + s * lab2[2]; // Now convert back to RGB vtkMath.lab2rgb(labTmp, tmpVec); @@ -657,18 +680,18 @@ function vtkColorTransferFunction(publicAPI, model) { // First, we will adjust our position based on sharpness in // order to make the curve sharper (closer to piecewise constant) if (s < 0.5) { - s = 0.5 * Math.pow(s * 2.0, 1.0 + (10.0 * sharpness)); + s = 0.5 * Math.pow(s * 2.0, 1.0 + 10.0 * sharpness); } else if (s > 0.5) { - s = 1.0 - (0.5 * Math.pow((1.0 - s) * 2, 1 + (10.0 * sharpness))); + s = 1.0 - 0.5 * Math.pow((1.0 - s) * 2, 1 + 10.0 * sharpness); } // Compute some coefficients we will need for the hermite curve const ss = s * s; const sss = ss * s; - const h1 = (2.0 * sss) - (3 * ss) + 1; - const h2 = (-2 * sss) + (3 * ss); - const h3 = sss - (2 * ss) + s; + const h1 = 2.0 * sss - 3 * ss + 1; + const h2 = -2 * sss + 3 * ss; + const h3 = sss - 2 * ss + s; const h4 = sss - ss; let slope; @@ -681,7 +704,7 @@ function vtkColorTransferFunction(publicAPI, model) { t = (1.0 - sharpness) * slope; // Compute the value - table[tidx + j] = (h1 * rgb1[j]) + (h2 * rgb2[j]) + (h3 * t) + (h4 * t); + table[tidx + j] = h1 * rgb1[j] + h2 * rgb2[j] + h3 * t + h4 * t; } } else if (model.colorSpace === ColorSpace.HSV) { const hsv1 = []; @@ -689,9 +712,10 @@ function vtkColorTransferFunction(publicAPI, model) { vtkMath.rgb2hsv(rgb1, hsv1); vtkMath.rgb2hsv(rgb2, hsv2); - if (model.hSVWrap && - (hsv1[0] - hsv2[0] > 0.5 || - hsv2[0] - hsv1[0] > 0.5)) { + if ( + model.hSVWrap && + (hsv1[0] - hsv2[0] > 0.5 || hsv2[0] - hsv1[0] > 0.5) + ) { if (hsv1[0] > hsv2[0]) { hsv1[0] -= 1.0; } else { @@ -707,7 +731,7 @@ function vtkColorTransferFunction(publicAPI, model) { t = (1.0 - sharpness) * slope; // Compute the value - hsvTmp[j] = (h1 * hsv1[j]) + (h2 * hsv2[j]) + (h3 * t) + (h4 * t); + hsvTmp[j] = h1 * hsv1[j] + h2 * hsv2[j] + h3 * t + h4 * t; if (j === 0 && hsvTmp[j] < 0.0) { hsvTmp[j] += 1.0; } @@ -730,7 +754,7 @@ function vtkColorTransferFunction(publicAPI, model) { t = (1.0 - sharpness) * slope; // Compute the value - labTmp[j] = (h1 * lab1[j]) + (h2 * lab2[j]) + (h3 * t) + (h4 * t); + labTmp[j] = h1 * lab1[j] + h2 * lab2[j] + h3 * t + h4 * t; } // Now convert this back to RGB vtkMath.lab2rgb(labTmp, tmpVec); @@ -751,8 +775,8 @@ function vtkColorTransferFunction(publicAPI, model) { // Final error check to make sure we don't go outside [0,1] for (let j = 0; j < 3; j++) { - table[tidx + j] = (table[tidx + j] < 0.0) ? (0.0) : (table[tidx + j]); - table[tidx + j] = (table[tidx + j] > 1.0) ? (1.0) : (table[tidx + j]); + table[tidx + j] = table[tidx + j] < 0.0 ? 0.0 : table[tidx + j]; + table[tidx + j] = table[tidx + j] > 1.0 ? 1.0 : table[tidx + j]; } } } @@ -760,18 +784,22 @@ function vtkColorTransferFunction(publicAPI, model) { //---------------------------------------------------------------------------- publicAPI.getUint8Table = (xStart, xEnd, size, withAlpha = false) => { - if (publicAPI.getMTime() <= model.buildTime && - model.tableSize === size && model.tableWithAlpha !== withAlpha) { + if ( + publicAPI.getMTime() <= model.buildTime && + model.tableSize === size && + model.tableWithAlpha !== withAlpha + ) { return model.table; } if (model.nodes.length === 0) { vtkErrorMacro( - 'Attempting to lookup a value with no points in the function'); + 'Attempting to lookup a value with no points in the function' + ); return model.table; } - const nbChannels = (withAlpha ? 4 : 3); + const nbChannels = withAlpha ? 4 : 3; if (model.tableSize !== size || model.tableWithAlpha !== withAlpha) { model.table = new Uint8Array(size * nbChannels); model.tableSize = size; @@ -782,11 +810,17 @@ function vtkColorTransferFunction(publicAPI, model) { publicAPI.getTable(xStart, xEnd, size, tmpTable); for (let i = 0; i < size; i++) { - model.table[(i * nbChannels) + 0] = Math.floor((tmpTable[(i * 3) + 0] * 255.0) + 0.5); - model.table[(i * nbChannels) + 1] = Math.floor((tmpTable[(i * 3) + 1] * 255.0) + 0.5); - model.table[(i * nbChannels) + 2] = Math.floor((tmpTable[(i * 3) + 2] * 255.0) + 0.5); + model.table[i * nbChannels + 0] = Math.floor( + tmpTable[i * 3 + 0] * 255.0 + 0.5 + ); + model.table[i * nbChannels + 1] = Math.floor( + tmpTable[i * 3 + 1] * 255.0 + 0.5 + ); + model.table[i * nbChannels + 2] = Math.floor( + tmpTable[i * 3 + 2] * 255.0 + 0.5 + ); if (withAlpha) { - model.table[(i * nbChannels) + 3] = 255; + model.table[i * nbChannels + 3] = 255; } } @@ -806,10 +840,10 @@ function vtkColorTransferFunction(publicAPI, model) { for (let i = 0; i < size; i++) { const node = { - x: xStart + (inc * i), + x: xStart + inc * i, r: table[i * 3], - g: table[(i * 3) + 1], - b: table[(i * 3) + 2], + g: table[i * 3 + 1], + b: table[i * 3 + 2], sharpness: 0.0, midpoint: 0.5, }; @@ -877,7 +911,7 @@ function vtkColorTransferFunction(publicAPI, model) { // has been called. return model.tableSize; } - return 16777216; // 2^24 + return 16777216; // 2^24 }; //---------------------------------------------------------------------------- @@ -906,10 +940,11 @@ function vtkColorTransferFunction(publicAPI, model) { for (let i = 0; i < nb; i++) { publicAPI.addRGBPoint( - ptr[i * 4], - ptr[(i * 4) + 1], - ptr[(i * 4) + 2], - ptr[(i * 4) + 3]); + ptr[i * 4], + ptr[i * 4 + 1], + ptr[i * 4 + 2], + ptr[i * 4 + 3] + ); } }; @@ -917,8 +952,7 @@ function vtkColorTransferFunction(publicAPI, model) { publicAPI.setMappingRange = (min, max) => { const range = [min, max]; const originalRange = publicAPI.getRange(); - if (originalRange[1] === range[1] && - originalRange[0] === range[0]) { + if (originalRange[1] === range[1] && originalRange[0] === range[0]) { return; } @@ -928,10 +962,10 @@ function vtkColorTransferFunction(publicAPI, model) { } const scale = (range[1] - range[0]) / (originalRange[1] - originalRange[0]); - const shift = range[0] - (originalRange[0] * scale); + const shift = range[0] - originalRange[0] * scale; for (let i = 0; i < model.nodes.length; ++i) { - model.nodes[i].x = (model.nodes[i].x * scale) + shift; + model.nodes[i].x = model.nodes[i].x * scale + shift; } model.mappingRange[0] = range[0]; @@ -963,7 +997,7 @@ function vtkColorTransferFunction(publicAPI, model) { // Remove all points out-of-range publicAPI.sortAndUpdateRange(); - for (let i = 0; i < model.nodes.length;) { + for (let i = 0; i < model.nodes.length; ) { if (model.nodes[i].x >= range[0] && model.nodes[i].x <= range[1]) { model.nodes.splice(i, 1); } else { @@ -997,7 +1031,12 @@ function vtkColorTransferFunction(publicAPI, model) { return distance; }; - publicAPI.mapScalarsThroughTable = (input, output, outFormat, inputOffset) => { + publicAPI.mapScalarsThroughTable = ( + input, + output, + outFormat, + inputOffset + ) => { if (publicAPI.getSize() === 0) { vtkDebugMacro('Transfer Function Has No Points!'); return; @@ -1017,7 +1056,7 @@ function vtkColorTransferFunction(publicAPI, model) { return; } - const alpha = Math.floor((publicAPI.getAlpha() * 255.0) + 0.5); + const alpha = Math.floor(publicAPI.getAlpha() * 255.0 + 0.5); const length = input.getNumberOfTuples(); const inIncr = input.getNumberOfComponents(); @@ -1027,43 +1066,43 @@ function vtkColorTransferFunction(publicAPI, model) { if (outFormat === ScalarMappingTarget.RGBA) { for (let i = 0; i < length; i++) { - const x = inputV[(i * inIncr) + inputOffset]; + const x = inputV[i * inIncr + inputOffset]; publicAPI.getColor(x, rgb); - outputV[i * 4] = Math.floor((rgb[0] * 255.0) + 0.5); - outputV[(i * 4) + 1] = Math.floor((rgb[1] * 255.0) + 0.5); - outputV[(i * 4) + 2] = Math.floor((rgb[2] * 255.0) + 0.5); - outputV[(i * 4) + 3] = alpha; + outputV[i * 4] = Math.floor(rgb[0] * 255.0 + 0.5); + outputV[i * 4 + 1] = Math.floor(rgb[1] * 255.0 + 0.5); + outputV[i * 4 + 2] = Math.floor(rgb[2] * 255.0 + 0.5); + outputV[i * 4 + 3] = alpha; } } if (outFormat === ScalarMappingTarget.RGB) { for (let i = 0; i < length; i++) { - const x = inputV[(i * inIncr) + inputOffset]; + const x = inputV[i * inIncr + inputOffset]; publicAPI.getColor(x, rgb); - outputV[i * 3] = Math.floor((rgb[0] * 255.0) + 0.5); - outputV[(i * 3) + 1] = Math.floor((rgb[1] * 255.0) + 0.5); - outputV[(i * 3) + 2] = Math.floor((rgb[2] * 255.0) + 0.5); + outputV[i * 3] = Math.floor(rgb[0] * 255.0 + 0.5); + outputV[i * 3 + 1] = Math.floor(rgb[1] * 255.0 + 0.5); + outputV[i * 3 + 2] = Math.floor(rgb[2] * 255.0 + 0.5); } } if (outFormat === ScalarMappingTarget.LUMINANCE) { for (let i = 0; i < length; i++) { - const x = inputV[(i * inIncr) + inputOffset]; + const x = inputV[i * inIncr + inputOffset]; publicAPI.getColor(x, rgb); outputV[i] = Math.floor( - (rgb[0] * 76.5) + (rgb[1] * 150.45) - + (rgb[2] * 28.05) + 0.5); + rgb[0] * 76.5 + rgb[1] * 150.45 + rgb[2] * 28.05 + 0.5 + ); } } if (outFormat === ScalarMappingTarget.LUMINANCE_ALPHA) { for (let i = 0; i < length; i++) { - const x = inputV[(i * inIncr) + inputOffset]; + const x = inputV[i * inIncr + inputOffset]; publicAPI.getColor(x, rgb); outputV[i * 2] = Math.floor( - (rgb[0] * 76.5) + (rgb[1] * 150.45) - + (rgb[2] * 28.05) + 0.5); - outputV[(i * 2) + 1] = alpha; + rgb[0] * 76.5 + rgb[1] * 150.45 + rgb[2] * 28.05 + 0.5 + ); + outputV[i * 2 + 1] = alpha; } } }; @@ -1073,7 +1112,9 @@ function vtkColorTransferFunction(publicAPI, model) { if (colorMap.ColorSpace) { model.colorSpace = ColorSpace[colorMap.ColorSpace.toUpperCase()]; if (model.colorSpace === undefined) { - vtkErrorMacro(`ColorSpace ${colorMap.ColorSpace} not supported, using RGB instead`); + vtkErrorMacro( + `ColorSpace ${colorMap.ColorSpace} not supported, using RGB instead` + ); model.colorSpace = ColorSpace.RGB; } } @@ -1139,7 +1180,6 @@ const DEFAULT_VALUES = { export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); - // Inheritance vtkScalarsToColors.extend(publicAPI, model, initialValues); @@ -1155,22 +1195,17 @@ export function extend(publicAPI, model, initialValues = {}) { macro.obj(model.buildTime); // Create get-only macros - macro.get(publicAPI, model, [ - 'buildTime', - 'mappingRange', - ]); + macro.get(publicAPI, model, ['buildTime', 'mappingRange']); // Create get-set macros - macro.setGet(publicAPI, model, [ - 'useAboveRangeColor', - 'useBelowRangeColor', - ]); + macro.setGet(publicAPI, model, ['useAboveRangeColor', 'useBelowRangeColor']); - macro.setArray(publicAPI, model, [ - 'nanColor', - 'belowRangeColor', - 'aboveRangeColor', - ], 4); + macro.setArray( + publicAPI, + model, + ['nanColor', 'belowRangeColor', 'aboveRangeColor'], + 4 + ); // Create get macros for array macro.getArray(publicAPI, model, [ @@ -1187,7 +1222,10 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkColorTransferFunction'); +export const newInstance = macro.newInstance( + extend, + 'vtkColorTransferFunction' +); // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/Core/ColorTransferFunction/test/createScalarMap.js b/Sources/Rendering/Core/ColorTransferFunction/test/createScalarMap.js index 4a12cf4e4ab..0b6b41fccc7 100644 --- a/Sources/Rendering/Core/ColorTransferFunction/test/createScalarMap.js +++ b/Sources/Rendering/Core/ColorTransferFunction/test/createScalarMap.js @@ -1,6 +1,6 @@ import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; // Factory imports import vtk from 'vtk.js/Sources/vtk'; @@ -9,7 +9,14 @@ import 'vtk.js/Sources/Common/Core/CellArray'; import 'vtk.js/Sources/Common/DataModel/DataSetAttributes'; import 'vtk.js/Sources/Common/DataModel/PolyData'; -export default function createScalarMap(offsetX, offsetY, preset, gc, min = 0, max = 1) { +export default function createScalarMap( + offsetX, + offsetY, + preset, + gc, + min = 0, + max = 1 +) { const polydata = vtk({ vtkClass: 'vtkPolyData', points: { @@ -17,35 +24,45 @@ export default function createScalarMap(offsetX, offsetY, preset, gc, min = 0, m dataType: 'Float32Array', numberOfComponents: 3, values: [ - offsetX, offsetY, 0, - offsetX + 0.25, offsetY, 0, - offsetX + 0.25, offsetY + 1, 0, - offsetX, offsetY + 1, 0, + offsetX, + offsetY, + 0, + offsetX + 0.25, + offsetY, + 0, + offsetX + 0.25, + offsetY + 1, + 0, + offsetX, + offsetY + 1, + 0, ], }, polys: { vtkClass: 'vtkCellArray', dataType: 'Uint16Array', - values: [ - 4, 0, 1, 2, 3, - ], + values: [4, 0, 1, 2, 3], }, pointData: { vtkClass: 'vtkDataSetAttributes', activeScalars: 0, - arrays: [{ - data: { - vtkClass: 'vtkDataArray', - name: 'pointScalars', - dataType: 'Float32Array', - values: [min, min, max, max], + arrays: [ + { + data: { + vtkClass: 'vtkDataArray', + name: 'pointScalars', + dataType: 'Float32Array', + values: [min, min, max, max], + }, }, - }], + ], }, }); const actor = gc.registerResource(vtkActor.newInstance()); - const mapper = gc.registerResource(vtkMapper.newInstance({ interpolateScalarsBeforeMapping: true })); + const mapper = gc.registerResource( + vtkMapper.newInstance({ interpolateScalarsBeforeMapping: true }) + ); actor.setMapper(mapper); mapper.setInputData(polydata); actor.getProperty().set({ edgeVisibility: true, edgeColor: [1, 1, 1] }); @@ -58,4 +75,3 @@ export default function createScalarMap(offsetX, offsetY, preset, gc, min = 0, m return actor; } - diff --git a/Sources/Rendering/Core/ColorTransferFunction/test/testColorTransferFunction.js b/Sources/Rendering/Core/ColorTransferFunction/test/testColorTransferFunction.js index cf8838977ee..25da9b2e3ab 100644 --- a/Sources/Rendering/Core/ColorTransferFunction/test/testColorTransferFunction.js +++ b/Sources/Rendering/Core/ColorTransferFunction/test/testColorTransferFunction.js @@ -1,14 +1,14 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; import baseline from './testColorTransferFunction.png'; @@ -18,7 +18,9 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Colors', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -62,13 +64,13 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Colors', (t) => { for (let i = 0; i < res; i++) { for (let j = 0; j < res; j++) { - const idx = (i * res) + j; + const idx = i * res + j; points[idx * 3] = j; - points[(idx * 3) + 1] = i; - points[(idx * 3) + 2] = 0.0; + points[idx * 3 + 1] = i; + points[idx * 3 + 2] = 0.0; // set scalars to be -0.5 to 1.5 so we have above and below range // data. - scalars[idx] = -0.5 + (2.0 * j / (res - 1.0)); + scalars[idx] = -0.5 + 2.0 * j / (res - 1.0); // also add nan for some data if (i === 4) { scalars[idx] = NaN; @@ -76,9 +78,9 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Colors', (t) => { } } - for (let i = 0; i < (res - 1); i++) { - for (let j = 0; j < (res - 1); j++) { - const idx = ((i * res) + j); + for (let i = 0; i < res - 1; i++) { + for (let j = 0; j < res - 1; j++) { + const idx = i * res + j; polys[cellLocation++] = 3; polys[cellLocation++] = idx; polys[cellLocation++] = idx + 1; @@ -90,7 +92,9 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Colors', (t) => { } } - const da = gc.registerResource(vtkDataArray.newInstance({ numberOfComponents: 1, values: scalars })); + const da = gc.registerResource( + vtkDataArray.newInstance({ numberOfComponents: 1, values: scalars }) + ); pd.getPointData().setScalars(da); mapper.setInputData(pd); @@ -104,5 +108,12 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Colors', (t) => { const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/Core/ColorTransferFunction/testColorTransferFunction', t, 1.5, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Rendering/Core/ColorTransferFunction/testColorTransferFunction', + t, + 1.5, + gc.releaseResources + ); }); diff --git a/Sources/Rendering/Core/ColorTransferFunction/test/testColorTransferFunctionInterpolation.js b/Sources/Rendering/Core/ColorTransferFunction/test/testColorTransferFunctionInterpolation.js index 4e7de128b66..7efe9b67a62 100644 --- a/Sources/Rendering/Core/ColorTransferFunction/test/testColorTransferFunctionInterpolation.js +++ b/Sources/Rendering/Core/ColorTransferFunction/test/testColorTransferFunctionInterpolation.js @@ -1,14 +1,14 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; import colorMaps from '../ColorMaps.json'; import createScalarMap from './createScalarMap'; -import baseline from './testColorTransferFunctionInterpolation.png'; +import baseline from './testColorTransferFunctionInterpolation.png'; test.onlyIfWebGL('Test Interpolate Scalars Before Colors', (t) => { const gc = testUtils.createGarbageCollector(t); @@ -18,7 +18,9 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Colors', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -28,7 +30,7 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Colors', (t) => { renderer.setBackground(0.0, 0.0, 0.0); // FIXME ---- magic flag underneath - const preset = colorMaps.find(p => p.Name === 'Cool to Warm'); + const preset = colorMaps.find((p) => p.Name === 'Cool to Warm'); const actor = createScalarMap(0, 0, preset, gc, 0, 10000); actor.getMapper().setScalarRange(0, 10000); // console.log('preset', JSON.stringify(preset, null, 2)); @@ -47,5 +49,12 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Colors', (t) => { renderWindow.render(); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/Core/ColorTransferFunction/testColorTransferFunctionInterpolation', t, 5, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Rendering/Core/ColorTransferFunction/testColorTransferFunctionInterpolation', + t, + 5, + gc.releaseResources + ); }); diff --git a/Sources/Rendering/Core/ColorTransferFunction/test/testColorTransferFunctionPresets.js b/Sources/Rendering/Core/ColorTransferFunction/test/testColorTransferFunctionPresets.js index 4e9be533992..77f24c5c86e 100644 --- a/Sources/Rendering/Core/ColorTransferFunction/test/testColorTransferFunctionPresets.js +++ b/Sources/Rendering/Core/ColorTransferFunction/test/testColorTransferFunctionPresets.js @@ -1,14 +1,14 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import colorMaps from '../ColorMaps.json'; +import colorMaps from '../ColorMaps.json'; -import createScalarMap from './createScalarMap'; -import baseline from './testColorTransferFunctionPresets.png'; +import createScalarMap from './createScalarMap'; +import baseline from './testColorTransferFunctionPresets.png'; const MAX_NUMBER_OF_PRESETS = 200; const NUMBER_PER_LINE = 20; @@ -19,7 +19,9 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Colors', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -34,7 +36,7 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Colors', (t) => { let count = 0; colorMaps.forEach((preset, idx) => { if (preset.RGBPoints && count < MAX_NUMBER_OF_PRESETS) { - const i = (count % NUMBER_PER_LINE); + const i = count % NUMBER_PER_LINE; const j = Math.floor(count / NUMBER_PER_LINE); renderer.addActor(createScalarMap(i * 0.5, j * 1.25, preset, gc)); count += 1; @@ -45,7 +47,10 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Colors', (t) => { const glwindow = gc.registerResource(vtkOpenGLRenderWindow.newInstance()); glwindow.setContainer(renderWindowContainer); renderWindow.addView(glwindow); - glwindow.setSize(50 * NUMBER_PER_LINE, 150 * Math.floor(count / NUMBER_PER_LINE)); + glwindow.setSize( + 50 * NUMBER_PER_LINE, + 150 * Math.floor(count / NUMBER_PER_LINE) + ); const camera = renderer.getActiveCamera(); renderer.resetCamera(); @@ -53,5 +58,12 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Colors', (t) => { renderWindow.render(); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/Core/ColorTransferFunction/testColorTransferFunctionPresets', t, 4.8, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Rendering/Core/ColorTransferFunction/testColorTransferFunctionPresets', + t, + 4.8, + gc.releaseResources + ); }); diff --git a/Sources/Rendering/Core/Coordinate/index.js b/Sources/Rendering/Core/Coordinate/index.js index b342750dbd7..0e187808a50 100644 --- a/Sources/Rendering/Core/Coordinate/index.js +++ b/Sources/Rendering/Core/Coordinate/index.js @@ -1,6 +1,6 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import Constants from 'vtk.js/Sources/Rendering/Core/Coordinate/Constants'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; const { Coordinate } = Constants; const { vtkErrorMacro } = macro; @@ -73,7 +73,8 @@ function vtkCoordinate(publicAPI, model) { publicAPI.setCoordinateSystem(Coordinate.WORLD); }; - publicAPI.getCoordinateSystemAsString = () => macro.enumToString(Coordinate, model.coordinateSystem); + publicAPI.getCoordinateSystemAsString = () => + macro.enumToString(Coordinate, model.coordinateSystem); publicAPI.getComputedWorldValue = (ren) => { let val = model.computedWorldValue; @@ -94,14 +95,18 @@ function vtkCoordinate(publicAPI, model) { if (!renderer) { if (model.coordinateSystem === Coordinate.WORLD) { if (model.referenceCoordinate) { - const refValue = model.referenceCoordinate.getComputedWorldValue(renderer); + const refValue = model.referenceCoordinate.getComputedWorldValue( + renderer + ); val[0] += refValue[0]; val[1] += refValue[1]; val[2] += refValue[2]; } model.computing = 0; } else { - vtkErrorMacro('Attempt to compute world coordinates from another coordinate system without a renderer'); + vtkErrorMacro( + 'Attempt to compute world coordinates from another coordinate system without a renderer' + ); } return val; } @@ -114,28 +119,78 @@ function vtkCoordinate(publicAPI, model) { return model.computedWorldValue; } - if (model.referenceCoordinate && model.coordinateSystem !== Coordinate.WORLD) { - const fval = model.referenceCoordinate.getComputedDoubleDisplayValue(renderer); + if ( + model.referenceCoordinate && + model.coordinateSystem !== Coordinate.WORLD + ) { + const fval = model.referenceCoordinate.getComputedDoubleDisplayValue( + renderer + ); let refValue = [fval[0], fval[1], 0.0]; switch (model.coordinateSystem) { case Coordinate.NORMALIZED_DISPLAY: - refValue = view.displayToNormalizedDisplay(refValue[0], refValue[1], refValue[2]); + refValue = view.displayToNormalizedDisplay( + refValue[0], + refValue[1], + refValue[2] + ); break; case Coordinate.VIEWPORT: - refValue = view.displayToNormalizedDisplay(refValue[0], refValue[1], refValue[2]); - refValue = view.normalizedDisplayToViewport(refValue[0], refValue[1], refValue[2], renderer); + refValue = view.displayToNormalizedDisplay( + refValue[0], + refValue[1], + refValue[2] + ); + refValue = view.normalizedDisplayToViewport( + refValue[0], + refValue[1], + refValue[2], + renderer + ); break; case Coordinate.NORMALIZED_VIEWPORT: - refValue = view.displayToNormalizedDisplay(refValue[0], refValue[1], refValue[2]); - refValue = view.normalizedDisplayToViewport(refValue[0], refValue[1], refValue[2], renderer); - refValue = view.viewportToNormalizedViewport(refValue[0], refValue[1], refValue[2], renderer); + refValue = view.displayToNormalizedDisplay( + refValue[0], + refValue[1], + refValue[2] + ); + refValue = view.normalizedDisplayToViewport( + refValue[0], + refValue[1], + refValue[2], + renderer + ); + refValue = view.viewportToNormalizedViewport( + refValue[0], + refValue[1], + refValue[2], + renderer + ); break; case Coordinate.VIEW: - refValue = view.displayToNormalizedDisplay(refValue[0], refValue[1], refValue[2]); - refValue = view.normalizedDisplayToViewport(refValue[0], refValue[1], refValue[2], renderer); - refValue = view.viewportToNormalizedViewport(refValue[0], refValue[1], refValue[2], renderer); - refValue = renderer.normalizedViewportToView(refValue[0], refValue[1], refValue[2]); + refValue = view.displayToNormalizedDisplay( + refValue[0], + refValue[1], + refValue[2] + ); + refValue = view.normalizedDisplayToViewport( + refValue[0], + refValue[1], + refValue[2], + renderer + ); + refValue = view.viewportToNormalizedViewport( + refValue[0], + refValue[1], + refValue[2], + renderer + ); + refValue = renderer.normalizedViewportToView( + refValue[0], + refValue[1], + refValue[2] + ); break; default: break; @@ -152,19 +207,44 @@ function vtkCoordinate(publicAPI, model) { switch (model.coordinateSystem) { case Coordinate.DISPLAY: val = view.displayToNormalizedDisplay(val[0], val[1], val[2]); - val = view.normalizedDisplayToViewport(val[0], val[1], val[2], renderer); - val = view.viewportToNormalizedViewport(val[0], val[1], val[2], renderer); + val = view.normalizedDisplayToViewport( + val[0], + val[1], + val[2], + renderer + ); + val = view.viewportToNormalizedViewport( + val[0], + val[1], + val[2], + renderer + ); val = renderer.normalizedViewportToView(val[0], val[1], val[2]); val = renderer.viewToWorld(val[0], val[1], val[2], aspect); break; case Coordinate.NORMALIZED_DISPLAY: - val = view.normalizedDisplayToViewport(val[0], val[1], val[2], renderer); - val = view.viewportToNormalizedViewport(val[0], val[1], val[2], renderer); + val = view.normalizedDisplayToViewport( + val[0], + val[1], + val[2], + renderer + ); + val = view.viewportToNormalizedViewport( + val[0], + val[1], + val[2], + renderer + ); val = renderer.normalizedViewportToView(val[0], val[1], val[2]); val = renderer.viewToWorld(val[0], val[1], val[2], aspect); break; case Coordinate.VIEWPORT: - val = view.viewportToNormalizedViewport(val[0], val[1], val[2], renderer); + val = view.viewportToNormalizedViewport( + val[0], + val[1], + val[2], + renderer + ); val = renderer.normalizedViewportToView(val[0], val[1], val[2]); val = renderer.viewToWorld(val[0], val[1], val[2], aspect); break; @@ -179,7 +259,10 @@ function vtkCoordinate(publicAPI, model) { break; } - if (model.referenceCoordinate && model.coordinateSystem === Coordinate.WORLD) { + if ( + model.referenceCoordinate && + model.coordinateSystem === Coordinate.WORLD + ) { const refValue = publicAPI.getComputedWorldValue(renderer); val[0] += refValue[0]; val[1] += refValue[1]; @@ -210,7 +293,9 @@ function vtkCoordinate(publicAPI, model) { let val = publicAPI.getComputedDisplayValue(renderer); if (!renderer) { - vtkErrorMacro('Attempt to convert to local display coordinates without a renderer'); + vtkErrorMacro( + 'Attempt to convert to local display coordinates without a renderer' + ); return val; } @@ -271,7 +356,9 @@ function vtkCoordinate(publicAPI, model) { model.computedDoubleDisplayValue[0] = Number.MAX_VALUE; model.computedDoubleDisplayValue[1] = Number.MAX_VALUE; - vtkErrorMacro('Request for coordinate transformation without required viewport'); + vtkErrorMacro( + 'Request for coordinate transformation without required viewport' + ); } return model.computedDoubleDisplayValue; } @@ -288,7 +375,9 @@ function vtkCoordinate(publicAPI, model) { switch (model.coordinateSystem) { case Coordinate.WORLD: { if (model.referenceCoordinate) { - const refValue = model.referenceCoordinate.getComputedWorldValue(renderer); + const refValue = model.referenceCoordinate.getComputedWorldValue( + renderer + ); val[0] += refValue[0]; val[1] += refValue[1]; val[2] += refValue[2]; @@ -297,14 +386,24 @@ function vtkCoordinate(publicAPI, model) { val = renderer.viewToNormalizedViewport(val[0], val[1], val[2]); val = view.normalizedViewportToViewport(val[0], val[1], val[2]); - val = view.viewportToNormalizedDisplay(val[0], val[1], val[2], renderer); + val = view.viewportToNormalizedDisplay( + val[0], + val[1], + val[2], + renderer + ); val = view.normalizedDisplayToDisplay(val[0], val[1], val[2]); break; } case Coordinate.VIEW: { val = renderer.viewToNormalizedViewport(val[0], val[1], val[2]); val = view.normalizedViewportToViewport(val[0], val[1], val[2]); - val = view.viewportToNormalizedDisplay(val[0], val[1], val[2], renderer); + val = view.viewportToNormalizedDisplay( + val[0], + val[1], + val[2], + renderer + ); val = view.normalizedDisplayToDisplay(val[0], val[1], val[2]); break; } @@ -312,22 +411,36 @@ function vtkCoordinate(publicAPI, model) { val = view.normalizedViewportToViewport(val[0], val[1], val[2]); if (model.referenceCoordinate) { - const refValue = model.referenceCoordinate.getComputedDoubleViewportValue(renderer); + const refValue = model.referenceCoordinate.getComputedDoubleViewportValue( + renderer + ); val[0] += refValue[0]; val[1] += refValue[1]; } - val = view.viewportToNormalizedDisplay(val[0], val[1], val[2], renderer); + val = view.viewportToNormalizedDisplay( + val[0], + val[1], + val[2], + renderer + ); val = view.normalizedDisplayToDisplay(val[0], val[1], val[2]); break; } case Coordinate.VIEWPORT: { if (model.referenceCoordinate) { - const refValue = model.referenceCoordinate.getComputedDoubleViewportValue(renderer); + const refValue = model.referenceCoordinate.getComputedDoubleViewportValue( + renderer + ); val[0] += refValue[0]; val[1] += refValue[1]; } - val = view.viewportToNormalizedDisplay(val[0], val[1], val[2], renderer); + val = view.viewportToNormalizedDisplay( + val[0], + val[1], + val[2], + renderer + ); val = view.normalizedDisplayToDisplay(val[0], val[1], val[2]); break; } @@ -343,10 +456,14 @@ function vtkCoordinate(publicAPI, model) { } // if we have a reference coordinate and we haven't handled it yet - if (model.referenceCoordinate && + if ( + model.referenceCoordinate && (model.coordinateSystem === Coordinate.DISPLAY || - model.coordinateSystem === Coordinate.NORMALIZED_DISPLAY)) { - const refValue = model.referenceCoordinate.getComputedDoubleDisplayValue(renderer); + model.coordinateSystem === Coordinate.NORMALIZED_DISPLAY) + ) { + const refValue = model.referenceCoordinate.getComputedDoubleDisplayValue( + renderer + ); val[0] += refValue[0]; val[1] += refValue[1]; } @@ -419,9 +536,7 @@ export function extend(publicAPI, model, initialValues = {}) { 'renderer', ]); - macro.getArray(publicAPI, model, [ - 'value', - ], 3); + macro.getArray(publicAPI, model, ['value'], 3); // Object methods vtkCoordinate(publicAPI, model); diff --git a/Sources/Rendering/Core/Coordinate/test/testCoordinate.js b/Sources/Rendering/Core/Coordinate/test/testCoordinate.js index 1cfda34c3b1..965f38a41d1 100644 --- a/Sources/Rendering/Core/Coordinate/test/testCoordinate.js +++ b/Sources/Rendering/Core/Coordinate/test/testCoordinate.js @@ -1,4 +1,4 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; import vtkCamera from 'vtk.js/Sources/Rendering/Core/Camera'; @@ -10,12 +10,26 @@ import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; test('Test vtkCoordinate publicAPI', (t) => { const gc = testUtils.createGarbageCollector(t); - const testGetters = (coords, ren, value, world, display, localDisplay, viewPort) => { + const testGetters = ( + coords, + ren, + value, + world, + display, + localDisplay, + viewPort + ) => { coords.setValue(value); const currWorld = coords.getComputedWorldValue(ren); - const v0 = Number(parseFloat(Math.round(currWorld[0] * 100) / 100).toFixed(2)); - const v1 = Number(parseFloat(Math.round(currWorld[1] * 100) / 100).toFixed(2)); - const v2 = Number(parseFloat(Math.round(currWorld[2] * 100) / 100).toFixed(2)); + const v0 = Number( + parseFloat(Math.round(currWorld[0] * 100) / 100).toFixed(2) + ); + const v1 = Number( + parseFloat(Math.round(currWorld[1] * 100) / 100).toFixed(2) + ); + const v2 = Number( + parseFloat(Math.round(currWorld[2] * 100) / 100).toFixed(2) + ); t.deepEqual([v0, v1, v2], world); const currDisplay = coords.getComputedDisplayValue(ren); @@ -30,7 +44,9 @@ test('Test vtkCoordinate publicAPI', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view diff --git a/Sources/Rendering/Core/Glyph3DMapper/example/index.js b/Sources/Rendering/Core/Glyph3DMapper/example/index.js index c14c02f09c3..a43da7a091b 100644 --- a/Sources/Rendering/Core/Glyph3DMapper/example/index.js +++ b/Sources/Rendering/Core/Glyph3DMapper/example/index.js @@ -1,14 +1,14 @@ import 'vtk.js/Sources/favicon'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; -import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; -import vtkGlyph3DMapper from 'vtk.js/Sources/Rendering/Core/Glyph3DMapper'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; +import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; +import vtkGlyph3DMapper from 'vtk.js/Sources/Rendering/Core/Glyph3DMapper'; -import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; -import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; +import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; +import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; import controlPanel from './controlPanel.html'; @@ -16,7 +16,9 @@ import controlPanel from './controlPanel.html'; // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -30,41 +32,47 @@ const mapper = vtkGlyph3DMapper.newInstance(); const actor = vtkActor.newInstance(); simpleFilter.setFormula({ - getArrays: inputDataSets => ({ - input: [ - { location: FieldDataTypes.COORDINATE }], // Require point coordinates as input - output: [ // Generate two output arrays: + getArrays: (inputDataSets) => ({ + input: [{ location: FieldDataTypes.COORDINATE }], // Require point coordinates as input + output: [ + // Generate two output arrays: { - location: FieldDataTypes.POINT, // This array will be point-data ... - name: 'pressure', // ... with the given name ... - dataType: 'Float32Array', // ... of this type ... - numberOfComponents: 3, // ... with this many components ... + location: FieldDataTypes.POINT, // This array will be point-data ... + name: 'pressure', // ... with the given name ... + dataType: 'Float32Array', // ... of this type ... + numberOfComponents: 3, // ... with this many components ... }, { location: FieldDataTypes.POINT, // This array will be field data ... - name: 'temperature', // ... with the given name ... - dataType: 'Float32Array', // ... of this type ... + name: 'temperature', // ... with the given name ... + dataType: 'Float32Array', // ... of this type ... attribute: AttributeTypes.SCALARS, // ... and will be marked as the default scalars. - numberOfComponents: 1, // ... with this many components ... + numberOfComponents: 1, // ... with this many components ... }, - ] }), + ], + }), evaluate: (arraysIn, arraysOut) => { // Convert in the input arrays of vtkDataArrays into variables // referencing the underlying JavaScript typed-data arrays: - const [coords] = arraysIn.map(d => d.getData()); - const [press, temp] = arraysOut.map(d => d.getData()); + const [coords] = arraysIn.map((d) => d.getData()); + const [press, temp] = arraysOut.map((d) => d.getData()); // Since we are passed coords as a 3-component array, // loop over all the points and compute the point-data output: for (let i = 0, sz = coords.length / 3; i < sz; ++i) { - press[i * 3] = ((coords[3 * i] - 0.5) * (coords[3 * i] - 0.5)); - press[(i * 3) + 1] = (((coords[(3 * i) + 1] - 0.5) * (coords[(3 * i) + 1] - 0.5)) + 0.125) * 0.1; - press[(i * 3) + 2] = (((coords[3 * i] - 0.5) * (coords[3 * i] - 0.5)) + ((coords[(3 * i) + 1] - 0.5) * (coords[(3 * i) + 1] - 0.5)) + 0.125) * 0.1; - temp[i] = coords[(3 * i) + 1] * 0.1; + press[i * 3] = (coords[3 * i] - 0.5) * (coords[3 * i] - 0.5); + press[i * 3 + 1] = + ((coords[3 * i + 1] - 0.5) * (coords[3 * i + 1] - 0.5) + 0.125) * 0.1; + press[i * 3 + 2] = + ((coords[3 * i] - 0.5) * (coords[3 * i] - 0.5) + + (coords[3 * i + 1] - 0.5) * (coords[3 * i + 1] - 0.5) + + 0.125) * + 0.1; + temp[i] = coords[3 * i + 1] * 0.1; } // Mark the output vtkDataArray as modified - arraysOut.forEach(x => x.modified()); + arraysOut.forEach((x) => x.modified()); }, }); @@ -85,7 +93,6 @@ renderer.addActor(actor); renderer.resetCamera(); renderWindow.render(); - // ----------------------------------------------------------- // UI control handling // ----------------------------------------------------------- @@ -99,7 +106,6 @@ fullScreenRenderer.addController(controlPanel); }); }); - // ----------------------------------------------------------- // Make some variables global so that you can inspect and // modify objects in your browser's developer console: diff --git a/Sources/Rendering/Core/Glyph3DMapper/index.js b/Sources/Rendering/Core/Glyph3DMapper/index.js index 464472ad193..028d31644d9 100644 --- a/Sources/Rendering/Core/Glyph3DMapper/index.js +++ b/Sources/Rendering/Core/Glyph3DMapper/index.js @@ -1,9 +1,9 @@ import { mat3, mat4, vec3 } from 'gl-matrix'; import Constants from 'vtk.js/Sources/Rendering/Core/Glyph3DMapper/Constants'; -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; import vtkBoundingBox from 'vtk.js/Sources/Common/DataModel/BoundingBox'; const { OrientationModes, ScaleModes } = Constants; @@ -80,9 +80,11 @@ function vtkGlyph3DMapper(publicAPI, model) { // if the mtgime requires it, rebuild const idata = publicAPI.getInputData(0); const gdata = publicAPI.getInputData(1); - if (model.buildTime.getMTime() < gdata.getMTime() || - model.buildTime.getMTime() < idata.getMTime() || - model.buildTime.getMTime() < publicAPI.getMTime()) { + if ( + model.buildTime.getMTime() < gdata.getMTime() || + model.buildTime.getMTime() < idata.getMTime() || + model.buildTime.getMTime() < publicAPI.getMTime() + ) { const pts = idata.getPoints().getData(); let sArray = publicAPI.getScaleArrayData(); let sData = null; @@ -92,10 +94,15 @@ function vtkGlyph3DMapper(publicAPI, model) { numSComp = sArray.getNumberOfComponents(); } - if (model.scaling && sArray && - model.scaleMode === ScaleModes.SCALE_BY_COMPONENTS && - sArray.getNumberOfComponents() !== 3) { - vtkErrorMacro('Cannot scale by components since scale array does not have 3 components.'); + if ( + model.scaling && + sArray && + model.scaleMode === ScaleModes.SCALE_BY_COMPONENTS && + sArray.getNumberOfComponents() !== 3 + ) { + vtkErrorMacro( + 'Cannot scale by components since scale array does not have 3 components.' + ); sArray = null; } @@ -128,8 +135,8 @@ function vtkGlyph3DMapper(publicAPI, model) { for (let i = 0; i < numPts; ++i) { const z = new Float32Array(mbuff, i * 64, 16); trans[0] = pts[i * 3]; - trans[1] = pts[(i * 3) + 1]; - trans[2] = pts[(i * 3) + 2]; + trans[1] = pts[i * 3 + 1]; + trans[2] = pts[i * 3 + 2]; mat4.translate(z, identity, trans); if (oArray) { @@ -171,7 +178,7 @@ function vtkGlyph3DMapper(publicAPI, model) { switch (model.scaleMode) { case ScaleModes.SCALE_BY_MAGNITUDE: for (let t = 0; t < numSComp; ++t) { - tuple[t] = sData[(i * numSComp) + t]; + tuple[t] = sData[i * numSComp + t]; } scale[0] *= vtkMath.norm(tuple, numSComp); scale[1] = scale[0]; @@ -179,7 +186,7 @@ function vtkGlyph3DMapper(publicAPI, model) { break; case ScaleModes.SCALE_BY_COMPONENTS: for (let t = 0; t < numSComp; ++t) { - tuple[t] = sData[(i * numSComp) + t]; + tuple[t] = sData[i * numSComp + t]; } scale[0] *= tuple[0]; scale[1] *= tuple[1]; @@ -233,14 +240,17 @@ function vtkGlyph3DMapper(publicAPI, model) { // map scalars as well const scalars = publicAPI.getAbstractScalars( - idata, model.scalarMode, + idata, + model.scalarMode, model.arrayAccessMode, model.arrayId, - model.colorByArrayName); + model.colorByArrayName + ); if (!model.useLookupTableScalarRange) { - publicAPI.getLookupTable().setRange( - model.scalarRange[0], model.scalarRange[1]); + publicAPI + .getLookupTable() + .setRange(model.scalarRange[0], model.scalarRange[1]); } model.colorArray = null; @@ -314,4 +324,3 @@ export const newInstance = macro.newInstance(extend, 'vtkGlyph3DMapper'); // ---------------------------------------------------------------------------- export default Object.assign({ newInstance, extend }, Constants); - diff --git a/Sources/Rendering/Core/Glyph3DMapper/test/testGlyph3DMapper.js b/Sources/Rendering/Core/Glyph3DMapper/test/testGlyph3DMapper.js index 95bec402900..ca878d42634 100644 --- a/Sources/Rendering/Core/Glyph3DMapper/test/testGlyph3DMapper.js +++ b/Sources/Rendering/Core/Glyph3DMapper/test/testGlyph3DMapper.js @@ -1,17 +1,17 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; -import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; -import vtkGlyph3DMapper from 'vtk.js/Sources/Rendering/Core/Glyph3DMapper'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; +import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; +import vtkGlyph3DMapper from 'vtk.js/Sources/Rendering/Core/Glyph3DMapper'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; -import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; +import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; +import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; import baseline from './testGlyph3DMapper.png'; @@ -21,7 +21,9 @@ test.onlyIfWebGL('Test vtkGlyph3DMapper Rendering', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -36,40 +38,46 @@ test.onlyIfWebGL('Test vtkGlyph3DMapper Rendering', (t) => { const actor = vtkActor.newInstance(); simpleFilter.setFormula({ - getArrays: inputDataSets => ({ - input: [ - { location: FieldDataTypes.COORDINATE }], // Require point coordinates as input - output: [ // Generate two output arrays: + getArrays: (inputDataSets) => ({ + input: [{ location: FieldDataTypes.COORDINATE }], // Require point coordinates as input + output: [ + // Generate two output arrays: { - location: FieldDataTypes.POINT, // This array will be point-data ... - name: 'pressure', // ... with the given name ... - dataType: 'Float32Array', // ... of this type ... - numberOfComponents: 3, // ... with this many components ... + location: FieldDataTypes.POINT, // This array will be point-data ... + name: 'pressure', // ... with the given name ... + dataType: 'Float32Array', // ... of this type ... + numberOfComponents: 3, // ... with this many components ... }, { location: FieldDataTypes.POINT, // This array will be field data ... - name: 'temperature', // ... with the given name ... - dataType: 'Float32Array', // ... of this type ... + name: 'temperature', // ... with the given name ... + dataType: 'Float32Array', // ... of this type ... attribute: AttributeTypes.SCALARS, // ... and will be marked as the default scalars. - numberOfComponents: 1, // ... with this many components ... + numberOfComponents: 1, // ... with this many components ... }, - ] }), + ], + }), evaluate: (arraysIn, arraysOut) => { // Convert in the input arrays of vtkDataArrays into variables // referencing the underlying JavaScript typed-data arrays: - const [coords] = arraysIn.map(d => d.getData()); - const [press, temp] = arraysOut.map(d => d.getData()); + const [coords] = arraysIn.map((d) => d.getData()); + const [press, temp] = arraysOut.map((d) => d.getData()); // Since we are passed coords as a 3-component array, // loop over all the points and compute the point-data output: for (let i = 0, sz = coords.length / 3; i < sz; ++i) { - press[i * 3] = ((coords[3 * i] - 0.5) * (coords[3 * i] - 0.5)); - press[(i * 3) + 1] = (((coords[(3 * i) + 1] - 0.5) * (coords[(3 * i) + 1] - 0.5)) + 0.125) * 0.1; - press[(i * 3) + 2] = (((coords[3 * i] - 0.5) * (coords[3 * i] - 0.5)) + ((coords[(3 * i) + 1] - 0.5) * (coords[(3 * i) + 1] - 0.5)) + 0.125) * 0.1; - temp[i] = coords[(3 * i) + 1] * 0.1; + press[i * 3] = (coords[3 * i] - 0.5) * (coords[3 * i] - 0.5); + press[i * 3 + 1] = + ((coords[3 * i + 1] - 0.5) * (coords[3 * i + 1] - 0.5) + 0.125) * 0.1; + press[i * 3 + 2] = + ((coords[3 * i] - 0.5) * (coords[3 * i] - 0.5) + + (coords[3 * i + 1] - 0.5) * (coords[3 * i + 1] - 0.5) + + 0.125) * + 0.1; + temp[i] = coords[3 * i + 1] * 0.1; } // Mark the output vtkDataArray as modified - arraysOut.forEach(x => x.modified()); + arraysOut.forEach((x) => x.modified()); }, }); @@ -98,5 +106,12 @@ test.onlyIfWebGL('Test vtkGlyph3DMapper Rendering', (t) => { renderWindow.render(); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/Core/Glyph3DMapper/testGlyph3DMapper', t, 1.0, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Rendering/Core/Glyph3DMapper/testGlyph3DMapper', + t, + 1.0, + gc.releaseResources + ); }); diff --git a/Sources/Rendering/Core/ImageMapper/example/index.js b/Sources/Rendering/Core/ImageMapper/example/index.js index 45f9b9f5206..72ae1c55303 100644 --- a/Sources/Rendering/Core/ImageMapper/example/index.js +++ b/Sources/Rendering/Core/ImageMapper/example/index.js @@ -1,10 +1,10 @@ import 'vtk.js/Sources/favicon'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkRTAnalyticSource from 'vtk.js/Sources/Filters/Sources/RTAnalyticSource'; -import vtkImageMapper from 'vtk.js/Sources/Rendering/Core/ImageMapper'; -import vtkImageSlice from 'vtk.js/Sources/Rendering/Core/ImageSlice'; -import vtkInteractorStyleImage from 'vtk.js/Sources/Interaction/Style/InteractorStyleImage'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkRTAnalyticSource from 'vtk.js/Sources/Filters/Sources/RTAnalyticSource'; +import vtkImageMapper from 'vtk.js/Sources/Rendering/Core/ImageMapper'; +import vtkImageSlice from 'vtk.js/Sources/Rendering/Core/ImageSlice'; +import vtkInteractorStyleImage from 'vtk.js/Sources/Interaction/Style/InteractorStyleImage'; // ---------------------------------------------------------------------------- // Standard rendering code setup diff --git a/Sources/Rendering/Core/ImageMapper/index.js b/Sources/Rendering/Core/ImageMapper/index.js index 523a6d919cd..48ce09e78bf 100644 --- a/Sources/Rendering/Core/ImageMapper/index.js +++ b/Sources/Rendering/Core/ImageMapper/index.js @@ -1,8 +1,8 @@ -import Constants from 'vtk.js/Sources/Rendering/Core/ImageMapper/Constants'; -import macro from 'vtk.js/Sources/macro'; -import vtkAbstractMapper from 'vtk.js/Sources/Rendering/Core/AbstractMapper'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; -import vtkPlane from 'vtk.js/Sources/Common/DataModel/Plane'; +import Constants from 'vtk.js/Sources/Rendering/Core/ImageMapper/Constants'; +import macro from 'vtk.js/Sources/macro'; +import vtkAbstractMapper from 'vtk.js/Sources/Rendering/Core/AbstractMapper'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkPlane from 'vtk.js/Sources/Common/DataModel/Plane'; import { vec3 } from 'gl-matrix'; @@ -67,7 +67,11 @@ function vtkImageMapper(publicAPI, model) { const extent = imageData.getExtent(); // Slice origin - const ijk = [model.xSlice + extent[0], model.ySlice + extent[2], model.zSlice + extent[4]]; + const ijk = [ + model.xSlice + extent[0], + model.ySlice + extent[2], + model.zSlice + extent[4], + ]; const worldOrigin = [0, 0, 0]; imageData.indexToWorld(ijk, worldOrigin); @@ -80,16 +84,26 @@ function vtkImageMapper(publicAPI, model) { worldNormal[2] -= worldOrigin[2]; vec3.normalize(worldNormal, worldNormal); - const intersect = vtkPlane.intersectWithLine(p1, p2, worldOrigin, worldNormal); + const intersect = vtkPlane.intersectWithLine( + p1, + p2, + worldOrigin, + worldNormal + ); if (intersect.intersection) { const point = intersect.x; const absoluteIJK = [0, 0, 0]; imageData.worldToIndex(point, absoluteIJK); // Are we outside our actual extent/bounds - if (absoluteIJK[0] < extent[0] || absoluteIJK[0] > extent[1] - || absoluteIJK[1] < extent[2] || absoluteIJK[1] > extent[3] - || absoluteIJK[2] < extent[4] || absoluteIJK[2] > extent[5]) { + if ( + absoluteIJK[0] < extent[0] || + absoluteIJK[0] > extent[1] || + absoluteIJK[1] < extent[2] || + absoluteIJK[1] > extent[3] || + absoluteIJK[2] < extent[4] || + absoluteIJK[2] > extent[5] + ) { return null; } @@ -112,7 +126,11 @@ function vtkImageMapper(publicAPI, model) { const extent = imageData.getExtent(); // Slice origin - const ijk = [model.xSlice + extent[0], model.ySlice + extent[2], model.zSlice + extent[4]]; + const ijk = [ + model.xSlice + extent[0], + model.ySlice + extent[2], + model.zSlice + extent[4], + ]; const worldOrigin = [0, 0, 0]; imageData.indexToWorld(ijk, worldOrigin); @@ -125,17 +143,26 @@ function vtkImageMapper(publicAPI, model) { worldNormal[2] -= worldOrigin[2]; vec3.normalize(worldNormal, worldNormal); - const intersect = vtkPlane.intersectWithLine(p1, p2, worldOrigin, worldNormal); + const intersect = vtkPlane.intersectWithLine( + p1, + p2, + worldOrigin, + worldNormal + ); if (intersect.intersection) { const point = intersect.x; const absoluteIJK = [0, 0, 0]; imageData.worldToIndex(point, absoluteIJK); - // Are we outside our actual extent/bounds - if (absoluteIJK[0] < extent[0] || absoluteIJK[0] > extent[1] - || absoluteIJK[1] < extent[2] || absoluteIJK[1] > extent[3] - || absoluteIJK[2] < extent[4] || absoluteIJK[2] > extent[5]) { + if ( + absoluteIJK[0] < extent[0] || + absoluteIJK[0] > extent[1] || + absoluteIJK[1] < extent[2] || + absoluteIJK[1] > extent[3] || + absoluteIJK[2] < extent[4] || + absoluteIJK[2] > extent[5] + ) { return null; } @@ -187,9 +214,7 @@ export function extend(publicAPI, model, initialValues = {}) { 'renderToRectangle', 'sliceAtFocalPoint', ]); - macro.setGetArray(publicAPI, model, [ - 'customDisplayExtent', - ], 4); + macro.setGetArray(publicAPI, model, ['customDisplayExtent'], 4); // Object methods vtkImageMapper(publicAPI, model); diff --git a/Sources/Rendering/Core/ImageProperty/index.js b/Sources/Rendering/Core/ImageProperty/index.js index f4c5036a758..2a63f823ad4 100644 --- a/Sources/Rendering/Core/ImageProperty/index.js +++ b/Sources/Rendering/Core/ImageProperty/index.js @@ -42,7 +42,7 @@ export function extend(publicAPI, model, initialValues = {}) { let mTime = model.mtime; if (model.rGBTransferFunction !== null) { const time = model.rGBTransferFunction.getMTime(); - mTime = (time > mTime ? time : mTime); + mTime = time > mTime ? time : mTime; } return mTime; diff --git a/Sources/Rendering/Core/ImageSlice/index.js b/Sources/Rendering/Core/ImageSlice/index.js index 4b2b79f68d7..1dd279ad86f 100644 --- a/Sources/Rendering/Core/ImageSlice/index.js +++ b/Sources/Rendering/Core/ImageSlice/index.js @@ -1,6 +1,6 @@ -import { vec3, mat4 } from 'gl-matrix'; -import macro from 'vtk.js/Sources/macro'; -import vtkProp3D from 'vtk.js/Sources/Rendering/Core/Prop3D'; +import { vec3, mat4 } from 'gl-matrix'; +import macro from 'vtk.js/Sources/macro'; +import vtkProp3D from 'vtk.js/Sources/Rendering/Core/Prop3D'; import vtkImageProperty from 'vtk.js/Sources/Rendering/Core/ImageProperty'; const { vtkDebugMacro } = macro; @@ -58,12 +58,17 @@ function vtkImageSlice(publicAPI, model) { // of caching. If the values returned this time are different, or // the modified time of this class is newer than the cached time, // then we need to rebuild. - const zip = rows => rows[0].map((_, c) => rows.map(row => row[c])); - if (!model.mapperBounds || - !zip([bds, model.mapperBounds]).reduce((a, b) => (a && b[0] === b[1]), true) || - publicAPI.getMTime() > model.boundsMTime.getMTime()) { + const zip = (rows) => rows[0].map((_, c) => rows.map((row) => row[c])); + if ( + !model.mapperBounds || + !zip([bds, model.mapperBounds]).reduce( + (a, b) => a && b[0] === b[1], + true + ) || + publicAPI.getMTime() > model.boundsMTime.getMTime() + ) { vtkDebugMacro('Recomputing bounds...'); - model.mapperBounds = bds.map(x => x); + model.mapperBounds = bds.map((x) => x); const bbox = [ vec3.fromValues(bds[1], bds[3], bds[5]), vec3.fromValues(bds[1], bds[2], bds[5]), @@ -78,15 +83,21 @@ function vtkImageSlice(publicAPI, model) { publicAPI.computeMatrix(); const tmp4 = mat4.create(); mat4.transpose(tmp4, model.matrix); - bbox.forEach(pt => vec3.transformMat4(pt, pt, tmp4)); + bbox.forEach((pt) => vec3.transformMat4(pt, pt, tmp4)); /* eslint-disable no-multi-assign */ model.bounds[0] = model.bounds[2] = model.bounds[4] = Number.MAX_VALUE; model.bounds[1] = model.bounds[3] = model.bounds[5] = -Number.MAX_VALUE; /* eslint-enable no-multi-assign */ - model.bounds = model.bounds.map((d, i) => ((i % 2 === 0) ? - bbox.reduce((a, b) => (a > b[i / 2] ? b[i / 2] : a), d) : - bbox.reduce((a, b) => (a < b[(i - 1) / 2] ? b[(i - 1) / 2] : a), d))); + model.bounds = model.bounds.map( + (d, i) => + i % 2 === 0 + ? bbox.reduce((a, b) => (a > b[i / 2] ? b[i / 2] : a), d) + : bbox.reduce( + (a, b) => (a < b[(i - 1) / 2] ? b[(i - 1) / 2] : a), + d + ) + ); model.boundsMTime.modified(); } return model.bounds; @@ -133,7 +144,7 @@ function vtkImageSlice(publicAPI, model) { let mt = model.mtime; if (model.property !== null) { const time = model.property.getMTime(); - mt = (time > mt ? time : mt); + mt = time > mt ? time : mt; } return mt; @@ -143,26 +154,27 @@ function vtkImageSlice(publicAPI, model) { let mt = model.mtime; if (model.mapper !== null) { let time = model.mapper.getMTime(); - mt = (time > mt ? time : mt); + mt = time > mt ? time : mt; if (model.mapper.getInput() !== null) { // FIXME !!! getInputAlgorithm / getInput model.mapper.getInputAlgorithm().update(); time = model.mapper.getInput().getMTime(); - mt = (time > mt ? time : mt); + mt = time > mt ? time : mt; } } if (model.property !== null) { let time = model.property.getMTime(); - mt = (time > mt ? time : mt); + mt = time > mt ? time : mt; if (model.property.getRGBTransferFunction() !== null) { time = model.property.getRGBTransferFunction().getMTime(); - mt = (time > mt ? time : mt); + mt = time > mt ? time : mt; } } return mt; }; - publicAPI.getSupportsSelection = () => (model.mapper ? model.mapper.getSupportsSelection() : false); + publicAPI.getSupportsSelection = () => + model.mapper ? model.mapper.getSupportsSelection() : false; } // ---------------------------------------------------------------------------- @@ -190,9 +202,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.set(publicAPI, model, ['property']); - macro.setGet(publicAPI, model, [ - 'mapper', - ]); + macro.setGet(publicAPI, model, ['mapper']); macro.getArray(publicAPI, model, ['bounds'], 6); // Object methods diff --git a/Sources/Rendering/Core/InteractorObserver/index.js b/Sources/Rendering/Core/InteractorObserver/index.js index 0b8f94a9e95..fabe36baafc 100644 --- a/Sources/Rendering/Core/InteractorObserver/index.js +++ b/Sources/Rendering/Core/InteractorObserver/index.js @@ -42,16 +42,16 @@ function vtkInteractorObserver(publicAPI, model) { return; } - // Since the observer mediator is bound to the interactor, reset it to - // 0 so that the next time it is requested, it is queried from the - // new interactor. - // Furthermore, remove ourself from the mediator queue. + // Since the observer mediator is bound to the interactor, reset it to + // 0 so that the next time it is requested, it is queried from the + // new interactor. + // Furthermore, remove ourself from the mediator queue. - // if (this->ObserverMediator) - // { - // this->ObserverMediator->RemoveAllCursorShapeRequests(this); - // this->ObserverMediator = 0; - // } + // if (this->ObserverMediator) + // { + // this->ObserverMediator->RemoveAllCursorShapeRequests(this); + // this->ObserverMediator = 0; + // } // if we already have an Interactor then stop observing it if (model.interactor) { @@ -66,12 +66,12 @@ function vtkInteractorObserver(publicAPI, model) { // add observers for each of the events handled in ProcessEvents if (i) { - model.charObserverTag = i.onCharEvent( - publicAPI.keyPressCallbackCommand); - // this->Priority); + model.charObserverTag = i.onCharEvent(publicAPI.keyPressCallbackCommand); + // this->Priority); model.deleteObserverTag = i.onDeleteEvent( - publicAPI.keyPressCallbackCommand); - // this->Priority); + publicAPI.keyPressCallbackCommand + ); + // this->Priority); // publicAPI.registerPickers(); } @@ -86,8 +86,9 @@ function vtkInteractorObserver(publicAPI, model) { return null; } - return model.interactor.getView().displayToWorld( - x, y, z, model.currentRenderer); + return model.interactor + .getView() + .displayToWorld(x, y, z, model.currentRenderer); }; //---------------------------------------------------------------------------- @@ -98,32 +99,31 @@ function vtkInteractorObserver(publicAPI, model) { return null; } - return model.interactor.getView().worldToDisplay( - x, y, z, model.currentRenderer); + return model.interactor + .getView() + .worldToDisplay(x, y, z, model.currentRenderer); }; //---------------------------------------------------------------------------- publicAPI.grabFocus = () => { - // void vtkInteractorObserver::GrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents) - // { - // if ( this->Interactor ) - // { - // this->Interactor->GrabFocus(mouseEvents,keypressEvents); - // } + // void vtkInteractorObserver::GrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents) + // { + // if ( this->Interactor ) + // { + // this->Interactor->GrabFocus(mouseEvents,keypressEvents); + // } }; - //---------------------------------------------------------------------------- publicAPI.releaseFocus = () => { - // void vtkInteractorObserver::ReleaseFocus() - // { - // if ( this->Interactor ) - // { - // this->Interactor->ReleaseFocus(); - // } + // void vtkInteractorObserver::ReleaseFocus() + // { + // if ( this->Interactor ) + // { + // this->Interactor->ReleaseFocus(); + // } }; - // //---------------------------------------------------------------------------- // void vtkInteractorObserver::StartInteraction() // { @@ -165,15 +165,10 @@ export function extend(publicAPI, model, initialValues = {}) { macro.event(publicAPI, model, 'EndInteractionEvent'); // Create get-only macros - macro.get(publicAPI, model, [ - 'interactor', - ]); + macro.get(publicAPI, model, ['interactor']); // Create get-set macros - macro.setGet(publicAPI, model, [ - 'priority', - 'currentRenderer', - ]); + macro.setGet(publicAPI, model, ['priority', 'currentRenderer']); // For more macro methods, see "Sources/macro.js" diff --git a/Sources/Rendering/Core/InteractorStyle/index.js b/Sources/Rendering/Core/InteractorStyle/index.js index 324b0fd287a..59eef1ff2bc 100644 --- a/Sources/Rendering/Core/InteractorStyle/index.js +++ b/Sources/Rendering/Core/InteractorStyle/index.js @@ -1,6 +1,6 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkInteractorObserver from 'vtk.js/Sources/Rendering/Core/InteractorObserver'; -import Constants from 'vtk.js/Sources/Rendering/Core/InteractorStyle/Constants'; +import Constants from 'vtk.js/Sources/Rendering/Core/InteractorStyle/Constants'; const { States } = Constants; const { vtkWarningMacro } = macro; @@ -80,11 +80,12 @@ function vtkInteractorStyle(publicAPI, model) { if (i) { events.forEach((eventName) => { model.unsubscribes.push( - i[`on${eventName}`]((data) => { - if (publicAPI[`handle${eventName}`]) { - publicAPI[`handle${eventName}`](data); - } - })); + i[`on${eventName}`]((data) => { + if (publicAPI[`handle${eventName}`]) { + publicAPI[`handle${eventName}`](data); + } + }) + ); }); } }; @@ -112,8 +113,8 @@ function vtkInteractorStyle(publicAPI, model) { let pos = null; switch (rwi.getKeyCode()) { - case 'r' : - case 'R' : + case 'r': + case 'R': pos = model.interactor.getEventPosition(rwi.getPointerIndex()); publicAPI.findPokedRenderer(pos.x, pos.y); if (model.currentRenderer !== 0) { @@ -124,8 +125,8 @@ function vtkInteractorStyle(publicAPI, model) { rwi.render(); break; - case 'w' : - case 'W' : + case 'w': + case 'W': pos = model.interactor.getEventPosition(rwi.getPointerIndex()); publicAPI.findPokedRenderer(pos.x, pos.y); if (model.currentRenderer !== 0) { @@ -139,8 +140,8 @@ function vtkInteractorStyle(publicAPI, model) { rwi.render(); break; - case 's' : - case 'S' : + case 's': + case 'S': pos = model.interactor.getEventPosition(rwi.getPointerIndex()); publicAPI.findPokedRenderer(pos.x, pos.y); if (model.currentRenderer !== 0) { @@ -154,8 +155,8 @@ function vtkInteractorStyle(publicAPI, model) { rwi.render(); break; - case 'v' : - case 'V' : + case 'v': + case 'V': pos = model.interactor.getEventPosition(rwi.getPointerIndex()); publicAPI.findPokedRenderer(pos.x, pos.y); if (model.currentRenderer !== 0) { diff --git a/Sources/Rendering/Core/Light/index.js b/Sources/Rendering/Core/Light/index.js index ed5e03844f2..c7c1669f163 100644 --- a/Sources/Rendering/Core/Light/index.js +++ b/Sources/Rendering/Core/Light/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkMath from 'vtk.js/Sources/Common/Core/Math'; // ---------------------------------------------------------------------------- @@ -45,7 +45,8 @@ function vtkLight(publicAPI, model) { publicAPI.setPosition( Math.cos(elevationRadians) * Math.sin(azimuthRadians), Math.sin(elevationRadians), - Math.cos(elevationRadians) * Math.cos(azimuthRadians)); + Math.cos(elevationRadians) * Math.cos(azimuthRadians) + ); publicAPI.setFocalPoint(0, 0, 0); publicAPI.setPositional(0); @@ -109,12 +110,12 @@ export function extend(publicAPI, model, initialValues = {}) { 'lightType', 'shadowAttenuation', ]); - macro.setGetArray(publicAPI, model, [ - 'color', - 'position', - 'focalPoint', - 'attenuationValues', - ], 3); + macro.setGetArray( + publicAPI, + model, + ['color', 'position', 'focalPoint', 'attenuationValues'], + 3 + ); // Object methods vtkLight(publicAPI, model); diff --git a/Sources/Rendering/Core/Mapper/index.js b/Sources/Rendering/Core/Mapper/index.js index ba31e4947cf..7ca8656a947 100644 --- a/Sources/Rendering/Core/Mapper/index.js +++ b/Sources/Rendering/Core/Mapper/index.js @@ -1,14 +1,14 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkAbstractMapper3D from 'vtk.js/Sources/Rendering/Core/AbstractMapper3D'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkImageData from 'vtk.js/Sources/Common/DataModel/ImageData'; -import vtkLookupTable from 'vtk.js/Sources/Common/Core/LookupTable'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; -import vtkScalarsToColors from 'vtk.js/Sources/Common/Core/ScalarsToColors/Constants'; // Need to go inside Constants otherwise dependency loop +import macro from 'vtk.js/Sources/macro'; +import vtkAbstractMapper3D from 'vtk.js/Sources/Rendering/Core/AbstractMapper3D'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkImageData from 'vtk.js/Sources/Common/DataModel/ImageData'; +import vtkLookupTable from 'vtk.js/Sources/Common/Core/LookupTable'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkScalarsToColors from 'vtk.js/Sources/Common/Core/ScalarsToColors/Constants'; // Need to go inside Constants otherwise dependency loop import CoincidentTopologyHelper from 'vtk.js/Sources/Rendering/Core/Mapper/CoincidentTopologyHelper'; -import otherStaticMethods from 'vtk.js/Sources/Rendering/Core/Mapper/Static'; -import Constants from 'vtk.js/Sources/Rendering/Core/Mapper/Constants'; +import otherStaticMethods from 'vtk.js/Sources/Rendering/Core/Mapper/Static'; +import Constants from 'vtk.js/Sources/Rendering/Core/Mapper/Constants'; const { ColorMode, ScalarMode, GetArray } = Constants; const { VectorMode } = vtkScalarsToColors; @@ -32,8 +32,10 @@ const staticOffsetAPI = {}; CoincidentTopologyHelper.addCoincidentTopologyMethods( staticOffsetAPI, staticOffsetModel, - CoincidentTopologyHelper.CATEGORIES - .map(key => ({ key, method: `ResolveCoincidentTopology${key}OffsetParameters` })), + CoincidentTopologyHelper.CATEGORIES.map((key) => ({ + key, + method: `ResolveCoincidentTopology${key}OffsetParameters`, + })) ); // ---------------------------------------------------------------------------- @@ -66,13 +68,15 @@ function vtkMapper(publicAPI, model) { model.lookupTable = vtkLookupTable.newInstance(); }; - publicAPI.getColorModeAsString = () => macro.enumToString(ColorMode, model.colorMode); + publicAPI.getColorModeAsString = () => + macro.enumToString(ColorMode, model.colorMode); publicAPI.setColorModeToDefault = () => publicAPI.setColorMode(0); publicAPI.setColorModeToMapScalars = () => publicAPI.setColorMode(1); publicAPI.setColorModeToDirectScalars = () => publicAPI.setColorMode(2); - publicAPI.getScalarModeAsString = () => macro.enumToString(ScalarMode, model.scalarMode); + publicAPI.getScalarModeAsString = () => + macro.enumToString(ScalarMode, model.scalarMode); publicAPI.setScalarModeToDefault = () => publicAPI.setScalarMode(0); publicAPI.setScalarModeToUsePointData = () => publicAPI.setScalarMode(1); @@ -99,8 +103,10 @@ function vtkMapper(publicAPI, model) { CoincidentTopologyHelper.addCoincidentTopologyMethods( publicAPI, model.topologyOffset, - CoincidentTopologyHelper.CATEGORIES - .map(key => ({ key, method: `RelativeCoincidentTopology${key}OffsetParameters` })), + CoincidentTopologyHelper.CATEGORIES.map((key) => ({ + key, + method: `RelativeCoincidentTopology${key}OffsetParameters`, + })) ); /* eslint-enable arrow-body-style */ @@ -131,8 +137,13 @@ function vtkMapper(publicAPI, model) { }; }; - publicAPI.getAbstractScalars = (input, scalarMode, arrayAccessMode, - arrayId, arrayName) => { + publicAPI.getAbstractScalars = ( + input, + scalarMode, + arrayAccessMode, + arrayId, + arrayName + ) => { // make sure we have an input if (!input || !model.scalarVisibility) { return null; @@ -177,8 +188,13 @@ function vtkMapper(publicAPI, model) { }; publicAPI.mapScalars = (input, alpha) => { - const scalars = publicAPI.getAbstractScalars(input, model.scalarMode, - model.arrayAccessMode, model.arrayId, model.colorByArrayName); + const scalars = publicAPI.getAbstractScalars( + input, + model.scalarMode, + model.arrayAccessMode, + model.arrayId, + model.colorByArrayName + ); if (!scalars) { model.colorCoordinates = null; @@ -188,8 +204,9 @@ function vtkMapper(publicAPI, model) { } if (!model.useLookupTableScalarRange) { - publicAPI.getLookupTable().setRange( - model.scalarRange[0], model.scalarRange[1]); + publicAPI + .getLookupTable() + .setRange(model.scalarRange[0], model.scalarRange[1]); } // Decide betweeen texture color or vertex color. @@ -213,11 +230,13 @@ function vtkMapper(publicAPI, model) { //----------------------------------------------------------------------------- publicAPI.scalarToTextureCoordinate = ( - scalarValue, // Input scalar - rangeMin, // range[0] - invRangeWidth) => { // 1/(range[1]-range[0]) - let texCoordS = 0.5; // Scalar value is arbitrary when NaN - let texCoordT = 1.0; // 1.0 in t coordinate means NaN + scalarValue, // Input scalar + rangeMin, // range[0] + invRangeWidth + ) => { + // 1/(range[1]-range[0]) + let texCoordS = 0.5; // Scalar value is arbitrary when NaN + let texCoordT = 1.0; // 1.0 in t coordinate means NaN if (!vtkMath.isNan(scalarValue)) { // 0.0 in t coordinate means not NaN. So why am I setting it to 0.49? // Because when you are mapping scalars and you have a NaN adjacent to @@ -256,13 +275,13 @@ function vtkMapper(publicAPI, model) { range, tableRange, tableNumberOfColors, - useLogScale) => { + useLogScale + ) => { // We have to change the range used for computing texture // coordinates slightly to accomodate the special above- and // below-range colors that are the first and last texels, // respectively. - const scalarTexelWidth = - (range[1] - range[0]) / tableNumberOfColors; + const scalarTexelWidth = (range[1] - range[0]) / tableNumberOfColors; const paddedRange = []; paddedRange[0] = range[0] - scalarTexelWidth; @@ -278,18 +297,22 @@ function vtkMapper(publicAPI, model) { for (let scalarIdx = 0; scalarIdx < numScalars; ++scalarIdx) { let sum = 0; for (let compIdx = 0; compIdx < numComps; ++compIdx) { - sum += (inputV[count] * inputV[count]); + sum += inputV[count] * inputV[count]; count++; } let magnitude = Math.sqrt(sum); if (useLogScale) { magnitude = vtkLookupTable.applyLogScale( - magnitude, tableRange, range); + magnitude, + tableRange, + range + ); } - const outputs = - publicAPI.scalarToTextureCoordinate( - magnitude, paddedRange[0], - invRangeWidth); + const outputs = publicAPI.scalarToTextureCoordinate( + magnitude, + paddedRange[0], + invRangeWidth + ); outputV[outputCount] = outputs.texCoordS; outputV[outputCount + 1] = outputs.texCoordT; outputCount += 2; @@ -300,11 +323,16 @@ function vtkMapper(publicAPI, model) { let inputValue = inputV[count]; if (useLogScale) { inputValue = vtkLookupTable.applyLogScale( - inputValue, tableRange, range); + inputValue, + tableRange, + range + ); } - const outputs = - publicAPI.scalarToTextureCoordinate( - inputValue, paddedRange[0], invRangeWidth); + const outputs = publicAPI.scalarToTextureCoordinate( + inputValue, + paddedRange[0], + invRangeWidth + ); outputV[outputCount] = outputs.texCoordS; outputV[outputCount + 1] = outputs.texCoordT; outputCount += 2; @@ -330,10 +358,12 @@ function vtkMapper(publicAPI, model) { // If the lookup table has changed, then recreate the color texture map. // Set a new lookup table changes this->MTime. - if (model.colorTextureMap == null || - publicAPI.getMTime() > model.colorTextureMap.getMTime() || - model.lookupTable.getMTime() > model.colorTextureMap.getMTime() || - model.lookupTable.getAlpha() !== alpha) { + if ( + model.colorTextureMap == null || + publicAPI.getMTime() > model.colorTextureMap.getMTime() || + model.lookupTable.getMTime() > model.colorTextureMap.getMTime() || + model.lookupTable.getAlpha() !== alpha + ) { model.lookupTable.setAlpha(alpha); model.colorTextureMap = null; @@ -351,7 +381,7 @@ function vtkMapper(publicAPI, model) { const newArray = new Float64Array(numberOfColors * 2); for (let i = 0; i < numberOfColors; ++i) { - newArray[i] = range[0] + (i * k) - k; // minus k to start at below range color + newArray[i] = range[0] + i * k - k; // minus k to start at below range color if (useLogScale) { newArray[i] = Math.pow(10.0, newArray[i]); } @@ -362,23 +392,28 @@ function vtkMapper(publicAPI, model) { } model.colorTextureMap = vtkImageData.newInstance(); - model.colorTextureMap.setExtent( - 0, numberOfColors - 1, 0, 1, 0, 0); + model.colorTextureMap.setExtent(0, numberOfColors - 1, 0, 1, 0, 0); - const tmp = vtkDataArray.newInstance({ numberOfComponents: 1, values: newArray }); + const tmp = vtkDataArray.newInstance({ + numberOfComponents: 1, + values: newArray, + }); - model.colorTextureMap.getPointData().setScalars( - model.lookupTable.mapScalars(tmp, model.colorMode, 0)); + model.colorTextureMap + .getPointData() + .setScalars(model.lookupTable.mapScalars(tmp, model.colorMode, 0)); model.lookupTable.setAlpha(origAlpha); } // Create new coordinates if necessary. // Need to compare lookup table incase the range has changed. - if (!model.colorCoordinates || - publicAPI.getMTime() > model.colorCoordinates.getMTime() || - publicAPI.getInputData(0).getMTime() > + if ( + !model.colorCoordinates || + publicAPI.getMTime() > model.colorCoordinates.getMTime() || + publicAPI.getInputData(0).getMTime() > model.colorCoordinates.getMTime() || - model.lookupTable.getMTime() > model.colorCoordinates.getMTime()) { + model.lookupTable.getMTime() > model.colorCoordinates.getMTime() + ) { // Get rid of old colors model.colorCoordinates = null; @@ -387,25 +422,37 @@ function vtkMapper(publicAPI, model) { const num = scalars.getNumberOfTuples(); // const fArray = new FloatArray(num * 2); - model.colorCoordinates = - vtkDataArray.newInstance({ numberOfComponents: 2, values: new Float32Array(num * 2) }); + model.colorCoordinates = vtkDataArray.newInstance({ + numberOfComponents: 2, + values: new Float32Array(num * 2), + }); let scalarComponent = model.lookupTable.getVectorComponent(); // Although I like the feature of applying magnitude to single component // scalars, it is not how the old MapScalars for vertex coloring works. - if (model.lookupTable.getVectorMode() === VectorMode.MAGNITUDE && - scalars.getNumberOfComponents() > 1) { + if ( + model.lookupTable.getVectorMode() === VectorMode.MAGNITUDE && + scalars.getNumberOfComponents() > 1 + ) { scalarComponent = -1; } publicAPI.createColorTextureCoordinates( scalars, model.colorCoordinates, - num, numComps, - scalarComponent, range, + num, + numComps, + scalarComponent, + range, model.lookupTable.getRange(), - (model.colorTextureMap.getPointData().getScalars().getNumberOfTuples() / 2) - 2, - useLogScale); + model.colorTextureMap + .getPointData() + .getScalars() + .getNumberOfTuples() / + 2 - + 2, + useLogScale + ); } }; @@ -425,8 +472,7 @@ function vtkMapper(publicAPI, model) { } // index color does not use textures - if (model.lookupTable && - model.lookupTable.getIndexedLookup()) { + if (model.lookupTable && model.lookupTable.getIndexedLookup()) { return false; } @@ -450,7 +496,7 @@ function vtkMapper(publicAPI, model) { let mt = model.mtime; if (model.lookupTable !== null) { const time = model.lookupTable.getMTime(); - mt = (time > mt ? time : mt); + mt = time > mt ? time : mt; } return mt; }; @@ -459,14 +505,22 @@ function vtkMapper(publicAPI, model) { const input = publicAPI.getInputData(); const pcount = { points: input.getPoints().getNumberOfValues(), - verts: input.getVerts().getNumberOfValues() - input.getVerts().getNumberOfCells(), - lines: input.getLines().getNumberOfValues() - (2 * input.getLines().getNumberOfCells()), - triangles: input.getPolys().getNumberOfValues() - (3 * input.getLines().getNumberOfCells()), + verts: + input.getVerts().getNumberOfValues() - + input.getVerts().getNumberOfCells(), + lines: + input.getLines().getNumberOfValues() - + 2 * input.getLines().getNumberOfCells(), + triangles: + input.getPolys().getNumberOfValues() - + 3 * input.getLines().getNumberOfCells(), }; return pcount; }; - publicAPI.acquireInvertibleLookupTable = notImplemented('AcquireInvertibleLookupTable'); + publicAPI.acquireInvertibleLookupTable = notImplemented( + 'AcquireInvertibleLookupTable' + ); publicAPI.valueToColor = notImplemented('ValueToColor'); publicAPI.colorToValue = notImplemented('ColorToValue'); publicAPI.useInvertibleColorFor = notImplemented('UseInvertibleColorFor'); @@ -538,9 +592,7 @@ export function extend(publicAPI, model, initialValues = {}) { 'useLookupTableScalarRange', 'viewSpecificProperties', ]); - macro.setGetArray(publicAPI, model, [ - 'scalarRange', - ], 2); + macro.setGetArray(publicAPI, model, ['scalarRange'], 2); if (!model.viewSpecificProperties) { model.viewSpecificProperties = {}; @@ -556,4 +608,9 @@ export const newInstance = macro.newInstance(extend, 'vtkMapper'); // ---------------------------------------------------------------------------- -export default Object.assign({ newInstance, extend }, staticOffsetAPI, otherStaticMethods, Constants); +export default Object.assign( + { newInstance, extend }, + staticOffsetAPI, + otherStaticMethods, + Constants +); diff --git a/Sources/Rendering/Core/Mapper/test/testEdgeVisibility.js b/Sources/Rendering/Core/Mapper/test/testEdgeVisibility.js index 9305719bbdf..7a783f47cbf 100644 --- a/Sources/Rendering/Core/Mapper/test/testEdgeVisibility.js +++ b/Sources/Rendering/Core/Mapper/test/testEdgeVisibility.js @@ -1,12 +1,12 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import baseline from './testEdgeVisibility.png'; @@ -16,7 +16,9 @@ test.onlyIfWebGL('Test Edge Visibility', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -43,5 +45,12 @@ test.onlyIfWebGL('Test Edge Visibility', (t) => { glwindow.setSize(400, 400); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/Core/Mapper/testEdgeVisibility.js', t, 5, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Rendering/Core/Mapper/testEdgeVisibility.js', + t, + 5, + gc.releaseResources + ); }); diff --git a/Sources/Rendering/Core/Mapper/test/testVectorComponent.js b/Sources/Rendering/Core/Mapper/test/testVectorComponent.js index d00b8f971e7..1a02c31ff68 100644 --- a/Sources/Rendering/Core/Mapper/test/testVectorComponent.js +++ b/Sources/Rendering/Core/Mapper/test/testVectorComponent.js @@ -1,13 +1,13 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkLookupTable from 'vtk.js/Sources/Common/Core/LookupTable'; +import vtkLookupTable from 'vtk.js/Sources/Common/Core/LookupTable'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import baseline from './testVectorComponent.png'; @@ -19,7 +19,9 @@ test.onlyIfWebGL('Test VectorComponent', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -58,5 +60,12 @@ test.onlyIfWebGL('Test VectorComponent', (t) => { renderWindow.render(); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/Core/Mapper/testVectorComponent.js', t, 5, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Rendering/Core/Mapper/testVectorComponent.js', + t, + 5, + gc.releaseResources + ); }); diff --git a/Sources/Rendering/Core/Picker/index.js b/Sources/Rendering/Core/Picker/index.js index 4b015ed10aa..e1e288338d0 100644 --- a/Sources/Rendering/Core/Picker/index.js +++ b/Sources/Rendering/Core/Picker/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkAbstractPicker from 'vtk.js/Sources/Rendering/Core/AbstractPicker'; import vtkBox from 'vtk.js/Sources/Common/DataModel/Box'; import vtkMath from 'vtk.js/Sources/Common/Core/Math'; @@ -54,7 +54,11 @@ function vtkPicker(publicAPI, model) { } // Project the center point onto the ray and determine its parametric value - const t = ((ray[0] * (center[0] - p1[0])) + (ray[1] * (center[1] - p1[1])) + (ray[2] * (center[2] - p1[2]))) / rayFactor; + const t = + (ray[0] * (center[0] - p1[0]) + + ray[1] * (center[1] - p1[1]) + + ray[2] * (center[2] - p1[2])) / + rayFactor; return t; }; @@ -110,15 +114,32 @@ function vtkPicker(publicAPI, model) { cameraPos = camera.getPosition(); cameraFP = camera.getFocalPoint(); - displayCoords = renderer.worldToNormalizedDisplay(cameraFP[0], cameraFP[1], cameraFP[2]); - displayCoords = view.normalizedDisplayToDisplay(displayCoords[0], displayCoords[1], displayCoords[2]); + displayCoords = renderer.worldToNormalizedDisplay( + cameraFP[0], + cameraFP[1], + cameraFP[2] + ); + displayCoords = view.normalizedDisplayToDisplay( + displayCoords[0], + displayCoords[1], + displayCoords[2] + ); selectionZ = displayCoords[2]; // Convert the selection point into world coordinates. - const normalizedDisplay = view.displayToNormalizedDisplay(selectionX, selectionY, selectionZ); + const normalizedDisplay = view.displayToNormalizedDisplay( + selectionX, + selectionY, + selectionZ + ); const dims = view.getViewportSize(renderer); const aspect = dims[0] / dims[1]; - worldCoords = renderer.normalizedDisplayToWorld(normalizedDisplay[0], normalizedDisplay[1], normalizedDisplay[2], aspect); + worldCoords = renderer.normalizedDisplayToWorld( + normalizedDisplay[0], + normalizedDisplay[1], + normalizedDisplay[2], + aspect + ); for (let i = 0; i < 3; i++) { model.pickPosition[i] = worldCoords[i]; @@ -149,41 +170,63 @@ function vtkPicker(publicAPI, model) { tF = clipRange[0] - rayLength; tB = clipRange[1] - rayLength; for (let i = 0; i < 3; i++) { - p1World[i] = model.pickPosition[i] + (tF * cameraDOP[i]); - p2World[i] = model.pickPosition[i] + (tB * cameraDOP[i]); + p1World[i] = model.pickPosition[i] + tF * cameraDOP[i]; + p2World[i] = model.pickPosition[i] + tB * cameraDOP[i]; } } else { tF = clipRange[0] / rayLength; tB = clipRange[1] / rayLength; for (let i = 0; i < 3; i++) { - p1World[i] = cameraPos[i] + (tF * ray[i]); - p2World[i] = cameraPos[i] + (tB * ray[i]); + p1World[i] = cameraPos[i] + tF * ray[i]; + p2World[i] = cameraPos[i] + tB * ray[i]; } } p1World[3] = 1.0; p2World[3] = 1.0; - // Compute the tolerance in world coordinates. Do this by // determining the world coordinates of the diagonal points of the // window, computing the width of the window in world coordinates, and // multiplying by the tolerance. viewport = renderer.getViewport(); if (renderer.getRenderWindow()) { - winSize = renderer.getRenderWindow().getViews()[0].getSize(); + winSize = renderer + .getRenderWindow() + .getViews()[0] + .getSize(); } x = winSize[0] * viewport[0]; y = winSize[1] * viewport[1]; - const normalizedLeftDisplay = view.displayToNormalizedDisplay(x, y, selectionZ); - windowLowerLeft = renderer.normalizedDisplayToWorld(normalizedLeftDisplay[0], normalizedLeftDisplay[1], normalizedLeftDisplay[2], aspect); + const normalizedLeftDisplay = view.displayToNormalizedDisplay( + x, + y, + selectionZ + ); + windowLowerLeft = renderer.normalizedDisplayToWorld( + normalizedLeftDisplay[0], + normalizedLeftDisplay[1], + normalizedLeftDisplay[2], + aspect + ); x = winSize[0] * viewport[2]; y = winSize[1] * viewport[3]; - const normalizedRightDisplay = view.displayToNormalizedDisplay(x, y, selectionZ); - windowUpperRight = renderer.normalizedDisplayToWorld(normalizedRightDisplay[0], normalizedRightDisplay[1], normalizedRightDisplay[2], aspect); + const normalizedRightDisplay = view.displayToNormalizedDisplay( + x, + y, + selectionZ + ); + windowUpperRight = renderer.normalizedDisplayToWorld( + normalizedRightDisplay[0], + normalizedRightDisplay[1], + normalizedRightDisplay[2], + aspect + ); for (let i = 0; i < 3; i++) { - tol += (windowUpperRight[i] - windowLowerLeft[i]) * (windowUpperRight[i] - windowLowerLeft[i]); + tol += + (windowUpperRight[i] - windowLowerLeft[i]) * + (windowUpperRight[i] - windowLowerLeft[i]); } tol = Math.sqrt(tol) * model.tolerance; @@ -207,9 +250,21 @@ function vtkPicker(publicAPI, model) { mat4.transpose(model.transformMatrix, model.transformMatrix); mat4.invert(model.transformMatrix, model.transformMatrix); // Extract scale - const col1 = [model.transformMatrix[0], model.transformMatrix[1], model.transformMatrix[2]]; - const col2 = [model.transformMatrix[4], model.transformMatrix[5], model.transformMatrix[6]]; - const col3 = [model.transformMatrix[8], model.transformMatrix[9], model.transformMatrix[10]]; + const col1 = [ + model.transformMatrix[0], + model.transformMatrix[1], + model.transformMatrix[2], + ]; + const col2 = [ + model.transformMatrix[4], + model.transformMatrix[5], + model.transformMatrix[6], + ]; + const col3 = [ + model.transformMatrix[8], + model.transformMatrix[9], + model.transformMatrix[10], + ]; scale[0] = vtkMath.norm(col1); scale[1] = vtkMath.norm(col2); scale[2] = vtkMath.norm(col3); @@ -234,12 +289,17 @@ function vtkPicker(publicAPI, model) { } if (vtkBox.intersectBox(bounds, p1Mapper, ray, hitPosition, t)) { - t[0] = publicAPI.intersectWithLine(p1Mapper, p2Mapper, tol * 0.333 * (scale[0] + scale[1] + scale[2]), mapper); + t[0] = publicAPI.intersectWithLine( + p1Mapper, + p2Mapper, + tol * 0.333 * (scale[0] + scale[1] + scale[2]), + mapper + ); if (t[0] < Number.MAX_VALUE) { const p = []; - p[0] = ((1.0 - t[0]) * p1World[0]) + (t[0] * p2World[0]); - p[1] = ((1.0 - t[0]) * p1World[1]) + (t[0] * p2World[1]); - p[2] = ((1.0 - t[0]) * p1World[2]) + (t[0] * p2World[2]); + p[0] = (1.0 - t[0]) * p1World[0] + t[0] * p2World[0]; + p[1] = (1.0 - t[0]) * p1World[1] + t[0] * p2World[1]; + p[2] = (1.0 - t[0]) * p1World[2] + t[0] * p2World[2]; // Check if the current actor is already in the list let actorID = -1; @@ -291,9 +351,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Inheritance vtkAbstractPicker.extend(publicAPI, model, initialValues); - macro.setGet(publicAPI, model, [ - 'tolerance', - ]); + macro.setGet(publicAPI, model, ['tolerance']); macro.setGetArray(publicAPI, model, ['mapperPosition'], 3); macro.get(publicAPI, model, [ 'mapper', diff --git a/Sources/Rendering/Core/PixelSpaceCallbackMapper/index.js b/Sources/Rendering/Core/PixelSpaceCallbackMapper/index.js index 4f9e4687f00..fcdd2b09bbf 100644 --- a/Sources/Rendering/Core/PixelSpaceCallbackMapper/index.js +++ b/Sources/Rendering/Core/PixelSpaceCallbackMapper/index.js @@ -1,6 +1,6 @@ import { mat4, vec3 } from 'gl-matrix'; -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; // ---------------------------------------------------------------------------- @@ -14,7 +14,13 @@ function vtkPixelSpaceCallbackMapper(publicAPI, model) { model.callback = () => {}; } - publicAPI.invokeCallback = (dataset, camera, aspect, windowSize, depthValues) => { + publicAPI.invokeCallback = ( + dataset, + camera, + aspect, + windowSize, + depthValues + ) => { if (!model.callback) { return; } @@ -32,17 +38,19 @@ function vtkPixelSpaceCallbackMapper(publicAPI, model) { for (let pidx = 0; pidx < dataPoints.getNumberOfPoints(); pidx += 1) { const point = dataPoints.getPoint(pidx); - result[0] = point[0]; result[1] = point[1]; result[2] = point[2]; + result[0] = point[0]; + result[1] = point[1]; + result[2] = point[2]; vec3.transformMat4(result, result, matrix); - const coord = [(result[0] * hw) + hw, (result[1] * hh) + hh, result[2], 0]; + const coord = [result[0] * hw + hw, result[1] * hh + hh, result[2], 0]; if (depthValues) { - const linIdx = (Math.floor(coord[1]) * width) + Math.floor(coord[0]); + const linIdx = Math.floor(coord[1]) * width + Math.floor(coord[0]); const idx = linIdx * 4; const r = depthValues[idx] / 255; const g = depthValues[idx + 1] / 255; - const z = ((r * 256) + g) / 257; - coord[3] = (z * 2) - 1; + const z = (r * 256 + g) / 257; + coord[3] = z * 2 - 1; } coords.push(coord); @@ -69,10 +77,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Inheritance vtkMapper.extend(publicAPI, model, initialValues); - macro.setGet(publicAPI, model, [ - 'callback', - 'useZValues', - ]); + macro.setGet(publicAPI, model, ['callback', 'useZValues']); // Object methods vtkPixelSpaceCallbackMapper(publicAPI, model); @@ -80,9 +85,11 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkPixelSpaceCallbackMapper'); +export const newInstance = macro.newInstance( + extend, + 'vtkPixelSpaceCallbackMapper' +); // ---------------------------------------------------------------------------- export default { newInstance, extend }; - diff --git a/Sources/Rendering/Core/PointPicker/example/PickerInteractorStyle.js b/Sources/Rendering/Core/PointPicker/example/PickerInteractorStyle.js index 2a16aa425ee..6058b8df245 100644 --- a/Sources/Rendering/Core/PointPicker/example/PickerInteractorStyle.js +++ b/Sources/Rendering/Core/PointPicker/example/PickerInteractorStyle.js @@ -1,8 +1,8 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkInteractorStyleTrackballCamera from 'vtk.js/Sources/Interaction/Style/InteractorStyleTrackballCamera'; -import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; // ---------------------------------------------------------------------------- // vtkInteractorStyleTrackballCamera2 methods @@ -15,7 +15,9 @@ function vtkPickerInteractorStyle(publicAPI, model) { const superClass = Object.assign({}, publicAPI); publicAPI.handleLeftButtonPress = () => { - const pos = model.interactor.getEventPosition(model.interactor.getPointerIndex()); + const pos = model.interactor.getEventPosition( + model.interactor.getPointerIndex() + ); publicAPI.findPokedRenderer(pos.x, pos.y); if (model.currentRenderer === null) { return; @@ -59,9 +61,7 @@ function vtkPickerInteractorStyle(publicAPI, model) { // ---------------------------------------------------------------------------- // Object factory // ---------------------------------------------------------------------------- -const DEFAULT_VALUES = { - -}; +const DEFAULT_VALUES = {}; export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); @@ -69,14 +69,16 @@ export function extend(publicAPI, model, initialValues = {}) { // Inheritance vtkInteractorStyleTrackballCamera.extend(publicAPI, model, initialValues); - // Object specific methods vtkPickerInteractorStyle(publicAPI, model); } // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkPickerInteractorStyle'); +export const newInstance = macro.newInstance( + extend, + 'vtkPickerInteractorStyle' +); // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/Core/PointPicker/example/index.js b/Sources/Rendering/Core/PointPicker/example/index.js index 95251583fa7..d51bd6d5d4f 100644 --- a/Sources/Rendering/Core/PointPicker/example/index.js +++ b/Sources/Rendering/Core/PointPicker/example/index.js @@ -1,12 +1,12 @@ import 'vtk.js/Sources/favicon'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkOutlineFilter from 'vtk.js/Sources/Filters/General/OutlineFilter'; -import vtkPickerInteractorStyle from 'vtk.js/Sources/Rendering/Core/PointPicker/example/PickerInteractorStyle'; -import vtkPointPicker from 'vtk.js/Sources/Rendering/Core/PointPicker'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkOutlineFilter from 'vtk.js/Sources/Filters/General/OutlineFilter'; +import vtkPickerInteractorStyle from 'vtk.js/Sources/Rendering/Core/PointPicker/example/PickerInteractorStyle'; +import vtkPointPicker from 'vtk.js/Sources/Rendering/Core/PointPicker'; // ---------------------------------------------------------------------------- // Standard rendering code setup diff --git a/Sources/Rendering/Core/PointPicker/index.js b/Sources/Rendering/Core/PointPicker/index.js index b265ae2d471..6ee5d46e24f 100644 --- a/Sources/Rendering/Core/PointPicker/index.js +++ b/Sources/Rendering/Core/PointPicker/index.js @@ -1,5 +1,5 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import macro from 'vtk.js/Sources/macro'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; import vtkPicker from 'vtk.js/Sources/Rendering/Core/Picker'; const { vtkErrorMacro } = macro; @@ -51,29 +51,38 @@ function vtkPointPicker(publicAPI, model) { const nbCells = input.getPolys().getNumberOfCells(); for (let cellID = 0; cellID < nbCells; cellID++) { - const firstPointIndex = (cellID * nbPointsPerCell) + 1; + const firstPointIndex = cellID * nbPointsPerCell + 1; const lastPointIndex = firstPointIndex + nbPointsPerCell; - for (let pointIndex = firstPointIndex; pointIndex < lastPointIndex; pointIndex++) { + for ( + let pointIndex = firstPointIndex; + pointIndex < lastPointIndex; + pointIndex++ + ) { const pointDataIndex = cellData[pointIndex]; points.getPoint(pointDataIndex, x); - t = ((ray[0] * (x[0] - p1[0])) + (ray[1] * (x[1] - p1[1])) + (ray[2] * (x[2] - p1[2]))) / rayFactor; + t = + (ray[0] * (x[0] - p1[0]) + + ray[1] * (x[1] - p1[1]) + + ray[2] * (x[2] - p1[2])) / + rayFactor; // If we find a point closer than we currently have, see whether it // lies within the pick tolerance and clipping planes. We keep track // of the point closest to the line (use a fudge factor for points // nearly the same distance away.) - if (t >= 0.0 && t <= 1.0 && t <= (tMin + model.tolerance)) { + if (t >= 0.0 && t <= 1.0 && t <= tMin + model.tolerance) { let maxDist = 0.0; for (let i = 0; i < 3; i++) { - projXYZ[i] = p1[i] + (t * ray[i]); + projXYZ[i] = p1[i] + t * ray[i]; const dist = Math.abs(x[i] - projXYZ[i]); if (dist > maxDist) { maxDist = dist; } } // end for i - if (maxDist <= tol && maxDist < minPtDist) { // within tolerance + if (maxDist <= tol && maxDist < minPtDist) { + // within tolerance minPtId = ptId; minXYZ[0] = x[0]; minXYZ[1] = x[1]; @@ -84,26 +93,32 @@ function vtkPointPicker(publicAPI, model) { } } // end for pointIndex } // end for cellID - } else { // end if model.useCells + } else { + // end if model.useCells for (ptId = 0; ptId < numPts; ptId++) { points.getPoint(ptId, x); - t = ((ray[0] * (x[0] - p1[0])) + (ray[1] * (x[1] - p1[1])) + (ray[2] * (x[2] - p1[2]))) / rayFactor; + t = + (ray[0] * (x[0] - p1[0]) + + ray[1] * (x[1] - p1[1]) + + ray[2] * (x[2] - p1[2])) / + rayFactor; // If we find a point closer than we currently have, see whether it // lies within the pick tolerance and clipping planes. We keep track // of the point closest to the line (use a fudge factor for points // nearly the same distance away.) - if (t >= 0.0 && t <= 1.0 && t <= (tMin + model.tolerance)) { + if (t >= 0.0 && t <= 1.0 && t <= tMin + model.tolerance) { let maxDist = 0.0; for (let i = 0; i < 3; i++) { - projXYZ[i] = p1[i] + (t * ray[i]); + projXYZ[i] = p1[i] + t * ray[i]; const dist = Math.abs(x[i] - projXYZ[i]); if (dist > maxDist) { maxDist = dist; } } // end for i - if (maxDist <= tol && maxDist < minPtDist) { // within tolerance + if (maxDist <= tol && maxDist < minPtDist) { + // within tolerance minPtId = ptId; minXYZ[0] = x[0]; minXYZ[1] = x[1]; diff --git a/Sources/Rendering/Core/Prop/index.js b/Sources/Rendering/Core/Prop/index.js index 60160d3797b..df43d545ae6 100644 --- a/Sources/Rendering/Core/Prop/index.js +++ b/Sources/Rendering/Core/Prop/index.js @@ -55,7 +55,8 @@ function vtkProp(publicAPI, model) { publicAPI.getSupportsSelection = () => false; publicAPI.getTextures = () => model.textures; - publicAPI.hasTexture = texture => !!model.textures.filter(item => item === texture).length; + publicAPI.hasTexture = (texture) => + !!model.textures.filter((item) => item === texture).length; publicAPI.addTexture = (texture) => { if (texture && !publicAPI.hasTexture(texture)) { model.textures = model.textures.concat(texture); @@ -64,7 +65,7 @@ function vtkProp(publicAPI, model) { }; publicAPI.removeTexture = (texture) => { - const newTextureList = model.textures.filter(item => item === texture); + const newTextureList = model.textures.filter((item) => item === texture); if (model.texture.length !== newTextureList.length) { model.textures = newTextureList; publicAPI.modified(); @@ -101,10 +102,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.obj(publicAPI, model); - macro.get(publicAPI, model, [ - 'estimatedRenderTime', - 'allocatedRenderTime', - ]); + macro.get(publicAPI, model, ['estimatedRenderTime', 'allocatedRenderTime']); macro.setGet(publicAPI, model, [ 'visibility', 'pickable', diff --git a/Sources/Rendering/Core/Prop3D/index.js b/Sources/Rendering/Core/Prop3D/index.js index a7dd3921a6e..a4409212c78 100644 --- a/Sources/Rendering/Core/Prop3D/index.js +++ b/Sources/Rendering/Core/Prop3D/index.js @@ -1,9 +1,9 @@ import { vec3, quat, mat4 } from 'gl-matrix'; -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkBoundingBox from 'vtk.js/Sources/Common/DataModel/BoundingBox'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; -import vtkProp from 'vtk.js/Sources/Rendering/Core/Prop'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkProp from 'vtk.js/Sources/Rendering/Core/Prop'; function notImplemented(method) { return () => macro.vtkErrorMacro(`vtkProp3D::${method} - NOT IMPLEMENTED`); @@ -18,7 +18,9 @@ function vtkProp3D(publicAPI, model) { model.classHierarchy.push('vtkProp3D'); publicAPI.addPosition = (deltaXYZ) => { - model.position = model.position.map((value, index) => value + deltaXYZ[index]); + model.position = model.position.map( + (value, index) => value + deltaXYZ[index] + ); publicAPI.modified(); }; @@ -35,13 +37,15 @@ function vtkProp3D(publicAPI, model) { publicAPI.getOrientation = notImplemented('getOrientation'); publicAPI.setOrientation = notImplemented('setOrientation'); - publicAPI.rotateX = (val) => { if (val === 0.0) { return; } - mat4.rotateX(model.rotation, model.rotation, - vtkMath.radiansFromDegrees(val)); + mat4.rotateX( + model.rotation, + model.rotation, + vtkMath.radiansFromDegrees(val) + ); publicAPI.modified(); }; @@ -49,8 +53,11 @@ function vtkProp3D(publicAPI, model) { if (val === 0.0) { return; } - mat4.rotateY(model.rotation, model.rotation, - vtkMath.radiansFromDegrees(val)); + mat4.rotateY( + model.rotation, + model.rotation, + vtkMath.radiansFromDegrees(val) + ); publicAPI.modified(); }; @@ -58,8 +65,11 @@ function vtkProp3D(publicAPI, model) { if (val === 0.0) { return; } - mat4.rotateZ(model.rotation, model.rotation, - vtkMath.radiansFromDegrees(val)); + mat4.rotateZ( + model.rotation, + model.rotation, + vtkMath.radiansFromDegrees(val) + ); publicAPI.modified(); }; @@ -101,14 +111,18 @@ function vtkProp3D(publicAPI, model) { mat4.translate(model.matrix, model.matrix, model.position); mat4.multiply(model.matrix, model.matrix, model.rotation); mat4.scale(model.matrix, model.matrix, model.scale); - mat4.translate(model.matrix, model.matrix, [-model.origin[0], -model.origin[1], -model.origin[2]]); + mat4.translate(model.matrix, model.matrix, [ + -model.origin[0], + -model.origin[1], + -model.origin[2], + ]); mat4.transpose(model.matrix, model.matrix); // check for identity model.isIdentity = true; for (let i = 0; i < 4; ++i) { for (let j = 0; j < 4; ++j) { - if ((i === j ? 1.0 : 0.0) !== model.matrix[i + (j * 4)]) { + if ((i === j ? 1.0 : 0.0) !== model.matrix[i + j * 4]) { model.isIdentity = false; } } @@ -163,16 +177,13 @@ export function extend(publicAPI, model, initialValues = {}) { macro.obj(model.matrixMTime); // Build VTK API - macro.get(publicAPI, model, [ - 'bounds', - 'isIdentity', - ]); - macro.setGetArray(publicAPI, model, [ - 'origin', - 'position', - 'orientation', - 'scale', - ], 3); + macro.get(publicAPI, model, ['bounds', 'isIdentity']); + macro.setGetArray( + publicAPI, + model, + ['origin', 'position', 'orientation', 'scale'], + 3 + ); // Object internal instance model.matrix = mat4.create(); diff --git a/Sources/Rendering/Core/Prop3D/test/testUserMatrix.js b/Sources/Rendering/Core/Prop3D/test/testUserMatrix.js index ee181190631..380bef691e5 100644 --- a/Sources/Rendering/Core/Prop3D/test/testUserMatrix.js +++ b/Sources/Rendering/Core/Prop3D/test/testUserMatrix.js @@ -1,12 +1,12 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkOBJReader from 'vtk.js/Sources/IO/Misc/OBJReader'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkOBJReader from 'vtk.js/Sources/IO/Misc/OBJReader'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; import { mat4 } from 'gl-matrix'; @@ -18,7 +18,9 @@ test.onlyIfWebGL('Test Set Actor User Matrix', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -30,7 +32,9 @@ test.onlyIfWebGL('Test Set Actor User Matrix', (t) => { // ---------------------------------------------------------------------------- // Test code // ---------------------------------------------------------------------------- - const reader = gc.registerResource(vtkOBJReader.newInstance({ splitMode: 'usemtl' })); + const reader = gc.registerResource( + vtkOBJReader.newInstance({ splitMode: 'usemtl' }) + ); const mapper = gc.registerResource(vtkMapper.newInstance()); mapper.setInputConnection(reader.getOutputPort()); @@ -45,17 +49,27 @@ test.onlyIfWebGL('Test Set Actor User Matrix', (t) => { actor.rotateZ(45); - reader.setUrl(`${__BASE_PATH__}/Data/obj/space-shuttle-orbiter/space-shuttle-orbiter.obj`).then(() => { - renderer.resetCamera(); - renderWindow.render(); + reader + .setUrl( + `${__BASE_PATH__}/Data/obj/space-shuttle-orbiter/space-shuttle-orbiter.obj` + ) + .then(() => { + renderer.resetCamera(); + renderWindow.render(); - const glwindow = gc.registerResource(vtkOpenGLRenderWindow.newInstance()); - glwindow.setContainer(renderWindowContainer); - renderWindow.addView(glwindow); - glwindow.setSize(400, 400); + const glwindow = gc.registerResource(vtkOpenGLRenderWindow.newInstance()); + glwindow.setContainer(renderWindowContainer); + renderWindow.addView(glwindow); + glwindow.setSize(400, 400); - const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/Core/Prop3D/testUserMatrix', t, 1.5, gc.releaseResources); - }); + const image = glwindow.captureImage(); + testUtils.compareImages( + image, + [baseline], + 'Rendering/Core/Prop3D/testUserMatrix', + t, + 1.5, + gc.releaseResources + ); + }); }); - diff --git a/Sources/Rendering/Core/Property/index.js b/Sources/Rendering/Core/Property/index.js index 218286be1b9..41386f2eb6e 100644 --- a/Sources/Rendering/Core/Property/index.js +++ b/Sources/Rendering/Core/Property/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import Constants from 'vtk.js/Sources/Rendering/Core/Property/Constants'; const { Representation, Interpolation } = Constants; @@ -32,15 +32,16 @@ function vtkProperty(publicAPI, model) { publicAPI.getColor = () => { // Inline computeCompositeColor let norm = 0.0; - if ((model.ambient + model.diffuse + model.specular) > 0) { + if (model.ambient + model.diffuse + model.specular > 0) { norm = 1.0 / (model.ambient + model.diffuse + model.specular); } for (let i = 0; i < 3; i++) { - model.color[i] = norm * ( - (model.ambient * model.ambientColor[i]) + - (model.diffuse * model.diffuseColor[i]) + - (model.specular * model.specularColor[i])); + model.color[i] = + norm * + (model.ambient * model.ambientColor[i] + + model.diffuse * model.diffuseColor[i] + + model.specular * model.specularColor[i]); } return [].concat(model.color); @@ -48,15 +49,23 @@ function vtkProperty(publicAPI, model) { publicAPI.addShaderVariable = notImplemented('AddShaderVariable'); - publicAPI.setInterpolationToFlat = () => publicAPI.setInterpolation(Interpolation.FLAT); - publicAPI.setInterpolationToGouraud = () => publicAPI.setInterpolation(Interpolation.GOURAUD); - publicAPI.setInterpolationToPhong = () => publicAPI.setInterpolation(Interpolation.PHONG); - publicAPI.getInterpolationAsString = () => macro.enumToString(Interpolation, model.interpolation); - - publicAPI.setRepresentationToWireframe = () => publicAPI.setRepresentation(Representation.WIREFRAME); - publicAPI.setRepresentationToSurface = () => publicAPI.setRepresentation(Representation.SURFACE); - publicAPI.setRepresentationToPoints = () => publicAPI.setRepresentation(Representation.POINTS); - publicAPI.getRepresentationAsString = () => macro.enumToString(Representation, model.representation); + publicAPI.setInterpolationToFlat = () => + publicAPI.setInterpolation(Interpolation.FLAT); + publicAPI.setInterpolationToGouraud = () => + publicAPI.setInterpolation(Interpolation.GOURAUD); + publicAPI.setInterpolationToPhong = () => + publicAPI.setInterpolation(Interpolation.PHONG); + publicAPI.getInterpolationAsString = () => + macro.enumToString(Interpolation, model.interpolation); + + publicAPI.setRepresentationToWireframe = () => + publicAPI.setRepresentation(Representation.WIREFRAME); + publicAPI.setRepresentationToSurface = () => + publicAPI.setRepresentation(Representation.SURFACE); + publicAPI.setRepresentationToPoints = () => + publicAPI.setRepresentation(Representation.POINTS); + publicAPI.getRepresentationAsString = () => + macro.enumToString(Representation, model.representation); } // ---------------------------------------------------------------------------- @@ -111,12 +120,12 @@ export function extend(publicAPI, model, initialValues = {}) { 'frontfaceCulling', 'representation', ]); - macro.setGetArray(publicAPI, model, [ - 'ambientColor', - 'specularColor', - 'diffuseColor', - 'edgeColor', - ], 3); + macro.setGetArray( + publicAPI, + model, + ['ambientColor', 'specularColor', 'diffuseColor', 'edgeColor'], + 3 + ); // Object methods vtkProperty(publicAPI, model); diff --git a/Sources/Rendering/Core/Property2D/index.js b/Sources/Rendering/Core/Property2D/index.js index fa4874b57ec..a3cf33396e0 100644 --- a/Sources/Rendering/Core/Property2D/index.js +++ b/Sources/Rendering/Core/Property2D/index.js @@ -33,9 +33,7 @@ export function extend(publicAPI, model, initialValues = {}) { 'pointSize', 'displayLocation', ]); - macro.setGetArray(publicAPI, model, [ - 'color', - ], 3); + macro.setGetArray(publicAPI, model, ['color'], 3); // Object methods vtkProperty2D(publicAPI, model); diff --git a/Sources/Rendering/Core/RenderWindow/index.js b/Sources/Rendering/Core/RenderWindow/index.js index 20a89f4df24..54eb4004e12 100644 --- a/Sources/Rendering/Core/RenderWindow/index.js +++ b/Sources/Rendering/Core/RenderWindow/index.js @@ -28,11 +28,11 @@ function vtkRenderWindow(publicAPI, model) { // Remove renderer publicAPI.removeRenderer = (renderer) => { - model.renderers = model.renderers.filter(r => r !== renderer); + model.renderers = model.renderers.filter((r) => r !== renderer); publicAPI.modified(); }; - publicAPI.hasRenderer = ren => model.renderers.indexOf(ren) !== -1; + publicAPI.hasRenderer = (ren) => model.renderers.indexOf(ren) !== -1; // Add renderer publicAPI.addView = (view) => { @@ -46,17 +46,17 @@ function vtkRenderWindow(publicAPI, model) { // Remove renderer publicAPI.removeView = (view) => { - model.views = model.views.filter(r => r !== view); + model.views = model.views.filter((r) => r !== view); publicAPI.modified(); }; - publicAPI.hasView = view => model.views.indexOf(view) !== -1; + publicAPI.hasView = (view) => model.views.indexOf(view) !== -1; publicAPI.render = () => { if (model.interactor) { model.interactor.render(); } else { - model.views.forEach(view => view.traverseAllPasses()); + model.views.forEach((view) => view.traverseAllPasses()); } }; @@ -78,15 +78,19 @@ function vtkRenderWindow(publicAPI, model) { } }); }); - results.str = Object.keys(results).map(keyName => `${keyName}: ${results[keyName]}`).join('\n'); + results.str = Object.keys(results) + .map((keyName) => `${keyName}: ${results[keyName]}`) + .join('\n'); return results; }; publicAPI.captureImages = (format = 'image/png') => { publicAPI.render(); return model.views - .map(view => (view.captureImage ? view.captureImage(format) : undefined)) - .filter(i => !!i); + .map( + (view) => (view.captureImage ? view.captureImage(format) : undefined) + ) + .filter((i) => !!i); }; } @@ -109,11 +113,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.obj(publicAPI, model); - macro.setGet(publicAPI, model, [ - 'interactor', - 'numberOfLayers', - 'views', - ]); + macro.setGet(publicAPI, model, ['interactor', 'numberOfLayers', 'views']); macro.get(publicAPI, model, ['neverRendered']); macro.getArray(publicAPI, model, ['renderers']); macro.event(publicAPI, model, 'completion'); diff --git a/Sources/Rendering/Core/RenderWindow/test/testMultipleRenderers.js b/Sources/Rendering/Core/RenderWindow/test/testMultipleRenderers.js index 5d87e1e84e8..9f93e8987da 100644 --- a/Sources/Rendering/Core/RenderWindow/test/testMultipleRenderers.js +++ b/Sources/Rendering/Core/RenderWindow/test/testMultipleRenderers.js @@ -1,14 +1,14 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; -import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; -import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; +import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; +import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; import baseline from './testMultipleRenderers.png'; @@ -17,7 +17,9 @@ test.onlyIfWebGL('Test multiple renderers', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -35,7 +37,9 @@ test.onlyIfWebGL('Test multiple renderers', (t) => { const coneMapper = gc.registerResource(vtkMapper.newInstance()); coneActor.setMapper(coneMapper); - const coneSource = gc.registerResource(vtkConeSource.newInstance({ height: 1.0 })); + const coneSource = gc.registerResource( + vtkConeSource.newInstance({ height: 1.0 }) + ); coneMapper.setInputConnection(coneSource.getOutputPort()); // Lower left renderer @@ -80,5 +84,12 @@ test.onlyIfWebGL('Test multiple renderers', (t) => { renderWindow.render(); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/Core/RenderWindow/testMultipleRenderers', t, 5, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Rendering/Core/RenderWindow/testMultipleRenderers', + t, + 5, + gc.releaseResources + ); }); diff --git a/Sources/Rendering/Core/RenderWindowInteractor/index.js b/Sources/Rendering/Core/RenderWindowInteractor/index.js index d2c51cde643..cfb89a006d1 100644 --- a/Sources/Rendering/Core/RenderWindowInteractor/index.js +++ b/Sources/Rendering/Core/RenderWindowInteractor/index.js @@ -1,7 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import macro from 'vtk.js/Sources/macro'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; import vtkInteractorStyleTrackballCamera from 'vtk.js/Sources/Interaction/Style/InteractorStyleTrackballCamera'; -import Constants from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor/Constants'; +import Constants from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor/Constants'; const { Device, Input } = Constants; const { vtkWarningMacro, vtkErrorMacro } = macro; @@ -73,11 +73,11 @@ function vtkRenderWindowInteractor(publicAPI, model) { //---------------------------------------------------------------------- publicAPI.start = () => { - // Let the compositing handle the event loop if it wants to. - // if (publicAPI.HasObserver(vtkCommand::StartEvent) && !publicAPI.HandleEventLoop) { - // publicAPI.invokeEvent({ type: 'StartEvent' }); - // return; - // } + // Let the compositing handle the event loop if it wants to. + // if (publicAPI.HasObserver(vtkCommand::StartEvent) && !publicAPI.HandleEventLoop) { + // publicAPI.invokeEvent({ type: 'StartEvent' }); + // return; + // } // As a convenience, initialize if we aren't initialized yet. if (!model.initialized) { @@ -93,7 +93,9 @@ function vtkRenderWindowInteractor(publicAPI, model) { //---------------------------------------------------------------------- publicAPI.setRenderWindow = (aren) => { - vtkErrorMacro('you want to call setView(view) instead of setRenderWindow on a vtk.js interactor'); + vtkErrorMacro( + 'you want to call setView(view) instead of setRenderWindow on a vtk.js interactor' + ); }; //---------------------------------------------------------------------- @@ -131,17 +133,23 @@ function vtkRenderWindowInteractor(publicAPI, model) { }; publicAPI.setAnimationEventPosition = (xv, yv, zv, pointer) => { - model.lastAnimationEventPositions.set(pointer, model.animationEventPositions.get(pointer)); + model.lastAnimationEventPositions.set( + pointer, + model.animationEventPositions.get(pointer) + ); model.animationEventPositions.set(pointer, { x: xv, y: yv, z: zv }); }; - publicAPI.getEventPosition = pointer => model.eventPositions.get(pointer); + publicAPI.getEventPosition = (pointer) => model.eventPositions.get(pointer); - publicAPI.getLastEventPosition = pointer => model.lastEventPositions.get(pointer); + publicAPI.getLastEventPosition = (pointer) => + model.lastEventPositions.get(pointer); - publicAPI.getAnimationEventPosition = pointer => model.animationEventPositions.get(pointer); + publicAPI.getAnimationEventPosition = (pointer) => + model.animationEventPositions.get(pointer); - publicAPI.getLastAnimationEventPosition = pointer => model.lastAnimationEventPositions.get(pointer); + publicAPI.getLastAnimationEventPosition = (pointer) => + model.lastAnimationEventPositions.get(pointer); publicAPI.bindEvents = (canvas) => { model.canvas = canvas; @@ -151,8 +159,12 @@ function vtkRenderWindowInteractor(publicAPI, model) { canvas.addEventListener('DOMMouseScroll', publicAPI.handleWheel); canvas.addEventListener('mousedown', publicAPI.handleMouseDown); - document.querySelector('body').addEventListener('keypress', publicAPI.handleKeyPress); - document.querySelector('body').addEventListener('keyup', publicAPI.handleKeyUp); + document + .querySelector('body') + .addEventListener('keypress', publicAPI.handleKeyPress); + document + .querySelector('body') + .addEventListener('keyup', publicAPI.handleKeyUp); canvas.addEventListener('mouseup', publicAPI.handleMouseUp); canvas.addEventListener('mousemove', publicAPI.handleMouseMove); canvas.addEventListener('touchstart', publicAPI.handleTouchStart, false); @@ -168,8 +180,12 @@ function vtkRenderWindowInteractor(publicAPI, model) { canvas.removeEventListener('DOMMouseScroll', publicAPI.handleWheel); canvas.removeEventListener('mousedown', publicAPI.handleMouseDown); - document.querySelector('body').removeEventListener('keypress', publicAPI.handleKeyPress); - document.querySelector('body').removeEventListener('keyup', publicAPI.handleKeyUp); + document + .querySelector('body') + .removeEventListener('keypress', publicAPI.handleKeyPress); + document + .querySelector('body') + .removeEventListener('keyup', publicAPI.handleKeyUp); canvas.removeEventListener('mouseup', publicAPI.handleMouseUp); canvas.removeEventListener('mousemove', publicAPI.handleMouseMove); canvas.removeEventListener('touchstart', publicAPI.handleTouchStart); @@ -201,8 +217,18 @@ function vtkRenderWindowInteractor(publicAPI, model) { event.preventDefault(); // intentioanlly done twice - publicAPI.setEventPosition(event.clientX, model.canvas.clientHeight - event.clientY + 1, 0, 0); - publicAPI.setEventPosition(event.clientX, model.canvas.clientHeight - event.clientY + 1, 0, 0); + publicAPI.setEventPosition( + event.clientX, + model.canvas.clientHeight - event.clientY + 1, + 0, + 0 + ); + publicAPI.setEventPosition( + event.clientX, + model.canvas.clientHeight - event.clientY + 1, + 0, + 0 + ); model.controlKey = event.ctrlKey; model.altKey = event.altKey; model.shiftKey = event.shiftKey; @@ -228,7 +254,10 @@ function vtkRenderWindowInteractor(publicAPI, model) { } function updateAnimationEventPositionsAtHandle(value, key) { - model.lastAnimationEventPositions.set(key, model.animationEventPositions.get(key)); + model.lastAnimationEventPositions.set( + key, + model.animationEventPositions.get(key) + ); model.animationEventPositions.set(key, value); } @@ -242,7 +271,8 @@ function vtkRenderWindowInteractor(publicAPI, model) { } }; - publicAPI.isAnimating = () => (model.vrAnimation || model.animationRequest !== null); + publicAPI.isAnimating = () => + model.vrAnimation || model.animationRequest !== null; publicAPI.cancelAnimation = (requestor) => { model.requestAnimationCount -= 1; @@ -281,23 +311,36 @@ function vtkRenderWindowInteractor(publicAPI, model) { if (!(b in model.lastGamepadValues[gp.index].buttons)) { model.lastGamepadValues[gp.index].buttons[b] = false; } - if (model.lastGamepadValues[gp.index].buttons[b] !== gp.buttons[b].pressed) { + if ( + model.lastGamepadValues[gp.index].buttons[b] !== + gp.buttons[b].pressed + ) { publicAPI.button3DEvent({ gamepad: gp, position: gp.pose.position, orientation: gp.pose.orientation, pressed: gp.buttons[b].pressed, - device: (gp.hand === 'left' ? Device.LeftController : Device.RightController), - input: (deviceInputMap[gp.id] && deviceInputMap[gp.id][b] ? deviceInputMap[gp.id][b] : Input.Trigger), + device: + gp.hand === 'left' + ? Device.LeftController + : Device.RightController, + input: + deviceInputMap[gp.id] && deviceInputMap[gp.id][b] + ? deviceInputMap[gp.id][b] + : Input.Trigger, }); - model.lastGamepadValues[gp.index].buttons[b] = gp.buttons[b].pressed; + model.lastGamepadValues[gp.index].buttons[b] = + gp.buttons[b].pressed; } if (model.lastGamepadValues[gp.index].buttons[b]) { publicAPI.move3DEvent({ gamepad: gp, position: gp.pose.position, orientation: gp.pose.orientation, - device: (gp.hand === 'left' ? Device.LeftController : Device.RightController), + device: + gp.hand === 'left' + ? Device.LeftController + : Device.RightController, }); } } @@ -306,7 +349,12 @@ function vtkRenderWindowInteractor(publicAPI, model) { }; publicAPI.handleMouseMove = (event) => { - publicAPI.setEventPosition(event.clientX, model.canvas.clientHeight - event.clientY + 1, 0, 0); + publicAPI.setEventPosition( + event.clientX, + model.canvas.clientHeight - event.clientY + 1, + 0, + 0 + ); // Do not consume event for move // event.stopPropagation(); // event.preventDefault(); @@ -342,8 +390,9 @@ function vtkRenderWindowInteractor(publicAPI, model) { // mode = 'wheelDeltaY'; wheelDelta = event.wheelDeltaY; } - publicAPI.setScale(publicAPI.getScale() * - Math.max(0.01, (wheelDelta + 1000.0) / 1000.0)); + publicAPI.setScale( + publicAPI.getScale() * Math.max(0.01, (wheelDelta + 1000.0) / 1000.0) + ); publicAPI.pinchEvent(); @@ -367,7 +416,12 @@ function vtkRenderWindowInteractor(publicAPI, model) { event.stopPropagation(); event.preventDefault(); - publicAPI.setEventPosition(event.clientX, model.canvas.clientHeight - event.clientY + 1, 0, 0); + publicAPI.setEventPosition( + event.clientX, + model.canvas.clientHeight - event.clientY + 1, + 0, + 0 + ); switch (event.which) { case 1: publicAPI.leftButtonReleaseEvent(); @@ -391,7 +445,12 @@ function vtkRenderWindowInteractor(publicAPI, model) { const touches = event.changedTouches; for (let i = 0; i < touches.length; i++) { const touch = touches[i]; - publicAPI.setEventPosition(touch.clientX, model.canvas.clientHeight - touch.clientY + 1, 0, touch.identifier); + publicAPI.setEventPosition( + touch.clientX, + model.canvas.clientHeight - touch.clientY + 1, + 0, + touch.identifier + ); publicAPI.setPointerIndex(touch.identifier); publicAPI.startTouchEvent(); } @@ -404,7 +463,12 @@ function vtkRenderWindowInteractor(publicAPI, model) { const touches = event.changedTouches; for (let i = 0; i < touches.length; i++) { const touch = touches[i]; - publicAPI.setEventPosition(touch.clientX, model.canvas.clientHeight - touch.clientY + 1, 0, touch.identifier); + publicAPI.setEventPosition( + touch.clientX, + model.canvas.clientHeight - touch.clientY + 1, + 0, + touch.identifier + ); publicAPI.setPointerIndex(touch.identifier); publicAPI.mouseMoveEvent(); } @@ -417,7 +481,12 @@ function vtkRenderWindowInteractor(publicAPI, model) { const touches = event.changedTouches; for (let i = 0; i < touches.length; i++) { const touch = touches[i]; - publicAPI.setEventPosition(touch.clientX, model.canvas.clientHeight - touch.clientY + 1, 0, touch.identifier); + publicAPI.setEventPosition( + touch.clientX, + model.canvas.clientHeight - touch.clientY + 1, + 0, + touch.identifier + ); publicAPI.setPointerIndex(touch.identifier); publicAPI.endTouchEvent(); } @@ -547,8 +616,7 @@ function vtkRenderWindowInteractor(publicAPI, model) { // store the initial positions if (event === 'LeftButtonPress') { model.pointersDown.forEach((value, key) => { - model.startingEventPositions.set(key, - model.eventPositions.get(key)); + model.startingEventPositions.set(key, model.eventPositions.get(key)); }); // we do not know what the gesture is yet model.currentGesture = 'Start'; @@ -581,9 +649,10 @@ function vtkRenderWindowInteractor(publicAPI, model) { const posVals = []; const startVals = []; model.pointersDown.forEach((value, key) => { - posVals[count] = (model.animationRequest === null) - ? model.eventPositions.get(key) - : model.animationEventPositions.get(key); + posVals[count] = + model.animationRequest === null + ? model.eventPositions.get(key) + : model.animationEventPositions.get(key); startVals[count] = model.startingEventPositions.get(key); count++; }); @@ -593,32 +662,42 @@ function vtkRenderWindowInteractor(publicAPI, model) { // of movement it is and then deal with it. // calculate the distances const originalDistance = Math.sqrt( - ((startVals[0].x - startVals[1].x) * (startVals[0].x - startVals[1].x)) - + ((startVals[0].y - startVals[1].y) * (startVals[0].y - startVals[1].y))); + (startVals[0].x - startVals[1].x) * (startVals[0].x - startVals[1].x) + + (startVals[0].y - startVals[1].y) * (startVals[0].y - startVals[1].y) + ); const newDistance = Math.sqrt( - ((posVals[0].x - posVals[1].x) * (posVals[0].x - posVals[1].x)) - + ((posVals[0].y - posVals[1].y) * (posVals[0].y - posVals[1].y))); + (posVals[0].x - posVals[1].x) * (posVals[0].x - posVals[1].x) + + (posVals[0].y - posVals[1].y) * (posVals[0].y - posVals[1].y) + ); // calculate rotations - let originalAngle = - vtkMath.degreesFromRadians(Math.atan2(startVals[1].y - startVals[0].y, - startVals[1].x - startVals[0].x)); - let newAngle = - vtkMath.degreesFromRadians(Math.atan2(posVals[1].y - posVals[0].y, - posVals[1].x - posVals[0].x)); + let originalAngle = vtkMath.degreesFromRadians( + Math.atan2( + startVals[1].y - startVals[0].y, + startVals[1].x - startVals[0].x + ) + ); + let newAngle = vtkMath.degreesFromRadians( + Math.atan2(posVals[1].y - posVals[0].y, posVals[1].x - posVals[0].x) + ); // angles are cyclic so watch for that, 1 and 359 are only 2 apart :) let angleDeviation = newAngle - originalAngle; - newAngle = (newAngle + 180.0 >= 360.0 ? newAngle - 180.0 : newAngle + 180.0); - originalAngle = (originalAngle + 180.0 >= 360.0 ? originalAngle - 180.0 : originalAngle + 180.0); + newAngle = newAngle + 180.0 >= 360.0 ? newAngle - 180.0 : newAngle + 180.0; + originalAngle = + originalAngle + 180.0 >= 360.0 + ? originalAngle - 180.0 + : originalAngle + 180.0; if (Math.abs(newAngle - originalAngle) < Math.abs(angleDeviation)) { angleDeviation = newAngle - originalAngle; } // calculate the translations const trans = []; - trans[0] = (posVals[0].x - startVals[0].x + posVals[1].x - startVals[1].x) / 2.0; - trans[1] = (posVals[0].y - startVals[0].y + posVals[1].y - startVals[1].y) / 2.0; + trans[0] = + (posVals[0].x - startVals[0].x + posVals[1].x - startVals[1].x) / 2.0; + trans[1] = + (posVals[0].y - startVals[0].y + posVals[1].y - startVals[1].y) / 2.0; if (event === 'MouseMove') { // OK we want to @@ -634,24 +713,31 @@ function vtkRenderWindowInteractor(publicAPI, model) { // pan is a move of the center point // compute the distance along each of these axes in pixels // the first to break thresh wins - let thresh = 0.01 * Math.sqrt( - (model.canvas.clientWidth * model.canvas.clientWidth) - + (model.canvas.clientHeight * model.canvas.clientHeight)); + let thresh = + 0.01 * + Math.sqrt( + model.canvas.clientWidth * model.canvas.clientWidth + + model.canvas.clientHeight * model.canvas.clientHeight + ); if (thresh < 15.0) { thresh = 15.0; } const pinchDistance = Math.abs(newDistance - originalDistance); - const rotateDistance = newDistance * 3.1415926 * Math.abs(angleDeviation) / 360.0; - const panDistance = Math.sqrt((trans[0] * trans[0]) + (trans[1] * trans[1])); - if (pinchDistance > thresh - && pinchDistance > rotateDistance - && pinchDistance > panDistance) { + const rotateDistance = + newDistance * 3.1415926 * Math.abs(angleDeviation) / 360.0; + const panDistance = Math.sqrt( + trans[0] * trans[0] + trans[1] * trans[1] + ); + if ( + pinchDistance > thresh && + pinchDistance > rotateDistance && + pinchDistance > panDistance + ) { model.currentGesture = 'Pinch'; model.scale = 1.0; publicAPI.startPinchEvent(); model.interactorStyle.setAnimationStateOn(); - } else if (rotateDistance > thresh - && rotateDistance > panDistance) { + } else if (rotateDistance > thresh && rotateDistance > panDistance) { model.currentGesture = 'Rotate'; model.rotation = 0.0; publicAPI.startRotateEvent(); @@ -828,8 +914,9 @@ export function extend(publicAPI, model, initialValues = {}) { macro.obj(publicAPI, model); macro.event(publicAPI, model, 'RenderEvent'); - eventsWeHandle.forEach(eventName => - macro.event(publicAPI, model, eventName)); + eventsWeHandle.forEach((eventName) => + macro.event(publicAPI, model, eventName) + ); // Create get-only macros macro.get(publicAPI, model, [ @@ -862,10 +949,7 @@ export function extend(publicAPI, model, initialValues = {}) { 'picker', ]); - macro.getArray(publicAPI, model, [ - 'translation', - 'lastTranslation', - ]); + macro.getArray(publicAPI, model, ['translation', 'lastTranslation']); // For more macro methods, see "Sources/macro.js" @@ -877,7 +961,10 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkRenderWindowInteractor'); +export const newInstance = macro.newInstance( + extend, + 'vtkRenderWindowInteractor' +); // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/Core/Renderer/index.js b/Sources/Rendering/Core/Renderer/index.js index 2bb1307692f..0400d6527e9 100644 --- a/Sources/Rendering/Core/Renderer/index.js +++ b/Sources/Rendering/Core/Renderer/index.js @@ -1,10 +1,10 @@ import { mat4, vec3 } from 'gl-matrix'; -import macro from 'vtk.js/Sources/macro'; -import vtkCamera from 'vtk.js/Sources/Rendering/Core/Camera'; -import vtkLight from 'vtk.js/Sources/Rendering/Core/Light'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; -import vtkViewport from 'vtk.js/Sources/Rendering/Core/Viewport'; +import macro from 'vtk.js/Sources/macro'; +import vtkCamera from 'vtk.js/Sources/Rendering/Core/Camera'; +import vtkLight from 'vtk.js/Sources/Rendering/Core/Light'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkViewport from 'vtk.js/Sources/Rendering/Core/Viewport'; import vtkBoundingBox from 'vtk.js/Sources/Common/DataModel/BoundingBox'; const { vtkDebugMacro, vtkErrorMacro, vtkWarningMacro } = macro; @@ -94,7 +94,12 @@ function vtkRenderer(publicAPI, model) { publicAPI.getVTKWindow = () => model.renderWindow; publicAPI.setLayer = (layer) => { - vtkDebugMacro(publicAPI.getClassName(), publicAPI, 'setting Layer to ', layer); + vtkDebugMacro( + publicAPI.getClassName(), + publicAPI, + 'setting Layer to ', + layer + ); if (model.layer !== layer) { model.layer = layer; publicAPI.modified(); @@ -141,12 +146,12 @@ function vtkRenderer(publicAPI, model) { publicAPI.addVolume = publicAPI.addViewProp; publicAPI.removeActor = (actor) => { - model.actors = model.actors.filter(a => a !== actor); + model.actors = model.actors.filter((a) => a !== actor); publicAPI.removeViewProp(actor); }; publicAPI.removeVolume = (volume) => { - model.volumes = model.volumes.filter(v => v !== volume); + model.volumes = model.volumes.filter((v) => v !== volume); publicAPI.removeViewProp(volume); }; @@ -172,11 +177,13 @@ function vtkRenderer(publicAPI, model) { }; publicAPI.removeLight = (light) => { - model.lights = model.lights.filter(l => l !== light); + model.lights = model.lights.filter((l) => l !== light); publicAPI.modified(); }; - publicAPI.removeAllLights = () => { model.lights = []; }; + publicAPI.removeAllLights = () => { + model.lights = []; + }; // FIXME publicAPI.addCuller = notImplemented('addCuller'); @@ -208,7 +215,9 @@ function vtkRenderer(publicAPI, model) { // set these values just to have a good default should LightFollowCamera // be turned off. model.createdLight.setPosition(publicAPI.getActiveCamera().getPosition()); - model.createdLight.setFocalPoint(publicAPI.getActiveCamera().getFocalPoint()); + model.createdLight.setFocalPoint( + publicAPI.getActiveCamera().getFocalPoint() + ); }; // requires the aspect ratio of the viewport as X/Y @@ -225,17 +234,21 @@ function vtkRenderer(publicAPI, model) { return publicAPI.viewToNormalizedDisplay(vpd[0], vpd[1], vpd[2], aspect); }; - // requires the aspect ratio of the viewport as X/Y publicAPI.viewToWorld = (x, y, z, aspect) => { if (model.activeCamera === null) { - vtkErrorMacro('ViewToWorld: no active camera, cannot compute view to world, returning 0,0,0'); + vtkErrorMacro( + 'ViewToWorld: no active camera, cannot compute view to world, returning 0,0,0' + ); return [0, 0, 0]; } // get the perspective transformation from the active camera - const matrix = model.activeCamera - .getCompositeProjectionMatrix(aspect, -1.0, 1.0); + const matrix = model.activeCamera.getCompositeProjectionMatrix( + aspect, + -1.0, + 1.0 + ); mat4.invert(matrix, matrix); mat4.transpose(matrix, matrix); @@ -250,13 +263,18 @@ function vtkRenderer(publicAPI, model) { // requires the aspect ratio of the viewport as X/Y publicAPI.worldToView = (x, y, z, aspect) => { if (model.activeCamera === null) { - vtkErrorMacro('ViewToWorld: no active camera, cannot compute view to world, returning 0,0,0'); + vtkErrorMacro( + 'ViewToWorld: no active camera, cannot compute view to world, returning 0,0,0' + ); return [0, 0, 0]; } // get the perspective transformation from the active camera - const matrix = model.activeCamera - .getCompositeProjectionMatrix(aspect, -1.0, 1.0); + const matrix = model.activeCamera.getCompositeProjectionMatrix( + aspect, + -1.0, + 1.0 + ); mat4.transpose(matrix, matrix); const result = vec3.fromValues(x, y, z); @@ -307,7 +325,7 @@ function vtkRenderer(publicAPI, model) { if (nothingVisible) { vtkMath.uninitializeBounds(model.allBounds); - vtkDebugMacro('Can\'t compute bounds, no 3D props are visible'); + vtkDebugMacro("Can't compute bounds, no 3D props are visible"); } return model.allBounds; @@ -348,7 +366,7 @@ function vtkRenderer(publicAPI, model) { let radius = w1 + w2 + w3; // If we have just a single point, pick a radius of 1.0 - radius = (radius === 0) ? (1.0) : (radius); + radius = radius === 0 ? 1.0 : radius; // compute the radius of the enclosing sphere radius = Math.sqrt(radius) * 0.5; @@ -380,9 +398,10 @@ function vtkRenderer(publicAPI, model) { // update the camera model.activeCamera.setFocalPoint(center[0], center[1], center[2]); model.activeCamera.setPosition( - center[0] + (distance * vn[0]), - center[1] + (distance * vn[1]), - center[2] + (distance * vn[2])); + center[0] + distance * vn[0], + center[1] + distance * vn[1], + center[2] + distance * vn[2] + ); publicAPI.resetCameraClippingRange(boundsToUse); @@ -391,7 +410,11 @@ function vtkRenderer(publicAPI, model) { // update reasonable world to physical values model.activeCamera.setPhysicalScale(1.0 / radius); - model.activeCamera.setPhysicalTranslation(-center[0], -center[1], -center[2]); + model.activeCamera.setPhysicalTranslation( + -center[0], + -center[1], + -center[2] + ); // Here to let parallel/distributed compositing intercept // and do the right thing. @@ -415,25 +438,33 @@ function vtkRenderer(publicAPI, model) { return false; } - let vn = null; let position = null; + let vn = null; + let position = null; vn = model.activeCamera.getViewPlaneNormalByReference(); position = model.activeCamera.getPositionByReference(); const a = -vn[0]; const b = -vn[1]; const c = -vn[2]; - const d = -((a * position[0]) + (b * position[1]) + (c * position[2])); + const d = -(a * position[0] + b * position[1] + c * position[2]); // Set the max near clipping plane and the min far clipping plane - const range = [(a * boundsToUse[0]) + (b * boundsToUse[2]) + (c * boundsToUse[4]) + d, 1e-18]; + const range = [ + a * boundsToUse[0] + b * boundsToUse[2] + c * boundsToUse[4] + d, + 1e-18, + ]; // Find the closest / farthest bounding box vertex for (let k = 0; k < 2; k++) { for (let j = 0; j < 2; j++) { for (let i = 0; i < 2; i++) { - const dist = (a * boundsToUse[i]) + (b * boundsToUse[2 + j]) + (c * boundsToUse[4 + k]) + d; - range[0] = (dist < range[0]) ? (dist) : (range[0]); - range[1] = (dist > range[1]) ? (dist) : (range[1]); + const dist = + a * boundsToUse[i] + + b * boundsToUse[2 + j] + + c * boundsToUse[4 + k] + + d; + range[0] = dist < range[0] ? dist : range[0]; + range[1] = dist > range[1] ? dist : range[1]; } } } @@ -444,7 +475,9 @@ function vtkRenderer(publicAPI, model) { if (model.activeCamera.getParallelProjection()) { minGap = 0.1 * model.activeCamera.getParallelScale(); } else { - const angle = vtkMath.radiansFromDegrees(model.activeCamera.getViewAngle()); + const angle = vtkMath.radiansFromDegrees( + model.activeCamera.getViewAngle() + ); minGap = 0.2 * Math.tan(angle / 2.0) * range[1]; } @@ -460,11 +493,13 @@ function vtkRenderer(publicAPI, model) { } // Give ourselves a little breathing room - range[0] = (0.99 * range[0]) - ((range[1] - range[0]) * model.clippingRangeExpansion); - range[1] = (1.01 * range[1]) + ((range[1] - range[0]) * model.clippingRangeExpansion); + range[0] = + 0.99 * range[0] - (range[1] - range[0]) * model.clippingRangeExpansion; + range[1] = + 1.01 * range[1] + (range[1] - range[0]) * model.clippingRangeExpansion; // Make sure near is not bigger than far - range[0] = (range[0] >= range[1]) ? (0.01 * range[1]) : (range[0]); + range[0] = range[0] >= range[1] ? 0.01 * range[1] : range[0]; // Make sure near is at least some fraction of far - this prevents near // from being behind the camera or too close in front. How close is too @@ -494,7 +529,8 @@ function vtkRenderer(publicAPI, model) { } }; - publicAPI.visibleActorCount = () => model.props.filter(prop => prop.getVisibility()).length; + publicAPI.visibleActorCount = () => + model.props.filter((prop) => prop.getVisibility()).length; publicAPI.visibleVolumeCount = publicAPI.visibleActorCount; publicAPI.getMTime = () => { diff --git a/Sources/Rendering/Core/Representation/index.js b/Sources/Rendering/Core/Representation/index.js index 54ee8e4d364..12b19116bd3 100644 --- a/Sources/Rendering/Core/Representation/index.js +++ b/Sources/Rendering/Core/Representation/index.js @@ -21,7 +21,7 @@ function vtkRepresentation(publicAPI, model) { publicAPI.removeActor = function removeActor(...actors) { const size = model.actors.length; - model.actors = model.actors.filter(a => actors.indexOf(a) === -1); + model.actors = model.actors.filter((a) => actors.indexOf(a) === -1); if (model.actors.length < size) { publicAPI.modified(); } @@ -32,23 +32,17 @@ function vtkRepresentation(publicAPI, model) { // Object factory // ---------------------------------------------------------------------------- -const DEFAULT_VALUES = { -}; +const DEFAULT_VALUES = {}; // ---------------------------------------------------------------------------- - export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API macro.obj(publicAPI, model); - macro.get(publicAPI, model, [ - 'actors', - ]); - macro.setGet(publicAPI, model, [ - 'input', - ]); + macro.get(publicAPI, model, ['actors']); + macro.setGet(publicAPI, model, ['input']); // Object methods vtkRepresentation(publicAPI, model); diff --git a/Sources/Rendering/Core/SphereMapper/example/index.js b/Sources/Rendering/Core/SphereMapper/example/index.js index bf0d58012d0..b9636d83444 100644 --- a/Sources/Rendering/Core/SphereMapper/example/index.js +++ b/Sources/Rendering/Core/SphereMapper/example/index.js @@ -1,14 +1,14 @@ import 'vtk.js/Sources/favicon'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; -import vtkSphereMapper from 'vtk.js/Sources/Rendering/Core/SphereMapper'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; +import vtkSphereMapper from 'vtk.js/Sources/Rendering/Core/SphereMapper'; -import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; -import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; -import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants'; +import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; +import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; +import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants'; import controlPanel from './controlPanel.html'; @@ -16,7 +16,9 @@ import controlPanel from './controlPanel.html'; // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -32,38 +34,43 @@ const actor = vtkActor.newInstance(); actor.getProperty().setRepresentation(Representation.WIREFRAME); // ??? Is this useful? simpleFilter.setFormula({ - getArrays: inputDataSets => ({ - input: [ - { location: FieldDataTypes.COORDINATE }], // Require point coordinates as input - output: [ // Generate two output arrays: + getArrays: (inputDataSets) => ({ + input: [{ location: FieldDataTypes.COORDINATE }], // Require point coordinates as input + output: [ + // Generate two output arrays: { - location: FieldDataTypes.POINT, // This array will be point-data ... - name: 'pressure', // ... with the given name ... - dataType: 'Float32Array', // ... of this type ... - numberOfComponents: 1, // ... with this many components ... + location: FieldDataTypes.POINT, // This array will be point-data ... + name: 'pressure', // ... with the given name ... + dataType: 'Float32Array', // ... of this type ... + numberOfComponents: 1, // ... with this many components ... }, { location: FieldDataTypes.POINT, // This array will be field data ... - name: 'temperature', // ... with the given name ... - dataType: 'Float32Array', // ... of this type ... + name: 'temperature', // ... with the given name ... + dataType: 'Float32Array', // ... of this type ... attribute: AttributeTypes.SCALARS, // ... and will be marked as the default scalars. - numberOfComponents: 1, // ... with this many components ... + numberOfComponents: 1, // ... with this many components ... }, - ] }), + ], + }), evaluate: (arraysIn, arraysOut) => { // Convert in the input arrays of vtkDataArrays into variables // referencing the underlying JavaScript typed-data arrays: - const [coords] = arraysIn.map(d => d.getData()); - const [press, temp] = arraysOut.map(d => d.getData()); + const [coords] = arraysIn.map((d) => d.getData()); + const [press, temp] = arraysOut.map((d) => d.getData()); // Since we are passed coords as a 3-component array, // loop over all the points and compute the point-data output: for (let i = 0, sz = coords.length / 3; i < sz; ++i) { - press[i] = (((coords[3 * i] - 0.5) * (coords[3 * i] - 0.5)) + ((coords[(3 * i) + 1] - 0.5) * (coords[(3 * i) + 1] - 0.5)) + 0.125) * 0.1; - temp[i] = coords[(3 * i) + 1]; + press[i] = + ((coords[3 * i] - 0.5) * (coords[3 * i] - 0.5) + + (coords[3 * i + 1] - 0.5) * (coords[3 * i + 1] - 0.5) + + 0.125) * + 0.1; + temp[i] = coords[3 * i + 1]; } // Mark the output vtkDataArray as modified - arraysOut.forEach(x => x.modified()); + arraysOut.forEach((x) => x.modified()); }, }); @@ -79,7 +86,6 @@ renderer.addActor(actor); renderer.resetCamera(); renderWindow.render(); - // ----------------------------------------------------------- // UI control handling // ----------------------------------------------------------- @@ -93,7 +99,6 @@ fullScreenRenderer.addController(controlPanel); }); }); - // ----------------------------------------------------------- // Make some variables global so that you can inspect and // modify objects in your browser's developer console: diff --git a/Sources/Rendering/Core/SphereMapper/index.js b/Sources/Rendering/Core/SphereMapper/index.js index b56a309a725..cd219158fd3 100644 --- a/Sources/Rendering/Core/SphereMapper/index.js +++ b/Sources/Rendering/Core/SphereMapper/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; // ---------------------------------------------------------------------------- @@ -27,10 +27,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Inheritance vtkMapper.extend(publicAPI, model, initialValues); - macro.setGet(publicAPI, model, [ - 'radius', - 'scaleArray', - ]); + macro.setGet(publicAPI, model, ['radius', 'scaleArray']); // Object methods vtkSphereMapper(publicAPI, model); @@ -43,4 +40,3 @@ export const newInstance = macro.newInstance(extend, 'vtkSphereMapper'); // ---------------------------------------------------------------------------- export default { newInstance, extend }; - diff --git a/Sources/Rendering/Core/SphereMapper/test/testDisableScalarColoring.js b/Sources/Rendering/Core/SphereMapper/test/testDisableScalarColoring.js index 34f3f64003b..637d96561e1 100644 --- a/Sources/Rendering/Core/SphereMapper/test/testDisableScalarColoring.js +++ b/Sources/Rendering/Core/SphereMapper/test/testDisableScalarColoring.js @@ -1,16 +1,16 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkSphereMapper from 'vtk.js/Sources/Rendering/Core/SphereMapper'; +import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkSphereMapper from 'vtk.js/Sources/Rendering/Core/SphereMapper'; -import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; -import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; +import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; +import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; import baseline from './testDisableScalarColoring.png'; @@ -20,7 +20,9 @@ test.onlyIfWebGL('Test vtkSphereMapper Rendering', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -35,29 +37,34 @@ test.onlyIfWebGL('Test vtkSphereMapper Rendering', (t) => { const mapper = gc.registerResource(vtkSphereMapper.newInstance()); actor.setMapper(mapper); - const coneSource = gc.registerResource(vtkConeSource.newInstance({ height: 1.0 })); + const coneSource = gc.registerResource( + vtkConeSource.newInstance({ height: 1.0 }) + ); const scalarRange = [1000000, -1000000]; const filter = gc.registerResource(vtkCalculator.newInstance()); filter.setInputConnection(coneSource.getOutputPort()); filter.setFormula({ - getArrays: inputDataSets => ({ - input: [ - { location: FieldDataTypes.COORDINATE }, - ], + getArrays: (inputDataSets) => ({ + input: [{ location: FieldDataTypes.COORDINATE }], output: [ - { location: FieldDataTypes.POINT, name: 'distance magnitude', dataType: 'Float32Array', attribute: AttributeTypes.SCALARS }, + { + location: FieldDataTypes.POINT, + name: 'distance magnitude', + dataType: 'Float32Array', + attribute: AttributeTypes.SCALARS, + }, ], }), evaluate: (arraysIn, arraysOut) => { - const [coords] = arraysIn.map(d => d.getData()); - const [dmag] = arraysOut.map(d => d.getData()); + const [coords] = arraysIn.map((d) => d.getData()); + const [dmag] = arraysOut.map((d) => d.getData()); for (let i = 0, sz = coords.length / 3; i < sz; ++i) { const idx = i * 3; const [x, y, z] = [coords[idx], coords[idx + 1], coords[idx + 2]]; - dmag[i] = Math.sqrt((x * x) + (y * y) + (z * z)); + dmag[i] = Math.sqrt(x * x + y * y + z * z); if (dmag[i] > scalarRange[1]) { scalarRange[1] = dmag[i]; } @@ -65,7 +72,7 @@ test.onlyIfWebGL('Test vtkSphereMapper Rendering', (t) => { scalarRange[0] = dmag[i]; } } - arraysOut.forEach(arr => arr.modified()); + arraysOut.forEach((arr) => arr.modified()); }, }); @@ -74,7 +81,9 @@ test.onlyIfWebGL('Test vtkSphereMapper Rendering', (t) => { mapper.setInputConnection(filter.getOutputPort()); - console.log(`Setting mapper scalar range to [${scalarRange[0]}, ${scalarRange[1]}]`); + console.log( + `Setting mapper scalar range to [${scalarRange[0]}, ${scalarRange[1]}]` + ); mapper.setScalarRange(scalarRange); mapper.setColorByArrayName('distance magnitude'); mapper.setColorModeToMapScalars(); @@ -95,5 +104,12 @@ test.onlyIfWebGL('Test vtkSphereMapper Rendering', (t) => { renderWindow.render(); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/Core/SphereMapper/testDisableScalarColoring', t, 1.0, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Rendering/Core/SphereMapper/testDisableScalarColoring', + t, + 1.0, + gc.releaseResources + ); }); diff --git a/Sources/Rendering/Core/StickMapper/example/index.js b/Sources/Rendering/Core/StickMapper/example/index.js index c1ef0d98da4..cd9a99de90b 100644 --- a/Sources/Rendering/Core/StickMapper/example/index.js +++ b/Sources/Rendering/Core/StickMapper/example/index.js @@ -1,27 +1,27 @@ import 'vtk.js/Sources/favicon'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; -import vtkStickMapper from 'vtk.js/Sources/Rendering/Core/StickMapper'; +import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; +import vtkStickMapper from 'vtk.js/Sources/Rendering/Core/StickMapper'; -import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; -import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; -import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants'; +import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; +import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; +import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants'; import controlPanel from './controlPanel.html'; - // ---------------------------------------------------------------------------- // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); - // ---------------------------------------------------------------------------- // Example code // ---------------------------------------------------------------------------- @@ -34,50 +34,63 @@ const actor = vtkActor.newInstance(); actor.getProperty().setRepresentation(Representation.WIREFRAME); // ??? Is this useful? simpleFilter.setFormula({ - getArrays: inputDataSets => ({ - input: [ - { location: FieldDataTypes.COORDINATE }], // Require point coordinates as input - output: [ // Generate two output arrays: + getArrays: (inputDataSets) => ({ + input: [{ location: FieldDataTypes.COORDINATE }], // Require point coordinates as input + output: [ + // Generate two output arrays: { - location: FieldDataTypes.POINT, // This array will be point-data ... - name: 'orientation', // ... with the given name ... - dataType: 'Float32Array', // ... of this type ... - numberOfComponents: 3, // ... with this many components ... + location: FieldDataTypes.POINT, // This array will be point-data ... + name: 'orientation', // ... with the given name ... + dataType: 'Float32Array', // ... of this type ... + numberOfComponents: 3, // ... with this many components ... }, { location: FieldDataTypes.POINT, // This array will be field data ... - name: 'temperature', // ... with the given name ... - dataType: 'Float32Array', // ... of this type ... + name: 'temperature', // ... with the given name ... + dataType: 'Float32Array', // ... of this type ... attribute: AttributeTypes.SCALARS, // ... and will be marked as the default scalars. - numberOfComponents: 1, // ... with this many components ... + numberOfComponents: 1, // ... with this many components ... }, { location: FieldDataTypes.POINT, // This array will be field data ... - name: 'pressure', // ... with the given name ... - dataType: 'Float32Array', // ... of this type ... - numberOfComponents: 2, // ... with this many components ... + name: 'pressure', // ... with the given name ... + dataType: 'Float32Array', // ... of this type ... + numberOfComponents: 2, // ... with this many components ... }, - ] }), + ], + }), evaluate: (arraysIn, arraysOut) => { // Convert in the input arrays of vtkDataArrays into variables // referencing the underlying JavaScript typed-data arrays: - const [coords] = arraysIn.map(d => d.getData()); - const [orient, temp, press] = arraysOut.map(d => d.getData()); + const [coords] = arraysIn.map((d) => d.getData()); + const [orient, temp, press] = arraysOut.map((d) => d.getData()); // Since we are passed coords as a 3-component array, // loop over all the points and compute the point-data output: for (let i = 0, sz = coords.length / 3; i < sz; ++i) { - orient[i * 3] = ((coords[3 * i] - 0.5) * (coords[3 * i] - 0.5)) + ((coords[(3 * i) + 1] - 0.5) * (coords[(3 * i) + 1] - 0.5)); - orient[(i * 3) + 1] = ((coords[3 * i] - 0.5) * (coords[3 * i] - 0.5)) + ((coords[(3 * i) + 1] - 0.5) * (coords[(3 * i) + 1] - 0.5)); - orient[(i * 3) + 2] = 1.0; - - temp[i] = coords[(3 * i) + 1]; - - press[(i * 2)] = ((((coords[3 * i]) * (coords[3 * i])) + ((coords[(3 * i) + 1]) * (coords[(3 * i) + 1]))) * 0.05) + 0.05; - press[(i * 2) + 1] = ((((coords[3 * i]) * (coords[3 * i])) + ((coords[(3 * i) + 1]) * (coords[(3 * i) + 1]))) * 0.01) + 0.01; + orient[i * 3] = + (coords[3 * i] - 0.5) * (coords[3 * i] - 0.5) + + (coords[3 * i + 1] - 0.5) * (coords[3 * i + 1] - 0.5); + orient[i * 3 + 1] = + (coords[3 * i] - 0.5) * (coords[3 * i] - 0.5) + + (coords[3 * i + 1] - 0.5) * (coords[3 * i + 1] - 0.5); + orient[i * 3 + 2] = 1.0; + + temp[i] = coords[3 * i + 1]; + + press[i * 2] = + (coords[3 * i] * coords[3 * i] + + coords[3 * i + 1] * coords[3 * i + 1]) * + 0.05 + + 0.05; + press[i * 2 + 1] = + (coords[3 * i] * coords[3 * i] + + coords[3 * i + 1] * coords[3 * i + 1]) * + 0.01 + + 0.01; } // Mark the output vtkDataArray as modified - arraysOut.forEach(x => x.modified()); + arraysOut.forEach((x) => x.modified()); }, }); @@ -95,7 +108,6 @@ renderer.addActor(actor); renderer.resetCamera(); renderWindow.render(); - // ----------------------------------------------------------- // UI control handling // ----------------------------------------------------------- @@ -109,7 +121,6 @@ fullScreenRenderer.addController(controlPanel); }); }); - // ----------------------------------------------------------- // Make some variables global so that you can inspect and // modify objects in your browser's developer console: diff --git a/Sources/Rendering/Core/StickMapper/index.js b/Sources/Rendering/Core/StickMapper/index.js index fe7c736a300..4cd9b8a8f5b 100644 --- a/Sources/Rendering/Core/StickMapper/index.js +++ b/Sources/Rendering/Core/StickMapper/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; // ---------------------------------------------------------------------------- @@ -47,4 +47,3 @@ export const newInstance = macro.newInstance(extend, 'vtkStickMapper'); // ---------------------------------------------------------------------------- export default { newInstance, extend }; - diff --git a/Sources/Rendering/Core/Texture/index.js b/Sources/Rendering/Core/Texture/index.js index 96d383bba24..6e140e8c056 100644 --- a/Sources/Rendering/Core/Texture/index.js +++ b/Sources/Rendering/Core/Texture/index.js @@ -58,9 +58,7 @@ export function extend(publicAPI, model, initialValues = {}) { macro.obj(publicAPI, model); macro.algo(publicAPI, model, 6, 0); - macro.get(publicAPI, model, [ - 'imageLoaded', - ]); + macro.get(publicAPI, model, ['imageLoaded']); macro.setGet(publicAPI, model, [ 'repeat', diff --git a/Sources/Rendering/Core/Viewport/index.js b/Sources/Rendering/Core/Viewport/index.js index b484db7abc4..17bbc379159 100644 --- a/Sources/Rendering/Core/Viewport/index.js +++ b/Sources/Rendering/Core/Viewport/index.js @@ -16,7 +16,8 @@ function vtkViewport(publicAPI, model) { // Public API methods publicAPI.getViewProps = () => model.props; - publicAPI.hasViewProp = prop => !!model.props.filter(item => item === prop).length; + publicAPI.hasViewProp = (prop) => + !!model.props.filter((item) => item === prop).length; publicAPI.addViewProp = (prop) => { if (prop && !publicAPI.hasViewProp(prop)) { model.props = model.props.concat(prop); @@ -24,7 +25,7 @@ function vtkViewport(publicAPI, model) { }; publicAPI.removeViewProp = (prop) => { - const newPropList = model.props.filter(item => item !== prop); + const newPropList = model.props.filter((item) => item !== prop); if (model.props.length !== newPropList.length) { model.props = newPropList; } @@ -60,8 +61,10 @@ function vtkViewport(publicAPI, model) { return model.actors2D; }; - publicAPI.displayToView = () => vtkErrorMacro('call displayToView on your view instead'); - publicAPI.viewToDisplay = () => vtkErrorMacro('callviewtodisplay on your view instead'); + publicAPI.displayToView = () => + vtkErrorMacro('call displayToView on your view instead'); + publicAPI.viewToDisplay = () => + vtkErrorMacro('callviewtodisplay on your view instead'); publicAPI.getSize = () => vtkErrorMacro('call getSize on your View instead'); publicAPI.normalizedDisplayToView = (x, y, z) => { @@ -73,30 +76,52 @@ function vtkViewport(publicAPI, model) { }; publicAPI.normalizedDisplayToNormalizedViewport = (x, y, z) => { - const scale = [model.viewport[2] - model.viewport[0], - model.viewport[3] - model.viewport[1]]; - return [(x - model.viewport[0]) / scale[0], (y - model.viewport[1]) / scale[1], z]; + const scale = [ + model.viewport[2] - model.viewport[0], + model.viewport[3] - model.viewport[1], + ]; + return [ + (x - model.viewport[0]) / scale[0], + (y - model.viewport[1]) / scale[1], + z, + ]; }; - publicAPI.normalizedViewportToView = (x, y, z) => - [(x * 2.0) - 1.0, (y * 2.0) - 1.0, (z * 2.0) - 1.0]; + publicAPI.normalizedViewportToView = (x, y, z) => [ + x * 2.0 - 1.0, + y * 2.0 - 1.0, + z * 2.0 - 1.0, + ]; publicAPI.viewToNormalizedDisplay = (x, y, z) => { // first to nvp const nvp = publicAPI.viewToNormalizedViewport(x, y, z); // then to ndp - return publicAPI.normalizedViewportToNormalizedDisplay(nvp[0], nvp[1], nvp[2]); + return publicAPI.normalizedViewportToNormalizedDisplay( + nvp[0], + nvp[1], + nvp[2] + ); }; publicAPI.normalizedViewportToNormalizedDisplay = (x, y, z) => { - const scale = [model.viewport[2] - model.viewport[0], - model.viewport[3] - model.viewport[1]]; - return [(x * scale[0]) + model.viewport[0], (y * scale[1]) + model.viewport[1], z]; + const scale = [ + model.viewport[2] - model.viewport[0], + model.viewport[3] - model.viewport[1], + ]; + return [ + x * scale[0] + model.viewport[0], + y * scale[1] + model.viewport[1], + z, + ]; }; - publicAPI.viewToNormalizedViewport = (x, y, z) => - [(x + 1.0) * 0.5, (y + 1.0) * 0.5, (z + 1.0) * 0.5]; + publicAPI.viewToNormalizedViewport = (x, y, z) => [ + (x + 1.0) * 0.5, + (y + 1.0) * 0.5, + (z + 1.0) * 0.5, + ]; publicAPI.PickPropFrom = notImplemented('PickPropFrom'); } @@ -126,14 +151,9 @@ export function extend(publicAPI, model, initialValues = {}) { macro.obj(publicAPI, model); macro.event(publicAPI, model, 'event'); - macro.setGetArray(publicAPI, model, [ - 'viewport', - ], 4); + macro.setGetArray(publicAPI, model, ['viewport'], 4); - macro.setGetArray(publicAPI, model, [ - 'background', - 'background2', - ], 3); + macro.setGetArray(publicAPI, model, ['background', 'background2'], 3); vtkViewport(publicAPI, model); } diff --git a/Sources/Rendering/Core/Volume/index.js b/Sources/Rendering/Core/Volume/index.js index 84289751064..c3856b5a0ec 100644 --- a/Sources/Rendering/Core/Volume/index.js +++ b/Sources/Rendering/Core/Volume/index.js @@ -1,7 +1,7 @@ import { vec3, mat4 } from 'gl-matrix'; -import macro from 'vtk.js/Sources/macro'; -import vtkProp3D from 'vtk.js/Sources/Rendering/Core/Prop3D'; -import vtkVolumeProperty from 'vtk.js/Sources/Rendering/Core/VolumeProperty'; +import macro from 'vtk.js/Sources/macro'; +import vtkProp3D from 'vtk.js/Sources/Rendering/Core/Prop3D'; +import vtkVolumeProperty from 'vtk.js/Sources/Rendering/Core/VolumeProperty'; const { vtkDebugMacro } = macro; @@ -48,12 +48,17 @@ function vtkVolume(publicAPI, model) { // of caching. If the values returned this time are different, or // the modified time of this class is newer than the cached time, // then we need to rebuild. - const zip = rows => rows[0].map((_, c) => rows.map(row => row[c])); - if (!model.mapperBounds || - !zip([bds, model.mapperBounds]).reduce((a, b) => (a && b[0] === b[1]), true) || - publicAPI.getMTime() > model.boundsMTime.getMTime()) { + const zip = (rows) => rows[0].map((_, c) => rows.map((row) => row[c])); + if ( + !model.mapperBounds || + !zip([bds, model.mapperBounds]).reduce( + (a, b) => a && b[0] === b[1], + true + ) || + publicAPI.getMTime() > model.boundsMTime.getMTime() + ) { vtkDebugMacro('Recomputing bounds...'); - model.mapperBounds = bds.map(x => x); + model.mapperBounds = bds.map((x) => x); const bbox = [ vec3.fromValues(bds[1], bds[3], bds[5]), vec3.fromValues(bds[1], bds[2], bds[5]), @@ -68,15 +73,21 @@ function vtkVolume(publicAPI, model) { publicAPI.computeMatrix(); const tmp4 = mat4.create(); mat4.transpose(tmp4, model.matrix); - bbox.forEach(pt => vec3.transformMat4(pt, pt, tmp4)); + bbox.forEach((pt) => vec3.transformMat4(pt, pt, tmp4)); /* eslint-disable no-multi-assign */ model.bounds[0] = model.bounds[2] = model.bounds[4] = Number.MAX_VALUE; model.bounds[1] = model.bounds[3] = model.bounds[5] = -Number.MAX_VALUE; /* eslint-enable no-multi-assign */ - model.bounds = model.bounds.map((d, i) => ((i % 2 === 0) ? - bbox.reduce((a, b) => (a > b[i / 2] ? b[i / 2] : a), d) : - bbox.reduce((a, b) => (a < b[(i - 1) / 2] ? b[(i - 1) / 2] : a), d))); + model.bounds = model.bounds.map( + (d, i) => + i % 2 === 0 + ? bbox.reduce((a, b) => (a > b[i / 2] ? b[i / 2] : a), d) + : bbox.reduce( + (a, b) => (a < b[(i - 1) / 2] ? b[(i - 1) / 2] : a), + d + ) + ); model.boundsMTime.modified(); } return model.bounds; @@ -86,7 +97,7 @@ function vtkVolume(publicAPI, model) { let mt = model.mtime; if (model.property !== null) { const time = model.property.getMTime(); - mt = (time > mt ? time : mt); + mt = time > mt ? time : mt; } return mt; }; @@ -95,12 +106,12 @@ function vtkVolume(publicAPI, model) { let mt = model.mtime; if (model.mapper !== null) { let time = model.mapper.getMTime(); - mt = (time > mt ? time : mt); + mt = time > mt ? time : mt; if (model.mapper.getInput() !== null) { // FIXME !!! getInputAlgorithm / getInput model.mapper.getInputAlgorithm().update(); time = model.mapper.getInput().getMTime(); - mt = (time > mt ? time : mt); + mt = time > mt ? time : mt; } } return mt; @@ -131,9 +142,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.set(publicAPI, model, ['property']); - macro.setGet(publicAPI, model, [ - 'mapper', - ]); + macro.setGet(publicAPI, model, ['mapper']); macro.getArray(publicAPI, model, ['bounds'], 6); // Object methods diff --git a/Sources/Rendering/Core/VolumeMapper/example/index.js b/Sources/Rendering/Core/VolumeMapper/example/index.js index b9f9fc56e86..78cdd0af284 100644 --- a/Sources/Rendering/Core/VolumeMapper/example/index.js +++ b/Sources/Rendering/Core/VolumeMapper/example/index.js @@ -1,17 +1,19 @@ import 'vtk.js/Sources/favicon'; -import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; -import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction'; -import vtkVolume from 'vtk.js/Sources/Rendering/Core/Volume'; -import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper'; +import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; +import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction'; +import vtkVolume from 'vtk.js/Sources/Rendering/Core/Volume'; +import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper'; // ---------------------------------------------------------------------------- // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); diff --git a/Sources/Rendering/Core/VolumeMapper/index.js b/Sources/Rendering/Core/VolumeMapper/index.js index 4c928abec63..dc893a8d15f 100644 --- a/Sources/Rendering/Core/VolumeMapper/index.js +++ b/Sources/Rendering/Core/VolumeMapper/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkMath from 'vtk.js/Sources/Common/Core/Math'; // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/Core/VolumeProperty/index.js b/Sources/Rendering/Core/VolumeProperty/index.js index 959f7fc0dd6..54226ca338f 100644 --- a/Sources/Rendering/Core/VolumeProperty/index.js +++ b/Sources/Rendering/Core/VolumeProperty/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction'; import Constants from 'vtk.js/Sources/Rendering/Core/VolumeProperty/Constants'; @@ -26,13 +26,13 @@ function vtkVolumeProperty(publicAPI, model) { if (model.componentData[index].grayTransferFunction) { // time that Gray transfer function was last modified time = model.componentData[index].grayTransferFunction.getMTime(); - mTime = (mTime > time ? mTime : time); + mTime = mTime > time ? mTime : time; } } else if (model.componentData[index].colorChannels === 3) { if (model.componentData[index].rGBTransferFunction) { // time that RGB transfer function was last modified time = model.componentData[index].rGBTransferFunction.getMTime(); - mTime = (mTime > time ? mTime : time); + mTime = mTime > time ? mTime : time; } } @@ -40,14 +40,14 @@ function vtkVolumeProperty(publicAPI, model) { if (model.componentData[index].scalarOpacity) { // time that Scalar opacity transfer function was last modified time = model.componentData[index].scalarOpacity.getMTime(); - mTime = (mTime > time ? mTime : time); + mTime = mTime > time ? mTime : time; } if (model.componentData[index].gradientOpacity) { if (!model.componentData[index].disableGradientOpacity) { // time that Gradient opacity transfer function was last modified time = model.componentData[index].gradientOpacity.getMTime(); - mTime = (mTime > time ? mTime : time); + mTime = mTime > time ? mTime : time; } } } @@ -80,7 +80,9 @@ function vtkVolumeProperty(publicAPI, model) { // Get the currently set gray transfer function. Create one if none set. publicAPI.getGrayTransferFunction = (index) => { if (model.componentData[index].grayTransferFunction === null) { - model.componentData[index].grayTransferFunction = vtkPiecewiseFunction.newInstance(); + model.componentData[ + index + ].grayTransferFunction = vtkPiecewiseFunction.newInstance(); model.componentData[index].grayTransferFunction.addPoint(0, 0.0); model.componentData[index].grayTransferFunction.addPoint(1024, 1.0); if (model.componentData[index].colorChannels !== 1) { @@ -108,9 +110,21 @@ function vtkVolumeProperty(publicAPI, model) { // Get the currently set RGB transfer function. Create one if none set. publicAPI.getRGBTransferFunction = (index) => { if (model.componentData[index].rGBTransferFunction === null) { - model.componentData[index].rGBTransferFunction = vtkColorTransferFunction.newInstance(); - model.componentData[index].rGBTransferFunction.addRGBPoint(0, 0.0, 0.0, 0.0); - model.componentData[index].rGBTransferFunction.addRGBPoint(1024, 1.0, 1.0, 1.0); + model.componentData[ + index + ].rGBTransferFunction = vtkColorTransferFunction.newInstance(); + model.componentData[index].rGBTransferFunction.addRGBPoint( + 0, + 0.0, + 0.0, + 0.0 + ); + model.componentData[index].rGBTransferFunction.addRGBPoint( + 1024, + 1.0, + 1.0, + 1.0 + ); if (model.componentData[index].colorChannels !== 3) { model.componentData[index].colorChannels = 3; } @@ -131,7 +145,9 @@ function vtkVolumeProperty(publicAPI, model) { // Get the scalar opacity transfer function. Create one if none set. publicAPI.getScalarOpacity = (index) => { if (model.componentData[index].scalarOpacity === null) { - model.componentData[index].scalarOpacity = vtkPiecewiseFunction.newInstance(); + model.componentData[ + index + ].scalarOpacity = vtkPiecewiseFunction.newInstance(); model.componentData[index].scalarOpacity.addPoint(0, 1.0); model.componentData[index].scalarOpacity.addPoint(1024, 1.0); publicAPI.modified(); @@ -146,7 +162,7 @@ function vtkVolumeProperty(publicAPI, model) { return; } - const val = value < 0.0 ? 0.0 : (value > 1.0 ? 1.0 : value); + const val = value < 0.0 ? 0.0 : value > 1.0 ? 1.0 : value; if (model.componentData[index].componentWeight !== val) { model.componentData[index].componentWeight = val; publicAPI.modified(); @@ -174,12 +190,17 @@ function vtkVolumeProperty(publicAPI, model) { publicAPI.setInterpolationType(InterpolationType.FAST_LINEAR); }; - publicAPI.getInterpolationTypeAsString = () => macro.enumToString(InterpolationType, model.interpolationType); + publicAPI.getInterpolationTypeAsString = () => + macro.enumToString(InterpolationType, model.interpolationType); const sets = [ - 'useGradientOpacity', 'scalarOpacityUnitDistance', - 'gradientOpacityMinimumValue', 'gradientOpacityMinimumOpacity', - 'gradientOpacityMaximumValue', 'gradientOpacityMaximumOpacity']; + 'useGradientOpacity', + 'scalarOpacityUnitDistance', + 'gradientOpacityMinimumValue', + 'gradientOpacityMinimumOpacity', + 'gradientOpacityMaximumValue', + 'gradientOpacityMaximumOpacity', + ]; sets.forEach((val) => { const cap = macro.capitalize(val); publicAPI[`set${cap}`] = (index, value) => { @@ -191,12 +212,16 @@ function vtkVolumeProperty(publicAPI, model) { }); const gets = [ - 'useGradientOpacity', 'scalarOpacityUnitDistance', - 'gradientOpacityMinimumValue', 'gradientOpacityMinimumOpacity', - 'gradientOpacityMaximumValue', 'gradientOpacityMaximumOpacity']; + 'useGradientOpacity', + 'scalarOpacityUnitDistance', + 'gradientOpacityMinimumValue', + 'gradientOpacityMinimumOpacity', + 'gradientOpacityMaximumValue', + 'gradientOpacityMaximumOpacity', + ]; gets.forEach((val) => { const cap = macro.capitalize(val); - publicAPI[`get${cap}`] = index => model.componentData[index][`${val}`]; + publicAPI[`get${cap}`] = (index) => model.componentData[index][`${val}`]; }); } diff --git a/Sources/Rendering/Core/index.js b/Sources/Rendering/Core/index.js index 512d2f548dd..79d0bedd545 100644 --- a/Sources/Rendering/Core/index.js +++ b/Sources/Rendering/Core/index.js @@ -1,37 +1,37 @@ -import vtkAbstractMapper from './AbstractMapper'; -import vtkAbstractMapper3D from './AbstractMapper3D'; -import vtkAbstractPicker from './AbstractPicker'; -import vtkActor from './Actor'; -import vtkActor2D from './Actor2D'; -import vtkCamera from './Camera'; -import vtkCellPicker from './CellPicker'; -import vtkColorTransferFunction from './ColorTransferFunction'; -import vtkCoordinate from './Coordinate'; -import vtkGlyph3DMapper from './Glyph3DMapper'; -import vtkImageMapper from './ImageMapper'; -import vtkImageProperty from './ImageProperty'; -import vtkImageSlice from './ImageSlice'; -import vtkInteractorObserver from './InteractorObserver'; -import vtkInteractorStyle from './InteractorStyle'; -import vtkLight from './Light'; -import vtkMapper from './Mapper'; -import vtkPicker from './Picker'; -import vtkPointPicker from './PointPicker'; -import vtkProp from './Prop'; -import vtkProp3D from './Prop3D'; -import vtkProperty from './Property'; -import vtkProperty2D from './Property2D'; -import vtkRenderer from './Renderer'; -import vtkRenderWindow from './RenderWindow'; -import vtkRenderWindowInteractor from './RenderWindowInteractor'; -import vtkRepresentation from './Representation'; -import vtkSphereMapper from './SphereMapper'; -import vtkStickMapper from './StickMapper'; -import vtkTexture from './Texture'; -import vtkViewport from './Viewport'; -import vtkVolume from './Volume'; -import vtkVolumeMapper from './VolumeMapper'; -import vtkVolumeProperty from './VolumeProperty'; +import vtkAbstractMapper from './AbstractMapper'; +import vtkAbstractMapper3D from './AbstractMapper3D'; +import vtkAbstractPicker from './AbstractPicker'; +import vtkActor from './Actor'; +import vtkActor2D from './Actor2D'; +import vtkCamera from './Camera'; +import vtkCellPicker from './CellPicker'; +import vtkColorTransferFunction from './ColorTransferFunction'; +import vtkCoordinate from './Coordinate'; +import vtkGlyph3DMapper from './Glyph3DMapper'; +import vtkImageMapper from './ImageMapper'; +import vtkImageProperty from './ImageProperty'; +import vtkImageSlice from './ImageSlice'; +import vtkInteractorObserver from './InteractorObserver'; +import vtkInteractorStyle from './InteractorStyle'; +import vtkLight from './Light'; +import vtkMapper from './Mapper'; +import vtkPicker from './Picker'; +import vtkPointPicker from './PointPicker'; +import vtkProp from './Prop'; +import vtkProp3D from './Prop3D'; +import vtkProperty from './Property'; +import vtkProperty2D from './Property2D'; +import vtkRenderer from './Renderer'; +import vtkRenderWindow from './RenderWindow'; +import vtkRenderWindowInteractor from './RenderWindowInteractor'; +import vtkRepresentation from './Representation'; +import vtkSphereMapper from './SphereMapper'; +import vtkStickMapper from './StickMapper'; +import vtkTexture from './Texture'; +import vtkViewport from './Viewport'; +import vtkVolume from './Volume'; +import vtkVolumeMapper from './VolumeMapper'; +import vtkVolumeProperty from './VolumeProperty'; export default { vtkAbstractMapper, diff --git a/Sources/Rendering/Misc/FullScreenRenderWindow/index.js b/Sources/Rendering/Misc/FullScreenRenderWindow/index.js index 47276191b4c..4495ea1099a 100644 --- a/Sources/Rendering/Misc/FullScreenRenderWindow/index.js +++ b/Sources/Rendering/Misc/FullScreenRenderWindow/index.js @@ -1,8 +1,8 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderWindowInteractor from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor'; +import macro from 'vtk.js/Sources/macro'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderWindowInteractor from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor'; // Load basic classes for vtk() factory import 'vtk.js/Sources/Common/Core/Points'; @@ -84,7 +84,10 @@ function vtkFullScreenRenderWindow(publicAPI, model) { publicAPI.addController = (html) => { model.controlContainer = document.createElement('div'); - applyStyle(model.controlContainer, model.controlPanelStyle || STYLE_CONTROL_PANEL); + applyStyle( + model.controlContainer, + model.controlPanelStyle || STYLE_CONTROL_PANEL + ); model.rootContainer.appendChild(model.controlContainer); model.controlContainer.innerHTML = html; @@ -109,13 +112,18 @@ function vtkFullScreenRenderWindow(publicAPI, model) { }); }; publicAPI.removeRepresentation = (representation) => { - representation.getActors().forEach(actor => model.renderer.removeActor(actor)); + representation + .getActors() + .forEach((actor) => model.renderer.removeActor(actor)); }; // Handle window resize publicAPI.resize = () => { const dims = model.container.getBoundingClientRect(); - model.openGLRenderWindow.setSize(Math.floor(dims.width), Math.floor(dims.height)); + model.openGLRenderWindow.setSize( + Math.floor(dims.width), + Math.floor(dims.height) + ); if (model.resizeCallback) { model.resizeCallback(dims); } diff --git a/Sources/Rendering/Misc/GenericRenderWindow/index.js b/Sources/Rendering/Misc/GenericRenderWindow/index.js index 1b682a96d33..6d38575fb26 100644 --- a/Sources/Rendering/Misc/GenericRenderWindow/index.js +++ b/Sources/Rendering/Misc/GenericRenderWindow/index.js @@ -1,8 +1,8 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderWindowInteractor from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor'; +import macro from 'vtk.js/Sources/macro'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderWindowInteractor from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor'; // Load basic classes for vtk() factory import 'vtk.js/Sources/Common/Core/Points'; @@ -40,7 +40,10 @@ function vtkGenericRenderWindow(publicAPI, model) { publicAPI.resize = () => { if (model.container) { const dims = model.container.getBoundingClientRect(); - model.openGlRenderWindow.setSize(Math.floor(dims.width), Math.floor(dims.height)); + model.openGlRenderWindow.setSize( + Math.floor(dims.width), + Math.floor(dims.height) + ); invokeResize(); model.renderWindow.render(); } diff --git a/Sources/Rendering/Misc/RenderWindowWithControlBar/example/index.js b/Sources/Rendering/Misc/RenderWindowWithControlBar/example/index.js index 5922877f8d2..7ba2ac988a3 100644 --- a/Sources/Rendering/Misc/RenderWindowWithControlBar/example/index.js +++ b/Sources/Rendering/Misc/RenderWindowWithControlBar/example/index.js @@ -1,10 +1,10 @@ import vtkRenderWindowWithControlBar from 'vtk.js/Sources/Rendering/Misc/RenderWindowWithControlBar'; -import vtkSlider from 'vtk.js/Sources/Interaction/UI/Slider'; -import vtkCornerAnnotation from 'vtk.js/Sources/Interaction/UI/CornerAnnotation'; +import vtkSlider from 'vtk.js/Sources/Interaction/UI/Slider'; +import vtkCornerAnnotation from 'vtk.js/Sources/Interaction/UI/CornerAnnotation'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; // Define container size/position const body = document.querySelector('body'); @@ -17,7 +17,9 @@ body.appendChild(rootContainer); body.style.margin = '0'; // Create render window inside container -const renderWindow = vtkRenderWindowWithControlBar.newInstance({ controlSize: 25 }); +const renderWindow = vtkRenderWindowWithControlBar.newInstance({ + controlSize: 25, +}); renderWindow.setContainer(rootContainer); // Add some content to the renderer @@ -55,12 +57,16 @@ cornerAnnotation.updateTemplates({ return `Resolution: ${meta.resolution}`; }, se(meta) { - return `mtime:${meta.mtime}
Annotation Corner`; + return `mtime:${ + meta.mtime + }
Annotation Corner`; }, }); // Add slider to the control bar -const sliderContainer = renderWindow.getControlContainer().querySelector('.js-slider'); +const sliderContainer = renderWindow + .getControlContainer() + .querySelector('.js-slider'); sliderContainer.style.flex = '1'; sliderContainer.style.position = 'relative'; sliderContainer.style.minWidth = '25px'; @@ -79,7 +85,9 @@ slider.onValueChange((resolution) => { function updateSizeAndOrientation() { renderWindow.resize(); slider.resize(); - renderWindow.getControlContainer().style.flexFlow = slider.getOrientation() ? 'row' : 'column'; + renderWindow.getControlContainer().style.flexFlow = slider.getOrientation() + ? 'row' + : 'column'; setTimeout(slider.resize, 0); } updateSizeAndOrientation(); diff --git a/Sources/Rendering/Misc/RenderWindowWithControlBar/index.js b/Sources/Rendering/Misc/RenderWindowWithControlBar/index.js index 72cf20bdfa5..64accc22e09 100644 --- a/Sources/Rendering/Misc/RenderWindowWithControlBar/index.js +++ b/Sources/Rendering/Misc/RenderWindowWithControlBar/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkGenericRenderWindow from 'vtk.js/Sources/Rendering/Misc/GenericRenderWindow'; import style from 'vtk.js/Sources/Rendering/Misc/RenderWindowWithControlBar/RenderWindowWithControlBar.mcss'; @@ -74,8 +74,14 @@ function vtkRenderWindowWithControlBar(publicAPI, model) { function updateControlerStyle() { ['left', 'right', 'top', 'bottom'].forEach(resetStyleToZero); - model.renderWindowContainer.style[model.controlPosition] = `${model.controlSize}px`; - applyControlStyle(model.controlContainer, model.controlPosition, model.controlSize); + model.renderWindowContainer.style[model.controlPosition] = `${ + model.controlSize + }px`; + applyControlStyle( + model.controlContainer, + model.controlPosition, + model.controlSize + ); } // Create container for the vtkGenericRenderWindow @@ -157,7 +163,10 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkRenderWindowWithControlBar'); +export const newInstance = macro.newInstance( + extend, + 'vtkRenderWindowWithControlBar' +); // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/Misc/SynchronizableRenderWindow/index.js b/Sources/Rendering/Misc/SynchronizableRenderWindow/index.js index dae3e28b22c..8969e083b43 100644 --- a/Sources/Rendering/Misc/SynchronizableRenderWindow/index.js +++ b/Sources/Rendering/Misc/SynchronizableRenderWindow/index.js @@ -28,25 +28,30 @@ function createArrayHandler() { if (!arrayFetcher) { return new Promise((resolve, reject) => { - reject('No array fetcher found, please use "setArrayFetcher" to provide one'); + reject( + 'No array fetcher found, please use "setArrayFetcher" to provide one' + ); }); } return new Promise((resolve, reject) => { - arrayFetcher(sha).then((data) => { - let buffer = data; - if (typeof data === 'string') { - buffer = toByteArray(data).buffer; + arrayFetcher(sha).then( + (data) => { + let buffer = data; + if (typeof data === 'string') { + buffer = toByteArray(data).buffer; + } + const array = new window[dataType](buffer); + const mtimes = { [context.getActiveViewId()]: context.getMTime() }; + dataArrayCache[sha] = { mtimes, array }; + resolve(array); + }, + (error) => { + console.log('Error getting data array:'); + console.log(error); + reject(error); } - const array = new window[dataType](buffer); - const mtimes = { [context.getActiveViewId()]: context.getMTime() }; - dataArrayCache[sha] = { mtimes, array }; - resolve(array); - }, (error) => { - console.log('Error getting data array:'); - console.log(error); - reject(error); - }); + ); }); } @@ -59,8 +64,11 @@ function createArrayHandler() { function freeOldArrays(threshold, context) { const mtimeThreshold = context.getMTime() - threshold; Object.keys(dataArrayCache) - .filter(key => dataArrayCache[key].mtimes[context.getActiveViewId()]) - .filter(key => dataArrayCache[key].mtimes[context.getActiveViewId()] < mtimeThreshold) + .filter((key) => dataArrayCache[key].mtimes[context.getActiveViewId()]) + .filter( + (key) => + dataArrayCache[key].mtimes[context.getActiveViewId()] < mtimeThreshold + ) .forEach((key) => { delete dataArrayCache[key]; }); @@ -194,12 +202,19 @@ function createSceneMtimeHandler() { function createSyncFunction(renderWindow, synchronizerContext) { const progressHandler = createProgressHandler(renderWindow.render); const mtimeHandler = createSceneMtimeHandler(); - const context = Object.assign({}, synchronizerContext, progressHandler, mtimeHandler); + const context = Object.assign( + {}, + synchronizerContext, + progressHandler, + mtimeHandler + ); let lastMtime = -1; let gcThreshold = 100; - const getManagedInstanceId = instance => instance.get('managedInstanceId').managedInstanceId; - const getManagedInstanceIds = () => macro.traverseInstanceTree(renderWindow, getManagedInstanceId); + const getManagedInstanceId = (instance) => + instance.get('managedInstanceId').managedInstanceId; + const getManagedInstanceIds = () => + macro.traverseInstanceTree(renderWindow, getManagedInstanceId); function clearOneTimeUpdaters() { vtkObjectManager.clearOneTimeUpdaters(getManagedInstanceIds()); @@ -232,7 +247,14 @@ function createSyncFunction(renderWindow, synchronizerContext) { return false; } - return { synchronize, setSynchronizedViewId, getSynchronizedViewId, updateGarbageCollectorThreshold, getManagedInstanceIds, clearOneTimeUpdaters }; + return { + synchronize, + setSynchronizedViewId, + getSynchronizedViewId, + updateGarbageCollectorThreshold, + getManagedInstanceIds, + clearOneTimeUpdaters, + }; } // ---------------------------------------------------------------------------- @@ -244,7 +266,9 @@ function vtkSynchronizableRenderWindow(publicAPI, model) { model.classHierarchy.push('vtkSynchronizableRenderWindow'); if (!model.synchronizerContext) { - model.synchronizerContext = getSynchronizerContext(model.synchronizerContextName); + model.synchronizerContext = getSynchronizerContext( + model.synchronizerContextName + ); } const addOn = createSyncFunction(publicAPI, model.synchronizerContext); @@ -278,7 +302,10 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkSynchronizableRenderWindow'); +export const newInstance = macro.newInstance( + extend, + 'vtkSynchronizableRenderWindow' +); // ---------------------------------------------------------------------------- // More Static methods diff --git a/Sources/Rendering/Misc/SynchronizableRenderWindow/vtkObjectManager.js b/Sources/Rendering/Misc/SynchronizableRenderWindow/vtkObjectManager.js index ad5b215ae1e..cbef7aed680 100644 --- a/Sources/Rendering/Misc/SynchronizableRenderWindow/vtkObjectManager.js +++ b/Sources/Rendering/Misc/SynchronizableRenderWindow/vtkObjectManager.js @@ -1,13 +1,13 @@ -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkCamera from 'vtk.js/Sources/Rendering/Core/Camera'; -import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; -import vtkLookupTable from 'vtk.js/Sources/Common/Core/LookupTable'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; -import vtkProperty from 'vtk.js/Sources/Rendering/Core/Property'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkCamera from 'vtk.js/Sources/Rendering/Core/Camera'; +import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; +import vtkLookupTable from 'vtk.js/Sources/Common/Core/LookupTable'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import vtkProperty from 'vtk.js/Sources/Rendering/Core/Property'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; // ---------------------------------------------------------------------------- // Some internal, module-level variables and methods @@ -28,7 +28,10 @@ function extractCallArgs(synchronizerContext, argList) { } function extractInstanceIds(argList) { - return argList.map(arg => WRAPPED_ID_RE.exec(arg)).filter(m => m).map(m => m[1]); + return argList + .map((arg) => WRAPPED_ID_RE.exec(arg)) + .filter((m) => m) + .map((m) => m[1]); } function extractDependencyIds(state, depList = []) { @@ -134,7 +137,9 @@ function genericUpdater(instance, state, context) { } if (state.calls) { - state.calls.forEach(call => instance[call[0]].apply(null, extractCallArgs(context, call[1]))); + state.calls.forEach((call) => + instance[call[0]].apply(null, extractCallArgs(context, call[1])) + ); } context.end(); @@ -179,7 +184,7 @@ function rendererUpdater(instance, state, context) { if (viewPropInstance) { const flattenedDepIds = extractDependencyIds(childState); viewPropInstance.set({ flattenedDepIds }, true); - flattenedDepIds.forEach(depId => allActorsDeps.add(depId)); + flattenedDepIds.forEach((depId) => allActorsDeps.add(depId)); } }); } @@ -189,26 +194,31 @@ function rendererUpdater(instance, state, context) { const unregisterCandidates = new Set(); if (state.calls) { - state.calls.filter(call => call[0] === 'removeViewProp').forEach((call) => { - // extract any ids associated with a 'removeViewProp' call (though really there - // should just be a single one), and use them to build a flat list of all - // representation dependency ids which we can then use our synchronizer context - // to unregister - extractInstanceIds(call[1]).forEach((vpId) => { - const deps = context.getInstance(vpId).get('flattenedDepIds').flattenedDepIds; - if (deps) { - // Consider each dependency for unregistering - deps.forEach(depId => unregisterCandidates.add(depId)); - } - // Consider the viewProp itself for unresistering - unregisterCandidates.add(vpId); + state.calls + .filter((call) => call[0] === 'removeViewProp') + .forEach((call) => { + // extract any ids associated with a 'removeViewProp' call (though really there + // should just be a single one), and use them to build a flat list of all + // representation dependency ids which we can then use our synchronizer context + // to unregister + extractInstanceIds(call[1]).forEach((vpId) => { + const deps = context.getInstance(vpId).get('flattenedDepIds') + .flattenedDepIds; + if (deps) { + // Consider each dependency for unregistering + deps.forEach((depId) => unregisterCandidates.add(depId)); + } + // Consider the viewProp itself for unresistering + unregisterCandidates.add(vpId); + }); }); - }); } // Now unregister any instances that are no longer needed - const idsToUnregister = [...unregisterCandidates].filter(depId => !allActorsDeps.has(depId)); - idsToUnregister.forEach(depId => context.unregisterInstance(depId)); + const idsToUnregister = [...unregisterCandidates].filter( + (depId) => !allActorsDeps.has(depId) + ); + idsToUnregister.forEach((depId) => context.unregisterInstance(depId)); } // ---------------------------------------------------------------------------- @@ -219,23 +229,25 @@ function vtkRenderWindowUpdater(instance, state, context) { // itself. This will clear the screen, at which point we can go about the normal // updater process. if (state.calls) { - state.calls.filter(call => call[0] === 'removeRenderer').forEach((call) => { - extractInstanceIds(call[1]).forEach((renId) => { - const renderer = context.getInstance(renId); - // Take brief detour through the view props to unregister the dependencies - // of each one - const viewProps = renderer.getViewProps(); - viewProps.forEach((viewProp) => { - const deps = viewProp.get('flattenedDepIds').flattenedDepIds; - if (deps) { - deps.forEach(depId => context.unregisterInstance(depId)); - } - context.unregisterInstance(context.getInstanceId(viewProp)); + state.calls + .filter((call) => call[0] === 'removeRenderer') + .forEach((call) => { + extractInstanceIds(call[1]).forEach((renId) => { + const renderer = context.getInstance(renId); + // Take brief detour through the view props to unregister the dependencies + // of each one + const viewProps = renderer.getViewProps(); + viewProps.forEach((viewProp) => { + const deps = viewProp.get('flattenedDepIds').flattenedDepIds; + if (deps) { + deps.forEach((depId) => context.unregisterInstance(depId)); + } + context.unregisterInstance(context.getInstanceId(viewProp)); + }); + // Now just remove all the view props + renderer.removeAllViewProps(); }); - // Now just remove all the view props - renderer.removeAllViewProps(); }); - }); } instance.render(); @@ -248,7 +260,9 @@ function vtkRenderWindowUpdater(instance, state, context) { function colorTransferFunctionUpdater(instance, state, context) { context.start(); - const nodes = state.properties.nodes.map(([x, r, g, b, midpoint, sharpness]) => ({ x, r, g, b, midpoint, sharpness })); + const nodes = state.properties.nodes.map( + ([x, r, g, b, midpoint, sharpness]) => ({ x, r, g, b, midpoint, sharpness }) + ); instance.set(Object.assign({}, state.properties, { nodes }), true); instance.sortAndUpdateRange(); instance.modified(); @@ -268,7 +282,7 @@ function polydataUpdater(instance, state, context) { ]; function validateDataset() { - if ((arraysToBind.length - 2) === nbArrayToDownload) { + if (arraysToBind.length - 2 === nbArrayToDownload) { while (arraysToBind.length) { const [fn, args] = arraysToBind.shift(); fn(...args); @@ -283,31 +297,45 @@ function polydataUpdater(instance, state, context) { if (props[arrayName]) { nbArrayToDownload += 1; const arrayMetadata = props[arrayName]; - context.getArray(arrayMetadata.hash, arrayMetadata.dataType, context) + context + .getArray(arrayMetadata.hash, arrayMetadata.dataType, context) .then( (values) => { - arraysToBind.push([instance.get(arrayName)[arrayName].setData, [values, arrayMetadata.numberOfComponents]]); + arraysToBind.push([ + instance.get(arrayName)[arrayName].setData, + [values, arrayMetadata.numberOfComponents], + ]); validateDataset(); }, (error) => { console.log('error geometry fetching array', error); - }); + } + ); } }); // Fetch needed data arrays... props.fields.forEach((arrayMetadata) => { - context.getArray(arrayMetadata.hash, arrayMetadata.dataType, context) - .then( - (values) => { - const array = vtkDataArray.newInstance(Object.assign({ values }, arrayMetadata)); - const regMethod = arrayMetadata.registration ? arrayMetadata.registration : 'addArray'; - arraysToBind.push([instance.get(arrayMetadata.location)[arrayMetadata.location][regMethod], [array]]); - validateDataset(); - }, - (error) => { - console.log('error field fetching array', error); - }); + context.getArray(arrayMetadata.hash, arrayMetadata.dataType, context).then( + (values) => { + const array = vtkDataArray.newInstance( + Object.assign({ values }, arrayMetadata) + ); + const regMethod = arrayMetadata.registration + ? arrayMetadata.registration + : 'addArray'; + arraysToBind.push([ + instance.get(arrayMetadata.location)[arrayMetadata.location][ + regMethod + ], + [array], + ]); + validateDataset(); + }, + (error) => { + console.log('error field fetching array', error); + } + ); }); } @@ -358,7 +386,6 @@ const DEFAULT_MAPPING = { }, }; - function setDefaultMapping(reset = true) { if (reset) { clearTypeMapping(); diff --git a/Sources/Rendering/OpenGL/Actor/index.js b/Sources/Rendering/OpenGL/Actor/index.js index a9c24c3c0a3..1dc08e85b31 100644 --- a/Sources/Rendering/OpenGL/Actor/index.js +++ b/Sources/Rendering/OpenGL/Actor/index.js @@ -1,6 +1,6 @@ import { mat3, mat4 } from 'gl-matrix'; -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; // ---------------------------------------------------------------------------- @@ -14,7 +14,9 @@ function vtkOpenGLActor(publicAPI, model) { // Builds myself. publicAPI.buildPass = (prepass) => { if (prepass) { - model.openGLRenderWindow = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderWindow'); + model.openGLRenderWindow = publicAPI.getFirstAncestorOfType( + 'vtkOpenGLRenderWindow' + ); model.context = model.openGLRenderWindow.getContext(); publicAPI.prepareNodes(); publicAPI.addMissingNodes(model.renderable.getTextures()); @@ -44,9 +46,11 @@ function vtkOpenGLActor(publicAPI, model) { // we draw textures, then mapper, then post pass textures publicAPI.traverseOpaquePass = (renderPass) => { - if (!model.renderable || - !model.renderable.getVisibility() || - !model.renderable.getIsOpaque()) { + if ( + !model.renderable || + !model.renderable.getVisibility() || + !model.renderable.getIsOpaque() + ) { return; } @@ -59,9 +63,11 @@ function vtkOpenGLActor(publicAPI, model) { // we draw textures, then mapper, then post pass textures publicAPI.traverseTranslucentPass = (renderPass) => { - if (!model.renderable || - !model.renderable.getVisibility() || - model.renderable.getIsOpaque()) { + if ( + !model.renderable || + !model.renderable.getVisibility() || + model.renderable.getIsOpaque() + ) { return; } @@ -90,8 +96,7 @@ function vtkOpenGLActor(publicAPI, model) { publicAPI.queryPass = (prepass, renderPass) => { if (prepass) { - if (!model.renderable || - !model.renderable.getVisibility()) { + if (!model.renderable || !model.renderable.getVisibility()) { return; } if (model.renderable.getIsOpaque()) { @@ -102,7 +107,8 @@ function vtkOpenGLActor(publicAPI, model) { } }; - publicAPI.opaqueZBufferPass = (prepass, renderPass) => publicAPI.opaquePass(prepass, renderPass); + publicAPI.opaqueZBufferPass = (prepass, renderPass) => + publicAPI.opaquePass(prepass, renderPass); publicAPI.opaquePass = (prepass, renderPass) => { if (prepass) { @@ -138,7 +144,10 @@ function vtkOpenGLActor(publicAPI, model) { mat3.identity(model.keyMatrices.normalMatrix); } else { mat3.fromMat4(model.keyMatrices.normalMatrix, model.keyMatrices.mcwc); - mat3.invert(model.keyMatrices.normalMatrix, model.keyMatrices.normalMatrix); + mat3.invert( + model.keyMatrices.normalMatrix, + model.keyMatrices.normalMatrix + ); } model.keyMatrixTime.modified(); } @@ -174,13 +183,9 @@ export function extend(publicAPI, model, initialValues = {}) { }; // Build VTK API - macro.setGet(publicAPI, model, [ - 'context', - ]); + macro.setGet(publicAPI, model, ['context']); - macro.get(publicAPI, model, [ - 'activeTextures', - ]); + macro.get(publicAPI, model, ['activeTextures']); // Object methods vtkOpenGLActor(publicAPI, model); diff --git a/Sources/Rendering/OpenGL/Actor/test/testRotate.js b/Sources/Rendering/OpenGL/Actor/test/testRotate.js index 285677b3cf9..845ad205f1e 100644 --- a/Sources/Rendering/OpenGL/Actor/test/testRotate.js +++ b/Sources/Rendering/OpenGL/Actor/test/testRotate.js @@ -1,12 +1,12 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; import baseline from './testRotate.png'; @@ -16,7 +16,9 @@ test.onlyIfWebGL('Test Actor', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -53,5 +55,12 @@ test.onlyIfWebGL('Test Actor', (t) => { glwindow.setSize(400, 400); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/OpenGL/Actor', t, 1, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Rendering/OpenGL/Actor', + t, + 1, + gc.releaseResources + ); }); diff --git a/Sources/Rendering/OpenGL/Actor2D/index.js b/Sources/Rendering/OpenGL/Actor2D/index.js index 44b942ce855..2e98e419de7 100644 --- a/Sources/Rendering/OpenGL/Actor2D/index.js +++ b/Sources/Rendering/OpenGL/Actor2D/index.js @@ -25,9 +25,11 @@ function vtkOpenGLActor2D(publicAPI, model) { // we draw textures, then mapper, then post pass textures publicAPI.traverseOpaquePass = (renderPass) => { - if (!model.renderable || - !model.renderable.getVisibility() || - !model.renderable.getIsOpaque()) { + if ( + !model.renderable || + !model.renderable.getVisibility() || + !model.renderable.getIsOpaque() + ) { return; } @@ -42,9 +44,11 @@ function vtkOpenGLActor2D(publicAPI, model) { // we draw textures, then mapper, then post pass textures publicAPI.traverseTranslucentPass = (renderPass) => { - if (!model.renderable || - !model.renderable.getVisibility() || - model.renderable.getIsOpaque()) { + if ( + !model.renderable || + !model.renderable.getVisibility() || + model.renderable.getIsOpaque() + ) { return; } @@ -73,7 +77,9 @@ function vtkOpenGLActor2D(publicAPI, model) { // Renders myself publicAPI.opaquePass = (prepass, renderPass) => { if (prepass) { - model.context = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderWindow').getContext(); + model.context = publicAPI + .getFirstAncestorOfType('vtkOpenGLRenderWindow') + .getContext(); model.context.depthMask(true); publicAPI.activateTextures(); } else { @@ -87,7 +93,9 @@ function vtkOpenGLActor2D(publicAPI, model) { // Renders myself publicAPI.translucentPass = (prepass, renderPass) => { if (prepass) { - model.context = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderWindow').getContext(); + model.context = publicAPI + .getFirstAncestorOfType('vtkOpenGLRenderWindow') + .getContext(); model.context.depthMask(false); publicAPI.activateTextures(); } else { @@ -118,13 +126,9 @@ export function extend(publicAPI, model, initialValues = {}) { vtkViewNode.extend(publicAPI, model, initialValues); // Build VTK API - macro.setGet(publicAPI, model, [ - 'context', - ]); + macro.setGet(publicAPI, model, ['context']); - macro.get(publicAPI, model, [ - 'activeTextures', - ]); + macro.get(publicAPI, model, ['activeTextures']); // Object methods vtkOpenGLActor2D(publicAPI, model); diff --git a/Sources/Rendering/OpenGL/BufferObject/index.js b/Sources/Rendering/OpenGL/BufferObject/index.js index 0599b0f1668..c06fd949713 100644 --- a/Sources/Rendering/OpenGL/BufferObject/index.js +++ b/Sources/Rendering/OpenGL/BufferObject/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import Constants from 'vtk.js/Sources/Rendering/OpenGL/BufferObject/Constants'; const { ObjectType } = Constants; @@ -60,7 +60,7 @@ function vtkOpenGLBufferObject(publicAPI, model) { internalHandle = model.context.createBuffer(); internalType = type; } - return (convertType(internalType) === objectTypeGL); + return convertType(internalType) === objectTypeGL; }; publicAPI.upload = (data, type) => { @@ -71,7 +71,11 @@ function vtkOpenGLBufferObject(publicAPI, model) { return false; } model.context.bindBuffer(convertType(internalType), internalHandle); - model.context.bufferData(convertType(internalType), data, model.context.STATIC_DRAW); + model.context.bufferData( + convertType(internalType), + data, + model.context.STATIC_DRAW + ); dirty = false; return true; }; @@ -133,9 +137,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Object methods macro.obj(publicAPI, model); - macro.get(publicAPI, model, [ - 'openGLRenderWindow', - ]); + macro.get(publicAPI, model, ['openGLRenderWindow']); vtkOpenGLBufferObject(publicAPI, model); } diff --git a/Sources/Rendering/OpenGL/Camera/index.js b/Sources/Rendering/OpenGL/Camera/index.js index a126721bf84..368f555ed99 100644 --- a/Sources/Rendering/OpenGL/Camera/index.js +++ b/Sources/Rendering/OpenGL/Camera/index.js @@ -13,7 +13,9 @@ function vtkOpenGLCamera(publicAPI, model) { publicAPI.buildPass = (prepass) => { if (prepass) { - model.openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer'); + model.openGLRenderer = publicAPI.getFirstAncestorOfType( + 'vtkOpenGLRenderer' + ); model.openGLRenderWindow = model.openGLRenderer.getParent(); model.context = model.openGLRenderWindow.getContext(); } @@ -23,8 +25,18 @@ function vtkOpenGLCamera(publicAPI, model) { publicAPI.opaquePass = (prepass) => { if (prepass) { const tsize = model.openGLRenderer.getTiledSizeAndOrigin(); - model.context.viewport(tsize.lowerLeftU, tsize.lowerLeftV, tsize.usize, tsize.vsize); - model.context.scissor(tsize.lowerLeftU, tsize.lowerLeftV, tsize.usize, tsize.vsize); + model.context.viewport( + tsize.lowerLeftU, + tsize.lowerLeftV, + tsize.usize, + tsize.vsize + ); + model.context.scissor( + tsize.lowerLeftU, + tsize.lowerLeftV, + tsize.usize, + tsize.vsize + ); } }; publicAPI.translucentPass = publicAPI.opaquePass; @@ -33,23 +45,34 @@ function vtkOpenGLCamera(publicAPI, model) { publicAPI.getKeyMatrices = (ren) => { // has the camera changed? - if (ren !== model.lastRenderer || + if ( + ren !== model.lastRenderer || model.openGLRenderWindow.getMTime() > model.keyMatrixTime.getMTime() || publicAPI.getMTime() > model.keyMatrixTime.getMTime() || - ren.getMTime() > model.keyMatrixTime.getMTime()) { + ren.getMTime() > model.keyMatrixTime.getMTime() + ) { mat4.copy(model.keyMatrices.wcvc, model.renderable.getViewMatrix()); mat3.fromMat4(model.keyMatrices.normalMatrix, model.keyMatrices.wcvc); - mat3.invert(model.keyMatrices.normalMatrix, model.keyMatrices.normalMatrix); + mat3.invert( + model.keyMatrices.normalMatrix, + model.keyMatrices.normalMatrix + ); mat4.transpose(model.keyMatrices.wcvc, model.keyMatrices.wcvc); const aspectRatio = model.openGLRenderer.getAspectRatio(); - mat4.copy(model.keyMatrices.vcdc, model.renderable.getProjectionMatrix( - aspectRatio, -1, 1)); + mat4.copy( + model.keyMatrices.vcdc, + model.renderable.getProjectionMatrix(aspectRatio, -1, 1) + ); mat4.transpose(model.keyMatrices.vcdc, model.keyMatrices.vcdc); - mat4.multiply(model.keyMatrices.wcdc, model.keyMatrices.vcdc, model.keyMatrices.wcvc); + mat4.multiply( + model.keyMatrices.wcdc, + model.keyMatrices.vcdc, + model.keyMatrices.wcvc + ); model.keyMatrixTime.modified(); model.lastRenderer = ren; @@ -89,10 +112,7 @@ export function extend(publicAPI, model, initialValues = {}) { }; // Build VTK API - macro.setGet(publicAPI, model, [ - 'context', - 'keyMatrixTime', - ]); + macro.setGet(publicAPI, model, ['context', 'keyMatrixTime']); // Object methods vtkOpenGLCamera(publicAPI, model); diff --git a/Sources/Rendering/OpenGL/CellArrayBufferObject/index.js b/Sources/Rendering/OpenGL/CellArrayBufferObject/index.js index 572332fa48c..47695bdab81 100644 --- a/Sources/Rendering/OpenGL/CellArrayBufferObject/index.js +++ b/Sources/Rendering/OpenGL/CellArrayBufferObject/index.js @@ -1,7 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkBufferObject from 'vtk.js/Sources/Rendering/OpenGL/BufferObject'; -import { ObjectType } from 'vtk.js/Sources/Rendering/OpenGL/BufferObject/Constants'; -import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants'; +import macro from 'vtk.js/Sources/macro'; +import vtkBufferObject from 'vtk.js/Sources/Rendering/OpenGL/BufferObject'; +import { ObjectType } from 'vtk.js/Sources/Rendering/OpenGL/BufferObject/Constants'; +import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants'; const { vtkDebugMacro, vtkErrorMacro } = macro; @@ -35,8 +35,12 @@ function vtkOpenGLCellArrayBufferObject(publicAPI, model) { let tcoordData = null; let colorData = null; - const colorComponents = (options.colors ? options.colors.getNumberOfComponents() : 0); - const textureComponents = (options.tcoords ? options.tcoords.getNumberOfComponents() : 0); + const colorComponents = options.colors + ? options.colors.getNumberOfComponents() + : 0; + const textureComponents = options.tcoords + ? options.tcoords.getNumberOfComponents() + : 0; // the values of 4 below are because floats are 4 bytes @@ -91,7 +95,7 @@ function vtkOpenGLCellArrayBufferObject(publicAPI, model) { // for polys we add a bunch of segments and close it for (let i = 0; i < numPoints; ++i) { addAPoint(cellPts[offset + i]); - addAPoint(cellPts[offset + ((i + 1) % numPoints)]); + addAPoint(cellPts[offset + (i + 1) % numPoints]); } }, stripsToWireframe(numPoints, cellPts, offset) { @@ -120,8 +124,8 @@ function vtkOpenGLCellArrayBufferObject(publicAPI, model) { stripsToSurface(npts, cellPts, offset) { for (let i = 0; i < npts - 2; i++) { addAPoint(cellPts[offset + i]); - addAPoint(cellPts[offset + i + 1 + (i % 2)]); - addAPoint(cellPts[offset + i + 1 + ((i + 1) % 2)]); + addAPoint(cellPts[offset + i + 1 + i % 2]); + addAPoint(cellPts[offset + i + 1 + (i + 1) % 2]); } }, }; @@ -138,7 +142,7 @@ function vtkOpenGLCellArrayBufferObject(publicAPI, model) { return numPoints * 2; }, stripsToWireframe(numPoints, cellPts) { - return (numPoints * 4) - 6; + return numPoints * 4 - 6; }, polysToSurface(npts, cellPts) { if (npts < 3) { @@ -167,9 +171,9 @@ function vtkOpenGLCellArrayBufferObject(publicAPI, model) { const array = cellArray.getData(); const size = array.length; let caboCount = 0; - for (let index = 0; index < size;) { + for (let index = 0; index < size; ) { caboCount += countFunc(array[index], array); - index += (array[index] + 1); + index += array[index] + 1; } let packedUCVBO = null; @@ -216,13 +220,13 @@ function vtkOpenGLCellArrayBufferObject(publicAPI, model) { packedUCVBO[ucidx++] = colorData[colorIdx++]; packedUCVBO[ucidx++] = colorData[colorIdx++]; packedUCVBO[ucidx++] = - (colorComponents === 4 ? colorData[colorIdx++] : 255); + colorComponents === 4 ? colorData[colorIdx++] : 255; } }; - for (let index = 0; index < size;) { + for (let index = 0; index < size; ) { func(array[index], array, index + 1); - index += (array[index] + 1); + index += array[index] + 1; cellCount++; } model.elementCount = caboCount; diff --git a/Sources/Rendering/OpenGL/ForwardPass/index.js b/Sources/Rendering/OpenGL/ForwardPass/index.js index 40e144d45f2..932939ebd7d 100644 --- a/Sources/Rendering/OpenGL/ForwardPass/index.js +++ b/Sources/Rendering/OpenGL/ForwardPass/index.js @@ -1,6 +1,6 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkOpenGLFramebuffer from 'vtk.js/Sources/Rendering/OpenGL/Framebuffer'; -import vtkRenderPass from 'vtk.js/Sources/Rendering/SceneGraph/RenderPass'; +import vtkRenderPass from 'vtk.js/Sources/Rendering/SceneGraph/RenderPass'; // ---------------------------------------------------------------------------- @@ -38,7 +38,10 @@ function vtkForwardPass(publicAPI, model) { renNode.traverse(publicAPI); // do we need to capture a zbuffer? - if ((model.opaqueActorCount > 0 && model.volumeCount > 0) || model.depthRequested) { + if ( + (model.opaqueActorCount > 0 && model.volumeCount > 0) || + model.depthRequested + ) { const size = viewNode.getSize(); // make sure the framebuffer is setup if (model.framebuffer === null) { @@ -47,8 +50,7 @@ function vtkForwardPass(publicAPI, model) { model.framebuffer.setOpenGLRenderWindow(viewNode); model.framebuffer.saveCurrentBindingsAndBuffers(); const fbSize = model.framebuffer.getSize(); - if (fbSize === null || - fbSize[0] !== size[0] || fbSize[1] !== size[1]) { + if (fbSize === null || fbSize[0] !== size[0] || fbSize[1] !== size[1]) { model.framebuffer.create(size[0], size[1]); model.framebuffer.populateFramebuffer(); } @@ -83,7 +85,8 @@ function vtkForwardPass(publicAPI, model) { }; publicAPI.incrementOpaqueActorCount = () => model.opaqueActorCount++; - publicAPI.incrementTranslucentActorCount = () => model.translucentActorCount++; + publicAPI.incrementTranslucentActorCount = () => + model.translucentActorCount++; publicAPI.incrementVolumeCount = () => model.volumeCount++; } @@ -108,9 +111,7 @@ export function extend(publicAPI, model, initialValues = {}) { vtkRenderPass.extend(publicAPI, model, initialValues); macro.get(publicAPI, model, ['framebuffer']); - macro.setGet(publicAPI, model, [ - 'depthRequested', - ]); + macro.setGet(publicAPI, model, ['depthRequested']); // Object methods vtkForwardPass(publicAPI, model); diff --git a/Sources/Rendering/OpenGL/Framebuffer/index.js b/Sources/Rendering/OpenGL/Framebuffer/index.js index f275d34564a..87473ef560c 100644 --- a/Sources/Rendering/OpenGL/Framebuffer/index.js +++ b/Sources/Rendering/OpenGL/Framebuffer/index.js @@ -1,7 +1,7 @@ -import * as macro from 'vtk.js/Sources/macro'; +import * as macro from 'vtk.js/Sources/macro'; import vtkOpenGLTexture from 'vtk.js/Sources/Rendering/OpenGL/Texture'; import { VtkDataTypes } from 'vtk.js/Sources/Common/Core/DataArray/Constants'; -import { Filter } from 'vtk.js/Sources/Rendering/OpenGL/Texture/Constants'; +import { Filter } from 'vtk.js/Sources/Rendering/OpenGL/Texture/Constants'; // ---------------------------------------------------------------------------- // vtkFramebuffer methods @@ -15,14 +15,17 @@ function vtkFramebuffer(publicAPI, model) { // publicAPI.getReadMode = () => model.context.READ_FRAMEBUFFER; publicAPI.saveCurrentBindingsAndBuffers = (modeIn) => { - const mode = (typeof modeIn !== 'undefined') ? modeIn : publicAPI.getBothMode(); + const mode = + typeof modeIn !== 'undefined' ? modeIn : publicAPI.getBothMode(); publicAPI.saveCurrentBindings(mode); publicAPI.saveCurrentBuffers(mode); }; publicAPI.saveCurrentBindings = (modeIn) => { const gl = model.context; - model.previousDrawBinding = gl.getParameter(model.context.FRAMEBUFFER_BINDING); + model.previousDrawBinding = gl.getParameter( + model.context.FRAMEBUFFER_BINDING + ); }; publicAPI.saveCurrentBuffers = (modeIn) => { @@ -30,7 +33,8 @@ function vtkFramebuffer(publicAPI, model) { }; publicAPI.restorePreviousBindingsAndBuffers = (modeIn) => { - const mode = (typeof modeIn !== 'undefined') ? modeIn : publicAPI.getBothMode(); + const mode = + typeof modeIn !== 'undefined' ? modeIn : publicAPI.getBothMode(); publicAPI.restorePreviousBindings(mode); publicAPI.restorePreviousBuffers(mode); }; @@ -46,7 +50,9 @@ function vtkFramebuffer(publicAPI, model) { publicAPI.bind = () => { model.context.bindFramebuffer( - model.context.FRAMEBUFFER, model.glFramebuffer); + model.context.FRAMEBUFFER, + model.glFramebuffer + ); if (model.colorTexture) { model.colorTexture.bind(); } @@ -61,7 +67,13 @@ function vtkFramebuffer(publicAPI, model) { publicAPI.setColorBuffer = (texture, mode) => { const gl = model.context; model.colorTexture = texture; - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture.getHandle(), 0); + gl.framebufferTexture2D( + gl.FRAMEBUFFER, + gl.COLOR_ATTACHMENT0, + gl.TEXTURE_2D, + texture.getHandle(), + 0 + ); }; // publicAPI.setDepthBuffer = (texture, mode) => { @@ -114,16 +126,29 @@ function vtkFramebuffer(publicAPI, model) { texture.setMagnificationFilter(Filter.LINEAR); texture.create2DFromRaw( model.glFramebuffer.width, - model.glFramebuffer.height, 4, VtkDataTypes.UNSIGNED_CHAR, null); + model.glFramebuffer.height, + 4, + VtkDataTypes.UNSIGNED_CHAR, + null + ); publicAPI.setColorBuffer(texture); // for now do not count of having a depth buffer texture // as they are not standard webgl 1 model.depthTexture = gl.createRenderbuffer(); gl.bindRenderbuffer(gl.RENDERBUFFER, model.depthTexture); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, - model.glFramebuffer.width, model.glFramebuffer.height); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, model.depthTexture); + gl.renderbufferStorage( + gl.RENDERBUFFER, + gl.DEPTH_COMPONENT16, + model.glFramebuffer.width, + model.glFramebuffer.height + ); + gl.framebufferRenderbuffer( + gl.FRAMEBUFFER, + gl.DEPTH_ATTACHMENT, + gl.RENDERBUFFER, + model.depthTexture + ); }; } @@ -148,9 +173,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.obj(publicAPI, model); - macro.setGet(publicAPI, model, [ - 'colorTexture', - ]); + macro.setGet(publicAPI, model, ['colorTexture']); // For more macro methods, see "Sources/macro.js" // Object specific methods diff --git a/Sources/Rendering/OpenGL/Glyph3DMapper/index.js b/Sources/Rendering/OpenGL/Glyph3DMapper/index.js index 367bac1a327..d452ac9998a 100644 --- a/Sources/Rendering/OpenGL/Glyph3DMapper/index.js +++ b/Sources/Rendering/OpenGL/Glyph3DMapper/index.js @@ -1,11 +1,11 @@ -import { mat3, mat4 } from 'gl-matrix'; +import { mat3, mat4 } from 'gl-matrix'; -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; -import vtkBufferObject from 'vtk.js/Sources/Rendering/OpenGL/BufferObject'; -import vtkProperty from 'vtk.js/Sources/Rendering/Core/Property'; -import vtkOpenGLPolyDataMapper from 'vtk.js/Sources/Rendering/OpenGL/PolyDataMapper'; -import vtkShaderProgram from 'vtk.js/Sources/Rendering/OpenGL/ShaderProgram'; +import vtkBufferObject from 'vtk.js/Sources/Rendering/OpenGL/BufferObject'; +import vtkProperty from 'vtk.js/Sources/Rendering/Core/Property'; +import vtkOpenGLPolyDataMapper from 'vtk.js/Sources/Rendering/OpenGL/PolyDataMapper'; +import vtkShaderProgram from 'vtk.js/Sources/Rendering/OpenGL/ShaderProgram'; const { vtkErrorMacro } = macro; const { Representation } = vtkProperty; @@ -39,7 +39,10 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { } // if there are no points then we are done - if (!model.currentInput.getPoints || !model.currentInput.getPoints().getNumberOfValues()) { + if ( + !model.currentInput.getPoints || + !model.currentInput.getPoints().getNumberOfValues() + ) { return; } @@ -50,7 +53,7 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { model.extension = null; } else if (!model.extension) { model.extension = model.context.getExtension('ANGLE_instanced_arrays'); - model.hardwareSupport = !(!(model.extension)); + model.hardwareSupport = !!model.extension; } const backfaceCulling = actor.getProperty().getBackfaceCulling(); @@ -93,48 +96,64 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { let b1 = b[off + 1]; let b2 = b[off + 2]; let b3 = b[off + 3]; - out[0] = (b0 * a00) + (b1 * a10) + (b2 * a20) + (b3 * a30); - out[1] = (b0 * a01) + (b1 * a11) + (b2 * a21) + (b3 * a31); - out[2] = (b0 * a02) + (b1 * a12) + (b2 * a22) + (b3 * a32); - out[3] = (b0 * a03) + (b1 * a13) + (b2 * a23) + (b3 * a33); - - b0 = b[off + 4]; b1 = b[off + 5]; b2 = b[off + 6]; b3 = b[off + 7]; - out[4] = (b0 * a00) + (b1 * a10) + (b2 * a20) + (b3 * a30); - out[5] = (b0 * a01) + (b1 * a11) + (b2 * a21) + (b3 * a31); - out[6] = (b0 * a02) + (b1 * a12) + (b2 * a22) + (b3 * a32); - out[7] = (b0 * a03) + (b1 * a13) + (b2 * a23) + (b3 * a33); - - b0 = b[off + 8]; b1 = b[off + 9]; b2 = b[off + 10]; b3 = b[off + 11]; - out[8] = (b0 * a00) + (b1 * a10) + (b2 * a20) + (b3 * a30); - out[9] = (b0 * a01) + (b1 * a11) + (b2 * a21) + (b3 * a31); - out[10] = (b0 * a02) + (b1 * a12) + (b2 * a22) + (b3 * a32); - out[11] = (b0 * a03) + (b1 * a13) + (b2 * a23) + (b3 * a33); - - b0 = b[off + 12]; b1 = b[off + 13]; b2 = b[off + 14]; b3 = b[off + 15]; - out[12] = (b0 * a00) + (b1 * a10) + (b2 * a20) + (b3 * a30); - out[13] = (b0 * a01) + (b1 * a11) + (b2 * a21) + (b3 * a31); - out[14] = (b0 * a02) + (b1 * a12) + (b2 * a22) + (b3 * a32); - out[15] = (b0 * a03) + (b1 * a13) + (b2 * a23) + (b3 * a33); + out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[off + 4]; + b1 = b[off + 5]; + b2 = b[off + 6]; + b3 = b[off + 7]; + out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[off + 8]; + b1 = b[off + 9]; + b2 = b[off + 10]; + b3 = b[off + 11]; + out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[off + 12]; + b1 = b[off + 13]; + b2 = b[off + 14]; + b3 = b[off + 15]; + out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; }; publicAPI.replaceShaderNormal = (shaders, ren, actor) => { if (model.hardwareSupport) { - const lastLightComplexity = - model.lastBoundBO.getReferenceByName('lastLightComplexity'); + const lastLightComplexity = model.lastBoundBO.getReferenceByName( + 'lastLightComplexity' + ); if (lastLightComplexity > 0) { let VSSource = shaders.Vertex; if (model.lastBoundBO.getCABO().getNormalOffset()) { - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::Normal::Dec', [ + VSSource = vtkShaderProgram.substitute( + VSSource, + '//VTK::Normal::Dec', + [ 'attribute vec3 normalMC;', 'attribute mat3 gNormal;', 'uniform mat3 normalMatrix;', - 'varying vec3 normalVCVSOutput;']).result; - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::Normal::Impl', [ - 'normalVCVSOutput = normalMatrix * gNormal * normalMC;']).result; + 'varying vec3 normalVCVSOutput;', + ] + ).result; + VSSource = vtkShaderProgram.substitute( + VSSource, + '//VTK::Normal::Impl', + ['normalVCVSOutput = normalMatrix * gNormal * normalMC;'] + ).result; } shaders.Vertex = VSSource; } @@ -142,15 +161,15 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { superClass.replaceShaderNormal(shaders, ren, actor); }; - publicAPI.replaceShaderColor = (shaders, ren, actor) => { if (model.hardwareSupport && model.renderable.getColorArray()) { let VSSource = shaders.Vertex; let GSSource = shaders.Geometry; let FSSource = shaders.Fragment; - const lastLightComplexity = - model.lastBoundBO.getReferenceByName('lastLightComplexity'); + const lastLightComplexity = model.lastBoundBO.getReferenceByName( + 'lastLightComplexity' + ); // create the material/color property declarations, and VS implementation // these are always defined @@ -158,12 +177,14 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { 'uniform float ambient;', 'uniform float diffuse;', 'uniform float specular;', - 'uniform float opacityUniform; // the fragment opacity']; + 'uniform float opacityUniform; // the fragment opacity', + ]; // add more for specular if (lastLightComplexity) { colorDec = colorDec.concat([ 'uniform vec3 specularColorUniform;', - 'uniform float specularPowerUniform;']); + 'uniform float specularPowerUniform;', + ]); } // now handle the more complex fragment shader implementation @@ -172,44 +193,55 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { let colorImpl = [ 'vec3 ambientColor;', ' vec3 diffuseColor;', - ' float opacity;']; + ' float opacity;', + ]; if (lastLightComplexity) { colorImpl = colorImpl.concat([ ' vec3 specularColor;', - ' float specularPower;']); + ' float specularPower;', + ]); } - colorImpl = colorImpl.concat([ - ' opacity = opacityUniform;']); + colorImpl = colorImpl.concat([' opacity = opacityUniform;']); if (lastLightComplexity) { colorImpl = colorImpl.concat([ ' specularColor = specularColorUniform;', - ' specularPower = specularPowerUniform;']); + ' specularPower = specularPowerUniform;', + ]); } if (!model.drawingEdges) { colorDec = colorDec.concat(['varying vec4 vertexColorVSOutput;']); VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Color::Dec', [ 'attribute vec4 gColor;', - 'varying vec4 vertexColorVSOutput;']).result; + 'varying vec4 vertexColorVSOutput;', + ]).result; VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Color::Impl', [ - 'vertexColorVSOutput = gColor;']).result; - GSSource = vtkShaderProgram.substitute(GSSource, - '//VTK::Color::Dec', [ - 'in vec4 vertexColorVSOutput[];', - 'out vec4 vertexColorGSOutput;']).result; - GSSource = vtkShaderProgram.substitute(GSSource, - '//VTK::Color::Impl', [ - 'vertexColorGSOutput = vertexColorVSOutput[i];']).result; + 'vertexColorVSOutput = gColor;', + ]).result; + GSSource = vtkShaderProgram.substitute(GSSource, '//VTK::Color::Dec', [ + 'in vec4 vertexColorVSOutput[];', + 'out vec4 vertexColorGSOutput;', + ]).result; + GSSource = vtkShaderProgram.substitute(GSSource, '//VTK::Color::Impl', [ + 'vertexColorGSOutput = vertexColorVSOutput[i];', + ]).result; } - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Color::Impl', + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Color::Impl', colorImpl.concat([ ' diffuseColor = vertexColorVSOutput.rgb;', ' ambientColor = vertexColorVSOutput.rgb;', - ' opacity = opacity*vertexColorVSOutput.a;'])).result; + ' opacity = opacity*vertexColorVSOutput.a;', + ]) + ).result; - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Color::Dec', - colorDec).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Color::Dec', + colorDec + ).result; shaders.Vertex = VSSource; shaders.Geometry = GSSource; @@ -223,28 +255,37 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { let VSSource = shaders.Vertex; // do we need the vertex in the shader in View Coordinates - const lastLightComplexity = - model.lastBoundBO.getReferenceByName('lastLightComplexity'); + const lastLightComplexity = model.lastBoundBO.getReferenceByName( + 'lastLightComplexity' + ); if (lastLightComplexity > 0) { - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::PositionVC::Impl', [ + VSSource = vtkShaderProgram.substitute( + VSSource, + '//VTK::PositionVC::Impl', + [ 'vec4 gVertexMC = gMatrix * vertexMC;', 'vertexVCVSOutput = MCVCMatrix * gVertexMC;', - ' gl_Position = MCDCMatrix * gVertexMC;']).result; - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::Camera::Dec', [ - 'attribute mat4 gMatrix;', - 'uniform mat4 MCDCMatrix;', - 'uniform mat4 MCVCMatrix;']).result; + ' gl_Position = MCDCMatrix * gVertexMC;', + ] + ).result; + VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Camera::Dec', [ + 'attribute mat4 gMatrix;', + 'uniform mat4 MCDCMatrix;', + 'uniform mat4 MCVCMatrix;', + ]).result; } else { - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::Camera::Dec', [ - 'attribute mat4 gMatrix;', - 'uniform mat4 MCDCMatrix;']).result; - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::PositionVC::Impl', [ + VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Camera::Dec', [ + 'attribute mat4 gMatrix;', + 'uniform mat4 MCDCMatrix;', + ]).result; + VSSource = vtkShaderProgram.substitute( + VSSource, + '//VTK::PositionVC::Impl', + [ 'vec4 gVertexMC = gMatrix * vertexMC;', - ' gl_Position = MCDCMatrix * gVertexMC;']).result; + ' gl_Position = MCDCMatrix * gVertexMC;', + ] + ).result; } shaders.Vertex = VSSource; } @@ -255,7 +296,11 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { normalMatrixUsed, mcvcMatrixUsed, cellBO, - carray, garray, narray, p) => { + carray, + garray, + narray, + p + ) => { const program = cellBO.getProgram(); if (normalMatrixUsed) { @@ -284,24 +329,34 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { const b21 = b[ofs + 7]; const b22 = b[ofs + 8]; - out[0] = (b00 * a00) + (b01 * a10) + (b02 * a20); - out[1] = (b00 * a01) + (b01 * a11) + (b02 * a21); - out[2] = (b00 * a02) + (b01 * a12) + (b02 * a22); + out[0] = b00 * a00 + b01 * a10 + b02 * a20; + out[1] = b00 * a01 + b01 * a11 + b02 * a21; + out[2] = b00 * a02 + b01 * a12 + b02 * a22; - out[3] = (b10 * a00) + (b11 * a10) + (b12 * a20); - out[4] = (b10 * a01) + (b11 * a11) + (b12 * a21); - out[5] = (b10 * a02) + (b11 * a12) + (b12 * a22); + out[3] = b10 * a00 + b11 * a10 + b12 * a20; + out[4] = b10 * a01 + b11 * a11 + b12 * a21; + out[5] = b10 * a02 + b11 * a12 + b12 * a22; - out[6] = (b20 * a00) + (b21 * a10) + (b22 * a20); - out[7] = (b20 * a01) + (b21 * a11) + (b22 * a21); - out[8] = (b20 * a02) + (b21 * a12) + (b22 * a22); + out[6] = b20 * a00 + b21 * a10 + b22 * a20; + out[7] = b20 * a01 + b21 * a11 + b22 * a21; + out[8] = b20 * a02 + b21 * a12 + b22 * a22; program.setUniformMatrix3x3('normalMatrix', model.tmpMat3); } - publicAPI.multiply4x4WithOffset(model.tmpMat4, model.mcdcMatrix, garray, p * 16); + publicAPI.multiply4x4WithOffset( + model.tmpMat4, + model.mcdcMatrix, + garray, + p * 16 + ); program.setUniformMatrix('MCDCMatrix', model.tmpMat4); if (mcvcMatrixUsed) { - publicAPI.multiply4x4WithOffset(model.tmpMat4, model.mcvcMatrix, garray, p * 16); + publicAPI.multiply4x4WithOffset( + model.tmpMat4, + model.mcvcMatrix, + garray, + p * 16 + ); program.setUniformMatrix('MCVCMatrix', model.tmpMat4); } @@ -309,8 +364,8 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { if (carray) { const cdata = carray.getData(); model.tmpColor[0] = cdata[p * 4] / 255.0; - model.tmpColor[1] = cdata[(p * 4) + 1] / 255.0; - model.tmpColor[2] = cdata[(p * 4) + 2] / 255.0; + model.tmpColor[1] = cdata[p * 4 + 1] / 255.0; + model.tmpColor[2] = cdata[p * 4 + 2] / 255.0; program.setUniform3fArray('ambientColorUniform', model.tmpColor); program.setUniform3fArray('diffuseColorUniform', model.tmpColor); } @@ -322,8 +377,8 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { const gl = model.context; const drawSurfaceWithEdges = - (actor.getProperty().getEdgeVisibility() && - representation === Representation.SURFACE); + actor.getProperty().getEdgeVisibility() && + representation === Representation.SURFACE; // // [WMVD]C == {world, model, view, display} coordinates // // E.g., WCDC == world to display coordinate transformation @@ -331,7 +386,11 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { const actMats = model.openGLActor.getKeyMatrices(); // precompute the actor+camera mats once - mat3.multiply(model.normalMatrix, keyMats.normalMatrix, actMats.normalMatrix); + mat3.multiply( + model.normalMatrix, + keyMats.normalMatrix, + actMats.normalMatrix + ); mat4.multiply(model.mcdcMatrix, keyMats.wcdc, actMats.mcwc); mat4.multiply(model.mcvcMatrix, keyMats.wcvc, actMats.mcwc); @@ -347,8 +406,9 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { if (cabo.getElementCount()) { // are we drawing edges model.drawingEdges = - drawSurfaceWithEdges && (i === model.primTypes.TrisEdges - || i === model.primTypes.TriStripsEdges); + drawSurfaceWithEdges && + (i === model.primTypes.TrisEdges || + i === model.primTypes.TriStripsEdges); publicAPI.updateShaders(model.primitives[i], ren, actor); const program = model.primitives[i].getProgram(); @@ -358,7 +418,12 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { if (model.hardwareSupport) { if (model.extension) { - model.extension.drawArraysInstancedANGLE(mode, 0, cabo.getElementCount(), numPts); + model.extension.drawArraysInstancedANGLE( + mode, + 0, + cabo.getElementCount(), + numPts + ); } else { gl.drawArraysInstanced(mode, 0, cabo.getElementCount(), numPts); } @@ -368,7 +433,12 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { publicAPI.updateGlyphShaderParameters( normalMatrixUsed, mcvcMatrixUsed, - model.primitives[i], carray, garray, narray, p); + model.primitives[i], + carray, + garray, + narray, + p + ); gl.drawArrays(mode, 0, cabo.getElementCount()); } } @@ -377,36 +447,72 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { }; publicAPI.setMapperShaderParameters = (cellBO, ren, actor) => { - if (cellBO.getCABO().getElementCount() && - (model.glyphBOBuildTime.getMTime() > cellBO.getAttributeUpdateTime().getMTime() || - cellBO.getShaderSourceTime().getMTime() > cellBO.getAttributeUpdateTime().getMTime())) { + if ( + cellBO.getCABO().getElementCount() && + (model.glyphBOBuildTime.getMTime() > + cellBO.getAttributeUpdateTime().getMTime() || + cellBO.getShaderSourceTime().getMTime() > + cellBO.getAttributeUpdateTime().getMTime()) + ) { if (cellBO.getProgram().isAttributeUsed('gMatrix')) { - if (!cellBO.getVAO().addAttributeMatrixWithDivisor( - cellBO.getProgram(), model.matrixBuffer, - 'gMatrix', 0, 64, model.context.FLOAT, 4, - false, 1)) { + if ( + !cellBO + .getVAO() + .addAttributeMatrixWithDivisor( + cellBO.getProgram(), + model.matrixBuffer, + 'gMatrix', + 0, + 64, + model.context.FLOAT, + 4, + false, + 1 + ) + ) { vtkErrorMacro('Error setting gMatrix in shader VAO.'); } } else { cellBO.getVAO().removeAttributeArray('gMatrix'); } if (cellBO.getProgram().isAttributeUsed('gNormal')) { - if (!cellBO.getVAO().addAttributeMatrixWithDivisor( - cellBO.getProgram(), model.normalBuffer, - 'gNormal', 0, 36, model.context.FLOAT, 3, - false, 1)) { + if ( + !cellBO + .getVAO() + .addAttributeMatrixWithDivisor( + cellBO.getProgram(), + model.normalBuffer, + 'gNormal', + 0, + 36, + model.context.FLOAT, + 3, + false, + 1 + ) + ) { vtkErrorMacro('Error setting gNormal in shader VAO.'); } } else { cellBO.getVAO().removeAttributeArray('gNormal'); } if (cellBO.getProgram().isAttributeUsed('gColor')) { - if (!cellBO.getVAO().addAttributeArrayWithDivisor( - cellBO.getProgram(), model.colorBuffer, - 'gColor', 0, 4, - model.context.UNSIGNED_BYTE, - 4, - true, 1, false)) { + if ( + !cellBO + .getVAO() + .addAttributeArrayWithDivisor( + cellBO.getProgram(), + model.colorBuffer, + 'gColor', + 0, + 4, + model.context.UNSIGNED_BYTE, + 4, + true, + 1, + false + ) + ) { vtkErrorMacro('Error setting gColor in shader VAO.'); } } else { @@ -432,7 +538,6 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { return superClass.getNeedToRebuildBufferObjects(ren, actor); }; - publicAPI.buildBufferObjects = (ren, actor) => { if (model.hardwareSupport) { // update the buffer objects if needed @@ -447,7 +552,10 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { model.colorBuffer = vtkBufferObject.newInstance(); model.colorBuffer.setOpenGLRenderWindow(model.openGLRenderWindow); } - if (model.renderable.getBuildTime().getMTime() > model.glyphBOBuildTime.getMTime()) { + if ( + model.renderable.getBuildTime().getMTime() > + model.glyphBOBuildTime.getMTime() + ) { model.matrixBuffer.upload(garray, ObjectType.ARRAY_BUFFER); model.normalBuffer.upload(narray, ObjectType.ARRAY_BUFFER); if (carray) { diff --git a/Sources/Rendering/OpenGL/HardwareSelector/index.js b/Sources/Rendering/OpenGL/HardwareSelector/index.js index ecd889fdaac..44ac53fd868 100644 --- a/Sources/Rendering/OpenGL/HardwareSelector/index.js +++ b/Sources/Rendering/OpenGL/HardwareSelector/index.js @@ -1,8 +1,8 @@ -import macro from 'vtk.js/Sources/macro'; -import Constants from 'vtk.js/Sources/Rendering/OpenGL/HardwareSelector/Constants'; +import macro from 'vtk.js/Sources/macro'; +import Constants from 'vtk.js/Sources/Rendering/OpenGL/HardwareSelector/Constants'; import vtkOpenGLFramebuffer from 'vtk.js/Sources/Rendering/OpenGL/Framebuffer'; -import vtkSelectionNode from 'vtk.js/Sources/Common/DataModel/SelectionNode'; -import vtkDataSet from 'vtk.js/Sources/Common/DataModel/DataSet'; +import vtkSelectionNode from 'vtk.js/Sources/Common/DataModel/SelectionNode'; +import vtkDataSet from 'vtk.js/Sources/Common/DataModel/DataSet'; const { PassTypes } = Constants; const { SelectionContent, SelectionField } = vtkSelectionNode; @@ -24,7 +24,9 @@ function vtkOpenGLHardwareSelector(publicAPI, model) { //---------------------------------------------------------------------------- publicAPI.beginSelection = () => { - model.openGLRenderer = model.openGLRenderWindow.getViewNodeFor(model.renderer); + model.openGLRenderer = model.openGLRenderWindow.getViewNodeFor( + model.renderer + ); model.maxAttributeId = 0; model.framebuffer = vtkOpenGLFramebuffer.newInstance(); @@ -50,19 +52,20 @@ function vtkOpenGLHardwareSelector(publicAPI, model) { model.framebuffer.restorePreviousBindingsAndBuffers(); }; - publicAPI.preCapturePass = () => { - }; + publicAPI.preCapturePass = () => {}; - publicAPI.postCapturePass = () => { - }; + publicAPI.postCapturePass = () => {}; //---------------------------------------------------------------------------- publicAPI.select = () => { let sel = null; if (publicAPI.captureBuffers()) { sel = publicAPI.generateSelection( - model.area[0], model.area[1], - model.area[2], model.area[3]); + model.area[0], + model.area[1], + model.area[2], + model.area[3] + ); publicAPI.releasePixBuffers(); } return sel; @@ -75,7 +78,9 @@ function vtkOpenGLHardwareSelector(publicAPI, model) { return false; } - model.openGLRenderer = model.openGLRenderWindow.getViewNodeFor(model.renderer); + model.openGLRenderer = model.openGLRenderWindow.getViewNodeFor( + model.renderer + ); // int rgba[4]; // rwin.getColorBufferSizes(rgba); @@ -92,8 +97,11 @@ function vtkOpenGLHardwareSelector(publicAPI, model) { model.renderer.setBackground(0.0, 0.0, 0.0); publicAPI.beginSelection(); - for (model.currentPass = PassTypes.MIN_KNOWN_PASS; - model.currentPass <= PassTypes.MAX_KNOWN_PASS; model.currentPass++) { + for ( + model.currentPass = PassTypes.MIN_KNOWN_PASS; + model.currentPass <= PassTypes.MAX_KNOWN_PASS; + model.currentPass++ + ) { if (publicAPI.passRequired(model.currentPass)) { publicAPI.preCapturePass(model.currentPass); model.openGLRenderWindow.traverseAllPasses(); @@ -114,12 +122,16 @@ function vtkOpenGLHardwareSelector(publicAPI, model) { }; //---------------------------------------------------------------------------- - publicAPI.passRequired = pass => true; + publicAPI.passRequired = (pass) => true; //---------------------------------------------------------------------------- publicAPI.savePixelBuffer = (passNo) => { model.pixBuffer[passNo] = model.openGLRenderWindow.getPixelData( - model.area[0], model.area[1], model.area[2], model.area[3]); + model.area[0], + model.area[1], + model.area[2], + model.area[3] + ); if (passNo === PassTypes.ACTOR_PASS) { publicAPI.buildPropHitList(model.pixBuffer[passNo]); } @@ -143,8 +155,7 @@ function vtkOpenGLHardwareSelector(publicAPI, model) { //---------------------------------------------------------------------------- publicAPI.renderProp = (prop) => { if (model.currentPass === PassTypes.ACTOR_PASS) { - publicAPI.setPropColorValueFromInt( - model.props.length + model.idOffset); + publicAPI.setPropColorValueFromInt(model.props.length + model.idOffset); model.props.push(prop); } }; @@ -165,8 +176,8 @@ function vtkOpenGLHardwareSelector(publicAPI, model) { return; } - model.maxAttributeId = (attribid > model.maxAttributeId) - ? attribid : model.maxAttributeId; + model.maxAttributeId = + attribid > model.maxAttributeId ? attribid : model.maxAttributeId; // if (model.currentPass < PassTypes.ID_LOW24) { // return; // useless... @@ -182,16 +193,16 @@ function vtkOpenGLHardwareSelector(publicAPI, model) { }; //---------------------------------------------------------------------------- - publicAPI.passTypeToString = type => macro.enumToString(PassTypes, type); + publicAPI.passTypeToString = (type) => macro.enumToString(PassTypes, type); //---------------------------------------------------------------------------- - publicAPI.isPropHit = id => model.hitProps.hasKey(id); + publicAPI.isPropHit = (id) => model.hitProps.hasKey(id); publicAPI.convert = (xx, yy, pb) => { if (!pb) { return 0; } - const offset = ((yy * (model.area[2] - model.area[0] + 1)) + xx) * 4; + const offset = (yy * (model.area[2] - model.area[0] + 1) + xx) * 4; const rgb = []; rgb[0] = pb[offset]; rgb[1] = pb[offset + 1]; @@ -221,24 +232,33 @@ function vtkOpenGLHardwareSelector(publicAPI, model) { publicAPI.getPixelInformation = ( inDisplayPosition, maxDistance, - outSelectedPosition) => { + outSelectedPosition + ) => { // Base case - const maxDist = (maxDistance < 0) ? 0 : maxDistance; + const maxDist = maxDistance < 0 ? 0 : maxDistance; if (maxDist === 0) { outSelectedPosition[0] = inDisplayPosition[0]; outSelectedPosition[1] = inDisplayPosition[1]; - if (inDisplayPosition[0] < model.area[0] || inDisplayPosition[0] > model.area[2] || - inDisplayPosition[1] < model.area[1] || inDisplayPosition[1] > model.area[3]) { + if ( + inDisplayPosition[0] < model.area[0] || + inDisplayPosition[0] > model.area[2] || + inDisplayPosition[1] < model.area[1] || + inDisplayPosition[1] > model.area[3] + ) { return null; } // offset inDisplayPosition based on the lower-left-corner of the Area. const displayPosition = [ inDisplayPosition[0] - model.area[0], - inDisplayPosition[1] - model.area[1]]; + inDisplayPosition[1] - model.area[1], + ]; const actorid = publicAPI.convert( - displayPosition[0], displayPosition[1], model.pixBuffer[PassTypes.ACTOR_PASS]); + displayPosition[0], + displayPosition[1], + model.pixBuffer[PassTypes.ACTOR_PASS] + ); if (actorid <= 0) { // the pixel did not hit any actor. return null; @@ -274,13 +294,21 @@ function vtkOpenGLHardwareSelector(publicAPI, model) { // They recursively call the base case to handle single pixels. const dispPos = [inDisplayPosition[0], inDisplayPosition[1]]; const curPos = [0, 0]; - let info = publicAPI.getPixelInformation(inDisplayPosition, 0, outSelectedPosition); + let info = publicAPI.getPixelInformation( + inDisplayPosition, + 0, + outSelectedPosition + ); if (info && info.valid) { return info; } for (let dist = 1; dist < maxDist; ++dist) { // Vertical sides of box. - for (let y = ((dispPos[1] > dist) ? (dispPos[1] - dist) : 0); y <= dispPos[1] + dist; ++y) { + for ( + let y = dispPos[1] > dist ? dispPos[1] - dist : 0; + y <= dispPos[1] + dist; + ++y + ) { curPos[1] = y; if (dispPos[0] >= dist) { curPos[0] = dispPos[0] - dist; @@ -296,7 +324,11 @@ function vtkOpenGLHardwareSelector(publicAPI, model) { } } // Horizontal sides of box. - for (let x = ((dispPos[0] >= dist) ? (dispPos[0] - (dist - 1)) : 0); x <= dispPos[0] + (dist - 1); ++x) { + for ( + let x = dispPos[0] >= dist ? dispPos[0] - (dist - 1) : 0; + x <= dispPos[0] + (dist - 1); + ++x + ) { curPos[0] = x; if (dispPos[1] >= dist) { curPos[1] = dispPos[1] - dist; @@ -320,8 +352,7 @@ function vtkOpenGLHardwareSelector(publicAPI, model) { }; //----------------------------------------------------------------------------- - publicAPI.convertSelection = ( - fieldassociation, dataMap) => { + publicAPI.convertSelection = (fieldassociation, dataMap) => { const sel = []; let count = 0; @@ -351,12 +382,10 @@ function vtkOpenGLHardwareSelector(publicAPI, model) { return sel; }; - publicAPI.getInfoHash = info => `${info.propID} ${info.compositeID}`; + publicAPI.getInfoHash = (info) => `${info.propID} ${info.compositeID}`; //---------------------------------------------------------------------------- - publicAPI.generateSelection = ( - x1, y1, - x2, y2) => { + publicAPI.generateSelection = (x1, y1, x2, y2) => { const dataMap = new Map(); const outSelectedPosition = [0, 0]; @@ -368,10 +397,16 @@ function vtkOpenGLHardwareSelector(publicAPI, model) { if (info && info.valid) { const hash = publicAPI.getInfoHash(info); if (!dataMap.has(hash)) { - dataMap.set(hash, { info, pixelCount: 1, attributeIDs: [info.attributeID] }); + dataMap.set(hash, { + info, + pixelCount: 1, + attributeIDs: [info.attributeID], + }); } else { dataMap.get(hash).pixelCount++; - if (dataMap.get(hash).attributeIDs.indexOf(info.attributeID) === -1) { + if ( + dataMap.get(hash).attributeIDs.indexOf(info.attributeID) === -1 + ) { dataMap.get(hash).attributeIDs.push(info.attributeID); } } @@ -421,12 +456,8 @@ export function extend(publicAPI, model, initialValues = {}) { 'currentPass', ]); - macro.setGetArray(publicAPI, model, [ - 'area', - ], 4); - macro.setGetArray(publicAPI, model, [ - 'propColorValue', - ], 3); + macro.setGetArray(publicAPI, model, ['area'], 4); + macro.setGetArray(publicAPI, model, ['propColorValue'], 3); macro.event(publicAPI, model, 'event'); // Object methods @@ -435,7 +466,10 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkOpenGLHardwareSelector'); +export const newInstance = macro.newInstance( + extend, + 'vtkOpenGLHardwareSelector' +); // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/OpenGL/HardwareSelector/test/testHardwareSelector.js b/Sources/Rendering/OpenGL/HardwareSelector/test/testHardwareSelector.js index 1446036410f..a04a8834dd7 100644 --- a/Sources/Rendering/OpenGL/HardwareSelector/test/testHardwareSelector.js +++ b/Sources/Rendering/OpenGL/HardwareSelector/test/testHardwareSelector.js @@ -1,15 +1,15 @@ import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkOpenGLHardwareSelector from 'vtk.js/Sources/Rendering/OpenGL/HardwareSelector'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; -import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; -import { FieldAssociations } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkOpenGLHardwareSelector from 'vtk.js/Sources/Rendering/OpenGL/HardwareSelector'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; +import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; +import { FieldAssociations } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; test.onlyIfWebGL('Test HardwareSelector', (tapeContext) => { const gc = testUtils.createGarbageCollector(tapeContext); @@ -17,7 +17,9 @@ test.onlyIfWebGL('Test HardwareSelector', (tapeContext) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -32,7 +34,9 @@ test.onlyIfWebGL('Test HardwareSelector', (tapeContext) => { const mapper = gc.registerResource(vtkMapper.newInstance()); actor.setMapper(mapper); - const PlaneSource = gc.registerResource(vtkPlaneSource.newInstance({ xResolution: 5, yResolution: 10 })); + const PlaneSource = gc.registerResource( + vtkPlaneSource.newInstance({ xResolution: 5, yResolution: 10 }) + ); mapper.setInputConnection(PlaneSource.getOutputPort()); const actor2 = gc.registerResource(vtkActor.newInstance()); @@ -67,9 +71,10 @@ test.onlyIfWebGL('Test HardwareSelector', (tapeContext) => { sel.setArea(200, 200, 300, 300); const res = sel.select(); - const allGood = (res.length === 2 && + const allGood = + res.length === 2 && res[0].getProperties().prop === actor && - res[1].getProperties().prop === actor3); + res[1].getProperties().prop === actor3; tapeContext.ok(res.length === 2, 'Two props selected'); tapeContext.ok(allGood, 'Correct props were selected'); diff --git a/Sources/Rendering/OpenGL/Helper/index.js b/Sources/Rendering/OpenGL/Helper/index.js index f6599dc27b5..3ace9a41a19 100644 --- a/Sources/Rendering/OpenGL/Helper/index.js +++ b/Sources/Rendering/OpenGL/Helper/index.js @@ -1,7 +1,7 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkCellArrayBufferObject from 'vtk.js/Sources/Rendering/OpenGL/CellArrayBufferObject'; -import vtkShaderProgram from 'vtk.js/Sources/Rendering/OpenGL/ShaderProgram'; -import vtkVertexArrayObject from 'vtk.js/Sources/Rendering/OpenGL/VertexArrayObject'; +import vtkShaderProgram from 'vtk.js/Sources/Rendering/OpenGL/ShaderProgram'; +import vtkVertexArrayObject from 'vtk.js/Sources/Rendering/OpenGL/VertexArrayObject'; // ---------------------------------------------------------------------------- // vtkOpenGLHelper methods diff --git a/Sources/Rendering/OpenGL/ImageMapper/index.js b/Sources/Rendering/OpenGL/ImageMapper/index.js index 3b80e79f127..29704c2443b 100644 --- a/Sources/Rendering/OpenGL/ImageMapper/index.js +++ b/Sources/Rendering/OpenGL/ImageMapper/index.js @@ -1,18 +1,21 @@ -import { mat4 } from 'gl-matrix'; -import Constants from 'vtk.js/Sources/Rendering/Core/ImageMapper/Constants'; -import macro from 'vtk.js/Sources/macro'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import { VtkDataTypes } from 'vtk.js/Sources/Common/Core/DataArray/Constants'; -import vtkHelper from 'vtk.js/Sources/Rendering/OpenGL/Helper'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; -import vtkOpenGLTexture from 'vtk.js/Sources/Rendering/OpenGL/Texture'; -import vtkShaderProgram from 'vtk.js/Sources/Rendering/OpenGL/ShaderProgram'; -import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; +import { mat4 } from 'gl-matrix'; +import Constants from 'vtk.js/Sources/Rendering/Core/ImageMapper/Constants'; +import macro from 'vtk.js/Sources/macro'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import { VtkDataTypes } from 'vtk.js/Sources/Common/Core/DataArray/Constants'; +import vtkHelper from 'vtk.js/Sources/Rendering/OpenGL/Helper'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkOpenGLTexture from 'vtk.js/Sources/Rendering/OpenGL/Texture'; +import vtkShaderProgram from 'vtk.js/Sources/Rendering/OpenGL/ShaderProgram'; +import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants'; -import { Wrap, Filter } from 'vtk.js/Sources/Rendering/OpenGL/Texture/Constants'; +import { + Wrap, + Filter, +} from 'vtk.js/Sources/Rendering/OpenGL/Texture/Constants'; -import vtkPolyDataVS from 'vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyDataVS.glsl'; -import vtkPolyDataFS from 'vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyDataFS.glsl'; +import vtkPolyDataVS from 'vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyDataVS.glsl'; +import vtkPolyDataFS from 'vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyDataFS.glsl'; const { vtkErrorMacro } = macro; @@ -28,15 +31,21 @@ function vtkOpenGLImageMapper(publicAPI, model) { publicAPI.buildPass = (prepass) => { if (prepass) { - model.openGLImageSlice = publicAPI.getFirstAncestorOfType('vtkOpenGLImageSlice'); - model.openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer'); + model.openGLImageSlice = publicAPI.getFirstAncestorOfType( + 'vtkOpenGLImageSlice' + ); + model.openGLRenderer = publicAPI.getFirstAncestorOfType( + 'vtkOpenGLRenderer' + ); model.openGLRenderWindow = model.openGLRenderer.getParent(); model.context = model.openGLRenderWindow.getContext(); model.tris.setOpenGLRenderWindow(model.openGLRenderWindow); model.openGLTexture.setOpenGLRenderWindow(model.openGLRenderWindow); model.colorTexture.setOpenGLRenderWindow(model.openGLRenderWindow); const ren = model.openGLRenderer.getRenderable(); - model.openGLCamera = model.openGLRenderer.getViewNodeFor(ren.getActiveCamera()); + model.openGLCamera = model.openGLRenderer.getViewNodeFor( + ren.getActiveCamera() + ); // is zslice set by the camera if (model.renderable.getSliceAtFocalPoint()) { model.renderable.setZSliceFromCamera(ren.getActiveCamera()); @@ -78,50 +87,68 @@ function vtkOpenGLImageMapper(publicAPI, model) { let VSSource = shaders.Vertex; let FSSource = shaders.Fragment; - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::Camera::Dec', [ - 'uniform mat4 MCDCMatrix;']).result; - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::PositionVC::Impl', [ - ' gl_Position = MCDCMatrix * vertexMC;']).result; - - VSSource = vtkShaderProgram.substitute(VSSource, + VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Camera::Dec', [ + 'uniform mat4 MCDCMatrix;', + ]).result; + VSSource = vtkShaderProgram.substitute( + VSSource, + '//VTK::PositionVC::Impl', + [' gl_Position = MCDCMatrix * vertexMC;'] + ).result; + + VSSource = vtkShaderProgram.substitute( + VSSource, '//VTK::TCoord::Impl', - 'tcoordVCVSOutput = tcoordMC;').result; + 'tcoordVCVSOutput = tcoordMC;' + ).result; const tNumComp = model.openGLTexture.getComponents(); - VSSource = vtkShaderProgram.substitute(VSSource, + VSSource = vtkShaderProgram.substitute( + VSSource, '//VTK::TCoord::Dec', - 'attribute vec2 tcoordMC; varying vec2 tcoordVCVSOutput;').result; - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::TCoord::Dec', [ - 'varying vec2 tcoordVCVSOutput;', - 'uniform float shift;', - 'uniform float scale;', - 'uniform sampler2D texture1;', - 'uniform sampler2D colorTexture1;']).result; + 'attribute vec2 tcoordMC; varying vec2 tcoordVCVSOutput;' + ).result; + FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Dec', [ + 'varying vec2 tcoordVCVSOutput;', + 'uniform float shift;', + 'uniform float scale;', + 'uniform sampler2D texture1;', + 'uniform sampler2D colorTexture1;', + ]).result; switch (tNumComp) { case 1: - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::TCoord::Impl', [ + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::TCoord::Impl', + [ 'float intensity = texture2D(texture1, tcoordVCVSOutput).r*scale + shift;', - 'gl_FragData[0] = texture2D(colorTexture1, vec2(intensity, 0.5));']).result; + 'gl_FragData[0] = texture2D(colorTexture1, vec2(intensity, 0.5));', + ] + ).result; break; case 2: - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::TCoord::Impl', [ + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::TCoord::Impl', + [ 'vec4 tcolor = texture2D(texture1, tcoordVCVSOutput);', 'float intensity = tcolor.r*scale + shift;', - 'gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(intensity, 0.5)), scale*tcolor.g + shift);']).result; + 'gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(intensity, 0.5)), scale*tcolor.g + shift);', + ] + ).result; break; default: - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::TCoord::Impl', [ + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::TCoord::Impl', + [ 'vec4 tcolor = scale*texture2D(texture1, tcoordVCVSOutput.st) + shift;', 'gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(tcolor.r,0.5)),', ' texture2D(colorTexture1, vec2(tcolor.g,0.5)),', - ' texture2D(colorTexture1, vec2(tcolor.b,0.5)), tcolor.a);']).result; + ' texture2D(colorTexture1, vec2(tcolor.b,0.5)), tcolor.a);', + ] + ).result; } shaders.Vertex = VSSource; shaders.Fragment = FSSource; @@ -133,10 +160,12 @@ function vtkOpenGLImageMapper(publicAPI, model) { // property modified (representation interpolation and lighting) // input modified // light complexity changed - if (cellBO.getProgram() === 0 || - cellBO.getShaderSourceTime().getMTime() < publicAPI.getMTime() || - cellBO.getShaderSourceTime().getMTime() < actor.getMTime() || - cellBO.getShaderSourceTime().getMTime() < model.currentInput.getMTime()) { + if ( + cellBO.getProgram() === 0 || + cellBO.getShaderSourceTime().getMTime() < publicAPI.getMTime() || + cellBO.getShaderSourceTime().getMTime() < actor.getMTime() || + cellBO.getShaderSourceTime().getMTime() < model.currentInput.getMTime() + ) { return true; } @@ -153,8 +182,13 @@ function vtkOpenGLImageMapper(publicAPI, model) { publicAPI.buildShaders(shaders, ren, actor); // compile and bind the program if needed - const newShader = - model.openGLRenderWindow.getShaderCache().readyShaderProgramArray(shaders.Vertex, shaders.Fragment, shaders.Geometry); + const newShader = model.openGLRenderWindow + .getShaderCache() + .readyShaderProgramArray( + shaders.Vertex, + shaders.Fragment, + shaders.Geometry + ); // if the shader changed reinitialize the VAO if (newShader !== cellBO.getProgram()) { @@ -165,7 +199,9 @@ function vtkOpenGLImageMapper(publicAPI, model) { cellBO.getShaderSourceTime().modified(); } else { - model.openGLRenderWindow.getShaderCache().readyShaderProgram(cellBO.getProgram()); + model.openGLRenderWindow + .getShaderCache() + .readyShaderProgram(cellBO.getProgram()); } cellBO.getVAO().bind(); @@ -177,23 +213,48 @@ function vtkOpenGLImageMapper(publicAPI, model) { publicAPI.setMapperShaderParameters = (cellBO, ren, actor) => { // Now to update the VAO too, if necessary. - if (cellBO.getCABO().getElementCount() && (model.VBOBuildTime > cellBO.getAttributeUpdateTime().getMTime() || - cellBO.getShaderSourceTime().getMTime() > cellBO.getAttributeUpdateTime().getMTime())) { + if ( + cellBO.getCABO().getElementCount() && + (model.VBOBuildTime > cellBO.getAttributeUpdateTime().getMTime() || + cellBO.getShaderSourceTime().getMTime() > + cellBO.getAttributeUpdateTime().getMTime()) + ) { if (cellBO.getProgram().isAttributeUsed('vertexMC')) { - if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO(), - 'vertexMC', cellBO.getCABO().getVertexOffset(), - cellBO.getCABO().getStride(), model.context.FLOAT, 3, - model.context.FALSE)) { + if ( + !cellBO + .getVAO() + .addAttributeArray( + cellBO.getProgram(), + cellBO.getCABO(), + 'vertexMC', + cellBO.getCABO().getVertexOffset(), + cellBO.getCABO().getStride(), + model.context.FLOAT, + 3, + model.context.FALSE + ) + ) { vtkErrorMacro('Error setting vertexMC in shader VAO.'); } } - if (cellBO.getProgram().isAttributeUsed('tcoordMC') && - cellBO.getCABO().getTCoordOffset()) { - if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO(), - 'tcoordMC', cellBO.getCABO().getTCoordOffset(), - cellBO.getCABO().getStride(), model.context.FLOAT, - cellBO.getCABO().getTCoordComponents(), - model.context.FALSE)) { + if ( + cellBO.getProgram().isAttributeUsed('tcoordMC') && + cellBO.getCABO().getTCoordOffset() + ) { + if ( + !cellBO + .getVAO() + .addAttributeArray( + cellBO.getProgram(), + cellBO.getCABO(), + 'tcoordMC', + cellBO.getCABO().getTCoordOffset(), + cellBO.getCABO().getStride(), + model.context.FLOAT, + cellBO.getCABO().getTCoordComponents(), + model.context.FALSE + ) + ) { vtkErrorMacro('Error setting tcoordMC in shader VAO.'); } } @@ -214,7 +275,7 @@ function vtkOpenGLImageMapper(publicAPI, model) { const oglShiftScale = model.openGLTexture.getShiftAndScale(); const scale = oglShiftScale.scale / cw; - const shift = ((oglShiftScale.shift - cl) / cw) + 0.5; + const shift = (oglShiftScale.shift - cl) / cw + 0.5; cellBO.getProgram().setUniformf('shift', shift); cellBO.getProgram().setUniformf('scale', scale); @@ -262,8 +323,7 @@ function vtkOpenGLImageMapper(publicAPI, model) { if (model.tris.getCABO().getElementCount()) { // First we do the triangles, update the shader, set uniforms, etc. publicAPI.updateShaders(model.tris, ren, actor); - gl.drawArrays(gl.TRIANGLES, 0, - model.tris.getCABO().getElementCount()); + gl.drawArrays(gl.TRIANGLES, 0, model.tris.getCABO().getElementCount()); model.tris.getVAO().release(); } @@ -271,8 +331,7 @@ function vtkOpenGLImageMapper(publicAPI, model) { model.colorTexture.deactivate(); }; - publicAPI.renderPieceFinish = (ren, actor) => { - }; + publicAPI.renderPieceFinish = (ren, actor) => {}; publicAPI.renderPiece = (ren, actor) => { // Make sure that we have been properly initialized. @@ -312,11 +371,13 @@ function vtkOpenGLImageMapper(publicAPI, model) { publicAPI.getNeedToRebuildBufferObjects = (ren, actor) => { // first do a coarse check - if (model.VBOBuildTime.getMTime() < publicAPI.getMTime() || - model.VBOBuildTime.getMTime() < actor.getMTime() || - model.VBOBuildTime.getMTime() < model.renderable.getMTime() || - model.VBOBuildTime.getMTime() < actor.getProperty().getMTime() || - model.VBOBuildTime.getMTime() < model.currentInput.getMTime()) { + if ( + model.VBOBuildTime.getMTime() < publicAPI.getMTime() || + model.VBOBuildTime.getMTime() < actor.getMTime() || + model.VBOBuildTime.getMTime() < model.renderable.getMTime() || + model.VBOBuildTime.getMTime() < actor.getProperty().getMTime() || + model.VBOBuildTime.getMTime() < model.currentInput.getMTime() + ) { return true; } return false; @@ -344,8 +405,13 @@ function vtkOpenGLImageMapper(publicAPI, model) { model.colorTextureString = cfunToString; model.colorTexture.setMinificationFilter(Filter.LINEAR); model.colorTexture.setMagnificationFilter(Filter.LINEAR); - model.colorTexture.create2DFromRaw(cWidth, 1, 3, - VtkDataTypes.UNSIGNED_CHAR, cTable); + model.colorTexture.create2DFromRaw( + cWidth, + 1, + 3, + VtkDataTypes.UNSIGNED_CHAR, + cTable + ); } } else { const cfunToString = '0'; @@ -358,8 +424,13 @@ function vtkOpenGLImageMapper(publicAPI, model) { model.colorTextureString = cfunToString; model.colorTexture.setMinificationFilter(Filter.LINEAR); model.colorTexture.setMagnificationFilter(Filter.LINEAR); - model.colorTexture.create2DFromRaw(cWidth, 1, 3, - VtkDataTypes.UNSIGNED_CHAR, cTable); + model.colorTexture.create2DFromRaw( + cWidth, + 1, + 3, + VtkDataTypes.UNSIGNED_CHAR, + cTable + ); } } @@ -375,11 +446,19 @@ function vtkOpenGLImageMapper(publicAPI, model) { nSlice = model.renderable.getYSlice(); sliceOffset = nSlice - ext[2]; } - const toString = `${nSlice}A${image.getMTime()}A${image.getPointData().getScalars().getMTime()}B${publicAPI.getMTime()}`; + const toString = `${nSlice}A${image.getMTime()}A${image + .getPointData() + .getScalars() + .getMTime()}B${publicAPI.getMTime()}`; if (model.VBOBuildString !== toString) { // Build the VBOs const dims = image.getDimensions(); - if (image.getPointData().getScalars().getNumberOfComponents() === 4) { + if ( + image + .getPointData() + .getScalars() + .getNumberOfComponents() === 4 + ) { model.openGLTexture.setGenerateMipmap(true); model.openGLTexture.setMinificationFilter(Filter.LINEAR_MIPMAP_LINEAR); } else { @@ -388,24 +467,32 @@ function vtkOpenGLImageMapper(publicAPI, model) { model.openGLTexture.setMagnificationFilter(Filter.LINEAR); model.openGLTexture.setWrapS(Wrap.CLAMP_TO_EDGE); model.openGLTexture.setWrapT(Wrap.CLAMP_TO_EDGE); - const numComp = image.getPointData().getScalars().getNumberOfComponents(); + const numComp = image + .getPointData() + .getScalars() + .getNumberOfComponents(); const sliceSize = dims[0] * dims[1] * numComp; const ptsArray = new Float32Array(12); const tcoordArray = new Float32Array(8); for (let i = 0; i < 4; i++) { - tcoordArray[(i * 2)] = (i % 2) ? 1.0 : 0.0; - tcoordArray[(i * 2) + 1] = (i > 1) ? 1.0 : 0.0; + tcoordArray[i * 2] = i % 2 ? 1.0 : 0.0; + tcoordArray[i * 2 + 1] = i > 1 ? 1.0 : 0.0; } - const basicScalars = image.getPointData().getScalars().getData(); + const basicScalars = image + .getPointData() + .getScalars() + .getData(); let scalars = null; // Get right scalars according to slicing mode if (model.renderable.getCurrentSlicingMode() === SlicingMode.X) { scalars = []; for (let k = 0; k < dims[2]; k++) { for (let j = 0; j < dims[1]; j++) { - scalars.push(basicScalars[sliceOffset + j * dims[0] + k * dims[0] * dims[1]]); + scalars.push( + basicScalars[sliceOffset + j * dims[0] + k * dims[0] * dims[1]] + ); } } dims[0] = dims[1]; @@ -426,7 +513,9 @@ function vtkOpenGLImageMapper(publicAPI, model) { scalars = []; for (let k = 0; k < dims[2]; k++) { for (let i = 0; i < dims[0]; i++) { - scalars.push(basicScalars[i + (sliceOffset * dims[0]) + (k * dims[0] * dims[1])]); + scalars.push( + basicScalars[i + sliceOffset * dims[0] + k * dims[0] * dims[1]] + ); } } dims[1] = dims[2]; @@ -443,7 +532,10 @@ function vtkOpenGLImageMapper(publicAPI, model) { ptsArray[10] = nSlice; ptsArray[11] = ext[5]; } else { - scalars = basicScalars.subarray(sliceOffset * sliceSize, (sliceOffset + 1) * sliceSize); + scalars = basicScalars.subarray( + sliceOffset * sliceSize, + (sliceOffset + 1) * sliceSize + ); ptsArray[0] = ext[0]; ptsArray[1] = ext[2]; ptsArray[2] = nSlice; @@ -458,17 +550,29 @@ function vtkOpenGLImageMapper(publicAPI, model) { ptsArray[11] = nSlice; } - model.openGLTexture.create2DFromRaw(dims[0], dims[1], + model.openGLTexture.create2DFromRaw( + dims[0], + dims[1], numComp, - image.getPointData().getScalars().getDataType(), - scalars); + image + .getPointData() + .getScalars() + .getDataType(), + scalars + ); model.openGLTexture.activate(); model.openGLTexture.sendParameters(); model.openGLTexture.deactivate(); - const points = vtkDataArray.newInstance({ numberOfComponents: 3, values: ptsArray }); + const points = vtkDataArray.newInstance({ + numberOfComponents: 3, + values: ptsArray, + }); points.setName('points'); - const tcoords = vtkDataArray.newInstance({ numberOfComponents: 2, values: tcoordArray }); + const tcoords = vtkDataArray.newInstance({ + numberOfComponents: 2, + values: tcoordArray, + }); tcoords.setName('tcoords'); const cellArray = new Uint16Array(8); @@ -480,11 +584,18 @@ function vtkOpenGLImageMapper(publicAPI, model) { cellArray[5] = 0; cellArray[6] = 3; cellArray[7] = 2; - const cells = vtkDataArray.newInstance({ numberOfComponents: 1, values: cellArray }); - - model.tris.getCABO().createVBO(cells, - 'polys', Representation.SURFACE, - { points, tcoords, cellOffset: 0 }); + const cells = vtkDataArray.newInstance({ + numberOfComponents: 1, + values: cellArray, + }); + + model.tris + .getCABO() + .createVBO(cells, 'polys', Representation.SURFACE, { + points, + tcoords, + cellOffset: 0, + }); model.VBOBuildTime.modified(); model.VBOBuildString = toString; } @@ -519,8 +630,7 @@ export function extend(publicAPI, model, initialValues = {}) { model.imagemat = mat4.create(); // Build VTK API - macro.setGet(publicAPI, model, [ - ]); + macro.setGet(publicAPI, model, []); model.VBOBuildTime = {}; macro.obj(model.VBOBuildTime); diff --git a/Sources/Rendering/OpenGL/ImageMapper/test/testImage.js b/Sources/Rendering/OpenGL/ImageMapper/test/testImage.js index 9d3381a0b31..1745a3314c3 100644 --- a/Sources/Rendering/OpenGL/ImageMapper/test/testImage.js +++ b/Sources/Rendering/OpenGL/ImageMapper/test/testImage.js @@ -1,12 +1,12 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkImageGridSource from 'vtk.js/Sources/Filters/Sources/ImageGridSource'; -import vtkImageMapper from 'vtk.js/Sources/Rendering/Core/ImageMapper'; -import vtkImageSlice from 'vtk.js/Sources/Rendering/Core/ImageSlice'; +import vtkImageGridSource from 'vtk.js/Sources/Filters/Sources/ImageGridSource'; +import vtkImageMapper from 'vtk.js/Sources/Rendering/Core/ImageMapper'; +import vtkImageSlice from 'vtk.js/Sources/Rendering/Core/ImageSlice'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; import baseline from './testImage.png'; @@ -16,7 +16,9 @@ test.onlyIfWebGL('Test ImageMapper', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -33,10 +35,7 @@ test.onlyIfWebGL('Test ImageMapper', (t) => { gridSource.setDataExtent(0, 200, 0, 200, 0, 0); gridSource.setGridSpacing(16, 16, 0); gridSource.setGridOrigin(8, 8, 0); - gridSource.setDataDirection( - 0.866, 0.5, 0, - -0.5, 0.866, 0, - 0, 0, 1); + gridSource.setDataDirection(0.866, 0.5, 0, -0.5, 0.866, 0, 0, 0, 1); const mapper = gc.registerResource(vtkImageMapper.newInstance()); mapper.setInputConnection(gridSource.getOutputPort()); @@ -62,5 +61,12 @@ test.onlyIfWebGL('Test ImageMapper', (t) => { glwindow.setSize(400, 400); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/OpenGL/ImageMapper', t, 1, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Rendering/OpenGL/ImageMapper', + t, + 1, + gc.releaseResources + ); }); diff --git a/Sources/Rendering/OpenGL/ImageMapper/test/testImageColorTransferFunction.js b/Sources/Rendering/OpenGL/ImageMapper/test/testImageColorTransferFunction.js index abb5c9cf305..cb354287cf6 100644 --- a/Sources/Rendering/OpenGL/ImageMapper/test/testImageColorTransferFunction.js +++ b/Sources/Rendering/OpenGL/ImageMapper/test/testImageColorTransferFunction.js @@ -1,13 +1,13 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkImageGridSource from 'vtk.js/Sources/Filters/Sources/ImageGridSource'; -import vtkImageMapper from 'vtk.js/Sources/Rendering/Core/ImageMapper'; -import vtkImageSlice from 'vtk.js/Sources/Rendering/Core/ImageSlice'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; +import vtkImageGridSource from 'vtk.js/Sources/Filters/Sources/ImageGridSource'; +import vtkImageMapper from 'vtk.js/Sources/Rendering/Core/ImageMapper'; +import vtkImageSlice from 'vtk.js/Sources/Rendering/Core/ImageSlice'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; import baseline from './testImageColorTransferFunction.png'; @@ -17,7 +17,9 @@ test.onlyIfWebGL('Test ImageMapper', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -34,10 +36,7 @@ test.onlyIfWebGL('Test ImageMapper', (t) => { gridSource.setDataExtent(0, 20, 0, 20, 0, 0); gridSource.setGridSpacing(16, 16, 0); gridSource.setGridOrigin(8, 8, 0); - gridSource.setDataDirection( - 0.866, 0.5, 0, - -0.5, 0.866, 0, - 0, 0, 1); + gridSource.setDataDirection(0.866, 0.5, 0, -0.5, 0.866, 0, 0, 0, 1); const mapper = gc.registerResource(vtkImageMapper.newInstance()); mapper.setInputConnection(gridSource.getOutputPort()); @@ -68,5 +67,12 @@ test.onlyIfWebGL('Test ImageMapper', (t) => { glwindow.setSize(400, 400); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/OpenGL/ImageMapper', t, 1, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Rendering/OpenGL/ImageMapper', + t, + 1, + gc.releaseResources + ); }); diff --git a/Sources/Rendering/OpenGL/ImageSlice/index.js b/Sources/Rendering/OpenGL/ImageSlice/index.js index 08cd0aa995b..f9f058546b7 100644 --- a/Sources/Rendering/OpenGL/ImageSlice/index.js +++ b/Sources/Rendering/OpenGL/ImageSlice/index.js @@ -1,6 +1,6 @@ import { mat3, mat4 } from 'gl-matrix'; -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; // ---------------------------------------------------------------------------- @@ -33,9 +33,11 @@ function vtkOpenGLImageSlice(publicAPI, model) { // we draw textures, then mapper, then post pass textures publicAPI.traverseOpaquePass = (renderPass) => { - if (!model.renderable || - !model.renderable.getVisibility() || - !model.renderable.getIsOpaque()) { + if ( + !model.renderable || + !model.renderable.getVisibility() || + !model.renderable.getIsOpaque() + ) { return; } @@ -48,9 +50,11 @@ function vtkOpenGLImageSlice(publicAPI, model) { // we draw textures, then mapper, then post pass textures publicAPI.traverseTranslucentPass = (renderPass) => { - if (!model.renderable || - !model.renderable.getVisibility() || - model.renderable.getIsOpaque()) { + if ( + !model.renderable || + !model.renderable.getVisibility() || + model.renderable.getIsOpaque() + ) { return; } @@ -63,8 +67,7 @@ function vtkOpenGLImageSlice(publicAPI, model) { publicAPI.queryPass = (prepass, renderPass) => { if (prepass) { - if (!model.renderable || - !model.renderable.getVisibility()) { + if (!model.renderable || !model.renderable.getVisibility()) { return; } if (model.renderable.getIsOpaque()) { @@ -75,12 +78,15 @@ function vtkOpenGLImageSlice(publicAPI, model) { } }; - publicAPI.opaqueZBufferPass = (prepass, renderPass) => publicAPI.opaquePass(prepass, renderPass); + publicAPI.opaqueZBufferPass = (prepass, renderPass) => + publicAPI.opaquePass(prepass, renderPass); // Renders myself publicAPI.opaquePass = (prepass, renderPass) => { if (prepass) { - model.context = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderWindow').getContext(); + model.context = publicAPI + .getFirstAncestorOfType('vtkOpenGLRenderWindow') + .getContext(); model.context.depthMask(true); } }; @@ -88,7 +94,9 @@ function vtkOpenGLImageSlice(publicAPI, model) { // Renders myself publicAPI.translucentPass = (prepass, renderPass) => { if (prepass) { - model.context = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderWindow').getContext(); + model.context = publicAPI + .getFirstAncestorOfType('vtkOpenGLRenderWindow') + .getContext(); model.context.depthMask(false); } else { model.context.depthMask(true); @@ -140,9 +148,7 @@ export function extend(publicAPI, model, initialValues = {}) { model.MCWCMatrix = mat4.create(); // Build VTK API - macro.setGet(publicAPI, model, [ - 'context', - ]); + macro.setGet(publicAPI, model, ['context']); // Object methods vtkOpenGLImageSlice(publicAPI, model); diff --git a/Sources/Rendering/OpenGL/PixelSpaceCallbackMapper/index.js b/Sources/Rendering/OpenGL/PixelSpaceCallbackMapper/index.js index 92b07c270a1..a71d5362f9f 100644 --- a/Sources/Rendering/OpenGL/PixelSpaceCallbackMapper/index.js +++ b/Sources/Rendering/OpenGL/PixelSpaceCallbackMapper/index.js @@ -1,7 +1,7 @@ // import { mat4, vec3 } from 'gl-matrix'; -import macro from 'vtk.js/Sources/macro'; -import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; +import macro from 'vtk.js/Sources/macro'; +import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; const { vtkDebugMacro } = macro; @@ -13,10 +13,14 @@ function vtkOpenGLPixelSpaceCallbackMapper(publicAPI, model) { model.classHierarchy.push('vtkOpenGLPixelSpaceCallbackMapper'); publicAPI.opaquePass = (prepass, renderPass) => { - model.openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer'); + model.openGLRenderer = publicAPI.getFirstAncestorOfType( + 'vtkOpenGLRenderer' + ); model.openGLRenderWindow = model.openGLRenderer.getParent(); const aspectRatio = model.openGLRenderer.getAspectRatio(); - const camera = model.openGLRenderer ? model.openGLRenderer.getRenderable().getActiveCamera() : null; + const camera = model.openGLRenderer + ? model.openGLRenderer.getRenderable().getActiveCamera() + : null; const tsize = model.openGLRenderer.getTiledSizeAndOrigin(); let texels = null; @@ -39,9 +43,17 @@ function vtkOpenGLPixelSpaceCallbackMapper(publicAPI, model) { const framebuffer = gl.createFramebuffer(); gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, zbt.getHandle(), 0); - - if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) === gl.FRAMEBUFFER_COMPLETE) { + gl.framebufferTexture2D( + gl.FRAMEBUFFER, + gl.COLOR_ATTACHMENT0, + gl.TEXTURE_2D, + zbt.getHandle(), + 0 + ); + + if ( + gl.checkFramebufferStatus(gl.FRAMEBUFFER) === gl.FRAMEBUFFER_COMPLETE + ) { texels = new Uint8Array(width * height * 4); gl.viewport(0, 0, width, height); gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, texels); @@ -55,7 +67,13 @@ function vtkOpenGLPixelSpaceCallbackMapper(publicAPI, model) { gl.deleteFramebuffer(framebuffer); } - model.renderable.invokeCallback(model.renderable.getInputData(), camera, aspectRatio, tsize, texels); + model.renderable.invokeCallback( + model.renderable.getInputData(), + camera, + aspectRatio, + tsize, + texels + ); }; publicAPI.queryPass = (prepass, renderPass) => { @@ -89,7 +107,10 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkOpenGLPixelSpaceCallbackMapper'); +export const newInstance = macro.newInstance( + extend, + 'vtkOpenGLPixelSpaceCallbackMapper' +); // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/OpenGL/PolyDataMapper/index.js b/Sources/Rendering/OpenGL/PolyDataMapper/index.js index d2f3be2896a..bf28782df5d 100644 --- a/Sources/Rendering/OpenGL/PolyDataMapper/index.js +++ b/Sources/Rendering/OpenGL/PolyDataMapper/index.js @@ -1,14 +1,14 @@ import { mat3, mat4, vec3 } from 'gl-matrix'; -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkHardwareSelector from 'vtk.js/Sources/Rendering/OpenGL/HardwareSelector'; -import vtkHelper from 'vtk.js/Sources/Rendering/OpenGL/Helper'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; -import vtkOpenGLTexture from 'vtk.js/Sources/Rendering/OpenGL/Texture'; -import vtkProperty from 'vtk.js/Sources/Rendering/Core/Property'; -import vtkShaderProgram from 'vtk.js/Sources/Rendering/OpenGL/ShaderProgram'; -import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; +import vtkHelper from 'vtk.js/Sources/Rendering/OpenGL/Helper'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkOpenGLTexture from 'vtk.js/Sources/Rendering/OpenGL/Texture'; +import vtkProperty from 'vtk.js/Sources/Rendering/Core/Property'; +import vtkShaderProgram from 'vtk.js/Sources/Rendering/OpenGL/ShaderProgram'; +import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; import vtkPolyDataVS from 'vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyDataVS.glsl'; import vtkPolyDataFS from 'vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyDataFS.glsl'; @@ -46,10 +46,13 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { publicAPI.buildPass = (prepass) => { if (prepass) { model.openGLActor = publicAPI.getFirstAncestorOfType('vtkOpenGLActor'); - model.openGLRenderer = model.openGLActor.getFirstAncestorOfType('vtkOpenGLRenderer'); + model.openGLRenderer = model.openGLActor.getFirstAncestorOfType( + 'vtkOpenGLRenderer' + ); model.openGLRenderWindow = model.openGLRenderer.getParent(); model.openGLCamera = model.openGLRenderer.getViewNodeFor( - model.openGLRenderer.getRenderable().getActiveCamera()); + model.openGLRenderer.getRenderable().getActiveCamera() + ); } }; @@ -103,7 +106,12 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { if (currReplacement.replaceFirst) { const shaderType = currReplacement.shaderType; const ssrc = shaders[shaderType]; - const substituteRes = vtkShaderProgram.substitute(ssrc, currReplacement.originalValue, currReplacement.replacementValue, currReplacement.replaceAll); + const substituteRes = vtkShaderProgram.substitute( + ssrc, + currReplacement.originalValue, + currReplacement.replacementValue, + currReplacement.replaceAll + ); shaders[shaderType] = substituteRes.result; } } @@ -118,7 +126,12 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { if (!currReplacement.replaceFirst) { const shaderType = currReplacement.shaderType; const ssrc = shaders[shaderType]; - const substituteRes = vtkShaderProgram.substitute(ssrc, currReplacement.originalValue, currReplacement.replacementValue, currReplacement.replaceAll); + const substituteRes = vtkShaderProgram.substitute( + ssrc, + currReplacement.originalValue, + currReplacement.replacementValue, + currReplacement.replaceAll + ); shaders[shaderType] = substituteRes.result; } } @@ -161,8 +174,9 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { let GSSource = shaders.Geometry; let FSSource = shaders.Fragment; - const lastLightComplexity = - model.lastBoundBO.getReferenceByName('lastLightComplexity'); + const lastLightComplexity = model.lastBoundBO.getReferenceByName( + 'lastLightComplexity' + ); // create the material/color property declarations, and VS implementation // these are always defined @@ -172,12 +186,14 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { 'uniform float specular;', 'uniform float opacityUniform; // the fragment opacity', 'uniform vec3 ambientColorUniform;', - 'uniform vec3 diffuseColorUniform;']; + 'uniform vec3 diffuseColorUniform;', + ]; // add more for specular if (lastLightComplexity) { colorDec = colorDec.concat([ 'uniform vec3 specularColorUniform;', - 'uniform float specularPowerUniform;']); + 'uniform float specularPowerUniform;', + ]); } // now handle the more complex fragment shader implementation @@ -186,64 +202,91 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { let colorImpl = [ 'vec3 ambientColor;', ' vec3 diffuseColor;', - ' float opacity;']; + ' float opacity;', + ]; if (lastLightComplexity) { colorImpl = colorImpl.concat([ ' vec3 specularColor;', - ' float specularPower;']); + ' float specularPower;', + ]); } colorImpl = colorImpl.concat([ ' ambientColor = ambientColorUniform;', ' diffuseColor = diffuseColorUniform;', - ' opacity = opacityUniform;']); + ' opacity = opacityUniform;', + ]); if (lastLightComplexity) { colorImpl = colorImpl.concat([ ' specularColor = specularColorUniform;', - ' specularPower = specularPowerUniform;']); + ' specularPower = specularPowerUniform;', + ]); } // add scalar vertex coloring - if (model.lastBoundBO.getCABO().getColorComponents() !== 0 && - !model.drawingEdges) { + if ( + model.lastBoundBO.getCABO().getColorComponents() !== 0 && + !model.drawingEdges + ) { colorDec = colorDec.concat(['varying vec4 vertexColorVSOutput;']); VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Color::Dec', [ 'attribute vec4 scalarColor;', - 'varying vec4 vertexColorVSOutput;']).result; + 'varying vec4 vertexColorVSOutput;', + ]).result; VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Color::Impl', [ - 'vertexColorVSOutput = scalarColor;']).result; - GSSource = vtkShaderProgram.substitute(GSSource, - '//VTK::Color::Dec', [ - 'in vec4 vertexColorVSOutput[];', - 'out vec4 vertexColorGSOutput;']).result; - GSSource = vtkShaderProgram.substitute(GSSource, - '//VTK::Color::Impl', [ - 'vertexColorGSOutput = vertexColorVSOutput[i];']).result; - } - - if (model.lastBoundBO.getCABO().getColorComponents() !== 0 && - !model.drawingEdges) { - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Color::Impl', + 'vertexColorVSOutput = scalarColor;', + ]).result; + GSSource = vtkShaderProgram.substitute(GSSource, '//VTK::Color::Dec', [ + 'in vec4 vertexColorVSOutput[];', + 'out vec4 vertexColorGSOutput;', + ]).result; + GSSource = vtkShaderProgram.substitute(GSSource, '//VTK::Color::Impl', [ + 'vertexColorGSOutput = vertexColorVSOutput[i];', + ]).result; + } + + if ( + model.lastBoundBO.getCABO().getColorComponents() !== 0 && + !model.drawingEdges + ) { + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Color::Impl', colorImpl.concat([ ' diffuseColor = vertexColorVSOutput.rgb;', ' ambientColor = vertexColorVSOutput.rgb;', - ' opacity = opacity*vertexColorVSOutput.a;'])).result; + ' opacity = opacity*vertexColorVSOutput.a;', + ]) + ).result; } else { - if (model.renderable.getInterpolateScalarsBeforeMapping() - && model.renderable.getColorCoordinates() - && !model.drawingEdges) { - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Color::Impl', + if ( + model.renderable.getInterpolateScalarsBeforeMapping() && + model.renderable.getColorCoordinates() && + !model.drawingEdges + ) { + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Color::Impl', colorImpl.concat([ ' vec4 texColor = texture2D(texture1, tcoordVCVSOutput.st);', ' diffuseColor = texColor.rgb;', ' ambientColor = texColor.rgb;', - ' opacity = opacity*texColor.a;'])).result; + ' opacity = opacity*texColor.a;', + ]) + ).result; } else { - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Color::Impl', colorImpl).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Color::Impl', + colorImpl + ).result; } } - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Color::Dec', - colorDec).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Color::Dec', + colorDec + ).result; shaders.Vertex = VSSource; shaders.Geometry = GSSource; @@ -256,47 +299,64 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { // check for shadow maps const shadowFactor = ''; - const lastLightComplexity = - model.lastBoundBO.getReferenceByName('lastLightComplexity'); + const lastLightComplexity = model.lastBoundBO.getReferenceByName( + 'lastLightComplexity' + ); - const lastLightCount = - model.lastBoundBO.getReferenceByName('lastLightCount'); + const lastLightCount = model.lastBoundBO.getReferenceByName( + 'lastLightCount' + ); let sstring = []; switch (lastLightComplexity) { case 0: // no lighting or RENDER_VALUES - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Light::Impl', [ - ' gl_FragData[0] = vec4(ambientColor * ambient + diffuseColor * diffuse, opacity);', - ' //VTK::Light::Impl'], - false, + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Light::Impl', + [ + ' gl_FragData[0] = vec4(ambientColor * ambient + diffuseColor * diffuse, opacity);', + ' //VTK::Light::Impl', + ], + false ).result; break; - case 1: // headlight - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Light::Impl', [ - ' float df = max(0.0, normalVCVSOutput.z);', - ' float sf = pow(df, specularPower);', - ' vec3 diffuseL = df * diffuseColor;', - ' vec3 specularL = sf * specularColor;', - ' gl_FragData[0] = vec4(ambientColor * ambient + diffuseL * diffuse + specularL * specular, opacity);', - ' //VTK::Light::Impl'], - false).result; + case 1: // headlight + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Light::Impl', + [ + ' float df = max(0.0, normalVCVSOutput.z);', + ' float sf = pow(df, specularPower);', + ' vec3 diffuseL = df * diffuseColor;', + ' vec3 specularL = sf * specularColor;', + ' gl_FragData[0] = vec4(ambientColor * ambient + diffuseL * diffuse + specularL * specular, opacity);', + ' //VTK::Light::Impl', + ], + false + ).result; break; case 2: // light kit for (let lc = 0; lc < lastLightCount; ++lc) { - sstring = sstring.concat([`uniform vec3 lightColor${lc};`, + sstring = sstring.concat([ + `uniform vec3 lightColor${lc};`, `uniform vec3 lightDirectionVC${lc}; // normalized`, - `uniform vec3 lightHalfAngleVC${lc}; // normalized`]); + `uniform vec3 lightHalfAngleVC${lc}; // normalized`, + ]); } - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Light::Dec', sstring).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Light::Dec', + sstring + ).result; sstring = [ 'vec3 diffuseL = vec3(0,0,0);', ' vec3 specularL = vec3(0,0,0);', - ' float df;']; + ' float df;', + ]; for (let lc = 0; lc < lastLightCount; ++lc) { sstring = sstring.concat([ ` df = max(0.0, dot(normalVCVSOutput, -lightDirectionVC${lc}));`, @@ -305,37 +365,49 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { ' {', ` float sf = pow( max(0.0, dot(lightHalfAngleVC${lc},normalVCVSOutput)), specularPower);`, ` specularL += ((sf${shadowFactor}) * lightColor${lc});`, - ' }']); + ' }', + ]); } sstring = sstring.concat([ ' diffuseL = diffuseL * diffuseColor;', ' specularL = specularL * specularColor;', ' gl_FragData[0] = vec4(ambientColor * ambient + diffuseL * diffuse + specularL * specular, opacity);', - ' //VTK::Light::Impl']); - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Light::Impl', sstring, false).result; + ' //VTK::Light::Impl', + ]); + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Light::Impl', + sstring, + false + ).result; break; case 3: // positional for (let lc = 0; lc < lastLightCount; ++lc) { - sstring = sstring.concat([`uniform vec3 lightColor${lc};`, + sstring = sstring.concat([ + `uniform vec3 lightColor${lc};`, `uniform vec3 lightDirectionVC${lc}; // normalized`, `uniform vec3 lightHalfAngleVC${lc}; // normalized`, `uniform vec3 lightPositionVC${lc};`, `uniform vec3 lightAttenuation${lc};`, `uniform float lightConeAngle${lc};`, `uniform float lightExponent${lc};`, - `uniform int lightPositional${lc};`]); + `uniform int lightPositional${lc};`, + ]); } - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Light::Dec', sstring).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Light::Dec', + sstring + ).result; sstring = [ 'vec3 diffuseL = vec3(0,0,0);', ' vec3 specularL = vec3(0,0,0);', ' vec3 vertLightDirectionVC;', ' float attenuation;', - ' float df;']; + ' float df;', + ]; for (let lc = 0; lc < lastLightCount; ++lc) { sstring = sstring.concat([ ' attenuation = 1.0;', @@ -373,15 +445,21 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { ' {', ` float sf = attenuation*pow( max(0.0, dot(lightHalfAngleVC${lc},normalVCVSOutput)), specularPower);`, ` specularL += ((sf${shadowFactor}) * lightColor${lc});`, - ' }']); + ' }', + ]); } sstring = sstring.concat([ ' diffuseL = diffuseL * diffuseColor;', ' specularL = specularL * specularColor;', ' gl_FragData[0] = vec4(ambientColor * ambient + diffuseL * diffuse + specularL * specular, opacity);', - ' //VTK::Light::Impl']); - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Light::Impl', sstring, false).result; + ' //VTK::Light::Impl', + ]); + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Light::Impl', + sstring, + false + ).result; break; default: vtkErrorMacro('bad light complexity'); @@ -391,8 +469,9 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { }; publicAPI.replaceShaderNormal = (shaders, ren, actor) => { - const lastLightComplexity = - model.lastBoundBO.getReferenceByName('lastLightComplexity'); + const lastLightComplexity = model.lastBoundBO.getReferenceByName( + 'lastLightComplexity' + ); if (lastLightComplexity > 0) { let VSSource = shaders.Vertex; @@ -400,47 +479,61 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { let FSSource = shaders.Fragment; if (model.lastBoundBO.getCABO().getNormalOffset()) { - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::Normal::Dec', [ - 'attribute vec3 normalMC;', - 'uniform mat3 normalMatrix;', - 'varying vec3 normalVCVSOutput;']).result; - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::Normal::Impl', [ - 'normalVCVSOutput = normalMatrix * normalMC;']).result; - GSSource = vtkShaderProgram.substitute(GSSource, - '//VTK::Normal::Dec', [ - 'in vec3 normalVCVSOutput[];', - 'out vec3 normalVCGSOutput;']).result; - GSSource = vtkShaderProgram.substitute(GSSource, - '//VTK::Normal::Impl', [ - 'normalVCGSOutput = normalVCVSOutput[i];']).result; - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Normal::Dec', [ - 'varying vec3 normalVCVSOutput;']).result; - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Normal::Impl', [ + VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Normal::Dec', [ + 'attribute vec3 normalMC;', + 'uniform mat3 normalMatrix;', + 'varying vec3 normalVCVSOutput;', + ]).result; + VSSource = vtkShaderProgram.substitute( + VSSource, + '//VTK::Normal::Impl', + ['normalVCVSOutput = normalMatrix * normalMC;'] + ).result; + GSSource = vtkShaderProgram.substitute(GSSource, '//VTK::Normal::Dec', [ + 'in vec3 normalVCVSOutput[];', + 'out vec3 normalVCGSOutput;', + ]).result; + GSSource = vtkShaderProgram.substitute( + GSSource, + '//VTK::Normal::Impl', + ['normalVCGSOutput = normalVCVSOutput[i];'] + ).result; + FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Dec', [ + 'varying vec3 normalVCVSOutput;', + ]).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Normal::Impl', + [ 'vec3 normalVCVSOutput = normalize(normalVCVSOutput);', // if (!gl_FrontFacing) does not work in intel hd4000 mac // if (int(gl_FrontFacing) == 0) does not work on mesa - ' if (gl_FrontFacing == false) { normalVCVSOutput = -normalVCVSOutput; }'], - ).result; + ' if (gl_FrontFacing == false) { normalVCVSOutput = -normalVCVSOutput; }', + ] + ).result; } else { if (model.haveCellNormals) { - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Normal::Dec', [ - 'uniform mat3 normalMatrix;', - 'uniform samplerBuffer textureN;']).result; - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Normal::Impl', [ + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Normal::Dec', + ['uniform mat3 normalMatrix;', 'uniform samplerBuffer textureN;'] + ).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Normal::Impl', + [ 'vec3 normalVCVSOutput = normalize(normalMatrix *', ' texelFetchBuffer(textureN, gl_PrimitiveID + PrimitiveIDOffset).xyz);', - ' if (gl_FrontFacing == false) { normalVCVSOutput = -normalVCVSOutput; }'], - ).result; + ' if (gl_FrontFacing == false) { normalVCVSOutput = -normalVCVSOutput; }', + ] + ).result; } else { - if (publicAPI.getOpenGLMode( - actor.getProperty().getRepresentation(), - model.lastBoundBO.getPrimitiveType()) === model.context.LINES) { + if ( + publicAPI.getOpenGLMode( + actor.getProperty().getRepresentation(), + model.lastBoundBO.getPrimitiveType() + ) === model.context.LINES + ) { // generate a normal for lines, it will be perpendicular to the line // and maximally aligned with the camera view direction // no clue if this is the best way to do this. @@ -452,40 +545,58 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { // view are probably not orthogonal. Which is why when we cross result that with // the line gradient again we get a reasonable normal. It will be othogonal to // the line (which is a plane but maximally aligned with the camera view. - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::UniformFlow::Impl', [ - ' vec3 fdx = vec3(dFdx(vertexVC.x),dFdx(vertexVC.y),dFdx(vertexVC.z));', - ' vec3 fdy = vec3(dFdy(vertexVC.x),dFdy(vertexVC.y),dFdy(vertexVC.z));', - ' //VTK::UniformFlow::Impl'], // For further replacements - ).result; - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Impl', [ - 'vec3 normalVCVSOutput;', - ' fdx = normalize(fdx);', - ' fdy = normalize(fdy);', - ' if (abs(fdx.x) > 0.0)', - ' { normalVCVSOutput = normalize(cross(vec3(fdx.y, -fdx.x, 0.0), fdx)); }', - ' else { normalVCVSOutput = normalize(cross(vec3(fdy.y, -fdy.x, 0.0), fdy));}'], - ).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::UniformFlow::Impl', + [ + ' vec3 fdx = vec3(dFdx(vertexVC.x),dFdx(vertexVC.y),dFdx(vertexVC.z));', + ' vec3 fdy = vec3(dFdy(vertexVC.x),dFdy(vertexVC.y),dFdy(vertexVC.z));', + ' //VTK::UniformFlow::Impl', + ] // For further replacements + ).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Normal::Impl', + [ + 'vec3 normalVCVSOutput;', + ' fdx = normalize(fdx);', + ' fdy = normalize(fdy);', + ' if (abs(fdx.x) > 0.0)', + ' { normalVCVSOutput = normalize(cross(vec3(fdx.y, -fdx.x, 0.0), fdx)); }', + ' else { normalVCVSOutput = normalize(cross(vec3(fdy.y, -fdy.x, 0.0), fdy));}', + ] + ).result; } else { - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Normal::Dec', [ - 'uniform int cameraParallel;']).result; - - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::UniformFlow::Impl', [ - // ' vec3 fdx = vec3(dFdx(vertexVC.x),dFdx(vertexVC.y),dFdx(vertexVC.z));', - // ' vec3 fdy = vec3(dFdy(vertexVC.x),dFdy(vertexVC.y),dFdy(vertexVC.z));', - ' vec3 fdx = dFdx(vertexVC.xyz);', - ' vec3 fdy = dFdy(vertexVC.xyz);', - ' //VTK::UniformFlow::Impl'], // For further replacements - ).result; - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Impl', [ - ' fdx = normalize(fdx);', - ' fdy = normalize(fdy);', - ' vec3 normalVCVSOutput = normalize(cross(fdx,fdy));', - // the code below is faster, but does not work on some devices - // 'vec3 normalVC = normalize(cross(dFdx(vertexVC.xyz), dFdy(vertexVC.xyz)));', - ' if (cameraParallel == 1 && normalVCVSOutput.z < 0.0) { normalVCVSOutput = -1.0*normalVCVSOutput; }', - ' if (cameraParallel == 0 && dot(normalVCVSOutput,vertexVC.xyz) > 0.0) { normalVCVSOutput = -1.0*normalVCVSOutput; }', - ]).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Normal::Dec', + ['uniform int cameraParallel;'] + ).result; + + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::UniformFlow::Impl', + [ + // ' vec3 fdx = vec3(dFdx(vertexVC.x),dFdx(vertexVC.y),dFdx(vertexVC.z));', + // ' vec3 fdy = vec3(dFdy(vertexVC.x),dFdy(vertexVC.y),dFdy(vertexVC.z));', + ' vec3 fdx = dFdx(vertexVC.xyz);', + ' vec3 fdy = dFdy(vertexVC.xyz);', + ' //VTK::UniformFlow::Impl', + ] // For further replacements + ).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Normal::Impl', + [ + ' fdx = normalize(fdx);', + ' fdy = normalize(fdy);', + ' vec3 normalVCVSOutput = normalize(cross(fdx,fdy));', + // the code below is faster, but does not work on some devices + // 'vec3 normalVC = normalize(cross(dFdx(vertexVC.xyz), dFdy(vertexVC.xyz)));', + ' if (cameraParallel == 1 && normalVCVSOutput.z < 0.0) { normalVCVSOutput = -1.0*normalVCVSOutput; }', + ' if (cameraParallel == 0 && dot(normalVCVSOutput,vertexVC.xyz) > 0.0) { normalVCVSOutput = -1.0*normalVCVSOutput; }', + ] + ).result; } } } @@ -501,49 +612,75 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { let FSSource = shaders.Fragment; // for points make sure to add in the point size - if (actor.getProperty().getRepresentation() === Representation.POINTS - || model.lastBoundBO.getPrimitiveType() === primTypes.Points) { - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::PositionVC::Impl', [ + if ( + actor.getProperty().getRepresentation() === Representation.POINTS || + model.lastBoundBO.getPrimitiveType() === primTypes.Points + ) { + VSSource = vtkShaderProgram.substitute( + VSSource, + '//VTK::PositionVC::Impl', + [ '//VTK::PositionVC::Impl', - ` gl_PointSize = ${actor.getProperty().getPointSize().toFixed(1)};`], false).result; + ` gl_PointSize = ${actor + .getProperty() + .getPointSize() + .toFixed(1)};`, + ], + false + ).result; } // do we need the vertex in the shader in View Coordinates - const lastLightComplexity = - model.lastBoundBO.getReferenceByName('lastLightComplexity'); + const lastLightComplexity = model.lastBoundBO.getReferenceByName( + 'lastLightComplexity' + ); if (lastLightComplexity > 0) { - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::PositionVC::Dec', [ - 'varying vec4 vertexVCVSOutput;']).result; - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::PositionVC::Impl', [ + VSSource = vtkShaderProgram.substitute( + VSSource, + '//VTK::PositionVC::Dec', + ['varying vec4 vertexVCVSOutput;'] + ).result; + VSSource = vtkShaderProgram.substitute( + VSSource, + '//VTK::PositionVC::Impl', + [ 'vertexVCVSOutput = MCVCMatrix * vertexMC;', - ' gl_Position = MCDCMatrix * vertexMC;']).result; - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::Camera::Dec', [ - 'uniform mat4 MCDCMatrix;', - 'uniform mat4 MCVCMatrix;']).result; - GSSource = vtkShaderProgram.substitute(GSSource, - '//VTK::PositionVC::Dec', [ - 'in vec4 vertexVCVSOutput[];', - 'out vec4 vertexVCGSOutput;']).result; - GSSource = vtkShaderProgram.substitute(GSSource, - '//VTK::PositionVC::Impl', [ - 'vertexVCGSOutput = vertexVCVSOutput[i];']).result; - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::PositionVC::Dec', [ - 'varying vec4 vertexVCVSOutput;']).result; - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::PositionVC::Impl', [ - 'vec4 vertexVC = vertexVCVSOutput;']).result; + ' gl_Position = MCDCMatrix * vertexMC;', + ] + ).result; + VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Camera::Dec', [ + 'uniform mat4 MCDCMatrix;', + 'uniform mat4 MCVCMatrix;', + ]).result; + GSSource = vtkShaderProgram.substitute( + GSSource, + '//VTK::PositionVC::Dec', + ['in vec4 vertexVCVSOutput[];', 'out vec4 vertexVCGSOutput;'] + ).result; + GSSource = vtkShaderProgram.substitute( + GSSource, + '//VTK::PositionVC::Impl', + ['vertexVCGSOutput = vertexVCVSOutput[i];'] + ).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::PositionVC::Dec', + ['varying vec4 vertexVCVSOutput;'] + ).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::PositionVC::Impl', + ['vec4 vertexVC = vertexVCVSOutput;'] + ).result; } else { - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::Camera::Dec', [ - 'uniform mat4 MCDCMatrix;']).result; - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::PositionVC::Impl', [ - ' gl_Position = MCDCMatrix * vertexMC;']).result; + VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Camera::Dec', [ + 'uniform mat4 MCDCMatrix;', + ]).result; + VSSource = vtkShaderProgram.substitute( + VSSource, + '//VTK::PositionVC::Impl', + [' gl_Position = MCDCMatrix * vertexMC;'] + ).result; } shaders.Vertex = VSSource; shaders.Geometry = GSSource; @@ -560,9 +697,11 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { return; } - VSSource = vtkShaderProgram.substitute(VSSource, + VSSource = vtkShaderProgram.substitute( + VSSource, '//VTK::TCoord::Impl', - 'tcoordVCVSOutput = tcoordMC;').result; + 'tcoordVCVSOutput = tcoordMC;' + ).result; // we only handle the first texture by default // additional textures are activated and we set the uniform @@ -578,81 +717,111 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { } } if (model.renderable.getColorTextureMap()) { - tNumComp = - model.renderable.getColorTextureMap() - .getPointData().getScalars().getNumberOfComponents(); + tNumComp = model.renderable + .getColorTextureMap() + .getPointData() + .getScalars() + .getNumberOfComponents(); tcdim = 2; } if (tcdim === 2) { - VSSource = vtkShaderProgram.substitute(VSSource, + VSSource = vtkShaderProgram.substitute( + VSSource, '//VTK::TCoord::Dec', - 'attribute vec2 tcoordMC; varying vec2 tcoordVCVSOutput;').result; - GSSource = vtkShaderProgram.substitute(GSSource, - '//VTK::TCoord::Dec', [ - 'in vec2 tcoordVCVSOutput[];', - 'out vec2 tcoordVCGSOutput;']).result; - GSSource = vtkShaderProgram.substitute(GSSource, + 'attribute vec2 tcoordMC; varying vec2 tcoordVCVSOutput;' + ).result; + GSSource = vtkShaderProgram.substitute(GSSource, '//VTK::TCoord::Dec', [ + 'in vec2 tcoordVCVSOutput[];', + 'out vec2 tcoordVCGSOutput;', + ]).result; + GSSource = vtkShaderProgram.substitute( + GSSource, '//VTK::TCoord::Impl', - 'tcoordVCGSOutput = tcoordVCVSOutput[i];').result; - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::TCoord::Dec', [ - 'varying vec2 tcoordVCVSOutput;', - 'uniform sampler2D texture1;']).result; + 'tcoordVCGSOutput = tcoordVCVSOutput[i];' + ).result; + FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Dec', [ + 'varying vec2 tcoordVCVSOutput;', + 'uniform sampler2D texture1;', + ]).result; switch (tNumComp) { case 1: - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::TCoord::Impl', [ + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::TCoord::Impl', + [ 'vec4 tcolor = texture2D(texture1, tcoordVCVSOutput);', 'gl_FragData[0] = clamp(gl_FragData[0],0.0,1.0)*', - ' vec4(tcolor.r,tcolor.r,tcolor.r,1.0);']).result; + ' vec4(tcolor.r,tcolor.r,tcolor.r,1.0);', + ] + ).result; break; case 2: - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::TCoord::Impl', [ + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::TCoord::Impl', + [ 'vec4 tcolor = texture2D(texture1, tcoordVCVSOutput);', 'gl_FragData[0] = clamp(gl_FragData[0],0.0,1.0)*', - ' vec4(tcolor.r,tcolor.r,tcolor.r,tcolor.g);']).result; + ' vec4(tcolor.r,tcolor.r,tcolor.r,tcolor.g);', + ] + ).result; break; default: - FSSource = vtkShaderProgram.substitute(FSSource, + FSSource = vtkShaderProgram.substitute( + FSSource, '//VTK::TCoord::Impl', - 'gl_FragData[0] = clamp(gl_FragData[0],0.0,1.0)*texture2D(texture1, tcoordVCVSOutput.st);').result; + 'gl_FragData[0] = clamp(gl_FragData[0],0.0,1.0)*texture2D(texture1, tcoordVCVSOutput.st);' + ).result; } } else { - VSSource = vtkShaderProgram.substitute(VSSource, + VSSource = vtkShaderProgram.substitute( + VSSource, '//VTK::TCoord::Dec', - 'attribute vec3 tcoordMC; varying vec3 tcoordVCVSOutput;').result; - GSSource = vtkShaderProgram.substitute(GSSource, - '//VTK::TCoord::Dec', [ - 'in vec3 tcoordVCVSOutput[];', - 'out vec3 tcoordVCGSOutput;']).result; - GSSource = vtkShaderProgram.substitute(GSSource, + 'attribute vec3 tcoordMC; varying vec3 tcoordVCVSOutput;' + ).result; + GSSource = vtkShaderProgram.substitute(GSSource, '//VTK::TCoord::Dec', [ + 'in vec3 tcoordVCVSOutput[];', + 'out vec3 tcoordVCGSOutput;', + ]).result; + GSSource = vtkShaderProgram.substitute( + GSSource, '//VTK::TCoord::Impl', - 'tcoordVCGSOutput = tcoordVCVSOutput[i];').result; - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::TCoord::Dec', [ - 'varying vec3 tcoordVCVSOutput;', - 'uniform samplerCube texture1;']).result; + 'tcoordVCGSOutput = tcoordVCVSOutput[i];' + ).result; + FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Dec', [ + 'varying vec3 tcoordVCVSOutput;', + 'uniform samplerCube texture1;', + ]).result; switch (tNumComp) { case 1: - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::TCoord::Impl', [ + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::TCoord::Impl', + [ 'vec4 tcolor = textureCube(texture1, tcoordVCVSOutput);', 'gl_FragData[0] = clamp(gl_FragData[0],0.0,1.0)*', - ' vec4(tcolor.r,tcolor.r,tcolor.r,1.0);']).result; + ' vec4(tcolor.r,tcolor.r,tcolor.r,1.0);', + ] + ).result; break; case 2: - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::TCoord::Impl', [ + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::TCoord::Impl', + [ 'vec4 tcolor = textureCube(texture1, tcoordVCVSOutput);', 'gl_FragData[0] = clamp(gl_FragData[0],0.0,1.0)*', - ' vec4(tcolor.r,tcolor.r,tcolor.r,tcolor.g);']).result; + ' vec4(tcolor.r,tcolor.r,tcolor.r,tcolor.g);', + ] + ).result; break; default: - FSSource = vtkShaderProgram.substitute(FSSource, + FSSource = vtkShaderProgram.substitute( + FSSource, '//VTK::TCoord::Impl', - 'gl_FragData[0] = clamp(gl_FragData[0],0.0,1.0)*textureCube(texture1, tcoordVCVSOutput);').result; + 'gl_FragData[0] = clamp(gl_FragData[0],0.0,1.0)*textureCube(texture1, tcoordVCVSOutput);' + ).result; } } shaders.Vertex = VSSource; @@ -671,37 +840,37 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { macro.vtkErrorMacro('OpenGL has a limit of 6 clipping planes'); numClipPlanes = 6; } - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::Clip::Dec', [ - 'uniform int numClipPlanes;', - 'uniform vec4 clipPlanes[6];', - 'varying float clipDistancesVSOutput[6];']).result; - - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::Clip::Impl', [ - 'for (int planeNum = 0; planeNum < 6; planeNum++)', - ' {', - ' if (planeNum >= numClipPlanes)', - ' {', - ' break;', - ' }', - ' clipDistancesVSOutput[planeNum] = dot(clipPlanes[planeNum], vertexMC);', - ' }']).result; - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Clip::Dec', [ - 'uniform int numClipPlanes;', - 'varying float clipDistancesVSOutput[6];']).result; - - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Clip::Impl', [ - 'for (int planeNum = 0; planeNum < 6; planeNum++)', - ' {', - ' if (planeNum >= numClipPlanes)', - ' {', - ' break;', - ' }', - ' if (clipDistancesVSOutput[planeNum] < 0.0) discard;', - ' }']).result; + VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Dec', [ + 'uniform int numClipPlanes;', + 'uniform vec4 clipPlanes[6];', + 'varying float clipDistancesVSOutput[6];', + ]).result; + + VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Impl', [ + 'for (int planeNum = 0; planeNum < 6; planeNum++)', + ' {', + ' if (planeNum >= numClipPlanes)', + ' {', + ' break;', + ' }', + ' clipDistancesVSOutput[planeNum] = dot(clipPlanes[planeNum], vertexMC);', + ' }', + ]).result; + FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Dec', [ + 'uniform int numClipPlanes;', + 'varying float clipDistancesVSOutput[6];', + ]).result; + + FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Impl', [ + 'for (int planeNum = 0; planeNum < 6; planeNum++)', + ' {', + ' if (planeNum >= numClipPlanes)', + ' {', + ' break;', + ' }', + ' if (clipDistancesVSOutput[planeNum] < 0.0) discard;', + ' }', + ]).result; } shaders.Vertex = VSSource; shaders.Fragment = FSSource; @@ -712,36 +881,47 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { // type let cp = null; const prop = actor.getProperty(); - if (model.renderable.getResolveCoincidentTopology() || - (prop.getEdgeVisibility() && - prop.getRepresentation() === Representation.SURFACE)) { + if ( + model.renderable.getResolveCoincidentTopology() || + (prop.getEdgeVisibility() && + prop.getRepresentation() === Representation.SURFACE) + ) { const primType = model.lastBoundBO.getPrimitiveType(); - if (primType === primTypes.Points || - prop.getRepresentation() === Representation.POINTS) { + if ( + primType === primTypes.Points || + prop.getRepresentation() === Representation.POINTS + ) { cp = model.renderable.getCoincidentTopologyPointOffsetParameter(); - } else if (primType === primTypes.Lines || - prop.getRepresentation() === Representation.WIREFRAME) { + } else if ( + primType === primTypes.Lines || + prop.getRepresentation() === Representation.WIREFRAME + ) { cp = model.renderable.getCoincidentTopologyLineOffsetParameters(); - } else if (primType === primTypes.Tris || primType === primTypes.TriStrips) { + } else if ( + primType === primTypes.Tris || + primType === primTypes.TriStrips + ) { cp = model.renderable.getCoincidentTopologyPolygonOffsetParameters(); } - if (primType === primTypes.TrisEdges || - primType === primTypes.TriStripsEdges) { + if ( + primType === primTypes.TrisEdges || + primType === primTypes.TriStripsEdges + ) { cp = model.renderable.getCoincidentTopologyPolygonOffsetParameters(); cp.factor /= 2.0; cp.offset /= 2.0; } } - // hardware picking always offset due to saved zbuffer - // This gets you above the saved surface depth buffer. - // vtkHardwareSelector* selector = ren->GetSelector(); - // if (selector && - // selector->GetFieldAssociation() == vtkDataObject::FIELD_ASSOCIATION_POINTS) - // { - // offset -= 2.0; - // return; - // } + // hardware picking always offset due to saved zbuffer + // This gets you above the saved surface depth buffer. + // vtkHardwareSelector* selector = ren->GetSelector(); + // if (selector && + // selector->GetFieldAssociation() == vtkDataObject::FIELD_ASSOCIATION_POINTS) + // { + // offset -= 2.0; + // return; + // } return cp; }; @@ -756,24 +936,34 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { if (cp && (cp.factor !== 0.0 || cp.offset !== 0.0)) { let FSSource = shaders.Fragment; - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Coincident::Dec', [ - 'uniform float cfactor;', - 'uniform float coffset;']).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Coincident::Dec', + ['uniform float cfactor;', 'uniform float coffset;'] + ).result; if (model.context.getExtension('EXT_frag_depth')) { if (cp.factor !== 0.0) { - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::UniformFlow::Impl', [ + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::UniformFlow::Impl', + [ 'float cscale = length(vec2(dFdx(gl_FragCoord.z),dFdy(gl_FragCoord.z)));', - '//VTK::UniformFlow::Impl'], false).result; - FSSource = vtkShaderProgram.substitute(FSSource, + '//VTK::UniformFlow::Impl', + ], + false + ).result; + FSSource = vtkShaderProgram.substitute( + FSSource, '//VTK::Depth::Impl', - 'gl_FragDepthEXT = gl_FragCoord.z + cfactor*cscale + 0.000016*coffset;').result; + 'gl_FragDepthEXT = gl_FragCoord.z + cfactor*cscale + 0.000016*coffset;' + ).result; } else { - FSSource = vtkShaderProgram.substitute(FSSource, + FSSource = vtkShaderProgram.substitute( + FSSource, '//VTK::Depth::Impl', - 'gl_FragDepthEXT = gl_FragCoord.z + 0.000016*coffset;').result; + 'gl_FragDepthEXT = gl_FragCoord.z + 0.000016*coffset;' + ).result; } } shaders.Fragment = FSSource; @@ -792,12 +982,16 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { // ], false).result; break; default: - FSSource = vtkShaderProgram.substitute(FSSource, + FSSource = vtkShaderProgram.substitute( + FSSource, '//VTK::Picking::Dec', - 'uniform vec3 mapperIndex;').result; - FSSource = vtkShaderProgram.substitute(FSSource, + 'uniform vec3 mapperIndex;' + ).result; + FSSource = vtkShaderProgram.substitute( + FSSource, '//VTK::Picking::Impl', - ' gl_FragData[0] = vec4(mapperIndex,1.0);').result; + ' gl_FragData[0] = vec4(mapperIndex,1.0);' + ).result; } shaders.Fragment = FSSource; } @@ -815,13 +1009,12 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { if (model.renderDepth) { let FSSource = shaders.Fragment; - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::ZBuffer::Impl', [ - 'float iz = floor(gl_FragCoord.z*65535.0 + 0.1);', - 'float rf = floor(iz/256.0)/255.0;', - 'float gf = mod(iz,256.0)/255.0;', - 'gl_FragData[0] = vec4(rf, gf, 0.0, 1.0);', - ]).result; + FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ZBuffer::Impl', [ + 'float iz = floor(gl_FragCoord.z*65535.0 + 0.1);', + 'float rf = floor(iz/256.0)/255.0;', + 'float gf = mod(iz,256.0)/255.0;', + 'gl_FragData[0] = vec4(rf, gf, 0.0, 1.0);', + ]).result; shaders.Fragment = FSSource; } }; @@ -836,16 +1029,20 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { const poly = model.currentInput; - let n = (actor.getProperty().getInterpolation() !== Shading.FLAT) - ? poly.getPointData().getNormals() : null; + let n = + actor.getProperty().getInterpolation() !== Shading.FLAT + ? poly.getPointData().getNormals() + : null; if (n === null && poly.getCellData().getNormals()) { n = poly.getCellData().getNormals(); } - const haveNormals = (n !== null); + const haveNormals = n !== null; - if (actor.getProperty().getRepresentation() === Representation.POINTS || - primType === primTypes.Points) { + if ( + actor.getProperty().getRepresentation() === Representation.POINTS || + primType === primTypes.Points + ) { needLighting = haveNormals; } @@ -865,35 +1062,42 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { } } - if (lightComplexity === 1 - && (numberOfLights > 1 - || light.getIntensity() !== 1.0 - || !light.lightTypeIsHeadLight())) { + if ( + lightComplexity === 1 && + (numberOfLights > 1 || + light.getIntensity() !== 1.0 || + !light.lightTypeIsHeadLight()) + ) { lightComplexity = 2; } - if (lightComplexity < 3 - && (light.getPositional())) { + if (lightComplexity < 3 && light.getPositional()) { lightComplexity = 3; } } } let needRebuild = false; - const lastLightComplexity = - model.lastBoundBO.getReferenceByName('lastLightComplexity'); - const lastLightCount = - model.lastBoundBO.getReferenceByName('lastLightCount'); - if (lastLightComplexity !== lightComplexity || - lastLightCount !== numberOfLights) { + const lastLightComplexity = model.lastBoundBO.getReferenceByName( + 'lastLightComplexity' + ); + const lastLightCount = model.lastBoundBO.getReferenceByName( + 'lastLightCount' + ); + if ( + lastLightComplexity !== lightComplexity || + lastLightCount !== numberOfLights + ) { model.lastBoundBO.set({ lastLightComplexity: lightComplexity }, true); model.lastBoundBO.set({ lastLightCount: numberOfLights }, true); needRebuild = true; } const selector = model.openGLRenderer.getSelector(); - const selectionPass = (selector === null ? -1 : selector.getCurrentPass()); - if (model.lastBoundBO.getReferenceByName('lastSelectionPass') !== - selectionPass) { + const selectionPass = selector === null ? -1 : selector.getCurrentPass(); + if ( + model.lastBoundBO.getReferenceByName('lastSelectionPass') !== + selectionPass + ) { model.lastBoundBO.set({ lastSelectionPass: selectionPass }, true); needRebuild = true; } @@ -905,13 +1109,15 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { // property modified (representation interpolation and lighting) // input modified // light complexity changed - if (model.shaderRebuildString !== toString || - cellBO.getProgram() === 0 || - cellBO.getShaderSourceTime().getMTime() < publicAPI.getMTime() || - cellBO.getShaderSourceTime().getMTime() < actor.getMTime() || - cellBO.getShaderSourceTime().getMTime() < model.renderable.getMTime() || - cellBO.getShaderSourceTime().getMTime() < model.currentInput.getMTime() || - needRebuild) { + if ( + model.shaderRebuildString !== toString || + cellBO.getProgram() === 0 || + cellBO.getShaderSourceTime().getMTime() < publicAPI.getMTime() || + cellBO.getShaderSourceTime().getMTime() < actor.getMTime() || + cellBO.getShaderSourceTime().getMTime() < model.renderable.getMTime() || + cellBO.getShaderSourceTime().getMTime() < model.currentInput.getMTime() || + needRebuild + ) { model.shaderRebuildString = toString; return true; } @@ -928,8 +1134,13 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { publicAPI.buildShaders(shaders, ren, actor); // compile and bind the program if needed - const newShader = - model.openGLRenderWindow.getShaderCache().readyShaderProgramArray(shaders.Vertex, shaders.Fragment, shaders.Geometry); + const newShader = model.openGLRenderWindow + .getShaderCache() + .readyShaderProgramArray( + shaders.Vertex, + shaders.Fragment, + shaders.Geometry + ); // if the shader changed reinitialize the VAO if (newShader !== cellBO.getProgram()) { @@ -940,7 +1151,9 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { cellBO.getShaderSourceTime().modified(); } else { - model.openGLRenderWindow.getShaderCache().readyShaderProgram(cellBO.getProgram()); + model.openGLRenderWindow + .getShaderCache() + .readyShaderProgram(cellBO.getProgram()); } cellBO.getVAO().bind(); @@ -950,7 +1163,8 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { publicAPI.setCameraShaderParameters(cellBO, ren, actor); publicAPI.setLightingShaderParameters(cellBO, ren, actor); - const listCallbacks = model.renderable.getViewSpecificProperties().ShadersCallbacks; + const listCallbacks = model.renderable.getViewSpecificProperties() + .ShadersCallbacks; if (listCallbacks) { listCallbacks.forEach((object) => { object.callback(object.userData, cellBO, ren, actor); @@ -961,56 +1175,105 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { publicAPI.setMapperShaderParameters = (cellBO, ren, actor) => { // Now to update the VAO too, if necessary. if (cellBO.getProgram().isUniformUsed('PrimitiveIDOffset')) { - cellBO.getProgram().setUniformi('PrimitiveIDOffset', - model.primitiveIDOffset); - } - - if (cellBO.getCABO().getElementCount() && - (model.VBOBuildTime.getMTime() > cellBO.getAttributeUpdateTime().getMTime() || - cellBO.getShaderSourceTime().getMTime() > cellBO.getAttributeUpdateTime().getMTime())) { - const lastLightComplexity = - model.lastBoundBO.getReferenceByName('lastLightComplexity'); + cellBO + .getProgram() + .setUniformi('PrimitiveIDOffset', model.primitiveIDOffset); + } + + if ( + cellBO.getCABO().getElementCount() && + (model.VBOBuildTime.getMTime() > + cellBO.getAttributeUpdateTime().getMTime() || + cellBO.getShaderSourceTime().getMTime() > + cellBO.getAttributeUpdateTime().getMTime()) + ) { + const lastLightComplexity = model.lastBoundBO.getReferenceByName( + 'lastLightComplexity' + ); if (cellBO.getProgram().isAttributeUsed('vertexMC')) { - if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO(), - 'vertexMC', cellBO.getCABO().getVertexOffset(), - cellBO.getCABO().getStride(), model.context.FLOAT, 3, - false)) { + if ( + !cellBO + .getVAO() + .addAttributeArray( + cellBO.getProgram(), + cellBO.getCABO(), + 'vertexMC', + cellBO.getCABO().getVertexOffset(), + cellBO.getCABO().getStride(), + model.context.FLOAT, + 3, + false + ) + ) { vtkErrorMacro('Error setting vertexMC in shader VAO.'); } } - if (cellBO.getProgram().isAttributeUsed('normalMC') && - cellBO.getCABO().getNormalOffset() && - lastLightComplexity > 0) { - if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO(), - 'normalMC', cellBO.getCABO().getNormalOffset(), - cellBO.getCABO().getStride(), model.context.FLOAT, 3, - false)) { + if ( + cellBO.getProgram().isAttributeUsed('normalMC') && + cellBO.getCABO().getNormalOffset() && + lastLightComplexity > 0 + ) { + if ( + !cellBO + .getVAO() + .addAttributeArray( + cellBO.getProgram(), + cellBO.getCABO(), + 'normalMC', + cellBO.getCABO().getNormalOffset(), + cellBO.getCABO().getStride(), + model.context.FLOAT, + 3, + false + ) + ) { vtkErrorMacro('Error setting normalMC in shader VAO.'); } } else { cellBO.getVAO().removeAttributeArray('normalMC'); } - if (cellBO.getProgram().isAttributeUsed('tcoordMC') && - cellBO.getCABO().getTCoordOffset()) { - if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO(), - 'tcoordMC', cellBO.getCABO().getTCoordOffset(), - cellBO.getCABO().getStride(), model.context.FLOAT, - cellBO.getCABO().getTCoordComponents(), - false)) { + if ( + cellBO.getProgram().isAttributeUsed('tcoordMC') && + cellBO.getCABO().getTCoordOffset() + ) { + if ( + !cellBO + .getVAO() + .addAttributeArray( + cellBO.getProgram(), + cellBO.getCABO(), + 'tcoordMC', + cellBO.getCABO().getTCoordOffset(), + cellBO.getCABO().getStride(), + model.context.FLOAT, + cellBO.getCABO().getTCoordComponents(), + false + ) + ) { vtkErrorMacro('Error setting tcoordMC in shader VAO.'); } } else { cellBO.getVAO().removeAttributeArray('tcoordMC'); } - if (cellBO.getProgram().isAttributeUsed('scalarColor') && - cellBO.getCABO().getColorComponents()) { - if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO().getColorBO(), - 'scalarColor', cellBO.getCABO().getColorOffset(), - cellBO.getCABO().getColorBOStride(), - model.context.UNSIGNED_BYTE, - 4, - true)) { + if ( + cellBO.getProgram().isAttributeUsed('scalarColor') && + cellBO.getCABO().getColorComponents() + ) { + if ( + !cellBO + .getVAO() + .addAttributeArray( + cellBO.getProgram(), + cellBO.getCABO().getColorBO(), + 'scalarColor', + cellBO.getCABO().getColorOffset(), + cellBO.getCABO().getColorBOStride(), + model.context.UNSIGNED_BYTE, + 4, + true + ) + ) { vtkErrorMacro('Error setting scalarColor in shader VAO.'); } } else { @@ -1030,7 +1293,11 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { const planeEquations = []; for (let i = 0; i < numClipPlanes; i++) { const planeEquation = []; - model.renderable.getClippingPlaneInDataCoords(actor.getMatrix(), i, planeEquation); + model.renderable.getClippingPlaneInDataCoords( + actor.getMatrix(), + i, + planeEquation + ); for (let j = 0; j < 4; j++) { planeEquations.push(planeEquation[j]); @@ -1040,10 +1307,13 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { cellBO.getProgram().setUniform4fv('clipPlanes', 6, planeEquations); } - if (model.internalColorTexture - && cellBO.getProgram().isUniformUsed('texture1')) { - cellBO.getProgram().setUniformi('texture1', - model.internalColorTexture.getTextureUnit()); + if ( + model.internalColorTexture && + cellBO.getProgram().isUniformUsed('texture1') + ) { + cellBO + .getProgram() + .setUniformi('texture1', model.internalColorTexture.getTextureUnit()); } const tus = model.openGLActor.getActiveTextures(); if (tus) { @@ -1070,15 +1340,18 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { const selector = model.openGLRenderer.getSelector(); if (selector && cellBO.getProgram().isUniformUsed('mapperIndex')) { if (selector.getCurrentPass() < PassTypes.ID_LOW24) { - cellBO.getProgram().setUniform3fArray('mapperIndex', selector.getPropColorValue()); + cellBO + .getProgram() + .setUniform3fArray('mapperIndex', selector.getPropColorValue()); } } }; publicAPI.setLightingShaderParameters = (cellBO, ren, actor) => { // for unlit and headlight there are no lighting parameters - const lastLightComplexity = - model.lastBoundBO.getReferenceByName('lastLightComplexity'); + const lastLightComplexity = model.lastBoundBO.getReferenceByName( + 'lastLightComplexity' + ); if (lastLightComplexity < 2) { return; } @@ -1107,9 +1380,18 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { model.lightHalfAngle[1] = -model.lightDirection[1]; model.lightHalfAngle[2] = -model.lightDirection[2] + 1.0; vtkMath.normalize(model.lightDirection); - program.setUniform3fArray(`lightColor${numberOfLights}`, model.lightColor); - program.setUniform3fArray(`lightDirectionVC${numberOfLights}`, model.lightDirection); - program.setUniform3fArray(`lightHalfAngleVC${numberOfLights}`, model.lightHalfAngle); + program.setUniform3fArray( + `lightColor${numberOfLights}`, + model.lightColor + ); + program.setUniform3fArray( + `lightDirectionVC${numberOfLights}`, + model.lightDirection + ); + program.setUniform3fArray( + `lightHalfAngleVC${numberOfLights}`, + model.lightHalfAngle + ); numberOfLights++; } } @@ -1133,12 +1415,27 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { const lp = light.getTransformedPosition(); const np = vec3.fromValues(lp[0], lp[1], lp[2]); vec3.transformMat4(np, np, viewTF); - program.setUniform3fArray(`lightAttenuation${numberOfLights}`, light.getAttenuationValuesByReference()); - program.setUniformi(`lightPositional${numberOfLights}`, light.getPositional()); - program.setUniformf(`lightExponent${numberOfLights}`, light.getExponent()); - program.setUniformf(`lightConeAngle${numberOfLights}`, light.getConeAngle()); - program.setUniform3fArray(`lightPositionVC${numberOfLights}`, - [np[0], np[1], np[2]]); + program.setUniform3fArray( + `lightAttenuation${numberOfLights}`, + light.getAttenuationValuesByReference() + ); + program.setUniformi( + `lightPositional${numberOfLights}`, + light.getPositional() + ); + program.setUniformf( + `lightExponent${numberOfLights}`, + light.getExponent() + ); + program.setUniformf( + `lightConeAngle${numberOfLights}`, + light.getConeAngle() + ); + program.setUniform3fArray(`lightPositionVC${numberOfLights}`, [ + np[0], + np[1], + np[2], + ]); numberOfLights++; } } @@ -1198,19 +1495,22 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { const opacity = ppty.getOpacity(); program.setUniformf('opacityUniform', opacity); - const aColor = model.drawingEdges ? ppty.getEdgeColorByReference() + const aColor = model.drawingEdges + ? ppty.getEdgeColorByReference() : ppty.getAmbientColorByReference(); program.setUniform3fArray('ambientColorUniform', aColor); program.setUniformf('ambient', ppty.getAmbient()); - const dColor = model.drawingEdges ? ppty.getEdgeColorByReference() + const dColor = model.drawingEdges + ? ppty.getEdgeColorByReference() : ppty.getDiffuseColorByReference(); program.setUniform3fArray('diffuseColorUniform', dColor); program.setUniformf('diffuse', ppty.getDiffuse()); // we are done unless we have lighting - const lastLightComplexity = - model.lastBoundBO.getReferenceByName('lastLightComplexity'); + const lastLightComplexity = model.lastBoundBO.getReferenceByName( + 'lastLightComplexity' + ); if (lastLightComplexity < 1) { return; } @@ -1284,8 +1584,8 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { const gl = model.context; const drawSurfaceWithEdges = - (actor.getProperty().getEdgeVisibility() && - representation === Representation.SURFACE); + actor.getProperty().getEdgeVisibility() && + representation === Representation.SURFACE; // for every primitive type for (let i = primTypes.Start; i < primTypes.End; i++) { @@ -1294,27 +1594,28 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { if (cabo.getElementCount()) { // are we drawing edges model.drawingEdges = - drawSurfaceWithEdges && (i === primTypes.TrisEdges - || i === primTypes.TriStripsEdges); + drawSurfaceWithEdges && + (i === primTypes.TrisEdges || i === primTypes.TriStripsEdges); publicAPI.updateShaders(model.primitives[i], ren, actor); const mode = publicAPI.getOpenGLMode(representation, i); gl.drawArrays(mode, 0, cabo.getElementCount()); - const stride = (mode === gl.POINTS ? 1 : (mode === gl.LINES ? 2 : 3)); + const stride = mode === gl.POINTS ? 1 : mode === gl.LINES ? 2 : 3; model.primitiveIDOffset += cabo.getElementCount() / stride; } } }; publicAPI.getOpenGLMode = (rep, type) => { - if (rep === Representation.POINTS || - type === primTypes.Points) { + if (rep === Representation.POINTS || type === primTypes.Points) { return model.context.POINTS; } - if (rep === Representation.WIREFRAME || + if ( + rep === Representation.WIREFRAME || type === primTypes.Lines || type === primTypes.TrisEdges || - type === primTypes.TriStripsEdges) { + type === primTypes.TriStripsEdges + ) { return model.context.LINES; } return model.context.TRIANGLES; @@ -1335,7 +1636,6 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { // return; // } - publicAPI.invokeEvent(StartEvent); if (!model.renderable.getStatic()) { model.renderable.update(); @@ -1349,7 +1649,10 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { } // if there are no points then we are done - if (!model.currentInput.getPoints || !model.currentInput.getPoints().getNumberOfValues()) { + if ( + !model.currentInput.getPoints || + !model.currentInput.getPoints().getNumberOfValues() + ) { return; } @@ -1391,10 +1694,12 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { // first do a coarse check // Note that the actor's mtime includes it's properties mtime const vmtime = model.VBOBuildTime.getMTime(); - if (vmtime < publicAPI.getMTime() || - vmtime < model.renderable.getMTime() || - vmtime < actor.getMTime() || - vmtime < model.currentInput.getMTime()) { + if ( + vmtime < publicAPI.getMTime() || + vmtime < model.renderable.getMTime() || + vmtime < actor.getMTime() || + vmtime < model.currentInput.getMTime() + ) { return true; } return false; @@ -1414,25 +1719,28 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { const scalarMode = model.renderable.getScalarMode(); if (model.renderable.getScalarVisibility()) { // We must figure out how the scalars should be mapped to the polydata. - if ((scalarMode === ScalarMode.USE_CELL_DATA || - scalarMode === ScalarMode.USE_CELL_FIELD_DATA || - scalarMode === ScalarMode.USE_FIELD_DATA || - !poly.getPointData().getScalars()) - && scalarMode !== ScalarMode.USE_POINT_FIELD_DATA - && c) { + if ( + (scalarMode === ScalarMode.USE_CELL_DATA || + scalarMode === ScalarMode.USE_CELL_FIELD_DATA || + scalarMode === ScalarMode.USE_FIELD_DATA || + !poly.getPointData().getScalars()) && + scalarMode !== ScalarMode.USE_POINT_FIELD_DATA && + c + ) { model.haveCellScalars = true; } } // Do we have normals? - let n = (actor.getProperty().getInterpolation() !== Shading.FLAT) - ? poly.getPointData().getNormals() : null; + let n = + actor.getProperty().getInterpolation() !== Shading.FLAT + ? poly.getPointData().getNormals() + : null; if (n === null && poly.getCellData().getNormals()) { model.haveCellNormals = true; n = poly.getCellData().getNormals(); } - // rebuild the VBO if the data has changed we create a string for the VBO what // can change the VBO? points normals tcoords colors so what can change those? // the input data is clearly one as it can change all four items tcoords may @@ -1463,19 +1771,23 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { const input = model.renderable.getColorTextureMap(); const ext = input.getExtent(); const inScalars = input.getPointData().getScalars(); - tex.create2DFromRaw(ext[1] - ext[0] + 1, ext[3] - ext[2] + 1, + tex.create2DFromRaw( + ext[1] - ext[0] + 1, + ext[3] - ext[2] + 1, inScalars.getNumberOfComponents(), inScalars.getDataType(), - inScalars.getData()); + inScalars.getData() + ); tex.activate(); tex.sendParameters(); tex.deactivate(); } - const toString = `${poly.getMTime()}A${representation}B${poly.getMTime()}` - + `C${(n ? n.getMTime() : 1)}D${(c ? c.getMTime() : 1)}` - + `E${actor.getProperty().getEdgeVisibility()}` - + `F${(tcoords ? tcoords.getMTime() : 1)}`; + const toString = + `${poly.getMTime()}A${representation}B${poly.getMTime()}` + + `C${n ? n.getMTime() : 1}D${c ? c.getMTime() : 1}` + + `E${actor.getProperty().getEdgeVisibility()}` + + `F${tcoords ? tcoords.getMTime() : 1}`; if (model.VBOBuildString !== toString) { // Build the VBOs const points = poly.getPoints(); @@ -1488,24 +1800,28 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { haveCellScalars: model.haveCellScalars, haveCellNormals: model.haveCellNormals, }; - options.cellOffset += model.primitives[primTypes.Points].getCABO() + options.cellOffset += model.primitives[primTypes.Points] + .getCABO() .createVBO(poly.getVerts(), 'verts', representation, options); - options.cellOffset += model.primitives[primTypes.Lines].getCABO() + options.cellOffset += model.primitives[primTypes.Lines] + .getCABO() .createVBO(poly.getLines(), 'lines', representation, options); - options.cellOffset += model.primitives[primTypes.Tris].getCABO() + options.cellOffset += model.primitives[primTypes.Tris] + .getCABO() .createVBO(poly.getPolys(), 'polys', representation, options); - options.cellOffset += model.primitives[primTypes.TriStrips].getCABO() + options.cellOffset += model.primitives[primTypes.TriStrips] + .getCABO() .createVBO(poly.getStrips(), 'strips', representation, options); const drawSurfaceWithEdges = - (actor.getProperty().getEdgeVisibility() && - representation === Representation.SURFACE); + actor.getProperty().getEdgeVisibility() && + representation === Representation.SURFACE; // if we have edge visibility build the edge VBOs if (drawSurfaceWithEdges) { - model.primitives[primTypes.TrisEdges].getCABO() - .createVBO(poly.getPolys(), 'polys', Representation.WIREFRAME, - { + model.primitives[primTypes.TrisEdges] + .getCABO() + .createVBO(poly.getPolys(), 'polys', Representation.WIREFRAME, { points, normals: n, tcoords: null, @@ -1514,9 +1830,9 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { haveCellScalars: false, haveCellNormals: false, }); - model.primitives[primTypes.TriStripsEdges].getCABO() - .createVBO(poly.getStrips(), 'strips', Representation.WIREFRAME, - { + model.primitives[primTypes.TriStripsEdges] + .getCABO() + .createVBO(poly.getStrips(), 'strips', Representation.WIREFRAME, { points, normals: n, tcoords: null, @@ -1525,11 +1841,14 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { haveCellScalars: false, haveCellNormals: false, }); - } else { // otherwise free them - model.primitives[primTypes.TrisEdges] - .releaseGraphicsResources(model.openGLRenderWindow); - model.primitives[primTypes.TriStripsEdges] - .releaseGraphicsResources(model.openGLRenderWindow); + } else { + // otherwise free them + model.primitives[primTypes.TrisEdges].releaseGraphicsResources( + model.openGLRenderWindow + ); + model.primitives[primTypes.TriStripsEdges].releaseGraphicsResources( + model.openGLRenderWindow + ); } model.VBOBuildTime.modified(); @@ -1575,13 +1894,13 @@ export function extend(publicAPI, model, initialValues = {}) { model.primitives[i] = vtkHelper.newInstance(); model.primitives[i].setPrimitiveType(i); model.primitives[i].set( - { lastLightComplexity: 0, lastLightCount: 0, lastSelectionPass: -1 }, true); + { lastLightComplexity: 0, lastLightCount: 0, lastSelectionPass: -1 }, + true + ); } // Build VTK API - macro.setGet(publicAPI, model, [ - 'context', - ]); + macro.setGet(publicAPI, model, ['context']); model.VBOBuildTime = {}; macro.obj(model.VBOBuildTime, { mtime: 0 }); diff --git a/Sources/Rendering/OpenGL/PolyDataMapper/test/testAddShaderReplacements.js b/Sources/Rendering/OpenGL/PolyDataMapper/test/testAddShaderReplacements.js index dc6e5c8596b..9a0d7aa7643 100644 --- a/Sources/Rendering/OpenGL/PolyDataMapper/test/testAddShaderReplacements.js +++ b/Sources/Rendering/OpenGL/PolyDataMapper/test/testAddShaderReplacements.js @@ -1,12 +1,12 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkOBJReader from 'vtk.js/Sources/IO/Misc/OBJReader'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkOBJReader from 'vtk.js/Sources/IO/Misc/OBJReader'; import baseline from './testAddShaderReplacement.png'; @@ -16,7 +16,9 @@ test.onlyIfWebGL('Test Add Shader Replacements', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -28,7 +30,9 @@ test.onlyIfWebGL('Test Add Shader Replacements', (t) => { // ---------------------------------------------------------------------------- // Test code // ---------------------------------------------------------------------------- - const reader = gc.registerResource(vtkOBJReader.newInstance({ splitMode: 'usemtl' })); + const reader = gc.registerResource( + vtkOBJReader.newInstance({ splitMode: 'usemtl' }) + ); const mapper = gc.registerResource(vtkMapper.newInstance()); mapper.setInputConnection(reader.getOutputPort()); @@ -39,16 +43,21 @@ test.onlyIfWebGL('Test Add Shader Replacements', (t) => { ShaderReplacements: [], }; - mapperViewProp.addShaderReplacements = - (_shaderType, _originalValue, _replaceFirst, _replacementValue, _replaceAll) => { - mapperViewProp.OpenGL.ShaderReplacements.push({ - shaderType: _shaderType, - originalValue: _originalValue, - replaceFirst: _replaceFirst, - replacementValue: _replacementValue, - replaceAll: _replaceAll, - }); - }; + mapperViewProp.addShaderReplacements = ( + _shaderType, + _originalValue, + _replaceFirst, + _replacementValue, + _replaceAll + ) => { + mapperViewProp.OpenGL.ShaderReplacements.push({ + shaderType: _shaderType, + originalValue: _originalValue, + replaceFirst: _replaceFirst, + replacementValue: _replacementValue, + replaceAll: _replaceAll, + }); + }; const actor = gc.registerResource(vtkActor.newInstance()); actor.setMapper(mapper); @@ -62,55 +71,65 @@ test.onlyIfWebGL('Test Add Shader Replacements', (t) => { actor.getProperty().setOpacity(1.0); renderer.addActor(actor); - reader.setUrl(`${__BASE_PATH__}/Data/obj/space-shuttle-orbiter/space-shuttle-orbiter.obj`).then(() => { - mapperViewProp.addShaderReplacements( - 'Vertex', - '//VTK::Normal::Dec', - true, - '//VTK::Normal::Dec\n varying vec3 myNormalMCVSOutput;\n', - false, - ); - - mapperViewProp.addShaderReplacements( - 'Vertex', - '//VTK::Normal::Impl', - true, - '//VTK::Normal::Impl\n myNormalMCVSOutput = normalMC;\n', - false, - ); - - mapperViewProp.addShaderReplacements( - 'Fragment', - '//VTK::Normal::Dec', - true, - '//VTK::Normal::Dec\n varying vec3 myNormalMCVSOutput;\n', - false, - ); - - mapperViewProp.addShaderReplacements( - 'Fragment', - '//VTK::Normal::Impl', - true, - '//VTK::Normal::Impl\n diffuseColor = abs(myNormalMCVSOutput) / diffuse;\n', - false, - ); - - renderWindow.render(); - const camera = renderer.getActiveCamera(); - camera.setPosition(-755.42, 861.83, -1700.66); - camera.setFocalPoint(13.24, 31.25, -147.31); - camera.setViewUp(0.28, 0.89, 0.33); - renderer.resetCamera(); - camera.zoom(1.6); - renderWindow.render(); - - const glwindow = gc.registerResource(vtkOpenGLRenderWindow.newInstance()); - glwindow.setContainer(renderWindowContainer); - renderWindow.addView(glwindow); - glwindow.setSize(400, 400); - - const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/OpenGL/PolyDataMapper/testShaderReplacementsAdd', t, 1.5, gc.releaseResources); - }); + reader + .setUrl( + `${__BASE_PATH__}/Data/obj/space-shuttle-orbiter/space-shuttle-orbiter.obj` + ) + .then(() => { + mapperViewProp.addShaderReplacements( + 'Vertex', + '//VTK::Normal::Dec', + true, + '//VTK::Normal::Dec\n varying vec3 myNormalMCVSOutput;\n', + false + ); + + mapperViewProp.addShaderReplacements( + 'Vertex', + '//VTK::Normal::Impl', + true, + '//VTK::Normal::Impl\n myNormalMCVSOutput = normalMC;\n', + false + ); + + mapperViewProp.addShaderReplacements( + 'Fragment', + '//VTK::Normal::Dec', + true, + '//VTK::Normal::Dec\n varying vec3 myNormalMCVSOutput;\n', + false + ); + + mapperViewProp.addShaderReplacements( + 'Fragment', + '//VTK::Normal::Impl', + true, + '//VTK::Normal::Impl\n diffuseColor = abs(myNormalMCVSOutput) / diffuse;\n', + false + ); + + renderWindow.render(); + const camera = renderer.getActiveCamera(); + camera.setPosition(-755.42, 861.83, -1700.66); + camera.setFocalPoint(13.24, 31.25, -147.31); + camera.setViewUp(0.28, 0.89, 0.33); + renderer.resetCamera(); + camera.zoom(1.6); + renderWindow.render(); + + const glwindow = gc.registerResource(vtkOpenGLRenderWindow.newInstance()); + glwindow.setContainer(renderWindowContainer); + renderWindow.addView(glwindow); + glwindow.setSize(400, 400); + + const image = glwindow.captureImage(); + testUtils.compareImages( + image, + [baseline], + 'Rendering/OpenGL/PolyDataMapper/testShaderReplacementsAdd', + t, + 1.5, + gc.releaseResources + ); + }); }); - diff --git a/Sources/Rendering/OpenGL/PolyDataMapper/test/testClearShaderReplacements.js b/Sources/Rendering/OpenGL/PolyDataMapper/test/testClearShaderReplacements.js index b66ad2f023c..87a4480282e 100644 --- a/Sources/Rendering/OpenGL/PolyDataMapper/test/testClearShaderReplacements.js +++ b/Sources/Rendering/OpenGL/PolyDataMapper/test/testClearShaderReplacements.js @@ -1,12 +1,12 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkOBJReader from 'vtk.js/Sources/IO/Misc/OBJReader'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkOBJReader from 'vtk.js/Sources/IO/Misc/OBJReader'; import baseline from './testClearShaderReplacement.png'; @@ -16,7 +16,9 @@ test.onlyIfWebGL('Test Clear Shader Replacements', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -28,7 +30,9 @@ test.onlyIfWebGL('Test Clear Shader Replacements', (t) => { // ---------------------------------------------------------------------------- // Test code // ---------------------------------------------------------------------------- - const reader = gc.registerResource(vtkOBJReader.newInstance({ splitMode: 'usemtl' })); + const reader = gc.registerResource( + vtkOBJReader.newInstance({ splitMode: 'usemtl' }) + ); const mapper = gc.registerResource(vtkMapper.newInstance()); mapper.setInputConnection(reader.getOutputPort()); @@ -38,23 +42,28 @@ test.onlyIfWebGL('Test Clear Shader Replacements', (t) => { ShaderReplacements: [], }; - mapperViewProp.clearShaderReplacement = - (_shaderType, _originalValue, _replaceFirst) => { - const shaderReplacement = mapperViewProp.OpenGL.ShaderReplacements; - let indexToRemove = -1; - - for (let i = 0; i < shaderReplacement.length; i++) { - if (shaderReplacement[i].shaderType === _shaderType && - shaderReplacement[i].originalValue === _originalValue && - shaderReplacement[i].replaceFirst === _replaceFirst) { - indexToRemove = i; - break; - } + mapperViewProp.clearShaderReplacement = ( + _shaderType, + _originalValue, + _replaceFirst + ) => { + const shaderReplacement = mapperViewProp.OpenGL.ShaderReplacements; + let indexToRemove = -1; + + for (let i = 0; i < shaderReplacement.length; i++) { + if ( + shaderReplacement[i].shaderType === _shaderType && + shaderReplacement[i].originalValue === _originalValue && + shaderReplacement[i].replaceFirst === _replaceFirst + ) { + indexToRemove = i; + break; } - if (indexToRemove > -1) { - shaderReplacement.splice(indexToRemove, 1); - } - }; + } + if (indexToRemove > -1) { + shaderReplacement.splice(indexToRemove, 1); + } + }; const actor = gc.registerResource(vtkActor.newInstance()); actor.setMapper(mapper); @@ -68,37 +77,48 @@ test.onlyIfWebGL('Test Clear Shader Replacements', (t) => { actor.getProperty().setOpacity(1.0); renderer.addActor(actor); - reader.setUrl(`${__BASE_PATH__}/Data/obj/space-shuttle-orbiter/space-shuttle-orbiter.obj`).then(() => { - mapperViewProp.OpenGL.ShaderReplacements.push({ - shaderType: 'Vertex', - originalValue: '//VTK::Normal::Dec', - replaceFirst: true, - replacementValue: '//VTK::Normal::Dec\n varying vec3 myNormalMCVSOutput;\n', - replaceAll: false, + reader + .setUrl( + `${__BASE_PATH__}/Data/obj/space-shuttle-orbiter/space-shuttle-orbiter.obj` + ) + .then(() => { + mapperViewProp.OpenGL.ShaderReplacements.push({ + shaderType: 'Vertex', + originalValue: '//VTK::Normal::Dec', + replaceFirst: true, + replacementValue: + '//VTK::Normal::Dec\n varying vec3 myNormalMCVSOutput;\n', + replaceAll: false, + }); + + mapperViewProp.clearShaderReplacement( + 'Vertex', + '//VTK::Normal::Dec', + true + ); + + renderWindow.render(); + const camera = renderer.getActiveCamera(); + camera.setPosition(-755.42, 861.83, -1700.66); + camera.setFocalPoint(13.24, 31.25, -147.31); + camera.setViewUp(0.28, 0.89, 0.33); + renderer.resetCamera(); + camera.zoom(1.6); + renderWindow.render(); + + const glwindow = gc.registerResource(vtkOpenGLRenderWindow.newInstance()); + glwindow.setContainer(renderWindowContainer); + renderWindow.addView(glwindow); + glwindow.setSize(400, 400); + + const image = glwindow.captureImage(); + testUtils.compareImages( + image, + [baseline], + 'Rendering/OpenGL/PolyDataMapper/testShaderReplacementsClear', + t, + 1.5, + gc.releaseResources + ); }); - - mapperViewProp.clearShaderReplacement( - 'Vertex', - '//VTK::Normal::Dec', - true, - ); - - renderWindow.render(); - const camera = renderer.getActiveCamera(); - camera.setPosition(-755.42, 861.83, -1700.66); - camera.setFocalPoint(13.24, 31.25, -147.31); - camera.setViewUp(0.28, 0.89, 0.33); - renderer.resetCamera(); - camera.zoom(1.6); - renderWindow.render(); - - const glwindow = gc.registerResource(vtkOpenGLRenderWindow.newInstance()); - glwindow.setContainer(renderWindowContainer); - renderWindow.addView(glwindow); - glwindow.setSize(400, 400); - - const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/OpenGL/PolyDataMapper/testShaderReplacementsClear', t, 1.5, gc.releaseResources); - }); }); - diff --git a/Sources/Rendering/OpenGL/PolyDataMapper/test/testClippingPlanes.js b/Sources/Rendering/OpenGL/PolyDataMapper/test/testClippingPlanes.js index 8f36cb1f56c..bf45a3afb81 100644 --- a/Sources/Rendering/OpenGL/PolyDataMapper/test/testClippingPlanes.js +++ b/Sources/Rendering/OpenGL/PolyDataMapper/test/testClippingPlanes.js @@ -1,13 +1,13 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkPlane from 'vtk.js/Sources/Common/DataModel/Plane'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkPlane from 'vtk.js/Sources/Common/DataModel/Plane'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; import baseline from './testClippingPlanes.png'; @@ -17,7 +17,9 @@ test.onlyIfWebGL('Test Clipping planes', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -40,25 +42,32 @@ test.onlyIfWebGL('Test Clipping planes', (t) => { actorCube0.setMapper(mapperCube0); renderer.addActor(actorCube0); + const planeX = gc.registerResource( + vtkPlane.newInstance({ + origin: [2.0, 0.0, 0.0], + normal: [1.0, 0.0, 0.0], + }) + ); - const planeX = gc.registerResource(vtkPlane.newInstance({ - origin: [2.0, 0.0, 0.0], - normal: [1.0, 0.0, 0.0], - })); + const planeY = gc.registerResource( + vtkPlane.newInstance({ + origin: [2.0, 0.0, 0.0], + normal: [0.0, 1.0, 0.0], + }) + ); - const planeY = gc.registerResource(vtkPlane.newInstance({ - origin: [2.0, 0.0, 0.0], - normal: [0.0, 1.0, 0.0], - })); + const planeZ = gc.registerResource( + vtkPlane.newInstance({ + origin: [2.0, 0.0, 0.0], + normal: [0.0, 0.0, 1.0], + }) + ); - const planeZ = gc.registerResource(vtkPlane.newInstance({ - origin: [2.0, 0.0, 0.0], - normal: [0.0, 0.0, 1.0], - })); - - const cube1 = gc.registerResource(vtkCubeSource.newInstance({ - center: [2.0, 0.0, 0.0], - })); + const cube1 = gc.registerResource( + vtkCubeSource.newInstance({ + center: [2.0, 0.0, 0.0], + }) + ); const mapperCube1 = gc.registerResource(vtkMapper.newInstance()); mapperCube1.setInputConnection(cube1.getOutputPort()); mapperCube1.addClippingPlane(planeX); @@ -75,5 +84,12 @@ test.onlyIfWebGL('Test Clipping planes', (t) => { glwindow.setSize(400, 400); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'TestClippingPlanes', t, 2.5, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'TestClippingPlanes', + t, + 2.5, + gc.releaseResources + ); }); diff --git a/Sources/Rendering/OpenGL/PolyDataMapper/test/testInterpolateScalarsBeforeMapping.js b/Sources/Rendering/OpenGL/PolyDataMapper/test/testInterpolateScalarsBeforeMapping.js index 8fdee3c7d19..248de4fbd65 100644 --- a/Sources/Rendering/OpenGL/PolyDataMapper/test/testInterpolateScalarsBeforeMapping.js +++ b/Sources/Rendering/OpenGL/PolyDataMapper/test/testInterpolateScalarsBeforeMapping.js @@ -1,14 +1,14 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkLookupTable from 'vtk.js/Sources/Common/Core/LookupTable'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkLookupTable from 'vtk.js/Sources/Common/Core/LookupTable'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; import baseline from './testInterpolateScalarsBeforeMapping.png'; @@ -18,7 +18,9 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Mapping', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -59,13 +61,13 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Mapping', (t) => { for (let i = 0; i < res; i++) { for (let j = 0; j < res; j++) { - const idx = (i * res) + j; + const idx = i * res + j; points[idx * 3] = j; - points[(idx * 3) + 1] = i; - points[(idx * 3) + 2] = 0.0; + points[idx * 3 + 1] = i; + points[idx * 3 + 2] = 0.0; // set scalars to be -0.5 to 1.5 so we have above and below range // data. - scalars[idx] = -0.5 + (2.0 * j / (res - 1.0)); + scalars[idx] = -0.5 + 2.0 * j / (res - 1.0); // also add nan for some data if (i === 4) { scalars[idx] = NaN; @@ -73,9 +75,9 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Mapping', (t) => { } } - for (let i = 0; i < (res - 1); i++) { - for (let j = 0; j < (res - 1); j++) { - const idx = ((i * res) + j); + for (let i = 0; i < res - 1; i++) { + for (let j = 0; j < res - 1; j++) { + const idx = i * res + j; polys[cellLocation++] = 3; polys[cellLocation++] = idx; polys[cellLocation++] = idx + 1; @@ -87,7 +89,9 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Mapping', (t) => { } } - const da = gc.registerResource(vtkDataArray.newInstance({ numberOfComponents: 1, values: scalars })); + const da = gc.registerResource( + vtkDataArray.newInstance({ numberOfComponents: 1, values: scalars }) + ); pd.getPointData().setScalars(da); mapper.setInputData(pd); @@ -100,5 +104,12 @@ test.onlyIfWebGL('Test Interpolate Scalars Before Mapping', (t) => { glwindow.setSize(400, 400); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/OpenGL/PolyDataMapper/testInterpolateScalarsBeforeMapping', t, 1.5, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Rendering/OpenGL/PolyDataMapper/testInterpolateScalarsBeforeMapping', + t, + 1.5, + gc.releaseResources + ); }); diff --git a/Sources/Rendering/OpenGL/RenderWindow/index.js b/Sources/Rendering/OpenGL/RenderWindow/index.js index 0debfd18bce..7a0650c3faf 100644 --- a/Sources/Rendering/OpenGL/RenderWindow/index.js +++ b/Sources/Rendering/OpenGL/RenderWindow/index.js @@ -1,11 +1,11 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkForwardPass from 'vtk.js/Sources/Rendering/OpenGL/ForwardPass'; -import vtkOpenGLViewNodeFactory from 'vtk.js/Sources/Rendering/OpenGL/ViewNodeFactory'; -import vtkRenderPass from 'vtk.js/Sources/Rendering/SceneGraph/RenderPass'; -import vtkShaderCache from 'vtk.js/Sources/Rendering/OpenGL/ShaderCache'; -import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; -import vtkOpenGLTextureUnitManager from 'vtk.js/Sources/Rendering/OpenGL/TextureUnitManager'; -import { VtkDataTypes } from 'vtk.js/Sources/Common/Core/DataArray/Constants'; +import macro from 'vtk.js/Sources/macro'; +import vtkForwardPass from 'vtk.js/Sources/Rendering/OpenGL/ForwardPass'; +import vtkOpenGLViewNodeFactory from 'vtk.js/Sources/Rendering/OpenGL/ViewNodeFactory'; +import vtkRenderPass from 'vtk.js/Sources/Rendering/SceneGraph/RenderPass'; +import vtkShaderCache from 'vtk.js/Sources/Rendering/OpenGL/ShaderCache'; +import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; +import vtkOpenGLTextureUnitManager from 'vtk.js/Sources/Rendering/OpenGL/TextureUnitManager'; +import { VtkDataTypes } from 'vtk.js/Sources/Common/Core/DataArray/Constants'; const { vtkDebugMacro, vtkErrorMacro } = macro; @@ -60,8 +60,12 @@ function vtkOpenGLRenderWindow(publicAPI, model) { model.shaderCache.setContext(model.context); // initialize blending for transparency const gl = model.context; - gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, - gl.ONE, gl.ONE_MINUS_SRC_ALPHA); + gl.blendFuncSeparate( + gl.SRC_ALPHA, + gl.ONE_MINUS_SRC_ALPHA, + gl.ONE, + gl.ONE_MINUS_SRC_ALPHA + ); gl.enable(gl.BLEND); model.initialized = true; } @@ -95,10 +99,12 @@ function vtkOpenGLRenderWindow(publicAPI, model) { publicAPI.isInViewport = (x, y, viewport) => { const vCoords = viewport.getViewportByReference(); const size = model.size; - if ((vCoords[0] * size[0] <= x) && - (vCoords[2] * size[0] >= x) && - (vCoords[1] * size[1] <= y) && - (vCoords[3] * size[1] >= y)) { + if ( + vCoords[0] * size[0] <= x && + vCoords[2] * size[0] >= x && + vCoords[1] * size[1] <= y && + vCoords[3] * size[1] >= y + ) { return true; } return false; @@ -107,7 +113,10 @@ function vtkOpenGLRenderWindow(publicAPI, model) { publicAPI.getViewportSize = (viewport) => { const vCoords = viewport.getViewportByReference(); const size = model.size; - return [(vCoords[2] - vCoords[0]) * size[0], (vCoords[3] - vCoords[1]) * size[1]]; + return [ + (vCoords[2] - vCoords[0]) * size[0], + (vCoords[3] - vCoords[1]) * size[1], + ]; }; publicAPI.getViewportCenter = (viewport) => { @@ -115,11 +124,17 @@ function vtkOpenGLRenderWindow(publicAPI, model) { return [size[0] * 0.5, size[1] * 0.5]; }; - publicAPI.displayToNormalizedDisplay = (x, y, z) => - [x / model.size[0], y / model.size[1], z]; + publicAPI.displayToNormalizedDisplay = (x, y, z) => [ + x / model.size[0], + y / model.size[1], + z, + ]; - publicAPI.normalizedDisplayToDisplay = (x, y, z) => - [x * model.size[0], y * model.size[1], z]; + publicAPI.normalizedDisplayToDisplay = (x, y, z) => [ + x * model.size[0], + y * model.size[1], + z, + ]; publicAPI.worldToView = (x, y, z, renderer) => { const dims = publicAPI.getViewportSize(renderer); @@ -158,11 +173,13 @@ function vtkOpenGLRenderWindow(publicAPI, model) { return [x, y, z]; }; - publicAPI.normalizedViewportToViewport = (x, y, z) => - [x * (model.size[0] - 1.0), y * (model.size[1] - 1.0), z]; + publicAPI.normalizedViewportToViewport = (x, y, z) => [ + x * (model.size[0] - 1.0), + y * (model.size[1] - 1.0), + z, + ]; - publicAPI.displayToLocalDisplay = (x, y, z) => - [x, model.size[1] - y - 1, z]; + publicAPI.displayToLocalDisplay = (x, y, z) => [x, model.size[1] - y - 1, z]; publicAPI.viewportToNormalizedDisplay = (x, y, z, renderer) => { let vCoords = renderer.getViewportByReference(); @@ -175,19 +192,25 @@ function vtkOpenGLRenderWindow(publicAPI, model) { publicAPI.getPixelData = (x1, y1, x2, y2) => { const pixels = new Uint8Array((x2 - x1 + 1) * (y2 - y1 + 1) * 4); model.context.readPixels( - x1, y1, x2 - x1 + 1, y2 - y1 + 1, + x1, + y1, + x2 - x1 + 1, + y2 - y1 + 1, model.context.RGBA, model.context.UNSIGNED_BYTE, - pixels); + pixels + ); return pixels; }; publicAPI.get2DContext = () => model.canvas.getContext('2d'); - publicAPI.get3DContext = (options = { preserveDrawingBuffer: false, depth: true, alpha: true }) => { + publicAPI.get3DContext = ( + options = { preserveDrawingBuffer: false, depth: true, alpha: true } + ) => { let result = null; - const webgl2Supported = (typeof WebGL2RenderingContext !== 'undefined'); + const webgl2Supported = typeof WebGL2RenderingContext !== 'undefined'; model.webgl2 = false; if (model.defaultToWebgl2 && webgl2Supported) { result = model.canvas.getContext('webgl2'); // , options); @@ -197,8 +220,9 @@ function vtkOpenGLRenderWindow(publicAPI, model) { } } if (!result) { - result = model.canvas.getContext('webgl', options) - || model.canvas.getContext('experimental-webgl', options); + result = + model.canvas.getContext('webgl', options) || + model.canvas.getContext('experimental-webgl', options); } // Do we have webvr support @@ -215,12 +239,19 @@ function vtkOpenGLRenderWindow(publicAPI, model) { } // prevent default context lost handler - model.canvas.addEventListener('webglcontextlost', (event) => { - event.preventDefault(); - }, false); + model.canvas.addEventListener( + 'webglcontextlost', + (event) => { + event.preventDefault(); + }, + false + ); model.canvas.addEventListener( - 'webglcontextrestored', publicAPI.restoreContext, false); + 'webglcontextrestored', + publicAPI.restoreContext, + false + ); return result; }; @@ -254,7 +285,6 @@ function vtkOpenGLRenderWindow(publicAPI, model) { model.canvas.width = model.oldCanvasSize[0]; model.canvas.height = model.oldCanvasSize[1]; - const ren = model.renderable.getRenderers()[0]; ren.getActiveCamera().setProjectionMatrix(null); @@ -264,7 +294,9 @@ function vtkOpenGLRenderWindow(publicAPI, model) { publicAPI.vrRender = () => { model.renderable.getInteractor().updateGamepads(model.vrDisplay.displayId); - model.vrSceneFrame = model.vrDisplay.requestAnimationFrame(publicAPI.vrRender); + model.vrSceneFrame = model.vrDisplay.requestAnimationFrame( + publicAPI.vrRender + ); model.vrDisplay.getFrameData(model.vrFrameData); // get the first renderer @@ -272,17 +304,25 @@ function vtkOpenGLRenderWindow(publicAPI, model) { // do the left eye ren.setViewport(0, 0, 0.5, 1.0); - ren.getActiveCamera().computeViewParametersFromPhysicalMatrix( - model.vrFrameData.leftViewMatrix); - ren.getActiveCamera().setProjectionMatrix( - model.vrFrameData.leftProjectionMatrix); + ren + .getActiveCamera() + .computeViewParametersFromPhysicalMatrix( + model.vrFrameData.leftViewMatrix + ); + ren + .getActiveCamera() + .setProjectionMatrix(model.vrFrameData.leftProjectionMatrix); publicAPI.traverseAllPasses(); ren.setViewport(0.5, 0, 1.0, 1.0); - ren.getActiveCamera().computeViewParametersFromPhysicalMatrix( - model.vrFrameData.rightViewMatrix); - ren.getActiveCamera().setProjectionMatrix( - model.vrFrameData.rightProjectionMatrix); + ren + .getActiveCamera() + .computeViewParametersFromPhysicalMatrix( + model.vrFrameData.rightViewMatrix + ); + ren + .getActiveCamera() + .setProjectionMatrix(model.vrFrameData.rightProjectionMatrix); publicAPI.traverseAllPasses(); model.vrDisplay.submitFrame(); @@ -304,7 +344,9 @@ function vtkOpenGLRenderWindow(publicAPI, model) { const activeUnit = publicAPI.getTextureUnitManager().allocate(); if (activeUnit < 0) { - vtkErrorMacro('Hardware does not support the number of textures defined.'); + vtkErrorMacro( + 'Hardware does not support the number of textures defined.' + ); return; } @@ -334,9 +376,12 @@ function vtkOpenGLRenderWindow(publicAPI, model) { switch (vtktype) { case VtkDataTypes.UNSIGNED_CHAR: switch (numComps) { - case 1: return model.context.R8; - case 2: return model.context.RG8; - case 3: return model.context.RGB8; + case 1: + return model.context.R8; + case 2: + return model.context.RG8; + case 3: + return model.context.RGB8; case 4: default: return model.context.RGBA8; @@ -344,9 +389,12 @@ function vtkOpenGLRenderWindow(publicAPI, model) { default: case VtkDataTypes.FLOAT: switch (numComps) { - case 1: return model.context.R16F; - case 2: return model.context.RG16F; - case 3: return model.context.RGB16F; + case 1: + return model.context.R16F; + case 2: + return model.context.RG16F; + case 3: + return model.context.RGB16F; case 4: default: return model.context.RGBA16F; @@ -356,9 +404,12 @@ function vtkOpenGLRenderWindow(publicAPI, model) { // webgl1 only supports four types switch (numComps) { - case 1: return model.context.LUMINANCE; - case 2: return model.context.LUMINANCE_ALPHA; - case 3: return model.context.RGB; + case 1: + return model.context.LUMINANCE; + case 2: + return model.context.LUMINANCE_ALPHA; + case 3: + return model.context.RGB; case 4: default: return model.context.RGBA; @@ -475,11 +526,7 @@ export function extend(publicAPI, model, initialValues = {}) { } // Build VTK API - macro.get(publicAPI, model, [ - 'shaderCache', - 'textureUnitManager', - 'webgl2', - ]); + macro.get(publicAPI, model, ['shaderCache', 'textureUnitManager', 'webgl2']); macro.setGet(publicAPI, model, [ 'initialized', @@ -491,9 +538,7 @@ export function extend(publicAPI, model, initialValues = {}) { 'cursor', ]); - macro.setGetArray(publicAPI, model, [ - 'size', - ], 2); + macro.setGetArray(publicAPI, model, ['size'], 2); // Object methods vtkOpenGLRenderWindow(publicAPI, model); diff --git a/Sources/Rendering/OpenGL/Renderer/index.js b/Sources/Rendering/OpenGL/Renderer/index.js index 419e5a28475..bb6fe523df9 100644 --- a/Sources/Rendering/OpenGL/Renderer/index.js +++ b/Sources/Rendering/OpenGL/Renderer/index.js @@ -1,6 +1,6 @@ -import macro from 'vtk.js/Sources/macro'; -import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import macro from 'vtk.js/Sources/macro'; +import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; const { vtkDebugMacro } = macro; @@ -27,8 +27,7 @@ function vtkOpenGLRenderer(publicAPI, model) { publicAPI.updateLights(); publicAPI.prepareNodes(); publicAPI.addMissingNode(model.renderable.getActiveCamera()); - publicAPI.addMissingNodes( - model.renderable.getViewPropsWithNestedProps()); + publicAPI.addMissingNodes(model.renderable.getViewPropsWithNestedProps()); publicAPI.removeUnusedNodes(); } }; @@ -83,7 +82,11 @@ function vtkOpenGLRenderer(publicAPI, model) { publicAPI.getAspectRatio = () => { const size = model.parent.getSizeByReference(); const viewport = model.renderable.getViewportByReference(); - return size[0] * (viewport[2] - viewport[0]) / ((viewport[3] - viewport[1]) * size[1]); + return ( + size[0] * + (viewport[2] - viewport[0]) / + ((viewport[3] - viewport[1]) * size[1]) + ); }; publicAPI.getTiledSizeAndOrigin = () => { @@ -107,10 +110,10 @@ function vtkOpenGLRenderer(publicAPI, model) { let vpu2 = vtkMath.clampValue(vport[2] - tileViewPort[0], 0.0, 1.0); let vpv2 = vtkMath.clampValue(vport[3] - tileViewPort[1], 0.0, 1.0); // also watch for the upper right boundary of the tile - if (vpu2 > (tileViewPort[2] - tileViewPort[0])) { + if (vpu2 > tileViewPort[2] - tileViewPort[0]) { vpu2 = tileViewPort[2] - tileViewPort[0]; } - if (vpv2 > (tileViewPort[3] - tileViewPort[1])) { + if (vpv2 > tileViewPort[3] - tileViewPort[1]) { vpv2 = tileViewPort[3] - tileViewPort[1]; } const ndvp2 = model.parent.normalizedDisplayToDisplay(vpu2, vpv2); @@ -137,7 +140,12 @@ function vtkOpenGLRenderer(publicAPI, model) { if (!model.renderable.getTransparent()) { const background = model.renderable.getBackgroundByReference(); // renderable ensures that background has 4 entries. - model.context.clearColor(background[0], background[1], background[2], background[3]); + model.context.clearColor( + background[0], + background[1], + background[2], + background[3] + ); clearMask |= gl.COLOR_BUFFER_BIT; } @@ -199,9 +207,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.get(publicAPI, model, ['shaderCache']); - macro.setGet(publicAPI, model, [ - 'selector', - ]); + macro.setGet(publicAPI, model, ['selector']); // Object methods vtkOpenGLRenderer(publicAPI, model); diff --git a/Sources/Rendering/OpenGL/Shader/index.js b/Sources/Rendering/OpenGL/Shader/index.js index 56c47129480..09985e953c3 100644 --- a/Sources/Rendering/OpenGL/Shader/index.js +++ b/Sources/Rendering/OpenGL/Shader/index.js @@ -15,7 +15,11 @@ function vtkShader(publicAPI, model) { publicAPI.compile = () => { let stype = model.context.VERTEX_SHADER; - if (!model.source || !model.source.length || model.shaderType === 'Unknown') { + if ( + !model.source || + !model.source.length || + model.shaderType === 'Unknown' + ) { return false; } @@ -41,7 +45,10 @@ function vtkShader(publicAPI, model) { model.handle = model.context.createShader(stype); model.context.shaderSource(model.handle, model.source); model.context.compileShader(model.handle); - const isCompiled = model.context.getShaderParameter(model.handle, model.context.COMPILE_STATUS); + const isCompiled = model.context.getShaderParameter( + model.handle, + model.context.COMPILE_STATUS + ); if (!isCompiled) { const lastError = model.context.getShaderInfoLog(model.handle); vtkErrorMacro(`Error compiling shader '${model.source}': ${lastError}`); diff --git a/Sources/Rendering/OpenGL/ShaderCache/index.js b/Sources/Rendering/OpenGL/ShaderCache/index.js index 71c47b19332..f442fdf2e2a 100644 --- a/Sources/Rendering/OpenGL/ShaderCache/index.js +++ b/Sources/Rendering/OpenGL/ShaderCache/index.js @@ -1,14 +1,11 @@ import md5 from 'blueimp-md5'; -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkShaderProgram from 'vtk.js/Sources/Rendering/OpenGL/ShaderProgram'; // ---------------------------------------------------------------------------- -const SET_GET_FIELDS = [ - 'lastShaderBound', - 'context', -]; +const SET_GET_FIELDS = ['lastShaderBound', 'context']; // ---------------------------------------------------------------------------- // vtkShaderCache methods @@ -28,7 +25,8 @@ function vtkShaderCache(publicAPI, model) { model.context.getExtension('OES_standard_derivatives'); let nFSSource = FSSource; if (GSSource.length > 0) { - nFSSource = vtkShaderProgram.substitute(nFSSource, 'VSOut', 'GSOut').result; + nFSSource = vtkShaderProgram.substitute(nFSSource, 'VSOut', 'GSOut') + .result; } let fragDepthString = '\n'; @@ -36,19 +34,22 @@ function vtkShaderCache(publicAPI, model) { fragDepthString = '#extension GL_EXT_frag_depth : enable\n'; } - const gl2 = (model.context.getParameter(model.context.VERSION).indexOf('WebGL 2.0') !== -1); + const gl2 = + model.context.getParameter(model.context.VERSION).indexOf('WebGL 2.0') !== + -1; let version = '#version 100\n'; if (gl2) { - version = '#version 300 es\n' - + '#define attribute in\n' - + '#define textureCube texture\n' - + '#define texture2D texture\n'; + version = + '#version 300 es\n' + + '#define attribute in\n' + + '#define textureCube texture\n' + + '#define texture2D texture\n'; } nFSSource = vtkShaderProgram.substitute(nFSSource, '//VTK::System::Dec', [ `${version}\n`, - (gl2 ? '' : '#extension GL_OES_standard_derivatives : enable\n'), + gl2 ? '' : '#extension GL_OES_standard_derivatives : enable\n', fragDepthString, '#ifdef GL_FRAGMENT_PRECISION_HIGH', 'precision highp float;', @@ -59,44 +60,67 @@ function vtkShaderCache(publicAPI, model) { '#endif', ]).result; - let nVSSource = vtkShaderProgram.substitute(VSSource, '//VTK::System::Dec', [ - `${version}\n`, - '#ifdef GL_FRAGMENT_PRECISION_HIGH', - 'precision highp float;', - 'precision highp int;', - '#else', - 'precision mediump float;', - 'precision mediump int;', - '#endif', - ]).result; + let nVSSource = vtkShaderProgram.substitute( + VSSource, + '//VTK::System::Dec', + [ + `${version}\n`, + '#ifdef GL_FRAGMENT_PRECISION_HIGH', + 'precision highp float;', + 'precision highp int;', + '#else', + 'precision mediump float;', + 'precision mediump int;', + '#endif', + ] + ).result; if (gl2) { - nVSSource = - vtkShaderProgram.substitute(nVSSource, 'varying', 'out').result; - nFSSource = - vtkShaderProgram.substitute(nFSSource, 'varying', 'in').result; - nFSSource = - vtkShaderProgram.substitute(nFSSource, 'gl_FragData\\[0\\]', 'fragOutput0').result; - nFSSource = - vtkShaderProgram.substitute(nFSSource, '//VTK::Output::Dec', 'layout(location = 0) out vec4 fragOutput0;').result; + nVSSource = vtkShaderProgram.substitute(nVSSource, 'varying', 'out') + .result; + nFSSource = vtkShaderProgram.substitute(nFSSource, 'varying', 'in') + .result; + nFSSource = vtkShaderProgram.substitute( + nFSSource, + 'gl_FragData\\[0\\]', + 'fragOutput0' + ).result; + nFSSource = vtkShaderProgram.substitute( + nFSSource, + '//VTK::Output::Dec', + 'layout(location = 0) out vec4 fragOutput0;' + ).result; } // nFSSource = ShaderProgram.substitute(nFSSource, 'gl_FragData\\[0\\]', // 'gl_FragColor').result; - const nGSSource = vtkShaderProgram.substitute(GSSource, '//VTK::System::Dec', - version).result; + const nGSSource = vtkShaderProgram.substitute( + GSSource, + '//VTK::System::Dec', + version + ).result; return { VSSource: nVSSource, FSSource: nFSSource, GSSource: nGSSource }; }; // return NULL if there is an issue - publicAPI.readyShaderProgramArray = (vertexCode, fragmentCode, geometryCode) => { - const data = publicAPI.replaceShaderValues(vertexCode, fragmentCode, geometryCode); - - const shader = - publicAPI.getShaderProgram( - data.VSSource, data.FSSource, data.GSSource); + publicAPI.readyShaderProgramArray = ( + vertexCode, + fragmentCode, + geometryCode + ) => { + const data = publicAPI.replaceShaderValues( + vertexCode, + fragmentCode, + geometryCode + ); + + const shader = publicAPI.getShaderProgram( + data.VSSource, + data.FSSource, + data.GSSource + ); return publicAPI.readyShaderProgram(shader); }; @@ -156,8 +180,8 @@ function vtkShaderCache(publicAPI, model) { publicAPI.releaseCurrentShader(); Object.keys(model.shaderPrograms) - .map(key => model.shaderPrograms[key]) - .forEach(sp => sp.releaseGraphicsResources(win)); + .map((key) => model.shaderPrograms[key]) + .forEach((sp) => sp.releaseGraphicsResources(win)); }; publicAPI.releaseGraphicsResources = () => { diff --git a/Sources/Rendering/OpenGL/ShaderProgram/index.js b/Sources/Rendering/OpenGL/ShaderProgram/index.js index 19d5178e8fe..f0b91cde847 100644 --- a/Sources/Rendering/OpenGL/ShaderProgram/index.js +++ b/Sources/Rendering/OpenGL/ShaderProgram/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkShader from 'vtk.js/Sources/Rendering/OpenGL/Shader'; const { vtkErrorMacro } = macro; @@ -6,7 +6,7 @@ const { vtkErrorMacro } = macro; // perform in place string substitutions, indicate if a substitution was done // this is useful for building up shader strings which typically involve // lots of string substitutions. Return true if a substitution was done. -export function substitute(source, search, replace, all = true) { +function substitute(source, search, replace, all = true) { const replaceStr = Array.isArray(replace) ? replace.join('\n') : replace; let replaced = false; if (source.search(search) !== -1) { @@ -31,18 +31,24 @@ function vtkShaderProgram(publicAPI, model) { publicAPI.compileShader = () => { if (!model.vertexShader.compile()) { - vtkErrorMacro(model.vertexShader.getSource() - .split('\n') - .map((line, index) => `${index}: ${line}`) - .join('\n')); + vtkErrorMacro( + model.vertexShader + .getSource() + .split('\n') + .map((line, index) => `${index}: ${line}`) + .join('\n') + ); vtkErrorMacro(model.vertexShader.getError()); return 0; } if (!model.fragmentShader.compile()) { - vtkErrorMacro(model.fragmentShader.getSource() - .split('\n') - .map((line, index) => `${index}: ${line}`) - .join('\n')); + vtkErrorMacro( + model.fragmentShader + .getSource() + .split('\n') + .map((line, index) => `${index}: ${line}`) + .join('\n') + ); vtkErrorMacro(model.fragmentShader.getError()); return 0; } @@ -103,7 +109,8 @@ function vtkShaderProgram(publicAPI, model) { } if (model.handle === 0) { - model.error = 'Program has not been initialized, and/or does not have shaders.'; + model.error = + 'Program has not been initialized, and/or does not have shaders.'; return false; } @@ -111,7 +118,10 @@ function vtkShaderProgram(publicAPI, model) { model.uniformLocs = {}; model.context.linkProgram(model.handle); - const isCompiled = model.context.getProgramParameter(model.handle, model.context.LINK_STATUS); + const isCompiled = model.context.getProgramParameter( + model.handle, + model.context.LINK_STATUS + ); if (!isCompiled) { const lastError = model.context.getProgramInfoLog(model.handle); vtkErrorMacro(`Error linking shader ${lastError}`); @@ -390,11 +400,13 @@ function vtkShaderProgram(publicAPI, model) { // see if we have cached the result let loc = model.uniformLocs[name]; if (loc !== undefined) { - return (loc !== null); + return loc !== null; } if (!model.linked) { - vtkErrorMacro('attempt to find uniform when the shader program is not linked'); + vtkErrorMacro( + 'attempt to find uniform when the shader program is not linked' + ); return false; } @@ -420,7 +432,9 @@ function vtkShaderProgram(publicAPI, model) { } if (!model.linked) { - vtkErrorMacro('attempt to find uniform when the shader program is not linked'); + vtkErrorMacro( + 'attempt to find uniform when the shader program is not linked' + ); return false; } @@ -567,7 +581,7 @@ const DEFAULT_VALUES = { // ---------------------------------------------------------------------------- -export function extend(publicAPI, model, initialValues = {}) { +function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Instanciate internal objects @@ -582,9 +596,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.obj(publicAPI, model); - macro.get(publicAPI, model, [ - 'lastCameraMTime', - ]); + macro.get(publicAPI, model, ['lastCameraMTime']); macro.setGet(publicAPI, model, [ 'error', 'handle', @@ -603,7 +615,7 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkShaderProgram'); +const newInstance = macro.newInstance(extend, 'vtkShaderProgram'); // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/OpenGL/SphereMapper/index.js b/Sources/Rendering/OpenGL/SphereMapper/index.js index 8819dfb321a..23d8a5bfd5b 100644 --- a/Sources/Rendering/OpenGL/SphereMapper/index.js +++ b/Sources/Rendering/OpenGL/SphereMapper/index.js @@ -1,16 +1,16 @@ -import { mat4 } from 'gl-matrix'; -import { ObjectType } from 'vtk.js/Sources/Rendering/OpenGL/BufferObject/Constants'; +import { mat4 } from 'gl-matrix'; +import { ObjectType } from 'vtk.js/Sources/Rendering/OpenGL/BufferObject/Constants'; -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; -import vtkBufferObject from 'vtk.js/Sources/Rendering/OpenGL/BufferObject'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkBufferObject from 'vtk.js/Sources/Rendering/OpenGL/BufferObject'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; -import vtkShaderProgram from 'vtk.js/Sources/Rendering/OpenGL/ShaderProgram'; -import vtkOpenGLPolyDataMapper from 'vtk.js/Sources/Rendering/OpenGL/PolyDataMapper'; +import vtkShaderProgram from 'vtk.js/Sources/Rendering/OpenGL/ShaderProgram'; +import vtkOpenGLPolyDataMapper from 'vtk.js/Sources/Rendering/OpenGL/PolyDataMapper'; -import vtkSphereMapperVS from 'vtk.js/Sources/Rendering/OpenGL/glsl/vtkSphereMapperVS.glsl'; -import vtkPolyDataFS from 'vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyDataFS.glsl'; +import vtkSphereMapperVS from 'vtk.js/Sources/Rendering/OpenGL/glsl/vtkSphereMapperVS.glsl'; +import vtkPolyDataFS from 'vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyDataFS.glsl'; const { vtkErrorMacro } = macro; @@ -35,20 +35,22 @@ function vtkOpenGLSphereMapper(publicAPI, model) { let VSSource = shaders.Vertex; let FSSource = shaders.Fragment; - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::Camera::Dec', [ - 'uniform mat4 VCDCMatrix;\n', - 'uniform mat4 MCVCMatrix;']).result; + VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Camera::Dec', [ + 'uniform mat4 VCDCMatrix;\n', + 'uniform mat4 MCVCMatrix;', + ]).result; - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::PositionVC::Dec', [ - 'varying vec4 vertexVCVSOutput;']).result; + FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::PositionVC::Dec', [ + 'varying vec4 vertexVCVSOutput;', + ]).result; // we create vertexVC below, so turn off the default // implementation - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::PositionVC::Impl', [ - 'vec4 vertexVC = vertexVCVSOutput;\n']).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::PositionVC::Impl', + ['vec4 vertexVC = vertexVCVSOutput;\n'] + ).result; // for lights kit and positional the VCDC matrix is already defined // so don't redefine it @@ -57,8 +59,13 @@ function vtkOpenGLSphereMapper(publicAPI, model) { 'uniform int cameraParallel;\n', 'varying float radiusVCVSOutput;\n', 'varying vec3 centerVCVSOutput;\n', - 'uniform mat4 VCDCMatrix;\n']; - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Dec', replacement).result; + 'uniform mat4 VCDCMatrix;\n', + ]; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Normal::Dec', + replacement + ).result; let fragString = ''; if (model.context.getExtension('EXT_frag_depth')) { @@ -102,22 +109,23 @@ function vtkOpenGLSphereMapper(publicAPI, model) { ' vertexVC.xyz = normalVCVSOutput*radiusVCVSOutput + centerVCVSOutput;\n', ' }\n', // compute the pixel's depth - // ' normalVCVSOutput = vec3(0,0,1);\n' + // ' normalVCVSOutput = vec3(0,0,1);\n' ' vec4 pos = VCDCMatrix * vertexVC;\n', - fragString]).result; + fragString, + ]).result; // Strip out the normal line -- the normal is computed as part of the depth - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Impl', '').result; + FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Impl', '') + .result; if (model.renderDepth) { - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::ZBuffer::Impl', [ - 'float computedZ = (pos.z / pos.w + 1.0) / 2.0;', - 'float iz = floor(computedZ * 65535.0 + 0.1);', - 'float rf = floor(iz/256.0)/255.0;', - 'float gf = mod(iz,256.0)/255.0;', - 'gl_FragData[0] = vec4(rf, gf, 0.0, 1.0);', - ]).result; + FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ZBuffer::Impl', [ + 'float computedZ = (pos.z / pos.w + 1.0) / 2.0;', + 'float iz = floor(computedZ * 65535.0 + 0.1);', + 'float rf = floor(iz/256.0)/255.0;', + 'float gf = mod(iz,256.0)/255.0;', + 'gl_FragData[0] = vec4(rf, gf, 0.0, 1.0);', + ]).result; shaders.Fragment = FSSource; } @@ -128,18 +136,33 @@ function vtkOpenGLSphereMapper(publicAPI, model) { }; publicAPI.setMapperShaderParameters = (cellBO, ren, actor) => { - if (cellBO.getCABO().getElementCount() && (model.VBOBuildTime > cellBO.getAttributeUpdateTime().getMTime() || - cellBO.getShaderSourceTime().getMTime() > cellBO.getAttributeUpdateTime().getMTime()) && - cellBO.getProgram().isAttributeUsed('offsetMC')) { - if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO(), - 'offsetMC', 12, // 12:this->VBO->ColorOffset+sizeof(float) - cellBO.getCABO().getStride(), model.context.FLOAT, 2, false)) { - vtkErrorMacro('Error setting \'offsetMC\' in shader VAO.'); + if ( + cellBO.getCABO().getElementCount() && + (model.VBOBuildTime > cellBO.getAttributeUpdateTime().getMTime() || + cellBO.getShaderSourceTime().getMTime() > + cellBO.getAttributeUpdateTime().getMTime()) && + cellBO.getProgram().isAttributeUsed('offsetMC') + ) { + if ( + !cellBO.getVAO().addAttributeArray( + cellBO.getProgram(), + cellBO.getCABO(), + 'offsetMC', + 12, // 12:this->VBO->ColorOffset+sizeof(float) + cellBO.getCABO().getStride(), + model.context.FLOAT, + 2, + false + ) + ) { + vtkErrorMacro("Error setting 'offsetMC' in shader VAO."); } } if (cellBO.getProgram().isUniformUsed('invertedDepth')) { - cellBO.getProgram().setUniformf('invertedDepth', model.invert ? -1.0 : 1.0); + cellBO + .getProgram() + .setUniformf('invertedDepth', model.invert ? -1.0 : 1.0); } superClass.setMapperShaderParameters(cellBO, ren, actor); @@ -167,7 +190,9 @@ function vtkOpenGLSphereMapper(publicAPI, model) { } if (program.isUniformUsed('cameraParallel')) { - cellBO.getProgram().setUniformi('cameraParallel', cam.getParallelProjection()); + cellBO + .getProgram() + .setUniformi('cameraParallel', cam.getParallelProjection()); } }; @@ -193,8 +218,10 @@ function vtkOpenGLSphereMapper(publicAPI, model) { const pointSize = 5; // x,y,z,orientation1,orientation2 let scales = null; - if (model.renderable.getScaleArray() != null && - pointData.hasArray(model.renderable.getScaleArray())) { + if ( + model.renderable.getScaleArray() != null && + pointData.hasArray(model.renderable.getScaleArray()) + ) { scales = pointData.getArray(model.renderable.getScaleArray()).getData(); } @@ -278,7 +305,9 @@ function vtkOpenGLSphereMapper(publicAPI, model) { vbo.setElementCount(vboIdx / pointSize); vbo.upload(packedVBO, ObjectType.ARRAY_BUFFER); - if (c) { vbo.getColorBO().upload(packedUCVBO, ObjectType.ARRAY_BUFFER); } + if (c) { + vbo.getColorBO().upload(packedUCVBO, ObjectType.ARRAY_BUFFER); + } model.VBOBuildTime.modified(); }; @@ -288,8 +317,7 @@ function vtkOpenGLSphereMapper(publicAPI, model) { // Object factory // ---------------------------------------------------------------------------- -const DEFAULT_VALUES = { -}; +const DEFAULT_VALUES = {}; // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/OpenGL/SphereMapper/test/testSphere.js b/Sources/Rendering/OpenGL/SphereMapper/test/testSphere.js index e96d1197449..685ee6fe246 100644 --- a/Sources/Rendering/OpenGL/SphereMapper/test/testSphere.js +++ b/Sources/Rendering/OpenGL/SphereMapper/test/testSphere.js @@ -1,16 +1,16 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; -import vtkSphereMapper from 'vtk.js/Sources/Rendering/Core/SphereMapper'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; +import vtkSphereMapper from 'vtk.js/Sources/Rendering/Core/SphereMapper'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; -import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; +import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; +import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; import baseline from './testSphere.png'; @@ -20,7 +20,9 @@ test.onlyIfWebGL('Test SphereMapper', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -39,39 +41,43 @@ test.onlyIfWebGL('Test SphereMapper', (t) => { const actor = gc.registerResource(vtkActor.newInstance()); simpleFilter.setFormula({ - getArrays: inputDataSets => ({ - input: [ - { location: FieldDataTypes.COORDINATE }], // Require point coordinates as input - output: [ // Generate two output arrays: + getArrays: (inputDataSets) => ({ + input: [{ location: FieldDataTypes.COORDINATE }], // Require point coordinates as input + output: [ + // Generate two output arrays: { - location: FieldDataTypes.POINT, // This array will be point-data ... - name: 'pressure', // ... with the given name ... - dataType: 'Float32Array', // ... of this type ... - numberOfComponents: 1, // ... with this many components ... + location: FieldDataTypes.POINT, // This array will be point-data ... + name: 'pressure', // ... with the given name ... + dataType: 'Float32Array', // ... of this type ... + numberOfComponents: 1, // ... with this many components ... }, { location: FieldDataTypes.POINT, // This array will be field data ... - name: 'temperature', // ... with the given name ... - dataType: 'Float32Array', // ... of this type ... + name: 'temperature', // ... with the given name ... + dataType: 'Float32Array', // ... of this type ... attribute: AttributeTypes.SCALARS, // ... and will be marked as the default scalars. - numberOfComponents: 1, // ... with this many components ... + numberOfComponents: 1, // ... with this many components ... }, ], }), evaluate: (arraysIn, arraysOut) => { // Convert in the input arrays of vtkDataArrays into variables // referencing the underlying JavaScript typed-data arrays: - const [coords] = arraysIn.map(d => d.getData()); - const [press, temp] = arraysOut.map(d => d.getData()); + const [coords] = arraysIn.map((d) => d.getData()); + const [press, temp] = arraysOut.map((d) => d.getData()); // Since we are passed coords as a 3-component array, // loop over all the points and compute the point-data output: for (let i = 0, sz = coords.length / 3; i < sz; ++i) { - press[i] = (((coords[3 * i] - 0.5) * (coords[3 * i] - 0.5)) + ((coords[(3 * i) + 1] - 0.5) * (coords[(3 * i) + 1] - 0.5)) + 0.125) * 0.1; - temp[i] = coords[(3 * i) + 1]; + press[i] = + ((coords[3 * i] - 0.5) * (coords[3 * i] - 0.5) + + (coords[3 * i + 1] - 0.5) * (coords[3 * i + 1] - 0.5) + + 0.125) * + 0.1; + temp[i] = coords[3 * i + 1]; } // Mark the output vtkDataArray as modified - arraysOut.forEach(x => x.modified()); + arraysOut.forEach((x) => x.modified()); }, }); @@ -99,5 +105,12 @@ test.onlyIfWebGL('Test SphereMapper', (t) => { glwindow.setSize(400, 400); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/OpenGL/SphereMapper', t, 1, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Rendering/OpenGL/SphereMapper', + t, + 1, + gc.releaseResources + ); }); diff --git a/Sources/Rendering/OpenGL/StickMapper/index.js b/Sources/Rendering/OpenGL/StickMapper/index.js index d15898a9f7b..00c74e42471 100644 --- a/Sources/Rendering/OpenGL/StickMapper/index.js +++ b/Sources/Rendering/OpenGL/StickMapper/index.js @@ -1,14 +1,14 @@ -import { mat3, mat4 } from 'gl-matrix'; -import { ObjectType } from 'vtk.js/Sources/Rendering/OpenGL/BufferObject/Constants'; +import { mat3, mat4 } from 'gl-matrix'; +import { ObjectType } from 'vtk.js/Sources/Rendering/OpenGL/BufferObject/Constants'; -import * as macro from 'vtk.js/Sources/macro'; +import * as macro from 'vtk.js/Sources/macro'; -import vtkBufferObject from 'vtk.js/Sources/Rendering/OpenGL/BufferObject'; -import vtkStickMapperVS from 'vtk.js/Sources/Rendering/OpenGL/glsl/vtkStickMapperVS.glsl'; -import vtkPolyDataFS from 'vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyDataFS.glsl'; +import vtkBufferObject from 'vtk.js/Sources/Rendering/OpenGL/BufferObject'; +import vtkStickMapperVS from 'vtk.js/Sources/Rendering/OpenGL/glsl/vtkStickMapperVS.glsl'; +import vtkPolyDataFS from 'vtk.js/Sources/Rendering/OpenGL/glsl/vtkPolyDataFS.glsl'; -import vtkShaderProgram from 'vtk.js/Sources/Rendering/OpenGL/ShaderProgram'; -import vtkOpenGLPolyDataMapper from 'vtk.js/Sources/Rendering/OpenGL/PolyDataMapper'; +import vtkShaderProgram from 'vtk.js/Sources/Rendering/OpenGL/ShaderProgram'; +import vtkOpenGLPolyDataMapper from 'vtk.js/Sources/Rendering/OpenGL/PolyDataMapper'; const { vtkErrorMacro } = macro; @@ -33,20 +33,24 @@ function vtkOpenGLStickMapper(publicAPI, model) { let VSSource = shaders.Vertex; let FSSource = shaders.Fragment; - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::Camera::Dec', [ - 'uniform mat4 VCDCMatrix;\n', - 'uniform mat4 MCVCMatrix;']).result; + VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Camera::Dec', [ + 'uniform mat4 VCDCMatrix;\n', + 'uniform mat4 MCVCMatrix;', + ]).result; - FSSource = vtkShaderProgram.substitute(FSSource, + FSSource = vtkShaderProgram.substitute( + FSSource, '//VTK::PositionVC::Dec', - 'varying vec4 vertexVCVSOutput;').result; + 'varying vec4 vertexVCVSOutput;' + ).result; // we create vertexVC below, so turn off the default // implementation - FSSource = vtkShaderProgram.substitute(FSSource, + FSSource = vtkShaderProgram.substitute( + FSSource, '//VTK::PositionVC::Impl', - ' vec4 vertexVC = vertexVCVSOutput;\n').result; + ' vec4 vertexVC = vertexVCVSOutput;\n' + ).result; // for lights kit and positional the VCDC matrix is already defined // so don't redefine it @@ -56,8 +60,13 @@ function vtkOpenGLStickMapper(publicAPI, model) { 'varying vec3 orientVCVSOutput;\n', 'varying float lengthVCVSOutput;\n', 'varying vec3 centerVCVSOutput;\n', - 'uniform mat4 VCDCMatrix;\n']; - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Dec', replacement).result; + 'uniform mat4 VCDCMatrix;\n', + ]; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Normal::Dec', + replacement + ).result; let fragString = ''; if (model.context.getExtension('EXT_frag_depth')) { @@ -130,60 +139,75 @@ function vtkOpenGLStickMapper(publicAPI, model) { ' }\n', ' }\n', - // ' vec3 normalVC = vec3(0.0,0.0,1.0);\n' + // ' vec3 normalVC = vec3(0.0,0.0,1.0);\n' // compute the pixel's depth ' vec4 pos = VCDCMatrix * vertexVC;\n', - fragString]).result; + fragString, + ]).result; // Strip out the normal line -- the normal is computed as part of the depth - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Impl', '').result; + FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Impl', '') + .result; const selector = ren.getSelector(); const picking = false; // (ren.getRenderWindow().getIsPicking() || selector != null); fragString = ''; if (picking) { - if (!selector /* || - (this->LastSelectionState >= vtkHardwareSelector::ID_LOW24) */) { - VSSource = vtkShaderProgram.substitute(VSSource, - '//VTK::Picking::Dec', [ - 'attribute vec4 selectionId;\n', - 'varying vec4 selectionIdVSOutput;']).result; - VSSource = vtkShaderProgram.substitute(VSSource, + if ( + !selector /* || + (this->LastSelectionState >= vtkHardwareSelector::ID_LOW24) */ + ) { + VSSource = vtkShaderProgram.substitute( + VSSource, + '//VTK::Picking::Dec', + ['attribute vec4 selectionId;\n', 'varying vec4 selectionIdVSOutput;'] + ).result; + VSSource = vtkShaderProgram.substitute( + VSSource, '//VTK::Picking::Impl', - 'selectionIdVSOutput = selectionId;').result; - FSSource = vtkShaderProgram.substitute(FSSource, + 'selectionIdVSOutput = selectionId;' + ).result; + FSSource = vtkShaderProgram.substitute( + FSSource, '//VTK::Picking::Dec', - 'varying vec4 selectionIdVSOutput;').result; + 'varying vec4 selectionIdVSOutput;' + ).result; if (model.context.getExtension('EXT_frag_depth')) { - fragString = ' gl_FragData[0] = vec4(selectionIdVSOutput.rgb, 1.0);\n'; + fragString = + ' gl_FragData[0] = vec4(selectionIdVSOutput.rgb, 1.0);\n'; } - FSSource = vtkShaderProgram.substitute(FSSource, + FSSource = vtkShaderProgram.substitute( + FSSource, '//VTK::Picking::Impl', - fragString).result; + fragString + ).result; } else { - FSSource = vtkShaderProgram.substitute(FSSource, + FSSource = vtkShaderProgram.substitute( + FSSource, '//VTK::Picking::Dec', - 'uniform vec3 mapperIndex;').result; + 'uniform vec3 mapperIndex;' + ).result; if (model.context.getExtension('EXT_frag_depth')) { fragString = ' gl_FragData[0] = vec4(mapperIndex,1.0);\n'; } - FSSource = vtkShaderProgram.substitute(FSSource, + FSSource = vtkShaderProgram.substitute( + FSSource, '//VTK::Picking::Impl', - fragString).result; + fragString + ).result; } } if (model.renderDepth) { - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::ZBuffer::Impl', [ - 'float computedZ = (pos.z / pos.w + 1.0) / 2.0;', - 'float iz = floor(computedZ * 65535.0 + 0.1);', - 'float rf = floor(iz/256.0)/255.0;', - 'float gf = mod(iz,256.0)/255.0;', - 'gl_FragData[0] = vec4(rf, gf, 0.0, 1.0);', - ]).result; + FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ZBuffer::Impl', [ + 'float computedZ = (pos.z / pos.w + 1.0) / 2.0;', + 'float iz = floor(computedZ * 65535.0 + 0.1);', + 'float rf = floor(iz/256.0)/255.0;', + 'float gf = mod(iz,256.0)/255.0;', + 'gl_FragData[0] = vec4(rf, gf, 0.0, 1.0);', + ]).result; shaders.Fragment = FSSource; } @@ -194,52 +218,86 @@ function vtkOpenGLStickMapper(publicAPI, model) { }; publicAPI.setMapperShaderParameters = (cellBO, ren, actor) => { - if (cellBO.getCABO().getElementCount() && (model.VBOBuildTime > cellBO.getAttributeUpdateTime().getMTime() || - cellBO.getShaderSourceTime().getMTime() > cellBO.getAttributeUpdateTime().getMTime())) { + if ( + cellBO.getCABO().getElementCount() && + (model.VBOBuildTime > cellBO.getAttributeUpdateTime().getMTime() || + cellBO.getShaderSourceTime().getMTime() > + cellBO.getAttributeUpdateTime().getMTime()) + ) { const selector = ren.getSelector(); const picking = false; // (ren.getRenderWindow().getIsPicking() || selector !== null); if (cellBO.getProgram().isAttributeUsed('orientMC')) { - if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO(), - 'orientMC', - 12, // after X Y Z - cellBO.getCABO().getStride(), model.context.FLOAT, 3, - false)) { - vtkErrorMacro('Error setting \'orientMC\' in shader VAO.'); + if ( + !cellBO.getVAO().addAttributeArray( + cellBO.getProgram(), + cellBO.getCABO(), + 'orientMC', + 12, // after X Y Z + cellBO.getCABO().getStride(), + model.context.FLOAT, + 3, + false + ) + ) { + vtkErrorMacro("Error setting 'orientMC' in shader VAO."); } } if (cellBO.getProgram().isAttributeUsed('offsetMC')) { - if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), - cellBO.getCABO().getColorBO(), - 'offsetMC', - 0, - cellBO.getCABO().getColorBOStride(), - model.context.UNSIGNED_BYTE, - 3, true)) { - vtkErrorMacro('Error setting \'offsetMC\' in shader VAO.'); + if ( + !cellBO + .getVAO() + .addAttributeArray( + cellBO.getProgram(), + cellBO.getCABO().getColorBO(), + 'offsetMC', + 0, + cellBO.getCABO().getColorBOStride(), + model.context.UNSIGNED_BYTE, + 3, + true + ) + ) { + vtkErrorMacro("Error setting 'offsetMC' in shader VAO."); } } if (cellBO.getProgram().isAttributeUsed('radiusMC')) { - if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), + if ( + !cellBO.getVAO().addAttributeArray( + cellBO.getProgram(), cellBO.getCABO(), 'radiusMC', 24, // X Y Z OX OY OZ - cellBO.getCABO().getStride(), model.context.FLOAT, 1, - false)) { - vtkErrorMacro('Error setting \'radiusMC\' in shader VAO.'); + cellBO.getCABO().getStride(), + model.context.FLOAT, + 1, + false + ) + ) { + vtkErrorMacro("Error setting 'radiusMC' in shader VAO."); } } - if (picking && - (!selector /* || - (model.LastSelectionState >= vtkHardwareSelector::ID_LOW24) */) && - cellBO.getProgram().isAttributeUsed('selectionId')) { - if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO(), - 'selectionId', - cellBO.getCABO().getColorOffset(), - cellBO.getCABO().getColorBOStride(), - model.context.UNSIGNED_CHAR, - 4, true)) { - vtkErrorMacro('Error setting \'selectionId\' in shader VAO.'); + if ( + picking && + !selector /* || + (model.LastSelectionState >= vtkHardwareSelector::ID_LOW24) */ && + cellBO.getProgram().isAttributeUsed('selectionId') + ) { + if ( + !cellBO + .getVAO() + .addAttributeArray( + cellBO.getProgram(), + cellBO.getCABO(), + 'selectionId', + cellBO.getCABO().getColorOffset(), + cellBO.getCABO().getColorBOStride(), + model.context.UNSIGNED_CHAR, + 4, + true + ) + ) { + vtkErrorMacro("Error setting 'selectionId' in shader VAO."); } } else { cellBO.getVAO().removeAttributeArray('selectionId'); @@ -282,7 +340,9 @@ function vtkOpenGLStickMapper(publicAPI, model) { } if (program.isUniformUsed('cameraParallel')) { - cellBO.getProgram().setUniformi('cameraParallel', cam.getParallelProjection()); + cellBO + .getProgram() + .setUniformi('cameraParallel', cam.getParallelProjection()); } }; @@ -333,23 +393,30 @@ function vtkOpenGLStickMapper(publicAPI, model) { let scales = null; let orientationArray = null; - // - // Generate points and point data for sides - // - if (model.renderable.getScaleArray() != null && - pointData.hasArray(model.renderable.getScaleArray())) { + // + // Generate points and point data for sides + // + if ( + model.renderable.getScaleArray() != null && + pointData.hasArray(model.renderable.getScaleArray()) + ) { scales = pointData.getArray(model.renderable.getScaleArray()).getData(); } - if (model.renderable.getOrientationArray() != null && - pointData.hasArray(model.renderable.getOrientationArray())) { - orientationArray = pointData.getArray(model.renderable.getOrientationArray()).getData(); + if ( + model.renderable.getOrientationArray() != null && + pointData.hasArray(model.renderable.getOrientationArray()) + ) { + orientationArray = pointData + .getArray(model.renderable.getOrientationArray()) + .getData(); } else { - vtkErrorMacro(['Error setting orientationArray.\n', - 'You have to specify the stick orientation']); + vtkErrorMacro([ + 'Error setting orientationArray.\n', + 'You have to specify the stick orientation', + ]); } - // Vertices // 013 - 032 - 324 - 453 // @@ -371,11 +438,13 @@ function vtkOpenGLStickMapper(publicAPI, model) { // 4: 011 // 5: 111 + // prettier-ignore const verticesArray = [ 0, 1, 3, 0, 3, 2, 2, 3, 5, - 2, 5, 4]; + 2, 5, 4, + ]; let pointIdx = 0; let colorIdx = 0; @@ -387,7 +456,7 @@ function vtkOpenGLStickMapper(publicAPI, model) { let radius = model.renderable.getRadius(); if (scales) { length = scales[i * 2]; - radius = scales[(i * 2) + 1]; + radius = scales[i * 2 + 1]; } for (let j = 0; j < verticesArray.length; ++j) { @@ -402,8 +471,8 @@ function vtkOpenGLStickMapper(publicAPI, model) { packedVBO[vboIdx++] = radius; packedUCVBO[ucIdx++] = 255 * (verticesArray[j] % 2); - packedUCVBO[ucIdx++] = (verticesArray[j] >= 4 ? 255 : 0); - packedUCVBO[ucIdx++] = (verticesArray[j] >= 2 ? 255 : 0); + packedUCVBO[ucIdx++] = verticesArray[j] >= 4 ? 255 : 0; + packedUCVBO[ucIdx++] = verticesArray[j] >= 2 ? 255 : 0; packedUCVBO[ucIdx++] = 255; colorIdx = i * colorComponents; @@ -426,8 +495,7 @@ function vtkOpenGLStickMapper(publicAPI, model) { // Object factory // ---------------------------------------------------------------------------- -const DEFAULT_VALUES = { -}; +const DEFAULT_VALUES = {}; // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/OpenGL/StickMapper/test/testStick.js b/Sources/Rendering/OpenGL/StickMapper/test/testStick.js index d43abab19fc..e1752194caf 100644 --- a/Sources/Rendering/OpenGL/StickMapper/test/testStick.js +++ b/Sources/Rendering/OpenGL/StickMapper/test/testStick.js @@ -1,16 +1,16 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkStickMapper from 'vtk.js/Sources/Rendering/Core/StickMapper'; +import vtkPlaneSource from 'vtk.js/Sources/Filters/Sources/PlaneSource'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkStickMapper from 'vtk.js/Sources/Rendering/Core/StickMapper'; -import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; -import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; +import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; +import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; import baseline from './testStick.png'; @@ -20,7 +20,9 @@ test.onlyIfWebGL('Test StickMapper', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -39,51 +41,63 @@ test.onlyIfWebGL('Test StickMapper', (t) => { const actor = gc.registerResource(vtkActor.newInstance()); simpleFilter.setFormula({ - getArrays: inputDataSets => ({ - input: [ - { location: FieldDataTypes.COORDINATE }], // Require point coordinates as input - output: [ // Generate two output arrays: + getArrays: (inputDataSets) => ({ + input: [{ location: FieldDataTypes.COORDINATE }], // Require point coordinates as input + output: [ + // Generate two output arrays: { - location: FieldDataTypes.POINT, // This array will be point-data ... - name: 'orientation', // ... with the given name ... - dataType: 'Float32Array', // ... of this type ... - numberOfComponents: 3, // ... with this many components ... + location: FieldDataTypes.POINT, // This array will be point-data ... + name: 'orientation', // ... with the given name ... + dataType: 'Float32Array', // ... of this type ... + numberOfComponents: 3, // ... with this many components ... }, { location: FieldDataTypes.POINT, // This array will be field data ... - name: 'temperature', // ... with the given name ... - dataType: 'Float32Array', // ... of this type ... + name: 'temperature', // ... with the given name ... + dataType: 'Float32Array', // ... of this type ... attribute: AttributeTypes.SCALARS, // ... and will be marked as the default scalars. - numberOfComponents: 1, // ... with this many components ... + numberOfComponents: 1, // ... with this many components ... }, { location: FieldDataTypes.POINT, // This array will be field data ... - name: 'pressure', // ... with the given name ... - dataType: 'Float32Array', // ... of this type ... - numberOfComponents: 2, // ... with this many components ... + name: 'pressure', // ... with the given name ... + dataType: 'Float32Array', // ... of this type ... + numberOfComponents: 2, // ... with this many components ... }, ], }), evaluate: (arraysIn, arraysOut) => { // Convert in the input arrays of vtkDataArrays into variables // referencing the underlying JavaScript typed-data arrays: - const [coords] = arraysIn.map(d => d.getData()); - const [orient, temp, press] = arraysOut.map(d => d.getData()); + const [coords] = arraysIn.map((d) => d.getData()); + const [orient, temp, press] = arraysOut.map((d) => d.getData()); // Since we are passed coords as a 3-component array, // loop over all the points and compute the point-data output: for (let i = 0, sz = coords.length / 3; i < sz; ++i) { - orient[i * 3] = ((coords[3 * i] - 0.5) * (coords[3 * i] - 0.5)) + ((coords[(3 * i) + 1] - 0.5) * (coords[(3 * i) + 1] - 0.5)); - orient[(i * 3) + 1] = ((coords[3 * i] - 0.5) * (coords[3 * i] - 0.5)) + ((coords[(3 * i) + 1] - 0.5) * (coords[(3 * i) + 1] - 0.5)); - orient[(i * 3) + 2] = 1.0; - - temp[i] = coords[(3 * i) + 1]; - - press[(i * 2)] = ((((coords[3 * i]) * (coords[3 * i])) + ((coords[(3 * i) + 1]) * (coords[(3 * i) + 1]))) * 0.05) + 0.05; - press[(i * 2) + 1] = ((((coords[3 * i]) * (coords[3 * i])) + ((coords[(3 * i) + 1]) * (coords[(3 * i) + 1]))) * 0.01) + 0.01; + orient[i * 3] = + (coords[3 * i] - 0.5) * (coords[3 * i] - 0.5) + + (coords[3 * i + 1] - 0.5) * (coords[3 * i + 1] - 0.5); + orient[i * 3 + 1] = + (coords[3 * i] - 0.5) * (coords[3 * i] - 0.5) + + (coords[3 * i + 1] - 0.5) * (coords[3 * i + 1] - 0.5); + orient[i * 3 + 2] = 1.0; + + temp[i] = coords[3 * i + 1]; + + press[i * 2] = + (coords[3 * i] * coords[3 * i] + + coords[3 * i + 1] * coords[3 * i + 1]) * + 0.05 + + 0.05; + press[i * 2 + 1] = + (coords[3 * i] * coords[3 * i] + + coords[3 * i + 1] * coords[3 * i + 1]) * + 0.01 + + 0.01; } // Mark the output vtkDataArray as modified - arraysOut.forEach(x => x.modified()); + arraysOut.forEach((x) => x.modified()); }, }); @@ -115,5 +129,12 @@ test.onlyIfWebGL('Test StickMapper', (t) => { renderer.getActiveCamera().azimuth(10.0); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/OpenGL/StickMapper', t, 1, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Rendering/OpenGL/StickMapper', + t, + 1, + gc.releaseResources + ); }); diff --git a/Sources/Rendering/OpenGL/Texture/index.js b/Sources/Rendering/OpenGL/Texture/index.js index a5795e9a0e2..ca1b945029e 100644 --- a/Sources/Rendering/OpenGL/Texture/index.js +++ b/Sources/Rendering/OpenGL/Texture/index.js @@ -1,9 +1,9 @@ -import Constants from 'vtk.js/Sources/Rendering/OpenGL/Texture/Constants'; -import macro from 'vtk.js/Sources/macro'; +import Constants from 'vtk.js/Sources/Rendering/OpenGL/Texture/Constants'; +import macro from 'vtk.js/Sources/macro'; import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; -import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; -import { vec3 } from 'gl-matrix'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; +import { vec3 } from 'gl-matrix'; const { Wrap, Filter } = Constants; const { VtkDataTypes } = vtkDataArray; @@ -18,7 +18,9 @@ function vtkOpenGLTexture(publicAPI, model) { model.classHierarchy.push('vtkOpenGLTexture'); // Renders myself publicAPI.render = () => { - model.openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer'); + model.openGLRenderer = publicAPI.getFirstAncestorOfType( + 'vtkOpenGLRenderer' + ); // sync renderable properties model.openGLRenderWindow = model.openGLRenderer.getParent(); model.context = model.openGLRenderWindow.getContext(); @@ -43,8 +45,10 @@ function vtkOpenGLTexture(publicAPI, model) { model.renderable.setImage(null); } // create the texture if it is not done already - if (!model.handle || - model.renderable.getMTime() > model.textureBuildTime.getMTime()) { + if ( + !model.handle || + model.renderable.getMTime() > model.textureBuildTime.getMTime() + ) { // if we have an Image if (model.renderable.getImage() !== null) { if (model.renderable.getInterpolate()) { @@ -69,21 +73,39 @@ function vtkOpenGLTexture(publicAPI, model) { const data = []; for (let i = 0; i < 6; ++i) { const indata = model.renderable.getInputData(i); - const scalars = indata ? indata.getPointData().getScalars().getData() : null; + const scalars = indata + ? indata + .getPointData() + .getScalars() + .getData() + : null; if (scalars) { data.push(scalars); } } if (data.length === 6) { - publicAPI.createCubeFromRaw(ext[1] - ext[0] + 1, ext[3] - ext[2] + 1, - inScalars.getNumberOfComponents(), inScalars.getDataType(), data); + publicAPI.createCubeFromRaw( + ext[1] - ext[0] + 1, + ext[3] - ext[2] + 1, + inScalars.getNumberOfComponents(), + inScalars.getDataType(), + data + ); } else { - if (model.renderable.getInterpolate() && inScalars.getNumberOfComponents() === 4) { + if ( + model.renderable.getInterpolate() && + inScalars.getNumberOfComponents() === 4 + ) { model.generateMipmap = true; publicAPI.setMinificationFilter(Filter.LINEAR_MIPMAP_LINEAR); } - publicAPI.create2DFromRaw(ext[1] - ext[0] + 1, ext[3] - ext[2] + 1, - inScalars.getNumberOfComponents(), inScalars.getDataType(), inScalars.getData()); + publicAPI.create2DFromRaw( + ext[1] - ext[0] + 1, + ext[3] - ext[2] + 1, + inScalars.getNumberOfComponents(), + inScalars.getDataType(), + inScalars.getData() + ); } publicAPI.activate(); publicAPI.sendParameters(); @@ -125,15 +147,27 @@ function vtkOpenGLTexture(publicAPI, model) { // See: http://www.openmodel.context..org/wiki/Common_Mistakes#Creating_a_complete_texture // turn off mip map filter or set the base and max level correctly. here // both are done. - model.context.texParameteri(model.target, model.context.TEXTURE_MIN_FILTER, - publicAPI.getOpenGLFilterMode(model.minificationFilter)); - model.context.texParameteri(model.target, model.context.TEXTURE_MAG_FILTER, - publicAPI.getOpenGLFilterMode(model.magnificationFilter)); + model.context.texParameteri( + model.target, + model.context.TEXTURE_MIN_FILTER, + publicAPI.getOpenGLFilterMode(model.minificationFilter) + ); + model.context.texParameteri( + model.target, + model.context.TEXTURE_MAG_FILTER, + publicAPI.getOpenGLFilterMode(model.magnificationFilter) + ); - model.context.texParameteri(model.target, model.context.TEXTURE_WRAP_S, - publicAPI.getOpenGLWrapMode(model.wrapS)); - model.context.texParameteri(model.target, model.context.TEXTURE_WRAP_T, - publicAPI.getOpenGLWrapMode(model.wrapT)); + model.context.texParameteri( + model.target, + model.context.TEXTURE_WRAP_S, + publicAPI.getOpenGLWrapMode(model.wrapS) + ); + model.context.texParameteri( + model.target, + model.context.TEXTURE_WRAP_T, + publicAPI.getOpenGLWrapMode(model.wrapT) + ); model.context.bindTexture(model.target, null); } @@ -190,7 +224,10 @@ function vtkOpenGLTexture(publicAPI, model) { //---------------------------------------------------------------------------- publicAPI.bind = () => { model.context.bindTexture(model.target, model.handle); - if (model.autoParameters && (publicAPI.getMTime() > model.sendParametersTime.getMTime())) { + if ( + model.autoParameters && + publicAPI.getMTime() > model.sendParametersTime.getMTime() + ) { publicAPI.sendParameters(); } }; @@ -216,24 +253,35 @@ function vtkOpenGLTexture(publicAPI, model) { //---------------------------------------------------------------------------- publicAPI.sendParameters = () => { - model.context.texParameteri(model.target, model.context.TEXTURE_WRAP_S, - publicAPI.getOpenGLWrapMode(model.wrapS)); - model.context.texParameteri(model.target, model.context.TEXTURE_WRAP_T, - publicAPI.getOpenGLWrapMode(model.wrapT)); + model.context.texParameteri( + model.target, + model.context.TEXTURE_WRAP_S, + publicAPI.getOpenGLWrapMode(model.wrapS) + ); + model.context.texParameteri( + model.target, + model.context.TEXTURE_WRAP_T, + publicAPI.getOpenGLWrapMode(model.wrapT) + ); if (model.openGLRenderWindow.getWebgl2()) { - model.context.texParameteri(model.target, model.context.TEXTURE_WRAP_R, - publicAPI.getOpenGLWrapMode(model.wrapR)); + model.context.texParameteri( + model.target, + model.context.TEXTURE_WRAP_R, + publicAPI.getOpenGLWrapMode(model.wrapR) + ); } model.context.texParameteri( model.target, model.context.TEXTURE_MIN_FILTER, - publicAPI.getOpenGLFilterMode(model.minificationFilter)); + publicAPI.getOpenGLFilterMode(model.minificationFilter) + ); model.context.texParameteri( model.target, model.context.TEXTURE_MAG_FILTER, - publicAPI.getOpenGLFilterMode(model.magnificationFilter)); + publicAPI.getOpenGLFilterMode(model.magnificationFilter) + ); // model.context.texParameterf(model.target, model.context.TEXTURE_MIN_LOD, model.minLOD); // model.context.texParameterf(model.target, model.context.TEXTURE_MAX_LOD, model.maxLOD); @@ -249,11 +297,15 @@ function vtkOpenGLTexture(publicAPI, model) { return model.internalFormat; } - model.internalFormat = - publicAPI.getDefaultInternalFormat(vtktype, numComps); + model.internalFormat = publicAPI.getDefaultInternalFormat( + vtktype, + numComps + ); if (!model.internalFormat) { - vtkDebugMacro(`Unable to find suitable internal format for T=${vtktype} NC= ${numComps}`); + vtkDebugMacro( + `Unable to find suitable internal format for T=${vtktype} NC= ${numComps}` + ); } return model.internalFormat; @@ -265,24 +317,31 @@ function vtkOpenGLTexture(publicAPI, model) { // try default next result = model.openGLRenderWindow.getDefaultTextureInternalFormat( - vtktype, numComps, false); + vtktype, + numComps, + false + ); if (result) { return result; } // try floating point result = this.openGLRenderWindow.getDefaultTextureInternalFormat( - vtktype, numComps, true); + vtktype, + numComps, + true + ); if (!result) { vtkDebugMacro('Unsupported internal texture type!'); - vtkDebugMacro(`Unable to find suitable internal format for T=${vtktype} NC= ${numComps}`); + vtkDebugMacro( + `Unable to find suitable internal format for T=${vtktype} NC= ${numComps}` + ); } return result; }; - //---------------------------------------------------------------------------- publicAPI.setInternalFormat = (iFormat) => { if (iFormat !== model.context.InternalFormat) { @@ -377,8 +436,10 @@ function vtkOpenGLTexture(publicAPI, model) { case VtkDataTypes.FLOAT: case VtkDataTypes.VOID: // used for depth component textures. default: - if (model.context.getExtension('OES_texture_float') && - model.context.getExtension('OES_texture_float_linear')) { + if ( + model.context.getExtension('OES_texture_float') && + model.context.getExtension('OES_texture_float_linear') + ) { return model.context.FLOAT; } return model.context.UNSIGNED_BYTE; @@ -470,7 +531,10 @@ function vtkOpenGLTexture(publicAPI, model) { const pixData = []; // if the opengl data type is float // then the data array must be float - if (dataType !== VtkDataTypes.FLOAT && model.openGLDataType === model.context.FLOAT) { + if ( + dataType !== VtkDataTypes.FLOAT && + model.openGLDataType === model.context.FLOAT + ) { const pixCount = model.width * model.height * model.components; for (let idx = 0; idx < data.length; idx++) { const newArray = new Float32Array(pixCount); @@ -483,7 +547,10 @@ function vtkOpenGLTexture(publicAPI, model) { // if the opengl data type is ubyte // then the data array must be u8, we currently simply truncate the data - if (dataType !== VtkDataTypes.UNSIGNED_CHAR && model.openGLDataType === model.context.UNSIGNED_BYTE) { + if ( + dataType !== VtkDataTypes.UNSIGNED_CHAR && + model.openGLDataType === model.context.UNSIGNED_BYTE + ) { const pixCount = model.width * model.height * model.components; for (let idx = 0; idx < data.length; idx++) { const newArray = new Uint8Array(pixCount); @@ -510,7 +577,10 @@ function vtkOpenGLTexture(publicAPI, model) { const width = model.width; const height = model.height; const numComps = model.components; - if (data && (!vtkMath.isPowerOfTwo(width) || !vtkMath.isPowerOfTwo(height))) { + if ( + data && + (!vtkMath.isPowerOfTwo(width) || !vtkMath.isPowerOfTwo(height)) + ) { // Scale up the texture to the next highest power of two dimensions. const newWidth = vtkMath.nearestPowerOfTwo(width); const newHeight = vtkMath.nearestPowerOfTwo(height); @@ -554,10 +624,10 @@ function vtkOpenGLTexture(publicAPI, model) { ihi *= numComps; for (let c = 0; c < numComps; c++) { newArray[joff + ioff + c] = - (data[idx][jlow + ilow + c] * jmix1 * (1.0 - imix)) + - (data[idx][jlow + ihi + c] * jmix1 * imix) + - (data[idx][jhi + ilow + c] * jmix * (1.0 - imix)) + - (data[idx][jhi + ihi + c] * jmix * imix); + data[idx][jlow + ilow + c] * jmix1 * (1.0 - imix) + + data[idx][jlow + ihi + c] * jmix1 * imix + + data[idx][jhi + ilow + c] * jmix * (1.0 - imix) + + data[idx][jhi + ihi + c] * jmix * imix; } } } @@ -612,14 +682,16 @@ function vtkOpenGLTexture(publicAPI, model) { model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1); model.context.texImage2D( - model.target, - 0, - model.internalFormat, - model.width, model.height, - 0, - model.format, - model.openGLDataType, - scaledData[0]); + model.target, + 0, + model.internalFormat, + model.width, + model.height, + 0, + model.format, + model.openGLDataType, + scaledData[0] + ); if (model.generateMipmap) { model.context.generateMipmap(model.target); @@ -663,11 +735,13 @@ function vtkOpenGLTexture(publicAPI, model) { model.context.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, model.internalFormat, - model.width, model.height, + model.width, + model.height, 0, model.format, model.openGLDataType, - scaledData[i]); + scaledData[i] + ); } } @@ -702,14 +776,16 @@ function vtkOpenGLTexture(publicAPI, model) { model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1); model.context.texImage2D( - model.target, - 0, - model.internalFormat, - model.width, model.height, - 0, - model.format, - model.openGLDataType, - data); + model.target, + 0, + model.internalFormat, + model.width, + model.height, + 0, + model.format, + model.openGLDataType, + data + ); if (model.generateMipmap) { model.context.generateMipmap(model.target); @@ -746,23 +822,39 @@ function vtkOpenGLTexture(publicAPI, model) { model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1); // Scale up the texture to the next highest power of two dimensions (if needed) and flip y. - const needNearestPowerOfTwo = (!vtkMath.isPowerOfTwo(image.width) || !vtkMath.isPowerOfTwo(image.height)); + const needNearestPowerOfTwo = + !vtkMath.isPowerOfTwo(image.width) || !vtkMath.isPowerOfTwo(image.height); const canvas = document.createElement('canvas'); - canvas.width = needNearestPowerOfTwo ? vtkMath.nearestPowerOfTwo(image.width) : image.width; - canvas.height = needNearestPowerOfTwo ? vtkMath.nearestPowerOfTwo(image.height) : image.height; + canvas.width = needNearestPowerOfTwo + ? vtkMath.nearestPowerOfTwo(image.width) + : image.width; + canvas.height = needNearestPowerOfTwo + ? vtkMath.nearestPowerOfTwo(image.height) + : image.height; const ctx = canvas.getContext('2d'); ctx.translate(0, canvas.height); ctx.scale(1, -1); - ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height); + ctx.drawImage( + image, + 0, + 0, + image.width, + image.height, + 0, + 0, + canvas.width, + canvas.height + ); const safeImage = canvas; model.context.texImage2D( - model.target, - 0, - model.internalFormat, - model.format, - model.openGLDataType, - safeImage); + model.target, + 0, + model.internalFormat, + model.format, + model.openGLDataType, + safeImage + ); if (model.generateMipmap) { model.context.generateMipmap(model.target); @@ -773,7 +865,14 @@ function vtkOpenGLTexture(publicAPI, model) { }; //---------------------------------------------------------------------------- - publicAPI.create3DFromRaw = (width, height, depth, numComps, dataType, data) => { + publicAPI.create3DFromRaw = ( + width, + height, + depth, + numComps, + dataType, + data + ) => { // Now determine the texture parameters using the arguments. publicAPI.getOpenGLDataType(dataType); publicAPI.getInternalFormat(dataType, numComps); @@ -799,14 +898,17 @@ function vtkOpenGLTexture(publicAPI, model) { // model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1); model.context.texImage3D( - model.target, - 0, - model.internalFormat, - model.width, model.height, model.depth, - 0, - model.format, - model.openGLDataType, - data); + model.target, + 0, + model.internalFormat, + model.width, + model.height, + model.depth, + 0, + model.format, + model.openGLDataType, + data + ); if (model.generateMipmap) { model.context.generateMipmap(model.target); @@ -818,7 +920,13 @@ function vtkOpenGLTexture(publicAPI, model) { //---------------------------------------------------------------------------- // This method simulates a 3D texture using 2D - publicAPI.create3DOneComponentFromRaw = (width, height, depth, dataType, data) => { + publicAPI.create3DOneComponentFromRaw = ( + width, + height, + depth, + dataType, + data + ) => { const numPixelsIn = width * height * depth; // compute min and max values @@ -844,9 +952,11 @@ function vtkOpenGLTexture(publicAPI, model) { if (dataType === VtkDataTypes.UNSIGNED_CHAR) { model.volumeInfo.min = 0.0; model.volumeInfo.max = 255.0; - } else if (model.openGLRenderWindow.getWebgl2() || - (model.context.getExtension('OES_texture_float') && - model.context.getExtension('OES_texture_float_linear'))) { + } else if ( + model.openGLRenderWindow.getWebgl2() || + (model.context.getExtension('OES_texture_float') && + model.context.getExtension('OES_texture_float_linear')) + ) { dataTypeToUse = VtkDataTypes.FLOAT; volCopyData = (outArray, outIdx, inValue, smin, smax) => { outArray[outIdx] = (inValue - smin) / (smax - smin); @@ -858,10 +968,10 @@ function vtkOpenGLTexture(publicAPI, model) { volCopyData = (outArray, outIdx, inValue, smin, smax) => { let fval = (inValue - smin) / (smax - smin); const r = Math.floor(fval * 255.0); - fval = (fval * 255.0) - r; + fval = fval * 255.0 - r; outArray[outIdx] = r; const g = Math.floor(fval * 255.0); - fval = (fval * 255.0) - g; + fval = fval * 255.0 - g; outArray[outIdx + 1] = g; const b = Math.floor(fval * 255.0); outArray[outIdx + 2] = b; @@ -874,7 +984,14 @@ function vtkOpenGLTexture(publicAPI, model) { for (let i = 0; i < numPixelsIn; ++i) { newArray[i] = (data[i] - min) / (max - min); } - return publicAPI.create3DFromRaw(width, height, depth, 1, VtkDataTypes.FLOAT, newArray); + return publicAPI.create3DFromRaw( + width, + height, + depth, + 1, + VtkDataTypes.FLOAT, + newArray + ); } return publicAPI.create3DFromRaw(width, height, depth, 1, dataType, data); } @@ -895,7 +1012,9 @@ function vtkOpenGLTexture(publicAPI, model) { model.numberOfDimensions = 2; // have to pack this 3D texture into pot 2D texture - const maxTexDim = model.context.getParameter(model.context.MAX_TEXTURE_SIZE); + const maxTexDim = model.context.getParameter( + model.context.MAX_TEXTURE_SIZE + ); // compute estimate for XY subsample let xstride = 1; @@ -918,7 +1037,18 @@ function vtkOpenGLTexture(publicAPI, model) { publicAPI.bind(); // store the information, we will need it later - model.volumeInfo = { encodedScalars, min, max, width, height, depth, xreps, yreps, xstride, ystride }; + model.volumeInfo = { + encodedScalars, + min, + max, + width, + height, + depth, + xreps, + yreps, + xstride, + ystride, + }; // OK stuff the data into the 2d TEXTURE @@ -936,19 +1066,19 @@ function vtkOpenGLTexture(publicAPI, model) { let outIdx = 0; for (let yRep = 0; yRep < yreps; yRep++) { - const xrepsThisRow = Math.min(xreps, depth - (yRep * xreps)); - const outXContIncr = model.width - (xrepsThisRow * Math.floor(width / xstride)); + const xrepsThisRow = Math.min(xreps, depth - yRep * xreps); + const outXContIncr = + model.width - xrepsThisRow * Math.floor(width / xstride); for (let inY = 0; inY < height; inY += ystride) { for (let xRep = 0; xRep < xrepsThisRow; xRep++) { - const inOffset = (((yRep * xreps) + xRep) * width * height) - + (inY * width); + const inOffset = (yRep * xreps + xRep) * width * height + inY * width; for (let inX = 0; inX < width; inX += xstride) { // copy value volCopyData(newArray, outIdx, data[inOffset + inX], min, max); outIdx += numCompsToUse; } } - outIdx += (outXContIncr * numCompsToUse); + outIdx += outXContIncr * numCompsToUse; } } @@ -957,14 +1087,16 @@ function vtkOpenGLTexture(publicAPI, model) { model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1); model.context.texImage2D( - model.target, - 0, - model.internalFormat, - model.width, model.height, - 0, - model.format, - model.openGLDataType, - newArray); + model.target, + 0, + model.internalFormat, + model.width, + model.height, + 0, + model.format, + model.openGLDataType, + newArray + ); publicAPI.deactivate(); return true; @@ -988,10 +1120,12 @@ function vtkOpenGLTexture(publicAPI, model) { let outPtr = 0; const sliceSize = width * height; const grad = vec3.create(); - vec3.set(grad, + vec3.set( + grad, (data[inPtr + 1] - data[inPtr]) / spacing[0], (data[inPtr + width] - data[inPtr]) / spacing[1], - (data[inPtr + sliceSize] - data[inPtr]) / spacing[2]); + (data[inPtr + sliceSize] - data[inPtr]) / spacing[2] + ); let minMag = vec3.length(grad); let maxMag = -1.0; for (let z = 0; z < depth; ++z) { @@ -1009,10 +1143,12 @@ function vtkOpenGLTexture(publicAPI, model) { if (x === width - 1) { edge--; } - vec3.set(grad, + vec3.set( + grad, (data[edge + 1] - data[edge]) / spacing[0], (data[edge + width] - data[edge]) / spacing[1], - (data[edge + sliceSize] - data[edge]) / spacing[2]); + (data[edge + sliceSize] - data[edge]) / spacing[2] + ); const mag = vec3.length(grad); minMag = Math.min(mag, minMag); @@ -1037,16 +1173,21 @@ function vtkOpenGLTexture(publicAPI, model) { const newArray = new Uint8Array(numPixelsIn * 4); for (let p = 0; p < numPixelsIn; ++p) { const pp = p * 4; - newArray[outIdx++] = 127.5 + (127.5 * tmpArray[pp]); - newArray[outIdx++] = 127.5 + (127.5 * tmpArray[pp + 1]); - newArray[outIdx++] = 127.5 + (127.5 * tmpArray[pp + 2]); + newArray[outIdx++] = 127.5 + 127.5 * tmpArray[pp]; + newArray[outIdx++] = 127.5 + 127.5 * tmpArray[pp + 1]; + newArray[outIdx++] = 127.5 + 127.5 * tmpArray[pp + 2]; // we encode gradient magnitude using sqrt so that // we have nonlinear resolution - newArray[outIdx++] = 255.0 * - (Math.sqrt(tmpArray[pp + 3] / maxMag)); + newArray[outIdx++] = 255.0 * Math.sqrt(tmpArray[pp + 3] / maxMag); } - return publicAPI.create3DFromRaw(width, height, depth, 4, - VtkDataTypes.UNSIGNED_CHAR, newArray); + return publicAPI.create3DFromRaw( + width, + height, + depth, + 4, + VtkDataTypes.UNSIGNED_CHAR, + newArray + ); } // Now determine the texture parameters using the arguments. @@ -1064,7 +1205,6 @@ function vtkOpenGLTexture(publicAPI, model) { model.depth = 1; model.numberOfDimensions = 2; - // now store the computed values into the packed 2D // texture using the same packing as volumeInfo model.width = scalarTexture.getWidth(); @@ -1072,24 +1212,27 @@ function vtkOpenGLTexture(publicAPI, model) { const newArray = new Uint8Array(model.width * model.height * 4); for (let yRep = 0; yRep < vinfo.yreps; yRep++) { - const xrepsThisRow = Math.min(vinfo.xreps, depth - (yRep * vinfo.xreps)); - const outXContIncr = model.width - (xrepsThisRow * Math.floor(width / vinfo.xstride)); + const xrepsThisRow = Math.min(vinfo.xreps, depth - yRep * vinfo.xreps); + const outXContIncr = + model.width - xrepsThisRow * Math.floor(width / vinfo.xstride); for (let inY = 0; inY < height; inY += vinfo.ystride) { for (let xRep = 0; xRep < xrepsThisRow; xRep++) { - const inOffset = 4 * ((((yRep * vinfo.xreps) + xRep) * width * height) - + (inY * width)); + const inOffset = + 4 * ((yRep * vinfo.xreps + xRep) * width * height + inY * width); for (let inX = 0; inX < width; inX += vinfo.xstride) { // copy value - newArray[outIdx++] = 127.5 + (127.5 * tmpArray[inOffset + (inX * 4)]); - newArray[outIdx++] = 127.5 + (127.5 * tmpArray[inOffset + (inX * 4) + 1]); - newArray[outIdx++] = 127.5 + (127.5 * tmpArray[inOffset + (inX * 4) + 2]); + newArray[outIdx++] = 127.5 + 127.5 * tmpArray[inOffset + inX * 4]; + newArray[outIdx++] = + 127.5 + 127.5 * tmpArray[inOffset + inX * 4 + 1]; + newArray[outIdx++] = + 127.5 + 127.5 * tmpArray[inOffset + inX * 4 + 2]; // we encode gradient magnitude using sqrt so that // we have nonlinear resolution - newArray[outIdx++] = 255.0 * - (Math.sqrt(tmpArray[inOffset + (inX * 4) + 3] / maxMag)); + newArray[outIdx++] = + 255.0 * Math.sqrt(tmpArray[inOffset + inX * 4 + 3] / maxMag); } } - outIdx += (outXContIncr * 4); + outIdx += outXContIncr * 4; } } @@ -1102,14 +1245,16 @@ function vtkOpenGLTexture(publicAPI, model) { model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1); model.context.texImage2D( - model.target, - 0, - model.internalFormat, - model.width, model.height, - 0, - model.format, - model.openGLDataType, - newArray); + model.target, + 0, + model.internalFormat, + model.width, + model.height, + 0, + model.format, + model.openGLDataType, + newArray + ); publicAPI.deactivate(); return true; @@ -1183,10 +1328,7 @@ export function extend(publicAPI, model, initialValues = {}) { macro.obj(model.textureBuildTime, { mtime: 0 }); // Build VTK API - macro.set(publicAPI, model, [ - 'format', - 'openGLDataType', - ]); + macro.set(publicAPI, model, ['format', 'openGLDataType']); macro.setGet(publicAPI, model, [ 'keyMatrixTime', diff --git a/Sources/Rendering/OpenGL/Texture/test/testCreateCubeFromRawTexture.js b/Sources/Rendering/OpenGL/Texture/test/testCreateCubeFromRawTexture.js index 02963e7be7f..441726a288f 100644 --- a/Sources/Rendering/OpenGL/Texture/test/testCreateCubeFromRawTexture.js +++ b/Sources/Rendering/OpenGL/Texture/test/testCreateCubeFromRawTexture.js @@ -1,12 +1,12 @@ -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; -import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; +import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkTexture from 'vtk.js/Sources/Rendering/Core/Texture'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; +import vtkTexture from 'vtk.js/Sources/Rendering/Core/Texture'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; @@ -20,7 +20,9 @@ test.onlyIfWebGL('Test vtkOpenGLTexture Rendering', (t) => { function callBackfunction(loadedTextures) { // Create come control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // Create view @@ -37,7 +39,10 @@ test.onlyIfWebGL('Test vtkOpenGLTexture Rendering', (t) => { const texture = gc.registerResource(vtkTexture.newInstance()); for (let i = 0; i < 6; i++) { - const scalarName = loadedTextures[i].getPointData().getArrayByIndex(0).getName(); + const scalarName = loadedTextures[i] + .getPointData() + .getArrayByIndex(0) + .getName(); loadedTextures[i].getPointData().setActiveScalars(scalarName); texture.setInputData(loadedTextures[i], i); } @@ -46,8 +51,14 @@ test.onlyIfWebGL('Test vtkOpenGLTexture Rendering', (t) => { const scale = 500; const cube = gc.registerResource(vtkCubeSource.newInstance()); cube.setGenerate3DTextureCoordinates(true); - cube.setBounds(bounds[0] * scale, bounds[1] * scale, bounds[2] * scale, - bounds[3] * scale, bounds[4] * scale, bounds[5] * scale); + cube.setBounds( + bounds[0] * scale, + bounds[1] * scale, + bounds[2] * scale, + bounds[3] * scale, + bounds[4] * scale, + bounds[5] * scale + ); // Update shaders in order to map texture to a cube const mapper = gc.registerResource(vtkMapper.newInstance()); @@ -71,26 +82,41 @@ test.onlyIfWebGL('Test vtkOpenGLTexture Rendering', (t) => { glwindow.setSize(400, 400); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline], 'Rendering/OpenGL/Texture/', t, 0.5, gc.releaseResources); + testUtils.compareImages( + image, + [baseline], + 'Rendering/OpenGL/Texture/', + t, + 0.5, + gc.releaseResources + ); } // Recursive function to load texture one by one - function loadTexture(idTexture, texturePathList, textureImageList, endCallBack) { + function loadTexture( + idTexture, + texturePathList, + textureImageList, + endCallBack + ) { if (idTexture === texturePathList.length) { - if (endCallBack) { // check if endcallback exists + if (endCallBack) { + // check if endcallback exists endCallBack(textureImageList); } return; } - const reader = gc.registerResource(vtkHttpDataSetReader.newInstance({ fetchGzip: true })); + const reader = gc.registerResource( + vtkHttpDataSetReader.newInstance({ fetchGzip: true }) + ); reader.setUrl(texturePathList[idTexture]).then(() => { reader.loadData().then(() => { textureImageList.push(reader.getOutputData()); const nextID = idTexture + 1; loadTexture(nextID, texturePathList, textureImageList, endCallBack); - });// end loadData - });// end set url + }); // end loadData + }); // end set url } const path = `${__BASE_PATH__}/Data/skybox/mountains/`; diff --git a/Sources/Rendering/OpenGL/TextureUnitManager/index.js b/Sources/Rendering/OpenGL/TextureUnitManager/index.js index 0d73ac56675..a4b7a426a61 100644 --- a/Sources/Rendering/OpenGL/TextureUnitManager/index.js +++ b/Sources/Rendering/OpenGL/TextureUnitManager/index.js @@ -32,7 +32,9 @@ function vtkOpenGLTextureUnitManager(publicAPI, model) { } model.context = ctx; if (model.context) { - model.numberOfTextureUnits = ctx.getParameter(ctx.MAX_TEXTURE_IMAGE_UNITS); + model.numberOfTextureUnits = ctx.getParameter( + ctx.MAX_TEXTURE_IMAGE_UNITS + ); for (let i = 0; i < model.numberOfTextureUnits; ++i) { model.textureUnits[i] = false; } @@ -71,7 +73,7 @@ function vtkOpenGLTextureUnitManager(publicAPI, model) { // Description: // Tell if texture unit `textureUnitId' is already allocated. // \pre valid_id_range : textureUnitId>=0 && textureUnitIdGetNumberOfTextureUnits() - publicAPI.isAllocated = textureUnitId => model.textureUnits[textureUnitId]; + publicAPI.isAllocated = (textureUnitId) => model.textureUnits[textureUnitId]; // ---------------------------------------------------------------------------- // Description: @@ -103,13 +105,9 @@ export function extend(publicAPI, model, initialValues = {}) { model.textureUnits = []; // Build VTK API - macro.get(publicAPI, model, [ - 'numberOfTextureUnits', - ]); + macro.get(publicAPI, model, ['numberOfTextureUnits']); - macro.setGet(publicAPI, model, [ - 'context', - ]); + macro.setGet(publicAPI, model, ['context']); // Object methods vtkOpenGLTextureUnitManager(publicAPI, model); @@ -117,7 +115,10 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkOpenGLTextureUnitManager'); +export const newInstance = macro.newInstance( + extend, + 'vtkOpenGLTextureUnitManager' +); // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/OpenGL/VertexArrayObject/index.js b/Sources/Rendering/OpenGL/VertexArrayObject/index.js index cd8594ef375..5c056a7175e 100644 --- a/Sources/Rendering/OpenGL/VertexArrayObject/index.js +++ b/Sources/Rendering/OpenGL/VertexArrayObject/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import { ObjectType } from 'vtk.js/Sources/Rendering/OpenGL/BufferObject/Constants'; // ---------------------------------------------------------------------------- @@ -17,11 +17,15 @@ function vtkOpenGLVertexArrayObject(publicAPI, model) { publicAPI.initialize = () => { model.instancingExtension = null; if (!model.openGLRenderWindow.getWebgl2()) { - model.instancingExtension = model.context.getExtension('ANGLE_instanced_arrays'); + model.instancingExtension = model.context.getExtension( + 'ANGLE_instanced_arrays' + ); } - if (!model.forceEmulation && - model.openGLRenderWindow && - model.openGLRenderWindow.getWebgl2()) { + if ( + !model.forceEmulation && + model.openGLRenderWindow && + model.openGLRenderWindow.getWebgl2() + ) { model.extension = null; model.supported = true; model.handleVAO = model.context.createVertexArray(); @@ -40,8 +44,7 @@ function vtkOpenGLVertexArrayObject(publicAPI, model) { publicAPI.isReady = () => // We either probed and allocated a VAO, or are falling back as the current // hardware does not support VAOs. - (model.handleVAO !== 0 || model.supported === false); - + model.handleVAO !== 0 || model.supported === false; publicAPI.bind = () => { // Either simply bind the VAO, or emulate behavior by binding all attributes. @@ -64,12 +67,20 @@ function vtkOpenGLVertexArrayObject(publicAPI, model) { const matrixCount = attrIt.isMatrix ? attrIt.size : 1; for (let i = 0; i < matrixCount; ++i) { gl.enableVertexAttribArray(attrIt.index + i); - gl.vertexAttribPointer(attrIt.index + i, attrIt.size, attrIt.type, - attrIt.normalize, attrIt.stride, - attrIt.offset + ((attrIt.stride * i) / attrIt.size)); + gl.vertexAttribPointer( + attrIt.index + i, + attrIt.size, + attrIt.type, + attrIt.normalize, + attrIt.stride, + attrIt.offset + attrIt.stride * i / attrIt.size + ); if (attrIt.divisor > 0) { if (model.instancingExtension) { - model.instancingExtension.vertexAttribDivisorANGLE(attrIt.index + i, 1); + model.instancingExtension.vertexAttribDivisorANGLE( + attrIt.index + i, + 1 + ); } else { gl.vertexAttribDivisor(attrIt.index + i, 1); } @@ -98,12 +109,20 @@ function vtkOpenGLVertexArrayObject(publicAPI, model) { const matrixCount = attrIt.isMatrix ? attrIt.size : 1; for (let i = 0; i < matrixCount; ++i) { gl.enableVertexAttribArray(attrIt.index + i); - gl.vertexAttribPointer(attrIt.index + i, attrIt.size, attrIt.type, - attrIt.normalize, attrIt.stride, - attrIt.offset + ((attrIt.stride * i) / attrIt.size)); + gl.vertexAttribPointer( + attrIt.index + i, + attrIt.size, + attrIt.type, + attrIt.normalize, + attrIt.stride, + attrIt.offset + attrIt.stride * i / attrIt.size + ); if (attrIt.divisor > 0) { if (model.instancingExtension) { - model.instancingExtension.vertexAttribDivisorANGLE(attrIt.index + i, 0); + model.instancingExtension.vertexAttribDivisorANGLE( + attrIt.index + i, + 0 + ); } else { gl.vertexAttribDivisor(attrIt.index + i, 0); } @@ -142,17 +161,51 @@ function vtkOpenGLVertexArrayObject(publicAPI, model) { model.handleProgram = 0; }; - publicAPI.addAttributeArray = (program, buffer, name, offset, stride, elementType, elementTupleSize, normalize) => - publicAPI.addAttributeArrayWithDivisor(program, buffer, name, offset, stride, elementType, elementTupleSize, normalize, 0, false); - - publicAPI.addAttributeArrayWithDivisor = (program, buffer, name, offset, stride, elementType, elementTupleSize, normalize, divisor, isMatrix) => { + publicAPI.addAttributeArray = ( + program, + buffer, + name, + offset, + stride, + elementType, + elementTupleSize, + normalize + ) => + publicAPI.addAttributeArrayWithDivisor( + program, + buffer, + name, + offset, + stride, + elementType, + elementTupleSize, + normalize, + 0, + false + ); + + publicAPI.addAttributeArrayWithDivisor = ( + program, + buffer, + name, + offset, + stride, + elementType, + elementTupleSize, + normalize, + divisor, + isMatrix + ) => { if (!program) { return false; } // Check the program is bound, and the buffer is valid. - if (!program.isBound() || buffer.getHandle() === 0 || - buffer.getType() !== ObjectType.ARRAY_BUFFER) { + if ( + !program.isBound() || + buffer.getHandle() === 0 || + buffer.getType() !== ObjectType.ARRAY_BUFFER + ) { return false; } @@ -188,10 +241,14 @@ function vtkOpenGLVertexArrayObject(publicAPI, model) { // up when we are emulating. buffer.bind(); gl.enableVertexAttribArray(attribs.index); - gl.vertexAttribPointer(attribs.index, attribs.size, attribs.type, - attribs.normalize, attribs.stride, - attribs.offset); - + gl.vertexAttribPointer( + attribs.index, + attribs.size, + attribs.type, + attribs.normalize, + attribs.stride, + attribs.offset + ); if (divisor > 0) { if (model.instancingExtension) { @@ -231,11 +288,30 @@ function vtkOpenGLVertexArrayObject(publicAPI, model) { return true; }; - publicAPI.addAttributeMatrixWithDivisor = (program, buffer, name, offset, stride, elementType, elementTupleSize, normalize, divisor) => { + publicAPI.addAttributeMatrixWithDivisor = ( + program, + buffer, + name, + offset, + stride, + elementType, + elementTupleSize, + normalize, + divisor + ) => { // bind the first row of values - const result = - publicAPI.addAttributeArrayWithDivisor(program, buffer, name, - offset, stride, elementType, elementTupleSize, normalize, divisor, true); + const result = publicAPI.addAttributeArrayWithDivisor( + program, + buffer, + name, + offset, + stride, + elementType, + elementTupleSize, + normalize, + divisor, + true + ); if (!result) { return result; @@ -247,9 +323,14 @@ function vtkOpenGLVertexArrayObject(publicAPI, model) { for (let i = 1; i < elementTupleSize; i++) { gl.enableVertexAttribArray(index + i); - gl.vertexAttribPointer(index + i, elementTupleSize, elementType, - normalize, stride, - offset + ((stride * i) / elementTupleSize)); + gl.vertexAttribPointer( + index + i, + elementTupleSize, + elementType, + normalize, + stride, + offset + stride * i / elementTupleSize + ); if (divisor > 0) { if (model.instancingExtension) { model.instancingExtension.vertexAttribDivisorANGLE(index + i, 1); @@ -339,7 +420,10 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkOpenGLVertexArrayObject'); +export const newInstance = macro.newInstance( + extend, + 'vtkOpenGLVertexArrayObject' +); // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/OpenGL/ViewNodeFactory/index.js b/Sources/Rendering/OpenGL/ViewNodeFactory/index.js index cb7fcc50795..d9a4ba043e4 100644 --- a/Sources/Rendering/OpenGL/ViewNodeFactory/index.js +++ b/Sources/Rendering/OpenGL/ViewNodeFactory/index.js @@ -1,21 +1,21 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkGenericWidgetRepresentation from 'vtk.js/Sources/Rendering/SceneGraph/GenericWidgetRepresentation'; -import vtkViewNodeFactory from 'vtk.js/Sources/Rendering/SceneGraph/ViewNodeFactory'; -import vtkOpenGLActor from 'vtk.js/Sources/Rendering/OpenGL/Actor'; -import vtkOpenGLActor2D from 'vtk.js/Sources/Rendering/OpenGL/Actor2D'; -import vtkOpenGLCamera from 'vtk.js/Sources/Rendering/OpenGL/Camera'; -import vtkOpenGLGlyph3DMapper from 'vtk.js/Sources/Rendering/OpenGL/Glyph3DMapper'; -import vtkOpenGLImageMapper from 'vtk.js/Sources/Rendering/OpenGL/ImageMapper'; -import vtkOpenGLImageSlice from 'vtk.js/Sources/Rendering/OpenGL/ImageSlice'; +import vtkViewNodeFactory from 'vtk.js/Sources/Rendering/SceneGraph/ViewNodeFactory'; +import vtkOpenGLActor from 'vtk.js/Sources/Rendering/OpenGL/Actor'; +import vtkOpenGLActor2D from 'vtk.js/Sources/Rendering/OpenGL/Actor2D'; +import vtkOpenGLCamera from 'vtk.js/Sources/Rendering/OpenGL/Camera'; +import vtkOpenGLGlyph3DMapper from 'vtk.js/Sources/Rendering/OpenGL/Glyph3DMapper'; +import vtkOpenGLImageMapper from 'vtk.js/Sources/Rendering/OpenGL/ImageMapper'; +import vtkOpenGLImageSlice from 'vtk.js/Sources/Rendering/OpenGL/ImageSlice'; import vtkOpenGLPixelSpaceCallbackMapper from 'vtk.js/Sources/Rendering/OpenGL/PixelSpaceCallbackMapper'; import vtkOpenGLPolyDataMapper from 'vtk.js/Sources/Rendering/OpenGL/PolyDataMapper'; -import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkOpenGLRenderer from 'vtk.js/Sources/Rendering/OpenGL/Renderer'; -import vtkOpenGLSphereMapper from 'vtk.js/Sources/Rendering/OpenGL/SphereMapper'; -import vtkOpenGLStickMapper from 'vtk.js/Sources/Rendering/OpenGL/StickMapper'; -import vtkOpenGLTexture from 'vtk.js/Sources/Rendering/OpenGL/Texture'; -import vtkOpenGLVolume from 'vtk.js/Sources/Rendering/OpenGL/Volume'; -import vtkOpenGLVolumeMapper from 'vtk.js/Sources/Rendering/OpenGL/VolumeMapper'; +import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; +import vtkOpenGLRenderer from 'vtk.js/Sources/Rendering/OpenGL/Renderer'; +import vtkOpenGLSphereMapper from 'vtk.js/Sources/Rendering/OpenGL/SphereMapper'; +import vtkOpenGLStickMapper from 'vtk.js/Sources/Rendering/OpenGL/StickMapper'; +import vtkOpenGLTexture from 'vtk.js/Sources/Rendering/OpenGL/Texture'; +import vtkOpenGLVolume from 'vtk.js/Sources/Rendering/OpenGL/Volume'; +import vtkOpenGLVolumeMapper from 'vtk.js/Sources/Rendering/OpenGL/VolumeMapper'; // ---------------------------------------------------------------------------- // vtkOpenGLViewNodeFactory methods @@ -30,8 +30,7 @@ function vtkOpenGLViewNodeFactory(publicAPI, model) { // Object factory // ---------------------------------------------------------------------------- -const DEFAULT_VALUES = { -}; +const DEFAULT_VALUES = {}; // ---------------------------------------------------------------------------- @@ -48,26 +47,52 @@ export function extend(publicAPI, model, initialValues = {}) { publicAPI.registerOverride('vtkActor', vtkOpenGLActor.newInstance); publicAPI.registerOverride('vtkActor2D', vtkOpenGLActor2D.newInstance); publicAPI.registerOverride('vtkCamera', vtkOpenGLCamera.newInstance); - publicAPI.registerOverride('vtkGlyph3DMapper', vtkOpenGLGlyph3DMapper.newInstance); - publicAPI.registerOverride('vtkImageMapper', vtkOpenGLImageMapper.newInstance); + publicAPI.registerOverride( + 'vtkGlyph3DMapper', + vtkOpenGLGlyph3DMapper.newInstance + ); + publicAPI.registerOverride( + 'vtkImageMapper', + vtkOpenGLImageMapper.newInstance + ); publicAPI.registerOverride('vtkImageSlice', vtkOpenGLImageSlice.newInstance); publicAPI.registerOverride('vtkMapper', vtkOpenGLPolyDataMapper.newInstance); - publicAPI.registerOverride('vtkPixelSpaceCallbackMapper', vtkOpenGLPixelSpaceCallbackMapper.newInstance); - publicAPI.registerOverride('vtkRenderWindow', vtkOpenGLRenderWindow.newInstance); + publicAPI.registerOverride( + 'vtkPixelSpaceCallbackMapper', + vtkOpenGLPixelSpaceCallbackMapper.newInstance + ); + publicAPI.registerOverride( + 'vtkRenderWindow', + vtkOpenGLRenderWindow.newInstance + ); publicAPI.registerOverride('vtkRenderer', vtkOpenGLRenderer.newInstance); - publicAPI.registerOverride('vtkSphereMapper', vtkOpenGLSphereMapper.newInstance); - publicAPI.registerOverride('vtkStickMapper', vtkOpenGLStickMapper.newInstance); + publicAPI.registerOverride( + 'vtkSphereMapper', + vtkOpenGLSphereMapper.newInstance + ); + publicAPI.registerOverride( + 'vtkStickMapper', + vtkOpenGLStickMapper.newInstance + ); publicAPI.registerOverride('vtkTexture', vtkOpenGLTexture.newInstance); publicAPI.registerOverride('vtkVolume', vtkOpenGLVolume.newInstance); - publicAPI.registerOverride('vtkVolumeMapper', vtkOpenGLVolumeMapper.newInstance); - publicAPI.registerOverride('vtkWidgetRepresentation', vtkGenericWidgetRepresentation.newInstance); + publicAPI.registerOverride( + 'vtkVolumeMapper', + vtkOpenGLVolumeMapper.newInstance + ); + publicAPI.registerOverride( + 'vtkWidgetRepresentation', + vtkGenericWidgetRepresentation.newInstance + ); } // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkOpenGLViewNodeFactory'); +export const newInstance = macro.newInstance( + extend, + 'vtkOpenGLViewNodeFactory' +); // ---------------------------------------------------------------------------- export default { newInstance, extend }; - diff --git a/Sources/Rendering/OpenGL/Volume/index.js b/Sources/Rendering/OpenGL/Volume/index.js index 2f1986f8e38..354974e4672 100644 --- a/Sources/Rendering/OpenGL/Volume/index.js +++ b/Sources/Rendering/OpenGL/Volume/index.js @@ -1,6 +1,6 @@ import { mat3, mat4 } from 'gl-matrix'; -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; // ---------------------------------------------------------------------------- @@ -25,8 +25,7 @@ function vtkOpenGLVolume(publicAPI, model) { publicAPI.queryPass = (prepass, renderPass) => { if (prepass) { - if (!model.renderable || - !model.renderable.getVisibility()) { + if (!model.renderable || !model.renderable.getVisibility()) { return; } renderPass.incrementVolumeCount(); @@ -34,8 +33,7 @@ function vtkOpenGLVolume(publicAPI, model) { }; publicAPI.traverseVolumePass = (renderPass) => { - if (!model.renderable || - !model.renderable.getVisibility()) { + if (!model.renderable || !model.renderable.getVisibility()) { return; } @@ -52,7 +50,9 @@ function vtkOpenGLVolume(publicAPI, model) { return; } if (prepass) { - model.context = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderWindow').getContext(); + model.context = publicAPI + .getFirstAncestorOfType('vtkOpenGLRenderWindow') + .getContext(); model.context.depthMask(false); } else { model.context.depthMask(true); @@ -104,9 +104,7 @@ export function extend(publicAPI, model, initialValues = {}) { model.MCWCMatrix = mat4.create(); // Build VTK API - macro.setGet(publicAPI, model, [ - 'context', - ]); + macro.setGet(publicAPI, model, ['context']); // Object methods vtkOpenGLVolume(publicAPI, model); diff --git a/Sources/Rendering/OpenGL/VolumeMapper/index.js b/Sources/Rendering/OpenGL/VolumeMapper/index.js index cf1b325ca27..26384549062 100644 --- a/Sources/Rendering/OpenGL/VolumeMapper/index.js +++ b/Sources/Rendering/OpenGL/VolumeMapper/index.js @@ -1,17 +1,20 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import { vec3, mat3, mat4 } from 'gl-matrix'; // import vtkBoundingBox from 'vtk.js/Sources/Common/DataModel/BoundingBox'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import { VtkDataTypes } from 'vtk.js/Sources/Common/Core/DataArray/Constants'; -import vtkHelper from 'vtk.js/Sources/Rendering/OpenGL/Helper'; -import vtkMath from 'vtk.js/Sources/Common/Core/Math'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import { VtkDataTypes } from 'vtk.js/Sources/Common/Core/DataArray/Constants'; +import vtkHelper from 'vtk.js/Sources/Rendering/OpenGL/Helper'; +import vtkMath from 'vtk.js/Sources/Common/Core/Math'; import vtkOpenGLFramebuffer from 'vtk.js/Sources/Rendering/OpenGL/Framebuffer'; -import vtkOpenGLTexture from 'vtk.js/Sources/Rendering/OpenGL/Texture'; -import vtkShaderProgram from 'vtk.js/Sources/Rendering/OpenGL/ShaderProgram'; +import vtkOpenGLTexture from 'vtk.js/Sources/Rendering/OpenGL/Texture'; +import vtkShaderProgram from 'vtk.js/Sources/Rendering/OpenGL/ShaderProgram'; import vtkVertexArrayObject from 'vtk.js/Sources/Rendering/OpenGL/VertexArrayObject'; -import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; -import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants'; -import { Wrap, Filter } from 'vtk.js/Sources/Rendering/OpenGL/Texture/Constants'; +import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; +import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants'; +import { + Wrap, + Filter, +} from 'vtk.js/Sources/Rendering/OpenGL/Texture/Constants'; import { InterpolationType } from 'vtk.js/Sources/Rendering/Core/VolumeProperty/Constants'; import vtkVolumeVS from 'vtk.js/Sources/Rendering/OpenGL/glsl/vtkVolumeVS.glsl'; @@ -46,7 +49,9 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { // Renders myself publicAPI.volumePass = (prepass, renderPass) => { if (prepass) { - model.openGLRenderWindow = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderWindow'); + model.openGLRenderWindow = publicAPI.getFirstAncestorOfType( + 'vtkOpenGLRenderWindow' + ); model.context = model.openGLRenderWindow.getContext(); model.tris.setOpenGLRenderWindow(model.openGLRenderWindow); model.scalarTexture.setOpenGLRenderWindow(model.openGLRenderWindow); @@ -58,9 +63,13 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { model.openGLVolume = publicAPI.getFirstAncestorOfType('vtkOpenGLVolume'); const actor = model.openGLVolume.getRenderable(); - model.openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer'); + model.openGLRenderer = publicAPI.getFirstAncestorOfType( + 'vtkOpenGLRenderer' + ); const ren = model.openGLRenderer.getRenderable(); - model.openGLCamera = model.openGLRenderer.getViewNodeFor(ren.getActiveCamera()); + model.openGLCamera = model.openGLRenderer.getViewNodeFor( + ren.getActiveCamera() + ); publicAPI.renderPiece(ren, actor); } }; @@ -92,65 +101,77 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { // for lighting and gradient opacity we need the // normal texture if (gopacity || model.lastLightComplexity > 0) { - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Normal::Dec', [ - 'uniform highp sampler3D normalTexture;', - ]).result; - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Normal::Impl', [ - 'vec4 normal = texture(normalTexture, ijk);', - ]).result; + FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Dec', [ + 'uniform highp sampler3D normalTexture;', + ]).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Normal::Impl', + ['vec4 normal = texture(normalTexture, ijk);'] + ).result; } - } else { // WebGL1 + } else { + // WebGL1 // compute the tcoords if (iType === InterpolationType.LINEAR) { - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::ComputeTCoords', [ + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::ComputeTCoords', + [ 'vec2 tpos = getTextureCoord(ijk, 0.0);', 'vec2 tpos2 = getTextureCoord(ijk, 1.0);', 'float zmix = ijk.z - floor(ijk.z);', - ]).result; + ] + ).result; } else { - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::ComputeTCoords', [ - 'vec2 tpos = getTextureCoord(ijk, 0.5);', - ]).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::ComputeTCoords', + ['vec2 tpos = getTextureCoord(ijk, 0.5);'] + ).result; } // compute the scalar value if (iType === InterpolationType.LINEAR) { - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::ScalarFunction', [ + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::ScalarFunction', + [ 'scalar = getScalarValue(tpos);', 'float scalar2 = getScalarValue(tpos2);', 'scalar = mix(scalar, scalar2, zmix);', - ]).result; + ] + ).result; } else { - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::ScalarFunction', [ - 'scalar = getScalarValue(tpos);', - ]).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::ScalarFunction', + ['scalar = getScalarValue(tpos);'] + ).result; } // for lighting and gradient opacity we need the // normal texture if (gopacity || model.lastLightComplexity > 0) { - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Normal::Dec', [ - 'uniform sampler2D normalTexture;', - ]).result; + FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Dec', [ + 'uniform sampler2D normalTexture;', + ]).result; if (iType === InterpolationType.LINEAR) { - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Normal::Impl', [ + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Normal::Impl', + [ 'vec4 normal = texture2D(normalTexture, tpos);', 'vec4 normal2 = texture2D(normalTexture, tpos2);', 'normal = mix(normal, normal2, zmix);', - ]).result; + ] + ).result; } else { - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::Normal::Impl', [ - 'vec4 normal = texture2D(normalTexture,tpos);', - ]).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Normal::Impl', + ['vec4 normal = texture2D(normalTexture,tpos);'] + ).result; } } @@ -158,15 +179,20 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { // rgb then add the right call to decode them // otherwise the generic texture lookup if (volInfo.encodedScalars) { - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::ScalarValueFunction::Impl', [ + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::ScalarValueFunction::Impl', + [ 'vec4 scalarComps = texture2D(texture1, tpos);', 'return scalarComps.r + scalarComps.g/255.0 + scalarComps.b/65025.0;', - ]).result; + ] + ).result; } else { - FSSource = vtkShaderProgram.substitute(FSSource, + FSSource = vtkShaderProgram.substitute( + FSSource, '//VTK::ScalarValueFunction::Impl', - 'return texture2D(texture1, tpos).r;').result; + 'return texture2D(texture1, tpos).r;' + ).result; } // WebGL only supports loops over constants @@ -179,49 +205,58 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { const ext = model.currentInput.getExtent(); const spc = model.currentInput.getSpacing(); const vsize = vec3.create(); - vec3.set(vsize, + vec3.set( + vsize, (ext[1] - ext[0]) * spc[0], (ext[3] - ext[2]) * spc[1], - (ext[5] - ext[4]) * spc[2]); - const maxSamples = vec3.length(vsize) / model.renderable.getSampleDistance(); + (ext[5] - ext[4]) * spc[2] + ); + const maxSamples = + vec3.length(vsize) / model.renderable.getSampleDistance(); - FSSource = vtkShaderProgram.substitute(FSSource, + FSSource = vtkShaderProgram.substitute( + FSSource, '//VTK::MaximumSamplesValue', - `${Math.ceil(maxSamples)}`).result; + `${Math.ceil(maxSamples)}` + ).result; } // if using gradient opacity apply that if (gopacity) { - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::GradientOpacity::Dec', [ + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::GradientOpacity::Dec', + [ 'uniform float goscale;', 'uniform float goshift;', 'uniform float gomin;', 'uniform float gomax;', - ]).result; - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::GradientOpacity::Impl', [ + ] + ).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::GradientOpacity::Impl', + [ 'tcolor.a = tcolor.a*clamp(normal.a*normal.a*goscale + goshift, gomin, gomax);', - ]).result; + ] + ).result; } // if we have a ztexture then declare it and use it if (model.zBufferTexture !== null) { - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::ZBuffer::Dec', [ - 'uniform sampler2D zBufferTexture;', - 'uniform float vpWidth;', - 'uniform float vpHeight;', - ]).result; - FSSource = vtkShaderProgram.substitute(FSSource, - '//VTK::ZBuffer::Impl', [ - 'vec4 depthVec = texture2D(zBufferTexture, vec2(gl_FragCoord.x / vpWidth, gl_FragCoord.y/vpHeight));', - 'float zdepth = (depthVec.r*256.0 + depthVec.g)/257.0;', - 'zdepth = zdepth * 2.0 - 1.0;', - 'zdepth = -2.0 * camFar * camNear / (zdepth*(camFar-camNear)-(camFar+camNear)) - camNear;', - 'zdepth = -zdepth/rayDir.z;', - 'tbounds.y = min(zdepth,tbounds.y);', - ]).result; + FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ZBuffer::Dec', [ + 'uniform sampler2D zBufferTexture;', + 'uniform float vpWidth;', + 'uniform float vpHeight;', + ]).result; + FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ZBuffer::Impl', [ + 'vec4 depthVec = texture2D(zBufferTexture, vec2(gl_FragCoord.x / vpWidth, gl_FragCoord.y/vpHeight));', + 'float zdepth = (depthVec.r*256.0 + depthVec.g)/257.0;', + 'zdepth = zdepth * 2.0 - 1.0;', + 'zdepth = -2.0 * camFar * camNear / (zdepth*(camFar-camNear)-(camFar+camNear)) - camNear;', + 'zdepth = -zdepth/rayDir.z;', + 'tbounds.y = min(zdepth,tbounds.y);', + ]).result; } shaders.Fragment = FSSource; @@ -240,16 +275,24 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { case 0: // no lighting, tcolor is fine as is break; - case 1: // headlight + case 1: // headlight case 2: // light kit - case 3: { // positional not implemented fallback to directional - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Light::Dec', [ - 'uniform float vSpecularPower;', - 'uniform float vAmbient;', - 'uniform float vDiffuse;', - 'uniform float vSpecular;', - '//VTK::Light::Dec'], false).result; - FSSource = vtkShaderProgram.substitute(FSSource, + case 3: { + // positional not implemented fallback to directional + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Light::Dec', + [ + 'uniform float vSpecularPower;', + 'uniform float vAmbient;', + 'uniform float vDiffuse;', + 'uniform float vSpecular;', + '//VTK::Light::Dec', + ], + false + ).result; + FSSource = vtkShaderProgram.substitute( + FSSource, '//VTK::Light::Impl', [ ' normal.rgb = 2.0*(normal.rgb - 0.5);', @@ -258,31 +301,41 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { ' //VTK::Light::Impl', ' tcolor.rgb = tcolor.rgb*(diffuse*vDiffuse + vAmbient) + specular*vSpecular;', ], - false, - ).result; + false + ).result; let lightNum = 0; ren.getLights().forEach((light) => { const status = light.getSwitch(); if (status > 0) { - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Light::Dec', [ - // intensity weighted color - `uniform vec3 lightColor${lightNum};`, - `uniform vec3 lightDirectionWC${lightNum}; // normalized`, - `uniform vec3 lightHalfAngleWC${lightNum}; // normalized`, - '//VTK::Light::Dec'], false).result; - FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Light::Impl', [ -// ` float df = max(0.0, dot(normal.rgb, -lightDirectionWC${lightNum}));`, - ` float df = abs(dot(normal.rgb, -lightDirectionWC${lightNum}));`, - ` diffuse += ((df${shadowFactor}) * lightColor${lightNum});`, - // ' if (df > 0.0)', - // ' {', -// ` float sf = pow( max(0.0, dot(lightHalfAngleWC${lightNum},normal.rgb)), specularPower);`, - ` float sf = pow( abs(dot(lightHalfAngleWC${lightNum},normal.rgb)), vSpecularPower);`, - ` specular += ((sf${shadowFactor}) * lightColor${lightNum});`, -// ' }', - ' //VTK::Light::Impl'], - false, - ).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Light::Dec', + [ + // intensity weighted color + `uniform vec3 lightColor${lightNum};`, + `uniform vec3 lightDirectionWC${lightNum}; // normalized`, + `uniform vec3 lightHalfAngleWC${lightNum}; // normalized`, + '//VTK::Light::Dec', + ], + false + ).result; + FSSource = vtkShaderProgram.substitute( + FSSource, + '//VTK::Light::Impl', + [ + // ` float df = max(0.0, dot(normal.rgb, -lightDirectionWC${lightNum}));`, + ` float df = abs(dot(normal.rgb, -lightDirectionWC${lightNum}));`, + ` diffuse += ((df${shadowFactor}) * lightColor${lightNum});`, + // ' if (df > 0.0)', + // ' {', + // ` float sf = pow( max(0.0, dot(lightHalfAngleWC${lightNum},normal.rgb)), specularPower);`, + ` float sf = pow( abs(dot(lightHalfAngleWC${lightNum},normal.rgb)), vSpecularPower);`, + ` specular += ((sf${shadowFactor}) * lightColor${lightNum});`, + // ' }', + ' //VTK::Light::Impl', + ], + false + ).result; lightNum++; } }); @@ -310,14 +363,15 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { } } - if (lightComplexity === 1 - && (model.numberOfLights > 1 - || light.getIntensity() !== 1.0 - || !light.lightTypeIsHeadLight())) { + if ( + lightComplexity === 1 && + (model.numberOfLights > 1 || + light.getIntensity() !== 1.0 || + !light.lightTypeIsHeadLight()) + ) { lightComplexity = 2; } - if (lightComplexity < 3 - && (light.getPositional())) { + if (lightComplexity < 3 && light.getPositional()) { lightComplexity = 3; } }); @@ -330,12 +384,14 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { } // has something changed that would require us to recreate the shader? - if (cellBO.getProgram() === 0 || - needRebuild || - model.lastZBufferTexture !== model.zBufferTexture || - cellBO.getShaderSourceTime().getMTime() < publicAPI.getMTime() || - cellBO.getShaderSourceTime().getMTime() < actor.getMTime() || - cellBO.getShaderSourceTime().getMTime() < model.currentInput.getMTime()) { + if ( + cellBO.getProgram() === 0 || + needRebuild || + model.lastZBufferTexture !== model.zBufferTexture || + cellBO.getShaderSourceTime().getMTime() < publicAPI.getMTime() || + cellBO.getShaderSourceTime().getMTime() < actor.getMTime() || + cellBO.getShaderSourceTime().getMTime() < model.currentInput.getMTime() + ) { model.lastZBufferTexture = model.zBufferTexture; return true; } @@ -353,8 +409,13 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { publicAPI.buildShaders(shaders, ren, actor); // compile and bind the program if needed - const newShader = - model.openGLRenderWindow.getShaderCache().readyShaderProgramArray(shaders.Vertex, shaders.Fragment, shaders.Geometry); + const newShader = model.openGLRenderWindow + .getShaderCache() + .readyShaderProgramArray( + shaders.Vertex, + shaders.Fragment, + shaders.Geometry + ); // if the shader changed reinitialize the VAO if (newShader !== cellBO.getProgram()) { @@ -365,7 +426,9 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { cellBO.getShaderSourceTime().modified(); } else { - model.openGLRenderWindow.getShaderCache().readyShaderProgram(cellBO.getProgram()); + model.openGLRenderWindow + .getShaderCache() + .readyShaderProgram(cellBO.getProgram()); } cellBO.getVAO().bind(); @@ -378,29 +441,43 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { // Now to update the VAO too, if necessary. const program = cellBO.getProgram(); - if (cellBO.getCABO().getElementCount() && - (model.VBOBuildTime.getMTime() > cellBO.getAttributeUpdateTime().getMTime() || - cellBO.getShaderSourceTime().getMTime() > cellBO.getAttributeUpdateTime().getMTime())) { + if ( + cellBO.getCABO().getElementCount() && + (model.VBOBuildTime.getMTime() > + cellBO.getAttributeUpdateTime().getMTime() || + cellBO.getShaderSourceTime().getMTime() > + cellBO.getAttributeUpdateTime().getMTime()) + ) { if (program.isAttributeUsed('vertexDC')) { - if (!cellBO.getVAO().addAttributeArray(program, cellBO.getCABO(), - 'vertexDC', cellBO.getCABO().getVertexOffset(), - cellBO.getCABO().getStride(), model.context.FLOAT, 3, - model.context.FALSE)) { + if ( + !cellBO + .getVAO() + .addAttributeArray( + program, + cellBO.getCABO(), + 'vertexDC', + cellBO.getCABO().getVertexOffset(), + cellBO.getCABO().getStride(), + model.context.FLOAT, + 3, + model.context.FALSE + ) + ) { vtkErrorMacro('Error setting vertexDC in shader VAO.'); } } cellBO.getAttributeUpdateTime().modified(); } - program.setUniformi('texture1', - model.scalarTexture.getTextureUnit()); - program.setUniformf('sampleDistance', - model.renderable.getSampleDistance()); + program.setUniformi('texture1', model.scalarTexture.getTextureUnit()); + program.setUniformf('sampleDistance', model.renderable.getSampleDistance()); // if we have a zbuffer texture then set it if (model.zBufferTexture !== null) { - program.setUniformi('zBufferTexture', - model.zBufferTexture.getTextureUnit()); + program.setUniformi( + 'zBufferTexture', + model.zBufferTexture.getTextureUnit() + ); const size = publicAPI.getRenderTargetSize(); program.setUniformf('vpWidth', size[0]); program.setUniformf('vpHeight', size[1]); @@ -432,9 +509,12 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { let dcymin = 1.0; let dcymax = -1.0; for (let i = 0; i < 8; ++i) { - vec3.set(pos, bounds[i % 2], - bounds[2 + (Math.floor(i / 2) % 2)], - bounds[4 + Math.floor(i / 4)]); + vec3.set( + pos, + bounds[i % 2], + bounds[2 + Math.floor(i / 2) % 2], + bounds[4 + Math.floor(i / 4)] + ); vec3.transformMat4(pos, pos, keyMats.wcvc); vec3.normalize(dir, pos); @@ -462,10 +542,12 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { const ext = model.currentInput.getExtent(); const spc = model.currentInput.getSpacing(); const vsize = vec3.create(); - vec3.set(vsize, + vec3.set( + vsize, (ext[1] - ext[0]) * spc[0], (ext[3] - ext[2]) * spc[1], - (ext[5] - ext[4]) * spc[2]); + (ext[5] - ext[4]) * spc[2] + ); program.setUniform3f('vSize', vsize[0], vsize[1], vsize[2]); vec3.set(pos, ext[0], ext[2], ext[4]); @@ -479,12 +561,18 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { mat4.multiply(model.idxToView, keyMats.wcvc, i2wmat4); mat3.copy(model.idxNormalMatrix, model.currentInput.getDirection()); - mat3.multiply(model.idxNormalMatrix, keyMats.normalMatrix, - model.idxNormalMatrix); - - const maxSamples = vec3.length(vsize) / model.renderable.getSampleDistance(); + mat3.multiply( + model.idxNormalMatrix, + keyMats.normalMatrix, + model.idxNormalMatrix + ); + + const maxSamples = + vec3.length(vsize) / model.renderable.getSampleDistance(); if (maxSamples > model.renderable.getMaximumSamplesPerRay()) { - vtkWarningMacro(`The number of steps required ${Math.ceil(maxSamples)} is larger than the + vtkWarningMacro(`The number of steps required ${Math.ceil( + maxSamples + )} is larger than the specified maximum number of steps ${model.renderable.getMaximumSamplesPerRay()}. Please either change the volumeMapper sampleDistance or its maximum number of samples.`); @@ -517,22 +605,28 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { for (let i = 0; i < 6; ++i) { switch (i) { default: - case 0: vec3.set(normal, 1.0, 0.0, 0.0); + case 0: + vec3.set(normal, 1.0, 0.0, 0.0); vec3.set(pos2, ext[1], ext[3], ext[5]); break; - case 1: vec3.set(normal, -1.0, 0.0, 0.0); + case 1: + vec3.set(normal, -1.0, 0.0, 0.0); vec3.set(pos2, ext[0], ext[2], ext[4]); break; - case 2: vec3.set(normal, 0.0, 1.0, 0.0); + case 2: + vec3.set(normal, 0.0, 1.0, 0.0); vec3.set(pos2, ext[1], ext[3], ext[5]); break; - case 3: vec3.set(normal, 0.0, -1.0, 0.0); + case 3: + vec3.set(normal, 0.0, -1.0, 0.0); vec3.set(pos2, ext[0], ext[2], ext[4]); break; - case 4: vec3.set(normal, 0.0, 0.0, 1.0); + case 4: + vec3.set(normal, 0.0, 0.0, 1.0); vec3.set(pos2, ext[1], ext[3], ext[5]); break; - case 5: vec3.set(normal, 0.0, 0.0, -1.0); + case 5: + vec3.set(normal, 0.0, 0.0, -1.0); vec3.set(pos2, ext[0], ext[2], ext[4]); break; } @@ -556,9 +650,10 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { case 0: // no lighting, tcolor is fine as is break; - case 1: // headlight + case 1: // headlight case 2: // light kit - case 3: { // positional not implemented fallback to directional + case 3: { + // positional not implemented fallback to directional let lightNum = 0; const camDOP = cam.getDirectionOfProjection(); const lightColor = []; @@ -576,7 +671,8 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { const halfAngle = [ -0.5 * (lightDir[0] + camDOP[0]), -0.5 * (lightDir[1] + camDOP[1]), - -0.5 * (lightDir[2] + camDOP[2])]; + -0.5 * (lightDir[2] + camDOP[2]), + ]; program.setUniform3fArray(`lightHalfAngleWC${lightNum}`, halfAngle); lightNum++; } @@ -588,12 +684,9 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { publicAPI.setPropertyShaderParameters = (cellBO, ren, actor) => { const program = cellBO.getProgram(); - program.setUniformi('ctexture', - model.colorTexture.getTextureUnit()); - program.setUniformi('otexture', - model.opacityTexture.getTextureUnit()); - program.setUniformi('jtexture', - model.jitterTexture.getTextureUnit()); + program.setUniformi('ctexture', model.colorTexture.getTextureUnit()); + program.setUniformi('otexture', model.opacityTexture.getTextureUnit()); + program.setUniformi('jtexture', model.jitterTexture.getTextureUnit()); const volInfo = model.scalarTexture.getVolumeInfo(); const sscale = volInfo.max - volInfo.min; @@ -601,12 +694,18 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { const vprop = actor.getProperty(); const ofun = vprop.getScalarOpacity(0); const oRange = ofun.getRange(); - program.setUniformf('oshift', (volInfo.min - oRange[0]) / (oRange[1] - oRange[0])); + program.setUniformf( + 'oshift', + (volInfo.min - oRange[0]) / (oRange[1] - oRange[0]) + ); program.setUniformf('oscale', sscale / (oRange[1] - oRange[0])); const cfun = vprop.getRGBTransferFunction(0); const cRange = cfun.getRange(); - program.setUniformf('cshift', (volInfo.min - cRange[0]) / (cRange[1] - cRange[0])); + program.setUniformf( + 'cshift', + (volInfo.min - cRange[0]) / (cRange[1] - cRange[0]) + ); program.setUniformf('cscale', sscale / (cRange[1] - cRange[0])); if (vprop.getUseGradientOpacity(0)) { @@ -617,15 +716,23 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { program.setUniformf('gomax', gomax); const goRange = [ vprop.getGradientOpacityMinimumValue(0), - vprop.getGradientOpacityMaximumValue(0)]; - program.setUniformf('goscale', lightingInfo.max * (gomax - gomin) / (goRange[1] - goRange[0])); - program.setUniformf('goshift', - (-goRange[0] * (gomax - gomin) / (goRange[1] - goRange[0])) + gomin); + vprop.getGradientOpacityMaximumValue(0), + ]; + program.setUniformf( + 'goscale', + lightingInfo.max * (gomax - gomin) / (goRange[1] - goRange[0]) + ); + program.setUniformf( + 'goshift', + -goRange[0] * (gomax - gomin) / (goRange[1] - goRange[0]) + gomin + ); } if (model.lastLightComplexity > 0 || vprop.getUseGradientOpacity(0)) { - program.setUniformi('normalTexture', - model.lightingTexture.getTextureUnit()); + program.setUniformi( + 'normalTexture', + model.lightingTexture.getTextureUnit() + ); } if (model.lastLightComplexity > 0) { @@ -653,14 +760,20 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { // frame time is typically for a couple frames prior // which makes it messy, so keep long running averages // of frame times and pixels rendered - model.avgFrameTime = - (0.97 * model.avgFrameTime) + (0.03 * rft); + model.avgFrameTime = 0.97 * model.avgFrameTime + 0.03 * rft; model.avgWindowArea = - (0.97 * model.avgWindowArea) + (0.03 / (model.lastXYF * model.lastXYF)); - - if (ren.getVTKWindow().getInteractor().isAnimating()) { + 0.97 * model.avgWindowArea + 0.03 / (model.lastXYF * model.lastXYF); + + if ( + ren + .getVTKWindow() + .getInteractor() + .isAnimating() + ) { // compute target xy factor - let txyf = Math.sqrt((model.avgFrameTime * rwi.getDesiredUpdateRate()) / model.avgWindowArea); + let txyf = Math.sqrt( + model.avgFrameTime * rwi.getDesiredUpdateRate() / model.avgWindowArea + ); // limit subsampling to a factor of 10 if (txyf > 10.0) { @@ -669,7 +782,9 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { model.targetXYF = txyf; } else { - model.targetXYF = Math.sqrt((model.avgFrameTime * rwi.getStillUpdateRate()) / model.avgWindowArea); + model.targetXYF = Math.sqrt( + model.avgFrameTime * rwi.getStillUpdateRate() / model.avgWindowArea + ); } // have some inertia to change states around 1.43 @@ -678,7 +793,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { } // and add some inertia to change at all - if (Math.abs(1.0 - (model.targetXYF / model.lastXYF)) < 0.1) { + if (Math.abs(1.0 - model.targetXYF / model.lastXYF) < 0.1) { model.targetXYF = model.lastXYF; } model.lastXYF = model.targetXYF; @@ -720,16 +835,20 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { if (model.framebuffer.getGLFramebuffer() === null) { model.framebuffer.create( Math.floor(size[0] * 0.7), - Math.floor(size[1] * 0.7)); + Math.floor(size[1] * 0.7) + ); model.framebuffer.populateFramebuffer(); } else { const fbSize = model.framebuffer.getSize(); - if (fbSize[0] !== Math.floor(size[0] * 0.7) || - fbSize[1] !== Math.floor(size[1] * 0.7)) { + if ( + fbSize[0] !== Math.floor(size[0] * 0.7) || + fbSize[1] !== Math.floor(size[1] * 0.7) + ) { console.log('resizing'); model.framebuffer.create( Math.floor(size[0] * 0.7), - Math.floor(size[1] * 0.7)); + Math.floor(size[1] * 0.7) + ); model.framebuffer.populateFramebuffer(); } } @@ -738,10 +857,11 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { gl.clearColor(0.0, 0.0, 0.0, 0.0); gl.colorMask(true, true, true, true); gl.clear(gl.COLOR_BUFFER_BIT); - gl.viewport(0, 0, - size[0] / xyf, size[1] / xyf); - model.fvp = [Math.floor(size[0] / xyf) / Math.floor(size[0] * 0.7), - Math.floor(size[1] / xyf) / Math.floor(size[1] * 0.7)]; + gl.viewport(0, 0, size[0] / xyf, size[1] / xyf); + model.fvp = [ + Math.floor(size[0] / xyf) / Math.floor(size[0] * 0.7), + Math.floor(size[1] / xyf) / Math.floor(size[1] * 0.7), + ]; } model.context.disable(model.context.DEPTH_TEST); @@ -779,8 +899,10 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { model.opacityTexture.activate(); model.colorTexture.activate(); model.jitterTexture.activate(); - if (actor.getProperty().getShade() || - actor.getProperty().getUseGradientOpacity(0)) { + if ( + actor.getProperty().getShade() || + actor.getProperty().getUseGradientOpacity(0) + ) { model.lightingTexture.activate(); } @@ -790,16 +912,17 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { // for (let i = 0; i < 11; ++i) { // gl.drawArrays(gl.TRIANGLES, 66 * i, 66); // } - gl.drawArrays(gl.TRIANGLES, 0, - model.tris.getCABO().getElementCount()); + gl.drawArrays(gl.TRIANGLES, 0, model.tris.getCABO().getElementCount()); model.tris.getVAO().release(); model.scalarTexture.deactivate(); model.colorTexture.deactivate(); model.opacityTexture.deactivate(); model.jitterTexture.deactivate(); - if (actor.getProperty().getShade() || - actor.getProperty().getUseGradientOpacity(0)) { + if ( + actor.getProperty().getShade() || + actor.getProperty().getUseGradientOpacity(0) + ) { model.lightingTexture.deactivate(); } }; @@ -816,8 +939,9 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { model.framebuffer.restorePreviousBindingsAndBuffers(); if (model.copyShader === null) { - model.copyShader = - model.openGLRenderWindow.getShaderCache().readyShaderProgramArray( + model.copyShader = model.openGLRenderWindow + .getShaderCache() + .readyShaderProgramArray( [ '//VTK::System::Dec', 'attribute vec4 vertexDC;', @@ -832,22 +956,32 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { 'varying vec2 tcoord;', 'void main() { gl_FragData[0] = texture2D(texture1,tcoord); }', ].join('\n'), - ''); + '' + ); const program = model.copyShader; model.copyVAO = vtkVertexArrayObject.newInstance(); model.copyVAO.setOpenGLRenderWindow(model.openGLRenderWindow); model.tris.getCABO().bind(); - if (!model.copyVAO.addAttributeArray( - program, model.tris.getCABO(), - 'vertexDC', model.tris.getCABO().getVertexOffset(), - model.tris.getCABO().getStride(), model.context.FLOAT, 3, - model.context.FALSE)) { + if ( + !model.copyVAO.addAttributeArray( + program, + model.tris.getCABO(), + 'vertexDC', + model.tris.getCABO().getVertexOffset(), + model.tris.getCABO().getStride(), + model.context.FLOAT, + 3, + model.context.FALSE + ) + ) { vtkErrorMacro('Error setting vertexDC in copy shader VAO.'); } } else { - model.openGLRenderWindow.getShaderCache().readyShaderProgram(model.copyShader); + model.openGLRenderWindow + .getShaderCache() + .readyShaderProgram(model.copyShader); } const size = model.openGLRenderWindow.getSize(); @@ -856,22 +990,32 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { // activate texture const tex = model.framebuffer.getColorTexture(); tex.activate(); - model.copyShader.setUniformi('texture', - tex.getTextureUnit()); + model.copyShader.setUniformi('texture', tex.getTextureUnit()); model.copyShader.setUniform2f('tfactor', model.fvp[0], model.fvp[1]); const gl = model.context; - gl.blendFuncSeparate(gl.ONE, gl.ONE_MINUS_SRC_ALPHA, - gl.ONE, gl.ONE_MINUS_SRC_ALPHA); + gl.blendFuncSeparate( + gl.ONE, + gl.ONE_MINUS_SRC_ALPHA, + gl.ONE, + gl.ONE_MINUS_SRC_ALPHA + ); // render quad - model.context.drawArrays(model.context.TRIANGLES, 0, - model.tris.getCABO().getElementCount()); + model.context.drawArrays( + model.context.TRIANGLES, + 0, + model.tris.getCABO().getElementCount() + ); tex.deactivate(); - gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, - gl.ONE, gl.ONE_MINUS_SRC_ALPHA); + gl.blendFuncSeparate( + gl.SRC_ALPHA, + gl.ONE_MINUS_SRC_ALPHA, + gl.ONE, + gl.ONE_MINUS_SRC_ALPHA + ); } }; @@ -908,11 +1052,13 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { publicAPI.getNeedToRebuildBufferObjects = (ren, actor) => { // first do a coarse check - if (model.VBOBuildTime.getMTime() < publicAPI.getMTime() || - model.VBOBuildTime.getMTime() < actor.getMTime() || - model.VBOBuildTime.getMTime() < model.renderable.getMTime() || - model.VBOBuildTime.getMTime() < actor.getProperty().getMTime() || - model.VBOBuildTime.getMTime() < model.currentInput.getMTime()) { + if ( + model.VBOBuildTime.getMTime() < publicAPI.getMTime() || + model.VBOBuildTime.getMTime() < actor.getMTime() || + model.VBOBuildTime.getMTime() < model.renderable.getMTime() || + model.VBOBuildTime.getMTime() < actor.getProperty().getMTime() || + model.VBOBuildTime.getMTime() < model.currentInput.getMTime() + ) { return true; } return false; @@ -934,13 +1080,19 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { } model.jitterTexture.setMinificationFilter(Filter.LINEAR); model.jitterTexture.setMagnificationFilter(Filter.LINEAR); - model.jitterTexture.create2DFromRaw(32, 32, 1, - VtkDataTypes.UNSIGNED_CHAR, oTable); + model.jitterTexture.create2DFromRaw( + 32, + 32, + 1, + VtkDataTypes.UNSIGNED_CHAR, + oTable + ); } // rebuild opacity tfun? const ofun = vprop.getScalarOpacity(0); - const opacityFactor = model.renderable.getSampleDistance() / + const opacityFactor = + model.renderable.getSampleDistance() / vprop.getScalarOpacityUnitDistance(0); let toString = `${ofun.getMTime()}A${opacityFactor}`; if (model.opacityTextureString !== toString) { @@ -954,8 +1106,13 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { } model.opacityTexture.setMinificationFilter(Filter.LINEAR); model.opacityTexture.setMagnificationFilter(Filter.LINEAR); - model.opacityTexture.create2DFromRaw(oWidth, 1, 1, - VtkDataTypes.UNSIGNED_CHAR, oTable); + model.opacityTexture.create2DFromRaw( + oWidth, + 1, + 1, + VtkDataTypes.UNSIGNED_CHAR, + oTable + ); model.opacityTextureString = toString; } @@ -973,8 +1130,13 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { } model.colorTexture.setMinificationFilter(Filter.LINEAR); model.colorTexture.setMagnificationFilter(Filter.LINEAR); - model.colorTexture.create2DFromRaw(cWidth, 1, 3, - VtkDataTypes.UNSIGNED_CHAR, cTable); + model.colorTexture.create2DFromRaw( + cWidth, + 1, + 3, + VtkDataTypes.UNSIGNED_CHAR, + cTable + ); model.colorTextureString = toString; } @@ -984,9 +1146,19 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { // Build the textures const dims = image.getDimensions(); model.scalarTexture.resetFormatAndType(); - model.scalarTexture.create3DOneComponentFromRaw(dims[0], dims[1], dims[2], - image.getPointData().getScalars().getDataType(), - image.getPointData().getScalars().getData()); + model.scalarTexture.create3DOneComponentFromRaw( + dims[0], + dims[1], + dims[2], + image + .getPointData() + .getScalars() + .getDataType(), + image + .getPointData() + .getScalars() + .getData() + ); model.scalarTextureString = toString; } @@ -997,9 +1169,14 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { toString = `${image.getMTime()}`; if ((shading || gopacity) && model.lightingTextureString !== toString) { model.lightingTexture.resetFormatAndType(); - model.lightingTexture.create3DLighting(model.scalarTexture, - image.getPointData().getScalars().getData(), - image.getSpacing()); + model.lightingTexture.create3DLighting( + model.scalarTexture, + image + .getPointData() + .getScalars() + .getData(), + image.getSpacing() + ); model.lightingTextureString = toString; } @@ -1007,9 +1184,9 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { // build the CABO const ptsArray = new Float32Array(12); for (let i = 0; i < 4; i++) { - ptsArray[(i * 3)] = ((i % 2) * 2) - 1.0; - ptsArray[(i * 3) + 1] = (i > 1) ? 1.0 : -1.0; - ptsArray[(i * 3) + 2] = -1.0; + ptsArray[i * 3] = (i % 2) * 2 - 1.0; + ptsArray[i * 3 + 1] = i > 1 ? 1.0 : -1.0; + ptsArray[i * 3 + 2] = -1.0; } const cellArray = new Uint16Array(8); @@ -1048,12 +1225,19 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { // } // } - const points = vtkDataArray.newInstance({ numberOfComponents: 3, values: ptsArray }); + const points = vtkDataArray.newInstance({ + numberOfComponents: 3, + values: ptsArray, + }); points.setName('points'); - const cells = vtkDataArray.newInstance({ numberOfComponents: 1, values: cellArray }); - model.tris.getCABO().createVBO(cells, - 'polys', Representation.SURFACE, - { points, cellOffset: 0 }); + const cells = vtkDataArray.newInstance({ + numberOfComponents: 1, + values: cellArray, + }); + model.tris.getCABO().createVBO(cells, 'polys', Representation.SURFACE, { + points, + cellOffset: 0, + }); } model.VBOBuildTime.modified(); @@ -1117,9 +1301,7 @@ export function extend(publicAPI, model, initialValues = {}) { model.idxNormalMatrix = mat3.create(); // Build VTK API - macro.setGet(publicAPI, model, [ - 'context', - ]); + macro.setGet(publicAPI, model, ['context']); // Object methods vtkOpenGLVolumeMapper(publicAPI, model); diff --git a/Sources/Rendering/OpenGL/VolumeMapper/test/testComposite.js b/Sources/Rendering/OpenGL/VolumeMapper/test/testComposite.js index bb470791640..c5b3bec904b 100644 --- a/Sources/Rendering/OpenGL/VolumeMapper/test/testComposite.js +++ b/Sources/Rendering/OpenGL/VolumeMapper/test/testComposite.js @@ -1,15 +1,15 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; -import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; +import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; +import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderWindowInteractor from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkVolume from 'vtk.js/Sources/Rendering/Core/Volume'; -import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper'; +import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderWindowInteractor from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkVolume from 'vtk.js/Sources/Rendering/Core/Volume'; +import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper'; import baseline1 from './testComposite.png'; import baseline2 from './testComposite_2.png'; @@ -21,7 +21,9 @@ test.onlyIfWebGL('Test Composite Volume Rendering', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -39,7 +41,7 @@ test.onlyIfWebGL('Test Composite Volume Rendering', (t) => { const reader = vtkHttpDataSetReader.newInstance({ fetchGzip: true }); // create color and opacity transfer functions const ctfun = vtkColorTransferFunction.newInstance(); - ctfun.addRGBPoint(0, (85 / 255.0), 0, 0); + ctfun.addRGBPoint(0, 85 / 255.0, 0, 0); ctfun.addRGBPoint(95, 1.0, 1.0, 1.0); ctfun.addRGBPoint(225, 0.66, 0.66, 0.5); ctfun.addRGBPoint(255, 0.3, 1.0, 0.5); @@ -75,9 +77,14 @@ test.onlyIfWebGL('Test Composite Volume Rendering', (t) => { renderer.resetCameraClippingRange(); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline1, baseline2], + testUtils.compareImages( + image, + [baseline1, baseline2], 'Rendering/OpenGL/VolumeMapper/testComposite', - t, 1.5, gc.releaseResources); + t, + 1.5, + gc.releaseResources + ); }); }); }); diff --git a/Sources/Rendering/OpenGL/VolumeMapper/test/testComposite16Bit.js b/Sources/Rendering/OpenGL/VolumeMapper/test/testComposite16Bit.js index 0ffbe6a7537..c2d04595fed 100644 --- a/Sources/Rendering/OpenGL/VolumeMapper/test/testComposite16Bit.js +++ b/Sources/Rendering/OpenGL/VolumeMapper/test/testComposite16Bit.js @@ -1,15 +1,15 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; -import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; +import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; +import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderWindowInteractor from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkVolume from 'vtk.js/Sources/Rendering/Core/Volume'; -import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper'; +import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderWindowInteractor from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkVolume from 'vtk.js/Sources/Rendering/Core/Volume'; +import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper'; import baseline1 from './testComposite16Bit.png'; import baseline2 from './testComposite16Bit_2.png'; @@ -21,7 +21,9 @@ test.onlyIfWebGL('Test Composite Volume Rendering', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -74,9 +76,14 @@ test.onlyIfWebGL('Test Composite Volume Rendering', (t) => { renderer.resetCamera(); renderWindow.render(); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline1, baseline2], + testUtils.compareImages( + image, + [baseline1, baseline2], 'Rendering/OpenGL/VolumeMapper/testComposite16Bit', - t, 1.5, gc.releaseResources); + t, + 1.5, + gc.releaseResources + ); }); }); }); diff --git a/Sources/Rendering/OpenGL/VolumeMapper/test/testIntermixed.js b/Sources/Rendering/OpenGL/VolumeMapper/test/testIntermixed.js index 2e85287280f..0036f805275 100644 --- a/Sources/Rendering/OpenGL/VolumeMapper/test/testIntermixed.js +++ b/Sources/Rendering/OpenGL/VolumeMapper/test/testIntermixed.js @@ -1,18 +1,18 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; -import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; +import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; +import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction'; -import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderWindowInteractor from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkVolume from 'vtk.js/Sources/Rendering/Core/Volume'; -import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper'; +import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction'; +import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderWindowInteractor from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkVolume from 'vtk.js/Sources/Rendering/Core/Volume'; +import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper'; import baseline1 from './testIntermixed.png'; import baseline2 from './testIntermixed_2.png'; @@ -24,7 +24,9 @@ test.onlyIfWebGL('Test Composite Volume Rendering', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -42,7 +44,7 @@ test.onlyIfWebGL('Test Composite Volume Rendering', (t) => { const reader = vtkHttpDataSetReader.newInstance({ fetchGzip: true }); // create color and opacity transfer functions const ctfun = vtkColorTransferFunction.newInstance(); - ctfun.addRGBPoint(0, (85 / 255.0), 0, 0); + ctfun.addRGBPoint(0, 85 / 255.0, 0, 0); ctfun.addRGBPoint(95, 1.0, 1.0, 1.0); ctfun.addRGBPoint(225, 0.66, 0.66, 0.5); ctfun.addRGBPoint(255, 0.3, 1.0, 0.5); @@ -69,7 +71,13 @@ test.onlyIfWebGL('Test Composite Volume Rendering', (t) => { actor.setMapper(mapper); actor.setPosition(300, 200, 200); - const sphereSource = gc.registerResource(vtkSphereSource.newInstance({ radius: 100, thetaResolution: 36, phiResolution: 18 })); + const sphereSource = gc.registerResource( + vtkSphereSource.newInstance({ + radius: 100, + thetaResolution: 36, + phiResolution: 18, + }) + ); mapper.setInputConnection(sphereSource.getOutputPort()); // Interactor @@ -90,9 +98,14 @@ test.onlyIfWebGL('Test Composite Volume Rendering', (t) => { renderer.resetCameraClippingRange(); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline1, baseline2], + testUtils.compareImages( + image, + [baseline1, baseline2], 'Rendering/OpenGL/VolumeMapper/testComposite', - t, 1.8, gc.releaseResources); + t, + 1.8, + gc.releaseResources + ); }); }); }); diff --git a/Sources/Rendering/OpenGL/VolumeMapper/test/testLighting.js b/Sources/Rendering/OpenGL/VolumeMapper/test/testLighting.js index 50dff025ee8..89d9049303a 100644 --- a/Sources/Rendering/OpenGL/VolumeMapper/test/testLighting.js +++ b/Sources/Rendering/OpenGL/VolumeMapper/test/testLighting.js @@ -1,15 +1,15 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import testUtils from 'vtk.js/Sources/Testing/testUtils'; -import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; -import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; +import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction'; +import vtkHttpDataSetReader from 'vtk.js/Sources/IO/Core/HttpDataSetReader'; import vtkOpenGLRenderWindow from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow'; -import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction'; -import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; -import vtkRenderWindowInteractor from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor'; -import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; -import vtkVolume from 'vtk.js/Sources/Rendering/Core/Volume'; -import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper'; +import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction'; +import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow'; +import vtkRenderWindowInteractor from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor'; +import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer'; +import vtkVolume from 'vtk.js/Sources/Rendering/Core/Volume'; +import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper'; import baseline1 from './testLighting.png'; import baseline2 from './testLighting_2.png'; @@ -21,7 +21,9 @@ test.onlyIfWebGL('Test Lighted Volume Rendering', (t) => { // Create some control UI const container = document.querySelector('body'); - const renderWindowContainer = gc.registerDOMElement(document.createElement('div')); + const renderWindowContainer = gc.registerDOMElement( + document.createElement('div') + ); container.appendChild(renderWindowContainer); // create what we will view @@ -90,9 +92,14 @@ test.onlyIfWebGL('Test Lighted Volume Rendering', (t) => { renderer.updateLightsGeometryToFollowCamera(); renderWindow.render(); const image = glwindow.captureImage(); - testUtils.compareImages(image, [baseline1, baseline2], + testUtils.compareImages( + image, + [baseline1, baseline2], 'Rendering/OpenGL/VolumeMapper/testLighting', - t, 1.5, gc.releaseResources); + t, + 1.5, + gc.releaseResources + ); }); }); }); diff --git a/Sources/Rendering/OpenGL/index.js b/Sources/Rendering/OpenGL/index.js index f12424c9e3a..f507678d914 100644 --- a/Sources/Rendering/OpenGL/index.js +++ b/Sources/Rendering/OpenGL/index.js @@ -1,28 +1,28 @@ -import vtkActor from './Actor'; -import vtkActor2D from './Actor2D'; -import vtkBufferObject from './BufferObject'; -import vtkCamera from './Camera'; -import vtkCellArrayBufferObject from './CellArrayBufferObject'; -import vtkFramebuffer from './Framebuffer'; -import vtkGlyph3DMapper from './Glyph3DMapper'; -import vtkHardwareSelector from './HardwareSelector'; -import vtkHelper from './Helper'; -import vtkImageMapper from './ImageMapper'; -import vtkImageSlice from './ImageSlice'; -import vtkPolyDataMapper from './PolyDataMapper'; -import vtkRenderer from './Renderer'; -import vtkRenderWindow from './RenderWindow'; -import vtkShader from './Shader'; -import vtkShaderCache from './ShaderCache'; -import vtkShaderProgram from './ShaderProgram'; -import vtkSphereMapper from './SphereMapper'; -import vtkStickMapper from './StickMapper'; -import vtkTexture from './Texture'; -import vtkTextureUnitManager from './TextureUnitManager'; -import vtkVertexArrayObject from './VertexArrayObject'; -import vtkViewNodeFactory from './ViewNodeFactory'; -import vtkVolume from './Volume'; -import vtkVolumeMapper from './VolumeMapper'; +import vtkActor from './Actor'; +import vtkActor2D from './Actor2D'; +import vtkBufferObject from './BufferObject'; +import vtkCamera from './Camera'; +import vtkCellArrayBufferObject from './CellArrayBufferObject'; +import vtkFramebuffer from './Framebuffer'; +import vtkGlyph3DMapper from './Glyph3DMapper'; +import vtkHardwareSelector from './HardwareSelector'; +import vtkHelper from './Helper'; +import vtkImageMapper from './ImageMapper'; +import vtkImageSlice from './ImageSlice'; +import vtkPolyDataMapper from './PolyDataMapper'; +import vtkRenderer from './Renderer'; +import vtkRenderWindow from './RenderWindow'; +import vtkShader from './Shader'; +import vtkShaderCache from './ShaderCache'; +import vtkShaderProgram from './ShaderProgram'; +import vtkSphereMapper from './SphereMapper'; +import vtkStickMapper from './StickMapper'; +import vtkTexture from './Texture'; +import vtkTextureUnitManager from './TextureUnitManager'; +import vtkVertexArrayObject from './VertexArrayObject'; +import vtkViewNodeFactory from './ViewNodeFactory'; +import vtkVolume from './Volume'; +import vtkVolumeMapper from './VolumeMapper'; export default { vtkActor, diff --git a/Sources/Rendering/SceneGraph/GenericWidgetRepresentation/index.js b/Sources/Rendering/SceneGraph/GenericWidgetRepresentation/index.js index b9cb1d10f74..9ede91c2ade 100644 --- a/Sources/Rendering/SceneGraph/GenericWidgetRepresentation/index.js +++ b/Sources/Rendering/SceneGraph/GenericWidgetRepresentation/index.js @@ -1,4 +1,4 @@ -import macro from 'vtk.js/Sources/macro'; +import macro from 'vtk.js/Sources/macro'; import vtkViewNode from 'vtk.js/Sources/Rendering/SceneGraph/ViewNode'; // ---------------------------------------------------------------------------- @@ -14,8 +14,7 @@ function vtkGenericWidgetRepresentation(publicAPI, model) { // Object factory // ---------------------------------------------------------------------------- -const DEFAULT_VALUES = { -}; +const DEFAULT_VALUES = {}; // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/SceneGraph/RenderPass/index.js b/Sources/Rendering/SceneGraph/RenderPass/index.js index 3a59b816b3c..51fbfce5780 100644 --- a/Sources/Rendering/SceneGraph/RenderPass/index.js +++ b/Sources/Rendering/SceneGraph/RenderPass/index.js @@ -10,7 +10,9 @@ function vtkRenderPass(publicAPI, model) { publicAPI.setCurrentOperation = (val) => { model.currentOperation = val; - model.currentTraverseOperation = `traverse${macro.capitalize(model.currentOperation)}`; + model.currentTraverseOperation = `traverse${macro.capitalize( + model.currentOperation + )}`; }; publicAPI.getTraverseOperation = () => model.currentTraverseOperation; @@ -60,9 +62,7 @@ export function extend(publicAPI, model, initialValues = {}) { // Build VTK API macro.obj(publicAPI, model); - macro.get(publicAPI, model, [ - 'currentOperation', - ]); + macro.get(publicAPI, model, ['currentOperation']); macro.setGet(publicAPI, model, [ 'delegates', 'currentParent', diff --git a/Sources/Rendering/SceneGraph/ViewNode/index.js b/Sources/Rendering/SceneGraph/ViewNode/index.js index 4b0f81e2955..1888e7c967a 100644 --- a/Sources/Rendering/SceneGraph/ViewNode/index.js +++ b/Sources/Rendering/SceneGraph/ViewNode/index.js @@ -2,7 +2,7 @@ import macro from 'vtk.js/Sources/macro'; const { vtkErrorMacro } = macro; -export const PASS_TYPES = ['Build', 'Render']; +const PASS_TYPES = ['Build', 'Render']; // ---------------------------------------------------------------------------- // vtkViewNode methods @@ -13,12 +13,10 @@ function vtkViewNode(publicAPI, model) { model.classHierarchy.push('vtkViewNode'); // Builds myself. - publicAPI.build = (prepass) => { - }; + publicAPI.build = (prepass) => {}; // Renders myself - publicAPI.render = (prepass) => { - }; + publicAPI.render = (prepass) => {}; publicAPI.traverse = (renderPass) => { // we can choose to do special @@ -80,7 +78,8 @@ function vtkViewNode(publicAPI, model) { // if found just mark as visited if (result !== undefined) { result.setVisited(true); - } else { // otherwise create a node + } else { + // otherwise create a node const newNode = publicAPI.createViewNode(dobj); if (newNode) { newNode.setParent(publicAPI); @@ -102,7 +101,8 @@ function vtkViewNode(publicAPI, model) { // if found just mark as visited if (result !== undefined) { result.setVisited(true); - } else { // otherwise create a node + } else { + // otherwise create a node const newNode = publicAPI.createViewNode(dobj); if (newNode) { newNode.setParent(publicAPI); @@ -145,7 +145,7 @@ function vtkViewNode(publicAPI, model) { if (deleted) { // slow does alloc but not as common - model.children = model.children.filter(el => !deleted.includes(el)); + model.children = model.children.filter((el) => !deleted.includes(el)); } }; @@ -176,7 +176,7 @@ const DEFAULT_VALUES = { // ---------------------------------------------------------------------------- -export function extend(publicAPI, model, initialValues = {}) { +function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API @@ -185,14 +185,8 @@ export function extend(publicAPI, model, initialValues = {}) { model.renderableChildMap = new Map(); - macro.get(publicAPI, model, [ - 'visited', - ]); - macro.setGet(publicAPI, model, [ - 'parent', - 'renderable', - 'myFactory', - ]); + macro.get(publicAPI, model, ['visited']); + macro.setGet(publicAPI, model, ['parent', 'renderable', 'myFactory']); macro.getArray(publicAPI, model, ['children']); // Object methods @@ -201,7 +195,7 @@ export function extend(publicAPI, model, initialValues = {}) { // ---------------------------------------------------------------------------- -export const newInstance = macro.newInstance(extend, 'vtkViewNode'); +const newInstance = macro.newInstance(extend, 'vtkViewNode'); // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/SceneGraph/index.js b/Sources/Rendering/SceneGraph/index.js index 34ce51b0823..f055e8f54f7 100644 --- a/Sources/Rendering/SceneGraph/index.js +++ b/Sources/Rendering/SceneGraph/index.js @@ -1,7 +1,7 @@ import vtkGenericWidgetRepresentation from './GenericWidgetRepresentation'; -import vtkRenderPass from './RenderPass'; -import vtkViewNode from './ViewNode'; -import vtkViewNodeFactory from './ViewNodeFactory'; +import vtkRenderPass from './RenderPass'; +import vtkViewNode from './ViewNode'; +import vtkViewNodeFactory from './ViewNodeFactory'; export default { vtkGenericWidgetRepresentation, diff --git a/Sources/Rendering/index.js b/Sources/Rendering/index.js index 54c17effdde..2b70b29387b 100644 --- a/Sources/Rendering/index.js +++ b/Sources/Rendering/index.js @@ -1,6 +1,6 @@ -import Core from './Core'; -import Misc from './Misc'; -import OpenGL from './OpenGL'; +import Core from './Core'; +import Misc from './Misc'; +import OpenGL from './OpenGL'; import SceneGraph from './SceneGraph'; export default { diff --git a/Sources/Testing/Examples/ActorSerialization/example/index.js b/Sources/Testing/Examples/ActorSerialization/example/index.js index 93ecd28133f..48f146ee3d6 100644 --- a/Sources/Testing/Examples/ActorSerialization/example/index.js +++ b/Sources/Testing/Examples/ActorSerialization/example/index.js @@ -1,9 +1,9 @@ import 'vtk.js/Sources/favicon'; import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtk from 'vtk.js/Sources/vtk'; +import vtk from 'vtk.js/Sources/vtk'; -import actorJSON from './actor.json'; +import actorJSON from './actor.json'; // ---------------------------------------------------------------------------- // Standard rendering code setup @@ -22,4 +22,3 @@ const actor = vtk(actorJSON); renderer.addActor(actor); renderer.resetCamera(); renderWindow.render(); - diff --git a/Sources/Testing/Examples/PipelineExecution/example/index.js b/Sources/Testing/Examples/PipelineExecution/example/index.js index 93e2ece69bf..d4f38fe7a8d 100644 --- a/Sources/Testing/Examples/PipelineExecution/example/index.js +++ b/Sources/Testing/Examples/PipelineExecution/example/index.js @@ -1,15 +1,15 @@ import 'vtk.js/Sources/favicon'; -import macro from 'vtk.js/Sources/macro'; -import vtk from 'vtk.js/Sources/vtk'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; -import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; -import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; +import macro from 'vtk.js/Sources/macro'; +import vtk from 'vtk.js/Sources/vtk'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkCalculator from 'vtk.js/Sources/Filters/General/Calculator'; +import vtkConeSource from 'vtk.js/Sources/Filters/Sources/ConeSource'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import { AttributeTypes } from 'vtk.js/Sources/Common/DataModel/DataSetAttributes/Constants'; +import { FieldDataTypes } from 'vtk.js/Sources/Common/DataModel/DataSet/Constants'; import controlPanel from './controller.html'; @@ -17,7 +17,9 @@ import controlPanel from './controller.html'; // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -44,15 +46,20 @@ const filterB = vtkCalculator.newInstance(); const filterC = vtkCalculator.newInstance(); filterA.setFormula({ - getArrays: inputDataSets => ({ + getArrays: (inputDataSets) => ({ input: [], output: [ - { location: FieldDataTypes.CELL, name: 'a', dataType: 'Float32Array', attribute: AttributeTypes.SCALARS }, + { + location: FieldDataTypes.CELL, + name: 'a', + dataType: 'Float32Array', + attribute: AttributeTypes.SCALARS, + }, ], }), evaluate: (arraysIn, arraysOut) => { updateExecution(0); - const [scalars] = arraysOut.map(d => d.getData()); + const [scalars] = arraysOut.map((d) => d.getData()); for (let i = 0; i < scalars.length; i++) { scalars[i] = Math.random(); } @@ -60,15 +67,20 @@ filterA.setFormula({ }); filterB.setFormula({ - getArrays: inputDataSets => ({ + getArrays: (inputDataSets) => ({ input: [], output: [ - { location: FieldDataTypes.CELL, name: 'b', dataType: 'Float32Array', attribute: AttributeTypes.SCALARS }, + { + location: FieldDataTypes.CELL, + name: 'b', + dataType: 'Float32Array', + attribute: AttributeTypes.SCALARS, + }, ], }), evaluate: (arraysIn, arraysOut) => { updateExecution(1); - const [scalars] = arraysOut.map(d => d.getData()); + const [scalars] = arraysOut.map((d) => d.getData()); for (let i = 0; i < scalars.length; i++) { scalars[i] = Math.random(); } @@ -78,9 +90,12 @@ filterB.setFormula({ const randFilter = macro.newInstance((publicAPI, model) => { macro.obj(publicAPI, model); // make it an object macro.algo(publicAPI, model, 1, 1); // mixin algorithm code 1 in, 1 out - publicAPI.requestData = (inData, outData) => { // implement requestData + publicAPI.requestData = (inData, outData) => { + // implement requestData updateExecution(2); - const newArray = new Float32Array(inData[0].getPoints().getNumberOfPoints()); + const newArray = new Float32Array( + inData[0].getPoints().getNumberOfPoints() + ); for (let i = 0; i < newArray.length; i++) { newArray[i] = i % 2 ? 1 : 0; } @@ -94,15 +109,20 @@ const randFilter = macro.newInstance((publicAPI, model) => { })(); filterC.setFormula({ - getArrays: inputDataSets => ({ + getArrays: (inputDataSets) => ({ input: [], output: [ - { location: FieldDataTypes.CELL, name: 'c', dataType: 'Float32Array', attribute: AttributeTypes.SCALARS }, + { + location: FieldDataTypes.CELL, + name: 'c', + dataType: 'Float32Array', + attribute: AttributeTypes.SCALARS, + }, ], }), evaluate: (arraysIn, arraysOut) => { updateExecution(3); - const [scalars] = arraysOut.map(d => d.getData()); + const [scalars] = arraysOut.map((d) => d.getData()); for (let i = 0; i < scalars.length; i++) { scalars[i] = Math.random(); } diff --git a/Sources/Testing/Examples/PolyDataSerialization/example/index.js b/Sources/Testing/Examples/PolyDataSerialization/example/index.js index abcd3337d0d..fa64920b56d 100644 --- a/Sources/Testing/Examples/PolyDataSerialization/example/index.js +++ b/Sources/Testing/Examples/PolyDataSerialization/example/index.js @@ -1,15 +1,17 @@ import 'vtk.js/Sources/favicon'; import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtk from 'vtk.js/Sources/vtk'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtk from 'vtk.js/Sources/vtk'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; // ---------------------------------------------------------------------------- // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -17,6 +19,7 @@ const renderWindow = fullScreenRenderer.getRenderWindow(); // Inline PolyData definition // ---------------------------------------------------------------------------- +// prettier-ignore const polydata = vtk({ vtkClass: 'vtkPolyData', points: { @@ -88,4 +91,3 @@ global.actor = actor; global.lut = lut; global.renderer = renderer; global.renderWindow = renderWindow; - diff --git a/Sources/Testing/Examples/StandaloneSceneLoader/example/SceneControllerWidget.js b/Sources/Testing/Examples/StandaloneSceneLoader/example/SceneControllerWidget.js index 46a9081cb0b..6406f4c9d8e 100644 --- a/Sources/Testing/Examples/StandaloneSceneLoader/example/SceneControllerWidget.js +++ b/Sources/Testing/Examples/StandaloneSceneLoader/example/SceneControllerWidget.js @@ -51,23 +51,38 @@ const SETTINGS_OPTIONS = { }, }; -const OPTIONS_HTML_STR = Object.keys(SETTINGS_OPTIONS).map(name => ``).join(''); +const OPTIONS_HTML_STR = Object.keys(SETTINGS_OPTIONS) + .map((name) => ``) + .join(''); export default function addWidget(container, sceneItems, render) { function handleChange(e) { const itemIdx = Number(e.target.name); const value = e.target.value; if (sceneItems[itemIdx][value]) { - vtkHttpSceneLoader.applySettings(sceneItems[itemIdx], sceneItems[itemIdx][value]); + vtkHttpSceneLoader.applySettings( + sceneItems[itemIdx], + sceneItems[itemIdx][value] + ); } else if (SETTINGS_OPTIONS[value]) { - vtkHttpSceneLoader.applySettings(sceneItems[itemIdx], SETTINGS_OPTIONS[value]); + vtkHttpSceneLoader.applySettings( + sceneItems[itemIdx], + SETTINGS_OPTIONS[value] + ); } if (render) { render(); } } - const listStr = sceneItems.map((item, idx) => `
  •   ${item.name}
  • `).join(''); + const listStr = sceneItems + .map( + (item, idx) => + `
  •   ${ + item.name + }
  • ` + ) + .join(''); const listContainer = document.createElement('ul'); listContainer.innerHTML = listStr; diff --git a/Sources/Testing/Examples/StandaloneSceneLoader/example/index.js b/Sources/Testing/Examples/StandaloneSceneLoader/example/index.js index b7215516fbd..e0f178221fa 100644 --- a/Sources/Testing/Examples/StandaloneSceneLoader/example/index.js +++ b/Sources/Testing/Examples/StandaloneSceneLoader/example/index.js @@ -5,14 +5,14 @@ import 'babel-polyfill'; import 'vtk.js/Sources/favicon'; -import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; +import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkHttpSceneLoader from 'vtk.js/Sources/IO/Core/HttpSceneLoader'; -import DataAccessHelper from 'vtk.js/Sources/IO/Core/DataAccessHelper'; -import vtkURLExtract from 'vtk.js/Sources/Common/Core/URLExtract'; -import vtkOBJReader from 'vtk.js/Sources/IO/Misc/OBJReader'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkHttpSceneLoader from 'vtk.js/Sources/IO/Core/HttpSceneLoader'; +import DataAccessHelper from 'vtk.js/Sources/IO/Core/DataAccessHelper'; +import vtkURLExtract from 'vtk.js/Sources/Common/Core/URLExtract'; +import vtkOBJReader from 'vtk.js/Sources/IO/Misc/OBJReader'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; import controlWidget from './SceneControllerWidget'; import style from './SceneLoader.mcss'; @@ -69,7 +69,11 @@ export function load(container, options) { // Add UI to dynamically change rendering settings if (!widgetCreated) { widgetCreated = true; - controlWidget(document.querySelector('body'), sceneImporter.getScene(), renderWindow.render); + controlWidget( + document.querySelector('body'), + sceneImporter.getScene(), + renderWindow.render + ); } }); @@ -84,19 +88,19 @@ export function load(container, options) { sceneImporter.setUrl(options.url); onReady(sceneImporter); } else if (options.fileURL) { - downloadZipFile(options.fileURL) - .then((zipContent) => { - const dataAccessHelper = DataAccessHelper.get( - 'zip', - { - zipContent, - callback: (zip) => { - const sceneImporter = vtkHttpSceneLoader.newInstance({ renderer, dataAccessHelper }); - sceneImporter.setUrl('index.json'); - onReady(sceneImporter); - }, + downloadZipFile(options.fileURL).then((zipContent) => { + const dataAccessHelper = DataAccessHelper.get('zip', { + zipContent, + callback: (zip) => { + const sceneImporter = vtkHttpSceneLoader.newInstance({ + renderer, + dataAccessHelper, }); + sceneImporter.setUrl('index.json'); + onReady(sceneImporter); + }, }); + }); } else if (options.file) { if (options.ext === 'obj') { const scene = []; @@ -120,8 +124,12 @@ export function load(container, options) { }); } onReady({ - getScene() { return scene; }, - resetScene() { renderer.resetCamera(); }, + getScene() { + return scene; + }, + resetScene() { + renderer.resetCamera(); + }, onReady(fn) { renderer.resetCamera(); renderWindow.render(); @@ -131,16 +139,17 @@ export function load(container, options) { }; reader.readAsText(options.file); } else { - const dataAccessHelper = DataAccessHelper.get( - 'zip', - { - zipContent: options.file, - callback: (zip) => { - const sceneImporter = vtkHttpSceneLoader.newInstance({ renderer, dataAccessHelper }); - sceneImporter.setUrl('index.json'); - onReady(sceneImporter); - }, - }); + const dataAccessHelper = DataAccessHelper.get('zip', { + zipContent: options.file, + callback: (zip) => { + const sceneImporter = vtkHttpSceneLoader.newInstance({ + renderer, + dataAccessHelper, + }); + sceneImporter.setUrl('index.json'); + onReady(sceneImporter); + }, + }); } } } diff --git a/Sources/Testing/Examples/WindTunnel/index.js b/Sources/Testing/Examples/WindTunnel/index.js index 65990c642d6..d312c81119b 100644 --- a/Sources/Testing/Examples/WindTunnel/index.js +++ b/Sources/Testing/Examples/WindTunnel/index.js @@ -1,20 +1,22 @@ import 'vtk.js/Sources/favicon'; -import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; +import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; -import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; -import vtkOBJReader from 'vtk.js/Sources/IO/Misc/OBJReader'; -import vtkOutlineFilter from 'vtk.js/Sources/Filters/General/OutlineFilter'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; +import vtkOBJReader from 'vtk.js/Sources/IO/Misc/OBJReader'; +import vtkOutlineFilter from 'vtk.js/Sources/Filters/General/OutlineFilter'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; import controlPanel from './controller.html'; -import style from './windtunnel.mcss'; +import style from './windtunnel.mcss'; // ---------------------------------------------------------------------------- // Standard rendering code setup // ---------------------------------------------------------------------------- -const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] }); +const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ + background: [0, 0, 0], +}); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); @@ -55,8 +57,8 @@ function updateUI() { if (tunnelBounds[i * 2] > objBounds[i * 2]) { tunnelBounds[i * 2] = objBounds[i * 2]; } - if (tunnelBounds[(i * 2) + 1] < objBounds[(i * 2) + 1]) { - tunnelBounds[(i * 2) + 1] = objBounds[(i * 2) + 1]; + if (tunnelBounds[i * 2 + 1] < objBounds[i * 2 + 1]) { + tunnelBounds[i * 2 + 1] = objBounds[i * 2 + 1]; } } document.querySelector('.tx0').value = tunnelBounds[0].toFixed(3); @@ -120,11 +122,14 @@ function onClick(event) { const camera = renderer.getActiveCamera(); const mappingIndex = 'xyz'.indexOf(dataModel.wind.direction[0]); - const delta = (dataModel.wind.direction[1] === '+') ? 1 : -1; + const delta = dataModel.wind.direction[1] === '+' ? 1 : -1; const focalPoint = camera.getFocalPoint(); - const position = focalPoint.map((v, i) => ((i === mappingIndex) ? (v + delta) : v)); + const position = focalPoint.map( + (v, i) => (i === mappingIndex ? v + delta : v) + ); const viewUp = [0, 0, 0]; - viewUp['xyz'.indexOf(dataModel.wind.orientation[0])] = ((dataModel.wind.orientation[1] === '+') ? 1 : -1); + viewUp['xyz'.indexOf(dataModel.wind.orientation[0])] = + dataModel.wind.orientation[1] === '+' ? 1 : -1; camera.set({ focalPoint, position, viewUp }); renderer.resetCamera(); updateUI(); @@ -181,7 +186,10 @@ mapper.setInputConnection(reader.getOutputPort()); actor.setMapper(mapper); reader - .setUrl('https://data.kitware.com/api/v1/file/589b535f8d777f07219fcc58/download', { fullpath: true, compression: 'gz' }) + .setUrl( + 'https://data.kitware.com/api/v1/file/589b535f8d777f07219fcc58/download', + { fullpath: true, compression: 'gz' } + ) .then(() => { dataModel.size.object = reader.getOutputData().getBounds(); updateUI(); diff --git a/Sources/Testing/testAlgorithm.js b/Sources/Testing/testAlgorithm.js index 6a04928414e..ef83701bf58 100644 --- a/Sources/Testing/testAlgorithm.js +++ b/Sources/Testing/testAlgorithm.js @@ -1,4 +1,4 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import macro from 'vtk.js/Sources/macro'; const model = {}; @@ -16,19 +16,20 @@ for (let i = 0; i < inLeft.length; i++) { // const daLeft = vtkDataArray.newInstance({ name: 'left', values: inLeft }); // const daRight = vtkDataArray.newInstance({ name: 'left', values: inLeft }); -publicAPI.requestData = (inData, outData) => { // implement requestData - outData[0] = inData.reduce((inArray1, inArray2) => ( - inArray2.map((d, i) => (d + inArray1[i])) - )); - outData[1] = inData.reduce((inArray1, inArray2) => ( - inArray2.map((d, i) => (d - inArray1[i])) - )); - outData[2] = inData.reduce((inArray1, inArray2) => ( - inArray2.map((d, i) => (d * inArray1[i])) - )); - outData[3] = inData.reduce((inArray1, inArray2) => ( - inArray2.map((d, i) => (d / inArray1[i])) - )); +publicAPI.requestData = (inData, outData) => { + // implement requestData + outData[0] = inData.reduce((inArray1, inArray2) => + inArray2.map((d, i) => d + inArray1[i]) + ); + outData[1] = inData.reduce((inArray1, inArray2) => + inArray2.map((d, i) => d - inArray1[i]) + ); + outData[2] = inData.reduce((inArray1, inArray2) => + inArray2.map((d, i) => d * inArray1[i]) + ); + outData[3] = inData.reduce((inArray1, inArray2) => + inArray2.map((d, i) => d / inArray1[i]) + ); }; test('Macro methods algo tests', (t) => { @@ -54,7 +55,11 @@ test('Macro methods algo tests', (t) => { t.deepEqual(output, { 0: 0, 1: 4, 2: 10 }, 'Multiply two input arrays'); const outputPort = publicAPI.getOutputPort(3); - t.deepEqual(outputPort(), { 0: Infinity, 1: 4, 2: 2.5 }, 'Divide two input arrays, using outputPort'); + t.deepEqual( + outputPort(), + { 0: Infinity, 1: 4, 2: 2.5 }, + 'Divide two input arrays, using outputPort' + ); t.end(); }); diff --git a/Sources/Testing/testMacro.js b/Sources/Testing/testMacro.js index 4c4c634f9b5..10d7cbeb739 100644 --- a/Sources/Testing/testMacro.js +++ b/Sources/Testing/testMacro.js @@ -1,4 +1,4 @@ -import test from 'tape-catch'; +import test from 'tape-catch'; import macro from 'vtk.js/Sources/macro'; const MY_ENUM = { @@ -20,7 +20,7 @@ function myClass(publicAPI, model) { // ---------------------------------------------------------------------------- const DEFAULT_VALUES = { myProp1: [0, 0, 0], - myProp2: null, // Do not initialize internal objects here + myProp2: null, // Do not initialize internal objects here myProp3: true, myProp4: 6, myProp5: [1, 2, 3, 4], @@ -56,18 +56,25 @@ function extend(publicAPI, model, initialValues = {}) { const newInstance = macro.newInstance(extend, 'vtkMyClass'); - test('Macro methods scalar tests', (t) => { t.ok('macros', 'macro setget'); const myTestClass = newInstance(); - t.equal(myTestClass.getMyProp3(), DEFAULT_VALUES.myProp3, 'Initial gets should match defaults'); + t.equal( + myTestClass.getMyProp3(), + DEFAULT_VALUES.myProp3, + 'Initial gets should match defaults' + ); myTestClass.setMyProp3(false); t.equal(myTestClass.getMyProp3(), false, 'Bool get should match set'); const mtime1 = myTestClass.getMTime(); - t.equal(myTestClass.getMyProp4(), DEFAULT_VALUES.myProp4, 'Initial gets should match defaults'); + t.equal( + myTestClass.getMyProp4(), + DEFAULT_VALUES.myProp4, + 'Initial gets should match defaults' + ); myTestClass.setMyProp4(42); const mtime2 = myTestClass.getMTime(); t.equal(myTestClass.getMyProp4(), 42, 'Int get should match set'); @@ -82,13 +89,25 @@ test('Macro methods scalar tests', (t) => { test('Macro methods array tests', (t) => { const myTestClass = newInstance(); - t.deepEqual(myTestClass.getMyProp1(), DEFAULT_VALUES.myProp1, 'Initial gets should match defaults'); + t.deepEqual( + myTestClass.getMyProp1(), + DEFAULT_VALUES.myProp1, + 'Initial gets should match defaults' + ); // we must wrap the non-existent call inside another function to avoid test program exiting, and tape-catch generating error. - t.throws(() => myTestClass.setMyProp1(1, 1, 1), /TypeError/, 'Throw if no set method declared'); + t.throws( + () => myTestClass.setMyProp1(1, 1, 1), + /TypeError/, + 'Throw if no set method declared' + ); const myArray = [10, 20, 30, 40]; t.ok(myTestClass.setMyProp5(...myArray), 'Array spread set OK'); - t.deepEqual(myTestClass.getMyProp5(), myArray, 'Array spread set should match get'); + t.deepEqual( + myTestClass.getMyProp5(), + myArray, + 'Array spread set should match get' + ); const mtime1 = myTestClass.getMTime(); myArray[0] = 99.9; @@ -98,19 +117,43 @@ test('Macro methods array tests', (t) => { const mtime2 = myTestClass.getMTime(); t.ok(mtime2 > mtime1, 'mtime should increase after set'); // set a too-short array, separate args - t.throws(() => myTestClass.setMyProp6(1, 2, 3), /RangeError/, 'Invalid number of values should throw'); - t.deepEqual(myTestClass.getMyProp6(), DEFAULT_VALUES.myProp6, 'Keep default value after illegal set'); + t.throws( + () => myTestClass.setMyProp6(1, 2, 3), + /RangeError/, + 'Invalid number of values should throw' + ); + t.deepEqual( + myTestClass.getMyProp6(), + DEFAULT_VALUES.myProp6, + 'Keep default value after illegal set' + ); const mtime3 = myTestClass.getMTime(); t.ok(mtime3 === mtime2, 'mtime should not increase after idempotent set'); // set a too-long array, single array arg - t.throws(() => myTestClass.setMyProp5([].concat(myArray, 555)), /RangeError/, 'Invalid number of values should throw'); - t.deepEqual(myTestClass.getMyProp5(), myArray, 'Keep value after illegal set'); + t.throws( + () => myTestClass.setMyProp5([].concat(myArray, 555)), + /RangeError/, + 'Invalid number of values should throw' + ); + t.deepEqual( + myTestClass.getMyProp5(), + myArray, + 'Keep value after illegal set' + ); // set an string - t.throws(() => myTestClass.setMyProp5('a string, really'), /RangeError/, 'Invalid set with string should throw'); - t.deepEqual(myTestClass.getMyProp5(), myArray, 'Keep value after illegal set'); + t.throws( + () => myTestClass.setMyProp5('a string, really'), + /RangeError/, + 'Invalid set with string should throw' + ); + t.deepEqual( + myTestClass.getMyProp5(), + myArray, + 'Keep value after illegal set' + ); t.end(); }); @@ -118,23 +161,58 @@ test('Macro methods array tests', (t) => { test('Macro methods enum tests', (t) => { const myTestClass = newInstance(); - t.equal(myTestClass.getMyProp7(), DEFAULT_VALUES.myProp7, 'Initial gets should match defaults'); + t.equal( + myTestClass.getMyProp7(), + DEFAULT_VALUES.myProp7, + 'Initial gets should match defaults' + ); myTestClass.setMyProp7(MY_ENUM.THIRD); t.equal(myTestClass.getMyProp7(), MY_ENUM.THIRD, 'Enum set should match get'); t.ok(myTestClass.setMyProp7(2)); - t.equal(myTestClass.getMyProp7(), MY_ENUM.SECOND, 'Enum set by index should get matching enum value'); - - t.notOk(myTestClass.setMyProp7(2), 'Setting idempotent value should return false'); - - t.throws(() => myTestClass.setMyProp7(42), /RangeError/, 'Invalid enum index should throw'); - t.equal(myTestClass.getMyProp7(), MY_ENUM.SECOND, 'Enum set out of range should be rejected'); - - t.throws(() => myTestClass.setMyProp7('FORTH'), /RangeError/, 'Invalid enum string should throw'); - t.equal(myTestClass.getMyProp7(), MY_ENUM.SECOND, 'Enum set string out of range should be rejected'); - - t.throws(() => myTestClass.setMyProp7([2]), /TypeError/, 'Invalid enum set with array/object should throw'); - t.equal(myTestClass.getMyProp7(), MY_ENUM.SECOND, 'Enum set string out of range should be rejected'); + t.equal( + myTestClass.getMyProp7(), + MY_ENUM.SECOND, + 'Enum set by index should get matching enum value' + ); + + t.notOk( + myTestClass.setMyProp7(2), + 'Setting idempotent value should return false' + ); + + t.throws( + () => myTestClass.setMyProp7(42), + /RangeError/, + 'Invalid enum index should throw' + ); + t.equal( + myTestClass.getMyProp7(), + MY_ENUM.SECOND, + 'Enum set out of range should be rejected' + ); + + t.throws( + () => myTestClass.setMyProp7('FORTH'), + /RangeError/, + 'Invalid enum string should throw' + ); + t.equal( + myTestClass.getMyProp7(), + MY_ENUM.SECOND, + 'Enum set string out of range should be rejected' + ); + + t.throws( + () => myTestClass.setMyProp7([2]), + /TypeError/, + 'Invalid enum set with array/object should throw' + ); + t.equal( + myTestClass.getMyProp7(), + MY_ENUM.SECOND, + 'Enum set string out of range should be rejected' + ); t.end(); }); @@ -143,22 +221,49 @@ test('Macro methods object tests', (t) => { const myTestClass = newInstance(); t.ok(myTestClass.get(), 'Get entire model'); - t.deepEqual(myTestClass.get(...Object.keys(DEFAULT_VALUES)), DEFAULT_VALUES, 'Get defaults back test'); - - t.throws(() => { myTestClass.getMyProp1 = () => ('42'); }, /TypeError/, 'Object should be frozen'); + t.deepEqual( + myTestClass.get(...Object.keys(DEFAULT_VALUES)), + DEFAULT_VALUES, + 'Get defaults back test' + ); + + t.throws( + () => { + myTestClass.getMyProp1 = () => '42'; + }, + /TypeError/, + 'Object should be frozen' + ); t.ok(myTestClass.set({ changeWhenModified: 'foo' })); - const off = myTestClass.onModified((publicAPI) => { publicAPI.set({ changeWhenModified: 'bar' }); }); + const off = myTestClass.onModified((publicAPI) => { + publicAPI.set({ changeWhenModified: 'bar' }); + }); t.ok(myTestClass.setMyProp3(false)); - t.deepEqual(myTestClass.get('changeWhenModified'), { changeWhenModified: 'bar' }, 'Object modified fires'); + t.deepEqual( + myTestClass.get('changeWhenModified'), + { changeWhenModified: 'bar' }, + 'Object modified fires' + ); off.unsubscribe(); myTestClass.set({ changeWhenModified: 'foobaz' }); myTestClass.setMyProp3(true); - t.deepEqual(myTestClass.get('changeWhenModified'), { changeWhenModified: 'foobaz' }, 'Object modified does not fire after unsubscribe'); - - t.ok(myTestClass.set({ myProp4: 99.9, myProp5: [1, 1, 1, 1] }), 'Test mult-set'); + t.deepEqual( + myTestClass.get('changeWhenModified'), + { changeWhenModified: 'foobaz' }, + 'Object modified does not fire after unsubscribe' + ); + + t.ok( + myTestClass.set({ myProp4: 99.9, myProp5: [1, 1, 1, 1] }), + 'Test mult-set' + ); t.equal(myTestClass.getMyProp4(), 99.9, 'Float get should match multi-set'); - t.deepEqual(myTestClass.getMyProp5(), [1, 1, 1, 1], 'Array multi-set should match get'); + t.deepEqual( + myTestClass.getMyProp5(), + [1, 1, 1, 1], + 'Array multi-set should match get' + ); t.ok(myTestClass.isA('vtkMyClass')); t.ok(myTestClass.isA('vtkObject')); diff --git a/Sources/Testing/testSerialization.js b/Sources/Testing/testSerialization.js index 3ff687ae919..056a748060c 100644 --- a/Sources/Testing/testSerialization.js +++ b/Sources/Testing/testSerialization.js @@ -1,13 +1,13 @@ -import test from 'tape-catch'; -import vtk from 'vtk.js/Sources/vtk'; +import test from 'tape-catch'; +import vtk from 'vtk.js/Sources/vtk'; import macro from 'vtk.js/Sources/macro'; -import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; -import vtkPoints from 'vtk.js/Sources/Common/Core/Points'; -import vtkLookupTable from 'vtk.js/Sources/Common/Core/LookupTable'; +import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray'; +import vtkPoints from 'vtk.js/Sources/Common/Core/Points'; +import vtkLookupTable from 'vtk.js/Sources/Common/Core/LookupTable'; import vtkScalarsToColors from 'vtk.js/Sources/Common/Core/ScalarsToColors'; -import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; +import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; const { vtkDebugMacro } = macro; @@ -35,8 +35,16 @@ const SERIALIZABLE_CLASSES = { vtkPolyData: { class: vtkPolyData, data: { - points: { vtkClass: 'vtkPoints', values: [0, 0, 0, 1, 1, 1, 2, 2, 2], numberOfComponents: 3 }, - polys: { vtkClass: 'vtkDataArray', values: [1, 0, 1, 2], dataType: 'Uint32Array' }, + points: { + vtkClass: 'vtkPoints', + values: [0, 0, 0, 1, 1, 1, 2, 2, 2], + numberOfComponents: 3, + }, + polys: { + vtkClass: 'vtkDataArray', + values: [1, 0, 1, 2], + dataType: 'Uint32Array', + }, }, }, }; @@ -46,7 +54,8 @@ function ignoreMTime(json) { } classToTest.forEach((testName) => { - const klass = SERIALIZABLE_CLASSES[testName].class || SERIALIZABLE_CLASSES[testName]; + const klass = + SERIALIZABLE_CLASSES[testName].class || SERIALIZABLE_CLASSES[testName]; const initData = SERIALIZABLE_CLASSES[testName].data; const debug = SERIALIZABLE_CLASSES[testName].debug; @@ -66,9 +75,12 @@ classToTest.forEach((testName) => { } t.notEqual(instance, instance2, 'We have two different instances'); - t.deepEqual(ignoreMTime(state), ignoreMTime(state2), 'But same serialized content'); + t.deepEqual( + ignoreMTime(state), + ignoreMTime(state2), + 'But same serialized content' + ); t.end(); }); }); - diff --git a/Sources/Testing/testUtils.js b/Sources/Testing/testUtils.js index 15fc8b37cc6..8ce7d8f94e7 100644 --- a/Sources/Testing/testUtils.js +++ b/Sources/Testing/testUtils.js @@ -2,7 +2,14 @@ import resemble from 'resemblejs'; let REMOVE_DOM_ELEMENTS = true; -function compareImages(image, baselines, testName, tapeContext, threshold = 0.5, nextCallback = null) { +function compareImages( + image, + baselines, + testName, + tapeContext, + threshold = 0.5, + nextCallback = null +) { const nbBaselines = baselines.length; let minDelta = 100; let isSameDimensions = false; @@ -12,7 +19,9 @@ function compareImages(image, baselines, testName, tapeContext, threshold = 0.5, tapeContext.ok(isSameDimensions, 'Image match resolution'); if (minDelta >= threshold) { - tapeContext.fail(` vs `); + tapeContext.fail( + ` vs ` + ); } if (nextCallback) { @@ -23,14 +32,19 @@ function compareImages(image, baselines, testName, tapeContext, threshold = 0.5, } baselines.forEach((baseline, idx) => { - resemble(baseline).compareTo(image).onComplete((data) => { - minDelta = (minDelta < data.misMatchPercentage) ? minDelta : data.misMatchPercentage; - isSameDimensions = isSameDimensions || data.isSameDimensions; - - if (idx + 1 === nbBaselines) { - done(); - } - }); + resemble(baseline) + .compareTo(image) + .onComplete((data) => { + minDelta = + minDelta < data.misMatchPercentage + ? minDelta + : data.misMatchPercentage; + isSameDimensions = isSameDimensions || data.isSameDimensions; + + if (idx + 1 === nbBaselines) { + done(); + } + }); }); } @@ -62,7 +76,7 @@ function createGarbageCollector(testContext) { } // vtkObject handling - resources.sort((a, b) => (b.priority - a.priority)); + resources.sort((a, b) => b.priority - a.priority); resources.forEach(({ vtkObj }) => { if (vtkObj) { vtkObj.delete(); @@ -93,7 +107,6 @@ function removeDOM() { REMOVE_DOM_ELEMENTS = true; } - export default { compareImages, createGarbageCollector, diff --git a/Sources/favicon.js b/Sources/favicon.js index c083f15ca01..ce13518e025 100644 --- a/Sources/favicon.js +++ b/Sources/favicon.js @@ -4,7 +4,10 @@ if (head) { [16, 32, 96, 160, 196].forEach((resolution) => { const link = document.createElement('link'); link.setAttribute('rel', 'icon'); - link.setAttribute('href', `http://kitware.github.io/vtk-js/icon/favicon-${resolution}x${resolution}.png`); + link.setAttribute( + 'href', + `http://kitware.github.io/vtk-js/icon/favicon-${resolution}x${resolution}.png` + ); link.setAttribute('sizes', `${resolution}x${resolution}`); link.setAttribute('type', 'image/png'); head.appendChild(link); diff --git a/Sources/index.js b/Sources/index.js index df240639151..bcb8790ed92 100644 --- a/Sources/index.js +++ b/Sources/index.js @@ -1,9 +1,9 @@ -import Common from './Common'; -import Filters from './Filters'; -import Imaging from './Imaging'; -import Interaction from './Interaction'; -import IO from './IO'; -import Rendering from './Rendering'; +import Common from './Common'; +import Filters from './Filters'; +import Imaging from './Imaging'; +import Interaction from './Interaction'; +import IO from './IO'; +import Rendering from './Rendering'; import { getCurrentGlobalMTime } from './macro'; diff --git a/Sources/macro.js b/Sources/macro.js index 22832c274e1..9d52d946625 100644 --- a/Sources/macro.js +++ b/Sources/macro.js @@ -2,7 +2,7 @@ import vtk from './vtk'; let globalMTime = 0; -export function getCurrentGlobalMTime() { +function getCurrentGlobalMTime() { return globalMTime; } @@ -14,10 +14,24 @@ export function getCurrentGlobalMTime() { const fakeConsole = {}; function noOp() {} -const consoleMethods = ['log', 'debug', 'info', 'warn', 'error', 'time', 'timeEnd', 'group', 'groupEnd']; -consoleMethods.forEach((methodName) => { (fakeConsole[methodName] = noOp); }); - -global.console = (window.console.hasOwnProperty('log') ? window.console : fakeConsole); +const consoleMethods = [ + 'log', + 'debug', + 'info', + 'warn', + 'error', + 'time', + 'timeEnd', + 'group', + 'groupEnd', +]; +consoleMethods.forEach((methodName) => { + fakeConsole[methodName] = noOp; +}); + +global.console = window.console.hasOwnProperty('log') + ? window.console + : fakeConsole; const loggerFunctions = { debug: noOp, // Don't print debug by default @@ -27,29 +41,29 @@ const loggerFunctions = { warn: global.console.warn || noOp, }; -export function setLoggerFunction(name, fn) { +function setLoggerFunction(name, fn) { if (loggerFunctions[name]) { loggerFunctions[name] = fn || noOp; } } -export function vtkLogMacro(...args) { +function vtkLogMacro(...args) { loggerFunctions.log(...args); } -export function vtkInfoMacro(...args) { +function vtkInfoMacro(...args) { loggerFunctions.info(...args); } -export function vtkDebugMacro(...args) { +function vtkDebugMacro(...args) { loggerFunctions.debug(...args); } -export function vtkErrorMacro(...args) { +function vtkErrorMacro(...args) { loggerFunctions.error(...args); } -export function vtkWarningMacro(...args) { +function vtkWarningMacro(...args) { loggerFunctions.warn(...args); } @@ -57,7 +71,7 @@ export function vtkWarningMacro(...args) { // capitilze provided string // ---------------------------------------------------------------------------- -export function capitalize(str) { +function capitalize(str) { return str.charAt(0).toUpperCase() + str.slice(1); } @@ -65,7 +79,7 @@ export function capitalize(str) { // Array helper // ---------------------------------------------------------------------------- -export function safeArrays(model) { +function safeArrays(model) { Object.keys(model).forEach((key) => { if (Array.isArray(model[key])) { model[key] = [].concat(model[key]); @@ -75,11 +89,11 @@ export function safeArrays(model) { // ---------------------------------------------------------------------------- -export function enumToString(e, value) { - return Object.keys(e).find(key => e[key] === value); +function enumToString(e, value) { + return Object.keys(e).find((key) => e[key] === value); } -export function getStateArrayMapFunc(item) { +function getStateArrayMapFunc(item) { if (item.isA) { return item.getState(); } @@ -90,12 +104,12 @@ export function getStateArrayMapFunc(item) { // vtkObject: modified(), onModified(callback), delete() // ---------------------------------------------------------------------------- -export function obj(publicAPI = {}, model = {}) { +function obj(publicAPI = {}, model = {}) { // Ensure each instance as a unique ref of array safeArrays(model); const callbacks = []; - model.mtime = (Number.isInteger(model.mtime) ? model.mtime : ++globalMTime); + model.mtime = Number.isInteger(model.mtime) ? model.mtime : ++globalMTime; model.classHierarchy = ['vtkObject']; function off(index) { @@ -122,7 +136,7 @@ export function obj(publicAPI = {}, model = {}) { } model.mtime = ++globalMTime; - callbacks.forEach(callback => callback && callback(publicAPI)); + callbacks.forEach((callback) => callback && callback(publicAPI)); }; publicAPI.onModified = (callback) => { @@ -150,7 +164,8 @@ export function obj(publicAPI = {}, model = {}) { return false; }; - publicAPI.getClassName = (depth = 0) => model.classHierarchy[model.classHierarchy.length - 1 - depth]; + publicAPI.getClassName = (depth = 0) => + model.classHierarchy[model.classHierarchy.length - 1 - depth]; publicAPI.set = (map = {}, noWarning = false, noFunction = false) => { let ret = false; @@ -163,7 +178,9 @@ export function obj(publicAPI = {}, model = {}) { } else { // Set data on model directly if (['mtime'].indexOf(name) === -1 && !noWarning) { - vtkWarningMacro(`Warning: Set value to model directly ${name}, ${map[name]}`); + vtkWarningMacro( + `Warning: Set value to model directly ${name}, ${map[name]}` + ); } model[name] = map[name]; ret = true; @@ -183,10 +200,10 @@ export function obj(publicAPI = {}, model = {}) { return subset; }; - publicAPI.getReferenceByName = val => model[val]; + publicAPI.getReferenceByName = (val) => model[val]; publicAPI.delete = () => { - Object.keys(model).forEach(field => delete model[field]); + Object.keys(model).forEach((field) => delete model[field]); callbacks.forEach((el, index) => off(index)); // Flag the instance being deleted @@ -195,7 +212,9 @@ export function obj(publicAPI = {}, model = {}) { // Add serialization support publicAPI.getState = () => { - const jsonArchive = Object.assign({}, model, { vtkClass: publicAPI.getClassName() }); + const jsonArchive = Object.assign({}, model, { + vtkClass: publicAPI.getClassName(), + }); // Convert every vtkObject to its serializable form Object.keys(jsonArchive).forEach((keyName) => { @@ -210,9 +229,11 @@ export function obj(publicAPI = {}, model = {}) { // Sort resulting object by key name const sortedObj = {}; - Object.keys(jsonArchive).sort().forEach((name) => { - sortedObj[name] = jsonArchive[name]; - }); + Object.keys(jsonArchive) + .sort() + .forEach((name) => { + sortedObj[name] = jsonArchive[name]; + }); // Remove mtime if (sortedObj.mtime) { @@ -225,7 +246,9 @@ export function obj(publicAPI = {}, model = {}) { // Add shallowCopy(otherInstance) support publicAPI.shallowCopy = (other, debug = false) => { if (other.getClassName() !== publicAPI.getClassName()) { - throw new Error(`Cannot ShallowCopy ${other.getClassName()} into ${publicAPI.getClassName()}`); + throw new Error( + `Cannot ShallowCopy ${other.getClassName()} into ${publicAPI.getClassName()}` + ); } const otherModel = other.get(); @@ -255,7 +278,7 @@ export function obj(publicAPI = {}, model = {}) { // getXXX: add getters // ---------------------------------------------------------------------------- -export function get(publicAPI, model, fieldNames) { +function get(publicAPI, model, fieldNames) { fieldNames.forEach((field) => { if (typeof field === 'object') { publicAPI[`get${capitalize(field.name)}`] = () => model[field.name]; @@ -286,7 +309,11 @@ const objectSetterMap = { } if (typeof value === 'number') { if (model[field.name] !== value) { - if (Object.keys(field.enum).map(key => field.enum[key]).indexOf(value) !== -1) { + if ( + Object.keys(field.enum) + .map((key) => field.enum[key]) + .indexOf(value) !== -1 + ) { model[field.name] = value; publicAPI.modified(); return true; @@ -296,7 +323,9 @@ const objectSetterMap = { } return false; } - vtkErrorMacro(`Set Enum with invalid argument (String/Number) ${field}, ${value}`); + vtkErrorMacro( + `Set Enum with invalid argument (String/Number) ${field}, ${value}` + ); throw new TypeError('Set Enum with invalid argument (String/Number)'); }; }, @@ -329,12 +358,18 @@ function findSetter(field) { }; } -export function set(publicAPI, model, fields) { +function set(publicAPI, model, fields) { fields.forEach((field) => { if (typeof field === 'object') { - publicAPI[`set${capitalize(field.name)}`] = findSetter(field)(publicAPI, model); + publicAPI[`set${capitalize(field.name)}`] = findSetter(field)( + publicAPI, + model + ); } else { - publicAPI[`set${capitalize(field)}`] = findSetter(field)(publicAPI, model); + publicAPI[`set${capitalize(field)}`] = findSetter(field)( + publicAPI, + model + ); } }); } @@ -343,7 +378,7 @@ export function set(publicAPI, model, fields) { // set/get XXX: add both setters and getters // ---------------------------------------------------------------------------- -export function setGet(publicAPI, model, fieldNames) { +function setGet(publicAPI, model, fieldNames) { get(publicAPI, model, fieldNames); set(publicAPI, model, fieldNames); } @@ -353,7 +388,7 @@ export function setGet(publicAPI, model, fieldNames) { // getXXXByReference: add getters for object of type array without copy // ---------------------------------------------------------------------------- -export function getArray(publicAPI, model, fieldNames) { +function getArray(publicAPI, model, fieldNames) { fieldNames.forEach((field) => { publicAPI[`get${capitalize(field)}`] = () => [].concat(model[field]); publicAPI[`get${capitalize(field)}ByReference`] = () => model[field]; @@ -366,7 +401,7 @@ export function getArray(publicAPI, model, fieldNames) { // set...From: fast path to copy the content of an array to the current one without call to modified. // ---------------------------------------------------------------------------- -export function setArray(publicAPI, model, fieldNames, size, defaultVal = undefined) { +function setArray(publicAPI, model, fieldNames, size, defaultVal = undefined) { fieldNames.forEach((field) => { publicAPI[`set${capitalize(field)}`] = (...args) => { if (model.deleted) { @@ -377,7 +412,9 @@ export function setArray(publicAPI, model, fieldNames, size, defaultVal = undefi let array = args; // allow an array passed as a single arg. if (array.length === 1 && Array.isArray(array[0])) { + /* eslint-disable prefer-destructuring */ array = array[0]; + /* eslint-enable prefer-destructuring */ } if (array.length !== size) { @@ -418,7 +455,13 @@ export function setArray(publicAPI, model, fieldNames, size, defaultVal = undefi // set/get XXX: add setter and getter for object of type array // ---------------------------------------------------------------------------- -export function setGetArray(publicAPI, model, fieldNames, size, defaultVal = undefined) { +function setGetArray( + publicAPI, + model, + fieldNames, + size, + defaultVal = undefined +) { getArray(publicAPI, model, fieldNames); setArray(publicAPI, model, fieldNames, size, defaultVal); } @@ -427,7 +470,7 @@ export function setGetArray(publicAPI, model, fieldNames, size, defaultVal = und // vtkAlgorithm: setInputData(), setInputConnection(), getOutput(), getOutputPort() // ---------------------------------------------------------------------------- -export function algo(publicAPI, model, numberOfInputs, numberOfOutputs) { +function algo(publicAPI, model, numberOfInputs, numberOfOutputs) { if (model.inputData) { model.inputData = model.inputData.map(vtk); } else { @@ -553,14 +596,20 @@ export function algo(publicAPI, model, numberOfInputs, numberOfOutputs) { count = model.numberOfInputs; while (count--) { - if (model.inputConnection[count] && model.inputConnection[count].filter.shouldUpdate()) { + if ( + model.inputConnection[count] && + model.inputConnection[count].filter.shouldUpdate() + ) { return true; } } count = model.numberOfInputs; while (count--) { - if (publicAPI.getInputData(count) && publicAPI.getInputData(count).getMTime() > minOutputMTime) { + if ( + publicAPI.getInputData(count) && + publicAPI.getInputData(count).getMTime() > minOutputMTime + ) { return true; } } @@ -618,15 +667,26 @@ export function algo(publicAPI, model, numberOfInputs, numberOfOutputs) { const arrayDesc = model.inputArrayToProcess[inputPort]; const ds = model.inputData[inputPort]; if (arrayDesc && ds) { - return ds[`get${arrayDesc.fieldAssociation}`]().getArray(arrayDesc.arrayName); + return ds[`get${arrayDesc.fieldAssociation}`]().getArray( + arrayDesc.arrayName + ); } return null; }; - publicAPI.setInputArrayToProcess = (inputPort, arrayName, fieldAssociation, attributeType = 'Scalars') => { + publicAPI.setInputArrayToProcess = ( + inputPort, + arrayName, + fieldAssociation, + attributeType = 'Scalars' + ) => { while (model.inputArrayToProcess.length < inputPort) { model.inputArrayToProcess.push(null); } - model.inputArrayToProcess[inputPort] = { arrayName, fieldAssociation, attributeType }; + model.inputArrayToProcess[inputPort] = { + arrayName, + fieldAssociation, + attributeType, + }; }; } @@ -634,7 +694,7 @@ export function algo(publicAPI, model, numberOfInputs, numberOfOutputs) { // Event handling: onXXX(callback), invokeXXX(args...) // ---------------------------------------------------------------------------- -export function event(publicAPI, model, eventName) { +function event(publicAPI, model, eventName) { const callbacks = []; const previousDelete = publicAPI.delete; @@ -687,7 +747,7 @@ export function event(publicAPI, model, eventName) { // newInstance // ---------------------------------------------------------------------------- -export function newInstance(extend, className) { +function newInstance(extend, className) { const constructor = (initialValues = {}) => { const model = {}; const publicAPI = {}; @@ -707,19 +767,24 @@ export function newInstance(extend, className) { // Chain function calls // ---------------------------------------------------------------------------- -export function chain(...fn) { - return (...args) => fn.filter(i => !!i).forEach(i => i(...args)); +function chain(...fn) { + return (...args) => fn.filter((i) => !!i).forEach((i) => i(...args)); } // ---------------------------------------------------------------------------- // Some utility methods for vtk objects // ---------------------------------------------------------------------------- -export function isVtkObject(instance) { +function isVtkObject(instance) { return instance && instance.isA && instance.isA('vtkObject'); } -export function traverseInstanceTree(instance, extractFunction, accumulator = [], visitedInstances = []) { +function traverseInstanceTree( + instance, + extractFunction, + accumulator = [], + visitedInstances = [] +) { if (isVtkObject(instance)) { if (visitedInstances.indexOf(instance) >= 0) { // avoid cycles @@ -738,10 +803,20 @@ export function traverseInstanceTree(instance, extractFunction, accumulator = [] const modelObj = model[key]; if (Array.isArray(modelObj)) { modelObj.forEach((subObj) => { - traverseInstanceTree(subObj, extractFunction, accumulator, visitedInstances); + traverseInstanceTree( + subObj, + extractFunction, + accumulator, + visitedInstances + ); }); } else { - traverseInstanceTree(modelObj, extractFunction, accumulator, visitedInstances); + traverseInstanceTree( + modelObj, + extractFunction, + accumulator, + visitedInstances + ); } }); } @@ -755,17 +830,17 @@ export function traverseInstanceTree(instance, extractFunction, accumulator = [] // N milliseconds. If `immediate` is passed, trigger the function on the // leading edge, instead of the trailing. -export function debounce(func, wait, immediate) { - var timeout; +function debounce(func, wait, immediate) { + let timeout; return (...args) => { - var context = this; - var later = () => { + const context = this; + const later = () => { timeout = null; if (!immediate) { func.apply(context, args); } }; - var callNow = immediate && !timeout; + const callNow = immediate && !timeout; clearTimeout(timeout); timeout = setTimeout(later, wait); if (callNow) { @@ -796,13 +871,13 @@ function proxy(publicAPI, model, sectionName, uiDescription = []) { publicAPI.getProxyId = () => model.proxyId; // list - const propertyNames = uiDescription.map(p => p.name); + const propertyNames = uiDescription.map((p) => p.name); publicAPI.listProxyProperties = () => propertyNames; // ui handling - const ui = uiDescription.map(i => Object.assign({}, i)); + const ui = uiDescription.map((i) => Object.assign({}, i)); publicAPI.updateProxyProperty = (propertyName, propUI) => { - const prop = ui.find(p => p.name === propertyName); + const prop = ui.find((p) => p.name === propertyName); if (prop) { Object.assign(prop, propUI); } @@ -836,7 +911,9 @@ function proxy(publicAPI, model, sectionName, uiDescription = []) { } } - const newValue = sourceLink.instance[`get${capitalize(sourceLink.propertyName)}`](); + const newValue = sourceLink.instance[ + `get${capitalize(sourceLink.propertyName)}` + ](); if (newValue !== value) { value = newValue; updateInProgress = true; diff --git a/Sources/vtk.js b/Sources/vtk.js index aeacc7de19e..e6d7d6e3b98 100644 --- a/Sources/vtk.js +++ b/Sources/vtk.js @@ -18,7 +18,9 @@ export default function vtk(obj) { const constructor = factoryMapping[obj.vtkClass]; if (!constructor) { if (global.console && global.console.error) { - global.console.error(`No vtk class found for Object of type ${obj.vtkClass}`); + global.console.error( + `No vtk class found for Object of type ${obj.vtkClass}` + ); } return null; } @@ -28,7 +30,11 @@ export default function vtk(obj) { // Convert into vtkObject any nested key Object.keys(model).forEach((keyName) => { - if (model[keyName] && typeof model[keyName] === 'object' && model[keyName].vtkClass) { + if ( + model[keyName] && + typeof model[keyName] === 'object' && + model[keyName].vtkClass + ) { model[keyName] = vtk(model[keyName]); } }); @@ -41,7 +47,7 @@ export default function vtk(obj) { return newInst; } -export function register(vtkClassName, constructor) { +function register(vtkClassName, constructor) { factoryMapping[vtkClassName] = constructor; } diff --git a/package-lock.json b/package-lock.json index 31f7d8bcb5a..7b89294ff76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,95 +4,423 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@babel/code-frame": { + "version": "7.0.0-beta.31", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.31.tgz", + "integrity": "sha512-yd7CkUughvHQoEahQqcMdrZw6o/6PwUxiRkfZuVDVHCDe77mysD/suoNyk5mK6phTnRW1kyIbPHyCJgxw++LXg==", + "dev": true, + "requires": { + "chalk": "2.3.0", + "esutils": "2.0.2", + "js-tokens": "3.0.2" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } + } + }, + "@babel/helper-function-name": { + "version": "7.0.0-beta.31", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.31.tgz", + "integrity": "sha512-c+DAyp8LMm2nzSs2uXEuxp4LYGSUYEyHtU3fU57avFChjsnTmmpWmXj2dv0yUxHTEydgVAv5fIzA+4KJwoqWDA==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "7.0.0-beta.31", + "@babel/template": "7.0.0-beta.31", + "@babel/traverse": "7.0.0-beta.31", + "@babel/types": "7.0.0-beta.31" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.0.0-beta.31", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.31.tgz", + "integrity": "sha512-m7rVVX/dMLbbB9NCzKYRrrFb0qZxgpmQ4Wv6y7zEsB6skoJHRuXVeb/hAFze79vXBbuD63ci7AVHXzAdZSk9KQ==", + "dev": true, + "requires": { + "@babel/types": "7.0.0-beta.31" + } + }, + "@babel/template": { + "version": "7.0.0-beta.31", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.0.0-beta.31.tgz", + "integrity": "sha512-97IRmLvoDhIDSQkqklVt3UCxJsv0LUEVb/0DzXWtc8Lgiyxj567qZkmTG9aR21CmcJVVIvq2Y/moZj4oEpl5AA==", + "dev": true, + "requires": { + "@babel/code-frame": "7.0.0-beta.31", + "@babel/types": "7.0.0-beta.31", + "babylon": "7.0.0-beta.31", + "lodash": "4.17.4" + }, + "dependencies": { + "babylon": { + "version": "7.0.0-beta.31", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.31.tgz", + "integrity": "sha512-6lm2mV3S51yEnKmQQNnswoABL1U1H1KHoCCVwdwI3hvIv+W7ya4ki7Aw4o4KxtUHjNKkK5WpZb22rrMMOcJXJQ==", + "dev": true + } + } + }, + "@babel/traverse": { + "version": "7.0.0-beta.31", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.0.0-beta.31.tgz", + "integrity": "sha512-3N+VJW+KlezEjFBG7WSYeMyC5kIqVLPb/PGSzCDPFcJrnArluD1GIl7Y3xC7cjKiTq2/JohaLWHVPjJWHlo9Gg==", + "dev": true, + "requires": { + "@babel/code-frame": "7.0.0-beta.31", + "@babel/helper-function-name": "7.0.0-beta.31", + "@babel/types": "7.0.0-beta.31", + "babylon": "7.0.0-beta.31", + "debug": "3.1.0", + "globals": "10.4.0", + "invariant": "2.2.2", + "lodash": "4.17.4" + }, + "dependencies": { + "babylon": { + "version": "7.0.0-beta.31", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.31.tgz", + "integrity": "sha512-6lm2mV3S51yEnKmQQNnswoABL1U1H1KHoCCVwdwI3hvIv+W7ya4ki7Aw4o4KxtUHjNKkK5WpZb22rrMMOcJXJQ==", + "dev": true + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "globals": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-10.4.0.tgz", + "integrity": "sha512-uNUtxIZpGyuaq+5BqGGQHsL4wUlJAXRqOm6g3Y48/CWNGTLONgBibI0lh6lGxjR2HljFYUfszb+mk4WkgMntsA==", + "dev": true + } + } + }, + "@babel/types": { + "version": "7.0.0-beta.31", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.0.0-beta.31.tgz", + "integrity": "sha512-exAHB+NeFGxkfQ5dSUD03xl3zYGneeSk2Mw2ldTt/nTvYxuDiuSp3DlxgUBgzbdTFG4fbwPk0WtKWOoTXCmNGg==", + "dev": true, + "requires": { + "esutils": "2.0.2", + "lodash": "4.17.4", + "to-fast-properties": "2.0.0" + }, + "dependencies": { + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "dev": true + } + } + }, "@semantic-release/commit-analyzer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@semantic-release/commit-analyzer/-/commit-analyzer-2.0.0.tgz", - "integrity": "sha1-kk0eLDAWfGpHK+2fZu6Pjgd0ibI=", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@semantic-release/commit-analyzer/-/commit-analyzer-5.0.0.tgz", + "integrity": "sha512-DWqE0EwLfqawNzH/cPd987KyplsvwmlKTr6Oz/hPe2NuIwexD8Zt7EvBvHt35udcRsK0EK6+QZTIz06Fr/gIsg==", "dev": true, "requires": { - "conventional-changelog": "0.0.17" + "conventional-changelog-angular": "1.6.0", + "conventional-commits-parser": "2.1.0", + "debug": "3.1.0", + "import-from": "2.1.0", + "lodash": "4.17.4" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } } }, "@semantic-release/condition-travis": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/@semantic-release/condition-travis/-/condition-travis-5.0.2.tgz", - "integrity": "sha1-9Lt3emxttVZdcHVKm2KSM71KZZc=", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/@semantic-release/condition-travis/-/condition-travis-7.1.4.tgz", + "integrity": "sha512-oH7XbwMjzfWqHFNZyXS0JDw34qH7ulS5SY14R1qFHxAxtFQISyRL4Gfdq7BoLMd4pHuBhLWqHEWcK3SxwfEclg==", "dev": true, "requires": { - "@semantic-release/error": "1.0.0", - "semver": "5.4.1", - "travis-deploy-once": "1.0.0-node-0.10-support" + "@semantic-release/error": "2.1.0", + "github": "13.0.1", + "parse-github-url": "1.0.2", + "travis-deploy-once": "4.3.0" } }, "@semantic-release/error": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@semantic-release/error/-/error-1.0.0.tgz", - "integrity": "sha1-u4+O7t1cf4xG+Ws37znhuMN2wcw=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@semantic-release/error/-/error-2.1.0.tgz", + "integrity": "sha512-r3pcw7lhzoSalM55O7L8R3gNq8AnZ7OS7RReHqJDTIuyRaQbtfZ+9S8Krvh/BSnTMYYhs4TgZctb6pOamegUtQ==", "dev": true }, - "@semantic-release/last-release-npm": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@semantic-release/last-release-npm/-/last-release-npm-1.2.1.tgz", - "integrity": "sha1-/3SBQuzxU1S4M6hroYIF9/zllO4=", + "@semantic-release/github": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/@semantic-release/github/-/github-2.2.3.tgz", + "integrity": "sha512-tmZLX1hiTpe3Osfkn4qYEdx3zz9TIeM3SoE40lN9588ay1GODzfyjt5sCOnD0t10iLA/+T/GxDwuKCi3VzdbGA==", "dev": true, "requires": { - "@semantic-release/error": "1.0.0", - "npm-registry-client": "7.5.0", - "npmlog": "1.2.1" + "@semantic-release/error": "2.1.0", + "debug": "3.1.0", + "fs-extra": "5.0.0", + "github": "13.0.1", + "globby": "7.1.1", + "lodash": "4.17.4", + "mime": "2.1.0", + "p-reduce": "1.0.0", + "parse-github-url": "1.0.2", + "url-join": "2.0.2" }, "dependencies": { - "are-we-there-yet": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.0.6.tgz", - "integrity": "sha1-otKMkxAqpsyWJFomy5VN4G7FPww=", + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, "requires": { - "delegates": "1.0.0", - "readable-stream": "2.0.6" + "ms": "2.0.0" } }, - "gauge": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-1.2.7.tgz", - "integrity": "sha1-6c7FSD09TuDvRLYKfZnkk14TbZM=", + "fs-extra": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz", + "integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==", "dev": true, "requires": { - "ansi": "0.3.1", - "has-unicode": "2.0.1", - "lodash.pad": "4.5.1", - "lodash.padend": "4.6.1", - "lodash.padstart": "4.6.1" + "graceful-fs": "4.1.11", + "jsonfile": "4.0.0", + "universalify": "0.1.1" } }, - "npmlog": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-1.2.1.tgz", - "integrity": "sha1-KOe+YZYJtT960d0wChDWTXFiaLY=", + "globby": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/globby/-/globby-7.1.1.tgz", + "integrity": "sha1-+yzP+UAfhgCUXfral0QMypcrhoA=", + "dev": true, + "requires": { + "array-union": "1.0.2", + "dir-glob": "2.0.0", + "glob": "7.1.2", + "ignore": "3.3.7", + "pify": "3.0.0", + "slash": "1.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11" + } + }, + "mime": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.1.0.tgz", + "integrity": "sha512-jPEuocEVyg24I7hWcF6EL5qH0OQ3Ficy95tXA9eNBN6qXsIopYi/CJl3ldTUR+Sljt2rP2SkWpeTcAMon/pjKA==", + "dev": true + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + } + } + }, + "@semantic-release/npm": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/@semantic-release/npm/-/npm-2.6.1.tgz", + "integrity": "sha512-7O+EKUlcKdk4LiyMYRBVOtFLsW2NmDQAJhbuetGZ+Dx9kz2iEIIPGAIpiP+J8cC17Fi/aseFNcpWKpkMmJ81ZQ==", + "dev": true, + "requires": { + "@semantic-release/error": "2.1.0", + "debug": "3.1.0", + "execa": "0.8.0", + "fs-extra": "5.0.0", + "lodash": "4.17.4", + "nerf-dart": "1.0.0", + "npm-conf": "1.1.3", + "npm-registry-client": "8.5.0", + "read-pkg": "3.0.0", + "registry-auth-token": "3.3.1" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "fs-extra": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz", + "integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "jsonfile": "4.0.0", + "universalify": "0.1.1" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11" + } + }, + "load-json-file": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", + "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "parse-json": "4.0.0", + "pify": "3.0.0", + "strip-bom": "3.0.0" + } + }, + "parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "dev": true, + "requires": { + "error-ex": "1.3.1", + "json-parse-better-errors": "1.0.1" + } + }, + "path-type": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", + "dev": true, + "requires": { + "pify": "3.0.0" + } + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + }, + "read-pkg": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", + "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", "dev": true, "requires": { - "ansi": "0.3.1", - "are-we-there-yet": "1.0.6", - "gauge": "1.2.7" + "load-json-file": "4.0.0", + "normalize-package-data": "2.4.0", + "path-type": "3.0.0" } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true } } }, "@semantic-release/release-notes-generator": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@semantic-release/release-notes-generator/-/release-notes-generator-2.0.0.tgz", - "integrity": "sha1-fF2mVolGbVNqU/36n01io70TwW4=", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@semantic-release/release-notes-generator/-/release-notes-generator-6.0.3.tgz", + "integrity": "sha512-qvO8B6kUm5cVHdBx0uAla/clAitUR3Pyl+/6a7wSp6RqExgWfa1twq1ekVRBgCHmxX1LFFmLtL3knnSXjpXj1Q==", "dev": true, "requires": { - "conventional-changelog": "0.0.17", - "github-url-from-git": "1.5.0" + "conventional-changelog-angular": "1.6.0", + "conventional-changelog-writer": "2.0.3", + "conventional-commits-parser": "2.1.0", + "debug": "3.1.0", + "get-stream": "3.0.0", + "git-url-parse": "7.0.2", + "import-from": "2.1.0", + "into-stream": "3.1.0", + "lodash": "4.17.4" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } } }, + "@sindresorhus/is": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.6.0.tgz", + "integrity": "sha1-OD9Faya8lseInwMyB59DWLFsWNw=", + "dev": true + }, "@types/node": { - "version": "6.0.89", - "resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.89.tgz", - "integrity": "sha512-Z/67L97+6H1qJiEEHSN1SQapkWjDss1D90rAnFcQ6UxKkah9juzotK5UNEP1bDv/0lJ3NAQTnVfc/JWdgCGruA==", + "version": "8.5.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.5.5.tgz", + "integrity": "sha512-JRnfoh0Ll4ElmIXKxbUfcOodkGvcNHljct6mO1X9hE/mlrMzAx0hYCLAD7sgT53YAY1HdlpzUcV0CkmDqUqTuA==", "dev": true }, + "JSONStream": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.2.tgz", + "integrity": "sha1-wQI3G27Dp887hHygDCC7D85Mbeo=", + "dev": true, + "requires": { + "jsonparse": "1.3.1", + "through": "2.3.8" + } + }, "abbrev": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", @@ -110,9 +438,9 @@ } }, "acorn": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.2.tgz", - "integrity": "sha512-o96FZLJBPY1lvTuJylGA9Bk3t/GKPPJG8H0ydQQl01crzwJgspa4AEIq/pVTXigmK0PHVQhiAtn8WMBLL9D2WA==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.3.0.tgz", + "integrity": "sha512-Yej+zOJ1Dm/IMZzzj78OntP/r3zHEaKcyNoU2lAaxPtrseM6rF0xwqoz5Q5ysAiED9hTjI2hgtvLXitlCN1/Ug==", "dev": true }, "acorn-dynamic-import": { @@ -156,37 +484,30 @@ "dev": true }, "agent-base": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-2.1.1.tgz", - "integrity": "sha1-1t4Q1a9hMtW9aSQn1G/FOFOQlMc=", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.1.2.tgz", + "integrity": "sha512-VE6QoEdaugY86BohRtfGmTDabxdU5sCKOkbcPA6PXKJsRzEi/7A3RCTxJal1ft/4qSfPht5/iQLhMh/wzSkkNw==", "dev": true, "requires": { - "extend": "3.0.1", - "semver": "5.0.3" - }, - "dependencies": { - "semver": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.0.3.tgz", - "integrity": "sha1-d0Zt5YnNXTyV8TiqeLxWmjy10no=", - "dev": true - } + "es6-promisify": "5.0.0" } }, "ajv": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", "dev": true, "requires": { "co": "4.6.0", - "json-stable-stringify": "1.0.1" + "fast-deep-equal": "1.0.0", + "fast-json-stable-stringify": "2.0.0", + "json-schema-traverse": "0.3.1" } }, "ajv-keywords": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz", - "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", + "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=", "dev": true }, "align-text": { @@ -212,32 +533,68 @@ "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", "dev": true }, - "ansi": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/ansi/-/ansi-0.3.1.tgz", - "integrity": "sha1-DELU+xcWDVqa8eSEus4cZpIsGyE=", - "dev": true - }, - "ansi-escape": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ansi-escape/-/ansi-escape-1.1.0.tgz", - "integrity": "sha1-ithZ6Epp4P+Rd5aUeTqS5OjAXpk=", - "dev": true - }, - "ansi-escapes": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", - "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", - "dev": true - }, - "ansi-html": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/ansi-html/-/ansi-html-0.0.7.tgz", - "integrity": "sha1-gTWEAhliqenm/QOflA0S9WynhZ4=", - "dev": true - }, - "ansi-regex": { - "version": "2.1.1", + "ansi-align": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-2.0.0.tgz", + "integrity": "sha1-w2rsy6VjuJzrVW82kPCx2eNUf38=", + "dev": true, + "requires": { + "string-width": "2.1.1" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } + } + } + }, + "ansi-escape": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-escape/-/ansi-escape-1.1.0.tgz", + "integrity": "sha1-ithZ6Epp4P+Rd5aUeTqS5OjAXpk=", + "dev": true + }, + "ansi-escapes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", + "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", + "dev": true + }, + "ansi-html": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/ansi-html/-/ansi-html-0.0.7.tgz", + "integrity": "sha1-gTWEAhliqenm/QOflA0S9WynhZ4=", + "dev": true + }, + "ansi-regex": { + "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true @@ -248,6 +605,12 @@ "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", "dev": true }, + "ansicolors": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/ansicolors/-/ansicolors-0.2.1.tgz", + "integrity": "sha1-vgiVmQl7dKXJxKhKDNvNtivYeu8=", + "dev": true + }, "anymatch": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz", @@ -269,6 +632,7 @@ "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz", "integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=", "dev": true, + "optional": true, "requires": { "delegates": "1.0.0", "readable-stream": "2.0.6" @@ -283,10 +647,16 @@ "sprintf-js": "1.0.3" } }, + "argv-formatter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/argv-formatter/-/argv-formatter-1.0.0.tgz", + "integrity": "sha1-oMoMvCmltz6Dbuvhy/bF4OTrgvk=", + "dev": true + }, "aria-query": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-0.5.0.tgz", - "integrity": "sha1-heMVLNjMW6sY2+1hzZxPzlT6ecM=", + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-0.7.0.tgz", + "integrity": "sha512-/r2lHl09V3o74+2MLKEdewoj37YZqiQZnfen1O4iNlrOjUgeKuu1U2yF3iKh6HJxqF+OXkLMfQv65Z/cvxD6vA==", "dev": true, "requires": { "ast-types-flow": "0.0.7" @@ -307,6 +677,12 @@ "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "dev": true + }, "array-find": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/array-find/-/array-find-1.0.0.tgz", @@ -325,6 +701,12 @@ "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=", "dev": true }, + "array-ify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz", + "integrity": "sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=", + "dev": true + }, "array-includes": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz", @@ -332,7 +714,7 @@ "dev": true, "requires": { "define-properties": "1.1.2", - "es-abstract": "1.9.0" + "es-abstract": "1.10.0" } }, "array-slice": { @@ -345,6 +727,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "dev": true, "requires": { "array-uniq": "1.0.3" } @@ -352,7 +735,8 @@ "array-uniq": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", - "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=" + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "dev": true }, "array-unique": { "version": "0.2.1", @@ -385,9 +769,9 @@ "dev": true }, "asn1.js": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.9.1.tgz", - "integrity": "sha1-SLokC0WpKA6UdImQull9IWYX/UA=", + "version": "4.9.2", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.9.2.tgz", + "integrity": "sha512-b/OsSjvWEo8Pi8H0zsDd2P6Uqo2TK2pH8gNLSJtNLM2Db0v2QaAZ0pBQJXVjAn4gBuugeVDr7s63ZogpUIwWDg==", "dev": true, "requires": { "bn.js": "4.11.8", @@ -410,6 +794,12 @@ "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "dev": true }, + "assign-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", + "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "dev": true + }, "ast-types": { "version": "0.9.6", "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.9.6.tgz", @@ -423,12 +813,10 @@ "dev": true }, "async": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/async/-/async-2.1.4.tgz", - "integrity": "sha1-LSFgx3iAMuTdbL4lAvH5osj2zeQ=", - "requires": { - "lodash": "4.17.4" - } + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true }, "async-each": { "version": "1.0.1", @@ -436,23 +824,35 @@ "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", "dev": true }, + "async-limiter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", + "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", + "dev": true + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", "dev": true }, + "atob": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.0.3.tgz", + "integrity": "sha1-GcenYEc3dEaPILLS0DNyrX1Mv10=", + "dev": true + }, "autoprefixer": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-7.1.1.tgz", - "integrity": "sha1-l7yFTH0Ll5+NZIneVHoNF/swf20=", + "version": "7.2.4", + "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-7.2.4.tgz", + "integrity": "sha512-am8jJ7Rbh1sy7FvLvNxxQScWvhv2FwLAS3bIhvrZpx9HbX5PEcc/7v6ecgpWuiu0Dwlj+p/z/1boHd8x60JFwA==", "dev": true, "requires": { - "browserslist": "2.5.1", - "caniuse-lite": "1.0.30000746", + "browserslist": "2.11.0", + "caniuse-lite": "1.0.30000787", "normalize-range": "0.1.2", "num2fraction": "1.2.2", - "postcss": "6.0.13", + "postcss": "6.0.15", "postcss-value-parser": "3.3.0" } }, @@ -489,9 +889,9 @@ } }, "babel-core": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.24.1.tgz", - "integrity": "sha1-jEKFZNzh4fQfszfsNPTDsCK1rYM=", + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.0.tgz", + "integrity": "sha1-rzL3izGm/O8RnIew/Y2XU/A6C7g=", "dev": true, "requires": { "babel-code-frame": "6.26.0", @@ -504,7 +904,7 @@ "babel-traverse": "6.26.0", "babel-types": "6.26.0", "babylon": "6.18.0", - "convert-source-map": "1.5.0", + "convert-source-map": "1.5.1", "debug": "2.6.9", "json5": "0.5.1", "lodash": "4.17.4", @@ -516,15 +916,25 @@ } }, "babel-eslint": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-7.2.3.tgz", - "integrity": "sha1-sv4tgBJkcPXBlELcdXJTqJdxCCc=", + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-8.1.2.tgz", + "integrity": "sha512-IE+glF8t0lLoldylN7JyR8gT7e3jwyuNH2ds8g3UVUwGob/U4iT7Xpsiq2kQ8QGLb0eX4RcQXNqeW6mgPysu9A==", "dev": true, "requires": { - "babel-code-frame": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0", - "babylon": "6.18.0" + "@babel/code-frame": "7.0.0-beta.31", + "@babel/traverse": "7.0.0-beta.31", + "@babel/types": "7.0.0-beta.31", + "babylon": "7.0.0-beta.31", + "eslint-scope": "3.7.1", + "eslint-visitor-keys": "1.0.0" + }, + "dependencies": { + "babylon": { + "version": "7.0.0-beta.31", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.31.tgz", + "integrity": "sha512-6lm2mV3S51yEnKmQQNnswoABL1U1H1KHoCCVwdwI3hvIv+W7ya4ki7Aw4o4KxtUHjNKkK5WpZb22rrMMOcJXJQ==", + "dev": true + } } }, "babel-generator": { @@ -543,6 +953,17 @@ "trim-right": "1.0.1" } }, + "babel-helper-builder-binary-assignment-operator-visitor": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz", + "integrity": "sha1-zORReto1b0IgvK6KAsKzRvmlZmQ=", + "dev": true, + "requires": { + "babel-helper-explode-assignable-expression": "6.24.1", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" + } + }, "babel-helper-builder-react-jsx": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-helper-builder-react-jsx/-/babel-helper-builder-react-jsx-6.26.0.tgz", @@ -578,11 +999,16 @@ "lodash": "4.17.4" } }, - "babel-helper-flip-expressions": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/babel-helper-flip-expressions/-/babel-helper-flip-expressions-0.1.2.tgz", - "integrity": "sha1-d/ZlL53pxCQB2Ce9RuvSEJ4+8Yo=", - "dev": true + "babel-helper-explode-assignable-expression": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz", + "integrity": "sha1-8luCz33BBDPFX3BZLVdGQArCLKo=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" + } }, "babel-helper-function-name": { "version": "6.24.1", @@ -638,6 +1064,19 @@ "lodash": "4.17.4" } }, + "babel-helper-remap-async-to-generator": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz", + "integrity": "sha1-XsWBgnrXI/7N04HxySg5BnbkVRs=", + "dev": true, + "requires": { + "babel-helper-function-name": "6.24.1", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" + } + }, "babel-helper-replace-supers": { "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz", @@ -663,12 +1102,12 @@ } }, "babel-loader": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-7.0.0.tgz", - "integrity": "sha1-LkOma+4f/0RwUz0EAsikUy+vuvc=", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-7.1.2.tgz", + "integrity": "sha512-jRwlFbINAeyDStqK6Dd5YuY0k5YuzQUvlz2ZamuXrXmxav3pNqe9vfJ402+2G+OmlJSXxCOpB6Uz0INM7RQe2A==", "dev": true, "requires": { - "find-cache-dir": "0.1.1", + "find-cache-dir": "1.0.0", "loader-utils": "1.1.0", "mkdirp": "0.5.1" }, @@ -711,18 +1150,21 @@ "dev": true, "requires": { "find-up": "2.1.0", - "istanbul-lib-instrument": "1.8.0", + "istanbul-lib-instrument": "1.9.1", "test-exclude": "4.1.1" } }, - "babel-plugin-minify-guarded-expressions": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/babel-plugin-minify-guarded-expressions/-/babel-plugin-minify-guarded-expressions-0.1.1.tgz", - "integrity": "sha1-RGwSTHJcOPk4Wf7XBsmq4c+rx/8=", - "dev": true, - "requires": { - "babel-helper-flip-expressions": "0.1.2" - } + "babel-plugin-syntax-async-functions": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz", + "integrity": "sha1-ytnK0RkbWtY0vzCuCHI5HgZHvpU=", + "dev": true + }, + "babel-plugin-syntax-exponentiation-operator": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz", + "integrity": "sha1-nufoM3KQ2pUoggGmpX9BcDF4MN4=", + "dev": true }, "babel-plugin-syntax-flow": { "version": "6.18.0", @@ -736,6 +1178,23 @@ "integrity": "sha1-CvMqmm4Tyno/1QaeYtew9Y0NiUY=", "dev": true }, + "babel-plugin-syntax-trailing-function-commas": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz", + "integrity": "sha1-ugNgk3+NBuQBgKQ/4NVhb/9TLPM=", + "dev": true + }, + "babel-plugin-transform-async-to-generator": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz", + "integrity": "sha1-ZTbjeK/2yx1VF6wOQOs+n8jQh2E=", + "dev": true, + "requires": { + "babel-helper-remap-async-to-generator": "6.24.1", + "babel-plugin-syntax-async-functions": "6.13.0", + "babel-runtime": "6.26.0" + } + }, "babel-plugin-transform-es2015-arrow-functions": { "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz", @@ -970,6 +1429,17 @@ "regexpu-core": "2.0.0" } }, + "babel-plugin-transform-exponentiation-operator": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz", + "integrity": "sha1-KrDJx/MJj6SJB3cruBP+QejeOg4=", + "dev": true, + "requires": { + "babel-helper-builder-binary-assignment-operator-visitor": "6.24.1", + "babel-plugin-syntax-exponentiation-operator": "6.13.0", + "babel-runtime": "6.26.0" + } + }, "babel-plugin-transform-flow-strip-types": { "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-flow-strip-types/-/babel-plugin-transform-flow-strip-types-6.22.0.tgz", @@ -1040,20 +1510,20 @@ } }, "babel-polyfill": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/babel-polyfill/-/babel-polyfill-6.23.0.tgz", - "integrity": "sha1-g2TKYt+Or7gwSZ9pkXdGbDsDSZ0=", + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-polyfill/-/babel-polyfill-6.26.0.tgz", + "integrity": "sha1-N5k3q8Z9eJWXCtxiHyhM2WbPIVM=", "dev": true, "requires": { "babel-runtime": "6.26.0", - "core-js": "2.5.1", + "core-js": "2.5.3", "regenerator-runtime": "0.10.5" }, "dependencies": { "core-js": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.1.tgz", - "integrity": "sha1-rmh03GaTd4m4B1T/VCjfZoGcpQs=", + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz", + "integrity": "sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4=", "dev": true }, "regenerator-runtime": { @@ -1064,13 +1534,15 @@ } } }, - "babel-preset-es2015": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz", - "integrity": "sha1-1EBQ1rwsn+6nAqrzjXJ6AhBTiTk=", + "babel-preset-env": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz", + "integrity": "sha512-W6VIyA6Ch9ePMI7VptNn2wBM6dbG0eSz25HEiL40nQXCsXGTGZSTZu1Iap+cj3Q0S5a7T9+529l/5Bkvd+afNA==", "dev": true, "requires": { "babel-plugin-check-es2015-constants": "6.22.0", + "babel-plugin-syntax-trailing-function-commas": "6.22.0", + "babel-plugin-transform-async-to-generator": "6.24.1", "babel-plugin-transform-es2015-arrow-functions": "6.22.0", "babel-plugin-transform-es2015-block-scoped-functions": "6.22.0", "babel-plugin-transform-es2015-block-scoping": "6.26.0", @@ -1093,7 +1565,11 @@ "babel-plugin-transform-es2015-template-literals": "6.22.0", "babel-plugin-transform-es2015-typeof-symbol": "6.23.0", "babel-plugin-transform-es2015-unicode-regex": "6.24.1", - "babel-plugin-transform-regenerator": "6.26.0" + "babel-plugin-transform-exponentiation-operator": "6.24.1", + "babel-plugin-transform-regenerator": "6.26.0", + "browserslist": "2.11.0", + "invariant": "2.2.2", + "semver": "5.4.1" } }, "babel-preset-flow": { @@ -1127,44 +1603,17 @@ "requires": { "babel-core": "6.26.0", "babel-runtime": "6.26.0", - "core-js": "2.5.1", + "core-js": "2.5.3", "home-or-tmp": "2.0.0", "lodash": "4.17.4", "mkdirp": "0.5.1", "source-map-support": "0.4.18" }, "dependencies": { - "babel-core": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.0.tgz", - "integrity": "sha1-rzL3izGm/O8RnIew/Y2XU/A6C7g=", - "dev": true, - "requires": { - "babel-code-frame": "6.26.0", - "babel-generator": "6.26.0", - "babel-helpers": "6.24.1", - "babel-messages": "6.23.0", - "babel-register": "6.26.0", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0", - "babylon": "6.18.0", - "convert-source-map": "1.5.0", - "debug": "2.6.9", - "json5": "0.5.1", - "lodash": "4.17.4", - "minimatch": "3.0.4", - "path-is-absolute": "1.0.1", - "private": "0.1.8", - "slash": "1.0.0", - "source-map": "0.5.7" - } - }, "core-js": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.1.tgz", - "integrity": "sha1-rmh03GaTd4m4B1T/VCjfZoGcpQs=", + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz", + "integrity": "sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4=", "dev": true } } @@ -1175,14 +1624,14 @@ "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", "dev": true, "requires": { - "core-js": "2.5.1", - "regenerator-runtime": "0.11.0" + "core-js": "2.5.3", + "regenerator-runtime": "0.11.1" }, "dependencies": { "core-js": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.1.tgz", - "integrity": "sha1-rmh03GaTd4m4B1T/VCjfZoGcpQs=", + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz", + "integrity": "sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4=", "dev": true } } @@ -1246,6 +1695,35 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, + "base": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", + "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", + "dev": true, + "requires": { + "cache-base": "1.0.1", + "class-utils": "0.3.5", + "component-emitter": "1.2.1", + "define-property": "1.0.0", + "isobject": "3.0.1", + "mixin-deep": "1.3.0", + "pascalcase": "0.1.1" + }, + "dependencies": { + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "dev": true + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, "base64-arraybuffer": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", @@ -1266,7 +1744,8 @@ "base64url": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/base64url/-/base64url-2.0.0.tgz", - "integrity": "sha1-6sFuA+oUOO/5Qj1puqNiYu0fcLs=" + "integrity": "sha1-6sFuA+oUOO/5Qj1puqNiYu0fcLs=", + "dev": true }, "batch": { "version": "0.6.1", @@ -1300,20 +1779,11 @@ "dev": true }, "binary-extensions": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.10.0.tgz", - "integrity": "sha1-muuabF6IY4qtFx4Wf1kAq+JINdA=", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.11.0.tgz", + "integrity": "sha1-RqoXUftqL5PuXmibsQh9SxTGwgU=", "dev": true }, - "bl": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.1.2.tgz", - "integrity": "sha1-/cqHGplxOqANGeO7ukHER4emU5g=", - "dev": true, - "requires": { - "readable-stream": "2.0.6" - } - }, "blob": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz", @@ -1355,6 +1825,28 @@ "type-is": "1.6.15" } }, + "bonjour": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/bonjour/-/bonjour-3.5.0.tgz", + "integrity": "sha1-jokKGD2O6aI5OzhExpGkK897yfU=", + "dev": true, + "requires": { + "array-flatten": "2.1.1", + "deep-equal": "1.0.1", + "dns-equal": "1.0.0", + "dns-txt": "2.0.2", + "multicast-dns": "6.2.1", + "multicast-dns-service-types": "1.1.0" + }, + "dependencies": { + "array-flatten": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-2.1.1.tgz", + "integrity": "sha1-Qmu52oQJDBg42BLIFQryCoMx4pY=", + "dev": true + } + } + }, "boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", @@ -1370,67 +1862,156 @@ "hoek": "4.2.0" } }, - "brace-expansion": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", - "requires": { - "balanced-match": "1.0.0", - "concat-map": "0.0.1" - } - }, - "braces": { - "version": "1.8.5", - "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", - "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", - "dev": true, - "requires": { - "expand-range": "1.8.2", - "preserve": "0.2.0", - "repeat-element": "1.1.2" - } - }, - "brorand": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", - "dev": true - }, - "browserify-aes": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.1.0.tgz", - "integrity": "sha512-W2bIMLYoZ9oow7TyePpMJk9l9LY7O3R61a/68bVCDOtnJynnwe3ZeW2IzzSkrQnPKNdJrxVDn3ALZNisSBwb7g==", - "dev": true, - "requires": { - "buffer-xor": "1.0.3", - "cipher-base": "1.0.4", - "create-hash": "1.1.3", - "evp_bytestokey": "1.0.3", - "inherits": "2.0.3", - "safe-buffer": "5.1.1" - } - }, - "browserify-cipher": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.0.tgz", - "integrity": "sha1-mYgkSHS/XtTijalWZtzWasj8Njo=", - "dev": true, - "requires": { - "browserify-aes": "1.1.0", - "browserify-des": "1.0.0", - "evp_bytestokey": "1.0.3" - } - }, - "browserify-des": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.0.tgz", - "integrity": "sha1-2qJ3cXRwki7S/hhZQRihdUOXId0=", + "boxen": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/boxen/-/boxen-1.3.0.tgz", + "integrity": "sha512-TNPjfTr432qx7yOjQyaXm3dSR0MH9vXp7eT1BFSl/C51g+EFnOR9hTg1IreahGBmDNCehscshe45f+C1TBZbLw==", "dev": true, "requires": { - "cipher-base": "1.0.4", - "des.js": "1.0.0", - "inherits": "2.0.3" - } + "ansi-align": "2.0.0", + "camelcase": "4.1.0", + "chalk": "2.3.0", + "cli-boxes": "1.0.0", + "string-width": "2.1.1", + "term-size": "1.2.0", + "widest-line": "2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + }, + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", + "dev": true + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } + } + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", + "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", + "dev": true, + "requires": { + "expand-range": "1.8.2", + "preserve": "0.2.0", + "repeat-element": "1.1.2" + } + }, + "brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", + "dev": true + }, + "browserify-aes": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.1.1.tgz", + "integrity": "sha512-UGnTYAnB2a3YuYKIRy1/4FB2HdM866E0qC46JXvVTYKlBlZlnvfpSfY6OKfXZAkv70eJ2a1SqzpAo5CRhZGDFg==", + "dev": true, + "requires": { + "buffer-xor": "1.0.3", + "cipher-base": "1.0.4", + "create-hash": "1.1.3", + "evp_bytestokey": "1.0.3", + "inherits": "2.0.3", + "safe-buffer": "5.1.1" + } + }, + "browserify-cipher": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.0.tgz", + "integrity": "sha1-mYgkSHS/XtTijalWZtzWasj8Njo=", + "dev": true, + "requires": { + "browserify-aes": "1.1.1", + "browserify-des": "1.0.0", + "evp_bytestokey": "1.0.3" + } + }, + "browserify-des": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.0.tgz", + "integrity": "sha1-2qJ3cXRwki7S/hhZQRihdUOXId0=", + "dev": true, + "requires": { + "cipher-base": "1.0.4", + "des.js": "1.0.0", + "inherits": "2.0.3" + } }, "browserify-rsa": { "version": "4.0.1", @@ -1475,13 +2056,13 @@ } }, "browserslist": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.5.1.tgz", - "integrity": "sha512-jAvM2ku7YDJ+leAq3bFH1DE0Ylw+F+EQDq4GkqZfgPEqpWYw9ofQH85uKSB9r3Tv7XDbfqVtE+sdvKJW7IlPJA==", + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.11.0.tgz", + "integrity": "sha512-mNYp0RNeu1xueGuJFSXkU+K0nH+dBE/gcjtyhtNKfU8hwdrVIfoA7i5iFSjOmzkGdL2QaO7YX9ExiVPE7AY9JA==", "dev": true, "requires": { - "caniuse-lite": "1.0.30000746", - "electron-to-chromium": "1.3.26" + "caniuse-lite": "1.0.30000787", + "electron-to-chromium": "1.3.30" } }, "buffer": { @@ -1495,6 +2076,12 @@ "isarray": "1.0.0" } }, + "buffer-indexof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-indexof/-/buffer-indexof-1.1.1.tgz", + "integrity": "sha512-4/rOEg86jivtPTeOUUT61jJO1Ya1TrR/OkqCSZDyq84WJh3LuuiphBYJN+fm5xufIk4XAFcEwte/8WzC8If/1g==", + "dev": true + }, "buffer-xor": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", @@ -1513,6 +2100,12 @@ "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", "dev": true }, + "builtins": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/builtins/-/builtins-1.0.3.tgz", + "integrity": "sha1-y5T662HIaWRR2zZTThQi+U8K7og=", + "dev": true + }, "bytes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", @@ -1520,9 +2113,9 @@ "dev": true }, "cacache": { - "version": "9.3.0", - "resolved": "https://registry.npmjs.org/cacache/-/cacache-9.3.0.tgz", - "integrity": "sha512-Vbi8J1XfC8v+FbQ6QkOtKXsHpPnB0i9uMeYFJoj40EbdOsEqWB3DPpNjfsnYBkqOPYA8UvrqH6FZPpBP0zdN7g==", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-10.0.1.tgz", + "integrity": "sha512-dRHYcs9LvG9cHgdPzjiI+/eS7e1xRhULrcyOx04RZQsszNJXU2SL9CyG60yLnge282Qq5nwTv+ieK2fH+WPZmA==", "dev": true, "requires": { "bluebird": "3.5.1", @@ -1535,7 +2128,7 @@ "move-concurrently": "1.0.1", "promise-inflight": "1.0.1", "rimraf": "2.6.2", - "ssri": "4.1.6", + "ssri": "5.0.0", "unique-filename": "1.1.0", "y18n": "3.2.1" }, @@ -1549,6 +2142,100 @@ "pseudomap": "1.0.2", "yallist": "2.1.2" } + }, + "ssri": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-5.0.0.tgz", + "integrity": "sha512-728D4yoQcQm1ooZvSbywLkV1RjfITZXh0oWrhM/lnsx3nAHx7LsRGJWB/YyvoceAYRq98xqbstiN4JBv1/wNHg==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + } + } + }, + "cache-base": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", + "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", + "dev": true, + "requires": { + "collection-visit": "1.0.0", + "component-emitter": "1.2.1", + "get-value": "2.0.6", + "has-value": "1.0.0", + "isobject": "3.0.1", + "set-value": "2.0.0", + "to-object-path": "0.3.0", + "union-value": "1.0.0", + "unset-value": "1.0.0" + }, + "dependencies": { + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "dev": true + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, + "cacheable-request": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-2.1.4.tgz", + "integrity": "sha1-DYCIAbY0KtM8kd+dC0TcCbkeXD0=", + "dev": true, + "requires": { + "clone-response": "1.0.2", + "get-stream": "3.0.0", + "http-cache-semantics": "3.8.1", + "keyv": "3.0.0", + "lowercase-keys": "1.0.0", + "normalize-url": "2.0.1", + "responselike": "1.0.2" + }, + "dependencies": { + "normalize-url": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-2.0.1.tgz", + "integrity": "sha512-D6MUW4K/VzoJ4rJ01JFKxDrtY1v9wrgzCX5f2qj/lzH1m/lW6MhUZFKerVsnyjOhOsYzI9Kqqak+10l4LvLpMw==", + "dev": true, + "requires": { + "prepend-http": "2.0.0", + "query-string": "5.0.1", + "sort-keys": "2.0.0" + } + }, + "prepend-http": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", + "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", + "dev": true + }, + "query-string": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.0.1.tgz", + "integrity": "sha512-aM+MkQClojlNiKkO09tiN2Fv8jM/L7GWIjG2liWeKljlOdOPNWr+bW3KQ+w5V/uKprpezC7fAsAMsJtJ+2rLKA==", + "dev": true, + "requires": { + "decode-uri-component": "0.2.0", + "object-assign": "4.1.1", + "strict-uri-encode": "1.1.0" + } + }, + "sort-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-2.0.0.tgz", + "integrity": "sha1-ZYU1WEhh7JfXMNbPQYIuH1ZoQSg=", + "dev": true, + "requires": { + "is-plain-obj": "1.1.0" + } } } }, @@ -1615,7 +2302,7 @@ "dev": true, "requires": { "browserslist": "1.7.7", - "caniuse-db": "1.0.30000746", + "caniuse-db": "1.0.30000787", "lodash.memoize": "4.1.2", "lodash.uniq": "4.5.0" }, @@ -1626,24 +2313,49 @@ "integrity": "sha1-C9dnBCWL6CmyOYu1Dkti0aFmsLk=", "dev": true, "requires": { - "caniuse-db": "1.0.30000746", - "electron-to-chromium": "1.3.26" + "caniuse-db": "1.0.30000787", + "electron-to-chromium": "1.3.30" } } } }, "caniuse-db": { - "version": "1.0.30000746", - "resolved": "https://registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000746.tgz", - "integrity": "sha1-UBCYxm9fu/Y0wC8lUIsF6ICZEPQ=", + "version": "1.0.30000787", + "resolved": "https://registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000787.tgz", + "integrity": "sha1-ygeigb5Taoi9f6yWuolfPPU/gRs=", "dev": true }, "caniuse-lite": { - "version": "1.0.30000746", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000746.tgz", - "integrity": "sha1-xk+Vo5Jc/TAgejCO12wa6W6gnqA=", + "version": "1.0.30000787", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000787.tgz", + "integrity": "sha1-p2xPodasAGQER+yDwefGsz3WFcU=", + "dev": true + }, + "canvas": { + "version": "1.6.9", + "resolved": "https://registry.npmjs.org/canvas/-/canvas-1.6.9.tgz", + "integrity": "sha1-4/lc7HsWvy1vP8clwC2UDTJY9ps=", + "dev": true, + "requires": { + "nan": "2.8.0" + } + }, + "capture-stack-trace": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz", + "integrity": "sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0=", "dev": true }, + "cardinal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/cardinal/-/cardinal-1.0.0.tgz", + "integrity": "sha1-UOIcGwqjdyn5N33vGWtanOyTLuk=", + "dev": true, + "requires": { + "ansicolors": "0.2.1", + "redeyed": "1.0.1" + } + }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -1673,6 +2385,12 @@ "supports-color": "2.0.0" } }, + "chardet": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", + "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=", + "dev": true + }, "chokidar": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", @@ -1681,6 +2399,7 @@ "requires": { "anymatch": "1.3.2", "async-each": "1.0.1", + "fsevents": "1.1.3", "glob-parent": "2.0.0", "inherits": "2.0.3", "is-binary-path": "1.0.1", @@ -1726,6 +2445,102 @@ "chalk": "1.1.3" } }, + "class-utils": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.5.tgz", + "integrity": "sha1-F+eTEDdQ+WJ7IXbqNM/RtWWQPIA=", + "dev": true, + "requires": { + "arr-union": "3.1.0", + "define-property": "0.2.5", + "isobject": "3.0.1", + "lazy-cache": "2.0.2", + "static-extend": "0.1.2" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "0.1.6", + "is-data-descriptor": "0.1.4", + "kind-of": "5.1.0" + } + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + }, + "lazy-cache": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-2.0.2.tgz", + "integrity": "sha1-uRkKT5EzVGlIQIWfio9whNiCImQ=", + "dev": true, + "requires": { + "set-getter": "0.1.0" + } + } + } + }, "clean-css": { "version": "4.1.9", "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.1.9.tgz", @@ -1735,6 +2550,12 @@ "source-map": "0.5.7" } }, + "cli-boxes": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-1.0.0.tgz", + "integrity": "sha1-T6kXw+WclKAEzWH47lCdplFocUM=", + "dev": true + }, "cli-cursor": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", @@ -1744,8 +2565,25 @@ "restore-cursor": "1.0.1" } }, - "cli-width": { - "version": "2.2.0", + "cli-table": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.1.tgz", + "integrity": "sha1-9TsFJmqLGguTSz0IIebi3FkUriM=", + "dev": true, + "requires": { + "colors": "1.0.3" + }, + "dependencies": { + "colors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", + "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=", + "dev": true + } + } + }, + "cli-width": { + "version": "2.2.0", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", "dev": true @@ -1770,11 +2608,20 @@ } }, "clone": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.2.tgz", - "integrity": "sha1-Jgt6meux7f4kdTgXX3gyQ8sZ0Uk=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.3.tgz", + "integrity": "sha1-KY1+IjFmD0DAA8LtMUDezz9TCF8=", "dev": true }, + "clone-response": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz", + "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=", + "dev": true, + "requires": { + "mimic-response": "1.0.0" + } + }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -1787,7 +2634,7 @@ "integrity": "sha1-qe8VNmDWqGqL3sAomlxoTSF0Mv0=", "dev": true, "requires": { - "q": "1.5.0" + "q": "1.5.1" } }, "code-point-at": { @@ -1796,21 +2643,31 @@ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true }, + "collection-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", + "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "dev": true, + "requires": { + "map-visit": "1.0.0", + "object-visit": "1.0.1" + } + }, "color": { "version": "0.11.4", "resolved": "https://registry.npmjs.org/color/-/color-0.11.4.tgz", "integrity": "sha1-bXtcdPtl6EHNSHkq0e1eB7kE12Q=", "dev": true, "requires": { - "clone": "1.0.2", - "color-convert": "1.9.0", + "clone": "1.0.3", + "color-convert": "1.9.1", "color-string": "0.3.0" } }, "color-convert": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz", - "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1970,7 +2827,7 @@ "dev": true, "requires": { "glob": "7.1.1", - "interpret": "1.0.4", + "interpret": "1.1.0", "rechoir": "0.6.2" } } @@ -1982,6 +2839,16 @@ "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", "dev": true }, + "compare-func": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-1.3.2.tgz", + "integrity": "sha1-md0LpFfh+bxyKxLAjsM+6rMfpkg=", + "dev": true, + "requires": { + "array-ify": "1.0.0", + "dot-prop": "3.0.0" + } + }, "component-bind": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", @@ -2001,9 +2868,9 @@ "dev": true }, "compressible": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.11.tgz", - "integrity": "sha1-FnGKdd4oPtjmBAQWJaIGRYZ5fYo=", + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.12.tgz", + "integrity": "sha1-xZpcmdt2dn6YdlAOJx72OzSTvWY=", "dev": true, "requires": { "mime-db": "1.30.0" @@ -2017,7 +2884,7 @@ "requires": { "accepts": "1.3.4", "bytes": "3.0.0", - "compressible": "2.0.11", + "compressible": "2.0.12", "debug": "2.6.9", "on-headers": "1.0.1", "safe-buffer": "5.1.1", @@ -2037,39 +2904,26 @@ } }, "compression-webpack-plugin": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/compression-webpack-plugin/-/compression-webpack-plugin-1.0.1.tgz", - "integrity": "sha512-ABF2AFb31gpIBeEy/w6Ct0u+K+jY8jFRfGwjUWGxVTidA9pf7iH/JzjcVBQ+KB1gNMycujMxA56/PznMPUV5jw==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/compression-webpack-plugin/-/compression-webpack-plugin-1.1.3.tgz", + "integrity": "sha512-DIvTIkihu1tyoPdoan5Lh9GVvXgcNMDEgXSfyjlAriW3UaILoPhUFHFTU7Zsui+rPEexmFNlTyiLe0TCkQFJGg==", "dev": true, "requires": { - "async": "2.4.1", - "webpack-sources": "1.0.1" + "async": "2.6.0", + "cacache": "10.0.1", + "find-cache-dir": "1.0.0", + "serialize-javascript": "1.4.0", + "webpack-sources": "1.1.0" }, "dependencies": { "async": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/async/-/async-2.4.1.tgz", - "integrity": "sha1-YqVrJ5yYoR0JhwlqAcw+6463u9c=", + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", + "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", "dev": true, "requires": { "lodash": "4.17.4" } - }, - "source-list-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.0.tgz", - "integrity": "sha512-I2UmuJSRr/T8jisiROLU3A3ltr+swpniSmNPI4Ml3ZCX6tVnDsuZzK7F2hl5jTqbZBWCEKlj5HRQiPExXLgE8A==", - "dev": true - }, - "webpack-sources": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.0.1.tgz", - "integrity": "sha512-05tMxipUCwHqYaVS8xc7sYPTly8PzXayRCB4dTxLhWTqlKUiwH6ezmEe0OSreL1c30LAuA3Zqmc+uEBUGFJDjw==", - "dev": true, - "requires": { - "source-list-map": "2.0.0", - "source-map": "0.5.7" - } } } }, @@ -2121,10 +2975,35 @@ "integrity": "sha1-q6CXR9++TD5w52am5BWG4YWfxvI=", "dev": true, "requires": { - "ini": "1.3.4", + "ini": "1.3.5", "proto-list": "1.2.4" } }, + "configstore": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.1.tgz", + "integrity": "sha512-5oNkD/L++l0O6xGXxb1EWS7SivtjfGQlRyxJsYgE0Z495/L81e2h4/d3r969hoPXuFItzNOKMtsXgYG4c7dYvw==", + "dev": true, + "requires": { + "dot-prop": "4.2.0", + "graceful-fs": "4.1.11", + "make-dir": "1.1.0", + "unique-string": "1.0.0", + "write-file-atomic": "2.3.0", + "xdg-basedir": "3.0.0" + }, + "dependencies": { + "dot-prop": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz", + "integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==", + "dev": true, + "requires": { + "is-obj": "1.0.1" + } + } + } + }, "connect": { "version": "3.6.5", "resolved": "https://registry.npmjs.org/connect/-/connect-3.6.5.tgz", @@ -2138,9 +3017,9 @@ } }, "connect-history-api-fallback": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-1.4.0.tgz", - "integrity": "sha1-PbJPlz9LkjsOgvYZzg3wJBHKYj0=", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-1.5.0.tgz", + "integrity": "sha1-sGhzk0vF40T+9hGhlqb6rgruAVo=", "dev": true }, "console-browserify": { @@ -2182,42 +3061,32 @@ "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", "dev": true }, - "conventional-changelog": { - "version": "0.0.17", - "resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-0.0.17.tgz", - "integrity": "sha1-XgIWYA9GhhkPDILvuws90RtJzjQ=", + "conventional-changelog-angular": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-1.6.0.tgz", + "integrity": "sha1-CiagcfLJ/PzyuGugz79uYwG3W/o=", + "dev": true, + "requires": { + "compare-func": "1.3.2", + "q": "1.5.1" + } + }, + "conventional-changelog-writer": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-2.0.3.tgz", + "integrity": "sha512-2E1h7UXL0fhRO5h0CxDZ5EBc5sfBZEQePvuZ+gPvApiRrICUyNDy/NQIP+2TBd4wKZQf2Zm7TxbzXHG5HkPIbA==", "dev": true, "requires": { + "compare-func": "1.3.2", + "conventional-commits-filter": "1.1.1", "dateformat": "1.0.12", - "event-stream": "3.3.4", - "github-url-from-git": "1.5.0", - "lodash": "3.10.1", - "normalize-package-data": "1.0.3" - }, - "dependencies": { - "lodash": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", - "dev": true - }, - "normalize-package-data": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-1.0.3.tgz", - "integrity": "sha1-i+lVuJB6+XXxpFhOqLubQUkjEvU=", - "dev": true, - "requires": { - "github-url-from-git": "1.5.0", - "github-url-from-username-repo": "1.0.2", - "semver": "4.3.6" - } - }, - "semver": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", - "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=", - "dev": true - } + "handlebars": "4.0.11", + "json-stringify-safe": "5.0.1", + "lodash": "4.17.4", + "meow": "3.7.0", + "semver": "5.4.1", + "split": "1.0.1", + "through2": "2.0.3" } }, "conventional-commit-types": { @@ -2226,10 +3095,35 @@ "integrity": "sha1-XblXOdbCEqy+e29lahG5QLqmiUY=", "dev": true }, + "conventional-commits-filter": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-1.1.1.tgz", + "integrity": "sha512-bQyatySNKHhcaeKVr9vFxYWA1W1Tdz6ybVMYDmv4/FhOXY1+fchiW07TzRbIQZhVa4cvBwrEaEUQBbCncFSdJQ==", + "dev": true, + "requires": { + "is-subset": "0.1.1", + "modify-values": "1.0.0" + } + }, + "conventional-commits-parser": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-2.1.0.tgz", + "integrity": "sha512-8MD05yN0Zb6aRsZnFX1ET+8rHWfWJk+my7ANCJZBU2mhz7TSB1fk2vZhkrwVy/PCllcTYAP/1T1NiWQ7Z01mKw==", + "dev": true, + "requires": { + "JSONStream": "1.3.2", + "is-text-path": "1.0.1", + "lodash": "4.17.4", + "meow": "3.7.0", + "split2": "2.2.0", + "through2": "2.0.3", + "trim-off-newlines": "1.0.1" + } + }, "convert-source-map": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.0.tgz", - "integrity": "sha1-ms1whRxtXf3ZPZKC5e35SgP/RrU=", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.1.tgz", + "integrity": "sha1-uCeAl7m8IpNl3lxiz1/K7YtVmeU=", "dev": true }, "cookie": { @@ -2258,6 +3152,12 @@ "run-queue": "1.0.3" } }, + "copy-descriptor": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", + "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "dev": true + }, "core-js": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.3.0.tgz", @@ -2301,6 +3201,15 @@ "elliptic": "6.4.0" } }, + "create-error-class": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/create-error-class/-/create-error-class-3.0.2.tgz", + "integrity": "sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y=", + "dev": true, + "requires": { + "capture-stack-trace": "1.0.0" + } + }, "create-hash": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.3.tgz", @@ -2371,9 +3280,9 @@ } }, "crypto-browserify": { - "version": "3.11.1", - "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.11.1.tgz", - "integrity": "sha512-Na7ZlwCOqoaW5RwUK1WpXws2kv8mNhWdTlzob0UXulk6G9BDbyiJaGTYBIX61Ozn9l1EPPJpICZb4DaOpT9NlQ==", + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", + "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", "dev": true, "requires": { "browserify-cipher": "1.0.0", @@ -2385,9 +3294,16 @@ "inherits": "2.0.3", "pbkdf2": "3.0.14", "public-encrypt": "4.0.0", - "randombytes": "2.0.5" + "randombytes": "2.0.5", + "randomfill": "1.0.3" } }, + "crypto-random-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz", + "integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=", + "dev": true + }, "css-color-names": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/css-color-names/-/css-color-names-0.0.4.tgz", @@ -2395,9 +3311,9 @@ "dev": true }, "css-loader": { - "version": "0.28.4", - "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-0.28.4.tgz", - "integrity": "sha1-bPNXkZLONV6LONX0Ldeh8uyJjQ8=", + "version": "0.28.7", + "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-0.28.7.tgz", + "integrity": "sha512-GxMpax8a/VgcfRrVy0gXD6yLd5ePYbXX/5zGgTVYp4wXtJklS8Z2VaUArJgc//f6/Dzil7BaJObdSv8eKKCPgg==", "dev": true, "requires": { "babel-code-frame": "6.26.0", @@ -2413,7 +3329,7 @@ "postcss-modules-scope": "1.1.0", "postcss-modules-values": "1.3.0", "postcss-value-parser": "3.3.0", - "source-list-map": "0.1.8" + "source-list-map": "2.0.0" }, "dependencies": { "loader-utils": { @@ -2434,7 +3350,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -2545,7 +3461,7 @@ "dev": true, "requires": { "browserslist": "1.7.7", - "caniuse-db": "1.0.30000746", + "caniuse-db": "1.0.30000787", "normalize-range": "0.1.2", "num2fraction": "1.2.2", "postcss": "5.2.18", @@ -2558,8 +3474,8 @@ "integrity": "sha1-C9dnBCWL6CmyOYu1Dkti0aFmsLk=", "dev": true, "requires": { - "caniuse-db": "1.0.30000746", - "electron-to-chromium": "1.3.26" + "caniuse-db": "1.0.30000787", + "electron-to-chromium": "1.3.30" } }, "postcss": { @@ -2569,7 +3485,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -2617,15 +3533,14 @@ "dev": true }, "cz-conventional-changelog": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/cz-conventional-changelog/-/cz-conventional-changelog-2.0.0.tgz", - "integrity": "sha1-Val5r9/pXnAkh50qD1kkYwFwtTM=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cz-conventional-changelog/-/cz-conventional-changelog-2.1.0.tgz", + "integrity": "sha1-L0vHOQ4yROTfKT5ro1Hkx0Cnx2Q=", "dev": true, "requires": { "conventional-commit-types": "2.2.0", "lodash.map": "4.6.0", "longest": "1.0.1", - "pad-right": "0.2.2", "right-pad": "1.0.1", "word-wrap": "1.2.3" } @@ -2636,7 +3551,7 @@ "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", "dev": true, "requires": { - "es5-ext": "0.10.35" + "es5-ext": "0.10.37" } }, "damerau-levenshtein": { @@ -2668,14 +3583,6 @@ "requires": { "get-stdin": "4.0.1", "meow": "3.7.0" - }, - "dependencies": { - "get-stdin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", - "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", - "dev": true - } } }, "debug": { @@ -2693,6 +3600,21 @@ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true }, + "decode-uri-component": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", + "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "dev": true + }, + "decompress-response": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz", + "integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=", + "dev": true, + "requires": { + "mimic-response": "1.0.0" + } + }, "dedent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.6.0.tgz", @@ -2705,6 +3627,12 @@ "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", "dev": true }, + "deep-extend": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", + "integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=", + "dev": true + }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", @@ -2727,6 +3655,15 @@ "object-keys": "1.0.11" } }, + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "1.0.2" + } + }, "defined": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", @@ -2774,7 +3711,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", - "dev": true + "dev": true, + "optional": true }, "depd": { "version": "1.1.1", @@ -2822,16 +3760,6 @@ "integrity": "sha1-ogM8CcyOFY03dI+951B4Mr1s4Sc=", "dev": true }, - "dezalgo": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.3.tgz", - "integrity": "sha1-f3Qt4Gb8dIvI24IFad3c5Jvw1FY=", - "dev": true, - "requires": { - "asap": "2.0.6", - "wrappy": "1.0.2" - } - }, "di": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", @@ -2849,14 +3777,65 @@ "randombytes": "2.0.5" } }, - "doctrine": { + "dir-glob": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.0.tgz", - "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-2.0.0.tgz", + "integrity": "sha512-37qirFDz8cA5fimp9feo43fSuRo2gHwaIn6dXL8Ber1dGwUosDrGZeCCXq57WnIqE4aQ+u3eQZzsk1yOzhdwag==", "dev": true, "requires": { - "esutils": "2.0.2", - "isarray": "1.0.0" + "arrify": "1.0.1", + "path-type": "3.0.0" + }, + "dependencies": { + "path-type": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", + "dev": true, + "requires": { + "pify": "3.0.0" + } + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + } + } + }, + "dns-equal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/dns-equal/-/dns-equal-1.0.0.tgz", + "integrity": "sha1-s55/HabrCnW6nBcySzR1PEfgZU0=", + "dev": true + }, + "dns-packet": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-1.2.2.tgz", + "integrity": "sha512-kN+DjfGF7dJGUL7nWRktL9Z18t1rWP3aQlyZdY8XlpvU3Nc6GeFTQApftcjtWKxAZfiggZSGrCEoszNgvnpwDg==", + "dev": true, + "requires": { + "ip": "1.1.5", + "safe-buffer": "5.1.1" + } + }, + "dns-txt": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/dns-txt/-/dns-txt-2.0.2.tgz", + "integrity": "sha1-uR2Ab10nGI5Ks+fRB9iBocxGQrY=", + "dev": true, + "requires": { + "buffer-indexof": "1.1.1" + } + }, + "doctrine": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.2.tgz", + "integrity": "sha512-y0tm5Pq6ywp3qSTZ1vPgVdAnbDEoeoc5wlOHXoY1c4Wug/a7JvqHIl7BTvwodaHmejWkK/9dSb3sCYfyo/om8A==", + "dev": true, + "requires": { + "esutils": "2.0.2" } }, "dom-converter": { @@ -2949,12 +3928,42 @@ "domelementtype": "1.3.0" } }, + "dot-prop": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-3.0.0.tgz", + "integrity": "sha1-G3CK8JSknJoOfbyteQq6U52sEXc=", + "dev": true, + "requires": { + "is-obj": "1.0.1" + } + }, + "dotenv": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-4.0.0.tgz", + "integrity": "sha1-hk7xN5rO1Vzm+V3r7NzhefegzR0=", + "dev": true + }, "duplexer": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", "dev": true }, + "duplexer2": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", + "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", + "dev": true, + "requires": { + "readable-stream": "2.0.6" + } + }, + "duplexer3": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", + "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=", + "dev": true + }, "duplexify": { "version": "3.5.1", "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.5.1.tgz", @@ -2989,12 +3998,21 @@ "integrity": "sha1-zIcsFoiArjxxiXYv1f/ACJbJUYo=", "dev": true }, - "electron-to-chromium": { - "version": "1.3.26", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.26.tgz", - "integrity": "sha1-mWQnKUhhp02cfIK5Jg6jAejALWY=", + "electron-releases": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/electron-releases/-/electron-releases-2.1.0.tgz", + "integrity": "sha512-cyKFD1bTE/UgULXfaueIN1k5EPFzs+FRc/rvCY5tIynefAPqopQEgjr0EzY+U3Dqrk/G4m9tXSPuZ77v6dL/Rw==", "dev": true }, + "electron-to-chromium": { + "version": "1.3.30", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.30.tgz", + "integrity": "sha512-zx1Prv7kYLfc4OA60FhxGbSo4qrEjgSzpo1/37i7l9ltXPYOoQBtjQxY9KmsgfHnBxHlBGXwLlsbt/gub1w5lw==", + "dev": true, + "requires": { + "electron-releases": "2.1.0" + } + }, "elliptic": { "version": "6.4.0", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", @@ -3028,6 +4046,15 @@ "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=", "dev": true }, + "encoding": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", + "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", + "dev": true, + "requires": { + "iconv-lite": "0.4.19" + } + }, "end-of-stream": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.0.tgz", @@ -3157,12 +4184,12 @@ "dev": true }, "errno": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.4.tgz", - "integrity": "sha1-uJbiOp5ei6M4cfyZar02NfyaHH0=", + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.6.tgz", + "integrity": "sha512-IsORQDpaaSwcDP4ZZnHxgE85werpo34VYn1Ud3mq+eUsF593faR8oCZNXrROVkpFu2TsbrNhHin0aUrTsQ9vNw==", "dev": true, "requires": { - "prr": "0.0.0" + "prr": "1.0.1" } }, "error-ex": { @@ -3175,9 +4202,9 @@ } }, "es-abstract": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.9.0.tgz", - "integrity": "sha512-kk3IJoKo7A3pWJc0OV8yZ/VEX2oSUytfekrJiqoxBlKJMFAJVJVpGdHClCCTdv+Fn2zHfpDHHIelMFhZVfef3Q==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.10.0.tgz", + "integrity": "sha512-/uh/DhdqIOSkAWifU+8nG78vlQxdLckUdI/sPgy0VhuXi2qJ7T8czBmqIYtLQVpCIFYafChnsRsB5pyb1JdmCQ==", "dev": true, "requires": { "es-to-primitive": "1.1.1", @@ -3199,23 +4226,23 @@ } }, "es5-ext": { - "version": "0.10.35", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.35.tgz", - "integrity": "sha1-GO6FjOajxFx9eekcFfzKnsVoSU8=", + "version": "0.10.37", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.37.tgz", + "integrity": "sha1-DudB0Ui4AGm6J9AgOTdWryV978M=", "dev": true, "requires": { - "es6-iterator": "2.0.1", + "es6-iterator": "2.0.3", "es6-symbol": "3.1.1" } }, "es6-iterator": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.1.tgz", - "integrity": "sha1-jjGcnwRTv1ddN0lAplWSDlnKVRI=", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.35", + "es5-ext": "0.10.37", "es6-symbol": "3.1.1" } }, @@ -3226,8 +4253,8 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.35", - "es6-iterator": "2.0.1", + "es5-ext": "0.10.37", + "es6-iterator": "2.0.3", "es6-set": "0.1.5", "es6-symbol": "3.1.1", "event-emitter": "0.3.5" @@ -3244,6 +4271,23 @@ "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.0.2.tgz", "integrity": "sha1-AQ1YWEI6XxGJeWZfRkhqlcbuK7Y=" }, + "es6-promisify": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", + "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", + "dev": true, + "requires": { + "es6-promise": "4.2.2" + }, + "dependencies": { + "es6-promise": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.2.tgz", + "integrity": "sha512-LSas5vsuA6Q4nEdf9wokY5/AJYXry98i0IzXsv49rYsgDGDNDPbqAYR1Pe23iFxygfbGZNR/5VrHXBCh2BhvUQ==", + "dev": true + } + } + }, "es6-set": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", @@ -3251,8 +4295,8 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.35", - "es6-iterator": "2.0.1", + "es5-ext": "0.10.37", + "es6-iterator": "2.0.3", "es6-symbol": "3.1.1", "event-emitter": "0.3.5" } @@ -3264,7 +4308,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.35" + "es5-ext": "0.10.37" } }, "es6-templates": { @@ -3284,8 +4328,8 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.35", - "es6-iterator": "2.0.1", + "es5-ext": "0.10.37", + "es6-iterator": "2.0.3", "es6-symbol": "3.1.1" } }, @@ -3347,134 +4391,273 @@ } }, "eslint": { - "version": "3.19.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-3.19.0.tgz", - "integrity": "sha1-yPxiAcf0DdCJQbh8CFdnOGpnmsw=", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.14.0.tgz", + "integrity": "sha512-Ul6CSGRjKscEyg0X/EeNs7o2XdnbTEOD1OM8cTjmx85RPcBJQrEhZLevhuJZNAE/vS2iVl5Uhgiqf3h5uLMCJQ==", "dev": true, "requires": { + "ajv": "5.5.2", "babel-code-frame": "6.26.0", - "chalk": "1.1.3", + "chalk": "2.3.0", "concat-stream": "1.6.0", - "debug": "2.6.9", - "doctrine": "2.0.0", - "escope": "3.6.0", - "espree": "3.5.1", + "cross-spawn": "5.1.0", + "debug": "3.1.0", + "doctrine": "2.0.2", + "eslint-scope": "3.7.1", + "eslint-visitor-keys": "1.0.0", + "espree": "3.5.2", "esquery": "1.0.0", - "estraverse": "4.2.0", "esutils": "2.0.2", "file-entry-cache": "2.0.0", + "functional-red-black-tree": "1.0.1", "glob": "7.1.2", - "globals": "9.18.0", - "ignore": "3.3.5", + "globals": "11.1.0", + "ignore": "3.3.7", "imurmurhash": "0.1.4", - "inquirer": "0.12.0", - "is-my-json-valid": "2.16.1", - "is-resolvable": "1.0.0", + "inquirer": "3.3.0", + "is-resolvable": "1.0.1", "js-yaml": "3.10.0", - "json-stable-stringify": "1.0.1", + "json-stable-stringify-without-jsonify": "1.0.1", "levn": "0.3.0", "lodash": "4.17.4", + "minimatch": "3.0.4", "mkdirp": "0.5.1", "natural-compare": "1.4.0", "optionator": "0.8.2", "path-is-inside": "1.0.2", - "pluralize": "1.2.1", - "progress": "1.1.8", + "pluralize": "7.0.0", + "progress": "2.0.0", "require-uncached": "1.0.3", - "shelljs": "0.7.8", - "strip-bom": "3.0.0", + "semver": "5.4.1", + "strip-ansi": "4.0.0", "strip-json-comments": "2.0.1", - "table": "3.8.3", - "text-table": "0.2.0", - "user-home": "2.0.0" + "table": "4.0.2", + "text-table": "0.2.0" }, "dependencies": { - "estraverse": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", - "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "ansi-escapes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.0.0.tgz", + "integrity": "sha512-O/klc27mWNUigtv0F8NJWbLF00OcegQalkqKURWdosW08YZKi4m6CnSUSvIZG1otNJbTWhN01Hhz389DW7mvDQ==", "dev": true }, - "inquirer": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz", - "integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=", + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", "dev": true, "requires": { - "ansi-escapes": "1.4.0", - "ansi-regex": "2.1.1", - "chalk": "1.1.3", - "cli-cursor": "1.0.2", + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "dev": true, + "requires": { + "restore-cursor": "2.0.0" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "external-editor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.1.0.tgz", + "integrity": "sha512-E44iT5QVOUJBKij4IIV3uvxuNlbKS38Tw1HiupxEIHPv9qtC2PrDYohbXV5U+1jnfIXttny8gUhj+oZvflFlzA==", + "dev": true, + "requires": { + "chardet": "0.4.2", + "iconv-lite": "0.4.19", + "tmp": "0.0.33" + } + }, + "figures": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "dev": true, + "requires": { + "escape-string-regexp": "1.0.5" + } + }, + "globals": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.1.0.tgz", + "integrity": "sha512-uEuWt9mqTlPDwSqi+sHjD4nWU/1N+q0fiWI9T1mZpD2UENqX20CFD5T/ziLZvztPaBKl7ZylUi1q6Qfm7E2CiQ==", + "dev": true + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "inquirer": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", + "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", + "dev": true, + "requires": { + "ansi-escapes": "3.0.0", + "chalk": "2.3.0", + "cli-cursor": "2.1.0", "cli-width": "2.2.0", - "figures": "1.7.0", + "external-editor": "2.1.0", + "figures": "2.0.0", "lodash": "4.17.4", - "readline2": "1.0.1", - "run-async": "0.1.0", - "rx-lite": "3.1.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", + "mute-stream": "0.0.7", + "run-async": "2.3.0", + "rx-lite": "4.0.8", + "rx-lite-aggregates": "4.0.8", + "string-width": "2.1.1", + "strip-ansi": "4.0.0", "through": "2.3.8" } }, - "run-async": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz", - "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", + "dev": true + }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", "dev": true, "requires": { - "once": "1.4.0" + "mimic-fn": "1.1.0" } }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "dev": true, + "requires": { + "onetime": "2.0.1", + "signal-exit": "3.0.2" + } + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "requires": { + "os-tmpdir": "1.0.2" + } } } }, "eslint-config-airbnb": { - "version": "15.0.1", - "resolved": "https://registry.npmjs.org/eslint-config-airbnb/-/eslint-config-airbnb-15.0.1.tgz", - "integrity": "sha1-e1GI5bfHS5ss5jn9Xh2rqP12Gu0=", + "version": "16.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb/-/eslint-config-airbnb-16.1.0.tgz", + "integrity": "sha512-zLyOhVWhzB/jwbz7IPSbkUuj7X2ox4PHXTcZkEmDqTvd0baJmJyuxlFPDlZOE/Y5bC+HQRaEkT3FoHo9wIdRiw==", "dev": true, "requires": { - "eslint-config-airbnb-base": "11.3.2" + "eslint-config-airbnb-base": "12.1.0" } }, "eslint-config-airbnb-base": { - "version": "11.3.2", - "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-11.3.2.tgz", - "integrity": "sha512-/fhjt/VqzBA2SRsx7ErDtv6Ayf+XLw9LIOqmpBuHFCVwyJo2EtzGWMB9fYRFBoWWQLxmNmCpenNiH0RxyeS41w==", + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-12.1.0.tgz", + "integrity": "sha512-/vjm0Px5ZCpmJqnjIzcFb9TKZrKWz0gnuG/7Gfkt0Db1ELJR51xkZth+t14rYdqWgX836XbuxtArbIHlVhbLBA==", "dev": true, "requires": { "eslint-restricted-globals": "0.1.1" } }, "eslint-config-prettier": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-2.6.0.tgz", - "integrity": "sha1-8h2w67Q4rWePuYlGCXxLsZi+/Mw=", + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-2.9.0.tgz", + "integrity": "sha512-ag8YEyBXsm3nmOv1Hz991VtNNDMRa+MNy8cY47Pl4bw6iuzqKbJajXdqUpiw13STdLLrznxgm1hj9NhxeOYq0A==", "dev": true, "requires": { "get-stdin": "5.0.1" + }, + "dependencies": { + "get-stdin": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz", + "integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=", + "dev": true + } } }, "eslint-import-resolver-node": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.2.3.tgz", - "integrity": "sha1-Wt2BBujJKNssuiMrzZ76hG49oWw=", + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.1.tgz", + "integrity": "sha512-yUtXS15gIcij68NmXmP9Ni77AQuCN0itXbCc/jWd8C6/yKZaSNXicpC8cgvjnxVdmfsosIXrjpzFq7GcDryb6A==", "dev": true, "requires": { "debug": "2.6.9", - "object-assign": "4.1.1", - "resolve": "1.4.0" + "resolve": "1.5.0" } }, "eslint-import-resolver-webpack": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-webpack/-/eslint-import-resolver-webpack-0.8.1.tgz", - "integrity": "sha1-x/i01b08W0iUV+VyjF2xxP+6yao=", + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-webpack/-/eslint-import-resolver-webpack-0.8.3.tgz", + "integrity": "sha512-xLSNz4KbWvb8KrkDqWSmgmztq8uXq7R/rviOw1DYrh3Luxc8vpMnwO4hOt9Eot45VBiyjt1PxidrvJbZIWlItA==", "dev": true, "requires": { "array-find": "1.0.0", @@ -3482,11 +4665,11 @@ "enhanced-resolve": "0.9.1", "find-root": "0.1.2", "has": "1.0.1", - "interpret": "1.0.4", + "interpret": "1.1.0", "is-absolute": "0.2.6", "lodash.get": "3.7.0", "node-libs-browser": "1.1.1", - "resolve": "1.4.0", + "resolve": "1.5.0", "semver": "5.4.1" }, "dependencies": { @@ -3507,7 +4690,7 @@ "buffer": "4.9.1", "console-browserify": "1.1.0", "constants-browserify": "1.0.0", - "crypto-browserify": "3.11.1", + "crypto-browserify": "3.12.0", "domain-browser": "1.1.7", "events": "1.1.1", "https-browserify": "0.0.1", @@ -3530,12 +4713,11 @@ } }, "eslint-loader": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/eslint-loader/-/eslint-loader-1.7.1.tgz", - "integrity": "sha1-ULFY3WJy3O+5fphCVIN/gaWALOA=", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/eslint-loader/-/eslint-loader-1.9.0.tgz", + "integrity": "sha512-40aN976qSNPyb9ejTqjEthZITpls1SVKtwguahmH1dzGCwQU/vySE+xX33VZmD8csU0ahVNCtFlsPgKqRBiqgg==", "dev": true, "requires": { - "find-cache-dir": "0.1.1", "loader-fs-cache": "1.0.1", "loader-utils": "1.1.0", "object-assign": "4.1.1", @@ -3564,19 +4746,49 @@ "requires": { "debug": "2.6.9", "pkg-dir": "1.0.0" + }, + "dependencies": { + "find-up": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "dev": true, + "requires": { + "path-exists": "2.1.0", + "pinkie-promise": "2.0.1" + } + }, + "path-exists": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "dev": true, + "requires": { + "pinkie-promise": "2.0.1" + } + }, + "pkg-dir": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-1.0.0.tgz", + "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=", + "dev": true, + "requires": { + "find-up": "1.1.2" + } + } } }, "eslint-plugin-import": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.3.0.tgz", - "integrity": "sha1-N8gB4K2g4pbL3yDD85OstbUq82s=", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.8.0.tgz", + "integrity": "sha512-Rf7dfKJxZ16QuTgVv1OYNxkZcsu/hULFnC+e+w0Gzi6jMC3guQoWQgxYxc54IDRinlb6/0v5z/PxxIKmVctN+g==", "dev": true, "requires": { "builtin-modules": "1.1.1", "contains-path": "0.1.0", "debug": "2.6.9", "doctrine": "1.5.0", - "eslint-import-resolver-node": "0.2.3", + "eslint-import-resolver-node": "0.3.1", "eslint-module-utils": "2.1.1", "has": "1.0.1", "lodash.cond": "4.5.2", @@ -3645,24 +4857,24 @@ } }, "eslint-plugin-jsx-a11y": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-5.0.3.tgz", - "integrity": "sha1-SpOfduwSUBBSiCMzG/lIzFczgLY=", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.0.3.tgz", + "integrity": "sha1-VFg9GuRCSDFi4EDhPMMYZUZRAOU=", "dev": true, "requires": { - "aria-query": "0.5.0", + "aria-query": "0.7.0", "array-includes": "3.0.3", "ast-types-flow": "0.0.7", "axobject-query": "0.1.0", "damerau-levenshtein": "1.0.4", "emoji-regex": "6.5.1", - "jsx-ast-utils": "1.4.1" + "jsx-ast-utils": "2.0.1" } }, "eslint-plugin-prettier": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-2.3.1.tgz", - "integrity": "sha512-AV8shBlGN9tRZffj5v/f4uiQWlP3qiQ+lh+BhTqRLuKSyczx+HRWVkVZaf7dOmguxghAH1wftnou/JUEEChhGg==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-2.4.0.tgz", + "integrity": "sha512-P0EohHM1MwL36GX5l1TOEYyt/5d7hcxrX3CqCjibTN3dH7VCAy2kjsC/WB6dUHnpB4mFkZq1Ndfh2DYQ2QMEGQ==", "dev": true, "requires": { "fast-diff": "1.1.2", @@ -3670,14 +4882,15 @@ } }, "eslint-plugin-react": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.0.1.tgz", - "integrity": "sha1-54EH4eVZxuKxd4a7Z8LioBCtDS8=", + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.5.1.tgz", + "integrity": "sha512-YGSjB9Qu6QbVTroUZi66pYky3DfoIPLdHQ/wmrBGyBRnwxQsBXAov9j2rpXt/55i8nyMv6IRWJv2s4d4YnduzQ==", "dev": true, "requires": { - "doctrine": "2.0.0", + "doctrine": "2.0.2", "has": "1.0.1", - "jsx-ast-utils": "1.4.1" + "jsx-ast-utils": "2.0.1", + "prop-types": "15.6.0" } }, "eslint-restricted-globals": { @@ -3686,13 +4899,37 @@ "integrity": "sha1-NfDVy8ZMLj7WLpO0saevBbp+1Nc=", "dev": true }, + "eslint-scope": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.1.tgz", + "integrity": "sha1-PWPD7f2gLgbgGkUq2IyqzHzctug=", + "dev": true, + "requires": { + "esrecurse": "4.2.0", + "estraverse": "4.2.0" + }, + "dependencies": { + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + } + } + }, + "eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", + "dev": true + }, "espree": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.1.tgz", - "integrity": "sha1-DJiLirRttTEAoZVK5LqZXd0n2H4=", + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.2.tgz", + "integrity": "sha512-sadKeYwaR/aJ3stC2CdvgXu1T16TdYN+qwCpcWbMnGJ8s0zNWemzrvb2GbD4OhmJ/fwpJjudThAlLobGbWZbCQ==", "dev": true, "requires": { - "acorn": "5.1.2", + "acorn": "5.3.0", "acorn-jsx": "3.0.1" } }, @@ -3762,22 +4999,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.35" - } - }, - "event-stream": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", - "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", - "dev": true, - "requires": { - "duplexer": "0.1.1", - "from": "0.1.7", - "map-stream": "0.1.0", - "pause-stream": "0.0.11", - "split": "0.3.3", - "stream-combiner": "0.0.4", - "through": "2.3.8" + "es5-ext": "0.10.37" } }, "eventemitter3": { @@ -3812,9 +5034,9 @@ } }, "execa": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", - "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.8.0.tgz", + "integrity": "sha1-2NdrvBtVIX7RkP1t1J08d07PyNo=", "dev": true, "requires": { "cross-spawn": "5.1.0", @@ -3927,9 +5149,9 @@ } }, "expose-loader": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/expose-loader/-/expose-loader-0.7.3.tgz", - "integrity": "sha1-NfvTZZeJ5PqoH1nei36fw55GbVE=", + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/expose-loader/-/expose-loader-0.7.4.tgz", + "integrity": "sha512-lweINkewAXcQtNjd7j1gO3cd8O/8lNYijsEwH4YZ+Dv3gT2Kh9/YvJov5Mdp2A75QIhgOvsSyRa/ZG3wYjNZpA==", "dev": true }, "express": { @@ -4000,6 +5222,12 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==", "dev": true + }, + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", + "dev": true } } }, @@ -4009,6 +5237,15 @@ "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", "dev": true }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + }, "external-editor": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-1.1.1.tgz", @@ -4058,6 +5295,12 @@ "integrity": "sha512-KaJUt+M9t1qaIteSvjc6P3RbMdXsNhK61GRftR6SNxqmhthcd9MGIi4T+o0jD8LUSpSnSKXE20nLtJ3fOHxQig==", "dev": true }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true + }, "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", @@ -4079,6 +5322,29 @@ "websocket-driver": "0.7.0" } }, + "fbjs": { + "version": "0.8.16", + "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.16.tgz", + "integrity": "sha1-XmdDL1UNxBtXK/VYR7ispk5TN9s=", + "dev": true, + "requires": { + "core-js": "1.2.7", + "isomorphic-fetch": "2.2.1", + "loose-envify": "1.3.1", + "object-assign": "4.1.1", + "promise": "7.3.1", + "setimmediate": "1.0.5", + "ua-parser-js": "0.7.17" + }, + "dependencies": { + "core-js": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", + "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=", + "dev": true + } + } + }, "figures": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", @@ -4100,12 +5366,13 @@ } }, "file-loader": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/file-loader/-/file-loader-0.11.1.tgz", - "integrity": "sha1-azKO4SNKcp5OR9Njdd1tNcDh24Q=", + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/file-loader/-/file-loader-1.1.6.tgz", + "integrity": "sha512-873ztuL+/hfvXbLDJ262PGO6XjERnybJu2gW1/5j8HUfxSiFJI9Hj/DhZ50ZGRUxBvuNiazb/cM2rh9pqrxP6Q==", "dev": true, "requires": { - "loader-utils": "1.1.0" + "loader-utils": "1.1.0", + "schema-utils": "0.3.0" }, "dependencies": { "loader-utils": { @@ -4128,9 +5395,9 @@ "dev": true }, "filesize": { - "version": "3.5.10", - "resolved": "https://registry.npmjs.org/filesize/-/filesize-3.5.10.tgz", - "integrity": "sha1-/I+iPdtO+eXgq24eZPZ5okpWdh8=", + "version": "3.5.11", + "resolved": "https://registry.npmjs.org/filesize/-/filesize-3.5.11.tgz", + "integrity": "sha512-ZH7loueKBoDb7yG9esn1U+fgq7BzlzW6NRi5/rMdxIZ05dj7GFD/Xc5rq2CDt5Yq86CyfSYVyx4242QQNZbx1g==", "dev": true }, "fill-range": { @@ -4159,17 +5426,25 @@ "parseurl": "1.3.2", "statuses": "1.3.1", "unpipe": "1.0.0" + }, + "dependencies": { + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", + "dev": true + } } }, "find-cache-dir": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-0.1.1.tgz", - "integrity": "sha1-yN765XyKUqinhPnjHFfHQumToLk=", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-1.0.0.tgz", + "integrity": "sha1-kojj6ePMN0hxfTnq3hfPcfww7m8=", "dev": true, "requires": { "commondir": "1.0.1", - "mkdirp": "0.5.1", - "pkg-dir": "1.0.0" + "make-dir": "1.1.0", + "pkg-dir": "2.0.0" } }, "find-node-modules": { @@ -4237,16 +5512,6 @@ "readable-stream": "2.0.6" } }, - "follow-redirects": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-0.0.7.tgz", - "integrity": "sha1-NLkLqyqRGqNHVx2pDyK9NuzYqRk=", - "dev": true, - "requires": { - "debug": "2.6.9", - "stream-consume": "0.1.0" - } - }, "for-each": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.2.tgz", @@ -4277,12 +5542,6 @@ "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", "dev": true }, - "foreachasync": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/foreachasync/-/foreachasync-3.0.0.tgz", - "integrity": "sha1-VQKYfchxS+M5IJfzLgBxyd7gfPY=", - "dev": true - }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -4306,18 +5565,21 @@ "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=", "dev": true }, + "fragment-cache": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", + "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", + "dev": true, + "requires": { + "map-cache": "0.2.2" + } + }, "fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", "dev": true }, - "from": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", - "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", - "dev": true - }, "from2": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", @@ -4329,9 +5591,9 @@ } }, "front-matter": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/front-matter/-/front-matter-2.2.0.tgz", - "integrity": "sha1-NSBfZ1IkMLEhPvJhSeywaFef44o=", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/front-matter/-/front-matter-2.3.0.tgz", + "integrity": "sha1-cgOviWzjV+4E4qpFFp6pHtf2dQQ=", "dev": true, "requires": { "js-yaml": "3.10.0" @@ -4356,6 +5618,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-3.0.1.tgz", "integrity": "sha1-N5TzeMWLNC6n27sjCVEJxLO2IpE=", + "dev": true, "requires": { "graceful-fs": "4.1.11", "jsonfile": "3.0.1", @@ -4374,22 +5637,933 @@ "readable-stream": "2.0.6" } }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" - }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "fsevents": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.3.tgz", + "integrity": "sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q==", + "dev": true, + "optional": true, + "requires": { + "nan": "2.8.0", + "node-pre-gyp": "0.6.39" + }, + "dependencies": { + "abbrev": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true + }, + "ajv": { + "version": "4.11.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true + }, + "aproba": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "delegates": "1.0.0", + "readable-stream": "2.2.9" + } + }, + "asn1": { + "version": "0.2.3", + "bundled": true, + "dev": true, + "optional": true + }, + "assert-plus": { + "version": "0.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "asynckit": { + "version": "0.4.0", + "bundled": true, + "dev": true, + "optional": true + }, + "aws-sign2": { + "version": "0.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "aws4": { + "version": "1.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "balanced-match": { + "version": "0.4.2", + "bundled": true, + "dev": true + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, + "block-stream": { + "version": "0.0.9", + "bundled": true, + "dev": true, + "requires": { + "inherits": "2.0.3" + } + }, + "boom": { + "version": "2.10.1", + "bundled": true, + "dev": true, + "requires": { + "hoek": "2.16.3" + } + }, + "brace-expansion": { + "version": "1.1.7", + "bundled": true, + "dev": true, + "requires": { + "balanced-match": "0.4.2", + "concat-map": "0.0.1" + } + }, + "buffer-shims": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "caseless": { + "version": "0.12.0", + "bundled": true, + "dev": true, + "optional": true + }, + "co": { + "version": "4.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "combined-stream": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "requires": { + "delayed-stream": "1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "bundled": true, + "dev": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "cryptiles": { + "version": "2.0.5", + "bundled": true, + "dev": true, + "requires": { + "boom": "2.10.1" + } + }, + "dashdash": { + "version": "1.14.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "debug": { + "version": "2.6.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.4.2", + "bundled": true, + "dev": true, + "optional": true + }, + "delayed-stream": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "detect-libc": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "ecc-jsbn": { + "version": "0.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "extend": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "extsprintf": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "forever-agent": { + "version": "0.6.1", + "bundled": true, + "dev": true, + "optional": true + }, + "form-data": { + "version": "2.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.15" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "fstream": { + "version": "1.0.11", + "bundled": true, + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "inherits": "2.0.3", + "mkdirp": "0.5.1", + "rimraf": "2.6.1" + } + }, + "fstream-ignore": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "fstream": "1.0.11", + "inherits": "2.0.3", + "minimatch": "3.0.4" + } + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aproba": "1.1.1", + "console-control-strings": "1.1.0", + "has-unicode": "2.0.1", + "object-assign": "4.1.1", + "signal-exit": "3.0.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wide-align": "1.1.2" + } + }, + "getpass": { + "version": "0.1.7", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "glob": { + "version": "7.1.2", + "bundled": true, + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "bundled": true, + "dev": true + }, + "har-schema": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "optional": true + }, + "har-validator": { + "version": "4.2.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ajv": "4.11.8", + "har-schema": "1.0.5" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "hawk": { + "version": "3.1.3", + "bundled": true, + "dev": true, + "requires": { + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" + } + }, + "hoek": { + "version": "2.16.3", + "bundled": true, + "dev": true + }, + "http-signature": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "0.2.0", + "jsprim": "1.4.0", + "sshpk": "1.13.0" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "dev": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true, + "dev": true + }, + "ini": { + "version": "1.3.4", + "bundled": true, + "dev": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "isarray": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "isstream": { + "version": "0.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "jodid25519": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "jsbn": { + "version": "0.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "json-schema": { + "version": "0.2.3", + "bundled": true, + "dev": true, + "optional": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsonify": "0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "jsonify": { + "version": "0.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "jsprim": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.0.2", + "json-schema": "0.2.3", + "verror": "1.3.6" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "mime-db": { + "version": "1.27.0", + "bundled": true, + "dev": true + }, + "mime-types": { + "version": "2.1.15", + "bundled": true, + "dev": true, + "requires": { + "mime-db": "1.27.0" + } + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "dev": true, + "requires": { + "brace-expansion": "1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true, + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "node-pre-gyp": { + "version": "0.6.39", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "detect-libc": "1.0.2", + "hawk": "3.1.3", + "mkdirp": "0.5.1", + "nopt": "4.0.1", + "npmlog": "4.1.0", + "rc": "1.2.1", + "request": "2.81.0", + "rimraf": "2.6.1", + "semver": "5.3.0", + "tar": "2.2.1", + "tar-pack": "3.4.0" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "abbrev": "1.1.0", + "osenv": "0.1.4" + } + }, + "npmlog": { + "version": "4.1.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "are-we-there-yet": "1.1.4", + "console-control-strings": "1.1.0", + "gauge": "2.7.4", + "set-blocking": "2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "oauth-sign": { + "version": "0.8.2", + "bundled": true, + "dev": true, + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "osenv": { + "version": "0.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "performance-now": { + "version": "0.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "process-nextick-args": { + "version": "1.0.7", + "bundled": true, + "dev": true + }, + "punycode": { + "version": "1.4.1", + "bundled": true, + "dev": true, + "optional": true + }, + "qs": { + "version": "6.4.0", + "bundled": true, + "dev": true, + "optional": true + }, + "rc": { + "version": "1.2.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "deep-extend": "0.4.2", + "ini": "1.3.4", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "readable-stream": { + "version": "2.2.9", + "bundled": true, + "dev": true, + "requires": { + "buffer-shims": "1.0.0", + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "string_decoder": "1.0.1", + "util-deprecate": "1.0.2" + } + }, + "request": { + "version": "2.81.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "4.2.1", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.15", + "oauth-sign": "0.8.2", + "performance-now": "0.2.0", + "qs": "6.4.0", + "safe-buffer": "5.0.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.2", + "tunnel-agent": "0.6.0", + "uuid": "3.0.1" + } + }, + "rimraf": { + "version": "2.6.1", + "bundled": true, + "dev": true, + "requires": { + "glob": "7.1.2" + } + }, + "safe-buffer": { + "version": "5.0.1", + "bundled": true, + "dev": true + }, + "semver": { + "version": "5.3.0", + "bundled": true, + "dev": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "sntp": { + "version": "1.0.9", + "bundled": true, + "dev": true, + "requires": { + "hoek": "2.16.3" + } + }, + "sshpk": { + "version": "1.13.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jodid25519": "1.0.2", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "string_decoder": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, + "stringstream": { + "version": "0.0.5", + "bundled": true, + "dev": true, + "optional": true + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "tar": { + "version": "2.2.1", + "bundled": true, + "dev": true, + "requires": { + "block-stream": "0.0.9", + "fstream": "1.0.11", + "inherits": "2.0.3" + } + }, + "tar-pack": { + "version": "3.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "debug": "2.6.8", + "fstream": "1.0.11", + "fstream-ignore": "1.0.5", + "once": "1.4.0", + "readable-stream": "2.2.9", + "rimraf": "2.6.1", + "tar": "2.2.1", + "uid-number": "0.0.6" + } + }, + "tough-cookie": { + "version": "2.3.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "punycode": "1.4.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "bundled": true, + "dev": true, + "optional": true + }, + "uid-number": { + "version": "0.0.6", + "bundled": true, + "dev": true, + "optional": true + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "uuid": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "verror": { + "version": "1.3.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "extsprintf": "1.0.2" + } + }, + "wide-align": { + "version": "1.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "string-width": "1.0.2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true, + "dev": true + } + } + }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, "gauge": { "version": "2.7.4", "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", "dev": true, + "optional": true, "requires": { "aproba": "1.2.0", "console-control-strings": "1.1.0", @@ -4401,21 +6575,6 @@ "wide-align": "1.1.2" } }, - "generate-function": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", - "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", - "dev": true - }, - "generate-object-property": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", - "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", - "dev": true, - "requires": { - "is-property": "1.0.2" - } - }, "get-caller-file": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz", @@ -4423,9 +6582,9 @@ "dev": true }, "get-stdin": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz", - "integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", + "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", "dev": true }, "get-stream": { @@ -4434,6 +6593,12 @@ "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", "dev": true }, + "get-value": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", + "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", + "dev": true + }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -4447,6 +6612,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/gh-pages/-/gh-pages-1.0.0.tgz", "integrity": "sha1-Skb0wlQ596K35oNVBNSknpSfBMo=", + "dev": true, "requires": { "async": "2.1.4", "base64url": "2.0.0", @@ -4457,59 +6623,94 @@ "rimraf": "2.6.2" }, "dependencies": { + "async": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.1.4.tgz", + "integrity": "sha1-LSFgx3iAMuTdbL4lAvH5osj2zeQ=", + "dev": true, + "requires": { + "lodash": "4.17.4" + } + }, "commander": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", + "dev": true, "requires": { "graceful-readlink": "1.0.1" } } } }, - "git-head": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/git-head/-/git-head-1.20.1.tgz", - "integrity": "sha1-A20WpLN0lJ5OPa8VgnkDaG08zVI=", + "git-log-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/git-log-parser/-/git-log-parser-1.2.0.tgz", + "integrity": "sha1-LmpMGxP8AAKCB7p5WnrDFme5/Uo=", "dev": true, "requires": { - "git-refs": "1.1.3" + "argv-formatter": "1.0.0", + "spawn-error-forwarder": "1.0.0", + "split2": "1.0.0", + "stream-combiner2": "1.1.1", + "through2": "2.0.3", + "traverse": "0.6.6" + }, + "dependencies": { + "split2": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-1.0.0.tgz", + "integrity": "sha1-UuLiIdiMdfmnP5BVbiY/+WdysxQ=", + "dev": true, + "requires": { + "through2": "2.0.3" + } + } } }, - "git-refs": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/git-refs/-/git-refs-1.1.3.tgz", - "integrity": "sha1-gwl8s6klhcSkkm7FTiGC354g6J0=", + "git-up": { + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/git-up/-/git-up-2.0.10.tgz", + "integrity": "sha512-2v4UN3qV2RGypD9QpmUjpk+4+RlYpW8GFuiZqQnKmvei08HsFPd0RfbDvEhnE4wBvnYs8ORVtYpOFuuCEmBVBw==", "dev": true, "requires": { - "path-object": "2.3.0", - "slash": "1.0.0", - "walk": "2.3.9" + "is-ssh": "1.3.0", + "parse-url": "1.3.11" } }, - "github": { - "version": "8.2.1", - "resolved": "https://registry.npmjs.org/github/-/github-8.2.1.tgz", - "integrity": "sha1-YWsiEfvNHMhjFmmu1nZT5i61OBY=", + "git-url-parse": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/git-url-parse/-/git-url-parse-7.0.2.tgz", + "integrity": "sha512-OQVonLdJfnGUz7Umyh9NmkZ4j9QmTB+r8ARqqSeZWlMgepn6oTrrHn7wSM5ptJQ1AcXj04xHFacpZVcXvKQAqg==", "dev": true, "requires": { - "follow-redirects": "0.0.7", - "https-proxy-agent": "1.0.0", - "mime": "1.4.1", - "netrc": "0.1.4" + "git-up": "2.0.10" } }, - "github-url-from-git": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/github-url-from-git/-/github-url-from-git-1.5.0.tgz", - "integrity": "sha1-+YX+3MCpqledyI16/waNVcxiUaA=", - "dev": true - }, - "github-url-from-username-repo": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/github-url-from-username-repo/-/github-url-from-username-repo-1.0.2.tgz", - "integrity": "sha1-fdeTMNKr5pwQws73lxTJchV5Hfo=", - "dev": true + "github": { + "version": "13.0.1", + "resolved": "https://registry.npmjs.org/github/-/github-13.0.1.tgz", + "integrity": "sha512-rApJzcnzy6E3WXhjGlSeRlWKnKM/yoi0fAxNjcOuq+1fjX4dMsiS/AWakrrhpMV3ZHi+mbNgNopS5d3go2AopQ==", + "dev": true, + "requires": { + "debug": "3.1.0", + "dotenv": "4.0.0", + "https-proxy-agent": "2.1.1", + "lodash": "4.17.4", + "proxy-from-env": "1.0.0", + "url-template": "2.0.8" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } + } }, "gl-matrix": { "version": "2.3.1", @@ -4566,6 +6767,15 @@ } } }, + "global-dirs": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", + "integrity": "sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=", + "dev": true, + "requires": { + "ini": "1.3.5" + } + }, "global-modules": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-0.2.3.tgz", @@ -4583,7 +6793,7 @@ "dev": true, "requires": { "homedir-polyfill": "1.0.1", - "ini": "1.3.4", + "ini": "1.3.5", "is-windows": "0.2.0", "which": "1.3.0" } @@ -4598,6 +6808,7 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", + "dev": true, "requires": { "array-union": "1.0.2", "glob": "7.1.2", @@ -4606,20 +6817,55 @@ "pinkie-promise": "2.0.1" } }, + "got": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/got/-/got-8.0.1.tgz", + "integrity": "sha1-bX+Ls+uZ5a+RLv4moQRHZEHgjn8=", + "dev": true, + "requires": { + "@sindresorhus/is": "0.6.0", + "cacheable-request": "2.1.4", + "decompress-response": "3.3.0", + "duplexer3": "0.1.4", + "get-stream": "3.0.0", + "into-stream": "3.1.0", + "is-retry-allowed": "1.1.0", + "isurl": "1.0.0", + "lowercase-keys": "1.0.0", + "mimic-response": "1.0.0", + "p-cancelable": "0.3.0", + "p-timeout": "2.0.1", + "pify": "3.0.0", + "safe-buffer": "5.1.1", + "timed-out": "4.0.1", + "url-parse-lax": "3.0.0", + "url-to-options": "1.0.1" + }, + "dependencies": { + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + } + } + }, "graceful-fs": { "version": "4.1.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true }, "graceful-readlink": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", - "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=" + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", + "dev": true }, "gzip-size": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-4.0.0.tgz", - "integrity": "sha512-6SWfFRd8r8VTKTpJCR7h/T6IbCaK+jM/n2gB1+pV3IrKcrLO1WTb8ZWdaRy1T/nwOz80cp4gAJf8sujpZxfA1w==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-4.1.0.tgz", + "integrity": "sha1-iuCWJX6r59acRb4rZ8RIEk/7UXw=", "dev": true, "requires": { "duplexer": "0.1.1", @@ -4641,9 +6887,9 @@ "dev": true }, "handlebars": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.10.tgz", - "integrity": "sha1-PTDHGLCaPZbyPqTMH0A8TTup/08=", + "version": "4.0.11", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.11.tgz", + "integrity": "sha1-Ywo13+ApS8KB7a5v/F0yn8eYLcw=", "dev": true, "requires": { "async": "1.5.2", @@ -4652,12 +6898,6 @@ "uglify-js": "2.8.29" }, "dependencies": { - "async": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", - "dev": true - }, "source-map": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", @@ -4687,22 +6927,8 @@ "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", "dev": true, "requires": { - "ajv": "5.2.3", + "ajv": "5.5.2", "har-schema": "2.0.0" - }, - "dependencies": { - "ajv": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.2.3.tgz", - "integrity": "sha1-wG9Zh3jETGsWGrr+NGa4GtGBTtI=", - "dev": true, - "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.0.0", - "json-schema-traverse": "0.3.1", - "json-stable-stringify": "1.0.1" - } - } } }, "has": { @@ -4752,11 +6978,87 @@ "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", "dev": true }, + "has-symbol-support-x": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/has-symbol-support-x/-/has-symbol-support-x-1.4.1.tgz", + "integrity": "sha512-JkaetveU7hFbqnAC1EV1sF4rlojU2D4Usc5CmS69l6NfmPDnpnFUegzFg33eDkkpNCxZ0mQp65HwUDrNFS/8MA==", + "dev": true + }, + "has-to-string-tag-x": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz", + "integrity": "sha512-vdbKfmw+3LoOYVr+mtxHaX5a96+0f3DljYd8JOqvOLsf5mw2Otda2qCDT9qRqLAhrjyQ0h7ual5nOiASpsGNFw==", + "dev": true, + "requires": { + "has-symbol-support-x": "1.4.1" + } + }, "has-unicode": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", - "dev": true + "dev": true, + "optional": true + }, + "has-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", + "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", + "dev": true, + "requires": { + "get-value": "2.0.6", + "has-values": "1.0.0", + "isobject": "3.0.1" + }, + "dependencies": { + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, + "has-values": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", + "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", + "dev": true, + "requires": { + "is-number": "3.0.0", + "kind-of": "4.0.0" + }, + "dependencies": { + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } }, "hash-base": { "version": "2.0.2", @@ -4786,7 +7088,7 @@ "boom": "4.3.1", "cryptiles": "3.1.2", "hoek": "4.2.0", - "sntp": "2.0.2" + "sntp": "2.1.0" } }, "he": { @@ -4871,14 +7173,14 @@ "dev": true }, "html-loader": { - "version": "0.4.5", - "resolved": "https://registry.npmjs.org/html-loader/-/html-loader-0.4.5.tgz", - "integrity": "sha1-X7zYfNY6XEmn/OL+VvQl4Fcpxow=", + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/html-loader/-/html-loader-0.5.1.tgz", + "integrity": "sha512-RxokXoxcsRSWcN553Ew+K0TUo68gQfmddTuUIZ4xRD8Ax1xXzX2UYQ3FC3D5MoRPGAdL1erWKeEFihDrrdxHiA==", "dev": true, "requires": { "es6-templates": "0.2.3", "fastparse": "1.1.1", - "html-minifier": "3.5.5", + "html-minifier": "3.5.8", "loader-utils": "1.1.0", "object-assign": "4.1.1" }, @@ -4897,41 +7199,53 @@ } }, "html-minifier": { - "version": "3.5.5", - "resolved": "https://registry.npmjs.org/html-minifier/-/html-minifier-3.5.5.tgz", - "integrity": "sha512-g+1+NBycQI0fGnggd52JM8TRUweG7+9W2wrtjGitMAqc4G7maweAHvVAAjz9veHseIH3tYKE2lk2USGSoewIrQ==", + "version": "3.5.8", + "resolved": "https://registry.npmjs.org/html-minifier/-/html-minifier-3.5.8.tgz", + "integrity": "sha512-WX7D6PB9PFq05fZ1/CyxPUuyqXed6vh2fGOM80+zJT5wAO93D/cUjLs0CcbBFjQmlwmCgRvl97RurtArIpOnkw==", "dev": true, "requires": { "camel-case": "3.0.0", "clean-css": "4.1.9", - "commander": "2.11.0", + "commander": "2.12.2", "he": "1.1.1", "ncname": "1.0.0", "param-case": "2.1.1", "relateurl": "0.2.7", - "uglify-js": "3.1.3" + "uglify-js": "3.3.4" }, "dependencies": { + "commander": { + "version": "2.12.2", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz", + "integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, "uglify-js": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.1.3.tgz", - "integrity": "sha512-5ZUOgufCHjN2mBBLfz63UtWTP6va2sSzBpNCM+/iqI6RnPzEhANmB0EKiKBYdQbc3v7KeomXJ2DJx0Xq9gvUvA==", + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.3.4.tgz", + "integrity": "sha512-hfIwuAQI5dlXP30UtdmWoYF9k+ypVqBXIdmd6ZKBiaNHHvA8ty7ZloMe3+7S5AEKVkxHbjByl4DfRHQ7QpZquw==", "dev": true, "requires": { - "commander": "2.11.0", - "source-map": "0.5.7" + "commander": "2.12.2", + "source-map": "0.6.1" } } } }, "html-webpack-plugin": { - "version": "2.28.0", - "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-2.28.0.tgz", - "integrity": "sha1-LnhjtX5f1I/iYzA+L/yTTDBk0Ak=", + "version": "2.30.1", + "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-2.30.1.tgz", + "integrity": "sha1-f5xCG36pHsRg9WUn1430hO51N9U=", "dev": true, "requires": { "bluebird": "3.5.1", - "html-minifier": "3.5.5", + "html-minifier": "3.5.8", "loader-utils": "0.2.17", "lodash": "4.17.4", "pretty-error": "2.1.1", @@ -4979,6 +7293,12 @@ } } }, + "http-cache-semantics": { + "version": "3.8.1", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz", + "integrity": "sha512-5ai2iksyV8ZXmnZhHH4rWPoxxistEexSi5936zIQ1bnNTW5VnA85B6P/VpXiRM017IgRvb2kKo1a//y+0wSp3w==", + "dev": true + }, "http-deceiver": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz", @@ -4994,7 +7314,7 @@ "depd": "1.1.1", "inherits": "2.0.3", "setprototypeof": "1.0.3", - "statuses": "1.3.1" + "statuses": "1.4.0" } }, "http-parser-js": { @@ -5060,14 +7380,24 @@ "dev": true }, "https-proxy-agent": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz", - "integrity": "sha1-NffabEjOTdv6JkiRrFk+5f+GceY=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.1.1.tgz", + "integrity": "sha512-LK6tQUR/VOkTI6ygAfWUKKP95I+e6M1h7N3PncGu1CATHCnex+CAv9ttR0lbHu1Uk2PXm/WoAHFo6JCGwMjVMw==", "dev": true, "requires": { - "agent-base": "2.1.1", - "debug": "2.6.9", - "extend": "3.0.1" + "agent-base": "4.1.2", + "debug": "3.1.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } } }, "iconv-lite": { @@ -5088,7 +7418,7 @@ "integrity": "sha1-g/Cg7DeL8yRheLbCrZE28TWxyWI=", "dev": true, "requires": { - "postcss": "6.0.13" + "postcss": "6.0.15" } }, "ieee754": { @@ -5104,9 +7434,9 @@ "dev": true }, "ignore": { - "version": "3.3.5", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.5.tgz", - "integrity": "sha512-JLH93mL8amZQhh/p6mfQgVBH3M6epNq3DfsXsTSuSrInVjwyYlFE1nv2AgfRCC8PoOhM0jwQ5v8s9LgbK7yGDw==", + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "image-size": { @@ -5120,6 +7450,39 @@ "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", "integrity": "sha1-nbHb0Pr43m++D13V5Wu2BigN5ps=" }, + "import-from": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/import-from/-/import-from-2.1.0.tgz", + "integrity": "sha1-M1238qev/VOqpHHUuAId7ja387E=", + "dev": true, + "requires": { + "resolve-from": "3.0.0" + }, + "dependencies": { + "resolve-from": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", + "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", + "dev": true + } + } + }, + "import-lazy": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz", + "integrity": "sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=", + "dev": true + }, + "import-local": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-0.1.1.tgz", + "integrity": "sha1-sReVcqrNwRxqkQCftDDbyrX2aKg=", + "dev": true, + "requires": { + "pkg-dir": "2.0.0", + "resolve-cwd": "2.0.0" + } + }, "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -5168,9 +7531,9 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, "ini": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", - "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -5195,10 +7558,29 @@ "through": "2.3.8" } }, + "internal-ip": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/internal-ip/-/internal-ip-1.2.0.tgz", + "integrity": "sha1-rp+/k7mEh4eF1QqN4bNWlWBYz1w=", + "dev": true, + "requires": { + "meow": "3.7.0" + } + }, "interpret": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.0.4.tgz", - "integrity": "sha1-ggzdWIuGj/sZGoCVBtbJyPISsbA=" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz", + "integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ=" + }, + "into-stream": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/into-stream/-/into-stream-3.1.0.tgz", + "integrity": "sha1-lvsKk2wSur1v8XUqF9BWFqvQlMY=", + "dev": true, + "requires": { + "from2": "2.3.0", + "p-is-promise": "1.1.0" + } }, "invariant": { "version": "2.2.2", @@ -5215,6 +7597,12 @@ "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", "dev": true }, + "ip": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", + "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=", + "dev": true + }, "ipaddr.js": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.5.2.tgz", @@ -5237,6 +7625,23 @@ "integrity": "sha1-UFMN+4T8yap9vnhS6Do3uTufKqY=", "dev": true }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + }, + "dependencies": { + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } + } + }, "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", @@ -5249,13 +7654,13 @@ "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", "dev": true, "requires": { - "binary-extensions": "1.10.0" + "binary-extensions": "1.11.0" } }, "is-buffer": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", - "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -5273,12 +7678,48 @@ "integrity": "sha1-hut1OSgF3cM69xySoO7fdO52BLI=", "dev": true }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "6.0.2" + }, + "dependencies": { + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } + } + }, "is-date-object": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", "dev": true }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "1.0.0", + "is-data-descriptor": "1.0.0", + "kind-of": "6.0.2" + }, + "dependencies": { + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } + } + }, "is-directory": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/is-directory/-/is-directory-0.3.1.tgz", @@ -5345,18 +7786,22 @@ "is-extglob": "1.0.0" } }, - "is-my-json-valid": { - "version": "2.16.1", - "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.16.1.tgz", - "integrity": "sha512-ochPsqWS1WXj8ZnMIV0vnNXooaMhp7cyL4FMSIPKTtnV0Ha/T19G2b9kkhcNsabV9bxYkze7/aLZJb/bYuFduQ==", + "is-installed-globally": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.1.0.tgz", + "integrity": "sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA=", "dev": true, "requires": { - "generate-function": "2.0.0", - "generate-object-property": "1.2.0", - "jsonpointer": "4.0.1", - "xtend": "4.0.1" + "global-dirs": "0.1.1", + "is-path-inside": "1.0.1" } }, + "is-npm": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", + "integrity": "sha1-8vtjpl5JBbQGyGBydloaTceTufQ=", + "dev": true + }, "is-number": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", @@ -5366,6 +7811,38 @@ "kind-of": "3.2.2" } }, + "is-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", + "dev": true + }, + "is-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz", + "integrity": "sha1-iVJojF7C/9awPsyF52ngKQMINHA=", + "dev": true + }, + "is-odd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-odd/-/is-odd-1.0.0.tgz", + "integrity": "sha1-O4qTLrAos3dcObsJ6RdnrM22kIg=", + "dev": true, + "requires": { + "is-number": "3.0.0" + }, + "dependencies": { + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + } + } + } + }, "is-path-cwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", @@ -5378,13 +7855,13 @@ "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=", "dev": true, "requires": { - "is-path-inside": "1.0.0" + "is-path-inside": "1.0.1" } }, "is-path-inside": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.0.tgz", - "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", + "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", "dev": true, "requires": { "path-is-inside": "1.0.2" @@ -5396,6 +7873,23 @@ "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", "dev": true }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "requires": { + "isobject": "3.0.1" + }, + "dependencies": { + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, "is-posix-bracket": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", @@ -5414,10 +7908,10 @@ "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", "dev": true }, - "is-property": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", - "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", + "is-redirect": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz", + "integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=", "dev": true }, "is-regex": { @@ -5439,12 +7933,24 @@ } }, "is-resolvable": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.0.tgz", - "integrity": "sha1-jfV8YeouPFAUCNEA+wE8+NbgzGI=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.1.tgz", + "integrity": "sha512-y5CXYbzvB3jTnWAZH1Nl7ykUWb6T3BcTs56HUruwBf8MhF56n1HWqhDWnVFo8GHrUPDgvUUNVhrc2U8W7iqz5g==", + "dev": true + }, + "is-retry-allowed": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", + "integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=", + "dev": true + }, + "is-ssh": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.3.0.tgz", + "integrity": "sha1-6+oRaaJhTaOSpjdANmw84EnY3/Y=", "dev": true, "requires": { - "tryit": "1.0.3" + "protocols": "1.4.6" } }, "is-stream": { @@ -5453,6 +7959,12 @@ "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", "dev": true }, + "is-subset": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-subset/-/is-subset-0.1.1.tgz", + "integrity": "sha1-ilkRfZMt4d4A8kX83TnOQ/HpOaY=", + "dev": true + }, "is-svg": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-svg/-/is-svg-2.1.0.tgz", @@ -5468,6 +7980,15 @@ "integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=", "dev": true }, + "is-text-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-text-path/-/is-text-path-1.0.1.tgz", + "integrity": "sha1-Thqg+1G/vLPpJogAE5cgLBd1tm4=", + "dev": true, + "requires": { + "text-extensions": "1.7.0" + } + }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -5495,6 +8016,12 @@ "integrity": "sha1-3hqm1j6indJIc3tp8f+LgALSEIw=", "dev": true }, + "is-wsl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", + "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=", + "dev": true + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -5521,6 +8048,16 @@ "isarray": "1.0.0" } }, + "isomorphic-fetch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", + "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", + "dev": true, + "requires": { + "node-fetch": "1.7.3", + "whatwg-fetch": "2.0.3" + } + }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -5538,7 +8075,7 @@ "escodegen": "1.8.1", "esprima": "2.7.3", "glob": "5.0.15", - "handlebars": "4.0.10", + "handlebars": "4.0.11", "js-yaml": "3.10.0", "mkdirp": "0.5.1", "nopt": "3.0.6", @@ -5549,12 +8086,6 @@ "wordwrap": "1.0.0" }, "dependencies": { - "async": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", - "dev": true - }, "glob": { "version": "5.0.15", "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", @@ -5598,9 +8129,9 @@ "dev": true }, "istanbul-lib-instrument": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-1.8.0.tgz", - "integrity": "sha1-ZvbJQhzJ7EcE928tsIS6kHiitTI=", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-1.9.1.tgz", + "integrity": "sha512-RQmXeQ7sphar7k7O1wTNzVczF9igKpaeGQAG9qR2L+BS4DCJNTI9nytRmIVYevwO0bbq+2CXvJmYDuz0gMrywA==", "dev": true, "requires": { "babel-generator": "6.26.0", @@ -5612,6 +8143,16 @@ "semver": "5.4.1" } }, + "isurl": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isurl/-/isurl-1.0.0.tgz", + "integrity": "sha512-1P/yWsxPlDtn7QeRD+ULKQPaIaN6yF368GZ2vDfv0AL0NwpStafjWCDDdn0k8wgFMWpVAqG7oJhxHnlud42i9w==", + "dev": true, + "requires": { + "has-to-string-tag-x": "1.4.1", + "is-object": "1.0.1" + } + }, "jest-docblock": { "version": "21.2.0", "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-21.2.0.tgz", @@ -5619,9 +8160,9 @@ "dev": true }, "js-base64": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.3.2.tgz", - "integrity": "sha512-Y2/+DnfJJXT1/FCwUebUhLWb3QihxiSC42+ctHLGogmW2jPY6LCapMdFZXRvVP2z6qyKW7s6qncE/9gSqZiArw==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.4.0.tgz", + "integrity": "sha512-Wehd+7Pf9tFvGb+ydPm9TjYjV8X1YHOVyG8QyELZxEMqOhemVwGRmoG8iQ/soqI3n8v4xn59zaLxiCJiaaRzKA==", "dev": true }, "js-tokens": { @@ -5661,12 +8202,24 @@ "integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=", "dev": true }, + "json-buffer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", + "integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=", + "dev": true + }, "json-loader": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/json-loader/-/json-loader-0.5.7.tgz", "integrity": "sha512-QLPs8Dj7lnf3e3QYS1zkCo+4ZwqOiF9d/nZnYozTISxXWCfNs9yuky5rJw4/W34s7POaNlbZmQGaB5NiXCbP4w==", "dev": true }, + "json-parse-better-errors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.1.tgz", + "integrity": "sha512-xyQpxeWWMKyJps9CuGJYeng6ssI5bpqS9ltQpdVQ90t4ql6NdnxFKh95JcRt2cun/DjMVNrdjniLPuMA69xmCw==", + "dev": true + }, "json-schema": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", @@ -5679,14 +8232,11 @@ "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", "dev": true }, - "json-stable-stringify": { + "json-stable-stringify-without-jsonify": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", - "dev": true, - "requires": { - "jsonify": "0.0.0" - } + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true }, "json-stringify-safe": { "version": "5.0.1", @@ -5710,20 +8260,15 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-3.0.1.tgz", "integrity": "sha1-pezG9l9T9mLEQVx2daAzHQmS7GY=", + "dev": true, "requires": { "graceful-fs": "4.1.11" } }, - "jsonify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", - "dev": true - }, - "jsonpointer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", - "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", + "jsonparse": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", + "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", "dev": true }, "jsprim": { @@ -5739,10 +8284,13 @@ } }, "jsx-ast-utils": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz", - "integrity": "sha1-OGchPo3Xm/Ho8jAMDPwe+xgsDfE=", - "dev": true + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz", + "integrity": "sha1-6AGxs5mF4g//yHtA43SAgOLcrH8=", + "dev": true, + "requires": { + "array-includes": "3.0.3" + } }, "jszip": { "version": "3.1.4", @@ -5778,7 +8326,7 @@ "isbinaryfile": "3.0.2", "lodash": "3.10.1", "log4js": "0.6.38", - "mime": "1.4.1", + "mime": "1.6.0", "minimatch": "3.0.4", "optimist": "0.6.1", "qjobs": "1.1.5", @@ -5852,7 +8400,7 @@ "loader-utils": "0.2.17", "lodash": "3.10.1", "source-map": "0.1.43", - "webpack-dev-middleware": "1.12.0" + "webpack-dev-middleware": "1.12.2" }, "dependencies": { "async": { @@ -5878,13 +8426,28 @@ } } }, + "keyv": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.0.0.tgz", + "integrity": "sha512-eguHnq22OE3uVoSYG0LVWNP+4ppamWr9+zWBe1bsNcovIMy6huUJFPgy4mGwCd/rnl3vOLGW1MTlu4c57CT1xA==", + "dev": true, + "requires": { + "json-buffer": "3.0.0" + } + }, + "killable": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/killable/-/killable-1.0.0.tgz", + "integrity": "sha1-2ouEvUfeU5WHj5XWTQLyRJ/gXms=", + "dev": true + }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.5" + "is-buffer": "1.1.6" } }, "klaw": { @@ -5923,74 +8486,120 @@ "dev": true, "requires": { "glob": "7.1.2", - "interpret": "1.0.4", + "interpret": "1.1.0", "rechoir": "0.6.2" } } } }, "kw-web-suite": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/kw-web-suite/-/kw-web-suite-3.1.1.tgz", - "integrity": "sha1-STFONK7xrsNtDwCRf3CwK5Ul1LY=", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/kw-web-suite/-/kw-web-suite-5.0.0.tgz", + "integrity": "sha512-qsZMVbog1yRemN5+2VWJViSR4p4ZlwNaYpPDguPUjNDHaz6jUs9kWYLT1Jwi//8Q0aiiYapXbm6bDT0+B0A5ig==", "dev": true, "requires": { - "autoprefixer": "7.1.1", - "babel-core": "6.24.1", - "babel-eslint": "7.2.3", - "babel-loader": "7.0.0", - "babel-plugin-minify-guarded-expressions": "0.1.1", - "babel-polyfill": "6.23.0", - "babel-preset-es2015": "6.24.1", + "autoprefixer": "7.2.4", + "babel-core": "6.26.0", + "babel-eslint": "8.1.2", + "babel-loader": "7.1.2", + "babel-polyfill": "6.26.0", + "babel-preset-env": "1.6.1", + "babel-preset-flow": "6.23.0", "babel-preset-react": "6.24.1", "commitizen": "2.9.6", - "css-loader": "0.28.4", - "cz-conventional-changelog": "2.0.0", - "eslint": "3.19.0", - "eslint-config-airbnb": "15.0.1", - "eslint-import-resolver-webpack": "0.8.1", - "eslint-loader": "1.7.1", - "eslint-plugin-import": "2.3.0", - "eslint-plugin-jsx-a11y": "5.0.3", - "eslint-plugin-react": "7.0.1", + "css-loader": "0.28.7", + "cz-conventional-changelog": "2.1.0", + "eslint": "4.14.0", + "eslint-config-airbnb": "16.1.0", + "eslint-config-prettier": "2.9.0", + "eslint-import-resolver-webpack": "0.8.3", + "eslint-loader": "1.9.0", + "eslint-plugin-import": "2.8.0", + "eslint-plugin-jsx-a11y": "6.0.3", + "eslint-plugin-prettier": "2.4.0", + "eslint-plugin-react": "7.5.1", "exports-loader": "0.6.4", - "expose-loader": "0.7.3", - "file-loader": "0.11.1", - "gh-pages": "1.0.0", + "expose-loader": "0.7.4", + "file-loader": "1.1.6", + "gh-pages": "1.1.0", "hson-loader": "2.0.0", - "html-loader": "0.4.5", - "html-webpack-plugin": "2.28.0", - "node-libs-browser": "2.0.0", - "normalize.css": "5.0.0", - "postcss-loader": "2.0.5", + "html-loader": "0.5.1", + "html-webpack-plugin": "2.30.1", + "node-libs-browser": "2.1.0", + "normalize.css": "7.0.0", + "postcss-loader": "2.0.10", + "prettier": "1.9.2", "raw-loader": "0.5.1", - "regexp-replace-loader": "1.0.0", - "semantic-release": "6.3.6", - "shader-loader": "1.3.0", - "shelljs": "0.7.7", + "regexp-replace-loader": "1.0.1", + "semantic-release": "11.0.2", + "shader-loader": "1.3.1", + "shelljs": "0.7.8", "shx": "0.2.2", - "string-replace-loader": "1.2.0", - "style-loader": "0.18.1", - "svg-sprite-loader": "3.0.5", - "url-loader": "0.5.8", - "webpack": "2.6.1", - "webpack-dev-server": "2.4.5", - "worker-loader": "0.8.0" + "size-limit": "0.13.2", + "string-replace-loader": "1.3.0", + "style-loader": "0.19.1", + "svg-sprite-loader": "3.6.2", + "url-loader": "0.6.2", + "webpack": "3.10.0", + "webpack-dev-server": "2.9.7", + "worker-loader": "1.1.0" }, "dependencies": { - "shelljs": { - "version": "0.7.7", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.7.tgz", - "integrity": "sha1-svXHfvlxSPS09uImguELuoZnz/E=", + "async": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", + "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", "dev": true, "requires": { - "glob": "7.1.2", - "interpret": "1.0.4", - "rechoir": "0.6.2" + "lodash": "4.17.4" + } + }, + "fs-extra": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", + "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "jsonfile": "4.0.0", + "universalify": "0.1.1" + } + }, + "gh-pages": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/gh-pages/-/gh-pages-1.1.0.tgz", + "integrity": "sha512-ZpDkeOVmIrN5mz+sBWDz5zmTqcbNJzI/updCwEv/7rrSdpTNlj1B5GhBqG7f4Q8p5sJOdnBV0SIqxJrxtZQ9FA==", + "dev": true, + "requires": { + "async": "2.6.0", + "base64url": "2.0.0", + "commander": "2.11.0", + "fs-extra": "4.0.3", + "globby": "6.1.0", + "graceful-fs": "4.1.11", + "rimraf": "2.6.2" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11" } } } }, + "latest-version": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-3.1.0.tgz", + "integrity": "sha1-ogU4P+oyKzO1rjsYq+4NwvNW7hU=", + "dev": true, + "requires": { + "package-json": "4.0.1" + } + }, "lazy-cache": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", @@ -6045,6 +8654,47 @@ "requires": { "find-cache-dir": "0.1.1", "mkdirp": "0.5.1" + }, + "dependencies": { + "find-cache-dir": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-0.1.1.tgz", + "integrity": "sha1-yN765XyKUqinhPnjHFfHQumToLk=", + "dev": true, + "requires": { + "commondir": "1.0.1", + "mkdirp": "0.5.1", + "pkg-dir": "1.0.0" + } + }, + "find-up": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "dev": true, + "requires": { + "path-exists": "2.1.0", + "pinkie-promise": "2.0.1" + } + }, + "path-exists": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "dev": true, + "requires": { + "pinkie-promise": "2.0.1" + } + }, + "pkg-dir": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-1.0.0.tgz", + "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=", + "dev": true, + "requires": { + "find-up": "1.1.2" + } + } } }, "loader-runner": { @@ -6078,22 +8728,7 @@ "lodash": { "version": "4.17.4", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" - }, - "lodash._baseassign": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", - "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", - "dev": true, - "requires": { - "lodash._basecopy": "3.0.1", - "lodash.keys": "3.1.2" - } - }, - "lodash._basecopy": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", - "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", "dev": true }, "lodash._baseget": { @@ -6102,35 +8737,6 @@ "integrity": "sha1-G2rh1frPPCVTI1ChPBGXy4u2dPQ=", "dev": true }, - "lodash._bindcallback": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz", - "integrity": "sha1-5THCdkTPi1epnhftlbNcdIeJOS4=", - "dev": true - }, - "lodash._createassigner": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz", - "integrity": "sha1-g4pbri/aymOsIt7o4Z+k5taXCxE=", - "dev": true, - "requires": { - "lodash._bindcallback": "3.0.1", - "lodash._isiterateecall": "3.0.9", - "lodash.restparam": "3.6.1" - } - }, - "lodash._getnative": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", - "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", - "dev": true - }, - "lodash._isiterateecall": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", - "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", - "dev": true - }, "lodash._topath": { "version": "3.8.1", "resolved": "https://registry.npmjs.org/lodash._topath/-/lodash._topath-3.8.1.tgz", @@ -6141,15 +8747,10 @@ } }, "lodash.assign": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-3.2.0.tgz", - "integrity": "sha1-POnwI0tLIiPilrj6CsH+6OvKZPo=", - "dev": true, - "requires": { - "lodash._baseassign": "3.2.0", - "lodash._createassigner": "3.1.1", - "lodash.keys": "3.1.2" - } + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz", + "integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=", + "dev": true }, "lodash.camelcase": { "version": "4.3.0", @@ -6173,29 +8774,12 @@ "lodash._topath": "3.8.1" } }, - "lodash.isarguments": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", - "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", - "dev": true - }, "lodash.isarray": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", "dev": true }, - "lodash.keys": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", - "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", - "dev": true, - "requires": { - "lodash._getnative": "3.9.1", - "lodash.isarguments": "3.1.0", - "lodash.isarray": "3.0.4" - } - }, "lodash.map": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.map/-/lodash.map-4.6.0.tgz", @@ -6208,28 +8792,10 @@ "integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=", "dev": true }, - "lodash.pad": { - "version": "4.5.1", - "resolved": "https://registry.npmjs.org/lodash.pad/-/lodash.pad-4.5.1.tgz", - "integrity": "sha1-QzCUmoM6fI2iLMIPaibE1Z3runA=", - "dev": true - }, - "lodash.padend": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/lodash.padend/-/lodash.padend-4.6.1.tgz", - "integrity": "sha1-U8y6BH0G4VjTEfRdpiX05J5vFm4=", - "dev": true - }, - "lodash.padstart": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/lodash.padstart/-/lodash.padstart-4.6.1.tgz", - "integrity": "sha1-0uPuv/DZ05rVD1y9G1KnvOa7YRs=", - "dev": true - }, - "lodash.restparam": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", - "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=", + "lodash.toarray": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.toarray/-/lodash.toarray-4.4.0.tgz", + "integrity": "sha1-JMS/zWsvuji/0FlNsRedjptlZWE=", "dev": true }, "lodash.uniq": { @@ -6274,6 +8840,12 @@ } } }, + "loglevel": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.6.0.tgz", + "integrity": "sha1-rgyqVhERSYxboTcj1vtjHSQAOTQ=", + "dev": true + }, "longest": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", @@ -6305,6 +8877,12 @@ "integrity": "sha1-miyr0bno4K6ZOkv31YdcOcQujqw=", "dev": true }, + "lowercase-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz", + "integrity": "sha1-TjNms55/VFfjXxMkvfb4jQv8cwY=", + "dev": true + }, "lru-cache": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.2.4.tgz", @@ -6318,32 +8896,62 @@ "dev": true }, "make-dir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.0.0.tgz", - "integrity": "sha1-l6ARdR6R3YfPre9Ygy67BJNt6Xg=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.1.0.tgz", + "integrity": "sha512-0Pkui4wLJ7rxvmfUvs87skoEaxmu0hCUApF8nonzpl7q//FWp9zu8W61Scz4sd/kUiqDxvUhtoam2efDyiBzcA==", "dev": true, "requires": { - "pify": "2.3.0" + "pify": "3.0.0" + }, + "dependencies": { + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + } } }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "dev": true + }, "map-obj": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", "dev": true }, - "map-stream": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", - "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", - "dev": true + "map-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", + "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "dev": true, + "requires": { + "object-visit": "1.0.1" + } }, "marked": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.3.tgz", - "integrity": "sha1-CLrZysE3NvbM7dwgI0TxsL8lU5A=", + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.9.tgz", + "integrity": "sha512-nW5u0dxpXxHfkHzzrveY45gCbi+R4PaO4WRZYqZNl+vB0hVGeqlFn0aOg1c8AKL63TrNFn9Bm2UP4AdiZ9TPLw==", "dev": true }, + "marked-terminal": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/marked-terminal/-/marked-terminal-2.0.0.tgz", + "integrity": "sha1-Xq9Wi+ZvaGVBr6UqVYKAMQox3i0=", + "dev": true, + "requires": { + "cardinal": "1.0.0", + "chalk": "1.1.3", + "cli-table": "0.3.1", + "lodash.assign": "4.2.0", + "node-emoji": "1.8.1" + } + }, "math-expression-evaluator": { "version": "1.2.17", "resolved": "https://registry.npmjs.org/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz", @@ -6393,7 +9001,7 @@ "integrity": "sha1-OpoguEYlI+RHz7x+i7gO1me/xVI=", "dev": true, "requires": { - "errno": "0.1.4", + "errno": "0.1.6", "readable-stream": "2.0.6" } }, @@ -6482,9 +9090,9 @@ } }, "mime": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", - "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", "dev": true }, "mime-db": { @@ -6508,6 +9116,12 @@ "integrity": "sha1-5md4PZLonb00KBi1IwudYqZyrRg=", "dev": true }, + "mimic-response": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.0.tgz", + "integrity": "sha1-3z02Uqc/3ta5sLJBRub9BSNTRY4=", + "dev": true + }, "min-document": { "version": "2.19.0", "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", @@ -6555,7 +9169,7 @@ "flush-write-stream": "1.0.2", "from2": "2.3.0", "parallel-transform": "1.1.0", - "pump": "1.0.2", + "pump": "1.0.3", "pumpify": "1.3.5", "stream-each": "1.2.2", "through2": "2.0.3" @@ -6567,6 +9181,27 @@ "integrity": "sha1-OA5hSA1qYVtmDwertg1R4KTkvtY=", "dev": true }, + "mixin-deep": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.0.tgz", + "integrity": "sha512-dgaCvoh6i1nosAUBKb0l0pfJ78K8+S9fluyIR2YvAeUD/QuMahnFnF3xYty5eYXMjhGSsB0DsW6A0uAZyetoAg==", + "dev": true, + "requires": { + "for-in": "1.0.2", + "is-extendable": "1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "2.0.4" + } + } + } + }, "mkdirp": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", @@ -6584,6 +9219,12 @@ } } }, + "modify-values": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/modify-values/-/modify-values-1.0.0.tgz", + "integrity": "sha1-4rbN65zhn5kxelNyLz2/XfXqqrI=", + "dev": true + }, "move-concurrently": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", @@ -6604,12 +9245,73 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, + "multicast-dns": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/multicast-dns/-/multicast-dns-6.2.1.tgz", + "integrity": "sha512-uV3/ckdsffHx9IrGQrx613mturMdMqQ06WTq+C09NsStJ9iNG6RcUWgPKs1Rfjy+idZT6tfQoXEusGNnEZhT3w==", + "dev": true, + "requires": { + "dns-packet": "1.2.2", + "thunky": "0.1.0" + } + }, + "multicast-dns-service-types": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/multicast-dns-service-types/-/multicast-dns-service-types-1.1.0.tgz", + "integrity": "sha1-iZ8R2WhuXgXLkbNdXw5jt3PPyQE=", + "dev": true + }, "mute-stream": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.6.tgz", "integrity": "sha1-SJYrGeFp/R38JAs/HnMXYnu8R9s=", "dev": true }, + "nan": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.8.0.tgz", + "integrity": "sha1-7XFfP+neArV6XmJS2QqWZ14fCFo=", + "dev": true + }, + "nanomatch": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.6.tgz", + "integrity": "sha512-WJ6XTCbvWXUFPbi/bDwKcYkCeOGUHzaJj72KbuPqGn78Ba/F5Vu26Zlo6SuMQbCIst1RGKL1zfWBCOGAlbRLAg==", + "dev": true, + "requires": { + "arr-diff": "4.0.0", + "array-unique": "0.3.2", + "define-property": "1.0.0", + "extend-shallow": "2.0.1", + "fragment-cache": "0.2.1", + "is-odd": "1.0.0", + "kind-of": "5.1.0", + "object.pick": "1.3.0", + "regex-not": "1.0.0", + "snapdragon": "0.8.1", + "to-regex": "3.0.1" + }, + "dependencies": { + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -6637,12 +9339,6 @@ "integrity": "sha1-5tq3/r9a2Bbqgc9cYpxaDr3nLBo=", "dev": true }, - "netrc": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/netrc/-/netrc-0.1.4.tgz", - "integrity": "sha1-a+lPysqNd63gqWcNxGCRTJRHJEQ=", - "dev": true - }, "no-case": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz", @@ -6652,30 +9348,55 @@ "lower-case": "1.1.4" } }, + "node-emoji": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.8.1.tgz", + "integrity": "sha512-+ktMAh1Jwas+TnGodfCfjUbJKoANqPaJFN0z0iqh41eqD8dvguNzcitVSBSVK1pidz0AqGbLKcoVuVLRVZ/aVg==", + "dev": true, + "requires": { + "lodash.toarray": "4.4.0" + } + }, + "node-fetch": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", + "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", + "dev": true, + "requires": { + "encoding": "0.1.12", + "is-stream": "1.1.0" + } + }, + "node-forge": { + "version": "0.6.33", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.6.33.tgz", + "integrity": "sha1-RjgRh59XPUUVWtap9D3ClujoXrw=", + "dev": true + }, "node-libs-browser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.0.0.tgz", - "integrity": "sha1-o6WeyXAkmFtG6Vg3lkb5bEthZkY=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.1.0.tgz", + "integrity": "sha512-5AzFzdoIMb89hBGMZglEegffzgRg+ZFoUmisQ8HI4j1KDdpx13J0taNp2y9xPbur6W61gepGDDotGBVQ7mfUCg==", "dev": true, "requires": { "assert": "1.4.1", - "browserify-zlib": "0.1.4", + "browserify-zlib": "0.2.0", "buffer": "4.9.1", "console-browserify": "1.1.0", "constants-browserify": "1.0.0", - "crypto-browserify": "3.11.1", + "crypto-browserify": "3.12.0", "domain-browser": "1.1.7", "events": "1.1.1", - "https-browserify": "0.0.1", - "os-browserify": "0.2.1", + "https-browserify": "1.0.0", + "os-browserify": "0.3.0", "path-browserify": "0.0.0", "process": "0.11.10", "punycode": "1.4.1", "querystring-es3": "0.2.1", - "readable-stream": "2.0.6", + "readable-stream": "2.3.3", "stream-browserify": "2.0.1", "stream-http": "2.7.2", - "string_decoder": "0.10.31", + "string_decoder": "1.0.3", "timers-browserify": "2.0.4", "tty-browserify": "0.0.0", "url": "0.11.0", @@ -6683,6 +9404,51 @@ "vm-browserify": "0.0.4" }, "dependencies": { + "browserify-zlib": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", + "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", + "dev": true, + "requires": { + "pako": "1.0.6" + } + }, + "https-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", + "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", + "dev": true + }, + "os-browserify": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", + "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", + "dev": true + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "timers-browserify": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.4.tgz", @@ -6743,37 +9509,58 @@ } }, "normalize.css": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/normalize.css/-/normalize.css-5.0.0.tgz", - "integrity": "sha1-fOyHXOgXilMzxN6Ato6pwYudfDc=", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/normalize.css/-/normalize.css-7.0.0.tgz", + "integrity": "sha1-q/sd2CRwZ04DIrU86xqvQSk45L8=", "dev": true }, + "npm-conf": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/npm-conf/-/npm-conf-1.1.3.tgz", + "integrity": "sha512-Yic4bZHJOt9RCFbRP3GgpqhScOY4HH3V2P8yBj6CeYq118Qr+BLXqT2JvpJ00mryLESpgOxf5XlFv4ZjXxLScw==", + "dev": true, + "requires": { + "config-chain": "1.1.11", + "pify": "3.0.0" + }, + "dependencies": { + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + } + } + }, "npm-package-arg": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-4.2.1.tgz", - "integrity": "sha1-WTMD/eqF98Qid18X+et2cPaA4+w=", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-5.1.2.tgz", + "integrity": "sha512-wJBsrf0qpypPT7A0LART18hCdyhpCMxeTtcb0X4IZO2jsP6Om7EHN1d9KSKiqD+KVH030RVNpWS9thk+pb7wzA==", "dev": true, "requires": { "hosted-git-info": "2.5.0", - "semver": "5.4.1" + "osenv": "0.1.4", + "semver": "5.4.1", + "validate-npm-package-name": "3.0.0" } }, "npm-registry-client": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-7.5.0.tgz", - "integrity": "sha1-D23W5dEUJM+pn85bkw/q8JtPfwQ=", + "version": "8.5.0", + "resolved": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-8.5.0.tgz", + "integrity": "sha512-Nkcw24bfECKFNt0FLDQ+PjVqSlKxMggcboXiUBIvjbCnA15xjRO4kCwRDluGNXZjHFLx/vPjN4+ESXyVjpXLbQ==", "dev": true, "requires": { "concat-stream": "1.6.0", "graceful-fs": "4.1.11", "normalize-package-data": "2.4.0", - "npm-package-arg": "4.2.1", + "npm-package-arg": "5.1.2", "npmlog": "4.1.2", "once": "1.4.0", "request": "2.83.0", "retry": "0.10.1", "semver": "5.4.1", - "slide": "1.1.6" + "slide": "1.1.6", + "ssri": "4.1.6" } }, "npm-run-path": { @@ -6785,45 +9572,12 @@ "path-key": "2.0.1" } }, - "npmconf": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/npmconf/-/npmconf-2.1.2.tgz", - "integrity": "sha1-ZmBqSnNvHnegWaoHGnnJSreBhTo=", - "dev": true, - "requires": { - "config-chain": "1.1.11", - "inherits": "2.0.3", - "ini": "1.3.4", - "mkdirp": "0.5.1", - "nopt": "3.0.6", - "once": "1.3.3", - "osenv": "0.1.4", - "semver": "4.3.6", - "uid-number": "0.0.5" - }, - "dependencies": { - "once": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", - "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", - "dev": true, - "requires": { - "wrappy": "1.0.2" - } - }, - "semver": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", - "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=", - "dev": true - } - } - }, "npmlog": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", "dev": true, + "optional": true, "requires": { "are-we-there-yet": "1.1.4", "console-control-strings": "1.1.0", @@ -6867,7 +9621,8 @@ "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true }, "object-component": { "version": "0.0.3", @@ -6875,6 +9630,65 @@ "integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=", "dev": true }, + "object-copy": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", + "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "dev": true, + "requires": { + "copy-descriptor": "0.1.1", + "define-property": "0.2.5", + "kind-of": "3.2.2" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "0.1.6", + "is-data-descriptor": "0.1.4", + "kind-of": "5.1.0" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + } + } + }, "object-hash": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-1.2.0.tgz", @@ -6893,6 +9707,23 @@ "integrity": "sha1-xUYBd4rVYPEULODgG8yotW0TQm0=", "dev": true }, + "object-visit": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", + "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "dev": true, + "requires": { + "isobject": "3.0.1" + }, + "dependencies": { + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, "object.omit": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", @@ -6903,6 +9734,23 @@ "is-extendable": "0.1.1" } }, + "object.pick": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "dev": true, + "requires": { + "isobject": "3.0.1" + }, + "dependencies": { + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, "obuf": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/obuf/-/obuf-1.1.1.tgz", @@ -6945,13 +9793,12 @@ "dev": true }, "opn": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/opn/-/opn-4.0.2.tgz", - "integrity": "sha1-erwi5kTf9jsKltWrfyeQwPAavJU=", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/opn/-/opn-5.1.0.tgz", + "integrity": "sha512-iPNl7SyM8L30Rm1sjGdLLheyHVw5YXVfi3SKWJzBI7efxRwHojfRFjwE/OLM6qp9xJYMgab8WicTU1cPoY+Hpg==", "dev": true, "requires": { - "object-assign": "4.1.1", - "pinkie-promise": "2.0.1" + "is-wsl": "1.1.0" } }, "optimist": { @@ -7026,12 +9873,31 @@ "dev": true }, "os-locale": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", - "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", + "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", "dev": true, "requires": { - "lcid": "1.0.0" + "execa": "0.7.0", + "lcid": "1.0.0", + "mem": "1.1.0" + }, + "dependencies": { + "execa": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", + "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", + "dev": true, + "requires": { + "cross-spawn": "5.1.0", + "get-stream": "3.0.0", + "is-stream": "1.1.0", + "npm-run-path": "2.0.2", + "p-finally": "1.0.0", + "signal-exit": "3.0.2", + "strip-eof": "1.0.0" + } + } } }, "os-shim": { @@ -7056,25 +9922,118 @@ "os-tmpdir": "1.0.2" } }, + "p-cancelable": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.3.0.tgz", + "integrity": "sha512-RVbZPLso8+jFeq1MfNvgXtCRED2raz/dKpacfTNxsx6pLEpEomM7gah6VeHSYV3+vo0OAi4MkArtQcWWXuQoyw==", + "dev": true + }, "p-finally": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", "dev": true }, - "p-limit": { + "p-is-promise": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.1.0.tgz", - "integrity": "sha1-sH/y2aXYi+yAYDWJWiurZqJ5iLw=", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", + "integrity": "sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4=", "dev": true }, + "p-limit": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.2.0.tgz", + "integrity": "sha512-Y/OtIaXtUPr4/YpMv1pCL5L5ed0rumAaAeBSj12F+bSlMdys7i8oQF/GUJmfpTS/QoaRrS/k6pma29haJpsMng==", + "dev": true, + "requires": { + "p-try": "1.0.0" + } + }, "p-locate": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", "dev": true, "requires": { - "p-limit": "1.1.0" + "p-limit": "1.2.0" + } + }, + "p-map": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-1.2.0.tgz", + "integrity": "sha512-r6zKACMNhjPJMTl8KcFH4li//gkrXWfbD6feV8l6doRHlzljFWGJ2AP6iKaCJXyZmAUMOPtvbW7EXkbWO/pLEA==", + "dev": true + }, + "p-reduce": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-reduce/-/p-reduce-1.0.0.tgz", + "integrity": "sha1-GMKw3ZNqRpClKfgjH1ig/bakffo=", + "dev": true + }, + "p-retry": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-1.0.0.tgz", + "integrity": "sha1-OSczKkt9cCabU1UVEX/FR9oaaWg=", + "dev": true, + "requires": { + "retry": "0.10.1" + } + }, + "p-timeout": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-2.0.1.tgz", + "integrity": "sha512-88em58dDVB/KzPEx1X0N3LwFfYZPyDc4B6eF38M1rk9VTZMbxXXgjugz8mmwpS9Ox4BDZ+t6t3QP5+/gazweIA==", + "dev": true, + "requires": { + "p-finally": "1.0.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true + }, + "package-json": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/package-json/-/package-json-4.0.1.tgz", + "integrity": "sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0=", + "dev": true, + "requires": { + "got": "6.7.1", + "registry-auth-token": "3.3.1", + "registry-url": "3.1.0", + "semver": "5.4.1" + }, + "dependencies": { + "got": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/got/-/got-6.7.1.tgz", + "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", + "dev": true, + "requires": { + "create-error-class": "3.0.2", + "duplexer3": "0.1.4", + "get-stream": "3.0.0", + "is-redirect": "1.0.0", + "is-retry-allowed": "1.1.0", + "is-stream": "1.1.0", + "lowercase-keys": "1.0.0", + "safe-buffer": "5.1.1", + "timed-out": "4.0.1", + "unzip-response": "2.0.1", + "url-parse-lax": "1.0.0" + } + }, + "url-parse-lax": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", + "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", + "dev": true, + "requires": { + "prepend-http": "1.0.4" + } + } } }, "pad": { @@ -7149,17 +10108,17 @@ "integrity": "sha1-N8T5t+06tlx0gXtfJICTf7+XxxI=", "dev": true, "requires": { - "asn1.js": "4.9.1", - "browserify-aes": "1.1.0", + "asn1.js": "4.9.2", + "browserify-aes": "1.1.1", "create-hash": "1.1.3", "evp_bytestokey": "1.0.3", "pbkdf2": "3.0.14" } }, - "parse-github-repo-url": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/parse-github-repo-url/-/parse-github-repo-url-1.4.1.tgz", - "integrity": "sha1-nn2LslKmy2ukJZUGC3v23z28H1A=", + "parse-github-url": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/parse-github-url/-/parse-github-url-1.0.2.tgz", + "integrity": "sha512-kgBf6avCbO3Cn6+RnzRGLkUsv4ZVqv/VfAYkRsyBcgkshNvVBkRn1FEZcW0Jb+npXQWm2vHPnnOqFteZxRRGNw==", "dev": true }, "parse-glob": { @@ -7195,13 +10154,23 @@ "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", "dev": true }, + "parse-url": { + "version": "1.3.11", + "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-1.3.11.tgz", + "integrity": "sha1-V8FUKKuKiSsfQ4aWRccR0OFEtVQ=", + "dev": true, + "requires": { + "is-ssh": "1.3.0", + "protocols": "1.4.6" + } + }, "parse5": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.2.tgz", - "integrity": "sha1-Be/1fw70V3+xRKefi5qWemzERRA=", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.3.tgz", + "integrity": "sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==", "dev": true, "requires": { - "@types/node": "6.0.89" + "@types/node": "8.5.5" } }, "parsejson": { @@ -7237,6 +10206,12 @@ "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=", "dev": true }, + "pascalcase": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "dev": true + }, "path-browserify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", @@ -7266,16 +10241,6 @@ "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", "dev": true }, - "path-object": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/path-object/-/path-object-2.3.0.tgz", - "integrity": "sha1-A+RmU+XDdcYK8cq92UvGRIpdkRA=", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "lodash.assign": "3.2.0" - } - }, "path-parse": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", @@ -7298,15 +10263,6 @@ "pinkie-promise": "2.0.1" } }, - "pause-stream": { - "version": "0.0.11", - "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", - "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", - "dev": true, - "requires": { - "through": "2.3.8" - } - }, "pbkdf2": { "version": "3.0.14", "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.14.tgz", @@ -7329,49 +10285,31 @@ "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true }, "pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true }, "pinkie-promise": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, "requires": { "pinkie": "2.0.4" } }, "pkg-dir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-1.0.0.tgz", - "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", + "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", "dev": true, "requires": { - "find-up": "1.1.2" - }, - "dependencies": { - "find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "dev": true, - "requires": { - "path-exists": "2.1.0", - "pinkie-promise": "2.0.1" - } - }, - "path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "requires": { - "pinkie-promise": "2.0.1" - } - } + "find-up": "2.1.0" } }, "plur": { @@ -7381,9 +10319,9 @@ "dev": true }, "pluralize": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-1.2.1.tgz", - "integrity": "sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU=", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", + "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", "dev": true }, "portfinder": { @@ -7395,25 +10333,23 @@ "async": "1.5.2", "debug": "2.6.9", "mkdirp": "0.5.1" - }, - "dependencies": { - "async": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", - "dev": true - } } }, + "posix-character-classes": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "dev": true + }, "postcss": { - "version": "6.0.13", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-6.0.13.tgz", - "integrity": "sha512-nHsrD1PPTMSJDfU+osVsLtPkSP9YGeoOz4FDLN4r1DW4N5vqL1J+gACzTQHsfwIiWG/0/nV4yCzjTMo1zD8U1g==", + "version": "6.0.15", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-6.0.15.tgz", + "integrity": "sha512-v/SpyMzLbtkmh45zUdaqLAaqXqzPdSrw8p4cQVO0/w6YiYfpj4k+Wkzhn68qk9br+H+0qfddhdPEVnbmBPfXVQ==", "dev": true, "requires": { - "chalk": "2.1.0", + "chalk": "2.3.0", "source-map": "0.6.1", - "supports-color": "4.4.0" + "supports-color": "5.1.0" }, "dependencies": { "ansi-styles": { @@ -7422,18 +10358,29 @@ "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", "dev": true, "requires": { - "color-convert": "1.9.0" + "color-convert": "1.9.1" } }, "chalk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", - "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", "dev": true, "requires": { "ansi-styles": "3.2.0", "escape-string-regexp": "1.0.5", - "supports-color": "4.4.0" + "supports-color": "4.5.0" + }, + "dependencies": { + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } } }, "has-flag": { @@ -7449,9 +10396,9 @@ "dev": true }, "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.1.0.tgz", + "integrity": "sha512-Ry0AwkoKjDpVKK4sV4h6o3UJmNRbjYm2uXhwfj3J56lMVdvnUNqzQVRztOOMGQ++w1K/TjNDFvpJk0F/LoeBCQ==", "dev": true, "requires": { "has-flag": "2.0.0" @@ -7477,7 +10424,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -7511,7 +10458,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -7544,7 +10491,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -7576,7 +10523,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -7608,7 +10555,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -7640,7 +10587,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -7672,7 +10619,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -7705,7 +10652,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -7738,7 +10685,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -7787,13 +10734,13 @@ } }, "postcss-loader": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-2.0.5.tgz", - "integrity": "sha1-wZ0+i4PrGsMW9WIe9MDvWz0bizo=", + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-2.0.10.tgz", + "integrity": "sha512-xQaDcEgJ/2JqFY18zpFkik8vyYs7oS5ZRbrjvDqkP97k2wYWfPT4+qA0m4o3pTSCsz0u26PNqs8ZO9FRUWAqrA==", "dev": true, "requires": { "loader-utils": "1.1.0", - "postcss": "6.0.13", + "postcss": "6.0.15", "postcss-load-config": "1.2.0", "schema-utils": "0.3.0" }, @@ -7829,7 +10776,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -7861,7 +10808,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -7896,8 +10843,8 @@ "integrity": "sha1-C9dnBCWL6CmyOYu1Dkti0aFmsLk=", "dev": true, "requires": { - "caniuse-db": "1.0.30000746", - "electron-to-chromium": "1.3.26" + "caniuse-db": "1.0.30000787", + "electron-to-chromium": "1.3.30" } }, "postcss": { @@ -7907,7 +10854,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -7947,7 +10894,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -7980,7 +10927,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -8015,7 +10962,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -8050,7 +10997,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -8072,7 +11019,7 @@ "integrity": "sha1-thTJcgvmgW6u41+zpfqh26agXds=", "dev": true, "requires": { - "postcss": "6.0.13" + "postcss": "6.0.15" } }, "postcss-modules-local-by-default": { @@ -8082,7 +11029,7 @@ "dev": true, "requires": { "css-selector-tokenizer": "0.7.0", - "postcss": "6.0.13" + "postcss": "6.0.15" } }, "postcss-modules-scope": { @@ -8092,7 +11039,7 @@ "dev": true, "requires": { "css-selector-tokenizer": "0.7.0", - "postcss": "6.0.13" + "postcss": "6.0.15" } }, "postcss-modules-values": { @@ -8102,7 +11049,7 @@ "dev": true, "requires": { "icss-replace-symbols": "1.1.0", - "postcss": "6.0.13" + "postcss": "6.0.15" } }, "postcss-normalize-charset": { @@ -8121,7 +11068,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -8156,7 +11103,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -8189,7 +11136,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -8221,7 +11168,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -8254,7 +11201,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -8286,7 +11233,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -8320,7 +11267,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -8366,7 +11313,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -8400,7 +11347,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -8440,7 +11387,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -8502,9 +11449,9 @@ } }, "posthtml-rename-id": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/posthtml-rename-id/-/posthtml-rename-id-1.0.2.tgz", - "integrity": "sha1-VAk6onYeKTkhaLsFcj4SZoYyslA=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/posthtml-rename-id/-/posthtml-rename-id-1.0.3.tgz", + "integrity": "sha512-zaaHJSTihw1fsx2L81npO6gmDYu4yZuHfRX89IsJDhcRIV1P8SKJY5m1xDRZQh542flidwNS+70/pVAK8yMYOA==", "dev": true, "requires": { "escape-string-regexp": "1.0.5" @@ -8517,9 +11464,9 @@ "dev": true }, "posthtml-svg-mode": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/posthtml-svg-mode/-/posthtml-svg-mode-1.0.0.tgz", - "integrity": "sha1-zdwE4cQYU9WYbAGfURs6qpRxDJU=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/posthtml-svg-mode/-/posthtml-svg-mode-1.0.2.tgz", + "integrity": "sha512-yH4w0CULTg6v3YW5hVUY2z14R+11XWvtxMRqk30FDgxg0JWv+BhS9FLtKNIu858/1mrO1NcIC4heb6IezLAfHw==", "dev": true, "requires": { "merge-options": "0.0.64", @@ -8547,9 +11494,9 @@ "dev": true }, "prettier": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.7.4.tgz", - "integrity": "sha1-XoYkrpNjyA+V7GRFhOzfVddPk/o=", + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.9.2.tgz", + "integrity": "sha512-piXx9N2WT8hWb7PBbX1glAuJVIkEyUV9F5fMXFINpZ0x3otVOFKKeGmeuiclFJlP/UrgTckyV606VjH2rNK4bw==", "dev": true }, "pretty-error": { @@ -8591,23 +11538,49 @@ "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" }, "progress": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", - "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz", + "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=", "dev": true }, + "promise": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", + "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", + "dev": true, + "requires": { + "asap": "2.0.6" + } + }, "promise-inflight": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=", "dev": true }, + "prop-types": { + "version": "15.6.0", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.6.0.tgz", + "integrity": "sha1-zq8IMCL8RrSjX2nhPvda7Q1jmFY=", + "dev": true, + "requires": { + "fbjs": "0.8.16", + "loose-envify": "1.3.1", + "object-assign": "4.1.1" + } + }, "proto-list": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz", "integrity": "sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk=", "dev": true }, + "protocols": { + "version": "1.4.6", + "resolved": "https://registry.npmjs.org/protocols/-/protocols-1.4.6.tgz", + "integrity": "sha1-+LsmPqG1/Xp2BNJri+Ob13Z4v4o=", + "dev": true + }, "proxy-addr": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.2.tgz", @@ -8618,10 +11591,16 @@ "ipaddr.js": "1.5.2" } }, + "proxy-from-env": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", + "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=", + "dev": true + }, "prr": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/prr/-/prr-0.0.0.tgz", - "integrity": "sha1-GoS4WQgyVQFBGFPQCB7j+obikmo=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", + "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", "dev": true }, "pseudomap": { @@ -8644,9 +11623,9 @@ } }, "pump": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.2.tgz", - "integrity": "sha1-Oz7mUS+U8OV1U4wXmV+fFpkKXVE=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", + "integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==", "dev": true, "requires": { "end-of-stream": "1.4.0", @@ -8661,7 +11640,7 @@ "requires": { "duplexify": "3.5.1", "inherits": "2.0.3", - "pump": "1.0.2" + "pump": "1.0.3" } }, "punycode": { @@ -8671,9 +11650,9 @@ "dev": true }, "q": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.0.tgz", - "integrity": "sha1-3QG6ydBtMObyGa7LglPunr3DCPE=", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", "dev": true }, "qjobs": { @@ -8741,7 +11720,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.5" + "is-buffer": "1.1.6" } } } @@ -8752,7 +11731,7 @@ "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, "requires": { - "is-buffer": "1.1.5" + "is-buffer": "1.1.6" } } } @@ -8766,6 +11745,16 @@ "safe-buffer": "5.1.1" } }, + "randomfill": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.3.tgz", + "integrity": "sha512-YL6GrhrWoic0Eq8rXVbMptH7dAxCs0J+mh5Y0euNekPPYaxEmdVGim6GdoxoRzKW2yJoU8tueifS7mYxvcFDEQ==", + "dev": true, + "requires": { + "randombytes": "2.0.5", + "safe-buffer": "5.1.1" + } + }, "range-parser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", @@ -8790,6 +11779,26 @@ "integrity": "sha1-DD0L6u2KAclm2Xh793goElKpeao=", "dev": true }, + "rc": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.2.tgz", + "integrity": "sha1-2M6ctX6NZNnHut2YdsfDTL48cHc=", + "dev": true, + "requires": { + "deep-extend": "0.4.2", + "ini": "1.3.5", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + } + } + }, "re-emitter": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/re-emitter/-/re-emitter-1.1.3.tgz", @@ -8863,25 +11872,6 @@ "set-immediate-shim": "1.0.1" } }, - "readline2": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz", - "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=", - "dev": true, - "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "mute-stream": "0.0.5" - }, - "dependencies": { - "mute-stream": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", - "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=", - "dev": true - } - } - }, "recast": { "version": "0.11.23", "resolved": "https://registry.npmjs.org/recast/-/recast-0.11.23.tgz", @@ -8907,7 +11897,7 @@ "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", "requires": { - "resolve": "1.4.0" + "resolve": "1.5.0" } }, "redent": { @@ -8920,6 +11910,23 @@ "strip-indent": "1.0.1" } }, + "redeyed": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/redeyed/-/redeyed-1.0.1.tgz", + "integrity": "sha1-6WwZO0DAgWsArshCaY5hGF5VSYo=", + "dev": true, + "requires": { + "esprima": "3.0.0" + }, + "dependencies": { + "esprima": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.0.0.tgz", + "integrity": "sha1-U88kes2ncxPlUcOqLnM0LT+099k=", + "dev": true + } + } + }, "reduce-css-calc": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/reduce-css-calc/-/reduce-css-calc-1.3.0.tgz", @@ -8963,9 +11970,9 @@ "dev": true }, "regenerator-runtime": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.0.tgz", - "integrity": "sha512-/aA0kLeRb5N9K0d4fw7ooEbI+xDe+DKD499EQqygGqeS8N3xto15p09uY2xj7ixP81sNPXvRLnAQIqdVStgb1A==", + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", "dev": true }, "regenerator-transform": { @@ -8988,10 +11995,19 @@ "is-equal-shallow": "0.1.3" } }, - "regexp-replace-loader": { + "regex-not": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/regexp-replace-loader/-/regexp-replace-loader-1.0.0.tgz", - "integrity": "sha1-swpnOBGIjcrZ+at9zQ/R1s0kzik=", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.0.tgz", + "integrity": "sha1-Qvg+OXcWIt+CawKvF2Ul1qXxV/k=", + "dev": true, + "requires": { + "extend-shallow": "2.0.1" + } + }, + "regexp-replace-loader": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/regexp-replace-loader/-/regexp-replace-loader-1.0.1.tgz", + "integrity": "sha1-Xa5zvp7oKk2U0JVcL6P8kj4TTX4=", "dev": true, "requires": { "loader-utils": "1.1.0" @@ -9021,6 +12037,25 @@ "regjsparser": "0.1.5" } }, + "registry-auth-token": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.3.1.tgz", + "integrity": "sha1-+w0yie4Nmtosu1KvXf5mywcNMAY=", + "dev": true, + "requires": { + "rc": "1.2.2", + "safe-buffer": "5.1.1" + } + }, + "registry-url": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-3.1.0.tgz", + "integrity": "sha1-PU74cPc93h138M+aOBQyRE4XSUI=", + "dev": true, + "requires": { + "rc": "1.2.2" + } + }, "regjsgen": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", @@ -9128,27 +12163,6 @@ "uuid": "3.1.0" } }, - "request-promise": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/request-promise/-/request-promise-4.2.2.tgz", - "integrity": "sha1-0epG1lSm7k+O5qT+oQGMIpEZBLQ=", - "dev": true, - "requires": { - "bluebird": "3.5.1", - "request-promise-core": "1.1.1", - "stealthy-require": "1.1.1", - "tough-cookie": "2.3.3" - } - }, - "request-promise-core": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.1.tgz", - "integrity": "sha1-Pu4AssWqgyOc+wTFcA2jb4HNCLY=", - "dev": true, - "requires": { - "lodash": "4.17.4" - } - }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -9167,12 +12181,6 @@ "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", "dev": true }, - "require-relative": { - "version": "0.8.7", - "resolved": "https://registry.npmjs.org/require-relative/-/require-relative-0.8.7.tgz", - "integrity": "sha1-eZlTn8ngR6N5KPoZb44VY9q9Nt4=", - "dev": true - }, "require-uncached": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", @@ -9196,13 +12204,30 @@ "dev": true }, "resolve": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", - "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "requires": { "path-parse": "1.0.5" } }, + "resolve-cwd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-2.0.0.tgz", + "integrity": "sha1-AKn3OHVW4nA46uIyyqNypqWbZlo=", + "dev": true, + "requires": { + "resolve-from": "3.0.0" + }, + "dependencies": { + "resolve-from": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", + "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", + "dev": true + } + } + }, "resolve-dir": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-0.1.1.tgz", @@ -9219,6 +12244,21 @@ "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", "dev": true }, + "resolve-url": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", + "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "dev": true + }, + "responselike": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-1.0.2.tgz", + "integrity": "sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec=", + "dev": true, + "requires": { + "lowercase-keys": "1.0.0" + } + }, "restore-cursor": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", @@ -9263,6 +12303,7 @@ "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "dev": true, "requires": { "glob": "7.1.2" } @@ -9286,15 +12327,6 @@ "is-promise": "2.1.0" } }, - "run-auto": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/run-auto/-/run-auto-2.0.0.tgz", - "integrity": "sha1-X0NT9Yrb1rdJJkibTyWeHa1qeNY=", - "dev": true, - "requires": { - "dezalgo": "1.0.3" - } - }, "run-queue": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz", @@ -9304,12 +12336,6 @@ "aproba": "1.2.0" } }, - "run-series": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/run-series/-/run-series-1.1.4.tgz", - "integrity": "sha1-iac93F51ye+KtjIMChYA1qQRebk=", - "dev": true - }, "rx": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/rx/-/rx-4.1.0.tgz", @@ -9317,11 +12343,20 @@ "dev": true }, "rx-lite": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", - "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", + "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", "dev": true }, + "rx-lite-aggregates": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", + "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", + "dev": true, + "requires": { + "rx-lite": "4.0.8" + } + }, "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", @@ -9340,21 +12375,7 @@ "integrity": "sha1-9YdyIs4+kx7a4DnxfrNxbnE3+M8=", "dev": true, "requires": { - "ajv": "5.2.3" - }, - "dependencies": { - "ajv": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.2.3.tgz", - "integrity": "sha1-wG9Zh3jETGsWGrr+NGa4GtGBTtI=", - "dev": true, - "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.0.0", - "json-schema-traverse": "0.3.1", - "json-stable-stringify": "1.0.1" - } - } + "ajv": "5.5.2" } }, "seedrandom": { @@ -9368,40 +12389,178 @@ "integrity": "sha1-Yl2GWPhlr0Psliv8N2o3NZpJlMo=", "dev": true }, + "selfsigned": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/selfsigned/-/selfsigned-1.10.1.tgz", + "integrity": "sha1-v4y3uDJWxFUeMTR8YxF3jbme7FI=", + "dev": true, + "requires": { + "node-forge": "0.6.33" + } + }, "semantic-release": { - "version": "6.3.6", - "resolved": "https://registry.npmjs.org/semantic-release/-/semantic-release-6.3.6.tgz", - "integrity": "sha1-Yp0K7JCziilXpXpKnuEhSvUZKMc=", - "dev": true, - "requires": { - "@semantic-release/commit-analyzer": "2.0.0", - "@semantic-release/condition-travis": "5.0.2", - "@semantic-release/error": "1.0.0", - "@semantic-release/last-release-npm": "1.2.1", - "@semantic-release/release-notes-generator": "2.0.0", - "git-head": "1.20.1", - "github": "8.2.1", + "version": "11.0.2", + "resolved": "https://registry.npmjs.org/semantic-release/-/semantic-release-11.0.2.tgz", + "integrity": "sha512-WL1drB52yPYUFIVlS2RvKu4FE3tuBM0LcKifn+RAkJ63N4ScYHbW09Vy6CWKVJ39B/Excatn3sRMnTd2jIyI3Q==", + "dev": true, + "requires": { + "@semantic-release/commit-analyzer": "5.0.0", + "@semantic-release/condition-travis": "7.1.4", + "@semantic-release/error": "2.1.0", + "@semantic-release/github": "2.2.3", + "@semantic-release/npm": "2.6.1", + "@semantic-release/release-notes-generator": "6.0.3", + "chalk": "2.3.0", + "commander": "2.11.0", + "cosmiconfig": "3.1.0", + "debug": "3.1.0", + "execa": "0.8.0", + "get-stream": "3.0.0", + "git-log-parser": "1.2.0", + "import-from": "2.1.0", "lodash": "4.17.4", - "nerf-dart": "1.0.0", - "nopt": "4.0.1", - "normalize-package-data": "2.4.0", - "npmconf": "2.1.2", - "npmlog": "4.1.2", - "parse-github-repo-url": "1.4.1", - "require-relative": "0.8.7", - "run-auto": "2.0.0", - "run-series": "1.1.4", + "marked": "0.3.9", + "marked-terminal": "2.0.0", + "p-reduce": "1.0.0", + "read-pkg-up": "3.0.0", "semver": "5.4.1" }, "dependencies": { - "nopt": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", - "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", "dev": true, "requires": { - "abbrev": "1.0.9", - "osenv": "0.1.4" + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "cosmiconfig": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-3.1.0.tgz", + "integrity": "sha512-zedsBhLSbPBms+kE7AH4vHg6JsKDz6epSv2/+5XHs8ILHlgDciSJfSWf8sX9aQ52Jb7KI7VswUTsLpR/G0cr2Q==", + "dev": true, + "requires": { + "is-directory": "0.3.1", + "js-yaml": "3.10.0", + "parse-json": "3.0.0", + "require-from-string": "2.0.1" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "load-json-file": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", + "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "parse-json": "4.0.0", + "pify": "3.0.0", + "strip-bom": "3.0.0" + }, + "dependencies": { + "parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "dev": true, + "requires": { + "error-ex": "1.3.1", + "json-parse-better-errors": "1.0.1" + } + } + } + }, + "parse-json": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-3.0.0.tgz", + "integrity": "sha1-+m9HsY4jgm6tMvJj50TQ4ehH+xM=", + "dev": true, + "requires": { + "error-ex": "1.3.1" + } + }, + "path-type": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", + "dev": true, + "requires": { + "pify": "3.0.0" + } + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + }, + "read-pkg": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", + "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", + "dev": true, + "requires": { + "load-json-file": "4.0.0", + "normalize-package-data": "2.4.0", + "path-type": "3.0.0" + } + }, + "read-pkg-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", + "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", + "dev": true, + "requires": { + "find-up": "2.1.0", + "read-pkg": "3.0.0" + } + }, + "require-from-string": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.1.tgz", + "integrity": "sha1-xUUjPp19pmFunVmt+zn8n1iGdv8=", + "dev": true + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" } } } @@ -9412,6 +12571,15 @@ "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==", "dev": true }, + "semver-diff": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/semver-diff/-/semver-diff-2.1.0.tgz", + "integrity": "sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY=", + "dev": true, + "requires": { + "semver": "5.4.1" + } + }, "send": { "version": "0.16.1", "resolved": "https://registry.npmjs.org/send/-/send-0.16.1.tgz", @@ -9431,8 +12599,28 @@ "on-finished": "2.3.0", "range-parser": "1.2.0", "statuses": "1.3.1" + }, + "dependencies": { + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==", + "dev": true + }, + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", + "dev": true + } } }, + "serialize-javascript": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.4.0.tgz", + "integrity": "sha1-fJWFFNtqwkQ6irwGLcn3iGp/YAU=", + "dev": true + }, "serve-index": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", @@ -9478,12 +12666,33 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true }, + "set-getter": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/set-getter/-/set-getter-0.1.0.tgz", + "integrity": "sha1-12nBgsnVpR9AkUXy+6guXoboA3Y=", + "dev": true, + "requires": { + "to-object-path": "0.3.0" + } + }, "set-immediate-shim": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", "dev": true }, + "set-value": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", + "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "dev": true, + "requires": { + "extend-shallow": "2.0.1", + "is-extendable": "0.1.1", + "is-plain-object": "2.0.4", + "split-string": "3.1.0" + } + }, "setimmediate": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", @@ -9507,10 +12716,26 @@ } }, "shader-loader": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/shader-loader/-/shader-loader-1.3.0.tgz", - "integrity": "sha1-dgmu+2U/XueFxgGAjLx0mfQPykM=", - "dev": true + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/shader-loader/-/shader-loader-1.3.1.tgz", + "integrity": "sha512-dt8F9K0x4rjmaFyHh7rNDfpt4LUiR64zhNIEwp2WbE99B3z4ALuvvmhftkElg93dUD6sTmv/aXa/z9SJiEddcA==", + "dev": true, + "requires": { + "loader-utils": "1.1.0" + }, + "dependencies": { + "loader-utils": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz", + "integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=", + "dev": true, + "requires": { + "big.js": "3.2.0", + "emojis-list": "2.1.0", + "json5": "0.5.1" + } + } + } }, "shebang-command": { "version": "1.2.0", @@ -9533,7 +12758,7 @@ "integrity": "sha1-3svPh0sNHl+3LhSxZKloMEjprLM=", "requires": { "glob": "7.1.2", - "interpret": "1.0.4", + "interpret": "1.1.0", "rechoir": "0.6.2" } }, @@ -9563,47 +12788,30 @@ "dev": true }, "size-limit": { - "version": "0.11.6", - "resolved": "https://registry.npmjs.org/size-limit/-/size-limit-0.11.6.tgz", - "integrity": "sha512-ussSQWgHF2QHXddoqsxIdVvJtLtRcCZQoMuAh9q8U+sXoWGUwz1QfvoDUp/psviGcXNcZM2bxvnbMuEobQlwDg==", + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/size-limit/-/size-limit-0.13.2.tgz", + "integrity": "sha512-AAacLFwKA0m1bt8FlB3uUNVxoy9HJ7CyYfVuDs5xFmdiVPb1cXud7bVSdmdj8IcVDf8pYIkFkPYHvrre0EvWhg==", "dev": true, "requires": { "bytes": "3.0.0", - "chalk": "2.1.0", + "chalk": "2.3.0", "ci-job-number": "0.3.0", - "compression-webpack-plugin": "1.0.1", + "compression-webpack-plugin": "1.1.3", + "cosmiconfig": "3.1.0", "css-loader": "0.28.7", "escape-string-regexp": "1.0.5", - "file-loader": "1.1.5", - "globby": "6.1.0", - "gzip-size": "4.0.0", + "file-loader": "1.1.6", + "globby": "7.1.1", + "gzip-size": "4.1.0", "memory-fs": "0.4.1", - "read-pkg-up": "2.0.0", - "style-loader": "0.18.2", - "uglifyjs-webpack-plugin": "1.0.0-beta.3", - "webpack": "3.7.1", - "webpack-bundle-analyzer": "2.9.0", - "yargs": "9.0.1" + "read-pkg-up": "3.0.0", + "style-loader": "0.19.1", + "uglifyjs-webpack-plugin": "1.1.5", + "webpack": "3.10.0", + "webpack-bundle-analyzer": "2.9.1", + "yargs": "10.0.3" }, "dependencies": { - "ajv": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.2.3.tgz", - "integrity": "sha1-wG9Zh3jETGsWGrr+NGa4GtGBTtI=", - "dev": true, - "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.0.0", - "json-schema-traverse": "0.3.1", - "json-stable-stringify": "1.0.1" - } - }, - "ajv-keywords": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.0.tgz", - "integrity": "sha1-opbhf3v658HOT34N5T0pyzIWLfA=", - "dev": true - }, "ansi-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", @@ -9616,24 +12824,18 @@ "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", "dev": true, "requires": { - "color-convert": "1.9.0" + "color-convert": "1.9.1" } }, - "camelcase": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", - "dev": true - }, "chalk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", - "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", "dev": true, "requires": { "ansi-styles": "3.2.0", "escape-string-regexp": "1.0.5", - "supports-color": "4.4.0" + "supports-color": "4.5.0" } }, "cliui": { @@ -9660,180 +12862,111 @@ } } }, - "css-loader": { - "version": "0.28.7", - "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-0.28.7.tgz", - "integrity": "sha512-GxMpax8a/VgcfRrVy0gXD6yLd5ePYbXX/5zGgTVYp4wXtJklS8Z2VaUArJgc//f6/Dzil7BaJObdSv8eKKCPgg==", - "dev": true, - "requires": { - "babel-code-frame": "6.26.0", - "css-selector-tokenizer": "0.7.0", - "cssnano": "3.10.0", - "icss-utils": "2.1.0", - "loader-utils": "1.1.0", - "lodash.camelcase": "4.3.0", - "object-assign": "4.1.1", - "postcss": "5.2.18", - "postcss-modules-extract-imports": "1.1.0", - "postcss-modules-local-by-default": "1.2.0", - "postcss-modules-scope": "1.1.0", - "postcss-modules-values": "1.3.0", - "postcss-value-parser": "3.3.0", - "source-list-map": "2.0.0" - } - }, - "enhanced-resolve": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-3.4.1.tgz", - "integrity": "sha1-BCHjOf1xQZs9oT0Smzl5BAIwR24=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "memory-fs": "0.4.1", - "object-assign": "4.1.1", - "tapable": "0.2.8" - } - }, - "file-loader": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/file-loader/-/file-loader-1.1.5.tgz", - "integrity": "sha512-RzGHDatcVNpGISTvCpfUfOGpYuSR7HSsSg87ki+wF6rw1Hm0RALPTiAdsxAq1UwLf0RRhbe22/eHK6nhXspiOQ==", - "dev": true, - "requires": { - "loader-utils": "1.1.0", - "schema-utils": "0.3.0" - } - }, - "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", - "dev": true - }, - "load-json-file": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", - "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "parse-json": "2.2.0", - "pify": "2.3.0", - "strip-bom": "3.0.0" - } - }, - "loader-utils": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz", - "integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=", - "dev": true, - "requires": { - "big.js": "3.2.0", - "emojis-list": "2.1.0", - "json5": "0.5.1" - } - }, - "os-locale": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", - "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", + "cosmiconfig": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-3.1.0.tgz", + "integrity": "sha512-zedsBhLSbPBms+kE7AH4vHg6JsKDz6epSv2/+5XHs8ILHlgDciSJfSWf8sX9aQ52Jb7KI7VswUTsLpR/G0cr2Q==", "dev": true, "requires": { - "execa": "0.7.0", - "lcid": "1.0.0", - "mem": "1.1.0" + "is-directory": "0.3.1", + "js-yaml": "3.10.0", + "parse-json": "3.0.0", + "require-from-string": "2.0.1" } }, - "path-type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", - "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "globby": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/globby/-/globby-7.1.1.tgz", + "integrity": "sha1-+yzP+UAfhgCUXfral0QMypcrhoA=", "dev": true, "requires": { - "pify": "2.3.0" + "array-union": "1.0.2", + "dir-glob": "2.0.0", + "glob": "7.1.2", + "ignore": "3.3.7", + "pify": "3.0.0", + "slash": "1.0.0" } }, - "postcss": { - "version": "5.2.18", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-5.2.18.tgz", - "integrity": "sha512-zrUjRRe1bpXKsX1qAJNJjqZViErVuyEkMTRrwu4ud4sbTtIBRmtaYDrHmcGgmrbsW3MHfmtIf+vJumgQn+PrXg==", + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "load-json-file": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", + "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", "dev": true, "requires": { - "chalk": "1.1.3", - "js-base64": "2.3.2", - "source-map": "0.5.7", - "supports-color": "3.2.3" + "graceful-fs": "4.1.11", + "parse-json": "4.0.0", + "pify": "3.0.0", + "strip-bom": "3.0.0" }, "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" - }, - "dependencies": { - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } - } - }, - "has-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", - "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", - "dev": true - }, - "supports-color": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", - "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", + "parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", "dev": true, "requires": { - "has-flag": "1.0.0" + "error-ex": "1.3.1", + "json-parse-better-errors": "1.0.1" } } } }, + "parse-json": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-3.0.0.tgz", + "integrity": "sha1-+m9HsY4jgm6tMvJj50TQ4ehH+xM=", + "dev": true, + "requires": { + "error-ex": "1.3.1" + } + }, + "path-type": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", + "dev": true, + "requires": { + "pify": "3.0.0" + } + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + }, "read-pkg": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", - "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", + "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", "dev": true, "requires": { - "load-json-file": "2.0.0", + "load-json-file": "4.0.0", "normalize-package-data": "2.4.0", - "path-type": "2.0.0" + "path-type": "3.0.0" } }, "read-pkg-up": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", - "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", + "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", "dev": true, "requires": { "find-up": "2.1.0", - "read-pkg": "2.0.0" + "read-pkg": "3.0.0" } }, - "source-list-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.0.tgz", - "integrity": "sha512-I2UmuJSRr/T8jisiROLU3A3ltr+swpniSmNPI4Ml3ZCX6tVnDsuZzK7F2hl5jTqbZBWCEKlj5HRQiPExXLgE8A==", + "require-from-string": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.1.tgz", + "integrity": "sha1-xUUjPp19pmFunVmt+zn8n1iGdv8=", "dev": true }, "string-width": { @@ -9869,139 +13002,33 @@ "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", "dev": true }, - "style-loader": { - "version": "0.18.2", - "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-0.18.2.tgz", - "integrity": "sha512-WPpJPZGUxWYHWIUMNNOYqql7zh85zGmr84FdTVWq52WTIkqlW9xSxD3QYWi/T31cqn9UNSsietVEgGn2aaSCzw==", - "dev": true, - "requires": { - "loader-utils": "1.1.0", - "schema-utils": "0.3.0" - } - }, "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", "dev": true, "requires": { "has-flag": "2.0.0" } }, - "tapable": { - "version": "0.2.8", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-0.2.8.tgz", - "integrity": "sha1-mTcqXJmb8t8WCvwNdL7U9HlIzSI=", - "dev": true - }, - "webpack": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-3.7.1.tgz", - "integrity": "sha512-8MR+gVfxsvtx4J1UlbRGkUJEpDQUBFmisRmpPO5cVLgF21R8UMChX39OOjDz63a+m/iswGoqATszdZB2VCsYuA==", - "dev": true, - "requires": { - "acorn": "5.1.2", - "acorn-dynamic-import": "2.0.2", - "ajv": "5.2.3", - "ajv-keywords": "2.1.0", - "async": "2.1.4", - "enhanced-resolve": "3.4.1", - "escope": "3.6.0", - "interpret": "1.0.4", - "json-loader": "0.5.7", - "json5": "0.5.1", - "loader-runner": "2.3.0", - "loader-utils": "1.1.0", - "memory-fs": "0.4.1", - "mkdirp": "0.5.1", - "node-libs-browser": "2.0.0", - "source-map": "0.5.7", - "supports-color": "4.4.0", - "tapable": "0.2.8", - "uglifyjs-webpack-plugin": "0.4.6", - "watchpack": "1.4.0", - "webpack-sources": "1.0.1", - "yargs": "8.0.2" - }, - "dependencies": { - "uglifyjs-webpack-plugin": { - "version": "0.4.6", - "resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-0.4.6.tgz", - "integrity": "sha1-uVH0q7a9YX5m9j64kUmOORdj4wk=", - "dev": true, - "requires": { - "source-map": "0.5.7", - "uglify-js": "2.8.29", - "webpack-sources": "1.0.1" - } - }, - "yargs": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-8.0.2.tgz", - "integrity": "sha1-YpmpBVsc78lp/355wdkY3Osiw2A=", - "dev": true, - "requires": { - "camelcase": "4.1.0", - "cliui": "3.2.0", - "decamelize": "1.2.0", - "get-caller-file": "1.0.2", - "os-locale": "2.1.0", - "read-pkg-up": "2.0.0", - "require-directory": "2.1.1", - "require-main-filename": "1.0.1", - "set-blocking": "2.0.0", - "string-width": "2.1.1", - "which-module": "2.0.0", - "y18n": "3.2.1", - "yargs-parser": "7.0.0" - } - } - } - }, - "webpack-sources": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.0.1.tgz", - "integrity": "sha512-05tMxipUCwHqYaVS8xc7sYPTly8PzXayRCB4dTxLhWTqlKUiwH6ezmEe0OSreL1c30LAuA3Zqmc+uEBUGFJDjw==", - "dev": true, - "requires": { - "source-list-map": "2.0.0", - "source-map": "0.5.7" - } - }, - "which-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", - "dev": true - }, "yargs": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-9.0.1.tgz", - "integrity": "sha1-UqzCP+7Kw0BCB47njAwAf1CF20w=", + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-10.0.3.tgz", + "integrity": "sha512-DqBpQ8NAUX4GyPP/ijDGHsJya4tYqLQrjPr95HNsr1YwL3+daCfvBwg7+gIC6IdJhR2kATh3hb61vjzMWEtjdw==", "dev": true, "requires": { - "camelcase": "4.1.0", "cliui": "3.2.0", "decamelize": "1.2.0", + "find-up": "2.1.0", "get-caller-file": "1.0.2", "os-locale": "2.1.0", - "read-pkg-up": "2.0.0", "require-directory": "2.1.1", "require-main-filename": "1.0.1", "set-blocking": "2.0.0", "string-width": "2.1.1", "which-module": "2.0.0", "y18n": "3.2.1", - "yargs-parser": "7.0.0" - } - }, - "yargs-parser": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-7.0.0.tgz", - "integrity": "sha1-jQrELxbqVd69MyyvTEA4s+P139k=", - "dev": true, - "requires": { - "camelcase": "4.1.0" + "yargs-parser": "8.1.0" } } } @@ -10013,10 +13040,21 @@ "dev": true }, "slice-ansi": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", - "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", - "dev": true + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", + "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + } + } }, "slide": { "version": "1.1.6", @@ -10024,10 +13062,122 @@ "integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=", "dev": true }, + "snapdragon": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.1.tgz", + "integrity": "sha1-4StUh/re0+PeoKyR6UAL91tAE3A=", + "dev": true, + "requires": { + "base": "0.11.2", + "debug": "2.6.9", + "define-property": "0.2.5", + "extend-shallow": "2.0.1", + "map-cache": "0.2.2", + "source-map": "0.5.7", + "source-map-resolve": "0.5.1", + "use": "2.0.2" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "0.1.6", + "is-data-descriptor": "0.1.4", + "kind-of": "5.1.0" + } + }, + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "snapdragon-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", + "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", + "dev": true, + "requires": { + "define-property": "1.0.0", + "isobject": "3.0.1", + "snapdragon-util": "3.0.1" + }, + "dependencies": { + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, + "snapdragon-util": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", + "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", + "dev": true, + "requires": { + "kind-of": "3.2.2" + } + }, "sntp": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.0.2.tgz", - "integrity": "sha1-UGQRDwr4X3z9t9a2ekACjOUrSys=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.0" @@ -10194,9 +13344,9 @@ } }, "sockjs-client": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-1.1.2.tgz", - "integrity": "sha1-8CEqhVDkyUaMjM6u79LjSTwDOtU=", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-1.1.4.tgz", + "integrity": "sha1-W6vjhrd15M8U51IJEUUmVAFsixI=", "dev": true, "requires": { "debug": "2.6.9", @@ -10204,7 +13354,7 @@ "faye-websocket": "0.11.1", "inherits": "2.0.3", "json3": "3.3.2", - "url-parse": "1.1.9" + "url-parse": "1.2.0" }, "dependencies": { "faye-websocket": { @@ -10228,9 +13378,9 @@ } }, "source-list-map": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-0.1.8.tgz", - "integrity": "sha1-xVCyq1Qn9rPyH1r+rYjE9Vh7IQY=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.0.tgz", + "integrity": "sha512-I2UmuJSRr/T8jisiROLU3A3ltr+swpniSmNPI4Ml3ZCX6tVnDsuZzK7F2hl5jTqbZBWCEKlj5HRQiPExXLgE8A==", "dev": true }, "source-map": { @@ -10239,6 +13389,19 @@ "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", "dev": true }, + "source-map-resolve": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.1.tgz", + "integrity": "sha512-0KW2wvzfxm8NCTb30z0LMNyPqWCdDGE2viwzUaucqJdkTRXtZiSY3I+2A6nVAjmdOy0I4gU8DwnVVGsk9jvP2A==", + "dev": true, + "requires": { + "atob": "2.0.3", + "decode-uri-component": "0.2.0", + "resolve-url": "0.2.1", + "source-map-url": "0.4.0", + "urix": "0.1.0" + } + }, "source-map-support": { "version": "0.4.18", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", @@ -10248,6 +13411,18 @@ "source-map": "0.5.7" } }, + "source-map-url": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", + "dev": true + }, + "spawn-error-forwarder": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/spawn-error-forwarder/-/spawn-error-forwarder-1.0.0.tgz", + "integrity": "sha1-Gv2Uc46ZmwNG17n8NzvlXgdXcCk=", + "dev": true + }, "spawn-sync": { "version": "1.0.15", "resolved": "https://registry.npmjs.org/spawn-sync/-/spawn-sync-1.0.15.tgz", @@ -10335,14 +13510,53 @@ } }, "split": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", - "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", + "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", "dev": true, "requires": { "through": "2.3.8" } }, + "split-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", + "dev": true, + "requires": { + "extend-shallow": "3.0.2" + }, + "dependencies": { + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "1.0.0", + "is-extendable": "1.0.1" + } + }, + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "2.0.4" + } + } + } + }, + "split2": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-2.2.0.tgz", + "integrity": "sha512-RAb22TG39LhI31MbreBgIuKiIKhVsawfTgEGqKHTK87aG+ul/PB8Sqoi3I7kVdRWiCfrKxK3uo4/YUkpNvhPbw==", + "dev": true, + "requires": { + "through2": "2.0.3" + } + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -10374,16 +13588,88 @@ "safe-buffer": "5.1.1" } }, + "static-extend": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", + "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "dev": true, + "requires": { + "define-property": "0.2.5", + "object-copy": "0.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "0.1.6", + "is-data-descriptor": "0.1.4", + "kind-of": "5.1.0" + } + }, + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, "statuses": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", - "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", - "dev": true - }, - "stealthy-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", - "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==", "dev": true }, "stream-browserify": { @@ -10396,21 +13682,16 @@ "readable-stream": "2.0.6" } }, - "stream-combiner": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", - "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", + "stream-combiner2": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", + "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", "dev": true, "requires": { - "duplexer": "0.1.1" + "duplexer2": "0.1.4", + "readable-stream": "2.0.6" } }, - "stream-consume": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.0.tgz", - "integrity": "sha1-pB6tGm1ggc63n2WwYZAbbY89HQ8=", - "dev": true - }, "stream-each": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/stream-each/-/stream-each-1.2.2.tgz", @@ -10473,9 +13754,9 @@ "dev": true }, "string-replace-loader": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/string-replace-loader/-/string-replace-loader-1.2.0.tgz", - "integrity": "sha1-MXUtIwWE5wA3qA+1D/OcIhvjJsk=", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string-replace-loader/-/string-replace-loader-1.3.0.tgz", + "integrity": "sha512-zj8J2ELc5HWOYFkS3MaRMgaHu+mPTG/EfHHaFesJqXjpaKOAruaONEWt3/Em5Urc6n8qDlvabIN6umiU8lH4QA==", "dev": true, "requires": { "loader-utils": "1.1.0", @@ -10513,7 +13794,7 @@ "dev": true, "requires": { "define-properties": "1.1.2", - "es-abstract": "1.9.0", + "es-abstract": "1.10.0", "function-bind": "1.1.1" } }, @@ -10559,14 +13840,6 @@ "dev": true, "requires": { "get-stdin": "4.0.1" - }, - "dependencies": { - "get-stdin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", - "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", - "dev": true - } } }, "strip-json-comments": { @@ -10576,9 +13849,9 @@ "dev": true }, "style-loader": { - "version": "0.18.1", - "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-0.18.1.tgz", - "integrity": "sha1-avyolTyEKDDl4tyEeWMJiAqX9+g=", + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-0.19.1.tgz", + "integrity": "sha512-IRE+ijgojrygQi3rsqT0U4dd+UcPCqcVvauZpCnQrGAlEe+FUIyrK93bUDScamesjP08JlQNsFJU+KmPedP5Og==", "dev": true, "requires": { "loader-utils": "1.1.0", @@ -10605,9 +13878,9 @@ "dev": true }, "svg-baker": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/svg-baker/-/svg-baker-1.2.13.tgz", - "integrity": "sha512-BfRtOOZ4/Fv32H0pSotQitpnDjHgcYalmYOHW/NdA2FrOQivk8KDxc2EqGHxLCypg1zEcHVlzztx0QESCyrCcg==", + "version": "1.2.17", + "resolved": "https://registry.npmjs.org/svg-baker/-/svg-baker-1.2.17.tgz", + "integrity": "sha512-Tjx9jgFoNpWQPLFgxEXKvCOjbo+8xoAxR9beUcdeR4k+5RFISfteWu6Y6OR7FPEXVBBrQzoZQM5/gSYTVfKxiA==", "dev": true, "requires": { "bluebird": "3.5.1", @@ -10616,20 +13889,189 @@ "image-size": "0.5.5", "loader-utils": "1.1.0", "merge-options": "0.0.64", + "micromatch": "3.1.0", "postcss": "5.2.18", "postcss-prefix-selector": "1.6.0", - "posthtml-rename-id": "1.0.2", - "posthtml-svg-mode": "1.0.0", + "posthtml-rename-id": "1.0.3", + "posthtml-svg-mode": "1.0.2", "query-string": "4.3.4", "traverse": "0.6.6" }, "dependencies": { + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "braces": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.0.tgz", + "integrity": "sha512-P4O8UQRdGiMLWSizsApmXVQDBS6KCt7dSexgLKBmH5Hr1CZq7vsnscFh8oR1sP1ab1Zj0uCHCEzZeV6SfUf3rA==", + "dev": true, + "requires": { + "arr-flatten": "1.1.0", + "array-unique": "0.3.2", + "define-property": "1.0.0", + "extend-shallow": "2.0.1", + "fill-range": "4.0.0", + "isobject": "3.0.1", + "repeat-element": "1.1.2", + "snapdragon": "0.8.1", + "snapdragon-node": "2.1.1", + "split-string": "3.1.0", + "to-regex": "3.0.1" + } + }, "clone": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.1.tgz", "integrity": "sha1-0hfR6WERjjrJpLi7oyhVU79kfNs=", "dev": true }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "dev": true, + "requires": { + "debug": "2.6.9", + "define-property": "0.2.5", + "extend-shallow": "2.0.1", + "posix-character-classes": "0.1.1", + "regex-not": "1.0.0", + "snapdragon": "0.8.1", + "to-regex": "3.0.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + } + } + }, + "extglob": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.3.tgz", + "integrity": "sha512-AyptZexgu7qppEPq59DtN/XJGZDrLcVxSHai+4hdgMMS9EpF4GBvygcWWApno8lL9qSjVpYt7Raao28qzJX1ww==", + "dev": true, + "requires": { + "array-unique": "0.3.2", + "define-property": "1.0.0", + "expand-brackets": "2.1.4", + "extend-shallow": "2.0.1", + "fragment-cache": "0.2.1", + "regex-not": "1.0.0", + "snapdragon": "0.8.1", + "to-regex": "3.0.1" + } + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "dev": true, + "requires": { + "extend-shallow": "2.0.1", + "is-number": "3.0.0", + "repeat-string": "1.6.1", + "to-regex-range": "2.1.1" + } + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "0.1.6", + "is-data-descriptor": "0.1.4", + "kind-of": "5.1.0" + } + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + }, "loader-utils": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz", @@ -10641,6 +14083,27 @@ "json5": "0.5.1" } }, + "micromatch": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.0.tgz", + "integrity": "sha512-3StSelAE+hnRvMs8IdVW7Uhk8CVed5tp+kLLGlBP6WiRAXS21GPGu/Nat4WNPXj2Eoc24B02SaeoyozPMfj0/g==", + "dev": true, + "requires": { + "arr-diff": "4.0.0", + "array-unique": "0.3.2", + "braces": "2.3.0", + "define-property": "1.0.0", + "extend-shallow": "2.0.1", + "extglob": "2.0.3", + "fragment-cache": "0.2.1", + "kind-of": "5.1.0", + "nanomatch": "1.2.6", + "object.pick": "1.3.0", + "regex-not": "1.0.0", + "snapdragon": "0.8.1", + "to-regex": "3.0.1" + } + }, "postcss": { "version": "5.2.18", "resolved": "https://registry.npmjs.org/postcss/-/postcss-5.2.18.tgz", @@ -10648,7 +14111,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "js-base64": "2.3.2", + "js-base64": "2.4.0", "source-map": "0.5.7", "supports-color": "3.2.3" } @@ -10672,13 +14135,13 @@ "requires": { "deepmerge": "1.3.2", "mitt": "1.1.2", - "svg-baker": "1.2.13" + "svg-baker": "1.2.17" } }, "svg-sprite-loader": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/svg-sprite-loader/-/svg-sprite-loader-3.0.5.tgz", - "integrity": "sha1-LoQf3CPn0vY0c1W9hmmZCuLBxWY=", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/svg-sprite-loader/-/svg-sprite-loader-3.6.2.tgz", + "integrity": "sha512-TvPnorRj7Z5b2sVDXnn5nD8AKHWKgyyYtGA+tMgNMdWwQPif9oKdoUQv2NgSOAijMKGC9WTYVm9tAwTzzwPJgA==", "dev": true, "requires": { "bluebird": "3.5.1", @@ -10686,7 +14149,7 @@ "domready": "1.0.8", "escape-string-regexp": "1.0.5", "loader-utils": "1.1.0", - "svg-baker": "1.2.13", + "svg-baker": "1.2.17", "svg-baker-runtime": "1.3.3", "url-slug": "2.0.0" }, @@ -10732,16 +14195,16 @@ } }, "table": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", - "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", + "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", "dev": true, "requires": { - "ajv": "4.11.8", - "ajv-keywords": "1.5.1", - "chalk": "1.1.3", + "ajv": "5.5.2", + "ajv-keywords": "2.1.1", + "chalk": "2.3.0", "lodash": "4.17.4", - "slice-ansi": "0.0.4", + "slice-ansi": "1.0.0", "string-width": "2.1.1" }, "dependencies": { @@ -10751,6 +14214,32 @@ "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", "dev": true }, + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", @@ -10775,6 +14264,15 @@ "requires": { "ansi-regex": "3.0.0" } + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } } } }, @@ -10810,17 +14308,6 @@ "readable-stream": "2.0.6", "split": "1.0.1", "trim": "0.0.1" - }, - "dependencies": { - "split": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", - "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", - "dev": true, - "requires": { - "through": "2.3.8" - } - } } }, "tap-spec": { @@ -10892,6 +14379,15 @@ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true + }, + "resolve": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", + "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==", + "dev": true, + "requires": { + "path-parse": "1.0.5" + } } } }, @@ -10904,6 +14400,32 @@ "global": "4.3.2" } }, + "term-size": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/term-size/-/term-size-1.2.0.tgz", + "integrity": "sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk=", + "dev": true, + "requires": { + "execa": "0.7.0" + }, + "dependencies": { + "execa": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", + "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", + "dev": true, + "requires": { + "cross-spawn": "5.1.0", + "get-stream": "3.0.0", + "is-stream": "1.1.0", + "npm-run-path": "2.0.2", + "p-finally": "1.0.0", + "signal-exit": "3.0.2", + "strip-eof": "1.0.0" + } + } + } + }, "test-exclude": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-4.1.1.tgz", @@ -10917,6 +14439,12 @@ "require-main-filename": "1.0.1" } }, + "text-extensions": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-1.7.0.tgz", + "integrity": "sha512-AKXZeDq230UaSzaO5s3qQUZOaC7iKbzq0jOFL614R7d9R593HLqAOL0cYoqLdkNrjBSOdmoQI06yigq1TSBXAg==", + "dev": true + }, "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -10965,6 +14493,12 @@ } } }, + "thunky": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/thunky/-/thunky-0.1.0.tgz", + "integrity": "sha1-vzAUaCTituZ7Dy16Ssi+smkIaE4=", + "dev": true + }, "tidy-markdown": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/tidy-markdown/-/tidy-markdown-2.0.5.tgz", @@ -10972,14 +14506,22 @@ "dev": true, "requires": { "argparse": "1.0.9", - "front-matter": "2.2.0", + "front-matter": "2.3.0", "html-entities": "1.2.1", "indent": "0.0.2", "js-yaml": "3.10.0", "lodash": "4.17.4", "marked": "0.3.3", "pad": "1.1.0", - "parse5": "3.0.2" + "parse5": "3.0.3" + }, + "dependencies": { + "marked": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.3.tgz", + "integrity": "sha1-CLrZysE3NvbM7dwgI0TxsL8lU5A=", + "dev": true + } } }, "time-stamp": { @@ -10988,6 +14530,12 @@ "integrity": "sha1-lcakRTDhW6jW9KPsuMOj+sRto1c=", "dev": true }, + "timed-out": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", + "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=", + "dev": true + }, "timers-browserify": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz", @@ -10997,33 +14545,142 @@ "process": "0.11.10" } }, - "tmp": { - "version": "0.0.31", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz", - "integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=", + "tmp": { + "version": "0.0.31", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz", + "integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=", + "dev": true, + "requires": { + "os-tmpdir": "1.0.2" + } + }, + "to-array": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", + "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=", + "dev": true + }, + "to-arraybuffer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", + "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=", + "dev": true + }, + "to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", + "dev": true + }, + "to-object-path": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", + "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + } + }, + "to-regex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.1.tgz", + "integrity": "sha1-FTWL7kosg712N3uh3ASdDxiDeq4=", + "dev": true, + "requires": { + "define-property": "0.2.5", + "extend-shallow": "2.0.1", + "regex-not": "1.0.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "0.1.6", + "is-data-descriptor": "0.1.4", + "kind-of": "5.1.0" + } + }, + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", "dev": true, "requires": { - "os-tmpdir": "1.0.2" + "is-number": "3.0.0", + "repeat-string": "1.6.1" + }, + "dependencies": { + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + } + } } }, - "to-array": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", - "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=", - "dev": true - }, - "to-arraybuffer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", - "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=", - "dev": true - }, - "to-fast-properties": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", - "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", - "dev": true - }, "toposort": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/toposort/-/toposort-1.0.6.tgz", @@ -11045,189 +14702,139 @@ "integrity": "sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc=", "dev": true }, - "travis-ci": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/travis-ci/-/travis-ci-2.1.1.tgz", - "integrity": "sha1-mGliZa+CeuNXbzGqBth250tLCC4=", + "travis-deploy-once": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/travis-deploy-once/-/travis-deploy-once-4.3.0.tgz", + "integrity": "sha512-VvqZO7+/bfMrzWsSBUB+9PQNm6TXi/JRWT2CTgQMR4bw8h9UOeK2r3VDOz+RKxQE7ade0mdy7ifTXMNKHaIKeQ==", "dev": true, "requires": { - "github": "0.1.16", - "lodash": "1.3.1", - "request": "2.74.0", - "underscore.string": "2.2.1" + "babel-polyfill": "6.26.0", + "babel-preset-env": "1.6.1", + "babel-register": "6.26.0", + "chalk": "2.3.0", + "execa": "0.8.0", + "got": "8.0.1", + "p-retry": "1.0.0", + "semver": "5.4.1", + "update-notifier": "2.3.0", + "url-join": "2.0.2", + "yargs": "10.0.3" }, "dependencies": { - "assert-plus": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", - "dev": true - }, - "aws-sign2": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", - "dev": true - }, - "boom": { - "version": "2.10.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", - "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", - "dev": true, - "requires": { - "hoek": "2.16.3" - } - }, - "caseless": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", - "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=", + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", "dev": true }, - "cryptiles": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", - "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", - "dev": true, - "requires": { - "boom": "2.10.1" - } - }, - "form-data": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-1.0.1.tgz", - "integrity": "sha1-rjFduaSQf6BlUCMEpm13M0de43w=", + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", "dev": true, "requires": { - "async": "2.1.4", - "combined-stream": "1.0.5", - "mime-types": "2.1.17" + "color-convert": "1.9.1" } }, - "github": { - "version": "0.1.16", - "resolved": "https://registry.npmjs.org/github/-/github-0.1.16.tgz", - "integrity": "sha1-iV0qhbD+t5gNiawM5PRNyqA/F7U=", - "dev": true - }, - "har-validator": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", - "integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=", + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", "dev": true, "requires": { - "chalk": "1.1.3", - "commander": "2.11.0", - "is-my-json-valid": "2.16.1", - "pinkie-promise": "2.0.1" + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" } }, - "hawk": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", "dev": true, "requires": { - "boom": "2.10.1", - "cryptiles": "2.0.5", - "hoek": "2.16.3", - "sntp": "1.0.9" + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wrap-ansi": "2.1.0" + }, + "dependencies": { + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + } } }, - "hoek": { - "version": "2.16.3", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", "dev": true }, - "http-signature": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { - "assert-plus": "0.2.0", - "jsprim": "1.4.1", - "sshpk": "1.13.1" + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } + } } }, - "lodash": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-1.3.1.tgz", - "integrity": "sha1-pGY7U2hriV/wdOK6UE37dqjit3A=", - "dev": true - }, - "node-uuid": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", - "integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc=", - "dev": true - }, - "qs": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.2.3.tgz", - "integrity": "sha1-HPyyXBCpsrSDBT/zn138kjOQjP4=", - "dev": true - }, - "request": { - "version": "2.74.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.74.0.tgz", - "integrity": "sha1-dpPKdou7DqXIzgjAhKRe+gW4kqs=", + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", "dev": true, "requires": { - "aws-sign2": "0.6.0", - "aws4": "1.6.0", - "bl": "1.1.2", - "caseless": "0.11.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "1.0.1", - "har-validator": "2.0.6", - "hawk": "3.1.3", - "http-signature": "1.1.1", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.17", - "node-uuid": "1.4.8", - "oauth-sign": "0.8.2", - "qs": "6.2.3", - "stringstream": "0.0.5", - "tough-cookie": "2.3.3", - "tunnel-agent": "0.4.3" + "has-flag": "2.0.0" } }, - "sntp": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", - "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", + "yargs": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-10.0.3.tgz", + "integrity": "sha512-DqBpQ8NAUX4GyPP/ijDGHsJya4tYqLQrjPr95HNsr1YwL3+daCfvBwg7+gIC6IdJhR2kATh3hb61vjzMWEtjdw==", "dev": true, "requires": { - "hoek": "2.16.3" + "cliui": "3.2.0", + "decamelize": "1.2.0", + "find-up": "2.1.0", + "get-caller-file": "1.0.2", + "os-locale": "2.1.0", + "require-directory": "2.1.1", + "require-main-filename": "1.0.1", + "set-blocking": "2.0.0", + "string-width": "2.1.1", + "which-module": "2.0.0", + "y18n": "3.2.1", + "yargs-parser": "8.1.0" } - }, - "tunnel-agent": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz", - "integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us=", - "dev": true } } }, - "travis-deploy-once": { - "version": "1.0.0-node-0.10-support", - "resolved": "https://registry.npmjs.org/travis-deploy-once/-/travis-deploy-once-1.0.0-node-0.10-support.tgz", - "integrity": "sha1-mOzOfZWy9Lpdze7r9Uud+HcT1eY=", - "dev": true, - "requires": { - "babel-polyfill": "6.23.0", - "bluebird": "3.5.1", - "request": "2.83.0", - "request-promise": "4.2.2", - "travis-ci": "2.1.1" - } - }, "trim": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", @@ -11240,18 +14847,18 @@ "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", "dev": true }, + "trim-off-newlines": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz", + "integrity": "sha1-n5up2e+odkw4dpi8v+sshI8RrbM=", + "dev": true + }, "trim-right": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", "dev": true }, - "tryit": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz", - "integrity": "sha1-OTvnMKlEb9Hq1tpZoBQwjzbCics=", - "dev": true - }, "tty-browserify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", @@ -11299,6 +14906,12 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "ua-parser-js": { + "version": "0.7.17", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.17.tgz", + "integrity": "sha512-uRdSdu1oA1rncCQL7sCj8vSyZkgtL7faaw9Tc9rZ3mGgraQ7+Pdx7w5mnOSF3gw9ZNG6oc+KXfkon3bKuROm0g==", + "dev": true + }, "uglify-js": { "version": "2.8.29", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", @@ -11318,74 +14931,45 @@ "optional": true }, "uglifyjs-webpack-plugin": { - "version": "1.0.0-beta.3", - "resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.0.0-beta.3.tgz", - "integrity": "sha512-4fpQrnoYEuzAwDxI2zLrKMgrknaWu71CpG4XaMRXWWyUJ7yBM4ueIhNNf0/AcKVSUgBpVudi1i9h9lWdfrU7ZQ==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.1.5.tgz", + "integrity": "sha512-YBGc9G7dv12Vjx8vUQs54DZgAXVf04LlG6dNNiEbTZjL3PbUqiY4uPB9Kv+fUJaqRskEGva/lS7sh08yJr7jnA==", "dev": true, "requires": { - "cacache": "9.3.0", + "cacache": "10.0.1", "find-cache-dir": "1.0.0", "schema-utils": "0.3.0", - "source-map": "0.5.7", - "uglify-es": "3.1.3", - "webpack-sources": "1.0.1", - "worker-farm": "1.5.0" + "serialize-javascript": "1.4.0", + "source-map": "0.6.1", + "uglify-es": "3.2.2", + "webpack-sources": "1.1.0", + "worker-farm": "1.5.2" }, "dependencies": { - "find-cache-dir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-1.0.0.tgz", - "integrity": "sha1-kojj6ePMN0hxfTnq3hfPcfww7m8=", - "dev": true, - "requires": { - "commondir": "1.0.1", - "make-dir": "1.0.0", - "pkg-dir": "2.0.0" - } - }, - "pkg-dir": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", - "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", - "dev": true, - "requires": { - "find-up": "2.1.0" - } - }, - "source-list-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.0.tgz", - "integrity": "sha512-I2UmuJSRr/T8jisiROLU3A3ltr+swpniSmNPI4Ml3ZCX6tVnDsuZzK7F2hl5jTqbZBWCEKlj5HRQiPExXLgE8A==", + "commander": { + "version": "2.12.2", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz", + "integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==", "dev": true }, - "uglify-es": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.1.3.tgz", - "integrity": "sha512-Nuo5gkv/Q6PmLa+Ui2LvK+87YdMAcuXfRIWF0uVfkHVSfpT3Ue0euCSu4t0b8xv4Bt05lmXUT8bLI9OmnyPj8A==", - "dev": true, - "requires": { - "commander": "2.11.0", - "source-map": "0.5.7" - } + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true }, - "webpack-sources": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.0.1.tgz", - "integrity": "sha512-05tMxipUCwHqYaVS8xc7sYPTly8PzXayRCB4dTxLhWTqlKUiwH6ezmEe0OSreL1c30LAuA3Zqmc+uEBUGFJDjw==", + "uglify-es": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.2.2.tgz", + "integrity": "sha512-l+s5VLzFwGJfS+fbqaGf/Dfwo1MF13jLOF2ekL0PytzqEqQ6cVppvHf4jquqFok+35USMpKjqkYxy6pQyUcuug==", "dev": true, "requires": { - "source-list-map": "2.0.0", - "source-map": "0.5.7" + "commander": "2.12.2", + "source-map": "0.6.1" } } } }, - "uid-number": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.5.tgz", - "integrity": "sha1-Wj2yPvXb1VuB/ODsmirG/M3ruB4=", - "dev": true - }, "ultron": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz", @@ -11398,18 +14982,38 @@ "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", "dev": true }, - "underscore.string": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.2.1.tgz", - "integrity": "sha1-18D6KvXVoaZ/QlPa7pgTLnM/Dxk=", - "dev": true - }, "unidecode": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/unidecode/-/unidecode-0.1.8.tgz", "integrity": "sha1-77swFTi8RSRqmsjFWdcvAVMFBT4=", "dev": true }, + "union-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", + "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "dev": true, + "requires": { + "arr-union": "3.1.0", + "get-value": "2.0.6", + "is-extendable": "0.1.1", + "set-value": "0.4.3" + }, + "dependencies": { + "set-value": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", + "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", + "dev": true, + "requires": { + "extend-shallow": "2.0.1", + "is-extendable": "0.1.1", + "is-plain-object": "2.0.4", + "to-object-path": "0.3.0" + } + } + } + }, "uniq": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz", @@ -11449,10 +15053,20 @@ "imurmurhash": "0.1.4" } }, + "unique-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", + "integrity": "sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo=", + "dev": true, + "requires": { + "crypto-random-string": "1.0.0" + } + }, "universalify": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz", - "integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc=" + "integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc=", + "dev": true }, "unpipe": { "version": "1.0.0", @@ -11460,12 +15074,124 @@ "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", "dev": true }, + "unset-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", + "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "dev": true, + "requires": { + "has-value": "0.3.1", + "isobject": "3.0.1" + }, + "dependencies": { + "has-value": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", + "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "dev": true, + "requires": { + "get-value": "2.0.6", + "has-values": "0.1.4", + "isobject": "2.1.0" + }, + "dependencies": { + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + } + } + }, + "has-values": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "dev": true + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, + "unzip-response": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-2.0.1.tgz", + "integrity": "sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c=", + "dev": true + }, + "update-notifier": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-2.3.0.tgz", + "integrity": "sha1-TognpruRUUCrCTVZ1wFOPruDdFE=", + "dev": true, + "requires": { + "boxen": "1.3.0", + "chalk": "2.3.0", + "configstore": "3.1.1", + "import-lazy": "2.1.0", + "is-installed-globally": "0.1.0", + "is-npm": "1.0.0", + "latest-version": "3.1.0", + "semver-diff": "2.1.0", + "xdg-basedir": "3.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } + } + }, "upper-case": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz", "integrity": "sha1-9rRQHC7EzdJrp4vnIilh3ndiFZg=", "dev": true }, + "urix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", + "dev": true + }, "url": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", @@ -11484,14 +15210,21 @@ } } }, + "url-join": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/url-join/-/url-join-2.0.2.tgz", + "integrity": "sha1-wHJ1aWetJLi1nldBVRyqx49QuLc=", + "dev": true + }, "url-loader": { - "version": "0.5.8", - "resolved": "https://registry.npmjs.org/url-loader/-/url-loader-0.5.8.tgz", - "integrity": "sha1-uRg7GAHg+EdxhnNnMEC8ncHHFcU=", + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/url-loader/-/url-loader-0.6.2.tgz", + "integrity": "sha512-h3qf9TNn53BpuXTTcpC+UehiRrl0Cv45Yr/xWayApjw6G8Bg2dGke7rIwDQ39piciWCWrC+WiqLjOh3SUp9n0Q==", "dev": true, "requires": { "loader-utils": "1.1.0", - "mime": "1.3.6" + "mime": "1.6.0", + "schema-utils": "0.3.0" }, "dependencies": { "loader-utils": { @@ -11504,19 +15237,13 @@ "emojis-list": "2.1.0", "json5": "0.5.1" } - }, - "mime": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.3.6.tgz", - "integrity": "sha1-WR2E02U6awtKO5343lqoEI5y5eA=", - "dev": true } } }, "url-parse": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.1.9.tgz", - "integrity": "sha1-xn8dd11R8KGJEd17P/rSe7nlvRk=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.2.0.tgz", + "integrity": "sha512-DT1XbYAfmQP65M/mE6OALxmXzZ/z1+e5zk2TcSKe/KiYbNGZxgtttzC0mR/sjopbpOXcbniq7eIKmocJnUWlEw==", "dev": true, "requires": { "querystringify": "1.0.0", @@ -11531,6 +15258,23 @@ } } }, + "url-parse-lax": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", + "integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=", + "dev": true, + "requires": { + "prepend-http": "2.0.0" + }, + "dependencies": { + "prepend-http": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", + "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", + "dev": true + } + } + }, "url-slug": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/url-slug/-/url-slug-2.0.0.tgz", @@ -11540,13 +15284,110 @@ "unidecode": "0.1.8" } }, - "user-home": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", - "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", + "url-template": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/url-template/-/url-template-2.0.8.tgz", + "integrity": "sha1-/FZaPMy/93MMd19WQflVV5FDnyE=", + "dev": true + }, + "url-to-options": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/url-to-options/-/url-to-options-1.0.1.tgz", + "integrity": "sha1-FQWgOiiaSMvXpDTvuu7FBV9WM6k=", + "dev": true + }, + "use": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/use/-/use-2.0.2.tgz", + "integrity": "sha1-riig1y+TvyJCKhii43mZMRLeyOg=", "dev": true, "requires": { - "os-homedir": "1.0.2" + "define-property": "0.2.5", + "isobject": "3.0.1", + "lazy-cache": "2.0.2" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "0.1.6" + } + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "0.1.6", + "is-data-descriptor": "0.1.4", + "kind-of": "5.1.0" + } + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + }, + "lazy-cache": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-2.0.2.tgz", + "integrity": "sha1-uRkKT5EzVGlIQIWfio9whNiCImQ=", + "dev": true, + "requires": { + "set-getter": "0.1.0" + } + } } }, "useragent": { @@ -11609,6 +15450,15 @@ "spdx-expression-parse": "1.0.4" } }, + "validate-npm-package-name": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-3.0.0.tgz", + "integrity": "sha1-X6kS2B630MdK/BQN5zF/DKffQ34=", + "dev": true, + "requires": { + "builtins": "1.0.3" + } + }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -11647,24 +15497,26 @@ "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=", "dev": true }, - "walk": { - "version": "2.3.9", - "resolved": "https://registry.npmjs.org/walk/-/walk-2.3.9.tgz", - "integrity": "sha1-MbTbZnjyrgHDnqn7hyWpAx5Vins=", - "dev": true, - "requires": { - "foreachasync": "3.0.0" - } - }, "watchpack": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.4.0.tgz", "integrity": "sha1-ShRyvLuVK9Cpu0A2gB+VTfs5+qw=", "dev": true, "requires": { - "async": "2.1.4", + "async": "2.6.0", "chokidar": "1.7.0", "graceful-fs": "4.1.11" + }, + "dependencies": { + "async": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", + "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", + "dev": true, + "requires": { + "lodash": "4.17.4" + } + } } }, "wbuf": { @@ -11677,70 +15529,191 @@ } }, "webpack": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-2.6.1.tgz", - "integrity": "sha1-LgRX8KuxrF3zqxBsacZy8jZ4Xwc=", + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-3.10.0.tgz", + "integrity": "sha512-fxxKXoicjdXNUMY7LIdY89tkJJJ0m1Oo8PQutZ5rLgWbV5QVKI15Cn7+/IHnRTd3vfKfiwBx6SBqlorAuNA8LA==", "dev": true, "requires": { - "acorn": "5.1.2", + "acorn": "5.3.0", "acorn-dynamic-import": "2.0.2", - "ajv": "4.11.8", - "ajv-keywords": "1.5.1", - "async": "2.1.4", + "ajv": "5.5.2", + "ajv-keywords": "2.1.1", + "async": "2.6.0", "enhanced-resolve": "3.4.1", - "interpret": "1.0.4", + "escope": "3.6.0", + "interpret": "1.1.0", "json-loader": "0.5.7", "json5": "0.5.1", "loader-runner": "2.3.0", - "loader-utils": "0.2.17", + "loader-utils": "1.1.0", "memory-fs": "0.4.1", "mkdirp": "0.5.1", - "node-libs-browser": "2.0.0", + "node-libs-browser": "2.1.0", "source-map": "0.5.7", - "supports-color": "3.2.3", + "supports-color": "4.5.0", "tapable": "0.2.8", - "uglify-js": "2.8.29", + "uglifyjs-webpack-plugin": "0.4.6", "watchpack": "1.4.0", - "webpack-sources": "0.2.3", - "yargs": "6.6.0" + "webpack-sources": "1.1.0", + "yargs": "8.0.2" }, "dependencies": { - "camelcase": { + "ansi-regex": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", - "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "async": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", + "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", + "dev": true, + "requires": { + "lodash": "4.17.4" + } + }, + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", + "dev": true + }, + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "dev": true, + "requires": { + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wrap-ansi": "2.1.0" + }, + "dependencies": { + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + } + } + }, + "enhanced-resolve": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-3.4.1.tgz", + "integrity": "sha1-BCHjOf1xQZs9oT0Smzl5BAIwR24=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "memory-fs": "0.4.1", + "object-assign": "4.1.1", + "tapable": "0.2.8" + } + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", "dev": true }, - "cliui": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", - "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "load-json-file": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "parse-json": "2.2.0", + "pify": "2.3.0", + "strip-bom": "3.0.0" + } + }, + "loader-utils": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz", + "integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=", "dev": true, "requires": { - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wrap-ansi": "2.1.0" + "big.js": "3.2.0", + "emojis-list": "2.1.0", + "json5": "0.5.1" } }, - "enhanced-resolve": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-3.4.1.tgz", - "integrity": "sha1-BCHjOf1xQZs9oT0Smzl5BAIwR24=", + "path-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", + "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "memory-fs": "0.4.1", - "object-assign": "4.1.1", - "tapable": "0.2.8" + "pify": "2.3.0" + } + }, + "read-pkg": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", + "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "dev": true, + "requires": { + "load-json-file": "2.0.0", + "normalize-package-data": "2.4.0", + "path-type": "2.0.0" + } + }, + "read-pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", + "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "dev": true, + "requires": { + "find-up": "2.1.0", + "read-pkg": "2.0.0" + } + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } + } } }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, "supports-color": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", - "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", "dev": true, "requires": { - "has-flag": "1.0.0" + "has-flag": "2.0.0" } }, "tapable": { @@ -11749,46 +15722,66 @@ "integrity": "sha1-mTcqXJmb8t8WCvwNdL7U9HlIzSI=", "dev": true }, + "uglifyjs-webpack-plugin": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-0.4.6.tgz", + "integrity": "sha1-uVH0q7a9YX5m9j64kUmOORdj4wk=", + "dev": true, + "requires": { + "source-map": "0.5.7", + "uglify-js": "2.8.29", + "webpack-sources": "1.1.0" + } + }, "yargs": { - "version": "6.6.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-6.6.0.tgz", - "integrity": "sha1-eC7CHvQDNF+DCoCMo9UTr1YGUgg=", + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-8.0.2.tgz", + "integrity": "sha1-YpmpBVsc78lp/355wdkY3Osiw2A=", "dev": true, "requires": { - "camelcase": "3.0.0", + "camelcase": "4.1.0", "cliui": "3.2.0", "decamelize": "1.2.0", "get-caller-file": "1.0.2", - "os-locale": "1.4.0", - "read-pkg-up": "1.0.1", + "os-locale": "2.1.0", + "read-pkg-up": "2.0.0", "require-directory": "2.1.1", "require-main-filename": "1.0.1", "set-blocking": "2.0.0", - "string-width": "1.0.2", - "which-module": "1.0.0", + "string-width": "2.1.1", + "which-module": "2.0.0", "y18n": "3.2.1", - "yargs-parser": "4.2.1" + "yargs-parser": "7.0.0" + } + }, + "yargs-parser": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-7.0.0.tgz", + "integrity": "sha1-jQrELxbqVd69MyyvTEA4s+P139k=", + "dev": true, + "requires": { + "camelcase": "4.1.0" } } } }, "webpack-bundle-analyzer": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-2.9.0.tgz", - "integrity": "sha1-tYvDTMMLJ//brz0AvyerpvopxuM=", + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-2.9.1.tgz", + "integrity": "sha512-a+UcvlsXvCmclNgfThT8PVyuJKd029By7CxkYEbNNCfs0Lqj9gagjkdv3S3MBvCIKBaUGYs8l4UpiVI0bFoh2Q==", "dev": true, "requires": { - "acorn": "5.1.2", + "acorn": "5.3.0", "chalk": "1.1.3", "commander": "2.11.0", "ejs": "2.5.7", "express": "4.16.2", - "filesize": "3.5.10", + "filesize": "3.5.11", "gzip-size": "3.0.0", "lodash": "4.17.4", "mkdirp": "0.5.1", "opener": "1.4.3", - "ws": "2.3.1" + "ws": "3.3.3" }, "dependencies": { "gzip-size": { @@ -11800,65 +15793,70 @@ "duplexer": "0.1.1" } }, - "safe-buffer": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz", - "integrity": "sha1-0mPKVGls2KMGtcplUekt5XkY++c=", - "dev": true - }, "ultron": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.0.tgz", - "integrity": "sha1-sHoualQagV/Go0zNRTO67DB8qGQ=", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", + "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==", "dev": true }, "ws": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-2.3.1.tgz", - "integrity": "sha1-a5Sz5EfLajY/eF6vlK9jWejoHIA=", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", + "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", "dev": true, "requires": { - "safe-buffer": "5.0.1", - "ultron": "1.1.0" + "async-limiter": "1.0.0", + "safe-buffer": "5.1.1", + "ultron": "1.1.1" } } } }, "webpack-dev-middleware": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-1.12.0.tgz", - "integrity": "sha1-007++y7dp+HTtdvgcolRMhllFwk=", + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-1.12.2.tgz", + "integrity": "sha512-FCrqPy1yy/sN6U/SaEZcHKRXGlqU0DUaEBL45jkUYoB8foVb6wCnbIJ1HKIx+qUFTW+3JpVcCJCxZ8VATL4e+A==", "dev": true, "requires": { "memory-fs": "0.4.1", - "mime": "1.4.1", + "mime": "1.6.0", "path-is-absolute": "1.0.1", "range-parser": "1.2.0", "time-stamp": "2.0.0" } }, "webpack-dev-server": { - "version": "2.4.5", - "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-2.4.5.tgz", - "integrity": "sha1-MThM6BE2vhCAtLTN4OubkOVO5s8=", + "version": "2.9.7", + "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-2.9.7.tgz", + "integrity": "sha512-Pu7uoQFgQj5RE5wmlfkpYSzihMKxulwEuO2xCsaMnAnyRSApwoVi3B8WCm9XbigyWTHaIMzYGkB90Vr6leAeTQ==", "dev": true, "requires": { "ansi-html": "0.0.7", + "array-includes": "3.0.3", + "bonjour": "3.5.0", "chokidar": "1.7.0", "compression": "1.7.1", - "connect-history-api-fallback": "1.4.0", + "connect-history-api-fallback": "1.5.0", + "debug": "3.1.0", + "del": "3.0.0", "express": "4.16.2", "html-entities": "1.2.1", "http-proxy-middleware": "0.17.4", - "opn": "4.0.2", + "import-local": "0.1.1", + "internal-ip": "1.2.0", + "ip": "1.1.5", + "killable": "1.0.0", + "loglevel": "1.6.0", + "opn": "5.1.0", "portfinder": "1.0.13", + "selfsigned": "1.10.1", "serve-index": "1.9.1", "sockjs": "0.3.18", - "sockjs-client": "1.1.2", + "sockjs-client": "1.1.4", "spdy": "3.4.7", "strip-ansi": "3.0.1", - "supports-color": "3.2.3", - "webpack-dev-middleware": "1.12.0", + "supports-color": "4.5.0", + "webpack-dev-middleware": "1.12.2", "yargs": "6.6.0" }, "dependencies": { @@ -11879,15 +15877,65 @@ "wrap-ansi": "2.1.0" } }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "del": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/del/-/del-3.0.0.tgz", + "integrity": "sha1-U+z2mf/LyzljdpGrE7rxYIGXZuU=", + "dev": true, + "requires": { + "globby": "6.1.0", + "is-path-cwd": "1.0.0", + "is-path-in-cwd": "1.0.0", + "p-map": "1.2.0", + "pify": "3.0.0", + "rimraf": "2.6.2" + } + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "os-locale": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", + "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", + "dev": true, + "requires": { + "lcid": "1.0.0" + } + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + }, "supports-color": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", - "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", "dev": true, "requires": { - "has-flag": "1.0.0" + "has-flag": "2.0.0" } }, + "which-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", + "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=", + "dev": true + }, "yargs": { "version": "6.6.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-6.6.0.tgz", @@ -11908,23 +15956,32 @@ "y18n": "3.2.1", "yargs-parser": "4.2.1" } + }, + "yargs-parser": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-4.2.1.tgz", + "integrity": "sha1-KczqwNxPA8bIe0qfIX3RjJ90hxw=", + "dev": true, + "requires": { + "camelcase": "3.0.0" + } } } }, "webpack-sources": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-0.2.3.tgz", - "integrity": "sha1-F8Yr+vE8cH+dAsR54Nzd6DgGl/s=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.1.0.tgz", + "integrity": "sha512-aqYp18kPphgoO5c/+NaUvEeACtZjMESmDChuD3NBciVpah3XpMEU9VAAtIaB1BsfJWWTSdv8Vv1m3T0aRk2dUw==", "dev": true, "requires": { - "source-list-map": "1.1.2", - "source-map": "0.5.7" + "source-list-map": "2.0.0", + "source-map": "0.6.1" }, "dependencies": { - "source-list-map": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-1.1.2.tgz", - "integrity": "sha1-mIkBnRAkzOVc3AaUmDN+9hhqEaE=", + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true } } @@ -11936,13 +15993,19 @@ "dev": true, "requires": { "http-parser-js": "0.4.9", - "websocket-extensions": "0.1.2" + "websocket-extensions": "0.1.3" } }, "websocket-extensions": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.2.tgz", - "integrity": "sha1-Dhh4HeYpoYMIzhSBZQ9n/6JpOl0=", + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.3.tgz", + "integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==", + "dev": true + }, + "whatwg-fetch": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz", + "integrity": "sha1-nITsLc9oGH/wC8ZOEnS0QhduHIQ=", "dev": true }, "whet.extend": { @@ -11961,9 +16024,9 @@ } }, "which-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", - "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "dev": true }, "wide-align": { @@ -11971,10 +16034,53 @@ "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz", "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==", "dev": true, + "optional": true, "requires": { "string-width": "1.0.2" } }, + "widest-line": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-2.0.0.tgz", + "integrity": "sha1-AUKk6KJD+IgsAjOqDgKBqnYVInM=", + "dev": true, + "requires": { + "string-width": "2.1.1" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } + } + } + }, "window-size": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", @@ -11994,22 +16100,23 @@ "dev": true }, "worker-farm": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.5.0.tgz", - "integrity": "sha512-DHRiUggxtbruaTwnLDm2/BRDKZIoOYvrgYUj5Bam4fU6Gtvc0FaEyoswFPBjMXAweGW2H4BDNIpy//1yXXuaqQ==", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.5.2.tgz", + "integrity": "sha512-XxiQ9kZN5n6mmnW+mFJ+wXjNNI/Nx4DIdaAKLX1Bn6LYBWlN/zaBhu34DQYPZ1AJobQuu67S2OfDdNSVULvXkQ==", "dev": true, "requires": { - "errno": "0.1.4", + "errno": "0.1.6", "xtend": "4.0.1" } }, "worker-loader": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/worker-loader/-/worker-loader-0.8.0.tgz", - "integrity": "sha1-E1gpYNzX1wDcgp0/0lKnVhaWFn4=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/worker-loader/-/worker-loader-1.1.0.tgz", + "integrity": "sha512-W91q8Wi1JxbzFQZuLJlFK4x8UuWjKgeOX9IMMyng007K0UkP6I8lOejckoCWY61QmnJq2x9qZ/Viru+uF8g6nA==", "dev": true, "requires": { - "loader-utils": "1.1.0" + "loader-utils": "1.1.0", + "schema-utils": "0.3.0" }, "dependencies": { "loader-utils": { @@ -12049,6 +16156,17 @@ "mkdirp": "0.5.1" } }, + "write-file-atomic": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.3.0.tgz", + "integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "imurmurhash": "0.1.4", + "signal-exit": "3.0.2" + } + }, "ws": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/ws/-/ws-1.1.2.tgz", @@ -12065,6 +16183,12 @@ "integrity": "sha1-OS2LotDxw00e4tYw8V0O+2jhBIo=", "dev": true }, + "xdg-basedir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-3.0.0.tgz", + "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=", + "dev": true + }, "xml-char-classes": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/xml-char-classes/-/xml-char-classes-1.0.0.tgz", @@ -12132,18 +16256,18 @@ } }, "yargs-parser": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-4.2.1.tgz", - "integrity": "sha1-KczqwNxPA8bIe0qfIX3RjJ90hxw=", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-8.1.0.tgz", + "integrity": "sha512-yP+6QqN8BmrgW2ggLtTbdrOyBNSI7zBa4IykmiV5R1wl1JWNxQvWhMfMdmzIYtKU7oP3OOInY/tl2ov3BDjnJQ==", "dev": true, "requires": { - "camelcase": "3.0.0" + "camelcase": "4.1.0" }, "dependencies": { "camelcase": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", - "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", "dev": true } } diff --git a/package.json b/package.json index bd803dc14af..6f3e9e7ffef 100644 --- a/package.json +++ b/package.json @@ -42,9 +42,9 @@ }, "scripts": { "size": "size-limit --why --config ./webpack.config.js", - "validate": "prettier --single-quote --trailing-comma es5 --print-width 100 --list-different \"Sources/**/*.js\"", - "reformat": "prettier --single-quote --trailing-comma es5 --print-width 100 --write \"Sources/**/*.js\"", - "reformat-only": "prettier --single-quote --trailing-comma es5 --print-width 100 --write", + "validate": "prettier --config ./prettier.config.js --list-different \"Sources/**/*.js\"", + "reformat": "prettier --config ./prettier.config.js --write \"Sources/**/*.js\"", + "reformat-only": "prettier --single-quote --trailing-comma es5 --print-width 80 --arrow-parens always --write", "doc": "kw-doc -c ./Documentation/config.js", "doc:www": "npm t -- --single-run && kw-doc -c ./Documentation/config.js -s", "doc:publish": "kw-doc -c ./Documentation/config.js -mp", diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 00000000000..ed60cd84ea7 --- /dev/null +++ b/prettier.config.js @@ -0,0 +1,6 @@ +module.exports = { + printWidth: 80, + singleQuote: true, + trailingComma: 'es5', + arrowParens: 'always', +};